From 7b07c064e0097a52a05abe22227e458707ded339 Mon Sep 17 00:00:00 2001 From: zhenghaoyu Date: Tue, 1 Apr 2025 16:05:30 +0800 Subject: [PATCH 1/9] =?UTF-8?q?1.=E4=BC=98=E5=8C=96=E5=8D=B8=E8=BD=A6?= =?UTF-8?q?=E6=95=B0=E6=8D=AE=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../feign/DistributionStockArticleClient.java | 42 +++++++++++-------- 1 file changed, 24 insertions(+), 18 deletions(-) diff --git a/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/feign/DistributionStockArticleClient.java b/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/feign/DistributionStockArticleClient.java index b9cd8d4f0..ee527e818 100644 --- a/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/feign/DistributionStockArticleClient.java +++ b/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/feign/DistributionStockArticleClient.java @@ -81,30 +81,36 @@ public class DistributionStockArticleClient implements IDistributionStockArticle String key = orderCode + warehouseId; - Boolean exists = bladeRedis.exists(key); - if(exists){ - String idStr = bladeRedis.get(key); - if("1".equals(idStr)){ - return 1L; - }else{ - return Long.valueOf(idStr); - } - }else{ - bladeRedis.setEx(key,"1",30L); - DistributionStockArticleEntity distributionStockArticle = distributionStockArticleService.findStockArticleByOrderCodeAndWarehouseId(orderCode, warehouseId); - if(ObjectUtils.isNotEmpty(distributionStockArticle)){ - bladeRedis.setEx(key,distributionStockArticle.getId().toString(),30L); - return distributionStockArticle.getId(); + try{ + Boolean exists = bladeRedis.exists(key); + if(exists){ + String idStr = bladeRedis.get(key); + if("1".equals(idStr)){ + return 1L; + }else{ + return Long.valueOf(idStr); + } }else{ - boolean saveFlag = distributionStockArticleService.save(distributionStockArticleEntity); - if(saveFlag){ + bladeRedis.setEx(key,"1",30L); + DistributionStockArticleEntity distributionStockArticle = distributionStockArticleService.findStockArticleByOrderCodeAndWarehouseId(orderCode, warehouseId); + if(ObjectUtils.isNotEmpty(distributionStockArticle)){ bladeRedis.setEx(key,distributionStockArticle.getId().toString(),30L); - return distributionStockArticleEntity.getId(); + return distributionStockArticle.getId(); }else{ - return 0L; + boolean saveFlag = distributionStockArticleService.save(distributionStockArticleEntity); + if(saveFlag){ + bladeRedis.setEx(key,distributionStockArticle.getId().toString(),30L); + return distributionStockArticleEntity.getId(); + }else{ + return 0L; + } } } + }catch (Exception e){ + log.error("#######addData: 保存订单失败",e); + return 0L; } + } @Override From 15e2635f64485428ca6738129617c9e265c94778 Mon Sep 17 00:00:00 2001 From: zhenghaoyu Date: Tue, 1 Apr 2025 16:12:56 +0800 Subject: [PATCH 2/9] =?UTF-8?q?1.=E4=BC=98=E5=8C=96=E5=8D=B8=E8=BD=A6?= =?UTF-8?q?=E6=95=B0=E6=8D=AE=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../distribution/feign/DistributionStockArticleClient.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/feign/DistributionStockArticleClient.java b/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/feign/DistributionStockArticleClient.java index ee527e818..81607ec5f 100644 --- a/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/feign/DistributionStockArticleClient.java +++ b/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/feign/DistributionStockArticleClient.java @@ -99,7 +99,7 @@ public class DistributionStockArticleClient implements IDistributionStockArticle }else{ boolean saveFlag = distributionStockArticleService.save(distributionStockArticleEntity); if(saveFlag){ - bladeRedis.setEx(key,distributionStockArticle.getId().toString(),30L); + bladeRedis.setEx(key,distributionStockArticleEntity.getId().toString(),30L); return distributionStockArticleEntity.getId(); }else{ return 0L; From e9e7e0728f23e3bb8622131173e9d78068a7414c Mon Sep 17 00:00:00 2001 From: "pref_mail@163.com" Date: Tue, 1 Apr 2025 16:18:27 +0800 Subject: [PATCH 3/9] =?UTF-8?q?add:=E5=A2=9E=E5=8A=A0=E8=AE=A2=E5=8D=95?= =?UTF-8?q?=E6=9F=A5=E8=AF=A2=E7=9A=84=E5=88=A4=E6=96=AD=EF=BC=8C=E5=A2=9E?= =?UTF-8?q?=E5=8A=A0=E5=8C=85=E4=BB=B6=E9=87=8D=E5=A4=8D=E7=9A=84=E6=9F=A5?= =?UTF-8?q?=E8=AF=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../suofeiya/job/SpiderDataJob.java | 48 ++++++++++++++++--- 1 file changed, 41 insertions(+), 7 deletions(-) diff --git a/blade-service/logpm-factory-data/logpm-factory-data-suofeiya/src/main/java/com/logpm/factorydata/suofeiya/job/SpiderDataJob.java b/blade-service/logpm-factory-data/logpm-factory-data-suofeiya/src/main/java/com/logpm/factorydata/suofeiya/job/SpiderDataJob.java index e079661c5..966ba7c03 100644 --- a/blade-service/logpm-factory-data/logpm-factory-data-suofeiya/src/main/java/com/logpm/factorydata/suofeiya/job/SpiderDataJob.java +++ b/blade-service/logpm-factory-data/logpm-factory-data-suofeiya/src/main/java/com/logpm/factorydata/suofeiya/job/SpiderDataJob.java @@ -25,6 +25,7 @@ import com.xxl.job.core.biz.model.ReturnT; import com.xxl.job.core.handler.annotation.XxlJob; import lombok.AllArgsConstructor; import lombok.extern.slf4j.Slf4j; +import org.springblade.core.redis.cache.BladeRedis; import org.springblade.core.tool.utils.BeanUtil; import org.springblade.core.tool.utils.StringUtil; import org.springframework.beans.factory.annotation.Autowired; @@ -62,6 +63,11 @@ public class SpiderDataJob { @Autowired private Executor asyncChangeDbExecutor; + @Autowired + private BladeRedis bladeRedis; + + private LocalDate firstDayOfMonth; + private LocalDate lastDayOfMonth; @@ -79,6 +85,8 @@ public class SpiderDataJob { startData =LocalDate.now().toString(); endData = LocalDate.now().minusDays(1).toString(); + + if(StringUtil.isNotBlank(param)){ if(param.contains(",")){ String[] split = param.split(","); @@ -91,6 +99,14 @@ public class SpiderDataJob { } + // 获取当前日期的第一天 的日期 和最后一天的日期 + LocalDate now = LocalDate.parse(startData); + firstDayOfMonth = now.withDayOfMonth(1); + lastDayOfMonth = now.withDayOfMonth(now.lengthOfMonth()); + + + + // // startData ="2025-02-25"; @@ -195,6 +211,7 @@ public class SpiderDataJob { vo.setOrderInfo(orderInfo); vo.setPackageInfo(packageInfoVOs); } + log.debug(">>>>> vo {}",vo); asyncChangeDbExecutor.execute(new ChdbTask(spiderInforEntity.getBindTenantCode(), vo,deliveryNoteService)); } @@ -308,14 +325,25 @@ public class SpiderDataJob { JSONObject jsonObject = getData(url, buildCookies(username, password)); JSONArray temList = jsonObject.getJSONArray("result"); + + log.debug("getCarOrders 执行时间:{}",temList.size()); + for (Object o : temList) { JSONObject jsonObject1 = (JSONObject) o; - JSONObject list2 = getOrderInfor(jsonObject1.getStr("orderNumber"), username, password); - JSONArray list_2 = list2.getJSONArray("result"); - for (Object o1 : list_2) { - JSONObject t = (JSONObject) o1; - result.add(t); + String orderNumber = jsonObject1.getStr("orderNumber"); + String key = "sfy:factory:"+orderNumber+".lock"; + Object o2 = bladeRedis.get(key); + if(o2 == null){ + JSONObject list2 = getOrderInfor(orderNumber, username, password); + + JSONArray list_2 = list2.getJSONArray("result"); + for (Object o1 : list_2) { + JSONObject t = (JSONObject) o1; + result.add(t); + } +// 单号存储3个小时 + bladeRedis.setEx(key,"1",60L); } } @@ -339,8 +367,14 @@ public class SpiderDataJob { */ private JSONObject getOrderInfor(String orderCode, String username, String password) { + + + Long _dc_ = System.currentTimeMillis(); - String url ="https://portal.sfygroup.com/reporthome/rest/delivedryNotice/all?_dc="+_dc_+"&page=1&start=0&limit=20&filtersRaw=[{\"id\":null,\"property\":\"A.SCHEDULE_DELIVERY_DATE\",\"value\":\""+startData+"\",\"operator\":\">=\",\"sql\":null},{\"id\":null,\"property\":\"A.SCHEDULE_DELIVERY_DATE\",\"value\":\""+endData+"\",\"operator\":\"<\",\"sql\":null},{\"id\":null,\"property\":\"A.ORDER_NUMBER\",\"value\":\""+orderCode+"\",\"operator\":\"like\",\"sql\":null}]"; + String url ="https://portal.sfygroup.com/reporthome/rest/delivedryNotice/all?_dc="+_dc_ + +"&page=1&start=0&limit=20&filtersRaw=[{\"id\":null,\"property\":\"A.SCHEDULE_DELIVERY_DATE\",\"value\":\""+ + firstDayOfMonth+"\",\"operator\":\">=\",\"sql\":null},{\"id\":null,\"property\":\"A.SCHEDULE_DELIVERY_DATE\",\"value\":\""+ + lastDayOfMonth+"\",\"operator\":\"<\",\"sql\":null},{\"id\":null,\"property\":\"A.ORDER_NUMBER\",\"value\":\""+orderCode+"\",\"operator\":\"like\",\"sql\":null}]"; JSONObject jsonObject = getData(url, buildCookiesByDD(username, password)); return jsonObject; @@ -385,7 +419,7 @@ public class SpiderDataJob { JSONArray response = new JSONArray(); //获取订单对应的装箱单 Long _dc_ = System.currentTimeMillis(); - String url = "https://portal.sfygroup.com/reporthome/rest/orderPackHead/all?_dc=" + _dc_ + "&page=1&start=0&limit=1000&filtersRaw=[{\"id\":null,\"property\":\"A.ORDER_NUMBER\",\"value\":\"" + orderCode + "\",\"operator\":\"=\",\"sql\":null},{\"id\":null,\"property\":\"A.SCHEDULE_DELIVERY_DATE\",\"value\":\"" + startData + "\",\"operator\":\">=\",\"sql\":null},{\"id\":null,\"property\":\"A.SCHEDULE_DELIVERY_DATE\",\"value\":\"" + endData + "\",\"operator\":\"<\",\"sql\":null}]"; + String url = "https://portal.sfygroup.com/reporthome/rest/orderPackHead/all?_dc=" + _dc_ + "&page=1&start=0&limit=1000&filtersRaw=[{\"id\":null,\"property\":\"A.ORDER_NUMBER\",\"value\":\"" + orderCode + "\",\"operator\":\"=\",\"sql\":null},{\"id\":null,\"property\":\"A.SCHEDULE_DELIVERY_DATE\",\"value\":\"" + firstDayOfMonth + "\",\"operator\":\">=\",\"sql\":null},{\"id\":null,\"property\":\"A.SCHEDULE_DELIVERY_DATE\",\"value\":\"" + lastDayOfMonth + "\",\"operator\":\"<\",\"sql\":null}]"; JSONObject data = getData(url, buildCookiesByZx(username, password)); JSONArray tempList = data.getJSONArray("result"); for (Object o : tempList) { From f4e1edddc00ce1302660fa4b7e97d82bc5b3ac16 Mon Sep 17 00:00:00 2001 From: zhaoqiaobo <583671871@qq.com> Date: Tue, 1 Apr 2025 16:57:07 +0800 Subject: [PATCH 4/9] =?UTF-8?q?feat(all):=20=E7=99=BE=E5=BE=97=E8=83=9C?= =?UTF-8?q?=E5=B7=A5=E5=8E=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 1 增加百得胜工厂数据对接 --- .../common/constant/ModuleNameConstant.java | 4 + .../factorydata/FactoryDataConstants.java | 8 + .../logpm/factorydata/enums/BrandEnums.java | 1 + .../logpm-factory-data-paterson/pom.xml | 96 ++++++++++ .../FactoryDataPatersonApplication.java | 20 ++ .../aspect/AsyncAnnotationAspect.java | 50 +++++ .../paterson/aspect/JobAnnotationAspect.java | 82 ++++++++ .../aspect/RabbitAnnotationAspect.java | 48 +++++ .../config/CustomMessageConverter.java | 161 ++++++++++++++++ .../paterson/config/ExecutorConfig.java | 85 ++++++++ .../FactoryDataPatersonConfiguration.java | 40 ++++ .../config/InterceptorAdapterConfig.java | 39 ++++ .../paterson/config/RabbitConfig.java | 17 ++ .../paterson/config/XxlJobConfig.java | 74 +++++++ .../paterson/controller/OrderController.java | 64 +++++++ .../paterson/entity/FactoryOrderEntity.java | 88 +++++++++ .../entity/FactoryOrderLogEntity.java | 63 ++++++ .../paterson/entity/FactoryPackageEntity.java | 72 +++++++ .../entity/FactoryShipmentEntity.java | 64 +++++++ .../FactoryAccountsInterceptor.java | 180 +++++++++++++++++ .../FactoryDataBaseLauncherServiceImpl.java | 60 ++++++ .../mapper/FactoryOrderLogMapper.java | 16 ++ .../paterson/mapper/FactoryOrderLogMapper.xml | 5 + .../paterson/mapper/FactoryOrderMapper.java | 16 ++ .../paterson/mapper/FactoryOrderMapper.xml | 5 + .../paterson/mapper/FactoryPackageMapper.java | 16 ++ .../paterson/mapper/FactoryPackageMapper.xml | 5 + .../mapper/FactoryShipmentMapper.java | 21 ++ .../paterson/mapper/FactoryShipmentMapper.xml | 17 ++ .../paterson/mq/FactoryOrderListener.java | 52 +++++ .../pros/FactoryDataPatersonProperties.java | 20 ++ .../paterson/pros/PatersonProperties.java | 78 ++++++++ .../paterson/service/DeliveryNoteService.java | 14 ++ .../service/FactoryOrderLogService.java | 14 ++ .../paterson/service/FactoryOrderService.java | 14 ++ .../service/FactoryPackageService.java | 14 ++ .../service/FactoryShipmentService.java | 19 ++ .../paterson/service/MqWorkerService.java | 13 ++ .../service/impl/DeliveryNoteServiceImpl.java | 181 ++++++++++++++++++ .../impl/FactoryOrderLogServiceImpl.java | 22 +++ .../service/impl/FactoryOrderServiceImpl.java | 22 +++ .../impl/FactoryPackageServiceImpl.java | 22 +++ .../impl/FactoryShipmentServiceImpl.java | 137 +++++++++++++ .../service/impl/MqWorkerServiceImpl.java | 139 ++++++++++++++ .../paterson/vo/FactoryAuthVO.java | 30 +++ .../paterson/vo/FactoryOrderDataVO.java | 27 +++ .../paterson/vo/FactoryOrderVO.java | 25 +++ .../paterson/vo/FactoryPackageVO.java | 21 ++ .../paterson/vo/FactoryShipmentVO.java | 25 +++ .../paterson/vo/PackageCategoryVO.java | 26 +++ .../vo/ThirdPlWarehouseMappingVO.java | 32 ++++ .../CustomHttpServletRequestWrapper.java | 38 ++++ .../paterson/wrapper/RequestWrapper.java | 75 ++++++++ .../src/main/resources/application-dev.yml | 73 +++++++ .../src/main/resources/application-prod.yml | 47 +++++ .../src/main/resources/application-test.yml | 73 +++++++ .../src/main/resources/application.yml | 31 +++ .../src/main/resources/logback.xml | 40 ++++ blade-service/logpm-factory-data/pom.xml | 1 + 59 files changed, 2742 insertions(+) create mode 100644 blade-service/logpm-factory-data/logpm-factory-data-paterson/pom.xml create mode 100644 blade-service/logpm-factory-data/logpm-factory-data-paterson/src/main/java/com/logpm/factorydata/FactoryDataPatersonApplication.java create mode 100644 blade-service/logpm-factory-data/logpm-factory-data-paterson/src/main/java/com/logpm/factorydata/paterson/aspect/AsyncAnnotationAspect.java create mode 100644 blade-service/logpm-factory-data/logpm-factory-data-paterson/src/main/java/com/logpm/factorydata/paterson/aspect/JobAnnotationAspect.java create mode 100644 blade-service/logpm-factory-data/logpm-factory-data-paterson/src/main/java/com/logpm/factorydata/paterson/aspect/RabbitAnnotationAspect.java create mode 100644 blade-service/logpm-factory-data/logpm-factory-data-paterson/src/main/java/com/logpm/factorydata/paterson/config/CustomMessageConverter.java create mode 100644 blade-service/logpm-factory-data/logpm-factory-data-paterson/src/main/java/com/logpm/factorydata/paterson/config/ExecutorConfig.java create mode 100644 blade-service/logpm-factory-data/logpm-factory-data-paterson/src/main/java/com/logpm/factorydata/paterson/config/FactoryDataPatersonConfiguration.java create mode 100644 blade-service/logpm-factory-data/logpm-factory-data-paterson/src/main/java/com/logpm/factorydata/paterson/config/InterceptorAdapterConfig.java create mode 100644 blade-service/logpm-factory-data/logpm-factory-data-paterson/src/main/java/com/logpm/factorydata/paterson/config/RabbitConfig.java create mode 100644 blade-service/logpm-factory-data/logpm-factory-data-paterson/src/main/java/com/logpm/factorydata/paterson/config/XxlJobConfig.java create mode 100644 blade-service/logpm-factory-data/logpm-factory-data-paterson/src/main/java/com/logpm/factorydata/paterson/controller/OrderController.java create mode 100644 blade-service/logpm-factory-data/logpm-factory-data-paterson/src/main/java/com/logpm/factorydata/paterson/entity/FactoryOrderEntity.java create mode 100644 blade-service/logpm-factory-data/logpm-factory-data-paterson/src/main/java/com/logpm/factorydata/paterson/entity/FactoryOrderLogEntity.java create mode 100644 blade-service/logpm-factory-data/logpm-factory-data-paterson/src/main/java/com/logpm/factorydata/paterson/entity/FactoryPackageEntity.java create mode 100644 blade-service/logpm-factory-data/logpm-factory-data-paterson/src/main/java/com/logpm/factorydata/paterson/entity/FactoryShipmentEntity.java create mode 100644 blade-service/logpm-factory-data/logpm-factory-data-paterson/src/main/java/com/logpm/factorydata/paterson/interceptor/FactoryAccountsInterceptor.java create mode 100644 blade-service/logpm-factory-data/logpm-factory-data-paterson/src/main/java/com/logpm/factorydata/paterson/launcher/FactoryDataBaseLauncherServiceImpl.java create mode 100644 blade-service/logpm-factory-data/logpm-factory-data-paterson/src/main/java/com/logpm/factorydata/paterson/mapper/FactoryOrderLogMapper.java create mode 100644 blade-service/logpm-factory-data/logpm-factory-data-paterson/src/main/java/com/logpm/factorydata/paterson/mapper/FactoryOrderLogMapper.xml create mode 100644 blade-service/logpm-factory-data/logpm-factory-data-paterson/src/main/java/com/logpm/factorydata/paterson/mapper/FactoryOrderMapper.java create mode 100644 blade-service/logpm-factory-data/logpm-factory-data-paterson/src/main/java/com/logpm/factorydata/paterson/mapper/FactoryOrderMapper.xml create mode 100644 blade-service/logpm-factory-data/logpm-factory-data-paterson/src/main/java/com/logpm/factorydata/paterson/mapper/FactoryPackageMapper.java create mode 100644 blade-service/logpm-factory-data/logpm-factory-data-paterson/src/main/java/com/logpm/factorydata/paterson/mapper/FactoryPackageMapper.xml create mode 100644 blade-service/logpm-factory-data/logpm-factory-data-paterson/src/main/java/com/logpm/factorydata/paterson/mapper/FactoryShipmentMapper.java create mode 100644 blade-service/logpm-factory-data/logpm-factory-data-paterson/src/main/java/com/logpm/factorydata/paterson/mapper/FactoryShipmentMapper.xml create mode 100644 blade-service/logpm-factory-data/logpm-factory-data-paterson/src/main/java/com/logpm/factorydata/paterson/mq/FactoryOrderListener.java create mode 100644 blade-service/logpm-factory-data/logpm-factory-data-paterson/src/main/java/com/logpm/factorydata/paterson/pros/FactoryDataPatersonProperties.java create mode 100644 blade-service/logpm-factory-data/logpm-factory-data-paterson/src/main/java/com/logpm/factorydata/paterson/pros/PatersonProperties.java create mode 100644 blade-service/logpm-factory-data/logpm-factory-data-paterson/src/main/java/com/logpm/factorydata/paterson/service/DeliveryNoteService.java create mode 100644 blade-service/logpm-factory-data/logpm-factory-data-paterson/src/main/java/com/logpm/factorydata/paterson/service/FactoryOrderLogService.java create mode 100644 blade-service/logpm-factory-data/logpm-factory-data-paterson/src/main/java/com/logpm/factorydata/paterson/service/FactoryOrderService.java create mode 100644 blade-service/logpm-factory-data/logpm-factory-data-paterson/src/main/java/com/logpm/factorydata/paterson/service/FactoryPackageService.java create mode 100644 blade-service/logpm-factory-data/logpm-factory-data-paterson/src/main/java/com/logpm/factorydata/paterson/service/FactoryShipmentService.java create mode 100644 blade-service/logpm-factory-data/logpm-factory-data-paterson/src/main/java/com/logpm/factorydata/paterson/service/MqWorkerService.java create mode 100644 blade-service/logpm-factory-data/logpm-factory-data-paterson/src/main/java/com/logpm/factorydata/paterson/service/impl/DeliveryNoteServiceImpl.java create mode 100644 blade-service/logpm-factory-data/logpm-factory-data-paterson/src/main/java/com/logpm/factorydata/paterson/service/impl/FactoryOrderLogServiceImpl.java create mode 100644 blade-service/logpm-factory-data/logpm-factory-data-paterson/src/main/java/com/logpm/factorydata/paterson/service/impl/FactoryOrderServiceImpl.java create mode 100644 blade-service/logpm-factory-data/logpm-factory-data-paterson/src/main/java/com/logpm/factorydata/paterson/service/impl/FactoryPackageServiceImpl.java create mode 100644 blade-service/logpm-factory-data/logpm-factory-data-paterson/src/main/java/com/logpm/factorydata/paterson/service/impl/FactoryShipmentServiceImpl.java create mode 100644 blade-service/logpm-factory-data/logpm-factory-data-paterson/src/main/java/com/logpm/factorydata/paterson/service/impl/MqWorkerServiceImpl.java create mode 100644 blade-service/logpm-factory-data/logpm-factory-data-paterson/src/main/java/com/logpm/factorydata/paterson/vo/FactoryAuthVO.java create mode 100644 blade-service/logpm-factory-data/logpm-factory-data-paterson/src/main/java/com/logpm/factorydata/paterson/vo/FactoryOrderDataVO.java create mode 100644 blade-service/logpm-factory-data/logpm-factory-data-paterson/src/main/java/com/logpm/factorydata/paterson/vo/FactoryOrderVO.java create mode 100644 blade-service/logpm-factory-data/logpm-factory-data-paterson/src/main/java/com/logpm/factorydata/paterson/vo/FactoryPackageVO.java create mode 100644 blade-service/logpm-factory-data/logpm-factory-data-paterson/src/main/java/com/logpm/factorydata/paterson/vo/FactoryShipmentVO.java create mode 100644 blade-service/logpm-factory-data/logpm-factory-data-paterson/src/main/java/com/logpm/factorydata/paterson/vo/PackageCategoryVO.java create mode 100644 blade-service/logpm-factory-data/logpm-factory-data-paterson/src/main/java/com/logpm/factorydata/paterson/vo/ThirdPlWarehouseMappingVO.java create mode 100644 blade-service/logpm-factory-data/logpm-factory-data-paterson/src/main/java/com/logpm/factorydata/paterson/wrapper/CustomHttpServletRequestWrapper.java create mode 100644 blade-service/logpm-factory-data/logpm-factory-data-paterson/src/main/java/com/logpm/factorydata/paterson/wrapper/RequestWrapper.java create mode 100644 blade-service/logpm-factory-data/logpm-factory-data-paterson/src/main/resources/application-dev.yml create mode 100644 blade-service/logpm-factory-data/logpm-factory-data-paterson/src/main/resources/application-prod.yml create mode 100644 blade-service/logpm-factory-data/logpm-factory-data-paterson/src/main/resources/application-test.yml create mode 100644 blade-service/logpm-factory-data/logpm-factory-data-paterson/src/main/resources/application.yml create mode 100644 blade-service/logpm-factory-data/logpm-factory-data-paterson/src/main/resources/logback.xml diff --git a/blade-biz-common/src/main/java/org/springblade/common/constant/ModuleNameConstant.java b/blade-biz-common/src/main/java/org/springblade/common/constant/ModuleNameConstant.java index ff9f81986..eecc4b6f7 100644 --- a/blade-biz-common/src/main/java/org/springblade/common/constant/ModuleNameConstant.java +++ b/blade-biz-common/src/main/java/org/springblade/common/constant/ModuleNameConstant.java @@ -106,6 +106,10 @@ public interface ModuleNameConstant { * 索菲亚工厂数据模块 */ String LOGPM_FACTORY_DATA_SUOFEIYA_NAME = "logpm-factory-data-suofeiya" + DEVAUTH; + /** + * 百得胜工厂数据模块 + */ + String LOGPM_FACTORY_DATA_PATERSON_NAME = "logpm-factory-data-paterson" + DEVAUTH; /** * 我乐工厂数据模块 */ diff --git a/blade-biz-common/src/main/java/org/springblade/common/constant/factorydata/FactoryDataConstants.java b/blade-biz-common/src/main/java/org/springblade/common/constant/factorydata/FactoryDataConstants.java index 28aee1439..7e03fa6a0 100644 --- a/blade-biz-common/src/main/java/org/springblade/common/constant/factorydata/FactoryDataConstants.java +++ b/blade-biz-common/src/main/java/org/springblade/common/constant/factorydata/FactoryDataConstants.java @@ -95,6 +95,10 @@ public abstract class FactoryDataConstants { String JP_NODE_DATA_PUSH = "factory.data.queue.jp.nodeDataPush" + DEVAUTH; String JP_FACTORY_ORDER = "factory.data.queue.jp.factoryOrder" + DEVAUTH; String JP_FACTORY_SHIPMENT = "factory.data.queue.jp.factoryShipment" + DEVAUTH; + /** + * 百得胜工厂订单 + */ + String BDS_FACTORY_SHIPMENT = "factory.data.queue.bds.factoryShipment" + DEVAUTH; /** * 皮阿诺作业节点数据推送 */ @@ -149,6 +153,10 @@ public abstract class FactoryDataConstants { String JP_NODE_DATA_PUSH = "jp.nodeDataPush" + DEVAUTH; String JP_FACTORY_ORDER = "jp.factoryOrder" + DEVAUTH; String JP_FACTORY_SHIPMENT = "jp.factoryShipment" + DEVAUTH; + /** + * 百得胜工厂订单 + */ + String BDS_FACTORY_SHIPMENT = "bds.factoryShipment" + DEVAUTH; /** * 皮阿诺作业节点数据推送 */ diff --git a/blade-service-api/logpm-factory-data-api/src/main/java/com/logpm/factorydata/enums/BrandEnums.java b/blade-service-api/logpm-factory-data-api/src/main/java/com/logpm/factorydata/enums/BrandEnums.java index bb50afe4a..77df15e6b 100644 --- a/blade-service-api/logpm-factory-data-api/src/main/java/com/logpm/factorydata/enums/BrandEnums.java +++ b/blade-service-api/logpm-factory-data-api/src/main/java/com/logpm/factorydata/enums/BrandEnums.java @@ -24,6 +24,7 @@ public enum BrandEnums implements Serializable { OLO(8, "我乐"), MHJ(9, "曼好家"), LINSY(10, "林氏家居"), + BDS(11, "百得胜"), ; private final Integer code; diff --git a/blade-service/logpm-factory-data/logpm-factory-data-paterson/pom.xml b/blade-service/logpm-factory-data/logpm-factory-data-paterson/pom.xml new file mode 100644 index 000000000..fb67b4865 --- /dev/null +++ b/blade-service/logpm-factory-data/logpm-factory-data-paterson/pom.xml @@ -0,0 +1,96 @@ + + 4.0.0 + + org.springblade + logpm-factory-data + 3.2.0.RELEASE + + + logpm-factory-data-paterson + ${bladex.project.version} + jar + + + 8 + 8 + + + + + org.springblade + blade-core-boot + + + org.springblade + blade-core-auto + provided + + + org.springframework.boot + spring-boot-starter-amqp + + + org.springblade + logpm-factory-data-api + 3.2.0.RELEASE + + + com.xuxueli + xxl-job-core + + + org.springblade + blade-starter-swagger + + + org.springblade + logpm-trunkline-api + 3.2.0.RELEASE + + + org.springblade + logpm-factory-data-base-api + ${bladex.project.version} + + + org.springblade + blade-starter-oss + + + io.minio + minio + + + org.springblade + blade-resource-api + 3.2.0.RELEASE + compile + + + + + + + com.spotify + dockerfile-maven-plugin + + ${docker.username} + ${docker.password} + ${docker.registry.url}/${docker.namespace}/${project.artifactId} + ${project.version} + true + + target/${project.build.finalName}.jar + + false + + + + org.apache.maven.plugins + maven-antrun-plugin + + + + + diff --git a/blade-service/logpm-factory-data/logpm-factory-data-paterson/src/main/java/com/logpm/factorydata/FactoryDataPatersonApplication.java b/blade-service/logpm-factory-data/logpm-factory-data-paterson/src/main/java/com/logpm/factorydata/FactoryDataPatersonApplication.java new file mode 100644 index 000000000..53b77acff --- /dev/null +++ b/blade-service/logpm-factory-data/logpm-factory-data-paterson/src/main/java/com/logpm/factorydata/FactoryDataPatersonApplication.java @@ -0,0 +1,20 @@ +package com.logpm.factorydata; + +import org.springblade.common.constant.ModuleNameConstant; +import org.springblade.core.cloud.client.BladeCloudApplication; +import org.springblade.core.launch.BladeApplication; + +/** + * 索菲亚工厂数据启动类 + * + * @author zhaoqiaobo + * @create 2024-4-26 + */ +@BladeCloudApplication +public class FactoryDataPatersonApplication { + + public static void main(String[] args) { + BladeApplication.run(ModuleNameConstant.LOGPM_FACTORY_DATA_PATERSON_NAME, FactoryDataPatersonApplication.class, args); + } + +} diff --git a/blade-service/logpm-factory-data/logpm-factory-data-paterson/src/main/java/com/logpm/factorydata/paterson/aspect/AsyncAnnotationAspect.java b/blade-service/logpm-factory-data/logpm-factory-data-paterson/src/main/java/com/logpm/factorydata/paterson/aspect/AsyncAnnotationAspect.java new file mode 100644 index 000000000..efad55d03 --- /dev/null +++ b/blade-service/logpm-factory-data/logpm-factory-data-paterson/src/main/java/com/logpm/factorydata/paterson/aspect/AsyncAnnotationAspect.java @@ -0,0 +1,50 @@ +package com.logpm.factorydata.paterson.aspect; + +import com.baomidou.dynamic.datasource.toolkit.DynamicDataSourceContextHolder; +import lombok.extern.slf4j.Slf4j; +import org.aspectj.lang.ProceedingJoinPoint; +import org.aspectj.lang.annotation.Aspect; +import org.aspectj.lang.reflect.MethodSignature; +import org.springblade.common.annotations.LogpmAsync; +import org.springblade.core.secure.utils.AuthUtil; +import org.springframework.core.annotation.Order; +import org.springframework.stereotype.Component; + +import java.lang.reflect.Method; + +@Aspect +@Component +@Slf4j +@Order(-1) +public class AsyncAnnotationAspect { + + /** + * 定义一个切点,匹配所有带有@LogpmAsync("asyncExecutor")注解的方法。 + * 注意:实际上Spring Framework自带对@LogpmAsync("asyncExecutor")的处理,直接这样配置可能会导致预期之外的行为。 + */ + //@Around("@annotation(org.springblade.common.annotations.LogpmAsync)") + public Object logAroundAsyncMethods(ProceedingJoinPoint joinPoint) throws Throwable { + + MethodSignature signature = (MethodSignature) joinPoint.getSignature(); + Method method = signature.getMethod(); + + LogpmAsync myAsync = method.getAnnotation(LogpmAsync.class); + String annotationValue = myAsync.value(); + log.info(">>>>>>>>>>>>>>>>>> annotationValue={}",annotationValue); + + log.info("@LogpmAsync注解的值为asyncExecutor,进行数据源切换 "); + + // 在方法执行前的操作 + String tenantId = AuthUtil.getTenantId(); + log.info(">> tenandId {} ",tenantId); + DynamicDataSourceContextHolder.push(tenantId); + + // 执行原方法 + Object result = joinPoint.proceed(); + + // 在方法执行后的操作 + DynamicDataSourceContextHolder.poll(); + return result; + } + +} diff --git a/blade-service/logpm-factory-data/logpm-factory-data-paterson/src/main/java/com/logpm/factorydata/paterson/aspect/JobAnnotationAspect.java b/blade-service/logpm-factory-data/logpm-factory-data-paterson/src/main/java/com/logpm/factorydata/paterson/aspect/JobAnnotationAspect.java new file mode 100644 index 000000000..ab555c054 --- /dev/null +++ b/blade-service/logpm-factory-data/logpm-factory-data-paterson/src/main/java/com/logpm/factorydata/paterson/aspect/JobAnnotationAspect.java @@ -0,0 +1,82 @@ +package com.logpm.factorydata.paterson.aspect; + +import com.alibaba.fastjson.JSONObject; +import com.baomidou.dynamic.datasource.toolkit.DynamicDataSourceContextHolder; +import lombok.AllArgsConstructor; +import org.aspectj.lang.ProceedingJoinPoint; +import org.aspectj.lang.annotation.Around; +import org.aspectj.lang.annotation.Aspect; +import org.springblade.common.cache.CacheNames; +import org.springblade.common.component.MockLoginService; +import org.springblade.common.utils.DefaultUserTokenConfig; +import org.springblade.core.redis.cache.BladeRedis; +import org.springblade.core.redis.lock.LockType; +import org.springblade.core.redis.lock.RedisLockClient; +import org.springblade.core.tool.utils.ThreadLocalUtil; +import org.springframework.core.env.Environment; +import org.springframework.http.HttpHeaders; +import org.springframework.mock.web.MockHttpServletRequest; +import org.springframework.stereotype.Component; +import org.springframework.web.context.request.RequestContextHolder; +import org.springframework.web.context.request.ServletRequestAttributes; + +import java.util.Objects; +import java.util.concurrent.TimeUnit; + +@Aspect +@Component +@AllArgsConstructor +public class JobAnnotationAspect { + private final BladeRedis bladeRedis; + private final Environment environment; + private final RedisLockClient redisLockClient; + private final MockLoginService mockLoginService; + + @Around("@annotation(com.xxl.job.core.handler.annotation.XxlJob)") + public Object xxlJobAnnotationMethods(ProceedingJoinPoint joinPoint) throws Throwable { + + + JSONObject jsonObject = mockLogin(); + MockHttpServletRequest mockRequest = new MockHttpServletRequest(); + mockRequest.addHeader("Blade-Auth", "bearer "+jsonObject.get("access_token")); + RequestContextHolder.setRequestAttributes(new ServletRequestAttributes(mockRequest)); + + HttpHeaders httpHeaders = new HttpHeaders(); + httpHeaders.add("Blade-Auth","bearer "+jsonObject.get("access_token") ); + httpHeaders.add( "Authorization", "Basic bG9jYWw6bG9jYWxfc2VjcmV0"); + ThreadLocalUtil.put("bladeContext", httpHeaders); + + DynamicDataSourceContextHolder.push(jsonObject.getString("tenant_id")); + // 执行原方法 + Object result = joinPoint.proceed(); + // 在方法执行后,从数据源上下文中移除租户ID + DynamicDataSourceContextHolder.poll(); + + return result; + + + } + + private JSONObject mockLogin() throws InterruptedException { + + String account ="shujutongbu"; + String tenantId ="627683"; + String key =CacheNames.LOCAL_SERVER_USER+tenantId+":"+account; + String lockKey =key+":lock"; + JSONObject data =bladeRedis.get(key); + if(Objects.isNull(data)){ + boolean flag = redisLockClient.tryLock(lockKey, LockType.FAIR, 5000, 10000, TimeUnit.MILLISECONDS); + if(flag){ + data =bladeRedis.get(key); + if(Objects.isNull(data)){ + data = mockLoginService.mockToken(tenantId,account); + bladeRedis.setEx(key,data, DefaultUserTokenConfig.EXPIRE_TIME); + redisLockClient.unLock(lockKey, LockType.FAIR); + } + } + } + return data; + } + + +} diff --git a/blade-service/logpm-factory-data/logpm-factory-data-paterson/src/main/java/com/logpm/factorydata/paterson/aspect/RabbitAnnotationAspect.java b/blade-service/logpm-factory-data/logpm-factory-data-paterson/src/main/java/com/logpm/factorydata/paterson/aspect/RabbitAnnotationAspect.java new file mode 100644 index 000000000..97646a66c --- /dev/null +++ b/blade-service/logpm-factory-data/logpm-factory-data-paterson/src/main/java/com/logpm/factorydata/paterson/aspect/RabbitAnnotationAspect.java @@ -0,0 +1,48 @@ +package com.logpm.factorydata.paterson.aspect; + +import com.baomidou.dynamic.datasource.toolkit.DynamicDataSourceContextHolder; +import lombok.extern.slf4j.Slf4j; +import org.aspectj.lang.ProceedingJoinPoint; +import org.aspectj.lang.annotation.Around; +import org.aspectj.lang.annotation.Aspect; +import org.springblade.core.secure.utils.AuthUtil; +import org.springframework.stereotype.Component; + +@Aspect +@Component +@Slf4j +public class RabbitAnnotationAspect { + + + /** + * 该方法为一个切面,用于对标记了@RabbitListener注解的方法进行增强,主要增加了日志记录和数据源上下文处理的功能。 + * + * @param joinPoint 切面的连接点,表示当前被拦截的方法。 + * @return 返回被拦截方法的执行结果。 + * @throws Throwable 如果执行过程中发生异常,则抛出。 + */ + @Around("@annotation(org.springframework.amqp.rabbit.annotation.RabbitListener)") + public Object rabbitMethods(ProceedingJoinPoint joinPoint) throws Throwable { + // 在方法执行前,获取当前租户ID并设置到数据源上下文中 + String tenantId = AuthUtil.getTenantId(); + DynamicDataSourceContextHolder.push(tenantId); + // 执行原方法 + Object result = joinPoint.proceed(); + // 在方法执行后,从数据源上下文中移除租户ID + DynamicDataSourceContextHolder.poll(); + return result; + } + + @Around("@annotation(org.springframework.amqp.rabbit.annotation.RabbitHandler)") + public Object rabbitHandlerMethods(ProceedingJoinPoint joinPoint) throws Throwable { + // 在方法执行前,获取当前租户ID并设置到数据源上下文中 + String tenantId = AuthUtil.getTenantId(); + DynamicDataSourceContextHolder.push(tenantId); + // 执行原方法 + Object result = joinPoint.proceed(); + // 在方法执行后,从数据源上下文中移除租户ID + DynamicDataSourceContextHolder.poll(); + return result; + } + +} diff --git a/blade-service/logpm-factory-data/logpm-factory-data-paterson/src/main/java/com/logpm/factorydata/paterson/config/CustomMessageConverter.java b/blade-service/logpm-factory-data/logpm-factory-data-paterson/src/main/java/com/logpm/factorydata/paterson/config/CustomMessageConverter.java new file mode 100644 index 000000000..e3e6d3c62 --- /dev/null +++ b/blade-service/logpm-factory-data/logpm-factory-data-paterson/src/main/java/com/logpm/factorydata/paterson/config/CustomMessageConverter.java @@ -0,0 +1,161 @@ +package com.logpm.factorydata.paterson.config; + +import cn.hutool.core.util.StrUtil; +import cn.hutool.json.JSONUtil; +import org.springblade.core.secure.BladeUser; +import org.springblade.core.secure.utils.AuthUtil; +import org.springblade.core.tool.utils.ThreadLocalUtil; +import org.springframework.amqp.core.Message; +import org.springframework.amqp.core.MessageProperties; +import org.springframework.amqp.support.converter.AllowedListDeserializingMessageConverter; +import org.springframework.amqp.support.converter.MessageConversionException; +import org.springframework.amqp.utils.SerializationUtils; +import org.springframework.beans.factory.BeanClassLoaderAware; +import org.springframework.http.HttpHeaders; +import org.springframework.mock.web.MockHttpServletRequest; +import org.springframework.remoting.rmi.CodebaseAwareObjectInputStream; +import org.springframework.stereotype.Component; +import org.springframework.util.ClassUtils; +import org.springframework.web.context.request.RequestContextHolder; +import org.springframework.web.context.request.ServletRequestAttributes; + +import java.io.ByteArrayInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.ObjectInputStream; +import java.io.ObjectStreamClass; +import java.io.Serializable; +import java.io.UnsupportedEncodingException; +import java.util.List; +import java.util.Map; + +/** + * @author zhaoqiaobo + * @create 2024-05-08 + */ +@Component +public class CustomMessageConverter extends AllowedListDeserializingMessageConverter implements BeanClassLoaderAware { + + private volatile String defaultCharset = "UTF-8"; + private ClassLoader beanClassLoader = ClassUtils.getDefaultClassLoader(); + private String codebaseUrl; + + @Deprecated + public void setCodebaseUrl(String codebaseUrl) { + this.codebaseUrl = codebaseUrl; + } + + @Override + public Object fromMessage(Message message) throws MessageConversionException { + Object content = null; + MessageProperties properties = message.getMessageProperties(); + if (properties != null) { + String contentType = properties.getContentType(); + if (contentType != null && contentType.startsWith("text")) { + String encoding = properties.getContentEncoding(); + if (encoding == null) { + encoding = "UTF-8"; + } + + try { + content = new String(message.getBody(), encoding); + } catch (UnsupportedEncodingException var8) { + throw new MessageConversionException("failed to convert text-based Message content", var8); + } + } else if (contentType != null && contentType.equals("application/x-java-serialized-object")) { + try { + content = SerializationUtils.deserialize(this.createObjectInputStream(new ByteArrayInputStream(message.getBody()), this.codebaseUrl)); + } catch (IllegalArgumentException | IllegalStateException | IOException var7) { + throw new MessageConversionException("failed to convert serialized Message content", var7); + } + } + } + Map headers = properties.getHeaders(); + HttpHeaders httpHeaders = new HttpHeaders(); + for (Map.Entry entry : headers.entrySet()) { + if (StrUtil.equals("Blade-Auth", entry.getKey()) + || StrUtil.equals("Authorization", entry.getKey()) + || StrUtil.equals("blade-auth", entry.getKey()) + || StrUtil.equals("authorization", entry.getKey())) { + List value = (List) entry.getValue(); + for (Object o : value) { + httpHeaders.add(entry.getKey(), String.valueOf(o)); + } + } + } + ThreadLocalUtil.put("bladeContext", httpHeaders); + Object bladeUser = headers.get("bladeUser"); + MockHttpServletRequest request = new MockHttpServletRequest(); + BladeUser bladeUser1 = JSONUtil.toBean(bladeUser.toString(), BladeUser.class); + request.setAttribute("_BLADE_USER_REQUEST_ATTR_", bladeUser1); + RequestContextHolder.setRequestAttributes(new ServletRequestAttributes(request)); + if (content == null) { + content = message.getBody(); + } + return content; + } + + @Override + protected Message createMessage(Object object, MessageProperties messageProperties) throws MessageConversionException { + byte[] bytes = null; + if (object instanceof byte[]) { + bytes = (byte[]) object; + messageProperties.setContentType("application/octet-stream"); + } else if (object instanceof String) { + try { + bytes = ((String) object).getBytes(this.defaultCharset); + } catch (UnsupportedEncodingException var6) { + throw new MessageConversionException("failed to convert to Message content", var6); + } + + messageProperties.setContentType("text/plain"); + messageProperties.setContentEncoding(this.defaultCharset); + } else if (object instanceof Serializable) { + try { + bytes = SerializationUtils.serialize(object); + } catch (IllegalArgumentException var5) { + throw new MessageConversionException("failed to convert to serialized Message content", var5); + } + + messageProperties.setContentType("application/x-java-serialized-object"); + } + HttpHeaders headers = (HttpHeaders) ThreadLocalUtil.get("bladeContext"); + if (headers != null && !headers.isEmpty()) { + headers.forEach((key, values) -> { + values.forEach((value) -> { + messageProperties.setHeader(key, new String[]{value}); + }); + }); + } + BladeUser user = AuthUtil.getUser(); + BladeUser bladeUser = new BladeUser(); + bladeUser.setTenantId(user.getTenantId()); + bladeUser.setUserId(user.getUserId()); + bladeUser.setAccount(user.getAccount()); + bladeUser.setRoleId(user.getRoleId()); + messageProperties.setHeader("bladeUser", JSONUtil.toJsonStr(bladeUser)); + + if (bytes != null) { + messageProperties.setContentLength((long) bytes.length); + return new Message(bytes, messageProperties); + } else { + throw new IllegalArgumentException(this.getClass().getSimpleName() + " only supports String, byte[] and Serializable payloads, received: " + object.getClass().getName()); + } + } + + @Override + public void setBeanClassLoader(ClassLoader classLoader) { + this.beanClassLoader = beanClassLoader; + } + + protected ObjectInputStream createObjectInputStream(InputStream is, String codebaseUrl) throws IOException { + return new CodebaseAwareObjectInputStream(is, this.beanClassLoader, codebaseUrl) { + @Override + protected Class resolveClass(ObjectStreamClass classDesc) throws IOException, ClassNotFoundException { + Class clazz = super.resolveClass(classDesc); + CustomMessageConverter.this.checkAllowedList(clazz); + return clazz; + } + }; + } +} diff --git a/blade-service/logpm-factory-data/logpm-factory-data-paterson/src/main/java/com/logpm/factorydata/paterson/config/ExecutorConfig.java b/blade-service/logpm-factory-data/logpm-factory-data-paterson/src/main/java/com/logpm/factorydata/paterson/config/ExecutorConfig.java new file mode 100644 index 000000000..422152972 --- /dev/null +++ b/blade-service/logpm-factory-data/logpm-factory-data-paterson/src/main/java/com/logpm/factorydata/paterson/config/ExecutorConfig.java @@ -0,0 +1,85 @@ +package com.logpm.factorydata.paterson.config; + +import com.baomidou.dynamic.datasource.toolkit.DynamicDataSourceContextHolder; +import lombok.extern.slf4j.Slf4j; +import org.slf4j.MDC; +import org.springblade.core.secure.utils.AuthUtil; +import org.springblade.core.tool.utils.ThreadLocalUtil; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.core.task.TaskDecorator; +import org.springframework.scheduling.annotation.EnableAsync; +import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor; +import org.springframework.web.context.request.RequestAttributes; +import org.springframework.web.context.request.RequestContextHolder; + +import javax.annotation.Nonnull; +import java.util.Map; +import java.util.concurrent.Executor; +import java.util.concurrent.ThreadPoolExecutor; + +@Configuration +@Slf4j +@EnableAsync +public class ExecutorConfig { + + @Bean + public Executor asyncExecutor() { + log.info("start async executor"); + ThreadPoolTaskExecutor threadPoolTaskExecutor = new ThreadPoolTaskExecutor(); +// 配置核心线程数 + threadPoolTaskExecutor.setCorePoolSize(10); +// 配置最大线程数 + threadPoolTaskExecutor.setMaxPoolSize(20); +// 配置队列大小 + threadPoolTaskExecutor.setQueueCapacity(50); +// 配置线程池中线程的名称前缀 + threadPoolTaskExecutor.setThreadNamePrefix("ASYNC_THREAD_"); +// HelloWorldServiceImpl rejection-policy: 当pool已经达到max size时,如何处理新任务: +// CallerRunsPolicy: 不在新线程中执行任务,而是由调用者所在的线程来执行; +// AbortPolicy: 拒绝执行新任务,并抛出RejectedExecutionException异常; +// DiscardPolicy:丢弃当前将要加入队列的任务; +// DiscardOldestPolicy:丢弃任务队列中最旧的任务; + threadPoolTaskExecutor.setRejectedExecutionHandler( + new ThreadPoolExecutor.CallerRunsPolicy() + ); + threadPoolTaskExecutor.setTaskDecorator(new ContextCopyingDecorator()); + threadPoolTaskExecutor.initialize(); + return threadPoolTaskExecutor; + } + + + static class ContextCopyingDecorator implements TaskDecorator { + @Nonnull + @Override + public Runnable decorate(@Nonnull Runnable runnable) { + RequestAttributes context = RequestContextHolder.currentRequestAttributes(); + String tenantId = AuthUtil.getTenantId(); + Map all = ThreadLocalUtil.getAll(); + Map mdcMap = MDC.getCopyOfContextMap(); + return () -> { + try { + all.keySet().forEach(key -> ThreadLocalUtil.put(key, all.get(key))); + if (mdcMap != null && !mdcMap.isEmpty()) { + MDC.setContextMap(mdcMap); + } + RequestContextHolder.setRequestAttributes(context); + // 未当前的异步线程绑定租户ID 和切换数据源 + log.info(">>>> 异步线程创建,绑定租户数据源 {}",tenantId); + DynamicDataSourceContextHolder.push(tenantId); + runnable.run(); + } finally { + RequestContextHolder.resetRequestAttributes(); + all.clear(); + if (mdcMap != null) { + mdcMap.clear(); + } + ThreadLocalUtil.clear(); + MDC.clear(); + DynamicDataSourceContextHolder.poll(); + } + }; + } + } + +} diff --git a/blade-service/logpm-factory-data/logpm-factory-data-paterson/src/main/java/com/logpm/factorydata/paterson/config/FactoryDataPatersonConfiguration.java b/blade-service/logpm-factory-data/logpm-factory-data-paterson/src/main/java/com/logpm/factorydata/paterson/config/FactoryDataPatersonConfiguration.java new file mode 100644 index 000000000..4bf093f44 --- /dev/null +++ b/blade-service/logpm-factory-data/logpm-factory-data-paterson/src/main/java/com/logpm/factorydata/paterson/config/FactoryDataPatersonConfiguration.java @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2018-2028, Chill Zhuang All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the dreamlu.net developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: Chill 庄骞 (smallchill@163.com) + */ +package com.logpm.factorydata.paterson.config; + + +import com.logpm.factorydata.paterson.pros.FactoryDataPatersonProperties; +import org.mybatis.spring.annotation.MapperScan; +import org.springframework.boot.context.properties.EnableConfigurationProperties; +import org.springframework.cloud.openfeign.EnableFeignClients; +import org.springframework.context.annotation.ComponentScan; +import org.springframework.context.annotation.Configuration; + +/** + * 配置feign、mybatis包名、properties + * + * @author chaos + */ +@Configuration(proxyBeanMethods = false) +@ComponentScan({"org.springblade", "com.logpm"}) +@EnableFeignClients({"org.springblade", "com.logpm"}) +@MapperScan({"org.springblade.**.mapper.**", "com.logpm.**.mapper.**"}) +@EnableConfigurationProperties(FactoryDataPatersonProperties.class) +public class FactoryDataPatersonConfiguration { + + +} diff --git a/blade-service/logpm-factory-data/logpm-factory-data-paterson/src/main/java/com/logpm/factorydata/paterson/config/InterceptorAdapterConfig.java b/blade-service/logpm-factory-data/logpm-factory-data-paterson/src/main/java/com/logpm/factorydata/paterson/config/InterceptorAdapterConfig.java new file mode 100644 index 000000000..cfb1081fe --- /dev/null +++ b/blade-service/logpm-factory-data/logpm-factory-data-paterson/src/main/java/com/logpm/factorydata/paterson/config/InterceptorAdapterConfig.java @@ -0,0 +1,39 @@ +package com.logpm.factorydata.paterson.config; + +import com.logpm.factorydata.paterson.interceptor.FactoryAccountsInterceptor; +import com.logpm.factorydata.paterson.pros.PatersonProperties; +import com.logpm.factorydata.paterson.service.FactoryShipmentService; +import org.springblade.common.component.MockLoginService; +import org.springblade.core.redis.cache.BladeRedis; +import org.springblade.core.redis.lock.RedisLockClient; +import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.Lazy; +import org.springframework.core.env.Environment; +import org.springframework.web.servlet.config.annotation.InterceptorRegistry; +import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; + +import javax.annotation.Resource; + +@Configuration +public class InterceptorAdapterConfig implements WebMvcConfigurer { + + @Resource + private BladeRedis redis; + @Resource + private Environment environment; + @Resource + private RedisLockClient redisLockClient; + @Resource + private MockLoginService mockLoginService; + @Lazy + @Resource + private FactoryShipmentService jpFactoryShipmentService; + @Resource + private PatersonProperties jinPaiProperties; + + @Override + public void addInterceptors(InterceptorRegistry interceptorRegistry) { + interceptorRegistry.addInterceptor(new FactoryAccountsInterceptor(redis, environment, redisLockClient, mockLoginService, jinPaiProperties, jpFactoryShipmentService)) + .addPathPatterns("/order/v1").order(3); + } +} diff --git a/blade-service/logpm-factory-data/logpm-factory-data-paterson/src/main/java/com/logpm/factorydata/paterson/config/RabbitConfig.java b/blade-service/logpm-factory-data/logpm-factory-data-paterson/src/main/java/com/logpm/factorydata/paterson/config/RabbitConfig.java new file mode 100644 index 000000000..720e81e08 --- /dev/null +++ b/blade-service/logpm-factory-data/logpm-factory-data-paterson/src/main/java/com/logpm/factorydata/paterson/config/RabbitConfig.java @@ -0,0 +1,17 @@ +package com.logpm.factorydata.paterson.config; + +import org.springframework.amqp.rabbit.connection.ConnectionFactory; +import org.springframework.amqp.rabbit.core.RabbitTemplate; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + +@Configuration +public class RabbitConfig { + + @Bean + public RabbitTemplate rabbitTemplate(ConnectionFactory factory) { + RabbitTemplate template = new RabbitTemplate(factory); + template.setMessageConverter(new CustomMessageConverter()); + return template; + } +} diff --git a/blade-service/logpm-factory-data/logpm-factory-data-paterson/src/main/java/com/logpm/factorydata/paterson/config/XxlJobConfig.java b/blade-service/logpm-factory-data/logpm-factory-data-paterson/src/main/java/com/logpm/factorydata/paterson/config/XxlJobConfig.java new file mode 100644 index 000000000..b8530a863 --- /dev/null +++ b/blade-service/logpm-factory-data/logpm-factory-data-paterson/src/main/java/com/logpm/factorydata/paterson/config/XxlJobConfig.java @@ -0,0 +1,74 @@ +package com.logpm.factorydata.paterson.config; + +import com.xxl.job.core.executor.impl.XxlJobSpringExecutor; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + +/** + * xxl-job config + * + * @author xuxueli 2017-04-28 + */ +@Configuration(proxyBeanMethods = false) +public class XxlJobConfig { + private final Logger logger = LoggerFactory.getLogger(XxlJobConfig.class); + + @Value("${xxl.job.admin.addresses}") + private String adminAddresses; + + @Value("${xxl.job.executor.appname}") + private String appName; + + @Value("${xxl.job.executor.ip}") + private String ip; + + @Value("${xxl.job.executor.port}") + private int port; + + @Value("${xxl.job.accessToken}") + private String accessToken; + + @Value("${xxl.job.executor.logpath}") + private String logPath; + + @Value("${xxl.job.executor.logretentiondays}") + private int logRetentionDays; + + + @Bean + public XxlJobSpringExecutor xxlJobExecutor() { + logger.info(">>>>>>>>>>> xxl-job config init."); + XxlJobSpringExecutor xxlJobSpringExecutor = new XxlJobSpringExecutor(); + xxlJobSpringExecutor.setAdminAddresses(adminAddresses); + xxlJobSpringExecutor.setAppName(appName); + xxlJobSpringExecutor.setIp(ip); + xxlJobSpringExecutor.setPort(port); + xxlJobSpringExecutor.setAccessToken(accessToken); + xxlJobSpringExecutor.setLogPath(logPath); + xxlJobSpringExecutor.setLogRetentionDays(logRetentionDays); + + return xxlJobSpringExecutor; + } + + /** + * 针对多网卡、容器内部署等情况,可借助 "spring-cloud-commons" 提供的 "InetUtils" 组件灵活定制注册IP; + * + * 1、引入依赖: + * + * org.springframework.cloud + * spring-cloud-commons + * ${version} + * + * + * 2、配置文件,或者容器启动变量 + * spring.cloud.inetutils.preferred-networks: 'xxx.xxx.xxx.' + * + * 3、获取IP + * String ip_ = inetUtils.findFirstNonLoopbackHostInfo().getIpAddress(); + */ + + +} diff --git a/blade-service/logpm-factory-data/logpm-factory-data-paterson/src/main/java/com/logpm/factorydata/paterson/controller/OrderController.java b/blade-service/logpm-factory-data/logpm-factory-data-paterson/src/main/java/com/logpm/factorydata/paterson/controller/OrderController.java new file mode 100644 index 000000000..6342a92f1 --- /dev/null +++ b/blade-service/logpm-factory-data/logpm-factory-data-paterson/src/main/java/com/logpm/factorydata/paterson/controller/OrderController.java @@ -0,0 +1,64 @@ +package com.logpm.factorydata.paterson.controller; + +import cn.hutool.core.util.ObjectUtil; +import cn.hutool.core.util.StrUtil; +import cn.hutool.json.JSONUtil; +import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; +import com.logpm.factorydata.paterson.service.FactoryShipmentService; +import com.logpm.factorydata.paterson.vo.FactoryOrderDataVO; +import com.logpm.factorydata.paterson.vo.FactoryShipmentVO; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import lombok.AllArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springblade.core.tool.api.R; +import org.springframework.context.annotation.Lazy; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.ResponseBody; +import org.springframework.web.bind.annotation.RestController; + +import javax.annotation.Resource; + +/** + * 工厂订单 前端控制器 + * + * @author zhaoqiaobo + * @create 2024-03-21 19:27 + */ +@Slf4j +@RestController +@RequestMapping("/order") +@AllArgsConstructor +@Api(value = "工厂订单", tags = "工厂订单") +public class OrderController { + + @Lazy + @Resource + private FactoryShipmentService shipmentService; + + @ResponseBody + @PostMapping("/v1") + @ApiOperationSupport(order = 1) + @ApiOperation(value = "百得胜-工厂订单", notes = "百得胜-工厂订单") + public R orderV1(@RequestBody FactoryOrderDataVO vo) { + String jsonStr = JSONUtil.toJsonStr(vo); + log.info("接收百得胜工厂订单:{} ", jsonStr); + String res = ""; + try { + String params = vo.getParams(); + if(StrUtil.isNotEmpty(params)){ + FactoryShipmentVO bean = JSONUtil.toBean(params, FactoryShipmentVO.class); + if (ObjectUtil.isNotEmpty(bean)) { + res = shipmentService.shipment(bean); + } + } + } catch (Exception e) { + log.error("百得胜工厂订单异常:{} ", e); + return R.fail("服务器异常"); + } + return R.success(res); + } + +} diff --git a/blade-service/logpm-factory-data/logpm-factory-data-paterson/src/main/java/com/logpm/factorydata/paterson/entity/FactoryOrderEntity.java b/blade-service/logpm-factory-data/logpm-factory-data-paterson/src/main/java/com/logpm/factorydata/paterson/entity/FactoryOrderEntity.java new file mode 100644 index 000000000..72e01d7fc --- /dev/null +++ b/blade-service/logpm-factory-data/logpm-factory-data-paterson/src/main/java/com/logpm/factorydata/paterson/entity/FactoryOrderEntity.java @@ -0,0 +1,88 @@ +package com.logpm.factorydata.paterson.entity; + +import com.baomidou.mybatisplus.annotation.TableName; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.EqualsAndHashCode; +import org.springblade.core.mp.base.BaseEntity; + +/** + * 百得胜工厂订单 实体类 + * + * @author zhaoqiaobo + * @create 2024-04-26 + */ +@Data +@TableName("bds_factory_order") +@ApiModel(value = "百得胜工厂订单", description = "百得胜工厂订单") +@EqualsAndHashCode(callSuper = true) +public class FactoryOrderEntity extends BaseEntity { + + @ApiModelProperty(name = "日志id") + private String logId; + @ApiModelProperty(name = "发货单id") + private Long shipmentId; + @ApiModelProperty(name = "订单号") + private String orderCode; + @ApiModelProperty(name = "交割单号/服务号") + private String serviceNum; + @ApiModelProperty(name = "服务类型") + private String serverType; + @ApiModelProperty(name = "结算方式") + private String settlementType; + @ApiModelProperty(name = "是否补件") + private String supplement; + @ApiModelProperty(name = "发运方式") + private String shipVia; + @ApiModelProperty(name = "订单总件数") + private Integer totalQuantity; + @ApiModelProperty(name = "商场名称") + private String mallName; + @ApiModelProperty(name = "商场编码") + private String mallCode; + @ApiModelProperty(name = "商场电话") + private String mallMobile; + @ApiModelProperty(name = "商场地址") + private String mallAddress; + @ApiModelProperty(name = "商场收货人") + private String mallConsignee; + @ApiModelProperty(name = "商场收货人电话") + private String mallConsigneeMobile; + @ApiModelProperty(name = "门店名称") + private String storeName; + @ApiModelProperty(name = "门店编码") + private String storeCode; + @ApiModelProperty(name = "门店电话") + private String storeMobile; + @ApiModelProperty(name = "门店地址") + private String storeAddress; + @ApiModelProperty(name = "门店收货人") + private String storeConsignee; + @ApiModelProperty(name = "门店收货人电话") + private String storeConsigneeMobile; + @ApiModelProperty(name = "终端收货人") + private String receiverName; + @ApiModelProperty(name = "终端收货人电话") + private String receiverMobile; + @ApiModelProperty(name = "终端收货人地址") + private String receiverAddress; + @ApiModelProperty(name = "备注") + private String remark; + @ApiModelProperty(name = "是否确认") + private Boolean checked; + @ApiModelProperty(name = "租户") + private String tenantCode; + + @ApiModelProperty(name = "预留1", notes = "") + private String reserve1; + @ApiModelProperty(name = "预留2", notes = "") + private String reserve2; + @ApiModelProperty(name = "预留3", notes = "") + private String reserve3; + @ApiModelProperty(name = "预留4", notes = "") + private String reserve4; + @ApiModelProperty(name = "预留5", notes = "") + private String reserve5; + +} diff --git a/blade-service/logpm-factory-data/logpm-factory-data-paterson/src/main/java/com/logpm/factorydata/paterson/entity/FactoryOrderLogEntity.java b/blade-service/logpm-factory-data/logpm-factory-data-paterson/src/main/java/com/logpm/factorydata/paterson/entity/FactoryOrderLogEntity.java new file mode 100644 index 000000000..b4af6c9cf --- /dev/null +++ b/blade-service/logpm-factory-data/logpm-factory-data-paterson/src/main/java/com/logpm/factorydata/paterson/entity/FactoryOrderLogEntity.java @@ -0,0 +1,63 @@ +package com.logpm.factorydata.paterson.entity; + +import com.baomidou.mybatisplus.annotation.TableName; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.EqualsAndHashCode; +import org.springblade.core.mp.base.BaseEntity; + +@Data +@TableName("bds_factory_log") +@ApiModel(value = "接收工厂订单日志", description = "接收工厂订单日志") +@EqualsAndHashCode(callSuper = true) +public class FactoryOrderLogEntity extends BaseEntity { + + /** + * 预留1 + */ + @ApiModelProperty(name = "预留1", notes = "") + private String reserve1; + /** + * 预留2 + */ + @ApiModelProperty(name = "预留2", notes = "") + private String reserve2; + /** + * 预留3 + */ + @ApiModelProperty(name = "预留3", notes = "") + private String reserve3; + /** + * 预留4 + */ + @ApiModelProperty(name = "预留4", notes = "") + private String reserve4; + /** + * 预留5 + */ + @ApiModelProperty(name = "预留5", notes = "") + private String reserve5; + /** + * 日志文件存放地址 + */ + @ApiModelProperty(name = "日志文件存放地址", notes = "") + private String logUrl; + /** + * 数据类型 1.拉取数据 2。推送数据 + */ + @ApiModelProperty(name = "数据类型 1.拉取数据 2。推送数据", notes = "") + private Integer type; + /** + * 数据维度:1 订单 2 订单明细 3 包件 + */ + @ApiModelProperty(name = "维度:1 订单 2 订单明细 3 包件", notes = "") + private Integer dimension; + /** + * 解析状态 0 未解析 1 解析失败 2 已解析 + */ + @ApiModelProperty(name = "解析状态 0 未解析 1 解析失败 2 已解析", notes = "") + private Integer saxStatus; + + +} diff --git a/blade-service/logpm-factory-data/logpm-factory-data-paterson/src/main/java/com/logpm/factorydata/paterson/entity/FactoryPackageEntity.java b/blade-service/logpm-factory-data/logpm-factory-data-paterson/src/main/java/com/logpm/factorydata/paterson/entity/FactoryPackageEntity.java new file mode 100644 index 000000000..ecc9f87d7 --- /dev/null +++ b/blade-service/logpm-factory-data/logpm-factory-data-paterson/src/main/java/com/logpm/factorydata/paterson/entity/FactoryPackageEntity.java @@ -0,0 +1,72 @@ +package com.logpm.factorydata.paterson.entity; + +import com.baomidou.mybatisplus.annotation.TableName; +import com.fasterxml.jackson.annotation.JsonProperty; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.EqualsAndHashCode; +import org.springblade.core.mp.base.BaseEntity; + +/** + * 百得胜工厂包件 实体类 + * + * @author zhaoqiaobo + * @create 2024-04-26 + */ +@Data +@TableName("bds_factory_package") +@ApiModel(value = "百得胜工厂包件", description = "百得胜工厂包件") +@EqualsAndHashCode(callSuper = true) +public class FactoryPackageEntity extends BaseEntity { + + @ApiModelProperty(name = "日志id") + private String logId; + @ApiModelProperty(name = "订单id") + private Long orderId; + @ApiModelProperty(name = "是否合包") + @JsonProperty("isConsolidation") + private String consolidation; + @ApiModelProperty(name = "合包码") + private String consolidationCode; + @ApiModelProperty(name = "包件码") + private String unitNo; + @ApiModelProperty(name = "产品编号") + private String productCode; + @ApiModelProperty(name = "产品名称") + private String productName; + @ApiModelProperty(name = "件数") + private Integer quantity; + @ApiModelProperty(name = "体积") + private Double volume; + @ApiModelProperty(name = "重量") + private Double weight; + @ApiModelProperty(name = "一级品类名称") + private String firstPackName; + @ApiModelProperty(name = "一级品类编码") + private String firstPackCode; + @ApiModelProperty(name = "二级品类名称") + private String secondPackName; + @ApiModelProperty(name = "二级品类编码") + private String secondPackCode; + @ApiModelProperty(name = "三级品类名称") + private String thirdPackName; + @ApiModelProperty(name = "三级品类编码") + private String thirdPackCode; + @ApiModelProperty(name = "是否确认") + private Boolean checked; + @ApiModelProperty(name = "租户") + private String tenantCode; + + @ApiModelProperty(name = "预留1", notes = "") + private String reserve1; + @ApiModelProperty(name = "预留2", notes = "") + private String reserve2; + @ApiModelProperty(name = "预留3", notes = "") + private String reserve3; + @ApiModelProperty(name = "预留4", notes = "") + private String reserve4; + @ApiModelProperty(name = "预留5", notes = "") + private String reserve5; + +} diff --git a/blade-service/logpm-factory-data/logpm-factory-data-paterson/src/main/java/com/logpm/factorydata/paterson/entity/FactoryShipmentEntity.java b/blade-service/logpm-factory-data/logpm-factory-data-paterson/src/main/java/com/logpm/factorydata/paterson/entity/FactoryShipmentEntity.java new file mode 100644 index 000000000..78b9f3f26 --- /dev/null +++ b/blade-service/logpm-factory-data/logpm-factory-data-paterson/src/main/java/com/logpm/factorydata/paterson/entity/FactoryShipmentEntity.java @@ -0,0 +1,64 @@ +package com.logpm.factorydata.paterson.entity; + +import com.baomidou.mybatisplus.annotation.TableName; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.EqualsAndHashCode; +import org.springblade.core.mp.base.BaseEntity; + +/** + * 百得胜工厂发货单 实体类 + * + * @author zhaoqiaobo + * @create 2024-04-26 + */ +@Data +@TableName("bds_factory_shipment") +@ApiModel(value = "百得胜工厂发货单", description = "百得胜工厂发货单") +@EqualsAndHashCode(callSuper = true) +public class FactoryShipmentEntity extends BaseEntity { + + @ApiModelProperty(name = "日志id") + private String logId; + @ApiModelProperty(name = "发货单号") + private String shipmentId; + @ApiModelProperty(name = "物流公司编码") + private String carrierCode; + @ApiModelProperty(name = "物流公司名称") + private String carrierName; + @ApiModelProperty(name = "发货基地") + private String shipmentHub; + @ApiModelProperty(name = "计划发车时间") + private String planStartTime; + @ApiModelProperty(name = "计划到达时间") + private String planEndTime; + @ApiModelProperty(name = "司机") + private String driverName; + @ApiModelProperty(name = "司机电话") + private String driverMobile; + @ApiModelProperty(name = "车牌") + private String carNumber; + @ApiModelProperty(name = "发货人名称") + private String senderName; + @ApiModelProperty(name = "发货人电话") + private String senderMobile; + @ApiModelProperty(name = "发货人地址") + private String senderAddress; + @ApiModelProperty(name = "是否确认") + private Boolean checked; + @ApiModelProperty(name = "租户") + private String tenantCode; + + @ApiModelProperty(name = "预留1", notes = "") + private String reserve1; + @ApiModelProperty(name = "预留2", notes = "") + private String reserve2; + @ApiModelProperty(name = "预留3", notes = "") + private String reserve3; + @ApiModelProperty(name = "预留4", notes = "") + private String reserve4; + @ApiModelProperty(name = "预留5", notes = "") + private String reserve5; + +} diff --git a/blade-service/logpm-factory-data/logpm-factory-data-paterson/src/main/java/com/logpm/factorydata/paterson/interceptor/FactoryAccountsInterceptor.java b/blade-service/logpm-factory-data/logpm-factory-data-paterson/src/main/java/com/logpm/factorydata/paterson/interceptor/FactoryAccountsInterceptor.java new file mode 100644 index 000000000..7097255c3 --- /dev/null +++ b/blade-service/logpm-factory-data/logpm-factory-data-paterson/src/main/java/com/logpm/factorydata/paterson/interceptor/FactoryAccountsInterceptor.java @@ -0,0 +1,180 @@ +package com.logpm.factorydata.paterson.interceptor; + +import cn.hutool.core.codec.Base64; +import cn.hutool.core.util.ObjectUtil; +import cn.hutool.core.util.StrUtil; +import cn.hutool.crypto.digest.MD5; +import com.alibaba.fastjson.JSONObject; +import com.logpm.factorydata.paterson.pros.PatersonProperties; +import com.logpm.factorydata.paterson.service.FactoryShipmentService; +import com.logpm.factorydata.paterson.vo.FactoryAuthVO; +import com.logpm.factorydata.paterson.wrapper.RequestWrapper; +import lombok.NoArgsConstructor; +import lombok.extern.log4j.Log4j2; +import org.springblade.common.cache.CacheNames; +import org.springblade.common.component.MockLoginService; +import org.springblade.common.exception.CustomerException; +import org.springblade.common.utils.DefaultUserTokenConfig; +import org.springblade.common.wrapper.CustomHttpServletRequestWrapper; +import org.springblade.core.redis.cache.BladeRedis; +import org.springblade.core.redis.lock.LockType; +import org.springblade.core.redis.lock.RedisLockClient; +import org.springblade.core.tool.api.R; +import org.springblade.core.tool.utils.StringUtil; +import org.springblade.core.tool.utils.ThreadLocalUtil; +import org.springframework.context.annotation.Lazy; +import org.springframework.core.env.Environment; +import org.springframework.http.HttpHeaders; +import org.springframework.web.context.request.RequestContextHolder; +import org.springframework.web.context.request.ServletRequestAttributes; +import org.springframework.web.servlet.HandlerInterceptor; +import org.springframework.web.servlet.ModelAndView; + +import javax.annotation.Resource; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; +import java.io.PrintWriter; +import java.time.Instant; +import java.util.Objects; +import java.util.concurrent.TimeUnit; + +@Log4j2 +@NoArgsConstructor +public class FactoryAccountsInterceptor implements HandlerInterceptor { + + @Resource + private BladeRedis bladeRedis; + @Resource + private Environment environment; + @Resource + private RedisLockClient redisLockClient; + @Resource + private MockLoginService mockLoginService; + @Resource + private PatersonProperties jinPaiProperties; + @Resource + @Lazy + private FactoryShipmentService jpFactoryShipmentService; + + public FactoryAccountsInterceptor(BladeRedis redis, Environment environment, RedisLockClient redisLockClient, MockLoginService mockLoginService, PatersonProperties suoFeiYaProperties, FactoryShipmentService deliveryNoteService) { + this.bladeRedis = redis; + this.environment = environment; + this.redisLockClient = redisLockClient; + this.mockLoginService = mockLoginService; + this.jinPaiProperties = suoFeiYaProperties; + this.jpFactoryShipmentService = deliveryNoteService; + } + + @Override + public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws CustomerException { + try { + log.info("##########preHandle: 认证开始--------------"); + RequestWrapper myRequestWrapper = new RequestWrapper(request); + String body = myRequestWrapper.getBody(); + log.info("##########preHandle: body={}", body); + JSONObject jsonObject = JSONObject.parseObject(body); + // 获取头中参数 + String companyCode = jsonObject.getString("companyCode"); + String params = jsonObject.getString("params"); + String sign = jsonObject.getString("digest"); + Long authTime = jsonObject.getLong("timestamp"); + if (ObjectUtil.isEmpty(authTime)) { + log.info("##########preHandle: 时间戳不能为空"); + returnJson(response, JSONObject.toJSONString(R.fail("时间戳不能为空"))); + return false; + } + log.info("##########preHandle: authTime={},sign={},companyCodeH={}", authTime, sign, companyCode); + + String account = "shujutongbu"; + String tenantId = "627683"; + String authorizationHeader = "bG9jYWw6bG9jYWxfc2VjcmV0"; + if (StringUtil.isNotBlank(companyCode)) { + FactoryAuthVO authVO = jpFactoryShipmentService.findFactoryAuth(companyCode); + if (ObjectUtil.isNotEmpty(authVO)) { + Long authTime1 = authVO.getAuthTime(); + long secondTimestamp = Instant.now().getEpochSecond(); + // 验证时间 不能大于5秒 + if (secondTimestamp - authTime > authTime1) { + log.info("##########preHandle: 时间戳过期"); + returnJson(response, JSONObject.toJSONString(R.fail("认证不通过,时间戳过期"))); + return false; + } + // 验证签名 + String auth = authVO.getAppKey(); + String md5Hex = Base64.encode(MD5.create().digestHex(params + auth + authTime)).toUpperCase(); + log.info("##########preHandle: md5Hex={}", md5Hex); + if (!StrUtil.equals(md5Hex, sign)) { + log.info("##########preHandle: 签名不正确"); + returnJson(response, JSONObject.toJSONString(R.fail("认证不通过,签名不正确"))); + return false; + } + account = authVO.getLoginAccount(); + tenantId = authVO.getTenantCode(); + authorizationHeader = authVO.getAuthorizationHeader(); + CustomHttpServletRequestWrapper wrappedRequest = new CustomHttpServletRequestWrapper(request); + String key = CacheNames.LOCAL_SERVER_USER + tenantId + ":" + account; + String lockKey = key + ":lock"; + JSONObject data = bladeRedis.get(key); + if (Objects.isNull(data)) { + boolean flag = redisLockClient.tryLock(lockKey, LockType.FAIR, 5000, 10000, TimeUnit.MILLISECONDS); + if (flag) { + data = bladeRedis.get(key); + if (Objects.isNull(data)) { + data = mockLoginService.mockToken(tenantId, account); + bladeRedis.setEx(key, data, DefaultUserTokenConfig.EXPIRE_TIME); + redisLockClient.unLock(lockKey, LockType.FAIR); + } + } + } + // 发送登录请求 + log.info("##########preHandle: request={}", request); + wrappedRequest.addHeader("Blade-Auth", "bearer " + data.getString("access_token")); + HttpHeaders httpHeaders = new HttpHeaders(); + httpHeaders.add("Blade-Auth", "bearer " + data.get("access_token")); + httpHeaders.add("Authorization", "Basic " + authorizationHeader); + ThreadLocalUtil.put("bladeContext", httpHeaders); + // 用包装后的request替换原始request + request = wrappedRequest; + RequestContextHolder.setRequestAttributes(new ServletRequestAttributes(request)); + return true; + } + } else { + returnJson(response, JSONObject.toJSONString(R.fail("缺少参数 companyCode"))); + return false; + } + return false; + } catch (Exception e) { + e.printStackTrace(); + returnJson(response, JSONObject.toJSONString(R.fail("服务异常,请联系管理员"))); + return false; + } + } + + private void returnJson(HttpServletResponse response, String json) { + PrintWriter writer = null; + response.setCharacterEncoding("UTF-8"); + response.setContentType("application/json"); + try { + writer = response.getWriter(); + writer.print(json); + + } catch (IOException e) { + System.out.println(e.getMessage()); + } finally { + if (writer != null) { + writer.close(); + } + } + } + + @Override + public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler, ModelAndView modelAndView) throws Exception { + HandlerInterceptor.super.postHandle(request, response, handler, modelAndView); + } + + @Override + public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex) throws Exception { + HandlerInterceptor.super.afterCompletion(request, response, handler, ex); + } +} diff --git a/blade-service/logpm-factory-data/logpm-factory-data-paterson/src/main/java/com/logpm/factorydata/paterson/launcher/FactoryDataBaseLauncherServiceImpl.java b/blade-service/logpm-factory-data/logpm-factory-data-paterson/src/main/java/com/logpm/factorydata/paterson/launcher/FactoryDataBaseLauncherServiceImpl.java new file mode 100644 index 000000000..90f7b53ea --- /dev/null +++ b/blade-service/logpm-factory-data/logpm-factory-data-paterson/src/main/java/com/logpm/factorydata/paterson/launcher/FactoryDataBaseLauncherServiceImpl.java @@ -0,0 +1,60 @@ +/* + * Copyright (c) 2018-2028, Chill Zhuang All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the dreamlu.net developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: Chill 庄骞 (smallchill@163.com) + */ +package com.logpm.factorydata.paterson.launcher; + +import org.springblade.core.auto.service.AutoService; +import org.springblade.core.launch.constant.NacosConstant; +import org.springblade.core.launch.service.LauncherService; +import org.springblade.core.launch.utils.PropsUtil; +import org.springframework.boot.builder.SpringApplicationBuilder; + +import java.util.Properties; + +/** + * 启动参数拓展 + * + * @author Chill + */ +@AutoService(LauncherService.class) +public class FactoryDataBaseLauncherServiceImpl implements LauncherService { + + @Override + public void launcher(SpringApplicationBuilder builder, String appName, String profile, boolean isLocalDev) { + Properties props = System.getProperties(); + // 开启多数据源 + PropsUtil.setProperty(props, "spring.datasource.dynamic.enabled", "true"); + // 指定注册配置信息 + PropsUtil.setProperty(props, "spring.cloud.nacos.config.extension-configs[0].data-id", NacosConstant.dataId(appName, profile)); + PropsUtil.setProperty(props, "spring.cloud.nacos.config.extension-configs[0].group", NacosConstant.NACOS_CONFIG_GROUP); + PropsUtil.setProperty(props, "spring.cloud.nacos.config.extension-configs[0].refresh", NacosConstant.NACOS_CONFIG_REFRESH); + // 指定注册IP + // PropsUtil.setProperty(props, "spring.cloud.nacos.discovery.ip", "127.0.0.1"); + // 指定注册端口 + // PropsUtil.setProperty(props, "spring.cloud.nacos.discovery.port", "8200"); + // 自定义命名空间 + // PropsUtil.setProperty(props, "spring.cloud.nacos.config.namespace", LauncherConstant.NACOS_NAMESPACE); + // PropsUtil.setProperty(props, "spring.cloud.nacos.discovery.namespace", LauncherConstant.NACOS_NAMESPACE); + // 自定义分组 + // PropsUtil.setProperty(props, "spring.cloud.nacos.config.group", NacosConstant.NACOS_CONFIG_GROUP); + // PropsUtil.setProperty(props, "spring.cloud.nacos.discovery.group", NacosConstant.NACOS_CONFIG_GROUP); + } + + @Override + public int getOrder() { + return 20; + } +} diff --git a/blade-service/logpm-factory-data/logpm-factory-data-paterson/src/main/java/com/logpm/factorydata/paterson/mapper/FactoryOrderLogMapper.java b/blade-service/logpm-factory-data/logpm-factory-data-paterson/src/main/java/com/logpm/factorydata/paterson/mapper/FactoryOrderLogMapper.java new file mode 100644 index 000000000..051f2efed --- /dev/null +++ b/blade-service/logpm-factory-data/logpm-factory-data-paterson/src/main/java/com/logpm/factorydata/paterson/mapper/FactoryOrderLogMapper.java @@ -0,0 +1,16 @@ +package com.logpm.factorydata.paterson.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.logpm.factorydata.paterson.entity.FactoryOrderLogEntity; +import org.apache.ibatis.annotations.Mapper; + +/** + * 工厂订单日志 mapper + * + * @author zqb + * @since 2024-03-26 + */ +@Mapper +public interface FactoryOrderLogMapper extends BaseMapper { + +} diff --git a/blade-service/logpm-factory-data/logpm-factory-data-paterson/src/main/java/com/logpm/factorydata/paterson/mapper/FactoryOrderLogMapper.xml b/blade-service/logpm-factory-data/logpm-factory-data-paterson/src/main/java/com/logpm/factorydata/paterson/mapper/FactoryOrderLogMapper.xml new file mode 100644 index 000000000..bd5071cfd --- /dev/null +++ b/blade-service/logpm-factory-data/logpm-factory-data-paterson/src/main/java/com/logpm/factorydata/paterson/mapper/FactoryOrderLogMapper.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/blade-service/logpm-factory-data/logpm-factory-data-paterson/src/main/java/com/logpm/factorydata/paterson/mapper/FactoryOrderMapper.java b/blade-service/logpm-factory-data/logpm-factory-data-paterson/src/main/java/com/logpm/factorydata/paterson/mapper/FactoryOrderMapper.java new file mode 100644 index 000000000..c71800fe3 --- /dev/null +++ b/blade-service/logpm-factory-data/logpm-factory-data-paterson/src/main/java/com/logpm/factorydata/paterson/mapper/FactoryOrderMapper.java @@ -0,0 +1,16 @@ +package com.logpm.factorydata.paterson.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.logpm.factorydata.paterson.entity.FactoryOrderEntity; +import org.apache.ibatis.annotations.Mapper; + +/** + * 百得胜工厂订单 mapper + * + * @author zqb + * @since 2024-03-26 + */ +@Mapper +public interface FactoryOrderMapper extends BaseMapper { + +} diff --git a/blade-service/logpm-factory-data/logpm-factory-data-paterson/src/main/java/com/logpm/factorydata/paterson/mapper/FactoryOrderMapper.xml b/blade-service/logpm-factory-data/logpm-factory-data-paterson/src/main/java/com/logpm/factorydata/paterson/mapper/FactoryOrderMapper.xml new file mode 100644 index 000000000..eb5d7f7f9 --- /dev/null +++ b/blade-service/logpm-factory-data/logpm-factory-data-paterson/src/main/java/com/logpm/factorydata/paterson/mapper/FactoryOrderMapper.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/blade-service/logpm-factory-data/logpm-factory-data-paterson/src/main/java/com/logpm/factorydata/paterson/mapper/FactoryPackageMapper.java b/blade-service/logpm-factory-data/logpm-factory-data-paterson/src/main/java/com/logpm/factorydata/paterson/mapper/FactoryPackageMapper.java new file mode 100644 index 000000000..fe745e583 --- /dev/null +++ b/blade-service/logpm-factory-data/logpm-factory-data-paterson/src/main/java/com/logpm/factorydata/paterson/mapper/FactoryPackageMapper.java @@ -0,0 +1,16 @@ +package com.logpm.factorydata.paterson.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.logpm.factorydata.paterson.entity.FactoryPackageEntity; +import org.apache.ibatis.annotations.Mapper; + +/** + * 百得胜工厂包件 mapper + * + * @author zqb + * @since 2024-03-26 + */ +@Mapper +public interface FactoryPackageMapper extends BaseMapper { + +} diff --git a/blade-service/logpm-factory-data/logpm-factory-data-paterson/src/main/java/com/logpm/factorydata/paterson/mapper/FactoryPackageMapper.xml b/blade-service/logpm-factory-data/logpm-factory-data-paterson/src/main/java/com/logpm/factorydata/paterson/mapper/FactoryPackageMapper.xml new file mode 100644 index 000000000..095532c65 --- /dev/null +++ b/blade-service/logpm-factory-data/logpm-factory-data-paterson/src/main/java/com/logpm/factorydata/paterson/mapper/FactoryPackageMapper.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/blade-service/logpm-factory-data/logpm-factory-data-paterson/src/main/java/com/logpm/factorydata/paterson/mapper/FactoryShipmentMapper.java b/blade-service/logpm-factory-data/logpm-factory-data-paterson/src/main/java/com/logpm/factorydata/paterson/mapper/FactoryShipmentMapper.java new file mode 100644 index 000000000..14eb2fe55 --- /dev/null +++ b/blade-service/logpm-factory-data/logpm-factory-data-paterson/src/main/java/com/logpm/factorydata/paterson/mapper/FactoryShipmentMapper.java @@ -0,0 +1,21 @@ +package com.logpm.factorydata.paterson.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.logpm.factorydata.paterson.entity.FactoryShipmentEntity; +import com.logpm.factorydata.paterson.vo.FactoryAuthVO; +import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; + +import java.util.List; + +/** + * 百得胜工厂发货单 mapper + * + * @author zqb + * @since 2024-03-26 + */ +@Mapper +public interface FactoryShipmentMapper extends BaseMapper { + + List findFactoryAuth(@Param("companyCode") String companyCode); +} diff --git a/blade-service/logpm-factory-data/logpm-factory-data-paterson/src/main/java/com/logpm/factorydata/paterson/mapper/FactoryShipmentMapper.xml b/blade-service/logpm-factory-data/logpm-factory-data-paterson/src/main/java/com/logpm/factorydata/paterson/mapper/FactoryShipmentMapper.xml new file mode 100644 index 000000000..6ca3241c8 --- /dev/null +++ b/blade-service/logpm-factory-data/logpm-factory-data-paterson/src/main/java/com/logpm/factorydata/paterson/mapper/FactoryShipmentMapper.xml @@ -0,0 +1,17 @@ + + + + + + diff --git a/blade-service/logpm-factory-data/logpm-factory-data-paterson/src/main/java/com/logpm/factorydata/paterson/mq/FactoryOrderListener.java b/blade-service/logpm-factory-data/logpm-factory-data-paterson/src/main/java/com/logpm/factorydata/paterson/mq/FactoryOrderListener.java new file mode 100644 index 000000000..3f2a1eacc --- /dev/null +++ b/blade-service/logpm-factory-data/logpm-factory-data-paterson/src/main/java/com/logpm/factorydata/paterson/mq/FactoryOrderListener.java @@ -0,0 +1,52 @@ +package com.logpm.factorydata.paterson.mq; + +import com.logpm.factorydata.paterson.service.MqWorkerService; +import com.rabbitmq.client.Channel; +import lombok.AllArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springblade.common.constant.factorydata.FactoryDataConstants; +import org.springframework.amqp.core.ExchangeTypes; +import org.springframework.amqp.rabbit.annotation.Exchange; +import org.springframework.amqp.rabbit.annotation.Queue; +import org.springframework.amqp.rabbit.annotation.QueueBinding; +import org.springframework.amqp.rabbit.annotation.RabbitListener; +import org.springframework.amqp.support.AmqpHeaders; +import org.springframework.messaging.handler.annotation.Header; +import org.springframework.stereotype.Component; + +import java.io.IOException; + +/** + * 监听百得胜订单数据 + * + * @author zhaoqiaobo + * @create 2024-03-18 + */ +@Slf4j +@Component +@AllArgsConstructor +public class FactoryOrderListener { + + private final MqWorkerService mqWorkerService; + + @RabbitListener(bindings = @QueueBinding( + value = @Queue(name = FactoryDataConstants.Mq.Queues.BDS_FACTORY_SHIPMENT), + exchange = @Exchange(name = FactoryDataConstants.Mq.Exchanges.FACTORY_ORDER, type = ExchangeTypes.TOPIC), + key = FactoryDataConstants.Mq.RoutingKeys.BDS_FACTORY_SHIPMENT + ), ackMode = "MANUAL") + public void factoryShipment(String msg, Channel channel, @Header(AmqpHeaders.DELIVERY_TAG) long tag) { + log.info("处理百得胜工厂订单:{}", msg); + try { + mqWorkerService.factoryShipment(msg); + } catch (Exception e) { + e.printStackTrace(); + log.error("处理百得胜工厂订单失败: {}", e.getMessage()); + } + try { + channel.basicAck(tag, false); + } catch (IOException e) { + throw new RuntimeException(e); + } + } + +} diff --git a/blade-service/logpm-factory-data/logpm-factory-data-paterson/src/main/java/com/logpm/factorydata/paterson/pros/FactoryDataPatersonProperties.java b/blade-service/logpm-factory-data/logpm-factory-data-paterson/src/main/java/com/logpm/factorydata/paterson/pros/FactoryDataPatersonProperties.java new file mode 100644 index 000000000..794cd622a --- /dev/null +++ b/blade-service/logpm-factory-data/logpm-factory-data-paterson/src/main/java/com/logpm/factorydata/paterson/pros/FactoryDataPatersonProperties.java @@ -0,0 +1,20 @@ +package com.logpm.factorydata.paterson.pros; + +import lombok.Data; +import org.springframework.boot.context.properties.ConfigurationProperties; + +/** + * FactoryProperties + * + * @author pref + */ +@Data +@ConfigurationProperties(prefix = "logpm") +public class FactoryDataPatersonProperties { + /** + * 名称 + */ + private String name; + + +} diff --git a/blade-service/logpm-factory-data/logpm-factory-data-paterson/src/main/java/com/logpm/factorydata/paterson/pros/PatersonProperties.java b/blade-service/logpm-factory-data/logpm-factory-data-paterson/src/main/java/com/logpm/factorydata/paterson/pros/PatersonProperties.java new file mode 100644 index 000000000..39c1e6ef5 --- /dev/null +++ b/blade-service/logpm-factory-data/logpm-factory-data-paterson/src/main/java/com/logpm/factorydata/paterson/pros/PatersonProperties.java @@ -0,0 +1,78 @@ +package com.logpm.factorydata.paterson.pros; + +import lombok.Data; +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.stereotype.Component; + +import java.util.Map; + +/** + * FactoryProperties + * + * @author pref + */ +@Data +@ConfigurationProperties(prefix = "paterson") +@Component +public class PatersonProperties { + + /** + * 百得胜工厂推送节点数据url + */ + private String pushNodeUrl; + /** + * 百得胜查询老数据查询老系统数据URL + */ + private String findOldDataUrl = "/openApi/jinpai/code-query"; + /** + * 是否推送工厂 + */ + private Boolean enable = true; + /** + * 百得胜工厂主机地址 + */ + private String host; + /** + * 承运商编码 + */ + private String carrierCode; + + /** + * 补节点数据时的延时时间(分钟) + */ + private Integer delayedTime = 30; + + /** + * 生成老系统暂存单 + */ + private Boolean oldAdvance = false; + + /** + * 生成新系统暂存单 + */ + private Boolean newAdvance = false; + + /** + * 老系统host + */ + private String oldSystemHost; + + /** + * 老系统回传到达url + */ + private String oldSystemArrivedUrl; + + /** + * 老系统回传入库url + */ + private String oldSystemAlreadyStockedUrl; + + private Map warehouse; + + /** auth过期时间 */ + private Long authTime = 30000L; + + /** key */ + private String auth; + +} diff --git a/blade-service/logpm-factory-data/logpm-factory-data-paterson/src/main/java/com/logpm/factorydata/paterson/service/DeliveryNoteService.java b/blade-service/logpm-factory-data/logpm-factory-data-paterson/src/main/java/com/logpm/factorydata/paterson/service/DeliveryNoteService.java new file mode 100644 index 000000000..c2c118deb --- /dev/null +++ b/blade-service/logpm-factory-data/logpm-factory-data-paterson/src/main/java/com/logpm/factorydata/paterson/service/DeliveryNoteService.java @@ -0,0 +1,14 @@ +package com.logpm.factorydata.paterson.service; + +import com.logpm.factorydata.paterson.vo.FactoryShipmentVO; + +/** + * 索菲亚发货单 服务类 + * + * @Author zqb + * @Date 2024/4/26 + **/ +public interface DeliveryNoteService { + + void buildFactoryAdvance(FactoryShipmentVO vo); +} diff --git a/blade-service/logpm-factory-data/logpm-factory-data-paterson/src/main/java/com/logpm/factorydata/paterson/service/FactoryOrderLogService.java b/blade-service/logpm-factory-data/logpm-factory-data-paterson/src/main/java/com/logpm/factorydata/paterson/service/FactoryOrderLogService.java new file mode 100644 index 000000000..a9216b266 --- /dev/null +++ b/blade-service/logpm-factory-data/logpm-factory-data-paterson/src/main/java/com/logpm/factorydata/paterson/service/FactoryOrderLogService.java @@ -0,0 +1,14 @@ +package com.logpm.factorydata.paterson.service; + +import com.logpm.factorydata.paterson.entity.FactoryOrderLogEntity; +import org.springblade.core.mp.base.BaseService; + +/** + * 工厂订单日志 服务类 + * + * @Author zqb + * @Date 2024/4/26 + **/ +public interface FactoryOrderLogService extends BaseService { + +} diff --git a/blade-service/logpm-factory-data/logpm-factory-data-paterson/src/main/java/com/logpm/factorydata/paterson/service/FactoryOrderService.java b/blade-service/logpm-factory-data/logpm-factory-data-paterson/src/main/java/com/logpm/factorydata/paterson/service/FactoryOrderService.java new file mode 100644 index 000000000..9b8221383 --- /dev/null +++ b/blade-service/logpm-factory-data/logpm-factory-data-paterson/src/main/java/com/logpm/factorydata/paterson/service/FactoryOrderService.java @@ -0,0 +1,14 @@ +package com.logpm.factorydata.paterson.service; + +import com.logpm.factorydata.paterson.entity.FactoryOrderEntity; +import org.springblade.core.mp.base.BaseService; + +/** + * 百得胜工厂订单 服务类 + * + * @Author zqb + * @Date 2024/4/26 + **/ +public interface FactoryOrderService extends BaseService { + +} diff --git a/blade-service/logpm-factory-data/logpm-factory-data-paterson/src/main/java/com/logpm/factorydata/paterson/service/FactoryPackageService.java b/blade-service/logpm-factory-data/logpm-factory-data-paterson/src/main/java/com/logpm/factorydata/paterson/service/FactoryPackageService.java new file mode 100644 index 000000000..6efe4bf78 --- /dev/null +++ b/blade-service/logpm-factory-data/logpm-factory-data-paterson/src/main/java/com/logpm/factorydata/paterson/service/FactoryPackageService.java @@ -0,0 +1,14 @@ +package com.logpm.factorydata.paterson.service; + +import com.logpm.factorydata.paterson.entity.FactoryPackageEntity; +import org.springblade.core.mp.base.BaseService; + +/** + * 百得胜工厂包件 服务类 + * + * @Author zqb + * @Date 2024/4/26 + **/ +public interface FactoryPackageService extends BaseService { + +} diff --git a/blade-service/logpm-factory-data/logpm-factory-data-paterson/src/main/java/com/logpm/factorydata/paterson/service/FactoryShipmentService.java b/blade-service/logpm-factory-data/logpm-factory-data-paterson/src/main/java/com/logpm/factorydata/paterson/service/FactoryShipmentService.java new file mode 100644 index 000000000..6419a6607 --- /dev/null +++ b/blade-service/logpm-factory-data/logpm-factory-data-paterson/src/main/java/com/logpm/factorydata/paterson/service/FactoryShipmentService.java @@ -0,0 +1,19 @@ +package com.logpm.factorydata.paterson.service; + +import com.logpm.factorydata.paterson.entity.FactoryShipmentEntity; +import com.logpm.factorydata.paterson.vo.FactoryAuthVO; +import com.logpm.factorydata.paterson.vo.FactoryShipmentVO; +import org.springblade.core.mp.base.BaseService; + +/** + * 百得胜工厂发货单 服务类 + * + * @Author zqb + * @Date 2024/4/26 + **/ +public interface FactoryShipmentService extends BaseService { + + FactoryAuthVO findFactoryAuth(String companyCode); + + String shipment(FactoryShipmentVO bean); +} diff --git a/blade-service/logpm-factory-data/logpm-factory-data-paterson/src/main/java/com/logpm/factorydata/paterson/service/MqWorkerService.java b/blade-service/logpm-factory-data/logpm-factory-data-paterson/src/main/java/com/logpm/factorydata/paterson/service/MqWorkerService.java new file mode 100644 index 000000000..0c99c9b45 --- /dev/null +++ b/blade-service/logpm-factory-data/logpm-factory-data-paterson/src/main/java/com/logpm/factorydata/paterson/service/MqWorkerService.java @@ -0,0 +1,13 @@ +package com.logpm.factorydata.paterson.service; + +/** + * 消息队列工作类 服务类 + * + * @Author zqb + * @Date 2024/4/26 + **/ +public interface MqWorkerService { + + void factoryShipment(String msg); + +} diff --git a/blade-service/logpm-factory-data/logpm-factory-data-paterson/src/main/java/com/logpm/factorydata/paterson/service/impl/DeliveryNoteServiceImpl.java b/blade-service/logpm-factory-data/logpm-factory-data-paterson/src/main/java/com/logpm/factorydata/paterson/service/impl/DeliveryNoteServiceImpl.java new file mode 100644 index 000000000..6cbbf0f2d --- /dev/null +++ b/blade-service/logpm-factory-data/logpm-factory-data-paterson/src/main/java/com/logpm/factorydata/paterson/service/impl/DeliveryNoteServiceImpl.java @@ -0,0 +1,181 @@ +package com.logpm.factorydata.paterson.service.impl; + +import cn.hutool.core.collection.CollUtil; +import cn.hutool.core.date.DateUtil; +import cn.hutool.core.util.NumberUtil; +import cn.hutool.core.util.ObjectUtil; +import cn.hutool.json.JSONObject; +import cn.hutool.json.JSONUtil; +import com.logpm.factorydata.base.feign.IFactoryDataBaseClient; +import com.logpm.factorydata.base.vo.FactoryWarehouseBindVO; +import com.logpm.factorydata.enums.BrandEnums; +import com.logpm.factorydata.feign.IFactoryDataClient; +import com.logpm.factorydata.paterson.service.DeliveryNoteService; +import com.logpm.factorydata.paterson.vo.FactoryOrderVO; +import com.logpm.factorydata.paterson.vo.FactoryPackageVO; +import com.logpm.factorydata.paterson.vo.FactoryShipmentVO; +import com.logpm.factorydata.vo.SendMsg; +import com.logpm.trunkline.entity.TrunklineAdvanceDetailEntity; +import com.logpm.trunkline.entity.TrunklineAdvanceEntity; +import lombok.extern.slf4j.Slf4j; +import org.springblade.common.annotations.LogpmAsync; +import org.springblade.common.constant.HttpConstants; +import org.springblade.common.constant.factorydata.FactoryDataConstants; +import org.springblade.core.tool.api.R; +import org.springblade.resource.feign.IOssClient; +import org.springframework.stereotype.Service; + +import javax.annotation.Resource; +import java.time.LocalDateTime; +import java.util.ArrayList; +import java.util.List; + +/** + * 发货单 业务实现类 + * + * @Author zqb + * @Date 2024/4/26 + **/ +@Slf4j +@Service +public class DeliveryNoteServiceImpl implements DeliveryNoteService { + + @Resource + private IFactoryDataClient factoryDataClient; + @Resource + private IOssClient ossClient; + @Resource + private IFactoryDataBaseClient baseClient; + + @Override + @LogpmAsync("asyncExecutor") + public void buildFactoryAdvance(FactoryShipmentVO vo) { + // 新起线程构建暂存单发送mq + Long startWarehouseId = null; + String startWarehouseName = null; + String tenantId = null; + // 获取工厂基地绑定的始发仓信息 + List details = vo.getOrderList(); + if (CollUtil.isEmpty(details)) { + return; + } + R warehouseByBrandAndSiteName = baseClient.getWarehouseByBrandAndSiteName(BrandEnums.BDS.getValue(), vo.getShipmentHub()); + if (ObjectUtil.equal(HttpConstants.HTTP.HTTP_RESOURCE_CODE.SUCCESS_CODE, warehouseByBrandAndSiteName.getCode())) { + FactoryWarehouseBindVO data = warehouseByBrandAndSiteName.getData(); + if (ObjectUtil.isNotNull(data)) { + startWarehouseId = data.getWarehouseId(); + startWarehouseName = data.getWarehouseName(); + tenantId = data.getTenantId(); + } + } + // 一个dd单号 一个暂存单 + // 组装暂存单数据 + List advances = new ArrayList<>(); + for (FactoryOrderVO orderInfoVO : details) { + List packageList = new ArrayList<>(); + TrunklineAdvanceEntity advanceEntity = new TrunklineAdvanceEntity(); + Boolean checked = vo.getChecked(); + if (checked) { + advanceEntity.setReserve2("1"); + } else { + advanceEntity.setReserve2("0"); + } + advanceEntity.setTenantId(tenantId); + advanceEntity.setStatus(0); + advanceEntity.setIsDeleted(0); + advanceEntity.setHasPackage(1); + advanceEntity.setOrderType(""); + advanceEntity.setBrand(BrandEnums.BDS.getValue()); + advanceEntity.setSiteName(vo.getShipmentHub()); + advanceEntity.setArea(""); + advanceEntity.setTotalNum(CollUtil.isNotEmpty(orderInfoVO.getPackageList()) ? orderInfoVO.getPackageList().size() : 0); + advanceEntity.setPackName(""); + advanceEntity.setPackCode(""); + advanceEntity.setWarehouseId(startWarehouseId); + advanceEntity.setWarehouseName(startWarehouseName); + + advanceEntity.setIsGcp(0); + advanceEntity.setCarrierName(""); + advanceEntity.setSystemType("线上"); + advanceEntity.setMatingType("1"); + advanceEntity.setSenderName(""); + advanceEntity.setSenderPhone(""); + advanceEntity.setSenderAddress(""); + advanceEntity.setWaybillStatus("0"); + advanceEntity.setWaybillNo(""); + advanceEntity.setTrainNumber(vo.getShipmentId()); + advanceEntity.setFreezeStatus("0"); + advanceEntity.setOrderCode(orderInfoVO.getOrderCode()); + advanceEntity.setServiceNum(orderInfoVO.getServiceNum()); + advanceEntity.setSenderFactory("百得胜"); + // 门店是商场 + // advanceEntity.setDealerCode(orderInfoVO.getShopCode()); + advanceEntity.setDealerName(orderInfoVO.getMallName()); + // advanceEntity.setStoreCode(orderInfoVO.getShopCode()); + advanceEntity.setStoreName(orderInfoVO.getStoreName()); + // 安装是客户 + advanceEntity.setCustomerName(orderInfoVO.getReceiverName()); + advanceEntity.setCustomerPhone(orderInfoVO.getReceiverMobile()); + advanceEntity.setCustomerAddress(orderInfoVO.getReceiverAddress()); + // 收货人就是商场收货人 + advanceEntity.setConsigneePerson(orderInfoVO.getMallConsignee()); + advanceEntity.setConsigneeMobile(orderInfoVO.getMallConsigneeMobile()); + advanceEntity.setConsigneeAddress(orderInfoVO.getMallAddress()); + + // 封装包件品类信息 + for (FactoryPackageVO packageInfoVO : orderInfoVO.getPackageList()) { + // 封装包件 + TrunklineAdvanceDetailEntity advanceDetailEntity = new TrunklineAdvanceDetailEntity(); + advanceDetailEntity.setWarehouseId(startWarehouseId); + advanceDetailEntity.setWarehouseName(startWarehouseName); + + advanceDetailEntity.setOrderCode(orderInfoVO.getOrderCode()); + advanceDetailEntity.setBrand(BrandEnums.BDS.getValue()); + advanceDetailEntity.setSystemType("线上"); + // 获取映射品类信息 + advanceDetailEntity.setFirstPackName(packageInfoVO.getFirstPackName()); + advanceDetailEntity.setFirstPackCode(packageInfoVO.getFirstPackCode()); + advanceDetailEntity.setSecondPackName(packageInfoVO.getSecondPackName()); + advanceDetailEntity.setSecondPackCode(packageInfoVO.getSecondPackCode()); + advanceDetailEntity.setThirdPackName(packageInfoVO.getThirdPackName()); + advanceDetailEntity.setThirdPackCode(packageInfoVO.getThirdPackCode()); + + advanceDetailEntity.setSiteName(vo.getShipmentHub()); + advanceDetailEntity.setSiteCode(""); + advanceDetailEntity.setQuantity(1); + advanceDetailEntity.setOrderPackageCode(packageInfoVO.getUnitNo()); + advanceDetailEntity.setTrainNumber(vo.getShipmentId()); + advanceDetailEntity.setServiceNum(orderInfoVO.getServiceNum()); + advanceDetailEntity.setWaybillNo(""); + advanceDetailEntity.setPackageStatus("0"); + advanceDetailEntity.setWeight(NumberUtil.toBigDecimal(packageInfoVO.getWeight())); + advanceDetailEntity.setVolume(NumberUtil.toBigDecimal(packageInfoVO.getVolume())); +// advanceDetailEntity.setChargeType(0); + advanceDetailEntity.setSupple(""); + advanceDetailEntity.setManifest(""); + advanceDetailEntity.setReturnNum(""); + advanceDetailEntity.setSendDateStr(DateUtil.formatLocalDateTime(LocalDateTime.now())); + advanceDetailEntity.setCarNumber(""); + advanceDetailEntity.setGoodsMan(""); + advanceDetailEntity.setTenantId(tenantId); + advanceDetailEntity.setStatus(0); + advanceDetailEntity.setIsDeleted(0); + JSONObject entries = JSONUtil.parseObj(advanceDetailEntity); + packageList.add(entries); + } + // 转成json对象,然后将包件明细放到detail中 + JSONObject entries = JSONUtil.parseObj(advanceEntity); + entries.set("details", JSONUtil.toJsonStr(packageList)); + advances.add(entries); + } + // 将组装好的暂存单发送到 MQ ,由暂存单服务统一消费SendMsg. + if (CollUtil.isNotEmpty(advances)) { + for (JSONObject advance : advances) { + SendMsg sendMsg = SendMsg.builder().exchange(FactoryDataConstants.Mq.Exchanges.ADVANCE_ORDER) + .routingKey(FactoryDataConstants.Mq.RoutingKeys.ADVANCE_ORDER).message(JSONUtil.toJsonStr(advance)).build(); + factoryDataClient.sendMessage(sendMsg); + } + } + } + +} diff --git a/blade-service/logpm-factory-data/logpm-factory-data-paterson/src/main/java/com/logpm/factorydata/paterson/service/impl/FactoryOrderLogServiceImpl.java b/blade-service/logpm-factory-data/logpm-factory-data-paterson/src/main/java/com/logpm/factorydata/paterson/service/impl/FactoryOrderLogServiceImpl.java new file mode 100644 index 000000000..97d9dd558 --- /dev/null +++ b/blade-service/logpm-factory-data/logpm-factory-data-paterson/src/main/java/com/logpm/factorydata/paterson/service/impl/FactoryOrderLogServiceImpl.java @@ -0,0 +1,22 @@ +package com.logpm.factorydata.paterson.service.impl; + +import com.logpm.factorydata.paterson.entity.FactoryOrderLogEntity; +import com.logpm.factorydata.paterson.mapper.FactoryOrderLogMapper; +import com.logpm.factorydata.paterson.service.FactoryOrderLogService; +import lombok.AllArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springblade.core.mp.base.BaseServiceImpl; +import org.springframework.stereotype.Service; + +/** + * 工厂订单日志 业务实现类 + * + * @Author zqb + * @Date 2024/4/26 + **/ +@Slf4j +@Service +@AllArgsConstructor +public class FactoryOrderLogServiceImpl extends BaseServiceImpl implements FactoryOrderLogService { + +} diff --git a/blade-service/logpm-factory-data/logpm-factory-data-paterson/src/main/java/com/logpm/factorydata/paterson/service/impl/FactoryOrderServiceImpl.java b/blade-service/logpm-factory-data/logpm-factory-data-paterson/src/main/java/com/logpm/factorydata/paterson/service/impl/FactoryOrderServiceImpl.java new file mode 100644 index 000000000..f198b0cd2 --- /dev/null +++ b/blade-service/logpm-factory-data/logpm-factory-data-paterson/src/main/java/com/logpm/factorydata/paterson/service/impl/FactoryOrderServiceImpl.java @@ -0,0 +1,22 @@ +package com.logpm.factorydata.paterson.service.impl; + +import com.logpm.factorydata.paterson.entity.FactoryOrderEntity; +import com.logpm.factorydata.paterson.mapper.FactoryOrderMapper; +import com.logpm.factorydata.paterson.service.FactoryOrderService; +import lombok.AllArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springblade.core.mp.base.BaseServiceImpl; +import org.springframework.stereotype.Service; + +/** + * 百得胜工厂订单 业务实现类 + * + * @Author zqb + * @Date 2024/4/26 + **/ +@Slf4j +@Service +@AllArgsConstructor +public class FactoryOrderServiceImpl extends BaseServiceImpl implements FactoryOrderService { + +} diff --git a/blade-service/logpm-factory-data/logpm-factory-data-paterson/src/main/java/com/logpm/factorydata/paterson/service/impl/FactoryPackageServiceImpl.java b/blade-service/logpm-factory-data/logpm-factory-data-paterson/src/main/java/com/logpm/factorydata/paterson/service/impl/FactoryPackageServiceImpl.java new file mode 100644 index 000000000..dd904366a --- /dev/null +++ b/blade-service/logpm-factory-data/logpm-factory-data-paterson/src/main/java/com/logpm/factorydata/paterson/service/impl/FactoryPackageServiceImpl.java @@ -0,0 +1,22 @@ +package com.logpm.factorydata.paterson.service.impl; + +import com.logpm.factorydata.paterson.entity.FactoryPackageEntity; +import com.logpm.factorydata.paterson.mapper.FactoryPackageMapper; +import com.logpm.factorydata.paterson.service.FactoryPackageService; +import lombok.AllArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springblade.core.mp.base.BaseServiceImpl; +import org.springframework.stereotype.Service; + +/** + * 百得胜工厂包件 业务实现类 + * + * @Author zqb + * @Date 2024/4/26 + **/ +@Slf4j +@Service +@AllArgsConstructor +public class FactoryPackageServiceImpl extends BaseServiceImpl implements FactoryPackageService { + +} diff --git a/blade-service/logpm-factory-data/logpm-factory-data-paterson/src/main/java/com/logpm/factorydata/paterson/service/impl/FactoryShipmentServiceImpl.java b/blade-service/logpm-factory-data/logpm-factory-data-paterson/src/main/java/com/logpm/factorydata/paterson/service/impl/FactoryShipmentServiceImpl.java new file mode 100644 index 000000000..4aadd5145 --- /dev/null +++ b/blade-service/logpm-factory-data/logpm-factory-data-paterson/src/main/java/com/logpm/factorydata/paterson/service/impl/FactoryShipmentServiceImpl.java @@ -0,0 +1,137 @@ +package com.logpm.factorydata.paterson.service.impl; + +import cn.hutool.core.collection.CollUtil; +import cn.hutool.core.io.FileUtil; +import cn.hutool.core.util.StrUtil; +import cn.hutool.json.JSONUtil; +import com.logpm.factorydata.enums.SaxStatusEnums; +import com.logpm.factorydata.feign.IFactoryDataClient; +import com.logpm.factorydata.paterson.entity.FactoryOrderLogEntity; +import com.logpm.factorydata.paterson.entity.FactoryShipmentEntity; +import com.logpm.factorydata.paterson.mapper.FactoryShipmentMapper; +import com.logpm.factorydata.paterson.service.FactoryOrderLogService; +import com.logpm.factorydata.paterson.service.FactoryShipmentService; +import com.logpm.factorydata.paterson.vo.FactoryAuthVO; +import com.logpm.factorydata.paterson.vo.FactoryShipmentVO; +import com.logpm.factorydata.vo.SendMsg; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.fileupload.FileItem; +import org.apache.commons.fileupload.disk.DiskFileItemFactory; +import org.apache.commons.io.IOUtils; +import org.jetbrains.annotations.NotNull; +import org.springblade.common.constant.factorydata.FactoryDataConstants; +import org.springblade.common.utils.FileLogsUtil; +import org.springblade.core.mp.base.BaseServiceImpl; +import org.springblade.core.oss.model.BladeFile; +import org.springblade.core.redis.cache.BladeRedis; +import org.springblade.core.tool.api.R; +import org.springblade.resource.feign.IOssClient; +import org.springframework.http.MediaType; +import org.springframework.stereotype.Service; +import org.springframework.web.multipart.MultipartFile; +import org.springframework.web.multipart.commons.CommonsMultipartFile; + +import javax.annotation.Resource; +import java.io.File; +import java.io.InputStream; +import java.io.OutputStream; +import java.nio.file.Files; +import java.time.Duration; +import java.util.List; + +/** + * 百得胜工厂发货单 业务实现类 + * + * @Author zqb + * @Date 2024/4/26 + **/ +@Slf4j +@Service +public class FactoryShipmentServiceImpl extends BaseServiceImpl implements FactoryShipmentService { + + @Resource + private BladeRedis bladeRedis; + @Resource + private IOssClient ossClient; + @Resource + private IFactoryDataClient factoryDataClient; + @Resource + private FactoryOrderLogService factoryOrderLogService; + + @Override + public FactoryAuthVO findFactoryAuth(String companyCode) { + // redis 缓存数据 缓存时间 1天 + if (StrUtil.isNotBlank(companyCode)) { + String key = "factory-data:bds:" + companyCode; + String json = bladeRedis.get(key); + if (StrUtil.isNotBlank(json)) { + return JSONUtil.toBean(json, FactoryAuthVO.class); + } else { + List factoryAuth = baseMapper.findFactoryAuth(companyCode); + if(CollUtil.isNotEmpty(factoryAuth)){ + FactoryAuthVO authVO = factoryAuth.get(0); + bladeRedis.setEx(key, JSONUtil.toJsonStr(authVO), Duration.ofDays(1)); + return authVO; + } + } + } + return null; + + } + + @Override + public String shipment(FactoryShipmentVO vo) { + // 1 上传数据到 minio 获取到地址 + String url = uploadFile(JSONUtil.toJsonStr(vo)); + // 2 保存地址到数据库 + FactoryOrderLogEntity logEntity = new FactoryOrderLogEntity(); + logEntity.setType(2); + logEntity.setSaxStatus(SaxStatusEnums.NOMAL.getCode()); + logEntity.setLogUrl(url); + factoryOrderLogService.save(logEntity); + // 3 将消息发送给 mq,解析保存 + SendMsg build = SendMsg.builder().exchange(FactoryDataConstants.Mq.Exchanges.FACTORY_ORDER) + .routingKey(FactoryDataConstants.Mq.RoutingKeys.BDS_FACTORY_SHIPMENT).message(JSONUtil.toJsonStr(logEntity)).build(); + factoryDataClient.sendMessage(build); + return "成功"; + + } + + private String uploadFile(String body) { + // 文本内容和保存为本地文件 并上传 + String logPath = FileLogsUtil.saveFileLogs(body); + log.info(">>> 文件路径 {}", logPath); + + MultipartFile multi = getMultipartFile(logPath); + // 上传到服务器 + R r = ossClient.fileUpload(multi, "bds-order-logs"); + if (r.isSuccess()) { + BladeFile data = (BladeFile) r.getData(); + // 删除本地文件 + FileUtil.del(logPath); + return data.getLink(); + } + return null; + } + + @NotNull + private MultipartFile getMultipartFile(String logPath) { + File file = new File(logPath); + + // File 转 MultipartFile + FileItem item = new DiskFileItemFactory().createItem("file" + , MediaType.MULTIPART_FORM_DATA_VALUE + , true + , file.getName()); + try ( + InputStream input = Files.newInputStream(file.toPath()); + OutputStream os = item.getOutputStream()) { + // 流转移 + IOUtils.copy(input, os); + } catch (Exception e) { + throw new IllegalArgumentException("Invalid file: " + e, e); + } + + return new CommonsMultipartFile(item); + } +} diff --git a/blade-service/logpm-factory-data/logpm-factory-data-paterson/src/main/java/com/logpm/factorydata/paterson/service/impl/MqWorkerServiceImpl.java b/blade-service/logpm-factory-data/logpm-factory-data-paterson/src/main/java/com/logpm/factorydata/paterson/service/impl/MqWorkerServiceImpl.java new file mode 100644 index 000000000..f4284f708 --- /dev/null +++ b/blade-service/logpm-factory-data/logpm-factory-data-paterson/src/main/java/com/logpm/factorydata/paterson/service/impl/MqWorkerServiceImpl.java @@ -0,0 +1,139 @@ +package com.logpm.factorydata.paterson.service.impl; + +import cn.hutool.core.bean.BeanUtil; +import cn.hutool.core.collection.CollUtil; +import cn.hutool.core.io.FileUtil; +import cn.hutool.core.util.CharsetUtil; +import cn.hutool.core.util.ObjectUtil; +import cn.hutool.core.util.StrUtil; +import cn.hutool.core.util.URLUtil; +import cn.hutool.json.JSONUtil; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import com.logpm.factorydata.enums.SaxStatusEnums; +import com.logpm.factorydata.paterson.entity.FactoryOrderLogEntity; +import com.logpm.factorydata.paterson.entity.FactoryOrderEntity; +import com.logpm.factorydata.paterson.entity.FactoryPackageEntity; +import com.logpm.factorydata.paterson.entity.FactoryShipmentEntity; +import com.logpm.factorydata.paterson.service.DeliveryNoteService; +import com.logpm.factorydata.paterson.service.FactoryOrderLogService; +import com.logpm.factorydata.paterson.service.FactoryOrderService; +import com.logpm.factorydata.paterson.service.FactoryPackageService; +import com.logpm.factorydata.paterson.service.FactoryShipmentService; +import com.logpm.factorydata.paterson.service.MqWorkerService; +import com.logpm.factorydata.paterson.vo.FactoryOrderVO; +import com.logpm.factorydata.paterson.vo.FactoryPackageVO; +import com.logpm.factorydata.paterson.vo.FactoryShipmentVO; +import lombok.AllArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springblade.core.secure.utils.AuthUtil; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.util.ArrayList; +import java.util.List; + +/** + * 消息队列工作类 业务实现类 + * + * @Author zqb + * @Date 2024/4/26 + **/ +@Slf4j +@Service +@AllArgsConstructor +public class MqWorkerServiceImpl implements MqWorkerService { + + private final DeliveryNoteService deliveryNoteService; + private final FactoryOrderLogService logService; + private final FactoryShipmentService jpFactoryShipmentService; + private final FactoryOrderService jpFactoryOrderService; + private final FactoryPackageService jpFactoryPackageService; + + @Override + @Transactional(rollbackFor = Exception.class) + public void factoryShipment(String msg) { + if (StrUtil.isEmpty(msg)) { + log.error("消息内容为空"); + return; + } + FactoryOrderLogEntity logEntity = JSONUtil.toBean(msg, FactoryOrderLogEntity.class); + if (ObjectUtil.isEmpty(logEntity)) { + log.error("消息内容为空"); + return; + } + // 去 minio 下载文件到本地,然后解析文件内容为实体对象 + FactoryShipmentVO pushOrderVO = null; + String logUrl = logEntity.getLogUrl(); + if (StrUtil.isNotEmpty(logUrl)) { + List res = new ArrayList<>(); + FileUtil.readLines(URLUtil.url(logUrl), CharsetUtil.CHARSET_UTF_8, res); + if (CollUtil.isNotEmpty(res)) { + String content = res.get(0); + if (StrUtil.isNotEmpty(content)) { + pushOrderVO = JSONUtil.toBean(content, FactoryShipmentVO.class); + } + } + } + shipmentData(pushOrderVO, logEntity); + } + + private void shipmentData(FactoryShipmentVO vo, FactoryOrderLogEntity logEntity) { + if (ObjectUtil.isNotEmpty(vo)) { + // 1 解析数据保存入库 + // 装车单号唯一 + Long logId = logEntity.getId(); + String truckNo = vo.getShipmentId(); + if (StrUtil.isEmpty(truckNo)) { + return; + } + List list = jpFactoryShipmentService.list(Wrappers.lambdaQuery().eq(FactoryShipmentEntity::getShipmentId, truckNo)); + Boolean checked = Boolean.FALSE; + if (CollUtil.isNotEmpty(list)) { + if (list.size() > 1) { + return; + } + checked = Boolean.TRUE; + } + vo.setChecked(checked); + vo.setLogId(ObjectUtil.isNotEmpty(logId) ? logId.toString() : null); + vo.setTenantCode(AuthUtil.getTenantId()); + jpFactoryShipmentService.save(vo); + List orderVOS = vo.getOrderList(); + if (CollUtil.isNotEmpty(orderVOS)) { + List packageEntities = new ArrayList<>(); + for (FactoryOrderVO orderVO : orderVOS) { + FactoryOrderEntity orderEntity = new FactoryOrderEntity(); + BeanUtil.copyProperties(orderVO, orderEntity); + orderEntity.setLogId(ObjectUtil.isNotEmpty(logId) ? logId.toString() : null); + orderEntity.setShipmentId(vo.getId()); + orderEntity.setChecked(checked); + orderEntity.setTenantCode(AuthUtil.getTenantId()); + jpFactoryOrderService.save(orderEntity); + List packageList = orderVO.getPackageList(); + if (CollUtil.isNotEmpty(packageList)) { + for (FactoryPackageVO jpFactoryPackageVO : packageList) { + FactoryPackageEntity packageEntity = new FactoryPackageEntity(); + BeanUtil.copyProperties(jpFactoryPackageVO, packageEntity); + packageEntity.setLogId(ObjectUtil.isNotEmpty(logId) ? logId.toString() : null); + packageEntity.setOrderId(orderEntity.getId()); + packageEntity.setChecked(checked); + packageEntity.setTenantCode(AuthUtil.getTenantId()); + packageEntities.add(packageEntity); + } + } + } + if (CollUtil.isNotEmpty(packageEntities)) { + jpFactoryPackageService.saveBatch(packageEntities); + } + } + // 2 构建暂存单,发送 mq 消息 + FactoryOrderLogEntity logEntity1 = new FactoryOrderLogEntity(); + logEntity1.setSaxStatus(SaxStatusEnums.SUCCESS.getCode()); + logEntity1.setId(logId); + logService.saveOrUpdate(logEntity1); + // 处理暂存单 + deliveryNoteService.buildFactoryAdvance(vo); + } + } + +} diff --git a/blade-service/logpm-factory-data/logpm-factory-data-paterson/src/main/java/com/logpm/factorydata/paterson/vo/FactoryAuthVO.java b/blade-service/logpm-factory-data/logpm-factory-data-paterson/src/main/java/com/logpm/factorydata/paterson/vo/FactoryAuthVO.java new file mode 100644 index 000000000..7614c2491 --- /dev/null +++ b/blade-service/logpm-factory-data/logpm-factory-data-paterson/src/main/java/com/logpm/factorydata/paterson/vo/FactoryAuthVO.java @@ -0,0 +1,30 @@ +package com.logpm.factorydata.paterson.vo; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +/** + * 物流商认证 + * + * @author zhaoqiaobo + * @create 2024-04-26 + */ +@Data +public class FactoryAuthVO { + + @ApiModelProperty(name = "物流编码") + private String logisticsCode; + @ApiModelProperty(name = "秘钥") + private String appKey; + @ApiModelProperty(name = "auth过期时间") + private Long authTime; + @ApiModelProperty(name = "物流公司") + private String companyCode; + @ApiModelProperty(name = "租户") + private String tenantCode; + @ApiModelProperty(name = "登录账号") + private String loginAccount; + @ApiModelProperty(name = "Authorization头") + private String authorizationHeader; + +} diff --git a/blade-service/logpm-factory-data/logpm-factory-data-paterson/src/main/java/com/logpm/factorydata/paterson/vo/FactoryOrderDataVO.java b/blade-service/logpm-factory-data/logpm-factory-data-paterson/src/main/java/com/logpm/factorydata/paterson/vo/FactoryOrderDataVO.java new file mode 100644 index 000000000..8d4fdcd60 --- /dev/null +++ b/blade-service/logpm-factory-data/logpm-factory-data-paterson/src/main/java/com/logpm/factorydata/paterson/vo/FactoryOrderDataVO.java @@ -0,0 +1,27 @@ +package com.logpm.factorydata.paterson.vo; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +/** + * 送货单 实体类 + * + * @author zhaoqiaobo + * @create 2024-04-26 + */ +@Data +@ApiModel(value = "发货单", description = "发货单") +public class FactoryOrderDataVO { + + @ApiModelProperty("加密后的密文") + private String digest; + @ApiModelProperty("时间戳 毫秒") + private Long timestamp; + @ApiModelProperty("公司编码") + private String companyCode; + + @ApiModelProperty("订单信息") + private String params; + +} diff --git a/blade-service/logpm-factory-data/logpm-factory-data-paterson/src/main/java/com/logpm/factorydata/paterson/vo/FactoryOrderVO.java b/blade-service/logpm-factory-data/logpm-factory-data-paterson/src/main/java/com/logpm/factorydata/paterson/vo/FactoryOrderVO.java new file mode 100644 index 000000000..6e9ac1685 --- /dev/null +++ b/blade-service/logpm-factory-data/logpm-factory-data-paterson/src/main/java/com/logpm/factorydata/paterson/vo/FactoryOrderVO.java @@ -0,0 +1,25 @@ +package com.logpm.factorydata.paterson.vo; + +import com.logpm.factorydata.paterson.entity.FactoryOrderEntity; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.EqualsAndHashCode; + +import java.util.List; + +/** + * 送货单 实体类 + * + * @author zhaoqiaobo + * @create 2024-04-26 + */ +@Data +@ApiModel(value = "发货单", description = "发货单") +@EqualsAndHashCode(callSuper = true) +public class FactoryOrderVO extends FactoryOrderEntity { + + @ApiModelProperty(name = "包件明细") + private List packageList; + +} diff --git a/blade-service/logpm-factory-data/logpm-factory-data-paterson/src/main/java/com/logpm/factorydata/paterson/vo/FactoryPackageVO.java b/blade-service/logpm-factory-data/logpm-factory-data-paterson/src/main/java/com/logpm/factorydata/paterson/vo/FactoryPackageVO.java new file mode 100644 index 000000000..c1322c89a --- /dev/null +++ b/blade-service/logpm-factory-data/logpm-factory-data-paterson/src/main/java/com/logpm/factorydata/paterson/vo/FactoryPackageVO.java @@ -0,0 +1,21 @@ +package com.logpm.factorydata.paterson.vo; + +import com.logpm.factorydata.paterson.entity.FactoryPackageEntity; +import io.swagger.annotations.ApiModel; +import lombok.Data; +import lombok.EqualsAndHashCode; + +/** + * 送货单 实体类 + * + * @author zhaoqiaobo + * @create 2024-04-26 + */ +@Data +@ApiModel(value = "发货单", description = "发货单") +@EqualsAndHashCode(callSuper = true) +public class FactoryPackageVO extends FactoryPackageEntity { + + + +} diff --git a/blade-service/logpm-factory-data/logpm-factory-data-paterson/src/main/java/com/logpm/factorydata/paterson/vo/FactoryShipmentVO.java b/blade-service/logpm-factory-data/logpm-factory-data-paterson/src/main/java/com/logpm/factorydata/paterson/vo/FactoryShipmentVO.java new file mode 100644 index 000000000..3b1f40c35 --- /dev/null +++ b/blade-service/logpm-factory-data/logpm-factory-data-paterson/src/main/java/com/logpm/factorydata/paterson/vo/FactoryShipmentVO.java @@ -0,0 +1,25 @@ +package com.logpm.factorydata.paterson.vo; + +import com.logpm.factorydata.paterson.entity.FactoryShipmentEntity; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.EqualsAndHashCode; + +import java.util.List; + +/** + * 送货单 实体类 + * + * @author zhaoqiaobo + * @create 2024-04-26 + */ +@Data +@ApiModel(value = "发货单", description = "发货单") +@EqualsAndHashCode(callSuper = true) +public class FactoryShipmentVO extends FactoryShipmentEntity { + + @ApiModelProperty(name = "订单明细") + private List orderList; + +} diff --git a/blade-service/logpm-factory-data/logpm-factory-data-paterson/src/main/java/com/logpm/factorydata/paterson/vo/PackageCategoryVO.java b/blade-service/logpm-factory-data/logpm-factory-data-paterson/src/main/java/com/logpm/factorydata/paterson/vo/PackageCategoryVO.java new file mode 100644 index 000000000..edabeb2f0 --- /dev/null +++ b/blade-service/logpm-factory-data/logpm-factory-data-paterson/src/main/java/com/logpm/factorydata/paterson/vo/PackageCategoryVO.java @@ -0,0 +1,26 @@ +package com.logpm.factorydata.paterson.vo; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.io.Serializable; + +/** + * @author zhaoqiaobo + * @create 2024-04-30 + */ +@Data +public class PackageCategoryVO implements Serializable { + + @ApiModelProperty(name = "一级品类") + private String typea; + @ApiModelProperty(name = "二级品类") + private String typeb; + @ApiModelProperty(name = "三级品类") + private String typec; + @ApiModelProperty(name = "包件码") + private String extBoxCode; + @ApiModelProperty(name = "包件类型") + private String extBoxType; + +} diff --git a/blade-service/logpm-factory-data/logpm-factory-data-paterson/src/main/java/com/logpm/factorydata/paterson/vo/ThirdPlWarehouseMappingVO.java b/blade-service/logpm-factory-data/logpm-factory-data-paterson/src/main/java/com/logpm/factorydata/paterson/vo/ThirdPlWarehouseMappingVO.java new file mode 100644 index 000000000..2a941bf13 --- /dev/null +++ b/blade-service/logpm-factory-data/logpm-factory-data-paterson/src/main/java/com/logpm/factorydata/paterson/vo/ThirdPlWarehouseMappingVO.java @@ -0,0 +1,32 @@ +package com.logpm.factorydata.paterson.vo; + +import lombok.Data; + +import java.io.Serializable; + +/** + * 百得胜三方物流仓库映射表 + * @author zhaoqiaobo + * @create 2024-04-30 + */ +@Data +public class ThirdPlWarehouseMappingVO implements Serializable { + + /** + * 到站网点 + */ + private String arriveOrgName; + /** + * 仓库id + */ + private String warehouseId; + /** + * 仓库名称 + */ + private String warehouseName; + /** + * 租户id + */ + private String tenantId; + +} diff --git a/blade-service/logpm-factory-data/logpm-factory-data-paterson/src/main/java/com/logpm/factorydata/paterson/wrapper/CustomHttpServletRequestWrapper.java b/blade-service/logpm-factory-data/logpm-factory-data-paterson/src/main/java/com/logpm/factorydata/paterson/wrapper/CustomHttpServletRequestWrapper.java new file mode 100644 index 000000000..0b336fa1a --- /dev/null +++ b/blade-service/logpm-factory-data/logpm-factory-data-paterson/src/main/java/com/logpm/factorydata/paterson/wrapper/CustomHttpServletRequestWrapper.java @@ -0,0 +1,38 @@ +package com.logpm.factorydata.paterson.wrapper; + +import org.springframework.http.HttpHeaders; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletRequestWrapper; +import java.util.Collections; +import java.util.Enumeration; +import java.util.List; + +public class CustomHttpServletRequestWrapper extends HttpServletRequestWrapper { + + private final HttpHeaders headers; + + public CustomHttpServletRequestWrapper(HttpServletRequest request) { + super(request); + headers = new HttpHeaders(); + } + + @Override + public String getHeader(String name) { + String headerValue = headers.getFirst(name); + return headerValue != null ? headerValue : super.getHeader(name); + } + + @Override + public Enumeration getHeaderNames() { + List names = Collections.list(super.getHeaderNames()); + headers.forEach((key, value) -> names.add(key)); + return Collections.enumeration(names); + } + + // 其他需要覆盖的方法... + + public void addHeader(String name, String value) { + headers.add(name, value); + } +} diff --git a/blade-service/logpm-factory-data/logpm-factory-data-paterson/src/main/java/com/logpm/factorydata/paterson/wrapper/RequestWrapper.java b/blade-service/logpm-factory-data/logpm-factory-data-paterson/src/main/java/com/logpm/factorydata/paterson/wrapper/RequestWrapper.java new file mode 100644 index 000000000..ebc52d00d --- /dev/null +++ b/blade-service/logpm-factory-data/logpm-factory-data-paterson/src/main/java/com/logpm/factorydata/paterson/wrapper/RequestWrapper.java @@ -0,0 +1,75 @@ +package com.logpm.factorydata.paterson.wrapper; + +import javax.servlet.ReadListener; +import javax.servlet.ServletInputStream; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletRequestWrapper; +import java.io.BufferedReader; +import java.io.ByteArrayInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; + +public class RequestWrapper extends HttpServletRequestWrapper { + private final String body; + public RequestWrapper(HttpServletRequest request) throws IOException { + super(request); + StringBuilder stringBuilder = new StringBuilder(); + BufferedReader bufferedReader = null; + try { + InputStream inputStream = request.getInputStream(); + if (inputStream != null) { + bufferedReader = new BufferedReader(new InputStreamReader(inputStream)); + char[] charBuffer = new char[128]; + int bytesRead = -1; + while ((bytesRead = bufferedReader.read(charBuffer)) > 0) { + stringBuilder.append(charBuffer, 0, bytesRead); + } + } else { + stringBuilder.append(""); + } + } catch (IOException ex) { + throw ex; + } finally { + if (bufferedReader != null) { + try { + bufferedReader.close(); + } catch (IOException ex) { + throw ex; + } + } + } + body = stringBuilder.toString(); + } + + @Override + public ServletInputStream getInputStream() throws IOException { + final ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(body.getBytes()); + ServletInputStream servletInputStream = new ServletInputStream() { + @Override + public boolean isFinished() { + return false; + } + @Override + public boolean isReady() { + return false; + } + @Override + public void setReadListener(ReadListener readListener) {} + @Override + public int read() throws IOException { + return byteArrayInputStream.read(); + } + }; + return servletInputStream; + + } + @Override + public BufferedReader getReader() throws IOException { + return new BufferedReader(new InputStreamReader(this.getInputStream())); + } + public String getBody() { + return this.body; + } + +} diff --git a/blade-service/logpm-factory-data/logpm-factory-data-paterson/src/main/resources/application-dev.yml b/blade-service/logpm-factory-data/logpm-factory-data-paterson/src/main/resources/application-dev.yml new file mode 100644 index 000000000..8f9d2464a --- /dev/null +++ b/blade-service/logpm-factory-data/logpm-factory-data-paterson/src/main/resources/application-dev.yml @@ -0,0 +1,73 @@ +#服务器端口 +server: + port: 19010 + +#数据源配置 +#spring: +# datasource: +# url: ${blade.datasource.dev.url} +# username: ${blade.datasource.dev.username} +# password: ${blade.datasource.dev.password} + +spring: + #rabbitmq配置 + rabbitmq: + host: 192.168.2.46 + port: 5672 + username: admin + password: admin + #虚拟host 可以不设置,使用server默认host + virtual-host: / + #确认消息已发送到队列(Queue) + publisher-returns: true + publisher-confirm-type: correlated + # 手动提交消息 + listener: + simple: + acknowledge-mode: auto + default-requeue-rejected: false + retry: + enabled: true # 开启消费者失败重试 + initial-interval: 1000 # 初识的失败等待时长为1秒 + multiplier: 1 # 失败的等待时长倍数,下次等待时长 = multiplier * last-interval + max-attempts: 3 # 最大重试次数 + stateless: true # true无状态;false有状态。如果业务中包含事务,这里改为false + direct: + acknowledge-mode: manual + template: + mandatory: true + #排除DruidDataSourceAutoConfigure + autoconfigure: + exclude: com.alibaba.druid.spring.boot.autoconfigure.DruidDataSourceAutoConfigure + datasource: + dynamic: + druid: + #通用校验配置 + validation-query: select 1 + #启用sql日志拦截器 + proxy-filters: + - sqlLogInterceptor + #设置默认的数据源或者数据源组,默认值即为master + primary: master + datasource: + master: + druid: + #独立校验配置 + validation-query: select 1 + #oracle校验 + #validation-query: select 1 from dual + url: ${blade.datasource.factorydata-bds.master.url} + username: ${blade.datasource.factorydata-bds.master.username} + password: ${blade.datasource.factorydata-bds.master.password} + 627683: + druid: + #独立校验配置 + validation-query: select 1 + #oracle校验 + #validation-query: select 1 from dual + url: ${blade.datasource.factorydata-bds.627683.url} + username: ${blade.datasource.factorydata-bds.627683.username} + password: ${blade.datasource.factorydata-bds.627683.password} +blade: + data-scope: + enabled: false diff --git a/blade-service/logpm-factory-data/logpm-factory-data-paterson/src/main/resources/application-prod.yml b/blade-service/logpm-factory-data/logpm-factory-data-paterson/src/main/resources/application-prod.yml new file mode 100644 index 000000000..c3ed4a9e4 --- /dev/null +++ b/blade-service/logpm-factory-data/logpm-factory-data-paterson/src/main/resources/application-prod.yml @@ -0,0 +1,47 @@ +#服务器端口 +server: + port: 19010 + +#数据源配置 +#spring: +# datasource: +# url: ${blade.datasource.dev.url} +# username: ${blade.datasource.dev.username} +# password: ${blade.datasource.dev.password} + +spring: + #排除DruidDataSourceAutoConfigure + autoconfigure: + exclude: com.alibaba.druid.spring.boot.autoconfigure.DruidDataSourceAutoConfigure + datasource: + dynamic: + druid: + #通用校验配置 + validation-query: select 1 + #启用sql日志拦截器 + proxy-filters: + - sqlLogInterceptor + #设置默认的数据源或者数据源组,默认值即为master + primary: master + datasource: + master: + druid: + #独立校验配置 + validation-query: select 1 + #oracle校验 + #validation-query: select 1 from dual + url: ${blade.datasource.factorydata-bds.master.url} + username: ${blade.datasource.factorydata-bds.master.username} + password: ${blade.datasource.factorydata-bds.master.password} + 627683: + druid: + #独立校验配置 + validation-query: select 1 + #oracle校验 + #validation-query: select 1 from dual + url: ${blade.datasource.factorydata-bds.627683.url} + username: ${blade.datasource.factorydata-bds.627683.username} + password: ${blade.datasource.factorydata-bds.627683.password} +blade: + data-scope: + enabled: false diff --git a/blade-service/logpm-factory-data/logpm-factory-data-paterson/src/main/resources/application-test.yml b/blade-service/logpm-factory-data/logpm-factory-data-paterson/src/main/resources/application-test.yml new file mode 100644 index 000000000..ab8655b3d --- /dev/null +++ b/blade-service/logpm-factory-data/logpm-factory-data-paterson/src/main/resources/application-test.yml @@ -0,0 +1,73 @@ +#服务器端口 +server: + port: 19010 + +#数据源配置 +#spring: +# datasource: +# url: ${blade.datasource.dev.url} +# username: ${blade.datasource.dev.username} +# password: ${blade.datasource.dev.password} + +spring: + #rabbitmq配置 + rabbitmq: + host: 192.168.2.110 + port: 5672 + username: admin + password: Slwk@123654 + #虚拟host 可以不设置,使用server默认host + virtual-host: / + #确认消息已发送到队列(Queue) + publisher-returns: true + publisher-confirm-type: correlated + # 手动提交消息 + listener: + simple: + acknowledge-mode: auto + default-requeue-rejected: false + retry: + enabled: true # 开启消费者失败重试 + initial-interval: 1000 # 初识的失败等待时长为1秒 + multiplier: 1 # 失败的等待时长倍数,下次等待时长 = multiplier * last-interval + max-attempts: 3 # 最大重试次数 + stateless: true # true无状态;false有状态。如果业务中包含事务,这里改为false + direct: + acknowledge-mode: manual + template: + mandatory: true + #排除DruidDataSourceAutoConfigure + autoconfigure: + exclude: com.alibaba.druid.spring.boot.autoconfigure.DruidDataSourceAutoConfigure + datasource: + dynamic: + druid: + #通用校验配置 + validation-query: select 1 + #启用sql日志拦截器 + proxy-filters: + - sqlLogInterceptor + #设置默认的数据源或者数据源组,默认值即为master + primary: master + datasource: + master: + druid: + #独立校验配置 + validation-query: select 1 + #oracle校验 + #validation-query: select 1 from dual + url: ${blade.datasource.factorydata-bds.master.url} + username: ${blade.datasource.factorydata-bds.master.username} + password: ${blade.datasource.factorydata-bds.master.password} + 627683: + druid: + #独立校验配置 + validation-query: select 1 + #oracle校验 + #validation-query: select 1 from dual + url: ${blade.datasource.factorydata-bds.627683.url} + username: ${blade.datasource.factorydata-bds.627683.username} + password: ${blade.datasource.factorydata-bds.627683.password} +blade: + data-scope: + enabled: false diff --git a/blade-service/logpm-factory-data/logpm-factory-data-paterson/src/main/resources/application.yml b/blade-service/logpm-factory-data/logpm-factory-data-paterson/src/main/resources/application.yml new file mode 100644 index 000000000..33da94b58 --- /dev/null +++ b/blade-service/logpm-factory-data/logpm-factory-data-paterson/src/main/resources/application.yml @@ -0,0 +1,31 @@ +#mybatis-plus配置 +mybatis-plus: + mapper-locations: classpath:com/logpm/**/mapper/*Mapper.xml + #实体扫描,多个package用逗号或者分号分隔 + typeAliasesPackage: com.logpm.**.entity + +#swagger扫描路径配置 +swagger: + base-packages: + - org.springblade + - com.logpm + +#oss配置 +oss: + enabled: true + name: minio + tenant-mode: false + endpoint: http://8.137.14.82:9000 + access-key: minio + secret-key: 123123123 + bucket-name: bladex + + +logging: + config: classpath:logback.xml + + +spring: + main: + allow-circular-references: true + diff --git a/blade-service/logpm-factory-data/logpm-factory-data-paterson/src/main/resources/logback.xml b/blade-service/logpm-factory-data/logpm-factory-data-paterson/src/main/resources/logback.xml new file mode 100644 index 000000000..222bcd196 --- /dev/null +++ b/blade-service/logpm-factory-data/logpm-factory-data-paterson/src/main/resources/logback.xml @@ -0,0 +1,40 @@ + + + + logback + + + + + + + + + + + + ${CONSOLE_LOG_PATTERN} + utf8 + + + + + ${log.path} + + ${log.path}.%d{yyyy-MM-dd}.zip + + + %date %level [%thread] %logger{36} [%file : %line] %msg%n + + + + + + + + + + diff --git a/blade-service/logpm-factory-data/pom.xml b/blade-service/logpm-factory-data/pom.xml index 4e8453707..0f652cc51 100644 --- a/blade-service/logpm-factory-data/pom.xml +++ b/blade-service/logpm-factory-data/pom.xml @@ -22,6 +22,7 @@ logpm-factory-data-mwh logpm-factory-data-mengtian logpm-factory-data-pan + logpm-factory-data-paterson From 7304ca69c45f9a2db2c34aebba0a312241a08974 Mon Sep 17 00:00:00 2001 From: zhenghaoyu Date: Tue, 1 Apr 2025 17:03:48 +0800 Subject: [PATCH 5/9] =?UTF-8?q?1.=E4=BC=98=E5=8C=96=E5=8D=B8=E8=BD=A6?= =?UTF-8?q?=E6=95=B0=E6=8D=AE=E5=90=8C=E6=AD=A5=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../impl/CarsLoadAsyncServiceImpl.java | 2 +- .../impl/TrunklineCarsLoadServiceImpl.java | 21 +++++++++++-------- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/impl/CarsLoadAsyncServiceImpl.java b/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/impl/CarsLoadAsyncServiceImpl.java index 5d1d81720..5946e2af6 100644 --- a/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/impl/CarsLoadAsyncServiceImpl.java +++ b/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/impl/CarsLoadAsyncServiceImpl.java @@ -596,7 +596,7 @@ public class CarsLoadAsyncServiceImpl implements ICarsLoadAsyncService { abnormalRecordEntity.setDealTime(new Date()); abnormalRecordEntity.setDealUserId(userId); abnormalRecordEntity.setDealUserName(nickName); - abnormalRecordEntity.setRemark("无卸车记录,已入库,系统判定自动完结"); + abnormalRecordEntity.setRemark("无卸车记录,已在其他车次入库,系统判定自动完结"); } addList.add(abnormalRecordEntity); // abnormalRecordClient.addAbnormalRecord(abnormalRecordEntity); diff --git a/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/impl/TrunklineCarsLoadServiceImpl.java b/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/impl/TrunklineCarsLoadServiceImpl.java index a96a20787..42a9e2c92 100644 --- a/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/impl/TrunklineCarsLoadServiceImpl.java +++ b/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/impl/TrunklineCarsLoadServiceImpl.java @@ -13618,7 +13618,13 @@ public class TrunklineCarsLoadServiceImpl extends BaseServiceImpl Date: Tue, 1 Apr 2025 17:31:47 +0800 Subject: [PATCH 6/9] =?UTF-8?q?feat(all):=20=E7=99=BE=E5=BE=97=E8=83=9C?= =?UTF-8?q?=E5=B7=A5=E5=8E=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 1 增加百得胜工厂数据对接 --- .../logpm-factory-data-paterson/Dockerfile | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 blade-service/logpm-factory-data/logpm-factory-data-paterson/Dockerfile diff --git a/blade-service/logpm-factory-data/logpm-factory-data-paterson/Dockerfile b/blade-service/logpm-factory-data/logpm-factory-data-paterson/Dockerfile new file mode 100644 index 000000000..678c6ceaf --- /dev/null +++ b/blade-service/logpm-factory-data/logpm-factory-data-paterson/Dockerfile @@ -0,0 +1,14 @@ +FROM 192.168.2.110:7777/hwy/hwy_base:v1.0 + +MAINTAINER h5u@163.com + +RUN mkdir -p /logpm/logpm-factory-data-paterson + +WORKDIR /logpm/logpm-factory-data-paterson + +EXPOSE 19010 + +ADD ./target/logpm-factory-data-paterson.jar ./app.jar + +ENTRYPOINT ["java", "-Djava.security.egd=file:/dev/./urandom", "-jar","-Xms128m","-Xmx512m", "app.jar"] +CMD ["--spring.profiles.active=test"] From 596e420b091afbc7aea421636bae4f270e579c5e Mon Sep 17 00:00:00 2001 From: "pref_mail@163.com" Date: Tue, 1 Apr 2025 17:48:24 +0800 Subject: [PATCH 7/9] =?UTF-8?q?add:=E4=BF=AE=E5=A4=8D=E5=95=86=E5=AE=B6?= =?UTF-8?q?=E7=AB=AF=E6=9A=82=E5=AD=98=E4=BD=86=E5=85=A5=E5=BA=93=E6=93=8D?= =?UTF-8?q?=E4=BD=9C=E6=95=B0=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../suofeiya/job/SpiderDataJob.java | 1 + .../impl/TrunklineAdvanceServiceImpl.java | 29 +++++++++++++++++-- 2 files changed, 28 insertions(+), 2 deletions(-) diff --git a/blade-service/logpm-factory-data/logpm-factory-data-suofeiya/src/main/java/com/logpm/factorydata/suofeiya/job/SpiderDataJob.java b/blade-service/logpm-factory-data/logpm-factory-data-suofeiya/src/main/java/com/logpm/factorydata/suofeiya/job/SpiderDataJob.java index 966ba7c03..eb649d33f 100644 --- a/blade-service/logpm-factory-data/logpm-factory-data-suofeiya/src/main/java/com/logpm/factorydata/suofeiya/job/SpiderDataJob.java +++ b/blade-service/logpm-factory-data/logpm-factory-data-suofeiya/src/main/java/com/logpm/factorydata/suofeiya/job/SpiderDataJob.java @@ -194,6 +194,7 @@ public class SpiderDataJob { packageInfoEntity.setUpdateTime(new Date()); packageInfoEntity.setIsDeleted(0); packageInfoEntity.setStatus(1); + packageInfoEntity.setDealerName(spiderInforEntity.getBindBussiness()); // 判断这个包条是否存在鱼数据库 如果不存在 则执行 diff --git a/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/impl/TrunklineAdvanceServiceImpl.java b/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/impl/TrunklineAdvanceServiceImpl.java index 028f13378..84a0e6acb 100644 --- a/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/impl/TrunklineAdvanceServiceImpl.java +++ b/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/impl/TrunklineAdvanceServiceImpl.java @@ -39,8 +39,11 @@ import org.springblade.common.exception.CustomerException; import org.springblade.common.utils.CommonUtil; import org.springblade.core.mp.base.BaseServiceImpl; import org.springblade.core.secure.utils.AuthUtil; +import org.springblade.core.tool.api.R; import org.springblade.core.tool.utils.Func; import org.springblade.core.tool.utils.StringUtil; +import org.springblade.system.entity.Tenant; +import org.springblade.system.feign.ISysClient; import org.springframework.amqp.rabbit.core.RabbitTemplate; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -65,6 +68,7 @@ public class TrunklineAdvanceServiceImpl extends BaseServiceImpl advanceDetailEntities, Long warehouseId) { - BasicdataWarehouseEntity warehouseEntity = basicdataWarehouseClient.getEntityWarehouseId(warehouseId); + + + Integer isTransfer; + + R tenant = sysClient.getTenant(AuthUtil.getTenantId()); + if(tenant.isSuccess()){ + Tenant data = tenant.getData(); + if(new Integer(2).equals(data.getTenantType())){ + isTransfer=0; + } else { + isTransfer = 1; + } + } else { + isTransfer = 1; + } + + + BasicdataWarehouseEntity warehouseEntity = basicdataWarehouseClient.getEntityWarehouseId(warehouseId); if (Objects.isNull(warehouseEntity)) { log.warn("############saveOrderAndPackages: 仓库信息不存在warehouseId={}", warehouseId); throw new CustomerException(405, "仓库信息不存在"); @@ -1010,7 +1031,11 @@ public class TrunklineAdvanceServiceImpl extends BaseServiceImpl Date: Tue, 1 Apr 2025 17:49:36 +0800 Subject: [PATCH 8/9] =?UTF-8?q?1.=E4=BC=98=E5=8C=96=E5=AF=BC=E5=85=A5?= =?UTF-8?q?=E6=95=B0=E6=8D=AE=E7=89=A9=E6=96=99=E4=BD=93=E7=A7=AF=E9=87=8D?= =?UTF-8?q?=E9=87=8F=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/impl/OpenOrderServiceImpl.java | 35 ++++++++++++++++--- 1 file changed, 31 insertions(+), 4 deletions(-) diff --git a/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/impl/OpenOrderServiceImpl.java b/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/impl/OpenOrderServiceImpl.java index 126bd274a..ddc003d52 100644 --- a/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/impl/OpenOrderServiceImpl.java +++ b/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/impl/OpenOrderServiceImpl.java @@ -1821,6 +1821,12 @@ public class OpenOrderServiceImpl implements IOpenOrderService { dto.setOrderCode(dto.getOrderCode().trim()); dto.setOrderPackageCode(dto.getOrderPackageCode().trim()); }); + + List materialEntities = basicMaterialClient.findAllList(); + //把materialEntities转化成以productCode和productName拼接为key的Map + Map materialEntityMap = materialEntities.stream().collect(Collectors.toMap(item -> item.getProductCode() + "&&" + item.getName(), item -> item)); + + //排除pacakgeDetailExcelDTOS中的orderPackageCode为空的元素 pacakgeDetailExcelDTOS = pacakgeDetailExcelDTOS.stream().filter(item -> StringUtil.isNotBlank(item.getOrderPackageCode())).collect(Collectors.toList()); //把importStandardOuPaiDTOS中orderPackageCode相同的元素去重 @@ -2077,16 +2083,37 @@ public class OpenOrderServiceImpl implements IOpenOrderService { advanceDetailModel.setQuantity(1); advanceDetailModel.setServiceNum(pacakgeDetailExcelDTO.getServiceNum()); advanceDetailModel.setPackageStatus("0"); + + String materialName = pacakgeDetailExcelDTO.getMaterialName(); + String materialCode = pacakgeDetailExcelDTO.getMaterialCode(); + advanceDetailModel.setMaterialName(materialName); + advanceDetailModel.setMaterialCode(materialCode); + if (!Objects.isNull(pacakgeDetailExcelDTO.getVolume())) { advanceDetailModel.setVolume(new BigDecimal(pacakgeDetailExcelDTO.getVolume())); } else { advanceDetailModel.setVolume(BigDecimal.ZERO); + + BasicMaterialEntity basicMaterialEntity = materialEntityMap.get(materialCode + "&&" + materialName); + + if (!Objects.isNull(basicMaterialEntity)) { + advanceDetailModel.setMaterialId(basicMaterialEntity.getId()); + + String weight = basicMaterialEntity.getWeight(); + if (StringUtil.isBlank(weight)) { + weight = "0"; + } + String volume2 = basicMaterialEntity.getVolume(); + if (StringUtil.isBlank(volume2)) { + volume2 = "0"; + } + advanceDetailModel.setWeight(new BigDecimal(weight)); + advanceDetailModel.setVolume(new BigDecimal(volume2)); + } + } - String materialName = pacakgeDetailExcelDTO.getMaterialName(); - String materialCode = pacakgeDetailExcelDTO.getMaterialCode(); - advanceDetailModel.setMaterialName(materialName); - advanceDetailModel.setMaterialCode(materialCode); + // if (StringUtil.isNotBlank(materialCode) && StringUtil.isNotBlank(materialName)) { From 3a3eb12ec02d56f072f77369063ecad9dfa125b2 Mon Sep 17 00:00:00 2001 From: "pref_mail@163.com" Date: Tue, 1 Apr 2025 21:17:19 +0800 Subject: [PATCH 9/9] =?UTF-8?q?add:=E4=BF=AE=E5=A4=8D=E6=9F=A5=E8=AF=A2?= =?UTF-8?q?=E7=94=A8=E6=88=B7id=E4=B8=BAnull=E7=9A=84=E6=83=85=E5=86=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../basicdata/service/impl/BasicdataTrayServiceImpl.java | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/blade-service/logpm-basicdata/src/main/java/com/logpm/basicdata/service/impl/BasicdataTrayServiceImpl.java b/blade-service/logpm-basicdata/src/main/java/com/logpm/basicdata/service/impl/BasicdataTrayServiceImpl.java index 344a3eee0..890b25e11 100644 --- a/blade-service/logpm-basicdata/src/main/java/com/logpm/basicdata/service/impl/BasicdataTrayServiceImpl.java +++ b/blade-service/logpm-basicdata/src/main/java/com/logpm/basicdata/service/impl/BasicdataTrayServiceImpl.java @@ -173,7 +173,7 @@ public class BasicdataTrayServiceImpl extends BaseServiceImpl operateUserIds = records.stream().map(BasicdataStockArticleVO::getOperateUser).collect(Collectors.toList()); List listR = new ArrayList<>(); - if (CollUtil.isEmpty(operateUserIds)) { + if (CollUtil.isNotEmpty(operateUserIds)) { R> temp = userClient.userInfoByIds(AuthUtil.getTenantId(), CollUtil.join(operateUserIds, StrUtil.COMMA)); if (temp.isSuccess() && temp.getData() != null) { listR.addAll(temp.getData()); @@ -185,9 +185,7 @@ public class BasicdataTrayServiceImpl extends BaseServiceImpl