Преглед на файлове

feat(供应商):流程调整

liutao преди 5 месеца
родител
ревизия
7ceec0350a
променени са 1 файла, в които са добавени 262 реда и са изтрити 247 реда
  1. 262 247
      src/main/java/com/sunxung/factoring/service/supplier/impl/SupplierApprovalFirstServiceImpl.java

+ 262 - 247
src/main/java/com/sunxung/factoring/service/supplier/impl/SupplierApprovalFirstServiceImpl.java

@@ -3,7 +3,6 @@ package com.sunxung.factoring.service.supplier.impl;
 import cn.hutool.json.JSONArray;
 import cn.hutool.json.JSONObject;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
-import com.sunxung.factoring.component.constance.SupplierScoringModel;
 import com.sunxung.factoring.component.enums.SupplierStatusEnums;
 import com.sunxung.factoring.component.exception.ServiceException;
 import com.sunxung.factoring.component.exception.ValidatorException;
@@ -29,6 +28,7 @@ import com.sunxung.factoring.service.sys.FileService;
 import com.sunxung.factoring.service.sys.FileStorageService;
 import com.sunxung.factoring.service.sys.UserService;
 import com.sunxung.factoring.service.sys.flowable.FlowableService;
+import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.stereotype.Service;
@@ -135,67 +135,71 @@ public class SupplierApprovalFirstServiceImpl extends ServiceImpl<SupplierApprov
     @Override
     @Transactional(rollbackFor = Exception.class)
     public void firstReview(SupplierInfo supplierInfo) {
-        //保存第一步审核结论
         SupplierApprovalFirst supplierApprovalFirst = lambdaQuery().eq(SupplierApprovalFirst::getcSupplierInfoId, supplierInfo.getId()).eq(SupplierApprovalFirst::getVisible, false).one();
-        if(supplierApprovalFirst == null){
-            supplierApprovalFirst = new SupplierApprovalFirst();
-        }
-        supplierApprovalFirst.setVisible(supplierInfo.getVisible());
-        supplierApprovalFirst.setApprovalComment(supplierInfo.getApprovalComment());
-        supplierApprovalFirst.setApprovalConclusion(supplierInfo.getApprovalConclusion());
-        save(supplierApprovalFirst);
         Enterprise guaranteeEnterprise = supplierInfo.getGuaranteeEnterprise();
         Enterprise enterprise = supplierInfo.getEnterprise();
-        if(supplierInfo.getApprovalConclusion().equals(ConstantConversionUtil.APPROVAL_RESULT_PASS)){
+        if (StringUtils.isEmpty(supplierInfo.getApprovalConclusion()) || supplierInfo.getApprovalConclusion().equals(ConstantConversionUtil.APPROVAL_RESULT_PASS)) {
+            //保存第一步审核结论
+            if (supplierApprovalFirst == null) {
+                supplierApprovalFirst = new SupplierApprovalFirst();
+            }
+            supplierApprovalFirst.setcSupplierInfoId(supplierInfo.getId());
+            supplierApprovalFirst.setVisible(supplierInfo.getVisible());
+            supplierApprovalFirst.setApprovalComment(supplierInfo.getApprovalComment());
+            supplierApprovalFirst.setApprovalConclusion(supplierInfo.getApprovalConclusion());
+            supplierApprovalFirst.setcSupplierInfoHistoryId(supplierInfo.getHistoryId());
+            saveOrUpdate(supplierApprovalFirst);
             supplierInfo.setSupplierApprovalFirst(supplierApprovalFirst);
             //保存企业审核信息
-            saveInfo(enterprise,supplierApprovalFirst.getId());
+            saveInfo(enterprise, supplierApprovalFirst.getId(), supplierInfo.getId());
             //保存担保企业审核信息
-            if(guaranteeEnterprise != null){
-                saveInfo(guaranteeEnterprise, supplierApprovalFirst.getId());
+            if (guaranteeEnterprise != null) {
+                saveInfo(guaranteeEnterprise, supplierApprovalFirst.getId(), supplierInfo.getId());
             }
         }
         //流程处理
-        if(supplierInfo.getVisible()){
-            //保存第一步审核结论
-            supplierApprovalFirst = measurement(supplierInfo);
-            updateById(supplierApprovalFirst);
+        if (supplierInfo.getVisible()) {
             String taskId = supplierInfo.getTaskId();
-            String result ;
-            if(supplierInfo.getApprovalConclusion().equals(ConstantConversionUtil.APPROVAL_RESULT_BACK)){
+            String result;
+            if (supplierInfo.getApprovalConclusion().equals(ConstantConversionUtil.APPROVAL_RESULT_BACK)) {
                 result = "退回";
-            }else if(supplierInfo.getApprovalConclusion().equals(ConstantConversionUtil.APPROVAL_RESULT_PASS)){
+            } else if (supplierInfo.getApprovalConclusion().equals(ConstantConversionUtil.APPROVAL_RESULT_PASS)) {
+                //保存第一步审核结论
+                supplierApprovalFirst = measurement(supplierInfo);
+                updateById(supplierApprovalFirst);
                 result = "通过";
-            }else {
-                throw new ServiceException(CodeUtil.FAIL,"审批结论出错!");
-            }
-            Long mainEnterpriseCount = supplierApprovalFirst.getMainEnterpriseCount();
-            if(mainEnterpriseCount > 0){
-                result = "红否";
-            }
-            if(guaranteeEnterprise != null){
-                Long guaranteeEnterpriseCount = supplierApprovalFirst.getGuaranteeEnterpriseCount();
-                if(guaranteeEnterpriseCount > 0){
+                Long mainEnterpriseCount = supplierApprovalFirst.getMainEnterpriseCount();
+                if (mainEnterpriseCount > 0) {
                     result = "红否";
                 }
+                if (guaranteeEnterprise != null) {
+                    Long guaranteeEnterpriseCount = supplierApprovalFirst.getGuaranteeEnterpriseCount();
+                    if (guaranteeEnterpriseCount > 0) {
+                        result = "红否";
+                    }
+                }
+            } else {
+                throw new ServiceException(CodeUtil.FAIL, "审批结论出错!");
             }
             Map<String, Object> procVariables = new HashMap<>();
-            procVariables.put("result",result);
+            procVariables.put("result", result);
             Map<String, Object> msgVariables = new HashMap<>();
             msgVariables.put(ConstantUtil.FLOWABLE_MSG_TITLE, "供应商名称:" + enterprise.getCorporateName());
-            if(result.equals("通过")){
+            if (result.equals("通过")) {
                 msgVariables.put(ConstantUtil.FLOWABLE_MSG_CONTENT,
                         "供应商名称为“" + enterprise.getCorporateName() + "”的供应商已进入“"
                                 + ConstantConversionUtil.flowBusinessKeyNames.get(ConstantUtil.SUPPLIER_INFO) + "—供应商审核第二步,"
                                 + ConstantUtil.FLOWABLE_MSG_ASSIGNEE);
-            }else if(result.equals("退回")){
+            } else if (result.equals("退回")) {
+                supplierInfo.setStatusStr(SupplierStatusEnums.ADD_INFO.getCode());
+                supplierInfoService.updateById(supplierInfo);
                 msgVariables.put(ConstantUtil.FLOWABLE_MSG_CONTENT,
                         "供应商名称为“" + enterprise.getCorporateName() + "”的供应商已进入“"
                                 + ConstantConversionUtil.flowBusinessKeyNames.get(ConstantUtil.SUPPLIER_INFO) + "—C端供应商录入,"
                                 + ConstantUtil.FLOWABLE_MSG_ASSIGNEE);
-            }else {
+            } else {
                 supplierApprovalFirst.setApprovalConclusion(ConstantConversionUtil.APPROVAL_RESULT_VETO);
-                supplierInfoService.lambdaUpdate().eq(SupplierInfo::getId,supplierInfo.getId()).set(SupplierInfo::getStatusStr, SupplierStatusEnums.VOTE.getCode()).update();
+                supplierInfoService.lambdaUpdate().eq(SupplierInfo::getId, supplierInfo.getId()).set(SupplierInfo::getStatusStr, SupplierStatusEnums.VOTE.getCode()).update();
                 msgVariables.put(ConstantUtil.FLOWABLE_MSG_CONTENT,
                         "供应商名称为“" + enterprise.getCorporateName() + "”的供应商审核已被否决");
             }
@@ -204,91 +208,91 @@ public class SupplierApprovalFirstServiceImpl extends ServiceImpl<SupplierApprov
     }
 
 
-    private void saveInfo(Enterprise enterprise, Long id) {
+    private void saveInfo(Enterprise enterprise, Long id, Long supplierInfoId) {
         List<CreditSituation> creditSituations = enterprise.getCreditSituations();
-        if(CollectionUtil.isNotEmpty(creditSituations)){
+        if (CollectionUtil.isNotEmpty(creditSituations)) {
             for (CreditSituation creditSituation : creditSituations) {
                 creditSituationService.lambdaUpdate()
-                        .eq(CreditSituation::getcCreditInvestigationInfoHistoryId,creditSituation.getcCreditInvestigationInfoHistoryId())
-                        .eq(CreditSituation::getSupplierApprovalFirstId,id).remove();
+                        .eq(CreditSituation::getcCreditInvestigationInfoHistoryId, creditSituation.getcCreditInvestigationInfoHistoryId())
+                        .eq(CreditSituation::getSupplierApprovalFirstId, id).remove();
                 creditSituation.setSupplierApprovalFirstId(id);
                 creditSituationService.save(creditSituation);
             }
-        }else {
-            throw new ValidatorException(CodeUtil.FAIL,"企业主要人员征信情况不能为空!");
+        } else {
+            throw new ValidatorException(CodeUtil.FAIL, "企业主要人员征信情况不能为空!");
         }
-        corporateGoodwillService.lambdaUpdate().eq(CorporateGoodwill::getcSupplierInfoId,id)
-                .eq(CorporateGoodwill::getcEnterpriseId,enterprise.getId()).remove();
+        corporateGoodwillService.lambdaUpdate().eq(CorporateGoodwill::getcSupplierInfoId, supplierInfoId)
+                .eq(CorporateGoodwill::getcEnterpriseId, enterprise.getId()).remove();
         CorporateGoodwill corporateGoodwill = enterprise.getCorporateGoodwill();
-        corporateGoodwill.setcSupplierInfoId(id);
+        corporateGoodwill.setcSupplierInfoId(supplierInfoId);
         corporateGoodwill.setcEnterpriseId(enterprise.getId());
         corporateGoodwillService.save(corporateGoodwill);
-        privateLendingService.lambdaUpdate().eq(PrivateLending::getcSupplierInfoId,id)
-                .eq(PrivateLending::getcEnterpriseId,enterprise.getId()).remove();
+        privateLendingService.lambdaUpdate().eq(PrivateLending::getcSupplierInfoId, supplierInfoId)
+                .eq(PrivateLending::getcEnterpriseId, enterprise.getId()).remove();
         List<PrivateLending> privateLendings = enterprise.getPrivateLendings();
-        if(CollectionUtil.isNotEmpty(privateLendings)){
+        if (CollectionUtil.isNotEmpty(privateLendings)) {
             for (PrivateLending privateLending : privateLendings) {
-                privateLending.setcSupplierInfoId(id);
+                privateLending.setcSupplierInfoId(supplierInfoId);
                 privateLending.setcEnterpriseId(enterprise.getId());
                 privateLendingService.save(privateLending);
             }
         }
-        seriousIllegalityService.lambdaUpdate().eq(SeriousIllegality::getcSupplierInfoId,id)
-                .eq(SeriousIllegality::getcEnterpriseId,enterprise.getId()).remove();
+        seriousIllegalityService.lambdaUpdate().eq(SeriousIllegality::getcSupplierInfoId, supplierInfoId)
+                .eq(SeriousIllegality::getcEnterpriseId, enterprise.getId()).remove();
         List<SeriousIllegality> seriousIllegalities = enterprise.getSeriousIllegalities();
-        if(CollectionUtil.isNotEmpty(seriousIllegalities)){
+        if (CollectionUtil.isNotEmpty(seriousIllegalities)) {
             for (SeriousIllegality seriousIllegality : seriousIllegalities) {
-                seriousIllegality.setcSupplierInfoId(id);
+                seriousIllegality.setcSupplierInfoId(supplierInfoId);
                 seriousIllegality.setcEnterpriseId(enterprise.getId());
                 seriousIllegalityService.save(seriousIllegality);
             }
         }
         List<TaxOweNotice> taxOweNotices = enterprise.getTaxOweNotices();
-        taxOweNoticeService.lambdaUpdate().eq(TaxOweNotice::getcSupplierInfoId,id)
-                .eq(TaxOweNotice::getcEnterpriseId,enterprise.getId()).remove();
-        if(CollectionUtil.isNotEmpty(taxOweNotices)){
+        taxOweNoticeService.lambdaUpdate().eq(TaxOweNotice::getcSupplierInfoId, supplierInfoId)
+                .eq(TaxOweNotice::getcEnterpriseId, enterprise.getId()).remove();
+        if (CollectionUtil.isNotEmpty(taxOweNotices)) {
             for (TaxOweNotice taxOweNotice : taxOweNotices) {
-                taxOweNotice.setcSupplierInfoId(id);
+                taxOweNotice.setcSupplierInfoId(supplierInfoId);
                 taxOweNotice.setcEnterpriseId(enterprise.getId());
                 taxOweNoticeService.save(taxOweNotice);
             }
         }
         List<TaxIllegalData> taxIllegalData = enterprise.getTaxIllegalData();
-        taxIllegalDataService.lambdaUpdate().eq(TaxIllegalData::getcSupplierInfoId,id)
-                .eq(TaxIllegalData::getcEnterpriseId,enterprise.getId()).remove();
-        if(CollectionUtil.isNotEmpty(taxIllegalData)){
+        taxIllegalDataService.lambdaUpdate().eq(TaxIllegalData::getcSupplierInfoId, supplierInfoId)
+                .eq(TaxIllegalData::getcEnterpriseId, enterprise.getId()).remove();
+        if (CollectionUtil.isNotEmpty(taxIllegalData)) {
             for (TaxIllegalData taxIllegalDatum : taxIllegalData) {
-                taxIllegalDatum.setcSupplierInfoId(id);
+                taxIllegalDatum.setcSupplierInfoId(supplierInfoId);
                 taxIllegalDatum.setcEnterpriseId(enterprise.getId());
                 taxIllegalDataService.save(taxIllegalDatum);
             }
         }
         List<Blacklist> blacklists = enterprise.getBlacklists();
-        blacklistService.lambdaUpdate().eq(Blacklist::getcSupplierInfoId,id)
-                .eq(Blacklist::getcEnterpriseId,enterprise.getId()).remove();
-        if(CollectionUtil.isNotEmpty(blacklists)){
+        blacklistService.lambdaUpdate().eq(Blacklist::getcSupplierInfoId, supplierInfoId)
+                .eq(Blacklist::getcEnterpriseId, enterprise.getId()).remove();
+        if (CollectionUtil.isNotEmpty(blacklists)) {
             for (Blacklist blacklist : blacklists) {
-                blacklist.setcSupplierInfoId(id);
+                blacklist.setcSupplierInfoId(supplierInfoId);
                 blacklist.setcEnterpriseId(enterprise.getId());
                 blacklistService.save(blacklist);
             }
         }
         List<ExceptionData> exceptionData = enterprise.getExceptionData();
-        exceptionDataService.lambdaUpdate().eq(ExceptionData::getcSupplierInfoId,id)
-                .eq(ExceptionData::getcEnterpriseId,enterprise.getId()).remove();
-        if(CollectionUtil.isNotEmpty(exceptionData)){
+        exceptionDataService.lambdaUpdate().eq(ExceptionData::getcSupplierInfoId, supplierInfoId)
+                .eq(ExceptionData::getcEnterpriseId, enterprise.getId()).remove();
+        if (CollectionUtil.isNotEmpty(exceptionData)) {
             for (ExceptionData exceptionDatum : exceptionData) {
-                exceptionDatum.setcSupplierInfoId(id);
+                exceptionDatum.setcSupplierInfoId(supplierInfoId);
                 exceptionDatum.setcEnterpriseId(enterprise.getId());
                 exceptionDataService.save(exceptionDatum);
             }
         }
         List<News> news = enterprise.getNews();
-        newsService.lambdaUpdate().eq(News::getcSupplierInfoId,id)
-                .eq(News::getcEnterpriseId,enterprise.getId()).remove();
-        if(CollectionUtil.isNotEmpty(news)){
+        newsService.lambdaUpdate().eq(News::getcSupplierInfoId, supplierInfoId)
+                .eq(News::getcEnterpriseId, enterprise.getId()).remove();
+        if (CollectionUtil.isNotEmpty(news)) {
             for (News news1 : news) {
-                news1.setcSupplierInfoId(id);
+                news1.setcSupplierInfoId(supplierInfoId);
                 news1.setcEnterpriseId(enterprise.getId());
                 newsService.save(news1);
             }
@@ -298,94 +302,100 @@ public class SupplierApprovalFirstServiceImpl extends ServiceImpl<SupplierApprov
     @Override
     public SupplierInfo getFirstReviewById(Long id) {
         //获取最后一次供应商C端录入时的log
-        BusinessProcessingLog lastLog = businessProcessingLogService.getLastByBusinessKeyBusinessTypeTaskName(id,ConstantUtil.SUPPLIER_INFO,"供应商C端录入");
+        BusinessProcessingLog lastLog = businessProcessingLogService.getLastByBusinessKeyBusinessTypeTaskName(id, ConstantUtil.SUPPLIER_INFO, "供应商C端录入");
         CSupplierInfoHistory supplierInfoHistory = supplierInfoHistoryService.getById(lastLog.getFormBusinessId());
         SupplierInfo supplierInfo = supplierInfoService.get(id);
         DueDiligenceAllocation dueDiligenceAllocation = dueDiligenceAllocationService.lambdaQuery().eq(DueDiligenceAllocation::getcSupplierInfoId, id).one();
         User riskManager = userService.get(dueDiligenceAllocation.getRiskManagerId());
         dueDiligenceAllocation.setRiskManager(riskManager);
         supplierInfo.setDueDiligenceAllocation(dueDiligenceAllocation);
-        SupplierApprovalFirst supplierApprovalFirst = lambdaQuery().eq(SupplierApprovalFirst::getcSupplierInfoId, id).eq(SupplierApprovalFirst::getVisible,false)
-                .orderByDesc(SupplierApprovalFirst::getGmtCreate).list().get(0);
+        List<SupplierApprovalFirst> supplierApprovalFirsts = lambdaQuery().eq(SupplierApprovalFirst::getcSupplierInfoId, id).eq(SupplierApprovalFirst::getVisible, false)
+                .orderByDesc(SupplierApprovalFirst::getGmtCreate).list();
+        if (CollectionUtil.isNotEmpty(supplierApprovalFirsts)) {
+            SupplierApprovalFirst supplierApprovalFirst = supplierApprovalFirsts.get(0);
+            supplierInfo.setSupplierApprovalFirst(supplierApprovalFirst);
+            supplierInfo.setApprovalConclusion(supplierApprovalFirst.getApprovalConclusion());
+            supplierInfo.setApprovalComment(supplierApprovalFirst.getApprovalComment());
+        }
         supplierInfo.setHistoryId(supplierInfoHistory.getId());
-        supplierInfo.setSupplierApprovalFirst(supplierApprovalFirst);
 
         CEnterpriseHistory enterpriseHistory = enterpriseHistoryService.getById(supplierInfoHistory.getcEnterpriseHistoryId());
         Enterprise enterprise = enterpriseService.getById(supplierInfo.getcEnterpriseId());
-        autoFirstReview(supplierInfo,enterprise,enterpriseHistory);
+        autoFirstReview(supplierInfo, enterprise, enterpriseHistory);
         supplierInfo.setEnterprise(enterprise);
         supplierInfo.setHasGuaranteeEnterprise(false);
-        if(supplierInfo.getGuaranteeEnterpriseId() != null){
+        if (supplierInfo.getGuaranteeEnterpriseId() != null) {
             supplierInfo.setHasGuaranteeEnterprise(true);
             CEnterpriseHistory enteguaranteeHistory = enterpriseHistoryService.getById(supplierInfoHistory.getGuaranteeEnterpriseHistoryId());
             Enterprise guaranteeEnterprise = enterpriseService.getById(supplierInfo.getGuaranteeEnterpriseId());
-            autoFirstReview(supplierInfo,guaranteeEnterprise, enteguaranteeHistory);
+            autoFirstReview(supplierInfo, guaranteeEnterprise, enteguaranteeHistory);
             supplierInfo.setGuaranteeEnterprise(guaranteeEnterprise);
         }
         return supplierInfo;
     }
 
-    private void autoFirstReview(SupplierInfo supplierInfo,Enterprise enterprise, CEnterpriseHistory enterpriseHistory) {
-        Long firstReviewId = supplierInfo.getSupplierApprovalFirst().getId();
+    private void autoFirstReview(SupplierInfo supplierInfo, Enterprise enterprise, CEnterpriseHistory enterpriseHistory) {
         Long id = supplierInfo.getId();
-        //企业负责人征信情况
-        List<CreditSituation> creditSituations = creditSituationService.lambdaQuery().eq(CreditSituation::getSupplierApprovalFirstId, firstReviewId).list();
         List<CreditSituation> creditSituationsResult = new ArrayList<>();
-        if(CollectionUtil.isNotEmpty(creditSituations)){
-            for (CreditSituation creditSituation : creditSituations) {
-                CCreditInvestigationInfoHistory creditInvestigationInfoHistory = creditInvestigationInfoHistoryService.getById(creditSituation.getcCreditInvestigationInfoHistoryId());
-                creditInvestigationInfoHistory.setTypeStr(dictionaryService.getByCode(creditInvestigationInfoHistory.getType()).getName());
-                CEnterpriseHistory byId = enterpriseHistoryService.getById(creditInvestigationInfoHistory.getcEnterpriseHistoryId());
-                CEnterpriseHistory historyServiceById = enterpriseHistoryService.getById(enterpriseHistory.getId());
-                List<FileStorage> list = new ArrayList<>();
-                if(byId.getCorporateName().equals(historyServiceById.getCorporateName())){
-                    //todo 填充征信报告
-                    CreditInfo creditInfo = creditService.lambdaQuery().eq(CreditInfo::getCardNo, creditInvestigationInfoHistory.getSocialCreditCode()).one();
-                    if(creditInfo != null){
-                        List<CreditDetail> creditDetails = creditDetailService.lambdaQuery()
-                                .eq(CreditDetail::getCreditId,creditInfo.getId())
-                                .isNotNull(CreditDetail::getCreditAddress)
-                                .orderByDesc(CreditDetail::getGmtCreate).list();
-                        if(CollectionUtil.isNotEmpty(creditDetails)){
-                            CreditDetail creditDetail = creditDetails.get(0);
-                            if(StringUtil.isNotEmpty(creditDetail.getCreditAddress())){
-                                FileStorage creditDetailFiles = fileStorageService.get(Long.valueOf(creditDetail.getCreditAddress()));
-                                list.add(creditDetailFiles);
+        if (supplierInfo.getSupplierApprovalFirst() != null) {
+            Long firstReviewId = supplierInfo.getSupplierApprovalFirst().getId();
+            List<CreditSituation> creditSituations = creditSituationService.lambdaQuery().eq(CreditSituation::getSupplierApprovalFirstId, firstReviewId).list();
+            if (CollectionUtil.isNotEmpty(creditSituations)) {
+                for (CreditSituation creditSituation : creditSituations) {
+                    CCreditInvestigationInfoHistory creditInvestigationInfoHistory = creditInvestigationInfoHistoryService.getById(creditSituation.getcCreditInvestigationInfoHistoryId());
+                    creditInvestigationInfoHistory.setTypeStr(dictionaryService.getByCode(creditInvestigationInfoHistory.getType()).getName());
+                    CEnterpriseHistory byId = enterpriseHistoryService.getById(creditInvestigationInfoHistory.getcEnterpriseHistoryId());
+                    CEnterpriseHistory historyServiceById = enterpriseHistoryService.getById(enterpriseHistory.getId());
+                    List<FileStorage> list = new ArrayList<>();
+                    if (byId.getCorporateName().equals(historyServiceById.getCorporateName())) {
+                        //todo 填充征信报告
+                        CreditInfo creditInfo = creditService.lambdaQuery().eq(CreditInfo::getCardNo, creditInvestigationInfoHistory.getSocialCreditCode()).one();
+                        if (creditInfo != null) {
+                            List<CreditDetail> creditDetails = creditDetailService.lambdaQuery()
+                                    .eq(CreditDetail::getCreditId, creditInfo.getId())
+                                    .isNotNull(CreditDetail::getCreditAddress)
+                                    .orderByDesc(CreditDetail::getGmtCreate).list();
+                            if (CollectionUtil.isNotEmpty(creditDetails)) {
+                                CreditDetail creditDetail = creditDetails.get(0);
+                                if (StringUtil.isNotEmpty(creditDetail.getCreditAddress())) {
+                                    FileStorage creditDetailFiles = fileStorageService.get(Long.valueOf(creditDetail.getCreditAddress()));
+                                    list.add(creditDetailFiles);
+                                }
                             }
                         }
+                        creditInvestigationInfoHistory.setCreditDetailFiles(list);
+                        List<FileStorageDO> cardFiles = fileService.findByBusinessId(creditInvestigationInfoHistory.getId(), FileModuleDict.ChildEnum.ENTERPRISE_IDCARD_FILES_HISTORY.getCode());
+                        creditInvestigationInfoHistory.setCardFiles(cardFiles);
+                        creditSituation.setCreditInvestigationInfoHistory(creditInvestigationInfoHistory);
+                        creditSituationsResult.add(creditSituation);
                     }
-                    creditInvestigationInfoHistory.setCreditDetailFiles(list);
-                    List<FileStorageDO> cardFiles = fileService.findByBusinessId(creditInvestigationInfoHistory.getId(), FileModuleDict.ChildEnum.ENTERPRISE_IDCARD_FILES_HISTORY.getCode());
-                    creditInvestigationInfoHistory.setCardFiles(cardFiles);
-                    creditSituation.setCreditInvestigationInfoHistory(creditInvestigationInfoHistory);
-                    creditSituationsResult.add(creditSituation);
                 }
             }
         }
-        if(CollectionUtil.isEmpty(creditSituationsResult)){
+        //企业负责人征信情况
+        if (CollectionUtil.isEmpty(creditSituationsResult)) {
             List<CCreditInvestigationInfoHistory> creditInvestigationInfoHistories = creditInvestigationInfoHistoryService.lambdaQuery().eq(CCreditInvestigationInfoHistory::getcEnterpriseHistoryId, enterpriseHistory.getId()).list();
-            if(CollectionUtil.isNotEmpty(creditInvestigationInfoHistories)){
+            if (CollectionUtil.isNotEmpty(creditInvestigationInfoHistories)) {
                 //去重
                 List<CCreditInvestigationInfoHistory> filterResult = creditInvestigationInfoHistories.stream()
                         .collect(Collectors.toMap(CCreditInvestigationInfoHistory::getName, user -> user, (u1, u2) -> u1))
                         .values().stream().collect(Collectors.toList());
                 for (CCreditInvestigationInfoHistory creditInvestigationInfoHistory : filterResult) {
                     List<FileStorage> list = new ArrayList<>();
-                    if(creditInvestigationInfoHistory.getcEnterpriseHistoryId().equals(enterpriseHistory.getId())){
+                    if (creditInvestigationInfoHistory.getcEnterpriseHistoryId().equals(enterpriseHistory.getId())) {
                         List<FileStorageDO> cardFiles = fileService.findByBusinessId(creditInvestigationInfoHistory.getId(), FileModuleDict.ChildEnum.ENTERPRISE_IDCARD_FILES_HISTORY.getCode());
                         creditInvestigationInfoHistory.setTypeStr(dictionaryService.getByCode(creditInvestigationInfoHistory.getType()).getName());
                         creditInvestigationInfoHistory.setCardFiles(cardFiles);
                         CreditSituation creditSituation = new CreditSituation();
-                        creditSituation.setSupplierApprovalFirstId(firstReviewId);
                         creditSituation.setcCreditInvestigationInfoHistoryId(creditInvestigationInfoHistory.getId());
                         //todo 填充征信报告
                         CreditInfo creditInfo = creditService.lambdaQuery().eq(CreditInfo::getCardNo, creditInvestigationInfoHistory.getSocialCreditCode()).one();
-                        if(creditInfo != null){
+                        if (creditInfo != null) {
                             List<CreditDetail> creditDetails = creditDetailService.lambdaQuery()
-                                    .eq(CreditDetail::getCreditId,creditInfo.getId())
+                                    .eq(CreditDetail::getCreditId, creditInfo.getId())
                                     .isNotNull(CreditDetail::getCreditAddress)
                                     .orderByDesc(CreditDetail::getGmtCreate).list();
-                            if(CollectionUtil.isNotEmpty(creditDetails)){
+                            if (CollectionUtil.isNotEmpty(creditDetails)) {
                                 CreditDetail creditDetail = creditDetails.get(0);
                                 FileStorage creditDetailFiles = fileStorageService.get(Long.valueOf(creditDetail.getCreditAddress()));
                                 list.add(creditDetailFiles);
@@ -398,10 +408,10 @@ public class SupplierApprovalFirstServiceImpl extends ServiceImpl<SupplierApprov
                             dongjiangaoRiskId = enterprise.getcDongjiangaoRiskId();
                         } else if (creditInvestigationInfoHistory.getType().equals("c_credit_investigation_info_type_2")) {
                             dongjiangaoRiskId = enterprise.getcDongjiangaoRiskBigId();
-                        }else {
+                        } else {
                             dongjiangaoRiskId = enterprise.getcDongjiangaoRiskControllerId();
                         }
-                        if(dongjiangaoRiskId != null){
+                        if (dongjiangaoRiskId != null) {
                             String dongjiangaoRisksUrl = dongjiangaoRisks + "?id=" + dongjiangaoRiskId;
                             ResponseJson dongjiangaoRisksObject = restTemplate.getForObject(dongjiangaoRisksUrl, ResponseJson.class);
                             if (dongjiangaoRisksObject == null) {
@@ -435,7 +445,7 @@ public class SupplierApprovalFirstServiceImpl extends ServiceImpl<SupplierApprov
         enterprise.setCreditSituations(creditSituationsResult);
         //企业信誉
         CorporateGoodwill corporateGoodwill = corporateGoodwillService.lambdaQuery().eq(CorporateGoodwill::getcSupplierInfoId, id).eq(CorporateGoodwill::getcEnterpriseId, enterprise.getId()).one();
-        if(corporateGoodwill == null){
+        if (corporateGoodwill == null) {
             corporateGoodwill = new CorporateGoodwill();
             corporateGoodwill.setcSupplierInfoId(id);
             corporateGoodwill.setcEnterpriseId(enterprise.getId());
@@ -443,14 +453,14 @@ public class SupplierApprovalFirstServiceImpl extends ServiceImpl<SupplierApprov
         //todo 填充征信报告
         CreditInfo creditInfo = creditService.lambdaQuery().eq(CreditInfo::getCardNo, enterprise.getSocialCreditCode()).one();
         List<FileStorage> list = new ArrayList<>();
-        if(creditInfo != null){
+        if (creditInfo != null) {
             List<CreditDetail> creditDetails = creditDetailService.lambdaQuery()
-                    .eq(CreditDetail::getCreditId,creditInfo.getId())
+                    .eq(CreditDetail::getCreditId, creditInfo.getId())
                     .isNotNull(CreditDetail::getCreditAddress)
                     .orderByDesc(CreditDetail::getGmtCreate).list();
-            if(CollectionUtil.isNotEmpty(creditDetails)){
+            if (CollectionUtil.isNotEmpty(creditDetails)) {
                 CreditDetail creditDetail = creditDetails.get(0);
-                if(StringUtil.isNotEmpty(creditDetail.getCreditAddress())){
+                if (StringUtil.isNotEmpty(creditDetail.getCreditAddress())) {
                     FileStorage creditDetailFiles = fileStorageService.get(Long.valueOf(creditDetail.getCreditAddress()));
                     list.add(creditDetailFiles);
                 }
@@ -459,47 +469,47 @@ public class SupplierApprovalFirstServiceImpl extends ServiceImpl<SupplierApprov
         corporateGoodwill.setCreditDetailFiles(list);
         enterprise.setCorporateGoodwill(corporateGoodwill);
         List<PrivateLending> privateLendings = privateLendingService.lambdaQuery().eq(PrivateLending::getcSupplierInfoId, id).eq(PrivateLending::getcEnterpriseId, enterprise.getId()).list();
-        if(CollectionUtil.isNotEmpty(privateLendings)){
+        if (CollectionUtil.isNotEmpty(privateLendings)) {
             //privateLendings.forEach(r->r.setPrivateLending(0));
         }
         enterprise.setPrivateLendings(privateLendings);
         List<SeriousIllegality> seriousIllegalities = seriousIllegalityService.lambdaQuery().eq(SeriousIllegality::getcSupplierInfoId, id).eq(SeriousIllegality::getcEnterpriseId, enterprise.getId()).list();
-        if(CollectionUtil.isNotEmpty(seriousIllegalities)){
+        if (CollectionUtil.isNotEmpty(seriousIllegalities)) {
             //seriousIllegalities.forEach(r->r.setSeriousIllegality(0));
         }
         enterprise.setSeriousIllegalities(seriousIllegalities);
         List<TaxOweNotice> taxOweNotices = taxOweNoticeService.lambdaQuery().eq(TaxOweNotice::getcSupplierInfoId, id).eq(TaxOweNotice::getcEnterpriseId, enterprise.getId()).list();
-        if(CollectionUtil.isNotEmpty(taxOweNotices)){
+        if (CollectionUtil.isNotEmpty(taxOweNotices)) {
             //taxOweNotices.forEach(r->r.setTaxOweNotice(0));
         }
         enterprise.setTaxOweNotices(taxOweNotices);
         List<TaxIllegalData> taxIllegalData = taxIllegalDataService.lambdaQuery().eq(TaxIllegalData::getcSupplierInfoId, id).eq(TaxIllegalData::getcEnterpriseId, enterprise.getId()).list();
-        if(CollectionUtil.isNotEmpty(taxIllegalData)){
+        if (CollectionUtil.isNotEmpty(taxIllegalData)) {
             //taxIllegalData.forEach(r->r.setTaxIllegal(0));
         }
         enterprise.setTaxIllegalData(taxIllegalData);
         List<Blacklist> blacklists = blacklistService.lambdaQuery().eq(Blacklist::getcSupplierInfoId, id).eq(Blacklist::getcEnterpriseId, enterprise.getId()).list();
-        if(CollectionUtil.isNotEmpty(blacklists)){
+        if (CollectionUtil.isNotEmpty(blacklists)) {
             //blacklists.forEach(r->r.setBlacklist(0));
         }
         enterprise.setBlacklists(blacklists);
         List<ExceptionData> exceptionData = exceptionDataService.lambdaQuery().eq(ExceptionData::getcSupplierInfoId, id).eq(ExceptionData::getcEnterpriseId, enterprise.getId()).list();
-        if(CollectionUtil.isNotEmpty(exceptionData)){
+        if (CollectionUtil.isNotEmpty(exceptionData)) {
             //exceptionData.forEach(r->r.setException(0));
         }
         enterprise.setExceptionData(exceptionData);
         List<News> news = newsService.lambdaQuery().eq(News::getcSupplierInfoId, id).eq(News::getcEnterpriseId, enterprise.getId()).list();
-        if(CollectionUtil.isNotEmpty(news)){
+        if (CollectionUtil.isNotEmpty(news)) {
             //news.forEach(r->r.setNews(0));
         }
         enterprise.setNews(news);
-        if(CollectionUtil.isEmpty(privateLendings) || CollectionUtil.isEmpty(seriousIllegalities) || CollectionUtil.isEmpty(taxOweNotices) || CollectionUtil.isEmpty(taxIllegalData)
-                || CollectionUtil.isEmpty(blacklists)|| CollectionUtil.isEmpty(exceptionData)|| CollectionUtil.isEmpty(news)){
+        if (CollectionUtil.isEmpty(privateLendings) || CollectionUtil.isEmpty(seriousIllegalities) || CollectionUtil.isEmpty(taxOweNotices) || CollectionUtil.isEmpty(taxIllegalData)
+                || CollectionUtil.isEmpty(blacklists) || CollectionUtil.isEmpty(exceptionData) || CollectionUtil.isEmpty(news)) {
             //sop 获取企业信誉数据
             String findCorporateGoodwillUrl = findCorporateGoodwill + "?comprehensiveRiskInvestigationId=" + enterprise.getcComprehensiveRiskInvestigationId();
             ResponseJson responseJson = restTemplate.getForObject(findCorporateGoodwillUrl, ResponseJson.class);
-            if(responseJson != null && responseJson.getCode().equals("200")){
-                JSONObject jsonObject = new JSONObject(responseJson.getData()) ;
+            if (responseJson != null && responseJson.getCode().equals("200")) {
+                JSONObject jsonObject = new JSONObject(responseJson.getData());
                 JSONArray judgmentDocuments = jsonObject.getJSONArray("judgmentDocuments");
                 JSONArray seriousIllegalData = jsonObject.getJSONArray("seriousIllegalData");
                 JSONArray taxOweNoticeData = jsonObject.getJSONArray("taxOweNoticeData");
@@ -508,7 +518,7 @@ public class SupplierApprovalFirstServiceImpl extends ServiceImpl<SupplierApprov
                 JSONArray newsRj = jsonObject.getJSONArray("news");
                 JSONArray taxIllegalDataRj = jsonObject.getJSONArray("taxIllegalData");
                 List<PrivateLending> judgmentDocumentList = new ArrayList();
-                if(CollectionUtil.isNotEmpty(judgmentDocuments)){
+                if (CollectionUtil.isNotEmpty(judgmentDocuments)) {
                     for (Object judgmentDocument : judgmentDocuments) {
                         JSONObject object = (JSONObject) judgmentDocument;
                         PrivateLending privateLending = new PrivateLending();
@@ -528,7 +538,7 @@ public class SupplierApprovalFirstServiceImpl extends ServiceImpl<SupplierApprov
                 }
                 enterprise.setPrivateLendings(judgmentDocumentList);
                 List<SeriousIllegality> seriousIllegalitieList = new ArrayList<>();
-                if(CollectionUtil.isNotEmpty(seriousIllegalData)){
+                if (CollectionUtil.isNotEmpty(seriousIllegalData)) {
                     for (Object seriousIllegalDatum : seriousIllegalData) {
                         JSONObject object = (JSONObject) seriousIllegalDatum;
                         SeriousIllegality seriousIllegality = new SeriousIllegality();
@@ -543,7 +553,7 @@ public class SupplierApprovalFirstServiceImpl extends ServiceImpl<SupplierApprov
                 }
                 enterprise.setSeriousIllegalities(seriousIllegalitieList);
                 List<TaxOweNotice> taxOweNoticeList = new ArrayList<>();
-                if(CollectionUtil.isNotEmpty(taxOweNoticeData)){
+                if (CollectionUtil.isNotEmpty(taxOweNoticeData)) {
                     for (Object taxOweNoticeDatum : taxOweNoticeData) {
                         JSONObject object = (JSONObject) taxOweNoticeDatum;
                         TaxOweNotice taxOweNotice = new TaxOweNotice();
@@ -560,7 +570,7 @@ public class SupplierApprovalFirstServiceImpl extends ServiceImpl<SupplierApprov
                 }
                 enterprise.setTaxOweNotices(taxOweNoticeList);
                 List<TaxIllegalData> taxIllegalDataList = new ArrayList<>();
-                if(CollectionUtil.isNotEmpty(taxIllegalDataRj)){
+                if (CollectionUtil.isNotEmpty(taxIllegalDataRj)) {
                     for (Object taxIllegal : taxIllegalDataRj) {
                         JSONObject object = (JSONObject) taxIllegal;
                         TaxIllegalData taxIllegalData1 = new TaxIllegalData();
@@ -577,7 +587,7 @@ public class SupplierApprovalFirstServiceImpl extends ServiceImpl<SupplierApprov
                 }
                 enterprise.setTaxIllegalData(taxIllegalDataList);
                 List<Blacklist> blacklist = new ArrayList<>();
-                if(CollectionUtil.isNotEmpty(blacklistsRj)){
+                if (CollectionUtil.isNotEmpty(blacklistsRj)) {
                     for (Object black : blacklistsRj) {
                         JSONObject object = (JSONObject) black;
                         Blacklist blacks = new Blacklist();
@@ -594,7 +604,7 @@ public class SupplierApprovalFirstServiceImpl extends ServiceImpl<SupplierApprov
                 }
                 enterprise.setBlacklists(blacklist);
                 List<ExceptionData> exceptionDataList = new ArrayList<>();
-                if(CollectionUtil.isNotEmpty(exceptionDataRj)){
+                if (CollectionUtil.isNotEmpty(exceptionDataRj)) {
                     for (Object exception : exceptionDataRj) {
                         JSONObject object = (JSONObject) exception;
                         ExceptionData exceptionData1 = new ExceptionData();
@@ -609,7 +619,7 @@ public class SupplierApprovalFirstServiceImpl extends ServiceImpl<SupplierApprov
                 }
                 enterprise.setExceptionData(exceptionDataList);
                 List<News> newsList = new ArrayList<>();
-                if(CollectionUtil.isNotEmpty(newsRj)){
+                if (CollectionUtil.isNotEmpty(newsRj)) {
                     for (Object newsObj : newsRj) {
                         JSONObject object = (JSONObject) newsObj;
                         News newsData = new News();
@@ -630,6 +640,8 @@ public class SupplierApprovalFirstServiceImpl extends ServiceImpl<SupplierApprov
     public SupplierInfo getView(Long id) {
         SupplierApprovalFirst supplierApprovalFirst = getById(id);
         SupplierInfo supplierInfo = supplierInfoService.get(supplierApprovalFirst.getcSupplierInfoId());
+        supplierInfo.setApprovalConclusion(supplierApprovalFirst.getApprovalConclusion());
+        supplierInfo.setApprovalComment(supplierApprovalFirst.getApprovalComment());
         DueDiligenceAllocation dueDiligenceAllocation = dueDiligenceAllocationService.lambdaQuery().eq(DueDiligenceAllocation::getcSupplierInfoId, supplierInfo.getId()).one();
         User user = userService.get(dueDiligenceAllocation.getRiskManagerId());
         dueDiligenceAllocation.setRiskManager(user);
@@ -638,14 +650,14 @@ public class SupplierApprovalFirstServiceImpl extends ServiceImpl<SupplierApprov
         supplierInfo.setSupplierApprovalFirst(supplierApprovalFirst);
         CEnterpriseHistory enterpriseHistory = enterpriseHistoryService.getById(supplierInfoHistory.getcEnterpriseHistoryId());
         Enterprise enterprise = enterpriseService.getById(supplierInfo.getcEnterpriseId());
-        autoView(supplierInfo,enterprise,enterpriseHistory);
+        autoView(supplierInfo, enterprise, enterpriseHistory);
         supplierInfo.setEnterprise(enterprise);
         supplierInfo.setHasGuaranteeEnterprise(false);
-        if(supplierInfo.getGuaranteeEnterpriseId() != null){
+        if (supplierInfo.getGuaranteeEnterpriseId() != null) {
             supplierInfo.setHasGuaranteeEnterprise(true);
             CEnterpriseHistory guaranteeHistory = enterpriseHistoryService.getById(supplierInfoHistory.getGuaranteeEnterpriseHistoryId());
             Enterprise guarantee = enterpriseService.getById(supplierInfo.getGuaranteeEnterpriseId());
-            autoView(supplierInfo,guarantee,guaranteeHistory);
+            autoView(supplierInfo, guarantee, guaranteeHistory);
             supplierInfo.setGuaranteeEnterprise(guarantee);
         }
         return supplierInfo;
@@ -654,15 +666,18 @@ public class SupplierApprovalFirstServiceImpl extends ServiceImpl<SupplierApprov
     @Override
     public SupplierApprovalFirst measurement(SupplierInfo supplierInfo) {
         SupplierApprovalFirst supplierApprovalFirst = supplierInfo.getSupplierApprovalFirst();
+        if (supplierApprovalFirst == null) {
+            supplierApprovalFirst = new SupplierApprovalFirst();
+        }
         supplierApprovalFirst.setcSupplierInfoId(supplierInfo.getId());
         supplierApprovalFirst.setcSupplierInfoHistoryId(supplierInfo.getHistoryId());
         //企业审核信息
         Enterprise enterprise = supplierInfo.getEnterprise();
-        measurementCount(enterprise,supplierApprovalFirst,true);
+        measurementCount(enterprise, supplierApprovalFirst, true);
         //担保企业审核信息
         Enterprise guaranteeEnterprise = supplierInfo.getGuaranteeEnterprise();
-        if(guaranteeEnterprise != null){
-            measurementCount(guaranteeEnterprise,supplierApprovalFirst,false);
+        if (guaranteeEnterprise != null) {
+            measurementCount(guaranteeEnterprise, supplierApprovalFirst, false);
         }
         return supplierApprovalFirst;
     }
@@ -670,174 +685,174 @@ public class SupplierApprovalFirstServiceImpl extends ServiceImpl<SupplierApprov
     private void measurementCount(Enterprise enterprise, SupplierApprovalFirst supplierApprovalFirst, boolean flag) {
         long count = 0L;
         List<CreditSituation> creditSituations = enterprise.getCreditSituations();
-        if(CollectionUtil.isNotEmpty(creditSituations)){
+        if (CollectionUtil.isNotEmpty(creditSituations)) {
             for (CreditSituation creditSituation : creditSituations) {
-                creditSituation.setSupplierApprovalFirstId(supplierApprovalFirst.getId());
-                creditSituationService.lambdaUpdate()
-                        .eq(CreditSituation::getcCreditInvestigationInfoHistoryId,creditSituation.getcCreditInvestigationInfoHistoryId())
-                        .eq(CreditSituation::getSupplierApprovalFirstId,supplierApprovalFirst.getId()).remove();
-                creditSituationService.save(creditSituation);
+//                creditSituation.setSupplierApprovalFirstId(supplierApprovalFirst.getId());
+//                creditSituationService.lambdaUpdate()
+//                        .eq(CreditSituation::getcCreditInvestigationInfoHistoryId,creditSituation.getcCreditInvestigationInfoHistoryId())
+//                        .eq(CreditSituation::getSupplierApprovalFirstId,supplierApprovalFirst.getId()).remove();
+//                creditSituationService.save(creditSituation);
                 //近两年发生过逾期的账户数≥3且合计金额≥5000元
-                if(creditSituation.getNumberOfOverdueAccounts() >= 3 && creditSituation.getTotalOverdueAmount().compareTo(new BigDecimal(5000)) > -1){
-                    count ++;
+                if (creditSituation.getNumberOfOverdueAccounts() >= 3 && creditSituation.getTotalOverdueAmount().compareTo(new BigDecimal(5000)) > -1) {
+                    count++;
                 }
                 //发生过90天以上逾期的账户数≥1
-                if(creditSituation.getOverdue() >= 1){
-                    count ++;
+                if (creditSituation.getOverdue() >= 1) {
+                    count++;
                 }
                 //近两年贷款、信用卡连续逾期月数>2个月且近两年逾期还款记录累计次数>5次
-                if(creditSituation.getConsecutiveOverdueMonth() > 2 && creditSituation.getAccumulatedOverdueTimes() > 5){
-                    count ++;
+                if (creditSituation.getConsecutiveOverdueMonth() > 2 && creditSituation.getAccumulatedOverdueTimes() > 5) {
+                    count++;
                 }
-                if(creditSituation.getBadRecords().equals(1)){
-                    count ++;
+                if (creditSituation.getBadRecords().equals(1)) {
+                    count++;
                 }
             }
         }
         CorporateGoodwill corporateGoodwill = enterprise.getCorporateGoodwill();
-        corporateGoodwill.setcEnterpriseId(enterprise.getId());
-        corporateGoodwill.setcSupplierInfoId(supplierApprovalFirst.getcSupplierInfoId());
-        if(corporateGoodwill.getRecoveredBalance().equals(1)){
-            count ++;
-        }
-        if(corporateGoodwill.getConcernedAccountsWithOutstandingCredit().equals(1)){
-            count ++;
-        }
-        if(corporateGoodwill.getOutstandingNonPerformingAccounts().equals(1)){
-            count ++;
-        }
-        corporateGoodwillService.lambdaUpdate().eq(CorporateGoodwill::getcSupplierInfoId,supplierApprovalFirst.getcSupplierInfoId())
-                        .eq(CorporateGoodwill::getcEnterpriseId,enterprise.getId()).remove();
-        corporateGoodwillService.save(corporateGoodwill);
-        privateLendingService.lambdaUpdate().eq(PrivateLending::getcSupplierInfoId,supplierApprovalFirst.getcSupplierInfoId())
-                .eq(PrivateLending::getcEnterpriseId,enterprise.getId()).remove();
+//        corporateGoodwill.setcEnterpriseId(enterprise.getId());
+//        corporateGoodwill.setcSupplierInfoId(supplierApprovalFirst.getcSupplierInfoId());
+        if (corporateGoodwill.getRecoveredBalance().equals(1)) {
+            count++;
+        }
+        if (corporateGoodwill.getConcernedAccountsWithOutstandingCredit().equals(1)) {
+            count++;
+        }
+        if (corporateGoodwill.getOutstandingNonPerformingAccounts().equals(1)) {
+            count++;
+        }
+//        corporateGoodwillService.lambdaUpdate().eq(CorporateGoodwill::getcSupplierInfoId,supplierApprovalFirst.getcSupplierInfoId())
+//                        .eq(CorporateGoodwill::getcEnterpriseId,enterprise.getId()).remove();
+//        corporateGoodwillService.save(corporateGoodwill);
+//        privateLendingService.lambdaUpdate().eq(PrivateLending::getcSupplierInfoId,supplierApprovalFirst.getcSupplierInfoId())
+//                .eq(PrivateLending::getcEnterpriseId,enterprise.getId()).remove();
         List<PrivateLending> privateLendings = enterprise.getPrivateLendings();
-        if(CollectionUtil.isNotEmpty(privateLendings)){
+        if (CollectionUtil.isNotEmpty(privateLendings)) {
             for (PrivateLending privateLending : privateLendings) {
-                privateLending.setcSupplierInfoId(supplierApprovalFirst.getcSupplierInfoId());
-                privateLending.setcEnterpriseId(enterprise.getId());
-                privateLendingService.save(privateLending);
-                if(privateLending.getPrivateLending().equals(1)){
-                    count ++;
+//                privateLending.setcSupplierInfoId(supplierApprovalFirst.getcSupplierInfoId());
+//                privateLending.setcEnterpriseId(enterprise.getId());
+//                privateLendingService.save(privateLending);
+                if (privateLending.getPrivateLending().equals(1)) {
+                    count++;
                 }
             }
         }
-        seriousIllegalityService.lambdaUpdate().eq(SeriousIllegality::getcSupplierInfoId,supplierApprovalFirst.getcSupplierInfoId())
-                .eq(SeriousIllegality::getcEnterpriseId,enterprise.getId()).remove();
+//        seriousIllegalityService.lambdaUpdate().eq(SeriousIllegality::getcSupplierInfoId,supplierApprovalFirst.getcSupplierInfoId())
+//                .eq(SeriousIllegality::getcEnterpriseId,enterprise.getId()).remove();
         List<SeriousIllegality> seriousIllegalities = enterprise.getSeriousIllegalities();
-        if(CollectionUtil.isNotEmpty(seriousIllegalities)){
+        if (CollectionUtil.isNotEmpty(seriousIllegalities)) {
             for (SeriousIllegality seriousIllegality : seriousIllegalities) {
-                seriousIllegality.setcSupplierInfoId(supplierApprovalFirst.getcSupplierInfoId());
-                seriousIllegality.setcEnterpriseId(enterprise.getId());
-                seriousIllegalityService.save(seriousIllegality);
-                if(seriousIllegality.getSeriousIllegality().equals(1)){
-                    count ++;
+//                seriousIllegality.setcSupplierInfoId(supplierApprovalFirst.getcSupplierInfoId());
+//                seriousIllegality.setcEnterpriseId(enterprise.getId());
+//                seriousIllegalityService.save(seriousIllegality);
+                if (seriousIllegality.getSeriousIllegality().equals(1)) {
+                    count++;
                 }
             }
         }
-        taxOweNoticeService.lambdaUpdate().eq(TaxOweNotice::getcSupplierInfoId,supplierApprovalFirst.getcSupplierInfoId())
-                .eq(TaxOweNotice::getcEnterpriseId,enterprise.getId()).remove();
+//        taxOweNoticeService.lambdaUpdate().eq(TaxOweNotice::getcSupplierInfoId,supplierApprovalFirst.getcSupplierInfoId())
+//                .eq(TaxOweNotice::getcEnterpriseId,enterprise.getId()).remove();
         List<TaxOweNotice> taxOweNotices = enterprise.getTaxOweNotices();
-        if(CollectionUtil.isNotEmpty(taxOweNotices)){
+        if (CollectionUtil.isNotEmpty(taxOweNotices)) {
             for (TaxOweNotice taxOweNotice : taxOweNotices) {
-                taxOweNotice.setcSupplierInfoId(supplierApprovalFirst.getcSupplierInfoId());
-                taxOweNotice.setcEnterpriseId(enterprise.getId());
-                taxOweNoticeService.save(taxOweNotice);
-                if(taxOweNotice.getTaxOweNotice().equals(1)){
-                    count ++;
+//                taxOweNotice.setcSupplierInfoId(supplierApprovalFirst.getcSupplierInfoId());
+//                taxOweNotice.setcEnterpriseId(enterprise.getId());
+//                taxOweNoticeService.save(taxOweNotice);
+                if (taxOweNotice.getTaxOweNotice().equals(1)) {
+                    count++;
                 }
             }
         }
-        taxIllegalDataService.lambdaUpdate().eq(TaxIllegalData::getcSupplierInfoId,supplierApprovalFirst.getcSupplierInfoId())
-                .eq(TaxIllegalData::getcEnterpriseId,enterprise.getId()).remove();
+//        taxIllegalDataService.lambdaUpdate().eq(TaxIllegalData::getcSupplierInfoId,supplierApprovalFirst.getcSupplierInfoId())
+//                .eq(TaxIllegalData::getcEnterpriseId,enterprise.getId()).remove();
         List<TaxIllegalData> taxIllegalData = enterprise.getTaxIllegalData();
-        if(CollectionUtil.isNotEmpty(taxIllegalData)){
+        if (CollectionUtil.isNotEmpty(taxIllegalData)) {
             for (TaxIllegalData taxIllegalDatum : taxIllegalData) {
-                taxIllegalDatum.setcSupplierInfoId(supplierApprovalFirst.getcSupplierInfoId());
-                taxIllegalDatum.setcEnterpriseId(enterprise.getId());
-                taxIllegalDataService.save(taxIllegalDatum);
-                if(taxIllegalDatum.getTaxIllegal().equals(1)){
-                    count ++;
+//                taxIllegalDatum.setcSupplierInfoId(supplierApprovalFirst.getcSupplierInfoId());
+//                taxIllegalDatum.setcEnterpriseId(enterprise.getId());
+//                taxIllegalDataService.save(taxIllegalDatum);
+                if (taxIllegalDatum.getTaxIllegal().equals(1)) {
+                    count++;
                 }
             }
         }
-        blacklistService.lambdaUpdate().eq(Blacklist::getcSupplierInfoId,supplierApprovalFirst.getcSupplierInfoId())
-                .eq(Blacklist::getcEnterpriseId,enterprise.getId()).remove();
+//        blacklistService.lambdaUpdate().eq(Blacklist::getcSupplierInfoId,supplierApprovalFirst.getcSupplierInfoId())
+//                .eq(Blacklist::getcEnterpriseId,enterprise.getId()).remove();
         List<Blacklist> blacklists = enterprise.getBlacklists();
-        if(CollectionUtil.isNotEmpty(blacklists)){
+        if (CollectionUtil.isNotEmpty(blacklists)) {
             for (Blacklist blacklist : blacklists) {
-                blacklist.setcSupplierInfoId(supplierApprovalFirst.getcSupplierInfoId());
-                blacklist.setcEnterpriseId(enterprise.getId());
-                blacklistService.save(blacklist);
-                if(blacklist.getBlacklist().equals(1)){
-                    count ++;
+//                blacklist.setcSupplierInfoId(supplierApprovalFirst.getcSupplierInfoId());
+//                blacklist.setcEnterpriseId(enterprise.getId());
+//                blacklistService.save(blacklist);
+                if (blacklist.getBlacklist().equals(1)) {
+                    count++;
                 }
             }
         }
-        exceptionDataService.lambdaUpdate().eq(ExceptionData::getcSupplierInfoId,supplierApprovalFirst.getcSupplierInfoId())
-                .eq(ExceptionData::getcEnterpriseId,enterprise.getId()).remove();
+//        exceptionDataService.lambdaUpdate().eq(ExceptionData::getcSupplierInfoId,supplierApprovalFirst.getcSupplierInfoId())
+//                .eq(ExceptionData::getcEnterpriseId,enterprise.getId()).remove();
         List<ExceptionData> exceptionData = enterprise.getExceptionData();
-        if(CollectionUtil.isNotEmpty(exceptionData)){
+        if (CollectionUtil.isNotEmpty(exceptionData)) {
             for (ExceptionData exceptionDatum : exceptionData) {
-                exceptionDatum.setcSupplierInfoId(supplierApprovalFirst.getcSupplierInfoId());
-                exceptionDatum.setcEnterpriseId(enterprise.getId());
-                exceptionDataService.save(exceptionDatum);
-                if(exceptionDatum.getException().equals(1)){
-                    count ++;
+//                exceptionDatum.setcSupplierInfoId(supplierApprovalFirst.getcSupplierInfoId());
+//                exceptionDatum.setcEnterpriseId(enterprise.getId());
+//                exceptionDataService.save(exceptionDatum);
+                if (exceptionDatum.getException().equals(1)) {
+                    count++;
                 }
             }
         }
-        newsService.lambdaUpdate().eq(News::getcSupplierInfoId,supplierApprovalFirst.getcSupplierInfoId())
-                .eq(News::getcEnterpriseId,enterprise.getId()).remove();
+//        newsService.lambdaUpdate().eq(News::getcSupplierInfoId,supplierApprovalFirst.getcSupplierInfoId())
+//                .eq(News::getcEnterpriseId,enterprise.getId()).remove();
         List<News> news = enterprise.getNews();
-        if(CollectionUtil.isNotEmpty(news)){
+        if (CollectionUtil.isNotEmpty(news)) {
             for (News news1 : news) {
-                news1.setcSupplierInfoId(supplierApprovalFirst.getcSupplierInfoId());
-                news1.setcEnterpriseId(enterprise.getId());
-                newsService.save(news1);
-                if(news1.getNews().equals(1)){
-                    count ++;
+//                news1.setcSupplierInfoId(supplierApprovalFirst.getcSupplierInfoId());
+//                news1.setcEnterpriseId(enterprise.getId());
+//                newsService.save(news1);
+                if (news1.getNews().equals(1)) {
+                    count++;
                 }
             }
         }
-        if(flag){
+        if (flag) {
             supplierApprovalFirst.setMainEnterpriseCount(count);
-            if(count > 0 ){
+            if (count > 0) {
                 supplierApprovalFirst.setMainEnterpriseResult("未通过");
-            }else {
+            } else {
                 supplierApprovalFirst.setMainEnterpriseResult("通过");
             }
-        }else {
+        } else {
             supplierApprovalFirst.setGuaranteeEnterpriseCount(count);
-            if(count > 0 ){
+            if (count > 0) {
                 supplierApprovalFirst.setGuaranteeEnterpriseResult("未通过");
-            }else {
+            } else {
                 supplierApprovalFirst.setGuaranteeEnterpriseResult("通过");
             }
         }
     }
 
-    private void autoView(SupplierInfo supplierInfo, Enterprise enterprise,CEnterpriseHistory enterpriseHistory) {
+    private void autoView(SupplierInfo supplierInfo, Enterprise enterprise, CEnterpriseHistory enterpriseHistory) {
         Long id = supplierInfo.getId();
         Long firstReviewId = supplierInfo.getSupplierApprovalFirst().getId();
         //企业负责人征信情况
         List<CreditSituation> creditSituations = creditSituationService.lambdaQuery().eq(CreditSituation::getSupplierApprovalFirstId, firstReviewId).list();
         List<CreditSituation> creditSituationsResult = new ArrayList<>();
-        if(CollectionUtil.isNotEmpty(creditSituations)){
+        if (CollectionUtil.isNotEmpty(creditSituations)) {
             for (CreditSituation creditSituation : creditSituations) {
                 CCreditInvestigationInfoHistory creditInvestigationInfoHistory = creditInvestigationInfoHistoryService.getById(creditSituation.getcCreditInvestigationInfoHistoryId());
                 List<FileStorage> list = new ArrayList<>();
-                if(creditInvestigationInfoHistory.getcEnterpriseHistoryId().equals(enterpriseHistory.getId())){
+                if (creditInvestigationInfoHistory.getcEnterpriseHistoryId().equals(enterpriseHistory.getId())) {
                     //todo 填充征信报告
                     CreditInfo creditInfo = creditService.lambdaQuery().eq(CreditInfo::getCardNo, creditInvestigationInfoHistory.getSocialCreditCode()).one();
-                    if(creditInfo != null){
+                    if (creditInfo != null) {
                         List<CreditDetail> creditDetails = creditDetailService.lambdaQuery()
-                                .eq(CreditDetail::getCreditId,creditInfo.getId())
+                                .eq(CreditDetail::getCreditId, creditInfo.getId())
                                 .isNotNull(CreditDetail::getCreditAddress)
                                 .orderByDesc(CreditDetail::getGmtCreate).list();
-                        if(CollectionUtil.isNotEmpty(creditDetails)){
+                        if (CollectionUtil.isNotEmpty(creditDetails)) {
                             CreditDetail creditDetail = creditDetails.get(0);
-                            if(StringUtil.isNotEmpty(creditDetail.getCreditAddress())){
+                            if (StringUtil.isNotEmpty(creditDetail.getCreditAddress())) {
                                 FileStorage creditDetailFiles = fileStorageService.get(Long.valueOf(creditDetail.getCreditAddress()));
                                 list.add(creditDetailFiles);
                             }
@@ -858,14 +873,14 @@ public class SupplierApprovalFirstServiceImpl extends ServiceImpl<SupplierApprov
         //todo 填充征信报告
         CreditInfo creditInfo = creditService.lambdaQuery().eq(CreditInfo::getCardNo, enterprise.getSocialCreditCode()).one();
         List<FileStorage> list = new ArrayList<>();
-        if(creditInfo != null){
+        if (creditInfo != null) {
             List<CreditDetail> creditDetails = creditDetailService.lambdaQuery()
-                    .eq(CreditDetail::getCreditId,creditInfo.getId())
+                    .eq(CreditDetail::getCreditId, creditInfo.getId())
                     .isNotNull(CreditDetail::getCreditAddress)
                     .orderByDesc(CreditDetail::getGmtCreate).list();
-            if(CollectionUtil.isNotEmpty(creditDetails)){
+            if (CollectionUtil.isNotEmpty(creditDetails)) {
                 CreditDetail creditDetail = creditDetails.get(0);
-                if(StringUtil.isNotEmpty(creditDetail.getCreditAddress())){
+                if (StringUtil.isNotEmpty(creditDetail.getCreditAddress())) {
                     FileStorage creditDetailFiles = fileStorageService.get(Long.valueOf(creditDetail.getCreditAddress()));
                     list.add(creditDetailFiles);
                 }