纪新园 1 год назад
Родитель
Сommit
7c2ed04403

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

@@ -167,5 +167,11 @@ public class LosBFeesTemplate implements Serializable {
 	@TableField(exist = false)
 	private Long billNoId;
 
+	/**
+	 * 类型
+	 */
+	@TableField(exist = false)
+	private String type;
+
 
 }

+ 2 - 2
blade-service-api/blade-los-api/src/main/java/org/springblade/los/finance/fee/entity/FinAccBills.java

@@ -528,9 +528,9 @@ public class FinAccBills implements Serializable {
 	@TableField(exist = false)
 	private String voucherDateEnd;
 	/**
-	 * 是否对账(0 未对账 1 已对账)
+	 * 是否对账(0 未对账 1 部分对账 2 已对账)
 	 */
-	@ApiModelProperty(value = "是否对账(0 未对账 1 已对账)")
+	@ApiModelProperty(value = "是否对账(0 未对账 1 部分对账 2 已对账)")
 	private Integer isChecked;
 	/**
 	 * 是否销账(0 未销账 3 部分销账 9 销账)

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

@@ -340,6 +340,24 @@
         <if test='acc.branchId != null'>
             and find_in_set(acc.branch_id,#{acc.branchId})
         </if>
+
+        <if test='acc.type != null and acc.type != "" and acc.type == "1"'>
+            <if test='acc.isChecked != null and acc.isChecked == "0"'>
+                and acc.is_checked in (0,1,2)
+            </if>
+            <if test='acc.isChecked != null and acc.isChecked == "1"'>
+                and acc.is_checked in (0,1)
+            </if>
+            <if test='acc.isChecked != null and acc.isChecked == "2"'>
+                and acc.is_checked = 0
+            </if>
+            <if test='acc.isChecked != null and acc.isChecked == "3"'>
+                and acc.is_checked = 1
+            </if>
+            <if test='acc.isChecked != null and acc.isChecked == "4"'>
+                and acc.is_checked = 2
+            </if>
+        </if>
         <if test='acc.type != null and acc.type != "" and acc.type == "2"'>
             and fee.amount > fee.stl_ttl_amount
         </if>
@@ -389,9 +407,6 @@
         <if test="acc.hblno != null and acc.hblno != ''">
             and fee.hblno like concat('%', #{acc.hblno}, '%')
         </if>
-        <if test="acc.isChecked != null">
-            and acc.is_checked = #{acc.isChecked}
-        </if>
         <if test="acc.billDateStart != null and acc.billDateStart != ''">
             and acc.bill_date &gt;= #{acc.billDateStart}
         </if>

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

@@ -324,9 +324,6 @@ public class FinAccBillsController extends BladeController {
 		} else if ("3".equals(listAccBillVO.getType())) {
 			listAccBillVO.setType("4");
 		}
-		if (ObjectUtils.isNotNull(listAccBillVO.getIsChecked()) && 0 == listAccBillVO.getIsChecked()) {
-			listAccBillVO.setIsChecked(null);
-		}
 		if (ObjectUtils.isNotNull(listAccBillVO.getIsCleared()) && 0 == listAccBillVO.getIsCleared()) {
 			listAccBillVO.setIsCleared(null);
 		}
@@ -366,9 +363,7 @@ public class FinAccBillsController extends BladeController {
 					finAccBillsVOList.add(item);
 				}
 			} else if ("1".equals(type)) {
-				if (new BigDecimal("0.00").compareTo(item.getAmount().subtract(item.getReconciliationAmount())) < 0) {
-					finAccBillsVOList.add(item);
-				}
+				finAccBillsVOList.add(item);
 			} else if ("5".equals(type)) {
 				finAccBillsVOList.add(item);
 			}
@@ -397,9 +392,6 @@ public class FinAccBillsController extends BladeController {
 		} else if ("3".equals(listAccBillVO.getType())) {
 			listAccBillVO.setType("4");
 		}
-		if (ObjectUtils.isNotNull(listAccBillVO.getIsChecked()) && 0 == listAccBillVO.getIsChecked()) {
-			listAccBillVO.setIsChecked(null);
-		}
 		if (ObjectUtils.isNotNull(listAccBillVO.getIsCleared()) && 0 == listAccBillVO.getIsCleared()) {
 			listAccBillVO.setIsCleared(null);
 		}
@@ -440,9 +432,7 @@ public class FinAccBillsController extends BladeController {
 					finAccBillsVOList.add(item);
 				}
 			} else if ("1".equals(type)) {
-				if (new BigDecimal("0.00").compareTo(item.getAmount().subtract(item.getReconciliationAmount())) < 0) {
-					finAccBillsVOList.add(item);
-				}
+				finAccBillsVOList.add(item);
 			} else if ("5".equals(type)) {
 				finAccBillsVOList.add(item);
 			}

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

@@ -31,6 +31,8 @@ import org.springblade.los.basic.cur.entity.BCurrency;
 import org.springblade.los.basic.cur.service.IBCurrencyService;
 import org.springblade.los.basic.fees.entity.FeesTemplateItems;
 import org.springblade.los.basic.fees.entity.LosBFeesTemplate;
+import org.springblade.los.business.aea.entity.AeaBills;
+import org.springblade.los.business.aea.mapper.AeaBillsMapper;
 import org.springblade.los.business.amends.entity.Amends;
 import org.springblade.los.business.amends.mapper.AmendsMapper;
 import org.springblade.los.business.sea.entity.Bills;
@@ -69,6 +71,8 @@ public class FeeCenterServiceImpl extends ServiceImpl<FeeCenterMapper, FeeCenter
 
 	private final BillsMapper billsMapper;
 
+	private final AeaBillsMapper aeaBillsMapper;
+
 	private final AmendsMapper amendsMapper;
 
 	private final IBCurrencyService bCurrencyService;
@@ -171,181 +175,268 @@ public class FeeCenterServiceImpl extends ServiceImpl<FeeCenterMapper, FeeCenter
 	@GlobalTransactional(rollbackFor = Exception.class, timeoutMills = 12000000)
 	public R<List<FeeCenter>> templateImport(LosBFeesTemplate losBFeesTemplate) {
 		List<FeeCenter> list = new ArrayList<>();
-		Bills bills = billsMapper.selectById(losBFeesTemplate.getBillNoId());
-		if (bills == null) {
-			throw new RuntimeException("未找到主表信息");
-		}
-		List<PreContainers> preContainers = preContainersService.list(new LambdaQueryWrapper<PreContainers>()
-			.eq(PreContainers::getTenantId, AuthUtil.getTenantId())
-			.eq(PreContainers::getIsDeleted, 0)
-			.eq(PreContainers::getPid, bills.getId()));
-		if (losBFeesTemplate.getFeesTemplateItemsList().size() > 0) {
-			int count = 1;
-			for (FeesTemplateItems items : losBFeesTemplate.getFeesTemplateItemsList()) {
-				FeeCenter feeCenter = new FeeCenter();
-
-				feeCenter.setElementsCnName(items.getElementsCnName());
-				feeCenter.setElementsEnName(items.getElementsEnName());
-				feeCenter.setElementsId(items.getElementsId());
-				feeCenter.setElementsCode(items.getElementsCode());
-
-				feeCenter.setPid(bills.getId());
-				feeCenter.setCntrNo(bills.getQuantityCntrTypesDescr());
-				feeCenter.setBillNo(bills.getBillNo());
-				feeCenter.setBusinessType(bills.getBusinessType());
-				feeCenter.setBillType(bills.getBillType());
-				feeCenter.setBillDate(bills.getBillDate());
-				feeCenter.setBillCorpId(bills.getCorpId());
-				feeCenter.setBillCorpCnName(bills.getCorpCnName());
-				feeCenter.setBillCorpEnName(bills.getCorpEnName());
-				feeCenter.setLineId(bills.getLineId());
-				feeCenter.setLineCnName(bills.getLineCnName());
-				feeCenter.setLineEnName(bills.getLineEnName());
-				feeCenter.setVesselId(bills.getVesselId());
-				feeCenter.setVesselCnName(bills.getVesselCnName());
-				feeCenter.setVesselEnName(bills.getVesselEnName());
-				feeCenter.setVoyageNo(bills.getVoyageNo());
-				feeCenter.setMblno(bills.getMblno());
-				feeCenter.setHblno(bills.getHblno());
-				feeCenter.setEtd(bills.getEtd());
-				feeCenter.setEta(bills.getEta());
-				feeCenter.setPolId(bills.getPolId());
-				feeCenter.setPolCode(bills.getPolCode());
-				feeCenter.setPolCnName(bills.getPolCnName());
-				feeCenter.setPolEnName(bills.getPolEnName());
-				feeCenter.setPodId(bills.getPodId());
-				feeCenter.setPodCode(bills.getPodCode());
-				feeCenter.setPodCnName(bills.getPodCnName());
-				feeCenter.setPodEnName(bills.getPodEnName());
-				feeCenter.setDc(losBFeesTemplate.getDc());
-				feeCenter.setPaymode(bills.getMpaymode());
-				feeCenter.setSort(count);
-				count++;
-				feeCenter.setCorpId(items.getCorpId());
-				feeCenter.setCorpCnName(items.getCorpCnName());
-				feeCenter.setCorpEnName(items.getCorpEnName());
-				feeCenter.setFeeId(items.getFeeId());
-				feeCenter.setFeeCode(items.getFeeCode());
-				feeCenter.setFeeCnName(items.getFeeCnName());
-				feeCenter.setFeeEnName(items.getFeeEnName());
-				feeCenter.setUnitNo(items.getUnitNo());
-				feeCenter.setPrice(items.getPrice());
-				feeCenter.setCurCode(items.getCurCode());
-				if (ObjectUtils.isNotNull(feeCenter.getCurCode())) {
-					BCurrency bCurrency = new BCurrency();
-					bCurrency.setDate(bills.getEtd());
-					bCurrency.setDc(losBFeesTemplate.getDc());
-					List<BCurrency> bCurrencyList = bCurrencyService.getExrate(bCurrency);
-					if (bCurrencyList.size() > 0) {
-						BCurrency currency = bCurrencyList.stream().filter(e -> e.getCode().equals(feeCenter.getCurCode())).findFirst().orElse(null);
-						if (currency != null) {
-							feeCenter.setExrate(currency.getExrate());
-						} else {
-							throw new RuntimeException("未找到汇率信息");
+		if ("HYCK".equals(losBFeesTemplate.getType()) || "HYJK".equals(losBFeesTemplate.getType())){
+			Bills bills = billsMapper.selectById(losBFeesTemplate.getBillNoId());
+			if (bills == null) {
+				throw new RuntimeException("未找到主表信息");
+			}
+			List<PreContainers> preContainers = preContainersService.list(new LambdaQueryWrapper<PreContainers>()
+				.eq(PreContainers::getTenantId, AuthUtil.getTenantId())
+				.eq(PreContainers::getIsDeleted, 0)
+				.eq(PreContainers::getPid, bills.getId()));
+			if (losBFeesTemplate.getFeesTemplateItemsList().size() > 0) {
+				int count = 1;
+				for (FeesTemplateItems items : losBFeesTemplate.getFeesTemplateItemsList()) {
+					FeeCenter feeCenter = new FeeCenter();
+
+					feeCenter.setElementsCnName(items.getElementsCnName());
+					feeCenter.setElementsEnName(items.getElementsEnName());
+					feeCenter.setElementsId(items.getElementsId());
+					feeCenter.setElementsCode(items.getElementsCode());
+
+					feeCenter.setPid(bills.getId());
+					feeCenter.setCntrNo(bills.getQuantityCntrTypesDescr());
+					feeCenter.setBillNo(bills.getBillNo());
+					feeCenter.setBusinessType(bills.getBusinessType());
+					feeCenter.setBillType(bills.getBillType());
+					feeCenter.setBillDate(bills.getBillDate());
+					feeCenter.setBillCorpId(bills.getCorpId());
+					feeCenter.setBillCorpCnName(bills.getCorpCnName());
+					feeCenter.setBillCorpEnName(bills.getCorpEnName());
+					feeCenter.setLineId(bills.getLineId());
+					feeCenter.setLineCnName(bills.getLineCnName());
+					feeCenter.setLineEnName(bills.getLineEnName());
+					feeCenter.setVesselId(bills.getVesselId());
+					feeCenter.setVesselCnName(bills.getVesselCnName());
+					feeCenter.setVesselEnName(bills.getVesselEnName());
+					feeCenter.setVoyageNo(bills.getVoyageNo());
+					feeCenter.setMblno(bills.getMblno());
+					feeCenter.setHblno(bills.getHblno());
+					feeCenter.setEtd(bills.getEtd());
+					feeCenter.setEta(bills.getEta());
+					feeCenter.setPolId(bills.getPolId());
+					feeCenter.setPolCode(bills.getPolCode());
+					feeCenter.setPolCnName(bills.getPolCnName());
+					feeCenter.setPolEnName(bills.getPolEnName());
+					feeCenter.setPodId(bills.getPodId());
+					feeCenter.setPodCode(bills.getPodCode());
+					feeCenter.setPodCnName(bills.getPodCnName());
+					feeCenter.setPodEnName(bills.getPodEnName());
+					feeCenter.setDc(losBFeesTemplate.getDc());
+					feeCenter.setPaymode(bills.getMpaymode());
+					feeCenter.setSort(count);
+					count++;
+					feeCenter.setCorpId(items.getCorpId());
+					feeCenter.setCorpCnName(items.getCorpCnName());
+					feeCenter.setCorpEnName(items.getCorpEnName());
+					feeCenter.setFeeId(items.getFeeId());
+					feeCenter.setFeeCode(items.getFeeCode());
+					feeCenter.setFeeCnName(items.getFeeCnName());
+					feeCenter.setFeeEnName(items.getFeeEnName());
+					feeCenter.setUnitNo(items.getUnitNo());
+					feeCenter.setPrice(items.getPrice());
+					feeCenter.setCurCode(items.getCurCode());
+					if (ObjectUtils.isNotNull(feeCenter.getCurCode())) {
+						BCurrency bCurrency = new BCurrency();
+						bCurrency.setDate(bills.getEtd());
+						bCurrency.setDc(losBFeesTemplate.getDc());
+						List<BCurrency> bCurrencyList = bCurrencyService.getExrate(bCurrency);
+						if (bCurrencyList.size() > 0) {
+							BCurrency currency = bCurrencyList.stream().filter(e -> e.getCode().equals(feeCenter.getCurCode())).findFirst().orElse(null);
+							if (currency != null) {
+								feeCenter.setExrate(currency.getExrate());
+							} else {
+								throw new RuntimeException("未找到汇率信息");
+							}
 						}
 					}
-				}
-				if ("1".equals(items.getQuantityRule())) {
-					if (preContainers.size() == 0) {
-						continue;
-					}
-					if ("20GP".equals(items.getUnitNo())) {
-						Integer quantity = preContainers.stream().filter(e -> "20GP".equals(e.getCntrTypeCode())).map(PreContainers::getQuantity).reduce(0, Integer::sum);
-						if (quantity == 0) {
+					if ("1".equals(items.getQuantityRule())) {
+						if (preContainers.size() == 0) {
 							continue;
 						}
-						feeCenter.setQuantity(new BigDecimal(quantity + ""));
-						feeCenter.setAmount(items.getPrice().multiply(feeCenter.getQuantity()));
-					} else if ("40GP".equals(items.getUnitNo())) {
-						Integer quantity = preContainers.stream().filter(e -> "40GP".equals(e.getCntrTypeCode())).map(PreContainers::getQuantity).reduce(0, Integer::sum);
-						if (quantity == 0) {
+						if ("20GP".equals(items.getUnitNo())) {
+							Integer quantity = preContainers.stream().filter(e -> "20GP".equals(e.getCntrTypeCode())).map(PreContainers::getQuantity).reduce(0, Integer::sum);
+							if (quantity == 0) {
+								continue;
+							}
+							feeCenter.setQuantity(new BigDecimal(quantity + ""));
+							feeCenter.setAmount(items.getPrice().multiply(feeCenter.getQuantity()));
+						} else if ("40GP".equals(items.getUnitNo())) {
+							Integer quantity = preContainers.stream().filter(e -> "40GP".equals(e.getCntrTypeCode())).map(PreContainers::getQuantity).reduce(0, Integer::sum);
+							if (quantity == 0) {
+								continue;
+							}
+							feeCenter.setQuantity(new BigDecimal(quantity + ""));
+							feeCenter.setAmount(items.getPrice().multiply(feeCenter.getQuantity()));
+						} else if ("40HC".equals(items.getUnitNo())) {
+							Integer quantity = preContainers.stream().filter(e -> "40HC".equals(e.getCntrTypeCode())).map(PreContainers::getQuantity).reduce(0, Integer::sum);
+							if (quantity == 0) {
+								continue;
+							}
+							feeCenter.setQuantity(new BigDecimal(quantity + ""));
+							feeCenter.setAmount(items.getPrice().multiply(feeCenter.getQuantity()));
+						} else if ("45GP".equals(items.getUnitNo())) {
+							Integer quantity = preContainers.stream().filter(e -> "45GP".equals(e.getCntrTypeCode())).map(PreContainers::getQuantity).reduce(0, Integer::sum);
+							if (quantity == 0) {
+								continue;
+							}
+							feeCenter.setQuantity(new BigDecimal(quantity + ""));
+							feeCenter.setAmount(items.getPrice().multiply(feeCenter.getQuantity()));
+						} else if ("48GP".equals(items.getUnitNo())) {
+							Integer quantity = preContainers.stream().filter(e -> "48GP".equals(e.getCntrTypeCode())).map(PreContainers::getQuantity).reduce(0, Integer::sum);
+							if (quantity == 0) {
+								continue;
+							}
+							feeCenter.setQuantity(new BigDecimal(quantity + ""));
+							feeCenter.setAmount(items.getPrice().multiply(feeCenter.getQuantity()));
+						}
+					} else if ("2".equals(items.getQuantityRule())) {
+						if ("JOB".equals(items.getUnitNo())) {
+							feeCenter.setQuantity(new BigDecimal("1"));
+							feeCenter.setAmount(items.getPrice().multiply(new BigDecimal("1")));
+						} else {
 							continue;
 						}
-						feeCenter.setQuantity(new BigDecimal(quantity + ""));
-						feeCenter.setAmount(items.getPrice().multiply(feeCenter.getQuantity()));
-					} else if ("40HC".equals(items.getUnitNo())) {
-						Integer quantity = preContainers.stream().filter(e -> "40HC".equals(e.getCntrTypeCode())).map(PreContainers::getQuantity).reduce(0, Integer::sum);
-						if (quantity == 0) {
+					} else if ("3".equals(items.getQuantityRule())) {
+						if ("KGS".equals(items.getUnitNo())) {
+							feeCenter.setQuantity(bills.getGrossWeight());
+							feeCenter.setAmount(items.getPrice().multiply(bills.getGrossWeight()));
+						} else {
 							continue;
 						}
-						feeCenter.setQuantity(new BigDecimal(quantity + ""));
-						feeCenter.setAmount(items.getPrice().multiply(feeCenter.getQuantity()));
-					} else if ("45GP".equals(items.getUnitNo())) {
-						Integer quantity = preContainers.stream().filter(e -> "45GP".equals(e.getCntrTypeCode())).map(PreContainers::getQuantity).reduce(0, Integer::sum);
-						if (quantity == 0) {
+					} else if ("4".equals(items.getQuantityRule())) {
+						if (preContainers.size() == 0) {
 							continue;
 						}
-						feeCenter.setQuantity(new BigDecimal(quantity + ""));
-						feeCenter.setAmount(items.getPrice().multiply(feeCenter.getQuantity()));
-					} else if ("48GP".equals(items.getUnitNo())) {
-						Integer quantity = preContainers.stream().filter(e -> "48GP".equals(e.getCntrTypeCode())).map(PreContainers::getQuantity).reduce(0, Integer::sum);
-						if (quantity == 0) {
+						if ("TEU".equals(items.getUnitNo())) {
+							BigDecimal quantity20GPTeu = preContainers.stream().filter(e -> "20GP".equals(e.getCntrTypeCode())).map(PreContainers::getTeu).reduce(BigDecimal.ZERO, BigDecimal::add);
+							Integer quantity20GP = preContainers.stream().filter(e -> "20GP".equals(e.getCntrTypeCode())).map(PreContainers::getQuantity).mapToInt(Integer::intValue).sum();
+							BigDecimal quantity20GPSum = quantity20GPTeu.multiply(new BigDecimal(quantity20GP + ""));
+
+							BigDecimal quantity40GPTeu = preContainers.stream().filter(e -> "40GP".equals(e.getCntrTypeCode())).map(PreContainers::getTeu).reduce(BigDecimal.ZERO, BigDecimal::add);
+							Integer quantity40GP = preContainers.stream().filter(e -> "40GP".equals(e.getCntrTypeCode())).map(PreContainers::getQuantity).mapToInt(Integer::intValue).sum();
+							BigDecimal quantity40GPSum = quantity40GPTeu.multiply(new BigDecimal(quantity40GP + ""));
+
+							BigDecimal quantity40HCTeu = preContainers.stream().filter(e -> "40HC".equals(e.getCntrTypeCode())).map(PreContainers::getTeu).reduce(BigDecimal.ZERO, BigDecimal::add);
+							Integer quantity40HC = preContainers.stream().filter(e -> "40HC".equals(e.getCntrTypeCode())).map(PreContainers::getQuantity).mapToInt(Integer::intValue).sum();
+							BigDecimal quantity40HCSum = quantity40HCTeu.multiply(new BigDecimal(quantity40HC + ""));
+
+							BigDecimal quantity45GPTeu = preContainers.stream().filter(e -> "45GP".equals(e.getCntrTypeCode())).map(PreContainers::getTeu).reduce(BigDecimal.ZERO, BigDecimal::add);
+							Integer quantity45GP = preContainers.stream().filter(e -> "45GP".equals(e.getCntrTypeCode())).map(PreContainers::getQuantity).mapToInt(Integer::intValue).sum();
+							BigDecimal quantity45GPSum = quantity45GPTeu.multiply(new BigDecimal(quantity45GP + ""));
+
+							BigDecimal quantity48GPTeu = preContainers.stream().filter(e -> "48GP".equals(e.getCntrTypeCode())).map(PreContainers::getTeu).reduce(BigDecimal.ZERO, BigDecimal::add);
+							Integer quantity48GP = preContainers.stream().filter(e -> "48GP".equals(e.getCntrTypeCode())).map(PreContainers::getQuantity).mapToInt(Integer::intValue).sum();
+							BigDecimal quantity48GPSum = quantity48GPTeu.multiply(new BigDecimal(quantity48GP + ""));
+
+							BigDecimal quantity = quantity20GPSum.add(quantity40GPSum).add(quantity40HCSum).add(quantity45GPSum).add(quantity48GPSum);
+							if (quantity.compareTo(new BigDecimal("0")) == 0) {
+								continue;
+							}
+							feeCenter.setQuantity(new BigDecimal(quantity + ""));
+							feeCenter.setAmount(items.getPrice().multiply(feeCenter.getQuantity()));
+						}
+					} else if ("5".equals(items.getQuantityRule())) {
+						if ("CBM".equals(items.getUnitNo())) {
+							feeCenter.setQuantity(bills.getMeasurement());
+							feeCenter.setAmount(items.getPrice().multiply(bills.getMeasurement()));
+						} else {
 							continue;
 						}
-						feeCenter.setQuantity(new BigDecimal(quantity + ""));
-						feeCenter.setAmount(items.getPrice().multiply(feeCenter.getQuantity()));
-					}
-				} else if ("2".equals(items.getQuantityRule())) {
-					if ("JOB".equals(items.getUnitNo())) {
+					} else {
 						feeCenter.setQuantity(new BigDecimal("1"));
 						feeCenter.setAmount(items.getPrice().multiply(new BigDecimal("1")));
-					} else {
-						continue;
 					}
-				} else if ("3".equals(items.getQuantityRule())) {
-					if ("KGS".equals(items.getUnitNo())) {
-						feeCenter.setQuantity(bills.getGrossWeight());
-						feeCenter.setAmount(items.getPrice().multiply(bills.getGrossWeight()));
-					} else {
-						continue;
-					}
-				} else if ("4".equals(items.getQuantityRule())) {
-					if (preContainers.size() == 0) {
-						continue;
+					list.add(feeCenter);
+				}
+			}
+			this.saveOrUpdateBatch(list);
+		}else if ("KYCK".equals(losBFeesTemplate.getType()) || "KYJK".equals(losBFeesTemplate.getType())){
+			AeaBills bills = aeaBillsMapper.selectById(losBFeesTemplate.getBillNoId());
+			if (bills == null) {
+				throw new RuntimeException("未找到主表信息");
+			}
+			if (losBFeesTemplate.getFeesTemplateItemsList().size() > 0) {
+				int count = 1;
+				for (FeesTemplateItems items : losBFeesTemplate.getFeesTemplateItemsList()) {
+					FeeCenter feeCenter = new FeeCenter();
+
+					feeCenter.setElementsCnName(items.getElementsCnName());
+					feeCenter.setElementsEnName(items.getElementsEnName());
+					feeCenter.setElementsId(items.getElementsId());
+					feeCenter.setElementsCode(items.getElementsCode());
+
+					feeCenter.setPid(bills.getId());
+					feeCenter.setBillNo(bills.getBillNo());
+					feeCenter.setBusinessType(bills.getBusinessType());
+					feeCenter.setBillType(bills.getBillType());
+					feeCenter.setBillDate(bills.getBillDate());
+					feeCenter.setBillCorpId(bills.getCorpId());
+					feeCenter.setBillCorpCnName(bills.getCorpCnName());
+					feeCenter.setBillCorpEnName(bills.getCorpEnName());
+					feeCenter.setVoyageNo(bills.getVoyageNo());
+					feeCenter.setMblno(bills.getMblno());
+					feeCenter.setHblno(bills.getHblno());
+					feeCenter.setEtd(bills.getEtd());
+					feeCenter.setEta(bills.getEta());
+					feeCenter.setDc(losBFeesTemplate.getDc());
+					feeCenter.setSort(count);
+					count++;
+					feeCenter.setCorpId(items.getCorpId());
+					feeCenter.setCorpCnName(items.getCorpCnName());
+					feeCenter.setCorpEnName(items.getCorpEnName());
+					feeCenter.setFeeId(items.getFeeId());
+					feeCenter.setFeeCode(items.getFeeCode());
+					feeCenter.setFeeCnName(items.getFeeCnName());
+					feeCenter.setFeeEnName(items.getFeeEnName());
+					feeCenter.setUnitNo(items.getUnitNo());
+					feeCenter.setPrice(items.getPrice());
+					feeCenter.setCurCode(items.getCurCode());
+					if (ObjectUtils.isNotNull(feeCenter.getCurCode())) {
+						BCurrency bCurrency = new BCurrency();
+						bCurrency.setDate(bills.getEtd());
+						bCurrency.setDc(losBFeesTemplate.getDc());
+						List<BCurrency> bCurrencyList = bCurrencyService.getExrate(bCurrency);
+						if (bCurrencyList.size() > 0) {
+							BCurrency currency = bCurrencyList.stream().filter(e -> e.getCode().equals(feeCenter.getCurCode())).findFirst().orElse(null);
+							if (currency != null) {
+								feeCenter.setExrate(currency.getExrate());
+							} else {
+								throw new RuntimeException("未找到汇率信息");
+							}
+						}
 					}
-					if ("TEU".equals(items.getUnitNo())) {
-						BigDecimal quantity20GPTeu = preContainers.stream().filter(e -> "20GP".equals(e.getCntrTypeCode())).map(PreContainers::getTeu).reduce(BigDecimal.ZERO, BigDecimal::add);
-						Integer quantity20GP = preContainers.stream().filter(e -> "20GP".equals(e.getCntrTypeCode())).map(PreContainers::getQuantity).mapToInt(Integer::intValue).sum();
-						BigDecimal quantity20GPSum = quantity20GPTeu.multiply(new BigDecimal(quantity20GP + ""));
-
-						BigDecimal quantity40GPTeu = preContainers.stream().filter(e -> "40GP".equals(e.getCntrTypeCode())).map(PreContainers::getTeu).reduce(BigDecimal.ZERO, BigDecimal::add);
-						Integer quantity40GP = preContainers.stream().filter(e -> "40GP".equals(e.getCntrTypeCode())).map(PreContainers::getQuantity).mapToInt(Integer::intValue).sum();
-						BigDecimal quantity40GPSum = quantity40GPTeu.multiply(new BigDecimal(quantity40GP + ""));
-
-						BigDecimal quantity40HCTeu = preContainers.stream().filter(e -> "40HC".equals(e.getCntrTypeCode())).map(PreContainers::getTeu).reduce(BigDecimal.ZERO, BigDecimal::add);
-						Integer quantity40HC = preContainers.stream().filter(e -> "40HC".equals(e.getCntrTypeCode())).map(PreContainers::getQuantity).mapToInt(Integer::intValue).sum();
-						BigDecimal quantity40HCSum = quantity40HCTeu.multiply(new BigDecimal(quantity40HC + ""));
-
-						BigDecimal quantity45GPTeu = preContainers.stream().filter(e -> "45GP".equals(e.getCntrTypeCode())).map(PreContainers::getTeu).reduce(BigDecimal.ZERO, BigDecimal::add);
-						Integer quantity45GP = preContainers.stream().filter(e -> "45GP".equals(e.getCntrTypeCode())).map(PreContainers::getQuantity).mapToInt(Integer::intValue).sum();
-						BigDecimal quantity45GPSum = quantity45GPTeu.multiply(new BigDecimal(quantity45GP + ""));
-
-						BigDecimal quantity48GPTeu = preContainers.stream().filter(e -> "48GP".equals(e.getCntrTypeCode())).map(PreContainers::getTeu).reduce(BigDecimal.ZERO, BigDecimal::add);
-						Integer quantity48GP = preContainers.stream().filter(e -> "48GP".equals(e.getCntrTypeCode())).map(PreContainers::getQuantity).mapToInt(Integer::intValue).sum();
-						BigDecimal quantity48GPSum = quantity48GPTeu.multiply(new BigDecimal(quantity48GP + ""));
-
-						BigDecimal quantity = quantity20GPSum.add(quantity40GPSum).add(quantity40HCSum).add(quantity45GPSum).add(quantity48GPSum);
-						if (quantity.compareTo(new BigDecimal("0")) == 0) {
+					 if ("2".equals(items.getQuantityRule())) {
+						if ("JOB".equals(items.getUnitNo())) {
+							feeCenter.setQuantity(new BigDecimal("1"));
+							feeCenter.setAmount(items.getPrice().multiply(new BigDecimal("1")));
+						} else {
+							continue;
+						}
+					} else if ("3".equals(items.getQuantityRule())) {
+						if ("KGS".equals(items.getUnitNo())) {
+							feeCenter.setQuantity(bills.getGrossWeight());
+							feeCenter.setAmount(items.getPrice().multiply(bills.getGrossWeight()));
+						} else {
+							continue;
+						}
+					}else if ("5".equals(items.getQuantityRule())) {
+						if ("CBM".equals(items.getUnitNo())) {
+							feeCenter.setQuantity(bills.getMeasurement());
+							feeCenter.setAmount(items.getPrice().multiply(bills.getMeasurement()));
+						} else {
 							continue;
 						}
-						feeCenter.setQuantity(new BigDecimal(quantity + ""));
-						feeCenter.setAmount(items.getPrice().multiply(feeCenter.getQuantity()));
-					}
-				} else if ("5".equals(items.getQuantityRule())) {
-					if ("CBM".equals(items.getUnitNo())) {
-						feeCenter.setQuantity(bills.getMeasurement());
-						feeCenter.setAmount(items.getPrice().multiply(bills.getMeasurement()));
 					} else {
-						continue;
+						feeCenter.setQuantity(new BigDecimal("1"));
+						feeCenter.setAmount(items.getPrice().multiply(new BigDecimal("1")));
 					}
-				} else {
-					feeCenter.setQuantity(new BigDecimal("1"));
-					feeCenter.setAmount(items.getPrice().multiply(new BigDecimal("1")));
+					list.add(feeCenter);
 				}
-				list.add(feeCenter);
 			}
+			this.saveOrUpdateBatch(list);
 		}
-		this.saveOrUpdateBatch(list);
+
 		return R.data(list);
 	}
 

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

@@ -215,6 +215,8 @@ public class FinInvoicesServiceImpl extends ServiceImpl<FinInvoicesMapper, FinIn
 			finInvoices.setAmountLoc(finInvoices.getAmountCny().add(bCurrencyService.converterCny("USD", finInvoices.getAmountUsd(), "")));
 			finInvoices.setAmountSubLocNet(finInvoices.getAmountLoc());
 			finInvoices.setAmountSubUsd(amountUsdD.subtract(amountUsdC));
+		}else {
+			throw new RuntimeException("请选择明细");
 		}
 		BigDecimal taxRate = new BigDecimal("0.00");
 		BigDecimal invoiceAmount = new BigDecimal("0.00");
@@ -400,6 +402,8 @@ public class FinInvoicesServiceImpl extends ServiceImpl<FinInvoicesMapper, FinIn
 			}
 			feeCenterService.saveOrUpdateBatch(feeCenterList);
 			finAccBillsService.saveOrUpdateBatch(finAccBillsList);
+		}else {
+			throw new RuntimeException("请选择明细");
 		}
 		BigDecimal invoiceAmount = new BigDecimal("0.00");
 		if (ObjectUtils.isNotNull(finInvoices.getFinInvoiceItemDetailList())) {
@@ -581,6 +585,8 @@ public class FinInvoicesServiceImpl extends ServiceImpl<FinInvoicesMapper, FinIn
 			}
 			feeCenterService.saveOrUpdateBatch(feeCenterList);
 			finAccBillsService.saveOrUpdateBatch(finAccBillsList);
+		}else {
+			throw new RuntimeException("请选择明细");
 		}
 		detail.setStatus(0);
 		baseMapper.updateById(detail);
@@ -664,6 +670,8 @@ public class FinInvoicesServiceImpl extends ServiceImpl<FinInvoicesMapper, FinIn
 			}
 			feeCenterService.saveOrUpdateBatch(feeCenterList);
 			finAccBillsService.saveOrUpdateBatch(finAccBillsList);
+		}else {
+			throw new RuntimeException("请选择明细");
 		}
 		BigDecimal invoiceAmount = new BigDecimal("0.00");
 		if (ObjectUtils.isNotNull(finInvoices.getFinInvoiceItemDetailList())) {
@@ -744,6 +752,8 @@ public class FinInvoicesServiceImpl extends ServiceImpl<FinInvoicesMapper, FinIn
 			}
 			feeCenterService.saveOrUpdateBatch(feeCenterList);
 			finAccBillsService.saveOrUpdateBatch(finAccBillsList);
+		}else {
+			throw new RuntimeException("请选择明细");
 		}
 		detail.setStatus(0);
 		baseMapper.updateById(detail);

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

@@ -270,6 +270,8 @@ public class FinStlBillsServiceImpl extends ServiceImpl<FinStlBillsMapper, FinSt
 			finStlBills.setAmountCrLocNet(amountCrCNYTax.add(bCurrencyService.converterCny("USD", amountCrUSDTax, "C")));
 			finStlBills.setAmountSubLocNet(finStlBills.getAmountCrLocNet().subtract(finStlBills.getAmountDrLocNet()));
 
+		}else {
+			throw new RuntimeException("请选择明细");
 		}
 		this.saveOrUpdate(finStlBills);
 		return R.data(finStlBills);
@@ -295,7 +297,6 @@ public class FinStlBillsServiceImpl extends ServiceImpl<FinStlBillsMapper, FinSt
 				item.setUpdateUserName(AuthUtil.getUserName());
 				FinAccBills finAccBills = finAccBillsService.getById(item.getAccBillId());
 				if (finAccBills != null) {
-					finAccBills.setIsChecked(1);
 					finAccBills.setUpdateUser(AuthUtil.getUserId());
 					finAccBills.setUpdateTime(new Date());
 					finAccBills.setUpdateUserName(AuthUtil.getUserName());
@@ -308,11 +309,40 @@ public class FinStlBillsServiceImpl extends ServiceImpl<FinStlBillsMapper, FinSt
 							throw new RuntimeException("本次对账金额大于账单应付金额");
 						}
 					}
+					int isChecked = 0;
 					if ("CNY".equals(item.getCurCode())) {
 						finAccBills.setReconciliationAmount(finAccBills.getReconciliationAmount().add(item.getCurrentStlAmount()));
+						if ("D".equals(finAccBills.getAccountDc())) {
+							if (finAccBills.getAmountDr().compareTo(finAccBills.getReconciliationAmount()) > 0) {
+								isChecked = 1;
+							} else if (finAccBills.getAmountDr().compareTo(finAccBills.getReconciliationAmount()) == 0) {
+								isChecked = 2;
+							}
+						} else {
+							if (finAccBills.getAmountCr().compareTo(finAccBills.getReconciliationAmount()) > 0) {
+								isChecked = 1;
+							} else if (finAccBills.getAmountCr().compareTo(finAccBills.getReconciliationAmount()) == 0) {
+								isChecked = 2;
+							}
+						}
 					} else {
 						finAccBills.setReconciliationAmountUsd(finAccBills.getReconciliationAmountUsd().add(item.getCurrentStlAmount()));
+						if ("D".equals(finAccBills.getAccountDc())) {
+							if (finAccBills.getAmountDrUsd().compareTo(finAccBills.getReconciliationAmountUsd()) > 0) {
+								isChecked = 1;
+							} else if (finAccBills.getAmountDrUsd().compareTo(finAccBills.getReconciliationAmountUsd()) == 0) {
+								isChecked = 2;
+							}
+						} else {
+							if (finAccBills.getAmountCrUsd().compareTo(finAccBills.getReconciliationAmountUsd()) > 0) {
+								isChecked = 1;
+							} else if (finAccBills.getAmountCrUsd().compareTo(finAccBills.getReconciliationAmountUsd()) == 0) {
+								isChecked = 2;
+							}
+						}
 					}
+					finAccBills.setIsChecked(isChecked);
+
 					finAccBillsList.add(finAccBills);
 					List<FeeCenter> feeCenters = feeCenterService.list(new LambdaQueryWrapper<FeeCenter>()
 						.in(FeeCenter::getAccBillId, finAccBills.getId())
@@ -348,6 +378,8 @@ public class FinStlBillsServiceImpl extends ServiceImpl<FinStlBillsMapper, FinSt
 			finStlBillsItemsService.saveOrUpdateBatch(finStlBills.getFinStlBillsItemsList());
 			feeCenterService.saveOrUpdateBatch(feeCenterList);
 			finAccBillsService.saveOrUpdateBatch(finAccBillsList);
+		} else {
+			throw new RuntimeException("请选择明细");
 		}
 		detail.setStatus(3);
 		detail.setIsChecked(1);
@@ -462,21 +494,48 @@ public class FinStlBillsServiceImpl extends ServiceImpl<FinStlBillsMapper, FinSt
 				item.setUpdateUserName(AuthUtil.getUserName());
 				FinAccBills finAccBills = finAccBillsService.getById(item.getAccBillId());
 				if (finAccBills != null) {
-					finAccBills.setIsChecked(1);
 					finAccBills.setUpdateUser(AuthUtil.getUserId());
 					finAccBills.setUpdateTime(new Date());
 					finAccBills.setUpdateUserName(AuthUtil.getUserName());
+					int isChecked = 0;
 					if ("CNY".equals(item.getCurCode())) {
 						if (finAccBills.getReconciliationAmount().compareTo(item.getCurrentStlAmount()) < 0) {
 							throw new RuntimeException("撤销失败,本次对账金额大于已对账金额");
 						}
 						finAccBills.setReconciliationAmount(finAccBills.getReconciliationAmount().subtract(item.getCurrentStlAmount()));
+						if ("D".equals(finAccBills.getAccountDc())) {
+							if (finAccBills.getAmountDr().compareTo(finAccBills.getReconciliationAmount()) > 0) {
+								isChecked = 1;
+							} else if (finAccBills.getAmountDr().compareTo(finAccBills.getReconciliationAmount()) == 0) {
+								isChecked = 0;
+							}
+						} else {
+							if (finAccBills.getAmountCr().compareTo(finAccBills.getReconciliationAmount()) > 0) {
+								isChecked = 1;
+							} else if (finAccBills.getAmountCr().compareTo(finAccBills.getReconciliationAmount()) == 0) {
+								isChecked = 0;
+							}
+						}
 					} else {
 						if (finAccBills.getReconciliationAmountUsd().compareTo(item.getCurrentStlAmount()) < 0) {
 							throw new RuntimeException("撤销失败,本次对账金额大于已对账金额");
 						}
 						finAccBills.setReconciliationAmountUsd(finAccBills.getReconciliationAmountUsd().subtract(item.getCurrentStlAmount()));
+						if ("D".equals(finAccBills.getAccountDc())) {
+							if (finAccBills.getAmountDrUsd().compareTo(finAccBills.getReconciliationAmountUsd()) > 0) {
+								isChecked = 1;
+							} else if (finAccBills.getAmountDrUsd().compareTo(finAccBills.getReconciliationAmountUsd()) == 0) {
+								isChecked = 0;
+							}
+						} else {
+							if (finAccBills.getAmountCrUsd().compareTo(finAccBills.getReconciliationAmountUsd()) > 0) {
+								isChecked = 1;
+							} else if (finAccBills.getAmountCrUsd().compareTo(finAccBills.getReconciliationAmountUsd()) == 0) {
+								isChecked = 0;
+							}
+						}
 					}
+					finAccBills.setIsChecked(isChecked);
 					finAccBillsList.add(finAccBills);
 					List<FeeCenter> feeCenters = feeCenterService.list(new LambdaQueryWrapper<FeeCenter>()
 						.in(FeeCenter::getAccBillId, finAccBills.getId())
@@ -512,6 +571,8 @@ public class FinStlBillsServiceImpl extends ServiceImpl<FinStlBillsMapper, FinSt
 			finStlBillsItemsService.saveOrUpdateBatch(finStlBills.getFinStlBillsItemsList());
 			feeCenterService.saveOrUpdateBatch(feeCenterList);
 			finAccBillsService.saveOrUpdateBatch(finAccBillsList);
+		}else {
+			throw new RuntimeException("请选择明细");
 		}
 		detail.setStatus(0);
 		detail.setIsChecked(2);
@@ -711,7 +772,7 @@ public class FinStlBillsServiceImpl extends ServiceImpl<FinStlBillsMapper, FinSt
 					.eq(FeeCenter::getAccStatus, 1)
 //					.apply("amount != stl_ttl_amount")
 					.orderByDesc(FeeCenter::getCreateTime));
-				BigDecimal currentStlAmount = item.getCurrentStlAmount();
+				BigDecimal currentStlAmount = item.getCurrentStlAmount().abs();
 				BigDecimal stlTtlAmount = feeCenters.stream().map(FeeCenter::getStlTtlAmount).filter(Objects::nonNull).reduce(BigDecimal.ZERO, BigDecimal::add);
 				if (item.getCurrentStlAmount().compareTo(new BigDecimal("0.00")) == 0 ||
 					item.getCurrentStlAmount().compareTo(item.getAmount().subtract(stlTtlAmount)) > 0) {
@@ -740,18 +801,24 @@ public class FinStlBillsServiceImpl extends ServiceImpl<FinStlBillsMapper, FinSt
 						e.setStlById(detail.getCreateUser());
 						e.setStlByName(detail.getCreateUserName());
 						if (ids.size() > 0) {
-							if ("D".equals(e.getDc())) {
-								if (e.getAmount().subtract(e.getStlTtlAmount()).compareTo(currentStlAmount) > 0) {
-									e.setStlTtlAmount(e.getAmount().subtract(e.getUnsettledAmount()));
-									currentStlAmount = new BigDecimal("0.00");
-								} else if (e.getAmount().subtract(e.getStlTtlAmount()).compareTo(currentStlAmount) == 0) {
-									e.setStlTtlAmount(e.getAmount().subtract(e.getUnsettledAmount()));
-									currentStlAmount = new BigDecimal("0.00");
-								} else {
-									e.setStlTtlAmount(e.getAmount().subtract(e.getUnsettledAmount()));
-									currentStlAmount = currentStlAmount.subtract(e.getAmount());
-								}
+//							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.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 {
 								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()));
@@ -768,7 +835,7 @@ public class FinStlBillsServiceImpl extends ServiceImpl<FinStlBillsMapper, FinSt
 									e.setAppliedAmountStl(e.getAmount().subtract(e.getUnsettledAmount()).subtract(e.getAppliedAmountStl()));
 									currentStlAmount = currentStlAmount.subtract(e.getAmount());
 								}
-							}
+							}*/
 						} else {
 							if (e.getAmount().subtract(e.getStlTtlAmount()).compareTo(currentStlAmount) > 0) {
 								e.setUnsettledAmount(e.getAmount().subtract(e.getStlTtlAmount()).subtract(currentStlAmount));
@@ -797,6 +864,8 @@ public class FinStlBillsServiceImpl extends ServiceImpl<FinStlBillsMapper, FinSt
 			finAccBillsService.saveOrUpdateBatch(finAccBillsList);
 			detail.setStatus(3);
 			detail.setIsCleared(1);
+		}else {
+			throw new RuntimeException("请选择明细");
 		}
 		baseMapper.updateById(detail);
 		return R.data(detail);
@@ -981,7 +1050,7 @@ public class FinStlBillsServiceImpl extends ServiceImpl<FinStlBillsMapper, FinSt
 					.eq(FeeCenter::getAccStatus, 1)
 //					.apply("stl_ttl_amount != 0")
 					.orderByDesc(FeeCenter::getCreateTime));
-				BigDecimal currentStlAmount = item.getCurrentStlAmount();
+				BigDecimal currentStlAmount = item.getCurrentStlAmount().abs();
 				BigDecimal stlTtlAmount = feeCenters.stream().map(FeeCenter::getStlTtlAmount).filter(Objects::nonNull).reduce(BigDecimal.ZERO, BigDecimal::add);
 				if (item.getCurrentStlAmount().compareTo(new BigDecimal("0.00")) == 0 ||
 					item.getCurrentStlAmount().compareTo(stlTtlAmount) > 0) {
@@ -1009,7 +1078,7 @@ public class FinStlBillsServiceImpl extends ServiceImpl<FinStlBillsMapper, FinSt
 						e.setStlById(0L);
 						e.setStlByName("");
 						if (ids.size() > 0) {
-							if ("D".equals(e.getDc())) {
+							/*if ("D".equals(e.getDc())) {
 								if (e.getStlTtlAmount().compareTo(currentStlAmount) > 0) {
 									e.setStlTtlAmount(e.getStlTtlAmount().subtract(currentStlAmount));
 									currentStlAmount = new BigDecimal("0.00");
@@ -1020,24 +1089,24 @@ public class FinStlBillsServiceImpl extends ServiceImpl<FinStlBillsMapper, FinSt
 									e.setStlTtlAmount(new BigDecimal("0.00"));
 									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.getAppliedAmountStl().subtract(currentStlAmount));
+								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 {
-								if (e.getStlTtlAmount().compareTo(currentStlAmount) > 0) {
-									e.setStlTtlAmount(e.getStlTtlAmount().subtract(currentStlAmount));
-									e.setUnsettledAmount(e.getAmount().subtract(e.getStlTtlAmount()));
-									e.setAppliedAmountStl(e.getAppliedAmountStl().subtract(currentStlAmount));
-									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(new BigDecimal("0.00"));
-									currentStlAmount = currentStlAmount.subtract(e.getAmount());
-								}
+								e.setStlTtlAmount(new BigDecimal("0.00"));
+								e.setUnsettledAmount(e.getAmount().subtract(e.getStlTtlAmount()));
+								e.setAppliedAmountStl(new BigDecimal("0.00"));
+								currentStlAmount = currentStlAmount.subtract(e.getAmount());
 							}
+//							}
 						} else {
 							if (e.getStlTtlAmount().compareTo(currentStlAmount) > 0) {
 								e.setStlTtlAmount(e.getStlTtlAmount().subtract(currentStlAmount));
@@ -1066,6 +1135,8 @@ public class FinStlBillsServiceImpl extends ServiceImpl<FinStlBillsMapper, FinSt
 			finAccBillsService.saveOrUpdateBatch(finAccBillsList);
 			detail.setStatus(0);
 			detail.setIsCleared(0);
+		}else {
+			throw new RuntimeException("请选择明细");
 		}
 		baseMapper.updateById(detail);
 		return R.data(detail);
@@ -1190,6 +1261,8 @@ public class FinStlBillsServiceImpl extends ServiceImpl<FinStlBillsMapper, FinSt
 				item.setUpdateUserName(AuthUtil.getUserName());
 			}
 			finStlBillsItemsService.saveOrUpdateBatch(finStlBills.getFinStlBillsItemsList());
+		}else {
+			throw new RuntimeException("请选择明细");
 		}
 		detail.setIsSignfor(1);
 		baseMapper.updateById(detail);
@@ -1215,6 +1288,8 @@ public class FinStlBillsServiceImpl extends ServiceImpl<FinStlBillsMapper, FinSt
 				item.setUpdateUserName(AuthUtil.getUserName());
 			}
 			finStlBillsItemsService.saveOrUpdateBatch(finStlBills.getFinStlBillsItemsList());
+		}else {
+			throw new RuntimeException("请选择明细");
 		}
 		detail.setIsSignfor(2);
 		baseMapper.updateById(detail);
@@ -1370,6 +1445,8 @@ public class FinStlBillsServiceImpl extends ServiceImpl<FinStlBillsMapper, FinSt
 			}
 			feeCenterService.saveOrUpdateBatch(feeCenterList);
 			finAccBillsService.saveOrUpdateBatch(finAccBillsList);
+		}else {
+			throw new RuntimeException("请选择明细");
 		}
 		baseMapper.updateById(detail);
 		return R.data(detail);
@@ -1454,6 +1531,8 @@ public class FinStlBillsServiceImpl extends ServiceImpl<FinStlBillsMapper, FinSt
 			}
 			feeCenterService.saveOrUpdateBatch(feeCenterList);
 			finAccBillsService.saveOrUpdateBatch(finAccBillsList);
+		}else {
+			throw new RuntimeException("请选择明细");
 		}
 		baseMapper.updateById(detail);
 		return R.data(detail);
@@ -1672,6 +1751,8 @@ public class FinStlBillsServiceImpl extends ServiceImpl<FinStlBillsMapper, FinSt
 			}
 			feeCenterService.saveOrUpdateBatch(feeCenterList);
 			finAccBillsService.saveOrUpdateBatch(finAccBillsList);
+		}else {
+			throw new RuntimeException("请选择明细");
 		}
 		baseMapper.updateById(detail);
 		return R.data(detail);
@@ -1707,6 +1788,8 @@ public class FinStlBillsServiceImpl extends ServiceImpl<FinStlBillsMapper, FinSt
 			}
 			feeCenterService.saveOrUpdateBatch(feeCenterList);
 			finAccBillsService.saveOrUpdateBatch(finAccBillsList);
+		}else {
+			throw new RuntimeException("请选择明细");
 		}
 		baseMapper.updateById(detail);
 		return R.data(detail);