Browse Source

1.修改重复订单不同包件的数据保存和推送逻辑

test
zhenghaoyu 2 years ago
parent
commit
f661a13649
  1. 133
      blade-service/logpm-factory/src/main/java/com/logpm/factory/comfac/service/impl/AsyncDataServiceImpl.java
  2. 15
      blade-service/logpm-factory/src/main/java/com/logpm/factory/mt/service/impl/MtFactoryDataServiceImpl.java
  3. 29
      blade-service/logpm-factory/src/main/java/com/logpm/factory/pan/controller/PanFactoryDataController.java
  4. 65
      blade-service/logpm-factory/src/main/java/com/logpm/factory/pan/service/impl/PanFactoryDataServiceImpl.java

133
blade-service/logpm-factory/src/main/java/com/logpm/factory/comfac/service/impl/AsyncDataServiceImpl.java

@ -70,59 +70,52 @@ public class AsyncDataServiceImpl implements IAsyncDataService {
for (PanFactoryOrder panFactoryOrder:panFactoryOrders){
Long orderId = panFactoryOrder.getId();
log.info("#########handlerDataToHt: 当前处理的订单id={}",orderId);
String orderNo = panFactoryOrder.getOrderNo();//订单自编码
AdvanceEntity advanceEntity = iAdvanceClient.getQueryDataOne(orderNo);
Integer advanceId = null;
if(Objects.isNull(advanceEntity)){
//添加订单信息
advanceEntity = new AdvanceEntity();
advanceEntity.setOrderSelfNum(StringUtil.isBlank(panFactoryOrder.getOrderNo())?"":panFactoryOrder.getOrderNo()); //订单自编号
advanceEntity.setSiteName(PanFactoryEnum.getMes(panFactoryOrder.getPlantId())); // 基地
advanceEntity.setArea(StringUtil.isBlank(panFactoryOrder.getReceiverArea())?"":panFactoryOrder.getReceiverArea()); // 区域
advanceEntity.setOrderTypeName(""); //订单类型名称 可以为空
advanceEntity.setOrderClassName("工厂"); //订单类型 可以为空
advanceEntity.setType(FactoryConstant.PIANO);
advanceEntity.setTotal(panFactoryOrder.getServiceCount()); //订单总数据
advanceEntity.setMctsTruck(StringUtil.isBlank(panFactoryOrder.getDeliveryNumber())?"":panFactoryOrder.getDeliveryNumber()); //车次
advanceEntity.setMtdsNo("");// MTDS单号 可以为空
advanceEntity.setFirstPackName(""); //一级品类
advanceEntity.setFirstPackCode(""); //一级品类
advanceEntity.setDealerName(""); //商场名称
advanceEntity.setDealerCode(StringUtil.isBlank(panFactoryOrder.getUserId())?"":panFactoryOrder.getUserId()); //商场编码
advanceEntity.setDueDate(""); // 交期
advanceEntity.setIsOpai(0); //是否干仓配
advanceEntity.setOrderNum("");//MSCS订单号 可以为空
advanceEntity.setCarrierName("汇通");//承运商 可以为空
advanceEntity.setCustomerName(StringUtil.isBlank(panFactoryOrder.getCustomerName())?"":panFactoryOrder.getCustomerName()); //顾客名称
advanceEntity.setCustomerPhone(StringUtil.isBlank(panFactoryOrder.getCustomerNumber())?"":panFactoryOrder.getCustomerNumber()); // 顾客电话
advanceEntity.setCustomerRoad(StringUtil.isBlank(panFactoryOrder.getCustomerAddress())?"":panFactoryOrder.getCustomerAddress());//顾客地址
advanceEntity.setSystemType("线上"); //订单类型
advanceEntity.setStoreNo(StringUtil.isBlank(panFactoryOrder.getUserId())?"":panFactoryOrder.getUserId()); //门店编码
advanceEntity.setStoreName(StringUtil.isBlank(panFactoryOrder.getUserName())?"":panFactoryOrder.getUserName()); //门店名称
advanceEntity.setSerialKey(""); //序列号
advanceEntity.setServiceNum(StringUtil.isBlank(panFactoryOrder.getServiceNum())?"":panFactoryOrder.getServiceNum()); //服务号
advanceEntity.setMatingCode("");//齐套模式 可以为空
advanceEntity.setContractNum("");//合同号 可以为空
advanceEntity.setLeaveBehind("");//遗留:Y=是,N=否
advanceEntity.setSenderMobile(StringUtil.isBlank(panFactoryOrder.getSenderMobile())?"":panFactoryOrder.getSenderMobile());//发货人电话 可以为空
advanceEntity.setSenderAddress(StringUtil.isBlank(panFactoryOrder.getSenderAddress())?"":panFactoryOrder.getSenderAddress()); //发货地址 可以为空
advanceEntity.setSenderName(StringUtil.isBlank(panFactoryOrder.getSendFactory())?"":panFactoryOrder.getSendFactory()); //发货工厂名称 可以为空
advanceEntity.setAdministratorsId(1078);// 导入人
advanceEntity.setCreateTime(LocalDate.now()); //添加时间
advanceEntity.setCarsNum(StringUtil.isBlank(panFactoryOrder.getDeliveryNumber())?"":panFactoryOrder.getDeliveryNumber()); //派车单--snm 可以为空
advanceEntity.setDeleteTime(0); // 删除时间
advanceEntity.setWaybillNo("");//运单号 可以为空
Integer warehouseId = PanFactoryEnum.getId(panFactoryOrder.getPlantId());
advanceEntity.setWarehouseId(warehouseId); //导入人仓库id
advanceEntity.setWaybillStatus(Byte.parseByte("1"));//开单状态:1=未开单,2=已开单
advanceEntity.setOldId(0);//
advanceEntity.setFreeze(Byte.parseByte("1"));//冻结状态:1=正常,2=冻结
advanceEntity.setDeleteReason("");//删除原因
advanceEntity.setDeleteAdministratorsId(0);//删除用户
advanceId = iAdvanceClient.addAdvanceClient(advanceEntity);
}else{
advanceId = advanceEntity.getId();
}
//添加订单信息
AdvanceEntity advanceEntity = new AdvanceEntity();
advanceEntity.setOrderSelfNum(StringUtil.isBlank(panFactoryOrder.getOrderNo())?"":panFactoryOrder.getOrderNo()); //订单自编号
advanceEntity.setSiteName(PanFactoryEnum.getMes(panFactoryOrder.getPlantId())); // 基地
advanceEntity.setArea(StringUtil.isBlank(panFactoryOrder.getReceiverArea())?"":panFactoryOrder.getReceiverArea()); // 区域
advanceEntity.setOrderTypeName(""); //订单类型名称 可以为空
advanceEntity.setOrderClassName("工厂"); //订单类型 可以为空
advanceEntity.setType(FactoryConstant.PIANO);
advanceEntity.setTotal(panFactoryOrder.getServiceCount()); //订单总数据
advanceEntity.setMctsTruck(StringUtil.isBlank(panFactoryOrder.getDeliveryNumber())?"":panFactoryOrder.getDeliveryNumber()); //车次
advanceEntity.setMtdsNo("");// MTDS单号 可以为空
advanceEntity.setFirstPackName(""); //一级品类
advanceEntity.setFirstPackCode(""); //一级品类
advanceEntity.setDealerName(""); //商场名称
advanceEntity.setDealerCode(StringUtil.isBlank(panFactoryOrder.getUserId())?"":panFactoryOrder.getUserId()); //商场编码
advanceEntity.setDueDate(""); // 交期
advanceEntity.setIsOpai(0); //是否干仓配
advanceEntity.setOrderNum("");//MSCS订单号 可以为空
advanceEntity.setCarrierName("汇通");//承运商 可以为空
advanceEntity.setCustomerName(StringUtil.isBlank(panFactoryOrder.getCustomerName())?"":panFactoryOrder.getCustomerName()); //顾客名称
advanceEntity.setCustomerPhone(StringUtil.isBlank(panFactoryOrder.getCustomerNumber())?"":panFactoryOrder.getCustomerNumber()); // 顾客电话
advanceEntity.setCustomerRoad(StringUtil.isBlank(panFactoryOrder.getCustomerAddress())?"":panFactoryOrder.getCustomerAddress());//顾客地址
advanceEntity.setSystemType("线上"); //订单类型
advanceEntity.setStoreNo(StringUtil.isBlank(panFactoryOrder.getUserId())?"":panFactoryOrder.getUserId()); //门店编码
advanceEntity.setStoreName(StringUtil.isBlank(panFactoryOrder.getUserName())?"":panFactoryOrder.getUserName()); //门店名称
advanceEntity.setSerialKey(""); //序列号
advanceEntity.setServiceNum(StringUtil.isBlank(panFactoryOrder.getServiceNum())?"":panFactoryOrder.getServiceNum()); //服务号
advanceEntity.setMatingCode("");//齐套模式 可以为空
advanceEntity.setContractNum("");//合同号 可以为空
advanceEntity.setLeaveBehind("");//遗留:Y=是,N=否
advanceEntity.setSenderMobile(StringUtil.isBlank(panFactoryOrder.getSenderMobile())?"":panFactoryOrder.getSenderMobile());//发货人电话 可以为空
advanceEntity.setSenderAddress(StringUtil.isBlank(panFactoryOrder.getSenderAddress())?"":panFactoryOrder.getSenderAddress()); //发货地址 可以为空
advanceEntity.setSenderName(StringUtil.isBlank(panFactoryOrder.getSendFactory())?"":panFactoryOrder.getSendFactory()); //发货工厂名称 可以为空
advanceEntity.setAdministratorsId(1078);// 导入人
advanceEntity.setCreateTime(LocalDate.now()); //添加时间
advanceEntity.setCarsNum(StringUtil.isBlank(panFactoryOrder.getDeliveryNumber())?"":panFactoryOrder.getDeliveryNumber()); //派车单--snm 可以为空
advanceEntity.setDeleteTime(0); // 删除时间
advanceEntity.setWaybillNo("");//运单号 可以为空
Integer warehouseId = PanFactoryEnum.getId(panFactoryOrder.getPlantId());
advanceEntity.setWarehouseId(warehouseId); //导入人仓库id
advanceEntity.setWaybillStatus(Byte.parseByte("1"));//开单状态:1=未开单,2=已开单
advanceEntity.setOldId(0);//
advanceEntity.setFreeze(Byte.parseByte("1"));//冻结状态:1=正常,2=冻结
advanceEntity.setDeleteReason("");//删除原因
advanceEntity.setDeleteAdministratorsId(0);//删除用户
Integer advanceId = iAdvanceClient.addAdvanceClient(advanceEntity);
if(advanceId > 0){
//更改订单状态
panFactoryOrder.setStatus(0);
@ -336,6 +329,7 @@ public class AsyncDataServiceImpl implements IAsyncDataService {
//通过订单id查询对应的包件
QueryWrapper<MtPackageInfo> packageQueryWrapper = new QueryWrapper<>();
packageQueryWrapper.eq("order_id",orderId)
.eq("status",1)
.eq("is_deleted",0);
List<MtPackageInfo> packages = mtPackageInfoService.list(packageQueryWrapper);
for(MtPackageInfo mtPackageInfo:packages){
@ -396,20 +390,27 @@ public class AsyncDataServiceImpl implements IAsyncDataService {
}
}
ServiceNumEntity serviceNum = new ServiceNumEntity();
serviceNum.setServiceNum(StringUtil.isBlank(mtFactoryOrderMain.getInvoiceOrderCode())?"":mtFactoryOrderMain.getInvoiceOrderCode()); //服务号
serviceNum.setTotal("1"); //订单数量
serviceNum.setDetailTotal(Objects.isNull(mtFactoryOrder.getQuantity())?"":mtFactoryOrder.getQuantity()+""); // 包数量
serviceNum.setStoreName(StringUtil.isBlank(mtFactoryOrder.getExclusiveName())?"":mtFactoryOrder.getExclusiveName()); //商场名
serviceNum.setStoreNo(StringUtil.isBlank(mtFactoryOrder.getExclusiveCode())?"":mtFactoryOrder.getExclusiveCode()); // 商场编号
serviceNum.setCustomerName(StringUtil.isBlank(mtFactoryOrder.getCustomName())?"":mtFactoryOrder.getCustomName());//顾客姓名
serviceNum.setCustomerPhone(StringUtil.isBlank(mtFactoryOrder.getCustomPhone())?"":mtFactoryOrder.getCustomPhone()); //顾客电话
serviceNum.setCustomerRoad(StringUtil.isBlank(mtFactoryOrder.getCustomAddress())?"":mtFactoryOrder.getCustomAddress()); //顾客地址
serviceNum.setIsOpai(1); //是否干仓配
serviceNum.setCompleteSet("V"); //齐套标识:Y=齐套,N=未齐套,V=未知
String sn = StringUtil.isBlank(mtFactoryOrder.getMainOrderCode()) ? "" : mtFactoryOrder.getMainOrderCode();
ServiceNumEntity serviceNum = serviceNumClient.findByserviceNum(sn);
if(Objects.isNull(serviceNum)){
serviceNum = new ServiceNumEntity();
serviceNum.setServiceNum(StringUtil.isBlank(mtFactoryOrder.getMainOrderCode())?"":mtFactoryOrder.getMainOrderCode()); //服务号
serviceNum.setTotal("1"); //订单数量
serviceNum.setDetailTotal(Objects.isNull(mtFactoryOrder.getQuantity())?"":mtFactoryOrder.getQuantity()+""); // 包数量
serviceNum.setStoreName(StringUtil.isBlank(mtFactoryOrder.getExclusiveName())?"":mtFactoryOrder.getExclusiveName()); //商场名
serviceNum.setStoreNo(StringUtil.isBlank(mtFactoryOrder.getExclusiveCode())?"":mtFactoryOrder.getExclusiveCode()); // 商场编号
serviceNum.setCustomerName(StringUtil.isBlank(mtFactoryOrder.getCustomName())?"":mtFactoryOrder.getCustomName());//顾客姓名
serviceNum.setCustomerPhone(StringUtil.isBlank(mtFactoryOrder.getCustomPhone())?"":mtFactoryOrder.getCustomPhone()); //顾客电话
serviceNum.setCustomerRoad(StringUtil.isBlank(mtFactoryOrder.getCustomAddress())?"":mtFactoryOrder.getCustomAddress()); //顾客地址
serviceNum.setIsOpai(1); //是否干仓配
serviceNum.setCompleteSet("V"); //齐套标识:Y=齐套,N=未齐套,V=未知
// serviceNum.setCreateTime(LocalDate.now());
serviceNum.setDeleteTime(0);
serviceNumEntityList.add(serviceNum);
serviceNum.setDeleteTime(0);
serviceNumEntityList.add(serviceNum);
}else{
log.info("#############handlerMtDataToHt: 当前服务号已存在数据serviceNum={}",sn);
}
}
serviceNumClient.addServiceNum(serviceNumEntityList);
log.info("##############handlerMtDataToHt: 处理数据完成");

15
blade-service/logpm-factory/src/main/java/com/logpm/factory/mt/service/impl/MtFactoryDataServiceImpl.java

@ -74,8 +74,23 @@ public class MtFactoryDataServiceImpl implements IMtFactoryDataService {
mtFactoryOrder.setMainId(mainId);
boolean saveOrder = mtFactoryOrderService.save(mtFactoryOrder);
if(saveOrder){
//根据订单自编码去查是否有已存在的包件,有就舍去
Long orderId = mtFactoryOrder.getId();
QueryWrapper<MtPackageInfo> qw = new QueryWrapper<>();
qw.eq("order_id",orderId);
List<MtPackageInfo> existPackages = mtPackageInfoService.list(qw);
List<MtPackageInfoDTO> packageInfos = mtFactoryOrderDTO.getPackageInfos();
for(MtPackageInfo mtPackageInfo:existPackages){
String packageCode = mtPackageInfo.getPackageCode();
for (MtPackageInfoDTO mtPackageInfoDTO:packageInfos){
String pc = mtPackageInfoDTO.getPackageCode();
if(packageCode.equals(pc)){
packageInfos.remove(mtPackageInfoDTO);
break;
}
}
}
List<MtPackageInfo> list = new ArrayList<>();
for(MtPackageInfoDTO mtPackageInfoDTO:packageInfos){
MtPackageInfo mtPackageInfo = new MtPackageInfo();

29
blade-service/logpm-factory/src/main/java/com/logpm/factory/pan/controller/PanFactoryDataController.java

@ -17,20 +17,16 @@
package com.logpm.factory.pan.controller;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.logpm.factory.comfac.service.IAsyncDataService;
import com.logpm.factory.comfac.service.IOrderStatusLogService;
import com.logpm.factory.pan.dto.PanFactoryOrderDTO;
import com.logpm.factory.pan.dto.PanPackageInfoDTO;
import com.logpm.factory.pan.service.IPanFactoryDataService;
import com.logpm.factory.pan.service.IPanFactoryOrderService;
import com.logpm.factory.pan.service.IPanPackageInfoService;
import com.logpm.factory.pan.service.IPanPackageListService;
import com.logpm.factory.snm.bean.Resp;
import com.logpm.factory.snm.entity.OrderStatusLog;
import com.logpm.factory.snm.entity.PanFactoryOrder;
import com.logpm.factory.snm.entity.PanPackageInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
@ -41,7 +37,6 @@ import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest;
import java.util.List;
import java.util.Objects;
/**
@ -115,30 +110,6 @@ public class PanFactoryDataController extends BladeController {
//判断数据是否已存入
String orderNo = factoryOrderDTO.getOrderNo();
QueryWrapper<PanFactoryOrder> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("order_no",orderNo);
PanFactoryOrder one = factoryOrderService.getOne(queryWrapper);
if(!Objects.isNull(one)){
// log.warn("############data: 订单数据已存在 orderNo={}",orderNo);
// return Resp.fail(400,"订单数据已存在");
//如果订单已存在就去验证订单下面的包件信息
List<PanPackageInfoDTO> order_attributes = factoryOrderDTO.getORDER_ATTRIBUTES();
QueryWrapper<PanPackageInfo> qw = new QueryWrapper<>();
qw.eq("order_no",orderNo);
List<PanPackageInfo> list = packageInfoService.list(qw);
for(PanPackageInfo panPackageInfo:list){
String unitNo = panPackageInfo.getUnitNo();
for(int i = 0; i<order_attributes.size(); i++){
String newUnitNo = order_attributes.get(i).getUnitNo();
if(unitNo.equals(newUnitNo)){
order_attributes.remove(i);
break;
}
}
}
factoryOrderDTO.setORDER_ATTRIBUTES(order_attributes);
}
Long orderId = null;
try{
orderId = panFactoryDataService.saveData(factoryOrderDTO);

65
blade-service/logpm-factory/src/main/java/com/logpm/factory/pan/service/impl/PanFactoryDataServiceImpl.java

@ -376,26 +376,50 @@ public class PanFactoryDataServiceImpl implements IPanFactoryDataService {
@Override
public Long saveData(PanFactoryOrderDTO factoryOrderDTO) {
QueryWrapper<PanFactoryOrder> qw = new QueryWrapper<>();
qw.eq("order_no",factoryOrderDTO.getOrderNo());
//先查询订单是否存在
PanFactoryOrder factoryOrder = factoryOrderService.getOne(qw);
boolean flag = false;
if(Objects.isNull(factoryOrder)){
factoryOrder = new PanFactoryOrder();
BeanUtil.copyProperties(factoryOrderDTO,factoryOrder);
//保存订单数据
factoryOrderService.save(factoryOrder);
}else{
factoryOrder.setStatus(1);
factoryOrderService.saveOrUpdate(factoryOrder);
flag = true;
// QueryWrapper<PanFactoryOrder> qw = new QueryWrapper<>();
// qw.eq("order_no",factoryOrderDTO.getOrderNo());
// //先查询订单是否存在
// PanFactoryOrder factoryOrder = factoryOrderService.getOne(qw);
// boolean flag = false;
// if(Objects.isNull(factoryOrder)){
// factoryOrder = new PanFactoryOrder();
// BeanUtil.copyProperties(factoryOrderDTO,factoryOrder);
// //保存订单数据
// factoryOrderService.save(factoryOrder);
// }else{
// factoryOrder.setStatus(1);
// factoryOrderService.saveOrUpdate(factoryOrder);
// flag = true;
// }
String orderNo = factoryOrderDTO.getOrderNo();
QueryWrapper<PanFactoryOrder> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("order_no",orderNo);
PanFactoryOrder one = factoryOrderService.getOne(queryWrapper);
if(!Objects.isNull(one)){
//如果订单已存在就去验证订单下面的包件信息
List<PanPackageInfoDTO> order_attributes = factoryOrderDTO.getORDER_ATTRIBUTES();
QueryWrapper<PanPackageInfo> qw = new QueryWrapper<>();
qw.eq("order_no",orderNo);
List<PanPackageInfo> list = packageInfoService.list(qw);
for(PanPackageInfo panPackageInfo:list){
String unitNo = panPackageInfo.getUnitNo();
for(int i = 0; i<order_attributes.size(); i++){
String newUnitNo = order_attributes.get(i).getUnitNo();
if(unitNo.equals(newUnitNo)){
order_attributes.remove(i);
break;
}
}
}
factoryOrderDTO.setORDER_ATTRIBUTES(order_attributes);
}
// PanFactoryOrder factoryOrder = new PanFactoryOrder();
// BeanUtil.copyProperties(factoryOrderDTO,factoryOrder);
// //保存订单数据
// factoryOrderService.save(factoryOrder);
PanFactoryOrder factoryOrder = new PanFactoryOrder();
BeanUtil.copyProperties(factoryOrderDTO,factoryOrder);
//保存订单数据
factoryOrderService.save(factoryOrder);
List<PanPackageInfoDTO> packageInfos = factoryOrderDTO.getORDER_ATTRIBUTES();
List<PanPackageInfo> panPackageInfos = new ArrayList<>();
@ -405,11 +429,6 @@ public class PanFactoryDataServiceImpl implements IPanFactoryDataService {
PanPackageInfo packageInfo = new PanPackageInfo();
BeanUtil.copyProperties(dto,packageInfo);
packageInfo.setOrderId(factoryOrder.getId());
if(flag){
packageInfo.setReissueStatus(1);
}else{
packageInfo.setReissueStatus(0);
}
panPackageInfos.add(packageInfo);
//保存包件信息数据

Loading…
Cancel
Save