Browse Source

2024年2月28日17:41:44

纪新园 1 year ago
parent
commit
5ccb4a33ec

+ 9 - 9
blade-service/blade-los/src/main/java/org/springblade/los/Util/RegularUtils.java

@@ -29,7 +29,7 @@ public class RegularUtils {
 		String code = "200";
 		String msg = "";
 		String susscess = "";
-		Pattern pattern = Pattern.compile("[^a-zA-Z0-9\\s]");
+		Pattern pattern = Pattern.compile("[^a-zA-Z0-9\\s]|\t");
 		Matcher matcher = pattern.matcher(data);
 		while (matcher.find()) {
 			String character = matcher.group();
@@ -44,7 +44,7 @@ public class RegularUtils {
 					"』".equals(character) || "〔".equals(character) || "〕".equals(character) || "【".equals(character) ||
 					"】".equals(character) || "¥".equals(character) || "£".equals(character) || "♀".equals(character) ||
 					"〖".equals(character) || "〗".equals(character) || "《".equals(character) || "》".equals(character) ||
-					"「".equals(character) || "」".equals(character)
+					"「".equals(character) || "」".equals(character) || "\t".equals(character)
 			) {
 				code = "500";
 				msg = "存在中文特殊字符:“" + character + "”";
@@ -651,7 +651,7 @@ public class RegularUtils {
 					} else if (regularLength(hipper, 140) && hipper.length() <= 175) {
 						inttraSoDto.setHsHipperFive(hipper.substring(140));
 					} else {
-						inttraSoDto.setHsHipperFive(hipper.substring( 174) + "*");
+						inttraSoDto.setHsHipperFive(hipper.substring(174) + "*");
 						if (ObjectUtils.isNotNull(inttraSoDto.getProductName())) {
 							inttraSoDto.setProductName(inttraSoDto.getProductName() + "*" + hipper.substring(174));
 						}
@@ -711,7 +711,7 @@ public class RegularUtils {
 					} else if (regularLength(hNotify, 140) && hNotify.length() <= 175) {
 						inttraSoDto.setHNotifyFive(hNotify.substring(140));
 					} else {
-						inttraSoDto.setHNotifyFive(hNotify.substring( 174) + "*");
+						inttraSoDto.setHNotifyFive(hNotify.substring(174) + "*");
 						if (ObjectUtils.isNotNull(inttraSoDto.getProductName())) {
 							inttraSoDto.setProductName(inttraSoDto.getProductName() + "***" + hNotify.substring(174));
 						}
@@ -1651,7 +1651,7 @@ public class RegularUtils {
 						text += inttraSoDto.getCarrySingleRemarks() + ";";
 					}
 					inttraSoDto.setRemarks(text);
-				}else if ("MAEU".equals(mapString.get("susscess"))) {
+				} else if ("MAEU".equals(mapString.get("susscess"))) {
 					String text = "";
 					if (ObjectUtils.isNotNull(inttraSoDto.getPaymentType())) {
 						if ("PP".equals(inttraSoDto.getPaymentType())) {
@@ -1684,7 +1684,7 @@ public class RegularUtils {
 						text += inttraSoDto.getCarrySingleRemarks() + ";";
 					}
 					inttraSoDto.setRemarks(text);
-				}else {
+				} else {
 					//备注
 					if (ObjectUtils.isNull(inttraSoDto.getRemarks())) {
 						msg += "备注,";
@@ -1842,7 +1842,7 @@ public class RegularUtils {
 					} else if (regularLength(hipper, 140) && hipper.length() <= 175) {
 						inttraSoDto.setHsHipperFive(hipper.substring(140));
 					} else {
-						inttraSoDto.setHsHipperFive(hipper.substring( 174) + "*");
+						inttraSoDto.setHsHipperFive(hipper.substring(174) + "*");
 						if (ObjectUtils.isNotNull(inttraSoDto.getProductName())) {
 							inttraSoDto.setProductName(inttraSoDto.getProductName() + "*" + hipper.substring(174));
 						}
@@ -1872,7 +1872,7 @@ public class RegularUtils {
 					} else if (regularLength(hConsignee, 140) && hConsignee.length() <= 175) {
 						inttraSoDto.setHConsigneeFive(hConsignee.substring(140));
 					} else {
-						inttraSoDto.setHConsigneeFive(hConsignee.substring( 174) + "*");
+						inttraSoDto.setHConsigneeFive(hConsignee.substring(174) + "*");
 						if (ObjectUtils.isNotNull(inttraSoDto.getProductName())) {
 							inttraSoDto.setProductName(inttraSoDto.getProductName() + "**" + hConsignee.substring(174));
 						}
@@ -1902,7 +1902,7 @@ public class RegularUtils {
 					} else if (regularLength(hNotify, 140) && hNotify.length() <= 175) {
 						inttraSoDto.setHNotifyFive(hNotify.substring(140));
 					} else {
-						inttraSoDto.setHNotifyFive(hNotify.substring( 174) + "*");
+						inttraSoDto.setHNotifyFive(hNotify.substring(174) + "*");
 						if (ObjectUtils.isNotNull(inttraSoDto.getProductName())) {
 							inttraSoDto.setProductName(inttraSoDto.getProductName() + "***" + hNotify.substring(174));
 						}

+ 20 - 6
blade-service/blade-los/src/main/java/org/springblade/los/basic/voucher/service/impl/VoucherTemplateServiceImpl.java

@@ -29,9 +29,11 @@ import org.springblade.los.basic.voucher.entity.VoucherTemplate;
 import org.springblade.los.basic.voucher.mapper.VoucherTemplateMapper;
 import org.springblade.los.basic.voucher.service.IVoucherTemplateService;
 import org.springblade.los.basic.voucher.vo.VoucherTemplateVO;
+import org.springblade.los.billno.entity.BusinessBillNo;
 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.util.ArrayList;
 import java.util.Date;
@@ -125,17 +127,22 @@ public class VoucherTemplateServiceImpl extends ServiceImpl<VoucherTemplateMappe
 		}
 		if ("HYCK".equals(businessType) || "HYJK".equals(businessType) || "KYCK".equals(businessType) ||
 			"KYJK".equals(businessType) || "SEA".equals(businessType) || "SIA".equals(businessType) ||
-			"AEA".equals(businessType) || "AIA".equals(businessType)) {
-			String[] CUR_CODE = new String[]{"RMB", "RMB", "RMB", "RMB", "USD", "USD", "USD", "USD"};
+			"AEA".equals(businessType) || "AIA".equals(businessType) || "BGSE".equals(businessType) || "BGSI".equals(businessType) ||
+			"BGAE".equals(businessType) || "BGAI".equals(businessType)) {
+			String[] CUR_CODE = new String[]{"CNY", "CNY", "CNY", "CNY", "USD", "USD", "USD", "USD"};
 			String[] CUR_NAME = new String[]{"人民币", "人民币", "人民币", "人民币", "美元", "美元", "美元", "美元"};
+			String[] DC = new String[]{"D", "C", "C", "D", "D", "C", "C", "D"};
 			String[] DC_TYPE = new String[]{"应收", "收入", "应付", "成本", "应收", "收入", "应付", "成本"};
 			String[] VOUCHER_TYPE = new String[]{"应收凭证", "", "应付凭证", "", "应收凭证", "", "应付凭证", ""};
 			String[] HY = new String[]{"海运应收", "代理业务收入", "海运应付", "代理业务成本", "海运应收", "代理业务收入", "海运应付", "代理业务成本"};
 			String[] KY = new String[]{"空运应收", "代理业务收入", "空运应付", "代理业务成本", "空运应收", "代理业务收入", "空运应付", "代理业务成本"};
 			String[] HY_AMEND = new String[]{"海运amend应收", "代理业务收入", "海运amend应付", "代理业务成本", "海运amend应收", "代理业务收入", "海运amend应付", "代理业务成本"};
 			String[] KY_AMEND = new String[]{"空运amend应收", "代理业务收入", "空运amend应付", "代理业务成本", "空运amend应收", "代理业务收入", "空运amend应付", "代理业务成本"};
-			String CK_FORMULAS = "[corpCnName] [mblno] [etd]";
-			String JK_FORMULAS = "[corpCnName] [mblno] [eta]";
+			String[] HY_BG = new String[]{"海运报关应收", "代理业务收入", "海运报关应付", "代理业务成本", "海运报关应收", "代理业务收入", "海运报关应付", "代理业务成本"};
+			String[] KY_BG = new String[]{"空运报关应收", "代理业务收入", "空运报关应付", "代理业务成本", "空运报关应收", "代理业务收入", "空运报关应付", "代理业务成本"};
+			String CK_FORMULAS = "corpCnName,mblno,etd";
+			String JK_FORMULAS = "corpCnName,mblno,eta";
+			String BG_FORMULAS = "corpCnName,mblno,declareDate";
 			for (int i = 0; i < 8; i++) {
 				VoucherTemplate voucherTemplate = new VoucherTemplate();
 				voucherTemplate.setCreateTime(new Date());
@@ -157,6 +164,7 @@ public class VoucherTemplateServiceImpl extends ServiceImpl<VoucherTemplateMappe
 				voucherTemplate.setCurrencyName(CUR_NAME[i]);
 				voucherTemplate.setDcType(DC_TYPE[i]);
 				voucherTemplate.setVoucherType(VOUCHER_TYPE[i]);
+				voucherTemplate.setAmountDirection(DC[i]);
 				if ("HYCK".equals(businessType)) {
 					voucherTemplate.setStaticValue(HY[i]);
 					voucherTemplate.setAdditionalFormulas(CK_FORMULAS);
@@ -178,14 +186,20 @@ public class VoucherTemplateServiceImpl extends ServiceImpl<VoucherTemplateMappe
 				} else if ("AEA".equals(businessType)) {
 					voucherTemplate.setStaticValue(KY_AMEND[i]);
 					voucherTemplate.setAdditionalFormulas(CK_FORMULAS);
-				} else {
+				} else if ("AIA".equals(businessType)) {
 					voucherTemplate.setStaticValue(KY_AMEND[i]);
 					voucherTemplate.setAdditionalFormulas(JK_FORMULAS);
+				} else if ("BGSE".equals(businessType) || "BGSI".equals(businessType)) {
+					voucherTemplate.setStaticValue(HY_BG[i]);
+					voucherTemplate.setAdditionalFormulas(BG_FORMULAS);
+				} else if ("BGAE".equals(businessType) || "BGAI".equals(businessType)) {
+					voucherTemplate.setStaticValue(KY_BG[i]);
+					voucherTemplate.setAdditionalFormulas(BG_FORMULAS);
 				}
 				voucherTemplateList.add(voucherTemplate);
 			}
 		} else if ("STL".equals(businessType)) {
-			String[] CUR_CODE = new String[]{"RMB", "RMB", "RMB", "RMB", "RMB", "USD", "USD", "USD", "USD", "USD"};
+			String[] CUR_CODE = new String[]{"CNY", "CNY", "CNY", "CNY", "CNY", "USD", "USD", "USD", "USD", "USD"};
 			String[] CUR_NAME = new String[]{"人民币", "人民币", "人民币", "人民币", "人民币", "美元", "美元", "美元", "美元", "美元"};
 			String[] DC_TYPE = new String[]{"现金", "银行", "应收账款", "应付账款", "汇兑收益", "现金", "银行", "应收账款", "应付账款", "汇兑收益"};
 			String[] VOUCHER_TYPE = new String[]{"现金收入凭证", "银行收入凭证", "现金支出凭证", "银行支出凭证", "", "现金收入凭证", "银行收入凭证", "现金支出凭证", "银行支出凭证", ""};

+ 11 - 0
blade-service/blade-los/src/main/java/org/springblade/los/billno/service/IBusinessBillNoService.java

@@ -23,6 +23,7 @@ import org.springblade.los.billno.entity.BusinessBillNo;
 import org.springblade.los.billno.vo.BusinessBillNoVO;
 import org.springblade.los.business.aea.entity.AeaBills;
 import org.springblade.los.business.sea.entity.Bills;
+import org.springblade.los.finance.vouchers.entity.FinVouchers;
 
 /**
  * 基础资料-业务类型编号格式 服务类
@@ -50,6 +51,14 @@ public interface IBusinessBillNoService extends IService<BusinessBillNo> {
 	 */
 	R<String> getBillNoLos(BusinessBillNo businessBillNo);
 
+	/**
+	 * 生成凭证号
+	 *
+	 * @param businessBillNo
+	 * @return
+	 */
+	R<String> getVoucherNoLos(BusinessBillNo businessBillNo);
+
 	void deteleBillNo(Bills item);
 
 	void deteleBillNoAe(AeaBills item);
@@ -67,4 +76,6 @@ public interface IBusinessBillNoService extends IService<BusinessBillNo> {
 	 * @return
 	 */
 	BusinessBillNo detail(BusinessBillNo businessBillNo);
+
+	void deteleFinVouchers(FinVouchers item);
 }

+ 221 - 4
blade-service/blade-los/src/main/java/org/springblade/los/billno/service/impl/BusinessBillNoServiceImpl.java

@@ -38,10 +38,12 @@ import org.springblade.los.billno.vo.BillNoSerialVO;
 import org.springblade.los.billno.vo.BusinessBillNoVO;
 import org.springblade.los.business.aea.entity.AeaBills;
 import org.springblade.los.business.sea.entity.Bills;
+import org.springblade.los.finance.vouchers.entity.FinVouchers;
 import org.springblade.system.feign.ISysClient;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
+import java.time.LocalDate;
 import java.util.Date;
 import java.util.List;
 
@@ -185,7 +187,120 @@ public class BusinessBillNoServiceImpl extends ServiceImpl<BusinessBillNoMapper,
 	}
 
 	@Override
+	public R<String> getVoucherNoLos(BusinessBillNo businessBillNo) {
+		String branchId = deptUtils.getDeptPid() + "";
+		BusinessBillNo detail = baseMapper.selectOne(new LambdaQueryWrapper<BusinessBillNo>()
+			.eq(BusinessBillNo::getTenantId, AuthUtil.getTenantId())
+			.eq(BusinessBillNo::getIsDeleted, 0)
+			.eq(BusinessBillNo::getBusinessTypeId, businessBillNo.getBusinessTypeId())
+			.eq(BusinessBillNo::getCode, businessBillNo.getCode())
+			.eq(BusinessBillNo::getBranchId, branchId)
+			.eq(BusinessBillNo::getStatus, 0));
+		if (detail == null) {
+			throw new RuntimeException("未找到可用生成凭证号规则");
+		}
+		//编码开头
+		String head = "";
+		//编码序列号
+		String tail = "";
+		//编码
+		String billNo = null;
+		//判断编码格式是否为空
+		if (ObjectUtils.isNotNull(detail.getCodeFormat())) {
+			int index = detail.getCodeFormat().indexOf("%");
+			head = detail.getCodeFormat().substring(0, index);
+			tail = detail.getCodeFormat().substring(index + 1);
+		} else {
+			throw new RuntimeException("编码格式为空");
+		}
+		String yyyyMM = "";
+		LocalDate currentDate = LocalDate.now();
+		//格式化日期
+		if ("Month".equals(detail.getResetRule())) {
+			yyyyMM = currentDate.getYear() + "" + currentDate.getMonthValue() + "";
+		} else if ("Year".equals(detail.getResetRule())) {
+			yyyyMM = currentDate.getYear() + "";
+		}
+		billNo = head;
+		List<BillNoCenter> billNoCenterList = billNoCenterService.list(new LambdaQueryWrapper<BillNoCenter>()
+			.eq(BillNoCenter::getTenantId, AuthUtil.getTenantId())
+			.eq(BillNoCenter::getIsDeleted, 0)
+			.eq(BillNoCenter::getBusinessTypeId, detail.getBusinessTypeId())
+			.eq(BillNoCenter::getBusinessType, detail.getBusinessType())
+			.eq(BillNoCenter::getPid, detail.getId())
+			.eq(BillNoCenter::getResetRule, detail.getResetRule())
+			.eq(BillNoCenter::getResetValue, head + yyyyMM)
+			.eq(BillNoCenter::getBranchId, branchId)
+			.orderByDesc(BillNoCenter::getCreateTime)
+		);
+		if (!billNoCenterList.isEmpty()) {
+			return R.data(billNoCenterList.get(0).getBillNo());
+		} else {
+			BillNoSerial billNoSerial1 = new BillNoSerialVO();
+			//判断是否有生成过编码记录
+			BillNoSerial billNoSerial = billNoSerialService.getOne(new LambdaQueryWrapper<BillNoSerial>()
+				.eq(BillNoSerial::getTenantId, AuthUtil.getTenantId())
+				.eq(BillNoSerial::getIsDeleted, 0)
+				.eq(BillNoSerial::getBusinessTypeId, detail.getBusinessTypeId())
+				.eq(BillNoSerial::getPid, detail.getId())
+				.eq(BillNoSerial::getResetRule, detail.getResetRule())
+				.eq(BillNoSerial::getBranchId, branchId)
+				.eq(BillNoSerial::getResetValue, billNo)
+			);
+			if (billNoSerial == null) {
+				billNoSerial1.setBusinessTypeId(detail.getBusinessTypeId());
+				billNoSerial1.setSerialNo(1L);
+				billNoSerial1.setPid(detail.getId());
+				billNoSerial1.setResetRule(detail.getResetRule());
+				billNoSerial1.setResetValue(billNo);
+				billNoSerial1.setBranchId(branchId);
+				billNoSerial1.setCreateDept(AuthUtil.getDeptId());
+				billNoSerial1.setCreateTime(new Date());
+				billNoSerial1.setCreateUser(AuthUtil.getUserId());
+				billNoSerial1.setCreateUserName(AuthUtil.getUserName());
+				billNoSerial1.setTenantId(AuthUtil.getTenantId());
+				//生成序列号  循环赋0  最后一位赋1
+				if (!tail.isEmpty()) {
+					StringBuilder number = new StringBuilder();
+					for (int i = 0; i <= tail.length(); i++) {
+						if (i == tail.length()) {
+							number.append("1");
+						} else {
+							number.append("0");
+						}
+					}
+					billNo = billNo + number.toString();
+				}
+			} else {
+				BeanUtil.copyProperties(billNoSerial, billNoSerial1);
+				billNoSerial1.setSerialNo(billNoSerial.getSerialNo() + 1);
+				billNoSerial1.setUpdateTime(new Date());
+				billNoSerial1.setUpdateUser(AuthUtil.getUserId());
+				billNoSerial1.setUpdateUserName(AuthUtil.getUserName());
+				billNoSerial1.setBranchId(branchId);
+				String count = billNoSerial1.getSerialNo() + "";
+				if (!tail.isEmpty()) {
+					//判断最大序列号长度与序列号规则长度是否相等  相等不赋0
+					if (tail.length() == count.length()) {
+						billNo = billNo + count;
+					} else {
+						//不相等  序列号规则长度-最大序列号长度 之间赋0 然后拼接最大序列号
+						StringBuilder number = new StringBuilder();
+						for (int i = 0; i <= tail.length() - count.length(); i++) {
+							number.append("0");
+						}
+						billNo = billNo + number.toString() + count;
+					}
+				}
+			}
+			billNoSerialService.saveOrUpdate(billNoSerial1);
+			return R.data(billNo);
+		}
+	}
+
+	@Override
 	public void deteleBillNo(Bills item) {
+		String branchId = deptUtils.getDeptPid() + "";
 		String billNo = "";
 		String mbillNo = "";
 		if (ObjectUtils.isNotNull(item.getBillNo())) {
@@ -205,7 +320,7 @@ public class BusinessBillNoServiceImpl extends ServiceImpl<BusinessBillNoMapper,
 			.eq(BillNoSerial::getTenantId, AuthUtil.getTenantId())
 			.eq(BillNoSerial::getIsDeleted, 0)
 			.like(BillNoSerial::getResetValue, billNo));
-		if (billNoSerialList.size() > 0) {
+		if (!billNoSerialList.isEmpty()) {
 			BusinessBillNo detail = baseMapper.selectById(billNoSerialList.get(0).getPid());
 			//判断编码格式是否为空
 			if (ObjectUtils.isNotNull(detail.getCodeFormat())) {
@@ -231,6 +346,7 @@ public class BusinessBillNoServiceImpl extends ServiceImpl<BusinessBillNoMapper,
 				billNoCenter.setResetValue(head + yyyyMM);
 				billNoCenter.setTenantId(AuthUtil.getTenantId());
 				billNoCenter.setCreateTime(new Date());
+				billNoCenter.setBranchId(branchId);
 				billNoCenter.setCreateUser(AuthUtil.getUserId());
 				billNoCenter.setCreateUserName(AuthUtil.getUserName());
 				billNoCenter.setCreateDept(AuthUtil.getDeptId());
@@ -242,7 +358,7 @@ public class BusinessBillNoServiceImpl extends ServiceImpl<BusinessBillNoMapper,
 			.eq(BillNoSerial::getTenantId, AuthUtil.getTenantId())
 			.eq(BillNoSerial::getIsDeleted, 0)
 			.like(BillNoSerial::getResetValue, mbillNo));
-		if (billNoSerialList1.size() > 0) {
+		if (!billNoSerialList1.isEmpty()) {
 			BusinessBillNo detail = baseMapper.selectById(billNoSerialList1.get(0).getPid());
 			if (ObjectUtils.isNotNull(detail) && 1 == detail.getIsRecyclable()) {
 				//判断编码格式是否为空
@@ -269,6 +385,7 @@ public class BusinessBillNoServiceImpl extends ServiceImpl<BusinessBillNoMapper,
 					billNoCenter.setResetValue(head + yyyyMM);
 					billNoCenter.setTenantId(AuthUtil.getTenantId());
 					billNoCenter.setCreateTime(new Date());
+					billNoCenter.setBranchId(branchId);
 					billNoCenter.setCreateUser(AuthUtil.getUserId());
 					billNoCenter.setCreateUserName(AuthUtil.getUserName());
 					billNoCenter.setCreateDept(AuthUtil.getDeptId());
@@ -280,6 +397,7 @@ public class BusinessBillNoServiceImpl extends ServiceImpl<BusinessBillNoMapper,
 
 	@Override
 	public void deteleBillNoAe(AeaBills item) {
+		String branchId = deptUtils.getDeptPid() + "";
 		String billNo = "";
 		String mbillNo = "";
 		if (ObjectUtils.isNotNull(item.getBillNo())) {
@@ -299,7 +417,7 @@ public class BusinessBillNoServiceImpl extends ServiceImpl<BusinessBillNoMapper,
 			.eq(BillNoSerial::getTenantId, AuthUtil.getTenantId())
 			.eq(BillNoSerial::getIsDeleted, 0)
 			.like(BillNoSerial::getResetValue, billNo));
-		if (billNoSerialList.size() > 0) {
+		if (!billNoSerialList.isEmpty()) {
 			BusinessBillNo detail = baseMapper.selectById(billNoSerialList.get(0).getPid());
 			//判断编码格式是否为空
 			if (ObjectUtils.isNotNull(detail.getCodeFormat())) {
@@ -325,6 +443,7 @@ public class BusinessBillNoServiceImpl extends ServiceImpl<BusinessBillNoMapper,
 				billNoCenter.setResetValue(head + yyyyMM);
 				billNoCenter.setTenantId(AuthUtil.getTenantId());
 				billNoCenter.setCreateTime(new Date());
+				billNoCenter.setBranchId(branchId);
 				billNoCenter.setCreateUser(AuthUtil.getUserId());
 				billNoCenter.setCreateUserName(AuthUtil.getUserName());
 				billNoCenter.setCreateDept(AuthUtil.getDeptId());
@@ -336,7 +455,7 @@ public class BusinessBillNoServiceImpl extends ServiceImpl<BusinessBillNoMapper,
 			.eq(BillNoSerial::getTenantId, AuthUtil.getTenantId())
 			.eq(BillNoSerial::getIsDeleted, 0)
 			.like(BillNoSerial::getResetValue, mbillNo));
-		if (billNoSerialList1.size() > 0) {
+		if (!billNoSerialList1.isEmpty()) {
 			BusinessBillNo detail = baseMapper.selectById(billNoSerialList1.get(0).getPid());
 			if (ObjectUtils.isNotNull(detail) && 1 == detail.getIsRecyclable()) {
 				//判断编码格式是否为空
@@ -363,6 +482,7 @@ public class BusinessBillNoServiceImpl extends ServiceImpl<BusinessBillNoMapper,
 					billNoCenter.setResetValue(head + yyyyMM);
 					billNoCenter.setTenantId(AuthUtil.getTenantId());
 					billNoCenter.setCreateTime(new Date());
+					billNoCenter.setBranchId(branchId);
 					billNoCenter.setCreateUser(AuthUtil.getUserId());
 					billNoCenter.setCreateUserName(AuthUtil.getUserName());
 					billNoCenter.setCreateDept(AuthUtil.getDeptId());
@@ -408,4 +528,101 @@ public class BusinessBillNoServiceImpl extends ServiceImpl<BusinessBillNoMapper,
 		return detail;
 	}
 
+	@Override
+	public void deteleFinVouchers(FinVouchers item) {
+		String branchId = deptUtils.getDeptPid() + "";
+		String billNo = "";
+		String voucherNo = "";
+		if (ObjectUtils.isNotNull(item.getBillNo())) {
+			billNo = item.getBillNo().replaceAll("\\D", "");
+		}
+		if (ObjectUtils.isNotNull(item.getVoucherNo())) {
+			voucherNo = item.getVoucherNo().substring(0, 1);
+		}
+		Date date = new Date();
+		//编码开头
+		String head = "";
+		//编码日期格式
+		String yearMmDd = "";
+		//格式化后日期
+		String yyyyMM = "";
+		List<BillNoSerial> billNoSerialList = billNoSerialService.list(new LambdaQueryWrapper<BillNoSerial>()
+			.eq(BillNoSerial::getTenantId, AuthUtil.getTenantId())
+			.eq(BillNoSerial::getIsDeleted, 0)
+			.like(BillNoSerial::getResetValue, billNo));
+		if (!billNoSerialList.isEmpty()) {
+			BusinessBillNo detail = baseMapper.selectById(billNoSerialList.get(0).getPid());
+			//判断编码格式是否为空
+			if (ObjectUtils.isNotNull(detail.getCodeFormat())) {
+				int index = detail.getCodeFormat().indexOf("%");
+				int indexLast = detail.getCodeFormat().indexOf("%", index + 1);
+				head = detail.getCodeFormat().substring(0, index);
+				yearMmDd = detail.getCodeFormat().substring(index + 1, indexLast);
+			} else {
+				throw new RuntimeException("编码格式为空");
+			}
+			//格式化日期
+			if (ObjectUtils.isNotNull(yearMmDd)) {
+				yyyyMM = DateFormatUtils.format(date, yearMmDd);
+			}
+			if (ObjectUtils.isNotNull(detail) && 1 == detail.getIsRecyclable()) {
+				BillNoCenter billNoCenter = new BillNoCenter();
+				billNoCenter.setBusinessType(detail.getBusinessType());
+				billNoCenter.setBusinessTypeId(detail.getBusinessTypeId());
+				billNoCenter.setPid(detail.getId());
+				billNoCenter.setBillId(item.getId());
+				billNoCenter.setBillNo(item.getBillNo());
+				billNoCenter.setResetRule(detail.getResetRule());
+				billNoCenter.setResetValue(head + yyyyMM);
+				billNoCenter.setTenantId(AuthUtil.getTenantId());
+				billNoCenter.setCreateTime(new Date());
+				billNoCenter.setBranchId(branchId);
+				billNoCenter.setCreateUser(AuthUtil.getUserId());
+				billNoCenter.setCreateUserName(AuthUtil.getUserName());
+				billNoCenter.setCreateDept(AuthUtil.getDeptId());
+				billNoCenterService.save(billNoCenter);
+			}
+		}
+
+		List<BillNoSerial> billNoSerialList1 = billNoSerialService.list(new LambdaQueryWrapper<BillNoSerial>()
+			.eq(BillNoSerial::getTenantId, AuthUtil.getTenantId())
+			.eq(BillNoSerial::getIsDeleted, 0)
+			.like(BillNoSerial::getResetValue, voucherNo));
+		if (!billNoSerialList1.isEmpty()) {
+			BusinessBillNo detail = baseMapper.selectById(billNoSerialList1.get(0).getPid());
+			if (ObjectUtils.isNotNull(detail) && 1 == detail.getIsRecyclable()) {
+				//判断编码格式是否为空
+				if (ObjectUtils.isNotNull(detail.getCodeFormat())) {
+					int index = detail.getCodeFormat().indexOf("%");
+					head = detail.getCodeFormat().substring(0, index);
+				} else {
+					throw new RuntimeException("编码格式为空");
+				}
+				//格式化日期
+				if ("Month".equals(detail.getResetRule())) {
+					yyyyMM = item.getAccountYear().toString() + item.getAccountMonth().toString();
+				} else if ("Year".equals(detail.getResetRule())) {
+					yyyyMM = item.getAccountYear().toString();
+				}
+				if (ObjectUtils.isNotNull(detail) && 1 == detail.getIsRecyclable()) {
+					BillNoCenter billNoCenter = new BillNoCenter();
+					billNoCenter.setBusinessType(detail.getBusinessType());
+					billNoCenter.setBusinessTypeId(detail.getBusinessTypeId());
+					billNoCenter.setPid(detail.getId());
+					billNoCenter.setBillId(item.getId());
+					billNoCenter.setBillNo(item.getVoucherNo());
+					billNoCenter.setResetRule(detail.getResetRule());
+					billNoCenter.setResetValue(head + yyyyMM);
+					billNoCenter.setTenantId(AuthUtil.getTenantId());
+					billNoCenter.setCreateTime(new Date());
+					billNoCenter.setCreateUser(AuthUtil.getUserId());
+					billNoCenter.setBranchId(branchId);
+					billNoCenter.setCreateUserName(AuthUtil.getUserName());
+					billNoCenter.setCreateDept(AuthUtil.getDeptId());
+					billNoCenterService.save(billNoCenter);
+				}
+			}
+		}
+	}
+
 }

+ 34 - 16
blade-service/blade-los/src/main/java/org/springblade/los/business/sea/service/impl/PreContainersServiceImpl.java

@@ -95,9 +95,9 @@ public class PreContainersServiceImpl extends ServiceImpl<PreContainersMapper, P
 			.select(PreContainers::getId, PreContainers::getMeasurement, PreContainers::getNumber, PreContainers::getGrossWeight)
 			.eq(PreContainers::getPid, bills.getId())
 			.eq(PreContainers::getIsDeleted, 0));
-		BigDecimal measurementSum = preContainersList.stream().map(PreContainers::getMeasurement).filter(Objects::nonNull).reduce(BigDecimal.ZERO,BigDecimal::add);
-		BigDecimal grossWeightSum = preContainersList.stream().map(PreContainers::getGrossWeight).filter(Objects::nonNull).reduce(BigDecimal.ZERO,BigDecimal::add);
-		BigDecimal quantitySum = preContainersList.stream().map(PreContainers::getNumber).filter(Objects::nonNull).reduce(BigDecimal.ZERO,BigDecimal::add);
+		BigDecimal measurementSum = preContainersList.stream().map(PreContainers::getMeasurement).filter(Objects::nonNull).reduce(BigDecimal.ZERO, BigDecimal::add);
+		BigDecimal grossWeightSum = preContainersList.stream().map(PreContainers::getGrossWeight).filter(Objects::nonNull).reduce(BigDecimal.ZERO, BigDecimal::add);
+		BigDecimal quantitySum = preContainersList.stream().map(PreContainers::getNumber).filter(Objects::nonNull).reduce(BigDecimal.ZERO, BigDecimal::add);
 		if (preContainers.getId() == null) {
 			preContainers.setCreateTime(new Date());
 			preContainers.setCreateUser(AuthUtil.getUserId());
@@ -108,19 +108,31 @@ public class PreContainersServiceImpl extends ServiceImpl<PreContainersMapper, P
 				preContainers.setCreateDeptName(deptName);
 			}
 			teu += preContainers.getTeu().intValue();
-			bills.setMeasurement(measurementSum.add(preContainers.getMeasurement()));
-			bills.setGrossWeight(grossWeightSum.add(preContainers.getGrossWeight()));
-			bills.setQuantity(quantitySum.add(new BigDecimal(preContainers.getQuantity())));
+			if (measurementSum.add(preContainers.getMeasurement()).compareTo(new BigDecimal("0")) != 0){
+				bills.setMeasurement(measurementSum.add(preContainers.getMeasurement()));
+			}
+			if (grossWeightSum.add(preContainers.getGrossWeight()).compareTo(new BigDecimal("0")) != 0){
+				bills.setGrossWeight(grossWeightSum.add(preContainers.getGrossWeight()));
+			}
+			if (quantitySum.add(new BigDecimal(preContainers.getQuantity())).compareTo(new BigDecimal("0")) != 0){
+				bills.setQuantity(quantitySum.add(new BigDecimal(preContainers.getQuantity())));
+			}
 		} else {
 			PreContainers preContainers1 = preContainersList.stream().filter(e -> e.getId().equals(preContainers.getId())).findFirst().orElse(null);
 			if (preContainers1 != null) {
 				BigDecimal measurement = ObjectUtils.isNotNull(preContainers1.getMeasurement()) ? preContainers1.getMeasurement() : new BigDecimal("0.00");
 				BigDecimal grossWeight = ObjectUtils.isNotNull(preContainers1.getGrossWeight()) ? preContainers1.getGrossWeight() : new BigDecimal("0.00");
 				BigDecimal quantity = ObjectUtils.isNotNull(preContainers1.getNumber()) ? preContainers1.getNumber() : new BigDecimal("0.00");
-				bills.setMeasurement(measurementSum.add(preContainers.getMeasurement()).subtract(measurement));
-				bills.setGrossWeight(grossWeightSum.add(preContainers.getGrossWeight()).subtract(grossWeight));
-				bills.setQuantity(quantitySum.add(preContainers.getNumber()).subtract(quantity));
-				if (ObjectUtils.isNotNull(preContainers1.getTeu()) && ObjectUtils.isNotNull(preContainers.getTeu())){
+				if (measurementSum.add(preContainers.getMeasurement()).subtract(measurement).compareTo(new BigDecimal("0")) != 0){
+					bills.setMeasurement(measurementSum.add(preContainers.getMeasurement()).subtract(measurement));
+				}
+				if (grossWeightSum.add(preContainers.getGrossWeight()).subtract(grossWeight).compareTo(new BigDecimal("0")) != 0){
+					bills.setGrossWeight(grossWeightSum.add(preContainers.getGrossWeight()).subtract(grossWeight));
+				}
+				if (quantitySum.add(preContainers.getNumber()).subtract(quantity).compareTo(new BigDecimal("0")) != 0){
+					bills.setQuantity(quantitySum.add(preContainers.getNumber()).subtract(quantity));
+				}
+				if (ObjectUtils.isNotNull(preContainers1.getTeu()) && ObjectUtils.isNotNull(preContainers.getTeu())) {
 					if (preContainers1.getTeu().compareTo(preContainers.getTeu()) >= 0) {
 						teu = teu - preContainers1.getTeu().subtract(preContainers.getTeu()).intValue();
 					} else {
@@ -240,17 +252,23 @@ public class PreContainersServiceImpl extends ServiceImpl<PreContainersMapper, P
 			bills.setUpdateTime(new Date());
 			bills.setUpdateUserName(AuthUtil.getUserName());
 			BigDecimal teu = new BigDecimal("0.00");
-			BigDecimal measurementSum = preContainersList.stream().map(PreContainers::getMeasurement).filter(Objects::nonNull).reduce(BigDecimal.ZERO,BigDecimal::add);
-			BigDecimal grossWeightSum = preContainersList.stream().map(PreContainers::getGrossWeight).filter(Objects::nonNull).reduce(BigDecimal.ZERO,BigDecimal::add);
-			BigDecimal quantitySum = preContainersList.stream().map(PreContainers::getNumber).filter(Objects::nonNull).reduce(BigDecimal.ZERO,BigDecimal::add);
+			BigDecimal measurementSum = preContainersList.stream().map(PreContainers::getMeasurement).filter(Objects::nonNull).reduce(BigDecimal.ZERO, BigDecimal::add);
+			BigDecimal grossWeightSum = preContainersList.stream().map(PreContainers::getGrossWeight).filter(Objects::nonNull).reduce(BigDecimal.ZERO, BigDecimal::add);
+			BigDecimal quantitySum = preContainersList.stream().map(PreContainers::getNumber).filter(Objects::nonNull).reduce(BigDecimal.ZERO, BigDecimal::add);
 			for (PreContainers preContainers : preContainersList) {
 				if (ObjectUtils.isNotNull(preContainers.getQuantity()) && ObjectUtils.isNotNull(preContainers.getTeu())) {
 					teu = teu.add(new BigDecimal(preContainers.getQuantity()).multiply(preContainers.getTeu()));
 				}
 			}
-			bills.setMeasurement(measurementSum);
-			bills.setGrossWeight(grossWeightSum);
-			bills.setQuantity(quantitySum);
+			if (measurementSum.compareTo(new BigDecimal("0")) != 0) {
+				bills.setMeasurement(measurementSum);
+			}
+			if (grossWeightSum.compareTo(new BigDecimal("0")) != 0) {
+				bills.setGrossWeight(grossWeightSum);
+			}
+			if (quantitySum.compareTo(new BigDecimal("0")) != 0) {
+				bills.setQuantity(quantitySum);
+			}
 			bills.setTeu(teu.intValue());
 			billsMapper.updateById(bills);
 		}

+ 244 - 14
blade-service/blade-los/src/main/java/org/springblade/los/check/service/impl/AuditProecessServiceImpl.java

@@ -76,8 +76,12 @@ import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 import org.springframework.transaction.interceptor.TransactionAspectSupport;
 
+import java.lang.reflect.Field;
 import java.math.BigDecimal;
+import java.math.MathContext;
+import java.math.RoundingMode;
 import java.text.SimpleDateFormat;
+import java.time.LocalDate;
 import java.util.*;
 import java.util.stream.Collectors;
 
@@ -578,6 +582,8 @@ public class AuditProecessServiceImpl extends ServiceImpl<AuditProecessMapper, L
 	}
 
 	@Override
+	@Transactional(rollbackFor = Exception.class)
+	@GlobalTransactional(rollbackFor = Exception.class, timeoutMills = 12000000)
 	public void losStlBillsCheck(LosAuditProecess auditProecess) {
 		//查看最新操作记录,防止重复提交
 		LosAuditProecess proecessTemp = baseMapper.selectById(auditProecess.getId());
@@ -766,6 +772,8 @@ public class AuditProecessServiceImpl extends ServiceImpl<AuditProecessMapper, L
 	}
 
 	@Override
+	@Transactional(rollbackFor = Exception.class)
+	@GlobalTransactional(rollbackFor = Exception.class, timeoutMills = 12000000)
 	public void losFinInvoicesCheck(LosAuditProecess auditProecess) {
 		//查看最新操作记录,防止重复提交
 		LosAuditProecess proecessTemp = baseMapper.selectById(auditProecess.getId());
@@ -951,6 +959,8 @@ public class AuditProecessServiceImpl extends ServiceImpl<AuditProecessMapper, L
 	}
 
 	@Override
+	@Transactional(rollbackFor = Exception.class)
+	@GlobalTransactional(rollbackFor = Exception.class, timeoutMills = 12000000)
 	public void amendsCheck(LosAuditProecess auditProecess) {
 		//查看最新操作记录,防止重复提交
 		LosAuditProecess proecessTemp = baseMapper.selectById(auditProecess.getId());
@@ -1208,24 +1218,46 @@ public class AuditProecessServiceImpl extends ServiceImpl<AuditProecessMapper, L
 
 	private void generateVoucher(String checkType, Long id) {
 		String typeCode;
+		String typeName;
 		if ("HYCK-DJ".equals(checkType)) {
 			typeCode = "HYCK";
+			typeName = "海运出口";
 		} else if ("HYJK-DJ".equals(checkType)) {
 			typeCode = "HYJK";
+			typeName = "海运进口";
 		} else if ("KYCK-DJ".equals(checkType)) {
 			typeCode = "KYCK";
+			typeName = "空运出口";
 		} else if ("KYJK-DJ".equals(checkType)) {
 			typeCode = "KYJK";
+			typeName = "空运进口";
 		} else if ("sea-approve".equals(checkType)) {
 			typeCode = "SEA";
+			typeName = "海运出口amend";
 		} else if ("sia-approve".equals(checkType)) {
 			typeCode = "SIA";
+			typeName = "海运进口amend";
 		} else if ("aea-approve".equals(checkType)) {
 			typeCode = "AEA";
+			typeName = "空运出口amend";
 		} else if ("aia-approve".equals(checkType)) {
 			typeCode = "AIA";
+			typeName = "空运进口amend";
+		} else if ("BGSE".equals(checkType)) {
+			typeCode = "BGSE";
+			typeName = "海运出口报关";
+		} else if ("BGSI".equals(checkType)) {
+			typeCode = "BGSI";
+			typeName = "海运进口报关";
+		} else if ("BGAE".equals(checkType)) {
+			typeCode = "BGAE";
+			typeName = "空运出口报关";
+		} else if ("BGAI".equals(checkType)) {
+			typeCode = "BGAI";
+			typeName = "空运进口报关";
 		} else {
 			typeCode = "";
+			typeName = "";
 		}
 		List<BusinessType> businessTypeList = bBusinessTypeService.list(new LambdaQueryWrapper<BusinessType>()
 			.eq(BusinessType::getIsDeleted, 0)
@@ -1254,12 +1286,17 @@ public class AuditProecessServiceImpl extends ServiceImpl<AuditProecessMapper, L
 		Dept dept = null;
 		User user = null;
 		BCorps userSrc = null;
+		Bills billsDetail = null;
+		AeaBills aeaBillsDetail = null;
+		CustomsDeclaration customsDeclarationDetail = null;
+		Amends amendsDetail = null;
 		//查询各业务模块 核算客户,核算部门,核算职员信息
 		if ("HYCK-DJ".equals(checkType) || "HYJK-DJ".equals(checkType)) {
 			Bills bills = billsMapper.selectById(id);
 			if (bills != null) {
+				billsDetail = bills;
 				bCorps = bCorpsService.getById(bills.getCorpId());
-				if (ObjectUtils.isNotNull(bills.getAccDept())){
+				if (ObjectUtils.isNotNull(bills.getAccDept())) {
 					R<Dept> deptR = sysClient.getDept(Long.parseLong(bills.getAccDept()));
 					if (deptR.isSuccess()) {
 						dept = deptR.getData();
@@ -1273,12 +1310,26 @@ public class AuditProecessServiceImpl extends ServiceImpl<AuditProecessMapper, L
 				} else {
 					userSrc = bCorpsService.getById(bills.getSrcId());
 				}
+				if ("MM".equals(bills.getBillType())) {
+					List<Bills> billsList = billsMapper.selectList(new LambdaQueryWrapper<Bills>()
+						.select(Bills::getId)
+						.eq(Bills::getMasterId, bills.getId()));
+					if (!billsList.isEmpty()) {
+						List<Long> billsId = billsList.stream().map(Bills::getId).collect(Collectors.toList());
+						List<FeeCenter> feeCenters = feeCenterService.list(new LambdaQueryWrapper<FeeCenter>()
+							.in(FeeCenter::getPid, billsId));
+						if (!feeCenters.isEmpty()) {
+							feeCenterList.addAll(feeCenters);
+						}
+					}
+				}
 			}
 		} else if ("KYCK-DJ".equals(checkType) || "KYJK-DJ".equals(checkType)) {
 			AeaBills bills = aeaBillsMapper.selectById(id);
 			if (bills != null) {
+				aeaBillsDetail = bills;
 				bCorps = bCorpsService.getById(bills.getCorpId());
-				if (ObjectUtils.isNotNull(bills.getAccDept())){
+				if (ObjectUtils.isNotNull(bills.getAccDept())) {
 					R<Dept> deptR = sysClient.getDept(Long.parseLong(bills.getAccDept()));
 					if (deptR.isSuccess()) {
 						dept = deptR.getData();
@@ -1292,13 +1343,27 @@ public class AuditProecessServiceImpl extends ServiceImpl<AuditProecessMapper, L
 				} else {
 					userSrc = bCorpsService.getById(bills.getSrcId());
 				}
+				if ("MM".equals(bills.getBillType())) {
+					List<Bills> billsList = billsMapper.selectList(new LambdaQueryWrapper<Bills>()
+						.select(Bills::getId)
+						.eq(Bills::getMasterId, bills.getId()));
+					if (!billsList.isEmpty()) {
+						List<Long> billsId = billsList.stream().map(Bills::getId).collect(Collectors.toList());
+						List<FeeCenter> feeCenters = feeCenterService.list(new LambdaQueryWrapper<FeeCenter>()
+							.in(FeeCenter::getPid, billsId));
+						if (!feeCenters.isEmpty()) {
+							feeCenterList.addAll(feeCenters);
+						}
+					}
+				}
 			}
 		} else if ("BGSE".equals(checkType) || "BGSI".equals(checkType) ||
 			"BGAE".equals(checkType) || "BGAI".equals(checkType)) {
 			CustomsDeclaration bills = customsDeclarationMapper.selectById(id);
 			if (bills != null) {
+				customsDeclarationDetail = bills;
 				bCorps = bCorpsService.getById(bills.getCorpId());
-				if (ObjectUtils.isNotNull(bills.getAccDept())){
+				if (ObjectUtils.isNotNull(bills.getAccDept())) {
 					R<Dept> deptR = sysClient.getDept(Long.parseLong(bills.getAccDept()));
 					if (deptR.isSuccess()) {
 						dept = deptR.getData();
@@ -1317,8 +1382,9 @@ public class AuditProecessServiceImpl extends ServiceImpl<AuditProecessMapper, L
 			"aea-approve".equals(checkType) || "aia-approve".equals(checkType)) {
 			Amends bills = amendsMapper.selectById(id);
 			if (bills != null) {
+				amendsDetail = bills;
 				bCorps = bCorpsService.getById(bills.getCorpId());
-				if (ObjectUtils.isNotNull(bills.getAccDept())){
+				if (ObjectUtils.isNotNull(bills.getAccDept())) {
 					R<Dept> deptR = sysClient.getDept(Long.parseLong(bills.getAccDept()));
 					if (deptR.isSuccess()) {
 						dept = deptR.getData();
@@ -1335,6 +1401,19 @@ 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)
+								.eq(Bills::getMasterId, bills.getId()));
+							if (!billsList.isEmpty()) {
+								List<Long> billsId = billsList.stream().map(Bills::getId).collect(Collectors.toList());
+								List<FeeCenter> feeCenters = feeCenterService.list(new LambdaQueryWrapper<FeeCenter>()
+									.in(FeeCenter::getPid, billsId));
+								if (!feeCenters.isEmpty()) {
+									feeCenterList.addAll(feeCenters);
+								}
+							}
+						}
 					}
 				} else {
 					AeaBills aeaBills = aeaBillsMapper.selectById(id);
@@ -1347,14 +1426,27 @@ public class AuditProecessServiceImpl extends ServiceImpl<AuditProecessMapper, L
 						} else {
 							userSrc = bCorpsService.getById(aeaBills.getSrcId());
 						}
+						if ("MM".equals(aeaBills.getBillType())) {
+							List<Bills> billsList = billsMapper.selectList(new LambdaQueryWrapper<Bills>()
+								.select(Bills::getId)
+								.eq(Bills::getMasterId, bills.getId()));
+							if (!billsList.isEmpty()) {
+								List<Long> billsId = billsList.stream().map(Bills::getId).collect(Collectors.toList());
+								List<FeeCenter> feeCenters = feeCenterService.list(new LambdaQueryWrapper<FeeCenter>()
+									.in(FeeCenter::getPid, billsId));
+								if (!feeCenters.isEmpty()) {
+									feeCenterList.addAll(feeCenters);
+								}
+							}
+						}
 					}
 				}
 			}
 		}
 		//计算 应收,应付人民币,美元各个合计金额
-		BigDecimal amountC = feeCenterList.stream().filter(e -> "RMB".equals(e.getCurCode()) && "C".equals(e.getDc())).map(FeeCenter::getAmount)
+		BigDecimal amountC = feeCenterList.stream().filter(e -> "CNY".equals(e.getCurCode()) && "C".equals(e.getDc())).map(FeeCenter::getAmount)
 			.reduce(BigDecimal.ZERO, BigDecimal::add);
-		BigDecimal amountD = feeCenterList.stream().filter(e -> "RMB".equals(e.getCurCode()) && "D".equals(e.getDc())).map(FeeCenter::getAmount)
+		BigDecimal amountD = feeCenterList.stream().filter(e -> "CNY".equals(e.getCurCode()) && "D".equals(e.getDc())).map(FeeCenter::getAmount)
 			.reduce(BigDecimal.ZERO, BigDecimal::add);
 		BigDecimal amountCUsd = feeCenterList.stream().filter(e -> "USD".equals(e.getCurCode()) && "C".equals(e.getDc())).map(FeeCenter::getAmount)
 			.reduce(BigDecimal.ZERO, BigDecimal::add);
@@ -1363,7 +1455,20 @@ public class AuditProecessServiceImpl extends ServiceImpl<AuditProecessMapper, L
 
 		//固定借,贷金额数组
 		BigDecimal[] amount = new BigDecimal[]{amountD, amountD, amountC, amountC, amountDUsd, amountDUsd, amountCUsd, amountCUsd};
-
+		BigDecimal rateC = new BigDecimal("0.00");
+		BigDecimal rateCRmb = new BigDecimal("0.00");
+		List<FeeCenter> rateListC = feeCenterList.stream().filter(e -> "USD".equals(e.getCurCode()) && "C".equals(e.getDc())).collect(Collectors.toList());
+		for (FeeCenter item : rateListC) {
+			rateCRmb = rateCRmb.add(item.getAmount().multiply(item.getExrate()));
+		}
+		rateC = rateCRmb.divide(amountCUsd, MathContext.DECIMAL32).setScale(4, RoundingMode.HALF_UP);
+		BigDecimal rateD = new BigDecimal("0.00");
+		BigDecimal rateDRmb = new BigDecimal("0.00");
+		List<FeeCenter> rateListD = feeCenterList.stream().filter(e -> "USD".equals(e.getCurCode()) && "D".equals(e.getDc())).collect(Collectors.toList());
+		for (FeeCenter item : rateListD) {
+			rateDRmb = rateDRmb.add(item.getAmount().multiply(item.getExrate()));
+		}
+		rateD = rateDRmb.divide(amountDUsd, MathContext.DECIMAL32).setScale(4, RoundingMode.HALF_UP);
 		//创建凭证主表信息
 		FinVouchers finVouchers = new FinVouchers();
 		String deptId = "";
@@ -1390,7 +1495,22 @@ public class AuditProecessServiceImpl extends ServiceImpl<AuditProecessMapper, L
 			throw new RuntimeException("生成订单编号失败");
 		}
 		finVouchers.setBillNo((String) clientBillNo.getData());
+		finVouchers.setVoucherType("记");
+		BusinessBillNo businessBillNo1 = new BusinessBillNo();
+		businessBillNo1.setBusinessTypeId(businessType.getId());
+		businessBillNo1.setCode("记");
+		R voucherNo = businessBillNoService.getVoucherNoLos(businessBillNo1);
+		if (!clientBillNo.isSuccess()) {
+			TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
+			throw new RuntimeException("生成凭证号失败");
+		}
+		finVouchers.setVoucherNo((String) voucherNo.getData());
+		finVouchers.setVoucherSource(typeName);
 		finVouchers.setVoucherDate(new Date());
+		LocalDate currentDate = LocalDate.now();
+		finVouchers.setAccountYear(currentDate.getYear());
+		finVouchers.setAccountMonth(currentDate.getMonthValue());
+		finVouchers.setAccountDay(currentDate.getDayOfMonth());
 		finVouchers.setCreateTime(new Date());
 		finVouchers.setCreateUser(AuthUtil.getUserId());
 		finVouchers.setCreateUserName(AuthUtil.getUserName());
@@ -1406,6 +1526,7 @@ 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) {
@@ -1436,14 +1557,14 @@ public class AuditProecessServiceImpl extends ServiceImpl<AuditProecessMapper, L
 				finVouchersItems.setAccountProperty(accounts.getProperty());
 				finVouchersItems.setAccountLevel(accounts.getLevel());
 				finVouchersItems.setDc(item.getAmountDirection());
-				finVouchersItems.setCurCode(accounts.getCurCode());
-				finVouchersItems.setExrate(accounts.getExrate());
+				finVouchersItems.setCurCode(item.getCurrencyCode());
 				/*判断是否人民币,美元
 				 * 人民币 判断模版借贷方向与科目借贷方向是否一致 true D+D=正 D+C=负 C+C=正 C+D=负
 				 * 美元 判断模版借贷方向与科目借贷方向是否一致 true D+D=正 D+C=负 C+C=正 C+D=负
 				 * 借或贷金额为零时跳过本次循环
 				 * */
-				if ("RMB".equals(item.getCurrencyCode())) {
+				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) {
@@ -1452,7 +1573,7 @@ public class AuditProecessServiceImpl extends ServiceImpl<AuditProecessMapper, L
 								continue;
 							}
 						} else {
-							finVouchersItems.setAmountDr(new BigDecimal("0.00").subtract(amount[count - 1]));
+							finVouchersItems.setAmountCr(new BigDecimal("0.00").subtract(amount[count - 1]));
 						}
 					} else {
 						if ("D".equals(accounts.getDc())) {
@@ -1467,21 +1588,27 @@ public class AuditProecessServiceImpl extends ServiceImpl<AuditProecessMapper, L
 					}
 				} 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.setAmountDrUsd(new BigDecimal("0.00").subtract(amount[count - 1]));
+							finVouchersItems.setAmountCrUsd(new BigDecimal("0.00").subtract(amount[count - 1]));
+							finVouchersItems.setAmountCr(finVouchersItems.getAmountCrUsd().multiply(rateD));
 						}
 					} 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 {
 								continue;
 							}
@@ -1489,8 +1616,10 @@ public class AuditProecessServiceImpl extends ServiceImpl<AuditProecessMapper, L
 					}
 				}
 				//计算借,贷人民币与美金合计人民币金额
-				finVouchersItems.setAmountDrLoc(finVouchersItems.getAmountDr().add(bCurrencyService.converterCny("USD", finVouchersItems.getAmountDrUsd(), "D")));
-				finVouchersItems.setAmountCrLoc(finVouchersItems.getAmountCr().add(bCurrencyService.converterCny("USD", finVouchersItems.getAmountCrUsd(), "C")));
+				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")));
+				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")));
 				finVouchersItems.setIsCorp(accounts.getIsCorp());
 				//判断是否核算客户 true 向明细中客户字段复制
 				if (1 == finVouchersItems.getIsCorp()) {
@@ -1525,12 +1654,111 @@ public class AuditProecessServiceImpl extends ServiceImpl<AuditProecessMapper, L
 				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(" ");
+							}
+						} 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(" ");
+							}
+						} 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 {
+							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(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(" ");
+							}
+						} else {
+							formulasValue.append(field.get(amendsDetail)).append(" ");
+						}
+					} catch (Exception e) {
+						throw new RuntimeException(e);
+					}
+				}
+			}
+			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));
+		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));
+		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));
+		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));
+		finVouchers.setAmountCrUsd(amountCrUSD);
+		finVouchers.setAmountDrLoc(amountDrCNY.add(bCurrencyService.converterCny("USD", amountDrUSD, "D")));
+		finVouchers.setAmountCrLoc(amountCrCNY.add(bCurrencyService.converterCny("USD", amountCrUSD, "C")));
+		finVouchers.setDescr(finVouchersItemsList.get(0).getDescr());
+		if (finVouchersItemsList.stream().anyMatch(e -> "USD".equals(e.getCurCode()))) {
+			finVouchers.setIsForeign(1);
+		}
+		finVouchersMapper.updateById(finVouchers);
 	}
 
 	@Override
+	@Transactional(rollbackFor = Exception.class)
+	@GlobalTransactional(rollbackFor = Exception.class, timeoutMills = 12000000)
 	public void losAeBillsCheck(LosAuditProecess auditProecess) {
 		//查看最新操作记录,防止重复提交
 		LosAuditProecess proecessTemp = baseMapper.selectById(auditProecess.getId());
@@ -1813,6 +2041,8 @@ public class AuditProecessServiceImpl extends ServiceImpl<AuditProecessMapper, L
 	}
 
 	@Override
+	@Transactional(rollbackFor = Exception.class)
+	@GlobalTransactional(rollbackFor = Exception.class, timeoutMills = 12000000)
 	public void losCustomsDeclarationCheck(LosAuditProecess auditProecess) {
 		//查看最新操作记录,防止重复提交
 		LosAuditProecess proecessTemp = baseMapper.selectById(auditProecess.getId());

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

@@ -127,7 +127,8 @@ public class FinVouchersController extends BladeController {
 	@ApiOperationSupport(order = 8)
 	@ApiOperation(value = "删除", notes = "传入ids")
 	public R remove(@ApiParam(value = "主键集合", required = true) @RequestParam String ids) {
-		return R.status(finVouchersService.removeByIds(Func.toLongList(ids)));
+		finVouchersService.removeIds(Func.toLongList(ids));
+		return R.data("操作成功");
 	}
 
 	/**

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

@@ -22,6 +22,8 @@ import org.springblade.los.finance.vouchers.vo.FinVouchersVO;
 import com.baomidou.mybatisplus.extension.service.IService;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 
+import java.util.List;
+
 /**
  * 业务-财务凭证 服务类
  *
@@ -66,4 +68,6 @@ public interface IFinVouchersService extends IService<FinVouchers> {
 	 * @return
 	 */
 	R revokeFinVouchers(String ids);
+
+	void removeIds(List<Long> longList);
 }

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

@@ -30,6 +30,7 @@ import org.springblade.los.basic.business.service.IBusinessTypeService;
 import org.springblade.los.basic.cur.service.IBCurrencyService;
 import org.springblade.los.billno.entity.BusinessBillNo;
 import org.springblade.los.billno.service.IBusinessBillNoService;
+import org.springblade.los.business.sea.entity.Bills;
 import org.springblade.los.finance.fee.entity.FeeCenter;
 import org.springblade.los.finance.fee.entity.FinAccBills;
 import org.springblade.los.finance.fee.service.IFeeCenterService;
@@ -46,6 +47,7 @@ import org.springframework.transaction.annotation.Transactional;
 import org.springframework.transaction.interceptor.TransactionAspectSupport;
 
 import java.math.BigDecimal;
+import java.time.LocalDate;
 import java.util.ArrayList;
 import java.util.Date;
 import java.util.List;
@@ -130,6 +132,21 @@ public class FinVouchersServiceImpl extends ServiceImpl<FinVouchersMapper, FinVo
 				return R.fail(500, "生成订单编号失败");
 			}
 			finVouchers.setBillNo((String) clientBillNo.getData());
+			finVouchers.setVoucherType("记");
+			BusinessBillNo businessBillNo1 = new BusinessBillNo();
+			businessBillNo1.setBusinessTypeId(businessType.getId());
+			businessBillNo1.setCode("记");
+			R voucherNo = businessBillNoService.getVoucherNoLos(businessBillNo1);
+			if (!clientBillNo.isSuccess()) {
+				TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
+				throw new RuntimeException("生成凭证号失败");
+			}
+			finVouchers.setVoucherNo((String) voucherNo.getData());
+			finVouchers.setVoucherDate(new Date());
+			LocalDate currentDate = LocalDate.now();
+			finVouchers.setAccountYear(currentDate.getYear());
+			finVouchers.setAccountMonth(currentDate.getMonthValue());
+			finVouchers.setAccountDay(currentDate.getDayOfMonth());
 			finVouchers.setCreateTime(new Date());
 			finVouchers.setCreateUser(AuthUtil.getUserId());
 			finVouchers.setCreateUserName(AuthUtil.getUserName());
@@ -359,4 +376,22 @@ public class FinVouchersServiceImpl extends ServiceImpl<FinVouchersMapper, FinVo
 		return R.data("");
 	}
 
+	@Override
+	public void removeIds(List<Long> ids) {
+		List<FinVouchers> finVouchersList = baseMapper.selectList(new LambdaQueryWrapper<FinVouchers>()
+			.eq(FinVouchers::getTenantId, AuthUtil.getTenantId())
+			.eq(FinVouchers::getIsDeleted, 0)
+			.in(FinVouchers::getId, ids));
+		List<FinVouchersItems> finVouchersItems = finVouchersItemsService.list(new LambdaQueryWrapper<FinVouchersItems>()
+			.eq(FinVouchersItems::getTenantId, AuthUtil.getTenantId())
+			.eq(FinVouchersItems::getIsDeleted, 0)
+			.in(FinVouchersItems::getPid, ids));
+		List<Long> itemIdList = finVouchersItems.stream().map(FinVouchersItems::getId).collect(Collectors.toList());
+		finVouchersItemsService.removeByIds(itemIdList);
+		for (FinVouchers item : finVouchersList) {
+			businessBillNoService.deteleFinVouchers(item);
+		}
+		baseMapper.deleteBatchIds(ids);
+	}
+
 }