|
|
@@ -27,7 +27,6 @@ import org.springblade.core.oss.model.BladeFile;
|
|
|
import org.springblade.core.secure.utils.AuthUtil;
|
|
|
import org.springblade.core.tool.api.R;
|
|
|
import org.springblade.core.tool.utils.BeanUtil;
|
|
|
-import org.springblade.core.tool.utils.Func;
|
|
|
import org.springblade.los.Util.CurrencyUtils;
|
|
|
import org.springblade.los.basic.business.entity.BusinessType;
|
|
|
import org.springblade.los.basic.business.service.IBusinessTypeService;
|
|
|
@@ -63,7 +62,9 @@ import org.springblade.los.business.sea.entity.Bills;
|
|
|
import org.springblade.los.business.sea.entity.Containers;
|
|
|
import org.springblade.los.business.sea.mapper.BillsMapper;
|
|
|
import org.springblade.los.business.sea.service.IContainersService;
|
|
|
+import org.springblade.los.excel.PodStationR;
|
|
|
import org.springblade.los.excel.RouteCostProfitExcel;
|
|
|
+import org.springblade.los.excel.UpdatePodStationExcel;
|
|
|
import org.springblade.los.finance.fee.entity.FeeCenter;
|
|
|
import org.springblade.los.finance.fee.service.IFeeCenterService;
|
|
|
import org.springblade.resource.feign.IOssClient;
|
|
|
@@ -1635,9 +1636,9 @@ public class PutBoxServiceImpl extends ServiceImpl<PutBoxMapper, PutBox> impleme
|
|
|
//对应海运进出口单据所属公司所有币别
|
|
|
List<BCurExrate> curExrateList = currencyUtils.obtainRate(new Date(), "1", bills.getBranchId());
|
|
|
Date polPickUpDate;
|
|
|
- if ("OW-N".equals(tradingBox.getType())){
|
|
|
+ if ("OW-N".equals(tradingBox.getType())) {
|
|
|
polPickUpDate = item.getPolPickUpDate();
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
polPickUpDate = item.getPolStationEmptyContainerExitDate();
|
|
|
}
|
|
|
//起运港超期天数
|
|
|
@@ -2899,72 +2900,562 @@ public class PutBoxServiceImpl extends ServiceImpl<PutBoxMapper, PutBox> impleme
|
|
|
|
|
|
@Override
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
- public R batchUpdatePodStation(String ids, Long podStationId, String podStationCode, String
|
|
|
- podStationCname, String podStationEname) {
|
|
|
- List<Containers> containersList = containersService.list(new LambdaQueryWrapper<Containers>()
|
|
|
+ public R batchUpdatePodStation(PodStationR podStationR) {
|
|
|
+ if (ObjectUtils.isNull(podStationR.getPodStationId()) || ObjectUtils.isNull(podStationR.getList()) ||
|
|
|
+ podStationR.getList().isEmpty()) {
|
|
|
+ throw new RuntimeException("缺少必要请求参数");
|
|
|
+ }
|
|
|
+ List<Long> containersIds = podStationR.getList().stream().map(UpdatePodStationExcel::getContainersId).collect(Collectors.toList());
|
|
|
+ List<Long> billsIds = podStationR.getList().stream().map(UpdatePodStationExcel::getId).distinct().collect(Collectors.toList());
|
|
|
+ List<Containers> containersHYJKList = containersService.list(new LambdaQueryWrapper<Containers>()
|
|
|
.eq(Containers::getTenantId, AuthUtil.getTenantId())
|
|
|
.eq(Containers::getIsDeleted, 0)
|
|
|
- .in(Containers::getId, Func.toLongList(ids)));
|
|
|
- if (containersList.isEmpty()) {
|
|
|
+ .in(Containers::getId, containersIds));
|
|
|
+ if (containersHYJKList.isEmpty()) {
|
|
|
throw new RuntimeException("未查到配箱信息");
|
|
|
}
|
|
|
- List<String> containerNumber = containersList.stream().map(Containers::getContainerNumber).filter(Objects::nonNull)
|
|
|
- .distinct().collect(Collectors.toList());
|
|
|
- List<String> boxCode = containersList.stream().map(Containers::getCntrNo).filter(Objects::nonNull)
|
|
|
- .distinct().collect(Collectors.toList());
|
|
|
- for (Containers item : containersList) {
|
|
|
- item.setPodStationId(podStationId);
|
|
|
- item.setPodStationCname(podStationCname);
|
|
|
- item.setPodStationEname(podStationEname);
|
|
|
- item.setPodStationCode(podStationCode);
|
|
|
- item.setUpdateTime(new Date());
|
|
|
- item.setUpdateUser(AuthUtil.getUserId());
|
|
|
- item.setUpdateUserName(AuthUtil.getUserName());
|
|
|
- }
|
|
|
- containersService.updateBatchById(containersList);
|
|
|
- List<PutBox> putBoxList = baseMapper.selectList(new LambdaQueryWrapper<PutBox>()
|
|
|
- .eq(PutBox::getTenantId, AuthUtil.getTenantId())
|
|
|
- .eq(PutBox::getIsDeleted, 0)
|
|
|
- .in(PutBox::getContainerNumber, containerNumber));
|
|
|
- if (!putBoxList.isEmpty()) {
|
|
|
+ if ("HYJK".equals(podStationR.getBusinessType())) {
|
|
|
+ List<String> boxNum = containersHYJKList.stream().map(Containers::getCntrNo).filter(Objects::nonNull)
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ if (boxNum.isEmpty()) {
|
|
|
+ throw new RuntimeException("所选配箱信息箱号不能为空");
|
|
|
+ }
|
|
|
+ //箱档案数据
|
|
|
+ List<Archives> archivesList = archivesService.list(new LambdaQueryWrapper<Archives>()
|
|
|
+ .eq(Archives::getTenantId, AuthUtil.getTenantId())
|
|
|
+ .eq(Archives::getIsDeleted, 0)
|
|
|
+ .in(Archives::getCode, boxNum)
|
|
|
+ .eq(Archives::getStatus, "使用中"));
|
|
|
+ if (archivesList.isEmpty()) {
|
|
|
+ throw new RuntimeException("未查到对应箱档案信息");
|
|
|
+ }
|
|
|
+ if (boxNum.size() > archivesList.size()) {
|
|
|
+ List<String> boxCode = archivesList.stream().map(Archives::getCode).collect(Collectors.toList());
|
|
|
+ throw new RuntimeException("箱号:" + boxNum.stream().filter(e -> !boxCode.contains(e))
|
|
|
+ .collect(Collectors.joining(",")) + "未查到对应箱档案信息");
|
|
|
+ }
|
|
|
+ List<String> containerNumberList = archivesList.stream().map(Archives::getContainerNumber)
|
|
|
+ .distinct().collect(Collectors.toList());
|
|
|
+ List<String> containerNumberOwList = archivesList.stream().map(Archives::getContainerNumberOw)
|
|
|
+ .distinct().collect(Collectors.toList());
|
|
|
+ if (!containerNumberOwList.isEmpty()) {
|
|
|
+ containerNumberList.addAll(containerNumberOwList);
|
|
|
+ }
|
|
|
+ List<PutBox> putBoxList = baseMapper.selectList(new LambdaQueryWrapper<PutBox>()
|
|
|
+ .eq(PutBox::getTenantId, AuthUtil.getTenantId())
|
|
|
+ .eq(PutBox::getIsDeleted, 0)
|
|
|
+ .and(i -> i.in(PutBox::getContainerNumber, containerNumberList).or()
|
|
|
+ .in(PutBox::getSrcContainerNumber, containerNumberList)));
|
|
|
+ if (putBoxList.isEmpty()) {
|
|
|
+ throw new RuntimeException("未查到放箱号单据");
|
|
|
+ }
|
|
|
+ List<Long> putBoxIdList = putBoxList.stream().map(PutBox::getId).collect(Collectors.toList());
|
|
|
List<PutBoxItems> putBoxItemsList = putBoxItemsService.list(new LambdaQueryWrapper<PutBoxItems>()
|
|
|
- .eq(PutBoxItems::getTenantId, AuthUtil.getTenantId())
|
|
|
.eq(PutBoxItems::getIsDeleted, 0)
|
|
|
- .in(PutBoxItems::getBoxCode, boxCode)
|
|
|
- .in(PutBoxItems::getPid, putBoxList.stream().map(PutBox::getId).collect(Collectors.toList()))
|
|
|
- );
|
|
|
- for (PutBoxItems item : putBoxItemsList) {
|
|
|
- item.setPodStationId(podStationId);
|
|
|
- item.setPodStationCname(podStationCname);
|
|
|
- item.setPodStationEname(podStationEname);
|
|
|
- item.setPodStationCode(podStationCode);
|
|
|
- item.setUpdateTime(new Date());
|
|
|
- item.setUpdateUser(AuthUtil.getUserId());
|
|
|
- item.setUpdateUserName(AuthUtil.getUserName());
|
|
|
+ .eq(PutBoxItems::getTenantId, AuthUtil.getTenantId())
|
|
|
+ .in(PutBoxItems::getPid, putBoxIdList));
|
|
|
+ List<Long> srcIdList = putBoxList.stream().map(PutBox::getSrcId).collect(Collectors.toList());
|
|
|
+ List<TradingBox> tradingBoxList = new ArrayList<>();
|
|
|
+ if (!srcIdList.isEmpty()) {
|
|
|
+ tradingBoxList = tradingBoxMapper.selectList(new LambdaQueryWrapper<TradingBox>()
|
|
|
+ .eq(TradingBox::getTenantId, AuthUtil.getTenantId())
|
|
|
+ .eq(TradingBox::getIsDeleted, 0)
|
|
|
+ .in(TradingBox::getId, srcIdList));
|
|
|
+ }
|
|
|
+ List<TradingBoxItem> tradingBoxItemList = new ArrayList<>();
|
|
|
+ if (!tradingBoxList.isEmpty()) {
|
|
|
+ List<Long> tradingBoxIdList = tradingBoxList.stream().map(TradingBox::getId).collect(Collectors.toList());
|
|
|
+ tradingBoxItemList = tradingBoxItemService.list(new LambdaQueryWrapper<TradingBoxItem>()
|
|
|
+ .eq(TradingBoxItem::getIsDeleted, 0)
|
|
|
+ .eq(TradingBoxItem::getTenantId, AuthUtil.getTenantId())
|
|
|
+ .in(TradingBoxItem::getPid, tradingBoxIdList));
|
|
|
}
|
|
|
- putBoxItemsService.updateBatchById(putBoxItemsList);
|
|
|
- }
|
|
|
- List<TradingBox> tradingBoxList = tradingBoxMapper.selectList(new LambdaQueryWrapper<TradingBox>()
|
|
|
- .eq(TradingBox::getTenantId, AuthUtil.getTenantId())
|
|
|
- .eq(TradingBox::getIsDeleted, 0)
|
|
|
- .in(TradingBox::getContainerNumber, containerNumber));
|
|
|
- if (!tradingBoxList.isEmpty()) {
|
|
|
- List<TradingBoxItem> tradingBoxItemList = tradingBoxItemService.list(new LambdaQueryWrapper<TradingBoxItem>()
|
|
|
- .eq(TradingBoxItem::getTenantId, AuthUtil.getTenantId())
|
|
|
- .eq(TradingBoxItem::getIsDeleted, 0)
|
|
|
- .in(TradingBoxItem::getCode, boxCode)
|
|
|
- .in(TradingBoxItem::getPid, tradingBoxList.stream().map(TradingBox::getId).collect(Collectors.toList()))
|
|
|
- );
|
|
|
- for (TradingBoxItem item : tradingBoxItemList) {
|
|
|
- item.setPodStationId(podStationId);
|
|
|
- item.setPodStationCname(podStationCname);
|
|
|
- item.setPodStationEname(podStationEname);
|
|
|
- item.setPodStationCode(podStationCode);
|
|
|
+ BusinessType businessType = bBusinessTypeService.getOne(new LambdaQueryWrapper<BusinessType>()
|
|
|
+ .select(BusinessType::getId)
|
|
|
+ .eq(BusinessType::getTenantId, AuthUtil.getTenantId())
|
|
|
+ .eq(BusinessType::getIsDeleted, 0)
|
|
|
+ .eq(BusinessType::getStatus, 0)
|
|
|
+ .eq(BusinessType::getCode, "FXH"));
|
|
|
+ if (businessType == null) {
|
|
|
+ throw new RuntimeException("未找到可用业务类型");
|
|
|
+ }
|
|
|
+ List<Bills> billsHYJKList = billsMapper.selectList(new LambdaQueryWrapper<Bills>()
|
|
|
+ .eq(Bills::getTenantId, AuthUtil.getTenantId())
|
|
|
+ .eq(Bills::getIsDeleted, 0)
|
|
|
+ .in(Bills::getId, billsIds));
|
|
|
+ if (billsHYJKList.isEmpty()) {
|
|
|
+ throw new RuntimeException("未查到海运进口单据");
|
|
|
+ }
|
|
|
+ List<Long> idHYJKList = new ArrayList<>();
|
|
|
+ List<Bills> billsHYJKListFD = billsMapper.selectList(new LambdaQueryWrapper<Bills>()
|
|
|
+ .eq(Bills::getTenantId, AuthUtil.getTenantId())
|
|
|
+ .eq(Bills::getIsDeleted, 0)
|
|
|
+ .in(Bills::getMasterId, billsIds));
|
|
|
+ if (!billsHYJKListFD.isEmpty()) {
|
|
|
+ idHYJKList.addAll(billsHYJKListFD.stream().map(Bills::getId).collect(Collectors.toList()));
|
|
|
+ }
|
|
|
+ List<Containers> containersHYJKListFD = containersService.list(new LambdaQueryWrapper<Containers>()
|
|
|
+ .eq(Containers::getTenantId, AuthUtil.getTenantId())
|
|
|
+ .eq(Containers::getIsDeleted, 0)
|
|
|
+ .in(Containers::getPid, idHYJKList)
|
|
|
+ .in(Containers::getCntrNo, boxNum));
|
|
|
+ List<Containers> containersListNew = new ArrayList<>();
|
|
|
+ for (Bills billsHYJK : billsHYJKList){
|
|
|
+ //目的港生成新放箱号单据
|
|
|
+ List<PutBox> putBoxNewList = new ArrayList<>();
|
|
|
+ //目的港生成新放箱号单据明细数据
|
|
|
+ List<PutBoxItems> putBoxItemsNewList = new ArrayList<>();
|
|
|
+ //原起运港放箱号单据明细数据
|
|
|
+ List<PutBoxItems> putBoxItemsOldList = new ArrayList<>();
|
|
|
+ //原起运港OW单据明细数据
|
|
|
+ List<TradingBoxItem> tradingBoxItemOldList = new ArrayList<>();
|
|
|
+ //自有箱-箱档案数据更新
|
|
|
+ List<Archives> archivesArrayList = new ArrayList<>();
|
|
|
+ //OW(拿)、代理箱-箱档案数据删除
|
|
|
+ List<Long> archivesDateleList = new ArrayList<>();
|
|
|
+ List<Containers> containersList = containersHYJKList.stream().filter(e-> e.getPid().equals(billsHYJK.getId()))
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ for (Containers item : containersList) {
|
|
|
+ item.setPodStationId(podStationR.getPodStationId());
|
|
|
+ item.setPodStationCname(podStationR.getPodStationCname());
|
|
|
+ item.setPodStationEname(podStationR.getPodStationEname());
|
|
|
+ item.setPodStationCode(podStationR.getPodStationCode());
|
|
|
+ item.setUpdateTime(new Date());
|
|
|
+ item.setUpdateUser(AuthUtil.getUserId());
|
|
|
+ item.setUpdateUserName(AuthUtil.getUserName());
|
|
|
+ containersListNew.add(item);
|
|
|
+ //进口分单配箱信息处理
|
|
|
+ if (!containersHYJKListFD.isEmpty()) {
|
|
|
+ Containers containers = containersHYJKListFD.stream().filter(e -> e.getCntrNo().equals(item.getCntrNo()))
|
|
|
+ .findFirst().orElse(null);
|
|
|
+ if (containers != null) {
|
|
|
+ containers.setPodStationId(podStationR.getPodStationId());
|
|
|
+ containers.setPodStationCname(podStationR.getPodStationCname());
|
|
|
+ containers.setPodStationEname(podStationR.getPodStationEname());
|
|
|
+ containers.setPodStationCode(podStationR.getPodStationCode());
|
|
|
+ containers.setUpdateTime(new Date());
|
|
|
+ containers.setUpdateUser(AuthUtil.getUserId());
|
|
|
+ containers.setUpdateUserName(AuthUtil.getUserName());
|
|
|
+ containersListNew.add(containers);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //箱档案信息处理
|
|
|
+ Archives archives = archivesList.stream().filter(e -> e.getCode().equals(item.getCntrNo())).findFirst().orElse(null);
|
|
|
+ if (archives == null) {
|
|
|
+ throw new RuntimeException("未查到箱号:" + item.getCntrNo() + "箱档案数据");
|
|
|
+ }
|
|
|
+ archives.setUpdateTime(new Date());
|
|
|
+ archives.setUpdateUser(AuthUtil.getUserId());
|
|
|
+ archives.setUpdateUserName(AuthUtil.getUserName());
|
|
|
+ archives.setStatus("待使用");
|
|
|
+ archives.setNewDate(podStationR.getReturnEmptyTime());
|
|
|
+ archives.setBoxDynamics("空箱进场");
|
|
|
+ archives.setAddressId(billsHYJK.getPodId());
|
|
|
+ archives.setAddressCode(billsHYJK.getPodCode());
|
|
|
+ archives.setAddressCname(billsHYJK.getPodCnName());
|
|
|
+ archives.setAddressEname(billsHYJK.getPodEnName());
|
|
|
+ archives.setStationId(podStationR.getPodStationId());
|
|
|
+ archives.setStationCode(podStationR.getPodStationCname());
|
|
|
+ archives.setStationCname(podStationR.getPodStationEname());
|
|
|
+ archives.setStationEname(podStationR.getPodStationCode());
|
|
|
+ archivesArrayList.add(archives);
|
|
|
+ //原放箱号数据处理
|
|
|
+ PutBox putBox1 = putBoxList.stream().filter(e -> e.getContainerNumber().equals(archives.getContainerNumberOw()))
|
|
|
+ .findFirst().orElse(null);
|
|
|
+ if (putBox1 != null) {
|
|
|
+ if ("OW(放),自有箱,代理箱".contains(putBox1.getBoxClass())) {
|
|
|
+ //放箱号明细数据处理
|
|
|
+ PutBoxItems putBoxItem;
|
|
|
+ if (!putBoxItemsList.isEmpty()) {
|
|
|
+ putBoxItem = putBoxItemsList.stream().filter(e -> e.getBoxCode().equals(item.getCntrNo()))
|
|
|
+ .findFirst().orElse(null);
|
|
|
+ if (putBoxItem != null) {
|
|
|
+ putBoxItem.setPid(putBox1.getId());
|
|
|
+ putBoxItem.setPodStationId(podStationR.getPodStationId());
|
|
|
+ putBoxItem.setPodStationCode(podStationR.getPodStationCname());
|
|
|
+ putBoxItem.setPodStationCname(podStationR.getPodStationEname());
|
|
|
+ putBoxItem.setPodStationEname(podStationR.getPodStationCode());
|
|
|
+ putBoxItem.setPodEmptyContainerReturnDate(podStationR.getReturnEmptyTime());
|
|
|
+ putBoxItem.setStatus("待使用");
|
|
|
+ putBoxItem.setBoxDynamics("空箱进场");
|
|
|
+ putBoxItemsOldList.add(putBoxItem);
|
|
|
+ } else {
|
|
|
+ throw new RuntimeException("未查到原放箱号:" + archives.getContainerNumber() + "中箱号为:" + item.getCntrNo() + "数据");
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ throw new RuntimeException("未查到原放箱号:" + archives.getContainerNumber() + "中箱号为:" + item.getCntrNo() + "数据");
|
|
|
+ }
|
|
|
+ if ("OW(放)".equals(putBox1.getBoxClass())) {
|
|
|
+ if (!tradingBoxList.isEmpty()) {
|
|
|
+ TradingBox tradingBox = tradingBoxList.stream().filter(e -> e.getId().equals(putBox1.getSrcId()))
|
|
|
+ .findFirst().orElse(null);
|
|
|
+ if (tradingBox != null) {
|
|
|
+ TradingBoxItem tradingBoxItem;
|
|
|
+ if (!tradingBoxItemList.isEmpty()) {
|
|
|
+ tradingBoxItem = tradingBoxItemList.stream().filter(e -> e.getCode().equals(item.getCntrNo()))
|
|
|
+ .findFirst().orElse(null);
|
|
|
+ if (tradingBoxItem != null) {
|
|
|
+ tradingBoxItem.setPid(tradingBox.getId());
|
|
|
+ tradingBoxItem.setPodStationId(podStationR.getPodStationId());
|
|
|
+ tradingBoxItem.setPodStationCode(podStationR.getPodStationCname());
|
|
|
+ tradingBoxItem.setPodStationCname(podStationR.getPodStationEname());
|
|
|
+ tradingBoxItem.setPodStationEname(podStationR.getPodStationCode());
|
|
|
+ tradingBoxItem.setPodEmptyContainerReturnDate(podStationR.getReturnEmptyTime());
|
|
|
+ tradingBoxItem.setBoxDynamics("空箱进场");
|
|
|
+ tradingBoxItem.setStatus("待使用");
|
|
|
+ tradingBoxItem.setPortId(billsHYJK.getPodId());
|
|
|
+ tradingBoxItem.setPortCode(billsHYJK.getPodCode());
|
|
|
+ tradingBoxItem.setPortCname(billsHYJK.getPodCnName());
|
|
|
+ tradingBoxItem.setPortEname(billsHYJK.getPodEnName());
|
|
|
+ tradingBoxItem.setStationId(podStationR.getPodStationId());
|
|
|
+ tradingBoxItem.setStationCode(podStationR.getPodStationCname());
|
|
|
+ tradingBoxItem.setStationCname(podStationR.getPodStationEname());
|
|
|
+ tradingBoxItem.setStationEname(podStationR.getPodStationCode());
|
|
|
+ tradingBoxItemOldList.add(tradingBoxItem);
|
|
|
+ } else {
|
|
|
+ throw new RuntimeException("未查到原OW单据-放箱号:" + archives.getContainerNumber() + "中箱号是:" + item.getCntrNo() + "数据");
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ throw new RuntimeException("未查到原OW单据-放箱号:" + archives.getContainerNumber() + "中箱号是:" + item.getCntrNo() + "数据");
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ throw new RuntimeException("未查到原OW单据-放箱号为:" + archives.getContainerNumber());
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ throw new RuntimeException("未查到原OW单据-放箱号为:" + archives.getContainerNumberOw());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //pod放箱号处理
|
|
|
+ PutBox putBox = putBoxList.stream().filter(e -> e.getContainerNumber().equals(archives.getContainerNumber())
|
|
|
+ && e.getPolId().equals(archives.getAddressId()) && e.getPolStationId().equals(archives.getStationId())
|
|
|
+ && e.getBusType().equals(archives.getContainerNumberType())).findFirst().orElse(null);
|
|
|
+ if (putBox == null) {
|
|
|
+ if (!putBoxNewList.isEmpty()) {
|
|
|
+ PutBox putBox2 = putBoxNewList.stream().filter(e -> e.getContainerNumber().equals(archives.getContainerNumber())
|
|
|
+ && e.getPolId().equals(archives.getAddressId()) && e.getPolStationId().equals(archives.getStationId())).findFirst().orElse(null);
|
|
|
+ if (putBox2 == null) {
|
|
|
+ putBox2 = new PutBox();
|
|
|
+ putBox2.setCreateUser(AuthUtil.getUserId());
|
|
|
+ putBox2.setCreateTime(new Date());
|
|
|
+ putBox2.setCreateUserName(AuthUtil.getUserName());
|
|
|
+ putBox2.setBusType("自有箱");
|
|
|
+ putBox2.setBoxBelongsTo("SOC");
|
|
|
+ putBox2.setBoxEastId(archives.getBoxEastId() + "");
|
|
|
+ putBox2.setBoxEastName(archives.getBoxEastName());
|
|
|
+ String code = "FXH-ZY";
|
|
|
+ BusinessBillNo businessBillNo = new BusinessBillNo();
|
|
|
+ businessBillNo.setBusinessTypeId(businessType.getId());
|
|
|
+ businessBillNo.setCode(code);
|
|
|
+ R clientBillNo = businessBillNoService.getBillNoLos(businessBillNo);
|
|
|
+ if (!clientBillNo.isSuccess()) {
|
|
|
+ throw new RuntimeException("生成订单编号失败");
|
|
|
+ }
|
|
|
+ putBox2.setSysNo((String) clientBillNo.getData());
|
|
|
+ putBox2.setContainerNumber(archives.getContainerNumber());
|
|
|
+ putBox2.setSrcContainerNumber(archives.getContainerNumberOw());
|
|
|
+ putBox2.setSrcType(archives.getContainerNumberTypeOw());
|
|
|
+ BusinessBillNo businessBillNo1 = new BusinessBillNo();
|
|
|
+ businessBillNo1.setBusinessTypeId(businessType.getId());
|
|
|
+ businessBillNo1.setCode("FXH-N");
|
|
|
+ R clientBillNo1 = businessBillNoService.getBillNoLos(businessBillNo1);
|
|
|
+ if (!clientBillNo1.isSuccess()) {
|
|
|
+ throw new RuntimeException("生成订单编号失败");
|
|
|
+ }
|
|
|
+ putBox2.setInternalContainerNumber((String) clientBillNo1.getData());
|
|
|
+ putBox2.setPolId(billsHYJK.getPodId());
|
|
|
+ putBox2.setPolCode(billsHYJK.getPodCode());
|
|
|
+ putBox2.setPolCname(billsHYJK.getPodCnName());
|
|
|
+ putBox2.setPolEname(billsHYJK.getPodEnName());
|
|
|
+ putBox2.setPolStationId(podStationR.getPodStationId());
|
|
|
+ putBox2.setPolStationCode(podStationR.getPodStationCname());
|
|
|
+ putBox2.setPolStationCname(podStationR.getPodStationEname());
|
|
|
+ putBox2.setPolStationEname(podStationR.getPodStationCode());
|
|
|
+ putBox2.setBoxType(archives.getTypeName());
|
|
|
+ putBox2.setBoxClass("自有箱");
|
|
|
+ putBox2.setTotalNum(1);
|
|
|
+ putBox2.setOccupyNum(0);
|
|
|
+ putBox2.setRemainingNum(1);
|
|
|
+ putBox2.setStorageNum(1);
|
|
|
+ putBoxNewList.add(putBox2);
|
|
|
+ } else {
|
|
|
+ putBox2.setTotalNum(putBox1.getTotalNum() + 1);
|
|
|
+ putBox2.setOccupyNum(0);
|
|
|
+ putBox2.setRemainingNum(putBox1.getRemainingNum() + 1);
|
|
|
+ putBox2.setStorageNum(putBox1.getStorageNum() + 1);
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ putBox = new PutBox();
|
|
|
+ putBox.setCreateUser(AuthUtil.getUserId());
|
|
|
+ putBox.setCreateTime(new Date());
|
|
|
+ putBox.setCreateUserName(AuthUtil.getUserName());
|
|
|
+ putBox.setBusType("自有箱");
|
|
|
+ putBox.setBoxClass("自有箱");
|
|
|
+ String code = "FXH-ZY";
|
|
|
+ BusinessBillNo businessBillNo = new BusinessBillNo();
|
|
|
+ businessBillNo.setBusinessTypeId(businessType.getId());
|
|
|
+ businessBillNo.setCode(code);
|
|
|
+ R clientBillNo = businessBillNoService.getBillNoLos(businessBillNo);
|
|
|
+ if (!clientBillNo.isSuccess()) {
|
|
|
+ throw new RuntimeException("生成订单编号失败");
|
|
|
+ }
|
|
|
+ putBox.setSysNo((String) clientBillNo.getData());
|
|
|
+ putBox.setContainerNumber(archives.getContainerNumber());
|
|
|
+ putBox.setBoxBelongsTo("SOC");
|
|
|
+ putBox.setBoxEastId(archives.getBoxEastId() + "");
|
|
|
+ putBox.setBoxEastName(archives.getBoxEastName());
|
|
|
+ putBox.setSrcContainerNumber(archives.getContainerNumberOw());
|
|
|
+ putBox.setSrcType(archives.getContainerNumberTypeOw());
|
|
|
+ BusinessBillNo businessBillNo1 = new BusinessBillNo();
|
|
|
+ businessBillNo1.setBusinessTypeId(businessType.getId());
|
|
|
+ businessBillNo1.setCode("FXH-N");
|
|
|
+ R clientBillNo1 = businessBillNoService.getBillNoLos(businessBillNo1);
|
|
|
+ if (!clientBillNo1.isSuccess()) {
|
|
|
+ throw new RuntimeException("生成订单编号失败");
|
|
|
+ }
|
|
|
+ putBox.setInternalContainerNumber((String) clientBillNo1.getData());
|
|
|
+ putBox.setPolId(billsHYJK.getPodId());
|
|
|
+ putBox.setPolCode(billsHYJK.getPodCode());
|
|
|
+ putBox.setPolCname(billsHYJK.getPodCnName());
|
|
|
+ putBox.setPolEname(billsHYJK.getPodEnName());
|
|
|
+ putBox.setPolStationId(podStationR.getPodStationId());
|
|
|
+ putBox.setPolStationCode(podStationR.getPodStationCname());
|
|
|
+ putBox.setPolStationCname(podStationR.getPodStationEname());
|
|
|
+ putBox.setPolStationEname(podStationR.getPodStationCode());
|
|
|
+ putBox.setBoxType(archives.getTypeName());
|
|
|
+ putBox.setBoxClass("自有箱");
|
|
|
+ putBox.setTotalNum(1);
|
|
|
+ putBox.setOccupyNum(0);
|
|
|
+ putBox.setRemainingNum(1);
|
|
|
+ putBox.setStorageNum(1);
|
|
|
+ putBoxNewList.add(putBox);
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ putBox.setTotalNum(putBox.getTotalNum() + 1);
|
|
|
+ putBox.setRemainingNum(putBox.getTotalNum() + 1 - putBox.getOccupyNum());
|
|
|
+ putBox.setStorageNum(putBox.getStorageNum() + 1 - putBox.getOccupyNum());
|
|
|
+ putBoxNewList.add(putBox);
|
|
|
+ }
|
|
|
+ } else if ("OW(拿)".equals(putBox1.getBoxClass())) {
|
|
|
+ //放箱号明细数据处理
|
|
|
+ PutBoxItems putBoxItem;
|
|
|
+ if (!putBoxItemsList.isEmpty()) {
|
|
|
+ putBoxItem = putBoxItemsList.stream().filter(e -> e.getBoxCode().equals(item.getCntrNo()))
|
|
|
+ .findFirst().orElse(null);
|
|
|
+ if (putBoxItem != null) {
|
|
|
+ putBoxItem.setPid(putBox1.getId());
|
|
|
+ putBoxItem.setPodStationId(podStationR.getPodStationId());
|
|
|
+ putBoxItem.setPodStationCode(podStationR.getPodStationCname());
|
|
|
+ putBoxItem.setPodStationCname(podStationR.getPodStationEname());
|
|
|
+ putBoxItem.setPodStationEname(podStationR.getPodStationCode());
|
|
|
+ putBoxItem.setPodEmptyContainerReturnDate(podStationR.getReturnEmptyTime());
|
|
|
+ putBoxItem.setStatus("待使用");
|
|
|
+ putBoxItem.setBoxDynamics("空箱进场");
|
|
|
+ putBoxItemsOldList.add(putBoxItem);
|
|
|
+ } else {
|
|
|
+ throw new RuntimeException("未查到原放箱号:" + archives.getContainerNumber() + "中箱号为:" + item.getCntrNo() + "数据");
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ throw new RuntimeException("未查到原放箱号:" + archives.getContainerNumber() + "中箱号为:" + item.getCntrNo() + "数据");
|
|
|
+ }
|
|
|
+ if (!tradingBoxList.isEmpty()) {
|
|
|
+ TradingBox tradingBox = tradingBoxList.stream().filter(e -> e.getId().equals(putBox1.getSrcId()))
|
|
|
+ .findFirst().orElse(null);
|
|
|
+ if (tradingBox != null) {
|
|
|
+ TradingBoxItem tradingBoxItem;
|
|
|
+ if (!tradingBoxItemList.isEmpty()) {
|
|
|
+ tradingBoxItem = tradingBoxItemList.stream().filter(e -> e.getCode().equals(item.getCntrNo()))
|
|
|
+ .findFirst().orElse(null);
|
|
|
+ if (tradingBoxItem != null) {
|
|
|
+ tradingBoxItem.setPid(tradingBox.getId());
|
|
|
+ tradingBoxItem.setPodStationId(podStationR.getPodStationId());
|
|
|
+ tradingBoxItem.setPodStationCode(podStationR.getPodStationCname());
|
|
|
+ tradingBoxItem.setPodStationCname(podStationR.getPodStationEname());
|
|
|
+ tradingBoxItem.setPodStationEname(podStationR.getPodStationCode());
|
|
|
+ tradingBoxItem.setPodEmptyContainerReturnDate(podStationR.getReturnEmptyTime());
|
|
|
+ tradingBoxItem.setBoxDynamics("空箱进场");
|
|
|
+ tradingBoxItem.setStatus("待使用");
|
|
|
+ tradingBoxItem.setPortId(billsHYJK.getPodId());
|
|
|
+ tradingBoxItem.setPortCode(billsHYJK.getPodCode());
|
|
|
+ tradingBoxItem.setPortCname(billsHYJK.getPodCnName());
|
|
|
+ tradingBoxItem.setPortEname(billsHYJK.getPodEnName());
|
|
|
+ tradingBoxItem.setStationId(podStationR.getPodStationId());
|
|
|
+ tradingBoxItem.setStationCode(podStationR.getPodStationCname());
|
|
|
+ tradingBoxItem.setStationCname(podStationR.getPodStationEname());
|
|
|
+ tradingBoxItem.setStationEname(podStationR.getPodStationCode());
|
|
|
+ tradingBoxItemOldList.add(tradingBoxItem);
|
|
|
+ } else {
|
|
|
+ throw new RuntimeException("未查到原OW单据-放箱号:" + archives.getContainerNumber() + "中箱号是:" + item.getCntrNo() + "数据");
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ throw new RuntimeException("未查到原OW单据-放箱号:" + archives.getContainerNumber() + "中箱号是:" + item.getCntrNo() + "数据");
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ throw new RuntimeException("未查到原OW单据-放箱号为:" + archives.getContainerNumber());
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ throw new RuntimeException("未查到原OW单据-放箱号为:" + archives.getContainerNumberOw());
|
|
|
+ }
|
|
|
+ archivesDateleList.add(archives.getId());
|
|
|
+ } else {
|
|
|
+ throw new RuntimeException("放箱号:" + archives.getContainerNumberOw() + "单据类型错误,请联系管理员");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (!containersListNew.isEmpty()) {
|
|
|
+ containersService.updateBatchById(containersListNew);
|
|
|
+ }
|
|
|
+ if (!putBoxItemsOldList.isEmpty()) {
|
|
|
+ putBoxItemsService.updateBatchById(putBoxItemsOldList);
|
|
|
+ }
|
|
|
+ if (!tradingBoxItemOldList.isEmpty()) {
|
|
|
+ tradingBoxItemService.updateBatchById(tradingBoxItemOldList);
|
|
|
+ }
|
|
|
+ if (!archivesArrayList.isEmpty()) {
|
|
|
+ archivesService.updateBatchById(archivesArrayList);
|
|
|
+ }
|
|
|
+ if (!archivesDateleList.isEmpty()) {
|
|
|
+ archivesService.removeByIds(archivesDateleList);
|
|
|
+ }
|
|
|
+ if (!putBoxNewList.isEmpty()) {
|
|
|
+ this.saveOrUpdateBatch(putBoxNewList);
|
|
|
+ }
|
|
|
+ for (Containers item : containersList) {
|
|
|
+ //箱档案信息处理
|
|
|
+ Archives archives = archivesList.stream().filter(e -> e.getCode().equals(item.getCntrNo())).findFirst().orElse(null);
|
|
|
+ if (archives == null) {
|
|
|
+ throw new RuntimeException("未查到箱号:" + item.getCntrNo() + "箱档案数据");
|
|
|
+ }
|
|
|
+ //放箱号数据处理
|
|
|
+ PutBox putBox1 = putBoxList.stream().filter(e -> e.getContainerNumber().equals(archives.getContainerNumberOw()))
|
|
|
+ .findFirst().orElse(null);
|
|
|
+ if (putBox1 != null) {
|
|
|
+ if ("OW(放),自有箱,代理箱".contains(putBox1.getBoxClass())) {
|
|
|
+ //POD放箱号数据明细处理
|
|
|
+ PutBox putBox = putBoxNewList.stream().filter(e -> e.getContainerNumber().equals(archives.getContainerNumber())
|
|
|
+ && e.getPolId().equals(archives.getAddressId()) && e.getPolStationId().equals(archives.getStationId()))
|
|
|
+ .findFirst().orElse(null);
|
|
|
+ if (putBox != null) {
|
|
|
+ //POD放箱号明细数据处理
|
|
|
+ PutBoxItems putBoxItem;
|
|
|
+ if (!putBoxItemsList.isEmpty()) {
|
|
|
+ putBoxItem = putBoxItemsList.stream().filter(e -> e.getBoxCode().equals(item.getCntrNo()) &&
|
|
|
+ putBox.getId().equals(e.getPid()))
|
|
|
+ .findFirst().orElse(null);
|
|
|
+ if (putBoxItem != null) {
|
|
|
+ putBoxItem.setMblno(item.getMblno());
|
|
|
+ putBoxItem.setBoxDynamics("空箱进场");
|
|
|
+ putBoxItem.setStatus("待使用");
|
|
|
+ putBoxItem.setPolCyId(billsHYJK.getPodId());
|
|
|
+ putBoxItem.setPolCyCode(billsHYJK.getPodCode());
|
|
|
+ putBoxItem.setPolCyCname(billsHYJK.getPodCnName());
|
|
|
+ putBoxItem.setPolCyEname(billsHYJK.getPodEnName());
|
|
|
+ putBoxItem.setEtd(null);
|
|
|
+ putBoxItem.setPolFreeBoxUseDays(0);
|
|
|
+ putBoxItem.setPolPreAppearanceDate(null);
|
|
|
+ putBoxItem.setPolStationEmptyContainerExitDate(null);
|
|
|
+ putBoxItem.setPolReturnDate(null);
|
|
|
+ putBoxItem.setPolOverdueBoxUseDays(0);
|
|
|
+ putBoxItem.setPolPickUpDate(null);
|
|
|
+ putBoxItem.setEta(null);
|
|
|
+ putBoxItem.setPodEmptyContainerReturnDate(null);
|
|
|
+ putBoxItem.setPodStationId(null);
|
|
|
+ putBoxItem.setPodStationCode(null);
|
|
|
+ putBoxItem.setPodStationCname(null);
|
|
|
+ putBoxItem.setPodStationEname(null);
|
|
|
+ putBoxItem.setPodFreeBoxUseDays(null);
|
|
|
+ putBoxItem.setPodBoxUseDays(null);
|
|
|
+ } else {
|
|
|
+ putBoxItem = new PutBoxItems();
|
|
|
+ putBoxItem.setBoxClass(putBox.getBusType());
|
|
|
+ putBoxItem.setBoxBelongsTo("SOC");
|
|
|
+ putBoxItem.setBoxCondition("新");
|
|
|
+ putBoxItem.setBoxStatus("好");
|
|
|
+ putBoxItem.setPid(putBox.getId());
|
|
|
+ putBoxItem.setContainerNumber(archives.getContainerNumber());
|
|
|
+ putBoxItem.setBoxCode(item.getCntrNo());
|
|
|
+ putBoxItem.setBoxType(item.getCntrTypeCode());
|
|
|
+ putBoxItem.setMblno(item.getMblno());
|
|
|
+ putBoxItem.setBoxDynamics("空箱进场");
|
|
|
+ putBoxItem.setStatus("待使用");
|
|
|
+ putBoxItem.setPolCyId(billsHYJK.getPodId());
|
|
|
+ putBoxItem.setPolCyCode(billsHYJK.getPodCode());
|
|
|
+ putBoxItem.setPolCyCname(billsHYJK.getPodCnName());
|
|
|
+ putBoxItem.setPolCyEname(billsHYJK.getPodEnName());
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ putBoxItem = new PutBoxItems();
|
|
|
+ putBoxItem.setBoxClass(putBox.getBusType());
|
|
|
+ putBoxItem.setBoxBelongsTo("SOC");
|
|
|
+ putBoxItem.setBoxCondition("新");
|
|
|
+ putBoxItem.setBoxStatus("好");
|
|
|
+ putBoxItem.setPid(putBox.getId());
|
|
|
+ putBoxItem.setContainerNumber(archives.getContainerNumber());
|
|
|
+ putBoxItem.setBoxCode(item.getCntrNo());
|
|
|
+ putBoxItem.setBoxType(item.getCntrTypeCode());
|
|
|
+ putBoxItem.setMblno(item.getMblno());
|
|
|
+ putBoxItem.setBoxDynamics("空箱进场");
|
|
|
+ putBoxItem.setStatus("待使用");
|
|
|
+ putBoxItem.setPolCyId(billsHYJK.getPodId());
|
|
|
+ putBoxItem.setPolCyCode(billsHYJK.getPodCode());
|
|
|
+ putBoxItem.setPolCyCname(billsHYJK.getPodCnName());
|
|
|
+ putBoxItem.setPolCyEname(billsHYJK.getPodEnName());
|
|
|
+ }
|
|
|
+ putBoxItemsNewList.add(putBoxItem);
|
|
|
+ } else {
|
|
|
+ throw new RuntimeException("未查到pod放箱号单据信息");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (!putBoxItemsNewList.isEmpty()) {
|
|
|
+ putBoxItemsService.saveOrUpdateBatch(putBoxItemsNewList);
|
|
|
+ for (PutBoxItems item : putBoxItemsNewList) {
|
|
|
+ PutBox putBox = putBoxNewList.stream().filter(e -> e.getId().equals(item.getPid())).findFirst().orElse(null);
|
|
|
+ if (putBox != null) {
|
|
|
+ //记录箱轨迹信息
|
|
|
+ ArchivesTrajectory archivesTrajectory = new ArchivesTrajectory();
|
|
|
+ archivesTrajectory.setPortId(putBox.getPolId());
|
|
|
+ archivesTrajectory.setPortCode(putBox.getPolCode());
|
|
|
+ archivesTrajectory.setPortCname(putBox.getPolCname());
|
|
|
+ archivesTrajectory.setPortEname(putBox.getPolEname());
|
|
|
+ archivesTrajectory.setStationId(putBox.getPolStationId());
|
|
|
+ archivesTrajectory.setStationCode(putBox.getPolStationCode());
|
|
|
+ archivesTrajectory.setStationCname(putBox.getPolStationCname());
|
|
|
+ archivesTrajectory.setStationEname(putBox.getPolStationEname());
|
|
|
+ archivesTrajectory.setContainerNumber(item.getContainerNumber());
|
|
|
+ archivesTrajectory.setBoxType(item.getBoxType());
|
|
|
+ archivesTrajectory.setBoxCategory(item.getBoxClass());
|
|
|
+ archivesTrajectory.setBoxEastId(item.getBoxEastId());
|
|
|
+ archivesTrajectory.setBoxEastName(item.getBoxEastName());
|
|
|
+ archivesTrajectory.setMblno(item.getMblno());
|
|
|
+ archivesTrajectory.setBoxDynamics("空箱进场");
|
|
|
+ archivesTrajectory.setStatus(item.getBoxDynamics());
|
|
|
+ archivesTrajectory.setBillType(putBox.getBusType());
|
|
|
+ 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(putBox.getId());
|
|
|
+ archivesTrajectoryMapper.insert(archivesTrajectory);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //计算超期箱使费
|
|
|
+ this.countOverdueFeeV1(billsHYJK, tradingBoxList, tradingBoxItemOldList);
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ for (Containers item : containersHYJKList) {
|
|
|
+ item.setPodStationId(podStationR.getPodStationId());
|
|
|
+ item.setPodStationCname(podStationR.getPodStationCname());
|
|
|
+ item.setPodStationEname(podStationR.getPodStationEname());
|
|
|
+ item.setPodStationCode(podStationR.getPodStationCode());
|
|
|
item.setUpdateTime(new Date());
|
|
|
item.setUpdateUser(AuthUtil.getUserId());
|
|
|
item.setUpdateUserName(AuthUtil.getUserName());
|
|
|
}
|
|
|
- tradingBoxItemService.updateBatchById(tradingBoxItemList);
|
|
|
+ containersService.updateBatchById(containersHYJKList);
|
|
|
}
|
|
|
return R.data("操作成功");
|
|
|
}
|