|
|
@@ -44,7 +44,10 @@ import java.time.Instant;
|
|
|
import java.time.LocalDate;
|
|
|
import java.time.Period;
|
|
|
import java.time.ZoneId;
|
|
|
-import java.util.*;
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.Date;
|
|
|
+import java.util.List;
|
|
|
+import java.util.Objects;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
|
@@ -164,6 +167,9 @@ public class TradingBoxServiceImpl extends ServiceImpl<TradingBoxMapper, Trading
|
|
|
} else if ("OW-F".equals(tradingBox.getType())) {
|
|
|
billNoFormat = "OW-F";
|
|
|
businessTypeCode = "OW-F";
|
|
|
+ } else if ("XGFY".equals(tradingBox.getType())) {
|
|
|
+ billNoFormat = "XGFY";
|
|
|
+ businessTypeCode = "XGFY";
|
|
|
} else {
|
|
|
throw new Error("缺少必要参数类型");
|
|
|
}
|
|
|
@@ -177,9 +183,18 @@ public class TradingBoxServiceImpl extends ServiceImpl<TradingBoxMapper, Trading
|
|
|
throw new RuntimeException("未找到可用业务类型");
|
|
|
}
|
|
|
if ("OW-N,OW-F".contains(tradingBox.getType()) && ObjectUtils.isNull(tradingBox.getInternalContainerNumber())) {
|
|
|
+ BusinessType businessType1 = bBusinessTypeService.getOne(new LambdaQueryWrapper<BusinessType>()
|
|
|
+ .select(BusinessType::getId)
|
|
|
+ .eq(BusinessType::getTenantId, AuthUtil.getTenantId())
|
|
|
+ .eq(BusinessType::getIsDeleted, 0)
|
|
|
+ .eq(BusinessType::getStatus, 0)
|
|
|
+ .eq(BusinessType::getCode, "FXH"));
|
|
|
+ if (businessType1 == null) {
|
|
|
+ throw new RuntimeException("未找到可用业务类型");
|
|
|
+ }
|
|
|
BusinessBillNo businessBillNo1 = new BusinessBillNo();
|
|
|
- businessBillNo1.setBusinessTypeId(businessType.getId());
|
|
|
- businessBillNo1.setCode(businessTypeCode);
|
|
|
+ businessBillNo1.setBusinessTypeId(businessType1.getId());
|
|
|
+ businessBillNo1.setCode("FXH-N");
|
|
|
R clientBillNo1 = businessBillNoService.getBillNoLos(businessBillNo1);
|
|
|
if (!clientBillNo1.isSuccess()) {
|
|
|
throw new RuntimeException("生成订单编号失败");
|
|
|
@@ -448,43 +463,40 @@ public class TradingBoxServiceImpl extends ServiceImpl<TradingBoxMapper, Trading
|
|
|
BFees fees = bFeesService.getOne(new LambdaQueryWrapper<BFees>()
|
|
|
.eq(BFees::getTenantId, AuthUtil.getTenantId())
|
|
|
.eq(BFees::getIsDeleted, 0)
|
|
|
- .eq(BFees::getCode, "ZXF"));
|
|
|
+ .eq(BFees::getCode, "BOX-ZJ"));
|
|
|
if (fees == null) {
|
|
|
throw new RuntimeException("请先维护费用基础信息");
|
|
|
}
|
|
|
List<Archives> archivesListNew = new ArrayList<>();
|
|
|
List<ArchivesTrajectory> archivesTrajectoryList = new ArrayList<>();
|
|
|
List<FeeCenter> feeCenterList = new ArrayList<>();
|
|
|
- for (TradingBoxItem tradingBoxItem : tradingBoxItemList) {
|
|
|
- ArchivesTrajectory archivesTrajectory = new ArchivesTrajectory();
|
|
|
- archivesTrajectory.setPortId(tradingBox.getAddressId());
|
|
|
- archivesTrajectory.setPortCode(tradingBox.getAddressCode());
|
|
|
- archivesTrajectory.setPortCname(tradingBox.getAddressCname());
|
|
|
- archivesTrajectory.setPortEname(tradingBox.getAddressEname());
|
|
|
- archivesTrajectory.setStationId(tradingBox.getAddressId());
|
|
|
- archivesTrajectory.setStationCode(tradingBox.getAddressCode());
|
|
|
- archivesTrajectory.setStationCname(tradingBox.getAddressCname());
|
|
|
- archivesTrajectory.setStationEname(tradingBox.getAddressEname());
|
|
|
- archivesTrajectory.setContainerNumber(tradingBoxItem.getContainerNumber());
|
|
|
- archivesTrajectory.setBoxType(tradingBoxItem.getBoxType());
|
|
|
- archivesTrajectory.setBoxCategory(tradingBoxItem.getBoxCategory());
|
|
|
- archivesTrajectory.setBoxEastId(tradingBoxItem.getBoxEastId());
|
|
|
- archivesTrajectory.setBoxEastName(tradingBoxItem.getBoxEastName());
|
|
|
- archivesTrajectory.setMblno(tradingBoxItem.getMblno());
|
|
|
- archivesTrajectory.setBoxDynamics(tradingBoxItem.getBoxDynamics());
|
|
|
- archivesTrajectory.setNewDate(tradingBox.getRentDate());
|
|
|
- tradingBoxItem.setUpdateUser(AuthUtil.getUserId());
|
|
|
- tradingBoxItem.setUpdateTime(new Date());
|
|
|
- tradingBoxItem.setUpdateUserName(AuthUtil.getUserName());
|
|
|
- if ("1".equals(tradingBox.getRentType())) {
|
|
|
+ List<TradingBoxItem> itemList = new ArrayList<>();
|
|
|
+ if ("1".equals(tradingBox.getRentType())) {
|
|
|
+ tradingBox.setBuxStaus("已启租");
|
|
|
+ tradingBox.setRentEndDate(tradingBox.getRentDate());
|
|
|
+ for (TradingBoxItem tradingBoxItem : tradingBoxItemList) {
|
|
|
+ ArchivesTrajectory archivesTrajectory = new ArchivesTrajectory();
|
|
|
+ archivesTrajectory.setPortId(tradingBox.getAddressId());
|
|
|
+ archivesTrajectory.setPortCode(tradingBox.getAddressCode());
|
|
|
+ archivesTrajectory.setPortCname(tradingBox.getAddressCname());
|
|
|
+ archivesTrajectory.setPortEname(tradingBox.getAddressEname());
|
|
|
+ archivesTrajectory.setStationId(tradingBox.getAddressId());
|
|
|
+ archivesTrajectory.setStationCode(tradingBox.getAddressCode());
|
|
|
+ archivesTrajectory.setStationCname(tradingBox.getAddressCname());
|
|
|
+ archivesTrajectory.setStationEname(tradingBox.getAddressEname());
|
|
|
+ archivesTrajectory.setContainerNumber(tradingBoxItem.getContainerNumber());
|
|
|
+ archivesTrajectory.setBoxType(tradingBoxItem.getBoxType());
|
|
|
+ archivesTrajectory.setBoxCategory(tradingBoxItem.getBoxCategory());
|
|
|
+ archivesTrajectory.setBoxEastId(tradingBoxItem.getBoxEastId());
|
|
|
+ archivesTrajectory.setBoxEastName(tradingBoxItem.getBoxEastName());
|
|
|
+ archivesTrajectory.setMblno(tradingBoxItem.getMblno());
|
|
|
+ archivesTrajectory.setBoxDynamics(tradingBoxItem.getBoxDynamics());
|
|
|
+ archivesTrajectory.setNewDate(tradingBox.getRentDate());
|
|
|
+ tradingBoxItem.setUpdateUser(AuthUtil.getUserId());
|
|
|
+ tradingBoxItem.setUpdateTime(new Date());
|
|
|
+ tradingBoxItem.setUpdateUserName(AuthUtil.getUserName());
|
|
|
tradingBoxItem.setStatus("待使用");
|
|
|
tradingBoxItem.setLeaseCommencementDate(tradingBox.getRentDate());
|
|
|
- if (ObjectUtils.isNotNull(tradingBoxItem.getLeaseCommencementDate()) && ObjectUtils.isNotNull(tradingBoxItem.getOverdueDays())) {
|
|
|
- Calendar calendar = new GregorianCalendar();
|
|
|
- calendar.setTime(tradingBoxItem.getLeaseCommencementDate());
|
|
|
- calendar.add(Calendar.DATE, tradingBoxItem.getOverdueDays());
|
|
|
- tradingBoxItem.setRentEndDate(calendar.getTime());
|
|
|
- }
|
|
|
if (ObjectUtils.isNotNull(tradingBoxItem.getCode())) {
|
|
|
//更新箱档案信息
|
|
|
Archives archivesR = new Archives();
|
|
|
@@ -543,61 +555,201 @@ public class TradingBoxServiceImpl extends ServiceImpl<TradingBoxMapper, Trading
|
|
|
} else {
|
|
|
throw new RuntimeException("箱号不能为空");
|
|
|
}
|
|
|
- } else {
|
|
|
- if (ObjectUtils.isNotNull(tradingBoxItem.getCode())) {
|
|
|
- //更新箱档案信息
|
|
|
- Archives archivesR = new Archives();
|
|
|
- if (!archivesList.isEmpty()) {
|
|
|
- archivesR = archivesList.stream().filter(e -> e.getCode().equals(tradingBoxItem.getCode())).findFirst().orElse(null);
|
|
|
- }
|
|
|
- if (archivesR == null) {
|
|
|
- throw new RuntimeException("未查到箱信息");
|
|
|
+ itemList.add(tradingBoxItem);
|
|
|
+ //记录箱轨迹信息
|
|
|
+ archivesTrajectory.setCorpId(tradingBox.getPurchaseCompanyId());
|
|
|
+ archivesTrajectory.setCorpName(tradingBox.getPurchaseCompanyName());
|
|
|
+ archivesTrajectory.setContractNo(tradingBox.getContractNo());
|
|
|
+ archivesTrajectory.setBillType(tradingBox.getType());
|
|
|
+ archivesTrajectory.setCode(tradingBoxItem.getCode());
|
|
|
+ archivesTrajectory.setCreateTime(new Date());
|
|
|
+ archivesTrajectory.setCreateUser(AuthUtil.getUserId());
|
|
|
+ archivesTrajectory.setCreateUserName(AuthUtil.getUserName());
|
|
|
+ archivesTrajectory.setTenantId(AuthUtil.getTenantId());
|
|
|
+ archivesTrajectoryList.add(archivesTrajectory);
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ tradingBox.setBuxStaus("已退租");
|
|
|
+ for (TradingBoxType item : tradingBoxTypeList) {
|
|
|
+ List<TradingBoxItem> tradingBoxItems = tradingBoxItemList.stream().filter(e -> e.getBoxType().equals(item.getBoxType()))
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ if (!tradingBoxItems.isEmpty()) {
|
|
|
+ FeeCenter feeCenter = new FeeCenter();
|
|
|
+ feeCenter.setCreateTime(new Date());
|
|
|
+ feeCenter.setCreateUser(AuthUtil.getUserId());
|
|
|
+ feeCenter.setCreateUserName(AuthUtil.getUserName());
|
|
|
+ feeCenter.setPid(item.getPid());
|
|
|
+ feeCenter.setDc("C");
|
|
|
+ feeCenter.setFeeId(fees.getId());
|
|
|
+ feeCenter.setFeeCode(fees.getCode());
|
|
|
+ feeCenter.setFeeCnName(fees.getCnName());
|
|
|
+ feeCenter.setFeeEnName(fees.getEnName());
|
|
|
+ feeCenter.setCurCode(fees.getCurNo());
|
|
|
+ feeCenter.setCntrNo(tradingBoxItems.stream().map(TradingBoxItem::getCode).collect(Collectors.joining(",")));
|
|
|
+ feeCenter.setUnitNo(item.getBoxType());
|
|
|
+ if (ObjectUtils.isNotNull(tradingBox.getRentEndDate()) && ObjectUtils.isNotNull(tradingBox.getRentDate())) {
|
|
|
+ Instant instant1 = tradingBox.getRentEndDate().toInstant();
|
|
|
+ Instant instant2 = tradingBox.getRentDate().toInstant();
|
|
|
+ LocalDate date1 = instant1.atZone(ZoneId.systemDefault()).toLocalDate();
|
|
|
+ LocalDate date2 = instant2.atZone(ZoneId.systemDefault()).toLocalDate();
|
|
|
+ Period period = Period.between(date1, date2);
|
|
|
+ feeCenter.setDays(period.getDays());
|
|
|
+ feeCenter.setPrice(item.getPrice());
|
|
|
+ feeCenter.setQuantity(new BigDecimal(tradingBoxItems.size() + ""));
|
|
|
+ feeCenter.setAmount(feeCenter.getPrice().multiply(feeCenter.getQuantity())
|
|
|
+ .multiply(new BigDecimal(feeCenter.getDays() + "")));
|
|
|
+ feeCenter.setRemarks("租金单价:" + feeCenter.getPrice() + "箱/天*箱数:" + feeCenter.getQuantity() + "*天数" + feeCenter.getDays());
|
|
|
}
|
|
|
- if (archivesR.getStatus().equals("使用")) {
|
|
|
- throw new RuntimeException("箱号:" + archivesR.getCode() + "状态为使用中,退租失败!");
|
|
|
+ feeCenter.setStorageDate(tradingBox.getRentEndDate());
|
|
|
+ feeCenter.setOutboundDate(tradingBox.getRentDate());
|
|
|
+ feeCenter.setBillNo(tradingBox.getSysNo());
|
|
|
+ feeCenter.setBusinessType(tradingBox.getType());
|
|
|
+ feeCenter.setBillDate(tradingBox.getPurchaseDate());
|
|
|
+ feeCenter.setBillCorpId(tradingBox.getPurchaseCompanyId());
|
|
|
+ feeCenter.setBillCorpCnName(tradingBox.getPurchaseCompanyName());
|
|
|
+ feeCenter.setBillCorpEnName(tradingBox.getPurchaseCompanyName());
|
|
|
+ feeCenter.setBillShortName(tradingBox.getPurchaseCompanyName());
|
|
|
+ feeCenter.setMblno(tradingBox.getContractNo());
|
|
|
+ feeCenter.setPolId(tradingBox.getAddressId());
|
|
|
+ feeCenter.setPolCode(tradingBox.getAddressCode());
|
|
|
+ feeCenter.setPolCnName(tradingBox.getAddressCname());
|
|
|
+ feeCenter.setPolEnName(tradingBox.getAddressCname());
|
|
|
+ feeCenterList.add(feeCenter);
|
|
|
+ for (TradingBoxItem tradingBoxItem : tradingBoxItems) {
|
|
|
+ ArchivesTrajectory archivesTrajectory = new ArchivesTrajectory();
|
|
|
+ archivesTrajectory.setPortId(tradingBox.getAddressId());
|
|
|
+ archivesTrajectory.setPortCode(tradingBox.getAddressCode());
|
|
|
+ archivesTrajectory.setPortCname(tradingBox.getAddressCname());
|
|
|
+ archivesTrajectory.setPortEname(tradingBox.getAddressEname());
|
|
|
+ archivesTrajectory.setStationId(tradingBox.getAddressId());
|
|
|
+ archivesTrajectory.setStationCode(tradingBox.getAddressCode());
|
|
|
+ archivesTrajectory.setStationCname(tradingBox.getAddressCname());
|
|
|
+ archivesTrajectory.setStationEname(tradingBox.getAddressEname());
|
|
|
+ archivesTrajectory.setContainerNumber(tradingBoxItem.getContainerNumber());
|
|
|
+ archivesTrajectory.setBoxType(tradingBoxItem.getBoxType());
|
|
|
+ archivesTrajectory.setBoxCategory(tradingBoxItem.getBoxCategory());
|
|
|
+ archivesTrajectory.setBoxEastId(tradingBoxItem.getBoxEastId());
|
|
|
+ archivesTrajectory.setBoxEastName(tradingBoxItem.getBoxEastName());
|
|
|
+ archivesTrajectory.setMblno(tradingBoxItem.getMblno());
|
|
|
+ archivesTrajectory.setBoxDynamics(tradingBoxItem.getBoxDynamics());
|
|
|
+ archivesTrajectory.setNewDate(tradingBox.getRentDate());
|
|
|
+ tradingBoxItem.setUpdateUser(AuthUtil.getUserId());
|
|
|
+ tradingBoxItem.setUpdateTime(new Date());
|
|
|
+ tradingBoxItem.setUpdateUserName(AuthUtil.getUserName());
|
|
|
+ if (ObjectUtils.isNotNull(tradingBoxItem.getCode())) {
|
|
|
+ //更新箱档案信息
|
|
|
+ Archives archivesR = new Archives();
|
|
|
+ if (!archivesList.isEmpty()) {
|
|
|
+ archivesR = archivesList.stream().filter(e -> e.getCode().equals(tradingBoxItem.getCode())).findFirst().orElse(null);
|
|
|
+ }
|
|
|
+ if (archivesR == null) {
|
|
|
+ throw new RuntimeException("未查到箱信息");
|
|
|
+ }
|
|
|
+ if (archivesR.getStatus().equals("使用")) {
|
|
|
+ throw new RuntimeException("箱号:" + archivesR.getCode() + "状态为使用中,退租失败!");
|
|
|
+ }
|
|
|
+ archivesR.setStatus("退租");
|
|
|
+ archivesR.setBoxAccessStatus("空箱离场");
|
|
|
+ archivesR.setUpdateTime(new Date());
|
|
|
+ archivesR.setUpdateUserName(AuthUtil.getUserName());
|
|
|
+ archivesR.setUpdateUser(AuthUtil.getUserId());
|
|
|
+ archivesR.setAddressCname(tradingBox.getAddressCname());
|
|
|
+ archivesR.setAddressId(tradingBox.getAddressId());
|
|
|
+ archivesR.setNewDate(tradingBox.getRentDate());
|
|
|
+ archivesListNew.add(archivesR);
|
|
|
+ archivesTrajectory.setStatus("退租");
|
|
|
+ } else {
|
|
|
+ throw new RuntimeException("箱号不能为空");
|
|
|
+ }
|
|
|
+ tradingBoxItem.setStatus("退租");
|
|
|
+ tradingBoxItem.setRentEndDate(tradingBox.getRentDate());
|
|
|
+ tradingBoxItem.setRentingOutDate(tradingBox.getRentDate());
|
|
|
+ itemList.add(tradingBoxItem);
|
|
|
+ //记录箱轨迹信息
|
|
|
+ archivesTrajectory.setCorpId(tradingBox.getPurchaseCompanyId());
|
|
|
+ archivesTrajectory.setCorpName(tradingBox.getPurchaseCompanyName());
|
|
|
+ archivesTrajectory.setContractNo(tradingBox.getContractNo());
|
|
|
+ archivesTrajectory.setBillType(tradingBox.getType());
|
|
|
+ archivesTrajectory.setCode(tradingBoxItem.getCode());
|
|
|
+ archivesTrajectory.setCreateTime(new Date());
|
|
|
+ archivesTrajectory.setCreateUser(AuthUtil.getUserId());
|
|
|
+ archivesTrajectory.setCreateUserName(AuthUtil.getUserName());
|
|
|
+ archivesTrajectory.setTenantId(AuthUtil.getTenantId());
|
|
|
+ archivesTrajectoryList.add(archivesTrajectory);
|
|
|
}
|
|
|
- archivesR.setStatus("退租");
|
|
|
- archivesR.setBoxAccessStatus("空箱离场");
|
|
|
- archivesR.setUpdateTime(new Date());
|
|
|
- archivesR.setUpdateUserName(AuthUtil.getUserName());
|
|
|
- archivesR.setUpdateUser(AuthUtil.getUserId());
|
|
|
- archivesR.setAddressCname(tradingBox.getAddressCname());
|
|
|
- archivesR.setAddressId(tradingBox.getAddressId());
|
|
|
- archivesR.setNewDate(tradingBox.getRentDate());
|
|
|
- archivesListNew.add(archivesR);
|
|
|
- archivesTrajectory.setStatus("退租");
|
|
|
- } else {
|
|
|
- throw new RuntimeException("箱号不能为空");
|
|
|
- }
|
|
|
- tradingBoxItem.setStatus("退租");
|
|
|
- TradingBoxType tradingBoxType = tradingBoxTypeList.stream().filter(e -> e.getBoxType().equals(tradingBoxItem.getBoxType()))
|
|
|
- .findFirst().orElse(null);
|
|
|
- if (tradingBoxType == null) {
|
|
|
- throw new RuntimeException("未查到箱型数据");
|
|
|
}
|
|
|
+ }
|
|
|
+ tradingBox.setRentEndDate(tradingBox.getRentDate());
|
|
|
+ tradingBox.setRentingOutDate(tradingBox.getRentDate());
|
|
|
+ }
|
|
|
+ if (!itemList.isEmpty()) {
|
|
|
+ tradingBoxItemService.updateBatchById(itemList);
|
|
|
+ }
|
|
|
+ if (!archivesListNew.isEmpty()) {
|
|
|
+ archivesService.saveOrUpdateBatch(archivesListNew);
|
|
|
+ }
|
|
|
+ if (!archivesTrajectoryList.isEmpty()) {
|
|
|
+ archivesTrajectoryService.saveBatch(archivesTrajectoryList);
|
|
|
+ }
|
|
|
+ if (!feeCenterList.isEmpty()) {
|
|
|
+ feeCenterService.saveOrUpdateBatch(feeCenterList);
|
|
|
+ }
|
|
|
+ baseMapper.updateById(tradingBox);
|
|
|
+ tradingBox.setTradingBoxItemsList(tradingBoxItemList);
|
|
|
+ return tradingBox;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
+ public TradingBox rentCalculation(TradingBox tradingBox) {
|
|
|
+ List<TradingBoxItem> tradingBoxItemList = tradingBox.getTradingBoxItemsList();
|
|
|
+ if (tradingBoxItemList.isEmpty()) {
|
|
|
+ throw new RuntimeException("明细不能为空");
|
|
|
+ }
|
|
|
+ BFees fees = bFeesService.getOne(new LambdaQueryWrapper<BFees>()
|
|
|
+ .eq(BFees::getTenantId, AuthUtil.getTenantId())
|
|
|
+ .eq(BFees::getIsDeleted, 0)
|
|
|
+ .eq(BFees::getCode, "BOX-ZJ"));
|
|
|
+ if (fees == null) {
|
|
|
+ throw new RuntimeException("请先维护费用基础信息");
|
|
|
+ }
|
|
|
+ List<TradingBoxType> tradingBoxTypeList = tradingBoxTypeService.list(new LambdaQueryWrapper<TradingBoxType>()
|
|
|
+ .eq(TradingBoxType::getTenantId, AuthUtil.getTenantId())
|
|
|
+ .eq(TradingBoxType::getIsDeleted, 0)
|
|
|
+ .eq(TradingBoxType::getPid, tradingBox.getId()));
|
|
|
+ List<FeeCenter> feeCenterList = new ArrayList<>();
|
|
|
+ List<TradingBoxItem> itemList = new ArrayList<>();
|
|
|
+ for (TradingBoxType item : tradingBoxTypeList) {
|
|
|
+ List<TradingBoxItem> tradingBoxItems = tradingBoxItemList.stream().filter(e -> e.getBoxType().equals(item.getBoxType()))
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ if (!tradingBoxItems.isEmpty()) {
|
|
|
FeeCenter feeCenter = new FeeCenter();
|
|
|
feeCenter.setCreateTime(new Date());
|
|
|
feeCenter.setCreateUser(AuthUtil.getUserId());
|
|
|
feeCenter.setCreateUserName(AuthUtil.getUserName());
|
|
|
- feeCenter.setPid(tradingBoxItem.getPid());
|
|
|
+ feeCenter.setPid(item.getPid());
|
|
|
feeCenter.setDc("C");
|
|
|
feeCenter.setFeeId(fees.getId());
|
|
|
feeCenter.setFeeCode(fees.getCode());
|
|
|
feeCenter.setFeeCnName(fees.getCnName());
|
|
|
feeCenter.setFeeEnName(fees.getEnName());
|
|
|
feeCenter.setCurCode(fees.getCurNo());
|
|
|
- if (ObjectUtils.isNotNull(tradingBoxItem.getRentEndDate()) && ObjectUtils.isNotNull(tradingBox.getRentDate())) {
|
|
|
- Instant instant1 = tradingBoxItem.getRentEndDate().toInstant();
|
|
|
+ feeCenter.setCntrNo(tradingBoxItems.stream().map(TradingBoxItem::getCode).collect(Collectors.joining(",")));
|
|
|
+ feeCenter.setUnitNo(item.getBoxType());
|
|
|
+ if (ObjectUtils.isNotNull(tradingBox.getRentEndDate()) && ObjectUtils.isNotNull(tradingBox.getRentDate())) {
|
|
|
+ Instant instant1 = tradingBox.getRentEndDate().toInstant();
|
|
|
Instant instant2 = tradingBox.getRentDate().toInstant();
|
|
|
LocalDate date1 = instant1.atZone(ZoneId.systemDefault()).toLocalDate();
|
|
|
LocalDate date2 = instant2.atZone(ZoneId.systemDefault()).toLocalDate();
|
|
|
Period period = Period.between(date1, date2);
|
|
|
feeCenter.setDays(period.getDays());
|
|
|
- feeCenter.setPrice(tradingBoxType.getPrice());
|
|
|
- feeCenter.setQuantity(new BigDecimal(period.getDays() + ""));
|
|
|
- feeCenter.setAmount(feeCenter.getPrice().multiply(feeCenter.getQuantity()));
|
|
|
+ feeCenter.setPrice(item.getPrice());
|
|
|
+ feeCenter.setQuantity(new BigDecimal(tradingBoxItems.size() + ""));
|
|
|
+ feeCenter.setAmount(feeCenter.getPrice().multiply(feeCenter.getQuantity())
|
|
|
+ .multiply(new BigDecimal(feeCenter.getDays() + "")));
|
|
|
+ feeCenter.setRemarks("租金单价:" + feeCenter.getPrice() + "箱/天*箱数:" + feeCenter.getQuantity() + "*天数" + feeCenter.getDays());
|
|
|
}
|
|
|
- feeCenter.setStorageDate(tradingBoxItem.getRentEndDate());
|
|
|
+ feeCenter.setStorageDate(tradingBox.getRentEndDate());
|
|
|
feeCenter.setOutboundDate(tradingBox.getRentDate());
|
|
|
feeCenter.setBillNo(tradingBox.getSysNo());
|
|
|
feeCenter.setBusinessType(tradingBox.getType());
|
|
|
@@ -612,156 +764,93 @@ public class TradingBoxServiceImpl extends ServiceImpl<TradingBoxMapper, Trading
|
|
|
feeCenter.setPolCnName(tradingBox.getAddressCname());
|
|
|
feeCenter.setPolEnName(tradingBox.getAddressCname());
|
|
|
feeCenterList.add(feeCenter);
|
|
|
- tradingBoxItem.setRentStartDate(tradingBoxItem.getRentEndDate());
|
|
|
- tradingBoxItem.setRentEndDate(tradingBox.getRentDate());
|
|
|
- tradingBoxItem.setRentingOutDate(tradingBox.getRentDate());
|
|
|
- }
|
|
|
- tradingBoxItemService.updateById(tradingBoxItem);
|
|
|
- if (!archivesListNew.isEmpty()) {
|
|
|
- archivesService.saveOrUpdateBatch(archivesListNew);
|
|
|
- }
|
|
|
- if (!feeCenterList.isEmpty()) {
|
|
|
- feeCenterService.saveOrUpdateBatch(feeCenterList);
|
|
|
+ for (TradingBoxItem tradingBoxItem : tradingBoxItems) {
|
|
|
+ tradingBoxItem.setUpdateUser(AuthUtil.getUserId());
|
|
|
+ tradingBoxItem.setUpdateTime(new Date());
|
|
|
+ tradingBoxItem.setUpdateUserName(AuthUtil.getUserName());
|
|
|
+ tradingBoxItem.setRentEndDate(tradingBox.getRentDate());
|
|
|
+ itemList.add(tradingBoxItem);
|
|
|
+ }
|
|
|
}
|
|
|
- //记录箱轨迹信息
|
|
|
- archivesTrajectory.setCorpId(tradingBox.getPurchaseCompanyId());
|
|
|
- archivesTrajectory.setCorpName(tradingBox.getPurchaseCompanyName());
|
|
|
- archivesTrajectory.setContractNo(tradingBox.getContractNo());
|
|
|
- archivesTrajectory.setBillType(tradingBox.getType());
|
|
|
- archivesTrajectory.setCode(tradingBoxItem.getCode());
|
|
|
- archivesTrajectory.setCreateTime(new Date());
|
|
|
- archivesTrajectory.setCreateUser(AuthUtil.getUserId());
|
|
|
- archivesTrajectory.setCreateUserName(AuthUtil.getUserName());
|
|
|
- archivesTrajectory.setTenantId(AuthUtil.getTenantId());
|
|
|
- archivesTrajectoryList.add(archivesTrajectory);
|
|
|
}
|
|
|
- if (!archivesTrajectoryList.isEmpty()) {
|
|
|
- archivesTrajectoryService.saveBatch(archivesTrajectoryList);
|
|
|
+ tradingBox.setRentEndDate(tradingBox.getRentDate());
|
|
|
+ baseMapper.updateById(tradingBox);
|
|
|
+ if (!itemList.isEmpty()) {
|
|
|
+ tradingBoxItemService.updateBatchById(itemList);
|
|
|
}
|
|
|
- tradingBox.setTradingBoxItemsList(tradingBoxItemList);
|
|
|
+ if (!feeCenterList.isEmpty()) {
|
|
|
+ feeCenterService.saveBatch(feeCenterList);
|
|
|
+ }
|
|
|
+ tradingBox.setFeeCenterList(feeCenterList);
|
|
|
return tradingBox;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
- public TradingBox rentCalculation(TradingBox tradingBox) {
|
|
|
+ public TradingBox revokeRentCalculation(TradingBox tradingBox) {
|
|
|
List<TradingBoxItem> tradingBoxItemList = tradingBox.getTradingBoxItemsList();
|
|
|
if (tradingBoxItemList.isEmpty()) {
|
|
|
throw new RuntimeException("明细不能为空");
|
|
|
}
|
|
|
- int days = 0;
|
|
|
- if (ObjectUtils.isNotNull(tradingBox.getRentCalculationDate()) && ObjectUtils.isNotNull(tradingBox.getRentStartDate())) {
|
|
|
- days = (int) ((tradingBox.getRentCalculationDate().getTime() - tradingBox.getRentStartDate().getTime()) / (1000 * 3600 * 24)) + 1;
|
|
|
+ BFees fees = bFeesService.getOne(new LambdaQueryWrapper<BFees>()
|
|
|
+ .eq(BFees::getTenantId, AuthUtil.getTenantId())
|
|
|
+ .eq(BFees::getIsDeleted, 0)
|
|
|
+ .eq(BFees::getCode, "BOX-ZJ"));
|
|
|
+ if (fees == null) {
|
|
|
+ throw new RuntimeException("请先维护费用基础信息");
|
|
|
}
|
|
|
-
|
|
|
- /*List<TradingBoxFees> tradingBoxFeesList = new ArrayList<>();
|
|
|
- for (TradingBoxItem tradingBoxItem : tradingBoxItemList) {
|
|
|
- TradingBoxFees tradingBoxFees = new TradingBoxFees();
|
|
|
- tradingBoxFees.setCorpId(tradingBox.getPurchaseCompanyId());
|
|
|
- tradingBoxFees.setCorpName(tradingBox.getPurchaseCompanyName());
|
|
|
- tradingBoxFees.setAmount(tradingBoxItem.getPrice().multiply(BigDecimal.valueOf(days)));
|
|
|
- tradingBoxFees.setPrice(tradingBoxItem.getPrice());
|
|
|
- tradingBoxFees.setQuantity(BigDecimal.valueOf(days));
|
|
|
- tradingBoxFees.setCurrency(tradingBoxItem.getCurrency());
|
|
|
- tradingBoxFees.setCode(tradingBoxItem.getCode());
|
|
|
- tradingBoxFees.setCorpName(tradingBox.getPurchaseCompanyName());
|
|
|
- //获取费用id
|
|
|
- R<FeesDesc> fees = feesDescClient.getFeesByName("租金");
|
|
|
- if (fees.isSuccess() && fees.getData() != null) {
|
|
|
- tradingBoxFees.setItemId(fees.getData().getId());
|
|
|
- }
|
|
|
- if ("ZR".equals(tradingBox.getType())) {
|
|
|
- tradingBoxFees.setFeesType(2);
|
|
|
- tradingBoxFees.setBillType("租入");
|
|
|
- } else {
|
|
|
- tradingBoxFees.setFeesType(1);
|
|
|
- tradingBoxFees.setBillType("租出");
|
|
|
- }
|
|
|
- tradingBoxFees.setPid(tradingBox.getId());
|
|
|
- tradingBoxFees.setSrcOrderNo(tradingBox.getContractNo());
|
|
|
- tradingBoxFees.setUnit(tradingBoxItem.getBoxType());
|
|
|
- tradingBoxFees.setExchangeRate(new BigDecimal(1));
|
|
|
- tradingBoxFees.setRentStartDate(tradingBox.getRentStartDate());
|
|
|
- tradingBoxFees.setRentEndDate(tradingBox.getRentCalculationDate());
|
|
|
- tradingBoxFees.setCreateUser(AuthUtil.getUserId());
|
|
|
- tradingBoxFees.setCreateTime(new Date());
|
|
|
- tradingBoxFees.setTenantId(AuthUtil.getTenantId());
|
|
|
- tradingBoxFees.setSubmitPay(0);
|
|
|
- tradingBoxFees.setIdentifier(0);
|
|
|
- tradingBoxFeesService.save(tradingBoxFees);
|
|
|
- tradingBoxFeesList.add(tradingBoxFees);
|
|
|
- tradingBoxItem.setOverdueAmount(tradingBoxItem.getPrice().multiply(BigDecimal.valueOf(days)));
|
|
|
- tradingBoxItem.setUpdateTime(new Date());
|
|
|
- tradingBoxItem.setUpdateUser(AuthUtil.getUserId());
|
|
|
- tradingBoxItem.setUpdateUserName(AuthUtil.getUserName());
|
|
|
- tradingBoxItem.setRentEndDate(tradingBox.getRentCalculationDate());
|
|
|
- tradingBoxItem.setRentStartDate(tradingBox.getRentStartDate());
|
|
|
- tradingBoxItem.setCount(tradingBoxItem.getCount() + 1);
|
|
|
- tradingBoxItemService.updateById(tradingBoxItem);
|
|
|
+ List<TradingBoxType> tradingBoxTypeList = tradingBoxTypeService.list(new LambdaQueryWrapper<TradingBoxType>()
|
|
|
+ .eq(TradingBoxType::getTenantId, AuthUtil.getTenantId())
|
|
|
+ .eq(TradingBoxType::getIsDeleted, 0)
|
|
|
+ .eq(TradingBoxType::getPid, tradingBox.getId()));
|
|
|
+ if (tradingBoxTypeList.isEmpty()) {
|
|
|
+ throw new RuntimeException("未查到箱型箱量数据");
|
|
|
}
|
|
|
- tradingBox.setTradingBoxFeesList(tradingBoxFeesList);*/
|
|
|
- return tradingBox;
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- @Transactional(rollbackFor = Exception.class)
|
|
|
- public TradingBox revokeRentCalculation(TradingBox tradingBox) {
|
|
|
- List<TradingBoxItem> tradingBoxItemList = tradingBox.getTradingBoxItemsList();
|
|
|
- if (tradingBoxItemList.size() < 1) {
|
|
|
- throw new RuntimeException("明细不能为空");
|
|
|
+ //获取订单费用信息
|
|
|
+ LambdaQueryWrapper<FeeCenter> tradingBoxFeesLambdaQueryWrapper = new LambdaQueryWrapper<>();
|
|
|
+ tradingBoxFeesLambdaQueryWrapper.eq(FeeCenter::getIsDeleted, 0)
|
|
|
+ .eq(FeeCenter::getPid, tradingBox.getId())
|
|
|
+ .eq(FeeCenter::getTenantId, AuthUtil.getTenantId())
|
|
|
+ .in(FeeCenter::getUnitNo, tradingBoxTypeList.stream().map(TradingBoxType::getBoxType).collect(Collectors.toList()))
|
|
|
+ .eq(FeeCenter::getFeeCode, fees.getCode())
|
|
|
+ .orderByDesc(FeeCenter::getCreateTime);
|
|
|
+ List<FeeCenter> feeCenters = feeCenterService.list(tradingBoxFeesLambdaQueryWrapper);
|
|
|
+ if (feeCenters.isEmpty()) {
|
|
|
+ throw new RuntimeException("未计算过租金,撤销失败");
|
|
|
}
|
|
|
- /* for (TradingBoxItem tradingBoxItem : tradingBoxItemList) {
|
|
|
- //获取订单费用信息
|
|
|
- LambdaQueryWrapper<TradingBoxFees> tradingBoxFeesLambdaQueryWrapper = new LambdaQueryWrapper<>();
|
|
|
- tradingBoxFeesLambdaQueryWrapper.eq(TradingBoxFees::getIsDeleted, 0);
|
|
|
- tradingBoxFeesLambdaQueryWrapper.eq(TradingBoxFees::getPid, tradingBox.getId());
|
|
|
- tradingBoxFeesLambdaQueryWrapper.eq(TradingBoxFees::getTenantId, AuthUtil.getTenantId());
|
|
|
-// tradingBoxFeesLambdaQueryWrapper.eq(TradingBoxFees::getSubmitPay, 1);
|
|
|
- tradingBoxFeesLambdaQueryWrapper.eq(TradingBoxFees::getCode, tradingBoxItem.getCode());
|
|
|
- tradingBoxFeesLambdaQueryWrapper.eq(TradingBoxFees::getIdentifier, 0);
|
|
|
- tradingBoxFeesLambdaQueryWrapper.orderByDesc(TradingBoxFees::getCreateTime);
|
|
|
- List<TradingBoxFees> tradingBoxFeesList = tradingBoxFeesService.list(tradingBoxFeesLambdaQueryWrapper);
|
|
|
- if (!tradingBoxFeesList.isEmpty()) {
|
|
|
- tradingBoxFeesService.removeById(tradingBoxFeesList.get(0).getId());
|
|
|
- //获取账单信息
|
|
|
- Acc acc = new Acc();
|
|
|
- acc.setSrcParentId(tradingBox.getId());
|
|
|
- acc.setSrcFeesId(tradingBoxFeesList.get(0).getId());
|
|
|
- if ("ZR".equals(tradingBox.getType())) {
|
|
|
- acc.setBillType("申请");
|
|
|
- } else {
|
|
|
- acc.setBillType("收费");
|
|
|
+ List<TradingBoxItem> itemList = new ArrayList<>();
|
|
|
+ for (TradingBoxType item : tradingBoxTypeList) {
|
|
|
+ List<TradingBoxItem> tradingBoxItems = tradingBoxItemList.stream().filter(e -> e.getBoxType().equals(item.getBoxType()))
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ List<FeeCenter> feeCenterList = feeCenters.stream().filter(e -> e.getUnitNo().equals(item.getBoxType())).collect(Collectors.toList());
|
|
|
+ if (!feeCenterList.isEmpty()) {
|
|
|
+ FeeCenter feeCenter = feeCenterList.get(0);
|
|
|
+ if (1 == feeCenter.getAccStatus()) {
|
|
|
+ throw new RuntimeException("箱型:" + item.getBoxType() + "费用已生成账单,撤销失败");
|
|
|
}
|
|
|
- acc.setTradeType("BOX");
|
|
|
- acc.setSrcType(5);
|
|
|
- R<List<Acc>> r = financeClient.getAccListByCondition(acc);
|
|
|
- if (r.isSuccess() && ObjectUtils.isNotNull(r.getData())) {
|
|
|
- for (Acc acc_ : r.getData()) {
|
|
|
- //判断是否有结算 true 不允许撤销审核 false 删除账单信息并撤销审核
|
|
|
- if (!acc_.getSettlementAmount().equals(new BigDecimal("0.00"))) {
|
|
|
- throw new SecurityException("订单已结算,不允许撤销");
|
|
|
+ feeCenterService.removeById(feeCenter.getId());
|
|
|
+ if (!tradingBoxItems.isEmpty()) {
|
|
|
+ for (TradingBoxItem tradingBoxItem : tradingBoxItems) {
|
|
|
+ tradingBoxItem.setUpdateTime(new Date());
|
|
|
+ tradingBoxItem.setUpdateUser(AuthUtil.getUserId());
|
|
|
+ tradingBoxItem.setUpdateUserName(AuthUtil.getUserName());
|
|
|
+ tradingBoxItem.setCount(tradingBoxItem.getCount() - 1);
|
|
|
+ if (feeCenterList.size() == 1) {
|
|
|
+ tradingBoxItem.setRentEndDate(tradingBoxItem.getLeaseCommencementDate());
|
|
|
} else {
|
|
|
- financeClient.remove(acc_.getId() + "");
|
|
|
+ tradingBoxItem.setRentEndDate(feeCenter.getStorageDate());
|
|
|
}
|
|
|
+ itemList.add(tradingBoxItem);
|
|
|
}
|
|
|
}
|
|
|
- } else {
|
|
|
- throw new SecurityException("箱号:" + tradingBoxItem.getCode() + "未计算租金,撤销失败");
|
|
|
}
|
|
|
- tradingBoxItem.setUpdateTime(new Date());
|
|
|
- tradingBoxItem.setUpdateUser(AuthUtil.getUserId());
|
|
|
- tradingBoxItem.setUpdateUserName(AuthUtil.getUserName());
|
|
|
- tradingBoxItem.setCount(tradingBoxItem.getCount() - 1);
|
|
|
- if (tradingBoxFeesList.size() == 1) {
|
|
|
- tradingBoxItem.setRentEndDate(tradingBoxItem.getLeaseCommencementDate());
|
|
|
- tradingBoxItem.setRentStartDate(tradingBoxItem.getLeaseCommencementDate());
|
|
|
- } else {
|
|
|
- tradingBoxItem.setRentEndDate(tradingBoxFeesList.get(1).getRentEndDate());
|
|
|
- tradingBoxItem.setRentStartDate(tradingBoxFeesList.get(1).getRentStartDate());
|
|
|
- }
|
|
|
- tradingBoxItemService.updateById(tradingBoxItem);
|
|
|
}
|
|
|
- tradingBox.setTradingBoxItemsList(tradingBoxItemList);*/
|
|
|
+ if (!itemList.isEmpty()) {
|
|
|
+ tradingBox.setRentEndDate(itemList.get(0).getRentEndDate());
|
|
|
+ tradingBoxItemService.updateBatchById(itemList);
|
|
|
+ }
|
|
|
+ baseMapper.updateById(tradingBox);
|
|
|
+ tradingBox.setTradingBoxItemsList(tradingBoxItemList);
|
|
|
return tradingBox;
|
|
|
}
|
|
|
|
|
|
@@ -771,79 +860,62 @@ public class TradingBoxServiceImpl extends ServiceImpl<TradingBoxMapper, Trading
|
|
|
throw new RuntimeException("缺少必要参数");
|
|
|
}
|
|
|
TradingBox details = baseMapper.selectById(tradingBox.getId());
|
|
|
-
|
|
|
- Long feesId = null;
|
|
|
-
|
|
|
- //获取费用id
|
|
|
- /*R<FeesDesc> fees = feesDescClient.getFeesByName("租金");
|
|
|
- if (fees.isSuccess() && fees.getData() != null) {
|
|
|
- feesId = fees.getData().getId();
|
|
|
- }*/
|
|
|
if (ObjectUtils.isNotNull(details)) {
|
|
|
- //获取明细信息
|
|
|
LambdaQueryWrapper<TradingBoxItem> tradingBoxItemLambdaQueryWrapper = new LambdaQueryWrapper<>();
|
|
|
tradingBoxItemLambdaQueryWrapper.eq(TradingBoxItem::getIsDeleted, 0)
|
|
|
.eq(TradingBoxItem::getTenantId, AuthUtil.getTenantId())
|
|
|
.eq(TradingBoxItem::getPid, details.getId());
|
|
|
List<TradingBoxItem> tradingBoxItemList = tradingBoxItemService.list(tradingBoxItemLambdaQueryWrapper);
|
|
|
- for (TradingBoxItem tradingBoxItem : tradingBoxItemList) {
|
|
|
- //获取费用信息
|
|
|
- /* LambdaQueryWrapper<TradingBoxFees> tradingBoxFeesLambdaQueryWrapper = new LambdaQueryWrapper<>();
|
|
|
- tradingBoxFeesLambdaQueryWrapper.eq(TradingBoxFees::getIsDeleted, 0)
|
|
|
- .eq(TradingBoxFees::getTenantId, AuthUtil.getTenantId())
|
|
|
- .eq(TradingBoxFees::getCode, tradingBoxItem.getCode())
|
|
|
- .eq(ObjectUtils.isNotNull(feesId), TradingBoxFees::getItemId, feesId)
|
|
|
- .eq(TradingBoxFees::getPid, details.getId());
|
|
|
- int count = tradingBoxFeesService.count(tradingBoxFeesLambdaQueryWrapper);
|
|
|
- tradingBoxItem.setCount(count);*/
|
|
|
- tradingBoxItem.setId(null);
|
|
|
- tradingBoxItem.setPid(null);
|
|
|
- tradingBoxItem.setCreateUserName(null);
|
|
|
- tradingBoxItem.setCreateUser(null);
|
|
|
- tradingBoxItem.setCreateTime(null);
|
|
|
- tradingBoxItem.setUpdateUserName(null);
|
|
|
- tradingBoxItem.setUpdateTime(null);
|
|
|
- tradingBoxItem.setUpdateUser(null);
|
|
|
- if ("ZR".equals(tradingBox.getType()) || "ZC".equals(tradingBox.getType())) {
|
|
|
- tradingBoxItem.setLeaseCommencementDate(null);
|
|
|
- tradingBoxItem.setRentingOutDate(null);
|
|
|
- tradingBoxItem.setRentEndDate(null);
|
|
|
- tradingBoxItem.setRentStartDate(null);
|
|
|
- if ("ZR".equals(tradingBox.getType())) {
|
|
|
- tradingBoxItem.setStatus("录入");
|
|
|
- } else {
|
|
|
- tradingBoxItem.setStatus("使用");
|
|
|
- }
|
|
|
- }
|
|
|
- tradingBoxItem.setTradingBoxFilesList(new ArrayList<>());
|
|
|
- }
|
|
|
- details.setTradingBoxItemsList(tradingBoxItemList);
|
|
|
-
|
|
|
- //获取费用信息
|
|
|
- /* LambdaQueryWrapper<TradingBoxFees> tradingBoxFeesLambdaQueryWrapper = new LambdaQueryWrapper<>();
|
|
|
- tradingBoxFeesLambdaQueryWrapper.eq(TradingBoxFees::getIsDeleted, 0)
|
|
|
- .eq(TradingBoxFees::getTenantId, AuthUtil.getTenantId())
|
|
|
- .eq(TradingBoxFees::getPid, details.getId());
|
|
|
- List<TradingBoxFees> tradingBoxFeesList = tradingBoxFeesService.list(tradingBoxFeesLambdaQueryWrapper);
|
|
|
- for (TradingBoxFees tradingBoxFees : tradingBoxFeesList) {
|
|
|
- R<FeesDesc> r = feesDescClient.detail(tradingBoxFees.getItemId());
|
|
|
- if (r.isSuccess() && ObjectUtils.isNotNull(r.getData())) {
|
|
|
- tradingBoxFees.setItemName(r.getData().getCname());
|
|
|
- }
|
|
|
- CorpsDesc corpsDesc = corpsDescClient.getCorpId(tradingBoxFees.getCorpId());
|
|
|
- if (ObjectUtils.isNotNull(corpsDesc)) {
|
|
|
- tradingBoxFees.setCorpName(corpsDesc.getCname());
|
|
|
- }
|
|
|
- tradingBoxFees.setId(null);
|
|
|
- tradingBoxFees.setPid(null);
|
|
|
- tradingBoxFees.setCreateUser(null);
|
|
|
- tradingBoxFees.setCreateTime(null);
|
|
|
- tradingBoxFees.setUpdateTime(null);
|
|
|
- tradingBoxFees.setUpdateUser(null);
|
|
|
- tradingBoxFees.setSubmitPay(0);
|
|
|
+ for (TradingBoxItem item : tradingBoxItemList) {
|
|
|
+ item.setId(null);
|
|
|
+ item.setPid(null);
|
|
|
+ item.setCreateUserName(null);
|
|
|
+ item.setCreateUser(null);
|
|
|
+ item.setCreateTime(null);
|
|
|
+ item.setUpdateUserName(null);
|
|
|
+ item.setUpdateTime(null);
|
|
|
+ item.setUpdateUser(null);
|
|
|
+ item.setLeaseCommencementDate(null);
|
|
|
+ item.setRentingOutDate(null);
|
|
|
+ item.setRentEndDate(null);
|
|
|
+ item.setRentStartDate(null);
|
|
|
+ item.setStatus("录入");
|
|
|
}
|
|
|
- details.setTradingBoxFeesList(tradingBoxFeesList);*/
|
|
|
+ details.setTradingBoxItemsList(tradingBoxItemList.isEmpty() ? new ArrayList<>() : tradingBoxItemList);
|
|
|
details.setTradingBoxFilesList(new ArrayList<>());
|
|
|
+ details.setFeeCenterList(new ArrayList<>());
|
|
|
+ LambdaQueryWrapper<RentTerm> rentTermLambdaQueryWrapper = new LambdaQueryWrapper<>();
|
|
|
+ rentTermLambdaQueryWrapper.eq(RentTerm::getIsDeleted, 0)
|
|
|
+ .eq(RentTerm::getTenantId, AuthUtil.getTenantId())
|
|
|
+ .eq(RentTerm::getPid, details.getId());
|
|
|
+ List<RentTerm> rentTermList = rentTermService.list(rentTermLambdaQueryWrapper);
|
|
|
+ for (RentTerm item : rentTermList) {
|
|
|
+ item.setId(null);
|
|
|
+ item.setPid(null);
|
|
|
+ item.setCreateUserName(null);
|
|
|
+ item.setCreateUser(null);
|
|
|
+ item.setCreateTime(null);
|
|
|
+ item.setUpdateUserName(null);
|
|
|
+ item.setUpdateTime(null);
|
|
|
+ item.setUpdateUser(null);
|
|
|
+ }
|
|
|
+ details.setRentTermList(rentTermList.isEmpty() ? new ArrayList<>() : rentTermList);
|
|
|
+ LambdaQueryWrapper<TradingBoxType> typeLambdaQueryWrapper = new LambdaQueryWrapper<>();
|
|
|
+ typeLambdaQueryWrapper.eq(TradingBoxType::getIsDeleted, 0)
|
|
|
+ .eq(TradingBoxType::getTenantId, AuthUtil.getTenantId())
|
|
|
+ .eq(TradingBoxType::getPid, details.getId());
|
|
|
+ List<TradingBoxType> tradingBoxTypeList = tradingBoxTypeService.list(typeLambdaQueryWrapper);
|
|
|
+ for (TradingBoxType item : tradingBoxTypeList) {
|
|
|
+ item.setId(null);
|
|
|
+ item.setPid(null);
|
|
|
+ item.setCreateUserName(null);
|
|
|
+ item.setCreateUser(null);
|
|
|
+ item.setCreateTime(null);
|
|
|
+ item.setUpdateUserName(null);
|
|
|
+ item.setUpdateTime(null);
|
|
|
+ item.setUpdateUser(null);
|
|
|
+ }
|
|
|
+ details.setBoxTypeList(tradingBoxTypeList.isEmpty() ? new ArrayList<>() : tradingBoxTypeList);
|
|
|
}
|
|
|
details.setId(null);
|
|
|
details.setCreateUserName(null);
|
|
|
@@ -852,81 +924,147 @@ public class TradingBoxServiceImpl extends ServiceImpl<TradingBoxMapper, Trading
|
|
|
details.setUpdateUserName(null);
|
|
|
details.setUpdateTime(null);
|
|
|
details.setUpdateUser(null);
|
|
|
- details.setStatus(0);
|
|
|
- details.setApprovalStatus(null);
|
|
|
- details.setPageStatus(null);
|
|
|
details.setSysNo(null);
|
|
|
+ details.setInternalContainerNumber("");
|
|
|
+ details.setBuxStaus("录入");
|
|
|
return details;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
public Object revokeRentingOut(TradingBox tradingBox) {
|
|
|
List<TradingBoxItem> tradingBoxItemList = tradingBox.getTradingBoxItemsList();
|
|
|
- if (tradingBoxItemList.size() < 1) {
|
|
|
+ if (tradingBoxItemList.isEmpty()) {
|
|
|
throw new RuntimeException("明细不能为空");
|
|
|
}
|
|
|
- /*for (TradingBoxItem tradingBoxItem : tradingBoxItemList) {
|
|
|
- //获取订单费用信息
|
|
|
- LambdaQueryWrapper<TradingBoxFees> tradingBoxFeesLambdaQueryWrapper = new LambdaQueryWrapper<>();
|
|
|
- tradingBoxFeesLambdaQueryWrapper.eq(TradingBoxFees::getIsDeleted, 0);
|
|
|
- tradingBoxFeesLambdaQueryWrapper.eq(TradingBoxFees::getPid, tradingBox.getId());
|
|
|
- tradingBoxFeesLambdaQueryWrapper.eq(TradingBoxFees::getTenantId, AuthUtil.getTenantId());
|
|
|
- tradingBoxFeesLambdaQueryWrapper.eq(TradingBoxFees::getSubmitPay, 1);
|
|
|
- tradingBoxFeesLambdaQueryWrapper.eq(TradingBoxFees::getCode, tradingBoxItem.getCode());
|
|
|
- tradingBoxFeesLambdaQueryWrapper.orderByDesc(TradingBoxFees::getRentEndDate);
|
|
|
- List<TradingBoxFees> tradingBoxFeesList = tradingBoxFeesService.list(tradingBoxFeesLambdaQueryWrapper);
|
|
|
- if (tradingBoxFeesList.size() > 0) {
|
|
|
- tradingBoxFeesService.removeById(tradingBoxFeesList.get(0).getId());
|
|
|
- //获取账单信息
|
|
|
- Acc acc = new Acc();
|
|
|
- acc.setSrcParentId(tradingBox.getId());
|
|
|
- acc.setSrcFeesId(tradingBoxFeesList.get(0).getId());
|
|
|
- if ("ZR".equals(tradingBox.getType())) {
|
|
|
- acc.setBillType("申请");
|
|
|
- tradingBoxItem.setStatus("待使用");
|
|
|
- } else {
|
|
|
- acc.setBillType("收费");
|
|
|
- tradingBoxItem.setStatus("使用");
|
|
|
+ tradingBox.setBuxStaus("已启租");
|
|
|
+ List<String> boxCode = tradingBoxItemList.stream().map(TradingBoxItem::getCode).collect(Collectors.toList());
|
|
|
+ List<Archives> archivesList = archivesService.list(new LambdaQueryWrapper<Archives>()
|
|
|
+ .eq(Archives::getTenantId, AuthUtil.getTenantId())
|
|
|
+ .eq(Archives::getIsDeleted, 0)
|
|
|
+ .in(Archives::getCode, boxCode));
|
|
|
+ BFees fees = bFeesService.getOne(new LambdaQueryWrapper<BFees>()
|
|
|
+ .eq(BFees::getTenantId, AuthUtil.getTenantId())
|
|
|
+ .eq(BFees::getIsDeleted, 0)
|
|
|
+ .eq(BFees::getCode, "BOX-ZJ"));
|
|
|
+ if (fees == null) {
|
|
|
+ throw new RuntimeException("请先维护费用基础信息");
|
|
|
+ }
|
|
|
+ List<TradingBoxType> tradingBoxTypeList = tradingBoxTypeService.list(new LambdaQueryWrapper<TradingBoxType>()
|
|
|
+ .eq(TradingBoxType::getTenantId, AuthUtil.getTenantId())
|
|
|
+ .eq(TradingBoxType::getIsDeleted, 0)
|
|
|
+ .eq(TradingBoxType::getPid, tradingBox.getId()));
|
|
|
+ if (tradingBoxTypeList.isEmpty()) {
|
|
|
+ throw new RuntimeException("未查到箱型箱量数据");
|
|
|
+ }
|
|
|
+ //获取订单费用信息
|
|
|
+ LambdaQueryWrapper<FeeCenter> tradingBoxFeesLambdaQueryWrapper = new LambdaQueryWrapper<>();
|
|
|
+ tradingBoxFeesLambdaQueryWrapper.eq(FeeCenter::getIsDeleted, 0)
|
|
|
+ .eq(FeeCenter::getPid, tradingBox.getId())
|
|
|
+ .eq(FeeCenter::getTenantId, AuthUtil.getTenantId())
|
|
|
+ .in(FeeCenter::getUnitNo, tradingBoxTypeList.stream().map(TradingBoxType::getBoxType).collect(Collectors.toList()))
|
|
|
+ .eq(FeeCenter::getFeeCode, fees.getCode())
|
|
|
+ .orderByDesc(FeeCenter::getCreateTime);
|
|
|
+ List<FeeCenter> feeCenters = feeCenterService.list(tradingBoxFeesLambdaQueryWrapper);
|
|
|
+ List<TradingBoxItem> itemList = new ArrayList<>();
|
|
|
+ List<Archives> archivesListNew = new ArrayList<>();
|
|
|
+ List<ArchivesTrajectory> archivesTrajectoryList = new ArrayList<>();
|
|
|
+ for (TradingBoxType item : tradingBoxTypeList) {
|
|
|
+ List<TradingBoxItem> tradingBoxItems = tradingBoxItemList.stream().filter(e -> e.getBoxType().equals(item.getBoxType()))
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ List<FeeCenter> feeCenterList = feeCenters.stream().filter(e -> e.getUnitNo().equals(item.getBoxType())).collect(Collectors.toList());
|
|
|
+ if (!feeCenterList.isEmpty()) {
|
|
|
+ FeeCenter feeCenter = feeCenterList.get(0);
|
|
|
+ if (1 == feeCenter.getAccStatus()) {
|
|
|
+ throw new RuntimeException("箱型:" + item.getBoxType() + "费用已生成账单,撤销失败");
|
|
|
}
|
|
|
- acc.setTradeType("BOX");
|
|
|
- acc.setSrcType(5);
|
|
|
- R<List<Acc>> r = financeClient.getAccListByCondition(acc);
|
|
|
- if (r.isSuccess() && ObjectUtils.isNotNull(r.getData())) {
|
|
|
- for (Acc acc_ : r.getData()) {
|
|
|
- //判断是否有结算 true 不允许撤销审核 false 删除账单信息并撤销审核
|
|
|
- if (!acc_.getSettlementAmount().equals(new BigDecimal("0.00"))) {
|
|
|
- throw new SecurityException("订单已结算,不允许撤销");
|
|
|
+ feeCenterService.removeById(feeCenter.getId());
|
|
|
+ if (!tradingBoxItems.isEmpty()) {
|
|
|
+ for (TradingBoxItem tradingBoxItem : tradingBoxItems) {
|
|
|
+ ArchivesTrajectory archivesTrajectory = new ArchivesTrajectory();
|
|
|
+ archivesTrajectory.setPortId(tradingBox.getAddressId());
|
|
|
+ archivesTrajectory.setPortCode(tradingBox.getAddressCode());
|
|
|
+ archivesTrajectory.setPortCname(tradingBox.getAddressCname());
|
|
|
+ archivesTrajectory.setPortEname(tradingBox.getAddressEname());
|
|
|
+ archivesTrajectory.setStationId(tradingBox.getAddressId());
|
|
|
+ archivesTrajectory.setStationCode(tradingBox.getAddressCode());
|
|
|
+ archivesTrajectory.setStationCname(tradingBox.getAddressCname());
|
|
|
+ archivesTrajectory.setStationEname(tradingBox.getAddressEname());
|
|
|
+ archivesTrajectory.setContainerNumber(tradingBoxItem.getContainerNumber());
|
|
|
+ archivesTrajectory.setBoxType(tradingBoxItem.getBoxType());
|
|
|
+ archivesTrajectory.setBoxCategory(tradingBoxItem.getBoxCategory());
|
|
|
+ archivesTrajectory.setBoxEastId(tradingBoxItem.getBoxEastId());
|
|
|
+ archivesTrajectory.setBoxEastName(tradingBoxItem.getBoxEastName());
|
|
|
+ archivesTrajectory.setMblno(tradingBoxItem.getMblno());
|
|
|
+ archivesTrajectory.setBoxDynamics(tradingBoxItem.getBoxDynamics());
|
|
|
+ archivesTrajectory.setNewDate(tradingBox.getRentDate());
|
|
|
+ tradingBoxItem.setUpdateUser(AuthUtil.getUserId());
|
|
|
+ tradingBoxItem.setUpdateTime(new Date());
|
|
|
+ tradingBoxItem.setUpdateUserName(AuthUtil.getUserName());
|
|
|
+ if (ObjectUtils.isNotNull(tradingBoxItem.getCode())) {
|
|
|
+ //更新箱档案信息
|
|
|
+ Archives archivesR = new Archives();
|
|
|
+ if (!archivesList.isEmpty()) {
|
|
|
+ archivesR = archivesList.stream().filter(e -> e.getCode().equals(tradingBoxItem.getCode())).findFirst().orElse(null);
|
|
|
+ }
|
|
|
+ if (archivesR == null) {
|
|
|
+ throw new RuntimeException("未查到箱信息");
|
|
|
+ }
|
|
|
+ if (archivesR.getStatus().equals("使用")) {
|
|
|
+ throw new RuntimeException("箱号:" + archivesR.getCode() + "状态为使用中,退租失败!");
|
|
|
+ }
|
|
|
+ archivesR.setStatus("退租");
|
|
|
+ archivesR.setBoxAccessStatus("空箱离场");
|
|
|
+ archivesR.setUpdateTime(new Date());
|
|
|
+ archivesR.setUpdateUserName(AuthUtil.getUserName());
|
|
|
+ archivesR.setUpdateUser(AuthUtil.getUserId());
|
|
|
+ archivesR.setAddressCname(tradingBox.getAddressCname());
|
|
|
+ archivesR.setAddressId(tradingBox.getAddressId());
|
|
|
+ archivesR.setNewDate(tradingBox.getRentDate());
|
|
|
+ archivesListNew.add(archivesR);
|
|
|
+ archivesTrajectory.setStatus("退租");
|
|
|
} else {
|
|
|
- financeClient.remove(acc_.getId() + "");
|
|
|
+ throw new RuntimeException("箱号不能为空");
|
|
|
}
|
|
|
+ tradingBoxItem.setStatus("退租");
|
|
|
+ //记录箱轨迹信息
|
|
|
+ archivesTrajectory.setCorpId(tradingBox.getPurchaseCompanyId());
|
|
|
+ archivesTrajectory.setCorpName(tradingBox.getPurchaseCompanyName());
|
|
|
+ archivesTrajectory.setContractNo(tradingBox.getContractNo());
|
|
|
+ archivesTrajectory.setBillType(tradingBox.getType());
|
|
|
+ archivesTrajectory.setCode(tradingBoxItem.getCode());
|
|
|
+ archivesTrajectory.setCreateTime(new Date());
|
|
|
+ archivesTrajectory.setCreateUser(AuthUtil.getUserId());
|
|
|
+ archivesTrajectory.setCreateUserName(AuthUtil.getUserName());
|
|
|
+ archivesTrajectory.setTenantId(AuthUtil.getTenantId());
|
|
|
+ archivesTrajectoryList.add(archivesTrajectory);
|
|
|
+ tradingBoxItem.setUpdateTime(new Date());
|
|
|
+ tradingBoxItem.setUpdateUser(AuthUtil.getUserId());
|
|
|
+ tradingBoxItem.setUpdateUserName(AuthUtil.getUserName());
|
|
|
+ tradingBoxItem.setRentingOutDate(null);
|
|
|
+ if (feeCenterList.size() == 1) {
|
|
|
+ tradingBoxItem.setRentEndDate(tradingBoxItem.getLeaseCommencementDate());
|
|
|
+ } else {
|
|
|
+ tradingBoxItem.setRentEndDate(feeCenter.getStorageDate());
|
|
|
+ }
|
|
|
+ itemList.add(tradingBoxItem);
|
|
|
}
|
|
|
}
|
|
|
- } else {
|
|
|
- throw new SecurityException("箱号:" + tradingBoxItem.getCode() + "未计算租金,撤销失败");
|
|
|
- }
|
|
|
- tradingBoxItem.setUpdateTime(new Date());
|
|
|
- tradingBoxItem.setUpdateUser(AuthUtil.getUserId());
|
|
|
- tradingBoxItem.setUpdateUserName(AuthUtil.getUserName());
|
|
|
- tradingBoxItem.setRentEndDate(tradingBoxFeesList.get(0).getRentEndDate());
|
|
|
- tradingBoxItem.setRentStartDate(tradingBoxFeesList.get(0).getRentStartDate());
|
|
|
- tradingBoxItem.setRentingOutDate(null);
|
|
|
- tradingBoxItemService.updateById(tradingBoxItem);
|
|
|
- if (ObjectUtils.isNotNull(tradingBoxItem.getCode())) {
|
|
|
- //更新箱档案信息
|
|
|
- Archives archivesR = archivesMapper.selectOne(new LambdaQueryWrapper<Archives>().eq(Archives::getIsDeleted, 0).eq(Archives::getTenantId, AuthUtil.getTenantId()).eq(Archives::getCode, tradingBoxItem.getCode()));
|
|
|
- if (ObjectUtils.isNotNull(archivesR)) {
|
|
|
- archivesR.setUpdateTime(new Date());
|
|
|
- archivesR.setUpdateUserName(AuthUtil.getUserName());
|
|
|
- archivesR.setUpdateUser(AuthUtil.getUserId());
|
|
|
- if ("ZR".equals(tradingBox.getType())) {
|
|
|
- archivesR.setStatus("待使用");
|
|
|
- } else {
|
|
|
- archivesR.setStatus("使用");
|
|
|
- }
|
|
|
- archivesMapper.updateById(archivesR);
|
|
|
- }
|
|
|
}
|
|
|
- }*/
|
|
|
+ }
|
|
|
+ if (!itemList.isEmpty()) {
|
|
|
+ tradingBox.setRentEndDate(itemList.get(0).getRentEndDate());
|
|
|
+ tradingBox.setRentingOutDate(null);
|
|
|
+ tradingBoxItemService.updateBatchById(itemList);
|
|
|
+ }
|
|
|
+ baseMapper.updateById(tradingBox);
|
|
|
+ if (!archivesListNew.isEmpty()) {
|
|
|
+ archivesService.saveOrUpdateBatch(archivesListNew);
|
|
|
+ }
|
|
|
+ if (!archivesTrajectoryList.isEmpty()) {
|
|
|
+ archivesTrajectoryService.saveBatch(archivesTrajectoryList);
|
|
|
+ }
|
|
|
+ tradingBox.setTradingBoxItemsList(tradingBoxItemList);
|
|
|
return tradingBox;
|
|
|
}
|
|
|
|
|
|
@@ -1208,7 +1346,7 @@ public class TradingBoxServiceImpl extends ServiceImpl<TradingBoxMapper, Trading
|
|
|
}
|
|
|
BusinessBillNo businessBillNo = new BusinessBillNo();
|
|
|
businessBillNo.setBusinessTypeId(businessType.getId());
|
|
|
- businessBillNo.setCode("FXH");
|
|
|
+ businessBillNo.setCode("FXH-OW");
|
|
|
R clientBillNo = businessBillNoService.getBillNoLos(businessBillNo);
|
|
|
if (!clientBillNo.isSuccess()) {
|
|
|
throw new RuntimeException("生成订单编号失败");
|
|
|
@@ -1488,9 +1626,19 @@ public class TradingBoxServiceImpl extends ServiceImpl<TradingBoxMapper, Trading
|
|
|
if (businessType == null) {
|
|
|
throw new RuntimeException("未找到可用业务类型");
|
|
|
}
|
|
|
+ String code;
|
|
|
+ if ("DL".equals(tradingBox.getType())) {
|
|
|
+ putBox.setBusType("代理箱");
|
|
|
+ putBox.setBoxClass("代理箱");
|
|
|
+ code = "FXH-DL";
|
|
|
+ } else {
|
|
|
+ putBox.setBusType("自有");
|
|
|
+ putBox.setBoxClass("自有");
|
|
|
+ code = "FXH-ZY";
|
|
|
+ }
|
|
|
BusinessBillNo businessBillNo = new BusinessBillNo();
|
|
|
businessBillNo.setBusinessTypeId(businessType.getId());
|
|
|
- businessBillNo.setCode("FXH");
|
|
|
+ businessBillNo.setCode(code);
|
|
|
R clientBillNo = businessBillNoService.getBillNoLos(businessBillNo);
|
|
|
if (!clientBillNo.isSuccess()) {
|
|
|
throw new RuntimeException("生成订单编号失败");
|
|
|
@@ -1506,6 +1654,18 @@ public class TradingBoxServiceImpl extends ServiceImpl<TradingBoxMapper, Trading
|
|
|
putBox.setBusType("自有");
|
|
|
putBox.setBoxClass("自有");
|
|
|
}
|
|
|
+ if (ObjectUtils.isNotNull(tradingBox.getInternalContainerNumber())) {
|
|
|
+ putBox.setInternalContainerNumber(tradingBox.getInternalContainerNumber());
|
|
|
+ } else {
|
|
|
+ BusinessBillNo businessBillNo1 = new BusinessBillNo();
|
|
|
+ businessBillNo1.setBusinessTypeId(businessType.getId());
|
|
|
+ businessBillNo1.setCode("FXH-N");
|
|
|
+ R clientBillNo1 = businessBillNoService.getBillNoLos(businessBillNo1);
|
|
|
+ if (!clientBillNo1.isSuccess()) {
|
|
|
+ throw new RuntimeException("生成订单编号失败");
|
|
|
+ }
|
|
|
+ putBox.setInternalContainerNumber((String) clientBillNo1.getData());
|
|
|
+ }
|
|
|
putBox.setPolId(detail.getPolId());
|
|
|
putBox.setPolCname(detail.getPolCname());
|
|
|
putBox.setPolEname(detail.getPolEname());
|