Browse Source

1.海运进出口审批驳回费用明细状态不对bug修改
2.箱模块保存费用信息报错修改
3.放箱号提取时ETD不在有效期内,不能被选择bug修改
4.买箱,租箱,代理箱-单据箱明细导入接口修改
5.箱池动态导入,根据不同模板类型,更新放箱号箱动态,模板不需要维护箱动态
6.费用明细增加版本号锁
7.分批次对账、结算、发票、申请,合计金额不能超出应收/应付金额
8.销项发票、结算中心,相同所属公司相同结算单位允许合并结算
9.结算中心外币合计不对修改
10.结算金额计算不对

纪新园 9 months ago
parent
commit
469a4c9f14
16 changed files with 1020 additions and 220 deletions
  1. 6 0
      blade-service-api/blade-los-api/src/main/java/org/springblade/los/box/entity/PutBox.java
  2. 90 0
      blade-service-api/blade-los-api/src/main/java/org/springblade/los/box/excel/AgentBoxItemExcel.java
  3. 194 0
      blade-service-api/blade-los-api/src/main/java/org/springblade/los/box/excel/PutBoxItemExcel.java
  4. 85 0
      blade-service-api/blade-los-api/src/main/java/org/springblade/los/box/excel/RentalBoxItemExcel.java
  5. 1 1
      blade-service/blade-los/src/main/java/org/springblade/los/box/controller/BoxPoolController.java
  6. 5 0
      blade-service/blade-los/src/main/java/org/springblade/los/box/controller/PutBoxController.java
  7. 17 1
      blade-service/blade-los/src/main/java/org/springblade/los/box/controller/PutBoxItemsController.java
  8. 17 7
      blade-service/blade-los/src/main/java/org/springblade/los/box/controller/TradingBoxItemController.java
  9. 1 1
      blade-service/blade-los/src/main/java/org/springblade/los/box/service/ITradingBoxItemService.java
  10. 20 20
      blade-service/blade-los/src/main/java/org/springblade/los/box/service/impl/PutBoxServiceImpl.java
  11. 449 130
      blade-service/blade-los/src/main/java/org/springblade/los/box/service/impl/TradingBoxItemServiceImpl.java
  12. 20 18
      blade-service/blade-los/src/main/java/org/springblade/los/box/service/impl/TradingBoxServiceImpl.java
  13. 19 8
      blade-service/blade-los/src/main/java/org/springblade/los/check/service/impl/AuditProecessServiceImpl.java
  14. 20 4
      blade-service/blade-los/src/main/java/org/springblade/los/finance/fee/service/impl/FeeCenterServiceImpl.java
  15. 20 1
      blade-service/blade-los/src/main/java/org/springblade/los/finance/invoices/service/impl/FinInvoicesServiceImpl.java
  16. 56 29
      blade-service/blade-los/src/main/java/org/springblade/los/finance/stl/service/impl/FinStlBillsServiceImpl.java

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

@@ -361,4 +361,10 @@ public class PutBox implements Serializable {
 	@ApiModelProperty(value = "箱号集合")
 	private String code;
 
+	/**
+	 * 开船日期
+	 */
+	@TableField(exist = false)
+	private Date etd;
+
 }

+ 90 - 0
blade-service-api/blade-los-api/src/main/java/org/springblade/los/box/excel/AgentBoxItemExcel.java

@@ -0,0 +1,90 @@
+/*
+ *      Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
+ *
+ *  Redistribution and use in source and binary forms, with or without
+ *  modification, are permitted provided that the following conditions are met:
+ *
+ *  Redistributions of source code must retain the above copyright notice,
+ *  this list of conditions and the following disclaimer.
+ *  Redistributions in binary form must reproduce the above copyright
+ *  notice, this list of conditions and the following disclaimer in the
+ *  documentation and/or other materials provided with the distribution.
+ *  Neither the name of the dreamlu.net developer nor the names of its
+ *  contributors may be used to endorse or promote products derived from
+ *  this software without specific prior written permission.
+ *  Author: Chill 庄骞 (smallchill@163.com)
+ */
+package org.springblade.los.box.excel;
+
+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 lombok.Data;
+
+import java.io.Serializable;
+import java.math.BigDecimal;
+
+@Data
+@ColumnWidth(25)
+@HeadRowHeight(20)
+@ContentRowHeight(18)
+public class AgentBoxItemExcel implements Serializable {
+
+	private static final long serialVersionUID = 1L;
+
+	/**
+	 * 箱号
+	 */
+	@ExcelProperty(value = "箱号*")
+	private String code;
+	/**
+	 * 箱类型
+	 */
+	@ExcelProperty(value = "箱型*")
+	private String boxType;
+	/**
+	 * 箱好坏
+	 */
+	@ExcelProperty(value = "箱好坏*")
+	private String boxStatus;
+
+	/**
+	 * 箱况
+	 */
+	@ExcelProperty(value = "箱况(新/旧)*")
+	private String boxCondition;
+	/**
+	 * 金额
+	 */
+	@ExcelProperty(value = "金额*")
+	private BigDecimal amount;
+	/**
+	 * 场站
+	 */
+	@ExcelProperty(value = "场站*")
+	private String stationCname;
+
+	/**
+	 * 币别
+	 */
+	@ExcelProperty(value = "币别*")
+	private String currency;
+
+	/**
+	 * 限制港口
+	 */
+	@ExcelProperty(value = "限制港口")
+	private String restrictedPortsName;
+
+	/**
+	 * 限制船公司
+	 */
+	@ExcelProperty(value = "限制船公司")
+	private String restrictingShippingCompaniesName;
+
+
+
+
+
+}

+ 194 - 0
blade-service-api/blade-los-api/src/main/java/org/springblade/los/box/excel/PutBoxItemExcel.java

@@ -0,0 +1,194 @@
+package org.springblade.los.box.excel;
+
+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.fasterxml.jackson.annotation.JsonFormat;
+import lombok.Data;
+import org.springframework.format.annotation.DateTimeFormat;
+
+import java.util.Date;
+
+/**
+ * @author :jixinyuan
+ * @date : 2025/4/17
+ */
+@Data
+@ColumnWidth(25)
+@HeadRowHeight(20)
+@ContentRowHeight(18)
+public class PutBoxItemExcel {
+
+
+	/**
+	 * 放箱号
+	 */
+	@ExcelProperty(value = "放箱号")
+	private String containerNumber;
+	/**
+	 * 箱号
+	 */
+	@ExcelProperty(value = "箱号")
+	private String boxCode;
+	/**
+	 * 箱型
+	 */
+	@ExcelProperty(value = "箱型")
+	private String boxType;
+	/**
+	 * 箱属
+	 */
+	@ExcelProperty(value = "箱属")
+	private String boxBelongsTo;
+	/**
+	 * 箱东
+	 */
+	@ExcelProperty(value = "箱东")
+	private Long boxEastId;
+	/**
+	 * 箱东
+	 */
+	@ExcelProperty(value = "箱东")
+	private String boxEastName;
+	/**
+	 * 箱种类
+	 */
+	@ExcelProperty(value = "箱种类")
+	private String boxClass;
+	/**
+	 * 箱况
+	 */
+	@ExcelProperty(value = "箱况")
+	private String boxCondition;
+	/**
+	 * 箱污染
+	 */
+	@ExcelProperty(value = "箱污染")
+	private String boxPollution;
+	/**
+	 * 客户名称
+	 */
+	@ExcelProperty(value = "客户名称")
+	private String corpName;
+	/**
+	 * 提单号
+	 */
+	@ExcelProperty(value = "提单号")
+	private String mblno;
+	/**
+	 * 分单号
+	 */
+	@ExcelProperty(value = "分单号")
+	private String hblno;
+	/**
+	 * 船名中文
+	 */
+	@ExcelProperty(value = "船名中文")
+	private String shipCname;
+	/**
+	 * 航次
+	 */
+	@ExcelProperty(value = "航次")
+	private String voyage;
+	/**
+	 * etd
+	 */
+	@ExcelProperty(value = "etd")
+	@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd")
+	@DateTimeFormat(pattern = "yyyy-MM-dd")
+	private Date etd;
+	/**
+	 * pol 堆场中文
+	 */
+	@ExcelProperty(value = "pol 堆场中文")
+	private String polCyCname;
+	/**
+	 * pol 免箱使天数
+	 */
+	@ExcelProperty(value = "pol 免箱使天数")
+	private Integer polFreeBoxUseDays;
+	/**
+	 * pol预出场日期
+	 */
+	@ExcelProperty(value = "pol预出场日期")
+	@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd")
+	@DateTimeFormat(pattern = "yyyy-MM-dd")
+	private Date polPreAppearanceDate;
+	/**
+	 * pol场站空箱出场日期
+	 */
+	@ExcelProperty(value = "pol场站空箱出场日期")
+	@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd")
+	@DateTimeFormat(pattern = "yyyy-MM-dd")
+	private Date polStationEmptyContainerExitDate;
+	/**
+	 * pol还箱日期
+	 */
+	@ExcelProperty(value = "pol还箱日期")
+	@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd")
+	@DateTimeFormat(pattern = "yyyy-MM-dd")
+	private Date polReturnDate;
+	/**
+	 * pol超期箱使天数
+	 */
+	@ExcelProperty(value = "pol超期箱使天数")
+	private Integer polOverdueBoxUseDays;
+	/**
+	 * pol提箱日期
+	 */
+	@ExcelProperty(value = "pol提箱日期")
+	@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd")
+	@DateTimeFormat(pattern = "yyyy-MM-dd")
+	private Date polPickUpDate;
+	/**
+	 * eta
+	 */
+	@ExcelProperty(value = "eta")
+	@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd")
+	@DateTimeFormat(pattern = "yyyy-MM-dd")
+	private Date eta;
+	/**
+	 * pod空箱还箱日期
+	 */
+	@ExcelProperty(value = "pod空箱还箱日期")
+	@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd")
+	@DateTimeFormat(pattern = "yyyy-MM-dd")
+	private Date podEmptyContainerReturnDate;
+	/**
+	 * pod场站中文
+	 */
+	@ExcelProperty(value = "pod场站中文")
+	private String podStationCname;
+	/**
+	 * pod 免箱使天数
+	 */
+	@ExcelProperty(value = "pod 免箱使天数")
+	private Integer podFreeBoxUseDays;
+	/**
+	 * pod箱使天数
+	 */
+	@ExcelProperty(value = "pod箱使天数")
+	private Integer podBoxUseDays;
+	/**
+	 * 代理名称
+	 */
+	@ExcelProperty(value = "代理名称")
+	private String agentName;
+	/**
+	 * 箱好坏
+	 */
+	@ExcelProperty(value = "箱好坏")
+	private String boxStatus;
+	/**
+	 * 箱动态
+	 */
+	@ExcelProperty(value = "箱动态")
+	private String boxDynamics;
+	/**
+	 * 箱状态 待使用、使用中、作废
+	 */
+	@ExcelProperty(value = "箱状态")
+	private String status;
+
+}

+ 85 - 0
blade-service-api/blade-los-api/src/main/java/org/springblade/los/box/excel/RentalBoxItemExcel.java

@@ -0,0 +1,85 @@
+/*
+ *      Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
+ *
+ *  Redistribution and use in source and binary forms, with or without
+ *  modification, are permitted provided that the following conditions are met:
+ *
+ *  Redistributions of source code must retain the above copyright notice,
+ *  this list of conditions and the following disclaimer.
+ *  Redistributions in binary form must reproduce the above copyright
+ *  notice, this list of conditions and the following disclaimer in the
+ *  documentation and/or other materials provided with the distribution.
+ *  Neither the name of the dreamlu.net developer nor the names of its
+ *  contributors may be used to endorse or promote products derived from
+ *  this software without specific prior written permission.
+ *  Author: Chill 庄骞 (smallchill@163.com)
+ */
+package org.springblade.los.box.excel;
+
+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 lombok.Data;
+
+import java.io.Serializable;
+import java.math.BigDecimal;
+
+@Data
+@ColumnWidth(25)
+@HeadRowHeight(20)
+@ContentRowHeight(18)
+public class RentalBoxItemExcel implements Serializable {
+
+	private static final long serialVersionUID = 1L;
+
+	/**
+	 * 箱号
+	 */
+	@ExcelProperty(value = "箱号*")
+	private String code;
+	/**
+	 * 箱类型
+	 */
+	@ExcelProperty(value = "箱型*")
+	private String boxType;
+	/**
+	 * 箱好坏
+	 */
+	@ExcelProperty(value = "箱好坏*")
+	private String boxStatus;
+
+	/**
+	 * 箱况
+	 */
+	@ExcelProperty(value = "箱况(新/旧)*")
+	private String boxCondition;
+	/**
+	 * 场站
+	 */
+	@ExcelProperty(value = "场站*")
+	private String stationCname;
+
+	/**
+	 * 币别
+	 */
+	@ExcelProperty(value = "币别*")
+	private String currency;
+
+	/**
+	 * 限制港口
+	 */
+	@ExcelProperty(value = "限制港口")
+	private String restrictedPortsName;
+
+	/**
+	 * 限制船公司
+	 */
+	@ExcelProperty(value = "限制船公司")
+	private String restrictingShippingCompaniesName;
+
+
+
+
+
+}

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

@@ -119,7 +119,7 @@ public class BoxPoolController extends BladeController {
 	@GetMapping("/giveAnEncore/template")
 	public void giveAnEncoreTemplate(HttpServletResponse response) {
 		List<GiveAnEncore> list = new ArrayList<>();
-		ExcelUtil.export(response, "空箱出场模板", "空箱出场", list, GiveAnEncore.class);
+		ExcelUtil.export(response, "POD返场模板", "POD返场", list, GiveAnEncore.class);
 	}
 
 	/**

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

@@ -198,6 +198,11 @@ public class PutBoxController extends BladeController {
 			lambdaQueryWrapper.eq(ObjectUtils.isNotNull(putBox.getCabinType()), PutBox::getCabinType, putBox.getCabinType());
 			lambdaQueryWrapper.eq(ObjectUtils.isNotNull(putBox.getAirlineId()), PutBox::getAirlineId, putBox.getAirlineId());
 		}
+		if (ObjectUtils.isNotNull(putBox.getEtd())) {
+			SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
+			lambdaQueryWrapper.apply("DATE_FORMAT(effective_start_date,'%Y-%m-%d') <= '" + formatter.format(putBox.getEtd()) + "'")
+				.apply( "DATE_FORMAT(effective_end_date,'%Y-%m-%d') >= '" + formatter.format(putBox.getEtd()) + "'");
+		}
 		List<PutBox> putBoxList = putBoxService.list(lambdaQueryWrapper);
 		List<SeaContainerNumberItem> containerNumberItemList = new ArrayList<>();
 		for (PutBox item : putBoxList) {

+ 17 - 1
blade-service/blade-los/src/main/java/org/springblade/los/box/controller/PutBoxItemsController.java

@@ -25,16 +25,19 @@ import io.swagger.annotations.ApiOperation;
 import io.swagger.annotations.ApiParam;
 import lombok.AllArgsConstructor;
 import org.springblade.core.boot.ctrl.BladeController;
+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.secure.utils.AuthUtil;
 import org.springblade.core.tool.api.R;
+import org.springblade.core.tool.utils.BeanUtil;
 import org.springblade.core.tool.utils.Func;
 import org.springblade.los.box.entity.PutBoxItems;
+import org.springblade.los.box.excel.PutBoxItemExcel;
 import org.springblade.los.box.service.IPutBoxItemsService;
-import org.springblade.los.box.vo.PutBoxItemsVO;
 import org.springframework.web.bind.annotation.*;
 
+import javax.servlet.http.HttpServletResponse;
 import javax.validation.Valid;
 import java.util.List;
 import java.util.stream.Collectors;
@@ -125,4 +128,17 @@ public class PutBoxItemsController extends BladeController {
 	}
 
 
+	/**
+	 * 导出放箱号箱明细数据
+	 */
+	@GetMapping("/exportBoxItem")
+	public void exportBoxItem(HttpServletResponse response, Long pid) {
+		List<PutBoxItems> list = putBoxItemsService.list(new LambdaQueryWrapper<PutBoxItems>()
+			.eq(PutBoxItems::getTenantId, AuthUtil.getTenantId())
+			.eq(PutBoxItems::getIsDeleted, 0)
+			.eq(PutBoxItems::getPid, pid));
+		ExcelUtil.export(response, "放箱号-箱明细", "箱明细", BeanUtil.copy(list, PutBoxItemExcel.class), PutBoxItemExcel.class);
+	}
+
+
 }

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

@@ -34,6 +34,8 @@ import org.springblade.core.tool.api.R;
 import org.springblade.core.tool.utils.Func;
 import org.springblade.los.box.entity.TradingBox;
 import org.springblade.los.box.entity.TradingBoxItem;
+import org.springblade.los.box.excel.AgentBoxItemExcel;
+import org.springblade.los.box.excel.RentalBoxItemExcel;
 import org.springblade.los.box.excel.TradingBoxItemExcel;
 import org.springblade.los.box.service.ITradingBoxItemService;
 import org.springblade.los.box.service.ITradingBoxService;
@@ -284,18 +286,26 @@ public class TradingBoxItemController extends BladeController {
 	 */
 	@PostMapping("/importBoxItem")
 	@RepeatSubmit
-	public R importBoxItem(@RequestParam("file") MultipartFile file, @RequestParam("id") Long id) {
-		return tradingBoxItemService.importBoxItem(file, id);
+	public R importBoxItem(@RequestParam("file") MultipartFile file, @RequestParam("id") Long id,
+						   @RequestParam("type") String type) {
+		return tradingBoxItemService.importBoxItem(file, id,type);
 	}
 
 	/**
-	 * 导入箱明细模板
+	 * 导入箱明细模板-买箱
 	 */
 	@GetMapping("/boxItemTemplate")
-	public void boxItemTemplate(HttpServletResponse response) {
-		List<TradingBoxItemExcel> list = new ArrayList<>();
-		ExcelUtil.export(response, "箱明细模板", "箱明细模板", list, TradingBoxItemExcel.class);
+	public void boxItemTemplate(HttpServletResponse response,String type) {
+		if ("1".equals(type)){
+			List<TradingBoxItemExcel> list = new ArrayList<>();
+			ExcelUtil.export(response, "导入箱明细模板-买箱", "箱明细", list, TradingBoxItemExcel.class);
+		}else if ("3".equals(type)){
+			List<AgentBoxItemExcel> list = new ArrayList<>();
+			ExcelUtil.export(response, "导入箱明细模板-代理箱", "箱明细", list, AgentBoxItemExcel.class);
+		}else if ("2".equals(type)){
+			List<RentalBoxItemExcel> list = new ArrayList<>();
+			ExcelUtil.export(response, "导入箱明细模板-租箱", "箱明细", list, RentalBoxItemExcel.class);
+		}
 	}
 
-
 }

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

@@ -41,5 +41,5 @@ public interface ITradingBoxItemService extends IService<TradingBoxItem> {
 	 */
 	IPage<TradingBoxItemVO> selectTradingBoxItemPage(IPage<TradingBoxItemVO> page, TradingBoxItemVO tradingBoxItem);
 
-    R importBoxItem(MultipartFile file,Long id);
+    R importBoxItem(MultipartFile file,Long id,String type);
 }

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

@@ -805,7 +805,7 @@ public class PutBoxServiceImpl extends ServiceImpl<PutBoxMapper, PutBox> impleme
 					if (putBoxItem != null) {
 						putBoxItem.setPid(putBox.getId());
 						putBoxItem.setMblno(item.getMblno());
-						putBoxItem.setBoxDynamics(item.getBoxStatus());
+						putBoxItem.setBoxDynamics("空箱出场");
 						putBoxItem.setPolCyId(corps.getId());
 						putBoxItem.setPolCyCode(corps.getCode());
 						putBoxItem.setPolCyCname(corps.getCnName());
@@ -824,7 +824,7 @@ public class PutBoxServiceImpl extends ServiceImpl<PutBoxMapper, PutBox> impleme
 						putBoxItem.setBoxCode(item.getBoxCode());
 						putBoxItem.setBoxType(item.getBoxType());
 						putBoxItem.setMblno(item.getMblno());
-						putBoxItem.setBoxDynamics(item.getBoxStatus());
+						putBoxItem.setBoxDynamics("空箱出场");
 						putBoxItem.setPolCyId(corps.getId());
 						putBoxItem.setPolCyCode(corps.getCode());
 						putBoxItem.setPolCyCname(corps.getCnName());
@@ -843,7 +843,7 @@ public class PutBoxServiceImpl extends ServiceImpl<PutBoxMapper, PutBox> impleme
 					putBoxItem.setBoxCode(item.getBoxCode());
 					putBoxItem.setBoxType(item.getBoxType());
 					putBoxItem.setMblno(item.getMblno());
-					putBoxItem.setBoxDynamics(item.getBoxStatus());
+					putBoxItem.setBoxDynamics("空箱出场");
 					putBoxItem.setPolCyId(corps.getId());
 					putBoxItem.setPolCyCode(corps.getCode());
 					putBoxItem.setPolCyCname(corps.getCnName());
@@ -872,7 +872,7 @@ public class PutBoxServiceImpl extends ServiceImpl<PutBoxMapper, PutBox> impleme
 								if (tradingBoxItem != null) {
 									tradingBoxItem.setPid(tradingBox.getId());
 									tradingBoxItem.setMblno(item.getMblno());
-									tradingBoxItem.setBoxDynamics(item.getBoxStatus());
+									tradingBoxItem.setBoxDynamics("空箱出场");
 									tradingBoxItem.setPortId(ports.getId());
 									tradingBoxItem.setPortCode(ports.getCode());
 									tradingBoxItem.setPortCname(ports.getCnName());
@@ -906,7 +906,7 @@ public class PutBoxServiceImpl extends ServiceImpl<PutBoxMapper, PutBox> impleme
 									tradingBoxItem.setContainerNumber(item.getContainerNumber());
 									tradingBoxItem.setCode(item.getBoxCode());
 									tradingBoxItem.setMblno(item.getMblno());
-									tradingBoxItem.setBoxDynamics(item.getBoxStatus());
+									tradingBoxItem.setBoxDynamics("空箱出场");
 									tradingBoxItem.setBoxType(cntrTypes.getCnName());
 									tradingBoxItem.setBoxTypeId(cntrTypes.getId());
 									tradingBoxItem.setPortId(ports.getId());
@@ -943,7 +943,7 @@ public class PutBoxServiceImpl extends ServiceImpl<PutBoxMapper, PutBox> impleme
 								tradingBoxItem.setContainerNumber(item.getContainerNumber());
 								tradingBoxItem.setCode(item.getBoxCode());
 								tradingBoxItem.setMblno(item.getMblno());
-								tradingBoxItem.setBoxDynamics(item.getBoxStatus());
+								tradingBoxItem.setBoxDynamics("空箱出场");
 								tradingBoxItem.setBoxType(cntrTypes.getCnName());
 								tradingBoxItem.setBoxTypeId(cntrTypes.getId());
 								tradingBoxItem.setPortId(ports.getId());
@@ -1064,7 +1064,7 @@ public class PutBoxServiceImpl extends ServiceImpl<PutBoxMapper, PutBox> impleme
 					archivesTrajectory.setBoxEastId(item.getBoxEastId());
 					archivesTrajectory.setBoxEastName(item.getBoxEastName());
 					archivesTrajectory.setMblno(item.getMblno());
-					archivesTrajectory.setBoxDynamics(item.getBoxDynamics());
+					archivesTrajectory.setBoxDynamics("空箱出场");
 					archivesTrajectory.setNewDate(tradingBox.getRentDate());
 					if ("OW-N".equals(tradingBox.getType())) {
 						archivesTrajectory.setStatus("OW-拿");
@@ -1353,7 +1353,7 @@ public class PutBoxServiceImpl extends ServiceImpl<PutBoxMapper, PutBox> impleme
 					if (putBoxItem != null) {
 						putBoxItem.setPid(putBox.getId());
 						putBoxItem.setMblno(item.getMblno());
-						putBoxItem.setBoxDynamics(item.getBoxStatus());
+						putBoxItem.setBoxDynamics("空箱进场");
 						putBoxItem.setPolCyId(corps.getId());
 						putBoxItem.setPolCyCode(corps.getCode());
 						putBoxItem.setPolCyCname(corps.getCnName());
@@ -1369,7 +1369,7 @@ public class PutBoxServiceImpl extends ServiceImpl<PutBoxMapper, PutBox> impleme
 						putBoxItem.setBoxCode(item.getBoxCode());
 						putBoxItem.setBoxType(item.getBoxType());
 						putBoxItem.setMblno(item.getMblno());
-						putBoxItem.setBoxDynamics(item.getBoxStatus());
+						putBoxItem.setBoxDynamics("空箱进场");
 						putBoxItem.setPolCyId(corps.getId());
 						putBoxItem.setPolCyCode(corps.getCode());
 						putBoxItem.setPolCyCname(corps.getCnName());
@@ -1386,7 +1386,7 @@ public class PutBoxServiceImpl extends ServiceImpl<PutBoxMapper, PutBox> impleme
 					putBoxItem.setBoxCode(item.getBoxCode());
 					putBoxItem.setBoxType(item.getBoxType());
 					putBoxItem.setMblno(item.getMblno());
-					putBoxItem.setBoxDynamics(item.getBoxStatus());
+					putBoxItem.setBoxDynamics("空箱进场");
 					putBoxItem.setPolCyId(corps.getId());
 					putBoxItem.setPolCyCode(corps.getCode());
 					putBoxItem.setPolCyCname(corps.getCnName());
@@ -1416,7 +1416,7 @@ public class PutBoxServiceImpl extends ServiceImpl<PutBoxMapper, PutBox> impleme
 					archivesTrajectory.setBoxEastId(item.getBoxEastId());
 					archivesTrajectory.setBoxEastName(item.getBoxEastName());
 					archivesTrajectory.setMblno(item.getMblno());
-					archivesTrajectory.setBoxDynamics(item.getBoxDynamics());
+					archivesTrajectory.setBoxDynamics("空箱进场");
 					archivesTrajectory.setStatus(item.getBoxDynamics());
 					archivesTrajectory.setBillType(putBox.getBusType());
 					archivesTrajectory.setCode(item.getBoxCode());
@@ -1510,7 +1510,7 @@ public class PutBoxServiceImpl extends ServiceImpl<PutBoxMapper, PutBox> impleme
 							tradingBoxItem.setPodStationCname(corps.getCnName());
 							tradingBoxItem.setPodStationEname(corps.getEnName());
 							tradingBoxItem.setPodEmptyContainerReturnDate(item.getBoxStatusDate());
-							tradingBoxItem.setBoxDynamics(item.getBoxStatus());
+							tradingBoxItem.setBoxDynamics("空箱进场");
 							tradingBoxItem.setStatus("待使用");
 							tradingBoxItem.setPortId(ports.getId());
 							tradingBoxItem.setPortCname(ports.getCnName());
@@ -1567,7 +1567,7 @@ public class PutBoxServiceImpl extends ServiceImpl<PutBoxMapper, PutBox> impleme
 					putBoxItem.setPodStationEname(corps.getEnName());
 					putBoxItem.setPodEmptyContainerReturnDate(item.getBoxStatusDate());
 					putBoxItem.setStatus("待使用");
-					putBoxItem.setBoxDynamics(item.getBoxStatus());
+					putBoxItem.setBoxDynamics("空箱进场");
 					putBoxItemsOldList.add(putBoxItem);
 				} else {
 					throw new RuntimeException("未查到原放箱号:" + archives.getContainerNumber() + "中箱号为:" + item.getBoxCode() + "数据");
@@ -2239,7 +2239,7 @@ public class PutBoxServiceImpl extends ServiceImpl<PutBoxMapper, PutBox> impleme
 					if (putBoxItem != null) {
 						putBoxItem.setPid(putBox.getId());
 						putBoxItem.setMblno(item.getMblno());
-						putBoxItem.setBoxDynamics(item.getBoxStatus());
+						putBoxItem.setBoxDynamics("空箱提箱进场");
 						putBoxItem.setPolCyId(corps.getId());
 						putBoxItem.setPolCyCode(corps.getCode());
 						putBoxItem.setPolCyCname(corps.getCnName());
@@ -2258,7 +2258,7 @@ public class PutBoxServiceImpl extends ServiceImpl<PutBoxMapper, PutBox> impleme
 						putBoxItem.setBoxCode(item.getBoxCode());
 						putBoxItem.setBoxType(item.getBoxType());
 						putBoxItem.setMblno(item.getMblno());
-						putBoxItem.setBoxDynamics(item.getBoxStatus());
+						putBoxItem.setBoxDynamics("空箱提箱进场");
 						putBoxItem.setPolCyId(corps.getId());
 						putBoxItem.setPolCyCode(corps.getCode());
 						putBoxItem.setPolCyCname(corps.getCnName());
@@ -2277,7 +2277,7 @@ public class PutBoxServiceImpl extends ServiceImpl<PutBoxMapper, PutBox> impleme
 					putBoxItem.setBoxCode(item.getBoxCode());
 					putBoxItem.setBoxType(item.getBoxType());
 					putBoxItem.setMblno(item.getMblno());
-					putBoxItem.setBoxDynamics(item.getBoxStatus());
+					putBoxItem.setBoxDynamics("空箱提箱进场");
 					putBoxItem.setPolCyId(corps.getId());
 					putBoxItem.setPolCyCode(corps.getCode());
 					putBoxItem.setPolCyCname(corps.getCnName());
@@ -2306,7 +2306,7 @@ public class PutBoxServiceImpl extends ServiceImpl<PutBoxMapper, PutBox> impleme
 								if (tradingBoxItem != null) {
 									tradingBoxItem.setPid(tradingBox.getId());
 									tradingBoxItem.setMblno(item.getMblno());
-									tradingBoxItem.setBoxDynamics(item.getBoxStatus());
+									tradingBoxItem.setBoxDynamics("空箱提箱进场");
 									tradingBoxItem.setPortId(ports.getId());
 									tradingBoxItem.setPortCode(ports.getCode());
 									tradingBoxItem.setPortCname(ports.getCnName());
@@ -2342,7 +2342,7 @@ public class PutBoxServiceImpl extends ServiceImpl<PutBoxMapper, PutBox> impleme
 									tradingBoxItem.setContainerNumber(item.getContainerNumber());
 									tradingBoxItem.setCode(item.getBoxCode());
 									tradingBoxItem.setMblno(item.getMblno());
-									tradingBoxItem.setBoxDynamics(item.getBoxStatus());
+									tradingBoxItem.setBoxDynamics("空箱提箱进场");
 									tradingBoxItem.setBoxType(cntrTypes.getCnName());
 									tradingBoxItem.setBoxTypeId(cntrTypes.getId());
 									tradingBoxItem.setPortId(ports.getId());
@@ -2381,7 +2381,7 @@ public class PutBoxServiceImpl extends ServiceImpl<PutBoxMapper, PutBox> impleme
 								tradingBoxItem.setContainerNumber(item.getContainerNumber());
 								tradingBoxItem.setCode(item.getBoxCode());
 								tradingBoxItem.setMblno(item.getMblno());
-								tradingBoxItem.setBoxDynamics(item.getBoxStatus());
+								tradingBoxItem.setBoxDynamics("空箱提箱进场");
 								tradingBoxItem.setBoxType(cntrTypes.getCnName());
 								tradingBoxItem.setBoxTypeId(cntrTypes.getId());
 								tradingBoxItem.setPortId(ports.getId());
@@ -2484,7 +2484,7 @@ public class PutBoxServiceImpl extends ServiceImpl<PutBoxMapper, PutBox> impleme
 					archivesTrajectory.setBoxEastId(item.getBoxEastId());
 					archivesTrajectory.setBoxEastName(item.getBoxEastName());
 					archivesTrajectory.setMblno(item.getMblno());
-					archivesTrajectory.setBoxDynamics(item.getBoxDynamics());
+					archivesTrajectory.setBoxDynamics("空箱提箱进场");
 					archivesTrajectory.setNewDate(tradingBox.getRentDate());
 					if ("OW-N".equals(tradingBox.getType())) {
 						archivesTrajectory.setStatus("OW-拿");

+ 449 - 130
blade-service/blade-los/src/main/java/org/springblade/los/box/service/impl/TradingBoxItemServiceImpl.java

@@ -31,11 +31,12 @@ import org.springblade.los.basic.cntr.service.IBCntrTypesService;
 import org.springblade.los.basic.corps.entity.BCorps;
 import org.springblade.los.basic.corps.service.IBCorpsService;
 import org.springblade.los.basic.cur.entity.BCurExrate;
-import org.springblade.los.basic.cur.service.IBCurrencyService;
 import org.springblade.los.basic.ports.entity.BPorts;
 import org.springblade.los.basic.ports.service.IBPortsService;
 import org.springblade.los.box.entity.TradingBox;
 import org.springblade.los.box.entity.TradingBoxItem;
+import org.springblade.los.box.excel.AgentBoxItemExcel;
+import org.springblade.los.box.excel.RentalBoxItemExcel;
 import org.springblade.los.box.excel.TradingBoxItemExcel;
 import org.springblade.los.box.mapper.TradingBoxItemMapper;
 import org.springblade.los.box.mapper.TradingBoxMapper;
@@ -79,52 +80,158 @@ public class TradingBoxItemServiceImpl extends ServiceImpl<TradingBoxItemMapper,
 
 	@Override
 	@Transactional(rollbackFor = Exception.class)
-	public R importBoxItem(MultipartFile file, Long id) {
+	public R importBoxItem(MultipartFile file, Long id, String type) {
 		if (id == null) {
 			throw new RuntimeException("缺少必要参数");
 		}
-		//导入数据
-		List<TradingBoxItemExcel> excelList = ExcelUtil.read(file, TradingBoxItemExcel.class);
-		if (CollectionUtils.isEmpty(excelList)) {
-			throw new SecurityException("数据不能为空");
-		}
 		TradingBox tradingBox = tradingBoxMapper.selectById(id);
 		if (tradingBox == null) {
 			throw new RuntimeException("未查到单据信息");
 		}
-		//箱号拼接字符串
-		List<String> codes = excelList.stream().map(TradingBoxItemExcel::getCode).distinct().collect(Collectors.toList());
-		if (excelList.size() != codes.size()) {
-			throw new RuntimeException("本单据明细存在重复箱号,操作失败!");
+		Date date;
+		if ("DL,ZR".contains(tradingBox.getType())) {
+			date = tradingBox.getEffectiveDate();
+		} else if ("BUY".contains(tradingBox.getType())) {
+			date = tradingBox.getPurchaseDate();
+		} else {
+			date = new Date();
 		}
-		List<TradingBoxItem> itemList = baseMapper.selectList(new LambdaQueryWrapper<TradingBoxItem>()
-			.eq(TradingBoxItem::getTenantId, AuthUtil.getTenantId())
-			.eq(TradingBoxItem::getIsDeleted, 0)
-			.eq(TradingBoxItem::getPid, id)
-			.in(TradingBoxItem::getCode, codes));
-		for (TradingBoxItemExcel item : excelList) {
-			if (ObjectUtils.isNull(item.getCode())) {
-				throw new RuntimeException("箱号不能为空");
+		String exrateType = currencyUtils.standardCurrency(AuthUtil.getDeptId());
+		List<BCurExrate> curExrateList = currencyUtils.obtainRate(date, "1", AuthUtil.getDeptId());
+		BigDecimal exrateC = currencyUtils.obtainExrate("C", curExrateList, "USD", "1");
+		List<String> codes=new ArrayList<>();
+		List<String> boxType=new ArrayList<>();
+		String portName = "";
+		String stationName = "";
+		String cyCname = "";
+		List<TradingBoxItem> tradingBoxItemList = new ArrayList<>();
+		if ("1".equals(type)) {
+			//导入数据
+			List<TradingBoxItemExcel> excelList = ExcelUtil.read(file, TradingBoxItemExcel.class);
+			if (CollectionUtils.isEmpty(excelList)) {
+				throw new SecurityException("数据不能为空");
+			}
+			//箱号拼接字符串
+			codes = excelList.stream().map(TradingBoxItemExcel::getCode).distinct().collect(Collectors.toList());
+			if (excelList.size() != codes.size()) {
+				throw new RuntimeException("本单据明细存在重复箱号,操作失败!");
+			}
+			for (TradingBoxItemExcel item : excelList) {
+				if (ObjectUtils.isNull(item.getCode())) {
+					throw new RuntimeException("箱号不能为空");
+				}
+				if (ObjectUtils.isNull(item.getBoxType())) {
+					throw new RuntimeException("箱型不能为空");
+				}
+				item.setBoxType(item.getBoxType().toUpperCase());
+				if (ObjectUtils.isNull(item.getBoxStatus())) {
+					throw new RuntimeException("箱好坏不能为空");
+				}
+				if (ObjectUtils.isNull(item.getBoxCondition())) {
+					throw new RuntimeException("箱况不能为空");
+				}
+				if (ObjectUtils.isNull(item.getCurrency())) {
+					throw new RuntimeException("币别不能为空");
+				}
+				if (ObjectUtils.isNull(item.getAmount())) {
+					throw new RuntimeException("金额不能为空");
+				}
 			}
-			if (ObjectUtils.isNull(item.getBoxType())) {
-				throw new RuntimeException("箱型不能为空");
+			boxType = excelList.stream().map(TradingBoxItemExcel::getBoxType).filter(Objects::nonNull)
+				.distinct().collect(Collectors.toList());
+			portName = excelList.stream().map(TradingBoxItemExcel::getRestrictedPortsName).filter(Objects::nonNull)
+				.distinct().collect(Collectors.joining(","));
+			stationName = excelList.stream().map(TradingBoxItemExcel::getRestrictingShippingCompaniesName).filter(Objects::nonNull)
+				.distinct().collect(Collectors.joining(","));
+		} else if("2".equals(type)) {
+			//导入数据
+			List<RentalBoxItemExcel> excelList = ExcelUtil.read(file, RentalBoxItemExcel.class);
+			if (CollectionUtils.isEmpty(excelList)) {
+				throw new SecurityException("数据不能为空");
 			}
-			item.setBoxType(item.getBoxType().toUpperCase());
-			if (ObjectUtils.isNull(item.getBoxStatus())) {
-				throw new RuntimeException("箱好坏不能为空");
+			//箱号拼接字符串
+			codes = excelList.stream().map(RentalBoxItemExcel::getCode).distinct().collect(Collectors.toList());
+			if (excelList.size() != codes.size()) {
+				throw new RuntimeException("本单据明细存在重复箱号,操作失败!");
+			}
+			for (RentalBoxItemExcel item : excelList) {
+				if (ObjectUtils.isNull(item.getCode())) {
+					throw new RuntimeException("箱号不能为空");
+				}
+				if (ObjectUtils.isNull(item.getBoxType())) {
+					throw new RuntimeException("箱型不能为空");
+				}
+				item.setBoxType(item.getBoxType().toUpperCase());
+				if (ObjectUtils.isNull(item.getBoxStatus())) {
+					throw new RuntimeException("箱好坏不能为空");
+				}
+				if (ObjectUtils.isNull(item.getBoxCondition())) {
+					throw new RuntimeException("箱况不能为空");
+				}
+				if (ObjectUtils.isNull(item.getCurrency())) {
+					throw new RuntimeException("币别不能为空");
+				}
+				if (ObjectUtils.isNull(item.getStationCname())) {
+					throw new RuntimeException("场站不能为空");
+				}
 			}
-			if (ObjectUtils.isNull(item.getBoxCondition())) {
-				throw new RuntimeException("箱况不能为空");
+			boxType = excelList.stream().map(RentalBoxItemExcel::getBoxType).filter(Objects::nonNull)
+				.distinct().collect(Collectors.toList());
+			portName = excelList.stream().map(RentalBoxItemExcel::getRestrictedPortsName).filter(Objects::nonNull)
+				.distinct().collect(Collectors.joining(","));
+			stationName = excelList.stream().map(RentalBoxItemExcel::getRestrictingShippingCompaniesName).filter(Objects::nonNull)
+				.distinct().collect(Collectors.joining(","));
+			cyCname = excelList.stream().map(RentalBoxItemExcel::getStationCname).filter(Objects::nonNull)
+				.distinct().collect(Collectors.joining(","));
+		}else if("3".equals(type)) {
+			//导入数据
+			List<AgentBoxItemExcel> excelList = ExcelUtil.read(file, AgentBoxItemExcel.class);
+			if (CollectionUtils.isEmpty(excelList)) {
+				throw new SecurityException("数据不能为空");
 			}
-			if (ObjectUtils.isNull(item.getCurrency())) {
-				throw new RuntimeException("币别不能为空");
+			//箱号拼接字符串
+			codes = excelList.stream().map(AgentBoxItemExcel::getCode).distinct().collect(Collectors.toList());
+			if (excelList.size() != codes.size()) {
+				throw new RuntimeException("本单据明细存在重复箱号,操作失败!");
 			}
-			if (ObjectUtils.isNull(item.getAmount())) {
-				throw new RuntimeException("金额不能为空");
+			for (AgentBoxItemExcel item : excelList) {
+				if (ObjectUtils.isNull(item.getCode())) {
+					throw new RuntimeException("箱号不能为空");
+				}
+				if (ObjectUtils.isNull(item.getBoxType())) {
+					throw new RuntimeException("箱型不能为空");
+				}
+				item.setBoxType(item.getBoxType().toUpperCase());
+				if (ObjectUtils.isNull(item.getBoxStatus())) {
+					throw new RuntimeException("箱好坏不能为空");
+				}
+				if (ObjectUtils.isNull(item.getBoxCondition())) {
+					throw new RuntimeException("箱况不能为空");
+				}
+				if (ObjectUtils.isNull(item.getCurrency())) {
+					throw new RuntimeException("币别不能为空");
+				}
+				if (ObjectUtils.isNull(item.getStationCname())) {
+					throw new RuntimeException("场站不能为空");
+				}
+				if (ObjectUtils.isNull(item.getAmount())) {
+					throw new RuntimeException("金额不能为空");
+				}
 			}
+			boxType = excelList.stream().map(AgentBoxItemExcel::getBoxType).filter(Objects::nonNull)
+				.distinct().collect(Collectors.toList());
+			portName = excelList.stream().map(AgentBoxItemExcel::getRestrictedPortsName).filter(Objects::nonNull)
+				.distinct().collect(Collectors.joining(","));
+			stationName = excelList.stream().map(AgentBoxItemExcel::getRestrictingShippingCompaniesName).filter(Objects::nonNull)
+				.distinct().collect(Collectors.joining(","));
+			cyCname = excelList.stream().map(AgentBoxItemExcel::getStationCname).filter(Objects::nonNull)
+				.distinct().collect(Collectors.joining(","));
 		}
-		List<String> boxType = excelList.stream().map(TradingBoxItemExcel::getBoxType).filter(Objects::nonNull)
-			.distinct().collect(Collectors.toList());
+		List<TradingBoxItem> itemList = baseMapper.selectList(new LambdaQueryWrapper<TradingBoxItem>()
+			.eq(TradingBoxItem::getTenantId, AuthUtil.getTenantId())
+			.eq(TradingBoxItem::getIsDeleted, 0)
+			.eq(TradingBoxItem::getPid, id)
+			.in(TradingBoxItem::getCode, codes));
 		List<BCntrTypes> cntrTypesList = bCntrTypesService.list(new LambdaQueryWrapper<BCntrTypes>()
 			.eq(BCntrTypes::getTenantId, AuthUtil.getTenantId())
 			.eq(BCntrTypes::getIsDeleted, 0)
@@ -132,8 +239,6 @@ public class TradingBoxItemServiceImpl extends ServiceImpl<TradingBoxItemMapper,
 		if (cntrTypesList.isEmpty()) {
 			throw new RuntimeException("未查到箱型数据");
 		}
-		String portName = excelList.stream().map(TradingBoxItemExcel::getRestrictedPortsName).filter(Objects::nonNull)
-			.distinct().collect(Collectors.joining(","));
 		List<BPorts> portsList = new ArrayList<>();
 		if (ObjectUtils.isNotNull(portName)) {
 			portsList = bPortsService.list(new LambdaQueryWrapper<BPorts>()
@@ -141,129 +246,343 @@ public class TradingBoxItemServiceImpl extends ServiceImpl<TradingBoxItemMapper,
 				.eq(BPorts::getIsDeleted, 0)
 				.apply("find_in_set(cn_name,'" + portName + "')"));
 		}
-		String stationName = excelList.stream().map(TradingBoxItemExcel::getRestrictingShippingCompaniesName).filter(Objects::nonNull)
-			.distinct().collect(Collectors.joining(","));
 		if (ObjectUtils.isNotNull(stationName)) {
 			stationName = stationName + ",WFL";
+			if (ObjectUtils.isNotNull(cyCname)) {
+				stationName = stationName + "," + cyCname;
+			}
 		} else {
 			stationName = "WFL";
+			if (ObjectUtils.isNotNull(cyCname)) {
+				stationName = stationName + "," + cyCname;
+			}
 		}
 		List<BCorps> corpsList = bCorpsService.list(new LambdaQueryWrapper<BCorps>()
 			.eq(BCorps::getTenantId, AuthUtil.getTenantId())
 			.eq(BCorps::getIsDeleted, 0)
 			.apply("find_in_set(cn_name,'" + stationName + "')"));
-		Date date;
-		if ("DL,ZR".contains(tradingBox.getType())) {
-			date = tradingBox.getEffectiveDate();
-		} else if ("BUY".contains(tradingBox.getType())) {
-			date = tradingBox.getPurchaseDate();
-		} else {
-			date = new Date();
-		}
-		String exrateType = currencyUtils.standardCurrency(AuthUtil.getDeptId());
-		List<BCurExrate> curExrateList = currencyUtils.obtainRate(date, "1", AuthUtil.getDeptId());
-		BigDecimal exrateC = currencyUtils.obtainExrate("C", curExrateList,  "USD", "1");
-		List<TradingBoxItem> tradingBoxItemList = new ArrayList<>();
-		for (TradingBoxItemExcel item : excelList) {
-			TradingBoxItem tradingBoxItem;
-			if (!itemList.isEmpty()) {
-				tradingBoxItem = itemList.stream().filter(e -> e.getCode().equals(item.getCode())).findFirst().orElse(null);
-				if (tradingBoxItem == null) {
+		if ("1".equals(type)) {
+			List<TradingBoxItemExcel> excelList = ExcelUtil.read(file, TradingBoxItemExcel.class);
+			for (TradingBoxItemExcel item : excelList) {
+				TradingBoxItem tradingBoxItem;
+				if (!itemList.isEmpty()) {
+					tradingBoxItem = itemList.stream().filter(e -> e.getCode().equals(item.getCode())).findFirst().orElse(null);
+					if (tradingBoxItem == null) {
+						tradingBoxItem = new TradingBoxItem();
+					}
+				} else {
 					tradingBoxItem = new TradingBoxItem();
 				}
-			} else {
-				tradingBoxItem = new TradingBoxItem();
-			}
-			if (ObjectUtils.isNotNull(item.getCode())) {
-				tradingBoxItem.setCode(item.getCode().trim());
-				tradingBoxItem.setCode(item.getCode().toUpperCase());
-			}
-			if (!exrateType.equals(item.getCurrency())) {
-				tradingBoxItem.setCurrency(item.getCurrency());
-				tradingBoxItem.setExrate(exrateC);
-			} else {
-				tradingBoxItem.setCurrency(exrateType);
-				tradingBoxItem.setExrate(new BigDecimal("1"));
-			}
-			tradingBoxItem.setAmount(item.getAmount());
-			tradingBoxItem.setBoxCondition(item.getBoxCondition());
-			tradingBoxItem.setBoxStatus(item.getBoxStatus());
-			BCntrTypes bCntrTypes = cntrTypesList.stream().filter(e -> e.getCnName().equals(item.getBoxType())).findFirst().orElse(null);
-			if (bCntrTypes == null) {
-				throw new RuntimeException("箱型:" + item.getBoxType() + "不存在,请先维护基础资料");
-			}
-			tradingBoxItem.setBoxType(bCntrTypes.getCnName());
-			tradingBoxItem.setBoxTypeId(bCntrTypes.getId());
-			if (!portsList.isEmpty() && ObjectUtils.isNotNull(item.getRestrictedPortsName())) {
-				String[] arr = item.getRestrictedPortsName().split(",");
-				StringBuilder portsIds = new StringBuilder();
-				for (String name : arr) {
-					BPorts bPorts = portsList.stream().filter(e -> name.equals(e.getCnName())).findFirst().orElse(null);
-					if (bPorts == null) {
-						throw new RuntimeException("港口:" + name + "不存在,请先维护基础资料");
+				if (ObjectUtils.isNotNull(item.getCode())) {
+					tradingBoxItem.setCode(item.getCode().trim());
+					tradingBoxItem.setCode(item.getCode().toUpperCase());
+				}
+				if (!exrateType.equals(item.getCurrency())) {
+					tradingBoxItem.setCurrency(item.getCurrency());
+					tradingBoxItem.setExrate(exrateC);
+				} else {
+					tradingBoxItem.setCurrency(exrateType);
+					tradingBoxItem.setExrate(new BigDecimal("1"));
+				}
+				tradingBoxItem.setAmount(item.getAmount());
+				tradingBoxItem.setBoxCondition(item.getBoxCondition());
+				tradingBoxItem.setBoxStatus(item.getBoxStatus());
+				BCntrTypes bCntrTypes = cntrTypesList.stream().filter(e -> e.getCnName().equals(item.getBoxType())).findFirst().orElse(null);
+				if (bCntrTypes == null) {
+					throw new RuntimeException("箱型:" + item.getBoxType() + "不存在,请先维护基础资料");
+				}
+				tradingBoxItem.setBoxType(bCntrTypes.getCnName());
+				tradingBoxItem.setBoxTypeId(bCntrTypes.getId());
+				if (!portsList.isEmpty() && ObjectUtils.isNotNull(item.getRestrictedPortsName())) {
+					String[] arr = item.getRestrictedPortsName().split(",");
+					StringBuilder portsIds = new StringBuilder();
+					for (String name : arr) {
+						BPorts bPorts = portsList.stream().filter(e -> name.equals(e.getCnName())).findFirst().orElse(null);
+						if (bPorts == null) {
+							throw new RuntimeException("港口:" + name + "不存在,请先维护基础资料");
+						}
+						portsIds.append(bPorts.getId()).append(",");
+					}
+					if (ObjectUtils.isNotNull(portsIds.toString())) {
+						tradingBoxItem.setRestrictedPortsIds(portsIds.substring(0, portsIds.length() - 1));
+						tradingBoxItem.setRestrictedPortsName(item.getRestrictedPortsName());
 					}
-					portsIds.append(bPorts.getId()).append(",");
 				}
-				if (ObjectUtils.isNotNull(portsIds.toString())) {
-					tradingBoxItem.setRestrictedPortsIds(portsIds.substring(0, portsIds.length() - 1));
-					tradingBoxItem.setRestrictedPortsName(item.getRestrictedPortsName());
+				if (!corpsList.isEmpty()) {
+					if (ObjectUtils.isNotNull(item.getRestrictingShippingCompaniesName())) {
+						String[] arr = item.getRestrictingShippingCompaniesName().split(",");
+						StringBuilder corpIds = new StringBuilder();
+						for (String name : arr) {
+							BCorps bCorps = corpsList.stream().filter(e -> name.equals(e.getCnName())).findFirst().orElse(null);
+							if (bCorps == null) {
+								throw new RuntimeException("船公司:" + name + "不存在,请先维护基础资料");
+							}
+							corpIds.append(bCorps.getId()).append(",");
+						}
+						if (ObjectUtils.isNotNull(corpIds.toString())) {
+							tradingBoxItem.setRestrictingShippingCompaniesIds(corpIds.substring(0, corpIds.length() - 1));
+							tradingBoxItem.setRestrictingShippingCompaniesName(item.getRestrictingShippingCompaniesName());
+						}
+					}
+					BCorps bCorps = corpsList.stream().filter(e -> "WFL".equals(e.getCode())).findFirst().orElse(null);
+					if (bCorps == null) {
+						throw new RuntimeException("箱东:WFL不存在,请先维护基础资料");
+					}
+					if ("BUY".equals(tradingBox.getType())) {
+						tradingBoxItem.setBoxEastId(bCorps.getId());
+						tradingBoxItem.setBoxEastName(bCorps.getCnName());
+						tradingBoxItem.setOriginalBoxEastId(tradingBox.getPurchaseCompanyId());
+						tradingBoxItem.setOriginalBoxEastName(tradingBox.getPurchaseCompanyName());
+					} else if ("DL".equals(tradingBox.getType())) {
+						tradingBoxItem.setBoxEastId(tradingBox.getPurchaseCompanyId());
+						tradingBoxItem.setBoxEastName(tradingBox.getPurchaseCompanyName());
+					} else if ("ZR".equals(tradingBox.getType())) {
+						tradingBoxItem.setBoxEastId(bCorps.getId());
+						tradingBoxItem.setBoxEastName(bCorps.getCnName());
+						tradingBoxItem.setOriginalBoxEastId(tradingBox.getPurchaseCompanyId());
+						tradingBoxItem.setOriginalBoxEastName(tradingBox.getPurchaseCompanyName());
+					}
 				}
+				if ("BUY".equals(tradingBox.getType())) {
+					tradingBoxItem.setBoxCategory("自有箱");
+				} else if ("DL".equals(tradingBox.getType())) {
+					tradingBoxItem.setBoxCategory("代理箱");
+				} else if ("ZR".equals(tradingBox.getType())) {
+					tradingBoxItem.setBoxCategory("自有箱");
+				} else {
+					tradingBoxItem.setBoxCategory("自有箱");
+				}
+				tradingBoxItem.setBoxBelongsTo("SOC");
+				tradingBoxItem.setStatus("待使用");
+				tradingBoxItem.setStationId(tradingBox.getStationId());
+				tradingBoxItem.setStationCname(tradingBox.getStationCname());
+				tradingBoxItem.setStationEname(tradingBox.getStationEname());
+				tradingBoxItem.setStationCode(tradingBox.getStationCode());
+				tradingBoxItem.setCreateUser(AuthUtil.getUserId());
+				tradingBoxItem.setCreateUserName(AuthUtil.getUserName());
+				tradingBoxItem.setCreateTime(new Date());
+				tradingBoxItem.setPid(tradingBox.getId());
+				tradingBoxItemList.add(tradingBoxItem);
 			}
-			if (!corpsList.isEmpty()) {
-				if (ObjectUtils.isNotNull(item.getRestrictingShippingCompaniesName())) {
-					String[] arr = item.getRestrictingShippingCompaniesName().split(",");
-					StringBuilder corpIds = new StringBuilder();
+		} else if("2".equals(type)){
+			//导入数据
+			List<RentalBoxItemExcel> excelList = ExcelUtil.read(file, RentalBoxItemExcel.class);
+			for (RentalBoxItemExcel item : excelList) {
+				TradingBoxItem tradingBoxItem;
+				if (!itemList.isEmpty()) {
+					tradingBoxItem = itemList.stream().filter(e -> e.getCode().equals(item.getCode())).findFirst().orElse(null);
+					if (tradingBoxItem == null) {
+						tradingBoxItem = new TradingBoxItem();
+					}
+				} else {
+					tradingBoxItem = new TradingBoxItem();
+				}
+				if (ObjectUtils.isNotNull(item.getCode())) {
+					tradingBoxItem.setCode(item.getCode().trim());
+					tradingBoxItem.setCode(item.getCode().toUpperCase());
+				}
+				if (!exrateType.equals(item.getCurrency())) {
+					tradingBoxItem.setCurrency(item.getCurrency());
+					tradingBoxItem.setExrate(exrateC);
+				} else {
+					tradingBoxItem.setCurrency(exrateType);
+					tradingBoxItem.setExrate(new BigDecimal("1"));
+				}
+				tradingBoxItem.setBoxCondition(item.getBoxCondition());
+				tradingBoxItem.setBoxStatus(item.getBoxStatus());
+				BCntrTypes bCntrTypes = cntrTypesList.stream().filter(e -> e.getCnName().equals(item.getBoxType())).findFirst().orElse(null);
+				if (bCntrTypes == null) {
+					throw new RuntimeException("箱型:" + item.getBoxType() + "不存在,请先维护基础资料");
+				}
+				tradingBoxItem.setBoxType(bCntrTypes.getCnName());
+				tradingBoxItem.setBoxTypeId(bCntrTypes.getId());
+				if (!portsList.isEmpty() && ObjectUtils.isNotNull(item.getRestrictedPortsName())) {
+					String[] arr = item.getRestrictedPortsName().split(",");
+					StringBuilder portsIds = new StringBuilder();
 					for (String name : arr) {
-						BCorps bCorps = corpsList.stream().filter(e -> name.equals(e.getCnName())).findFirst().orElse(null);
-						if (bCorps == null) {
-							throw new RuntimeException("船公司:" + name + "不存在,请先维护基础资料");
+						BPorts bPorts = portsList.stream().filter(e -> name.equals(e.getCnName())).findFirst().orElse(null);
+						if (bPorts == null) {
+							throw new RuntimeException("港口:" + name + "不存在,请先维护基础资料");
 						}
-						corpIds.append(bCorps.getId()).append(",");
+						portsIds.append(bPorts.getId()).append(",");
 					}
-					if (ObjectUtils.isNotNull(corpIds.toString())) {
-						tradingBoxItem.setRestrictingShippingCompaniesIds(corpIds.substring(0, corpIds.length() - 1));
-						tradingBoxItem.setRestrictingShippingCompaniesName(item.getRestrictingShippingCompaniesName());
+					if (ObjectUtils.isNotNull(portsIds.toString())) {
+						tradingBoxItem.setRestrictedPortsIds(portsIds.substring(0, portsIds.length() - 1));
+						tradingBoxItem.setRestrictedPortsName(item.getRestrictedPortsName());
 					}
 				}
-				BCorps bCorps = corpsList.stream().filter(e -> "WFL".equals(e.getCode())).findFirst().orElse(null);
-				if (bCorps == null) {
-					throw new RuntimeException("箱东:WFL不存在,请先维护基础资料");
+				if (!corpsList.isEmpty()) {
+					if (ObjectUtils.isNotNull(item.getStationCname())) {
+						BCorps bCorps = corpsList.stream().filter(e -> item.getStationCname().equals(e.getCnName())).findFirst().orElse(null);
+						if (bCorps == null) {
+							throw new RuntimeException("场站:" + item.getStationCname() + "不存在,请先维护基础资料");
+						}
+						tradingBoxItem.setStationId(bCorps.getId());
+						tradingBoxItem.setStationCname(bCorps.getCnName());
+						tradingBoxItem.setStationCode(bCorps.getCode());
+						tradingBoxItem.setStationEname(bCorps.getEnName());
+					}
+					if (ObjectUtils.isNotNull(item.getRestrictingShippingCompaniesName())) {
+						String[] arr = item.getRestrictingShippingCompaniesName().split(",");
+						StringBuilder corpIds = new StringBuilder();
+						for (String name : arr) {
+							BCorps bCorps = corpsList.stream().filter(e -> name.equals(e.getCnName())).findFirst().orElse(null);
+							if (bCorps == null) {
+								throw new RuntimeException("船公司:" + name + "不存在,请先维护基础资料");
+							}
+							corpIds.append(bCorps.getId()).append(",");
+						}
+						if (ObjectUtils.isNotNull(corpIds.toString())) {
+							tradingBoxItem.setRestrictingShippingCompaniesIds(corpIds.substring(0, corpIds.length() - 1));
+							tradingBoxItem.setRestrictingShippingCompaniesName(item.getRestrictingShippingCompaniesName());
+						}
+					}
+					BCorps bCorps = corpsList.stream().filter(e -> "WFL".equals(e.getCode())).findFirst().orElse(null);
+					if (bCorps == null) {
+						throw new RuntimeException("箱东:WFL不存在,请先维护基础资料");
+					}
+					if ("BUY".equals(tradingBox.getType())) {
+						tradingBoxItem.setBoxEastId(bCorps.getId());
+						tradingBoxItem.setBoxEastName(bCorps.getCnName());
+						tradingBoxItem.setOriginalBoxEastId(tradingBox.getPurchaseCompanyId());
+						tradingBoxItem.setOriginalBoxEastName(tradingBox.getPurchaseCompanyName());
+					} else if ("DL".equals(tradingBox.getType())) {
+						tradingBoxItem.setBoxEastId(tradingBox.getPurchaseCompanyId());
+						tradingBoxItem.setBoxEastName(tradingBox.getPurchaseCompanyName());
+					} else if ("ZR".equals(tradingBox.getType())) {
+						tradingBoxItem.setBoxEastId(bCorps.getId());
+						tradingBoxItem.setBoxEastName(bCorps.getCnName());
+						tradingBoxItem.setOriginalBoxEastId(tradingBox.getPurchaseCompanyId());
+						tradingBoxItem.setOriginalBoxEastName(tradingBox.getPurchaseCompanyName());
+					}
 				}
 				if ("BUY".equals(tradingBox.getType())) {
-					tradingBoxItem.setBoxEastId(bCorps.getId());
-					tradingBoxItem.setBoxEastName(bCorps.getCnName());
-					tradingBoxItem.setOriginalBoxEastId(tradingBox.getPurchaseCompanyId());
-					tradingBoxItem.setOriginalBoxEastName(tradingBox.getPurchaseCompanyName());
+					tradingBoxItem.setBoxCategory("自有箱");
 				} else if ("DL".equals(tradingBox.getType())) {
-					tradingBoxItem.setBoxEastId(tradingBox.getPurchaseCompanyId());
-					tradingBoxItem.setBoxEastName(tradingBox.getPurchaseCompanyName());
+					tradingBoxItem.setBoxCategory("代理箱");
 				} else if ("ZR".equals(tradingBox.getType())) {
-					tradingBoxItem.setBoxEastId(bCorps.getId());
-					tradingBoxItem.setBoxEastName(bCorps.getCnName());
-					tradingBoxItem.setOriginalBoxEastId(tradingBox.getPurchaseCompanyId());
-					tradingBoxItem.setOriginalBoxEastName(tradingBox.getPurchaseCompanyName());
+					tradingBoxItem.setBoxCategory("自有箱");
+				} else {
+					tradingBoxItem.setBoxCategory("自有箱");
 				}
+				tradingBoxItem.setBoxBelongsTo("SOC");
+				tradingBoxItem.setStatus("待使用");
+				tradingBoxItem.setCreateUser(AuthUtil.getUserId());
+				tradingBoxItem.setCreateUserName(AuthUtil.getUserName());
+				tradingBoxItem.setCreateTime(new Date());
+				tradingBoxItem.setPid(tradingBox.getId());
+				tradingBoxItemList.add(tradingBoxItem);
 			}
-			if ("BUY".equals(tradingBox.getType())) {
-				tradingBoxItem.setBoxCategory("自有箱");
-			} else if ("DL".equals(tradingBox.getType())) {
-				tradingBoxItem.setBoxCategory("代理箱");
-			} else if ("ZR".equals(tradingBox.getType())) {
-				tradingBoxItem.setBoxCategory("自有箱");
-			} else {
-				tradingBoxItem.setBoxCategory("自有箱");
+		}else if("3".equals(type)){
+			//导入数据
+			List<AgentBoxItemExcel> excelList = ExcelUtil.read(file, AgentBoxItemExcel.class);
+			for (AgentBoxItemExcel item : excelList) {
+				TradingBoxItem tradingBoxItem;
+				if (!itemList.isEmpty()) {
+					tradingBoxItem = itemList.stream().filter(e -> e.getCode().equals(item.getCode())).findFirst().orElse(null);
+					if (tradingBoxItem == null) {
+						tradingBoxItem = new TradingBoxItem();
+					}
+				} else {
+					tradingBoxItem = new TradingBoxItem();
+				}
+				if (ObjectUtils.isNotNull(item.getCode())) {
+					tradingBoxItem.setCode(item.getCode().trim());
+					tradingBoxItem.setCode(item.getCode().toUpperCase());
+				}
+				if (!exrateType.equals(item.getCurrency())) {
+					tradingBoxItem.setCurrency(item.getCurrency());
+					tradingBoxItem.setExrate(exrateC);
+				} else {
+					tradingBoxItem.setCurrency(exrateType);
+					tradingBoxItem.setExrate(new BigDecimal("1"));
+				}
+				tradingBoxItem.setBoxCondition(item.getBoxCondition());
+				tradingBoxItem.setBoxStatus(item.getBoxStatus());
+				tradingBoxItem.setAmount(item.getAmount());
+				BCntrTypes bCntrTypes = cntrTypesList.stream().filter(e -> e.getCnName().equals(item.getBoxType())).findFirst().orElse(null);
+				if (bCntrTypes == null) {
+					throw new RuntimeException("箱型:" + item.getBoxType() + "不存在,请先维护基础资料");
+				}
+				tradingBoxItem.setBoxType(bCntrTypes.getCnName());
+				tradingBoxItem.setBoxTypeId(bCntrTypes.getId());
+				if (!portsList.isEmpty() && ObjectUtils.isNotNull(item.getRestrictedPortsName())) {
+					String[] arr = item.getRestrictedPortsName().split(",");
+					StringBuilder portsIds = new StringBuilder();
+					for (String name : arr) {
+						BPorts bPorts = portsList.stream().filter(e -> name.equals(e.getCnName())).findFirst().orElse(null);
+						if (bPorts == null) {
+							throw new RuntimeException("港口:" + name + "不存在,请先维护基础资料");
+						}
+						portsIds.append(bPorts.getId()).append(",");
+					}
+					if (ObjectUtils.isNotNull(portsIds.toString())) {
+						tradingBoxItem.setRestrictedPortsIds(portsIds.substring(0, portsIds.length() - 1));
+						tradingBoxItem.setRestrictedPortsName(item.getRestrictedPortsName());
+					}
+				}
+				if (!corpsList.isEmpty()) {
+					if (ObjectUtils.isNotNull(item.getStationCname())) {
+						BCorps bCorps = corpsList.stream().filter(e -> item.getStationCname().equals(e.getCnName())).findFirst().orElse(null);
+						if (bCorps == null) {
+							throw new RuntimeException("场站:" + item.getStationCname() + "不存在,请先维护基础资料");
+						}
+						tradingBoxItem.setStationId(bCorps.getId());
+						tradingBoxItem.setStationCname(bCorps.getCnName());
+						tradingBoxItem.setStationCode(bCorps.getCode());
+						tradingBoxItem.setStationEname(bCorps.getEnName());
+					}
+					if (ObjectUtils.isNotNull(item.getRestrictingShippingCompaniesName())) {
+						String[] arr = item.getRestrictingShippingCompaniesName().split(",");
+						StringBuilder corpIds = new StringBuilder();
+						for (String name : arr) {
+							BCorps bCorps = corpsList.stream().filter(e -> name.equals(e.getCnName())).findFirst().orElse(null);
+							if (bCorps == null) {
+								throw new RuntimeException("船公司:" + name + "不存在,请先维护基础资料");
+							}
+							corpIds.append(bCorps.getId()).append(",");
+						}
+						if (ObjectUtils.isNotNull(corpIds.toString())) {
+							tradingBoxItem.setRestrictingShippingCompaniesIds(corpIds.substring(0, corpIds.length() - 1));
+							tradingBoxItem.setRestrictingShippingCompaniesName(item.getRestrictingShippingCompaniesName());
+						}
+					}
+					BCorps bCorps = corpsList.stream().filter(e -> "WFL".equals(e.getCode())).findFirst().orElse(null);
+					if (bCorps == null) {
+						throw new RuntimeException("箱东:WFL不存在,请先维护基础资料");
+					}
+					if ("BUY".equals(tradingBox.getType())) {
+						tradingBoxItem.setBoxEastId(bCorps.getId());
+						tradingBoxItem.setBoxEastName(bCorps.getCnName());
+						tradingBoxItem.setOriginalBoxEastId(tradingBox.getPurchaseCompanyId());
+						tradingBoxItem.setOriginalBoxEastName(tradingBox.getPurchaseCompanyName());
+					} else if ("DL".equals(tradingBox.getType())) {
+						tradingBoxItem.setBoxEastId(tradingBox.getPurchaseCompanyId());
+						tradingBoxItem.setBoxEastName(tradingBox.getPurchaseCompanyName());
+					} else if ("ZR".equals(tradingBox.getType())) {
+						tradingBoxItem.setBoxEastId(bCorps.getId());
+						tradingBoxItem.setBoxEastName(bCorps.getCnName());
+						tradingBoxItem.setOriginalBoxEastId(tradingBox.getPurchaseCompanyId());
+						tradingBoxItem.setOriginalBoxEastName(tradingBox.getPurchaseCompanyName());
+					}
+				}
+				if ("BUY".equals(tradingBox.getType())) {
+					tradingBoxItem.setBoxCategory("自有箱");
+				} else if ("DL".equals(tradingBox.getType())) {
+					tradingBoxItem.setBoxCategory("代理箱");
+				} else if ("ZR".equals(tradingBox.getType())) {
+					tradingBoxItem.setBoxCategory("自有箱");
+				} else {
+					tradingBoxItem.setBoxCategory("自有箱");
+				}
+				tradingBoxItem.setBoxBelongsTo("SOC");
+				tradingBoxItem.setStatus("待使用");
+				tradingBoxItem.setCreateUser(AuthUtil.getUserId());
+				tradingBoxItem.setCreateUserName(AuthUtil.getUserName());
+				tradingBoxItem.setCreateTime(new Date());
+				tradingBoxItem.setPid(tradingBox.getId());
+				tradingBoxItemList.add(tradingBoxItem);
 			}
-			tradingBoxItem.setBoxBelongsTo("SOC");
-			tradingBoxItem.setStatus("待使用");
-			tradingBoxItem.setStationId(tradingBox.getStationId());
-			tradingBoxItem.setStationCname(tradingBox.getStationCname());
-			tradingBoxItem.setStationEname(tradingBox.getStationEname());
-			tradingBoxItem.setStationCode(tradingBox.getStationCode());
-			tradingBoxItem.setCreateUser(AuthUtil.getUserId());
-			tradingBoxItem.setCreateUserName(AuthUtil.getUserName());
-			tradingBoxItem.setCreateTime(new Date());
-			tradingBoxItem.setPid(tradingBox.getId());
-			tradingBoxItemList.add(tradingBoxItem);
 		}
 		if (!tradingBoxItemList.isEmpty()) {
 			this.saveOrUpdateBatch(tradingBoxItemList);

+ 20 - 18
blade-service/blade-los/src/main/java/org/springblade/los/box/service/impl/TradingBoxServiceImpl.java

@@ -375,6 +375,7 @@ public class TradingBoxServiceImpl extends ServiceImpl<TradingBoxMapper, Trading
 			BigDecimal amountLocD = new BigDecimal("0.00");
 			BigDecimal amountLocC = new BigDecimal("0.00");
 			for (FeeCenter item : tradingBox.getFeeCenterList()) {
+				item.setAmountLoc(item.getAmount().multiply(item.getExrate()));
 				if (exrateType.equals(item.getCurCode())) {
 					if ("D".equals(item.getDc())) {
 						amountD = amountD.add(item.getAmount());
@@ -385,11 +386,11 @@ public class TradingBoxServiceImpl extends ServiceImpl<TradingBoxMapper, Trading
 					}
 				} else {
 					if ("D".equals(item.getDc())) {
-						amountDUsd = amountDUsd.add(item.getAmountLoc());
-						amountLocD = amountLocD.add(currencyUtils.converter(item.getDc(), curExrateList, item.getAmount(), item.getCurCode(), "1"));
+						amountDUsd = amountDUsd.add(item.getAmount());
+						amountLocD = amountLocD.add(item.getAmountLoc());
 					} else {
-						amountCUsd = amountCUsd.add(item.getAmountLoc());
-						amountLocC = amountLocC.add(currencyUtils.converter(item.getDc(), curExrateList, item.getAmount(), item.getCurCode(), "1"));
+						amountCUsd = amountCUsd.add(item.getAmount());
+						amountLocC = amountLocC.add(item.getAmountLoc());
 					}
 				}
 				item.setPid(tradingBox.getId());
@@ -2235,6 +2236,7 @@ public class TradingBoxServiceImpl extends ServiceImpl<TradingBoxMapper, Trading
 			BigDecimal amountDrLoc = new BigDecimal("0.00");
 			BigDecimal amountCrLoc = new BigDecimal("0.00");
 			for (FeeCenter item : feeCenters) {
+				item.setAmountLoc(item.getAmount().multiply(item.getExrate()));
 				if (exrateType.equals(item.getCurCode())) {
 					if ("D".equals(item.getDc())) {
 						amountD = amountD.add(item.getAmount());
@@ -2245,11 +2247,11 @@ public class TradingBoxServiceImpl extends ServiceImpl<TradingBoxMapper, Trading
 					}
 				} else {
 					if ("D".equals(item.getDc())) {
-						amountDUsd = amountDUsd.add(item.getAmountLoc());
-						amountDrLoc = amountDrLoc.add(currencyUtils.converter(item.getDc(), curExrateList, item.getAmount(), item.getCurCode(), "1"));
+						amountDUsd = amountDUsd.add(item.getAmount());
+						amountDrLoc = amountDrLoc.add(item.getAmountLoc());
 					} else {
-						amountCUsd = amountCUsd.add(item.getAmountLoc());
-						amountCrLoc = amountCrLoc.add(currencyUtils.converter(item.getDc(), curExrateList, item.getAmount(), item.getCurCode(), "1"));
+						amountCUsd = amountCUsd.add(item.getAmount());
+						amountCrLoc = amountCrLoc.add(item.getAmountLoc());
 					}
 				}
 			}
@@ -2325,7 +2327,6 @@ public class TradingBoxServiceImpl extends ServiceImpl<TradingBoxMapper, Trading
 		}
 		if (!feeId.isEmpty()) {
 			String exrateType = currencyUtils.standardCurrency(AuthUtil.getDeptId());
-			List<BCurExrate> curExrateList = currencyUtils.obtainRate(new Date(), "1", AuthUtil.getDeptId());
 			List<FeeCenter> feeCenterList = feeCentersList.stream().filter(e -> !feeId.contains(e.getId())).collect(Collectors.toList());
 			//费用数据
 			BigDecimal amountD = new BigDecimal("0.00");
@@ -2335,6 +2336,7 @@ public class TradingBoxServiceImpl extends ServiceImpl<TradingBoxMapper, Trading
 			BigDecimal amountDrLoc = new BigDecimal("0.00");
 			BigDecimal amountCrLoc = new BigDecimal("0.00");
 			for (FeeCenter item : feeCenterList) {
+				item.setAmountLoc(item.getAmount().multiply(item.getExrate()));
 				if (exrateType.equals(item.getCurCode())) {
 					if ("D".equals(item.getDc())) {
 						amountD = amountD.add(item.getAmount());
@@ -2345,11 +2347,11 @@ public class TradingBoxServiceImpl extends ServiceImpl<TradingBoxMapper, Trading
 					}
 				} else {
 					if ("D".equals(item.getDc())) {
-						amountDUsd = amountDUsd.add(item.getAmountLoc());
-						amountDrLoc = amountDrLoc.add(currencyUtils.converter(item.getDc(), curExrateList, item.getAmount(), item.getCurCode(), "1"));
+						amountDUsd = amountDUsd.add(item.getAmount());
+						amountDrLoc = amountDrLoc.add(item.getAmountLoc());
 					} else {
-						amountCUsd = amountCUsd.add(item.getAmountLoc());
-						amountCrLoc = amountCrLoc.add(currencyUtils.converter(item.getDc(), curExrateList, item.getAmount(), item.getCurCode(), "1"));
+						amountCUsd = amountCUsd.add(item.getAmount());
+						amountCrLoc = amountCrLoc.add(item.getAmountLoc());
 					}
 				}
 			}
@@ -2630,7 +2632,6 @@ public class TradingBoxServiceImpl extends ServiceImpl<TradingBoxMapper, Trading
 		}
 		if (!feeId.isEmpty()) {
 			String exrateType = currencyUtils.standardCurrency(AuthUtil.getDeptId());
-			List<BCurExrate> curExrateList = currencyUtils.obtainRate(new Date(), "1", AuthUtil.getDeptId());
 			List<FeeCenter> feeCenterList = feeCentersList.stream().filter(e -> !feeId.contains(e.getId())).collect(Collectors.toList());
 			//费用数据
 			BigDecimal amountD = new BigDecimal("0.00");
@@ -2640,6 +2641,7 @@ public class TradingBoxServiceImpl extends ServiceImpl<TradingBoxMapper, Trading
 			BigDecimal amountDrLoc = new BigDecimal("0.00");
 			BigDecimal amountCrLoc = new BigDecimal("0.00");
 			for (FeeCenter item : feeCenterList) {
+				item.setAmountLoc(item.getAmount().multiply(item.getExrate()));
 				if (exrateType.equals(item.getCurCode())) {
 					if ("D".equals(item.getDc())) {
 						amountD = amountD.add(item.getAmount());
@@ -2650,11 +2652,11 @@ public class TradingBoxServiceImpl extends ServiceImpl<TradingBoxMapper, Trading
 					}
 				} else {
 					if ("D".equals(item.getDc())) {
-						amountDUsd = amountDUsd.add(item.getAmountLoc());
-						amountDrLoc = amountDrLoc.add(currencyUtils.converter(item.getDc(), curExrateList, item.getAmount(), item.getCurCode(), "1"));
+						amountDUsd = amountDUsd.add(item.getAmount());
+						amountDrLoc = amountDrLoc.add(item.getAmountLoc());
 					} else {
-						amountCUsd = amountCUsd.add(item.getAmountLoc());
-						amountCrLoc = amountCrLoc.add(currencyUtils.converter(item.getDc(), curExrateList, item.getAmount(), item.getCurCode(), "1"));
+						amountCUsd = amountCUsd.add(item.getAmount());
+						amountCrLoc = amountCrLoc.add(item.getAmountLoc());
 					}
 				}
 			}

+ 19 - 8
blade-service/blade-los/src/main/java/org/springblade/los/check/service/impl/AuditProecessServiceImpl.java

@@ -28,7 +28,6 @@ import org.springblade.client.feign.IMessageClient;
 import org.springblade.core.secure.utils.AuthUtil;
 import org.springblade.core.tool.api.R;
 import org.springblade.core.tool.utils.StringUtil;
-import org.springblade.los.Util.IDeptUtils;
 import org.springblade.los.basic.business.entity.BusinessType;
 import org.springblade.los.basic.business.service.IBusinessTypeService;
 import org.springblade.los.basic.corps.entity.BCorps;
@@ -534,25 +533,31 @@ public class AuditProecessServiceImpl extends ServiceImpl<AuditProecessMapper, L
 				item.setAuditStatus("2");
 			} else if (4 == status) {
 				item.setAuditStatus("0");
-			} else {
+			} else if (3 == status) {
 				item.setAuditStatus("4");
+			} else {
+				item.setAuditStatus("0");
 			}
 			int version = StringUtil.isBlank(item.getVersion()) ? 1 : Integer.parseInt(item.getVersion());
 			item.setVersion(String.valueOf(version + 1));
 		}
-		if (3 != status) {
-			feeCenterService.updateBatchById(feeCenterList);
-		}
+		feeCenterService.updateBatchById(feeCenterList);
 		for (Bills item : billsList) {
 			item.setApprovedDate(new Date());
 			int version = StringUtil.isBlank(item.getVersion()) ? 1 : Integer.parseInt(item.getVersion());
 			item.setVersion(String.valueOf(version + 1));
-			item.setStatus(status);
-			if (3 == status) {
+			if (2 == status) {
+				item.setStatus(2);
+			} else if (4 == status) {
+				item.setStatus(0);
+			} else if (3 == status) {
+				item.setStatus(3);
 				item.setBillStatus(status);
+			} else {
+				item.setStatus(0);
 			}
 			List<FeeCenter> feeCenters = feeCenterList.stream().filter(e -> e.getPid().equals(item.getId())).collect(Collectors.toList());
-			if (!feeCenters.isEmpty()) {
+			if (!feeCenters.isEmpty() && 3 == status) {
 				FinAccBills finAccBills = new FinAccBills();
 				finAccBills.setFeeCenterList(feeCenters);
 				finAccBills.setBusinessTypeCode("HYZD");
@@ -1665,6 +1670,8 @@ public class AuditProecessServiceImpl extends ServiceImpl<AuditProecessMapper, L
 				item.setAccById(AuthUtil.getUserId());
 				item.setAccByName(AuthUtil.getUserName());
 				item.setAuditStatus(number);
+				int version = StringUtil.isBlank(item.getVersion()) ? 1 : Integer.parseInt(item.getVersion());
+				item.setVersion(String.valueOf(version + 1));
 			}
 		} else if ("0".equals(number)) {
 			for (FeeCenter item : feeCenterList) {
@@ -1679,6 +1686,8 @@ public class AuditProecessServiceImpl extends ServiceImpl<AuditProecessMapper, L
 				item.setApproverId(AuthUtil.getUserId());
 				item.setApproverName(AuthUtil.getUserName());
 				item.setApproveTime(new Date());
+				int version = StringUtil.isBlank(item.getVersion()) ? 1 : Integer.parseInt(item.getVersion());
+				item.setVersion(String.valueOf(version + 1));
 			}
 		} else {
 			for (FeeCenter item : feeCenterList) {
@@ -1689,6 +1698,8 @@ public class AuditProecessServiceImpl extends ServiceImpl<AuditProecessMapper, L
 				item.setApproverId(AuthUtil.getUserId());
 				item.setApproverName(AuthUtil.getUserName());
 				item.setApproveTime(new Date());
+				int version = StringUtil.isBlank(item.getVersion()) ? 1 : Integer.parseInt(item.getVersion());
+				item.setVersion(String.valueOf(version + 1));
 			}
 		}
 		feeCenterService.updateBatchById(feeCenterList);

+ 20 - 4
blade-service/blade-los/src/main/java/org/springblade/los/finance/fee/service/impl/FeeCenterServiceImpl.java

@@ -816,7 +816,21 @@ public class FeeCenterServiceImpl extends ServiceImpl<FeeCenterMapper, FeeCenter
 				branchId = list.get(0).getBranchId();
 			}
 			String exrateType = currencyUtils.standardCurrency(branchId);
+			List<Long> idList = list.stream().map(FeeCenter::getId).filter(Objects::nonNull).collect(Collectors.toList());
+			List<FeeCenter> feeCenterList1 = new ArrayList<>();
+			if (!idList.isEmpty()) {
+				feeCenterList1 = baseMapper.selectList(new LambdaQueryWrapper<FeeCenter>()
+					.in(FeeCenter::getId, idList));
+			}
 			for (FeeCenter feeCenter : list) {
+				if (feeCenter.getId() != null && !feeCenterList1.isEmpty()) {
+					FeeCenter feeCenter1 = feeCenterList1.stream().filter(e -> e.getId().equals(feeCenter.getId()))
+						.findFirst().orElse(null);
+					if (feeCenter1 != null && !feeCenter.getVersion().equals(feeCenter1.getVersion())) {
+						throw new RuntimeException("数据已被其他用户更新,请等待刷新后重试");
+					}
+				}
+				feeCenter.setAmountLoc(feeCenter.getAmount().multiply(feeCenter.getExrate()));
 				if (exrateType.equals(feeCenter.getCurCode())) {
 					if ("D".equals(feeCenter.getDc())) {
 						amountD = amountD.add(feeCenter.getAmount());
@@ -827,10 +841,10 @@ public class FeeCenterServiceImpl extends ServiceImpl<FeeCenterMapper, FeeCenter
 					}
 				} else {
 					if ("D".equals(feeCenter.getDc())) {
-						amountDUsd = amountDUsd.add(feeCenter.getAmountLoc());
+						amountDUsd = amountDUsd.add(feeCenter.getAmount());
 						amountDLoc = amountDLoc.add(feeCenter.getAmount().multiply(feeCenter.getExrate()));
 					} else {
-						amountCUsd = amountCUsd.add(feeCenter.getAmountLoc());
+						amountCUsd = amountCUsd.add(feeCenter.getAmount());
 						amountCLoc = amountCLoc.add(feeCenter.getAmount().multiply(feeCenter.getExrate()));
 					}
 				}
@@ -873,6 +887,8 @@ public class FeeCenterServiceImpl extends ServiceImpl<FeeCenterMapper, FeeCenter
 				}
 				feeCenter.setStlTtlAmount(ObjectUtils.isNotNull(feeCenter.getStlTtlAmount()) ? feeCenter.getStlTtlAmount() : new BigDecimal("0"));
 				feeCenter.setUnsettledAmount(feeCenter.getAmount().subtract(feeCenter.getStlTtlAmount()));
+				int version = StringUtil.isBlank(feeCenter.getVersion()) ? 1 : Integer.parseInt(feeCenter.getVersion());
+				feeCenter.setVersion(String.valueOf(version + 1));
 				feeCenterList.add(feeCenter);
 			}
 			tradingBox.setAmountC(tradingBox.getAmountC().add(amountC));
@@ -1095,9 +1111,9 @@ public class FeeCenterServiceImpl extends ServiceImpl<FeeCenterMapper, FeeCenter
 				feeCenter.setUnitNo(items.getUnitNo());
 				feeCenter.setPrice(items.getSalesPrice());
 				feeCenter.setCurCode(items.getCurCode());
-				if (exrateType.equals(items.getCurCode())){
+				if (exrateType.equals(items.getCurCode())) {
 					feeCenter.setExrate(new BigDecimal("1.00"));
-				}else{
+				} else {
 					feeCenter.setExrate(currencyUtils.obtainExrate(feeCenter.getDc(), curExrateList, feeCenter.getCurCode(), "1"));
 				}
 				if ("按箱型".equals(items.getQuantityRule())) {

+ 20 - 1
blade-service/blade-los/src/main/java/org/springblade/los/finance/invoices/service/impl/FinInvoicesServiceImpl.java

@@ -44,6 +44,7 @@ import org.springblade.los.finance.invoices.service.IFinInvoiceItemDetailService
 import org.springblade.los.finance.invoices.service.IFinInvoicesItemsService;
 import org.springblade.los.finance.invoices.service.IFinInvoicesService;
 import org.springblade.los.finance.invoices.vo.FinInvoicesVO;
+import org.springblade.los.finance.stl.entity.FinStlBillsItems;
 import org.springblade.system.feign.ISysClient;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
@@ -141,6 +142,11 @@ public class FinInvoicesServiceImpl extends ServiceImpl<FinInvoicesMapper, FinIn
 		}
 		this.saveOrUpdate(finInvoices);
 		if (ObjectUtils.isNotNull(finInvoices.getFinInvoicesItemsList())) {
+			List<String> branchIdList = finInvoices.getFinInvoicesItemsList().stream().map(FinInvoicesItems::getBranchId)
+				.distinct().collect(Collectors.toList());
+			if (branchIdList.size() > 1) {
+				throw new RuntimeException("请选择同一个所属公司明细");
+			}
 			BigDecimal amountCnyD = new BigDecimal("0.00");
 			BigDecimal amountUsdD = new BigDecimal("0.00");
 			BigDecimal amountCnyC = new BigDecimal("0.00");
@@ -262,6 +268,11 @@ public class FinInvoicesServiceImpl extends ServiceImpl<FinInvoicesMapper, FinIn
 		FinInvoices detail = baseMapper.selectById(finInvoices.getId());
 		String exrateType = currencyUtils.standardCurrency(detail.getBranchId());
 		if (ObjectUtils.isNotNull(finInvoices.getFinInvoicesItemsList())) {
+			List<String> branchIdList = finInvoices.getFinInvoicesItemsList().stream().map(FinInvoicesItems::getBranchId)
+				.distinct().collect(Collectors.toList());
+			if (branchIdList.size() > 1) {
+				throw new RuntimeException("请选择同一个所属公司明细");
+			}
 			detail.setBusinessNo(finInvoices.getFinInvoicesItemsList().stream().map(FinInvoicesItems::getBillNo).distinct().collect(Collectors.joining(",")));
 			detail.setMblno(finInvoices.getFinInvoicesItemsList().stream().map(FinInvoicesItems::getMblno).distinct().collect(Collectors.joining(",")));
 			detail.setHblno(finInvoices.getFinInvoicesItemsList().stream().map(FinInvoicesItems::getHblno).distinct().collect(Collectors.joining(",")));
@@ -416,8 +427,11 @@ public class FinInvoicesServiceImpl extends ServiceImpl<FinInvoicesMapper, FinIn
 				invoiceAmount = invoiceAmount.add(item.getAmount());
 			}
 		}
+		if (new BigDecimal("0.00").compareTo(finInvoices.getAmountLoc()) == 0) {
+			throw new RuntimeException("开票失败:开票金额不能小于等于0");
+		}
 		if (invoiceAmount.compareTo(finInvoices.getAmountLoc()) > 0) {
-			throw new RuntimeException("开票金额大于合计金额,保存失败");
+			throw new RuntimeException("开票失败:开票金额大于合计金额,保存失败");
 		}
 		detail.setStatus(3);
 		baseMapper.updateById(detail);
@@ -761,6 +775,11 @@ public class FinInvoicesServiceImpl extends ServiceImpl<FinInvoicesMapper, FinIn
 		List<FeeCenter> feeCenterList = new ArrayList<>();
 		List<FinAccBills> finAccBillsList = new ArrayList<>();
 		if (ObjectUtils.isNotNull(finInvoices.getFinInvoicesItemsList())) {
+			List<String> branchIdList = finInvoices.getFinInvoicesItemsList().stream().map(FinInvoicesItems::getBranchId)
+				.distinct().collect(Collectors.toList());
+			if (branchIdList.size() > 1) {
+				throw new RuntimeException("请选择同一个所属公司明细");
+			}
 			detail.setBusinessNo(finInvoices.getFinInvoicesItemsList().stream().map(FinInvoicesItems::getBillNo).distinct().collect(Collectors.joining(",")));
 			detail.setMblno(finInvoices.getFinInvoicesItemsList().stream().map(FinInvoicesItems::getMblno).distinct().collect(Collectors.joining(",")));
 			detail.setHblno(finInvoices.getFinInvoicesItemsList().stream().map(FinInvoicesItems::getHblno).distinct().collect(Collectors.joining(",")));

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

@@ -210,6 +210,11 @@ public class FinStlBillsServiceImpl extends ServiceImpl<FinStlBillsMapper, FinSt
 		}
 		this.saveOrUpdate(finStlBills);
 		if (ObjectUtils.isNotNull(finStlBills.getFinStlBillsItemsList())) {
+			List<String> branchIdList = finStlBills.getFinStlBillsItemsList().stream().map(FinStlBillsItems::getBranchId)
+				.distinct().collect(Collectors.toList());
+			if (branchIdList.size() > 1) {
+				throw new RuntimeException("请选择同一个所属公司明细");
+			}
 			List<FinStlBillsItems> finStlBillsItemsList = new ArrayList<>();
 			BigDecimal amountDrCNY = new BigDecimal("0.00");
 			BigDecimal amountCrCNY = new BigDecimal("0.00");
@@ -234,13 +239,13 @@ public class FinStlBillsServiceImpl extends ServiceImpl<FinStlBillsMapper, FinSt
 						amountCrLoc = amountCrLoc.add(item.getCurrentStlAmount());
 					}
 				} else {
-					BigDecimal loc = currencyUtils.converter(item.getDc(), curExrateList, item.getCurrentStlAmount(), item.getCurrentStlCurCode(), "2");
+					BigDecimal loc = item.getCurrentStlAmount().multiply(item.getCurrentStlExrate());
 					item.setCurrentStlAmountLoc(loc);
 					if ("D".equals(item.getDc())) {
-						amountDrUSD = amountDrUSD.add(loc);
+						amountDrUSD = amountDrUSD.add(item.getCurrentStlAmount());
 						amountDrLoc = amountDrLoc.add(loc);
 					} else {
-						amountCrUSD = amountCrUSD.add(loc);
+						amountCrUSD = amountCrUSD.add(item.getCurrentStlAmount());
 						amountCrLoc = amountCrLoc.add(loc);
 					}
 				}
@@ -290,7 +295,13 @@ public class FinStlBillsServiceImpl extends ServiceImpl<FinStlBillsMapper, FinSt
 			throw new RuntimeException("缺少必要参数");
 		}
 		FinStlBills detail = baseMapper.selectById(finStlBills.getId());
+		String exrateType = currencyUtils.standardCurrency(detail.getBranchId());
 		if (ObjectUtils.isNotNull(finStlBills.getFinStlBillsItemsList())) {
+			List<String> branchIdList = finStlBills.getFinStlBillsItemsList().stream().map(FinStlBillsItems::getBranchId)
+				.distinct().collect(Collectors.toList());
+			if (branchIdList.size() > 1) {
+				throw new RuntimeException("请选择同一个所属公司明细");
+			}
 			detail.setBusinessNo(finStlBills.getFinStlBillsItemsList().stream().map(FinStlBillsItems::getBillNo).distinct().collect(Collectors.joining(",")));
 			detail.setAccountNo(finStlBills.getFinStlBillsItemsList().stream().map(FinStlBillsItems::getAccBillNo).distinct().collect(Collectors.joining(",")));
 			detail.setMblno(finStlBills.getFinStlBillsItemsList().stream().map(FinStlBillsItems::getMblno).distinct().collect(Collectors.joining(",")));
@@ -311,17 +322,8 @@ public class FinStlBillsServiceImpl extends ServiceImpl<FinStlBillsMapper, FinSt
 					finAccBills.setUpdateUser(AuthUtil.getUserId());
 					finAccBills.setUpdateTime(new Date());
 					finAccBills.setUpdateUserName(AuthUtil.getUserName());
-					if ("D".equals(finAccBills.getAccountDc())) {
-						if (finAccBills.getAmountDrLoc().abs().compareTo(item.getCurrentStlAmount().abs()) < 0) {
-							throw new RuntimeException("本次对账金额大于账单应收金额");
-						}
-					} else {
-						if (finAccBills.getAmountCrLoc().abs().compareTo(item.getCurrentStlAmount().abs()) < 0) {
-							throw new RuntimeException("本次对账金额大于账单应付金额");
-						}
-					}
 					int isChecked = 0;
-					if ("CNY".equals(item.getCurCode())) {
+					if (exrateType.equals(item.getCurCode())) {
 						finAccBills.setReconciliationAmount(finAccBills.getReconciliationAmount().add(item.getCurrentStlAmount()));
 						if ("D".equals(finAccBills.getAccountDc())) {
 							if (finAccBills.getAmountDr().abs().compareTo(finAccBills.getReconciliationAmount().abs()) > 0) {
@@ -329,12 +331,18 @@ public class FinStlBillsServiceImpl extends ServiceImpl<FinStlBillsMapper, FinSt
 							} else if (finAccBills.getAmountDr().abs().compareTo(finAccBills.getReconciliationAmount().abs()) == 0) {
 								isChecked = 2;
 							}
+							if (finAccBills.getReconciliationAmount().abs().compareTo(finAccBills.getAmountDr().abs()) > 0) {
+								throw new RuntimeException("本次对账金额大于账单应收金额");
+							}
 						} else {
 							if (finAccBills.getAmountCr().abs().compareTo(finAccBills.getReconciliationAmount().abs()) > 0) {
 								isChecked = 1;
 							} else if (finAccBills.getAmountCr().abs().compareTo(finAccBills.getReconciliationAmount().abs()) == 0) {
 								isChecked = 2;
 							}
+							if (finAccBills.getReconciliationAmount().abs().compareTo(finAccBills.getAmountCr().abs()) > 0) {
+								throw new RuntimeException("本次对账金额大于账单应付金额");
+							}
 						}
 					} else {
 						finAccBills.setReconciliationAmountUsd(finAccBills.getReconciliationAmountUsd().add(item.getCurrentStlAmount()));
@@ -344,12 +352,18 @@ public class FinStlBillsServiceImpl extends ServiceImpl<FinStlBillsMapper, FinSt
 							} else if (finAccBills.getAmountDrUsd().abs().compareTo(finAccBills.getReconciliationAmountUsd().abs()) == 0) {
 								isChecked = 2;
 							}
+							if (finAccBills.getReconciliationAmountUsd().abs().compareTo(finAccBills.getAmountDrUsd().abs()) > 0) {
+								throw new RuntimeException("本次对账金额大于账单应收金额");
+							}
 						} else {
 							if (finAccBills.getAmountCrUsd().abs().compareTo(finAccBills.getReconciliationAmountUsd().abs()) > 0) {
 								isChecked = 1;
 							} else if (finAccBills.getAmountCrUsd().abs().compareTo(finAccBills.getReconciliationAmountUsd().abs()) == 0) {
 								isChecked = 2;
 							}
+							if (finAccBills.getReconciliationAmountUsd().abs().compareTo(finAccBills.getAmountCrUsd().abs()) > 0) {
+								throw new RuntimeException("本次对账金额大于账单应付金额");
+							}
 						}
 					}
 					finAccBills.setIsChecked(isChecked);
@@ -598,6 +612,7 @@ public class FinStlBillsServiceImpl extends ServiceImpl<FinStlBillsMapper, FinSt
 			throw new RuntimeException("缺少必要参数");
 		}
 		FinStlBills detail = baseMapper.selectById(finStlBills.getId());
+		String exrateType = currencyUtils.standardCurrency(detail.getBranchId());
 		if (ObjectUtils.isNotNull(finStlBills.getFinStlBillsItemsList())) {
 			List<FinAccBills> finAccBillsList = new ArrayList<>();
 			List<FeeCenter> feeCenterList = new ArrayList<>();
@@ -613,7 +628,7 @@ public class FinStlBillsServiceImpl extends ServiceImpl<FinStlBillsMapper, FinSt
 					finAccBills.setUpdateTime(new Date());
 					finAccBills.setUpdateUserName(AuthUtil.getUserName());
 					int isChecked = 0;
-					if ("CNY".equals(item.getCurCode())) {
+					if (exrateType.equals(item.getCurCode())) {
 						if (finAccBills.getReconciliationAmount().abs().compareTo(item.getCurrentStlAmount().abs()) < 0) {
 							throw new RuntimeException("撤销失败,本次对账金额大于已对账金额");
 						}
@@ -722,8 +737,12 @@ public class FinStlBillsServiceImpl extends ServiceImpl<FinStlBillsMapper, FinSt
 		}
 		FinStlBills detail = baseMapper.selectById(finStlBills.getId());
 		String exrateType = currencyUtils.standardCurrency(detail.getBranchId());
-		List<BCurExrate> curExrateList = currencyUtils.obtainRate(new Date(), "2", detail.getBranchId());
 		if (ObjectUtils.isNotNull(finStlBills.getFinStlBillsItemsList())) {
+			List<String> branchIdList = finStlBills.getFinStlBillsItemsList().stream().map(FinStlBillsItems::getBranchId)
+				.distinct().collect(Collectors.toList());
+			if (branchIdList.size() > 1) {
+				throw new RuntimeException("请选择同一个所属公司明细");
+			}
 			detail.setBusinessNo(finStlBills.getFinStlBillsItemsList().stream().map(FinStlBillsItems::getBillNo).distinct().collect(Collectors.joining(",")));
 			detail.setAccountNo(finStlBills.getFinStlBillsItemsList().stream().map(FinStlBillsItems::getAccBillNo).distinct().collect(Collectors.joining(",")));
 			detail.setMblno(finStlBills.getFinStlBillsItemsList().stream().map(FinStlBillsItems::getMblno).distinct().collect(Collectors.joining(",")));
@@ -826,11 +845,6 @@ public class FinStlBillsServiceImpl extends ServiceImpl<FinStlBillsMapper, FinSt
 				item.setStlTtlAmount(item.getStlTtlAmount().add(item.getCurrentStlAmount().add(item.getCurrentStlDiscount())));
 				item.setUnsettledAmount(item.getAmount().subtract(item.getStlTtlAmount()));
 				if ("D".equals(item.getDc())) {
-					if (finAccBills.getStlAmountDr().abs().compareTo(finAccBills.getAmountDr().abs()) > 0 ||
-						finAccBills.getStlAmountDrUsd().abs().compareTo(finAccBills.getAmountDrUsd().abs()) > 0
-					) {
-						throw new RuntimeException("结算金额大于账单金额,操作失败");
-					}
 					if (exrateType.equals(item.getCurCode())) {
 						finAccBills.setStlAmountDr(finAccBills.getStlAmountDr().add(item.getCurrentStlAmount()));
 						finAccBills.setStlAmountDrLoc(finAccBills.getStlAmountDrLoc().add(item.getCurrentStlAmount()));
@@ -839,7 +853,7 @@ public class FinStlBillsServiceImpl extends ServiceImpl<FinStlBillsMapper, FinSt
 						}
 					} else {
 						finAccBills.setStlAmountDrUsd(finAccBills.getStlAmountDrUsd().add(item.getCurrentStlAmount()));
-						BigDecimal cny = currencyUtils.converter(item.getDc(), curExrateList, item.getCurrentStlAmount(), item.getCurrentStlCurCode(), "2");
+						BigDecimal cny = item.getCurrentStlAmount().multiply(item.getCurrentStlExrate());
 						finAccBills.setStlAmountDrLoc(finAccBills.getStlAmountDrLoc().add(cny));
 						if (!ids.isEmpty()) {
 							finAccBills.setAppliedAmountStlUsd(finAccBills.getAppliedAmountStl().add(item.getCurrentStlAmount()));
@@ -849,12 +863,12 @@ public class FinStlBillsServiceImpl extends ServiceImpl<FinStlBillsMapper, FinSt
 						finAccBills.getAmountDrUsd().abs().compareTo(finAccBills.getStlAmountDrUsd().abs()) == 0) {
 						status = true;
 					}
-				} else if ("C".equals(item.getDc())) {
-					if (finAccBills.getStlAmountCr().abs().compareTo(finAccBills.getAmountCr().abs()) > 0 ||
-						finAccBills.getStlAmountCrUsd().abs().compareTo(finAccBills.getAmountCrUsd().abs()) > 0
+					if (finAccBills.getStlAmountDr().abs().compareTo(finAccBills.getAmountDr().abs()) > 0 ||
+						finAccBills.getStlAmountDrUsd().abs().compareTo(finAccBills.getAmountDrUsd().abs()) > 0
 					) {
 						throw new RuntimeException("结算金额大于账单金额,操作失败");
 					}
+				} else if ("C".equals(item.getDc())) {
 					if (exrateType.equals(item.getCurCode())) {
 						finAccBills.setStlAmountCr(finAccBills.getStlAmountCr().add(item.getCurrentStlAmount()));
 						finAccBills.setStlAmountCrLoc(finAccBills.getStlAmountCrLoc().add(item.getCurrentStlAmount()));
@@ -863,7 +877,7 @@ public class FinStlBillsServiceImpl extends ServiceImpl<FinStlBillsMapper, FinSt
 						}
 					} else {
 						finAccBills.setStlAmountCrUsd(finAccBills.getStlAmountCrUsd().add(item.getCurrentStlAmount()));
-						BigDecimal cny = currencyUtils.converter(item.getDc(), curExrateList, item.getCurrentStlAmount(), item.getCurrentStlCurCode(), "2");
+						BigDecimal cny = item.getCurrentStlAmount().multiply(item.getCurrentStlExrate());
 						finAccBills.setStlAmountCrLoc(finAccBills.getStlAmountCrLoc().add(cny));
 						if (!ids.isEmpty()) {
 							finAccBills.setAppliedAmountStlUsd(finAccBills.getAppliedAmountStlUsd().add(item.getCurrentStlAmount()));
@@ -873,6 +887,11 @@ public class FinStlBillsServiceImpl extends ServiceImpl<FinStlBillsMapper, FinSt
 						finAccBills.getAmountCrUsd().abs().compareTo(finAccBills.getStlAmountCrUsd().abs()) == 0) {
 						status = true;
 					}
+					if (finAccBills.getStlAmountCr().abs().compareTo(finAccBills.getAmountCr().abs()) > 0 ||
+						finAccBills.getStlAmountCrUsd().abs().compareTo(finAccBills.getAmountCrUsd().abs()) > 0
+					) {
+						throw new RuntimeException("结算金额大于账单金额,操作失败");
+					}
 				}
 				if (status) {
 					finAccBills.setIsCleared(9);
@@ -915,7 +934,7 @@ public class FinStlBillsServiceImpl extends ServiceImpl<FinStlBillsMapper, FinSt
 						e.setStlBillId(detail.getId());
 						e.setStlBillNo(detail.getBillNo());
 						e.setStlDate(detail.getBillDate());
-						e.setStlOrgAmount(currencyUtils.converter(e.getDc(), curExrateList, item.getCurrentStlAmount(), item.getCurCode(), "2"));
+						e.setStlOrgAmount(item.getCurrentStlAmount().multiply(item.getExrate()));
 						e.setStlCurCode(item.getCurrentStlCurCode());
 						e.setStlExrate(item.getExrate());
 						e.setStlExrateLoc(item.getCurrentStlExrate());
@@ -1385,6 +1404,7 @@ public class FinStlBillsServiceImpl extends ServiceImpl<FinStlBillsMapper, FinSt
 		if (bills == null) {
 			throw new SecurityException("审批通过失败");
 		}
+		String exrateType = currencyUtils.standardCurrency(bills.getBranchId());
 		List<FinStlBillsItems> finStlBillsItemsList = finStlBillsItemsService.list(new LambdaQueryWrapper<FinStlBillsItems>()
 			.eq(FinStlBillsItems::getTenantId, AuthUtil.getTenantId())
 			.eq(FinStlBillsItems::getIsDeleted, 0)
@@ -1396,7 +1416,7 @@ public class FinStlBillsServiceImpl extends ServiceImpl<FinStlBillsMapper, FinSt
 			if (finAccBills == null) {
 				throw new RuntimeException("未找到账单明细,操作失败");
 			}
-			if ("CNY".equals(item.getCurCode())) {
+			if (exrateType.equals(item.getCurCode())) {
 				if (item.getCurrentStlAmount().abs().compareTo(finAccBills.getAppliedAmount().abs()) > 0) {
 					throw new RuntimeException("本次申请金额大于未申请金额");
 				}
@@ -1514,6 +1534,7 @@ public class FinStlBillsServiceImpl extends ServiceImpl<FinStlBillsMapper, FinSt
 			throw new RuntimeException("缺少必要参数");
 		}
 		FinStlBills detail = baseMapper.selectById(finStlBills.getId());
+		String exrateType = currencyUtils.standardCurrency(detail.getBranchId());
 		//审批数据
 		LosAuditProecessDTO auditProecessDTO = new LosAuditProecessDTO();
 		//获取审批级次
@@ -1588,6 +1609,11 @@ public class FinStlBillsServiceImpl extends ServiceImpl<FinStlBillsMapper, FinSt
 		detail.setStatus(1);
 		detail.setAuditDateFrom(new Date());
 		if (ObjectUtils.isNotNull(finStlBills.getFinStlBillsItemsList())) {
+			List<String> branchIdList = finStlBills.getFinStlBillsItemsList().stream().map(FinStlBillsItems::getBranchId)
+				.distinct().collect(Collectors.toList());
+			if (branchIdList.size() > 1) {
+				throw new RuntimeException("请选择同一个所属公司明细");
+			}
 			detail.setBusinessNo(finStlBills.getFinStlBillsItemsList().stream().map(FinStlBillsItems::getBillNo).distinct().collect(Collectors.joining(",")));
 			detail.setAccountNo(finStlBills.getFinStlBillsItemsList().stream().map(FinStlBillsItems::getAccBillNo).distinct().collect(Collectors.joining(",")));
 			detail.setMblno(finStlBills.getFinStlBillsItemsList().stream().map(FinStlBillsItems::getMblno).distinct().collect(Collectors.joining(",")));
@@ -1604,7 +1630,7 @@ public class FinStlBillsServiceImpl extends ServiceImpl<FinStlBillsMapper, FinSt
 				if (finAccBills == null) {
 					throw new RuntimeException("未找到账单明细,操作失败");
 				}
-				if ("CNY".equals(item.getCurCode())) {
+				if (exrateType.equals(item.getCurCode())) {
 					BigDecimal amount = finAccBills.getAppliedAmount().subtract(finAccBills.getAppliedAmountStl().abs());
 					if ("D".equals(finAccBills.getAccountDc())) {
 						if (item.getCurrentStlAmount().abs().compareTo(finAccBills.getAmountDrLoc().abs().subtract(amount.abs()).subtract(finAccBills.getStlAmountDrLoc().abs())) > 0) {
@@ -1689,6 +1715,7 @@ public class FinStlBillsServiceImpl extends ServiceImpl<FinStlBillsMapper, FinSt
 			throw new RuntimeException("缺少必要参数");
 		}
 		FinStlBills detail = baseMapper.selectById(finStlBills.getId());
+		String exrateType = currencyUtils.standardCurrency(detail.getBranchId());
 		if (ObjectUtils.isNotNull(finStlBills.getFinStlBillsItemsList())) {
 			if (detail.getStatus() > 1) {
 				throw new RuntimeException("正在审核中,撤销失败");
@@ -1705,7 +1732,7 @@ public class FinStlBillsServiceImpl extends ServiceImpl<FinStlBillsMapper, FinSt
 				if (finAccBills == null) {
 					throw new RuntimeException("未找到账单明细,操作失败");
 				}
-				if ("CNY".equals(item.getCurCode())) {
+				if (exrateType.equals(item.getCurCode())) {
 					if (item.getCurrentStlAmount().abs().compareTo(finAccBills.getAppliedAmount().abs()) > 0) {
 						throw new RuntimeException("本次申请金额大于未申请金额");
 					}