From fe3957739897eb4fc8c65c55b713cc9fa6e09907 Mon Sep 17 00:00:00 2001 From: anthonyywj2 <353682448@qq.com> Date: Thu, 24 Mar 2022 16:36:25 +0800 Subject: [PATCH] =?UTF-8?q?=E5=90=8C=E6=AD=A5=E6=9C=8D=E5=8A=A1=E5=AE=8C?= =?UTF-8?q?=E7=BB=93=EF=BC=8C=E4=BB=A3=E7=A0=81=E5=A4=87=E4=BB=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../admin/constant/BasicProcessStatus.java | 13 ++ .../sync/BasicDowmloadController.java | 78 +++++++ .../sync/BasicExportUploadController.java | 191 ++++++++++++++++++ .../sync/ThrProductsImportLogController.java | 2 - .../sale/admin/dao/sync/BasicExportDao.java | 22 ++ .../entity/sync/BasicExportStatusEntity.java | 14 ++ .../entity/sync/BasicUnitMaintainEntity.java | 37 ++++ .../admin/entity/sync/InvWarehouseEntity.java | 32 +++ .../sale/admin/entity/sync/ThrCorpEntity.java | 23 +++ .../entity/sync/ThrInvWarehouseEntity.java | 32 +++ .../entity/sync/ThrOrderDetailEntity.java | 22 ++ .../admin/entity/sync/ThrOrderEntity.java | 21 ++ .../admin/entity/sync/ThrProductsEntity.java | 31 +++ .../com/glxp/sale/admin/http/SpGetHttp.java | 74 ++++++- .../com/glxp/sale/admin/http/SpPostHttp.java | 94 +++++++++ .../req/sync/BasicDataFilterRequest.java | 13 ++ .../req/sync/BasicExportStatusRequest.java | 11 + .../req/sync/BasicStatusFilterRequest.java | 10 + .../admin/req/sync/PostThrCorpRequest.java | 14 ++ .../sync/BasicUnitMaintainExportResponse.java | 30 +++ .../res/sync/InvWarehouseExportResponse.java | 14 ++ .../res/sync/ThrOrderExportJsonResponse.java | 16 ++ .../sync/UdiRelevanceExportJsonResponse.java | 7 +- .../service/sync/BasicExportService.java | 20 ++ .../sync/impl/BasicExportServiceImpl.java | 46 +++++ .../sale/admin/thread/DlBasicService.java | 185 +++++++++++++++++ .../sale/admin/thread/DlSpOrderService.java | 7 +- .../sale/admin/thread/DlUploadService.java | 132 ++++++++++++ .../com/glxp/sale/admin/thread/HeartTask.java | 92 +++++++-- .../admin/thread/ScanDownloadService.java | 121 +++++++++++ .../sale/admin/thread/ScanUploadService.java | 190 +++++++++++++++++ .../glxp/sale/admin/util/FileFilterImpl.java | 13 ++ .../com/glxp/sale/admin/util/FileUtils.java | 16 +- .../main/resources/application-pro.properties | 44 +++- .../mybatis/mapper/sync/BasicExportDao.xml | 52 +++++ 35 files changed, 1694 insertions(+), 25 deletions(-) create mode 100644 api-admin/src/main/java/com/glxp/sale/admin/controller/sync/BasicDowmloadController.java create mode 100644 api-admin/src/main/java/com/glxp/sale/admin/controller/sync/BasicExportUploadController.java create mode 100644 api-admin/src/main/java/com/glxp/sale/admin/dao/sync/BasicExportDao.java create mode 100644 api-admin/src/main/java/com/glxp/sale/admin/entity/sync/BasicExportStatusEntity.java create mode 100644 api-admin/src/main/java/com/glxp/sale/admin/entity/sync/BasicUnitMaintainEntity.java create mode 100644 api-admin/src/main/java/com/glxp/sale/admin/entity/sync/InvWarehouseEntity.java create mode 100644 api-admin/src/main/java/com/glxp/sale/admin/entity/sync/ThrCorpEntity.java create mode 100644 api-admin/src/main/java/com/glxp/sale/admin/entity/sync/ThrInvWarehouseEntity.java create mode 100644 api-admin/src/main/java/com/glxp/sale/admin/entity/sync/ThrOrderDetailEntity.java create mode 100644 api-admin/src/main/java/com/glxp/sale/admin/entity/sync/ThrOrderEntity.java create mode 100644 api-admin/src/main/java/com/glxp/sale/admin/entity/sync/ThrProductsEntity.java create mode 100644 api-admin/src/main/java/com/glxp/sale/admin/http/SpPostHttp.java create mode 100644 api-admin/src/main/java/com/glxp/sale/admin/req/sync/BasicDataFilterRequest.java create mode 100644 api-admin/src/main/java/com/glxp/sale/admin/req/sync/BasicExportStatusRequest.java create mode 100644 api-admin/src/main/java/com/glxp/sale/admin/req/sync/BasicStatusFilterRequest.java create mode 100644 api-admin/src/main/java/com/glxp/sale/admin/req/sync/PostThrCorpRequest.java create mode 100644 api-admin/src/main/java/com/glxp/sale/admin/res/sync/BasicUnitMaintainExportResponse.java create mode 100644 api-admin/src/main/java/com/glxp/sale/admin/res/sync/InvWarehouseExportResponse.java create mode 100644 api-admin/src/main/java/com/glxp/sale/admin/res/sync/ThrOrderExportJsonResponse.java create mode 100644 api-admin/src/main/java/com/glxp/sale/admin/service/sync/BasicExportService.java create mode 100644 api-admin/src/main/java/com/glxp/sale/admin/service/sync/impl/BasicExportServiceImpl.java create mode 100644 api-admin/src/main/java/com/glxp/sale/admin/thread/DlBasicService.java create mode 100644 api-admin/src/main/java/com/glxp/sale/admin/thread/DlUploadService.java create mode 100644 api-admin/src/main/java/com/glxp/sale/admin/thread/ScanDownloadService.java create mode 100644 api-admin/src/main/java/com/glxp/sale/admin/thread/ScanUploadService.java create mode 100644 api-admin/src/main/java/com/glxp/sale/admin/util/FileFilterImpl.java create mode 100644 api-admin/src/main/resources/mybatis/mapper/sync/BasicExportDao.xml diff --git a/api-admin/src/main/java/com/glxp/sale/admin/constant/BasicProcessStatus.java b/api-admin/src/main/java/com/glxp/sale/admin/constant/BasicProcessStatus.java index d53581d..fc8cc89 100644 --- a/api-admin/src/main/java/com/glxp/sale/admin/constant/BasicProcessStatus.java +++ b/api-admin/src/main/java/com/glxp/sale/admin/constant/BasicProcessStatus.java @@ -21,6 +21,19 @@ public class BasicProcessStatus { public static final int DATA_TYPE_UDI = 1; public static final int DATA_TYPE_SP = 2; + //导出数据类型 + public static final int BASIC_UDI = 1; //耗材字典 + public static final int BASIC_INV = 2; //仓库字典 + public static final int BASIC_CORP = 3; //往来单位 + public static final int BASIC_THIRD_PRODUCTS = 4; //往来单位 + public static final int BASIC_THIRD_CORP = 5; //往来单位 + public static final int BASIC_THIRD_ORDER = 6; //往来单位 + + + public static final int IMPORT_LOG_TYPE_ORDER = 1;//单据 + public static final int IMPORT_LOG_TYPE_UDIINFO = 2;//耗材字典 + public static final int IMPORT_LOG_TYPE_CORP = 3;//往来单位 + public static final int IMPORT_LOG_TYPE_INV = 4;//仓库字典 } diff --git a/api-admin/src/main/java/com/glxp/sale/admin/controller/sync/BasicDowmloadController.java b/api-admin/src/main/java/com/glxp/sale/admin/controller/sync/BasicDowmloadController.java new file mode 100644 index 0000000..b38e03e --- /dev/null +++ b/api-admin/src/main/java/com/glxp/sale/admin/controller/sync/BasicDowmloadController.java @@ -0,0 +1,78 @@ +package com.glxp.sale.admin.controller.sync; + +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONObject; +import com.alibaba.fastjson.TypeReference; +import com.glxp.sale.admin.annotation.AuthRuleAnnotation; +import com.glxp.sale.admin.constant.BasicProcessStatus; +import com.glxp.sale.admin.entity.sync.BasicExportStatusEntity; +import com.glxp.sale.admin.req.info.DeleteRequest; +import com.glxp.sale.admin.req.sync.BasicExportStatusRequest; +import com.glxp.sale.admin.req.sync.FilterUdiInfoRequest; +import com.glxp.sale.admin.res.sync.BasicUnitMaintainExportResponse; +import com.glxp.sale.admin.res.sync.InvWarehouseExportResponse; +import com.glxp.sale.admin.res.sync.UdiRelevanceExportJsonResponse; +import com.glxp.sale.admin.service.sync.BasicExportService; +import com.glxp.sale.admin.util.RedisUtil; +import com.glxp.sale.common.res.BaseResponse; +import com.glxp.sale.common.util.ResultVOUtils; +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 BasicDowmloadController { + + + @Resource + BasicExportService basicExportService; + @Resource + RedisUtil redisUtil; + + + @GetMapping("/spssync/basic/udiinfo/getStatus") + public BaseResponse getStatus(BasicExportStatusRequest basicExportStatusRequest) { + List basicExportStatusEntities = basicExportService.filterExportStatus(basicExportStatusRequest); + return ResultVOUtils.success(basicExportStatusEntities); + } + + + @PostMapping("/spssync/basic/udiinfo/downloadByStatus") + public BaseResponse downloadByStatus(@RequestBody BasicExportStatusRequest basicExportStatusRequest) { + + if (basicExportStatusRequest.getType() == BasicProcessStatus.BASIC_UDI) {//基础信息下载 + String data = (String) redisUtil.get(basicExportStatusRequest.getId() + ""); + UdiRelevanceExportJsonResponse udiRelevanceExportJsonResponse = JSONObject.parseObject(data, new TypeReference() { + }); + return ResultVOUtils.success(udiRelevanceExportJsonResponse); + } else if (basicExportStatusRequest.getType() == BasicProcessStatus.BASIC_CORP) {//基础信息下载 + String data = (String) redisUtil.get(basicExportStatusRequest.getId() + ""); + BasicUnitMaintainExportResponse basicUnitMaintainExportResponse = JSONObject.parseObject(data, new TypeReference() { + }); + return ResultVOUtils.success(basicUnitMaintainExportResponse); + } else if (basicExportStatusRequest.getType() == BasicProcessStatus.BASIC_INV) {//基础信息下载 + String data = (String) redisUtil.get(basicExportStatusRequest.getId() + ""); + InvWarehouseExportResponse invWarehouseExportResponse = JSONObject.parseObject(data, new TypeReference() { + }); + return ResultVOUtils.success(invWarehouseExportResponse); + } + return ResultVOUtils.error(500, "数据不存在!"); + + } + + + @PostMapping("/spssync/basic/udiinfo/deleteByStatus") + public BaseResponse deleteByStatus(@RequestBody DeleteRequest deleteRequest) { + + boolean b = basicExportService.deleteById(Integer.parseInt(deleteRequest.getId())); + redisUtil.del(deleteRequest.getId()); + if (b) + return ResultVOUtils.success("删除成功!"); + else + return ResultVOUtils.error(500, "删除失败!"); + } +} \ No newline at end of file diff --git a/api-admin/src/main/java/com/glxp/sale/admin/controller/sync/BasicExportUploadController.java b/api-admin/src/main/java/com/glxp/sale/admin/controller/sync/BasicExportUploadController.java new file mode 100644 index 0000000..b4abe1c --- /dev/null +++ b/api-admin/src/main/java/com/glxp/sale/admin/controller/sync/BasicExportUploadController.java @@ -0,0 +1,191 @@ +package com.glxp.sale.admin.controller.sync; + + +import com.alibaba.fastjson.JSON; +import com.glxp.sale.admin.entity.param.SystemParamConfigEntity; +import com.glxp.sale.admin.entity.sync.IOOrderStatusEntity; +import com.glxp.sale.admin.http.SpPostHttp; +import com.glxp.sale.admin.req.sync.PostThrCorpRequest; +import com.glxp.sale.admin.req.sync.PostThrProductsRequest; +import com.glxp.sale.admin.res.sync.*; +import com.glxp.sale.admin.service.param.SystemParamConfigService; +import com.glxp.sale.admin.util.CustomUtil; +import com.glxp.sale.admin.util.FileUtils; +import com.glxp.sale.common.enums.ResultEnum; +import com.glxp.sale.common.res.BaseResponse; +import com.glxp.sale.common.util.ResultVOUtils; +import org.springframework.beans.factory.annotation.Value; +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; + +/** + * 接收下游上传数据 + */ + +@RestController +public class BasicExportUploadController { + + @Value("${file_path_dupp_udiinfo}") + private String udiFilePath; + @Value("${back_file_path}") + private String backFilePath; + @Resource + SystemParamConfigService systemParamConfigService; + @Resource + SpPostHttp spPostHttp; + + @PostMapping("/spssync/basic/udiinfo/upload") + public BaseResponse postUdiInfo(@RequestBody UdiRelevanceExportJsonResponse udiRelevanceExportJsonResponse, + BindingResult bindingResult) { + + if (bindingResult.hasErrors()) { + return ResultVOUtils.error(ResultEnum.PARAM_VERIFY_FALL, bindingResult.getFieldError().getDefaultMessage()); + } + SystemParamConfigEntity systemParamConfigEntity = systemParamConfigService.selectByParamKey("sync_upstream_enable"); + if (systemParamConfigEntity.getParamValue().equals("0")) {//上游不通 + String key = CustomUtil.getId(); + String fileName = udiFilePath + "耗材字典" + key + ".udi"; + String backFileName = backFilePath + "耗材字典" + key + ".udi"; + FileUtils.makeDirectory(udiFilePath); + FileUtils.makeDirectory(backFilePath); + String datas = JSON.toJSONString(udiRelevanceExportJsonResponse); + FileUtils.SaveFileAs(datas, fileName); + FileUtils.SaveFileAs(datas, backFileName); + return ResultVOUtils.success("文件上传成功,已保存,等待拷贝!"); + } else { + //上游通 + return spPostHttp.postUdiInfo(udiRelevanceExportJsonResponse); + } + } + + + @PostMapping("/spssync/basic/corp/upload") + public BaseResponse postCorp(@RequestBody BasicUnitMaintainExportResponse basicUnitMaintainExportResponse, + BindingResult bindingResult) { + + if (bindingResult.hasErrors()) { + return ResultVOUtils.error(ResultEnum.PARAM_VERIFY_FALL, bindingResult.getFieldError().getDefaultMessage()); + } + SystemParamConfigEntity systemParamConfigEntity = systemParamConfigService.selectByParamKey("sync_upstream_enable"); + if (systemParamConfigEntity.getParamValue().equals("0")) {//上游不通 + String key = CustomUtil.getId(); + String fileName = udiFilePath + "往来单位" + key + ".udi"; + String backFileName = backFilePath + "往来单位" + key + ".udi"; + FileUtils.makeDirectory(udiFilePath); + FileUtils.makeDirectory(backFilePath); + String datas = JSON.toJSONString(basicUnitMaintainExportResponse); + FileUtils.SaveFileAs(datas, fileName); + FileUtils.SaveFileAs(datas, backFileName); + return ResultVOUtils.success("文件上传成功,已保存,等待拷贝!"); + } else { + //上游通 + return spPostHttp.postCorp(basicUnitMaintainExportResponse); + } + } + + + @PostMapping("/spssync/basic/inv/upload") + public BaseResponse postInv(@RequestBody InvWarehouseExportResponse invWarehouseExportResponse, + BindingResult bindingResult) { + + if (bindingResult.hasErrors()) { + return ResultVOUtils.error(ResultEnum.PARAM_VERIFY_FALL, bindingResult.getFieldError().getDefaultMessage()); + } + SystemParamConfigEntity systemParamConfigEntity = systemParamConfigService.selectByParamKey("sync_upstream_enable"); + if (systemParamConfigEntity.getParamValue().equals("0")) {//上游不通 + String key = CustomUtil.getId(); + String fileName = udiFilePath + "仓库字典" + key + ".udi"; + String backFileName = backFilePath + "仓库字典" + key + ".udi"; + FileUtils.makeDirectory(udiFilePath); + FileUtils.makeDirectory(backFilePath); + String datas = JSON.toJSONString(invWarehouseExportResponse); + FileUtils.SaveFileAs(datas, fileName); + FileUtils.SaveFileAs(datas, backFileName); + return ResultVOUtils.success("文件上传成功,已保存,等待拷贝!"); + } else { + //上游通 + return spPostHttp.postInv(invWarehouseExportResponse); + } + } + + + @PostMapping("/spssync/thirdsys/products/upload") + public BaseResponse postThirdProducts(@RequestBody PostThrProductsRequest postThrProductsRequest, + BindingResult bindingResult) { + + if (bindingResult.hasErrors()) { + return ResultVOUtils.error(ResultEnum.PARAM_VERIFY_FALL, bindingResult.getFieldError().getDefaultMessage()); + } + SystemParamConfigEntity systemParamConfigEntity = systemParamConfigService.selectByParamKey("sync_upstream_enable"); + if (systemParamConfigEntity.getParamValue().equals("0")) {//上游不通 + String key = CustomUtil.getId(); + String fileName = udiFilePath + "第三方产品信息" + key + ".udi"; + String backFileName = backFilePath + "第三方产品信息" + key + ".udi"; + FileUtils.makeDirectory(udiFilePath); + FileUtils.makeDirectory(backFilePath); + String datas = JSON.toJSONString(postThrProductsRequest); + FileUtils.SaveFileAs(datas, fileName); + FileUtils.SaveFileAs(datas, backFileName); + return ResultVOUtils.success("文件上传成功,已保存,等待拷贝!"); + } else { + //上游通 + return spPostHttp.postThirdProducts(postThrProductsRequest); + } + } + + + @PostMapping("/spssync/thirdsys/corp/upload") + public BaseResponse postThridCorp(@RequestBody PostThrCorpRequest postThrCorpRequest, + BindingResult bindingResult) { + + if (bindingResult.hasErrors()) { + return ResultVOUtils.error(ResultEnum.PARAM_VERIFY_FALL, bindingResult.getFieldError().getDefaultMessage()); + } + SystemParamConfigEntity systemParamConfigEntity = systemParamConfigService.selectByParamKey("sync_upstream_enable"); + if (systemParamConfigEntity.getParamValue().equals("0")) {//上游不通 + String key = CustomUtil.getId(); + String fileName = udiFilePath + "第三方往来单位" + key + ".udi"; + String backFileName = backFilePath + "第三方往来单位" + key + ".udi"; + FileUtils.makeDirectory(udiFilePath); + FileUtils.makeDirectory(backFilePath); + String datas = JSON.toJSONString(postThrCorpRequest); + FileUtils.SaveFileAs(datas, fileName); + FileUtils.SaveFileAs(datas, backFileName); + return ResultVOUtils.success("文件上传成功,已保存,等待拷贝!"); + } else { + //上游通 + return spPostHttp.postThirdCorps(postThrCorpRequest); + } + } + + + @PostMapping("/spssync/thirdsys/order/upload") + public BaseResponse postThridOrder(@RequestBody ThrOrderExportJsonResponse thrOrderExportJsonResponse, + BindingResult bindingResult) { + + if (bindingResult.hasErrors()) { + return ResultVOUtils.error(ResultEnum.PARAM_VERIFY_FALL, bindingResult.getFieldError().getDefaultMessage()); + } + SystemParamConfigEntity systemParamConfigEntity = systemParamConfigService.selectByParamKey("sync_upstream_enable"); + if (systemParamConfigEntity.getParamValue().equals("0")) {//上游不通 + String key = CustomUtil.getId(); + String fileName = udiFilePath + "第三方业务单据" + key + ".udi"; + String backFileName = backFilePath + "第三方业务单据" + key + ".udi"; + FileUtils.makeDirectory(udiFilePath); + FileUtils.makeDirectory(backFilePath); + String datas = JSON.toJSONString(thrOrderExportJsonResponse); + FileUtils.SaveFileAs(datas, fileName); + FileUtils.SaveFileAs(datas, backFileName); + return ResultVOUtils.success("文件上传成功,已保存,等待拷贝!"); + } else { + //上游通 + return spPostHttp.postThirdOrders(thrOrderExportJsonResponse); + } + } + +} diff --git a/api-admin/src/main/java/com/glxp/sale/admin/controller/sync/ThrProductsImportLogController.java b/api-admin/src/main/java/com/glxp/sale/admin/controller/sync/ThrProductsImportLogController.java index 3a28df0..f2c02c1 100644 --- a/api-admin/src/main/java/com/glxp/sale/admin/controller/sync/ThrProductsImportLogController.java +++ b/api-admin/src/main/java/com/glxp/sale/admin/controller/sync/ThrProductsImportLogController.java @@ -106,9 +106,7 @@ public class ThrProductsImportLogController { if ("1".equals(value)) { return postSmpHttp.postThrProducts(postThrProductsRequest); } else { - List erpProductsResponses = postThrProductsRequest.getDatas(); - String genKey = postThrProductsRequest.getGenKey(); if (genKey == null) { genKey = CustomUtil.getId(); diff --git a/api-admin/src/main/java/com/glxp/sale/admin/dao/sync/BasicExportDao.java b/api-admin/src/main/java/com/glxp/sale/admin/dao/sync/BasicExportDao.java new file mode 100644 index 0000000..4ed46ec --- /dev/null +++ b/api-admin/src/main/java/com/glxp/sale/admin/dao/sync/BasicExportDao.java @@ -0,0 +1,22 @@ +package com.glxp.sale.admin.dao.sync; + +import com.glxp.sale.admin.entity.sync.BasicExportStatusEntity; +import com.glxp.sale.admin.req.sync.BasicExportStatusRequest; +import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; + +import java.util.List; + +@Mapper +public interface BasicExportDao { + + + List filterExportStatus(BasicExportStatusRequest basicExportStatusRequest); + + boolean insertExportStatus(BasicExportStatusEntity ioOrderStatusEntity); + + boolean deleteById(@Param("id") Integer id); + + boolean updateExportStatus(BasicExportStatusEntity warehouseEntity); + +} diff --git a/api-admin/src/main/java/com/glxp/sale/admin/entity/sync/BasicExportStatusEntity.java b/api-admin/src/main/java/com/glxp/sale/admin/entity/sync/BasicExportStatusEntity.java new file mode 100644 index 0000000..dfcad06 --- /dev/null +++ b/api-admin/src/main/java/com/glxp/sale/admin/entity/sync/BasicExportStatusEntity.java @@ -0,0 +1,14 @@ +package com.glxp.sale.admin.entity.sync; + +import lombok.Data; + +import java.util.Date; + +@Data +public class BasicExportStatusEntity { + private String id; + private String idDatas; + private Integer status; + private Integer type; + private Date updateTime; +} diff --git a/api-admin/src/main/java/com/glxp/sale/admin/entity/sync/BasicUnitMaintainEntity.java b/api-admin/src/main/java/com/glxp/sale/admin/entity/sync/BasicUnitMaintainEntity.java new file mode 100644 index 0000000..79bb52e --- /dev/null +++ b/api-admin/src/main/java/com/glxp/sale/admin/entity/sync/BasicUnitMaintainEntity.java @@ -0,0 +1,37 @@ +package com.glxp.sale.admin.entity.sync; + +import lombok.Data; + +import java.util.Date; + +@Data +public class BasicUnitMaintainEntity { + + private Integer id; + private String erpId; + private String name; + private String spell; + private String addr; + private String status; + private String type; + 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 int corpType; + + +} diff --git a/api-admin/src/main/java/com/glxp/sale/admin/entity/sync/InvWarehouseEntity.java b/api-admin/src/main/java/com/glxp/sale/admin/entity/sync/InvWarehouseEntity.java new file mode 100644 index 0000000..642ba82 --- /dev/null +++ b/api-admin/src/main/java/com/glxp/sale/admin/entity/sync/InvWarehouseEntity.java @@ -0,0 +1,32 @@ +package com.glxp.sale.admin.entity.sync; + +import lombok.Data; + +import java.util.Date; + +@Data +public class InvWarehouseEntity { + + + private Integer id; + private Integer pid; + private String code; + private String name; + private Boolean advanceType; + private Boolean isDefault; + private Integer status; + private Date updateTime; + private String remark; + private Integer level; + private String pcode; + + /** + * 第三方仓库ID + */ + private String thirdId; + private String thirdId1; + private String thirdId2; + private String thirdId3; + private String thirdId4; + +} diff --git a/api-admin/src/main/java/com/glxp/sale/admin/entity/sync/ThrCorpEntity.java b/api-admin/src/main/java/com/glxp/sale/admin/entity/sync/ThrCorpEntity.java new file mode 100644 index 0000000..a124ad1 --- /dev/null +++ b/api-admin/src/main/java/com/glxp/sale/admin/entity/sync/ThrCorpEntity.java @@ -0,0 +1,23 @@ +package com.glxp.sale.admin.entity.sync; + +import lombok.Data; + +import java.util.Date; + +@Data +public class ThrCorpEntity { + + private String id; + private String unitId; + private String name; + private String spell; + private String addr; + private String creditNo; + private String contact; + private String mobile; + private String thirdSysFk; + private Boolean checked; + private Date updateTime; + + +} diff --git a/api-admin/src/main/java/com/glxp/sale/admin/entity/sync/ThrInvWarehouseEntity.java b/api-admin/src/main/java/com/glxp/sale/admin/entity/sync/ThrInvWarehouseEntity.java new file mode 100644 index 0000000..35838b6 --- /dev/null +++ b/api-admin/src/main/java/com/glxp/sale/admin/entity/sync/ThrInvWarehouseEntity.java @@ -0,0 +1,32 @@ +package com.glxp.sale.admin.entity.sync; + +import lombok.Data; + +import java.util.Date; + +/** + * 第三方仓库信息 + */ +@Data +public class ThrInvWarehouseEntity { + + private Integer id; + private Integer pid; + private String code; + private String name; + private Boolean advanceType; + private Boolean isDefault; + private Integer status; + private Date updateTime; + private String remark; + + /** + * 仓库等级 + */ + private Integer level; + + /** + * 父级仓库编码 + */ + private String pcode; +} \ No newline at end of file diff --git a/api-admin/src/main/java/com/glxp/sale/admin/entity/sync/ThrOrderDetailEntity.java b/api-admin/src/main/java/com/glxp/sale/admin/entity/sync/ThrOrderDetailEntity.java new file mode 100644 index 0000000..1a70d16 --- /dev/null +++ b/api-admin/src/main/java/com/glxp/sale/admin/entity/sync/ThrOrderDetailEntity.java @@ -0,0 +1,22 @@ +package com.glxp.sale.admin.entity.sync; + +import lombok.Data; + +import java.util.Date; + +@Data +public class ThrOrderDetailEntity { + private Integer id; + private String productId; + private String productName; + private String spec; + private String batchNo; + private String expireDate; + private String productDate; + private Integer count; + private Integer reCount; + private String orderIdFk; + private String thirdSysFk; + private Date updateTime; + +} diff --git a/api-admin/src/main/java/com/glxp/sale/admin/entity/sync/ThrOrderEntity.java b/api-admin/src/main/java/com/glxp/sale/admin/entity/sync/ThrOrderEntity.java new file mode 100644 index 0000000..1d6dcfd --- /dev/null +++ b/api-admin/src/main/java/com/glxp/sale/admin/entity/sync/ThrOrderEntity.java @@ -0,0 +1,21 @@ +package com.glxp.sale.admin.entity.sync; + +import lombok.Data; + +import java.util.Date; + +@Data +public class ThrOrderEntity { + + private Integer id; + private String billNo; + private String billdate; + private String corpId; + private String corpName; + private String billType; + private String billFlag; + private String thirdSysFk; + private Date updateTime; + private String originType; + +} diff --git a/api-admin/src/main/java/com/glxp/sale/admin/entity/sync/ThrProductsEntity.java b/api-admin/src/main/java/com/glxp/sale/admin/entity/sync/ThrProductsEntity.java new file mode 100644 index 0000000..32b3d94 --- /dev/null +++ b/api-admin/src/main/java/com/glxp/sale/admin/entity/sync/ThrProductsEntity.java @@ -0,0 +1,31 @@ +package com.glxp.sale.admin.entity.sync; + +import lombok.Data; + +import java.util.Date; + +@Data +public class ThrProductsEntity { + private Integer id; + private String code; + private String name; + private String measname; + private String spec; + private String registerNo; + private String manufactory; + private String thirdSysFk; + private String cplb; + private String flbm; + private String qxlb; + private String ybbm; + private String sptm; + private String tyshxydm; + private String zczbhhzbapzbh; + private String ylqxzcrbarmc; + private String ylqxzcrbarywmc; + private String cpms; + private Date updateTime; + private String supName; + private boolean isChecked; + +} diff --git a/api-admin/src/main/java/com/glxp/sale/admin/http/SpGetHttp.java b/api-admin/src/main/java/com/glxp/sale/admin/http/SpGetHttp.java index dab1bc0..af15906 100644 --- a/api-admin/src/main/java/com/glxp/sale/admin/http/SpGetHttp.java +++ b/api-admin/src/main/java/com/glxp/sale/admin/http/SpGetHttp.java @@ -1,11 +1,17 @@ package com.glxp.sale.admin.http; +import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.TypeReference; +import com.glxp.sale.admin.entity.sync.BasicExportStatusEntity; import com.glxp.sale.admin.entity.sync.IOOrderStatusEntity; +import com.glxp.sale.admin.entity.sync.OrderEntity; +import com.glxp.sale.admin.req.sync.BasicDataFilterRequest; +import com.glxp.sale.admin.req.sync.BasicStatusFilterRequest; import com.glxp.sale.admin.req.sync.OrderStatusFilterRequest; +import com.glxp.sale.admin.req.sync.PostThrOrderRequest; import com.glxp.sale.admin.res.PageSimpleResponse; -import com.glxp.sale.admin.res.sync.DlOrderResponse; +import com.glxp.sale.admin.res.sync.*; import com.glxp.sale.common.res.BaseResponse; import com.glxp.sale.common.util.ResultVOUtils; import org.springframework.beans.factory.annotation.Value; @@ -70,7 +76,6 @@ public class SpGetHttp { public BaseResponse postOrder(String orderId) { OrderStatusFilterRequest orderStatusFilterRequest = new OrderStatusFilterRequest(); orderStatusFilterRequest.setOrderId(orderId); - orderStatusFilterRequest.setStatus(2); String result = UHttpClient.postJson(spmsUrl + "/spms/inout/order/deleteStatus", orderStatusFilterRequest, getHeaders()); BaseResponse response = JSONObject.parseObject(result, new TypeReference>() { @@ -78,4 +83,69 @@ public class SpGetHttp { return response; } + + public BaseResponse> getBasicStatus(String type) { + Map paramMap = new HashMap<>(16); + paramMap.put("type", type); + String response = UHttpClient.mipsGetHead(spmsUrl + "/udiwms/basic/udiinfo/getStatus", paramMap, getHeaders()); + try { + BaseResponse> data = + JSONObject.parseObject(response, new TypeReference>>() { + }); + return data; + + } catch (Exception e) { + e.printStackTrace(); + return ResultVOUtils.error(500, "下载失败!"); + } + } + + + //获取耗材字典 + public String getBasicUdiInfo(List ids) { + BasicDataFilterRequest basicDataFilterRequest = new BasicDataFilterRequest(); + basicDataFilterRequest.setRelIds(ids); + String result = UHttpClient.postJson(spmsUrl + "/udiwms/basic/udiinfo/downloadByStatus", basicDataFilterRequest, getHeaders()); + BaseResponse response = + JSONObject.parseObject(result, new TypeReference>() { + }); + UdiRelevanceExportJsonResponse udiRelevanceExportJsonResponse = response.getData(); + return JSON.toJSON(udiRelevanceExportJsonResponse).toString(); + } + + + //获取往来单位 + public String getBasicCorps(List ids) { + BasicDataFilterRequest basicDataFilterRequest = new BasicDataFilterRequest(); + basicDataFilterRequest.setIds(ids); + String result = UHttpClient.postJson(spmsUrl + "/udiwms/basic/corps/downloadByStatus", basicDataFilterRequest, getHeaders()); + BaseResponse response = + JSONObject.parseObject(result, new TypeReference>() { + }); + return JSON.toJSON(response.getData()).toString(); + } + + + //获取往来单位 + public String getBasicInv(List ids) { + BasicDataFilterRequest basicDataFilterRequest = new BasicDataFilterRequest(); + basicDataFilterRequest.setIds(ids); + String result = UHttpClient.postJson(spmsUrl + "/spms/inv/warehouse/downloadByStatus", basicDataFilterRequest, getHeaders()); + BaseResponse response = + JSONObject.parseObject(result, new TypeReference>() { + }); + return JSON.toJSON(response.getData()).toString(); + } + + public BaseResponse postBasicStatus(String id) { + BasicStatusFilterRequest basicStatusFilterRequest = new BasicStatusFilterRequest(); + basicStatusFilterRequest.setId(id); + basicStatusFilterRequest.setStatus(2); + String result = UHttpClient.postJson(spmsUrl + "/udiwms/basic/udiinfo/deleteByStatus", basicStatusFilterRequest, getHeaders()); + BaseResponse response = + JSONObject.parseObject(result, new TypeReference>() { + }); + return response; + } + } diff --git a/api-admin/src/main/java/com/glxp/sale/admin/http/SpPostHttp.java b/api-admin/src/main/java/com/glxp/sale/admin/http/SpPostHttp.java new file mode 100644 index 0000000..47f9a81 --- /dev/null +++ b/api-admin/src/main/java/com/glxp/sale/admin/http/SpPostHttp.java @@ -0,0 +1,94 @@ +package com.glxp.sale.admin.http; + +import com.alibaba.fastjson.JSONObject; +import com.alibaba.fastjson.TypeReference; +import com.glxp.sale.admin.req.sync.OrderStatusFilterRequest; +import com.glxp.sale.admin.req.sync.PostThrCorpRequest; +import com.glxp.sale.admin.req.sync.PostThrProductsRequest; +import com.glxp.sale.admin.res.sync.*; +import com.glxp.sale.common.res.BaseResponse; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.http.HttpHeaders; +import org.springframework.stereotype.Service; + +@Service +public class SpPostHttp { + + @Value("${SPMS_IP}") + private String spmsUrl; + @Value("${API_KEY}") + private String apiKey; + @Value("${API_SECRET}") + private String apiSecret; + + public HttpHeaders getHeaders() { + HttpHeaders headers = new HttpHeaders(); + headers.add("Content-Type", "application/json"); + headers.add("api_key", apiKey); + headers.add("secret_key", apiSecret); + return headers; + } + + + public BaseResponse postOrder(DlOrderResponse dlOrderResponse) { + String result = UHttpClient.postJson(spmsUrl + "/spms/inout/order/deleteStatus", dlOrderResponse, getHeaders()); + BaseResponse response = + JSONObject.parseObject(result, new TypeReference>() { + }); + return response; + } + + + public BaseResponse postUdiInfo(UdiRelevanceExportJsonResponse udiRelevanceExportJsonResponse) { + String result = UHttpClient.postJson(spmsUrl + "/spssync/basic/udiinfo/upload", udiRelevanceExportJsonResponse, getHeaders()); + BaseResponse response = + JSONObject.parseObject(result, new TypeReference>() { + }); + return response; + } + + + public BaseResponse postCorp(BasicUnitMaintainExportResponse basicUnitMaintainExportResponse) { + String result = UHttpClient.postJson(spmsUrl + "/spssync/basic/corp/upload", basicUnitMaintainExportResponse, getHeaders()); + BaseResponse response = + JSONObject.parseObject(result, new TypeReference>() { + }); + return response; + } + + public BaseResponse postInv(InvWarehouseExportResponse invWarehouseExportResponse) { + String result = UHttpClient.postJson(spmsUrl + "/spssync/basic/inv/upload", invWarehouseExportResponse, getHeaders()); + BaseResponse response = + JSONObject.parseObject(result, new TypeReference>() { + }); + return response; + } + + + public BaseResponse postThirdProducts(PostThrProductsRequest postThrProductsRequest) { + String result = UHttpClient.postJson(spmsUrl + "/spssync/thirdsys/products/upload", postThrProductsRequest, getHeaders()); + BaseResponse response = + JSONObject.parseObject(result, new TypeReference>() { + }); + return response; + } + + public BaseResponse postThirdCorps(PostThrCorpRequest postThrCorpRequest) { + String result = UHttpClient.postJson(spmsUrl + "/spssync/thirdsys/corp/upload", postThrCorpRequest, getHeaders()); + BaseResponse response = + JSONObject.parseObject(result, new TypeReference>() { + }); + return response; + } + + + public BaseResponse postThirdOrders(ThrOrderExportJsonResponse thrOrderExportJsonResponse) { + String result = UHttpClient.postJson(spmsUrl + "/spssync/thirdsys/order/upload", thrOrderExportJsonResponse, getHeaders()); + BaseResponse response = + JSONObject.parseObject(result, new TypeReference>() { + }); + return response; + } + + +} diff --git a/api-admin/src/main/java/com/glxp/sale/admin/req/sync/BasicDataFilterRequest.java b/api-admin/src/main/java/com/glxp/sale/admin/req/sync/BasicDataFilterRequest.java new file mode 100644 index 0000000..8230b4d --- /dev/null +++ b/api-admin/src/main/java/com/glxp/sale/admin/req/sync/BasicDataFilterRequest.java @@ -0,0 +1,13 @@ +package com.glxp.sale.admin.req.sync; + +import lombok.Data; + +import java.util.List; + +@Data +public class BasicDataFilterRequest { + + List relIds; + List ids; + +} diff --git a/api-admin/src/main/java/com/glxp/sale/admin/req/sync/BasicExportStatusRequest.java b/api-admin/src/main/java/com/glxp/sale/admin/req/sync/BasicExportStatusRequest.java new file mode 100644 index 0000000..309ac30 --- /dev/null +++ b/api-admin/src/main/java/com/glxp/sale/admin/req/sync/BasicExportStatusRequest.java @@ -0,0 +1,11 @@ +package com.glxp.sale.admin.req.sync; + +import com.glxp.sale.admin.req.ListPageRequest; +import lombok.Data; + +@Data +public class BasicExportStatusRequest extends ListPageRequest { + private Integer id; + private Integer status; + private Integer type; +} diff --git a/api-admin/src/main/java/com/glxp/sale/admin/req/sync/BasicStatusFilterRequest.java b/api-admin/src/main/java/com/glxp/sale/admin/req/sync/BasicStatusFilterRequest.java new file mode 100644 index 0000000..80108bc --- /dev/null +++ b/api-admin/src/main/java/com/glxp/sale/admin/req/sync/BasicStatusFilterRequest.java @@ -0,0 +1,10 @@ +package com.glxp.sale.admin.req.sync; + +import com.glxp.sale.admin.req.ListPageRequest; +import lombok.Data; + +@Data +public class BasicStatusFilterRequest extends ListPageRequest { + private String id; + private Integer status; +} diff --git a/api-admin/src/main/java/com/glxp/sale/admin/req/sync/PostThrCorpRequest.java b/api-admin/src/main/java/com/glxp/sale/admin/req/sync/PostThrCorpRequest.java new file mode 100644 index 0000000..2218c70 --- /dev/null +++ b/api-admin/src/main/java/com/glxp/sale/admin/req/sync/PostThrCorpRequest.java @@ -0,0 +1,14 @@ +package com.glxp.sale.admin.req.sync; + +import com.glxp.sale.admin.entity.sync.ThrCorpEntity; +import lombok.Data; + +import java.util.List; + +@Data +public class PostThrCorpRequest { + private String genKey; + private String thirdSys; + private String uploadType; + private List datas; +} diff --git a/api-admin/src/main/java/com/glxp/sale/admin/res/sync/BasicUnitMaintainExportResponse.java b/api-admin/src/main/java/com/glxp/sale/admin/res/sync/BasicUnitMaintainExportResponse.java new file mode 100644 index 0000000..6bf4694 --- /dev/null +++ b/api-admin/src/main/java/com/glxp/sale/admin/res/sync/BasicUnitMaintainExportResponse.java @@ -0,0 +1,30 @@ +package com.glxp.sale.admin.res.sync; + +import com.glxp.sale.admin.entity.sync.BasicUnitMaintainEntity; +import com.glxp.sale.admin.entity.sync.ThrCorpEntity; +import lombok.Data; + +import java.util.ArrayList; +import java.util.List; + +/** + * 往来单位信息数据导出 + */ +@Data +public class BasicUnitMaintainExportResponse { + + /** + * 基础往来单位信息 + */ + private List corpList; + + /** + * 第三方往来单位信息 + */ + private List thrCorpEntities; + + public BasicUnitMaintainExportResponse() { + this.corpList = new ArrayList<>(); + this.thrCorpEntities = new ArrayList<>(); + } +} diff --git a/api-admin/src/main/java/com/glxp/sale/admin/res/sync/InvWarehouseExportResponse.java b/api-admin/src/main/java/com/glxp/sale/admin/res/sync/InvWarehouseExportResponse.java new file mode 100644 index 0000000..aad91f9 --- /dev/null +++ b/api-admin/src/main/java/com/glxp/sale/admin/res/sync/InvWarehouseExportResponse.java @@ -0,0 +1,14 @@ +package com.glxp.sale.admin.res.sync; + +import com.glxp.sale.admin.entity.sync.InvWarehouseEntity; +import com.glxp.sale.admin.entity.sync.ThrInvWarehouseEntity; +import lombok.Data; + +import java.util.List; + +@Data +public class InvWarehouseExportResponse { + + List invWarehouseEntities; + List thrInvWarehouseEntities; +} diff --git a/api-admin/src/main/java/com/glxp/sale/admin/res/sync/ThrOrderExportJsonResponse.java b/api-admin/src/main/java/com/glxp/sale/admin/res/sync/ThrOrderExportJsonResponse.java new file mode 100644 index 0000000..d9d521f --- /dev/null +++ b/api-admin/src/main/java/com/glxp/sale/admin/res/sync/ThrOrderExportJsonResponse.java @@ -0,0 +1,16 @@ +package com.glxp.sale.admin.res.sync; + +import com.glxp.sale.admin.entity.sync.ThrOrderDetailEntity; +import com.glxp.sale.admin.entity.sync.ThrOrderEntity; +import lombok.Data; + +import java.util.List; + +@Data +public class ThrOrderExportJsonResponse { + + private List thrOrderEntityList; + + private List thrOrderDetailEntities; + +} diff --git a/api-admin/src/main/java/com/glxp/sale/admin/res/sync/UdiRelevanceExportJsonResponse.java b/api-admin/src/main/java/com/glxp/sale/admin/res/sync/UdiRelevanceExportJsonResponse.java index f6786fa..d6eea40 100644 --- a/api-admin/src/main/java/com/glxp/sale/admin/res/sync/UdiRelevanceExportJsonResponse.java +++ b/api-admin/src/main/java/com/glxp/sale/admin/res/sync/UdiRelevanceExportJsonResponse.java @@ -1,6 +1,7 @@ package com.glxp.sale.admin.res.sync; import com.glxp.sale.admin.entity.info.CompanyProductRelevanceEntity; +import com.glxp.sale.admin.entity.sync.ThrProductsEntity; import com.glxp.sale.admin.entity.sync.UdiInfoEntity; import com.glxp.sale.admin.entity.sync.UdiRelevanceEntity; import lombok.Data; @@ -18,11 +19,15 @@ public class UdiRelevanceExportJsonResponse { List udiRelevanceEntities; - List companyProductRelevanceEntities; + //第三方产品信息 + List thrProductsEntities; public UdiRelevanceExportJsonResponse() { this.udiInfoEntities = new ArrayList<>(); this.udiRelevanceEntities = new ArrayList<>(); this.companyProductRelevanceEntities = new ArrayList<>(); + this.thrProductsEntities = new ArrayList<>(); } + + private List companyProductRelevanceEntities; } diff --git a/api-admin/src/main/java/com/glxp/sale/admin/service/sync/BasicExportService.java b/api-admin/src/main/java/com/glxp/sale/admin/service/sync/BasicExportService.java new file mode 100644 index 0000000..e287f6a --- /dev/null +++ b/api-admin/src/main/java/com/glxp/sale/admin/service/sync/BasicExportService.java @@ -0,0 +1,20 @@ +package com.glxp.sale.admin.service.sync; + + + +import com.glxp.sale.admin.entity.sync.BasicExportStatusEntity; +import com.glxp.sale.admin.req.sync.BasicExportStatusRequest; + +import java.util.List; + +public interface BasicExportService { + + + List filterExportStatus(BasicExportStatusRequest basicExportStatusRequest); + + boolean insertExportStatus(BasicExportStatusEntity ioOrderStatusEntity); + + boolean deleteById(Integer id); + + boolean updateExportStatus(BasicExportStatusEntity warehouseEntity); +} diff --git a/api-admin/src/main/java/com/glxp/sale/admin/service/sync/impl/BasicExportServiceImpl.java b/api-admin/src/main/java/com/glxp/sale/admin/service/sync/impl/BasicExportServiceImpl.java new file mode 100644 index 0000000..7958aba --- /dev/null +++ b/api-admin/src/main/java/com/glxp/sale/admin/service/sync/impl/BasicExportServiceImpl.java @@ -0,0 +1,46 @@ +package com.glxp.sale.admin.service.sync.impl; + +import com.github.pagehelper.PageHelper; +import com.glxp.sale.admin.dao.sync.BasicExportDao; +import com.glxp.sale.admin.entity.sync.BasicExportStatusEntity; +import com.glxp.sale.admin.req.sync.BasicExportStatusRequest; +import com.glxp.sale.admin.service.sync.BasicExportService; +import org.springframework.stereotype.Service; + +import javax.annotation.Resource; +import java.util.Collections; +import java.util.List; + +@Service +public class BasicExportServiceImpl implements BasicExportService { + + @Resource + BasicExportDao basicExportDao; + + @Override + public List filterExportStatus(BasicExportStatusRequest basicExportStatusRequest) { + if (basicExportStatusRequest == null) { + return Collections.emptyList(); + } + if (basicExportStatusRequest.getPage() != null) { + int offset = (basicExportStatusRequest.getPage() - 1) * basicExportStatusRequest.getLimit(); + PageHelper.offsetPage(offset, basicExportStatusRequest.getLimit()); + } + return basicExportDao.filterExportStatus(basicExportStatusRequest); + } + + @Override + public boolean insertExportStatus(BasicExportStatusEntity basicExportStatusEntity) { + return basicExportDao.insertExportStatus(basicExportStatusEntity); + } + + @Override + public boolean deleteById(Integer id) { + return basicExportDao.deleteById(id); + } + + @Override + public boolean updateExportStatus(BasicExportStatusEntity basicExportStatusEntity) { + return basicExportDao.updateExportStatus(basicExportStatusEntity); + } +} diff --git a/api-admin/src/main/java/com/glxp/sale/admin/thread/DlBasicService.java b/api-admin/src/main/java/com/glxp/sale/admin/thread/DlBasicService.java new file mode 100644 index 0000000..beb4556 --- /dev/null +++ b/api-admin/src/main/java/com/glxp/sale/admin/thread/DlBasicService.java @@ -0,0 +1,185 @@ +package com.glxp.sale.admin.thread; + +import cn.hutool.core.util.StrUtil; +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONObject; +import com.glxp.sale.admin.constant.BasicProcessStatus; +import com.glxp.sale.admin.entity.param.SystemParamConfigEntity; +import com.glxp.sale.admin.entity.sync.*; +import com.glxp.sale.admin.http.SpGetHttp; +import com.glxp.sale.admin.res.PageSimpleResponse; +import com.glxp.sale.admin.res.sync.DlOrderResponse; +import com.glxp.sale.admin.res.sync.UdiRelevanceExportJsonResponse; +import com.glxp.sale.admin.service.param.SystemParamConfigService; +import com.glxp.sale.admin.service.sync.*; +import com.glxp.sale.admin.util.CustomUtil; +import com.glxp.sale.admin.util.FileUtils; +import com.glxp.sale.admin.util.RedisUtil; +import com.glxp.sale.common.res.BaseResponse; +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.lang.reflect.Type; +import java.util.ArrayList; +import java.util.Date; +import java.util.List; + +@Service +public class DlBasicService { + + + @Resource + SpGetHttp spGetHttp; + @Resource + SystemParamConfigService systemParamConfigService; + @Value("${file_path_updl_order}") + private String orderFilePath; + @Value("${file_path_updl_udiinfo}") + private String udiFilePath; + @Value("${back_file_path}") + private String backFilePath; + @Resource + private ThrImportLogService thrImportLogService; + @Resource + RedisUtil redisUtil; + @Resource + BasicExportService basicExportService; + + @Async + public void dlBasicUdiInfo() { + SystemParamConfigEntity systemParamConfigEntity = systemParamConfigService.selectByParamKey("sync_upstream_enable"); + BaseResponse> baseResponse = spGetHttp.getBasicStatus(BasicProcessStatus.BASIC_UDI + ""); + List pageSimpleResponse = baseResponse.getData(); + if (pageSimpleResponse != null) { + List basicExportStatusEntities = pageSimpleResponse; + if (basicExportStatusEntities != null && basicExportStatusEntities.size() > 0) { + for (BasicExportStatusEntity basicExportStatusEntity : basicExportStatusEntities) { + if (!StrUtil.isEmpty(basicExportStatusEntity.getIdDatas())) { + if (basicExportStatusEntity.getType() == BasicProcessStatus.BASIC_UDI) { + + List ids = JSON.parseArray(basicExportStatusEntity.getIdDatas(), String.class); + String datas = spGetHttp.getBasicUdiInfo(ids); + String key = basicExportStatusEntity.getId() + ""; + if (systemParamConfigEntity.getParamValue().equals("1")) { + redisUtil.set(key, datas); + BasicExportStatusEntity myEntity = new BasicExportStatusEntity(); + BeanUtils.copyProperties(basicExportStatusEntity, myEntity); + myEntity.setId(key); + basicExportService.insertExportStatus(myEntity); + spGetHttp.postBasicStatus(basicExportStatusEntity.getId()); + } else { + String fileName = udiFilePath + "耗材字典" + key + ".udi"; + String backFileName = backFilePath + "耗材字典" + key + ".udi"; + FileUtils.makeDirectory(udiFilePath); + FileUtils.makeDirectory(backFilePath); + FileUtils.SaveFileAs(datas, fileName); + FileUtils.SaveFileAs(datas, backFileName); + ThrImportLogEntity thrImportLogEntity = new ThrImportLogEntity(); + thrImportLogEntity.setGenKey(CustomUtil.getUUId()); + thrImportLogEntity.setImportType(BasicProcessStatus.IMPORT_LOG_TYPE_UDIINFO); + thrImportLogEntity.setUpdateTime(new Date()); + thrImportLogEntity.setFilePath(fileName); + thrImportLogEntity.setBackFilePath(backFileName); + thrImportLogService.insertImportLog(thrImportLogEntity); + spGetHttp.postBasicStatus(basicExportStatusEntity.getId()); + } + + } + } + } + } + } + } + + + @Async + public void dlBasicCorp() { + SystemParamConfigEntity systemParamConfigEntity = systemParamConfigService.selectByParamKey("sync_upstream_enable"); + BaseResponse> baseResponse = spGetHttp.getBasicStatus(BasicProcessStatus.BASIC_CORP + ""); + List pageSimpleResponse = baseResponse.getData(); + if (pageSimpleResponse != null) { + List basicExportStatusEntities = pageSimpleResponse; + if (basicExportStatusEntities != null && basicExportStatusEntities.size() > 0) { + for (BasicExportStatusEntity basicExportStatusEntity : basicExportStatusEntities) { + if (!StrUtil.isEmpty(basicExportStatusEntity.getIdDatas())) { + List ids = JSON.parseArray(basicExportStatusEntity.getIdDatas(), String.class); + String datas = spGetHttp.getBasicCorps(ids); + String key = basicExportStatusEntity.getId() + ""; + if (systemParamConfigEntity.getParamValue().equals("1")) { + redisUtil.set(key, datas); + BasicExportStatusEntity myEntity = new BasicExportStatusEntity(); + BeanUtils.copyProperties(basicExportStatusEntity, myEntity); + myEntity.setId(key); + basicExportService.insertExportStatus(myEntity); + spGetHttp.postBasicStatus(basicExportStatusEntity.getId()); + } else { + String fileName = udiFilePath + "往来单位" + key + ".udi"; + String backFileName = backFilePath + "往来单位" + key + ".udi"; + FileUtils.makeDirectory(udiFilePath); + FileUtils.makeDirectory(backFilePath); + FileUtils.SaveFileAs(datas, fileName); + FileUtils.SaveFileAs(datas, backFileName); + ThrImportLogEntity thrImportLogEntity = new ThrImportLogEntity(); + thrImportLogEntity.setGenKey(CustomUtil.getUUId()); + thrImportLogEntity.setImportType(BasicProcessStatus.IMPORT_LOG_TYPE_CORP); + thrImportLogEntity.setUpdateTime(new Date()); + thrImportLogEntity.setFilePath(fileName); + thrImportLogEntity.setBackFilePath(backFileName); + thrImportLogService.insertImportLog(thrImportLogEntity); + spGetHttp.postBasicStatus(basicExportStatusEntity.getId()); + } + + } + } + } + } + } + + @Async + public void dlBasicInv() { + SystemParamConfigEntity systemParamConfigEntity = systemParamConfigService.selectByParamKey("sync_upstream_enable"); + BaseResponse> baseResponse = spGetHttp.getBasicStatus(BasicProcessStatus.BASIC_INV + ""); + List pageSimpleResponse = baseResponse.getData(); + if (pageSimpleResponse != null) { + List basicExportStatusEntities = pageSimpleResponse; + if (basicExportStatusEntities != null && basicExportStatusEntities.size() > 0) { + for (BasicExportStatusEntity basicExportStatusEntity : basicExportStatusEntities) { + if (!StrUtil.isEmpty(basicExportStatusEntity.getIdDatas())) { + List ids = JSON.parseArray(basicExportStatusEntity.getIdDatas(), String.class); + String datas = spGetHttp.getBasicInv(ids); + String key = basicExportStatusEntity.getId() + ""; + if (systemParamConfigEntity.getParamValue().equals("1")) { + redisUtil.set(key, datas); + BasicExportStatusEntity myEntity = new BasicExportStatusEntity(); + BeanUtils.copyProperties(basicExportStatusEntity, myEntity); + myEntity.setId(key); + basicExportService.insertExportStatus(myEntity); + spGetHttp.postBasicStatus(basicExportStatusEntity.getId()); + } else { + String fileName = udiFilePath + "仓库字典" + key + ".udi"; + String backFileName = backFilePath + "仓库字典" + key + ".udi"; + FileUtils.makeDirectory(udiFilePath); + FileUtils.makeDirectory(backFilePath); + FileUtils.SaveFileAs(datas, fileName); + FileUtils.SaveFileAs(datas, backFileName); + ThrImportLogEntity thrImportLogEntity = new ThrImportLogEntity(); + thrImportLogEntity.setGenKey(CustomUtil.getUUId()); + thrImportLogEntity.setImportType(BasicProcessStatus.IMPORT_LOG_TYPE_INV); + thrImportLogEntity.setUpdateTime(new Date()); + thrImportLogEntity.setFilePath(fileName); + thrImportLogEntity.setBackFilePath(backFileName); + thrImportLogService.insertImportLog(thrImportLogEntity); + spGetHttp.postBasicStatus(basicExportStatusEntity.getId()); + } + + } + } + } + } + } + + +} diff --git a/api-admin/src/main/java/com/glxp/sale/admin/thread/DlSpOrderService.java b/api-admin/src/main/java/com/glxp/sale/admin/thread/DlSpOrderService.java index f5c22e5..2b5a9a1 100644 --- a/api-admin/src/main/java/com/glxp/sale/admin/thread/DlSpOrderService.java +++ b/api-admin/src/main/java/com/glxp/sale/admin/thread/DlSpOrderService.java @@ -38,7 +38,7 @@ public class DlSpOrderService { SystemParamConfigService systemParamConfigService; @Resource IOOrderStatusService ioOrderStatusService; - @Value("${file_path}") + @Value("${file_path_updl_order}") private String filePath; @Value("${back_file_path}") private String backFilePath; @@ -75,7 +75,10 @@ public class DlSpOrderService { } if (Integer.parseInt(folderConfig.getParamValue()) == 1) { - String fileName = filePath + "/" + "扫码单据" + orderEntity.getId() + ".json"; + + filePath = filePath + "/" + "已完成扫码单据/"; + backFilePath = backFilePath + "/" + "已完成扫码单据/"; + String fileName = filePath + "扫码单据" + orderEntity.getId() + ".json"; String backFileName = backFilePath + "/" + "扫码单据" + orderEntity.getId() + ".json"; List postOrders = new ArrayList<>(); PostOrderRequest postOrderRequest = new PostOrderRequest(); diff --git a/api-admin/src/main/java/com/glxp/sale/admin/thread/DlUploadService.java b/api-admin/src/main/java/com/glxp/sale/admin/thread/DlUploadService.java new file mode 100644 index 0000000..cf94d9e --- /dev/null +++ b/api-admin/src/main/java/com/glxp/sale/admin/thread/DlUploadService.java @@ -0,0 +1,132 @@ +package com.glxp.sale.admin.thread; + +import com.glxp.sale.admin.entity.param.SystemParamConfigEntity; +import com.glxp.sale.admin.service.param.SystemParamConfigService; +import com.glxp.sale.admin.util.RedisUtil; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.stereotype.Service; + +import javax.annotation.Resource; + +@Service +public class DlUploadService { + @Resource + RedisUtil redisUtil; + @Resource + SystemParamConfigService systemParamConfigService; + @Resource + DlSpOrderService dlSpOrderService; + @Resource + DlBasicService dlBasicService; + + final Logger logger = LoggerFactory.getLogger(DlUploadService.class); + + //定时从上游下载数据----下载单据 + public void dlOrder() { + SystemParamConfigEntity systemParamConfigEntity = systemParamConfigService.selectByParamKey("dl_order_status"); + long timeInterval = Long.parseLong(systemParamConfigEntity.getParamValue()) * 60 * 1000; + long curTime = System.currentTimeMillis(); + //任务一,定时下载供应商平台已完成单据 + Long lastTime = (Long) redisUtil.get("DL_ORDER_STATUS"); + if (lastTime == null) { + lastTime = System.currentTimeMillis(); + redisUtil.set("DL_ORDER_STATUS", lastTime); + } + if (curTime - lastTime > timeInterval) { + logger.info("每分钟执行一次单据下载"); + redisUtil.set("DL_ORDER_STATUS", curTime); + dlSpOrderService.dlOrdedrs(); + } + } + + //定时从上游下载数据----下载基础信息 + public void dlBasicUdiInfo() { + SystemParamConfigEntity systemParamConfigEntity = systemParamConfigService.selectByParamKey("dl_basic_udiinfo_status"); + long timeInterval = Long.parseLong(systemParamConfigEntity.getParamValue()) * 60 * 1000; + long curTime = System.currentTimeMillis(); + Long lastTime = (Long) redisUtil.get("DL_BASIC_UDIINFO_STATUS"); + if (lastTime == null) { + lastTime = System.currentTimeMillis(); + redisUtil.set("DL_BASIC_UDIINFO_STATUS", lastTime); + } else if (curTime - lastTime > timeInterval) { + logger.info("每分钟执行一次基础信息下载"); + redisUtil.set("DL_BASIC_UDIINFO_STATUS", curTime); + dlBasicService.dlBasicUdiInfo(); + dlBasicService.dlBasicCorp(); + dlBasicService.dlBasicInv(); + } + } + + + //定时扫描本地共享文件夹---上传到上游 + public void scanFolderUpload() { + SystemParamConfigEntity upConnect = systemParamConfigService.selectByParamKey("sync_upstream_enable"); + if (upConnect.getParamValue().equals("1")) { + SystemParamConfigEntity systemParamConfigEntity = systemParamConfigService.selectByParamKey("dl_basic_udiinfo_status"); + long timeInterval = Long.parseLong(systemParamConfigEntity.getParamValue()) * 60 * 1000; + long curTime = System.currentTimeMillis(); + Long lastTime = (Long) redisUtil.get("DL_BASIC_UDIINFO_STATUS"); + if (lastTime == null) { + redisUtil.set("DL_BASIC_UDIINFO_STATUS", System.currentTimeMillis()); + } else if (curTime - lastTime > timeInterval) { + logger.info("每分钟执行一次基础信息下载"); + redisUtil.set("DL_BASIC_UDIINFO_STATUS", curTime); + dlBasicService.dlBasicUdiInfo(); + dlBasicService.dlBasicCorp(); + dlBasicService.dlBasicInv(); + } + } + } + + //定时扫描本地共享文件夹---上传到上游 + public void scanFolderDown() { + SystemParamConfigEntity upConnect = systemParamConfigService.selectByParamKey("sync_upstream_enable"); + if (upConnect.getParamValue().equals("1")) { + SystemParamConfigEntity systemParamConfigEntity = systemParamConfigService.selectByParamKey("dl_basic_udiinfo_status"); + long timeInterval = Long.parseLong(systemParamConfigEntity.getParamValue()) * 60 * 1000; + long curTime = System.currentTimeMillis(); + Long lastTime = (Long) redisUtil.get("DL_BASIC_UDIINFO_STATUS"); + if (lastTime == null) { + redisUtil.set("DL_BASIC_UDIINFO_STATUS", System.currentTimeMillis()); + } else if (curTime - lastTime > timeInterval) { + logger.info("每分钟执行一次基础信息下载"); + redisUtil.set("DL_BASIC_UDIINFO_STATUS", curTime); + dlBasicService.dlBasicUdiInfo(); + dlBasicService.dlBasicCorp(); + dlBasicService.dlBasicInv(); + } + } + } + + public void dlBasicCorp() { + SystemParamConfigEntity systemParamConfigEntity = systemParamConfigService.selectByParamKey("dl_basic_corp_status"); + long timeInterval = Long.parseLong(systemParamConfigEntity.getParamValue()) * 60 * 1000; + long curTime = System.currentTimeMillis(); + //任务一,定时下载供应商平台已完成单据 + Long lastTime = (Long) redisUtil.get("DL_BASIC_CORP_STATUS"); + if (lastTime == null) { + redisUtil.set("DL_BASIC_CORP_STATUS", System.currentTimeMillis()); + } else if (curTime - lastTime > timeInterval) { + logger.info("每分钟执行一次单据下载"); + redisUtil.set("DL_BASIC_CORP_STATUS", curTime); + dlBasicService.dlBasicCorp(); + } + } + + public void dlBasicInv() { + SystemParamConfigEntity systemParamConfigEntity = systemParamConfigService.selectByParamKey("dl_basic_inv_status"); + long timeInterval = Long.parseLong(systemParamConfigEntity.getParamValue()) * 60 * 1000; + long curTime = System.currentTimeMillis(); + //任务一,定时下载供应商平台已完成单据 + Long lastTime = (Long) redisUtil.get("DL_BASIC_INV_STATUS"); + if (lastTime == null) { + redisUtil.set("DL_BASIC_INV_STATUS", System.currentTimeMillis()); + } else if (curTime - lastTime > timeInterval) { + logger.info("每分钟执行一次单据下载"); + redisUtil.set("DL_BASIC_INV_STATUS", curTime); + dlBasicService.dlBasicInv(); + } + } + +} diff --git a/api-admin/src/main/java/com/glxp/sale/admin/thread/HeartTask.java b/api-admin/src/main/java/com/glxp/sale/admin/thread/HeartTask.java index 795e9b4..1a8604e 100644 --- a/api-admin/src/main/java/com/glxp/sale/admin/thread/HeartTask.java +++ b/api-admin/src/main/java/com/glxp/sale/admin/thread/HeartTask.java @@ -28,11 +28,15 @@ public class HeartTask implements SchedulingConfigurer { @Resource protected ScheduledDao scheduledDao; @Resource + SystemParamConfigService systemParamConfigService; + @Resource + DlUploadService dlUploadService; + @Resource RedisUtil redisUtil; @Resource - SystemParamConfigService systemParamConfigService; + ScanUploadService scanUploadService; @Resource - DlSpOrderService dlSpOrderService; + ScanDownloadService scanDownloadService; @Override public void configureTasks(ScheduledTaskRegistrar scheduledTaskRegistrar) { @@ -52,21 +56,83 @@ public class HeartTask implements SchedulingConfigurer { private void process() { + dlData(); + } + + //定时从上游下载数据 + private void dlData() { + SystemParamConfigEntity upConnect = systemParamConfigService.selectByParamKey("sync_upstream_enable"); + if (upConnect.getParamValue().equals("1")) { + dlUploadService.dlOrder(); + dlUploadService.dlBasicUdiInfo(); + } + scanUpload(); + scanDonwload(); + } - SystemParamConfigEntity systemParamConfigEntity = systemParamConfigService.selectByParamKey("dl_order_status"); - long timeInterval = Long.parseLong(systemParamConfigEntity.getParamValue()) * 60 * 1000; - long curTime = System.currentTimeMillis(); - //任务一,定时下载供应商平台已完成单据 - Long lastTime = (Long) redisUtil.get("DL_ORDER_STATUS"); - if (lastTime == null) { - redisUtil.set("DL_ORDER_STATUS", System.currentTimeMillis()); + private void scanUpload() { + SystemParamConfigEntity upConnect = systemParamConfigService.selectByParamKey("sync_upstream_enable"); + if (upConnect.getParamValue().equals("1")) { + SystemParamConfigEntity systemParamConfigEntity = systemParamConfigService.selectByParamKey("sc_udiinfo_upload"); + long timeInterval = Long.parseLong(systemParamConfigEntity.getParamValue()) * 60 * 1000; + long curTime = System.currentTimeMillis(); + //任务一,定时下载供应商平台已完成单据 + Long lastTime = (Long) redisUtil.get("UPLOAD_UDIINFO_STATUS"); + if (lastTime == null) { + lastTime = System.currentTimeMillis(); + redisUtil.set("UPLOAD_UDIINFO_STATUS", lastTime); + } + if (curTime - lastTime > timeInterval) { + redisUtil.set("UPLOAD_UDIINFO_STATUS", curTime); + scanUploadService.scanCorp(); + scanUploadService.scanUdi(); + scanUploadService.scanInv(); + scanUploadService.scanThirdProducts(); + scanUploadService.scanThirdCorp(); + scanUploadService.scanThirdOrder(); + + } } - if (curTime - lastTime > timeInterval) { - logger.info("每分钟执行一次单据下载"); - redisUtil.set("DL_ORDER_STATUS", curTime); - dlSpOrderService.dlOrdedrs(); + } + + + private void scanDonwload() { + SystemParamConfigEntity upConnect = systemParamConfigService.selectByParamKey("sync_downstream_enable"); + if (upConnect.getParamValue().equals("1")) { + SystemParamConfigEntity systemParamConfigEntity = systemParamConfigService.selectByParamKey("sc_order_status"); + long timeInterval = Long.parseLong(systemParamConfigEntity.getParamValue()) * 60 * 1000; + long curTime = System.currentTimeMillis(); + //任务一,定时下载供应商平台已完成单据 + Long lastTime = (Long) redisUtil.get("SC_ORDER_DOWNLOAD_STATUS"); + if (lastTime == null) { + lastTime = System.currentTimeMillis(); + redisUtil.set("SC_ORDER_DOWNLOAD_STATUS", lastTime); + } + if (curTime - lastTime > timeInterval) { + redisUtil.set("SC_ORDER_DOWNLOAD_STATUS", curTime); + scanDownloadService.scanOrder(); + } } + if (upConnect.getParamValue().equals("1")) { + SystemParamConfigEntity systemParamConfigEntity = systemParamConfigService.selectByParamKey("sc_udiinfo_status"); + long timeInterval = Long.parseLong(systemParamConfigEntity.getParamValue()) * 60 * 1000; + long curTime = System.currentTimeMillis(); + Long lastTime = (Long) redisUtil.get("SC_UDIINFO_DOWNLOAD_STATUS"); + if (lastTime == null) { + lastTime = System.currentTimeMillis(); + redisUtil.set("SC_UDIINFO_DOWNLOAD_STATUS", lastTime); + } + if (curTime - lastTime > timeInterval) { + redisUtil.set("SC_UDIINFO_DOWNLOAD_STATUS", curTime); + scanDownloadService.scanUdi(); + scanDownloadService.scanCorp(); + scanDownloadService.scanInv(); + + + } + } } + } diff --git a/api-admin/src/main/java/com/glxp/sale/admin/thread/ScanDownloadService.java b/api-admin/src/main/java/com/glxp/sale/admin/thread/ScanDownloadService.java new file mode 100644 index 0000000..35696d9 --- /dev/null +++ b/api-admin/src/main/java/com/glxp/sale/admin/thread/ScanDownloadService.java @@ -0,0 +1,121 @@ +package com.glxp.sale.admin.thread; + +import com.glxp.sale.admin.constant.BasicProcessStatus; +import com.glxp.sale.admin.entity.sync.BasicExportStatusEntity; +import com.glxp.sale.admin.entity.sync.IOOrderStatusEntity; +import com.glxp.sale.admin.entity.sync.WarehouseEntity; +import com.glxp.sale.admin.service.sync.BasicExportService; +import com.glxp.sale.admin.service.sync.IOOrderStatusService; +import com.glxp.sale.admin.util.FileFilterImpl; +import com.glxp.sale.admin.util.FileUtils; +import com.glxp.sale.admin.util.RedisUtil; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.scheduling.annotation.Async; +import org.springframework.stereotype.Service; + +import javax.annotation.Resource; +import java.io.File; +import java.util.Date; +import java.util.List; + +/** + * 扫面文件路径,形成状态表等待udi管理系统下载 + */ + +@Service +public class ScanDownloadService { + + + @Value("${file_path_wdl_order}") + private String orderFilePath; + @Value("${file_path_wdl_udiinfo}") + private String udiFilePath; + + @Resource + IOOrderStatusService ioOrderStatusService; + @Resource + RedisUtil redisUtil; + @Resource + BasicExportService basicExportService; + + + public void scanOrder() { + File[] files = FileUtils.listAll(new File(orderFilePath), new FileFilterImpl()); + if (files != null && files.length > 0) { + for (int i = 0; i < files.length; i++) { + File file = files[i]; + String data = FileUtils.readFileAll(file.getPath()); + IOOrderStatusEntity orderStatusEntity = new IOOrderStatusEntity(); + orderStatusEntity.setOrderId(file.getName()); + orderStatusEntity.setUpdateTime(new Date()); + orderStatusEntity.setStatus(1); + ioOrderStatusService.insertOrderStatus(orderStatusEntity); + redisUtil.set(file.getName(), data); + + } + } + } + + public void scanUdi() { + File[] files = FileUtils.listAll(new File(udiFilePath), new FileFilterImpl()); + if (files != null && files.length > 0) { + for (int i = 0; i < files.length; i++) { + File file = files[i]; + if (file.getName().contains("耗材字典")) { + String data = FileUtils.readFileAll(file.getPath()); + BasicExportStatusEntity basicExportStatusEntity = new BasicExportStatusEntity(); + basicExportStatusEntity.setId(file.getName()); + basicExportStatusEntity.setUpdateTime(new Date()); + basicExportStatusEntity.setStatus(1); + basicExportStatusEntity.setIdDatas(file.getPath()); + basicExportStatusEntity.setType(BasicProcessStatus.BASIC_UDI); + basicExportService.insertExportStatus(basicExportStatusEntity); + redisUtil.set(file.getName(), data); + } + + } + } + } + + public void scanCorp() { + File[] files = FileUtils.listAll(new File(udiFilePath), new FileFilterImpl()); + if (files != null && files.length > 0) { + for (int i = 0; i < files.length; i++) { + File file = files[i]; + if (file.getName().contains("往来单位")) { + String data = FileUtils.readFileAll(file.getPath()); + BasicExportStatusEntity basicExportStatusEntity = new BasicExportStatusEntity(); + basicExportStatusEntity.setId(file.getName()); + basicExportStatusEntity.setUpdateTime(new Date()); + basicExportStatusEntity.setStatus(1); + basicExportStatusEntity.setIdDatas(file.getPath()); + basicExportStatusEntity.setType(BasicProcessStatus.BASIC_CORP); + basicExportService.insertExportStatus(basicExportStatusEntity); + redisUtil.set(file.getName(), data); + } + } + } + } + + public void scanInv() { + File[] files = FileUtils.listAll(new File(udiFilePath), new FileFilterImpl()); + if (files != null && files.length > 0) { + for (int i = 0; i < files.length; i++) { + File file = files[i]; + if (file.getName().contains("仓库字典")) { + String data = FileUtils.readFileAll(file.getPath()); + BasicExportStatusEntity basicExportStatusEntity = new BasicExportStatusEntity(); + basicExportStatusEntity.setId(file.getName()); + basicExportStatusEntity.setUpdateTime(new Date()); + basicExportStatusEntity.setStatus(1); + basicExportStatusEntity.setIdDatas(file.getPath()); + basicExportStatusEntity.setType(BasicProcessStatus.BASIC_INV); + basicExportService.insertExportStatus(basicExportStatusEntity); + redisUtil.set(file.getName(), data); + } + } + } + } + + +} diff --git a/api-admin/src/main/java/com/glxp/sale/admin/thread/ScanUploadService.java b/api-admin/src/main/java/com/glxp/sale/admin/thread/ScanUploadService.java new file mode 100644 index 0000000..a233af8 --- /dev/null +++ b/api-admin/src/main/java/com/glxp/sale/admin/thread/ScanUploadService.java @@ -0,0 +1,190 @@ +package com.glxp.sale.admin.thread; + +import com.alibaba.fastjson.JSON; +import com.glxp.sale.admin.constant.BasicProcessStatus; +import com.glxp.sale.admin.entity.sync.BasicExportStatusEntity; +import com.glxp.sale.admin.entity.sync.IOOrderStatusEntity; +import com.glxp.sale.admin.http.SpGetHttp; +import com.glxp.sale.admin.http.SpPostHttp; +import com.glxp.sale.admin.req.sync.PostThrCorpRequest; +import com.glxp.sale.admin.req.sync.PostThrProductsRequest; +import com.glxp.sale.admin.res.sync.*; +import com.glxp.sale.admin.service.sync.BasicExportService; +import com.glxp.sale.admin.service.sync.IOOrderStatusService; +import com.glxp.sale.admin.util.FileFilterImpl; +import com.glxp.sale.admin.util.FileUtils; +import com.glxp.sale.admin.util.RedisUtil; +import com.glxp.sale.common.res.BaseResponse; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.scheduling.annotation.Async; +import org.springframework.stereotype.Service; + +import javax.annotation.Resource; +import java.io.File; +import java.util.Date; + +/** + * 扫描文件夹,上传到UDI自助平台 + */ + +@Service +public class ScanUploadService { + + @Value("${file_path_wup_order}") + private String orderFilePath; + @Value("${file_path_wup_udiinfo}") + private String udiFilePath; + @Resource + SpPostHttp spPostHttp; + @Value("${back_file_path}") + private String backFilePath; + + public void scanOrder() { + File[] files = FileUtils.listAll(new File(orderFilePath), new FileFilterImpl()); + if (files != null && files.length > 0) { + for (int i = 0; i < files.length; i++) { + File file = files[i]; + String data = FileUtils.readFileAll(file.getPath()); + DlOrderResponse dlOrderResponse = JSON.parseObject(data, DlOrderResponse.class); + BaseResponse baseResponse = spPostHttp.postOrder(dlOrderResponse); + if (baseResponse.getCode() == 20000) {//上传成功 + try { + FileUtils.CutFile(file.getPath(), backFilePath + "/已上传单据/"+ file.getName()); + } catch (Exception e) { + e.printStackTrace(); + } + } + + } + } + } + + public void scanUdi() { + File[] files = FileUtils.listAll(new File(udiFilePath), new FileFilterImpl()); + if (files != null && files.length > 0) { + for (int i = 0; i < files.length; i++) { + File file = files[i]; + if (file.getName().contains("耗材字典")) { + String data = FileUtils.readFileAll(file.getPath()); + UdiRelevanceExportJsonResponse udiRelevanceExportJsonResponse = JSON.parseObject(data, UdiRelevanceExportJsonResponse.class); + BaseResponse baseResponse = spPostHttp.postUdiInfo(udiRelevanceExportJsonResponse); + if (baseResponse.getCode() == 20000) {//上传成功 + try { + FileUtils.CutFile(file.getPath(), backFilePath + "/已上传基础信息/"+ file.getName()); + } catch (Exception e) { + e.printStackTrace(); + } + } + } + + } + } + } + + public void scanCorp() { + File[] files = FileUtils.listAll(new File(udiFilePath), new FileFilterImpl()); + if (files != null && files.length > 0) { + for (int i = 0; i < files.length; i++) { + File file = files[i]; + if (file.getName().contains("往来单位")) { + String data = FileUtils.readFileAll(file.getPath()); + BasicUnitMaintainExportResponse basicUnitMaintainExportResponse = JSON.parseObject(data, BasicUnitMaintainExportResponse.class); + BaseResponse baseResponse = spPostHttp.postCorp(basicUnitMaintainExportResponse); + if (baseResponse.getCode() == 20000) {//上传成功 + try { + FileUtils.CutFile(file.getPath(), backFilePath + "/已上传基础信息/"+ file.getName()); + } catch (Exception e) { + e.printStackTrace(); + } + } + } + } + } + } + + public void scanInv() { + File[] files = FileUtils.listAll(new File(udiFilePath), new FileFilterImpl()); + if (files != null && files.length > 0) { + for (int i = 0; i < files.length; i++) { + File file = files[i]; + if (file.getName().contains("仓库字典")) { + String data = FileUtils.readFileAll(file.getPath()); + InvWarehouseExportResponse invWarehouseExportResponse = JSON.parseObject(data, InvWarehouseExportResponse.class); + BaseResponse baseResponse = spPostHttp.postInv(invWarehouseExportResponse); + if (baseResponse.getCode() == 20000) {//上传成功 + try { + FileUtils.CutFile(file.getPath(), backFilePath + "/已上传基础信息/"+ file.getName()); + } catch (Exception e) { + e.printStackTrace(); + } + } + } + } + } + } + + public void scanThirdProducts() { + File[] files = FileUtils.listAll(new File(udiFilePath), new FileFilterImpl()); + if (files != null && files.length > 0) { + for (int i = 0; i < files.length; i++) { + File file = files[i]; + if (file.getName().contains("第三方产品信息")) { + String data = FileUtils.readFileAll(file.getPath()); + PostThrProductsRequest postThrProductsRequest = JSON.parseObject(data, PostThrProductsRequest.class); + BaseResponse baseResponse = spPostHttp.postThirdProducts(postThrProductsRequest); + if (baseResponse.getCode() == 20000) {//上传成功 + try { + FileUtils.CutFile(file.getPath(), backFilePath + "/已上传基础信息/"+ file.getName()); + } catch (Exception e) { + e.printStackTrace(); + } + } + } + } + } + } + + + public void scanThirdCorp() { + File[] files = FileUtils.listAll(new File(udiFilePath), new FileFilterImpl()); + if (files != null && files.length > 0) { + for (int i = 0; i < files.length; i++) { + File file = files[i]; + if (file.getName().contains("第三方往来单位")) { + String data = FileUtils.readFileAll(file.getPath()); + PostThrCorpRequest postThrCorpRequest = JSON.parseObject(data, PostThrCorpRequest.class); + BaseResponse baseResponse = spPostHttp.postThirdCorps(postThrCorpRequest); + if (baseResponse.getCode() == 20000) {//上传成功 + try { + FileUtils.CutFile(file.getPath(), backFilePath + "/已上传基础信息/"+ file.getName()); + } catch (Exception e) { + e.printStackTrace(); + } + } + } + } + } + } + + public void scanThirdOrder() { + File[] files = FileUtils.listAll(new File(udiFilePath), new FileFilterImpl()); + if (files != null && files.length > 0) { + for (int i = 0; i < files.length; i++) { + File file = files[i]; + if (file.getName().contains("第三方业务单据")) { + String data = FileUtils.readFileAll(file.getPath()); + ThrOrderExportJsonResponse thrOrderExportJsonResponse = JSON.parseObject(data, ThrOrderExportJsonResponse.class); + BaseResponse baseResponse = spPostHttp.postThirdOrders(thrOrderExportJsonResponse); + if (baseResponse.getCode() == 20000) {//上传成功 + try { + FileUtils.CutFile(file.getPath(), backFilePath + "/已上传基础信息/" + file.getName()); + } catch (Exception e) { + e.printStackTrace(); + } + } + } + } + } + } + +} diff --git a/api-admin/src/main/java/com/glxp/sale/admin/util/FileFilterImpl.java b/api-admin/src/main/java/com/glxp/sale/admin/util/FileFilterImpl.java new file mode 100644 index 0000000..f5bf3b5 --- /dev/null +++ b/api-admin/src/main/java/com/glxp/sale/admin/util/FileFilterImpl.java @@ -0,0 +1,13 @@ +package com.glxp.sale.admin.util; + + +import java.io.File; +import java.io.FileFilter; + +//自定义文件过滤器 +public class FileFilterImpl implements FileFilter { + @Override + public boolean accept(File pathname) { + return true; + } +} diff --git a/api-admin/src/main/java/com/glxp/sale/admin/util/FileUtils.java b/api-admin/src/main/java/com/glxp/sale/admin/util/FileUtils.java index fecfb33..13fa69b 100644 --- a/api-admin/src/main/java/com/glxp/sale/admin/util/FileUtils.java +++ b/api-admin/src/main/java/com/glxp/sale/admin/util/FileUtils.java @@ -184,7 +184,6 @@ public class FileUtils { } - /** * 清空指定目录中的文件。 * 这个方法将尽可能删除所有的文件,但是只要有一个文件没有被删除都会返回false。 @@ -273,7 +272,7 @@ public class FileUtils { * @since 1.0 */ public static File[] listAll(File file, - javax.swing.filechooser.FileFilter filter) { + FileFilter filter) { ArrayList list = new ArrayList(); File[] files; if (!file.exists() || file.isFile()) { @@ -293,7 +292,7 @@ public class FileUtils { * @param file 目录 */ private static void list(ArrayList list, File file, - javax.swing.filechooser.FileFilter filter) { + FileFilter filter) { if (filter.accept(file)) { list.add(file); if (file.isFile()) { @@ -718,6 +717,9 @@ public class FileUtils { try { File in = new File(infile); File out = new File(outfile); + if (!out.exists()) { + out.createNewFile(); + } return CopyFile(in, out); } catch (IOException ie) { ie.printStackTrace(); @@ -726,6 +728,14 @@ public class FileUtils { } + + public static final boolean CutFile(String infile, String outfile) throws Exception { + if (CopyFile(infile, outfile)) { + return new File(infile).delete(); + } + return false; + } + /** * 把内容content写的path文件中 * diff --git a/api-admin/src/main/resources/application-pro.properties b/api-admin/src/main/resources/application-pro.properties index 9c17893..bb4688c 100644 --- a/api-admin/src/main/resources/application-pro.properties +++ b/api-admin/src/main/resources/application-pro.properties @@ -23,10 +23,50 @@ server.connectionTimeout=180000 # \u8F93\u51FA\u65E5\u5FD7\u5230\u9879\u76EE\u6839\u76EE\u5F55\u4E0B\u7684springboot.log\u6587\u4EF6\u4E2D // \u914D\u7F6E logback-spring.xml\u65F6 \u6B64\u65E5\u5FD7\u8F93\u51FA\u65B9\u5F0F\u4F1A\u88AB\u8986\u76D6\u3002 logging.file=D:/1s/udiwms/udiwms.log #logging.file=/www/glxpdata/spsyc/ -file_path=D:/1s/udiwms/sp/order/sync +file_path=D:/share/udisps/ #file_path=/share/order/sync -back_file_path=D:/1s/udiwms/sp/order/sync/sync_back +back_file_path=D:/share/udisps/back/ #back_file_path=/share/order/sync_back +#----------------------------------上游下载文件路径-start----------------- +#上游下载单据文件路径 +file_path_updl_order=D:/share/udisps/updownload/order/ +#上游下载耗材字典文件路径 +file_path_updl_udiinfo=D:/share/udisps/updownload/udiinfo/ +#上游下载往来单位文件路径 +file_path_updl_corp=D:/share/udisps/updownload/corp/ +#上游下载仓库字典文件路径 +file_path_updl_inv=D:/share/udisps/updownload/inv/ +#----------------------------------上游下载文件路径-end--------------------- +#----------------------------------手动拷贝等待下载文件路径-start----------------- +#上游下载单据文件路径 +file_path_wdl_order=D:/share/udisps/waitdownload/order/ +#上游下载耗材字典文件路径 +file_path_wdl_udiinfo=D:/share/udisps/waitdownload/udiinfo/ +#上游下载往来单位文件路径 +file_path_wdl_corp=D:/share/udisps/waitdownload/corp/ +#上游下载仓库字典文件路径 +file_path_wdl_inv=D:/share/udisps/waitdownload/inv/ +#----------------------------------手动拷贝等待下载文件路径-end----------------- +#----------------------------------手动拷贝等待上传文件路径-start----------------- +#上游下载单据文件路径 +file_path_wup_order=D:/share/udisps/waitupload/order/ +#上游下载耗材字典文件路径 +file_path_wup_udiinfo=D:/share/udisps/waitupload/udiinfo/ +#上游下载往来单位文件路径 +file_path_wup_corp=D:/share/udisps/waitupload/corp/ +#上游下载仓库字典文件路径 +file_path_wup_inv=D:/share/udisps/waitupload/inv/ +#----------------------------------手动拷贝等待上传文件路径-end----------------- +#----------------------------------下游上传文件路径-start----------------- +#上游下载单据文件路径 +file_path_dup_order=D:/share/udisps/downupload/order/ +#上游下载耗材字典文件路径 +file_path_dupp_udiinfo=D:/share/udisps/downupload/udiinfo/ +#上游下载往来单位文件路径 +file_path_dup_corp=D:/share/udisps/downupload/corp/ +#上游下载仓库字典文件路径 +file_path_dup_inv=D:/share/udisps/downupload/inv/ +#----------------------------------下游上传文件路径-end----------------- #UDI\u6570\u636E\u4E0B\u8F7D UDI_SERVER_URL=https://www.udims.com/UDI_DL_Server #UCLOD\u670D\u52A1 diff --git a/api-admin/src/main/resources/mybatis/mapper/sync/BasicExportDao.xml b/api-admin/src/main/resources/mybatis/mapper/sync/BasicExportDao.xml new file mode 100644 index 0000000..7dc49c6 --- /dev/null +++ b/api-admin/src/main/resources/mybatis/mapper/sync/BasicExportDao.xml @@ -0,0 +1,52 @@ + + + + + + + + + + replace + INTO basic_export_status(id,idDatas,status,type,updateTime) + values( + #{id}, + #{idDatas}, + #{status}, + #{type}, + #{updateTime} + ) + + + + UPDATE basic_export_status + + idDatas=#{idDatas}, + status=#{status}, + type=#{type}, + updateTime=#{updateTime}, + + WHERE orderId = #{orderId} + + + DELETE + FROM basic_export_status + WHERE id = #{id} + + + \ No newline at end of file