|
|
|
@ -14,7 +14,9 @@ import com.logpm.distribution.entity.DistributionStockArticleEntity;
|
|
|
|
|
import com.logpm.distribution.feign.IDistributionParcelListClient; |
|
|
|
|
import com.logpm.distribution.feign.IDistributionStockArticleClient; |
|
|
|
|
import com.logpm.oldproject.entity.WayBillEntity; |
|
|
|
|
import com.logpm.oldproject.entity.WaybillDesEntity; |
|
|
|
|
import com.logpm.oldproject.feign.IWayBillClient; |
|
|
|
|
import com.logpm.oldproject.feign.IWaybillDesClient; |
|
|
|
|
import com.logpm.warehouse.dto.ProductDTO; |
|
|
|
|
import com.logpm.warehouse.dto.SplitOrderDTO; |
|
|
|
|
import com.logpm.warehouse.dto.WaybillDTO; |
|
|
|
@ -50,6 +52,7 @@ import java.util.Objects;
|
|
|
|
|
public class WarehouseWaybillServiceImpl extends BaseServiceImpl<WarehouseWaybillMapper, WarehouseWaybillEntity> implements IWarehouseWaybillService { |
|
|
|
|
private final WarehouseWaybillMapper warehouseWaybillMapper; |
|
|
|
|
private final IWayBillClient wayBillClient; |
|
|
|
|
private final IWaybillDesClient waybillDesClient; |
|
|
|
|
private final IBasicdataWarehouseClient basicdataWarehouseClient; |
|
|
|
|
private final IBasicdataClientClient basicdataClientClient; |
|
|
|
|
private final IBasicdataStoreBusinessClient basicdataStoreBusinessClient; |
|
|
|
@ -67,15 +70,14 @@ public class WarehouseWaybillServiceImpl extends BaseServiceImpl<WarehouseWaybil
|
|
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
|
public void waybillDataHandler(WaybillDTO waybillDTO) { |
|
|
|
|
String waybillNo = waybillDTO.getWaybillNo(); |
|
|
|
|
List<ProductDTO> productList = waybillDTO.getProductList(); |
|
|
|
|
Integer allNum = waybillDTO.getNumber(); |
|
|
|
|
Date date = new Date(); |
|
|
|
|
Integer allNum = 0; |
|
|
|
|
Long waybillId = null; |
|
|
|
|
boolean isOrder = false; |
|
|
|
|
for (ProductDTO productDTO : productList) { |
|
|
|
|
Integer num = productDTO.getNum(); |
|
|
|
|
allNum = allNum + num; |
|
|
|
|
} |
|
|
|
|
// for (ProductDTO productDTO : productList) {
|
|
|
|
|
// Integer num = productDTO.getNum();
|
|
|
|
|
// allNum = allNum + num;
|
|
|
|
|
// }
|
|
|
|
|
log.info("###############waybillDataHandler: 处理数据开始 waybillNo={}", waybillNo); |
|
|
|
|
|
|
|
|
|
//通过运单号先去查询新系统是否存在这个运单号
|
|
|
|
@ -86,7 +88,7 @@ public class WarehouseWaybillServiceImpl extends BaseServiceImpl<WarehouseWaybil
|
|
|
|
|
//如果新系统中不存在这个运单,那么就去查询老系统的运单数据
|
|
|
|
|
WayBillEntity wayBillEntity = wayBillClient.getByWaybillNo(waybillNo); |
|
|
|
|
if (Objects.isNull(wayBillEntity)) { |
|
|
|
|
log.warn("##############waybillDataHandler: 老系统中为找到对应运单waybillNo={}", waybillNo); |
|
|
|
|
log.warn("##############waybillDataHandler: 老系统中未找到对应运单waybillNo={}", waybillNo); |
|
|
|
|
throw new CustomerException("老系统中未找到对应运单"); |
|
|
|
|
} |
|
|
|
|
String startSite = wayBillEntity.getStartSite();//始发仓名称
|
|
|
|
@ -94,6 +96,7 @@ public class WarehouseWaybillServiceImpl extends BaseServiceImpl<WarehouseWaybil
|
|
|
|
|
String warehouseName = wayBillEntity.getWarehouseName();//目的仓
|
|
|
|
|
BasicdataWarehouseEntity endhouse = basicdataWarehouseClient.findByName(warehouseName); |
|
|
|
|
Integer number = wayBillEntity.getNumber();//运单总数量
|
|
|
|
|
String packname = wayBillEntity.getPackname(); |
|
|
|
|
String agent = wayBillEntity.getAgent(); |
|
|
|
|
if (allNum.compareTo(number) > 0) { |
|
|
|
|
log.warn("##############waybillDataHandler: 运单的总数量异常 allNum={} number={}", allNum, number); |
|
|
|
@ -133,7 +136,7 @@ public class WarehouseWaybillServiceImpl extends BaseServiceImpl<WarehouseWaybil
|
|
|
|
|
warehouseWaybill.setConsigneeMobile(wayBillEntity.getTakeMobile()); |
|
|
|
|
warehouseWaybill.setConsigneeAddress(wayBillEntity.getTakeAddress()); |
|
|
|
|
warehouseWaybill.setDestination(wayBillEntity.getArriveSite()); |
|
|
|
|
warehouseWaybill.setGoodsName(wayBillEntity.getPackname()); |
|
|
|
|
warehouseWaybill.setGoodsName(packname); |
|
|
|
|
warehouseWaybill.setTotalCount(number); |
|
|
|
|
warehouseWaybill.setStockCount(allNum); |
|
|
|
|
warehouseWaybill.setTotalWeight(wayBillEntity.getWeight()); |
|
|
|
@ -152,12 +155,30 @@ public class WarehouseWaybillServiceImpl extends BaseServiceImpl<WarehouseWaybil
|
|
|
|
|
warehouseWaybill.setRemark(wayBillEntity.getMsg()); |
|
|
|
|
warehouseWaybill.setBatchNo(wayBillEntity.getStartCarsNo()); |
|
|
|
|
warehouseWaybill.setFreezeStatus(0); |
|
|
|
|
warehouseWaybill.setStatus(1); |
|
|
|
|
warehouseWaybill.setStatus(0); |
|
|
|
|
warehouseWaybill.setIsDeleted(0); |
|
|
|
|
warehouseWaybill.setCreateTime(date); |
|
|
|
|
warehouseWaybill.setUpdateTime(date); |
|
|
|
|
warehouseWaybillMapper.insert(warehouseWaybill); |
|
|
|
|
waybillId = warehouseWaybill.getId(); |
|
|
|
|
|
|
|
|
|
//新增的时候存入所有的订单详情
|
|
|
|
|
List<WaybillDesEntity> des = waybillDesClient.getDesList(waybillNo); |
|
|
|
|
List<WarehouseWayBillDetail> ls = new ArrayList<>(); |
|
|
|
|
for (WaybillDesEntity waybillDesEntity : des) { |
|
|
|
|
WarehouseWayBillDetail warehouseWayBillDetail = new WarehouseWayBillDetail(); |
|
|
|
|
warehouseWayBillDetail.setWaybillId(waybillId); |
|
|
|
|
warehouseWayBillDetail.setWaybillNo(waybillNo); |
|
|
|
|
warehouseWayBillDetail.setProductName(waybillDesEntity.getName()); |
|
|
|
|
warehouseWayBillDetail.setNum(waybillDesEntity.getNum()); |
|
|
|
|
warehouseWayBillDetail.setStatus(1); |
|
|
|
|
warehouseWayBillDetail.setIsDeleted(0); |
|
|
|
|
warehouseWayBillDetail.setCreateTime(date); |
|
|
|
|
warehouseWayBillDetail.setUpdateTime(date); |
|
|
|
|
ls.add(warehouseWayBillDetail); |
|
|
|
|
} |
|
|
|
|
warehouseWayBillDetailService.addList(ls); |
|
|
|
|
|
|
|
|
|
//判断是否需要创建在库订单
|
|
|
|
|
if (allNum.compareTo(number) == 0) { |
|
|
|
|
isOrder = true; |
|
|
|
@ -179,28 +200,32 @@ public class WarehouseWaybillServiceImpl extends BaseServiceImpl<WarehouseWaybil
|
|
|
|
|
isOrder = true; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
//处理运单明细
|
|
|
|
|
for (ProductDTO productDTO : productList) { |
|
|
|
|
String productName = productDTO.getProductName(); |
|
|
|
|
Integer num = productDTO.getNum(); |
|
|
|
|
WarehouseWayBillDetail warehouseWayBillDetail = warehouseWayBillDetailService.findByProductName(productName); |
|
|
|
|
if (Objects.isNull(warehouseWayBillDetail)) { |
|
|
|
|
warehouseWayBillDetail = new WarehouseWayBillDetail(); |
|
|
|
|
warehouseWayBillDetail.setWaybillId(waybillId); |
|
|
|
|
warehouseWayBillDetail.setWaybillNo(waybillNo); |
|
|
|
|
warehouseWayBillDetail.setProductName(productName); |
|
|
|
|
warehouseWayBillDetail.setNum(num); |
|
|
|
|
warehouseWayBillDetail.setStatus(1); |
|
|
|
|
warehouseWayBillDetail.setIsDeleted(0); |
|
|
|
|
warehouseWayBillDetail.setCreateTime(date); |
|
|
|
|
warehouseWayBillDetail.setUpdateTime(date); |
|
|
|
|
warehouseWayBillDetailService.save(warehouseWayBillDetail); |
|
|
|
|
} else { |
|
|
|
|
warehouseWayBillDetail.setNum(warehouseWayBillDetail.getNum() + num); |
|
|
|
|
warehouseWayBillDetail.setUpdateTime(date); |
|
|
|
|
warehouseWayBillDetailService.update(warehouseWayBillDetail); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
// String goodsName = warehouseWaybill.getGoodsName();
|
|
|
|
|
// //处理运单明细
|
|
|
|
|
// WarehouseWayBillDetail warehouseWayBillDetail = warehouseWayBillDetailService.findByWaybillIdAndGoodsName(waybillId,goodsName);
|
|
|
|
|
//
|
|
|
|
|
//
|
|
|
|
|
// for (ProductDTO productDTO : productList) {
|
|
|
|
|
// String productName = productDTO.getProductName();
|
|
|
|
|
// Integer num = productDTO.getNum();
|
|
|
|
|
//
|
|
|
|
|
// if (Objects.isNull(warehouseWayBillDetail)) {
|
|
|
|
|
// warehouseWayBillDetail = new WarehouseWayBillDetail();
|
|
|
|
|
// warehouseWayBillDetail.setWaybillId(waybillId);
|
|
|
|
|
// warehouseWayBillDetail.setWaybillNo(waybillNo);
|
|
|
|
|
// warehouseWayBillDetail.setProductName(productName);
|
|
|
|
|
// warehouseWayBillDetail.setNum(num);
|
|
|
|
|
// warehouseWayBillDetail.setStatus(1);
|
|
|
|
|
// warehouseWayBillDetail.setIsDeleted(0);
|
|
|
|
|
// warehouseWayBillDetail.setCreateTime(date);
|
|
|
|
|
// warehouseWayBillDetail.setUpdateTime(date);
|
|
|
|
|
// warehouseWayBillDetailService.save(warehouseWayBillDetail);
|
|
|
|
|
// } else {
|
|
|
|
|
// warehouseWayBillDetail.setNum(warehouseWayBillDetail.getNum() + num);
|
|
|
|
|
// warehouseWayBillDetail.setUpdateTime(date);
|
|
|
|
|
// warehouseWayBillDetailService.update(warehouseWayBillDetail);
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
if (isOrder) { |
|
|
|
|
//创建在库订单
|
|
|
|
|