Browse Source

永发 增加ow拿,放报表打印,pol,pod导入接口逻辑修改

纪新园 10 months ago
parent
commit
08a19b2b0a
14 changed files with 552 additions and 139 deletions
  1. 29 23
      blade-service-api/blade-los-api/src/main/java/org/springblade/los/box/dto/ExportTradingBoxItemOut.java
  2. 12 0
      blade-service-api/blade-los-api/src/main/java/org/springblade/los/box/entity/Archives.java
  3. 0 2
      blade-service-api/blade-los-api/src/main/java/org/springblade/los/box/entity/PutBoxItems.java
  4. 25 0
      blade-service-api/blade-los-api/src/main/java/org/springblade/los/box/entity/TradingBox.java
  5. 7 0
      blade-service-api/blade-los-api/src/main/java/org/springblade/los/box/entity/TradingBoxItem.java
  6. 4 0
      blade-service/blade-los/src/main/java/org/springblade/los/Util/MagicValues.java
  7. 20 0
      blade-service/blade-los/src/main/java/org/springblade/los/basic/reports/controller/ReportsController.java
  8. 35 0
      blade-service/blade-los/src/main/java/org/springblade/los/basic/reports/service/IReportsBoxService.java
  9. 106 0
      blade-service/blade-los/src/main/java/org/springblade/los/basic/reports/service/impl/ReportsBoxServiceImpl.java
  10. 2 0
      blade-service/blade-los/src/main/java/org/springblade/los/box/controller/PutBoxController.java
  11. 34 18
      blade-service/blade-los/src/main/java/org/springblade/los/box/controller/TradingBoxController.java
  12. 1 0
      blade-service/blade-los/src/main/java/org/springblade/los/box/service/ITradingBoxService.java
  13. 119 64
      blade-service/blade-los/src/main/java/org/springblade/los/box/service/impl/PutBoxServiceImpl.java
  14. 158 32
      blade-service/blade-los/src/main/java/org/springblade/los/box/service/impl/TradingBoxServiceImpl.java

+ 29 - 23
blade-service-api/blade-los-api/src/main/java/org/springblade/los/box/dto/ExportTradingBoxItemOut.java

@@ -21,6 +21,7 @@ import com.alibaba.excel.annotation.write.style.ColumnWidth;
 import com.alibaba.excel.annotation.write.style.ContentRowHeight;
 import com.alibaba.excel.annotation.write.style.HeadRowHeight;
 import com.fasterxml.jackson.annotation.JsonFormat;
+import io.swagger.annotations.ApiModelProperty;
 import lombok.Data;
 import org.springframework.format.annotation.DateTimeFormat;
 
@@ -41,47 +42,52 @@ import java.util.Date;
 public class ExportTradingBoxItemOut implements Serializable {
 
 	/**
-	 * 合同号
+	 * 箱东
 	 */
-	@ExcelProperty(value = "合同号")
-	private String contractNo;
+	@ExcelProperty(value = "箱东")
+	private String boxEastName;
+	/**
+	 * 放箱号
+	 */
+	@ExcelProperty(value = "放箱号")
+	private String containerNumber;
 
 	/**
-	 * 箱号
+	 * 箱
 	 */
-	@ExcelProperty(value = "箱号")
-	private String code;
+	@ExcelProperty(value = "箱")
+	private String boxType;
 
 	/**
-	 * 最新时间
+	 * 提单号
 	 */
-	@ExcelProperty(value = "最新时间")
-	@DateTimeFormat(pattern = "yyyy-MM-dd")
-	@JsonFormat(pattern = "yyyy-MM-dd")
-	private Date newDate;
+	@ExcelProperty(value = "提单号")
+	private String mblno;
 
 	/**
-	 * 最新地点
+	 * 箱号
 	 */
-	@ExcelProperty(value = "最新地点")
-	private String address;
+	@ExcelProperty(value = "箱号")
+	private String code;
 
 	/**
-	 * 金额
+	 * 起运港
 	 */
-	@ExcelProperty(value = "金额")
-	private BigDecimal amount;
+	@ExcelProperty(value = "起运港")
+	private String polCname;
 
 	/**
-	 * 状态
+	 * 目的港
 	 */
-	@ExcelProperty(value = "状态")
-	private String status;
+	@ExcelProperty(value = "目的港")
+	private String podCname;
 
 	/**
-	 * 业务类型
+	 * 还箱场站
 	 */
-	@ExcelProperty(value = "业务类型")
-	private String type;
+	@ExcelProperty(value = "还箱场站")
+	private String podStationCname;
+
+
 
 }

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

@@ -336,6 +336,18 @@ public class Archives implements Serializable {
 	@ApiModelProperty(value = "放箱号类型")
 	private String containerNumberType;
 
+	/**
+	 * 放箱号OW
+	 */
+	@ApiModelProperty(value = "放箱号OW")
+	private String containerNumberOw;
+
+	/**
+	 * 放箱号类型OW
+	 */
+	@ApiModelProperty(value = "放箱号类型OW")
+	private String containerNumberTypeOw;
+
 
 	/**
 	 * 文件

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

@@ -288,6 +288,4 @@ public class PutBoxItems implements Serializable {
 	 */
 	@ApiModelProperty(value = "箱状态")
 	private String status;
-
-
 }

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

@@ -23,6 +23,7 @@ import io.swagger.annotations.ApiModel;
 import io.swagger.annotations.ApiModelProperty;
 import lombok.Data;
 import org.springblade.los.finance.fee.entity.FeeCenter;
+import org.springblade.system.entity.Dept;
 
 import java.io.Serializable;
 import java.math.BigDecimal;
@@ -639,4 +640,28 @@ public class TradingBox implements Serializable {
 	@TableField(exist = false)
 	private Integer count;
 
+	/**
+	 * 报表打印抬头
+	 */
+	@TableField(exist = false)
+	private Dept dept;
+
+	/**
+	 * 起运港提/放箱地址
+	 */
+	@TableField(exist = false)
+	private String polStationAddress;
+
+	/**
+	 * 起运港提/放箱联系电话
+	 */
+	@TableField(exist = false)
+	private String polStationTel;
+
+	/**
+	 * 报表打印时间
+	 */
+	@TableField(exist = false)
+	private Date date;
+
 }

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

@@ -594,4 +594,11 @@ public class TradingBoxItem implements Serializable {
 	 */
 	@TableField(exist = false)
 	private List<String> rentingOutDateList;
+
+
+	/**
+	 * 是否计算租金
+	 */
+	@ApiModelProperty(value = "是否计算租金")
+	private String whetherCountRent;
 }

+ 4 - 0
blade-service/blade-los/src/main/java/org/springblade/los/Util/MagicValues.java

@@ -11,6 +11,10 @@ public class MagicValues {
 	public static final String HYJKBG = "海运进口报关";
 	public static final String KYCKBG = "空运出口报关";
 	public static final String KYJKBG = "空运进口报关";
+	public static final String OW = "OW";
+
+	public static final String OW_N = "OW-N";
+	public static final String OW_F = "OW-F";
 	public static final String DOCUMENT = "单证";
 	public static final String COST = "费用";
 	public static final String PAID_APPLICATION = "付费申请";

+ 20 - 0
blade-service/blade-los/src/main/java/org/springblade/los/basic/reports/controller/ReportsController.java

@@ -33,6 +33,7 @@ import org.springblade.core.tool.api.R;
 import org.springblade.core.tool.utils.Func;
 import org.springblade.los.Util.IDeptUtils;
 import org.springblade.los.basic.reports.entity.Reports;
+import org.springblade.los.basic.reports.service.IReportsBoxService;
 import org.springblade.los.basic.reports.service.IReportsService;
 import org.springblade.los.basic.reports.vo.ReportsVO;
 import org.springframework.web.bind.annotation.*;
@@ -53,6 +54,8 @@ public class ReportsController extends BladeController {
 
 	private final IReportsService reportsService;
 
+	private final IReportsBoxService reportsBoxService;
+
 	private final IDeptUtils deptUtils;
 
 	/**
@@ -185,5 +188,22 @@ public class ReportsController extends BladeController {
 		return reportsService.getReportData(billId, reportCode, groupCode, corpIds, itemIds, type, curCode);
 	}
 
+	/**
+	 * 获取模本数据加信息
+	 */
+	@GetMapping("/getReportDataBox")
+	@ApiOperationSupport(order = 1)
+	@ApiOperation(value = "详情", notes = "传入reports")
+	public R getReportDataBox(@RequestParam(value = "billId") String billId,
+						   @RequestParam(value = "reportCode", required = false) String reportCode,
+						   @RequestParam(value = "groupCode", required = false) String groupCode,
+						   @RequestParam(value = "corpIds", required = false) String corpIds,
+						   @RequestParam(value = "itemIds", required = false) String itemIds,
+						   @RequestParam(value = "curCode", required = false) String curCode,
+						   @RequestParam(value = "type", required = false) String type
+	) {
+		return reportsBoxService.getReportData(billId, reportCode, groupCode, corpIds, itemIds, type, curCode);
+	}
+
 
 }

+ 35 - 0
blade-service/blade-los/src/main/java/org/springblade/los/basic/reports/service/IReportsBoxService.java

@@ -0,0 +1,35 @@
+/*
+ *      Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
+ *
+ *  Redistribution and use in source and binary forms, with or without
+ *  modification, are permitted provided that the following conditions are met:
+ *
+ *  Redistributions of source code must retain the above copyright notice,
+ *  this list of conditions and the following disclaimer.
+ *  Redistributions in binary form must reproduce the above copyright
+ *  notice, this list of conditions and the following disclaimer in the
+ *  documentation and/or other materials provided with the distribution.
+ *  Neither the name of the dreamlu.net developer nor the names of its
+ *  contributors may be used to endorse or promote products derived from
+ *  this software without specific prior written permission.
+ *  Author: Chill 庄骞 (smallchill@163.com)
+ */
+package org.springblade.los.basic.reports.service;
+
+import org.springblade.core.tool.api.R;
+
+/**
+ * 基础资料-报表管理 服务类
+ *
+ * @author BladeX
+ * @since 2023-10-30
+ */
+public interface IReportsBoxService {
+
+	/**
+	 * 获取模本数据加信息
+	 */
+	R getReportData(String billId, String reportCode, String groupCode, String corpIds,
+					String itemIds, String type, String curCode);
+
+}

+ 106 - 0
blade-service/blade-los/src/main/java/org/springblade/los/basic/reports/service/impl/ReportsBoxServiceImpl.java

@@ -0,0 +1,106 @@
+/*
+ *      Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
+ *
+ *  Redistribution and use in source and binary forms, with or without
+ *  modification, are permitted provided that the following conditions are met:
+ *
+ *  Redistributions of source code must retain the above copyright notice,
+ *  this list of conditions and the following disclaimer.
+ *  Redistributions in binary form must reproduce the above copyright
+ *  notice, this list of conditions and the following disclaimer in the
+ *  documentation and/or other materials provided with the distribution.
+ *  Neither the name of the dreamlu.net developer nor the names of its
+ *  contributors may be used to endorse or promote products derived from
+ *  this software without specific prior written permission.
+ *  Author: Chill 庄骞 (smallchill@163.com)
+ */
+package org.springblade.los.basic.reports.service.impl;
+
+import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
+import lombok.AllArgsConstructor;
+import org.springblade.core.secure.utils.AuthUtil;
+import org.springblade.core.tool.api.R;
+import org.springblade.los.Util.IDeptUtils;
+import org.springblade.los.Util.MagicValues;
+import org.springblade.los.basic.corps.entity.BCorps;
+import org.springblade.los.basic.corps.service.IBCorpsService;
+import org.springblade.los.basic.reports.service.IReportsBoxService;
+import org.springblade.los.box.entity.TradingBox;
+import org.springblade.los.box.service.ITradingBoxService;
+import org.springblade.system.entity.Dept;
+import org.springblade.system.feign.ISysClient;
+import org.springblade.system.user.entity.User;
+import org.springblade.system.user.feign.IUserClient;
+import org.springframework.stereotype.Service;
+
+import java.util.Date;
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * 基础资料-报表打印记录 服务实现类
+ *
+ * @author BladeX
+ * @since 2023-11-29
+ */
+@Service
+@AllArgsConstructor
+public class ReportsBoxServiceImpl implements IReportsBoxService {
+
+	private final ISysClient sysClient;
+
+	private final IDeptUtils deptUtils;
+
+	private final IUserClient userClient;
+
+	private final ITradingBoxService tradingBoxService;
+
+	private final IBCorpsService bCorpsService;
+
+
+	@Override
+	public R getReportData(String billId, String reportCode, String groupCode, String corpIds, String itemIds, String type, String curCode) {
+		Map<String, Object> map = new HashMap<>();
+		if (ObjectUtils.isNull(billId)) {
+			throw new RuntimeException("缺少比要参数");
+		}
+		R<Dept> res = sysClient.getDept(deptUtils.getDeptPid());
+		Dept dept;
+		if (res.isSuccess() && res.getData() != null) {
+			dept = res.getData();
+			String status = sysClient.getParamServiceNew("is.update.default");
+			if ("1".equals(status)) {
+				R<User> resUser = userClient.userInfoById(AuthUtil.getUserId());
+				if (resUser.isSuccess() && resUser.getData() != null) {
+					dept.setEmail(resUser.getData().getEmail());
+					dept.setTel(resUser.getData().getPhone());
+					dept.setContacts(resUser.getData().getRealName());
+				}
+			}
+		} else {
+			throw new RuntimeException("获取报表表头数据失败");
+		}
+		if (MagicValues.OW.equals(reportCode) && MagicValues.OW.equals(groupCode)
+			&& (MagicValues.OW_N.equals(type) || MagicValues.OW_F.equals(type))) {
+			TradingBox tradingBox = tradingBoxService.getById(billId);
+			if (tradingBox != null) {
+				tradingBox.setBoxTypeQuantityOne(tradingBox.getBoxNumber() + "*" + tradingBox.getBoxTypeQuantityOne());
+				if (ObjectUtils.isNotNull(tradingBox.getPolStationId())) {
+					BCorps corps = bCorpsService.getById(tradingBox.getPolStationId());
+					if (corps != null) {
+						tradingBox.setPolStationAddress(corps.getCnAddr());
+						tradingBox.setPolStationTel(corps.getTel());
+					}
+				}
+				tradingBox.setDate(new Date());
+				tradingBox.setDept(dept);
+				map.put(MagicValues.DATA, tradingBox);
+			} else {
+				map.put(MagicValues.DATA, null);
+			}
+		} else {
+			throw new RuntimeException("未查到数据");
+		}
+		return R.data(map);
+	}
+}

+ 2 - 0
blade-service/blade-los/src/main/java/org/springblade/los/box/controller/PutBoxController.java

@@ -181,4 +181,6 @@ public class PutBoxController extends BladeController {
 	}
 
 
+
+
 }

+ 34 - 18
blade-service/blade-los/src/main/java/org/springblade/los/box/controller/TradingBoxController.java

@@ -35,18 +35,16 @@ import org.springblade.core.tool.utils.BeanUtil;
 import org.springblade.core.tool.utils.Func;
 import org.springblade.los.box.dto.ExportTradingBoxItemOut;
 import org.springblade.los.box.dto.ExportTradingBoxOut;
-import org.springblade.los.box.entity.PutBox;
 import org.springblade.los.box.entity.TradingBox;
 import org.springblade.los.box.entity.TradingBoxItem;
 import org.springblade.los.box.service.ITradingBoxItemService;
 import org.springblade.los.box.service.ITradingBoxService;
-import org.springblade.los.box.vo.TradingBoxVO;
 import org.springframework.web.bind.annotation.*;
 
 import javax.servlet.http.HttpServletResponse;
 import javax.validation.Valid;
 import java.text.SimpleDateFormat;
-import java.time.format.DateTimeFormatter;
+import java.util.ArrayList;
 import java.util.List;
 import java.util.stream.Collectors;
 
@@ -109,10 +107,10 @@ public class TradingBoxController extends BladeController {
 			.eq(ObjectUtils.isNotNull(tradingBox.getBuxStaus()), TradingBox::getBuxStaus, tradingBox.getBuxStaus())
 			.eq(ObjectUtils.isNotNull(tradingBox.getDc()), TradingBox::getDc, tradingBox.getDc())
 		;
-		if (ObjectUtils.isNotNull(tradingBox.getEffectiveDate()) && ObjectUtils.isNotNull(tradingBox.getExpiryDate())){
+		if (ObjectUtils.isNotNull(tradingBox.getEffectiveDate()) && ObjectUtils.isNotNull(tradingBox.getExpiryDate())) {
 			SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
-			lambdaQueryWrapper.apply(ObjectUtils.isNotNull(tradingBox.getEffectiveDate()),"DATE_FORMAT(effective_date,'%Y-%m-%d') >= '"+formatter.format(tradingBox.getEffectiveDate())+"'")
-				.apply(ObjectUtils.isNotNull(tradingBox.getExpiryDate()),"DATE_FORMAT(expiry_date,'%Y-%m-%d') <= '"+formatter.format(tradingBox.getExpiryDate())+"'");
+			lambdaQueryWrapper.apply(ObjectUtils.isNotNull(tradingBox.getEffectiveDate()), "DATE_FORMAT(effective_date,'%Y-%m-%d') >= '" + formatter.format(tradingBox.getEffectiveDate()) + "'")
+				.apply(ObjectUtils.isNotNull(tradingBox.getExpiryDate()), "DATE_FORMAT(expiry_date,'%Y-%m-%d') <= '" + formatter.format(tradingBox.getExpiryDate()) + "'");
 		}
 		if (tradingBox.getPurchaseDateList() != null && tradingBox.getPurchaseDateList().size() > 1) {
 			lambdaQueryWrapper.ge(TradingBox::getPurchaseDate, tradingBox.getPurchaseDateList().get(0));
@@ -222,19 +220,29 @@ public class TradingBoxController extends BladeController {
 	 */
 	@GetMapping("/exportTradingBoxItemOut")
 	public void exportTradingBoxItemOut(TradingBox tradingBox, HttpServletResponse response) {
-		tradingBox.setTenantId(AuthUtil.getTenantId());
-		List<ExportTradingBoxItemOut> tradingBoxList = tradingBoxService.exportTradingBoxItemOut(tradingBox);
-		String name = "";
-		if ("BUY".equals(tradingBox.getType())) {
-			name = "买箱";
-		} else if ("SELL".equals(tradingBox.getType())) {
-			name = "卖箱";
-		} else if ("ZR".equals(tradingBox.getType())) {
-			name = "租入";
-		} else if ("ZC".equals(tradingBox.getType())) {
-			name = "租出";
+		if (tradingBox.getId() == null) {
+			throw new RuntimeException("缺少必要参数");
 		}
-		ExcelUtil.export(response, name + "箱明细", "箱数据", tradingBoxList, ExportTradingBoxItemOut.class);
+		TradingBox detail = tradingBoxService.getById(tradingBox.getId());
+		List<TradingBoxItem> tradingBoxItemList = tradingBoxItemService.list(new LambdaQueryWrapper<TradingBoxItem>()
+			.eq(TradingBoxItem::getTenantId, AuthUtil.getTenantId())
+			.eq(TradingBoxItem::getIsDeleted, 0)
+			.eq(TradingBoxItem::getPid, tradingBox.getId())
+		);
+		List<ExportTradingBoxItemOut> outList = new ArrayList<>();
+		for (TradingBoxItem item : tradingBoxItemList) {
+			ExportTradingBoxItemOut data = new ExportTradingBoxItemOut();
+			data.setBoxEastName(item.getBoxEastName());
+			data.setContainerNumber(item.getContainerNumber());
+			data.setBoxType(item.getBoxType());
+			data.setMblno(item.getMblno());
+			data.setCode(item.getCode());
+			data.setPolCname(detail.getPolCname());
+			data.setPodCname(detail.getPodCname());
+			data.setPodStationCname(detail.getPodStationCname());
+			outList.add(data);
+		}
+		ExcelUtil.export(response, "箱明细", "箱明细", outList, ExportTradingBoxItemOut.class);
 	}
 
 
@@ -310,4 +318,12 @@ public class TradingBoxController extends BladeController {
 		return R.data(tradingBoxService.revoke(tradingBox));
 	}
 
+	/**
+	 * OW计算租金
+	 */
+	@GetMapping("/countRent")
+	public R countRent(TradingBox tradingBox) {
+		return tradingBoxService.countRent(tradingBox);
+	}
+
 }

+ 1 - 0
blade-service/blade-los/src/main/java/org/springblade/los/box/service/ITradingBoxService.java

@@ -59,4 +59,5 @@ public interface ITradingBoxService extends IService<TradingBox> {
 
 	TradingBox revoke(TradingBox tradingBox);
 
+	R countRent(TradingBox tradingBox);
 }

+ 119 - 64
blade-service/blade-los/src/main/java/org/springblade/los/box/service/impl/PutBoxServiceImpl.java

@@ -402,14 +402,39 @@ public class PutBoxServiceImpl extends ServiceImpl<PutBoxMapper, PutBox> impleme
 		putBoxOld.setUpdateUser(AuthUtil.getUserId());
 		baseMapper.updateById(putBoxOld);
 		List<PutBoxItems> putBoxItemsList = putBox.getPutBoxItemsList();
+		List<Archives> archivesList = archivesService.list(new LambdaQueryWrapper<Archives>()
+			.eq(Archives::getTenantId, AuthUtil.getTenantId())
+			.eq(Archives::getIsDeleted, 0)
+			.in(Archives::getCode, putBoxItemsList.stream().map(PutBoxItems::getBoxCode).distinct().collect(Collectors.toList())));
+		List<Archives> archives = new ArrayList<>();
 		for (PutBoxItems item : putBoxItemsList) {
 			item.setPid(detail.getId());
 			item.setUpdateTime(new Date());
 			item.setUpdateUser(AuthUtil.getUserId());
 			item.setUpdateUserName(AuthUtil.getUserName());
 			item.setContainerNumber(detail.getContainerNumber());
+			if (!archivesList.isEmpty()) {
+				Archives archives1 = archivesList.stream().filter(e -> e.getCode().equals(item.getBoxCode())).findFirst().orElse(null);
+				if (archives1 != null) {
+					archives1.setAddressId(detail.getPolId());
+					archives1.setAddressCname(detail.getPolCname());
+					archives1.setAddressEname(detail.getPolEname());
+					archives1.setAddressCode(detail.getPolCode());
+					archives1.setStationId(detail.getPolStationId());
+					archives1.setStationCname(detail.getPolStationCname());
+					archives1.setStationEname(detail.getPolStationEname());
+					archives1.setStationCode(detail.getPolStationCode());
+					archives1.setNewDate(new Date());
+					archives.add(archives1);
+				} else {
+					throw new RuntimeException("箱号:" + item.getBoxCode() + "不在箱档案中");
+				}
+			}
 		}
 		putBoxItemsService.updateBatchById(putBoxItemsList);
+		if (!archives.isEmpty()) {
+			archivesService.updateBatchById(archives);
+		}
 		return R.data(putBox);
 	}
 
@@ -691,6 +716,10 @@ public class PutBoxServiceImpl extends ServiceImpl<PutBoxMapper, PutBox> impleme
 				//箱档案数据处理
 				Archives archives = archivesList.stream().filter(e -> e.getCode().equals(item.getBoxCode())).findFirst().orElse(null);
 				if (archives != null) {
+					if ("OW(放)".equals(putBox.getBusType())) {
+						archives.setContainerNumberOw(item.getContainerNumber());
+						archives.setContainerNumberTypeOw("OW(放)");
+					}
 					archives.setUpdateTime(new Date());
 					archives.setUpdateUser(AuthUtil.getUserId());
 					archives.setUpdateUserName(AuthUtil.getUserName());
@@ -789,9 +818,10 @@ public class PutBoxServiceImpl extends ServiceImpl<PutBoxMapper, PutBox> impleme
 					putBoxItem.setPolCyEname(corps.getEnName());
 					putBoxItem.setPolStationEmptyContainerExitDate(item.getBoxStatusDate());
 				}
+				putBoxItem.setBoxEastId(Long.parseLong(putBox.getBoxEastId()));
+				putBoxItem.setBoxEastName(putBox.getBoxEastName());
+				putBoxItems.add(putBoxItem);
 				if ("OW(拿),OW(放)".contains(putBox.getBusType())) {
-					putBoxItem.setBoxEastId(Long.parseLong(putBox.getBoxEastId()));
-					putBoxItem.setBoxEastName(putBox.getBoxEastName());
 					if (!tradingBoxList.isEmpty()) {
 						TradingBox tradingBox = tradingBoxList.stream().filter(e -> e.getId().equals(putBox.getSrcId()))
 							.findFirst().orElse(null);
@@ -824,6 +854,7 @@ public class PutBoxServiceImpl extends ServiceImpl<PutBoxMapper, PutBox> impleme
 									tradingBoxItem.setPolCyCname(corps.getCnName());
 									tradingBoxItem.setPolCyEname(corps.getEnName());
 									tradingBoxItem.setPolStationEmptyContainerExitDate(item.getBoxStatusDate());
+									tradingBoxItem.setStatus("待使用");
 								} else {
 									tradingBoxItem = new TradingBoxItem();
 									tradingBoxItem.setBoxBelongsTo("SOC");
@@ -855,6 +886,7 @@ public class PutBoxServiceImpl extends ServiceImpl<PutBoxMapper, PutBox> impleme
 									tradingBoxItem.setPolCyCname(corps.getCnName());
 									tradingBoxItem.setPolCyEname(corps.getEnName());
 									tradingBoxItem.setPolStationEmptyContainerExitDate(item.getBoxStatusDate());
+									tradingBoxItem.setStatus("待使用");
 								}
 							} else {
 								tradingBoxItem = new TradingBoxItem();
@@ -886,6 +918,7 @@ public class PutBoxServiceImpl extends ServiceImpl<PutBoxMapper, PutBox> impleme
 								tradingBoxItem.setPolCyCname(corps.getCnName());
 								tradingBoxItem.setPolCyEname(corps.getEnName());
 								tradingBoxItem.setPolStationEmptyContainerExitDate(item.getBoxStatusDate());
+								tradingBoxItem.setStatus("待使用");
 							}
 							tradingBoxItem.setBoxEastId(tradingBox.getPurchaseCompanyId());
 							tradingBoxItem.setBoxEastName(tradingBox.getPurchaseCompanyName());
@@ -897,7 +930,6 @@ public class PutBoxServiceImpl extends ServiceImpl<PutBoxMapper, PutBox> impleme
 						throw new RuntimeException("放箱号:" + item.getContainerNumber() + "未查到OW单据");
 					}
 				}
-				putBoxItems.add(putBoxItem);
 			} else {
 				throw new RuntimeException("未查到放箱号:" + item.getContainerNumber() + "单据");
 			}
@@ -1129,54 +1161,19 @@ public class PutBoxServiceImpl extends ServiceImpl<PutBoxMapper, PutBox> impleme
 			if (archives == null) {
 				throw new RemoteException("箱号:" + item.getBoxCode() + "未查到数据");
 			}
-			if ("自有箱".equals(archives.getContainerNumberType())) {
+			if (ObjectUtils.isNotNull(archives.getContainerNumberTypeOw()) && "OW(放)".equals(archives.getContainerNumberTypeOw())) {
 				//判断目的港是否存在对应放箱号单据处理
-				List<PutBox> putBoxes = this.create(putBoxList, archives, ports, corps, putBoxNewList, businessType.getId());
+				List<PutBox> putBoxes = this.create(putBoxList, archives, ports, corps, putBoxNewList, businessType.getId(), "1");
 				if (!putBoxes.isEmpty()) {
 					putBoxNewList.addAll(putBoxes);
 				}
 				//修改原放箱号明细数据
-				List<PutBoxItems> putBoxItems = this.updatePutBoxItems(putBoxList, archives, item, corps, putBoxItemsList);
-				if (!putBoxItems.isEmpty()) {
-					putBoxItemsOldList.addAll(putBoxItems);
-				}
-				//更新箱档案数据
-				this.updateArchives(archives, item, ports, corps);
-				archivesArrayList.add(archives);
-			} else if ("代理箱".equals(archives.getContainerNumberType())) {
-				//箱档案数据删除
-				archivesDateleList.add(archives.getId());
-				//修改原放箱号明细数据
-				List<PutBoxItems> putBoxItems = this.updatePutBoxItems(putBoxList, archives, item, corps, putBoxItemsList);
-				if (!putBoxItems.isEmpty()) {
-					putBoxItemsOldList.addAll(putBoxItems);
-				}
-			} else if ("OW(拿)".equals(archives.getContainerNumberType())) {
-				//箱档案数据删除
-				archivesDateleList.add(archives.getId());
-				//修改原放箱号明细数据
-				List<PutBoxItems> putBoxItems = this.updatePutBoxItems(putBoxList, archives, item, corps, putBoxItemsList);
+				List<PutBoxItems> putBoxItems = this.updatePutBoxItems(putBoxList, archives, item, corps, putBoxItemsList, "1");
 				if (!putBoxItems.isEmpty()) {
 					putBoxItemsOldList.addAll(putBoxItems);
 				}
 				//修改原放ow单据明细数据
-				List<TradingBoxItem> tradingBoxItems = this.updatePutBoxItemsTrading(putBoxList, archives, item, corps, tradingBoxList, tradingBoxItemList, ports);
-				if (!tradingBoxItems.isEmpty()) {
-					tradingBoxItemOldList.addAll(tradingBoxItems);
-				}
-			} else if ("OW(放)".equals(archives.getContainerNumberType())) {
-				//判断目的港是否存在对应放箱号单据处理
-				List<PutBox> putBoxes = this.create(putBoxList, archives, ports, corps, putBoxNewList, businessType.getId());
-				if (!putBoxes.isEmpty()) {
-					putBoxNewList.addAll(putBoxes);
-				}
-				//修改原放箱号明细数据
-				List<PutBoxItems> putBoxItems = this.updatePutBoxItems(putBoxList, archives, item, corps, putBoxItemsList);
-				if (!putBoxItems.isEmpty()) {
-					putBoxItemsOldList.addAll(putBoxItems);
-				}
-				//修改原放ow单据明细数据
-				List<TradingBoxItem> tradingBoxItems = this.updatePutBoxItemsTrading(putBoxList, archives, item, corps, tradingBoxList, tradingBoxItemList, ports);
+				List<TradingBoxItem> tradingBoxItems = this.updatePutBoxItemsTrading(putBoxList, archives, item, corps, tradingBoxList, tradingBoxItemList, ports, "1");
 				if (!tradingBoxItems.isEmpty()) {
 					tradingBoxItemOldList.addAll(tradingBoxItems);
 				}
@@ -1184,7 +1181,44 @@ public class PutBoxServiceImpl extends ServiceImpl<PutBoxMapper, PutBox> impleme
 				this.updateArchives(archives, item, ports, corps);
 				archivesArrayList.add(archives);
 			} else {
-				throw new RemoteException("箱号:" + item.getBoxCode() + "放箱号类型错误");
+				if ("自有箱".equals(archives.getContainerNumberType())) {
+					//判断目的港是否存在对应放箱号单据处理
+					List<PutBox> putBoxes = this.create(putBoxList, archives, ports, corps, putBoxNewList, businessType.getId(), null);
+					if (!putBoxes.isEmpty()) {
+						putBoxNewList.addAll(putBoxes);
+					}
+					//修改原放箱号明细数据
+					List<PutBoxItems> putBoxItems = this.updatePutBoxItems(putBoxList, archives, item, corps, putBoxItemsList, null);
+					if (!putBoxItems.isEmpty()) {
+						putBoxItemsOldList.addAll(putBoxItems);
+					}
+					//更新箱档案数据
+					this.updateArchives(archives, item, ports, corps);
+					archivesArrayList.add(archives);
+				} else if ("代理箱".equals(archives.getContainerNumberType())) {
+					//箱档案数据删除
+					archivesDateleList.add(archives.getId());
+					//修改原放箱号明细数据
+					List<PutBoxItems> putBoxItems = this.updatePutBoxItems(putBoxList, archives, item, corps, putBoxItemsList, null);
+					if (!putBoxItems.isEmpty()) {
+						putBoxItemsOldList.addAll(putBoxItems);
+					}
+				} else if ("OW(拿)".equals(archives.getContainerNumberType())) {
+					//箱档案数据删除
+					archivesDateleList.add(archives.getId());
+					//修改原放箱号明细数据
+					List<PutBoxItems> putBoxItems = this.updatePutBoxItems(putBoxList, archives, item, corps, putBoxItemsList, null);
+					if (!putBoxItems.isEmpty()) {
+						putBoxItemsOldList.addAll(putBoxItems);
+					}
+					//修改原放ow单据明细数据
+					List<TradingBoxItem> tradingBoxItems = this.updatePutBoxItemsTrading(putBoxList, archives, item, corps, tradingBoxList, tradingBoxItemList, ports, null);
+					if (!tradingBoxItems.isEmpty()) {
+						tradingBoxItemOldList.addAll(tradingBoxItems);
+					}
+				} else {
+					throw new RemoteException("箱号:" + item.getBoxCode() + "放箱号类型错误");
+				}
 			}
 		}
 		if (!putBoxNewList.isEmpty()) {
@@ -1347,11 +1381,18 @@ public class PutBoxServiceImpl extends ServiceImpl<PutBoxMapper, PutBox> impleme
 
 	private List<TradingBoxItem> updatePutBoxItemsTrading(List<PutBox> putBoxList, Archives archives, EmptyContainerAppearance item,
 														  BCorps corps, List<TradingBox> tradingBoxList,
-														  List<TradingBoxItem> tradingBoxItemList, BPorts ports) {
+														  List<TradingBoxItem> tradingBoxItemList, BPorts ports, String status) {
+		PutBox putBoxOld;
+		if ("1".equals(status)) {
+			putBoxOld = putBoxList.stream().filter(e -> e.getContainerNumber().equals(archives.getContainerNumberOw())
+				&& ObjectUtils.isNotNull(e.getPolId()) && e.getPolId().equals(archives.getAddressId())
+				&& ObjectUtils.isNotNull(e.getPolStationId()) && e.getPolStationId().equals(archives.getStationId())).findFirst().orElse(null);
+		} else {
+			putBoxOld = putBoxList.stream().filter(e -> e.getContainerNumber().equals(archives.getContainerNumber())
+				&& ObjectUtils.isNotNull(e.getPolId()) && e.getPolId().equals(archives.getAddressId())
+				&& ObjectUtils.isNotNull(e.getPolStationId()) && e.getPolStationId().equals(archives.getStationId())).findFirst().orElse(null);
+		}
 		List<TradingBoxItem> tradingBoxItemOldList = new ArrayList<>();
-		PutBox putBoxOld = putBoxList.stream().filter(e -> e.getContainerNumber().equals(archives.getContainerNumber())
-			&& ObjectUtils.isNotNull(e.getPolId()) && e.getPolId().equals(archives.getAddressId())
-			&& ObjectUtils.isNotNull(e.getPolStationId()) && e.getPolStationId().equals(archives.getStationId())).findFirst().orElse(null);
 		if (putBoxOld != null) {
 			if (ObjectUtils.isNotNull(putBoxOld.getBoxType()) && !putBoxOld.getBoxType().equals(item.getBoxType())) {
 				throw new RuntimeException("放箱号:" + archives.getContainerNumber() + "箱型不符合");
@@ -1400,11 +1441,19 @@ public class PutBoxServiceImpl extends ServiceImpl<PutBoxMapper, PutBox> impleme
 		return tradingBoxItemOldList;
 	}
 
-	private List<PutBoxItems> updatePutBoxItems(List<PutBox> putBoxList, Archives archives, EmptyContainerAppearance item, BCorps corps, List<PutBoxItems> putBoxItemsList) {
+	private List<PutBoxItems> updatePutBoxItems(List<PutBox> putBoxList, Archives archives, EmptyContainerAppearance item,
+												BCorps corps, List<PutBoxItems> putBoxItemsList, String status) {
+		PutBox putBoxOld;
+		if ("1".equals(status)) {
+			putBoxOld = putBoxList.stream().filter(e -> e.getContainerNumber().equals(archives.getContainerNumberOw())
+				&& ObjectUtils.isNotNull(e.getPolId()) && e.getPolId().equals(archives.getAddressId())
+				&& ObjectUtils.isNotNull(e.getPolStationId()) && e.getPolStationId().equals(archives.getStationId())).findFirst().orElse(null);
+		} else {
+			putBoxOld = putBoxList.stream().filter(e -> e.getContainerNumber().equals(archives.getContainerNumber())
+				&& ObjectUtils.isNotNull(e.getPolId()) && e.getPolId().equals(archives.getAddressId())
+				&& ObjectUtils.isNotNull(e.getPolStationId()) && e.getPolStationId().equals(archives.getStationId())).findFirst().orElse(null);
+		}
 		List<PutBoxItems> putBoxItemsOldList = new ArrayList<>();
-		PutBox putBoxOld = putBoxList.stream().filter(e -> e.getContainerNumber().equals(archives.getContainerNumber())
-			&& ObjectUtils.isNotNull(e.getPolId()) && e.getPolId().equals(archives.getAddressId())
-			&& ObjectUtils.isNotNull(e.getPolStationId()) && e.getPolStationId().equals(archives.getStationId())).findFirst().orElse(null);
 		if (putBoxOld != null) {
 			if (ObjectUtils.isNotNull(putBoxOld.getBoxType()) && !putBoxOld.getBoxType().equals(item.getBoxType())) {
 				throw new RuntimeException("放箱号:" + archives.getContainerNumber() + "箱型不符合");
@@ -1436,10 +1485,17 @@ public class PutBoxServiceImpl extends ServiceImpl<PutBoxMapper, PutBox> impleme
 		return putBoxItemsOldList;
 	}
 
-	private List<PutBox> create(List<PutBox> putBoxList, Archives archives, BPorts ports, BCorps corps, List<PutBox> putBoxNewList, Long id) {
-		PutBox putBox = putBoxList.stream().filter(e -> e.getContainerNumber().equals(archives.getContainerNumber())
-			&& e.getPolId().equals(ports.getId()) && e.getPolStationId().equals(corps.getId())
-			&& e.getBusType().equals(archives.getContainerNumberType())).findFirst().orElse(null);
+	private List<PutBox> create(List<PutBox> putBoxList, Archives archives, BPorts ports, BCorps corps, List<PutBox> putBoxNewList, Long id, String status) {
+		PutBox putBox;
+		if ("1".equals(status)) {
+			putBox = putBoxList.stream().filter(e -> e.getContainerNumber().equals(archives.getContainerNumberOw())
+				&& e.getPolId().equals(ports.getId()) && e.getPolStationId().equals(corps.getId())
+				&& e.getBusType().equals(archives.getContainerNumberTypeOw())).findFirst().orElse(null);
+		} else {
+			putBox = putBoxList.stream().filter(e -> e.getContainerNumber().equals(archives.getContainerNumber())
+				&& e.getPolId().equals(ports.getId()) && e.getPolStationId().equals(corps.getId())
+				&& e.getBusType().equals(archives.getContainerNumberType())).findFirst().orElse(null);
+		}
 		if (putBox == null) {
 			if (!putBoxNewList.isEmpty()) {
 				PutBox putBox1 = putBoxNewList.stream().filter(e -> e.getContainerNumber().equals(archives.getContainerNumber())
@@ -1659,12 +1715,12 @@ public class PutBoxServiceImpl extends ServiceImpl<PutBoxMapper, PutBox> impleme
 			}
 			if ("自有箱".equals(archives.getContainerNumberType())) {
 				//判断目的港是否存在对应放箱号单据处理
-				List<PutBox> putBoxes = this.create(putBoxList, archives, ports, corps, putBoxNewList, businessType.getId());
+				List<PutBox> putBoxes = this.create(putBoxList, archives, ports, corps, putBoxNewList, businessType.getId(), null);
 				if (!putBoxes.isEmpty()) {
 					putBoxNewList.addAll(putBoxes);
 				}
 				//修改原放箱号明细数据
-				List<PutBoxItems> putBoxItems = this.updatePutBoxItems(putBoxList, archives, item, corps, putBoxItemsList);
+				List<PutBoxItems> putBoxItems = this.updatePutBoxItems(putBoxList, archives, item, corps, putBoxItemsList, null);
 				if (!putBoxItems.isEmpty()) {
 					putBoxItemsOldList.addAll(putBoxItems);
 				}
@@ -1675,7 +1731,7 @@ public class PutBoxServiceImpl extends ServiceImpl<PutBoxMapper, PutBox> impleme
 				//箱档案数据删除
 				archivesDateleList.add(archives.getId());
 				//修改原放箱号明细数据
-				List<PutBoxItems> putBoxItems = this.updatePutBoxItems(putBoxList, archives, item, corps, putBoxItemsList);
+				List<PutBoxItems> putBoxItems = this.updatePutBoxItems(putBoxList, archives, item, corps, putBoxItemsList, null);
 				if (!putBoxItems.isEmpty()) {
 					putBoxItemsOldList.addAll(putBoxItems);
 				}
@@ -1683,28 +1739,28 @@ public class PutBoxServiceImpl extends ServiceImpl<PutBoxMapper, PutBox> impleme
 				//箱档案数据删除
 				archivesDateleList.add(archives.getId());
 				//修改原放箱号明细数据
-				List<PutBoxItems> putBoxItems = this.updatePutBoxItems(putBoxList, archives, item, corps, putBoxItemsList);
+				List<PutBoxItems> putBoxItems = this.updatePutBoxItems(putBoxList, archives, item, corps, putBoxItemsList, null);
 				if (!putBoxItems.isEmpty()) {
 					putBoxItemsOldList.addAll(putBoxItems);
 				}
 				//修改原放ow单据明细数据
-				List<TradingBoxItem> tradingBoxItems = this.updatePutBoxItemsTrading(putBoxList, archives, item, corps, tradingBoxList, tradingBoxItemList, ports);
+				List<TradingBoxItem> tradingBoxItems = this.updatePutBoxItemsTrading(putBoxList, archives, item, corps, tradingBoxList, tradingBoxItemList, ports, null);
 				if (!tradingBoxItems.isEmpty()) {
 					tradingBoxItemOldList.addAll(tradingBoxItems);
 				}
 			} else if ("OW(放)".equals(archives.getContainerNumberType())) {
 				//判断目的港是否存在对应放箱号单据处理
-				List<PutBox> putBoxes = this.create(putBoxList, archives, ports, corps, putBoxNewList, businessType.getId());
+				List<PutBox> putBoxes = this.create(putBoxList, archives, ports, corps, putBoxNewList, businessType.getId(), null);
 				if (!putBoxes.isEmpty()) {
 					putBoxNewList.addAll(putBoxes);
 				}
 				//修改原放箱号明细数据
-				List<PutBoxItems> putBoxItems = this.updatePutBoxItems(putBoxList, archives, item, corps, putBoxItemsList);
+				List<PutBoxItems> putBoxItems = this.updatePutBoxItems(putBoxList, archives, item, corps, putBoxItemsList, null);
 				if (!putBoxItems.isEmpty()) {
 					putBoxItemsOldList.addAll(putBoxItems);
 				}
 				//修改原放ow单据明细数据
-				List<TradingBoxItem> tradingBoxItems = this.updatePutBoxItemsTrading(putBoxList, archives, item, corps, tradingBoxList, tradingBoxItemList, ports);
+				List<TradingBoxItem> tradingBoxItems = this.updatePutBoxItemsTrading(putBoxList, archives, item, corps, tradingBoxList, tradingBoxItemList, ports, null);
 				if (!tradingBoxItems.isEmpty()) {
 					tradingBoxItemOldList.addAll(tradingBoxItems);
 				}
@@ -1868,5 +1924,4 @@ public class PutBoxServiceImpl extends ServiceImpl<PutBoxMapper, PutBox> impleme
 		details.setInternalContainerNumber("");
 		return details;
 	}
-
 }

+ 158 - 32
blade-service/blade-los/src/main/java/org/springblade/los/box/service/impl/TradingBoxServiceImpl.java

@@ -1529,14 +1529,14 @@ public class TradingBoxServiceImpl extends ServiceImpl<TradingBoxMapper, Trading
 						archives1.setNewDate(detail.getActivationDate());
 						archives1.setBoxDynamics("空箱入场");
 						archives1.setStatus("待使用");
-						archives1.setAddressId(tradingBox.getAddressId());
-						archives1.setAddressCode(tradingBox.getAddressCode());
-						archives1.setAddressCname(tradingBox.getAddressCname());
-						archives1.setAddressEname(tradingBox.getAddressEname());
-						archives1.setStationId(tradingBox.getStationId());
-						archives1.setStationCode(tradingBox.getStationCode());
-						archives1.setStationCname(tradingBox.getStationCname());
-						archives1.setStationEname(tradingBox.getStationEname());
+						archives1.setAddressId(detail.getAddressId());
+						archives1.setAddressCode(detail.getAddressCode());
+						archives1.setAddressCname(detail.getAddressCname());
+						archives1.setAddressEname(detail.getAddressEname());
+						archives1.setStationId(detail.getStationId());
+						archives1.setStationCode(detail.getStationCode());
+						archives1.setStationCname(detail.getStationCname());
+						archives1.setStationEname(detail.getStationEname());
 						if ("BUY".equals(tradingBox.getType())) {
 							archives1.setContainerNumberType("自有箱");
 						} else if ("SELL".equals(tradingBox.getType())) {
@@ -1574,14 +1574,14 @@ public class TradingBoxServiceImpl extends ServiceImpl<TradingBoxMapper, Trading
 						archives1.setContractNo(tradingBox.getContractNo());
 						archives1.setBoxDynamics(item.getBoxDynamics());
 						archives1.setStatus(item.getStatus());
-						archives1.setAddressId(tradingBox.getAddressId());
-						archives1.setAddressCode(tradingBox.getAddressCode());
-						archives1.setAddressCname(tradingBox.getAddressCname());
-						archives1.setAddressEname(tradingBox.getAddressEname());
-						archives1.setStationId(tradingBox.getStationId());
-						archives1.setStationCode(tradingBox.getStationCode());
-						archives1.setStationCname(tradingBox.getStationCname());
-						archives1.setStationEname(tradingBox.getStationEname());
+						archives1.setAddressId(detail.getPolId());
+						archives1.setAddressCode(detail.getPolCode());
+						archives1.setAddressCname(detail.getPolCname());
+						archives1.setAddressEname(detail.getPolEname());
+						archives1.setStationId(detail.getPolStationId());
+						archives1.setStationCode(detail.getPolStationCode());
+						archives1.setStationCname(detail.getPolStationCname());
+						archives1.setStationEname(detail.getPolStationEname());
 						if ("BUY".equals(tradingBox.getType())) {
 							archives1.setPurchaseDate(tradingBox.getPurchaseDate());
 							archives1.setBoxSource("买箱");
@@ -1631,14 +1631,14 @@ public class TradingBoxServiceImpl extends ServiceImpl<TradingBoxMapper, Trading
 					archives1.setContractNo(tradingBox.getContractNo());
 					archives1.setBoxDynamics(item.getBoxDynamics());
 					archives1.setStatus(item.getStatus());
-					archives1.setAddressId(tradingBox.getAddressId());
-					archives1.setAddressCode(tradingBox.getAddressCode());
-					archives1.setAddressCname(tradingBox.getAddressCname());
-					archives1.setAddressEname(tradingBox.getAddressEname());
-					archives1.setStationId(tradingBox.getStationId());
-					archives1.setStationCode(tradingBox.getStationCode());
-					archives1.setStationCname(tradingBox.getStationCname());
-					archives1.setStationEname(tradingBox.getStationEname());
+					archives1.setAddressId(detail.getPolId());
+					archives1.setAddressCode(detail.getPolCode());
+					archives1.setAddressCname(detail.getPolCname());
+					archives1.setAddressEname(detail.getPolEname());
+					archives1.setStationId(detail.getPolStationId());
+					archives1.setStationCode(detail.getPolStationCode());
+					archives1.setStationCname(detail.getPolStationCname());
+					archives1.setStationEname(detail.getPolStationEname());
 					if ("BUY".equals(tradingBox.getType())) {
 						archives1.setPurchaseDate(tradingBox.getPurchaseDate());
 						archives1.setBoxSource("买箱");
@@ -1674,14 +1674,14 @@ public class TradingBoxServiceImpl extends ServiceImpl<TradingBoxMapper, Trading
 				} else if ("DL".equals(tradingBox.getType())) {
 					archivesTrajectory.setStatus("代理");
 				}
-				archivesTrajectory.setPortId(tradingBox.getAddressId());
-				archivesTrajectory.setPortCode(tradingBox.getAddressCode());
-				archivesTrajectory.setPortCname(tradingBox.getAddressCname());
-				archivesTrajectory.setPortEname(tradingBox.getAddressEname());
-				archivesTrajectory.setStationId(tradingBox.getStationId());
-				archivesTrajectory.setStationCode(tradingBox.getStationCode());
-				archivesTrajectory.setStationCname(tradingBox.getStationCname());
-				archivesTrajectory.setStationEname(tradingBox.getStationEname());
+				archivesTrajectory.setPortId(detail.getPolId());
+				archivesTrajectory.setPortCode(detail.getPolCode());
+				archivesTrajectory.setPortCname(detail.getPolCname());
+				archivesTrajectory.setPortEname(detail.getPolEname());
+				archivesTrajectory.setStationId(detail.getPolStationId());
+				archivesTrajectory.setStationCode(detail.getPolStationCode());
+				archivesTrajectory.setStationCname(detail.getPolStationCname());
+				archivesTrajectory.setStationEname(detail.getPolStationEname());
 				archivesTrajectory.setContainerNumber(item.getContainerNumber());
 				archivesTrajectory.setBoxType(item.getBoxType());
 				archivesTrajectory.setBoxCategory(item.getBoxCategory());
@@ -1914,4 +1914,130 @@ public class TradingBoxServiceImpl extends ServiceImpl<TradingBoxMapper, Trading
 		return tradingBox;
 	}
 
+	@Override
+	@Transactional(rollbackFor = Exception.class)
+	public R countRent(TradingBox tradingBox) {
+		if (tradingBox.getId() == null) {
+			throw new RuntimeException("缺少必要参数");
+		}
+		TradingBox detail = baseMapper.selectById(tradingBox.getId());
+		List<TradingBoxItem> putBoxItemsList = tradingBoxItemService.list(new LambdaQueryWrapper<TradingBoxItem>()
+			.eq(TradingBoxItem::getTenantId, AuthUtil.getTenantId())
+			.eq(TradingBoxItem::getIsDeleted, 0)
+			.eq(TradingBoxItem::getPid, detail.getId())
+			.eq(TradingBoxItem::getWhetherCountRent, "0")
+			.isNotNull(TradingBoxItem::getPolStationEmptyContainerExitDate)
+			.isNotNull(TradingBoxItem::getPodEmptyContainerReturnDate)
+		);
+		if (putBoxItemsList.isEmpty()) {
+			throw new RuntimeException("未查到需计算租金明细");
+		}
+		List<RentTerm> rentTermList = rentTermService.list(new LambdaQueryWrapper<RentTerm>()
+			.eq(RentTerm::getIsDeleted, 0)
+			.eq(RentTerm::getTenantId, AuthUtil.getTenantId())
+			.eq(RentTerm::getPid, detail.getId())
+			.isNotNull(RentTerm::getRiseDays)
+			.isNotNull(RentTerm::getStopDays)
+			.orderByAsc(RentTerm::getRiseDays)
+		);
+		if (rentTermList.isEmpty()) {
+			throw new RuntimeException("请先维护租金条款");
+		}
+		BFees fees = bFeesService.getOne(new LambdaQueryWrapper<BFees>()
+			.eq(BFees::getTenantId, AuthUtil.getTenantId())
+			.eq(BFees::getIsDeleted, 0)
+			.eq(BFees::getCode, "BOX-ZJ"));
+		if (fees == null) {
+			throw new RuntimeException("请先维护费用基础信息");
+		}
+		BigDecimal exrateC = bCurrencyService.getCnyExrate(new Date(), "USD", "C", "1");
+		List<FeeCenter> feeCenterList = new ArrayList<>();
+		for (TradingBoxItem item : putBoxItemsList) {
+			item.setWhetherCountRent("1");
+			item.setUpdateTime(new Date());
+			item.setUpdateUserName(AuthUtil.getUserName());
+			item.setUpdateUser(AuthUtil.getUserId());
+			FeeCenter feeCenter = new FeeCenter();
+			feeCenter.setBillType("箱东");
+			feeCenter.setCorpId(tradingBox.getPurchaseCompanyId());
+			feeCenter.setCorpCnName(tradingBox.getPurchaseCompanyName());
+			feeCenter.setCorpEnName(tradingBox.getPurchaseCompanyName());
+			feeCenter.setCreateTime(new Date());
+			feeCenter.setCreateUser(AuthUtil.getUserId());
+			feeCenter.setCreateUserName(AuthUtil.getUserName());
+			feeCenter.setPid(item.getPid());
+			feeCenter.setDc("C");
+			feeCenter.setFeeId(fees.getId());
+			feeCenter.setFeeCode(fees.getCode());
+			feeCenter.setFeeCnName(fees.getCnName());
+			feeCenter.setFeeEnName(fees.getEnName());
+			feeCenter.setCurCode(fees.getCurNo());
+			feeCenter.setCntrNo(item.getCode());
+			feeCenter.setUnitNo(item.getBoxType());
+			Instant instant1 = item.getPolStationEmptyContainerExitDate().toInstant();
+			Instant instant2 = item.getPodEmptyContainerReturnDate().toInstant();
+			LocalDate date1 = instant1.atZone(ZoneId.systemDefault()).toLocalDate();
+			LocalDate date2 = instant2.atZone(ZoneId.systemDefault()).toLocalDate();
+			Duration duration = Duration.between(date1.atStartOfDay(), date2.atStartOfDay());
+			Calendar calendar = Calendar.getInstance();
+			calendar.setTime(tradingBox.getRentEndDate());
+			calendar.add(Calendar.DAY_OF_MONTH, 1);
+			feeCenter.setStorageDate(item.getPolStationEmptyContainerExitDate());
+			feeCenter.setDays(Integer.parseInt(duration.toDays() + ""));
+			Integer days = feeCenter.getDays();
+			int earlySumDays = 0;
+			String text = "";
+			int dayLength;
+			BigDecimal amount = new BigDecimal("0.00");
+			for (RentTerm term : rentTermList) {
+				dayLength = term.getStopDays() - term.getRiseDays() + 1;
+				if (earlySumDays >= dayLength) {
+					earlySumDays -= dayLength;
+					continue;
+				}
+				if (earlySumDays + days > dayLength) {
+					Integer tempDays = dayLength - earlySumDays;
+					earlySumDays = 0;
+					days -= tempDays;
+					BigDecimal calculate = term.getRate().multiply(new BigDecimal(tempDays + ""));
+					amount = amount.add(calculate);
+					text = tempDays + "天*" + term.getRate() + "元=" + calculate + "元,";
+				} else {
+					BigDecimal calculate = term.getRate().multiply(new BigDecimal(days + ""));
+					amount = amount.add(calculate);
+					text = days + "天*" + term.getRate() + "元=" + calculate + "元";
+					break;
+				}
+			}
+			if ("CNY".equals(feeCenter.getCurCode())) {
+				feeCenter.setExrate(new BigDecimal("1.00"));
+			} else {
+				feeCenter.setExrate(exrateC);
+			}
+			feeCenter.setPrice(amount);
+			feeCenter.setAmount(amount);
+			feeCenter.setRemarks(text);
+			feeCenter.setQuantity(new BigDecimal("1"));
+			feeCenter.setOutboundDate(item.getPodEmptyContainerReturnDate());
+			feeCenter.setBillNo(tradingBox.getSysNo());
+			feeCenter.setBusinessType(tradingBox.getType());
+			feeCenter.setBillDate(tradingBox.getPurchaseDate());
+			feeCenter.setBillCorpId(tradingBox.getPurchaseCompanyId());
+			feeCenter.setBillCorpCnName(tradingBox.getPurchaseCompanyName());
+			feeCenter.setBillCorpEnName(tradingBox.getPurchaseCompanyName());
+			feeCenter.setBillShortName(tradingBox.getPurchaseCompanyName());
+			feeCenter.setMblno(tradingBox.getContainerNumber());
+			feeCenter.setPolId(tradingBox.getPolId());
+			feeCenter.setPolCode(tradingBox.getPolCode());
+			feeCenter.setPolCnName(tradingBox.getPolCname());
+			feeCenter.setPolEnName(tradingBox.getPolEname());
+			feeCenterList.add(feeCenter);
+		}
+		tradingBoxItemService.updateBatchById(putBoxItemsList);
+		if (!feeCenterList.isEmpty()) {
+			feeCenterService.saveBatch(feeCenterList);
+		}
+		return R.data(tradingBox);
+	}
+
 }