From 647e84b5c2a43156128d2744ac7da9fa60d15781 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=83=91=E6=98=8E=E6=A2=81?= <2429105222@qq.com> Date: Thu, 12 Jan 2023 17:47:27 +0800 Subject: [PATCH] =?UTF-8?q?=E7=AC=AC=E4=B8=89=E6=96=B9=E5=BA=93=E5=AD=98?= =?UTF-8?q?=E4=BF=A1=E6=81=AF=E4=BB=A3=E7=A0=81=E6=8F=90=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../thrsys/ThrInvProductsController.java | 201 +++++++++- .../ThrInvProductsExportLogController.java | 187 ++++++++++ .../ThrInvProductsImportLogController.java | 90 +++++ .../api/dao/thrsys/ThrInvProductsDao.java | 31 +- .../dao/thrsys/ThrInvProductsDetailDao.java | 24 ++ .../thrsys/ThrInvProductsExportLogDao.java | 20 + .../thrsys/ThrInvProductsImportLogDao.java | 22 ++ .../thrsys/ThrInvProductsExportLogEntity.java | 88 +++++ .../ThrInvProductsImportDetailEntity.java | 116 ++++++ .../thrsys/ThrInvProductsImportLogEntity.java | 77 ++++ .../java/com/glxp/api/http/ErpInvClient.java | 65 ++++ .../thrsys/FilterThrInvProductsRequest.java | 40 ++ .../req/thrsys/PostThrInvProductsRequest.java | 16 + .../thrsys/ThrInvProductsExportRequest.java | 22 ++ .../glxp/api/req/thrsys/ThrOnhandRequest.java | 33 ++ .../api/res/thrsys/ThrInvProductResponse.java | 40 ++ .../api/res/thrsys/ThrOnHandResponse.java | 16 + .../thrsys/ThrInvProductsDetailService.java | 21 ++ .../thrsys/ThrInvProductsDlService.java | 343 ++++++++++++++++++ .../ThrInvProductsExportLogService.java | 21 ++ .../ThrInvProductsImportLogService.java | 22 ++ .../service/thrsys/ThrInvProductsService.java | 29 +- .../impl/ThrInvProductsDetailServiceImpl.java | 57 +++ .../ThrInvProductsExportLogServiceImpl.java | 58 +++ .../ThrInvProductsImportLogServiceImpl.java | 59 +++ .../impl/ThrInvProductsServiceImpl.java | 62 +++- .../mapper/thrsys/ThrInvProductsDao.xml | 161 ++++++-- .../mapper/thrsys/ThrInvProductsDetailDao.xml | 92 +++++ .../thrsys/ThrInvProductsExportLogDao.xml | 53 +++ .../thrsys/ThrInvProductsImportLogDao.xml | 57 +++ 30 files changed, 2038 insertions(+), 85 deletions(-) create mode 100644 src/main/java/com/glxp/api/controller/thrsys/ThrInvProductsExportLogController.java create mode 100644 src/main/java/com/glxp/api/controller/thrsys/ThrInvProductsImportLogController.java create mode 100644 src/main/java/com/glxp/api/dao/thrsys/ThrInvProductsDetailDao.java create mode 100644 src/main/java/com/glxp/api/dao/thrsys/ThrInvProductsExportLogDao.java create mode 100644 src/main/java/com/glxp/api/dao/thrsys/ThrInvProductsImportLogDao.java create mode 100644 src/main/java/com/glxp/api/entity/thrsys/ThrInvProductsExportLogEntity.java create mode 100644 src/main/java/com/glxp/api/entity/thrsys/ThrInvProductsImportDetailEntity.java create mode 100644 src/main/java/com/glxp/api/entity/thrsys/ThrInvProductsImportLogEntity.java create mode 100644 src/main/java/com/glxp/api/http/ErpInvClient.java create mode 100644 src/main/java/com/glxp/api/req/thrsys/FilterThrInvProductsRequest.java create mode 100644 src/main/java/com/glxp/api/req/thrsys/PostThrInvProductsRequest.java create mode 100644 src/main/java/com/glxp/api/req/thrsys/ThrInvProductsExportRequest.java create mode 100644 src/main/java/com/glxp/api/req/thrsys/ThrOnhandRequest.java create mode 100644 src/main/java/com/glxp/api/res/thrsys/ThrInvProductResponse.java create mode 100644 src/main/java/com/glxp/api/res/thrsys/ThrOnHandResponse.java create mode 100644 src/main/java/com/glxp/api/service/thrsys/ThrInvProductsDetailService.java create mode 100644 src/main/java/com/glxp/api/service/thrsys/ThrInvProductsDlService.java create mode 100644 src/main/java/com/glxp/api/service/thrsys/ThrInvProductsExportLogService.java create mode 100644 src/main/java/com/glxp/api/service/thrsys/ThrInvProductsImportLogService.java create mode 100644 src/main/java/com/glxp/api/service/thrsys/impl/ThrInvProductsDetailServiceImpl.java create mode 100644 src/main/java/com/glxp/api/service/thrsys/impl/ThrInvProductsExportLogServiceImpl.java create mode 100644 src/main/java/com/glxp/api/service/thrsys/impl/ThrInvProductsImportLogServiceImpl.java create mode 100644 src/main/resources/mybatis/mapper/thrsys/ThrInvProductsDetailDao.xml create mode 100644 src/main/resources/mybatis/mapper/thrsys/ThrInvProductsExportLogDao.xml create mode 100644 src/main/resources/mybatis/mapper/thrsys/ThrInvProductsImportLogDao.xml diff --git a/src/main/java/com/glxp/api/controller/thrsys/ThrInvProductsController.java b/src/main/java/com/glxp/api/controller/thrsys/ThrInvProductsController.java index 315d199a0..5373357a9 100644 --- a/src/main/java/com/glxp/api/controller/thrsys/ThrInvProductsController.java +++ b/src/main/java/com/glxp/api/controller/thrsys/ThrInvProductsController.java @@ -1,29 +1,200 @@ package com.glxp.api.controller.thrsys; - +import com.alibaba.fastjson.JSONObject; +import com.alibaba.fastjson.TypeReference; 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.constant.Constant; +import com.glxp.api.entity.basic.BasicThirdSysEntity; import com.glxp.api.entity.thrsys.ThrInvProductsEntity; +import com.glxp.api.entity.thrsys.ThrInvProductsImportLogEntity; +import com.glxp.api.entity.thrsys.ThrSystemEntity; +import com.glxp.api.http.HttpOkClient; +import com.glxp.api.req.system.DeleteRequest; +import com.glxp.api.req.thrsys.FilterThrInvProductsRequest; +import com.glxp.api.req.thrsys.PostThrInvProductsRequest; +import com.glxp.api.req.thrsys.ThrOnhandRequest; import com.glxp.api.res.PageSimpleResponse; +import com.glxp.api.res.thrsys.ThrInvProductResponse; +import com.glxp.api.service.thrsys.ThrInvProductsDlService; +import com.glxp.api.service.thrsys.ThrInvProductsImportLogService; +import com.glxp.api.service.thrsys.ThrInvProductsService; +import com.glxp.api.service.thrsys.ThrSystemService; +import com.glxp.api.util.CustomUtil; +import com.glxp.api.util.RedisUtil; +import lombok.extern.slf4j.Slf4j; import org.springframework.validation.BindingResult; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; - -import org.springframework.web.bind.annotation.RestController; - -/** - *

- * 第三方产品信息表 前端控制器 - *

- * - * @author zml - * @since 2023-01-10 - */ +import org.springframework.web.bind.annotation.*; + +import javax.annotation.Resource; +import java.util.Date; +import java.util.List; + +@Slf4j @RestController public class ThrInvProductsController { + @Resource + RedisUtil redisUtil; + @Resource + private ThrInvProductsService thrInvProductsService; + @Resource + private ThrInvProductsDlService thrInvProductsDlService; + @Resource + private ThrInvProductsImportLogService thrInvProductsImportLogService; + @Resource + HttpOkClient httpOkClient; + @Resource + private ThrSystemService thrSystemService; -} + @GetMapping("/udiwms/thrsys/getInvProducts") + public BaseResponse getInvProducts(FilterThrInvProductsRequest filterThrInvProductsRequest, + BindingResult bindingResult) { + + if (bindingResult.hasErrors()) { + return ResultVOUtils.error(ResultEnum.PARAM_VERIFY_FALL, bindingResult.getFieldError().getDefaultMessage()); + } + List thrInvProductsEntities + = thrInvProductsService.filterThrInvProductss(filterThrInvProductsRequest); + PageInfo pageInfo; + pageInfo = new PageInfo<>(thrInvProductsEntities); + PageSimpleResponse pageSimpleResponse = new PageSimpleResponse<>(); + pageSimpleResponse.setTotal(pageInfo.getTotal()); + pageSimpleResponse.setList(thrInvProductsEntities); + return ResultVOUtils.success(pageSimpleResponse); + } + + + //第三方服务上传(包括文件导入后上传) + @PostMapping("/udiwms/thrsys/postInvProducts") + public BaseResponse postInvProducts(@RequestBody PostThrInvProductsRequest postThrInvProductsRequest, + BindingResult bindingResult) { + + if (bindingResult.hasErrors()) { + return ResultVOUtils.error(ResultEnum.PARAM_VERIFY_FALL, bindingResult.getFieldError().getDefaultMessage()); + } + + List erpOnHandResponses = postThrInvProductsRequest.getDatas(); + + String genKey = postThrInvProductsRequest.getGenKey(); + if (genKey == null) { + genKey = CustomUtil.getId(); + } + ThrInvProductsImportLogEntity thrInvProductsImportLogEntity = thrInvProductsImportLogService.selectByGenKey(genKey); + if (thrInvProductsImportLogEntity == null) { + thrInvProductsImportLogEntity = new ThrInvProductsImportLogEntity(); + thrInvProductsImportLogEntity.setGenKey(genKey); + if (postThrInvProductsRequest.getUploadType() != null) { + thrInvProductsImportLogEntity.setFromType(postThrInvProductsRequest.getUploadType()); + } else + thrInvProductsImportLogEntity.setFromType("第三方系统上传"); + thrInvProductsImportLogEntity.setStatus(BasicProcessStatus.UDIINFO_IMPORT_PROCESS); + thrInvProductsImportLogEntity.setUpdateTime(new Date()); + thrInvProductsImportLogEntity.setThirdSysFk(postThrInvProductsRequest.getThirdSys()); + thrInvProductsImportLogService.insertImportLog(thrInvProductsImportLogEntity); + } + if (erpOnHandResponses != null && erpOnHandResponses.size() > 0) { + thrInvProductsDlService.insertInvProducts(genKey, postThrInvProductsRequest.getThirdSys(), erpOnHandResponses); + return ResultVOUtils.success("库存产品信息上传成功,后台正在处理,请稍后重试!"); + } + thrInvProductsImportLogEntity.setStatus(BasicProcessStatus.UDIINFO_IMPORT_FAIL); + thrInvProductsImportLogEntity.setUpdateTime(new Date()); + thrInvProductsImportLogEntity.setRemark("上传数据为空"); + thrInvProductsImportLogService.updateImportLog(thrInvProductsImportLogEntity); + return ResultVOUtils.error(500, "上传数据为空"); + } + + @PostMapping("/udiwms/thrsys/delInvProducts") + public BaseResponse delInvProducts(@RequestBody DeleteRequest deleteRequest, BindingResult bindingResult) { + if (bindingResult.hasErrors()) { + return ResultVOUtils.error(ResultEnum.PARAM_VERIFY_FALL, bindingResult.getFieldError().getDefaultMessage()); + } + String id = deleteRequest.getId(); + boolean b = thrInvProductsService.deleteById(id); + if (b) + return ResultVOUtils.success("删除成功"); + else return ResultVOUtils.error(500, "无法删除!"); + } + + + @RequestMapping("/udiwms/thrsys/invProducts/delAll") + public BaseResponse delAll() { + thrInvProductsService.deleteAll(); + return ResultVOUtils.success("删除成功"); + } + + @RequestMapping("/udiwms/thrsys/invProducts/downloadAll") + public BaseResponse downloadAll(FilterThrInvProductsRequest filterThrInvProductsRequest) { + String data = (String) redisUtil.get(Constant.dlThrInvProducts); + if (data != null && data.equals("true")) { + return ResultVOUtils.error(500, "当前任务正在下载更新库存产品信息,请稍后重试!"); + } else { + redisUtil.set(Constant.dlThrProducts, "true", 10 * 60); + if (filterThrInvProductsRequest.getThirdSysFk() == null) { + return ResultVOUtils.error(500, "未选择第三方系统!"); + } + ThrInvProductsImportLogEntity thrInvProductsImportLogEntity = new ThrInvProductsImportLogEntity(); + String genKey = CustomUtil.getId(); + thrInvProductsImportLogEntity.setGenKey(genKey); + thrInvProductsImportLogEntity.setFromType("第三方系统获取"); + thrInvProductsImportLogEntity.setStatus(BasicProcessStatus.UDIINFO_IMPORT_PROCESS); + thrInvProductsImportLogEntity.setUpdateTime(new Date()); + thrInvProductsImportLogEntity.setThirdSysFk(filterThrInvProductsRequest.getThirdSys()); + thrInvProductsImportLogService.insertImportLog(thrInvProductsImportLogEntity); + thrInvProductsDlService.importProducrs(genKey,filterThrInvProductsRequest.getThirdSysFk(), null); + return ResultVOUtils.success("后台开始下载更新,请稍后刷新查看"); + } + } + + @PostMapping("/udiwms/thrsys/invProducts/inpisDlAll") + public BaseResponse inpisDlAll(@RequestBody ThrOnhandRequest erpOnhandRequest) { + + String data = (String) redisUtil.get(Constant.dlThrInvProducts); + if (data != null && data.equals("true")) { + return ResultVOUtils.error(500, "当前任务正在下载更新库存产品信息,请稍后重试!"); + } else { + redisUtil.set(Constant.dlThrProducts, "true", 10 * 60); + if (erpOnhandRequest.getThirdSys() == null) { + return ResultVOUtils.error(500, "未选择第三方系统!"); + } + ThrInvProductsImportLogEntity thrInvProductsImportLogEntity = new ThrInvProductsImportLogEntity(); + String genKey = CustomUtil.getId(); + thrInvProductsImportLogEntity.setGenKey(genKey); + thrInvProductsImportLogEntity.setFromType("第三方系统获取"); + thrInvProductsImportLogEntity.setStatus(BasicProcessStatus.UDIINFO_IMPORT_PROCESS); + thrInvProductsImportLogEntity.setUpdateTime(new Date()); + thrInvProductsImportLogEntity.setThirdSysFk(erpOnhandRequest.getThirdSys()); + thrInvProductsImportLogService.insertImportLog(thrInvProductsImportLogEntity); + + if (erpOnhandRequest.getThrInvProductsEntities() != null && erpOnhandRequest.getThrInvProductsEntities().size() > 0) {//选中导出 + thrInvProductsDlService.importSelcyInvProducrs(genKey,erpOnhandRequest.getThirdSys(), erpOnhandRequest.getThrInvProductsEntities()); + } else { //结果导出 + thrInvProductsDlService.importProducrs(genKey,erpOnhandRequest.getThirdSys(),erpOnhandRequest); + } + + return ResultVOUtils.success("后台开始下载更新,请稍后刷新查看"); + } + + } + + @GetMapping("/udiwms/inv/getInvProducts") + public BaseResponse getInvProducts(ThrOnhandRequest thrOnhandRequest) { + ThrSystemEntity thrSystemEntity = thrSystemService.selectByThirdId(thrOnhandRequest.getThirdSys()); + String url = thrSystemEntity.getThridUrl() + "/udiwms/erp/inv/getEnvProduct"; + + try { + String response = httpOkClient.uCloudPost(url, thrOnhandRequest, thrSystemEntity); + BaseResponse> udiDlDeviceResponse = + JSONObject.parseObject(response, new TypeReference>>() { + }); + return udiDlDeviceResponse; + } catch (Exception e) { + log.error("获取库存产品信息异常", e); + return ResultVOUtils.error(500, "连接第三方系统接口服务出错!"); + } + } +} diff --git a/src/main/java/com/glxp/api/controller/thrsys/ThrInvProductsExportLogController.java b/src/main/java/com/glxp/api/controller/thrsys/ThrInvProductsExportLogController.java new file mode 100644 index 000000000..711dd5ba1 --- /dev/null +++ b/src/main/java/com/glxp/api/controller/thrsys/ThrInvProductsExportLogController.java @@ -0,0 +1,187 @@ +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.ThrInvProductsEntity; +import com.glxp.api.entity.thrsys.ThrInvProductsExportLogEntity; +import com.glxp.api.entity.thrsys.ThrSystemDetailEntity; +import com.glxp.api.http.ErpInvClient; +import com.glxp.api.req.system.DeleteRequest; +import com.glxp.api.req.thrsys.*; +import com.glxp.api.res.PageSimpleResponse; +import com.glxp.api.res.thrsys.ThrInvProductResponse; +import com.glxp.api.service.thrsys.ThrInvProductsDlService; +import com.glxp.api.service.thrsys.ThrInvProductsExportLogService; +import com.glxp.api.service.thrsys.ThrInvProductsService; +import com.glxp.api.service.thrsys.ThrSystemDetailService; +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 ThrInvProductsExportLogController { + @Resource + ThrInvProductsExportLogService thrInvProductsExportLogService; + @Resource + ThrInvProductsDlService thrInvProductsDlService; + @Resource + ThrSystemDetailService thrSystemDetailService; + @Resource + private ThrInvProductsService thrInvProductsService; + @Resource + ErpInvClient erpInvClient; + + @GetMapping("/udiwms/invProducts/exportLog/filter") + public BaseResponse filter(FilterThrCorpExportLogRequest filterThrProductsExportLogRequest, + BindingResult bindingResult) { + + if (bindingResult.hasErrors()) { + return ResultVOUtils.error(ResultEnum.PARAM_VERIFY_FALL, bindingResult.getFieldError().getDefaultMessage()); + } + List thrInvProductsExportLogEntities = thrInvProductsExportLogService.filterThrInvProductsExportLog(filterThrProductsExportLogRequest); + PageInfo pageInfo; + pageInfo = new PageInfo<>(thrInvProductsExportLogEntities); + PageSimpleResponse pageSimpleResponse = new PageSimpleResponse<>(); + pageSimpleResponse.setTotal(pageInfo.getTotal()); + pageSimpleResponse.setList(thrInvProductsExportLogEntities); + return ResultVOUtils.success(pageSimpleResponse); + } + + @PostMapping("/udiwms/invProducts/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(); + thrInvProductsExportLogService.deleteById(id + ""); + return ResultVOUtils.success("删除成功"); + } + + //产品信息excel文件下载 + @GetMapping("/udiwms/invProducts/exportLog/download") + public void download(FilterThrCorpExportLogRequest filterThrCorpExportLogRequest, HttpServletResponse res) { + + List thrInvProductsExportLogEntities = thrInvProductsExportLogService.filterThrInvProductsExportLog(filterThrCorpExportLogRequest); + ThrInvProductsExportLogEntity thrInvProductsExportLogEntity = thrInvProductsExportLogEntities.get(0); + try { + String filePath = thrInvProductsExportLogEntity.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 (thrInvProductsExportLogEntity.getDlCount() == 0) { + thrInvProductsExportLogEntity.setDlCount(1); + } else { + thrInvProductsExportLogEntity.setDlCount(thrInvProductsExportLogEntity.getDlCount() + 1); + } + thrInvProductsExportLogService.updateThrInvProductsExportLog(thrInvProductsExportLogEntity); + } catch (Exception ex) { + System.out.println("下载失败!"); + } + + + } + + //产品信息导出生成Excel,并创建生成记录 + @PostMapping("/udiwms/invProducts/importLog/export") + public BaseResponse excelDownload(@RequestBody ThrInvProductsExportRequest thrInvProductsExportRequest) { + + String fileName = "D:\\udiwms\\exportFile\\" + "库存产品信息导出" + System.currentTimeMillis() + ".xls"; + File file = new File(fileName); + if (!file.exists()) { + try { + file.createNewFile(); + } catch (IOException e) { + e.printStackTrace(); + } + } + ThrInvProductsExportLogEntity udiInfoExportLogEntity = new ThrInvProductsExportLogEntity(); + udiInfoExportLogEntity.setStatus(BasicProcessStatus.UDIINFO_IMPORT_PROCESS); + String genKey = CustomUtil.getId(); + udiInfoExportLogEntity.setGenKey(genKey); + udiInfoExportLogEntity.setFilePath(fileName); + udiInfoExportLogEntity.setUpdateTime(new Date()); + udiInfoExportLogEntity.setDlCount(0); + thrInvProductsExportLogService.insertThrInvProductsExportLog(udiInfoExportLogEntity); + thrInvProductsDlService.genExcel(genKey, thrInvProductsExportRequest); + return ResultVOUtils.success("后台正在导出生成excel文件,请稍后刷新查看!"); + + } + + + //第三方库存产品信息接口下载(第三方使用) + @GetMapping("/udiwms/thirdSys/invProducts/download") + public BaseResponse getOnhand(ThrOnhandRequest onhandQueryRequest, + BindingResult bindingResult) { + + if (bindingResult.hasErrors()) { + return ResultVOUtils.error(ResultEnum.PARAM_VERIFY_FALL, bindingResult.getFieldError().getDefaultMessage()); + } + ThrSystemDetailEntity thrSystemDetailEntity = thrSystemDetailService.selectByKey("invPiUrl", onhandQueryRequest.getThirdSys()); + String onHandUrl; + if (thrSystemDetailEntity == null || thrSystemDetailEntity.getValue() == null) + return ResultVOUtils.error(500, "ERP库存产品信息接口地址未定义"); + else + onHandUrl = thrSystemDetailEntity.getValue(); + if (!thrSystemDetailEntity.getEnabled()) { + return ResultVOUtils.error(500, "第三方系统库存信息接口服务未启用!"); + } + if (thrSystemDetailEntity.getFromType() == 0) { + + BaseResponse> responseBaseResponse = erpInvClient.getInvPrdoductResponse(onhandQueryRequest, onHandUrl); + return responseBaseResponse; + } else { + FilterThrInvProductsRequest filterThrInvProductsRequest = new FilterThrInvProductsRequest(); + BeanUtils.copyProperties(onhandQueryRequest, filterThrInvProductsRequest); + filterThrInvProductsRequest.setThirdSysFk(onhandQueryRequest.getThirdSys()); + List thrInvProductsEntities + = thrInvProductsService.filterThrInvProductss(filterThrInvProductsRequest); + List erpInvProductResponseList = thrInvProductsEntities.stream().map(item -> + { + ThrInvProductResponse erpInvProductResponse = new ThrInvProductResponse(); + BeanUtils.copyProperties(item, erpInvProductResponse); + erpInvProductResponse.setCode(item.getInventoryCode()); + erpInvProductResponse.setName(item.getInventoryName()); + return erpInvProductResponse; + }).collect(Collectors.toList()); + PageInfo pageInfo; + pageInfo = new PageInfo<>(erpInvProductResponseList); + PageSimpleResponse pageSimpleResponse = new PageSimpleResponse<>(); + pageSimpleResponse.setTotal(pageInfo.getTotal()); + pageSimpleResponse.setList(erpInvProductResponseList); + return ResultVOUtils.success(pageSimpleResponse); + } + + } + +} diff --git a/src/main/java/com/glxp/api/controller/thrsys/ThrInvProductsImportLogController.java b/src/main/java/com/glxp/api/controller/thrsys/ThrInvProductsImportLogController.java new file mode 100644 index 000000000..83159b3c5 --- /dev/null +++ b/src/main/java/com/glxp/api/controller/thrsys/ThrInvProductsImportLogController.java @@ -0,0 +1,90 @@ +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.ThrInvProductsImportDetailEntity; +import com.glxp.api.entity.thrsys.ThrInvProductsImportLogEntity; +import com.glxp.api.req.system.DeleteRequest; +import com.glxp.api.req.thrsys.FilterThrCorpExportLogRequest; +import com.glxp.api.req.thrsys.FilterThrCorpImportLogRequest; +import com.glxp.api.req.thrsys.FilterThrCorpRequest; +import com.glxp.api.res.PageSimpleResponse; +import com.glxp.api.service.thrsys.ThrInvProductsDetailService; +import com.glxp.api.service.thrsys.ThrInvProductsImportLogService; +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 ThrInvProductsImportLogController { + + + @Resource + ThrInvProductsImportLogService thrInvProductsImportLogService; + @Resource + ThrInvProductsDetailService thrInvProductsDetailService; + + @GetMapping("/udiwms/thrInvProducts/importLog/filter") + public BaseResponse filter(FilterThrCorpImportLogRequest filterThrCorpImportLogRequest, + BindingResult bindingResult) { + + if (bindingResult.hasErrors()) { + return ResultVOUtils.error(ResultEnum.PARAM_VERIFY_FALL, bindingResult.getFieldError().getDefaultMessage()); + } + List thrInvProductsImportLogEntities + = thrInvProductsImportLogService.filterThrInvProductsImportLog(filterThrCorpImportLogRequest); + PageInfo pageInfo; + pageInfo = new PageInfo<>(thrInvProductsImportLogEntities); + PageSimpleResponse pageSimpleResponse = new PageSimpleResponse<>(); + pageSimpleResponse.setTotal(pageInfo.getTotal()); + pageSimpleResponse.setList(thrInvProductsImportLogEntities); + return ResultVOUtils.success(pageSimpleResponse); + } + + @GetMapping("/udiwms/thrInvProducts/importLog/filterDetail") + public BaseResponse filterDetail(FilterThrCorpImportLogRequest filterThrCorpImportLogRequest, + BindingResult bindingResult) { + + if (bindingResult.hasErrors()) { + return ResultVOUtils.error(ResultEnum.PARAM_VERIFY_FALL, bindingResult.getFieldError().getDefaultMessage()); + } + List thrInvProductsImportDetailEntities + = thrInvProductsDetailService.filterInvProductsDetailImport(filterThrCorpImportLogRequest); + PageInfo pageInfo; + pageInfo = new PageInfo<>(thrInvProductsImportDetailEntities); + PageSimpleResponse pageSimpleResponse = new PageSimpleResponse<>(); + pageSimpleResponse.setTotal(pageInfo.getTotal()); + pageSimpleResponse.setList(thrInvProductsImportDetailEntities); + return ResultVOUtils.success(pageSimpleResponse); + } + + @PostMapping("/udiwms/thrInvProducts/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 thrInvProductsImportLogEntities = thrInvProductsImportLogService.filterThrInvProductsImportLog(filterInCodeLogRequest); + if (thrInvProductsImportLogEntities != null && thrInvProductsImportLogEntities.size() > 0) { + ThrInvProductsImportLogEntity thrInvProductsImportLogEntity = thrInvProductsImportLogEntities.get(0); + thrInvProductsImportLogService.deleteById(thrInvProductsImportLogEntity.getId() + ""); + thrInvProductsDetailService.deleteByGenkey(thrInvProductsImportLogEntity.getGenKey()); + return ResultVOUtils.success("删除成功"); + }else { + return ResultVOUtils.error(500, "删除失败,未找到该记录"); + } + + + } + +} diff --git a/src/main/java/com/glxp/api/dao/thrsys/ThrInvProductsDao.java b/src/main/java/com/glxp/api/dao/thrsys/ThrInvProductsDao.java index 7f0da250e..16acd5038 100644 --- a/src/main/java/com/glxp/api/dao/thrsys/ThrInvProductsDao.java +++ b/src/main/java/com/glxp/api/dao/thrsys/ThrInvProductsDao.java @@ -1,17 +1,28 @@ package com.glxp.api.dao.thrsys; -import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.glxp.api.entity.thrsys.ThrInvProductsEntity; +import com.glxp.api.req.thrsys.FilterThrInvProductsRequest; +import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; -/** - *

- * 第三方产品信息表 Mapper 接口 - *

- * - * @author zml - * @since 2023-01-10 - */ -public interface ThrInvProductsDao extends BaseMapper { +import java.util.List; + +@Mapper +public interface ThrInvProductsDao { + + List filterThrInvProductss(FilterThrInvProductsRequest filterThrInvProductsRequest); + + ThrInvProductsEntity selectById(@Param("id") String id); + + boolean insertThrInvProduct(ThrInvProductsEntity thrInvProductsEntity); + + boolean insertThrInvProducts(@Param("thrInvProductsEntities") List thrInvProductsEntities); + + boolean updateThrInvProducts(ThrInvProductsEntity thrInvProductsEntity); + + boolean deleteById(@Param("id") String id); + + boolean deleteAll(); } diff --git a/src/main/java/com/glxp/api/dao/thrsys/ThrInvProductsDetailDao.java b/src/main/java/com/glxp/api/dao/thrsys/ThrInvProductsDetailDao.java new file mode 100644 index 000000000..ab951190d --- /dev/null +++ b/src/main/java/com/glxp/api/dao/thrsys/ThrInvProductsDetailDao.java @@ -0,0 +1,24 @@ +package com.glxp.api.dao.thrsys; + + +import com.glxp.api.entity.thrsys.ThrInvProductsImportDetailEntity; +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 ThrInvProductsDetailDao { + List filterInvProductsDetailImport(FilterThrCorpImportLogRequest filterThrCorpImportLogRequest); + + boolean insertInvProductsDetailImport(ThrInvProductsImportDetailEntity thrInvProductsImportDetailEntity); + + boolean updateInvProductsDetailImport(ThrInvProductsImportDetailEntity thrInvProductsImportDetailEntity); + + boolean insertInvProductsDetailImports(@Param("invProducts") List thrInvProductsImportDetailEntities); + + boolean deleteById(@Param("id") String id); + + boolean deleteByGenkey(@Param("genKey") String genKey); +} diff --git a/src/main/java/com/glxp/api/dao/thrsys/ThrInvProductsExportLogDao.java b/src/main/java/com/glxp/api/dao/thrsys/ThrInvProductsExportLogDao.java new file mode 100644 index 000000000..e74422969 --- /dev/null +++ b/src/main/java/com/glxp/api/dao/thrsys/ThrInvProductsExportLogDao.java @@ -0,0 +1,20 @@ +package com.glxp.api.dao.thrsys; + + +import com.glxp.api.entity.thrsys.ThrInvProductsExportLogEntity; +import com.glxp.api.req.thrsys.FilterThrCorpExportLogRequest; +import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; + +import java.util.List; + +@Mapper +public interface ThrInvProductsExportLogDao { + List filterThrInvProductsExportLog(FilterThrCorpExportLogRequest filterThrCorpExportLogRequest); + + boolean insertThrInvProductsExportLog(ThrInvProductsExportLogEntity thrInvProductsExportLogEntity); + + boolean updateThrInvProductsExportLog(ThrInvProductsExportLogEntity thrInvProductsExportLogEntity); + + boolean deleteById(@Param("id") String id); +} diff --git a/src/main/java/com/glxp/api/dao/thrsys/ThrInvProductsImportLogDao.java b/src/main/java/com/glxp/api/dao/thrsys/ThrInvProductsImportLogDao.java new file mode 100644 index 000000000..4b29dbb9c --- /dev/null +++ b/src/main/java/com/glxp/api/dao/thrsys/ThrInvProductsImportLogDao.java @@ -0,0 +1,22 @@ +package com.glxp.api.dao.thrsys; + + +import com.glxp.api.entity.thrsys.ThrInvProductsImportLogEntity; +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 ThrInvProductsImportLogDao { + + List filterThrInvProductsImportLog(FilterThrCorpImportLogRequest filterThrCorpImportLogRequest); + + boolean insertImportLog(ThrInvProductsImportLogEntity thrInvProductsImportLogEntity); + + boolean updateImportLog(ThrInvProductsImportLogEntity thrInvProductsImportLogEntity); + + boolean deleteById(@Param("id") String id); + +} diff --git a/src/main/java/com/glxp/api/entity/thrsys/ThrInvProductsExportLogEntity.java b/src/main/java/com/glxp/api/entity/thrsys/ThrInvProductsExportLogEntity.java new file mode 100644 index 000000000..c0a5d5b91 --- /dev/null +++ b/src/main/java/com/glxp/api/entity/thrsys/ThrInvProductsExportLogEntity.java @@ -0,0 +1,88 @@ +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 com.baomidou.mybatisplus.annotation.TableName; +import lombok.Data; + +import java.io.Serializable; +import java.time.LocalDateTime; +import java.util.Date; + +/** + *

+ * 第三方产品信息日志表 + *

+ * + * @author 作者 + * @since 2023-01-12 + */ +@Data +@TableName("thr_inv_products_export_log") +public class ThrInvProductsExportLogEntity { + + private static final long serialVersionUID = 1L; + + @TableId(value = "id", type = IdType.AUTO) + private Integer id; + + /** + * 生成日志记录 + */ + @TableField("genKey") + private String genKey; + + /** + * 生成状态0:失败;1:成功 + */ + @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; + + +} diff --git a/src/main/java/com/glxp/api/entity/thrsys/ThrInvProductsImportDetailEntity.java b/src/main/java/com/glxp/api/entity/thrsys/ThrInvProductsImportDetailEntity.java new file mode 100644 index 000000000..0bc175651 --- /dev/null +++ b/src/main/java/com/glxp/api/entity/thrsys/ThrInvProductsImportDetailEntity.java @@ -0,0 +1,116 @@ +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 com.baomidou.mybatisplus.annotation.TableName; +import lombok.Data; + +import java.io.Serializable; +import java.time.LocalDateTime; +import java.util.Date; + +/** + *

+ * 第三方产品信息导入表 + *

+ * + * @author 作者 + * @since 2023-01-12 + */ +@Data +@TableName("thr_inv_products_import_detail") +public class ThrInvProductsImportDetailEntity implements Serializable { + + private static final long serialVersionUID = 1L; + + @TableId(value = "id", type = IdType.AUTO) + private Integer id; + + @TableField("inventoryCode") + private String inventoryCode; + + @TableField("inventoryName") + private String inventoryName; + + @TableField("spec") + private String spec; + + @TableField("count") + private String count; + + @TableField("batchNo") + private String batchNo; + + /** + * 仓位号 + */ + @TableField("warehouseName") + private String warehouseName; + + /** + * 仓位名称 + */ + @TableField("warehouseCode") + private String warehouseCode; + + @TableField("registerCertNo") + private String registerCertNo; + + /** + * 仓库号 + */ + @TableField("spaceCode") + private String spaceCode; + + /** + * 仓库名称 + */ + @TableField("spaceName") + private String spaceName; + + @TableField("manufacturingDate") + private String manufacturingDate; + + @TableField("expirationDate") + private String expirationDate; + + @TableField("thirdSysFk") + private String thirdSysFk; + + @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; + + + +} diff --git a/src/main/java/com/glxp/api/entity/thrsys/ThrInvProductsImportLogEntity.java b/src/main/java/com/glxp/api/entity/thrsys/ThrInvProductsImportLogEntity.java new file mode 100644 index 000000000..97685fb5c --- /dev/null +++ b/src/main/java/com/glxp/api/entity/thrsys/ThrInvProductsImportLogEntity.java @@ -0,0 +1,77 @@ +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 com.baomidou.mybatisplus.annotation.TableName; +import lombok.Data; + +import java.io.Serializable; +import java.time.LocalDateTime; +import java.util.Date; + +/** + *

+ * + *

+ * + * @author 作者 + * @since 2023-01-12 + */ +@Data +@TableName("thr_inv_products_import_log") +public class ThrInvProductsImportLogEntity implements Serializable { + + 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; + + + +} diff --git a/src/main/java/com/glxp/api/http/ErpInvClient.java b/src/main/java/com/glxp/api/http/ErpInvClient.java new file mode 100644 index 000000000..8510b2b86 --- /dev/null +++ b/src/main/java/com/glxp/api/http/ErpInvClient.java @@ -0,0 +1,65 @@ +package com.glxp.api.http; + +import com.alibaba.fastjson.JSONObject; +import com.alibaba.fastjson.TypeReference; +import com.glxp.api.common.res.BaseResponse; +import com.glxp.api.req.thrsys.ThrOnhandRequest; +import com.glxp.api.res.PageSimpleResponse; +import com.glxp.api.res.thrsys.ThrInvProductResponse; +import org.springframework.stereotype.Service; + +import javax.annotation.Resource; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +@Service +public class ErpInvClient { + + @Resource + HttpOkClient httpOkClient; + + + public BaseResponse> getInvPrdoductResponse(ThrOnhandRequest onhandRequest, String url) { + + Map paramMap = new HashMap<>(16); + if (onhandRequest.getBatchNo() != null && !onhandRequest.getBatchNo().equals("")) + paramMap.put("batchNo", onhandRequest.getBatchNo()); + if (onhandRequest.getWarehouseCode() != null && !onhandRequest.getWarehouseCode().equals("")) + paramMap.put("warehouseCode", onhandRequest.getWarehouseCode()); + if (onhandRequest.getInventoryCode() != null && !onhandRequest.getInventoryCode().equals("")) + paramMap.put("inventoryCode", onhandRequest.getInventoryCode()); + if (onhandRequest.getInventoryName() != null && !onhandRequest.getInventoryName().equals("")) + paramMap.put("inventoryName", onhandRequest.getInventoryName()); + if (onhandRequest.getSpec() != null && !onhandRequest.getSpec().equals("")) + paramMap.put("spec", onhandRequest.getSpec()); + if (onhandRequest.getRegisterCertNo() != null && !onhandRequest.getRegisterCertNo().equals("")) + paramMap.put("registerCertNo", onhandRequest.getRegisterCertNo()); + if (onhandRequest.getManufactory() != null && !onhandRequest.getManufactory().equals("")) + paramMap.put("manufactory", onhandRequest.getManufactory()); + + if (onhandRequest.getFilterCount() != null && !onhandRequest.getFilterCount().equals("")) + paramMap.put("filterCount", onhandRequest.getFilterCount()); + if (onhandRequest.getPage() != null) + paramMap.put("page", onhandRequest.getPage()); + if (onhandRequest.getLimit() != null) + paramMap.put("limit", onhandRequest.getLimit()); +// String response = HttpClient.mipsGet(url, paramMap); + String response = httpOkClient.uCloudPost(url, onhandRequest); + try { + BaseResponse> onHandsResponse = + JSONObject.parseObject(response, new TypeReference>>() { + }); + return onHandsResponse; + } catch (Exception e) { + e.printStackTrace(); + } + return null; + } + + public List getInvPrdoduct(ThrOnhandRequest onhandRequest, String url) { + BaseResponse> responseBaseResponse = getInvPrdoductResponse(onhandRequest, url); + List responseList = responseBaseResponse.getData().getList(); + return responseList; + } +} diff --git a/src/main/java/com/glxp/api/req/thrsys/FilterThrInvProductsRequest.java b/src/main/java/com/glxp/api/req/thrsys/FilterThrInvProductsRequest.java new file mode 100644 index 000000000..3a8b793ca --- /dev/null +++ b/src/main/java/com/glxp/api/req/thrsys/FilterThrInvProductsRequest.java @@ -0,0 +1,40 @@ +package com.glxp.api.req.thrsys; + + +import com.glxp.api.req.ListPageRequest; +import com.glxp.api.res.thrsys.ThrInvProductResponse; +import lombok.Data; + +import java.util.List; + +@Data +public class FilterThrInvProductsRequest extends ListPageRequest { + + private String inventoryCode; + private String inventoryName; + private String thirdSysFk; + private String batchNo; + private String warehouseCode; + private List inventoryCodes; + private String udiCode; + private String nameCode; + private String thirdSys; + List thrInvProductResponseList; + + + + private String spec; + private String registerCertNo; + private String manufactory; + private Integer filterCount;//0:不过滤,1,过滤等于0,2.过滤大于0 + + //增加字段 + private String productDate; //生产日期 + private String expireDate; //失效日期 + private String productName; //产品名称 + private String productId; //产品ID + private String standard; //规格型号 + private String registerNo; //注册、备案证号 + private String supId; //配送企业ID + private String supName; //配送企业名称 +} diff --git a/src/main/java/com/glxp/api/req/thrsys/PostThrInvProductsRequest.java b/src/main/java/com/glxp/api/req/thrsys/PostThrInvProductsRequest.java new file mode 100644 index 000000000..17ef5526b --- /dev/null +++ b/src/main/java/com/glxp/api/req/thrsys/PostThrInvProductsRequest.java @@ -0,0 +1,16 @@ +package com.glxp.api.req.thrsys; + + +import com.glxp.api.res.thrsys.ThrInvProductResponse; +import lombok.Data; + +import java.util.List; + +@Data +public class PostThrInvProductsRequest { + + private String genKey; + private String thirdSys; + private String uploadType; + private List datas; +} diff --git a/src/main/java/com/glxp/api/req/thrsys/ThrInvProductsExportRequest.java b/src/main/java/com/glxp/api/req/thrsys/ThrInvProductsExportRequest.java new file mode 100644 index 000000000..5e2b56bf5 --- /dev/null +++ b/src/main/java/com/glxp/api/req/thrsys/ThrInvProductsExportRequest.java @@ -0,0 +1,22 @@ +package com.glxp.api.req.thrsys; + + +import com.glxp.api.entity.thrsys.ThrInvProductsEntity; +import lombok.Data; + +import java.util.List; + +@Data +public class ThrInvProductsExportRequest { + private List thrInvProductsEntities; + + private String inventoryCode; + private String inventoryName; + private String thirdSysFk; + private String batchNo; + private String warehouseCode; + private List inventoryCodes; + private String udiCode; + private String nameCode; + private String thirdSys; +} diff --git a/src/main/java/com/glxp/api/req/thrsys/ThrOnhandRequest.java b/src/main/java/com/glxp/api/req/thrsys/ThrOnhandRequest.java new file mode 100644 index 000000000..d427ddeb6 --- /dev/null +++ b/src/main/java/com/glxp/api/req/thrsys/ThrOnhandRequest.java @@ -0,0 +1,33 @@ +package com.glxp.api.req.thrsys; + + +import com.glxp.api.req.ListPageRequest; +import com.glxp.api.res.thrsys.ThrInvProductResponse; +import lombok.Data; + +import java.util.List; + +@Data +public class ThrOnhandRequest extends ListPageRequest { + + private String batchNo; + private String warehouseCode; + private String inventoryName; + private String inventoryCode; + private List inventoryCodes; + private String udiCode; + private String nameCode; + private String thirdSys; + + + private Boolean isDownThrSys; + + List thrInvProductsEntities; + + + + private String spec; + private String registerCertNo; + private String manufactory; + private Integer filterCount;//0:不过滤,1,过滤等于0,2.过滤大于0 +} diff --git a/src/main/java/com/glxp/api/res/thrsys/ThrInvProductResponse.java b/src/main/java/com/glxp/api/res/thrsys/ThrInvProductResponse.java new file mode 100644 index 000000000..8c940a10f --- /dev/null +++ b/src/main/java/com/glxp/api/res/thrsys/ThrInvProductResponse.java @@ -0,0 +1,40 @@ +package com.glxp.api.res.thrsys; + +import lombok.Data; + +import java.util.Date; + +@Data +public class ThrInvProductResponse { + + private String code; + private String name; + private String batchNo; + private String manufacturingDate; + private String expirationDate; + private String warehouseCode; + private String warehouseName; + private String registerCertNo; + private String spaceCode; + private String spaceName; + private String thirdSysFk; + private String spec; + private Integer count; + private String manufactory; + + //增加字段 + private String productDate; //生产日期 + private String expireDate; //失效日期 + private String productName; //产品名称 + private String productId; //产品ID + private String standard; //规格型号 + private String registerNo; //注册、备案证号 + private String supId; //配送企业ID + private String supName; //配送企业名称 + + private String createUser; + private Date createTime; + private String updateUser; + private Date updateTime; + private String remark; +} diff --git a/src/main/java/com/glxp/api/res/thrsys/ThrOnHandResponse.java b/src/main/java/com/glxp/api/res/thrsys/ThrOnHandResponse.java new file mode 100644 index 000000000..265774c54 --- /dev/null +++ b/src/main/java/com/glxp/api/res/thrsys/ThrOnHandResponse.java @@ -0,0 +1,16 @@ +package com.glxp.api.res.thrsys; + +import lombok.Data; + +@Data +public class ThrOnHandResponse { + + private String inventoryCode; + private String inventoryName; + private String spec; + private int count; + private String batchNo; + private String warehouseName; + private String warehouseCode; + private String registerCertNo; +} diff --git a/src/main/java/com/glxp/api/service/thrsys/ThrInvProductsDetailService.java b/src/main/java/com/glxp/api/service/thrsys/ThrInvProductsDetailService.java new file mode 100644 index 000000000..3dcd35541 --- /dev/null +++ b/src/main/java/com/glxp/api/service/thrsys/ThrInvProductsDetailService.java @@ -0,0 +1,21 @@ +package com.glxp.api.service.thrsys; + + +import com.glxp.api.entity.thrsys.ThrInvProductsImportDetailEntity; +import com.glxp.api.req.thrsys.FilterThrCorpImportLogRequest; + +import java.util.List; + +public interface ThrInvProductsDetailService { + List filterInvProductsDetailImport(FilterThrCorpImportLogRequest filterThrCorpImportLogRequest); + + boolean insertInvProductsDetailImport(ThrInvProductsImportDetailEntity thrInvProductsImportDetailEntity); + + boolean updateInvProductsDetailImport(ThrInvProductsImportDetailEntity thrInvProductsImportDetailEntity); + + boolean insertInvProductsDetailImports(List thrInvProductsImportDetailEntities); + + boolean deleteById(String id); + + boolean deleteByGenkey(String genKey); +} diff --git a/src/main/java/com/glxp/api/service/thrsys/ThrInvProductsDlService.java b/src/main/java/com/glxp/api/service/thrsys/ThrInvProductsDlService.java new file mode 100644 index 000000000..7873c87d7 --- /dev/null +++ b/src/main/java/com/glxp/api/service/thrsys/ThrInvProductsDlService.java @@ -0,0 +1,343 @@ +package com.glxp.api.service.thrsys; + + +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.basic.BasicThirdSysDetailEntity; +import com.glxp.api.entity.thrsys.*; +import com.glxp.api.http.ErpInvClient; +import com.glxp.api.req.thrsys.*; +import com.glxp.api.res.PageSimpleResponse; +import com.glxp.api.res.thrsys.ThrInvProductResponse; +import com.glxp.api.util.ExcelUtil; +import com.glxp.api.util.RedisUtil; +import org.springframework.beans.BeanUtils; +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 ThrInvProductsDlService { + + @Resource + ThrInvProductsService thrInvProductsService; + @Resource + ThrSystemDetailService thrSystemDetailService; + @Resource + RedisUtil redisUtil; + @Resource + ThrInvProductsImportLogService thrInvProductsImportLogService; + @Resource + ThrInvProductsExportLogService thrInvProductsExportLogService; + @Resource + ThrInvProductsDetailService thrInvProductsDetailService; + @Resource + ErpInvClient erpInvClient; + + @Async + public void importSelcyInvProducrs(String genKey, String thirdSys, List ThrInvProductResponses) { + ThrInvProductsImportLogEntity thrInvProductsImportLogEntity = thrInvProductsImportLogService.selectByGenKey(genKey); + ThrSystemDetailEntity piDetailEntity = thrSystemDetailService.selectByKey("invPiUrl", thirdSys); + if (piDetailEntity == null || piDetailEntity.getValue() == null) { + WebSocketServer.sendInfo("库存产品信息接口未设置!", "sid"); + return; + } + + + if (ThrInvProductResponses != null && ThrInvProductResponses.size() > 0) { + List thrProductsEntities = ThrInvProductResponses.stream().map( + item -> { + ThrInvProductsImportDetailEntity thrProductsEntity = new ThrInvProductsImportDetailEntity(); + BeanUtils.copyProperties(item, thrProductsEntity); + thrProductsEntity.setInventoryCode(item.getCode()); + thrProductsEntity.setInventoryName(item.getName()); + thrProductsEntity.setGenKeyFk(genKey); + thrProductsEntity.setThirdSysFk(thirdSys); + thrProductsEntity.setUpdateTime(new Date()); + return thrProductsEntity; + } + ).collect(Collectors.toList()); + thrInvProductsDetailService.insertInvProductsDetailImports(thrProductsEntities); + } + + FilterThrCorpImportLogRequest filterUdiIpLogRequest = new FilterThrCorpImportLogRequest(); + filterUdiIpLogRequest.setGenKey(genKey); + List thrInvProductsImportDetailEntities = thrInvProductsDetailService.filterInvProductsDetailImport(filterUdiIpLogRequest); + List thrInvProductsEntities = thrInvProductsImportDetailEntities.stream().map( + item -> { + ThrInvProductsEntity thrInvProductsEntity = new ThrInvProductsEntity(); + BeanUtils.copyProperties(item, thrInvProductsEntity); + thrInvProductsEntity.setUpdateTime(new Date()); + return thrInvProductsEntity; + } + ).collect(Collectors.toList()); + thrInvProductsService.insertThrInvProducts(thrInvProductsEntities); + redisUtil.set(Constant.dlThrProducts, "false"); + WebSocketServer.sendInfo("库存产品信息下载已完成,请刷新查看!", "sid"); + thrInvProductsImportLogEntity.setStatus(BasicProcessStatus.UDIINFO_IMPORT_SUCCESS); + thrInvProductsImportLogService.updateImportLog(thrInvProductsImportLogEntity); + + } + + + @Async + public void importProducrs(String genKey, String thirdSys, ThrOnhandRequest thrOnhandRequest) { + ThrSystemDetailEntity thrSystemDetailEntity = thrSystemDetailService.selectByKey("invPiUrl", thirdSys); + if (thrSystemDetailEntity == null || thrSystemDetailEntity.getValue() == null) { + WebSocketServer.sendInfo("库存产品信息接口未设置!", "sid"); + return; + } + ThrInvProductsImportLogEntity thrInvProductsImportLogEntity = thrInvProductsImportLogService.selectByGenKey(genKey); + int page = 1; + int limit = 100; + while (page != -1) { + page = getInvmandoc(page, limit, thrSystemDetailEntity.getValue(), thrInvProductsImportLogEntity, genKey, thirdSys, thrOnhandRequest); + } + FilterThrCorpImportLogRequest filterUdiIpLogRequest = new FilterThrCorpImportLogRequest(); + filterUdiIpLogRequest.setGenKey(genKey); + List thrInvProductsImportDetailEntities = thrInvProductsDetailService.filterInvProductsDetailImport(filterUdiIpLogRequest); + List thrInvProductsEntities = thrInvProductsImportDetailEntities.stream().map( + item -> { + ThrInvProductsEntity thrInvProductsEntity = new ThrInvProductsEntity(); + BeanUtils.copyProperties(item, thrInvProductsEntity); + thrInvProductsEntity.setUpdateTime(new Date()); + return thrInvProductsEntity; + } + ).collect(Collectors.toList()); + thrInvProductsService.insertThrInvProducts(thrInvProductsEntities); + redisUtil.set(Constant.dlThrProducts, "false"); + WebSocketServer.sendInfo("库存产品信息下载已完成,请刷新查看!", "sid"); + } + + @Async + public void genExcel(String genKey, ThrInvProductsExportRequest thrInvProductsExportRequest) { + + ThrInvProductsExportLogEntity thrInvProductsExportLogEntity = thrInvProductsExportLogService.selectByGenKey(genKey); + List> excelData = new ArrayList<>(); + List head = new ArrayList<>(); + head.add("存货编码"); + head.add("存货名称"); + head.add("规格型号"); + head.add("数量"); + head.add("批次号"); + head.add("生产日期"); + head.add("失效日期"); + head.add("仓位号"); + head.add("仓位名称"); + head.add("货位号"); + head.add("货位名称"); + excelData.add(head); + //选中导出 + if (thrInvProductsExportRequest.getThrInvProductsEntities() != null && thrInvProductsExportRequest.getThrInvProductsEntities().size() > 0) { + List thrInvProductsEntities = thrInvProductsExportRequest.getThrInvProductsEntities(); + + for (ThrInvProductsEntity thrInvProductsEntity : thrInvProductsEntities) { + thrInvProductsEntity.setInventoryCode(thrInvProductsEntity.getInventoryCode()); + thrInvProductsEntity.setInventoryName(thrInvProductsEntity.getInventoryName()); + } + excelData.addAll(getRows(thrInvProductsEntities)); + } else {//一键导出 + //判断是否启用实时获取 + ThrSystemDetailEntity thrSystemDetailEntity = thrSystemDetailService.selectByKey("invPiUrl", thrInvProductsExportRequest.getThirdSys()); + if (thrSystemDetailEntity == null || thrSystemDetailEntity.getValue() == null) { + thrInvProductsExportLogEntity.setStatus(BasicProcessStatus.UDIINFO_IMPORT_FAIL); + thrInvProductsExportLogEntity.setRemark("库存产品信息接口地址未定义"); + thrInvProductsExportLogService.updateThrInvProductsExportLog(thrInvProductsExportLogEntity); + return; + } + if (!thrSystemDetailEntity.getEnabled()) { + thrInvProductsExportLogEntity.setStatus(BasicProcessStatus.UDIINFO_IMPORT_FAIL); + thrInvProductsExportLogEntity.setRemark("第三方库存产品信息接口服务未启用"); + thrInvProductsExportLogService.updateThrInvProductsExportLog(thrInvProductsExportLogEntity); + return; + } + if (thrSystemDetailEntity.getFromType() == 0) { + //从第三方服务实时一键导出 + FilterThrInvProductsRequest filterThrInvProductsRequest = new FilterThrInvProductsRequest(); + BeanUtils.copyProperties(thrInvProductsExportRequest, filterThrInvProductsRequest); + List thrInvProductsEntities = exportInvProducts(filterThrInvProductsRequest); + excelData.addAll(getRows(thrInvProductsEntities)); + } else { + //从本地导出 + FilterThrInvProductsRequest filterThrInvProductsRequest = new FilterThrInvProductsRequest(); + BeanUtils.copyProperties(thrInvProductsExportRequest, filterThrInvProductsRequest); + List> genDatas = genExcelData(null, filterThrInvProductsRequest); + if (genDatas != null && genDatas.size() > 0) { + excelData.addAll(genDatas); + } + } + } + String sheetName = "库存产品信息"; + new ExcelUtil().exportExcel(excelData, sheetName, thrInvProductsExportLogEntity.getFilePath(), 20); + thrInvProductsExportLogEntity.setStatus(BasicProcessStatus.UDIINFO_IMPORT_SUCCESS); + thrInvProductsExportLogService.updateThrInvProductsExportLog(thrInvProductsExportLogEntity); + } + + @Async + public void insertInvProducts(String genKey, String thirdSys, List erpOnHandResponses) { + + ThrInvProductsImportLogEntity thrInvProductsImportLogEntity = thrInvProductsImportLogService.selectByGenKey(genKey); + + List thrInvProductsImportDetailEntities; + thrInvProductsImportDetailEntities = erpOnHandResponses.stream().map( + item -> { + ThrInvProductsImportDetailEntity thrInvProductsImportDetailEntity = new ThrInvProductsImportDetailEntity(); + BeanUtils.copyProperties(item, thrInvProductsImportDetailEntity); + thrInvProductsImportDetailEntity.setInventoryCode(item.getCode()); + thrInvProductsImportDetailEntity.setInventoryName(item.getName()); + thrInvProductsImportDetailEntity.setThirdSysFk(thirdSys); + thrInvProductsImportDetailEntity.setGenKeyFk(genKey); + thrInvProductsImportDetailEntity.setUpdateTime(new Date()); + return thrInvProductsImportDetailEntity; + } + ).collect(Collectors.toList()); + thrInvProductsDetailService.insertInvProductsDetailImports(thrInvProductsImportDetailEntities); + + List thrInvProductsEntities; + thrInvProductsEntities = thrInvProductsImportDetailEntities.stream().map( + item -> { + ThrInvProductsEntity thrInvProductsEntity = new ThrInvProductsEntity(); + BeanUtils.copyProperties(item, thrInvProductsEntity); + thrInvProductsEntity.setUpdateTime(new Date()); + return thrInvProductsEntity; + } + ).collect(Collectors.toList()); + thrInvProductsService.insertThrInvProducts(thrInvProductsEntities); + + thrInvProductsImportLogEntity.setStatus(BasicProcessStatus.UDIINFO_IMPORT_SUCCESS); + thrInvProductsImportLogEntity.setUpdateTime(new Date()); + thrInvProductsImportLogService.updateImportLog(thrInvProductsImportLogEntity); + } + + + public int getInvmandoc(int page, int limit, String productUrl, ThrInvProductsImportLogEntity thrInvProductsImportLogEntity, + String genKey, String thirdSys, ThrOnhandRequest ThrOnhandRequest) { + if (ThrOnhandRequest == null) + ThrOnhandRequest = new ThrOnhandRequest(); + ThrOnhandRequest.setPage(page); + ThrOnhandRequest.setLimit(limit); + + BaseResponse> responseBaseResponse = erpInvClient.getInvPrdoductResponse(ThrOnhandRequest, productUrl); + + if (responseBaseResponse.getCode() != 20000) { + thrInvProductsImportLogEntity.setStatus(BasicProcessStatus.UDIINFO_IMPORT_FAIL); + thrInvProductsImportLogEntity.setRemark(responseBaseResponse.getMessage()); + thrInvProductsImportLogService.updateImportLog(thrInvProductsImportLogEntity); + return -1; + } + + List ThrInvProductResponses = responseBaseResponse.getData().getList(); + if (ThrInvProductResponses != null && ThrInvProductResponses.size() > 0) { + List thrProductsEntities = ThrInvProductResponses.stream().map( + item -> { + ThrInvProductsImportDetailEntity thrProductsEntity = new ThrInvProductsImportDetailEntity(); + BeanUtils.copyProperties(item, thrProductsEntity); + thrProductsEntity.setInventoryCode(item.getCode()); + thrProductsEntity.setInventoryName(item.getName()); + thrProductsEntity.setGenKeyFk(genKey); + thrProductsEntity.setThirdSysFk(thirdSys); + thrProductsEntity.setUpdateTime(new Date()); + return thrProductsEntity; + } + ).collect(Collectors.toList()); + thrInvProductsDetailService.insertInvProductsDetailImports(thrProductsEntities); + page++; + if (page * limit < responseBaseResponse.getData().getTotal()) { + return page; + } + } + thrInvProductsImportLogEntity.setStatus(BasicProcessStatus.UDIINFO_IMPORT_SUCCESS); + thrInvProductsImportLogService.updateImportLog(thrInvProductsImportLogEntity); + return -1; + } + + public List exportInvProducts(FilterThrInvProductsRequest filterThrInvProductsRequest) { + ThrSystemDetailEntity thrSystemDetailEntity = thrSystemDetailService.selectByKey("invPiUrl", filterThrInvProductsRequest.getThirdSys()); + int page = 1; + int limit = 100; + List thrInvProductsEntities = new ArrayList<>(); + while (true) { + List datas = getInvProducts(page, limit, thrSystemDetailEntity.getValue(), filterThrInvProductsRequest); + if (datas != null && datas.size() >= limit) { + thrInvProductsEntities.addAll(datas); + page++; + + } else { + if (datas != null) { + thrInvProductsEntities.addAll(datas); + } + break; + } + } + return thrInvProductsEntities; + } + + public List getInvProducts(int page, int limit, String invPiUrl, FilterThrInvProductsRequest filterThrInvProductsRequest) { + ThrOnhandRequest ThrOnhandRequest = new ThrOnhandRequest(); + BeanUtils.copyProperties(filterThrInvProductsRequest, ThrOnhandRequest); + ThrOnhandRequest.setPage(page); + ThrOnhandRequest.setLimit(limit); + + BaseResponse> responseBaseResponse = erpInvClient.getInvPrdoductResponse(ThrOnhandRequest, invPiUrl); + if (responseBaseResponse != null && responseBaseResponse.getCode() == 20000) { + List ThrInvProductResponses = responseBaseResponse.getData().getList(); + if (ThrInvProductResponses != null && ThrInvProductResponses.size() > 0) { + List thrProductsEntities = ThrInvProductResponses.stream().map( + item -> { + ThrInvProductsEntity thrProductsEntity = new ThrInvProductsEntity(); + BeanUtils.copyProperties(item, thrProductsEntity); + thrProductsEntity.setInventoryCode(item.getCode()); + thrProductsEntity.setInventoryName(item.getName()); + return thrProductsEntity; + } + ).collect(Collectors.toList()); + return thrProductsEntities; + } + } + + + return null; + } + + public List> genExcelData(String id, FilterThrInvProductsRequest filterThrInvProductsRequest) { + filterThrInvProductsRequest.setThirdSysFk(filterThrInvProductsRequest.getThirdSys()); + List> excelData = new ArrayList<>(); + List thrInvProductsEntities = new ArrayList<>(); + if (id != null) { + ThrInvProductsEntity thrInvProductsEntity = thrInvProductsService.selectById(id); + thrInvProductsEntities.add(thrInvProductsEntity); + } else { + thrInvProductsEntities = thrInvProductsService.filterThrInvProductss(filterThrInvProductsRequest); + } + excelData.addAll(getRows(thrInvProductsEntities)); + return excelData; + } + + + public List> getRows(List thrInvProductsEntities) { + List> excelData = new ArrayList<>(); + for (ThrInvProductsEntity thrInvProductsEntity : thrInvProductsEntities) { + List rows = new ArrayList<>(); + rows.add(thrInvProductsEntity.getInventoryCode()); + rows.add(thrInvProductsEntity.getInventoryName()); + rows.add(thrInvProductsEntity.getSpec()); + rows.add(thrInvProductsEntity.getCount() + ""); + rows.add(thrInvProductsEntity.getBatchNo()); + rows.add(thrInvProductsEntity.getManufacturingDate()); + rows.add(thrInvProductsEntity.getExpirationDate()); + rows.add(thrInvProductsEntity.getWarehouseCode()); + rows.add(thrInvProductsEntity.getWarehouseName()); + rows.add(thrInvProductsEntity.getSpaceCode()); + rows.add(thrInvProductsEntity.getSpaceName()); + excelData.add(rows); + } + return excelData; + } +} diff --git a/src/main/java/com/glxp/api/service/thrsys/ThrInvProductsExportLogService.java b/src/main/java/com/glxp/api/service/thrsys/ThrInvProductsExportLogService.java new file mode 100644 index 000000000..fe97a2d34 --- /dev/null +++ b/src/main/java/com/glxp/api/service/thrsys/ThrInvProductsExportLogService.java @@ -0,0 +1,21 @@ +package com.glxp.api.service.thrsys; + + + +import com.glxp.api.entity.thrsys.ThrInvProductsExportLogEntity; +import com.glxp.api.req.thrsys.FilterThrCorpExportLogRequest; + +import java.util.List; + +public interface ThrInvProductsExportLogService { + + ThrInvProductsExportLogEntity selectByGenKey(String genKey); + + List filterThrInvProductsExportLog(FilterThrCorpExportLogRequest filterThrCorpExportLogRequest); + + boolean insertThrInvProductsExportLog(ThrInvProductsExportLogEntity thrInvProductsExportLogEntity); + + boolean updateThrInvProductsExportLog(ThrInvProductsExportLogEntity thrInvProductsExportLogEntity); + + boolean deleteById(String id); +} diff --git a/src/main/java/com/glxp/api/service/thrsys/ThrInvProductsImportLogService.java b/src/main/java/com/glxp/api/service/thrsys/ThrInvProductsImportLogService.java new file mode 100644 index 000000000..33d36ec49 --- /dev/null +++ b/src/main/java/com/glxp/api/service/thrsys/ThrInvProductsImportLogService.java @@ -0,0 +1,22 @@ +package com.glxp.api.service.thrsys; + + + +import com.glxp.api.entity.thrsys.ThrInvProductsImportLogEntity; +import com.glxp.api.req.thrsys.FilterThrCorpImportLogRequest; + +import java.util.List; + +public interface ThrInvProductsImportLogService { + + + List filterThrInvProductsImportLog(FilterThrCorpImportLogRequest filterThrCorpImportLogRequest); + + boolean insertImportLog(ThrInvProductsImportLogEntity thrInvProductsImportLogEntity); + + boolean updateImportLog(ThrInvProductsImportLogEntity thrInvProductsImportLogEntity); + + boolean deleteById(String id); + + ThrInvProductsImportLogEntity selectByGenKey(String genKey); +} diff --git a/src/main/java/com/glxp/api/service/thrsys/ThrInvProductsService.java b/src/main/java/com/glxp/api/service/thrsys/ThrInvProductsService.java index d906a8a05..f725eafae 100644 --- a/src/main/java/com/glxp/api/service/thrsys/ThrInvProductsService.java +++ b/src/main/java/com/glxp/api/service/thrsys/ThrInvProductsService.java @@ -1,17 +1,26 @@ package com.glxp.api.service.thrsys; -import com.baomidou.mybatisplus.extension.service.IService; + import com.glxp.api.entity.thrsys.ThrInvProductsEntity; +import com.glxp.api.req.thrsys.FilterThrInvProductsRequest; + +import java.util.List; + +public interface ThrInvProductsService { + + List filterThrInvProductss(FilterThrInvProductsRequest filterThrInvProductsRequest); + + ThrInvProductsEntity selectById(String id); + + boolean insertThrInvProduct(ThrInvProductsEntity thrInvProductsEntity); + + boolean insertThrInvProducts(List thrInvProductsEntities); + + boolean updateThrInvProducts(ThrInvProductsEntity thrInvProductsEntity); + + boolean deleteById(String id); -/** - *

- * 第三方产品信息表 服务类 - *

- * - * @author zml - * @since 2023-01-10 - */ -public interface ThrInvProductsService extends IService { + boolean deleteAll(); } diff --git a/src/main/java/com/glxp/api/service/thrsys/impl/ThrInvProductsDetailServiceImpl.java b/src/main/java/com/glxp/api/service/thrsys/impl/ThrInvProductsDetailServiceImpl.java new file mode 100644 index 000000000..75f7fb51a --- /dev/null +++ b/src/main/java/com/glxp/api/service/thrsys/impl/ThrInvProductsDetailServiceImpl.java @@ -0,0 +1,57 @@ +package com.glxp.api.service.thrsys.impl; + +import com.github.pagehelper.PageHelper; +import com.glxp.api.dao.thrsys.ThrInvProductsDetailDao; +import com.glxp.api.entity.thrsys.ThrInvProductsImportDetailEntity; +import com.glxp.api.req.thrsys.FilterThrCorpImportLogRequest; +import com.glxp.api.service.thrsys.ThrInvProductsDetailService; +import org.springframework.stereotype.Service; + +import javax.annotation.Resource; +import java.util.Collections; +import java.util.List; + +@Service +public class ThrInvProductsDetailServiceImpl implements ThrInvProductsDetailService { + + @Resource + ThrInvProductsDetailDao thrInvProductsDetailDao; + + @Override + public List filterInvProductsDetailImport(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 data = thrInvProductsDetailDao.filterInvProductsDetailImport(filterThrCorpImportLogRequest); + return data; + } + + @Override + public boolean insertInvProductsDetailImport(ThrInvProductsImportDetailEntity thrInvProductsImportDetailEntity) { + return thrInvProductsDetailDao.insertInvProductsDetailImport(thrInvProductsImportDetailEntity); + } + + @Override + public boolean updateInvProductsDetailImport(ThrInvProductsImportDetailEntity thrInvProductsImportDetailEntity) { + return thrInvProductsDetailDao.updateInvProductsDetailImport(thrInvProductsImportDetailEntity); + } + + @Override + public boolean insertInvProductsDetailImports(List thrInvProductsImportDetailEntities) { + return thrInvProductsDetailDao.insertInvProductsDetailImports(thrInvProductsImportDetailEntities); + } + + @Override + public boolean deleteById(String id) { + return thrInvProductsDetailDao.deleteById(id); + } + + @Override + public boolean deleteByGenkey(String genKey) { + return thrInvProductsDetailDao.deleteByGenkey(genKey); + } +} diff --git a/src/main/java/com/glxp/api/service/thrsys/impl/ThrInvProductsExportLogServiceImpl.java b/src/main/java/com/glxp/api/service/thrsys/impl/ThrInvProductsExportLogServiceImpl.java new file mode 100644 index 000000000..2a87ec30c --- /dev/null +++ b/src/main/java/com/glxp/api/service/thrsys/impl/ThrInvProductsExportLogServiceImpl.java @@ -0,0 +1,58 @@ +package com.glxp.api.service.thrsys.impl; + +import com.github.pagehelper.PageHelper; +import com.glxp.api.dao.thrsys.ThrInvProductsExportLogDao; +import com.glxp.api.entity.thrsys.ThrInvProductsExportLogEntity; +import com.glxp.api.req.thrsys.FilterThrCorpExportLogRequest; +import com.glxp.api.service.thrsys.ThrInvProductsExportLogService; +import org.springframework.stereotype.Service; + +import javax.annotation.Resource; +import java.util.Collections; +import java.util.List; + +@Service +public class ThrInvProductsExportLogServiceImpl implements ThrInvProductsExportLogService { + + @Resource + ThrInvProductsExportLogDao thrInvProductsExportLogDao; + + @Override + public ThrInvProductsExportLogEntity selectByGenKey(String genKey) { + FilterThrCorpExportLogRequest filterUdiEpLogRequest = new FilterThrCorpExportLogRequest(); + filterUdiEpLogRequest.setGenKey(genKey); + List thrInvProductsExportLogEntities = thrInvProductsExportLogDao.filterThrInvProductsExportLog(filterUdiEpLogRequest); + if (thrInvProductsExportLogEntities != null && thrInvProductsExportLogEntities.size() > 0) { + return thrInvProductsExportLogEntities.get(0); + } + return null; + } + + @Override + public List filterThrInvProductsExportLog(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 data = thrInvProductsExportLogDao.filterThrInvProductsExportLog(filterThrCorpExportLogRequest); + return data; + } + + @Override + public boolean insertThrInvProductsExportLog(ThrInvProductsExportLogEntity thrInvProductsExportLogEntity) { + return thrInvProductsExportLogDao.insertThrInvProductsExportLog(thrInvProductsExportLogEntity); + } + + @Override + public boolean updateThrInvProductsExportLog(ThrInvProductsExportLogEntity thrInvProductsExportLogEntity) { + return thrInvProductsExportLogDao.updateThrInvProductsExportLog(thrInvProductsExportLogEntity); + } + + @Override + public boolean deleteById(String id) { + return thrInvProductsExportLogDao.deleteById(id); + } +} diff --git a/src/main/java/com/glxp/api/service/thrsys/impl/ThrInvProductsImportLogServiceImpl.java b/src/main/java/com/glxp/api/service/thrsys/impl/ThrInvProductsImportLogServiceImpl.java new file mode 100644 index 000000000..3080784df --- /dev/null +++ b/src/main/java/com/glxp/api/service/thrsys/impl/ThrInvProductsImportLogServiceImpl.java @@ -0,0 +1,59 @@ +package com.glxp.api.service.thrsys.impl; + +import com.github.pagehelper.PageHelper; +import com.glxp.api.dao.thrsys.ThrInvProductsImportLogDao; +import com.glxp.api.entity.thrsys.ThrInvProductsImportLogEntity; +import com.glxp.api.req.thrsys.FilterThrCorpImportLogRequest; +import com.glxp.api.service.thrsys.ThrInvProductsImportLogService; +import org.springframework.stereotype.Service; + +import javax.annotation.Resource; +import java.util.Collections; +import java.util.List; + +@Service +public class ThrInvProductsImportLogServiceImpl implements ThrInvProductsImportLogService +{ + + @Resource + ThrInvProductsImportLogDao thrInvProductsImportLogDao; + + @Override + public List filterThrInvProductsImportLog(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 data = thrInvProductsImportLogDao.filterThrInvProductsImportLog(filterThrCorpImportLogRequest); + return data; + } + + @Override + public boolean insertImportLog(ThrInvProductsImportLogEntity thrInvProductsImportLogEntity) { + return thrInvProductsImportLogDao.insertImportLog(thrInvProductsImportLogEntity); + } + + @Override + public boolean updateImportLog(ThrInvProductsImportLogEntity thrInvProductsImportLogEntity) { + return thrInvProductsImportLogDao.updateImportLog(thrInvProductsImportLogEntity); + } + + @Override + public boolean deleteById(String id) { + return thrInvProductsImportLogDao.deleteById(id); + } + + @Override + public ThrInvProductsImportLogEntity selectByGenKey(String genKey) { + FilterThrCorpImportLogRequest filterUdiIpLogRequest = new FilterThrCorpImportLogRequest(); + filterUdiIpLogRequest.setGenKey(genKey); + List data = thrInvProductsImportLogDao.filterThrInvProductsImportLog(filterUdiIpLogRequest); + if (data != null && data.size() > 0) { + return data.get(0); + } + return null; + } +} diff --git a/src/main/java/com/glxp/api/service/thrsys/impl/ThrInvProductsServiceImpl.java b/src/main/java/com/glxp/api/service/thrsys/impl/ThrInvProductsServiceImpl.java index 6ed061e59..84422962f 100644 --- a/src/main/java/com/glxp/api/service/thrsys/impl/ThrInvProductsServiceImpl.java +++ b/src/main/java/com/glxp/api/service/thrsys/impl/ThrInvProductsServiceImpl.java @@ -1,21 +1,63 @@ package com.glxp.api.service.thrsys.impl; +import com.github.pagehelper.PageHelper; -import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.glxp.api.dao.thrsys.ThrInvProductsDao; import com.glxp.api.entity.thrsys.ThrInvProductsEntity; +import com.glxp.api.req.thrsys.FilterThrInvProductsRequest; import com.glxp.api.service.thrsys.ThrInvProductsService; import org.springframework.stereotype.Service; -/** - *

- * 第三方产品信息表 服务实现类 - *

- * - * @author zml - * @since 2023-01-10 - */ +import javax.annotation.Resource; +import java.util.Collections; +import java.util.List; + @Service -public class ThrInvProductsServiceImpl extends ServiceImpl implements ThrInvProductsService { +public class ThrInvProductsServiceImpl implements ThrInvProductsService { + + @Resource + private ThrInvProductsDao thrInvProductsDao; + + @Override + public List filterThrInvProductss(FilterThrInvProductsRequest filterThrInvProductsRequest) { + if (filterThrInvProductsRequest == null) { + return Collections.emptyList(); + } + if (filterThrInvProductsRequest.getPage() != null) { + int offset = (filterThrInvProductsRequest.getPage() - 1) * filterThrInvProductsRequest.getLimit(); + PageHelper.offsetPage(offset, filterThrInvProductsRequest.getLimit()); + } + List data = thrInvProductsDao.filterThrInvProductss(filterThrInvProductsRequest); + return data; + } + + @Override + public ThrInvProductsEntity selectById(String id) { + return thrInvProductsDao.selectById(id); + } + + @Override + public boolean insertThrInvProduct(ThrInvProductsEntity thrInvProductsEntity) { + return thrInvProductsDao.insertThrInvProduct(thrInvProductsEntity); + } + + @Override + public boolean insertThrInvProducts(List thrInvProductsEntities) { + return thrInvProductsDao.insertThrInvProducts(thrInvProductsEntities); + } + + @Override + public boolean updateThrInvProducts(ThrInvProductsEntity thrInvProductsEntity) { + return thrInvProductsDao.updateThrInvProducts(thrInvProductsEntity); + } + + @Override + public boolean deleteById(String id) { + return thrInvProductsDao.deleteById(id); + } + @Override + public boolean deleteAll() { + return thrInvProductsDao.deleteAll(); + } } diff --git a/src/main/resources/mybatis/mapper/thrsys/ThrInvProductsDao.xml b/src/main/resources/mybatis/mapper/thrsys/ThrInvProductsDao.xml index b331b11cb..81f6b6221 100644 --- a/src/main/resources/mybatis/mapper/thrsys/ThrInvProductsDao.xml +++ b/src/main/resources/mybatis/mapper/thrsys/ThrInvProductsDao.xml @@ -1,42 +1,123 @@ - - + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - id, inventoryCode, inventoryName, spec, count, batchNo, warehouseName, warehouseCode, registerCertNo, spaceCode, spaceName, manufacturingDate, expirationDate, thirdSysFk, manufactory, productDate, expireDate, productName, productId, standard, registerNo, supId, supName, createUser, createTime, updateUser, updateTime, remark - - - + + + + + replace INTO thr_inv_products + ( + inventoryCode,inventoryName,count,spec, + warehouseName,warehouseCode,registerCertNo,manufacturingDate, + expirationDate,thirdSysFk,batchNo,spaceCode,spaceName,updateTime,manufactory, + productDate, expireDate, productName, productId, standard, registerNo, supId, supName + ) + values + ( + #{inventoryCode}, #{inventoryName}, #{count}, #{spec}, + #{warehouseName}, #{warehouseCode}, #{registerCertNo}, #{manufacturingDate}, + #{expirationDate}, + #{thirdSysFk},#{batchNo},#{spaceCode},#{spaceName},#{updateTime},#{manufactory}, + #{productDate}, #{expireDate}, #{productName}, #{productId}, #{standard}, + #{registerNo}, #{supId}, #{supName} + ) + + + + replace INTO thr_inv_products + ( + inventoryCode,inventoryName,count,spec, + warehouseName,warehouseCode,registerCertNo,manufacturingDate, + expirationDate,thirdSysFk,batchNo,spaceCode,spaceName,updateTime,manufactory, + productDate, expireDate, productName, productId, standard, registerNo, supId, supName + ) + values + + + ( + #{item.inventoryCode}, #{item.inventoryName}, #{item.count}, #{item.spec}, + #{item.warehouseName}, #{item.warehouseCode}, #{item.registerCertNo}, + #{item.manufacturingDate}, #{item.expirationDate}, + #{item.thirdSysFk},#{item.batchNo},#{item.spaceCode},#{item.spaceName},#{item.updateTime},#{item.manufactory}, + #{item.productDate},#{item.expireDate}, #{item.productName}, #{item.productId}, #{item.standard}, #{item.registerNo}, + #{item.supId}, #{item.supName} + ) + + + + + DELETE FROM thr_inv_products WHERE id = #{id} + + + + + DELETE FROM thr_inv_products + + + + UPDATE thr_inv_products + + inventoryCode=#{inventoryCode}, + inventoryName=#{inventoryName}, + spec=#{spec}, + count=#{count}, + batchNo=#{batchNo}, + warehouseName=#{warehouseName}, + warehouseCode=#{warehouseCode}, + registerCertNo=#{registerCertNo}, + manufacturingDate=#{manufacturingDate}, + expirationDate=#{expirationDate}, + spaceCode=#{spaceCode}, + spaceName=#{spaceName}, + thirdSysFk=#{thirdSysFk}, + updateTime=#{updateTime}, + manufactory=#{manufactory}, + productDate=#{productDate}, + expireDate=#{expireDate}, + productName=#{productName}, + productId=#{productId}, + standard=#{standard}, + registerNo=#{registerNo}, + supId=#{supId}, + supName=#{supName}, + + WHERE id = #{id} + + + \ No newline at end of file diff --git a/src/main/resources/mybatis/mapper/thrsys/ThrInvProductsDetailDao.xml b/src/main/resources/mybatis/mapper/thrsys/ThrInvProductsDetailDao.xml new file mode 100644 index 000000000..bfd21a2ca --- /dev/null +++ b/src/main/resources/mybatis/mapper/thrsys/ThrInvProductsDetailDao.xml @@ -0,0 +1,92 @@ + + + + + + + + + + insert INTO thr_inv_products_import_detail + ( + inventoryCode,inventoryName,count,spec, + warehouseName,warehouseCode,registerCertNo,manufacturingDate, + expirationDate,thirdSysFk,batchNo,spaceCode,spaceName,updateTime ,genKeyFk + ) + values + ( + #{inventoryCode}, #{inventoryName}, #{count}, #{spec}, + #{warehouseName}, #{warehouseCode}, #{registerCertNo}, #{manufacturingDate}, + #{expirationDate}, + #{thirdSysFk},#{batchNo},#{spaceCode},#{spaceName}, + #{updateTime}, + #{genKeyFk} + ) + + + + insert INTO thr_inv_products_import_detail + ( + inventoryCode,inventoryName,count,spec, + warehouseName,warehouseCode,registerCertNo,manufacturingDate, + expirationDate,thirdSysFk,batchNo,spaceCode,spaceName,updateTime ,genKeyFk ) + values + + ( + #{item.inventoryCode}, #{item.inventoryName}, #{item.count}, #{item.spec}, + #{item.warehouseName}, #{item.warehouseCode}, #{item.registerCertNo}, + #{item.manufacturingDate}, #{item.expirationDate}, + #{item.thirdSysFk},#{item.batchNo},#{item.spaceCode},#{item.spaceName} + ,#{item.updateTime},#{item.genKeyFk} ) + + + + DELETE FROM thr_inv_products_import_detail WHERE id = #{id} + + + DELETE FROM thr_inv_products_import_detail WHERE genKeyFk = #{genKey} + + + + UPDATE thr_inv_products_import_detail + + inventoryCode=#{inventoryCode}, + inventoryName=#{inventoryName}, + spec=#{spec}, + count=#{count}, + batchNo=#{batchNo}, + warehouseName=#{warehouseName}, + warehouseCode=#{warehouseCode}, + registerCertNo=#{registerCertNo}, + manufacturingDate=#{manufacturingDate}, + expirationDate=#{expirationDate}, + spaceCode=#{spaceCode}, + spaceName=#{spaceName}, + thirdSysFk=#{thirdSysFk}, + updateTime=#{updateTime}, + genKeyFk=#{genKeyFk}, + + WHERE id = #{id} + + + \ No newline at end of file diff --git a/src/main/resources/mybatis/mapper/thrsys/ThrInvProductsExportLogDao.xml b/src/main/resources/mybatis/mapper/thrsys/ThrInvProductsExportLogDao.xml new file mode 100644 index 000000000..6d5dffb04 --- /dev/null +++ b/src/main/resources/mybatis/mapper/thrsys/ThrInvProductsExportLogDao.xml @@ -0,0 +1,53 @@ + + + + + + + + + + insert INTO thr_inv_products_export_log + (genKey,updateTime,dlCount,status,filePath,remark,`type`) + values + ( + #{genKey}, + #{updateTime}, + #{dlCount},#{status},#{filePath},#{remark},#{type} + ) + + + + + DELETE FROM thr_inv_products_export_log WHERE id = #{id} + + + + UPDATE thr_inv_products_export_log + + updateTime=#{updateTime}, + dlCount=#{dlCount}, + status=#{status}, + filePath=#{filePath}, + remark=#{remark}, + + WHERE genKey = #{genKey} + + + \ No newline at end of file diff --git a/src/main/resources/mybatis/mapper/thrsys/ThrInvProductsImportLogDao.xml b/src/main/resources/mybatis/mapper/thrsys/ThrInvProductsImportLogDao.xml new file mode 100644 index 000000000..8b6becc46 --- /dev/null +++ b/src/main/resources/mybatis/mapper/thrsys/ThrInvProductsImportLogDao.xml @@ -0,0 +1,57 @@ + + + + + + + + + + insert INTO thr_inv_products_import_log + (genKey,fromType,updateTime,thirdSysFk,status) + values + ( + #{genKey}, + #{fromType}, + #{updateTime}, + #{thirdSysFk},#{status} + ) + + + + + DELETE FROM thr_inv_products_import_log WHERE id = #{id} + + + + UPDATE thr_inv_products_import_log + + genKey=#{genKey}, + fromType=#{fromType}, + updateTime=#{updateTime}, + thirdSysFk=#{thirdSysFk}, + status=#{status}, + remark=#{remark}, + + WHERE genKey = #{genKey} + + + \ No newline at end of file