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/broadcast/FanoutConstants.java b/blade-biz-common/src/main/java/org/springblade/common/constant/broadcast/FanoutConstants.java index 6a041b053..13a14e86a 100644 --- a/blade-biz-common/src/main/java/org/springblade/common/constant/broadcast/FanoutConstants.java +++ b/blade-biz-common/src/main/java/org/springblade/common/constant/broadcast/FanoutConstants.java @@ -142,6 +142,21 @@ public abstract class FanoutConstants { } + /** + * 备货节点 + * + * @see org.springblade.common.model.StockUpVO + **/ + interface tripartite { + + String EXCHANGE = "fanout.trunkline.tripartite" + ModuleNameConstant.DEVAUTH; + + interface QUEUE { + String SIGN = "fanout.trunkline.tripartite.sign" + ModuleNameConstant.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-biz-common/src/main/java/org/springblade/common/constant/order/OrderSplitStatusConstant.java b/blade-biz-common/src/main/java/org/springblade/common/constant/order/OrderSplitStatusConstant.java new file mode 100644 index 000000000..7953b447a --- /dev/null +++ b/blade-biz-common/src/main/java/org/springblade/common/constant/order/OrderSplitStatusConstant.java @@ -0,0 +1,24 @@ +package org.springblade.common.constant.order; + + +import lombok.Getter; + +/** + * 订单拆单状态 + * 状态:0=无,1=进行中 + */ +@Getter +public enum OrderSplitStatusConstant { + + No("无",0), + InProgress("进行中",1); + + private final String name; + private final Integer value; + + OrderSplitStatusConstant(String name, Integer value) { + this.name = name; + this.value = value; + } + +} diff --git a/blade-biz-common/src/main/java/org/springblade/common/model/TripartiteVO.java b/blade-biz-common/src/main/java/org/springblade/common/model/TripartiteVO.java new file mode 100644 index 000000000..8d5eb0584 --- /dev/null +++ b/blade-biz-common/src/main/java/org/springblade/common/model/TripartiteVO.java @@ -0,0 +1,50 @@ +package org.springblade.common.model; + +import lombok.Data; + +import java.io.Serializable; +import java.util.Date; +import java.util.List; + +@Data +public class TripartiteVO implements Serializable { + + /** 发车批次号 */ + private String carsNo ; + + /** 司机id */ + private Long driverId ; + /** 司机名称 */ + private String driverName ; + /** 司机电话 */ + private String driverMobile ; + /** 副驾id */ + private Long assistantId ; + /** 副驾i名称 */ + private String assistantName ; + /** 副驾i电话 */ + private String assistantMobile ; + + /** 车辆id */ + private Long carId ; + + /** 送货方式:1=自提,2=送货 */ + private String deliveryType ; + + /** 客户类型:1=商场,2=C端客户[多选] */ + private String customerType ; + + /** 承运商id */ + private Long carrierId ; + /** 承运商名称 */ + private String carrierName ; + /** 承运单号 */ + private String carrierOrderCode ; + /** 承运时间 */ + private Date carrierTime ; + /** 车牌号 */ + private String carNumber ; + + private List packageDataList; + +} diff --git a/blade-service-api/logpm-distribution-api/src/main/java/com/logpm/distribution/entity/DistributionStockArticleEntity.java b/blade-service-api/logpm-distribution-api/src/main/java/com/logpm/distribution/entity/DistributionStockArticleEntity.java index ddf0681fb..b131a3808 100644 --- a/blade-service-api/logpm-distribution-api/src/main/java/com/logpm/distribution/entity/DistributionStockArticleEntity.java +++ b/blade-service-api/logpm-distribution-api/src/main/java/com/logpm/distribution/entity/DistributionStockArticleEntity.java @@ -454,6 +454,9 @@ public class DistributionStockArticleEntity extends TenantEntity { @ApiModelProperty(value = "备注") private String remark; + + @ApiModelProperty(value = "拆单状态") + private Integer splitStatus; /** /* * 未入库数量 *//* diff --git a/blade-service-api/logpm-distribution-api/src/main/java/com/logpm/distribution/vo/app/queryOrderVO.java b/blade-service-api/logpm-distribution-api/src/main/java/com/logpm/distribution/vo/app/queryOrderVO.java index c5141e58a..528f4c602 100644 --- a/blade-service-api/logpm-distribution-api/src/main/java/com/logpm/distribution/vo/app/queryOrderVO.java +++ b/blade-service-api/logpm-distribution-api/src/main/java/com/logpm/distribution/vo/app/queryOrderVO.java @@ -1,9 +1,8 @@ package com.logpm.distribution.vo.app; +import com.alibaba.fastjson.JSONObject; import com.logpm.distribution.entity.DistributionParcelListEntity; import com.logpm.distribution.entity.DistributionStockArticleEntity; -import com.logpm.distribution.vo.DistributionParcelListVO; -import com.logpm.distribution.vo.DistributionStockListInfoVO; import com.logpm.distribution.vo.DistributionStockListVO; import io.swagger.annotations.ApiModelProperty; import lombok.Data; @@ -42,4 +41,11 @@ public class queryOrderVO extends DistributionStockArticleEntity { private Integer inventoryNum; + /** + * 未入库包件列表 + */ + @ApiModelProperty(value = "未入库包件列表") + private List noIncomingList; + + } diff --git a/blade-service-api/logpm-factory-api/src/main/java/com/logpm/factory/oupai/vo/OpFactoryPackageDataVO.java b/blade-service-api/logpm-factory-api/src/main/java/com/logpm/factory/oupai/vo/OpFactoryPackageDataVO.java index 4fb5d9d11..4c7c2d99a 100644 --- a/blade-service-api/logpm-factory-api/src/main/java/com/logpm/factory/oupai/vo/OpFactoryPackageDataVO.java +++ b/blade-service-api/logpm-factory-api/src/main/java/com/logpm/factory/oupai/vo/OpFactoryPackageDataVO.java @@ -41,6 +41,15 @@ public class OpFactoryPackageDataVO implements Serializable { */ private String pushStatus; + /** + * 业务员模式 + * + * 经销商 + * + * 干仓配 不进行数据回传 + */ + private String businessModel; + 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-api/logpm-trunkline-api/src/main/java/com/logpm/trunkline/feign/ITrunklineAdvanceDetailClient.java b/blade-service-api/logpm-trunkline-api/src/main/java/com/logpm/trunkline/feign/ITrunklineAdvanceDetailClient.java index ac642dcee..473b63039 100644 --- a/blade-service-api/logpm-trunkline-api/src/main/java/com/logpm/trunkline/feign/ITrunklineAdvanceDetailClient.java +++ b/blade-service-api/logpm-trunkline-api/src/main/java/com/logpm/trunkline/feign/ITrunklineAdvanceDetailClient.java @@ -1,7 +1,6 @@ package com.logpm.trunkline.feign; import com.logpm.trunkline.entity.TrunklineAdvanceDetailEntity; -import com.logpm.trunkline.vo.TrunklineAdvanceDetailVO; import org.springblade.common.constant.ModuleNameConstant; import org.springblade.core.tool.api.R; import org.springframework.cloud.openfeign.FeignClient; @@ -48,4 +47,7 @@ public interface ITrunklineAdvanceDetailClient { @PostMapping(API_PREFIX + "/maintainMaterial") R maintainMaterial(@RequestBody Map map); + + @GetMapping(API_PREFIX+"/findListByStockArticleId") + List findListByStockArticleId(@RequestParam Long stockArticleId, @RequestParam Long warehouseId); } diff --git a/blade-service/logpm-aftersales/src/main/java/com/logpm/aftersales/service/impl/AftersalesAbnormalRecordServiceImpl.java b/blade-service/logpm-aftersales/src/main/java/com/logpm/aftersales/service/impl/AftersalesAbnormalRecordServiceImpl.java index 666606365..dae73affd 100644 --- a/blade-service/logpm-aftersales/src/main/java/com/logpm/aftersales/service/impl/AftersalesAbnormalRecordServiceImpl.java +++ b/blade-service/logpm-aftersales/src/main/java/com/logpm/aftersales/service/impl/AftersalesAbnormalRecordServiceImpl.java @@ -339,6 +339,16 @@ public class AftersalesAbnormalRecordServiceImpl extends BaseServiceImpl updateScanZeroDetailEntityList = new ArrayList<>(); List addParcelNumberEntityList = new ArrayList<>(); List updateRecordZeroDetailList = new ArrayList<>(); 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> allTaskList(Query query, DistributionSplitAllTaskSearchDTO distributionSplitAllTaskSearchDTO) { + public R> allTaskList(Query query, DistributionSplitAllTaskSearchDTO distributionSplitAllTaskSearchDTO) { return distributionSplitOrderTaskService.allTaskList(query, distributionSplitAllTaskSearchDTO); } @@ -96,7 +98,7 @@ public class DistributionSplitOrderTaskController { } @GetMapping("/task-list") - public R> taskList(Query query, DistributionSplitTaskSearchDTO distributionSplitTaskSearchDTO) { + public R> taskList(Query query, DistributionSplitTaskSearchDTO distributionSplitTaskSearchDTO) { return distributionSplitOrderTaskService.taskList(query, distributionSplitTaskSearchDTO); } @@ -115,6 +117,11 @@ public class DistributionSplitOrderTaskController { return distributionSplitOrderTaskService.checkOrderCode(orderCode); } + @GetMapping("/check-order-code-by-stock-article-id") + public R checkOrderCode(Long stockArticleId) { + return distributionSplitOrderTaskService.checkOrderCode(stockArticleId); + } + @GetMapping("/get-package-code-by-order-code") public R> getPackageCodeByOrderCode(Query query, String orderCode) { return distributionSplitOrderTaskService.getPackageCodeByOrderCode(query, orderCode); @@ -124,4 +131,9 @@ public class DistributionSplitOrderTaskController { public R> getPackageCodeByTaskId(Long taskId) { return distributionSplitOrderTaskService.getPackageCodeByTaskId( taskId); } + + @GetMapping("/get-allow-split-order-number") + public R getAllowSplitOrderNumber(Long stockArticleId){ + return R.data(distributionSplitOrderTaskService.getSplitOrderAllowCount(stockArticleId)); + } } 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 6c950d0e8..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 @@ -38,6 +38,7 @@ import org.springblade.common.exception.CustomerException; import org.springblade.core.mp.support.BladePage; import org.springblade.core.mp.support.Condition; import org.springblade.core.mp.support.Query; +import org.springblade.core.redis.cache.BladeRedis; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RestController; @@ -59,8 +60,9 @@ public class DistributionStockArticleClient implements IDistributionStockArticle private final IDistributionStockArticleService distributionStockArticleService; private final IDistributionParcelListService distributionParcelListService; + private final BladeRedis bladeRedis; - @Override + @Override @GetMapping(TOP) public BladePage top(Integer current, Integer size) { Query query = new Query(); @@ -73,12 +75,42 @@ public class DistributionStockArticleClient implements IDistributionStockArticle @Override @PostMapping(API_PREFIX + "/addData") public Long addData(DistributionStockArticleEntity distributionStockArticleEntity) { - boolean saveFlag = distributionStockArticleService.save(distributionStockArticleEntity); - if(saveFlag){ - return distributionStockArticleEntity.getId(); - }else{ + + String orderCode = distributionStockArticleEntity.getOrderCode(); + Long warehouseId = distributionStockArticleEntity.getWarehouseId(); + + String key = orderCode + warehouseId; + + 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{ + 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(); + }else{ + boolean saveFlag = distributionStockArticleService.save(distributionStockArticleEntity); + if(saveFlag){ + bladeRedis.setEx(key,distributionStockArticleEntity.getId().toString(),30L); + return distributionStockArticleEntity.getId(); + }else{ + return 0L; + } + } + } + }catch (Exception e){ + log.error("#######addData: 保存订单失败",e); return 0L; } + } @Override diff --git a/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/service/IDistributionSplitOrderTaskService.java b/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/service/IDistributionSplitOrderTaskService.java index 7de3e8547..c5531b703 100644 --- a/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/service/IDistributionSplitOrderTaskService.java +++ b/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/service/IDistributionSplitOrderTaskService.java @@ -6,6 +6,8 @@ import com.logpm.distribution.dto.splitOrder.DistributionSplitAllTaskSearchDTO; import com.logpm.distribution.dto.splitOrder.DistributionSplitTaskSearchDTO; import com.logpm.distribution.entity.DistributionSplitOrderAllTaskEntity; import com.logpm.distribution.entity.DistributionSplitOrderTaskEntity; +import com.logpm.distribution.vo.DistributionSplitOrderAllTaskVO; +import com.logpm.distribution.vo.DistributionSplitOrderTaskVO; import com.logpm.distribution.vo.SplitPackageOrderVO; import org.springblade.core.mp.base.BaseService; import org.springblade.core.mp.support.Query; @@ -24,7 +26,7 @@ public interface IDistributionSplitOrderTaskService extends BaseService> taskList(Query query, DistributionSplitTaskSearchDTO distributionSplitTaskSearchDTO); + R> taskList(Query query, DistributionSplitTaskSearchDTO distributionSplitTaskSearchDTO); /** * 拆单总任务 @@ -32,7 +34,7 @@ public interface IDistributionSplitOrderTaskService extends BaseService> allTaskList(Query query, DistributionSplitAllTaskSearchDTO distributionSplitAllTaskSearchDTO); + R> allTaskList(Query query, DistributionSplitAllTaskSearchDTO distributionSplitAllTaskSearchDTO); /** * 创建任务 @@ -115,6 +117,10 @@ public interface IDistributionSplitOrderTaskService extends BaseService checkOrderCode(String orderCode); + R checkOrderCode(Long stockArticleId); + + long getSplitOrderAllowCount(Long stockArticleId); + R> getPackageCodeByTaskId(Long taskId); R> getPackageCodeByOrderCode(Query query, String orderCode); diff --git a/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/service/impl/DistributionSplitOrderTaskServiceImpl.java b/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/service/impl/DistributionSplitOrderTaskServiceImpl.java index 22175185e..fda556a3c 100644 --- a/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/service/impl/DistributionSplitOrderTaskServiceImpl.java +++ b/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/service/impl/DistributionSplitOrderTaskServiceImpl.java @@ -1,11 +1,13 @@ package com.logpm.distribution.service.impl; +import cn.hutool.core.bean.BeanUtil; import cn.hutool.core.date.DateUtil; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.toolkit.SerializationUtils; import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.core.toolkit.support.SFunction; +import com.logpm.distribution.bean.Resp; import com.logpm.distribution.dto.splitOrder.DistributionSplitAllTaskSearchDTO; import com.logpm.distribution.dto.splitOrder.DistributionSplitTaskSearchDTO; import com.logpm.distribution.entity.DistributionParcelListEntity; @@ -21,13 +23,12 @@ import com.logpm.distribution.service.IDistributionSplitOrderDetailService; import com.logpm.distribution.service.IDistributionSplitOrderLogService; import com.logpm.distribution.service.IDistributionSplitOrderTaskService; import com.logpm.distribution.service.IDistributionStockArticleService; +import com.logpm.distribution.vo.DistributionSplitOrderAllTaskVO; +import com.logpm.distribution.vo.DistributionSplitOrderTaskVO; import com.logpm.distribution.vo.SplitPackageOrderVO; import lombok.AllArgsConstructor; import lombok.extern.slf4j.Slf4j; -import org.springblade.common.constant.order.OrderReservationStatusConstant; -import org.springblade.common.constant.order.OrderSplitAllTaskStateConstant; -import org.springblade.common.constant.order.OrderSplitStateConstant; -import org.springblade.common.constant.order.OrderStatusConstant; +import org.springblade.common.constant.order.*; import org.springblade.common.constant.orderpackage.*; import org.springblade.common.exception.CustomerException; import org.springblade.core.mp.base.BaseServiceImpl; @@ -37,15 +38,15 @@ import org.springblade.core.redis.lock.LockType; import org.springblade.core.redis.lock.RedisLockClient; import org.springblade.core.secure.utils.AuthUtil; import org.springblade.core.tool.api.R; +import org.springblade.system.entity.User; +import org.springblade.system.feign.IUserClient; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Objects; +import java.util.*; import java.util.concurrent.TimeUnit; import java.util.stream.Collectors; +import java.util.stream.Stream; @Service @AllArgsConstructor @@ -58,10 +59,11 @@ public class DistributionSplitOrderTaskServiceImpl extends BaseServiceImpl> taskList(Query query, DistributionSplitTaskSearchDTO distributionSplitTaskSearchDTO) { + public R> taskList(Query query, DistributionSplitTaskSearchDTO distributionSplitTaskSearchDTO) { LambdaQueryWrapper queryWrapper = Wrappers.lambdaQuery(); if (distributionSplitTaskSearchDTO.getSplitOrderAllTaskId() != null) { queryWrapper.eq(DistributionSplitOrderTaskEntity::getSplitOrderAllTaskId, distributionSplitTaskSearchDTO.getSplitOrderAllTaskId()); @@ -83,10 +85,31 @@ public class DistributionSplitOrderTaskServiceImpl extends BaseServiceImpl page = Condition.getPage(query); - List list = list(page, queryWrapper); - page.setRecords(list); + IPage pageRes = Condition.getPage(query); + List list = list(page, queryWrapper); + List listVo = new ArrayList<>(); + if (list != null && !list.isEmpty()) { + Map userIdNameMap = getUserIdNameMap(list.stream().map(DistributionSplitOrderTaskEntity::getCreateUser).collect(Collectors.toList())); + + listVo = list.stream().map(item -> { + DistributionSplitOrderTaskVO distributionSplitOrderTaskVO = new DistributionSplitOrderTaskVO(); + BeanUtil.copyProperties(item, distributionSplitOrderTaskVO); + distributionSplitOrderTaskVO.setCreateUserName(userIdNameMap.get(item.getCreateUser())); + return distributionSplitOrderTaskVO; + }).collect(Collectors.toList()); + } - return R.data(page); + pageRes.setRecords(listVo); + pageRes.setPages(page.getPages()); + pageRes.setTotal(page.getTotal()); + + return R.data(pageRes); + } + + private Map getUserIdNameMap(List list) { + String createUserIds = list.stream().map((d) -> d + "").collect(Collectors.joining(",")); + List users = iUserClient.userInfoByIds(AuthUtil.getTenantId(), createUserIds).getData(); + return users.stream().collect(Collectors.toMap(User::getId, User::getName)); } @Transactional @@ -107,28 +130,41 @@ public class DistributionSplitOrderTaskServiceImpl extends BaseServiceImpllambdaQuery() - .in(DistributionParcelListEntity::getStockArticleId, stockArticleId) - .ne(DistributionParcelListEntity::getOrderPackageStatus, OrderPackageStatusConstant.yiqianshou.getValue()) - .eq(DistributionParcelListEntity::getOrderPackageReservationStatus, OrderPackageReservationStatusConstant.daiyuyue.getValue()) - .eq(DistributionParcelListEntity::getOrderPackageLoadingStatus, OrderPackageLoadingStatusConstant.weizhuancghe.getValue()) - .eq(DistributionParcelListEntity::getOrderPackageFreezeStatus, OrderPackageFreezeStatusConstant.weidongjie.getValue()) - .eq(DistributionParcelListEntity::getIsTransfer, 0) - ); - long packageAllCount = distributionParcelListService.count( - Wrappers.lambdaQuery() - .in(DistributionParcelListEntity::getStockArticleId, stockArticleId) - ); + long packageAllowCount = getSplitOrderAllowCount(stockArticleId); + long packageAllCount = getSplitOrderAllCount(stockArticleId); + if (packageAllowCount == 0 || packageAllCount == 1) { return R.fail("订单"+ distributionStockArticle.getOrderCode() +"包件数量不足,不允许拆单"); } + boolean exists = exists( + Wrappers.lambdaQuery() + .eq(DistributionSplitOrderTaskEntity::getStockArticleId, stockArticleId) + .eq(DistributionSplitOrderTaskEntity::getState, OrderSplitStateConstant.InProgress.getValue()) + ); + if (exists) { + return R.fail("订单"+ distributionStockArticle.getOrderCode() +"正在拆单中,不允许重复拆单"); + } + + int taskNumber = distributionSplitOrderTaskList + .stream() + .map(DistributionSplitOrderTaskEntity::getTaskNumber) + .mapToInt(Integer::intValue) + .sum(); + long tipNumber = packageAllCount > packageAllowCount ? packageAllowCount : packageAllowCount - 1; + if (packageAllowCount < taskNumber) { + return R.fail("拆单包件数量不足,请重新填写,目前可拆单数量:" + tipNumber); + } + if (packageAllCount <= taskNumber) { + return R.fail("拆单数需要小于订单总数量,请重新填写,目前可拆单数量:" + tipNumber); + } + taskLock(stockArticleId, () -> { String allTaskNo = getAllTaskNo(); DistributionSplitOrderAllTaskEntity allTask = new DistributionSplitOrderAllTaskEntity(); @@ -138,10 +174,7 @@ public class DistributionSplitOrderTaskServiceImpl extends BaseServiceImpl existsList = distributionSplitOrderDetailService.list(Wrappers.lambdaQuery() .in(DistributionSplitOrderDetailEntity::getOrderPackageCode, packageCodes) ); - int addNumber = packageCodes.size(); if (!existsList.isEmpty()) { if (existsList.stream().anyMatch(detail -> !detail.getSplitOrderTaskId().equals(taskId) && detail.getState().equals(OrderPackageSplitStateConstant.finish.getValue()))) { return R.fail("提交包件包含其他拆单任务的包件"); @@ -318,7 +354,7 @@ public class DistributionSplitOrderTaskServiceImpl extends BaseServiceImpllambdaQuery() - .eq(DistributionStockArticleEntity::getId, task.getStockArticleId()) - .eq(DistributionStockArticleEntity::getIsDeleted, 1) - ); - if (oldStockArticle == null) { - return R.fail("订单错误,无法删除"); - } - oldStockArticle.setIsDeleted(0); - } - - List packageList = distributionParcelListService.list(Wrappers.lambdaQuery() - .eq(DistributionParcelListEntity::getStockArticleId, task.getNewStockArticleId())); - - if (packageList.stream().anyMatch(distributionParcelListEntity -> OrderPackageReservationStatusConstant.yiyueyue.getValue().equals(distributionParcelListEntity.getOrderPackageReservationStatus()))) { - return R.fail("新的订单包件已预约,无法删除"); + long count = count( + Wrappers.lambdaQuery() + .eq(DistributionSplitOrderTaskEntity::getSplitOrderAllTaskId, task.getSplitOrderAllTaskId()) + .in(DistributionSplitOrderTaskEntity::getState, Arrays.asList(OrderSplitStateConstant.InProgress.getValue(), OrderSplitStateConstant.finish.getValue())) + ); + if (count == 1) { + return R.fail("总任务下只有一条任务,无法撤销"); } try { - - distributionParcelListService.update(Wrappers.lambdaUpdate() - .eq(DistributionParcelListEntity::getStockArticleId, task.getNewStockArticleId()) - .set(DistributionParcelListEntity::getStockArticleId, task.getStockArticleId()) - .set(DistributionParcelListEntity::getOrderCode, task.getOrderCode()) - ); - - if (newStockArticle != null) { - newStockArticle.setTotalNumber(0); - newStockArticle.setHandQuantity(0); - distributionStockArticleService.updateById(newStockArticle); - oldStockArticle.setTotalNumber(oldStockArticle.getTotalNumber() + newStockArticle.getTotalNumber()); - oldStockArticle.setHandQuantity(oldStockArticle.getHandQuantity() + newStockArticle.getHandQuantity()); - } - - distributionStockArticleService.updateById(oldStockArticle); - - distributionSplitOrderDetailService.update(Wrappers.lambdaUpdate() - .eq(DistributionSplitOrderDetailEntity::getSplitOrderTaskId, taskId) - .set(DistributionSplitOrderDetailEntity::getState, OrderPackageSplitStateConstant.cancel.getValue()) - .set(DistributionSplitOrderDetailEntity::getCancelUser, AuthUtil.getUser().getUserId()) - .set(DistributionSplitOrderDetailEntity::getCancelUsername, AuthUtil.getUser().getUserName()) - ); - distributionSplitOrderLogService.record(task, "取消拆单任务", AuthUtil.getUser().getUserName()); - - allTask.setNumber(allTask.getNumber() - 1); - allTask.setOrderPackageNumber(allTask.getOrderPackageNumber() - task.getTaskNumber()); - distributionSplitOrderAllTaskService.updateById(allTask); - - task.setIsDeleted(1); - task.setNumber(0); - updateById(task); - + cancelTask(task); return R.success("success"); } catch (Exception e) { log.error("取消拆单任务系统错误", e); @@ -604,6 +599,9 @@ public class DistributionSplitOrderTaskServiceImpl extends BaseServiceImpllambdaQuery() .in(DistributionSplitOrderDetailEntity::getOrderPackageCode, packageCodes) @@ -618,11 +616,6 @@ public class DistributionSplitOrderTaskServiceImpl extends BaseServiceImpllambdaUpdate() @@ -699,6 +692,10 @@ public class DistributionSplitOrderTaskServiceImpl extends BaseServiceImpl cancelTask(Long taskId) { DistributionSplitOrderTaskEntity task = getById(taskId); - if (!task.getState().equals(OrderSplitStateConstant.InProgress.getValue())) { + if (!task.getState().equals(OrderSplitStateConstant.finish.getValue())) { return R.fail("任务未已完成,无法操作"); } DistributionSplitOrderAllTaskEntity allTask = distributionSplitOrderAllTaskService.getById(task.getSplitOrderAllTaskId()); @@ -735,28 +733,44 @@ public class DistributionSplitOrderTaskServiceImpl extends BaseServiceImpllambdaUpdate() + .eq(DistributionSplitOrderDetailEntity::getSplitOrderTaskId, task.getId()) + .set(DistributionSplitOrderDetailEntity::getState, OrderPackageSplitStateConstant.cancel.getValue()) + .set(DistributionSplitOrderDetailEntity::getCancelUser, AuthUtil.getUser().getUserId()) + .set(DistributionSplitOrderDetailEntity::getCancelUsername, AuthUtil.getUser().getUserName()) + ); + + distributionSplitOrderLogService.record(task, "撤消拆单任务", AuthUtil.getUser().getUserName()); + + } + + @Transactional @Override public R cancelAllTask(Long allTaskId) { DistributionSplitOrderAllTaskEntity allTask = distributionSplitOrderAllTaskService.getById(allTaskId); if (!allTask.getState().equals(OrderSplitAllTaskStateConstant.finish.getValue())) { - return R.fail("拆单总任务已完成,无法操作"); + return R.fail("拆单总任务未完成,无法操作"); } if (!list(Wrappers.lambdaQuery() @@ -766,8 +780,25 @@ public class DistributionSplitOrderTaskServiceImpl extends BaseServiceImpl list = list( + Wrappers.lambdaQuery() + .eq(DistributionSplitOrderTaskEntity::getSplitOrderAllTaskId, allTaskId) + ); + + long finishCount = list.stream().filter(task -> task.getState().equals(OrderSplitStateConstant.finish.getValue())).count(); + if (finishCount > 0) { + return R.fail("拆单任务中存在已完成拆单任务,无法操作"); + } + allTask.setState(OrderSplitAllTaskStateConstant.cancel.getValue()); distributionSplitOrderAllTaskService.updateById(allTask); + list.forEach(this::cancelTask); + + distributionStockArticleService.update( + Wrappers.lambdaUpdate() + .eq(DistributionStockArticleEntity::getId, allTask.getStockArticleId()) + .set(DistributionStockArticleEntity::getSplitStatus, OrderSplitStatusConstant.No.getValue()) + ); return R.success("success"); } @@ -780,11 +811,11 @@ public class DistributionSplitOrderTaskServiceImpl extends BaseServiceImpllambdaQuery() + boolean existsInProgress = exists(Wrappers.lambdaQuery() .eq(DistributionSplitOrderTaskEntity::getSplitOrderAllTaskId, allTaskId) .eq(DistributionSplitOrderTaskEntity::getState, OrderSplitStateConstant.InProgress.getValue()) ); - if (existsInProgress != null) { + if (existsInProgress) { return R.fail("拆单总任务中存在未完成拆单任务,无法操作"); } @@ -799,6 +830,12 @@ public class DistributionSplitOrderTaskServiceImpl extends BaseServiceImpllambdaUpdate() + .eq(DistributionStockArticleEntity::getId, allTask.getStockArticleId()) + .set(DistributionStockArticleEntity::getSplitStatus, OrderSplitStatusConstant.No.getValue()) + ); + return R.success("success"); } @@ -836,8 +873,9 @@ public class DistributionSplitOrderTaskServiceImpl extends BaseServiceImpl> allTaskList(Query query, DistributionSplitAllTaskSearchDTO distributionSplitAllTaskSearchDTO) { + public R> allTaskList(Query query, DistributionSplitAllTaskSearchDTO distributionSplitAllTaskSearchDTO) { IPage page = Condition.getPage(query); + IPage pageResult = Condition.getPage(query); LambdaQueryWrapper queryWrapper = Wrappers.lambdaQuery(); @@ -878,18 +916,49 @@ public class DistributionSplitOrderTaskServiceImpl extends BaseServiceImpl list = distributionSplitOrderAllTaskService.list(page, queryWrapper); - page.setRecords(list); + List listVo = new ArrayList<>(); + if (list != null && !list.isEmpty()) { + Map userMap = getUserIdNameMap(list.stream().map(DistributionSplitOrderAllTaskEntity::getCreateUser).collect(Collectors.toList())); + Map allTaskIdPackageNumber = getAllTaskIdPackageNumber(list.stream().map(DistributionSplitOrderAllTaskEntity::getId).collect(Collectors.toList())); + listVo = list.stream().map(d -> { + DistributionSplitOrderAllTaskVO vo = new DistributionSplitOrderAllTaskVO(); + BeanUtil.copyProperties(d, vo); + vo.setCreateUserName(userMap.get(d.getCreateUser())); + vo.setSplitPackageNumber(allTaskIdPackageNumber.get(d.getId())); + return vo; + }).collect(Collectors.toList()); + } + + pageResult.setRecords(listVo); + pageResult.setPages(page.getPages()); + pageResult.setTotal(page.getTotal()); - return R.data(page); + return R.data(pageResult); } + private Map getAllTaskIdPackageNumber(List taskIds){ + List> maps = baseMapper.selectMaps( + Wrappers.query() + .select("split_order_all_task_id", "SUM(number) as number") + .in("split_order_all_task_id", taskIds) + .in("state", OrderSplitStateConstant.InProgress.getValue(), OrderSplitStateConstant.finish.getValue()) + .groupBy("split_order_all_task_id") + ); + + return maps.stream().collect(Collectors.toMap( + m -> Long.valueOf(m.get("split_order_all_task_id").toString()), + m -> Long.valueOf(m.get("number").toString()) + )); + } + + @Override public R getTaskDetail(Long taskId) { R> PackageOrderList = getPackageCodeByTaskId(taskId); @@ -902,20 +971,80 @@ public class DistributionSplitOrderTaskServiceImpl extends BaseServiceImpllambdaQuery() + .in(DistributionParcelListEntity::getStockArticleId, stockArticleId) + .ne(DistributionParcelListEntity::getOrderPackageStatus, OrderPackageStatusConstant.yiqianshou.getValue()) + .eq(DistributionParcelListEntity::getOrderPackageReservationStatus, OrderPackageReservationStatusConstant.daiyuyue.getValue()) + .eq(DistributionParcelListEntity::getOrderPackageLoadingStatus, OrderPackageLoadingStatusConstant.weizhuancghe.getValue()) + .eq(DistributionParcelListEntity::getOrderPackageFreezeStatus, OrderPackageFreezeStatusConstant.weidongjie.getValue()) + .eq(DistributionParcelListEntity::getIsTransfer, 0) + ); + } + + public long getSplitOrderAllCount(Long stockArticleId) { + return distributionParcelListService.count( + Wrappers.lambdaQuery() + .in(DistributionParcelListEntity::getStockArticleId, stockArticleId) + ); + } @Override public R checkOrderCode(String orderCode) { + DistributionStockArticleEntity distributionStockArticle = distributionStockArticleService.getOne(Wrappers.lambdaQuery() + .eq(DistributionStockArticleEntity::getOrderCode, orderCode)); + long splitOrderAllCount = getSplitOrderAllCount(distributionStockArticle.getId()); + long splitOrderAllowCount = getSplitOrderAllowCount(distributionStockArticle.getId()); + if (splitOrderAllowCount == 0 || splitOrderAllCount == 1) { + return R.success("该订单无法拆单"); + } + return R.success(""); + } - DistributionSplitOrderAllTaskEntity exists = distributionSplitOrderAllTaskService.getOne( - Wrappers.lambdaQuery() - .eq(DistributionSplitOrderAllTaskEntity::getOrderCode, orderCode) + @Override + public R checkOrderCode(Long stockArticleId){ + DistributionStockArticleEntity distributionStockArticle = distributionStockArticleService.getById(stockArticleId); + if (distributionStockArticle == null) { + return R.fail("原订单信息错误"); + } + if (distributionStockArticle.getOrderStatus().equals(OrderStatusConstant.chuku.getValue()) + || distributionStockArticle.getOrderStatus().equals(OrderStatusConstant.qianshou.getValue()) + || Objects.equals(distributionStockArticle.getReservationStatus(), OrderReservationStatusConstant.yiyueyue.getValue())) { + return R.fail("订单"+ distributionStockArticle.getOrderCode() +"不允许拆单"); + } + + long packageAllowCount = getSplitOrderAllowCount(stockArticleId); + long packageAllCount = getSplitOrderAllCount(stockArticleId); + + if (packageAllowCount == 0 || packageAllCount == 1) { + return R.fail("订单"+ distributionStockArticle.getOrderCode() +"包件数量不足,不允许拆单"); + } + + boolean exists = exists( + Wrappers.lambdaQuery() + .eq(DistributionSplitOrderTaskEntity::getStockArticleId, stockArticleId) + .eq(DistributionSplitOrderTaskEntity::getState, OrderSplitStateConstant.InProgress.getValue()) + ); + if (exists) { + return R.fail("订单"+ distributionStockArticle.getOrderCode() +"正在拆单中,不允许重复拆单"); + } + + boolean hasSplit = exists( + Wrappers.lambdaQuery() + .eq(DistributionSplitOrderTaskEntity::getNewStockArticleId, stockArticleId) ); - return R.success(exists == null ? "" : exists.getNo()); + if (hasSplit){ + return R.fail("订单"+ distributionStockArticle.getOrderCode() +"已是拆单订单,不允许再次拆单"); + } + + return R.success(""); } @Override diff --git a/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/service/impl/DistributionStockArticleServiceImpl.java b/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/service/impl/DistributionStockArticleServiceImpl.java index 10a3bc900..7bb62fb18 100644 --- a/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/service/impl/DistributionStockArticleServiceImpl.java +++ b/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/service/impl/DistributionStockArticleServiceImpl.java @@ -1189,10 +1189,16 @@ public class DistributionStockArticleServiceImpl extends BaseServiceImpl myWarehouseList = warehouseClient.getMyWatchWarehouse(); - List collect = myWarehouseList.stream() - .map(BasicdataWarehouseEntity::getId) - .collect(Collectors.toList()); +// List myWarehouseList = warehouseClient.getMyWatchWarehouse(); +// List collect = myWarehouseList.stream() +// .map(BasicdataWarehouseEntity::getId) +// .collect(Collectors.toList()); + List collect = new ArrayList<>(); + + BasicdataWarehouseEntity myCurrentWarehouse = warehouseClient.getMyCurrentWarehouse(); + Long warehouseId = myCurrentWarehouse.getId(); + collect.add(warehouseId); + //查询包条(库存品)所在订单 queryOrderVO queryOrderVO; if (i == 1) { @@ -1207,12 +1213,21 @@ public class DistributionStockArticleServiceImpl extends BaseServiceImpl distributionParcelListEntitys = distributionParcelListMapper.selectListByOderId(id, collect); + //查询订单下的所有库存品 List distributionStockListVOS = distributionParcelListMapper.selectStockListByOderId(id, collect); + //查询订单下所有未入库的包件 + List advanceDetailEntities = trunklineAdvanceDetailClient.findListByStockArticleId(id,warehouseId); + List noIncomingPackage = new ArrayList<>(); + advanceDetailEntities.forEach(advanceDetailEntity -> { + noIncomingPackage.add(JSONObject.parseObject(JSONObject.toJSONString(advanceDetailEntity))); + }); + queryOrderVO.setWrapNum(distributionParcelListEntitys.size()); queryOrderVO.setInventoryNum(distributionStockListVOS.size()); queryOrderVO.setList(distributionParcelListEntitys); queryOrderVO.setStockList(distributionStockListVOS); + queryOrderVO.setNoIncomingList(noIncomingPackage); return queryOrderVO; } diff --git a/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/vo/DistributionSplitOrderAllTaskVO.java b/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/vo/DistributionSplitOrderAllTaskVO.java new file mode 100644 index 000000000..b0400f11b --- /dev/null +++ b/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/vo/DistributionSplitOrderAllTaskVO.java @@ -0,0 +1,16 @@ +package com.logpm.distribution.vo; + +import com.logpm.distribution.entity.DistributionSplitOrderAllTaskEntity; +import lombok.Data; +import lombok.EqualsAndHashCode; + +@EqualsAndHashCode(callSuper = true) +@Data +public class DistributionSplitOrderAllTaskVO extends DistributionSplitOrderAllTaskEntity { + + private String createUserName; + /** + * 已拆单包件数量 + */ + private Long splitPackageNumber; +} diff --git a/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/vo/DistributionSplitOrderTaskVO.java b/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/vo/DistributionSplitOrderTaskVO.java new file mode 100644 index 000000000..35eb05339 --- /dev/null +++ b/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/vo/DistributionSplitOrderTaskVO.java @@ -0,0 +1,11 @@ +package com.logpm.distribution.vo; + +import com.logpm.distribution.entity.DistributionSplitOrderTaskEntity; +import lombok.Data; +import lombok.EqualsAndHashCode; + +@EqualsAndHashCode(callSuper = true) +@Data +public class DistributionSplitOrderTaskVO extends DistributionSplitOrderTaskEntity { + private String createUserName; +} diff --git a/blade-service/logpm-factory-data/logpm-factory-data-jinpai/src/main/java/com/logpm/factorydata/jinpai/job/AdvanceJob.java b/blade-service/logpm-factory-data/logpm-factory-data-jinpai/src/main/java/com/logpm/factorydata/jinpai/job/AdvanceJob.java index db0de1e07..3b35b6c88 100644 --- a/blade-service/logpm-factory-data/logpm-factory-data-jinpai/src/main/java/com/logpm/factorydata/jinpai/job/AdvanceJob.java +++ b/blade-service/logpm-factory-data/logpm-factory-data-jinpai/src/main/java/com/logpm/factorydata/jinpai/job/AdvanceJob.java @@ -1,9 +1,10 @@ package com.logpm.factorydata.jinpai.job; import cn.hutool.core.collection.CollUtil; +import cn.hutool.core.convert.Convert; +import cn.hutool.core.util.NumberUtil; +import cn.hutool.core.util.StrUtil; import com.baomidou.mybatisplus.core.toolkit.Wrappers; -import com.logpm.factorydata.base.feign.IFactoryDataBaseClient; -import com.logpm.factorydata.feign.IFactoryDataClient; import com.logpm.factorydata.jinpai.entity.DeliveryNoteEntity; import com.logpm.factorydata.jinpai.entity.OrderInfoEntity; import com.logpm.factorydata.jinpai.entity.PackageInfoEntity; @@ -14,9 +15,9 @@ 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.common.annotations.LogpmAsync; import org.springframework.stereotype.Component; +import java.math.BigDecimal; import java.util.ArrayList; import java.util.HashMap; import java.util.HashSet; @@ -62,21 +63,78 @@ public class AdvanceJob { // 将数据封装到packageInfoEntityMap中 其中omsExtOrderNo为key packageInfoEntityMap.computeIfAbsent(entity.getOmsExtOrderNo(), k -> new ArrayList<>()).add(entity); } - // 根据订单数据查询出所有订单明细和包件信息 - List deliveryNoteEntities = deliveryNoteService.list(Wrappers.lambdaQuery().in(DeliveryNoteEntity::getOrderId, deliveryNoteSet)); - if (CollUtil.isNotEmpty(deliveryNoteEntities)) { - for (DeliveryNoteEntity entity : deliveryNoteEntities) { - deliveryNoteEntityMap.put(entity.getOrderId(), entity); - } + } + List orders = orderInfoService.list(Wrappers.lambdaQuery().eq(OrderInfoEntity::getReserve1, "0")); + if (CollUtil.isNotEmpty(orders)) { + for (OrderInfoEntity order : orders) { + orderInfoSet.add(order.getOmsExtOrderNo()); + } + } + List orderInfoEntities = orderInfoService.list(Wrappers.lambdaQuery().in(OrderInfoEntity::getOmsExtOrderNo, orderInfoSet)); + if (CollUtil.isNotEmpty(orderInfoEntities)) { + for (OrderInfoEntity entity : orderInfoEntities) { + String omsExtOrderNo = entity.getOmsExtOrderNo(); + orderInfoEntityMap.put(omsExtOrderNo, entity); + deliveryNoteSet.add(entity.getOrderId()); } - List orderInfoEntities = orderInfoService.list(Wrappers.lambdaQuery().in(OrderInfoEntity::getOmsExtOrderNo, orderInfoSet)); - if (CollUtil.isNotEmpty(orderInfoEntities)) { - for (OrderInfoEntity entity : orderInfoEntities) { - orderInfoEntityMap.put(entity.getOmsExtOrderNo(), entity); + } + // 根据订单数据查询出所有订单明细和包件信息 + List deliveryNoteEntities = deliveryNoteService.list(Wrappers.lambdaQuery().in(DeliveryNoteEntity::getOrderId, deliveryNoteSet)); + if (CollUtil.isNotEmpty(deliveryNoteEntities)) { + for (DeliveryNoteEntity entity : deliveryNoteEntities) { + deliveryNoteEntityMap.put(entity.getOrderId(), entity); + } + } + // 处理无包条的情况 + if (CollUtil.isNotEmpty(orderInfoEntities)) { + for (OrderInfoEntity entity : orderInfoEntities) { + String omsExtOrderNo = entity.getOmsExtOrderNo(); + String goodsNumber = entity.getGoodsNumber(); + if (!packageInfoEntityMap.containsKey(omsExtOrderNo)) { + // 订单没有包件,生成包件 + if (StrUtil.isNotEmpty(goodsNumber)) { + Integer anInt = Convert.toInt(goodsNumber); + if (anInt > 0) { + // 创建包件 + List packageInfoEntities = new ArrayList<>(); + for (int i = 0; i < anInt; i++) { + PackageInfoEntity packageInfoEntity = new PackageInfoEntity(); + packageInfoEntity.setOrderId(entity.getOrderId()); + packageInfoEntity.setOmsExtOrderNo(omsExtOrderNo); + packageInfoEntity.setGoodsNum(entity.getGoodsNumber()); + packageInfoEntity.setBoxType1(entity.getGoodsType()); + packageInfoEntity.setBoxType2(entity.getGoodsType()); + packageInfoEntity.setBoxType3(entity.getGoodsType()); + packageInfoEntity.setExtBoxCode(deliveryNoteEntityMap.get(entity.getOrderId()).getOmsExtYsId() + omsExtOrderNo + "-" + i); + String goodsVolume = entity.getGoodsVolume(); + if (StrUtil.isNotEmpty(goodsVolume)) { + BigDecimal div = NumberUtil.div(Convert.toBigDecimal(goodsVolume), Convert.toBigDecimal(anInt), 4); + packageInfoEntity.setGoodsVolume(Convert.toStr(div)); + } + packageInfoEntities.add(packageInfoEntity); + } + packageInfoEntityMap.put(omsExtOrderNo, packageInfoEntities); + } + } } } - // 组装数据,然后生成暂存单 - deliveryNoteService.buildAdvancePull(packageInfoEntityMap, deliveryNoteEntityMap, orderInfoEntityMap); + } + // 组装数据,然后生成暂存单 + deliveryNoteService.buildAdvancePull(packageInfoEntityMap, deliveryNoteEntityMap, orderInfoEntityMap); + if (CollUtil.isNotEmpty(orderInfoEntities)) { + // 修改包件的发送状态 TODO 后面修改为暂存单消费完成之后回调更新状态 + List updatePackageList = new ArrayList<>(); + for (OrderInfoEntity entity : orderInfoEntities) { + OrderInfoEntity updateEntity = new OrderInfoEntity(); + updateEntity.setReserve1("1"); + updateEntity.setId(entity.getId()); + updatePackageList.add(updateEntity); + } + if (CollUtil.isNotEmpty(updatePackageList)) { + orderInfoService.updateBatchById(updatePackageList); + } + } + if (CollUtil.isNotEmpty(list)) { // 修改包件的发送状态 TODO 后面修改为暂存单消费完成之后回调更新状态 List updatePackageList = new ArrayList<>(); for (PackageInfoEntity entity : list) { diff --git a/blade-service/logpm-factory-data/logpm-factory-data-jinpai/src/main/java/com/logpm/factorydata/jinpai/service/impl/MqWorkerServiceImpl.java b/blade-service/logpm-factory-data/logpm-factory-data-jinpai/src/main/java/com/logpm/factorydata/jinpai/service/impl/MqWorkerServiceImpl.java index 135a76c19..af2edbd34 100644 --- a/blade-service/logpm-factory-data/logpm-factory-data-jinpai/src/main/java/com/logpm/factorydata/jinpai/service/impl/MqWorkerServiceImpl.java +++ b/blade-service/logpm-factory-data/logpm-factory-data-jinpai/src/main/java/com/logpm/factorydata/jinpai/service/impl/MqWorkerServiceImpl.java @@ -307,6 +307,8 @@ public class MqWorkerServiceImpl implements MqWorkerService { OrderInfoEntity deliveryNoteEntity = new OrderInfoEntity(); BeanUtil.copyProperties(vo, deliveryNoteEntity); deliveryNoteEntity.setLogId(ObjectUtil.isNotEmpty(logEntity.getId()) ? logEntity.getId().toString() : null); + // 是否推送 + deliveryNoteEntity.setReserve1("0"); entities.add(deliveryNoteEntity); } if (CollUtil.isNotEmpty(entities)) { 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"] 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..ac71ee9ab --- /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,192 @@ +package com.logpm.factorydata.paterson.interceptor; + +import cn.hutool.core.codec.Base64; +import cn.hutool.core.date.DateTime; +import cn.hutool.core.date.DateUnit; +import cn.hutool.core.date.DateUtil; +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.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 = DateUtil.current(); + DateTime currentDate = DateUtil.date(); + // 验证时间 + if (secondTimestamp - authTime > authTime1) { + log.info("##########preHandle: 时间戳过期"); + returnJson(response, JSONObject.toJSONString(R.fail("认证不通过,时间戳过期"))); + return false; + } + // 将 authTime 转换为时间并与当前时间比较 + DateTime authDateTime = DateUtil.date(authTime); // 将时间戳转换为 DateTime + // 将 authTime 转换为时间并与当前时间比较 + long timeDifferenceInSeconds = DateUtil.between(authDateTime, currentDate, DateUnit.MS); + if (timeDifferenceInSeconds > 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/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..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 @@ -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"; @@ -178,6 +194,7 @@ public class SpiderDataJob { packageInfoEntity.setUpdateTime(new Date()); packageInfoEntity.setIsDeleted(0); packageInfoEntity.setStatus(1); + packageInfoEntity.setDealerName(spiderInforEntity.getBindBussiness()); // 判断这个包条是否存在鱼数据库 如果不存在 则执行 @@ -195,6 +212,7 @@ public class SpiderDataJob { vo.setOrderInfo(orderInfo); vo.setPackageInfo(packageInfoVOs); } + log.debug(">>>>> vo {}",vo); asyncChangeDbExecutor.execute(new ChdbTask(spiderInforEntity.getBindTenantCode(), vo,deliveryNoteService)); } @@ -308,14 +326,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 +368,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 +420,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) { 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 diff --git a/blade-service/logpm-factory/src/main/java/com/logpm/factory/oupai/mapper/FactoryPackageMapper.xml b/blade-service/logpm-factory/src/main/java/com/logpm/factory/oupai/mapper/FactoryPackageMapper.xml index 4f24799f4..d98e09a84 100644 --- a/blade-service/logpm-factory/src/main/java/com/logpm/factory/oupai/mapper/FactoryPackageMapper.xml +++ b/blade-service/logpm-factory/src/main/java/com/logpm/factory/oupai/mapper/FactoryPackageMapper.xml @@ -22,7 +22,8 @@ ofp.first_class_name, ofp.second_class_name, ofp.third_class_name, - ofp.push_status + ofp.push_status, + ofo.business_model FROM op_factory_package ofp LEFT JOIN op_factory_order ofo ON ofo.id = ofp.order_id diff --git a/blade-service/logpm-report/src/main/java/com/logpm/report/config/MybatisPlusConfig.java b/blade-service/logpm-report/src/main/java/com/logpm/report/config/MybatisPlusConfig.java index 53c8a37e5..10998183b 100644 --- a/blade-service/logpm-report/src/main/java/com/logpm/report/config/MybatisPlusConfig.java +++ b/blade-service/logpm-report/src/main/java/com/logpm/report/config/MybatisPlusConfig.java @@ -63,7 +63,7 @@ public class MybatisPlusConfig implements WebMvcConfigurer { AnnotationAwareOrderComparator.sort(queryInterceptorArray); paginationInterceptor.setQueryInterceptors(queryInterceptorArray); } - paginationInterceptor.setMaxLimit(mybatisPlusProperties.getPageLimit()); + paginationInterceptor.setMaxLimit(-1L); paginationInterceptor.setOverflow(mybatisPlusProperties.getOverflow()); paginationInterceptor.setOptimizeJoin(mybatisPlusProperties.getOptimizeJoin()); paginationInterceptor.setDbType(DbType.MYSQL); diff --git a/blade-service/logpm-report/src/main/java/com/logpm/report/mapper/ReportIncomingMapper.xml b/blade-service/logpm-report/src/main/java/com/logpm/report/mapper/ReportIncomingMapper.xml index 5aea8e6a4..927d2b628 100644 --- a/blade-service/logpm-report/src/main/java/com/logpm/report/mapper/ReportIncomingMapper.xml +++ b/blade-service/logpm-report/src/main/java/com/logpm/report/mapper/ReportIncomingMapper.xml @@ -958,6 +958,12 @@ and lww.settlement_status = #{param.settlementStatus} + + and lww.document_making_time >= #{param.startTime} + + + and lww.document_making_time <= #{param.endTime} + GROUP BY lww.id order by lww.create_time desc @@ -1251,6 +1257,12 @@ and lww.settlement_status = #{param.settlementStatus} + + and lww.document_making_time >= #{param.startTime} + + + and lww.document_making_time <= #{param.endTime} + GROUP BY lww.id order by lww.create_time desc diff --git a/blade-service/logpm-report/src/main/java/com/logpm/report/mapper/ReportTimeMapper.xml b/blade-service/logpm-report/src/main/java/com/logpm/report/mapper/ReportTimeMapper.xml index 1ca670eb3..976703731 100644 --- a/blade-service/logpm-report/src/main/java/com/logpm/report/mapper/ReportTimeMapper.xml +++ b/blade-service/logpm-report/src/main/java/com/logpm/report/mapper/ReportTimeMapper.xml @@ -238,14 +238,20 @@ count(lta.waybill_id) openNum, sum( IF(ltcls.id IS NOT NULL AND ltcll.start_date is not null,1,0) ) startNum, count(lta.id)-sum( IF(ltcls.id IS NOT NULL AND ltcll.start_date is not null,1,0) ) noOutNum, - sum(if( ltcls.id is null and now() > DATE_ADD( lta.create_time, INTERVAL #{param.hoursTime} HOUR ),1,0)) noOutOverNum, + sum(if( (ltcls.id IS NULL OR ltcll.start_date IS NULL) and now() > DATE_ADD( lta.create_time, INTERVAL #{param.hoursTime} HOUR ),1,0)) noOutOverNum, sum(if(ltcll.start_date <= DATE_ADD( lta.create_time, INTERVAL #{param.hoursTime} HOUR ),1,0)) onTimeNum, IFNULL(round(sum(if(ltcll.start_date <= DATE_ADD( lta.create_time, INTERVAL #{param.hoursTime} HOUR ),1,0))/count(lta.id)*100,2),'0.00') onTimeRate, round(sum(TIMESTAMPDIFF(SECOND, lta.create_time, ltcll.start_date))/count(ltcls.id)/3600,1) avgTime from logpm_trunkline_advance_detail lta left join logpm_warehouse_waybill lww on lww.id = lta.waybill_id left join logpm_warehouse_warehouse waw on waw.id = lta.warehouse_id - left join logpm_trunkline_cars_load_scan ltcls on ltcls.scan_code = lta.order_package_code and ltcls.warehouse_id = lta.warehouse_id and ltcls.type = 1 and ltcls.scan_status != 4 + left join ( + SELECT + t1.* + FROM logpm_trunkline_cars_load_scan t1 + LEFT JOIN logpm_trunkline_cars_load_scan t2 ON t1.scan_code = t2.scan_code AND t1.create_time < t2.create_time + WHERE t2.scan_code IS NULL + ) ltcls on ltcls.scan_code = lta.order_package_code and ltcls.warehouse_id = lta.warehouse_id and ltcls.type = 1 and ltcls.scan_status != 4 left join logpm_trunkline_cars_load_line ltcll on ltcll.load_id = ltcls.load_id and ltcll.node_id = ltcls.warehouse_id where lta.create_time > '2024-10-22 00:00:00' and lww.document_making_time > '2024-10-22 00:00:00' @@ -299,14 +305,20 @@ count(lta.waybill_id) openNum, sum( IF(ltcls.id IS NOT NULL AND ltcll.start_date is not null,1,0) ) startNum, count(lta.id)-sum( IF(ltcls.id IS NOT NULL AND ltcll.start_date is not null,1,0) ) noOutNum, - sum(if( ltcls.id is null and now() > DATE_ADD( lta.create_time, INTERVAL #{param.hoursTime} HOUR ),1,0)) noOutOverNum, + sum(if( (ltcls.id IS NULL OR ltcll.start_date IS NULL) and now() > DATE_ADD( lta.create_time, INTERVAL #{param.hoursTime} HOUR ),1,0)) noOutOverNum, sum(if(ltcll.start_date <= DATE_ADD( lta.create_time, INTERVAL #{param.hoursTime} HOUR ),1,0)) onTimeNum, - IFNULL(concat(round(sum(if(ltcll.start_date <= DATE_ADD( lta.create_time, INTERVAL #{param.hoursTime} HOUR ),1,0))/count(ltcls.id)*100,2),'%'),'0.00%') onTimeRate, + IFNULL(concat(round(sum(if(ltcll.start_date <= DATE_ADD( lta.create_time, INTERVAL #{param.hoursTime} HOUR ),1,0))/count(lta.id)*100,2),'%'),'0.00%') onTimeRate, round(sum(TIMESTAMPDIFF(SECOND, lta.create_time, ltcll.start_date))/count(ltcls.id)/3600,1) avgTime from logpm_trunkline_advance_detail lta left join logpm_warehouse_waybill lww on lww.id = lta.waybill_id left join logpm_warehouse_warehouse waw on waw.id = lta.warehouse_id - left join logpm_trunkline_cars_load_scan ltcls on ltcls.scan_code = lta.order_package_code and ltcls.warehouse_id = lta.warehouse_id and ltcls.type = 1 and ltcls.scan_status != 4 + left join ( + SELECT + t1.* + FROM logpm_trunkline_cars_load_scan t1 + LEFT JOIN logpm_trunkline_cars_load_scan t2 ON t1.scan_code = t2.scan_code AND t1.create_time < t2.create_time + WHERE t2.scan_code IS NULL + ) ltcls on ltcls.scan_code = lta.order_package_code and ltcls.warehouse_id = lta.warehouse_id and ltcls.type = 1 and ltcls.scan_status != 4 left join logpm_trunkline_cars_load_line ltcll on ltcll.load_id = ltcls.load_id and ltcll.node_id = ltcls.warehouse_id where lta.create_time > '2024-10-22 00:00:00' and lww.document_making_time > '2024-10-22 00:00:00' @@ -2826,7 +2838,7 @@ and ltcls.id is null - and now() <= DATE_ADD( ltad.create_time, INTERVAL #{param.hoursTime} HOUR ) + and now() > DATE_ADD( ltad.create_time, INTERVAL #{param.hoursTime} HOUR ) group by ltad.id @@ -2928,7 +2940,7 @@ and ltcls.id is null - and now() <= DATE_ADD( ltad.create_time, INTERVAL #{param.hoursTime} HOUR ) + and now() > DATE_ADD( ltad.create_time, INTERVAL #{param.hoursTime} HOUR ) group by ltad.id diff --git a/blade-service/logpm-report/src/main/java/com/logpm/report/mapper/TrunklinePickupMapper.xml b/blade-service/logpm-report/src/main/java/com/logpm/report/mapper/TrunklinePickupMapper.xml index 7f3d9352d..52b9a0fbc 100644 --- a/blade-service/logpm-report/src/main/java/com/logpm/report/mapper/TrunklinePickupMapper.xml +++ b/blade-service/logpm-report/src/main/java/com/logpm/report/mapper/TrunklinePickupMapper.xml @@ -248,7 +248,7 @@ + select ltad.* + from logpm_trunkline_advance_detail ltad + left join logpm_distribution_parcel_list ldpl on ldpl.order_package_code = ltad.order_package_code + where ldpl.stock_article_id = #{stockArticleId} + and ldpl.warehouse_id = #{warehouseId} + and ltad.is_deleted = 0 + and ldpl.is_deleted = 0 + and ldpl.id is null + + diff --git a/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/mapper/TrunklineAdvanceMapper.xml b/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/mapper/TrunklineAdvanceMapper.xml index cde4b100b..d9e1d4e72 100644 --- a/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/mapper/TrunklineAdvanceMapper.xml +++ b/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/mapper/TrunklineAdvanceMapper.xml @@ -93,7 +93,6 @@ diff --git a/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/ITrunklineAdvanceDetailService.java b/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/ITrunklineAdvanceDetailService.java index 9be8e14e1..500c555fc 100644 --- a/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/ITrunklineAdvanceDetailService.java +++ b/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/ITrunklineAdvanceDetailService.java @@ -129,4 +129,6 @@ public interface ITrunklineAdvanceDetailService extends BaseService map); + + List findListByStockArticleId(Long stockArticleId, Long warehouseId); } diff --git a/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/ITrunklineCarsLoadScanService.java b/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/ITrunklineCarsLoadScanService.java index 9e3f587ec..0e820d8fd 100644 --- a/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/ITrunklineCarsLoadScanService.java +++ b/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/ITrunklineCarsLoadScanService.java @@ -213,5 +213,5 @@ public interface ITrunklineCarsLoadScanService extends BaseService addList = new ArrayList<>(); List noUnloadList = trunklineCarsLoadScanService.findUnloadCheckAbnormalNoUnloadList(loadId, warehouseId); + //把noUnloadList中所有元素的scanCode放入一个List + List scanCodeList = noUnloadList.stream().map(TrunklineCarsLoadScanEntity::getScanCode).collect(Collectors.toList()); + FindParamterDTO findParamterDTO = new FindParamterDTO(); + findParamterDTO.setOrderPackageCodeList(scanCodeList); + findParamterDTO.setWarehouseId(warehouseId); + List parcelListEntityList = distributionParcelListClient.findListByOrderPackageCodeList(findParamterDTO); + //把parcelListEntityList转化成以orderPackageCode作为key的Map + Map parcelMap = parcelListEntityList.stream() + .collect(Collectors.toMap(DistributionParcelListEntity::getOrderPackageCode, Function.identity())); + for (TrunklineCarsLoadScanEntity trunklineCarsLoadScanEntity : noUnloadList) { String loadCode = trunklineCarsLoadScanEntity.getLoadCode(); String waybillNo = trunklineCarsLoadScanEntity.getWaybillNo(); @@ -579,6 +590,14 @@ public class CarsLoadAsyncServiceImpl implements ICarsLoadAsyncService { abnormalRecordEntity.setRemark("无卸车记录"); abnormalRecordEntity.setIsZero(0); abnormalRecordEntity.setNum(1); + DistributionParcelListEntity distributionParcel = parcelMap.get(scanCode); + if(!Objects.isNull(distributionParcel)){ + abnormalRecordEntity.setAbnormalStatus(1); + abnormalRecordEntity.setDealTime(new Date()); + abnormalRecordEntity.setDealUserId(userId); + abnormalRecordEntity.setDealUserName(nickName); + abnormalRecordEntity.setRemark("无卸车记录,已在其他车次入库,系统判定自动完结"); + } addList.add(abnormalRecordEntity); // abnormalRecordClient.addAbnormalRecord(abnormalRecordEntity); } 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 181a5f8c0..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 @@ -320,6 +320,7 @@ public class OpenOrderServiceImpl implements IOpenOrderService { String dealerName = null; String dealerCode = null; String brand = null; + Set orderCodeSet = new HashSet<>(); for (TrunklineAdvanceEntity advanceEntity : list) { if (StringUtil.isBlank(dealerName)) { dealerName = advanceEntity.getDealerName(); @@ -328,11 +329,13 @@ public class OpenOrderServiceImpl implements IOpenOrderService { if (StringUtil.isBlank(brand)) { brand = advanceEntity.getBrand(); } + orderCodeSet.add(advanceEntity.getOrderCode()); } OpenOrderVO openOrderVO = new OpenOrderVO(); //查询品牌 客户车次号 订单自编码 OpenOrderVO infoByIds = advanceService.selectInfoByIds(advanceIds); BeanUtil.copy(infoByIds, openOrderVO); + openOrderVO.setOrderCode(String.join(",", orderCodeSet)); openOrderVO.setAdvanceIds(advanceIds); BasicdataBrandEntity basicdataBrandEntity = basicdataBrandClient.findEntityByName(brand); if (!Objects.isNull(basicdataBrandEntity)) { @@ -1818,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相同的元素去重 @@ -2074,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)) { @@ -4051,6 +4081,7 @@ public class OpenOrderServiceImpl implements IOpenOrderService { String dealerName = null; String brand = null; Integer totalNum = 0; + Set orderCodeSet = new HashSet<>(); for (TrunklineAdvanceEntity advanceEntity : list) { if (StringUtil.isBlank(dealerName)) { dealerName = advanceEntity.getDealerName(); @@ -4060,11 +4091,15 @@ public class OpenOrderServiceImpl implements IOpenOrderService { } totalNum = totalNum + advanceEntity.getTotalNum(); + + orderCodeSet.add(advanceEntity.getOrderCode()); + } OpenOrderVO openOrderVO = new OpenOrderVO(); //查询品牌 客户车次号 订单自编码 OpenOrderVO infoByIds = advanceService.selectInfoByIds(advanceIds); BeanUtil.copy(infoByIds, openOrderVO); + openOrderVO.setOrderCode(String.join(",", orderCodeSet)); openOrderVO.setAdvanceIds(advanceIds); //发站仓-----目前登录人的仓库 openOrderVO.setDepartureWarehouseName(basicdataWarehouseEntity.getName()); @@ -6193,6 +6228,15 @@ public class OpenOrderServiceImpl implements IOpenOrderService { if (Objects.isNull(orderId)) { log.warn("#################createStockArticle: 保存订单信息失败 orderCode={}", distributionStockArticleEntity.getOrderCode()); throw new CustomerException(405, "保存订单信息失败"); + }else{ + if(orderId.equals(0L)){ + log.warn("################createStockArticle: 订单信息保存失败 orderCode={} warehouseId={}",distributionStockArticleEntity.getOrderCode(),distributionStockArticleEntity.getWarehouseId()); + throw new CustomerException(405,"订单信息保存失败"); + } + if(orderId.equals(1L)){ + log.warn("################dealAbnocreateStockArticlermal: 订单信息正在更新 orderCode={} warehouseId={}",distributionStockArticleEntity.getOrderCode(),distributionStockArticleEntity.getWarehouseId()); + throw new CustomerException(405,"订单信息正在更新,请稍后重试"); + } } List wayBillDetailList = warehouseWaybillDetailClient.findByWaybillId(warehouseWaybill.getId()); diff --git a/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/impl/TrunklineAdvanceDetailServiceImpl.java b/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/impl/TrunklineAdvanceDetailServiceImpl.java index 9b807483e..32b9fc63f 100644 --- a/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/impl/TrunklineAdvanceDetailServiceImpl.java +++ b/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/impl/TrunklineAdvanceDetailServiceImpl.java @@ -974,4 +974,9 @@ public class TrunklineAdvanceDetailServiceImpl extends BaseServiceImpl findListByStockArticleId(Long stockArticleId, Long warehouseId) { + return baseMapper.findListByStockArticleId(stockArticleId,warehouseId); + } } 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 a629c136d..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, "仓库信息不存在"); @@ -991,7 +1031,11 @@ public class TrunklineAdvanceServiceImpl extends BaseServiceImpl parcelListEntityList = distributionParcelListClient.findEntityVOListByOrderCode(orderCode, fromWarehouseId); @@ -1516,8 +1527,6 @@ public class TrunklineCarsLoadServiceImpl extends BaseServiceImpl qualityList = carsLoadLinePhotoService.findListByLoadIdAndWarehouseId(loadId, warehouseId, 30, null); //把qualityList通过position=2进行过滤生成新的list List qualityListHou = qualityList.stream().filter(item -> item.getPosition().equals(2)).collect(Collectors.toList()); if(qualityListHou.size() == 0){ - updateEntity.setIsUnloadPhoto(0); - trunklineCarsLoadLineService.updateById(updateEntity); + carsLoadLine.setIsUnloadPhoto(0); + trunklineCarsLoadLineService.updateById(carsLoadLine); return R.success("上传成功"); } List qualityListZuo = qualityList.stream().filter(item -> item.getPosition().equals(3)).collect(Collectors.toList()); if(qualityListZuo.size() == 0){ - updateEntity.setIsUnloadPhoto(0); - trunklineCarsLoadLineService.updateById(updateEntity); + carsLoadLine.setIsUnloadPhoto(0); + trunklineCarsLoadLineService.updateById(carsLoadLine); return R.success("上传成功"); } List qualityListYou = qualityList.stream().filter(item -> item.getPosition().equals(4)).collect(Collectors.toList()); if(qualityListYou.size() == 0){ - updateEntity.setIsUnloadPhoto(0); - trunklineCarsLoadLineService.updateById(updateEntity); + carsLoadLine.setIsUnloadPhoto(0); + trunklineCarsLoadLineService.updateById(carsLoadLine); return R.success("上传成功"); } List protectionList = carsLoadLinePhotoService.findListByLoadIdAndWarehouseId(loadId, warehouseId, 31, 2); if(protectionList.size() == 0){ - updateEntity.setIsUnloadPhoto(0); - trunklineCarsLoadLineService.updateById(updateEntity); + carsLoadLine.setIsUnloadPhoto(0); + trunklineCarsLoadLineService.updateById(carsLoadLine); return R.success("上传成功"); } - updateEntity.setIsUnloadPhoto(1); - trunklineCarsLoadLineService.updateById(updateEntity); + carsLoadLine.setIsUnloadPhoto(1); + trunklineCarsLoadLineService.updateById(carsLoadLine); return R.success("上传成功"); } @@ -5203,6 +5212,10 @@ public class TrunklineCarsLoadServiceImpl extends BaseServiceImpl parcelListEntityList = distributionParcelListClient.findEntityVOListByOrderCode(orderCode, fromWarehouseId); @@ -5751,6 +5764,11 @@ public class TrunklineCarsLoadServiceImpl extends BaseServiceImpl packageDataList = new ArrayList<>(); + List loadScanEntityList = trunklineCarsLoadScanService.findListByIds(loadScanIds); //把loadScanEntityList中所有元素通过type进行分组 Map> map = loadScanEntityList.stream().collect(Collectors.groupingBy(TrunklineCarsLoadScanEntity::getType)); @@ -9727,30 +9764,107 @@ public class TrunklineCarsLoadServiceImpl extends BaseServiceImpl scanCodes = trunklineCarsLoadScanEntities.stream().map(TrunklineCarsLoadScanEntity::getScanCode).collect(Collectors.toList()); //TODO 暂时注释 // carsLoadAsyncService.sendReportPackageSignData(AuthUtil.getNickName(),AuthUtil.getUserId(),warehouseId,warehouseName,carsLoadEntity,scanCodes); + + +// FindParamterDTO findParamterDTO = new FindParamterDTO(); +// findParamterDTO.setOrderPackageCodeList(scanCodes); +// findParamterDTO.setWarehouseId(warehouseId); +// List parcelListEntityList = distributionParcelListClient.findListByOrderPackageCodeList(findParamterDTO); +// parcelListEntityList.forEach(parcelListEntity -> { +// PackageData packageData = new PackageData(); +// packageData.setWaybillNumber(parcelListEntity.getWaybillNumber()); +// packageData.setBrand(parcelListEntity.getBrandName()); +// packageData.setPackageCode(parcelListEntity.getOrderPackageCode()); +// packageData.setMaterialCode(parcelListEntity.getMaterialCode()); +// packageData.setMaterialName(parcelListEntity.getMaterialName()); +// packageData.setNumber(1); +// packageData.setOrderCode(parcelListEntity.getOrderCode()); +// packageData.setPackageType(PackageTypeEnums.CMP); +// packageDataList.add(packageData); +// }); + }else{ trunklineCarsLoadScanEntities.forEach(carsLoadScanEntity -> { Long scanId = carsLoadScanEntity.getId(); List zeroDetailVOList = scanZeroDetailService.findListByCarsLoadScanId(scanId); + + //把zeroDetailList中所有元素的packageId放入一个List + List packageIds = zeroDetailVOList.stream().map(TrunklineScanZeroDetailEntity::getPackageId).collect(Collectors.toList()); + List parcelListEntityList = distributionParcelListClient.findListByIds(packageIds); + //把parcelListEntityList转成以id为key的Map + Map parcelListMap = parcelListEntityList.stream().collect(Collectors.toMap(DistributionParcelListEntity::getId, Function.identity())); + List zeroDetailList = new ArrayList<>(); zeroDetailVOList.forEach(zeroDetailVO -> { TrunklineScanZeroDetailEntity entity = new TrunklineScanZeroDetailEntity(); BeanUtil.copy(zeroDetailVO, entity); zeroDetailList.add(entity); +// Long packageId = zeroDetailVO.getPackageId(); +// DistributionParcelListEntity parcelList = parcelListMap.get(packageId); +// if(!Objects.isNull(parcelList)){ +// PackageData packageData = new PackageData(); +// packageData.setWaybillNumber(parcelList.getWaybillNumber()); +// packageData.setBrand(parcelList.getBrandName()); +// packageData.setProductId(zeroDetailVO.getGoodsId()); +// packageData.setProductName(zeroDetailVO.getGoodsName()); +// packageData.setNumber(zeroDetailVO.getUnloadNum()); +// packageData.setOrderCode(parcelList.getOrderCode()); +// packageData.setPackageType(PackageTypeEnums.LTL); +// packageDataList.add(packageData); +// } + + }); //TODO 暂时注释 // carsLoadAsyncService.sendReportZeroPackageSignData(AuthUtil.getUserId(), AuthUtil.getNickName(), warehouseId, warehouseName, zeroDetailList, carsLoadScanEntity, carsLoadEntity); + + + }); } }); +// NodeFanoutMsg tripartiteVONodeFanoutMsg = buildNodeFanoutMessage(carsLoadEntity, packageDataList, warehouseId); +// if(!Objects.isNull(tripartiteVONodeFanoutMsg)){ +// rabbitTemplate.convertAndSend(FanoutConstants.trunkline.tripartite.EXCHANGE, null, com.alibaba.fastjson.JSONObject.toJSONString(tripartiteVONodeFanoutMsg)); +// } return R.success("签收成功"); } + private NodeFanoutMsg buildNodeFanoutMessage(TrunklineCarsLoadEntity carsLoadEntity, List packageDataList,Long warehouseId) { + try { + BladeUser user = AuthUtil.getUser(); + NodeFanoutMsg nodeFanoutMsg = new NodeFanoutMsg(); + nodeFanoutMsg.setBizOperation(BizOperationEnums.ADD); + nodeFanoutMsg.setNode(WorkNodeEnums.SIGN_TRIPARTITE_TRANSFER_DEPART); + BasicdataWarehouseEntity entityWarehouse = basicdataWarehouseClient.getEntityWarehouseId(warehouseId); + if (entityWarehouse != null) { + nodeFanoutMsg.setWarehouse(entityWarehouse.getName()); + } + nodeFanoutMsg.setWarehouseId(warehouseId); + nodeFanoutMsg.setOperator(user.getNickName()); + nodeFanoutMsg.setOperatorTime(new Date()); + TripartiteVO tripartiteVO = new TripartiteVO(); + BeanUtil.copy(carsLoadEntity, tripartiteVO); +// ReservationVO reservationVO = distributionReservationService.getReservationVO(reservationEntity); + + tripartiteVO.setPackageDataList(packageDataList); + nodeFanoutMsg.setMain(tripartiteVO); + nodeFanoutMsg.setTenantId(AuthUtil.getTenantId()); + + return nodeFanoutMsg; + } catch (Exception e) { + log.warn("三方中转签收:发送三方中转签收节点消息失败", e); + } + return null; + + } + private void sendFactorySignTriparite(Long warehouseId, List orderPackageCodes, BasicdataWarehouseEntity warehouseEntity) { try { FindParamterDTO paramterDTO = new FindParamterDTO(); @@ -10107,6 +10221,14 @@ public class TrunklineCarsLoadServiceImpl extends BaseServiceImpl orderPackageCodes = new ArrayList<>(); orderPackageCodes.add(orderPackageCode); + String content = "包件在 " + warehouseName + "卸车,车次号:"+carsLoadEntity.getCarsNo()+" 卸车方式:" + IncomingTypeEnum.getValue(incomingType)+ (StringUtil.isNotBlank(unloadTrayName)?"托盘:"+unloadTrayName:""); + if(NumberUtil.equals(isData,0)){ + content = "包件在 " + warehouseName + "卸车,车次号:"+carsLoadEntity.getCarsNo()+" 卸车方式:系统无编码 卸车(只记录未入库)"; + } packageTrackLogAsyncService.addPackageTrackLog(AuthUtil.getTenantId(), AuthUtil.getUserId(), Func.firstLong(AuthUtil.getDeptId()), AuthUtil.getNickName(), orderPackageCodes, warehouseId, warehouseName, WorkNodeEnums.UNLOAD_INCOMING_WAREHOUSE.getCode(), content); carsLoadAsyncService.sendFactoryData(orderCode,orderPackageCode,warehouseId,warehouseName); @@ -12744,7 +12911,17 @@ public class TrunklineCarsLoadServiceImpl extends BaseServiceImpl scanCodeList = new ArrayList<>(scanCodeSet); + + FindParamterDTO findParamterDTO = new FindParamterDTO(); + findParamterDTO.setOrderPackageCodeList(scanCodeList); + findParamterDTO.setWarehouseId(warehouseId); + List parcelListEntityList = distributionParcelListClient.findListByOrderPackageCodeList(findParamterDTO); + //把parcelListEntityList转化成以orderPackageCode作为key的Map + Map parcelMap = parcelListEntityList.stream() + .collect(Collectors.toMap(DistributionParcelListEntity::getOrderPackageCode, Function.identity())); + + List allAdvanceDetailList = new ArrayList<>(); int packageBatchSize = 500; @@ -13405,7 +13622,13 @@ public class TrunklineCarsLoadServiceImpl extends BaseServiceImpl 0){ DistributionParcelListEntity parcelListEntity = distributionParcelListClient.findByPacketBarCodeAndWarehouseId(orderPackageCode, warehouseId); if(!Objects.isNull(parcelListEntity)){ @@ -13461,6 +13684,7 @@ public class TrunklineCarsLoadServiceImpl extends BaseServiceImpl updateParceList = new ArrayList<>(); @@ -13512,6 +13732,10 @@ public class TrunklineCarsLoadServiceImpl extends BaseServiceImpl parcelListEntityList = distributionParcelListClient.findEntityListByOrderCode(orderCode, fromWarehouseId); List ls = new ArrayList<>(); for (DistributionParcelListEntity parcelListEntity : parcelListEntityList) { diff --git a/blade-service/logpm-warehouse/src/main/java/com/logpm/warehouse/service/impl/WarehouseTrayTypeServiceImpl.java b/blade-service/logpm-warehouse/src/main/java/com/logpm/warehouse/service/impl/WarehouseTrayTypeServiceImpl.java index b4596610f..1f083ae81 100644 --- a/blade-service/logpm-warehouse/src/main/java/com/logpm/warehouse/service/impl/WarehouseTrayTypeServiceImpl.java +++ b/blade-service/logpm-warehouse/src/main/java/com/logpm/warehouse/service/impl/WarehouseTrayTypeServiceImpl.java @@ -4877,10 +4877,15 @@ public class WarehouseTrayTypeServiceImpl extends BaseServiceImpl parcelNumberList = new ArrayList<>(); for (ProductDTO productDTO : products) { String productName = productDTO.getProductName();