From 21dfddd6e09d32a50a636fff62a3d8a2ed362d5a Mon Sep 17 00:00:00 2001
From: shiyunteng <shiyunteng@example.com>
Date: 星期四, 20 八月 2026 16:29:49 +0800
Subject: [PATCH] feat:合同标的物新增导入 银行流水强制确认 简易合同新增 发票重开 合同标的物导入

---
 platformx-business-finance-biz/src/main/java/com/by4cloud/platformx/business/service/impl/ContractServiceImpl.java |  123 +++++++++++++++++++++++++++++++++--------
 1 files changed, 99 insertions(+), 24 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 a0d71bb..4245c12 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
@@ -1,6 +1,7 @@
 package com.by4cloud.platformx.business.service.impl;
 
 import cn.hutool.core.bean.BeanUtil;
+import cn.hutool.core.collection.CollUtil;
 import cn.hutool.core.convert.Convert;
 import cn.hutool.core.date.DatePattern;
 import cn.hutool.core.date.DateUtil;
@@ -54,6 +55,8 @@
 import java.util.concurrent.atomic.AtomicReference;
 import java.util.stream.Collectors;
 
+;
+
 /**
  * @author cd
  * @description
@@ -80,6 +83,7 @@
 	private final PaymentSlipMapper paymentSlipMapper;
 	private final ContractInvoiceMapper contractInvoiceMapper;
 	private final StringRedisTemplate redisTemplate;
+	private final ContractOutBoundMapper contractOutBoundMapper;
 
 	@Value("${erp.ymj}")
 	private String ymjErp;
@@ -98,6 +102,12 @@
 
 	@Value("${dept.smj}")
 	private String smj;
+
+	@Value("${dept.smjsc}")
+	private String smjsc;
+
+	@Value("${dept.smjzt}")
+	private String smjzt;
 
 	@Value("${dept.sgb}")
 	private String sgb;
@@ -155,11 +165,12 @@
 			}
 		}
 
-		if (ArrayUtil.isEmpty(addDTO.getContractSubjectMatter().toArray())){
+		if (CollUtil.isEmpty(addDTO.getContractSubjectMatter())){
 			return R.failed("鏍囩殑鐗╀笉鑳戒负绌�");
 		}
 
-		if (StrUtil.equals(SecurityUtils.getUser().getCompId()+"",smj)){
+		if (StrUtil.equals(SecurityUtils.getUser().getCompId()+"",smj)||StrUtil.equals(SecurityUtils.getUser().getCompId()+"",smjsc)||
+				StrUtil.equals(SecurityUtils.getUser().getCompId()+"",smjzt)){
 			contract.setContractNo(generateSMJContractNo());
 		}
 		if (StrUtil.equals(SecurityUtils.getUser().getCompId()+"",sgb)){
@@ -183,7 +194,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());
@@ -214,7 +225,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();
@@ -282,7 +293,8 @@
 		contract.setPaidAmount(new BigDecimal("0"));
 		contract.setBillingAmout(new BigDecimal("0"));
 		contract.setNickName(SecurityUtils.getUser().getNickname());
-		if (StrUtil.equals(SecurityUtils.getUser().getCompId()+"",smj)){
+		if (StrUtil.equals(SecurityUtils.getUser().getCompId()+"",smj)||StrUtil.equals(SecurityUtils.getUser().getCompId()+"",smjsc)||
+				StrUtil.equals(SecurityUtils.getUser().getCompId()+"",smjzt)){
 			contract.setContractNo(generateSMJContractNo());
 		}
 		if (StrUtil.equals(SecurityUtils.getUser().getCompId()+"",sgb)){
@@ -323,7 +335,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 -> {
@@ -350,7 +362,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);
@@ -398,12 +410,33 @@
 		if (ObjUtil.isNotNull(a)){
 			detailVo.setPartyAOrgCode(a.getCreditCode());
 		}
+		List<ContractOutBound> outBoundList = contractOutBoundMapper.selectList(Wrappers.<ContractOutBound>lambdaQuery()
+				.eq(ContractOutBound::getContractId,id).orderByAsc(ContractOutBound::getOutBoundTime));
+		if (CollUtil.isNotEmpty(outBoundList)){
+			detailVo.setContractOutBound(outBoundList);
+		}
+		List<ContractInvoice> invoiceList = contractInvoiceMapper.selectList(Wrappers.<ContractInvoice>lambdaQuery()
+				.eq(ContractInvoice::getContractId,id).orderByAsc(ContractInvoice::getCreateTime));
+		if (CollUtil.isNotEmpty(invoiceList)){
+			detailVo.setContractInvoice(invoiceList);
+		}
+		List<PaymentSlip> slipList = paymentSlipMapper.selectList(Wrappers.<PaymentSlip>lambdaQuery()
+				.eq(PaymentSlip::getContractId,id).orderByAsc(PaymentSlip::getPaymentTime));
+		if (CollUtil.isNotEmpty(slipList)){
+			detailVo.setPaymentSlip(slipList);
+		}
 		return detailVo;
 	}
 
 	@Override
 	public R startApproval(Long id) {
 		Contract contract = baseMapper.selectById(id);
+
+		//绠�鏄撳悎鍚屾棤娉曠户缁悗缁搷浣�
+		if (StrUtil.equals(contract.getContractCategory(), "simple")){
+			return R.failed("璇疯ˉ鍏呮爣鐨勭墿鍜屾敹娆鹃樁娈靛悗鍐嶈繘琛屾搷浣滐紒");
+		}
+
 		//鍚姩娴佺▼
 		ProcessInstanceParamDto dto = new ProcessInstanceParamDto();
 		Map<String, Object> map = BeanUtil.beanToMap(contract);
@@ -423,10 +456,11 @@
 		contract.setContractStatus(2);
 		baseMapper.updateById(contract);
 
+
 		List<ContractSubjectMatter> subjectMatterList = contractSubjectMatterMapper.selectList(Wrappers.<ContractSubjectMatter>lambdaQuery()
 				.eq(ContractSubjectMatter::getContractId,id));
 		if (StrUtil.isNotEmpty(contract.getContractCategory()) && StrUtil.equals(contract.getContractCategory(), "water_house")) {
-			if (ArrayUtil.isNotEmpty(subjectMatterList.toArray())) {
+			if (CollUtil.isNotEmpty(subjectMatterList)) {
 				for (ContractSubjectMatter contractSubjectMatter: subjectMatterList)  {
 					if (StrUtil.equals(contract.getExecFrequency(), "1")) {
 						Long weeksTrue = DateUtil.betweenWeek(DateUtil.beginOfWeek(contract.getEffectiveDate()),
@@ -576,7 +610,7 @@
 					.eq(ContractPaymentSchedule::getContractId, fitstSchedule.getContractId())
 					.gt(ContractPaymentSchedule::getStageOrder, fitstSchedule.getStageOrder())
 					.orderByAsc(ContractPaymentSchedule::getCreateTime));
-			if (ArrayUtil.isNotEmpty(afterSchedule.toArray()) && afterSchedule.size() == 1) {
+			if (ArrayUtil.isNotEmpty(afterSchedule) && afterSchedule.size() == 1) {
 				//鏈�鍚庨樁娈电敓鏁堟椂闂�
 				ContractPaymentSchedule endSchedule = afterSchedule.get(0);
 				if (StrUtil.equals(endSchedule.getStageName(), "璐ㄤ繚閲�")) {
@@ -610,7 +644,7 @@
 				contract.setNextScheduleName(endSchedule.getStageName());
 				baseMapper.updateById(contract);
 			}
-			if (ArrayUtil.isNotEmpty(afterSchedule.toArray()) && afterSchedule.size() > 1) {
+			if (ArrayUtil.isNotEmpty(afterSchedule) && afterSchedule.size() > 1) {
 				//绗竴闃舵鐢熸晥鏃堕棿
 //			fitstSchedule.setEffectiveEndDate(DateUtil.offsetDay(contract.getSignDate(),fitstSchedule.getAgreedDays()));
 //			contractPaymentScheduleMapper.updateById(fitstSchedule);
@@ -619,7 +653,7 @@
 				baseMapper.updateById(contract);
 			}
 			//鍙湁褰撳墠鍚堝悓绛惧瓧闃舵
-//		if(ArrayUtil.isEmpty(afterSchedule.toArray())){
+//		if(ArrayUtil.isEmpty(afterSchedule)){
 //			fitstSchedule.setEffectiveEndDate(DateUtil.offsetDay(contract.getSignDate(),fitstSchedule.getAgreedDays()));
 //			contractPaymentScheduleMapper.updateById(fitstSchedule);
 //		}
@@ -641,7 +675,7 @@
 					request.put("moneySum",contract.getAmount());
 					request.put("signManner","闈㈢");
 					request.put("salesman","");
-					if (ArrayUtil.isNotEmpty(subjectMatterList.toArray())){
+					if (ArrayUtil.isNotEmpty(subjectMatterList)){
 						JSONArray subjectMatter = new JSONArray();
 						subjectMatterList.stream().forEach(contractSubjectMatter -> {
 							JSONObject subjectMatterItem = new JSONObject();
@@ -834,7 +868,7 @@
 					outAmountList.add(outConfirm.getTransationAmount());
 				}
 			}
-			if (ArrayUtil.isNotEmpty(outAmountList.toArray())) {
+			if (ArrayUtil.isNotEmpty(outAmountList)) {
 				BigDecimal currentInSum = outAmountList.stream().reduce(BigDecimal.ZERO, BigDecimal::add);
 				//鏂板褰撳墠鍚堝悓 璧勯噾杞叆
 				PaymentConfirm inConfirm = BeanUtil.copyProperties(paymentConfirm, PaymentConfirm.class, "id", "transationAmount",
@@ -870,7 +904,7 @@
 				.lt(ContractPaymentSchedule::getEffectiveEndDate, DateUtil.today())
 				.ne(ContractPaymentSchedule::getPaymentStatus, "2")
 				.ne(ContractPaymentSchedule::getPaymentStatus, 3));
-		if (ArrayUtil.isNotEmpty(scheduleList.toArray())) {
+		if (ArrayUtil.isNotEmpty(scheduleList)) {
 			scheduleList.stream().forEach(contractPaymentSchedule -> {
 				Contract contract = baseMapper.selectById(contractPaymentSchedule.getContractId());
 				if (ObjUtil.isNotNull(contract)) {
@@ -949,7 +983,8 @@
 		newContract.setErpPushFlag("0");
 		newContract.setContractStatus(0);
 		newContract.setBillingAmout(new BigDecimal("0"));
-		if (StrUtil.equals(SecurityUtils.getUser().getCompId()+"",smj)){
+		if (StrUtil.equals(SecurityUtils.getUser().getCompId()+"",smj)||StrUtil.equals(SecurityUtils.getUser().getCompId()+"",smjsc)||
+				StrUtil.equals(SecurityUtils.getUser().getCompId()+"",smjzt)){
 			newContract.setContractNo(generateSMJContractNo());
 		}
 		if (StrUtil.equals(SecurityUtils.getUser().getCompId()+"",sgb)){
@@ -1077,7 +1112,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.toArray())) {
+		if (ArrayUtil.isNotEmpty(execDateList)) {
 			execDateList.stream().forEach(contractExecDate -> {
 				Contract contract = baseMapper.selectById(contractExecDate.getContractId());
 				ContractSubjectMatter subjectMatter = contractSubjectMatterMapper.selectOne(Wrappers.<ContractSubjectMatter>lambdaQuery()
@@ -1587,10 +1622,10 @@
 
 	@Override
 	public R addContractSgb(ContractAddDTO addDTO) {
-		if (ArrayUtil.isEmpty(addDTO.getContractSubjectMatter().toArray())){
+		if (ArrayUtil.isEmpty(addDTO.getContractSubjectMatter())){
 			return R.failed("璇锋坊鍔犳爣鐨勭墿");
 		}
-		if (ArrayUtil.isEmpty(addDTO.getContractPaymentSchedule().toArray())){
+		if (ArrayUtil.isEmpty(addDTO.getContractPaymentSchedule())){
 			return R.failed("璇锋坊鍔犱粯娆鹃樁娈垫垨浠樻闃舵缂哄皯");
 		}
 		if (!isValidPaymentStages(addDTO.getContractPaymentSchedule())){
@@ -1710,10 +1745,10 @@
 
 	@Override
 	public R updateContractSgb(ContractUpdateDTO updateDTO) {
-		if (ArrayUtil.isEmpty(updateDTO.getContractSubjectMatter().toArray())){
+		if (ArrayUtil.isEmpty(updateDTO.getContractSubjectMatter())){
 			return R.failed("璇锋坊鍔犳爣鐨勭墿");
 		}
-		if (ArrayUtil.isEmpty(updateDTO.getContractPaymentSchedule().toArray())){
+		if (ArrayUtil.isEmpty(updateDTO.getContractPaymentSchedule())){
 			return R.failed("璇锋坊鍔犱粯娆鹃樁娈垫垨浠樻闃舵缂哄皯");
 		}
 		if (!isValidPaymentStages(updateDTO.getContractPaymentSchedule())){
@@ -1964,20 +1999,22 @@
 	@Override
 	public Page fourAssociation(Page page,ContractQueryDTO queryDTO) {
 		Page<FourAssociationPageVo> page1 = baseMapper.fourAssociation(page,queryDTO,DataScope.of("comp_id"));
-		if (ArrayUtil.isNotEmpty(page1.getRecords().toArray())){
+		if (ArrayUtil.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.toArray())){
+				if (ArrayUtil.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.toArray())){
+				if (ArrayUtil.isNotEmpty(invoices)){
 					fourAssociationPageVo.setInvoiceVoList(BeanUtil.copyToList(invoices, ContractInvoiceVo.class));
 				}
 				if (fourAssociationPageVo.getAmount().compareTo(fourAssociationPageVo.getPaidAmount())==0&&
-						fourAssociationPageVo.getAmount().compareTo(fourAssociationPageVo.getBillingAmout())==0){
+						fourAssociationPageVo.getAmount().compareTo(fourAssociationPageVo.getBillingAmout())==0&&
+					ArrayUtil.isNotEmpty(slips)&&ArrayUtil.isNotEmpty(invoices)
+				){
 					fourAssociationPageVo.setAssociation("宸插畬鎴�");
 				}
 			});
@@ -2195,4 +2232,42 @@
 			e.printStackTrace();
 		}
 	}
+
+	@Override
+	public R addSimple(ContractAddDTO addDTO) {
+		Contract contract = BeanUtil.copyProperties(addDTO, Contract.class);
+		contract.setPartyBId(SecurityUtils.getUser().getCompId());
+		contract.setPartyB(SecurityUtils.getUser().getCompName());
+		if (StrUtil.isEmpty(addDTO.getPartyA())){
+			BusinessCustomer bc = businessCustomerMapper.selectById(addDTO.getPartyAId());
+			if (ObjUtil.isNotNull(bc)){
+				contract.setPartyA(bc.getCompanyName());
+			}
+		}
+
+		contract.setPaidAmount(new BigDecimal("0"));
+		contract.setBillingStatus("1");
+		contract.setBillingAmout(new BigDecimal("0"));
+		contract.setErpPushFlag("0");
+		contract.setNickName(SecurityUtils.getUser().getNickname());
+
+		if (StrUtil.equals(SecurityUtils.getUser().getCompId()+"",smj)||StrUtil.equals(SecurityUtils.getUser().getCompId()+"",smjsc)||
+				StrUtil.equals(SecurityUtils.getUser().getCompId()+"",smjzt)){
+			contract.setContractNo(generateSMJContractNo());
+		}
+		if (StrUtil.equals(SecurityUtils.getUser().getCompId()+"",sgb)){
+			contract.setContractNo(generateGYBContractNo());
+		}
+		if (StrUtil.equals(SecurityUtils.getUser().getCompId()+"",ymj)){
+			contract.setContractNo(generateYMJContractNo());
+		}
+		if (StrUtil.equals(SecurityUtils.getUser().getCompId()+"",tfgs)){
+			contract.setContractNo(generateTFContractNo());
+		}
+		if (StrUtil.equals(SecurityUtils.getUser().getCompId()+"",jxc)){
+			contract.setContractNo(generateJXCContractNo());
+		}
+		baseMapper.insert(contract);
+		return R.ok();
+	}
 }

--
Gitblit v1.9.1