|
|
@@ -519,17 +519,18 @@ public class TradingBoxServiceImpl extends ServiceImpl<TradingBoxMapper, Trading
|
|
|
item.setBillCorpCnName(tradingBox.getPurchaseCompanyName());
|
|
|
item.setBillCorpEnName(tradingBox.getPurchaseCompanyName());
|
|
|
item.setBillShortName(tradingBox.getPurchaseCompanyName());
|
|
|
- item.setMblno(tradingBox.getContractNo());
|
|
|
if ("BUY,ZR,DL".contains(tradingBox.getType())) {
|
|
|
item.setPolId(tradingBox.getAddressId());
|
|
|
item.setPolCode(tradingBox.getAddressCode());
|
|
|
item.setPolCnName(tradingBox.getAddressCname());
|
|
|
item.setPolEnName(tradingBox.getAddressCname());
|
|
|
+ item.setMblno(tradingBox.getContractNo());
|
|
|
} else if ("OW-N,OW-F".contains(tradingBox.getType())) {
|
|
|
item.setPolId(tradingBox.getPolId());
|
|
|
item.setPolCode(tradingBox.getPolCode());
|
|
|
item.setPolCnName(tradingBox.getPolCname());
|
|
|
item.setPolEnName(tradingBox.getPolCname());
|
|
|
+ item.setMblno(tradingBox.getContainerNumber());
|
|
|
} else if ("XGDX,CCSQ".contains(tradingBox.getType())) {
|
|
|
item.setPolId(tradingBox.getPolId());
|
|
|
item.setPolCode(tradingBox.getPolCode());
|
|
|
@@ -539,6 +540,7 @@ public class TradingBoxServiceImpl extends ServiceImpl<TradingBoxMapper, Trading
|
|
|
item.setPodCode(tradingBox.getPodCode());
|
|
|
item.setPodCnName(tradingBox.getPodCname());
|
|
|
item.setPodEnName(tradingBox.getPodCname());
|
|
|
+ item.setMblno(tradingBox.getContractNo());
|
|
|
}
|
|
|
if (item.getId() == null) {
|
|
|
item.setCreateUser(AuthUtil.getUserId());
|
|
|
@@ -4011,4 +4013,232 @@ public class TradingBoxServiceImpl extends ServiceImpl<TradingBoxMapper, Trading
|
|
|
return appearanceList;
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
+ public R batchContainerNumber(TradingBox tradingBox) {
|
|
|
+ if (ObjectUtils.isNull(tradingBox.getId()) || ObjectUtils.isNull(tradingBox.getContainerNumber()) ||
|
|
|
+ ObjectUtils.isNull(tradingBox.getSrcId()) || ObjectUtils.isNull(tradingBox.getTradingBoxItemsList())
|
|
|
+ || tradingBox.getTradingBoxItemsList().isEmpty()) {
|
|
|
+ throw new RuntimeException("缺少必要请求参数");
|
|
|
+ }
|
|
|
+ List<String> codeList = tradingBox.getTradingBoxItemsList().stream().map(TradingBoxItem::getCode).collect(Collectors.toList());
|
|
|
+ List<Archives> archivesList = archivesService.list(new LambdaQueryWrapper<Archives>()
|
|
|
+ .eq(Archives::getTenantId, AuthUtil.getTenantId())
|
|
|
+ .eq(Archives::getIsDeleted, 0)
|
|
|
+ .in(Archives::getCode, codeList));
|
|
|
+ if (archivesList == null) {
|
|
|
+ throw new RuntimeException("未查到箱档案信息");
|
|
|
+ }
|
|
|
+ TradingBox tradingBox1 = baseMapper.selectById(tradingBox.getId());
|
|
|
+ if (tradingBox1 == null) {
|
|
|
+ throw new RuntimeException("未查到单据信息");
|
|
|
+ }
|
|
|
+ PutBox putBox = putBoxService.getOne(new LambdaQueryWrapper<PutBox>()
|
|
|
+ .eq(PutBox::getTenantId, AuthUtil.getTenantId())
|
|
|
+ .eq(PutBox::getIsDeleted, 0)
|
|
|
+ .eq(PutBox::getSrcId, tradingBox1.getId()));
|
|
|
+ if (putBox == null) {
|
|
|
+ throw new RuntimeException("未查到单据信息");
|
|
|
+ }
|
|
|
+ List<PutBoxItems> putBoxItemsList = putBoxItemsService.list(new LambdaQueryWrapper<PutBoxItems>()
|
|
|
+ .eq(PutBoxItems::getTenantId, AuthUtil.getTenantId())
|
|
|
+ .eq(PutBoxItems::getIsDeleted, 0)
|
|
|
+ .eq(PutBoxItems::getPid, putBox.getId())
|
|
|
+ .in(PutBoxItems::getBoxCode, codeList));
|
|
|
+ if (putBoxItemsList == null) {
|
|
|
+ throw new RuntimeException("未查到箱号明细信息");
|
|
|
+ }
|
|
|
+ TradingBox tradingBoxNew = baseMapper.selectById(tradingBox.getSrcId());
|
|
|
+ if (tradingBoxNew == null) {
|
|
|
+ throw new RuntimeException("未查到单据信息");
|
|
|
+ }
|
|
|
+ PutBox putBoxNew = putBoxService.getOne(new LambdaQueryWrapper<PutBox>()
|
|
|
+ .eq(PutBox::getTenantId, AuthUtil.getTenantId())
|
|
|
+ .eq(PutBox::getIsDeleted, 0)
|
|
|
+ .eq(PutBox::getSrcId, tradingBoxNew.getId()));
|
|
|
+ if (putBoxNew == null) {
|
|
|
+ throw new RuntimeException("未查到单据信息");
|
|
|
+ }
|
|
|
+ String[] arr = tradingBox1.getCode().split(",");
|
|
|
+ List<String> codeNew = new ArrayList<>();
|
|
|
+ for (String item : arr) {
|
|
|
+ if (!codeList.contains(item)) {
|
|
|
+ codeNew.add(item);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //原OW拿单据
|
|
|
+ tradingBox1.setCode(String.join(",", codeNew));
|
|
|
+ tradingBox1.setBoxNumber(tradingBox1.getBoxNumber() - tradingBox.getTradingBoxItemsList().size());
|
|
|
+ tradingBox1.setSuitcaseNum(tradingBox1.getSuitcaseNum() - tradingBox.getTradingBoxItemsList().size());
|
|
|
+ tradingBox1.setNotSuitcaseNum(tradingBox1.getBoxNumber()-tradingBox1.getSuitcaseNum());
|
|
|
+ tradingBox1.setUpdateTime(new Date());
|
|
|
+ tradingBox1.setUpdateUser(AuthUtil.getUserId());
|
|
|
+ tradingBox1.setUpdateUserName(AuthUtil.getUserName());
|
|
|
+ int version = StringUtil.isBlank(tradingBox1.getVersion()) ? 1 : Integer.parseInt(tradingBox1.getVersion());
|
|
|
+ tradingBox1.setVersion(String.valueOf(version + 1));
|
|
|
+ baseMapper.updateById(tradingBox1);
|
|
|
+ //原放箱号单据
|
|
|
+ putBox.setCode(String.join(",", codeNew));
|
|
|
+ if (putBox.getRemainingNum()<tradingBox.getTradingBoxItemsList().size()){
|
|
|
+ throw new RuntimeException("放箱号可用数量小于本次更改数量");
|
|
|
+ }
|
|
|
+ if (putBox.getStorageNum()<tradingBox.getTradingBoxItemsList().size()){
|
|
|
+ throw new RuntimeException("放箱号盘存数量小于本次更改数量");
|
|
|
+ }
|
|
|
+ putBox.setTotalNum(putBox.getTotalNum() - tradingBox.getTradingBoxItemsList().size());
|
|
|
+ putBox.setRemainingNum(putBox.getRemainingNum() - tradingBox.getTradingBoxItemsList().size());
|
|
|
+ putBox.setStorageNum(putBox.getStorageNum() - tradingBox.getTradingBoxItemsList().size());
|
|
|
+ putBox.setUpdateTime(new Date());
|
|
|
+ putBox.setUpdateUser(AuthUtil.getUserId());
|
|
|
+ putBox.setUpdateUserName(AuthUtil.getUserName());
|
|
|
+ putBox.setVersion(putBox.getVersion()+1);
|
|
|
+ putBoxService.updateById(putBox);
|
|
|
+ //新OW拿单据
|
|
|
+ tradingBoxNew.setCode((ObjectUtils.isNull(tradingBoxNew.getCode()) ? "" : tradingBoxNew.getCode() + ",") + String.join(",", codeList));
|
|
|
+ if (tradingBoxNew.getNotSuitcaseNum() < tradingBox.getTradingBoxItemsList().size()){
|
|
|
+ throw new RuntimeException("放箱号剩余未提箱数量小于本次更改数量");
|
|
|
+ }
|
|
|
+ tradingBoxNew.setSuitcaseNum(tradingBoxNew.getSuitcaseNum()+tradingBox.getTradingBoxItemsList().size());
|
|
|
+ tradingBoxNew.setNotSuitcaseNum(tradingBox1.getBoxNumber()-tradingBox1.getSuitcaseNum());
|
|
|
+ tradingBoxNew.setUpdateTime(new Date());
|
|
|
+ tradingBoxNew.setUpdateUser(AuthUtil.getUserId());
|
|
|
+ tradingBoxNew.setUpdateUserName(AuthUtil.getUserName());
|
|
|
+ int version1 = StringUtil.isBlank(tradingBoxNew.getVersion()) ? 1 : Integer.parseInt(tradingBoxNew.getVersion());
|
|
|
+ tradingBoxNew.setVersion(String.valueOf(version1 + 1));
|
|
|
+ baseMapper.updateById(tradingBoxNew);
|
|
|
+ //新放箱号单据
|
|
|
+ putBoxNew.setCode((ObjectUtils.isNull(tradingBoxNew.getCode()) ? "" : tradingBoxNew.getCode() + ",") + String.join(",", codeList));
|
|
|
+ putBoxNew.setTotalNum(putBox.getTotalNum() + tradingBox.getTradingBoxItemsList().size());
|
|
|
+ putBoxNew.setRemainingNum(putBox.getRemainingNum() + tradingBox.getTradingBoxItemsList().size());
|
|
|
+ putBoxNew.setStorageNum(putBox.getStorageNum() + tradingBox.getTradingBoxItemsList().size());
|
|
|
+ putBoxNew.setUpdateTime(new Date());
|
|
|
+ putBoxNew.setUpdateUser(AuthUtil.getUserId());
|
|
|
+ putBoxNew.setUpdateUserName(AuthUtil.getUserName());
|
|
|
+ putBoxNew.setVersion(putBoxNew.getVersion()+1);
|
|
|
+ putBoxService.updateById(putBoxNew);
|
|
|
+ //OW拿箱明细
|
|
|
+ for (TradingBoxItem item : tradingBox.getTradingBoxItemsList()) {
|
|
|
+ item.setContainerNumber(tradingBoxNew.getContainerNumber());
|
|
|
+ item.setPid(tradingBoxNew.getId());
|
|
|
+ item.setUpdateUserName(AuthUtil.getUserName());
|
|
|
+ item.setUpdateUser(AuthUtil.getUserId());
|
|
|
+ item.setUpdateTime(new Date());
|
|
|
+ item.setBoxEastId(tradingBoxNew.getPurchaseCompanyId());
|
|
|
+ item.setBoxEastName(tradingBoxNew.getPurchaseCompanyName());
|
|
|
+ item.setStationId(tradingBoxNew.getPolStationId());
|
|
|
+ item.setStationCode(tradingBoxNew.getPolStationCode());
|
|
|
+ item.setStationCname(tradingBoxNew.getPolStationCname());
|
|
|
+ item.setStationEname(tradingBoxNew.getPolStationEname());
|
|
|
+ item.setPolCyId(tradingBoxNew.getPolStationId());
|
|
|
+ item.setPolCyCode(tradingBoxNew.getPolStationCode());
|
|
|
+ item.setPolCyCname(tradingBoxNew.getPolStationCname());
|
|
|
+ item.setPolCyEname(tradingBoxNew.getPolStationEname());
|
|
|
+ item.setPortId(tradingBoxNew.getPolId());
|
|
|
+ item.setPortCode(tradingBoxNew.getPolCode());
|
|
|
+ item.setPortCname(tradingBoxNew.getPolCname());
|
|
|
+ item.setPortEname(tradingBoxNew.getPolEname());
|
|
|
+ }
|
|
|
+ tradingBoxItemService.updateBatchById(tradingBox.getTradingBoxItemsList());
|
|
|
+ List<ArchivesTrajectory> archivesTrajectoryList = new ArrayList<>();
|
|
|
+ List<Archives> archives = new ArrayList<>();
|
|
|
+ //放箱号箱明细
|
|
|
+ for (PutBoxItems item : putBoxItemsList) {
|
|
|
+ item.setPid(putBoxNew.getId());
|
|
|
+ item.setUpdateTime(new Date());
|
|
|
+ item.setUpdateUser(AuthUtil.getUserId());
|
|
|
+ item.setUpdateUserName(AuthUtil.getUserName());
|
|
|
+ item.setContainerNumber(putBoxNew.getContainerNumber());
|
|
|
+ item.setPolCyId(putBoxNew.getPolId());
|
|
|
+ item.setPolCyCode(putBoxNew.getPolCode());
|
|
|
+ item.setPolCyCname(putBoxNew.getPolCname());
|
|
|
+ item.setPolCyEname(putBoxNew.getPolEname());
|
|
|
+ if (!archivesList.isEmpty()) {
|
|
|
+ Archives archives1 = archivesList.stream().filter(e -> e.getCode().equals(item.getBoxCode())).findFirst().orElse(null);
|
|
|
+ if (archives1 != null) {
|
|
|
+ archives1.setAddressId(putBoxNew.getPolId());
|
|
|
+ archives1.setAddressCname(putBoxNew.getPolCname());
|
|
|
+ archives1.setAddressEname(putBoxNew.getPolEname());
|
|
|
+ archives1.setAddressCode(putBoxNew.getPolCode());
|
|
|
+ archives1.setStationId(putBoxNew.getPolStationId());
|
|
|
+ archives1.setStationCname(putBoxNew.getPolStationCname());
|
|
|
+ archives1.setStationEname(putBoxNew.getPolStationEname());
|
|
|
+ archives1.setStationCode(putBoxNew.getPolStationCode());
|
|
|
+ archives1.setNewDate(new Date());
|
|
|
+ archives1.setContainerNumber(putBoxNew.getContainerNumber());
|
|
|
+ archives1.setContainerNumberType(putBoxNew.getBoxClass());
|
|
|
+ archives1.setContainerNumberOw(putBoxNew.getContainerNumber());
|
|
|
+ archives1.setContainerNumberTypeOw(putBoxNew.getBoxClass());
|
|
|
+ archives.add(archives1);
|
|
|
+ } else {
|
|
|
+ throw new RuntimeException("箱号:" + item.getBoxCode() + "不在箱档案中");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //记录箱轨迹信息
|
|
|
+ ArchivesTrajectory archivesTrajectory = new ArchivesTrajectory();
|
|
|
+ archivesTrajectory.setPortId(putBoxNew.getPolId());
|
|
|
+ archivesTrajectory.setPortCname(putBoxNew.getPolCname());
|
|
|
+ archivesTrajectory.setPortEname(putBoxNew.getPolEname());
|
|
|
+ archivesTrajectory.setPortCode(putBoxNew.getPolCode());
|
|
|
+ archivesTrajectory.setStationId(putBoxNew.getPolStationId());
|
|
|
+ archivesTrajectory.setStationCname(putBoxNew.getPolStationCname());
|
|
|
+ archivesTrajectory.setStationEname(putBoxNew.getPolStationEname());
|
|
|
+ archivesTrajectory.setStationCode(putBoxNew.getPolStationCode());
|
|
|
+ archivesTrajectory.setNewDate(new Date());
|
|
|
+ archivesTrajectory.setContainerNumber(item.getContainerNumber());
|
|
|
+ archivesTrajectory.setBoxType(item.getBoxType());
|
|
|
+ archivesTrajectory.setBoxStatus(item.getBoxStatus());
|
|
|
+ archivesTrajectory.setBoxCategory(item.getBoxClass());
|
|
|
+ archivesTrajectory.setBoxEastId(item.getBoxEastId());
|
|
|
+ archivesTrajectory.setBoxEastName(item.getBoxEastName());
|
|
|
+ archivesTrajectory.setMblno(item.getMblno());
|
|
|
+ archivesTrajectory.setHblno(item.getHblno());
|
|
|
+ archivesTrajectory.setBoxDynamics("OW-更改放箱号");
|
|
|
+ archivesTrajectory.setStatus("OW-更改放箱号");
|
|
|
+ archivesTrajectory.setCorpId(item.getBoxEastId());
|
|
|
+ archivesTrajectory.setCorpName(item.getBoxEastName());
|
|
|
+ archivesTrajectory.setBillType(putBoxNew.getBoxClass());
|
|
|
+ archivesTrajectory.setCode(item.getBoxCode());
|
|
|
+ archivesTrajectory.setNewDate(new Date());
|
|
|
+ archivesTrajectory.setCreateTime(new Date());
|
|
|
+ archivesTrajectory.setCreateUser(AuthUtil.getUserId());
|
|
|
+ archivesTrajectory.setCreateUserName(AuthUtil.getUserName());
|
|
|
+ archivesTrajectory.setTenantId(AuthUtil.getTenantId());
|
|
|
+ archivesTrajectory.setSrcId(putBoxNew.getId());
|
|
|
+ archivesTrajectory.setEtd(item.getEtd());
|
|
|
+ archivesTrajectory.setPolCyId(item.getPolCyId());
|
|
|
+ archivesTrajectory.setPolCyCode(item.getPolCyCode());
|
|
|
+ archivesTrajectory.setPolCyCname(item.getPolCyCname());
|
|
|
+ archivesTrajectory.setPolCyEname(item.getPolCyEname());
|
|
|
+ archivesTrajectory.setPolFreeBoxUseDays(item.getPolFreeBoxUseDays());
|
|
|
+ archivesTrajectory.setPolPreAppearanceDate(item.getPolPreAppearanceDate());
|
|
|
+ archivesTrajectory.setPolStationEmptyContainerExitDate(item.getPolStationEmptyContainerExitDate());
|
|
|
+ archivesTrajectory.setPolReturnDate(item.getPolReturnDate());
|
|
|
+ archivesTrajectory.setPolOverdueBoxUseDays(item.getPolOverdueBoxUseDays());
|
|
|
+ archivesTrajectory.setEta(item.getEta());
|
|
|
+ archivesTrajectory.setPodEmptyContainerReturnDate(item.getPodEmptyContainerReturnDate());
|
|
|
+ archivesTrajectory.setPodStationId(item.getPodStationId());
|
|
|
+ archivesTrajectory.setPodStationCode(item.getPodStationCode());
|
|
|
+ archivesTrajectory.setPodStationCname(item.getPodStationCname());
|
|
|
+ archivesTrajectory.setPodStationEname(item.getPodStationEname());
|
|
|
+ archivesTrajectory.setPodFreeBoxUseDays(item.getPodFreeBoxUseDays());
|
|
|
+ archivesTrajectory.setPodBoxUseDays(item.getPodBoxUseDays());
|
|
|
+ archivesTrajectory.setShipNameId(item.getShipNameId());
|
|
|
+ archivesTrajectory.setShipCname(item.getShipCname());
|
|
|
+ archivesTrajectory.setShipEname(item.getShipEname());
|
|
|
+ archivesTrajectory.setShipCode(item.getShipCode());
|
|
|
+ archivesTrajectory.setVoyage(item.getVoyage());
|
|
|
+ archivesTrajectoryList.add(archivesTrajectory);
|
|
|
+ }
|
|
|
+ if (!putBoxItemsList.isEmpty()) {
|
|
|
+ putBoxItemsService.updateBatchById(putBoxItemsList);
|
|
|
+ }
|
|
|
+ if (!archivesTrajectoryList.isEmpty()) {
|
|
|
+ archivesTrajectoryService.saveBatch(archivesTrajectoryList);
|
|
|
+ }
|
|
|
+ if (!archivesTrajectoryList.isEmpty()) {
|
|
|
+ archivesService.updateBatchById(archives);
|
|
|
+ }
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
}
|