From 6d137d9620c355f4862c4a0bfbb83e4329fabdfd Mon Sep 17 00:00:00 2001 From: zhaoqiaobo Date: Mon, 3 Jun 2024 14:56:37 +0800 Subject: [PATCH] =?UTF-8?q?feat(all):=20=E5=A2=9E=E5=8A=A0=E6=9E=97?= =?UTF-8?q?=E6=B0=8F=E5=B7=A5=E5=8E=82=E6=95=B0=E6=8D=AE=E6=8E=A5=E6=94=B6?= =?UTF-8?q?=E5=92=8C=E6=95=B0=E6=8D=AE=E5=9B=9E=E6=8E=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../common/constant/WorkNodeEnums.java | 9 + .../trunkline/dto/CancelOrderParamVO.java | 24 ++ .../feign/ITrunklineAdvanceClient.java | 4 + .../{src => }/Dockerfile | 0 .../linsy/controller/OrderController.java | 29 +- .../linsy/entity/FactoryNodePushEntity.java | 74 +++++ .../linsy/entity/PackageInfoEntity.java | 4 + .../linsy/enums/FactoryNodeEnums.java | 51 ++++ .../linsy/enums/NodeMappingEnums.java | 62 ++++ .../linsy/enums/NodeNeedEnums.java | 34 +++ .../linsy/enums/PushStatusEnums.java | 27 -- .../linsy/mapper/FactoryNodePushMapper.java | 16 + .../linsy/mapper/FactoryNodePushMapper.xml | 5 + .../linsy/mq/FactoryOrderListener.java | 20 +- .../linsy/mq/NodeDataPushListener.java | 247 +++++++++++++++ .../linsy/pros/LinsyProperties.java | 40 +++ .../linsy/service/DeliveryNoteService.java | 2 + .../linsy/service/FactoryNodePushService.java | 15 + .../linsy/service/FactoryOrderLogService.java | 1 - .../service/impl/DeliveryNoteServiceImpl.java | 13 + .../impl/FactoryNodePushServiceImpl.java | 22 ++ .../impl/FactoryOrderLogServiceImpl.java | 12 +- .../olo/enums/FactoryNodeEnums.java | 2 +- .../zbom/entity/ZbFactoryNodePushEntity.java | 5 + .../entity/ZbFactoryNodePushFailEntity.java | 5 + .../logpm/trunkline/dto/LoadScanBrandDTO.java | 8 + .../feign/TrunklineAdvanceClient.java | 6 + .../mapper/TrunklineCarsLoadMapper.xml | 6 +- .../service/ITrunklineAdvanceService.java | 2 + .../service/impl/InComingServiceImpl.java | 18 +- .../impl/TrunklineAdvanceServiceImpl.java | 280 ++++++++++-------- .../impl/TrunklineCarsLoadServiceImpl.java | 30 +- 32 files changed, 858 insertions(+), 215 deletions(-) create mode 100644 blade-service-api/logpm-trunkline-api/src/main/java/com/logpm/trunkline/dto/CancelOrderParamVO.java rename blade-service/logpm-factory-data/logpm-factory-data-linsy/{src => }/Dockerfile (100%) create mode 100644 blade-service/logpm-factory-data/logpm-factory-data-linsy/src/main/java/com/logpm/factorydata/linsy/entity/FactoryNodePushEntity.java create mode 100644 blade-service/logpm-factory-data/logpm-factory-data-linsy/src/main/java/com/logpm/factorydata/linsy/enums/FactoryNodeEnums.java create mode 100644 blade-service/logpm-factory-data/logpm-factory-data-linsy/src/main/java/com/logpm/factorydata/linsy/enums/NodeMappingEnums.java create mode 100644 blade-service/logpm-factory-data/logpm-factory-data-linsy/src/main/java/com/logpm/factorydata/linsy/enums/NodeNeedEnums.java delete mode 100644 blade-service/logpm-factory-data/logpm-factory-data-linsy/src/main/java/com/logpm/factorydata/linsy/enums/PushStatusEnums.java create mode 100644 blade-service/logpm-factory-data/logpm-factory-data-linsy/src/main/java/com/logpm/factorydata/linsy/mapper/FactoryNodePushMapper.java create mode 100644 blade-service/logpm-factory-data/logpm-factory-data-linsy/src/main/java/com/logpm/factorydata/linsy/mapper/FactoryNodePushMapper.xml create mode 100644 blade-service/logpm-factory-data/logpm-factory-data-linsy/src/main/java/com/logpm/factorydata/linsy/mq/NodeDataPushListener.java create mode 100644 blade-service/logpm-factory-data/logpm-factory-data-linsy/src/main/java/com/logpm/factorydata/linsy/pros/LinsyProperties.java create mode 100644 blade-service/logpm-factory-data/logpm-factory-data-linsy/src/main/java/com/logpm/factorydata/linsy/service/FactoryNodePushService.java create mode 100644 blade-service/logpm-factory-data/logpm-factory-data-linsy/src/main/java/com/logpm/factorydata/linsy/service/impl/FactoryNodePushServiceImpl.java diff --git a/blade-biz-common/src/main/java/org/springblade/common/constant/WorkNodeEnums.java b/blade-biz-common/src/main/java/org/springblade/common/constant/WorkNodeEnums.java index d26ffc027..eb21e6291 100644 --- a/blade-biz-common/src/main/java/org/springblade/common/constant/WorkNodeEnums.java +++ b/blade-biz-common/src/main/java/org/springblade/common/constant/WorkNodeEnums.java @@ -68,4 +68,13 @@ public enum WorkNodeEnums implements Serializable { return null; } + public static WorkNodeEnums getByCode(Integer code){ + for (WorkNodeEnums value : WorkNodeEnums.values()) { + if (value.getCode().equals(code)) { + return value; + } + } + return null; + } + } diff --git a/blade-service-api/logpm-trunkline-api/src/main/java/com/logpm/trunkline/dto/CancelOrderParamVO.java b/blade-service-api/logpm-trunkline-api/src/main/java/com/logpm/trunkline/dto/CancelOrderParamVO.java new file mode 100644 index 000000000..c8a05102e --- /dev/null +++ b/blade-service-api/logpm-trunkline-api/src/main/java/com/logpm/trunkline/dto/CancelOrderParamVO.java @@ -0,0 +1,24 @@ +package com.logpm.trunkline.dto; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import javax.validation.constraints.NotEmpty; +import java.io.Serializable; + +/** + * 取消订单 实体类 + * + * @author zhaoqiaobo + * @create 2024-04-26 + */ +@Data +@ApiModel(value = "取消订单", description = "取消订单") +public class CancelOrderParamVO implements Serializable { + + @ApiModelProperty("订单编号") + @NotEmpty(message = "订单编号不能为空") + private String orderCode; + +} diff --git a/blade-service-api/logpm-trunkline-api/src/main/java/com/logpm/trunkline/feign/ITrunklineAdvanceClient.java b/blade-service-api/logpm-trunkline-api/src/main/java/com/logpm/trunkline/feign/ITrunklineAdvanceClient.java index cd2b5b9c9..fb3d19099 100644 --- a/blade-service-api/logpm-trunkline-api/src/main/java/com/logpm/trunkline/feign/ITrunklineAdvanceClient.java +++ b/blade-service-api/logpm-trunkline-api/src/main/java/com/logpm/trunkline/feign/ITrunklineAdvanceClient.java @@ -1,5 +1,6 @@ package com.logpm.trunkline.feign; +import com.logpm.trunkline.dto.CancelOrderParamVO; import com.logpm.trunkline.entity.TrunklineAdvanceEntity; import org.springblade.common.constant.ModuleNameConstant; import org.springframework.cloud.openfeign.FeignClient; @@ -25,4 +26,7 @@ public interface ITrunklineAdvanceClient { @PostMapping(API_PREFIX+"/findListByIds") List findListByIds(@RequestBody List collect); + + @PostMapping(API_PREFIX+"/cancelOrder") + Boolean cancelOrder(@RequestBody CancelOrderParamVO orderCode); } diff --git a/blade-service/logpm-factory-data/logpm-factory-data-linsy/src/Dockerfile b/blade-service/logpm-factory-data/logpm-factory-data-linsy/Dockerfile similarity index 100% rename from blade-service/logpm-factory-data/logpm-factory-data-linsy/src/Dockerfile rename to blade-service/logpm-factory-data/logpm-factory-data-linsy/Dockerfile diff --git a/blade-service/logpm-factory-data/logpm-factory-data-linsy/src/main/java/com/logpm/factorydata/linsy/controller/OrderController.java b/blade-service/logpm-factory-data/logpm-factory-data-linsy/src/main/java/com/logpm/factorydata/linsy/controller/OrderController.java index bfb407caf..cf6b9426f 100644 --- a/blade-service/logpm-factory-data/logpm-factory-data-linsy/src/main/java/com/logpm/factorydata/linsy/controller/OrderController.java +++ b/blade-service/logpm-factory-data/logpm-factory-data-linsy/src/main/java/com/logpm/factorydata/linsy/controller/OrderController.java @@ -1,6 +1,5 @@ package com.logpm.factorydata.linsy.controller; -import cn.hutool.core.bean.BeanUtil; import cn.hutool.json.JSONUtil; import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; import com.logpm.factorydata.linsy.service.DeliveryNoteService; @@ -11,20 +10,17 @@ import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import lombok.AllArgsConstructor; import lombok.extern.slf4j.Slf4j; -import org.apache.ibatis.annotations.Delete; +import org.springblade.common.constant.factorydata.FactoryDataConstants; import org.springblade.core.tool.api.R; -import org.springframework.web.bind.annotation.DeleteMapping; +import org.springframework.amqp.rabbit.core.RabbitTemplate; import org.springframework.web.bind.annotation.PatchMapping; import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.PutMapping; 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 java.util.List; import java.util.Map; -import java.util.stream.Collectors; /** * 工厂订单 前端控制器 @@ -40,6 +36,19 @@ import java.util.stream.Collectors; public class OrderController { private final FactoryOrderLogService service; + private final DeliveryNoteService deliveryNoteService; + private final RabbitTemplate rabbitTemplate; + + @ResponseBody + @PostMapping("sendMsg") + @ApiOperationSupport(order = 1) + @ApiOperation(value = "推送工厂订单", notes = "推送工厂订单") + public R sendMsg(@RequestBody Map vo) { + log.info("推送工厂订单:{} ", JSONUtil.toJsonStr(vo)); + rabbitTemplate.convertAndSend(FactoryDataConstants.Mq.Exchanges.NODE_DATA_PUSH, + FactoryDataConstants.Mq.RoutingKeys.LINSY_NODE_DATA_PUSH, JSONUtil.toJsonStr(vo)); + return R.success("成功"); + } @ResponseBody @PostMapping @@ -63,9 +72,11 @@ public class OrderController { @ApiOperation(value = "取消订单", notes = "取消订单") public R cancelOrder(@RequestBody CancelOrderVO vo) { log.info("取消订单:{} ", JSONUtil.toJsonStr(vo)); - String res = ""; - res = service.cancelOrder(vo); - return R.success(res); + Boolean res = deliveryNoteService.cancelOrder(vo); + if (res) { + return R.success("取消成功"); + } + return R.fail("该订单已作业,无法取消"); } } diff --git a/blade-service/logpm-factory-data/logpm-factory-data-linsy/src/main/java/com/logpm/factorydata/linsy/entity/FactoryNodePushEntity.java b/blade-service/logpm-factory-data/logpm-factory-data-linsy/src/main/java/com/logpm/factorydata/linsy/entity/FactoryNodePushEntity.java new file mode 100644 index 000000000..c9c8fc047 --- /dev/null +++ b/blade-service/logpm-factory-data/logpm-factory-data-linsy/src/main/java/com/logpm/factorydata/linsy/entity/FactoryNodePushEntity.java @@ -0,0 +1,74 @@ +package com.logpm.factorydata.linsy.entity; + +import com.baomidou.mybatisplus.annotation.TableName; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.NoArgsConstructor; +import org.springblade.core.mp.base.BaseEntity; + +/** + * 节点数据推送成功数据 + * + * @Author zqb + * @Date 2024/3/26 + **/ +@Builder +@Data +@TableName("linsy_factory_node_push") +@ApiModel(value = "节点数据推送成功数据", description = "节点数据推送成功数据") +@EqualsAndHashCode(callSuper = true) +@NoArgsConstructor +@AllArgsConstructor +public class FactoryNodePushEntity 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 billCode; + /** + * 节点 + */ + @ApiModelProperty(name = "节点", notes = "") + private String node; + /** + * 内容 + */ + @ApiModelProperty(name = "内容", notes = "") + private String content; + /** + * 返回值 + */ + @ApiModelProperty(name = "返回值", notes = "") + private String resultContent; + +} diff --git a/blade-service/logpm-factory-data/logpm-factory-data-linsy/src/main/java/com/logpm/factorydata/linsy/entity/PackageInfoEntity.java b/blade-service/logpm-factory-data/logpm-factory-data-linsy/src/main/java/com/logpm/factorydata/linsy/entity/PackageInfoEntity.java index 3f1598be9..b27f120fa 100644 --- a/blade-service/logpm-factory-data/logpm-factory-data-linsy/src/main/java/com/logpm/factorydata/linsy/entity/PackageInfoEntity.java +++ b/blade-service/logpm-factory-data/logpm-factory-data-linsy/src/main/java/com/logpm/factorydata/linsy/entity/PackageInfoEntity.java @@ -23,6 +23,10 @@ public class PackageInfoEntity extends BaseEntity { private String logId; @ApiModelProperty(value = "发货单id") private String deliveryNoteId; + @ApiModelProperty(value = "订单号") + private String orderCode; + @ApiModelProperty(value = "已推送节点编码") + private Integer workedNodeCode; @ApiModelProperty(value = "父项物料编码") private String parentMaterialCode; @ApiModelProperty(value = "父项物料名称") diff --git a/blade-service/logpm-factory-data/logpm-factory-data-linsy/src/main/java/com/logpm/factorydata/linsy/enums/FactoryNodeEnums.java b/blade-service/logpm-factory-data/logpm-factory-data-linsy/src/main/java/com/logpm/factorydata/linsy/enums/FactoryNodeEnums.java new file mode 100644 index 000000000..9b637d7a3 --- /dev/null +++ b/blade-service/logpm-factory-data/logpm-factory-data-linsy/src/main/java/com/logpm/factorydata/linsy/enums/FactoryNodeEnums.java @@ -0,0 +1,51 @@ +package com.logpm.factorydata.linsy.enums; + +import lombok.Getter; + +import java.util.ArrayList; +import java.util.List; + +/** + * 工厂节点枚举 + * + * @author zhaoqiaobo + * @create 2024-03-20 15:19 + */ +@Getter +public enum FactoryNodeEnums { + + /** + * 已交接 + */ + INITIAL_WAREHOUSE_ENTRY(20, "Deliveried", 1), + /** + * 收货完成 + */ + END_WAREHOUSE_UNLOADING(170, "Received", 1); + + private Integer code; + private String text; + private Integer mustPush; + + FactoryNodeEnums(Integer code, String text, Integer mustPush) { + this.code = code; + this.text = text; + this.mustPush = mustPush; + } + + /** + * 获取所有必推节点的编码 + * + * @return + */ + public static List getMustPushCode() { + List list = new ArrayList<>(); + for (FactoryNodeEnums value : FactoryNodeEnums.values()) { + if (value.getMustPush() == 1) { + list.add(value.getCode()); + } + } + return list; + } + +} diff --git a/blade-service/logpm-factory-data/logpm-factory-data-linsy/src/main/java/com/logpm/factorydata/linsy/enums/NodeMappingEnums.java b/blade-service/logpm-factory-data/logpm-factory-data-linsy/src/main/java/com/logpm/factorydata/linsy/enums/NodeMappingEnums.java new file mode 100644 index 000000000..068297675 --- /dev/null +++ b/blade-service/logpm-factory-data/logpm-factory-data-linsy/src/main/java/com/logpm/factorydata/linsy/enums/NodeMappingEnums.java @@ -0,0 +1,62 @@ +package com.logpm.factorydata.linsy.enums; + +import cn.hutool.core.util.ObjectUtil; +import lombok.Getter; +import org.springblade.common.constant.WorkNodeEnums; + +/** + * 系统和工厂节点映射枚举 + * + * @author zhaoqiaobo + * @create 2024-03-20 15:19 + */ +@Getter +public enum NodeMappingEnums { + + /** + * 已交接 + */ + INITIAL_WAREHOUSE_ENTRY(FactoryNodeEnums.INITIAL_WAREHOUSE_ENTRY, WorkNodeEnums.INITIAL_WAREHOUSE_ENTRY, 1), + /** + * 收货完成 + */ + END_WAREHOUSE_UNLOADING(FactoryNodeEnums.END_WAREHOUSE_UNLOADING, WorkNodeEnums.END_WAREHOUSE_UNLOADING, 1); + + /** + * 系统作业节点 + */ + private WorkNodeEnums workNodeEnums; + /** + * 工厂作业节点 + */ + private FactoryNodeEnums factoryNodeEnums; + /** + * 状态码 + * 存在我们系统同一个作业节点对应工厂多个节点的情况,通过状态码区分 + */ + private Integer status; + + NodeMappingEnums(FactoryNodeEnums factoryNodeEnums, WorkNodeEnums workNodeEnums, Integer status) { + this.workNodeEnums = workNodeEnums; + this.factoryNodeEnums = factoryNodeEnums; + this.status = status; + } + + public static FactoryNodeEnums getFactoryByNodeAndStatus(WorkNodeEnums workNodeEnums) { + return getFactoryByNodeAndStatus(workNodeEnums, 1); + } + + public static FactoryNodeEnums getFactoryByNodeAndStatus(WorkNodeEnums workNodeEnums, Integer status) { + NodeMappingEnums[] values = values(); + for (NodeMappingEnums value : values) { + WorkNodeEnums workNodeEnums1 = value.getWorkNodeEnums(); + Integer status1 = value.getStatus(); + FactoryNodeEnums factoryNodeEnums = value.getFactoryNodeEnums(); + if (ObjectUtil.equal(workNodeEnums1, workNodeEnums) && ObjectUtil.equal(status1, status)) { + return factoryNodeEnums; + } + } + return null; + } + +} diff --git a/blade-service/logpm-factory-data/logpm-factory-data-linsy/src/main/java/com/logpm/factorydata/linsy/enums/NodeNeedEnums.java b/blade-service/logpm-factory-data/logpm-factory-data-linsy/src/main/java/com/logpm/factorydata/linsy/enums/NodeNeedEnums.java new file mode 100644 index 000000000..f44f304e8 --- /dev/null +++ b/blade-service/logpm-factory-data/logpm-factory-data-linsy/src/main/java/com/logpm/factorydata/linsy/enums/NodeNeedEnums.java @@ -0,0 +1,34 @@ +package com.logpm.factorydata.linsy.enums; + +import lombok.Getter; + +import java.io.Serializable; + +/** + * 作业节点枚举 + * + * @author zhaoqiaobo + * @create 2024-03-20 15:19 + */ +@Getter +public enum NodeNeedEnums implements Serializable { + + /** + * 始发仓入库 + */ + INITIAL_WAREHOUSE_ENTRY(20, "始发仓入库"), + /** + * 末端仓卸车确认 + */ + END_WAREHOUSE_UNLOADING(170, "末端仓卸车确认"), + ; + + private Integer code; + private String value; + + NodeNeedEnums(Integer code, String value) { + this.code = code; + this.value = value; + } + +} diff --git a/blade-service/logpm-factory-data/logpm-factory-data-linsy/src/main/java/com/logpm/factorydata/linsy/enums/PushStatusEnums.java b/blade-service/logpm-factory-data/logpm-factory-data-linsy/src/main/java/com/logpm/factorydata/linsy/enums/PushStatusEnums.java deleted file mode 100644 index b50ecfddb..000000000 --- a/blade-service/logpm-factory-data/logpm-factory-data-linsy/src/main/java/com/logpm/factorydata/linsy/enums/PushStatusEnums.java +++ /dev/null @@ -1,27 +0,0 @@ -package com.logpm.factorydata.linsy.enums; - -import org.springblade.common.model.IDict; - -/** - * 回传状态码表 - * - * @author zhaoqiaobo - * @create 2024-04-01 - */ -public enum PushStatusEnums implements IDict { - - /** - * 已交接 - */ - DELIVERIED("Deliveried", "已交接"), - /** - * 收货完成 - */ - RECEIVED("Received", "收货完成"), - ; - - PushStatusEnums(String code, String text) { - init(code, text); - } - -} diff --git a/blade-service/logpm-factory-data/logpm-factory-data-linsy/src/main/java/com/logpm/factorydata/linsy/mapper/FactoryNodePushMapper.java b/blade-service/logpm-factory-data/logpm-factory-data-linsy/src/main/java/com/logpm/factorydata/linsy/mapper/FactoryNodePushMapper.java new file mode 100644 index 000000000..09fcc1606 --- /dev/null +++ b/blade-service/logpm-factory-data/logpm-factory-data-linsy/src/main/java/com/logpm/factorydata/linsy/mapper/FactoryNodePushMapper.java @@ -0,0 +1,16 @@ +package com.logpm.factorydata.linsy.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.logpm.factorydata.linsy.entity.FactoryNodePushEntity; +import org.apache.ibatis.annotations.Mapper; + +/** + * 装箱包信息 mapper + * + * @author zqb + * @since 2024-03-26 + */ +@Mapper +public interface FactoryNodePushMapper extends BaseMapper { + +} diff --git a/blade-service/logpm-factory-data/logpm-factory-data-linsy/src/main/java/com/logpm/factorydata/linsy/mapper/FactoryNodePushMapper.xml b/blade-service/logpm-factory-data/logpm-factory-data-linsy/src/main/java/com/logpm/factorydata/linsy/mapper/FactoryNodePushMapper.xml new file mode 100644 index 000000000..76ca06fd7 --- /dev/null +++ b/blade-service/logpm-factory-data/logpm-factory-data-linsy/src/main/java/com/logpm/factorydata/linsy/mapper/FactoryNodePushMapper.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/blade-service/logpm-factory-data/logpm-factory-data-linsy/src/main/java/com/logpm/factorydata/linsy/mq/FactoryOrderListener.java b/blade-service/logpm-factory-data/logpm-factory-data-linsy/src/main/java/com/logpm/factorydata/linsy/mq/FactoryOrderListener.java index 8d8b983c9..1aae21e23 100644 --- a/blade-service/logpm-factory-data/logpm-factory-data-linsy/src/main/java/com/logpm/factorydata/linsy/mq/FactoryOrderListener.java +++ b/blade-service/logpm-factory-data/logpm-factory-data-linsy/src/main/java/com/logpm/factorydata/linsy/mq/FactoryOrderListener.java @@ -2,23 +2,15 @@ package com.logpm.factorydata.linsy.mq; import cn.hutool.core.bean.BeanUtil; import cn.hutool.core.collection.CollUtil; -import cn.hutool.core.convert.Convert; -import cn.hutool.core.date.DateUtil; import cn.hutool.core.io.FileUtil; import cn.hutool.core.util.CharsetUtil; -import cn.hutool.core.util.NumberUtil; import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.StrUtil; import cn.hutool.core.util.URLUtil; import cn.hutool.json.JSONConfig; -import cn.hutool.json.JSONObject; import cn.hutool.json.JSONUtil; import com.baomidou.mybatisplus.core.toolkit.Wrappers; -import com.logpm.factorydata.base.feign.IFactoryDataBaseClient; -import com.logpm.factorydata.base.vo.FactoryWarehouseBindVO; -import com.logpm.factorydata.enums.BrandEnums; import com.logpm.factorydata.enums.SaxStatusEnums; -import com.logpm.factorydata.feign.IFactoryDataClient; import com.logpm.factorydata.linsy.entity.DeliveryNoteEntity; import com.logpm.factorydata.linsy.entity.FactoryOrderLogEntity; import com.logpm.factorydata.linsy.entity.PackageInfoEntity; @@ -27,16 +19,9 @@ import com.logpm.factorydata.linsy.service.FactoryOrderLogService; import com.logpm.factorydata.linsy.service.PackageInfoService; import com.logpm.factorydata.linsy.vo.DeliveryNoteVO; import com.logpm.factorydata.linsy.vo.PackageInfoVO; -import com.logpm.factorydata.vo.SendMsg; -import com.logpm.trunkline.entity.TrunklineAdvanceDetailEntity; -import com.logpm.trunkline.entity.TrunklineAdvanceEntity; import lombok.AllArgsConstructor; 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.redis.cache.BladeRedis; -import org.springblade.core.tool.api.R; import org.springframework.amqp.core.ExchangeTypes; import org.springframework.amqp.rabbit.annotation.Exchange; import org.springframework.amqp.rabbit.annotation.Queue; @@ -45,12 +30,8 @@ import org.springframework.amqp.rabbit.annotation.RabbitListener; import org.springframework.stereotype.Component; import org.springframework.transaction.annotation.Transactional; -import java.math.BigDecimal; -import java.time.LocalDateTime; import java.util.ArrayList; -import java.util.HashMap; import java.util.List; -import java.util.Map; /** * 监听订单数据 @@ -123,6 +104,7 @@ public class FactoryOrderListener { BeanUtil.copyProperties(orderInfo, orderInfoEntity); orderInfoEntity.setLogId(ObjectUtil.isNotEmpty(logId) ? logId.toString() : null); orderInfoEntity.setDeliveryNoteId(vo.getId().toString()); + orderInfoEntity.setOrderCode(vo.getBillCode()); infoEntities.add(orderInfoEntity); } packageInfoService.saveBatch(infoEntities); diff --git a/blade-service/logpm-factory-data/logpm-factory-data-linsy/src/main/java/com/logpm/factorydata/linsy/mq/NodeDataPushListener.java b/blade-service/logpm-factory-data/logpm-factory-data-linsy/src/main/java/com/logpm/factorydata/linsy/mq/NodeDataPushListener.java new file mode 100644 index 000000000..b8690f4f0 --- /dev/null +++ b/blade-service/logpm-factory-data/logpm-factory-data-linsy/src/main/java/com/logpm/factorydata/linsy/mq/NodeDataPushListener.java @@ -0,0 +1,247 @@ +package com.logpm.factorydata.linsy.mq; + +import cn.hutool.core.collection.CollUtil; +import cn.hutool.core.convert.Convert; +import cn.hutool.core.util.EnumUtil; +import cn.hutool.core.util.ObjectUtil; +import cn.hutool.core.util.StrUtil; +import cn.hutool.http.HttpUtil; +import cn.hutool.json.JSONObject; +import cn.hutool.json.JSONUtil; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import com.logpm.factorydata.feign.IFactoryDataClient; +import com.logpm.factorydata.linsy.entity.FactoryNodePushEntity; +import com.logpm.factorydata.linsy.entity.PackageInfoEntity; +import com.logpm.factorydata.linsy.enums.FactoryNodeEnums; +import com.logpm.factorydata.linsy.enums.NodeMappingEnums; +import com.logpm.factorydata.linsy.enums.NodeNeedEnums; +import com.logpm.factorydata.linsy.pros.LinsyProperties; +import com.logpm.factorydata.linsy.service.FactoryNodePushService; +import com.logpm.factorydata.linsy.service.PackageInfoService; +import com.logpm.factorydata.vo.PushData; +import com.logpm.factorydata.vo.SendMsg; +import lombok.AllArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.bouncycastle.util.Pack; +import org.springblade.common.constant.WorkNodeEnums; +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.stereotype.Component; +import org.springframework.transaction.annotation.Transactional; + +import java.util.ArrayList; +import java.util.Comparator; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Optional; +import java.util.stream.Collectors; + +/** + * 监听业务系统推送给志邦的节点数据 + * + * @author zhaoqiaobo + * @create 2024-03-18 0:02 + */ +@Slf4j +@Component +@AllArgsConstructor +public class NodeDataPushListener { + + private final IFactoryDataClient factoryDataClient; + private final PackageInfoService packageInfoService; + private final FactoryNodePushService factoryNodePushService; + private final LinsyProperties linsyProperties; + + @RabbitListener(bindings = @QueueBinding( + value = @Queue(name = FactoryDataConstants.Mq.Queues.LINSY_NODE_DATA_PUSH, durable = "true"), + exchange = @Exchange(name = FactoryDataConstants.Mq.Exchanges.NODE_DATA_PUSH_DELAYED, type = ExchangeTypes.TOPIC + , delayed = FactoryDataConstants.Mq.DELAYED), + key = FactoryDataConstants.Mq.RoutingKeys.LINSY_NODE_DATA_PUSH + )) + public void nodeDataPushDelayed(String msg) { + // 直接调用nodeDataPush方法处理接收到的消息 + nodeDataPush(msg); + } + + @RabbitListener(bindings = @QueueBinding( + value = @Queue(name = FactoryDataConstants.Mq.Queues.LINSY_NODE_DATA_PUSH, durable = "true"), + exchange = @Exchange(name = FactoryDataConstants.Mq.Exchanges.NODE_DATA_PUSH, type = ExchangeTypes.TOPIC), + key = FactoryDataConstants.Mq.RoutingKeys.LINSY_NODE_DATA_PUSH + )) + @Transactional(rollbackFor = Exception.class) + public void nodeDataPush(String msg) { + // {"brand":"ZBOM","node":"TRANSFER_WAREHOUSE_DEPART","operator":"","operatorTime":"","content":[{"packageCode":"1423090693445"}]} + log.info("接收到节点数据推送:{}", msg); + // 1 校验数据 + if (checkData(msg)) { + return; + } + JSONObject entries = JSONUtil.parseObj(msg); + // 节点 + String node = entries.getStr("node"); + WorkNodeEnums workNodeEnums = EnumUtil.fromString(WorkNodeEnums.class, node); + // 2 获取业务数据 + List content = entries.getBeanList("content", PushData.class); + // 数据按订单分组 + // 3 拿到所有必推节点的code + List mustPushCode = FactoryNodeEnums.getMustPushCode(); + if (CollUtil.isNotEmpty(content)) { + // 根据订单码查询出本次操作的所有数据 + List packageInfoEntities = packageInfoService.list(Wrappers.lambdaQuery() + .in(PackageInfoEntity::getOrderCode, content.stream().map(PushData::getOrderCode).collect(Collectors.toList()))); + if (CollUtil.isEmpty(packageInfoEntities)) { + log.info("未查到包件数据,不处理:{}", JSONUtil.toJsonStr(content)); + return; + } + // packageInfoEntities按订单分组 + Map> packageInfoMap = packageInfoEntities.stream() + .collect(HashMap::new, (m, v) -> m.computeIfAbsent(v.getOrderCode(), k -> new ArrayList<>()).add(v), HashMap::putAll); + // 所有包件按订单号分组 + Map> groupByOrder = content.stream() + .collect(HashMap::new, (m, v) -> m.computeIfAbsent(v.getOrderCode(), k -> new ArrayList<>()).add(v), HashMap::putAll); + // 4 根据订单号查看所有已推节点,获取最大的推送节点 + List list = factoryNodePushService.list(Wrappers.lambdaQuery() + .in(FactoryNodePushEntity::getBillCode, groupByOrder.keySet()) + ); + Map maxNodeMap = new HashMap<>(); + if (CollUtil.isNotEmpty(list)) { + list.forEach(factoryNodePushEntity -> { + String billCode = factoryNodePushEntity.getBillCode(); + Integer code = Convert.toInt(factoryNodePushEntity.getNode()); + if (mustPushCode.contains(code)) { + if (maxNodeMap.containsKey(billCode)) { + Integer minNode = maxNodeMap.get(billCode); + if (code > minNode) { + maxNodeMap.put(billCode, code); + } + } else { + maxNodeMap.put(billCode, code); + } + } + }); + } + List updateList = new ArrayList<>(); + for (Map.Entry> entry : groupByOrder.entrySet()) { + String orderCode = entry.getKey(); + Integer code = workNodeEnums.getCode(); + // 当前的节点小于已经推送的最大节点,则跳过 + Integer maxCode = 0; + if (maxNodeMap.containsKey(orderCode)) { + if (maxNodeMap.get(orderCode) >= code) { + continue; + } + maxCode = maxNodeMap.get(orderCode); + } + List value = entry.getValue(); + if (CollUtil.isNotEmpty(value)) { + List collect = value.stream().map(PushData::getPackageCode).collect(Collectors.toList()); + // 5 根据订单号,包件码 查看数据是否齐套,齐套直接推送工厂 + List entities = packageInfoMap.get(orderCode); + // 过滤掉entities 中的 workedNodeCode < code 的数据 + List workerList = entities.stream() + .filter(packageInfoEntity -> !collect.contains(packageInfoEntity.getBarcode())) + .filter(packageInfoEntity -> packageInfoEntity.getWorkedNodeCode() < code) + .collect(Collectors.toList()); + FactoryNodeEnums factoryByNodeAndStatus = NodeMappingEnums.getFactoryByNodeAndStatus(workNodeEnums); + if (CollUtil.isEmpty(workerList)) { + // 齐套 推送工厂 + // 6 必传的节点中 必须大于 maxCode 并且 小于当前节点编码 并且 数值最小的一条数据 + Integer finalMaxCode = maxCode; + Optional min = mustPushCode.stream() + .filter(data -> data > finalMaxCode) + .filter(data -> data < code) + .min(Comparator.naturalOrder()); + Integer sendCode = null; + if (min.isPresent()) { + sendCode = min.get(); + } + if (ObjectUtil.isNotEmpty(sendCode)) { + // 延迟发送 + factoryByNodeAndStatus = NodeMappingEnums.getFactoryByNodeAndStatus(WorkNodeEnums.getByCode(sendCode)); + SendMsg sendMsg = SendMsg.builder() + .routingKey(FactoryDataConstants.Mq.RoutingKeys.LINSY_NODE_DATA_PUSH) + .exchange(FactoryDataConstants.Mq.Exchanges.NODE_DATA_PUSH_DELAYED) + .message(msg) + .delay(linsyProperties.getDelayedTime() * 1000 * 60) + .build(); + log.info("补节点延时推送:{}", msg); + factoryDataClient.sendMessage(sendMsg); + } + // 推送工厂 + JSONObject sendObj = new JSONObject(); + sendObj.set("billCode", orderCode); + sendObj.set("status", factoryByNodeAndStatus.getText()); + sendObj.set("packages", entities.stream().map(packageInfoEntity -> { + JSONObject jsonObject = new JSONObject(); + jsonObject.set("barcode", packageInfoEntity.getBarcode()); + return jsonObject; + }).collect(Collectors.toList())); + log.info("推送工厂:{}", JSONUtil.toJsonStr(sendObj)); + String url = linsyProperties.getHost() + linsyProperties.getPushNodeUrl(); + try { + if (linsyProperties.getEnable()) { + String result = HttpUtil.post(url, JSONUtil.toJsonStr(sendObj)); + log.info("推送工厂结果:{}", result); + // 保存推送记录 + factoryNodePushService.save(FactoryNodePushEntity.builder() + .billCode(orderCode) + .node(factoryByNodeAndStatus.getCode().toString()) + .content(JSONUtil.toJsonStr(sendObj)) + .resultContent(result) + .build()); + } + } catch (Exception e) { + log.error("推送工厂失败:{}", e); + } + } + // 封装需要修改作业节点状态的数据 + updateList.addAll(entities.stream() + .filter(data -> collect.contains(data.getBarcode())) + .map(packageInfoEntity -> { + PackageInfoEntity entity = new PackageInfoEntity(); + entity.setId(packageInfoEntity.getId()); + entity.setWorkedNodeCode(workNodeEnums.getCode()); + return entity; + }) + .collect(Collectors.toList())); + } + } + if (CollUtil.isNotEmpty(updateList)) { + packageInfoService.updateBatchById(updateList); + } + } + } + + private boolean checkData(String msg) { + if (StrUtil.isEmpty(msg)) { + return true; + } + if (!msg.contains("brand") || !msg.contains("content") || !msg.contains("node")) { + return true; + } + JSONObject entries = JSONUtil.parseObj(msg); + String node = entries.getStr("node"); + if (StrUtil.isEmpty(node)) { + return true; + } + // 不是志邦需要的节点数据直接不处理 + if (!EnumUtil.contains(NodeNeedEnums.class, node)) { + return true; + } + WorkNodeEnums workNodeEnums = EnumUtil.fromString(WorkNodeEnums.class, node); + if (ObjectUtil.isEmpty(workNodeEnums)) { + return true; + } + List content = entries.getBeanList("content", JSONObject.class); + if (CollUtil.isEmpty(content)) { + return true; + } + return false; + } + +} diff --git a/blade-service/logpm-factory-data/logpm-factory-data-linsy/src/main/java/com/logpm/factorydata/linsy/pros/LinsyProperties.java b/blade-service/logpm-factory-data/logpm-factory-data-linsy/src/main/java/com/logpm/factorydata/linsy/pros/LinsyProperties.java new file mode 100644 index 000000000..529b44a23 --- /dev/null +++ b/blade-service/logpm-factory-data/logpm-factory-data-linsy/src/main/java/com/logpm/factorydata/linsy/pros/LinsyProperties.java @@ -0,0 +1,40 @@ +package com.logpm.factorydata.linsy.pros; + +import lombok.Data; +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.stereotype.Component; + +/** + * FactoryProperties + * + * @author pref + */ +@Data +@ConfigurationProperties(prefix = "linsy") +@Component +public class LinsyProperties { + + /** + * 林氏工厂推送节点数据url + */ + private String pushNodeUrl; + /** + * 是否推送工厂 + */ + private Boolean enable = true; + /** + * 林氏工厂主机地址 + */ + private String host; + /** + * 承运商编码 + */ + private String carrierCode; + + /** + * 补节点数据时的延时时间(分钟) + */ + private Integer delayedTime = 30; + + +} diff --git a/blade-service/logpm-factory-data/logpm-factory-data-linsy/src/main/java/com/logpm/factorydata/linsy/service/DeliveryNoteService.java b/blade-service/logpm-factory-data/logpm-factory-data-linsy/src/main/java/com/logpm/factorydata/linsy/service/DeliveryNoteService.java index 441ca7fb0..a2f1e0030 100644 --- a/blade-service/logpm-factory-data/logpm-factory-data-linsy/src/main/java/com/logpm/factorydata/linsy/service/DeliveryNoteService.java +++ b/blade-service/logpm-factory-data/logpm-factory-data-linsy/src/main/java/com/logpm/factorydata/linsy/service/DeliveryNoteService.java @@ -1,6 +1,7 @@ package com.logpm.factorydata.linsy.service; import com.logpm.factorydata.linsy.entity.DeliveryNoteEntity; +import com.logpm.factorydata.linsy.vo.CancelOrderVO; import com.logpm.factorydata.linsy.vo.DeliveryNoteVO; import org.springblade.core.mp.base.BaseService; @@ -17,4 +18,5 @@ public interface DeliveryNoteService extends BaseService { void buildAdvance(DeliveryNoteVO entities); + Boolean cancelOrder(CancelOrderVO vo); } diff --git a/blade-service/logpm-factory-data/logpm-factory-data-linsy/src/main/java/com/logpm/factorydata/linsy/service/FactoryNodePushService.java b/blade-service/logpm-factory-data/logpm-factory-data-linsy/src/main/java/com/logpm/factorydata/linsy/service/FactoryNodePushService.java new file mode 100644 index 000000000..38eb69ae7 --- /dev/null +++ b/blade-service/logpm-factory-data/logpm-factory-data-linsy/src/main/java/com/logpm/factorydata/linsy/service/FactoryNodePushService.java @@ -0,0 +1,15 @@ +package com.logpm.factorydata.linsy.service; + +import com.logpm.factorydata.linsy.entity.FactoryNodePushEntity; +import com.logpm.factorydata.linsy.entity.PackageInfoEntity; +import org.springblade.core.mp.base.BaseService; + +/** + * 推送工厂节点数据 服务类 + * + * @Author zqb + * @Date 2024/4/26 + **/ +public interface FactoryNodePushService extends BaseService { + +} diff --git a/blade-service/logpm-factory-data/logpm-factory-data-linsy/src/main/java/com/logpm/factorydata/linsy/service/FactoryOrderLogService.java b/blade-service/logpm-factory-data/logpm-factory-data-linsy/src/main/java/com/logpm/factorydata/linsy/service/FactoryOrderLogService.java index 487a90088..864b296b0 100644 --- a/blade-service/logpm-factory-data/logpm-factory-data-linsy/src/main/java/com/logpm/factorydata/linsy/service/FactoryOrderLogService.java +++ b/blade-service/logpm-factory-data/logpm-factory-data-linsy/src/main/java/com/logpm/factorydata/linsy/service/FactoryOrderLogService.java @@ -15,5 +15,4 @@ public interface FactoryOrderLogService extends BaseService implements FactoryNodePushService { + +} diff --git a/blade-service/logpm-factory-data/logpm-factory-data-linsy/src/main/java/com/logpm/factorydata/linsy/service/impl/FactoryOrderLogServiceImpl.java b/blade-service/logpm-factory-data/logpm-factory-data-linsy/src/main/java/com/logpm/factorydata/linsy/service/impl/FactoryOrderLogServiceImpl.java index 820d0e96b..c96ae76d8 100644 --- a/blade-service/logpm-factory-data/logpm-factory-data-linsy/src/main/java/com/logpm/factorydata/linsy/service/impl/FactoryOrderLogServiceImpl.java +++ b/blade-service/logpm-factory-data/logpm-factory-data-linsy/src/main/java/com/logpm/factorydata/linsy/service/impl/FactoryOrderLogServiceImpl.java @@ -68,16 +68,6 @@ public class FactoryOrderLogServiceImpl extends BaseServiceImpl { /** * 文员复核 */ - CLERK_REVIEW(290, "签收"), + CLERK_REVIEW(290, "已签收"), ; FactoryNodeEnums(Integer code, String text) { diff --git a/blade-service/logpm-factory-data/logpm-factory-data-zbom/src/main/java/com/logpm/factorydata/zbom/entity/ZbFactoryNodePushEntity.java b/blade-service/logpm-factory-data/logpm-factory-data-zbom/src/main/java/com/logpm/factorydata/zbom/entity/ZbFactoryNodePushEntity.java index a34dc0924..a950762b8 100644 --- a/blade-service/logpm-factory-data/logpm-factory-data-zbom/src/main/java/com/logpm/factorydata/zbom/entity/ZbFactoryNodePushEntity.java +++ b/blade-service/logpm-factory-data/logpm-factory-data-zbom/src/main/java/com/logpm/factorydata/zbom/entity/ZbFactoryNodePushEntity.java @@ -65,6 +65,11 @@ public class ZbFactoryNodePushEntity extends BaseEntity { */ @ApiModelProperty(name = "节点", notes = "") private String node; + /** + * 仓库 + */ + @ApiModelProperty(name = "仓库", notes = "") + private String warehouseName; /** * 包条码 */ diff --git a/blade-service/logpm-factory-data/logpm-factory-data-zbom/src/main/java/com/logpm/factorydata/zbom/entity/ZbFactoryNodePushFailEntity.java b/blade-service/logpm-factory-data/logpm-factory-data-zbom/src/main/java/com/logpm/factorydata/zbom/entity/ZbFactoryNodePushFailEntity.java index 6cd896836..84703f4ce 100644 --- a/blade-service/logpm-factory-data/logpm-factory-data-zbom/src/main/java/com/logpm/factorydata/zbom/entity/ZbFactoryNodePushFailEntity.java +++ b/blade-service/logpm-factory-data/logpm-factory-data-zbom/src/main/java/com/logpm/factorydata/zbom/entity/ZbFactoryNodePushFailEntity.java @@ -66,6 +66,11 @@ public class ZbFactoryNodePushFailEntity extends BaseEntity { */ @ApiModelProperty(name = "节点", notes = "") private String node; + /** + * 仓库 + */ + @ApiModelProperty(name = "仓库", notes = "") + private String warehouseName; /** * 包条码 */ diff --git a/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/dto/LoadScanBrandDTO.java b/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/dto/LoadScanBrandDTO.java index 274d33434..2773d7268 100644 --- a/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/dto/LoadScanBrandDTO.java +++ b/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/dto/LoadScanBrandDTO.java @@ -18,6 +18,14 @@ public class LoadScanBrandDTO implements Serializable { * 包件码 */ private String packageCode; + /** + * 订单 + */ + private String orderCode; + /** + * 运单 + */ + private String waybillNumber; /** * 始发仓 */ diff --git a/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/feign/TrunklineAdvanceClient.java b/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/feign/TrunklineAdvanceClient.java index 6551f65e0..8b8e6ba8c 100644 --- a/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/feign/TrunklineAdvanceClient.java +++ b/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/feign/TrunklineAdvanceClient.java @@ -1,6 +1,7 @@ package com.logpm.trunkline.feign; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.logpm.trunkline.dto.CancelOrderParamVO; import com.logpm.trunkline.entity.TrunklineAdvanceEntity; import com.logpm.trunkline.service.ITrunklineAdvanceService; import lombok.AllArgsConstructor; @@ -43,4 +44,9 @@ public class TrunklineAdvanceClient implements ITrunklineAdvanceClient{ return advanceService.findListByIds(collect); } + + @Override + public Boolean cancelOrder(CancelOrderParamVO orderCode) { + return advanceService.cancelOrder(orderCode.getOrderCode()); + } } diff --git a/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/mapper/TrunklineCarsLoadMapper.xml b/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/mapper/TrunklineCarsLoadMapper.xml index c1a497bbe..bf4f3d64f 100644 --- a/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/mapper/TrunklineCarsLoadMapper.xml +++ b/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/mapper/TrunklineCarsLoadMapper.xml @@ -524,11 +524,13 @@ diff --git a/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/ITrunklineAdvanceService.java b/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/ITrunklineAdvanceService.java index 0ed04c63b..e69f2fe6e 100644 --- a/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/ITrunklineAdvanceService.java +++ b/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/ITrunklineAdvanceService.java @@ -42,4 +42,6 @@ public interface ITrunklineAdvanceService extends BaseService findListByExistsAndOrderCodeSet(List orderCodeSet); boolean saveOrderAndPackages(List advanceDetailEntities, Long warehouseId); + + Boolean cancelOrder(String orderCode); } diff --git a/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/impl/InComingServiceImpl.java b/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/impl/InComingServiceImpl.java index 5753ebde6..b1fcef415 100644 --- a/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/impl/InComingServiceImpl.java +++ b/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/impl/InComingServiceImpl.java @@ -166,7 +166,11 @@ public class InComingServiceImpl implements IInComingService { .address("在【" + warehouseName + "】入库") .brand(BrandEnums.getByValue(advanceDetailEntity.getBrand())) .node(WorkNodeEnums.INITIAL_WAREHOUSE_ENTRY) - .content(Arrays.asList(PushData.builder().packageCode(packageCode).build())) + .content(Arrays.asList(PushData.builder() + .packageCode(packageCode) + .warehouseName(warehouseName) + .orderCode(advanceDetailEntity.getOrderCode()) + .build())) .build(); factoryDataMessageSender.sendNodeDataByBrand(nodePushMsg); } catch (Exception e) { @@ -301,7 +305,11 @@ public class InComingServiceImpl implements IInComingService { .address("在【" + finalWarehouseName + "】入库") .brand(BrandEnums.getByValue(advanceDetailEntity.getBrand())) .node(WorkNodeEnums.INITIAL_WAREHOUSE_ENTRY) - .content(Arrays.asList(PushData.builder().packageCode(advanceDetailEntity.getOrderPackageCode()).build())) + .content(Arrays.asList(PushData.builder() + .packageCode(advanceDetailEntity.getOrderPackageCode()) + .orderCode(advanceDetailEntity.getOrderCode()) + .warehouseName(finalWarehouseName) + .build())) .build(); factoryDataMessageSender.sendNodeDataByBrand(nodePushMsg); } else if (tenant.getTenantType() == 2) { @@ -553,7 +561,11 @@ public class InComingServiceImpl implements IInComingService { .address("在【" + warehouseName + "】入库") .brand(BrandEnums.getByValue(advanceDetailEntity.getBrand())) .node(WorkNodeEnums.INITIAL_WAREHOUSE_ENTRY) - .content(Arrays.asList(PushData.builder().packageCode(advanceDetailEntity.getOrderPackageCode()).build())) + .content(Arrays.asList(PushData.builder() + .packageCode(advanceDetailEntity.getOrderPackageCode()) + .orderCode(advanceDetailEntity.getOrderCode()) + .warehouseName(warehouseName) + .build())) .build(); factoryDataMessageSender.sendNodeDataByBrand(nodePushMsg); } 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 bd2e12cbf..3efcb6577 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 @@ -5,6 +5,7 @@ import cn.hutool.core.date.DateUtil; import cn.hutool.json.JSONUtil; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.logpm.basic.entity.BasicMaterialEntity; import com.logpm.basic.feign.IBasicMaterialClient; import com.logpm.basicdata.entity.BasicdataClientEntity; @@ -24,6 +25,7 @@ import com.logpm.trunkline.dto.OrderStatusDTO; import com.logpm.trunkline.entity.TrunklineAdvanceDetailEntity; import com.logpm.trunkline.entity.TrunklineAdvanceEntity; import com.logpm.trunkline.mapper.TrunklineAdvanceMapper; +import com.logpm.trunkline.service.ITrunklineAdvanceDetailService; import com.logpm.trunkline.service.ITrunklineAdvanceService; import com.logpm.trunkline.vo.CustomerInfoVO; import com.logpm.trunkline.vo.OpenOrderVO; @@ -41,6 +43,7 @@ import org.springblade.core.tool.utils.Func; import org.springblade.core.tool.utils.StringUtil; import org.springframework.amqp.rabbit.core.RabbitTemplate; import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; import java.util.*; import java.util.function.Function; @@ -61,6 +64,7 @@ public class TrunklineAdvanceServiceImpl extends BaseServiceImpl parcelListEntityList = parcelListClient.findEntityListByOrderCode(orderCode, warehouseId); @@ -330,7 +334,7 @@ public class TrunklineAdvanceServiceImpl extends BaseServiceImpl queryWrapper = new QueryWrapper<>(); - queryWrapper.eq("order_code",orderCode) - .eq("train_number",trainNumber) - .eq("service_num",serviceNum); + queryWrapper.eq("order_code", orderCode) + .eq("train_number", trainNumber) + .eq("service_num", serviceNum); return baseMapper.selectOne(queryWrapper); } @Override public TrunklineAdvanceEntity findEntityByOrderCodeAndTrainNumber(String orderCode, String trainNumber) { QueryWrapper queryWrapper = new QueryWrapper<>(); - queryWrapper.eq("order_code",orderCode) - .eq("train_number",trainNumber); + queryWrapper.eq("order_code", orderCode) + .eq("train_number", trainNumber); return baseMapper.selectOne(queryWrapper); } @Override public void updateTotalNumById(Long id, int totalNum) { - baseMapper.updateTotalNumById(id,totalNum); + baseMapper.updateTotalNumById(id, totalNum); } @Override @@ -401,7 +405,7 @@ public class TrunklineAdvanceServiceImpl extends BaseServiceImpl parcelListEntityList = new ArrayList<>(); List orderPackageCodes = new ArrayList<>(); @@ -597,7 +601,7 @@ public class TrunklineAdvanceServiceImpl extends BaseServiceImpl advanceDetailEntities, Long warehouseId) { BasicdataWarehouseEntity warehouseEntity = basicdataWarehouseClient.getEntityWarehouseId(warehouseId); - if(Objects.isNull(warehouseEntity)){ - log.warn("############saveOrderAndPackages: 仓库信息不存在warehouseId={}",warehouseId); - throw new CustomerException(405,"仓库信息不存在"); + if (Objects.isNull(warehouseEntity)) { + log.warn("############saveOrderAndPackages: 仓库信息不存在warehouseId={}", warehouseId); + throw new CustomerException(405, "仓库信息不存在"); } TrunklineAdvanceDetailEntity advanceDetailEntity = advanceDetailEntities.get(0); String tenantId = advanceDetailEntity.getTenantId(); Long userId = AuthUtil.getUserId(); Long deptId = Func.firstLong(AuthUtil.getDeptId()); - if(Objects.isNull(userId)){ + if (Objects.isNull(userId)) { userId = advanceDetailEntity.getCreateUser(); } - if(Objects.isNull(deptId)){ + if (Objects.isNull(deptId)) { userId = advanceDetailEntity.getCreateDept(); } @@ -725,21 +729,21 @@ public class TrunklineAdvanceServiceImpl extends BaseServiceImpl advanceIdSet = advanceDetailEntities.stream().map(TrunklineAdvanceDetailEntity::getAdvanceId).collect(Collectors.toSet()); List advanceEntityList = findListByIds(new ArrayList<>(advanceIdSet)); - Map advanceEntityMap = new HashMap<>(); - if(!advanceEntityList.isEmpty()){ + Map advanceEntityMap = new HashMap<>(); + if (!advanceEntityList.isEmpty()) { advanceEntityMap = advanceEntityList.stream().collect(Collectors.toMap(TrunklineAdvanceEntity::getOrderCode, Function.identity())); } - List stockArticleEntities = stockArticleClient.findListByOrderCodesAndWarehouseId(orderCodeSet,warehouseId); + List stockArticleEntities = stockArticleClient.findListByOrderCodesAndWarehouseId(orderCodeSet, warehouseId); Map stockArticleMap = new HashMap<>(); - if(!stockArticleEntities.isEmpty()){ + if (!stockArticleEntities.isEmpty()) { stockArticleMap = stockArticleEntities.stream().collect(Collectors.toMap(DistributionStockArticleEntity::getOrderCode, Function.identity())); } - List parcelListEntities = parcelListClient.findListByOrderCodesAndWarehouseId(orderCodeSet,warehouseId); + List parcelListEntities = parcelListClient.findListByOrderCodesAndWarehouseId(orderCodeSet, warehouseId); Map parcelListMap = new HashMap<>(); - if(!parcelListEntities.isEmpty()){ + if (!parcelListEntities.isEmpty()) { parcelListMap = parcelListEntities.stream().collect(Collectors.toMap(DistributionParcelListEntity::getOrderPackageCode, Function.identity())); } @@ -758,9 +762,9 @@ public class TrunklineAdvanceServiceImpl extends BaseServiceImpl returnStockArticleEntities = stockArticleClient.addReturnList(addStockArticleEntities); returnStockArticleEntities.addAll(updateStockArticleEntities); - Map saMap = returnStockArticleEntities.stream().collect(Collectors.toMap(DistributionStockArticleEntity::getOrderCode, Function.identity())); + Map saMap = returnStockArticleEntities.stream().collect(Collectors.toMap(DistributionStockArticleEntity::getOrderCode, Function.identity())); List parcelListEntityList = new ArrayList<>(); - orderCodeMap.keySet().forEach(orderCode->{ + orderCodeMap.keySet().forEach(orderCode -> { DistributionStockArticleEntity stockArticleEntity = saMap.get(orderCode); - if(!Objects.isNull(stockArticleEntity)){ + if (!Objects.isNull(stockArticleEntity)) { Long orderId = stockArticleEntity.getId(); List adList = orderCodeMap.get(orderCode); - adList.forEach(ad->{ + adList.forEach(ad -> { String orderPackageCode = ad.getOrderPackageCode(); - if(!hasOrderPackageCodes.contains(orderPackageCode)){ + if (!hasOrderPackageCodes.contains(orderPackageCode)) { String trainNumber = ad.getTrainNumber(); DistributionParcelListEntity parcelList = new DistributionParcelListEntity(); parcelList.setCreateUser(finalUserId); @@ -900,9 +904,9 @@ public class TrunklineAdvanceServiceImpl extends BaseServiceImpl{ - stockArticleClient.updateOrderInfo(orderCode,warehouseId); + orderCodeSet.forEach(orderCode -> { + stockArticleClient.updateOrderInfo(orderCode, warehouseId); }); @@ -1240,4 +1244,28 @@ public class TrunklineAdvanceServiceImpl extends BaseServiceImpl list = advanceDetailService.list(Wrappers.lambdaQuery() + .eq(TrunklineAdvanceDetailEntity::getOrderCode, orderCode) + .and( + wrapper -> wrapper.eq(TrunklineAdvanceDetailEntity::getPackageStatus, "1") + .or().isNotNull(TrunklineAdvanceDetailEntity::getWaybillNo) + ) + ); + if (CollUtil.isNotEmpty(list)) { + return Boolean.FALSE; + } + boolean detailUpdate = advanceDetailService.update(Wrappers.lambdaUpdate() + .eq(TrunklineAdvanceDetailEntity::getOrderCode, orderCode) + .set(TrunklineAdvanceDetailEntity::getIsDeleted, "1") + ); + boolean advanceUpdate = this.update(Wrappers.lambdaUpdate() + .eq(TrunklineAdvanceEntity::getOrderCode, orderCode) + .set(TrunklineAdvanceEntity::getIsDeleted, "1") + ); + return detailUpdate && advanceUpdate; + } + } diff --git a/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/impl/TrunklineCarsLoadServiceImpl.java b/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/impl/TrunklineCarsLoadServiceImpl.java index 1c5ec4c90..90470db6d 100644 --- a/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/impl/TrunklineCarsLoadServiceImpl.java +++ b/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/impl/TrunklineCarsLoadServiceImpl.java @@ -392,22 +392,20 @@ public class TrunklineCarsLoadServiceImpl extends BaseServiceImpl contents = new ArrayList<>(); - ArrayList codes = CollUtil.newArrayList(packageCode.split(",")); - if (CollUtil.isNotEmpty(codes)) { - for (String code : codes) { - JSONObject jsonObject = new JSONObject(); - jsonObject.put("packageCode", code); - contents.add(jsonObject); - } - } - msg.setContent(contents); + NodePushMsg msg = NodePushMsg.builder() + .operator(AuthUtil.getNickName()) + .operatorTime(new Date()) + .address(warehouseAddress) + .brand(BrandEnums.getByValue(brand.getBrand())) + .node(WorkNodeEnums.INITIAL_WAREHOUSE_ENTRY) + .content(StrUtil.split(packageCode, ",").stream().map(data->{ + return PushData.builder() + .packageCode(data) + .warehouseName(warehouseEntity.getName()) + .orderCode(brand.getOrderCode()) + .build(); + }).collect(Collectors.toList())) + .build(); log.info("推送工厂数据:{}", JSONUtil.toJsonStr(msg)); factoryDataMessageSender.sendNodeDataByBrand(msg); // 推送梦天工厂