From 9171db8f5ddd91b4619bf6a928dcbe98b82f33a0 Mon Sep 17 00:00:00 2001
From: shiyunteng <shiyunteng@example.com>
Date: 星期三, 09 九月 2026 15:34:14 +0800
Subject: [PATCH] feat:工业泵收款推送 bip收款单与收款确认分离  开票前校验产品是否维护税收分类信息

---
 platformx-business-finance-biz/src/main/java/com/by4cloud/platformx/business/service/impl/ContractServiceImpl.java |  107 ++++++++++++++++++++++++++++++++++++++++++++---------
 1 files changed, 88 insertions(+), 19 deletions(-)

diff --git a/platformx-business-finance-biz/src/main/java/com/by4cloud/platformx/business/service/impl/ContractServiceImpl.java b/platformx-business-finance-biz/src/main/java/com/by4cloud/platformx/business/service/impl/ContractServiceImpl.java
index 9f3abfb..101e539 100644
--- a/platformx-business-finance-biz/src/main/java/com/by4cloud/platformx/business/service/impl/ContractServiceImpl.java
+++ b/platformx-business-finance-biz/src/main/java/com/by4cloud/platformx/business/service/impl/ContractServiceImpl.java
@@ -92,6 +92,7 @@
 	private final ContractOutBoundMapper contractOutBoundMapper;
 	private final RemoteDictService remoteDictService;
 	private final ContractPaymentScheduleProcessService processService;
+	private final ContractSubjectMatterChangeMapper changeMapper;
 
 	@Value("${erp.ymj}")
 	private String ymjErp;
@@ -435,9 +436,35 @@
 			detailVo.setPaymentSlip(slipList);
 		}
 		BusinessCustomer customer = businessCustomerMapper.selectById(contract.getPartyAId());
+
+		ContractInvoiceBipVo bipVo = new ContractInvoiceBipVo();
+		bipVo.setDjrq(DateUtil.today());
+		R<SysDept> r = remoteDeptService.getById(contract.getPartyBId());
+		if (r.isOk()) {
+			bipVo.setKpzz(r.getData().getBipCode());
+		}
+
 		if (ObjUtil.isNotNull(customer)) {
 			detailVo.setInvoiceType(customer.getInvoiceType());
+			bipVo.setYwzz(r.getData().getBipCode());
 		}
+		R<SysDept> rDept = remoteDeptService.getById(SecurityUtils.getUser().getDeptId());
+		if (rDept.isOk()) {
+			bipVo.setBm(rDept.getData().getOrgCode());
+			bipVo.setHsdy(rDept.getData().getOrgCode());
+		}
+		bipVo.setYwy(SecurityUtils.getUser().getNickname());
+		bipVo.setPzzdr(SecurityUtils.getUser().getNickname());
+		bipVo.setJylx("ZBYXGLXT");
+		bipVo.setWldxlx("1");
+		bipVo.setKh(customer.getCreditCode());
+		bipVo.setBz("浜烘皯甯�");
+		bipVo.setFjzs("1");
+		bipVo.setSfzy("鏄�");
+		bipVo.setSfnbwl("鏄�");
+		bipVo.setSfjyjs("鍚�");
+		bipVo.setDjfx("1");
+		detailVo.setBipVo(bipVo);
 		return detailVo;
 	}
 
@@ -569,7 +596,7 @@
 					request.put("moneySum", contract.getAmount());
 					request.put("signManner", "闈㈢");
 					request.put("salesman", "");
-					if (ArrayUtil.isNotEmpty(subjectMatterList)) {
+					if (CollUtil.isNotEmpty(subjectMatterList)) {
 						JSONArray subjectMatter = new JSONArray();
 						subjectMatterList.stream().forEach(contractSubjectMatter -> {
 							JSONObject subjectMatterItem = new JSONObject();
@@ -623,7 +650,7 @@
 					request.put("moneySum", contract.getAmount());
 					request.put("signManner", "闈㈢");
 					request.put("salesman", "");
-					if (ArrayUtil.isNotEmpty(subjectMatterList)) {
+					if (CollUtil.isNotEmpty(subjectMatterList)) {
 						JSONArray subjectMatter = new JSONArray();
 						subjectMatterList.stream().forEach(contractSubjectMatter -> {
 							JSONObject subjectMatterItem = new JSONObject();
@@ -681,9 +708,7 @@
 				if (StrUtil.equals(contract.getPartyBId() + "", tfgs) && StrUtil.isNotEmpty(tfgsErp)) {
 					//閫氭柟鍏徃閫氳繃绯荤粺褰曞叆
 				}
-				if (StrUtil.equals(contract.getPartyBId() + "", sgb) && StrUtil.isNotEmpty(sgbErp)) {
-					//鐭冲伐娉典富鍔ㄦ帹閫佺郴缁�
-				}
+
 			} catch (Exception e) {
 				e.printStackTrace();
 			}
@@ -865,7 +890,7 @@
 				.lt(ContractPaymentSchedule::getEffectiveEndDate, DateUtil.today())
 				.ne(ContractPaymentSchedule::getPaymentStatus, "2")
 				.ne(ContractPaymentSchedule::getPaymentStatus, 3));
-		if (ArrayUtil.isNotEmpty(scheduleList)) {
+		if (CollUtil.isNotEmpty(scheduleList)) {
 			scheduleList.stream().forEach(contractPaymentSchedule -> {
 				Contract contract = baseMapper.selectById(contractPaymentSchedule.getContractId());
 				if (ObjUtil.isNotNull(contract)) {
@@ -1073,7 +1098,7 @@
 	public R genCycleReceiced() {
 		List<ContractExecDate> execDateList = contractExecDateMapper.selectList(Wrappers.<ContractExecDate>lambdaQuery()
 				.le(ContractExecDate::getExecDate, DateUtil.today()).eq(ContractExecDate::getGenFlag, "0"));
-		if (ArrayUtil.isNotEmpty(execDateList)) {
+		if (CollUtil.isNotEmpty(execDateList)) {
 			execDateList.stream().forEach(contractExecDate -> {
 				Contract contract = baseMapper.selectById(contractExecDate.getContractId());
 				ContractSubjectMatter subjectMatter = contractSubjectMatterMapper.selectOne(Wrappers.<ContractSubjectMatter>lambdaQuery()
@@ -1585,10 +1610,10 @@
 
 	@Override
 	public R addContractSgb(ContractAddDTO addDTO) {
-		if (ArrayUtil.isEmpty(addDTO.getContractSubjectMatter())) {
+		if (CollUtil.isEmpty(addDTO.getContractSubjectMatter())) {
 			return R.failed("璇锋坊鍔犳爣鐨勭墿");
 		}
-		if (ArrayUtil.isEmpty(addDTO.getContractPaymentSchedule())) {
+		if (CollUtil.isEmpty(addDTO.getContractPaymentSchedule())) {
 			return R.failed("璇锋坊鍔犱粯娆鹃樁娈垫垨浠樻闃舵缂哄皯");
 		}
 		if (!isValidPaymentStages(addDTO.getContractPaymentSchedule())) {
@@ -1637,7 +1662,7 @@
 		}
 		baseMapper.insert(contract);
 
-		if (ArrayUtil.isNotEmpty(addDTO.getContractSubjectMatter())) {
+		if (CollUtil.isNotEmpty(addDTO.getContractSubjectMatter())) {
 			addDTO.getContractSubjectMatter().stream().forEach(contractSubjectMatterAddDTO -> {
 				ContractSubjectMatter subjectMatter = BeanUtil.copyProperties(contractSubjectMatterAddDTO, ContractSubjectMatter.class);
 				subjectMatter.setContractId(contract.getId());
@@ -1668,7 +1693,7 @@
 
 		}
 
-		if (ArrayUtil.isNotEmpty(addDTO.getContractPaymentSchedule())) {
+		if (CollUtil.isNotEmpty(addDTO.getContractPaymentSchedule())) {
 			AtomicInteger index = new AtomicInteger(1);
 			addDTO.getContractPaymentSchedule().stream().forEach(contractPaymentScheduleAddDTO -> {
 				int currentIndex = index.getAndIncrement();
@@ -1711,10 +1736,10 @@
 
 	@Override
 	public R updateContractSgb(ContractUpdateDTO updateDTO) {
-		if (ArrayUtil.isEmpty(updateDTO.getContractSubjectMatter())) {
+		if (CollUtil.isEmpty(updateDTO.getContractSubjectMatter())) {
 			return R.failed("璇锋坊鍔犳爣鐨勭墿");
 		}
-		if (ArrayUtil.isEmpty(updateDTO.getContractPaymentSchedule())) {
+		if (CollUtil.isEmpty(updateDTO.getContractPaymentSchedule())) {
 			return R.failed("璇锋坊鍔犱粯娆鹃樁娈垫垨浠樻闃舵缂哄皯");
 		}
 		if (!isValidPaymentStages(updateDTO.getContractPaymentSchedule())) {
@@ -1747,7 +1772,7 @@
 		}
 		baseMapper.updateById(contract);
 
-		if (ArrayUtil.isNotEmpty(updateDTO.getContractSubjectMatter())) {
+		if (CollUtil.isNotEmpty(updateDTO.getContractSubjectMatter())) {
 			contractSubjectMatterMapper.delete(Wrappers.<ContractSubjectMatter>lambdaQuery().eq(ContractSubjectMatter::getContractId, contract.getId()));
 
 			updateDTO.getContractSubjectMatter().stream().forEach(contractSubjectMatterAddDTO -> {
@@ -1773,7 +1798,7 @@
 			});
 		}
 
-		if (ArrayUtil.isNotEmpty(updateDTO.getContractPaymentSchedule())) {
+		if (CollUtil.isNotEmpty(updateDTO.getContractPaymentSchedule())) {
 			contractPaymentScheduleMapper.delete(Wrappers.<ContractPaymentSchedule>lambdaQuery().eq(ContractPaymentSchedule::getContractId, contract.getId()));
 
 			AtomicInteger index = new AtomicInteger(1);
@@ -1966,21 +1991,21 @@
 	@Override
 	public Page fourAssociation(Page page, ContractQueryDTO queryDTO) {
 		Page<FourAssociationPageVo> page1 = baseMapper.fourAssociation(page, queryDTO, DataScope.of("comp_id"));
-		if (ArrayUtil.isNotEmpty(page1.getRecords())) {
+		if (CollUtil.isNotEmpty(page1.getRecords())) {
 			page1.getRecords().stream().forEach(fourAssociationPageVo -> {
 				List<PaymentSlip> slips = paymentSlipMapper.selectList(Wrappers.<PaymentSlip>lambdaQuery().eq(PaymentSlip::getContractId, fourAssociationPageVo.getId())
 						.orderByAsc(PaymentSlip::getPaymentTime));
-				if (ArrayUtil.isNotEmpty(slips)) {
+				if (CollUtil.isNotEmpty(slips)) {
 					fourAssociationPageVo.setSlipVoList(BeanUtil.copyToList(slips, ContractSlipVo.class));
 				}
 				List<ContractInvoice> invoices = contractInvoiceMapper.selectList(Wrappers.<ContractInvoice>lambdaQuery().eq(ContractInvoice::getContractId, fourAssociationPageVo.getId())
 						.orderByAsc(ContractInvoice::getInvoiceTime));
-				if (ArrayUtil.isNotEmpty(invoices)) {
+				if (CollUtil.isNotEmpty(invoices)) {
 					fourAssociationPageVo.setInvoiceVoList(BeanUtil.copyToList(invoices, ContractInvoiceVo.class));
 				}
 				if (fourAssociationPageVo.getAmount().compareTo(fourAssociationPageVo.getPaidAmount()) == 0 &&
 						fourAssociationPageVo.getAmount().compareTo(fourAssociationPageVo.getBillingAmout()) == 0 &&
-						ArrayUtil.isNotEmpty(slips) && ArrayUtil.isNotEmpty(invoices)
+						CollUtil.isNotEmpty(slips) && CollUtil.isNotEmpty(invoices)
 				) {
 					fourAssociationPageVo.setAssociation("宸插畬鎴�");
 				}
@@ -2535,4 +2560,48 @@
 		}
 		return R.ok();
 	}
+
+
+	@Override
+	public R subjectChange(ContractSubjectChangeDTO changeDTO) {
+		Contract contract = baseMapper.selectById(changeDTO.getId());
+		if (ObjUtil.isNull(contract)){
+			return R.failed("鍚堝悓鐘舵�佸紓甯�");
+		}
+		if (contract.getBillingAmout().compareTo(new BigDecimal("0"))>0){
+			return R.failed("鍚堝悓宸插紑绁紝涓嶈兘杩涜鍙樻洿");
+		}
+		if (ObjUtil.isNotNull(contract.getOutBoundAmout())&&contract.getOutBoundAmout().compareTo(new BigDecimal("0"))>0){
+			return R.failed("鍚堝悓鏍囩殑鐗╁凡鍑哄簱锛屼笉鑳借繘琛屽彉鏇�");
+		}
+		if (CollUtil.isEmpty(changeDTO.getContractSubjectMatter())){
+			return R.failed("鍚堝悓鍙樻洿鍚庢爣鐨勭墿涓嶈兘涓虹┖");
+		}
+		BigDecimal changeAmount = changeDTO.getContractSubjectMatter().stream().map(subject->subject.getUnitPrice().multiply(subject.getQuantity())).reduce(BigDecimal.ZERO,BigDecimal::add);
+		if (contract.getAmount().compareTo(changeAmount)!=0){
+			return R.failed("鍚堝悓鍙樻洿鍚庢爣鐨勭墿鎬讳环蹇呴』涓庡悎鍚屾�讳环涓�鑷�");
+		}
+		List<ContractSubjectMatter> beforeList = contractSubjectMatterMapper.selectList(Wrappers.<ContractSubjectMatter>lambdaQuery().eq(ContractSubjectMatter::getContractId,changeDTO.getId()));
+		ContractSubjectMatterChange change = new ContractSubjectMatterChange();
+		change.setContractId(contract.getId());
+		change.setBeforeChange(JSONObject.toJSONString(beforeList));
+		change.setAfterChange(JSONObject.toJSONString(changeDTO.getContractSubjectMatter()));
+		changeMapper.insert(change);
+		contractSubjectMatterMapper.delete(Wrappers.<ContractSubjectMatter>lambdaQuery().eq(ContractSubjectMatter::getContractId,changeDTO.getId()));
+		changeDTO.getContractSubjectMatter().stream().forEach(contractSubjectMatterAddDTO -> {
+			ContractSubjectMatter subjectMatter = BeanUtil.copyProperties(contractSubjectMatterAddDTO, ContractSubjectMatter.class);
+			subjectMatter.setContractId(contract.getId());
+			subjectMatter.setLineNo(ItemGeneratorUtil.nextId());
+			subjectMatter.setDeliveredQuantity(new BigDecimal("0"));
+			subjectMatter.setDeliveryStatus(0);
+			subjectMatter.setTotalAmount(contractSubjectMatterAddDTO.getQuantity().multiply(contractSubjectMatterAddDTO.getUnitPrice()));
+			contractSubjectMatterMapper.insert(subjectMatter);
+		});
+		return R.ok();
+	}
+
+	@Override
+	public Page subjectChangePage(Page page, ContracQueryDTO queryDTO) {
+		return changeMapper.subjectChangePage(page,queryDTO,DataScope.of("comp_id"));
+	}
 }

--
Gitblit v1.9.1