Просмотр исходного кода

1.主单同步分单,截单日期同步问题修改
2.主单配箱列表删除bug修改
3.财务金额处理负数问题修改
4.OW拿启用接口bug修改
5.OW放增加还箱逻辑

纪新园 3 дней назад
Родитель
Сommit
70552ed338

+ 78 - 4
blade-service/blade-los/src/main/java/org/springblade/los/Util/EntryExitDataHandleUtils.java

@@ -31,10 +31,12 @@ public class EntryExitDataHandleUtils {
 	 * @param bills            海运单据数据
 	 * @param boxDynamics      箱动态
 	 * @param status           箱状态
-	 * @param type             1=进场,2=调拨进场,3=出场,4=调箱出场,5=客户还箱,6=无货返空,7=退租出场,8=OW放箱出场
+	 * @param type             1=进场,2=调拨进场,3=出场,4=调箱出场,5=客户还箱(旧),6=无货返空,7=退租出场,8=OW放箱出场,9客户还箱(新)
+	 * @param whetherFX        是否是OW放业务
 	 */
 	public static PutBoxItems putBoxItemDataHandle(PutBoxItems putBoxItem, BoxDynamicsRecordItems item, PutBox putBoxData,
-												   boolean whetherExistence, Bills bills, String boxDynamics, String status, String type) {
+												   boolean whetherExistence, Bills bills, String boxDynamics, String status, String type
+	,boolean whetherFX) {
 		if ("8".equals(type)) {
 			putBoxItem = new PutBoxItems();
 			putBoxItem.setBoxClass(putBoxData.getBoxClass());
@@ -69,6 +71,7 @@ public class EntryExitDataHandleUtils {
 			}
 			putBoxItem.setPolStationEmptyContainerExitDate(item.getApproachExitDate());
 			putBoxItem.setHblno(item.getHblno());
+			putBoxItem.setTemporaryStatus(false);
 		} else if ("3".equals(type)) {
 			putBoxItem.setPid(putBoxData.getId());
 			putBoxItem.setUpdateUser(AuthUtil.getUserId());
@@ -109,10 +112,13 @@ public class EntryExitDataHandleUtils {
 				putBoxItem.setActualEtd(bills.getActualEtd());
 				putBoxItem.setPolFreeBoxUseDays(bills.getPolFreeBoxUseDays());
 			} else {
-				//未查到海运单据则未占用
-				putBoxItem.setUnoccupied("1");
+				if (!whetherFX){
+					//未查到海运单据则未占用
+					putBoxItem.setUnoccupied("1");
+				}
 			}
 			putBoxItem.setHblno(item.getHblno());
+			putBoxItem.setTemporaryStatus(false);
 		} else if ("4".equals(type)) {
 			if (putBoxItem != null) {
 				putBoxItem.setPid(putBoxData.getId());
@@ -137,6 +143,7 @@ public class EntryExitDataHandleUtils {
 			putBoxItem.setPolCyCname(item.getStationCname());
 			putBoxItem.setPolCyEname(item.getStationEname());
 			putBoxItem.setPolStationEmptyContainerExitDate(item.getApproachExitDate());
+			putBoxItem.setTemporaryStatus(false);
 		} else if ("7".equals(type)) {
 			putBoxItem.setPid(putBoxData.getId());
 			putBoxItem.setPodStationId(item.getStationId());
@@ -147,10 +154,13 @@ public class EntryExitDataHandleUtils {
 			putBoxItem.setUpdateUser(AuthUtil.getUserId());
 			putBoxItem.setUpdateUserName(AuthUtil.getUserName());
 			putBoxItem.setUpdateTime(new Date());
+			putBoxItem.setTemporaryStatus(false);
 		} else if ("1".equals(type)) {
 			if (putBoxItem != null) {
 				if ("使用中".equals(putBoxItem.getStatus())) {
 					putBoxItem.setTemporaryStatus(true);
+				}else{
+					putBoxItem.setTemporaryStatus(false);
 				}
 				putBoxItem.setUpdateUser(AuthUtil.getUserId());
 				putBoxItem.setUpdateUserName(AuthUtil.getUserName());
@@ -215,6 +225,8 @@ public class EntryExitDataHandleUtils {
 			putBoxItem.setBoxStatus(item.getBoxStatus());
 			if ("待使用".equals(putBoxItem.getStatus())) {
 				putBoxItem.setTemporaryStatus(true);
+			}else{
+				putBoxItem.setTemporaryStatus(false);
 			}
 			putBoxItem.setUpdateUser(AuthUtil.getUserId());
 			putBoxItem.setUpdateUserName(AuthUtil.getUserName());
@@ -230,6 +242,8 @@ public class EntryExitDataHandleUtils {
 			if (putBoxItem != null) {
 				if ("使用中".equals(putBoxItem.getStatus())) {
 					putBoxItem.setTemporaryStatus(true);
+				}else{
+					putBoxItem.setTemporaryStatus(false);
 				}
 				putBoxItem.setUpdateUser(AuthUtil.getUserId());
 				putBoxItem.setUpdateUserName(AuthUtil.getUserName());
@@ -247,6 +261,7 @@ public class EntryExitDataHandleUtils {
 				putBoxItem.setCreateUserName(AuthUtil.getUserName());
 				putBoxItem.setCreateTime(new Date());
 				putBoxItem.setPid(putBoxData.getId());
+				putBoxItem.setTemporaryStatus(false);
 			}
 			putBoxItem.setPolCyId(item.getStationId());
 			putBoxItem.setPolCyCode(item.getStationCode());
@@ -294,7 +309,65 @@ public class EntryExitDataHandleUtils {
 			putBoxItem.setAgentName("");
 			putBoxItem.setActualEtd(null);
 			putBoxItem.setActualEta(null);
+			putBoxItem.setTemporaryStatus(false);
+		}else if ("9".equals(type)){
+			if (putBoxItem != null) {
+				putBoxItem.setUpdateUser(AuthUtil.getUserId());
+				putBoxItem.setUpdateUserName(AuthUtil.getUserName());
+				putBoxItem.setUpdateTime(new Date());
+
+				putBoxItem.setPodEmptyContainerReturnDate(null);
+				putBoxItem.setPodStationId(null);
+				putBoxItem.setPodStationCode(null);
+				putBoxItem.setPodStationCname(null);
+				putBoxItem.setPodStationEname(null);
+				putBoxItem.setEta(null);
+				putBoxItem.setCorpId(0L);
+				putBoxItem.setCorpName("");
+				putBoxItem.setMblno("");
+				putBoxItem.setHblno("");
+				putBoxItem.setShipNameId(0L);
+				putBoxItem.setShipCname("");
+				putBoxItem.setShipEname("");
+				putBoxItem.setShipCode("");
+				putBoxItem.setVoyage("");
+				putBoxItem.setPodCyAddress("");
+				putBoxItem.setPodCyContact("");
+				putBoxItem.setPodCyEmail("");
+				putBoxItem.setPodCyTel("");
+				putBoxItem.setEtd(null);
+				putBoxItem.setPolFreeBoxUseDays(0);
+				putBoxItem.setPolStationEmptyContainerExitDate(null);
+				putBoxItem.setPolReturnDate(null);
+				putBoxItem.setPolOverdueBoxUseDays(0);
+				putBoxItem.setPodFreeBoxUseDays(0);
+				putBoxItem.setPodBoxUseDays(0);
+				putBoxItem.setAgentName("");
+				putBoxItem.setActualEtd(null);
+				putBoxItem.setActualEta(null);
+			} else {
+				putBoxItem = new PutBoxItems();
+				putBoxItem.setBoxClass(putBoxData.getBoxClass());
+				putBoxItem.setBoxBelongsTo("SOC");
+				putBoxItem.setBoxCondition("新");
+				putBoxItem.setContainerNumber(item.getContainerNumber());
+				putBoxItem.setBoxCode(item.getBoxCode());
+				putBoxItem.setBoxType(item.getBoxType());
+				putBoxItem.setBoxClass(putBoxData.getBoxClass());
+				putBoxItem.setCreateUser(AuthUtil.getUserId());
+				putBoxItem.setCreateUserName(AuthUtil.getUserName());
+				putBoxItem.setCreateTime(new Date());
+			}
+			putBoxItem.setBoxDynamics(boxDynamics);
+			putBoxItem.setStatus(status);
+			putBoxItem.setPolCyId(item.getStationId());
+			putBoxItem.setPolCyCode(item.getStationCode());
+			putBoxItem.setPolCyCname(item.getStationCname());
+			putBoxItem.setPolCyEname(item.getPortEname());
+			putBoxItem.setPolPickUpDate(item.getApproachExitDate());
+			putBoxItem.setPolPreAppearanceDate(item.getApproachExitDate());
 		}
+		putBoxItem.setPid(putBoxData.getId());
 		putBoxItem.setBoxStatus(item.getBoxStatus());
 		putBoxItem.setStatus(status);
 		putBoxItem.setBoxDynamics(boxDynamics);
@@ -564,6 +637,7 @@ public class EntryExitDataHandleUtils {
 			tradingBoxItem.setActualEta(null);
 			tradingBoxItem.setTemporaryId(item.getTemporaryId());
 		}
+		tradingBoxItem.setPid(tradingBox.getId());
 		tradingBoxItem.setHblno(item.getHblno());
 		tradingBoxItem.setBoxDynamics(boxDynamics);
 		tradingBoxItem.setBoxStatus(item.getBoxStatus());

+ 70 - 45
blade-service/blade-los/src/main/java/org/springblade/los/Util/OwBoxUsageFeeUtils.java

@@ -2,7 +2,6 @@ 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;
@@ -454,22 +453,22 @@ public class OwBoxUsageFeeUtils {
 							}
 							item.setPolOverdueBoxUseDays(Integer.parseInt(overdueDays + ""));
 							item.setPolFreeBoxUseDays(feeCenter.getOverdueBoxUseDays());
-						}
-						putBoxItemsList.add(item);
-						if ("OW(拿),OW(放)".contains(putBox.getBoxClass())) {
-							TradingBoxItem tradingBoxItem = tradingBoxItemOldList.stream().filter(e -> e.getCode().equals(item.getBoxCode())).findFirst().orElse(null);
-							if (tradingBoxItem == null) {
-								failureHandling("3", boxDynamicsRecord, "未查到OW单据明细箱号");
-								return false;
-							}
-							//查找OW明细对应主表
-							TradingBox tradingBox = tradingBoxList.stream().filter(e -> e.getId().equals(tradingBoxItem.getPid())).findFirst().orElse(null);
-							if (tradingBox == null) {
-								failureHandling("3", boxDynamicsRecord, "未查到OW单据");
-								return false;
+							putBoxItemsList.add(item);
+							if ("OW(拿),OW(放)".contains(putBox.getBoxClass())) {
+								TradingBoxItem tradingBoxItem = tradingBoxItemOldList.stream().filter(e -> e.getCode().equals(item.getBoxCode())).findFirst().orElse(null);
+								if (tradingBoxItem == null) {
+									failureHandling("3", boxDynamicsRecord, "未查到OW单据明细箱号");
+									return false;
+								}
+								//查找OW明细对应主表
+								TradingBox tradingBox = tradingBoxList.stream().filter(e -> e.getId().equals(tradingBoxItem.getPid())).findFirst().orElse(null);
+								if (tradingBox == null) {
+									failureHandling("3", boxDynamicsRecord, "未查到OW单据");
+									return false;
+								}
+								tradingBoxItem.setPolOverdueBoxUseDays(overdueDays);
+								tradingBoxItemList.add(tradingBoxItem);
 							}
-							tradingBoxItem.setPolOverdueBoxUseDays(overdueDays);
-							tradingBoxItemList.add(tradingBoxItem);
 						}
 					}
 				}
@@ -1203,13 +1202,43 @@ public class OwBoxUsageFeeUtils {
 		feeCenter.setCurCode(storageFeesItems.get(0).getCurCode());
 		feeCenter.setCntrNo(item.getBoxCode());
 		feeCenter.setUnitNo(item.getBoxType());
-		//计算天数
-		int days = overdueDays + 1;
-		int earlySumDays = 0;
-		String text = "";
-		int dayLength;
-		BigDecimal amount = new BigDecimal("0.00");
+		//免箱使天数
 		int overdueBoxUseDays = 0;
+		if (ObjectUtils.isNotNull(bills.getPolFreeBoxUseDays())) {
+			overdueBoxUseDays = bills.getPolFreeBoxUseDays();
+		}
+		//判断是否超期
+		if (overdueDays < overdueBoxUseDays) {
+			return null;
+		}
+		//获取第一档计费规则明细
+		int finalOverdueBoxUseDays = overdueBoxUseDays;
+		StorageFeesItems feesItems = storageFeesItems.stream().filter(e -> finalOverdueBoxUseDays > e.getStartDay()
+			&& finalOverdueBoxUseDays < e.getEndDay()).findFirst().orElse(null);
+		if (feesItems == null) {
+			return null;
+		}
+		//开始计费-第一档应计费天数
+		int firstTierChargeableFeeDays = feesItems.getEndDay() - overdueBoxUseDays + 1;
+		//计算过程
+		String text;
+		//超期金额
+		BigDecimal amount;
+		//按照箱型取对应超期单价
+		if ("20GP".equals(item.getBoxType())) {
+			amount = feesItems.getPrice20gp().multiply(new BigDecimal(firstTierChargeableFeeDays + ""));
+			text = firstTierChargeableFeeDays + "天*" + feesItems.getPrice20gp() + "元=" + amount + "元,";
+		} else if ("40HC".equals(item.getBoxType())) {
+			amount = feesItems.getPrice40hc().multiply(new BigDecimal(firstTierChargeableFeeDays + ""));
+			text = firstTierChargeableFeeDays + "天*" + feesItems.getPrice40hc() + "元=" + amount + "元,";
+		} else if ("40GP".equals(item.getBoxType())) {
+			amount = feesItems.getPrice40gp().multiply(new BigDecimal(firstTierChargeableFeeDays + ""));
+			text = firstTierChargeableFeeDays + "天*" + feesItems.getPrice40gp() + "元=" + amount + "元,";
+		} else {
+			return null;
+		}
+		//剩余计费天数
+		int days = overdueDays - feesItems.getEndDay();
 		for (StorageFeesItems term : storageFeesItems) {
 			BigDecimal rate;
 			//根据箱型获取具体超期单价
@@ -1222,30 +1251,27 @@ public class OwBoxUsageFeeUtils {
 			} else {
 				continue;
 			}
-			dayLength = term.getEndDay() - term.getStartDay() + 1;
-			if (new BigDecimal("0.00").compareTo(rate) == 0) {
-				overdueBoxUseDays = dayLength;
-			}
-			if (earlySumDays >= dayLength) {
-				earlySumDays -= dayLength;
-				continue;
-			}
-			if (earlySumDays + days > dayLength) {
-				int tempDays = dayLength - earlySumDays;
-				earlySumDays = 0;
-				days -= tempDays;
-				BigDecimal calculate = rate.multiply(new BigDecimal(tempDays + ""));
-				amount = amount.add(calculate);
-				text = text + tempDays + "天*" + rate + "元=" + calculate + "元,";
-			} else {
-				BigDecimal calculate = rate.multiply(new BigDecimal(days + ""));
-				amount = amount.add(calculate);
-				text = text + days + "天*" + rate + "元=" + calculate + "元";
-				days = 0;
-				break;
+			//剩余计费天数需从免箱使天数所在下一档次开始计算
+			if (term.getStartDay() > feesItems.getEndDay()) {
+				//本档次需计费天数
+				int dayLength = term.getEndDay() - term.getStartDay() + 1;
+				//剩余计费天数是否大于本档次计费天数
+				if (days > dayLength) {
+					days -= dayLength;
+					BigDecimal calculate = rate.multiply(new BigDecimal(dayLength + ""));
+					amount = amount.add(calculate);
+					text = text + dayLength + "天*" + rate + "元=" + calculate + "元,";
+				} else {
+					BigDecimal calculate = rate.multiply(new BigDecimal(days + ""));
+					amount = amount.add(calculate);
+					text = text + days + "天*" + rate + "元=" + calculate + "元";
+					days = 0;
+					break;
+				}
 			}
 		}
-		feeCenter.setOverdueBoxUseDays(overdueBoxUseDays);
+		feeCenter.setOverdueBoxUseDays(overdueDays - overdueBoxUseDays);
+		//如果计费规则循环计算完成后还有剩余计费天数,需按照最后一档次计算超期金额
 		if (days != 0) {
 			if ("20GP".equals(item.getBoxType())) {
 				BigDecimal calculate = storageFeesItems.get(storageFeesItems.size() - 1).getPrice20gp().multiply(new BigDecimal(days + ""));
@@ -1276,7 +1302,6 @@ public class OwBoxUsageFeeUtils {
 		feeCenter.setUnsettledAmount(amount);
 		feeCenter.setPrice(amount);
 		feeCenter.setRemarks(text);
-//		int quantity = bills.getQuantityV20()+bills.getQuantityV40()+bills.getQuantityV45()+bills.getQuantityV48()+bills.getQuantityV40hc();
 		feeCenter.setQuantity(new BigDecimal("1"));
 		feeCenter.setBillNo(bills.getBillNo());
 		feeCenter.setBusinessType(bills.getBusinessType());

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

@@ -76,9 +76,6 @@ import java.math.BigDecimal;
 import java.rmi.RemoteException;
 import java.text.ParseException;
 import java.text.SimpleDateFormat;
-import java.time.LocalDateTime;
-import java.time.ZoneId;
-import java.time.temporal.ChronoUnit;
 import java.util.*;
 import java.util.stream.Collectors;
 
@@ -455,12 +452,12 @@ public class BoxDynamicsRecordServiceImpl extends ServiceImpl<BoxDynamicsRecordM
 				failureHandling(type, boxDynamicsRecord, "未查到箱号:" + recordItems.getBoxCode() + "箱档案数据");
 				return false;
 			}
-			if (!archives.getTypeName().equals(recordItems.getBoxType())){
+			if (!archives.getTypeName().equals(recordItems.getBoxType())) {
 				failureHandling(type, boxDynamicsRecord, "箱号:" + recordItems.getBoxCode() + "箱型与箱档案不符");
 				return false;
 			}
 			//箱档案数据处理
-			archives = ArchivesUtils.dataAssembly(archives,recordItems,BoxDynamicsEnums.getName(recordItems.getObjective()),"退租",null);
+			archives = ArchivesUtils.dataAssembly(archives, recordItems, BoxDynamicsEnums.getName(recordItems.getObjective()), "退租", null);
 			archivesArrayList.add(archives);
 			archivesDateleList.add(archives.getId());
 			//原放箱号数据处理
@@ -477,8 +474,8 @@ public class BoxDynamicsRecordServiceImpl extends ServiceImpl<BoxDynamicsRecordM
 					putBoxItem = putBoxItemsList.stream().filter(e -> e.getBoxCode().equals(recordItems.getBoxCode()))
 						.findFirst().orElse(null);
 					if (putBoxItem != null) {
-						putBoxItem = EntryExitDataHandleUtils.putBoxItemDataHandle(putBoxItem,recordItems,putBox1,false,
-							null,BoxDynamicsEnums.getName(recordItems.getObjective()),"退租","7");
+						putBoxItem = EntryExitDataHandleUtils.putBoxItemDataHandle(putBoxItem, recordItems, putBox1, false,
+							null, BoxDynamicsEnums.getName(recordItems.getObjective()), "退租", "7", false);
 						putBoxItemsOldList.add(putBoxItem);
 					} else {
 						failureHandling(type, boxDynamicsRecord, "未查到放箱号:" + recordItems.getContainerNumber() + "下箱号:" + recordItems.getBoxCode() + "明细");
@@ -520,6 +517,8 @@ public class BoxDynamicsRecordServiceImpl extends ServiceImpl<BoxDynamicsRecordM
 				archivesTrajectory.setBillType(putBox1.getBoxClass());
 				archivesTrajectory.setCode(recordItems.getBoxCode());
 				archivesTrajectory.setNewDate(recordItems.getApproachExitDate());
+				archivesTrajectory.setMblno(recordItems.getHblno());
+				archivesTrajectory.setHblno(recordItems.getHblno());
 				archivesTrajectory.setCreateTime(new Date());
 				archivesTrajectory.setCreateUser(AuthUtil.getUserId());
 				archivesTrajectory.setCreateUserName(AuthUtil.getUserName());
@@ -550,13 +549,14 @@ public class BoxDynamicsRecordServiceImpl extends ServiceImpl<BoxDynamicsRecordM
 					if (!tradingBoxItemList.isEmpty()) {
 						tradingBoxItem = tradingBoxItemList.stream().filter(e -> e.getCode().equals(recordItems.getBoxCode()))
 							.findFirst().orElse(null);
-						tradingBoxItem = EntryExitDataHandleUtils.tradingBoxItemDataHandle(tradingBoxItem,recordItems,tradingBox,false,
-							null,BoxDynamicsEnums.getName(recordItems.getObjective()),"退租","7");
+						tradingBoxItem = EntryExitDataHandleUtils.tradingBoxItemDataHandle(tradingBoxItem, recordItems, tradingBox, false,
+							null, BoxDynamicsEnums.getName(recordItems.getObjective()), "退租", "7");
+						tradingBoxItemOldList.add(tradingBoxItem);
 					} else {
-						tradingBoxItem = EntryExitDataHandleUtils.tradingBoxItemDataHandle(null,recordItems,tradingBox,false,
-							null,BoxDynamicsEnums.getName(recordItems.getObjective()),"退租","7");
+						tradingBoxItem = EntryExitDataHandleUtils.tradingBoxItemDataHandle(null, recordItems, tradingBox, false,
+							null, BoxDynamicsEnums.getName(recordItems.getObjective()), "退租", "7");
+						tradingBoxItemOldList.add(tradingBoxItem);
 					}
-					tradingBoxItemOldList.add(tradingBoxItem);
 				} else {
 					failureHandling(type, boxDynamicsRecord, "未查到放箱号:" + recordItems.getContainerNumber() + "对应退租单据");
 					return false;
@@ -1468,13 +1468,13 @@ public class BoxDynamicsRecordServiceImpl extends ServiceImpl<BoxDynamicsRecordM
 						}
 						//存储上一步数据
 						BoxNumUtils.storagePreviousStepData(archives, item);
-						archives = ArchivesUtils.dataAssembly(archives,item,"空箱提箱进场","待使用",putBox.getBoxClass());
+						archives = ArchivesUtils.dataAssembly(archives, item, "空箱提箱进场", "待使用", putBox.getBoxClass());
 					} else {
 						if (!"OW(拿),代理箱,租箱".contains(putBox.getBoxClass())) {
 							failureHandling(type, boxDynamicsRecord, "箱档案中未查到箱号:" + item.getBoxCode());
 							return false;
 						}
-						archives = ArchivesUtils.dataAssembly(null,item,"空箱提箱进场","待使用",putBox.getBoxClass());
+						archives = ArchivesUtils.dataAssembly(null, item, "空箱提箱进场", "待使用", putBox.getBoxClass());
 						archives.setTenantId(tenantId);
 					}
 					archives.setTemporaryId(item.getTemporaryId());
@@ -1488,16 +1488,17 @@ public class BoxDynamicsRecordServiceImpl extends ServiceImpl<BoxDynamicsRecordM
 					if (!putBoxItemsList.isEmpty()) {
 						putBoxItem = putBoxItemsList.stream().filter(e -> e.getBoxCode().equals(item.getBoxCode()))
 							.findFirst().orElse(null);
-						putBoxItem = EntryExitDataHandleUtils.putBoxItemDataHandle(putBoxItem,item,putBox,false,null,"空箱提箱进场","待使用","1");
+						putBoxItem = EntryExitDataHandleUtils.putBoxItemDataHandle(putBoxItem, item, putBox, false, null, "空箱提箱进场", "待使用", "1", false);
+						if (putBoxItem.getTemporaryStatus()) {
+							failureHandling(type, boxDynamicsRecord, "放箱号:" + item.getContainerNumber() + "箱号:" +
+								item.getBoxCode() + "状态为使用中,请先还箱");
+							return false;
+						}
+						putBoxItems.add(putBoxItem);
 					} else {
-						putBoxItem = EntryExitDataHandleUtils.putBoxItemDataHandle(null,item,putBox,false,null,"空箱提箱进场","待使用","1");
-					}
-					if (putBoxItem.getTemporaryStatus()) {
-						failureHandling(type, boxDynamicsRecord, "放箱号:" + item.getContainerNumber() + "箱号:" +
-							item.getBoxCode() + "状态为使用中,请先还箱");
-						return false;
+						putBoxItem = EntryExitDataHandleUtils.putBoxItemDataHandle(null, item, putBox, false, null, "空箱提箱进场", "待使用", "1", false);
+						putBoxItems.add(putBoxItem);
 					}
-					putBoxItems.add(putBoxItem);
 					if ("OW(拿)".equals(putBox.getBoxClass())) {
 						if (!tradingBoxList.isEmpty()) {
 							TradingBox tradingBox = tradingBoxList.stream().filter(e -> e.getId().equals(putBox.getSrcId()))
@@ -1515,11 +1516,12 @@ public class BoxDynamicsRecordServiceImpl extends ServiceImpl<BoxDynamicsRecordM
 								if (!tradingBoxItemList.isEmpty()) {
 									tradingBoxItem = tradingBoxItemList.stream().filter(e -> e.getCode().equals(item.getBoxCode()))
 										.findFirst().orElse(null);
-									tradingBoxItem = EntryExitDataHandleUtils.tradingBoxItemDataHandle(tradingBoxItem,item,tradingBox,false,null,"空箱提箱进场","待使用","1");
+									tradingBoxItem = EntryExitDataHandleUtils.tradingBoxItemDataHandle(tradingBoxItem, item, tradingBox, false, null, "空箱提箱进场", "待使用", "1");
+									tradingBoxItems.add(tradingBoxItem);
 								} else {
-									tradingBoxItem = EntryExitDataHandleUtils.tradingBoxItemDataHandle(null,item,tradingBox,false,null,"空箱提箱进场","待使用","1");
+									tradingBoxItem = EntryExitDataHandleUtils.tradingBoxItemDataHandle(null, item, tradingBox, false, null, "空箱提箱进场", "待使用", "1");
+									tradingBoxItems.add(tradingBoxItem);
 								}
-								tradingBoxItems.add(tradingBoxItem);
 							} else {
 								failureHandling(type, boxDynamicsRecord, "放箱号:" + item.getContainerNumber() + "未查到来源单据");
 								return false;
@@ -2150,19 +2152,65 @@ public class BoxDynamicsRecordServiceImpl extends ServiceImpl<BoxDynamicsRecordM
 				}
 			}
 			//客户还箱
-			List<BoxDynamicsRecordItems> itemsListFCs = itemsList.stream().filter(e -> "C".equals(e.getObjective())).collect(Collectors.toList());
-			if (!itemsListFCs.isEmpty()) {
-				List<String> boxNum = itemsListFCs.stream().map(BoxDynamicsRecordItems::getBoxCode).filter(Objects::nonNull)
+			List<BoxDynamicsRecordItems> itemsListKHHX = itemsList.stream().filter(e -> "C".equals(e.getObjective())).collect(Collectors.toList());
+			if (!itemsListKHHX.isEmpty()) {
+				//OW(放)放箱号前缀参数
+				String fixedPrefix = sysClient.getParamService("fixed.prefix.numbering");
+				if (ObjectUtils.isNull(fixedPrefix) || "获取数据失败".equals(fixedPrefix)) {
+					failureHandling(type, boxDynamicsRecord, "请先维护放箱号固定前缀参数!");
+					return false;
+				}
+				List<String> boxNum = itemsListKHHX.stream().map(BoxDynamicsRecordItems::getBoxCode).filter(Objects::nonNull)
 					.collect(Collectors.toList());
 				if (boxNum.isEmpty()) {
 					failureHandling(type, boxDynamicsRecord, "所选配箱信息箱号不能为空");
 					return false;
 				}
 				//箱档案数据
-				List<Archives> archivesList = archivesService.list(new LambdaQueryWrapper<Archives>()
+				List<Archives> archivesListFXHX = archivesService.list(new LambdaQueryWrapper<Archives>()
 					.eq(Archives::getTenantId, boxDynamicsRecord.getTenantId())
 					.eq(Archives::getIsDeleted, 0)
 					.in(Archives::getCode, boxNum));
+				List<BoxDynamicsRecordItems> itemsListFXHX = new ArrayList<>();
+				List<BoxDynamicsRecordItems> itemsListFCs = new ArrayList<>();
+				//区分正常还箱还是OW放还箱  只有箱档案存在,箱档案中提单号不为空并且符合前缀匹配的才是OW放还箱箱号,其余都是正常还箱
+				for (BoxDynamicsRecordItems item : itemsListKHHX) {
+					if (!archivesListFXHX.isEmpty()) {
+						Archives archives = archivesListFXHX.stream().filter(e -> e.getCode().equals(item.getBoxCode())).findFirst().orElse(null);
+						if (archives != null) {
+							if (ObjectUtils.isNotNull(archives.getBillNo())) {
+								//截取提单号前缀,判断是否是OW(放)放箱号
+								String data = archives.getBillNo().substring(0, fixedPrefix.length());
+								if (fixedPrefix.equals(data)) {
+									itemsListFXHX.add(item);
+									continue;
+								}
+							}
+						}
+					}
+					itemsListFCs.add(item);
+				}
+				//OW放-客户还箱
+				if (!itemsListFXHX.isEmpty()) {
+					Boolean status = this.synchronizationFXHX(itemsListFXHX, boxDynamicsRecord, type);
+					if (!status) {
+						return false;
+					}
+				}
+				if (itemsListFCs.isEmpty()) {
+					return true;
+				}
+				List<String> boxNumFC = itemsListFCs.stream().map(BoxDynamicsRecordItems::getBoxCode).filter(Objects::nonNull)
+					.collect(Collectors.toList());
+				if (boxNumFC.isEmpty()) {
+					failureHandling(type, boxDynamicsRecord, "所选配箱信息箱号不能为空");
+					return false;
+				}
+				//箱档案数据
+				List<Archives> archivesList = archivesService.list(new LambdaQueryWrapper<Archives>()
+					.eq(Archives::getTenantId, boxDynamicsRecord.getTenantId())
+					.eq(Archives::getIsDeleted, 0)
+					.in(Archives::getCode, boxNumFC));
 				List<BoxDynamicsRecordItems> itemsListFC = new ArrayList<>();
 				//判断是否有未查到箱档案数据的箱号  未查到的一律按照新箱进场逻辑走
 				if (boxNum.size() != archivesList.size()) {
@@ -2295,8 +2343,8 @@ public class BoxDynamicsRecordServiceImpl extends ServiceImpl<BoxDynamicsRecordM
 								putBoxItem = putBoxItemsList.stream().filter(e -> e.getBoxCode().equals(recordItems.getBoxCode())
 									&& e.getPid().equals(putBoxOld.getId())).findFirst().orElse(null);
 								if (putBoxItem != null) {
-									putBoxItem = EntryExitDataHandleUtils.putBoxItemDataHandle(putBoxItem,recordItems,putBoxOld,
-										false,null,"已返场","已还箱","5");
+									putBoxItem = EntryExitDataHandleUtils.putBoxItemDataHandle(putBoxItem, recordItems, putBoxOld,
+										false, null, "已返场", "已还箱", "5", false);
 									if (putBoxItem.getTemporaryStatus()) {
 										failureHandling(type, boxDynamicsRecord, "放箱号:" + recordItems.getContainerNumber() + "中箱号:" +
 											recordItems.getBoxCode() + "未出场,不允许直接还箱");
@@ -2362,8 +2410,8 @@ public class BoxDynamicsRecordServiceImpl extends ServiceImpl<BoxDynamicsRecordM
 										tradingBoxItem = tradingBoxItemList.stream().filter(e -> e.getCode().equals(recordItems.getBoxCode()))
 											.findFirst().orElse(null);
 										if (tradingBoxItem != null) {
-											tradingBoxItem = EntryExitDataHandleUtils.tradingBoxItemDataHandle(tradingBoxItem,recordItems,tradingBox,
-												false,bills,"已返场","已还箱","5");
+											tradingBoxItem = EntryExitDataHandleUtils.tradingBoxItemDataHandle(tradingBoxItem, recordItems, tradingBox,
+												false, bills, "已返场", "已还箱", "5");
 											tradingBoxItemOldList.add(tradingBoxItem);
 										}
 									}
@@ -2377,7 +2425,7 @@ public class BoxDynamicsRecordServiceImpl extends ServiceImpl<BoxDynamicsRecordM
 							}
 						}
 						//箱档案数据处理
-						archives = ArchivesUtils.dataAssembly(archives,recordItems,"空箱提箱进场","待使用",null);
+						archives = ArchivesUtils.dataAssembly(archives, recordItems, "空箱提箱进场", "待使用", null);
 						archivesArrayList.add(archives);
 						if (!containerNumberType.equals("OW(拿)")) {
 							//新放箱号数据处理
@@ -2390,13 +2438,14 @@ public class BoxDynamicsRecordServiceImpl extends ServiceImpl<BoxDynamicsRecordM
 								if (!putBoxItemsList.isEmpty()) {
 									putBoxItem = putBoxItemsList.stream().filter(e -> e.getBoxCode().equals(recordItems.getBoxCode())
 										&& putBox.getId().equals(e.getPid())).findFirst().orElse(null);
-									putBoxItem = EntryExitDataHandleUtils.putBoxItemDataHandle(putBoxItem,recordItems,putBox,
-										false,null,"空箱提箱进场","待使用","5");
+									putBoxItem = EntryExitDataHandleUtils.putBoxItemDataHandle(putBoxItem, recordItems, putBox,
+										false, null, "空箱提箱进场", "待使用", "9", false);
+									putBoxItemsNewList.add(putBoxItem);
 								} else {
-									putBoxItem = EntryExitDataHandleUtils.putBoxItemDataHandle(null,recordItems,putBox,
-										false,null,"空箱提箱进场","待使用","5");
+									putBoxItem = EntryExitDataHandleUtils.putBoxItemDataHandle(null, recordItems, putBox,
+										false, null, "空箱提箱进场", "待使用", "9", false);
+									putBoxItemsNewList.add(putBoxItem);
 								}
-								putBoxItemsNewList.add(putBoxItem);
 								recordItems.setSrcPutBoxPodId(putBox.getId());
 								if (putBoxNewList.isEmpty()) {
 									putBoxNewList.add(putBox);
@@ -2715,16 +2764,16 @@ public class BoxDynamicsRecordServiceImpl extends ServiceImpl<BoxDynamicsRecordM
 							putBoxItem = putBoxItemsList.stream().filter(e -> e.getBoxCode().equals(item.getBoxCode()) &&
 									e.getPid().equals(putBox.getId()))
 								.findFirst().orElse(null);
-							putBoxItem = EntryExitDataHandleUtils.putBoxItemDataHandle(putBoxItem,item,putBox,
-								false,null,"调箱进场","待使用","2");
+							putBoxItem = EntryExitDataHandleUtils.putBoxItemDataHandle(putBoxItem, item, putBox,
+								false, null, "调箱进场", "待使用", "2", false);
 							if (putBoxItem.getTemporaryStatus()) {
 								failureHandling(type, boxDynamicsRecord, "放箱号:" + item.getContainerNumber() + "箱号:" +
 									item.getBoxCode() + "状态为使用中,请先还箱");
 								return false;
 							}
 						} else {
-							putBoxItem = EntryExitDataHandleUtils.putBoxItemDataHandle(null,item,putBox,
-								false,null,"调箱进场","待使用","2");
+							putBoxItem = EntryExitDataHandleUtils.putBoxItemDataHandle(null, item, putBox,
+								false, null, "调箱进场", "待使用", "2", false);
 						}
 						putBoxItems.add(putBoxItem);
 						boolean samePort = true;
@@ -2747,12 +2796,12 @@ public class BoxDynamicsRecordServiceImpl extends ServiceImpl<BoxDynamicsRecordM
 								if (!tradingBoxItemList.isEmpty()) {
 									tradingBoxItem = tradingBoxItemList.stream().filter(e -> e.getCode().equals(item.getBoxCode()))
 										.findFirst().orElse(null);
-									tradingBoxItem = EntryExitDataHandleUtils.tradingBoxItemDataHandle(tradingBoxItem,item,tradingBox,
-										false,null,"调箱进场","待使用","2");
+									tradingBoxItem = EntryExitDataHandleUtils.tradingBoxItemDataHandle(tradingBoxItem, item, tradingBox,
+										false, null, "调箱进场", "待使用", "2");
 
 								} else {
-									tradingBoxItem = EntryExitDataHandleUtils.tradingBoxItemDataHandle(null,item,tradingBox,
-										false,null,"调箱进场","待使用","2");
+									tradingBoxItem = EntryExitDataHandleUtils.tradingBoxItemDataHandle(null, item, tradingBox,
+										false, null, "调箱进场", "待使用", "2");
 								}
 								tradingBoxItems.add(tradingBoxItem);
 							}
@@ -2766,13 +2815,13 @@ public class BoxDynamicsRecordServiceImpl extends ServiceImpl<BoxDynamicsRecordM
 							}
 							//存储上一步数据
 							BoxNumUtils.storagePreviousStepData(archives, item);
-							archives = ArchivesUtils.dataAssembly(archives,item,"调箱进场","待使用",putBox.getBoxClass());
+							archives = ArchivesUtils.dataAssembly(archives, item, "调箱进场", "待使用", putBox.getBoxClass());
 						} else {
 							if (!"OW(拿),代理箱,租箱".contains(putBox.getBoxClass())) {
 								failureHandling(type, boxDynamicsRecord, "箱档案中未查到箱号:" + item.getBoxCode());
 								return false;
 							}
-							archives = ArchivesUtils.dataAssembly(archives,item,"调箱进场","待使用",putBox.getBoxClass());
+							archives = ArchivesUtils.dataAssembly(archives, item, "调箱进场", "待使用", putBox.getBoxClass());
 						}
 						if (samePort) {
 							archives.setWhetherTransfer("1");
@@ -3073,8 +3122,8 @@ public class BoxDynamicsRecordServiceImpl extends ServiceImpl<BoxDynamicsRecordM
 											recordItems.getBoxCode() + "未出场,不允许直接还箱");
 										return false;
 									}
-									putBoxItem = EntryExitDataHandleUtils.putBoxItemDataHandle(putBoxItem,recordItems,putBox,
-										false,null,"空箱提箱进场","待使用","6");
+									putBoxItem = EntryExitDataHandleUtils.putBoxItemDataHandle(putBoxItem, recordItems, putBox,
+										false, null, "空箱提箱进场", "待使用", "6", false);
 									putBoxItemsNewList.add(putBoxItem);
 								} else {
 									failureHandling(type, boxDynamicsRecord, "放箱号:" + recordItems.getContainerNumber() + "中,箱号:"
@@ -3103,8 +3152,8 @@ public class BoxDynamicsRecordServiceImpl extends ServiceImpl<BoxDynamicsRecordM
 										tradingBoxItem = tradingBoxItemList.stream().filter(e -> e.getCode().equals(recordItems.getBoxCode()))
 											.findFirst().orElse(null);
 										if (tradingBoxItem != null) {
-											tradingBoxItem = EntryExitDataHandleUtils.tradingBoxItemDataHandle(tradingBoxItem,recordItems,tradingBox,
-												false,null,"空箱提箱进场","待使用","6");
+											tradingBoxItem = EntryExitDataHandleUtils.tradingBoxItemDataHandle(tradingBoxItem, recordItems, tradingBox,
+												false, null, "空箱提箱进场", "待使用", "6");
 											tradingBoxItemOldList.add(tradingBoxItem);
 										} else {
 											failureHandling(type, boxDynamicsRecord, "放箱号:" + recordItems.getContainerNumber() + "来源单据中,箱号:"
@@ -3133,7 +3182,7 @@ public class BoxDynamicsRecordServiceImpl extends ServiceImpl<BoxDynamicsRecordM
 							failureHandling(type, boxDynamicsRecord, "放箱号:" + recordItems.getContainerNumber() + "未查到");
 							return false;
 						}
-						ArchivesUtils.dataAssembly(archives,recordItems,"","",null);
+						ArchivesUtils.dataAssembly(archives, recordItems, "", "", null);
 						archivesArrayList.add(archives);
 					}
 					if (!archivesArrayList.isEmpty()) {
@@ -3646,7 +3695,7 @@ public class BoxDynamicsRecordServiceImpl extends ServiceImpl<BoxDynamicsRecordM
 							}
 						}
 						//箱档案数据处理
-						archives = ArchivesUtils.dataAssembly(archives,item,"调箱出场","使用中",putBoxData.getBoxClass());
+						archives = ArchivesUtils.dataAssembly(archives, item, "调箱出场", "使用中", putBoxData.getBoxClass());
 						archives.setTemporaryId(item.getTemporaryId());
 						archivesArrayList.add(archives);
 						if (ObjectUtils.isNotNull(putBoxData.getBoxType()) && !putBoxData.getBoxType().equals(item.getBoxType())) {
@@ -3658,11 +3707,11 @@ public class BoxDynamicsRecordServiceImpl extends ServiceImpl<BoxDynamicsRecordM
 						if (!putBoxItemsList.isEmpty()) {
 							putBoxItem = putBoxItemsList.stream().filter(e -> e.getBoxCode().equals(item.getBoxCode()) &&
 								e.getPid().equals(putBoxData.getId())).findFirst().orElse(null);
-							putBoxItem = EntryExitDataHandleUtils.putBoxItemDataHandle(putBoxItem,item,putBoxData,false,null,
-								"调箱出场","使用中","4");
+							putBoxItem = EntryExitDataHandleUtils.putBoxItemDataHandle(putBoxItem, item, putBoxData, false, null,
+								"调箱出场", "使用中", "4", false);
 						} else {
-							putBoxItem = EntryExitDataHandleUtils.putBoxItemDataHandle(null,item,putBoxData,false,null,
-								"调箱出场","使用中","4");
+							putBoxItem = EntryExitDataHandleUtils.putBoxItemDataHandle(null, item, putBoxData, false, null,
+								"调箱出场", "使用中", "4", false);
 						}
 						putBoxItems.add(putBoxItem);
 						if (!tradingBoxList.isEmpty()) {
@@ -3681,11 +3730,11 @@ public class BoxDynamicsRecordServiceImpl extends ServiceImpl<BoxDynamicsRecordM
 								if (!tradingBoxItemList.isEmpty()) {
 									tradingBoxItem = tradingBoxItemList.stream().filter(e -> e.getCode().equals(item.getBoxCode()))
 										.findFirst().orElse(null);
-									tradingBoxItem = EntryExitDataHandleUtils.tradingBoxItemDataHandle(tradingBoxItem,item,tradingBox,false,null,
-										"调箱出场","使用中","4");
+									tradingBoxItem = EntryExitDataHandleUtils.tradingBoxItemDataHandle(tradingBoxItem, item, tradingBox, false, null,
+										"调箱出场", "使用中", "4");
 								} else {
-									tradingBoxItem = EntryExitDataHandleUtils.tradingBoxItemDataHandle(null,item,tradingBox,false,null,
-										"调箱出场","使用中","4");
+									tradingBoxItem = EntryExitDataHandleUtils.tradingBoxItemDataHandle(null, item, tradingBox, false, null,
+										"调箱出场", "使用中", "4");
 								}
 								tradingBoxItems.add(tradingBoxItem);
 							}
@@ -4007,7 +4056,9 @@ public class BoxDynamicsRecordServiceImpl extends ServiceImpl<BoxDynamicsRecordM
 					}
 					//截取提单号前缀,判断是否是OW(放)放箱号
 					String data = item.getHblno().substring(0, fixedPrefix.length());
+					boolean whetherFX = false;
 					if (fixedPrefix.equals(data)) {
+						whetherFX = true;
 						PutBox putBox = putBoxList.stream().filter(e -> e.getContainerNumber().equals(item.getContainerNumber())
 							&& ObjectUtils.isNotNull(e.getPolId()) && item.getHblno().equals(e.getSrcContainerNumber())).findFirst().orElse(null);
 						if (putBox != null) {
@@ -4022,7 +4073,7 @@ public class BoxDynamicsRecordServiceImpl extends ServiceImpl<BoxDynamicsRecordM
 								PutBoxItems putBoxItem = putBoxItemsList.stream().filter(e -> e.getBoxCode().equals(item.getBoxCode()) &&
 									e.getPid().equals(putBox.getId())).findFirst().orElse(null);
 								if (putBoxItem == null) {
-									putBoxItem = EntryExitDataHandleUtils.putBoxItemDataHandle(putBoxItem,item,putBox,false,null,"空箱出场","使用中","8");
+									putBoxItem = EntryExitDataHandleUtils.putBoxItemDataHandle(putBoxItem, item, putBox, false, null, "空箱出场", "使用中", "8", false);
 									putBoxItemsOwf.add(putBoxItem);
 								} else {
 									failureHandling(type, boxDynamicsRecord, "放箱号:" + item.getContainerNumber() + "中箱号:" + item.getBoxCode() + "已存在");
@@ -4073,7 +4124,7 @@ public class BoxDynamicsRecordServiceImpl extends ServiceImpl<BoxDynamicsRecordM
 					}
 					//海运单据
 					Bills bills;
-					if (!billsList.isEmpty()) {
+					if (!billsList.isEmpty() && !whetherFX) {
 						//只查分单加直单
 						bills = billsList.stream().filter(e -> "MH,DD".contains(e.getBillType())
 							&& ObjectUtils.isNotNull(item.getHblno()) && item.getHblno().equals(e.getHblno())).findFirst().orElse(null);
@@ -4124,12 +4175,14 @@ public class BoxDynamicsRecordServiceImpl extends ServiceImpl<BoxDynamicsRecordM
 						}
 					} else {
 						bills = null;
-						//判断出场港口是否国内或越南港口,是提单号必须存在  否需提示但箱正常出场
-						if (intercept) {
-							failureHandling(type, boxDynamicsRecord, "未查到提单号:" + item.getHblno() + "对应海运出口单据");
-							return false;
-						} else {
-							failureHandling("3", boxDynamicsRecord, "未查到提单号:" + item.getHblno() + "对应海运出口单据");
+						if (!whetherFX) {
+							//判断出场港口是否国内或越南港口,是提单号必须存在  否需提示但箱正常出场
+							if (intercept) {
+								failureHandling(type, boxDynamicsRecord, "未查到提单号:" + item.getHblno() + "对应海运出口单据");
+								return false;
+							} else {
+								failureHandling("3", boxDynamicsRecord, "未查到提单号:" + item.getHblno() + "对应海运出口单据");
+							}
 						}
 					}
 					//放箱号明细数据处理
@@ -4138,7 +4191,7 @@ public class BoxDynamicsRecordServiceImpl extends ServiceImpl<BoxDynamicsRecordM
 						putBoxItem = putBoxItemsList.stream().filter(e -> e.getBoxCode().equals(item.getBoxCode()) &&
 							e.getPid().equals(putBoxData.getId())).findFirst().orElse(null);
 						if (putBoxItem != null) {
-							putBoxItem = EntryExitDataHandleUtils.putBoxItemDataHandle(putBoxItem,item,putBoxData,whetherExistence,bills,"空箱出场","使用中","3");
+							putBoxItem = EntryExitDataHandleUtils.putBoxItemDataHandle(putBoxItem, item, putBoxData, whetherExistence, bills, "空箱出场", "使用中", "3", whetherFX);
 							putBoxItems.add(putBoxItem);
 						} else {
 							failureHandling(type, boxDynamicsRecord, "放箱号:" + item.getContainerNumber() + "未查到箱号:" + item.getBoxCode() + "进场记录");
@@ -4189,8 +4242,8 @@ public class BoxDynamicsRecordServiceImpl extends ServiceImpl<BoxDynamicsRecordM
 									tradingBoxItem = tradingBoxItemList.stream().filter(e -> e.getCode().equals(item.getBoxCode()))
 										.findFirst().orElse(null);
 									if (tradingBoxItem != null) {
-										tradingBoxItem = EntryExitDataHandleUtils.tradingBoxItemDataHandle(tradingBoxItem,item,tradingBox,whetherExistence
-											,bills,"空箱出场","使用中","3");
+										tradingBoxItem = EntryExitDataHandleUtils.tradingBoxItemDataHandle(tradingBoxItem, item, tradingBox, whetherExistence
+											, bills, "空箱出场", "使用中", "3");
 										tradingBoxItems.add(tradingBoxItem);
 									} else {
 										failureHandling(type, boxDynamicsRecord, "OW(拿)放箱号:" + item.getContainerNumber() + "未查到箱号:" + item.getBoxCode() + "进场记录");
@@ -4212,7 +4265,7 @@ public class BoxDynamicsRecordServiceImpl extends ServiceImpl<BoxDynamicsRecordM
 					//存储上一步数据
 					BoxNumUtils.storagePreviousStepData(archives, item);
 					//箱档案数据处理
-					archives = ArchivesUtils.dataAssembly(archives,item,"空箱出场","使用中",putBoxData.getBoxClass());
+					archives = ArchivesUtils.dataAssembly(archives, item, "空箱出场", "使用中", putBoxData.getBoxClass());
 					archivesArrayList.add(archives);
 					//海运单据配箱数据处理
 					if (!"OW(放)".equals(putBoxData.getBoxClass()) && ObjectUtils.isNotNull(item.getHblno())) {
@@ -4551,9 +4604,9 @@ public class BoxDynamicsRecordServiceImpl extends ServiceImpl<BoxDynamicsRecordM
 				if (!archivesArrayList.isEmpty()) {
 					archivesService.saveOrUpdateBatch(archivesArrayList);
 				}
-				if (!putBoxItemsOwf.isEmpty()){
+				if (!putBoxItemsOwf.isEmpty()) {
 					putBoxItemsService.saveOrUpdateBatch(putBoxItemsOwf);
-					if (!putBoxesOwf.isEmpty()){
+					if (!putBoxesOwf.isEmpty()) {
 						for (PutBox item : putBoxesOwf) {
 							//主表增加本次出场箱号数据
 							if (ObjectUtils.isNotNull(item.getCode())) {
@@ -4616,6 +4669,381 @@ public class BoxDynamicsRecordServiceImpl extends ServiceImpl<BoxDynamicsRecordM
 		return true;
 	}
 
+	private Boolean synchronizationFXHX(List<BoxDynamicsRecordItems> itemsListFXHX, BoxDynamicsRecord boxDynamicsRecord, String type) throws IOException {
+		List<String> boxNum = itemsListFXHX.stream().map(BoxDynamicsRecordItems::getBoxCode).filter(Objects::nonNull)
+			.collect(Collectors.toList());
+		if (boxNum.isEmpty()) {
+			failureHandling(type, boxDynamicsRecord, "所选配箱信息箱号不能为空");
+			return false;
+		}
+		//箱档案数据
+		List<Archives> archivesList = archivesService.list(new LambdaQueryWrapper<Archives>()
+			.eq(Archives::getTenantId, boxDynamicsRecord.getTenantId())
+			.eq(Archives::getIsDeleted, 0)
+			.in(Archives::getCode, boxNum));
+		if (archivesList.isEmpty()) {
+			failureHandling(type, boxDynamicsRecord, "未查到客户还箱箱档案数据");
+			return false;
+		}
+		List<String> containerNumberList = itemsListFXHX.stream().map(BoxDynamicsRecordItems::getContainerNumber)
+			.distinct().collect(Collectors.toList());
+		List<String> billNoList = archivesList.stream().map(Archives::getBillNo)
+			.distinct().collect(Collectors.toList());
+		List<PutBox> putBoxList = putBoxService.list(new LambdaQueryWrapper<PutBox>()
+			.eq(PutBox::getTenantId, boxDynamicsRecord.getTenantId())
+			.eq(PutBox::getIsDeleted, 0)
+			.and(i -> i.in(PutBox::getContainerNumber, containerNumberList).or()
+				.in(PutBox::getContainerNumber, billNoList)));
+		if (putBoxList.isEmpty()) {
+			failureHandling(type, boxDynamicsRecord, "未查到放箱号单据");
+			return false;
+		}
+		List<Long> putBoxIdList = putBoxList.stream().map(PutBox::getId).collect(Collectors.toList());
+		List<PutBoxItems> putBoxItemsList = putBoxItemsService.list(new LambdaQueryWrapper<PutBoxItems>()
+			.eq(PutBoxItems::getIsDeleted, 0)
+			.eq(PutBoxItems::getTenantId, boxDynamicsRecord.getTenantId())
+			.in(PutBoxItems::getPid, putBoxIdList));
+		List<Long> srcIdList = putBoxList.stream().map(PutBox::getSrcId).collect(Collectors.toList());
+		List<TradingBox> tradingBoxList = new ArrayList<>();
+		if (!srcIdList.isEmpty()) {
+			tradingBoxList = tradingBoxMapper.selectList(new LambdaQueryWrapper<TradingBox>()
+				.eq(TradingBox::getTenantId, boxDynamicsRecord.getTenantId())
+				.eq(TradingBox::getIsDeleted, 0)
+				.in(TradingBox::getId, srcIdList));
+		}
+		List<TradingBoxItem> tradingBoxItemList = new ArrayList<>();
+		if (!tradingBoxList.isEmpty()) {
+			List<Long> tradingBoxIdList = tradingBoxList.stream().map(TradingBox::getId).collect(Collectors.toList());
+			tradingBoxItemList = tradingBoxItemService.list(new LambdaQueryWrapper<TradingBoxItem>()
+				.eq(TradingBoxItem::getIsDeleted, 0)
+				.eq(TradingBoxItem::getTenantId, boxDynamicsRecord.getTenantId())
+				.in(TradingBoxItem::getPid, tradingBoxIdList));
+		}
+		//自有箱-箱档案数据更新
+		List<Archives> archivesArrayList = new ArrayList<>();
+		//新放箱号单据
+		List<PutBox> putBoxNewList = new ArrayList<>();
+		//新放箱号单据
+		List<PutBox> putBoxes = new ArrayList<>();
+		//新放箱号单据明细数据
+		List<PutBoxItems> putBoxItemsNewList = new ArrayList<>();
+		//原放箱号单据明细数据
+		List<PutBoxItems> putBoxItemsOldFXList = new ArrayList<>();
+		//原放箱号单据明细数据
+		List<PutBoxItems> putBoxItemsOldList = new ArrayList<>();
+		//原OW单据明细数据
+		List<TradingBoxItem> tradingBoxItemOldList = new ArrayList<>();
+		List<TradingBox> tradingBoxes = new ArrayList<>();
+		for (BoxDynamicsRecordItems recordItems : itemsListFXHX) {
+			if (ObjectUtils.isNull(recordItems.getApproachExitDate())) {
+				recordItems.setApproachExitDate(new Date());
+			}
+			recordItems.setTemporaryId(StringTools.generateRandomString(32));
+			//箱档案信息处理
+			Archives archives = archivesList.stream().filter(e -> e.getCode().equals(recordItems.getBoxCode())).findFirst().orElse(null);
+			if (archives == null) {
+				failureHandling(type, boxDynamicsRecord, "未查到箱号:" + recordItems.getBoxCode() + "箱档案数据");
+				return false;
+			}
+			//存储上一步数据
+			BoxNumUtils.storagePreviousStepData(archives, recordItems);
+
+			//原OW放-放箱号数据处理
+			Archives finalArchives = archives;
+			PutBox putBoxOldFX = putBoxList.stream().filter(e -> e.getContainerNumber().equals(finalArchives.getBillNo()))
+				.findFirst().orElse(null);
+			if (putBoxOldFX != null) {
+				PutBoxItems putBoxItem;
+				if (!putBoxItemsList.isEmpty()) {
+					putBoxItem = putBoxItemsList.stream().filter(e -> e.getBoxCode().equals(recordItems.getBoxCode())
+						&& e.getPid().equals(putBoxOldFX.getId())).findFirst().orElse(null);
+					if (putBoxItem != null) {
+						putBoxItem = EntryExitDataHandleUtils.putBoxItemDataHandle(putBoxItem, recordItems, putBoxOldFX,
+							false, null, "已返场", "已还箱", "5", false);
+						if (putBoxItem.getTemporaryStatus()) {
+							failureHandling(type, boxDynamicsRecord, "放箱号:" + recordItems.getContainerNumber() + "中箱号:" +
+								recordItems.getBoxCode() + "未出场,不允许直接还箱");
+							return false;
+						}
+						putBoxItemsOldFXList.add(putBoxItem);
+					}
+				}
+				if (!tradingBoxList.isEmpty()) {
+					TradingBox tradingBox = tradingBoxList.stream().filter(e -> e.getId().equals(putBoxOldFX.getSrcId()))
+						.findFirst().orElse(null);
+					if (tradingBox != null) {
+						recordItems.setSrcTradingBoxId(tradingBox.getId());
+						if (!tradingBoxes.isEmpty()) {
+							if (!tradingBoxes.stream().map(TradingBox::getId).collect(Collectors.toList()).contains(tradingBox.getId())) {
+								tradingBoxes.add(tradingBox);
+							}
+						} else {
+							tradingBoxes.add(tradingBox);
+						}
+						TradingBoxItem tradingBoxItem;
+						if (!tradingBoxItemList.isEmpty()) {
+							tradingBoxItem = tradingBoxItemList.stream().filter(e -> e.getCode().equals(recordItems.getBoxCode()))
+								.findFirst().orElse(null);
+							if (tradingBoxItem != null) {
+								tradingBoxItem = EntryExitDataHandleUtils.tradingBoxItemDataHandle(tradingBoxItem, recordItems, tradingBox,
+									false, null, "已返场", "已还箱", "5");
+								tradingBoxItemOldList.add(tradingBoxItem);
+							}
+						}
+					}
+				}
+			}
+			//原自有箱放箱号数据处理
+			PutBox putBoxOld = putBoxList.stream().filter(e -> e.getContainerNumber().equals(recordItems.getContainerNumber())
+				&& e.getPolId().equals(finalArchives.getAddressId()) && e.getPolStationId().equals(finalArchives.getStationId())
+				&& e.getBoxType().equals(finalArchives.getTypeName())).findFirst().orElse(null);
+			if (putBoxOld != null) {
+				if (putBoxes.isEmpty()) {
+					putBoxes.add(putBoxOld);
+				} else {
+					PutBox putBox1 = putBoxes.stream().filter(e -> e.getId().equals(putBoxOld.getId())).findFirst().orElse(null);
+					if (putBox1 == null) {
+						putBoxes.add(putBoxOld);
+					}
+				}
+				PutBoxItems putBoxItem;
+				if (!putBoxItemsList.isEmpty()) {
+					putBoxItem = putBoxItemsList.stream().filter(e -> e.getBoxCode().equals(recordItems.getBoxCode())
+						&& e.getPid().equals(putBoxOld.getId())).findFirst().orElse(null);
+					if (putBoxItem != null) {
+						putBoxItem = EntryExitDataHandleUtils.putBoxItemDataHandle(putBoxItem, recordItems, putBoxOld,
+							false, null, "已返场", "已还箱", "5", false);
+						if (putBoxItem.getTemporaryStatus()) {
+							failureHandling(type, boxDynamicsRecord, "放箱号:" + recordItems.getContainerNumber() + "中箱号:" +
+								recordItems.getBoxCode() + "未出场,不允许直接还箱");
+							return false;
+						}
+						putBoxItemsOldList.add(putBoxItem);
+					}
+				}
+			}
+			//箱档案数据处理
+			archives = ArchivesUtils.dataAssembly(archives, recordItems, "空箱提箱进场", "待使用", null);
+			archivesArrayList.add(archives);
+			//新放箱号数据处理
+			PutBox putBox = putBoxList.stream().filter(e -> e.getContainerNumber().equals(recordItems.getContainerNumber())
+				&& e.getPolId().equals(recordItems.getPortId()) && e.getPolStationId().equals(recordItems.getStationId())
+				&& e.getBoxType().equals(recordItems.getBoxType())).findFirst().orElse(null);
+			if (putBox != null) {
+				//放箱号明细数据处理
+				PutBoxItems putBoxItem;
+				if (!putBoxItemsList.isEmpty()) {
+					putBoxItem = putBoxItemsList.stream().filter(e -> e.getBoxCode().equals(recordItems.getBoxCode())
+						&& putBox.getId().equals(e.getPid())).findFirst().orElse(null);
+					if (putBoxItem != null) {
+						putBoxItem = EntryExitDataHandleUtils.putBoxItemDataHandle(putBoxItem, recordItems, putBox,
+							false, null, "空箱提箱进场", "待使用", "5", false);
+						putBoxItemsNewList.add(putBoxItem);
+					}
+				} else {
+					putBoxItem = EntryExitDataHandleUtils.putBoxItemDataHandle(null, recordItems, putBox,
+						false, null, "空箱提箱进场", "待使用", "5", false);
+					putBoxItemsNewList.add(putBoxItem);
+				}
+				recordItems.setSrcPutBoxPodId(putBox.getId());
+				if (putBoxNewList.isEmpty()) {
+					putBoxNewList.add(putBox);
+				} else {
+					PutBox putBox1 = putBoxNewList.stream().filter(e -> e.getId().equals(putBox.getId())).findFirst().orElse(null);
+					if (putBox1 == null) {
+						putBoxNewList.add(putBox);
+					}
+				}
+			} else {
+				failureHandling(type, boxDynamicsRecord, "放箱号:" + recordItems.getContainerNumber() + "未查到");
+				return false;
+			}
+		}
+		if (!archivesArrayList.isEmpty()) {
+			archivesService.updateBatchById(archivesArrayList);
+		}
+		if (!putBoxItemsOldFXList.isEmpty()) {
+			putBoxItemsService.updateBatchById(putBoxItemsOldFXList);
+		}
+		if (!putBoxNewList.isEmpty()) {
+			for (PutBox item : putBoxNewList) {
+				if (!putBoxItemsNewList.isEmpty()) {
+					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);
+				}
+			}
+			putBoxService.saveOrUpdateBatch(putBoxNewList);
+		}
+		if (!putBoxItemsNewList.isEmpty()) {
+			putBoxItemsService.saveOrUpdateBatch(putBoxItemsNewList);
+			for (PutBoxItems item : putBoxItemsNewList) {
+				PutBox putBox = putBoxNewList.stream().filter(e -> e.getId().equals(item.getPid())).findFirst().orElse(null);
+				if (putBox != null) {
+					//记录箱轨迹信息
+					ArchivesTrajectory archivesTrajectory = new ArchivesTrajectory();
+					archivesTrajectory.setPortId(putBox.getPolId());
+					archivesTrajectory.setPortCode(putBox.getPolCode());
+					archivesTrajectory.setPortCname(putBox.getPolCname());
+					archivesTrajectory.setPortEname(putBox.getPolEname());
+					archivesTrajectory.setStationId(putBox.getPolStationId());
+					archivesTrajectory.setStationCode(putBox.getPolStationCode());
+					archivesTrajectory.setStationCname(putBox.getPolStationCname());
+					archivesTrajectory.setStationEname(putBox.getPolStationEname());
+					archivesTrajectory.setContainerNumber(item.getContainerNumber());
+					archivesTrajectory.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 = itemsListFXHX.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);
+				}
+			}
+		} 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 = itemsListFXHX.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);
+		}
+		if (!tradingBoxItemOldList.isEmpty()) {
+			tradingBoxItemService.updateBatchById(tradingBoxItemOldList);
+		}
+		for (BoxDynamicsRecordItems item : itemsListFXHX) {
+			item.setWhetherSynchronous("1");
+			if (!putBoxItemsNewList.isEmpty()) {
+				putBoxItemsNewList.stream().filter(e -> item.getTemporaryId().equals(e.getTemporaryId())).findFirst().ifPresent(putBox -> item.setSrcPutBoxItemsPodId(putBox.getId()));
+			}
+			if (!archivesArrayList.isEmpty()) {
+				archivesArrayList.stream().filter(e -> item.getTemporaryId().equals(e.getTemporaryId())).findFirst().ifPresent(putBox -> item.setSrcArchivesId(putBox.getId()));
+			}
+		}
+		boxDynamicsRecordItemsService.updateBatchById(itemsListFXHX);
+		return true;
+	}
+
 	/**
 	 * 进出场数据错误统一处理
 	 *

+ 38 - 6
blade-service/blade-los/src/main/java/org/springblade/los/box/service/impl/TradingBoxServiceImpl.java

@@ -1643,7 +1643,7 @@ public class TradingBoxServiceImpl extends ServiceImpl<TradingBoxMapper, Trading
 				.eq(PutBox::getPolId, detail.getPolId())
 				.eq(ObjectUtils.isNotNull(boxType), PutBox::getBoxType, boxType)
 				.eq(PutBox::getPolStationId, detail.getPolStationId());
-			if ("OW-N".contains(tradingBox.getType())) {
+			if ("OW-F".contains(tradingBox.getType())) {
 				lambdaQueryWrapper.eq(PutBox::getSrcContainerNumber, detail.getInternalContainerNumber());
 			} else {
 				lambdaQueryWrapper.eq(PutBox::getContainerNumber, detail.getContainerNumber());
@@ -1716,8 +1716,9 @@ public class TradingBoxServiceImpl extends ServiceImpl<TradingBoxMapper, Trading
 				}
 				putBox.setSrcId(tradingBox.getId());
 				putBox.setSrcNo(tradingBox.getSysNo());
-				if ("OW-N".contains(tradingBox.getType())) {
+				if ("OW-F".contains(tradingBox.getType())) {
 					putBox.setSrcContainerNumber(tradingBox.getInternalContainerNumber());
+					putBox.setInternalContainerNumber(tradingBox.getInternalContainerNumber());
 					PutBox putBoxOld = putBoxService.getById(tradingBox.getSrcContainerNumberId());
 					if (putBoxOld == null) {
 						throw new RuntimeException("未查到原放箱号数据");
@@ -1758,7 +1759,7 @@ public class TradingBoxServiceImpl extends ServiceImpl<TradingBoxMapper, Trading
 					if (putBoxOld.getRemainingNum() < 0) {
 						throw new RuntimeException("放箱号:" + putBoxOld.getContainerNumber() + "可用数量不足");
 					}
-					putBoxOld.setVersion(putBoxOld.getVersion()+1);
+					putBoxOld.setVersion(putBoxOld.getVersion() + 1);
 					putBoxService.updateById(putBoxOld);
 				} else {
 					putBox.setSrcContainerNumber(tradingBox.getContainerNumber());
@@ -2899,7 +2900,7 @@ public class TradingBoxServiceImpl extends ServiceImpl<TradingBoxMapper, Trading
 		if (putBox.getRemainingNum() < tradingBox.getCancelNumber()) {
 			throw new RuntimeException("取消数量大于放箱号可用数量");
 		}
-		putBox.setRemainingNum(tradingBox.getBoxNumber() - putBox.getOccupyNum() - alreadyAppeared-tradingBox.getCancelNumber());
+		putBox.setRemainingNum(tradingBox.getBoxNumber() - putBox.getOccupyNum() - alreadyAppeared - tradingBox.getCancelNumber());
 		putBox.setVersion(putBox.getVersion() + 1);
 		putBoxService.updateById(putBox);
 		return R.data(tradingBox);
@@ -3350,7 +3351,6 @@ public class TradingBoxServiceImpl extends ServiceImpl<TradingBoxMapper, Trading
 		PutBox putBox = putBoxService.getOne(new LambdaQueryWrapper<PutBox>()
 			.eq(PutBox::getTenantId, AuthUtil.getTenantId())
 			.eq(PutBox::getIsDeleted, 0)
-			.eq(PutBox::getSrcContainerNumber, tradingBox.getContainerNumber())
 			.eq(PutBox::getSrcNo, tradingBox.getSysNo())
 			.eq(PutBox::getSrcId, tradingBox.getId())
 			.eq(PutBox::getWhetherManuallyCreate, "1")
@@ -3372,7 +3372,39 @@ public class TradingBoxServiceImpl extends ServiceImpl<TradingBoxMapper, Trading
 					putBoxItemsService.removeByIds(boxItemsList.stream().map(PutBoxItems::getId).collect(Collectors.toList()));
 				}
 			}
-			putBoxService.removeById(putBox.getId());
+			putBox.setUpdateTime(new Date());
+			putBox.setUpdateUserName(AuthUtil.getUserName());
+			putBox.setUpdateUser(AuthUtil.getUserId());
+			putBox.setIsDeleted(1);
+			putBoxService.updateById(putBox);
+		}
+		if ("OW-F".contains(tradingBox.getType())) {
+			PutBox putBoxOld = putBoxService.getById(tradingBox.getSrcContainerNumberId());
+			if (putBoxOld == null) {
+				throw new RuntimeException("未查到原放箱号数据");
+			}
+			SeaContainerNumberItem containerNumberItem = seaContainerNumberItemService.getOne(new LambdaQueryWrapper<SeaContainerNumberItem>()
+				.eq(SeaContainerNumberItem::getTenantId, AuthUtil.getTenantId())
+				.eq(SeaContainerNumberItem::getIsDeleted, 0)
+				.eq(SeaContainerNumberItem::getPid, tradingBox.getId())
+				.last("LIMIT 1"));
+			if (containerNumberItem != null) {
+				containerNumberItem.setUpdateUser(AuthUtil.getUserId());
+				containerNumberItem.setUpdateUserName(AuthUtil.getUserName());
+				containerNumberItem.setUpdateTime(new Date());
+				containerNumberItem.setIsDeleted(1);
+				seaContainerNumberItemService.updateById(containerNumberItem);
+			}
+			putBoxOld.setUpdateTime(new Date());
+			putBoxOld.setUpdateUser(AuthUtil.getUserId());
+			putBoxOld.setUpdateUserName(AuthUtil.getUserName());
+			putBoxOld.setOccupyNum(putBoxOld.getOccupyNum() - tradingBox.getBoxNumber());
+			if (putBoxOld.getOccupyNum() < 0) {
+				throw new RuntimeException("放箱号:" + putBoxOld.getContainerNumber() + "占用数量不足");
+			}
+			putBoxOld.setRemainingNum(putBoxOld.getRemainingNum() + tradingBox.getBoxNumber());
+			putBoxOld.setVersion(putBoxOld.getVersion() + 1);
+			putBoxService.updateById(putBoxOld);
 		}
 		tradingBox.setWhetherEnable("否");
 		int version = StringUtil.isBlank(tradingBox.getVersion()) ? 1 : Integer.parseInt(tradingBox.getVersion());

+ 2 - 0
blade-service/blade-los/src/main/java/org/springblade/los/business/sea/service/impl/BillsServiceImpl.java

@@ -5905,6 +5905,8 @@ public class BillsServiceImpl extends ServiceImpl<BillsMapper, Bills> implements
 					item.setPlaceDeliveryCode(bills.getPlaceDeliveryCode());
 					item.setIssueAtId(bills.getIssueAtId());
 					item.setCabinType(bills.getCabinType());
+					item.setCyReturnTime(bills.getCyReturnTime());
+					item.setCyTrailerTime(bills.getCyTrailerTime());
 					if (!bookingList.isEmpty() && ObjectUtils.isNotNull(item.getTemporaryId())) {
 						Bills bills1 = bookingList.stream().filter(e -> e.getId().equals(item.getTemporaryId())).findFirst().orElse(null);
 						if (bills1 != null) {

+ 2 - 1
blade-service/blade-los/src/main/java/org/springblade/los/business/sea/service/impl/ContainersServiceImpl.java

@@ -743,6 +743,7 @@ public class ContainersServiceImpl extends ServiceImpl<ContainersMapper, Contain
 	}
 
 	@Override
+	@Transactional(rollbackFor = Exception.class)
 	public R detele(String ids) {
 		logUtils.saveOperationLogBatch(OperatorType.DELETE, "配箱列表全部删除", ids);
 		List<Containers> containersList = baseMapper.selectList(new LambdaQueryWrapper<Containers>()
@@ -767,7 +768,7 @@ public class ContainersServiceImpl extends ServiceImpl<ContainersMapper, Contain
 			item.setUpdateTime(new Date());
 			item.setIsDeleted(1);
 		}
-		this.removeByIds(containersList);
+		this.updateBatchById(containersList);
 		return R.success("操作成功");
 	}
 

+ 59 - 59
blade-service/blade-los/src/main/java/org/springblade/los/finance/stl/service/impl/FinStlBillsServiceImpl.java

@@ -2340,7 +2340,7 @@ public class FinStlBillsServiceImpl extends ServiceImpl<FinStlBillsMapper, FinSt
 						finAccBills.setUpdateUserName(AuthUtil.getUserName());
 						int isChecked = 0;
 						if (exrateType.equals(item.getCurCode())) {
-							finAccBills.setReconciliationAmount(finAccBills.getReconciliationAmount().add(item.getCurrentStlAmount()));
+							finAccBills.setReconciliationAmount(finAccBills.getReconciliationAmount().abs().add(item.getCurrentStlAmount().abs()));
 							if ("D".equals(finAccBills.getAccountDc())) {
 								if (finAccBills.getAmountDr().abs().compareTo(finAccBills.getReconciliationAmount().abs()) > 0) {
 									isChecked = 1;
@@ -2361,7 +2361,7 @@ public class FinStlBillsServiceImpl extends ServiceImpl<FinStlBillsMapper, FinSt
 								}
 							}
 						} else {
-							finAccBills.setReconciliationAmountUsd(finAccBills.getReconciliationAmountUsd().add(item.getCurrentStlAmount()));
+							finAccBills.setReconciliationAmountUsd(finAccBills.getReconciliationAmountUsd().abs().add(item.getCurrentStlAmount().abs()));
 							if ("D".equals(finAccBills.getAccountDc())) {
 								if (finAccBills.getAmountDrUsd().abs().compareTo(finAccBills.getReconciliationAmountUsd().abs()) > 0) {
 									isChecked = 1;
@@ -2386,7 +2386,7 @@ public class FinStlBillsServiceImpl extends ServiceImpl<FinStlBillsMapper, FinSt
 						finAccBillsList.add(finAccBills);
 						List<FeeCenter> feeCenters = feeCenterListAll.stream().filter(e -> e.getAccBillId().equals(finAccBills.getId()))
 							.collect(Collectors.toList());
-						BigDecimal currentStlAmount = item.getCurrentStlAmount();
+						BigDecimal currentStlAmount = item.getCurrentStlAmount().abs();
 						for (FeeCenter feeCenter : feeCenters) {
 							feeCenter.setCheckBillId(stlBills.getId());
 							feeCenter.setCheckBillNo(stlBills.getBillNo());
@@ -2401,18 +2401,18 @@ public class FinStlBillsServiceImpl extends ServiceImpl<FinStlBillsMapper, FinSt
 								break;
 							} else {
 								if (feeCenter.getAmount().abs().subtract(feeCenter.getReconciliationAmount().abs()).compareTo(currentStlAmount.abs()) > 0) {
-									feeCenter.setReconciliationAmount(feeCenter.getReconciliationAmount().add(currentStlAmount));
+									feeCenter.setReconciliationAmount(feeCenter.getReconciliationAmount().abs().add(currentStlAmount));
 									currentStlAmount = new BigDecimal("0.00");
 								} else if (feeCenter.getAmount().abs().subtract(feeCenter.getReconciliationAmount().abs()).compareTo(currentStlAmount.abs()) == 0) {
-									feeCenter.setReconciliationAmount(feeCenter.getReconciliationAmount().add(currentStlAmount));
+									feeCenter.setReconciliationAmount(feeCenter.getReconciliationAmount().abs().add(currentStlAmount));
 									currentStlAmount = new BigDecimal("0.00");
 								} else {
 									if (new BigDecimal("0.00").compareTo(currentStlAmount) > 0) {
 										currentStlAmount = currentStlAmount.add((feeCenter.getAmount().abs().subtract(feeCenter.getReconciliationAmount().abs())).abs());
 									} else {
-										currentStlAmount = currentStlAmount.subtract((feeCenter.getAmount().subtract(feeCenter.getReconciliationAmount())));
+										currentStlAmount = currentStlAmount.subtract((feeCenter.getAmount().abs().subtract(feeCenter.getReconciliationAmount().abs())));
 									}
-									feeCenter.setReconciliationAmount(feeCenter.getAmount());
+									feeCenter.setReconciliationAmount(feeCenter.getAmount().abs());
 								}
 							}
 							feeCenterList.add(feeCenter);
@@ -2470,7 +2470,7 @@ public class FinStlBillsServiceImpl extends ServiceImpl<FinStlBillsMapper, FinSt
 						throw new RuntimeException("未找到账单明细,操作失败");
 					}
 					if (exrateType.equals(item.getCurCode())) {
-						BigDecimal amount = finAccBills.getAppliedAmount().subtract(finAccBills.getAppliedAmountStl().abs());
+						BigDecimal amount = finAccBills.getAppliedAmount().abs().subtract(finAccBills.getAppliedAmountStl().abs());
 						if ("D".equals(finAccBills.getAccountDc())) {
 							if (item.getCurrentStlAmount().abs().compareTo(finAccBills.getAmountDrLoc().abs().subtract(amount.abs()).subtract(finAccBills.getStlAmountDrLoc().abs())) > 0) {
 								throw new RuntimeException("本次申请金额大于未申请金额");
@@ -2482,7 +2482,7 @@ public class FinStlBillsServiceImpl extends ServiceImpl<FinStlBillsMapper, FinSt
 						}
 						finAccBills.setAppliedAmount(finAccBills.getAppliedAmount().add(item.getCurrentStlAmount()));
 					} else {
-						BigDecimal amount = finAccBills.getAppliedAmountUsd().subtract(finAccBills.getAppliedAmountStlUsd().abs());
+						BigDecimal amount = finAccBills.getAppliedAmountUsd().abs().subtract(finAccBills.getAppliedAmountStlUsd().abs());
 						if ("D".equals(finAccBills.getAccountDc())) {
 							if (item.getCurrentStlAmount().abs().compareTo(finAccBills.getAmountDrUsd().abs().subtract(amount.abs()).subtract(finAccBills.getStlAmountDrUsd().abs())) > 0) {
 								throw new RuntimeException("本次申请金额大于未申请金额");
@@ -2492,7 +2492,7 @@ public class FinStlBillsServiceImpl extends ServiceImpl<FinStlBillsMapper, FinSt
 								throw new RuntimeException("本次申请金额大于未申请金额");
 							}
 						}
-						finAccBills.setAppliedAmountUsd(finAccBills.getAppliedAmountUsd().add(item.getCurrentStlAmount()));
+						finAccBills.setAppliedAmountUsd(finAccBills.getAppliedAmountUsd().abs().add(item.getCurrentStlAmount().abs()));
 					}
 					finAccBillsList.add(finAccBills);
 					//计算字段null值处理
@@ -2501,7 +2501,7 @@ public class FinStlBillsServiceImpl extends ServiceImpl<FinStlBillsMapper, FinSt
 					item.setCurrentStlDiscount(ObjectUtils.isNotNull(item.getCurrentStlDiscount()) ? item.getCurrentStlDiscount() : new BigDecimal("0.00"));
 					List<FeeCenter> feeCenters = feeCenterListAll.stream().filter(e -> e.getAccBillId().equals(finAccBills.getId()))
 						.collect(Collectors.toList());
-					BigDecimal currentStlAmount = item.getCurrentStlAmount();
+					BigDecimal currentStlAmount = item.getCurrentStlAmount().abs();
 					for (FeeCenter e : feeCenters) {
 						int version = StringUtil.isBlank(e.getVersion()) ? 1 : Integer.parseInt(e.getVersion());
 						e.setVersion(String.valueOf(version + 1));
@@ -2512,15 +2512,15 @@ public class FinStlBillsServiceImpl extends ServiceImpl<FinStlBillsMapper, FinSt
 							e.setAmount(ObjectUtils.isNotNull(e.getAmount()) ? e.getAmount() : new BigDecimal("0.00"));
 							e.setStlTtlAmount(ObjectUtils.isNotNull(e.getStlTtlAmount()) ? e.getStlTtlAmount() : new BigDecimal("0.00"));
 							if (e.getAmount().abs().subtract(e.getAppliedAmount().abs()).subtract(e.getStlTtlAmount().abs()).compareTo(currentStlAmount.abs()) > 0) {
-								e.setAppliedAmount(e.getAppliedAmount().add(currentStlAmount));
+								e.setAppliedAmount(e.getAppliedAmount().abs().add(currentStlAmount));
 								currentStlAmount = new BigDecimal("0.00");
 							} else if (e.getAmount().abs().subtract(e.getAppliedAmount().abs()).subtract(e.getStlTtlAmount().abs()).compareTo(currentStlAmount.abs()) == 0) {
-								e.setAppliedAmount(e.getAppliedAmount().add(currentStlAmount));
+								e.setAppliedAmount(e.getAppliedAmount().abs().add(currentStlAmount));
 								currentStlAmount = new BigDecimal("0.00");
 							} else {
-								BigDecimal subAmount = e.getAmount().subtract(e.getAppliedAmount().abs());
+								BigDecimal subAmount = e.getAmount().abs().subtract(e.getAppliedAmount().abs());
 								currentStlAmount = currentStlAmount.subtract(subAmount);
-								e.setAppliedAmount(e.getAmount());
+								e.setAppliedAmount(e.getAmount().abs());
 							}
 							feeCenterList.add(e);
 						}
@@ -2593,12 +2593,12 @@ public class FinStlBillsServiceImpl extends ServiceImpl<FinStlBillsMapper, FinSt
 					//计算字段null值处理
 					if ("D".equals(item.getDc())) {
 						if (exrateType.equals(item.getCurCode())) {
-							finAccBills.setStlAmountDr(finAccBills.getStlAmountDr().add(item.getCurrentStlAmount()));
-							finAccBills.setStlAmountDrLoc(finAccBills.getStlAmountDrLoc().add(item.getCurrentStlAmount()));
+							finAccBills.setStlAmountDr(finAccBills.getStlAmountDr().abs().add(item.getCurrentStlAmount().abs()));
+							finAccBills.setStlAmountDrLoc(finAccBills.getStlAmountDrLoc().abs().add(item.getCurrentStlAmount().abs()));
 						} else {
-							finAccBills.setStlAmountDrUsd(finAccBills.getStlAmountDrUsd().add(item.getCurrentStlAmount()));
-							BigDecimal cny = item.getCurrentStlAmount().multiply(item.getCurrentStlExrate());
-							finAccBills.setStlAmountDrLoc(finAccBills.getStlAmountDrLoc().add(cny));
+							finAccBills.setStlAmountDrUsd(finAccBills.getStlAmountDrUsd().abs().add(item.getCurrentStlAmount().abs()));
+							BigDecimal cny = item.getCurrentStlAmount().abs().multiply(item.getCurrentStlExrate());
+							finAccBills.setStlAmountDrLoc(finAccBills.getStlAmountDrLoc().abs().add(cny));
 						}
 						if (finAccBills.getAmountDr().abs().compareTo(finAccBills.getStlAmountDr().abs()) == 0 &&
 							finAccBills.getAmountDrUsd().abs().compareTo(finAccBills.getStlAmountDrUsd().abs()) == 0) {
@@ -2611,12 +2611,12 @@ public class FinStlBillsServiceImpl extends ServiceImpl<FinStlBillsMapper, FinSt
 						}
 					} else if ("C".equals(item.getDc())) {
 						if (exrateType.equals(item.getCurCode())) {
-							finAccBills.setStlAmountCr(finAccBills.getStlAmountCr().add(item.getCurrentStlAmount()));
-							finAccBills.setStlAmountCrLoc(finAccBills.getStlAmountCrLoc().add(item.getCurrentStlAmount()));
+							finAccBills.setStlAmountCr(finAccBills.getStlAmountCr().abs().add(item.getCurrentStlAmount().abs()));
+							finAccBills.setStlAmountCrLoc(finAccBills.getStlAmountCrLoc().abs().add(item.getCurrentStlAmount().abs()));
 						} else {
-							finAccBills.setStlAmountCrUsd(finAccBills.getStlAmountCrUsd().add(item.getCurrentStlAmount()));
-							BigDecimal cny = item.getCurrentStlAmount().multiply(item.getCurrentStlExrate());
-							finAccBills.setStlAmountCrLoc(finAccBills.getStlAmountCrLoc().add(cny));
+							finAccBills.setStlAmountCrUsd(finAccBills.getStlAmountCrUsd().abs().add(item.getCurrentStlAmount().abs()));
+							BigDecimal cny = item.getCurrentStlAmount().abs().multiply(item.getCurrentStlExrate());
+							finAccBills.setStlAmountCrLoc(finAccBills.getStlAmountCrLoc().abs().add(cny));
 						}
 						if (finAccBills.getAmountCr().abs().compareTo(finAccBills.getStlAmountCr().abs()) == 0 &&
 							finAccBills.getAmountCrUsd().abs().compareTo(finAccBills.getStlAmountCrUsd().abs()) == 0) {
@@ -2642,7 +2642,7 @@ public class FinStlBillsServiceImpl extends ServiceImpl<FinStlBillsMapper, FinSt
 					finAccBillsList.add(finAccBills);
 					List<FeeCenter> feeCenters = feeCenterListAll.stream().filter(e -> e.getAccBillId().equals(finAccBills.getId()))
 						.collect(Collectors.toList());
-					BigDecimal currentStlAmount = item.getCurrentStlAmount();
+					BigDecimal currentStlAmount = item.getCurrentStlAmount().abs();
 					BigDecimal stlTtlAmount = feeCenters.stream().map(FeeCenter::getStlTtlAmount).filter(Objects::nonNull).reduce(BigDecimal.ZERO, BigDecimal::add);
 					if (item.getCurrentStlAmount().compareTo(new BigDecimal("0.00")) == 0 ||
 						item.getCurrentStlAmount().abs().compareTo(item.getAmount().abs().subtract(stlTtlAmount).abs()) > 0) {
@@ -2674,17 +2674,17 @@ public class FinStlBillsServiceImpl extends ServiceImpl<FinStlBillsMapper, FinSt
 							e.setStlById(stlBills.getCreateUser());
 							e.setStlByName(stlBills.getCreateUserName());
 							if (e.getAmount().abs().subtract(e.getStlTtlAmount().abs()).compareTo(currentStlAmount.abs()) > 0) {
-								e.setUnsettledAmount(e.getAmount().subtract(e.getStlTtlAmount()).subtract(currentStlAmount));
-								e.setStlTtlAmount(e.getAmount().subtract(e.getUnsettledAmount()));
+								e.setUnsettledAmount(e.getAmount().abs().subtract(e.getStlTtlAmount().abs()).subtract(currentStlAmount));
+								e.setStlTtlAmount(e.getAmount().abs().subtract(e.getUnsettledAmount().abs()));
 								currentStlAmount = new BigDecimal("0.00");
 							} else if (e.getAmount().abs().subtract(e.getStlTtlAmount().abs()).compareTo(currentStlAmount.abs()) == 0) {
 								e.setUnsettledAmount(new BigDecimal("0.00"));
-								e.setStlTtlAmount(e.getAmount().subtract(e.getUnsettledAmount()));
+								e.setStlTtlAmount(e.getAmount().abs().subtract(e.getUnsettledAmount().abs()));
 								currentStlAmount = new BigDecimal("0.00");
 							} else {
 								e.setUnsettledAmount(new BigDecimal("0.00"));
-								currentStlAmount = currentStlAmount.subtract((e.getAmount().subtract(e.getStlTtlAmount())));
-								e.setStlTtlAmount(e.getAmount().subtract(e.getUnsettledAmount()));
+								currentStlAmount = currentStlAmount.subtract((e.getAmount().abs().subtract(e.getStlTtlAmount().abs())));
+								e.setStlTtlAmount(e.getAmount().abs().subtract(e.getUnsettledAmount().abs()));
 							}
 							feeCenterList.add(e);
 						}
@@ -3002,7 +3002,7 @@ public class FinStlBillsServiceImpl extends ServiceImpl<FinStlBillsMapper, FinSt
 							if (finAccBills.getReconciliationAmount().abs().compareTo(item.getCurrentStlAmount().abs()) < 0) {
 								throw new RuntimeException("撤销失败,本次对账金额大于已对账金额");
 							}
-							finAccBills.setReconciliationAmount(finAccBills.getReconciliationAmount().subtract(item.getCurrentStlAmount()));
+							finAccBills.setReconciliationAmount(finAccBills.getReconciliationAmount().abs().subtract(item.getCurrentStlAmount().abs()));
 							if ("D".equals(finAccBills.getAccountDc())) {
 								if (finAccBills.getAmountDr().abs().compareTo(finAccBills.getReconciliationAmount().abs()) > 0) {
 									isChecked = 1;
@@ -3016,7 +3016,7 @@ public class FinStlBillsServiceImpl extends ServiceImpl<FinStlBillsMapper, FinSt
 							if (finAccBills.getReconciliationAmountUsd().abs().compareTo(item.getCurrentStlAmount().abs()) < 0) {
 								throw new RuntimeException("撤销失败,本次对账金额大于已对账金额");
 							}
-							finAccBills.setReconciliationAmountUsd(finAccBills.getReconciliationAmountUsd().subtract(item.getCurrentStlAmount()));
+							finAccBills.setReconciliationAmountUsd(finAccBills.getReconciliationAmountUsd().abs().subtract(item.getCurrentStlAmount().abs()));
 							if ("D".equals(finAccBills.getAccountDc())) {
 								if (finAccBills.getAmountDrUsd().abs().compareTo(finAccBills.getReconciliationAmountUsd().abs()) > 0) {
 									isChecked = 1;
@@ -3031,7 +3031,7 @@ public class FinStlBillsServiceImpl extends ServiceImpl<FinStlBillsMapper, FinSt
 						finAccBillsList.add(finAccBills);
 						List<FeeCenter> feeCenters = feeCenterListAll.stream().filter(e -> e.getAccBillId().equals(finAccBills.getId()))
 							.collect(Collectors.toList());
-						BigDecimal currentStlAmount = item.getCurrentStlAmount();
+						BigDecimal currentStlAmount = item.getCurrentStlAmount().abs();
 						for (FeeCenter feeCenter : feeCenters) {
 							feeCenter.setCheckBillId(0L);
 							feeCenter.setCheckBillNo("");
@@ -3046,14 +3046,14 @@ public class FinStlBillsServiceImpl extends ServiceImpl<FinStlBillsMapper, FinSt
 								break;
 							} else {
 								if (feeCenter.getReconciliationAmount().abs().compareTo(currentStlAmount.abs()) > 0) {
-									feeCenter.setReconciliationAmount(feeCenter.getReconciliationAmount().subtract(currentStlAmount));
+									feeCenter.setReconciliationAmount(feeCenter.getReconciliationAmount().abs().subtract(currentStlAmount));
 									currentStlAmount = new BigDecimal("0.00");
 								} else if (feeCenter.getReconciliationAmount().abs().compareTo(currentStlAmount.abs()) == 0) {
-									feeCenter.setReconciliationAmount(feeCenter.getReconciliationAmount().subtract(currentStlAmount));
+									feeCenter.setReconciliationAmount(feeCenter.getReconciliationAmount().abs().subtract(currentStlAmount));
 									currentStlAmount = new BigDecimal("0.00");
 								} else {
 									feeCenter.setReconciliationAmount(new BigDecimal("0.00"));
-									currentStlAmount = currentStlAmount.subtract(feeCenter.getAmount());
+									currentStlAmount = currentStlAmount.subtract(feeCenter.getAmount().abs());
 								}
 							}
 							feeCenterList.add(feeCenter);
@@ -3071,12 +3071,12 @@ public class FinStlBillsServiceImpl extends ServiceImpl<FinStlBillsMapper, FinSt
 						if (item.getCurrentStlAmount().abs().compareTo(finAccBills.getAppliedAmount().abs()) > 0) {
 							throw new RuntimeException("本次申请金额大于未申请金额");
 						}
-						finAccBills.setAppliedAmount(finAccBills.getAppliedAmount().subtract(item.getCurrentStlAmount()));
+						finAccBills.setAppliedAmount(finAccBills.getAppliedAmount().abs().subtract(item.getCurrentStlAmount().abs()));
 					} else {
 						if (item.getCurrentStlAmount().abs().compareTo(finAccBills.getAppliedAmountUsd().abs()) > 0) {
 							throw new RuntimeException("本次申请金额大于未申请金额");
 						}
-						finAccBills.setAppliedAmountUsd(finAccBills.getAppliedAmountUsd().subtract(item.getCurrentStlAmount()));
+						finAccBills.setAppliedAmountUsd(finAccBills.getAppliedAmountUsd().abs().subtract(item.getCurrentStlAmount().abs()));
 					}
 					finAccBillsList.add(finAccBills);
 					//计算字段null值处理
@@ -3085,7 +3085,7 @@ public class FinStlBillsServiceImpl extends ServiceImpl<FinStlBillsMapper, FinSt
 					item.setCurrentStlDiscount(ObjectUtils.isNotNull(item.getCurrentStlDiscount()) ? item.getCurrentStlDiscount() : new BigDecimal("0.00"));
 					List<FeeCenter> feeCenters = feeCenterListAll.stream().filter(e -> e.getAccBillId().equals(finAccBills.getId()))
 						.collect(Collectors.toList());
-					BigDecimal currentStlAmount = item.getCurrentStlAmount();
+					BigDecimal currentStlAmount = item.getCurrentStlAmount().abs();
 					for (FeeCenter e : feeCenters) {
 						int version = StringUtil.isBlank(e.getVersion()) ? 1 : Integer.parseInt(e.getVersion());
 						e.setVersion(String.valueOf(version + 1));
@@ -3097,14 +3097,14 @@ public class FinStlBillsServiceImpl extends ServiceImpl<FinStlBillsMapper, FinSt
 							e.setStlTtlAmount(ObjectUtils.isNotNull(e.getStlTtlAmount()) ? e.getStlTtlAmount() : new BigDecimal("0.00"));
 
 							if (e.getAppliedAmount().abs().compareTo(currentStlAmount.abs()) > 0) {
-								e.setAppliedAmount(e.getAppliedAmount().subtract(currentStlAmount));
+								e.setAppliedAmount(e.getAppliedAmount().abs().subtract(currentStlAmount));
 								currentStlAmount = new BigDecimal("0.00");
 							} else if (e.getAppliedAmount().abs().compareTo(currentStlAmount.abs()) == 0) {
-								e.setAppliedAmount(e.getAppliedAmount().subtract(currentStlAmount));
+								e.setAppliedAmount(e.getAppliedAmount().abs().subtract(currentStlAmount));
 								currentStlAmount = new BigDecimal("0.00");
 							} else {
 								e.setAppliedAmount(new BigDecimal("0.00"));
-								currentStlAmount = currentStlAmount.subtract(e.getAmount());
+								currentStlAmount = currentStlAmount.subtract(e.getAmount().abs());
 							}
 							feeCenterList.add(e);
 						}
@@ -3124,12 +3124,12 @@ public class FinStlBillsServiceImpl extends ServiceImpl<FinStlBillsMapper, FinSt
 					//计算字段null值处理
 					if ("D".equals(item.getDc())) {
 						if (exrateType.equals(item.getCurCode())) {
-							finAccBills.setStlAmountDr(finAccBills.getStlAmountDr().subtract(item.getCurrentStlAmount()));
-							finAccBills.setStlAmountDrLoc(finAccBills.getStlAmountDrLoc().subtract(item.getCurrentStlAmount()));
+							finAccBills.setStlAmountDr(finAccBills.getStlAmountDr().abs().subtract(item.getCurrentStlAmount().abs()));
+							finAccBills.setStlAmountDrLoc(finAccBills.getStlAmountDrLoc().abs().subtract(item.getCurrentStlAmount().abs()));
 						} else {
-							finAccBills.setStlAmountDrUsd(finAccBills.getStlAmountDrUsd().subtract(item.getCurrentStlAmount()));
-							BigDecimal cny = currencyUtils.converter(item.getDc(), curExrateList, item.getCurrentStlAmount(), item.getCurCode(), "2");
-							finAccBills.setStlAmountDrLoc(finAccBills.getStlAmountDrLoc().subtract(cny));
+							finAccBills.setStlAmountDrUsd(finAccBills.getStlAmountDrUsd().abs().subtract(item.getCurrentStlAmount().abs()));
+							BigDecimal cny = currencyUtils.converter(item.getDc(), curExrateList, item.getCurrentStlAmount().abs(), item.getCurCode(), "2");
+							finAccBills.setStlAmountDrLoc(finAccBills.getStlAmountDrLoc().abs().subtract(cny));
 						}
 						if (finAccBills.getAmountDr().compareTo(new BigDecimal("0.00")) == 0 &&
 							finAccBills.getAmountDrUsd().compareTo(new BigDecimal("0.00")) == 0) {
@@ -3151,12 +3151,12 @@ public class FinStlBillsServiceImpl extends ServiceImpl<FinStlBillsMapper, FinSt
 
 					} else if ("C".equals(item.getDc())) {
 						if (exrateType.equals(item.getCurCode())) {
-							finAccBills.setStlAmountCr(finAccBills.getStlAmountCr().subtract(item.getCurrentStlAmount()));
-							finAccBills.setStlAmountCrLoc(finAccBills.getStlAmountCrLoc().subtract(item.getCurrentStlAmount()));
+							finAccBills.setStlAmountCr(finAccBills.getStlAmountCr().abs().subtract(item.getCurrentStlAmount().abs()));
+							finAccBills.setStlAmountCrLoc(finAccBills.getStlAmountCrLoc().abs().subtract(item.getCurrentStlAmount().abs()));
 						} else {
-							finAccBills.setStlAmountCrUsd(finAccBills.getStlAmountCrUsd().subtract(item.getCurrentStlAmount()));
-							BigDecimal cny = currencyUtils.converter(item.getDc(), curExrateList, item.getCurrentStlAmount(), item.getCurCode(), "2");
-							finAccBills.setStlAmountCrLoc(finAccBills.getStlAmountCrLoc().subtract(cny));
+							finAccBills.setStlAmountCrUsd(finAccBills.getStlAmountCrUsd().abs().subtract(item.getCurrentStlAmount().abs()));
+							BigDecimal cny = currencyUtils.converter(item.getDc(), curExrateList, item.getCurrentStlAmount().abs(), item.getCurCode(), "2");
+							finAccBills.setStlAmountCrLoc(finAccBills.getStlAmountCrLoc().abs().subtract(cny));
 						}
 						if (finAccBills.getAmountCr().compareTo(new BigDecimal("0.00")) == 0 &&
 							finAccBills.getAmountCrUsd().compareTo(new BigDecimal("0.00")) == 0) {
@@ -3185,7 +3185,7 @@ public class FinStlBillsServiceImpl extends ServiceImpl<FinStlBillsMapper, FinSt
 					finAccBillsList.add(finAccBills);
 					List<FeeCenter> feeCenters = feeCenterListAll.stream().filter(e -> e.getAccBillId().equals(finAccBills.getId()))
 						.collect(Collectors.toList());
-					BigDecimal currentStlAmount = item.getCurrentStlAmount();
+					BigDecimal currentStlAmount = item.getCurrentStlAmount().abs();
 					for (FeeCenter e : feeCenters) {
 						int version = StringUtil.isBlank(e.getVersion()) ? 1 : Integer.parseInt(e.getVersion());
 						e.setVersion(String.valueOf(version + 1));
@@ -3208,17 +3208,17 @@ public class FinStlBillsServiceImpl extends ServiceImpl<FinStlBillsMapper, FinSt
 							e.setStlById(0L);
 							e.setStlByName("");
 							if (e.getStlTtlAmount().abs().compareTo(currentStlAmount.abs()) > 0) {
-								e.setStlTtlAmount(e.getStlTtlAmount().subtract(currentStlAmount));
-								e.setUnsettledAmount(e.getAmount().subtract(e.getStlTtlAmount()));
+								e.setStlTtlAmount(e.getStlTtlAmount().abs().subtract(currentStlAmount));
+								e.setUnsettledAmount(e.getAmount().abs().subtract(e.getStlTtlAmount().abs()));
 								currentStlAmount = new BigDecimal("0.00");
 							} else if (e.getStlTtlAmount().abs().compareTo(currentStlAmount.abs()) == 0) {
 								e.setStlTtlAmount(new BigDecimal("0.00"));
-								e.setUnsettledAmount(e.getAmount().subtract(e.getStlTtlAmount()));
+								e.setUnsettledAmount(e.getAmount().abs().subtract(e.getStlTtlAmount().abs()));
 								currentStlAmount = new BigDecimal("0.00");
 							} else {
 								e.setStlTtlAmount(new BigDecimal("0.00"));
-								e.setUnsettledAmount(e.getAmount().subtract(e.getStlTtlAmount()));
-								currentStlAmount = currentStlAmount.subtract(e.getAmount());
+								e.setUnsettledAmount(e.getAmount().abs().subtract(e.getStlTtlAmount().abs()));
+								currentStlAmount = currentStlAmount.subtract(e.getAmount().abs());
 							}
 							feeCenterList.add(e);
 						}