From 160ed1f1b85267ba36e333bceb08021f99bb834a Mon Sep 17 00:00:00 2001 From: anthonyywj2 <353682448@qq.com> Date: Thu, 31 Mar 2022 10:52:00 +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=BD2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../sale/admin/constant/FileConstant.java | 41 ++++ .../param/SystemParamConfigController.java | 70 +++++- .../sync/BasicDowmloadController.java | 2 +- .../sync/BasicExportUploadController.java | 67 +++--- .../sale/admin/dao/sync/BasicExportDao.java | 2 +- .../req/sync/BasicExportStatusRequest.java | 2 +- .../service/sync/BasicExportService.java | 2 +- .../sync/impl/BasicExportServiceImpl.java | 2 +- .../sale/admin/thread/DlBasicService.java | 210 ++++++++++-------- .../sale/admin/thread/DlSpOrderService.java | 127 ++++++----- .../admin/thread/ScanDownloadService.java | 100 +++++++-- .../sale/admin/thread/ScanUploadService.java | 47 ++-- .../com/glxp/sale/admin/util/FileUtils.java | 20 ++ 13 files changed, 462 insertions(+), 230 deletions(-) create mode 100644 api-admin/src/main/java/com/glxp/sale/admin/constant/FileConstant.java diff --git a/api-admin/src/main/java/com/glxp/sale/admin/constant/FileConstant.java b/api-admin/src/main/java/com/glxp/sale/admin/constant/FileConstant.java new file mode 100644 index 0000000..4612eab --- /dev/null +++ b/api-admin/src/main/java/com/glxp/sale/admin/constant/FileConstant.java @@ -0,0 +1,41 @@ +package com.glxp.sale.admin.constant; + +public class FileConstant { + + + //上游通,等待拷贝 + public static String upWaitCopy_order = "/UpperOut/Order/"; + public static String upWaitCopy_order_back = "/UpperOut/Order/Completed/"; + public static String upWaitCopy_order_error = "/UpperOut/Order/Error/"; + public static String upWaitCopy_products = "/UpperOut/Dictionaries/"; + public static String upWaitCopy_products_back = "/UpperOut/Dictionaries/Completed/"; + public static String upWaitCopy_products_error = "/UpperOut/Dictionaries/Error/"; + + //上游通,等待上传 + public static String waitUpload_order = "/UpperIn/Order/"; + public static String waitUpload_order_back = "/UpperIn/Order/Completed"; + public static String waitUpload_order_error = "/UpperIn/Order/Error/"; + public static String waitUpload_products = "/UpperIn/Dictionaries/"; + public static String waitUpload_products_back = "/UpperIn/Dictionaries/Completed/"; + public static String waitUpload_products_error = "/UpperIn/Dictionaries/Error/"; + + + //下游通,下游上传后,等待拷贝 + public static String lowerWaitCopy_order = "/LowerOut/Order/"; + public static String lowerWaitCopy_order_back = "/LowerOut/Order/Completed/"; + public static String lowerWaitCopy_order_error = "/LowerOut/Order/Error/"; + public static String lowerWaitCopy_products = "/LowerOut/Dictionaries/"; + public static String lowerWaitCopy_products_back = "/LowerOut/Dictionaries/Completed/"; + public static String lowerWaitCopy_products_error = "/LowerOut/Dictionaries/Error/"; + + + //下游通,等待下载 + public static String waitDownload_order = "/LowerIn/Order/"; + public static String waitDownload_order_back = "/LowerIn/Order/Completed/"; + public static String waitDownload_order_error = "/LowerIn/Order/Error/"; + public static String waitDownload_products = "/LowerIn/Dictionaries/"; + public static String waitDownload_products_back = "/LowerIn/Dictionaries/Completed/"; + public static String waitDownload_products_error = "/LowerIn/Dictionaries/Error/"; + + +} diff --git a/api-admin/src/main/java/com/glxp/sale/admin/controller/param/SystemParamConfigController.java b/api-admin/src/main/java/com/glxp/sale/admin/controller/param/SystemParamConfigController.java index 58ca810..b920ce9 100644 --- a/api-admin/src/main/java/com/glxp/sale/admin/controller/param/SystemParamConfigController.java +++ b/api-admin/src/main/java/com/glxp/sale/admin/controller/param/SystemParamConfigController.java @@ -2,12 +2,14 @@ package com.glxp.sale.admin.controller.param; import com.github.pagehelper.PageInfo; import com.glxp.sale.admin.annotation.AuthRuleAnnotation; +import com.glxp.sale.admin.constant.FileConstant; import com.glxp.sale.admin.entity.param.SystemParamConfigEntity; import com.glxp.sale.admin.req.param.SystemParamConfigRequest; import com.glxp.sale.admin.req.param.SystemParamConfigSaveRequest; import com.glxp.sale.admin.res.PageSimpleResponse; import com.glxp.sale.admin.res.param.SystemParamConfigResponse; import com.glxp.sale.admin.service.param.SystemParamConfigService; +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; @@ -20,6 +22,7 @@ import org.springframework.web.bind.annotation.RestController; import javax.annotation.Resource; import javax.validation.Valid; +import java.io.File; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -34,7 +37,7 @@ public class SystemParamConfigController { @AuthRuleAnnotation("system/param/config/list") @GetMapping("/system/param/config/list") public BaseResponse list(@Valid SystemParamConfigRequest systemParamConfigRequest, - BindingResult bindingResult) { + BindingResult bindingResult) { if (bindingResult.hasErrors()) { return ResultVOUtils.error(ResultEnum.PARAM_VERIFY_FALL, bindingResult.getFieldError().getDefaultMessage()); @@ -79,6 +82,71 @@ public class SystemParamConfigController { @PostMapping("/system/param/config/update") public BaseResponse update(@RequestBody SystemParamConfigSaveRequest systemParamConfigSaveRequest) { // systemParamConfigSaveRequest.setId(1); + if (systemParamConfigSaveRequest.getParamKey().equals("share_folder")) { + try { + if (new File(systemParamConfigSaveRequest.getParamValue()).exists()) { + return ResultVOUtils.error(500, "文件目录已存在"); + } + if (!FileUtils.makeDirectory(new File(systemParamConfigSaveRequest.getParamValue()))) { + return ResultVOUtils.error(500, "文件目录创建失败"); + } + } catch (Exception e) { + e.printStackTrace(); + return ResultVOUtils.error(500, e.getMessage()); + } + } else if (systemParamConfigSaveRequest.getParamKey().equals("sync_upstream_enable")) { + + + //下游如果联通 + if (systemParamConfigSaveRequest.getParamValue().equals("0")) { + SystemParamConfigEntity systemParamConfigEntity = systemParamConfigService.selectByParamKey("share_folder"); + String filePath = systemParamConfigEntity.getParamValue(); + if (!new File(filePath).exists()) { + return ResultVOUtils.error(500, "文件根目录不存在!"); + } + + boolean b1 = FileUtils.makeDirectory(new File(filePath + FileConstant.lowerWaitCopy_order)); + boolean b2 = FileUtils.makeDirectory(new File(filePath + FileConstant.lowerWaitCopy_order_back)); + boolean b3 = FileUtils.makeDirectory(new File(filePath + FileConstant.lowerWaitCopy_order_error)); + boolean b4 = FileUtils.makeDirectory(new File(filePath + FileConstant.lowerWaitCopy_products)); + boolean b5 = FileUtils.makeDirectory(new File(filePath + FileConstant.lowerWaitCopy_products_back)); + boolean b6 = FileUtils.makeDirectory(new File(filePath + FileConstant.lowerWaitCopy_products_error)); + + boolean b7 = FileUtils.makeDirectory(new File(filePath + FileConstant.waitDownload_order)); + boolean b8 = FileUtils.makeDirectory(new File(filePath + FileConstant.waitDownload_order_back)); + boolean b9 = FileUtils.makeDirectory(new File(filePath + FileConstant.waitDownload_order_error)); + boolean b10 = FileUtils.makeDirectory(new File(filePath + FileConstant.waitDownload_products)); + boolean b11 = FileUtils.makeDirectory(new File(filePath + FileConstant.waitDownload_products_back)); + boolean b12 = FileUtils.makeDirectory(new File(filePath + FileConstant.waitDownload_products_error)); + + } + + } else if (systemParamConfigSaveRequest.getParamKey().equals("sync_downstream_enable")) { + //上游如果联通 + if (systemParamConfigSaveRequest.getParamValue().equals("0")) { + SystemParamConfigEntity systemParamConfigEntity = systemParamConfigService.selectByParamKey("share_folder"); + String filePath = systemParamConfigEntity.getParamValue(); + if (!new File(filePath).exists()) { + return ResultVOUtils.error(500, "文件根目录不存在!"); + } + boolean b1 = FileUtils.makeDirectory(new File(filePath + FileConstant.upWaitCopy_order)); + boolean b2 = FileUtils.makeDirectory(new File(filePath + FileConstant.upWaitCopy_order_back)); + boolean b3 = FileUtils.makeDirectory(new File(filePath + FileConstant.upWaitCopy_order_error)); + boolean b4 = FileUtils.makeDirectory(new File(filePath + FileConstant.upWaitCopy_products)); + boolean b5 = FileUtils.makeDirectory(new File(filePath + FileConstant.upWaitCopy_products_back)); + boolean b6 = FileUtils.makeDirectory(new File(filePath + FileConstant.upWaitCopy_products_error)); + + boolean b7 = FileUtils.makeDirectory(new File(filePath + FileConstant.waitUpload_order)); + boolean b8 = FileUtils.makeDirectory(new File(filePath + FileConstant.waitUpload_order_back)); + boolean b9 = FileUtils.makeDirectory(new File(filePath + FileConstant.waitUpload_order_error)); + boolean b10 = FileUtils.makeDirectory(new File(filePath + FileConstant.waitUpload_products)); + boolean b11 = FileUtils.makeDirectory(new File(filePath + FileConstant.waitUpload_products_back)); + boolean b12 = FileUtils.makeDirectory(new File(filePath + FileConstant.waitUpload_products_error)); + + } + } + + systemParamConfigService.updateById(systemParamConfigSaveRequest); if (systemParamConfigSaveRequest.getParentId() == 0) { SystemParamConfigSaveRequest systemParamConfigSaveRequest1 = new SystemParamConfigSaveRequest(); 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 index b38e03e..75b26ac 100644 --- 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 @@ -68,7 +68,7 @@ public class BasicDowmloadController { @PostMapping("/spssync/basic/udiinfo/deleteByStatus") public BaseResponse deleteByStatus(@RequestBody DeleteRequest deleteRequest) { - boolean b = basicExportService.deleteById(Integer.parseInt(deleteRequest.getId())); + boolean b = basicExportService.deleteById(deleteRequest.getId()); redisUtil.del(deleteRequest.getId()); if (b) return ResultVOUtils.success("删除成功!"); 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 index b4abe1c..203c071 100644 --- 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 @@ -2,6 +2,7 @@ package com.glxp.sale.admin.controller.sync; import com.alibaba.fastjson.JSON; +import com.glxp.sale.admin.constant.FileConstant; import com.glxp.sale.admin.entity.param.SystemParamConfigEntity; import com.glxp.sale.admin.entity.sync.IOOrderStatusEntity; import com.glxp.sale.admin.http.SpPostHttp; @@ -30,15 +31,19 @@ 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; + + public String getPath() { + SystemParamConfigEntity systemParamConfigEntity = systemParamConfigService.selectByParamKey("share_folder"); + String filePath = systemParamConfigEntity.getParamValue(); + return filePath; + } + + @PostMapping("/spssync/basic/udiinfo/upload") public BaseResponse postUdiInfo(@RequestBody UdiRelevanceExportJsonResponse udiRelevanceExportJsonResponse, BindingResult bindingResult) { @@ -49,10 +54,11 @@ public class BasicExportUploadController { 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 path = getPath(); + String fileName = path + FileConstant.lowerWaitCopy_products + "耗材字典" + key + ".udi"; + String backFileName = path + FileConstant.lowerWaitCopy_products_back + "耗材字典" + key + ".udi"; +// FileUtils.makeDirectory(path); +// FileUtils.makeDirectory(path + "/备份/"); String datas = JSON.toJSONString(udiRelevanceExportJsonResponse); FileUtils.SaveFileAs(datas, fileName); FileUtils.SaveFileAs(datas, backFileName); @@ -74,10 +80,11 @@ public class BasicExportUploadController { 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 path = getPath(); + String fileName = path + FileConstant.lowerWaitCopy_products + "往来单位" + key + ".udi"; + String backFileName = path + FileConstant.lowerWaitCopy_products_back + "往来单位" + key + ".udi"; +// FileUtils.makeDirectory(path); +// FileUtils.makeDirectory(path + "/备份/"); String datas = JSON.toJSONString(basicUnitMaintainExportResponse); FileUtils.SaveFileAs(datas, fileName); FileUtils.SaveFileAs(datas, backFileName); @@ -99,10 +106,11 @@ public class BasicExportUploadController { 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 path = getPath(); + String fileName = path + FileConstant.lowerWaitCopy_products + "仓库字典" + key + ".udi"; + String backFileName = path + FileConstant.lowerWaitCopy_products_back + "/备份/" + "仓库字典" + key + ".udi"; +// FileUtils.makeDirectory(path); +// FileUtils.makeDirectory(path + "/备份/"); String datas = JSON.toJSONString(invWarehouseExportResponse); FileUtils.SaveFileAs(datas, fileName); FileUtils.SaveFileAs(datas, backFileName); @@ -124,10 +132,11 @@ public class BasicExportUploadController { 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 path = getPath(); + String fileName = path + FileConstant.lowerWaitCopy_products + "第三方产品信息" + key + ".udi"; + String backFileName = path + FileConstant.lowerWaitCopy_products_back + "第三方产品信息" + key + ".udi"; +// FileUtils.makeDirectory(path); +// FileUtils.makeDirectory(path + "/备份/"); String datas = JSON.toJSONString(postThrProductsRequest); FileUtils.SaveFileAs(datas, fileName); FileUtils.SaveFileAs(datas, backFileName); @@ -149,10 +158,11 @@ public class BasicExportUploadController { 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 path = getPath(); + String fileName = path + FileConstant.lowerWaitCopy_products + "第三方往来单位" + key + ".udi"; + String backFileName = path + FileConstant.lowerWaitCopy_products_back + "第三方往来单位" + key + ".udi"; + FileUtils.makeDirectory(path); + FileUtils.makeDirectory(path + "/备份/"); String datas = JSON.toJSONString(postThrCorpRequest); FileUtils.SaveFileAs(datas, fileName); FileUtils.SaveFileAs(datas, backFileName); @@ -174,10 +184,11 @@ public class BasicExportUploadController { 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 path = getPath(); + String fileName = path + FileConstant.lowerWaitCopy_products + "第三方业务单据" + key + ".udi"; + String backFileName = path + FileConstant.lowerWaitCopy_products_back + "第三方业务单据" + key + ".udi"; +// FileUtils.makeDirectory(path); +// FileUtils.makeDirectory(path + "/备份/"); String datas = JSON.toJSONString(thrOrderExportJsonResponse); FileUtils.SaveFileAs(datas, fileName); FileUtils.SaveFileAs(datas, backFileName); 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 index 4ed46ec..20b45df 100644 --- 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 @@ -15,7 +15,7 @@ public interface BasicExportDao { boolean insertExportStatus(BasicExportStatusEntity ioOrderStatusEntity); - boolean deleteById(@Param("id") Integer id); + boolean deleteById(@Param("id") String id); boolean updateExportStatus(BasicExportStatusEntity warehouseEntity); 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 index 309ac30..a3ae2ff 100644 --- 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 @@ -5,7 +5,7 @@ import lombok.Data; @Data public class BasicExportStatusRequest extends ListPageRequest { - private Integer id; + private String id; private Integer status; private Integer type; } 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 index e287f6a..c25712f 100644 --- 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 @@ -14,7 +14,7 @@ public interface BasicExportService { boolean insertExportStatus(BasicExportStatusEntity ioOrderStatusEntity); - boolean deleteById(Integer id); + boolean deleteById(String 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 index 7958aba..4aea725 100644 --- 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 @@ -35,7 +35,7 @@ public class BasicExportServiceImpl implements BasicExportService { } @Override - public boolean deleteById(Integer id) { + public boolean deleteById(String id) { return basicExportDao.deleteById(id); } 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 index beb4556..7b60d59 100644 --- 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 @@ -4,6 +4,7 @@ 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.constant.FileConstant; import com.glxp.sale.admin.entity.param.SystemParamConfigEntity; import com.glxp.sale.admin.entity.sync.*; import com.glxp.sale.admin.http.SpGetHttp; @@ -35,12 +36,6 @@ public class DlBasicService { 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 @@ -48,22 +43,80 @@ public class DlBasicService { @Resource BasicExportService basicExportService; + public String getPath() { + SystemParamConfigEntity systemParamConfigEntity = systemParamConfigService.selectByParamKey("share_folder"); + String filePath = systemParamConfigEntity.getParamValue(); + return filePath; + } + @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) { + if (systemParamConfigEntity.getParamValue().equals("1")) { + BaseResponse> baseResponse = spGetHttp.getBasicStatus(BasicProcessStatus.BASIC_UDI + ""); + SystemParamConfigEntity downstream = systemParamConfigService.selectByParamKey("sync_downstream_enable"); + 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 (downstream.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 path = getPath(); + String fileName = path + FileConstant.upWaitCopy_products + "耗材字典" + key + ".udi"; + String backFileName = path + FileConstant.upWaitCopy_products_back + "耗材字典" + key + ".udi"; +// FileUtils.makeDirectory(path); +// FileUtils.makeDirectory(path + "/备份/"); + 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"); + if (systemParamConfigEntity.getParamValue().equals("1")) { + + SystemParamConfigEntity downstream = systemParamConfigService.selectByParamKey("sync_downstream_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.getBasicUdiInfo(ids); + String datas = spGetHttp.getBasicCorps(ids); String key = basicExportStatusEntity.getId() + ""; - if (systemParamConfigEntity.getParamValue().equals("1")) { + if (downstream.getParamValue().equals("1")) { redisUtil.set(key, datas); BasicExportStatusEntity myEntity = new BasicExportStatusEntity(); BeanUtils.copyProperties(basicExportStatusEntity, myEntity); @@ -71,15 +124,16 @@ public class DlBasicService { basicExportService.insertExportStatus(myEntity); spGetHttp.postBasicStatus(basicExportStatusEntity.getId()); } else { - String fileName = udiFilePath + "耗材字典" + key + ".udi"; - String backFileName = backFilePath + "耗材字典" + key + ".udi"; - FileUtils.makeDirectory(udiFilePath); - FileUtils.makeDirectory(backFilePath); + String path = getPath(); + String fileName = path + FileConstant.upWaitCopy_products + "往来单位" + key + ".udi"; + String backFileName = path + FileConstant.upWaitCopy_products_back + "往来单位" + key + ".udi"; +// FileUtils.makeDirectory(path); +// FileUtils.makeDirectory(path + "备份"); FileUtils.SaveFileAs(datas, fileName); FileUtils.SaveFileAs(datas, backFileName); ThrImportLogEntity thrImportLogEntity = new ThrImportLogEntity(); thrImportLogEntity.setGenKey(CustomUtil.getUUId()); - thrImportLogEntity.setImportType(BasicProcessStatus.IMPORT_LOG_TYPE_UDIINFO); + thrImportLogEntity.setImportType(BasicProcessStatus.IMPORT_LOG_TYPE_CORP); thrImportLogEntity.setUpdateTime(new Date()); thrImportLogEntity.setFilePath(fileName); thrImportLogEntity.setBackFilePath(backFileName); @@ -92,93 +146,55 @@ public class DlBasicService { } } } - } - - - @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()); - } + if (systemParamConfigEntity.getParamValue().equals("1")) { + BaseResponse> baseResponse = spGetHttp.getBasicStatus(BasicProcessStatus.BASIC_INV + ""); + SystemParamConfigEntity downstream = systemParamConfigService.selectByParamKey("sync_downstream_enable"); + 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 (downstream.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 path = getPath(); + String fileName = path + FileConstant.upWaitCopy_products + "仓库字典" + key + ".udi"; + String backFileName = path + FileConstant.upWaitCopy_products_back + "仓库字典" + key + ".udi"; +// FileUtils.makeDirectory(path); +// FileUtils.makeDirectory(path + "/备份/"); + 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 2b5a9a1..37e37c7 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 @@ -1,6 +1,7 @@ package com.glxp.sale.admin.thread; import com.alibaba.fastjson.JSONObject; +import com.glxp.sale.admin.constant.FileConstant; import com.glxp.sale.admin.entity.param.SystemParamConfigEntity; import com.glxp.sale.admin.entity.sync.*; import com.glxp.sale.admin.http.SpGetHttp; @@ -38,82 +39,88 @@ public class DlSpOrderService { SystemParamConfigService systemParamConfigService; @Resource IOOrderStatusService ioOrderStatusService; - @Value("${file_path_updl_order}") - private String filePath; - @Value("${back_file_path}") - private String backFilePath; @Resource private ThrImportLogService thrImportLogService; + public String getPath() { + SystemParamConfigEntity systemParamConfigEntity = systemParamConfigService.selectByParamKey("share_folder"); + String filePath = systemParamConfigEntity.getParamValue(); + return filePath; + } + @Async public void dlOrdedrs() { - BaseResponse> baseResponse = spGetHttp.getOrderStatus(); - PageSimpleResponse pageSimpleResponse = baseResponse.getData(); - SystemParamConfigEntity folderConfig = systemParamConfigService.selectByParamKey("gen_order_folder"); - SystemParamConfigEntity stausConfig = systemParamConfigService.selectByParamKey("gen_order_status"); - if (pageSimpleResponse != null) { - List ioOrderStatusEntityList = pageSimpleResponse.getList(); - if (ioOrderStatusEntityList != null && ioOrderStatusEntityList.size() > 0) { - for (IOOrderStatusEntity ioOrderStatusEntity : ioOrderStatusEntityList) { - BaseResponse> ordersRes = spGetHttp.getOrders(ioOrderStatusEntity.getOrderId()); - List dlOrderResponses = ordersRes.getData(); - if (dlOrderResponses != null && dlOrderResponses.size() > 0) { - for (DlOrderResponse dlOrderResponse : dlOrderResponses) { - OrderEntity orderEntity = dlOrderResponse.getOrderEntity(); - if(orderEntity!=null){ - IOOrderStatusEntity temp = ioOrderStatusService.findByOrderId(orderEntity.getId()); - if (temp == null) {//避免重复操作插入 - if (Integer.parseInt(stausConfig.getParamValue()) == 1) { - IOOrderStatusEntity orderStatusEntity = new IOOrderStatusEntity(); - orderStatusEntity.setOrderId(orderEntity.getId()); - orderStatusEntity.setUpdateTime(new Date()); - orderStatusEntity.setStatus(1); - ioOrderStatusService.insertOrderStatus(orderStatusEntity); - List codes = dlOrderResponse.getCodes(); - orderService.insertOrder(orderEntity); - codesService.insertWarehouses(codes); - } - if (Integer.parseInt(folderConfig.getParamValue()) == 1) { + SystemParamConfigEntity systemParamConfigEntity = systemParamConfigService.selectByParamKey("sync_upstream_enable"); + if (systemParamConfigEntity.getParamValue().equals("1")) { + String path = getPath(); + SystemParamConfigEntity downstream = systemParamConfigService.selectByParamKey("sync_downstream_enable"); + BaseResponse> baseResponse = spGetHttp.getOrderStatus(); + PageSimpleResponse pageSimpleResponse = baseResponse.getData(); +// SystemParamConfigEntity folderConfig = systemParamConfigService.selectByParamKey("gen_order_folder"); +// SystemParamConfigEntity stausConfig = systemParamConfigService.selectByParamKey("gen_order_status"); + + + if (pageSimpleResponse != null) { + List ioOrderStatusEntityList = pageSimpleResponse.getList(); + if (ioOrderStatusEntityList != null && ioOrderStatusEntityList.size() > 0) { + for (IOOrderStatusEntity ioOrderStatusEntity : ioOrderStatusEntityList) { + BaseResponse> ordersRes = spGetHttp.getOrders(ioOrderStatusEntity.getOrderId()); + List dlOrderResponses = ordersRes.getData(); + if (dlOrderResponses != null && dlOrderResponses.size() > 0) { + for (DlOrderResponse dlOrderResponse : dlOrderResponses) { + OrderEntity orderEntity = dlOrderResponse.getOrderEntity(); + if (orderEntity != null) { + IOOrderStatusEntity temp = ioOrderStatusService.findByOrderId(orderEntity.getId()); + if (temp == null) {//避免重复操作插入 + if (Integer.parseInt(downstream.getParamValue()) == 1) { + IOOrderStatusEntity orderStatusEntity = new IOOrderStatusEntity(); + orderStatusEntity.setOrderId(orderEntity.getId()); + orderStatusEntity.setUpdateTime(new Date()); + orderStatusEntity.setStatus(1); + ioOrderStatusService.insertOrderStatus(orderStatusEntity); + List codes = dlOrderResponse.getCodes(); + orderService.insertOrder(orderEntity); + codesService.insertWarehouses(codes); + } else { + + String fileName = path + FileConstant.upWaitCopy_order + "扫码单据" + orderEntity.getId() + ".json"; + String backFileName = path + FileConstant.upWaitCopy_order_back + "扫码单据" + orderEntity.getId() + ".json"; + List postOrders = new ArrayList<>(); + PostOrderRequest postOrderRequest = new PostOrderRequest(); + List warehouseEntityList = dlOrderResponse.getCodes(); + PostOrderRequest.PostOrder postOrder = new PostOrderRequest.PostOrder(); + postOrder.setCodes(warehouseEntityList); + postOrder.setBillType(orderEntity.getAction()); + postOrders.add(postOrder); + postOrderRequest.setPostOrders(postOrders); + String json = JSONObject.toJSON(postOrderRequest).toString(); +// FileUtils.makeDirectory(path); +// FileUtils.makeDirectory(path + "/备份/"); + FileUtils.SaveFileAs(json, fileName); + FileUtils.SaveFileAs(json, backFileName); + ThrImportLogEntity thrImportLogEntity = new ThrImportLogEntity(); + thrImportLogEntity.setGenKey(CustomUtil.getUUId()); + thrImportLogEntity.setImportType(1); + thrImportLogEntity.setUpdateTime(new Date()); + thrImportLogEntity.setFilePath(fileName); + thrImportLogEntity.setBackFilePath(backFileName); + thrImportLogEntity.setOrderId(orderEntity.getId()); + thrImportLogService.insertImportLog(thrImportLogEntity); + } - filePath = filePath + "/" + "已完成扫码单据/"; - backFilePath = backFilePath + "/" + "已完成扫码单据/"; - String fileName = filePath + "扫码单据" + orderEntity.getId() + ".json"; - String backFileName = backFilePath + "/" + "扫码单据" + orderEntity.getId() + ".json"; - List postOrders = new ArrayList<>(); - PostOrderRequest postOrderRequest = new PostOrderRequest(); - List warehouseEntityList = dlOrderResponse.getCodes(); - PostOrderRequest.PostOrder postOrder = new PostOrderRequest.PostOrder(); - postOrder.setCodes(warehouseEntityList); - postOrder.setBillType(orderEntity.getAction()); - postOrders.add(postOrder); - postOrderRequest.setPostOrders(postOrders); - String json = JSONObject.toJSON(postOrderRequest).toString(); - FileUtils.makeDirectory(filePath); - FileUtils.makeDirectory(backFilePath); - FileUtils.SaveFileAs(json, fileName); - FileUtils.SaveFileAs(json, backFileName); - ThrImportLogEntity thrImportLogEntity = new ThrImportLogEntity(); - thrImportLogEntity.setGenKey(CustomUtil.getUUId()); - thrImportLogEntity.setImportType(1); - thrImportLogEntity.setUpdateTime(new Date()); - thrImportLogEntity.setFilePath(fileName); - thrImportLogEntity.setBackFilePath(backFileName); - thrImportLogEntity.setOrderId(orderEntity.getId()); - thrImportLogService.insertImportLog(thrImportLogEntity); + spGetHttp.postOrder(orderEntity.getId()); } - spGetHttp.postOrder(orderEntity.getId()); } - } + } } - } + } } } } - } } 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 index 35696d9..5877dd5 100644 --- 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 @@ -1,14 +1,19 @@ package com.glxp.sale.admin.thread; import com.glxp.sale.admin.constant.BasicProcessStatus; +import com.glxp.sale.admin.constant.FileConstant; +import com.glxp.sale.admin.entity.param.SystemParamConfigEntity; 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.param.SystemParamConfigService; 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.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Value; import org.springframework.scheduling.annotation.Async; import org.springframework.stereotype.Service; @@ -25,52 +30,93 @@ import java.util.List; @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; + @Resource + SystemParamConfigService systemParamConfigService; + final Logger logger = LoggerFactory.getLogger(HeartTask.class); + + public String getPath() { + SystemParamConfigEntity systemParamConfigEntity = systemParamConfigService.selectByParamKey("share_folder"); + String filePath = systemParamConfigEntity.getParamValue(); + return filePath; + } public void scanOrder() { - File[] files = FileUtils.listAll(new File(orderFilePath), new FileFilterImpl()); + logger.info("扫描单据生成状态表等待下载!"); + File[] files = FileUtils.listCurentAll(new File(getPath() + FileConstant.waitDownload_order), 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()); + String fileName; + String orderId = null; + try { + fileName = file.getName(); + orderId = fileName.substring(4, fileName.length() - 4); + if (!fileName.contains(".udi")) { + errorFile(file); + continue; + } + } catch (Exception e) { + e.printStackTrace(); + errorFile(file); + //文件格式异常 + continue; + } + orderStatusEntity.setOrderId(orderId); orderStatusEntity.setUpdateTime(new Date()); orderStatusEntity.setStatus(1); ioOrderStatusService.insertOrderStatus(orderStatusEntity); - redisUtil.set(file.getName(), data); - + redisUtil.set(orderId, data); + try { + FileUtils.CutFile(file.getPath(), getPath() + FileConstant.waitDownload_order_back + file.getName()); + } catch (Exception e) { + e.printStackTrace(); + } } } } + + public void errorFile(File file) { + try { + FileUtils.CutFile(file.getPath(), getPath() + FileConstant.waitDownload_order_error + file.getName()); + } catch (Exception e1) { + e1.printStackTrace(); + } + } + public void scanUdi() { - File[] files = FileUtils.listAll(new File(udiFilePath), new FileFilterImpl()); + logger.info("扫描耗材字典生成状态表等待下载!"); + File[] files = FileUtils.listCurentAll(new File(getPath() + FileConstant.waitDownload_products), 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()); + String fileName = file.getName(); + String id = fileName.substring(4, fileName.length() - 4); + basicExportStatusEntity.setId(id); basicExportStatusEntity.setUpdateTime(new Date()); basicExportStatusEntity.setStatus(1); basicExportStatusEntity.setIdDatas(file.getPath()); basicExportStatusEntity.setType(BasicProcessStatus.BASIC_UDI); basicExportService.insertExportStatus(basicExportStatusEntity); - redisUtil.set(file.getName(), data); + redisUtil.set(id, data); + try { + FileUtils.CutFile(file.getPath(), getPath() + FileConstant.waitDownload_products_back + file.getName()); + } catch (Exception e) { + e.printStackTrace(); + } } } @@ -78,40 +124,56 @@ public class ScanDownloadService { } public void scanCorp() { - File[] files = FileUtils.listAll(new File(udiFilePath), new FileFilterImpl()); + logger.info("扫描往来单位生成状态表等待下载!"); + File[] files = FileUtils.listCurentAll(new File(getPath() + FileConstant.waitDownload_products), 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()); + String fileName = file.getName(); + String id = fileName.substring(4, fileName.length() - 4); + basicExportStatusEntity.setId(id); basicExportStatusEntity.setUpdateTime(new Date()); basicExportStatusEntity.setStatus(1); basicExportStatusEntity.setIdDatas(file.getPath()); basicExportStatusEntity.setType(BasicProcessStatus.BASIC_CORP); basicExportService.insertExportStatus(basicExportStatusEntity); - redisUtil.set(file.getName(), data); + redisUtil.set(id, data); + try { + FileUtils.CutFile(file.getPath(), getPath() + FileConstant.waitDownload_products_back + file.getName()); + } catch (Exception e) { + e.printStackTrace(); + } } } } } public void scanInv() { - File[] files = FileUtils.listAll(new File(udiFilePath), new FileFilterImpl()); + logger.info("扫描仓库字典生成状态表等待下载!"); + File[] files = FileUtils.listCurentAll(new File(getPath() + FileConstant.waitDownload_products), 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()); + String fileName = file.getName(); + String id = fileName.substring(4, fileName.length() - 4); + basicExportStatusEntity.setId(id); basicExportStatusEntity.setUpdateTime(new Date()); basicExportStatusEntity.setStatus(1); basicExportStatusEntity.setIdDatas(file.getPath()); basicExportStatusEntity.setType(BasicProcessStatus.BASIC_INV); basicExportService.insertExportStatus(basicExportStatusEntity); - redisUtil.set(file.getName(), data); + redisUtil.set(id, data); + try { + FileUtils.CutFile(file.getPath(), getPath() + FileConstant.waitDownload_products_back + file.getName()); + } catch (Exception e) { + e.printStackTrace(); + } } } } 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 index a233af8..aea5fb4 100644 --- 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 @@ -2,6 +2,8 @@ package com.glxp.sale.admin.thread; import com.alibaba.fastjson.JSON; import com.glxp.sale.admin.constant.BasicProcessStatus; +import com.glxp.sale.admin.constant.FileConstant; +import com.glxp.sale.admin.entity.param.SystemParamConfigEntity; import com.glxp.sale.admin.entity.sync.BasicExportStatusEntity; import com.glxp.sale.admin.entity.sync.IOOrderStatusEntity; import com.glxp.sale.admin.http.SpGetHttp; @@ -9,8 +11,10 @@ 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.service.sync.BasicExportService; import com.glxp.sale.admin.service.sync.IOOrderStatusService; +import com.glxp.sale.admin.util.Constant; import com.glxp.sale.admin.util.FileFilterImpl; import com.glxp.sale.admin.util.FileUtils; import com.glxp.sale.admin.util.RedisUtil; @@ -30,17 +34,20 @@ import java.util.Date; @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; + @Resource + SystemParamConfigService systemParamConfigService; + + + public String getPath() { + SystemParamConfigEntity systemParamConfigEntity = systemParamConfigService.selectByParamKey("share_folder"); + String filePath = systemParamConfigEntity.getParamValue(); + return filePath; + } public void scanOrder() { - File[] files = FileUtils.listAll(new File(orderFilePath), new FileFilterImpl()); + File[] files = FileUtils.listCurentAll(new File(getPath() + FileConstant.waitUpload_order), new FileFilterImpl()); if (files != null && files.length > 0) { for (int i = 0; i < files.length; i++) { File file = files[i]; @@ -49,7 +56,7 @@ public class ScanUploadService { BaseResponse baseResponse = spPostHttp.postOrder(dlOrderResponse); if (baseResponse.getCode() == 20000) {//上传成功 try { - FileUtils.CutFile(file.getPath(), backFilePath + "/已上传单据/"+ file.getName()); + FileUtils.CutFile(file.getPath(), getPath() + FileConstant.waitUpload_order_back + file.getName()); } catch (Exception e) { e.printStackTrace(); } @@ -60,7 +67,7 @@ public class ScanUploadService { } public void scanUdi() { - File[] files = FileUtils.listAll(new File(udiFilePath), new FileFilterImpl()); + File[] files = FileUtils.listCurentAll(new File(getPath() + FileConstant.waitUpload_products), new FileFilterImpl()); if (files != null && files.length > 0) { for (int i = 0; i < files.length; i++) { File file = files[i]; @@ -70,7 +77,7 @@ public class ScanUploadService { BaseResponse baseResponse = spPostHttp.postUdiInfo(udiRelevanceExportJsonResponse); if (baseResponse.getCode() == 20000) {//上传成功 try { - FileUtils.CutFile(file.getPath(), backFilePath + "/已上传基础信息/"+ file.getName()); + FileUtils.CutFile(file.getPath(), getPath() + FileConstant.waitUpload_products_back + file.getName()); } catch (Exception e) { e.printStackTrace(); } @@ -82,7 +89,7 @@ public class ScanUploadService { } public void scanCorp() { - File[] files = FileUtils.listAll(new File(udiFilePath), new FileFilterImpl()); + File[] files = FileUtils.listCurentAll(new File(getPath() + FileConstant.waitUpload_products), new FileFilterImpl()); if (files != null && files.length > 0) { for (int i = 0; i < files.length; i++) { File file = files[i]; @@ -92,7 +99,7 @@ public class ScanUploadService { BaseResponse baseResponse = spPostHttp.postCorp(basicUnitMaintainExportResponse); if (baseResponse.getCode() == 20000) {//上传成功 try { - FileUtils.CutFile(file.getPath(), backFilePath + "/已上传基础信息/"+ file.getName()); + FileUtils.CutFile(file.getPath(), getPath() + FileConstant.waitUpload_products_back + file.getName()); } catch (Exception e) { e.printStackTrace(); } @@ -103,7 +110,7 @@ public class ScanUploadService { } public void scanInv() { - File[] files = FileUtils.listAll(new File(udiFilePath), new FileFilterImpl()); + File[] files = FileUtils.listCurentAll(new File(getPath() + FileConstant.waitUpload_products), new FileFilterImpl()); if (files != null && files.length > 0) { for (int i = 0; i < files.length; i++) { File file = files[i]; @@ -113,7 +120,7 @@ public class ScanUploadService { BaseResponse baseResponse = spPostHttp.postInv(invWarehouseExportResponse); if (baseResponse.getCode() == 20000) {//上传成功 try { - FileUtils.CutFile(file.getPath(), backFilePath + "/已上传基础信息/"+ file.getName()); + FileUtils.CutFile(file.getPath(), getPath() + FileConstant.waitUpload_products_back + file.getName()); } catch (Exception e) { e.printStackTrace(); } @@ -124,7 +131,7 @@ public class ScanUploadService { } public void scanThirdProducts() { - File[] files = FileUtils.listAll(new File(udiFilePath), new FileFilterImpl()); + File[] files = FileUtils.listCurentAll(new File(getPath() + FileConstant.waitUpload_products), new FileFilterImpl()); if (files != null && files.length > 0) { for (int i = 0; i < files.length; i++) { File file = files[i]; @@ -134,7 +141,7 @@ public class ScanUploadService { BaseResponse baseResponse = spPostHttp.postThirdProducts(postThrProductsRequest); if (baseResponse.getCode() == 20000) {//上传成功 try { - FileUtils.CutFile(file.getPath(), backFilePath + "/已上传基础信息/"+ file.getName()); + FileUtils.CutFile(file.getPath(), getPath() + FileConstant.waitUpload_products_back + file.getName()); } catch (Exception e) { e.printStackTrace(); } @@ -146,7 +153,7 @@ public class ScanUploadService { public void scanThirdCorp() { - File[] files = FileUtils.listAll(new File(udiFilePath), new FileFilterImpl()); + File[] files = FileUtils.listCurentAll(new File(getPath() + FileConstant.waitUpload_products), new FileFilterImpl()); if (files != null && files.length > 0) { for (int i = 0; i < files.length; i++) { File file = files[i]; @@ -156,7 +163,7 @@ public class ScanUploadService { BaseResponse baseResponse = spPostHttp.postThirdCorps(postThrCorpRequest); if (baseResponse.getCode() == 20000) {//上传成功 try { - FileUtils.CutFile(file.getPath(), backFilePath + "/已上传基础信息/"+ file.getName()); + FileUtils.CutFile(file.getPath(), getPath() + FileConstant.waitUpload_products_back + file.getName()); } catch (Exception e) { e.printStackTrace(); } @@ -167,7 +174,7 @@ public class ScanUploadService { } public void scanThirdOrder() { - File[] files = FileUtils.listAll(new File(udiFilePath), new FileFilterImpl()); + File[] files = FileUtils.listCurentAll(new File(getPath() + FileConstant.waitUpload_products), new FileFilterImpl()); if (files != null && files.length > 0) { for (int i = 0; i < files.length; i++) { File file = files[i]; @@ -177,7 +184,7 @@ public class ScanUploadService { BaseResponse baseResponse = spPostHttp.postThirdOrders(thrOrderExportJsonResponse); if (baseResponse.getCode() == 20000) {//上传成功 try { - FileUtils.CutFile(file.getPath(), backFilePath + "/已上传基础信息/" + file.getName()); + FileUtils.CutFile(file.getPath(), getPath() + FileConstant.waitUpload_products_back + file.getName()); } catch (Exception e) { e.printStackTrace(); } 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 13fa69b..ff7f56e 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 @@ -284,6 +284,26 @@ public class FileUtils { return files; } + public static File[] listCurentAll(File file, + FileFilter filter) { + ArrayList list = new ArrayList(); + File[] files; + if (!file.exists() || file.isFile()) { + return null; + } + files = file.listFiles(); + if (files != null) { + for (int i = 0; i < files.length; i++) { + if (files[i].isFile()) { + list.add(files[i]); + } + } + } + File[] resultfiles = new File[list.size()]; + list.toArray(resultfiles); + return resultfiles; + } + /** * 将目录中的内容添加到列表。 *