Browse Source

feat(all): 增加林氏工厂数据接收和数据回推

dist.1.3.0
zhaoqiaobo 10 months ago
parent
commit
6d137d9620
  1. 9
      blade-biz-common/src/main/java/org/springblade/common/constant/WorkNodeEnums.java
  2. 24
      blade-service-api/logpm-trunkline-api/src/main/java/com/logpm/trunkline/dto/CancelOrderParamVO.java
  3. 4
      blade-service-api/logpm-trunkline-api/src/main/java/com/logpm/trunkline/feign/ITrunklineAdvanceClient.java
  4. 0
      blade-service/logpm-factory-data/logpm-factory-data-linsy/Dockerfile
  5. 29
      blade-service/logpm-factory-data/logpm-factory-data-linsy/src/main/java/com/logpm/factorydata/linsy/controller/OrderController.java
  6. 74
      blade-service/logpm-factory-data/logpm-factory-data-linsy/src/main/java/com/logpm/factorydata/linsy/entity/FactoryNodePushEntity.java
  7. 4
      blade-service/logpm-factory-data/logpm-factory-data-linsy/src/main/java/com/logpm/factorydata/linsy/entity/PackageInfoEntity.java
  8. 51
      blade-service/logpm-factory-data/logpm-factory-data-linsy/src/main/java/com/logpm/factorydata/linsy/enums/FactoryNodeEnums.java
  9. 62
      blade-service/logpm-factory-data/logpm-factory-data-linsy/src/main/java/com/logpm/factorydata/linsy/enums/NodeMappingEnums.java
  10. 34
      blade-service/logpm-factory-data/logpm-factory-data-linsy/src/main/java/com/logpm/factorydata/linsy/enums/NodeNeedEnums.java
  11. 27
      blade-service/logpm-factory-data/logpm-factory-data-linsy/src/main/java/com/logpm/factorydata/linsy/enums/PushStatusEnums.java
  12. 16
      blade-service/logpm-factory-data/logpm-factory-data-linsy/src/main/java/com/logpm/factorydata/linsy/mapper/FactoryNodePushMapper.java
  13. 5
      blade-service/logpm-factory-data/logpm-factory-data-linsy/src/main/java/com/logpm/factorydata/linsy/mapper/FactoryNodePushMapper.xml
  14. 20
      blade-service/logpm-factory-data/logpm-factory-data-linsy/src/main/java/com/logpm/factorydata/linsy/mq/FactoryOrderListener.java
  15. 247
      blade-service/logpm-factory-data/logpm-factory-data-linsy/src/main/java/com/logpm/factorydata/linsy/mq/NodeDataPushListener.java
  16. 40
      blade-service/logpm-factory-data/logpm-factory-data-linsy/src/main/java/com/logpm/factorydata/linsy/pros/LinsyProperties.java
  17. 2
      blade-service/logpm-factory-data/logpm-factory-data-linsy/src/main/java/com/logpm/factorydata/linsy/service/DeliveryNoteService.java
  18. 15
      blade-service/logpm-factory-data/logpm-factory-data-linsy/src/main/java/com/logpm/factorydata/linsy/service/FactoryNodePushService.java
  19. 1
      blade-service/logpm-factory-data/logpm-factory-data-linsy/src/main/java/com/logpm/factorydata/linsy/service/FactoryOrderLogService.java
  20. 13
      blade-service/logpm-factory-data/logpm-factory-data-linsy/src/main/java/com/logpm/factorydata/linsy/service/impl/DeliveryNoteServiceImpl.java
  21. 22
      blade-service/logpm-factory-data/logpm-factory-data-linsy/src/main/java/com/logpm/factorydata/linsy/service/impl/FactoryNodePushServiceImpl.java
  22. 12
      blade-service/logpm-factory-data/logpm-factory-data-linsy/src/main/java/com/logpm/factorydata/linsy/service/impl/FactoryOrderLogServiceImpl.java
  23. 2
      blade-service/logpm-factory-data/logpm-factory-data-olo/src/main/java/com/logpm/factorydata/olo/enums/FactoryNodeEnums.java
  24. 5
      blade-service/logpm-factory-data/logpm-factory-data-zbom/src/main/java/com/logpm/factorydata/zbom/entity/ZbFactoryNodePushEntity.java
  25. 5
      blade-service/logpm-factory-data/logpm-factory-data-zbom/src/main/java/com/logpm/factorydata/zbom/entity/ZbFactoryNodePushFailEntity.java
  26. 8
      blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/dto/LoadScanBrandDTO.java
  27. 6
      blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/feign/TrunklineAdvanceClient.java
  28. 6
      blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/mapper/TrunklineCarsLoadMapper.xml
  29. 2
      blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/ITrunklineAdvanceService.java
  30. 18
      blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/impl/InComingServiceImpl.java
  31. 280
      blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/impl/TrunklineAdvanceServiceImpl.java
  32. 30
      blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/impl/TrunklineCarsLoadServiceImpl.java

9
blade-biz-common/src/main/java/org/springblade/common/constant/WorkNodeEnums.java

@ -68,4 +68,13 @@ public enum WorkNodeEnums implements Serializable {
return null; return null;
} }
public static WorkNodeEnums getByCode(Integer code){
for (WorkNodeEnums value : WorkNodeEnums.values()) {
if (value.getCode().equals(code)) {
return value;
}
}
return null;
}
} }

24
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;
}

4
blade-service-api/logpm-trunkline-api/src/main/java/com/logpm/trunkline/feign/ITrunklineAdvanceClient.java

@ -1,5 +1,6 @@
package com.logpm.trunkline.feign; package com.logpm.trunkline.feign;
import com.logpm.trunkline.dto.CancelOrderParamVO;
import com.logpm.trunkline.entity.TrunklineAdvanceEntity; import com.logpm.trunkline.entity.TrunklineAdvanceEntity;
import org.springblade.common.constant.ModuleNameConstant; import org.springblade.common.constant.ModuleNameConstant;
import org.springframework.cloud.openfeign.FeignClient; import org.springframework.cloud.openfeign.FeignClient;
@ -25,4 +26,7 @@ public interface ITrunklineAdvanceClient {
@PostMapping(API_PREFIX+"/findListByIds") @PostMapping(API_PREFIX+"/findListByIds")
List<TrunklineAdvanceEntity> findListByIds(@RequestBody List<Long> collect); List<TrunklineAdvanceEntity> findListByIds(@RequestBody List<Long> collect);
@PostMapping(API_PREFIX+"/cancelOrder")
Boolean cancelOrder(@RequestBody CancelOrderParamVO orderCode);
} }

0
blade-service/logpm-factory-data/logpm-factory-data-linsy/src/Dockerfile → blade-service/logpm-factory-data/logpm-factory-data-linsy/Dockerfile

29
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; package com.logpm.factorydata.linsy.controller;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.json.JSONUtil; import cn.hutool.json.JSONUtil;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.logpm.factorydata.linsy.service.DeliveryNoteService; import com.logpm.factorydata.linsy.service.DeliveryNoteService;
@ -11,20 +10,17 @@ import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j; 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.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.PatchMapping;
import org.springframework.web.bind.annotation.PostMapping; 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.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody; import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.stream.Collectors;
/** /**
* 工厂订单 前端控制器 * 工厂订单 前端控制器
@ -40,6 +36,19 @@ import java.util.stream.Collectors;
public class OrderController { public class OrderController {
private final FactoryOrderLogService service; 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 @ResponseBody
@PostMapping @PostMapping
@ -63,9 +72,11 @@ public class OrderController {
@ApiOperation(value = "取消订单", notes = "取消订单") @ApiOperation(value = "取消订单", notes = "取消订单")
public R cancelOrder(@RequestBody CancelOrderVO vo) { public R cancelOrder(@RequestBody CancelOrderVO vo) {
log.info("取消订单:{} ", JSONUtil.toJsonStr(vo)); log.info("取消订单:{} ", JSONUtil.toJsonStr(vo));
String res = ""; Boolean res = deliveryNoteService.cancelOrder(vo);
res = service.cancelOrder(vo); if (res) {
return R.success(res); return R.success("取消成功");
}
return R.fail("该订单已作业,无法取消");
} }
} }

74
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;
}

4
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; private String logId;
@ApiModelProperty(value = "发货单id") @ApiModelProperty(value = "发货单id")
private String deliveryNoteId; private String deliveryNoteId;
@ApiModelProperty(value = "订单号")
private String orderCode;
@ApiModelProperty(value = "已推送节点编码")
private Integer workedNodeCode;
@ApiModelProperty(value = "父项物料编码") @ApiModelProperty(value = "父项物料编码")
private String parentMaterialCode; private String parentMaterialCode;
@ApiModelProperty(value = "父项物料名称") @ApiModelProperty(value = "父项物料名称")

51
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<Integer> getMustPushCode() {
List<Integer> list = new ArrayList<>();
for (FactoryNodeEnums value : FactoryNodeEnums.values()) {
if (value.getMustPush() == 1) {
list.add(value.getCode());
}
}
return list;
}
}

62
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;
}
}

34
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;
}
}

27
blade-service/logpm-factory-data/logpm-factory-data-linsy/src/main/java/com/logpm/factorydata/linsy/enums/PushStatusEnums.java

@ -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<String> {
/**
* 已交接
*/
DELIVERIED("Deliveried", "已交接"),
/**
* 收货完成
*/
RECEIVED("Received", "收货完成"),
;
PushStatusEnums(String code, String text) {
init(code, text);
}
}

16
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<FactoryNodePushEntity> {
}

5
blade-service/logpm-factory-data/logpm-factory-data-linsy/src/main/java/com/logpm/factorydata/linsy/mapper/FactoryNodePushMapper.xml

@ -0,0 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.logpm.factorydata.linsy.mapper.FactoryNodePushMapper">
</mapper>

20
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.bean.BeanUtil;
import cn.hutool.core.collection.CollUtil; 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.io.FileUtil;
import cn.hutool.core.util.CharsetUtil; import cn.hutool.core.util.CharsetUtil;
import cn.hutool.core.util.NumberUtil;
import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil; import cn.hutool.core.util.StrUtil;
import cn.hutool.core.util.URLUtil; import cn.hutool.core.util.URLUtil;
import cn.hutool.json.JSONConfig; import cn.hutool.json.JSONConfig;
import cn.hutool.json.JSONObject;
import cn.hutool.json.JSONUtil; import cn.hutool.json.JSONUtil;
import com.baomidou.mybatisplus.core.toolkit.Wrappers; 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.enums.SaxStatusEnums;
import com.logpm.factorydata.feign.IFactoryDataClient;
import com.logpm.factorydata.linsy.entity.DeliveryNoteEntity; import com.logpm.factorydata.linsy.entity.DeliveryNoteEntity;
import com.logpm.factorydata.linsy.entity.FactoryOrderLogEntity; import com.logpm.factorydata.linsy.entity.FactoryOrderLogEntity;
import com.logpm.factorydata.linsy.entity.PackageInfoEntity; 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.service.PackageInfoService;
import com.logpm.factorydata.linsy.vo.DeliveryNoteVO; import com.logpm.factorydata.linsy.vo.DeliveryNoteVO;
import com.logpm.factorydata.linsy.vo.PackageInfoVO; 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.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j; 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.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.core.ExchangeTypes;
import org.springframework.amqp.rabbit.annotation.Exchange; import org.springframework.amqp.rabbit.annotation.Exchange;
import org.springframework.amqp.rabbit.annotation.Queue; 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.stereotype.Component;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map;
/** /**
* 监听订单数据 * 监听订单数据
@ -123,6 +104,7 @@ public class FactoryOrderListener {
BeanUtil.copyProperties(orderInfo, orderInfoEntity); BeanUtil.copyProperties(orderInfo, orderInfoEntity);
orderInfoEntity.setLogId(ObjectUtil.isNotEmpty(logId) ? logId.toString() : null); orderInfoEntity.setLogId(ObjectUtil.isNotEmpty(logId) ? logId.toString() : null);
orderInfoEntity.setDeliveryNoteId(vo.getId().toString()); orderInfoEntity.setDeliveryNoteId(vo.getId().toString());
orderInfoEntity.setOrderCode(vo.getBillCode());
infoEntities.add(orderInfoEntity); infoEntities.add(orderInfoEntity);
} }
packageInfoService.saveBatch(infoEntities); packageInfoService.saveBatch(infoEntities);

247
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<PushData> content = entries.getBeanList("content", PushData.class);
// 数据按订单分组
// 3 拿到所有必推节点的code
List<Integer> mustPushCode = FactoryNodeEnums.getMustPushCode();
if (CollUtil.isNotEmpty(content)) {
// 根据订单码查询出本次操作的所有数据
List<PackageInfoEntity> packageInfoEntities = packageInfoService.list(Wrappers.<PackageInfoEntity>lambdaQuery()
.in(PackageInfoEntity::getOrderCode, content.stream().map(PushData::getOrderCode).collect(Collectors.toList())));
if (CollUtil.isEmpty(packageInfoEntities)) {
log.info("未查到包件数据,不处理:{}", JSONUtil.toJsonStr(content));
return;
}
// packageInfoEntities按订单分组
Map<String, List<PackageInfoEntity>> packageInfoMap = packageInfoEntities.stream()
.collect(HashMap::new, (m, v) -> m.computeIfAbsent(v.getOrderCode(), k -> new ArrayList<>()).add(v), HashMap::putAll);
// 所有包件按订单号分组
Map<String, List<PushData>> groupByOrder = content.stream()
.collect(HashMap::new, (m, v) -> m.computeIfAbsent(v.getOrderCode(), k -> new ArrayList<>()).add(v), HashMap::putAll);
// 4 根据订单号查看所有已推节点,获取最大的推送节点
List<FactoryNodePushEntity> list = factoryNodePushService.list(Wrappers.<FactoryNodePushEntity>lambdaQuery()
.in(FactoryNodePushEntity::getBillCode, groupByOrder.keySet())
);
Map<String, Integer> 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<PackageInfoEntity> updateList = new ArrayList<>();
for (Map.Entry<String, List<PushData>> 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<PushData> value = entry.getValue();
if (CollUtil.isNotEmpty(value)) {
List<String> collect = value.stream().map(PushData::getPackageCode).collect(Collectors.toList());
// 5 根据订单号,包件码 查看数据是否齐套,齐套直接推送工厂
List<PackageInfoEntity> entities = packageInfoMap.get(orderCode);
// 过滤掉entities 中的 workedNodeCode < code 的数据
List<PackageInfoEntity> 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<Integer> 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<JSONObject> content = entries.getBeanList("content", JSONObject.class);
if (CollUtil.isEmpty(content)) {
return true;
}
return false;
}
}

40
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;
}

2
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; package com.logpm.factorydata.linsy.service;
import com.logpm.factorydata.linsy.entity.DeliveryNoteEntity; import com.logpm.factorydata.linsy.entity.DeliveryNoteEntity;
import com.logpm.factorydata.linsy.vo.CancelOrderVO;
import com.logpm.factorydata.linsy.vo.DeliveryNoteVO; import com.logpm.factorydata.linsy.vo.DeliveryNoteVO;
import org.springblade.core.mp.base.BaseService; import org.springblade.core.mp.base.BaseService;
@ -17,4 +18,5 @@ public interface DeliveryNoteService extends BaseService<DeliveryNoteEntity> {
void buildAdvance(DeliveryNoteVO entities); void buildAdvance(DeliveryNoteVO entities);
Boolean cancelOrder(CancelOrderVO vo);
} }

15
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<FactoryNodePushEntity> {
}

1
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<FactoryOrderLogEntit
String order(DeliveryNoteVO vo); String order(DeliveryNoteVO vo);
String cancelOrder(CancelOrderVO vo);
} }

13
blade-service/logpm-factory-data/logpm-factory-data-linsy/src/main/java/com/logpm/factorydata/linsy/service/impl/DeliveryNoteServiceImpl.java

@ -13,11 +13,14 @@ import com.logpm.factorydata.feign.IFactoryDataClient;
import com.logpm.factorydata.linsy.entity.DeliveryNoteEntity; import com.logpm.factorydata.linsy.entity.DeliveryNoteEntity;
import com.logpm.factorydata.linsy.mapper.DeliveryNoteMapper; import com.logpm.factorydata.linsy.mapper.DeliveryNoteMapper;
import com.logpm.factorydata.linsy.service.DeliveryNoteService; import com.logpm.factorydata.linsy.service.DeliveryNoteService;
import com.logpm.factorydata.linsy.vo.CancelOrderVO;
import com.logpm.factorydata.linsy.vo.DeliveryNoteVO; import com.logpm.factorydata.linsy.vo.DeliveryNoteVO;
import com.logpm.factorydata.linsy.vo.PackageInfoVO; import com.logpm.factorydata.linsy.vo.PackageInfoVO;
import com.logpm.factorydata.vo.SendMsg; import com.logpm.factorydata.vo.SendMsg;
import com.logpm.trunkline.dto.CancelOrderParamVO;
import com.logpm.trunkline.entity.TrunklineAdvanceDetailEntity; import com.logpm.trunkline.entity.TrunklineAdvanceDetailEntity;
import com.logpm.trunkline.entity.TrunklineAdvanceEntity; import com.logpm.trunkline.entity.TrunklineAdvanceEntity;
import com.logpm.trunkline.feign.ITrunklineAdvanceClient;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springblade.common.annotations.LogpmAsync; import org.springblade.common.annotations.LogpmAsync;
@ -45,6 +48,7 @@ public class DeliveryNoteServiceImpl extends BaseServiceImpl<DeliveryNoteMapper,
private final IFactoryDataBaseClient baseClient; private final IFactoryDataBaseClient baseClient;
private final IFactoryDataClient factoryDataClient; private final IFactoryDataClient factoryDataClient;
private final ITrunklineAdvanceClient advanceClient;
@Override @Override
@LogpmAsync("asyncExecutor") @LogpmAsync("asyncExecutor")
@ -161,4 +165,13 @@ public class DeliveryNoteServiceImpl extends BaseServiceImpl<DeliveryNoteMapper,
} }
} }
@Override
public Boolean cancelOrder(CancelOrderVO vo) {
log.info("工厂发起取消订单:{}", JSONUtil.toJsonStr(vo));
CancelOrderParamVO param = new CancelOrderParamVO();
param.setOrderCode(vo.getSourceCode());
Boolean result = advanceClient.cancelOrder(param);
return result;
}
} }

22
blade-service/logpm-factory-data/logpm-factory-data-linsy/src/main/java/com/logpm/factorydata/linsy/service/impl/FactoryNodePushServiceImpl.java

@ -0,0 +1,22 @@
package com.logpm.factorydata.linsy.service.impl;
import com.logpm.factorydata.linsy.entity.FactoryNodePushEntity;
import com.logpm.factorydata.linsy.mapper.FactoryNodePushMapper;
import com.logpm.factorydata.linsy.service.FactoryNodePushService;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springblade.core.mp.base.BaseServiceImpl;
import org.springframework.stereotype.Service;
/**
* 装箱包信息 业务实现类
*
* @Author zqb
* @Date 2024/4/26
**/
@Slf4j
@Service
@AllArgsConstructor
public class FactoryNodePushServiceImpl extends BaseServiceImpl<FactoryNodePushMapper, FactoryNodePushEntity> implements FactoryNodePushService {
}

12
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<FactoryOrderLogM
return "成功"; return "成功";
} }
@Override
public String cancelOrder(CancelOrderVO vo) {
// TODO 取消订单逻辑后续实现 同步接口,实时返回取消状态
if (ObjectUtil.equal(vo.getSourceCode(), "1")) {
return "取消成功";
} else {
throw new ServiceException("取消失败");
}
}
private String uploadFile(String body) { private String uploadFile(String body) {
//文本内容和保存为本地文件 并上传 //文本内容和保存为本地文件 并上传
String logPath = FileLogsUtil.saveFileLogs(body); String logPath = FileLogsUtil.saveFileLogs(body);
@ -85,7 +75,7 @@ public class FactoryOrderLogServiceImpl extends BaseServiceImpl<FactoryOrderLogM
MultipartFile multi = getMultipartFile(logPath); MultipartFile multi = getMultipartFile(logPath);
//上传到服务器 //上传到服务器
R r = ossClient.fileUpload(multi, "olo-order-logs"); R r = ossClient.fileUpload(multi, "linsy-order-logs");
if (r.isSuccess()) { if (r.isSuccess()) {
BladeFile data = (BladeFile) r.getData(); BladeFile data = (BladeFile) r.getData();
// 删除本地文件 // 删除本地文件

2
blade-service/logpm-factory-data/logpm-factory-data-olo/src/main/java/com/logpm/factorydata/olo/enums/FactoryNodeEnums.java

@ -19,7 +19,7 @@ public enum FactoryNodeEnums implements IDict<Integer> {
/** /**
* 文员复核 * 文员复核
*/ */
CLERK_REVIEW(290, "签收"), CLERK_REVIEW(290, "签收"),
; ;
FactoryNodeEnums(Integer code, String text) { FactoryNodeEnums(Integer code, String text) {

5
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 = "") @ApiModelProperty(name = "节点", notes = "")
private String node; private String node;
/**
* 仓库
*/
@ApiModelProperty(name = "仓库", notes = "")
private String warehouseName;
/** /**
* 包条码 * 包条码
*/ */

5
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 = "") @ApiModelProperty(name = "节点", notes = "")
private String node; private String node;
/**
* 仓库
*/
@ApiModelProperty(name = "仓库", notes = "")
private String warehouseName;
/** /**
* 包条码 * 包条码
*/ */

8
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 packageCode;
/**
* 订单
*/
private String orderCode;
/**
* 运单
*/
private String waybillNumber;
/** /**
* 始发仓 * 始发仓
*/ */

6
blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/feign/TrunklineAdvanceClient.java

@ -1,6 +1,7 @@
package com.logpm.trunkline.feign; package com.logpm.trunkline.feign;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.logpm.trunkline.dto.CancelOrderParamVO;
import com.logpm.trunkline.entity.TrunklineAdvanceEntity; import com.logpm.trunkline.entity.TrunklineAdvanceEntity;
import com.logpm.trunkline.service.ITrunklineAdvanceService; import com.logpm.trunkline.service.ITrunklineAdvanceService;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
@ -43,4 +44,9 @@ public class TrunklineAdvanceClient implements ITrunklineAdvanceClient{
return advanceService.findListByIds(collect); return advanceService.findListByIds(collect);
} }
@Override
public Boolean cancelOrder(CancelOrderParamVO orderCode) {
return advanceService.cancelOrder(orderCode.getOrderCode());
}
} }

6
blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/mapper/TrunklineCarsLoadMapper.xml

@ -524,11 +524,13 @@
</where> </where>
</select> </select>
<select id="fingPackageCodeByLoadId" resultType="com.logpm.trunkline.dto.LoadScanBrandDTO"> <select id="fingPackageCodeByLoadId" resultType="com.logpm.trunkline.dto.LoadScanBrandDTO">
select dpl.brand_name brand,dpl.send_warehouse_id startWarehouseId,group_concat(dpl.order_package_code) packageCode select dpl.brand_name brand,dpl.order_code,dpl.waybill_number,
dpl.send_warehouse_id startWarehouseId,
group_concat(dpl.order_package_code) packageCode
from logpm_trunkline_cars_load_scan t from logpm_trunkline_cars_load_scan t
left join logpm_distribution_parcel_list dpl on dpl.order_package_code = t.scan_code and dpl.warehouse_id = #{warehouseId} left join logpm_distribution_parcel_list dpl on dpl.order_package_code = t.scan_code and dpl.warehouse_id = #{warehouseId}
where t.load_id = #{loadId} where t.load_id = #{loadId}
group by dpl.brand_name,dpl.accept_warehouse_id group by dpl.brand_name,dpl.accept_warehouse_id,dpl.order_code,dpl.waybill_number
</select> </select>
<update id="updateWaybillOrderIsCustemer"> <update id="updateWaybillOrderIsCustemer">

2
blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/ITrunklineAdvanceService.java

@ -42,4 +42,6 @@ public interface ITrunklineAdvanceService extends BaseService<TrunklineAdvanceEn
List<TrunklineAdvanceEntity> findListByExistsAndOrderCodeSet(List<String> orderCodeSet); List<TrunklineAdvanceEntity> findListByExistsAndOrderCodeSet(List<String> orderCodeSet);
boolean saveOrderAndPackages(List<TrunklineAdvanceDetailEntity> advanceDetailEntities, Long warehouseId); boolean saveOrderAndPackages(List<TrunklineAdvanceDetailEntity> advanceDetailEntities, Long warehouseId);
Boolean cancelOrder(String orderCode);
} }

18
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 + "】入库") .address("在【" + warehouseName + "】入库")
.brand(BrandEnums.getByValue(advanceDetailEntity.getBrand())) .brand(BrandEnums.getByValue(advanceDetailEntity.getBrand()))
.node(WorkNodeEnums.INITIAL_WAREHOUSE_ENTRY) .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(); .build();
factoryDataMessageSender.sendNodeDataByBrand(nodePushMsg); factoryDataMessageSender.sendNodeDataByBrand(nodePushMsg);
} catch (Exception e) { } catch (Exception e) {
@ -301,7 +305,11 @@ public class InComingServiceImpl implements IInComingService {
.address("在【" + finalWarehouseName + "】入库") .address("在【" + finalWarehouseName + "】入库")
.brand(BrandEnums.getByValue(advanceDetailEntity.getBrand())) .brand(BrandEnums.getByValue(advanceDetailEntity.getBrand()))
.node(WorkNodeEnums.INITIAL_WAREHOUSE_ENTRY) .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(); .build();
factoryDataMessageSender.sendNodeDataByBrand(nodePushMsg); factoryDataMessageSender.sendNodeDataByBrand(nodePushMsg);
} else if (tenant.getTenantType() == 2) { } else if (tenant.getTenantType() == 2) {
@ -553,7 +561,11 @@ public class InComingServiceImpl implements IInComingService {
.address("在【" + warehouseName + "】入库") .address("在【" + warehouseName + "】入库")
.brand(BrandEnums.getByValue(advanceDetailEntity.getBrand())) .brand(BrandEnums.getByValue(advanceDetailEntity.getBrand()))
.node(WorkNodeEnums.INITIAL_WAREHOUSE_ENTRY) .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(); .build();
factoryDataMessageSender.sendNodeDataByBrand(nodePushMsg); factoryDataMessageSender.sendNodeDataByBrand(nodePushMsg);
} }

280
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 cn.hutool.json.JSONUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.logpm.basic.entity.BasicMaterialEntity; import com.logpm.basic.entity.BasicMaterialEntity;
import com.logpm.basic.feign.IBasicMaterialClient; import com.logpm.basic.feign.IBasicMaterialClient;
import com.logpm.basicdata.entity.BasicdataClientEntity; 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.TrunklineAdvanceDetailEntity;
import com.logpm.trunkline.entity.TrunklineAdvanceEntity; import com.logpm.trunkline.entity.TrunklineAdvanceEntity;
import com.logpm.trunkline.mapper.TrunklineAdvanceMapper; import com.logpm.trunkline.mapper.TrunklineAdvanceMapper;
import com.logpm.trunkline.service.ITrunklineAdvanceDetailService;
import com.logpm.trunkline.service.ITrunklineAdvanceService; import com.logpm.trunkline.service.ITrunklineAdvanceService;
import com.logpm.trunkline.vo.CustomerInfoVO; import com.logpm.trunkline.vo.CustomerInfoVO;
import com.logpm.trunkline.vo.OpenOrderVO; 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.springblade.core.tool.utils.StringUtil;
import org.springframework.amqp.rabbit.core.RabbitTemplate; import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.*; import java.util.*;
import java.util.function.Function; import java.util.function.Function;
@ -61,6 +64,7 @@ public class TrunklineAdvanceServiceImpl extends BaseServiceImpl<TrunklineAdvanc
private final IWarehouseWaybillClient warehouseWaybillClient; private final IWarehouseWaybillClient warehouseWaybillClient;
private final IBasicdataTripartiteMallClient basicdataTripartiteMallClient; private final IBasicdataTripartiteMallClient basicdataTripartiteMallClient;
private final RabbitTemplate rabbitTemplate; private final RabbitTemplate rabbitTemplate;
private final ITrunklineAdvanceDetailService advanceDetailService;
@Override @Override
@ -69,38 +73,38 @@ public class TrunklineAdvanceServiceImpl extends BaseServiceImpl<TrunklineAdvanc
String orderCode = advanceDetailEntity.getOrderCode(); String orderCode = advanceDetailEntity.getOrderCode();
Long advanceId = advanceDetailEntity.getAdvanceId(); Long advanceId = advanceDetailEntity.getAdvanceId();
String tenantId = advanceDetailEntity.getTenantId(); String tenantId = advanceDetailEntity.getTenantId();
log.info("############saveOrderAndPackage: 保存订单和包件信息 orderPackageCode={}",orderPackageCode); log.info("############saveOrderAndPackage: 保存订单和包件信息 orderPackageCode={}", orderPackageCode);
BasicdataWarehouseEntity warehouseEntity = basicdataWarehouseClient.getEntityWarehouseId(warehouseId); BasicdataWarehouseEntity warehouseEntity = basicdataWarehouseClient.getEntityWarehouseId(warehouseId);
if(Objects.isNull(warehouseEntity)){ if (Objects.isNull(warehouseEntity)) {
log.warn("############saveOrderAndPackage: 仓库信息不存在warehouseId={}",warehouseId); log.warn("############saveOrderAndPackage: 仓库信息不存在warehouseId={}", warehouseId);
throw new CustomerException(405,"仓库信息不存在"); throw new CustomerException(405, "仓库信息不存在");
} }
//1.判断包件是否已经存在 //1.判断包件是否已经存在
DistributionParcelListEntity parcelListEntity = parcelListClient.findByPacketBarCodeAndWarehouseId(orderPackageCode, warehouseId); DistributionParcelListEntity parcelListEntity = parcelListClient.findByPacketBarCodeAndWarehouseId(orderPackageCode, warehouseId);
if(!Objects.isNull(parcelListEntity)){ if (!Objects.isNull(parcelListEntity)) {
log.warn("############saveOrderAndPackage: 包件信息已存在 orderPackageCode={} warehouseId={}",orderPackageCode,warehouseId); log.warn("############saveOrderAndPackage: 包件信息已存在 orderPackageCode={} warehouseId={}", orderPackageCode, warehouseId);
return true; return true;
} }
TrunklineAdvanceEntity advanceEntity = getById(advanceId); TrunklineAdvanceEntity advanceEntity = getById(advanceId);
if(Objects.isNull(advanceEntity)){ if (Objects.isNull(advanceEntity)) {
log.warn("############saveOrderAndPackage: 暂存单信息不存在 advanceId={} warehouseId={}",advanceId,warehouseId); log.warn("############saveOrderAndPackage: 暂存单信息不存在 advanceId={} warehouseId={}", advanceId, warehouseId);
throw new CustomerException(405,"暂存单信息不存在"); throw new CustomerException(405, "暂存单信息不存在");
} }
Long userId = AuthUtil.getUserId(); Long userId = AuthUtil.getUserId();
Long deptId = null; Long deptId = null;
String deptIds = AuthUtil.getDeptId(); String deptIds = AuthUtil.getDeptId();
String[] split = deptIds.split(","); String[] split = deptIds.split(",");
if(Objects.isNull(userId)){ if (Objects.isNull(userId)) {
userId = advanceDetailEntity.getCreateUser(); userId = advanceDetailEntity.getCreateUser();
} }
if(CollUtil.isEmpty(Arrays.asList(split))){ if (CollUtil.isEmpty(Arrays.asList(split))) {
deptId = Long.parseLong(split[0]); deptId = Long.parseLong(split[0]);
} }
if(Objects.isNull(deptId)){ if (Objects.isNull(deptId)) {
userId = advanceDetailEntity.getCreateDept(); userId = advanceDetailEntity.getCreateDept();
} }
@ -110,7 +114,7 @@ public class TrunklineAdvanceServiceImpl extends BaseServiceImpl<TrunklineAdvanc
Date date = new Date(); Date date = new Date();
Long orderId = null; Long orderId = null;
DistributionStockArticleEntity stockArticleEntity = stockArticleClient.findStockArticleByOrderCodeAndWarehouseId(orderCode, warehouseId); DistributionStockArticleEntity stockArticleEntity = stockArticleClient.findStockArticleByOrderCodeAndWarehouseId(orderCode, warehouseId);
if(Objects.isNull(stockArticleEntity)){ if (Objects.isNull(stockArticleEntity)) {
log.info("#############saveOrderAndPackage: 订单信息为空,同步订单信息"); log.info("#############saveOrderAndPackage: 订单信息为空,同步订单信息");
//订单信息为空 //订单信息为空
String waybillNo = advanceEntity.getWaybillNo(); String waybillNo = advanceEntity.getWaybillNo();
@ -139,13 +143,13 @@ public class TrunklineAdvanceServiceImpl extends BaseServiceImpl<TrunklineAdvanc
stockArticleEntity.setTypeService("1");//默认商配 stockArticleEntity.setTypeService("1");//默认商配
if(!StringUtil.isBlank(waybillNo)){ if (!StringUtil.isBlank(waybillNo)) {
WarehouseWaybillEntity waybillEntity = warehouseWaybillClient.findByWaybillNo(waybillNo); WarehouseWaybillEntity waybillEntity = warehouseWaybillClient.findByWaybillNo(waybillNo);
if(!Objects.isNull(waybillEntity)){ if (!Objects.isNull(waybillEntity)) {
Long consigneeId = waybillEntity.getConsigneeId(); Long consigneeId = waybillEntity.getConsigneeId();
BasicdataClientEntity clientEntity = basicdataClientClient.findEntityById(consigneeId); BasicdataClientEntity clientEntity = basicdataClientClient.findEntityById(consigneeId);
if(!Objects.isNull(clientEntity)){ if (!Objects.isNull(clientEntity)) {
stockArticleEntity.setMallId(clientEntity.getId()); stockArticleEntity.setMallId(clientEntity.getId());
stockArticleEntity.setMallName(clientEntity.getClientName()); stockArticleEntity.setMallName(clientEntity.getClientName());
stockArticleEntity.setMallCode(clientEntity.getClientCode()); stockArticleEntity.setMallCode(clientEntity.getClientCode());
@ -160,44 +164,44 @@ public class TrunklineAdvanceServiceImpl extends BaseServiceImpl<TrunklineAdvanc
stockArticleEntity.setConsigneeAddress(consigneeAddress); stockArticleEntity.setConsigneeAddress(consigneeAddress);
BasicdataStoreBusinessEntity basicdataStoreBusinessEntity = basicdataStoreBusinessClient.findByClientIdAndTypeService(consigneeId, 3); BasicdataStoreBusinessEntity basicdataStoreBusinessEntity = basicdataStoreBusinessClient.findByClientIdAndTypeService(consigneeId, 3);
if(!Objects.isNull(basicdataStoreBusinessEntity)){ if (!Objects.isNull(basicdataStoreBusinessEntity)) {
stockArticleEntity.setTypeService(basicdataStoreBusinessEntity.getMold()); stockArticleEntity.setTypeService(basicdataStoreBusinessEntity.getMold());
} }
} }
}else{ } else {
Long clientId = basicdataTripartiteMallClient.getClientIdByNameAndBrand(dealerName, advanceEntity.getBrand()); Long clientId = basicdataTripartiteMallClient.getClientIdByNameAndBrand(dealerName, advanceEntity.getBrand());
BasicdataClientEntity basicdataClientEntity = basicdataClientClient.findEntityById(clientId); BasicdataClientEntity basicdataClientEntity = basicdataClientClient.findEntityById(clientId);
if(!Objects.isNull(basicdataClientEntity)){ if (!Objects.isNull(basicdataClientEntity)) {
String clientType = basicdataClientEntity.getClientType(); String clientType = basicdataClientEntity.getClientType();
if("5".equals(clientType)){ if ("5".equals(clientType)) {
stockArticleEntity.setStoreId(basicdataClientEntity.getId()); stockArticleEntity.setStoreId(basicdataClientEntity.getId());
stockArticleEntity.setStoreCode(basicdataClientEntity.getClientCode()); stockArticleEntity.setStoreCode(basicdataClientEntity.getClientCode());
stockArticleEntity.setStoreName(basicdataClientEntity.getClientName()); stockArticleEntity.setStoreName(basicdataClientEntity.getClientName());
//查询门店的父级商场 //查询门店的父级商场
Long pid = basicdataClientEntity.getPid(); Long pid = basicdataClientEntity.getPid();
BasicdataClientEntity pidEntity = basicdataClientClient.findEntityById(pid); BasicdataClientEntity pidEntity = basicdataClientClient.findEntityById(pid);
if(!Objects.isNull(pidEntity)){ if (!Objects.isNull(pidEntity)) {
String pidEntityClientType = pidEntity.getClientType(); String pidEntityClientType = pidEntity.getClientType();
if("2".equals(pidEntityClientType)){ if ("2".equals(pidEntityClientType)) {
//商城 //商城
stockArticleEntity.setMallId(pidEntity.getId()); stockArticleEntity.setMallId(pidEntity.getId());
stockArticleEntity.setMallName(pidEntity.getClientName()); stockArticleEntity.setMallName(pidEntity.getClientName());
stockArticleEntity.setMallCode(pidEntity.getClientCode()); stockArticleEntity.setMallCode(pidEntity.getClientCode());
BasicdataStoreBusinessEntity basicdataStoreBusinessEntity = basicdataStoreBusinessClient.findByClientIdAndTypeService(pidEntity.getId(), 3); BasicdataStoreBusinessEntity basicdataStoreBusinessEntity = basicdataStoreBusinessClient.findByClientIdAndTypeService(pidEntity.getId(), 3);
if(!Objects.isNull(basicdataStoreBusinessEntity)){ if (!Objects.isNull(basicdataStoreBusinessEntity)) {
stockArticleEntity.setTypeService(basicdataStoreBusinessEntity.getMold()); stockArticleEntity.setTypeService(basicdataStoreBusinessEntity.getMold());
} }
} }
} }
}else if("2".equals(clientType)){ } else if ("2".equals(clientType)) {
//商城 //商城
stockArticleEntity.setMallId(basicdataClientEntity.getId()); stockArticleEntity.setMallId(basicdataClientEntity.getId());
stockArticleEntity.setMallName(basicdataClientEntity.getClientName()); stockArticleEntity.setMallName(basicdataClientEntity.getClientName());
stockArticleEntity.setMallCode(basicdataClientEntity.getClientCode()); stockArticleEntity.setMallCode(basicdataClientEntity.getClientCode());
BasicdataStoreBusinessEntity basicdataStoreBusinessEntity = basicdataStoreBusinessClient.findByClientIdAndTypeService(basicdataClientEntity.getId(), 3); BasicdataStoreBusinessEntity basicdataStoreBusinessEntity = basicdataStoreBusinessClient.findByClientIdAndTypeService(basicdataClientEntity.getId(), 3);
if(!Objects.isNull(basicdataStoreBusinessEntity)){ if (!Objects.isNull(basicdataStoreBusinessEntity)) {
stockArticleEntity.setTypeService(basicdataStoreBusinessEntity.getMold()); stockArticleEntity.setTypeService(basicdataStoreBusinessEntity.getMold());
} }
} }
@ -221,17 +225,17 @@ public class TrunklineAdvanceServiceImpl extends BaseServiceImpl<TrunklineAdvanc
stockArticleEntity.setTransferQuantity(0); stockArticleEntity.setTransferQuantity(0);
stockArticleEntity.setSigninQuantity(0); stockArticleEntity.setSigninQuantity(0);
orderId = stockArticleClient.addData(stockArticleEntity); orderId = stockArticleClient.addData(stockArticleEntity);
}else{ } else {
stockArticleEntity.setTotalNumber(total); stockArticleEntity.setTotalNumber(total);
stockArticleClient.saveOrUpdate(stockArticleEntity); stockArticleClient.saveOrUpdate(stockArticleEntity);
orderId = stockArticleEntity.getId(); orderId = stockArticleEntity.getId();
} }
if(Objects.isNull(orderId)){ if (Objects.isNull(orderId)) {
log.warn("##############saveOrderAndPackage: 订单信息有误 orderId={}",orderId); log.warn("##############saveOrderAndPackage: 订单信息有误 orderId={}", orderId);
throw new CustomerException(405,"订单信息有误"); throw new CustomerException(405, "订单信息有误");
} }
log.info("#############saveOrderAndPackage: 订单信息保存成功 orderId={}",orderId); log.info("#############saveOrderAndPackage: 订单信息保存成功 orderId={}", orderId);
//保存包件信息 //保存包件信息
DistributionParcelListEntity parcelList = new DistributionParcelListEntity(); DistributionParcelListEntity parcelList = new DistributionParcelListEntity();
@ -243,9 +247,9 @@ public class TrunklineAdvanceServiceImpl extends BaseServiceImpl<TrunklineAdvanc
parcelList.setWarehouseId(warehouseId); parcelList.setWarehouseId(warehouseId);
parcelList.setIsTransfer(1); parcelList.setIsTransfer(1);
String waybillNo = advanceEntity.getWaybillNo(); String waybillNo = advanceEntity.getWaybillNo();
if(StringUtil.isNotBlank(waybillNo)){ if (StringUtil.isNotBlank(waybillNo)) {
WarehouseWaybillEntity waybillEntity = warehouseWaybillClient.findByWaybillNo(waybillNo); WarehouseWaybillEntity waybillEntity = warehouseWaybillClient.findByWaybillNo(waybillNo);
if(!Objects.isNull(waybillEntity)){ if (!Objects.isNull(waybillEntity)) {
parcelList.setWaybillId(waybillEntity.getId()); parcelList.setWaybillId(waybillEntity.getId());
parcelList.setWaybillNumber(waybillEntity.getWaybillNo()); parcelList.setWaybillNumber(waybillEntity.getWaybillNo());
parcelList.setSendWarehouseId(waybillEntity.getDepartureWarehouseId()); parcelList.setSendWarehouseId(waybillEntity.getDepartureWarehouseId());
@ -253,7 +257,7 @@ public class TrunklineAdvanceServiceImpl extends BaseServiceImpl<TrunklineAdvanc
Long destinationWarehouseId = waybillEntity.getDestinationWarehouseId(); Long destinationWarehouseId = waybillEntity.getDestinationWarehouseId();
parcelList.setAcceptWarehouseId(destinationWarehouseId); parcelList.setAcceptWarehouseId(destinationWarehouseId);
parcelList.setAcceptWarehouseName(waybillEntity.getDestinationWarehouseName()); parcelList.setAcceptWarehouseName(waybillEntity.getDestinationWarehouseName());
if(warehouseId.equals(destinationWarehouseId)){ if (warehouseId.equals(destinationWarehouseId)) {
parcelList.setIsTransfer(0); parcelList.setIsTransfer(0);
} }
} }
@ -273,17 +277,17 @@ public class TrunklineAdvanceServiceImpl extends BaseServiceImpl<TrunklineAdvanc
Long materialId = advanceDetailEntity.getMaterialId(); Long materialId = advanceDetailEntity.getMaterialId();
String materialCode = advanceDetailEntity.getMaterialCode(); String materialCode = advanceDetailEntity.getMaterialCode();
String materialName = advanceDetailEntity.getMaterialName(); String materialName = advanceDetailEntity.getMaterialName();
if(Objects.isNull(materialId)){ if (Objects.isNull(materialId)) {
BasicMaterialEntity materialEntity = basicMaterialClient.findEntityByCodeAndName(materialCode,materialName); BasicMaterialEntity materialEntity = basicMaterialClient.findEntityByCodeAndName(materialCode, materialName);
if(!Objects.isNull(materialEntity)){ if (!Objects.isNull(materialEntity)) {
parcelList.setMaterialId(materialEntity.getId()); parcelList.setMaterialId(materialEntity.getId());
parcelList.setMaterialName(materialEntity.getName()); parcelList.setMaterialName(materialEntity.getName());
parcelList.setMaterialCode(materialEntity.getProductCode()); parcelList.setMaterialCode(materialEntity.getProductCode());
parcelList.setMaterialUnit(materialEntity.getSpecification()); parcelList.setMaterialUnit(materialEntity.getSpecification());
} }
}else{ } else {
BasicMaterialEntity materialOwnId = basicMaterialClient.getMaterialOwnId(materialId); BasicMaterialEntity materialOwnId = basicMaterialClient.getMaterialOwnId(materialId);
if(!Objects.isNull(materialOwnId)){ if (!Objects.isNull(materialOwnId)) {
parcelList.setMaterialId(materialOwnId.getId()); parcelList.setMaterialId(materialOwnId.getId());
parcelList.setMaterialName(materialOwnId.getName()); parcelList.setMaterialName(materialOwnId.getName());
parcelList.setMaterialCode(materialOwnId.getProductCode()); parcelList.setMaterialCode(materialOwnId.getProductCode());
@ -302,8 +306,8 @@ public class TrunklineAdvanceServiceImpl extends BaseServiceImpl<TrunklineAdvanc
parcelList.setDealerCode(stockArticleEntity.getDealerCode()); parcelList.setDealerCode(stockArticleEntity.getDealerCode());
parcelList.setDealerName(stockArticleEntity.getDealerName()); parcelList.setDealerName(stockArticleEntity.getDealerName());
Long orderPackageId = parcelListClient.addReturnId(parcelList); Long orderPackageId = parcelListClient.addReturnId(parcelList);
if(!Objects.isNull(orderPackageId)){ if (!Objects.isNull(orderPackageId)) {
log.info("################saveOrderAndPackage: 包件信息保存成功 OrderPackageCode={}",advanceDetailEntity.getOrderPackageCode()); log.info("################saveOrderAndPackage: 包件信息保存成功 OrderPackageCode={}", advanceDetailEntity.getOrderPackageCode());
//1.修改订单在库件数和最后入库时间和入库状态 //1.修改订单在库件数和最后入库时间和入库状态
// List<DistributionParcelListEntity> parcelListEntityList = parcelListClient.findEntityListByOrderCode(orderCode, warehouseId); // List<DistributionParcelListEntity> parcelListEntityList = parcelListClient.findEntityListByOrderCode(orderCode, warehouseId);
@ -330,7 +334,7 @@ public class TrunklineAdvanceServiceImpl extends BaseServiceImpl<TrunklineAdvanc
// } // }
// stockArticleClient.saveOrUpdate(stockArticleEntity); // stockArticleClient.saveOrUpdate(stockArticleEntity);
} }
log.info("#############saveOrderAndPackage: 订单包件信息保存完成 OrderPackageCode={}",advanceDetailEntity.getOrderPackageCode()); log.info("#############saveOrderAndPackage: 订单包件信息保存完成 OrderPackageCode={}", advanceDetailEntity.getOrderPackageCode());
return true; return true;
} }
@ -375,23 +379,23 @@ public class TrunklineAdvanceServiceImpl extends BaseServiceImpl<TrunklineAdvanc
@Override @Override
public TrunklineAdvanceEntity findEntityByOrderCodeAndServiceNumAndTrainNumber(String orderCode, String trainNumber, String serviceNum) { public TrunklineAdvanceEntity findEntityByOrderCodeAndServiceNumAndTrainNumber(String orderCode, String trainNumber, String serviceNum) {
QueryWrapper<TrunklineAdvanceEntity> queryWrapper = new QueryWrapper<>(); QueryWrapper<TrunklineAdvanceEntity> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("order_code",orderCode) queryWrapper.eq("order_code", orderCode)
.eq("train_number",trainNumber) .eq("train_number", trainNumber)
.eq("service_num",serviceNum); .eq("service_num", serviceNum);
return baseMapper.selectOne(queryWrapper); return baseMapper.selectOne(queryWrapper);
} }
@Override @Override
public TrunklineAdvanceEntity findEntityByOrderCodeAndTrainNumber(String orderCode, String trainNumber) { public TrunklineAdvanceEntity findEntityByOrderCodeAndTrainNumber(String orderCode, String trainNumber) {
QueryWrapper<TrunklineAdvanceEntity> queryWrapper = new QueryWrapper<>(); QueryWrapper<TrunklineAdvanceEntity> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("order_code",orderCode) queryWrapper.eq("order_code", orderCode)
.eq("train_number",trainNumber); .eq("train_number", trainNumber);
return baseMapper.selectOne(queryWrapper); return baseMapper.selectOne(queryWrapper);
} }
@Override @Override
public void updateTotalNumById(Long id, int totalNum) { public void updateTotalNumById(Long id, int totalNum) {
baseMapper.updateTotalNumById(id,totalNum); baseMapper.updateTotalNumById(id, totalNum);
} }
@Override @Override
@ -401,7 +405,7 @@ public class TrunklineAdvanceServiceImpl extends BaseServiceImpl<TrunklineAdvanc
@Override @Override
public void updateIncomingWarehouseName(String incomingWarehouseName, Long advanceId) { public void updateIncomingWarehouseName(String incomingWarehouseName, Long advanceId) {
baseMapper.updateIncomingWarehouseName(incomingWarehouseName,advanceId); baseMapper.updateIncomingWarehouseName(incomingWarehouseName, advanceId);
} }
@Override @Override
@ -415,17 +419,17 @@ public class TrunklineAdvanceServiceImpl extends BaseServiceImpl<TrunklineAdvanc
Date date = new Date(); Date date = new Date();
BasicdataWarehouseEntity warehouseEntity = basicdataWarehouseClient.getEntityWarehouseId(warehouseId); BasicdataWarehouseEntity warehouseEntity = basicdataWarehouseClient.getEntityWarehouseId(warehouseId);
if(Objects.isNull(warehouseEntity)){ if (Objects.isNull(warehouseEntity)) {
log.warn("###############incomingPackageBatch: 仓库信息不存在 warehouseId={}",warehouseId); log.warn("###############incomingPackageBatch: 仓库信息不存在 warehouseId={}", warehouseId);
throw new CustomerException(405,"仓库信息不存在"); throw new CustomerException(405, "仓库信息不存在");
} }
String warehouseName = warehouseEntity.getName(); String warehouseName = warehouseEntity.getName();
//查询暂存单数据 //查询暂存单数据
TrunklineAdvanceEntity advanceEntity = baseMapper.selectById(advanceId); TrunklineAdvanceEntity advanceEntity = baseMapper.selectById(advanceId);
if(Objects.isNull(advanceEntity)){ if (Objects.isNull(advanceEntity)) {
log.warn("###############incomingPackageBatch: 暂存单信息不存在 advanceId={}",advanceId); log.warn("###############incomingPackageBatch: 暂存单信息不存在 advanceId={}", advanceId);
throw new CustomerException(405,"暂存单信息不存在"); throw new CustomerException(405, "暂存单信息不存在");
} }
String orderCode = advanceEntity.getOrderCode(); String orderCode = advanceEntity.getOrderCode();
@ -433,7 +437,7 @@ public class TrunklineAdvanceServiceImpl extends BaseServiceImpl<TrunklineAdvanc
Long orderId = null; Long orderId = null;
DistributionStockArticleEntity stockArticleEntity = stockArticleClient.findStockArticleByOrderCodeAndWarehouseId(orderCode, warehouseId); DistributionStockArticleEntity stockArticleEntity = stockArticleClient.findStockArticleByOrderCodeAndWarehouseId(orderCode, warehouseId);
if(Objects.isNull(stockArticleEntity)){ if (Objects.isNull(stockArticleEntity)) {
log.info("#############saveOrderAndPackage: 订单信息为空,同步订单信息"); log.info("#############saveOrderAndPackage: 订单信息为空,同步订单信息");
//订单信息为空 //订单信息为空
String waybillNo = advanceEntity.getWaybillNo(); String waybillNo = advanceEntity.getWaybillNo();
@ -463,16 +467,16 @@ public class TrunklineAdvanceServiceImpl extends BaseServiceImpl<TrunklineAdvanc
stockArticleEntity.setTypeService("1");//默认商配 stockArticleEntity.setTypeService("1");//默认商配
if(Objects.isNull(waybillEntity)){ if (Objects.isNull(waybillEntity)) {
if(!StringUtil.isBlank(waybillNo)){ if (!StringUtil.isBlank(waybillNo)) {
waybillEntity = warehouseWaybillClient.findByWaybillNo(waybillNo); waybillEntity = warehouseWaybillClient.findByWaybillNo(waybillNo);
if(Objects.isNull(waybillEntity)){ if (Objects.isNull(waybillEntity)) {
throw new CustomerException(405,"运单信息不存在"); throw new CustomerException(405, "运单信息不存在");
} }
Long consigneeId = waybillEntity.getConsigneeId(); Long consigneeId = waybillEntity.getConsigneeId();
BasicdataClientEntity clientEntity = basicdataClientClient.findEntityById(consigneeId); BasicdataClientEntity clientEntity = basicdataClientClient.findEntityById(consigneeId);
if(!Objects.isNull(clientEntity)){ if (!Objects.isNull(clientEntity)) {
stockArticleEntity.setMallId(clientEntity.getId()); stockArticleEntity.setMallId(clientEntity.getId());
stockArticleEntity.setMallName(clientEntity.getClientName()); stockArticleEntity.setMallName(clientEntity.getClientName());
stockArticleEntity.setMallCode(clientEntity.getClientCode()); stockArticleEntity.setMallCode(clientEntity.getClientCode());
@ -487,53 +491,53 @@ public class TrunklineAdvanceServiceImpl extends BaseServiceImpl<TrunklineAdvanc
stockArticleEntity.setConsigneeAddress(consigneeAddress); stockArticleEntity.setConsigneeAddress(consigneeAddress);
BasicdataStoreBusinessEntity basicdataStoreBusinessEntity = basicdataStoreBusinessClient.findByClientIdAndTypeService(consigneeId, 3); BasicdataStoreBusinessEntity basicdataStoreBusinessEntity = basicdataStoreBusinessClient.findByClientIdAndTypeService(consigneeId, 3);
if(!Objects.isNull(basicdataStoreBusinessEntity)){ if (!Objects.isNull(basicdataStoreBusinessEntity)) {
stockArticleEntity.setTypeService(basicdataStoreBusinessEntity.getMold()); stockArticleEntity.setTypeService(basicdataStoreBusinessEntity.getMold());
} }
}else{ } else {
Long clientId = basicdataTripartiteMallClient.getClientIdByNameAndBrand(dealerName, advanceEntity.getBrand()); Long clientId = basicdataTripartiteMallClient.getClientIdByNameAndBrand(dealerName, advanceEntity.getBrand());
BasicdataClientEntity basicdataClientEntity = basicdataClientClient.findEntityById(clientId); BasicdataClientEntity basicdataClientEntity = basicdataClientClient.findEntityById(clientId);
if(!Objects.isNull(basicdataClientEntity)){ if (!Objects.isNull(basicdataClientEntity)) {
String clientType = basicdataClientEntity.getClientType(); String clientType = basicdataClientEntity.getClientType();
if("5".equals(clientType)){ if ("5".equals(clientType)) {
stockArticleEntity.setStoreId(basicdataClientEntity.getId()); stockArticleEntity.setStoreId(basicdataClientEntity.getId());
stockArticleEntity.setStoreCode(basicdataClientEntity.getClientCode()); stockArticleEntity.setStoreCode(basicdataClientEntity.getClientCode());
stockArticleEntity.setStoreName(basicdataClientEntity.getClientName()); stockArticleEntity.setStoreName(basicdataClientEntity.getClientName());
//查询门店的父级商场 //查询门店的父级商场
Long pid = basicdataClientEntity.getPid(); Long pid = basicdataClientEntity.getPid();
BasicdataClientEntity pidEntity = basicdataClientClient.findEntityById(pid); BasicdataClientEntity pidEntity = basicdataClientClient.findEntityById(pid);
if(!Objects.isNull(pidEntity)){ if (!Objects.isNull(pidEntity)) {
String pidEntityClientType = pidEntity.getClientType(); String pidEntityClientType = pidEntity.getClientType();
if("2".equals(pidEntityClientType)){ if ("2".equals(pidEntityClientType)) {
//商城 //商城
stockArticleEntity.setMallId(pidEntity.getId()); stockArticleEntity.setMallId(pidEntity.getId());
stockArticleEntity.setMallName(pidEntity.getClientName()); stockArticleEntity.setMallName(pidEntity.getClientName());
stockArticleEntity.setMallCode(pidEntity.getClientCode()); stockArticleEntity.setMallCode(pidEntity.getClientCode());
BasicdataStoreBusinessEntity basicdataStoreBusinessEntity = basicdataStoreBusinessClient.findByClientIdAndTypeService(pidEntity.getId(), 3); BasicdataStoreBusinessEntity basicdataStoreBusinessEntity = basicdataStoreBusinessClient.findByClientIdAndTypeService(pidEntity.getId(), 3);
if(!Objects.isNull(basicdataStoreBusinessEntity)){ if (!Objects.isNull(basicdataStoreBusinessEntity)) {
stockArticleEntity.setTypeService(basicdataStoreBusinessEntity.getMold()); stockArticleEntity.setTypeService(basicdataStoreBusinessEntity.getMold());
} }
} }
} }
}else if("2".equals(clientType)){ } else if ("2".equals(clientType)) {
//商城 //商城
stockArticleEntity.setMallId(basicdataClientEntity.getId()); stockArticleEntity.setMallId(basicdataClientEntity.getId());
stockArticleEntity.setMallName(basicdataClientEntity.getClientName()); stockArticleEntity.setMallName(basicdataClientEntity.getClientName());
stockArticleEntity.setMallCode(basicdataClientEntity.getClientCode()); stockArticleEntity.setMallCode(basicdataClientEntity.getClientCode());
BasicdataStoreBusinessEntity basicdataStoreBusinessEntity = basicdataStoreBusinessClient.findByClientIdAndTypeService(basicdataClientEntity.getId(), 3); BasicdataStoreBusinessEntity basicdataStoreBusinessEntity = basicdataStoreBusinessClient.findByClientIdAndTypeService(basicdataClientEntity.getId(), 3);
if(!Objects.isNull(basicdataStoreBusinessEntity)){ if (!Objects.isNull(basicdataStoreBusinessEntity)) {
stockArticleEntity.setTypeService(basicdataStoreBusinessEntity.getMold()); stockArticleEntity.setTypeService(basicdataStoreBusinessEntity.getMold());
} }
} }
} }
} }
}else{ } else {
Long consigneeId = waybillEntity.getConsigneeId(); Long consigneeId = waybillEntity.getConsigneeId();
BasicdataClientEntity clientEntity = basicdataClientClient.findEntityById(consigneeId); BasicdataClientEntity clientEntity = basicdataClientClient.findEntityById(consigneeId);
if(!Objects.isNull(clientEntity)){ if (!Objects.isNull(clientEntity)) {
stockArticleEntity.setMallId(clientEntity.getId()); stockArticleEntity.setMallId(clientEntity.getId());
stockArticleEntity.setMallName(clientEntity.getClientName()); stockArticleEntity.setMallName(clientEntity.getClientName());
stockArticleEntity.setMallCode(clientEntity.getClientCode()); stockArticleEntity.setMallCode(clientEntity.getClientCode());
@ -548,7 +552,7 @@ public class TrunklineAdvanceServiceImpl extends BaseServiceImpl<TrunklineAdvanc
stockArticleEntity.setConsigneeAddress(consigneeAddress); stockArticleEntity.setConsigneeAddress(consigneeAddress);
BasicdataStoreBusinessEntity basicdataStoreBusinessEntity = basicdataStoreBusinessClient.findByClientIdAndTypeService(consigneeId, 3); BasicdataStoreBusinessEntity basicdataStoreBusinessEntity = basicdataStoreBusinessClient.findByClientIdAndTypeService(consigneeId, 3);
if(!Objects.isNull(basicdataStoreBusinessEntity)){ if (!Objects.isNull(basicdataStoreBusinessEntity)) {
stockArticleEntity.setTypeService(basicdataStoreBusinessEntity.getMold()); stockArticleEntity.setTypeService(basicdataStoreBusinessEntity.getMold());
} }
} }
@ -570,17 +574,17 @@ public class TrunklineAdvanceServiceImpl extends BaseServiceImpl<TrunklineAdvanc
stockArticleEntity.setTransferQuantity(0); stockArticleEntity.setTransferQuantity(0);
stockArticleEntity.setSigninQuantity(0); stockArticleEntity.setSigninQuantity(0);
orderId = stockArticleClient.addData(stockArticleEntity); orderId = stockArticleClient.addData(stockArticleEntity);
}else{ } else {
stockArticleEntity.setTotalNumber(total); stockArticleEntity.setTotalNumber(total);
stockArticleClient.saveOrUpdate(stockArticleEntity); stockArticleClient.saveOrUpdate(stockArticleEntity);
orderId = stockArticleEntity.getId(); orderId = stockArticleEntity.getId();
} }
if(Objects.isNull(orderId)){ if (Objects.isNull(orderId)) {
log.warn("##############saveOrderAndPackage: 订单信息有误 orderId={}",orderId); log.warn("##############saveOrderAndPackage: 订单信息有误 orderId={}", orderId);
throw new CustomerException(405,"订单信息有误"); throw new CustomerException(405, "订单信息有误");
} }
stockArticleClient.updateAllOrderTotalNum(orderCode,total); stockArticleClient.updateAllOrderTotalNum(orderCode, total);
List<DistributionParcelListEntity> parcelListEntityList = new ArrayList<>(); List<DistributionParcelListEntity> parcelListEntityList = new ArrayList<>();
List<String> orderPackageCodes = new ArrayList<>(); List<String> orderPackageCodes = new ArrayList<>();
@ -597,7 +601,7 @@ public class TrunklineAdvanceServiceImpl extends BaseServiceImpl<TrunklineAdvanc
parcelList.setWarehouse(warehouseEntity.getName()); parcelList.setWarehouse(warehouseEntity.getName());
parcelList.setWarehouseId(warehouseId); parcelList.setWarehouseId(warehouseId);
String waybillNo = advanceEntity.getWaybillNo(); String waybillNo = advanceEntity.getWaybillNo();
if(!Objects.isNull(waybillEntity)){ if (!Objects.isNull(waybillEntity)) {
Long departureWarehouseId = waybillEntity.getDepartureWarehouseId(); Long departureWarehouseId = waybillEntity.getDepartureWarehouseId();
Long destinationWarehouseId = waybillEntity.getDestinationWarehouseId(); Long destinationWarehouseId = waybillEntity.getDestinationWarehouseId();
parcelList.setWaybillId(waybillEntity.getId()); parcelList.setWaybillId(waybillEntity.getId());
@ -606,7 +610,7 @@ public class TrunklineAdvanceServiceImpl extends BaseServiceImpl<TrunklineAdvanc
parcelList.setSendWarehouseName(waybillEntity.getDepartureWarehouseName()); parcelList.setSendWarehouseName(waybillEntity.getDepartureWarehouseName());
parcelList.setAcceptWarehouseId(destinationWarehouseId); parcelList.setAcceptWarehouseId(destinationWarehouseId);
parcelList.setAcceptWarehouseName(waybillEntity.getDestinationWarehouseName()); parcelList.setAcceptWarehouseName(waybillEntity.getDestinationWarehouseName());
if(departureWarehouseId.equals(destinationWarehouseId)){ if (departureWarehouseId.equals(destinationWarehouseId)) {
parcelList.setIsTransfer(0); parcelList.setIsTransfer(0);
} }
} }
@ -625,17 +629,17 @@ public class TrunklineAdvanceServiceImpl extends BaseServiceImpl<TrunklineAdvanc
Long materialId = advanceDetailEntity.getMaterialId(); Long materialId = advanceDetailEntity.getMaterialId();
String materialCode = advanceDetailEntity.getMaterialCode(); String materialCode = advanceDetailEntity.getMaterialCode();
String materialName = advanceDetailEntity.getMaterialName(); String materialName = advanceDetailEntity.getMaterialName();
if(Objects.isNull(materialId)){ if (Objects.isNull(materialId)) {
BasicMaterialEntity materialEntity = basicMaterialClient.findEntityByCodeAndName(materialCode,materialName); BasicMaterialEntity materialEntity = basicMaterialClient.findEntityByCodeAndName(materialCode, materialName);
if(!Objects.isNull(materialEntity)){ if (!Objects.isNull(materialEntity)) {
parcelList.setMaterialId(materialEntity.getId()); parcelList.setMaterialId(materialEntity.getId());
parcelList.setMaterialName(materialEntity.getName()); parcelList.setMaterialName(materialEntity.getName());
parcelList.setMaterialCode(materialEntity.getProductCode()); parcelList.setMaterialCode(materialEntity.getProductCode());
parcelList.setMaterialUnit(materialEntity.getSpecification()); parcelList.setMaterialUnit(materialEntity.getSpecification());
} }
}else{ } else {
BasicMaterialEntity materialOwnId = basicMaterialClient.getMaterialOwnId(materialId); BasicMaterialEntity materialOwnId = basicMaterialClient.getMaterialOwnId(materialId);
if(!Objects.isNull(materialOwnId)){ if (!Objects.isNull(materialOwnId)) {
parcelList.setMaterialId(materialOwnId.getId()); parcelList.setMaterialId(materialOwnId.getId());
parcelList.setMaterialName(materialOwnId.getName()); parcelList.setMaterialName(materialOwnId.getName());
parcelList.setMaterialCode(materialOwnId.getProductCode()); parcelList.setMaterialCode(materialOwnId.getProductCode());
@ -664,7 +668,7 @@ public class TrunklineAdvanceServiceImpl extends BaseServiceImpl<TrunklineAdvanc
} }
parcelListClient.addBatch(parcelListEntityList); parcelListClient.addBatch(parcelListEntityList);
try { try {
if(CollUtil.isNotEmpty(parcelListEntityList)){ if (CollUtil.isNotEmpty(parcelListEntityList)) {
for (DistributionParcelListEntity parcelListEntity : parcelListEntityList) { for (DistributionParcelListEntity parcelListEntity : parcelListEntityList) {
// 发送入库消息 // 发送入库消息
OrderStatusDTO orderStatusDTO = new OrderStatusDTO(); OrderStatusDTO orderStatusDTO = new OrderStatusDTO();
@ -694,19 +698,19 @@ public class TrunklineAdvanceServiceImpl extends BaseServiceImpl<TrunklineAdvanc
public boolean saveOrderAndPackages(List<TrunklineAdvanceDetailEntity> advanceDetailEntities, Long warehouseId) { public boolean saveOrderAndPackages(List<TrunklineAdvanceDetailEntity> advanceDetailEntities, Long warehouseId) {
BasicdataWarehouseEntity warehouseEntity = basicdataWarehouseClient.getEntityWarehouseId(warehouseId); BasicdataWarehouseEntity warehouseEntity = basicdataWarehouseClient.getEntityWarehouseId(warehouseId);
if(Objects.isNull(warehouseEntity)){ if (Objects.isNull(warehouseEntity)) {
log.warn("############saveOrderAndPackages: 仓库信息不存在warehouseId={}",warehouseId); log.warn("############saveOrderAndPackages: 仓库信息不存在warehouseId={}", warehouseId);
throw new CustomerException(405,"仓库信息不存在"); throw new CustomerException(405, "仓库信息不存在");
} }
TrunklineAdvanceDetailEntity advanceDetailEntity = advanceDetailEntities.get(0); TrunklineAdvanceDetailEntity advanceDetailEntity = advanceDetailEntities.get(0);
String tenantId = advanceDetailEntity.getTenantId(); String tenantId = advanceDetailEntity.getTenantId();
Long userId = AuthUtil.getUserId(); Long userId = AuthUtil.getUserId();
Long deptId = Func.firstLong(AuthUtil.getDeptId()); Long deptId = Func.firstLong(AuthUtil.getDeptId());
if(Objects.isNull(userId)){ if (Objects.isNull(userId)) {
userId = advanceDetailEntity.getCreateUser(); userId = advanceDetailEntity.getCreateUser();
} }
if(Objects.isNull(deptId)){ if (Objects.isNull(deptId)) {
userId = advanceDetailEntity.getCreateDept(); userId = advanceDetailEntity.getCreateDept();
} }
@ -725,21 +729,21 @@ public class TrunklineAdvanceServiceImpl extends BaseServiceImpl<TrunklineAdvanc
Set<Long> advanceIdSet = advanceDetailEntities.stream().map(TrunklineAdvanceDetailEntity::getAdvanceId).collect(Collectors.toSet()); Set<Long> advanceIdSet = advanceDetailEntities.stream().map(TrunklineAdvanceDetailEntity::getAdvanceId).collect(Collectors.toSet());
List<TrunklineAdvanceEntity> advanceEntityList = findListByIds(new ArrayList<>(advanceIdSet)); List<TrunklineAdvanceEntity> advanceEntityList = findListByIds(new ArrayList<>(advanceIdSet));
Map<String,TrunklineAdvanceEntity> advanceEntityMap = new HashMap<>(); Map<String, TrunklineAdvanceEntity> advanceEntityMap = new HashMap<>();
if(!advanceEntityList.isEmpty()){ if (!advanceEntityList.isEmpty()) {
advanceEntityMap = advanceEntityList.stream().collect(Collectors.toMap(TrunklineAdvanceEntity::getOrderCode, Function.identity())); advanceEntityMap = advanceEntityList.stream().collect(Collectors.toMap(TrunklineAdvanceEntity::getOrderCode, Function.identity()));
} }
List<DistributionStockArticleEntity> stockArticleEntities = stockArticleClient.findListByOrderCodesAndWarehouseId(orderCodeSet,warehouseId); List<DistributionStockArticleEntity> stockArticleEntities = stockArticleClient.findListByOrderCodesAndWarehouseId(orderCodeSet, warehouseId);
Map<String, DistributionStockArticleEntity> stockArticleMap = new HashMap<>(); Map<String, DistributionStockArticleEntity> stockArticleMap = new HashMap<>();
if(!stockArticleEntities.isEmpty()){ if (!stockArticleEntities.isEmpty()) {
stockArticleMap = stockArticleEntities.stream().collect(Collectors.toMap(DistributionStockArticleEntity::getOrderCode, Function.identity())); stockArticleMap = stockArticleEntities.stream().collect(Collectors.toMap(DistributionStockArticleEntity::getOrderCode, Function.identity()));
} }
List<DistributionParcelListEntity> parcelListEntities = parcelListClient.findListByOrderCodesAndWarehouseId(orderCodeSet,warehouseId); List<DistributionParcelListEntity> parcelListEntities = parcelListClient.findListByOrderCodesAndWarehouseId(orderCodeSet, warehouseId);
Map<String, DistributionParcelListEntity> parcelListMap = new HashMap<>(); Map<String, DistributionParcelListEntity> parcelListMap = new HashMap<>();
if(!parcelListEntities.isEmpty()){ if (!parcelListEntities.isEmpty()) {
parcelListMap = parcelListEntities.stream().collect(Collectors.toMap(DistributionParcelListEntity::getOrderPackageCode, Function.identity())); parcelListMap = parcelListEntities.stream().collect(Collectors.toMap(DistributionParcelListEntity::getOrderPackageCode, Function.identity()));
} }
@ -758,9 +762,9 @@ public class TrunklineAdvanceServiceImpl extends BaseServiceImpl<TrunklineAdvanc
int total = baseMapper.getAllTotalNum(orderCode); int total = baseMapper.getAllTotalNum(orderCode);
DistributionStockArticleEntity stockArticleEntity = finalStockArticleMap.get(orderCode); DistributionStockArticleEntity stockArticleEntity = finalStockArticleMap.get(orderCode);
if(Objects.isNull(stockArticleEntity)){ if (Objects.isNull(stockArticleEntity)) {
TrunklineAdvanceEntity advanceEntity = finalAdvanceEntityMap.get(orderCode); TrunklineAdvanceEntity advanceEntity = finalAdvanceEntityMap.get(orderCode);
if(!Objects.isNull(advanceEntity)){ if (!Objects.isNull(advanceEntity)) {
String waybillNo = advanceEntity.getWaybillNo(); String waybillNo = advanceEntity.getWaybillNo();
stockArticleEntity = new DistributionStockArticleEntity(); stockArticleEntity = new DistributionStockArticleEntity();
@ -787,13 +791,13 @@ public class TrunklineAdvanceServiceImpl extends BaseServiceImpl<TrunklineAdvanc
stockArticleEntity.setTypeService("1");//默认商配 stockArticleEntity.setTypeService("1");//默认商配
if(!StringUtil.isBlank(waybillNo)){ if (!StringUtil.isBlank(waybillNo)) {
WarehouseWaybillEntity waybillEntity = waybillEntityMap.get(waybillNo); WarehouseWaybillEntity waybillEntity = waybillEntityMap.get(waybillNo);
if(!Objects.isNull(waybillEntity)){ if (!Objects.isNull(waybillEntity)) {
Long consigneeId = waybillEntity.getConsigneeId(); Long consigneeId = waybillEntity.getConsigneeId();
BasicdataClientEntity clientEntity = basicdataClientClient.findEntityById(consigneeId); BasicdataClientEntity clientEntity = basicdataClientClient.findEntityById(consigneeId);
if(!Objects.isNull(clientEntity)){ if (!Objects.isNull(clientEntity)) {
stockArticleEntity.setMallId(clientEntity.getId()); stockArticleEntity.setMallId(clientEntity.getId());
stockArticleEntity.setMallName(clientEntity.getClientName()); stockArticleEntity.setMallName(clientEntity.getClientName());
stockArticleEntity.setMallCode(clientEntity.getClientCode()); stockArticleEntity.setMallCode(clientEntity.getClientCode());
@ -808,44 +812,44 @@ public class TrunklineAdvanceServiceImpl extends BaseServiceImpl<TrunklineAdvanc
stockArticleEntity.setConsigneeAddress(consigneeAddress); stockArticleEntity.setConsigneeAddress(consigneeAddress);
BasicdataStoreBusinessEntity basicdataStoreBusinessEntity = basicdataStoreBusinessClient.findByClientIdAndTypeService(consigneeId, 3); BasicdataStoreBusinessEntity basicdataStoreBusinessEntity = basicdataStoreBusinessClient.findByClientIdAndTypeService(consigneeId, 3);
if(!Objects.isNull(basicdataStoreBusinessEntity)){ if (!Objects.isNull(basicdataStoreBusinessEntity)) {
stockArticleEntity.setTypeService(basicdataStoreBusinessEntity.getMold()); stockArticleEntity.setTypeService(basicdataStoreBusinessEntity.getMold());
} }
} }
}else{ } else {
Long clientId = basicdataTripartiteMallClient.getClientIdByNameAndBrand(dealerName, advanceEntity.getBrand()); Long clientId = basicdataTripartiteMallClient.getClientIdByNameAndBrand(dealerName, advanceEntity.getBrand());
BasicdataClientEntity basicdataClientEntity = basicdataClientClient.findEntityById(clientId); BasicdataClientEntity basicdataClientEntity = basicdataClientClient.findEntityById(clientId);
if(!Objects.isNull(basicdataClientEntity)){ if (!Objects.isNull(basicdataClientEntity)) {
String clientType = basicdataClientEntity.getClientType(); String clientType = basicdataClientEntity.getClientType();
if("5".equals(clientType)){ if ("5".equals(clientType)) {
stockArticleEntity.setStoreId(basicdataClientEntity.getId()); stockArticleEntity.setStoreId(basicdataClientEntity.getId());
stockArticleEntity.setStoreCode(basicdataClientEntity.getClientCode()); stockArticleEntity.setStoreCode(basicdataClientEntity.getClientCode());
stockArticleEntity.setStoreName(basicdataClientEntity.getClientName()); stockArticleEntity.setStoreName(basicdataClientEntity.getClientName());
//查询门店的父级商场 //查询门店的父级商场
Long pid = basicdataClientEntity.getPid(); Long pid = basicdataClientEntity.getPid();
BasicdataClientEntity pidEntity = basicdataClientClient.findEntityById(pid); BasicdataClientEntity pidEntity = basicdataClientClient.findEntityById(pid);
if(!Objects.isNull(pidEntity)){ if (!Objects.isNull(pidEntity)) {
String pidEntityClientType = pidEntity.getClientType(); String pidEntityClientType = pidEntity.getClientType();
if("2".equals(pidEntityClientType)){ if ("2".equals(pidEntityClientType)) {
//商城 //商城
stockArticleEntity.setMallId(pidEntity.getId()); stockArticleEntity.setMallId(pidEntity.getId());
stockArticleEntity.setMallName(pidEntity.getClientName()); stockArticleEntity.setMallName(pidEntity.getClientName());
stockArticleEntity.setMallCode(pidEntity.getClientCode()); stockArticleEntity.setMallCode(pidEntity.getClientCode());
BasicdataStoreBusinessEntity basicdataStoreBusinessEntity = basicdataStoreBusinessClient.findByClientIdAndTypeService(pidEntity.getId(), 3); BasicdataStoreBusinessEntity basicdataStoreBusinessEntity = basicdataStoreBusinessClient.findByClientIdAndTypeService(pidEntity.getId(), 3);
if(!Objects.isNull(basicdataStoreBusinessEntity)){ if (!Objects.isNull(basicdataStoreBusinessEntity)) {
stockArticleEntity.setTypeService(basicdataStoreBusinessEntity.getMold()); stockArticleEntity.setTypeService(basicdataStoreBusinessEntity.getMold());
} }
} }
} }
}else if("2".equals(clientType)){ } else if ("2".equals(clientType)) {
//商城 //商城
stockArticleEntity.setMallId(basicdataClientEntity.getId()); stockArticleEntity.setMallId(basicdataClientEntity.getId());
stockArticleEntity.setMallName(basicdataClientEntity.getClientName()); stockArticleEntity.setMallName(basicdataClientEntity.getClientName());
stockArticleEntity.setMallCode(basicdataClientEntity.getClientCode()); stockArticleEntity.setMallCode(basicdataClientEntity.getClientCode());
BasicdataStoreBusinessEntity basicdataStoreBusinessEntity = basicdataStoreBusinessClient.findByClientIdAndTypeService(basicdataClientEntity.getId(), 3); BasicdataStoreBusinessEntity basicdataStoreBusinessEntity = basicdataStoreBusinessClient.findByClientIdAndTypeService(basicdataClientEntity.getId(), 3);
if(!Objects.isNull(basicdataStoreBusinessEntity)){ if (!Objects.isNull(basicdataStoreBusinessEntity)) {
stockArticleEntity.setTypeService(basicdataStoreBusinessEntity.getMold()); stockArticleEntity.setTypeService(basicdataStoreBusinessEntity.getMold());
} }
} }
@ -869,7 +873,7 @@ public class TrunklineAdvanceServiceImpl extends BaseServiceImpl<TrunklineAdvanc
stockArticleEntity.setSigninQuantity(0); stockArticleEntity.setSigninQuantity(0);
addStockArticleEntities.add(stockArticleEntity); addStockArticleEntities.add(stockArticleEntity);
} }
}else{ } else {
stockArticleEntity.setTotalNumber(total); stockArticleEntity.setTotalNumber(total);
updateStockArticleEntities.add(stockArticleEntity); updateStockArticleEntities.add(stockArticleEntity);
} }
@ -879,17 +883,17 @@ public class TrunklineAdvanceServiceImpl extends BaseServiceImpl<TrunklineAdvanc
List<DistributionStockArticleEntity> returnStockArticleEntities = stockArticleClient.addReturnList(addStockArticleEntities); List<DistributionStockArticleEntity> returnStockArticleEntities = stockArticleClient.addReturnList(addStockArticleEntities);
returnStockArticleEntities.addAll(updateStockArticleEntities); returnStockArticleEntities.addAll(updateStockArticleEntities);
Map<String,DistributionStockArticleEntity> saMap = returnStockArticleEntities.stream().collect(Collectors.toMap(DistributionStockArticleEntity::getOrderCode, Function.identity())); Map<String, DistributionStockArticleEntity> saMap = returnStockArticleEntities.stream().collect(Collectors.toMap(DistributionStockArticleEntity::getOrderCode, Function.identity()));
List<DistributionParcelListEntity> parcelListEntityList = new ArrayList<>(); List<DistributionParcelListEntity> parcelListEntityList = new ArrayList<>();
orderCodeMap.keySet().forEach(orderCode->{ orderCodeMap.keySet().forEach(orderCode -> {
DistributionStockArticleEntity stockArticleEntity = saMap.get(orderCode); DistributionStockArticleEntity stockArticleEntity = saMap.get(orderCode);
if(!Objects.isNull(stockArticleEntity)){ if (!Objects.isNull(stockArticleEntity)) {
Long orderId = stockArticleEntity.getId(); Long orderId = stockArticleEntity.getId();
List<TrunklineAdvanceDetailEntity> adList = orderCodeMap.get(orderCode); List<TrunklineAdvanceDetailEntity> adList = orderCodeMap.get(orderCode);
adList.forEach(ad->{ adList.forEach(ad -> {
String orderPackageCode = ad.getOrderPackageCode(); String orderPackageCode = ad.getOrderPackageCode();
if(!hasOrderPackageCodes.contains(orderPackageCode)){ if (!hasOrderPackageCodes.contains(orderPackageCode)) {
String trainNumber = ad.getTrainNumber(); String trainNumber = ad.getTrainNumber();
DistributionParcelListEntity parcelList = new DistributionParcelListEntity(); DistributionParcelListEntity parcelList = new DistributionParcelListEntity();
parcelList.setCreateUser(finalUserId); parcelList.setCreateUser(finalUserId);
@ -900,9 +904,9 @@ public class TrunklineAdvanceServiceImpl extends BaseServiceImpl<TrunklineAdvanc
parcelList.setWarehouseId(warehouseId); parcelList.setWarehouseId(warehouseId);
parcelList.setIsTransfer(1); parcelList.setIsTransfer(1);
String waybillNo = ad.getWaybillNo(); String waybillNo = ad.getWaybillNo();
if(StringUtil.isNotBlank(waybillNo)){ if (StringUtil.isNotBlank(waybillNo)) {
WarehouseWaybillEntity waybillEntity = waybillEntityMap.get(waybillNo); WarehouseWaybillEntity waybillEntity = waybillEntityMap.get(waybillNo);
if(!Objects.isNull(waybillEntity)){ if (!Objects.isNull(waybillEntity)) {
parcelList.setWaybillId(waybillEntity.getId()); parcelList.setWaybillId(waybillEntity.getId());
parcelList.setWaybillNumber(waybillEntity.getWaybillNo()); parcelList.setWaybillNumber(waybillEntity.getWaybillNo());
parcelList.setSendWarehouseId(waybillEntity.getDepartureWarehouseId()); parcelList.setSendWarehouseId(waybillEntity.getDepartureWarehouseId());
@ -910,7 +914,7 @@ public class TrunklineAdvanceServiceImpl extends BaseServiceImpl<TrunklineAdvanc
Long destinationWarehouseId = waybillEntity.getDestinationWarehouseId(); Long destinationWarehouseId = waybillEntity.getDestinationWarehouseId();
parcelList.setAcceptWarehouseId(destinationWarehouseId); parcelList.setAcceptWarehouseId(destinationWarehouseId);
parcelList.setAcceptWarehouseName(waybillEntity.getDestinationWarehouseName()); parcelList.setAcceptWarehouseName(waybillEntity.getDestinationWarehouseName());
if(warehouseId.equals(destinationWarehouseId)){ if (warehouseId.equals(destinationWarehouseId)) {
parcelList.setIsTransfer(0); parcelList.setIsTransfer(0);
} }
} }
@ -930,17 +934,17 @@ public class TrunklineAdvanceServiceImpl extends BaseServiceImpl<TrunklineAdvanc
Long materialId = advanceDetailEntity.getMaterialId(); Long materialId = advanceDetailEntity.getMaterialId();
String materialCode = advanceDetailEntity.getMaterialCode(); String materialCode = advanceDetailEntity.getMaterialCode();
String materialName = advanceDetailEntity.getMaterialName(); String materialName = advanceDetailEntity.getMaterialName();
if(Objects.isNull(materialId)){ if (Objects.isNull(materialId)) {
BasicMaterialEntity materialEntity = basicMaterialClient.findEntityByCodeAndName(materialCode,materialName); BasicMaterialEntity materialEntity = basicMaterialClient.findEntityByCodeAndName(materialCode, materialName);
if(!Objects.isNull(materialEntity)){ if (!Objects.isNull(materialEntity)) {
parcelList.setMaterialId(materialEntity.getId()); parcelList.setMaterialId(materialEntity.getId());
parcelList.setMaterialName(materialEntity.getName()); parcelList.setMaterialName(materialEntity.getName());
parcelList.setMaterialCode(materialEntity.getProductCode()); parcelList.setMaterialCode(materialEntity.getProductCode());
parcelList.setMaterialUnit(materialEntity.getSpecification()); parcelList.setMaterialUnit(materialEntity.getSpecification());
} }
}else{ } else {
BasicMaterialEntity materialOwnId = basicMaterialClient.getMaterialOwnId(materialId); BasicMaterialEntity materialOwnId = basicMaterialClient.getMaterialOwnId(materialId);
if(!Objects.isNull(materialOwnId)){ if (!Objects.isNull(materialOwnId)) {
parcelList.setMaterialId(materialOwnId.getId()); parcelList.setMaterialId(materialOwnId.getId());
parcelList.setMaterialName(materialOwnId.getName()); parcelList.setMaterialName(materialOwnId.getName());
parcelList.setMaterialCode(materialOwnId.getProductCode()); parcelList.setMaterialCode(materialOwnId.getProductCode());
@ -966,8 +970,8 @@ public class TrunklineAdvanceServiceImpl extends BaseServiceImpl<TrunklineAdvanc
parcelListClient.addBatch(parcelListEntityList); parcelListClient.addBatch(parcelListEntityList);
orderCodeSet.forEach(orderCode->{ orderCodeSet.forEach(orderCode -> {
stockArticleClient.updateOrderInfo(orderCode,warehouseId); stockArticleClient.updateOrderInfo(orderCode, warehouseId);
}); });
@ -1240,4 +1244,28 @@ public class TrunklineAdvanceServiceImpl extends BaseServiceImpl<TrunklineAdvanc
return true; return true;
} }
@Override
@Transactional(rollbackFor = Exception.class)
public Boolean cancelOrder(String orderCode) {
List<TrunklineAdvanceDetailEntity> list = advanceDetailService.list(Wrappers.<TrunklineAdvanceDetailEntity>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.<TrunklineAdvanceDetailEntity>lambdaUpdate()
.eq(TrunklineAdvanceDetailEntity::getOrderCode, orderCode)
.set(TrunklineAdvanceDetailEntity::getIsDeleted, "1")
);
boolean advanceUpdate = this.update(Wrappers.<TrunklineAdvanceEntity>lambdaUpdate()
.eq(TrunklineAdvanceEntity::getOrderCode, orderCode)
.set(TrunklineAdvanceEntity::getIsDeleted, "1")
);
return detailUpdate && advanceUpdate;
}
} }

30
blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/impl/TrunklineCarsLoadServiceImpl.java

@ -392,22 +392,20 @@ public class TrunklineCarsLoadServiceImpl extends BaseServiceImpl<TrunklineCarsL
warehouseAddress = "到达【" + warehouseEntity.getName() + "】"; warehouseAddress = "到达【" + warehouseEntity.getName() + "】";
} }
} }
NodePushMsg msg = new NodePushMsg(); NodePushMsg msg = NodePushMsg.builder()
msg.setNode(node); .operator(AuthUtil.getNickName())
msg.setBrand(BrandEnums.getByValue(brand.getBrand())); .operatorTime(new Date())
msg.setOperator(AuthUtil.getUser().getNickName()); .address(warehouseAddress)
msg.setOperatorTime(new Date()); .brand(BrandEnums.getByValue(brand.getBrand()))
msg.setAddress(warehouseAddress); .node(WorkNodeEnums.INITIAL_WAREHOUSE_ENTRY)
List<Object> contents = new ArrayList<>(); .content(StrUtil.split(packageCode, ",").stream().map(data->{
ArrayList<String> codes = CollUtil.newArrayList(packageCode.split(",")); return PushData.builder()
if (CollUtil.isNotEmpty(codes)) { .packageCode(data)
for (String code : codes) { .warehouseName(warehouseEntity.getName())
JSONObject jsonObject = new JSONObject(); .orderCode(brand.getOrderCode())
jsonObject.put("packageCode", code); .build();
contents.add(jsonObject); }).collect(Collectors.toList()))
} .build();
}
msg.setContent(contents);
log.info("推送工厂数据:{}", JSONUtil.toJsonStr(msg)); log.info("推送工厂数据:{}", JSONUtil.toJsonStr(msg));
factoryDataMessageSender.sendNodeDataByBrand(msg); factoryDataMessageSender.sendNodeDataByBrand(msg);
// 推送梦天工厂 // 推送梦天工厂

Loading…
Cancel
Save