Browse Source

feat(all): 金牌工厂

1 解决金牌工厂拉取的数据无包条的情况自动生成包条数据生成暂存单
dev
zhaoqiaobo 5 days ago
parent
commit
2e88527d5f
  1. 88
      blade-service/logpm-factory-data/logpm-factory-data-jinpai/src/main/java/com/logpm/factorydata/jinpai/job/AdvanceJob.java
  2. 2
      blade-service/logpm-factory-data/logpm-factory-data-jinpai/src/main/java/com/logpm/factorydata/jinpai/service/impl/MqWorkerServiceImpl.java

88
blade-service/logpm-factory-data/logpm-factory-data-jinpai/src/main/java/com/logpm/factorydata/jinpai/job/AdvanceJob.java

@ -1,9 +1,10 @@
package com.logpm.factorydata.jinpai.job;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.convert.Convert;
import cn.hutool.core.util.NumberUtil;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.logpm.factorydata.base.feign.IFactoryDataBaseClient;
import com.logpm.factorydata.feign.IFactoryDataClient;
import com.logpm.factorydata.jinpai.entity.DeliveryNoteEntity;
import com.logpm.factorydata.jinpai.entity.OrderInfoEntity;
import com.logpm.factorydata.jinpai.entity.PackageInfoEntity;
@ -14,9 +15,9 @@ import com.xxl.job.core.biz.model.ReturnT;
import com.xxl.job.core.handler.annotation.XxlJob;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springblade.common.annotations.LogpmAsync;
import org.springframework.stereotype.Component;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
@ -62,21 +63,78 @@ public class AdvanceJob {
// 将数据封装到packageInfoEntityMap中 其中omsExtOrderNo为key
packageInfoEntityMap.computeIfAbsent(entity.getOmsExtOrderNo(), k -> new ArrayList<>()).add(entity);
}
// 根据订单数据查询出所有订单明细和包件信息
List<DeliveryNoteEntity> deliveryNoteEntities = deliveryNoteService.list(Wrappers.<DeliveryNoteEntity>lambdaQuery().in(DeliveryNoteEntity::getOrderId, deliveryNoteSet));
if (CollUtil.isNotEmpty(deliveryNoteEntities)) {
for (DeliveryNoteEntity entity : deliveryNoteEntities) {
deliveryNoteEntityMap.put(entity.getOrderId(), entity);
}
}
List<OrderInfoEntity> orders = orderInfoService.list(Wrappers.<OrderInfoEntity>lambdaQuery().eq(OrderInfoEntity::getReserve1, "0"));
if (CollUtil.isNotEmpty(orders)) {
for (OrderInfoEntity order : orders) {
orderInfoSet.add(order.getOmsExtOrderNo());
}
}
List<OrderInfoEntity> orderInfoEntities = orderInfoService.list(Wrappers.<OrderInfoEntity>lambdaQuery().in(OrderInfoEntity::getOmsExtOrderNo, orderInfoSet));
if (CollUtil.isNotEmpty(orderInfoEntities)) {
for (OrderInfoEntity entity : orderInfoEntities) {
String omsExtOrderNo = entity.getOmsExtOrderNo();
orderInfoEntityMap.put(omsExtOrderNo, entity);
deliveryNoteSet.add(entity.getOrderId());
}
List<OrderInfoEntity> orderInfoEntities = orderInfoService.list(Wrappers.<OrderInfoEntity>lambdaQuery().in(OrderInfoEntity::getOmsExtOrderNo, orderInfoSet));
if (CollUtil.isNotEmpty(orderInfoEntities)) {
for (OrderInfoEntity entity : orderInfoEntities) {
orderInfoEntityMap.put(entity.getOmsExtOrderNo(), entity);
}
// 根据订单数据查询出所有订单明细和包件信息
List<DeliveryNoteEntity> deliveryNoteEntities = deliveryNoteService.list(Wrappers.<DeliveryNoteEntity>lambdaQuery().in(DeliveryNoteEntity::getOrderId, deliveryNoteSet));
if (CollUtil.isNotEmpty(deliveryNoteEntities)) {
for (DeliveryNoteEntity entity : deliveryNoteEntities) {
deliveryNoteEntityMap.put(entity.getOrderId(), entity);
}
}
// 处理无包条的情况
if (CollUtil.isNotEmpty(orderInfoEntities)) {
for (OrderInfoEntity entity : orderInfoEntities) {
String omsExtOrderNo = entity.getOmsExtOrderNo();
String goodsNumber = entity.getGoodsNumber();
if (!packageInfoEntityMap.containsKey(omsExtOrderNo)) {
// 订单没有包件,生成包件
if (StrUtil.isNotEmpty(goodsNumber)) {
Integer anInt = Convert.toInt(goodsNumber);
if (anInt > 0) {
// 创建包件
List<PackageInfoEntity> packageInfoEntities = new ArrayList<>();
for (int i = 0; i < anInt; i++) {
PackageInfoEntity packageInfoEntity = new PackageInfoEntity();
packageInfoEntity.setOrderId(entity.getOrderId());
packageInfoEntity.setOmsExtOrderNo(omsExtOrderNo);
packageInfoEntity.setGoodsNum(entity.getGoodsNumber());
packageInfoEntity.setBoxType1(entity.getGoodsType());
packageInfoEntity.setBoxType2(entity.getGoodsType());
packageInfoEntity.setBoxType3(entity.getGoodsType());
packageInfoEntity.setExtBoxCode(deliveryNoteEntityMap.get(entity.getOrderId()).getOmsExtYsId() + omsExtOrderNo + "-" + i);
String goodsVolume = entity.getGoodsVolume();
if (StrUtil.isNotEmpty(goodsVolume)) {
BigDecimal div = NumberUtil.div(Convert.toBigDecimal(goodsVolume), Convert.toBigDecimal(anInt), 4);
packageInfoEntity.setGoodsVolume(Convert.toStr(div));
}
packageInfoEntities.add(packageInfoEntity);
}
packageInfoEntityMap.put(omsExtOrderNo, packageInfoEntities);
}
}
}
}
// 组装数据,然后生成暂存单
deliveryNoteService.buildAdvancePull(packageInfoEntityMap, deliveryNoteEntityMap, orderInfoEntityMap);
}
// 组装数据,然后生成暂存单
deliveryNoteService.buildAdvancePull(packageInfoEntityMap, deliveryNoteEntityMap, orderInfoEntityMap);
if (CollUtil.isNotEmpty(orderInfoEntities)) {
// 修改包件的发送状态 TODO 后面修改为暂存单消费完成之后回调更新状态
List<OrderInfoEntity> updatePackageList = new ArrayList<>();
for (OrderInfoEntity entity : orderInfoEntities) {
OrderInfoEntity updateEntity = new OrderInfoEntity();
updateEntity.setReserve1("1");
updateEntity.setId(entity.getId());
updatePackageList.add(updateEntity);
}
if (CollUtil.isNotEmpty(updatePackageList)) {
orderInfoService.updateBatchById(updatePackageList);
}
}
if (CollUtil.isNotEmpty(list)) {
// 修改包件的发送状态 TODO 后面修改为暂存单消费完成之后回调更新状态
List<PackageInfoEntity> updatePackageList = new ArrayList<>();
for (PackageInfoEntity entity : list) {

2
blade-service/logpm-factory-data/logpm-factory-data-jinpai/src/main/java/com/logpm/factorydata/jinpai/service/impl/MqWorkerServiceImpl.java

@ -307,6 +307,8 @@ public class MqWorkerServiceImpl implements MqWorkerService {
OrderInfoEntity deliveryNoteEntity = new OrderInfoEntity();
BeanUtil.copyProperties(vo, deliveryNoteEntity);
deliveryNoteEntity.setLogId(ObjectUtil.isNotEmpty(logEntity.getId()) ? logEntity.getId().toString() : null);
// 是否推送
deliveryNoteEntity.setReserve1("0");
entities.add(deliveryNoteEntity);
}
if (CollUtil.isNotEmpty(entities)) {

Loading…
Cancel
Save