Browse Source

1.干线-批量装车,批量卸车 逻辑优化

master
zhenghaoyu 11 months ago
parent
commit
e01df114c1
  1. 2
      blade-service-api/logpm-trunkline-api/src/main/java/com/logpm/trunkline/dto/UnloadPackageDTO.java
  2. 23
      blade-service/logpm-distribution/src/main/java/com/logpm/distribution/feign/DistributionParcelListClient.java
  3. 13
      blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/mapper/TrunklineCarsLoadScanMapper.java
  4. 61
      blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/mapper/TrunklineCarsLoadScanMapper.xml
  5. 3
      blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/IPackageTrackLogAsyncService.java
  6. 13
      blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/ITrunklineCarsLoadScanService.java
  7. 8
      blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/impl/OpenOrderServiceImpl.java
  8. 12
      blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/impl/PackageTrackLogAsyncServiceImpl.java
  9. 28
      blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/impl/TrunklineCarsLoadScanServiceImpl.java
  10. 378
      blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/impl/TrunklineCarsLoadServiceImpl.java

2
blade-service-api/logpm-trunkline-api/src/main/java/com/logpm/trunkline/dto/UnloadPackageDTO.java

@ -8,5 +8,5 @@ import java.io.Serializable;
public class UnloadPackageDTO implements Serializable {
private String orderPackageCode;
private Long carsLoadScanId;
}

23
blade-service/logpm-distribution/src/main/java/com/logpm/distribution/feign/DistributionParcelListClient.java

@ -43,6 +43,7 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors;
/**
* 在库订单包件清单 Feign实现类
@ -116,7 +117,18 @@ public class DistributionParcelListClient implements IDistributionParcelListClie
@Override
@PostMapping(API_PREFIX+"/addBatch")
public boolean addBatch(List<DistributionParcelListEntity> parcelListEntityList) {
return distributionParcelListService.saveBatch(parcelListEntityList);
boolean b = distributionParcelListService.saveBatch(parcelListEntityList);
if(b){
Long warehouseId = parcelListEntityList.get(0).getWarehouseId();
//把parcelListEntityList中的ordeCode存入一个Set
Set<String> orderCodes = parcelListEntityList.stream().map(DistributionParcelListEntity::getOrderCode).collect(Collectors.toSet());
orderCodes.forEach(orderCode -> {
distributionStockArticleService.updateOrderInfo(orderCode,warehouseId);
});
return b;
}else{
return b;
}
}
@Override
@ -326,9 +338,12 @@ public class DistributionParcelListClient implements IDistributionParcelListClie
distributionParcelListService.updatePackageStatus(orderPackageCodes,warehouseId,packageStatus);
List<DistributionParcelListEntity> list = distributionParcelListService.findListByOrderPackageCode(orderPackageCodes,warehouseId);
//循环list调用更新updateOrderInfo方法
list.forEach(item->{
distributionStockArticleService.updateOrderInfo(item.getOrderCode(),warehouseId);
//把list中的orderCode放入一个set
Set<String> orderCodeSet = list.stream().map(DistributionParcelListEntity::getOrderCode).collect(Collectors.toSet());
orderCodeSet.forEach(orderCode -> {
distributionStockArticleService.updateOrderInfo(orderCode,warehouseId);
});
}
}

13
blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/mapper/TrunklineCarsLoadScanMapper.java

@ -2,10 +2,13 @@ package com.logpm.trunkline.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.logpm.distribution.entity.DistributionParcelListEntity;
import com.logpm.distribution.entity.DistributionStockArticleEntity;
import com.logpm.trunkline.dto.LoadCarsDTO;
import com.logpm.trunkline.dto.ProductInfoDTO;
import com.logpm.trunkline.entity.TrunklineCarsLoadScanEntity;
import com.logpm.trunkline.vo.*;
import com.logpm.warehouse.entity.WarehouseWaybillEntity;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
@ -132,4 +135,14 @@ public interface TrunklineCarsLoadScanMapper extends BaseMapper<TrunklineCarsLoa
Integer findSignNumByLoadId(@Param("loadId") Long loadId);
UnloadReportVO findUnloadReport(@Param("loadId") Long loadId, @Param("warehouseId") Long warehouseId);
List<DistributionParcelListEntity> findParceListByCarsLoadScanIds(@Param("carsLoadScanIds") List<Long> carsLoadScanIds);
List<DistributionStockArticleEntity> findOrderListByCarsLoadScanIds(@Param("carsLoadScanIds") List<Long> carsLoadScanIds);
List<WarehouseWaybillEntity> findWaybillListByCarsLoadScanIds(@Param("carsLoadScanIds") List<Long> carsLoadScanIds);
List<TrunklineCarsLoadScanEntity> findListByIdsNoPackage(@Param("carsLoadScanIds") List<Long> carsLoadScanIds,@Param("warehouseId") Long warehouseId);
List<String> findIncomingOrdeCodesByCarsLoadScanIds(@Param("carsLoadScanIds") List<Long> carsLoadScanIds, @Param("warehouseId") Long warehouseId);
}

61
blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/mapper/TrunklineCarsLoadScanMapper.xml

@ -641,4 +641,65 @@
where ltcls.load_id =
</select>
<select id="findParceListByCarsLoadScanIds" resultType="com.logpm.distribution.entity.DistributionParcelListEntity">
select ldpl.*
from logpm_trunkline_cars_load_scan ltcls
left join logpm_distribution_parcel_list ldpl on ldpl.order_package_code = ltcls.scan_code and ldpl.warehouse_id = ltcls.from_warehouse_id
where ltcls.type = '1'
and ltcls.id in
<foreach collection="carsLoadScanIds" item="item" separator="," open="(" close=")">
#{item}
</foreach>
</select>
<select id="findOrderListByCarsLoadScanIds" resultType="com.logpm.distribution.entity.DistributionStockArticleEntity">
select ldsa.*
from logpm_trunkline_cars_load_scan ltcls
left join logpm_distribution_stock_article ldsa on ldsa.order_code = ltcls.order_code and ldsa.warehouse_id = ltcls.from_warehouse_id
where ltcls.type = '1'
and ltcls.id in
<foreach collection="carsLoadScanIds" item="item" separator="," open="(" close=")">
#{item}
</foreach>
group by ltcls.order_code
</select>
<select id="findWaybillListByCarsLoadScanIds" resultType="com.logpm.warehouse.entity.WarehouseWaybillEntity">
select lww.*
from logpm_trunkline_cars_load_scan ltcls
left join logpm_warehouse_waybill lww on lww.id = ltcls.waybill_id
where ltcls.type = '1'
and ltcls.id in
<foreach collection="carsLoadScanIds" item="item" separator="," open="(" close=")">
#{item}
</foreach>
group by ltcls.waybill_id
</select>
<select id="findListByIdsNoPackage" resultType="com.logpm.trunkline.entity.TrunklineCarsLoadScanEntity">
select ltcls.*
from logpm_trunkline_cars_load_scan ltcls
where ltcls.type = '1'
and ltcls.scan_status = '1'
and ltcls.id in
<foreach collection="carsLoadScanIds" item="item" separator="," open="(" close=")">
#{item}
</foreach>
</select>
<select id="findIncomingOrdeCodesByCarsLoadScanIds" resultType="String">
select concat(ldsa.order_code,'----',ldsa.id)
from logpm_trunkline_cars_load_scan ltcls
left join logpm_distribution_stock_article ldsa on ldsa.order_code = ltcls.order_code
where ltcls.type = '1'
and ldsa.warehouse_id = #{warehouseId}
and ldsa.id is not null
and ltcls.id in
<foreach collection="carsLoadScanIds" item="item" separator="," open="(" close=")">
#{item}
</foreach>
group by ldsa.order_code,ldsa.id
</select>
</mapper>

3
blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/IPackageTrackLogAsyncService.java

@ -1,9 +1,12 @@
package com.logpm.trunkline.service;
import com.logpm.warehouse.entity.WarehousePackageTrackLogEntity;
import java.util.List;
public interface IPackageTrackLogAsyncService {
void addPackageTrackLog(String tenantId, Long userId, Long deptId, String nickName, List<String> orderPackageCodes, Long warehouseId, String warehouseName, Integer workNode, String content);
void addBatchPackageTrackLog(List<WarehousePackageTrackLogEntity> addPackageTrackLogList, List<String> orderPackageCodes, Integer code);
}

13
blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/ITrunklineCarsLoadScanService.java

@ -1,10 +1,13 @@
package com.logpm.trunkline.service;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.logpm.distribution.entity.DistributionParcelListEntity;
import com.logpm.distribution.entity.DistributionStockArticleEntity;
import com.logpm.trunkline.dto.LoadCarsDTO;
import com.logpm.trunkline.dto.ProductInfoDTO;
import com.logpm.trunkline.entity.TrunklineCarsLoadScanEntity;
import com.logpm.trunkline.vo.*;
import com.logpm.warehouse.entity.WarehouseWaybillEntity;
import org.springblade.core.mp.base.BaseService;
import java.util.List;
@ -127,4 +130,14 @@ public interface ITrunklineCarsLoadScanService extends BaseService<TrunklineCars
Integer findSignNumByLoadId(Long loadId);
UnloadReportVO findUnloadReport(Long loadId, Long warehouseId);
List<DistributionParcelListEntity> findParceListByCarsLoadScanIds(List<Long> carsLoadScanIds);
List<DistributionStockArticleEntity> findOrderListByCarsLoadScanIds(List<Long> carsLoadScanIds);
List<WarehouseWaybillEntity> findWaybillListByCarsLoadScanIds(List<Long> carsLoadScanIds);
List<TrunklineCarsLoadScanEntity> findListByIdsNoPackage(List<Long> carsLoadScanIds, Long warehouseId);
List<String> findIncomingOrdeCodesByCarsLoadScanIds(List<Long> carsLoadScanIds, Long warehouseId);
}

8
blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/impl/OpenOrderServiceImpl.java

@ -586,7 +586,9 @@ public class OpenOrderServiceImpl implements IOpenOrderService {
// sendRabbitMessageLoadScanData(JSONUtil.parseArray(advanceIds));
carsLoadService.sendRabbitMessageOpenOrder(advanceIds, waybillId);
return R.success("开单成功");
Map<String,Object> map = new HashMap<>();
map.put("waybillId",waybillId);
return R.data(map);
}
@Override
@ -784,7 +786,9 @@ public class OpenOrderServiceImpl implements IOpenOrderService {
trunklineWaybillOrderEntity.setHandleNumber(waybillEntity.getTotalCount());
trunklineWaybillOrderService.save(trunklineWaybillOrderEntity);
return R.success("开单成功");
Map<String,Object> map = new HashMap<>();
map.put("waybillId",waybillId);
return R.data(map);
}
@Override

12
blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/impl/PackageTrackLogAsyncServiceImpl.java

@ -46,6 +46,16 @@ public class PackageTrackLogAsyncServiceImpl implements IPackageTrackLogAsyncSer
}
warehousePackageTrackLogClient.addLogList(list);
waybillPackageService.updatePackageStatus(orderPackageCodes,workNode);
waybillPackageService.updatePackageStatus(orderPackageCodes, workNode);
}
@Async
@Override
public void addBatchPackageTrackLog(List<WarehousePackageTrackLogEntity> addPackageTrackLogList, List<String> orderPackageCodes, Integer workNode) {
warehousePackageTrackLogClient.addLogList(addPackageTrackLogList);
waybillPackageService.updatePackageStatus(orderPackageCodes, workNode);
}
}

28
blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/impl/TrunklineCarsLoadScanServiceImpl.java

@ -1,12 +1,15 @@
package com.logpm.trunkline.service.impl;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.logpm.distribution.entity.DistributionParcelListEntity;
import com.logpm.distribution.entity.DistributionStockArticleEntity;
import com.logpm.trunkline.dto.LoadCarsDTO;
import com.logpm.trunkline.dto.ProductInfoDTO;
import com.logpm.trunkline.entity.TrunklineCarsLoadScanEntity;
import com.logpm.trunkline.mapper.TrunklineCarsLoadScanMapper;
import com.logpm.trunkline.service.ITrunklineCarsLoadScanService;
import com.logpm.trunkline.vo.*;
import com.logpm.warehouse.entity.WarehouseWaybillEntity;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springblade.core.mp.base.BaseServiceImpl;
@ -313,4 +316,29 @@ public class TrunklineCarsLoadScanServiceImpl extends BaseServiceImpl<TrunklineC
return baseMapper.findUnloadReport(loadId,warehouseId);
}
@Override
public List<DistributionParcelListEntity> findParceListByCarsLoadScanIds(List<Long> carsLoadScanIds) {
return baseMapper.findParceListByCarsLoadScanIds(carsLoadScanIds);
}
@Override
public List<DistributionStockArticleEntity> findOrderListByCarsLoadScanIds(List<Long> carsLoadScanIds) {
return baseMapper.findOrderListByCarsLoadScanIds(carsLoadScanIds);
}
@Override
public List<WarehouseWaybillEntity> findWaybillListByCarsLoadScanIds(List<Long> carsLoadScanIds) {
return baseMapper.findWaybillListByCarsLoadScanIds(carsLoadScanIds);
}
@Override
public List<TrunklineCarsLoadScanEntity> findListByIdsNoPackage(List<Long> carsLoadScanIds, Long warehouseId) {
return baseMapper.findListByIdsNoPackage(carsLoadScanIds,warehouseId);
}
@Override
public List<String> findIncomingOrdeCodesByCarsLoadScanIds(List<Long> carsLoadScanIds, Long warehouseId) {
return baseMapper.findIncomingOrdeCodesByCarsLoadScanIds(carsLoadScanIds,warehouseId);
}
}

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

@ -34,6 +34,7 @@ import com.logpm.trunkline.entity.*;
import com.logpm.trunkline.mapper.TrunklineCarsLoadMapper;
import com.logpm.trunkline.service.*;
import com.logpm.trunkline.vo.*;
import com.logpm.warehouse.entity.WarehousePackageTrackLogEntity;
import com.logpm.warehouse.entity.WarehouseWayBillDetail;
import com.logpm.warehouse.entity.WarehouseWaybillEntity;
import com.logpm.warehouse.feign.IWarehouseTrayTypeClient;
@ -3390,12 +3391,18 @@ public class TrunklineCarsLoadServiceImpl extends BaseServiceImpl<TrunklineCarsL
return R.success("卸车成功");
}
@Transactional(rollbackFor = Exception.class)
@Override
public R batchUnload(BatchUnloadDTO batchUnloadDTO) {
Long loadId = batchUnloadDTO.getLoadId();
Long warehouseId = batchUnloadDTO.getWarehouseId();
Integer incomingType = batchUnloadDTO.getIncomingType();
String nickName = AuthUtil.getNickName();
Long userId = AuthUtil.getUserId();
String tenantId = AuthUtil.getTenantId();
Long deptId = Func.firstLong(AuthUtil.getDeptId());
TrunklineCarsLoadEntity carsLoadEntity = baseMapper.selectById(loadId);
if (Objects.isNull(carsLoadEntity)) {
log.warn("############batchUnload: 配载计划信息不存在 loadId={}", loadId);
@ -3408,26 +3415,255 @@ public class TrunklineCarsLoadServiceImpl extends BaseServiceImpl<TrunklineCarsL
return R.fail(405, "当前节点还未到车");
}
BasicdataWarehouseEntity warehouseEntity = basicdataWarehouseClient.getEntityWarehouseId(warehouseId);
if (Objects.isNull(warehouseEntity)) {
log.warn("############batchUnload: 仓库信息不存在 warehouseId={}", warehouseId);
return R.fail(405, "仓库信息不存在");
}
String warehouseName = warehouseEntity.getName();
List<UnloadPackageDTO> unloadPackageList = batchUnloadDTO.getUnloadPackageList();
List<UnloadZeroDTO> unloadZeroList = batchUnloadDTO.getUnloadZeroList();
for (UnloadPackageDTO unloadPackageDTO : unloadPackageList) {
String orderPackageCode = unloadPackageDTO.getOrderPackageCode();
unloadPackage(loadId, orderPackageCode, warehouseId, 1, "批量卸车包件正常卸车", incomingType);
}
for (UnloadZeroDTO unloadZeroDTO : unloadZeroList) {
String waybillNo = unloadZeroDTO.getWaybillNo();
Integer enterNum = unloadZeroDTO.getEnterNum();
String trayCode = unloadZeroDTO.getTrayCode();
String orderCode = unloadZeroDTO.getOrderCode();
unloadZero(loadId, waybillNo, enterNum, warehouseId, 1, trayCode, orderCode, "批量卸车零担正常卸车");
}
List<Long> carsLoadScanIds = new ArrayList<>();
for (UnloadPackageDTO unloadPackageDTO : unloadPackageList) {
carsLoadScanIds.add(unloadPackageDTO.getCarsLoadScanId());
}
if(!carsLoadScanIds.isEmpty()){
List<TrunklineCarsLoadScanEntity> loadScanEntityList = trunklineCarsLoadScanService.findListByIdsNoPackage(carsLoadScanIds,warehouseId);
List<DistributionParcelListEntity> parcelListEntities = trunklineCarsLoadScanService.findParceListByCarsLoadScanIds(carsLoadScanIds);
//把parcelListEntities转成orderPackageCode为键值的map
Map<String,DistributionParcelListEntity> parcelListMap = parcelListEntities.stream().collect(Collectors.toMap(DistributionParcelListEntity::getOrderPackageCode, e -> e));
List<DistributionStockArticleEntity> stockArticleEntities = trunklineCarsLoadScanService.findOrderListByCarsLoadScanIds(carsLoadScanIds);
//把stockArticleEntities转成orderCode为键值的map
Map<String,DistributionStockArticleEntity> stockArticleMap = stockArticleEntities.stream().collect(Collectors.toMap(DistributionStockArticleEntity::getOrderCode, e -> e));
// List<WarehouseWaybillEntity> waybillEntities = trunklineCarsLoadScanService.findWaybillListByCarsLoadScanIds(carsLoadScanIds);
// //把waybillEntities转成WaybillNo为键值的map
// Map<String,WarehouseWaybillEntity> waybillMap = waybillEntities.stream().collect(Collectors.toMap(WarehouseWaybillEntity::getWaybillNo, e -> e));
List<String> orderCodeList = trunklineCarsLoadScanService.findIncomingOrdeCodesByCarsLoadScanIds(carsLoadScanIds,warehouseId);
Map<String,Long> orderCodes = new HashMap<>();
if(!Objects.isNull(orderCodeList)){
Map<String, Long> finalOrderCodes2 = orderCodes;
orderCodeList.forEach(e -> {
String[] split = e.split("----");
finalOrderCodes2.put(split[0],Long.valueOf(split[1]));
});
orderCodes = finalOrderCodes2;
}
List<TrunklineCarsLoadScanEntity> updateScanEntityList = new ArrayList<>();
//把loadScanEntityList通过isData=0和isData=1分成两个新的list
List<TrunklineCarsLoadScanEntity> loadScanEntityListNoData = loadScanEntityList.stream().filter(e -> e.getIsData() == 0).collect(Collectors.toList());
loadScanEntityListNoData.forEach(e -> {
e.setScanStatus("2");
e.setUnloadNodeId(warehouseId);
e.setUnloadNodeName(warehouseName);
e.setUnloadAbnormal(0);
e.setUnloadNum(1);
e.setUnloadUserName(nickName);
updateScanEntityList.add(e);
});
//需要解托下架的包件嘛
Map<Long,List<String>> unbingTrayAndDelAllocationPackages = new HashMap<>();
//直接新增的包件
List<DistributionParcelListEntity> newParcelListEntities = new ArrayList<>();
//需要修改仓库信息的打托数据
List<String> trayCodes = new ArrayList<>();
List<String> orderPackageCodes = new ArrayList<>();
List<TrunklineCarsLoadScanEntity> loadScanEntityListHasData = loadScanEntityList.stream().filter(e -> e.getIsData() == 1).collect(Collectors.toList());
//把loadScanEntityListHasData通过tray_code is null和tray_code is not null 分成两个新的list
List<TrunklineCarsLoadScanEntity> loadScanEntityListHasDataNoTray = loadScanEntityListHasData.stream().filter(e -> StringUtil.isBlank(e.getTrayCode())).collect(Collectors.toList());
//把loadScanEntityListHasDataNoTray通过orderCode进行分组
Map<String, List<TrunklineCarsLoadScanEntity>> loadScanEntityListHasDataNoTrayMap = loadScanEntityListHasDataNoTray.stream().collect(Collectors.groupingBy(TrunklineCarsLoadScanEntity::getOrderCode));
Map<String, Long> finalOrderCodes = orderCodes;
loadScanEntityListHasDataNoTrayMap.keySet().forEach(e -> {
//判断是否有已经有order了
Long orderId = null;
if(!finalOrderCodes.isEmpty()){
orderId = finalOrderCodes.get(e);
}
if(ObjectUtil.isNull(orderId)){
//没有id
DistributionStockArticleEntity stockArticleEntity = stockArticleMap.get(e);
DistributionStockArticleEntity newStockArticleEntity = new DistributionStockArticleEntity();
BeanUtil.copy(stockArticleEntity,newStockArticleEntity);
newStockArticleEntity.setId(null);
newStockArticleEntity.setWarehouseId(warehouseId);
newStockArticleEntity.setWarehouse(warehouseName);
newStockArticleEntity.setHandQuantity(0);
newStockArticleEntity.setIncomingNum(0);
newStockArticleEntity.setCreateUserName(nickName);
newStockArticleEntity.setOrderStatus("10");
newStockArticleEntity.setStockupStatus("10");
newStockArticleEntity.setReservationStatus("10");
newStockArticleEntity.setGroundingStatus("10");
newStockArticleEntity.setOrderReceiveStatus("10");
newStockArticleEntity.setFreezeStatus("10");
orderId = distributionStockArticleClient.addData(newStockArticleEntity);
finalOrderCodes.put(e,orderId);
}
List<TrunklineCarsLoadScanEntity> carsLoadScanEntities = loadScanEntityListHasDataNoTrayMap.get(e);
Long finalOrderId = orderId;
carsLoadScanEntities.forEach(p -> {
Long fromWarehouseId = p.getFromWarehouseId();
DistributionParcelListEntity parcelListEntity = parcelListMap.get(p.getScanCode());
Long acceptWarehouseId = parcelListEntity.getAcceptWarehouseId();
DistributionParcelListEntity newNoOrderPackage = new DistributionParcelListEntity();
BeanUtil.copy(parcelListEntity,newNoOrderPackage);
newNoOrderPackage.setId(null);
newNoOrderPackage.setWarehouseId(warehouseId);
newNoOrderPackage.setWarehouse(warehouseName);
newNoOrderPackage.setStockArticleId(finalOrderId);
newNoOrderPackage.setOrderPackageStatus("20");
newNoOrderPackage.setOrderPackageFreezeStatus("10");
newNoOrderPackage.setOrderPackageGroundingStatus("10");
newNoOrderPackage.setOrderPackageStockupStatus("10");
newNoOrderPackage.setOrderPackageReservationStatus("10");
newNoOrderPackage.setOrderPackageLoadingStatus("10");
if(acceptWarehouseId.equals(warehouseId)){
newNoOrderPackage.setIsTransfer(0);
}else{
newNoOrderPackage.setIsTransfer(1);
}
newParcelListEntities.add(newNoOrderPackage);
orderPackageCodes.add(p.getScanCode());
List<String> list = unbingTrayAndDelAllocationPackages.get(fromWarehouseId);
if(Objects.isNull(list)){
list = new ArrayList<>();
list.add(p.getScanCode());
}else{
list.add(p.getScanCode());
}
unbingTrayAndDelAllocationPackages.put(fromWarehouseId,list);
p.setScanStatus("2");
p.setUnloadNodeId(warehouseId);
p.setUnloadNodeName(warehouseName);
p.setUnloadAbnormal(0);
p.setUnloadNum(1);
p.setUnloadUserName(nickName);
updateScanEntityList.add(p);
});
});
orderCodes = finalOrderCodes;
List<TrunklineCarsLoadScanEntity> loadScanEntityListHasDataHasTray = loadScanEntityListHasData.stream().filter(e -> StringUtil.isNotBlank(e.getTrayCode())).collect(Collectors.toList());
//把loadScanEntityListHasDataHasTray通过TrayCode进行分组
Map<String, List<TrunklineCarsLoadScanEntity>> loadScanEntityListHasDataHasTrayMap = loadScanEntityListHasDataHasTray.stream().collect(Collectors.groupingBy(TrunklineCarsLoadScanEntity::getTrayCode));
Map<String, Long> finalOrderCodes1 = orderCodes;
loadScanEntityListHasDataHasTrayMap.keySet().forEach(o -> {
trayCodes.add(o);
List<TrunklineCarsLoadScanEntity> carsLoadScanEntities = loadScanEntityListHasDataHasTrayMap.get(o);
//把carsLoadScanEntities通过orderCode进行分组
Map<String, List<TrunklineCarsLoadScanEntity>> carsLoadScanEntitiesMap = carsLoadScanEntities.stream().collect(Collectors.groupingBy(TrunklineCarsLoadScanEntity::getOrderCode));
carsLoadScanEntitiesMap.keySet().forEach(e -> {
//判断是否有已经有order了
Long orderId = finalOrderCodes1.get(e);
if(ObjectUtil.isNull(orderId)){
//没有id
DistributionStockArticleEntity stockArticleEntity = stockArticleMap.get(e);
DistributionStockArticleEntity newStockArticleEntity = new DistributionStockArticleEntity();
BeanUtil.copy(stockArticleEntity,newStockArticleEntity);
newStockArticleEntity.setId(null);
newStockArticleEntity.setWarehouseId(warehouseId);
newStockArticleEntity.setWarehouse(warehouseName);
newStockArticleEntity.setHandQuantity(0);
newStockArticleEntity.setIncomingNum(0);
newStockArticleEntity.setCreateUserName(nickName);
newStockArticleEntity.setOrderStatus("10");
newStockArticleEntity.setStockupStatus("10");
newStockArticleEntity.setReservationStatus("10");
newStockArticleEntity.setGroundingStatus("10");
newStockArticleEntity.setOrderReceiveStatus("10");
newStockArticleEntity.setFreezeStatus("10");
orderId = distributionStockArticleClient.addData(newStockArticleEntity);
finalOrderCodes1.put(e,orderId);
}
List<TrunklineCarsLoadScanEntity> carsLoadScanList = carsLoadScanEntitiesMap.get(e);
Long finalOrderId = orderId;
carsLoadScanList.forEach(p -> {
DistributionParcelListEntity parcelListEntity = parcelListMap.get(p.getScanCode());
Long acceptWarehouseId = parcelListEntity.getAcceptWarehouseId();
DistributionParcelListEntity newNoOrderPackage = new DistributionParcelListEntity();
BeanUtil.copy(parcelListEntity,newNoOrderPackage);
newNoOrderPackage.setId(null);
newNoOrderPackage.setWarehouseId(warehouseId);
newNoOrderPackage.setWarehouse(warehouseName);
newNoOrderPackage.setStockArticleId(finalOrderId);
newNoOrderPackage.setOrderPackageStatus("20");
newNoOrderPackage.setOrderPackageFreezeStatus("10");
newNoOrderPackage.setOrderPackageGroundingStatus("10");
newNoOrderPackage.setOrderPackageStockupStatus("10");
newNoOrderPackage.setOrderPackageReservationStatus("10");
newNoOrderPackage.setOrderPackageLoadingStatus("10");
if(acceptWarehouseId.equals(warehouseId)){
newNoOrderPackage.setIsTransfer(0);
}else{
newNoOrderPackage.setIsTransfer(1);
}
newParcelListEntities.add(newNoOrderPackage);
orderPackageCodes.add(p.getScanCode());
p.setScanStatus("2");
p.setUnloadNodeId(warehouseId);
p.setUnloadNodeName(warehouseName);
p.setUnloadAbnormal(0);
p.setUnloadNum(1);
p.setUnloadUserName(nickName);
updateScanEntityList.add(p);
});
});
});
//直接新增的包件
distributionParcelListClient.addBatch(newParcelListEntities);
trunklineCarsLoadScanService.updateBatchById(updateScanEntityList);
//需要解托下架的包件嘛
unbingTrayAndDelAllocationPackages.keySet().forEach(w -> {
List<String> list = unbingTrayAndDelAllocationPackages.get(w);
updownTypeClient.downPackageOrDelTray(StringUtil.join(list),w,"批量入库解托下架");
});
//需要修改仓库信息的打托数据
trayCodes.forEach(trayCode -> {
trayTypeClient.changeTrayWarehouseInfo(trayCode,warehouseId);
});
newParcelListEntities.forEach(e -> {
carsLoadAsyncService.dealwithAfterAbnormalPackage(e.getOrderPackageCode(),warehouseId,warehouseName,carsLoadEntity.getCarsNo(),userId, deptId, nickName);
});
String content = "包件在 " + warehouseName + "卸车,卸车方式:" + IncomingTypeEnum.getValue(incomingType);
packageTrackLogAsyncService.addPackageTrackLog(tenantId, userId, deptId, nickName, orderPackageCodes, warehouseId, warehouseName, WorkNodeEnums.UNLOAD_INCOMING_WAREHOUSE.getCode(), content);
}
updateNumByLoadId(loadId);
return R.success("卸车成功");
}
@ -3928,12 +4164,14 @@ public class TrunklineCarsLoadServiceImpl extends BaseServiceImpl<TrunklineCarsL
log.warn("##############manualLoading: 配载计划不存在 loadId={}", loadId);
return R.fail(405, "配载计划不存在");
}
String carsNo = carsLoadEntity.getCarsNo();
BasicdataWarehouseEntity warehouseEntity = basicdataWarehouseClient.getEntityWarehouseId(warehouseId);
if (Objects.isNull(warehouseEntity)) {
log.warn("##############manualLoading: 仓库信息不存在 warehouseId={}", warehouseId);
return R.fail(405, "仓库信息不存在");
}
String warehouseName = warehouseEntity.getName();
Long nowWarehouseId = carsLoadEntity.getNowWarehouseId();
if (!nowWarehouseId.equals(warehouseId)) {
@ -3941,39 +4179,107 @@ public class TrunklineCarsLoadServiceImpl extends BaseServiceImpl<TrunklineCarsL
return R.fail(405, "车辆不在当前仓");
}
String tenantId = AuthUtil.getTenantId();
Long userId = AuthUtil.getUserId();
Long deptId = Func.firstLong(AuthUtil.getDeptId());
String nickName = AuthUtil.getNickName();
//查询有哪些在当前仓做计划的订单
List<TrunklineCarsOrderEntity> carsOrderEntityList = trunklineCarsOrderService.findListByLoadIdAndNodeId(loadId, warehouseId);
for (TrunklineCarsOrderEntity carsOrderEntity : carsOrderEntityList) {
Integer type = carsOrderEntity.getType();
Integer realNum = carsOrderEntity.getRealNum();
if (type.equals(1)) {
//订制品订单
String orderCode = carsOrderEntity.getOrderCode();
Integer planNum = carsOrderEntity.getPlanNum();
String waybillNo = carsOrderEntity.getWaybillNo();
List<DistributionParcelListEntity> entityListByOrderCode = distributionParcelListClient.findEntityListByOrderCodeAndStatus(orderCode, warehouseId, "20",waybillNo);
int size = entityListByOrderCode.size();
if (planNum.equals(size + realNum)) {
for (DistributionParcelListEntity parcelListEntity : entityListByOrderCode) {
String orderPackageCode = parcelListEntity.getOrderPackageCode();
//查询包件是否已经装车
TrunklineCarsLoadScanEntity carsLoadScanEntity = trunklineCarsLoadScanService.findEntityByLoadIdAndOrderPackageCode(loadId, orderPackageCode);
if (Objects.isNull(carsLoadScanEntity)) {
loadingScan(loadId, warehouseId, orderPackageCode, null, "手动一键装车");
}
}
}
} else if (type.equals(2)) {
//零担订单
String orderCode = carsOrderEntity.getOrderCode();
String waybillNo = carsOrderEntity.getWaybillNo();
Integer planNum = carsOrderEntity.getPlanNum();
// Integer realNum = carsOrderEntity.getRealNum();
if (realNum.equals(0)) {
loadingZero(loadId, warehouseId, waybillNo, orderCode, null, planNum, "手动一键装车");
//把carsOrderEntityList通过type分组成两个新的集合
List<TrunklineCarsOrderEntity> packageOrderList = carsOrderEntityList.stream().filter(e -> e.getType().equals(1)).collect(Collectors.toList());
List<TrunklineCarsOrderEntity> zeroOrderList = carsOrderEntityList.stream().filter(e -> e.getType().equals(2)).collect(Collectors.toList());
//零担批量装车
zeroOrderList.stream().forEach(e -> {
//零担订单
Integer realNum = e.getRealNum();
String orderCode = e.getOrderCode();
String waybillNo = e.getWaybillNo();
Integer planNum = e.getPlanNum();
if (realNum.equals(0)) {
loadingZero(loadId, warehouseId, waybillNo, orderCode, null, planNum, "手动一键装车");
}
});
List<TrunklineCarsLoadScanEntity> addCarsLoadScanList = new ArrayList<>();
List<WarehousePackageTrackLogEntity> addPackageTrackLogList = new ArrayList<>();
List<String> orderPackageCodes = new ArrayList<>();
List<DistributionParcelListEntity> parcelList = new ArrayList<>();
packageOrderList.stream().forEach(e -> {
Integer realNum = e.getRealNum();
String orderCode = e.getOrderCode();
Integer planNum = e.getPlanNum();
String waybillNo = e.getWaybillNo();
Long finalNodeId = e.getFinalNodeId();
String finalNodeName = null;
BasicdataWarehouseEntity finalNodeWarehouse = basicdataWarehouseClient.getEntityWarehouseId(finalNodeId);
if (Objects.nonNull(finalNodeWarehouse)){
finalNodeName = finalNodeWarehouse.getName();
}
List<DistributionParcelListEntity> entityListByOrderCode = distributionParcelListClient.findEntityListByOrderCodeAndStatus(orderCode, warehouseId, "20",waybillNo);
int size = entityListByOrderCode.size();
if(planNum.equals(size + realNum)){
for (DistributionParcelListEntity parcelListEntity : entityListByOrderCode) {
String orderPackageCode = parcelListEntity.getOrderPackageCode();
TrunklineCarsLoadScanEntity carsLoadScanEntity = new TrunklineCarsLoadScanEntity();
carsLoadScanEntity.setLoadId(loadId);
carsLoadScanEntity.setWarehouseId(warehouseId);
carsLoadScanEntity.setWarehouseName(warehouseName);
carsLoadScanEntity.setLoadCode(carsNo);
carsLoadScanEntity.setWaybillId(parcelListEntity.getWaybillId());
carsLoadScanEntity.setWaybillNo(parcelListEntity.getWaybillNumber());
carsLoadScanEntity.setOrderCode(parcelListEntity.getOrderCode());
carsLoadScanEntity.setScanCode(orderPackageCode);
carsLoadScanEntity.setScanStatus("1");
carsLoadScanEntity.setNum(1);
carsLoadScanEntity.setType(1);
carsLoadScanEntity.setIsData(1);
carsLoadScanEntity.setLoadingAbnormal(0);
carsLoadScanEntity.setUnloadAbnormal(0);
carsLoadScanEntity.setFromWarehouseId(warehouseId);
carsLoadScanEntity.setUnloadNum(0);
carsLoadScanEntity.setFinalNodeId(finalNodeId);
carsLoadScanEntity.setFinalNodeName(finalNodeName);
carsLoadScanEntity.setUnloadCheck(0);
carsLoadScanEntity.setIsSupple(0);
carsLoadScanEntity.setLoadingUserName(AuthUtil.getNickName());
addCarsLoadScanList.add(carsLoadScanEntity);
Date date = new Date();
WarehousePackageTrackLogEntity warehousePackageTrackLogEntity = new WarehousePackageTrackLogEntity();
warehousePackageTrackLogEntity.setTenantId(tenantId);
warehousePackageTrackLogEntity.setCreateUser(userId);
warehousePackageTrackLogEntity.setCreateTime(date);
warehousePackageTrackLogEntity.setUpdateUser(userId);
warehousePackageTrackLogEntity.setUpdateTime(date);
warehousePackageTrackLogEntity.setIsDeleted(0);
warehousePackageTrackLogEntity.setStatus(1);
warehousePackageTrackLogEntity.setCreateDept(deptId);
warehousePackageTrackLogEntity.setOrderPackageCode(orderPackageCode);
warehousePackageTrackLogEntity.setWarehouseId(warehouseId);
warehousePackageTrackLogEntity.setWarehouseName(warehouseName);
warehousePackageTrackLogEntity.setWorkNode(WorkNodeEnums.INITIAL_WAREHOUSE_LOADING.getCode());
String content = "包件在 " + warehouseName + "手动批量装车,配载计划目的仓 " + carsLoadScanEntity.getFinalNodeName() + ",数据来源仓库 " + warehouseName;
warehousePackageTrackLogEntity.setContent(content);
warehousePackageTrackLogEntity.setOperator(nickName);
addPackageTrackLogList.add(warehousePackageTrackLogEntity);
orderPackageCodes.add(orderPackageCode);
}
}
}
});
distributionParcelListClient.updatePackageStatus(orderPackageCodes,warehouseId,"60");
trunklineCarsLoadScanService.saveBatch(addCarsLoadScanList);
updateNumByLoadId(loadId);
addCarsLoadScanList.forEach(e -> {
trunklineCarsLoadingLogService.savaLoadingLog(warehouseId, warehouseName, loadId, e.getLoadCode(), e.getWaybillId(), e.getWaybillNo(), e.getOrderCode(), e.getScanCode(), 1,
1, 1, 0, null, null, null, e.getFromWarehouseId(), e.getId(), remark);
});
packageTrackLogAsyncService.addBatchPackageTrackLog(addPackageTrackLogList,orderPackageCodes,WorkNodeEnums.INITIAL_WAREHOUSE_LOADING.getCode());
return R.success("装车完成");
}

Loading…
Cancel
Save