|
|
@@ -74,6 +74,7 @@ import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
|
import java.io.IOException;
|
|
|
import java.math.BigDecimal;
|
|
|
+import java.math.RoundingMode;
|
|
|
import java.rmi.RemoteException;
|
|
|
import java.time.LocalDateTime;
|
|
|
import java.time.ZoneId;
|
|
|
@@ -1204,6 +1205,7 @@ public class PutBoxServiceImpl extends ServiceImpl<PutBoxMapper, PutBox> impleme
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+ this.countOverdueFee(tradingBoxList, tradingBoxItems);
|
|
|
return R.data("操作成功");
|
|
|
}
|
|
|
|
|
|
@@ -1613,6 +1615,10 @@ public class PutBoxServiceImpl extends ServiceImpl<PutBoxMapper, PutBox> impleme
|
|
|
if (fees == null) {
|
|
|
throw new RuntimeException("请先维护费用基础信息");
|
|
|
}
|
|
|
+ String overdueProportion = sysClient.getParamService("overdue.proportion");
|
|
|
+ if (ObjectUtils.isNull(overdueProportion) || "获取数据失败".equals(overdueProportion)) {
|
|
|
+ throw new RuntimeException("超期箱使费比例");
|
|
|
+ }
|
|
|
for (TradingBoxItem item : tradingBoxItemOldList) {
|
|
|
//查找OW明细对应主表
|
|
|
TradingBox tradingBox = tradingBoxList.stream().filter(e -> e.getId().equals(item.getPid())).findFirst().orElse(null);
|
|
|
@@ -1628,8 +1634,14 @@ public class PutBoxServiceImpl extends ServiceImpl<PutBoxMapper, PutBox> impleme
|
|
|
String exrateType = currencyUtils.standardCurrency(bills.getBranchId());
|
|
|
//对应海运进出口单据所属公司所有币别
|
|
|
List<BCurExrate> curExrateList = currencyUtils.obtainRate(new Date(), "1", bills.getBranchId());
|
|
|
+ Date polPickUpDate;
|
|
|
+ if ("OW-N".equals(tradingBox.getType())){
|
|
|
+ polPickUpDate = item.getPolPickUpDate();
|
|
|
+ }else{
|
|
|
+ polPickUpDate = item.getPolStationEmptyContainerExitDate();
|
|
|
+ }
|
|
|
//起运港超期天数
|
|
|
- if (ObjectUtils.isNotNull(item.getPolPickUpDate()) && ObjectUtils.isNotNull(bills.getEtd())) {
|
|
|
+ if (ObjectUtils.isNotNull(polPickUpDate) && ObjectUtils.isNotNull(bills.getEtd())) {
|
|
|
//所属公司具体超期标准
|
|
|
StorageFees storageFees = this.getStorageFees(storageFeesList, bills, "1");
|
|
|
if (storageFees == null) {
|
|
|
@@ -1642,7 +1654,7 @@ public class PutBoxServiceImpl extends ServiceImpl<PutBoxMapper, PutBox> impleme
|
|
|
throw new RuntimeException("请先维护基础资料-超期标准");
|
|
|
}
|
|
|
LocalDateTime ldt1 = bills.getEtd().toInstant().atZone(ZoneId.systemDefault()).toLocalDateTime();
|
|
|
- LocalDateTime ldt2 = item.getPolPickUpDate().toInstant().atZone(ZoneId.systemDefault()).toLocalDateTime();
|
|
|
+ LocalDateTime ldt2 = polPickUpDate.toInstant().atZone(ZoneId.systemDefault()).toLocalDateTime();
|
|
|
long days = ChronoUnit.DAYS.between(ldt2, ldt1);
|
|
|
//超期天数
|
|
|
int overdueDays = 0;
|
|
|
@@ -1654,36 +1666,13 @@ public class PutBoxServiceImpl extends ServiceImpl<PutBoxMapper, PutBox> impleme
|
|
|
FeeCenter feeCenter = this.addFeeCenter(tradingBox, item, bills, fees, storageFeesItems, curExrateList, overdueDays, exrateType);
|
|
|
if (feeCenter != null) {
|
|
|
feeCenterList.add(feeCenter);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- //目的港超期天数
|
|
|
- if (ObjectUtils.isNotNull(item.getPodEmptyContainerReturnDate()) &&
|
|
|
- ObjectUtils.isNotNull(bills.getEta())) {
|
|
|
- //所属公司具体超期标准
|
|
|
- StorageFees storageFees = this.getStorageFees(storageFeesList, bills, "2");
|
|
|
- if (storageFees == null) {
|
|
|
- throw new RuntimeException("请先维护基础资料-超期标准");
|
|
|
- }
|
|
|
- //所属公司具体超期标准明细
|
|
|
- List<StorageFeesItems> storageFeesItems = storageFeesItemsList.stream().filter(e -> e.getPid().equals(storageFees.getId()))
|
|
|
- .collect(Collectors.toList());
|
|
|
- if (storageFeesItems.isEmpty()) {
|
|
|
- throw new RuntimeException("请先维护基础资料-超期标准");
|
|
|
- }
|
|
|
- LocalDateTime ldt1 = item.getPodEmptyContainerReturnDate().toInstant().atZone(ZoneId.systemDefault()).toLocalDateTime();
|
|
|
- LocalDateTime ldt2 = bills.getEta().toInstant().atZone(ZoneId.systemDefault()).toLocalDateTime();
|
|
|
- long days = ChronoUnit.DAYS.between(ldt2, ldt1);
|
|
|
- //超期天数
|
|
|
- int overdueDays = 0;
|
|
|
- if (ObjectUtils.isNull(bills.getPodFreeBoxUseDays()) || 0 == bills.getPodFreeBoxUseDays() ||
|
|
|
- days > bills.getPodFreeBoxUseDays()) {
|
|
|
- overdueDays = (int) (days - bills.getPodFreeBoxUseDays());
|
|
|
- }
|
|
|
- if (overdueDays != 0) {
|
|
|
- FeeCenter feeCenter = this.addFeeCenter(tradingBox, item, bills, fees, storageFeesItems, curExrateList, overdueDays, exrateType);
|
|
|
- if (feeCenter != null) {
|
|
|
- feeCenterList.add(feeCenter);
|
|
|
+ FeeCenter feeCenterC = new FeeCenter();
|
|
|
+ BeanUtil.copyProperties(feeCenter, feeCenterC);
|
|
|
+ feeCenterC.setDc("C");
|
|
|
+ feeCenterC.setPrice(feeCenterC.getPrice().multiply(new BigDecimal(overdueProportion)).setScale(2, RoundingMode.HALF_UP));
|
|
|
+ feeCenterC.setAmount(feeCenterC.getQuantity().multiply(feeCenterC.getPrice()));
|
|
|
+ feeCenterC.setAmountLoc(feeCenterC.getAmount().multiply(feeCenter.getExrate()));
|
|
|
+ feeCenterList.add(feeCenterC);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
@@ -3986,27 +3975,93 @@ public class PutBoxServiceImpl extends ServiceImpl<PutBoxMapper, PutBox> impleme
|
|
|
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::getIsDeleted, 0)
|
|
|
+ .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));
|
|
|
+ }
|
|
|
+ //目的港生成新放箱号单据
|
|
|
+ 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<>();
|
|
|
+ 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("未找到可用业务类型");
|
|
|
+ }
|
|
|
Bills billsHYJK = billsMapper.selectById(bills.getId());
|
|
|
if (billsHYJK == null) {
|
|
|
throw new RuntimeException("未查到海运进口单据");
|
|
|
}
|
|
|
- List<Long> idHYCKList = new ArrayList<>();
|
|
|
- Bills billsHYCK = billsMapper.selectById(billsHYJK.getSrcBusId());
|
|
|
- if (billsHYCK == null) {
|
|
|
- throw new RuntimeException("未查到来源海运出口单据");
|
|
|
- }
|
|
|
- idHYCKList.add(billsHYCK.getId());
|
|
|
- List<Bills> billsHYCKListFD = billsMapper.selectList(new LambdaQueryWrapper<Bills>()
|
|
|
+ List<Long> idHYJKList = new ArrayList<>();
|
|
|
+ List<Bills> billsHYJKListFD = billsMapper.selectList(new LambdaQueryWrapper<Bills>()
|
|
|
.eq(Bills::getTenantId, AuthUtil.getTenantId())
|
|
|
.eq(Bills::getIsDeleted, 0)
|
|
|
- .eq(Bills::getMasterId, billsHYCK.getId()));
|
|
|
- if (!billsHYCKListFD.isEmpty()) {
|
|
|
- idHYCKList.addAll(billsHYCKListFD.stream().map(Bills::getId).collect(Collectors.toList()));
|
|
|
+ .eq(Bills::getMasterId, bills.getId()));
|
|
|
+ if (!billsHYJKListFD.isEmpty()) {
|
|
|
+ idHYJKList.addAll(billsHYJKListFD.stream().map(Bills::getId).collect(Collectors.toList()));
|
|
|
}
|
|
|
- List<Containers> containersHYCKList = containersService.list(new LambdaQueryWrapper<Containers>()
|
|
|
+ List<Containers> containersHYJKListFD = containersService.list(new LambdaQueryWrapper<Containers>()
|
|
|
.eq(Containers::getTenantId, AuthUtil.getTenantId())
|
|
|
.eq(Containers::getIsDeleted, 0)
|
|
|
- .in(Containers::getPid, idHYCKList)
|
|
|
+ .in(Containers::getPid, idHYJKList)
|
|
|
.in(Containers::getCntrNo, boxNum));
|
|
|
List<Containers> containersListNew = new ArrayList<>();
|
|
|
for (Containers item : containersHYJKList) {
|
|
|
@@ -4018,18 +4073,511 @@ public class PutBoxServiceImpl extends ServiceImpl<PutBoxMapper, PutBox> impleme
|
|
|
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(bills.getPodStationId());
|
|
|
+ containers.setPodStationCname(bills.getPodStationCname());
|
|
|
+ containers.setPodStationEname(bills.getPodStationEname());
|
|
|
+ containers.setPodStationCode(bills.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(bills.getReturnEmptyTime());
|
|
|
+ archives.setBoxDynamics("空箱进场");
|
|
|
+ archives.setAddressId(bills.getPodId());
|
|
|
+ archives.setAddressCode(bills.getPodCode());
|
|
|
+ archives.setAddressCname(bills.getPodCnName());
|
|
|
+ archives.setAddressEname(bills.getPodEnName());
|
|
|
+ archives.setStationId(bills.getPodStationId());
|
|
|
+ archives.setStationCode(bills.getPodStationCname());
|
|
|
+ archives.setStationCname(bills.getPodStationEname());
|
|
|
+ archives.setStationEname(bills.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(bills.getPodStationId());
|
|
|
+ putBoxItem.setPodStationCode(bills.getPodStationCname());
|
|
|
+ putBoxItem.setPodStationCname(bills.getPodStationEname());
|
|
|
+ putBoxItem.setPodStationEname(bills.getPodStationCode());
|
|
|
+ putBoxItem.setPodEmptyContainerReturnDate(bills.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(bills.getPodStationId());
|
|
|
+ tradingBoxItem.setPodStationCode(bills.getPodStationCname());
|
|
|
+ tradingBoxItem.setPodStationCname(bills.getPodStationEname());
|
|
|
+ tradingBoxItem.setPodStationEname(bills.getPodStationCode());
|
|
|
+ tradingBoxItem.setPodEmptyContainerReturnDate(bills.getReturnEmptyTime());
|
|
|
+ tradingBoxItem.setBoxDynamics("空箱进场");
|
|
|
+ tradingBoxItem.setStatus("待使用");
|
|
|
+ tradingBoxItem.setPortId(bills.getPodId());
|
|
|
+ tradingBoxItem.setPortCode(bills.getPodCode());
|
|
|
+ tradingBoxItem.setPortCname(bills.getPodCnName());
|
|
|
+ tradingBoxItem.setPortEname(bills.getPodEnName());
|
|
|
+ tradingBoxItem.setStationId(bills.getPodStationId());
|
|
|
+ tradingBoxItem.setStationCode(bills.getPodStationCname());
|
|
|
+ tradingBoxItem.setStationCname(bills.getPodStationEname());
|
|
|
+ tradingBoxItem.setStationEname(bills.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(bills.getPodId());
|
|
|
+ putBox2.setPolCode(bills.getPodCode());
|
|
|
+ putBox2.setPolCname(bills.getPodCnName());
|
|
|
+ putBox2.setPolEname(bills.getPodEnName());
|
|
|
+ putBox2.setPolStationId(bills.getPodStationId());
|
|
|
+ putBox2.setPolStationCode(bills.getPodStationCname());
|
|
|
+ putBox2.setPolStationCname(bills.getPodStationEname());
|
|
|
+ putBox2.setPolStationEname(bills.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(bills.getPodId());
|
|
|
+ putBox.setPolCode(bills.getPodCode());
|
|
|
+ putBox.setPolCname(bills.getPodCnName());
|
|
|
+ putBox.setPolEname(bills.getPodEnName());
|
|
|
+ putBox.setPolStationId(bills.getPodStationId());
|
|
|
+ putBox.setPolStationCode(bills.getPodStationCname());
|
|
|
+ putBox.setPolStationCname(bills.getPodStationEname());
|
|
|
+ putBox.setPolStationEname(bills.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(bills.getPodStationId());
|
|
|
+ putBoxItem.setPodStationCode(bills.getPodStationCname());
|
|
|
+ putBoxItem.setPodStationCname(bills.getPodStationEname());
|
|
|
+ putBoxItem.setPodStationEname(bills.getPodStationCode());
|
|
|
+ putBoxItem.setPodEmptyContainerReturnDate(bills.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(bills.getPodStationId());
|
|
|
+ tradingBoxItem.setPodStationCode(bills.getPodStationCname());
|
|
|
+ tradingBoxItem.setPodStationCname(bills.getPodStationEname());
|
|
|
+ tradingBoxItem.setPodStationEname(bills.getPodStationCode());
|
|
|
+ tradingBoxItem.setPodEmptyContainerReturnDate(bills.getReturnEmptyTime());
|
|
|
+ tradingBoxItem.setBoxDynamics("空箱进场");
|
|
|
+ tradingBoxItem.setStatus("待使用");
|
|
|
+ tradingBoxItem.setPortId(bills.getPodId());
|
|
|
+ tradingBoxItem.setPortCode(bills.getPodCode());
|
|
|
+ tradingBoxItem.setPortCname(bills.getPodCnName());
|
|
|
+ tradingBoxItem.setPortEname(bills.getPodEnName());
|
|
|
+ tradingBoxItem.setStationId(bills.getPodStationId());
|
|
|
+ tradingBoxItem.setStationCode(bills.getPodStationCname());
|
|
|
+ tradingBoxItem.setStationCname(bills.getPodStationEname());
|
|
|
+ tradingBoxItem.setStationEname(bills.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() + "单据类型错误,请联系管理员");
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
- for (Containers item : containersHYCKList) {
|
|
|
- item.setPodStationId(bills.getPodStationId());
|
|
|
- item.setPodStationCname(bills.getPodStationCname());
|
|
|
- item.setPodStationEname(bills.getPodStationEname());
|
|
|
- item.setPodStationCode(bills.getPodStationCode());
|
|
|
- item.setUpdateTime(new Date());
|
|
|
- item.setUpdateUser(AuthUtil.getUserId());
|
|
|
- item.setUpdateUserName(AuthUtil.getUserName());
|
|
|
- containersListNew.add(item);
|
|
|
+ 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 : containersHYJKList) {
|
|
|
+ //箱档案信息处理
|
|
|
+ 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(bills.getPodId());
|
|
|
+ putBoxItem.setPolCyCode(bills.getPodCode());
|
|
|
+ putBoxItem.setPolCyCname(bills.getPodCnName());
|
|
|
+ putBoxItem.setPolCyEname(bills.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(bills.getPodId());
|
|
|
+ putBoxItem.setPolCyCode(bills.getPodCode());
|
|
|
+ putBoxItem.setPolCyCname(bills.getPodCnName());
|
|
|
+ putBoxItem.setPolCyEname(bills.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(bills.getPodId());
|
|
|
+ putBoxItem.setPolCyCode(bills.getPodCode());
|
|
|
+ putBoxItem.setPolCyCname(bills.getPodCnName());
|
|
|
+ putBoxItem.setPolCyEname(bills.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);
|
|
|
|
|
|
return null;
|
|
|
}
|
|
|
+
|
|
|
+ private void countOverdueFeeV1(Bills billsHYJK, List<TradingBox> tradingBoxList, List<TradingBoxItem> tradingBoxItemOldList) {
|
|
|
+ List<FeeCenter> feeCenterList = new ArrayList<>();
|
|
|
+ //超期标准
|
|
|
+ List<StorageFees> storageFeesList = storageFeesService.list(new LambdaQueryWrapper<StorageFees>()
|
|
|
+ .eq(StorageFees::getTenantId, AuthUtil.getTenantId())
|
|
|
+ .eq(StorageFees::getIsDeleted, 0)
|
|
|
+ .eq(StorageFees::getBranchId, billsHYJK.getBranchId()));
|
|
|
+ if (storageFeesList.isEmpty()) {
|
|
|
+ throw new RuntimeException("请先维护基础资料-超期标准");
|
|
|
+ }
|
|
|
+ List<Long> idList = storageFeesList.stream().map(StorageFees::getId).collect(Collectors.toList());
|
|
|
+ //超期标准明细
|
|
|
+ List<StorageFeesItems> storageFeesItemsList = storageFeesItemsService.list(new LambdaQueryWrapper<StorageFeesItems>()
|
|
|
+ .eq(StorageFeesItems::getTenantId, AuthUtil.getTenantId())
|
|
|
+ .eq(StorageFeesItems::getIsDeleted, 0)
|
|
|
+ .in(StorageFeesItems::getPid, idList));
|
|
|
+ if (storageFeesItemsList.isEmpty()) {
|
|
|
+ throw new RuntimeException("请先维护基础资料-超期标准");
|
|
|
+ }
|
|
|
+ //超期箱使费
|
|
|
+ BFees fees = bFeesService.getOne(new LambdaQueryWrapper<BFees>()
|
|
|
+ .eq(BFees::getTenantId, AuthUtil.getTenantId())
|
|
|
+ .eq(BFees::getIsDeleted, 0)
|
|
|
+ .eq(BFees::getCode, "CQXSF"));
|
|
|
+ if (fees == null) {
|
|
|
+ throw new RuntimeException("请先维护费用基础信息");
|
|
|
+ }
|
|
|
+ String overdueProportion = sysClient.getParamService("overdue.proportion");
|
|
|
+ if (ObjectUtils.isNull(overdueProportion) || "获取数据失败".equals(overdueProportion)) {
|
|
|
+ throw new RuntimeException("超期箱使费比例");
|
|
|
+ }
|
|
|
+ for (TradingBoxItem item : tradingBoxItemOldList) {
|
|
|
+ //查找OW明细对应主表
|
|
|
+ TradingBox tradingBox = tradingBoxList.stream().filter(e -> e.getId().equals(item.getPid())).findFirst().orElse(null);
|
|
|
+ if (tradingBox == null) {
|
|
|
+ throw new RuntimeException("未查到OW单据");
|
|
|
+ }
|
|
|
+ //对应海运进出口单据所属公司本位币
|
|
|
+ String exrateType = currencyUtils.standardCurrency(billsHYJK.getBranchId());
|
|
|
+ //对应海运进出口单据所属公司所有币别
|
|
|
+ List<BCurExrate> curExrateList = currencyUtils.obtainRate(new Date(), "1", billsHYJK.getBranchId());
|
|
|
+ //目的港超期天数
|
|
|
+ if (ObjectUtils.isNotNull(item.getPodEmptyContainerReturnDate()) &&
|
|
|
+ ObjectUtils.isNotNull(billsHYJK.getEta())) {
|
|
|
+ //所属公司具体超期标准
|
|
|
+ StorageFees storageFees = this.getStorageFees(storageFeesList, billsHYJK, "2");
|
|
|
+ if (storageFees == null) {
|
|
|
+ throw new RuntimeException("请先维护基础资料-超期标准");
|
|
|
+ }
|
|
|
+ //所属公司具体超期标准明细
|
|
|
+ List<StorageFeesItems> storageFeesItems = storageFeesItemsList.stream().filter(e -> e.getPid().equals(storageFees.getId()))
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ if (storageFeesItems.isEmpty()) {
|
|
|
+ throw new RuntimeException("请先维护基础资料-超期标准");
|
|
|
+ }
|
|
|
+ LocalDateTime ldt1 = item.getPodEmptyContainerReturnDate().toInstant().atZone(ZoneId.systemDefault()).toLocalDateTime();
|
|
|
+ LocalDateTime ldt2 = billsHYJK.getEta().toInstant().atZone(ZoneId.systemDefault()).toLocalDateTime();
|
|
|
+ long days = ChronoUnit.DAYS.between(ldt2, ldt1);
|
|
|
+ //超期天数
|
|
|
+ int overdueDays = 0;
|
|
|
+ if (ObjectUtils.isNull(billsHYJK.getPodFreeBoxUseDays()) || 0 == billsHYJK.getPodFreeBoxUseDays() ||
|
|
|
+ days > billsHYJK.getPodFreeBoxUseDays()) {
|
|
|
+ overdueDays = (int) (days - billsHYJK.getPodFreeBoxUseDays());
|
|
|
+ }
|
|
|
+ if (overdueDays != 0) {
|
|
|
+ FeeCenter feeCenter = this.addFeeCenter(tradingBox, item, billsHYJK, fees, storageFeesItems, curExrateList, overdueDays, exrateType);
|
|
|
+ if (feeCenter != null) {
|
|
|
+ feeCenterList.add(feeCenter);
|
|
|
+ FeeCenter feeCenterC = new FeeCenter();
|
|
|
+ BeanUtil.copyProperties(feeCenter, feeCenterC);
|
|
|
+ feeCenterC.setDc("C");
|
|
|
+ feeCenterC.setPrice(feeCenterC.getPrice().multiply(new BigDecimal(overdueProportion)).setScale(2, RoundingMode.HALF_UP));
|
|
|
+ feeCenterC.setAmount(feeCenterC.getQuantity().multiply(feeCenterC.getPrice()));
|
|
|
+ feeCenterC.setAmountLoc(feeCenterC.getAmount().multiply(feeCenter.getExrate()));
|
|
|
+ feeCenterList.add(feeCenterC);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (!feeCenterList.isEmpty()) {
|
|
|
+ feeCenterService.saveBatch(feeCenterList);
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|