|
|
@@ -29,25 +29,18 @@ 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.core.tool.utils.StringUtil;
|
|
|
-import org.springblade.los.Util.*;
|
|
|
-import org.springblade.los.basic.business.entity.BusinessType;
|
|
|
-import org.springblade.los.basic.business.service.IBusinessTypeService;
|
|
|
+import org.springblade.los.Util.BoxNumUtils;
|
|
|
+import org.springblade.los.Util.GlobalOperationLogUtils;
|
|
|
+import org.springblade.los.Util.OperatorType;
|
|
|
+import org.springblade.los.Util.OwBoxUsageFeeUtils;
|
|
|
import org.springblade.los.basic.cntr.entity.BCntrTypes;
|
|
|
import org.springblade.los.basic.cntr.service.IBCntrTypesService;
|
|
|
import org.springblade.los.basic.corps.entity.BCorps;
|
|
|
import org.springblade.los.basic.corps.service.IBCorpsService;
|
|
|
-import org.springblade.los.basic.cur.entity.BCurExrate;
|
|
|
-import org.springblade.los.basic.fees.entity.BFees;
|
|
|
-import org.springblade.los.basic.fees.service.IBFeesService;
|
|
|
import org.springblade.los.basic.ports.entity.BPorts;
|
|
|
import org.springblade.los.basic.ports.service.IBPortsService;
|
|
|
-import org.springblade.los.basic.storage.entity.StorageFees;
|
|
|
-import org.springblade.los.basic.storage.entity.StorageFeesItems;
|
|
|
-import org.springblade.los.basic.storage.service.IStorageFeesItemsService;
|
|
|
-import org.springblade.los.basic.storage.service.IStorageFeesService;
|
|
|
-import org.springblade.los.billno.entity.BusinessBillNo;
|
|
|
-import org.springblade.los.billno.service.IBusinessBillNoService;
|
|
|
import org.springblade.los.box.dynamics.entity.BoxDynamicsRecord;
|
|
|
import org.springblade.los.box.dynamics.entity.BoxDynamicsRecordItems;
|
|
|
import org.springblade.los.box.dynamics.mapper.BoxDynamicsRecordMapper;
|
|
|
@@ -71,11 +64,6 @@ import org.springblade.los.business.sea.service.IContainersService;
|
|
|
import org.springblade.los.business.sea.service.IPreContainersService;
|
|
|
import org.springblade.los.business.sea.service.ISeaContainerNumberItemService;
|
|
|
import org.springblade.los.enums.BoxDynamicsEnums;
|
|
|
-import org.springblade.los.finance.fee.entity.FeeCenter;
|
|
|
-import org.springblade.los.finance.fee.entity.FinAccBills;
|
|
|
-import org.springblade.los.finance.fee.service.ICostProfitCalculationService;
|
|
|
-import org.springblade.los.finance.fee.service.IFeeCenterService;
|
|
|
-import org.springblade.los.finance.fee.service.IFinAccBillsService;
|
|
|
import org.springblade.los.ftp.dto.ApiItem;
|
|
|
import org.springblade.los.ftp.dto.ApiRequest;
|
|
|
import org.springblade.resource.feign.IOssClient;
|
|
|
@@ -88,7 +76,6 @@ import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
|
import java.io.IOException;
|
|
|
import java.math.BigDecimal;
|
|
|
-import java.math.RoundingMode;
|
|
|
import java.rmi.RemoteException;
|
|
|
import java.text.ParseException;
|
|
|
import java.text.SimpleDateFormat;
|
|
|
@@ -142,30 +129,12 @@ public class BoxDynamicsRecordServiceImpl extends ServiceImpl<BoxDynamicsRecordM
|
|
|
|
|
|
private final ISeaContainerNumberItemService seaContainerNumberItemService;
|
|
|
|
|
|
- private final IStorageFeesService storageFeesService;
|
|
|
-
|
|
|
- private final IStorageFeesItemsService storageFeesItemsService;
|
|
|
-
|
|
|
- private final IBFeesService bFeesService;
|
|
|
-
|
|
|
- private final CurrencyUtils currencyUtils;
|
|
|
-
|
|
|
private final GlobalOperationLogUtils logUtils;
|
|
|
|
|
|
- private final IFeeCenterService feeCenterService;
|
|
|
-
|
|
|
- private final IFinAccBillsService finAccBillsService;
|
|
|
-
|
|
|
private final IBCntrTypesService cntrTypesService;
|
|
|
|
|
|
private final IMessageClient messageClient;
|
|
|
|
|
|
- private final ICostProfitCalculationService costProfitCalculationService;
|
|
|
-
|
|
|
- private final IBusinessTypeService bBusinessTypeService;
|
|
|
-
|
|
|
- private final IBusinessBillNoService businessBillNoService;
|
|
|
-
|
|
|
private final OwBoxUsageFeeUtils owBoxUsageFeeUtils;
|
|
|
|
|
|
@Override
|
|
|
@@ -989,10 +958,15 @@ public class BoxDynamicsRecordServiceImpl extends ServiceImpl<BoxDynamicsRecordM
|
|
|
appearance.setBoxCode(item.getCode());
|
|
|
appearance.setBoxType(tradingBox.getBoxTypeQuantityOne());
|
|
|
if (ObjectUtils.isNotNull(item.getPodStationId())) {
|
|
|
- portsList.stream().filter(e -> ObjectUtils.isNotNull(e.getAddressId()) && e.getAddressId().contains(item.getPodStationId() + "")).findFirst().ifPresent(ports -> appearance.setPortName(ports.getCnName()));
|
|
|
+ portsList.stream().filter(e -> ObjectUtils.isNotNull(e.getAddressId()) && e.getAddressId().contains(item.getPodStationId() + ""))
|
|
|
+ .findFirst().ifPresent(ports -> appearance.setPortName(ports.getCnName()));
|
|
|
+ } else {
|
|
|
+ if (ObjectUtils.isNotNull(tradingBox.getPodId()) && !tradingBox.getPodId().contains(",")) {
|
|
|
+ appearance.setPortName(tradingBox.getPodCname());
|
|
|
+ }
|
|
|
}
|
|
|
appearance.setStationName(item.getPodStationCname());
|
|
|
- appearance.setMblno("");
|
|
|
+ appearance.setMblno(item.getHblno());
|
|
|
appearance.setObjective("客户还箱");
|
|
|
appearance.setStatus(item.getBoxStatus());
|
|
|
list.add(appearance);
|
|
|
@@ -1000,6 +974,250 @@ public class BoxDynamicsRecordServiceImpl extends ServiceImpl<BoxDynamicsRecordM
|
|
|
return list;
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public R splitBoxNumber(Long billId, Long billIdNew, String containersIds) {
|
|
|
+ Bills bills = billsMapper.selectById(billId);
|
|
|
+ Bills billsNew = billsMapper.selectById(billIdNew);
|
|
|
+ List<Containers> containersList = containersService.list(new LambdaQueryWrapper<Containers>()
|
|
|
+ .eq(Containers::getTenantId, AuthUtil.getTenantId())
|
|
|
+ .eq(Containers::getIsDeleted, 0)
|
|
|
+ .eq(Containers::getPid, billId)
|
|
|
+ .in(Containers::getId, Func.toLongList(containersIds)));
|
|
|
+ if (containersList.isEmpty()) {
|
|
|
+ throw new RuntimeException("箱信息查询错误");
|
|
|
+ }
|
|
|
+ if (ObjectUtils.isNotNull(bills.getExtendedData())) {
|
|
|
+ String[] arr = bills.getExtendedData().split(",");
|
|
|
+ List<String> boxCode = new ArrayList<>();
|
|
|
+ for (String item : arr) {
|
|
|
+ if (!bills.getExtendedData().contains(item)) {
|
|
|
+ boxCode.add(item);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (!boxCode.isEmpty()) {
|
|
|
+ bills.setExtendedData(String.join(",", boxCode));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ billsNew.setExtendedData((ObjectUtils.isNotNull(billsNew.getExtendedData()) ? billsNew.getExtendedData() + "," : "")
|
|
|
+ + containersList.stream().map(Containers::getCntrNo).collect(Collectors.joining(",")));
|
|
|
+ List<String> boxType = containersList.stream().map(Containers::getCntrTypeCode).distinct().collect(Collectors.toList());
|
|
|
+ for (Containers item : containersList) {
|
|
|
+ item.setPid(billsNew.getId());
|
|
|
+ item.setHblno(billsNew.getHblno());
|
|
|
+ item.setMblno(billsNew.getMblno());
|
|
|
+ item.setUpdateUser(AuthUtil.getUserId());
|
|
|
+ item.setUpdateUserName(AuthUtil.getUserName());
|
|
|
+ item.setUpdateTime(new Date());
|
|
|
+ }
|
|
|
+ containersService.updateBatchById(containersList);
|
|
|
+ List<PreContainers> preContainersList = preContainersService.list(new LambdaQueryWrapper<PreContainers>()
|
|
|
+ .eq(PreContainers::getTenantId, AuthUtil.getTenantId())
|
|
|
+ .eq(PreContainers::getIsDeleted, 0)
|
|
|
+ .in(PreContainers::getCntrTypeCode, boxType)
|
|
|
+ .eq(PreContainers::getPid, billId));
|
|
|
+ List<SeaContainerNumberItem> containerNumberItemList = seaContainerNumberItemService.list(new LambdaQueryWrapper<SeaContainerNumberItem>()
|
|
|
+ .eq(SeaContainerNumberItem::getTenantId, AuthUtil.getTenantId())
|
|
|
+ .eq(SeaContainerNumberItem::getIsDeleted, 0)
|
|
|
+ .in(SeaContainerNumberItem::getBoxType, boxType)
|
|
|
+ .eq(SeaContainerNumberItem::getPid, billId));
|
|
|
+ if (containerNumberItemList.isEmpty()) {
|
|
|
+ throw new RuntimeException("提单号:" + bills.getHblno() + "未查到箱型占用放箱号记录");
|
|
|
+ }
|
|
|
+ List<SeaContainerNumberItem> containerNumberItemListNew = seaContainerNumberItemService.list(new LambdaQueryWrapper<SeaContainerNumberItem>()
|
|
|
+ .eq(SeaContainerNumberItem::getTenantId, AuthUtil.getTenantId())
|
|
|
+ .eq(SeaContainerNumberItem::getIsDeleted, 0)
|
|
|
+ .eq(SeaContainerNumberItem::getPid, billIdNew));
|
|
|
+ if (containerNumberItemList.isEmpty()) {
|
|
|
+ throw new RuntimeException("提单号" + billsNew.getHblno() + "未查到箱型占用放箱号记录");
|
|
|
+ }
|
|
|
+ List<PreContainers> preContainersListNew = preContainersService.list(new LambdaQueryWrapper<PreContainers>()
|
|
|
+ .eq(PreContainers::getTenantId, AuthUtil.getTenantId())
|
|
|
+ .eq(PreContainers::getIsDeleted, 0)
|
|
|
+ .eq(PreContainers::getPid, billIdNew));
|
|
|
+ List<PreContainers> preContainers = new ArrayList<>();
|
|
|
+ List<SeaContainerNumberItem> containerNumberItems = new ArrayList<>();
|
|
|
+ for (PreContainers item : preContainersList) {
|
|
|
+ //判断箱量是否大于箱型箱量和
|
|
|
+ int boxNumber = containersList.stream().filter(e -> e.getCntrTypeCode().equals(item.getCntrTypeCode())).collect(Collectors.toList()).size();
|
|
|
+ if (boxNumber > item.getQuantity()) {
|
|
|
+ throw new RuntimeException("本次拆分箱型:" + item.getCntrTypeCode() + "箱量大于箱型中箱量");
|
|
|
+ }
|
|
|
+ item.setQuantity(item.getQuantity() - boxNumber);
|
|
|
+ item.setActualQuantity(item.getQuantity());
|
|
|
+ item.setOccupyNum(item.getQuantity());
|
|
|
+ item.setUpdateUser(AuthUtil.getUserId());
|
|
|
+ item.setUpdateUserName(AuthUtil.getUserName());
|
|
|
+ item.setUpdateTime(new Date());
|
|
|
+ preContainers.add(item);
|
|
|
+ //修改原箱型占用放箱号记录数量
|
|
|
+ List<SeaContainerNumberItem> seaContainerNumberItems = containerNumberItemList.stream().filter(e -> e.getBoxType().equals(item.getCntrTypeCode()))
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ for (SeaContainerNumberItem containerNumberItem : seaContainerNumberItems) {
|
|
|
+ containerNumberItem.setUpdateUser(AuthUtil.getUserId());
|
|
|
+ containerNumberItem.setUpdateUserName(AuthUtil.getUserName());
|
|
|
+ containerNumberItem.setUpdateTime(new Date());
|
|
|
+ //计算单个放箱号拆分数量
|
|
|
+ int containerNumberSum = containersList.stream().filter(e -> e.getContainerNumber().equals(containerNumberItem.getContainerNumber())).collect(Collectors.toList()).size();
|
|
|
+ if (containerNumberSum > 0) {
|
|
|
+ containerNumberItem.setOccupyNum(containerNumberItem.getOccupyNum() - containerNumberSum);
|
|
|
+ containerNumberItem.setActualOccupyNum(containerNumberItem.getActualOccupyNum() - containerNumberSum);
|
|
|
+ containerNumberItem.setOutNum(containerNumberItem.getOutNum() - containerNumberSum);
|
|
|
+ containerNumberItems.add(containerNumberItem);
|
|
|
+ //查询
|
|
|
+ SeaContainerNumberItem seaContainerNumberItem = containerNumberItemListNew.stream()
|
|
|
+ .filter(e -> e.getSrcId().equals(containerNumberItem.getSrcId())).findFirst().orElse(null);
|
|
|
+ if (seaContainerNumberItem != null) {
|
|
|
+ seaContainerNumberItem.setOccupyNum(containerNumberItem.getOccupyNum() + containerNumberSum);
|
|
|
+ seaContainerNumberItem.setActualOccupyNum(containerNumberItem.getActualOccupyNum() + containerNumberSum);
|
|
|
+ seaContainerNumberItem.setOutNum(containerNumberItem.getOutNum() + containerNumberSum);
|
|
|
+ seaContainerNumberItem.setUpdateUser(AuthUtil.getUserId());
|
|
|
+ seaContainerNumberItem.setUpdateUserName(AuthUtil.getUserName());
|
|
|
+ seaContainerNumberItem.setUpdateTime(new Date());
|
|
|
+ } else {
|
|
|
+ seaContainerNumberItem = new SeaContainerNumberItem();
|
|
|
+ BeanUtil.copyProperties(containerNumberItem, seaContainerNumberItem);
|
|
|
+ seaContainerNumberItem.setUpdateUser(null);
|
|
|
+ seaContainerNumberItem.setUpdateUserName(null);
|
|
|
+ seaContainerNumberItem.setUpdateTime(null);
|
|
|
+ seaContainerNumberItem.setCreateUser(AuthUtil.getUserId());
|
|
|
+ seaContainerNumberItem.setCreateUserName(AuthUtil.getUserName());
|
|
|
+ seaContainerNumberItem.setCreateTime(new Date());
|
|
|
+ seaContainerNumberItem.setWhetherAppearStatus("1");
|
|
|
+ seaContainerNumberItem.setPid(billsNew.getId());
|
|
|
+ seaContainerNumberItem.setOccupyNum(containerNumberSum);
|
|
|
+ seaContainerNumberItem.setActualOccupyNum(containerNumberSum);
|
|
|
+ seaContainerNumberItem.setOutNum(containerNumberSum);
|
|
|
+ }
|
|
|
+ containerNumberItems.add(seaContainerNumberItem);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (!preContainersListNew.isEmpty()) {
|
|
|
+ PreContainers preContainers1 = preContainersListNew.stream().filter(e -> e.getCntrTypeCode().equals(item.getCntrTypeCode()))
|
|
|
+ .findFirst().orElse(null);
|
|
|
+ if (preContainers1 != null) {
|
|
|
+ preContainers1.setQuantity(item.getQuantity() + boxNumber);
|
|
|
+ preContainers1.setActualQuantity(item.getQuantity());
|
|
|
+ preContainers1.setOccupyNum(item.getQuantity());
|
|
|
+ preContainers1.setUpdateUser(AuthUtil.getUserId());
|
|
|
+ preContainers1.setUpdateUserName(AuthUtil.getUserName());
|
|
|
+ preContainers1.setUpdateTime(new Date());
|
|
|
+ preContainers.add(preContainers1);
|
|
|
+ } else {
|
|
|
+ throw new RuntimeException("提单号:" + billsNew.getHblno() + "未查到" + item.getCntrTypeCode() + "箱型");
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ throw new RuntimeException("提单号:" + billsNew.getHblno() + "未查到" + item.getCntrTypeCode() + "箱型");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (!preContainers.isEmpty()) {
|
|
|
+ preContainersService.updateBatchById(preContainers);
|
|
|
+ List<PreContainers> preContainers1 = preContainers.stream().filter(e -> e.getPid().equals(billId)).collect(Collectors.toList());
|
|
|
+ if (!preContainers1.isEmpty()) {
|
|
|
+ Integer V20 = 0;
|
|
|
+ Integer V40 = 0;
|
|
|
+ Integer V40HC = 0;
|
|
|
+ Integer V45 = 0;
|
|
|
+ Integer V48 = 0;
|
|
|
+ Integer other = 0;
|
|
|
+ BigDecimal teu = new BigDecimal("0.00");
|
|
|
+ StringBuilder boxTypeSum = new StringBuilder();
|
|
|
+ bills.setTeu(teu.intValue());
|
|
|
+ for (PreContainers item : preContainers1) {
|
|
|
+ switch (item.getCntrTypeCode()) {
|
|
|
+ case "20GP":
|
|
|
+ V20 += item.getQuantity();
|
|
|
+ break;
|
|
|
+ case "20HC":
|
|
|
+ V45 += item.getQuantity();
|
|
|
+ break;
|
|
|
+ case "40FR":
|
|
|
+ V48 += item.getQuantity();
|
|
|
+ break;
|
|
|
+ case "40GP":
|
|
|
+ V40 += item.getQuantity();
|
|
|
+ break;
|
|
|
+ case "40HC":
|
|
|
+ V40HC += item.getQuantity();
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ other += item.getQuantity();
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ boxTypeSum.append(item.getCntrTypeCode()).append("*").append(item.getQuantity()).append(",");
|
|
|
+ if (ObjectUtils.isNotNull(item.getQuantity()) && ObjectUtils.isNotNull(item.getTeu())) {
|
|
|
+ teu = teu.add(new BigDecimal(item.getQuantity()).multiply(item.getTeu()));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (boxTypeSum.length() > 0) {
|
|
|
+ boxTypeSum = new StringBuilder(boxTypeSum.substring(0, boxTypeSum.length() - 1));
|
|
|
+ bills.setQuantityCntrDescr(boxTypeSum.toString());
|
|
|
+ }
|
|
|
+ bills.setQuantityV20(V20);
|
|
|
+ bills.setQuantityV40(V40);
|
|
|
+ bills.setQuantityV40hc(V40HC);
|
|
|
+ bills.setQuantityV45(V45);
|
|
|
+ bills.setQuantityV48(V48);
|
|
|
+ bills.setQuantityOther(other);
|
|
|
+ bills.setTeu(teu.intValue());
|
|
|
+ }
|
|
|
+ List<PreContainers> preContainers2 = preContainers.stream().filter(e -> e.getPid().equals(billIdNew)).collect(Collectors.toList());
|
|
|
+ if (!preContainers2.isEmpty()) {
|
|
|
+ Integer V20 = 0;
|
|
|
+ Integer V40 = 0;
|
|
|
+ Integer V40HC = 0;
|
|
|
+ Integer V45 = 0;
|
|
|
+ Integer V48 = 0;
|
|
|
+ Integer other = 0;
|
|
|
+ BigDecimal teu = new BigDecimal("0.00");
|
|
|
+ StringBuilder boxTypeSum = new StringBuilder();
|
|
|
+ billsNew.setTeu(teu.intValue());
|
|
|
+ for (PreContainers item : preContainers2) {
|
|
|
+ switch (item.getCntrTypeCode()) {
|
|
|
+ case "20GP":
|
|
|
+ V20 += item.getQuantity();
|
|
|
+ break;
|
|
|
+ case "20HC":
|
|
|
+ V45 += item.getQuantity();
|
|
|
+ break;
|
|
|
+ case "40FR":
|
|
|
+ V48 += item.getQuantity();
|
|
|
+ break;
|
|
|
+ case "40GP":
|
|
|
+ V40 += item.getQuantity();
|
|
|
+ break;
|
|
|
+ case "40HC":
|
|
|
+ V40HC += item.getQuantity();
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ other += item.getQuantity();
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ boxTypeSum.append(item.getCntrTypeCode()).append("*").append(item.getQuantity()).append(",");
|
|
|
+ if (ObjectUtils.isNotNull(item.getQuantity()) && ObjectUtils.isNotNull(item.getTeu())) {
|
|
|
+ teu = teu.add(new BigDecimal(item.getQuantity()).multiply(item.getTeu()));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (boxTypeSum.length() > 0) {
|
|
|
+ boxTypeSum = new StringBuilder(boxTypeSum.substring(0, boxTypeSum.length() - 1));
|
|
|
+ billsNew.setQuantityCntrDescr(boxTypeSum.toString());
|
|
|
+ }
|
|
|
+ billsNew.setQuantityV20(V20);
|
|
|
+ billsNew.setQuantityV40(V40);
|
|
|
+ billsNew.setQuantityV40hc(V40HC);
|
|
|
+ billsNew.setQuantityV45(V45);
|
|
|
+ billsNew.setQuantityV48(V48);
|
|
|
+ billsNew.setQuantityOther(other);
|
|
|
+ billsNew.setTeu(teu.intValue());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (!containerNumberItems.isEmpty()) {
|
|
|
+ seaContainerNumberItemService.saveOrUpdateBatch(containerNumberItems);
|
|
|
+ }
|
|
|
+ billsMapper.updateById(bills);
|
|
|
+ billsMapper.updateById(billsNew);
|
|
|
+ return R.success("操作成功");
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 新箱进场流程
|
|
|
*
|
|
|
@@ -1217,6 +1435,11 @@ public class BoxDynamicsRecordServiceImpl extends ServiceImpl<BoxDynamicsRecordM
|
|
|
putBoxItem.setPid(putBox.getId());
|
|
|
putBoxItem.setMblno(item.getMblno());
|
|
|
putBoxItem.setBoxDynamics("空箱提箱进场");
|
|
|
+ if ("使用中".equals(putBoxItem.getStatus())) {
|
|
|
+ failureHandling(type, boxDynamicsRecord, "放箱号:" + item.getContainerNumber() + "箱号:" +
|
|
|
+ item.getBoxCode() + "状态为使用中,请先还箱");
|
|
|
+ return false;
|
|
|
+ }
|
|
|
putBoxItem.setStatus("待使用");
|
|
|
putBoxItem.setPolCyId(item.getStationId());
|
|
|
putBoxItem.setPolCyCode(item.getStationCode());
|
|
|
@@ -2435,7 +2658,7 @@ public class BoxDynamicsRecordServiceImpl extends ServiceImpl<BoxDynamicsRecordM
|
|
|
if (!tradingBoxItemOldList.isEmpty()) {
|
|
|
tradingBoxItemService.updateBatchById(tradingBoxItemOldList);
|
|
|
//OW(拿)计算箱使费
|
|
|
- List<Long> pidList = tradingBoxItemOldList.stream().map(TradingBoxItem::getPid).distinct().collect(Collectors.toList());
|
|
|
+ /*List<Long> pidList = tradingBoxItemOldList.stream().map(TradingBoxItem::getPid).distinct().collect(Collectors.toList());
|
|
|
if (!tradingBoxList.isEmpty()) {
|
|
|
List<TradingBox> tradingBoxes1 = tradingBoxList.stream().filter(e -> pidList.contains(e.getId())).collect(Collectors.toList());
|
|
|
for (TradingBox detail : tradingBoxes1) {
|
|
|
@@ -2444,7 +2667,7 @@ public class BoxDynamicsRecordServiceImpl extends ServiceImpl<BoxDynamicsRecordM
|
|
|
filter(e -> e.getPid().equals(detail.getId())).collect(Collectors.toList()), type);
|
|
|
}
|
|
|
}
|
|
|
- }
|
|
|
+ }*/
|
|
|
|
|
|
}
|
|
|
if (!containersListNew.isEmpty()) {
|
|
|
@@ -2461,7 +2684,7 @@ public class BoxDynamicsRecordServiceImpl extends ServiceImpl<BoxDynamicsRecordM
|
|
|
}
|
|
|
for (Bills billsHYJK : billsHYJKListFD) {
|
|
|
//计算超期箱使费
|
|
|
- this.countOverdueFeeV1(billsHYJK, tradingBoxList, tradingBoxItemOldList, putBoxItemsOldList, putBoxList, boxDynamicsRecord, type);
|
|
|
+ owBoxUsageFeeUtils.countOverdueFeeV1(billsHYJK, tradingBoxList, tradingBoxItemOldList, putBoxItemsOldList, putBoxList, boxDynamicsRecord, type);
|
|
|
}
|
|
|
for (BoxDynamicsRecordItems item : itemsListFC) {
|
|
|
item.setWhetherSynchronous("1");
|
|
|
@@ -2595,6 +2818,11 @@ public class BoxDynamicsRecordServiceImpl extends ServiceImpl<BoxDynamicsRecordM
|
|
|
}
|
|
|
putBoxItem.setPid(putBox.getId());
|
|
|
putBoxItem.setBoxDynamics("调箱进场");
|
|
|
+ if ("使用中".equals(putBoxItem.getStatus())) {
|
|
|
+ failureHandling(type, boxDynamicsRecord, "放箱号:" + item.getContainerNumber() + "箱号:" +
|
|
|
+ item.getBoxCode() + "状态为使用中,请先还箱");
|
|
|
+ return false;
|
|
|
+ }
|
|
|
putBoxItem.setStatus("待使用");
|
|
|
putBoxItem.setPolCyId(item.getStationId());
|
|
|
putBoxItem.setPolCyCode(item.getStationCode());
|
|
|
@@ -3375,8 +3603,7 @@ public class BoxDynamicsRecordServiceImpl extends ServiceImpl<BoxDynamicsRecordM
|
|
|
if (!containersListNew.isEmpty()) {
|
|
|
containersService.updateBatchById(containersListNew);
|
|
|
}
|
|
|
- //todo 计算无货返空超期箱使费
|
|
|
- this.countOverdueFeeWHFK(putBoxNewList, tradingBoxList, tradingBoxItemOldList, billsListFD, putBoxItemsNewList, boxDynamicsRecord, type);
|
|
|
+ owBoxUsageFeeUtils.countOverdueFeeWHFK(putBoxNewList, tradingBoxList, tradingBoxItemOldList, billsListFD, putBoxItemsNewList, boxDynamicsRecord, type);
|
|
|
|
|
|
for (BoxDynamicsRecordItems item : itemsListFC) {
|
|
|
item.setWhetherSynchronous("1");
|
|
|
@@ -4361,7 +4588,6 @@ public class BoxDynamicsRecordServiceImpl extends ServiceImpl<BoxDynamicsRecordM
|
|
|
putBoxItem.setAgentName(bills.getForeignAgencyCnName());
|
|
|
putBoxItem.setCorpId(bills.getCorpId());
|
|
|
putBoxItem.setCorpName(bills.getCorpCnName());
|
|
|
- putBoxItem.setHblno(bills.getHblno());
|
|
|
putBoxItem.setVoyage(bills.getVoyageNo());
|
|
|
putBoxItem.setShipNameId(bills.getVesselId());
|
|
|
putBoxItem.setAgentName(bills.getForeignAgencyCnName());
|
|
|
@@ -4372,6 +4598,7 @@ public class BoxDynamicsRecordServiceImpl extends ServiceImpl<BoxDynamicsRecordM
|
|
|
} else {
|
|
|
putBoxItem.setUnoccupied("1");
|
|
|
}
|
|
|
+ putBoxItem.setHblno(item.getHblno());
|
|
|
putBoxItem.setTemporaryId(item.getTemporaryId());
|
|
|
putBoxItems.add(putBoxItem);
|
|
|
if ("OW(拿),OW(放)".contains(putBoxData.getBoxClass())) {
|
|
|
@@ -4497,7 +4724,6 @@ public class BoxDynamicsRecordServiceImpl extends ServiceImpl<BoxDynamicsRecordM
|
|
|
tradingBoxItem.setMblno(bills.getMblno());
|
|
|
tradingBoxItem.setCorpId(bills.getCorpId());
|
|
|
tradingBoxItem.setCorpName(bills.getCorpCnName());
|
|
|
- tradingBoxItem.setHblno(bills.getHblno());
|
|
|
tradingBoxItem.setVoyage(bills.getVoyageNo());
|
|
|
tradingBoxItem.setShipNameId(bills.getVesselId());
|
|
|
tradingBoxItem.setShipCname(bills.getVesselCnName());
|
|
|
@@ -4505,6 +4731,7 @@ public class BoxDynamicsRecordServiceImpl extends ServiceImpl<BoxDynamicsRecordM
|
|
|
tradingBoxItem.setPolFreeBoxUseDays(bills.getPolFreeBoxUseDays());
|
|
|
tradingBoxItem.setEtd(bills.getEtd());
|
|
|
}
|
|
|
+ tradingBoxItem.setHblno(item.getHblno());
|
|
|
tradingBoxItem.setTemporaryId(item.getTemporaryId());
|
|
|
tradingBoxItems.add(tradingBoxItem);
|
|
|
} else {
|
|
|
@@ -4549,6 +4776,20 @@ public class BoxDynamicsRecordServiceImpl extends ServiceImpl<BoxDynamicsRecordM
|
|
|
containers.setPolCyCname(recordItems.getStationCname());
|
|
|
containers.setPolCyEname(recordItems.getStationEname());
|
|
|
containers.setPolStationEmptyContainerExitDate(recordItems.getApproachExitDate());
|
|
|
+ if (!tradingBoxItemList.isEmpty()) {
|
|
|
+ TradingBoxItem tradingBoxItem = tradingBoxItemList.stream().filter(e -> e.getCode().equals(recordItems.getBoxCode()))
|
|
|
+ .findFirst().orElse(null);
|
|
|
+ if (tradingBoxItem != null) {
|
|
|
+ containers.setPodStationId(tradingBoxItem.getPodStationId());
|
|
|
+ containers.setPodStationCode(tradingBoxItem.getPodStationCode());
|
|
|
+ containers.setPodStationCname(tradingBoxItem.getPodStationCname());
|
|
|
+ containers.setPodStationEname(tradingBoxItem.getPodStationEname());
|
|
|
+ containers.setPodCyAddress(tradingBoxItem.getPodCyAddress());
|
|
|
+ containers.setPodCyContact(tradingBoxItem.getPodCyContact());
|
|
|
+ containers.setPodCyEmail(tradingBoxItem.getPodCyEmail());
|
|
|
+ containers.setPodCyTel(tradingBoxItem.getPodCyTel());
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
} else {
|
|
|
BoxDynamicsRecordItems recordItems = hblnoList.stream().filter(e -> containers.getCntrNo().equals(e.getBoxCode())).findFirst().orElse(null);
|
|
|
@@ -4560,16 +4801,22 @@ public class BoxDynamicsRecordServiceImpl extends ServiceImpl<BoxDynamicsRecordM
|
|
|
containers.setPolCyCname(recordItems.getStationCname());
|
|
|
containers.setPolCyEname(recordItems.getStationEname());
|
|
|
containers.setPolStationEmptyContainerExitDate(recordItems.getApproachExitDate());
|
|
|
+ if (!tradingBoxItemList.isEmpty()) {
|
|
|
+ TradingBoxItem tradingBoxItem = tradingBoxItemList.stream().filter(e -> e.getCode().equals(recordItems.getBoxCode()))
|
|
|
+ .findFirst().orElse(null);
|
|
|
+ if (tradingBoxItem != null) {
|
|
|
+ containers.setPodStationId(tradingBoxItem.getPodStationId());
|
|
|
+ containers.setPodStationCode(tradingBoxItem.getPodStationCode());
|
|
|
+ containers.setPodStationCname(tradingBoxItem.getPodStationCname());
|
|
|
+ containers.setPodStationEname(tradingBoxItem.getPodStationEname());
|
|
|
+ containers.setPodCyAddress(tradingBoxItem.getPodCyAddress());
|
|
|
+ containers.setPodCyContact(tradingBoxItem.getPodCyContact());
|
|
|
+ containers.setPodCyEmail(tradingBoxItem.getPodCyEmail());
|
|
|
+ containers.setPodCyTel(tradingBoxItem.getPodCyTel());
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
- containers.setPodStationId(putBoxData.getPodStationId());
|
|
|
- containers.setPodStationCode(putBoxData.getPodStationCode());
|
|
|
- containers.setPodStationCname(putBoxData.getPodStationCname());
|
|
|
- containers.setPodStationEname(putBoxData.getPodStationEname());
|
|
|
- containers.setPodCyAddress(putBoxData.getPodCyAddress());
|
|
|
- containers.setPodCyContact(putBoxData.getPodCyContact());
|
|
|
- containers.setPodCyEmail(putBoxData.getPodCyEmail());
|
|
|
- containers.setPodCyTel(putBoxData.getPodCyTel());
|
|
|
containers.setBoxSrcType(putBoxData.getBoxClass());
|
|
|
containers.setWhetherAppearStatus("1");
|
|
|
int version = StringUtil.isBlank(containers.getVersion()) ? 1 : Integer.parseInt(containers.getVersion());
|
|
|
@@ -4818,7 +5065,7 @@ public class BoxDynamicsRecordServiceImpl extends ServiceImpl<BoxDynamicsRecordM
|
|
|
tradingBoxItemService.saveOrUpdateBatch(tradingBoxItems);
|
|
|
}
|
|
|
if (!putBoxItems.isEmpty()) {
|
|
|
- this.countOverdueFee(putBoxList, tradingBoxList, tradingBoxItems, containersListNew, putBoxItems, boxDynamicsRecord, type);
|
|
|
+ owBoxUsageFeeUtils.countOverdueFee(putBoxList, tradingBoxList, tradingBoxItems, containersListNew, putBoxItems, boxDynamicsRecord, type);
|
|
|
}
|
|
|
for (BoxDynamicsRecordItems item : itemsListCC) {
|
|
|
item.setWhetherSynchronous("1");
|
|
|
@@ -4876,1168 +5123,6 @@ public class BoxDynamicsRecordServiceImpl extends ServiceImpl<BoxDynamicsRecordM
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * 正常出场-起运港出口超期箱使费
|
|
|
- *
|
|
|
- * @param containersListNew 出口分单配箱明细
|
|
|
- * @param tradingBoxList ow/自有箱单据
|
|
|
- * @param tradingBoxItemOldList ow/自有箱单据箱明细
|
|
|
- * @param putBoxItems 放箱号单据箱明细
|
|
|
- * @param putBoxList 放箱号单据
|
|
|
- * @param boxDynamicsRecord 进场记录
|
|
|
- * @param type 操作类型 1=excel导入直接提示 2=api记录并修改状态为失败 3=只记录
|
|
|
- */
|
|
|
- private Boolean countOverdueFee(List<PutBox> putBoxList, List<TradingBox> tradingBoxList, List<TradingBoxItem> tradingBoxItemOldList,
|
|
|
- List<Containers> containersListNew, List<PutBoxItems> putBoxItems
|
|
|
- , BoxDynamicsRecord boxDynamicsRecord, String type) throws IOException {
|
|
|
- List<FeeCenter> feeCenterListD = new ArrayList<>();
|
|
|
- List<FeeCenter> feeCenterListC = new ArrayList<>();
|
|
|
- List<PutBoxItems> putBoxItemsList = new ArrayList<>();
|
|
|
- List<TradingBoxItem> tradingBoxItemList = new ArrayList<>();
|
|
|
- List<String> mblnoList = putBoxItems.stream().map(PutBoxItems::getHblno).collect(Collectors.toList());
|
|
|
- List<Bills> billsList = new ArrayList<>();
|
|
|
- //超期箱使费
|
|
|
- BFees fees = bFeesService.getOne(new LambdaQueryWrapper<BFees>()
|
|
|
- .eq(BFees::getTenantId, boxDynamicsRecord.getTenantId())
|
|
|
- .eq(BFees::getIsDeleted, 0)
|
|
|
- .eq(BFees::getCode, "CQXSF"));
|
|
|
- if (fees == null) {
|
|
|
- failureHandling("3", boxDynamicsRecord, "请先维护费用基础信息");
|
|
|
- return false;
|
|
|
- }
|
|
|
- if (!mblnoList.isEmpty()) {
|
|
|
- //海运进出口单据
|
|
|
- billsList = billsMapper.selectList(new LambdaQueryWrapper<Bills>()
|
|
|
- .eq(Bills::getTenantId, boxDynamicsRecord.getTenantId())
|
|
|
- .eq(Bills::getIsDeleted, 0)
|
|
|
- .in(Bills::getHblno, mblnoList)
|
|
|
- .eq(Bills::getBusinessType, "SE"));
|
|
|
- if (billsList.isEmpty()) {
|
|
|
- failureHandling("3", boxDynamicsRecord, "未查到对应提单号海运进出口单据");
|
|
|
- return false;
|
|
|
- }
|
|
|
- List<String> branchIdList = billsList.stream().map(Bills::getBranchId).distinct().collect(Collectors.toList());
|
|
|
- //超期标准
|
|
|
- List<StorageFees> storageFeesList = storageFeesService.list(new LambdaQueryWrapper<StorageFees>()
|
|
|
- .eq(StorageFees::getTenantId, boxDynamicsRecord.getTenantId())
|
|
|
- .eq(StorageFees::getIsDeleted, 0)
|
|
|
- .in(StorageFees::getBranchId, branchIdList));
|
|
|
- if (storageFeesList.isEmpty()) {
|
|
|
- failureHandling("3", boxDynamicsRecord, "请先维护基础资料-超期标准");
|
|
|
- return false;
|
|
|
- }
|
|
|
- List<Long> idList = storageFeesList.stream().map(StorageFees::getId).collect(Collectors.toList());
|
|
|
- //超期标准明细
|
|
|
- List<StorageFeesItems> storageFeesItemsList = storageFeesItemsService.list(new LambdaQueryWrapper<StorageFeesItems>()
|
|
|
- .eq(StorageFeesItems::getTenantId, boxDynamicsRecord.getTenantId())
|
|
|
- .eq(StorageFeesItems::getIsDeleted, 0)
|
|
|
- .in(StorageFeesItems::getPid, idList));
|
|
|
- if (storageFeesItemsList.isEmpty()) {
|
|
|
- failureHandling("3", boxDynamicsRecord, "请先维护基础资料-超期标准");
|
|
|
- return false;
|
|
|
- }
|
|
|
- String overdueProportion = sysClient.getParamService("overdue.proportion");
|
|
|
- if (ObjectUtils.isNull(overdueProportion) || "获取数据失败".equals(overdueProportion)) {
|
|
|
- failureHandling("3", boxDynamicsRecord, "超期箱使费比例");
|
|
|
- return false;
|
|
|
- }
|
|
|
- BCorps bCorps = bCorpsService.getOne(new LambdaQueryWrapper<BCorps>()
|
|
|
- .eq(BCorps::getTenantId, boxDynamicsRecord.getTenantId())
|
|
|
- .eq(BCorps::getIsDeleted, 0)
|
|
|
- .eq(BCorps::getCode, "ZBYF"));
|
|
|
- if (bCorps == null) {
|
|
|
- failureHandling("3", boxDynamicsRecord, "基础资料未查到编码为‘ZBYF’往来单位");
|
|
|
- return false;
|
|
|
- }
|
|
|
- for (PutBoxItems item : putBoxItems) {
|
|
|
- PutBox putBox = putBoxList.stream().filter(e -> e.getId().equals(item.getPid())).findFirst().orElse(null);
|
|
|
- if (putBox == null) {
|
|
|
- failureHandling("3", boxDynamicsRecord, "未查到放箱号数据");
|
|
|
- return false;
|
|
|
- }
|
|
|
- Containers containers = containersListNew.stream().filter(e -> item.getBoxCode().equals(e.getCntrNo())).findFirst().orElse(null);
|
|
|
- if (containers == null) {
|
|
|
- failureHandling("3", boxDynamicsRecord, "箱号未在配箱信息中查到");
|
|
|
- return false;
|
|
|
- }
|
|
|
- //查找OW明细提单号对应海运进出口单据
|
|
|
- Bills bills = billsList.stream().filter(e -> e.getHblno().equals(item.getHblno()) && e.getId().equals(containers.getPid()))
|
|
|
- .findFirst().orElse(null);
|
|
|
- if (bills == null) {
|
|
|
- failureHandling("3", boxDynamicsRecord, "海运出口提单号:" + item.getHblno() + "配箱信息列表中未查到对应箱号:" + item.getBoxCode());
|
|
|
- return false;
|
|
|
- }
|
|
|
- //对应海运进出口单据所属公司本位币
|
|
|
- String exrateType = currencyUtils.standardCurrency(bills.getBranchId());
|
|
|
- //对应海运进出口单据所属公司所有币别
|
|
|
- List<BCurExrate> curExrateList = currencyUtils.obtainRate(new Date(), "1", bills.getBranchId());
|
|
|
- Date polPickUpDate = item.getPolStationEmptyContainerExitDate();
|
|
|
- //起运港超期天数
|
|
|
- if (ObjectUtils.isNotNull(polPickUpDate) && ObjectUtils.isNotNull(bills.getActualEtd())) {
|
|
|
- //所属公司具体超期标准
|
|
|
- StorageFees storageFees = this.getStorageFees(storageFeesList, bills, "1");
|
|
|
- if (storageFees == null) {
|
|
|
- failureHandling("3", boxDynamicsRecord, "请先维护基础资料-超期标准");
|
|
|
- return false;
|
|
|
- }
|
|
|
- //所属公司具体超期标准明细
|
|
|
- List<StorageFeesItems> storageFeesItems = storageFeesItemsList.stream().filter(e -> e.getPid().equals(storageFees.getId()))
|
|
|
- .collect(Collectors.toList());
|
|
|
- if (storageFeesItems.isEmpty()) {
|
|
|
- failureHandling("3", boxDynamicsRecord, "请先维护基础资料-超期标准");
|
|
|
- return false;
|
|
|
- }
|
|
|
- LocalDateTime ldt1 = bills.getActualEtd().toInstant().atZone(ZoneId.systemDefault()).toLocalDateTime();
|
|
|
- LocalDateTime ldt2 = polPickUpDate.toInstant().atZone(ZoneId.systemDefault()).toLocalDateTime();
|
|
|
- int overdueDays = (int) ChronoUnit.DAYS.between(ldt1, ldt2);
|
|
|
- //超期天数
|
|
|
- if (overdueDays > 0) {
|
|
|
- FeeCenter feeCenter = this.addFeeCenter(item, bills, fees, storageFeesItems, curExrateList, overdueDays, exrateType);
|
|
|
- if (feeCenter != null) {
|
|
|
- FeeCenter feeCenterC = new FeeCenter();
|
|
|
- BeanUtil.copyProperties(feeCenter, feeCenterC);
|
|
|
- feeCenterC.setPid(bills.getId());
|
|
|
- feeCenterC.setDc("C");
|
|
|
- feeCenterC.setCorpType("国内直接客户");
|
|
|
- feeCenterC.setCorpId(bCorps.getId());
|
|
|
- feeCenterC.setCorpCnName(bCorps.getCnName());
|
|
|
- feeCenterC.setCorpEnName(bCorps.getEnName());
|
|
|
- feeCenterC.setShortName(bCorps.getShortName());
|
|
|
- feeCenterC.setPrice(feeCenterC.getPrice().multiply(new BigDecimal(overdueProportion))
|
|
|
- .divide(new BigDecimal("100"), 2, RoundingMode.HALF_UP).setScale(2, RoundingMode.HALF_UP));
|
|
|
- feeCenterC.setAmount(feeCenterC.getQuantity().multiply(feeCenterC.getPrice()));
|
|
|
- feeCenterC.setAmountLoc(feeCenterC.getAmount().multiply(feeCenter.getExrate()));
|
|
|
- feeCenterC.setUnsettledAmount(feeCenterC.getAmount());
|
|
|
- if (feeCenterListD.isEmpty()) {
|
|
|
- feeCenterListD.add(feeCenter);
|
|
|
- feeCenterListC.add(feeCenterC);
|
|
|
- } else {
|
|
|
- FeeCenter feeCenterD = feeCenterListD.stream().filter(e -> e.getPid().equals(feeCenter.getPid()) &&
|
|
|
- e.getUnitNo().equals(feeCenter.getUnitNo())).findFirst().orElse(null);
|
|
|
- if (feeCenterD != null) {
|
|
|
- feeCenterD.setQuantity(feeCenterD.getQuantity().add(new BigDecimal("1")));
|
|
|
- feeCenterD.setAmount(feeCenterD.getQuantity().multiply(feeCenterD.getPrice()));
|
|
|
- feeCenterD.setAmountLoc(feeCenterD.getAmount().multiply(feeCenterD.getExrate()));
|
|
|
- feeCenterD.setUnsettledAmount(feeCenterD.getAmount());
|
|
|
- FeeCenter feeCentersC = feeCenterListC.stream().filter(e -> e.getPid().equals(feeCenterC.getPid()) &&
|
|
|
- e.getUnitNo().equals(feeCenterC.getUnitNo())).findFirst().orElse(null);
|
|
|
- if (feeCentersC != null) {
|
|
|
- feeCentersC.setQuantity(feeCentersC.getQuantity().add(new BigDecimal("1")));
|
|
|
- feeCentersC.setAmount(feeCentersC.getQuantity().multiply(feeCentersC.getPrice()));
|
|
|
- feeCentersC.setAmountLoc(feeCentersC.getAmount().multiply(feeCentersC.getExrate()));
|
|
|
- feeCentersC.setUnsettledAmount(feeCentersC.getAmount());
|
|
|
- }
|
|
|
- } else {
|
|
|
- feeCenterListD.add(feeCenter);
|
|
|
- feeCenterListC.add(feeCenterC);
|
|
|
- }
|
|
|
- }
|
|
|
- item.setPolOverdueBoxUseDays(Integer.parseInt(overdueDays + ""));
|
|
|
- item.setPolFreeBoxUseDays(feeCenter.getOverdueBoxUseDays());
|
|
|
- }
|
|
|
- putBoxItemsList.add(item);
|
|
|
- if ("OW(拿),OW(放)".contains(putBox.getBoxClass())) {
|
|
|
- TradingBoxItem tradingBoxItem = tradingBoxItemOldList.stream().filter(e -> e.getCode().equals(item.getBoxCode())).findFirst().orElse(null);
|
|
|
- if (tradingBoxItem == null) {
|
|
|
- failureHandling("3", boxDynamicsRecord, "未查到OW单据明细箱号");
|
|
|
- return false;
|
|
|
- }
|
|
|
- //查找OW明细对应主表
|
|
|
- TradingBox tradingBox = tradingBoxList.stream().filter(e -> e.getId().equals(tradingBoxItem.getPid())).findFirst().orElse(null);
|
|
|
- if (tradingBox == null) {
|
|
|
- failureHandling("3", boxDynamicsRecord, "未查到OW单据");
|
|
|
- return false;
|
|
|
- }
|
|
|
- tradingBoxItem.setPolOverdueBoxUseDays(overdueDays);
|
|
|
- tradingBoxItemList.add(tradingBoxItem);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- if (!putBoxItemsList.isEmpty()) {
|
|
|
- putBoxItemsService.saveOrUpdateBatch(putBoxItemsList);
|
|
|
- } else {
|
|
|
- putBoxItemsService.saveOrUpdateBatch(putBoxItems);
|
|
|
- }
|
|
|
- if (!tradingBoxItemList.isEmpty()) {
|
|
|
- tradingBoxItemService.saveOrUpdateBatch(tradingBoxItemList);
|
|
|
- } else {
|
|
|
- tradingBoxItemService.saveOrUpdateBatch(tradingBoxItemOldList);
|
|
|
- }
|
|
|
- List<Long> idList = billsList.stream().map(Bills::getId).collect(Collectors.toList());
|
|
|
- List<FeeCenter> feeCenterListAcc = new ArrayList<>();
|
|
|
- List<FeeCenter> feeCenterList = new ArrayList<>();
|
|
|
- if (!idList.isEmpty()) {
|
|
|
- feeCenterList = feeCenterService.list(new LambdaQueryWrapper<FeeCenter>()
|
|
|
- .eq(FeeCenter::getTenantId, AuthUtil.getTenantId())
|
|
|
- .eq(FeeCenter::getIsDeleted, 0)
|
|
|
- .in(FeeCenter::getPid, idList));
|
|
|
- }
|
|
|
- if (feeCenterList.isEmpty()) {
|
|
|
- feeCenterList = new ArrayList<>();
|
|
|
- }
|
|
|
- if (!feeCenterListD.isEmpty()) {
|
|
|
- feeCenterService.saveBatch(feeCenterListD);
|
|
|
- feeCenterList.addAll(feeCenterListD);
|
|
|
- feeCenterListAcc.addAll(feeCenterListD);
|
|
|
- }
|
|
|
- if (!feeCenterListC.isEmpty()) {
|
|
|
- feeCenterService.saveBatch(feeCenterListC);
|
|
|
- feeCenterList.addAll(feeCenterListC);
|
|
|
- feeCenterListAcc.addAll(feeCenterListC);
|
|
|
- List<Long> idListMh = feeCenterListC.stream().map(FeeCenter::getPid).filter(Objects::nonNull).distinct().collect(Collectors.toList());
|
|
|
- List<Bills> billsArrayList = billsList.stream().filter(e -> idListMh.contains(e.getId())).collect(Collectors.toList());
|
|
|
- if (!billsArrayList.isEmpty()) {
|
|
|
- List<Long> masterIdList = billsArrayList.stream().filter(e -> !"MM".equals(e.getBillType())).map(Bills::getMasterId)
|
|
|
- .filter(Objects::nonNull).distinct().collect(Collectors.toList());
|
|
|
- if (!masterIdList.isEmpty()) {
|
|
|
- List<Bills> billsList1 = billsMapper.selectList(new LambdaQueryWrapper<Bills>()
|
|
|
- .eq(Bills::getTenantId, AuthUtil.getTenantId())
|
|
|
- .eq(Bills::getIsDeleted, 0)
|
|
|
- .in(Bills::getMasterId, masterIdList));
|
|
|
- List<FeeCenter> feeCenterListM = feeCenterService.list(new LambdaQueryWrapper<FeeCenter>()
|
|
|
- .eq(FeeCenter::getTenantId, AuthUtil.getTenantId())
|
|
|
- .eq(FeeCenter::getIsDeleted, 0)
|
|
|
- .in(FeeCenter::getPid, masterIdList));
|
|
|
- for (Bills item : billsArrayList) {
|
|
|
- BCorps corps = bCorpsService.getOne(new LambdaQueryWrapper<BCorps>()
|
|
|
- .eq(BCorps::getTenantId, AuthUtil.getTenantId())
|
|
|
- .eq(BCorps::getIsDeleted, 0)
|
|
|
- .eq(BCorps::getEnName, item.getBranchName()));
|
|
|
- if (corps == null) {
|
|
|
- throw new RuntimeException("基础资料未查到往来单位" + item.getBranchName());
|
|
|
- }
|
|
|
- if (!billsList1.isEmpty()) {
|
|
|
- Bills billsHYCKM = billsList1.stream().filter(e -> e.getId().equals(item.getMasterId())).findFirst().orElse(null);
|
|
|
- if (billsHYCKM != null) {
|
|
|
- BigDecimal amount = feeCenterListC.stream().filter(e -> e.getPid().equals(item.getId()))
|
|
|
- .map(FeeCenter::getAmount).reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
- FeeCenter feeCenterD = new FeeCenter();
|
|
|
- feeCenterD.setBookingAgentId(billsHYCKM.getBookingAgentId());
|
|
|
- feeCenterD.setBookingAgentCnName(billsHYCKM.getBookingAgentCnName());
|
|
|
- feeCenterD.setBookingAgentEnName(billsHYCKM.getBookingAgentEnName());
|
|
|
- feeCenterD.setQuantityCntrDescr(billsHYCKM.getQuantityCntrDescr());
|
|
|
- feeCenterD.setBillBranchId(billsHYCKM.getBranchId());
|
|
|
- feeCenterD.setBillBranchName(billsHYCKM.getBranchName());
|
|
|
- feeCenterD.setTeu(billsHYCKM.getTeu());
|
|
|
- feeCenterD.setBranchId(billsHYCKM.getBranchId());
|
|
|
- feeCenterD.setBranchName(billsHYCKM.getBranchName());
|
|
|
- feeCenterD.setPid(billsHYCKM.getId());
|
|
|
- feeCenterD.setCntrNo(billsHYCKM.getQuantityCntrTypesDescr());
|
|
|
- feeCenterD.setBillNo(billsHYCKM.getBillNo());
|
|
|
- feeCenterD.setBusinessType(billsHYCKM.getBusinessType());
|
|
|
- feeCenterD.setBillType(billsHYCKM.getBillType());
|
|
|
- feeCenterD.setBillDate(billsHYCKM.getBillDate());
|
|
|
- feeCenterD.setBillCorpId(billsHYCKM.getCorpId());
|
|
|
- feeCenterD.setBillCorpCnName(billsHYCKM.getCorpCnName());
|
|
|
- feeCenterD.setBillCorpEnName(billsHYCKM.getCorpEnName());
|
|
|
- feeCenterD.setBillShortName(billsHYCKM.getShortName());
|
|
|
- feeCenterD.setLineId(billsHYCKM.getLineId());
|
|
|
- feeCenterD.setLineCnName(billsHYCKM.getLineCnName());
|
|
|
- feeCenterD.setLineEnName(billsHYCKM.getLineEnName());
|
|
|
- feeCenterD.setVesselId(billsHYCKM.getVesselId());
|
|
|
- feeCenterD.setVesselCnName(billsHYCKM.getVesselCnName());
|
|
|
- feeCenterD.setVesselEnName(billsHYCKM.getVesselEnName());
|
|
|
- feeCenterD.setVoyageNo(billsHYCKM.getVoyageNo());
|
|
|
- feeCenterD.setMblno(billsHYCKM.getMblno());
|
|
|
- feeCenterD.setHblno(item.getHblno());
|
|
|
- feeCenterD.setEtd(billsHYCKM.getEtd());
|
|
|
- feeCenterD.setEta(billsHYCKM.getEta());
|
|
|
- feeCenterD.setPolId(billsHYCKM.getPolId());
|
|
|
- feeCenterD.setPolCode(billsHYCKM.getPolCode());
|
|
|
- feeCenterD.setPolCnName(billsHYCKM.getPolCnName());
|
|
|
- feeCenterD.setPolEnName(billsHYCKM.getPolEnName());
|
|
|
- feeCenterD.setPodId(billsHYCKM.getPodId());
|
|
|
- feeCenterD.setPodCode(billsHYCKM.getPodCode());
|
|
|
- feeCenterD.setPodCnName(billsHYCKM.getPodCnName());
|
|
|
- feeCenterD.setPodEnName(billsHYCKM.getPodEnName());
|
|
|
- feeCenterD.setPaymode(billsHYCKM.getMpaymode());
|
|
|
- feeCenterD.setSort(1);
|
|
|
- feeCenterD.setFeeId(fees.getId());
|
|
|
- feeCenterD.setFeeCode(fees.getCode());
|
|
|
- feeCenterD.setFeeCnName(fees.getCnName());
|
|
|
- feeCenterD.setFeeEnName(fees.getEnName());
|
|
|
- feeCenterD.setUnitNo("JOB");
|
|
|
- feeCenterD.setCurCode(feeCenterListC.get(0).getCurCode());
|
|
|
- feeCenterD.setExrate(feeCenterListC.get(0).getExrate());
|
|
|
- feeCenterD.setDc("D");
|
|
|
- feeCenterD.setCorpType("国内直接客户");
|
|
|
-
|
|
|
- feeCenterD.setCorpId(corps.getId());
|
|
|
- feeCenterD.setCorpCnName(corps.getCnName());
|
|
|
- feeCenterD.setCorpEnName(corps.getEnName());
|
|
|
- feeCenterD.setShortName(corps.getShortName());
|
|
|
- feeCenterD.setGenerationCorpId(corps.getBookingAgentId());
|
|
|
- feeCenterD.setGenerationCorpCnName(corps.getBookingAgentCnName());
|
|
|
- feeCenterD.setGenerationCorpEnName(corps.getBookingAgentEnName());
|
|
|
- feeCenterD.setQuantity(new BigDecimal("1"));
|
|
|
- feeCenterD.setPrice(amount);
|
|
|
- feeCenterD.setAmount(amount);
|
|
|
- feeCenterD.setAmountLoc(amount.multiply(feeCenterD.getExrate()));
|
|
|
- feeCenterD.setUnsettledAmount(feeCenterD.getAmount());
|
|
|
- feeCenterD.setCreateUser(billsHYCKM.getOperatorId());
|
|
|
- feeCenterD.setCreateUserName(billsHYCKM.getOperatorName());
|
|
|
- feeCenterD.setCreateTime(new Date());
|
|
|
- feeCenterService.save(feeCenterD);
|
|
|
- feeCenterListAcc.add(feeCenterD);
|
|
|
- List<FeeCenter> feeCenterListMs = feeCenterListM.stream().filter(e -> e.getPid().equals(billsHYCKM.getId()))
|
|
|
- .collect(Collectors.toList());
|
|
|
- if (feeCenterListMs.isEmpty()) {
|
|
|
- feeCenterListMs = new ArrayList<>();
|
|
|
- }
|
|
|
- feeCenterListMs.add(feeCenterD);
|
|
|
- //对应海运进口单据所属公司本位币
|
|
|
- String exrateType = currencyUtils.standardCurrency(billsHYCKM.getBranchId());
|
|
|
- Bills billsAmount = costProfitCalculationService.costProfitCalculation(feeCenterListMs, exrateType);
|
|
|
- if (billsAmount != null) {
|
|
|
- billsHYCKM.setAccountStatus(billsAmount.getAccountStatus());
|
|
|
- billsHYCKM.setAmountDr(billsHYCKM.getAmountDr().add(billsAmount.getAmountDr()));
|
|
|
- billsHYCKM.setOceanFreightDr(billsHYCKM.getOceanFreightDr().add(billsAmount.getOceanFreightDr()));
|
|
|
- billsHYCKM.setAmountCr(billsHYCKM.getAmountCr().add(billsAmount.getAmountCr()));
|
|
|
- billsHYCKM.setOceanFreightCr(billsHYCKM.getOceanFreightCr().add(billsAmount.getOceanFreightCr()));
|
|
|
- billsHYCKM.setAmountProfit(billsHYCKM.getAmountProfit().add(billsAmount.getAmountProfit()));
|
|
|
- billsHYCKM.setOceanFreightProfit(billsHYCKM.getOceanFreightProfit().add(billsAmount.getOceanFreightProfit()));
|
|
|
- billsHYCKM.setAmountDrUsd(billsHYCKM.getAmountDrUsd().add(billsAmount.getAmountDrUsd()));
|
|
|
- billsHYCKM.setAmountCrUsd(billsHYCKM.getAmountCrUsd().add(billsAmount.getAmountCrUsd()));
|
|
|
- billsHYCKM.setAmountProfitUsd(billsHYCKM.getAmountProfitUsd().add(billsAmount.getAmountProfitUsd()));
|
|
|
- billsHYCKM.setAmountDrLoc(billsHYCKM.getAmountDrLoc().add(billsAmount.getAmountDrLoc()));
|
|
|
- billsHYCKM.setAmountCrLoc(billsHYCKM.getAmountCrLoc().add(billsAmount.getAmountCrLoc()));
|
|
|
- billsHYCKM.setAmountProfitLoc(billsHYCKM.getAmountProfitLoc().add(billsAmount.getAmountProfitLoc()));
|
|
|
- int version = StringUtil.isBlank(billsHYCKM.getVersion()) ? 1 : Integer.parseInt(billsHYCKM.getVersion());
|
|
|
- billsHYCKM.setVersion(String.valueOf(version + 1));
|
|
|
- billsMapper.updateById(billsHYCKM);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- if (!feeCenterListAcc.isEmpty()) {
|
|
|
- List<Bills> billsLists = costProfitCalculationService.costProfitCalculationBatch(feeCenterList, billsList);
|
|
|
- if (!billsLists.isEmpty()) {
|
|
|
- for (Bills item : billsLists) {
|
|
|
- int version = StringUtil.isBlank(item.getVersion()) ? 1 : Integer.parseInt(item.getVersion());
|
|
|
- item.setVersion(String.valueOf(version + 1));
|
|
|
- billsMapper.updateById(item);
|
|
|
- List<FeeCenter> feeCenters = feeCenterListAcc.stream().filter(e -> e.getPid().equals(item.getId()))
|
|
|
- .collect(Collectors.toList());
|
|
|
- String exrateType = currencyUtils.standardCurrency(item.getBranchId());
|
|
|
- Boolean status = this.generateAccBills(feeCenters, item, exrateType, boxDynamicsRecord, type);
|
|
|
- if (!status) {
|
|
|
- failureHandling("3", boxDynamicsRecord, "提单号" + item.getHblno() + "超期箱使费生成账单失败");
|
|
|
- return false;
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- return true;
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- /**
|
|
|
- * 无货返空-超期箱使费
|
|
|
- *
|
|
|
- * @param billsList 出口分单数据
|
|
|
- * @param tradingBoxList ow/自有箱单据
|
|
|
- * @param tradingBoxItemOldList ow/自有箱单据箱明细
|
|
|
- * @param putBoxItems 放箱号单据箱明细
|
|
|
- * @param putBoxList 放箱号单据
|
|
|
- * @param boxDynamicsRecord 进场记录
|
|
|
- * @param type 操作类型 1=excel导入直接提示 2=api记录并修改状态为失败 3=只记录
|
|
|
- */
|
|
|
- private Boolean countOverdueFeeWHFK(List<PutBox> putBoxList, List<TradingBox> tradingBoxList, List<TradingBoxItem> tradingBoxItemOldList,
|
|
|
- List<Bills> billsList, List<PutBoxItems> putBoxItems
|
|
|
- , BoxDynamicsRecord boxDynamicsRecord, String type) throws IOException {
|
|
|
- List<FeeCenter> feeCenterListD = new ArrayList<>();
|
|
|
- List<FeeCenter> feeCenterListC = new ArrayList<>();
|
|
|
- List<PutBoxItems> putBoxItemsList = new ArrayList<>();
|
|
|
- List<TradingBoxItem> tradingBoxItemList = new ArrayList<>();
|
|
|
- List<String> branchIdList = billsList.stream().map(Bills::getBranchId).distinct().collect(Collectors.toList());
|
|
|
- //超期标准
|
|
|
- List<StorageFees> storageFeesList = new ArrayList<>();
|
|
|
- if (!branchIdList.isEmpty()) {
|
|
|
- storageFeesList = storageFeesService.list(new LambdaQueryWrapper<StorageFees>()
|
|
|
- .eq(StorageFees::getTenantId, boxDynamicsRecord.getTenantId())
|
|
|
- .eq(StorageFees::getIsDeleted, 0)
|
|
|
- .in(StorageFees::getBranchId, branchIdList));
|
|
|
- }
|
|
|
- if (storageFeesList.isEmpty()) {
|
|
|
- failureHandling("3", boxDynamicsRecord, "请先维护基础资料-超期标准");
|
|
|
- return false;
|
|
|
- }
|
|
|
- List<Long> idList = storageFeesList.stream().map(StorageFees::getId).collect(Collectors.toList());
|
|
|
- //超期标准明细
|
|
|
- List<StorageFeesItems> storageFeesItemsList = storageFeesItemsService.list(new LambdaQueryWrapper<StorageFeesItems>()
|
|
|
- .eq(StorageFeesItems::getTenantId, boxDynamicsRecord.getTenantId())
|
|
|
- .eq(StorageFeesItems::getIsDeleted, 0)
|
|
|
- .in(StorageFeesItems::getPid, idList));
|
|
|
- if (storageFeesItemsList.isEmpty()) {
|
|
|
- failureHandling("3", boxDynamicsRecord, "请先维护基础资料-超期标准");
|
|
|
- return false;
|
|
|
- }
|
|
|
- //超期箱使费
|
|
|
- BFees fees = bFeesService.getOne(new LambdaQueryWrapper<BFees>()
|
|
|
- .eq(BFees::getTenantId, boxDynamicsRecord.getTenantId())
|
|
|
- .eq(BFees::getIsDeleted, 0)
|
|
|
- .eq(BFees::getCode, "CQXSF"));
|
|
|
- if (fees == null) {
|
|
|
- failureHandling("3", boxDynamicsRecord, "请先维护费用基础信息");
|
|
|
- return false;
|
|
|
- }
|
|
|
- String overdueProportion = sysClient.getParamService("overdue.proportion");
|
|
|
- if (ObjectUtils.isNull(overdueProportion) || "获取数据失败".equals(overdueProportion)) {
|
|
|
- failureHandling("3", boxDynamicsRecord, "超期箱使费比例");
|
|
|
- return false;
|
|
|
- }
|
|
|
- BCorps bCorps = bCorpsService.getOne(new LambdaQueryWrapper<BCorps>()
|
|
|
- .eq(BCorps::getTenantId, boxDynamicsRecord.getTenantId())
|
|
|
- .eq(BCorps::getIsDeleted, 0)
|
|
|
- .eq(BCorps::getCode, "ZBYF"));
|
|
|
- if (bCorps == null) {
|
|
|
- failureHandling("3", boxDynamicsRecord, "基础资料未查到编码为‘ZBYF’往来单位");
|
|
|
- return false;
|
|
|
- }
|
|
|
- for (PutBoxItems item : putBoxItems) {
|
|
|
- PutBox putBox = putBoxList.stream().filter(e -> e.getId().equals(item.getPid())).findFirst().orElse(null);
|
|
|
- if (putBox == null) {
|
|
|
- failureHandling("3", boxDynamicsRecord, "未查到放箱号数据");
|
|
|
- return false;
|
|
|
- }
|
|
|
- //查找OW明细提单号对应海运进出口单据
|
|
|
- Bills bills = billsList.stream().filter(e -> e.getHblno().equals(item.getTemporaryHblno()))
|
|
|
- .findFirst().orElse(null);
|
|
|
- if (bills == null) {
|
|
|
- failureHandling("3", boxDynamicsRecord, "海运出口提单号:" + item.getHblno() + "未查到");
|
|
|
- return false;
|
|
|
- }
|
|
|
- //对应海运进出口单据所属公司本位币
|
|
|
- String exrateType = currencyUtils.standardCurrency(bills.getBranchId());
|
|
|
- //对应海运进出口单据所属公司所有币别
|
|
|
- List<BCurExrate> curExrateList = currencyUtils.obtainRate(new Date(), "1", bills.getBranchId());
|
|
|
- //起运港超期天数
|
|
|
- if (ObjectUtils.isNotNull(item.getPolReturnDate()) && ObjectUtils.isNotNull(item.getPolStationEmptyContainerExitDate())) {
|
|
|
- //所属公司具体超期标准
|
|
|
- StorageFees storageFees = this.getStorageFees(storageFeesList, bills, "1");
|
|
|
- if (storageFees == null) {
|
|
|
- failureHandling("3", boxDynamicsRecord, "请先维护基础资料-超期标准");
|
|
|
- return false;
|
|
|
- }
|
|
|
- //所属公司具体超期标准明细
|
|
|
- List<StorageFeesItems> storageFeesItems = storageFeesItemsList.stream().filter(e -> e.getPid().equals(storageFees.getId()))
|
|
|
- .collect(Collectors.toList());
|
|
|
- if (storageFeesItems.isEmpty()) {
|
|
|
- failureHandling("3", boxDynamicsRecord, "请先维护基础资料-超期标准");
|
|
|
- return false;
|
|
|
- }
|
|
|
- LocalDateTime ldt1 = item.getPolReturnDate().toInstant().atZone(ZoneId.systemDefault()).toLocalDateTime();
|
|
|
- LocalDateTime ldt2 = item.getPolStationEmptyContainerExitDate().toInstant().atZone(ZoneId.systemDefault()).toLocalDateTime();
|
|
|
- int overdueDays = (int) ChronoUnit.DAYS.between(ldt1, ldt2);
|
|
|
- if (overdueDays > 0) {
|
|
|
- FeeCenter feeCenter = this.addFeeCenter(item, bills, fees, storageFeesItems, curExrateList, overdueDays, exrateType);
|
|
|
- if (feeCenter != null) {
|
|
|
- FeeCenter feeCenterC = new FeeCenter();
|
|
|
- BeanUtil.copyProperties(feeCenter, feeCenterC);
|
|
|
- feeCenterC.setPid(bills.getId());
|
|
|
- feeCenterC.setDc("C");
|
|
|
- feeCenterC.setCorpType("国内直接客户");
|
|
|
- feeCenterC.setCorpId(bCorps.getId());
|
|
|
- feeCenterC.setCorpCnName(bCorps.getCnName());
|
|
|
- feeCenterC.setCorpEnName(bCorps.getEnName());
|
|
|
- feeCenterC.setShortName(bCorps.getShortName());
|
|
|
- feeCenterC.setPrice(feeCenterC.getPrice().multiply(new BigDecimal(overdueProportion))
|
|
|
- .divide(new BigDecimal("100"), 2, RoundingMode.HALF_UP).setScale(2, RoundingMode.HALF_UP));
|
|
|
- feeCenterC.setAmount(feeCenterC.getQuantity().multiply(feeCenterC.getPrice()));
|
|
|
- feeCenterC.setAmountLoc(feeCenterC.getAmount().multiply(feeCenter.getExrate()));
|
|
|
- feeCenterC.setUnsettledAmount(feeCenterC.getAmount());
|
|
|
- if (feeCenterListD.isEmpty()) {
|
|
|
- feeCenterListD.add(feeCenter);
|
|
|
- feeCenterListC.add(feeCenterC);
|
|
|
- } else {
|
|
|
- FeeCenter feeCenterD = feeCenterListD.stream().filter(e -> e.getPid().equals(feeCenter.getPid()) &&
|
|
|
- e.getUnitNo().equals(feeCenter.getUnitNo())).findFirst().orElse(null);
|
|
|
- if (feeCenterD != null) {
|
|
|
- feeCenterD.setQuantity(feeCenterD.getQuantity().add(new BigDecimal("1")));
|
|
|
- feeCenterD.setAmount(feeCenterD.getQuantity().multiply(feeCenterD.getPrice()));
|
|
|
- feeCenterD.setAmountLoc(feeCenterD.getAmount().multiply(feeCenterD.getExrate()));
|
|
|
- feeCenterD.setUnsettledAmount(feeCenterD.getAmount());
|
|
|
- FeeCenter feeCentersC = feeCenterListC.stream().filter(e -> e.getPid().equals(feeCenterC.getPid()) &&
|
|
|
- e.getUnitNo().equals(feeCenterC.getUnitNo())).findFirst().orElse(null);
|
|
|
- if (feeCentersC != null) {
|
|
|
- feeCentersC.setQuantity(feeCentersC.getQuantity().add(new BigDecimal("1")));
|
|
|
- feeCentersC.setAmount(feeCentersC.getQuantity().multiply(feeCentersC.getPrice()));
|
|
|
- feeCentersC.setAmountLoc(feeCentersC.getAmount().multiply(feeCentersC.getExrate()));
|
|
|
- feeCentersC.setUnsettledAmount(feeCentersC.getAmount());
|
|
|
- }
|
|
|
- } else {
|
|
|
- feeCenterListD.add(feeCenter);
|
|
|
- feeCenterListC.add(feeCenterC);
|
|
|
- }
|
|
|
- }
|
|
|
- item.setPolOverdueBoxUseDays(Integer.parseInt(overdueDays + ""));
|
|
|
- }
|
|
|
- putBoxItemsList.add(item);
|
|
|
- if ("OW(拿),OW(放)".contains(putBox.getBoxClass())) {
|
|
|
- TradingBoxItem tradingBoxItem = tradingBoxItemOldList.stream().filter(e -> e.getCode().equals(item.getBoxCode())).findFirst().orElse(null);
|
|
|
- if (tradingBoxItem == null) {
|
|
|
- failureHandling("3", boxDynamicsRecord, "未查到OW单据明细箱号");
|
|
|
- return false;
|
|
|
- }
|
|
|
- //查找OW明细对应主表
|
|
|
- TradingBox tradingBox = tradingBoxList.stream().filter(e -> e.getId().equals(tradingBoxItem.getPid())).findFirst().orElse(null);
|
|
|
- if (tradingBox == null) {
|
|
|
- failureHandling("3", boxDynamicsRecord, "未查到OW单据");
|
|
|
- return false;
|
|
|
- }
|
|
|
- tradingBoxItem.setPolOverdueBoxUseDays(overdueDays);
|
|
|
- tradingBoxItemList.add(tradingBoxItem);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- if (!putBoxItemsList.isEmpty()) {
|
|
|
- putBoxItemsService.saveOrUpdateBatch(putBoxItemsList);
|
|
|
- } else {
|
|
|
- putBoxItemsService.saveOrUpdateBatch(putBoxItems);
|
|
|
- }
|
|
|
- if (!tradingBoxItemList.isEmpty()) {
|
|
|
- tradingBoxItemService.saveOrUpdateBatch(tradingBoxItemList);
|
|
|
- } else {
|
|
|
- tradingBoxItemService.saveOrUpdateBatch(tradingBoxItemOldList);
|
|
|
- }
|
|
|
- List<FeeCenter> feeCenterList = new ArrayList<>();
|
|
|
- if (!feeCenterListD.isEmpty()) {
|
|
|
- feeCenterService.saveBatch(feeCenterListD);
|
|
|
- feeCenterList.addAll(feeCenterListD);
|
|
|
- }
|
|
|
- if (!feeCenterListC.isEmpty()) {
|
|
|
- feeCenterService.saveBatch(feeCenterListC);
|
|
|
- feeCenterList.addAll(feeCenterListC);
|
|
|
- }
|
|
|
- if (!feeCenterList.isEmpty()) {
|
|
|
- List<Bills> billsLists = costProfitCalculationService.costProfitCalculationBatch(feeCenterList, billsList);
|
|
|
- if (!billsLists.isEmpty()) {
|
|
|
- for (Bills item : billsLists) {
|
|
|
- int version = StringUtil.isBlank(item.getVersion()) ? 1 : Integer.parseInt(item.getVersion());
|
|
|
- item.setVersion(String.valueOf(version + 1));
|
|
|
- billsMapper.updateById(item);
|
|
|
- List<FeeCenter> feeCenters = feeCenterList.stream().filter(e -> e.getPid().equals(item.getId()))
|
|
|
- .collect(Collectors.toList());
|
|
|
- String exrateType = currencyUtils.standardCurrency(item.getBranchId());
|
|
|
- Boolean status = this.generateAccBills(feeCenters, item, exrateType, boxDynamicsRecord, type);
|
|
|
- if (!status) {
|
|
|
- failureHandling("3", boxDynamicsRecord, "提单号" + item.getHblno() + "超期箱使费生成账单失败");
|
|
|
- return false;
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- return true;
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 获取具体超期箱使费标准
|
|
|
- *
|
|
|
- * @param storageFeesList 超期箱使费标准数据
|
|
|
- * @param bills 海运进出口单据
|
|
|
- * @param type 操作类型 1=起运港 2=目的港
|
|
|
- */
|
|
|
- private StorageFees getStorageFees(List<StorageFees> storageFeesList, Bills bills, String type) {
|
|
|
- StorageFees storageFees;
|
|
|
- String portId;
|
|
|
- if ("1".equals(type)) {
|
|
|
- portId = bills.getPolId() + "";
|
|
|
- } else {
|
|
|
- portId = bills.getPodId() + "";
|
|
|
- }
|
|
|
- if ("SE".equals(bills.getBusinessType())) {
|
|
|
- storageFees = storageFeesList.stream().filter(e -> e.getBranchId().equals(bills.getBranchId()) &&
|
|
|
- "出口超期箱".equals(e.getType()) && e.getPortId().contains(portId)).findFirst().orElse(null);
|
|
|
- } else if ("SI".equals(bills.getBusinessType())) {
|
|
|
- storageFees = storageFeesList.stream().filter(e -> e.getBranchId().equals(bills.getBranchId()) &&
|
|
|
- "进口超期箱".equals(e.getType()) && e.getPortId().contains(portId)).findFirst().orElse(null);
|
|
|
- } else {
|
|
|
- storageFees = storageFeesList.stream().filter(e -> e.getBranchId().equals(bills.getBranchId()) &&
|
|
|
- "退关、无货返空箱".equals(e.getType()) && e.getPortId().contains(portId)).findFirst().orElse(null);
|
|
|
- }
|
|
|
- return storageFees;
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 超期箱使费-费用中心数据拼接
|
|
|
- *
|
|
|
- * @param item 放箱号箱明细
|
|
|
- * @param bills 进出口单据
|
|
|
- * @param fees 费用信息
|
|
|
- * @param storageFeesItems 超期箱使费规则明细
|
|
|
- * @param curExrateList 汇率明细
|
|
|
- * @param overdueDays 超期天数
|
|
|
- * @param exrateType 本币币别
|
|
|
- */
|
|
|
- private FeeCenter addFeeCenter(PutBoxItems item, Bills bills, BFees fees,
|
|
|
- List<StorageFeesItems> storageFeesItems, List<BCurExrate> curExrateList,
|
|
|
- int overdueDays, String exrateType) {
|
|
|
- FeeCenter feeCenter = new FeeCenter();
|
|
|
- feeCenter.setBillType(bills.getBillType());
|
|
|
- feeCenter.setCorpType("国内同行及代理");
|
|
|
- feeCenter.setCorpId(bills.getCorpId());
|
|
|
- feeCenter.setCorpCnName(bills.getCorpCnName());
|
|
|
- feeCenter.setCorpEnName(bills.getCorpEnName());
|
|
|
- feeCenter.setShortName(bills.getShortName());
|
|
|
- feeCenter.setCreateTime(new Date());
|
|
|
- feeCenter.setCreateUser(bills.getOperatorId());
|
|
|
- feeCenter.setCreateUserName(bills.getOperatorName());
|
|
|
- feeCenter.setPaymode(bills.getMpaymode());
|
|
|
- feeCenter.setPid(bills.getId());
|
|
|
- feeCenter.setDc("D");
|
|
|
- feeCenter.setFeeId(fees.getId());
|
|
|
- feeCenter.setFeeCode(fees.getCode());
|
|
|
- feeCenter.setFeeCnName(fees.getCnName());
|
|
|
- feeCenter.setFeeEnName(fees.getEnName());
|
|
|
- feeCenter.setCurCode(storageFeesItems.get(0).getCurCode());
|
|
|
- feeCenter.setCntrNo(item.getBoxCode());
|
|
|
- feeCenter.setUnitNo(item.getBoxType());
|
|
|
- //计算天数
|
|
|
- int days = overdueDays + 1;
|
|
|
- int earlySumDays = 0;
|
|
|
- String text = "";
|
|
|
- int dayLength;
|
|
|
- BigDecimal amount = new BigDecimal("0.00");
|
|
|
- int overdueBoxUseDays = 0;
|
|
|
- for (StorageFeesItems term : storageFeesItems) {
|
|
|
- BigDecimal rate;
|
|
|
- //根据箱型获取具体超期单价
|
|
|
- if ("20GP".equals(item.getBoxType())) {
|
|
|
- rate = term.getPrice20gp();
|
|
|
- } else if ("40HC".equals(item.getBoxType())) {
|
|
|
- rate = term.getPrice40hc();
|
|
|
- } else if ("40GP".equals(item.getBoxType())) {
|
|
|
- rate = term.getPrice40gp();
|
|
|
- } else {
|
|
|
- continue;
|
|
|
- }
|
|
|
- dayLength = term.getEndDay() - term.getStartDay() + 1;
|
|
|
- if (new BigDecimal("0.00").compareTo(rate) == 0) {
|
|
|
- overdueBoxUseDays = dayLength;
|
|
|
- }
|
|
|
- if (earlySumDays >= dayLength) {
|
|
|
- earlySumDays -= dayLength;
|
|
|
- continue;
|
|
|
- }
|
|
|
- if (earlySumDays + days > dayLength) {
|
|
|
- int tempDays = dayLength - earlySumDays;
|
|
|
- earlySumDays = 0;
|
|
|
- days -= tempDays;
|
|
|
- BigDecimal calculate = rate.multiply(new BigDecimal(tempDays + ""));
|
|
|
- amount = amount.add(calculate);
|
|
|
- text = text + tempDays + "天*" + rate + "元=" + calculate + "元,";
|
|
|
- } else {
|
|
|
- BigDecimal calculate = rate.multiply(new BigDecimal(days + ""));
|
|
|
- amount = amount.add(calculate);
|
|
|
- text = text + days + "天*" + rate + "元=" + calculate + "元";
|
|
|
- days = 0;
|
|
|
- break;
|
|
|
- }
|
|
|
- }
|
|
|
- feeCenter.setOverdueBoxUseDays(overdueBoxUseDays);
|
|
|
- if (days != 0) {
|
|
|
- if ("20GP".equals(item.getBoxType())) {
|
|
|
- BigDecimal calculate = storageFeesItems.get(storageFeesItems.size() - 1).getPrice20gp().multiply(new BigDecimal(days + ""));
|
|
|
- amount = amount.add(calculate);
|
|
|
- text = text + "超出费用:" + days + "天*" + storageFeesItems.get(storageFeesItems.size() - 1).getPrice20gp() + "元=" + calculate + "元,";
|
|
|
- } else if ("40HC".equals(item.getBoxType())) {
|
|
|
- BigDecimal calculate = storageFeesItems.get(storageFeesItems.size() - 1).getPrice40hc().multiply(new BigDecimal(days + ""));
|
|
|
- amount = amount.add(calculate);
|
|
|
- text = text + "超出费用:" + days + "天*" + storageFeesItems.get(storageFeesItems.size() - 1).getPrice40hc() + "元=" + calculate + "元,";
|
|
|
- } else if ("40GP".equals(item.getBoxType())) {
|
|
|
- BigDecimal calculate = storageFeesItems.get(storageFeesItems.size() - 1).getPrice40gp().multiply(new BigDecimal(days + ""));
|
|
|
- amount = amount.add(calculate);
|
|
|
- text = text + "超出费用:" + days + "天*" + storageFeesItems.get(storageFeesItems.size() - 1).getPrice40gp() + "元=" + calculate + "元,";
|
|
|
- } else {
|
|
|
- return null;
|
|
|
- }
|
|
|
- }
|
|
|
- if (exrateType.equals(feeCenter.getCurCode())) {
|
|
|
- feeCenter.setExrate(new BigDecimal("1.00"));
|
|
|
- } else {
|
|
|
- feeCenter.setExrate(currencyUtils.obtainExrate("C", curExrateList, feeCenter.getCurCode(), "1"));
|
|
|
- }
|
|
|
- if (new BigDecimal("0.00").compareTo(amount) == 0) {
|
|
|
- return null;
|
|
|
- }
|
|
|
- feeCenter.setAmount(amount);
|
|
|
- feeCenter.setAmountLoc(amount.multiply(feeCenter.getExrate()));
|
|
|
- feeCenter.setUnsettledAmount(amount);
|
|
|
- feeCenter.setPrice(amount);
|
|
|
- feeCenter.setRemarks(text);
|
|
|
-// int quantity = bills.getQuantityV20()+bills.getQuantityV40()+bills.getQuantityV45()+bills.getQuantityV48()+bills.getQuantityV40hc();
|
|
|
- feeCenter.setQuantity(new BigDecimal("1"));
|
|
|
- feeCenter.setBillNo(bills.getBillNo());
|
|
|
- feeCenter.setBusinessType(bills.getBusinessType());
|
|
|
- feeCenter.setBillDate(bills.getBillDate());
|
|
|
- feeCenter.setBillCorpId(bills.getCorpId());
|
|
|
- feeCenter.setBillCorpCnName(bills.getCorpCnName());
|
|
|
- feeCenter.setBillCorpEnName(bills.getCorpEnName());
|
|
|
- feeCenter.setBillShortName(bills.getCorpShortName());
|
|
|
- feeCenter.setMblno(bills.getMblno());
|
|
|
- feeCenter.setHblno(bills.getHblno());
|
|
|
- feeCenter.setPolId(bills.getPolId());
|
|
|
- feeCenter.setPolCode(bills.getPolCode());
|
|
|
- feeCenter.setPolCnName(bills.getPolCnName());
|
|
|
- feeCenter.setPolEnName(bills.getPolEnName());
|
|
|
- feeCenter.setAutomaticGenerated("1");
|
|
|
- feeCenter.setBranchId(bills.getBranchId());
|
|
|
- feeCenter.setBranchName(bills.getBranchName());
|
|
|
- feeCenter.setVersion("1");
|
|
|
- return feeCenter;
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 客户还箱-目的港进口超期箱使费
|
|
|
- *
|
|
|
- * @param billsHYJK 进口分单
|
|
|
- * @param tradingBoxList ow/自有箱单据
|
|
|
- * @param tradingBoxItemOldList ow/自有箱单据箱明细
|
|
|
- * @param putBoxItemsOldList 放箱号单据箱明细
|
|
|
- * @param putBoxList 放箱号单据
|
|
|
- * @param boxDynamicsRecord 进场记录
|
|
|
- * @param type 操作类型 1=excel导入直接提示 2=api记录并修改状态为失败 3=只记录
|
|
|
- */
|
|
|
- private Boolean countOverdueFeeV1(Bills billsHYJK, List<TradingBox> tradingBoxList,
|
|
|
- List<TradingBoxItem> tradingBoxItemOldList, List<PutBoxItems> putBoxItemsOldList,
|
|
|
- List<PutBox> putBoxList, BoxDynamicsRecord boxDynamicsRecord, String type) throws IOException {
|
|
|
- List<FeeCenter> feeCenterListD = new ArrayList<>();
|
|
|
- List<FeeCenter> feeCenterListC = new ArrayList<>();
|
|
|
- List<PutBoxItems> putBoxItemsList = new ArrayList<>();
|
|
|
- List<TradingBoxItem> tradingBoxItemList = new ArrayList<>();
|
|
|
- //超期标准
|
|
|
- List<StorageFees> storageFeesList = storageFeesService.list(new LambdaQueryWrapper<StorageFees>()
|
|
|
- .eq(StorageFees::getTenantId, boxDynamicsRecord.getTenantId())
|
|
|
- .eq(StorageFees::getIsDeleted, 0)
|
|
|
- .eq(StorageFees::getBranchId, billsHYJK.getBranchId()));
|
|
|
- if (storageFeesList.isEmpty()) {
|
|
|
- failureHandling("3", boxDynamicsRecord, "请先维护基础资料-超期标准");
|
|
|
- return false;
|
|
|
- }
|
|
|
- List<Long> idList = storageFeesList.stream().map(StorageFees::getId).collect(Collectors.toList());
|
|
|
- //超期标准明细
|
|
|
- List<StorageFeesItems> storageFeesItemsList = storageFeesItemsService.list(new LambdaQueryWrapper<StorageFeesItems>()
|
|
|
- .eq(StorageFeesItems::getTenantId, boxDynamicsRecord.getTenantId())
|
|
|
- .eq(StorageFeesItems::getIsDeleted, 0)
|
|
|
- .in(StorageFeesItems::getPid, idList));
|
|
|
- if (storageFeesItemsList.isEmpty()) {
|
|
|
- failureHandling("3", boxDynamicsRecord, "请先维护基础资料-超期标准");
|
|
|
- return false;
|
|
|
- }
|
|
|
- //超期箱使费
|
|
|
- BFees fees = bFeesService.getOne(new LambdaQueryWrapper<BFees>()
|
|
|
- .eq(BFees::getTenantId, boxDynamicsRecord.getTenantId())
|
|
|
- .eq(BFees::getIsDeleted, 0)
|
|
|
- .eq(BFees::getCode, "CQXSF"));
|
|
|
- if (fees == null) {
|
|
|
- failureHandling("3", boxDynamicsRecord, "请先维护费用基础信息");
|
|
|
- return false;
|
|
|
- }
|
|
|
- String overdueProportion = sysClient.getParamService("overdue.proportion");
|
|
|
- if (ObjectUtils.isNull(overdueProportion) || "获取数据失败".equals(overdueProportion)) {
|
|
|
- failureHandling("3", boxDynamicsRecord, "超期箱使费比例");
|
|
|
- return false;
|
|
|
- }
|
|
|
- BCorps bCorps = bCorpsService.getOne(new LambdaQueryWrapper<BCorps>()
|
|
|
- .eq(BCorps::getTenantId, boxDynamicsRecord.getTenantId())
|
|
|
- .eq(BCorps::getIsDeleted, 0)
|
|
|
- .eq(BCorps::getCode, "ZBYF"));
|
|
|
- if (bCorps == null) {
|
|
|
- failureHandling("3", boxDynamicsRecord, "基础资料未查到编码为‘ZBYF’往来单位");
|
|
|
- return false;
|
|
|
- }
|
|
|
- //对应海运进出口单据所属公司本位币
|
|
|
- String exrateType = currencyUtils.standardCurrency(billsHYJK.getBranchId());
|
|
|
- for (PutBoxItems item : putBoxItemsOldList) {
|
|
|
- PutBox putBox = putBoxList.stream().filter(e -> e.getId().equals(item.getPid())).findFirst().orElse(null);
|
|
|
- if (putBox == null) {
|
|
|
- failureHandling("3", boxDynamicsRecord, "未查到放箱号数据");
|
|
|
- return false;
|
|
|
- }
|
|
|
-
|
|
|
- //对应海运进出口单据所属公司所有币别
|
|
|
- List<BCurExrate> curExrateList = currencyUtils.obtainRate(new Date(), "1", billsHYJK.getBranchId());
|
|
|
- //目的港超期天数
|
|
|
- if (ObjectUtils.isNotNull(item.getPodEmptyContainerReturnDate()) &&
|
|
|
- ObjectUtils.isNotNull(billsHYJK.getActualEta())) {
|
|
|
- //所属公司具体超期标准
|
|
|
- StorageFees storageFees = this.getStorageFees(storageFeesList, billsHYJK, "2");
|
|
|
- if (storageFees == null) {
|
|
|
- failureHandling("3", boxDynamicsRecord, "请先维护基础资料-超期标准");
|
|
|
- return false;
|
|
|
- }
|
|
|
- //所属公司具体超期标准明细
|
|
|
- List<StorageFeesItems> storageFeesItems = storageFeesItemsList.stream().filter(e -> e.getPid().equals(storageFees.getId()))
|
|
|
- .collect(Collectors.toList());
|
|
|
- if (storageFeesItems.isEmpty()) {
|
|
|
- failureHandling("3", boxDynamicsRecord, "请先维护基础资料-超期标准");
|
|
|
- return false;
|
|
|
- }
|
|
|
- LocalDateTime ldt1 = item.getPodEmptyContainerReturnDate().toInstant().atZone(ZoneId.systemDefault()).toLocalDateTime();
|
|
|
- LocalDateTime ldt2 = billsHYJK.getActualEta().toInstant().atZone(ZoneId.systemDefault()).toLocalDateTime();
|
|
|
- int overdueDays = (int) ChronoUnit.DAYS.between(ldt2, ldt1);
|
|
|
- //超期天数
|
|
|
- if (overdueDays > 0) {
|
|
|
- FeeCenter feeCenter = this.addFeeCenter(item, billsHYJK, fees, storageFeesItems, curExrateList, overdueDays, exrateType);
|
|
|
- if (feeCenter != null) {
|
|
|
- FeeCenter feeCenterC = new FeeCenter();
|
|
|
- BeanUtil.copyProperties(feeCenter, feeCenterC);
|
|
|
- feeCenterC.setDc("C");
|
|
|
- feeCenterC.setCorpType("国内直接客户");
|
|
|
- feeCenterC.setCorpId(bCorps.getId());
|
|
|
- feeCenterC.setCorpCnName(bCorps.getCnName());
|
|
|
- feeCenterC.setCorpEnName(bCorps.getEnName());
|
|
|
- feeCenterC.setShortName(bCorps.getShortName());
|
|
|
- feeCenterC.setPrice(feeCenterC.getPrice().multiply(new BigDecimal(overdueProportion))
|
|
|
- .divide(new BigDecimal("100"), 2, RoundingMode.HALF_UP).setScale(2, RoundingMode.HALF_UP));
|
|
|
- feeCenterC.setAmount(feeCenterC.getQuantity().multiply(feeCenterC.getPrice()));
|
|
|
- feeCenterC.setAmountLoc(feeCenterC.getAmount().multiply(feeCenter.getExrate()));
|
|
|
- feeCenterC.setUnsettledAmount(feeCenterC.getAmount());
|
|
|
-
|
|
|
- if (feeCenterListD.isEmpty()) {
|
|
|
- feeCenterListD.add(feeCenter);
|
|
|
- feeCenterListC.add(feeCenterC);
|
|
|
- } else {
|
|
|
- FeeCenter feeCenterD = feeCenterListD.stream().filter(e -> e.getPid().equals(feeCenter.getPid()) &&
|
|
|
- e.getUnitNo().equals(feeCenter.getUnitNo())).findFirst().orElse(null);
|
|
|
- if (feeCenterD != null) {
|
|
|
- feeCenterD.setQuantity(feeCenterD.getQuantity().add(new BigDecimal("1")));
|
|
|
- feeCenterD.setAmount(feeCenterD.getQuantity().multiply(feeCenterD.getPrice()));
|
|
|
- feeCenterD.setAmountLoc(feeCenterD.getAmount().multiply(feeCenterD.getExrate()));
|
|
|
- feeCenterD.setUnsettledAmount(feeCenterD.getAmount());
|
|
|
- FeeCenter feeCentersC = feeCenterListC.stream().filter(e -> e.getPid().equals(feeCenterC.getPid()) &&
|
|
|
- e.getUnitNo().equals(feeCenterC.getUnitNo())).findFirst().orElse(null);
|
|
|
- if (feeCentersC != null) {
|
|
|
- feeCentersC.setQuantity(feeCentersC.getQuantity().add(new BigDecimal("1")));
|
|
|
- feeCentersC.setAmount(feeCentersC.getQuantity().multiply(feeCentersC.getPrice()));
|
|
|
- feeCentersC.setAmountLoc(feeCentersC.getAmount().multiply(feeCentersC.getExrate()));
|
|
|
- feeCentersC.setUnsettledAmount(feeCentersC.getAmount());
|
|
|
- }
|
|
|
- } else {
|
|
|
- feeCenterListD.add(feeCenter);
|
|
|
- feeCenterListC.add(feeCenterC);
|
|
|
- }
|
|
|
- }
|
|
|
- item.setPodFreeBoxUseDays(feeCenter.getOverdueBoxUseDays());
|
|
|
- }
|
|
|
- putBoxItemsList.add(item);
|
|
|
- if ("OW(拿),OW(放)".contains(putBox.getBoxClass())) {
|
|
|
- TradingBoxItem tradingBoxItem = tradingBoxItemOldList.stream().filter(e -> e.getCode().equals(item.getBoxCode())).findFirst().orElse(null);
|
|
|
- if (tradingBoxItem == null) {
|
|
|
- failureHandling("3", boxDynamicsRecord, "未查到OW单据明细箱号");
|
|
|
- return false;
|
|
|
- }
|
|
|
- //查找OW明细对应主表
|
|
|
- TradingBox tradingBox = tradingBoxList.stream().filter(e -> e.getId().equals(tradingBoxItem.getPid())).findFirst().orElse(null);
|
|
|
- if (tradingBox == null) {
|
|
|
- failureHandling("3", boxDynamicsRecord, "未查到OW单据");
|
|
|
- return false;
|
|
|
- }
|
|
|
- tradingBoxItem.setPodBoxUseDays(overdueDays);
|
|
|
- tradingBoxItemList.add(tradingBoxItem);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- if (!putBoxItemsList.isEmpty()) {
|
|
|
- putBoxItemsService.saveOrUpdateBatch(putBoxItemsList);
|
|
|
- } else {
|
|
|
- putBoxItemsService.saveOrUpdateBatch(putBoxItemsOldList);
|
|
|
- }
|
|
|
- if (!tradingBoxItemList.isEmpty()) {
|
|
|
- tradingBoxItemService.saveOrUpdateBatch(tradingBoxItemList);
|
|
|
- } else {
|
|
|
- tradingBoxItemService.saveOrUpdateBatch(tradingBoxItemOldList);
|
|
|
- }
|
|
|
- List<FeeCenter> feeCenterList = feeCenterService.list(new LambdaQueryWrapper<FeeCenter>()
|
|
|
- .eq(FeeCenter::getTenantId, AuthUtil.getTenantId())
|
|
|
- .eq(FeeCenter::getIsDeleted, 0)
|
|
|
- .eq(FeeCenter::getPid, billsHYJK.getId()));
|
|
|
- List<FeeCenter> feeCenterListAcc = new ArrayList<>();
|
|
|
- if (feeCenterList.isEmpty()) {
|
|
|
- feeCenterList = new ArrayList<>();
|
|
|
- }
|
|
|
- if (!feeCenterListD.isEmpty()) {
|
|
|
- feeCenterService.saveBatch(feeCenterListD);
|
|
|
- feeCenterList.addAll(feeCenterListD);
|
|
|
- feeCenterListAcc.addAll(feeCenterListD);
|
|
|
- }
|
|
|
- if (!feeCenterListC.isEmpty()) {
|
|
|
- feeCenterService.saveBatch(feeCenterListC);
|
|
|
- feeCenterList.addAll(feeCenterListC);
|
|
|
- feeCenterListAcc.addAll(feeCenterListC);
|
|
|
- if ("MH".equals(billsHYJK.getBillType())) {
|
|
|
- BigDecimal amount = feeCenterListC.stream().map(FeeCenter::getAmount).reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
- Bills bills = billsMapper.selectById(billsHYJK.getMasterId());
|
|
|
- FeeCenter feeCenterD = new FeeCenter();
|
|
|
- feeCenterD.setBookingAgentId(bills.getBookingAgentId());
|
|
|
- feeCenterD.setBookingAgentCnName(bills.getBookingAgentCnName());
|
|
|
- feeCenterD.setBookingAgentEnName(bills.getBookingAgentEnName());
|
|
|
- feeCenterD.setQuantityCntrDescr(bills.getQuantityCntrDescr());
|
|
|
- feeCenterD.setBillBranchId(bills.getBranchId());
|
|
|
- feeCenterD.setBillBranchName(bills.getBranchName());
|
|
|
- feeCenterD.setTeu(bills.getTeu());
|
|
|
- feeCenterD.setBranchId(bills.getBranchId());
|
|
|
- feeCenterD.setBranchName(bills.getBranchName());
|
|
|
- feeCenterD.setPid(bills.getId());
|
|
|
- feeCenterD.setCntrNo(bills.getQuantityCntrTypesDescr());
|
|
|
- feeCenterD.setBillNo(bills.getBillNo());
|
|
|
- feeCenterD.setBusinessType(bills.getBusinessType());
|
|
|
- feeCenterD.setBillType(bills.getBillType());
|
|
|
- feeCenterD.setBillDate(bills.getBillDate());
|
|
|
- feeCenterD.setBillCorpId(bills.getCorpId());
|
|
|
- feeCenterD.setBillCorpCnName(bills.getCorpCnName());
|
|
|
- feeCenterD.setBillCorpEnName(bills.getCorpEnName());
|
|
|
- feeCenterD.setBillShortName(bills.getShortName());
|
|
|
- feeCenterD.setLineId(bills.getLineId());
|
|
|
- feeCenterD.setLineCnName(bills.getLineCnName());
|
|
|
- feeCenterD.setLineEnName(bills.getLineEnName());
|
|
|
- feeCenterD.setVesselId(bills.getVesselId());
|
|
|
- feeCenterD.setVesselCnName(bills.getVesselCnName());
|
|
|
- feeCenterD.setVesselEnName(bills.getVesselEnName());
|
|
|
- feeCenterD.setVoyageNo(bills.getVoyageNo());
|
|
|
- feeCenterD.setMblno(bills.getMblno());
|
|
|
- feeCenterD.setHblno(billsHYJK.getHblno());
|
|
|
- feeCenterD.setEtd(bills.getEtd());
|
|
|
- feeCenterD.setEta(bills.getEta());
|
|
|
- feeCenterD.setPolId(bills.getPolId());
|
|
|
- feeCenterD.setPolCode(bills.getPolCode());
|
|
|
- feeCenterD.setPolCnName(bills.getPolCnName());
|
|
|
- feeCenterD.setPolEnName(bills.getPolEnName());
|
|
|
- feeCenterD.setPodId(bills.getPodId());
|
|
|
- feeCenterD.setPodCode(bills.getPodCode());
|
|
|
- feeCenterD.setPodCnName(bills.getPodCnName());
|
|
|
- feeCenterD.setPodEnName(bills.getPodEnName());
|
|
|
- feeCenterD.setPaymode(bills.getMpaymode());
|
|
|
- feeCenterD.setSort(1);
|
|
|
- feeCenterD.setFeeId(fees.getId());
|
|
|
- feeCenterD.setFeeCode(fees.getCode());
|
|
|
- feeCenterD.setFeeCnName(fees.getCnName());
|
|
|
- feeCenterD.setFeeEnName(fees.getEnName());
|
|
|
- feeCenterD.setUnitNo("JOB");
|
|
|
- feeCenterD.setCurCode(feeCenterListC.get(0).getCurCode());
|
|
|
- feeCenterD.setExrate(feeCenterListC.get(0).getExrate());
|
|
|
- feeCenterD.setDc("D");
|
|
|
- feeCenterD.setCorpType("国内直接客户");
|
|
|
- BCorps corps = bCorpsService.getOne(new LambdaQueryWrapper<BCorps>()
|
|
|
- .eq(BCorps::getTenantId, AuthUtil.getTenantId())
|
|
|
- .eq(BCorps::getIsDeleted, 0)
|
|
|
- .eq(BCorps::getEnName, billsHYJK.getBranchName()));
|
|
|
- if (corps == null) {
|
|
|
- throw new RuntimeException("基础资料未查到往来单位" + bills.getBranchName());
|
|
|
- }
|
|
|
- feeCenterD.setCorpId(corps.getId());
|
|
|
- feeCenterD.setCorpCnName(corps.getCnName());
|
|
|
- feeCenterD.setCorpEnName(corps.getEnName());
|
|
|
- feeCenterD.setShortName(corps.getShortName());
|
|
|
- feeCenterD.setGenerationCorpId(corps.getBookingAgentId());
|
|
|
- feeCenterD.setGenerationCorpCnName(corps.getBookingAgentCnName());
|
|
|
- feeCenterD.setGenerationCorpEnName(corps.getBookingAgentEnName());
|
|
|
- feeCenterD.setQuantity(new BigDecimal("1"));
|
|
|
- feeCenterD.setPrice(amount);
|
|
|
- feeCenterD.setAmount(amount);
|
|
|
- feeCenterD.setAmountLoc(amount.multiply(feeCenterD.getExrate()));
|
|
|
- feeCenterD.setUnsettledAmount(feeCenterD.getAmount());
|
|
|
- feeCenterD.setCreateUser(bills.getOperatorId());
|
|
|
- feeCenterD.setCreateUserName(bills.getOperatorName());
|
|
|
- feeCenterD.setCreateTime(new Date());
|
|
|
- feeCenterService.save(feeCenterD);
|
|
|
- feeCenterListAcc.add(feeCenterD);
|
|
|
- List<FeeCenter> feeCenterListM = feeCenterService.list(new LambdaQueryWrapper<FeeCenter>()
|
|
|
- .eq(FeeCenter::getTenantId, AuthUtil.getTenantId())
|
|
|
- .eq(FeeCenter::getIsDeleted, 0)
|
|
|
- .eq(FeeCenter::getPid, bills.getId()));
|
|
|
- if (feeCenterListM.isEmpty()) {
|
|
|
- feeCenterListM = new ArrayList<>();
|
|
|
- }
|
|
|
- feeCenterListM.add(feeCenterD);
|
|
|
- Bills billsAmount = costProfitCalculationService.costProfitCalculation(feeCenterListM, exrateType);
|
|
|
- if (billsAmount != null) {
|
|
|
- bills.setAccountStatus(billsAmount.getAccountStatus());
|
|
|
- bills.setAmountDr(bills.getAmountDr().add(billsAmount.getAmountDr()));
|
|
|
- bills.setOceanFreightDr(bills.getOceanFreightDr().add(billsAmount.getOceanFreightDr()));
|
|
|
- bills.setAmountCr(bills.getAmountCr().add(billsAmount.getAmountCr()));
|
|
|
- bills.setOceanFreightCr(bills.getOceanFreightCr().add(billsAmount.getOceanFreightCr()));
|
|
|
- bills.setAmountProfit(bills.getAmountProfit().add(billsAmount.getAmountProfit()));
|
|
|
- bills.setOceanFreightProfit(bills.getOceanFreightProfit().add(billsAmount.getOceanFreightProfit()));
|
|
|
- bills.setAmountDrUsd(bills.getAmountDrUsd().add(billsAmount.getAmountDrUsd()));
|
|
|
- bills.setAmountCrUsd(bills.getAmountCrUsd().add(billsAmount.getAmountCrUsd()));
|
|
|
- bills.setAmountProfitUsd(bills.getAmountProfitUsd().add(billsAmount.getAmountProfitUsd()));
|
|
|
- bills.setAmountDrLoc(bills.getAmountDrLoc().add(billsAmount.getAmountDrLoc()));
|
|
|
- bills.setAmountCrLoc(bills.getAmountCrLoc().add(billsAmount.getAmountCrLoc()));
|
|
|
- bills.setAmountProfitLoc(bills.getAmountProfitLoc().add(billsAmount.getAmountProfitLoc()));
|
|
|
- int version = StringUtil.isBlank(bills.getVersion()) ? 1 : Integer.parseInt(bills.getVersion());
|
|
|
- bills.setVersion(String.valueOf(version + 1));
|
|
|
- billsMapper.updateById(bills);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- if (!feeCenterListAcc.isEmpty()) {
|
|
|
- Bills billsAmount = costProfitCalculationService.costProfitCalculation(feeCenterList, exrateType);
|
|
|
- if (billsAmount != null) {
|
|
|
- billsHYJK.setAccountStatus(billsAmount.getAccountStatus());
|
|
|
- billsHYJK.setAmountDr(billsHYJK.getAmountDr().add(billsAmount.getAmountDr()));
|
|
|
- billsHYJK.setOceanFreightDr(billsHYJK.getOceanFreightDr().add(billsAmount.getOceanFreightDr()));
|
|
|
- billsHYJK.setAmountCr(billsHYJK.getAmountCr().add(billsAmount.getAmountCr()));
|
|
|
- billsHYJK.setOceanFreightCr(billsHYJK.getOceanFreightCr().add(billsAmount.getOceanFreightCr()));
|
|
|
- billsHYJK.setAmountProfit(billsHYJK.getAmountProfit().add(billsAmount.getAmountProfit()));
|
|
|
- billsHYJK.setOceanFreightProfit(billsHYJK.getOceanFreightProfit().add(billsAmount.getOceanFreightProfit()));
|
|
|
- billsHYJK.setAmountDrUsd(billsHYJK.getAmountDrUsd().add(billsAmount.getAmountDrUsd()));
|
|
|
- billsHYJK.setAmountCrUsd(billsHYJK.getAmountCrUsd().add(billsAmount.getAmountCrUsd()));
|
|
|
- billsHYJK.setAmountProfitUsd(billsHYJK.getAmountProfitUsd().add(billsAmount.getAmountProfitUsd()));
|
|
|
- billsHYJK.setAmountDrLoc(billsHYJK.getAmountDrLoc().add(billsAmount.getAmountDrLoc()));
|
|
|
- billsHYJK.setAmountCrLoc(billsHYJK.getAmountCrLoc().add(billsAmount.getAmountCrLoc()));
|
|
|
- billsHYJK.setAmountProfitLoc(billsHYJK.getAmountProfitLoc().add(billsAmount.getAmountProfitLoc()));
|
|
|
- int version = StringUtil.isBlank(billsHYJK.getVersion()) ? 1 : Integer.parseInt(billsHYJK.getVersion());
|
|
|
- billsHYJK.setVersion(String.valueOf(version + 1));
|
|
|
- billsMapper.updateById(billsHYJK);
|
|
|
- }
|
|
|
- Boolean status = this.generateAccBills(feeCenterListAcc, billsHYJK, exrateType, boxDynamicsRecord, type);
|
|
|
- if (!status) {
|
|
|
- failureHandling("3", boxDynamicsRecord, "提单号" + billsHYJK.getHblno() + "超期箱使费生成账单失败");
|
|
|
- return false;
|
|
|
- }
|
|
|
- }
|
|
|
- return true;
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 费用明细生成账单数据
|
|
|
- *
|
|
|
- * @param feeCenterList 费用明细
|
|
|
- * @param billsHYJK 进出口单据信息
|
|
|
- * @param exrateType 本币币别
|
|
|
- * @param boxDynamicsRecord 进出场记录
|
|
|
- * @param type 操作类型 1=excel导入直接提示 2=api记录并修改状态为失败 3=只记录
|
|
|
- */
|
|
|
- private Boolean generateAccBills(List<FeeCenter> feeCenterList, Bills billsHYJK, String exrateType,
|
|
|
- BoxDynamicsRecord boxDynamicsRecord, String type) throws IOException {
|
|
|
- List<FeeCenter> feeCenterList1 = new ArrayList<>();
|
|
|
- BusinessType businessType = bBusinessTypeService.getOne(new LambdaQueryWrapper<BusinessType>()
|
|
|
- .eq(BusinessType::getTenantId, AuthUtil.getTenantId())
|
|
|
- .eq(BusinessType::getIsDeleted, 0)
|
|
|
- .eq(BusinessType::getStatus, 0)
|
|
|
- .eq(BusinessType::getCode, "HYZD"));
|
|
|
- if (businessType == null) {
|
|
|
- failureHandling(type, boxDynamicsRecord, "未找到账单业务编号规则");
|
|
|
- return false;
|
|
|
- }
|
|
|
- for (FeeCenter item : feeCenterList) {
|
|
|
- BigDecimal amount = item.getAmount();
|
|
|
- FinAccBills data = new FinAccBills();
|
|
|
- data.setCurCode(item.getCurCode());
|
|
|
- data.setGenerationCorpId(item.getGenerationCorpId());
|
|
|
- data.setGenerationCorpCnName(item.getGenerationCorpCnName());
|
|
|
- data.setGenerationCorpEnName(item.getGenerationCorpEnName());
|
|
|
- data.setCreateTime(new Date());
|
|
|
- data.setCreateUser(AuthUtil.getUserId());
|
|
|
- data.setCreateUserName(AuthUtil.getUserName());
|
|
|
- data.setCreateDept(item.getCreateDept());
|
|
|
- data.setCreateDeptName(item.getCreateDeptName());
|
|
|
- data.setBranchId(item.getBranchId());
|
|
|
- data.setBranchName(item.getBranchName());
|
|
|
- data.setDeptId(Long.parseLong(item.getBranchId()));
|
|
|
- data.setDeptName(item.getBranchName());
|
|
|
- data.setBookingAgentId(item.getBookingAgentId());
|
|
|
- data.setBookingAgentCnName(item.getBookingAgentCnName());
|
|
|
- data.setBookingAgentEnName(item.getBookingAgentEnName());
|
|
|
- data.setTaxRate(item.getTaxRate());
|
|
|
- data.setAmountTax(item.getAmountTax());
|
|
|
- data.setBillBranchId(item.getBillBranchId());
|
|
|
- data.setBillBranchName(item.getBillBranchName());
|
|
|
- BusinessBillNo businessBillNo = new BusinessBillNo();
|
|
|
- businessBillNo.setBusinessTypeId(businessType.getId());
|
|
|
- businessBillNo.setCode("HYZD");
|
|
|
- businessBillNo.setBranchId(item.getBranchId());
|
|
|
- R clientBillNo = businessBillNoService.getBillNoLos(businessBillNo);
|
|
|
- if (!clientBillNo.isSuccess()) {
|
|
|
- failureHandling(type, boxDynamicsRecord, "生成账单编号失败");
|
|
|
- return false;
|
|
|
- }
|
|
|
- data.setBillNo((String) clientBillNo.getData());
|
|
|
- data.setBillDate(item.getBillDate());
|
|
|
- data.setAccountDc(item.getDc());
|
|
|
- data.setAccountDate(item.getBillDate());
|
|
|
- data.setBillKey(item.getBillKey());
|
|
|
- data.setBusinessType(item.getBusinessType());
|
|
|
- data.setBillType(item.getBillType());
|
|
|
- data.setBusinessBillId(item.getPid());
|
|
|
- data.setBusinessBillNo(item.getBillNo());
|
|
|
- data.setBusinessDate(item.getBillDate());
|
|
|
- data.setSrcId(billsHYJK.getSrcId());
|
|
|
- data.setSrcCnName(billsHYJK.getSrcCnName());
|
|
|
- data.setSrcEnName(billsHYJK.getSrcEnName());
|
|
|
- data.setSrcType(billsHYJK.getSrcType());
|
|
|
- data.setOperatorId(billsHYJK.getOperatorId());
|
|
|
- data.setOperatorName(billsHYJK.getOperatorName());
|
|
|
- data.setQuantityCntrDescr(billsHYJK.getQuantityCntrDescr());
|
|
|
- data.setPaymode(item.getPaymode());
|
|
|
- data.setCorpId(item.getCorpId());
|
|
|
- data.setCorpCnName(item.getCorpCnName());
|
|
|
- data.setCorpEnName(item.getCorpEnName());
|
|
|
- data.setCorpArgreementNo(billsHYJK.getCorpArgreementNo());
|
|
|
- data.setBillCorpId(item.getBillCorpId());
|
|
|
- data.setBillCorpCnName(item.getBillCorpCnName());
|
|
|
- data.setBillCorpEnName(item.getBillCorpEnName());
|
|
|
- data.setVesselId(item.getVesselId());
|
|
|
- data.setVesselCnName(item.getVesselCnName());
|
|
|
- data.setVesselEnName(item.getVesselEnName());
|
|
|
- data.setVoyageNo(item.getVoyageNo());
|
|
|
- data.setMblno(item.getMblno());
|
|
|
- data.setHblno(item.getHblno());
|
|
|
- data.setRefno(billsHYJK.getRefno());
|
|
|
- data.setBookingNo(billsHYJK.getBookingNo());
|
|
|
- data.setEtd(item.getEtd());
|
|
|
- data.setEta(item.getEta());
|
|
|
- data.setPolId(item.getPolId());
|
|
|
- data.setPolCnName(item.getPolCnName());
|
|
|
- data.setPolEnName(item.getPolEnName());
|
|
|
- data.setPolNamePrint(billsHYJK.getPolNamePrint());
|
|
|
- data.setPodId(item.getPodId());
|
|
|
- data.setPodCnName(item.getPodCnName());
|
|
|
- data.setPodCode(item.getPodCode());
|
|
|
- data.setPodEnName(item.getPodEnName());
|
|
|
- data.setPodNamePrint(billsHYJK.getPodNamePrint());
|
|
|
- data.setTrackingNumber(item.getTrackingNumber());
|
|
|
- data.setAccountType("LOCAL");
|
|
|
- BigDecimal amountLoc = item.getAmountLoc();
|
|
|
- if ("D".equals(item.getDc())) {
|
|
|
- if (exrateType.equals(item.getCurCode())) {
|
|
|
- data.setAmountDr(amount);
|
|
|
- } else {
|
|
|
- data.setAmountDrUsd(amount);
|
|
|
- }
|
|
|
- data.setAmountDrLoc(amountLoc);
|
|
|
- } else {
|
|
|
- if (exrateType.equals(item.getCurCode())) {
|
|
|
- data.setAmountCr(amount);
|
|
|
- } else {
|
|
|
- data.setAmountCrUsd(amount);
|
|
|
- }
|
|
|
- data.setAmountCrLoc(amountLoc);
|
|
|
- }
|
|
|
- data.setExrate(item.getExrate());
|
|
|
- finAccBillsService.saveOrUpdate(data);
|
|
|
- item.setAccBillId(data.getId());
|
|
|
- item.setAccBillNo(data.getBillNo());
|
|
|
- item.setAccDate(data.getBillDate());
|
|
|
- item.setAccAmount(amountLoc);
|
|
|
- item.setAccStatus(1);
|
|
|
- item.setAccById(AuthUtil.getUserId());
|
|
|
- item.setAccByName(AuthUtil.getUserName());
|
|
|
- item.setAuditStatus("4");
|
|
|
- feeCenterList1.add(item);
|
|
|
- }
|
|
|
- feeCenterService.saveOrUpdateBatch(feeCenterList1);
|
|
|
- return true;
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
* 明细参数校验方法
|
|
|
*
|
|
|
* @param apiRequest 请求对象
|