Browse Source

2024年5月24日17:32:30

纪新园 1 year ago
parent
commit
78e23eeb6b

+ 10 - 0
blade-service/blade-box-tube/src/main/java/org/springblade/box/tube/service/impl/TradingBoxServiceImpl.java

@@ -519,6 +519,16 @@ public class TradingBoxServiceImpl extends ServiceImpl<TradingBoxMapper, Trading
 				.eq(TradingBoxItem::getPid, tradingBox.getId()));
 			for (TradingBoxItem tradingBoxItem:tradingBoxItemList) {
 				if (ObjectUtils.isNotNull(tradingBoxItem.getCode())) {
+					if ("BUY".equals(tradingBox.getType())) {
+						tradingBoxItem.setBoxSource("购买");
+						tradingBoxItem.setStatus("待使用");
+					}else if ("SELL".equals(tradingBox.getType())){
+						if ("购买".equals(tradingBoxItem.getBoxSource())) {
+							tradingBoxItem.setStatus("卖出");
+						} else {
+							tradingBoxItem.setStatus("退租");
+						}
+					}
 					//更新箱档案信息
 					Archives archivesR = archivesMapper.selectOne(new LambdaQueryWrapper<Archives>().eq(Archives::getIsDeleted, 0)
 						.eq(Archives::getTenantId, AuthUtil.getTenantId())

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

@@ -37,6 +37,8 @@ import org.springblade.los.basic.acc.entity.Accounts;
 import org.springblade.los.basic.acc.service.IAccountsService;
 import org.springblade.los.basic.acc.vo.AccountsDetail;
 import org.springblade.los.basic.acc.vo.AccountsVO;
+import org.springblade.los.basic.cur.entity.BCurrency;
+import org.springblade.los.basic.cur.service.IBCurrencyService;
 import org.springblade.los.finance.genleg.dto.PeriodVouchersAccItems;
 import org.springblade.los.finance.vouchers.entity.FinVouchersItems;
 import org.springblade.los.finance.vouchers.service.IFinVouchersItemsService;
@@ -63,6 +65,8 @@ public class AccountsController extends BladeController {
 
 	private final IFinVouchersItemsService finVouchersItemsService;
 
+	private final IBCurrencyService bCurrencyService;
+
 	/**
 	 * 详情
 	 */
@@ -101,7 +105,29 @@ public class AccountsController extends BladeController {
 			lambdaQueryWrapper.eq(Accounts::getBranchId, deptUtils.getDeptPid());
 		}
 		IPage<Accounts> pages = accountsService.page(Condition.getPage(query), lambdaQueryWrapper);
+		BCurrency bCurrency = new BCurrency();
+		bCurrency.setDc("D");
+		List<BCurrency> bCurrencyListD = bCurrencyService.getExrate(bCurrency);
+		bCurrency.setDc("C");
+		List<BCurrency> bCurrencyListC = bCurrencyService.getExrate(bCurrency);
 		for (Accounts item : pages.getRecords()) {
+			if ("USD".equals(item.getCurCode())) {
+				if ("D".equals(item.getDc())) {
+					if (!bCurrencyListD.isEmpty()) {
+						BCurrency bCurrency1 = bCurrencyListD.stream().filter(e -> e.getCode().equals("USD")).findFirst().orElse(null);
+						if (bCurrency1 != null) {
+							item.setExrate(bCurrency1.getExrate());
+						}
+					}
+				} else if ("C".equals(item.getDc())) {
+					if (!bCurrencyListD.isEmpty()) {
+						BCurrency bCurrency1 = bCurrencyListC.stream().filter(e -> e.getCode().equals("USD")).findFirst().orElse(null);
+						if (bCurrency1 != null) {
+							item.setExrate(bCurrency1.getExrate());
+						}
+					}
+				}
+			}
 			int count = finVouchersItemsService.count(new LambdaQueryWrapper<FinVouchersItems>()
 				.eq(FinVouchersItems::getAccountId, item.getId()));
 			count = count > 1 ? 1 : 0;

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

@@ -447,9 +447,11 @@ public class AccountsServiceImpl extends ServiceImpl<AccountsMapper, Accounts> i
 			.eq(Accounts::getBranchId, deptUtils.getDeptPid())
 			.eq(Accounts::getIsDetail, 1);
 		if ("1".equals(accounts.getType())) {
-			lambdaQueryWrapper.apply("cur_code != 'CNY'");
+			lambdaQueryWrapper.apply("cur_code = 'USD'");
 		} else {
+			lambdaQueryWrapper.apply("cur_code != '' and cur_code is not null");
 			lambdaQueryWrapper.apply("find_in_set(property,'2,4')");
+			lambdaQueryWrapper.apply("cn_name!='期间损益'");
 		}
 		List<Accounts> accountsList = baseMapper.selectList(lambdaQueryWrapper);
 		List<PeriodVouchersAccItems> list = new ArrayList<>();

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

@@ -383,6 +383,8 @@ public class BCurrencyServiceImpl extends ServiceImpl<CurrencyMapper, BCurrency>
 						lambdaQueryWrapper.eq(BCurExrate::getExrateMonth, month);
 						lambdaQueryWrapper.eq(BCurExrate::getExrateDay, day)
 							.eq(BCurExrate::getType, bCurrency.getParitiesType());
+					}else if ("年汇率".equals(bCurrency.getParitiesType())) {
+						lambdaQueryWrapper.eq(BCurExrate::getType, bCurrency.getParitiesType());
 					}
 				}
 			} else {
@@ -393,6 +395,8 @@ public class BCurrencyServiceImpl extends ServiceImpl<CurrencyMapper, BCurrency>
 					lambdaQueryWrapper.eq(BCurExrate::getExrateMonth, month);
 					lambdaQueryWrapper.eq(BCurExrate::getExrateDay, day)
 						.eq(BCurExrate::getType, bCurrency.getParitiesType());
+				}else if ("年汇率".equals(bCurrency.getParitiesType())) {
+					lambdaQueryWrapper.eq(BCurExrate::getType, bCurrency.getParitiesType());
 				}
 			}
 			BCurExrate bCurExrate = bCurExrateService.getOne(lambdaQueryWrapper);

+ 42 - 0
blade-service/blade-los/src/main/java/org/springblade/los/business/aea/service/impl/AeaBillsServiceImpl.java

@@ -55,6 +55,8 @@ import org.springblade.los.finance.fee.entity.FeeCenter;
 import org.springblade.los.finance.fee.entity.FinAccBills;
 import org.springblade.los.finance.fee.service.IFeeCenterService;
 import org.springblade.los.finance.fee.service.IFinAccBillsService;
+import org.springblade.los.finance.genleg.entity.FinPeriod;
+import org.springblade.los.finance.genleg.mapper.FinPeriodMapper;
 import org.springblade.system.entity.Dept;
 import org.springblade.system.feign.ISysClient;
 import org.springframework.stereotype.Service;
@@ -67,6 +69,8 @@ import java.math.RoundingMode;
 import java.text.DateFormat;
 import java.text.ParseException;
 import java.text.SimpleDateFormat;
+import java.time.LocalDate;
+import java.time.ZoneId;
 import java.util.ArrayList;
 import java.util.Date;
 import java.util.List;
@@ -107,6 +111,8 @@ public class AeaBillsServiceImpl extends ServiceImpl<AeaBillsMapper, AeaBills> i
 
 	private final IBCorpsService ibCorpsService;
 
+	private final FinPeriodMapper finPeriodMapper;
+
 	@Override
 	public IPage<AeaBillsVO> selectAeaBillsPage(IPage<AeaBillsVO> page, AeaBillsVO aeaBills) {
 		return page.setRecords(baseMapper.selectAeaBillsPage(page, aeaBills));
@@ -138,6 +144,24 @@ public class AeaBillsServiceImpl extends ServiceImpl<AeaBillsMapper, AeaBills> i
 			.eq(AeaBills::getIsDeleted, 0)
 			.eq(AeaBills::getMblno, aeaBills.getMblno()
 			));
+		if (ObjectUtils.isNotNull(aeaBills.getBillDate())) {
+			LocalDate date = aeaBills.getBillDate().toInstant().atZone(ZoneId.systemDefault()).toLocalDate();
+			int year = date.getYear();
+			int month = date.getMonthValue();
+			FinPeriod finPeriod = finPeriodMapper.selectOne(new LambdaQueryWrapper<FinPeriod>()
+				.eq(FinPeriod::getTenantId, AuthUtil.getTenantId())
+				.eq(FinPeriod::getIsDeleted, 0)
+				.eq(FinPeriod::getPeriodYear, year)
+				.eq(FinPeriod::getPeriodMonth, month));
+			if (finPeriod != null) {
+				if (1 == finPeriod.getIsClosed()) {
+					throw new RuntimeException(year + "年" + month + "月账期已结转,保存失败");
+				}
+				if (1 == finPeriod.getLockingStatus()) {
+					throw new RuntimeException(year + "年" + month + "月账期已锁定,保存失败");
+				}
+			}
+		}
 		if (aeaBills.getId() == null) {
 			if ("MH".equals(aeaBills.getBillType())) {
 				if (ObjectUtils.isNotNull(aeaBills.getMblno())) {
@@ -1329,6 +1353,24 @@ public class AeaBillsServiceImpl extends ServiceImpl<AeaBillsMapper, AeaBills> i
 		} catch (ParseException e) {
 			throw new RuntimeException(e);
 		}
+		if (ObjectUtils.isNotNull(bills.getBillDate())) {
+			LocalDate date2 = bills.getBillDate().toInstant().atZone(ZoneId.systemDefault()).toLocalDate();
+			int year = date2.getYear();
+			int month = date2.getMonthValue();
+			FinPeriod finPeriod = finPeriodMapper.selectOne(new LambdaQueryWrapper<FinPeriod>()
+				.eq(FinPeriod::getTenantId, AuthUtil.getTenantId())
+				.eq(FinPeriod::getIsDeleted, 0)
+				.eq(FinPeriod::getPeriodYear, year)
+				.eq(FinPeriod::getPeriodMonth, month));
+			if (finPeriod != null) {
+				if (1 == finPeriod.getIsClosed()) {
+					throw new RuntimeException(year + "年" + month + "月账期已结转,保存失败");
+				}
+				if (1 == finPeriod.getLockingStatus()) {
+					throw new RuntimeException(year + "年" + month + "月账期已锁定,保存失败");
+				}
+			}
+		}
 		if ("1".equals(type)) {
 			List<FeeCenter> feeCenterListSum = new ArrayList<>();
 			BigDecimal exrateDUsd = null;

+ 24 - 0
blade-service/blade-los/src/main/java/org/springblade/los/business/amends/service/impl/AmendsServiceImpl.java

@@ -51,6 +51,8 @@ import org.springblade.los.finance.fee.entity.FeeCenter;
 import org.springblade.los.finance.fee.entity.FinAccBills;
 import org.springblade.los.finance.fee.service.IFeeCenterService;
 import org.springblade.los.finance.fee.service.IFinAccBillsService;
+import org.springblade.los.finance.genleg.entity.FinPeriod;
+import org.springblade.los.finance.genleg.mapper.FinPeriodMapper;
 import org.springblade.system.feign.ISysClient;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
@@ -59,6 +61,8 @@ import org.springframework.transaction.interceptor.TransactionAspectSupport;
 import java.math.BigDecimal;
 import java.math.MathContext;
 import java.math.RoundingMode;
+import java.time.LocalDate;
+import java.time.ZoneId;
 import java.util.Date;
 import java.util.List;
 import java.util.Objects;
@@ -100,6 +104,8 @@ public class AmendsServiceImpl extends ServiceImpl<AmendsMapper, Amends> impleme
 
 	private final IBCurrencyService bCurrencyService;
 
+	private final FinPeriodMapper finPeriodMapper;
+
 	@Override
 	public IPage<AmendsVO> selectAmendsPage(IPage<AmendsVO> page, AmendsVO amends) {
 		return page.setRecords(baseMapper.selectAmendsPage(page, amends));
@@ -121,6 +127,24 @@ public class AmendsServiceImpl extends ServiceImpl<AmendsMapper, Amends> impleme
 			}
 		}
 		amends.setBillDate(new Date());
+		if (ObjectUtils.isNotNull(amends.getBillDate())) {
+			LocalDate date = amends.getBillDate().toInstant().atZone(ZoneId.systemDefault()).toLocalDate();
+			int year = date.getYear();
+			int month = date.getMonthValue();
+			FinPeriod finPeriod = finPeriodMapper.selectOne(new LambdaQueryWrapper<FinPeriod>()
+				.eq(FinPeriod::getTenantId, AuthUtil.getTenantId())
+				.eq(FinPeriod::getIsDeleted, 0)
+				.eq(FinPeriod::getPeriodYear, year)
+				.eq(FinPeriod::getPeriodMonth, month));
+			if (finPeriod != null) {
+				if (1 == finPeriod.getIsClosed()) {
+					throw new RuntimeException(year + "年" + month + "月账期已结转,保存失败");
+				}
+				if (1 == finPeriod.getLockingStatus()) {
+					throw new RuntimeException(year + "年" + month + "月账期已锁定,保存失败");
+				}
+			}
+		}
 		if (amends.getId() == null) {
 			BusinessType businessType = bBusinessTypeService.getOne(new LambdaQueryWrapper<BusinessType>()
 				.eq(BusinessType::getTenantId, AuthUtil.getTenantId())

+ 24 - 0
blade-service/blade-los/src/main/java/org/springblade/los/business/customsDeclaration/service/impl/CustomsDeclarationServiceImpl.java

@@ -53,12 +53,16 @@ import org.springblade.los.finance.fee.entity.FeeCenter;
 import org.springblade.los.finance.fee.entity.FinAccBills;
 import org.springblade.los.finance.fee.service.IFeeCenterService;
 import org.springblade.los.finance.fee.service.IFinAccBillsService;
+import org.springblade.los.finance.genleg.entity.FinPeriod;
+import org.springblade.los.finance.genleg.mapper.FinPeriodMapper;
 import org.springblade.system.feign.ISysClient;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 import org.springframework.transaction.interceptor.TransactionAspectSupport;
 
 import java.math.BigDecimal;
+import java.time.LocalDate;
+import java.time.ZoneId;
 import java.util.Date;
 import java.util.List;
 import java.util.stream.Collectors;
@@ -97,6 +101,8 @@ public class CustomsDeclarationServiceImpl extends ServiceImpl<CustomsDeclaratio
 
 	private final ICustomsDeclarationGoodsService customsDeclarationGoodsService;
 
+	private final FinPeriodMapper finPeriodMapper;
+
 	@Override
 	public IPage<CustomsDeclarationVO> selectCustomsDeclarationPage(IPage<CustomsDeclarationVO> page, CustomsDeclarationVO customsDeclaration) {
 		return page.setRecords(baseMapper.selectCustomsDeclarationPage(page, customsDeclaration));
@@ -152,6 +158,24 @@ public class CustomsDeclarationServiceImpl extends ServiceImpl<CustomsDeclaratio
 		if (ObjectUtils.isNotNull(customsDeclaration.getMblno())) {
 			customsDeclaration.setMblno(customsDeclaration.getMblno().replaceAll(" ", ""));
 		}
+		if (ObjectUtils.isNotNull(customsDeclaration.getBillDate())) {
+			LocalDate date = customsDeclaration.getBillDate().toInstant().atZone(ZoneId.systemDefault()).toLocalDate();
+			int year = date.getYear();
+			int month = date.getMonthValue();
+			FinPeriod finPeriod = finPeriodMapper.selectOne(new LambdaQueryWrapper<FinPeriod>()
+				.eq(FinPeriod::getTenantId, AuthUtil.getTenantId())
+				.eq(FinPeriod::getIsDeleted, 0)
+				.eq(FinPeriod::getPeriodYear, year)
+				.eq(FinPeriod::getPeriodMonth, month));
+			if (finPeriod != null) {
+				if (1 == finPeriod.getIsClosed()) {
+					throw new RuntimeException(year + "年" + month + "月账期已结转,保存失败");
+				}
+				if (1 == finPeriod.getLockingStatus()) {
+					throw new RuntimeException(year + "年" + month + "月账期已锁定,保存失败");
+				}
+			}
+		}
 		List<CustomsDeclaration> count = baseMapper.selectList(new LambdaQueryWrapper<CustomsDeclaration>()
 			.eq(CustomsDeclaration::getCreateDept, AuthUtil.getDeptId())
 			.eq(CustomsDeclaration::getTenantId, AuthUtil.getTenantId())

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

@@ -56,6 +56,8 @@ import org.springblade.los.finance.fee.entity.FeeCenter;
 import org.springblade.los.finance.fee.entity.FinAccBills;
 import org.springblade.los.finance.fee.service.IFeeCenterService;
 import org.springblade.los.finance.fee.service.IFinAccBillsService;
+import org.springblade.los.finance.genleg.entity.FinPeriod;
+import org.springblade.los.finance.genleg.mapper.FinPeriodMapper;
 import org.springblade.system.entity.Dept;
 import org.springblade.system.feign.ISysClient;
 import org.springframework.stereotype.Service;
@@ -68,7 +70,9 @@ import java.math.RoundingMode;
 import java.text.DateFormat;
 import java.text.ParseException;
 import java.text.SimpleDateFormat;
+import java.time.LocalDate;
 import java.time.LocalDateTime;
+import java.time.ZoneId;
 import java.time.format.DateTimeFormatter;
 import java.util.ArrayList;
 import java.util.Date;
@@ -118,6 +122,8 @@ public class BillsServiceImpl extends ServiceImpl<BillsMapper, Bills> implements
 
 	private final IBCorpsService ibCorpsService;
 
+	private final FinPeriodMapper finPeriodMapper;
+
 	@Override
 	public IPage<BillsVO> selectBillsPage(IPage<BillsVO> page, BillsVO bills) {
 		return page.setRecords(baseMapper.selectBillsPage(page, bills));
@@ -155,6 +161,24 @@ public class BillsServiceImpl extends ServiceImpl<BillsMapper, Bills> implements
 		} else {
 			bills.setBillDate(bills.getEta());
 		}
+		if (ObjectUtils.isNotNull(bills.getBillDate())) {
+			LocalDate date = bills.getBillDate().toInstant().atZone(ZoneId.systemDefault()).toLocalDate();
+			int year = date.getYear();
+			int month = date.getMonthValue();
+			FinPeriod finPeriod = finPeriodMapper.selectOne(new LambdaQueryWrapper<FinPeriod>()
+				.eq(FinPeriod::getTenantId, AuthUtil.getTenantId())
+				.eq(FinPeriod::getIsDeleted, 0)
+				.eq(FinPeriod::getPeriodYear, year)
+				.eq(FinPeriod::getPeriodMonth, month));
+			if (finPeriod != null) {
+				if (1 == finPeriod.getIsClosed()) {
+					throw new RuntimeException(year + "年" + month + "月账期已结转,保存失败");
+				}
+				if (1 == finPeriod.getLockingStatus()) {
+					throw new RuntimeException(year + "年" + month + "月账期已锁定,保存失败");
+				}
+			}
+		}
 		if (bills.getId() == null) {
 			if (!"MH".equals(bills.getBillType())) {
 				if (ObjectUtils.isNotNull(bills.getMblno())) {
@@ -795,6 +819,24 @@ public class BillsServiceImpl extends ServiceImpl<BillsMapper, Bills> implements
 		bills.setUpdateUser(AuthUtil.getUserId());
 		bills.setUpdateTime(new Date());
 		bills.setUpdateUserName(AuthUtil.getUserName());
+		if (ObjectUtils.isNotNull(bills.getBillDate())) {
+			LocalDate date = bills.getBillDate().toInstant().atZone(ZoneId.systemDefault()).toLocalDate();
+			int year = date.getYear();
+			int month = date.getMonthValue();
+			FinPeriod finPeriod = finPeriodMapper.selectOne(new LambdaQueryWrapper<FinPeriod>()
+				.eq(FinPeriod::getTenantId, AuthUtil.getTenantId())
+				.eq(FinPeriod::getIsDeleted, 0)
+				.eq(FinPeriod::getPeriodYear, year)
+				.eq(FinPeriod::getPeriodMonth, month));
+			if (finPeriod != null) {
+				if (1 == finPeriod.getIsClosed()) {
+					throw new RuntimeException(year + "年" + month + "月账期已结转,保存失败");
+				}
+				if (1 == finPeriod.getLockingStatus()) {
+					throw new RuntimeException(year + "年" + month + "月账期已锁定,保存失败");
+				}
+			}
+		}
 		if (!bills.getPreContainersList().isEmpty()) {
 			preContainersService.saveOrUpdateBatch(bills.getPreContainersList());
 		}
@@ -1798,6 +1840,24 @@ public class BillsServiceImpl extends ServiceImpl<BillsMapper, Bills> implements
 		} catch (ParseException e) {
 			throw new RuntimeException(e);
 		}
+		if (ObjectUtils.isNotNull(bills.getBillDate())) {
+			LocalDate date2 = bills.getBillDate().toInstant().atZone(ZoneId.systemDefault()).toLocalDate();
+			int year = date2.getYear();
+			int month = date2.getMonthValue();
+			FinPeriod finPeriod = finPeriodMapper.selectOne(new LambdaQueryWrapper<FinPeriod>()
+				.eq(FinPeriod::getTenantId, AuthUtil.getTenantId())
+				.eq(FinPeriod::getIsDeleted, 0)
+				.eq(FinPeriod::getPeriodYear, year)
+				.eq(FinPeriod::getPeriodMonth, month));
+			if (finPeriod != null) {
+				if (1 == finPeriod.getIsClosed()) {
+					throw new RuntimeException(year + "年" + month + "月账期已结转,保存失败");
+				}
+				if (1 == finPeriod.getLockingStatus()) {
+					throw new RuntimeException(year + "年" + month + "月账期已锁定,保存失败");
+				}
+			}
+		}
 		if ("1".equals(type)) {
 			List<FeeCenter> feeCenterListSum = new ArrayList<>();
 			BigDecimal exrateDUsd = null;

+ 298 - 147
blade-service/blade-los/src/main/java/org/springblade/los/finance/genleg/service/impl/FinPeriodServiceImpl.java

@@ -217,8 +217,7 @@ public class FinPeriodServiceImpl extends ServiceImpl<FinPeriodMapper, FinPeriod
 			.apply("((business_type = 'SE' and etd >='" + beginDate + "' and etd <= '" + endDate + "' ) " +
 				"or (business_type = 'SI' and eta >='" + beginDate + "' and eta <= '" + endDate + "'))"));
 		if (!billsList.isEmpty()) {
-			List<Bills> bills = billsList.stream().filter(e -> e.getBillStatus().equals(3)).collect(Collectors.toList());
-			for (Bills item : bills) {
+			for (Bills item : billsList) {
 				ReviewFailedExcel reviewFailedExcel = new ReviewFailedExcel();
 				if ("SE".equals(item.getBusinessType())) {
 					reviewFailedExcel.setBusinessType("海运出口");
@@ -243,8 +242,7 @@ public class FinPeriodServiceImpl extends ServiceImpl<FinPeriodMapper, FinPeriod
 			.apply("((business_type = 'AE' and etd >='" + beginDate + "' and etd <= '" + endDate + "' ) " +
 				"or (business_type = 'AI' and eta >='" + beginDate + "' and eta <= '" + endDate + "'))"));
 		if (!aeaBillsList.isEmpty()) {
-			List<AeaBills> aeaBills = aeaBillsList.stream().filter(e -> e.getBillStatus().equals(3)).collect(Collectors.toList());
-			for (AeaBills item : aeaBills) {
+			for (AeaBills item : aeaBillsList) {
 				ReviewFailedExcel reviewFailedExcel = new ReviewFailedExcel();
 				if ("AE".equals(item.getBusinessType())) {
 					reviewFailedExcel.setBusinessType("空运出口");
@@ -271,70 +269,67 @@ public class FinPeriodServiceImpl extends ServiceImpl<FinPeriodMapper, FinPeriod
 				"or (business_type = 'AEA' and etd >='" + beginDate + "' and etd <= '" + endDate + "')" +
 				"or (business_type = 'AIA' and eta >='" + beginDate + "' and eta <= '" + endDate + "'))"
 			));
+		List<Bills> billsList1 = new ArrayList<>();
+		List<AeaBills> aeaBillsList1 = new ArrayList<>();
 		if (!amendsList.isEmpty()) {
-			List<Amends> bills = amendsList.stream().filter(e -> e.getBillStatus().equals(3)).collect(Collectors.toList());
-			List<Bills> billsList1 = new ArrayList<>();
-			List<AeaBills> aeaBillsList1 = new ArrayList<>();
-			if (!bills.isEmpty()) {
-				List<Long> billsId = bills.stream().map(Amends::getOrigId).collect(Collectors.toList());
-				if (!billsId.isEmpty()) {
-					billsList1 = billsService.list(new LambdaQueryWrapper<Bills>()
-						.eq(Bills::getTenantId, AuthUtil.getTenantId())
-						.eq(Bills::getIsDeleted, 0)
-						.eq(Bills::getBranchId, detail.getBranchId())
-						.in(Bills::getId, billsId)
-					);
-				}
-				List<Long> aeaBillsId = bills.stream().map(Amends::getOrigId).collect(Collectors.toList());
-				if (!aeaBillsId.isEmpty()) {
-					aeaBillsList1 = aeaBillsService.list(new LambdaQueryWrapper<AeaBills>()
-						.eq(AeaBills::getTenantId, AuthUtil.getTenantId())
-						.eq(AeaBills::getIsDeleted, 0)
-						.eq(AeaBills::getBranchId, detail.getBranchId())
-						.in(AeaBills::getId, aeaBillsId));
-				}
+			List<Long> billsId = amendsList.stream().map(Amends::getOrigId).collect(Collectors.toList());
+			if (!billsId.isEmpty()) {
+				billsList1 = billsService.list(new LambdaQueryWrapper<Bills>()
+					.eq(Bills::getTenantId, AuthUtil.getTenantId())
+					.eq(Bills::getIsDeleted, 0)
+					.eq(Bills::getBranchId, detail.getBranchId())
+					.in(Bills::getId, billsId)
+				);
 			}
-			for (Amends item : bills) {
-				ReviewFailedExcel reviewFailedExcel = new ReviewFailedExcel();
-				if ("AEA".equals(item.getBusinessType())) {
-					if (!aeaBillsList1.isEmpty()) {
-						AeaBills aeaBills = aeaBillsList1.stream().filter(e -> e.getId().equals(item.getOrigId())).findFirst().orElse(null);
-						if (aeaBills != null && "SALES".equals(aeaBills.getSrcType())) {
-							reviewFailedExcel.setSalesperson(aeaBills.getSrcCnName());
-						}
+			List<Long> aeaBillsId = amendsList.stream().map(Amends::getOrigId).collect(Collectors.toList());
+			if (!aeaBillsId.isEmpty()) {
+				aeaBillsList1 = aeaBillsService.list(new LambdaQueryWrapper<AeaBills>()
+					.eq(AeaBills::getTenantId, AuthUtil.getTenantId())
+					.eq(AeaBills::getIsDeleted, 0)
+					.eq(AeaBills::getBranchId, detail.getBranchId())
+					.in(AeaBills::getId, aeaBillsId));
+			}
+		}
+		for (Amends item : amendsList) {
+			ReviewFailedExcel reviewFailedExcel = new ReviewFailedExcel();
+			if ("AEA".equals(item.getBusinessType())) {
+				if (!aeaBillsList1.isEmpty()) {
+					AeaBills aeaBills = aeaBillsList1.stream().filter(e -> e.getId().equals(item.getOrigId())).findFirst().orElse(null);
+					if (aeaBills != null && "SALES".equals(aeaBills.getSrcType())) {
+						reviewFailedExcel.setSalesperson(aeaBills.getSrcCnName());
 					}
-					reviewFailedExcel.setBusinessType("空运出口Amends");
-				} else if ("AIA".equals(item.getBusinessType())) {
-					if (!aeaBillsList1.isEmpty()) {
-						AeaBills aeaBills = aeaBillsList1.stream().filter(e -> e.getId().equals(item.getOrigId())).findFirst().orElse(null);
-						if (aeaBills != null && "SALES".equals(aeaBills.getSrcType())) {
-							reviewFailedExcel.setSalesperson(aeaBills.getSrcCnName());
-						}
+				}
+				reviewFailedExcel.setBusinessType("空运出口Amends");
+			} else if ("AIA".equals(item.getBusinessType())) {
+				if (!aeaBillsList1.isEmpty()) {
+					AeaBills aeaBills = aeaBillsList1.stream().filter(e -> e.getId().equals(item.getOrigId())).findFirst().orElse(null);
+					if (aeaBills != null && "SALES".equals(aeaBills.getSrcType())) {
+						reviewFailedExcel.setSalesperson(aeaBills.getSrcCnName());
 					}
-					reviewFailedExcel.setBusinessType("空运进口Amends");
-				} else if ("SIA".equals(item.getBusinessType())) {
-					if (!billsList1.isEmpty()) {
-						Bills aeaBills = billsList1.stream().filter(e -> e.getId().equals(item.getOrigId())).findFirst().orElse(null);
-						if (aeaBills != null && "SALES".equals(aeaBills.getSrcType())) {
-							reviewFailedExcel.setSalesperson(aeaBills.getSrcCnName());
-						}
+				}
+				reviewFailedExcel.setBusinessType("空运进口Amends");
+			} else if ("SIA".equals(item.getBusinessType())) {
+				if (!billsList1.isEmpty()) {
+					Bills aeaBills = billsList1.stream().filter(e -> e.getId().equals(item.getOrigId())).findFirst().orElse(null);
+					if (aeaBills != null && "SALES".equals(aeaBills.getSrcType())) {
+						reviewFailedExcel.setSalesperson(aeaBills.getSrcCnName());
 					}
-					reviewFailedExcel.setBusinessType("海运进口Amends");
-				} else if ("SEA".equals(item.getBusinessType())) {
-					if (!billsList1.isEmpty()) {
-						Bills aeaBills = billsList1.stream().filter(e -> e.getId().equals(item.getOrigId())).findFirst().orElse(null);
-						if (aeaBills != null && "SALES".equals(aeaBills.getSrcType())) {
-							reviewFailedExcel.setSalesperson(aeaBills.getSrcCnName());
-						}
+				}
+				reviewFailedExcel.setBusinessType("海运进口Amends");
+			} else if ("SEA".equals(item.getBusinessType())) {
+				if (!billsList1.isEmpty()) {
+					Bills aeaBills = billsList1.stream().filter(e -> e.getId().equals(item.getOrigId())).findFirst().orElse(null);
+					if (aeaBills != null && "SALES".equals(aeaBills.getSrcType())) {
+						reviewFailedExcel.setSalesperson(aeaBills.getSrcCnName());
 					}
-					reviewFailedExcel.setBusinessType("海运出口Amends");
 				}
-				reviewFailedExcel.setBillNo(item.getBillNo());
-				reviewFailedExcel.setBusinessDate(item.getBillDate());
-				reviewFailedExcel.setMblno(item.getMblno());
-				reviewFailedExcel.setOperator(item.getOperatorName());
-				reviewFailedExcelList.add(reviewFailedExcel);
+				reviewFailedExcel.setBusinessType("海运出口Amends");
 			}
+			reviewFailedExcel.setBillNo(item.getBillNo());
+			reviewFailedExcel.setBusinessDate(item.getBillDate());
+			reviewFailedExcel.setMblno(item.getMblno());
+			reviewFailedExcel.setOperator(item.getOperatorName());
+			reviewFailedExcelList.add(reviewFailedExcel);
 		}
 		List<CustomsDeclaration> customsDeclarationList = customsDeclarationService.list(new LambdaQueryWrapper<CustomsDeclaration>()
 			.eq(CustomsDeclaration::getTenantId, AuthUtil.getTenantId())
@@ -345,8 +340,7 @@ public class FinPeriodServiceImpl extends ServiceImpl<FinPeriodMapper, FinPeriod
 			.lt(CustomsDeclaration::getDeclareDate, detail.getEndDate())
 		);
 		if (!customsDeclarationList.isEmpty()) {
-			List<CustomsDeclaration> bills = customsDeclarationList.stream().filter(e -> e.getBillStatus().equals(3)).collect(Collectors.toList());
-			for (CustomsDeclaration item : bills) {
+			for (CustomsDeclaration item : customsDeclarationList) {
 				ReviewFailedExcel reviewFailedExcel = new ReviewFailedExcel();
 				if ("BGSE".equals(item.getBusinessType())) {
 					reviewFailedExcel.setBusinessType("海运报关");
@@ -377,38 +371,35 @@ public class FinPeriodServiceImpl extends ServiceImpl<FinPeriodMapper, FinPeriod
 			.lt(FinStlBills::getBillDate, endDate)
 		);
 		if (!finStlBillsList.isEmpty()) {
-			List<FinStlBills> bills = finStlBillsList.stream().filter(e -> e.getBillStatus().equals("3")).collect(Collectors.toList());
-			if (!bills.isEmpty()) {
-				List<Long> ids = bills.stream().map(FinStlBills::getId).collect(Collectors.toList());
-				if (!ids.isEmpty()) {
-					List<FinVouchers> finVouchersList = finVouchersService.list(new LambdaQueryWrapper<FinVouchers>()
-						.eq(FinVouchers::getTenantId, AuthUtil.getTenantId())
-						.eq(FinVouchers::getIsDeleted, 0)
-						.eq(FinVouchers::getBranchId, detail.getBranchId())
-						.in(FinVouchers::getSrcId, ids)
-						.gt(FinVouchers::getVoucherDate, beginDate)
-						.lt(FinVouchers::getVoucherDate, endDate));
-					for (FinStlBills item : bills) {
-						FinVouchers finVouchers = finVouchersList.stream().filter(e -> e.getSrcId().equals(item.getId())).findFirst().orElse(null);
-						if (finVouchers == null) {
-							ReviewFailedExcel reviewFailedExcel = new ReviewFailedExcel();
-							reviewFailedExcel.setBusinessType("结算中心");
-							reviewFailedExcel.setBillNo(item.getBillNo());
-							reviewFailedExcel.setBusinessDate(item.getBillDate());
-							reviewFailedExcel.setMblno(item.getMblno());
-							reviewFailedExcel.setOperator(item.getCreateUserName());
-							reviewFailedExcel.setSalesperson(item.getSalesName());
-							reviewFailedExcelList.add(reviewFailedExcel);
-						} else {
-							if (3 != finVouchers.getStatus()) {
-								UnbookkeptExcel unbookkeptExcel = new UnbookkeptExcel();
-								unbookkeptExcel.setYear(finVouchers.getAccountYear() + "");
-								unbookkeptExcel.setMonth(finVouchers.getAccountMonth() + "");
-								unbookkeptExcel.setVoucherNumber(finVouchers.getVoucherNo());
-								unbookkeptExcel.setVoucherDate(finVouchers.getVoucherDate());
-								unbookkeptExcel.setOperator(finVouchers.getCreateUserName());
-								unbookkeptExcelList.add(unbookkeptExcel);
-							}
+			List<Long> ids = finStlBillsList.stream().map(FinStlBills::getId).collect(Collectors.toList());
+			if (!ids.isEmpty()) {
+				List<FinVouchers> finVouchersList = finVouchersService.list(new LambdaQueryWrapper<FinVouchers>()
+					.eq(FinVouchers::getTenantId, AuthUtil.getTenantId())
+					.eq(FinVouchers::getIsDeleted, 0)
+					.eq(FinVouchers::getBranchId, detail.getBranchId())
+					.in(FinVouchers::getSrcId, ids)
+					.gt(FinVouchers::getVoucherDate, beginDate)
+					.lt(FinVouchers::getVoucherDate, endDate));
+				for (FinStlBills item : finStlBillsList) {
+					FinVouchers finVouchers = finVouchersList.stream().filter(e -> e.getSrcId().equals(item.getId())).findFirst().orElse(null);
+					if (finVouchers == null) {
+						ReviewFailedExcel reviewFailedExcel = new ReviewFailedExcel();
+						reviewFailedExcel.setBusinessType("结算中心");
+						reviewFailedExcel.setBillNo(item.getBillNo());
+						reviewFailedExcel.setBusinessDate(item.getBillDate());
+						reviewFailedExcel.setMblno(item.getMblno());
+						reviewFailedExcel.setOperator(item.getCreateUserName());
+						reviewFailedExcel.setSalesperson(item.getSalesName());
+						reviewFailedExcelList.add(reviewFailedExcel);
+					} else {
+						if (3 != finVouchers.getStatus()) {
+							UnbookkeptExcel unbookkeptExcel = new UnbookkeptExcel();
+							unbookkeptExcel.setYear(finVouchers.getAccountYear() + "");
+							unbookkeptExcel.setMonth(finVouchers.getAccountMonth() + "");
+							unbookkeptExcel.setVoucherNumber(finVouchers.getVoucherNo());
+							unbookkeptExcel.setVoucherDate(finVouchers.getVoucherDate());
+							unbookkeptExcel.setOperator(finVouchers.getCreateUserName());
+							unbookkeptExcelList.add(unbookkeptExcel);
 						}
 					}
 				}
@@ -883,6 +874,24 @@ public class FinPeriodServiceImpl extends ServiceImpl<FinPeriodMapper, FinPeriod
 		String[] arr = periodVouchersTemplate.getDate().split("-");
 		Integer year = Integer.parseInt(arr[0]);
 		Integer month = Integer.parseInt(arr[1]);
+		FinPeriod finPeriod = baseMapper.selectById(periodVouchersTemplate.getId());
+		if (finPeriod == null) {
+			throw new RuntimeException("未查到" + periodVouchersTemplate.getDate() + "期间数据");
+		}
+		if (0 == finPeriod.getLockingStatus()) {
+			throw new RuntimeException("请先将当前期间锁定后再生成凭证");
+		}
+		if (!"FM-CURRENCY-PL-TRANSFER".equals(periodVouchersTemplate.getBsType())) {
+			if (finVouchersService.count(new LambdaQueryWrapper<FinVouchers>()
+				.eq(FinVouchers::getTenantId, AuthUtil.getTenantId())
+				.eq(FinVouchers::getIsDeleted, 0)
+				.eq(FinVouchers::getAccountYear, year)
+				.eq(FinVouchers::getAccountMonth, month)
+				.eq(FinVouchers::getVoucherType, periodVouchersTemplate.getVkno())
+				.eq(FinVouchers::getVoucherSource, "FM-CURRENCY-PL-TRANSFER")) == 0) {
+				throw new RuntimeException("请先生成汇兑损益凭证");
+			}
+		}
 		if (finVouchersService.count(new LambdaQueryWrapper<FinVouchers>()
 			.eq(FinVouchers::getTenantId, AuthUtil.getTenantId())
 			.eq(FinVouchers::getIsDeleted, 0)
@@ -962,7 +971,14 @@ public class FinPeriodServiceImpl extends ServiceImpl<FinPeriodMapper, FinPeriod
 				PeriodExchangeRate periodExchangeRate = exchangeRateList.stream()
 					.filter(e -> e.getCurCode().equals(item.getCurCode())).findFirst().orElse(null);
 				if (periodExchangeRate == null) {
-					throw new RuntimeException("未找到汇率信息");
+					if (!"CNY".equals(item.getCurCode())) {
+						throw new RuntimeException("未找到汇率信息");
+					} else {
+						periodExchangeRate = new PeriodExchangeRate();
+						periodExchangeRate.setCurCode("CNY");
+						periodExchangeRate.setCurName("人民币");
+						periodExchangeRate.setExrate(new BigDecimal("1.0"));
+					}
 				}
 				if (1 == item.getIsCorp() || 1 == item.getIsDept() || 1 == item.getIsEmpl()) {
 					List<FinGenlegCalc> finGenlegCalcs = finGenlegCalcList.stream()
@@ -1027,6 +1043,10 @@ public class FinPeriodServiceImpl extends ServiceImpl<FinPeriodMapper, FinPeriod
 									if (new BigDecimal("0.00").compareTo(amountDrUsdSubtract) != 0) {
 										finVouchersItems.setAmountDrUsd(amountDrUsdSubtract);
 										finVouchersItems.setAmountDr(finVouchersItems.getAmountDrUsd().multiply(periodExchangeRate.getExrate()));
+										finVouchersItems.setAmountDrLoc(finVouchersItems.getAmountDrUsd().multiply(periodExchangeRate.getExrate()));
+										finVouchersItems.setAmountCrUsd(new BigDecimal("0.00"));
+										finVouchersItems.setAmountCr(new BigDecimal("0.00"));
+										finVouchersItems.setAmountCrLoc(new BigDecimal("0.00"));
 									} else {
 										continue;
 									}
@@ -1036,6 +1056,10 @@ public class FinPeriodServiceImpl extends ServiceImpl<FinPeriodMapper, FinPeriod
 									if (new BigDecimal("0.00").compareTo(amountCrUsdSubtract) != 0) {
 										finVouchersItems.setAmountCrUsd(amountCrUsdSubtract);
 										finVouchersItems.setAmountCr(finVouchersItems.getAmountCrUsd().multiply(periodExchangeRate.getExrate()));
+										finVouchersItems.setAmountCrLoc(finVouchersItems.getAmountCrUsd().multiply(periodExchangeRate.getExrate()));
+										finVouchersItems.setAmountDrUsd(new BigDecimal("0.00"));
+										finVouchersItems.setAmountDr(new BigDecimal("0.00"));
+										finVouchersItems.setAmountDrLoc(new BigDecimal("0.00"));
 									} else {
 										continue;
 									}
@@ -1047,36 +1071,81 @@ public class FinPeriodServiceImpl extends ServiceImpl<FinPeriodMapper, FinPeriod
 								finVouchersItemsList.add(finVouchersItems);
 							}
 						} else {
-							if (!"CNY".equals(item.getCurCode())) {
-								finVouchersItems.setExrate(periodExchangeRate.getExrate());
-								if ("D".equals(item.getDc())) {
-									if (new BigDecimal("0.00").compareTo(calc.getAmountDrUsd()) != 0) {
-										finVouchersItems.setAmountCrUsd(calc.getAmountDrUsd());
-										finVouchersItems.setAmountCr(finVouchersItems.getAmountCrUsd().multiply(periodExchangeRate.getExrate()));
+							if ("550304".equals(item.getCode())) {
+								finVouchersItems.setExrate(new BigDecimal("1"));
+								if ("C".equals(item.getDc())) {
+									if (new BigDecimal("0.00").compareTo(calc.getAmountCr()) != 0) {
+										finVouchersItems.setAmountCr(calc.getAmountCr());
+										finVouchersItems.setAmountCrLoc(calc.getAmountCr());
+										finVouchersItems.setAmountCrUsd(new BigDecimal("0.00"));
+										finVouchersItems.setAmountDr(new BigDecimal("0.00"));
+										finVouchersItems.setAmountDrLoc(new BigDecimal("0.00"));
+										finVouchersItems.setAmountDrUsd(new BigDecimal("0.00"));
 									} else {
 										continue;
 									}
 								} else {
-									if (new BigDecimal("0.00").compareTo(calc.getAmountCrUsd()) != 0) {
-										finVouchersItems.setAmountDrUsd(calc.getAmountCrUsd());
-										finVouchersItems.setAmountDr(finVouchersItems.getAmountDrUsd().multiply(periodExchangeRate.getExrate()));
+									if (new BigDecimal("0.00").compareTo(calc.getAmountDr()) != 0) {
+										finVouchersItems.setAmountDr(calc.getAmountDr());
+										finVouchersItems.setAmountDrLoc(calc.getAmountDr());
+										finVouchersItems.setAmountCrUsd(new BigDecimal("0.00"));
+										finVouchersItems.setAmountCr(new BigDecimal("0.00"));
+										finVouchersItems.setAmountCrLoc(new BigDecimal("0.00"));
+										finVouchersItems.setAmountDrUsd(new BigDecimal("0.00"));
 									} else {
 										continue;
 									}
 								}
 							} else {
-								finVouchersItems.setExrate(new BigDecimal("1"));
-								if ("D".equals(item.getDc())) {
-									if (new BigDecimal("0.00").compareTo(calc.getAmountDrUsd()) != 0) {
-										finVouchersItems.setAmountCr(calc.getAmountDrUsd());
+								if (!"CNY".equals(item.getCurCode())) {
+									finVouchersItems.setExrate(periodExchangeRate.getExrate());
+									if ("D".equals(item.getDc())) {
+										if (new BigDecimal("0.00").compareTo(calc.getAmountDrUsd()) != 0) {
+											finVouchersItems.setAmountCrUsd(calc.getAmountDrUsd());
+											finVouchersItems.setAmountCr(finVouchersItems.getAmountCrUsd().multiply(periodExchangeRate.getExrate()));
+											finVouchersItems.setAmountCrLoc(finVouchersItems.getAmountCrUsd().multiply(periodExchangeRate.getExrate()));
+											finVouchersItems.setAmountDrUsd(new BigDecimal("0.00"));
+											finVouchersItems.setAmountDr(new BigDecimal("0.00"));
+											finVouchersItems.setAmountDrLoc(new BigDecimal("0.00"));
+										} else {
+											continue;
+										}
 									} else {
-										continue;
+										if (new BigDecimal("0.00").compareTo(calc.getAmountCrUsd()) != 0) {
+											finVouchersItems.setAmountDrUsd(calc.getAmountCrUsd());
+											finVouchersItems.setAmountDr(finVouchersItems.getAmountDrUsd().multiply(periodExchangeRate.getExrate()));
+											finVouchersItems.setAmountDrLoc(finVouchersItems.getAmountDrUsd().multiply(periodExchangeRate.getExrate()));
+											finVouchersItems.setAmountCrUsd(new BigDecimal("0.00"));
+											finVouchersItems.setAmountCr(new BigDecimal("0.00"));
+											finVouchersItems.setAmountCrLoc(new BigDecimal("0.00"));
+										} else {
+											continue;
+										}
 									}
 								} else {
-									if (new BigDecimal("0.00").compareTo(calc.getAmountCrUsd()) != 0) {
-										finVouchersItems.setAmountDr(calc.getAmountCrUsd());
+									finVouchersItems.setExrate(new BigDecimal("1"));
+									if ("D".equals(item.getDc())) {
+										if (new BigDecimal("0.00").compareTo(calc.getAmountDr()) != 0) {
+											finVouchersItems.setAmountCr(calc.getAmountDr());
+											finVouchersItems.setAmountCrLoc(calc.getAmountDr());
+											finVouchersItems.setAmountCrUsd(new BigDecimal("0.00"));
+											finVouchersItems.setAmountDr(new BigDecimal("0.00"));
+											finVouchersItems.setAmountDrLoc(new BigDecimal("0.00"));
+											finVouchersItems.setAmountDrUsd(new BigDecimal("0.00"));
+										} else {
+											continue;
+										}
 									} else {
-										continue;
+										if (new BigDecimal("0.00").compareTo(calc.getAmountCr()) != 0) {
+											finVouchersItems.setAmountDr(calc.getAmountCr());
+											finVouchersItems.setAmountDrLoc(calc.getAmountCr());
+											finVouchersItems.setAmountCrUsd(new BigDecimal("0.00"));
+											finVouchersItems.setAmountCr(new BigDecimal("0.00"));
+											finVouchersItems.setAmountCrLoc(new BigDecimal("0.00"));
+											finVouchersItems.setAmountDrUsd(new BigDecimal("0.00"));
+										} else {
+											continue;
+										}
 									}
 								}
 							}
@@ -1126,6 +1195,10 @@ public class FinPeriodServiceImpl extends ServiceImpl<FinPeriodMapper, FinPeriod
 								if (new BigDecimal("0.00").compareTo(amountDrUsdSubtract) != 0) {
 									finVouchersItems.setAmountDrUsd(amountDrUsdSubtract);
 									finVouchersItems.setAmountDr(finVouchersItems.getAmountDrUsd().multiply(periodExchangeRate.getExrate()));
+									finVouchersItems.setAmountDrLoc(finVouchersItems.getAmountDrUsd().multiply(periodExchangeRate.getExrate()));
+									finVouchersItems.setAmountCrUsd(new BigDecimal("0.00"));
+									finVouchersItems.setAmountCr(new BigDecimal("0.00"));
+									finVouchersItems.setAmountCrLoc(new BigDecimal("0.00"));
 								} else {
 									continue;
 								}
@@ -1135,6 +1208,10 @@ public class FinPeriodServiceImpl extends ServiceImpl<FinPeriodMapper, FinPeriod
 								if (new BigDecimal("0.00").compareTo(amountCrUsdSubtract) != 0) {
 									finVouchersItems.setAmountCrUsd(amountCrUsdSubtract);
 									finVouchersItems.setAmountCr(finVouchersItems.getAmountCrUsd().multiply(periodExchangeRate.getExrate()));
+									finVouchersItems.setAmountCrLoc(finVouchersItems.getAmountCrUsd().multiply(periodExchangeRate.getExrate()));
+									finVouchersItems.setAmountDrUsd(new BigDecimal("0.00"));
+									finVouchersItems.setAmountDr(new BigDecimal("0.00"));
+									finVouchersItems.setAmountDrLoc(new BigDecimal("0.00"));
 								} else {
 									continue;
 								}
@@ -1146,36 +1223,81 @@ public class FinPeriodServiceImpl extends ServiceImpl<FinPeriodMapper, FinPeriod
 							finVouchersItemsList.add(finVouchersItems);
 						}
 					} else {
-						if (!"CNY".equals(item.getCurCode())) {
-							finVouchersItems.setExrate(periodExchangeRate.getExrate());
-							if ("D".equals(item.getDc())) {
-								if (new BigDecimal("0.00").compareTo(finGenleg.getAmountDrUsd()) != 0) {
-									finVouchersItems.setAmountCrUsd(finGenleg.getAmountDrUsd());
-									finVouchersItems.setAmountCr(finVouchersItems.getAmountCrUsd().multiply(periodExchangeRate.getExrate()));
+						if ("550304".equals(item.getCode())) {
+							finVouchersItems.setExrate(new BigDecimal("1"));
+							if ("C".equals(item.getDc())) {
+								if (new BigDecimal("0.00").compareTo(finGenleg.getAmountCr()) != 0) {
+									finVouchersItems.setAmountCr(finGenleg.getAmountCr());
+									finVouchersItems.setAmountCrLoc(finGenleg.getAmountCr());
+									finVouchersItems.setAmountDrUsd(new BigDecimal("0.00"));
+									finVouchersItems.setAmountDr(new BigDecimal("0.00"));
+									finVouchersItems.setAmountDrLoc(new BigDecimal("0.00"));
+									finVouchersItems.setAmountCrUsd(new BigDecimal("0.00"));
 								} else {
 									continue;
 								}
 							} else {
-								if (new BigDecimal("0.00").compareTo(finGenleg.getAmountCrUsd()) != 0) {
-									finVouchersItems.setAmountDrUsd(finGenleg.getAmountCrUsd());
-									finVouchersItems.setAmountDr(finVouchersItems.getAmountDrUsd().multiply(periodExchangeRate.getExrate()));
+								if (new BigDecimal("0.00").compareTo(finGenleg.getAmountDr()) != 0) {
+									finVouchersItems.setAmountDr(finGenleg.getAmountDr());
+									finVouchersItems.setAmountDrLoc(finGenleg.getAmountDr());
+									finVouchersItems.setAmountCrUsd(new BigDecimal("0.00"));
+									finVouchersItems.setAmountCr(new BigDecimal("0.00"));
+									finVouchersItems.setAmountCrLoc(new BigDecimal("0.00"));
+									finVouchersItems.setAmountDrUsd(new BigDecimal("0.00"));
 								} else {
 									continue;
 								}
 							}
 						} else {
-							finVouchersItems.setExrate(new BigDecimal("1"));
-							if ("D".equals(item.getDc())) {
-								if (new BigDecimal("0.00").compareTo(finGenleg.getAmountDrUsd()) != 0) {
-									finVouchersItems.setAmountCr(finGenleg.getAmountDrUsd());
+							if (!"CNY".equals(item.getCurCode())) {
+								finVouchersItems.setExrate(periodExchangeRate.getExrate());
+								if ("D".equals(item.getDc())) {
+									if (new BigDecimal("0.00").compareTo(finGenleg.getAmountDrUsd()) != 0) {
+										finVouchersItems.setAmountCrUsd(finGenleg.getAmountDrUsd());
+										finVouchersItems.setAmountCr(finVouchersItems.getAmountCrUsd().multiply(periodExchangeRate.getExrate()));
+										finVouchersItems.setAmountCrLoc(finVouchersItems.getAmountCrUsd().multiply(periodExchangeRate.getExrate()));
+										finVouchersItems.setAmountDrUsd(new BigDecimal("0.00"));
+										finVouchersItems.setAmountDr(new BigDecimal("0.00"));
+										finVouchersItems.setAmountDrLoc(new BigDecimal("0.00"));
+									} else {
+										continue;
+									}
 								} else {
-									continue;
+									if (new BigDecimal("0.00").compareTo(finGenleg.getAmountCrUsd()) != 0) {
+										finVouchersItems.setAmountDrUsd(finGenleg.getAmountCrUsd());
+										finVouchersItems.setAmountDr(finVouchersItems.getAmountDrUsd().multiply(periodExchangeRate.getExrate()));
+										finVouchersItems.setAmountDrLoc(finVouchersItems.getAmountDrUsd().multiply(periodExchangeRate.getExrate()));
+										finVouchersItems.setAmountCrUsd(new BigDecimal("0.00"));
+										finVouchersItems.setAmountCr(new BigDecimal("0.00"));
+										finVouchersItems.setAmountCrLoc(new BigDecimal("0.00"));
+									} else {
+										continue;
+									}
 								}
 							} else {
-								if (new BigDecimal("0.00").compareTo(finGenleg.getAmountCrUsd()) != 0) {
-									finVouchersItems.setAmountDr(finGenleg.getAmountCrUsd());
+								finVouchersItems.setExrate(new BigDecimal("1"));
+								if ("D".equals(item.getDc())) {
+									if (new BigDecimal("0.00").compareTo(finGenleg.getAmountDr()) != 0) {
+										finVouchersItems.setAmountCr(finGenleg.getAmountDr());
+										finVouchersItems.setAmountCrLoc(finGenleg.getAmountDr());
+										finVouchersItems.setAmountDrUsd(new BigDecimal("0.00"));
+										finVouchersItems.setAmountDr(new BigDecimal("0.00"));
+										finVouchersItems.setAmountDrLoc(new BigDecimal("0.00"));
+										finVouchersItems.setAmountCrUsd(new BigDecimal("0.00"));
+									} else {
+										continue;
+									}
 								} else {
-									continue;
+									if (new BigDecimal("0.00").compareTo(finGenleg.getAmountCr()) != 0) {
+										finVouchersItems.setAmountDr(finGenleg.getAmountCr());
+										finVouchersItems.setAmountDrLoc(finGenleg.getAmountCr());
+										finVouchersItems.setAmountCrUsd(new BigDecimal("0.00"));
+										finVouchersItems.setAmountCr(new BigDecimal("0.00"));
+										finVouchersItems.setAmountCrLoc(new BigDecimal("0.00"));
+										finVouchersItems.setAmountDrUsd(new BigDecimal("0.00"));
+									} else {
+										continue;
+									}
 								}
 							}
 						}
@@ -1190,6 +1312,7 @@ public class FinPeriodServiceImpl extends ServiceImpl<FinPeriodMapper, FinPeriod
 		} else {
 			throw new RuntimeException("未找到对应科目信息");
 		}
+
 		BigDecimal amountDrCNY = new BigDecimal("0.00");
 		BigDecimal amountCrCNY = new BigDecimal("0.00");
 		BigDecimal amountDrUSD = new BigDecimal("0.00");
@@ -1197,27 +1320,34 @@ public class FinPeriodServiceImpl extends ServiceImpl<FinPeriodMapper, FinPeriod
 		BigDecimal amountDrLoc = new BigDecimal("0.00");
 		BigDecimal amountCrLoc = 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));
+			.filter(e -> "CNY".equals(e.getCurCode()) && "D".equals(e.getDc()))
+			.map(FinVouchersItems::getAmountDr).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));
+			.filter(e -> "CNY".equals(e.getCurCode()) && "C".equals(e.getDc()))
+			.map(FinVouchersItems::getAmountCr).filter(ObjectUtils::isNotNull)
+			.reduce(BigDecimal.ZERO, BigDecimal::add));
 		amountDrUSD = amountDrUSD.add(finVouchersItemsList.stream()
-			.filter(e -> !"CNY".equals(e.getCurCode()) && "D".equals(e.getDc())).map(FinVouchersItems::getAmountDrUsd)
+			.filter(e -> !"CNY".equals(e.getCurCode()) && "D".equals(e.getDc()))
+			.map(FinVouchersItems::getAmountDrUsd)
 			.filter(ObjectUtils::isNotNull).reduce(BigDecimal.ZERO, BigDecimal::add));
 		amountCrUSD = amountCrUSD.add(finVouchersItemsList.stream()
-			.filter(e -> !"CNY".equals(e.getCurCode()) && "C".equals(e.getDc())).map(FinVouchersItems::getAmountCrUsd)
+			.filter(e -> !"CNY".equals(e.getCurCode()) && "C".equals(e.getDc()))
+			.map(FinVouchersItems::getAmountCrUsd)
 			.filter(ObjectUtils::isNotNull).reduce(BigDecimal.ZERO, BigDecimal::add));
 		amountDrLoc = amountDrLoc.add(finVouchersItemsList.stream()
-			.filter(e -> "D".equals(e.getDc())).map(FinVouchersItems::getAmountDrLoc)
+			.filter(e -> "D".equals(e.getDc()))
+			.map(FinVouchersItems::getAmountDrLoc)
 			.filter(ObjectUtils::isNotNull).reduce(BigDecimal.ZERO, BigDecimal::add));
 		amountCrLoc = amountCrLoc.add(finVouchersItemsList.stream()
-			.filter(e -> "C".equals(e.getDc())).map(FinVouchersItems::getAmountCrLoc)
+			.filter(e -> "C".equals(e.getDc()))
+			.map(FinVouchersItems::getAmountCrLoc)
 			.filter(ObjectUtils::isNotNull).reduce(BigDecimal.ZERO, BigDecimal::add));
 		finVouchers.setDescr(periodVouchersTemplate.getDescr());
 		if (finVouchersItemsList.stream().anyMatch(e -> !"CNY".equals(e.getCurCode()))) {
 			finVouchers.setIsForeign(1);
 		}
+
 		FinVouchersItems finVouchersItems = new FinVouchersItems();
 		finVouchersItems.setCreateTime(new Date());
 		finVouchersItems.setCreateUser(AuthUtil.getUserId());
@@ -1235,6 +1365,7 @@ public class FinPeriodServiceImpl extends ServiceImpl<FinPeriodMapper, FinPeriod
 		finVouchersItems.setAccountYear(finVouchers.getAccountYear());
 		finVouchersItems.setAccountMonth(finVouchers.getAccountMonth());
 		finVouchersItems.setAccountDay(finVouchers.getAccountDay());
+		finVouchersItems.setExrate(new BigDecimal("1.00"));
 		Accounts accounts = accountsService.getById(periodVouchersTemplate.getPlAccID());
 		if (accounts == null) {
 			throw new RuntimeException("科目:" + periodVouchersTemplate.getPlAccCnm() + "不存在");
@@ -1247,28 +1378,48 @@ public class FinPeriodServiceImpl extends ServiceImpl<FinPeriodMapper, FinPeriod
 		finVouchersItems.setAccountLevel(accounts.getLevel());
 		finVouchersItems.setDc(accounts.getDc());
 		finVouchersItems.setCurCode(accounts.getCurCode());
+		finVouchersItems.setAmountDrUsd(new BigDecimal("0.00"));
+		finVouchersItems.setAmountCrUsd(new BigDecimal("0.00"));
 		if (!"CNY".equals(accounts.getCurCode())) {
 			throw new RuntimeException("科目:" + periodVouchersTemplate.getPlAccCnm() + "币别不是CNY");
 		}
-		if ("FM-CURRENCY-PL-TRANSFER".equals(periodVouchersTemplate.getBsType())) {
-			BigDecimal subtract = amountDrLoc.subtract(amountCrLoc);
-			if ("D".equals(accounts.getDc())) {
-				finVouchersItems.setAmountDr(subtract);
-				finVouchersItems.setAmountDrLoc(subtract);
-			} else {
-				finVouchersItems.setAmountCr(subtract);
-				finVouchersItems.setAmountCrLoc(subtract);
-			}
+
+		BigDecimal subtract = amountDrLoc.subtract(amountCrLoc);
+		if ("D".equals(accounts.getDc())) {
+			finVouchersItems.setAmountDr(subtract);
+			finVouchersItems.setAmountDrLoc(subtract);
+			finVouchersItems.setAmountCr(new BigDecimal("0.00"));
+			finVouchersItems.setAmountDrUsd(new BigDecimal("0.00"));
+			finVouchersItems.setAmountCrUsd(new BigDecimal("0.00"));
+			finVouchersItems.setAmountCrLoc(new BigDecimal("0.00"));
 		} else {
+			finVouchersItems.setAmountCr(subtract);
+			finVouchersItems.setAmountCrLoc(subtract);
+			finVouchersItems.setAmountCrUsd(new BigDecimal("0.00"));
+			finVouchersItems.setAmountDr(new BigDecimal("0.00"));
+			finVouchersItems.setAmountDrUsd(new BigDecimal("0.00"));
+			finVouchersItems.setAmountDrLoc(new BigDecimal("0.00"));
+		}
+		/*} else {
 			BigDecimal subtract = amountDrLoc.subtract(amountCrLoc);
 			if ("D".equals(accounts.getDc())) {
 				finVouchersItems.setAmountCr(subtract);
 				finVouchersItems.setAmountCrLoc(subtract);
+
+				finVouchersItems.setAmountCrUsd(new BigDecimal("0.00"));
+				finVouchersItems.setAmountDr(new BigDecimal("0.00"));
+				finVouchersItems.setAmountDrUsd(new BigDecimal("0.00"));
+				finVouchersItems.setAmountDrLoc(new BigDecimal("0.00"));
 			} else {
 				finVouchersItems.setAmountDr(subtract);
 				finVouchersItems.setAmountDrLoc(subtract);
+
+				finVouchersItems.setAmountDrUsd(new BigDecimal("0.00"));
+				finVouchersItems.setAmountCr(new BigDecimal("0.00"));
+				finVouchersItems.setAmountCrUsd(new BigDecimal("0.00"));
+				finVouchersItems.setAmountCrLoc(new BigDecimal("0.00"));
 			}
-		}
+		}*/
 		finVouchersItemsList.add(finVouchersItems);
 		finVouchers.setAmountDr(amountDrCNY.add(finVouchersItems.getAmountDr()));
 		finVouchers.setAmountCr(amountCrCNY.add(finVouchersItems.getAmountCr()));

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

@@ -51,6 +51,8 @@ import org.springblade.los.finance.fee.entity.ListAccBillVO;
 import org.springblade.los.finance.fee.service.IFeeCenterService;
 import org.springblade.los.finance.fee.service.IFinAccBillsService;
 import org.springblade.los.finance.fee.vo.FinAccBillsVO;
+import org.springblade.los.finance.genleg.entity.FinPeriod;
+import org.springblade.los.finance.genleg.mapper.FinPeriodMapper;
 import org.springblade.los.finance.invoices.entity.FinInvoices;
 import org.springblade.los.finance.invoices.entity.FinInvoicesItems;
 import org.springblade.los.finance.invoices.mapper.FinInvoicesItemsMapper;
@@ -81,6 +83,7 @@ import java.math.MathContext;
 import java.math.RoundingMode;
 import java.text.SimpleDateFormat;
 import java.time.LocalDate;
+import java.time.ZoneId;
 import java.util.ArrayList;
 import java.util.Date;
 import java.util.List;
@@ -137,6 +140,8 @@ public class FinStlBillsServiceImpl extends ServiceImpl<FinStlBillsMapper, FinSt
 
 	private final IAccountsService accountsService;
 
+	private final FinPeriodMapper finPeriodMapper;
+
 	@Override
 	public IPage<FinStlBillsVO> selectFinStlBillsPage(IPage<FinStlBillsVO> page, FinStlBillsVO finStlBills) {
 		return page.setRecords(baseMapper.selectFinStlBillsPage(page, finStlBills));
@@ -176,6 +181,24 @@ public class FinStlBillsServiceImpl extends ServiceImpl<FinStlBillsMapper, FinSt
 				deptName = String.join(",", res.getData());
 			}
 		}
+		if (ObjectUtils.isNotNull(finStlBills.getBillDate()) && "STL".equals(finStlBills.getBusinessType())) {
+			LocalDate date = finStlBills.getBillDate().toInstant().atZone(ZoneId.systemDefault()).toLocalDate();
+			int year = date.getYear();
+			int month = date.getMonthValue();
+			FinPeriod finPeriod = finPeriodMapper.selectOne(new LambdaQueryWrapper<FinPeriod>()
+				.eq(FinPeriod::getTenantId, AuthUtil.getTenantId())
+				.eq(FinPeriod::getIsDeleted, 0)
+				.eq(FinPeriod::getPeriodYear, year)
+				.eq(FinPeriod::getPeriodMonth, month));
+			if (finPeriod != null) {
+				if (1 == finPeriod.getIsClosed()) {
+					throw new RuntimeException(year + "年" + month + "月账期已结转,保存失败");
+				}
+				if (1 == finPeriod.getLockingStatus()) {
+					throw new RuntimeException(year + "年" + month + "月账期已锁定,保存失败");
+				}
+			}
+		}
 		if (finStlBills.getId() == null) {
 			BusinessType businessType = bBusinessTypeService.getOne(new LambdaQueryWrapper<BusinessType>()
 				.eq(BusinessType::getTenantId, AuthUtil.getTenantId())

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

@@ -39,6 +39,8 @@ import org.springblade.los.finance.fee.service.IFeeCenterService;
 import org.springblade.los.finance.fee.service.IFinAccBillsService;
 import org.springblade.los.finance.genleg.entity.FinGenleg;
 import org.springblade.los.finance.genleg.entity.FinGenlegCalc;
+import org.springblade.los.finance.genleg.entity.FinPeriod;
+import org.springblade.los.finance.genleg.mapper.FinPeriodMapper;
 import org.springblade.los.finance.genleg.service.IFinGenlegCalcService;
 import org.springblade.los.finance.genleg.service.IFinGenlegService;
 import org.springblade.los.finance.vouchers.entity.FinVouchers;
@@ -54,6 +56,7 @@ import org.springframework.transaction.interceptor.TransactionAspectSupport;
 
 import java.math.BigDecimal;
 import java.time.LocalDate;
+import java.time.ZoneId;
 import java.util.ArrayList;
 import java.util.Date;
 import java.util.List;
@@ -92,6 +95,8 @@ public class FinVouchersServiceImpl extends ServiceImpl<FinVouchersMapper, FinVo
 
 	private final IFinGenlegCalcService finGenlegCalcService;
 
+	private final FinPeriodMapper finPeriodMapper;
+
 	@Override
 	public IPage<FinVouchersVO> selectFinVouchersPage(IPage<FinVouchersVO> page, FinVouchersVO finVouchers) {
 		return page.setRecords(baseMapper.selectFinVouchersPage(page, finVouchers));
@@ -126,6 +131,24 @@ public class FinVouchersServiceImpl extends ServiceImpl<FinVouchersMapper, FinVo
 				deptName = String.join(",", res.getData());
 			}
 		}
+		if (ObjectUtils.isNotNull(finVouchers.getVoucherDate())) {
+			LocalDate date = finVouchers.getVoucherDate().toInstant().atZone(ZoneId.systemDefault()).toLocalDate();
+			int year = date.getYear();
+			int month = date.getMonthValue();
+			FinPeriod finPeriod = finPeriodMapper.selectOne(new LambdaQueryWrapper<FinPeriod>()
+				.eq(FinPeriod::getTenantId, AuthUtil.getTenantId())
+				.eq(FinPeriod::getIsDeleted, 0)
+				.eq(FinPeriod::getPeriodYear, year)
+				.eq(FinPeriod::getPeriodMonth, month));
+			if (finPeriod != null) {
+				if (1 == finPeriod.getIsClosed()) {
+					throw new RuntimeException(year + "年" + month + "月账期已结转,保存失败");
+				}
+				if (1 == finPeriod.getLockingStatus()) {
+					throw new RuntimeException(year + "年" + month + "月账期已锁定,保存失败");
+				}
+			}
+		}
 		if (finVouchers.getId() == null) {
 			BusinessType businessType = bBusinessTypeService.getOne(new LambdaQueryWrapper<BusinessType>()
 				.eq(BusinessType::getTenantId, AuthUtil.getTenantId())
@@ -624,38 +647,56 @@ public class FinVouchersServiceImpl extends ServiceImpl<FinVouchersMapper, FinVo
 		BigDecimal amountYearCrUsd = finGenleg.getAmountYearCrUsd();
 		//本期外币余额
 		BigDecimal amountUsdBlc;
-		if ("CNY".equals(item.getCurCode())) {
-			if ("D".equals(item.getDc())) {
-				//本期本币借方金额(CNY)
-				amountDr = amountDr.add(item.getAmountDr());
-				//本年本币借方金额(CNY)
-				amountYearDr = amountYearDr.add(item.getAmountDr());
-			} else {
-				//本期本币贷方金额(CNY)
-				amountCr = amountCr.add(item.getAmountCr());
-				//本年本币贷方金额(CNY)
-				amountYearCr = amountYearCr.add(item.getAmountCr());
-			}
-		} else {
-			if ("D".equals(item.getDc())) {
-				//本期本币借方金额(CNY)
-				amountDrUsd = amountDrUsd.add(item.getAmountDrUsd());
-				//本年本币借方金额(CNY)
-				amountYearDrUsd = amountYearDrUsd.add(item.getAmountDrUsd());
-				//本期本币借方金额(CNY)
-				amountDr = amountDr.add(item.getAmountDrUsd().multiply(item.getExrate()));
-				//本年本币借方金额(CNY)
-				amountYearDr = amountYearDr.add(item.getAmountDrUsd().multiply(item.getExrate()));
-			} else {
-				//本期本币贷方金额(CNY)
-				amountCrUsd = amountCrUsd.add(item.getAmountCrUsd());
-				//本年本币贷方金额(CNY)
-				amountYearCrUsd = amountYearCrUsd.add(item.getAmountCrUsd());
-				//本期本币贷方金额(CNY)
-				amountCr = amountCr.add(item.getAmountCrUsd().multiply(item.getExrate()));
-				//本年本币贷方金额(CNY)
-				amountYearCr = amountYearCr.add(item.getAmountCrUsd().multiply(item.getExrate()));
-			}
+		if ("550303".equals(accounts.getCode())) {
+			//本期本币借方金额(CNY)
+			amountDr = amountDr.add(item.getAmountCr());
+			//本年本币借方金额(CNY)
+			amountYearDr = amountYearDr.add(item.getAmountCr());
+			//本期本币贷方金额(CNY)
+			amountCr = amountCr.add(item.getAmountDr());
+			//本年本币贷方金额(CNY)
+			amountYearCr = amountYearCr.add(item.getAmountDr());
+			//本期本币借方金额(CNY)
+			amountDrUsd = amountDrUsd.add(item.getAmountCrUsd());
+			//本年本币借方金额(CNY)
+			amountYearDrUsd = amountYearDrUsd.add(item.getAmountCrUsd());
+			//本期本币借方金额(CNY)
+			amountDr = amountDr.add(item.getAmountCrUsd().multiply(item.getExrate()));
+			//本年本币借方金额(CNY)
+			amountYearDr = amountYearDr.add(item.getAmountCrUsd().multiply(item.getExrate()));
+			//本期本币贷方金额(CNY)
+			amountCrUsd = amountCrUsd.add(item.getAmountDrUsd());
+			//本年本币贷方金额(CNY)
+			amountYearCrUsd = amountYearCrUsd.add(item.getAmountDrUsd());
+			//本期本币贷方金额(CNY)
+			amountCr = amountCr.add(item.getAmountDrUsd().multiply(item.getExrate()));
+			//本年本币贷方金额(CNY)
+			amountYearCr = amountYearCr.add(item.getAmountDrUsd().multiply(item.getExrate()));
+		}else{
+			//本期本币借方金额(CNY)
+			amountDr = amountDr.add(item.getAmountDr());
+			//本年本币借方金额(CNY)
+			amountYearDr = amountYearDr.add(item.getAmountDr());
+			//本期本币贷方金额(CNY)
+			amountCr = amountCr.add(item.getAmountCr());
+			//本年本币贷方金额(CNY)
+			amountYearCr = amountYearCr.add(item.getAmountCr());
+			//本期本币借方金额(CNY)
+			amountDrUsd = amountDrUsd.add(item.getAmountDrUsd());
+			//本年本币借方金额(CNY)
+			amountYearDrUsd = amountYearDrUsd.add(item.getAmountDrUsd());
+			//本期本币借方金额(CNY)
+			amountDr = amountDr.add(item.getAmountDrUsd().multiply(item.getExrate()));
+			//本年本币借方金额(CNY)
+			amountYearDr = amountYearDr.add(item.getAmountDrUsd().multiply(item.getExrate()));
+			//本期本币贷方金额(CNY)
+			amountCrUsd = amountCrUsd.add(item.getAmountCrUsd());
+			//本年本币贷方金额(CNY)
+			amountYearCrUsd = amountYearCrUsd.add(item.getAmountCrUsd());
+			//本期本币贷方金额(CNY)
+			amountCr = amountCr.add(item.getAmountCrUsd().multiply(item.getExrate()));
+			//本年本币贷方金额(CNY)
+			amountYearCr = amountYearCr.add(item.getAmountCrUsd().multiply(item.getExrate()));
 		}
 		if ("D".equals(finGenleg.getDc())) {
 			amountBlc = amountLastBlc.add(amountDr).subtract(amountCr);
@@ -791,39 +832,31 @@ public class FinVouchersServiceImpl extends ServiceImpl<FinVouchersMapper, FinVo
 		BigDecimal amountYearCrUsdCalc = finGenlegCalc.getAmountYearCrUsd();
 		//本期外币余额
 		BigDecimal amountUsdBlcCalc;
-		if ("CNY".equals(item.getCurCode())) {
-			if ("D".equals(accounts.getDc())) {
-				//本期本币借方金额(CNY)
-				amountDrCalc = amountDrCalc.add(item.getAmountDr());
-				//本年本币借方金额(CNY)
-				amountYearDrCalc = amountYearDrCalc.add(item.getAmountDr());
-			} else {
-				//本期本币贷方金额(CNY)
-				amountCrCalc = amountCrCalc.add(item.getAmountCr());
-				//本年本币贷方金额(CNY)
-				amountYearCrCalc = amountYearCrCalc.add(item.getAmountCr());
-			}
-		} else {
-			if ("D".equals(accounts.getDc())) {
-				//本期本币借方金额(USD)
-				amountDrUsdCalc = amountDrUsdCalc.add(item.getAmountDrUsd());
-				//本期本币借方金额(CNY)
-				amountDrCalc = amountDrCalc.add(item.getAmountDrUsd().multiply(item.getExrate()));
-				//本年本币借方金额(USD)
-				amountYearDrUsdCalc = amountYearDrUsdCalc.add(item.getAmountDrUsd());
-				//本年本币借方金额(CNY)
-				amountYearDrCalc = amountYearDrCalc.add(item.getAmountDrUsd().multiply(item.getExrate()));
-			} else {
-				//本期本币贷方金额(USD)
-				amountCrUsdCalc = amountCrUsdCalc.add(item.getAmountCrUsd());
-				//本年本币贷方金额(USD)
-				amountYearCrUsdCalc = amountYearCrUsdCalc.add(item.getAmountCrUsd());
-				//本期本币贷方金额(CNY)
-				amountCrCalc = amountCrCalc.add(item.getAmountCrUsd().multiply(item.getExrate()));
-				//本年本币贷方金额(CNY)
-				amountYearCrCalc = amountYearCrCalc.add(item.getAmountCrUsd().multiply(item.getExrate()));
-			}
-		}
+
+		//本期本币借方金额(CNY)
+		amountDrCalc = amountDrCalc.add(item.getAmountDr());
+		//本年本币借方金额(CNY)
+		amountYearDrCalc = amountYearDrCalc.add(item.getAmountDr());
+		//本期本币贷方金额(CNY)
+		amountCrCalc = amountCrCalc.add(item.getAmountCr());
+		//本年本币贷方金额(CNY)
+		amountYearCrCalc = amountYearCrCalc.add(item.getAmountCr());
+		//本期本币借方金额(USD)
+		amountDrUsdCalc = amountDrUsdCalc.add(item.getAmountDrUsd());
+		//本期本币借方金额(CNY)
+		amountDrCalc = amountDrCalc.add(item.getAmountDrUsd().multiply(item.getExrate()));
+		//本年本币借方金额(USD)
+		amountYearDrUsdCalc = amountYearDrUsdCalc.add(item.getAmountDrUsd());
+		//本年本币借方金额(CNY)
+		amountYearDrCalc = amountYearDrCalc.add(item.getAmountDrUsd().multiply(item.getExrate()));
+		//本期本币贷方金额(USD)
+		amountCrUsdCalc = amountCrUsdCalc.add(item.getAmountCrUsd());
+		//本年本币贷方金额(USD)
+		amountYearCrUsdCalc = amountYearCrUsdCalc.add(item.getAmountCrUsd());
+		//本期本币贷方金额(CNY)
+		amountCrCalc = amountCrCalc.add(item.getAmountCrUsd().multiply(item.getExrate()));
+		//本年本币贷方金额(CNY)
+		amountYearCrCalc = amountYearCrCalc.add(item.getAmountCrUsd().multiply(item.getExrate()));
 		if ("D".equals(accounts.getDc())) {
 			amountBlcCalc = amountLastBlcCalc.add(amountDrCalc).subtract(amountCrCalc);
 			amountUsdBlcCalc = amountLastBlcCalc.add(amountDrUsdCalc).subtract(amountCrUsdCalc);
@@ -892,38 +925,56 @@ public class FinVouchersServiceImpl extends ServiceImpl<FinVouchersMapper, FinVo
 		BigDecimal amountYearCrUsd = finGenleg.getAmountYearCrUsd();
 		//本期外币余额
 		BigDecimal amountUsdBlc;
-		if ("CNY".equals(item.getCurCode())) {
-			if ("D".equals(item.getDc())) {
-				//本期本币借方金额(CNY)
-				amountDr = amountDr.subtract(item.getAmountDr());
-				//本年本币借方金额(CNY)
-				amountYearDr = amountYearDr.subtract(item.getAmountDr());
-			} else {
-				//本期本币贷方金额(CNY)
-				amountCr = amountCr.subtract(item.getAmountCr());
-				//本年本币贷方金额(CNY)
-				amountYearCr = amountYearCr.subtract(item.getAmountCr());
-			}
-		} else {
-			if ("D".equals(item.getDc())) {
-				//本期本币借方金额(CNY)
-				amountDrUsd = amountDrUsd.subtract(item.getAmountDrUsd());
-				//本年本币借方金额(CNY)
-				amountYearDrUsd = amountYearDrUsd.subtract(item.getAmountDrUsd());
-				//本期本币借方金额(CNY)
-				amountDr = amountDr.subtract(item.getAmountDrUsd().multiply(item.getExrate()));
-				//本年本币借方金额(CNY)
-				amountYearDr = amountYearDr.subtract(item.getAmountDrUsd().multiply(item.getExrate()));
-			} else {
-				//本期本币贷方金额(CNY)
-				amountCrUsd = amountCrUsd.subtract(item.getAmountCrUsd());
-				//本年本币贷方金额(CNY)
-				amountYearCrUsd = amountYearCrUsd.subtract(item.getAmountCrUsd());
-				//本期本币贷方金额(CNY)
-				amountCr = amountCr.subtract(item.getAmountCrUsd().multiply(item.getExrate()));
-				//本年本币贷方金额(CNY)
-				amountYearCr = amountYearCr.subtract(item.getAmountCrUsd().multiply(item.getExrate()));
-			}
+		if ("550303".equals(accounts.getCode())) {
+			//本期本币借方金额(CNY)
+			amountDr = amountDr.subtract(item.getAmountCr());
+			//本年本币借方金额(CNY)
+			amountYearDr = amountYearDr.subtract(item.getAmountCr());
+			//本期本币贷方金额(CNY)
+			amountCr = amountCr.subtract(item.getAmountDr());
+			//本年本币贷方金额(CNY)
+			amountYearCr = amountYearCr.subtract(item.getAmountDr());
+			//本期本币借方金额(CNY)
+			amountDrUsd = amountDrUsd.subtract(item.getAmountCrUsd());
+			//本年本币借方金额(CNY)
+			amountYearDrUsd = amountYearDrUsd.subtract(item.getAmountCrUsd());
+			//本期本币借方金额(CNY)
+			amountDr = amountDr.subtract(item.getAmountCrUsd().multiply(item.getExrate()));
+			//本年本币借方金额(CNY)
+			amountYearDr = amountYearDr.subtract(item.getAmountCrUsd().multiply(item.getExrate()));
+			//本期本币贷方金额(CNY)
+			amountCrUsd = amountCrUsd.subtract(item.getAmountDrUsd());
+			//本年本币贷方金额(CNY)
+			amountYearCrUsd = amountYearCrUsd.subtract(item.getAmountDrUsd());
+			//本期本币贷方金额(CNY)
+			amountCr = amountCr.subtract(item.getAmountDrUsd().multiply(item.getExrate()));
+			//本年本币贷方金额(CNY)
+			amountYearCr = amountYearCr.subtract(item.getAmountDrUsd().multiply(item.getExrate()));
+		}else{
+			//本期本币借方金额(CNY)
+			amountDr = amountDr.subtract(item.getAmountDr());
+			//本年本币借方金额(CNY)
+			amountYearDr = amountYearDr.subtract(item.getAmountDr());
+			//本期本币贷方金额(CNY)
+			amountCr = amountCr.subtract(item.getAmountCr());
+			//本年本币贷方金额(CNY)
+			amountYearCr = amountYearCr.subtract(item.getAmountCr());
+			//本期本币借方金额(CNY)
+			amountDrUsd = amountDrUsd.subtract(item.getAmountDrUsd());
+			//本年本币借方金额(CNY)
+			amountYearDrUsd = amountYearDrUsd.subtract(item.getAmountDrUsd());
+			//本期本币借方金额(CNY)
+			amountDr = amountDr.subtract(item.getAmountDrUsd().multiply(item.getExrate()));
+			//本年本币借方金额(CNY)
+			amountYearDr = amountYearDr.subtract(item.getAmountDrUsd().multiply(item.getExrate()));
+			//本期本币贷方金额(CNY)
+			amountCrUsd = amountCrUsd.subtract(item.getAmountCrUsd());
+			//本年本币贷方金额(CNY)
+			amountYearCrUsd = amountYearCrUsd.subtract(item.getAmountCrUsd());
+			//本期本币贷方金额(CNY)
+			amountCr = amountCr.subtract(item.getAmountCrUsd().multiply(item.getExrate()));
+			//本年本币贷方金额(CNY)
+			amountYearCr = amountYearCr.subtract(item.getAmountCrUsd().multiply(item.getExrate()));
 		}
 		if ("D".equals(finGenleg.getDc())) {
 			amountBlc = amountLastBlc.subtract(amountDr).add(amountCr);
@@ -986,39 +1037,30 @@ public class FinVouchersServiceImpl extends ServiceImpl<FinVouchersMapper, FinVo
 		BigDecimal amountYearCrUsdCalc = finGenlegCalc.getAmountYearCrUsd();
 		//本期外币余额
 		BigDecimal amountUsdBlcCalc;
-		if ("CNY".equals(item.getCurCode())) {
-			if ("D".equals(item.getDc())) {
-				//本期本币借方金额(CNY)
-				amountDrCalc = amountDrCalc.subtract(item.getAmountDr());
-				//本年本币借方金额(CNY)
-				amountYearDrCalc = amountYearDrCalc.subtract(item.getAmountDr());
-			} else {
-				//本期本币贷方金额(CNY)
-				amountCrCalc = amountCrCalc.subtract(item.getAmountCr());
-				//本年本币贷方金额(CNY)
-				amountYearCrCalc = amountYearCrCalc.subtract(item.getAmountCr());
-			}
-		} else {
-			if ("D".equals(item.getDc())) {
-				//本期本币借方金额(CNY)
-				amountDrUsdCalc = amountDrUsdCalc.subtract(item.getAmountDrUsd());
-				//本年本币借方金额(CNY)
-				amountYearDrUsdCalc = amountYearDrUsdCalc.subtract(item.getAmountDrUsd());
-				//本期本币借方金额(CNY)
-				amountDrCalc = amountDrCalc.subtract(item.getAmountDrUsd().multiply(item.getExrate()));
-				//本年本币借方金额(CNY)
-				amountYearDrCalc = amountYearDrCalc.subtract(item.getAmountDrUsd().multiply(item.getExrate()));
-			} else {
-				//本期本币贷方金额(CNY)
-				amountCrUsdCalc = amountCrUsdCalc.subtract(item.getAmountCrUsd());
-				//本年本币贷方金额(CNY)
-				amountYearCrUsdCalc = amountYearCrUsdCalc.subtract(item.getAmountCrUsd());
-				//本期本币贷方金额(CNY)
-				amountCrCalc = amountCrCalc.subtract(item.getAmountCrUsd().multiply(item.getExrate()));
-				//本年本币贷方金额(CNY)
-				amountYearCrCalc = amountYearCrCalc.subtract(item.getAmountCrUsd().multiply(item.getExrate()));
-			}
-		}
+		//本期本币借方金额(CNY)
+		amountDrCalc = amountDrCalc.subtract(item.getAmountDr());
+		//本年本币借方金额(CNY)
+		amountYearDrCalc = amountYearDrCalc.subtract(item.getAmountDr());
+		//本期本币贷方金额(CNY)
+		amountCrCalc = amountCrCalc.subtract(item.getAmountCr());
+		//本年本币贷方金额(CNY)
+		amountYearCrCalc = amountYearCrCalc.subtract(item.getAmountCr());
+		//本期本币借方金额(CNY)
+		amountDrUsdCalc = amountDrUsdCalc.subtract(item.getAmountDrUsd());
+		//本年本币借方金额(CNY)
+		amountYearDrUsdCalc = amountYearDrUsdCalc.subtract(item.getAmountDrUsd());
+		//本期本币借方金额(CNY)
+		amountDrCalc = amountDrCalc.subtract(item.getAmountDrUsd().multiply(item.getExrate()));
+		//本年本币借方金额(CNY)
+		amountYearDrCalc = amountYearDrCalc.subtract(item.getAmountDrUsd().multiply(item.getExrate()));
+		//本期本币贷方金额(CNY)
+		amountCrUsdCalc = amountCrUsdCalc.subtract(item.getAmountCrUsd());
+		//本年本币贷方金额(CNY)
+		amountYearCrUsdCalc = amountYearCrUsdCalc.subtract(item.getAmountCrUsd());
+		//本期本币贷方金额(CNY)
+		amountCrCalc = amountCrCalc.subtract(item.getAmountCrUsd().multiply(item.getExrate()));
+		//本年本币贷方金额(CNY)
+		amountYearCrCalc = amountYearCrCalc.subtract(item.getAmountCrUsd().multiply(item.getExrate()));
 		if ("D".equals(accounts.getDc())) {
 			amountBlcCalc = amountLastBlcCalc.subtract(amountDrCalc).add(amountCrCalc);
 			amountUsdBlcCalc = amountLastBlcUsdCalc.subtract(amountDrUsdCalc).add(amountCrUsdCalc);
@@ -1128,7 +1170,7 @@ public class FinVouchersServiceImpl extends ServiceImpl<FinVouchersMapper, FinVo
 									(1 == accounts.getIsCorp() && e.getIsCorp().equals(item.getIsCorp()))))
 								.findFirst().orElse(null);
 							finGenlegCalc = revokeGenlegAccountingFinGenlegCalc(accounts, item, finGenlegCalc);
-							if (ObjectUtils.isNotNull(finGenlegCalc)){
+							if (ObjectUtils.isNotNull(finGenlegCalc)) {
 								finGenlegCalcListNew.add(finGenlegCalc);
 							}
 						}
@@ -1245,12 +1287,74 @@ public class FinVouchersServiceImpl extends ServiceImpl<FinVouchersMapper, FinVo
 		}
 		finVouchers.setVoucherNo((String) voucherNo.getData());
 		finVouchers.setVoucherDate(new Date());
+		finVouchers.setStatus(3);
+		finVouchers.setVoucherStatus(1);
+		finVouchers.setPostUserId(AuthUtil.getUserId());
+		finVouchers.setPostUserName(AuthUtil.getUserName());
+		finVouchers.setPostTime(new Date());
 		this.saveOrUpdate(finVouchers);
 		if (ObjectUtils.isNotNull(finVouchers.getFinVouchersItemsList())) {
+			List<Accounts> accountsList = new ArrayList<>();
+			List<FinGenleg> finGenlegList = new ArrayList<>();
+			List<FinGenlegCalc> finGenlegCalcList = new ArrayList<>();
+			List<FinVouchersItems> finVouchersItemsListNew = new ArrayList<>();
+			if (ObjectUtils.isNotNull(finVouchers.getFinVouchersItemsList())) {
+				List<Long> accId = finVouchers.getFinVouchersItemsList().stream().map(FinVouchersItems::getAccountId).collect(Collectors.toList());
+				if (!accId.isEmpty()) {
+					accountsList = accountsService.list(new LambdaQueryWrapper<Accounts>()
+						.in(Accounts::getId, accId));
+					finGenlegList = finGenlegService.list(new LambdaQueryWrapper<FinGenleg>()
+						.in(FinGenleg::getAccId, accId));
+					finGenlegCalcList = finGenlegCalcService.list(new LambdaQueryWrapper<FinGenlegCalc>()
+						.in(FinGenlegCalc::getAccId, accId));
+				}
+			}
+			List<FinGenleg> finGenlegListNew = new ArrayList<>();
+			List<FinGenlegCalc> finGenlegCalcListNew = new ArrayList<>();
 			for (FinVouchersItems item : finVouchers.getFinVouchersItemsList()) {
 				item.setPid(finVouchers.getId());
+				Accounts accounts = accountsList.stream().filter(e -> e.getId().equals(item.getAccountId())).findFirst().orElse(null);
+				if (accounts != null) {
+					FinGenleg finGenleg = finGenlegList.stream().filter(e -> e.getAccId().equals(item.getAccountId()) &&
+						e.getAccyear().equals(item.getAccountYear()) && e.getAccmonth().equals(item.getAccountMonth())).findFirst().orElse(null);
+					FinGenlegCalc finGenlegCalc;
+					if (1 == accounts.getIsDept() || 1 == accounts.getIsCorp() || 1 == accounts.getIsEmpl()) {
+						finGenlegCalc = finGenlegCalcList.stream().filter(e -> e.getAccId().equals(item.getAccountId()) &&
+								e.getAccyear().equals(item.getAccountYear()) && e.getAccmonth().equals(item.getAccountMonth())
+								&& ((1 == accounts.getIsDept() && e.getDeptId().equals(item.getDeptId())) ||
+								(1 == accounts.getIsEmpl() && e.getIsEmpl().equals(item.getIsEmpl())) ||
+								(1 == accounts.getIsCorp() && e.getIsCorp().equals(item.getIsCorp()))))
+							.findFirst().orElse(null);
+						finGenlegCalc = genlegAccountingFinGenlegCalc(accounts, item, finGenlegCalc);
+						if (ObjectUtils.isNotNull(finGenlegCalc)) {
+							finGenlegCalcListNew.add(finGenlegCalc);
+						}
+					}
+					finGenleg = genlegAccountingFinGenleg(accounts, item, finGenleg);
+					if (ObjectUtils.isNotNull(finGenleg)) {
+						finGenlegListNew.add(finGenleg);
+					}
+					FinGenleg finalFinGenleg = finGenleg;
+					FinGenleg finGenlegP = finGenlegList.stream().filter(e -> e.getAccId().equals(finalFinGenleg.getParentId()) &&
+						e.getAccyear().equals(item.getAccountYear()) && e.getAccmonth().equals(item.getAccountMonth())).findFirst().orElse(null);
+					if (finGenlegP != null) {
+						List<FinGenleg> finGenlegs = new ArrayList<>();
+						genlegAccountingFor(item, finGenlegP, finGenlegList, finGenlegs);
+						if (!finGenlegs.isEmpty()) {
+							finGenlegListNew.addAll(finGenlegs);
+						}
+					}
+				}
+				item.setStatus(1);
+				item.setVoucherDate(finVouchers.getVoucherDate());
+				item.setUpdateUser(AuthUtil.getUserId());
+				item.setUpdateTime(new Date());
+				item.setUpdateUserName(AuthUtil.getUserName());
+				finVouchersItemsListNew.add(item);
 			}
-			finVouchersItemsService.saveOrUpdateBatch(finVouchers.getFinVouchersItemsList());
+			finVouchersItemsService.saveOrUpdateBatch(finVouchersItemsListNew);
+			finGenlegService.saveOrUpdateBatch(finGenlegListNew);
+			finGenlegCalcService.saveOrUpdateBatch(finGenlegCalcListNew);
 		}
 		return R.data(finVouchers);
 	}