|
|
|
@ -3180,6 +3180,455 @@ public class DistributionSignforServiceImpl extends BaseServiceImpl<Distribution
|
|
|
|
|
//维护配送信息
|
|
|
|
|
distributionDeliveryListService.maintenanceDeliveryInfo(distributionSignforEntity.getDeliveryId()); |
|
|
|
|
return R.status(true); |
|
|
|
|
} @Override |
|
|
|
|
|
|
|
|
|
@Transactional |
|
|
|
|
public R oneclickPDA(DistributionSignforDTO distributionSignfor) { |
|
|
|
|
|
|
|
|
|
BladeUser user = AuthUtil.getUser(); |
|
|
|
|
BasicdataWarehouseEntity myCurrentWarehouse = basicdataWarehouseClient.getMyCurrentWarehouse(); |
|
|
|
|
if (Objects.isNull(myCurrentWarehouse)) { |
|
|
|
|
return R.fail(403,"仓库信息不能为空"); |
|
|
|
|
// throw new CustomerException(403, "仓库信息不能为/**/空");
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// ------------------------------------2023-09-08 一键签收调整------------------------------------------
|
|
|
|
|
//1、查询本次一键签收操作是否有效 ---- > 这里一件签收针对的就是制定的任务下的包件和库存品
|
|
|
|
|
// 无效 -- > 直接提示该次操作无效 无效的场景快速点击操作两次签收的动作,司机已经进行了所有的包件签收扫描但是还未进行签收确认的动作
|
|
|
|
|
// 有效 -- >
|
|
|
|
|
// 查询该车次任务中装车的包件和库存品 此时一键签收就需要将该车次中的所有包件和库存品都进行签收
|
|
|
|
|
// 此时考虑多种场景:
|
|
|
|
|
// 1、存在库存品 库存品未进行备货操作无法进行一件装车,但是对于已备货的库存品可以进行装车
|
|
|
|
|
// 2、多个车次的配送任务进行一件签收状态、在没有进行装车操作的时候
|
|
|
|
|
//
|
|
|
|
|
// 3、对于已经装车的库存品或者包件在一件签收的时候需要进行过滤
|
|
|
|
|
// Map<String, List<DistributionSignPrintDTO>> map = distributionSignfor.getMap();
|
|
|
|
|
// if (Func.isEmpty(map)){
|
|
|
|
|
// log.error("#############无图片信息:{}", map);
|
|
|
|
|
// return R.fail("无图片信息");
|
|
|
|
|
// }
|
|
|
|
|
this.updatePicture(distributionSignfor); |
|
|
|
|
//2、维护状态
|
|
|
|
|
DistributionReservationEntity reservationEntity = distributionReservationMapper.selectById(distributionSignfor.getReservationId()); |
|
|
|
|
if (Func.isEmpty(reservationEntity)) { |
|
|
|
|
log.error("#############reservationEntity参数错误:{}", reservationEntity); |
|
|
|
|
return R.fail("服务器正忙~~"); |
|
|
|
|
} |
|
|
|
|
//查询数据
|
|
|
|
|
DistributionSignforEntity distributionSignforEntity = baseMapper.selectOne(new QueryWrapper<DistributionSignforEntity>().lambda() |
|
|
|
|
.eq(DistributionSignforEntity::getDeliveryId, distributionSignfor.getDeliveryId()) |
|
|
|
|
.eq(DistributionSignforEntity::getReservationId, distributionSignfor.getReservationId()) |
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
//获取计划配送用户司机
|
|
|
|
|
DistributionDeliveryListEntity distributionDeliveryListEntity = distributionDeliveryListMapper.selectById(distributionSignfor.getDeliveryId()); |
|
|
|
|
if (Func.isEmpty(distributionDeliveryListEntity)) { |
|
|
|
|
log.error("#############deliveryId参数错误:{}", distributionSignfor.getDeliveryId()); |
|
|
|
|
return R.fail("服务器正忙~~"); |
|
|
|
|
} |
|
|
|
|
DistributionDeliverySelfEntity distributionDeliverySelfEntity = null; |
|
|
|
|
if (distributionDeliveryListEntity.getKind().equals("1")) { |
|
|
|
|
//自主
|
|
|
|
|
distributionDeliverySelfEntity = distributionDeliverySelfMapper.selectOne(new QueryWrapper<DistributionDeliverySelfEntity>().lambda() |
|
|
|
|
.eq(DistributionDeliverySelfEntity::getIsMaster, 2) |
|
|
|
|
.eq(DistributionDeliverySelfEntity::getDeliveryId, distributionSignfor.getDeliveryId()) |
|
|
|
|
); |
|
|
|
|
} else { |
|
|
|
|
//三方
|
|
|
|
|
DistributionDeliveryTripartiteEntity distributionDeliveryTripartiteEntity = distributionDeliveryTripartiteMapper.selectOne(new QueryWrapper<DistributionDeliveryTripartiteEntity>().lambda() |
|
|
|
|
.eq(DistributionDeliveryTripartiteEntity::getDeliveryId, distributionSignfor.getDeliveryId()) |
|
|
|
|
); |
|
|
|
|
distributionDeliverySelfEntity = Func.copy(distributionDeliveryTripartiteEntity, DistributionDeliverySelfEntity.class); |
|
|
|
|
// BeanUtils.copyProperties(distributionDeliveryTripartiteEntity, distributionDeliverySelfEntity);
|
|
|
|
|
} |
|
|
|
|
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (Func.equals(distributionSignforEntity.getDriverSigning(), SignforDriverSigningStatusConstant.yiqianshou.getValue())) { |
|
|
|
|
log.error("###############重复签收+{" + distributionSignforEntity + "}"); |
|
|
|
|
return R.fail("签收失败"); |
|
|
|
|
} |
|
|
|
|
//处理库存品
|
|
|
|
|
//查询出该客户下的库存品信息
|
|
|
|
|
List<DisStockListDetailEntity> detailEntities = distributionReservationMapper.selectInventoryListByReservation(distributionSignforEntity.getReservationId()); |
|
|
|
|
if (detailEntities.size() > 0 && Func.isNotEmpty(detailEntities)) { |
|
|
|
|
boolean flag = detailEntities.stream().allMatch(s -> Func.isNotEmpty(s.getStockPackageCode())); |
|
|
|
|
//只要库存品没有进行备货操作则不能进行一件装车操作
|
|
|
|
|
if (flag) { |
|
|
|
|
for (DisStockListDetailEntity detailEntity : detailEntities) { |
|
|
|
|
DistributionLoadscaninvnEntity loadscaninvnEntity = distributionLoadscaninvnService.getOne(Wrappers.<DistributionLoadscaninvnEntity>query().lambda() |
|
|
|
|
.eq(DistributionLoadscaninvnEntity::getReservationId, detailEntity.getReservationId()) |
|
|
|
|
.eq(DistributionLoadscaninvnEntity::getInventoryId, detailEntity.getStockListId()) |
|
|
|
|
.eq(DistributionLoadscaninvnEntity::getOrderPackageCode, detailEntity.getStockPackageCode()) |
|
|
|
|
.eq(DistributionLoadscaninvnEntity::getInventoryPackageId, detailEntity.getId()) |
|
|
|
|
.ne(DistributionLoadscaninvnEntity::getScanStatus, LoadingStatusConstant.quxiao.getValue()) |
|
|
|
|
); |
|
|
|
|
if (Func.isNotEmpty(loadscaninvnEntity)) { |
|
|
|
|
if (!loadscaninvnEntity.getSignforState().equals(LoadScanSigningStatusConstant.yiqianshou.getValue())) { |
|
|
|
|
//存在库存品装车数据,这里进行签收状态修改
|
|
|
|
|
loadscaninvnEntity.setSignforState(LoadScanSigningStatusConstant.yiqianshou.getValue()); |
|
|
|
|
loadscaninvnEntity.setReceivedQuantity(detailEntity.getNum()); |
|
|
|
|
loadscaninvnEntity.setOneClick(1); |
|
|
|
|
loadscaninvnEntity.setOneQclick(2); |
|
|
|
|
loadscaninvnEntity.setSigningUser(user.getNickName()); |
|
|
|
|
loadscaninvnEntity.setSigningUserId(user.getUserId()); |
|
|
|
|
loadscaninvnEntity.setReceivedQuantity(detailEntity.getNum()); |
|
|
|
|
loadscaninvnEntity.setSigningTime(simpleDateFormat.format(new Date())); |
|
|
|
|
distributionLoadscaninvnService.updateById(loadscaninvnEntity); |
|
|
|
|
Integer i = distributionDeliveryListMapper.updateloadingTimeById(distributionDeliveryListEntity.getId()); |
|
|
|
|
Integer j = distributionSignforMapper.updatesignforByinvn(loadscaninvnEntity.getDeliveryId(), loadscaninvnEntity.getReservationId(), loadscaninvnEntity.getPackageNub()); |
|
|
|
|
//更新签收人
|
|
|
|
|
Integer m = distributionSignforMapper.updateSignUser(loadscaninvnEntity.getDeliveryId(), loadscaninvnEntity.getReservationId(), AuthUtil.getUser()); |
|
|
|
|
distributionAsyncService.checkSignStatus(null, loadscaninvnEntity.getReservationId(), loadscaninvnEntity.getDeliveryId()); |
|
|
|
|
} |
|
|
|
|
} else { |
|
|
|
|
//不存在装车数据 这里需要进行装车数据的补录
|
|
|
|
|
detailEntity.setStockLockingStatus(InventoryLoadingStatusConstant.yizhuangche.getValue()); |
|
|
|
|
detailEntity.setStockSignfoStatus(InventorySigningStatusConstant.yiqianshou.getValue()); |
|
|
|
|
disStockListDetailService.updateById(detailEntity); |
|
|
|
|
DistributionLoadscaninvnEntity newLoadscaninvnEntity = new DistributionLoadscaninvnEntity(); |
|
|
|
|
if (Func.isNotEmpty(distributionDeliverySelfEntity.getDriverId())) { |
|
|
|
|
newLoadscaninvnEntity.setDriverId(distributionDeliverySelfEntity.getDriverId()); |
|
|
|
|
} |
|
|
|
|
if (Func.isNotEmpty(distributionDeliverySelfEntity.getDriverName())) { |
|
|
|
|
newLoadscaninvnEntity.setDriverName(distributionDeliverySelfEntity.getDriverName()); |
|
|
|
|
} |
|
|
|
|
if (Func.isNotEmpty(distributionDeliverySelfEntity.getVehicleId())) { |
|
|
|
|
newLoadscaninvnEntity.setVehicleId(distributionDeliverySelfEntity.getVehicleId()); |
|
|
|
|
} |
|
|
|
|
if (Func.isNotEmpty(distributionDeliverySelfEntity.getVehicleNub())) { |
|
|
|
|
newLoadscaninvnEntity.setVehicleName(distributionDeliverySelfEntity.getVehicleNub()); |
|
|
|
|
} |
|
|
|
|
if (Func.isNotEmpty(distributionDeliverySelfEntity.getDriverPhone())) { |
|
|
|
|
newLoadscaninvnEntity.setDriverPhone(distributionDeliverySelfEntity.getDriverPhone()); |
|
|
|
|
} |
|
|
|
|
newLoadscaninvnEntity.setLoadingId(distributionDeliverySelfEntity.getId().toString()); |
|
|
|
|
newLoadscaninvnEntity.setOrderPackageCode(detailEntity.getStockPackageCode()); |
|
|
|
|
newLoadscaninvnEntity.setInventoryId(detailEntity.getStockListId()); |
|
|
|
|
newLoadscaninvnEntity.setDeliveryId(distributionSignforEntity.getDeliveryId()); |
|
|
|
|
newLoadscaninvnEntity.setReservationId(distributionSignforEntity.getReservationId()); |
|
|
|
|
newLoadscaninvnEntity.setInventoryPackageId(detailEntity.getId()); |
|
|
|
|
newLoadscaninvnEntity.setScanUser(user.getNickName()); |
|
|
|
|
newLoadscaninvnEntity.setScanTime(simpleDateFormat.format(new Date())); |
|
|
|
|
newLoadscaninvnEntity.setPackageNub(detailEntity.getNum()); |
|
|
|
|
newLoadscaninvnEntity.setScanStatus(LoadingStatusConstant.yijianzhuangche.getValue()); |
|
|
|
|
newLoadscaninvnEntity.setIsInsert(LoadingIsInsertConstant.bulu.getValue()); |
|
|
|
|
newLoadscaninvnEntity.setScanType("1"); |
|
|
|
|
newLoadscaninvnEntity.setType(2); |
|
|
|
|
newLoadscaninvnEntity.setSignforState(LoadScanSigningStatusConstant.yiqianshou.getValue()); |
|
|
|
|
newLoadscaninvnEntity.setIsSignfor(1); |
|
|
|
|
newLoadscaninvnEntity.setReceivedQuantity(detailEntity.getNum()); |
|
|
|
|
newLoadscaninvnEntity.setOneClick(2); |
|
|
|
|
newLoadscaninvnEntity.setOneQclick(2); |
|
|
|
|
newLoadscaninvnEntity.setSigningUser(user.getNickName()); |
|
|
|
|
newLoadscaninvnEntity.setSigningUserId(user.getUserId()); |
|
|
|
|
newLoadscaninvnEntity.setSigningTime(simpleDateFormat.format(new Date())); |
|
|
|
|
if (distributionSignfor.getIsClerk()) { |
|
|
|
|
newLoadscaninvnEntity.setMsg("文员一键签收数据补录"); |
|
|
|
|
} else { |
|
|
|
|
newLoadscaninvnEntity.setMsg("司机一键签收数据补录"); |
|
|
|
|
} |
|
|
|
|
distributionLoadscaninvnService.save(newLoadscaninvnEntity); |
|
|
|
|
Integer i = distributionDeliveryListMapper.updateloadingTimeById(distributionDeliveryListEntity.getId()); |
|
|
|
|
//更新签收表的签收数量和装车数量
|
|
|
|
|
Integer j = distributionSignforMapper.updateLoadAndsignforByinvn(newLoadscaninvnEntity.getDeliveryId(), newLoadscaninvnEntity.getReservationId(), newLoadscaninvnEntity.getPackageNub()); |
|
|
|
|
//更新签收人
|
|
|
|
|
Integer m = distributionSignforMapper.updateSignUser(newLoadscaninvnEntity.getDeliveryId(), newLoadscaninvnEntity.getReservationId(), AuthUtil.getUser()); |
|
|
|
|
|
|
|
|
|
//维护预约库存品数据
|
|
|
|
|
//扣减库存
|
|
|
|
|
DistributionStockListEntity stockListEntity = distributionStockListService.getById(detailEntity.getStockListId()); |
|
|
|
|
stockListEntity.setQuantityOccupied(stockListEntity.getQuantityOccupied() - newLoadscaninvnEntity.getPackageNub()); |
|
|
|
|
stockListEntity.setQuantityStock(stockListEntity.getQuantityStock() - newLoadscaninvnEntity.getPackageNub()); |
|
|
|
|
stockListEntity.setOutboundQuantity(stockListEntity.getOutboundQuantity() + newLoadscaninvnEntity.getPackageNub()); |
|
|
|
|
distributionStockListService.updateById(stockListEntity); |
|
|
|
|
distributionAsyncService.checkSignStatus(null, newLoadscaninvnEntity.getReservationId(), newLoadscaninvnEntity.getDeliveryId()); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} else { |
|
|
|
|
log.error("################库存品未进行备货操作+{}" , detailEntities); |
|
|
|
|
return R.fail("库存品未进行备货操作"); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
//查询出该签收任务下的客户对应的所有包件和库存品信息
|
|
|
|
|
List<DistributionParcelListEntity> parcelListEntityList = distributionReservationMapper.selectPackageListByReservationId(distributionSignforEntity.getReservationId()); |
|
|
|
|
//包件不需要考虑备货、装车直接可进行签收 过滤已装车的包件
|
|
|
|
|
// List<DistributionParcelListEntity> noLoadingPackage = parcelListEntityList.stream().filter(p -> p.getOrderPackageLoadingStatus().equals(OrderPackageLoadingStatusConstant.weizhuancghe.getValue())).collect(Collectors.toList());
|
|
|
|
|
//查询该客户下的所有零担信息
|
|
|
|
|
List<DistributionParcelNumberDTO> parcelNumberEntityList = distributionReservationMapper.selectZeroPackageListByReservationId(distributionSignforEntity.getReservationId()); |
|
|
|
|
if (Func.isNotEmpty(parcelNumberEntityList)) { |
|
|
|
|
for (DistributionParcelNumberDTO parcelNumberEntity : parcelNumberEntityList) { |
|
|
|
|
DistributionLoadscanEntity distributionLoadscanEntity = distributionLoadscanService.getOne(Wrappers.<DistributionLoadscanEntity>query().lambda().eq(DistributionLoadscanEntity::getReservationId, distributionSignforEntity.getReservationId()).eq(DistributionLoadscanEntity::getPackageId, parcelNumberEntity.getParcelListId()).ne(DistributionLoadscanEntity::getScanStatus, LoadingStatusConstant.quxiao.getValue())); |
|
|
|
|
if (Func.isNotEmpty(distributionLoadscanEntity)) { |
|
|
|
|
//情况列举:
|
|
|
|
|
// 1、装车件数未按照计划数量
|
|
|
|
|
// 2、装车件数齐套,签收数量未签收
|
|
|
|
|
// 3、部分签收
|
|
|
|
|
// 4、完成签收
|
|
|
|
|
//不论什么情况均进行一次重新签收维护数量
|
|
|
|
|
DistributionParcelNumberEntity distributionParcelNumberEntity = distributionParcelNumberService.getById(parcelNumberEntity.getId()); |
|
|
|
|
BigDecimal signinQuantity = new BigDecimal(distributionParcelNumberEntity.getSigninQuantity()); |
|
|
|
|
BigDecimal reservationNum = new BigDecimal(parcelNumberEntity.getReservationNum()); |
|
|
|
|
BigDecimal deliveryQuantity = new BigDecimal(distributionParcelNumberEntity.getDeliveryQuantity()); |
|
|
|
|
BigDecimal handQuantity = new BigDecimal(distributionParcelNumberEntity.getHandQuantity()); |
|
|
|
|
BigDecimal outboundQuantity = new BigDecimal(distributionParcelNumberEntity.getOutboundQuantity()); |
|
|
|
|
BigDecimal loadedQuantity = new BigDecimal(distributionLoadscanEntity.getLoadedNub()); |
|
|
|
|
BigDecimal receivedQuantity = new BigDecimal(distributionLoadscanEntity.getReceivedQuantity()); |
|
|
|
|
if (distributionLoadscanEntity.getSignforState().equals(LoadScanSigningStatusConstant.yiqianshou.getValue())) { |
|
|
|
|
//装车数量和签收数量只会一样,
|
|
|
|
|
if (distributionLoadscanEntity.getReceivedQuantity() > 0) { |
|
|
|
|
distributionParcelNumberEntity.setSigninQuantity(signinQuantity.add(reservationNum).subtract(receivedQuantity).intValue()); |
|
|
|
|
distributionParcelNumberEntity.setHandQuantity(handQuantity.add(receivedQuantity).subtract(reservationNum).intValue()); |
|
|
|
|
distributionParcelNumberEntity.setOutboundQuantity(outboundQuantity.add(reservationNum).subtract(receivedQuantity).intValue()); |
|
|
|
|
distributionParcelNumberEntity.setDeliveryQuantity(deliveryQuantity.add(receivedQuantity).subtract(reservationNum).intValue()); |
|
|
|
|
distributionParcelNumberService.updateById(distributionParcelNumberEntity); |
|
|
|
|
} else { |
|
|
|
|
log.error("################扫描签收零担订单数量为0:{}", distributionLoadscanEntity); |
|
|
|
|
return Resp.scanFail("服务器正忙...", "请稍后重试"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} else if (distributionLoadscanEntity.getSignforState().equals(LoadScanSigningStatusConstant.weiqianshou.getValue())) { |
|
|
|
|
if (distributionLoadscanEntity.getLoadedNub() .equals(parcelNumberEntity.getReservationNum()) ) { |
|
|
|
|
//装车数量和计划数量一致,这里进行签收数量的维护
|
|
|
|
|
//修改这里装车数量已经维护好了,只需要维护签收数量
|
|
|
|
|
distributionParcelNumberEntity.setSigninQuantity(signinQuantity.add(reservationNum).intValue()); |
|
|
|
|
distributionParcelNumberService.updateById(distributionParcelNumberEntity); |
|
|
|
|
} else { |
|
|
|
|
if (distributionLoadscanEntity.getLoadedNub() > 0) { |
|
|
|
|
distributionParcelNumberEntity.setSigninQuantity(signinQuantity.add(reservationNum).intValue()); |
|
|
|
|
distributionParcelNumberEntity.setHandQuantity(handQuantity.add(loadedQuantity).subtract(reservationNum).intValue()); |
|
|
|
|
distributionParcelNumberEntity.setOutboundQuantity(outboundQuantity.add(reservationNum).subtract(loadedQuantity).intValue()); |
|
|
|
|
distributionParcelNumberEntity.setDeliveryQuantity(deliveryQuantity.add(loadedQuantity).subtract(reservationNum).intValue()); |
|
|
|
|
distributionParcelNumberService.updateById(distributionParcelNumberEntity); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} else { |
|
|
|
|
log.error("##################扫描签收状态异常:{}", distributionLoadscanEntity.getId()); |
|
|
|
|
throw new RuntimeException("服务器正忙..."); |
|
|
|
|
} |
|
|
|
|
distributionLoadscanEntity.setReceivedQuantity(parcelNumberEntity.getReservationNum()); |
|
|
|
|
distributionLoadscanEntity.setLoadedNub(parcelNumberEntity.getReservationNum()); |
|
|
|
|
distributionLoadscanEntity.setPackageNub(parcelNumberEntity.getReservationNum()); |
|
|
|
|
distributionLoadscanEntity.setSignforState(LoadScanSigningStatusConstant.yiqianshou.getValue()); |
|
|
|
|
if (distributionSignfor.getIsClerk()) { |
|
|
|
|
distributionLoadscanEntity.setMsg("文员一键签收数据补录"); |
|
|
|
|
} else { |
|
|
|
|
distributionLoadscanEntity.setMsg("司机一键签收数据补录"); |
|
|
|
|
} |
|
|
|
|
distributionLoadscanService.updateById(distributionLoadscanEntity); |
|
|
|
|
distributionAsyncService.checkSignStatus(distributionLoadscanEntity.getPackageId(), distributionLoadscanEntity.getReservationId(), distributionLoadscanEntity.getDeliveryId()); |
|
|
|
|
//更新签收人
|
|
|
|
|
Integer m = distributionSignforMapper.updateSignUser(distributionLoadscanEntity.getDeliveryId(), distributionLoadscanEntity.getReservationId(), AuthUtil.getUser()); |
|
|
|
|
//维护签收数量
|
|
|
|
|
DistributionSignforEntity signforEntity = distributionSignforMapper.selectOne(Wrappers.<DistributionSignforEntity>query().lambda().eq(DistributionSignforEntity::getDeliveryId, distributionLoadscanEntity.getDeliveryId()).eq(DistributionSignforEntity::getReservationId, distributionLoadscanEntity.getReservationId())); |
|
|
|
|
BigDecimal loadedNumber = new BigDecimal(signforEntity.getLoadedNumber()); |
|
|
|
|
BigDecimal signingReceivedQuantity = new BigDecimal(signforEntity.getReceivedQuantity()); |
|
|
|
|
signforEntity.setLoadedNumber(loadedNumber.subtract(loadedQuantity).add(reservationNum).intValue()); |
|
|
|
|
signforEntity.setReceivedQuantity(signingReceivedQuantity.subtract(receivedQuantity).add(reservationNum).intValue()); |
|
|
|
|
distributionSignforMapper.updateById(signforEntity); |
|
|
|
|
} else { |
|
|
|
|
//不存在装车数据
|
|
|
|
|
DistributionLoadscanEntity loadscanEntity = new DistributionLoadscanEntity(); |
|
|
|
|
loadscanEntity.setPackageId(parcelNumberEntity.getParcelListId()); |
|
|
|
|
loadscanEntity.setOrderId(parcelNumberEntity.getStockArticleId()); |
|
|
|
|
loadscanEntity.setDeliveryId(distributionSignforEntity.getDeliveryId()); |
|
|
|
|
loadscanEntity.setReservationId(distributionSignforEntity.getReservationId()); |
|
|
|
|
loadscanEntity.setScanUser(user.getNickName()); |
|
|
|
|
loadscanEntity.setScanTime(simpleDateFormat.format(new Date())); |
|
|
|
|
loadscanEntity.setPackageNub(parcelNumberEntity.getReservationNum()); |
|
|
|
|
loadscanEntity.setLoadedNub(parcelNumberEntity.getReservationNum()); |
|
|
|
|
loadscanEntity.setSigningUser(user.getUserName()); |
|
|
|
|
loadscanEntity.setSigningUserId(user.getUserId()); |
|
|
|
|
if (Func.isNotEmpty(distributionDeliverySelfEntity.getDriverId())) { |
|
|
|
|
loadscanEntity.setDriverId(distributionDeliverySelfEntity.getDriverId()); |
|
|
|
|
} |
|
|
|
|
if (Func.isNotEmpty(distributionDeliverySelfEntity.getDriverName())) { |
|
|
|
|
loadscanEntity.setDriverName(distributionDeliverySelfEntity.getDriverName()); |
|
|
|
|
} |
|
|
|
|
if (Func.isNotEmpty(distributionDeliverySelfEntity.getVehicleId())) { |
|
|
|
|
loadscanEntity.setVehicleId(distributionDeliverySelfEntity.getVehicleId()); |
|
|
|
|
} |
|
|
|
|
if (Func.isNotEmpty(distributionDeliverySelfEntity.getVehicleNub())) { |
|
|
|
|
loadscanEntity.setVehicleName(distributionDeliverySelfEntity.getVehicleNub()); |
|
|
|
|
} |
|
|
|
|
if (Func.isNotEmpty(distributionDeliverySelfEntity.getDriverPhone())) { |
|
|
|
|
loadscanEntity.setDriverPhone(distributionDeliverySelfEntity.getDriverPhone()); |
|
|
|
|
} |
|
|
|
|
loadscanEntity.setLoadingId(distributionDeliverySelfEntity.getId().toString()); |
|
|
|
|
loadscanEntity.setScanStatus(LoadingStatusConstant.yijianzhuangche.getValue()); |
|
|
|
|
loadscanEntity.setIsInsert(LoadingIsInsertConstant.bulu.getValue()); |
|
|
|
|
loadscanEntity.setScanType("1"); |
|
|
|
|
loadscanEntity.setType(2); |
|
|
|
|
loadscanEntity.setSignforState(LoadScanSigningStatusConstant.yiqianshou.getValue()); |
|
|
|
|
loadscanEntity.setIsSignfor(1); |
|
|
|
|
loadscanEntity.setReceivedQuantity(parcelNumberEntity.getReservationNum()); |
|
|
|
|
loadscanEntity.setOneClick(2); |
|
|
|
|
loadscanEntity.setOneQclick(2); |
|
|
|
|
loadscanEntity.setSigningTime(simpleDateFormat.format(new Date())); |
|
|
|
|
if (distributionSignfor.getIsClerk()) { |
|
|
|
|
loadscanEntity.setMsg("文员一键签收数据补录"); |
|
|
|
|
} else { |
|
|
|
|
loadscanEntity.setMsg("司机一键签收数据补录"); |
|
|
|
|
} |
|
|
|
|
distributionLoadscanService.save(loadscanEntity); |
|
|
|
|
distributionAsyncService.checkSignStatus(loadscanEntity.getPackageId(), loadscanEntity.getReservationId(), loadscanEntity.getDeliveryId()); |
|
|
|
|
|
|
|
|
|
Integer i = distributionDeliveryListMapper.updateloadingTimeById(distributionDeliveryListEntity.getId()); |
|
|
|
|
//更新签收表的签收数量和装车数量
|
|
|
|
|
Integer j = distributionSignforMapper.updateSignforByReservationId(loadscanEntity.getDeliveryId(), loadscanEntity.getReservationId(), loadscanEntity.getPackageNub()); |
|
|
|
|
|
|
|
|
|
//更新签收人
|
|
|
|
|
Integer m = distributionSignforMapper.updateSignUser(loadscanEntity.getDeliveryId(), loadscanEntity.getReservationId(), AuthUtil.getUser()); |
|
|
|
|
|
|
|
|
|
//维护出库数量和签收数量
|
|
|
|
|
DistributionParcelNumberEntity parcelNumberServiceById = distributionParcelNumberService.getById(parcelNumberEntity.getId()); |
|
|
|
|
BigDecimal signinQuantity = new BigDecimal(parcelNumberServiceById.getSigninQuantity()); |
|
|
|
|
BigDecimal reservationNum = new BigDecimal(parcelNumberEntity.getReservationNum()); |
|
|
|
|
BigDecimal deliveryQuantity = new BigDecimal(parcelNumberServiceById.getDeliveryQuantity()); |
|
|
|
|
BigDecimal handQuantity = new BigDecimal(parcelNumberServiceById.getHandQuantity()); |
|
|
|
|
BigDecimal outboundQuantity = new BigDecimal(parcelNumberServiceById.getOutboundQuantity()); |
|
|
|
|
parcelNumberServiceById.setSigninQuantity(signinQuantity.add(reservationNum).intValue()); |
|
|
|
|
parcelNumberServiceById.setDeliveryQuantity(deliveryQuantity.subtract(reservationNum).intValue()); |
|
|
|
|
parcelNumberServiceById.setOutboundQuantity(outboundQuantity.add(reservationNum).intValue()); |
|
|
|
|
parcelNumberServiceById.setHandQuantity(handQuantity.subtract(reservationNum).intValue()); |
|
|
|
|
distributionParcelNumberService.updateById(parcelNumberServiceById); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
String signingTime = simpleDateFormat.format(new Date()); |
|
|
|
|
List<Long> packageIds = new ArrayList<>(); |
|
|
|
|
List<String> orderCodes = new ArrayList<>(); |
|
|
|
|
if (Func.isNotEmpty(parcelListEntityList)) { |
|
|
|
|
for (DistributionParcelListEntity parcelListEntity : parcelListEntityList) { |
|
|
|
|
//查询是否进行装车
|
|
|
|
|
DistributionLoadscanEntity loadscanEntities = distributionLoadscanService.getOne(Wrappers.<DistributionLoadscanEntity>query().lambda() |
|
|
|
|
.eq(DistributionLoadscanEntity::getPackageId, parcelListEntity.getId()) |
|
|
|
|
.eq(DistributionLoadscanEntity::getDeliveryId, distributionSignforEntity.getDeliveryId()) |
|
|
|
|
.eq(DistributionLoadscanEntity::getReservationId, distributionSignforEntity.getReservationId()) |
|
|
|
|
.ne(DistributionLoadscanEntity::getScanStatus, LoadingStatusConstant.quxiao.getValue())); |
|
|
|
|
parcelListEntity.setOrderPackageLoadingStatus(OrderPackageLoadingStatusConstant.yizhuangche.getValue()); |
|
|
|
|
parcelListEntity.setOrderPackageStatus(OrderPackageStatusConstant.yiqianshou.getValue()); |
|
|
|
|
if (Func.isEmpty(loadscanEntities)) { |
|
|
|
|
//没有进行过装车操作
|
|
|
|
|
DistributionLoadscanEntity loadscanEntity = new DistributionLoadscanEntity(); |
|
|
|
|
loadscanEntity.setPackageId(parcelListEntity.getId()); |
|
|
|
|
loadscanEntity.setOrderPackageCode(parcelListEntity.getOrderPackageCode()); |
|
|
|
|
loadscanEntity.setOrderId(parcelListEntity.getStockArticleId()); |
|
|
|
|
loadscanEntity.setDeliveryId(distributionSignforEntity.getDeliveryId()); |
|
|
|
|
loadscanEntity.setReservationId(distributionSignforEntity.getReservationId()); |
|
|
|
|
loadscanEntity.setScanUser(user.getNickName()); |
|
|
|
|
loadscanEntity.setScanTime(signingTime); |
|
|
|
|
loadscanEntity.setPackageNub(parcelListEntity.getQuantity()); |
|
|
|
|
loadscanEntity.setSigningUser(user.getNickName()); |
|
|
|
|
loadscanEntity.setSigningUserId(user.getUserId()); |
|
|
|
|
if (Func.isNotEmpty(distributionDeliverySelfEntity.getDriverId())) { |
|
|
|
|
loadscanEntity.setDriverId(distributionDeliverySelfEntity.getDriverId()); |
|
|
|
|
} |
|
|
|
|
if (Func.isNotEmpty(distributionDeliverySelfEntity.getDriverName())) { |
|
|
|
|
loadscanEntity.setDriverName(distributionDeliverySelfEntity.getDriverName()); |
|
|
|
|
} |
|
|
|
|
if (Func.isNotEmpty(distributionDeliverySelfEntity.getVehicleId())) { |
|
|
|
|
loadscanEntity.setVehicleId(distributionDeliverySelfEntity.getVehicleId()); |
|
|
|
|
} |
|
|
|
|
if (Func.isNotEmpty(distributionDeliverySelfEntity.getVehicleNub())) { |
|
|
|
|
loadscanEntity.setVehicleName(distributionDeliverySelfEntity.getVehicleNub()); |
|
|
|
|
} |
|
|
|
|
if (Func.isNotEmpty(distributionDeliverySelfEntity.getDriverPhone())) { |
|
|
|
|
loadscanEntity.setDriverPhone(distributionDeliverySelfEntity.getDriverPhone()); |
|
|
|
|
} |
|
|
|
|
loadscanEntity.setLoadingId(distributionDeliverySelfEntity.getId().toString()); |
|
|
|
|
loadscanEntity.setScanStatus(LoadingStatusConstant.yijianzhuangche.getValue()); |
|
|
|
|
loadscanEntity.setIsInsert(LoadingIsInsertConstant.bulu.getValue()); |
|
|
|
|
loadscanEntity.setScanType("1"); |
|
|
|
|
loadscanEntity.setType(2); |
|
|
|
|
loadscanEntity.setSignforState(LoadScanSigningStatusConstant.yiqianshou.getValue()); |
|
|
|
|
loadscanEntity.setIsSignfor(1); |
|
|
|
|
loadscanEntity.setReceivedQuantity(parcelListEntity.getQuantity()); |
|
|
|
|
loadscanEntity.setOneClick(2); |
|
|
|
|
loadscanEntity.setOneQclick(2); |
|
|
|
|
loadscanEntity.setSigningTime(signingTime); |
|
|
|
|
if (distributionSignfor.getIsClerk()) { |
|
|
|
|
loadscanEntity.setMsg("文员一键签收数据补录"); |
|
|
|
|
} else { |
|
|
|
|
loadscanEntity.setMsg("司机一键签收数据补录"); |
|
|
|
|
} |
|
|
|
|
distributionLoadscanService.save(loadscanEntity); |
|
|
|
|
Integer i = distributionDeliveryListMapper.updateloadingTimeById(distributionDeliveryListEntity.getId()); |
|
|
|
|
//更新签收表的签收数量和装车数量
|
|
|
|
|
Integer j = distributionSignforMapper.updateSignforByReservationId(loadscanEntity.getDeliveryId(), loadscanEntity.getReservationId(), loadscanEntity.getPackageNub()); |
|
|
|
|
//扣减订单的在库数量
|
|
|
|
|
Integer k = distributionStockArticleMapper.deductionHandQuantity(loadscanEntity.getOrderId(), loadscanEntity.getLoadedNub()); |
|
|
|
|
//更新签收人
|
|
|
|
|
Integer m = distributionSignforMapper.updateSignUser(loadscanEntity.getDeliveryId(), loadscanEntity.getReservationId(), AuthUtil.getUser()); |
|
|
|
|
|
|
|
|
|
} else { |
|
|
|
|
//存在装车数据
|
|
|
|
|
if (distributionSignfor.getIsClerk()) { |
|
|
|
|
loadscanEntities.setMsg("文员一键签收数据补录"); |
|
|
|
|
} else { |
|
|
|
|
loadscanEntities.setMsg("司机一键签收数据补录"); |
|
|
|
|
} |
|
|
|
|
if (!loadscanEntities.getSignforState().equals(LoadScanSigningStatusConstant.yiqianshou.getValue())) { |
|
|
|
|
//已经进行过装车 这里不需要进行订制品订单在库数量扣减
|
|
|
|
|
loadscanEntities.setSignforState(LoadScanSigningStatusConstant.yiqianshou.getValue()); |
|
|
|
|
loadscanEntities.setReceivedQuantity(parcelListEntity.getQuantity()); |
|
|
|
|
loadscanEntities.setOneClick(1); |
|
|
|
|
loadscanEntities.setOneQclick(2); |
|
|
|
|
loadscanEntities.setSigningUser(user.getNickName()); |
|
|
|
|
loadscanEntities.setSigningUserId(user.getUserId()); |
|
|
|
|
loadscanEntities.setReceivedQuantity(parcelListEntity.getQuantity()); |
|
|
|
|
loadscanEntities.setSigningTime(signingTime); |
|
|
|
|
distributionLoadscanService.updateById(loadscanEntities); |
|
|
|
|
Integer i = distributionDeliveryListMapper.updateloadingTimeById(distributionDeliveryListEntity.getId()); |
|
|
|
|
//更新签收数量
|
|
|
|
|
Integer j = distributionSignforMapper.updateSignforNum(loadscanEntities.getDeliveryId(), loadscanEntities.getReservationId(), loadscanEntities.getPackageNub()); |
|
|
|
|
//更新签收人
|
|
|
|
|
Integer m = distributionSignforMapper.updateSignUser(loadscanEntities.getDeliveryId(), loadscanEntities.getReservationId(), AuthUtil.getUser()); |
|
|
|
|
distributionAsyncService.checkSignStatus(loadscanEntities.getPackageId(), loadscanEntities.getReservationId(), loadscanEntities.getDeliveryId()); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
distributionAsyncService.sendFactory(parcelListEntity,simpleDateFormat.format(new Date()), reservationEntity.getId(), reservationEntity.getReservationCode(), myCurrentWarehouse.getName(),user.getNickName()); |
|
|
|
|
packageIds.add(parcelListEntity.getId()); |
|
|
|
|
orderCodes.add(parcelListEntity.getOrderCode()); |
|
|
|
|
} |
|
|
|
|
//批量维护订单信息
|
|
|
|
|
if (Func.isNotEmpty(orderCodes)){ |
|
|
|
|
String orderCode = orderCodes.stream().distinct().collect(Collectors.joining(",")); |
|
|
|
|
distributionStockArticleService.maintenanceOrderInfo(orderCode,myCurrentWarehouse.getId()); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (Func.isNotEmpty(packageIds)) { |
|
|
|
|
distributionAsyncService.handlPakcage(packageIds, myCurrentWarehouse.getId()); |
|
|
|
|
//批量推送
|
|
|
|
|
distributionAsyncService.sendReviewFactory(distributionSignforEntity.getId(),myCurrentWarehouse.getName() ,myCurrentWarehouse.getId()); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
//维护客户信息状态
|
|
|
|
|
reservationEntity.setLoadingStatus(ReservationLoadingStatusConstant.yizhuangche.getValue()); |
|
|
|
|
reservationEntity.setSigningStatus(ReservationSigningStatusConstant.yiqianshou.getValue()); |
|
|
|
|
distributionReservationMapper.updateById(reservationEntity); |
|
|
|
|
//维护签收状态
|
|
|
|
|
|
|
|
|
|
// distributionAsyncService.checkDeliverySignStatusByReservation(distributionSignforEntity.getDeliveryId());
|
|
|
|
|
// distributionDeliveryListEntity.setDeliveryListLoadingStatus(ReservationLoadingStatusConstant.yizhuangche.getValue());
|
|
|
|
|
// if (distributionSignfor.getIsClerk()) {
|
|
|
|
|
// distributionDeliveryListEntity.setDeliveryStatus(DeliveryStatusConstant.peisongzhong.getValue());
|
|
|
|
|
// } else {
|
|
|
|
|
// distributionDeliveryListEntity.setDeliveryStatus(DeliveryStatusConstant.yiwancheng.getValue());
|
|
|
|
|
// }
|
|
|
|
|
// distributionDeliveryListMapper.updateById(distributionDeliveryListEntity);
|
|
|
|
|
LambdaUpdateWrapper<DistributionSignforEntity> set = new UpdateWrapper<DistributionSignforEntity>().lambda() |
|
|
|
|
.eq(DistributionSignforEntity::getId, distributionSignforEntity.getId()) |
|
|
|
|
.set(StringUtils.isNotBlank(distributionSignfor.getDeliverySignPictures()), DistributionSignforEntity::getDeliverySignPictures, distributionSignfor.getDeliverySignPictures()) |
|
|
|
|
.set(StringUtils.isNotBlank(distributionSignfor.getSigningType()), DistributionSignforEntity::getSigningType, distributionSignfor.getSigningType()) |
|
|
|
|
.set(DistributionSignforEntity::getDriverSigning, 2) |
|
|
|
|
.set(!distributionSignfor.getIsClerk() && StringUtils.isNotBlank(distributionSignfor.getDriverRemarks()), DistributionSignforEntity::getDriverRemarks, distributionSignfor.getDriverRemarks()) |
|
|
|
|
.set(DistributionSignforEntity::getDriverSigning, 2); |
|
|
|
|
boolean update = this.update(set); |
|
|
|
|
//维护配送信息
|
|
|
|
|
return R.status(true); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|