diff --git a/blade-service/logpm-basicdata/src/main/java/com/logpm/basicdata/controller/BasicdataDriverArteryController.java b/blade-service/logpm-basicdata/src/main/java/com/logpm/basicdata/controller/BasicdataDriverArteryController.java index b8975fa25..50071e22c 100644 --- a/blade-service/logpm-basicdata/src/main/java/com/logpm/basicdata/controller/BasicdataDriverArteryController.java +++ b/blade-service/logpm-basicdata/src/main/java/com/logpm/basicdata/controller/BasicdataDriverArteryController.java @@ -52,6 +52,8 @@ import springfox.documentation.annotations.ApiIgnore; import javax.servlet.http.HttpServletResponse; import javax.validation.Valid; +import java.util.ArrayList; +import java.util.Date; import java.util.List; import java.util.Map; @@ -198,6 +200,7 @@ public class BasicdataDriverArteryController extends BladeController { /** * 导出数据 + * http://localhost:8400/driverArtery/export-basicdataDriverArtery */ @GetMapping("/export-basicdataDriverArtery") @ApiOperationSupport(order = 9) @@ -222,4 +225,41 @@ public class BasicdataDriverArteryController extends BladeController { return R.success("操作成功"); } + /** + * 导出数据模板 + * http://localhost:8400/driverArtery/export-basicdataDriverArteryMb + */ + @GetMapping("/export-basicdataDriverArteryMb") + @ApiOperationSupport(order = 10) + @ApiOperation(value = "导出数据模板", notes = "传入basicdataDriverArtery") + public void exportBasicdataDriverArteryMb(@ApiIgnore @RequestParam Map basicdataDriverArtery, BladeUser bladeUser, HttpServletResponse response) { + List list = new ArrayList<>(); + //存入模板 + BasicdataDriverArteryImproterExcel excel = new BasicdataDriverArteryImproterExcel(); + excel.setName("张三"); + excel.setPhone("13812345678"); + excel.setType("1"); + excel.setJobType("1"); + excel.setDrivingType("1"); + excel.setBindVehicle("川A12345,川B56789"); + excel.setContractStartTime(new Date()); + excel.setContractEndTime(new Date()); + excel.setIdCard("440123198012345678"); + excel.setGender("1"); + excel.setWarehouseName("龙泉仓"); + excel.setResidentialAddress("四川省成都市龙泉驿区车城东六路"); + excel.setBankType("1"); + excel.setBankCardNub("1234567890123456789"); + excel.setDriverLicenseNub("A123456789"); + excel.setDriverLicenseOrgan("四川省成都市市公安局交警支队"); + excel.setDriverLicenseStartTime(new Date()); + excel.setDriverLicenseEndTime(new Date()); + excel.setEmployeeQualificationNub("A987654321"); + excel.setRoadOperationLicenseNub("B123456789"); + excel.setCarrierName("汇通运输"); + excel.setTransportationAgreement("运输协议123"); + excel.setNotes("这是备注信息"); + list.add(excel); + ExcelUtil.export(response, "司机信息数据模板" + DateUtil.time(), "司机信息数据模板表", list, BasicdataDriverArteryImproterExcel.class); + } } diff --git a/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/appcontroller/DistributionSignforAppController.java b/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/appcontroller/DistributionSignforAppController.java index 940389b4c..4ec7c3be0 100644 --- a/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/appcontroller/DistributionSignforAppController.java +++ b/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/appcontroller/DistributionSignforAppController.java @@ -231,7 +231,7 @@ public class DistributionSignforAppController { @ApiOperation(value = "司机一键签收", notes = "传入distributionSignfor") public R oneclick(@Valid @RequestBody DistributionSignforDTO distributionSignfor) { distributionSignfor.setIsClerk(false); - R r = distributionSignforService.oneclick(distributionSignfor); + R r = distributionSignforService.oneclickPDA(distributionSignfor); List packageCodes = (List)r.getData(); try{ String orderPackageCodes = null; diff --git a/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/mapper/DistributionStockListMapper.xml b/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/mapper/DistributionStockListMapper.xml index 43d368afc..d62f25cd4 100644 --- a/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/mapper/DistributionStockListMapper.xml +++ b/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/mapper/DistributionStockListMapper.xml @@ -452,7 +452,7 @@ FROM logpm_distribution_stock_list ldsl - ldsl.service_type = #{par.serviceType} and ldsl.warehouse_id = #{par.warehouseId} and ldsl.is_deleted = 0 + ldsl.service_type = #{par.serviceType} and ldsl.warehouse_id = #{par.warehouseId} and ldsl.is_deleted = 0 and (ldsl.quantity_stock - ldsl.quantity_occupied) > 0 and ldsl.incoming_batch like concat('%',#{par.incomingBatch},'%') diff --git a/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/service/IDistributionSignforService.java b/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/service/IDistributionSignforService.java index bd9d349e0..dcfd9f2cc 100644 --- a/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/service/IDistributionSignforService.java +++ b/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/service/IDistributionSignforService.java @@ -138,6 +138,11 @@ public interface IDistributionSignforService extends BaseService keyongshuliang) { + throw new RuntimeException("库存品库内数量不足!!!"); + } //新增库存品 reservationStocklistEntity.setStocklistId(distributionStockListDTO.getId()); reservationStocklistEntity.setReservationId(id); diff --git a/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/service/impl/DistributionSignforServiceImpl.java b/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/service/impl/DistributionSignforServiceImpl.java index e4a66e6ab..e535a0b4a 100644 --- a/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/service/impl/DistributionSignforServiceImpl.java +++ b/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/service/impl/DistributionSignforServiceImpl.java @@ -3180,6 +3180,455 @@ public class DistributionSignforServiceImpl extends BaseServiceImpl 这里一件签收针对的就是制定的任务下的包件和库存品 + // 无效 -- > 直接提示该次操作无效 无效的场景快速点击操作两次签收的动作,司机已经进行了所有的包件签收扫描但是还未进行签收确认的动作 + // 有效 -- > + // 查询该车次任务中装车的包件和库存品 此时一键签收就需要将该车次中的所有包件和库存品都进行签收 +// 此时考虑多种场景: +// 1、存在库存品 库存品未进行备货操作无法进行一件装车,但是对于已备货的库存品可以进行装车 +// 2、多个车次的配送任务进行一件签收状态、在没有进行装车操作的时候 +// +// 3、对于已经装车的库存品或者包件在一件签收的时候需要进行过滤 +// Map> 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().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().lambda() + .eq(DistributionDeliverySelfEntity::getIsMaster, 2) + .eq(DistributionDeliverySelfEntity::getDeliveryId, distributionSignfor.getDeliveryId()) + ); + } else { + //三方 + DistributionDeliveryTripartiteEntity distributionDeliveryTripartiteEntity = distributionDeliveryTripartiteMapper.selectOne(new QueryWrapper().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 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.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 parcelListEntityList = distributionReservationMapper.selectPackageListByReservationId(distributionSignforEntity.getReservationId()); + //包件不需要考虑备货、装车直接可进行签收 过滤已装车的包件 +// List noLoadingPackage = parcelListEntityList.stream().filter(p -> p.getOrderPackageLoadingStatus().equals(OrderPackageLoadingStatusConstant.weizhuancghe.getValue())).collect(Collectors.toList()); + //查询该客户下的所有零担信息 + List parcelNumberEntityList = distributionReservationMapper.selectZeroPackageListByReservationId(distributionSignforEntity.getReservationId()); + if (Func.isNotEmpty(parcelNumberEntityList)) { + for (DistributionParcelNumberDTO parcelNumberEntity : parcelNumberEntityList) { + DistributionLoadscanEntity distributionLoadscanEntity = distributionLoadscanService.getOne(Wrappers.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.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 packageIds = new ArrayList<>(); + List orderCodes = new ArrayList<>(); + if (Func.isNotEmpty(parcelListEntityList)) { + for (DistributionParcelListEntity parcelListEntity : parcelListEntityList) { + //查询是否进行装车 + DistributionLoadscanEntity loadscanEntities = distributionLoadscanService.getOne(Wrappers.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 set = new UpdateWrapper().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); } diff --git a/blade-service/logpm-patch/src/main/java/com/logpm/patch/controller/SyncServiceTypeController.java b/blade-service/logpm-patch/src/main/java/com/logpm/patch/controller/SyncServiceTypeController.java new file mode 100644 index 000000000..d616090de --- /dev/null +++ b/blade-service/logpm-patch/src/main/java/com/logpm/patch/controller/SyncServiceTypeController.java @@ -0,0 +1,35 @@ +package com.logpm.patch.controller; + +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; +import com.logpm.patch.dto.SyncInventoryDTO; +import com.logpm.patch.entity.SyncInventoryEntity; +import com.logpm.patch.service.ISyncServiceTypeService; + +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import lombok.AllArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springblade.core.tool.api.R; +import org.springframework.web.bind.annotation.*; + +/* + * logisticsplatform-service + * @Author Diss + * @Create 2024/1/15 12:30 + */ +@Slf4j +@RestController +@AllArgsConstructor +@RequestMapping("/syncServiceType") +@Api(value = "同步订单信息控制器", tags = "同步订单信息接口") +public class SyncServiceTypeController { + private final ISyncServiceTypeService syncServiceTypeService; + @ResponseBody + @PostMapping("/change") + @ApiOperation(value = "分页", notes = "传入运单号,仓库名称,商店名称") + public R change(@RequestParam String id, @RequestParam String warehouseName, @RequestParam String mallName) { + syncServiceTypeService.syncServiceType(id, warehouseName, mallName); + return R.success("修改成功"); + } +} diff --git a/blade-service/logpm-patch/src/main/java/com/logpm/patch/mapper/SyncServiceTypeMapper.java b/blade-service/logpm-patch/src/main/java/com/logpm/patch/mapper/SyncServiceTypeMapper.java new file mode 100644 index 000000000..13ff20c55 --- /dev/null +++ b/blade-service/logpm-patch/src/main/java/com/logpm/patch/mapper/SyncServiceTypeMapper.java @@ -0,0 +1,16 @@ +package com.logpm.patch.mapper; + +import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; + +/* + * logisticsplatform-service + * @Author Diss + * @Create 2024/1/15 14:46 + */ +@Mapper +public interface SyncServiceTypeMapper { + void syncServiceTypeByMallName(@Param("stockArticleId")Long stockArticleId, @Param("mallName")String mallName); + + void syncServiceTypeByWarehouseName(@Param("stockArticleId")Long stockArticleId, @Param("warehouseName") String warehouseName); +} diff --git a/blade-service/logpm-patch/src/main/java/com/logpm/patch/mapper/SyncServiceTypeMapper.xml b/blade-service/logpm-patch/src/main/java/com/logpm/patch/mapper/SyncServiceTypeMapper.xml new file mode 100644 index 000000000..b3722ce89 --- /dev/null +++ b/blade-service/logpm-patch/src/main/java/com/logpm/patch/mapper/SyncServiceTypeMapper.xml @@ -0,0 +1,21 @@ + + + + + + + UPDATE logpm_distribution_stock_article ldsa + LEFT JOIN logpm_basicdata_client lbc ON lbc.client_name = #{mallName} AND lbc.is_deleted = 0 + LEFT JOIN logpm_basicdata_store_business lbsb ON lbsb.client_id = lbc.id + SET ldsa.mall_id = COALESCE(lbc.id, ldsa.mall_id), + ldsa.mall_code = COALESCE(lbc.client_code, ldsa.mall_code), + ldsa.mall_name = COALESCE(lbc.client_name, ldsa.mall_name), + ldsa.type_service = COALESCE(lbsb.type_service, ldsa.type_service), + ldsa.consignee_unit = #{mallName} + WHERE ldsa.id = #{stockArticleId}; + + + + + + diff --git a/blade-service/logpm-patch/src/main/java/com/logpm/patch/service/ISyncServiceTypeService.java b/blade-service/logpm-patch/src/main/java/com/logpm/patch/service/ISyncServiceTypeService.java new file mode 100644 index 000000000..3820da314 --- /dev/null +++ b/blade-service/logpm-patch/src/main/java/com/logpm/patch/service/ISyncServiceTypeService.java @@ -0,0 +1,14 @@ +package com.logpm.patch.service; +/* + * logisticsplatform-service + * @Author Diss + * @Create 2024/1/15 13:57 + */ + +import org.springframework.web.bind.annotation.RequestParam; + +public interface ISyncServiceTypeService { + + void syncServiceType( String id, String warehouseName, String shopName) ; + + } diff --git a/blade-service/logpm-patch/src/main/java/com/logpm/patch/service/impl/SyncServiceTypeServiceImpl.java b/blade-service/logpm-patch/src/main/java/com/logpm/patch/service/impl/SyncServiceTypeServiceImpl.java new file mode 100644 index 000000000..54560a76b --- /dev/null +++ b/blade-service/logpm-patch/src/main/java/com/logpm/patch/service/impl/SyncServiceTypeServiceImpl.java @@ -0,0 +1,48 @@ +package com.logpm.patch.service.impl; +/* + * logisticsplatform-service + * @Author Diss + * @Create 2024/1/15 14:04 + */ + +import com.logpm.distribution.entity.DistributionParcelListEntity; +import com.logpm.distribution.feign.IDistributionParcelListClient; +import com.logpm.patch.controller.SyncServiceTypeController; +import com.logpm.patch.mapper.SyncServiceTypeMapper; +import com.logpm.patch.service.ISyncServiceTypeService; +import lombok.AllArgsConstructor; +import lombok.extern.log4j.Log4j2; +import org.springblade.core.log.exception.ServiceException; +import org.springframework.stereotype.Service; + +import java.util.Objects; + +@Log4j2 +@Service +@AllArgsConstructor +public class SyncServiceTypeServiceImpl implements ISyncServiceTypeService { + private final IDistributionParcelListClient distributionParcelListClient; + private final SyncServiceTypeMapper syncServiceTypeMapper; + + @Override + public void syncServiceType(String id, String warehouseName, String mallName) { + DistributionParcelListEntity distributionParcelListEntity = distributionParcelListClient.findByOrderPackageCodeAndStatus(id); + if (distributionParcelListEntity==null){ + throw new ServiceException("订单号不存在"); + } + Long stockArticleId = distributionParcelListEntity.getStockArticleId(); + //判断那个是仓库名称和商店名称谁是null + if (Objects.isNull(warehouseName) || warehouseName.isEmpty()){ + //用订单和商店名称来操作 //修改商场名称 id code 服务类型 收货单位 + + syncServiceTypeMapper.syncServiceTypeByMallName(stockArticleId,mallName); + + }else if(Objects.isNull(mallName) || mallName.isEmpty()){ + //用订单号和仓库名称来操作 + syncServiceTypeMapper.syncServiceTypeByWarehouseName(stockArticleId,warehouseName); + }else { + throw new ServiceException("请传入仓库名称或商店名称"); + } + + } +}