|
|
@@ -30,10 +30,7 @@ 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.StringUtil;
|
|
|
-import org.springblade.los.Util.BoxNumUtils;
|
|
|
-import org.springblade.los.Util.CurrencyUtils;
|
|
|
-import org.springblade.los.Util.GlobalOperationLogUtils;
|
|
|
-import org.springblade.los.Util.OperatorType;
|
|
|
+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.basic.cntr.entity.BCntrTypes;
|
|
|
@@ -169,6 +166,8 @@ public class BoxDynamicsRecordServiceImpl extends ServiceImpl<BoxDynamicsRecordM
|
|
|
|
|
|
private final IBusinessBillNoService businessBillNoService;
|
|
|
|
|
|
+ private final OwBoxUsageFeeUtils owBoxUsageFeeUtils;
|
|
|
+
|
|
|
@Override
|
|
|
public IPage<BoxDynamicsRecordVO> selectBoxDynamicsRecordPage(IPage<BoxDynamicsRecordVO> page, BoxDynamicsRecordVO boxDynamicsRecord) {
|
|
|
return page.setRecords(baseMapper.selectBoxDynamicsRecordPage(page, boxDynamicsRecord));
|
|
|
@@ -177,7 +176,6 @@ public class BoxDynamicsRecordServiceImpl extends ServiceImpl<BoxDynamicsRecordM
|
|
|
@Override
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
public R importExcel(MultipartFile file, String type) throws IOException {
|
|
|
- List<EmptyContainerAppearance> analysisList = new ArrayList<>();
|
|
|
//导入数据
|
|
|
List<EmptyContainerAppearance> excelList = ExcelUtil.read(file, EmptyContainerAppearance.class);
|
|
|
if (CollectionUtils.isEmpty(excelList)) {
|
|
|
@@ -965,6 +963,43 @@ public class BoxDynamicsRecordServiceImpl extends ServiceImpl<BoxDynamicsRecordM
|
|
|
return R.success("操作成功");
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public List<EmptyContainerAppearance> exportTemplateById(String id, String ids) {
|
|
|
+ List<EmptyContainerAppearance> list = new ArrayList<>();
|
|
|
+ TradingBox tradingBox = tradingBoxMapper.selectById(id);
|
|
|
+ if (tradingBox == null) {
|
|
|
+ throw new RuntimeException("未查到单据信息");
|
|
|
+ }
|
|
|
+ List<TradingBoxItem> itemList = tradingBoxItemService.list(new LambdaQueryWrapper<TradingBoxItem>()
|
|
|
+ .eq(TradingBoxItem::getTenantId, AuthUtil.getTenantId())
|
|
|
+ .eq(TradingBoxItem::getIsDeleted, 0)
|
|
|
+ .eq(TradingBoxItem::getPid, id)
|
|
|
+ .eq(TradingBoxItem::getStatus, "使用中")
|
|
|
+ .apply(ObjectUtils.isNotNull(ids), "find_in_set(id,'" + ids + "')"));
|
|
|
+ if (itemList.isEmpty()) {
|
|
|
+ throw new RuntimeException("未查到箱号状态为使用中的待还箱信息");
|
|
|
+ }
|
|
|
+ List<BPorts> portsList = bPortsService.list(new LambdaQueryWrapper<BPorts>()
|
|
|
+ .eq(BPorts::getIsDeleted, 0)
|
|
|
+ .eq(BPorts::getTenantId, AuthUtil.getTenantId()));
|
|
|
+
|
|
|
+ for (TradingBoxItem item : itemList) {
|
|
|
+ EmptyContainerAppearance appearance = new EmptyContainerAppearance();
|
|
|
+ appearance.setContainerNumber(tradingBox.getContainerNumber());
|
|
|
+ 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()));
|
|
|
+ }
|
|
|
+ appearance.setStationName(item.getPodStationCname());
|
|
|
+ appearance.setMblno("");
|
|
|
+ appearance.setObjective("客户还箱");
|
|
|
+ appearance.setStatus(item.getBoxStatus());
|
|
|
+ list.add(appearance);
|
|
|
+ }
|
|
|
+ return list;
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 新箱进场流程
|
|
|
*
|
|
|
@@ -2399,6 +2434,18 @@ 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());
|
|
|
+ if (!tradingBoxList.isEmpty()) {
|
|
|
+ List<TradingBox> tradingBoxes1 = tradingBoxList.stream().filter(e -> pidList.contains(e.getId())).collect(Collectors.toList());
|
|
|
+ for (TradingBox detail : tradingBoxes1) {
|
|
|
+ if ("OW(拿)".equals(detail.getType())) {
|
|
|
+ owBoxUsageFeeUtils.calculateCost(detail, null, tradingBoxItemOldList.stream().
|
|
|
+ filter(e -> e.getPid().equals(detail.getId())).collect(Collectors.toList()), type);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
if (!containersListNew.isEmpty()) {
|
|
|
containersService.updateBatchById(containersListNew);
|
|
|
@@ -4024,8 +4071,10 @@ public class BoxDynamicsRecordServiceImpl extends ServiceImpl<BoxDynamicsRecordM
|
|
|
if (!itemsListCC.isEmpty()) {
|
|
|
BPorts ports = bPortsService.getById(boxDynamicsRecord.getPortId());
|
|
|
boolean intercept = false;
|
|
|
+ String restriction = sysClient.getParamService("whether.start.restriction");
|
|
|
if (ports != null) {
|
|
|
- if (ObjectUtils.isNotNull(ports.getUnCode()) && (ports.getUnCode().contains("CN") || ports.getUnCode().contains("VN"))) {
|
|
|
+ if (ObjectUtils.isNotNull(ports.getUnCode()) && (ports.getUnCode().contains("CN") || ports.getUnCode().contains("VN"))
|
|
|
+ && "1".equals(restriction)) {
|
|
|
intercept = true;
|
|
|
}
|
|
|
}
|
|
|
@@ -4249,6 +4298,10 @@ public class BoxDynamicsRecordServiceImpl extends ServiceImpl<BoxDynamicsRecordM
|
|
|
putBoxItem.setUpdateUserName(AuthUtil.getUserName());
|
|
|
putBoxItem.setUpdateTime(new Date());
|
|
|
} else {
|
|
|
+ if ("OW(拿)".equals(putBoxData.getBoxClass())) {
|
|
|
+ failureHandling(type, boxDynamicsRecord, "OW(拿)放箱号:" + item.getContainerNumber() + "未查到进场记录");
|
|
|
+ return false;
|
|
|
+ }
|
|
|
putBoxItem = new PutBoxItems();
|
|
|
putBoxItem.setBoxClass(putBoxData.getBoxClass());
|
|
|
putBoxItem.setBoxBelongsTo("SOC");
|
|
|
@@ -4263,6 +4316,10 @@ public class BoxDynamicsRecordServiceImpl extends ServiceImpl<BoxDynamicsRecordM
|
|
|
putBoxItem.setCreateTime(new Date());
|
|
|
}
|
|
|
} else {
|
|
|
+ if ("OW(拿)".equals(putBoxData.getBoxClass())) {
|
|
|
+ failureHandling(type, boxDynamicsRecord, "OW(拿)放箱号:" + item.getContainerNumber() + "未查到进场记录");
|
|
|
+ return false;
|
|
|
+ }
|
|
|
putBoxItem = new PutBoxItems();
|
|
|
putBoxItem.setBoxClass(putBoxData.getBoxClass());
|
|
|
putBoxItem.setBoxBelongsTo("SOC");
|
|
|
@@ -4310,7 +4367,6 @@ public class BoxDynamicsRecordServiceImpl extends ServiceImpl<BoxDynamicsRecordM
|
|
|
putBoxItem.setAgentName(bills.getForeignAgencyCnName());
|
|
|
putBoxItem.setShipCname(bills.getVesselCnName());
|
|
|
putBoxItem.setShipEname(bills.getVesselEnName());
|
|
|
- putBoxItem.setPolFreeBoxUseDays(bills.getPolFreeBoxUseDays());
|
|
|
putBoxItem.setEtd(bills.getEtd());
|
|
|
putBoxItem.setActualEtd(bills.getActualEtd());
|
|
|
} else {
|
|
|
@@ -4580,7 +4636,7 @@ public class BoxDynamicsRecordServiceImpl extends ServiceImpl<BoxDynamicsRecordM
|
|
|
.findFirst().orElse(null);
|
|
|
if (containerNumberItems == null) {
|
|
|
remainingNum = remainingNum + Integer.parseInt(sum + "");
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
if (sum > containerNumberItems.getOccupyNum() - containerNumberItems.getOutNum()) {
|
|
|
failureHandling(type, boxDynamicsRecord, "提单号:" + bills.getHblno() + "出场箱数大于占用数量");
|
|
|
return false;
|
|
|
@@ -4976,6 +5032,7 @@ public class BoxDynamicsRecordServiceImpl extends ServiceImpl<BoxDynamicsRecordM
|
|
|
}
|
|
|
}
|
|
|
item.setPolOverdueBoxUseDays(Integer.parseInt(overdueDays + ""));
|
|
|
+ item.setPolFreeBoxUseDays(feeCenter.getOverdueBoxUseDays());
|
|
|
}
|
|
|
putBoxItemsList.add(item);
|
|
|
if ("OW(拿),OW(放)".contains(putBox.getBoxClass())) {
|
|
|
@@ -5008,6 +5065,7 @@ public class BoxDynamicsRecordServiceImpl extends ServiceImpl<BoxDynamicsRecordM
|
|
|
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>()
|
|
|
@@ -5021,10 +5079,12 @@ public class BoxDynamicsRecordServiceImpl extends ServiceImpl<BoxDynamicsRecordM
|
|
|
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()) {
|
|
|
@@ -5119,6 +5179,7 @@ public class BoxDynamicsRecordServiceImpl extends ServiceImpl<BoxDynamicsRecordM
|
|
|
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()) {
|
|
|
@@ -5152,14 +5213,14 @@ public class BoxDynamicsRecordServiceImpl extends ServiceImpl<BoxDynamicsRecordM
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- if (!feeCenterList.isEmpty()) {
|
|
|
+ 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 = feeCenterList.stream().filter(e -> e.getPid().equals(item.getId()))
|
|
|
+ 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);
|
|
|
@@ -5442,6 +5503,7 @@ public class BoxDynamicsRecordServiceImpl extends ServiceImpl<BoxDynamicsRecordM
|
|
|
String text = "";
|
|
|
int dayLength;
|
|
|
BigDecimal amount = new BigDecimal("0.00");
|
|
|
+ int overdueBoxUseDays = 0;
|
|
|
for (StorageFeesItems term : storageFeesItems) {
|
|
|
BigDecimal rate;
|
|
|
//根据箱型获取具体超期单价
|
|
|
@@ -5455,6 +5517,9 @@ public class BoxDynamicsRecordServiceImpl extends ServiceImpl<BoxDynamicsRecordM
|
|
|
continue;
|
|
|
}
|
|
|
dayLength = term.getEndDay() - term.getStartDay() + 1;
|
|
|
+ if (new BigDecimal("0.00").compareTo(rate) == 0) {
|
|
|
+ overdueBoxUseDays = dayLength;
|
|
|
+ }
|
|
|
if (earlySumDays >= dayLength) {
|
|
|
earlySumDays -= dayLength;
|
|
|
continue;
|
|
|
@@ -5474,6 +5539,7 @@ public class BoxDynamicsRecordServiceImpl extends ServiceImpl<BoxDynamicsRecordM
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
+ feeCenter.setOverdueBoxUseDays(overdueBoxUseDays);
|
|
|
if (days != 0) {
|
|
|
if ("20GP".equals(item.getBoxType())) {
|
|
|
BigDecimal calculate = storageFeesItems.get(storageFeesItems.size() - 1).getPrice20gp().multiply(new BigDecimal(days + ""));
|
|
|
@@ -5657,6 +5723,7 @@ public class BoxDynamicsRecordServiceImpl extends ServiceImpl<BoxDynamicsRecordM
|
|
|
feeCenterListC.add(feeCenterC);
|
|
|
}
|
|
|
}
|
|
|
+ item.setPodFreeBoxUseDays(feeCenter.getOverdueBoxUseDays());
|
|
|
}
|
|
|
putBoxItemsList.add(item);
|
|
|
if ("OW(拿),OW(放)".contains(putBox.getBoxClass())) {
|
|
|
@@ -5691,16 +5758,19 @@ public class BoxDynamicsRecordServiceImpl extends ServiceImpl<BoxDynamicsRecordM
|
|
|
.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());
|
|
|
@@ -5777,6 +5847,7 @@ public class BoxDynamicsRecordServiceImpl extends ServiceImpl<BoxDynamicsRecordM
|
|
|
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)
|
|
|
@@ -5806,7 +5877,7 @@ public class BoxDynamicsRecordServiceImpl extends ServiceImpl<BoxDynamicsRecordM
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- if (!feeCenterList.isEmpty()) {
|
|
|
+ if (!feeCenterListAcc.isEmpty()) {
|
|
|
Bills billsAmount = costProfitCalculationService.costProfitCalculation(feeCenterList, exrateType);
|
|
|
if (billsAmount != null) {
|
|
|
billsHYJK.setAccountStatus(billsAmount.getAccountStatus());
|
|
|
@@ -5826,7 +5897,7 @@ public class BoxDynamicsRecordServiceImpl extends ServiceImpl<BoxDynamicsRecordM
|
|
|
billsHYJK.setVersion(String.valueOf(version + 1));
|
|
|
billsMapper.updateById(billsHYJK);
|
|
|
}
|
|
|
- Boolean status = this.generateAccBills(feeCenterList, billsHYJK, exrateType, boxDynamicsRecord, type);
|
|
|
+ Boolean status = this.generateAccBills(feeCenterListAcc, billsHYJK, exrateType, boxDynamicsRecord, type);
|
|
|
if (!status) {
|
|
|
failureHandling("3", boxDynamicsRecord, "提单号" + billsHYJK.getHblno() + "超期箱使费生成账单失败");
|
|
|
return false;
|