From a68bf12a2975405f57f9a9d51b91c13a93c026f0 Mon Sep 17 00:00:00 2001
From: MrShi <1878285526@qq.com>
Date: 星期三, 31 一月 2024 21:01:36 +0800
Subject: [PATCH] Mr.Shi

---
 server/service/src/main/java/com/doumee/service/business/impl/ApplyChangeServiceImpl.java |  216 ++++++++++++++++++++++++++++++++++++++++++++---------
 1 files changed, 178 insertions(+), 38 deletions(-)

diff --git a/server/service/src/main/java/com/doumee/service/business/impl/ApplyChangeServiceImpl.java b/server/service/src/main/java/com/doumee/service/business/impl/ApplyChangeServiceImpl.java
index 3370231..c8e661a 100644
--- a/server/service/src/main/java/com/doumee/service/business/impl/ApplyChangeServiceImpl.java
+++ b/server/service/src/main/java/com/doumee/service/business/impl/ApplyChangeServiceImpl.java
@@ -16,12 +16,10 @@
 import com.doumee.dao.business.dto.ApplyChangeOptDTO;
 import com.doumee.dao.business.dto.CountCyclePriceDTO;
 import com.doumee.dao.business.dto.InsuranceApplyOptDTO;
-import com.doumee.dao.business.join.ApplyChagneDetailJoinMapper;
-import com.doumee.dao.business.join.ApplyChangeJoinMapper;
-import com.doumee.dao.business.join.ApplyDetailJoinMapper;
-import com.doumee.dao.business.join.DuSolutionJoinMapper;
+import com.doumee.dao.business.join.*;
 import com.doumee.dao.business.model.*;
 import com.doumee.dao.business.vo.CountCyclePriceVO;
+import com.doumee.dao.system.model.SystemUser;
 import com.doumee.service.business.ApplyChangeService;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
@@ -33,14 +31,12 @@
 import org.apache.commons.lang3.StringUtils;
 import org.apache.shiro.SecurityUtils;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
 import java.math.BigDecimal;
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.List;
-import java.util.Objects;
+import java.util.*;
 import java.util.stream.Collectors;
 
 /**
@@ -68,6 +64,8 @@
     @Autowired
     private SystemDictDataBiz systemDictDataBiz;
     @Autowired
+    private CompanyMapper companyMapper;
+    @Autowired
     private SignService signService;
     @Autowired
     private ApplyChagneDetailJoinMapper applyChagneDetailJoinMapper;
@@ -87,6 +85,10 @@
 
     @Autowired
     private ApplyLogMapper applyLogMapper;
+    @Value("${debug_model}")
+    private boolean debugModel;
+    @Autowired
+    private ApplyLogJoinMapper applyLogJoinMapper;
 
     @Autowired
     private SolutionsMapper solutionsMapper;
@@ -262,7 +264,8 @@
                         .selectAs(Solutions::getTimeUnit,ApplyChagneDetail::getSolutionTimeUnit)
                         .selectAs(Solutions::getPrice,ApplyChagneDetail::getSolutionPrice)
                   .leftJoin(ApplyChange.class, ApplyChange::getId, ApplyChagneDetail::getApplyChangeId)
-                  .leftJoin(Solutions.class, Solutions::getId, ApplyChange::getSolutionsId)
+                  .leftJoin(InsuranceApply.class, InsuranceApply::getId, ApplyChange::getApplyId)
+                  .leftJoin(Solutions.class, Solutions::getId, InsuranceApply::getSolutionId)
                   .eq(ApplyChagneDetail::getApplyChangeId,update.getId())
                   .eq(ApplyChagneDetail::getIsdeleted,Constants.ZERO) );
         if(detailList ==null || detailList.size()==0){
@@ -299,7 +302,8 @@
                         .selectAs(Solutions::getTimeUnit,ApplyChagneDetail::getSolutionTimeUnit)
                         .selectAs(Solutions::getPrice,ApplyChagneDetail::getSolutionPrice)
                   .leftJoin(ApplyChange.class, ApplyChange::getId, ApplyChagneDetail::getApplyChangeId)
-                  .leftJoin(Solutions.class, Solutions::getId, ApplyChange::getSolutionsId)
+                  .leftJoin(InsuranceApply.class, InsuranceApply::getId, ApplyChange::getApplyId)
+                  .leftJoin(Solutions.class, Solutions::getId, InsuranceApply::getSolutionId)
                   .eq(ApplyChagneDetail::getApplyChangeId,update.getId())
                   .eq(ApplyChagneDetail::getIsdeleted,Constants.ZERO) );
         if(detailList ==null || detailList.size()==0){
@@ -326,7 +330,8 @@
                 add.setDuId(detail.getDuId());
                 add.setStartTime(update.getApplyStartTime());
                 add.setEndTime(detail.getEndTime());
-                add.setFee(Constants.countDetailFee(detail.getSolutionTimeUnit(),detail.getSolutionPrice(), add.getStartTime(),add.getEndTime()));
+                add.setFee(new BigDecimal(0));
+//                add.setFee(Constants.countDetailFee(detail.getSolutionTimeUnit(),detail.getSolutionPrice(), add.getStartTime(),add.getEndTime()));
                 if(DateUtil.daysBetweenDates(add.getStartTime(),new Date() )>=0){
                     //濡傛灉宸蹭骇鐢熻垂鐢紝璁$畻宸蹭骇鐢熻垂鐢�
                     add.setCurrentFee(Constants.countDetailFee(detail.getSolutionTimeUnit(),detail.getSolutionPrice(), add.getStartTime(),new Date()));
@@ -349,7 +354,7 @@
                 BigDecimal updateCurrentFee = new BigDecimal(0);
                 if(DateUtil.daysBetweenDates(update.getApplyStartTime(),new Date() )>0){
                     //濡傛灉鐢熸晥鏃堕棿 鏄粖澶╀箣鍓嶏紝閫�鍥炲凡浜х敓璐圭敤锛岃绠楀凡浜х敓璐圭敤(鎬昏垂鐢�-宸蹭骇鐢熻垂鐢�)
-                    updateCurrentFee = updateFee.subtract(oldModel.getCurrentFee());
+                    updateCurrentFee = updateFee.subtract(Constants.formatBigdecimal(oldModel.getCurrentFee()));
                 }
                 applyDetailJoinMapper.update(null, new UpdateWrapper<ApplyDetail>().lambda()
                         .setSql(" fee = ifnull(fee,0)+"+updateFee)
@@ -454,11 +459,12 @@
         if (!loginUserInfo.getType().equals(Constants.ONE)) {
             throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(), "鐢ㄦ埛绫诲瀷閿欒锛氶潪浼佷笟鐢ㄦ埛鏃犳硶杩涜璇ユ搷浣�");
         }
+        BigDecimal fee = BigDecimal.ZERO;
+
         InsuranceApply insuranceApply = insuranceApplyMapper.selectById(applyChange.getApplyId());
         if (Objects.isNull(insuranceApply)) {
             throw new BusinessException(ResponseStatus.DATA_EMPTY);
         }
-        System.out.println(Constants.InsuranceApplyStatus.UPLOAD_INSURANCE.getKey());
         if (!Constants.equalsInteger(insuranceApply.getStatus(),Constants.InsuranceApplyStatus.UPLOAD_INSURANCE.getKey())) {
             throw new BusinessException(ResponseStatus.DATA_ERRO.getCode(), "淇濆崟鐘舵�侀敊璇�");
         }
@@ -491,6 +497,90 @@
         applyChange.setStatus(Constants.ZERO);
         applyChangeMapper.insert(applyChange);
 
+        this.dealApplyChangeData(applyChange,insuranceApply,companySolution,solutions,loginUserInfo,fee);
+
+        ApplyChange applyChangeFee = new ApplyChange();
+        applyChangeFee.setId(applyChange.getId());
+        applyChangeFee.setFee(fee);
+        applyChangeMapper.updateById(applyChangeFee);
+
+        this.saveApplyLog(applyChange,Constants.ApplyChangeLogStatus.UPLOAD,null);
+        return applyChange.getId();
+    }
+
+
+
+
+    @Override
+    @Transactional(rollbackFor = {Exception.class,BusinessException.class})
+    public Integer update(ApplyChange applyChange) {
+        if (Objects.isNull(applyChange)
+                || Objects.isNull(applyChange.getId())
+                || Objects.isNull(applyChange.getApplyId())
+                || Objects.isNull(applyChange.getValidTime())
+                || Objects.isNull(applyChange.getType())
+                || !(applyChange.getType().equals(Constants.ZERO) || applyChange.getType().equals(Constants.ONE))
+        ) {
+            throw new BusinessException(ResponseStatus.BAD_REQUEST);
+        }
+        LoginUserInfo loginUserInfo = (LoginUserInfo) SecurityUtils.getSubject().getPrincipal();
+        if (!loginUserInfo.getType().equals(Constants.ONE)) {
+            throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(), "鐢ㄦ埛绫诲瀷閿欒锛氶潪浼佷笟鐢ㄦ埛鏃犳硶杩涜璇ユ搷浣�");
+        }
+        ApplyChange dbApplyChange = applyChangeMapper.selectById(applyChange.getId());
+        if(Objects.isNull(dbApplyChange)){
+            throw new BusinessException(ResponseStatus.DATA_EMPTY);
+        }
+        if(!dbApplyChange.getStatus().equals(Constants.ApplyChangeStatus.PLATFORM_AGREE.getKey())){
+            throw new BusinessException(ResponseStatus.DATA_ERRO.getCode(), "涓氬姟淇濈敵璇峰崟鐘舵�侀敊璇�");
+        }
+
+        InsuranceApply insuranceApply = insuranceApplyMapper.selectById(applyChange.getApplyId());
+        if (Objects.isNull(insuranceApply)) {
+            throw new BusinessException(ResponseStatus.DATA_EMPTY);
+        }
+        if (!Constants.equalsInteger(insuranceApply.getStatus(),Constants.InsuranceApplyStatus.UPLOAD_INSURANCE.getKey())) {
+            throw new BusinessException(ResponseStatus.DATA_ERRO.getCode(), "淇濆崟鐘舵�侀敊璇�");
+        }
+        if (DateUtil.compareDate(insuranceApply.getEndTime(),new Date()) >= Constants.ZERO
+        ) {
+            throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(), "淇濆崟宸茶繃淇濓紝鏃犳硶杩涜璇ユ搷浣�");
+        }
+        Solutions solutions = solutionsMapper.selectById(insuranceApply.getSolutionId());
+        if(Objects.isNull(solutions)){
+            throw new BusinessException(ResponseStatus.DATA_EMPTY.getCode(),"鏈煡璇㈠埌淇濋櫓鏂规");
+        }
+        CompanySolution companySolution = companySolutionMapper.selectOne(new QueryWrapper<CompanySolution>().lambda()
+                .eq(CompanySolution::getCompanyId,loginUserInfo.getCompanyId())
+                .eq(CompanySolution::getSolutionBaseId,solutions.getId())
+                .eq(CompanySolution::getIsdeleted,Constants.ZERO)
+                .last(" limit 1 ")
+        );
+        if(Objects.isNull(companySolution)){
+            throw new BusinessException(ResponseStatus.DATA_EMPTY.getCode(),"鏈煡璇㈠埌浼佷笟鍒嗛厤淇濋櫓鏂规淇℃伅");
+        }
+        //鐢宠鏃堕棿蹇呴』澶勪簬淇濆崟鐨勬椂闂磋寖鍥村唴
+        if (!(DateUtil.compareDate( insuranceApply.getStartTime(),applyChange.getValidTime()) >= Constants.ZERO
+                && DateUtil.compareDate( applyChange.getValidTime(),insuranceApply.getEndTime()) >= Constants.ZERO)) {
+            throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(), "鐢宠鏃ユ湡鏈浜庝繚鍗曟棩鏈熷唴锛屾棤娉曡繘琛岃鎿嶄綔");
+        }
+
+
+        applyChange.setEditDate(new Date());
+        applyChange.setEditor(loginUserInfo.getId());
+        applyChange.setStatus(Constants.ZERO);
+        BigDecimal fee = BigDecimal.ZERO;
+        this.dealApplyChangeData(applyChange,insuranceApply,companySolution,solutions,loginUserInfo,fee);
+        applyChange.setFee(fee);
+        applyChangeMapper.updateById(applyChange);
+        this.saveApplyLog(applyChange,Constants.ApplyChangeLogStatus.UPLOAD,null);
+        return applyChange.getId();
+    }
+
+
+    public void dealApplyChangeData(ApplyChange applyChange,InsuranceApply insuranceApply,CompanySolution companySolution,Solutions solutions,LoginUserInfo loginUserInfo,BigDecimal fee){
+
+
         //鏌ヨ淇濋櫓鏂规涓嬬殑鎵�鏈夋淳閬e崟浣�
         List<DuSolution>  duSolutionList = duSolutionJoinMapper.selectJoinList(DuSolution.class,new MPJLambdaWrapper<DuSolution>()
                 .selectAll(DuSolution.class)
@@ -514,17 +604,16 @@
         if (!CollectionUtils.isNotEmpty(duWorktypeList)) {
             throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(), "鏁版嵁寮傚父锛氫繚闄╂柟妗堜笅鏈煡璇㈠埌宸ョ淇℃伅");
         }
-        BigDecimal fee = BigDecimal.ZERO;
+
         //鍔犱繚鏁版嵁
         List<ApplyChagneDetail> addDetailList = applyChange.getAddDetailList();
         if (CollectionUtils.isNotEmpty(addDetailList)) {
-           if(companySolution.getCanAdd().equals(Constants.ZERO)){
-               throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(), "璇ヤ紒涓氬垎閰嶄繚闄╂柟妗堟棤娉曡繘琛屽姞淇�");
-           }
+            if(companySolution.getCanAdd().equals(Constants.ZERO)){
+                throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(), "璇ヤ紒涓氬垎閰嶄繚闄╂柟妗堟棤娉曡繘琛屽姞淇�");
+            }
             this.addChangeDetail(applyChange,addDetailList,duWorktypeList,duSolutionList,insuranceApply,solutions,loginUserInfo);
 
             fee = addDetailList.stream().map(ApplyChagneDetail::getFee).reduce(BigDecimal.ZERO,BigDecimal::add);
-
         }
 
         //鍑忎繚鏁版嵁
@@ -533,23 +622,19 @@
             if(companySolution.getCanReduce().equals(Constants.ZERO)){
                 throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(), "璇ヤ紒涓氬垎閰嶄繚闄╂柟妗堟棤娉曡繘琛屽噺淇�");
             }
-             this.delChangeDetail(applyChange,delDetailList,insuranceApply,solutions,loginUserInfo);
+            this.delChangeDetail(applyChange,delDetailList,insuranceApply,solutions,loginUserInfo);
             fee = fee.add(delDetailList.stream().map(ApplyChagneDetail::getFee).reduce(BigDecimal.ZERO,BigDecimal::add));
         }
-        ApplyChange applyChangeFee = new ApplyChange();
-        applyChangeFee.setId(applyChange.getId());
-        applyChangeFee.setFee(fee);
-        applyChangeMapper.updateById(applyChangeFee);
 
         //鎹㈠巶涓氬姟
         List<ApplyChagneDetail> changeDetailList = applyChange.getChangeDetailList();
         if (CollectionUtils.isNotEmpty(changeDetailList)) {
             this.changeDetail(applyChange,changeDetailList,duWorktypeList,duSolutionList,loginUserInfo);
         }
-
-        this.saveApplyLog(applyChange,Constants.ApplyChangeLogStatus.UPLOAD,null);
-        return applyChange.getId();
     }
+
+
+
 
 
     public void saveApplyLog(ApplyChange applyChange,Constants.ApplyChangeLogStatus applyChangeLogStatus,String content){
@@ -894,6 +979,7 @@
         queryWrapper
                 .selectAll(ApplyChange.class)
                 .selectAs(InsuranceApply::getCode,ApplyChange::getApplyCode)
+                .selectAs(Solutions::getName,ApplyChange::getSolutionsName)
                 .select("( select count(1) from apply_chagne_detail ad where t.id = ad.APPLY_CHANGE_ID and ad.TYPE = 0  )",ApplyChange::getAddNum)
                 .select("( select count(1) from apply_chagne_detail ad where t.id = ad.APPLY_CHANGE_ID and ad.TYPE = 1  )",ApplyChange::getDelNum)
                 .select("( select count(1) from apply_chagne_detail ad where t.id = ad.APPLY_CHANGE_ID and ad.TYPE = 2  )",ApplyChange::getChangeNum)
@@ -906,7 +992,8 @@
                         Constants.ApplyChangeStatus.RETURN_APPLY_UPLOAD.getKey(),
                         Constants.ApplyChangeStatus.RETURN_APPLY_SIGNATURE.getKey())
                 .eq(!Objects.isNull(model.getCompanyId()),InsuranceApply::getCompanyId,model.getCompanyId())
-                .eq(!Objects.isNull(model.getSolutionsId()),ApplyChange::getSolutionsId,model.getSolutionsId())
+//                .eq(!Objects.isNull(model.getSolutionsId()),ApplyChange::getSolutionsId,model.getSolutionsId())
+                .eq(!Objects.isNull(model.getBaseSolutionsId()),Solutions::getBaseId,model.getBaseSolutionsId())
                 .ge(StringUtils.isNotBlank(model.getCreateDateS()),ApplyChange::getCreateDate, model.getCreateDateS()+" 00:00:00" )
                 .le(StringUtils.isNotBlank(model.getCreateDateE()),ApplyChange::getCreateDate, model.getCreateDateE()+" 23:59:59" );
 
@@ -1016,15 +1103,59 @@
         queryWrapper.selectAll(ApplyChange.class)
                 .selectAs(InsuranceApply::getCode,ApplyChange::getApplyCode)
                 .selectAs(Company::getName,ApplyChange::getCompanyName)
+                .selectAs(InsuranceApply::getStartTime,ApplyChange::getStartTime)
+                .selectAs(InsuranceApply::getEndTime,ApplyChange::getEndTime)
+                .selectAs(Solutions::getName,ApplyChange::getSolutionsName)
                 .select("( select count(1) from apply_chagne_detail ad where t.id = ad.APPLY_CHANGE_ID and ad.TYPE = 0  )",ApplyChange::getAddNum)
                 .select("( select count(1) from apply_chagne_detail ad where t.id = ad.APPLY_CHANGE_ID and ad.TYPE = 1  )",ApplyChange::getDelNum)
                 .select("( select count(1) from apply_chagne_detail ad where t.id = ad.APPLY_CHANGE_ID and ad.TYPE = 2  )",ApplyChange::getChangeNum)
-                .select("( select ifnull(sum(ad.FEE),0) from apply_chagne_detail ad where t.id = ad.APPLY_CHANGE_ID  )",ApplyChange::getChangeMoney)
                 .leftJoin(InsuranceApply.class,InsuranceApply::getId,ApplyChange::getApplyId)
                 .leftJoin(Solutions.class,Solutions::getId,InsuranceApply::getSolutionId)
                 .leftJoin(Company.class,Company::getId,InsuranceApply::getCompanyId)
                 .eq(ApplyChange::getId,id);
         ApplyChange applyChange =  applyChangeJoinMapper.selectOne(queryWrapper);
+
+        //鏌ヨ鎿嶄綔璁板綍
+        List<ApplyLog> applyLogList = applyLogJoinMapper.selectJoinList(ApplyLog.class,
+                new MPJLambdaWrapper<ApplyLog>()
+                        .selectAll(ApplyLog.class)
+                        .selectAs(SystemUser::getRealname,ApplyLog::getCreatorName)
+                        .selectAs(SystemUser::getType,ApplyLog::getCreatorType)
+                        .selectAs(Company::getName,ApplyLog::getCompanyName)
+                        .leftJoin(SystemUser.class,SystemUser::getId,ApplyLog::getCreator)
+                        .leftJoin(Company.class,Company::getId,SystemUser::getCompanyId)
+                        .eq(ApplyLog::getObjId,applyChange.getId())
+                        .orderByAsc(ApplyLog::getCreateDate)
+        );
+        applyChange.setApplyLogList(applyLogList);
+
+        List<Multifile> multifiles = multifileMapper.selectList(new QueryWrapper<Multifile>().lambda()
+                .eq(Multifile::getObjId,applyChange.getId())
+                .in(Multifile::getObjType, Arrays.asList(new Integer[]{Constants.MultiFile.CA_APPLY_JIAJIAN_SIGN.getKey()
+                        ,Constants.MultiFile.CA_PD_PDF.getKey()
+                        ,Constants.MultiFile.CA_APPLY_CHANGEUNIT_SIGN.getKey()}))
+                .eq(Multifile::getIsdeleted,Constants.ZERO));
+        if(multifiles!=null){
+            String path = systemDictDataBiz.queryByCode(Constants.OSS,Constants.RESOURCE_PATH).getCode()
+                    +systemDictDataBiz.queryByCode(Constants.OSS,Constants.APPLY_FILE).getCode();
+            for(Multifile f : multifiles){
+                if(StringUtils.isBlank(f.getFileurl())){
+                    continue;
+                }
+                f.setFileurlFull(path+f.getFileurl());
+                if(Constants.equalsInteger(f.getObjType(),Constants.MultiFile.CA_APPLY_JIAJIAN_SIGN.getKey())){
+                    //绛剧讲鍚庣敵璇峰崟
+                    applyChange.setApplyFile(f);
+                }else    if(Constants.equalsInteger(f.getObjType(),Constants.MultiFile.CA_APPLY_CHANGEUNIT_SIGN.getKey())){
+                    //绛剧讲鍚庣敵璇峰崟
+                    applyChange.setApplyUnitFile(f);
+                }else if(Constants.equalsInteger(f.getObjType(),Constants.MultiFile.CA_PD_PDF.getKey())){
+                    //绛剧讲鍚庣殑鎶曚繚鍗�
+                    applyChange.setPidanFile(f);
+                }
+            }
+        }
+
         return applyChange;
     }
     /**
@@ -1035,7 +1166,7 @@
     @Override
     public  ApplyChange  exportChangeUnitExcel(ApplyChange param){
         ApplyChange model = findJoinDetail(param);
-        if(Objects.isNull(model) ||! Constants.equalsInteger(Constants.ZERO,model.getType())){
+        if(Objects.isNull(model) ||! Constants.equalsInteger(Constants.ZERO,model.getIsdeleted())){
             throw new BusinessException(ResponseStatus.DATA_EMPTY);
         }
 
@@ -1067,7 +1198,7 @@
     }
 
     private String getOnlineSignLink(ApplyChange model) {
-        if(Objects.isNull(model) ||! Constants.equalsInteger(Constants.ZERO,model.getType())){
+        if(Objects.isNull(model) ||! Constants.equalsInteger(Constants.ZERO,model.getIsdeleted())){
             throw new BusinessException(ResponseStatus.DATA_EMPTY);
         }
         if(!Constants.equalsInteger(Constants.ZERO,model.getStatus())){
@@ -1075,14 +1206,21 @@
         }
         LoginUserInfo user = (LoginUserInfo) SecurityUtils.getSubject().getPrincipal();
         Company company = user.getCompany();
-        if(company== null || StringUtils.isBlank( company.getEmail()) || !Constants.equalsInteger(company.getSignStatus(),Constants.ONE)){
+        if(debugModel){
+company = companyMapper.selectById(model.getCompanyId());
+        }
+        if(company== null || StringUtils.isBlank( company.getEmail()) || !Constants.equalsInteger(company.getSignStatus(),Constants.THREE)){
             throw  new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"瀵逛笉璧凤紝浼佷笟灏氭湭鍏峰鍦ㄧ嚎绛剧珷鏉′欢锛岃鑱旂郴骞冲彴绠$悊鍛樼‘璁");
         }
-
-        String fileUrl = ExcelExporter.build(ApplyChange.class).exportChangeUnitExcelToPdf(model,"缂撳瓨鐢宠琛�");
+        String fileUrl = null;
+        if(Constants.equalsObject(model.getType(), Constants.ONE)){
+              fileUrl = ExcelExporter.build(ApplyChange.class).exportChangeUnitExcelToPdf(model,"鎹㈠巶鐢宠琛�");
+        }else{
+            fileUrl = ExcelExporter.build(ApplyChange.class).exportJiajianBaoExcelToPdf(model,"鍔犲噺淇濈敵璇疯〃");
+        }
         String notifyUrl = systemDictDataBiz.queryByCode(Constants.SYSTEM,Constants.SIGN_DONE_NOTIFY_URL).getCode();
         notifyUrl = notifyUrl.replace("${type}","0").replace("${id}",model.getId().toString());
-        String applyNo = signService.applySignLocalFile(company.getName(),fileUrl,company.getName(),company.getCode(),company.getEmail(),null,company.getSignId(),notifyUrl);
+        String applyNo = signService.applySignLocalFile(company.getName(),company.getName(),fileUrl,company.getCode(),company.getEmail(),"鎶曚繚浼佷笟绛剧珷",company.getSignId(),notifyUrl);
         if(StringUtils.isBlank(applyNo) ){
             throw  new BusinessException(ResponseStatus.SERVER_ERROR.getCode(),"瀵逛笉璧凤紝鑾峰彇鍦ㄧ嚎绛剧珷鍦板潃澶辫触锛岃绋嶅悗閲嶈瘯锛�");
         }
@@ -1096,6 +1234,7 @@
         update.setEditDate(new Date());
         update.setSignApplyNo(applyNo);
         applyChangeMapper.updateById(update);
+
         return  link;
     }
 
@@ -1109,7 +1248,7 @@
     public  ApplyChange  exportJiajianBaoExcel(ApplyChange param){
 
         ApplyChange model = findJoinDetail(param);
-        if(Objects.isNull(model) ||! Constants.equalsInteger(Constants.ZERO,model.getType())){
+        if(Objects.isNull(model) ||! Constants.equalsInteger(Constants.ZERO,model.getIsdeleted())){
             throw new BusinessException(ResponseStatus.DATA_EMPTY);
         }
 
@@ -1135,12 +1274,13 @@
                 .selectAll(ApplyChange.class)
                 .selectAs(Solutions::getName,ApplyChange::getSolutionsName)
                 .selectAs(Company::getName,ApplyChange::getCompanyName)
+                .selectAs(InsuranceApply::getCompanyId,ApplyChange::getCompanyId)
                 .selectAs(InsuranceApply::getCode,ApplyChange::getApplyCode)
                 .selectAs(InsuranceApply::getStartTime,ApplyChange::getStartTime)
                 .selectAs(InsuranceApply::getStartTime,ApplyChange::getEndTime)
                 .leftJoin(InsuranceApply.class,InsuranceApply::getId,ApplyChange::getApplyId)
                 .leftJoin(Solutions.class,Solutions::getId,InsuranceApply::getSolutionId)
-                .leftJoin(Company.class,Company::getId,ApplyChange::getCompanyId)
+                .leftJoin(Company.class,Company::getId,InsuranceApply::getCompanyId)
                 .eq(ApplyChange::getId,param.getId())
                 .last("limit 1");
 
@@ -1152,7 +1292,7 @@
                 .selectAll(ApplyChagneDetail.class)
                 .selectAs(Member::getName,ApplyChagneDetail::getMemberName)
                 .selectAs(Member::getSex,ApplyChagneDetail::getSex)
-                .selectAs(Member::getIdcardNo,ApplyChagneDetail::getIdcardNo)
+                .selectAs(Member::getIdcardNo,ApplyChagneDetail::getMemberIdcardNo)
                 .selectAs(Worktype::getName,ApplyChagneDetail::getWorkTypeName)
                 .selectAs(DispatchUnit::getName,ApplyChagneDetail::getDuName)
                 .leftJoin(Worktype.class,Worktype::getId,ApplyChagneDetail::getWorktypeId)
@@ -1174,7 +1314,7 @@
                 .select("t3.name as oldWorktypeName")
                 .select("t4.name as oldDuName")
                 .selectAs(Member::getSex,ApplyChagneDetail::getSex)
-                .selectAs(Member::getIdcardNo,ApplyChagneDetail::getIdcardNo)
+                .selectAs(Member::getIdcardNo,ApplyChagneDetail::getMemberIdcardNo)
                 .leftJoin(Worktype.class,Worktype::getId,ApplyChagneDetail::getWorktypeId)
                 .leftJoin(DispatchUnit.class,DispatchUnit::getId,ApplyChagneDetail::getDuId)
                 .leftJoin(Worktype.class,Worktype::getId,ApplyChagneDetail::getOldWorktypeId)

--
Gitblit v1.9.3