From 0d6bb65549a15f9681710c283f21927ff861aa56 Mon Sep 17 00:00:00 2001
From: jiangping <jp@doumee.com>
Date: 星期四, 25 一月 2024 09:57:14 +0800
Subject: [PATCH] 开发业务接口

---
 server/service/src/main/java/com/doumee/service/business/impl/InsuranceApplyServiceImpl.java |  120 +++++++++++++++++++++++++++++++++++++++++++++++++++++++-----
 1 files changed, 110 insertions(+), 10 deletions(-)

diff --git a/server/service/src/main/java/com/doumee/service/business/impl/InsuranceApplyServiceImpl.java b/server/service/src/main/java/com/doumee/service/business/impl/InsuranceApplyServiceImpl.java
index 4be1bc8..57e08ea 100644
--- a/server/service/src/main/java/com/doumee/service/business/impl/InsuranceApplyServiceImpl.java
+++ b/server/service/src/main/java/com/doumee/service/business/impl/InsuranceApplyServiceImpl.java
@@ -10,6 +10,7 @@
 import com.doumee.core.utils.Constants;
 import com.doumee.core.utils.DateUtil;
 import com.doumee.core.utils.Utils;
+import com.doumee.core.utils.aliyun.ALiYunUtil;
 import com.doumee.dao.business.*;
 import com.doumee.dao.business.dto.InsuranceApplyOptDTO;
 import com.doumee.dao.business.dto.InsuranceApplyQueryDTO;
@@ -331,23 +332,122 @@
         insuranceApplyMapper.updateById(update);
         return  link;
     }
+    public String uploadSignFile(String link){
+        try {
+            String bucketName = systemDictDataBiz.queryByCode(Constants.OSS,Constants.BUCKETNAME).getCode();
+            String access_id= systemDictDataBiz.queryByCode(Constants.OSS,Constants.ACCESS_ID).getCode();
+            String access_key= systemDictDataBiz.queryByCode(Constants.OSS,Constants.ACCESS_KEY).getCode();
+            String endpoint = systemDictDataBiz.queryByCode(Constants.OSS,Constants.ENDPOINT).getCode();
+            String folder = systemDictDataBiz.queryByCode(Constants.OSS,Constants.APPLY_FILE).getCode();
+            String tempFileName =  DateUtil.getNowShortDate() + "/" + UUID.randomUUID().toString() + ".pdf";
+            String key = folder + tempFileName;// 鏂囦欢鍚�
+            ALiYunUtil obs = new ALiYunUtil(endpoint,access_id, access_key);
+            if (obs.uploadOnlineObject(link,bucketName, key,null)) {
+                // 绉诲姩鎴愬姛,杩斿洖鏂囦欢鍚�
+                return tempFileName;
+            }
+        }catch (Exception e){
+
+        }
+        return  null;
+
+    }
+
+
+    public Integer uploadSignedFileDo(InsuranceApply model,String fileurl) {
+        InsuranceApply update = new InsuranceApply();
+        update.setEditDate(new Date());
+        update.setEditor(model.getCreator());
+        update.setStatus(Constants.InsuranceApplyStatus.UPLOAD_INSURANCE.getKey());
+        update.setCheckDate(update.getEditDate());
+        update.setCheckInfo("浼佷笟瀹屾垚绛剧讲");
+        update.setCheckUserId(model.getCreator());
+        update.setId(model.getId());
+        insuranceApplyMapper.updateById(update);
+
+        Multifile f = new Multifile();
+        f.setIsdeleted(Constants.ZERO);
+        f.setCreator(model.getCreator());
+        f.setObjId(update.getId());
+        f.setCreateDate(update.getEditDate());
+        f.setObjType(Constants.MultiFile.BD_SIGNED_PDF.getKey());
+        f.setType(Constants.TWO);
+        f.setFileurl(fileurl);
+        f.setName("鎶曚繚鍗曠绾﹀悎鍚�.pdf");
+        multifileMapper.insert(f);
+        Constants.ApplyLogType applyLogType = Constants.ApplyLogType.SIGNATURE;
+        ApplyLog log = new ApplyLog(update,applyLogType.getName(), null,update.getId(),applyLogType.getKey(),JSONObject.toJSONString(model), JSONObject.toJSONString(update));
+        applyLogMapper.insert(log);
+        return  1;
+
+    }
+    public Integer uploadChangeSignedFileDo(ApplyChange model,String fileurl) {
+        ApplyChange update = new ApplyChange();
+        update.setEditDate(new Date());
+        update.setEditor(model.getCreator());
+        update.setStatus(Constants.ApplyChangeStatus.SIGNATURE.getKey());
+        update.setCheckDate(update.getEditDate());
+        update.setCheckInfo("浼佷笟瀹屾垚绛剧讲");
+        update.setCheckUserId(model.getCreator());
+        update.setId(model.getId());
+        applyChangeMapper.updateById(update);
+
+        Multifile f = new Multifile();
+        f.setIsdeleted(Constants.ZERO);
+        f.setCreator(model.getCreator());
+        f.setObjId(update.getId());
+        f.setCreateDate(update.getEditDate());
+        f.setObjType(Constants.equalsInteger(Constants.ZERO,model.getType())?Constants.MultiFile.CA_APPLY_JIAJIAN_SIGN.getKey() : Constants.MultiFile.CA_APPLY_CHANGEUNIT_SIGN.getKey());
+        f.setType(Constants.TWO);
+        f.setFileurl(fileurl);
+        f.setName("绛剧珷鐢宠琛�.pdf");
+        multifileMapper.insert(f);
+        Constants.ApplyLogType applyLogType =Constants.equalsInteger(Constants.ZERO,model.getType())? Constants.ApplyLogType.CA_JIAJIAN_APPLY_SIGN: Constants.ApplyLogType.CA_CHANGUNIT_APPLY_SIGN;
+        ApplyLog log = new ApplyLog(update,applyLogType.getName(), null,update.getId(),applyLogType.getKey(),JSONObject.toJSONString(model), JSONObject.toJSONString(update));
+        applyLogMapper.insert(log);
+        return  1;
+
+    }
     @Override
     public   void dealSignResult(NotifyDataReq data){
         if(data.getApplyNo() == null ){
             throw  new BusinessException(ResponseStatus.BAD_REQUEST);
         }
-        InsuranceApply model = insuranceApplyMapper.selectOne(new QueryWrapper<InsuranceApply>().lambda().eq(InsuranceApply::getSignApplyNo,data.getApplyNo()).last("limit 1" ));
-        if(model != null ){
-            //-----------------TUDO--------瀹屽杽绛剧害瀹屾垚涓氬姟------
-
-        }else{
-            ApplyChange applyChange = applyChangeMapper.selectOne(new QueryWrapper<ApplyChange>().lambda().eq(ApplyChange::getSignApplyNo,data.getApplyNo()).last("limit 1" ));
-            if(applyChange == null){
-                throw  new BusinessException(ResponseStatus.DATA_EMPTY.getCode(),"绯荤粺鏈壘鍒板尮閰嶅悎鍚屽彿!");
+        if(Constants.equalsInteger(data.getSignStatus(), Constants.THREE )){
+            //濡傛灉宸蹭繚鍏�,鍙笅杞界绾﹂檮浠�
+            InsuranceApply model = insuranceApplyMapper.selectOne(new QueryWrapper<InsuranceApply>().lambda().eq(InsuranceApply::getSignApplyNo,data.getApplyNo()).last("limit 1" ));
+            if(model != null && Constants.equalsInteger(model.getStatus(),Constants.InsuranceApplyStatus.COMPANY_BACK_APPLY_WAIT_SIGNATURE.getKey())){
+                //瀹屾垚绛剧讲宸插畬鎴愭搷浣�
+                String link = signService.linkFile(data.getApplyNo());
+                String fileUrl = uploadSignFile(link);
+                if(StringUtils.isBlank(fileUrl)){
+                    //濡傛灉涓嬭浇澶辫触锛屾竻闄ゅ悎鍚岋紝涓嬫绛剧珷閲嶆柊鐢熸垚鏂板悎鍚�
+                    return;
+                }
+                uploadSignedFileDo(model,fileUrl);
+                return;
             }
-            //-----------------TUDO-------瀹屽杽绛剧害瀹屾垚-------
-        }
 
+            ApplyChange applyChange = applyChangeMapper.selectOne(new QueryWrapper<ApplyChange>().lambda().eq(ApplyChange::getSignApplyNo,data.getApplyNo()).last("limit 1" ));
+            if(applyChange != null &&Constants.equalsInteger(applyChange.getStatus(),Constants.ApplyChangeStatus.UPLOAD.getKey())){
+                String link = signService.linkFile(data.getApplyNo());
+                String fileUrl = uploadSignFile(link);
+                if(StringUtils.isBlank(fileUrl)){
+                    //濡傛灉涓嬭浇澶辫触锛屾竻闄ゅ悎鍚岋紝涓嬫绛剧珷閲嶆柊鐢熸垚鏂板悎鍚�
+                    return;
+                }
+                uploadChangeSignedFileDo(applyChange,fileUrl);
+            }
+        }else if(Constants.equalsInteger(data.getSignStatus(), Constants.TWO )){
+            //濡傛灉宸叉嫆绛撅紝娓呴櫎鍚堝悓锛屼笅娆$绔犻噸鏂扮敓鎴愭柊鍚堝悓
+            insuranceApplyMapper.update(null,new UpdateWrapper<InsuranceApply>().lambda()
+                    .set(InsuranceApply::getSignApplyNo,null)
+                    .eq(InsuranceApply::getSignApplyNo,data.getApplyNo()));
+            //濡傛灉宸叉嫆绛撅紝娓呴櫎鍚堝悓锛屼笅娆$绔犻噸鏂扮敓鎴愭柊鍚堝悓
+            applyChangeMapper.update(null,new UpdateWrapper<ApplyChange>().lambda()
+                    .set(ApplyChange::getSignApplyNo,null)
+                    .eq(ApplyChange::getSignApplyNo,data.getApplyNo()));
+        }
 
     }
     @Override

--
Gitblit v1.9.3