Jelajahi Sumber

1.获取符合拆分条件单据接口增加剔除本身逻辑
2.ow箱到导出箱号修改模板名称
3.进出场excel导入增加必填项校验
4.确认拆分接口增加同步放箱号,ow箱明细数据逻辑
5.ow(拿)客户还箱未生成箱轨迹
6.箱轨迹增加pod港口
7.调拨进场,退租出场箱量计算问题修改
8.放箱号明细,ow箱明细中pol免箱使天数赋值问题修改
9.空箱出场。海运出口配箱明细操作日志重复问题修改
10.ow箱计算超期箱使费问题修改
11.箱档案修改箱状态,箱动态
12.箱管调箱已保存的数据再次保存报差修改
13.撤销ow箱计算超期箱使费问题修改

纪新园 5 jam lalu
induk
melakukan
60510e7ac4

+ 21 - 0
blade-service-api/blade-los-api/src/main/java/org/springblade/los/box/entity/ArchivesTrajectory.java

@@ -304,6 +304,27 @@ public class ArchivesTrajectory implements Serializable {
 	private String portEname;
 
 	/**
+	 * POD港口
+	 */
+	@ApiModelProperty(value = "POD港口")
+	private Long podId;
+	/**
+	 * 当前港口编码
+	 */
+	@ApiModelProperty(value = "POD港口编码")
+	private String podCode;
+	/**
+	 * POD港口中文
+	 */
+	@ApiModelProperty(value = "POD港口中文")
+	private String podCname;
+	/**
+	 * POD港口英文
+	 */
+	@ApiModelProperty(value = "POD港口英文")
+	private String podEname;
+
+	/**
 	 * 提单号
 	 */
 	@ApiModelProperty(value = "提单号")

+ 12 - 0
blade-service-api/blade-los-api/src/main/java/org/springblade/los/box/entity/TradingBox.java

@@ -728,6 +728,18 @@ public class TradingBox implements Serializable {
 	private String appearanceType;
 
 	/**
+	 * 箱管备注
+	 */
+	@ApiModelProperty(value = "箱管备注")
+	private String boxTubeRemarks;
+
+	/**
+	 * 取消数量
+	 */
+	@ApiModelProperty(value = "取消数量")
+	private BigDecimal cancelNumber;
+
+	/**
 	 * 临时数据
 	 */
 	@TableField(exist = false)

+ 2 - 2
blade-service-api/blade-los-api/src/main/java/org/springblade/los/business/sea/entity/Bills.java

@@ -888,9 +888,9 @@ public class Bills implements Serializable {
 	@ApiModelProperty(value = "POL场站联系人电话")
 	private String cyTel;
 	/**
-	 * POL场站备注
+	 * POL场站备注(订舱备注)
 	 */
-	@ApiModelProperty(value = "POL场站备注")
+	@ApiModelProperty(value = "POL场站备注(订舱备注)")
 	private String cyRemarks;
 	/**
 	 * 场站背箱时间 yyyy-MM-dd hh:nn

+ 5 - 1
blade-service-api/blade-los-api/src/main/java/org/springblade/los/finance/fee/entity/FeeCenterItems.java

@@ -24,7 +24,6 @@ import lombok.Data;
 
 import java.io.Serializable;
 import java.math.BigDecimal;
-import java.time.LocalDateTime;
 import java.util.Date;
 
 /**
@@ -338,6 +337,11 @@ public class FeeCenterItems implements Serializable {
 	 */
 	@ApiModelProperty(value = "gateInFee")
 	private BigDecimal gateInFee;
+	/**
+	 * 批次编号
+	 */
+	@ApiModelProperty(value = "批次编号")
+	private Long batchNo;
 
 	/**
 	 * 财务日期

+ 28 - 17
blade-service/blade-los/src/main/java/org/springblade/los/Util/OwBoxUsageFeeUtils.java

@@ -2,6 +2,7 @@ package org.springblade.los.Util;
 
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
+import com.baomidou.mybatisplus.core.toolkit.StringUtils;
 import lombok.AllArgsConstructor;
 import org.springblade.core.secure.utils.AuthUtil;
 import org.springblade.core.tool.api.R;
@@ -94,12 +95,13 @@ public class OwBoxUsageFeeUtils {
 
 	/**
 	 * ow箱计算超期箱使费
-	 * @param detail ow箱单据
-	 * @param rentDate 计算截止时间
+	 *
+	 * @param detail          ow箱单据
+	 * @param rentDate        计算截止时间
 	 * @param putBoxItemsList 箱信息
-	 * @param type 操作类型
+	 * @param type            操作类型
 	 */
-	public Boolean calculateCost(TradingBox detail, Date rentDate, List<TradingBoxItem> putBoxItemsList,String type) {
+	public Boolean calculateCost(TradingBox detail, Date rentDate, List<TradingBoxItem> putBoxItemsList, String type) {
 		List<RentTerm> rentTermList = rentTermService.list(new LambdaQueryWrapper<RentTerm>()
 			.eq(RentTerm::getIsDeleted, 0)
 			.eq(RentTerm::getTenantId, AuthUtil.getTenantId())
@@ -109,9 +111,9 @@ public class OwBoxUsageFeeUtils {
 			.orderByAsc(RentTerm::getRiseDays)
 		);
 		if (rentTermList.isEmpty()) {
-			if ("1".equals(type)){
+			if ("1".equals(type)) {
 				throw new RuntimeException("请先维护租金条款");
-			}else{
+			} else {
 				return false;
 			}
 		}
@@ -120,9 +122,9 @@ public class OwBoxUsageFeeUtils {
 			.eq(BFees::getIsDeleted, 0)
 			.eq(BFees::getCode, "PerDiem"));
 		if (fees == null) {
-			if ("1".equals(type)){
+			if ("1".equals(type)) {
 				throw new RuntimeException("请先维护'PerDiem'费用基础信息");
-			}else{
+			} else {
 				return false;
 			}
 		}
@@ -131,7 +133,14 @@ public class OwBoxUsageFeeUtils {
 		SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
 		String exrateType = currencyUtils.standardCurrency(AuthUtil.getDeptId());
 		List<BCurExrate> curExrateList = currencyUtils.obtainRate(new Date(), "1", AuthUtil.getDeptId());
+		Long batchNo = System.currentTimeMillis();
 		for (TradingBoxItem item : putBoxItemsList) {
+			if (ObjectUtils.isNotNull(item.getRentEndDate()) && ObjectUtils.isNotNull(item.getPodEmptyContainerReturnDate())) {
+				if (dateFormat.format(item.getRentEndDate()).equals(dateFormat.format(item.getPodEmptyContainerReturnDate()))
+					&& !"0".equals(item.getWhetherCountRent())) {
+					continue;
+				}
+			}
 			Date endDate;
 			if (ObjectUtils.isNull(rentDate)) {
 				endDate = item.getPodEmptyContainerReturnDate();
@@ -149,6 +158,7 @@ public class OwBoxUsageFeeUtils {
 			int month = calendar.get(Calendar.MONTH) + 1; // 获取月份(注意需加上1,因为月份从0开始计数)
 			int day = calendar.get(Calendar.DATE);
 			FeeCenterItems feeCenterItems = new FeeCenterItems();
+			feeCenterItems.setBatchNo(batchNo);
 			feeCenterItems.setBranchId(AuthUtil.getDeptId());
 			feeCenterItems.setCreateUser(AuthUtil.getUserId());
 			feeCenterItems.setCreateUserName(detail.getCreateUserName());
@@ -276,6 +286,7 @@ public class OwBoxUsageFeeUtils {
 			item.setUpdateUserName(AuthUtil.getUserName());
 			item.setUpdateUser(AuthUtil.getUserId());
 			item.setRentEndDate(endDate);
+			item.setWhetherCountRent("1");
 			item.setCount(item.getCount() + 1);
 		}
 		tradingBoxItemService.updateBatchById(putBoxItemsList);
@@ -297,7 +308,7 @@ public class OwBoxUsageFeeUtils {
 	 * @param type                  操作类型  1=excel导入直接提示  2=api记录并修改状态为失败 3=只记录
 	 */
 	public Boolean countOverdueFee(List<PutBox> putBoxList, List<TradingBox> tradingBoxList, List<TradingBoxItem> tradingBoxItemOldList,
-									List<Containers> containersListNew, List<PutBoxItems> putBoxItems
+								   List<Containers> containersListNew, List<PutBoxItems> putBoxItems
 		, BoxDynamicsRecord boxDynamicsRecord, String type) throws IOException {
 		List<FeeCenter> feeCenterListD = new ArrayList<>();
 		List<FeeCenter> feeCenterListC = new ArrayList<>();
@@ -498,13 +509,13 @@ public class OwBoxUsageFeeUtils {
 			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)
+				List<Long> masterIdList = billsArrayList.stream().filter(e -> "MH".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));
+						.in(Bills::getId, masterIdList));
 					List<FeeCenter> feeCenterListM = feeCenterService.list(new LambdaQueryWrapper<FeeCenter>()
 						.eq(FeeCenter::getTenantId, AuthUtil.getTenantId())
 						.eq(FeeCenter::getIsDeleted, 0)
@@ -656,7 +667,7 @@ public class OwBoxUsageFeeUtils {
 	 * @param type                  操作类型  1=excel导入直接提示  2=api记录并修改状态为失败 3=只记录
 	 */
 	public Boolean countOverdueFeeWHFK(List<PutBox> putBoxList, List<TradingBox> tradingBoxList, List<TradingBoxItem> tradingBoxItemOldList,
-										List<Bills> billsList, List<PutBoxItems> putBoxItems
+									   List<Bills> billsList, List<PutBoxItems> putBoxItems
 		, BoxDynamicsRecord boxDynamicsRecord, String type) throws IOException {
 		List<FeeCenter> feeCenterListD = new ArrayList<>();
 		List<FeeCenter> feeCenterListC = new ArrayList<>();
@@ -856,8 +867,8 @@ public class OwBoxUsageFeeUtils {
 	 * @param type                  操作类型  1=excel导入直接提示  2=api记录并修改状态为失败 3=只记录
 	 */
 	public Boolean countOverdueFeeV1(Bills billsHYJK, List<TradingBox> tradingBoxList,
-									  List<TradingBoxItem> tradingBoxItemOldList, List<PutBoxItems> putBoxItemsOldList,
-									  List<PutBox> putBoxList, BoxDynamicsRecord boxDynamicsRecord, String type) throws IOException {
+									 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<>();
@@ -1170,8 +1181,8 @@ public class OwBoxUsageFeeUtils {
 	 * @param exrateType       本币币别
 	 */
 	public FeeCenter addFeeCenter(PutBoxItems item, Bills bills, BFees fees,
-								   List<StorageFeesItems> storageFeesItems, List<BCurExrate> curExrateList,
-								   int overdueDays, String exrateType) {
+								  List<StorageFeesItems> storageFeesItems, List<BCurExrate> curExrateList,
+								  int overdueDays, String exrateType) {
 		FeeCenter feeCenter = new FeeCenter();
 		feeCenter.setBillType(bills.getBillType());
 		feeCenter.setCorpType("国内同行及代理");
@@ -1345,7 +1356,7 @@ public class OwBoxUsageFeeUtils {
 	 * @param type              操作类型  1=excel导入直接提示  2=api记录并修改状态为失败 3=只记录
 	 */
 	public Boolean generateAccBills(List<FeeCenter> feeCenterList, Bills billsHYJK, String exrateType,
-									 BoxDynamicsRecord boxDynamicsRecord, String type) throws IOException {
+									BoxDynamicsRecord boxDynamicsRecord, String type) throws IOException {
 		List<FeeCenter> feeCenterList1 = new ArrayList<>();
 		BusinessType businessType = bBusinessTypeService.getOne(new LambdaQueryWrapper<BusinessType>()
 			.eq(BusinessType::getTenantId, AuthUtil.getTenantId())

+ 1 - 1
blade-service/blade-los/src/main/java/org/springblade/los/box/dynamics/controller/BoxDynamicsRecordController.java

@@ -190,7 +190,7 @@ public class BoxDynamicsRecordController extends BladeController {
 	@GetMapping("/exportTemplateById")
 	public void exportTemplateById(HttpServletResponse response,@RequestParam ("id") String id ,@RequestParam ("ids") String ids) {
 		List<EmptyContainerAppearance> list = boxDynamicsRecordService.exportTemplateById(id,ids);
-		ExcelUtil.export(response, "导入模板", "导入模板", list, EmptyContainerAppearance.class);
+		ExcelUtil.export(response, "OW箱-客户还箱", "还箱明细", list, EmptyContainerAppearance.class);
 	}
 
 	/**

+ 251 - 29
blade-service/blade-los/src/main/java/org/springblade/los/box/dynamics/service/impl/BoxDynamicsRecordServiceImpl.java

@@ -150,10 +150,33 @@ public class BoxDynamicsRecordServiceImpl extends ServiceImpl<BoxDynamicsRecordM
 		if (CollectionUtils.isEmpty(excelList)) {
 			throw new SecurityException("数据不能为空");
 		}
+		String err = "";
+		int count = 1;
 		for (EmptyContainerAppearance item : excelList) {
 			if (ObjectUtils.isNotNull(item.getBoxCode())) {
 				item.setBoxCode(item.getBoxCode().toUpperCase());
 			}
+			if (ObjectUtils.isNull(item.getContainerNumber())) {
+				err = "第" + count + "行放箱号不能为空,";
+			}
+			if (ObjectUtils.isNull(item.getBoxCode())) {
+				err = "第" + count + "行箱号不能为空,";
+			}
+			if (ObjectUtils.isNull(item.getBoxType())) {
+				err = "第" + count + "行箱型不能为空,";
+			}
+			if (ObjectUtils.isNull(item.getPortName())) {
+				err = "第" + count + "行港口不能为空,";
+			}
+			if (ObjectUtils.isNull(item.getStationName())) {
+				err = "第" + count + "行场站不能为空,";
+			}
+			if (ObjectUtils.isNull(item.getObjective())) {
+				err = "第" + count + "行目的不能为空,";
+			}
+		}
+		if (ObjectUtils.isNotNull(err)) {
+			throw new RemoteException(err);
 		}
 		List<String> boxCodeList = excelList.stream().map(EmptyContainerAppearance::getBoxCode).filter(Objects::nonNull)
 			.distinct().collect(Collectors.toList());
@@ -183,7 +206,7 @@ public class BoxDynamicsRecordServiceImpl extends ServiceImpl<BoxDynamicsRecordM
 		List<String> boxType = excelList.stream().map(EmptyContainerAppearance::getBoxType).filter(Objects::nonNull)
 			.distinct().collect(Collectors.toList());
 		List<BCntrTypes> boxTypeList = new ArrayList<>();
-		if (!portName.isEmpty()) {
+		if (!boxType.isEmpty()) {
 			boxTypeList = cntrTypesService.list(new LambdaQueryWrapper<BCntrTypes>()
 				.eq(BCntrTypes::getTenantId, AuthUtil.getTenantId())
 				.eq(BCntrTypes::getIsDeleted, 0)
@@ -640,6 +663,8 @@ public class BoxDynamicsRecordServiceImpl extends ServiceImpl<BoxDynamicsRecordM
 					item.setUpdateUserName(AuthUtil.getUserName());
 					int version = StringUtil.isBlank(item.getVersion()) ? 1 : Integer.parseInt(item.getVersion());
 					item.setVersion(String.valueOf(version + 1));
+					item.setCode((ObjectUtils.isNotNull(item.getCode()) ? item.getCode() + "," : "") + itemList.stream()
+						.map(TradingBoxItem::getCode).collect(Collectors.joining(",")));
 					tradingBoxMapper.updateById(item);
 				}
 			}
@@ -975,6 +1000,7 @@ public class BoxDynamicsRecordServiceImpl extends ServiceImpl<BoxDynamicsRecordM
 	}
 
 	@Override
+	@Transactional(rollbackFor = Exception.class)
 	public R splitBoxNumber(Long billId, Long billIdNew, String containersIds) {
 		Bills bills = billsMapper.selectById(billId);
 		Bills billsNew = billsMapper.selectById(billIdNew);
@@ -1001,7 +1027,14 @@ public class BoxDynamicsRecordServiceImpl extends ServiceImpl<BoxDynamicsRecordM
 		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());
+		List<String> boxCode = containersList.stream().map(Containers::getCntrNo).distinct().collect(Collectors.toList());
 		for (Containers item : containersList) {
+			if (ObjectUtils.isNull(item.getCntrNo())) {
+				throw new RuntimeException("箱号为空不能拆单!");
+			}
+			if (ObjectUtils.isNull(item.getContainerNumber())) {
+				throw new RuntimeException("箱号:" + item.getCntrNo() + "未出场!");
+			}
 			item.setPid(billsNew.getId());
 			item.setHblno(billsNew.getHblno());
 			item.setMblno(billsNew.getMblno());
@@ -1076,6 +1109,7 @@ public class BoxDynamicsRecordServiceImpl extends ServiceImpl<BoxDynamicsRecordM
 					} else {
 						seaContainerNumberItem = new SeaContainerNumberItem();
 						BeanUtil.copyProperties(containerNumberItem, seaContainerNumberItem);
+						seaContainerNumberItem.setId(null);
 						seaContainerNumberItem.setUpdateUser(null);
 						seaContainerNumberItem.setUpdateUserName(null);
 						seaContainerNumberItem.setUpdateTime(null);
@@ -1095,9 +1129,9 @@ public class BoxDynamicsRecordServiceImpl extends ServiceImpl<BoxDynamicsRecordM
 				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.setQuantity(preContainers1.getQuantity() + boxNumber);
+					preContainers1.setActualQuantity(preContainers1.getQuantity());
+					preContainers1.setOccupyNum(preContainers1.getQuantity());
 					preContainers1.setUpdateUser(AuthUtil.getUserId());
 					preContainers1.setUpdateUserName(AuthUtil.getUserName());
 					preContainers1.setUpdateTime(new Date());
@@ -1212,6 +1246,68 @@ public class BoxDynamicsRecordServiceImpl extends ServiceImpl<BoxDynamicsRecordM
 		}
 		if (!containerNumberItems.isEmpty()) {
 			seaContainerNumberItemService.saveOrUpdateBatch(containerNumberItems);
+			List<Long> srcIdList = containerNumberItems.stream().map(SeaContainerNumberItem::getSrcId)
+				.filter(Objects::nonNull).distinct().collect(Collectors.toList());
+			if (!srcIdList.isEmpty()) {
+				List<PutBoxItems> putBoxItemsList = putBoxItemsService.list(new LambdaQueryWrapper<PutBoxItems>()
+					.eq(PutBoxItems::getTenantId, AuthUtil.getTenantId())
+					.eq(PutBoxItems::getIsDeleted, 0)
+					.in(PutBoxItems::getPid, srcIdList)
+					.in(PutBoxItems::getBoxCode, boxCode));
+				if (!putBoxItemsList.isEmpty()) {
+					for (PutBoxItems putBoxItem : putBoxItemsList) {
+						putBoxItem.setMblno(billsNew.getMblno());
+						putBoxItem.setHblno(billsNew.getHblno());
+						putBoxItem.setAgentName(billsNew.getForeignAgencyCnName());
+						putBoxItem.setVoyage(billsNew.getVoyageNo());
+						putBoxItem.setShipNameId(billsNew.getVesselId());
+						putBoxItem.setAgentName(billsNew.getForeignAgencyCnName());
+						putBoxItem.setShipCname(billsNew.getVesselCnName());
+						putBoxItem.setShipEname(billsNew.getVesselEnName());
+						putBoxItem.setEtd(billsNew.getEtd());
+						putBoxItem.setActualEtd(billsNew.getActualEtd());
+						putBoxItem.setUpdateTime(new Date());
+						putBoxItem.setUpdateUserName(AuthUtil.getUserName());
+						putBoxItem.setUpdateUser(AuthUtil.getUserId());
+					}
+					putBoxItemsService.updateBatchById(putBoxItemsList);
+					List<PutBox> putBoxList = putBoxService.list(new LambdaQueryWrapper<PutBox>()
+						.eq(PutBox::getTenantId, AuthUtil.getTenantId())
+						.eq(PutBox::getIsDeleted, 0)
+						.in(PutBox::getId, srcIdList));
+					if (!putBoxList.isEmpty()) {
+						List<Long> srcIdOWList = putBoxList.stream().map(PutBox::getSrcId)
+							.filter(Objects::nonNull).distinct().collect(Collectors.toList());
+						if (!srcIdOWList.isEmpty()) {
+							List<TradingBoxItem> tradingBoxItemList = tradingBoxItemService.list(new LambdaQueryWrapper<TradingBoxItem>()
+								.eq(TradingBoxItem::getTenantId, AuthUtil.getTenantId())
+								.eq(TradingBoxItem::getIsDeleted, 0)
+								.in(TradingBoxItem::getPid, srcIdOWList)
+								.in(TradingBoxItem::getCode, boxCode));
+							if (!putBoxItemsList.isEmpty()) {
+								for (TradingBoxItem tradingBoxItem : tradingBoxItemList) {
+									tradingBoxItem.setAgentName(billsNew.getForeignAgencyCnName());
+									tradingBoxItem.setActualEtd(billsNew.getActualEtd());
+									tradingBoxItem.setMblno(billsNew.getMblno());
+									tradingBoxItem.setHblno(billsNew.getHblno());
+									tradingBoxItem.setCorpId(billsNew.getCorpId());
+									tradingBoxItem.setCorpName(billsNew.getCorpCnName());
+									tradingBoxItem.setVoyage(billsNew.getVoyageNo());
+									tradingBoxItem.setShipNameId(billsNew.getVesselId());
+									tradingBoxItem.setShipCname(billsNew.getVesselCnName());
+									tradingBoxItem.setShipEname(billsNew.getVesselEnName());
+									tradingBoxItem.setPolFreeBoxUseDays(billsNew.getPolFreeBoxUseDays());
+									tradingBoxItem.setEtd(billsNew.getEtd());
+									tradingBoxItem.setUpdateTime(new Date());
+									tradingBoxItem.setUpdateUserName(AuthUtil.getUserName());
+									tradingBoxItem.setUpdateUser(AuthUtil.getUserId());
+								}
+								tradingBoxItemService.updateBatchById(tradingBoxItemList);
+							}
+						}
+					}
+				}
+			}
 		}
 		billsMapper.updateById(bills);
 		billsMapper.updateById(billsNew);
@@ -1412,7 +1508,6 @@ public class BoxDynamicsRecordServiceImpl extends ServiceImpl<BoxDynamicsRecordM
 							putBoxItem.setContainerNumber(item.getContainerNumber());
 							putBoxItem.setBoxCode(item.getBoxCode());
 							putBoxItem.setBoxType(item.getBoxType());
-							putBoxItem.setBoxClass(putBox.getBoxClass());
 							putBoxItem.setTenantId(tenantId);
 							putBoxItem.setCreateUser(AuthUtil.getUserId());
 							putBoxItem.setCreateUserName(AuthUtil.getUserName());
@@ -1426,7 +1521,6 @@ public class BoxDynamicsRecordServiceImpl extends ServiceImpl<BoxDynamicsRecordM
 						putBoxItem.setContainerNumber(item.getContainerNumber());
 						putBoxItem.setBoxCode(item.getBoxCode());
 						putBoxItem.setBoxType(item.getBoxType());
-						putBoxItem.setBoxClass(putBox.getBoxClass());
 						putBoxItem.setTenantId(tenantId);
 						putBoxItem.setCreateUser(AuthUtil.getUserId());
 						putBoxItem.setCreateUserName(AuthUtil.getUserName());
@@ -1676,6 +1770,12 @@ public class BoxDynamicsRecordServiceImpl extends ServiceImpl<BoxDynamicsRecordM
 							archivesTrajectory.setBoxDynamics(BoxDynamicsEnums.getName(dynamicsRecordItems.getObjective()));
 							archivesTrajectory.setNewDate(dynamicsRecordItems.getApproachExitDate());
 						}
+						if (ObjectUtils.isNotNull(tradingBox.getPodId()) && !tradingBox.getPodId().contains(",")) {
+							archivesTrajectory.setPodId(Long.parseLong(tradingBox.getPodId()));
+							archivesTrajectory.setPodCode(tradingBox.getPodCode());
+							archivesTrajectory.setPodCname(tradingBox.getPodCname());
+							archivesTrajectory.setPodEname(tradingBox.getPodEname());
+						}
 						archivesTrajectory.setStatus(archivesTrajectory.getBoxDynamics());
 						archivesTrajectory.setCorpId(item.getBoxEastId());
 						archivesTrajectory.setCorpName(item.getBoxEastName());
@@ -1863,7 +1963,7 @@ public class BoxDynamicsRecordServiceImpl extends ServiceImpl<BoxDynamicsRecordM
 						archives.setUpdateTime(new Date());
 						archives.setUpdateUserName(AuthUtil.getUserName());
 						archives.setUpdateUser(AuthUtil.getUserId());
-						if (ObjectUtils.isNotNull(item.getSrcBoxStatus()) && !"待使用".equals(archives.getStatus())) {
+						if (ObjectUtils.isNotNull(item.getSrcBoxStatus())) {
 							archives.setStatus(item.getSrcBoxStatus());
 							archives.setBoxDynamics(item.getSrcBoxDynamics());
 							archives.setBoxStatus(item.getSrcBoxGoodBad());
@@ -1927,8 +2027,8 @@ public class BoxDynamicsRecordServiceImpl extends ServiceImpl<BoxDynamicsRecordM
 							}
 						}
 						if ("HX".equals(type)) {
-							if (!"待使用".equals(putBoxItem.getStatus())) {
-								throw new RemoteException("箱号:" + putBoxItem.getBoxCode() + "状态不是待使用,撤销还箱失败");
+							if (!"已还箱".equals(putBoxItem.getStatus())) {
+								throw new RemoteException("箱号:" + putBoxItem.getBoxCode() + "状态不是已还箱,撤销还箱失败");
 							}
 							putBoxItem.setPodEmptyContainerReturnDate(null);
 							putBoxItem.setPodStationId(null);
@@ -2022,8 +2122,14 @@ public class BoxDynamicsRecordServiceImpl extends ServiceImpl<BoxDynamicsRecordM
 						item.setVersion(item.getVersion() + 1);
 						if ("JC,DBJ,TG".contains(type)) {
 							if (!"OW(拿)".equals(item.getBoxClass()) && !"DBJ".equals(type)) {
+								if (item.getRemainingNum()<count){
+									throw new RemoteException("可用数量不足,撤销失败");
+								}
 								item.setRemainingNum(item.getRemainingNum() - Integer.parseInt(count + ""));
 							}
+							if (item.getStorageNum()<count){
+								throw new RemoteException("盘存数量不足,撤销失败");
+							}
 							item.setStorageNum(item.getStorageNum() - Integer.parseInt(count + ""));
 							putBoxes.add(item);
 						} else if ("DBC,TZ".contains(type)) {
@@ -2048,10 +2154,11 @@ public class BoxDynamicsRecordServiceImpl extends ServiceImpl<BoxDynamicsRecordM
 											e.getContainerNumber().equals(item.getContainerNumber()) && boxList.contains(e.getCntrNo())).count();
 										boolean whetherAppearStatus = false;
 										if (!containerNumberItemList.isEmpty()) {
-											SeaContainerNumberItem containerNumberItems = containerNumberItemList.stream().filter(e -> e.getSrcId().equals(item.getId())).findFirst().orElse(null);
+											SeaContainerNumberItem containerNumberItems = containerNumberItemList.stream()
+												.filter(e -> e.getSrcId().equals(item.getId())).findFirst().orElse(null);
 											if (containerNumberItems != null) {
 												containerNumberItems.setOutNum(containerNumberItems.getOutNum() - Integer.parseInt(size + ""));
-												if (containerNumberItems.getOutNum().equals(containerNumberItems.getOccupyNum())) {
+												if (!containerNumberItems.getOutNum().equals(containerNumberItems.getOccupyNum())) {
 													containerNumberItems.setWhetherAppearStatus("0");
 													whetherAppearStatus = true;
 												}
@@ -2466,9 +2573,6 @@ public class BoxDynamicsRecordServiceImpl extends ServiceImpl<BoxDynamicsRecordM
 						archives.setStationCode(recordItems.getStationCname());
 						archives.setStationCname(recordItems.getStationEname());
 						archives.setStationEname(recordItems.getStationCode());
-						archives.setContainerNumberOw("");
-						archives.setContainerNumberTypeOw("");
-						archives.setBillNo("");
 						archives.setTemporaryId(recordItems.getTemporaryId());
 						archivesArrayList.add(archives);
 						if (!containerNumberType.equals("OW(拿)")) {
@@ -2579,11 +2683,20 @@ public class BoxDynamicsRecordServiceImpl extends ServiceImpl<BoxDynamicsRecordM
 					if (!putBoxNewList.isEmpty()) {
 						for (PutBox item : putBoxNewList) {
 							if (!putBoxItemsNewList.isEmpty()) {
-								long count = putBoxItemsNewList.stream().filter(e -> e.getPid().equals(item.getId())).count();
-								item.setTotalNum((ObjectUtils.isNull(item.getTotalNum()) ? 0 : item.getTotalNum())
-									+ Integer.parseInt(count + ""));
-								item.setRemainingNum((ObjectUtils.isNull(item.getRemainingNum()) ? 0 : item.getRemainingNum()) + Integer.parseInt(count + ""));
-								item.setStorageNum((ObjectUtils.isNull(item.getStorageNum()) ? 0 : item.getStorageNum()) + Integer.parseInt(count + ""));
+								List<PutBoxItems> putBoxItems = putBoxItemsNewList.stream().filter(e -> e.getPid().equals(item.getId())).collect(Collectors.toList());
+								if (!putBoxItems.isEmpty()) {
+									item.setTotalNum((ObjectUtils.isNull(item.getTotalNum()) ? 0 : item.getTotalNum())
+										+ putBoxItems.size());
+									item.setRemainingNum((ObjectUtils.isNull(item.getRemainingNum()) ? 0 : item.getRemainingNum()) + putBoxItems.size());
+									item.setStorageNum((ObjectUtils.isNull(item.getStorageNum()) ? 0 : item.getStorageNum()) + putBoxItems.size());
+									for (PutBoxItems boxItems : putBoxItems) {
+										if (ObjectUtils.isNotNull(item.getCode())) {
+											item.setCode(item.getCode() + "," + boxItems.getBoxCode());
+										} else {
+											item.setCode(boxItems.getBoxCode());
+										}
+									}
+								}
 								item.setVersion(ObjectUtils.isNull(item.getVersion()) ? 1 : item.getVersion() + 1);
 							}
 						}
@@ -2617,6 +2730,12 @@ public class BoxDynamicsRecordServiceImpl extends ServiceImpl<BoxDynamicsRecordM
 									archivesTrajectory.setBoxDynamics(BoxDynamicsEnums.getName(dynamicsRecordItems.getObjective()));
 									archivesTrajectory.setNewDate(dynamicsRecordItems.getApproachExitDate());
 								}
+								if (ObjectUtils.isNotNull(putBox.getPodId()) && !putBox.getPodId().contains(",")) {
+									archivesTrajectory.setPodId(Long.parseLong(putBox.getPodId()));
+									archivesTrajectory.setPodCode(putBox.getPodCode());
+									archivesTrajectory.setPodCname(putBox.getPodCname());
+									archivesTrajectory.setPodEname(putBox.getPodEname());
+								}
 								archivesTrajectory.setStatus(archivesTrajectory.getBoxDynamics());
 								archivesTrajectory.setBillType(putBox.getBoxClass());
 								archivesTrajectory.setCode(item.getBoxCode());
@@ -2651,6 +2770,75 @@ public class BoxDynamicsRecordServiceImpl extends ServiceImpl<BoxDynamicsRecordM
 								archivesTrajectoryMapper.insert(archivesTrajectory);
 							}
 						}
+					} else {
+						if (!putBoxItemsOldList.isEmpty()) {
+							for (PutBoxItems item : putBoxItemsOldList) {
+								PutBox putBox = putBoxes.stream().filter(e -> e.getId().equals(item.getPid())).findFirst().orElse(null);
+								if (putBox != null) {
+									//记录箱轨迹信息
+									ArchivesTrajectory archivesTrajectory = new ArchivesTrajectory();
+									archivesTrajectory.setPortId(putBox.getPolId());
+									archivesTrajectory.setPortCode(putBox.getPolCode());
+									archivesTrajectory.setPortCname(putBox.getPolCname());
+									archivesTrajectory.setPortEname(putBox.getPolEname());
+									archivesTrajectory.setStationId(putBox.getPolStationId());
+									archivesTrajectory.setStationCode(putBox.getPolStationCode());
+									archivesTrajectory.setStationCname(putBox.getPolStationCname());
+									archivesTrajectory.setStationEname(putBox.getPolStationEname());
+									archivesTrajectory.setContainerNumber(item.getContainerNumber());
+									archivesTrajectory.setBoxStatus(item.getBoxStatus());
+									archivesTrajectory.setBoxType(item.getBoxType());
+									archivesTrajectory.setBoxCategory(item.getBoxClass());
+									archivesTrajectory.setBoxEastId(item.getBoxEastId());
+									archivesTrajectory.setBoxEastName(item.getBoxEastName());
+									archivesTrajectory.setMblno(item.getMblno());
+									archivesTrajectory.setHblno(item.getHblno());
+									BoxDynamicsRecordItems dynamicsRecordItems = itemsListFC.stream().filter(e -> e.getBoxCode().equals(item.getBoxCode())).findFirst().orElse(null);
+									if (dynamicsRecordItems != null) {
+										archivesTrajectory.setBoxDynamics(BoxDynamicsEnums.getName(dynamicsRecordItems.getObjective()));
+										archivesTrajectory.setNewDate(dynamicsRecordItems.getApproachExitDate());
+									}
+									if (ObjectUtils.isNotNull(putBox.getPodId()) && !putBox.getPodId().contains(",")) {
+										archivesTrajectory.setPodId(Long.parseLong(putBox.getPodId()));
+										archivesTrajectory.setPodCode(putBox.getPodCode());
+										archivesTrajectory.setPodCname(putBox.getPodCname());
+										archivesTrajectory.setPodEname(putBox.getPodEname());
+									}
+									archivesTrajectory.setStatus(archivesTrajectory.getBoxDynamics());
+									archivesTrajectory.setBillType(putBox.getBoxClass());
+									archivesTrajectory.setCode(item.getBoxCode());
+									archivesTrajectory.setCreateTime(new Date());
+									archivesTrajectory.setCreateUser(AuthUtil.getUserId());
+									archivesTrajectory.setCreateUserName(AuthUtil.getUserName());
+									archivesTrajectory.setTenantId(AuthUtil.getTenantId());
+									archivesTrajectory.setSrcId(putBox.getId());
+									archivesTrajectory.setEtd(item.getEtd());
+									archivesTrajectory.setPolCyId(item.getPolCyId());
+									archivesTrajectory.setPolCyCode(item.getPolCyCode());
+									archivesTrajectory.setPolCyCname(item.getPolCyCname());
+									archivesTrajectory.setPolCyEname(item.getPolCyEname());
+									archivesTrajectory.setPolFreeBoxUseDays(item.getPolFreeBoxUseDays());
+									archivesTrajectory.setPolPreAppearanceDate(item.getPolPreAppearanceDate());
+									archivesTrajectory.setPolStationEmptyContainerExitDate(item.getPolStationEmptyContainerExitDate());
+									archivesTrajectory.setPolReturnDate(item.getPolReturnDate());
+									archivesTrajectory.setPolOverdueBoxUseDays(item.getPolOverdueBoxUseDays());
+									archivesTrajectory.setEta(item.getEta());
+									archivesTrajectory.setPodEmptyContainerReturnDate(item.getPodEmptyContainerReturnDate());
+									archivesTrajectory.setPodStationId(item.getPodStationId());
+									archivesTrajectory.setPodStationCode(item.getPodStationCode());
+									archivesTrajectory.setPodStationCname(item.getPodStationCname());
+									archivesTrajectory.setPodStationEname(item.getPodStationEname());
+									archivesTrajectory.setPodFreeBoxUseDays(item.getPodFreeBoxUseDays());
+									archivesTrajectory.setPodBoxUseDays(item.getPodBoxUseDays());
+									archivesTrajectory.setShipNameId(item.getShipNameId());
+									archivesTrajectory.setShipCname(item.getShipCname());
+									archivesTrajectory.setShipEname(item.getShipEname());
+									archivesTrajectory.setShipCode(item.getShipCode());
+									archivesTrajectory.setVoyage(item.getVoyage());
+									archivesTrajectoryMapper.insert(archivesTrajectory);
+								}
+							}
+						}
 					}
 					if (!putBoxItemsOldList.isEmpty()) {
 						putBoxItemsService.updateBatchById(putBoxItemsOldList);
@@ -3083,6 +3271,12 @@ public class BoxDynamicsRecordServiceImpl extends ServiceImpl<BoxDynamicsRecordM
 								archivesTrajectory.setBoxDynamics(BoxDynamicsEnums.getName(dynamicsRecordItems.getObjective()));
 								archivesTrajectory.setNewDate(dynamicsRecordItems.getApproachExitDate());
 							}
+							if (ObjectUtils.isNotNull(tradingBox.getPodId()) && !tradingBox.getPodId().contains(",")) {
+								archivesTrajectory.setPodId(Long.parseLong(tradingBox.getPodId()));
+								archivesTrajectory.setPodCode(tradingBox.getPodCode());
+								archivesTrajectory.setPodCname(tradingBox.getPodCname());
+								archivesTrajectory.setPodEname(tradingBox.getPodEname());
+							}
 							archivesTrajectory.setStatus(archivesTrajectory.getBoxDynamics());
 							archivesTrajectory.setCorpId(item.getBoxEastId());
 							archivesTrajectory.setCorpName(item.getBoxEastName());
@@ -3562,6 +3756,12 @@ public class BoxDynamicsRecordServiceImpl extends ServiceImpl<BoxDynamicsRecordM
 									archivesTrajectory.setBoxDynamics(BoxDynamicsEnums.getName(dynamicsRecordItems.getObjective()));
 									archivesTrajectory.setNewDate(dynamicsRecordItems.getApproachExitDate());
 								}
+								if (ObjectUtils.isNotNull(putBox.getPodId()) && !putBox.getPodId().contains(",")) {
+									archivesTrajectory.setPodId(Long.parseLong(putBox.getPodId()));
+									archivesTrajectory.setPodCode(putBox.getPodCode());
+									archivesTrajectory.setPodCname(putBox.getPodCname());
+									archivesTrajectory.setPodEname(putBox.getPodEname());
+								}
 								archivesTrajectory.setStatus(archivesTrajectory.getBoxDynamics());
 								archivesTrajectory.setBillType(putBox.getBoxClass());
 								archivesTrajectory.setCode(item.getBoxCode());
@@ -3783,6 +3983,12 @@ public class BoxDynamicsRecordServiceImpl extends ServiceImpl<BoxDynamicsRecordM
 								archivesTrajectory.setBoxDynamics(BoxDynamicsEnums.getName(dynamicsRecordItems.getObjective()));
 								archivesTrajectory.setNewDate(dynamicsRecordItems.getApproachExitDate());
 							}
+							if (ObjectUtils.isNotNull(putBox.getPodId()) && !putBox.getPodId().contains(",")) {
+								archivesTrajectory.setPodId(Long.parseLong(putBox.getPodId()));
+								archivesTrajectory.setPodCode(putBox.getPodCode());
+								archivesTrajectory.setPodCname(putBox.getPodCname());
+								archivesTrajectory.setPodEname(putBox.getPodEname());
+							}
 							archivesTrajectory.setStatus(archivesTrajectory.getBoxDynamics());
 							archivesTrajectory.setBillType(putBox.getBoxClass());
 							archivesTrajectory.setCode(item.getBoxCode());
@@ -4168,20 +4374,19 @@ public class BoxDynamicsRecordServiceImpl extends ServiceImpl<BoxDynamicsRecordM
 						if (!putBoxItems.isEmpty()) {
 							count = putBoxItems.stream().filter(e -> item.getId().equals(e.getPid())).count();
 						}
-						item.setTotalNum(item.getTotalNum() - Integer.parseInt(count + ""));
 						item.setStorageNum(item.getStorageNum() - Integer.parseInt(count + ""));
 						if (item.getStorageNum() < 0) {
 							failureHandling(type, boxDynamicsRecord, "放箱号:" + item.getContainerNumber() + "剩余场地盘存小于本次导入箱数");
 							return false;
 						}
-						item.setRemainingNum(item.getRemainingNum() - Integer.parseInt(count + ""));
-						if (item.getStorageNum() < 0) {
-							failureHandling(type, boxDynamicsRecord, "放箱号:" + item.getContainerNumber() + "剩余可用小于本次导入箱数");
-							return false;
-						}
-						item.setVersion(ObjectUtils.isNull(item.getVersion()) ? 1 : item.getVersion() + 1);
-						putBoxList1.add(item);
-						if (!tradingBoxes.isEmpty()) {
+						if (tradingBoxes.isEmpty()) {
+							item.setTotalNum(item.getTotalNum() - Integer.parseInt(count + ""));
+							item.setRemainingNum(item.getRemainingNum() - Integer.parseInt(count + ""));
+							if (item.getRemainingNum() < 0) {
+								failureHandling(type, boxDynamicsRecord, "放箱号:" + item.getContainerNumber() + "剩余可用小于本次导入箱数");
+								return false;
+							}
+						} else {
 							TradingBox tradingBox = tradingBoxes.stream().filter(e -> e.getId().equals(item.getSrcId())).findFirst().orElse(null);
 							if (tradingBox != null) {
 								if (ObjectUtils.isNotNull(tradingBox.getCode())) {
@@ -4202,6 +4407,8 @@ public class BoxDynamicsRecordServiceImpl extends ServiceImpl<BoxDynamicsRecordM
 								tradingBoxMapper.updateById(tradingBox);
 							}
 						}
+						item.setVersion(ObjectUtils.isNull(item.getVersion()) ? 1 : item.getVersion() + 1);
+						putBoxList1.add(item);
 					}
 					putBoxService.saveOrUpdateBatch(putBoxList1);
 				}
@@ -4233,6 +4440,12 @@ public class BoxDynamicsRecordServiceImpl extends ServiceImpl<BoxDynamicsRecordM
 								archivesTrajectory.setBoxDynamics(BoxDynamicsEnums.getName(dynamicsRecordItems.getObjective()));
 								archivesTrajectory.setNewDate(dynamicsRecordItems.getApproachExitDate());
 							}
+							if (ObjectUtils.isNotNull(tradingBox.getPodId()) && !tradingBox.getPodId().contains(",")) {
+								archivesTrajectory.setPodId(Long.parseLong(tradingBox.getPodId()));
+								archivesTrajectory.setPodCode(tradingBox.getPodCode());
+								archivesTrajectory.setPodCname(tradingBox.getPodCname());
+								archivesTrajectory.setPodEname(tradingBox.getPodEname());
+							}
 							archivesTrajectory.setStatus(archivesTrajectory.getBoxDynamics());
 							archivesTrajectory.setCorpId(item.getBoxEastId());
 							archivesTrajectory.setCorpName(item.getBoxEastName());
@@ -4595,6 +4808,7 @@ public class BoxDynamicsRecordServiceImpl extends ServiceImpl<BoxDynamicsRecordM
 							putBoxItem.setShipEname(bills.getVesselEnName());
 							putBoxItem.setEtd(bills.getEtd());
 							putBoxItem.setActualEtd(bills.getActualEtd());
+							putBoxItem.setPolFreeBoxUseDays(bills.getPolFreeBoxUseDays());
 						} else {
 							putBoxItem.setUnoccupied("1");
 						}
@@ -4730,6 +4944,7 @@ public class BoxDynamicsRecordServiceImpl extends ServiceImpl<BoxDynamicsRecordM
 										tradingBoxItem.setShipEname(bills.getVesselEnName());
 										tradingBoxItem.setPolFreeBoxUseDays(bills.getPolFreeBoxUseDays());
 										tradingBoxItem.setEtd(bills.getEtd());
+										tradingBoxItem.setPolFreeBoxUseDays(bills.getPolFreeBoxUseDays());
 									}
 									tradingBoxItem.setHblno(item.getHblno());
 									tradingBoxItem.setTemporaryId(item.getTemporaryId());
@@ -4790,6 +5005,7 @@ public class BoxDynamicsRecordServiceImpl extends ServiceImpl<BoxDynamicsRecordM
 													containers.setPodCyTel(tradingBoxItem.getPodCyTel());
 												}
 											}
+											logUtils.saveOperationLog(OperatorType.API_DATA_SYNCHRONIZATION, OperatorType.CC, containers.getId());
 										}
 									} else {
 										BoxDynamicsRecordItems recordItems = hblnoList.stream().filter(e -> containers.getCntrNo().equals(e.getBoxCode())).findFirst().orElse(null);
@@ -4815,6 +5031,7 @@ public class BoxDynamicsRecordServiceImpl extends ServiceImpl<BoxDynamicsRecordM
 													containers.setPodCyTel(tradingBoxItem.getPodCyTel());
 												}
 											}
+											logUtils.saveOperationLog(OperatorType.API_DATA_SYNCHRONIZATION, OperatorType.CC, containers.getId());
 										}
 									}
 									containers.setBoxSrcType(putBoxData.getBoxClass());
@@ -4822,7 +5039,6 @@ public class BoxDynamicsRecordServiceImpl extends ServiceImpl<BoxDynamicsRecordM
 									int version = StringUtil.isBlank(containers.getVersion()) ? 1 : Integer.parseInt(containers.getVersion());
 									containers.setVersion(String.valueOf(version + 1));
 									containersListNew.add(containers);
-									logUtils.saveOperationLog(OperatorType.API_DATA_SYNCHRONIZATION, OperatorType.CC, containers.getId());
 								}
 							} else {
 								failureHandling(type, boxDynamicsRecord, "未查到对应提单号:" + item.getMblno() + "配箱单据");
@@ -5007,6 +5223,12 @@ public class BoxDynamicsRecordServiceImpl extends ServiceImpl<BoxDynamicsRecordM
 									archivesTrajectory.setNewDate(dynamicsRecordItems.getApproachExitDate());
 								}
 							}
+							if (ObjectUtils.isNotNull(tradingBox.getPodId()) && !tradingBox.getPodId().contains(",")) {
+								archivesTrajectory.setPodId(Long.parseLong(tradingBox.getPodId()));
+								archivesTrajectory.setPodCode(tradingBox.getPodCode());
+								archivesTrajectory.setPodCname(tradingBox.getPodCname());
+								archivesTrajectory.setPodEname(tradingBox.getPodEname());
+							}
 							archivesTrajectory.setStatus(archivesTrajectory.getBoxDynamics());
 							archivesTrajectory.setCorpId(item.getBoxEastId());
 							archivesTrajectory.setCorpName(item.getBoxEastName());

+ 74 - 47
blade-service/blade-los/src/main/java/org/springblade/los/box/service/impl/PutBoxServiceImpl.java

@@ -366,6 +366,7 @@ public class PutBoxServiceImpl extends ServiceImpl<PutBoxMapper, PutBox> impleme
 			.eq(PutBox::getPolId, putBox.getPolId())
 			.eq(PutBox::getPolStationId, putBox.getPolStationId())
 			.like(ObjectUtils.isNotNull(putBox.getPodId()), PutBox::getPodId, putBox.getPodId())
+			.eq(ObjectUtils.isNotNull(putBox.getPodStationId()), PutBox::getPodStationId, putBox.getPodStationId())
 			.eq(PutBox::getBoxClass, putBox.getBoxClass())
 			.last("LIMIT 1"));
 		if (putBox1 == null) {
@@ -413,6 +414,9 @@ public class PutBoxServiceImpl extends ServiceImpl<PutBoxMapper, PutBox> impleme
 			.in(Archives::getCode, putBoxItemsList.stream().map(PutBoxItems::getBoxCode).distinct().collect(Collectors.toList())));
 		List<Archives> archives = new ArrayList<>();
 		for (PutBoxItems item : putBoxItemsList) {
+			if (!putBox1.getBoxType().equals(item.getBoxType())) {
+				throw new RuntimeException("箱型不符");
+			}
 			item.setPid(putBox1.getId());
 			item.setUpdateTime(new Date());
 			item.setUpdateUser(AuthUtil.getUserId());
@@ -454,6 +458,7 @@ public class PutBoxServiceImpl extends ServiceImpl<PutBoxMapper, PutBox> impleme
 			archivesTrajectory.setNewDate(new Date());
 			archivesTrajectory.setContainerNumber(item.getContainerNumber());
 			archivesTrajectory.setBoxType(item.getBoxType());
+			archivesTrajectory.setBoxStatus(item.getBoxStatus());
 			archivesTrajectory.setBoxCategory(item.getBoxClass());
 			archivesTrajectory.setBoxEastId(item.getBoxEastId());
 			archivesTrajectory.setBoxEastName(item.getBoxEastName());
@@ -5027,7 +5032,7 @@ public class PutBoxServiceImpl extends ServiceImpl<PutBoxMapper, PutBox> impleme
 	}
 
 	@Override
-	public R synchronization(String ids, String status,String boxDynamics) {
+	public R synchronization(String ids, String status, String boxDynamics) {
 		if (ObjectUtils.isNull(ids)) {
 			throw new RuntimeException("缺少必要请求参数");
 		}
@@ -5039,10 +5044,9 @@ public class PutBoxServiceImpl extends ServiceImpl<PutBoxMapper, PutBox> impleme
 		List<TradingBoxItem> tradingBoxItemList = new ArrayList<>();
 		for (Archives item : archivesList) {
 			LambdaQueryWrapper<PutBox> lambdaQueryWrapper = new LambdaQueryWrapper<>();
-			lambdaQueryWrapper.eq(PutBox::getTenantId,AuthUtil.getTenantId())
-				.eq(PutBox::getIsDeleted,0)
+			lambdaQueryWrapper.eq(PutBox::getTenantId, AuthUtil.getTenantId())
+				.eq(PutBox::getIsDeleted, 0)
 				.eq(PutBox::getBoxType, item.getTypeName())
-				.eq(PutBox::getBoxClass, item.getContainerNumberType())
 				.eq(PutBox::getContainerNumber, item.getContainerNumber())
 				.eq(PutBox::getPolId, item.getAddressId())
 				.eq(PutBox::getPolStationId, item.getStationId())
@@ -5054,18 +5058,23 @@ public class PutBoxServiceImpl extends ServiceImpl<PutBoxMapper, PutBox> impleme
 			putBox.setUpdateUser(AuthUtil.getUserId());
 			putBox.setUpdateTime(new Date());
 			putBox.setUpdateUserName(AuthUtil.getUserName());
-			putBox.setVersion(putBox.getVersion()+1);
-			if ("空箱提箱进场".equals(boxDynamics)){
-				putBox.setRemainingNum(putBox.getRemainingNum()+1);
-				putBox.setStorageNum(putBox.getStorageNum()+1);
-				putBox.setTotalNum(putBox.getTotalNum()+1);
-			}else if ("调箱进场".equals(boxDynamics)){
-				putBox.setStorageNum(putBox.getStorageNum()+1);
-			}else if ("场内退租出场".equals(boxDynamics)||"已返场".equals(boxDynamics)||"直接退租出场".equals(boxDynamics)
-				||"空箱出场".equals(boxDynamics)||"退租出场".equals(boxDynamics)){
-				putBox.setRemainingNum(putBox.getRemainingNum()-1);
-				putBox.setStorageNum(putBox.getStorageNum()-1);
-				putBox.setTotalNum(putBox.getTotalNum()-1);
+			putBox.setVersion(putBox.getVersion() + 1);
+			if ("空箱提箱进场".equals(boxDynamics) || "调箱进场".equals(boxDynamics)) {
+				if (!"空箱提箱进场".equals(item.getBoxDynamics()) && !"调箱进场".equals(boxDynamics)) {
+					putBox.setRemainingNum(putBox.getRemainingNum() + 1);
+					putBox.setStorageNum(putBox.getStorageNum() + 1);
+					putBox.setTotalNum(putBox.getTotalNum() + 1);
+				}
+			} else if ("场内退租出场".equals(boxDynamics) || "已返场".equals(boxDynamics) || "直接退租出场".equals(boxDynamics)
+				|| "空箱出场".equals(boxDynamics) || "退租出场".equals(boxDynamics)) {
+				if (!"场内退租出场".equals(item.getBoxDynamics()) && !"已返场".equals(item.getBoxDynamics()) && !"直接退租出场".equals(item.getBoxDynamics())
+					&& !"空箱出场".equals(item.getBoxDynamics()) && !"退租出场".equals(item.getBoxDynamics())) {
+					putBox.setRemainingNum(putBox.getRemainingNum() - 1);
+					putBox.setStorageNum(putBox.getStorageNum() - 1);
+					putBox.setTotalNum(putBox.getTotalNum() - 1);
+				}
+			} else {
+				throw new RuntimeException("数据错误请联系管理员");
 			}
 			baseMapper.updateById(putBox);
 			PutBoxItems putBoxItems = putBoxItemsService.getOne(new LambdaQueryWrapper<PutBoxItems>()
@@ -5082,7 +5091,7 @@ public class PutBoxServiceImpl extends ServiceImpl<PutBoxMapper, PutBox> impleme
 			putBoxItems.setStatus(status);
 			putBoxItems.setBoxDynamics(boxDynamics);
 			putBoxItemsList.add(putBoxItems);
-			if ("OW(拿),OW(放)".contains(putBox.getBoxClass())){
+			if ("OW(拿),OW(放)".contains(putBox.getBoxClass())) {
 				TradingBox tradingBox = tradingBoxMapper.selectOne(new LambdaQueryWrapper<TradingBox>()
 					.eq(TradingBox::getId, putBox.getSrcId())
 					.eq(TradingBox::getTenantId, AuthUtil.getTenantId())
@@ -5105,35 +5114,53 @@ public class PutBoxServiceImpl extends ServiceImpl<PutBoxMapper, PutBox> impleme
 				tradingBoxItem.setBoxDynamics(boxDynamics);
 				tradingBoxItemList.add(tradingBoxItem);
 			}
+			lambdaQueryWrapper.last("GROUP BY code,box_type,bill_type,box_dynamics,box_category,DATE_FORMAT(new_date, '%Y-%m-%d')," +
+				"port_id,station_id,container_number,IFNULL(mblno, ''),IFNULL(hblno, ''),src_id ORDER BY new_date DESC");
 			//记录箱轨迹信息
-			ArchivesTrajectory archivesTrajectory = new ArchivesTrajectory();
-			archivesTrajectory.setPortId(item.getAddressId());
-			archivesTrajectory.setPortCname(item.getAddressCname());
-			archivesTrajectory.setPortEname(item.getAddressEname());
-			archivesTrajectory.setPortCode(item.getAddressCode());
-			archivesTrajectory.setStationId(item.getStationId());
-			archivesTrajectory.setStationCname(item.getStationCname());
-			archivesTrajectory.setStationEname(item.getStationEname());
-			archivesTrajectory.setStationCode(item.getStationCode());
-			archivesTrajectory.setNewDate(new Date());
-			archivesTrajectory.setContainerNumber(item.getContainerNumber());
-			archivesTrajectory.setBoxType(item.getBoxType());
-			archivesTrajectory.setBoxCategory(item.getContainerNumberType());
-			archivesTrajectory.setBoxEastId(item.getBoxEastId());
-			archivesTrajectory.setBoxEastName(item.getBoxEastName());
-			archivesTrajectory.setBoxDynamics("箱档案-更改箱状态");
-			archivesTrajectory.setStatus("箱档案-更改箱状态");
-			archivesTrajectory.setCorpId(item.getBoxEastId());
-			archivesTrajectory.setCorpName(item.getBoxEastName());
-			archivesTrajectory.setBillType(item.getContainerNumberType());
-			archivesTrajectory.setCode(item.getCode());
-			archivesTrajectory.setCreateTime(new Date());
-			archivesTrajectory.setCreateUser(AuthUtil.getUserId());
-			archivesTrajectory.setCreateUserName(AuthUtil.getUserName());
-			archivesTrajectory.setSrcId(item.getId());
-			archivesTrajectoryMapper.insert(archivesTrajectory);
-			logUtils.saveOperationLog(OperatorType.UPDATE, "箱档案修改箱状态-"+item.getStatus()+"=>"+status+
-				",箱动态-"+item.getBoxDynamics()+"=>"+boxDynamics, archivesTrajectory.getId());
+			ArchivesTrajectory archivesTrajectory = archivesTrajectoryMapper.selectOne(new LambdaQueryWrapper<ArchivesTrajectory>()
+				.eq(ArchivesTrajectory::getTenantId, AuthUtil.getTenantId())
+				.eq(ArchivesTrajectory::getIsDeleted, 0)
+				.eq(ArchivesTrajectory::getCode, item.getCode())
+				.eq(ArchivesTrajectory::getBoxType, item.getTypeName())
+				.eq(ArchivesTrajectory::getBillType, item.getContainerNumberType())
+				.eq(ArchivesTrajectory::getBoxDynamics, "箱档案-更改箱状态")
+				.eq(ArchivesTrajectory::getBoxCategory, item.getContainerNumberType())
+				.eq(ArchivesTrajectory::getPortId, item.getAddressId())
+				.eq(ArchivesTrajectory::getStationId, item.getStationId())
+				.eq(ArchivesTrajectory::getContainerNumber, item.getContainerNumber())
+				.eq(ArchivesTrajectory::getSrcId, item.getId())
+				.eq(ArchivesTrajectory::getTrajectoryStatus, "0")
+			);
+			if (archivesTrajectory == null) {
+				archivesTrajectory = new ArchivesTrajectory();
+				archivesTrajectory.setPortId(item.getAddressId());
+				archivesTrajectory.setPortCname(item.getAddressCname());
+				archivesTrajectory.setPortEname(item.getAddressEname());
+				archivesTrajectory.setPortCode(item.getAddressCode());
+				archivesTrajectory.setStationId(item.getStationId());
+				archivesTrajectory.setStationCname(item.getStationCname());
+				archivesTrajectory.setStationEname(item.getStationEname());
+				archivesTrajectory.setStationCode(item.getStationCode());
+				archivesTrajectory.setNewDate(new Date());
+				archivesTrajectory.setContainerNumber(item.getContainerNumber());
+				archivesTrajectory.setBoxType(item.getTypeName());
+				archivesTrajectory.setBoxCategory(item.getContainerNumberType());
+				archivesTrajectory.setBoxEastId(item.getBoxEastId());
+				archivesTrajectory.setBoxEastName(item.getBoxEastName());
+				archivesTrajectory.setBoxDynamics("箱档案-更改箱状态");
+				archivesTrajectory.setStatus("箱档案-更改箱状态");
+				archivesTrajectory.setCorpId(item.getBoxEastId());
+				archivesTrajectory.setCorpName(item.getBoxEastName());
+				archivesTrajectory.setBillType(item.getContainerNumberType());
+				archivesTrajectory.setCode(item.getCode());
+				archivesTrajectory.setCreateTime(new Date());
+				archivesTrajectory.setCreateUser(AuthUtil.getUserId());
+				archivesTrajectory.setCreateUserName(AuthUtil.getUserName());
+				archivesTrajectory.setSrcId(item.getId());
+				archivesTrajectoryMapper.insert(archivesTrajectory);
+			}
+			logUtils.saveOperationLog(OperatorType.UPDATE, "箱档案修改箱状态-" + item.getStatus() + "=>" + status +
+				",箱动态-" + item.getBoxDynamics() + "=>" + boxDynamics, archivesTrajectory.getId());
 			item.setUpdateUser(AuthUtil.getUserId());
 			item.setUpdateTime(new Date());
 			item.setUpdateUserName(AuthUtil.getUserName());
@@ -5141,10 +5168,10 @@ public class PutBoxServiceImpl extends ServiceImpl<PutBoxMapper, PutBox> impleme
 			item.setBoxDynamics(boxDynamics);
 		}
 		archivesService.updateBatchById(archivesList);
-		if (!putBoxItemsList.isEmpty()){
+		if (!putBoxItemsList.isEmpty()) {
 			putBoxItemsService.updateBatchById(putBoxItemsList);
 		}
-		if (!tradingBoxItemList.isEmpty()){
+		if (!tradingBoxItemList.isEmpty()) {
 			tradingBoxItemService.updateBatchById(tradingBoxItemList);
 		}
 		return R.success("操作成功");

+ 22 - 7
blade-service/blade-los/src/main/java/org/springblade/los/box/service/impl/TradingBoxServiceImpl.java

@@ -338,7 +338,7 @@ public class TradingBoxServiceImpl extends ServiceImpl<TradingBoxMapper, Trading
 			}
 			int version = StringUtil.isBlank(dataTradingBox.getVersion()) ? 1 : Integer.parseInt(dataTradingBox.getVersion());
 			tradingBox.setVersion(String.valueOf(version + 1));
-			if (tradingBoxList.stream().anyMatch(e -> !e.getId().equals(tradingBox.getId()))) {
+			if (tradingBoxList.stream().anyMatch(e -> !e.getId().equals(tradingBox.getId())) && ObjectUtils.isNotNull(text)) {
 				throw new RuntimeException(text);
 			}
 			tradingBox.setUpdateTime(new Date());
@@ -2668,11 +2668,12 @@ public class TradingBoxServiceImpl extends ServiceImpl<TradingBoxMapper, Trading
 		if (putBox == null) {
 			throw new RuntimeException("未查到放箱号");
 		}
+		List<String> code = tradingBox.getTradingBoxItemsList().stream().map(TradingBoxItem::getCode).collect(Collectors.toList());
 		List<PutBoxItems> putBoxItemsList = putBoxItemsService.list(new LambdaQueryWrapper<PutBoxItems>()
 			.eq(PutBoxItems::getTenantId, AuthUtil.getTenantId())
 			.eq(PutBoxItems::getIsDeleted, 0)
 			.eq(PutBoxItems::getPid, putBox.getId())
-			.in(PutBoxItems::getBoxCode, tradingBox.getTradingBoxItemsList().stream().map(TradingBoxItem::getCode).collect(Collectors.toList())));
+			.in(PutBoxItems::getBoxCode, code));
 		if (putBoxItemsList.isEmpty()) {
 			throw new RuntimeException("未查到放箱号箱明细");
 		}
@@ -2725,7 +2726,8 @@ public class TradingBoxServiceImpl extends ServiceImpl<TradingBoxMapper, Trading
 			List<Containers> containersList = containersService.list(new LambdaQueryWrapper<Containers>()
 				.eq(Containers::getTenantId, AuthUtil.getTenantId())
 				.eq(Containers::getIsDeleted, 0)
-				.in(Containers::getHblno, hblno));
+				.in(Containers::getHblno, hblno)
+				.in(Containers::getCntrNo, code));
 			for (Containers containers : containersList) {
 				containers.setPodStationId(tradingBox.getPodStationId());
 				containers.setPodStationCname(tradingBox.getPodStationCname());
@@ -2736,7 +2738,7 @@ public class TradingBoxServiceImpl extends ServiceImpl<TradingBoxMapper, Trading
 				containers.setPodCyEmail(tradingBox.getPodCyEmail());
 				containers.setPodCyTel(tradingBox.getPodCyTel());
 				containers.setOffhireReference(tradingBox.getOffhireReference());
-				containers.setContainerNumber(tradingBox.getContainerNumber());
+				containers.setContainerNumber(putBox.getContainerNumber());
 				logUtils.saveOperationLog(OperatorType.OW_BOX, "OW修改pod场站", containers.getId());
 				if (!billsList.isEmpty()) {
 					if (billsList.stream().filter(e -> e.getId().equals(containers.getPid())).count() > 0) {
@@ -2749,9 +2751,9 @@ public class TradingBoxServiceImpl extends ServiceImpl<TradingBoxMapper, Trading
 				containersService.updateBatchById(containersList);
 			}
 		}
-		if (count>0){
-			return R.data("操作成功","箱号:"+boxCode+"已同步到进口单据,请联系相关人员");
-		}else{
+		if (count > 0) {
+			return R.data("操作成功", "箱号:" + boxCode + "已同步到进口单据,请联系相关人员");
+		} else {
 			return R.data(tradingBox);
 		}
 	}
@@ -2832,6 +2834,7 @@ public class TradingBoxServiceImpl extends ServiceImpl<TradingBoxMapper, Trading
 		}
 		putBox.setTotalNum(tradingBox.getBoxNumber());
 		putBox.setRemainingNum(putBox.getTotalNum() - putBox.getOccupyNum() - alreadyAppeared);
+		putBox.setVersion(putBox.getVersion()+1);
 		putBoxService.updateById(putBox);
 		return R.data(tradingBox);
 	}
@@ -2996,8 +2999,17 @@ public class TradingBoxServiceImpl extends ServiceImpl<TradingBoxMapper, Trading
 			.eq(FeeCenterItems::getFeeCode, "PerDiem")
 			.orderByDesc(FeeCenterItems::getCreateTime);
 		List<FeeCenterItems> feeCenterItems = feeCenterItemsService.list(tradingBoxFeesLambdaQueryWrapper);
+		if (feeCenterItems.isEmpty()) {
+			throw new RuntimeException("未计算过租金,撤销失败");
+		}
+		FeeCenterItems feeCenterItems1 = feeCenterItems.get(0);
+		List<String> codeList = feeCenterItems.stream().filter(e -> ObjectUtils.isNotNull(e.getBatchNo()) && e.getBatchNo().equals(feeCenterItems1.getBatchNo()))
+			.map(FeeCenterItems::getCntrNo).collect(Collectors.toList());
 		List<TradingBoxItem> itemList = new ArrayList<>();
 		for (TradingBoxItem item : tradingBoxItemList) {
+			if (!codeList.contains(item.getCode())) {
+				continue;
+			}
 			if (ObjectUtils.isNull(item.getRentStartDate())) {
 				throw new RuntimeException("未计算过租金,撤销失败");
 			} else {
@@ -3016,6 +3028,9 @@ public class TradingBoxServiceImpl extends ServiceImpl<TradingBoxMapper, Trading
 						if (item.getRentEndDate().compareTo(item.getPolPickUpDate()) < 0) {
 							item.setRentEndDate(item.getPolPickUpDate());
 						}
+						if (feeCenterItemsList1.size() == 1) {
+							item.setWhetherCountRent("0");
+						}
 					}
 				}
 				item.setUpdateTime(new Date());

+ 1 - 0
blade-service/blade-los/src/main/java/org/springblade/los/business/sea/controller/BillsController.java

@@ -1131,6 +1131,7 @@ public class BillsController extends BladeController {
 			.like(ObjectUtils.isNotNull(bills.getHblno()), Bills::getHblno, bills.getHblno())
 			.eq(Bills::getPolId, bills.getPolId())
 			.eq(Bills::getPodId, bills.getPodId())
+			.ne(Bills::getId, bills.getId())
 			.eq(ObjectUtils.isNotNull(bills.getBoxBelongsTo()),Bills::getBoxBelongsTo, bills.getBoxBelongsTo())
 			.apply("DATE_FORMAT(actual_etd,'%Y-%m-%d') <= '" + formatter.format(new Date()) + "'");
 		List<Bills> billsList = billsService.list(lambdaQueryWrapper);