From 95db36f778d5a6f4197cc2cde4390c84e57b26b6 Mon Sep 17 00:00:00 2001
From: jiangping <jp@doumee.com>
Date: 星期三, 31 一月 2024 09:36:53 +0800
Subject: [PATCH] 开发业务接口

---
 server/service/src/main/java/com/doumee/service/business/impl/ApplyChangeServiceImpl.java |  110 +++++++++++++++++++++++++++++++++++++++++++++++-------
 1 files changed, 95 insertions(+), 15 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 9264c44..d74064d 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
@@ -1,6 +1,8 @@
 package com.doumee.service.business.impl;
 
 import com.alibaba.fastjson.JSONObject;
+import com.doumee.biz.system.SystemDictDataBiz;
+import com.doumee.core.annotation.excel.ExcelExporter;
 import com.doumee.core.constants.ResponseStatus;
 import com.doumee.core.exception.BusinessException;
 import com.doumee.core.model.LoginUserInfo;
@@ -21,6 +23,7 @@
 import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.doumee.service.business.third.SignService;
 import com.github.xiaoymin.knife4j.core.util.CollectionUtils;
 import com.github.yulichang.wrapper.MPJLambdaWrapper;
 import org.apache.commons.lang3.StringUtils;
@@ -56,6 +59,10 @@
     @Autowired
     private ApplyChangeJoinMapper applyChangeJoinMapper;
 
+    @Autowired
+    private SystemDictDataBiz systemDictDataBiz;
+    @Autowired
+    private SignService signService;
     @Autowired
     private ApplyChagneDetailJoinMapper applyChagneDetailJoinMapper;
 
@@ -518,8 +525,6 @@
         }
 
         this.saveApplyLog(applyChange,Constants.ApplyChangeLogStatus.UPLOAD,null);
-
-
         return applyChange.getId();
     }
 
@@ -532,7 +537,7 @@
         applyLog.setIsdeleted(Constants.ZERO);
         applyLog.setApplyId(applyChange.getApplyId());
         applyLog.setTitle(applyChangeLogStatus.getName());
-        applyLog.setContent(content);
+        applyLog.setContent(applyChangeLogStatus.getInfo().replace("${param}",content));
         applyLog.setObjType(applyChangeLogStatus.getKey());
         applyLog.setObjId( applyChange.getId());
         applyLog.setStatus(applyChange.getStatus());
@@ -780,7 +785,10 @@
                 .leftJoin(InsuranceApply.class,InsuranceApply::getId,ApplyChange::getApplyId)
                 .leftJoin(Solutions.class,Solutions::getId,InsuranceApply::getSolutionId)
                 .eq(!Objects.isNull(model.getType()),ApplyChange::getType,model.getType())
-                .eq(!Objects.isNull(model.getStatus()),ApplyChange::getStatus,model.getStatus())
+                .eq(!Objects.isNull(model.getStatus())&&!model.getStatus().equals(Constants.ApplyChangeStatus.RETURN_APPLY_UPLOAD.getKey()),ApplyChange::getStatus,model.getStatus())
+                .in(!Objects.isNull(model.getStatus())&&model.getStatus().equals(Constants.ApplyChangeStatus.RETURN_APPLY_UPLOAD.getKey()),ApplyChange::getStatus,
+                        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())
                 .ge(StringUtils.isNotBlank(model.getCreateDateS()),ApplyChange::getCreateDate, model.getCreateDateS()+" 00:00:00" )
@@ -821,7 +829,10 @@
                 .leftJoin(InsuranceApply.class,InsuranceApply::getId,ApplyChange::getApplyId)
                 .leftJoin(Solutions.class,Solutions::getId,InsuranceApply::getSolutionId)
                 .eq(!Objects.isNull(model.getType()),ApplyChange::getType,model.getType())
-                .eq(!Objects.isNull(model.getStatus()),ApplyChange::getStatus,model.getStatus())
+                .eq(!Objects.isNull(model.getStatus())&&!model.getStatus().equals(Constants.ApplyChangeStatus.RETURN_APPLY_UPLOAD.getKey()),ApplyChange::getStatus,model.getStatus())
+                .in(!Objects.isNull(model.getStatus())&&model.getStatus().equals(Constants.ApplyChangeStatus.RETURN_APPLY_UPLOAD.getKey()),ApplyChange::getStatus,
+                        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())
                 .ge(StringUtils.isNotBlank(model.getCreateDateS()),ApplyChange::getCreateDate, model.getCreateDateS()+" 00:00:00" )
@@ -861,16 +872,24 @@
             throw new BusinessException(ResponseStatus.DATA_ERRO.getCode(),"鏁版嵁宸插垹闄�,鏃犳硶杩涜璇ユ搷浣�");
         }
         Constants.ApplyChangeLogStatus applyChangeLogStatus = Constants.ApplyChangeLogStatus.RETURN_APPLY;
-        if(applyChangeOptDTO.getOptType().equals(Constants.ApplyChangeStatus.RETURN_APPLY_UPLOAD.getKey())
-                ||applyChangeOptDTO.getOptType().equals(Constants.ApplyChangeStatus.RETURN_APPLY_SIGNATURE.getKey())){
+
+        if(applyChangeOptDTO.getOptType().equals(3)){
             //鍙戣捣閫�鍥炵敵璇�
             if(loginUserInfo.getType().equals(Constants.ONE)){
                 throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"闈炰紒涓氱鐢ㄦ埛鏃犳硶杩涜璇ユ搷浣�");
             }
-            if(!applyChange.getStatus().equals(Constants.ApplyChangeStatus.UPLOAD.getKey()) ){
-                throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"鏁版嵁鐘舵�侀敊璇棤娉曡繘琛岃鎿嶄綔!");
+            if(!(applyChange.getStatus().equals(Constants.ApplyChangeStatus.UPLOAD.getKey())
+                || applyChange.getStatus().equals(Constants.ApplyChangeStatus.SIGNATURE.getKey()))){
+                throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"鏁版嵁鐘舵�侀敊璇棤娉曡繘閫�鍥炵敵璇�!");
             }
-        }else if(applyChangeOptDTO.getOptType().equals(Constants.ApplyChangeStatus.PLATFORM_AGREE.getKey())){
+
+            if(applyChange.getStatus().equals(Constants.ApplyChangeStatus.UPLOAD.getKey())){
+                applyChange.setStatus(Constants.ApplyChangeStatus.RETURN_APPLY_UPLOAD.getKey());
+            }else{
+                applyChange.setStatus(Constants.ApplyChangeStatus.RETURN_APPLY_SIGNATURE.getKey());
+            }
+
+        }else if(applyChangeOptDTO.getOptType().equals(4)){
             applyChangeLogStatus = Constants.ApplyChangeLogStatus.PLATFORM_AGREE;
             //骞冲彴鍚屾剰閫�鍥�
             if(loginUserInfo.getType().equals(Constants.ZERO)){
@@ -881,7 +900,7 @@
                     )){
                 throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"鏁版嵁鐘舵�侀敊璇棤娉曡繘琛岃鎿嶄綔!");
             }
-        }else if(applyChangeOptDTO.getOptType().equals(Constants.ApplyChangeStatus.UPLOAD.getKey())){
+        }else if(applyChangeOptDTO.getOptType().equals(5)){
             applyChangeLogStatus = Constants.ApplyChangeLogStatus.PLATFORM_UN_AGREE;
             //骞冲彴椹冲洖閫�鍥�
             if(loginUserInfo.getType().equals(Constants.ZERO)){
@@ -892,21 +911,29 @@
                     )){
                 throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"鏁版嵁鐘舵�侀敊璇棤娉曡繘琛岃鎿嶄綔!");
             }
-        }else if(applyChangeOptDTO.getOptType().equals(Constants.ApplyChangeStatus.CLOSE.getKey())){
-            applyChangeLogStatus = Constants.ApplyChangeLogStatus.CLOSE;
+            if(applyChange.getStatus().equals(Constants.ApplyChangeStatus.RETURN_APPLY_UPLOAD.getKey())){
+                applyChange.setStatus(Constants.ApplyChangeStatus.UPLOAD.getKey());
+            }else{
+                applyChange.setStatus(Constants.ApplyChangeStatus.SIGNATURE.getKey());
+            }
+        }else if(applyChangeOptDTO.getOptType().equals(6)){
             //浼佷笟鍏抽棴
+            applyChangeLogStatus = Constants.ApplyChangeLogStatus.CLOSE;
             if(loginUserInfo.getType().equals(Constants.ONE)){
                 throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"闈炰紒涓氱鐢ㄦ埛鏃犳硶杩涜璇ユ搷浣�");
             }
             if(!applyChange.getStatus().equals(Constants.ApplyChangeStatus.PLATFORM_AGREE.getKey())){
                 throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"鏁版嵁鐘舵�侀敊璇棤娉曡繘琛岃鎿嶄綔!");
             }
+            applyChange.setStatus(Constants.ApplyChangeStatus.CLOSE.getKey());
         }else{
             throw new BusinessException(ResponseStatus.BAD_REQUEST  );
         }
-        applyChange.setStatus(applyChangeOptDTO.getOptType());
+        applyChange.setEditor(loginUserInfo.getId());
+        applyChange.setEditDate(new Date());
         applyChangeMapper.updateById(applyChange);
-//        //瀛樺偍鏃ュ織鏁版嵁
+
+        //瀛樺偍鏃ュ織鏁版嵁
         this.saveApplyLog(applyChange,applyChangeLogStatus,applyChangeOptDTO.getOptIllustration());
     }
 
@@ -946,6 +973,59 @@
         model.setChangeNum(model.getChangeDetailList().size());
         return model;
     }
+    /**
+     * 瀵煎嚭鎹㈠巶鐢宠琛�
+     * @param param
+     * @return
+     */
+    @Override
+    public  String  getSignLinkJiajiabao(ApplyChange param){
+        ApplyChange model = exportJiajianBaoExcel(param);
+        return  getOnlineSignLink(model);
+    }
+    /**
+     * 瀵煎嚭鎹㈠巶鐢宠琛�
+     * @param param
+     * @return
+     */
+    @Override
+    public  String  getSignLinkChangeUnit(ApplyChange param){
+        ApplyChange model = exportChangeUnitExcel(param);
+        return  getOnlineSignLink(model);
+    }
+
+    private String getOnlineSignLink(ApplyChange model) {
+        if(Objects.isNull(model) ||! Constants.equalsInteger(Constants.ZERO,model.getType())){
+            throw new BusinessException(ResponseStatus.DATA_EMPTY);
+        }
+        if(!Constants.equalsInteger(Constants.ZERO,model.getStatus())){
+            throw new BusinessException(ResponseStatus.DATA_EMPTY.getCode(),"瀵逛笉璧凤紝璇ョ敵璇风姸鎬佸凡娴佽浆锛屽綋鍓嶄笉鏀寔绛剧珷鎿嶄綔锛�");
+        }
+        LoginUserInfo user = (LoginUserInfo) SecurityUtils.getSubject().getPrincipal();
+        Company company = user.getCompany();
+        if(company== null || StringUtils.isBlank( company.getEmail()) || !Constants.equalsInteger(company.getSignStatus(),Constants.ONE)){
+            throw  new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"瀵逛笉璧凤紝浼佷笟灏氭湭鍏峰鍦ㄧ嚎绛剧珷鏉′欢锛岃鑱旂郴骞冲彴绠$悊鍛樼‘璁");
+        }
+
+        String fileUrl = ExcelExporter.build(ApplyChange.class).exportChangeUnitExcelToPdf(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);
+        if(StringUtils.isBlank(applyNo) ){
+            throw  new BusinessException(ResponseStatus.SERVER_ERROR.getCode(),"瀵逛笉璧凤紝鑾峰彇鍦ㄧ嚎绛剧珷鍦板潃澶辫触锛岃绋嶅悗閲嶈瘯锛�");
+        }
+        String link = signService.signLink(applyNo,company.getName(),company.getCode());
+        if(StringUtils.isBlank(link) ){
+            throw  new BusinessException(ResponseStatus.SERVER_ERROR.getCode(),"瀵逛笉璧凤紝鑾峰彇鍦ㄧ嚎绛剧珷鍦板潃澶辫触锛岃绋嶅悗閲嶈瘯锛�");
+        }
+        ApplyChange update= new ApplyChange();
+        update.setId(model.getId());
+        update.setEditor(user.getId());
+        update.setEditDate(new Date());
+        update.setSignApplyNo(applyNo);
+        applyChangeMapper.updateById(update);
+        return  link;
+    }
 
 
     /**

--
Gitblit v1.9.3