Browse Source

永发 禅道bug修改
箱池动态导入导出接口

纪新园 1 year ago
parent
commit
c31bddb7cf
22 changed files with 1116 additions and 344 deletions
  1. 3 18
      blade-service-api/blade-los-api/src/main/java/org/springblade/los/basic/corps/entity/BCorps.java
  2. 21 0
      blade-service-api/blade-los-api/src/main/java/org/springblade/los/basic/ports/entity/BPorts.java
  3. 14 0
      blade-service-api/blade-los-api/src/main/java/org/springblade/los/box/dto/BoxPoolContainerNumberDTO.java
  4. 15 0
      blade-service-api/blade-los-api/src/main/java/org/springblade/los/box/dto/BoxPoolDTO.java
  5. 9 0
      blade-service-api/blade-los-api/src/main/java/org/springblade/los/box/dto/BoxPoolPortDTO.java
  6. 5 0
      blade-service-api/blade-los-api/src/main/java/org/springblade/los/box/entity/Archives.java
  7. 1 1
      blade-service-api/blade-los-api/src/main/java/org/springblade/los/box/entity/ArchivesFiles.java
  8. 10 5
      blade-service-api/blade-los-api/src/main/java/org/springblade/los/box/entity/PutBox.java
  9. 14 2
      blade-service-api/blade-los-api/src/main/java/org/springblade/los/box/entity/TradingBox.java
  10. 6 0
      blade-service-api/blade-los-api/src/main/java/org/springblade/los/logistics/route/entity/RouteCost.java
  11. 17 12
      blade-service/blade-los/src/main/java/org/springblade/los/basic/corps/controller/BCorpsController.java
  12. 11 8
      blade-service/blade-los/src/main/java/org/springblade/los/box/controller/BoxPoolController.java
  13. 10 3
      blade-service/blade-los/src/main/java/org/springblade/los/box/controller/PutBoxController.java
  14. 21 0
      blade-service/blade-los/src/main/java/org/springblade/los/box/controller/TradingBoxController.java
  15. 4 4
      blade-service/blade-los/src/main/java/org/springblade/los/box/controller/TradingBoxItemController.java
  16. 27 3
      blade-service/blade-los/src/main/java/org/springblade/los/box/mapper/PutBoxMapper.xml
  17. 2 0
      blade-service/blade-los/src/main/java/org/springblade/los/box/service/IPutBoxService.java
  18. 4 0
      blade-service/blade-los/src/main/java/org/springblade/los/box/service/ITradingBoxService.java
  19. 554 106
      blade-service/blade-los/src/main/java/org/springblade/los/box/service/impl/PutBoxServiceImpl.java
  20. 360 177
      blade-service/blade-los/src/main/java/org/springblade/los/box/service/impl/TradingBoxServiceImpl.java
  21. 5 2
      blade-service/blade-los/src/main/java/org/springblade/los/excel/RouteCostProfitExcel.java
  22. 3 3
      blade-service/blade-los/src/main/java/org/springblade/los/logistics/route/controller/RouteCostProfitController.java

+ 3 - 18
blade-service-api/blade-los-api/src/main/java/org/springblade/los/basic/corps/entity/BCorps.java

@@ -614,25 +614,10 @@ public class BCorps implements Serializable {
 	private String carrierArgreementNo;
 
 	/**
-	 * 港口id
+	 * 场站ids
 	 */
-	@ApiModelProperty(value = "港口id")
-	private Long addressId;
-	/**
-	 * 港口编码
-	 */
-	@ApiModelProperty(value = "港口编码")
-	private String addressCode;
-	/**
-	 * 港口中文
-	 */
-	@ApiModelProperty(value = "港口中文")
-	private String addressCname;
-	/**
-	 * 港口英文
-	 */
-	@ApiModelProperty(value = "港口英文")
-	private String addressEname;
+	@TableField(exist = false)
+	private String ids;
 
 
 }

+ 21 - 0
blade-service-api/blade-los-api/src/main/java/org/springblade/los/basic/ports/entity/BPorts.java

@@ -185,5 +185,26 @@ public class BPorts implements Serializable {
 	@TableField(exist = false)
 	private List<BPortsTerms> bPortsTermsList;
 
+	/**
+	 * 港口id
+	 */
+	@ApiModelProperty(value = "港口id")
+	private String addressId;
+	/**
+	 * 港口编码
+	 */
+	@ApiModelProperty(value = "港口编码")
+	private String addressCode;
+	/**
+	 * 港口中文
+	 */
+	@ApiModelProperty(value = "港口中文")
+	private String addressCname;
+	/**
+	 * 港口英文
+	 */
+	@ApiModelProperty(value = "港口英文")
+	private String addressEname;
+
 
 }

+ 14 - 0
blade-service-api/blade-los-api/src/main/java/org/springblade/los/box/dto/BoxPoolContainerNumberDTO.java

@@ -16,6 +16,7 @@
  */
 package org.springblade.los.box.dto;
 
+import io.swagger.annotations.ApiModelProperty;
 import lombok.Data;
 
 /**
@@ -147,6 +148,19 @@ public class BoxPoolContainerNumberDTO {
 	 */
 	private Long remainingTotal;
 
+	/**
+	 * 可用箱量
+	 */
+	private Long remainingNum;
+	/**
+	 * 总箱量
+	 */
+	private Long totalNum;
+
+	/**
+	 * 操作占用
+	 */
+	private Integer occupyNum;
 
 
 }

+ 15 - 0
blade-service-api/blade-los-api/src/main/java/org/springblade/los/box/dto/BoxPoolDTO.java

@@ -43,6 +43,11 @@ public class BoxPoolDTO {
 	private Long boxEastId;
 
 	/**
+	 * 箱东
+	 */
+	private String boxEastName;
+
+	/**
 	 * 场站/堆场
 	 */
 	private Long stationId;
@@ -63,6 +68,16 @@ public class BoxPoolDTO {
 	private Long podId;
 
 	/**
+	 * 起运港
+	 */
+	private String polName;
+
+	/**
+	 * 目的港
+	 */
+	private String podName;
+
+	/**
 	 * 箱型
 	 */
 	private String boxType;

+ 9 - 0
blade-service-api/blade-los-api/src/main/java/org/springblade/los/box/dto/BoxPoolPortDTO.java

@@ -96,8 +96,17 @@ public class BoxPoolPortDTO {
 	private Long remainingTotal;
 
 	/**
+	 * 可用箱量
+	 */
+	private Long remainingNum;
+
+	/**
 	 * 放箱号类型
 	 */
 	private String busType;
+/**
+	 * 放箱号类型
+	 */
+	private String boxType;
 
 }

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

@@ -330,6 +330,11 @@ public class Archives implements Serializable {
 	@ApiModelProperty(value = "启用日期")
 	private Date activationDate;
 
+	/**
+	 * 放箱号类型
+	 */
+	@ApiModelProperty(value = "放箱号类型")
+	private String containerNumberType;
 
 
 	/**

+ 1 - 1
blade-service-api/blade-los-api/src/main/java/org/springblade/los/box/entity/ArchivesFiles.java

@@ -124,7 +124,7 @@ public class ArchivesFiles implements Serializable {
 	private String value;
 
 	/**
-	 * 分类 1空箱出场 2 空箱进场edi 3空箱进场excel 4无货返空
+	 * 分类 1空箱出场 2 空箱进场excel 3无货返空
 	 */
 	@ApiModelProperty(value = "分类")
 	private String type;

+ 10 - 5
blade-service-api/blade-los-api/src/main/java/org/springblade/los/box/entity/PutBox.java

@@ -114,7 +114,7 @@ public class PutBox implements Serializable {
 	 * 起运港
 	 */
 	@ApiModelProperty(value = "起运港")
-	private String polId;
+	private Long polId;
 	/**
 	 * 起运港中文
 	 */
@@ -181,14 +181,19 @@ public class PutBox implements Serializable {
 	@ApiModelProperty(value = "箱种类")
 	private String boxClass;
 	/**
-	 * 总箱数
+	 * 场地盘存
 	 */
-	@ApiModelProperty(value = "总箱数")
+	@ApiModelProperty(value = "场地盘存")
 	private Integer totalNum;
 	/**
-	 * 剩余箱量
+	 * 操作占用
 	 */
-	@ApiModelProperty(value = "剩余箱量")
+	@ApiModelProperty(value = "操作占用")
+	private Integer occupyNum;
+	/**
+	 * 可用箱
+	 */
+	@ApiModelProperty(value = "可用箱")
 	private Integer remainingNum;
 	/**
 	 * 箱属

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

@@ -138,7 +138,7 @@ public class TradingBox implements Serializable {
 	@ApiModelProperty(value = "状态")
 	private Integer status;
 	/**
-	 * 类别(BUY:买箱 、SELL:卖箱、ZR:租入、ZC:租出、DL:代理箱、OW-N:OW拿箱、OW-F:OW放箱、XGFY:箱管费用)
+	 * 类别(BUY:买箱 、SELL:卖箱、ZR:租入、ZC:租出、DL:代理箱、OW-N:OW拿箱、OW-F:OW放箱、XGFY:箱管费用、XGDX:箱管调箱
 	 */
 	@ApiModelProperty(value = "类别")
 	private String type;
@@ -331,7 +331,7 @@ public class TradingBox implements Serializable {
 	 * 起运港
 	 */
 	@ApiModelProperty(value = "起运港")
-	private String polId;
+	private Long polId;
 	/**
 	 * 起运港中文
 	 */
@@ -522,6 +522,18 @@ public class TradingBox implements Serializable {
 	private Date rentingOutDate;
 
 	/**
+	 * 临时数据
+	 */
+	@ApiModelProperty(value = "临时数据")
+	private String cyText;
+
+	/**
+	 * 临时数据
+	 */
+	@TableField(exist = false)
+	private String cyTextOne;
+
+	/**
 	 * 买入时间(开始-结束)
 	 */
 	@TableField(exist = false)

+ 6 - 0
blade-service-api/blade-los-api/src/main/java/org/springblade/los/logistics/route/entity/RouteCost.java

@@ -512,6 +512,12 @@ public class RouteCost implements Serializable {
 	@TableField(updateStrategy = FieldStrategy.IGNORED)
 	private String transportationTermsTwo;
 
+	/**
+	 * 限大柜
+	 */
+	@ApiModelProperty(value = "限大柜")
+	private String limitBox;
+
 
 	/**
 	 * 费用明细

+ 17 - 12
blade-service/blade-los/src/main/java/org/springblade/los/basic/corps/controller/BCorpsController.java

@@ -115,12 +115,10 @@ public class BCorpsController extends BladeController {
 			.eq(BCorps::getIsDeleted, 0)
 			.like(ObjectUtils.isNotNull(bCorps.getCode()), BCorps::getCode, bCorps.getCode())
 			.eq(ObjectUtils.isNotNull(bCorps.getStatus()), BCorps::getStatus, bCorps.getStatus())
-			.eq(ObjectUtils.isNotNull(bCorps.getAddressId()), BCorps::getAddressId, bCorps.getAddressId())
 			.and(ObjectUtils.isNotNull(bCorps.getCnName()), i -> i.like(BCorps::getCnName, bCorps.getCnName()).or()
 				.like(BCorps::getEnName, bCorps.getCnName()).or().like(BCorps::getCode, bCorps.getCnName()))
-			.and(ObjectUtils.isNotNull(bCorps.getAddressCname()), i -> i.like(BCorps::getAddressCname, bCorps.getAddressCname()).or()
-				.like(BCorps::getAddressEname, bCorps.getAddressCname()).or().like(BCorps::getAddressCode, bCorps.getAddressCname()))
 			.like(ObjectUtils.isNotNull(bCorps.getShortName()), BCorps::getShortName, bCorps.getShortName())
+			.apply(ObjectUtils.isNotNull(bCorps.getIds()), "find_in_set(id,'" + bCorps.getIds() + "')")
 			.like(ObjectUtils.isNotNull(bCorps.getEnName()), BCorps::getEnName, bCorps.getEnName())
 			.like(ObjectUtils.isNotNull(bCorps.getUscc()), BCorps::getUscc, bCorps.getUscc())
 			.like(ObjectUtils.isNotNull(bCorps.getCnAddr()), BCorps::getCnAddr, bCorps.getCnAddr())
@@ -210,8 +208,7 @@ public class BCorpsController extends BladeController {
 			.and(ObjectUtils.isNotNull(bCorps.getCnName()), i -> i.like(BCorps::getCode, bCorps.getCnName()).or()
 				.like(BCorps::getCnName, bCorps.getCnName()).or().like(BCorps::getEnName, bCorps.getCnName())
 				.or().like(BCorps::getShortName, bCorps.getCnName()))
-			.and(ObjectUtils.isNotNull(bCorps.getAddressCname()), i -> i.like(BCorps::getAddressCname, bCorps.getAddressCname()).or()
-				.like(BCorps::getAddressEname, bCorps.getAddressCname()).or().like(BCorps::getAddressCode, bCorps.getAddressCname()))
+			.apply(ObjectUtils.isNotNull(bCorps.getIds()), "find_in_set(id,'" + bCorps.getIds() + "')")
 			.like(ObjectUtils.isNotNull(bCorps.getCode()), BCorps::getCode, bCorps.getCode())
 			.eq(ObjectUtils.isNotNull(bCorps.getStatus()), BCorps::getStatus, bCorps.getStatus())
 			.like(ObjectUtils.isNotNull(bCorps.getEnName()), BCorps::getEnName, bCorps.getEnName())
@@ -387,9 +384,9 @@ public class BCorpsController extends BladeController {
 		lambdaQueryWrapper.eq(BCorps::getTenantId, AuthUtil.getTenantId())
 			.eq(BCorps::getIsDeleted, 0)
 			.eq(ObjectUtils.isNotNull(bCorps.getStatus()), BCorps::getStatus, bCorps.getStatus())
-			.eq(ObjectUtils.isNotNull(bCorps.getAddressId()), BCorps::getAddressId, bCorps.getAddressId())
 			.and(ObjectUtils.isNotNull(bCorps.getCnName()), i -> i.like(BCorps::getCnName, bCorps.getCnName()).or()
 				.like(BCorps::getEnName, bCorps.getCnName()).or().like(BCorps::getCode, bCorps.getCnName()))
+			.apply(ObjectUtils.isNotNull(bCorps.getIds()), "find_in_set(id,'" + bCorps.getIds() + "')")
 			.like(ObjectUtils.isNotNull(bCorps.getEnName()), BCorps::getEnName, bCorps.getEnName())
 			.like(ObjectUtils.isNotNull(bCorps.getUscc()), BCorps::getUscc, bCorps.getUscc())
 			.like(ObjectUtils.isNotNull(bCorps.getCnAddr()), BCorps::getCnAddr, bCorps.getCnAddr())
@@ -401,8 +398,6 @@ public class BCorpsController extends BladeController {
 			.and(ObjectUtils.isNotNull(bCorps.getShortName()), i -> i.like(BCorps::getCnName, bCorps.getShortName()).or()
 				.like(BCorps::getEnName, bCorps.getShortName()).or().like(BCorps::getCode, bCorps.getShortName())
 				.or().like(BCorps::getShortName, bCorps.getShortName()))
-			.and(ObjectUtils.isNotNull(bCorps.getAddressCname()), i -> i.like(BCorps::getAddressCname, bCorps.getAddressCname()).or()
-				.like(BCorps::getAddressEname, bCorps.getAddressCname()).or().like(BCorps::getAddressCode, bCorps.getAddressCname()))
 			.like(ObjectUtils.isNotNull(bCorps.getTel()), BCorps::getTel, bCorps.getTel())
 			.like(ObjectUtils.isNotNull(bCorps.getAdminProfiles()), BCorps::getAdminProfiles, bCorps.getAdminProfiles())
 //			.apply(ObjectUtils.isNotNull(bCorps.getCorpType()), "find_in_set('" + bCorps.getCorpType() + "',corp_type)");
@@ -445,7 +440,7 @@ public class BCorpsController extends BladeController {
 	@ApiOperation(value = "分页", notes = "传入bCorps")
 	public R<List<BCorps>> list(BCorps bCorps) {
 		List<Long> corpIds = new ArrayList<>();
-		if (ObjectUtils.isNotNull(bCorps.getCorpTypeName())){
+		if (ObjectUtils.isNotNull(bCorps.getCorpTypeName())) {
 			List<Long> typeIds = new ArrayList<>();
 			LambdaQueryWrapper<BCorpsTypeDefine> lambdaQueryWrapperTypes = new LambdaQueryWrapper<>();
 			lambdaQueryWrapperTypes.eq(BCorpsTypeDefine::getTenantId, AuthUtil.getTenantId())
@@ -470,11 +465,9 @@ public class BCorpsController extends BladeController {
 			.in(!corpIds.isEmpty(), BCorps::getId, corpIds)
 			.like(ObjectUtils.isNotNull(bCorps.getCode()), BCorps::getCode, bCorps.getCode())
 			.eq(ObjectUtils.isNotNull(bCorps.getStatus()), BCorps::getStatus, bCorps.getStatus())
-			.eq(ObjectUtils.isNotNull(bCorps.getAddressId()), BCorps::getAddressId, bCorps.getAddressId())
 			.and(ObjectUtils.isNotNull(bCorps.getCnName()), i -> i.like(BCorps::getCnName, bCorps.getCnName()).or()
 				.like(BCorps::getEnName, bCorps.getCnName()).or().like(BCorps::getCode, bCorps.getCnName()))
-			.and(ObjectUtils.isNotNull(bCorps.getAddressCname()), i -> i.like(BCorps::getAddressCname, bCorps.getAddressCname()).or()
-				.like(BCorps::getAddressEname, bCorps.getAddressCname()).or().like(BCorps::getAddressCode, bCorps.getAddressCname()))
+			.apply(ObjectUtils.isNotNull(bCorps.getIds()), "find_in_set(id,'" + bCorps.getIds() + "')")
 			.like(ObjectUtils.isNotNull(bCorps.getShortName()), BCorps::getShortName, bCorps.getShortName())
 			.like(ObjectUtils.isNotNull(bCorps.getEnName()), BCorps::getEnName, bCorps.getEnName())
 			.like(ObjectUtils.isNotNull(bCorps.getUscc()), BCorps::getUscc, bCorps.getUscc())
@@ -495,6 +488,18 @@ public class BCorpsController extends BladeController {
 			lambdaQueryWrapper.orderByDesc(BCorps::getCreateTime);
 		}
 		List<BCorps> pages = bCorpsService.list(lambdaQueryWrapper);
+		for (BCorps item : pages) {
+			if (ObjectUtils.isNotNull(item.getExtendedData())) {
+				Gson gson = new Gson();
+				List<ExtendedData> list = gson.fromJson(item.getExtendedData(), new TypeToken<List<ExtendedData>>() {
+				}.getType());
+				if (ObjectUtils.isNotNull(list)) {
+					item.setExtendedDataArr(list);
+				} else {
+					item.setExtendedDataArr(new ArrayList<>());
+				}
+			}
+		}
 		return R.data(pages);
 	}
 

+ 11 - 8
blade-service/blade-los/src/main/java/org/springblade/los/box/controller/BoxPoolController.java

@@ -17,9 +17,6 @@
 package org.springblade.los.box.controller;
 
 import com.baomidou.mybatisplus.core.metadata.IPage;
-import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
-import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
-import io.swagger.annotations.ApiOperation;
 import lombok.AllArgsConstructor;
 import org.springblade.common.annotation.RepeatSubmit;
 import org.springblade.core.boot.ctrl.BladeController;
@@ -27,15 +24,12 @@ import org.springblade.core.excel.util.ExcelUtil;
 import org.springblade.core.mp.support.Condition;
 import org.springblade.core.mp.support.Query;
 import org.springblade.core.tool.api.R;
-import org.springblade.los.basic.countrys.entity.BCountrys;
 import org.springblade.los.box.dto.BoxPoolContainerNumberDTO;
 import org.springblade.los.box.dto.BoxPoolDTO;
 import org.springblade.los.box.dto.BoxPoolItemDTO;
 import org.springblade.los.box.dto.BoxPoolPortDTO;
-import org.springblade.los.box.entity.Archives;
 import org.springblade.los.box.excel.EmptyContainerAppearance;
 import org.springblade.los.box.service.IPutBoxService;
-import org.springblade.los.excel.BCountrysExcel;
 import org.springframework.web.bind.annotation.*;
 import org.springframework.web.multipart.MultipartFile;
 
@@ -70,7 +64,7 @@ public class BoxPoolController extends BladeController {
 	 */
 	@GetMapping("/listContainerNumber")
 	public R<IPage<BoxPoolContainerNumberDTO>> listContainerNumber(BoxPoolDTO boxPoolDTO, Query query) {
-		return R.data(putBoxService.listContainerNumber(boxPoolDTO,Condition.getPage(query)));
+		return R.data(putBoxService.listContainerNumber(boxPoolDTO, Condition.getPage(query)));
 	}
 
 	/**
@@ -91,7 +85,7 @@ public class BoxPoolController extends BladeController {
 	}
 
 	/**
-	 * 导入 空箱出场
+	 * 导入 POL空箱出场
 	 */
 	@PostMapping("/emptyContainerAppearance")
 	@RepeatSubmit
@@ -99,5 +93,14 @@ public class BoxPoolController extends BladeController {
 		return putBoxService.emptyContainerAppearance(file);
 	}
 
+	/**
+	 * 导入 POD返场
+	 */
+	@PostMapping("/giveAnEncore")
+	@RepeatSubmit
+	public R giveAnEncore(@RequestParam("file") MultipartFile file) throws IOException {
+		return putBoxService.giveAnEncore(file);
+	}
+
 
 }

+ 10 - 3
blade-service/blade-los/src/main/java/org/springblade/los/box/controller/PutBoxController.java

@@ -37,6 +37,7 @@ import org.springblade.los.box.service.IPutBoxService;
 import org.springframework.web.bind.annotation.*;
 
 import javax.validation.Valid;
+import java.text.SimpleDateFormat;
 import java.util.ArrayList;
 import java.util.List;
 
@@ -90,10 +91,13 @@ public class PutBoxController extends BladeController {
 			.like(ObjectUtils.isNotNull(putBox.getPodStationCname()), PutBox::getPodStationCname, putBox.getPodStationCname())
 			.eq(ObjectUtils.isNotNull(putBox.getPolStationId()), PutBox::getPolStationId, putBox.getPolStationId())
 			.like(ObjectUtils.isNotNull(putBox.getPolStationCname()), PutBox::getPolStationCname, putBox.getPolStationCname())
-			.ge(ObjectUtils.isNotNull(putBox.getEffectiveStartDate()), PutBox::getEffectiveStartDate, putBox.getEffectiveStartDate())
-			.le(ObjectUtils.isNotNull(putBox.getEffectiveEndDate()), PutBox::getEffectiveEndDate, putBox.getEffectiveEndDate())
 			.orderByDesc(PutBox::getCreateTime)
 		;
+		if (ObjectUtils.isNotNull(putBox.getEffectiveStartDate()) && ObjectUtils.isNotNull(putBox.getEffectiveEndDate())) {
+			SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
+			lambdaQueryWrapper.apply(ObjectUtils.isNotNull(putBox.getEffectiveStartDate()), "DATE_FORMAT(effective_start_date,'%Y-%m-%d') >= '" + formatter.format(putBox.getEffectiveStartDate()) + "'")
+				.apply(ObjectUtils.isNotNull(putBox.getEffectiveEndDate()), "DATE_FORMAT(effective_end_date,'%Y-%m-%d') <= '" + formatter.format(putBox.getEffectiveEndDate()) + "'");
+		}
 		IPage<PutBox> pages = putBoxService.page(Condition.getPage(query), lambdaQueryWrapper);
 		return R.data(pages);
 	}
@@ -145,7 +149,10 @@ public class PutBoxController extends BladeController {
 			.eq(PutBox::getTenantId, AuthUtil.getTenantId())
 			.eq(PutBox::getIsDeleted, 0)
 			.eq(PutBox::getContainerNumber, putBox.getContainerNumber())
-			.eq(PutBox::getBusType, putBox.getBusType()));
+			.eq(PutBox::getBusType, putBox.getBusType())
+			.like(ObjectUtils.isNotNull(putBox.getPodId()), PutBox::getPodId, putBox.getPodId())
+			.like(ObjectUtils.isNotNull(putBox.getPolId()), PutBox::getPolId, putBox.getPolId())
+		);
 		if (detail == null) {
 			return R.data(new ArrayList<>());
 		} else {

+ 21 - 0
blade-service/blade-los/src/main/java/org/springblade/los/box/controller/TradingBoxController.java

@@ -90,6 +90,7 @@ public class TradingBoxController extends BladeController {
 			.like(ObjectUtils.isNotNull(tradingBox.getSysNo()), TradingBox::getSysNo, tradingBox.getSysNo())
 			.like(ObjectUtils.isNotNull(tradingBox.getContractNo()), TradingBox::getContractNo, tradingBox.getContractNo())
 			.eq(ObjectUtils.isNotNull(tradingBox.getPurchaseCompanyId()), TradingBox::getPurchaseCompanyId, tradingBox.getPurchaseCompanyId())
+			.like(ObjectUtils.isNotNull(tradingBox.getPurchaseCompanyName()), TradingBox::getPurchaseCompanyName, tradingBox.getPurchaseCompanyName())
 			.eq(ObjectUtils.isNotNull(tradingBox.getStatus()), TradingBox::getStatus, tradingBox.getStatus())
 			.like(ObjectUtils.isNotNull(tradingBox.getCode()), TradingBox::getCode, tradingBox.getCode())
 			.like(ObjectUtils.isNotNull(tradingBox.getContainerNumber()), TradingBox::getContainerNumber, tradingBox.getContainerNumber())
@@ -105,6 +106,7 @@ public class TradingBoxController extends BladeController {
 			.like(ObjectUtils.isNotNull(tradingBox.getBoxTypeQuantityOne()), TradingBox::getBoxTypeQuantityOne, tradingBox.getBoxTypeQuantityOne())
 			.like(ObjectUtils.isNotNull(tradingBox.getBoxTypeQuantityTwo()), TradingBox::getBoxTypeQuantityTwo, tradingBox.getBoxTypeQuantityTwo())
 			.eq(ObjectUtils.isNotNull(tradingBox.getBoxClass()), TradingBox::getBoxClass, tradingBox.getBoxClass())
+			.eq(ObjectUtils.isNotNull(tradingBox.getBuxStaus()), TradingBox::getBuxStaus, tradingBox.getBuxStaus())
 		;
 		if (ObjectUtils.isNotNull(tradingBox.getEffectiveDate()) && ObjectUtils.isNotNull(tradingBox.getExpiryDate())){
 			SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
@@ -288,4 +290,23 @@ public class TradingBoxController extends BladeController {
 		return R.data(tradingBoxService.revokeRentCalculation(tradingBox));
 	}
 
+
+	/**
+	 * 箱管费用,调箱确认
+	 */
+	@PostMapping("/confirm")
+	@RepeatSubmit
+	public R confirm(@Valid @RequestBody TradingBox tradingBox) {
+		return R.data(tradingBoxService.confirm(tradingBox));
+	}
+
+	/**
+	 * 箱管费用,调箱撤销
+	 */
+	@PostMapping("/revoke")
+	@RepeatSubmit
+	public R revoke(@Valid @RequestBody TradingBox tradingBox) {
+		return R.data(tradingBoxService.revoke(tradingBox));
+	}
+
 }

+ 4 - 4
blade-service/blade-los/src/main/java/org/springblade/los/box/controller/TradingBoxItemController.java

@@ -145,10 +145,10 @@ public class TradingBoxItemController extends BladeController {
 					} else if ("DL".equals(tradingBox.getType())) {
 						item.setBoxSource("代理");
 						item.setStatus("待使用");
-					} else if ("OWN".equals(tradingBox.getType())) {
+					} else if ("OW-N".equals(tradingBox.getType())) {
 						item.setBoxSource("OW拿");
 						item.setStatus("待使用");
-					} else if ("OWF".equals(tradingBox.getType())) {
+					} else if ("OW-F".equals(tradingBox.getType())) {
 						item.setBoxSource("OW放");
 						item.setStatus("待使用");
 					} else {
@@ -210,10 +210,10 @@ public class TradingBoxItemController extends BladeController {
 						} else if ("DL".equals(tradingBox.getType())) {
 							item.setBoxSource("代理");
 							item.setStatus("待使用");
-						} else if ("OWN".equals(tradingBox.getType())) {
+						} else if ("OW-N".equals(tradingBox.getType())) {
 							item.setBoxSource("OW拿");
 							item.setStatus("待使用");
-						} else if ("OWF".equals(tradingBox.getType())) {
+						} else if ("OW-F".equals(tradingBox.getType())) {
 							item.setBoxSource("OW放");
 							item.setStatus("待使用");
 						} else {

+ 27 - 3
blade-service/blade-los/src/main/java/org/springblade/los/box/mapper/PutBoxMapper.xml

@@ -57,7 +57,10 @@
         pod_station_id as podStationId,
         pod_station_cname as podStationName,
         pod_station_cname as podStationName,
-        box_type as boxType
+        box_type as boxType,
+        remaining_num as remainingNum,
+        total_num as totalNum,
+        occupy_num as occupyNum
         FROM
         logistics_put_box
         WHERE
@@ -72,9 +75,18 @@
         <if test="data.podId!=null and data.podId != ''">
             and pod_id like concat(concat('%', #{data.podId}),'%')
         </if>
+        <if test="data.polName!=null and data.polName != ''">
+            and pol_cname like concat(concat('%', #{data.polName}),'%')
+        </if>
+        <if test="data.podName!=null and data.podName != ''">
+            and pod_cname like concat(concat('%', #{data.podName}),'%')
+        </if>
         <if test="data.boxEastId!=null and data.boxEastId != ''">
             and box_east_id like concat(concat('%', #{data.boxEastId}),'%')
         </if>
+        <if test="data.boxEastName!=null and data.boxEastName != ''">
+            and box_east_name like concat(concat('%', #{data.boxEastName}),'%')
+        </if>
         <if test="data.busType!=null and data.busType != ''">
             and  find_in_set(bus_type,#{data.busType})
         </if>
@@ -91,7 +103,9 @@
         lp.id as portId,
         lp.cn_name as portName,
         lpb.pol_station_cname as stationName,
-        lpb.bus_type as busType
+        lpb.bus_type as busType,
+        lpb.box_type as boxType,
+        lpb.remaining_num as remainingNum
         FROM
         logistics_put_box lpb
         LEFT JOIN los_b_ports lp ON FIND_IN_SET( lp.id, lpb.pol_id )
@@ -109,11 +123,20 @@
         <if test="data.podId!=null and data.podId != ''">
             and lpb.pod_id like concat(concat('%', #{data.podId}),'%')
         </if>
+        <if test="data.polName!=null and data.polName != ''">
+            and lpb.pol_cname like concat(concat('%', #{data.polName}),'%')
+        </if>
+        <if test="data.podName!=null and data.podName != ''">
+            and lpb.pod_cname like concat(concat('%', #{data.podName}),'%')
+        </if>
         <if test="data.boxEastId!=null and data.boxEastId != ''">
             and lpb.box_east_id like concat(concat('%', #{data.boxEastId}),'%')
         </if>
+        <if test="data.boxEastName!=null and data.boxEastName != ''">
+            and lpb.box_east_name like concat(concat('%', #{data.boxEastName}),'%')
+        </if>
         <if test="data.busType!=null and data.busType != ''">
-            and lpb.bus_type = #{data.busType}
+            and find_in_set(lpb.bus_type,#{data.busType})
         </if>
         <if test="data.boxType!=null and data.boxType != ''">
             and lpb.box_type = #{data.boxType}
@@ -247,6 +270,7 @@
             lpb.pod_cname as destinationCname,
             lpb.box_type as boxType,
             lpb.bus_type as busType,
+            lpb.remaining_num as remainingNum,
             count(lpbi.id) as sum
         FROM
             logistics_put_box lpb

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

@@ -68,4 +68,6 @@ public interface IPutBoxService extends IService<PutBox> {
 	R emptyContainerAppearance(MultipartFile file) throws IOException;
 
 	List<RouteCostProfitExcel> getBoxNumber(RouteCostProfitExcel routeCost);
+
+	R giveAnEncore(MultipartFile file)throws IOException;
 }

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

@@ -54,4 +54,8 @@ public interface ITradingBoxService extends IService<TradingBox> {
 	List<ExportTradingBoxItemOut> exportTradingBoxItemOut(TradingBox tradingBox);
 
 	R enable(TradingBox tradingBox);
+
+	TradingBox confirm(TradingBox tradingBox);
+
+	TradingBox revoke(TradingBox tradingBox);
 }

+ 554 - 106
blade-service/blade-los/src/main/java/org/springblade/los/box/service/impl/PutBoxServiceImpl.java

@@ -31,7 +31,8 @@ import org.springblade.los.basic.business.entity.BusinessType;
 import org.springblade.los.basic.business.service.IBusinessTypeService;
 import org.springblade.los.basic.cntr.entity.BCntrTypes;
 import org.springblade.los.basic.cntr.service.IBCntrTypesService;
-import org.springblade.los.basic.locations.entity.BLocations;
+import org.springblade.los.basic.corps.entity.BCorps;
+import org.springblade.los.basic.corps.service.IBCorpsService;
 import org.springblade.los.basic.locations.service.IBLocationsService;
 import org.springblade.los.basic.ports.entity.BPorts;
 import org.springblade.los.basic.ports.service.IBPortsService;
@@ -46,10 +47,7 @@ import org.springblade.los.box.excel.EmptyContainerAppearance;
 import org.springblade.los.box.mapper.ArchivesTrajectoryMapper;
 import org.springblade.los.box.mapper.PutBoxMapper;
 import org.springblade.los.box.mapper.TradingBoxMapper;
-import org.springblade.los.box.service.IArchivesFilesService;
-import org.springblade.los.box.service.IPutBoxItemsService;
-import org.springblade.los.box.service.IPutBoxService;
-import org.springblade.los.box.service.ITradingBoxItemService;
+import org.springblade.los.box.service.*;
 import org.springblade.los.box.vo.PutBoxVO;
 import org.springblade.los.excel.RouteCostProfitExcel;
 import org.springblade.resource.feign.IOssClient;
@@ -98,6 +96,10 @@ public class PutBoxServiceImpl extends ServiceImpl<PutBoxMapper, PutBox> impleme
 
 	private final IOssClient ossClient;
 
+	private final IArchivesService archivesService;
+
+	private final IBCorpsService bCorpsService;
+
 	@Override
 	public IPage<PutBoxVO> selectPutBoxPage(IPage<PutBoxVO> page, PutBoxVO putBox) {
 		return null;
@@ -130,18 +132,15 @@ public class PutBoxServiceImpl extends ServiceImpl<PutBoxMapper, PutBox> impleme
 		}
 		String businessTypeCode = "FXH";
 		String billNoFormat;
-		String billNoFormatInternal;
-		if ("自有".equals(putBox.getBoxClass())) {
-			billNoFormat = "FXH";
-			billNoFormatInternal = "FXH-N";
-		} else if ("代理".equals(putBox.getBoxClass())) {
+		String billNoFormatInternal = "FXH-N";
+		if ("自有箱".equals(putBox.getBoxClass())) {
+			billNoFormat = "FXH-ZY";
+		} else if ("代理箱".equals(putBox.getBoxClass())) {
 			billNoFormat = "FXH-DL";
-			billNoFormatInternal = "FXHN-DL";
-		} else if ("OW".equals(putBox.getBoxClass())) {
+		} else if ("OW(拿),OW(放)".contains(putBox.getBoxClass())) {
 			billNoFormat = "FXH-OW";
-			billNoFormatInternal = "FXHN-OW";
 		} else {
-			billNoFormat = "FXH";
+			billNoFormat = "FXH-ZY";
 			billNoFormatInternal = "FXH-N";
 		}
 		BusinessType businessType = bBusinessTypeService.getOne(new LambdaQueryWrapper<BusinessType>()
@@ -220,7 +219,7 @@ public class PutBoxServiceImpl extends ServiceImpl<PutBoxMapper, PutBox> impleme
 				item.setBoxBelongsTo(putBox.getBoxBelongsTo());
 				item.setBoxCondition(putBox.getBoxCondition());
 				item.setBoxClass(putBox.getBoxClass());
-				if ("OW".equals(putBox.getBusType()) && ObjectUtils.isNotNull(putBox.getBoxEastId())
+				if ("OW(拿),OW(放)".contains(putBox.getBusType()) && ObjectUtils.isNotNull(putBox.getBoxEastId())
 					&& !"null".equals(putBox.getBoxEastId()) && ObjectUtils.isNull(item.getBoxEastId())) {
 					item.setBoxEastId(Long.parseLong(putBox.getBoxEastId()));
 					item.setBoxEastName(putBox.getBoxEastName());
@@ -276,19 +275,31 @@ public class PutBoxServiceImpl extends ServiceImpl<PutBoxMapper, PutBox> impleme
 		putBoxItemsService.updateBatchById(putBoxItemsList);
 		if (!putBoxItems.isEmpty()) {
 			putBoxItems.addAll(putBoxItemsList);
-			StringBuilder boxEastId = new StringBuilder();
+			String boxEastId = "";
 			for (PutBoxItems item : putBoxItems) {
-				boxEastId.append(item.getBoxEastId()).append(",");
+				if (ObjectUtils.isNull(boxEastId)) {
+					boxEastId = item.getBoxEastId() + ",";
+				} else {
+					if (!boxEastId.contains(item.getBoxEastId() + "")) {
+						boxEastId = boxEastId + item.getBoxEastId() + ",";
+					}
+				}
 			}
-			String boxEastName = putBoxItems.stream().map(PutBoxItems::getBoxEastName).collect(Collectors.joining(","));
+			String boxEastName = putBoxItems.stream().map(PutBoxItems::getBoxEastName).distinct().collect(Collectors.joining(","));
 			detail.setBoxEastId(boxEastId.substring(0, boxEastId.length() - 1));
 			detail.setBoxEastName(boxEastName);
 		} else {
-			StringBuilder boxEastId = new StringBuilder();
+			String boxEastId = "";
 			for (PutBoxItems item : putBoxItemsList) {
-				boxEastId.append(item.getBoxEastId()).append(",");
+				if (ObjectUtils.isNull(boxEastId)) {
+					boxEastId = item.getBoxEastId() + ",";
+				} else {
+					if (!boxEastId.contains(item.getBoxEastId() + "")) {
+						boxEastId = boxEastId + item.getBoxEastId() + ",";
+					}
+				}
 			}
-			String boxEastName = putBoxItemsList.stream().map(PutBoxItems::getBoxEastName).collect(Collectors.joining(","));
+			String boxEastName = putBoxItemsList.stream().map(PutBoxItems::getBoxEastName).distinct().collect(Collectors.joining(","));
 			detail.setBoxEastId(boxEastId.substring(0, boxEastId.length() - 1));
 			detail.setBoxEastName(boxEastName);
 		}
@@ -315,16 +326,7 @@ public class PutBoxServiceImpl extends ServiceImpl<PutBoxMapper, PutBox> impleme
 		detail.setCreateTime(new Date());
 		detail.setContainerNumber(putBox.getContainerNumber());
 		String businessTypeCode = "FXH";
-		String billNoFormatInternal;
-		if ("自有".equals(putBox.getBoxClass())) {
-			billNoFormatInternal = "FXH-N";
-		} else if ("代理".equals(putBox.getBoxClass())) {
-			billNoFormatInternal = "FXHN-DL";
-		} else if ("OW".equals(putBox.getBoxClass())) {
-			billNoFormatInternal = "FXHN-OW";
-		} else {
-			billNoFormatInternal = "FXH-N";
-		}
+		String billNoFormatInternal = "FXH-N";
 		BusinessType businessType = bBusinessTypeService.getOne(new LambdaQueryWrapper<BusinessType>()
 			.select(BusinessType::getId)
 			.eq(BusinessType::getTenantId, AuthUtil.getTenantId())
@@ -371,16 +373,28 @@ public class PutBoxServiceImpl extends ServiceImpl<PutBoxMapper, PutBox> impleme
 				long gP40Bad = 0;
 				long hG40Bad = 0;
 				long otherBad = 0;
-				for (Map<String, Long> map : mapList) {
-					if (!mapList.isEmpty()) {
-						gP20Good = gP20Good + map.get("gP20Good");
-						gP40Good = gP40Good + map.get("gP40Good");
-						hG40Good = hG40Good + map.get("hG40Good");
-						otherGood = otherGood + map.get("otherGood");
-						gP20Bad = gP20Bad + map.get("gP20Bad");
-						gP40Bad = gP40Bad + map.get("gP40Bad");
-						hG40Bad = hG40Bad + map.get("hG40Bad");
-						otherBad = otherBad + map.get("otherBad");
+				if ("OW(拿),OW(放)".contains(item.getBusType())) {
+					if ("20GP".equals(item.getBoxType())) {
+						gP20Good = gP20Good + item.getRemainingNum();
+					} else if ("40GP".equals(item.getBoxType())) {
+						gP40Good = gP40Good + item.getRemainingNum();
+					} else if ("40HG".equals(item.getBoxType())) {
+						hG40Good = hG40Good + item.getRemainingNum();
+					} else {
+						otherGood = otherGood + item.getRemainingNum();
+					}
+				} else {
+					for (Map<String, Long> map : mapList) {
+						if (!map.isEmpty()) {
+							gP20Good = gP20Good + map.get("gP20Good");
+							gP40Good = gP40Good + map.get("gP40Good");
+							hG40Good = hG40Good + map.get("hG40Good");
+							otherGood = otherGood + map.get("otherGood");
+							gP20Bad = gP20Bad + map.get("gP20Bad");
+							gP40Bad = gP40Bad + map.get("gP40Bad");
+							hG40Bad = hG40Bad + map.get("hG40Bad");
+							otherBad = otherBad + map.get("otherBad");
+						}
 					}
 				}
 				item.setGP20Good(gP20Good);
@@ -408,8 +422,11 @@ public class PutBoxServiceImpl extends ServiceImpl<PutBoxMapper, PutBox> impleme
 			.apply(ObjectUtils.isNotNull(boxPoolDTO.getBusType()), "find_in_set(bus_type,'" + boxPoolDTO.getBusType() + "')")
 			.like(ObjectUtils.isNotNull(boxPoolDTO.getContainerNumber()), PutBox::getContainerNumber, boxPoolDTO.getContainerNumber())
 			.like(ObjectUtils.isNotNull(boxPoolDTO.getPodId()), PutBox::getPodId, boxPoolDTO.getPodId())
+			.like(ObjectUtils.isNotNull(boxPoolDTO.getPodName()), PutBox::getPodCname, boxPoolDTO.getPodName())
 			.like(ObjectUtils.isNotNull(boxPoolDTO.getPolId()), PutBox::getPolId, boxPoolDTO.getPolId())
+			.like(ObjectUtils.isNotNull(boxPoolDTO.getPolName()), PutBox::getPolCname, boxPoolDTO.getPolName())
 			.like(ObjectUtils.isNotNull(boxPoolDTO.getBoxEastId()), PutBox::getBoxEastId, boxPoolDTO.getBoxEastId())
+			.like(ObjectUtils.isNotNull(boxPoolDTO.getBoxEastName()), PutBox::getBoxEastName, boxPoolDTO.getBoxEastName())
 			.like(ObjectUtils.isNotNull(boxPoolDTO.getStationId()), PutBox::getPolStationId, boxPoolDTO.getStationId());
 		if (ObjectUtils.isNotNull(boxPoolDTO.getWhetherLoseEfficacy())) {
 			lambdaQueryWrapper.ge(PutBox::getEffectiveStartDate, new Date())
@@ -423,13 +440,21 @@ public class PutBoxServiceImpl extends ServiceImpl<PutBoxMapper, PutBox> impleme
 				.eq(PutBoxItems::getIsDeleted, 0)
 				.in(PutBoxItems::getPid, ids));
 			for (BoxPoolContainerNumberDTO item : putBoxList) {
-				if (!boxItemsList.isEmpty()) {
-					List<PutBoxItems> itemsList = boxItemsList.stream().filter(e -> e.getPid().equals(item.getId())).collect(Collectors.toList());
-					if (!itemsList.isEmpty()) {
-						item.setGood(itemsList.stream().filter(e -> "好".equals(e.getBoxStatus()) && item.getBoxType().equals(e.getBoxType())).count());
-						item.setBad(itemsList.stream().filter(e -> "坏".equals(e.getBoxStatus()) && item.getBoxType().equals(e.getBoxType())).count());
-						item.setTotal(item.getGood() + item.getBad());
-						item.setRemainingTotal(item.getTotal());
+				if ("OW(拿),OW(放)".contains(item.getBusType())){
+					item.setGood(item.getRemainingNum());
+					item.setTotal(item.getRemainingNum());
+					item.setOccupyNum(item.getOccupyNum());
+					item.setRemainingTotal(item.getTotalNum());
+				}else{
+					if (!boxItemsList.isEmpty()) {
+						List<PutBoxItems> itemsList = boxItemsList.stream().filter(e -> e.getPid().equals(item.getId())).collect(Collectors.toList());
+						if (!itemsList.isEmpty()) {
+							item.setGood(itemsList.stream().filter(e -> "好".equals(e.getBoxStatus()) && item.getBoxType().equals(e.getBoxType())).count());
+							item.setBad(itemsList.stream().filter(e -> "坏".equals(e.getBoxStatus()) && item.getBoxType().equals(e.getBoxType())).count());
+							item.setTotal(item.getGood() + item.getBad());
+							item.setOccupyNum(item.getOccupyNum());
+							item.setRemainingTotal(item.getTotal());
+						}
 					}
 				}
 			}
@@ -501,6 +526,13 @@ public class PutBoxServiceImpl extends ServiceImpl<PutBoxMapper, PutBox> impleme
 		if (CollectionUtils.isEmpty(excelList)) {
 			throw new SecurityException("数据不能为空");
 		}
+		List<String> boxCodeList = excelList.stream().map(EmptyContainerAppearance::getBoxCode)
+			.distinct().collect(Collectors.toList());
+		//箱档案数据
+		List<Archives> archivesList = archivesService.list(new LambdaQueryWrapper<Archives>()
+			.eq(Archives::getTenantId, AuthUtil.getTenantId())
+			.eq(Archives::getIsDeleted, 0)
+			.in(Archives::getCode, boxCodeList));
 		List<String> containerNumberList = excelList.stream().map(EmptyContainerAppearance::getContainerNumber)
 			.distinct().collect(Collectors.toList());
 		List<String> boxType = excelList.stream().map(EmptyContainerAppearance::getBoxType).filter(Objects::nonNull)
@@ -517,10 +549,10 @@ public class PutBoxServiceImpl extends ServiceImpl<PutBoxMapper, PutBox> impleme
 			.in(BPorts::getCnName, portName));
 		List<String> stationName = excelList.stream().map(EmptyContainerAppearance::getStationName).filter(Objects::nonNull)
 			.distinct().collect(Collectors.toList());
-		List<BLocations> locationsList = bLocationsService.list(new LambdaQueryWrapper<BLocations>()
-			.eq(BLocations::getTenantId, AuthUtil.getTenantId())
-			.eq(BLocations::getIsDeleted, 0)
-			.in(BLocations::getCnName, stationName));
+		List<BCorps> corpsList = bCorpsService.list(new LambdaQueryWrapper<BCorps>()
+			.eq(BCorps::getTenantId, AuthUtil.getTenantId())
+			.eq(BCorps::getIsDeleted, 0)
+			.in(BCorps::getCnName, stationName));
 		List<PutBox> putBoxList = baseMapper.selectList(new LambdaQueryWrapper<PutBox>()
 			.eq(PutBox::getTenantId, AuthUtil.getTenantId())
 			.eq(PutBox::getIsDeleted, 0)
@@ -533,25 +565,22 @@ public class PutBoxServiceImpl extends ServiceImpl<PutBoxMapper, PutBox> impleme
 			.eq(PutBoxItems::getIsDeleted, 0)
 			.eq(PutBoxItems::getTenantId, AuthUtil.getTenantId())
 			.in(PutBoxItems::getPid, putBoxIdList));
-		List<String> boxCodeList = excelList.stream().map(EmptyContainerAppearance::getBoxCode)
-			.distinct().collect(Collectors.toList());
+
 		String blacklist = sysClient.getParamService("box.blacklist");
 		if (ObjectUtils.isNotNull(blacklist)) {
 			StringBuilder text = new StringBuilder();
 			for (String item : boxCodeList) {
-				String head = item.substring(0, 3);
-				if (blacklist.contains(head)) {
-					text.append(item).append(",");
+				if (item.length() > 3) {
+					String head = item.substring(0, 3);
+					if (blacklist.contains(head)) {
+						text.append(item).append(",");
+					}
 				}
 			}
 			if (ObjectUtils.isNotNull(text.toString())) {
 				throw new RuntimeException("箱号:" + text + "为黑名单箱,请修改数据后再操作");
 			}
 		}
-		List<PutBoxItems> putBoxItemsCodeList = putBoxItemsService.list(new LambdaQueryWrapper<PutBoxItems>()
-			.eq(PutBoxItems::getIsDeleted, 0)
-			.eq(PutBoxItems::getTenantId, AuthUtil.getTenantId())
-			.in(PutBoxItems::getBoxCode, boxCodeList));
 		List<TradingBox> tradingBoxList = tradingBoxMapper.selectList(new LambdaQueryWrapper<TradingBox>()
 			.eq(TradingBox::getTenantId, AuthUtil.getTenantId())
 			.eq(TradingBox::getIsDeleted, 0)
@@ -566,19 +595,74 @@ public class PutBoxServiceImpl extends ServiceImpl<PutBoxMapper, PutBox> impleme
 			.in(TradingBoxItem::getPid, tradingBoxIdList));
 		List<PutBoxItems> putBoxItems = new ArrayList<>();
 		List<TradingBoxItem> tradingBoxItems = new ArrayList<>();
+		List<Archives> archivesArrayList = new ArrayList<>();
+		List<PutBox> putBoxes = new ArrayList<>();
 		for (EmptyContainerAppearance item : excelList) {
 			BCntrTypes cntrTypes = cntrTypesList.stream().filter(e -> e.getCnName().equals(item.getBoxType())).findFirst().orElse(null);
+			if (cntrTypes == null) {
+				throw new RemoteException("请先维护箱型:" + item.getBoxType() + "基础资料");
+			}
 			BPorts ports = portsList.stream().filter(e -> e.getCnName().equals(item.getPortName())).findFirst().orElse(null);
-			BLocations locations = locationsList.stream().filter(e -> e.getCnName().equals(item.getStationName())).findFirst().orElse(null);
-			PutBox putBox = putBoxList.stream().filter(e -> e.getContainerNumber().equals(item.getContainerNumber())).findFirst().orElse(null);
+			if (ports == null) {
+				throw new RemoteException("请先维护港口:" + item.getPortName() + "基础资料");
+			}
+			BCorps corps = corpsList.stream().filter(e -> e.getCnName().equals(item.getStationName())).findFirst().orElse(null);
+			if (corps == null) {
+				throw new RemoteException("请先维护场站:" + item.getStationName() + "基础资料");
+			}
+			PutBox putBox = putBoxList.stream().filter(e -> e.getContainerNumber().equals(item.getContainerNumber())
+				&& e.getPolId().equals(ports.getId()) && e.getPolStationId().equals(corps.getId())).findFirst().orElse(null);
 			if (putBox != null) {
+				long count = excelList.stream().filter(e -> e.getContainerNumber().equals(putBox.getContainerNumber())).count();
+				putBox.setOccupyNum(putBox.getOccupyNum() + Integer.parseInt(count + ""));
+				putBox.setRemainingNum(putBox.getTotalNum() - putBox.getOccupyNum());
+				putBoxes.add(putBox);
+				//箱档案数据处理
+				Archives archives = archivesList.stream().filter(e -> e.getCode().equals(item.getBoxCode())).findFirst().orElse(null);
+				if (archives != null) {
+					archives.setUpdateTime(new Date());
+					archives.setUpdateUser(AuthUtil.getUserId());
+					archives.setUpdateUserName(AuthUtil.getUserName());
+					archives.setStatus("使用中");
+					archives.setNewDate(item.getBoxStatusDate());
+					archives.setBoxAccessStatus("空箱出场");
+					archives.setAddressId(ports.getId());
+					archives.setAddressCode(ports.getCode());
+					archives.setAddressCname(ports.getCnName());
+					archives.setAddressEname(ports.getEnName());
+					archives.setStationId(corps.getId());
+					archives.setStationCode(corps.getCode());
+					archives.setStationCname(corps.getCnName());
+					archives.setStationEname(corps.getEnName());
+				} else {
+					archives = new Archives();
+					archives.setCode(item.getBoxCode());
+					archives.setCreateTime(new Date());
+					archives.setCreateUser(AuthUtil.getUserId());
+					archives.setCreateUserName(AuthUtil.getUserName());
+					archives.setStatus("使用中");
+					archives.setNewDate(item.getBoxStatusDate());
+					archives.setBoxAccessStatus("空箱出场");
+					archives.setBoxBelongsTo("SOC");
+					archives.setContainerNumber(item.getContainerNumber());
+					archives.setContainerNumberType(putBox.getBusType());
+					archives.setTypeId(cntrTypes.getId());
+					archives.setTypeName(cntrTypes.getCnName());
+					archives.setBoxType(putBox.getBusType());
+					archives.setAddressId(ports.getId());
+					archives.setAddressCode(ports.getCode());
+					archives.setAddressCname(ports.getCnName());
+					archives.setAddressEname(ports.getEnName());
+					archives.setStationId(corps.getId());
+					archives.setStationCode(corps.getCode());
+					archives.setStationCname(corps.getCnName());
+					archives.setStationEname(corps.getEnName());
+				}
+				archivesArrayList.add(archives);
 				if (ObjectUtils.isNotNull(putBox.getBoxType()) && !putBox.getBoxType().equals(item.getBoxType())) {
 					throw new RemoteException("放箱号:" + item.getContainerNumber() + "箱型不符合");
 				}
-				if (!putBoxItemsCodeList.isEmpty() && putBoxItemsCodeList.stream()
-					.anyMatch(e -> !e.getPid().equals(putBox.getId()) && item.getBoxCode().equals(e.getBoxCode()))) {
-					throw new RuntimeException("箱号:" + item.getBoxCode() + "已在其他放箱号中存在,请修改后再操作");
-				}
+				//放箱号明细数据处理
 				PutBoxItems putBoxItem;
 				if (!putBoxItemsList.isEmpty()) {
 					putBoxItem = putBoxItemsList.stream().filter(e -> e.getBoxCode().equals(item.getBoxCode()))
@@ -587,6 +671,11 @@ public class PutBoxServiceImpl extends ServiceImpl<PutBoxMapper, PutBox> impleme
 						putBoxItem.setPid(putBox.getId());
 						putBoxItem.setMblno(item.getMblno());
 						putBoxItem.setBoxDynamics(item.getBoxStatus());
+						putBoxItem.setPolCyId(corps.getId());
+						putBoxItem.setPolCyCode(corps.getCode());
+						putBoxItem.setPolCyCname(corps.getCnName());
+						putBoxItem.setPolCyEname(corps.getEnName());
+						putBoxItem.setPolStationEmptyContainerExitDate(item.getBoxStatusDate());
 					} else {
 						putBoxItem = new PutBoxItems();
 						putBoxItem.setBoxClass(putBox.getBusType());
@@ -599,6 +688,11 @@ public class PutBoxServiceImpl extends ServiceImpl<PutBoxMapper, PutBox> impleme
 						putBoxItem.setBoxType(item.getBoxType());
 						putBoxItem.setMblno(item.getMblno());
 						putBoxItem.setBoxDynamics(item.getBoxStatus());
+						putBoxItem.setPolCyId(corps.getId());
+						putBoxItem.setPolCyCode(corps.getCode());
+						putBoxItem.setPolCyCname(corps.getCnName());
+						putBoxItem.setPolCyEname(corps.getEnName());
+						putBoxItem.setPolStationEmptyContainerExitDate(item.getBoxStatusDate());
 					}
 				} else {
 					putBoxItem = new PutBoxItems();
@@ -612,13 +706,23 @@ public class PutBoxServiceImpl extends ServiceImpl<PutBoxMapper, PutBox> impleme
 					putBoxItem.setBoxType(item.getBoxType());
 					putBoxItem.setMblno(item.getMblno());
 					putBoxItem.setBoxDynamics(item.getBoxStatus());
+					putBoxItem.setPolCyId(corps.getId());
+					putBoxItem.setPolCyCode(corps.getCode());
+					putBoxItem.setPolCyCname(corps.getCnName());
+					putBoxItem.setPolCyEname(corps.getEnName());
+					putBoxItem.setPolStationEmptyContainerExitDate(item.getBoxStatusDate());
 				}
-				if ("OW,OW-F".contains(putBox.getBusType())) {
+				if ("OW(拿),OW(放)".contains(putBox.getBusType())) {
 					putBoxItem.setBoxEastId(Long.parseLong(putBox.getBoxEastId()));
 					putBoxItem.setBoxEastName(putBox.getBoxEastName());
-					TradingBox tradingBox = tradingBoxList.stream().filter(e -> e.getContainerNumber().equals(item.getContainerNumber()))
+					TradingBox tradingBox = tradingBoxList.stream().filter(e -> e.getContainerNumber().equals(item.getContainerNumber())
+							&& e.getPolId().equals(ports.getId()) && e.getPolStationId().equals(corps.getId()))
 						.findFirst().orElse(null);
 					if (tradingBox != null) {
+						long count1 = excelList.stream().filter(e -> e.getContainerNumber().equals(putBox.getContainerNumber())).count();
+						tradingBox.setActualBoxNumber(tradingBox.getActualBoxNumber() + Integer.parseInt(count1 + ""));
+						tradingBox.setRemainingBoxNumber(tradingBox.getBoxNumber() - tradingBox.getActualBoxNumber());
+						tradingBoxMapper.updateById(tradingBox);
 						TradingBoxItem tradingBoxItem;
 						if (!tradingBoxItemList.isEmpty()) {
 							tradingBoxItem = tradingBoxItemList.stream().filter(e -> e.getCode().equals(item.getBoxCode()))
@@ -627,13 +731,26 @@ public class PutBoxServiceImpl extends ServiceImpl<PutBoxMapper, PutBox> impleme
 								tradingBoxItem.setPid(tradingBox.getId());
 								tradingBoxItem.setMblno(item.getMblno());
 								tradingBoxItem.setBoxDynamics(item.getBoxStatus());
+								tradingBoxItem.setPortId(ports.getId());
+								tradingBoxItem.setPortCode(ports.getCode());
+								tradingBoxItem.setPortCname(ports.getCnName());
+								tradingBoxItem.setPortEname(ports.getEnName());
+								tradingBoxItem.setStationId(corps.getId());
+								tradingBoxItem.setStationCode(corps.getCode());
+								tradingBoxItem.setStationCname(corps.getCnName());
+								tradingBoxItem.setStationEname(corps.getEnName());
+								tradingBoxItem.setPolCyId(corps.getId());
+								tradingBoxItem.setPolCyCode(corps.getCode());
+								tradingBoxItem.setPolCyCname(corps.getCnName());
+								tradingBoxItem.setPolCyEname(corps.getEnName());
+								tradingBoxItem.setPolStationEmptyContainerExitDate(item.getBoxStatusDate());
 							} else {
 								tradingBoxItem = new TradingBoxItem();
 								tradingBoxItem.setBoxBelongsTo("SOC");
 								if ("OW-N".equals(tradingBox.getType())) {
-									tradingBoxItem.setBoxCategory("OW");
+									tradingBoxItem.setBoxCategory("OW(拿)");
 								} else if ("OW-F".equals(tradingBox.getType())) {
-									tradingBoxItem.setBoxCategory("OW-F");
+									tradingBoxItem.setBoxCategory("OW(放)");
 								}
 								putBoxItem.setBoxClass(putBox.getBusType());
 								tradingBoxItem.setBoxCondition("新");
@@ -643,29 +760,28 @@ public class PutBoxServiceImpl extends ServiceImpl<PutBoxMapper, PutBox> impleme
 								tradingBoxItem.setCode(item.getBoxCode());
 								tradingBoxItem.setMblno(item.getMblno());
 								tradingBoxItem.setBoxDynamics(item.getBoxStatus());
-								if (cntrTypes != null) {
-									tradingBoxItem.setBoxType(cntrTypes.getCnName());
-									tradingBoxItem.setBoxTypeId(cntrTypes.getId());
-								}
-								if (ports != null) {
-									tradingBoxItem.setPortId(ports.getId());
-									tradingBoxItem.setPortCode(ports.getCode());
-									tradingBoxItem.setPortCname(ports.getCnName());
-									tradingBoxItem.setPortEname(ports.getEnName());
-								}
-								if (locations != null) {
-									tradingBoxItem.setStationId(locations.getId());
-									tradingBoxItem.setStationCode(locations.getCode());
-									tradingBoxItem.setStationCname(locations.getCnName());
-									tradingBoxItem.setStationEname(locations.getEnName());
-								}
+								tradingBoxItem.setBoxType(cntrTypes.getCnName());
+								tradingBoxItem.setBoxTypeId(cntrTypes.getId());
+								tradingBoxItem.setPortId(ports.getId());
+								tradingBoxItem.setPortCode(ports.getCode());
+								tradingBoxItem.setPortCname(ports.getCnName());
+								tradingBoxItem.setPortEname(ports.getEnName());
+								tradingBoxItem.setStationId(corps.getId());
+								tradingBoxItem.setStationCode(corps.getCode());
+								tradingBoxItem.setStationCname(corps.getCnName());
+								tradingBoxItem.setStationEname(corps.getEnName());
+								tradingBoxItem.setPolCyId(corps.getId());
+								tradingBoxItem.setPolCyCode(corps.getCode());
+								tradingBoxItem.setPolCyCname(corps.getCnName());
+								tradingBoxItem.setPolCyEname(corps.getEnName());
+								tradingBoxItem.setPolStationEmptyContainerExitDate(item.getBoxStatusDate());
 							}
 						} else {
 							tradingBoxItem = new TradingBoxItem();
 							if ("OW-N".equals(tradingBox.getType())) {
-								tradingBoxItem.setBoxCategory("OW");
+								tradingBoxItem.setBoxCategory("OW(拿)");
 							} else if ("OW-F".equals(tradingBox.getType())) {
-								tradingBoxItem.setBoxCategory("OW-F");
+								tradingBoxItem.setBoxCategory("OW(放)");
 							}
 							tradingBoxItem.setBoxBelongsTo("SOC");
 							tradingBoxItem.setBoxCondition("新");
@@ -675,22 +791,21 @@ public class PutBoxServiceImpl extends ServiceImpl<PutBoxMapper, PutBox> impleme
 							tradingBoxItem.setCode(item.getBoxCode());
 							tradingBoxItem.setMblno(item.getMblno());
 							tradingBoxItem.setBoxDynamics(item.getBoxStatus());
-							if (cntrTypes != null) {
-								tradingBoxItem.setBoxType(cntrTypes.getCnName());
-								tradingBoxItem.setBoxTypeId(cntrTypes.getId());
-							}
-							if (ports != null) {
-								tradingBoxItem.setPortId(ports.getId());
-								tradingBoxItem.setPortCode(ports.getCode());
-								tradingBoxItem.setPortCname(ports.getCnName());
-								tradingBoxItem.setPortEname(ports.getEnName());
-							}
-							if (locations != null) {
-								tradingBoxItem.setStationId(locations.getId());
-								tradingBoxItem.setStationCode(locations.getCode());
-								tradingBoxItem.setStationCname(locations.getCnName());
-								tradingBoxItem.setStationEname(locations.getEnName());
-							}
+							tradingBoxItem.setBoxType(cntrTypes.getCnName());
+							tradingBoxItem.setBoxTypeId(cntrTypes.getId());
+							tradingBoxItem.setPortId(ports.getId());
+							tradingBoxItem.setPortCode(ports.getCode());
+							tradingBoxItem.setPortCname(ports.getCnName());
+							tradingBoxItem.setPortEname(ports.getEnName());
+							tradingBoxItem.setStationId(corps.getId());
+							tradingBoxItem.setStationCode(corps.getCode());
+							tradingBoxItem.setStationCname(corps.getCnName());
+							tradingBoxItem.setStationEname(corps.getEnName());
+							tradingBoxItem.setPolCyId(corps.getId());
+							tradingBoxItem.setPolCyCode(corps.getCode());
+							tradingBoxItem.setPolCyCname(corps.getCnName());
+							tradingBoxItem.setPolCyEname(corps.getEnName());
+							tradingBoxItem.setPolStationEmptyContainerExitDate(item.getBoxStatusDate());
 						}
 						tradingBoxItem.setBoxEastId(tradingBox.getPurchaseCompanyId());
 						tradingBoxItem.setBoxEastName(tradingBox.getPurchaseCompanyName());
@@ -704,8 +819,14 @@ public class PutBoxServiceImpl extends ServiceImpl<PutBoxMapper, PutBox> impleme
 				throw new RuntimeException("未查到放箱号:" + item.getContainerNumber() + "单据");
 			}
 		}
+		if (!putBoxes.isEmpty()) {
+			this.saveOrUpdateBatch(putBoxes);
+		}
 		if (!putBoxItems.isEmpty()) {
-			putBoxItemsService.saveOrUpdateBatch(putBoxItems);
+			putBoxItemsService.updateBatchById(putBoxItems);
+		}
+		if (!archivesArrayList.isEmpty()) {
+			archivesService.saveOrUpdateBatch(archivesArrayList);
 		}
 		if (!tradingBoxItems.isEmpty()) {
 			tradingBoxItemService.saveOrUpdateBatch(tradingBoxItems);
@@ -772,4 +893,331 @@ public class PutBoxServiceImpl extends ServiceImpl<PutBoxMapper, PutBox> impleme
 		return baseMapper.getBoxNumber(routeCost);
 	}
 
+	@Override
+	@Transactional(rollbackFor = Exception.class)
+	public R giveAnEncore(MultipartFile file) throws IOException {
+		//导入数据
+		List<EmptyContainerAppearance> excelList = ExcelUtil.read(file, EmptyContainerAppearance.class);
+		if (CollectionUtils.isEmpty(excelList)) {
+			throw new SecurityException("数据不能为空");
+		}
+		List<String> boxCodeList = excelList.stream().map(EmptyContainerAppearance::getBoxCode)
+			.distinct().collect(Collectors.toList());
+		//箱档案数据
+		List<Archives> archivesList = archivesService.list(new LambdaQueryWrapper<Archives>()
+			.eq(Archives::getTenantId, AuthUtil.getTenantId())
+			.eq(Archives::getIsDeleted, 0)
+			.in(Archives::getCode, boxCodeList)
+			.eq(Archives::getStatus, "使用中")
+		);
+		if (archivesList.isEmpty()) {
+			throw new RemoteException("未查到对应箱档案信息");
+		}
+		if (boxCodeList.size() > archivesList.size()) {
+			List<String> boxCode = archivesList.stream().map(Archives::getCode).collect(Collectors.toList());
+			throw new RemoteException("箱号:" + boxCodeList.stream().filter(e -> !boxCode.contains(e)).collect(Collectors.joining(","))
+				+ "未查到对应箱档案信息");
+		}
+		List<String> containerNumberList = archivesList.stream().map(Archives::getContainerNumber)
+			.distinct().collect(Collectors.toList());
+		List<String> portName = excelList.stream().map(EmptyContainerAppearance::getPortName).filter(Objects::nonNull)
+			.distinct().collect(Collectors.toList());
+		List<BPorts> portsList = bPortsService.list(new LambdaQueryWrapper<BPorts>()
+			.eq(BPorts::getTenantId, AuthUtil.getTenantId())
+			.eq(BPorts::getIsDeleted, 0)
+			.in(BPorts::getCnName, portName));
+		List<String> stationName = excelList.stream().map(EmptyContainerAppearance::getStationName).filter(Objects::nonNull)
+			.distinct().collect(Collectors.toList());
+		List<BCorps> corpsList = bCorpsService.list(new LambdaQueryWrapper<BCorps>()
+			.eq(BCorps::getTenantId, AuthUtil.getTenantId())
+			.eq(BCorps::getIsDeleted, 0)
+			.in(BCorps::getCnName, stationName));
+		List<PutBox> putBoxList = baseMapper.selectList(new LambdaQueryWrapper<PutBox>()
+			.eq(PutBox::getTenantId, AuthUtil.getTenantId())
+			.eq(PutBox::getIsDeleted, 0)
+			.in(PutBox::getContainerNumber, containerNumberList));
+		if (putBoxList.isEmpty()) {
+			throw new RuntimeException("未查到放箱号单据");
+		}
+		List<PutBox> putBoxNewList = new ArrayList<>();
+		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, AuthUtil.getTenantId())
+			.in(PutBoxItems::getPid, putBoxIdList));
+		List<PutBoxItems> putBoxItems = new ArrayList<>();
+		List<Archives> archivesArrayList = new ArrayList<>();
+		List<Long> archivesDateleList = new ArrayList<>();
+		BusinessType businessType = bBusinessTypeService.getOne(new LambdaQueryWrapper<BusinessType>()
+			.select(BusinessType::getId)
+			.eq(BusinessType::getTenantId, AuthUtil.getTenantId())
+			.eq(BusinessType::getIsDeleted, 0)
+			.eq(BusinessType::getStatus, 0)
+			.eq(BusinessType::getCode, "FXH"));
+		if (businessType == null) {
+			throw new RuntimeException("未找到可用业务类型");
+		}
+		for (EmptyContainerAppearance item : excelList) {
+			BPorts ports = portsList.stream().filter(e -> e.getCnName().equals(item.getPortName())).findFirst().orElse(null);
+			if (ports == null) {
+				throw new RemoteException("请先维护港口:" + item.getPortName() + "基础资料");
+			}
+			BCorps corps = corpsList.stream().filter(e -> e.getCnName().equals(item.getStationName())).findFirst().orElse(null);
+			if (corps == null) {
+				throw new RemoteException("请先维护场站:" + item.getStationName() + "基础资料");
+			}
+			//箱档案数据处理
+			Archives archives = archivesList.stream().filter(e -> e.getCode().equals(item.getBoxCode())).findFirst().orElse(null);
+			if (archives != null) {
+				if ("OW(拿),代理箱".contains(archives.getContainerNumberType())) {
+					archivesDateleList.add(archives.getId());
+					continue;
+				} else {
+					archives.setUpdateTime(new Date());
+					archives.setUpdateUser(AuthUtil.getUserId());
+					archives.setUpdateUserName(AuthUtil.getUserName());
+					archives.setStatus("待使用");
+					archives.setNewDate(item.getBoxStatusDate());
+					archives.setBoxAccessStatus("空箱进场");
+					archives.setAddressId(ports.getId());
+					archives.setAddressCode(ports.getCode());
+					archives.setAddressCname(ports.getCnName());
+					archives.setAddressEname(ports.getEnName());
+					archives.setStationId(corps.getId());
+					archives.setStationCode(corps.getCode());
+					archives.setStationCname(corps.getCnName());
+					archives.setStationEname(corps.getEnName());
+					archivesArrayList.add(archives);
+				}
+			} else {
+				throw new RemoteException("箱号:" + item.getBoxCode() + "未查到数据");
+			}
+			PutBox putBox = putBoxList.stream().filter(e -> e.getContainerNumber().equals(item.getContainerNumber())
+				&& e.getPolId().equals(ports.getId()) && e.getPolStationId().equals(corps.getId())).findFirst().orElse(null);
+			if (putBox == null) {
+				if (!putBoxNewList.isEmpty()) {
+					PutBox putBox1 = putBoxNewList.stream().filter(e -> e.getContainerNumber().equals(item.getContainerNumber())
+						&& e.getPolId().equals(ports.getId()) && e.getPolStationId().equals(corps.getId())).findFirst().orElse(null);
+					if (putBox1 == null) {
+						putBox1 = new PutBox();
+						putBox1.setCreateUser(AuthUtil.getUserId());
+						putBox1.setCreateTime(new Date());
+						putBox1.setCreateUserName(AuthUtil.getUserName());
+						putBox1.setBusType("自有箱");
+						putBox1.setBoxClass("自有箱");
+						putBox1.setBoxBelongsTo("SOC");
+						putBox1.setBoxEastId(archives.getBoxEastId() + "");
+						putBox1.setBoxEastName(archives.getBoxEastName());
+						String code = "FXH-ZY";
+						BusinessBillNo businessBillNo = new BusinessBillNo();
+						businessBillNo.setBusinessTypeId(businessType.getId());
+						businessBillNo.setCode(code);
+						R clientBillNo = businessBillNoService.getBillNoLos(businessBillNo);
+						if (!clientBillNo.isSuccess()) {
+							throw new RuntimeException("生成订单编号失败");
+						}
+						putBox1.setSysNo((String) clientBillNo.getData());
+						putBox1.setContainerNumber(item.getContainerNumber());
+						BusinessBillNo businessBillNo1 = new BusinessBillNo();
+						businessBillNo1.setBusinessTypeId(businessType.getId());
+						businessBillNo1.setCode("FXH-N");
+						R clientBillNo1 = businessBillNoService.getBillNoLos(businessBillNo1);
+						if (!clientBillNo1.isSuccess()) {
+							throw new RuntimeException("生成订单编号失败");
+						}
+						putBox1.setInternalContainerNumber((String) clientBillNo1.getData());
+						putBox1.setPolId(ports.getId());
+						putBox1.setPolCode(ports.getCode());
+						putBox1.setPolCname(ports.getCnName());
+						putBox1.setPolEname(ports.getEnName());
+						putBox1.setPolStationId(corps.getId());
+						putBox1.setPolStationCode(corps.getCode());
+						putBox1.setPolStationCname(corps.getCnName());
+						putBox1.setPolStationEname(corps.getEnName());
+						putBox1.setBoxCondition("好");
+						putBox1.setBoxType(item.getBoxType());
+						putBox1.setBoxClass("自有箱");
+						putBox1.setTotalNum(1);
+						putBox1.setOccupyNum(0);
+						putBox1.setRemainingNum(1);
+						putBoxNewList.add(putBox1);
+					} else {
+						putBox1.setTotalNum(putBox1.getTotalNum() + 1);
+						putBox1.setOccupyNum(0);
+						putBox1.setRemainingNum(putBox1.getRemainingNum() + 1);
+					}
+				} else {
+					putBox = new PutBox();
+					putBox.setCreateUser(AuthUtil.getUserId());
+					putBox.setCreateTime(new Date());
+					putBox.setCreateUserName(AuthUtil.getUserName());
+					putBox.setBusType("自有箱");
+					putBox.setBoxClass("自有箱");
+					String code = "FXH-ZY";
+					BusinessBillNo businessBillNo = new BusinessBillNo();
+					businessBillNo.setBusinessTypeId(businessType.getId());
+					businessBillNo.setCode(code);
+					R clientBillNo = businessBillNoService.getBillNoLos(businessBillNo);
+					if (!clientBillNo.isSuccess()) {
+						throw new RuntimeException("生成订单编号失败");
+					}
+					putBox.setSysNo((String) clientBillNo.getData());
+					putBox.setContainerNumber(item.getContainerNumber());
+					putBox.setBoxBelongsTo("SOC");
+					putBox.setBoxEastId(archives.getBoxEastId() + "");
+					putBox.setBoxEastName(archives.getBoxEastName());
+					BusinessBillNo businessBillNo1 = new BusinessBillNo();
+					businessBillNo1.setBusinessTypeId(businessType.getId());
+					businessBillNo1.setCode("FXH-N");
+					R clientBillNo1 = businessBillNoService.getBillNoLos(businessBillNo1);
+					if (!clientBillNo1.isSuccess()) {
+						throw new RuntimeException("生成订单编号失败");
+					}
+					putBox.setInternalContainerNumber((String) clientBillNo1.getData());
+					putBox.setPolId(ports.getId());
+					putBox.setPolCode(ports.getCode());
+					putBox.setPolCname(ports.getCnName());
+					putBox.setPolEname(ports.getEnName());
+					putBox.setPolStationId(corps.getId());
+					putBox.setPolStationCode(corps.getCode());
+					putBox.setPolStationCname(corps.getCnName());
+					putBox.setPolStationEname(corps.getEnName());
+					putBox.setBoxCondition("好");
+					putBox.setBoxType(item.getBoxType());
+					putBox.setBoxClass("自有箱");
+					putBox.setTotalNum(1);
+					putBox.setOccupyNum(0);
+					putBox.setRemainingNum(1);
+					putBoxNewList.add(putBox);
+				}
+			} else {
+				putBox.setTotalNum(putBox.getTotalNum() + 1);
+				putBox.setRemainingNum(putBox.getTotalNum() + 1 - putBox.getOccupyNum());
+			}
+		}
+		if (!putBoxNewList.isEmpty()) {
+			this.saveOrUpdateBatch(putBoxNewList);
+		} else {
+			throw new RemoteException("保存放箱号单据失败");
+		}
+		for (EmptyContainerAppearance item : excelList) {
+			BPorts ports = portsList.stream().filter(e -> e.getCnName().equals(item.getPortName())).findFirst().orElse(null);
+			if (ports == null) {
+				throw new RemoteException("请先维护港口:" + item.getPortName() + "基础资料");
+			}
+			BCorps corps = corpsList.stream().filter(e -> e.getCnName().equals(item.getStationName())).findFirst().orElse(null);
+			if (corps == null) {
+				throw new RemoteException("请先维护场站:" + item.getStationName() + "基础资料");
+			}
+			PutBox putBox = putBoxNewList.stream().filter(e -> e.getContainerNumber().equals(item.getContainerNumber())
+				&& e.getPolId().equals(ports.getId()) && e.getPolStationId().equals(corps.getId())).findFirst().orElse(null);
+			if (putBox == null) {
+				throw new RuntimeException("未查到放箱号:" + item.getContainerNumber() + "单据");
+			}
+			//放箱号明细数据处理
+			PutBoxItems putBoxItem;
+			if (!putBoxItemsList.isEmpty()) {
+				putBoxItem = putBoxItemsList.stream().filter(e -> e.getBoxCode().equals(item.getBoxCode()))
+					.findFirst().orElse(null);
+				if (putBoxItem != null) {
+					putBoxItem.setPid(putBox.getId());
+					putBoxItem.setMblno(item.getMblno());
+					putBoxItem.setBoxDynamics(item.getBoxStatus());
+					putBoxItem.setPolCyId(corps.getId());
+					putBoxItem.setPolCyCode(corps.getCode());
+					putBoxItem.setPolCyCname(corps.getCnName());
+					putBoxItem.setPolCyEname(corps.getEnName());
+				} else {
+					putBoxItem = new PutBoxItems();
+					putBoxItem.setBoxClass(putBox.getBusType());
+					putBoxItem.setBoxBelongsTo("SOC");
+					putBoxItem.setBoxCondition("新");
+					putBoxItem.setBoxStatus("好");
+					putBoxItem.setPid(putBox.getId());
+					putBoxItem.setContainerNumber(item.getContainerNumber());
+					putBoxItem.setBoxCode(item.getBoxCode());
+					putBoxItem.setBoxType(item.getBoxType());
+					putBoxItem.setMblno(item.getMblno());
+					putBoxItem.setBoxDynamics(item.getBoxStatus());
+					putBoxItem.setPolCyId(corps.getId());
+					putBoxItem.setPolCyCode(corps.getCode());
+					putBoxItem.setPolCyCname(corps.getCnName());
+					putBoxItem.setPolCyEname(corps.getEnName());
+				}
+			} else {
+				putBoxItem = new PutBoxItems();
+				putBoxItem.setBoxClass(putBox.getBusType());
+				putBoxItem.setBoxBelongsTo("SOC");
+				putBoxItem.setBoxCondition("新");
+				putBoxItem.setBoxStatus("好");
+				putBoxItem.setPid(putBox.getId());
+				putBoxItem.setContainerNumber(item.getContainerNumber());
+				putBoxItem.setBoxCode(item.getBoxCode());
+				putBoxItem.setBoxType(item.getBoxType());
+				putBoxItem.setMblno(item.getMblno());
+				putBoxItem.setBoxDynamics(item.getBoxStatus());
+				putBoxItem.setPolCyId(corps.getId());
+				putBoxItem.setPolCyCode(corps.getCode());
+				putBoxItem.setPolCyCname(corps.getCnName());
+				putBoxItem.setPolCyEname(corps.getEnName());
+			}
+			putBoxItems.add(putBoxItem);
+		}
+		if (!putBoxItems.isEmpty()) {
+			putBoxItemsService.saveOrUpdateBatch(putBoxItems);
+			for (PutBoxItems item : putBoxItems) {
+				PutBox putBox = putBoxList.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.setBoxType(item.getBoxType());
+					archivesTrajectory.setBoxCategory(item.getBoxClass());
+					archivesTrajectory.setBoxEastId(item.getBoxEastId());
+					archivesTrajectory.setBoxEastName(item.getBoxEastName());
+					archivesTrajectory.setMblno(item.getMblno());
+					archivesTrajectory.setBoxDynamics(item.getBoxDynamics());
+					archivesTrajectory.setStatus(item.getBoxDynamics());
+					archivesTrajectory.setBillType(putBox.getBusType());
+					archivesTrajectory.setCode(item.getBoxCode());
+					archivesTrajectory.setNewDate(new Date());
+					archivesTrajectory.setCreateTime(new Date());
+					archivesTrajectory.setCreateUser(AuthUtil.getUserId());
+					archivesTrajectory.setCreateUserName(AuthUtil.getUserName());
+					archivesTrajectory.setTenantId(AuthUtil.getTenantId());
+					archivesTrajectory.setSrcId(putBox.getId());
+					archivesTrajectoryMapper.insert(archivesTrajectory);
+				}
+			}
+		}
+		if (!archivesArrayList.isEmpty()) {
+			archivesService.saveOrUpdateBatch(archivesArrayList);
+		}
+		if (!archivesDateleList.isEmpty()) {
+			archivesService.removeByIds(archivesDateleList);
+		}
+		ArchivesFiles archivesFiles = new ArchivesFiles();
+		archivesFiles.setCreateUser(AuthUtil.getUserId());
+		archivesFiles.setCreateTime(new Date());
+		archivesFiles.setTenantId(AuthUtil.getTenantId());
+		archivesFiles.setType("2");
+		R<BladeFile> res = ossClient.putFile(file);
+		if (res.isSuccess() && ObjectUtils.isNotNull(res.getData())) {
+			archivesFiles.setUrl(res.getData().getLink());
+			archivesFiles.setFileName(res.getData().getOriginalName());
+		} else {
+			throw new RemoteException("文件保存失败");
+		}
+		archivesFilesService.save(archivesFiles);
+		return R.data("操作成功");
+	}
+
 }

+ 360 - 177
blade-service/blade-los/src/main/java/org/springblade/los/box/service/impl/TradingBoxServiceImpl.java

@@ -44,10 +44,7 @@ import java.time.Instant;
 import java.time.LocalDate;
 import java.time.Period;
 import java.time.ZoneId;
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.List;
-import java.util.Objects;
+import java.util.*;
 import java.util.stream.Collectors;
 
 /**
@@ -135,8 +132,7 @@ public class TradingBoxServiceImpl extends ServiceImpl<TradingBoxMapper, Trading
 		if (ObjectUtils.isNotNull(tradingBox.getContractNo())) {
 			LambdaQueryWrapper<TradingBox> lambdaQueryWrapper = new LambdaQueryWrapper<>();
 			lambdaQueryWrapper.eq(TradingBox::getIsDeleted, 0)
-				.eq(TradingBox::getTenantId, AuthUtil.getTenantId())
-				.eq(TradingBox::getType, tradingBox.getType());
+				.eq(TradingBox::getTenantId, AuthUtil.getTenantId());
 			if ("OW-N,OW-F".contains(tradingBox.getType())) {
 				lambdaQueryWrapper.eq(TradingBox::getContainerNumber, tradingBox.getContainerNumber());
 			} else {
@@ -164,12 +160,17 @@ public class TradingBoxServiceImpl extends ServiceImpl<TradingBoxMapper, Trading
 		} else if ("OW-N".equals(tradingBox.getType())) {
 			billNoFormat = "OW-N";
 			businessTypeCode = "OW-N";
+			tradingBox.setRemainingBoxNumber(tradingBox.getBoxNumber()-tradingBox.getActualBoxNumber());
 		} else if ("OW-F".equals(tradingBox.getType())) {
 			billNoFormat = "OW-F";
 			businessTypeCode = "OW-F";
+			tradingBox.setRemainingBoxNumber(tradingBox.getBoxNumber()-tradingBox.getActualBoxNumber());
 		} else if ("XGFY".equals(tradingBox.getType())) {
 			billNoFormat = "XGFY";
 			businessTypeCode = "XGFY";
+		}else if ("XGDX".equals(tradingBox.getType())) {
+			billNoFormat = "XGDX";
+			businessTypeCode = "XGDX";
 		} else {
 			throw new Error("缺少必要参数类型");
 		}
@@ -225,10 +226,11 @@ public class TradingBoxServiceImpl extends ServiceImpl<TradingBoxMapper, Trading
 			tradingBox.setCreateUserName(AuthUtil.getUserName());
 			tradingBox.setTenantId(AuthUtil.getTenantId());
 			tradingBox.setStatus(0);
+			tradingBox.setBuxStaus("录入");
 			baseMapper.insert(tradingBox);
 		} else {
 			if (tradingBoxList.stream().anyMatch(e -> !e.getId().equals(tradingBox.getId()))) {
-				throw new Error(text);
+				throw new RuntimeException(text);
 			}
 			tradingBox.setUpdateTime(new Date());
 			tradingBox.setUpdateUser(AuthUtil.getUserId());
@@ -459,21 +461,19 @@ public class TradingBoxServiceImpl extends ServiceImpl<TradingBoxMapper, Trading
 		List<TradingBoxType> tradingBoxTypeList = tradingBoxTypeService.list(new LambdaQueryWrapper<TradingBoxType>()
 			.eq(TradingBoxType::getTenantId, AuthUtil.getTenantId())
 			.eq(TradingBoxType::getIsDeleted, 0)
-			.eq(TradingBoxType::getPid, tradingBoxItemList.get(0).getPid()));
-		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("请先维护费用基础信息");
+			.eq(TradingBoxType::getPid, tradingBox.getId()));
+		if (tradingBoxTypeList.isEmpty()){
+			throw new RuntimeException("请先维护箱型箱量数据");
 		}
 		List<Archives> archivesListNew = new ArrayList<>();
 		List<ArchivesTrajectory> archivesTrajectoryList = new ArrayList<>();
 		List<FeeCenter> feeCenterList = new ArrayList<>();
 		List<TradingBoxItem> itemList = new ArrayList<>();
+		BigDecimal exrateC = bCurrencyService.getCnyExrate(new Date(), "USD", "C", "1");
 		if ("1".equals(tradingBox.getRentType())) {
 			tradingBox.setBuxStaus("已启租");
 			tradingBox.setRentEndDate(tradingBox.getRentDate());
+			tradingBox.setPurchaseDate(tradingBox.getRentDate());
 			for (TradingBoxItem tradingBoxItem : tradingBoxItemList) {
 				ArchivesTrajectory archivesTrajectory = new ArchivesTrajectory();
 				archivesTrajectory.setPortId(tradingBox.getAddressId());
@@ -568,13 +568,71 @@ public class TradingBoxServiceImpl extends ServiceImpl<TradingBoxMapper, Trading
 				archivesTrajectory.setTenantId(AuthUtil.getTenantId());
 				archivesTrajectoryList.add(archivesTrajectory);
 			}
+			if (ObjectUtils.isNotNull(tradingBox.getTotalAmountC()) && new BigDecimal("0.00").compareTo(tradingBox.getTotalAmountC()) != 0){
+				BFees fees = bFeesService.getOne(new LambdaQueryWrapper<BFees>()
+					.eq(BFees::getTenantId, AuthUtil.getTenantId())
+					.eq(BFees::getIsDeleted, 0)
+					.eq(BFees::getCode, "BOX-YJ"));
+				if (fees == null) {
+					throw new RuntimeException("请先维护费用基础信息");
+				}
+				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(tradingBox.getId());
+				feeCenter.setDc("C");
+				feeCenter.setFeeId(fees.getId());
+				feeCenter.setFeeCode(fees.getCode());
+				feeCenter.setFeeCnName(fees.getCnName());
+				feeCenter.setFeeEnName(fees.getEnName());
+				feeCenter.setCurCode(fees.getCurNo());
+				feeCenter.setUnitNo("按票");
+				feeCenter.setPrice(tradingBox.getTotalAmountC());
+				feeCenter.setQuantity(new BigDecimal("1"));
+				if ("CNY".equals(feeCenter.getCurCode())) {
+					feeCenter.setAmount(feeCenter.getPrice().multiply(feeCenter.getQuantity()));
+					feeCenter.setExrate(new BigDecimal("1.00"));
+				} else {
+					feeCenter.setAmountLoc(feeCenter.getPrice().multiply(feeCenter.getQuantity()));
+					feeCenter.setExrate(exrateC);
+				}
+				feeCenter.setBillNo(tradingBox.getSysNo());
+				feeCenter.setBusinessType(tradingBox.getType());
+				feeCenter.setBillDate(tradingBox.getPurchaseDate());
+				feeCenter.setBillCorpId(tradingBox.getPurchaseCompanyId());
+				feeCenter.setBillCorpCnName(tradingBox.getPurchaseCompanyName());
+				feeCenter.setBillCorpEnName(tradingBox.getPurchaseCompanyName());
+				feeCenter.setBillShortName(tradingBox.getPurchaseCompanyName());
+				feeCenter.setMblno(tradingBox.getContractNo());
+				feeCenter.setPolId(tradingBox.getAddressId());
+				feeCenter.setPolCode(tradingBox.getAddressCode());
+				feeCenter.setPolCnName(tradingBox.getAddressCname());
+				feeCenter.setPolEnName(tradingBox.getAddressCname());
+				feeCenterList.add(feeCenter);
+			}
 		} else {
 			tradingBox.setBuxStaus("已退租");
+			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("请先维护费用基础信息");
+			}
 			for (TradingBoxType item : tradingBoxTypeList) {
 				List<TradingBoxItem> tradingBoxItems = tradingBoxItemList.stream().filter(e -> e.getBoxType().equals(item.getBoxType()))
 					.collect(Collectors.toList());
 				if (!tradingBoxItems.isEmpty()) {
 					FeeCenter feeCenter = new FeeCenter();
+					feeCenter.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());
@@ -593,14 +651,27 @@ public class TradingBoxServiceImpl extends ServiceImpl<TradingBoxMapper, Trading
 						LocalDate date1 = instant1.atZone(ZoneId.systemDefault()).toLocalDate();
 						LocalDate date2 = instant2.atZone(ZoneId.systemDefault()).toLocalDate();
 						Period period = Period.between(date1, date2);
+						if (ObjectUtils.isNotNull(tradingBox.getRentEndDate())) {
+							Calendar calendar = Calendar.getInstance();
+							calendar.setTime(tradingBox.getRentEndDate());
+							calendar.add(Calendar.DAY_OF_MONTH, 1);
+							feeCenter.setStorageDate(calendar.getTime());
+						}
 						feeCenter.setDays(period.getDays());
 						feeCenter.setPrice(item.getPrice());
 						feeCenter.setQuantity(new BigDecimal(tradingBoxItems.size() + ""));
-						feeCenter.setAmount(feeCenter.getPrice().multiply(feeCenter.getQuantity())
-							.multiply(new BigDecimal(feeCenter.getDays() + "")));
-						feeCenter.setRemarks("租金单价:" + feeCenter.getPrice() + "箱/天*箱数:" + feeCenter.getQuantity() + "*天数" + feeCenter.getDays());
+						if ("CNY".equals(feeCenter.getCurCode())) {
+							feeCenter.setAmount(feeCenter.getPrice().multiply(feeCenter.getQuantity())
+								.multiply(new BigDecimal(feeCenter.getDays() + "")));
+							feeCenter.setExrate(new BigDecimal("1.00"));
+							feeCenter.setRemarks("租金" + feeCenter.getAmount() + "=" + feeCenter.getPrice() + "箱/天*箱数" + feeCenter.getQuantity() + "*天数" + feeCenter.getDays());
+						} else {
+							feeCenter.setAmountLoc(feeCenter.getPrice().multiply(feeCenter.getQuantity())
+								.multiply(new BigDecimal(feeCenter.getDays() + "")));
+							feeCenter.setExrate(exrateC);
+							feeCenter.setRemarks("租金" + feeCenter.getAmountLoc() + "=" + feeCenter.getPrice() + "箱/天*箱数" + feeCenter.getQuantity() + "*天数" + feeCenter.getDays());
+						}
 					}
-					feeCenter.setStorageDate(tradingBox.getRentEndDate());
 					feeCenter.setOutboundDate(tradingBox.getRentDate());
 					feeCenter.setBillNo(tradingBox.getSysNo());
 					feeCenter.setBusinessType(tradingBox.getType());
@@ -719,11 +790,16 @@ public class TradingBoxServiceImpl extends ServiceImpl<TradingBoxMapper, Trading
 			.eq(TradingBoxType::getPid, tradingBox.getId()));
 		List<FeeCenter> feeCenterList = new ArrayList<>();
 		List<TradingBoxItem> itemList = new ArrayList<>();
+		BigDecimal exrateC = bCurrencyService.getCnyExrate(new Date(), "USD", "C", "1");
 		for (TradingBoxType item : tradingBoxTypeList) {
 			List<TradingBoxItem> tradingBoxItems = tradingBoxItemList.stream().filter(e -> e.getBoxType().equals(item.getBoxType()))
 				.collect(Collectors.toList());
 			if (!tradingBoxItems.isEmpty()) {
 				FeeCenter feeCenter = new FeeCenter();
+				feeCenter.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());
@@ -742,14 +818,31 @@ public class TradingBoxServiceImpl extends ServiceImpl<TradingBoxMapper, Trading
 					LocalDate date1 = instant1.atZone(ZoneId.systemDefault()).toLocalDate();
 					LocalDate date2 = instant2.atZone(ZoneId.systemDefault()).toLocalDate();
 					Period period = Period.between(date1, date2);
-					feeCenter.setDays(period.getDays());
+					if (ObjectUtils.isNotNull(tradingBox.getRentEndDate()) &&
+						tradingBoxItems.get(0).getLeaseCommencementDate().compareTo(tradingBox.getRentEndDate()) != 0) {
+						Calendar calendar = Calendar.getInstance();
+						calendar.setTime(tradingBox.getRentEndDate());
+						calendar.add(Calendar.DAY_OF_MONTH, 1);
+						feeCenter.setStorageDate(calendar.getTime());
+						feeCenter.setDays(period.getDays());
+					} else {
+						feeCenter.setStorageDate(tradingBox.getRentEndDate());
+						feeCenter.setDays(period.getDays() + 1);
+					}
 					feeCenter.setPrice(item.getPrice());
 					feeCenter.setQuantity(new BigDecimal(tradingBoxItems.size() + ""));
-					feeCenter.setAmount(feeCenter.getPrice().multiply(feeCenter.getQuantity())
-						.multiply(new BigDecimal(feeCenter.getDays() + "")));
-					feeCenter.setRemarks("租金单价:" + feeCenter.getPrice() + "箱/天*箱数:" + feeCenter.getQuantity() + "*天数" + feeCenter.getDays());
+					if ("CNY".equals(feeCenter.getCurCode())) {
+						feeCenter.setAmount(feeCenter.getPrice().multiply(feeCenter.getQuantity())
+							.multiply(new BigDecimal(feeCenter.getDays() + "")));
+						feeCenter.setExrate(new BigDecimal("1.00"));
+						feeCenter.setRemarks("租金" + feeCenter.getAmount() + "=" + feeCenter.getPrice() + "箱/天*箱数" + feeCenter.getQuantity() + "*天数" + feeCenter.getDays());
+					} else {
+						feeCenter.setAmountLoc(feeCenter.getPrice().multiply(feeCenter.getQuantity())
+							.multiply(new BigDecimal(feeCenter.getDays() + "")));
+						feeCenter.setExrate(exrateC);
+						feeCenter.setRemarks("租金" + feeCenter.getAmountLoc() + "=" + feeCenter.getPrice() + "箱/天*箱数" + feeCenter.getQuantity() + "*天数" + feeCenter.getDays());
+					}
 				}
-				feeCenter.setStorageDate(tradingBox.getRentEndDate());
 				feeCenter.setOutboundDate(tradingBox.getRentDate());
 				feeCenter.setBillNo(tradingBox.getSysNo());
 				feeCenter.setBusinessType(tradingBox.getType());
@@ -1045,7 +1138,12 @@ public class TradingBoxServiceImpl extends ServiceImpl<TradingBoxMapper, Trading
 						if (feeCenterList.size() == 1) {
 							tradingBoxItem.setRentEndDate(tradingBoxItem.getLeaseCommencementDate());
 						} else {
-							tradingBoxItem.setRentEndDate(feeCenter.getStorageDate());
+							if (ObjectUtils.isNotNull(feeCenter.getStorageDate())) {
+								Calendar calendar = Calendar.getInstance();
+								calendar.setTime(feeCenter.getStorageDate());
+								calendar.add(Calendar.DAY_OF_MONTH, -1);
+								tradingBoxItem.setRentEndDate(calendar.getTime());
+							}
 						}
 						itemList.add(tradingBoxItem);
 					}
@@ -1306,18 +1404,22 @@ public class TradingBoxServiceImpl extends ServiceImpl<TradingBoxMapper, Trading
 	@Override
 	@Transactional(rollbackFor = Exception.class)
 	public R enable(TradingBox detail) {
-		if (ObjectUtils.isNull(detail.getPodId()) || ObjectUtils.isNull(detail.getPolId())
-			|| ObjectUtils.isNull(detail.getContainerNumber())) {
+		if (ObjectUtils.isNull(detail.getPolId())
+			|| ObjectUtils.isNull(detail.getContainerNumber()) || ObjectUtils.isNull(detail.getPolStationId())) {
 			throw new RuntimeException("必要参数未填写");
 		}
 		TradingBox tradingBox = baseMapper.selectById(detail.getId());
 		if ("OW-N,OW-F".contains(tradingBox.getType())) {
 			tradingBox.setWhetherEnable("是");
+			tradingBox.setContainerNumber(detail.getContainerNumber());
 			baseMapper.updateById(tradingBox);
 			PutBox putBox = putBoxService.getOne(new LambdaQueryWrapper<PutBox>()
 				.eq(PutBox::getTenantId, AuthUtil.getTenantId())
 				.eq(PutBox::getIsDeleted, 0)
 				.eq(PutBox::getContainerNumber, detail.getContainerNumber())
+				.eq(PutBox::getPolId, detail.getPolId())
+				.eq(PutBox::getPolStationId, detail.getPolStationId())
+				.apply("find_in_set(bus_type,'OW(拿),OW(放)')")
 			);
 			if (putBox != null) {
 				if (!putBox.getBoxEastId().contains(tradingBox.getPurchaseCompanyId() + "")) {
@@ -1328,7 +1430,7 @@ public class TradingBoxServiceImpl extends ServiceImpl<TradingBoxMapper, Trading
 				putBox.setUpdateTime(new Date());
 				putBox.setUpdateUserName(AuthUtil.getUserName());
 				putBox.setTotalNum(putBox.getTotalNum() + tradingBox.getBoxNumber());
-				putBox.setRemainingNum(putBox.getRemainingNum() + tradingBox.getRemainingBoxNumber());
+				putBox.setRemainingNum(putBox.getTotalNum() - putBox.getOccupyNum());
 				putBoxService.updateById(putBox);
 			} else {
 				putBox = new PutBox();
@@ -1356,11 +1458,11 @@ public class TradingBoxServiceImpl extends ServiceImpl<TradingBoxMapper, Trading
 				putBox.setBoxEastName(tradingBox.getPurchaseCompanyName());
 				putBox.setContainerNumber(detail.getContainerNumber());
 				if ("OW-N".equals(tradingBox.getType())) {
-					putBox.setBusType("OW");
-					putBox.setBoxClass("OW");
+					putBox.setBusType("OW(拿)");
+					putBox.setBoxClass("OW(拿)");
 				} else if ("OW-F".equals(tradingBox.getType())) {
-					putBox.setBusType("OW-F");
-					putBox.setBoxClass("OW-F");
+					putBox.setBusType("OW(放)");
+					putBox.setBoxClass("OW(放)");
 				}
 				putBox.setPolId(detail.getPolId());
 				putBox.setPolCname(detail.getPolCname());
@@ -1413,63 +1515,154 @@ public class TradingBoxServiceImpl extends ServiceImpl<TradingBoxMapper, Trading
 				.eq(Archives::getTenantId, AuthUtil.getTenantId())
 				.eq(Archives::getIsDeleted, 0)
 				.in(Archives::getCode, itemList.stream().map(TradingBoxItem::getCode).collect(Collectors.toList())));
-			if (!archivesList.isEmpty()) {
-				throw new RuntimeException("箱号:" + archivesList.stream().map(Archives::getCode).collect(Collectors.joining(","))
-					+ "已存在");
-			}
 			List<Archives> archivesListNew = new ArrayList<>();
 			List<ArchivesTrajectory> archivesTrajectoryList = new ArrayList<>();
 			for (TradingBoxItem item : itemList) {
-				Archives archives1 = new Archives();
-				archives1.setCode(item.getCode());
-				archives1.setName(item.getBoxType());
-				archives1.setCreateUser(AuthUtil.getUserId());
-				archives1.setCreateTime(new Date());
-				archives1.setCreateUserName(AuthUtil.getUserName());
-				archives1.setTypeId(item.getBoxTypeId());
-				archives1.setTypeName(item.getBoxType());
-				archives1.setContainerNumber(item.getContainerNumber());
-				archives1.setBoxBelongsTo(item.getBoxBelongsTo());
-				archives1.setBoxType(item.getBoxCategory());
-				archives1.setBoxEastId(item.getBoxEastId());
-				archives1.setBoxEastName(item.getBoxEastName());
-				archives1.setOriginalBoxEastId(item.getOriginalBoxEastId());
-				archives1.setOriginalBoxEastName(item.getOriginalBoxEastName());
-				archives1.setRestrictedPortsIds(item.getRestrictedPortsIds());
-				archives1.setRestrictedPortsName(item.getRestrictedPortsName());
-				archives1.setRestrictingShippingCompaniesIds(item.getRestrictingShippingCompaniesIds());
-				archives1.setRestrictingShippingCompaniesName(item.getRestrictingShippingCompaniesName());
-				archives1.setActivationDate(item.getActivationDate());
-				archives1.setNewDate(new Date());
-				archives1.setBoxStatus(item.getBoxStatus());
-				archives1.setContractNo(tradingBox.getContractNo());
-				archives1.setBoxAccessStatus(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());
-				if ("BUY".equals(tradingBox.getType())) {
-					archives1.setPurchaseDate(tradingBox.getPurchaseDate());
-					archives1.setBoxSource("买箱");
-				} else if ("SELL".equals(tradingBox.getType())) {
-					archives1.setBoxSource("卖箱");
-				} else if ("ZR".equals(tradingBox.getType())) {
-					archives1.setBoxSource("租入");
-					archives1.setLeasingCompanyId(tradingBox.getPurchaseCompanyId());
-					archives1.setLeasingCompany(tradingBox.getPurchaseCompanyName());
-					archives1.setLeaseCommencementDate(tradingBox.getEffectiveDate());
-				} else if ("DL".equals(tradingBox.getType())) {
-					archives1.setBoxSource("代理");
-					archives1.setLeasingCompanyId(tradingBox.getPurchaseCompanyId());
-					archives1.setLeasingCompany(tradingBox.getPurchaseCompanyName());
-					archives1.setLeaseCommencementDate(tradingBox.getEffectiveDate());
-				} else {
-					throw new RuntimeException("单据类型错误");
+				Archives archives1;
+				if (!archivesList.isEmpty()){
+					archives1 = archivesList.stream().filter(e-> e.getCode().equals(item.getCode())).findFirst().orElse(null);
+					if (archives1 != null){
+						archives1.setUpdateUser(AuthUtil.getUserId());
+						archives1.setUpdateTime(new Date());
+						archives1.setUpdateUserName(AuthUtil.getUserName());
+						archives1.setContainerNumber(detail.getContainerNumber());
+						archives1.setActivationDate(detail.getActivationDate());
+						archives1.setNewDate(detail.getActivationDate());
+						archives1.setBoxAccessStatus("空箱入场");
+						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());
+						if ("BUY".equals(tradingBox.getType())) {
+							archives1.setContainerNumberType("自有箱");
+						} else if ("SELL".equals(tradingBox.getType())) {
+							archives1.setContainerNumberType("自有箱");
+						} else if ("ZR".equals(tradingBox.getType())) {
+							archives1.setContainerNumberType("自有箱");
+						} else if ("DL".equals(tradingBox.getType())) {
+							archives1.setContainerNumberType("代理箱");
+						} else {
+							throw new RuntimeException("单据类型错误");
+						}
+					}else{
+						archives1 = new Archives();
+						archives1.setCode(item.getCode());
+						archives1.setName(item.getBoxType());
+						archives1.setCreateUser(AuthUtil.getUserId());
+						archives1.setCreateTime(new Date());
+						archives1.setCreateUserName(AuthUtil.getUserName());
+						archives1.setTypeId(item.getBoxTypeId());
+						archives1.setTypeName(item.getBoxType());
+						archives1.setContainerNumber(detail.getContainerNumber());
+						archives1.setBoxBelongsTo(item.getBoxBelongsTo());
+						archives1.setBoxType(item.getBoxCategory());
+						archives1.setBoxEastId(item.getBoxEastId());
+						archives1.setBoxEastName(item.getBoxEastName());
+						archives1.setOriginalBoxEastId(item.getOriginalBoxEastId());
+						archives1.setOriginalBoxEastName(item.getOriginalBoxEastName());
+						archives1.setRestrictedPortsIds(item.getRestrictedPortsIds());
+						archives1.setRestrictedPortsName(item.getRestrictedPortsName());
+						archives1.setRestrictingShippingCompaniesIds(item.getRestrictingShippingCompaniesIds());
+						archives1.setRestrictingShippingCompaniesName(item.getRestrictingShippingCompaniesName());
+						archives1.setActivationDate(item.getActivationDate());
+						archives1.setNewDate(new Date());
+						archives1.setBoxStatus(item.getBoxStatus());
+						archives1.setContractNo(tradingBox.getContractNo());
+						archives1.setBoxAccessStatus(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());
+						if ("BUY".equals(tradingBox.getType())) {
+							archives1.setPurchaseDate(tradingBox.getPurchaseDate());
+							archives1.setBoxSource("买箱");
+							archives1.setContainerNumberType("自有箱");
+						} else if ("SELL".equals(tradingBox.getType())) {
+							archives1.setBoxSource("卖箱");
+							archives1.setContainerNumberType("自有箱");
+						} else if ("ZR".equals(tradingBox.getType())) {
+							archives1.setBoxSource("租入");
+							archives1.setContainerNumberType("自有箱");
+							archives1.setLeasingCompanyId(tradingBox.getPurchaseCompanyId());
+							archives1.setLeasingCompany(tradingBox.getPurchaseCompanyName());
+							archives1.setLeaseCommencementDate(tradingBox.getEffectiveDate());
+						} else if ("DL".equals(tradingBox.getType())) {
+							archives1.setBoxSource("代理");
+							archives1.setContainerNumberType("代理箱");
+							archives1.setLeasingCompanyId(tradingBox.getPurchaseCompanyId());
+							archives1.setLeasingCompany(tradingBox.getPurchaseCompanyName());
+							archives1.setLeaseCommencementDate(tradingBox.getEffectiveDate());
+						} else {
+							throw new RuntimeException("单据类型错误");
+						}
+					}
+				}
+				else{
+					archives1 = new Archives();
+					archives1.setCode(item.getCode());
+					archives1.setName(item.getBoxType());
+					archives1.setCreateUser(AuthUtil.getUserId());
+					archives1.setCreateTime(new Date());
+					archives1.setCreateUserName(AuthUtil.getUserName());
+					archives1.setTypeId(item.getBoxTypeId());
+					archives1.setTypeName(item.getBoxType());
+					archives1.setContainerNumber(detail.getContainerNumber());
+					archives1.setBoxBelongsTo(item.getBoxBelongsTo());
+					archives1.setBoxType(item.getBoxCategory());
+					archives1.setBoxEastId(tradingBox.getPurchaseCompanyId());
+					archives1.setBoxEastName(tradingBox.getPurchaseCompanyName());
+					archives1.setOriginalBoxEastId(item.getOriginalBoxEastId());
+					archives1.setOriginalBoxEastName(item.getOriginalBoxEastName());
+					archives1.setRestrictedPortsIds(item.getRestrictedPortsIds());
+					archives1.setRestrictedPortsName(item.getRestrictedPortsName());
+					archives1.setRestrictingShippingCompaniesIds(item.getRestrictingShippingCompaniesIds());
+					archives1.setRestrictingShippingCompaniesName(item.getRestrictingShippingCompaniesName());
+					archives1.setActivationDate(detail.getActivationDate());
+					archives1.setNewDate(detail.getActivationDate());
+					archives1.setBoxStatus(item.getBoxStatus());
+					archives1.setContractNo(tradingBox.getContractNo());
+					archives1.setBoxAccessStatus(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());
+					if ("BUY".equals(tradingBox.getType())) {
+						archives1.setPurchaseDate(tradingBox.getPurchaseDate());
+						archives1.setBoxSource("买箱");
+						archives1.setContainerNumberType("自有箱");
+					} else if ("SELL".equals(tradingBox.getType())) {
+						archives1.setBoxSource("卖箱");
+						archives1.setContainerNumberType("自有箱");
+					} else if ("ZR".equals(tradingBox.getType())) {
+						archives1.setBoxSource("租入");
+						archives1.setContainerNumberType("自有箱");
+						archives1.setLeasingCompanyId(tradingBox.getPurchaseCompanyId());
+						archives1.setLeasingCompany(tradingBox.getPurchaseCompanyName());
+						archives1.setLeaseCommencementDate(tradingBox.getEffectiveDate());
+					} else if ("DL".equals(tradingBox.getType())) {
+						archives1.setBoxSource("代理");
+						archives1.setContainerNumberType("代理箱");
+						archives1.setLeasingCompanyId(tradingBox.getPurchaseCompanyId());
+						archives1.setLeasingCompany(tradingBox.getPurchaseCompanyName());
+						archives1.setLeaseCommencementDate(tradingBox.getEffectiveDate());
+					} else {
+						throw new RuntimeException("单据类型错误");
+					}
 				}
 				archivesListNew.add(archives1);
 				//记录箱轨迹信息
@@ -1501,14 +1694,17 @@ public class TradingBoxServiceImpl extends ServiceImpl<TradingBoxMapper, Trading
 				archivesTrajectoryService.saveBatch(archivesTrajectoryList);
 			}
 			if (!archivesListNew.isEmpty()) {
-				archivesService.saveBatch(archivesListNew);
+				archivesService.saveOrUpdateBatch(archivesListNew);
 			}
 			List<PutBoxItems> putBoxItemsList = new ArrayList<>();
 			PutBox putBox = putBoxService.getOne(new LambdaQueryWrapper<PutBox>()
 				.eq(PutBox::getTenantId, AuthUtil.getTenantId())
 				.eq(PutBox::getIsDeleted, 0)
 				.eq(PutBox::getContainerNumber, detail.getContainerNumber())
+				.eq(PutBox::getPolId, detail.getPolId())
+				.eq(PutBox::getPolStationId, detail.getPolStationId())
 				.eq(PutBox::getBoxType, itemList.get(0).getBoxType())
+				.apply("not find_in_set(bus_type,'OW(拿),OW(放)')")
 			);
 			if (putBox != null) {
 				List<String> boxType = itemList.stream().map(TradingBoxItem::getBoxType).distinct().collect(Collectors.toList());
@@ -1518,18 +1714,6 @@ public class TradingBoxServiceImpl extends ServiceImpl<TradingBoxMapper, Trading
 						.collect(Collectors.joining(","));
 					throw new RuntimeException("放箱号:" + detail.getContainerNumber() + "存在其他箱型" + type);
 				}
-				List<PutBoxItems> boxItemsList = putBoxItemsService.list(new LambdaQueryWrapper<PutBoxItems>()
-					.eq(PutBoxItems::getTenantId, AuthUtil.getTenantId())
-					.eq(PutBoxItems::getIsDeleted, 0)
-					.eq(PutBoxItems::getPid, putBox.getId()));
-				if (!boxItemsList.isEmpty()) {
-					List<String> boxNumber = boxItemsList.stream().map(PutBoxItems::getBoxCode).distinct().collect(Collectors.toList());
-					if (itemList.stream().anyMatch(e -> boxNumber.contains(e.getCode()))) {
-						String boxCode = itemList.stream().map(TradingBoxItem::getCode).filter(boxNumber::contains)
-							.collect(Collectors.joining(","));
-						throw new RuntimeException("放箱号:" + detail.getContainerNumber() + "存在重复箱号" + boxCode);
-					}
-				}
 				if (!putBox.getBoxEastId().contains(tradingBox.getPurchaseCompanyId() + "")) {
 					putBox.setBoxEastId(putBox.getBoxEastId() + "," + tradingBox.getPurchaseCompanyId());
 					putBox.setBoxEastName(putBox.getBoxEastName() + "," + tradingBox.getPurchaseCompanyName());
@@ -1539,21 +1723,6 @@ public class TradingBoxServiceImpl extends ServiceImpl<TradingBoxMapper, Trading
 				putBox.setUpdateUserName(AuthUtil.getUserName());
 				putBox.setTotalNum(putBox.getTotalNum() + itemList.size());
 				putBox.setRemainingNum(putBox.getRemainingNum() + itemList.size());
-				putBox.setTotalNum(putBox.getTotalNum() + itemList.size());
-				putBox.setRemainingNum(putBox.getRemainingNum() + itemList.size());
-				if (ObjectUtils.isNotNull(putBox.getPolId())) {
-					if (!putBox.getPolId().contains(detail.getPolId())) {
-						putBox.setPolId(putBox.getPolId() + "," + detail.getPolId());
-						putBox.setPolCname(putBox.getPolCname() + "," + detail.getPolCname());
-						putBox.setPolEname(putBox.getPolEname() + "," + detail.getPolEname());
-						putBox.setPolCode(putBox.getPolCode() + "," + detail.getPolCode());
-					}
-				} else {
-					putBox.setPolId(detail.getPolId());
-					putBox.setPolCname(detail.getPolCname());
-					putBox.setPolEname(detail.getPolEname());
-					putBox.setPolCode(detail.getPolCode());
-				}
 				if (ObjectUtils.isNotNull(putBox.getPodId())) {
 					if (!putBox.getPodId().contains(detail.getPodId())) {
 						putBox.setPodId(putBox.getPodId() + "," + detail.getPodId());
@@ -1567,51 +1736,7 @@ public class TradingBoxServiceImpl extends ServiceImpl<TradingBoxMapper, Trading
 					putBox.setPodEname(detail.getPodEname());
 					putBox.setPodCode(detail.getPodCode());
 				}
-				putBox.setBoxBelongsTo(itemList.get(0).getBoxBelongsTo());
-				putBox.setBoxClass(itemList.get(0).getBoxCategory());
 				putBoxService.updateById(putBox);
-				for (TradingBoxItem item : itemList) {
-					item.setUpdateUser(AuthUtil.getUserId());
-					item.setUpdateUserName(AuthUtil.getUserName());
-					item.setUpdateTime(new Date());
-					item.setWhetherEnable("是");
-					item.setContainerNumber(detail.getContainerNumber());
-					item.setActivationDate(detail.getActivationDate());
-					if (item.getRestrictedPortsIds().contains(detail.getPodId())) {
-						throw new RuntimeException("箱号:" + item.getCode() + "限制港口:" + detail.getPodCname());
-					}
-					PutBoxItems boxItems = boxItemsList.stream().filter(e -> e.getBoxCode().equals(item.getCode())).findFirst().orElse(null);
-					if (boxItems != null) {
-						boxItems.setPid(putBox.getId());
-						boxItems.setUpdateUser(AuthUtil.getUserId());
-						boxItems.setUpdateTime(new Date());
-						boxItems.setUpdateUserName(AuthUtil.getUserName());
-						boxItems.setBoxBelongsTo(item.getBoxBelongsTo());
-						boxItems.setBoxEastId(item.getBoxEastId());
-						boxItems.setBoxEastName(item.getBoxEastName());
-						boxItems.setBoxClass(item.getBoxCategory());
-						boxItems.setBoxStatus(item.getBoxStatus());
-						boxItems.setBoxCondition(item.getBoxCondition());
-					} else {
-						boxItems = new PutBoxItems();
-						boxItems.setPid(putBox.getId());
-						boxItems.setCreateUser(AuthUtil.getUserId());
-						boxItems.setCreateTime(new Date());
-						boxItems.setCreateUserName(AuthUtil.getUserName());
-						boxItems.setBoxCode(item.getCode());
-						boxItems.setBoxType(item.getBoxType());
-						boxItems.setBoxBelongsTo(item.getBoxBelongsTo());
-						boxItems.setBoxEastId(item.getBoxEastId());
-						boxItems.setBoxEastName(item.getBoxEastName());
-						boxItems.setBoxClass(item.getBoxCategory());
-						boxItems.setBoxStatus(item.getBoxStatus());
-						boxItems.setBoxCondition(item.getBoxCondition());
-					}
-					putBoxItemsList.add(boxItems);
-				}
-				if (!putBoxItemsList.isEmpty()) {
-					putBoxItemsService.saveBatch(putBoxItemsList);
-				}
 			} else {
 				putBox = new PutBox();
 				putBox.setCreateUser(AuthUtil.getUserId());
@@ -1632,8 +1757,8 @@ public class TradingBoxServiceImpl extends ServiceImpl<TradingBoxMapper, Trading
 					putBox.setBoxClass("代理箱");
 					code = "FXH-DL";
 				} else {
-					putBox.setBusType("自有");
-					putBox.setBoxClass("自有");
+					putBox.setBusType("自有");
+					putBox.setBoxClass("自有");
 					code = "FXH-ZY";
 				}
 				BusinessBillNo businessBillNo = new BusinessBillNo();
@@ -1651,8 +1776,8 @@ public class TradingBoxServiceImpl extends ServiceImpl<TradingBoxMapper, Trading
 					putBox.setBusType("代理箱");
 					putBox.setBoxClass("代理箱");
 				} else {
-					putBox.setBusType("自有");
-					putBox.setBoxClass("自有");
+					putBox.setBusType("自有");
+					putBox.setBoxClass("自有");
 				}
 				if (ObjectUtils.isNotNull(tradingBox.getInternalContainerNumber())) {
 					putBox.setInternalContainerNumber(tradingBox.getInternalContainerNumber());
@@ -1666,10 +1791,15 @@ public class TradingBoxServiceImpl extends ServiceImpl<TradingBoxMapper, Trading
 					}
 					putBox.setInternalContainerNumber((String) clientBillNo1.getData());
 				}
+				putBox.setBoxBelongsTo("SOC");
 				putBox.setPolId(detail.getPolId());
 				putBox.setPolCname(detail.getPolCname());
 				putBox.setPolEname(detail.getPolEname());
 				putBox.setPolCode(detail.getPolCode());
+				putBox.setPolStationId(detail.getPolStationId());
+				putBox.setPolStationCname(detail.getPolStationCname());
+				putBox.setPolStationEname(detail.getPolStationEname());
+				putBox.setPolStationCode(detail.getPolStationCode());
 				putBox.setPodId(detail.getPodId());
 				putBox.setPodCname(detail.getPodCname());
 				putBox.setPodEname(detail.getPodEname());
@@ -1680,17 +1810,43 @@ public class TradingBoxServiceImpl extends ServiceImpl<TradingBoxMapper, Trading
 				putBox.setTotalNum(itemList.size());
 				putBox.setRemainingNum(itemList.size());
 				putBoxService.save(putBox);
-				for (TradingBoxItem item : itemList) {
-					item.setUpdateUser(AuthUtil.getUserId());
-					item.setUpdateUserName(AuthUtil.getUserName());
-					item.setUpdateTime(new Date());
-					item.setWhetherEnable("是");
-					item.setContainerNumber(detail.getContainerNumber());
-					item.setActivationDate(detail.getActivationDate());
-					if (item.getRestrictedPortsIds().contains(detail.getPodId())) {
-						throw new RuntimeException("箱号:" + item.getCode() + "限制港口:" + detail.getPodCname());
-					}
-					PutBoxItems boxItems = new PutBoxItems();
+			}
+			List<PutBoxItems> boxItemsList = putBoxItemsService.list(new LambdaQueryWrapper<PutBoxItems>()
+				.eq(PutBoxItems::getTenantId, AuthUtil.getTenantId())
+				.eq(PutBoxItems::getIsDeleted, 0)
+				.eq(PutBoxItems::getPid, putBox.getId()));
+			if (!boxItemsList.isEmpty()) {
+				List<String> boxNumber = boxItemsList.stream().map(PutBoxItems::getBoxCode).distinct().collect(Collectors.toList());
+				if (itemList.stream().anyMatch(e -> boxNumber.contains(e.getCode()))) {
+					String boxCode = itemList.stream().map(TradingBoxItem::getCode).filter(boxNumber::contains)
+						.collect(Collectors.joining(","));
+					throw new RuntimeException("放箱号:" + detail.getContainerNumber() + "存在重复箱号" + boxCode);
+				}
+			}
+			for (TradingBoxItem item : itemList) {
+				item.setUpdateUser(AuthUtil.getUserId());
+				item.setUpdateUserName(AuthUtil.getUserName());
+				item.setUpdateTime(new Date());
+				item.setWhetherEnable("是");
+				item.setContainerNumber(detail.getContainerNumber());
+				item.setActivationDate(detail.getActivationDate());
+				if (ObjectUtils.isNotNull(item.getRestrictedPortsIds()) && item.getRestrictedPortsIds().contains(detail.getPodId())) {
+					throw new RuntimeException("箱号:" + item.getCode() + "限制港口:" + detail.getPodCname());
+				}
+				PutBoxItems boxItems = boxItemsList.stream().filter(e -> e.getBoxCode().equals(item.getCode())).findFirst().orElse(null);
+				if (boxItems != null) {
+					boxItems.setPid(putBox.getId());
+					boxItems.setUpdateUser(AuthUtil.getUserId());
+					boxItems.setUpdateTime(new Date());
+					boxItems.setUpdateUserName(AuthUtil.getUserName());
+					boxItems.setBoxBelongsTo(item.getBoxBelongsTo());
+					boxItems.setBoxEastId(item.getBoxEastId());
+					boxItems.setBoxEastName(item.getBoxEastName());
+					boxItems.setBoxClass(item.getBoxCategory());
+					boxItems.setBoxStatus(item.getBoxStatus());
+					boxItems.setBoxCondition(item.getBoxCondition());
+				} else {
+					boxItems = new PutBoxItems();
 					boxItems.setPid(putBox.getId());
 					boxItems.setCreateUser(AuthUtil.getUserId());
 					boxItems.setCreateTime(new Date());
@@ -1703,16 +1859,43 @@ public class TradingBoxServiceImpl extends ServiceImpl<TradingBoxMapper, Trading
 					boxItems.setBoxClass(item.getBoxCategory());
 					boxItems.setBoxStatus(item.getBoxStatus());
 					boxItems.setBoxCondition(item.getBoxCondition());
-					boxItems.setContainerNumber(item.getContainerNumber());
-					putBoxItemsList.add(boxItems);
-				}
-				if (!putBoxItemsList.isEmpty()) {
-					putBoxItemsService.saveBatch(putBoxItemsList);
 				}
+				putBoxItemsList.add(boxItems);
+			}
+			if (!putBoxItemsList.isEmpty()) {
+				putBoxItemsService.saveBatch(putBoxItemsList);
 			}
 			tradingBoxItemService.updateBatchById(itemList);
 			return R.data(putBox);
 		}
 	}
 
+	@Override
+	@Transactional(rollbackFor = Exception.class)
+	public TradingBox confirm(TradingBox tradingBox) {
+		if (tradingBox.getId() == null) {
+			throw new RuntimeException("缺少必要参数");
+		}
+		tradingBox.setBuxStaus("已确认");
+		tradingBox.setUpdateTime(new Date());
+		tradingBox.setUpdateUser(AuthUtil.getUserId());
+		tradingBox.setUpdateUserName(AuthUtil.getUserName());
+		baseMapper.updateById(tradingBox);
+		return tradingBox;
+	}
+
+	@Override
+	@Transactional(rollbackFor = Exception.class)
+	public TradingBox revoke(TradingBox tradingBox) {
+		if (tradingBox.getId() == null) {
+			throw new RuntimeException("缺少必要参数");
+		}
+		tradingBox.setBuxStaus("录入");
+		tradingBox.setUpdateTime(new Date());
+		tradingBox.setUpdateUser(AuthUtil.getUserId());
+		tradingBox.setUpdateUserName(AuthUtil.getUserName());
+		baseMapper.updateById(tradingBox);
+		return tradingBox;
+	}
+
 }

+ 5 - 2
blade-service/blade-los/src/main/java/org/springblade/los/excel/RouteCostProfitExcel.java

@@ -21,8 +21,6 @@ import com.alibaba.excel.annotation.ExcelProperty;
 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.baomidou.mybatisplus.annotation.TableField;
-import io.swagger.annotations.ApiModelProperty;
 import lombok.Data;
 
 import java.io.Serializable;
@@ -90,6 +88,11 @@ public class RouteCostProfitExcel implements Serializable {
 	 */
 	@ExcelProperty(value = "箱量(自有箱)")
 	private BigDecimal boxNumberOwnBox;
+	/**
+	 * 可用箱量
+	 */
+	@ExcelIgnore
+	private BigDecimal remainingNum;
 
 	/**
 	 * 利润

+ 3 - 3
blade-service/blade-los/src/main/java/org/springblade/los/logistics/route/controller/RouteCostProfitController.java

@@ -68,11 +68,11 @@ public class RouteCostProfitController extends BladeController {
 			for (RouteCostProfitExcel item : pages.getRecords()) {
 				if (!profitExcelList.isEmpty()) {
 					item.setOwnBoxStock(profitExcelList.stream().filter(e -> e.getBoxType().equals(item.getBoxType())
-							&& e.getPodCname().contains(item.getPodCname()) && !"OW,OW-F".contains(e.getBusType()))
-						.map(RouteCostProfitExcel::getSum).reduce(BigDecimal.ZERO, BigDecimal::add));
+							&& e.getPodCname().contains(item.getPodCname()) && !"OW(拿)".contains(e.getBusType()))
+						.map(RouteCostProfitExcel::getRemainingNum).reduce(BigDecimal.ZERO, BigDecimal::add));
 					item.setReachPod(profitExcelList.stream().filter(e -> e.getBoxType().equals(item.getBoxType())
 						&& e.getDestinationCname().contains(item.getDestinationCname()) && e.getPodCname().contains(item.getPodCname())
-						&& "OW,OW-F".contains(e.getBusType())).map(RouteCostProfitExcel::getSum).reduce(BigDecimal.ZERO, BigDecimal::add));
+						&& "OW(拿)".contains(e.getBusType())).map(RouteCostProfitExcel::getRemainingNum).reduce(BigDecimal.ZERO, BigDecimal::add));
 					item.setBoxTotal(item.getOwnBoxStock().add(item.getReachPod()));
 				}
 			}