liutao месяцев назад: 6
Родитель
Сommit
392c6c2b49

+ 70 - 56
src/main/java/com/sunxung/factoring/service/purchcontractmanagement/impl/PurchContractApprovalServiceImpl.java

@@ -32,6 +32,7 @@ import com.sunxung.factoring.service.sys.dto.AttachmentDto;
 import com.sunxung.factoring.service.sys.flowable.FlowableService;
 import com.sunxung.factoring.service.tradingPlatform.PlatformService;
 import com.sunxung.factoring.service.tradingPlatform.TradingPlatformInvoiceInfoService;
+import org.apache.bcel.generic.IF_ACMPEQ;
 import org.apache.pdfbox.pdmodel.PDDocument;
 import org.apache.pdfbox.util.PDFTextStripper;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -222,6 +223,9 @@ public class PurchContractApprovalServiceImpl extends ServiceImpl<PurchContractA
         //获取合同补充信息
         PurchContractReplenishInfo replenishInfo = purchContractReplenishInfoService
                 .lambdaQuery().eq(PurchContractReplenishInfo::getPurchContractApprovalId, purchContractApproval.getId()).one();
+        if (replenishInfo == null){
+            replenishInfo = new PurchContractReplenishInfo();
+        }
         replenishInfo.setContractName(purchContractBasicInfo.getContractName());
         replenishInfo.setContractNumber(purchContractBasicInfo.getContractNumber());
         purchContractApprovalVo.setPurchContractReplenishInfo(replenishInfo);
@@ -297,7 +301,7 @@ public class PurchContractApprovalServiceImpl extends ServiceImpl<PurchContractA
 
 
         //补充信息
-        PurchContractReplenishInfo replenishInfo = new PurchContractReplenishInfo();
+        PurchContractReplenishInfo replenishInfo = null;
 
         //需方收货人(该业务对应的供应商用户的项目经理)
         List<User> userList = new ArrayList<>();
@@ -382,9 +386,9 @@ public class PurchContractApprovalServiceImpl extends ServiceImpl<PurchContractA
                     user.setIdCard(c.getIdCard());
                     user.setName(c.getName());
                     users.add(user);
-                    purchContractApprovalVo.setUserList(users);
                 });
             }
+            purchContractApprovalVo.setUserList(users);
 
 
             //增值税要求
@@ -431,6 +435,9 @@ public class PurchContractApprovalServiceImpl extends ServiceImpl<PurchContractA
                 purchContractApprovalVo.getPurchContractApproval().setUploadPurchContracts(list);
             }
         }
+        if (replenishInfo == null){
+            replenishInfo = new PurchContractReplenishInfo();
+        }
         replenishInfo.setContractName(purch.getContractName());
         replenishInfo.setContractNumber(purch.getContractNumber());
 
@@ -465,7 +472,7 @@ public class PurchContractApprovalServiceImpl extends ServiceImpl<PurchContractA
             //删除之前的审批信息
             PurchContractApproval oldApproval = getLatestPurchContractApproval(purch.getId(), 0);
 
-            if (oldApproval != null) {
+            if (oldApproval != null && purchContractApproval.getApprovalConclusion().equals("pass")) {
                 //删除之前上传的合同信息
                 List<UploadPurchContract> oldUploadContracts = uploadPurchContractService.lambdaQuery().eq(UploadPurchContract::getPurchContractApprovalId, oldApproval.getId()).list();
                 if (CollectionUtil.isNotEmpty(oldUploadContracts)) {
@@ -544,62 +551,65 @@ public class PurchContractApprovalServiceImpl extends ServiceImpl<PurchContractA
         }
 
 
-        //添加合同补充信息
-        if (purchContractApprovalVo.getPurchContractReplenishInfo() != null) {
-            PurchContractReplenishInfo replenishInfo = purchContractApprovalVo.getPurchContractReplenishInfo();
-            replenishInfo.setPurchContractApprovalId(purchContractApproval.getId());
-            purchContractReplenishInfoService.save(replenishInfo);
-        }
+        if (purchContractApproval.getApprovalConclusion().equals("pass")) {
+           //添加合同补充信息
+            if (purchContractApprovalVo.getPurchContractReplenishInfo() != null) {
+                PurchContractReplenishInfo replenishInfo = purchContractApprovalVo.getPurchContractReplenishInfo();
+                replenishInfo.setPurchContractApprovalId(purchContractApproval.getId());
+                purchContractReplenishInfoService.save(replenishInfo);
+            }
 
 
-        //添加质量与验收
-        if (purchContractApprovalVo.getPurchContractQualityAccept() != null) {
-            PurchContractQualityAccept qualityAccept = purchContractApprovalVo.getPurchContractQualityAccept();
-            qualityAccept.setPurchContractApprovalId(purchContractApproval.getId());
-            purchContractQualityAcceptService.save(qualityAccept);
-        }
+            //添加质量与验收
+            if (purchContractApprovalVo.getPurchContractQualityAccept() != null) {
+                PurchContractQualityAccept qualityAccept = purchContractApprovalVo.getPurchContractQualityAccept();
+                qualityAccept.setPurchContractApprovalId(purchContractApproval.getId());
+                purchContractQualityAcceptService.save(qualityAccept);
+            }
 
-        //结算与付款
-        if (purchContractApprovalVo.getApprovalSettlePayment() != null) {
-            PurchContractApprovalSettlePayment approvalSettlePayment = purchContractApprovalVo.getApprovalSettlePayment();
-            approvalSettlePayment.setPurchContractApprovalId(purchContractApproval.getId());
-            approvalSettlePaymentService.save(approvalSettlePayment);
-        }
+            //结算与付款
+            if (purchContractApprovalVo.getApprovalSettlePayment() != null) {
+                PurchContractApprovalSettlePayment approvalSettlePayment = purchContractApprovalVo.getApprovalSettlePayment();
+                approvalSettlePayment.setPurchContractApprovalId(purchContractApproval.getId());
+                approvalSettlePaymentService.save(approvalSettlePayment);
+            }
 
-        //添加交货规定
-        if (purchContractApprovalVo.getPurchContractDeliverClause() != null) {
-            PurchContractDeliverClause deliverClause = purchContractApprovalVo.getPurchContractDeliverClause();
-            deliverClause.setPurchContractApprovalId(purchContractApproval.getId());
-            purchContractDeliverClauseService.save(deliverClause);
-        }
+            //添加交货规定
+            if (purchContractApprovalVo.getPurchContractDeliverClause() != null) {
+                PurchContractDeliverClause deliverClause = purchContractApprovalVo.getPurchContractDeliverClause();
+                deliverClause.setPurchContractApprovalId(purchContractApproval.getId());
+                purchContractDeliverClauseService.save(deliverClause);
+            }
 
-        //结算周期
-        if (purchContractApprovalVo.getApprovalSettleCycle() != null) {
-            PurchContractApprovalSettleCycle approvalSettleCycle = purchContractApprovalVo.getApprovalSettleCycle();
-            approvalSettleCycle.setPurchContractApprovalId(purchContractApproval.getId());
-            approvalSettleCycleService.save(approvalSettleCycle);
-        }
+            //结算周期
+            if (purchContractApprovalVo.getApprovalSettleCycle() != null) {
+                PurchContractApprovalSettleCycle approvalSettleCycle = purchContractApprovalVo.getApprovalSettleCycle();
+                approvalSettleCycle.setPurchContractApprovalId(purchContractApproval.getId());
+                approvalSettleCycleService.save(approvalSettleCycle);
+            }
 
-        //需方收货人
-        if (CollectionUtil.isNotEmpty(purchContractApprovalVo.getUserList())) {
-            for (User user : purchContractApprovalVo.getUserList()) {
-                PurchContractNeedUserRel needUserRel = new PurchContractNeedUserRel();
-                needUserRel.setName(user.getName());
-                needUserRel.setIdCard(user.getIdCard());
-                needUserRel.setMobile(user.getMobile());
-                needUserRel.setPurchContractApprovalId(purchContractApproval.getId());
-                needUserRel.setSysUserId(user.getId());
-                purchContractNeedUserRelService.save(needUserRel);
+            //需方收货人
+            if (CollectionUtil.isNotEmpty(purchContractApprovalVo.getUserList())) {
+                for (User user : purchContractApprovalVo.getUserList()) {
+                    PurchContractNeedUserRel needUserRel = new PurchContractNeedUserRel();
+                    needUserRel.setName(user.getName());
+                    needUserRel.setIdCard(user.getIdCard());
+                    needUserRel.setMobile(user.getMobile());
+                    needUserRel.setPurchContractApprovalId(purchContractApproval.getId());
+                    needUserRel.setSysUserId(user.getId());
+                    purchContractNeedUserRelService.save(needUserRel);
+                }
             }
-        }
 
-        //增值税要求
-        if (purchContractApprovalVo.getApprovalVatInfo() != null) {
-            PurchContractApprovalVatInfo approvalVatInfo = purchContractApprovalVo.getApprovalVatInfo();
-            approvalVatInfo.setPurchContractApprovalId(purchContractApproval.getId());
-            approvalVatInfoService.save(approvalVatInfo);
+            //增值税要求
+            if (purchContractApprovalVo.getApprovalVatInfo() != null) {
+                PurchContractApprovalVatInfo approvalVatInfo = purchContractApprovalVo.getApprovalVatInfo();
+                approvalVatInfo.setPurchContractApprovalId(purchContractApproval.getId());
+                approvalVatInfoService.save(approvalVatInfo);
+            }
         }
 
+
         //添加其他条款
         if (purchContractApprovalVo.getPurchContractOtherClause() != null && purchContractApprovalVo.getPurchContractOtherClause().size() > 0) {
             int i = 0;
@@ -611,13 +621,12 @@ public class PurchContractApprovalServiceImpl extends ServiceImpl<PurchContractA
             purchContractOtherClauseService.saveBatch(purchContractApprovalVo.getPurchContractOtherClause());
         }
         if (purchContractApprovalVo.getVisible().equals(1)) {
-            if (purchContractApproval.getUpload() != null && purchContractApproval.getUpload() == 1) {
+            if (purchContractApproval.getUpload() != null && purchContractApproval.getUpload() == 1 && purchContractApproval.getApprovalConclusion().equals("pass")) {
                 List<UploadPurchContract> uploadPurchContracts = purchContractApprovalVo.getPurchContractApproval().getUploadPurchContracts();
                 if (CollectionUtil.isEmpty(uploadPurchContracts)) {
                     throw new ValidatorException(CodeUtil.FAIL, "请上传合同文件!!!");
                 }
             }
-            //添加历史
             Map<String, Object> procVariables = new HashMap<>(1);
 
             Dictionary firstApprovalDict = dictService.getByCode(PurchContractStatusDict.ChildEnum.FIRST_APPROVAL.getCode());
@@ -642,12 +651,17 @@ public class PurchContractApprovalServiceImpl extends ServiceImpl<PurchContractA
                             //变更货物
                             SalesContractSupplementGoodsInfo salesContractSupplementGoods =
                                     salesContractSupplementGoodsInfoService.getById(purchContractGoodsInfo.getSalesContractGoodsInfoId());
-                            salesContractSupplementGoodsInfoService.lambdaUpdate().eq(SalesContractSupplementGoodsInfo::getId, salesContractSupplementGoods.getId())
-                                    .set(SalesContractSupplementGoodsInfo::getOccupy, 0).update();
+                            if (salesContractSupplementGoods != null) {
+                                salesContractSupplementGoodsInfoService.lambdaUpdate().eq(SalesContractSupplementGoodsInfo::getId, salesContractSupplementGoods.getId())
+                                        .set(SalesContractSupplementGoodsInfo::getOccupy, 0).update();
+                            }
+
                         } else {
                             CSalesContractGoodsInfo salesContractGoods = salesContractGoodsInfoService.getById(purchContractGoodsInfo.getSalesContractGoodsInfoId());
-                            salesContractGoodsInfoService.lambdaUpdate().eq(CSalesContractGoodsInfo::getId, salesContractGoods.getId())
-                                    .set(CSalesContractGoodsInfo::getOccupy, 0).update();
+                            if (salesContractGoods != null) {
+                                salesContractGoodsInfoService.lambdaUpdate().eq(CSalesContractGoodsInfo::getId, salesContractGoods.getId())
+                                        .set(CSalesContractGoodsInfo::getOccupy, 0).update();
+                            }
                         }
                     });
                 }
@@ -713,7 +727,7 @@ public class PurchContractApprovalServiceImpl extends ServiceImpl<PurchContractA
                 || contractApproval == null) {
             //贸易平台的信息
             Platform platform = platformService.getById(purch.getTradingPlatformId());
-            if (purchContractApprovalVo.getPurchContractReplenishInfo().getProjectAmountCategory() != null && platform.getAuthStatus().equals(1) && platform.isAutoSignStatus() && purchContractApprovalVo.getPurchContractApproval().getSignMode().equals(1)) {
+            if (purchContractApprovalVo.getPurchContractReplenishInfo().getProjectAmountCategory() != null && platform.getAuthStatus() == 1 && platform.isAutoSignStatus() && purchContractApprovalVo.getPurchContractApproval().getSignMode()== 1) {
                 //制作合同
                 File outFile = purchContractElectronicInfoService.makePurchContractDocx(purchContractManagement, purch);
                 //将docx转为pdf

+ 3 - 1
src/main/java/com/sunxung/factoring/service/purchcontractmanagement/impl/PurchContractSignConclusionServiceImpl.java

@@ -137,7 +137,9 @@ public class PurchContractSignConclusionServiceImpl extends ServiceImpl<PurchCon
             PurchContractApproval latestPurchContractApproval = purchContractApprovalService
                     .getOne(new QueryWrapper<PurchContractApproval>().eq("purch_contract_basic_info_id", purch.getId())
                             .eq("visible", 1)
-                            .orderByDesc("gmt_create").last("limit 1"));
+                            .eq("approval_conclusion", "pass")
+                            .orderByDesc("gmt_create")
+                            .last("limit 1"));
             if (latestPurchContractApproval == null) {
                 return null;
             }