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..5ee4695b2 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 @@ -9,7 +9,7 @@ public interface ModuleNameConstant { /** * 如果不需要 "" */ - public static final String DEVAUTH =""; + public static final String DEVAUTH ="-zhy"; /** * 工厂对接服务名称 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 146fb6315..8a761b427 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 @@ -27,6 +27,20 @@ public abstract class FanoutConstants { } + interface CARSLOADDATA { + // 交换机 + String EXCHANGE = "fanout.trunkline.carsloaddata" + ModuleNameConstant.DEVAUTH; + + interface QUEUE { + + // 保存基础数据 + String REPORT_CARSLOADDATA = "fanout.trunkline.reportdata.report.carsloadData" + ModuleNameConstant.DEVAUTH; + + } + } + + + // 开单 interface OPENWAYBILL { diff --git a/blade-biz-common/src/main/java/org/springblade/common/model/PackageData.java b/blade-biz-common/src/main/java/org/springblade/common/model/PackageData.java index 87ec1bf1e..6f24b3681 100644 --- a/blade-biz-common/src/main/java/org/springblade/common/model/PackageData.java +++ b/blade-biz-common/src/main/java/org/springblade/common/model/PackageData.java @@ -149,4 +149,8 @@ public class PackageData implements Serializable { */ private String signUser;//签收人 + + private Long finalNodeId; + private String finalNodeName; + } diff --git a/blade-service-api/logpm-report-api/src/main/java/com/logpm/report/entity/ReportPackageBasicEntity.java b/blade-service-api/logpm-report-api/src/main/java/com/logpm/report/entity/ReportPackageBasicEntity.java index 8ffed246a..610d89d0a 100644 --- a/blade-service-api/logpm-report-api/src/main/java/com/logpm/report/entity/ReportPackageBasicEntity.java +++ b/blade-service-api/logpm-report-api/src/main/java/com/logpm/report/entity/ReportPackageBasicEntity.java @@ -94,6 +94,9 @@ public class ReportPackageBasicEntity extends TenantEntity { @ApiModelProperty(name = "客户车次号",notes = "") private String customerTrain ; + @ApiModelProperty(name = "物料编码",notes = "") + private String materialCode ; + @ApiModelProperty(name = "物料名称",notes = "") private String materialName ; @@ -160,4 +163,14 @@ public class ReportPackageBasicEntity extends TenantEntity { @ApiModelProperty(name = "是否改过单",notes = "") private Integer isEditWaybill ; + @ApiModelProperty(name = "暂存单id",notes = "") + private Long advanceId; + + @ApiModelProperty(name = "数据推送仓库id",notes = "") + private Long warehouseId; + + @ApiModelProperty(name = "数据推送仓库",notes = "") + private String warehouse; + + } diff --git a/blade-service-api/logpm-trunkline-api/src/main/java/com/logpm/trunkline/entity/ReportPackageBasicEntity.java b/blade-service-api/logpm-trunkline-api/src/main/java/com/logpm/trunkline/entity/ReportPackageBasicEntity.java new file mode 100644 index 000000000..081dfbf91 --- /dev/null +++ b/blade-service-api/logpm-trunkline-api/src/main/java/com/logpm/trunkline/entity/ReportPackageBasicEntity.java @@ -0,0 +1,176 @@ +package com.logpm.trunkline.entity; + +import com.baomidou.mybatisplus.annotation.TableName; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.*; +import org.springblade.core.tenant.mp.TenantEntity; + +import java.math.BigDecimal; +import java.util.Date; + +@Data +@TableName("logpm_report_package_basic") +@ApiModel(value = "ReportPackageBasic对象", description = "报表基础信息类") +@EqualsAndHashCode(callSuper = true) +@AllArgsConstructor +@NoArgsConstructor +@Builder +public class ReportPackageBasicEntity extends TenantEntity { + + /** 预留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 waybillNo ; + + @ApiModelProperty(name = "服务号",notes = "") + private String serviceNo ; + + @ApiModelProperty(name = "订单号",notes = "") + private String orderCode ; + + @ApiModelProperty(name = "包件码",notes = "") + private String orderPackageCode ; + + @ApiModelProperty(name = "品类名称",notes = "") + private String productName ; + + @ApiModelProperty(name = "品类id",notes = "") + private Long productId ; + + @ApiModelProperty(name = "数量",notes = "") + private Integer num ; + + @ApiModelProperty(name = "重量",notes = "") + private BigDecimal weight ; + + @ApiModelProperty(name = "体积",notes = "") + private BigDecimal volume ; + + @ApiModelProperty(name = "入库时间",notes = "") + private Date incomingTime ; + + @ApiModelProperty(name = "入库人",notes = "") + private String incomingUserName ; + + @ApiModelProperty(name = "入库人id",notes = "") + private Long incomingUserId ; + + @ApiModelProperty(name = "数据推送时间",notes = "") + private Date pushTime ; + + @ApiModelProperty(name = "数据推送人",notes = "") + private String pushUserName ; + + @ApiModelProperty(name = "数据推送人id",notes = "") + private Long pushUserId ; + + @ApiModelProperty(name = "开单时间",notes = "") + private Date openTime ; + + @ApiModelProperty(name = "开单人",notes = "") + private String openUserName ; + + @ApiModelProperty(name = "开单人id",notes = "") + private Long openUserId ; + + @ApiModelProperty(name = "数据类型 1订制品 2零担",notes = "") + private Integer dataType ; + + @ApiModelProperty(name = "客户车次号",notes = "") + private String customerTrain ; + + @ApiModelProperty(name = "物料编码",notes = "") + private String materialCode ; + + @ApiModelProperty(name = "物料名称",notes = "") + private String materialName ; + + @ApiModelProperty(name = "物料id",notes = "") + private Long materialId ; + + @ApiModelProperty(name = "批次号",notes = "") + private String incomingBatch ; + + @ApiModelProperty(name = "发货单位名称",notes = "") + private String shipper; + + @ApiModelProperty(name = "发货单位id",notes = "") + private Long shipperId; + + @ApiModelProperty(name = "收货单位名称",notes = "") + private String consignee ; + + @ApiModelProperty(name = "收货单位id",notes = "") + private Long consigneeId ; + + @ApiModelProperty(name = "发站仓",notes = "") + private String departureWarehouseName ; + + @ApiModelProperty(name = "发站仓id",notes = "") + private Long departureWarehouseId ; + + @ApiModelProperty(name = "目的仓",notes = "") + private String destinationWarehouseName ; + + @ApiModelProperty(name = "目的仓id",notes = "") + private Long destinationWarehouseId ; + + @ApiModelProperty(name = "发站",notes = "") + private String departure ; + + @ApiModelProperty(name = "到站",notes = "") + private String destination ; + + @ApiModelProperty(name = "工厂商场编码",notes = "") + private String dealerCode ; + + @ApiModelProperty(name = "工厂商场名称",notes = "") + private String dealerName ; + + @ApiModelProperty(name = "合包码",notes = "") + private String mergePackageCode ; + + @ApiModelProperty(name = "入库类型",notes = "") + private Integer incomingType ; + + @ApiModelProperty(name = "品牌id",notes = "") + private Long brandId ; + + @ApiModelProperty(name = "品牌",notes = "") + private String brand ; + + @ApiModelProperty(name = "订单来源",notes = "") + private String systemType ; + + @ApiModelProperty(name = "入库状态",notes = "") + private Integer incomingStatus ; + + @ApiModelProperty(name = "是否改过单",notes = "") + private Integer isEditWaybill ; + + @ApiModelProperty(name = "暂存单id",notes = "") + private Long advanceId; + + @ApiModelProperty(name = "数据推送仓库id",notes = "") + private Long warehouseId; + + @ApiModelProperty(name = "数据推送仓库",notes = "") + private String warehouse; + + +} diff --git a/blade-service-api/logpm-trunkline-api/src/main/java/com/logpm/trunkline/entity/ReportPackageTrunklineEntity.java b/blade-service-api/logpm-trunkline-api/src/main/java/com/logpm/trunkline/entity/ReportPackageTrunklineEntity.java new file mode 100644 index 000000000..d4f399ca1 --- /dev/null +++ b/blade-service-api/logpm-trunkline-api/src/main/java/com/logpm/trunkline/entity/ReportPackageTrunklineEntity.java @@ -0,0 +1,128 @@ +package com.logpm.trunkline.entity; + +import com.baomidou.mybatisplus.annotation.TableName; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.*; +import org.springblade.core.tenant.mp.TenantEntity; + +@Data +@TableName("logpm_report_package_trunkline") +@ApiModel(value = "ReportPackageTrunkline对象", description = "报表干线信息类") +@EqualsAndHashCode(callSuper = true) +@AllArgsConstructor +@NoArgsConstructor +@Builder +public class ReportPackageTrunklineEntity extends TenantEntity { + + /** 预留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 = "基础id",notes = "") + private Long basicId ; + + @ApiModelProperty(name = "配载车次号",notes = "") + private String loadNo ; + + @ApiModelProperty(name = "运单号",notes = "") + private String waybillNo ; + + @ApiModelProperty(name = "服务号",notes = "") + private String serviceNo ; + + @ApiModelProperty(name = "订单号",notes = "") + private String orderCode ; + + @ApiModelProperty(name = "包件码",notes = "") + private String orderPackageCode ; + + @ApiModelProperty(name = "品类名称",notes = "") + private String productName ; + + @ApiModelProperty(name = "品类id",notes = "") + private Long productId ; + + @ApiModelProperty(name = "品牌",notes = "") + private String brand ; + + @ApiModelProperty(name = "品牌id",notes = "") + private Long brandId ; + + @ApiModelProperty(name = "发站仓",notes = "") + private String departureWarehouseName ; + + @ApiModelProperty(name = "发站仓id",notes = "") + private Long departureWarehouseId ; + + @ApiModelProperty(name = "目的仓",notes = "") + private String destinationWarehouseName ; + + @ApiModelProperty(name = "目的仓id",notes = "") + private Long destinationWarehouseId ; + + @ApiModelProperty(name = "装车仓库id",notes = "") + private Long loadingWarehouseId ; + + @ApiModelProperty(name = "装车仓库",notes = "") + private String loadingWarehouseName ; + + @ApiModelProperty(name = "装车人id",notes = "") + private Long loadingUserId ; + + @ApiModelProperty(name = "装车人名称",notes = "") + private String loadingUserName ; + + @ApiModelProperty(name = "是否是始发仓",notes = "") + private Integer isStartWarehouse ; + + @ApiModelProperty(name = "计划卸车仓库id",notes = "") + private Long finalNodeId ; + + @ApiModelProperty(name = "计划卸车仓库",notes = "") + private String finalNodeName ; + + @ApiModelProperty(name = "卸车仓库id",notes = "") + private Long unloadWarehouseId ; + + @ApiModelProperty(name = "卸车仓库",notes = "") + private String unloadWarehouseName ; + + @ApiModelProperty(name = "卸车人id",notes = "") + private Long unloadUserId ; + + @ApiModelProperty(name = "卸车人名称",notes = "") + private String unloadUserName ; + + @ApiModelProperty(name = "是否是目的仓仓",notes = "") + private Integer isEndWarehouse ; + + @ApiModelProperty(name = "干线状态 1装车 2卸车 3签收",notes = "") + private Integer trunklineStatus ; + + @ApiModelProperty(name = "是否是直发商家 0否 1是",notes = "") + private Integer isCustomer ; + + @ApiModelProperty(name = "装车数量",notes = "") + private Integer loadingNum ; + + @ApiModelProperty(name = "卸车数量",notes = "") + private Integer unloadNum ; + + @ApiModelProperty(name = "签收数量",notes = "") + private Integer signNum ; + + +} diff --git a/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/controller/AdvanceDetailController.java b/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/controller/AdvanceDetailController.java index 7ede23f75..aa209636b 100644 --- a/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/controller/AdvanceDetailController.java +++ b/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/controller/AdvanceDetailController.java @@ -88,6 +88,12 @@ public class AdvanceDetailController { try{ List advanceDetailIds = advanceDetailDTO.getAdvanceDetailIds(); + BasicdataWarehouseEntity myCurrentWarehouse = warehouseClient.getMyCurrentWarehouse(); + if(!Objects.isNull(myCurrentWarehouse)){ + advanceDetailDTO.setWarehouseId(myCurrentWarehouse.getId()); + advanceDetailDTO.setWarehouseName(myCurrentWarehouse.getName()); + } + if(CollUtil.isEmpty(advanceDetailIds)){ log.warn(method+"请选择删除的包件"); return R.fail(405,"请选择删除的包件"); diff --git a/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/mapper/ReportPackageBasicMapper.java b/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/mapper/ReportPackageBasicMapper.java new file mode 100644 index 000000000..1fc6439c1 --- /dev/null +++ b/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/mapper/ReportPackageBasicMapper.java @@ -0,0 +1,23 @@ +package com.logpm.trunkline.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.logpm.trunkline.entity.ReportPackageBasicEntity; +import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; + +import java.util.List; + +@Mapper +public interface ReportPackageBasicMapper extends BaseMapper { + void deleteByOrderPackageCodes(@Param("packageCodes") List packageCodes); + + List findByOrderPackageCodes(@Param("packageCodes") List packageCodes); + + List findListByWaybillNo(@Param("waybillNo") String waybillNo); + + void deleteByIds(@Param("ids") List ids); + + List findListByOrderCode(@Param("orderCode") String orderCode); + + List findListByOrderCodeList(@Param("orderCodeList") List orderCodeList); +} diff --git a/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/mapper/ReportPackageBasicMapper.xml b/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/mapper/ReportPackageBasicMapper.xml new file mode 100644 index 000000000..b61531dff --- /dev/null +++ b/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/mapper/ReportPackageBasicMapper.xml @@ -0,0 +1,53 @@ + + + + + + + delete from logpm_report_package_basic + where order_package_code in + + #{item} + + + + + + + + + + delete from logpm_report_package_basic + where id in + + #{item} + + + + + + + + diff --git a/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/mapper/ReportPackageTrunklineMapper.java b/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/mapper/ReportPackageTrunklineMapper.java new file mode 100644 index 000000000..6cc48b22d --- /dev/null +++ b/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/mapper/ReportPackageTrunklineMapper.java @@ -0,0 +1,12 @@ +package com.logpm.trunkline.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.logpm.trunkline.entity.ReportPackageTrunklineEntity; +import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; + +@Mapper +public interface ReportPackageTrunklineMapper extends BaseMapper { + + void deleteListByCarsNoAndWarehouseId(@Param("carsNo") String carsNo, @Param("warehouseId") Long warehouseId); +} diff --git a/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/mapper/ReportPackageTrunklineMapper.xml b/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/mapper/ReportPackageTrunklineMapper.xml new file mode 100644 index 000000000..26e2d7a3f --- /dev/null +++ b/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/mapper/ReportPackageTrunklineMapper.xml @@ -0,0 +1,13 @@ + + + + + + + delete from logpm_report_package_trunkline + where load_no = #{carsNo} + and loading_warehouse_id = #{warehouseId} + + + + diff --git a/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/mapper/TrunklineAdvanceDetailMapper.java b/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/mapper/TrunklineAdvanceDetailMapper.java index 4fa40dd7e..185a5b37b 100644 --- a/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/mapper/TrunklineAdvanceDetailMapper.java +++ b/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/mapper/TrunklineAdvanceDetailMapper.java @@ -103,6 +103,8 @@ public interface TrunklineAdvanceDetailMapper extends BaseMapper findOrderDetailsAndTrunklineCarsNo(IPage page, @Param("param") OrderDetailsDTO orderDetailsDTO); + List findListByWaybillId(@Param("waybillId") Long waybillId); + void deleteListByIds(@Param("advanceDetailIdList") List advanceDetailIdList); } diff --git a/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/mapper/TrunklineAdvanceDetailMapper.xml b/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/mapper/TrunklineAdvanceDetailMapper.xml index 9c0ff6c2c..f1ca96c59 100644 --- a/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/mapper/TrunklineAdvanceDetailMapper.xml +++ b/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/mapper/TrunklineAdvanceDetailMapper.xml @@ -735,6 +735,13 @@ AND cmax.cupdateTime = ltcls.create_time + + delete from logpm_trunkline_advance_detail where id in diff --git a/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/mq/report/AdvanceDetailDealListener.java b/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/mq/report/AdvanceDetailDealListener.java new file mode 100644 index 000000000..e8646b915 --- /dev/null +++ b/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/mq/report/AdvanceDetailDealListener.java @@ -0,0 +1,463 @@ +package com.logpm.trunkline.mq.report; + +import cn.hutool.core.collection.CollUtil; +import cn.hutool.json.JSONArray; +import cn.hutool.json.JSONObject; +import cn.hutool.json.JSONUtil; +import com.logpm.trunkline.entity.ReportPackageBasicEntity; +import com.logpm.trunkline.entity.TrunklineAdvanceDetailEntity; +import com.logpm.trunkline.service.IReportPackageBasicService; +import com.logpm.trunkline.service.ITrunklineAdvanceDetailService; +import com.logpm.warehouse.entity.WarehouseWayBillDetail; +import com.logpm.warehouse.entity.WarehouseWaybillEntity; +import com.logpm.warehouse.feign.IWarehouseWaybillDetailClient; +import lombok.AllArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springblade.common.constant.WorkNodeEnums; +import org.springblade.common.constant.broadcast.FanoutConstants; +import org.springblade.common.enums.BizOperationEnums; +import org.springblade.common.enums.PackageTypeEnums; +import org.springblade.common.model.NodeFanoutMsg; +import org.springblade.common.model.PackageData; +import org.springblade.core.tool.utils.StringUtil; +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.stereotype.Component; +import org.springframework.transaction.annotation.Transactional; + +import java.util.*; +import java.util.function.Function; +import java.util.stream.Collectors; + + +/** + * 监听工厂数据转暂存单 + * + * @author zhenghaoyu + * @create 2024-03-26 13:43 + */ +@Slf4j +@Component +@AllArgsConstructor +public class AdvanceDetailDealListener { + + private final IReportPackageBasicService reportPackageBasicService; + private final IWarehouseWaybillDetailClient warehouseWaybillDetailClient; + private final ITrunklineAdvanceDetailService advanceDetailService; + + + @RabbitListener(bindings = @QueueBinding( + value = @Queue(name = FanoutConstants.trunkline.REPORTDATA.QUEUE.REPORT_BASICDATA), + exchange = @Exchange(name = FanoutConstants.trunkline.REPORTDATA.EXCHANGE, type = ExchangeTypes.FANOUT) + )) + @Transactional(rollbackFor = Exception.class) + public void advanceDetailDeal(String msg) { + String method = "####################advanceDetailDeal: "; + if(StringUtil.isNotBlank(msg)){ + + NodeFanoutMsg bean = JSONUtil.toBean(msg, NodeFanoutMsg.class); + WorkNodeEnums node = bean.getNode(); + BizOperationEnums bizOperation = bean.getBizOperation(); + String operator = bean.getOperator(); + Long operatorId = bean.getOperatorId(); + Date operatorTime = bean.getOperatorTime(); + String warehouse = bean.getWarehouse(); + Long warehouseId = bean.getWarehouseId(); + Object main = bean.getMain(); + + if(WorkNodeEnums.INITIAL_DATA_ENTRY.equals(node)){ + + if(BizOperationEnums.ADD.equals(bizOperation)){ + //暂存单数据入库 + //保存包件基础数据 + savePackageBasicData(main, operator, operatorId,operatorTime,warehouse,warehouseId); + }else if(BizOperationEnums.DELETE.equals(bizOperation)){ + deletePackageBasicData(main, operator, operatorId,operatorTime,warehouse,warehouseId); + }else if(BizOperationEnums.MODIFY.equals(bizOperation)){ + + }else{ + log.warn(method+"未知的操作类型"); + } + }else if(WorkNodeEnums.INITIAL_WAREHOUSE_ENTRY.equals(node)){ + if(BizOperationEnums.ADD.equals(bizOperation)){ + + }else if(BizOperationEnums.DELETE.equals(bizOperation)){ + + }else if(BizOperationEnums.MODIFY.equals(bizOperation)){ + updateIncomingPackageBasicData(main, operator, operatorId,operatorTime,warehouse,warehouseId); + }else{ + log.warn(method+"未知的操作类型"); + } + }else if(WorkNodeEnums.OPEN_ORDER.equals(node)){ + if(BizOperationEnums.ADD.equals(bizOperation)){ + + }else if(BizOperationEnums.DELETE.equals(bizOperation)){ + + }else if(BizOperationEnums.MODIFY.equals(bizOperation)){ + updateOpenOrderPackageBasicData(main, operator, operatorId,operatorTime,warehouse,warehouseId); + }else{ + log.warn(method+"未知的操作类型"); + } + }else if(WorkNodeEnums.CHANGE_ORDER.equals(node)){ + if(BizOperationEnums.ADD.equals(bizOperation)){ + + }else if(BizOperationEnums.DELETE.equals(bizOperation)){ + + }else if(BizOperationEnums.MODIFY.equals(bizOperation)){ + updateWaybillPackageBasicData(main, operator, operatorId,operatorTime,warehouse,warehouseId); + }else{ + log.warn(method+"未知的操作类型"); + } + }else { + log.warn(method+"未知的节点类型"); + } + + } + + } + + private void updateWaybillPackageBasicData(Object main, String operator, Long operatorId, Date operatorTime, String warehouse, Long warehouseId) { + + String method = "####################updateWaybillPackageBasicData: "; + + WarehouseWaybillEntity waybill = JSONUtil.toBean(JSONUtil.toJsonStr(main), WarehouseWaybillEntity.class); + Long waybillId = waybill.getId(); + Integer waybillType = waybill.getWaybillType(); + String waybillNo = waybill.getWaybillNo(); + List updateList = new ArrayList<>(); + List addList = new ArrayList<>(); + List deleteList = new ArrayList<>(); + if(waybillType == 1){ + + List reportPackageList = reportPackageBasicService.findListByWaybillNo(waybillNo); + + List advanceDetailEntities = advanceDetailService.findListByWaybillId(waybillId); + //把advanceDetailEntities转化成以orderPackageCode为key的Map + Map advanceDetailEntityMap = advanceDetailEntities.stream().collect(Collectors.toMap(TrunklineAdvanceDetailEntity::getOrderPackageCode, Function.identity())); + + reportPackageList.forEach(reportPackageBasicEntity -> { + String orderPackageCode = reportPackageBasicEntity.getOrderPackageCode(); + TrunklineAdvanceDetailEntity trunklineAdvanceDetailEntity = advanceDetailEntityMap.get(orderPackageCode); + if(!Objects.isNull(trunklineAdvanceDetailEntity)){ + ReportPackageBasicEntity updateEntity = new ReportPackageBasicEntity(); + updateEntity.setId(reportPackageBasicEntity.getId()); + updateEntity.setProductId(trunklineAdvanceDetailEntity.getIncomeCategoryId()); + updateEntity.setProductName(trunklineAdvanceDetailEntity.getIncomeCategoryName()); + updateEntity.setMaterialId(trunklineAdvanceDetailEntity.getMaterialId()); + updateEntity.setMaterialCode(trunklineAdvanceDetailEntity.getMaterialCode()); + updateEntity.setMaterialName(trunklineAdvanceDetailEntity.getMaterialName()); + updateEntity.setShipperId(waybill.getShipperId()); + updateEntity.setShipper(waybill.getShipper()); + updateEntity.setConsignee(waybill.getConsignee()); + updateEntity.setConsigneeId(waybill.getConsigneeId()); + updateEntity.setDepartureWarehouseId(waybill.getDepartureWarehouseId()); + updateEntity.setDepartureWarehouseName(waybill.getDepartureWarehouseName()); + updateEntity.setDestinationWarehouseId(waybill.getDestinationWarehouseId()); + updateEntity.setDestinationWarehouseName(waybill.getDestinationWarehouseName()); + updateEntity.setDeparture(waybill.getDeparture()); + updateEntity.setDestination(waybill.getDestination()); + updateEntity.setIsEditWaybill(1); + updateList.add(updateEntity); + } + }); + + + }else if(waybillType == 2){ + + List wayBillDetailList = warehouseWaybillDetailClient.findByWaybillId(waybillId); + + List reportPackageList = reportPackageBasicService.findListByOrderCode(waybillNo); + //把reportPackageList以productName为key的Map + Map reportPackageBasicEntityMap = reportPackageList.stream().collect(Collectors.toMap(ReportPackageBasicEntity::getProductName, Function.identity())); + wayBillDetailList.forEach(wayBillDetail -> { + String productName = wayBillDetail.getProductName(); + ReportPackageBasicEntity reportPackageBasicEntity = reportPackageBasicEntityMap.get(productName); + if(!Objects.isNull(reportPackageBasicEntity)){ + ReportPackageBasicEntity updateEntity = new ReportPackageBasicEntity(); + updateEntity.setId(reportPackageBasicEntity.getId()); + updateEntity.setProductId(wayBillDetail.getProductId()); + updateEntity.setProductName(wayBillDetail.getProductName()); + updateEntity.setNum(wayBillDetail.getNum()); + updateEntity.setWeight(wayBillDetail.getWeight()); + updateEntity.setVolume(wayBillDetail.getVolume()); + updateEntity.setShipperId(waybill.getShipperId()); + updateEntity.setShipper(waybill.getShipper()); + updateEntity.setConsignee(waybill.getConsignee()); + updateEntity.setConsigneeId(waybill.getConsigneeId()); + updateEntity.setDepartureWarehouseId(waybill.getDepartureWarehouseId()); + updateEntity.setDepartureWarehouseName(waybill.getDepartureWarehouseName()); + updateEntity.setDestinationWarehouseId(waybill.getDestinationWarehouseId()); + updateEntity.setDestinationWarehouseName(waybill.getDestinationWarehouseName()); + updateEntity.setDeparture(waybill.getDeparture()); + updateEntity.setDestination(waybill.getDestination()); + updateEntity.setIsEditWaybill(1); + updateList.add(updateEntity); + }else{ + ReportPackageBasicEntity addEntity = new ReportPackageBasicEntity(); + addEntity.setWaybillNo(waybill.getWaybillNo()); + addEntity.setOrderCode(waybill.getWaybillNo()); + addEntity.setNum(wayBillDetail.getNum()); + addEntity.setWeight(wayBillDetail.getWeight()); + addEntity.setVolume(wayBillDetail.getVolume()); + addEntity.setPushUserId(operatorId); + addEntity.setPushUserName(operator); + addEntity.setPushTime(operatorTime); + addEntity.setOpenTime(operatorTime); + addEntity.setOpenUserName(operator); + addEntity.setOpenUserId(operatorId); + addEntity.setIncomingTime(operatorTime); + addEntity.setIncomingUserName(operator); + addEntity.setIncomingUserId(operatorId); + addEntity.setDataType(PackageTypeEnums.LTL.getCode()); + addEntity.setSystemType("线下"); + addEntity.setBrandId(waybill.getBrandId()); + addEntity.setBrand(waybill.getBrand()); + addEntity.setWarehouse(warehouse); + addEntity.setWarehouseId(warehouseId); + addEntity.setIncomingType(3); + addEntity.setShipper(waybill.getShipper()); + addEntity.setShipperId(waybill.getShipperId()); + addEntity.setConsignee(waybill.getConsignee()); + addEntity.setConsigneeId(waybill.getConsigneeId()); + addEntity.setDepartureWarehouseId(waybill.getDepartureWarehouseId()); + addEntity.setDepartureWarehouseName(waybill.getDepartureWarehouseName()); + addEntity.setDestinationWarehouseId(waybill.getDestinationWarehouseId()); + addEntity.setDestinationWarehouseName(waybill.getDestinationWarehouseName()); + addEntity.setDeparture(waybill.getDeparture()); + addEntity.setDestination(waybill.getDestination()); + addEntity.setIncomingStatus(1); + addList.add(addEntity); + } + }); + + //判断是否有删除的明细数据 + reportPackageList.forEach(reportPackageBasicEntity -> { + String productName = reportPackageBasicEntity.getProductName(); + Integer flag = 0; + for (WarehouseWayBillDetail warehouseWayBillDetail : wayBillDetailList) { + String productName1 = warehouseWayBillDetail.getProductName(); + if(productName.equals(productName1)){ + flag = 1; + break; + } + } + if(flag == 1){ + deleteList.add(reportPackageBasicEntity); + } + }); + + }else{ + log.warn(method+"未知的运单类型"); + } + + if(CollUtil.isNotEmpty(updateList)){ + reportPackageBasicService.updateBatchById(updateList); + } + if(CollUtil.isNotEmpty(addList)){ + reportPackageBasicService.saveBatch(addList); + } + if(CollUtil.isNotEmpty(deleteList)){ + //把deleteList中所有元素的id放入一个list + List ids = deleteList.stream().map(ReportPackageBasicEntity::getId).collect(Collectors.toList()); + reportPackageBasicService.deleteByIds(ids); + } + } + + private void updateOpenOrderPackageBasicData(Object main, String operator, Long operatorId, Date operatorTime, String warehouse, Long warehouseId) { + + JSONObject js = JSONUtil.toBean(JSONUtil.toJsonStr(main), JSONObject.class); + + JSONArray details = js.getJSONArray("details"); + + List packageDataList = JSONUtil.toList(details, PackageData.class); + + WarehouseWaybillEntity waybill = JSONUtil.toBean(js, WarehouseWaybillEntity.class); + Long waybillId = waybill.getId(); + Integer waybillType = waybill.getWaybillType(); + if(waybillType == 1){ + //订制品开单 + //把packageDataList中所有元素的orderPackageCode放入一个List + List packageCodes = packageDataList.stream().map(PackageData::getPackageCode).collect(java.util.stream.Collectors.toList()); + //把packageDataList转化成以orderPackageCode为key的Map + Map packageDataMap = packageDataList.stream().collect(Collectors.toMap(PackageData::getPackageCode, Function.identity())); + + List updateList = new ArrayList<>(); + List packageBasicEntities = reportPackageBasicService.findByOrderPackageCodes(packageCodes); + packageBasicEntities.forEach(entity -> { + String orderPackageCode = entity.getOrderPackageCode(); + PackageData packageData = packageDataMap.get(orderPackageCode); + if(!Objects.isNull(packageData)){ + entity.setWaybillNo(waybill.getWaybillNo()); + entity.setProductId(packageData.getProductId()); + entity.setProductName(packageData.getProductName()); + entity.setWeight(packageData.getWeight()); + entity.setVolume(packageData.getVolume()); + entity.setNum(packageData.getNumber()); + entity.setOpenTime(operatorTime); + entity.setOpenUserName(operator); + entity.setOpenUserId(operatorId); + entity.setShipper(waybill.getShipper()); + entity.setShipperId(waybill.getShipperId()); + entity.setConsignee(waybill.getConsignee()); + entity.setConsigneeId(waybill.getConsigneeId()); + entity.setDepartureWarehouseId(waybill.getDepartureWarehouseId()); + entity.setDepartureWarehouseName(waybill.getDepartureWarehouseName()); + entity.setDestinationWarehouseId(waybill.getDestinationWarehouseId()); + entity.setDestinationWarehouseName(waybill.getDestinationWarehouseName()); + entity.setDeparture(waybill.getDeparture()); + entity.setDestination(waybill.getDestination()); + updateList.add(entity); + } + + }); + + if(CollUtil.isNotEmpty(updateList)){ + reportPackageBasicService.updateBatchById(updateList); + } + + + }else if(waybillType == 2){ + //零担开单 + List wayBillDetailList = warehouseWaybillDetailClient.findByWaybillId(waybillId); + List addList = new ArrayList<>(); + wayBillDetailList.forEach(detail -> { + ReportPackageBasicEntity reportPackageBasicEntity = new ReportPackageBasicEntity(); + reportPackageBasicEntity.setWaybillNo(waybill.getWaybillNo()); + reportPackageBasicEntity.setOrderCode(waybill.getWaybillNo()); + reportPackageBasicEntity.setNum(detail.getNum()); + reportPackageBasicEntity.setWeight(detail.getWeight()); + reportPackageBasicEntity.setVolume(detail.getVolume()); + reportPackageBasicEntity.setPushUserId(operatorId); + reportPackageBasicEntity.setPushUserName(operator); + reportPackageBasicEntity.setPushTime(operatorTime); + reportPackageBasicEntity.setOpenTime(operatorTime); + reportPackageBasicEntity.setOpenUserName(operator); + reportPackageBasicEntity.setOpenUserId(operatorId); + reportPackageBasicEntity.setIncomingTime(operatorTime); + reportPackageBasicEntity.setIncomingUserName(operator); + reportPackageBasicEntity.setIncomingUserId(operatorId); + reportPackageBasicEntity.setDataType(PackageTypeEnums.LTL.getCode()); + reportPackageBasicEntity.setSystemType("线下"); + reportPackageBasicEntity.setBrandId(waybill.getBrandId()); + reportPackageBasicEntity.setBrand(waybill.getBrand()); + reportPackageBasicEntity.setWarehouse(warehouse); + reportPackageBasicEntity.setWarehouseId(warehouseId); + reportPackageBasicEntity.setIncomingType(3); + reportPackageBasicEntity.setShipper(waybill.getShipper()); + reportPackageBasicEntity.setShipperId(waybill.getShipperId()); + reportPackageBasicEntity.setConsignee(waybill.getConsignee()); + reportPackageBasicEntity.setConsigneeId(waybill.getConsigneeId()); + reportPackageBasicEntity.setDepartureWarehouseId(waybill.getDepartureWarehouseId()); + reportPackageBasicEntity.setDepartureWarehouseName(waybill.getDepartureWarehouseName()); + reportPackageBasicEntity.setDestinationWarehouseId(waybill.getDestinationWarehouseId()); + reportPackageBasicEntity.setDestinationWarehouseName(waybill.getDestinationWarehouseName()); + reportPackageBasicEntity.setDeparture(waybill.getDeparture()); + reportPackageBasicEntity.setDestination(waybill.getDestination()); + reportPackageBasicEntity.setIncomingStatus(1); + addList.add(reportPackageBasicEntity); + }); + + if(CollUtil.isNotEmpty(addList)){ + reportPackageBasicService.saveBatch(addList); + } + + } + + } + + private void updateIncomingPackageBasicData(Object main, String operator, Long operatorId, Date operatorTime, String warehouse, Long warehouseId) { + + List packageDataList = JSONUtil.toList(JSONUtil.toJsonStr(main), PackageData.class); + //把packageDataList中所有元素的orderPackageCode放入一个List + List packageCodes = packageDataList.stream().map(PackageData::getPackageCode).collect(java.util.stream.Collectors.toList()); + //把packageDataList转化成以orderPackageCode为key的Map + Map packageDataMap = packageDataList.stream().collect(Collectors.toMap(PackageData::getPackageCode, Function.identity())); + + List updateList = new ArrayList<>(); + List packageBasicEntities = reportPackageBasicService.findByOrderPackageCodes(packageCodes); + packageBasicEntities.forEach(entity -> { + String orderPackageCode = entity.getOrderPackageCode(); + PackageData packageData = packageDataMap.get(orderPackageCode); + if(!Objects.isNull(packageData)){ + entity.setWaybillNo(packageData.getWaybillNumber()); + entity.setProductId(packageData.getProductId()); + entity.setProductName(packageData.getProductName()); + entity.setWeight(packageData.getWeight()); + entity.setVolume(packageData.getVolume()); + entity.setNum(packageData.getNumber()); + entity.setIncomingTime(operatorTime); + entity.setIncomingUserName(operator); + entity.setIncomingUserId(operatorId); + entity.setIncomingStatus(1); + entity.setIncomingType(packageData.getIncomingType()); + updateList.add(entity); + + } + + }); + + if(CollUtil.isNotEmpty(updateList)){ + reportPackageBasicService.updateBatchById(updateList); + } + + } + + private void deletePackageBasicData(Object main, String operator, Long operatorId, Date operatorTime, String warehouse, Long warehouseId) { + + List packageDataList = JSONUtil.toList(JSONUtil.toJsonStr(main), PackageData.class); + //把packageDataList中所有元素的orderPackageCode放入一个List + List packageCodes = packageDataList.stream().map(PackageData::getPackageCode).collect(java.util.stream.Collectors.toList()); + + reportPackageBasicService.deleteByOrderPackageCodes(packageCodes); + + } + + private void savePackageBasicData(Object main, String operator, Long operatorId, Date operatorTime, String warehouse, Long warehouseId) { + + List packageDataList = JSONUtil.toList(JSONUtil.toJsonStr(main), PackageData.class); + //把advanceDetailEntityList中所有元素的orderPackageCode放入一个List +// List packageCodes = advanceDetailEntityList.stream().map(TrunklineAdvanceDetailEntity::getOrderPackageCode).collect(java.util.stream.Collectors.toList()); +// List hasReportPackageBasicEntityList = reportPackageBasicService.findOrderPackageCodeListByPackageCodes(packageCodes); +// //把hasReportPackageBasicEntityList转换为以orderPackageCode为key的Map +// Map map = hasReportPackageBasicEntityList.stream() +// .collect(Collectors.toMap( +// ReportPackageBasicEntity::getOrderPackageCode, // key +// entity -> entity)); // value + + List addList = new ArrayList<>(); + packageDataList.forEach(entity -> { + + ReportPackageBasicEntity reportPackageBasicEntity = new ReportPackageBasicEntity(); + reportPackageBasicEntity.setServiceNo(entity.getServiceNo()); + reportPackageBasicEntity.setOrderCode(entity.getOrderCode()); + reportPackageBasicEntity.setOrderPackageCode(entity.getPackageCode()); + reportPackageBasicEntity.setMergePackageCode(entity.getMergePackageCode()); + reportPackageBasicEntity.setNum(entity.getNumber()); + reportPackageBasicEntity.setWeight(entity.getWeight()); + reportPackageBasicEntity.setVolume(entity.getVolume()); + reportPackageBasicEntity.setMaterialId(entity.getMaterialId()); + reportPackageBasicEntity.setMaterialCode(entity.getMaterialCode()); + reportPackageBasicEntity.setMaterialName(entity.getMaterialName()); + reportPackageBasicEntity.setDealerCode(entity.getDealerCode()); + reportPackageBasicEntity.setDealerName(entity.getDealerName()); + reportPackageBasicEntity.setPushUserId(operatorId); + reportPackageBasicEntity.setPushUserName(operator); + reportPackageBasicEntity.setPushTime(operatorTime); + reportPackageBasicEntity.setDataType(entity.getPackageType().getCode()); + reportPackageBasicEntity.setSystemType(entity.getSystemType()); + reportPackageBasicEntity.setCustomerTrain(entity.getCustomerTrain()); + reportPackageBasicEntity.setBrandId(entity.getBrandId()); + reportPackageBasicEntity.setBrand(entity.getBrand()); + reportPackageBasicEntity.setWarehouse(warehouse); + reportPackageBasicEntity.setWarehouseId(warehouseId); + addList.add(reportPackageBasicEntity); + }); + if(CollUtil.isNotEmpty(addList)){ + reportPackageBasicService.saveBatch(addList); + } + } + +} diff --git a/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/mq/report/CarsLoadDealListener.java b/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/mq/report/CarsLoadDealListener.java new file mode 100644 index 000000000..156410367 --- /dev/null +++ b/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/mq/report/CarsLoadDealListener.java @@ -0,0 +1,251 @@ +package com.logpm.trunkline.mq.report; + +import cn.hutool.core.collection.CollUtil; +import cn.hutool.core.util.NumberUtil; +import cn.hutool.json.JSONArray; +import cn.hutool.json.JSONObject; +import cn.hutool.json.JSONUtil; +import com.logpm.trunkline.entity.ReportPackageBasicEntity; +import com.logpm.trunkline.entity.ReportPackageTrunklineEntity; +import com.logpm.trunkline.entity.TrunklineCarsLoadEntity; +import com.logpm.trunkline.service.IReportPackageBasicService; +import com.logpm.trunkline.service.IReportPackageTrunklineService; +import lombok.AllArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springblade.common.constant.WorkNodeEnums; +import org.springblade.common.constant.broadcast.FanoutConstants; +import org.springblade.common.enums.BizOperationEnums; +import org.springblade.common.model.NodeFanoutMsg; +import org.springblade.common.model.PackageData; +import org.springblade.core.tool.utils.StringUtil; +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.stereotype.Component; +import org.springframework.transaction.annotation.Transactional; + +import java.util.ArrayList; +import java.util.Date; +import java.util.List; +import java.util.Map; +import java.util.function.Function; +import java.util.stream.Collectors; + +@Slf4j +@Component +@AllArgsConstructor +public class CarsLoadDealListener { + + private final IReportPackageBasicService reportPackageBasicService; + private final IReportPackageTrunklineService reportPackageTrunklineService; + + + + @RabbitListener(bindings = @QueueBinding( + value = @Queue(name = FanoutConstants.trunkline.CARSLOADDATA.QUEUE.REPORT_CARSLOADDATA), + exchange = @Exchange(name = FanoutConstants.trunkline.CARSLOADDATA.EXCHANGE, type = ExchangeTypes.FANOUT) + )) + @Transactional(rollbackFor = Exception.class) + public void carsLoadDeal(String msg) { + String method = "####################carsLoadDeal: "; + + if(StringUtil.isNotBlank(msg)){ + + NodeFanoutMsg bean = JSONUtil.toBean(msg, NodeFanoutMsg.class); + WorkNodeEnums node = bean.getNode(); + BizOperationEnums bizOperation = bean.getBizOperation(); + String operator = bean.getOperator(); + Long operatorId = bean.getOperatorId(); + Date operatorTime = bean.getOperatorTime(); + String warehouse = bean.getWarehouse(); + Long warehouseId = bean.getWarehouseId(); + Object main = bean.getMain(); + + if(WorkNodeEnums.INITIAL_WAREHOUSE_DEPART.equals(node) || WorkNodeEnums.TRANSFER_WAREHOUSE_DEPART.equals(node)){ + if(BizOperationEnums.ADD.equals(bizOperation)){ + savePackageCarsLoadData(main, operator, operatorId,operatorTime,warehouse,warehouseId); + }else if(BizOperationEnums.DELETE.equals(bizOperation)){ + + }else if(BizOperationEnums.MODIFY.equals(bizOperation)){ + + }else{ + log.warn(method+"未知的操作类型"); + } + }else if(WorkNodeEnums.CANCEL_INITIAL_WAREHOUSE_DEPART.equals(node) || WorkNodeEnums.CANEL_TRANSFER_WAREHOUSE_DEPART.equals(node)){ + if(BizOperationEnums.ADD.equals(bizOperation)){ + + }else if(BizOperationEnums.DELETE.equals(bizOperation)){ + deleteCarsLoadData(main, operator, operatorId,operatorTime,warehouse,warehouseId); + }else if(BizOperationEnums.MODIFY.equals(bizOperation)){ + + }else{ + log.warn(method+"未知的操作类型"); + } + }else { + log.warn(method+"未知的节点类型"); + } + + } + + } + + private void deleteCarsLoadData(Object main, String operator, Long operatorId, Date operatorTime, String warehouse, Long warehouseId) { + String method = "####################deleteCarsLoadData: "; + + JSONObject js = JSONUtil.toBean(JSONUtil.toJsonStr(main), JSONObject.class); + + TrunklineCarsLoadEntity carsLoadEntity = JSONUtil.toBean(js, TrunklineCarsLoadEntity.class); + + String carsNo = carsLoadEntity.getCarsNo(); + + reportPackageTrunklineService.deleteListByCarsNoAndWarehouseId(carsNo, warehouseId); + + + } + + + private void savePackageCarsLoadData(Object main, String operator, Long operatorId, Date operatorTime, String warehouse, Long warehouseId) { + + String method = "####################savePackageCarsLoadData: "; + + JSONObject js = JSONUtil.toBean(JSONUtil.toJsonStr(main), JSONObject.class); + + JSONArray details = js.getJSONArray("details"); + + List packageDataList = JSONUtil.toList(details, PackageData.class); + //把packageDataList通过packageType的code进行分组 + Map> packageTypeEnumsListMap = packageDataList.stream().collect(Collectors.groupingBy(t->t.getPackageType().getCode())); + + + TrunklineCarsLoadEntity carsLoadEntity = JSONUtil.toBean(js, TrunklineCarsLoadEntity.class); + + + List addList = new ArrayList<>(); + packageTypeEnumsListMap.keySet().forEach(packageTypeCode -> { + List packageDataListByPackageType = packageTypeEnumsListMap.get(packageTypeCode); + if(NumberUtil.equals(packageTypeCode,1)){ + //把packageDataListByPackageType中所有元素的orderPackageCode放入一个List + List packageCodes = packageDataListByPackageType.stream().map(PackageData::getPackageCode).collect(java.util.stream.Collectors.toList()); + //把packageDataListByPackageType转化成以orderPackageCode为key的Map + Map packageDataMap = packageDataListByPackageType.stream().collect(Collectors.toMap(PackageData::getPackageCode, Function.identity())); + + List packageBasicEntityList = reportPackageBasicService.findByOrderPackageCodes(packageCodes); + packageBasicEntityList.forEach(entity -> { + ReportPackageTrunklineEntity reportPackageTrunklineEntity = new ReportPackageTrunklineEntity(); + reportPackageTrunklineEntity.setBasicId(entity.getId()); + reportPackageTrunklineEntity.setLoadNo(carsLoadEntity.getCarsNo()); + reportPackageTrunklineEntity.setWaybillNo(entity.getWaybillNo()); + reportPackageTrunklineEntity.setServiceNo(entity.getServiceNo()); + reportPackageTrunklineEntity.setOrderCode(entity.getOrderCode()); + String orderPackageCode = entity.getOrderPackageCode(); + PackageData packageData = packageDataMap.get(orderPackageCode); + + reportPackageTrunklineEntity.setOrderPackageCode(orderPackageCode); + reportPackageTrunklineEntity.setProductName(entity.getProductName()); + reportPackageTrunklineEntity.setProductId(entity.getProductId()); + reportPackageTrunklineEntity.setBrand(entity.getBrand()); + reportPackageTrunklineEntity.setBrandId(entity.getBrandId()); + Long departureWarehouseId = entity.getDepartureWarehouseId(); + reportPackageTrunklineEntity.setDepartureWarehouseId(departureWarehouseId); + reportPackageTrunklineEntity.setDepartureWarehouseName(entity.getDepartureWarehouseName()); + Long destinationWarehouseId = entity.getDestinationWarehouseId(); + reportPackageTrunklineEntity.setDestinationWarehouseId(destinationWarehouseId); + reportPackageTrunklineEntity.setDestinationWarehouseName(entity.getDestinationWarehouseName()); + reportPackageTrunklineEntity.setLoadingWarehouseId(warehouseId); + reportPackageTrunklineEntity.setLoadingWarehouseName(warehouse); + reportPackageTrunklineEntity.setLoadingUserId(operatorId); + reportPackageTrunklineEntity.setLoadingUserName(operator); + reportPackageTrunklineEntity.setFinalNodeId(packageData.getFinalNodeId()); + reportPackageTrunklineEntity.setFinalNodeName(packageData.getFinalNodeName()); + + reportPackageTrunklineEntity.setIsStartWarehouse(0); + if(warehouseId.equals(departureWarehouseId)){ + reportPackageTrunklineEntity.setIsStartWarehouse(1); + } + reportPackageTrunklineEntity.setIsEndWarehouse(0); + if(warehouseId.equals(destinationWarehouseId)){ + reportPackageTrunklineEntity.setIsEndWarehouse(1); + } + reportPackageTrunklineEntity.setTrunklineStatus(1); + reportPackageTrunklineEntity.setIsCustomer(0); + reportPackageTrunklineEntity.setLoadingNum(entity.getNum()); + reportPackageTrunklineEntity.setUnloadNum(0); + reportPackageTrunklineEntity.setSignNum(0); + addList.add(reportPackageTrunklineEntity); + }); + + }else if(NumberUtil.equals(packageTypeCode,2)){ + //把packageDataListByPackageType中所有元素的orderCode放入一个List + List orderCodeList = packageDataListByPackageType.stream().map(PackageData::getOrderCode).collect(java.util.stream.Collectors.toList()); + List packageBasicEntityList = reportPackageBasicService.findListByOrderCodeList(orderCodeList); + //把packageBasicEntityList通过orderCode进行分组 + Map> packageBasicEntityListMap = packageBasicEntityList.stream().collect(Collectors.groupingBy(ReportPackageBasicEntity::getOrderCode)); + + //把packageDataListByPackageType通过orderCode进行分组 + Map> packageDataListMap = packageDataListByPackageType.stream().collect(Collectors.groupingBy(PackageData::getOrderCode)); + packageDataListMap.keySet().forEach(orderCode -> { + List packageDataList1 = packageDataListMap.get(orderCode); + List packageBasicEntities = packageBasicEntityListMap.get(orderCode); + //把packageBasicEntities转化成以productName为key的Map + Map packageBasicEntityMap = packageBasicEntities.stream().collect(Collectors.toMap(ReportPackageBasicEntity::getProductName, Function.identity())); + + packageDataList1.forEach(packageData1 -> { + String productName = packageData1.getProductName(); + ReportPackageBasicEntity packageBasicEntity = packageBasicEntityMap.get(productName); + + ReportPackageTrunklineEntity reportPackageTrunklineEntity = new ReportPackageTrunklineEntity(); + reportPackageTrunklineEntity.setBasicId(packageBasicEntity.getId()); + reportPackageTrunklineEntity.setLoadNo(carsLoadEntity.getCarsNo()); + reportPackageTrunklineEntity.setWaybillNo(packageBasicEntity.getWaybillNo()); + reportPackageTrunklineEntity.setServiceNo(packageBasicEntity.getServiceNo()); + reportPackageTrunklineEntity.setOrderCode(packageBasicEntity.getOrderCode()); + + reportPackageTrunklineEntity.setOrderPackageCode(packageBasicEntity.getOrderPackageCode()); + reportPackageTrunklineEntity.setProductName(packageBasicEntity.getProductName()); + reportPackageTrunklineEntity.setProductId(packageBasicEntity.getProductId()); + reportPackageTrunklineEntity.setBrand(packageBasicEntity.getBrand()); + reportPackageTrunklineEntity.setBrandId(packageBasicEntity.getBrandId()); + Long departureWarehouseId = packageBasicEntity.getDepartureWarehouseId(); + reportPackageTrunklineEntity.setDepartureWarehouseId(departureWarehouseId); + reportPackageTrunklineEntity.setDepartureWarehouseName(packageBasicEntity.getDepartureWarehouseName()); + Long destinationWarehouseId = packageBasicEntity.getDestinationWarehouseId(); + reportPackageTrunklineEntity.setDestinationWarehouseId(destinationWarehouseId); + reportPackageTrunklineEntity.setDestinationWarehouseName(packageBasicEntity.getDestinationWarehouseName()); + reportPackageTrunklineEntity.setLoadingWarehouseId(warehouseId); + reportPackageTrunklineEntity.setLoadingWarehouseName(warehouse); + reportPackageTrunklineEntity.setLoadingUserId(operatorId); + reportPackageTrunklineEntity.setLoadingUserName(operator); + reportPackageTrunklineEntity.setFinalNodeId(packageData1.getFinalNodeId()); + reportPackageTrunklineEntity.setFinalNodeName(packageData1.getFinalNodeName()); + + reportPackageTrunklineEntity.setIsStartWarehouse(0); + if(warehouseId.equals(departureWarehouseId)){ + reportPackageTrunklineEntity.setIsStartWarehouse(1); + } + reportPackageTrunklineEntity.setIsEndWarehouse(0); + if(warehouseId.equals(destinationWarehouseId)){ + reportPackageTrunklineEntity.setIsEndWarehouse(1); + } + reportPackageTrunklineEntity.setTrunklineStatus(1); + reportPackageTrunklineEntity.setIsCustomer(0); + reportPackageTrunklineEntity.setLoadingNum(packageData1.getNumber()); + reportPackageTrunklineEntity.setUnloadNum(0); + reportPackageTrunklineEntity.setSignNum(0); + addList.add(reportPackageTrunklineEntity); + }); + + }); + + + } + }); + + if(CollUtil.isNotEmpty(addList)){ + reportPackageTrunklineService.saveBatch(addList); + } + } + + +} diff --git a/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/IReportPackageBasicService.java b/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/IReportPackageBasicService.java new file mode 100644 index 000000000..cb55e34cf --- /dev/null +++ b/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/IReportPackageBasicService.java @@ -0,0 +1,22 @@ +package com.logpm.trunkline.service; + +import com.logpm.trunkline.entity.ReportPackageBasicEntity; +import org.springblade.core.mp.base.BaseService; + +import java.util.List; + +public interface IReportPackageBasicService extends BaseService { + List findOrderPackageCodeListByPackageCodes(List packageCodes); + + void deleteByOrderPackageCodes(List packageCodes); + + List findByOrderPackageCodes(List packageCodes); + + List findListByWaybillNo(String waybillNo); + + void deleteByIds(List ids); + + List findListByOrderCode(String orderCode); + + List findListByOrderCodeList(List orderCodeList); +} diff --git a/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/IReportPackageTrunklineService.java b/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/IReportPackageTrunklineService.java new file mode 100644 index 000000000..9475e25be --- /dev/null +++ b/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/IReportPackageTrunklineService.java @@ -0,0 +1,8 @@ +package com.logpm.trunkline.service; + +import com.logpm.trunkline.entity.ReportPackageTrunklineEntity; +import org.springblade.core.mp.base.BaseService; + +public interface IReportPackageTrunklineService extends BaseService { + void deleteListByCarsNoAndWarehouseId(String carsNo, Long warehouseId); +} 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 e84d08474..8cb1aae86 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 @@ -115,4 +115,6 @@ public interface ITrunklineAdvanceDetailService extends BaseService findAllUnloadData(); void updateSyncUnloadDataStatus(Integer id, int status); + + List findListByWaybillId(Long waybillId); } diff --git a/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/impl/CarsLoadAsyncServiceImpl.java b/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/impl/CarsLoadAsyncServiceImpl.java index 723b4a8e9..5ee9335a5 100644 --- a/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/impl/CarsLoadAsyncServiceImpl.java +++ b/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/impl/CarsLoadAsyncServiceImpl.java @@ -713,9 +713,15 @@ public class CarsLoadAsyncServiceImpl implements ICarsLoadAsyncService { .eq("scan_status", "1"); List carsLoadScanEntityList = trunklineCarsLoadScanService.list(queryWrapper); + Long startWarehouseId = carsLoadEntity.getStartWarehouseId(); + NodeFanoutMsg nodeFanoutMsg = new NodeFanoutMsg(); - nodeFanoutMsg.setNode(WorkNodeEnums.INITIAL_WAREHOUSE_DEPART); + if(startWarehouseId.equals(warehouseId)){ + nodeFanoutMsg.setNode(WorkNodeEnums.INITIAL_WAREHOUSE_DEPART); + }else{ + nodeFanoutMsg.setNode(WorkNodeEnums.TRANSFER_WAREHOUSE_DEPART); + } nodeFanoutMsg.setBizOperation(BizOperationEnums.ADD); nodeFanoutMsg.setOperator(nickName); nodeFanoutMsg.setOperatorId(userId); @@ -744,6 +750,8 @@ public class CarsLoadAsyncServiceImpl implements ICarsLoadAsyncService { packageData.setWaybillNumber(entity.getWaybillNo()); packageData.setNumber(entity.getNum()); packageData.setPackageType(PackageTypeEnums.CMP); + packageData.setFinalNodeId(entity.getFinalNodeId()); + packageData.setFinalNodeName(entity.getFinalNodeName()); packageDataList.add(packageData); }); @@ -765,6 +773,8 @@ public class CarsLoadAsyncServiceImpl implements ICarsLoadAsyncService { packageData.setWaybillNumber(carsLoadScanEntity.getWaybillNo()); packageData.setProductId(zeroDetailVO.getGoodsId()); packageData.setProductName(zeroDetailVO.getGoodsName()); + packageData.setFinalNodeId(carsLoadScanEntity.getFinalNodeId()); + packageData.setFinalNodeName(carsLoadScanEntity.getFinalNodeName()); packageDataList.add(packageData); }); @@ -777,7 +787,7 @@ public class CarsLoadAsyncServiceImpl implements ICarsLoadAsyncService { json.put("details", packageDataList); nodeFanoutMsg.setMain(json); - FanoutMsg fanoutMsg = FanoutMsg.builder().exchange(FanoutConstants.trunkline.REPORTDATA.EXCHANGE).msg(JSONObject.toJSONString(nodeFanoutMsg)).build(); + FanoutMsg fanoutMsg = FanoutMsg.builder().exchange(FanoutConstants.trunkline.CARSLOADDATA.EXCHANGE).msg(JSONObject.toJSONString(nodeFanoutMsg)).build(); sendFanoutService.sendFanoutMsg(fanoutMsg); } @@ -794,7 +804,12 @@ public class CarsLoadAsyncServiceImpl implements ICarsLoadAsyncService { NodeFanoutMsg nodeFanoutMsg = new NodeFanoutMsg(); - nodeFanoutMsg.setNode(WorkNodeEnums.CANCEL_INITIAL_WAREHOUSE_DEPART); + Long startWarehouseId = carsLoadEntity.getStartWarehouseId(); + if(warehouseId.equals(startWarehouseId)){ + nodeFanoutMsg.setNode(WorkNodeEnums.CANCEL_INITIAL_WAREHOUSE_DEPART); + }else{ + nodeFanoutMsg.setNode(WorkNodeEnums.CANEL_TRANSFER_WAREHOUSE_DEPART); + } nodeFanoutMsg.setBizOperation(BizOperationEnums.DELETE); nodeFanoutMsg.setOperator(nickName); nodeFanoutMsg.setOperatorId(userId); diff --git a/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/impl/ReportPackageBasicServiceImpl.java b/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/impl/ReportPackageBasicServiceImpl.java new file mode 100644 index 000000000..2c3785f77 --- /dev/null +++ b/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/impl/ReportPackageBasicServiceImpl.java @@ -0,0 +1,56 @@ +package com.logpm.trunkline.service.impl; + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.logpm.trunkline.entity.ReportPackageBasicEntity; +import com.logpm.trunkline.mapper.ReportPackageBasicMapper; +import com.logpm.trunkline.service.IReportPackageBasicService; +import lombok.AllArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springblade.core.mp.base.BaseServiceImpl; +import org.springframework.stereotype.Service; + +import java.util.Collections; +import java.util.List; + +@Service +@AllArgsConstructor +@Slf4j +public class ReportPackageBasicServiceImpl extends BaseServiceImpl implements IReportPackageBasicService { + @Override + public List findOrderPackageCodeListByPackageCodes(List packageCodes) { + QueryWrapper queryWrapper = new QueryWrapper<>(); + queryWrapper.in("order_package_code", packageCodes); + + return baseMapper.selectList(queryWrapper); + } + + @Override + public void deleteByOrderPackageCodes(List packageCodes) { + baseMapper.deleteByOrderPackageCodes(packageCodes); + } + + @Override + public List findByOrderPackageCodes(List packageCodes) { + return baseMapper.findByOrderPackageCodes(packageCodes); + } + + @Override + public List findListByWaybillNo(String waybillNo) { + return baseMapper.findListByWaybillNo(waybillNo); + } + + @Override + public void deleteByIds(List ids) { + baseMapper.deleteByIds(ids); + } + + @Override + public List findListByOrderCode(String orderCode) { + return baseMapper.findListByOrderCode(orderCode); + } + + @Override + public List findListByOrderCodeList(List orderCodeList) { + return baseMapper.findListByOrderCodeList(orderCodeList); + } +} diff --git a/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/impl/ReportPackageTrunklineServiceImpl.java b/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/impl/ReportPackageTrunklineServiceImpl.java new file mode 100644 index 000000000..9b8a699d3 --- /dev/null +++ b/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/impl/ReportPackageTrunklineServiceImpl.java @@ -0,0 +1,19 @@ +package com.logpm.trunkline.service.impl; + +import com.logpm.trunkline.entity.ReportPackageTrunklineEntity; +import com.logpm.trunkline.mapper.ReportPackageTrunklineMapper; +import com.logpm.trunkline.service.IReportPackageTrunklineService; +import lombok.AllArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springblade.core.mp.base.BaseServiceImpl; +import org.springframework.stereotype.Service; + +@Service +@AllArgsConstructor +@Slf4j +public class ReportPackageTrunklineServiceImpl extends BaseServiceImpl implements IReportPackageTrunklineService { + @Override + public void deleteListByCarsNoAndWarehouseId(String carsNo, Long warehouseId) { + baseMapper.deleteListByCarsNoAndWarehouseId(carsNo,warehouseId); + } +} 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 ea7b1a445..f51a50949 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 @@ -299,9 +299,67 @@ public class TrunklineAdvanceDetailServiceImpl extends BaseServiceImpl deleteList) { + String key = AuthUtil.getTenantId()+":brandList"; + + Map brandMap = bladeRedis.hGetAll(key); + + if(CollUtil.isEmpty(brandMap)){ + List allList = basicdataBrandClient.findAllList(); + Map brandIdMap = new HashMap<>(); + allList.forEach(jsonObject -> { + brandIdMap.put(jsonObject.getString("brandName"),jsonObject.getLong("brandId")); + }); + brandMap.putAll(brandIdMap); + } + + NodeFanoutMsg nodeFanoutMsg = new NodeFanoutMsg(); + nodeFanoutMsg.setNode(WorkNodeEnums.INITIAL_DATA_ENTRY); + nodeFanoutMsg.setBizOperation(BizOperationEnums.DELETE); + nodeFanoutMsg.setOperator(nickName); + nodeFanoutMsg.setOperatorId(userId); + nodeFanoutMsg.setWarehouse(warehouseName); + nodeFanoutMsg.setWarehouseId(warehouseId); + nodeFanoutMsg.setOperatorTime(date); + + //组装包件数据 + List packageDataList = new ArrayList<>(); + deleteList.forEach(detailEntity -> { + PackageData packageData = new PackageData(); + packageData.setPackageCode(detailEntity.getOrderPackageCode()); + packageData.setOrderCode(detailEntity.getOrderCode()); + packageData.setServiceNo(detailEntity.getServiceNum()); + packageData.setMaterialId(detailEntity.getMaterialId()); + packageData.setMaterialCode(detailEntity.getMaterialCode()); + packageData.setMaterialName(detailEntity.getMaterialName()); + packageData.setNumber(detailEntity.getQuantity()); + packageData.setWeight(detailEntity.getWeight()); + packageData.setVolume(detailEntity.getVolume()); + packageData.setPackageType(PackageTypeEnums.CMP); + packageData.setCustomerTrain(detailEntity.getTrainNumber()); + String brand = detailEntity.getBrand(); + packageData.setBrandId(brandMap.get(brand)); + packageData.setBrandName(brand); + packageData.setSystemType(detailEntity.getSystemType()); + packageDataList.add(packageData); + }); + nodeFanoutMsg.setMain(packageDataList); + + FanoutMsg fanoutMsg = FanoutMsg.builder().exchange(FanoutConstants.trunkline.REPORTDATA.EXCHANGE).msg(JSONObject.toJSONString(nodeFanoutMsg)).build(); + + sendFanoutService.sendFanoutMsg(fanoutMsg); + + } + @Override public Integer findTotalNumByOrderCode(String orderCode) { return baseMapper.findTotalNumByOrderCode(orderCode); @@ -594,6 +652,8 @@ public class TrunklineAdvanceDetailServiceImpl extends BaseServiceImpl findListByWaybillId(Long waybillId) { + return baseMapper.findListByWaybillId(waybillId); + } } 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 e4822f3c3..6faef99c6 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 @@ -686,6 +686,8 @@ public class TrunklineAdvanceServiceImpl extends BaseServiceImpl