Browse Source

1.费用请核-报表打印接口逻辑修改
2.分单添加主单以后,需要增加控制,先撤销,再退仓撤销
3.分单添加主单,把主单维护的代理信息,同步到分单
4.单添加主单,主分单起运港,目的港需要一致才允许添加
"5.主单带有分单排序
主单排首位,分单按照排序方式排列"
6.主单汇总所有分单的货物信息
7.单从主单撤销 清空提单号
8.列表增加批量请核费用接口

纪新园 9 months ago
parent
commit
4ea1596f5f
19 changed files with 723 additions and 210 deletions
  1. 1 1
      blade-service-api/blade-los-api/src/main/java/org/springblade/los/basic/fees/entity/LosBFeesTemplate.java
  2. 11 2
      blade-service-api/blade-los-api/src/main/java/org/springblade/los/box/entity/ExpenseApplication.java
  3. 5 4
      blade-service-api/blade-los-api/src/main/java/org/springblade/los/business/sea/entity/Bills.java
  4. 5 0
      blade-service-api/blade-los-api/src/main/java/org/springblade/los/business/sea/entity/Containers.java
  5. 5 0
      blade-service-api/blade-los-api/src/main/java/org/springblade/los/business/sea/entity/ContainersBills.java
  6. 5 0
      blade-service-api/blade-los-api/src/main/java/org/springblade/los/business/sea/entity/ContainersCommodity.java
  7. 98 0
      blade-service-api/blade-los-api/src/main/java/org/springblade/los/finance/fee/dto/ExpenseApplicationFeeReports.java
  8. 11 6
      blade-service/blade-los/src/main/java/org/springblade/los/Util/BigDecimalUtils.java
  9. 1 1
      blade-service/blade-los/src/main/java/org/springblade/los/basic/fees/controller/LosBFeesTemplateController.java
  10. 3 3
      blade-service/blade-los/src/main/java/org/springblade/los/basic/fees/service/impl/LosBFeesTemplateServiceImpl.java
  11. 67 12
      blade-service/blade-los/src/main/java/org/springblade/los/basic/reports/service/impl/ReportsBoxServiceImpl.java
  12. 9 0
      blade-service/blade-los/src/main/java/org/springblade/los/box/controller/ExpenseApplicationController.java
  13. 2 0
      blade-service/blade-los/src/main/java/org/springblade/los/box/service/IExpenseApplicationService.java
  14. 194 0
      blade-service/blade-los/src/main/java/org/springblade/los/box/service/impl/ExpenseApplicationServiceImpl.java
  15. 4 2
      blade-service/blade-los/src/main/java/org/springblade/los/box/service/impl/TradingBoxItemServiceImpl.java
  16. 49 96
      blade-service/blade-los/src/main/java/org/springblade/los/business/sea/controller/BillsController.java
  17. 186 12
      blade-service/blade-los/src/main/java/org/springblade/los/business/sea/service/impl/BillsServiceImpl.java
  18. 65 69
      blade-service/blade-los/src/main/java/org/springblade/los/finance/fee/service/impl/FeeCenterServiceImpl.java
  19. 2 2
      blade-service/blade-los/src/main/java/org/springblade/los/finance/fee/service/impl/FinAccBillsServiceImpl.java

+ 1 - 1
blade-service-api/blade-los-api/src/main/java/org/springblade/los/basic/fees/entity/LosBFeesTemplate.java

@@ -162,7 +162,7 @@ public class LosBFeesTemplate implements Serializable {
 	 * 船公司
 	 */
 	@ApiModelProperty(value = "船公司")
-	private Long shippingCompanyId;
+	private String shippingCompanyId;
 	/**
 	 * 船公司中文
 	 */

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

@@ -24,6 +24,8 @@ import io.swagger.annotations.ApiModelProperty;
 import lombok.Data;
 import org.springblade.los.business.sea.entity.Bills;
 import org.springblade.los.check.entity.LosAuditPathsLevels;
+import org.springblade.los.finance.fee.dto.ExpenseApplicationFeeReports;
+import org.springblade.los.finance.fee.dto.FeeCenterReports;
 import org.springblade.los.finance.fee.entity.FeeCenter;
 import org.springblade.system.entity.Dept;
 
@@ -163,11 +165,18 @@ public class ExpenseApplication implements Serializable {
 	 */
 	@TableField(exist = false)
 	private List<FeeCenter> feeCenterList;
+
 	/**
-	 * 费用中心
+	 * 物流-费用中心(收)
+	 */
+	@TableField(exist = false)
+	private List<ExpenseApplicationFeeReports> feeCenterListD;
+
+	/**
+	 * 物流-费用中心(付)
 	 */
 	@TableField(exist = false)
-	private List<FeeCenter> feeCenterListC;
+	private List<ExpenseApplicationFeeReports> feeCenterListC;
 
 	//审核-跳转对应页面的路由
 	@TableField(exist = false)

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

@@ -147,6 +147,7 @@ public class Bills implements Serializable {
 	 * 主单单据编号
 	 */
 	@ApiModelProperty(value = "主单单据编号")
+	@TableField(updateStrategy = FieldStrategy.IGNORED)
 	private String masterBillNo;
 	/**
 	 * 分单合计
@@ -894,16 +895,16 @@ public class Bills implements Serializable {
 	 * 场站背箱时间 yyyy-MM-dd hh:nn
 	 */
 	@ApiModelProperty(value = "场站背箱时间 yyyy-MM-dd hh:nn")
-	@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd")
-	@DateTimeFormat(pattern = "yyyy-MM-dd")
+	@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
+	@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
 	@TableField(updateStrategy = FieldStrategy.IGNORED)
 	private Date cyTrailerTime;
 	/**
 	 * 返场(回箱)时间 yyyy-MM-dd hh:nn  (放行日期)
 	 */
 	@ApiModelProperty(value = "返场(回箱)时间 yyyy-MM-dd hh:nn")
-	@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd")
-	@DateTimeFormat(pattern = "yyyy-MM-dd")
+	@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
+	@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
 	@TableField(updateStrategy = FieldStrategy.IGNORED)
 	private Date cyReturnTime;
 	/**

+ 5 - 0
blade-service-api/blade-los-api/src/main/java/org/springblade/los/business/sea/entity/Containers.java

@@ -487,6 +487,11 @@ public class Containers implements Serializable {
 	 */
 	@ApiModelProperty(value = "pod箱使天数")
 	private Integer podBoxUseDays;
+	/**
+	 * 来源分单id
+	 */
+	@ApiModelProperty(value = "来源分单id")
+	private Long srcSplitOrderId;
 
 	/**
 	 * 配箱类型

+ 5 - 0
blade-service-api/blade-los-api/src/main/java/org/springblade/los/business/sea/entity/ContainersBills.java

@@ -285,6 +285,11 @@ public class ContainersBills implements Serializable {
 	 */
 	@ApiModelProperty(value = "租户")
 	private String tenantId;
+	/**
+	 * 来源分单id
+	 */
+	@ApiModelProperty(value = "来源分单id")
+	private Long srcSplitOrderId;
 
 
 }

+ 5 - 0
blade-service-api/blade-los-api/src/main/java/org/springblade/los/business/sea/entity/ContainersCommodity.java

@@ -353,6 +353,11 @@ public class ContainersCommodity implements Serializable {
 	 */
 	@ApiModelProperty(value = "包装等级")
 	private String packingLevel;
+	/**
+	 * 来源分单id
+	 */
+	@ApiModelProperty(value = "来源分单id")
+	private Long srcSplitOrderId;
 
 
 }

+ 98 - 0
blade-service-api/blade-los-api/src/main/java/org/springblade/los/finance/fee/dto/ExpenseApplicationFeeReports.java

@@ -0,0 +1,98 @@
+/*
+ *      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.finance.fee.dto;
+
+import lombok.Data;
+
+import java.io.Serializable;
+import java.math.BigDecimal;
+
+/**
+ * @author BladeX
+ * @since 2023-10-18
+ */
+@Data
+public class ExpenseApplicationFeeReports implements Serializable {
+
+	/**
+	 * 主表 id
+	 */
+	private Long pid;
+
+	/**
+	 * 申请pid
+	 */
+	private Long stlPid;
+	/**
+	 * 客户中文名称
+	 */
+	private String corpCnName;
+	/**
+	 * 费用中文名称
+	 */
+	private String feeCnName;
+
+	/**
+	 * 金额
+	 */
+	private BigDecimal amount;
+
+	/**
+	 * 金额
+	 */
+	private BigDecimal amountUsd;
+
+	/**
+	 * 本币金额,外币转为本币的金额
+	 */
+	private BigDecimal amountLoc;
+
+	/**
+	 * dc
+	 */
+	private String dc;
+
+	/**
+	 * 备注
+	 */
+	private String remarks;
+
+	/**
+	 * 汇率
+	 */
+	private BigDecimal exrate;
+
+	/**
+	 * 数量
+	 */
+	private BigDecimal quantity;
+
+	/**
+	 * 单位
+	 */
+	private String unitNo;
+	/**
+	 * 单价
+	 */
+	private BigDecimal price;
+
+	/**
+	 * 费用英文名称
+	 */
+	private String feeEnName;
+
+}

+ 11 - 6
blade-service/blade-los/src/main/java/org/springblade/los/Util/BigDecimalUtils.java

@@ -17,13 +17,18 @@ public class BigDecimalUtils {
 	public static String convertToEnglish(BigDecimal number) {
 		BigDecimal integerPart = number.setScale(0, BigDecimal.ROUND_DOWN);
 		String decimal = number.toString();
-		BigDecimal decimalAmount = new BigDecimal(decimal.substring(decimal.indexOf(".") + 1));
-		long integralPart = integerPart.longValue();
-		String uppercaseInteger = convert(integralPart).trim();
-		if (new BigDecimal("0.00").compareTo(decimalAmount) != 0) {
-			uppercaseInteger = uppercaseInteger + " POINT " + convert(decimalAmount.longValue()).trim();
+		if (decimal.indexOf(".") > 0) {
+			BigDecimal decimalAmount = new BigDecimal(decimal.substring(decimal.indexOf(".") + 1));
+			long integralPart = integerPart.longValue();
+			String uppercaseInteger = convert(integralPart).trim();
+			if (new BigDecimal("0.00").compareTo(decimalAmount) != 0) {
+				uppercaseInteger = uppercaseInteger + " POINT " + convert(decimalAmount.longValue()).trim();
+			}
+			return uppercaseInteger;
+		} else {
+			long integralPart = integerPart.longValue();
+			return convert(integralPart).trim();
 		}
-		return uppercaseInteger;
 	}
 
 	private static String convert(long number) {

+ 1 - 1
blade-service/blade-los/src/main/java/org/springblade/los/basic/fees/controller/LosBFeesTemplateController.java

@@ -217,7 +217,7 @@ public class LosBFeesTemplateController extends BladeController {
 			.eq(ObjectUtils.isNotNull(losBFeesTemplate.getStatus()), LosBFeesTemplate::getStatus, losBFeesTemplate.getStatus())
 			.eq(ObjectUtils.isNotNull(losBFeesTemplate.getAddressId()), LosBFeesTemplate::getAddressId, losBFeesTemplate.getAddressId())
 			.like(ObjectUtils.isNotNull(losBFeesTemplate.getAddressCname()), LosBFeesTemplate::getAddressCname, losBFeesTemplate.getAddressCname())
-			.eq(LosBFeesTemplate::getShippingCompanyId, losBFeesTemplate.getShippingCompanyId())
+			.like(LosBFeesTemplate::getShippingCompanyId, losBFeesTemplate.getShippingCompanyId())
 			.like(ObjectUtils.isNotNull(losBFeesTemplate.getShippingCompanyCname()), LosBFeesTemplate::getShippingCompanyCname, losBFeesTemplate.getShippingCompanyCname())
 			.eq(ObjectUtils.isNotNull(losBFeesTemplate.getTransportationTerms()), LosBFeesTemplate::getTransportationTerms, losBFeesTemplate.getTransportationTerms())
 			.orderByDesc(LosBFeesTemplate::getCreateTime);

+ 3 - 3
blade-service/blade-los/src/main/java/org/springblade/los/basic/fees/service/impl/LosBFeesTemplateServiceImpl.java

@@ -196,8 +196,8 @@ public class LosBFeesTemplateServiceImpl extends ServiceImpl<LosBFeesTemplateMap
 						if (ObjectUtils.isNull(sonItems.getDc())) {
 							sonItems.setDc(item.getDc());
 						}
-						sonItems.setUnitNo(item.getUnitNo());
-						sonItems.setUnitId(item.getUnitId());
+						/*sonItems.setUnitNo(item.getUnitNo());
+						sonItems.setUnitId(item.getUnitId());*/
 						sonItems.setCorpId(item.getCorpId());
 						sonItems.setCorpCnName(item.getCorpCnName());
 						sonItems.setCorpEnName(item.getCorpEnName());
@@ -207,7 +207,7 @@ public class LosBFeesTemplateServiceImpl extends ServiceImpl<LosBFeesTemplateMap
 						sonItems.setFeeCode(item.getFeeCode());
 						sonItems.setFeeCnName(item.getFeeCnName());
 						sonItems.setFeeEnName(item.getFeeEnName());
-						sonItems.setCurCode(item.getCurCode());
+//						sonItems.setCurCode(item.getCurCode());
 						sonItems.setQuantityRule(item.getQuantityRule());
 						sonItems.setType(item.getCorpType());
 						if (sonItems.getId() == null) {

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

@@ -35,6 +35,7 @@ import org.springblade.los.business.sea.entity.Bills;
 import org.springblade.los.business.sea.entity.SeaBillsDetail;
 import org.springblade.los.business.sea.service.IBillsService;
 import org.springblade.los.business.sea.service.ISeaBillsDetailService;
+import org.springblade.los.finance.fee.dto.ExpenseApplicationFeeReports;
 import org.springblade.los.finance.fee.entity.FeeCenter;
 import org.springblade.los.finance.fee.service.IFeeCenterService;
 import org.springblade.system.entity.Dept;
@@ -150,23 +151,52 @@ public class ReportsBoxServiceImpl implements IReportsBoxService {
 					.eq(FeeCenter::getStlPid, expenseApplication.getId());
 				List<FeeCenter> feeCenterList = feeCenterService.list(feeCenterLambdaQueryWrapper);
 				if (!feeCenterList.isEmpty()) {
+					List<ExpenseApplicationFeeReports> reportsListD = new ArrayList<>();
+					List<ExpenseApplicationFeeReports> reportsListC = new ArrayList<>();
 					for (FeeCenter item : feeCenterList) {
+						ExpenseApplicationFeeReports reports = new ExpenseApplicationFeeReports();
+						reports.setPid(item.getPid());
+						reports.setStlPid(item.getStlPid());
+						reports.setCorpCnName(item.getShortName());
+						reports.setFeeCnName(item.getFeeCnName());
+						reports.setDc(item.getDc());
+						reports.setRemarks(item.getRemarks());
+						reports.setQuantity(item.getQuantity());
+						reports.setUnitNo(item.getUnitNo());
+						reports.setPrice(item.getPrice());
+						reports.setFeeEnName(item.getFeeEnName());
 						if ("D".equals(item.getDc())) {
 							if (exrateType.equals(item.getCurCode())) {
 								amountDr = amountDr.add(item.getAmount());
 								amountDrLoc = amountDrLoc.add(item.getAmount());
+								reports.setAmount(item.getAmount());
+								reports.setAmountUsd(new BigDecimal("0.00"));
+								reports.setAmountLoc(item.getAmount());
 							} else {
 								amountDrUsd = amountDrUsd.add(item.getAmount());
-								amountDrLoc = amountDrLoc.add(currencyUtils.converter(item.getDc(), curExrateList, item.getAmount(), item.getCurCode(), "1"));
+								BigDecimal amount = currencyUtils.converter(item.getDc(), curExrateList, item.getAmount(), item.getCurCode(), "1");
+								amountDrLoc = amountDrLoc.add(amount);
+								reports.setAmount(new BigDecimal("0.00"));
+								reports.setAmountUsd(item.getAmount());
+								reports.setAmountLoc(amount);
 							}
+							reportsListD.add(reports);
 						} else {
 							if (exrateType.equals(item.getCurCode())) {
 								amountCr = amountCr.add(item.getAmount());
 								amountCrLoc = amountCrLoc.add(item.getAmount());
+								reports.setAmount(item.getAmount());
+								reports.setAmountUsd(new BigDecimal("0.00"));
+								reports.setAmountLoc(item.getAmount());
 							} else {
+								BigDecimal amount = currencyUtils.converter(item.getDc(), curExrateList, item.getAmount(), item.getCurCode(), "1");
 								amountCrUsd = amountCrUsd.add(item.getAmount());
-								amountCrLoc = amountCrLoc.add(currencyUtils.converter(item.getDc(), curExrateList, item.getAmount(), item.getCurCode(), "1"));
+								amountCrLoc = amountCrLoc.add(amount);
+								reports.setAmount(new BigDecimal("0.00"));
+								reports.setAmountUsd(item.getAmount());
+								reports.setAmountLoc(amount);
 							}
+							reportsListC.add(reports);
 						}
 					}
 					amountProfit = amountDr.subtract(amountCr);
@@ -182,10 +212,8 @@ public class ReportsBoxServiceImpl implements IReportsBoxService {
 					tradingBox.setAmountCrLoc(amountCrLoc);
 					tradingBox.setAmountProfitLoc(amountProfitLoc);
 					expenseApplication.setTradingBox(tradingBox);
-					List<FeeCenter> feeCenterListD = feeCenterList.stream().filter(e -> "D".equals(e.getDc())).collect(Collectors.toList());
-					List<FeeCenter> feeCenterListC = feeCenterList.stream().filter(e -> "C".equals(e.getDc())).collect(Collectors.toList());
-					expenseApplication.setFeeCenterList(feeCenterListD.isEmpty() ? new ArrayList<>() : feeCenterListD);
-					expenseApplication.setFeeCenterListC(feeCenterListC.isEmpty() ? new ArrayList<>() : feeCenterListC);
+					expenseApplication.setFeeCenterListC(reportsListC);
+					expenseApplication.setFeeCenterListD(reportsListD);
 				}
 				expenseApplication.setDept(dept);
 				map.put(MagicValues.DATA, expenseApplication);
@@ -235,23 +263,52 @@ public class ReportsBoxServiceImpl implements IReportsBoxService {
 					.eq(FeeCenter::getStlPid, expenseApplication.getId());
 				List<FeeCenter> feeCenterList = feeCenterService.list(feeCenterLambdaQueryWrapper);
 				if (!feeCenterList.isEmpty()) {
+					List<ExpenseApplicationFeeReports> reportsListD = new ArrayList<>();
+					List<ExpenseApplicationFeeReports> reportsListC = new ArrayList<>();
 					for (FeeCenter item : feeCenterList) {
+						ExpenseApplicationFeeReports reports = new ExpenseApplicationFeeReports();
+						reports.setPid(item.getPid());
+						reports.setStlPid(item.getStlPid());
+						reports.setCorpCnName(item.getShortName());
+						reports.setFeeCnName(item.getFeeCnName());
+						reports.setDc(item.getDc());
+						reports.setRemarks(item.getRemarks());
+						reports.setQuantity(item.getQuantity());
+						reports.setUnitNo(item.getUnitNo());
+						reports.setPrice(item.getPrice());
+						reports.setFeeEnName(item.getFeeEnName());
 						if ("D".equals(item.getDc())) {
 							if (exrateType.equals(item.getCurCode())) {
 								amountDr = amountDr.add(item.getAmount());
 								amountDrLoc = amountDrLoc.add(item.getAmount());
+								reports.setAmount(item.getAmount());
+								reports.setAmountUsd(new BigDecimal("0.00"));
+								reports.setAmountLoc(item.getAmount());
 							} else {
 								amountDrUsd = amountDrUsd.add(item.getAmount());
-								amountDrLoc = amountDrLoc.add(currencyUtils.converter(item.getDc(), curExrateList, item.getAmount(), item.getCurCode(), "1"));
+								BigDecimal amount = currencyUtils.converter(item.getDc(), curExrateList, item.getAmount(), item.getCurCode(), "1");
+								amountDrLoc = amountDrLoc.add(amount);
+								reports.setAmount(new BigDecimal("0.00"));
+								reports.setAmountUsd(item.getAmount());
+								reports.setAmountLoc(amount);
 							}
+							reportsListD.add(reports);
 						} else {
 							if (exrateType.equals(item.getCurCode())) {
 								amountCr = amountCr.add(item.getAmount());
 								amountCrLoc = amountCrLoc.add(item.getAmount());
+								reports.setAmount(item.getAmount());
+								reports.setAmountUsd(new BigDecimal("0.00"));
+								reports.setAmountLoc(item.getAmount());
 							} else {
+								BigDecimal amount = currencyUtils.converter(item.getDc(), curExrateList, item.getAmount(), item.getCurCode(), "1");
 								amountCrUsd = amountCrUsd.add(item.getAmount());
-								amountCrLoc = amountCrLoc.add(currencyUtils.converter(item.getDc(), curExrateList, item.getAmount(), item.getCurCode(), "1"));
+								amountCrLoc = amountCrLoc.add(amount);
+								reports.setAmount(new BigDecimal("0.00"));
+								reports.setAmountUsd(item.getAmount());
+								reports.setAmountLoc(amount);
 							}
+							reportsListC.add(reports);
 						}
 					}
 					amountProfit = amountDr.subtract(amountCr);
@@ -267,10 +324,8 @@ public class ReportsBoxServiceImpl implements IReportsBoxService {
 					bills.setAmountCrLoc(amountCrLoc);
 					bills.setAmountProfitLoc(amountProfitLoc);
 					expenseApplication.setBills(bills);
-					List<FeeCenter> feeCenterListD = feeCenterList.stream().filter(e -> "D".equals(e.getDc())).collect(Collectors.toList());
-					List<FeeCenter> feeCenterListC = feeCenterList.stream().filter(e -> "C".equals(e.getDc())).collect(Collectors.toList());
-					expenseApplication.setFeeCenterList(feeCenterListD.isEmpty() ? new ArrayList<>() : feeCenterListD);
-					expenseApplication.setFeeCenterListC(feeCenterListC.isEmpty() ? new ArrayList<>() : feeCenterListC);
+					expenseApplication.setFeeCenterListC(reportsListC);
+					expenseApplication.setFeeCenterListD(reportsListD);
 				}
 				expenseApplication.setDept(dept);
 				map.put(MagicValues.DATA, expenseApplication);

+ 9 - 0
blade-service/blade-los/src/main/java/org/springblade/los/box/controller/ExpenseApplicationController.java

@@ -155,5 +155,14 @@ public class ExpenseApplicationController extends BladeController {
 		return expenseApplicationService.pleaseVerifyCost(expenseApplication);
 	}
 
+	/**
+	 * 请核费用-批量
+	 */
+	@GetMapping("/pleaseVerifyCostBatch")
+	public R pleaseVerifyCostBatch(@RequestParam("ids") String ids,@RequestParam("type") String type,
+								   @RequestParam("dc") String dc) {
+		return expenseApplicationService.pleaseVerifyCostBatch(ids,type,dc);
+	}
+
 
 }

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

@@ -44,4 +44,6 @@ public interface IExpenseApplicationService extends IService<ExpenseApplication>
 	R submit(ExpenseApplication expenseApplication);
 
 	R pleaseVerifyCost(ExpenseApplication expenseApplication);
+
+	R pleaseVerifyCostBatch(String ids,String type,String dc);
 }

+ 194 - 0
blade-service/blade-los/src/main/java/org/springblade/los/box/service/impl/ExpenseApplicationServiceImpl.java

@@ -301,4 +301,198 @@ public class ExpenseApplicationServiceImpl extends ServiceImpl<ExpenseApplicatio
 		return R.data(expenseApplication);
 	}
 
+	@Override
+	@Transactional(rollbackFor = Exception.class)
+	public R pleaseVerifyCostBatch(String ids, String type, String dc) {
+		if (ObjectUtils.isNull(ids)) {
+			throw new RuntimeException("缺少必要参数");
+		}
+		List<FeeCenter> feeCenterList = feeCenterService.list(new LambdaQueryWrapper<FeeCenter>()
+			.eq(FeeCenter::getIsDeleted, 0)
+			.eq(FeeCenter::getTenantId, AuthUtil.getTenantId())
+			.eq(FeeCenter::getAccStatus, "0")
+			.eq(FeeCenter::getAuditStatus, "0")
+			.eq(FeeCenter::getDc, dc)
+			.apply("find_in_set(pid,'" + ids + "')"));
+		if (feeCenterList.isEmpty()) {
+			throw new RuntimeException("未查到可申请费用");
+		}
+		List<ExpenseApplication> expenseApplicationList = new ArrayList<>();
+		if ("BUY,ZR,DL,OW-N,OW-F,XGFY,XGDX,CCSQ".contains(type)) {
+			List<TradingBox> tradingBoxList = tradingBoxService.list(new LambdaQueryWrapper<TradingBox>()
+				.eq(TradingBox::getIsDeleted, 0)
+				.eq(TradingBox::getTenantId, AuthUtil.getTenantId())
+				.apply("find_in_set(id,'" + ids + "')"));
+			for (TradingBox tradingBox : tradingBoxList) {
+				ExpenseApplication expenseApplication = new ExpenseApplication();
+				expenseApplication.setSrcId(tradingBox.getId());
+				expenseApplication.setSrcType(type);
+				expenseApplication.setCreateUser(AuthUtil.getUserId());
+				expenseApplication.setCreateTime(new Date());
+				expenseApplication.setCreateUserName(AuthUtil.getUserName());
+				expenseApplication.setSrcNo(tradingBox.getSysNo());
+				expenseApplication.setSrcMblno(tradingBox.getContractNo());
+				expenseApplication.setSrcContainerNumber(tradingBox.getContainerNumber());
+				expenseApplication.setSrcContractNo(tradingBox.getContractNo());
+				expenseApplication.setStatus("审核提交");
+				expenseApplication.setSrcBusDate(new Date());
+				expenseApplication.setCorpId(tradingBox.getPurchaseCompanyId());
+				expenseApplication.setCorpCnName(tradingBox.getPurchaseCompanyName());
+				expenseApplication.setCorpEnName(tradingBox.getPurchaseCompanyName());
+				expenseApplication.setBranchId(AuthUtil.getDeptId());
+				List<FeeCenter> feeCenters = feeCenterList.stream().filter(e -> e.getPid().equals(tradingBox.getId())).collect(Collectors.toList());
+				if (!feeCenters.isEmpty()) {
+					List<FeeCenter> feeCentersNew = new ArrayList<>();
+					for (FeeCenter item : feeCenters) {
+						item.setUpdateTime(new Date());
+						item.setUpdateUser(AuthUtil.getUserId());
+						item.setUpdateUserName(AuthUtil.getUserName());
+						item.setStlPid(expenseApplication.getId());
+						item.setAuditStatus("1");
+						item.setApplyId(AuthUtil.getUserId());
+						item.setApplyName(AuthUtil.getUserName());
+						item.setApplyTime(new Date());
+						feeCentersNew.add(item);
+					}
+					expenseApplication.setFeeCenterList(feeCentersNew);
+				}
+				expenseApplicationList.add(expenseApplication);
+			}
+		} else if ("HYJK,HYCK".contains(type)) {
+			List<Bills> billsList = billsService.list(new LambdaQueryWrapper<Bills>()
+				.eq(Bills::getIsDeleted, 0)
+				.eq(Bills::getTenantId, AuthUtil.getTenantId())
+				.apply("find_in_set(id,'" + ids + "')"));
+			for (Bills bills : billsList) {
+				ExpenseApplication expenseApplication = new ExpenseApplication();
+				expenseApplication.setSrcId(bills.getId());
+				expenseApplication.setSrcType(type);
+				expenseApplication.setCreateUser(AuthUtil.getUserId());
+				expenseApplication.setCreateTime(new Date());
+				expenseApplication.setCreateUserName(AuthUtil.getUserName());
+				expenseApplication.setSrcNo(bills.getBillNo());
+				expenseApplication.setSrcMblno(bills.getMblno());
+				expenseApplication.setSrcContainerNumber("");
+				expenseApplication.setSrcContractNo(bills.getBookingNo());
+				expenseApplication.setStatus("审核提交");
+				expenseApplication.setSrcBusDate(new Date());
+				expenseApplication.setCorpId(bills.getCorpId());
+				expenseApplication.setCorpCnName(bills.getCorpCnName());
+				expenseApplication.setCorpEnName(bills.getCorpEnName());
+				expenseApplication.setBranchId(bills.getBranchId());
+				expenseApplication.setBranchName(bills.getBranchName());
+				List<FeeCenter> feeCenters = feeCenterList.stream().filter(e -> e.getPid().equals(bills.getId())).collect(Collectors.toList());
+				if (!feeCenters.isEmpty()) {
+					List<FeeCenter> feeCentersNew = new ArrayList<>();
+					for (FeeCenter item : feeCenters) {
+						item.setUpdateTime(new Date());
+						item.setUpdateUser(AuthUtil.getUserId());
+						item.setUpdateUserName(AuthUtil.getUserName());
+						item.setStlPid(expenseApplication.getId());
+						item.setAuditStatus("1");
+						item.setApplyId(AuthUtil.getUserId());
+						item.setApplyName(AuthUtil.getUserName());
+						item.setApplyTime(new Date());
+						feeCentersNew.add(item);
+					}
+					expenseApplication.setFeeCenterList(feeCentersNew);
+				}
+				expenseApplicationList.add(expenseApplication);
+			}
+		} else {
+			throw new RuntimeException("类型错误,未查到单据");
+		}
+		this.saveBatch(expenseApplicationList);
+		for (ExpenseApplication item : expenseApplicationList){
+			for (FeeCenter feeCenter : item.getFeeCenterList()) {
+				feeCenter.setUpdateTime(new Date());
+				feeCenter.setUpdateUser(AuthUtil.getUserId());
+				feeCenter.setUpdateUserName(AuthUtil.getUserName());
+				feeCenter.setStlPid(item.getId());
+				feeCenter.setAuditStatus("1");
+				feeCenter.setApplyId(AuthUtil.getUserId());
+				feeCenter.setApplyName(AuthUtil.getUserName());
+				feeCenter.setApplyTime(new Date());
+			}
+			if (ObjectUtils.isNotNull(item.getFeeCenterList()) && !item.getFeeCenterList().isEmpty()){
+				feeCenterService.updateBatchById(item.getFeeCenterList());
+			}
+		}
+		Integer actId = 1130;
+		String processType = "请核费用";
+		String checkType = "FYSQ";
+		//审批数据
+		LosAuditProecessDTO auditProecessDTO = new LosAuditProecessDTO();
+		//获取审批级次
+		List<LosAuditPathsLevels> auditPathsLevels;
+		// 判断是否有审批流,如果审批流已开启就进入审批流,否则直接走申请通过
+		LosAuditPathsActs pathsActs;
+		//是否开启流程
+		LambdaQueryWrapper<LosAuditPathsActs> auditPathsActsLambdaQueryWrapper = new LambdaQueryWrapper<>();
+		auditPathsActsLambdaQueryWrapper
+			.eq(LosAuditPathsActs::getIsEnable, 1)
+			.eq(LosAuditPathsActs::getFidStatus, "status")
+			.eq(LosAuditPathsActs::getTenantId, AuthUtil.getTenantId())
+			.eq(LosAuditPathsActs::getSalesCompanyId, AuthUtil.getDeptId())
+			.eq(LosAuditPathsActs::getActId, actId);
+		pathsActs = auditPathsActsService.getOne(auditPathsActsLambdaQueryWrapper);
+		//获取审批信息
+		LosAuditPathsActs losAuditPathsActs = auditPathsActsService.getOne(new LambdaQueryWrapper<LosAuditPathsActs>()
+			.eq(LosAuditPathsActs::getActId, actId)
+			.eq(LosAuditPathsActs::getFidStatus, "status")
+			.eq(LosAuditPathsActs::getSalesCompanyId, AuthUtil.getDeptId())
+			.eq(LosAuditPathsActs::getTenantId, AuthUtil.getTenantId()));
+		Long pathId = losAuditPathsActs.getPathId();
+		auditPathsLevels = auditPathsLevelsService.list(new LambdaQueryWrapper<LosAuditPathsLevels>()
+			.eq(LosAuditPathsLevels::getTenantId, AuthUtil.getTenantId()).eq(LosAuditPathsLevels::getPathId, pathId));
+		auditProecessDTO.setTimes(1);
+		auditProecessDTO.setProcessType(processType);
+		// 没开启审批流直接走 通过流程
+		if (pathsActs == null || pathsActs.getIsEnable() == 2) {
+			throw new SecurityException("当前租户未查询到审批流配置");
+		} else {
+			if (CollectionUtils.isEmpty(auditPathsLevels)) {
+				throw new SecurityException("开启审批失败:未查询到审批信息");
+			}
+			// 绑定审核类型
+			auditProecessDTO.setCheckType(checkType);
+			auditProecessDTO.setPathsLevelsList(auditPathsLevels);
+			auditProecessDTO.setActId(1);
+			auditProecessDTO.setSendUserId(AuthUtil.getUserId());
+			auditProecessDTO.setSendName(AuthUtil.getUserName());
+			auditProecessDTO.setSendTime(new Date());
+			auditProecessDTO.setTenantId(AuthUtil.getTenantId());
+			for (ExpenseApplication expenseApplication : expenseApplicationList) {
+				// 追加跳转路由url
+				auditProecessDTO.setUrl(expenseApplication.getUrl());
+				auditProecessDTO.setPageStatus(expenseApplication.getPageStatus());
+				auditProecessDTO.setPageLabel(expenseApplication.getPageLabel());
+				auditProecessDTO.setOrderRemark(expenseApplication.getRemarks());
+				auditProecessDTO.setSrcBillId(expenseApplication.getId());
+				auditProecessDTO.setBillId(expenseApplication.getSrcId());
+				auditProecessDTO.setBillNo(expenseApplication.getSrcNo());
+				auditProecessDTO.setBillTime(expenseApplication.getCreateTime());
+				auditProecessDTO.setCorpId(expenseApplication.getCorpId());
+				auditProecessDTO.setCorpsName(expenseApplication.getCorpCnName());
+				auditProecessDTO.setReferenceNumber(expenseApplication.getSrcContainerNumber());
+				auditProecessDTO.setMorderNo(expenseApplication.getSrcMblno());
+				auditProecessDTO.setSrcBusType(expenseApplication.getSrcType());
+				auditProecessDTO.setSalesCompanyId(Long.parseLong(expenseApplication.getBranchId()));
+				auditProecessDTO.setSalesCompanyName(expenseApplication.getBranchName());
+				BigDecimal salesPrice = expenseApplication.getFeeCenterList().stream().filter(e -> e.getDc().equals("D"))
+					.map(FeeCenter::getAmount).filter(Objects::nonNull).reduce(BigDecimal.ZERO, BigDecimal::add);
+				BigDecimal costPrice = expenseApplication.getFeeCenterList().stream().filter(e -> e.getDc().equals("C"))
+					.map(FeeCenter::getAmount).filter(Objects::nonNull).reduce(BigDecimal.ZERO, BigDecimal::add);
+				auditProecessDTO.setPayAmount(costPrice);
+				auditProecessDTO.setReceivableAmount(salesPrice);
+				auditProecessDTO.setGrossProfit(salesPrice.subtract(costPrice));
+				R financeProcess = auditProecessService.createFinanceProcess(auditProecessDTO);
+				if (!financeProcess.isSuccess()) {
+					throw new SecurityException("操作失败,请联系管理员");
+				}
+			}
+		}
+		return R.data("操作成功");
+	}
+
 }

+ 4 - 2
blade-service/blade-los/src/main/java/org/springblade/los/box/service/impl/TradingBoxItemServiceImpl.java

@@ -133,8 +133,10 @@ public class TradingBoxItemServiceImpl extends ServiceImpl<TradingBoxItemMapper,
 				if (ObjectUtils.isNull(item.getCurrency())) {
 					throw new RuntimeException("币别不能为空");
 				}
-				if (ObjectUtils.isNull(item.getAmount())) {
-					throw new RuntimeException("金额不能为空");
+				if ("1".contains(type)) {
+					if (ObjectUtils.isNull(item.getAmount())) {
+						throw new RuntimeException("金额不能为空");
+					}
 				}
 			}
 			boxType = excelList.stream().map(TradingBoxItemExcel::getBoxType).filter(Objects::nonNull)

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

@@ -140,7 +140,7 @@ public class BillsController extends BladeController {
 			lambdaQueryWrapper.eq(ObjectUtils.isNotNull(bills.getSrcType()), Bills::getSrcType, bills.getSrcType())
 				.and(ObjectUtils.isNotNull(bills.getSrcCnName()), i -> i.like(Bills::getSrcCnName, bills.getSrcCnName()).or()
 					.like(Bills::getSrcEnName, bills.getSrcCnName()));
-			lambdaQueryWrapper.eq(ObjectUtils.isNotNull(bills.getBranchId()),Bills::getBranchId, bills.getBranchId());
+			lambdaQueryWrapper.eq(ObjectUtils.isNotNull(bills.getBranchId()), Bills::getBranchId, bills.getBranchId());
 		}
 		lambdaQueryWrapper.and(ObjectUtils.isNotNull(bills.getBookingAgentCnName()), i -> i.like(Bills::getBookingAgentCnName, bills.getBookingAgentCnName()).or()
 				.like(Bills::getBookingAgentEnName, bills.getBookingAgentCnName()))
@@ -196,18 +196,30 @@ public class BillsController extends BladeController {
 		if ("SE".equals(bills.getBusinessType())) {
 			if ("1".equals(bills.getBillSort())) {
 				lambdaQueryWrapper.orderByDesc(Bills::getEtd);
+				lambdaQueryWrapper.orderByAsc(Bills::getMasterBillNo);
+				lambdaQueryWrapper.orderByDesc(Bills::getBillType);
 			} else if ("2".equals(bills.getBillSort())) {
 				lambdaQueryWrapper.orderByDesc(Bills::getMblno);
+				lambdaQueryWrapper.orderByAsc(Bills::getMasterBillNo);
+				lambdaQueryWrapper.orderByDesc(Bills::getBillType);
 			} else {
 				lambdaQueryWrapper.orderByDesc(Bills::getEtd);
+				lambdaQueryWrapper.orderByAsc(Bills::getMasterBillNo);
+				lambdaQueryWrapper.orderByDesc(Bills::getBillType);
 			}
 		} else {
 			if ("1".equals(bills.getBillSort())) {
 				lambdaQueryWrapper.orderByDesc(Bills::getEta);
+				lambdaQueryWrapper.orderByAsc(Bills::getMasterBillNo);
+				lambdaQueryWrapper.orderByDesc(Bills::getBillType);
 			} else if ("2".equals(bills.getBillSort())) {
 				lambdaQueryWrapper.orderByDesc(Bills::getMblno);
+				lambdaQueryWrapper.orderByAsc(Bills::getMasterBillNo);
+				lambdaQueryWrapper.orderByDesc(Bills::getBillType);
 			} else {
 				lambdaQueryWrapper.orderByDesc(Bills::getEta);
+				lambdaQueryWrapper.orderByAsc(Bills::getMasterBillNo);
+				lambdaQueryWrapper.orderByDesc(Bills::getBillType);
 			}
 		}
 		IPage<Bills> pages = billsService.page(Condition.getPage(query), lambdaQueryWrapper);
@@ -243,39 +255,11 @@ public class BillsController extends BladeController {
 		LambdaQueryWrapper<Bills> lambdaQueryWrapper = new LambdaQueryWrapper<>();
 		lambdaQueryWrapper.eq(Bills::getIsDeleted, 0)
 			.eq(Bills::getTenantId, AuthUtil.getTenantId())
+			.eq(ObjectUtils.isNotNull(bills.getPolId()), Bills::getPolId, bills.getPolId())
+			.eq(ObjectUtils.isNotNull(bills.getPodId()), Bills::getPodId, bills.getPodId())
 			.like(ObjectUtils.isNotNull(bills.getBillNo()), Bills::getBillNo, bills.getBillNo())
 			.like(ObjectUtils.isNotNull(bills.getMblno()), Bills::getMblno, bills.getMblno())
-			.like(ObjectUtils.isNotNull(bills.getHblno()), Bills::getHblno, bills.getHblno())
-			.like(ObjectUtils.isNotNull(bills.getCorpSource()), Bills::getCorpSource, bills.getCorpSource())
-			.like(ObjectUtils.isNotNull(bills.getCreateUserName()), Bills::getCreateUserName, bills.getCreateUserName())
-			.like(ObjectUtils.isNotNull(bills.getBookingNo()), Bills::getBookingNo, bills.getBookingNo())
-			.and(ObjectUtils.isNotNull(bills.getVesselCnName()), i -> i.like(Bills::getVesselCnName, bills.getVesselCnName()).or()
-				.like(Bills::getVesselEnName, bills.getVesselCnName()))
-			.like(ObjectUtils.isNotNull(bills.getVoyageNo()), Bills::getVoyageNo, bills.getVoyageNo())
-			.and(ObjectUtils.isNotNull(bills.getCorpCnName()), i -> i.like(Bills::getCorpCnName, bills.getCorpCnName()).or()
-				.like(Bills::getCorpEnName, bills.getCorpCnName()))
-			.and(ObjectUtils.isNotNull(bills.getCarrierCnName()), i -> i.like(Bills::getCarrierCnName, bills.getCarrierCnName()).or()
-				.like(Bills::getCarrierEnName, bills.getCarrierCnName()).or().like(Bills::getCarrierArgreementNo, bills.getCarrierCnName()))
-			.and(ObjectUtils.isNotNull(bills.getPodCnName()), i -> i.like(Bills::getPodCnName, bills.getPodCnName()).or()
-				.like(Bills::getPodEnName, bills.getPodCnName()).or().like(Bills::getPodCode, bills.getPodCnName()))
-			.and(ObjectUtils.isNotNull(bills.getPolEnName()), i -> i.like(Bills::getPolCnName, bills.getPolEnName()).or()
-				.like(Bills::getPolEnName, bills.getPolEnName()).or().like(Bills::getPolCode, bills.getPolEnName()))
-			.and(ObjectUtils.isNotNull(bills.getLineCnName()), i -> i.like(Bills::getLineCnName, bills.getLineCnName()).or()
-				.like(Bills::getLineEnName, bills.getLineCnName()))
-			.and(ObjectUtils.isNotNull(bills.getCyCnName()), i -> i.like(Bills::getCyCode, bills.getCyCnName()).or()
-				.like(Bills::getCyCnName, bills.getCyCnName()).or().like(Bills::getCyEnName, bills.getCyCnName()))
-			.eq(ObjectUtils.isNotNull(bills.getSrcType()), Bills::getSrcType, bills.getSrcType())
-			.and(ObjectUtils.isNotNull(bills.getSrcCnName()), i -> i.like(Bills::getSrcCnName, bills.getSrcCnName()).or()
-				.like(Bills::getSrcEnName, bills.getSrcCnName()))
-			.apply(ObjectUtils.isNotNull(bills.getCreateDeptName()), "find_in_set('" + bills.getCreateDeptName() + "',create_dept_name)");
-		if (ObjectUtils.isNotNull(bills.getEtdList()) && !bills.getEtdList().isEmpty()) {
-			lambdaQueryWrapper.ge(Bills::getEtd, bills.getEtdList().get(0));
-			lambdaQueryWrapper.le(Bills::getEtd, bills.getEtdList().get(1));
-		}
-		if (ObjectUtils.isNotNull(bills.getEtaList()) && !bills.getEtaList().isEmpty()) {
-			lambdaQueryWrapper.ge(Bills::getEta, bills.getEtaList().get(0));
-			lambdaQueryWrapper.le(Bills::getEta, bills.getEtaList().get(1));
-		}
+			.like(ObjectUtils.isNotNull(bills.getHblno()), Bills::getHblno, bills.getHblno());
 		if (!AuthUtil.getUserRole().contains("总部") && !AuthUtil.getUserRole().contains("admin")) {
 			lambdaQueryWrapper.eq(Bills::getBranchId, AuthUtil.getDeptId());
 			if (!AuthUtil.getUserRole().contains("secondaryAdmin")) {
@@ -293,76 +277,16 @@ public class BillsController extends BladeController {
 			lambdaQueryWrapper.eq(ObjectUtils.isNotNull(bills.getSrcType()), Bills::getSrcType, bills.getSrcType())
 				.and(ObjectUtils.isNotNull(bills.getSrcCnName()), i -> i.like(Bills::getSrcCnName, bills.getSrcCnName()).or()
 					.like(Bills::getSrcEnName, bills.getSrcCnName()));
-			lambdaQueryWrapper.eq(ObjectUtils.isNotNull(bills.getBranchId()),Bills::getBranchId, bills.getBranchId());
+			lambdaQueryWrapper.eq(ObjectUtils.isNotNull(bills.getBranchId()), Bills::getBranchId, bills.getBranchId());
 		}
 		lambdaQueryWrapper.and(ObjectUtils.isNotNull(bills.getBookingAgentCnName()), i -> i.like(Bills::getBookingAgentCnName, bills.getBookingAgentCnName()).or()
 				.like(Bills::getBookingAgentEnName, bills.getBookingAgentCnName()))
-			.eq(ObjectUtils.isNotNull(bills.getIssueType()), Bills::getIssueType, bills.getIssueType())
-
 			.eq(ObjectUtils.isNotNull(bills.getBillType()), Bills::getBillType, bills.getBillType())
 			.eq(ObjectUtils.isNotNull(bills.getBusinessType()), Bills::getBusinessType, bills.getBusinessType())
 			.eq(ObjectUtils.isNotNull(bills.getSeaType()), Bills::getSeaType, bills.getSeaType())
-
 			.eq(ObjectUtils.isNotNull(bills.getMasterBillNo()), Bills::getMasterBillNo, bills.getMasterBillNo())
+			.ne(Bills::getBillStatus, 3)
 			.eq(ObjectUtils.isNotNull(bills.getMasterId()), Bills::getMasterId, bills.getMasterId());
-		if (ObjectUtils.isNotNull(bills.getBillStatus())) {
-			if ("SE".equals(bills.getBusinessType())) {
-				if ("1,2,3".contains(bills.getBillStatus() + "")) {
-					lambdaQueryWrapper.eq(Bills::getBillStatus, bills.getBillStatus());
-				} else if (0 == bills.getBillStatus()) {
-					lambdaQueryWrapper.and(i -> i.isNull(Bills::getMblno).or().eq(Bills::getMblno, ""));
-					lambdaQueryWrapper.eq(Bills::getBillStatus, 0);
-				} else if (4 == bills.getBillStatus()) {
-					lambdaQueryWrapper.isNotNull(Bills::getMblno)
-						.ne(Bills::getMblno, "");
-					lambdaQueryWrapper.eq(Bills::getBillStatus, 0);
-				} else if (5 == bills.getBillStatus()) {
-					lambdaQueryWrapper.isNotNull(Bills::getActualEtd);
-					lambdaQueryWrapper.eq(Bills::getBillStatus, 0);
-				} else if (6 == bills.getBillStatus()) {
-					lambdaQueryWrapper.isNotNull(Bills::getActualEta);
-					lambdaQueryWrapper.eq(Bills::getBillStatus, 0);
-				}
-			} else if ("SI".equals(bills.getBusinessType())) {
-				if ("1,2,3".contains(bills.getBillStatus() + "")) {
-					lambdaQueryWrapper.eq(Bills::getBillStatus, bills.getBillStatus());
-				} else if (0 == bills.getBillStatus()) {
-					lambdaQueryWrapper.isNotNull(Bills::getMblno)
-						.ne(Bills::getMblno, "");
-					lambdaQueryWrapper.ne(Bills::getBillStatus, "3");
-					lambdaQueryWrapper.ne(Bills::getBillStatus, "1");
-				} else if (6 == bills.getBillStatus()) {
-					lambdaQueryWrapper.isNotNull(Bills::getActualEta);
-					lambdaQueryWrapper.eq(Bills::getBillStatus, 0);
-				} else if (8 == bills.getBillStatus()) {
-					lambdaQueryWrapper.isNotNull(Bills::getReturnEmptyDate);
-					lambdaQueryWrapper.eq(Bills::getBillStatus, 0);
-				} else if (9 == bills.getBillStatus()) {
-					lambdaQueryWrapper.isNotNull(Bills::getChangeOrderDate);
-					lambdaQueryWrapper.eq(Bills::getBillStatus, 0);
-				} else if (10 == bills.getBillStatus()) {
-					lambdaQueryWrapper.isNotNull(Bills::getClearanceDate);
-					lambdaQueryWrapper.eq(Bills::getBillStatus, 0);
-				}
-			}
-		}
-		if ("SE".equals(bills.getBusinessType())) {
-			if ("1".equals(bills.getBillSort())) {
-				lambdaQueryWrapper.orderByDesc(Bills::getEtd);
-			} else if ("2".equals(bills.getBillSort())) {
-				lambdaQueryWrapper.orderByDesc(Bills::getMblno);
-			} else {
-				lambdaQueryWrapper.orderByDesc(Bills::getEtd);
-			}
-		} else {
-			if ("1".equals(bills.getBillSort())) {
-				lambdaQueryWrapper.orderByDesc(Bills::getEta);
-			} else if ("2".equals(bills.getBillSort())) {
-				lambdaQueryWrapper.orderByDesc(Bills::getMblno);
-			} else {
-				lambdaQueryWrapper.orderByDesc(Bills::getEta);
-			}
-		}
 		List<Bills> pages = billsService.list(lambdaQueryWrapper);
 		return R.data(pages);
 	}
@@ -603,7 +527,7 @@ public class BillsController extends BladeController {
 							@RequestParam(value = "billType", required = false) String billType,
 							@RequestParam(value = "copyCntr", required = false) String copyCntr,
 							@RequestParam(value = "copyFee", required = false) String copyFee) {
-		return billsService.batchCopyBills(ids, billType, copyCntr,copyFee);
+		return billsService.batchCopyBills(ids, billType, copyCntr, copyFee);
 	}
 
 	/**
@@ -701,7 +625,7 @@ public class BillsController extends BladeController {
 			lambdaQueryWrapper.eq(ObjectUtils.isNotNull(bills.getSrcType()), Bills::getSrcType, bills.getSrcType())
 				.and(ObjectUtils.isNotNull(bills.getSrcCnName()), i -> i.like(Bills::getSrcCnName, bills.getSrcCnName()).or()
 					.like(Bills::getSrcEnName, bills.getSrcCnName()));
-			lambdaQueryWrapper.eq(ObjectUtils.isNotNull(bills.getBranchId()),Bills::getBranchId, bills.getBranchId());
+			lambdaQueryWrapper.eq(ObjectUtils.isNotNull(bills.getBranchId()), Bills::getBranchId, bills.getBranchId());
 		}
 		lambdaQueryWrapper.and(ObjectUtils.isNotNull(bills.getBookingAgentCnName()), i -> i.like(Bills::getBookingAgentCnName, bills.getBookingAgentCnName()).or()
 				.like(Bills::getBookingAgentEnName, bills.getBookingAgentCnName()))
@@ -752,6 +676,35 @@ public class BillsController extends BladeController {
 				}
 			}
 		}
+		if ("SE".equals(bills.getBusinessType())) {
+			if ("1".equals(bills.getBillSort())) {
+				lambdaQueryWrapper.orderByDesc(Bills::getEtd);
+				lambdaQueryWrapper.orderByAsc(Bills::getMasterBillNo);
+				lambdaQueryWrapper.orderByDesc(Bills::getBillType);
+			} else if ("2".equals(bills.getBillSort())) {
+				lambdaQueryWrapper.orderByDesc(Bills::getMblno);
+				lambdaQueryWrapper.orderByAsc(Bills::getMasterBillNo);
+				lambdaQueryWrapper.orderByDesc(Bills::getBillType);
+			} else {
+				lambdaQueryWrapper.orderByDesc(Bills::getEtd);
+				lambdaQueryWrapper.orderByAsc(Bills::getMasterBillNo);
+				lambdaQueryWrapper.orderByDesc(Bills::getBillType);
+			}
+		} else {
+			if ("1".equals(bills.getBillSort())) {
+				lambdaQueryWrapper.orderByDesc(Bills::getEta);
+				lambdaQueryWrapper.orderByAsc(Bills::getMasterBillNo);
+				lambdaQueryWrapper.orderByDesc(Bills::getBillType);
+			} else if ("2".equals(bills.getBillSort())) {
+				lambdaQueryWrapper.orderByDesc(Bills::getMblno);
+				lambdaQueryWrapper.orderByAsc(Bills::getMasterBillNo);
+				lambdaQueryWrapper.orderByDesc(Bills::getBillType);
+			} else {
+				lambdaQueryWrapper.orderByDesc(Bills::getEta);
+				lambdaQueryWrapper.orderByAsc(Bills::getMasterBillNo);
+				lambdaQueryWrapper.orderByDesc(Bills::getBillType);
+			}
+		}
 		List<Bills> list = billsService.list(lambdaQueryWrapper);
 		List<BillsExcel> billsExcelList = new ArrayList<>();
 		R<List<DictBiz>> res1 = dictBizClient.getList("account_status");

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

@@ -823,9 +823,10 @@ public class BillsServiceImpl extends ServiceImpl<BillsMapper, Bills> implements
 			boolean statusBookingAgentId = ObjectUtils.isNotNull(details.getBookingAgentId()) && !details.getBookingAgentId().equals(bills.getBookingAgentId());
 			boolean shippingAgencyId = ObjectUtils.isNotNull(details.getShippingAgencyId()) && !details.getShippingAgencyId().equals(bills.getShippingAgencyId());
 			boolean carrierId = ObjectUtils.isNotNull(details.getCarrierId()) && !details.getCarrierId().equals(bills.getCarrierId());
+			boolean foreignAgencyId = ObjectUtils.isNotNull(details.getForeignAgencyId()) && !details.getForeignAgencyId().equals(bills.getForeignAgencyId());
 			if (statusEtd || statusEta || statusAtd || statusAta || statusVessel || statusVoyageNo || statusMblno || statusPolId
 				|| statusPodId || statusCyTrailerTime || statusCyReturnTime || statusLineId || statusForwarding || statusBookingAgentId
-				|| shippingAgencyId || bookingDate || carrierId) {
+				|| shippingAgencyId || bookingDate || carrierId || foreignAgencyId) {
 				billsList = baseMapper.selectList(new LambdaQueryWrapper<Bills>()
 					.eq(Bills::getTenantId, AuthUtil.getTenantId())
 					.eq(Bills::getIsDeleted, 0)
@@ -868,6 +869,12 @@ public class BillsServiceImpl extends ServiceImpl<BillsMapper, Bills> implements
 						item.setCarrierCnName(bills.getCarrierCnName());
 						item.setCarrierEnName(bills.getCarrierEnName());
 						item.setCarrierArgreementNo(bills.getCarrierArgreementNo());
+						item.setForeignAgencyId(bills.getForeignAgencyId());
+						item.setForeignAgencyCode(bills.getForeignAgencyCode());
+						item.setForeignAgencyCnName(bills.getForeignAgencyCnName());
+						item.setForeignAgencyEnName(bills.getForeignAgencyEnName());
+						item.setForeignAgencyDetails(bills.getForeignAgencyDetails());
+						item.setForeignCntyName(bills.getForeignCntyName());
 					}
 					this.updateBatchById(billsList);
 					List<Long> billIds = billsList.stream().map(Bills::getId).collect(Collectors.toList());
@@ -1160,16 +1167,6 @@ public class BillsServiceImpl extends ServiceImpl<BillsMapper, Bills> implements
 				item.setVesselCnName(bills.getVesselCnName());
 				item.setVesselEnName(bills.getVesselEnName());
 				item.setVoyageNo(bills.getVoyageNo());
-				item.setPolId(bills.getPolId());
-				item.setPolCnName(bills.getPolCnName());
-				item.setPolEnName(bills.getPolEnName());
-				item.setPolCode(bills.getPolCode());
-				item.setPolNamePrint(bills.getPolNamePrint());
-				item.setPodId(bills.getPodId());
-				item.setPodCnName(bills.getPodCnName());
-				item.setPodEnName(bills.getPodEnName());
-				item.setPodNamePrint(bills.getPodNamePrint());
-				item.setPodCode(bills.getPodCode());
 				item.setCyTrailerTime(bills.getCyTrailerTime());
 				item.setCyReturnTime(bills.getCyReturnTime());
 				item.setLineId(bills.getLineId());
@@ -1189,6 +1186,12 @@ public class BillsServiceImpl extends ServiceImpl<BillsMapper, Bills> implements
 				item.setDestinationName(bills.getDestinationName());
 				item.setDestinationCode(bills.getDestinationCode());
 				item.setDestinationNamePrint(bills.getDestinationNamePrint());
+				item.setForeignAgencyId(bills.getForeignAgencyId());
+				item.setForeignAgencyCode(bills.getForeignAgencyCode());
+				item.setForeignAgencyCnName(bills.getForeignAgencyCnName());
+				item.setForeignAgencyEnName(bills.getForeignAgencyEnName());
+				item.setForeignAgencyDetails(bills.getForeignAgencyDetails());
+				item.setForeignCntyName(bills.getForeignCntyName());
 				item.setCarrierId(bills.getCarrierId());
 				item.setCarrierCnName(bills.getCarrierCnName());
 				item.setCarrierEnName(bills.getCarrierEnName());
@@ -1198,7 +1201,6 @@ public class BillsServiceImpl extends ServiceImpl<BillsMapper, Bills> implements
 				item.setUpdateUserName(AuthUtil.getUserName());
 			}
 			this.updateBatchById(billsList);
-
 			BigDecimal amountDr = bills.getAmountDr();
 			BigDecimal amountCr = bills.getAmountCr();
 			BigDecimal amountProfit = bills.getAmountProfit();
@@ -1208,7 +1210,12 @@ public class BillsServiceImpl extends ServiceImpl<BillsMapper, Bills> implements
 			BigDecimal amountDrLoc = bills.getAmountDrLoc();
 			BigDecimal amountCrLoc = bills.getAmountCrLoc();
 			BigDecimal amountProfitLoc = bills.getAmountProfitLoc();
+			BigDecimal grossWeight = bills.getGrossWeight();
+			BigDecimal quantity = bills.getQuantity();
+			BigDecimal measurement = bills.getMeasurement();
 			Integer teuTotal = bills.getTeuTotal();
+			String marks = "";
+			String commodityDescr = "";
 			if (!billsList.isEmpty()) {
 				amountDr = amountDr.add(billsList.stream().map(Bills::getAmountDr).filter(Objects::nonNull).reduce(BigDecimal.ZERO, BigDecimal::add));
 				amountCr = amountCr.add(billsList.stream().map(Bills::getAmountCr).filter(Objects::nonNull).reduce(BigDecimal.ZERO, BigDecimal::add));
@@ -1220,6 +1227,12 @@ public class BillsServiceImpl extends ServiceImpl<BillsMapper, Bills> implements
 				amountCrLoc = amountCrLoc.add(billsList.stream().map(Bills::getAmountCrLoc).filter(Objects::nonNull).reduce(BigDecimal.ZERO, BigDecimal::add));
 				amountProfitLoc = amountProfitLoc.add(billsList.stream().map(Bills::getAmountProfitLoc).filter(Objects::nonNull).reduce(BigDecimal.ZERO, BigDecimal::add));
 				teuTotal = teuTotal + billsList.stream().map(Bills::getTeu).filter(Objects::nonNull).reduce(0, Integer::sum);
+				grossWeight = grossWeight.add(billsList.stream().map(Bills::getGrossWeight).filter(Objects::nonNull).reduce(BigDecimal.ZERO, BigDecimal::add));
+				quantity = quantity.add(billsList.stream().map(Bills::getQuantity).filter(Objects::nonNull).reduce(BigDecimal.ZERO, BigDecimal::add));
+				measurement = measurement.add(billsList.stream().map(Bills::getMeasurement).filter(Objects::nonNull).reduce(BigDecimal.ZERO, BigDecimal::add));
+				marks = billsList.stream().map(Bills::getMarks).filter(Objects::nonNull).collect(Collectors.joining("&"));
+				commodityDescr = billsList.stream().map(Bills::getCommodityDescr).filter(Objects::nonNull).collect(Collectors.joining("&"));
+				this.itemCopy(bills, billsList);
 			}
 			bills.setTeuTotal(teuTotal);
 			bills.setAmountDr(amountDr);
@@ -1231,12 +1244,101 @@ public class BillsServiceImpl extends ServiceImpl<BillsMapper, Bills> implements
 			bills.setAmountDrLoc(amountDrLoc);
 			bills.setAmountCrLoc(amountCrLoc);
 			bills.setAmountProfitLoc(amountProfitLoc);
+			bills.setGrossWeight(grossWeight);
+			bills.setQuantity(quantity);
+			bills.setMeasurement(measurement);
 			bills.setSplitOrderSum(bills.getSplitOrderSum() + billsList.size());
+			if (ObjectUtils.isNotNull(marks)) {
+				marks = marks.replaceAll("N/M", "");
+				bills.setMarks(bills.getMarks() + "&" + marks);
+			}
+			if (ObjectUtils.isNotNull(commodityDescr)) {
+				bills.setCommodityDescr(bills.getCommodityDescr() + "&" + commodityDescr);
+			}
 			baseMapper.updateById(bills);
 		}
 		return R.data("操作成功");
 	}
 
+	private void itemCopy(Bills bills, List<Bills> billsList) {
+		List<Containers> containersList = containersService.list(new LambdaQueryWrapper<Containers>()
+			.eq(Containers::getTenantId, AuthUtil.getTenantId())
+			.eq(Containers::getIsDeleted, 0)
+			.in(Containers::getPid, billsList.stream().map(Bills::getId).collect(Collectors.toList())));
+		if (!containersList.isEmpty()) {
+			List<Containers> containersListNew = new ArrayList<>();
+			for (Containers item : containersList) {
+				item.setSrcSplitOrderId(item.getPid());
+				item.setSrcId(item.getId());
+				item.setId(null);
+				item.setPid(bills.getId());
+				item.setCreateTime(new Date());
+				item.setCreateUser(AuthUtil.getUserId());
+				item.setCreateUserName(AuthUtil.getUserName());
+				item.setBranchId(bills.getBranchId());
+				item.setUpdateUser(null);
+				item.setUpdateTime(null);
+				item.setUpdateUserName(null);
+				containersListNew.add(item);
+			}
+			containersService.saveBatch(containersListNew);
+			List<ContainersCommodity> containersCommodityList = containersCommodityService.list(new LambdaQueryWrapper<ContainersCommodity>()
+				.eq(ContainersCommodity::getTenantId, AuthUtil.getTenantId())
+				.eq(ContainersCommodity::getIsDeleted, 0)
+				.in(ContainersCommodity::getPpId, billsList.stream().map(Bills::getId).collect(Collectors.toList())));
+			if (!containersCommodityList.isEmpty()) {
+				List<ContainersCommodity> containersCommodityListNew = new ArrayList<>();
+				for (ContainersCommodity item : containersCommodityList) {
+					Containers containers = containersListNew.stream().filter(e -> e.getSrcId().equals(item.getPid())).findFirst().orElse(null);
+					if (containers != null) {
+						item.setSrcSplitOrderId(item.getPid());
+						item.setId(null);
+						item.setCreateTime(new Date());
+						item.setCreateUser(AuthUtil.getUserId());
+						item.setCreateUserName(AuthUtil.getUserName());
+						item.setBranchId(bills.getBranchId());
+						item.setUpdateUser(null);
+						item.setUpdateTime(null);
+						item.setUpdateUserName(null);
+						item.setPid(containers.getId());
+						item.setPpId(bills.getId());
+					} else {
+						throw new RuntimeException("装箱明细数据错误,请联系管理员");
+					}
+					containersCommodityListNew.add(item);
+				}
+				containersCommodityService.saveBatch(containersCommodityListNew);
+			}
+			List<ContainersBills> containersBillsList = containersBillsService.list(new LambdaQueryWrapper<ContainersBills>()
+				.eq(ContainersBills::getTenantId, AuthUtil.getTenantId())
+				.eq(ContainersBills::getIsDeleted, 0)
+				.in(ContainersBills::getPpId, billsList.stream().map(Bills::getId).collect(Collectors.toList())));
+			if (!containersBillsList.isEmpty()) {
+				List<ContainersBills> containersBillsListNew = new ArrayList<>();
+				for (ContainersBills item : containersBillsList) {
+					Containers containers = containersListNew.stream().filter(e -> e.getSrcId().equals(item.getPid())).findFirst().orElse(null);
+					if (containers != null) {
+						item.setSrcSplitOrderId(item.getPid());
+						item.setId(null);
+						item.setCreateTime(new Date());
+						item.setCreateUser(AuthUtil.getUserId());
+						item.setCreateUserName(AuthUtil.getUserName());
+						item.setBranchId(bills.getBranchId());
+						item.setUpdateUser(null);
+						item.setUpdateTime(null);
+						item.setUpdateUserName(null);
+						item.setPid(containers.getId());
+						item.setPpId(bills.getId());
+					} else {
+						throw new RuntimeException("装箱明细数据错误,请联系管理员");
+					}
+					containersBillsListNew.add(item);
+				}
+				containersBillsService.saveBatch(containersBillsListNew);
+			}
+		}
+	}
+
 	@Override
 	@Transactional(rollbackFor = Exception.class)
 	public R revokeReinsurancePolicy(String ids, String id) {
@@ -1253,6 +1355,7 @@ public class BillsServiceImpl extends ServiceImpl<BillsMapper, Bills> implements
 			for (Bills item : billsList) {
 				item.setMasterId(0L);
 				item.setMasterBillNo("");
+				item.setMblno("");
 				item.setUpdateTime(new Date());
 				item.setUpdateUser(AuthUtil.getUserId());
 				item.setUpdateUserName(AuthUtil.getUserName());
@@ -1267,6 +1370,9 @@ public class BillsServiceImpl extends ServiceImpl<BillsMapper, Bills> implements
 			BigDecimal amountDrLoc = bills.getAmountDrLoc();
 			BigDecimal amountCrLoc = bills.getAmountCrLoc();
 			BigDecimal amountProfitLoc = bills.getAmountProfitLoc();
+			BigDecimal grossWeight = bills.getGrossWeight();
+			BigDecimal quantity = bills.getQuantity();
+			BigDecimal measurement = bills.getMeasurement();
 			Integer teuTotal = bills.getTeuTotal();
 			if (!billsList.isEmpty()) {
 				amountDr = amountDr.subtract(billsList.stream().map(Bills::getAmountDr).filter(Objects::nonNull).reduce(BigDecimal.ZERO, BigDecimal::add));
@@ -1280,6 +1386,32 @@ public class BillsServiceImpl extends ServiceImpl<BillsMapper, Bills> implements
 				amountProfitLoc = amountProfitLoc.subtract(billsList.stream().map(Bills::getAmountProfitLoc).filter(Objects::nonNull).reduce(BigDecimal.ZERO, BigDecimal::add));
 				amountProfitLoc = amountProfitLoc.subtract(billsList.stream().map(Bills::getAmountProfitLoc).filter(Objects::nonNull).reduce(BigDecimal.ZERO, BigDecimal::add));
 				teuTotal = teuTotal - billsList.stream().map(Bills::getTeu).filter(Objects::nonNull).reduce(0, Integer::sum);
+				grossWeight = grossWeight.subtract(billsList.stream().map(Bills::getGrossWeight).filter(Objects::nonNull).reduce(BigDecimal.ZERO, BigDecimal::add));
+				quantity = quantity.subtract(billsList.stream().map(Bills::getQuantity).filter(Objects::nonNull).reduce(BigDecimal.ZERO, BigDecimal::add));
+				measurement = measurement.subtract(billsList.stream().map(Bills::getMeasurement).filter(Objects::nonNull).reduce(BigDecimal.ZERO, BigDecimal::add));
+				this.itemRevoke(bills, billsList);
+			}
+			List<Bills> billsList1 = baseMapper.selectList(new LambdaQueryWrapper<Bills>()
+				.eq(Bills::getTenantId, AuthUtil.getTenantId())
+				.eq(Bills::getIsDeleted, 0)
+				.eq(Bills::getMasterId, bills.getId())
+				.notIn(Bills::getId, idArr));
+			if (!billsList1.isEmpty()) {
+				String marks = billsList.stream().map(Bills::getMarks).filter(Objects::nonNull).collect(Collectors.joining("&"));
+				String commodityDescr = billsList.stream().map(Bills::getCommodityDescr).filter(Objects::nonNull).collect(Collectors.joining("&"));
+				if (ObjectUtils.isNotNull(marks)) {
+					bills.setMarks(bills.getMarks() + "&" + marks);
+				}
+				if (ObjectUtils.isNotNull(commodityDescr)) {
+					bills.setCommodityDescr(bills.getCommodityDescr() + "&" + commodityDescr);
+				}
+			} else {
+				if (ObjectUtils.isNotNull(bills.getMarks())) {
+					bills.setMarks(bills.getMarks().substring(0, bills.getMarks().indexOf("&")));
+				}
+				if (ObjectUtils.isNotNull(bills.getCommodityDescr())) {
+					bills.setCommodityDescr(bills.getCommodityDescr().substring(0, bills.getCommodityDescr().indexOf("&")));
+				}
 			}
 			bills.setTeuTotal(teuTotal);
 			bills.setAmountDr(amountDr);
@@ -1291,6 +1423,9 @@ public class BillsServiceImpl extends ServiceImpl<BillsMapper, Bills> implements
 			bills.setAmountDrLoc(amountDrLoc);
 			bills.setAmountCrLoc(amountCrLoc);
 			bills.setAmountProfitLoc(amountProfitLoc);
+			bills.setGrossWeight(grossWeight);
+			bills.setQuantity(quantity);
+			bills.setMeasurement(measurement);
 			bills.setMasterBillNo("");
 			bills.setMasterId(0L);
 			bills.setSplitOrderSum(bills.getSplitOrderSum() - billsList.size());
@@ -1299,6 +1434,35 @@ public class BillsServiceImpl extends ServiceImpl<BillsMapper, Bills> implements
 		return R.data("操作成功");
 	}
 
+	private void itemRevoke(Bills bills, List<Bills> billsList) {
+		List<Containers> containersList = containersService.list(new LambdaQueryWrapper<Containers>()
+			.eq(Containers::getTenantId, AuthUtil.getTenantId())
+			.eq(Containers::getIsDeleted, 0)
+			.eq(Containers::getPid, bills.getId())
+			.in(Containers::getSrcSplitOrderId, billsList.stream().map(Bills::getId).collect(Collectors.toList()))
+		);
+		if (!containersList.isEmpty()) {
+			containersService.removeByIds(containersList.stream().map(Containers::getId).collect(Collectors.toList()));
+			List<ContainersCommodity> containersCommodityList = containersCommodityService.list(new LambdaQueryWrapper<ContainersCommodity>()
+				.eq(ContainersCommodity::getTenantId, AuthUtil.getTenantId())
+				.eq(ContainersCommodity::getPpId, bills.getId())
+				.in(ContainersCommodity::getSrcSplitOrderId, billsList.stream().map(Bills::getId).collect(Collectors.toList()))
+			);
+			if (!containersCommodityList.isEmpty()) {
+				containersCommodityService.removeByIds(containersCommodityList.stream().map(ContainersCommodity::getId).collect(Collectors.toList()));
+			}
+			List<ContainersBills> containersBillsList = containersBillsService.list(new LambdaQueryWrapper<ContainersBills>()
+				.eq(ContainersBills::getTenantId, AuthUtil.getTenantId())
+				.eq(ContainersBills::getIsDeleted, 0)
+				.eq(ContainersBills::getPpId, bills.getId())
+				.in(ContainersBills::getSrcSplitOrderId, billsList.stream().map(Bills::getId).collect(Collectors.toList()))
+			);
+			if (!containersBillsList.isEmpty()) {
+				containersBillsService.removeByIds(containersBillsList.stream().map(ContainersBills::getId).collect(Collectors.toList()));
+			}
+		}
+	}
+
 	@Override
 	@Transactional(rollbackFor = Exception.class)
 	public void removeIds(List<Long> ids) {
@@ -1355,6 +1519,12 @@ public class BillsServiceImpl extends ServiceImpl<BillsMapper, Bills> implements
 			.eq(Bills::getIsDeleted, 0)
 			.in(Bills::getId, ids));
 		for (Bills item : billsList) {
+			if ("MH".equals(item.getBillType()) && ObjectUtils.isNotNull(item.getMasterBillNo())) {
+				throw new RuntimeException("单号:" + item.getBillNo() + "已添加主单,请先撤销在退舱");
+			}
+			if ("MM".equals(item.getBillType()) && item.getSplitOrderSum() != 0) {
+				throw new RuntimeException("单号:" + item.getBillNo() + "主单下存在分单,请先撤销在退舱");
+			}
 			if (item.getBillStatus() == 1) {
 				throw new RuntimeException("已退舱,请勿重复操作");
 			}
@@ -1880,6 +2050,8 @@ public class BillsServiceImpl extends ServiceImpl<BillsMapper, Bills> implements
 		copyBills.setBookingNo("");
 		copyBills.setMasterBillNo(null);
 		copyBills.setMasterId(null);
+		copyBills.setSplitOrderSum(0);
+		copyBills.setTeuTotal(0);
 		copyBills.setStatus(0);
 		copyBills.setBillStatus(0);
 		copyBills.setBillingStatus(0);
@@ -3455,6 +3627,8 @@ public class BillsServiceImpl extends ServiceImpl<BillsMapper, Bills> implements
 			copyBills.setStatus(0);
 			copyBills.setBillStatus(0);
 			copyBills.setBillingStatus(0);
+			copyBills.setSplitOrderSum(0);
+			copyBills.setTeuTotal(0);
 			copyBills.setWhetherSail(null);
 			copyBills.setLogisticsStatus(null);
 			copyBills.setWhetherReachHarbor(null);

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

@@ -256,17 +256,22 @@ public class FeeCenterServiceImpl extends ServiceImpl<FeeCenterMapper, FeeCenter
 				feeCenter.setPaymode(bills.getMpaymode());
 				feeCenter.setSort(count);
 				count++;
-				if ("客户".equals(items.getCorpType())) {
+				if ("国内直接客户,国外直接客户,国内同行及代理".contains(items.getCorpType())) {
 					feeCenter.setCorpId(bills.getCorpId());
 					feeCenter.setCorpCnName(bills.getShortName());
 					feeCenter.setCorpEnName(bills.getCorpEnName());
 					feeCenter.setShortName(bills.getShortName());
-				} else if ("船公司".equals(items.getCorpType())) {
+				} else if ("国外同行及代理".contains(items.getCorpType())) {
+					feeCenter.setCorpId(bills.getForeignAgencyId());
+					feeCenter.setCorpCnName(bills.getForeignAgencyCnName());
+					feeCenter.setCorpEnName(bills.getForeignAgencyEnName());
+					feeCenter.setShortName(bills.getForeignAgencyCnName());
+				}else if ("船公司".contains(items.getCorpType())) {
 					feeCenter.setCorpId(bills.getCarrierId());
 					feeCenter.setCorpCnName(bills.getCarrierShortName());
 					feeCenter.setCorpEnName(bills.getCarrierEnName());
 					feeCenter.setShortName(bills.getCarrierShortName());
-				} else if ("场站".equals(items.getCorpType())) {
+				} else if ("场站".contains(items.getCorpType())) {
 					BCorps bCorps = null;
 					if (!corpsList.isEmpty()) {
 						bCorps = corpsList.stream().filter(e -> e.getId().equals(bills.getCyId())).findFirst().orElse(null);
@@ -275,34 +280,12 @@ public class FeeCenterServiceImpl extends ServiceImpl<FeeCenterMapper, FeeCenter
 					feeCenter.setCorpCnName(bCorps == null ? bills.getCyCnName() : bCorps.getShortName());
 					feeCenter.setCorpEnName(bills.getCyEnName());
 					feeCenter.setShortName(bCorps == null ? bills.getCyCnName() : bCorps.getShortName());
-				} else if ("订舱代理".equals(items.getCorpType())) {
-					BCorps bCorps = null;
-					if (!corpsList.isEmpty()) {
-						bCorps = corpsList.stream().filter(e -> e.getId().equals(bills.getBookingAgentId())).findFirst().orElse(null);
-					}
-					feeCenter.setCorpId(bills.getBookingAgentId());
-					feeCenter.setCorpCnName(bCorps == null ? bills.getBookingAgentCnName() : bCorps.getShortName());
-					feeCenter.setCorpEnName(bills.getBookingAgentEnName());
-					feeCenter.setShortName(bCorps == null ? bills.getBookingAgentCnName() : bCorps.getShortName());
-				} else if ("收货代理".equals(items.getCorpType())) {
-					BCorps bCorps = null;
-					if (!corpsList.isEmpty()) {
-						bCorps = corpsList.stream().filter(e -> e.getId().equals(bills.getMconsigneeId())).findFirst().orElse(null);
-					}
-					feeCenter.setCorpId(bills.getMconsigneeId());
-					feeCenter.setCorpCnName(bCorps == null ? bills.getMconsigneeCnName() : bCorps.getShortName());
-					feeCenter.setCorpEnName(bills.getMconsigneeEnName());
-					feeCenter.setShortName(bCorps == null ? bills.getMconsigneeCnName() : bCorps.getShortName());
-				} else if ("MBL通知人".equals(items.getCorpType())) {
-					BCorps bCorps = null;
-					if (!corpsList.isEmpty()) {
-						bCorps = corpsList.stream().filter(e -> e.getId().equals(bills.getMnotifyId())).findFirst().orElse(null);
-					}
-					feeCenter.setCorpId(bills.getMnotifyId());
-					feeCenter.setCorpCnName(bCorps == null ? bills.getMnotifyCnName() : bCorps.getShortName());
-					feeCenter.setCorpEnName(bills.getMnotifyEnName());
-					feeCenter.setShortName(bCorps == null ? bills.getMnotifyCnName() : bCorps.getShortName());
-				} else {
+				} else if ("船代".contains(items.getCorpType())) {
+					feeCenter.setCorpId(bills.getShippingAgencyId());
+					feeCenter.setCorpCnName(bills.getShippingAgencyCname());
+					feeCenter.setCorpEnName(bills.getShippingAgencyEname());
+					feeCenter.setShortName(bills.getShippingAgencyCname());
+				}  else {
 					BCorps bCorps = null;
 					if (!corpsList.isEmpty()) {
 						bCorps = corpsList.stream().filter(e -> e.getId().equals(items.getCorpId())).findFirst().orElse(null);
@@ -319,7 +302,11 @@ public class FeeCenterServiceImpl extends ServiceImpl<FeeCenterMapper, FeeCenter
 				feeCenter.setUnitNo(items.getUnitNo());
 				feeCenter.setPrice(items.getPrice());
 				feeCenter.setCurCode(items.getCurCode());
-				feeCenter.setExrate(currencyUtils.obtainExrate(feeCenter.getDc(), curExrateList, feeCenter.getCurCode(), "1"));
+				if (exrateType.equals(items.getCurCode())){
+					feeCenter.setExrate(new BigDecimal("1"));
+				}else{
+					feeCenter.setExrate(currencyUtils.obtainExrate(feeCenter.getDc(), curExrateList, feeCenter.getCurCode(), "1"));
+				}
 				if ("按箱型".equals(items.getQuantityRule())) {
 					if (preContainers.isEmpty()) {
 						text.append("费用:").append(items.getFeeCnName()).append("未找到集装箱信息!");
@@ -352,7 +339,20 @@ public class FeeCenterServiceImpl extends ServiceImpl<FeeCenterMapper, FeeCenter
 					}
 					feeCenter.setQuantity(new BigDecimal(quantity + ""));
 					feeCenter.setAmount(feeCenter.getPrice().multiply(feeCenter.getQuantity()));
-				} else if ("按尺码".equals(items.getQuantityRule())) {
+				} else if ("按箱量".equals(items.getQuantityRule())) {
+					if (preContainers.isEmpty()) {
+						text.append("费用:").append(items.getFeeCnName()).append("未找到集装箱信息!");
+						continue;
+					}
+					Integer quantityGP = preContainers.stream().map(PreContainers::getQuantity).mapToInt(Integer::intValue).sum();
+					BigDecimal quantity = new BigDecimal(quantityGP + "");
+					if (quantity.compareTo(new BigDecimal("0")) == 0) {
+						text.append("费用:").append(items.getFeeCnName()).append("集装箱箱量为零!");
+						continue;
+					}
+					feeCenter.setQuantity(new BigDecimal(quantity + ""));
+					feeCenter.setAmount(feeCenter.getPrice().multiply(feeCenter.getQuantity()));
+				}else if ("按尺码".equals(items.getQuantityRule())) {
 					feeCenter.setQuantity(bills.getMeasurement());
 					feeCenter.setAmount(feeCenter.getPrice().multiply(feeCenter.getQuantity()));
 				} else {
@@ -1078,17 +1078,22 @@ public class FeeCenterServiceImpl extends ServiceImpl<FeeCenterMapper, FeeCenter
 				feeCenter.setPaymode(bills.getMpaymode());
 				feeCenter.setSort(count);
 				count++;
-				if ("客户".equals(templateItems.getCorpType())) {
+				if ("国内直接客户,国外直接客户,国内同行及代理".contains(templateItems.getCorpType())) {
 					feeCenter.setCorpId(bills.getCorpId());
 					feeCenter.setCorpCnName(bills.getShortName());
 					feeCenter.setCorpEnName(bills.getCorpEnName());
 					feeCenter.setShortName(bills.getShortName());
-				} else if ("船公司".equals(templateItems.getCorpType())) {
+				} else if ("国外同行及代理".contains(templateItems.getCorpType())) {
+					feeCenter.setCorpId(bills.getForeignAgencyId());
+					feeCenter.setCorpCnName(bills.getForeignAgencyCnName());
+					feeCenter.setCorpEnName(bills.getForeignAgencyEnName());
+					feeCenter.setShortName(bills.getForeignAgencyCnName());
+				}else if ("船公司".contains(templateItems.getCorpType())) {
 					feeCenter.setCorpId(bills.getCarrierId());
 					feeCenter.setCorpCnName(bills.getCarrierShortName());
 					feeCenter.setCorpEnName(bills.getCarrierEnName());
 					feeCenter.setShortName(bills.getCarrierShortName());
-				} else if ("场站".equals(templateItems.getCorpType())) {
+				} else if ("场站".contains(templateItems.getCorpType())) {
 					BCorps bCorps = null;
 					if (!corpsList.isEmpty()) {
 						bCorps = corpsList.stream().filter(e -> e.getId().equals(bills.getCyId())).findFirst().orElse(null);
@@ -1097,42 +1102,20 @@ public class FeeCenterServiceImpl extends ServiceImpl<FeeCenterMapper, FeeCenter
 					feeCenter.setCorpCnName(bCorps == null ? bills.getCyCnName() : bCorps.getShortName());
 					feeCenter.setCorpEnName(bills.getCyEnName());
 					feeCenter.setShortName(bCorps == null ? bills.getCyCnName() : bCorps.getShortName());
-				} else if ("订舱代理".equals(templateItems.getCorpType())) {
+				} else if ("船代".contains(templateItems.getCorpType())) {
+					feeCenter.setCorpId(bills.getShippingAgencyId());
+					feeCenter.setCorpCnName(bills.getShippingAgencyCname());
+					feeCenter.setCorpEnName(bills.getShippingAgencyEname());
+					feeCenter.setShortName(bills.getShippingAgencyCname());
+				}  else {
 					BCorps bCorps = null;
 					if (!corpsList.isEmpty()) {
-						bCorps = corpsList.stream().filter(e -> e.getId().equals(bills.getBookingAgentId())).findFirst().orElse(null);
-					}
-					feeCenter.setCorpId(bills.getBookingAgentId());
-					feeCenter.setCorpCnName(bCorps == null ? bills.getBookingAgentCnName() : bCorps.getShortName());
-					feeCenter.setCorpEnName(bills.getBookingAgentEnName());
-					feeCenter.setShortName(bCorps == null ? bills.getBookingAgentCnName() : bCorps.getShortName());
-				} else if ("收货代理".equals(templateItems.getCorpType())) {
-					BCorps bCorps = null;
-					if (!corpsList.isEmpty()) {
-						bCorps = corpsList.stream().filter(e -> e.getId().equals(bills.getMconsigneeId())).findFirst().orElse(null);
-					}
-					feeCenter.setCorpId(bills.getMconsigneeId());
-					feeCenter.setCorpCnName(bCorps == null ? bills.getMconsigneeCnName() : bCorps.getShortName());
-					feeCenter.setCorpEnName(bills.getMconsigneeEnName());
-					feeCenter.setShortName(bCorps == null ? bills.getMconsigneeCnName() : bCorps.getShortName());
-				} else if ("MBL通知人".equals(templateItems.getCorpType())) {
-					BCorps bCorps = null;
-					if (!corpsList.isEmpty()) {
-						bCorps = corpsList.stream().filter(e -> e.getId().equals(bills.getMnotifyId())).findFirst().orElse(null);
-					}
-					feeCenter.setCorpId(bills.getMnotifyId());
-					feeCenter.setCorpCnName(bCorps == null ? bills.getMnotifyCnName() : bCorps.getShortName());
-					feeCenter.setCorpEnName(bills.getMnotifyEnName());
-					feeCenter.setShortName(bCorps == null ? bills.getMnotifyCnName() : bCorps.getShortName());
-				} else {
-					BCorps bCorps = null;
-					if (!corpsList.isEmpty()) {
-						bCorps = corpsList.stream().filter(e -> e.getId().equals(templateItems.getCorpId())).findFirst().orElse(null);
+						bCorps = corpsList.stream().filter(e -> e.getId().equals(items.getCorpId())).findFirst().orElse(null);
 					}
-					feeCenter.setCorpId(templateItems.getCorpId());
-					feeCenter.setCorpCnName(bCorps == null ? templateItems.getCorpCnName() : bCorps.getShortName());
-					feeCenter.setCorpEnName(templateItems.getCorpEnName());
-					feeCenter.setShortName(bCorps == null ? templateItems.getCorpCnName() : bCorps.getShortName());
+					feeCenter.setCorpId(items.getCorpId());
+					feeCenter.setCorpCnName(bCorps == null ? items.getCorpCnName() : bCorps.getShortName());
+					feeCenter.setCorpEnName(items.getCorpEnName());
+					feeCenter.setShortName(bCorps == null ? items.getCorpCnName() : bCorps.getShortName());
 				}
 				feeCenter.setFeeId(items.getFeeId());
 				feeCenter.setCorpType(items.getType());
@@ -1179,6 +1162,19 @@ public class FeeCenterServiceImpl extends ServiceImpl<FeeCenterMapper, FeeCenter
 					}
 					feeCenter.setQuantity(new BigDecimal(quantity + ""));
 					feeCenter.setAmount(feeCenter.getPrice().multiply(feeCenter.getQuantity()));
+				}else if ("按箱量".equals(items.getQuantityRule())) {
+					if (preContainers.isEmpty()) {
+						text.append("费用:").append(items.getFeeCnName()).append("未找到集装箱信息!");
+						continue;
+					}
+					Integer quantityGP = preContainers.stream().map(PreContainers::getQuantity).mapToInt(Integer::intValue).sum();
+					BigDecimal quantity = new BigDecimal(quantityGP + "");
+					if (quantity.compareTo(new BigDecimal("0")) == 0) {
+						text.append("费用:").append(items.getFeeCnName()).append("集装箱箱量为零!");
+						continue;
+					}
+					feeCenter.setQuantity(new BigDecimal(quantity + ""));
+					feeCenter.setAmount(feeCenter.getPrice().multiply(feeCenter.getQuantity()));
 				} else if ("按尺码".equals(items.getQuantityRule())) {
 					feeCenter.setQuantity(bills.getMeasurement());
 					feeCenter.setAmount(feeCenter.getPrice().multiply(feeCenter.getQuantity()));

+ 2 - 2
blade-service/blade-los/src/main/java/org/springblade/los/finance/fee/service/impl/FinAccBillsServiceImpl.java

@@ -183,8 +183,8 @@ public class FinAccBillsServiceImpl extends ServiceImpl<FinAccBillsMapper, FinAc
 			data.setCreateDeptName(item.getCreateDeptName());
 			data.setBranchId(item.getBranchId());
 			data.setBranchName(item.getBranchName());
-			data.setDeptId(Long.parseLong(item.getCreateDept()));
-			data.setDeptName(item.getCreateDeptName());
+			data.setDeptId(Long.parseLong(item.getBranchId()));
+			data.setDeptName(item.getBranchName());
 			BusinessBillNo businessBillNo = new BusinessBillNo();
 			businessBillNo.setBusinessTypeId(businessType.getId());
 			businessBillNo.setCode(finAccBills.getBillNoFormat());