Parcourir la source

Merge branch 'wq1' of SH-Arbitrate/Mediation-Backend into dev

wangqiong123 il y a 2 ans
Parent
révision
b4e54bd501

+ 13
- 0
ruoyi-admin/src/main/java/com/ruoyi/web/controller/wisdomarbitrate/mscase/MsCaseApplicationController.java Voir le fichier

@@ -412,4 +412,17 @@ public class MsCaseApplicationController extends BaseController {
412 412
         List<SmsSendRecord> list = caseApplicationService.getSmsSendRecord(smsSendRecord);
413 413
         return getDataTable(list);
414 414
     }
415
+    /**
416
+     * 保存onlyOffice在线编辑的文件
417
+     * @param
418
+     * @return
419
+     */
420
+    @GetMapping("/saveOnlyOfficeFile")
421
+    public AjaxResult saveOnlyOfficeFile(  @RequestBody MsCaseAttach caseAttach) {
422
+        if(caseAttach.getCaseAppliId()==null||StrUtil.isEmpty(caseAttach.getOnlyOfficeFileId())||StrUtil.isEmpty(caseAttach.getAnnexPath())){
423
+            return error("参数校验失败");
424
+        }
425
+
426
+        return  caseApplicationService.saveOnlyOfficeFile(caseAttach);
427
+    }
415 428
 }

+ 5
- 1
ruoyi-admin/src/main/resources/application.yml Voir le fichier

@@ -18,7 +18,7 @@ ruoyi:
18 18
 # 开发环境配置
19 19
 server:
20 20
   # 测试环境6001,开发环境7001
21
-  port: 7001
21
+  port: 6001
22 22
   servlet:
23 23
     # 应用的访问路径
24 24
     context-path: /
@@ -194,6 +194,10 @@ arbitrateConfig:
194 194
 # 回调通知
195 195
 signSealCallbackConfig:
196 196
   url: http://121.40.189.20:6001/mssignSeal/signSeaalCaseApplicaCallback
197
+#  onlyOffice系统url配置
198
+onlyOfficeConfig:
199
+#  url: http://172.16.0.254:9090/files/upload
200
+  url: http://121.40.189.20:9090/files/upload
197 201
 #jodconverter:
198 202
 #  local:
199 203
 #    host: 121.40.189.20

+ 3
- 3
ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/domain/entity/mscase/MsCaseAttach.java Voir le fichier

@@ -73,8 +73,8 @@ public class MsCaseAttach {
73 73
     private Long sealStatus;
74 74
 
75 75
     /**
76
-     * 是否是证据上传,0-否,1-是
76
+     * onlyOffice附件id
77 77
      */
78
-    @Column(name = "is_batch_upload")
79
-    private Long isBatchUpload;
78
+    @Column(name = "only_office_file_id")
79
+    private String onlyOfficeFileId;
80 80
 }

+ 12
- 1
ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/service/mscase/MsCaseApplicationService.java Voir le fichier

@@ -1,5 +1,6 @@
1 1
 package com.ruoyi.wisdomarbitrate.service.mscase;
2 2
 
3
+import com.alibaba.fastjson.JSONArray;
3 4
 import com.ruoyi.common.core.domain.AjaxResult;
4 5
 import com.ruoyi.common.core.domain.entity.SysDictData;
5 6
 import com.ruoyi.common.core.domain.entity.SysUser;
@@ -219,6 +220,11 @@ public interface MsCaseApplicationService {
219 220
      * @param dictDataList 内置字段
220 221
      */
221 222
      void createMediateApplication(MsCaseApplication application, MsCaseAffiliate affiliate, String templatePath, List<String> bookmarkList, List<SysDictData> dictDataList, Integer templateType) ;
223
+    /**
224
+     * 调解书上传到onlyoffice服务器
225
+     * @param annexPath
226
+     */
227
+     JSONArray uploadOnlyOffice(String annexPath);
222 228
     /**
223 229
      * 案件受理
224 230
      * @param application
@@ -255,6 +261,11 @@ public interface MsCaseApplicationService {
255 261
      * @return
256 262
      */
257 263
     List<SmsSendRecord> getSmsSendRecord(SmsSendRecord smsSendRecord);
264
+    /**
265
+     * 保存onlyOffice在线编辑的文件
266
+     * @param
267
+     * @return
268
+     */
258 269
 
259
-
270
+    AjaxResult saveOnlyOfficeFile(MsCaseAttach caseAttach);
260 271
 }

+ 85
- 16
ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/service/mscase/impl/MsCaseApplicationServiceImpl.java Voir le fichier

@@ -5,6 +5,7 @@ import cn.hutool.core.collection.CollectionUtil;
5 5
 import cn.hutool.core.util.StrUtil;
6 6
 import cn.hutool.http.HttpRequest;
7 7
 import cn.hutool.http.HttpResponse;
8
+import cn.hutool.http.HttpUtil;
8 9
 import cn.hutool.json.JSONUtil;
9 10
 import com.alibaba.fastjson.JSONArray;
10 11
 import com.alibaba.fastjson.JSONObject;
@@ -47,7 +48,6 @@ import com.ruoyi.wisdomarbitrate.mapper.template.FatchRuleMapper;
47 48
 import com.ruoyi.wisdomarbitrate.mapper.template.TemplateManageMapper;
48 49
 import com.ruoyi.wisdomarbitrate.service.mscase.MsCaseApplicationService;
49 50
 import com.ruoyi.wisdomarbitrate.utils.*;
50
-
51 51
 import org.apache.pdfbox.pdmodel.PDDocument;
52 52
 import org.apache.poi.xwpf.usermodel.XWPFDocument;
53 53
 import org.springframework.beans.BeanUtils;
@@ -92,6 +92,8 @@ public class MsCaseApplicationServiceImpl implements MsCaseApplicationService {
92 92
 
93 93
     @Value("${arbitrateConfig.url}")
94 94
     private String arbitrateUrl;
95
+    @Value("${onlyOfficeConfig.url}")
96
+    private String onlyOfficeUrl;
95 97
     @Autowired
96 98
     MsCaseApplicationService caseApplicationService;
97 99
     @Autowired
@@ -1548,7 +1550,6 @@ public class MsCaseApplicationServiceImpl implements MsCaseApplicationService {
1548 1550
                         .annexType(annexType)
1549 1551
                         .useId(SecurityUtils.getUserId())
1550 1552
                         .useAccount(SecurityUtils.getUsername())
1551
-                        .isBatchUpload(1L)
1552 1553
                         .build();
1553 1554
                 int count = msCaseAttachMapper.save(caseAttach);
1554 1555
                 if (count > 0 ) {
@@ -2154,6 +2155,25 @@ public class MsCaseApplicationServiceImpl implements MsCaseApplicationService {
2154 2155
     public List<SmsSendRecord> getSmsSendRecord(SmsSendRecord smsSendRecord) {
2155 2156
         return smsRecordMapper.getSmsSendRecord(smsSendRecord);
2156 2157
     }
2158
+    /**
2159
+     * 保存onlyOffice在线编辑的文件
2160
+     * @param
2161
+     * @return
2162
+     */
2163
+    @Transactional
2164
+    @Override
2165
+    public AjaxResult saveOnlyOfficeFile(MsCaseAttach caseAttach) {
2166
+        if(StrUtil.isEmpty(caseAttach.getAnnexName())){
2167
+            caseAttach.setAnnexName("调解书");
2168
+            caseAttach.setAnnexType(AnnexTypeEnum.MEDIATE_BOOK.getCode());
2169
+            caseAttach.setUseId(getUserInfo().getUserId());
2170
+            caseAttach.setUseAccount(getUserInfo().getUserName());
2171
+            // 先删除之前的在新增
2172
+            msCaseAttachMapper.deleteCaseAttachByCasedIdAndType(caseAttach.getCaseAppliId(), caseAttach.getAnnexType());
2173
+            msCaseAttachMapper.save(caseAttach);
2174
+        }
2175
+        return AjaxResult.success();
2176
+    }
2157 2177
 
2158 2178
     /**
2159 2179
      * 查询预约信息
@@ -2224,10 +2244,11 @@ public class MsCaseApplicationServiceImpl implements MsCaseApplicationService {
2224 2244
                         if (caseAttachList != null && caseAttachList.size() > 0) {
2225 2245
                             for (MsCaseAttach caseAttach : caseAttachList) {
2226 2246
                                 if (caseAttach.getAnnexType() == AnnexTypeEnum.MEDIATE_BOOK.getCode()) {
2227
-                                    String prefix = "/profile";
2228
-                                    int startIndex = prefix.length();
2247
+                                  //  String prefix = "/profile";
2248
+                                  //  int startIndex = prefix.length();
2229 2249
                                     String annexPath = caseAttach.getAnnexPath();
2230
-                                    String path = "/home/ruoyi/uploadPath/" + annexPath.substring(startIndex+1);
2250
+                                  //  String path = "/home/ruoyi/uploadPath/" + annexPath.substring(startIndex+1);
2251
+                                    String path = annexPath;
2231 2252
                                     //获取文件上传地址
2232 2253
                                     EsignHttpResponse response = SaaSAPIFileUtils.getUploadUrl(path);
2233 2254
                                     String body = response.getBody();
@@ -2635,10 +2656,11 @@ public class MsCaseApplicationServiceImpl implements MsCaseApplicationService {
2635 2656
                         if (caseAttachList != null && caseAttachList.size() > 0) {
2636 2657
                             for (MsCaseAttach caseAttach : caseAttachList) {
2637 2658
                                 if (caseAttach.getAnnexType() == AnnexTypeEnum.MEDIATE_BOOK.getCode()) {
2638
-                                    String prefix = "/profile";
2639
-                                    int startIndex = prefix.length();
2659
+                                   // String prefix = "/profile";
2660
+                                  //  int startIndex = prefix.length();
2640 2661
                                     String annexPath = caseAttach.getAnnexPath();
2641
-                                    String path = "/home/ruoyi/uploadPath/" + annexPath.substring(startIndex+1);
2662
+//                                    String path = "/home/ruoyi/uploadPath/" + annexPath.substring(startIndex+1);
2663
+                                    String path = annexPath;
2642 2664
                                     //获取文件上传地址
2643 2665
                                     EsignHttpResponse response = SaaSAPIFileUtils.getUploadUrl(path);
2644 2666
                                     String body = response.getBody();
@@ -3729,15 +3751,62 @@ public class MsCaseApplicationServiceImpl implements MsCaseApplicationService {
3729 3751
         // 将word中的标签替换掉,生成新的word
3730 3752
         wordChangeText(templatePath, bookmarkValueMap,saveFolderPath,resultFilePath);
3731 3753
 
3732
-        MsCaseAttach caseAttach = MsCaseAttach.builder()
3733
-                .caseAppliId(application.getId())
3734
-                .annexName(orgFileName+".docx")
3735
-                .annexPath(resultFilePath.replace(RuoYiConfig.getProfile(),Constants.RESOURCE_PREFIX))
3736
-                .annexType(annexType)
3737
-                .build();
3754
+        MsCaseAttach caseAttach = null;
3755
+       String annexPath=resultFilePath.replace(RuoYiConfig.getProfile(),Constants.RESOURCE_PREFIX);
3756
+       // 如果是调解书或者调解协议上传到onlyoffice服务器
3757
+        if(annexType != null   && annexType.equals(AnnexTypeEnum.MEDIATE_BOOK.getCode())){
3758
+            JSONArray jsonArray = caseApplicationService.uploadOnlyOffice(annexPath);
3759
+            if(jsonArray!=null && jsonArray.size() > 0){
3760
+                    for (Object obj : jsonArray) {
3761
+                        JSONObject jsonObject = (JSONObject) obj;
3762
+                        caseAttach=    MsCaseAttach.builder()
3763
+                                .caseAppliId(application.getId())
3764
+                                .annexName(jsonObject.getString("fileName"))
3765
+                                .annexPath(jsonObject.getString("filePath"))
3766
+                                .annexType(annexType)
3767
+                                .onlyOfficeFileId(jsonObject.getString("fileId"))
3768
+                                .build();
3769
+
3770
+                }
3771
+            }
3772
+
3773
+        }
3738 3774
         //保存到附件表里,先删除之前的在保存
3739
-        msCaseAttachMapper.deleteCaseAttachByCasedIdAndType(caseAttach.getCaseAppliId(), annexType);
3740
-        msCaseAttachMapper.save(caseAttach);
3775
+        if(caseAttach != null) {
3776
+           msCaseAttachMapper.deleteCaseAttachByCasedIdAndType(caseAttach.getCaseAppliId(), annexType);
3777
+            msCaseAttachMapper.save(caseAttach);
3778
+        }
3779
+    }
3780
+
3781
+    /**
3782
+     * 调解书上传到onlyoffice服务器
3783
+     * @param annexPath
3784
+     */
3785
+    @Override
3786
+    @Transactional
3787
+    public JSONArray uploadOnlyOffice(String annexPath) {
3788
+        annexPath=annexPath.replace("/profile","/home/ruoyi/uploadPath");
3789
+        File file = new File(annexPath);
3790
+        if (file.exists()) {
3791
+           // 调用onlyoffice
3792
+//            String url = "http://121.40.189.20:9090/files/upload";
3793
+            try {
3794
+                Map<String, Object> params = new HashMap<>();
3795
+                params.put("file", file);
3796
+                String postResult = HttpUtil.post(onlyOfficeUrl, params);
3797
+                if(StrUtil.isNotEmpty(postResult)){
3798
+                    // 转为jsonArray
3799
+                    JSONArray jsonArray = JSONArray.parseArray(postResult);
3800
+
3801
+                    return jsonArray;
3802
+                }
3803
+            } catch (Exception e) {
3804
+                throw new ServiceException("上传OnlyOffice服务器失败");
3805
+            }
3806
+        }else {
3807
+            throw new ServiceException("文件不存在");
3808
+        }
3809
+return null;
3741 3810
     }
3742 3811
 
3743 3812
     /**

+ 8
- 10
ruoyi-system/src/main/resources/mapper/wisdomarbitrate/mscase/MsCaseAttachMapper.xml Voir le fichier

@@ -13,18 +13,19 @@
13 13
         <result property="sealStatus"     column="seal_status"    />
14 14
         <result property="useId"     column="use_id"    />
15 15
         <result property="useAccount"     column="use_account"    />
16
+        <result property="onlyOfficeFileId"     column="only_office_file_id"    />
16 17
     </resultMap>
17 18
     <insert id="save" useGeneratedKeys="true" keyProperty="annexId">
18
-        INSERT INTO ms_case_attach (case_appli_id, annex_name, annex_path , annex_type,note,use_id,use_account,seal_status,is_batch_upload)
19
-        VALUES (#{caseAppliId}, #{annexName}, #{annexPath},#{annexType},#{note},#{useId},#{useAccount},#{sealStatus},#{isBatchUpload})
19
+        INSERT INTO ms_case_attach (case_appli_id, annex_name, annex_path , annex_type,note,use_id,use_account,seal_status,only_office_file_id)
20
+        VALUES (#{caseAppliId}, #{annexName}, #{annexPath},#{annexType},#{note},#{useId},#{useAccount},#{sealStatus},#{onlyOfficeFileId})
20 21
     </insert>
21 22
     <insert id="batchSave" useGeneratedKeys="true" keyProperty="annexId">
22
-        INSERT INTO ms_case_attach (case_appli_id, annex_name, annex_path , annex_type,note,use_id,use_account,seal_status,is_batch_upload)
23
+        INSERT INTO ms_case_attach (case_appli_id, annex_name, annex_path , annex_type,note,use_id,use_account,seal_status,only_office_file_id)
23 24
         VALUES
24 25
         <foreach item="item" index="index" collection="list" separator=",">
25 26
 
26 27
 
27
-         (#{item.caseAppliId}, #{item.annexName}, #{item.annexPath},#{item.annexType},#{item.note},#{item.useId},#{item.useAccount},#{item.sealStatus},#{item.isBatchUpload})
28
+         (#{item.caseAppliId}, #{item.annexName}, #{item.annexPath},#{item.annexType},#{item.note},#{item.useId},#{item.useAccount},#{item.sealStatus},#{item.onlyOfficeFileId})
28 29
         </foreach>
29 30
     </insert>
30 31
     <delete id="deleteByFileIds">
@@ -38,19 +39,16 @@
38 39
         delete from ms_case_attach
39 40
         where case_appli_id = #{caseAppliId}
40 41
         and annex_type = #{annexType}
41
-        <if test="isBatchUpload != null ">
42
-            AND is_batch_upload = #{isBatchUpload}
43
-        </if>
44 42
     </delete>
45 43
 
46 44
     <select id="queryAnnexPathByCaseId" resultType="com.ruoyi.wisdomarbitrate.domain.entity.mscase.MsCaseAttach" resultMap="CaseAttachResult">
47
-        select annex_id,case_appli_id,annex_name,annex_path,annex_type,note,use_id,use_account
45
+        select *
48 46
         from ms_case_attach
49 47
         where case_appli_id =#{id}
50 48
     </select>
51 49
 
52 50
     <select id="listCaseAttachByCaseIdAndType" resultType="com.ruoyi.wisdomarbitrate.domain.entity.mscase.MsCaseAttach" resultMap="CaseAttachResult">
53
-        select annex_id,case_appli_id,annex_name,annex_path,annex_type,note,use_id,use_account
51
+        select *
54 52
         from ms_case_attach
55 53
         <where>
56 54
             <if test="caseAppliId != null ">
@@ -78,7 +76,7 @@
78 76
     </delete>
79 77
 
80 78
     <select id="queryCaseAttachList" resultMap="CaseAttachResult">
81
-        select annex_id,case_appli_id,annex_name,annex_path,annex_type,note,use_id,use_account
79
+        select *
82 80
         from ms_case_attach
83 81
         <where>
84 82
             <if test="id != null ">