Procházet zdrojové kódy

2024年6月18日13:41:34

纪新园 před 1 rokem
rodič
revize
64e18fb85b

+ 12 - 0
blade-service-api/blade-los-api/src/main/java/org/springblade/los/finance/genleg/dto/FinGenlegReport.java

@@ -50,6 +50,18 @@ public class FinGenlegReport implements Serializable {
 	 */
 	private String dc;
 	/**
+	 * 期初本币借方金额(CNY)
+	 */
+	private BigDecimal amountOpenDr;
+	/**
+	 * 期初本币贷方金额(CNY)
+	 */
+	private BigDecimal amountOpenCr;
+	/**
+	 * 期初本币余额(CNY)
+	 */
+	private BigDecimal amountOpenBlc;
+	/**
 	 * 上期本币余额(CNY)
 	 */
 	private BigDecimal amountLastBlc;

+ 4 - 2
blade-service/blade-los/src/main/java/org/springblade/los/basic/acc/controller/AccountsController.java

@@ -155,9 +155,11 @@ public class AccountsController extends BladeController {
 		lambdaQueryWrapper.eq(Accounts::getTenantId, AuthUtil.getTenantId())
 			.eq(Accounts::getBranchId, deptUtils.getDeptPid())
 			.eq(ObjectUtils.isNotNull(accounts.getProperty()), Accounts::getProperty, accounts.getProperty())
-			.like(ObjectUtils.isNotNull(accounts.getCode()), Accounts::getCode, accounts.getCode())
-			.like(ObjectUtils.isNotNull(accounts.getCnName()), Accounts::getCnName, accounts.getCnName())
+			.and(ObjectUtils.isNotNull(accounts.getCode()),i-> i.like( Accounts::getCode, accounts.getCode()).or()
+				.like( Accounts::getCnName, accounts.getCode()))
 			.eq(ObjectUtils.isNotNull(accounts.getCurCode()), Accounts::getCurCode, accounts.getCurCode())
+			.and(ObjectUtils.isNotNull(accounts.getCnName()),i-> i.like( Accounts::getCode, accounts.getCnName()).or()
+				.like( Accounts::getCnName, accounts.getCnName()))
 			.eq(ObjectUtils.isNotNull(accounts.getDc()), Accounts::getDc, accounts.getDc())
 			.eq(ObjectUtils.isNotNull(accounts.getIsDetail()), Accounts::getIsDetail, accounts.getIsDetail())
 			.eq(ObjectUtils.isNotNull(accounts.getIsForeign()), Accounts::getIsForeign, accounts.getIsForeign())

+ 35 - 34
blade-service/blade-los/src/main/java/org/springblade/los/basic/acc/service/impl/AccountsServiceImpl.java

@@ -427,6 +427,7 @@ public class AccountsServiceImpl extends ServiceImpl<AccountsMapper, Accounts> i
 		List<FinGenleg> finGenlegList = finGenlegMapper.selectList(genlegLambdaQueryWrapper);
 		LambdaQueryWrapper<FinVouchersItems> lambdaQueryWrapper = new LambdaQueryWrapper<>();
 		lambdaQueryWrapper.eq(FinVouchersItems::getIsDeleted, 0)
+			.eq(FinVouchersItems::getStatus, 1)
 			.eq(FinVouchersItems::getTenantId, AuthUtil.getTenantId())
 			.eq(FinVouchersItems::getBranchId, deptUtils.getDeptPid())
 			.eq(FinVouchersItems::getAccountId, accountsDTO.getAccIds())
@@ -444,33 +445,33 @@ public class AccountsServiceImpl extends ServiceImpl<AccountsMapper, Accounts> i
 		List<FinVouchersItems> finVouchersItemsList = finVouchersItemsService.list(lambdaQueryWrapper);
 		for (FinGenleg item : finGenlegList) {
 			AccountsDetail accountsDetail = new AccountsDetail();
-			accountsDetail.setVoucherDate(item.getAccyear() + "-" + item.getAccmonth() + "-01");
+			accountsDetail.setVoucherDate(item.getAccyear() + "-" + item.getAccmonth());
 			accountsDetail.setDescr("上期余额");
 			if ("D".equals(item.getDc())) {
 				if (new BigDecimal("0.00").compareTo(item.getAmountBlc()) < 0) {
-					accountsDetail.setDc("");
+					accountsDetail.setDc("");
 				} else if (new BigDecimal("0.00").compareTo(item.getAmountBlc()) == 0) {
 					accountsDetail.setDc("平");
 				} else {
-					accountsDetail.setDc("");
+					accountsDetail.setDc("");
 				}
 			} else {
 				if (new BigDecimal("0.00").compareTo(item.getAmountBlc()) < 0) {
-					accountsDetail.setDc("");
+					accountsDetail.setDc("");
 				} else if (new BigDecimal("0.00").compareTo(item.getAmountBlc()) == 0) {
 					accountsDetail.setDc("平");
 				} else {
-					accountsDetail.setDc("");
+					accountsDetail.setDc("");
 				}
 			}
-			accountsDetail.setAmountBlc(item.getAmountBlc());
-			accountsDetail.setAmountUsdBlc(item.getAmountUsdBlc());
+			accountsDetail.setAmountBlc(item.getAmountLastBlc());
+			accountsDetail.setAmountUsdBlc(item.getAmountLastBlcUsd());
 			accountsDetailList.add(accountsDetail);
 			List<FinVouchersItems> finVouchersItems = finVouchersItemsList.stream()
 				.filter(e -> e.getAccountId().equals(item.getAccId()) && e.getAccountYear().equals(item.getAccyear())
 					&& e.getAccountMonth().equals(item.getAccmonth())).collect(Collectors.toList());
-			BigDecimal amountBlc = item.getAmountBlc();
-			BigDecimal amountUsdBlc = item.getAmountUsdBlc();
+			BigDecimal amountBlc = item.getAmountLastBlc();
+			BigDecimal amountUsdBlc = item.getAmountLastBlcUsd();
 			if (!finVouchersItems.isEmpty()) {
 				for (FinVouchersItems vouchersItems : finVouchersItems) {
 					AccountsDetail detail = new AccountsDetail();
@@ -506,11 +507,11 @@ public class AccountsServiceImpl extends ServiceImpl<AccountsMapper, Accounts> i
 						amountBlc = amountBlc.add(vouchersItems.getAmountDr());
 						amountUsdBlc = amountUsdBlc.add(vouchersItems.getAmountDrUsd());
 						if (new BigDecimal("0.00").compareTo(amountBlc) < 0) {
-							detail.setDc("");
+							detail.setDc("");
 						} else if (new BigDecimal("0.00").compareTo(amountBlc) == 0) {
 							detail.setDc("平");
 						} else {
-							detail.setDc("");
+							detail.setDc("");
 						}
 					} else {
 						detail.setAmountCr(vouchersItems.getAmountCr());
@@ -518,11 +519,11 @@ public class AccountsServiceImpl extends ServiceImpl<AccountsMapper, Accounts> i
 						amountBlc = amountBlc.subtract(vouchersItems.getAmountCr());
 						amountUsdBlc = amountUsdBlc.subtract(vouchersItems.getAmountCrUsd());
 						if (new BigDecimal("0.00").compareTo(amountBlc) < 0) {
-							detail.setDc("");
+							detail.setDc("");
 						} else if (new BigDecimal("0.00").compareTo(amountBlc) == 0) {
 							detail.setDc("平");
 						} else {
-							detail.setDc("");
+							detail.setDc("");
 						}
 					}
 					detail.setAmountBlc(amountBlc);
@@ -541,19 +542,19 @@ public class AccountsServiceImpl extends ServiceImpl<AccountsMapper, Accounts> i
 					accountsDetailSum.setAmountCrUsd(item.getAmountCrUsd());
 					if ("D".equals(item.getDc())) {
 						if (new BigDecimal("0.00").compareTo(amountBlc) < 0) {
-							accountsDetailSum.setDc("");
+							accountsDetailSum.setDc("");
 						} else if (new BigDecimal("0.00").compareTo(amountBlc) == 0) {
 							accountsDetailSum.setDc("平");
 						} else {
-							accountsDetailSum.setDc("");
+							accountsDetailSum.setDc("");
 						}
 					} else {
 						if (new BigDecimal("0.00").compareTo(amountBlc) < 0) {
-							accountsDetailSum.setDc("");
+							accountsDetailSum.setDc("");
 						} else if (new BigDecimal("0.00").compareTo(amountBlc) == 0) {
 							accountsDetailSum.setDc("平");
 						} else {
-							accountsDetailSum.setDc("");
+							accountsDetailSum.setDc("");
 						}
 					}
 					accountsDetailSum.setAmountBlc(amountBlc);
@@ -570,19 +571,19 @@ public class AccountsServiceImpl extends ServiceImpl<AccountsMapper, Accounts> i
 					BigDecimal amount = item.getAmountYearDr().subtract(item.getAmountYearCr());
 					if ("D".equals(item.getDc())) {
 						if (new BigDecimal("0.00").compareTo(amount) < 0) {
-							accountsDetailYearSum.setDc("");
+							accountsDetailYearSum.setDc("");
 						} else if (new BigDecimal("0.00").compareTo(amount) == 0) {
 							accountsDetailYearSum.setDc("平");
 						} else {
-							accountsDetailYearSum.setDc("");
+							accountsDetailYearSum.setDc("");
 						}
 					} else {
 						if (new BigDecimal("0.00").compareTo(amount) < 0) {
-							accountsDetailYearSum.setDc("");
+							accountsDetailYearSum.setDc("");
 						} else if (new BigDecimal("0.00").compareTo(amount) == 0) {
 							accountsDetailYearSum.setDc("平");
 						} else {
-							accountsDetailYearSum.setDc("");
+							accountsDetailYearSum.setDc("");
 						}
 					}
 					accountsDetailYearSum.setAmountBlc(item.getAmountYearDr().subtract(item.getAmountYearCr()));
@@ -599,19 +600,19 @@ public class AccountsServiceImpl extends ServiceImpl<AccountsMapper, Accounts> i
 				accountsDetailSum.setAmountCrUsd(item.getAmountCrUsd());
 				if ("D".equals(item.getDc())) {
 					if (new BigDecimal("0.00").compareTo(amountBlc) < 0) {
-						accountsDetailSum.setDc("");
+						accountsDetailSum.setDc("");
 					} else if (new BigDecimal("0.00").compareTo(amountBlc) == 0) {
 						accountsDetailSum.setDc("平");
 					} else {
-						accountsDetailSum.setDc("");
+						accountsDetailSum.setDc("");
 					}
 				} else {
 					if (new BigDecimal("0.00").compareTo(amountBlc) < 0) {
-						accountsDetailSum.setDc("");
+						accountsDetailSum.setDc("");
 					} else if (new BigDecimal("0.00").compareTo(amountBlc) == 0) {
 						accountsDetailSum.setDc("平");
 					} else {
-						accountsDetailSum.setDc("");
+						accountsDetailSum.setDc("");
 					}
 				}
 				accountsDetailSum.setAmountBlc(amountBlc);
@@ -621,26 +622,26 @@ public class AccountsServiceImpl extends ServiceImpl<AccountsMapper, Accounts> i
 				AccountsDetail accountsDetailYearSum = new AccountsDetail();
 				accountsDetailYearSum.setVoucherDate(item.getAccyear() + "-" + item.getAccmonth());
 				accountsDetailYearSum.setDescr("本年累计计");
-				accountsDetailSum.setAmountDr(item.getAmountYearDr());
-				accountsDetailSum.setAmountCr(item.getAmountYearCr());
-				accountsDetailSum.setAmountDrUsd(item.getAmountYearDrUsd());
-				accountsDetailSum.setAmountCrUsd(item.getAmountYearCrUsd());
+				accountsDetailYearSum.setAmountDr(item.getAmountYearDr());
+				accountsDetailYearSum.setAmountCr(item.getAmountYearCr());
+				accountsDetailYearSum.setAmountDrUsd(item.getAmountYearDrUsd());
+				accountsDetailYearSum.setAmountCrUsd(item.getAmountYearCrUsd());
 				BigDecimal amount = item.getAmountYearDr().subtract(item.getAmountYearCr());
 				if ("D".equals(item.getDc())) {
 					if (new BigDecimal("0.00").compareTo(amount) < 0) {
-						accountsDetailYearSum.setDc("");
+						accountsDetailYearSum.setDc("");
 					} else if (new BigDecimal("0.00").compareTo(amount) == 0) {
 						accountsDetailYearSum.setDc("平");
 					} else {
-						accountsDetailYearSum.setDc("");
+						accountsDetailYearSum.setDc("");
 					}
 				} else {
 					if (new BigDecimal("0.00").compareTo(amount) < 0) {
-						accountsDetailYearSum.setDc("");
+						accountsDetailYearSum.setDc("");
 					} else if (new BigDecimal("0.00").compareTo(amount) == 0) {
 						accountsDetailYearSum.setDc("平");
 					} else {
-						accountsDetailYearSum.setDc("");
+						accountsDetailYearSum.setDc("");
 					}
 				}
 				accountsDetailYearSum.setAmountBlc(item.getAmountYearDr().subtract(item.getAmountYearCr()));
@@ -828,7 +829,7 @@ public class AccountsServiceImpl extends ServiceImpl<AccountsMapper, Accounts> i
 				list.add(accountsList1);
 			}
 		}
-		return list;
+		return list.stream().filter(e-> ObjectUtils.isNotNull(e.getAccName())).collect(Collectors.toList());
 	}
 
 	private void selectSuperiorCode(Accounts accounts, Long parentId) {

+ 1034 - 189
blade-service/blade-los/src/main/java/org/springblade/los/check/service/impl/AuditProecessServiceImpl.java

@@ -1283,22 +1283,20 @@ public class AuditProecessServiceImpl extends ServiceImpl<AuditProecessMapper, L
 		if (feeCenterList.isEmpty()) {
 			throw new RuntimeException("费用为空,自动生成凭证失败");
 		}
-		BCorps bCorps = null;
-		Dept dept = null;
-		User user = null;
-		BCorps userSrc = null;
 		Bills billsDetail = null;
 		AeaBills aeaBillsDetail = null;
 		CustomsDeclaration customsDeclarationDetail = null;
 		Amends amendsDetail = null;
 		String srcBillNo = "";
+		Dept dept = null;
+		User user = null;
+		BCorps userSrc = null;
 		//查询各业务模块 核算客户,核算部门,核算职员信息
 		if ("HYCK-DJ".equals(checkType) || "HYJK-DJ".equals(checkType)) {
 			Bills bills = billsMapper.selectById(id);
 			if (bills != null) {
 				srcBillNo = bills.getBillNo();
 				billsDetail = bills;
-				bCorps = bCorpsService.getById(bills.getCorpId());
 				if (ObjectUtils.isNotNull(bills.getAccDept())) {
 					R<Dept> deptR = sysClient.getDept(Long.parseLong(bills.getAccDept()));
 					if (deptR.isSuccess()) {
@@ -1332,7 +1330,6 @@ public class AuditProecessServiceImpl extends ServiceImpl<AuditProecessMapper, L
 			if (bills != null) {
 				srcBillNo = bills.getBillNo();
 				aeaBillsDetail = bills;
-				bCorps = bCorpsService.getById(bills.getCorpId());
 				if (ObjectUtils.isNotNull(bills.getAccDept())) {
 					R<Dept> deptR = sysClient.getDept(Long.parseLong(bills.getAccDept()));
 					if (deptR.isSuccess()) {
@@ -1367,7 +1364,6 @@ public class AuditProecessServiceImpl extends ServiceImpl<AuditProecessMapper, L
 			if (bills != null) {
 				srcBillNo = bills.getBillNo();
 				customsDeclarationDetail = bills;
-				bCorps = bCorpsService.getById(bills.getCorpId());
 				if (ObjectUtils.isNotNull(bills.getAccDept())) {
 					R<Dept> deptR = sysClient.getDept(Long.parseLong(bills.getAccDept()));
 					if (deptR.isSuccess()) {
@@ -1389,7 +1385,6 @@ public class AuditProecessServiceImpl extends ServiceImpl<AuditProecessMapper, L
 			if (bills != null) {
 				srcBillNo = bills.getBillNo();
 				amendsDetail = bills;
-				bCorps = bCorpsService.getById(bills.getCorpId());
 				if (ObjectUtils.isNotNull(bills.getAccDept())) {
 					R<Dept> deptR = sysClient.getDept(Long.parseLong(bills.getAccDept()));
 					if (deptR.isSuccess()) {
@@ -1407,6 +1402,7 @@ public class AuditProecessServiceImpl extends ServiceImpl<AuditProecessMapper, L
 						} else {
 							userSrc = bCorpsService.getById(bills1.getSrcId());
 						}
+
 						if ("MM".equals(bills1.getBillType())) {
 							List<Bills> billsList = billsMapper.selectList(new LambdaQueryWrapper<Bills>()
 								.select(Bills::getId)
@@ -1479,6 +1475,47 @@ public class AuditProecessServiceImpl extends ServiceImpl<AuditProecessMapper, L
 		if (new BigDecimal("0.00").compareTo(rateDRmb) != 0) {
 			rateD = rateDRmb.divide(amountDUsd, MathContext.DECIMAL32).setScale(4, RoundingMode.HALF_UP);
 		}
+		List<Long> corpIds = feeCenterList.stream().map(FeeCenter::getCorpId).collect(Collectors.toList());
+		List<BCorps> bCorpsList = bCorpsService.list(new LambdaQueryWrapper<BCorps>()
+			.eq(BCorps::getTenantId, AuthUtil.getTenantId())
+			.eq(BCorps::getIsDeleted, 0)
+			.in(BCorps::getId, corpIds));
+		List<Map<Long, BigDecimal>> mapListCC = new ArrayList<>();
+		List<Long> corpIdCC = feeCenterList.stream().filter(e -> "CNY".equals(e.getCurCode()) && "C".equals(e.getDc())).map(FeeCenter::getCorpId).distinct().collect(Collectors.toList());
+		for (Long item : corpIdCC) {
+			Map<Long, BigDecimal> map = new HashMap<>();
+			map.put(item, feeCenterList.stream().filter(e -> "CNY".equals(e.getCurCode())
+					&& "C".equals(e.getDc()) && item.equals(e.getCorpId())).map(FeeCenter::getAmount)
+				.reduce(BigDecimal.ZERO, BigDecimal::add));
+			mapListCC.add(map);
+		}
+		List<Map<Long, BigDecimal>> mapListUC = new ArrayList<>();
+		List<Long> corpIdUC = feeCenterList.stream().filter(e -> "USD".equals(e.getCurCode()) && "C".equals(e.getDc())).map(FeeCenter::getCorpId).distinct().collect(Collectors.toList());
+		for (Long item : corpIdUC) {
+			Map<Long, BigDecimal> map = new HashMap<>();
+			map.put(item, feeCenterList.stream().filter(e -> "USD".equals(e.getCurCode())
+					&& "C".equals(e.getDc()) && item.equals(e.getCorpId())).map(FeeCenter::getAmount)
+				.reduce(BigDecimal.ZERO, BigDecimal::add));
+			mapListUC.add(map);
+		}
+		List<Map<Long, BigDecimal>> mapListCD = new ArrayList<>();
+		List<Long> corpIdCD = feeCenterList.stream().filter(e -> "CNY".equals(e.getCurCode()) && "D".equals(e.getDc())).map(FeeCenter::getCorpId).distinct().collect(Collectors.toList());
+		for (Long item : corpIdCD) {
+			Map<Long, BigDecimal> map = new HashMap<>();
+			map.put(item, feeCenterList.stream().filter(e -> "CNY".equals(e.getCurCode())
+					&& "D".equals(e.getDc()) && item.equals(e.getCorpId())).map(FeeCenter::getAmount)
+				.reduce(BigDecimal.ZERO, BigDecimal::add));
+			mapListCD.add(map);
+		}
+		List<Map<Long, BigDecimal>> mapListUD = new ArrayList<>();
+		List<Long> corpIdUD = feeCenterList.stream().filter(e -> "USD".equals(e.getCurCode()) && "D".equals(e.getDc())).map(FeeCenter::getCorpId).distinct().collect(Collectors.toList());
+		for (Long item : corpIdUD) {
+			Map<Long, BigDecimal> map = new HashMap<>();
+			map.put(item, feeCenterList.stream().filter(e -> "USD".equals(e.getCurCode())
+					&& "D".equals(e.getDc()) && item.equals(e.getCorpId())).map(FeeCenter::getAmount)
+				.reduce(BigDecimal.ZERO, BigDecimal::add));
+			mapListUD.add(map);
+		}
 		//创建凭证主表信息
 		FinVouchers finVouchers = new FinVouchers();
 		String deptId = "";
@@ -1538,229 +1575,1037 @@ public class AuditProecessServiceImpl extends ServiceImpl<AuditProecessMapper, L
 			.eq(Accounts::getStatus, 0)
 			.apply("find_in_set(code,'" + accountsCode + "')"));
 		List<FinVouchersItems> finVouchersItemsList = new ArrayList<>();
-		SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
 		int count = 0;
-		//循环复制凭证明细信息
-		for (VoucherTemplate item : voucherTemplateList) {
+		SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
+		for (int i = 0; i < 8; i++) {
 			count++;
-			FinVouchersItems finVouchersItems = new FinVouchersItems();
-			finVouchersItems.setCreateTime(new Date());
-			finVouchersItems.setCreateUser(AuthUtil.getUserId());
-			finVouchersItems.setCreateUserName(AuthUtil.getUserName());
-			if (ObjectUtils.isNotNull(AuthUtil.getDeptId())) {
-				finVouchersItems.setCreateDept(deptId);
-				finVouchersItems.setBranchId(branchId);
-				finVouchersItems.setCreateDeptName(deptName);
-			}
-			finVouchersItems.setPid(finVouchers.getId());
-			finVouchersItems.setBillNo(finVouchers.getBillNo());
-			finVouchersItems.setVoucherSource(finVouchers.getVoucherSource());
-			finVouchersItems.setVoucherType(finVouchers.getVoucherType());
-			finVouchersItems.setVoucherNo(finVouchers.getVoucherNo());
-			finVouchersItems.setVoucherDate(finVouchers.getVoucherDate());
-			finVouchersItems.setAccountYear(finVouchers.getAccountYear());
-			finVouchersItems.setAccountMonth(finVouchers.getAccountMonth());
-			finVouchersItems.setAccountDay(finVouchers.getAccountDay());
+			VoucherTemplate item = voucherTemplateList.get(i);
 			Accounts accounts = accountsList.stream().filter(e -> e.getCode().equals(item.getSubjectCode()))
 				.findFirst().orElse(null);
 			//获取模板中科目所对应科目信息并赋值
 			if (accounts != null) {
-				finVouchersItems.setAccountId(accounts.getId());
-				finVouchersItems.setAccountCode(accounts.getCode());
-				finVouchersItems.setAccountCnName(accounts.getCnName());
-				finVouchersItems.setAccountEnName(accounts.getEnName());
-				finVouchersItems.setAccountProperty(accounts.getProperty());
-				finVouchersItems.setAccountLevel(accounts.getLevel());
-				finVouchersItems.setDc(item.getAmountDirection());
-				finVouchersItems.setCurCode(item.getCurrencyCode());
-				/*判断是否人民币,美元
-				 * 人民币 判断模版借贷方向与科目借贷方向是否一致 true D+D=正 D+C=负 C+C=正 C+D=负
-				 * 美元 判断模版借贷方向与科目借贷方向是否一致 true D+D=正 D+C=负 C+C=正 C+D=负
-				 * 借或贷金额为零时跳过本次循环
-				 * */
-				if ("CNY".equals(item.getCurrencyCode())) {
-					finVouchersItems.setExrate(new BigDecimal("1"));
-					if ("D".equals(item.getAmountDirection())) {
-						if ("D".equals(accounts.getDc())) {
-							if (new BigDecimal("0.00").compareTo(amount[count - 1]) != 0) {
-								finVouchersItems.setAmountDr(amount[count - 1]);
+				if (1 == accounts.getIsCorp() || 1 == accounts.getIsDept() || 1 == accounts.getIsEmpl()) {
+					if (0 == i || 1 == i) {
+						for (Map<Long, BigDecimal> map : mapListCD) {
+							Long key;
+							Iterator<Long> iterator = map.keySet().iterator();
+							if (iterator.hasNext()) {
+								key = iterator.next();
 							} else {
-								continue;
+								key = null;
 							}
-						} else {
-							finVouchersItems.setAmountCr(new BigDecimal("0.00").subtract(amount[count - 1]));
+							FinVouchersItems finVouchersItems = new FinVouchersItems();
+							finVouchersItems.setCreateTime(new Date());
+							finVouchersItems.setCreateUser(AuthUtil.getUserId());
+							finVouchersItems.setCreateUserName(AuthUtil.getUserName());
+							if (ObjectUtils.isNotNull(AuthUtil.getDeptId())) {
+								finVouchersItems.setCreateDept(deptId);
+								finVouchersItems.setBranchId(branchId);
+								finVouchersItems.setCreateDeptName(deptName);
+							}
+							finVouchersItems.setPid(finVouchers.getId());
+							finVouchersItems.setBillNo(finVouchers.getBillNo());
+							finVouchersItems.setVoucherSource(finVouchers.getVoucherSource());
+							finVouchersItems.setVoucherType(finVouchers.getVoucherType());
+							finVouchersItems.setVoucherNo(finVouchers.getVoucherNo());
+							finVouchersItems.setVoucherDate(finVouchers.getVoucherDate());
+							finVouchersItems.setAccountYear(finVouchers.getAccountYear());
+							finVouchersItems.setAccountMonth(finVouchers.getAccountMonth());
+							finVouchersItems.setAccountDay(finVouchers.getAccountDay());
+							finVouchersItems.setAccountId(accounts.getId());
+							finVouchersItems.setAccountCode(accounts.getCode());
+							finVouchersItems.setAccountCnName(accounts.getCnName());
+							finVouchersItems.setAccountEnName(accounts.getEnName());
+							finVouchersItems.setAccountProperty(accounts.getProperty());
+							finVouchersItems.setAccountLevel(accounts.getLevel());
+							finVouchersItems.setDc(item.getAmountDirection());
+							finVouchersItems.setCurCode(item.getCurrencyCode());
+							/*判断是否人民币,美元
+							 * 人民币 判断模版借贷方向与科目借贷方向是否一致 true D+D=正 D+C=负 C+C=正 C+D=负
+							 * 美元 判断模版借贷方向与科目借贷方向是否一致 true D+D=正 D+C=负 C+C=正 C+D=负
+							 * 借或贷金额为零时跳过本次循环
+							 * */
+							if ("CNY".equals(item.getCurrencyCode())) {
+								finVouchersItems.setExrate(new BigDecimal("1"));
+								if ("D".equals(item.getAmountDirection())) {
+									if ("D".equals(accounts.getDc())) {
+
+										if (new BigDecimal("0.00").compareTo(map.get(key)) != 0) {
+											finVouchersItems.setAmountDr(map.get(key));
+										} else {
+											continue;
+										}
+									} else {
+										finVouchersItems.setAmountCr(new BigDecimal("0.00").subtract(map.get(key)));
+									}
+								} else {
+									if ("D".equals(accounts.getDc())) {
+										finVouchersItems.setAmountDr(new BigDecimal("0.00").subtract(map.get(key)));
+									} else {
+										if (new BigDecimal("0.00").compareTo(map.get(key)) != 0) {
+											finVouchersItems.setAmountCr(map.get(key));
+										} else {
+											continue;
+										}
+									}
+								}
+							} else {
+								if ("D".equals(item.getAmountDirection())) {
+									finVouchersItems.setExrate(rateD);
+									if ("D".equals(accounts.getDc())) {
+										if (new BigDecimal("0.00").compareTo(map.get(key)) != 0) {
+											finVouchersItems.setAmountDrUsd(map.get(key));
+											finVouchersItems.setAmountDr(finVouchersItems.getAmountDrUsd().multiply(rateD));
+										} else {
+											continue;
+										}
+									} else {
+										finVouchersItems.setAmountCrUsd(new BigDecimal("0.00").subtract(map.get(key)));
+										finVouchersItems.setAmountCr(finVouchersItems.getAmountCrUsd().multiply(rateD));
+									}
+								} else {
+									finVouchersItems.setExrate(rateC);
+									if ("D".equals(accounts.getDc())) {
+										finVouchersItems.setAmountDrUsd(new BigDecimal("0.00").subtract(map.get(key)));
+										finVouchersItems.setAmountDr(finVouchersItems.getAmountDrUsd().multiply(rateC));
+									} else {
+										if (new BigDecimal("0.00").compareTo(map.get(key)) != 0) {
+											finVouchersItems.setAmountCrUsd(map.get(key));
+											finVouchersItems.setAmountCr(finVouchersItems.getAmountCrUsd().multiply(rateC));
+										} else {
+											continue;
+										}
+									}
+								}
+							}
+							//计算借,贷人民币与美金合计人民币金额
+							finVouchersItems.setAmountDrLoc(ObjectUtils.isNull(finVouchersItems.getAmountDr()) ? new BigDecimal("0") : finVouchersItems.getAmountDr()
+								.add(bCurrencyService.converterCny("USD", ObjectUtils.isNull(finVouchersItems.getAmountDrUsd()) ? new BigDecimal("0") : finVouchersItems.getAmountDrUsd(), "D", "1")));
+							finVouchersItems.setAmountCrLoc(ObjectUtils.isNull(finVouchersItems.getAmountCr()) ? new BigDecimal("0") : finVouchersItems.getAmountCr()
+								.add(bCurrencyService.converterCny("USD", ObjectUtils.isNull(finVouchersItems.getAmountCrUsd()) ? new BigDecimal("0") : finVouchersItems.getAmountCrUsd(), "C", "1")));
+							finVouchersItems.setIsCorp(accounts.getIsCorp());
+							//判断是否核算客户 true 向明细中客户字段复制
+							if (1 == finVouchersItems.getIsCorp()) {
+								BCorps bCorps = bCorpsList.stream().filter(e -> e.getId().equals(key)).findFirst().orElse(null);
+								if (bCorps != null) {
+									finVouchersItems.setCorpId(bCorps.getId());
+									finVouchersItems.setCorpCnName(bCorps.getCnName());
+									finVouchersItems.setCorpEnName(bCorps.getEnName());
+								}
+							}
+							finVouchersItems.setIsDept(accounts.getIsDept());
+							//判断是否核算部门 true 向明细中部门字段复制
+							if (1 == finVouchersItems.getIsDept()) {
+								if (dept != null) {
+									finVouchersItems.setDeptId(dept.getId());
+									finVouchersItems.setDeptName(dept.getDeptName());
+								}
+							}
+							finVouchersItems.setIsEmpl(accounts.getIsEmpl());
+							//判断是否核算职员 true 向明细中职员字段复制
+							if (1 == finVouchersItems.getIsEmpl()) {
+								if (user != null) {
+									finVouchersItems.setEmplId(user.getId());
+									finVouchersItems.setEmplName(user.getName());
+								} else {
+									if (userSrc != null) {
+										finVouchersItems.setEmplId(userSrc.getId());
+										finVouchersItems.setEmplName(userSrc.getCnName());
+									}
+								}
+							}
+							finVouchersItems.setLineNo(count);
+							StringBuilder formulasValue = new StringBuilder();
+							formulasValue.append(" ");
+							String formulasData = item.getAdditionalFormulas();
+							String[] arr = formulasData.split(",");
+							for (String l : arr) {
+								if ("corpCnName".equals(l)) {
+									BCorps bCorps = bCorpsList.stream().filter(e -> e.getId().equals(key)).findFirst().orElse(null);
+									if (bCorps != null) {
+										formulasValue.append(bCorps.getCnName()).append(" ");
+									}
+								} else {
+									if ("HYCK-DJ".equals(checkType) || "HYJK-DJ".equals(checkType)) {
+										try {
+											Field field = Bills.class.getDeclaredField(l);
+											field.setAccessible(true);
+											if (field.getType().equals(Date.class)) {
+												if (ObjectUtils.isNotNull(field.get(billsDetail))) {
+													String formattedDate = dateFormat.format(field.get(billsDetail));
+													formulasValue.append(formattedDate).append(" ");
+												}
+											} else {
+												formulasValue.append(field.get(billsDetail)).append(" ");
+											}
+										} catch (Exception e) {
+											throw new RuntimeException(e);
+										}
+									} else if ("KYCK-DJ".equals(checkType) || "KYJK-DJ".equals(checkType)) {
+										try {
+											Field field = AeaBills.class.getDeclaredField(l);
+											field.setAccessible(true);
+											if (field.getType().equals(Date.class)) {
+												if (ObjectUtils.isNotNull(field.get(aeaBillsDetail))) {
+													String formattedDate = dateFormat.format(field.get(aeaBillsDetail));
+													formulasValue.append(formattedDate).append(" ");
+												}
+											} else {
+												formulasValue.append(field.get(aeaBillsDetail)).append(" ");
+											}
+										} catch (Exception e) {
+											throw new RuntimeException(e);
+										}
+									} else if ("BGSE".equals(checkType) || "BGSI".equals(checkType) ||
+										"BGAE".equals(checkType) || "BGAI".equals(checkType)) {
+										try {
+											Field field = CustomsDeclaration.class.getDeclaredField(l);
+											field.setAccessible(true);
+											if (field.getType().equals(Date.class)) {
+												if (ObjectUtils.isNotNull(field.get(customsDeclarationDetail))) {
+													String formattedDate = dateFormat.format(field.get(customsDeclarationDetail));
+													formulasValue.append(formattedDate).append(" ");
+												}
+											} else {
+												formulasValue.append(field.get(customsDeclarationDetail)).append(" ");
+											}
+										} catch (Exception e) {
+											throw new RuntimeException(e);
+										}
+									} else if ("sea-approve".equals(checkType) || "sia-approve".equals(checkType) ||
+										"aea-approve".equals(checkType) || "aia-approve".equals(checkType)) {
+										try {
+											Field field = Amends.class.getDeclaredField(l);
+											field.setAccessible(true);
+											if (field.getType().equals(Date.class)) {
+												if (ObjectUtils.isNotNull(field.get(amendsDetail))) {
+													String formattedDate = dateFormat.format(field.get(amendsDetail));
+													formulasValue.append(formattedDate).append(" ");
+												}
+											} else {
+												formulasValue.append(field.get(amendsDetail)).append(" ");
+											}
+										} catch (Exception e) {
+											throw new RuntimeException(e);
+										}
+									}
+								}
+							}
+							finVouchersItems.setDescr(item.getStaticValue() + formulasValue);
+							finVouchersItemsList.add(finVouchersItems);
 						}
-					} else {
-						if ("D".equals(accounts.getDc())) {
-							finVouchersItems.setAmountDr(new BigDecimal("0.00").subtract(amount[count - 1]));
-						} else {
-							if (new BigDecimal("0.00").compareTo(amount[count - 1]) != 0) {
-								finVouchersItems.setAmountCr(amount[count - 1]);
+					} else if (2 == i || 3 == i) {
+						for (Map<Long, BigDecimal> map : mapListCC) {
+							Long key;
+							Iterator<Long> iterator = map.keySet().iterator();
+							if (iterator.hasNext()) {
+								key = iterator.next();
 							} else {
-								continue;
+								key = null;
+							}
+							FinVouchersItems finVouchersItems = new FinVouchersItems();
+							finVouchersItems.setCreateTime(new Date());
+							finVouchersItems.setCreateUser(AuthUtil.getUserId());
+							finVouchersItems.setCreateUserName(AuthUtil.getUserName());
+							if (ObjectUtils.isNotNull(AuthUtil.getDeptId())) {
+								finVouchersItems.setCreateDept(deptId);
+								finVouchersItems.setBranchId(branchId);
+								finVouchersItems.setCreateDeptName(deptName);
+							}
+							finVouchersItems.setPid(finVouchers.getId());
+							finVouchersItems.setBillNo(finVouchers.getBillNo());
+							finVouchersItems.setVoucherSource(finVouchers.getVoucherSource());
+							finVouchersItems.setVoucherType(finVouchers.getVoucherType());
+							finVouchersItems.setVoucherNo(finVouchers.getVoucherNo());
+							finVouchersItems.setVoucherDate(finVouchers.getVoucherDate());
+							finVouchersItems.setAccountYear(finVouchers.getAccountYear());
+							finVouchersItems.setAccountMonth(finVouchers.getAccountMonth());
+							finVouchersItems.setAccountDay(finVouchers.getAccountDay());
+							finVouchersItems.setAccountId(accounts.getId());
+							finVouchersItems.setAccountCode(accounts.getCode());
+							finVouchersItems.setAccountCnName(accounts.getCnName());
+							finVouchersItems.setAccountEnName(accounts.getEnName());
+							finVouchersItems.setAccountProperty(accounts.getProperty());
+							finVouchersItems.setAccountLevel(accounts.getLevel());
+							finVouchersItems.setDc(item.getAmountDirection());
+							finVouchersItems.setCurCode(item.getCurrencyCode());
+							/*判断是否人民币,美元
+							 * 人民币 判断模版借贷方向与科目借贷方向是否一致 true D+D=正 D+C=负 C+C=正 C+D=负
+							 * 美元 判断模版借贷方向与科目借贷方向是否一致 true D+D=正 D+C=负 C+C=正 C+D=负
+							 * 借或贷金额为零时跳过本次循环
+							 * */
+							if ("CNY".equals(item.getCurrencyCode())) {
+								finVouchersItems.setExrate(new BigDecimal("1"));
+								if ("D".equals(item.getAmountDirection())) {
+									if ("D".equals(accounts.getDc())) {
+
+										if (new BigDecimal("0.00").compareTo(map.get(key)) != 0) {
+											finVouchersItems.setAmountDr(map.get(key));
+										} else {
+											continue;
+										}
+									} else {
+										finVouchersItems.setAmountCr(new BigDecimal("0.00").subtract(map.get(key)));
+									}
+								} else {
+									if ("D".equals(accounts.getDc())) {
+										finVouchersItems.setAmountDr(new BigDecimal("0.00").subtract(map.get(key)));
+									} else {
+										if (new BigDecimal("0.00").compareTo(map.get(key)) != 0) {
+											finVouchersItems.setAmountCr(map.get(key));
+										} else {
+											continue;
+										}
+									}
+								}
+							} else {
+								if ("D".equals(item.getAmountDirection())) {
+									finVouchersItems.setExrate(rateD);
+									if ("D".equals(accounts.getDc())) {
+										if (new BigDecimal("0.00").compareTo(map.get(key)) != 0) {
+											finVouchersItems.setAmountDrUsd(map.get(key));
+											finVouchersItems.setAmountDr(finVouchersItems.getAmountDrUsd().multiply(rateD));
+										} else {
+											continue;
+										}
+									} else {
+										finVouchersItems.setAmountCrUsd(new BigDecimal("0.00").subtract(map.get(key)));
+										finVouchersItems.setAmountCr(finVouchersItems.getAmountCrUsd().multiply(rateD));
+									}
+								} else {
+									finVouchersItems.setExrate(rateC);
+									if ("D".equals(accounts.getDc())) {
+										finVouchersItems.setAmountDrUsd(new BigDecimal("0.00").subtract(map.get(key)));
+										finVouchersItems.setAmountDr(finVouchersItems.getAmountDrUsd().multiply(rateC));
+									} else {
+										if (new BigDecimal("0.00").compareTo(map.get(key)) != 0) {
+											finVouchersItems.setAmountCrUsd(map.get(key));
+											finVouchersItems.setAmountCr(finVouchersItems.getAmountCrUsd().multiply(rateC));
+										} else {
+											continue;
+										}
+									}
+								}
+							}
+							//计算借,贷人民币与美金合计人民币金额
+							finVouchersItems.setAmountDrLoc(ObjectUtils.isNull(finVouchersItems.getAmountDr()) ? new BigDecimal("0") : finVouchersItems.getAmountDr()
+								.add(bCurrencyService.converterCny("USD", ObjectUtils.isNull(finVouchersItems.getAmountDrUsd()) ? new BigDecimal("0") : finVouchersItems.getAmountDrUsd(), "D", "1")));
+							finVouchersItems.setAmountCrLoc(ObjectUtils.isNull(finVouchersItems.getAmountCr()) ? new BigDecimal("0") : finVouchersItems.getAmountCr()
+								.add(bCurrencyService.converterCny("USD", ObjectUtils.isNull(finVouchersItems.getAmountCrUsd()) ? new BigDecimal("0") : finVouchersItems.getAmountCrUsd(), "C", "1")));
+							finVouchersItems.setIsCorp(accounts.getIsCorp());
+							//判断是否核算客户 true 向明细中客户字段复制
+							if (1 == finVouchersItems.getIsCorp()) {
+								BCorps bCorps = bCorpsList.stream().filter(e -> e.getId().equals(key)).findFirst().orElse(null);
+								if (bCorps != null) {
+									finVouchersItems.setCorpId(bCorps.getId());
+									finVouchersItems.setCorpCnName(bCorps.getCnName());
+									finVouchersItems.setCorpEnName(bCorps.getEnName());
+								}
+							}
+							finVouchersItems.setIsDept(accounts.getIsDept());
+							//判断是否核算部门 true 向明细中部门字段复制
+							if (1 == finVouchersItems.getIsDept()) {
+								if (dept != null) {
+									finVouchersItems.setDeptId(dept.getId());
+									finVouchersItems.setDeptName(dept.getDeptName());
+								}
+							}
+							finVouchersItems.setIsEmpl(accounts.getIsEmpl());
+							//判断是否核算职员 true 向明细中职员字段复制
+							if (1 == finVouchersItems.getIsEmpl()) {
+								if (user != null) {
+									finVouchersItems.setEmplId(user.getId());
+									finVouchersItems.setEmplName(user.getName());
+								} else {
+									if (userSrc != null) {
+										finVouchersItems.setEmplId(userSrc.getId());
+										finVouchersItems.setEmplName(userSrc.getCnName());
+									}
+								}
+							}
+							finVouchersItems.setLineNo(count);
+							StringBuilder formulasValue = new StringBuilder();
+							formulasValue.append(" ");
+							String formulasData = item.getAdditionalFormulas();
+							String[] arr = formulasData.split(",");
+							for (String l : arr) {
+								if ("corpCnName".equals(l)) {
+									BCorps bCorps = bCorpsList.stream().filter(e -> e.getId().equals(key)).findFirst().orElse(null);
+									if (bCorps != null) {
+										formulasValue.append(bCorps.getCnName()).append(" ");
+									}
+								} else {
+									if ("HYCK-DJ".equals(checkType) || "HYJK-DJ".equals(checkType)) {
+										try {
+											Field field = Bills.class.getDeclaredField(l);
+											field.setAccessible(true);
+											if (field.getType().equals(Date.class)) {
+												if (ObjectUtils.isNotNull(field.get(billsDetail))) {
+													String formattedDate = dateFormat.format(field.get(billsDetail));
+													formulasValue.append(formattedDate).append(" ");
+												}
+											} else {
+												formulasValue.append(field.get(billsDetail)).append(" ");
+											}
+										} catch (Exception e) {
+											throw new RuntimeException(e);
+										}
+									} else if ("KYCK-DJ".equals(checkType) || "KYJK-DJ".equals(checkType)) {
+										try {
+											Field field = AeaBills.class.getDeclaredField(l);
+											field.setAccessible(true);
+											if (field.getType().equals(Date.class)) {
+												if (ObjectUtils.isNotNull(field.get(aeaBillsDetail))) {
+													String formattedDate = dateFormat.format(field.get(aeaBillsDetail));
+													formulasValue.append(formattedDate).append(" ");
+												}
+											} else {
+												formulasValue.append(field.get(aeaBillsDetail)).append(" ");
+											}
+										} catch (Exception e) {
+											throw new RuntimeException(e);
+										}
+									} else if ("BGSE".equals(checkType) || "BGSI".equals(checkType) ||
+										"BGAE".equals(checkType) || "BGAI".equals(checkType)) {
+										try {
+											Field field = CustomsDeclaration.class.getDeclaredField(l);
+											field.setAccessible(true);
+											if (field.getType().equals(Date.class)) {
+												if (ObjectUtils.isNotNull(field.get(customsDeclarationDetail))) {
+													String formattedDate = dateFormat.format(field.get(customsDeclarationDetail));
+													formulasValue.append(formattedDate).append(" ");
+												}
+											} else {
+												formulasValue.append(field.get(customsDeclarationDetail)).append(" ");
+											}
+										} catch (Exception e) {
+											throw new RuntimeException(e);
+										}
+									} else if ("sea-approve".equals(checkType) || "sia-approve".equals(checkType) ||
+										"aea-approve".equals(checkType) || "aia-approve".equals(checkType)) {
+										try {
+											Field field = Amends.class.getDeclaredField(l);
+											field.setAccessible(true);
+											if (field.getType().equals(Date.class)) {
+												if (ObjectUtils.isNotNull(field.get(amendsDetail))) {
+													String formattedDate = dateFormat.format(field.get(amendsDetail));
+													formulasValue.append(formattedDate).append(" ");
+												}
+											} else {
+												formulasValue.append(field.get(amendsDetail)).append(" ");
+											}
+										} catch (Exception e) {
+											throw new RuntimeException(e);
+										}
+									}
+								}
 							}
+							finVouchersItems.setDescr(item.getStaticValue() + formulasValue);
+							finVouchersItemsList.add(finVouchersItems);
 						}
-					}
-				} else {
-					if ("D".equals(item.getAmountDirection())) {
-						finVouchersItems.setExrate(rateD);
-						if ("D".equals(accounts.getDc())) {
-							if (new BigDecimal("0.00").compareTo(amount[count - 1]) != 0) {
-								finVouchersItems.setAmountDrUsd(amount[count - 1]);
-								finVouchersItems.setAmountDr(finVouchersItems.getAmountDrUsd().multiply(rateD));
+					} else if (4 == i || 5 == i) {
+						for (Map<Long, BigDecimal> map : mapListUD) {
+							Long key;
+							Iterator<Long> iterator = map.keySet().iterator();
+							if (iterator.hasNext()) {
+								key = iterator.next();
 							} else {
-								continue;
+								key = null;
 							}
-						} else {
-							finVouchersItems.setAmountCrUsd(new BigDecimal("0.00").subtract(amount[count - 1]));
-							finVouchersItems.setAmountCr(finVouchersItems.getAmountCrUsd().multiply(rateD));
+							FinVouchersItems finVouchersItems = new FinVouchersItems();
+							finVouchersItems.setCreateTime(new Date());
+							finVouchersItems.setCreateUser(AuthUtil.getUserId());
+							finVouchersItems.setCreateUserName(AuthUtil.getUserName());
+							if (ObjectUtils.isNotNull(AuthUtil.getDeptId())) {
+								finVouchersItems.setCreateDept(deptId);
+								finVouchersItems.setBranchId(branchId);
+								finVouchersItems.setCreateDeptName(deptName);
+							}
+							finVouchersItems.setPid(finVouchers.getId());
+							finVouchersItems.setBillNo(finVouchers.getBillNo());
+							finVouchersItems.setVoucherSource(finVouchers.getVoucherSource());
+							finVouchersItems.setVoucherType(finVouchers.getVoucherType());
+							finVouchersItems.setVoucherNo(finVouchers.getVoucherNo());
+							finVouchersItems.setVoucherDate(finVouchers.getVoucherDate());
+							finVouchersItems.setAccountYear(finVouchers.getAccountYear());
+							finVouchersItems.setAccountMonth(finVouchers.getAccountMonth());
+							finVouchersItems.setAccountDay(finVouchers.getAccountDay());
+							finVouchersItems.setAccountId(accounts.getId());
+							finVouchersItems.setAccountCode(accounts.getCode());
+							finVouchersItems.setAccountCnName(accounts.getCnName());
+							finVouchersItems.setAccountEnName(accounts.getEnName());
+							finVouchersItems.setAccountProperty(accounts.getProperty());
+							finVouchersItems.setAccountLevel(accounts.getLevel());
+							finVouchersItems.setDc(item.getAmountDirection());
+							finVouchersItems.setCurCode(item.getCurrencyCode());
+							/*判断是否人民币,美元
+							 * 人民币 判断模版借贷方向与科目借贷方向是否一致 true D+D=正 D+C=负 C+C=正 C+D=负
+							 * 美元 判断模版借贷方向与科目借贷方向是否一致 true D+D=正 D+C=负 C+C=正 C+D=负
+							 * 借或贷金额为零时跳过本次循环
+							 * */
+							if ("CNY".equals(item.getCurrencyCode())) {
+								finVouchersItems.setExrate(new BigDecimal("1"));
+								if ("D".equals(item.getAmountDirection())) {
+									if ("D".equals(accounts.getDc())) {
+
+										if (new BigDecimal("0.00").compareTo(map.get(key)) != 0) {
+											finVouchersItems.setAmountDr(map.get(key));
+										} else {
+											continue;
+										}
+									} else {
+										finVouchersItems.setAmountCr(new BigDecimal("0.00").subtract(map.get(key)));
+									}
+								} else {
+									if ("D".equals(accounts.getDc())) {
+										finVouchersItems.setAmountDr(new BigDecimal("0.00").subtract(map.get(key)));
+									} else {
+										if (new BigDecimal("0.00").compareTo(map.get(key)) != 0) {
+											finVouchersItems.setAmountCr(map.get(key));
+										} else {
+											continue;
+										}
+									}
+								}
+							} else {
+								if ("D".equals(item.getAmountDirection())) {
+									finVouchersItems.setExrate(rateD);
+									if ("D".equals(accounts.getDc())) {
+										if (new BigDecimal("0.00").compareTo(map.get(key)) != 0) {
+											finVouchersItems.setAmountDrUsd(map.get(key));
+											finVouchersItems.setAmountDr(finVouchersItems.getAmountDrUsd().multiply(rateD));
+										} else {
+											continue;
+										}
+									} else {
+										finVouchersItems.setAmountCrUsd(new BigDecimal("0.00").subtract(map.get(key)));
+										finVouchersItems.setAmountCr(finVouchersItems.getAmountCrUsd().multiply(rateD));
+									}
+								} else {
+									finVouchersItems.setExrate(rateC);
+									if ("D".equals(accounts.getDc())) {
+										finVouchersItems.setAmountDrUsd(new BigDecimal("0.00").subtract(map.get(key)));
+										finVouchersItems.setAmountDr(finVouchersItems.getAmountDrUsd().multiply(rateC));
+									} else {
+										if (new BigDecimal("0.00").compareTo(map.get(key)) != 0) {
+											finVouchersItems.setAmountCrUsd(map.get(key));
+											finVouchersItems.setAmountCr(finVouchersItems.getAmountCrUsd().multiply(rateC));
+										} else {
+											continue;
+										}
+									}
+								}
+							}
+							//计算借,贷人民币与美金合计人民币金额
+							finVouchersItems.setAmountDrLoc(ObjectUtils.isNull(finVouchersItems.getAmountDr()) ? new BigDecimal("0") : finVouchersItems.getAmountDr()
+								.add(bCurrencyService.converterCny("USD", ObjectUtils.isNull(finVouchersItems.getAmountDrUsd()) ? new BigDecimal("0") : finVouchersItems.getAmountDrUsd(), "D", "1")));
+							finVouchersItems.setAmountCrLoc(ObjectUtils.isNull(finVouchersItems.getAmountCr()) ? new BigDecimal("0") : finVouchersItems.getAmountCr()
+								.add(bCurrencyService.converterCny("USD", ObjectUtils.isNull(finVouchersItems.getAmountCrUsd()) ? new BigDecimal("0") : finVouchersItems.getAmountCrUsd(), "C", "1")));
+							finVouchersItems.setIsCorp(accounts.getIsCorp());
+							//判断是否核算客户 true 向明细中客户字段复制
+							if (1 == finVouchersItems.getIsCorp()) {
+								BCorps bCorps = bCorpsList.stream().filter(e -> e.getId().equals(key)).findFirst().orElse(null);
+								if (bCorps != null) {
+									finVouchersItems.setCorpId(bCorps.getId());
+									finVouchersItems.setCorpCnName(bCorps.getCnName());
+									finVouchersItems.setCorpEnName(bCorps.getEnName());
+								}
+							}
+							finVouchersItems.setIsDept(accounts.getIsDept());
+							//判断是否核算部门 true 向明细中部门字段复制
+							if (1 == finVouchersItems.getIsDept()) {
+								if (dept != null) {
+									finVouchersItems.setDeptId(dept.getId());
+									finVouchersItems.setDeptName(dept.getDeptName());
+								}
+							}
+							finVouchersItems.setIsEmpl(accounts.getIsEmpl());
+							//判断是否核算职员 true 向明细中职员字段复制
+							if (1 == finVouchersItems.getIsEmpl()) {
+								if (user != null) {
+									finVouchersItems.setEmplId(user.getId());
+									finVouchersItems.setEmplName(user.getName());
+								} else {
+									if (userSrc != null) {
+										finVouchersItems.setEmplId(userSrc.getId());
+										finVouchersItems.setEmplName(userSrc.getCnName());
+									}
+								}
+							}
+							finVouchersItems.setLineNo(count);
+							StringBuilder formulasValue = new StringBuilder();
+							formulasValue.append(" ");
+							String formulasData = item.getAdditionalFormulas();
+							String[] arr = formulasData.split(",");
+							for (String l : arr) {
+								if ("corpCnName".equals(l)) {
+									BCorps bCorps = bCorpsList.stream().filter(e -> e.getId().equals(key)).findFirst().orElse(null);
+									if (bCorps != null) {
+										formulasValue.append(bCorps.getCnName()).append(" ");
+									}
+								} else {
+									if ("HYCK-DJ".equals(checkType) || "HYJK-DJ".equals(checkType)) {
+										try {
+											Field field = Bills.class.getDeclaredField(l);
+											field.setAccessible(true);
+											if (field.getType().equals(Date.class)) {
+												if (ObjectUtils.isNotNull(field.get(billsDetail))) {
+													String formattedDate = dateFormat.format(field.get(billsDetail));
+													formulasValue.append(formattedDate).append(" ");
+												}
+											} else {
+												formulasValue.append(field.get(billsDetail)).append(" ");
+											}
+										} catch (Exception e) {
+											throw new RuntimeException(e);
+										}
+									} else if ("KYCK-DJ".equals(checkType) || "KYJK-DJ".equals(checkType)) {
+										try {
+											Field field = AeaBills.class.getDeclaredField(l);
+											field.setAccessible(true);
+											if (field.getType().equals(Date.class)) {
+												if (ObjectUtils.isNotNull(field.get(aeaBillsDetail))) {
+													String formattedDate = dateFormat.format(field.get(aeaBillsDetail));
+													formulasValue.append(formattedDate).append(" ");
+												}
+											} else {
+												formulasValue.append(field.get(aeaBillsDetail)).append(" ");
+											}
+										} catch (Exception e) {
+											throw new RuntimeException(e);
+										}
+									} else if ("BGSE".equals(checkType) || "BGSI".equals(checkType) ||
+										"BGAE".equals(checkType) || "BGAI".equals(checkType)) {
+										try {
+											Field field = CustomsDeclaration.class.getDeclaredField(l);
+											field.setAccessible(true);
+											if (field.getType().equals(Date.class)) {
+												if (ObjectUtils.isNotNull(field.get(customsDeclarationDetail))) {
+													String formattedDate = dateFormat.format(field.get(customsDeclarationDetail));
+													formulasValue.append(formattedDate).append(" ");
+												}
+											} else {
+												formulasValue.append(field.get(customsDeclarationDetail)).append(" ");
+											}
+										} catch (Exception e) {
+											throw new RuntimeException(e);
+										}
+									} else if ("sea-approve".equals(checkType) || "sia-approve".equals(checkType) ||
+										"aea-approve".equals(checkType) || "aia-approve".equals(checkType)) {
+										try {
+											Field field = Amends.class.getDeclaredField(l);
+											field.setAccessible(true);
+											if (field.getType().equals(Date.class)) {
+												if (ObjectUtils.isNotNull(field.get(amendsDetail))) {
+													String formattedDate = dateFormat.format(field.get(amendsDetail));
+													formulasValue.append(formattedDate).append(" ");
+												}
+											} else {
+												formulasValue.append(field.get(amendsDetail)).append(" ");
+											}
+										} catch (Exception e) {
+											throw new RuntimeException(e);
+										}
+									}
+								}
+							}
+							finVouchersItems.setDescr(item.getStaticValue() + formulasValue);
+							finVouchersItemsList.add(finVouchersItems);
 						}
-					} else {
-						finVouchersItems.setExrate(rateC);
-						if ("D".equals(accounts.getDc())) {
-							finVouchersItems.setAmountDrUsd(new BigDecimal("0.00").subtract(amount[count - 1]));
-							finVouchersItems.setAmountDr(finVouchersItems.getAmountDrUsd().multiply(rateC));
-						} else {
-							if (new BigDecimal("0.00").compareTo(amount[count - 1]) != 0) {
-								finVouchersItems.setAmountCrUsd(amount[count - 1]);
-								finVouchersItems.setAmountCr(finVouchersItems.getAmountCrUsd().multiply(rateC));
+					} else if (6 == i || 7 == i) {
+						for (Map<Long, BigDecimal> map : mapListUC) {
+							Long key;
+							Iterator<Long> iterator = map.keySet().iterator();
+							if (iterator.hasNext()) {
+								key = iterator.next();
+							} else {
+								key = null;
+							}
+							FinVouchersItems finVouchersItems = new FinVouchersItems();
+							finVouchersItems.setCreateTime(new Date());
+							finVouchersItems.setCreateUser(AuthUtil.getUserId());
+							finVouchersItems.setCreateUserName(AuthUtil.getUserName());
+							if (ObjectUtils.isNotNull(AuthUtil.getDeptId())) {
+								finVouchersItems.setCreateDept(deptId);
+								finVouchersItems.setBranchId(branchId);
+								finVouchersItems.setCreateDeptName(deptName);
+							}
+							finVouchersItems.setPid(finVouchers.getId());
+							finVouchersItems.setBillNo(finVouchers.getBillNo());
+							finVouchersItems.setVoucherSource(finVouchers.getVoucherSource());
+							finVouchersItems.setVoucherType(finVouchers.getVoucherType());
+							finVouchersItems.setVoucherNo(finVouchers.getVoucherNo());
+							finVouchersItems.setVoucherDate(finVouchers.getVoucherDate());
+							finVouchersItems.setAccountYear(finVouchers.getAccountYear());
+							finVouchersItems.setAccountMonth(finVouchers.getAccountMonth());
+							finVouchersItems.setAccountDay(finVouchers.getAccountDay());
+							finVouchersItems.setAccountId(accounts.getId());
+							finVouchersItems.setAccountCode(accounts.getCode());
+							finVouchersItems.setAccountCnName(accounts.getCnName());
+							finVouchersItems.setAccountEnName(accounts.getEnName());
+							finVouchersItems.setAccountProperty(accounts.getProperty());
+							finVouchersItems.setAccountLevel(accounts.getLevel());
+							finVouchersItems.setDc(item.getAmountDirection());
+							finVouchersItems.setCurCode(item.getCurrencyCode());
+							/*判断是否人民币,美元
+							 * 人民币 判断模版借贷方向与科目借贷方向是否一致 true D+D=正 D+C=负 C+C=正 C+D=负
+							 * 美元 判断模版借贷方向与科目借贷方向是否一致 true D+D=正 D+C=负 C+C=正 C+D=负
+							 * 借或贷金额为零时跳过本次循环
+							 * */
+							if ("CNY".equals(item.getCurrencyCode())) {
+								finVouchersItems.setExrate(new BigDecimal("1"));
+								if ("D".equals(item.getAmountDirection())) {
+									if ("D".equals(accounts.getDc())) {
+
+										if (new BigDecimal("0.00").compareTo(map.get(key)) != 0) {
+											finVouchersItems.setAmountDr(map.get(key));
+										} else {
+											continue;
+										}
+									} else {
+										finVouchersItems.setAmountCr(new BigDecimal("0.00").subtract(map.get(key)));
+									}
+								} else {
+									if ("D".equals(accounts.getDc())) {
+										finVouchersItems.setAmountDr(new BigDecimal("0.00").subtract(map.get(key)));
+									} else {
+										if (new BigDecimal("0.00").compareTo(map.get(key)) != 0) {
+											finVouchersItems.setAmountCr(map.get(key));
+										} else {
+											continue;
+										}
+									}
+								}
 							} else {
-								continue;
+								if ("D".equals(item.getAmountDirection())) {
+									finVouchersItems.setExrate(rateD);
+									if ("D".equals(accounts.getDc())) {
+										if (new BigDecimal("0.00").compareTo(map.get(key)) != 0) {
+											finVouchersItems.setAmountDrUsd(map.get(key));
+											finVouchersItems.setAmountDr(finVouchersItems.getAmountDrUsd().multiply(rateD));
+										} else {
+											continue;
+										}
+									} else {
+										finVouchersItems.setAmountCrUsd(new BigDecimal("0.00").subtract(map.get(key)));
+										finVouchersItems.setAmountCr(finVouchersItems.getAmountCrUsd().multiply(rateD));
+									}
+								} else {
+									finVouchersItems.setExrate(rateC);
+									if ("D".equals(accounts.getDc())) {
+										finVouchersItems.setAmountDrUsd(new BigDecimal("0.00").subtract(map.get(key)));
+										finVouchersItems.setAmountDr(finVouchersItems.getAmountDrUsd().multiply(rateC));
+									} else {
+										if (new BigDecimal("0.00").compareTo(map.get(key)) != 0) {
+											finVouchersItems.setAmountCrUsd(map.get(key));
+											finVouchersItems.setAmountCr(finVouchersItems.getAmountCrUsd().multiply(rateC));
+										} else {
+											continue;
+										}
+									}
+								}
+							}
+							//计算借,贷人民币与美金合计人民币金额
+							finVouchersItems.setAmountDrLoc(ObjectUtils.isNull(finVouchersItems.getAmountDr()) ? new BigDecimal("0") : finVouchersItems.getAmountDr()
+								.add(bCurrencyService.converterCny("USD", ObjectUtils.isNull(finVouchersItems.getAmountDrUsd()) ? new BigDecimal("0") : finVouchersItems.getAmountDrUsd(), "D", "1")));
+							finVouchersItems.setAmountCrLoc(ObjectUtils.isNull(finVouchersItems.getAmountCr()) ? new BigDecimal("0") : finVouchersItems.getAmountCr()
+								.add(bCurrencyService.converterCny("USD", ObjectUtils.isNull(finVouchersItems.getAmountCrUsd()) ? new BigDecimal("0") : finVouchersItems.getAmountCrUsd(), "C", "1")));
+							finVouchersItems.setIsCorp(accounts.getIsCorp());
+							//判断是否核算客户 true 向明细中客户字段复制
+							if (1 == finVouchersItems.getIsCorp()) {
+								BCorps bCorps = bCorpsList.stream().filter(e -> e.getId().equals(key)).findFirst().orElse(null);
+								if (bCorps != null) {
+									finVouchersItems.setCorpId(bCorps.getId());
+									finVouchersItems.setCorpCnName(bCorps.getCnName());
+									finVouchersItems.setCorpEnName(bCorps.getEnName());
+								}
+							}
+							finVouchersItems.setIsDept(accounts.getIsDept());
+							//判断是否核算部门 true 向明细中部门字段复制
+							if (1 == finVouchersItems.getIsDept()) {
+								if (dept != null) {
+									finVouchersItems.setDeptId(dept.getId());
+									finVouchersItems.setDeptName(dept.getDeptName());
+								}
 							}
+							finVouchersItems.setIsEmpl(accounts.getIsEmpl());
+							//判断是否核算职员 true 向明细中职员字段复制
+							if (1 == finVouchersItems.getIsEmpl()) {
+								if (user != null) {
+									finVouchersItems.setEmplId(user.getId());
+									finVouchersItems.setEmplName(user.getName());
+								} else {
+									if (userSrc != null) {
+										finVouchersItems.setEmplId(userSrc.getId());
+										finVouchersItems.setEmplName(userSrc.getCnName());
+									}
+								}
+							}
+							finVouchersItems.setLineNo(count);
+							StringBuilder formulasValue = new StringBuilder();
+							formulasValue.append(" ");
+							String formulasData = item.getAdditionalFormulas();
+							String[] arr = formulasData.split(",");
+							for (String l : arr) {
+								if ("corpCnName".equals(l)) {
+									BCorps bCorps = bCorpsList.stream().filter(e -> e.getId().equals(key)).findFirst().orElse(null);
+									if (bCorps != null) {
+										formulasValue.append(bCorps.getCnName()).append(" ");
+									}
+								} else {
+									if ("HYCK-DJ".equals(checkType) || "HYJK-DJ".equals(checkType)) {
+										try {
+											Field field = Bills.class.getDeclaredField(l);
+											field.setAccessible(true);
+											if (field.getType().equals(Date.class)) {
+												if (ObjectUtils.isNotNull(field.get(billsDetail))) {
+													String formattedDate = dateFormat.format(field.get(billsDetail));
+													formulasValue.append(formattedDate).append(" ");
+												}
+											} else {
+												formulasValue.append(field.get(billsDetail)).append(" ");
+											}
+										} catch (Exception e) {
+											throw new RuntimeException(e);
+										}
+									} else if ("KYCK-DJ".equals(checkType) || "KYJK-DJ".equals(checkType)) {
+										try {
+											Field field = AeaBills.class.getDeclaredField(l);
+											field.setAccessible(true);
+											if (field.getType().equals(Date.class)) {
+												if (ObjectUtils.isNotNull(field.get(aeaBillsDetail))) {
+													String formattedDate = dateFormat.format(field.get(aeaBillsDetail));
+													formulasValue.append(formattedDate).append(" ");
+												}
+											} else {
+												formulasValue.append(field.get(aeaBillsDetail)).append(" ");
+											}
+										} catch (Exception e) {
+											throw new RuntimeException(e);
+										}
+									} else if ("BGSE".equals(checkType) || "BGSI".equals(checkType) ||
+										"BGAE".equals(checkType) || "BGAI".equals(checkType)) {
+										try {
+											Field field = CustomsDeclaration.class.getDeclaredField(l);
+											field.setAccessible(true);
+											if (field.getType().equals(Date.class)) {
+												if (ObjectUtils.isNotNull(field.get(customsDeclarationDetail))) {
+													String formattedDate = dateFormat.format(field.get(customsDeclarationDetail));
+													formulasValue.append(formattedDate).append(" ");
+												}
+											} else {
+												formulasValue.append(field.get(customsDeclarationDetail)).append(" ");
+											}
+										} catch (Exception e) {
+											throw new RuntimeException(e);
+										}
+									} else if ("sea-approve".equals(checkType) || "sia-approve".equals(checkType) ||
+										"aea-approve".equals(checkType) || "aia-approve".equals(checkType)) {
+										try {
+											Field field = Amends.class.getDeclaredField(l);
+											field.setAccessible(true);
+											if (field.getType().equals(Date.class)) {
+												if (ObjectUtils.isNotNull(field.get(amendsDetail))) {
+													String formattedDate = dateFormat.format(field.get(amendsDetail));
+													formulasValue.append(formattedDate).append(" ");
+												}
+											} else {
+												formulasValue.append(field.get(amendsDetail)).append(" ");
+											}
+										} catch (Exception e) {
+											throw new RuntimeException(e);
+										}
+									}
+								}
+							}
+							finVouchersItems.setDescr(item.getStaticValue() + formulasValue);
+							finVouchersItemsList.add(finVouchersItems);
 						}
 					}
-				}
-				//计算借,贷人民币与美金合计人民币金额
-				finVouchersItems.setAmountDrLoc(ObjectUtils.isNull(finVouchersItems.getAmountDr()) ? new BigDecimal("0") : finVouchersItems.getAmountDr()
-					.add(bCurrencyService.converterCny("USD", ObjectUtils.isNull(finVouchersItems.getAmountDrUsd()) ? new BigDecimal("0") : finVouchersItems.getAmountDrUsd(), "D", "1")));
-				finVouchersItems.setAmountCrLoc(ObjectUtils.isNull(finVouchersItems.getAmountCr()) ? new BigDecimal("0") : finVouchersItems.getAmountCr()
-					.add(bCurrencyService.converterCny("USD", ObjectUtils.isNull(finVouchersItems.getAmountCrUsd()) ? new BigDecimal("0") : finVouchersItems.getAmountCrUsd(), "C", "1")));
-				finVouchersItems.setIsCorp(accounts.getIsCorp());
-				//判断是否核算客户 true 向明细中客户字段复制
-				if (1 == finVouchersItems.getIsCorp()) {
-					if (bCorps != null) {
-						finVouchersItems.setCorpId(bCorps.getId());
-						finVouchersItems.setCorpCnName(bCorps.getCnName());
-						finVouchersItems.setCorpEnName(bCorps.getEnName());
-					}
-				}
-				finVouchersItems.setIsDept(accounts.getIsDept());
-				//判断是否核算部门 true 向明细中部门字段复制
-				if (1 == finVouchersItems.getIsDept()) {
-					if (dept != null) {
-						finVouchersItems.setDeptId(dept.getId());
-						finVouchersItems.setDeptName(dept.getDeptName());
-					}
-				}
-				finVouchersItems.setIsEmpl(accounts.getIsEmpl());
-				//判断是否核算职员 true 向明细中职员字段复制
-				if (1 == finVouchersItems.getIsEmpl()) {
-					if (user != null) {
-						finVouchersItems.setEmplId(user.getId());
-						finVouchersItems.setEmplName(user.getName());
-					} else {
-						if (userSrc != null) {
-							finVouchersItems.setEmplId(userSrc.getId());
-							finVouchersItems.setEmplName(userSrc.getCnName());
-						}
+				} else {
+					FinVouchersItems finVouchersItems = new FinVouchersItems();
+					finVouchersItems.setCreateTime(new Date());
+					finVouchersItems.setCreateUser(AuthUtil.getUserId());
+					finVouchersItems.setCreateUserName(AuthUtil.getUserName());
+					if (ObjectUtils.isNotNull(AuthUtil.getDeptId())) {
+						finVouchersItems.setCreateDept(deptId);
+						finVouchersItems.setBranchId(branchId);
+						finVouchersItems.setCreateDeptName(deptName);
 					}
-				}
-			} else {
-				throw new RuntimeException("未找到科目信息");
-			}
-			finVouchersItems.setLineNo(count);
-			StringBuilder formulasValue = new StringBuilder();
-			formulasValue.append(" ");
-			String formulasData = item.getAdditionalFormulas();
-			String[] arr = formulasData.split(",");
-			for (String i : arr) {
-				if ("HYCK-DJ".equals(checkType) || "HYJK-DJ".equals(checkType)) {
-					try {
-						Field field = Bills.class.getDeclaredField(i);
-						field.setAccessible(true);
-						if (field.getType().equals(Date.class)) {
-							if (ObjectUtils.isNotNull(field.get(billsDetail))) {
-								String formattedDate = dateFormat.format(field.get(billsDetail));
-								formulasValue.append(formattedDate).append(" ");
+					finVouchersItems.setPid(finVouchers.getId());
+					finVouchersItems.setBillNo(finVouchers.getBillNo());
+					finVouchersItems.setVoucherSource(finVouchers.getVoucherSource());
+					finVouchersItems.setVoucherType(finVouchers.getVoucherType());
+					finVouchersItems.setVoucherNo(finVouchers.getVoucherNo());
+					finVouchersItems.setVoucherDate(finVouchers.getVoucherDate());
+					finVouchersItems.setAccountYear(finVouchers.getAccountYear());
+					finVouchersItems.setAccountMonth(finVouchers.getAccountMonth());
+					finVouchersItems.setAccountDay(finVouchers.getAccountDay());
+					finVouchersItems.setAccountId(accounts.getId());
+					finVouchersItems.setAccountCode(accounts.getCode());
+					finVouchersItems.setAccountCnName(accounts.getCnName());
+					finVouchersItems.setAccountEnName(accounts.getEnName());
+					finVouchersItems.setAccountProperty(accounts.getProperty());
+					finVouchersItems.setAccountLevel(accounts.getLevel());
+					finVouchersItems.setDc(item.getAmountDirection());
+					finVouchersItems.setCurCode(item.getCurrencyCode());
+					/*判断是否人民币,美元
+					 * 人民币 判断模版借贷方向与科目借贷方向是否一致 true D+D=正 D+C=负 C+C=正 C+D=负
+					 * 美元 判断模版借贷方向与科目借贷方向是否一致 true D+D=正 D+C=负 C+C=正 C+D=负
+					 * 借或贷金额为零时跳过本次循环
+					 * */
+					if ("CNY".equals(item.getCurrencyCode())) {
+						finVouchersItems.setExrate(new BigDecimal("1"));
+						if ("D".equals(item.getAmountDirection())) {
+							if ("D".equals(accounts.getDc())) {
+								if (new BigDecimal("0.00").compareTo(amount[count - 1]) != 0) {
+									finVouchersItems.setAmountDr(amount[count - 1]);
+								} else {
+									continue;
+								}
+							} else {
+								finVouchersItems.setAmountCr(new BigDecimal("0.00").subtract(amount[count - 1]));
 							}
 						} else {
-							formulasValue.append(field.get(billsDetail)).append(" ");
-						}
-					} catch (Exception e) {
-						throw new RuntimeException(e);
-					}
-				} else if ("KYCK-DJ".equals(checkType) || "KYJK-DJ".equals(checkType)) {
-					try {
-						Field field = AeaBills.class.getDeclaredField(i);
-						field.setAccessible(true);
-						if (field.getType().equals(Date.class)) {
-							if (ObjectUtils.isNotNull(field.get(aeaBillsDetail))) {
-								String formattedDate = dateFormat.format(field.get(aeaBillsDetail));
-								formulasValue.append(formattedDate).append(" ");
+							if ("D".equals(accounts.getDc())) {
+								finVouchersItems.setAmountDr(new BigDecimal("0.00").subtract(amount[count - 1]));
+							} else {
+								if (new BigDecimal("0.00").compareTo(amount[count - 1]) != 0) {
+									finVouchersItems.setAmountCr(amount[count - 1]);
+								} else {
+									continue;
+								}
 							}
-						} else {
-							formulasValue.append(field.get(aeaBillsDetail)).append(" ");
 						}
-					} catch (Exception e) {
-						throw new RuntimeException(e);
-					}
-				} else if ("BGSE".equals(checkType) || "BGSI".equals(checkType) ||
-					"BGAE".equals(checkType) || "BGAI".equals(checkType)) {
-					try {
-						Field field = CustomsDeclaration.class.getDeclaredField(i);
-						field.setAccessible(true);
-						if (field.getType().equals(Date.class)) {
-							if (ObjectUtils.isNotNull(field.get(customsDeclarationDetail))) {
-								String formattedDate = dateFormat.format(field.get(customsDeclarationDetail));
-								formulasValue.append(formattedDate).append(" ");
+					} else {
+						if ("D".equals(item.getAmountDirection())) {
+							finVouchersItems.setExrate(rateD);
+							if ("D".equals(accounts.getDc())) {
+								if (new BigDecimal("0.00").compareTo(amount[count - 1]) != 0) {
+									finVouchersItems.setAmountDrUsd(amount[count - 1]);
+									finVouchersItems.setAmountDr(finVouchersItems.getAmountDrUsd().multiply(rateD));
+								} else {
+									continue;
+								}
+							} else {
+								finVouchersItems.setAmountCrUsd(new BigDecimal("0.00").subtract(amount[count - 1]));
+								finVouchersItems.setAmountCr(finVouchersItems.getAmountCrUsd().multiply(rateD));
 							}
 						} else {
-							formulasValue.append(field.get(customsDeclarationDetail)).append(" ");
+							finVouchersItems.setExrate(rateC);
+							if ("D".equals(accounts.getDc())) {
+								finVouchersItems.setAmountDrUsd(new BigDecimal("0.00").subtract(amount[count - 1]));
+								finVouchersItems.setAmountDr(finVouchersItems.getAmountDrUsd().multiply(rateC));
+							} else {
+								if (new BigDecimal("0.00").compareTo(amount[count - 1]) != 0) {
+									finVouchersItems.setAmountCrUsd(amount[count - 1]);
+									finVouchersItems.setAmountCr(finVouchersItems.getAmountCrUsd().multiply(rateC));
+								} else {
+									continue;
+								}
+							}
 						}
-					} catch (Exception e) {
-						throw new RuntimeException(e);
 					}
-				} else if ("sea-approve".equals(checkType) || "sia-approve".equals(checkType) ||
-					"aea-approve".equals(checkType) || "aia-approve".equals(checkType)) {
-					try {
-						Field field = Amends.class.getDeclaredField(i);
-						field.setAccessible(true);
-						if (field.getType().equals(Date.class)) {
-							if (ObjectUtils.isNotNull(field.get(amendsDetail))) {
-								String formattedDate = dateFormat.format(field.get(amendsDetail));
-								formulasValue.append(formattedDate).append(" ");
+					//计算借,贷人民币与美金合计人民币金额
+					finVouchersItems.setAmountDrLoc(ObjectUtils.isNull(finVouchersItems.getAmountDr()) ? new BigDecimal("0") : finVouchersItems.getAmountDr()
+						.add(bCurrencyService.converterCny("USD", ObjectUtils.isNull(finVouchersItems.getAmountDrUsd()) ? new BigDecimal("0") : finVouchersItems.getAmountDrUsd(), "D", "1")));
+					finVouchersItems.setAmountCrLoc(ObjectUtils.isNull(finVouchersItems.getAmountCr()) ? new BigDecimal("0") : finVouchersItems.getAmountCr()
+						.add(bCurrencyService.converterCny("USD", ObjectUtils.isNull(finVouchersItems.getAmountCrUsd()) ? new BigDecimal("0") : finVouchersItems.getAmountCrUsd(), "C", "1")));
+					finVouchersItems.setIsCorp(accounts.getIsCorp());
+					finVouchersItems.setLineNo(count);
+					StringBuilder formulasValue = new StringBuilder();
+					formulasValue.append(" ");
+					String formulasData = item.getAdditionalFormulas();
+					String[] arr = formulasData.split(",");
+					for (String l : arr) {
+						if ("HYCK-DJ".equals(checkType) || "HYJK-DJ".equals(checkType)) {
+							try {
+								Field field = Bills.class.getDeclaredField(l);
+								field.setAccessible(true);
+								if (field.getType().equals(Date.class)) {
+									if (ObjectUtils.isNotNull(field.get(billsDetail))) {
+										String formattedDate = dateFormat.format(field.get(billsDetail));
+										formulasValue.append(formattedDate).append(" ");
+									}
+								} else {
+									formulasValue.append(field.get(billsDetail)).append(" ");
+								}
+							} catch (Exception e) {
+								throw new RuntimeException(e);
+							}
+						} else if ("KYCK-DJ".equals(checkType) || "KYJK-DJ".equals(checkType)) {
+							try {
+								Field field = AeaBills.class.getDeclaredField(l);
+								field.setAccessible(true);
+								if (field.getType().equals(Date.class)) {
+									if (ObjectUtils.isNotNull(field.get(aeaBillsDetail))) {
+										String formattedDate = dateFormat.format(field.get(aeaBillsDetail));
+										formulasValue.append(formattedDate).append(" ");
+									}
+								} else {
+									formulasValue.append(field.get(aeaBillsDetail)).append(" ");
+								}
+							} catch (Exception e) {
+								throw new RuntimeException(e);
+							}
+						} else if ("BGSE".equals(checkType) || "BGSI".equals(checkType) ||
+							"BGAE".equals(checkType) || "BGAI".equals(checkType)) {
+							try {
+								Field field = CustomsDeclaration.class.getDeclaredField(l);
+								field.setAccessible(true);
+								if (field.getType().equals(Date.class)) {
+									if (ObjectUtils.isNotNull(field.get(customsDeclarationDetail))) {
+										String formattedDate = dateFormat.format(field.get(customsDeclarationDetail));
+										formulasValue.append(formattedDate).append(" ");
+									}
+								} else {
+									formulasValue.append(field.get(customsDeclarationDetail)).append(" ");
+								}
+							} catch (Exception e) {
+								throw new RuntimeException(e);
+							}
+						} else if ("sea-approve".equals(checkType) || "sia-approve".equals(checkType) ||
+							"aea-approve".equals(checkType) || "aia-approve".equals(checkType)) {
+							try {
+								Field field = Amends.class.getDeclaredField(l);
+								field.setAccessible(true);
+								if (field.getType().equals(Date.class)) {
+									if (ObjectUtils.isNotNull(field.get(amendsDetail))) {
+										String formattedDate = dateFormat.format(field.get(amendsDetail));
+										formulasValue.append(formattedDate).append(" ");
+									}
+								} else {
+									formulasValue.append(field.get(amendsDetail)).append(" ");
+								}
+							} catch (Exception e) {
+								throw new RuntimeException(e);
 							}
-						} else {
-							formulasValue.append(field.get(amendsDetail)).append(" ");
 						}
-					} catch (Exception e) {
-						throw new RuntimeException(e);
 					}
+					finVouchersItems.setDescr(item.getStaticValue() + formulasValue);
+					finVouchersItemsList.add(finVouchersItems);
 				}
+			} else {
+				throw new RuntimeException("未找到科目信息");
 			}
-			finVouchersItems.setDescr(item.getStaticValue() + formulasValue);
-			finVouchersItemsList.add(finVouchersItems);
 		}
+
 		finVouchersItemsService.saveOrUpdateBatch(finVouchersItemsList);
 		BigDecimal amountDrCNY = new BigDecimal("0.00");
 		BigDecimal amountCrCNY = new BigDecimal("0.00");
 		BigDecimal amountDrUSD = new BigDecimal("0.00");
 		BigDecimal amountCrUSD = new BigDecimal("0.00");
-		amountDrCNY = amountDrCNY.add(finVouchersItemsList.stream()
-			.filter(e -> "CNY".equals(e.getCurCode()) && "D".equals(e.getDc())).map(FinVouchersItems::getAmountDr)
-			.filter(ObjectUtils::isNotNull).reduce(BigDecimal.ZERO, BigDecimal::add));
+		amountDrCNY = amountDrCNY.add(finVouchersItemsList.stream().filter(e -> "CNY".equals(e.getCurCode())
+				&& "D".equals(e.getDc())).map(FinVouchersItems::getAmountDr).filter(ObjectUtils::isNotNull).reduce(BigDecimal.ZERO, BigDecimal::add));
 		finVouchers.setAmountDr(amountDrCNY);
-		amountCrCNY = amountCrCNY.add(finVouchersItemsList.stream()
-			.filter(e -> "CNY".equals(e.getCurCode()) && "C".equals(e.getDc())).map(FinVouchersItems::getAmountCr)
-			.filter(ObjectUtils::isNotNull).reduce(BigDecimal.ZERO, BigDecimal::add));
+		amountCrCNY = amountCrCNY.add(finVouchersItemsList.stream().filter(e -> "CNY".equals(e.getCurCode())
+				&& "C".equals(e.getDc())).map(FinVouchersItems::getAmountCr).filter(ObjectUtils::isNotNull).reduce(BigDecimal.ZERO, BigDecimal::add));
 		finVouchers.setAmountCr(amountCrCNY);
-		amountDrUSD = amountDrUSD.add(finVouchersItemsList.stream()
-			.filter(e -> "USD".equals(e.getCurCode()) && "D".equals(e.getDc())).map(FinVouchersItems::getAmountDrUsd)
-			.filter(ObjectUtils::isNotNull).reduce(BigDecimal.ZERO, BigDecimal::add));
+		amountDrUSD = amountDrUSD.add(finVouchersItemsList.stream().filter(e -> "USD".equals(e.getCurCode())
+					&& "D".equals(e.getDc())).map(FinVouchersItems::getAmountDrUsd).filter(ObjectUtils::isNotNull).reduce(BigDecimal.ZERO, BigDecimal::add));
 		finVouchers.setAmountDrUsd(amountDrUSD);
-		amountCrUSD = amountCrUSD.add(finVouchersItemsList.stream()
-			.filter(e -> "USD".equals(e.getCurCode()) && "C".equals(e.getDc())).map(FinVouchersItems::getAmountCrUsd)
-			.filter(ObjectUtils::isNotNull).reduce(BigDecimal.ZERO, BigDecimal::add));
+		amountCrUSD = amountCrUSD.add(finVouchersItemsList.stream().filter(e -> "USD".equals(e.getCurCode())
+					&& "C".equals(e.getDc())).map(FinVouchersItems::getAmountCrUsd).filter(ObjectUtils::isNotNull).reduce(BigDecimal.ZERO, BigDecimal::add));
 		finVouchers.setAmountCrUsd(amountCrUSD);
 		finVouchers.setAmountDrLoc(amountDrCNY.add(bCurrencyService.converterCny("USD", amountDrUSD, "D", "1")));
 		finVouchers.setAmountCrLoc(amountCrCNY.add(bCurrencyService.converterCny("USD", amountCrUSD, "C", "1")));

+ 9 - 167
blade-service/blade-los/src/main/java/org/springblade/los/finance/genleg/service/impl/FinGenlegCalcServiceImpl.java

@@ -448,7 +448,7 @@ public class FinGenlegCalcServiceImpl extends ServiceImpl<FinGenlegCalcMapper, F
 				}
 			}
 		}
-		return calcListList;
+		return calcListList.stream().filter(e-> ObjectUtils.isNotNull(e.getCname())).collect(Collectors.toList());
 	}
 
 	@Override
@@ -499,6 +499,7 @@ public class FinGenlegCalcServiceImpl extends ServiceImpl<FinGenlegCalcMapper, F
 		List<FinGenlegCalc> finGenlegList = baseMapper.selectList(genlegLambdaQueryWrapper);
 		LambdaQueryWrapper<FinVouchersItems> lambdaQueryWrapper = new LambdaQueryWrapper<>();
 		lambdaQueryWrapper.eq(FinVouchersItems::getIsDeleted, 0)
+			.eq(FinVouchersItems::getStatus, 1)
 			.eq(FinVouchersItems::getTenantId, AuthUtil.getTenantId())
 			.eq(FinVouchersItems::getBranchId, deptUtils.getDeptPid())
 			.ge(ObjectUtils.isNotNull(startYear), FinVouchersItems::getAccountYear, startYear)
@@ -540,7 +541,7 @@ public class FinGenlegCalcServiceImpl extends ServiceImpl<FinGenlegCalcMapper, F
 
 		for (FinGenlegCalc item : finGenlegCalcList) {
 			AccountsDetail accountsDetail = new AccountsDetail();
-			accountsDetail.setVoucherDate(item.getAccyear() + "-" + item.getAccmonth() + "-01");
+			accountsDetail.setVoucherDate(item.getAccyear() + "-" + item.getAccmonth());
 			accountsDetail.setDescr("上期余额");
 			item.setAmountLastBlc(finGenlegList.stream().map(FinGenlegCalc::getAmountLastBlc).reduce(BigDecimal.ZERO,BigDecimal::add));
 			item.setAmountDr(finGenlegList.stream().map(FinGenlegCalc::getAmountDr).reduce(BigDecimal.ZERO,BigDecimal::add));
@@ -556,23 +557,23 @@ public class FinGenlegCalcServiceImpl extends ServiceImpl<FinGenlegCalcMapper, F
 			item.setAmountUsdBlc(finGenlegList.stream().map(FinGenlegCalc::getAmountUsdBlc).reduce(BigDecimal.ZERO,BigDecimal::add));
 			if ("D".equals(item.getDc())) {
 				if (new BigDecimal("0.00").compareTo(item.getAmountBlc()) < 0) {
-					accountsDetail.setDc("");
+					accountsDetail.setDc("");
 				} else if (new BigDecimal("0.00").compareTo(item.getAmountBlc()) == 0) {
 					accountsDetail.setDc("平");
 				} else {
-					accountsDetail.setDc("");
+					accountsDetail.setDc("");
 				}
 			} else {
 				if (new BigDecimal("0.00").compareTo(item.getAmountBlc()) < 0) {
-					accountsDetail.setDc("");
+					accountsDetail.setDc("");
 				} else if (new BigDecimal("0.00").compareTo(item.getAmountBlc()) == 0) {
 					accountsDetail.setDc("平");
 				} else {
-					accountsDetail.setDc("");
+					accountsDetail.setDc("");
 				}
 			}
-			accountsDetail.setAmountBlc(item.getAmountBlc());
-			accountsDetail.setAmountUsdBlc(item.getAmountUsdBlc());
+			accountsDetail.setAmountBlc(item.getAmountLastBlc());
+			accountsDetail.setAmountUsdBlc(item.getAmountLastBlcUsd());
 			accountsDetailList.add(accountsDetail);
 			/*
 			 * 判断是否是一级数据 true 按正常客户、部门、职员查询数据
@@ -588,165 +589,6 @@ public class FinGenlegCalcServiceImpl extends ServiceImpl<FinGenlegCalcMapper, F
 					finVouchersItems = finVouchersItemsList.stream()
 						.filter(e -> e.getCorpId().equals(item.getCorpId()) && e.getAccountYear().equals(item.getAccyear())
 							&& e.getAccountMonth().equals(item.getAccmonth())).collect(Collectors.toList());
-					/*for (FinVouchersItems vouchersItems : finVouchersItems) {
-						AccountsDetail detail = new AccountsDetail();
-						detail.setVoucherDate(vouchersItems.getAccountYear() + "-" + vouchersItems.getAccountMonth() + vouchersItems.getAccountDay());
-						detail.setVoucherNo(vouchersItems.getVoucherNo());
-						if (ObjectUtils.isNotNull(vouchersItems.getCorpCnName())) {
-							vouchersItems.setDescr(vouchersItems.getDescr() + "-" + vouchersItems.getCorpCnName());
-						}
-						detail.setDescr(vouchersItems.getDescr());
-						detail.setAmountDr(vouchersItems.getAmountDr());
-						detail.setAmountDrUsd(vouchersItems.getAmountDrUsd());
-						detail.setAmountCr(vouchersItems.getAmountCr());
-						detail.setAmountCrUsd(vouchersItems.getAmountCrUsd());
-						if ("D".equals(vouchersItems.getDc())) {
-							BigDecimal amountBlcNew = amountBlc.add(vouchersItems.getAmountDr()).subtract(vouchersItems.getAmountCr());
-							BigDecimal amountUsdNew = amountUsdBlc.add(vouchersItems.getAmountDrUsd()).subtract(vouchersItems.getAmountCrUsd());
-							detail.setAmountBlc(amountBlcNew);
-							detail.setAmountUsdBlc(amountUsdNew);
-							if (new BigDecimal("0.00").compareTo(amountBlcNew) < 0) {
-								detail.setDc("贷");
-							} else if (new BigDecimal("0.00").compareTo(amountBlcNew) == 0) {
-								detail.setDc("平");
-							} else {
-								detail.setDc("借");
-							}
-						} else {
-							BigDecimal amountBlcNew = amountBlc.subtract(vouchersItems.getAmountDr()).add(vouchersItems.getAmountCr());
-							BigDecimal amountUsdNew = amountUsdBlc.subtract(vouchersItems.getAmountDrUsd()).add(vouchersItems.getAmountCrUsd());
-							detail.setAmountBlc(amountBlcNew);
-							detail.setAmountUsdBlc(amountUsdNew);
-							if (new BigDecimal("0.00").compareTo(amountBlcNew) < 0) {
-								detail.setDc("借");
-							} else if (new BigDecimal("0.00").compareTo(amountBlcNew) == 0) {
-								detail.setDc("平");
-							} else {
-								detail.setDc("贷");
-							}
-						}
-						accountsDetailList.add(detail);
-					}
-					if (1 == finGenlegCalcVO.getDoNotDisplayYear()) {
-						if (!finVouchersItems.isEmpty()) {
-							AccountsDetail accountsDetailSum = new AccountsDetail();
-							accountsDetailSum.setVoucherDate(item.getAccyear() + "-" + item.getAccmonth());
-							accountsDetailSum.setDescr("本期合计");
-							accountsDetailSum.setAmountDr(item.getAmountDr());
-							accountsDetailSum.setAmountCr(item.getAmountCr());
-							accountsDetailSum.setAmountDrUsd(item.getAmountDrUsd());
-							accountsDetailSum.setAmountCrUsd(item.getAmountCrUsd());
-							if ("D".equals(item.getDc())) {
-								if (new BigDecimal("0.00").compareTo(item.getAmountBlc()) < 0) {
-									accountsDetailSum.setDc("贷");
-								} else if (new BigDecimal("0.00").compareTo(item.getAmountBlc()) == 0) {
-									accountsDetailSum.setDc("平");
-								} else {
-									accountsDetailSum.setDc("借");
-								}
-							} else {
-								if (new BigDecimal("0.00").compareTo(item.getAmountBlc()) < 0) {
-									accountsDetailSum.setDc("借");
-								} else if (new BigDecimal("0.00").compareTo(item.getAmountBlc()) == 0) {
-									accountsDetailSum.setDc("平");
-								} else {
-									accountsDetailSum.setDc("贷");
-								}
-							}
-							accountsDetailSum.setAmountBlc(item.getAmountBlc());
-							accountsDetailSum.setAmountUsdBlc(item.getAmountUsdBlc());
-							accountsDetailList.add(accountsDetailSum);
-
-							AccountsDetail accountsDetailYearSum = new AccountsDetail();
-							accountsDetailYearSum.setVoucherDate(item.getAccyear() + "-" + item.getAccmonth());
-							accountsDetailYearSum.setDescr("本年累计");
-							accountsDetailYearSum.setAmountDr(item.getAmountYearDr());
-							accountsDetailYearSum.setAmountCr(item.getAmountYearCr());
-							accountsDetailYearSum.setAmountDrUsd(item.getAmountYearDrUsd());
-							accountsDetailYearSum.setAmountCrUsd(item.getAmountYearCrUsd());
-							BigDecimal amount = item.getAmountYearDr().subtract(item.getAmountYearCr());
-							BigDecimal amountUsd = item.getAmountYearDrUsd().subtract(item.getAmountYearCrUsd());
-							if ("D".equals(item.getDc())) {
-								if (new BigDecimal("0.00").compareTo(amount) < 0) {
-									accountsDetailYearSum.setDc("贷");
-								} else if (new BigDecimal("0.00").compareTo(amount) == 0) {
-									accountsDetailYearSum.setDc("平");
-								} else {
-									accountsDetailYearSum.setDc("借");
-								}
-							} else {
-								if (new BigDecimal("0.00").compareTo(amount) < 0) {
-									accountsDetailYearSum.setDc("借");
-								} else if (new BigDecimal("0.00").compareTo(amount) == 0) {
-									accountsDetailYearSum.setDc("平");
-								} else {
-									accountsDetailYearSum.setDc("贷");
-								}
-							}
-							accountsDetailYearSum.setAmountBlc(amount);
-							accountsDetailYearSum.setAmountUsdBlc(amountUsd);
-							accountsDetailList.add(accountsDetailYearSum);
-						}
-					}
-					else {
-						AccountsDetail accountsDetailSum = new AccountsDetail();
-						accountsDetailSum.setVoucherDate(item.getAccyear() + "-" + item.getAccmonth());
-						accountsDetailSum.setDescr("本期合计");
-						accountsDetailSum.setAmountDr(item.getAmountDr());
-						accountsDetailSum.setAmountCr(item.getAmountCr());
-						accountsDetailSum.setAmountDrUsd(item.getAmountDrUsd());
-						accountsDetailSum.setAmountCrUsd(item.getAmountCrUsd());
-						if ("D".equals(item.getDc())) {
-							if (new BigDecimal("0.00").compareTo(item.getAmountBlc()) < 0) {
-								accountsDetailSum.setDc("贷");
-							} else if (new BigDecimal("0.00").compareTo(item.getAmountBlc()) == 0) {
-								accountsDetailSum.setDc("平");
-							} else {
-								accountsDetailSum.setDc("借");
-							}
-						} else {
-							if (new BigDecimal("0.00").compareTo(item.getAmountBlc()) < 0) {
-								accountsDetailSum.setDc("借");
-							} else if (new BigDecimal("0.00").compareTo(item.getAmountBlc()) == 0) {
-								accountsDetailSum.setDc("平");
-							} else {
-								accountsDetailSum.setDc("贷");
-							}
-						}
-						accountsDetailSum.setAmountBlc(item.getAmountBlc());
-						accountsDetailSum.setAmountUsdBlc(item.getAmountUsdBlc());
-						accountsDetailList.add(accountsDetailSum);
-
-						AccountsDetail accountsDetailYearSum = new AccountsDetail();
-						accountsDetailYearSum.setVoucherDate(item.getAccyear() + "-" + item.getAccmonth());
-						accountsDetailYearSum.setDescr("本年累计");
-						accountsDetailYearSum.setAmountDr(item.getAmountYearDr());
-						accountsDetailYearSum.setAmountCr(item.getAmountYearCr());
-						accountsDetailYearSum.setAmountDrUsd(item.getAmountYearDrUsd());
-						accountsDetailYearSum.setAmountCrUsd(item.getAmountYearCrUsd());
-						BigDecimal amount = item.getAmountYearDr().subtract(item.getAmountYearCr());
-						BigDecimal amountUsd = item.getAmountYearDrUsd().subtract(item.getAmountYearCrUsd());
-						if ("D".equals(item.getDc())) {
-							if (new BigDecimal("0.00").compareTo(amount) < 0) {
-								accountsDetailYearSum.setDc("贷");
-							} else if (new BigDecimal("0.00").compareTo(amount) == 0) {
-								accountsDetailYearSum.setDc("平");
-							} else {
-								accountsDetailYearSum.setDc("借");
-							}
-						} else {
-							if (new BigDecimal("0.00").compareTo(amount) < 0) {
-								accountsDetailYearSum.setDc("借");
-							} else if (new BigDecimal("0.00").compareTo(amount) == 0) {
-								accountsDetailYearSum.setDc("平");
-							} else {
-								accountsDetailYearSum.setDc("贷");
-							}
-						}
-						accountsDetailYearSum.setAmountBlc(amount);
-						accountsDetailYearSum.setAmountUsdBlc(amountUsd);
-						accountsDetailList.add(accountsDetailYearSum);
-					}*/
 				} else if (2 == finGenlegCalcVO.getType()) {
 					//通过部门id查询
 					finVouchersItems = finVouchersItemsList.stream()

+ 31 - 23
blade-service/blade-los/src/main/java/org/springblade/los/finance/genleg/service/impl/FinGenlegServiceImpl.java

@@ -559,6 +559,7 @@ public class FinGenlegServiceImpl extends ServiceImpl<FinGenlegMapper, FinGenleg
 		if ("1".equals(type)) {
 			lambdaQueryWrapper.eq(FinGenleg::getLevel, 1);
 		}
+		lambdaQueryWrapper.orderByAsc(FinGenleg::getAccCode);
 		List<FinGenleg> finGenlegList = baseMapper.selectList(lambdaQueryWrapper);
 		List<FinGenlegReport> finGenlegReportList = new ArrayList<>();
 		for (FinGenleg item : finGenlegList) {
@@ -567,9 +568,16 @@ public class FinGenlegServiceImpl extends ServiceImpl<FinGenlegMapper, FinGenleg
 			finGenlegReport.setDate(date);
 			finGenlegReportList.add(finGenlegReport);
 		}
-		map.put("dept", dept);
-		map.put("data", finGenlegReportList);
-		return R.data(map);
+		for (FinGenlegReport item : finGenlegReportList) {
+			FinGenlegReport finGenlegReport = new FinGenlegReport();
+			BeanUtil.copyProperties(item, finGenlegReport);
+			finGenlegReport.setDate(date);
+			map.put("gl_"+item.getAccCode(), finGenlegReport);
+		}
+		Map<String, Object> sortedMap = new TreeMap<>(String.CASE_INSENSITIVE_ORDER);
+		sortedMap.putAll(map);
+		sortedMap.put("dept", dept);
+		return R.data(sortedMap);
 	}
 
 	private List<FinGenlegDTO> assemblyData(List<FinGenlegDTO> finGenlegDTOList, List<FinGenleg> finGenlegVOList, FinGenlegVO finGenleg) {
@@ -638,20 +646,20 @@ public class FinGenlegServiceImpl extends ServiceImpl<FinGenlegMapper, FinGenleg
 				if ("D".equals(item.getDc())) {
 					BigDecimal amount = item.getAmountLastBlc().add(item.getAmountDr()).subtract(item.getAmountCr());
 					if (new BigDecimal("0").compareTo(amount) < 0) {
-						genlegThisPeriod.setDc("");
+						genlegThisPeriod.setDc("");
 					} else if (new BigDecimal("0").compareTo(amount) == 0) {
 						genlegThisPeriod.setDc("平");
 					} else {
-						genlegThisPeriod.setDc("");
+						genlegThisPeriod.setDc("");
 					}
 				} else {
 					BigDecimal amount = item.getAmountLastBlc().add(item.getAmountCr()).subtract(item.getAmountDr());
 					if (new BigDecimal("0").compareTo(amount) < 0) {
-						genlegThisPeriod.setDc("");
+						genlegThisPeriod.setDc("");
 					} else if (new BigDecimal("0").compareTo(amount) == 0) {
 						genlegThisPeriod.setDc("平");
 					} else {
-						genlegThisPeriod.setDc("");
+						genlegThisPeriod.setDc("");
 					}
 				}
 				finGenlegDTOList.add(genlegThisPeriod);
@@ -672,20 +680,20 @@ public class FinGenlegServiceImpl extends ServiceImpl<FinGenlegMapper, FinGenleg
 				if ("D".equals(item.getDc())) {
 					BigDecimal amount = item.getAmountLastBlc().add(item.getAmountYearDr()).subtract(item.getAmountYearCr());
 					if (new BigDecimal("0").compareTo(amount) < 0) {
-						genlegThisYear.setDc("");
+						genlegThisYear.setDc("");
 					} else if (new BigDecimal("0").compareTo(amount) == 0) {
 						genlegThisYear.setDc("平");
 					} else {
-						genlegThisYear.setDc("");
+						genlegThisYear.setDc("");
 					}
 				} else {
 					BigDecimal amount = item.getAmountLastBlc().add(item.getAmountYearCr()).subtract(item.getAmountYearDr());
 					if (new BigDecimal("0").compareTo(amount) < 0) {
-						genlegThisYear.setDc("");
+						genlegThisYear.setDc("");
 					} else if (new BigDecimal("0").compareTo(amount) == 0) {
 						genlegThisYear.setDc("平");
 					} else {
-						genlegThisYear.setDc("");
+						genlegThisYear.setDc("");
 					}
 				}
 				finGenlegDTOList.add(genlegThisYear);
@@ -706,19 +714,19 @@ public class FinGenlegServiceImpl extends ServiceImpl<FinGenlegMapper, FinGenleg
 					finGenlegLastCalc.setDescr("上期余额");
 					if ("D".equals(calc.getDc())) {
 						if (new BigDecimal("0").compareTo(calc.getAmountLastBlc()) < 0) {
-							finGenlegLastCalc.setDc("");
+							finGenlegLastCalc.setDc("");
 						} else if (new BigDecimal("0").compareTo(calc.getAmountLastBlc()) == 0) {
 							finGenlegLastCalc.setDc("平");
 						} else {
-							finGenlegLastCalc.setDc("");
+							finGenlegLastCalc.setDc("");
 						}
 					} else {
 						if (new BigDecimal("0").compareTo(calc.getAmountLastBlc()) < 0) {
-							finGenlegLastCalc.setDc("");
+							finGenlegLastCalc.setDc("");
 						} else if (new BigDecimal("0").compareTo(calc.getAmountLastBlc()) == 0) {
 							finGenlegLastCalc.setDc("平");
 						} else {
-							finGenlegLastCalc.setDc("");
+							finGenlegLastCalc.setDc("");
 						}
 					}
 					finGenlegDTOList.add(finGenlegLastCalc);
@@ -749,20 +757,20 @@ public class FinGenlegServiceImpl extends ServiceImpl<FinGenlegMapper, FinGenleg
 						if ("D".equals(calc.getDc())) {
 							BigDecimal amount = calc.getAmountLastBlc().add(calc.getAmountDr()).subtract(calc.getAmountCr());
 							if (new BigDecimal("0").compareTo(amount) < 0) {
-								genlegThisPeriod.setDc("");
+								genlegThisPeriod.setDc("");
 							} else if (new BigDecimal("0").compareTo(amount) == 0) {
 								genlegThisPeriod.setDc("平");
 							} else {
-								genlegThisPeriod.setDc("");
+								genlegThisPeriod.setDc("");
 							}
 						} else {
 							BigDecimal amount = calc.getAmountLastBlc().add(calc.getAmountCr()).subtract(calc.getAmountDr());
 							if (new BigDecimal("0").compareTo(amount) < 0) {
-								genlegThisPeriod.setDc("");
+								genlegThisPeriod.setDc("");
 							} else if (new BigDecimal("0").compareTo(amount) == 0) {
 								genlegThisPeriod.setDc("平");
 							} else {
-								genlegThisPeriod.setDc("");
+								genlegThisPeriod.setDc("");
 							}
 						}
 						finGenlegDTOList.add(genlegThisPeriod);
@@ -783,20 +791,20 @@ public class FinGenlegServiceImpl extends ServiceImpl<FinGenlegMapper, FinGenleg
 						if ("D".equals(calc.getDc())) {
 							BigDecimal amount = calc.getAmountLastBlc().add(calc.getAmountYearDr()).subtract(calc.getAmountYearCr());
 							if (new BigDecimal("0").compareTo(amount) < 0) {
-								genlegThisYear.setDc("");
+								genlegThisYear.setDc("");
 							} else if (new BigDecimal("0").compareTo(amount) == 0) {
 								genlegThisYear.setDc("平");
 							} else {
-								genlegThisYear.setDc("");
+								genlegThisYear.setDc("");
 							}
 						} else {
 							BigDecimal amount = calc.getAmountLastBlc().add(calc.getAmountYearCr()).subtract(calc.getAmountYearDr());
 							if (new BigDecimal("0").compareTo(amount) < 0) {
-								genlegThisYear.setDc("");
+								genlegThisYear.setDc("");
 							} else if (new BigDecimal("0").compareTo(amount) == 0) {
 								genlegThisYear.setDc("平");
 							} else {
-								genlegThisYear.setDc("");
+								genlegThisYear.setDc("");
 							}
 						}
 						finGenlegDTOList.add(genlegThisYear);

Rozdílová data souboru nebyla zobrazena, protože soubor je příliš velký
+ 1048 - 23
blade-service/blade-los/src/main/java/org/springblade/los/finance/stl/service/impl/FinStlBillsServiceImpl.java


+ 11 - 0
blade-service/blade-los/src/main/java/org/springblade/los/finance/vouchers/controller/FinVouchersController.java

@@ -64,6 +64,17 @@ public class FinVouchersController extends BladeController {
 	}
 
 	/**
+	 * 详情
+	 */
+	@GetMapping("/detailByVoucherNo")
+	@ApiOperationSupport(order = 1)
+	@ApiOperation(value = "详情", notes = "传入finVouchers")
+	public R<FinVouchers> detailByVoucherNo(FinVouchers finVouchers) {
+		FinVouchers detail = finVouchersService.detailByVoucherNo(finVouchers);
+		return R.data(detail);
+	}
+
+	/**
 	 * 分页 业务-财务凭证
 	 */
 	@GetMapping("/list")

+ 2 - 0
blade-service/blade-los/src/main/java/org/springblade/los/finance/vouchers/service/IFinVouchersService.java

@@ -72,4 +72,6 @@ public interface IFinVouchersService extends IService<FinVouchers> {
 	void removeIds(List<Long> longList);
 
 	R submitPeriod(FinVouchers finVouchers);
+
+	FinVouchers detailByVoucherNo(FinVouchers finVouchers);
 }

+ 17 - 0
blade-service/blade-los/src/main/java/org/springblade/los/finance/vouchers/service/impl/FinVouchersServiceImpl.java

@@ -1841,4 +1841,21 @@ public class FinVouchersServiceImpl extends ServiceImpl<FinVouchersMapper, FinVo
 		return R.data(finVouchers);
 	}
 
+	@Override
+	public FinVouchers detailByVoucherNo(FinVouchers finVouchers) {
+		if (finVouchers.getVoucherNo() == null) {
+			throw new RuntimeException("缺少必要参数");
+		}
+		FinVouchers detail = baseMapper.selectOne(new LambdaQueryWrapper<FinVouchers>()
+			.eq(FinVouchers::getTenantId, AuthUtil.getTenantId())
+			.eq(FinVouchers::getIsDeleted, 0)
+			.eq(FinVouchers::getVoucherNo, finVouchers.getVoucherNo()));
+		detail.setFinVouchersItemsList(finVouchersItemsService.list(new LambdaQueryWrapper<FinVouchersItems>()
+			.eq(FinVouchersItems::getIsDeleted, 0)
+			.eq(FinVouchersItems::getTenantId, AuthUtil.getTenantId())
+			.eq(FinVouchersItems::getPid, detail.getId())
+		));
+		return detail;
+	}
+
 }

Některé soubory nejsou zobrazeny, neboť je v těchto rozdílových datech změněno mnoho souborů