第三方产品信息导入导出代码提交

master
郑明梁 3 years ago
parent a25f2c8e57
commit c05c55d808

@ -0,0 +1,222 @@
package com.glxp.api.controller.thrsys;
import com.github.pagehelper.PageInfo;
import com.glxp.api.common.enums.ResultEnum;
import com.glxp.api.common.res.BaseResponse;
import com.glxp.api.common.util.ResultVOUtils;
import com.glxp.api.constant.BasicProcessStatus;
import com.glxp.api.entity.basic.BasicThirdSysDetailEntity;
import com.glxp.api.entity.thrsys.FilterThrCorpExportLogRequest;
import com.glxp.api.entity.thrsys.ThrCorpEntity;
import com.glxp.api.entity.thrsys.ThrCorpExportLogEntity;
import com.glxp.api.http.ErpBasicClient;
import com.glxp.api.req.system.DeleteRequest;
import com.glxp.api.req.thrsys.FilterThrCorpImportLogRequest;
import com.glxp.api.req.thrsys.FilterThrCorpRequest;
import com.glxp.api.req.thrsys.ThrCorpExportRequest;
import com.glxp.api.req.thrsys.ThrUnitMaintainFilterRequest;
import com.glxp.api.res.PageSimpleResponse;
import com.glxp.api.res.thrsys.ThrCorpsResponse;
import com.glxp.api.service.thrsys.ThrCorpExportLogService;
import com.glxp.api.service.thrsys.ThrCorpService;
import com.glxp.api.service.thrsys.ThrCorpsDlService;
import com.glxp.api.util.CustomUtil;
import org.springframework.beans.BeanUtils;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.util.Date;
import java.util.List;
import java.util.stream.Collectors;
/**
*
*/
@RestController
public class ThrCorpExportLogController {
@Resource
ThrCorpExportLogService thrCorpExportLogService;
@Resource
private ThrCorpService thrCorpService;
@Resource
ThrCorpsDlService thrCorpsDlService;
@Resource
private ErpBasicClient erpBasicClient;
@GetMapping("/udiwms/thrCorp/exportLog/filter")
public BaseResponse filter(FilterThrCorpExportLogRequest filterThrCorpExportLogRequest,
BindingResult bindingResult) {
if (bindingResult.hasErrors()) {
return ResultVOUtils.error(ResultEnum.PARAM_VERIFY_FALL, bindingResult.getFieldError().getDefaultMessage());
}
List<ThrCorpExportLogEntity> thrCorpExportLogEntities
= thrCorpExportLogService.filterThrCorpExportLog(filterThrCorpExportLogRequest);
PageInfo<ThrCorpExportLogEntity> pageInfo;
pageInfo = new PageInfo<>(thrCorpExportLogEntities);
PageSimpleResponse<ThrCorpExportLogEntity> pageSimpleResponse = new PageSimpleResponse<>();
pageSimpleResponse.setTotal(pageInfo.getTotal());
pageSimpleResponse.setList(thrCorpExportLogEntities);
return ResultVOUtils.success(pageSimpleResponse);
}
@PostMapping("/udiwms/thrCorp/exportLog/deleteLog")
public BaseResponse deleteLog(@RequestBody DeleteRequest deleteRequest, BindingResult bindingResult) {
if (bindingResult.hasErrors()) {
return ResultVOUtils.error(ResultEnum.PARAM_VERIFY_FALL, bindingResult.getFieldError().getDefaultMessage());
}
String id = deleteRequest.getId();
thrCorpExportLogService.deleteById(id + "");
return ResultVOUtils.success("删除成功");
}
//往来单位excel文件下载
@GetMapping("/udiwms/thrCorp/exportLog/download")
public void download(FilterThrCorpExportLogRequest filterThrCorpExportLogRequest, HttpServletResponse res) {
List<ThrCorpExportLogEntity> thrCorpExportLogEntities = thrCorpExportLogService.filterThrCorpExportLog(filterThrCorpExportLogRequest);
ThrCorpExportLogEntity thrOrderExportLogEntity = thrCorpExportLogEntities.get(0);
try {
String filePath = thrOrderExportLogEntity.getFilePath();
String fileName = "temp";
if (filePath != null && filePath.length() > 0) {
String[] data = filePath.split("/");
fileName = data[data.length - 1];
}
res.setHeader("Content-disposition", "attachment;fileName=" + fileName);
res.setContentType("text/plain;charset=UTF-8");
FileInputStream input = new FileInputStream(new File(filePath));
OutputStream out = res.getOutputStream();
byte[] b = new byte[2048];
int len;
while ((len = input.read(b)) != -1) {
out.write(b, 0, len);
}
input.close();
if (thrOrderExportLogEntity.getDlCount() == 0) {
thrOrderExportLogEntity.setDlCount(1);
} else {
thrOrderExportLogEntity.setDlCount(thrOrderExportLogEntity.getDlCount() + 1);
}
thrCorpExportLogService.updateThrCorpExportLog(thrOrderExportLogEntity);
} catch (Exception ex) {
System.out.println("下载失败!");
}
}
//往来单位导出生成Excel并创建生成记录
@PostMapping("/udiwms/thrCorp/importLog/export")
public BaseResponse excelDownload(@RequestBody ThrCorpExportRequest thrCorpExportRequest) {
//String fileName = "D:\\udiwms\\exportFile\\" + "第三方往来单位信息导出" + System.currentTimeMillis() + ".xls";
String fileName = "D:\\udiwms\\exportFile\\" + "第三方往来单位信息导出" + System.currentTimeMillis() + ".udi";
File file = new File(fileName);
if (!file.exists()) {
try {
file.createNewFile();
} catch (IOException e) {
e.printStackTrace();
}
}
ThrCorpExportLogEntity thrCorpExportLogEntity = new ThrCorpExportLogEntity();
thrCorpExportLogEntity.setStatus(BasicProcessStatus.UDIINFO_IMPORT_PROCESS);
String genKey = CustomUtil.getId();
thrCorpExportLogEntity.setGenKey(genKey);
thrCorpExportLogEntity.setFilePath(fileName);
thrCorpExportLogEntity.setUpdateTime(new Date());
thrCorpExportLogEntity.setDlCount(0);
thrCorpExportLogEntity.setType(BasicProcessStatus.EXPORT_EXCEL);
thrCorpExportLogService.insertThrCorpExportLog(thrCorpExportLogEntity);
//thrCorpsDlService.genExcel(genKey, thrCorpExportRequest);
//修改为导出json文件
thrCorpsDlService.genJsonFile(genKey, thrCorpExportRequest);
return ResultVOUtils.success("后台正在导出生成udi文件请稍后刷新查看!");
}
//往来单位导出生成Excel并创建生成记录
@PostMapping("/udiwms/thrCorp/importLog/upload")
public BaseResponse uploadSmp(@RequestBody ThrCorpExportRequest thrCorpExportRequest) {
//String fileName = "D:\\udiwms\\exportFile\\" + "第三方往来单位信息导出" + System.currentTimeMillis() + ".xls";
String fileName = "D:\\udiwms\\exportFile\\" + "第三方往来单位信息导出" + System.currentTimeMillis() + ".udi";
File file = new File(fileName);
if (!file.exists()) {
try {
file.createNewFile();
} catch (IOException e) {
e.printStackTrace();
}
}
ThrCorpExportLogEntity thrCorpExportLogEntity = new ThrCorpExportLogEntity();
thrCorpExportLogEntity.setStatus(BasicProcessStatus.UDIINFO_IMPORT_PROCESS);
String genKey = CustomUtil.getId();
thrCorpExportLogEntity.setGenKey(genKey);
thrCorpExportLogEntity.setFilePath(fileName);
thrCorpExportLogEntity.setUpdateTime(new Date());
thrCorpExportLogEntity.setDlCount(0);
thrCorpExportLogEntity.setType(BasicProcessStatus.EXPORT_SMP);
thrCorpExportLogService.insertThrCorpExportLog(thrCorpExportLogEntity);
thrCorpsDlService.uploadSmp(genKey, thrCorpExportRequest);
return ResultVOUtils.success("后台正在导出生成udi文件请稍后刷新查看!");
}
//第三方往来单位接口下载(第三方使用)
@GetMapping("/udiwms/thrsys/thrCorp/download")
public BaseResponse downloadThrCorps(ThrUnitMaintainFilterRequest unitMaintainFilterRequest,
BindingResult bindingResult) {
if (bindingResult.hasErrors()) {
return ResultVOUtils.error(ResultEnum.PARAM_VERIFY_FALL, bindingResult.getFieldError().getDefaultMessage());
}
BasicThirdSysDetailEntity basicThirdSysDetailEntity = thrCorpService.selectByKey("corpUrl", unitMaintainFilterRequest.getThirdSys());
if (basicThirdSysDetailEntity == null || basicThirdSysDetailEntity.getValue() == null)
return ResultVOUtils.error(500, "往来单位接口地址未定义");
if (basicThirdSysDetailEntity.getEnabled()) {
if (basicThirdSysDetailEntity.getFromType() == 0) {
BaseResponse<PageSimpleResponse<ThrCorpsResponse>> udiDlDeviceResponse =
erpBasicClient.getErpCrop(unitMaintainFilterRequest);
return udiDlDeviceResponse;
} else {
FilterThrCorpRequest filterThrCorpRequest = new FilterThrCorpRequest();
BeanUtils.copyProperties(unitMaintainFilterRequest, filterThrCorpRequest);
filterThrCorpRequest.setThirdSysFk(unitMaintainFilterRequest.getThirdSys());
List<ThrCorpsResponse> thrCorpEntities = thrCorpService.filterThrCorps(filterThrCorpRequest);
List<ThrCorpEntity> thrCorpEntityList = thrCorpEntities.stream().map(item ->
{
ThrCorpEntity thrCorpEntity = new ThrCorpEntity();
BeanUtils.copyProperties(item, thrCorpEntity);
return thrCorpEntity;
}).collect(Collectors.toList());
PageInfo<ThrCorpEntity> pageInfo;
pageInfo = new PageInfo<>(thrCorpEntityList);
PageSimpleResponse<ThrCorpEntity> pageSimpleResponse = new PageSimpleResponse<>();
pageSimpleResponse.setTotal(pageInfo.getTotal());
pageSimpleResponse.setList(thrCorpEntityList);
return ResultVOUtils.success(pageSimpleResponse);
}
} else {
return ResultVOUtils.error(500, "第三方系统往来单位接口服务未启用");
}
}
}

@ -0,0 +1,86 @@
package com.glxp.api.controller.thrsys;
import com.github.pagehelper.PageInfo;
import com.glxp.api.common.enums.ResultEnum;
import com.glxp.api.common.res.BaseResponse;
import com.glxp.api.common.util.ResultVOUtils;
import com.glxp.api.entity.thrsys.ThrCorpImportDetailEntity;
import com.glxp.api.entity.thrsys.ThrCorpImportLogEntity;
import com.glxp.api.req.system.DeleteRequest;
import com.glxp.api.req.thrsys.FilterThrCorpImportLogRequest;
import com.glxp.api.res.PageSimpleResponse;
import com.glxp.api.service.thrsys.ThrCorpImportDetailService;
import com.glxp.api.service.thrsys.ThrCorpImportLogService;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
import java.util.List;
/**
*
*/
@RestController
public class ThrCorpImportLogController {
@Resource
ThrCorpImportLogService thrCorpImportLogService;
@Resource
ThrCorpImportDetailService thrCorpImportDetailService;
@GetMapping("/udiwms/thrCorp/importLog/filter")
public BaseResponse filter(FilterThrCorpImportLogRequest filterThrCorpImportLogRequest,
BindingResult bindingResult) {
if (bindingResult.hasErrors()) {
return ResultVOUtils.error(ResultEnum.PARAM_VERIFY_FALL, bindingResult.getFieldError().getDefaultMessage());
}
List<ThrCorpImportLogEntity> thrCorpImportLogEntities = thrCorpImportLogService.filterThrCorpImportLog(filterThrCorpImportLogRequest);
PageInfo<ThrCorpImportLogEntity> pageInfo;
pageInfo = new PageInfo<>(thrCorpImportLogEntities);
PageSimpleResponse<ThrCorpImportLogEntity> pageSimpleResponse = new PageSimpleResponse<>();
pageSimpleResponse.setTotal(pageInfo.getTotal());
pageSimpleResponse.setList(thrCorpImportLogEntities);
return ResultVOUtils.success(pageSimpleResponse);
}
@GetMapping("/udiwms/thrCorp/importLog/filterDetail")
public BaseResponse filterDetail(FilterThrCorpImportLogRequest filterThrCorpImportLogRequest,
BindingResult bindingResult) {
if (bindingResult.hasErrors()) {
return ResultVOUtils.error(ResultEnum.PARAM_VERIFY_FALL, bindingResult.getFieldError().getDefaultMessage());
}
List<ThrCorpImportDetailEntity> thrCorpImportDetailEntities
= thrCorpImportDetailService.filterCorpDetailImport(filterThrCorpImportLogRequest);
PageInfo<ThrCorpImportDetailEntity> pageInfo;
pageInfo = new PageInfo<>(thrCorpImportDetailEntities);
PageSimpleResponse<ThrCorpImportDetailEntity> pageSimpleResponse = new PageSimpleResponse<>();
pageSimpleResponse.setTotal(pageInfo.getTotal());
pageSimpleResponse.setList(thrCorpImportDetailEntities);
return ResultVOUtils.success(pageSimpleResponse);
}
@PostMapping("/udiwms/thrCorp/importLog/deleteLog")
public BaseResponse deleteLog(@RequestBody DeleteRequest deleteRequest, BindingResult bindingResult) {
if (bindingResult.hasErrors()) {
return ResultVOUtils.error(ResultEnum.PARAM_VERIFY_FALL, bindingResult.getFieldError().getDefaultMessage());
}
String id = deleteRequest.getId();
FilterThrCorpImportLogRequest filterInCodeLogRequest = new FilterThrCorpImportLogRequest();
filterInCodeLogRequest.setId(Integer.parseInt(id));
List<ThrCorpImportLogEntity> thrCorpImportLogEntities = thrCorpImportLogService.filterThrCorpImportLog(filterInCodeLogRequest);
if (thrCorpImportLogEntities != null && thrCorpImportLogEntities.size() > 0) {
ThrCorpImportLogEntity thrCorpImportLogEntity = thrCorpImportLogEntities.get(0);
thrCorpImportLogService.deleteById(thrCorpImportLogEntity.getId() + "");
thrCorpImportDetailService.deleteByGenkey(thrCorpImportLogEntity.getGenKey());
}
return ResultVOUtils.success("删除成功");
}
}

@ -0,0 +1,240 @@
package com.glxp.api.controller.thrsys;
import com.github.pagehelper.PageInfo;
import com.glxp.api.annotation.AuthRuleAnnotation;
import com.glxp.api.common.enums.ResultEnum;
import com.glxp.api.common.res.BaseResponse;
import com.glxp.api.common.util.ResultVOUtils;
import com.glxp.api.constant.BasicProcessStatus;
import com.glxp.api.constant.Constant;
import com.glxp.api.entity.basic.BasicUnitMaintainEntity;
import com.glxp.api.entity.thrsys.ThrCorpEntity;
import com.glxp.api.entity.thrsys.ThrCorpImportLogEntity;
import com.glxp.api.entity.thrsys.ThrSystemDetailEntity;
import com.glxp.api.http.ErpBasicClient;
import com.glxp.api.req.system.DeleteRequest;
import com.glxp.api.req.thrsys.FilterThrCorpRequest;
import com.glxp.api.req.thrsys.PostThrCorpRequest;
import com.glxp.api.req.thrsys.ThrUnitMaintainFilterRequest;
import com.glxp.api.res.PageSimpleResponse;
import com.glxp.api.res.thrsys.ThrCorpsResponse;
import com.glxp.api.service.thrsys.ThrCorpImportLogService;
import com.glxp.api.service.thrsys.ThrCorpService;
import com.glxp.api.service.thrsys.ThrCorpsDlService;
import com.glxp.api.service.thrsys.ThrSystemDetailService;
import com.glxp.api.util.CustomUtil;
import com.glxp.api.util.RedisUtil;
import org.springframework.beans.BeanUtils;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import java.util.Date;
import java.util.List;
import java.util.stream.Collectors;
@RestController
public class ThrCorpsController {
@Resource
RedisUtil redisUtil;
@Resource
private ThrCorpService thrCorpService;
@Resource
private ThrCorpsDlService thrCorpsDlService;
@Resource
private ThrCorpImportLogService thrCorpImportLogService;
@Resource
private ErpBasicClient erpBasicClient;
@Resource
private ThrSystemDetailService thrSystemDetailService;
@GetMapping("/udiwms/thrsys/getCorps")
public BaseResponse getCorps(FilterThrCorpRequest filterThrCorpRequest,
BindingResult bindingResult) {
if (bindingResult.hasErrors()) {
return ResultVOUtils.error(ResultEnum.PARAM_VERIFY_FALL, bindingResult.getFieldError().getDefaultMessage());
}
List<ThrCorpsResponse> thrCorpEntities
= thrCorpService.filterThrCorps(filterThrCorpRequest);
PageInfo<ThrCorpsResponse> pageInfo;
pageInfo = new PageInfo<>(thrCorpEntities);
PageSimpleResponse<ThrCorpsResponse> pageSimpleResponse = new PageSimpleResponse<>();
pageSimpleResponse.setTotal(pageInfo.getTotal());
pageSimpleResponse.setList(thrCorpEntities);
return ResultVOUtils.success(pageSimpleResponse);
}
@AuthRuleAnnotation("")
@PostMapping("/udiwms/thrsys/delCorps")
public BaseResponse delCorps(@RequestBody DeleteRequest deleteRequest, BindingResult bindingResult) {
if (bindingResult.hasErrors()) {
return ResultVOUtils.error(ResultEnum.PARAM_VERIFY_FALL, bindingResult.getFieldError().getDefaultMessage());
}
String id = deleteRequest.getId();
thrCorpService.deleteByUnitId(id);
return ResultVOUtils.success("删除成功");
}
@AuthRuleAnnotation("")
@RequestMapping("/udiwms/thrsys/corp/delAll")
public BaseResponse delAll() {
thrCorpService.deleteAll();
return ResultVOUtils.success("删除成功");
}
//第三方服务上传(包括文件导入后上传)
@PostMapping("/udiwms/thrsys/postCorps")
public BaseResponse postCorps(@RequestBody PostThrCorpRequest postThrCorpRequest,
BindingResult bindingResult) {
if (bindingResult.hasErrors()) {
return ResultVOUtils.error(ResultEnum.PARAM_VERIFY_FALL, bindingResult.getFieldError().getDefaultMessage());
}
List<ThrCorpsResponse> thrCorpsResponseList = postThrCorpRequest.getCorps();
if (thrCorpsResponseList != null && thrCorpsResponseList.size() > 0) {
String genKey = postThrCorpRequest.getGenKey();
if (genKey == null) {
genKey = CustomUtil.getId();
}
ThrCorpImportLogEntity thrCorpImportLogEntity = thrCorpImportLogService.selectByGenKey(genKey);
if (thrCorpImportLogEntity == null) {
thrCorpImportLogEntity = new ThrCorpImportLogEntity();
thrCorpImportLogEntity.setGenKey(genKey);
if (postThrCorpRequest.getUploadType() != null) {
thrCorpImportLogEntity.setFromType(postThrCorpRequest.getUploadType());
} else
thrCorpImportLogEntity.setFromType("第三方系统上传");
thrCorpImportLogEntity.setStatus(BasicProcessStatus.UDIINFO_IMPORT_PROCESS);
thrCorpImportLogEntity.setUpdateTime(new Date());
thrCorpImportLogEntity.setThirdSysFk(postThrCorpRequest.getThirdSys());
thrCorpImportLogService.insertImportLog(thrCorpImportLogEntity);
}
thrCorpsDlService.insertData(genKey, postThrCorpRequest.getThirdSys(), thrCorpsResponseList);
return ResultVOUtils.success("往来单位上传成功!后台正在处理,请稍后刷新查看!");
}
return ResultVOUtils.error(500, "上传数据为空");
}
//接口一键全部
@AuthRuleAnnotation("")
@RequestMapping("/udiwms/thrsys/corp/downloadAll")
public BaseResponse downloadAll(FilterThrCorpRequest filterThrProductsRequest) {
String data = (String) redisUtil.get(Constant.dlThrProducts);
if (data != null && data.equals("true")) {
return ResultVOUtils.error(500, "当前任务正在下载更新产品信息,请稍后重试!");
} else {
redisUtil.set(Constant.dlThrCorps, "true", 30);
if (filterThrProductsRequest.getThirdSysFk() == null) {
return ResultVOUtils.error(500, "未选择第三方系统!");
}
ThrCorpImportLogEntity thrCorpImportLogEntity = new ThrCorpImportLogEntity();
String genKey = CustomUtil.getId();
thrCorpImportLogEntity.setGenKey(genKey);
thrCorpImportLogEntity.setFromType("第三方系统获取");
thrCorpImportLogEntity.setStatus(BasicProcessStatus.UDIINFO_IMPORT_PROCESS);
thrCorpImportLogEntity.setUpdateTime(new Date());
thrCorpImportLogEntity.setThirdSysFk(filterThrProductsRequest.getThirdSysFk());
thrCorpImportLogService.insertImportLog(thrCorpImportLogEntity);
thrCorpsDlService.importCorps(genKey,null, filterThrProductsRequest.getThirdSysFk());
return ResultVOUtils.success("后台开始下载更新,请稍后刷新查看");
}
}
//选中或者下载全部
@AuthRuleAnnotation("")
@PostMapping("/udiwms/thrsys/corp/corpsDlAll")
public BaseResponse corpsDlAll(@RequestBody ThrUnitMaintainFilterRequest thrUnitMaintainFilterRequest) {
thrUnitMaintainFilterRequest.setThirdSysFk(thrUnitMaintainFilterRequest.getThirdSys());
String data = (String) redisUtil.get(Constant.dlThrProducts);
if (data != null && data.equals("true")) {
return ResultVOUtils.error(500, "当前任务正在下载更新产品信息,请稍后重试!");
} else {
redisUtil.set(Constant.dlThrCorps, "true", 30);
if (thrUnitMaintainFilterRequest.getThirdSysFk() == null) {
return ResultVOUtils.error(500, "未选择第三方系统!");
}
ThrCorpImportLogEntity thrCorpImportLogEntity = new ThrCorpImportLogEntity();
String genKey = CustomUtil.getId();
thrCorpImportLogEntity.setGenKey(genKey);
thrCorpImportLogEntity.setFromType("第三方系统获取");
thrCorpImportLogEntity.setStatus(BasicProcessStatus.UDIINFO_IMPORT_PROCESS);
thrCorpImportLogEntity.setUpdateTime(new Date());
thrCorpImportLogEntity.setThirdSysFk(thrUnitMaintainFilterRequest.getThirdSysFk());
thrCorpImportLogService.insertImportLog(thrCorpImportLogEntity);
if (thrUnitMaintainFilterRequest.getThrCorpEntities() != null && thrUnitMaintainFilterRequest.getThrCorpEntities().size() > 0) {//选中导出
thrCorpsDlService.importSelectCorps(genKey, thrUnitMaintainFilterRequest.getThrCorpEntities(), thrUnitMaintainFilterRequest.getThirdSysFk());
} else { //结果导出
thrCorpsDlService.importCorps(genKey,thrUnitMaintainFilterRequest, thrUnitMaintainFilterRequest.getThirdSysFk());
}
// thrCorpsDlService.importCorps(genKey, filterThrCorpRequest.getThirdSysFk());
return ResultVOUtils.success("后台开始下载更新,请稍后刷新查看");
}
}
//查询ERP往来单位
@AuthRuleAnnotation("")
@GetMapping("/udiwms/unitMaintain/filterErp")
public BaseResponse filterErp(ThrUnitMaintainFilterRequest thrUnitMaintainFilterRequest,
BindingResult bindingResult) {
if (bindingResult.hasErrors()) {
return ResultVOUtils.error(ResultEnum.PARAM_VERIFY_FALL, bindingResult.getFieldError().getDefaultMessage());
}
ThrSystemDetailEntity thrSystemDetailEntity = thrSystemDetailService.selectByKey("corpUrl", thrUnitMaintainFilterRequest.getThirdSys());
if (thrSystemDetailEntity == null || thrSystemDetailEntity.getValue() == null)
return ResultVOUtils.error(500, "往来单位接口地址未定义");
if (thrSystemDetailEntity.getEnabled()) {
if (thrSystemDetailEntity.getFromType() == 0 || (thrUnitMaintainFilterRequest.getIsDownThrSys() != null && thrUnitMaintainFilterRequest.getIsDownThrSys())) {
BaseResponse<PageSimpleResponse<ThrCorpsResponse>> udiDlDeviceResponse = erpBasicClient.getErpCrop(thrUnitMaintainFilterRequest);
if (udiDlDeviceResponse.getCode() == 20000) {
for (ThrCorpsResponse erpUnitsResponse : udiDlDeviceResponse.getData().getList()) {
BasicUnitMaintainEntity basicUnitMaintainEntity = thrCorpService.selectByThirdId(erpUnitsResponse.getId(), thrUnitMaintainFilterRequest.getThirdSys());
if (basicUnitMaintainEntity != null) {
erpUnitsResponse.setChecked(true);
} else {
erpUnitsResponse.setChecked(false);
}
}
return udiDlDeviceResponse;
} else {
return udiDlDeviceResponse;
}
} else {
FilterThrCorpRequest filterThrCorpRequest = new FilterThrCorpRequest();
BeanUtils.copyProperties(thrUnitMaintainFilterRequest, filterThrCorpRequest);
filterThrCorpRequest.setThirdSysFk(thrUnitMaintainFilterRequest.getThirdSys());
List<ThrCorpsResponse> thrCorpEntities = thrCorpService.filterThrCorps(filterThrCorpRequest);
List<ThrCorpsResponse> thrCorpEntityList = thrCorpEntities.stream().map(item ->
{
ThrCorpsResponse thrCorpEntity = new ThrCorpsResponse();
BeanUtils.copyProperties(item, thrCorpEntity);
BasicUnitMaintainEntity basicUnitMaintainEntity = thrCorpService.selectByThirdId(item.getUnitId(), thrUnitMaintainFilterRequest.getThirdSys());
if (basicUnitMaintainEntity != null) {
thrCorpEntity.setChecked(true);
} else {
thrCorpEntity.setChecked(false);
}
thrCorpEntity.setId(item.getUnitId());
return thrCorpEntity;
}).collect(Collectors.toList());
PageInfo<ThrCorpsResponse> pageInfo;
pageInfo = new PageInfo<>(thrCorpEntities);
PageSimpleResponse<ThrCorpsResponse> pageSimpleResponse = new PageSimpleResponse<>();
pageSimpleResponse.setTotal(pageInfo.getTotal());
pageSimpleResponse.setList(thrCorpEntityList);
return ResultVOUtils.success(pageSimpleResponse);
}
} else {
return ResultVOUtils.error(500, "第三方系统往来单位服务接口未启用");
}
}
}

@ -1,27 +1,22 @@
package com.glxp.api.controller.thrsys;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.github.pagehelper.PageInfo;
import com.glxp.api.annotation.AuthRuleAnnotation;
import com.glxp.api.common.enums.ResultEnum;
import com.glxp.api.common.res.BaseResponse;
import com.glxp.api.common.util.ResultVOUtils;
import com.glxp.api.entity.auth.AuthAdmin;
import com.glxp.api.entity.basic.BasicThirdSysDetailEntity;
import com.glxp.api.entity.basic.BasicThirdSysEntity;
import com.glxp.api.entity.thrsys.ThrProductsEntity;
import com.glxp.api.entity.thrsys.ThrSystemDetailEntity;
import com.glxp.api.http.ErpBasicClient;
import com.glxp.api.req.system.DeleteRequest;
import com.glxp.api.req.thrsys.FilterThrProductsRequest;
import com.glxp.api.req.thrsys.ThrProductsRequest;
import com.glxp.api.res.PageSimpleResponse;
import com.glxp.api.res.thrsys.ThrProductsResponse;
import com.glxp.api.service.auth.CustomerService;
import com.glxp.api.service.basic.BasicThirdSysDetailService;
import com.glxp.api.service.thrsys.ThrProductsService;
import org.springframework.beans.BeanUtils;
import com.glxp.api.service.thrsys.ThrSystemDetailService;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.*;
@ -44,7 +39,7 @@ public class ThrProductsController {
ThrProductsService thrProductsService;
@Resource
BasicThirdSysDetailService basicThirdSysDetailService;
ThrSystemDetailService thrSystemDetailService;
@Resource
private ErpBasicClient erpBasicClient;
@ -62,13 +57,13 @@ public class ThrProductsController {
return ResultVOUtils.error(ResultEnum.PARAM_VERIFY_FALL, bindingResult.getFieldError().getDefaultMessage());
}
BasicThirdSysDetailEntity basicThirdSysDetailEntity = basicThirdSysDetailService.selectByKey("piQueryUrl", filterThrProductsRequest.getThirdSys());
if (basicThirdSysDetailEntity == null || basicThirdSysDetailEntity.getValue() == null) {
ThrSystemDetailEntity thrSystemDetailEntity = thrSystemDetailService.selectByKey("piQueryUrl", filterThrProductsRequest.getThirdSys());
if (thrSystemDetailEntity == null || thrSystemDetailEntity.getValue() == null) {
return ResultVOUtils.error(500, "ERP产品信息接口地址未定义");
}
if (basicThirdSysDetailEntity.getEnabled()) {
if (basicThirdSysDetailEntity.getFromType() == 0 || (filterThrProductsRequest.getIsDownThrSys() != null && filterThrProductsRequest.getIsDownThrSys())) {
if (thrSystemDetailEntity.getEnabled()) {
if (thrSystemDetailEntity.getFromType() == 0 || (filterThrProductsRequest.getIsDownThrSys() != null && filterThrProductsRequest.getIsDownThrSys())) {
BaseResponse<PageSimpleResponse<ThrProductsResponse>> udiDlDeviceResponse = erpBasicClient.getErpProducts(filterThrProductsRequest);
if (udiDlDeviceResponse.getCode() == 20000) {
List<ThrProductsResponse> invmandocResponses = udiDlDeviceResponse.getData().getList();

@ -5,9 +5,8 @@ import com.glxp.api.common.enums.ResultEnum;
import com.glxp.api.common.res.BaseResponse;
import com.glxp.api.common.util.ResultVOUtils;
import com.glxp.api.constant.BasicProcessStatus;
import com.glxp.api.entity.basic.BasicThirdSysDetailEntity;
import com.glxp.api.entity.thrsys.ThrProductsEntity;
import com.glxp.api.entity.thrsys.ThrProductsExportLogEntity;
import com.glxp.api.entity.thrsys.ThrSystemDetailEntity;
import com.glxp.api.http.ErpBasicClient;
import com.glxp.api.req.system.DeleteRequest;
import com.glxp.api.req.thrsys.FilterThrProductsExportLogRequest;
@ -16,10 +15,10 @@ import com.glxp.api.req.thrsys.ThrProductsExportRequest;
import com.glxp.api.res.PageSimpleResponse;
import com.glxp.api.res.thrsys.ThrProductsResponse;
import com.glxp.api.service.auth.CustomerService;
import com.glxp.api.service.basic.BasicThirdSysDetailService;
import com.glxp.api.service.thrsys.ThrProductsDlService;
import com.glxp.api.service.thrsys.ThrProductsExportLogService;
import com.glxp.api.service.thrsys.ThrProductsService;
import com.glxp.api.service.thrsys.ThrSystemDetailService;
import com.glxp.api.util.CustomUtil;
import org.springframework.beans.BeanUtils;
import org.springframework.validation.BindingResult;
@ -47,7 +46,7 @@ public class ThrProductsExportLogController {
@Resource
ThrProductsDlService thrProductsDlService;
@Resource
BasicThirdSysDetailService basicThirdSysDetailService;
ThrSystemDetailService thrSystemDetailService;
@Resource
private CustomerService customerService;
@ -177,11 +176,11 @@ public class ThrProductsExportLogController {
if (bindingResult.hasErrors()) {
return ResultVOUtils.error(ResultEnum.PARAM_VERIFY_FALL, bindingResult.getFieldError().getDefaultMessage());
}
BasicThirdSysDetailEntity basicThirdSysDetailEntity = basicThirdSysDetailService.selectByKey("piQueryUrl", filterThrProductsRequest.getThirdSys());
if (basicThirdSysDetailEntity == null || basicThirdSysDetailEntity.getValue() == null)
ThrSystemDetailEntity thrSystemDetailEntity = thrSystemDetailService.selectByKey("piQueryUrl", filterThrProductsRequest.getThirdSys());
if (thrSystemDetailEntity == null || thrSystemDetailEntity.getValue() == null)
return ResultVOUtils.error(500, "ERP产品信息接口地址未定义");
if (basicThirdSysDetailEntity.getEnabled()) {
if (basicThirdSysDetailEntity.getFromType() == 0) {
if (thrSystemDetailEntity.getEnabled()) {
if (thrSystemDetailEntity.getFromType() == 0) {
ErpBasicClient erpBasicHttpClient = new ErpBasicClient();
BaseResponse<PageSimpleResponse<ThrProductsResponse>> udiDlDeviceResponse = erpBasicHttpClient.getErpProducts(filterThrProductsRequest);
if (udiDlDeviceResponse.getCode() == 20000) {

@ -4,6 +4,7 @@ import com.github.pagehelper.PageInfo;
import com.glxp.api.common.enums.ResultEnum;
import com.glxp.api.common.res.BaseResponse;
import com.glxp.api.common.util.ResultVOUtils;
import com.glxp.api.entity.thrsys.ThrCorpImportLogEntity;
import com.glxp.api.entity.thrsys.ThrProductsImportLogEntity;
import com.glxp.api.entity.thrsys.ThrProductsImportDetailEntity;
import com.glxp.api.req.system.DeleteRequest;
@ -81,4 +82,5 @@ public class ThrProductsImportLogController {
return ResultVOUtils.success("删除成功");
}
}

@ -1,52 +0,0 @@
package com.glxp.api.dao.basic;
import com.glxp.api.entity.basic.BasicThirdSysEntity;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
@Mapper
public interface BasicThirdSysDao {
// boolean updateBasicThiSys(BasicThirdSysEntity basicThirdSysEntity);
//
BasicThirdSysEntity selectByThirdId(@Param("thirdId") String thirdId);
//
// List<BasicThirdSysEntity> filterBasicThiSys(FilterBasicThirdSysRequest filterBasicThirdSysRequest);
//
// /**
// * 查询启用的第三方系统的ID
// *
// * @return
// */
// List<String> selectEnabledThirdId();
//
// /**
// * 查询第三方系统名称数量
// *
// * @param thirdName
// * @return
// */
// int selectCountByThirdName(@Param("thirdName") String thirdName);
//
// /**
// * 根据系统ID和名称查询第三方系统配置信息
// *
// * @param thirdId
// * @param thirdName
// * @return
// */
// BasicThirdSysEntity selectByThirdIdAndThirdName(@Param("thirdId") String thirdId, @Param("thirdName") String thirdName);
//
/**
* ID
*
* @param thirdId
* @return
*/
String selectThirdNameByThirdId(@Param("thirdId") String thirdId);
//
// int countThirdSys(FilterBasicThirdSysRequest filterBasicThirdSysRequest);
}

@ -1,17 +0,0 @@
package com.glxp.api.dao.basic;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.glxp.api.entity.basic.BasicThirdSysDetailEntity;
import com.glxp.api.entity.thrsys.ThrProductsEntity;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
@Mapper
public interface BasicThirdSysDetailDao extends BaseMapper<BasicThirdSysDetailEntity> {
BasicThirdSysDetailEntity selectByKey(@Param("key") String key,@Param("thirdSys") String thirdSys);
}

@ -0,0 +1,38 @@
package com.glxp.api.dao.thrsys;
import com.glxp.api.entity.basic.BasicThirdSysDetailEntity;
import com.glxp.api.entity.basic.BasicUnitMaintainEntity;
import com.glxp.api.entity.thrsys.ThrCorpEntity;
import com.glxp.api.req.thrsys.FilterThrCorpRequest;
import com.glxp.api.req.thrsys.ThrUnitMaintainFilterRequest;
import com.glxp.api.res.thrsys.ThrCorpsResponse;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
@Mapper
public interface ThrCorpDao {
List<ThrCorpsResponse> filterThrCorps(FilterThrCorpRequest filterThrCorpRequest);
boolean insertThrCorps(ThrCorpEntity thrCorpEntity);
boolean insertThrCorpss(@Param("thrCorpEntitys") List<ThrCorpEntity> thrCorpEntitys);
boolean updateThrCorps(ThrCorpEntity thrCorpEntity);
boolean deleteById(@Param("id") String id);
boolean deleteByUnitId(@Param("unitId") String unitId);
boolean deleteAll();
void importThrCorp(ThrCorpEntity thrCorpEntity);
BasicUnitMaintainEntity selectByThirdId(ThrUnitMaintainFilterRequest thrUnitMaintainFilterRequest);
BasicThirdSysDetailEntity selectByKey(@Param("key") String key, @Param("thirdSys") String thirdSys);
}

@ -0,0 +1,27 @@
package com.glxp.api.dao.thrsys;
import com.glxp.api.entity.thrsys.FilterThrCorpExportLogRequest;
import com.glxp.api.entity.thrsys.ThrCorpExportLogEntity;
import com.glxp.api.req.thrsys.FilterThrProductsExportLogRequest;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
@Mapper
public interface ThrCorpExportLogDao {
List<ThrCorpExportLogEntity> filterThrCorpExportLog(FilterThrCorpExportLogRequest filterThrCorpExportLogRequest);
boolean insertThrCorpExportLog(ThrCorpExportLogEntity thrCorpExportLogEntity);
boolean updateThrCorpExportLog(ThrCorpExportLogEntity thrCorpExportLogEntity);
boolean deleteById(@Param("id") String id);
boolean deleteByTime();
String selectFilePathById(@Param("id") String id);
}

@ -0,0 +1,26 @@
package com.glxp.api.dao.thrsys;
import com.glxp.api.entity.thrsys.ThrCorpImportDetailEntity;
import com.glxp.api.req.thrsys.FilterThrCorpImportLogRequest;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
@Mapper
public interface ThrCorpImportDetailDao {
List<ThrCorpImportDetailEntity> filterCorpDetailImport(FilterThrCorpImportLogRequest filterThrCorpImportLogRequest);
boolean insertCorpDetailImport(ThrCorpImportDetailEntity thrCorpImportDetailEntity);
boolean updateCorpDetailImport(ThrCorpImportDetailEntity thrCorpImportDetailEntity);
boolean insertCorpDetailImports(@Param("corps") List<ThrCorpImportDetailEntity> thrCorpImportDetailEntities);
boolean deleteById(@Param("id") String id);
boolean deleteByGenkey(@Param("genKey") String genKey);
boolean deleteByTime();
}

@ -0,0 +1,25 @@
package com.glxp.api.dao.thrsys;
import com.glxp.api.entity.thrsys.ThrCorpImportLogEntity;
import com.glxp.api.req.thrsys.FilterThrCorpImportLogRequest;
import com.glxp.api.req.thrsys.FilterThrProductsImportLogRequest;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
@Mapper
public interface ThrCorpImportLogDao {
List<ThrCorpImportLogEntity> filterThrCorpImportLog(FilterThrCorpImportLogRequest filterThrCorpImportLogRequest);
boolean insertImportLog(ThrCorpImportLogEntity thrCorpImportLogEntity);
boolean updateImportLog(ThrCorpImportLogEntity thrCorpImportLogEntity);
boolean deleteById(@Param("id") String id);
boolean deleteByTime();
}

@ -0,0 +1,43 @@
package com.glxp.api.entity.basic;
import lombok.Data;
import javax.validation.constraints.NotBlank;
import java.util.Date;
@Data
public class BasicUnitMaintainEntity {
private Integer id;
private String erpId;
@NotBlank(message = "往来单位名称不能为空!")
private String name;
private String spell;
private String addr;
private String status;
private String type;
@NotBlank(message = "社会信用号不能为空!")
private String creditNo;
private String contact;
private String mobile;
private String thirdId;
private String thirdId1;
private String thirdId2;
private String thirdId3;
private String thirdId4;
private String thirdName;
private String thirdName1;
private String thirdName2;
private String thirdName3;
private String thirdName4;
private Date updateTime;
private Integer corpType;
private Integer outType;
}

@ -0,0 +1,15 @@
package com.glxp.api.entity.thrsys;
import com.glxp.api.req.ListPageRequest;
import lombok.Data;
@Data
public class FilterThrCorpExportLogRequest extends ListPageRequest {
private String genKey;
private Integer status;
private Integer type;
}

@ -0,0 +1,80 @@
package com.glxp.api.entity.thrsys;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import lombok.Data;
import java.time.LocalDateTime;
import java.util.Date;
/**
* <p>
*
* </p>
* @since 2023-01-12
*/
@Data
public class ThrCorpEntity{
private static final long serialVersionUID = 1L;
@TableId(value = "id", type = IdType.AUTO)
private Integer id;
@TableField("unitId")
private String unitId;
@TableField("spell")
private String spell;
@TableField("addr")
private String addr;
@TableField("creditNo")
private String creditNo;
@TableField("contact")
private String contact;
@TableField("mobile")
private String mobile;
@TableField("thirdSysFk")
private String thirdSysFk;
@TableField("name")
private String name;
/**
*
*/
@TableField("createUser")
private String createUser;
/**
*
*/
@TableField("createTime")
private Date createTime;
/**
*
*/
@TableField("updateUser")
private String updateUser;
/**
*
*/
@TableField("updateTime")
private Date updateTime;
/**
*
*/
@TableField("remark")
private String remark;
}

@ -0,0 +1,84 @@
package com.glxp.api.entity.thrsys;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import lombok.Data;
import java.time.LocalDateTime;
import java.util.Date;
/**
* <p>
*
* </p>
*
* @since 2023-01-12
*/
@Data
public class ThrCorpExportLogEntity{
private static final long serialVersionUID = 1L;
@TableId(value = "id", type = IdType.AUTO)
private Integer id;
/**
*
*/
@TableField("genKey")
private String genKey;
/**
* 01
*/
@TableField("status")
private Integer status;
/**
*
*/
@TableField("dlCount")
private Integer dlCount;
/**
*
*/
@TableField("filePath")
private String filePath;
@TableField("type")
private Integer type;
/**
*
*/
@TableField("createUser")
private String createUser;
/**
*
*/
@TableField("createTime")
private Date createTime;
/**
*
*/
@TableField("updateUser")
private String updateUser;
/**
*
*/
@TableField("updateTime")
private Date updateTime;
/**
*
*/
@TableField("remark")
private String remark;
}

@ -0,0 +1,83 @@
package com.glxp.api.entity.thrsys;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import lombok.Data;
import java.time.LocalDateTime;
import java.util.Date;
/**
* <p>
*
* @since 2023-01-12
*/
@Data
public class ThrCorpImportDetailEntity{
private static final long serialVersionUID = 1L;
@TableId(value = "id", type = IdType.AUTO)
private Integer id;
@TableField("unitId")
private String unitId;
@TableField("spell")
private String spell;
@TableField("addr")
private String addr;
@TableField("creditNo")
private String creditNo;
@TableField("contact")
private String contact;
@TableField("mobile")
private String mobile;
@TableField("thirdSysFk")
private String thirdSysFk;
@TableField("name")
private String name;
@TableField("genKeyFk")
private String genKeyFk;
/**
*
*/
@TableField("createUser")
private String createUser;
/**
*
*/
@TableField("createTime")
private Date createTime;
/**
*
*/
@TableField("updateUser")
private String updateUser;
/**
*
*/
@TableField("updateTime")
private Date updateTime;
/**
*
*/
@TableField("remark")
private String remark;
}

@ -0,0 +1,71 @@
package com.glxp.api.entity.thrsys;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import lombok.Data;
import java.time.LocalDateTime;
import java.util.Date;
/**
* <p>
*
* </p>
* @since 2023-01-12
*/
@Data
public class ThrCorpImportLogEntity{
private static final long serialVersionUID = 1L;
@TableId(value = "id", type = IdType.AUTO)
private Integer id;
@TableField("genKey")
private String genKey;
/**
* 0:1.2.3.
*/
@TableField("status")
private Integer status;
@TableField("fromType")
private String fromType;
@TableField("thirdSysFk")
private String thirdSysFk;
/**
*
*/
@TableField("createUser")
private String createUser;
/**
*
*/
@TableField("createTime")
private Date createTime;
/**
*
*/
@TableField("updateUser")
private String updateUser;
/**
*
*/
@TableField("updateTime")
private Date updateTime;
/**
*
*/
@TableField("remark")
private String remark;
}

@ -8,12 +8,16 @@ import com.glxp.api.common.util.ResultVOUtils;
import com.glxp.api.entity.thrsys.ThrSystemBusApiEntity;
import com.glxp.api.entity.thrsys.ThrSystemEntity;
import com.glxp.api.http.req.UdiwmsBusTypeRequest;
import com.glxp.api.http.req.UdiwmsUnitRequest;
import com.glxp.api.req.thrsys.FilterBasicThirdSysDetailRequest;
import com.glxp.api.req.thrsys.FilterThrProductsRequest;
import com.glxp.api.req.thrsys.ThrUnitMaintainFilterRequest;
import com.glxp.api.res.PageSimpleResponse;
import com.glxp.api.res.thrsys.ThrCorpsResponse;
import com.glxp.api.res.thrsys.ThrProductsResponse;
import com.glxp.api.service.thrsys.ThrSystemService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
@ -29,28 +33,29 @@ public class ErpBasicClient {
@Resource
private ThrSystemService basicThirdSysService;
//获取往来单位
public BaseResponse<PageSimpleResponse<ThrCorpsResponse>> getErpCrop(ThrUnitMaintainFilterRequest thrUnitMaintainFilterRequest) {
UdiwmsUnitRequest udiwmsUnitRequest = new UdiwmsUnitRequest();
BeanUtils.copyProperties(thrUnitMaintainFilterRequest, udiwmsUnitRequest);
udiwmsUnitRequest.setUnitId(thrUnitMaintainFilterRequest.getErpId());
ThrSystemEntity thrSystemEntity = basicThirdSysService.selectByThirdId(thrUnitMaintainFilterRequest.getThirdSys());
try {
String url = thrSystemEntity.getThridUrl() + "/udiwms/erp/getUnits";
String response = httpOkClient.uCloudPost(url, udiwmsUnitRequest, thrSystemEntity);
if(StrUtil.isBlank(response)){
return ResultVOUtils.error(500, "连接第三方系统接口服务出错!");
}
BaseResponse<PageSimpleResponse<ThrCorpsResponse>> udiDlDeviceResponse =
JSONObject.parseObject(response, new TypeReference<BaseResponse<PageSimpleResponse<ThrCorpsResponse>>>() {
});
return udiDlDeviceResponse;
} catch (Exception e) {
log.error("获取往来单位异常", e);
return ResultVOUtils.error(500, "连接第三方系统接口服务出错!");
}
}
//todo 基础信息相关接口还未完成
// //获取往来单位
// public BaseResponse<PageSimpleResponse<ErpUnitsResponse>> getErpCrop(BasicUnitMaintainFilterRequest unitMaintainFilterRequest) {
// UdiwmsUnitRequest udiwmsUnitRequest = new UdiwmsUnitRequest();
// BeanUtils.copyProperties(unitMaintainFilterRequest, udiwmsUnitRequest);
// udiwmsUnitRequest.setUnitId(unitMaintainFilterRequest.getErpId());
// BasicThirdSysEntity basicThirdSysEntity = basicThirdSysService.selectByThirdId(unitMaintainFilterRequest.getThirdSys());
//
// try {
// String url = basicThirdSysEntity.getThridUrl() + "/udiwms/erp/getUnits";
// String response = httpOkClient.uCloudPost(url, udiwmsUnitRequest, basicThirdSysEntity);
// BaseResponse<PageSimpleResponse<ErpUnitsResponse>> udiDlDeviceResponse =
// JSONObject.parseObject(response, new TypeReference<BaseResponse<PageSimpleResponse<ErpUnitsResponse>>>() {
// });
// return udiDlDeviceResponse;
// } catch (Exception e) {
// log.error("获取往来单位异常", e);
// return ResultVOUtils.error(500, "连接第三方系统接口服务出错!");
// }
// }
//
//获取产品信息
public BaseResponse<PageSimpleResponse<ThrProductsResponse>> getErpProducts(FilterThrProductsRequest filterThrProductsRequest) {

@ -0,0 +1,12 @@
package com.glxp.api.http.req;
import com.glxp.api.req.ListPageRequest;
import lombok.Data;
@Data
public class UdiwmsUnitRequest extends ListPageRequest {
String key;
private String unitId;
private String name;
}

@ -0,0 +1,17 @@
package com.glxp.api.req.thrsys;
import com.glxp.api.req.ListPageRequest;
import lombok.Data;
@Data
public class FilterThrCorpImportLogRequest extends ListPageRequest {
private Integer id;
private String genKey;
private Integer status;
private String thirdSysFk;
private String fromType;
private String lastUpdateTime;
}

@ -0,0 +1,22 @@
package com.glxp.api.req.thrsys;
import com.glxp.api.req.ListPageRequest;
import com.glxp.api.res.thrsys.ThrCorpsResponse;
import lombok.Data;
import java.util.List;
@Data
public class FilterThrCorpRequest extends ListPageRequest {
private String thirdSysFk;
private String thirdSys;
private String unitId;
private String name;
List<ThrCorpsResponse> thrCorpEntities;
private String lastUpdateTime;
}

@ -0,0 +1,17 @@
package com.glxp.api.req.thrsys;
import com.glxp.api.entity.thrsys.ThrCorpEntity;
import com.glxp.api.res.thrsys.ThrCorpsResponse;
import lombok.Data;
import java.util.List;
@Data
public class PostThrCorpRequest {
private String genKey;
private String thirdSys;
private String uploadType;
private List<ThrCorpsResponse> corps;
private List<ThrCorpEntity> datas;
}

@ -0,0 +1,19 @@
package com.glxp.api.req.thrsys;
import com.glxp.api.entity.thrsys.ThrCorpEntity;
import com.glxp.api.req.ListPageRequest;
import lombok.Data;
import java.util.List;
@Data
public class ThrCorpExportRequest extends ListPageRequest {
private List<ThrCorpEntity> thrCorpEntities;
private String thirdSysFk;
private String unitId;
private String thirdSys;
private String name;
}

@ -0,0 +1,31 @@
package com.glxp.api.req.thrsys;
import com.glxp.api.req.ListPageRequest;
import com.glxp.api.res.thrsys.ThrCorpsResponse;
import lombok.Data;
import java.util.List;
@Data
public class ThrUnitMaintainFilterRequest extends ListPageRequest {
private Integer id;
private String key;
private String unitId;
private String name;
private String thirdSys;
private String thirdSysFk;
private String thirdId;
private String thirdId1;
private String thirdId2;
private String thirdId3;
private String thirdId4;
private String erpId;
private Integer corpType;
private Integer outType;
private Boolean isDownThrSys;
private String lastUpdateTime;
List<ThrCorpsResponse> thrCorpEntities;
}

@ -0,0 +1,27 @@
package com.glxp.api.res.thrsys;
import lombok.Data;
import java.util.Date;
@Data
public class ThrCorpsResponse {
private String id;
private String name;
private String spell;
private String addr;
private String creditNo;
private String contact;
private String mobile;
private Boolean checked;
private String unitId; //必填 往来单位ID
private String thirdSysFk;
private String createUser;
private Date createTime;
private String updateUser;
private Date updateTime;
private String remark;
}

@ -1,23 +0,0 @@
package com.glxp.api.service.basic;
import com.baomidou.mybatisplus.extension.service.IService;
import com.glxp.api.common.res.BaseResponse;
import com.glxp.api.entity.basic.BasicThirdSysDetailEntity;
import com.glxp.api.entity.basic.BasicThirdSysEntity;
import com.glxp.api.entity.thrsys.ThrInvProductsEntity;
import com.glxp.api.entity.thrsys.ThrSystemEntity;
import java.util.List;
public interface BasicThirdSysDetailService{
BasicThirdSysDetailEntity selectByKey(String key, String thirdSys);
/**
*
*
* @param thrSystemEntity
*/
BaseResponse testThirdService(ThrSystemEntity thrSystemEntity);
}

@ -1,34 +0,0 @@
package com.glxp.api.service.basic.impl;
import com.baomidou.mybatisplus.extension.service.IService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.glxp.api.common.res.BaseResponse;
import com.glxp.api.dao.basic.BasicThirdSysDetailDao;
import com.glxp.api.entity.basic.BasicThirdSysDetailEntity;
import com.glxp.api.entity.thrsys.ThrSystemEntity;
import com.glxp.api.http.ErpBasicClient;
import com.glxp.api.service.basic.BasicThirdSysDetailService;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
@Service
public class BasicThirdSysDetailServiceImpl implements BasicThirdSysDetailService {
@Resource
private ErpBasicClient erpBasicClient;
@Resource
BasicThirdSysDetailDao basicThirdSysDetailDao;
@Override
public BasicThirdSysDetailEntity selectByKey(String key, String thirdSys) {
return basicThirdSysDetailDao.selectByKey(key,thirdSys);
}
@Override
public BaseResponse testThirdService(ThrSystemEntity thrSystemEntity) {
return erpBasicClient.testThridConnect(thrSystemEntity);
}
}

@ -0,0 +1,26 @@
package com.glxp.api.service.thrsys;
import com.glxp.api.entity.thrsys.FilterThrCorpExportLogRequest;
import com.glxp.api.entity.thrsys.ThrCorpExportLogEntity;
import java.util.List;
public interface ThrCorpExportLogService {
ThrCorpExportLogEntity selectByGenKey(String genKey);
List<ThrCorpExportLogEntity> filterThrCorpExportLog(FilterThrCorpExportLogRequest filterThrCorpExportLogRequest);
boolean insertThrCorpExportLog(ThrCorpExportLogEntity thrCorpExportLogEntity);
boolean updateThrCorpExportLog(ThrCorpExportLogEntity thrCorpExportLogEntity);
boolean deleteById(String id);
boolean deleteByTime();
}

@ -0,0 +1,27 @@
package com.glxp.api.service.thrsys;
import com.glxp.api.entity.thrsys.ThrCorpImportDetailEntity;
import com.glxp.api.req.thrsys.FilterThrCorpImportLogRequest;
import org.springframework.stereotype.Service;
import java.util.List;
@Service
public interface ThrCorpImportDetailService {
List<ThrCorpImportDetailEntity> filterCorpDetailImport(FilterThrCorpImportLogRequest filterThrCorpImportLogRequest);
boolean insertCorpDetailImport(ThrCorpImportDetailEntity thrCorpImportDetailEntity);
boolean updateCorpDetailImport(ThrCorpImportDetailEntity thrCorpImportDetailEntity);
boolean insertCorpDetailImports( List<ThrCorpImportDetailEntity> thrCorpImportDetailEntities);
boolean deleteById( String id);
boolean deleteByGenkey( String genKey);
boolean deleteByTime();
}

@ -0,0 +1,23 @@
package com.glxp.api.service.thrsys;
import com.glxp.api.entity.thrsys.ThrCorpImportLogEntity;
import com.glxp.api.req.thrsys.FilterThrCorpImportLogRequest;
import java.util.List;
public interface ThrCorpImportLogService {
ThrCorpImportLogEntity selectByGenKey(String genKey);
List<ThrCorpImportLogEntity> filterThrCorpImportLog(FilterThrCorpImportLogRequest filterInCodeLogRequest);
boolean insertImportLog(ThrCorpImportLogEntity thrCorpImportLogEntity);
boolean updateImportLog(ThrCorpImportLogEntity thrCorpImportLogEntity);
boolean deleteById(String id);
boolean deleteByTime();
}

@ -0,0 +1,33 @@
package com.glxp.api.service.thrsys;
import com.glxp.api.entity.basic.BasicThirdSysDetailEntity;
import com.glxp.api.entity.basic.BasicUnitMaintainEntity;
import com.glxp.api.entity.thrsys.ThrCorpEntity;
import com.glxp.api.req.thrsys.FilterThrCorpRequest;
import com.glxp.api.res.thrsys.ThrCorpsResponse;
import java.util.List;
public interface ThrCorpService {
List<ThrCorpsResponse> filterThrCorps(FilterThrCorpRequest filterThrCorpRequest);
boolean insertThrCorps(ThrCorpEntity thrCorpEntity);
boolean insertThrCorpss(List<ThrCorpEntity> thrCorpEntitys);
boolean updateThrCorps(ThrCorpEntity thrCorpEntity);
boolean deleteById(String id);
boolean deleteByUnitId(String id);
boolean deleteAll();
BasicUnitMaintainEntity selectByThirdId(String thirdId, String thirdSys);
BasicThirdSysDetailEntity selectByKey(String key, String thirdSys);
}

@ -0,0 +1,500 @@
package com.glxp.api.service.thrsys;
import cn.hutool.core.io.file.FileWriter;
import cn.hutool.json.JSONUtil;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.TypeReference;
import com.glxp.api.common.res.BaseResponse;
import com.glxp.api.config.WebSocketServer;
import com.glxp.api.constant.BasicProcessStatus;
import com.glxp.api.constant.Constant;
import com.glxp.api.entity.system.SyncDataSetEntity;
import com.glxp.api.entity.thrsys.*;
import com.glxp.api.http.ErpBasicClient;
import com.glxp.api.http.HttpOkClient;
import com.glxp.api.req.thrsys.*;
import com.glxp.api.res.PageSimpleResponse;
import com.glxp.api.res.thrsys.ThrCorpsResponse;
import com.glxp.api.res.thrsys.ThrProductsResponse;
import com.glxp.api.service.system.SyncDataSetService;
import com.glxp.api.util.CustomUtil;
import com.glxp.api.util.ExcelUtil;
import com.glxp.api.util.RedisUtil;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.stream.Collectors;
@Service
public class ThrCorpsDlService {
@Resource
ThrCorpService thrCorpService;
@Resource
ThrSystemDetailService thrSystemDetailService;
@Resource
RedisUtil redisUtil;
@Resource
ThrCorpImportLogService thrCorpImportLogService;
@Resource
ThrCorpExportLogService thrCorpExportLogService;
@Resource
private ThrCorpImportDetailService thrCorpImportDetailService;
// @Value("${SPSYNC_IP}")
// private String spsSyncUrl;
@Resource
ErpBasicClient erpBasicClient;
@Resource
SyncDataSetService syncDataSetService;
@Resource
HttpOkClient httpOkClient;
public String getIpUrl() {
SyncDataSetEntity syncDataSetEntity = syncDataSetService.findSet();
return syncDataSetEntity.getSyncIp();
}
@Async
public void importSelectCorps(String genKey, List<ThrCorpsResponse> thrCorpsResponseList, String thirdSys) {
ThrSystemDetailEntity piDetailEntity = thrSystemDetailService.selectByKey("corpUrl", thirdSys);
if (piDetailEntity == null || piDetailEntity.getValue() == null) {
WebSocketServer.sendInfo("往来单位接口未设置!", "sid");
return;
}
ThrCorpImportLogEntity thrProductsImportLogEntity = thrCorpImportLogService.selectByGenKey(genKey);
if (thrCorpsResponseList != null && thrCorpsResponseList.size() > 0) {
List<ThrCorpImportDetailEntity> thrCorpImportDetailEntities;
String finalGenKey = genKey;
thrCorpImportDetailEntities = thrCorpsResponseList.stream().map(
item -> {
ThrCorpImportDetailEntity thrCorpEntity = new ThrCorpImportDetailEntity();
BeanUtils.copyProperties(item, thrCorpEntity);
thrCorpEntity.setUnitId(item.getUnitId());
thrCorpEntity.setGenKeyFk(finalGenKey);
thrCorpEntity.setUpdateTime(new Date());
thrCorpEntity.setThirdSysFk(thirdSys);
return thrCorpEntity;
}
).collect(Collectors.toList());
thrCorpImportDetailService.insertCorpDetailImports(thrCorpImportDetailEntities);
FilterThrCorpImportLogRequest filterThrCorpImportLogRequest = new FilterThrCorpImportLogRequest();
filterThrCorpImportLogRequest.setGenKey(genKey);
List<ThrCorpImportDetailEntity> temps = thrCorpImportDetailService.filterCorpDetailImport(filterThrCorpImportLogRequest);
List<ThrCorpEntity> thrCorpEntities = temps.stream().map(
item -> {
ThrCorpEntity thrProductsEntity = new ThrCorpEntity();
BeanUtils.copyProperties(item, thrProductsEntity);
thrProductsEntity.setThirdSysFk(thirdSys);
thrProductsEntity.setUpdateTime(new Date());
return thrProductsEntity;
}
).collect(Collectors.toList());
thrCorpService.insertThrCorpss(thrCorpEntities);
redisUtil.set(Constant.dlThrProducts, "false");
WebSocketServer.sendInfo("往来单位信息下载已完成,请刷新查看!", "sid");
thrProductsImportLogEntity.setStatus(BasicProcessStatus.UDIINFO_IMPORT_SUCCESS);
thrProductsImportLogEntity.setUpdateTime(new Date());
thrCorpImportLogService.updateImportLog(thrProductsImportLogEntity);
}
}
//主动下载第三方系统往来单位信息
@Async
public void importCorps(String genKey, ThrUnitMaintainFilterRequest thrUnitMaintainFilterRequest, String thirdSys) {
ThrSystemDetailEntity piDetailEntity = thrSystemDetailService.selectByKey("corpUrl", thirdSys);
if (piDetailEntity == null || piDetailEntity.getValue() == null) {
WebSocketServer.sendInfo("往来单位接口未设置!", "sid");
return;
}
ThrCorpImportLogEntity thrProductsImportLogEntity = thrCorpImportLogService.selectByGenKey(genKey);
int page = 1;
int limit = 100;
while (page != -1) {
page = getCorps(page, limit, piDetailEntity.getValue(), thrProductsImportLogEntity, thirdSys, genKey, thrUnitMaintainFilterRequest);
}
FilterThrCorpImportLogRequest filterUdiIpLogRequest = new FilterThrCorpImportLogRequest();
filterUdiIpLogRequest.setGenKey(genKey);
List<ThrCorpImportDetailEntity> thrCorpImportDetailEntities = thrCorpImportDetailService.filterCorpDetailImport(filterUdiIpLogRequest);
List<ThrCorpEntity> thrCorpEntities = thrCorpImportDetailEntities.stream().map(
item -> {
ThrCorpEntity thrProductsEntity = new ThrCorpEntity();
BeanUtils.copyProperties(item, thrProductsEntity);
thrProductsEntity.setUpdateTime(new Date());
thrProductsEntity.setThirdSysFk(thirdSys);
return thrProductsEntity;
}
).collect(Collectors.toList());
List<List<ThrCorpEntity>> splitList = CustomUtil.splitList(thrCorpEntities, 100);
for (List<ThrCorpEntity> data : splitList) {
thrCorpService.insertThrCorpss(data);
}
redisUtil.set(Constant.dlThrProducts, "false");
WebSocketServer.sendInfo("往来单位信息下载已完成,请刷新查看!", "sid");
thrProductsImportLogEntity.setStatus(BasicProcessStatus.UDIINFO_IMPORT_SUCCESS);
thrProductsImportLogEntity.setUpdateTime(new Date());
thrCorpImportLogService.updateImportLog(thrProductsImportLogEntity);
}
//导出生成Excel文件
@Async
public void genExcel(String genKey, ThrCorpExportRequest thrCorpExportRequest) {
ThrCorpExportLogEntity thrCorpExportLogEntity = thrCorpExportLogService.selectByGenKey(genKey);
List<List<String>> excelData = new ArrayList<>();
List<String> head = new ArrayList<>();
head.add("往来单位ID");
head.add("往来单位名称");
head.add("拼音简写");
head.add("地址");
head.add("社会信用号");
head.add("联系人");
head.add("联系电话");
excelData.add(head);
//选中导出
if (thrCorpExportRequest.getThrCorpEntities() != null && thrCorpExportRequest.getThrCorpEntities().size() > 0) {
List<ThrCorpEntity> corpEntities = thrCorpExportRequest.getThrCorpEntities();
for (ThrCorpEntity thrCorpEntity : corpEntities) {
List<String> rows = new ArrayList<>();
rows.add(thrCorpEntity.getUnitId());
rows.add(thrCorpEntity.getName());
rows.add(thrCorpEntity.getSpell());
rows.add(thrCorpEntity.getAddr());
rows.add(thrCorpEntity.getCreditNo());
rows.add(thrCorpEntity.getContact());
rows.add(thrCorpEntity.getMobile());
excelData.add(rows);
}
} else {//一键导出
//判断是否启用实时获取
ThrSystemDetailEntity thrSystemDetailEntity = thrSystemDetailService.selectByKey("corpUrl", thrCorpExportRequest.getThirdSys());
if (thrSystemDetailEntity == null || thrSystemDetailEntity.getValue() == null) {
thrCorpExportLogEntity.setStatus(BasicProcessStatus.UDIINFO_IMPORT_FAIL);
thrCorpExportLogEntity.setRemark("往来单位接口地址未定义");
thrCorpExportLogService.updateThrCorpExportLog(thrCorpExportLogEntity);
return;
}
if (!thrSystemDetailEntity.getEnabled()) {
thrCorpExportLogEntity.setStatus(BasicProcessStatus.UDIINFO_IMPORT_FAIL);
thrCorpExportLogEntity.setRemark("第三方接口往来单位服务接口未启用");
thrCorpExportLogService.updateThrCorpExportLog(thrCorpExportLogEntity);
return;
}
if (thrSystemDetailEntity.getFromType() == 0) {
//根据查询条件一键导出第三方系统往来单位
List<ThrCorpEntity> thrCorpEntities = exportCorps(thrCorpExportRequest);
excelData.addAll(getRows(thrCorpEntities));
} else {
//根据查询条件一键导出数据库往来单位
FilterThrCorpRequest filterThrCorpRequest = new FilterThrCorpRequest();
BeanUtils.copyProperties(thrCorpExportRequest, filterThrCorpRequest);
filterThrCorpRequest.setPage(null);
List<List<String>> genDatas = genExcelData(filterThrCorpRequest);
if (genDatas != null && genDatas.size() > 0) {
excelData.addAll(genDatas);
}
}
}
String sheetName = "往来单位信息";
new ExcelUtil().exportExcel(excelData, sheetName, thrCorpExportLogEntity.getFilePath(), 20);
thrCorpExportLogEntity.setStatus(BasicProcessStatus.UDIINFO_IMPORT_SUCCESS);
thrCorpExportLogService.updateThrCorpExportLog(thrCorpExportLogEntity);
}
//接收第三方上传或文件导入数据
@Async
public void insertData(String genKey, String thirdSys, List<ThrCorpsResponse> thrCorpsResponseList) {
ThrCorpImportLogEntity thrCorpImportLogEntity = thrCorpImportLogService.selectByGenKey(genKey);
//转入临时表
List<ThrCorpEntity> thrCorpEntities;
List<ThrCorpImportDetailEntity> thrCorpImportDetailEntities;
String finalGenKey = genKey;
thrCorpImportDetailEntities = thrCorpsResponseList.stream().map(
item -> {
ThrCorpImportDetailEntity thrCorpEntity = new ThrCorpImportDetailEntity();
BeanUtils.copyProperties(item, thrCorpEntity);
thrCorpEntity.setGenKeyFk(finalGenKey);
thrCorpEntity.setUpdateTime(new Date());
thrCorpEntity.setThirdSysFk(thirdSys);
return thrCorpEntity;
}
).collect(Collectors.toList());
// thrCorpImportDetailService.insertCorpDetailImports(thrCorpImportDetailEntities);
thrCorpEntities = thrCorpImportDetailEntities.stream().map(
item -> {
ThrCorpEntity thrCorpEntity = new ThrCorpEntity();
BeanUtils.copyProperties(item, thrCorpEntity);
// thrCorpEntity.setUnitId(item.getId());
thrCorpEntity.setUpdateTime(new Date());
thrCorpEntity.setThirdSysFk(thirdSys);
return thrCorpEntity;
}
).collect(Collectors.toList());
thrCorpService.insertThrCorpss(thrCorpEntities);
thrCorpImportLogEntity.setStatus(BasicProcessStatus.UDIINFO_IMPORT_SUCCESS);
thrCorpImportLogEntity.setUpdateTime(new Date());
thrCorpImportLogService.updateImportLog(thrCorpImportLogEntity);
}
public int getCorps(int page, int limit, String corpUrl, ThrCorpImportLogEntity thrCorpImportLogEntity, String thirdSys, String genKey, ThrUnitMaintainFilterRequest thrUnitMaintainFilterRequest) {
if (thrUnitMaintainFilterRequest == null)
thrUnitMaintainFilterRequest = new ThrUnitMaintainFilterRequest();
thrUnitMaintainFilterRequest.setPage(page);
thrUnitMaintainFilterRequest.setLimit(limit);
BaseResponse<PageSimpleResponse<ThrCorpsResponse>> erpCrops = erpBasicClient.getErpCrop(thrUnitMaintainFilterRequest);
if (erpCrops == null || erpCrops.getCode() != 20000) {
thrCorpImportLogEntity.setStatus(BasicProcessStatus.UDIINFO_IMPORT_FAIL);
thrCorpImportLogEntity.setRemark(erpCrops.getMessage());
thrCorpImportLogService.updateImportLog(thrCorpImportLogEntity);
return -1;
}
List<ThrCorpsResponse> erpUnitsResponses = erpCrops.getData().getList();
if (erpUnitsResponses != null && erpUnitsResponses.size() > 0) {
List<ThrCorpImportDetailEntity> thrCorpImportDetailEntities;
String finalGenKey = genKey;
thrCorpImportDetailEntities = erpUnitsResponses.stream().map(
item -> {
ThrCorpImportDetailEntity thrCorpEntity = new ThrCorpImportDetailEntity();
BeanUtils.copyProperties(item, thrCorpEntity);
thrCorpEntity.setUnitId(item.getUnitId());
thrCorpEntity.setGenKeyFk(finalGenKey);
thrCorpEntity.setUpdateTime(new Date());
thrCorpEntity.setThirdSysFk(thirdSys);
return thrCorpEntity;
}
).collect(Collectors.toList());
thrCorpImportDetailService.insertCorpDetailImports(thrCorpImportDetailEntities);
if (erpUnitsResponses.size() >= limit)
page++;
else {
return -1;
}
return page;
}
thrCorpImportLogEntity.setStatus(BasicProcessStatus.UDIINFO_IMPORT_SUCCESS);
thrCorpImportLogService.updateImportLog(thrCorpImportLogEntity);
return -1;
}
public List<ThrCorpEntity> exportCorps(ThrCorpExportRequest thrCorpExportRequest) {
ThrSystemDetailEntity corpEntity = thrSystemDetailService.selectByKey("corpUrl", thrCorpExportRequest.getThirdSys());
int page = 1;
int limit = 100;
List<ThrCorpEntity> thrCorpEntities = new ArrayList<>();
while (true) {
List<ThrCorpEntity> datas = getCorps(page, limit, corpEntity.getValue(), thrCorpExportRequest);
if (datas != null && datas.size() >= limit) {
thrCorpEntities.addAll(datas);
} else {
if (datas != null) {
thrCorpEntities.addAll(datas);
}
break;
}
}
return thrCorpEntities;
}
public List<ThrCorpEntity> getCorps(int page, int limit, String corpUrl, ThrCorpExportRequest thrCorpExportRequest) {
ThrUnitMaintainFilterRequest thrUnitMaintainFilterRequest = new ThrUnitMaintainFilterRequest();
thrUnitMaintainFilterRequest.setName(thrCorpExportRequest.getName());
thrUnitMaintainFilterRequest.setErpId(thrCorpExportRequest.getUnitId());
thrUnitMaintainFilterRequest.setPage(page);
thrUnitMaintainFilterRequest.setLimit(limit);
BaseResponse<PageSimpleResponse<ThrCorpsResponse>> erpCrops = new ErpBasicClient().getErpCrop(thrUnitMaintainFilterRequest);
if (erpCrops.getCode() != 20000) {
return null;
}
List<ThrCorpsResponse> erpUnitsResponses = erpCrops.getData().getList();
if (erpUnitsResponses != null && erpUnitsResponses.size() > 0) {
List<ThrCorpEntity> thrCorpEntities = erpUnitsResponses.stream().map(
item -> {
ThrCorpEntity thrProductsEntity = new ThrCorpEntity();
BeanUtils.copyProperties(item, thrProductsEntity);
thrProductsEntity.setUnitId(item.getId());
return thrProductsEntity;
}
).collect(Collectors.toList());
return thrCorpEntities;
}
return null;
}
public List<List<String>> genExcelData(FilterThrCorpRequest filterThrOrderRequest) {
List<List<String>> excelData = new ArrayList<>();
List<ThrCorpEntity> thrCorpEntityList=new ArrayList<>();
List<ThrCorpsResponse> thrCorpsResponseList = thrCorpService.filterThrCorps(filterThrOrderRequest);
if(thrCorpsResponseList.size()>0){
thrCorpEntityList = thrCorpsResponseList.stream().map(
item -> {
ThrCorpEntity thrCorpEntity = new ThrCorpEntity();
BeanUtils.copyProperties(item, thrCorpEntity);
return thrCorpEntity;
}
).collect(Collectors.toList());
}
excelData.addAll(getRows(thrCorpEntityList));
return excelData;
}
public List<List<String>> getRows(List<ThrCorpEntity> thrCorpEntities) {
List<List<String>> excelData = new ArrayList<>();
for (ThrCorpEntity thrCorpEntity : thrCorpEntities) {
List<String> rows = new ArrayList<>();
rows.add(thrCorpEntity.getUnitId());
rows.add(thrCorpEntity.getName());
rows.add(thrCorpEntity.getSpell());
rows.add(thrCorpEntity.getAddr());
rows.add(thrCorpEntity.getCreditNo());
rows.add(thrCorpEntity.getContact());
rows.add(thrCorpEntity.getMobile());
excelData.add(rows);
}
return excelData;
}
//导出生成json文件
@Async
public void genJsonFile(String genKey, ThrCorpExportRequest thrCorpExportRequest) {
ThrCorpExportLogEntity thrCorpExportLogEntity = thrCorpExportLogService.selectByGenKey(genKey);
List<ThrCorpEntity> exportData = new ArrayList<>();
//选中导出
if (thrCorpExportRequest.getThrCorpEntities() != null && thrCorpExportRequest.getThrCorpEntities().size() > 0) {
List<ThrCorpEntity> corpEntities = thrCorpExportRequest.getThrCorpEntities();
exportData.addAll(corpEntities);
} else {//一键导出
//判断是否启用实时获取
ThrSystemDetailEntity basicThirdSysDetailEntity = thrSystemDetailService.selectByKey("corpUrl", thrCorpExportRequest.getThirdSys());
if (basicThirdSysDetailEntity == null || basicThirdSysDetailEntity.getValue() == null) {
thrCorpExportLogEntity.setStatus(BasicProcessStatus.UDIINFO_IMPORT_FAIL);
thrCorpExportLogEntity.setRemark("往来单位接口地址未定义");
thrCorpExportLogService.updateThrCorpExportLog(thrCorpExportLogEntity);
return;
}
if (!basicThirdSysDetailEntity.getEnabled()) {
thrCorpExportLogEntity.setStatus(BasicProcessStatus.UDIINFO_IMPORT_FAIL);
thrCorpExportLogEntity.setRemark("第三方接口往来单位服务接口未启用");
thrCorpExportLogService.updateThrCorpExportLog(thrCorpExportLogEntity);
return;
}
if (basicThirdSysDetailEntity.getFromType() == 0) {
//根据查询条件一键导出第三方系统往来单位
List<ThrCorpEntity> thrCorpEntities = exportCorps(thrCorpExportRequest);
exportData.addAll(thrCorpEntities);
} else {
//根据查询条件一键导出数据库往来单位
List<ThrCorpEntity> thrCorpEntityList=new ArrayList<>();
FilterThrCorpRequest filterThrCorpRequest = new FilterThrCorpRequest();
BeanUtils.copyProperties(thrCorpExportRequest, filterThrCorpRequest);
filterThrCorpRequest.setPage(null);
List<ThrCorpsResponse> thrCorpsResponseList = thrCorpService.filterThrCorps(filterThrCorpRequest);
if(thrCorpsResponseList.size()>0){
thrCorpEntityList = thrCorpsResponseList.stream().map(
item -> {
ThrCorpEntity thrCorpEntity = new ThrCorpEntity();
BeanUtils.copyProperties(item, thrCorpEntity);
return thrCorpEntity;
}
).collect(Collectors.toList());
}
exportData.addAll(thrCorpEntityList);
}
}
FileWriter writer = new FileWriter(thrCorpExportLogEntity.getFilePath());
writer.write(JSONUtil.toJsonStr(exportData));
thrCorpExportLogEntity.setStatus(BasicProcessStatus.UDIINFO_IMPORT_SUCCESS);
thrCorpExportLogService.updateThrCorpExportLog(thrCorpExportLogEntity);
}
@Async
public void uploadSmp(String genKey, ThrCorpExportRequest thrCorpExportRequest) {
ThrCorpExportLogEntity thrCorpExportLogEntity = thrCorpExportLogService.selectByGenKey(genKey);
List<ThrCorpEntity> exportData = new ArrayList<>();
PostThrCorpRequest postThrCorpRequest = new PostThrCorpRequest();
//选中导出
if (thrCorpExportRequest.getThrCorpEntities() != null && thrCorpExportRequest.getThrCorpEntities().size() > 0) {
List<ThrCorpEntity> corpEntities = thrCorpExportRequest.getThrCorpEntities();
exportData.addAll(corpEntities);
} else {//一键导出
//判断是否启用实时获取
ThrSystemDetailEntity basicThirdSysDetailEntity = thrSystemDetailService.selectByKey("corpUrl", thrCorpExportRequest.getThirdSys());
if (basicThirdSysDetailEntity == null || basicThirdSysDetailEntity.getValue() == null) {
thrCorpExportLogEntity.setStatus(BasicProcessStatus.UDIINFO_IMPORT_FAIL);
thrCorpExportLogEntity.setRemark("往来单位接口地址未定义");
thrCorpExportLogService.updateThrCorpExportLog(thrCorpExportLogEntity);
return;
}
if (!basicThirdSysDetailEntity.getEnabled()) {
thrCorpExportLogEntity.setStatus(BasicProcessStatus.UDIINFO_IMPORT_FAIL);
thrCorpExportLogEntity.setRemark("第三方接口往来单位服务接口未启用");
thrCorpExportLogService.updateThrCorpExportLog(thrCorpExportLogEntity);
return;
}
if (basicThirdSysDetailEntity.getFromType() == 0) {
//根据查询条件一键导出第三方系统往来单位
List<ThrCorpEntity> thrCorpEntities = exportCorps(thrCorpExportRequest);
exportData.addAll(thrCorpEntities);
} else {
//根据查询条件一键导出数据库往来单位
List<ThrCorpEntity> thrCorpEntityList=new ArrayList<>();
FilterThrCorpRequest filterThrCorpRequest = new FilterThrCorpRequest();
BeanUtils.copyProperties(thrCorpExportRequest, filterThrCorpRequest);
filterThrCorpRequest.setPage(null);
List<ThrCorpsResponse> thrCorpsResponseList = thrCorpService.filterThrCorps(filterThrCorpRequest);
if(thrCorpsResponseList.size()>0){
thrCorpEntityList = thrCorpsResponseList.stream().map(
item -> {
ThrCorpEntity thrCorpEntity = new ThrCorpEntity();
BeanUtils.copyProperties(item, thrCorpEntity);
return thrCorpEntity;
}
).collect(Collectors.toList());
}
exportData.addAll(thrCorpEntityList);
}
}
postThrCorpRequest.setDatas(exportData);
postThrCorpRequest.setGenKey(genKey);
postThrCorpRequest.setThirdSys(thrCorpExportRequest.getThirdSys());
postThrCorpRequest.setUploadType("接口上传");
String response = httpOkClient.uCloudPost(getIpUrl() + "/spssync/thirdsys/corp/upload", postThrCorpRequest);
BaseResponse baseResponse = JSONObject.parseObject(response, new TypeReference<BaseResponse>() {
});
if (baseResponse.getCode() == 20000) {
thrCorpExportLogEntity.setStatus(BasicProcessStatus.UDIINFO_IMPORT_SUCCESS);
} else {
thrCorpExportLogEntity.setStatus(BasicProcessStatus.UDIINFO_IMPORT_FAIL);
}
thrCorpExportLogEntity.setStatus(BasicProcessStatus.UDIINFO_IMPORT_SUCCESS);
thrCorpExportLogService.updateThrCorpExportLog(thrCorpExportLogEntity);
}
}

@ -10,6 +10,7 @@ import com.glxp.api.entity.basic.BasicThirdSysDetailEntity;
import com.glxp.api.entity.system.SyncDataSetEntity;
import com.glxp.api.entity.thrsys.ThrProductsEntity;
import com.glxp.api.entity.thrsys.ThrProductsExportLogEntity;
import com.glxp.api.entity.thrsys.ThrSystemDetailEntity;
import com.glxp.api.http.ErpBasicClient;
import com.glxp.api.http.HttpOkClient;
import com.glxp.api.req.thrsys.FilterThrProductsRequest;
@ -17,7 +18,6 @@ import com.glxp.api.req.thrsys.PostThrProductsRequest;
import com.glxp.api.req.thrsys.ThrProductsExportRequest;
import com.glxp.api.res.PageSimpleResponse;
import com.glxp.api.res.thrsys.ThrProductsResponse;
import com.glxp.api.service.basic.BasicThirdSysDetailService;
import com.glxp.api.service.system.SyncDataSetService;
import org.springframework.beans.BeanUtils;
import org.springframework.scheduling.annotation.Async;
@ -25,7 +25,6 @@ import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.stream.Collectors;
@ -40,7 +39,7 @@ public class ThrProductsDlService {
@Resource
ThrProductsService thrProductsService;
@Resource
BasicThirdSysDetailService basicThirdSysDetailService;
ThrSystemDetailService thrSystemDetailService;
// @Resource
// RedisUtil redisUtil;
// @Resource
@ -315,15 +314,15 @@ public class ThrProductsDlService {
} else {//一键导出
BasicThirdSysDetailEntity basicThirdSysDetailEntity = basicThirdSysDetailService.selectByKey("piQueryUrl", thrProductsExportRequest.getThirdSys());
if (basicThirdSysDetailEntity == null || basicThirdSysDetailEntity.getValue() == null) {
ThrSystemDetailEntity thrSystemDetailEntity = thrSystemDetailService.selectByKey("piQueryUrl", thrProductsExportRequest.getThirdSys());
if (thrSystemDetailEntity == null || thrSystemDetailEntity.getValue() == null) {
thrProductsExportLogEntity.setStatus(BasicProcessStatus.UDIINFO_IMPORT_FAIL);
thrProductsExportLogEntity.setRemark("产品信息接口未定义!");
thrProductsExportLogService.updateThrProductsExportLog(thrProductsExportLogEntity);
return;
}
if (!basicThirdSysDetailEntity.getEnabled()) {
if (!thrSystemDetailEntity.getEnabled()) {
thrProductsExportLogEntity.setStatus(BasicProcessStatus.UDIINFO_IMPORT_FAIL);
thrProductsExportLogEntity.setRemark("第三方系统产品信息接口服务未启用!");
thrProductsExportLogService.updateThrProductsExportLog(thrProductsExportLogEntity);
@ -331,7 +330,7 @@ public class ThrProductsDlService {
}
List<ThrProductsResponse> thrProductsResponses=new ArrayList<>();
if (basicThirdSysDetailEntity.getFromType() == 0) {
if (thrSystemDetailEntity.getFromType() == 0) {
FilterThrProductsRequest filterThrProductsRequest = new FilterThrProductsRequest();
BeanUtils.copyProperties(thrProductsExportRequest, filterThrProductsRequest);
List<ThrProductsEntity> thrProductsEntities= exportThrProducts(filterThrProductsRequest);
@ -464,12 +463,12 @@ public class ThrProductsDlService {
// }
//
public List<ThrProductsEntity> exportThrProducts(FilterThrProductsRequest filterThrProductsRequest) {
BasicThirdSysDetailEntity basicThirdSysDetailEntity = basicThirdSysDetailService.selectByKey("piQueryUrl", filterThrProductsRequest.getThirdSys());
ThrSystemDetailEntity thrSystemDetailEntity = thrSystemDetailService.selectByKey("piQueryUrl", filterThrProductsRequest.getThirdSys());
int page = 1;
int limit = 100;
List<ThrProductsEntity> thrProductsEntities = new ArrayList<>();
while (true) {
List<ThrProductsEntity> datas = getThrProducrts(page, limit, basicThirdSysDetailEntity.getValue(), filterThrProductsRequest);
List<ThrProductsEntity> datas = getThrProducrts(page, limit, thrSystemDetailEntity.getValue(), filterThrProductsRequest);
if (datas != null && datas.size() >= limit) {
thrProductsEntities.addAll(datas);
page++;
@ -565,22 +564,22 @@ public class ThrProductsDlService {
exportData.addAll(thrProductsEntities);
} else {//一键导出
BasicThirdSysDetailEntity basicThirdSysDetailEntity = basicThirdSysDetailService.selectByKey("piQueryUrl", thrProductsExportRequest.getThirdSys());
if (basicThirdSysDetailEntity == null || basicThirdSysDetailEntity.getValue() == null) {
ThrSystemDetailEntity thrSystemDetailEntity = thrSystemDetailService.selectByKey("piQueryUrl", thrProductsExportRequest.getThirdSys());
if (thrSystemDetailEntity == null || thrSystemDetailEntity.getValue() == null) {
thrProductsExportLogEntity.setStatus(BasicProcessStatus.UDIINFO_IMPORT_FAIL);
thrProductsExportLogEntity.setRemark("产品信息接口未定义!");
thrProductsExportLogService.updateThrProductsExportLog(thrProductsExportLogEntity);
return;
}
if (!basicThirdSysDetailEntity.getEnabled()) {
if (!thrSystemDetailEntity.getEnabled()) {
thrProductsExportLogEntity.setStatus(BasicProcessStatus.UDIINFO_IMPORT_FAIL);
thrProductsExportLogEntity.setRemark("第三方系统产品信息接口服务未启用!");
thrProductsExportLogService.updateThrProductsExportLog(thrProductsExportLogEntity);
return;
}
if (basicThirdSysDetailEntity.getFromType() == 0) {
if (thrSystemDetailEntity.getFromType() == 0) {
FilterThrProductsRequest filterThrProductsRequest = new FilterThrProductsRequest();
BeanUtils.copyProperties(thrProductsExportRequest, filterThrProductsRequest);
List<ThrProductsEntity> thrProductsEntities = exportThrProducts(filterThrProductsRequest);

@ -3,6 +3,7 @@ package com.glxp.api.service.thrsys;
import com.glxp.api.entity.thrsys.ThrSystemEntity;
import com.glxp.api.req.thrsys.FilterBasicThirdSysRequest;
import org.apache.ibatis.annotations.Param;
import java.util.List;
@ -25,6 +26,13 @@ public interface ThrSystemService {
* @return
*/
boolean selectThirdNameExists(String thirdId, String thirdName);
/**
* ID
*
* @param thirdId
* @return
*/
String selectThirdNameByThirdId(@Param("thirdId") String thirdId);
int countThirdSys(FilterBasicThirdSysRequest filterBasicThirdSysRequest);

@ -0,0 +1,69 @@
package com.glxp.api.service.thrsys.impl;
import cn.hutool.core.io.FileUtil;
import cn.hutool.core.util.StrUtil;
import com.github.pagehelper.PageHelper;
import com.glxp.api.dao.thrsys.ThrCorpExportLogDao;
import com.glxp.api.entity.thrsys.FilterThrCorpExportLogRequest;
import com.glxp.api.entity.thrsys.ThrCorpExportLogEntity;
import com.glxp.api.service.thrsys.ThrCorpExportLogService;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.Collections;
import java.util.List;
@Service
public class ThrCorpExportLogServiceImpl implements ThrCorpExportLogService {
@Resource
ThrCorpExportLogDao thrCorpExportLogDao;
@Override
public ThrCorpExportLogEntity selectByGenKey(String genKey) {
FilterThrCorpExportLogRequest filterThrCorpExportLogRequest = new FilterThrCorpExportLogRequest();
filterThrCorpExportLogRequest.setGenKey(genKey);
List<ThrCorpExportLogEntity> data = thrCorpExportLogDao.filterThrCorpExportLog(filterThrCorpExportLogRequest);
if (data != null && data.size() > 0) {
return data.get(0);
}
return null;
}
@Override
public List<ThrCorpExportLogEntity> filterThrCorpExportLog(FilterThrCorpExportLogRequest filterThrCorpExportLogRequest) {
if (filterThrCorpExportLogRequest == null) {
return Collections.emptyList();
}
if (filterThrCorpExportLogRequest.getPage() != null) {
int offset = (filterThrCorpExportLogRequest.getPage() - 1) * filterThrCorpExportLogRequest.getLimit();
PageHelper.offsetPage(offset, filterThrCorpExportLogRequest.getLimit());
}
List<ThrCorpExportLogEntity> data = thrCorpExportLogDao.filterThrCorpExportLog(filterThrCorpExportLogRequest);
return data;
}
@Override
public boolean insertThrCorpExportLog(ThrCorpExportLogEntity thrCorpExportLogEntity) {
return thrCorpExportLogDao.insertThrCorpExportLog(thrCorpExportLogEntity);
}
@Override
public boolean updateThrCorpExportLog(ThrCorpExportLogEntity thrCorpExportLogEntity) {
return thrCorpExportLogDao.updateThrCorpExportLog(thrCorpExportLogEntity);
}
@Override
public boolean deleteById(String id) {
//删除日志同步删除文件
String filePath = thrCorpExportLogDao.selectFilePathById(id);
if (StrUtil.isNotBlank(filePath)) {
FileUtil.del(filePath);
}
return thrCorpExportLogDao.deleteById(id);
}
@Override
public boolean deleteByTime() {
return thrCorpExportLogDao.deleteByTime();
}
}

@ -0,0 +1,62 @@
package com.glxp.api.service.thrsys.impl;
import com.github.pagehelper.PageHelper;
import com.glxp.api.dao.thrsys.ThrCorpImportDetailDao;
import com.glxp.api.entity.thrsys.ThrCorpImportDetailEntity;
import com.glxp.api.req.thrsys.FilterThrCorpImportLogRequest;
import com.glxp.api.service.thrsys.ThrCorpImportDetailService;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.Collections;
import java.util.List;
@Service
public class ThrCorpImportDetailServiceImpl implements ThrCorpImportDetailService {
@Resource
ThrCorpImportDetailDao thrCorpImportDetailDao;
@Override
public List<ThrCorpImportDetailEntity> filterCorpDetailImport(FilterThrCorpImportLogRequest filterThrCorpImportLogRequest) {
if (filterThrCorpImportLogRequest == null) {
return Collections.emptyList();
}
if (filterThrCorpImportLogRequest.getPage() != null) {
int offset = (filterThrCorpImportLogRequest.getPage() - 1) * filterThrCorpImportLogRequest.getLimit();
PageHelper.offsetPage(offset, filterThrCorpImportLogRequest.getLimit());
}
List<ThrCorpImportDetailEntity> data = thrCorpImportDetailDao.filterCorpDetailImport(filterThrCorpImportLogRequest);
return data;
}
@Override
public boolean insertCorpDetailImport(ThrCorpImportDetailEntity thrCorpImportDetailEntity) {
return thrCorpImportDetailDao.insertCorpDetailImport(thrCorpImportDetailEntity);
}
@Override
public boolean updateCorpDetailImport(ThrCorpImportDetailEntity thrCorpImportDetailEntity) {
return thrCorpImportDetailDao.updateCorpDetailImport(thrCorpImportDetailEntity);
}
@Override
public boolean insertCorpDetailImports(List<ThrCorpImportDetailEntity> thrCorpImportDetailEntities) {
return thrCorpImportDetailDao.insertCorpDetailImports(thrCorpImportDetailEntities);
}
@Override
public boolean deleteById(String id) {
return thrCorpImportDetailDao.deleteById(id);
}
@Override
public boolean deleteByGenkey(String genKey) {
return thrCorpImportDetailDao.deleteByGenkey(genKey);
}
@Override
public boolean deleteByTime() {
return thrCorpImportDetailDao.deleteByTime();
}
}

@ -0,0 +1,64 @@
package com.glxp.api.service.thrsys.impl;
import com.github.pagehelper.PageHelper;
import com.glxp.api.dao.thrsys.ThrCorpImportLogDao;
import com.glxp.api.entity.thrsys.ThrCorpImportLogEntity;
import com.glxp.api.req.thrsys.FilterThrCorpImportLogRequest;
import com.glxp.api.service.thrsys.ThrCorpImportLogService;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.Collections;
import java.util.List;
@Service
public class ThrCorpImportLogServiceImpl implements ThrCorpImportLogService {
@Resource
ThrCorpImportLogDao thrCorpImportLogDao;
@Override
public ThrCorpImportLogEntity selectByGenKey(String genKey) {
FilterThrCorpImportLogRequest filterUdiIpLogRequest = new FilterThrCorpImportLogRequest();
filterUdiIpLogRequest.setGenKey(genKey);
List<ThrCorpImportLogEntity> data = thrCorpImportLogDao.filterThrCorpImportLog(filterUdiIpLogRequest);
if (data != null && data.size() > 0) {
return data.get(0);
}
return null;
}
@Override
public List<ThrCorpImportLogEntity> filterThrCorpImportLog(FilterThrCorpImportLogRequest filterThrCorpImportLogRequest) {
if (filterThrCorpImportLogRequest == null) {
return Collections.emptyList();
}
if (filterThrCorpImportLogRequest.getPage() != null) {
int offset = (filterThrCorpImportLogRequest.getPage() - 1) * filterThrCorpImportLogRequest.getLimit();
PageHelper.offsetPage(offset, filterThrCorpImportLogRequest.getLimit());
}
List<ThrCorpImportLogEntity> data = thrCorpImportLogDao.filterThrCorpImportLog(filterThrCorpImportLogRequest);
return data;
}
@Override
public boolean insertImportLog(ThrCorpImportLogEntity thrCorpImportLogEntity) {
return thrCorpImportLogDao.insertImportLog(thrCorpImportLogEntity);
}
@Override
public boolean updateImportLog(ThrCorpImportLogEntity thrCorpImportLogEntity) {
return thrCorpImportLogDao.updateImportLog(thrCorpImportLogEntity);
}
@Override
public boolean deleteById(String id) {
return thrCorpImportLogDao.deleteById(id);
}
@Override
public boolean deleteByTime() {
return thrCorpImportLogDao.deleteByTime();
}
}

@ -0,0 +1,90 @@
package com.glxp.api.service.thrsys.impl;
import com.github.pagehelper.PageHelper;
import com.glxp.api.dao.thrsys.ThrCorpDao;
import com.glxp.api.entity.basic.BasicThirdSysDetailEntity;
import com.glxp.api.entity.basic.BasicUnitMaintainEntity;
import com.glxp.api.entity.thrsys.ThrCorpEntity;
import com.glxp.api.req.thrsys.FilterThrCorpRequest;
import com.glxp.api.req.thrsys.ThrUnitMaintainFilterRequest;
import com.glxp.api.res.thrsys.ThrCorpsResponse;
import com.glxp.api.service.thrsys.ThrCorpService;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.Collections;
import java.util.List;
@Service
public class ThrCorpServiceImpl implements ThrCorpService {
@Resource
private ThrCorpDao thrCorpDao;
@Override
public List<ThrCorpsResponse> filterThrCorps(FilterThrCorpRequest filterThrCorpRequest) {
if (filterThrCorpRequest == null) {
return Collections.emptyList();
}
if (filterThrCorpRequest.getPage() != null) {
int offset = (filterThrCorpRequest.getPage() - 1) * filterThrCorpRequest.getLimit();
PageHelper.offsetPage(offset, filterThrCorpRequest.getLimit());
}
List<ThrCorpsResponse> data = thrCorpDao.filterThrCorps(filterThrCorpRequest);
return data;
}
@Override
public boolean insertThrCorps(ThrCorpEntity thrCorpEntity) {
return thrCorpDao.insertThrCorps(thrCorpEntity);
}
@Override
public boolean insertThrCorpss(List<ThrCorpEntity> thrCorpEntitys) {
return thrCorpDao.insertThrCorpss(thrCorpEntitys);
}
@Override
public boolean updateThrCorps(ThrCorpEntity thrCorpEntity) {
return thrCorpDao.updateThrCorps(thrCorpEntity);
}
@Override
public boolean deleteById(String id) {
return thrCorpDao.deleteById(id);
}
@Override
public boolean deleteByUnitId(String id) {
return thrCorpDao.deleteByUnitId(id);
}
@Override
public boolean deleteAll() {
return thrCorpDao.deleteAll();
}
@Override
public BasicUnitMaintainEntity selectByThirdId(String thirdId, String thirdSys) {
ThrUnitMaintainFilterRequest filterUdiInfoRequest = new ThrUnitMaintainFilterRequest();
if ("thirdId".equals(thirdSys)) {
filterUdiInfoRequest.setThirdId(thirdId);
} else if ("thirdId1".equals(thirdSys)) {
filterUdiInfoRequest.setThirdId1(thirdId);
} else if ("thirdId2".equals(thirdSys)) {
filterUdiInfoRequest.setThirdId2(thirdId);
} else if ("thirdId3".equals(thirdSys)) {
filterUdiInfoRequest.setThirdId3(thirdId);
} else if ("thirdId4".equals(thirdSys)) {
filterUdiInfoRequest.setThirdId4(thirdId);
}
return thrCorpDao.selectByThirdId(filterUdiInfoRequest);
}
@Override
public BasicThirdSysDetailEntity selectByKey(String key, String thirdSys) {
return thrCorpDao.selectByKey(key,thirdSys);
}
}

@ -2,16 +2,14 @@ package com.glxp.api.service.thrsys.impl;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.github.pagehelper.PageHelper;
import com.glxp.api.dao.basic.BasicThirdSysDao;
import com.glxp.api.dao.basic.BasicThirdSysDetailDao;
import com.glxp.api.entity.thrsys.ThrProductsEntity;
import com.glxp.api.dao.thrsys.ThrProductsDao;
import com.glxp.api.entity.thrsys.ThrSystemEntity;
import com.glxp.api.req.thrsys.FilterThrProductsRequest;
import com.glxp.api.res.thrsys.ThrProductsResponse;
import com.glxp.api.service.thrsys.ThrProductsService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.glxp.api.service.thrsys.ThrSystemService;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
@ -33,7 +31,7 @@ public class ThrProductsServiceImpl implements ThrProductsService {
ThrProductsDao thrProductsDao;
@Resource
BasicThirdSysDao basicThirdSysDao;
ThrSystemService thrSystemService;
@Override
public List<ThrProductsResponse> filterThrProductsRequest(FilterThrProductsRequest filterThrProductsRequest) {
@ -49,7 +47,7 @@ public class ThrProductsServiceImpl implements ThrProductsService {
if (CollUtil.isNotEmpty(data)) {
for (ThrProductsResponse thrProductsResponse : data) {
if (StrUtil.isNotBlank(thrProductsResponse.getThirdSysFk())) {
String thirdName = basicThirdSysDao.selectThirdNameByThirdId(thrProductsResponse.getThirdSysFk());
String thirdName = thrSystemService.selectThirdNameByThirdId(thrProductsResponse.getThirdSysFk());
thrProductsResponse.setThirdSysName(thirdName);
}
}

@ -86,6 +86,11 @@ public class ThrSystemServiceImpl implements ThrSystemService {
return false;
}
@Override
public String selectThirdNameByThirdId(String thirdId) {
return thrSystemDao.selectThirdNameByThirdId(thirdId);
}
@Override
public int countThirdSys(FilterBasicThirdSysRequest filterBasicThirdSysRequest) {
return thrSystemDao.countThirdSys(filterBasicThirdSysRequest);

@ -1,68 +0,0 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="com.glxp.api.dao.basic.BasicThirdSysDao">
<!-- <update id="updateBasicThiSys" parameterType="com.glxp.api.admin.entity.basic.BasicThirdSysEntity">-->
<!-- UPDATE basic_third_sys-->
<!-- <trim prefix="set" suffixOverrides=",">-->
<!-- <if test="thirdId != null">thirdId=#{thirdId},</if>-->
<!-- <if test="thirdName != null">thirdName=#{thirdName},</if>-->
<!-- <if test="guideUrl != null">guideUrl=#{guideUrl},</if>-->
<!-- <if test="remark != null">remark=#{remark},</if>-->
<!-- <if test="thridUrl != null">thridUrl=#{thridUrl},</if>-->
<!-- <if test="enabled != null">enabled=#{enabled},</if>-->
<!-- <if test="mainSys != null">mainSys=#{mainSys},</if>-->
<!-- <if test="thirdSysUrl != null">thirdSysUrl=#{thirdSysUrl},</if>-->
<!-- <if test="apikey != null">apikey=#{apikey},</if>-->
<!-- <if test="secretkey != null">secretkey=#{secretkey}</if>-->
<!-- </trim>-->
<!-- WHERE id=#{id}-->
<!-- </update>-->
<!-- <select id="filterBasicThiSys" parameterType="com.glxp.api.req.basic.FilterBasicThirdSysRequest"-->
<!-- resultType="com.glxp.api.entity.basic.BasicThirdSysEntity">-->
<!-- SELECT * FROM basic_third_sys-->
<!-- <where>-->
<!-- <if test="thirdId != '' and thirdId != null">-->
<!-- AND thirdId like concat('%',#{thirdId},'%')-->
<!-- </if>-->
<!-- <if test="thirdName != '' and thirdName != null">-->
<!-- AND thirdName like concat('%',#{thirdName},'%')-->
<!-- </if>-->
<!-- <if test="enabled != null">-->
<!-- AND enabled = #{enabled}-->
<!-- </if>-->
<!-- <if test="mainSys != '' and mainSys != null">-->
<!-- AND mainSys = #{mainSys}-->
<!-- </if>-->
<!-- </where>-->
<!-- </select>-->
<select id="selectByThirdId" parameterType="Map" resultType="com.glxp.api.entity.basic.BasicThirdSysEntity">
select * FROM basic_third_sys WHERE thirdId = #{thirdId}
</select>
<!-- <select id="selectEnabledThirdId" resultType="java.lang.String">-->
<!-- select thirdId-->
<!-- from basic_third_sys-->
<!-- where enabled = true-->
<!-- </select>-->
<!-- <select id="selectCountByThirdName" resultType="java.lang.Integer">-->
<!-- select count(*) from basic_third_sys where thirdName =#{thirdName}-->
<!-- </select>-->
<!-- <select id="selectByThirdIdAndThirdName" resultType="com.glxp.api.admin.entity.basic.BasicThirdSysEntity">-->
<!-- select * from basic_third_sys where thirdId = #{thirdId} and thirdName = #{thirdName}-->
<!-- </select>-->
<select id="selectThirdNameByThirdId" resultType="java.lang.String">
select thirdName from basic_third_sys where thirdId = #{thirdId}
</select>
<!-- <select id="countThirdSys" resultType="java.lang.Integer">-->
<!-- select count(*) from basic_third_sys-->
<!-- <where>-->
<!-- <if test="enabled != null">-->
<!-- AND enabled = #{enabled}-->
<!-- </if>-->
<!-- </where>-->
<!-- </select>-->
</mapper>

@ -1,17 +0,0 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="com.glxp.api.dao.basic.BasicThirdSysDetailDao">
<select id="selectByKey" parameterType="Map"
resultType="com.glxp.api.entity.basic.BasicThirdSysDetailEntity">
select basic_third_sys_detail.*, basic_third_sys.thridUrl
FROM basic_third_sys_detail
inner join basic_third_sys on basic_third_sys_detail.thirdSysFk = basic_third_sys.thirdId
WHERE basic_third_sys_detail.key = #{key}
and basic_third_sys_detail.thirdSysFk = #{thirdSys}
and basic_third_sys.enabled = 1
</select>
</mapper>

@ -0,0 +1,157 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="com.glxp.api.dao.thrsys.ThrCorpDao">
<select id="filterThrCorps" parameterType="com.glxp.api.req.thrsys.FilterThrCorpRequest"
resultType="com.glxp.api.res.thrsys.ThrCorpsResponse">
SELECT * FROM thr_corp
<where>
<if test="unitId != '' and unitId != null">
AND unitId like concat('%',#{unitId},'%')
</if>
<if test="name != '' and name != null">
AND ( name LIKE concat('%',#{name},'%') or spell LIKE concat('%',#{name},'%') )
</if>
<if test="thirdSysFk != '' and thirdSysFk != null">
AND thirdSysFk = #{thirdSysFk}
</if>
<if test="lastUpdateTime!=null and lastUpdateTime!=''">
<![CDATA[ and DATE_FORMAT(updateTime, '%Y-%m-%d %H:%i:%S')>= DATE_FORMAT(#{lastUpdateTime}, '%Y-%m-%d %H:%i:%S') ]]>
</if>
</where>
ORDER BY updateTime DESC
</select>
<insert id="insertThrCorps" keyProperty="id" parameterType="com.glxp.api.entity.thrsys.ThrCorpEntity">
replace
INTO thr_corp
(
unitId,name,spell,addr,creditNo,
contact,mobile,thirdSysFk,updateTime
)
values
(
#{unitId},
#{name},
#{spell},
#{addr},
#{creditNo},
#{contact},
#{mobile},
#{thirdSysFk},
#{updateTime}
)
</insert>
<insert id="insertThrCorpss" keyProperty="id" parameterType="java.util.List">
replace INTO thr_corp
(
unitId,name,spell,addr,creditNo,
contact,mobile,thirdSysFk,updateTime
)
values
<foreach collection="thrCorpEntitys" item="item" index="index"
separator=",">
(
#{item.unitId},
#{item.name},
#{item.spell},
#{item.addr},
#{item.creditNo},
#{item.contact},
#{item.mobile},
#{item.thirdSysFk},#{item.updateTime}
)
</foreach>
</insert>
<delete id="deleteById" parameterType="Map">
DELETE
FROM thr_corp
WHERE id = #{id}
</delete>
<delete id="deleteByUnitId" parameterType="Map">
DELETE
FROM thr_corp
WHERE unitId = #{unitId}
</delete>
<delete id="deleteAll">
DELETE
FROM thr_corp
</delete>
<update id="updateThrCorps" parameterType="com.glxp.api.entity.thrsys.ThrCorpEntity">
UPDATE thr_corp
<trim prefix="set" suffixOverrides=",">
<if test="unitId != null">unitId=#{unitId},</if>
<if test="name != null">name=#{name},</if>
<if test="spell != null">spell=#{spell},</if>
<if test="addr != null">addr=#{addr},</if>
<if test="creditNo != null">creditNo=#{creditNo},</if>
<if test="contact != null">contact=#{contact},</if>
<if test="mobile != null">mobile=#{mobile},</if>
<if test="thirdSysFk != null">thirdSysFk=#{thirdSysFk},</if>
<if test="updateTime != null">updateTime=#{updateTime},</if>
</trim>
WHERE id = #{id}
</update>
<insert id="importThrCorp" parameterType="com.glxp.api.entity.thrsys.ThrCorpEntity">
replace
into thr_corp (unitId, spell, addr, creditNo, contact, mobile, thirdSysFk, name, updateTime)
values (
#{unitId},
#{spell},
#{addr},
#{creditNo},
#{contact},
#{mobile},
#{thirdSysFk},
#{name},
#{updateTime}
)
</insert>
<select id="selectByThirdId" parameterType="com.glxp.api.req.thrsys.ThrUnitMaintainFilterRequest"
resultType="com.glxp.api.entity.basic.BasicUnitMaintainEntity">
select * FROM basic_corp
<where>
<if test="thirdId != '' and thirdId != null">
AND thirdId = #{thirdId}
</if>
<if test="thirdId1 != '' and thirdId1 != null">
AND thirdId1 = #{thirdId1}
</if>
<if test="thirdId2 != '' and thirdId2 != null">
AND thirdId2 = #{thirdId2}
</if>
<if test="thirdId3 != '' and thirdId3 != null">
AND thirdId3 = #{thirdId3}
</if>
<if test="thirdId4 != '' and thirdId4 != null">
AND thirdId4 = #{thirdId4}
</if>
<if test="corpType != null">
AND corpType = #{corpType}
</if>
</where>
limit 1
</select>
<select id="selectByKey" parameterType="Map"
resultType="com.glxp.api.entity.basic.BasicThirdSysDetailEntity">
select basic_third_sys_detail.*, basic_third_sys.thridUrl
FROM basic_third_sys_detail
inner join basic_third_sys on basic_third_sys_detail.thirdSysFk = basic_third_sys.thirdId
WHERE basic_third_sys_detail.key = #{key}
and basic_third_sys_detail.thirdSysFk = #{thirdSys}
and basic_third_sys.enabled = 1
</select>
</mapper>

@ -0,0 +1,61 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="com.glxp.api.dao.thrsys.ThrCorpExportLogDao">
<select id="filterThrCorpExportLog" parameterType="com.glxp.api.req.thrsys.FilterThrProductsExportLogRequest"
resultType="com.glxp.api.entity.thrsys.ThrCorpExportLogEntity">
SELECT * FROM thr_corp_export_log
<where>
<if test="genKey != '' and genKey != null">
AND genKey = #{genKey}
</if>
<if test="status != '' and status != null">
AND status = #{status}
</if>
<if test="type != '' and type != null">
AND `type` = #{type}
</if>
</where>
ORDER BY updateTime DESC
</select>
<select id="selectFilePathById" resultType="java.lang.String">
select filePath from thr_corp_export_log where id = #{id}
</select>
<insert id="insertThrCorpExportLog" keyProperty="id"
parameterType="com.glxp.api.entity.thrsys.ThrCorpExportLogEntity">
insert INTO thr_corp_export_log
(genKey,updateTime,dlCount,status,filePath,remark,`type`)
values
(
#{genKey},
#{updateTime},
#{dlCount},#{status},#{filePath},#{remark},#{type}
)
</insert>
<delete id="deleteById" parameterType="Map">
DELETE FROM thr_corp_export_log WHERE id = #{id}
</delete>
<update id="updateThrCorpExportLog" parameterType="com.glxp.api.entity.thrsys.ThrCorpExportLogEntity">
UPDATE thr_corp_export_log
<set>
<if test="updateTime != null">updateTime=#{updateTime},</if>
<if test="dlCount != null">dlCount=#{dlCount},</if>
<if test="status != null">status=#{status},</if>
<if test="filePath != null">filePath=#{filePath},</if>
<if test="remark != null">remark=#{remark},</if>
</set>
WHERE genKey = #{genKey}
</update>
<delete id="deleteByTime">
Delete From thr_corp_export_log
where date(updateTime) &lt;= date(DATE_SUB(NOW(),INTERVAL 30 day))
</delete>
</mapper>

@ -0,0 +1,97 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="com.glxp.api.dao.thrsys.ThrCorpImportDetailDao">
<select id="filterCorpDetailImport" parameterType="com.glxp.api.req.thrsys.FilterThrCorpImportLogRequest"
resultType="com.glxp.api.entity.thrsys.ThrCorpImportDetailEntity">
SELECT * FROM thr_corp_import_detail
<where>
<if test="genKey != '' and genKey != null">
AND genKeyFk = #{genKey}
</if>
<if test="id != '' and id != null">
AND id = #{id}
</if>
<if test="status != '' and status != null">
AND status = #{status}
</if>
<if test="thirdSysFk != '' and thirdSysFk != null">
AND thirdSysFk = #{thirdSysFk}
</if>
</where>
</select>
<insert id="insertCorpDetailImport" keyProperty="id"
parameterType="com.glxp.api.entity.thrsys.ThrCorpImportDetailEntity">
insert INTO thr_corp_import_detail
(
unitId,name,spell,addr,creditNo,
contact,mobile,thirdSysFk,updateTime ,genKeyFk
)
values
(
#{unitId},
#{name},
#{spell},
#{addr},
#{creditNo},
#{contact},
#{mobile},
#{thirdSysFk},
#{updateTime},
#{genKeyFk}
)
</insert>
<insert id="insertCorpDetailImports" keyProperty="id" parameterType="java.util.List">
insert INTO thr_corp_import_detail
(
unitId,name,spell,addr,creditNo,
contact,mobile,thirdSysFk ,updateTime ,genKeyFk )
values
<foreach collection="corps" item="item" index="index"
separator=",">
(
#{item.unitId},
#{item.name},
#{item.spell},
#{item.addr},
#{item.creditNo},
#{item.contact},
#{item.mobile},
#{item.thirdSysFk} ,#{item.updateTime},#{item.genKeyFk} )
</foreach>
</insert>
<delete id="deleteById" parameterType="Map">
DELETE FROM thr_corp_import_detail WHERE id = #{id}
</delete>
<delete id="deleteByGenkey" parameterType="Map">
DELETE FROM thr_corp_import_detail WHERE genKeyFk = #{genKey}
</delete>
<update id="updateCorpDetailImport" parameterType="com.glxp.api.entity.thrsys.ThrCorpImportDetailEntity">
UPDATE thr_corp_import_detail
<trim prefix="set" suffixOverrides=",">
<if test="unitId != null">unitId=#{unitId},</if>
<if test="name != null">name=#{name},</if>
<if test="spell != null">spell=#{spell},</if>
<if test="addr != null">addr=#{addr},</if>
<if test="creditNo != null">creditNo=#{creditNo},</if>
<if test="contact != null">contact=#{contact},</if>
<if test="mobile != null">mobile=#{mobile},</if>
<if test="thirdSysFk != null">thirdSysFk=#{thirdSysFk},</if>
<if test="updateTime != null">updateTime=#{updateTime},</if>
<if test="genKeyFk != null">genKeyFk=#{genKeyFk},</if>
</trim>
WHERE id = #{id}
</update>
<delete id="deleteByTime">
Delete From thr_corp_import_detail
where date(updateTime) &lt;= date(DATE_SUB(NOW(),INTERVAL 30 day))
</delete>
</mapper>

@ -0,0 +1,63 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="com.glxp.api.dao.thrsys.ThrCorpImportLogDao">
<select id="filterThrCorpImportLog" parameterType="com.glxp.api.req.thrsys.FilterThrCorpImportLogRequest"
resultType="com.glxp.api.entity.thrsys.ThrCorpImportLogEntity">
SELECT * FROM thr_corp_import_log
<where>
<if test="genKey != '' and genKey != null">
AND genKey = #{genKey}
</if>
<if test="id != '' and id != null">
AND id = #{id}
</if>
<if test="status != null">
AND status = #{status}
</if>
<if test="thirdSysFk != '' and thirdSysFk != null">
AND thirdSysFk = #{thirdSysFk}
</if>
</where>
ORDER BY updateTime DESC
</select>
<insert id="insertImportLog" keyProperty="id" parameterType="com.glxp.api.entity.thrsys.ThrCorpImportLogEntity">
insert INTO thr_corp_import_log
(genKey,fromType,updateTime,thirdSysFk,status)
values
(
#{genKey},
#{fromType},
#{updateTime},
#{thirdSysFk},#{status}
)
</insert>
<delete id="deleteById" parameterType="Map">
DELETE FROM thr_corp_import_log WHERE id = #{id}
</delete>
<update id="updateImportLog" parameterType="com.glxp.api.entity.thrsys.ThrCorpImportLogEntity">
UPDATE thr_corp_import_log
<set>
<if test="genKey != null">genKey=#{genKey},</if>
<if test="fromType != null">fromType=#{fromType},</if>
<if test="updateTime != null">updateTime=#{updateTime},</if>
<if test="thirdSysFk != null">thirdSysFk=#{thirdSysFk},</if>
<if test="status != null">status=#{status},</if>
<if test="remark != null">remark=#{remark},</if>
</set>
WHERE genKey = #{genKey}
</update>
<delete id="deleteByTime">
Delete From thr_corp_import_log
where date(updateTime) &lt;= date(DATE_SUB(NOW(),INTERVAL 30 day))
</delete>
</mapper>
Loading…
Cancel
Save