Browse Source

2024年1月13日17:11:53

纪新园 2 years ago
parent
commit
4b5074b79d
29 changed files with 800 additions and 249 deletions
  1. 6 0
      blade-service-api/blade-los-api/src/main/java/org/springblade/los/basic/cur/entity/BCurExrate.java
  2. 13 1
      blade-service-api/blade-los-api/src/main/java/org/springblade/los/basic/cur/entity/BCurrency.java
  3. 11 0
      blade-service-api/blade-los-api/src/main/java/org/springblade/los/finance/fee/entity/FeeCenter.java
  4. 5 0
      blade-service-api/blade-los-api/src/main/java/org/springblade/los/finance/fee/entity/ListAccBillVO.java
  5. 21 0
      blade-service-api/blade-los-api/src/main/java/org/springblade/los/finance/fee/vo/FinAccBillsVO.java
  6. 39 0
      blade-service-api/blade-los-api/src/main/java/org/springblade/los/finance/stl/entity/FinStlBillsItems.java
  7. 4 0
      blade-service/blade-los/src/main/java/org/springblade/los/basic/cntr/service/impl/BCntrTypesServiceImpl.java
  8. 14 1
      blade-service/blade-los/src/main/java/org/springblade/los/basic/cur/controller/BCurExrateController.java
  9. 11 0
      blade-service/blade-los/src/main/java/org/springblade/los/basic/cur/controller/BCurrencyController.java
  10. 2 0
      blade-service/blade-los/src/main/java/org/springblade/los/basic/cur/service/IBCurrencyService.java
  11. 81 11
      blade-service/blade-los/src/main/java/org/springblade/los/basic/cur/service/impl/BCurrencyServiceImpl.java
  12. 4 0
      blade-service/blade-los/src/main/java/org/springblade/los/basic/packages/service/impl/BPackagesServiceImpl.java
  13. 2 0
      blade-service/blade-los/src/main/java/org/springblade/los/basic/ports/service/impl/BPortsServiceImpl.java
  14. 4 0
      blade-service/blade-los/src/main/java/org/springblade/los/basic/vessels/service/impl/BVesselsServiceImpl.java
  15. 2 0
      blade-service/blade-los/src/main/java/org/springblade/los/business/sea/mapper/BillsMapper.java
  16. 183 19
      blade-service/blade-los/src/main/java/org/springblade/los/business/sea/mapper/BillsMapper.xml
  17. 11 8
      blade-service/blade-los/src/main/java/org/springblade/los/business/sea/service/impl/BillsServiceImpl.java
  18. 10 10
      blade-service/blade-los/src/main/java/org/springblade/los/business/sea/service/impl/ContainersServiceImpl.java
  19. 0 6
      blade-service/blade-los/src/main/java/org/springblade/los/check/service/impl/AuditProecessServiceImpl.java
  20. 2 11
      blade-service/blade-los/src/main/java/org/springblade/los/edi/service/impl/EDISenderServiceImpl.java
  21. 146 144
      blade-service/blade-los/src/main/java/org/springblade/los/edi/service/impl/EdiTypesServiceImpl.java
  22. 5 0
      blade-service/blade-los/src/main/java/org/springblade/los/finance/fee/controller/FinAccBillsController.java
  23. 7 0
      blade-service/blade-los/src/main/java/org/springblade/los/finance/fee/service/IFinAccBillsService.java
  24. 5 0
      blade-service/blade-los/src/main/java/org/springblade/los/finance/fee/service/impl/FinAccBillsServiceImpl.java
  25. 26 3
      blade-service/blade-los/src/main/java/org/springblade/los/finance/invoices/service/impl/FinInvoicesServiceImpl.java
  26. 12 0
      blade-service/blade-los/src/main/java/org/springblade/los/finance/stl/controller/FinStlBillsController.java
  27. 2 0
      blade-service/blade-los/src/main/java/org/springblade/los/finance/stl/service/IFinStlBillsService.java
  28. 167 34
      blade-service/blade-los/src/main/java/org/springblade/los/finance/stl/service/impl/FinStlBillsServiceImpl.java
  29. 5 1
      blade-service/blade-sales-part/src/main/java/org/springblade/salesPart/corps/controller/CorpsDescController.java

+ 6 - 0
blade-service-api/blade-los-api/src/main/java/org/springblade/los/basic/cur/entity/BCurExrate.java

@@ -184,5 +184,11 @@ public class BCurExrate implements Serializable {
 	@ApiModelProperty(value = "汇率日")
 	private Integer exrateDay;
 
+	/**
+	 * 类型
+	 */
+	@ApiModelProperty(value = "类型")
+	private String type;
+
 
 }

+ 13 - 1
blade-service-api/blade-los-api/src/main/java/org/springblade/los/basic/cur/entity/BCurrency.java

@@ -149,7 +149,7 @@ public class BCurrency implements Serializable {
 	 * 是否已删除(0 否 1是)
 	 */
 	@ApiModelProperty(value = "是否已删除(0 否 1是)")
-	@TableLogic(value = "0",delval = "1")
+	@TableLogic(value = "0", delval = "1")
 	private Integer isDeleted;
 	/**
 	 * 备注
@@ -186,5 +186,17 @@ public class BCurrency implements Serializable {
 	@TableField(exist = false)
 	private List<BCurExrate> curExrateList;
 
+	/**
+	 * 日期
+	 */
+	@TableField(exist = false)
+	private Date date;
+
+	/**
+	 * 类型
+	 */
+	@TableField(exist = false)
+	private String dc;
+
 
 }

+ 11 - 0
blade-service-api/blade-los-api/src/main/java/org/springblade/los/finance/fee/entity/FeeCenter.java

@@ -857,5 +857,16 @@ public class FeeCenter implements Serializable {
 	@ApiModelProperty(value = "已对账金额")
 	private BigDecimal reconciliationAmount;
 
+	/**
+	 * 已申请结算金额
+	 */
+	@ApiModelProperty(value = "已申请金额")
+	private BigDecimal appliedAmountStl;
+	/**
+	 * 已申请发票结算金额
+	 */
+	@ApiModelProperty(value = "已申请发票金额")
+	private BigDecimal appliedInvoiceAmountStl;
+
 
 }

+ 5 - 0
blade-service-api/blade-los-api/src/main/java/org/springblade/los/finance/fee/entity/ListAccBillVO.java

@@ -168,4 +168,9 @@ public class ListAccBillVO extends FinAccBills {
 	@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm")
 	private Date accountDateTo;
 
+	/**
+	 * 账单id
+	 */
+	private Long accId;
+
 }

+ 21 - 0
blade-service-api/blade-los-api/src/main/java/org/springblade/los/finance/fee/vo/FinAccBillsVO.java

@@ -256,10 +256,31 @@ public class FinAccBillsVO extends FinAccBills {
 	 * 已申请发票金额
 	 */
 	private BigDecimal appliedInvoiceAmount;
+	/**
+	 * 已申请结算金额
+	 */
+	private BigDecimal appliedAmountStl;
+	/**
+	 * 本次结算金额C
+	 */
+	private BigDecimal appliedCurrentStlAmount;
+	/**
+	 * 已申请发票结算金额
+	 */
+	private BigDecimal appliedInvoiceAmountStl;
+	/**
+	 * 本次结算金额D
+	 */
+	private BigDecimal appliedInvoiceCurrentStlAmount;
 
 	/**
 	 * 已对账金额
 	 */
 	private BigDecimal reconciliationAmount;
 
+	/**
+	 * 本次
+	 */
+	private BigDecimal currentStlAmount;
+
 }

+ 39 - 0
blade-service-api/blade-los-api/src/main/java/org/springblade/los/finance/stl/entity/FinStlBillsItems.java

@@ -658,4 +658,43 @@ public class FinStlBillsItems implements Serializable {
 	private String srcIdStatus;
 
 
+	/**
+	 * 已申请金额
+	 */
+	@TableField(exist = false)
+	private BigDecimal appliedAmount;
+	/**
+	 * 已申请发票金额
+	 */
+	@TableField(exist = false)
+	private BigDecimal appliedInvoiceAmount;
+	/**
+	 * 已申请结算金额
+	 */
+	@TableField(exist = false)
+	private BigDecimal appliedAmountStl;
+	/**
+	 * 已申请发票结算金额
+	 */
+	@TableField(exist = false)
+	private BigDecimal appliedInvoiceAmountStl;
+
+	/**
+	 * 已对账金额
+	 */
+	@TableField(exist = false)
+	private BigDecimal reconciliationAmount;
+
+	/**
+	 * 本次结算金额C
+	 */
+	@TableField(exist = false)
+	private BigDecimal appliedCurrentStlAmount;
+	/**
+	 * 本次结算金额D
+	 */
+	@TableField(exist = false)
+	private BigDecimal appliedInvoiceCurrentStlAmount;
+
+
 }

+ 4 - 0
blade-service/blade-los/src/main/java/org/springblade/los/basic/cntr/service/impl/BCntrTypesServiceImpl.java

@@ -20,6 +20,7 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import io.seata.spring.annotation.GlobalTransactional;
 import lombok.AllArgsConstructor;
 import org.springblade.core.secure.utils.AuthUtil;
 import org.springblade.core.tool.api.R;
@@ -32,6 +33,7 @@ import org.springblade.los.basic.cntr.vo.BCntrTypesVO;
 import org.springblade.los.excel.BCntrTypesExcel;
 import org.springblade.system.feign.ISysClient;
 import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
 
 import java.util.ArrayList;
 import java.util.Date;
@@ -91,6 +93,8 @@ public class BCntrTypesServiceImpl extends ServiceImpl<CntrTypesMapper, BCntrTyp
 	}
 
 	@Override
+	@Transactional(rollbackFor = Exception.class)
+	@GlobalTransactional(rollbackFor = Exception.class, timeoutMills = 12000000)
 	public R<List<BCntrTypes>> importBCntrTypes(List<BCntrTypesExcel> excelList) {
 		List<BCntrTypes> bCntrTypesList = new ArrayList<>();
 		for (BCntrTypesExcel item : excelList) {

+ 14 - 1
blade-service/blade-los/src/main/java/org/springblade/los/basic/cur/controller/BCurExrateController.java

@@ -16,17 +16,22 @@
  */
 package org.springblade.los.basic.cur.controller;
 
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import io.swagger.annotations.ApiParam;
 import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
 import lombok.AllArgsConstructor;
+
 import javax.validation.Valid;
 
 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.Func;
+import org.springblade.los.basic.cur.entity.BCurrency;
 import org.springframework.web.bind.annotation.*;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import org.springblade.los.basic.cur.entity.BCurExrate;
@@ -66,7 +71,15 @@ public class BCurExrateController extends BladeController {
 	@ApiOperationSupport(order = 2)
 	@ApiOperation(value = "分页", notes = "传入bCurExrate")
 	public R<IPage<BCurExrate>> list(BCurExrate bCurExrate, Query query) {
-		IPage<BCurExrate> pages = bCurExrateService.page(Condition.getPage(query), Condition.getQueryWrapper(bCurExrate));
+		LambdaQueryWrapper<BCurExrate> lambdaQueryWrapper = new LambdaQueryWrapper<>();
+		lambdaQueryWrapper.eq(BCurExrate::getTenantId, AuthUtil.getTenantId())
+			.eq(BCurExrate::getIsDeleted, 0)
+			.eq(ObjectUtils.isNotNull(bCurExrate.getCode()), BCurExrate::getCode, bCurExrate.getCode())
+			.eq(ObjectUtils.isNotNull(bCurExrate.getExrateYear()), BCurExrate::getExrateYear, bCurExrate.getExrateYear())
+			.eq(ObjectUtils.isNotNull(bCurExrate.getExrateMonth()), BCurExrate::getExrateMonth, bCurExrate.getExrateMonth())
+			.eq(ObjectUtils.isNotNull(bCurExrate.getType()), BCurExrate::getType, bCurExrate.getType())
+			.orderByAsc(BCurExrate::getExrateMonth);
+		IPage<BCurExrate> pages = bCurExrateService.page(Condition.getPage(query), lambdaQueryWrapper);
 		return R.data(pages);
 	}
 

+ 11 - 0
blade-service/blade-los/src/main/java/org/springblade/los/basic/cur/controller/BCurrencyController.java

@@ -199,5 +199,16 @@ public class BCurrencyController extends BladeController {
 		return bCurrencyService.importBCurrency(excelList);
 	}
 
+	/**
+	 * 详情
+	 */
+	@GetMapping("/getExrate")
+	@ApiOperationSupport(order = 1)
+	@ApiOperation(value = "详情", notes = "传入bCurrency")
+	public R<List<BCurrency>> getExrate(BCurrency bCurrency) {
+		List<BCurrency> detail = bCurrencyService.getExrate(bCurrency);
+		return R.data(detail);
+	}
+
 
 }

+ 2 - 0
blade-service/blade-los/src/main/java/org/springblade/los/basic/cur/service/IBCurrencyService.java

@@ -79,4 +79,6 @@ public interface IBCurrencyService extends IService<BCurrency> {
 	 * @return 结果
 	 */
 	BigDecimal converterCny(String curCode, BigDecimal amount,String dc);
+
+	List<BCurrency> getExrate(BCurrency bCurrency);
 }

+ 81 - 11
blade-service/blade-los/src/main/java/org/springblade/los/basic/cur/service/impl/BCurrencyServiceImpl.java

@@ -181,13 +181,17 @@ public class BCurrencyServiceImpl extends ServiceImpl<CurrencyMapper, BCurrency>
 			.eq(BCurrency::getCode, curCode));
 		if (ObjectUtils.isNotNull(bCurrency) && ObjectUtils.isNotNull(bCurrency.getExrate()) &&
 			new BigDecimal("0.00").compareTo(bCurrency.getExrate()) != 0) {
-			BCurExrate bCurExrate = bCurExrateService.getOne(new LambdaQueryWrapper<BCurExrate>()
+			LambdaQueryWrapper<BCurExrate> lambdaQueryWrapper = new LambdaQueryWrapper<BCurExrate>()
 				.eq(BCurExrate::getCode, curCode)
 				.eq(BCurExrate::getTenantId, AuthUtil.getTenantId())
 				.eq(BCurExrate::getIsDeleted, 0)
 				.eq(BCurExrate::getExrateYear, year)
-				.eq(BCurExrate::getExrateMonth, month)
-			);
+				.eq(BCurExrate::getType, bCurrency.getParitiesType())
+				;
+			if ("月汇率".equals(bCurrency.getParitiesType())) {
+				lambdaQueryWrapper.eq(BCurExrate::getExrateMonth, month);
+			}
+			BCurExrate bCurExrate = bCurExrateService.getOne(lambdaQueryWrapper);
 			BigDecimal CNY;
 			if ("D".equals(dc)) {
 				if (ObjectUtils.isNull(bCurExrate)) {
@@ -218,13 +222,16 @@ public class BCurrencyServiceImpl extends ServiceImpl<CurrencyMapper, BCurrency>
 				.eq(BCurrency::getCode, "USD"));
 			if (ObjectUtils.isNotNull(bCurrencyUsd) && ObjectUtils.isNotNull(bCurrencyUsd.getExrate()) &&
 				new BigDecimal("0.00").compareTo(bCurrencyUsd.getExrate()) != 0) {
-				BCurExrate bCurExrateUsd = bCurExrateService.getOne(new LambdaQueryWrapper<BCurExrate>()
+				LambdaQueryWrapper<BCurExrate> lambdaQueryWrapperUsd = new LambdaQueryWrapper<BCurExrate>()
 					.eq(BCurExrate::getCode, curCode)
 					.eq(BCurExrate::getTenantId, AuthUtil.getTenantId())
-					.eq(BCurExrate::getIsDeleted, 0)
-					.eq(BCurExrate::getExrateYear, year)
-					.eq(BCurExrate::getExrateMonth, month)
-				);
+					.eq(BCurExrate::getIsDeleted, 0).eq(BCurExrate::getExrateYear, year)
+					.eq(BCurExrate::getType, bCurrency.getParitiesType())
+					;
+				if ("月汇率".equals(bCurrency.getParitiesType())) {
+					lambdaQueryWrapperUsd.eq(BCurExrate::getExrateMonth, month);
+				}
+				BCurExrate bCurExrateUsd = bCurExrateService.getOne(lambdaQueryWrapperUsd);
 				if ("D".equals(dc)) {
 					if (ObjectUtils.isNull(bCurExrateUsd)) {
 						throw new RuntimeException("未找到" + year + "年" + month + "月,币别为USD汇率信息");
@@ -270,13 +277,17 @@ public class BCurrencyServiceImpl extends ServiceImpl<CurrencyMapper, BCurrency>
 			.eq(BCurrency::getCode, curCode));
 		if (ObjectUtils.isNotNull(bCurrency) && ObjectUtils.isNotNull(bCurrency.getExrate()) &&
 			new BigDecimal("0.00").compareTo(bCurrency.getExrate()) != 0) {
-			BCurExrate bCurExrate = bCurExrateService.getOne(new LambdaQueryWrapper<BCurExrate>()
+			LambdaQueryWrapper<BCurExrate> lambdaQueryWrapper = new LambdaQueryWrapper<BCurExrate>()
 				.eq(BCurExrate::getCode, curCode)
 				.eq(BCurExrate::getTenantId, AuthUtil.getTenantId())
 				.eq(BCurExrate::getIsDeleted, 0)
 				.eq(BCurExrate::getExrateYear, year)
-				.eq(BCurExrate::getExrateMonth, month)
-			);
+				.eq(BCurExrate::getType, bCurrency.getParitiesType())
+				;
+			if ("月汇率".equals(bCurrency.getParitiesType())) {
+				lambdaQueryWrapper.eq(BCurExrate::getExrateMonth, month);
+			}
+			BCurExrate bCurExrate = bCurExrateService.getOne(lambdaQueryWrapper);
 			if ("D".equals(dc)) {
 				if (ObjectUtils.isNull(bCurExrate)) {
 					throw new RuntimeException("未找到" + year + "年" + month + "月,币别为USD汇率信息");
@@ -307,4 +318,63 @@ public class BCurrencyServiceImpl extends ServiceImpl<CurrencyMapper, BCurrency>
 		return CNY;
 	}
 
+	@Override
+	public List<BCurrency> getExrate(BCurrency bCurrency) {
+		// 创建 Calendar 对象并设置为当前时间
+		Calendar calendar = Calendar.getInstance();
+		if (ObjectUtils.isNull(bCurrency.getDate())) {
+			bCurrency.setDate(new Date());
+		}
+		calendar.setTime(bCurrency.getDate());
+		int year = calendar.get(Calendar.YEAR); // 获取年份
+		int month = calendar.get(Calendar.MONTH) + 1; // 获取月份(注意需加上1,因为月份从0开始计数)
+		List<BCurrency> bCurrencyList = baseMapper.selectList(new LambdaQueryWrapper<BCurrency>()
+			.eq(BCurrency::getTenantId, AuthUtil.getTenantId())
+			.eq(BCurrency::getIsDeleted, 0)
+			.eq(BCurrency::getStatus, 0));
+		for (BCurrency details :bCurrencyList){
+			if (ObjectUtils.isNotNull(details) && ObjectUtils.isNotNull(details.getExrate()) &&
+				new BigDecimal("0.00").compareTo(details.getExrate()) != 0) {
+				LambdaQueryWrapper<BCurExrate> lambdaQueryWrapper = new LambdaQueryWrapper<BCurExrate>()
+					.eq(BCurExrate::getCode, details.getCode())
+					.eq(BCurExrate::getTenantId, AuthUtil.getTenantId())
+					.eq(BCurExrate::getIsDeleted, 0)
+					.eq(BCurExrate::getExrateYear, year)
+					.eq(BCurExrate::getType, details.getParitiesType())
+					;
+				if ("月汇率".equals(details.getParitiesType())) {
+					lambdaQueryWrapper.eq(BCurExrate::getExrateMonth, month);
+				}
+				BCurExrate bCurExrate = bCurExrateService.getOne(lambdaQueryWrapper);
+				if ("D".equals(bCurrency.getDc())) {
+					if (ObjectUtils.isNull(bCurExrate)) {
+						throw new RuntimeException("未找到" + year + "年" + month + "月,币别为USD汇率信息");
+					}
+					if (ObjectUtils.isNull(bCurExrate.getExrateReceipts()) &&
+						new BigDecimal("0.00").compareTo(bCurExrate.getExrateReceipts()) == 0) {
+						throw new RuntimeException("未找到" + year + "年" + month + "月,币别为" + bCurrency.getCode() + "实收汇率信息");
+					} else {
+						details.setExrate(bCurExrate.getExrateReceipts());
+					}
+				} else if ("C".equals(bCurrency.getDc())) {
+					if (ObjectUtils.isNull(bCurExrate)) {
+						throw new RuntimeException("未找到" + year + "年" + month + "月,币别为USD汇率信息");
+					}
+					if (ObjectUtils.isNull(bCurExrate.getExratePayment()) &&
+						new BigDecimal("0.00").compareTo(bCurExrate.getExratePayment()) == 0) {
+						throw new RuntimeException("未找到" + year + "年" + month + "月,币别为" + bCurrency.getCode() + "实付汇率信息");
+					} else {
+						details.setExrate(bCurExrate.getExratePayment());
+					}
+				} else {
+					throw new RuntimeException("未找到" + year + "年" + month + "月,币别为USD汇率信息");
+				}
+
+			} else {
+				throw new RuntimeException("未找到币别汇率信息");
+			}
+		}
+		return bCurrencyList;
+	}
+
 }

+ 4 - 0
blade-service/blade-los/src/main/java/org/springblade/los/basic/packages/service/impl/BPackagesServiceImpl.java

@@ -20,6 +20,7 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import io.seata.spring.annotation.GlobalTransactional;
 import lombok.AllArgsConstructor;
 import org.springblade.core.secure.utils.AuthUtil;
 import org.springblade.core.tool.api.R;
@@ -32,6 +33,7 @@ import org.springblade.los.basic.packages.service.IBPackagesService;
 import org.springblade.los.basic.packages.vo.BPackagesVO;
 import org.springblade.system.feign.ISysClient;
 import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
 
 import java.util.ArrayList;
 import java.util.Date;
@@ -85,6 +87,8 @@ public class BPackagesServiceImpl extends ServiceImpl<PackagesMapper, BPackages>
 	}
 
 	@Override
+	@Transactional(rollbackFor = Exception.class)
+	@GlobalTransactional(rollbackFor = Exception.class, timeoutMills = 12000000)
 	public R<List<BPackages>> importBPackages(List<BPackagesExcel> excelList) {
 		List<BPackages> bPackagesList = new ArrayList<>();
 		for (BPackagesExcel item : excelList) {

+ 2 - 0
blade-service/blade-los/src/main/java/org/springblade/los/basic/ports/service/impl/BPortsServiceImpl.java

@@ -132,6 +132,8 @@ public class BPortsServiceImpl extends ServiceImpl<PortsMapper, BPorts> implemen
 	}
 
 	@Override
+	@Transactional(rollbackFor = Exception.class)
+	@GlobalTransactional(rollbackFor = Exception.class, timeoutMills = 12000000)
 	public R<List<BPorts>> importBPorts(List<BPortsExcel> excelList) {
 		List<BPorts> bPortsList = new ArrayList<>();
 		for (BPortsExcel item : excelList) {

+ 4 - 0
blade-service/blade-los/src/main/java/org/springblade/los/basic/vessels/service/impl/BVesselsServiceImpl.java

@@ -20,6 +20,7 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import io.seata.spring.annotation.GlobalTransactional;
 import lombok.AllArgsConstructor;
 import org.springblade.core.secure.utils.AuthUtil;
 import org.springblade.core.tool.api.R;
@@ -34,6 +35,7 @@ import org.springblade.los.basic.vessels.service.IBVesselsService;
 import org.springblade.los.basic.vessels.vo.BVesselsVO;
 import org.springblade.system.feign.ISysClient;
 import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
 
 import java.util.ArrayList;
 import java.util.Date;
@@ -89,6 +91,8 @@ public class BVesselsServiceImpl extends ServiceImpl<VesselsMapper, BVessels> im
 	}
 
 	@Override
+	@Transactional(rollbackFor = Exception.class)
+	@GlobalTransactional(rollbackFor = Exception.class, timeoutMills = 12000000)
 	public R<List<BVessels>> importBVessels(List<BVesselsExcel> excelList) {
 		List<BVessels> bVesselsList = new ArrayList<>();
 		for (BVesselsExcel item : excelList) {

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

@@ -54,4 +54,6 @@ public interface BillsMapper extends BaseMapper<Bills> {
 	List<Map<String, Object>> decisionAnalysisByCGS();
 
 	List<Map<String, Object>> decisionAnalysisByYWY();
+
+	FinAccBillsVO listByAccBillId(@Param("acc") ListAccBillVO finAccBills);
 }

+ 183 - 19
blade-service/blade-los/src/main/java/org/springblade/los/business/sea/mapper/BillsMapper.xml

@@ -312,9 +312,14 @@
         IF
         ( sum( fee.applied_amount ), sum( fee.applied_amount ), 0.00 ) AS appliedAmount,
         IF
+        ( sum( fee.applied_amount_stl ), sum( fee.applied_amount_stl ), 0.00 ) AS appliedAmountStl,
+        IF
         ( sum( fee.reconciliation_amount ), sum( fee.reconciliation_amount ), 0.00 ) AS reconciliationAmount,
         IF
         ( sum( fee.applied_invoice_amount ), sum( fee.applied_invoice_amount ), 0.00 ) AS appliedInvoiceAmount,
+        IF
+        ( sum( fee.applied_invoice_amount_stl ), sum( fee.applied_invoice_amount_stl ), 0.00 ) AS
+        appliedInvoiceAmountStl,
         fee.is_signfor as isSignfor,
         fee.signfor_id as signforId,
         fee.signfor_name as signforName,
@@ -342,7 +347,7 @@
         <if test='acc.type != null and acc.type != "" and acc.type == "4"'>
             and fee.amount > fee.uninvoiced_amount + fee.applied_invoice_amount
         </if>
-         <if test='acc.type != null and acc.type != "" and acc.type == "5"'>
+        <if test='acc.type != null and acc.type != "" and acc.type == "5"'>
             and fee.voucher_status = '0'
         </if>
         <if test="acc.dc != null and acc.dc != ''">
@@ -480,28 +485,187 @@
         </if>
     </select>
     <select id="decisionAnalysisByCGS" resultType="java.util.Map">
-        SELECT
-            c.cn_name as cname,
-            IF((select sum(b.quantity_v20+b.quantity_v40+b.quantity_v45+b.quantity_v48+b.quantity_v40hc) from los_sea_bills b  where c.id = b.src_id and b.is_deleted = '0' and b.tenant_id = '409341' and m_paymode = 'PP' and src_type = 'OWN' GROUP BY b.src_id),(select sum(b.quantity_v20+b.quantity_v40+b.quantity_v45+b.quantity_v48+b.quantity_v40hc) from los_sea_bills b  where c.id = b.src_id and b.is_deleted = '0' and b.tenant_id = '409341' and m_paymode = 'PP' and src_type = 'OWN' GROUP BY b.src_id),0.00) as totalP,
-            IF((select sum(b.quantity_v20+b.quantity_v40+b.quantity_v45+b.quantity_v48+b.quantity_v40hc) from los_sea_bills b  where c.id = b.src_id and b.is_deleted = '0' and b.tenant_id = '409341' and m_paymode = 'CC' and src_type = 'OWN' GROUP BY b.src_id),(select sum(b.quantity_v20+b.quantity_v40+b.quantity_v45+b.quantity_v48+b.quantity_v40hc) from los_sea_bills b  where c.id = b.src_id and b.is_deleted = '0' and b.tenant_id = '409341' and m_paymode = 'CC' and src_type = 'OWN' GROUP BY b.src_id),0.00) as totalC,
-            IF((select sum(b.quantity_v20+b.quantity_v40+b.quantity_v45+b.quantity_v48+b.quantity_v40hc) from los_sea_bills b  where c.id = b.src_id and b.is_deleted = '0' and b.tenant_id = '409341' and src_type = 'OWN' GROUP BY b.src_id),(select sum(b.quantity_v20+b.quantity_v40+b.quantity_v45+b.quantity_v48+b.quantity_v40hc) from los_sea_bills b  where c.id = b.src_id and b.is_deleted = '0' and b.tenant_id = '409341' and src_type = 'OWN' GROUP BY b.src_id),0.00) as total
-        FROM
-            los_b_corps c
-        WHERE
-            c.is_deleted = 0
-          and FIND_IN_SET('1712286570540703745',c.corp_type)
+        SELECT c.cn_name                     as cname,
+               IF((select sum(b.quantity_v20 + b.quantity_v40 + b.quantity_v45 + b.quantity_v48 + b.quantity_v40hc)
+                   from los_sea_bills b
+                   where c.id = b.src_id
+                     and b.is_deleted = '0'
+                     and b.tenant_id = '409341'
+                     and m_paymode = 'PP'
+                     and src_type = 'OWN'
+                   GROUP BY b.src_id),
+                  (select sum(b.quantity_v20 + b.quantity_v40 + b.quantity_v45 + b.quantity_v48 + b.quantity_v40hc)
+                   from los_sea_bills b
+                   where c.id = b.src_id
+                     and b.is_deleted = '0'
+                     and b.tenant_id = '409341'
+                     and m_paymode = 'PP'
+                     and src_type = 'OWN'
+                   GROUP BY b.src_id), 0.00) as totalP,
+               IF((select sum(b.quantity_v20 + b.quantity_v40 + b.quantity_v45 + b.quantity_v48 + b.quantity_v40hc)
+                   from los_sea_bills b
+                   where c.id = b.src_id
+                     and b.is_deleted = '0'
+                     and b.tenant_id = '409341'
+                     and m_paymode = 'CC'
+                     and src_type = 'OWN'
+                   GROUP BY b.src_id),
+                  (select sum(b.quantity_v20 + b.quantity_v40 + b.quantity_v45 + b.quantity_v48 + b.quantity_v40hc)
+                   from los_sea_bills b
+                   where c.id = b.src_id
+                     and b.is_deleted = '0'
+                     and b.tenant_id = '409341'
+                     and m_paymode = 'CC'
+                     and src_type = 'OWN'
+                   GROUP BY b.src_id), 0.00) as totalC,
+               IF((select sum(b.quantity_v20 + b.quantity_v40 + b.quantity_v45 + b.quantity_v48 + b.quantity_v40hc)
+                   from los_sea_bills b
+                   where c.id = b.src_id
+                     and b.is_deleted = '0'
+                     and b.tenant_id = '409341'
+                     and src_type = 'OWN'
+                   GROUP BY b.src_id),
+                  (select sum(b.quantity_v20 + b.quantity_v40 + b.quantity_v45 + b.quantity_v48 + b.quantity_v40hc)
+                   from los_sea_bills b
+                   where c.id = b.src_id
+                     and b.is_deleted = '0'
+                     and b.tenant_id = '409341'
+                     and src_type = 'OWN'
+                   GROUP BY b.src_id), 0.00) as total
+        FROM los_b_corps c
+        WHERE c.is_deleted = 0
+          and FIND_IN_SET('1712286570540703745', c.corp_type)
     </select>
     <select id="decisionAnalysisByYWY" resultType="java.util.Map">
-        SELECT
-            c.real_name as cname,
-            IF((select sum(b.quantity_v20+b.quantity_v40+b.quantity_v45+b.quantity_v48+b.quantity_v40hc) from los_sea_bills b  where c.id = b.src_id and b.is_deleted = '0' and b.tenant_id = '409341' and m_paymode = 'PP' and src_type = 'SALES' GROUP BY b.src_id),(select sum(b.quantity_v20+b.quantity_v40+b.quantity_v45+b.quantity_v48+b.quantity_v40hc) from los_sea_bills b  where c.id = b.src_id and b.is_deleted = '0' and b.tenant_id = '409341' and m_paymode = 'PP' and src_type = 'SALES' GROUP BY b.src_id),0.00) as totalP,
-            IF((select sum(b.quantity_v20+b.quantity_v40+b.quantity_v45+b.quantity_v48+b.quantity_v40hc) from los_sea_bills b  where c.id = b.src_id and b.is_deleted = '0' and b.tenant_id = '409341' and m_paymode = 'CC' and src_type = 'SALES' GROUP BY b.src_id),(select sum(b.quantity_v20+b.quantity_v40+b.quantity_v45+b.quantity_v48+b.quantity_v40hc) from los_sea_bills b  where c.id = b.src_id and b.is_deleted = '0' and b.tenant_id = '409341' and m_paymode = 'CC' and src_type = 'SALES' GROUP BY b.src_id),0.00) as totalC,
-            IF((select sum(b.quantity_v20+b.quantity_v40+b.quantity_v45+b.quantity_v48+b.quantity_v40hc) from los_sea_bills b  where c.id = b.src_id and b.is_deleted = '0' and b.tenant_id = '409341' and src_type = 'SALES' GROUP BY b.src_id),(select sum(b.quantity_v20+b.quantity_v40+b.quantity_v45+b.quantity_v48+b.quantity_v40hc) from los_sea_bills b  where c.id = b.src_id and b.is_deleted = '0' and b.tenant_id = '409341' and src_type = 'SALES' GROUP BY b.src_id),0.00) as total
+        SELECT c.real_name                   as cname,
+               IF((select sum(b.quantity_v20 + b.quantity_v40 + b.quantity_v45 + b.quantity_v48 + b.quantity_v40hc)
+                   from los_sea_bills b
+                   where c.id = b.src_id
+                     and b.is_deleted = '0'
+                     and b.tenant_id = '409341'
+                     and m_paymode = 'PP'
+                     and src_type = 'SALES'
+                   GROUP BY b.src_id),
+                  (select sum(b.quantity_v20 + b.quantity_v40 + b.quantity_v45 + b.quantity_v48 + b.quantity_v40hc)
+                   from los_sea_bills b
+                   where c.id = b.src_id
+                     and b.is_deleted = '0'
+                     and b.tenant_id = '409341'
+                     and m_paymode = 'PP'
+                     and src_type = 'SALES'
+                   GROUP BY b.src_id), 0.00) as totalP,
+               IF((select sum(b.quantity_v20 + b.quantity_v40 + b.quantity_v45 + b.quantity_v48 + b.quantity_v40hc)
+                   from los_sea_bills b
+                   where c.id = b.src_id
+                     and b.is_deleted = '0'
+                     and b.tenant_id = '409341'
+                     and m_paymode = 'CC'
+                     and src_type = 'SALES'
+                   GROUP BY b.src_id),
+                  (select sum(b.quantity_v20 + b.quantity_v40 + b.quantity_v45 + b.quantity_v48 + b.quantity_v40hc)
+                   from los_sea_bills b
+                   where c.id = b.src_id
+                     and b.is_deleted = '0'
+                     and b.tenant_id = '409341'
+                     and m_paymode = 'CC'
+                     and src_type = 'SALES'
+                   GROUP BY b.src_id), 0.00) as totalC,
+               IF((select sum(b.quantity_v20 + b.quantity_v40 + b.quantity_v45 + b.quantity_v48 + b.quantity_v40hc)
+                   from los_sea_bills b
+                   where c.id = b.src_id
+                     and b.is_deleted = '0'
+                     and b.tenant_id = '409341'
+                     and src_type = 'SALES'
+                   GROUP BY b.src_id),
+                  (select sum(b.quantity_v20 + b.quantity_v40 + b.quantity_v45 + b.quantity_v48 + b.quantity_v40hc)
+                   from los_sea_bills b
+                   where c.id = b.src_id
+                     and b.is_deleted = '0'
+                     and b.tenant_id = '409341'
+                     and src_type = 'SALES'
+                   GROUP BY b.src_id), 0.00) as total
+        FROM blade_user c
+        WHERE c.is_deleted = 0
+          and FIND_IN_SET('1727585951967916033', c.role_id)
+    </select>
+    <select id="listByAccBillId" resultType="org.springblade.los.finance.fee.vo.FinAccBillsVO">
+        SELECT DISTINCT
+        acc.*,
+        fee.business_type as businessType,
+        fee.bill_type as billType,
+        fee.id as sourceId,
+        fee.cur_code as curCode,
+        fee.account_year as accountYear,
+        fee.account_month as accountMonth,
+        fee.account_day as accountDay,
+        fee.src_type as srcType,
+        fee.src_id as srcId,
+        fee.src_cn_name as srcCnName,
+        fee.src_en_name as srcEnName,
+        fee.line_id as lineId,
+        fee.line_cn_name as lineCnName,
+        fee.line_en_name as lineEnName,
+        fee.cntr_no as cntrNo,
+        SUM(fee.quantity) as quantity,
+        fee.unit_no as unitNo,
+        SUM(fee.price) as price,
+        fee.fee_id as feeId,
+        fee.fee_code as feeCode,
+        fee.fee_cn_name as feeCnName,
+        fee.fee_en_name as feeEnName,
+        fee.exrate as exrate,
+        fee.is_tax as isTax,
+        fee.tax_type as taxType,
+        fee.tax_rate as taxRate,
+        fee.surcharge_rate as surchargeRate,
+        SUM(fee.amount_discount) as amountDiscount,
+        SUM(fee.amount_net) as amountNet,
+        SUM(fee.amount_tax) as amountTax,
+        SUM(fee.amount) as amount,
+        SUM(fee.amount_tax_loc) as amountTaxLoc,
+        SUM(fee.amount_net_loc) as amountNetLoc,
+        SUM(fee.amount_discount_loc) as amountDiscountLoc,
+        SUM(fee.amount_loc) as amountLoc,
+        SUM(fee.stl_ttl_amount) as stlTtlAmount,
+        SUM(fee.invoice_amount_loc) as invoiceAmountLoc,
+        IF
+        ( sum( fee.uninvoiced_amount ), sum( fee.uninvoiced_amount ), 0.00 ) AS uninvoicedAmount,
+        IF
+        ( sum( fee.unsettled_amount ), sum( fee.unsettled_amount ), 0.00 ) AS unsettledAmount,
+        IF
+        ( sum( fee.applied_amount ), sum( fee.applied_amount ), 0.00 ) AS appliedAmount,
+        IF
+        ( sum( fee.applied_amount_stl ), sum( fee.applied_amount_stl ), 0.00 ) AS appliedAmountStl,
+        IF
+        ( sum( fee.reconciliation_amount ), sum( fee.reconciliation_amount ), 0.00 ) AS reconciliationAmount,
+        IF
+        ( sum( fee.applied_invoice_amount ), sum( fee.applied_invoice_amount ), 0.00 ) AS appliedInvoiceAmount,
+        IF
+        ( sum( fee.applied_invoice_amount_stl ), sum( fee.applied_invoice_amount_stl ), 0.00 ) AS
+        appliedInvoiceAmountStl,
+        fee.is_signfor as isSignfor,
+        fee.signfor_id as signforId,
+        fee.signfor_name as signforName,
+        fee.signfor_date as signforDate,
+        bill.operator_id as operatorId,
+        bill.operator_name as operatorName,
+        bill.quantity_packing_descr as quantityPackingDescr,
+        bill.quantity_cntr_types_descr as quantityCntrTypesDescr,
+        corp.account_period_type as accountPeriodType
         FROM
-            blade_user c
+        los_fee_center fee
+        JOIN los_sea_bills bill ON bill.id = fee.pid
+        LEFT JOIN los_b_corps corp ON corp.id = fee.corp_id
+        LEFT JOIN los_fin_acc_bills acc ON acc.id = fee.acc_bill_id
         WHERE
-            c.is_deleted = 0
-          and FIND_IN_SET('1727585951967916033',c.role_id)
+        acc.is_deleted = '0'
+        AND fee.is_deleted = '0'
+        and bill.is_deleted = '0'
+        <if test='acc.accId != null'>
+            and acc.id = #{acc.accId}
+        </if>
+        GROUP BY acc.bill_no
+        ORDER BY acc.create_time
     </select>
 
 </mapper>

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

@@ -437,7 +437,7 @@ public class BillsServiceImpl extends ServiceImpl<BillsMapper, Bills> implements
 				} else if ("CNY".equals(item.getCurCode())) {
 					amountCr = amountCr.add(item.getAmount());
 				} else {
-					BigDecimal usd = bCurrencyService.converter(item.getCurCode(), item.getAmount(),item.getDc());
+					BigDecimal usd = bCurrencyService.converter(item.getCurCode(), item.getAmount(), item.getDc());
 					amountCrUsd = amountCrUsd.add(usd);
 				}
 			}
@@ -487,7 +487,7 @@ public class BillsServiceImpl extends ServiceImpl<BillsMapper, Bills> implements
 				} else if ("CNY".equals(item.getCurCode())) {
 					amountDr = amountDr.add(item.getAmount());
 				} else {
-					BigDecimal usd = bCurrencyService.converter(item.getCurCode(), item.getAmount(),item.getDc());
+					BigDecimal usd = bCurrencyService.converter(item.getCurCode(), item.getAmount(), item.getDc());
 					amountDrUsd = amountDrUsd.add(usd);
 				}
 			}
@@ -541,7 +541,7 @@ public class BillsServiceImpl extends ServiceImpl<BillsMapper, Bills> implements
 						} else if ("CNY".equals(item.getCurCode())) {
 							amountCrM = amountCrM.add(item.getAmount());
 						} else {
-							BigDecimal usd = bCurrencyService.converter(item.getCurCode(), item.getAmount(),item.getDc());
+							BigDecimal usd = bCurrencyService.converter(item.getCurCode(), item.getAmount(), item.getDc());
 							amountCrUsdM = amountCrUsdM.add(usd);
 						}
 					} else {
@@ -550,7 +550,7 @@ public class BillsServiceImpl extends ServiceImpl<BillsMapper, Bills> implements
 						} else if ("CNY".equals(item.getCurCode())) {
 							amountDrM = amountDrM.add(item.getAmount());
 						} else {
-							BigDecimal usd = bCurrencyService.converter(item.getCurCode(), item.getAmount(),item.getDc());
+							BigDecimal usd = bCurrencyService.converter(item.getCurCode(), item.getAmount(), item.getDc());
 							amountDrUsdM = amountDrUsdM.add(usd);
 						}
 					}
@@ -580,8 +580,8 @@ public class BillsServiceImpl extends ServiceImpl<BillsMapper, Bills> implements
 				//利润 = 收 - 付
 				amountProfitM = amountDrM.subtract(amountCrM);
 				amountProfitUsdM = amountDrUsdM.subtract(amountCrUsdM);
-				amountDrLocM = amountDrLocM.add(bCurrencyService.converterCny("USD", amountDrUsdM,"D")).add(amountDrM);
-				amountCrLocM = amountCrLocM.add(bCurrencyService.converterCny("USD", amountCrUsdM,"C")).add(amountCrM);
+				amountDrLocM = amountDrLocM.add(bCurrencyService.converterCny("USD", amountDrUsdM, "D")).add(amountDrM);
+				amountCrLocM = amountCrLocM.add(bCurrencyService.converterCny("USD", amountCrUsdM, "C")).add(amountCrM);
 				amountProfitLocM = amountDrLocM.subtract(amountCrLocM);
 				details.setAmountDr(amountDrM);
 				details.setAmountCr(amountCrM);
@@ -601,8 +601,8 @@ public class BillsServiceImpl extends ServiceImpl<BillsMapper, Bills> implements
 		//利润 = 收 - 付
 		amountProfit = amountDr.subtract(amountCr);
 		amountProfitUsd = amountDrUsd.subtract(amountCrUsd);
-		amountDrLoc = amountDrLoc.add(bCurrencyService.converterCny("USD", amountDrUsd,"D")).add(amountDr);
-		amountCrLoc = amountCrLoc.add(bCurrencyService.converterCny("USD", amountCrUsd,"C")).add(amountCr);
+		amountDrLoc = amountDrLoc.add(bCurrencyService.converterCny("USD", amountDrUsd, "D")).add(amountDr);
+		amountCrLoc = amountCrLoc.add(bCurrencyService.converterCny("USD", amountCrUsd, "C")).add(amountCr);
 		amountProfitLoc = amountDrLoc.subtract(amountCrLoc);
 		bills.setAmountDr(amountDr);
 		bills.setAmountCr(amountCr);
@@ -1060,6 +1060,9 @@ public class BillsServiceImpl extends ServiceImpl<BillsMapper, Bills> implements
 	@GlobalTransactional(rollbackFor = Exception.class, timeoutMills = 12000000)
 	public Bills revokeCheckOrder(Bills bills) {
 		Bills declare = baseMapper.selectById(bills.getId());
+		if (3 == declare.getStatus()) {
+			throw new SecurityException("审核已通过,撤销失败");
+		}
 		R financeProcess = auditProecessService.deteleByBillId(bills.getId());
 		if (!financeProcess.isSuccess()) {
 			throw new SecurityException("操作失败,请联系管理员");

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

@@ -107,10 +107,10 @@ public class ContainersServiceImpl extends ServiceImpl<ContainersMapper, Contain
 			.eq(Containers::getPid, containers.getPid())
 			.eq(Containers::getCntrNo, containers.getCntrNo()));
 		if (containers.getId() == null) {
-			if (cntrNoCount > 0) {
+			if (ObjectUtils.isNotNull(containers.getCntrNo()) && cntrNoCount > 0) {
 				throw new RuntimeException("箱号不允许重复");
 			}
-			if (sealNoCount > 0) {
+			if (ObjectUtils.isNotNull(containers.getSealNo()) && sealNoCount > 0) {
 				throw new RuntimeException("铅封号不允许重复");
 			}
 			containers.setCreateTime(new Date());
@@ -122,10 +122,10 @@ public class ContainersServiceImpl extends ServiceImpl<ContainersMapper, Contain
 				containers.setCreateDeptName(deptName);
 			}
 		} else {
-			if (cntrNoCount > 1) {
+			if (ObjectUtils.isNotNull(containers.getCntrNo()) && cntrNoCount > 1) {
 				throw new RuntimeException("箱号不允许重复");
 			}
-			if (sealNoCount > 1) {
+			if (ObjectUtils.isNotNull(containers.getSealNo()) && sealNoCount > 1) {
 				throw new RuntimeException("铅封号不允许重复");
 			}
 			containers.setUpdateUser(AuthUtil.getUserId());
@@ -368,11 +368,11 @@ public class ContainersServiceImpl extends ServiceImpl<ContainersMapper, Contain
 
 	@Override
 	public R<List<Containers>> importBoxNo(List<BoxAndLeadSealNoExcel> excelList) {
-		List<String> cntrNo = excelList.stream().map(BoxAndLeadSealNoExcel::getCntrNo).distinct().collect(Collectors.toList());
+		List<String> cntrNo = excelList.stream().map(BoxAndLeadSealNoExcel::getCntrNo).filter(Objects::nonNull).distinct().collect(Collectors.toList());
 		if (cntrNo.size() != excelList.size()) {
 			throw new RuntimeException("箱号不允许重复");
 		}
-		List<String> sealNo = excelList.stream().map(BoxAndLeadSealNoExcel::getSealNo).distinct().collect(Collectors.toList());
+		List<String> sealNo = excelList.stream().map(BoxAndLeadSealNoExcel::getSealNo).filter(Objects::nonNull).distinct().collect(Collectors.toList());
 		if (cntrNo.size() != excelList.size()) {
 			throw new RuntimeException("铅封号不允许重复");
 		}
@@ -440,10 +440,10 @@ public class ContainersServiceImpl extends ServiceImpl<ContainersMapper, Contain
 				.eq(Containers::getPid, containers.getPid())
 				.eq(Containers::getCntrNo, containers.getCntrNo()));
 			if (containers.getId() == null) {
-				if (cntrNoCount > 0) {
+				if (ObjectUtils.isNotNull(containers.getCntrNo()) && cntrNoCount > 0) {
 					throw new RuntimeException("箱号不允许重复");
 				}
-				if (sealNoCount > 0) {
+				if (ObjectUtils.isNotNull(containers.getSealNo()) && sealNoCount > 0) {
 					throw new RuntimeException("铅封号不允许重复");
 				}
 				containers.setCreateTime(new Date());
@@ -455,10 +455,10 @@ public class ContainersServiceImpl extends ServiceImpl<ContainersMapper, Contain
 					containers.setCreateDeptName(deptName);
 				}
 			} else {
-				if (cntrNoCount > 1) {
+				if (ObjectUtils.isNotNull(containers.getCntrNo()) && cntrNoCount > 1) {
 					throw new RuntimeException("箱号不允许重复");
 				}
-				if (sealNoCount > 1) {
+				if (ObjectUtils.isNotNull(containers.getSealNo()) && sealNoCount > 1) {
 					throw new RuntimeException("铅封号不允许重复");
 				}
 				containers.setUpdateUser(AuthUtil.getUserId());

+ 0 - 6
blade-service/blade-los/src/main/java/org/springblade/los/check/service/impl/AuditProecessServiceImpl.java

@@ -136,12 +136,6 @@ public class AuditProecessServiceImpl extends ServiceImpl<AuditProecessMapper, L
 			auditProecess.setBatchNo(finalCurrent);
 			auditProecess.setCheckType(auditProecessDTO.getCheckType());
 			auditProecess.setOrderRemark(auditProecessDTO.getOrderRemark());
-			auditProecess.setGrossProfit(auditProecessDTO.getGrossProfit());
-			auditProecess.setGrossProfitRate(auditProecessDTO.getGrossProfitRate());
-			auditProecess.setOrderQuantity(auditProecessDTO.getOrderQuantity());
-			auditProecess.setAmount(auditProecessDTO.getAmount());
-			auditProecess.setReceivableAmount(auditProecessDTO.getReceivableAmount());
-			auditProecess.setPayAmount(auditProecessDTO.getPayAmount());
 			auditProecess.setTimes(auditProecessDTO.getTimes());
 			auditProecess.setReferenceNo(auditProecessDTO.getReferenceNo());
 			auditProecess.setStorage(auditProecessDTO.getStorage());

+ 2 - 11
blade-service/blade-los/src/main/java/org/springblade/los/edi/service/impl/EDISenderServiceImpl.java

@@ -10,7 +10,6 @@ import org.springblade.los.edi.service.IEDISenderService;
 import org.springframework.stereotype.Service;
 import org.springframework.validation.annotation.Validated;
 
-import javax.validation.Valid;
 import java.io.BufferedWriter;
 import java.io.File;
 import java.io.FileWriter;
@@ -29,10 +28,8 @@ public class EDISenderServiceImpl implements IEDISenderService {
 	@Override
 	public FilesCenter sendingInttraSo(@Validated InttraSoDto inttraSoDto) {
 		try {
-			SimpleDateFormat sdf1 = new SimpleDateFormat("yyMMddhhmmss");
-			Date date = new Date();
 			//生成edi文件
-			File file = new File("/home/minio/file/" + AuthUtil.getTenantId() + "-bladex/upload", inttraSoDto.getEdiTypes().getCode()+ ".txt");
+			File file = new File("/home/minio/file/" + AuthUtil.getTenantId() + "-bladex/upload", inttraSoDto.getEdiTypes().getCode() + ".txt");
 //			File file = new File("D:/home/minio/file/" + AuthUtil.getTenantId() + "-bladex/upload", sdf1.format(date) + "-edi.text");
 			file.createNewFile();
 			// 打开文件输出流进行写入操作
@@ -690,8 +687,6 @@ public class EDISenderServiceImpl implements IEDISenderService {
 	@Override
 	public FilesCenter sendingInttraSI(@Validated InttraSiDto inttraSiDto) {
 		try {
-			SimpleDateFormat sdf1 = new SimpleDateFormat("yyMMddhhmmss");
-			Date date = new Date();
 			//生成edi文件
 			File file = new File("/home/minio/file/" + AuthUtil.getTenantId() + "-bladex/upload", inttraSiDto.getEdiTypes().getCode() + ".txt");
 //			File file = new File("D:/home/minio/file/" + AuthUtil.getTenantId() + "-bladex/upload", sdf1.format(date) + "-edi.text");
@@ -1228,8 +1223,6 @@ public class EDISenderServiceImpl implements IEDISenderService {
 	@Override
 	public FilesCenter sendingInttraSiBill(@Validated InttraSiBillDto inttraSiBillDto) {
 		try {
-			SimpleDateFormat sdf1 = new SimpleDateFormat("yyMMddhhmmss");
-			Date date = new Date();
 			//生成edi文件
 			File file = new File("/home/minio/file/" + AuthUtil.getTenantId() + "-bladex/upload", inttraSiBillDto.getEdiTypes().getCode() + ".txt");
 			file.createNewFile();
@@ -2621,10 +2614,8 @@ public class EDISenderServiceImpl implements IEDISenderService {
 	}
 
 	@Override
-	public FilesCenter sendingAplSo(@Validated APLSoDto aplSoDto)  {
+	public FilesCenter sendingAplSo(@Validated APLSoDto aplSoDto) {
 		try {
-			SimpleDateFormat sdf1 = new SimpleDateFormat("yyMMddhhmmss");
-			Date date = new Date();
 			//生成edi文件
 			File file = new File("/home/minio/file/" + AuthUtil.getTenantId() + "-bladex/upload", aplSoDto.getEdiTypes().getCode() + ".txt");
 			file.createNewFile();

+ 146 - 144
blade-service/blade-los/src/main/java/org/springblade/los/edi/service/impl/EdiTypesServiceImpl.java

@@ -249,7 +249,9 @@ public class EdiTypesServiceImpl extends ServiceImpl<EdiTypesMapper, EdiTypes> i
 				inttraSoDto.setPolName(details.getPolCnName());
 
 				SimpleDateFormat sdf3 = new SimpleDateFormat("yyyymmdd");
-				inttraSoDto.setEtd(sdf3.format(details.getEtd()));
+				if (ObjectUtils.isNotNull(details.getEtd())){
+					inttraSoDto.setEtd(sdf3.format(details.getEtd()));
+				}
 
 				details.setPlaceReceiptCode(RegularUtils.regularEn(details.getPlaceReceiptCode()));
 				inttraSoDto.setPlaceReceiptCode(details.getPlaceReceiptCode());
@@ -408,7 +410,7 @@ public class EdiTypesServiceImpl extends ServiceImpl<EdiTypesMapper, EdiTypes> i
 				filesCenter.setItemId(ediLog.getId());
 				filesCenter.setBusinessType(details.getBusinessType());
 				filesCenter.setClassifyCode("edi");
-				filesCenter.setGroupCode("SO");
+				filesCenter.setGroupCode("INTTRA-SO");
 				filesCenter.setSerialNo(1);
 				filesCenter.setSort(1);
 				filesCenter.setReceivedData(new Date());
@@ -664,7 +666,7 @@ public class EdiTypesServiceImpl extends ServiceImpl<EdiTypesMapper, EdiTypes> i
 				filesCenter.setItemId(ediLog.getId());
 				filesCenter.setBusinessType(details.getBusinessType());
 				filesCenter.setClassifyCode("edi");
-				filesCenter.setGroupCode("SI");
+				filesCenter.setGroupCode("INTTRA-SI");
 				filesCenter.setSerialNo(1);
 				filesCenter.setSort(1);
 				filesCenter.setReceivedData(new Date());
@@ -809,7 +811,7 @@ public class EdiTypesServiceImpl extends ServiceImpl<EdiTypesMapper, EdiTypes> i
 				filesCenter.setItemId(ediLog.getId());
 				filesCenter.setBusinessType(details.getBusinessType());
 				filesCenter.setClassifyCode("edi");
-				filesCenter.setGroupCode("SI");
+				filesCenter.setGroupCode("INTTRA-SI-bill");
 				filesCenter.setSerialNo(1);
 				filesCenter.setSort(1);
 				filesCenter.setReceivedData(new Date());
@@ -823,7 +825,145 @@ public class EdiTypesServiceImpl extends ServiceImpl<EdiTypesMapper, EdiTypes> i
 			Date date = new Date();
 			for (Bills details : billsList) {
 				APLSoDto aplSoDto = new APLSoDto();
+				aplSoDto.setMessageType("IFTMBF");
+				aplSoDto.setFileDescription("BOOKING");
+				aplSoDto.setFileFunction("9");
 				aplSoDto.setEdiTypes(ediTypes);
+				aplSoDto.setSenderCode("发送方代码");
+				aplSoDto.setReceiverCode("接收方代码");
+				SimpleDateFormat sdf = new SimpleDateFormat("yyMMdd:hhmm");
+				aplSoDto.setFilesEstablishTime(sdf.format(date));
+				aplSoDto.setOperationNumber(details.getBillNo());
+				aplSoDto.setBillNo(details.getMblno());
+				aplSoDto.setDeliveryTerms("交货条款");
+				aplSoDto.setBookerExplain("订舱人说明");
+				aplSoDto.setSignerCode("签单人代码");
+				aplSoDto.setSignerExplain("签单人说明");
+				aplSoDto.setInquiryParty("询价单位");
+				aplSoDto.setAbroadBookingParty("国外订舱单位");
+				aplSoDto.setTransshipmentIdentification("转船标识");
+				aplSoDto.setInBatches("分批");
+				aplSoDto.setInstallationPeriod(null);
+				aplSoDto.setValidityPeriod(null);
+				aplSoDto.setFreightAgreementNumber("运费协议号");
+				aplSoDto.setRateBookCode("费率本代码");
+				aplSoDto.setServiceContractNumber("服务合同号");
+				aplSoDto.setBondNo("bondNo");
+				aplSoDto.setCabinInteroperabilityIdentification("舱位互用标识");
+				aplSoDto.setBillOfLadingType(details.getBillType());
+				aplSoDto.setBillOfLadingIssuingPlaceCode("提单签发地代码");
+				aplSoDto.setBillOfLadingIssuingPlace("提单签发地");
+				SimpleDateFormat sdf1 = new SimpleDateFormat("CCyyMMdd");
+				aplSoDto.setIssuanceDate(Integer.parseInt(sdf1.format(details.getIssueDate())));
+				aplSoDto.setNumberOfOriginalBillsOfLading(details.getNumberOfOblDigit());
+				aplSoDto.setPrepaidAt(details.getHpayplace());
+				aplSoDto.setPayableAt(details.getMpayplace());
+				aplSoDto.setVesselCallSign("船舶呼号");
+				aplSoDto.setVesselName(details.getVesselCnName());
+				aplSoDto.setVoyage(details.getVoyageNo());
+				aplSoDto.setVesselOperatorCode("船舶经营人代码");
+				aplSoDto.setVesselOperator("船舶经营人");
+				aplSoDto.setBillCarryCode("提单承运人代码");
+				aplSoDto.setBillCarry("提单承运人");
+				aplSoDto.setIssuanceDate(Integer.parseInt(sdf1.format(details.getEtd())));
+				aplSoDto.setTradeCode("航线代码");
+				aplSoDto.setTrade("航线");
+				aplSoDto.setPreVesselCode("前程运输船名代码");
+				aplSoDto.setPreVessel("前程运输船名");
+				aplSoDto.setPreVoyage("前程运输航次");
+				aplSoDto.setPlaceCodeOfReceipt(details.getPlaceReceiptCode());
+				aplSoDto.setPlaceOfReceipt(details.getPlaceReceiptName());
+				aplSoDto.setLoadPortCode(details.getPolCode());
+				aplSoDto.setLoadPort(details.getPolCnName());
+				aplSoDto.setDischargePortCode(details.getPodCode());
+				aplSoDto.setDischargePort(details.getPodCnName());
+				aplSoDto.setTransFerportCode(details.getPotCode());
+				aplSoDto.setTransFerport(details.getPotCnName());
+				aplSoDto.setPlaceoFdeliveryCode(details.getPlaceDeliveryCode());
+				aplSoDto.setPlaceoFdelivery(details.getPlaceDeliveryName());
+				aplSoDto.setFinalDestinationCode(details.getDestinationCode());
+				aplSoDto.setFinalDestination(details.getDestinationName());
+				aplSoDto.setDepotCode("堆场代码");
+				aplSoDto.setOptDischPortCode("可选卸货港代码");
+				aplSoDto.setOptDischPort("可选卸货港");
+				aplSoDto.setOptPlaceOfDeliveryCode("CODE可选交货地代码");
+				aplSoDto.setOptPlaceOfDelivery("可选交货地");
+				aplSoDto.setFrClauseCode("运费条款代码");
+				aplSoDto.setFrEightClause("运费条款");
+				aplSoDto.setFrChCode("运费及费用代码");
+				aplSoDto.setFrChRemark("运费及费用说明");
+				aplSoDto.setPrepaidOrCollect(details.getMpaymode());
+				aplSoDto.setPayableAtE("第三地付款地点代码");
+				aplSoDto.setPayeeCode("收款人代码");
+				aplSoDto.setQuantity("数量");
+				aplSoDto.setCurrency("币种");
+				aplSoDto.setRateOfFrCh("费率");
+				aplSoDto.setUnitOfQuantity("数量单位");
+				aplSoDto.setAmount("金额");
+				aplSoDto.setRemarks(details.getBookingRemarks());
+				aplSoDto.setCargoAmount("货物金额");
+				aplSoDto.setModeOfStuffing("装箱方式");
+				aplSoDto.setShipperCode(details.getHshipperCode());
+				aplSoDto.setShipper(details.getHshipperCnName());
+				aplSoDto.setConsigneeCode(details.getHconsigneeCode());
+				aplSoDto.setConsignee(details.getHconsigneeCnName());
+				aplSoDto.setNotifyCode(details.getHnotifyCode());
+				aplSoDto.setNotify(details.getHnotifyCnName());
+				aplSoDto.setAlsoNotifyCode(details.getHnotify2Code());
+				aplSoDto.setAlsoNotify(details.getHnotify2CnName());
+				aplSoDto.setCargoSequenceNo(1);//货物序号
+				aplSoDto.setCargoCode("货类代码");
+				aplSoDto.setCargoId("货物标识");
+				aplSoDto.setNumbersOfPkgs(1);//第一层包装件数
+				aplSoDto.setCodeOfPkgs("第一层包装类型");
+				aplSoDto.setPackagesDes("第一层包装说明");
+				aplSoDto.setCargoGrossWt(new BigDecimal("0.00"));//第一层包装皮重
+				aplSoDto.setCargoMeasurement(new BigDecimal("0.00"));//第一层包装尺码
+				aplSoDto.setNumbersOfPackages(new BigDecimal("0.00"));//第二层包装件数
+				aplSoDto.setCodeOfPkgs2("第二层包装类型");
+				aplSoDto.setPackagesDes2("第二层包装说明");
+				aplSoDto.setCargoGrossWt2(new BigDecimal("0.00"));//第二层包装皮重
+				aplSoDto.setCargoMeasurement2(new BigDecimal("0.00"));//第二层包装尺码
+				aplSoDto.setCargoGrossWeight(details.getGrossWeight());
+				aplSoDto.setCargoNetWeight(details.getNetWeight());
+				aplSoDto.setQuarantineCodingCode("检疫代码");
+				aplSoDto.setQuarantineCoding("检疫名称");
+				aplSoDto.setDgClass(details.getDgImdgCode());
+				aplSoDto.setPage("危险品页号");
+				aplSoDto.setUndgNo(1);
+				aplSoDto.setLabel("危险品标签");
+				aplSoDto.setFlashPoint(details.getDgFlashPointUnit());
+				aplSoDto.setEmsNo("船运危险品应急措施号");
+				aplSoDto.setMfagNo("医疗急救指南号");
+				aplSoDto.setMptMarinePollutant("海运污染");
+				aplSoDto.setEmergencyContact("应急联系");
+				aplSoDto.setReeferVentilationFlux("冷藏通风量");
+				aplSoDto.setTemperatureId("温度计量单位");
+				aplSoDto.setTemperatureSetting("设置温度");
+				aplSoDto.setMinTemperature("冷藏最低温度");
+				aplSoDto.setMaxTemperature("冷藏最高温度");
+				aplSoDto.setOverLengthFront(1);
+				aplSoDto.setOverLengthBack(1);
+				aplSoDto.setOverWidthLeft(1);
+				aplSoDto.setOverWidthRight(1);
+				aplSoDto.setOverHeight(1);
+				aplSoDto.setMarks(details.getMarks());
+				aplSoDto.setCargoDescription("货物描述");
+				aplSoDto.setCtnSizeType("集装箱尺寸类型");
+				aplSoDto.setCtnNumbers(1);
+				aplSoDto.setCtnStatus("集装箱状态");
+				aplSoDto.setMasterLclNo("主拼号");
+				aplSoDto.setCntModeOfStuffing("装箱方式");
+				aplSoDto.setVanningDepotCode("装箱地点代码");
+				aplSoDto.setVanningDepot("装箱地点说明");
+				aplSoDto.setContainerSoc("货主箱标志");
+				aplSoDto.setCtnNo("箱号");
+				aplSoDto.setCtnTypeSize("箱型尺寸");
+				aplSoDto.setSealNo("铅封号");
+				aplSoDto.setCtnNumbersOfPackages(details.getQuantity().intValue());
+				aplSoDto.setCtnCargoNetWeight(details.getGrossWeight());
+				aplSoDto.setCargoTareWeight(new BigDecimal("0.00"));
+				aplSoDto.setRecordTotalOfFile(1);
 				FilesCenter filesCenter = iediSenderService.sendingAplSo(aplSoDto);
 
 				//发送edi记录
@@ -858,7 +998,7 @@ public class EdiTypesServiceImpl extends ServiceImpl<EdiTypesMapper, EdiTypes> i
 				filesCenter.setItemId(ediLog.getId());
 				filesCenter.setBusinessType(details.getBusinessType());
 				filesCenter.setClassifyCode("edi");
-				filesCenter.setGroupCode("SI");
+				filesCenter.setGroupCode("APL-SO");
 				filesCenter.setSerialNo(1);
 				filesCenter.setSort(1);
 				filesCenter.setReceivedData(new Date());
@@ -871,145 +1011,7 @@ public class EdiTypesServiceImpl extends ServiceImpl<EdiTypesMapper, EdiTypes> i
 		else if ("HYCK".equals(ediTypes.getType()) && "APL-SI".equals(ediTypes.getCode())) {
 			Date date = new Date();
 			for (Bills details : billsList) {
-				InttraSiBillDto inttraSoDto = new InttraSiBillDto();
-				inttraSoDto.setIdentifying("发送方标识");
-				SimpleDateFormat sdf = new SimpleDateFormat("yyMMdd:hhmm");
-				inttraSoDto.setDate(sdf.format(date));
-				SimpleDateFormat sdf1 = new SimpleDateFormat("yyMMddhhmm");
-				String corpId = details.getCorpId().toString();
-				inttraSoDto.setFileExchangeNumber(sdf1.format(date) + corpId.substring(corpId.length() - 4));
-				inttraSoDto.setInformationNo(inttraSoDto.getFileExchangeNumber());
-
-				details.setMblno(RegularUtils.regularEn(details.getMblno()));
-				inttraSoDto.setIdentificationCode(details.getMblno());
-
-				if (ObjectUtils.isNotNull(details.getEdiStatus()) && Integer.parseInt(details.getEdiStatus()) > 0) {
-					inttraSoDto.setFilesFunction("5");
-					details.setEdiStatus(Integer.parseInt(details.getEdiStatus()) + 1 + "");
-				} else {
-					inttraSoDto.setFilesFunction("9");
-					details.setEdiStatus("1");
-				}
-				inttraSoDto.setFilesDate(sdf1.format(date));
-
-				details.setServiceTerms(RegularUtils.regularEn(details.getServiceTerms()));
-				inttraSoDto.setTransportTermCode(details.getServiceTerms());
-
-				inttraSoDto.setLclType("2");
-
-				details.setRemarks(RegularUtils.regularEn(details.getRemarks()));
-				inttraSoDto.setRemarks(details.getRemarks());
-
-				SimpleDateFormat sdf2 = new SimpleDateFormat("yyyymmdd");
-				if (ObjectUtils.isNotNull(details.getIssueDate())) {
-					inttraSoDto.setIssueDate(sdf2.format(details.getIssueDate()));
-				}
-
-				details.setRefno(RegularUtils.regularEn(details.getRefno()));
-				inttraSoDto.setBillNo(details.getRefno());
-
-				inttraSoDto.setPaymentType(details.getMpaymode());
-
-				details.setVoyageNo(RegularUtils.regularEn(details.getVoyageNo()));
-				inttraSoDto.setVoyageNo(details.getVoyageNo());
-				if (ObjectUtils.isNotNull(details.getVesselId())) {
-					BVessels bVessels = bVesselsService.getById(details.getVesselId());
-					if (bVessels != null) {
-						BCorps bCorps = bCorpsService.getById(bVessels.getCarrierId());
-						if (bCorps != null) {
-							bCorps.setCarrierCode(RegularUtils.regularEn(bCorps.getCarrierCode()));
-							inttraSoDto.setVesselCarrierCode(bCorps.getCarrierCode());
-						}
-					}
-				}
-
-				details.setVesselCnName(RegularUtils.regularEn(details.getVesselCnName()));
-				inttraSoDto.setVesselName(details.getVesselCnName());
-
-				inttraSoDto.setBillLadingType("提单类型");
-				if (details.getStlCrStatus() >= 3 || details.getStlDrStatus() >= 3) {
-					inttraSoDto.setPaymentStatus("已付款");
-				} else {
-					inttraSoDto.setPaymentStatus("未付款");
-				}
-				inttraSoDto.setBillLadingNumber(new BigDecimal("0"));
-				inttraSoDto.setPackagesNumbers(details.getQuantity());
-				inttraSoDto.setPackagesCode(details.getPackingUnit());
-				inttraSoDto.setPackagesDescribe("包装描述");
-				inttraSoDto.setHsCode(new BigDecimal("001"));
-
-				inttraSoDto.setMarks(details.getMarks());
-				BigDecimal boxGoodNumber = new BigDecimal("0.00");
-				if (containersList.size() > 0) {
-					inttraSoDto.setBoxGoodNumber(containersList.get(0).getQuantity());
-
-					String boxNumber = containersList.stream().map(Containers::getCntrNo).filter(Objects::nonNull).distinct().collect(Collectors.joining("/"));
-					inttraSoDto.setBoxNo(boxNumber);
-					inttraSoDto.setShipperBoxIdentification("货主箱标识");
-
-				} else {
-					inttraSoDto.setBoxGoodNumber(boxGoodNumber);
-				}
-				details.setDgImdgCode(RegularUtils.regularEn(details.getDgImdgCode()));
-				inttraSoDto.setDgImdgCode(details.getDgImdgCode());
-				inttraSoDto.setPageNumber(new BigDecimal("007"));
-				inttraSoDto.setDgUnCode(1);
-				inttraSoDto.setDgFlashPoint(new BigDecimal("1"));
-				inttraSoDto.setDgFlashPointUnit(details.getDgFlashPointUnit());
-				inttraSoDto.setPackingGroup("包装组别");
-				inttraSoDto.setEmergencyMeasureNo("应急措施号");
-				details.setDgRemarks(RegularUtils.regularEn(details.getDgRemarks()));
-				inttraSoDto.setDgRemarks(details.getDgRemarks());
-				inttraSoDto.setDgContacts(details.getDgContacts());
-				inttraSoDto.setDgTel(details.getDgTel());
-				inttraSoDto.setBoxCode(details.getQuantityCntrDescr());
-				inttraSoDto.setTemperature(1);
-				inttraSoDto.setTemperatureUnit("温度单位");
-				inttraSoDto.setRecordRows(new BigDecimal("10"));
-				inttraSoDto.setInformationNoEnd(inttraSoDto.getInformationNo());
-				inttraSoDto.setFileExchangeNumberEnd(inttraSoDto.getFileExchangeNumber());
-				inttraSoDto.setEdiTypes(ediTypes);
-				FilesCenter filesCenter = iediSenderService.sendingInttraSiBill(inttraSoDto);
-
-				//发送edi记录
-				EdiLog ediLog = new EdiLog();
-				ediLog.setBillId(details.getId());
-				ediLog.setBillNo(details.getBillNo());
-				ediLog.setMblno(details.getMblno());
-				ediLog.setHblno(details.getHblno());
-				ediLog.setPid(ediTypes.getId());
-				ediLog.setSenderDate(new Date());
-				ediLog.setBranchId(details.getBranchId());
-				ediLog.setCreateDept(details.getCreateDept());
-				ediLog.setCreateTime(details.getCreateTime());
-				ediLog.setCreateDeptName(details.getCreateDeptName());
-				ediLog.setCreateUser(details.getCreateUser());
-				ediLog.setCreateUserName(details.getCreateUserName());
-				ediLog.setRemarks("发送成功");
-				ediLog.setStatus(1);
-				ediLogService.save(ediLog);
-
-				//发送edi文件
-				filesCenter.setMblno(details.getMblno());
-				filesCenter.setHblno(details.getHblno());
-				filesCenter.setBillNo(details.getBillNo());
-				filesCenter.setBranchId(details.getBranchId());
-				filesCenter.setCreateDept(details.getCreateDept());
-				filesCenter.setCreateTime(details.getCreateTime());
-				filesCenter.setCreateDeptName(details.getCreateDeptName());
-				filesCenter.setCreateUser(details.getCreateUser());
-				filesCenter.setCreateUserName(details.getCreateUserName());
-				filesCenter.setPid(details.getId());
-				filesCenter.setItemId(ediLog.getId());
-				filesCenter.setBusinessType(details.getBusinessType());
-				filesCenter.setClassifyCode("edi");
-				filesCenter.setGroupCode("SI");
-				filesCenter.setSerialNo(1);
-				filesCenter.setSort(1);
-				filesCenter.setReceivedData(new Date());
-				filesCenter.setIsImage(0);
-				filesCenter.setTenantId(AuthUtil.getTenantId());
-				filesCenterList.add(filesCenter);
+				//数据处理
 			}
 			billsService.updateBatchById(billsList);
 		}

+ 5 - 0
blade-service/blade-los/src/main/java/org/springblade/los/finance/fee/controller/FinAccBillsController.java

@@ -363,6 +363,11 @@ public class FinAccBillsController extends BladeController {
 			listAccBillVO.setType("4");
 		}
 		List<FinAccBillsVO> list = finAccBillsService.listAccBill(listAccBillVO);
+		for (FinAccBillsVO item : list) {
+			item.setAppliedCurrentStlAmount(item.getAmount().subtract(item.getAppliedAmount().add(item.getAppliedAmountStl())).subtract(item.getStlTtlAmount()));
+			item.setAppliedInvoiceCurrentStlAmount(item.getAmount().subtract(item.getAppliedInvoiceAmount().add(item.getAppliedInvoiceAmountStl())).subtract(item.getUninvoicedAmount()));
+			item.setAppliedInvoiceCurrentStlAmount(item.getAmount().subtract(item.getStlTtlAmount()));
+		}
 		return R.data(list);
 	}
 

+ 7 - 0
blade-service/blade-los/src/main/java/org/springblade/los/finance/fee/service/IFinAccBillsService.java

@@ -69,4 +69,11 @@ public interface IFinAccBillsService extends IService<FinAccBills> {
 	 * @return
 	 */
     List<FinAccBillsVO> listAccBill(ListAccBillVO finAccBills);
+
+	/**
+	 *
+	 * @param id
+	 * @return
+	 */
+	FinAccBillsVO listByAccBillId(ListAccBillVO finAccBills);
 }

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

@@ -442,6 +442,11 @@ public class FinAccBillsServiceImpl extends ServiceImpl<FinAccBillsMapper, FinAc
 		return billsMapper.listAccBill(finAccBills);
 	}
 
+	@Override
+	public FinAccBillsVO listByAccBillId(ListAccBillVO finAccBills) {
+		return billsMapper.listByAccBillId(finAccBills);
+	}
+
 	private static <T> Predicate<T> distinctByKey(Function<? super T, ?> keyExtractor) {
 		Set<Object> seen = ConcurrentHashMap.newKeySet();
 		return t -> seen.add(keyExtractor.apply(t));

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

@@ -155,7 +155,7 @@ public class FinInvoicesServiceImpl extends ServiceImpl<FinInvoicesMapper, FinIn
 					item.setCurrentAmountLoc(item.getCurrentAmount());
 					item.setCurrentAmountEx(item.getCurrentAmount());
 				} else {
-					item.setCurrentAmountLoc(bCurrencyService.converterCny(item.getCurrentCurCode(), item.getCurrentAmount(),""));
+					item.setCurrentAmountLoc(bCurrencyService.converterCny(item.getCurrentCurCode(), item.getCurrentAmount(), ""));
 					if (1 == finInvoices.getIsExchangeToCny()) {
 						item.setCurrentAmountEx(item.getCurrentAmount().multiply(finInvoices.getExrate()));
 					} else {
@@ -220,7 +220,7 @@ public class FinInvoicesServiceImpl extends ServiceImpl<FinInvoicesMapper, FinIn
 			finInvoices.setAmountUsd(amountUsdD.subtract(amountUsdC));
 			finInvoices.setAmountTax(amountTaxD.subtract(amountTaxC).abs());
 			finInvoices.setAmountSub(amountCnyD.subtract(amountCnyC));
-			finInvoices.setAmountLoc(finInvoices.getAmountCny().add(bCurrencyService.converterCny("USD", finInvoices.getAmountUsd(),"")));
+			finInvoices.setAmountLoc(finInvoices.getAmountCny().add(bCurrencyService.converterCny("USD", finInvoices.getAmountUsd(), "")));
 			finInvoices.setAmountSubLocNet(finInvoices.getAmountLoc());
 			finInvoices.setAmountSubUsd(amountUsdD.subtract(amountUsdC));
 		}
@@ -395,6 +395,7 @@ public class FinInvoicesServiceImpl extends ServiceImpl<FinInvoicesMapper, FinIn
 	}
 
 	private List<FeeCenter> reconciliationFeeCenter(FinInvoices detail, List<FeeCenter> feeCenterList, int count) {
+		BigDecimal currentStlAmount = detail.getAmountLoc();
 		for (FeeCenter item : feeCenterList) {
 			item.setInvoiceAmountLoc(item.getInvoiceAmountLoc() == null ? new BigDecimal("0.00") : item.getInvoiceAmountLoc());
 			if (count == 1) {
@@ -411,9 +412,18 @@ public class FinInvoicesServiceImpl extends ServiceImpl<FinInvoicesMapper, FinIn
 					item.setInvoiceAmount(detail.getAmountUsd());
 				}
 				item.setInvoiceAmountLoc(detail.getAmountLoc());
-				item.setUninvoicedAmount(item.getUninvoicedAmount().add(detail.getAmountLoc()));
 				item.setInvoiceById(detail.getCreateUser());
 				item.setInvoiceByName(detail.getCreateUserName());
+				if (item.getAmount().subtract(item.getUninvoicedAmount()).compareTo(currentStlAmount) > 0) {
+					item.setUninvoicedAmount(item.getUninvoicedAmount().add(currentStlAmount));
+					currentStlAmount = new BigDecimal("0.00");
+				} else if (item.getAmount().subtract(item.getStlTtlAmount()).compareTo(currentStlAmount) == 0) {
+					item.setUninvoicedAmount(item.getAmount());
+					currentStlAmount = new BigDecimal("0.00");
+				} else {
+					item.setUninvoicedAmount(item.getAmount());
+					currentStlAmount = currentStlAmount.subtract(item.getAmount());
+				}
 			} else if (count == 2) {
 				item.setInvoiceBillId(detail.getId() + "");
 				item.setInvoiceBillNo(detail.getBillNo());
@@ -431,6 +441,16 @@ public class FinInvoicesServiceImpl extends ServiceImpl<FinInvoicesMapper, FinIn
 				item.setUninvoicedAmount(item.getUninvoicedAmount().add(new BigDecimal("0.00").subtract(detail.getAmountLoc())));
 				item.setInvoiceById(detail.getCreateUser());
 				item.setInvoiceByName(detail.getCreateUserName());
+				if (item.getAmount().subtract(item.getUninvoicedAmount()).compareTo(currentStlAmount) > 0) {
+					item.setUninvoicedAmount(item.getUninvoicedAmount().subtract(currentStlAmount));
+					currentStlAmount = new BigDecimal("0.00");
+				} else if (item.getAmount().subtract(item.getStlTtlAmount()).compareTo(currentStlAmount) == 0) {
+					item.setUninvoicedAmount(item.getUninvoicedAmount().subtract(currentStlAmount));
+					currentStlAmount = new BigDecimal("0.00");
+				} else {
+					item.setUninvoicedAmount(item.getUninvoicedAmount().subtract(currentStlAmount));
+					currentStlAmount = currentStlAmount.subtract(item.getAmount());
+				}
 			} else if (count == 3) {
 				item.setAppliedInvoiceAmount(item.getAppliedInvoiceAmount().add(detail.getAmountLoc()));
 			} else if (count == 4) {
@@ -448,6 +468,9 @@ public class FinInvoicesServiceImpl extends ServiceImpl<FinInvoicesMapper, FinIn
 			throw new RuntimeException("缺少必要参数");
 		}
 		FinInvoices detail = baseMapper.selectById(finInvoices.getId());
+		if ("1".equals(detail.getBillStatus())) {
+			throw new RuntimeException("单据已结算,撤销失败");
+		}
 		if (ObjectUtils.isNotNull(finInvoices.getFinInvoicesItemsList())) {
 			for (FinInvoicesItems item : finInvoices.getFinInvoicesItemsList()) {
 				item.setBillDate(null);

+ 12 - 0
blade-service/blade-los/src/main/java/org/springblade/los/finance/stl/controller/FinStlBillsController.java

@@ -306,5 +306,17 @@ public class FinStlBillsController extends BladeController {
 		return finStlBillsService.generateFinStlBills(billId, dc);
 	}
 
+	/**
+	 * 详情
+	 */
+	@GetMapping("/getByDetail")
+	@ApiOperationSupport(order = 1)
+	@ApiOperation(value = "详情", notes = "传入finStlBills")
+	public R<FinStlBills> getByDetail(FinStlBills finStlBills) {
+		FinStlBills detail = finStlBillsService.getByDetail(finStlBills);
+		return R.data(detail);
+	}
+
+
 
 }

+ 2 - 0
blade-service/blade-los/src/main/java/org/springblade/los/finance/stl/service/IFinStlBillsService.java

@@ -103,4 +103,6 @@ public interface IFinStlBillsService extends IService<FinStlBills> {
 	 * @return
 	 */
 	R generateFinStlBills(String billId, String dc);
+
+	FinStlBills getByDetail(FinStlBills finStlBills);
 }

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

@@ -42,8 +42,10 @@ import org.springblade.los.check.service.IAuditPathsLevelsService;
 import org.springblade.los.check.service.IAuditProecessService;
 import org.springblade.los.finance.fee.entity.FeeCenter;
 import org.springblade.los.finance.fee.entity.FinAccBills;
+import org.springblade.los.finance.fee.entity.ListAccBillVO;
 import org.springblade.los.finance.fee.service.IFeeCenterService;
 import org.springblade.los.finance.fee.service.IFinAccBillsService;
+import org.springblade.los.finance.fee.vo.FinAccBillsVO;
 import org.springblade.los.finance.invoices.entity.FinInvoices;
 import org.springblade.los.finance.invoices.entity.FinInvoicesItems;
 import org.springblade.los.finance.invoices.mapper.FinInvoicesItemsMapper;
@@ -200,7 +202,7 @@ public class FinStlBillsServiceImpl extends ServiceImpl<FinStlBillsMapper, FinSt
 				if ("CNY".equals(item.getCurrentStlCurCode())) {
 					item.setCurrentStlAmountLoc(item.getCurrentStlAmount());
 				} else {
-					item.setCurrentStlAmountLoc(bCurrencyService.converterCny(item.getCurrentStlCurCode(), item.getCurrentStlAmount(),""));
+					item.setCurrentStlAmountLoc(bCurrencyService.converterCny(item.getCurrentStlCurCode(), item.getCurrentStlAmount(), ""));
 				}
 				// 去税金额 = 本次结算金额currentStlAmount - 税额amountTax
 				BigDecimal amountNet = new BigDecimal("0.00");
@@ -271,11 +273,11 @@ public class FinStlBillsServiceImpl extends ServiceImpl<FinStlBillsMapper, FinSt
 			finStlBills.setAmountCrUsdNet(amountCrUSDTax);
 			finStlBills.setAmountSub(finStlBills.getAmountCr().subtract(finStlBills.getAmountDr()));
 			finStlBills.setAmountSubUsd(finStlBills.getAmountCrUsd().subtract(finStlBills.getAmountDrUsd()));
-			finStlBills.setAmountDrLoc(amountDrCNY.add(bCurrencyService.converterCny("USD", amountDrUSD,"D")));
-			finStlBills.setAmountCrLoc(amountCrCNY.add(bCurrencyService.converterCny("USD", amountCrUSD,"C")));
+			finStlBills.setAmountDrLoc(amountDrCNY.add(bCurrencyService.converterCny("USD", amountDrUSD, "D")));
+			finStlBills.setAmountCrLoc(amountCrCNY.add(bCurrencyService.converterCny("USD", amountCrUSD, "C")));
 			finStlBills.setAmountSubLoc(finStlBills.getAmountCrLoc().subtract(finStlBills.getAmountDrLoc()));
-			finStlBills.setAmountDrLocNet(amountDrCNYTax.add(bCurrencyService.converterCny("USD", amountDrUSDTax,"D")));
-			finStlBills.setAmountCrLocNet(amountCrCNYTax.add(bCurrencyService.converterCny("USD", amountCrUSDTax,"C")));
+			finStlBills.setAmountDrLocNet(amountDrCNYTax.add(bCurrencyService.converterCny("USD", amountDrUSDTax, "D")));
+			finStlBills.setAmountCrLocNet(amountCrCNYTax.add(bCurrencyService.converterCny("USD", amountCrUSDTax, "C")));
 			finStlBills.setAmountSubLocNet(finStlBills.getAmountCrLocNet().subtract(finStlBills.getAmountDrLocNet()));
 
 		}
@@ -610,7 +612,7 @@ public class FinStlBillsServiceImpl extends ServiceImpl<FinStlBillsMapper, FinSt
 						finAccBills.setStlAmountDrLoc(finAccBills.getStlAmountDrLoc().add(finAccBills.getStlAmountDr().add(item.getCurrentStlDiscount())));
 					} else {
 						finAccBills.setStlAmountDrUsd(finAccBills.getStlAmountDrUsd().add(item.getCurrentStlAmount().add(item.getCurrentStlDiscount())));
-						BigDecimal cny = bCurrencyService.converterCny(item.getCurCode(), item.getCurrentStlAmount().add(item.getCurrentStlDiscount()),"D");
+						BigDecimal cny = bCurrencyService.converterCny(item.getCurCode(), item.getCurrentStlAmount().add(item.getCurrentStlDiscount()), "D");
 						finAccBills.setStlAmountDrLoc(finAccBills.getStlAmountDrLoc().add(cny));
 					}
 					if (finAccBills.getAmountDr().compareTo(finAccBills.getStlAmountDr()) == 0 &&
@@ -626,7 +628,7 @@ public class FinStlBillsServiceImpl extends ServiceImpl<FinStlBillsMapper, FinSt
 						finAccBills.setStlAmountCrLoc(finAccBills.getStlAmountCrLoc().add(finAccBills.getStlAmountCr()));
 					} else {
 						finAccBills.setStlAmountCrUsd(finAccBills.getStlAmountCrUsd().add(item.getCurrentStlAmount()));
-						BigDecimal cny = bCurrencyService.converterCny(item.getCurCode(), item.getCurrentStlAmount(),"C");
+						BigDecimal cny = bCurrencyService.converterCny(item.getCurCode(), item.getCurrentStlAmount(), "C");
 						finAccBills.setStlAmountCrLoc(finAccBills.getStlAmountCrLoc().add(cny));
 					}
 					if (finAccBills.getAmountCr().compareTo(finAccBills.getStlAmountCr()) == 0 &&
@@ -681,7 +683,7 @@ public class FinStlBillsServiceImpl extends ServiceImpl<FinStlBillsMapper, FinSt
 						e.setStlBillId(detail.getId());
 						e.setStlBillNo(detail.getBillNo());
 						e.setStlDate(detail.getBillDate());
-						e.setStlOrgAmount(bCurrencyService.converterCny(item.getCurCode(), item.getCurrentStlAmount(),e.getDc()));
+						e.setStlOrgAmount(bCurrencyService.converterCny(item.getCurCode(), item.getCurrentStlAmount(), e.getDc()));
 						e.setStlCurCode(item.getCurrentStlCurCode());
 						e.setStlExrate(item.getExrate());
 						e.setStlExrateLoc(item.getCurrentStlExrate());
@@ -690,18 +692,56 @@ public class FinStlBillsServiceImpl extends ServiceImpl<FinStlBillsMapper, FinSt
 						e.setStlStatus(1);
 						e.setStlById(detail.getCreateUser());
 						e.setStlByName(detail.getCreateUserName());
-						if (e.getAmount().subtract(e.getStlTtlAmount()).compareTo(currentStlAmount) > 0) {
-							e.setUnsettledAmount(e.getAmount().subtract(e.getStlTtlAmount()).subtract(currentStlAmount));
-							e.setStlTtlAmount(e.getAmount().subtract(e.getUnsettledAmount()));
-							currentStlAmount = new BigDecimal("0.00");
-						} else if (e.getAmount().subtract(e.getStlTtlAmount()).compareTo(currentStlAmount) == 0) {
-							e.setUnsettledAmount(new BigDecimal("0.00"));
-							e.setStlTtlAmount(e.getAmount().subtract(e.getUnsettledAmount()));
-							currentStlAmount = new BigDecimal("0.00");
+						if (ids.size() > 0) {
+							if ("D".equals(e.getDc())) {
+								if (e.getAmount().subtract(e.getStlTtlAmount()).compareTo(currentStlAmount) > 0) {
+									e.setUnsettledAmount(e.getAmount().subtract(e.getStlTtlAmount()).subtract(currentStlAmount));
+									e.setStlTtlAmount(e.getAmount().subtract(e.getUnsettledAmount()));
+									e.setAppliedInvoiceAmountStl(e.getAmount().subtract(e.getUnsettledAmount()).subtract(e.getAppliedInvoiceAmountStl()));
+									currentStlAmount = new BigDecimal("0.00");
+								} else if (e.getAmount().subtract(e.getStlTtlAmount()).compareTo(currentStlAmount) == 0) {
+									e.setUnsettledAmount(new BigDecimal("0.00"));
+									e.setStlTtlAmount(e.getAmount().subtract(e.getUnsettledAmount()));
+									e.setAppliedInvoiceAmountStl(e.getAmount().subtract(e.getUnsettledAmount()).subtract(e.getAppliedInvoiceAmountStl()));
+									currentStlAmount = new BigDecimal("0.00");
+								} else {
+									e.setUnsettledAmount(new BigDecimal("0.00"));
+									e.setStlTtlAmount(e.getAmount().subtract(e.getUnsettledAmount()));
+									e.setAppliedInvoiceAmountStl(e.getAmount().subtract(e.getUnsettledAmount()).subtract(e.getAppliedInvoiceAmountStl()));
+									currentStlAmount = currentStlAmount.subtract(e.getAmount());
+								}
+							} else {
+								if (e.getAmount().subtract(e.getStlTtlAmount()).compareTo(currentStlAmount) > 0) {
+									e.setUnsettledAmount(e.getAmount().subtract(e.getStlTtlAmount()).subtract(currentStlAmount));
+									e.setStlTtlAmount(e.getAmount().subtract(e.getUnsettledAmount()));
+									e.setAppliedAmountStl(e.getAmount().subtract(e.getUnsettledAmount()).subtract(e.getAppliedAmountStl()));
+									currentStlAmount = new BigDecimal("0.00");
+								} else if (e.getAmount().subtract(e.getStlTtlAmount()).compareTo(currentStlAmount) == 0) {
+									e.setUnsettledAmount(new BigDecimal("0.00"));
+									e.setStlTtlAmount(e.getAmount().subtract(e.getUnsettledAmount()));
+									e.setAppliedAmountStl(e.getAmount().subtract(e.getUnsettledAmount()).subtract(e.getAppliedAmountStl()));
+									currentStlAmount = new BigDecimal("0.00");
+								} else {
+									e.setUnsettledAmount(new BigDecimal("0.00"));
+									e.setStlTtlAmount(e.getAmount().subtract(e.getUnsettledAmount()));
+									e.setAppliedAmountStl(e.getAmount().subtract(e.getUnsettledAmount()).subtract(e.getAppliedAmountStl()));
+									currentStlAmount = currentStlAmount.subtract(e.getAmount());
+								}
+							}
 						} else {
-							e.setUnsettledAmount(new BigDecimal("0.00"));
-							e.setStlTtlAmount(e.getAmount().subtract(e.getUnsettledAmount()));
-							currentStlAmount = currentStlAmount.subtract(e.getAmount());
+							if (e.getAmount().subtract(e.getStlTtlAmount()).compareTo(currentStlAmount) > 0) {
+								e.setUnsettledAmount(e.getAmount().subtract(e.getStlTtlAmount()).subtract(currentStlAmount));
+								e.setStlTtlAmount(e.getAmount().subtract(e.getUnsettledAmount()));
+								currentStlAmount = new BigDecimal("0.00");
+							} else if (e.getAmount().subtract(e.getStlTtlAmount()).compareTo(currentStlAmount) == 0) {
+								e.setUnsettledAmount(new BigDecimal("0.00"));
+								e.setStlTtlAmount(e.getAmount().subtract(e.getUnsettledAmount()));
+								currentStlAmount = new BigDecimal("0.00");
+							} else {
+								e.setUnsettledAmount(new BigDecimal("0.00"));
+								e.setStlTtlAmount(e.getAmount().subtract(e.getUnsettledAmount()));
+								currentStlAmount = currentStlAmount.subtract(e.getAmount());
+							}
 						}
 						feeCenterList.add(e);
 					}
@@ -826,7 +866,7 @@ public class FinStlBillsServiceImpl extends ServiceImpl<FinStlBillsMapper, FinSt
 						finAccBills.setStlAmountDrLoc(finAccBills.getStlAmountDrLoc().subtract(finAccBills.getStlAmountDr().subtract(item.getCurrentStlDiscount())));
 					} else {
 						finAccBills.setStlAmountDrUsd(finAccBills.getStlAmountDrUsd().subtract(item.getCurrentStlAmount().subtract(item.getCurrentStlDiscount())));
-						BigDecimal cny = bCurrencyService.converterCny(item.getCurCode(), item.getCurrentStlAmount().subtract(item.getCurrentStlDiscount()),"D");
+						BigDecimal cny = bCurrencyService.converterCny(item.getCurCode(), item.getCurrentStlAmount().subtract(item.getCurrentStlDiscount()), "D");
 						finAccBills.setStlAmountDrLoc(finAccBills.getStlAmountDrLoc().subtract(cny));
 					}
 					if (finAccBills.getAmountDr().compareTo(new BigDecimal("0.00")) == 0 &&
@@ -855,7 +895,7 @@ public class FinStlBillsServiceImpl extends ServiceImpl<FinStlBillsMapper, FinSt
 						finAccBills.setStlAmountCrLoc(finAccBills.getStlAmountCrLoc().subtract(finAccBills.getStlAmountCr().subtract(item.getCurrentStlDiscount())));
 					} else {
 						finAccBills.setStlAmountCrUsd(finAccBills.getStlAmountCrUsd().subtract(item.getCurrentStlAmount().subtract(item.getCurrentStlDiscount())));
-						BigDecimal cny = bCurrencyService.converterCny(item.getCurCode(), item.getCurrentStlAmount().subtract(item.getCurrentStlDiscount()),"C");
+						BigDecimal cny = bCurrencyService.converterCny(item.getCurCode(), item.getCurrentStlAmount().subtract(item.getCurrentStlDiscount()), "C");
 						finAccBills.setStlAmountCrLoc(finAccBills.getStlAmountCrLoc().subtract(cny));
 					}
 					if (finAccBills.getAmountCr().compareTo(new BigDecimal("0.00")) == 0 &&
@@ -920,18 +960,56 @@ public class FinStlBillsServiceImpl extends ServiceImpl<FinStlBillsMapper, FinSt
 						e.setStlStatus(0);
 						e.setStlById(0L);
 						e.setStlByName("");
-						if (e.getStlTtlAmount().compareTo(currentStlAmount) > 0) {
-							e.setStlTtlAmount(e.getStlTtlAmount().subtract(currentStlAmount));
-							e.setUnsettledAmount(e.getAmount().subtract(e.getStlTtlAmount()));
-							currentStlAmount = new BigDecimal("0.00");
-						} else if (e.getStlTtlAmount().compareTo(currentStlAmount) == 0) {
-							e.setStlTtlAmount(new BigDecimal("0.00"));
-							e.setUnsettledAmount(e.getAmount().subtract(e.getStlTtlAmount()));
-							currentStlAmount = new BigDecimal("0.00");
-						} else {
-							e.setStlTtlAmount(new BigDecimal("0.00"));
-							e.setUnsettledAmount(e.getAmount().subtract(e.getStlTtlAmount()));
-							currentStlAmount = currentStlAmount.subtract(e.getAmount());
+						if (ids.size() > 0) {
+							if ("D".equals(e.getDc())) {
+								if (e.getStlTtlAmount().compareTo(currentStlAmount) > 0) {
+									e.setStlTtlAmount(e.getStlTtlAmount().subtract(currentStlAmount));
+									e.setUnsettledAmount(e.getAmount().subtract(e.getStlTtlAmount()));
+									e.setAppliedInvoiceAmountStl(e.getAmount().subtract(e.getUnsettledAmount()).subtract(e.getAppliedInvoiceAmountStl()));
+									currentStlAmount = new BigDecimal("0.00");
+								} else if (e.getStlTtlAmount().compareTo(currentStlAmount) == 0) {
+									e.setStlTtlAmount(new BigDecimal("0.00"));
+									e.setUnsettledAmount(e.getAmount().subtract(e.getStlTtlAmount()));
+									e.setAppliedInvoiceAmountStl(e.getAmount().subtract(e.getUnsettledAmount()).subtract(e.getAppliedInvoiceAmountStl()));
+									currentStlAmount = new BigDecimal("0.00");
+								} else {
+									e.setStlTtlAmount(new BigDecimal("0.00"));
+									e.setUnsettledAmount(e.getAmount().subtract(e.getStlTtlAmount()));
+									e.setAppliedInvoiceAmountStl(e.getAmount().subtract(e.getUnsettledAmount()).subtract(e.getAppliedInvoiceAmountStl()));
+									currentStlAmount = currentStlAmount.subtract(e.getAmount());
+								}
+							}else{
+								if (e.getStlTtlAmount().compareTo(currentStlAmount) > 0) {
+									e.setStlTtlAmount(e.getStlTtlAmount().subtract(currentStlAmount));
+									e.setUnsettledAmount(e.getAmount().subtract(e.getStlTtlAmount()));
+									e.setAppliedAmountStl(e.getAmount().subtract(e.getUnsettledAmount()).subtract(e.getAppliedAmountStl()));
+									currentStlAmount = new BigDecimal("0.00");
+								} else if (e.getStlTtlAmount().compareTo(currentStlAmount) == 0) {
+									e.setStlTtlAmount(new BigDecimal("0.00"));
+									e.setUnsettledAmount(e.getAmount().subtract(e.getStlTtlAmount()));
+									e.setAppliedAmountStl(e.getAmount().subtract(e.getUnsettledAmount()).subtract(e.getAppliedAmountStl()));
+									currentStlAmount = new BigDecimal("0.00");
+								} else {
+									e.setStlTtlAmount(new BigDecimal("0.00"));
+									e.setUnsettledAmount(e.getAmount().subtract(e.getStlTtlAmount()));
+									e.setAppliedAmountStl(e.getAmount().subtract(e.getUnsettledAmount()).subtract(e.getAppliedAmountStl()));
+									currentStlAmount = currentStlAmount.subtract(e.getAmount());
+								}
+							}
+						}else{
+							if (e.getStlTtlAmount().compareTo(currentStlAmount) > 0) {
+								e.setStlTtlAmount(e.getStlTtlAmount().subtract(currentStlAmount));
+								e.setUnsettledAmount(e.getAmount().subtract(e.getStlTtlAmount()));
+								currentStlAmount = new BigDecimal("0.00");
+							} else if (e.getStlTtlAmount().compareTo(currentStlAmount) == 0) {
+								e.setStlTtlAmount(new BigDecimal("0.00"));
+								e.setUnsettledAmount(e.getAmount().subtract(e.getStlTtlAmount()));
+								currentStlAmount = new BigDecimal("0.00");
+							} else {
+								e.setStlTtlAmount(new BigDecimal("0.00"));
+								e.setUnsettledAmount(e.getAmount().subtract(e.getStlTtlAmount()));
+								currentStlAmount = currentStlAmount.subtract(e.getAmount());
+							}
 						}
 						feeCenterList.add(e);
 					}
@@ -1164,6 +1242,9 @@ public class FinStlBillsServiceImpl extends ServiceImpl<FinStlBillsMapper, FinSt
 			auditProecessDTO.setCorpId(detail.getCorpId());
 			auditProecessDTO.setSalesCompanyId(Long.parseLong(detail.getCreateDept()));
 			auditProecessDTO.setSalesCompanyName(detail.getCreateDeptName());
+			auditProecessDTO.setPayAmount(detail.getAmountCrLoc());
+			auditProecessDTO.setReceivableAmount(detail.getAmountDrLoc());
+			auditProecessDTO.setGrossProfit(detail.getAmountSubLoc());
 			R financeProcess = auditProecessService.createFinanceProcess(auditProecessDTO);
 			if (!financeProcess.isSuccess()) {
 				throw new SecurityException("操作失败,请联系管理员");
@@ -1214,7 +1295,7 @@ public class FinStlBillsServiceImpl extends ServiceImpl<FinStlBillsMapper, FinSt
 					}
 				}
 				if (currentStlAmount.compareTo(new BigDecimal("0.00")) != 0) {
-					throw new RuntimeException("结算金额计算错误,操作失败");
+					throw new RuntimeException("本次申请金额加已申请金额超出账单金额,操作失败");
 				}
 				/**-----------------------费用中心数据处理--------------------------- */
 			}
@@ -1413,4 +1494,56 @@ public class FinStlBillsServiceImpl extends ServiceImpl<FinStlBillsMapper, FinSt
 		}
 		return R.data(finStlBills);
 	}
+
+	@Override
+	public FinStlBills getByDetail(FinStlBills finStlBills) {
+
+		FinStlBills detail = baseMapper.selectOne(new LambdaQueryWrapper<FinStlBills>()
+			.eq(FinStlBills::getIsDeleted, 0)
+			.eq(FinStlBills::getTenantId, AuthUtil.getTenantId())
+			.eq(FinStlBills::getBillNo, finStlBills.getCheckNo())
+			.eq(FinStlBills::getCorpId, finStlBills.getCorpId()));
+		if (detail == null) {
+			throw new RuntimeException("未查到单据信息");
+		}
+		List<FinStlBillsItems> finStlBillsItemsList = finStlBillsItemsService.list(new LambdaQueryWrapper<FinStlBillsItems>()
+			.eq(FinStlBillsItems::getIsDeleted, 0)
+			.eq(FinStlBillsItems::getTenantId, AuthUtil.getTenantId())
+			.eq(FinStlBillsItems::getPid, detail.getId())
+			.eq(ObjectUtils.isNotNull(finStlBills.getDc()), FinStlBillsItems::getDc, finStlBills.getDc())
+			.eq(ObjectUtils.isNotNull(finStlBills.getBusinessNo()), FinStlBillsItems::getBillNo, finStlBills.getBusinessNo())
+			.eq(ObjectUtils.isNotNull(finStlBills.getMblno()), FinStlBillsItems::getMblno, finStlBills.getMblno())
+			.eq(ObjectUtils.isNotNull(finStlBills.getAccountNo()), FinStlBillsItems::getAccBillNo, finStlBills.getAccountNo())
+			.eq(ObjectUtils.isNotNull(finStlBills.getHblno()), FinStlBillsItems::getHblno, finStlBills.getHblno())
+			.eq(ObjectUtils.isNotNull(finStlBills.getVesselId()), FinStlBillsItems::getVesselId, finStlBills.getVesselId())
+			.eq(ObjectUtils.isNotNull(finStlBills.getVoyageNo()), FinStlBillsItems::getVoyageNo, finStlBills.getVoyageNo())
+		);
+		for (FinStlBillsItems item : finStlBillsItemsList) {
+			ListAccBillVO finAccBills = new ListAccBillVO();
+			finAccBills.setAccId(item.getAccBillId());
+			FinAccBillsVO finAccBillsVO = finAccBillsService.listByAccBillId(finAccBills);
+			if (finAccBillsVO != null) {
+				item.setAppliedAmount(finAccBillsVO.getAppliedAmount());
+				item.setAppliedInvoiceAmount(finAccBillsVO.getAppliedInvoiceAmount());
+				item.setAppliedAmountStl(finAccBillsVO.getAppliedAmountStl());
+				item.setAppliedInvoiceAmountStl(finAccBillsVO.getAppliedInvoiceAmountStl());
+				item.setReconciliationAmount(finAccBillsVO.getReconciliationAmount());
+
+				item.setAppliedCurrentStlAmount(item.getAmount().subtract(item.getAppliedAmount().add(item.getAppliedAmountStl())).subtract(finAccBillsVO.getStlTtlAmount()));
+				item.setAppliedInvoiceCurrentStlAmount(item.getAmount().subtract(item.getAppliedInvoiceAmount()).add(item.getAppliedInvoiceAmountStl()).subtract(finAccBillsVO.getUninvoicedAmount()));
+				item.setCurrentStlAmount(item.getAmount().subtract(finAccBillsVO.getStlTtlAmount()));
+			} else {
+				item.setAppliedAmount(new BigDecimal("0.00"));
+				item.setAppliedInvoiceAmount(new BigDecimal("0.00"));
+				item.setAppliedAmountStl(new BigDecimal("0.00"));
+				item.setAppliedInvoiceAmountStl(new BigDecimal("0.00"));
+				item.setReconciliationAmount(new BigDecimal("0.00"));
+				item.setAppliedCurrentStlAmount(new BigDecimal("0.00"));
+				item.setAppliedInvoiceCurrentStlAmount(new BigDecimal("0.00"));
+				item.setCurrentStlAmount(new BigDecimal("0.00"));
+			}
+		}
+		detail.setFinStlBillsItemsList(finStlBillsItemsList);
+		return detail;
+	}
 }

+ 5 - 1
blade-service/blade-sales-part/src/main/java/org/springblade/salesPart/corps/controller/CorpsDescController.java

@@ -451,6 +451,7 @@ public class CorpsDescController extends BladeController {
 		LambdaQueryWrapper<PjCorpsDesc> lambdaQueryWrapper = new LambdaQueryWrapper<>();
 		lambdaQueryWrapper.eq(PjCorpsDesc::getTenantId, AuthUtil.getTenantId());
 		lambdaQueryWrapper.eq(PjCorpsDesc::getIsDeleted, 0);
+		lambdaQueryWrapper.eq(PjCorpsDesc::getSalesCompanyId, AuthUtil.getDeptId());
 		lambdaQueryWrapper.like(StringUtil.isNotBlank(corpsDesc.getCname()), PjCorpsDesc::getCname, corpsDesc.getCname());
 		lambdaQueryWrapper.like(StringUtil.isNotBlank(corpsDesc.getCorpType()), PjCorpsDesc::getCorpType, corpsDesc.getCorpType());
 		//获得客户信息
@@ -594,7 +595,10 @@ public class CorpsDescController extends BladeController {
 		BigDecimal lossRate = new BigDecimal("0.00");
 
 		LambdaQueryWrapper<PjCorpsDesc> corpsDescQueryWrapper = new LambdaQueryWrapper<>();
-		corpsDescQueryWrapper.eq(PjCorpsDesc::getIsDeleted, 0).eq(PjCorpsDesc::getTenantId, AuthUtil.getTenantId()).eq(PjCorpsDesc::getCorpType, "KH");
+		corpsDescQueryWrapper.eq(PjCorpsDesc::getIsDeleted, 0)
+			.eq(PjCorpsDesc::getTenantId, AuthUtil.getTenantId())
+			.eq(PjCorpsDesc::getSalesCompanyId, AuthUtil.getDeptId())
+			.eq(PjCorpsDesc::getCorpType, "KH");
 		//客户总数量
 		List<PjCorpsDesc> corpsDescList = corpsDescService.list(corpsDescQueryWrapper);
 		for (PjCorpsDesc corpsDesc : corpsDescList) {