Просмотр исходного кода

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

wangqiong123 2 лет назад
Родитель
Сommit
a2a72acd9b

+ 14
- 7
ruoyi-admin/src/main/java/com/ruoyi/web/controller/common/CommonController.java Просмотреть файл

@@ -77,7 +77,7 @@ public class CommonController
77 77
      * 通用上传请求(单个)
78 78
      */
79 79
     @PostMapping("/upload")
80
-    public AjaxResult uploadFile(@RequestParam("file") MultipartFile file, @RequestParam("annexType") Integer annexType, @RequestParam("id") Long id) throws Exception
80
+    public AjaxResult uploadFile(@RequestParam("file") MultipartFile file, @RequestParam("annexType") Integer annexType) throws Exception
81 81
     {
82 82
         try
83 83
         {
@@ -86,8 +86,10 @@ public class CommonController
86 86
             // 上传并返回新文件名称
87 87
             String fileName = FileUploadUtils.upload(filePath, file);
88 88
             String url = serverConfig.getUrl() + fileName;
89
-            saveCaseAttach(id, annexType, fileName,file.getOriginalFilename());
89
+            Long annexId = saveCaseAttach(annexType, fileName, file.getOriginalFilename());
90 90
             AjaxResult ajax = AjaxResult.success();
91
+            ajax.put("annexId", annexId);
92
+            ajax.put("annexType", annexType);
91 93
             ajax.put("url", url);
92 94
             ajax.put("fileName", fileName);
93 95
             ajax.put("newFileName", FileUtils.getName(fileName));
@@ -102,13 +104,13 @@ public class CommonController
102 104
 
103 105
     /**
104 106
      * 保存到案件附件表
105
-     * @param id
107
+     * @param
106 108
      * @param annexType
107 109
      * @param fileName
108 110
      * @param originalFilename
109 111
      */
110
-    private void saveCaseAttach(Long id, Integer annexType, String fileName, String originalFilename) {
111
-        MsCaseAttach caseAttach = MsCaseAttach.builder().caseAppliId(id)
112
+    private Long saveCaseAttach(Integer annexType, String fileName, String originalFilename) {
113
+        MsCaseAttach caseAttach = MsCaseAttach.builder()
112 114
                 .annexName(originalFilename)
113 115
                 .annexPath(fileName)
114 116
                 .annexType(annexType)
@@ -116,6 +118,7 @@ public class CommonController
116 118
                 .useAccount(SecurityUtils.getUsername())
117 119
                 .build();
118 120
         msCaseAttachMapper.save(caseAttach);
121
+        return caseAttach.getAnnexId();
119 122
     }
120 123
     /**
121 124
      * 根据案件id获取附件
@@ -140,7 +143,7 @@ public class CommonController
140 143
      * 通用上传请求(多个)
141 144
      */
142 145
     @PostMapping("/uploads")
143
-    public AjaxResult uploadFiles(@RequestParam("files") MultipartFile[] files, @RequestParam("annexType")Integer annexType, @RequestParam("id")Long id ) throws Exception
146
+    public AjaxResult uploadFiles(@RequestParam("files") MultipartFile[] files, @RequestParam("annexType")Integer annexType ) throws Exception
144 147
     {
145 148
         try
146 149
         {
@@ -150,6 +153,7 @@ public class CommonController
150 153
             List<String> fileNames = new ArrayList<String>();
151 154
             List<String> newFileNames = new ArrayList<String>();
152 155
             List<String> originalFilenames = new ArrayList<String>();
156
+            List<Long> annexIds = new ArrayList<>();
153 157
             for (MultipartFile file : files)
154 158
             {
155 159
                 // 上传并返回新文件名称
@@ -159,9 +163,12 @@ public class CommonController
159 163
                 fileNames.add(fileName);
160 164
                 newFileNames.add(FileUtils.getName(fileName));
161 165
                 originalFilenames.add(file.getOriginalFilename());
162
-                saveCaseAttach(id, annexType, fileName,file.getOriginalFilename());
166
+                Long annexId = saveCaseAttach(annexType, fileName, file.getOriginalFilename());
167
+                annexIds.add(annexId);
163 168
             }
164 169
             AjaxResult ajax = AjaxResult.success();
170
+            ajax.put("annexIds", annexIds);
171
+            ajax.put("annexType", annexType);
165 172
             ajax.put("urls", StringUtils.join(urls, FILE_DELIMETER));
166 173
             ajax.put("fileNames", StringUtils.join(fileNames, FILE_DELIMETER));
167 174
             ajax.put("newFileNames", StringUtils.join(newFileNames, FILE_DELIMETER));

+ 37
- 0
ruoyi-admin/src/main/java/com/ruoyi/web/controller/wisdomarbitrate/mscase/MsCaseApplicationController.java Просмотреть файл

@@ -7,8 +7,10 @@ import com.ruoyi.wisdomarbitrate.domain.vo.mscase.MsCaseApplicationReq;
7 7
 import com.ruoyi.wisdomarbitrate.domain.vo.mscase.MsCaseApplicationVO;
8 8
 import com.ruoyi.wisdomarbitrate.service.mscase.MsCaseApplicationService;
9 9
 import org.springframework.web.bind.annotation.*;
10
+import org.springframework.web.multipart.MultipartFile;
10 11
 
11 12
 import javax.annotation.Resource;
13
+import java.io.IOException;
12 14
 import java.util.List;
13 15
 /**
14 16
  * 案件列表控制层
@@ -42,6 +44,41 @@ public class MsCaseApplicationController extends BaseController {
42 44
         return success(caseApplicationService.insert(caseApplication));
43 45
     }
44 46
 
47
+    /**
48
+     * 修改案件
49
+     */
50
+    @PostMapping("/update")
51
+    public AjaxResult update(@RequestBody MsCaseApplicationVO caseApplication )
52
+    {
53
+        if(caseApplication.getId()==null){
54
+            error("id不能为空");
55
+        }
56
+        return caseApplicationService.update(caseApplication);
57
+    }
58
+    /**
59
+     * 根据id查询案件
60
+     */
61
+    @GetMapping("/selectById")
62
+    public AjaxResult selectById(@RequestParam Long id )
63
+    {
64
+        if(id==null){
65
+            error("id不能为空");
66
+        }
67
+        return success(caseApplicationService.selectById(id));
68
+    }
69
+    /**
70
+     * 案件压缩包导入
71
+     * @param file
72
+     * @return
73
+     * @throws IOException
74
+     */
75
+    @PostMapping("/uploadCaseZipFile")
76
+    public AjaxResult uploadCaseZipFile(@RequestParam("file") MultipartFile file, @RequestParam("templateId")  Long templateId) throws IOException {
77
+        if(file.isEmpty()||templateId==null){
78
+            return error("参数不能为空");
79
+        }
80
+        return caseApplicationService.uploadCaseZipFile(file,templateId);
81
+    }
45 82
 
46 83
 
47 84
 

+ 23
- 0
ruoyi-common/src/main/java/com/ruoyi/common/utils/ThreadUtil.java Просмотреть файл

@@ -0,0 +1,23 @@
1
+package com.ruoyi.common.utils;
2
+
3
+import com.google.common.util.concurrent.ThreadFactoryBuilder;
4
+
5
+import java.util.concurrent.*;
6
+
7
+/**
8
+ * @Author: ymbgy
9
+ * @Date: 2022-09-23 10:06
10
+ */
11
+public class ThreadUtil {
12
+    public static ExecutorService createThreadPool() {
13
+        //获取系统处理器个数,作为线程池数量
14
+        int nThreads = Runtime.getRuntime().availableProcessors();
15
+        ThreadFactory namedThreadFactory = new ThreadFactoryBuilder()
16
+                .setNameFormat("demo-pool-%d").build();
17
+        //Thread Pool
18
+        ExecutorService executor = new ThreadPoolExecutor(nThreads, 200,
19
+                0L, TimeUnit.MILLISECONDS,
20
+                new LinkedBlockingQueue<Runnable>(1024), namedThreadFactory, new ThreadPoolExecutor.AbortPolicy());
21
+        return executor;
22
+    }
23
+}

+ 10
- 2
ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/domain/entity/mscase/MsCaseAffiliate.java Просмотреть файл

@@ -1,11 +1,14 @@
1 1
 package com.ruoyi.wisdomarbitrate.domain.entity.mscase;
2 2
 
3
-import java.util.Date;
4
-import javax.persistence.*;
5 3
 import lombok.Getter;
6 4
 import lombok.Setter;
7 5
 import lombok.ToString;
8 6
 
7
+import javax.persistence.Column;
8
+import javax.persistence.Id;
9
+import javax.persistence.Table;
10
+import java.util.Date;
11
+
9 12
 @Getter
10 13
 @Setter
11 14
 @ToString
@@ -89,6 +92,11 @@ public class MsCaseAffiliate {
89 92
      */
90 93
     @Column(name = "respondent_identity_num")
91 94
     private String respondentIdentityNum;
95
+    /**
96
+     * 被申请人联系电话
97
+     */
98
+    @Column(name = "respondent_phone")
99
+    private String respondentPhone;
92 100
 
93 101
     /**
94 102
      * 被申请人性别(0=男,女=1)

+ 5
- 0
ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/domain/entity/mscase/MsCaseApplication.java Просмотреть файл

@@ -1,5 +1,7 @@
1 1
 package com.ruoyi.wisdomarbitrate.domain.entity.mscase;
2 2
 
3
+import com.fasterxml.jackson.annotation.JsonFormat;
4
+import lombok.Data;
3 5
 import lombok.Getter;
4 6
 import lombok.Setter;
5 7
 import lombok.ToString;
@@ -15,6 +17,7 @@ import java.util.Date;
15 17
 @Setter
16 18
 @ToString
17 19
 @Table(name = "ms_case_application")
20
+@Data
18 21
 public class MsCaseApplication {
19 22
     /**
20 23
      * id
@@ -145,6 +148,7 @@ public class MsCaseApplication {
145 148
     /**
146 149
      * 创建时间
147 150
      */
151
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "Asia/Shanghai")
148 152
     @Column(name = "create_time")
149 153
     private Date createTime;
150 154
 
@@ -157,6 +161,7 @@ public class MsCaseApplication {
157 161
     /**
158 162
      * 更新时间
159 163
      */
164
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "Asia/Shanghai")
160 165
     @Column(name = "update_time")
161 166
     private Date updateTime;
162 167
 

+ 8
- 2
ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/domain/entity/mscase/MsCaseLogRecord.java Просмотреть файл

@@ -1,11 +1,15 @@
1 1
 package com.ruoyi.wisdomarbitrate.domain.entity.mscase;
2 2
 
3
-import java.util.Date;
4
-import javax.persistence.*;
5 3
 import lombok.Getter;
6 4
 import lombok.Setter;
7 5
 import lombok.ToString;
8 6
 
7
+import javax.persistence.Column;
8
+import javax.persistence.GeneratedValue;
9
+import javax.persistence.Id;
10
+import javax.persistence.Table;
11
+import java.util.Date;
12
+
9 13
 @Getter
10 14
 @Setter
11 15
 @ToString
@@ -67,4 +71,6 @@ public class MsCaseLogRecord {
67 71
      * 备注
68 72
      */
69 73
     private String notes;
74
+    @Column(name = "case_status_name")
75
+    private String caseStatusName;
70 76
 }

+ 2
- 2
ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/domain/vo/mscase/MsCaseApplicationReq.java Просмотреть файл

@@ -22,9 +22,9 @@ public class MsCaseApplicationReq {
22 22
      */
23 23
     private String applicationOrganId;
24 24
     /**
25
-     * 案件状态
25
+     * 案件状态ID
26 26
      */
27
-    private String caseStatusName;
27
+    private Long caseFlowId;
28 28
     /**
29 29
      * 开始时间
30 30
      */

+ 25
- 0
ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/domain/vo/mscase/MsCaseApplicationVO.java Просмотреть файл

@@ -16,10 +16,27 @@ import java.util.List;
16 16
 @AllArgsConstructor
17 17
 @Data
18 18
 public class MsCaseApplicationVO extends MsCaseApplication {
19
+    /**
20
+     * 案件日志id
21
+     */
22
+    private Long caseAppliLogId;
23
+    /**
24
+     * 申请机构名称
25
+     */
26
+    private String applicationOrganName;
27
+    /**
28
+     * 被申请人姓名
29
+     */
30
+    private String respondentName;
31
+
19 32
     /**
20 33
      * 案件相关人员
21 34
      */
22 35
     private MsCaseAffiliate affiliate;
36
+    /**
37
+     * 是否压缩包导入,默认false
38
+     */
39
+    private boolean importFlag=false;
23 40
     /**
24 41
      * 案件附件相关表
25 42
      */
@@ -28,5 +45,13 @@ public class MsCaseApplicationVO extends MsCaseApplication {
28 45
      * 附件类型
29 46
      */
30 47
     private List<Integer> annexTypeList;
48
+    /**
49
+     * 附件类型
50
+     */
51
+    private Integer annexType;
52
+    /**
53
+     * 自定义字段
54
+     */
55
+    private List<MsColumnValueVO> columnValueList;
31 56
 
32 57
 }

+ 19
- 10
ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/mapper/mscase/MsCaseApplicationMapper.java Просмотреть файл

@@ -31,21 +31,24 @@ public interface MsCaseApplicationMapper extends Mapper<MsCaseApplication> {
31 31
     /**
32 32
      * 案件列表查询
33 33
      * @param req
34
-     * @param caseStatusName
34
+     * @param caseStatusNames
35 35
      * @return
36 36
      */
37
-    @Select("<script> select t.* from (select c.id,c.batch_number batchNumber,c.case_num caseNum,c.case_subject_amount caseSubjectAmount," +
37
+    @Select("<script> select t.* from (select c.id,c.case_flow_id caseFlowId,c.batch_number batchNumber,c.case_num caseNum,c.case_subject_amount caseSubjectAmount," +
38 38
             "a.application_organ_name applicationOrganName,a.respondent_name respondentName,c.mediator_name mediatorName," +
39 39
             "c.hear_date hearDate,c.case_status_name caseStatusName,c.create_time createTime from ms_case_application c " +
40 40
             "join ms_case_affiliate a on c.id=a.case_appli_id <where> " +
41
-            "<if test='caseStatusName != null and caseStatusName.size() > 0 '> and  c.case_status_name in" +
42
-            "<foreach item='caseStatus' index='index' collection='caseStatusName' open='(' separator=',' close=')'>" +
41
+            "<if test='caseStatusNames != null and caseStatusNames.size() > 0 '> and  c.case_status_name in" +
42
+            "<foreach item='caseStatus' index='index' collection='caseStatusNames' open='(' separator=',' close=')'>" +
43 43
             "#{caseStatus}" +
44 44
             "</foreach>" +
45 45
             "</if> " +
46 46
             "<if test=\"req.batchNumber != null and req.batchNumber != ''\">" +
47 47
             "    AND c.batch_number = #{req.batchNumber} " +
48 48
             "</if> " +
49
+            "<if test=\"req.caseFlowId != null \">" +
50
+            "    AND c.case_flow_id = #{req.caseFlowId} " +
51
+            "</if> " +
49 52
             "<if test=\"req.caseNum != null and req.caseNum != ''\">" +
50 53
             "    AND c.case_num = #{req.caseNum} " +
51 54
             "</if> " +
@@ -58,20 +61,23 @@ public interface MsCaseApplicationMapper extends Mapper<MsCaseApplication> {
58 61
             "<if test=\"req.endTime != null and req.endTime != ''\">" +
59 62
             "and c.create_time &lt;= #{req.endTime}</if>" +
60 63
             "        </where> " +
61
-            "union  select c.id id,c.batch_number batchNumber,c.case_num caseNum,c.case_subject_amount caseSubjectAmount," +
64
+            "union  select c.id id,c.case_flow_id caseFlowId,c.batch_number batchNumber,c.case_num caseNum,c.case_subject_amount caseSubjectAmount," +
62 65
             "a.application_organ_name applicationOrganName,a.respondent_name respondentName,c.mediator_name mediatorName," +
63 66
             "c.hear_date hearDate,c.case_status_name caseStatusName,c.create_time createTime from ms_case_log_record r " +
64 67
             "join ms_case_application c on r.case_appli_id=c.id and r.case_status_name!=c.case_status_name " +
65 68
             "join ms_case_affiliate a on c.id=a.case_appli_id  <where> r.create_by=#{req.userName}  and c.id not in (" +
66 69
             "select c1.id from  ms_case_application c1 JOIN ms_case_affiliate a1 ON a1.case_appli_id = c1.id" +
67
-            "<if test='caseStatusName != null and caseStatusName.size() > 0 '> and  c.case_status_name in" +
68
-            "<foreach item='caseStatus' index='index' collection='caseStatusName' open='(' separator=',' close=')'>" +
70
+            "<if test='caseStatusNames != null and caseStatusNames.size() > 0 '> and  c.case_status_name in" +
71
+            "<foreach item='caseStatus' index='index' collection='caseStatusNames' open='(' separator=',' close=')'>" +
69 72
             "#{caseStatus}" +
70 73
             "</foreach>" +
71 74
             "</if> " +
72 75
             "<if test=\"req.batchNumber != null and req.batchNumber != ''\">" +
73 76
             "    AND c1.batch_number = #{req.batchNumber} " +
74 77
             "</if> " +
78
+            "<if test=\"req.caseFlowId != null \">" +
79
+            "    AND c1.case_flow_id = #{req.caseFlowId} " +
80
+            "</if> " +
75 81
             "<if test=\"req.caseNum != null and req.caseNum != ''\">" +
76 82
             "    AND c1.case_num = #{req.caseNum} " +
77 83
             "</if> " +
@@ -84,14 +90,17 @@ public interface MsCaseApplicationMapper extends Mapper<MsCaseApplication> {
84 90
             "and c1.create_time &lt;= #{req.endTime}</if>" +
85 91
             "        </where> " +
86 92
             "                    ) " +
87
-            "<if test='caseStatusName != null and caseStatusName.size() > 0 '> and  c.case_status_name in" +
88
-            "<foreach item='caseStatus' index='index' collection='caseStatusName' open='(' separator=',' close=')'>" +
93
+            "<if test='caseStatusNames != null and caseStatusNames.size() > 0 '> and  c.case_status_name in" +
94
+            "<foreach item='caseStatus' index='index' collection='caseStatusNames' open='(' separator=',' close=')'>" +
89 95
             "#{caseStatus}" +
90 96
             "</foreach>" +
91 97
             "</if> " +
92 98
             "<if test=\"req.batchNumber != null and req.batchNumber != ''\">" +
93 99
             "    AND c.batch_number = #{req.batchNumber} " +
94 100
             "</if> " +
101
+            "<if test=\"req.caseFlowId != null \">" +
102
+            "    AND c.case_flow_id = #{req.caseFlowId} " +
103
+            "</if> " +
95 104
             "<if test=\"req.caseNum != null and req.caseNum != ''\">" +
96 105
             "    AND c.case_num = #{req.caseNum} " +
97 106
             "</if> " +
@@ -104,5 +113,5 @@ public interface MsCaseApplicationMapper extends Mapper<MsCaseApplication> {
104 113
             "and c.create_time &lt;= #{req.endTime}</if>" +
105 114
             "         ) t order by  t.createTime desc,t.caseNum desc" +
106 115
             " </script>")
107
-    List<MsCaseApplicationVO> list(@Param("req")MsCaseApplicationReq req, @Param("caseStatusName") List<String> caseStatusName);
116
+    List<MsCaseApplicationVO> list(@Param("req")MsCaseApplicationReq req, @Param("caseStatusNames") List<String> caseStatusNames);
108 117
 }

+ 35
- 0
ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/service/mscase/MsCaseApplicationService.java Просмотреть файл

@@ -1,7 +1,10 @@
1 1
 package com.ruoyi.wisdomarbitrate.service.mscase;
2 2
 
3
+import com.ruoyi.common.core.domain.AjaxResult;
4
+import com.ruoyi.wisdomarbitrate.domain.entity.mscase.MsCaseAffiliate;
3 5
 import com.ruoyi.wisdomarbitrate.domain.vo.mscase.MsCaseApplicationReq;
4 6
 import com.ruoyi.wisdomarbitrate.domain.vo.mscase.MsCaseApplicationVO;
7
+import org.springframework.web.multipart.MultipartFile;
5 8
 
6 9
 import java.util.List;
7 10
 
@@ -20,5 +23,37 @@ public interface MsCaseApplicationService {
20 23
      */
21 24
     List<MsCaseApplicationVO> list(MsCaseApplicationReq req);
22 25
 
26
+    /**
27
+     * 根据id查询案件
28
+     * @param id
29
+     * @return
30
+     */
31
+    MsCaseApplicationVO selectById(Long id);
32
+
33
+    /**
34
+     * 新增案件
35
+     * @param caseApplication
36
+     * @return
37
+     */
23 38
     int insert(MsCaseApplicationVO caseApplication);
39
+    /**
40
+     * 新增申请机构代理人
41
+     * @param affiliate
42
+     */
43
+    void insertAgentUser(MsCaseAffiliate affiliate);
44
+
45
+    /**
46
+     * 修改案件
47
+     * @param caseApplication
48
+     * @return
49
+     */
50
+    AjaxResult update(MsCaseApplicationVO caseApplication);
51
+
52
+    /**
53
+     * 案件压缩包导入
54
+     * @param file 附件
55
+     * @param templateId 模板id
56
+     * @return
57
+     */
58
+    AjaxResult uploadCaseZipFile(MultipartFile file, Long templateId);
24 59
 }

+ 527
- 84
ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/service/mscase/impl/MsCaseApplicationServiceImpl.java Просмотреть файл

@@ -1,38 +1,46 @@
1 1
 package com.ruoyi.wisdomarbitrate.service.mscase.impl;
2 2
 
3
+import cn.hutool.core.bean.BeanUtil;
3 4
 import cn.hutool.core.collection.CollectionUtil;
4 5
 import cn.hutool.core.util.StrUtil;
6
+import com.ruoyi.common.core.domain.AjaxResult;
5 7
 import com.ruoyi.common.core.domain.entity.SysDept;
8
+import com.ruoyi.common.core.domain.entity.SysDictData;
6 9
 import com.ruoyi.common.core.domain.entity.SysRole;
7 10
 import com.ruoyi.common.core.domain.entity.SysUser;
8 11
 import com.ruoyi.common.core.domain.model.LoginUser;
9 12
 import com.ruoyi.common.exception.ServiceException;
10
-import com.ruoyi.common.utils.DateUtils;
11
-import com.ruoyi.common.utils.IdWorkerUtil;
12
-import com.ruoyi.common.utils.SecurityUtils;
13
+import com.ruoyi.common.utils.*;
13 14
 import com.ruoyi.system.domain.entity.flow.MsCaseFlow;
14 15
 import com.ruoyi.system.domain.entity.flow.MsCaseFlowRoleRelated;
15
-import com.ruoyi.system.mapper.SysDeptMapper;
16
-import com.ruoyi.system.mapper.SysRoleMapper;
17
-import com.ruoyi.system.mapper.SysUserMapper;
18
-import com.ruoyi.system.mapper.SysUserRoleMapper;
16
+import com.ruoyi.system.mapper.*;
19 17
 import com.ruoyi.system.mapper.flow.MsCaseFlowMapper;
20 18
 import com.ruoyi.system.mapper.flow.MsCaseFlowRoleRelatedMapper;
19
+import com.ruoyi.wisdomarbitrate.domain.dto.template.FatchRule;
21 20
 import com.ruoyi.wisdomarbitrate.domain.entity.mscase.MsCaseAffiliate;
21
+import com.ruoyi.wisdomarbitrate.domain.entity.mscase.MsCaseApplication;
22 22
 import com.ruoyi.wisdomarbitrate.domain.entity.mscase.MsCaseAttach;
23 23
 import com.ruoyi.wisdomarbitrate.domain.vo.mscase.MsCaseApplicationReq;
24 24
 import com.ruoyi.wisdomarbitrate.domain.vo.mscase.MsCaseApplicationVO;
25
+import com.ruoyi.wisdomarbitrate.domain.vo.mscase.MsColumnValueVO;
25 26
 import com.ruoyi.wisdomarbitrate.mapper.mscase.*;
27
+import com.ruoyi.wisdomarbitrate.mapper.template.FatchRuleMapper;
26 28
 import com.ruoyi.wisdomarbitrate.service.mscase.MsCaseApplicationService;
29
+import com.ruoyi.wisdomarbitrate.utils.CaseLogUtils;
30
+import com.ruoyi.wisdomarbitrate.utils.OCRUtils;
31
+import com.ruoyi.wisdomarbitrate.utils.UnZipFileUtils;
32
+import org.apache.pdfbox.pdmodel.PDDocument;
27 33
 import org.springframework.beans.factory.annotation.Autowired;
28 34
 import org.springframework.stereotype.Service;
29 35
 import org.springframework.transaction.annotation.Transactional;
36
+import org.springframework.web.multipart.MultipartFile;
30 37
 import tk.mybatis.mapper.entity.Example;
31 38
 
39
+import java.io.*;
32 40
 import java.math.BigDecimal;
33
-import java.util.ArrayList;
34
-import java.util.List;
35
-import java.util.Map;
41
+import java.math.RoundingMode;
42
+import java.text.SimpleDateFormat;
43
+import java.util.*;
36 44
 import java.util.stream.Collectors;
37 45
 
38 46
 import static com.ruoyi.common.utils.SecurityUtils.getUsername;
@@ -45,7 +53,7 @@ import static com.ruoyi.common.utils.SecurityUtils.getUsername;
45 53
  * @Created wangqiong
46 54
  */
47 55
 @Service
48
-public class MsCaseApplicationServiceImpl  implements MsCaseApplicationService {
56
+public class MsCaseApplicationServiceImpl implements MsCaseApplicationService {
49 57
     @Autowired
50 58
     MsCaseApplicationMapper msCaseApplicationMapper;
51 59
     @Autowired
@@ -59,6 +67,10 @@ public class MsCaseApplicationServiceImpl  implements MsCaseApplicationService {
59 67
     @Autowired
60 68
     MsCaseAttachLogMapper msCaseAttachLogMapper;
61 69
     @Autowired
70
+    MsColumnValueMapper columnValueMapper;
71
+    @Autowired
72
+    MsColumnValueLogMapper columnValueLogMapper;
73
+    @Autowired
62 74
     MsCaseFlowMapper caseFlowMapper;
63 75
     @Autowired
64 76
     MsCaseFlowRoleRelatedMapper caseFlowRoleRelatedMapper;
@@ -70,78 +82,109 @@ public class MsCaseApplicationServiceImpl  implements MsCaseApplicationService {
70 82
     SysUserMapper userMapper;
71 83
     @Autowired
72 84
     SysUserRoleMapper userRoleMapper;
85
+    @Autowired
86
+    FatchRuleMapper fatchRuleMapper;
87
+    @Autowired
88
+    SysDictDataMapper dictDataMapper;
89
+    // 案件基本字段
90
+    public static final List<String> CASE_BASE_COLUMN = Arrays.asList("caseSubjectAmount", "arbitratClaims", "facts", "requestRule");
91
+    public static final SimpleDateFormat yyyymmddFormat = new SimpleDateFormat("yyyy-MM-dd");
73 92
 
74 93
     /**
75 94
      * 案件列表查询
95
+     *
76 96
      * @param req
77 97
      * @return
78 98
      */
79 99
     @Override
80 100
     public List<MsCaseApplicationVO> list(MsCaseApplicationReq req) {
101
+        // admin查询所有案件
102
+        if (StrUtil.equals(SecurityUtils.getUsername(), "admin")) {
103
+            return msCaseApplicationMapper.list(req, null);
104
+        }
81 105
         // 根据用户查询角色
82 106
         LoginUser loginUser = SecurityUtils.getLoginUser();
83 107
         List<SysRole> roles = loginUser.getUser().getRoles();
84
-        if(CollectionUtil.isEmpty(roles)){
108
+        if (CollectionUtil.isEmpty(roles)) {
85 109
             throw new ServiceException("该用户未指定角色");
86 110
         }
87 111
         req.setUserName(SecurityUtils.getUsername());
88 112
         // 根据角色查询关联的案件状态
89 113
         Example example = new Example(MsCaseFlowRoleRelated.class);
90
-        example.createCriteria().andIn("roleid",roles.stream().map(SysRole::getRoleId).collect(Collectors.toList()));
91
-        List<MsCaseFlowRoleRelated> caseFlowRoleRelatedList= caseFlowRoleRelatedMapper.selectByExample(example);
92
-        if(CollectionUtil.isEmpty(caseFlowRoleRelatedList)){
114
+        example.createCriteria().andIn("roleid", roles.stream().map(SysRole::getRoleId).collect(Collectors.toList()));
115
+        List<MsCaseFlowRoleRelated> caseFlowRoleRelatedList = caseFlowRoleRelatedMapper.selectByExample(example);
116
+        if (CollectionUtil.isEmpty(caseFlowRoleRelatedList)) {
93 117
             throw new ServiceException("该角色为绑定案件流程");
94 118
         }
95 119
         Example flowExample = new Example(MsCaseFlow.class);
96
-        flowExample.createCriteria().andIn("id",caseFlowRoleRelatedList.stream().map(MsCaseFlowRoleRelated::getFlowId).collect(Collectors.toList()));
120
+        flowExample.createCriteria().andIn("id", caseFlowRoleRelatedList.stream().map(MsCaseFlowRoleRelated::getFlowId).collect(Collectors.toList()));
97 121
         List<MsCaseFlow> caseFlows = caseFlowMapper.selectByExample(flowExample);
98
-        if(CollectionUtil.isEmpty(caseFlows)){
122
+        if (CollectionUtil.isEmpty(caseFlows)) {
99 123
             throw new ServiceException("该角色为绑定案件流程");
100 124
         }
101 125
         // 查询案件列表
102
-       List<MsCaseApplicationVO> caseApplicationList=msCaseApplicationMapper.list(req,caseFlows.stream().map(MsCaseFlow::getCaseStatusName).collect(Collectors.toList()));
126
+        List<MsCaseApplicationVO> caseApplicationList = msCaseApplicationMapper.list(req, caseFlows.stream().map(MsCaseFlow::getCaseStatusName).collect(Collectors.toList()));
103 127
         return caseApplicationList;
104 128
     }
105 129
 
130
+    @Override
131
+    public MsCaseApplicationVO selectById(Long id) {
132
+        MsCaseApplicationVO vo = new MsCaseApplicationVO();
133
+        MsCaseApplication caseApplication = msCaseApplicationMapper.selectByPrimaryKey(id);
134
+        BeanUtil.copyProperties(caseApplication, vo);
135
+        // 查询案件相关人员
136
+        MsCaseAffiliate caseAffiliate = msCaseAffiliateMapper.selectByPrimaryKey(id);
137
+        vo.setAffiliate(caseAffiliate);
138
+        // 查询附件
139
+        List<MsCaseAttach> caseAttachList = msCaseAttachMapper.queryAnnexPathByCaseId(id);
140
+        vo.setCaseAttachList(caseAttachList);
141
+        // 自定义字段
142
+        List<MsColumnValueVO> columnValueVOS = columnValueMapper.listByCaseId(id);
143
+        vo.setColumnValueList(columnValueVOS);
144
+        return vo;
145
+    }
146
+
106 147
     /**
107 148
      * 新增案件
149
+     *
108 150
      * @param caseApplication
109 151
      * @return
110 152
      */
111 153
     @Transactional
112 154
     @Override
113 155
     public int insert(MsCaseApplicationVO caseApplication) {
114
-        caseApplication.setId(IdWorkerUtil.getId());
156
+        if (caseApplication.getId() == null) {
157
+            caseApplication.setId(IdWorkerUtil.getId());
158
+        }
115 159
         // 根据用户查询角色
116 160
         LoginUser loginUser = SecurityUtils.getLoginUser();
117 161
         List<SysRole> roles = loginUser.getUser().getRoles();
118
-        if(CollectionUtil.isEmpty(roles)){
162
+        if (CollectionUtil.isEmpty(roles)) {
119 163
             throw new ServiceException("该用户未指定角色");
120 164
         }
121 165
         // 根据角色查询关联的案件状态
122 166
         Example example = new Example(MsCaseFlowRoleRelated.class);
123
-        example.createCriteria().andIn("roleid",roles.stream().map(SysRole::getRoleId).collect(Collectors.toList()));
124
-        List<MsCaseFlowRoleRelated> caseFlowRoleRelatedList= caseFlowRoleRelatedMapper.selectByExample(example);
125
-        if(CollectionUtil.isEmpty(caseFlowRoleRelatedList)){
167
+        example.createCriteria().andIn("roleid", roles.stream().map(SysRole::getRoleId).collect(Collectors.toList()));
168
+        List<MsCaseFlowRoleRelated> caseFlowRoleRelatedList = caseFlowRoleRelatedMapper.selectByExample(example);
169
+        if (CollectionUtil.isEmpty(caseFlowRoleRelatedList)) {
126 170
             throw new ServiceException("该角色为绑定案件流程");
127 171
         }
128 172
         Example flowExample = new Example(MsCaseFlow.class);
129 173
         flowExample.setOrderByClause("sort asc");
130
-        flowExample.createCriteria().andIn("id",caseFlowRoleRelatedList.stream().map(MsCaseFlowRoleRelated::getFlowId).collect(Collectors.toList()));
174
+        flowExample.createCriteria().andIn("id", caseFlowRoleRelatedList.stream().map(MsCaseFlowRoleRelated::getFlowId).collect(Collectors.toList()));
131 175
         List<MsCaseFlow> caseFlows = caseFlowMapper.selectByExample(flowExample);
132
-        if(CollectionUtil.isNotEmpty(caseFlows)){
133
-            caseApplication.setCaseStatusName(caseFlows.get(0).getCaseStatusName());
134
-            caseApplication.setCaseFlowId(caseFlows.get(0).getId());
176
+        MsCaseFlow caseFlow = caseFlows.get(0);
177
+        if (CollectionUtil.isNotEmpty(caseFlows)) {
178
+            caseApplication.setCaseStatusName(caseFlow.getCaseStatusName());
179
+            caseApplication.setCaseFlowId(caseFlow.getId());
135 180
         }
136
-
181
+        caseApplication.setCreateTime(new Date());
137 182
         // 计算仲裁费用
138
-        if( caseApplication.getCaseSubjectAmount()!=null) {
139
-            BigDecimal feeRate = new BigDecimal("0.01");
140
-            BigDecimal feePayable = caseApplication.getCaseSubjectAmount().multiply(feeRate).setScale(2, BigDecimal.ROUND_HALF_UP);
141
-            caseApplication.setFeePayable(feePayable);
142
-        }
183
+        setFeePayableMethod(caseApplication);
143 184
         // 设置批号
144
-        caseApplication.setBatchNumber(getBatchNumber());
185
+        if (StrUtil.isEmpty(caseApplication.getBatchNumber())) {
186
+            caseApplication.setBatchNumber(getBatchNumber());
187
+        }
145 188
         // 设置编码
146 189
         caseApplication.setCaseNum(getCaseNum());
147 190
         caseApplication.setCreateBy(SecurityUtils.getUsername());
@@ -149,80 +192,478 @@ public class MsCaseApplicationServiceImpl  implements MsCaseApplicationService {
149 192
         caseApplication.setVersion(1);
150 193
         MsCaseAffiliate affiliate = caseApplication.getAffiliate();
151 194
         // 保存案件基本信息
152
-        if(msCaseApplicationMapper.insertSelective(caseApplication)>0){
195
+        if (msCaseApplicationMapper.insertSelective(caseApplication) > 0) {
153 196
             List<MsCaseAttach> caseAttachList = caseApplication.getCaseAttachList();
154 197
             // 保存案件相关人员
155
-            if(affiliate !=null) {
198
+            if (affiliate != null) {
156 199
                 // 设置申请人
157
-                if( StrUtil.isNotEmpty(affiliate.getApplicationOrganName())){
200
+                if (StrUtil.isNotEmpty(affiliate.getApplicationOrganName())) {
158 201
                     // 组装申请机构
159 202
                     insertDept(affiliate);
160
-                    // 查询申请人角色id
161
-                    Long roleId = roleMapper.selectRoleIdByName("申请人");
162
-                    // 根据代理人手机号去用户表查询,有修改,么有新增
163
-                    SysUser agentUser = userMapper.selectUserByPhone(affiliate.getContactTelphoneAgent());
164
-                    // 代理人为空,新增代理人
165
-                    if(agentUser==null){
166
-                        agentUser = new SysUser();
167
-                        agentUser.setUserName(affiliate.getContactTelphoneAgent());
168
-                        agentUser.setNickName(affiliate.getNameAgent());
169
-                        agentUser.setPhonenumber(affiliate.getContactTelphoneAgent());
170
-                        agentUser.setPassword(SecurityUtils.encryptPassword("abc123456"));
171
-                        agentUser.setDeptId(Long.valueOf(affiliate.getApplicationOrganId()));
172
-                        userMapper.insertUser(agentUser);
173
-                        userRoleMapper.insertUserRole(agentUser.getUserId(), roleId);
174
-                    }else if(null != agentUser.getDeptId() && !String.valueOf(agentUser.getDeptId()).equals(affiliate.getApplicationOrganId())){
175
-                        if (null != agentUser.getDept() && StrUtil.isNotEmpty(agentUser.getDept().getDeptName())) {
176
-                            throw new ServiceException( "该申请代理人已在【" + agentUser.getDept().getDeptName() + "】申请机构下存在,请检查填写信息是否正确");
177
-                        } else {
178
-                            throw new ServiceException("该申请代理人已存在,与申请机构不匹配,请检查填写信息是否正确");
179
-                        }
180
-                    }else if (null != agentUser.getDeptId() && String.valueOf(agentUser.getDeptId()).equals(affiliate.getApplicationOrganId())) {
181
-                        // 同步用户表和案件关联人表的手机号和名称
182
-                        affiliate.setContactTelphoneAgent(StrUtil.isNotEmpty(agentUser.getPhonenumber())?agentUser.getPhonenumber():affiliate.getContactTelphoneAgent());
183
-                        affiliate.setNameAgent(agentUser.getNickName());
184
-                        affiliate.setAgentEmail(StrUtil.isNotEmpty(agentUser.getEmail())?agentUser.getEmail():affiliate.getAgentEmail());
185
-                        List<Long> longList = new ArrayList<>();
186
-                        // 新增角色为申请人
187
-                        if (CollectionUtil.isNotEmpty(agentUser.getRoles())) {
188
-                            longList = agentUser.getRoles().stream().map(SysRole::getRoleId).collect(Collectors.toList());
189
-                            if (!longList.contains(roleId)) {
190
-                                userRoleMapper.insertUserRole(agentUser.getUserId(), roleId);
191
-                            }
192
-                        } else {
193
-                            userRoleMapper.insertUserRole(agentUser.getUserId(), roleId);
194
-                        }
203
+                    // 新增申请机构代理人
204
+                    insertAgentUser(affiliate);
205
+                }
206
+                // 压缩包导入,则根据身份证号获取性别和出生日期
207
+                String identityNum = affiliate.getRespondentIdentityNum();
208
+                if (caseApplication.isImportFlag() && StrUtil.isNotEmpty(identityNum)) {
195 209
 
210
+                    identityNum = identityNum.replace("\n", "");
211
+                    Map<String, String> identityNumMap = IdCardUtils.getBirAgeSex(identityNum);
212
+                    String birthday = identityNumMap.get("birthday");
213
+                    if (StrUtil.isNotEmpty(birthday)) {
214
+                        Date birthdayDate = null;
215
+                        try {
216
+                            birthdayDate = yyyymmddFormat.parse(birthday);
217
+                        } catch (Exception e) {
218
+                            e.printStackTrace();
219
+                        }
220
+                        affiliate.setRespondentBirth(birthdayDate);
196 221
                     }
222
+                    //从身份证抓取性别
223
+                    affiliate.setRespondentSex(identityNumMap.get("sexCode"));
224
+                }
225
+                if (StrUtil.isNotEmpty(affiliate.getAgentEmail())) {
226
+                    affiliate.setAgentEmail(affiliate.getAgentEmail().replace("\n", "").replaceAll("\\s", ""));
227
+                }
228
+                if (StrUtil.isNotEmpty(affiliate.getRespondentEmail())) {
229
+                    affiliate.setRespondentEmail(affiliate.getRespondentEmail().replace("\n", "").replaceAll("\\s", ""));
197 230
                 }
198 231
                 affiliate.setCaseAppliId(caseApplication.getId());
199 232
                 msCaseAffiliateMapper.insert(affiliate);
200 233
             }
201 234
             // 保存案件附件
202
-            if(CollectionUtil.isNotEmpty(caseAttachList)){
235
+
236
+            if (CollectionUtil.isNotEmpty(caseAttachList) && !caseApplication.isImportFlag()) {
203 237
                 for (MsCaseAttach caseAttach : caseAttachList) {
204 238
                     caseAttach.setCaseAppliId(caseApplication.getId());
205 239
                     // 修改案件附件
206 240
                     msCaseAttachMapper.updateCaseAttach(caseAttach);
207 241
                 }
208
-//                for(MsCaseAttach caseAttach:caseAttachList){
209
-//                    caseAttach.setCaseAppliId(caseApplication.getId());
210
-//
211
-//                }
212
-//                msCaseAttachMapper.batchSave(caseAttachList);
213 242
             }
243
+            List<MsColumnValueVO> columnValueList = caseApplication.getColumnValueList();
244
+            if (CollectionUtil.isNotEmpty(columnValueList)) {
245
+                for (MsColumnValueVO msColumnValueVO : columnValueList) {
246
+                    msColumnValueVO.setCaseId(caseApplication.getId());
247
+                }
248
+                columnValueMapper.batchSave(columnValueList);
249
+            }
250
+            CaseLogUtils.insertCaseLog(caseApplication.getId(), caseFlow.getNodeId(), caseFlow.getCaseStatusName(), "");
214 251
             return 1;
215 252
         }
216 253
 
217 254
         return 0;
218 255
     }
219 256
 
257
+    /**
258
+     * 计算仲裁费用
259
+     *
260
+     * @param caseApplication
261
+     */
262
+    private void setFeePayableMethod(MsCaseApplicationVO caseApplication) {
263
+        if (caseApplication.getCaseSubjectAmount() != null) {
264
+            BigDecimal feeRate = new BigDecimal("0.01");
265
+            BigDecimal feePayable = caseApplication.getCaseSubjectAmount().multiply(feeRate).setScale(2, RoundingMode.HALF_UP);
266
+            caseApplication.setFeePayable(feePayable);
267
+        }
268
+    }
269
+
270
+    /**
271
+     * 修改案件
272
+     *
273
+     * @param caseApplication
274
+     * @return
275
+     */
276
+    @Transactional
277
+    @Override
278
+    public AjaxResult update(MsCaseApplicationVO caseApplication) {
279
+        // 计算仲裁费用
280
+        setFeePayableMethod(caseApplication);
281
+        caseApplication.setUpdateBy(SecurityUtils.getUsername());
282
+        caseApplication.setUpdateTime(new Date());
283
+        // 为null则不更新
284
+        msCaseApplicationMapper.updateByPrimaryKeySelective(caseApplication);
285
+        MsCaseAffiliate affiliate = caseApplication.getAffiliate();
286
+        if (affiliate != null) {
287
+            affiliate.setCaseAppliId(caseApplication.getId());
288
+            // 设置申请人
289
+            if (StrUtil.isNotEmpty(affiliate.getApplicationOrganName())) {
290
+                // 组装申请机构
291
+                insertDept(affiliate);
292
+                // 新增申请机构代理人
293
+                insertAgentUser(affiliate);
294
+            }
295
+            msCaseAffiliateMapper.updateByPrimaryKeySelective(affiliate);
296
+        }
297
+        if (CollectionUtil.isNotEmpty(caseApplication.getCaseAttachList())) {
298
+            for (MsCaseAttach caseAttach : caseApplication.getCaseAttachList()) {
299
+                caseAttach.setCaseAppliId(caseApplication.getId());
300
+                msCaseAttachMapper.updateCaseAttach(caseAttach);
301
+            }
302
+        }
303
+        if (CollectionUtil.isNotEmpty(caseApplication.getColumnValueList())) {
304
+            columnValueMapper.batchUpdate(caseApplication.getColumnValueList());
305
+        }
306
+        return AjaxResult.success("修改成功");
307
+    }
308
+
309
+    /**
310
+     * 压缩包导入
311
+     *
312
+     * @param file       附件
313
+     * @param templateId 模板id
314
+     * @return
315
+     */
316
+    @Transactional
317
+    @Override
318
+    public AjaxResult uploadCaseZipFile(MultipartFile file, Long templateId) {
319
+        UUID uuid = UUID.randomUUID();
320
+        // todo 压缩包解压路径
321
+        String targetPath = "/home/ruoyi/uploadPath/upload/unzipFile/" + uuid + "/";
322
+//        String targetPath = "D:/home/ruoyi/uploadPath/upload/unzipFile/"+uuid+ "/";
323
+        File zipFile = null;
324
+        InputStream ins = null;
325
+        try {
326
+            ins = file.getInputStream();
327
+            //上传的压缩包保存的路径
328
+            // todo
329
+            String savePath = "/home/ruoyi/uploadPath/upload/zipFile/";
330
+//           String savePath = "D:/home/ruoyi/uploadPath/upload/zipFile/";
331
+            String saveName = uuid + "_" + file.getOriginalFilename();
332
+            zipFile = new File(savePath + saveName);
333
+            inputChangeToFile(ins, zipFile);
334
+        } catch (IOException e) {
335
+            e.printStackTrace();
336
+        }
337
+        if (zipFile == null) {
338
+            return AjaxResult.error("压缩包上传失败");
339
+        }
340
+        //解压缩上传的压缩包
341
+        boolean unzipSuccess = UnZipFileUtils.unZipFile(zipFile, targetPath);
342
+        if (!unzipSuccess) {
343
+            // 解压失败
344
+            return AjaxResult.error("解压失败");
345
+        }
346
+        // 查询抓取规则
347
+        List<FatchRule> fatchRuleList = fatchRuleMapper.listByTemplateId(templateId);
348
+        if (CollectionUtil.isEmpty(fatchRuleList)) {
349
+            return AjaxResult.error("未设置抓取规则");
350
+        }
351
+        Map<Integer, List<FatchRule>> defaultRuleMap = fatchRuleList.stream().collect(Collectors.groupingBy(FatchRule::getIsDefault));
352
+
353
+        // 判断解压后的文件夹是否存在
354
+        File directory = new File(targetPath);
355
+        if (!directory.exists()) {
356
+            return AjaxResult.error("文件不存在");
357
+        }
358
+        if (!directory.isDirectory() || directory.listFiles() == null) {
359
+            return AjaxResult.error("未找到文件夹");
360
+        }
361
+        File[] files = directory.listFiles();
362
+        if (files == null) {
363
+            return AjaxResult.error("压缩包格式不正确");
364
+        }
365
+        // 抓取规则,0-内置字段,1-自定义字段
366
+        Map<String, List<FatchRule>> fatchRuleMap = fatchRuleList.stream().collect(Collectors.groupingBy(FatchRule::getFileName));
367
+        // 在系统表中查询案件内置字段
368
+        SysDictData sysDictData = new SysDictData();
369
+        sysDictData.setDictType("case_built_type");
370
+        List<SysDictData> dictDataList = dictDataMapper.selectDictDataList(sysDictData);
371
+        if (CollectionUtil.isEmpty(dictDataList)) {
372
+            return AjaxResult.error("未找到案件内置字段");
373
+        }
374
+        //查询批次号
375
+        String batchNumber = getBatchNumber();
376
+        // 抓取内容
377
+        Map<String, String> fatchMap = new HashMap<>();
378
+        for (File outFile : files) {
379
+            if (!outFile.isDirectory() || outFile.listFiles() == null) {
380
+                continue;
381
+            }
382
+            //   一个infile对应一个案件
383
+            for (File inFile : outFile.listFiles()) {
384
+                // 所有的文件,fileMap<fileName,filePath>
385
+                Map<String, String> fileMap = findFile(inFile);
386
+                if (fileMap != null && !fileMap.isEmpty()) {
387
+                    // 根据抓取规则设置字段值
388
+                    for (Map.Entry<String, List<FatchRule>> entry : fatchRuleMap.entrySet()) {
389
+                        getFatchContent(fileMap, entry.getKey(), fatchMap, entry.getValue());
390
+                    }
391
+                    if (fatchMap.size() > 0) {
392
+                        // 组装案件信息
393
+                        MsCaseApplicationVO caseApplicationVO = new MsCaseApplicationVO();
394
+                        MsCaseApplication caseApplication = new MsCaseApplication();
395
+                        MsCaseAffiliate affiliate = new MsCaseAffiliate();
396
+                        List<MsCaseAttach> attachList = new ArrayList<>();
397
+                        List<MsColumnValueVO> columnValueList = new ArrayList<>();
398
+                        caseApplication.setId(IdWorkerUtil.getId());
399
+                        caseApplication.setTemplateId(templateId);
400
+                        caseApplication.setBatchNumber(batchNumber);
401
+                        // 组装案件内置字段
402
+                        for (SysDictData dictData : dictDataList) {
403
+                            // 主表字段
404
+                            if (CASE_BASE_COLUMN.contains(dictData.getDictValue())) {
405
+                                ObjectFieldUtils.setValue(caseApplication, dictData.getDictValue(), fatchMap.get(dictData.getDictLabel()));
406
+                            } else {
407
+                                // 相关人员字段
408
+                                ObjectFieldUtils.setValue(affiliate, dictData.getDictValue(), fatchMap.get(dictData.getDictLabel()));
409
+                            }
410
+                        }
411
+                        // 自定义字段,组装columnValue表
412
+                        if (defaultRuleMap.size() > 0 && defaultRuleMap.containsKey(1)) {
413
+                            List<FatchRule> columnRules = defaultRuleMap.get(1);
414
+                            columnRules.forEach(columnRule -> {
415
+                                MsColumnValueVO columnValue = new MsColumnValueVO();
416
+                                columnValue.setColumn(columnRule.getColumn());
417
+                                columnValue.setName(columnRule.getColumnName());
418
+                                columnValue.setValue(fatchMap.get(columnRule.getColumnName()));
419
+                                columnValue.setIsDefault(1);
420
+                                columnValue.setCaseId(caseApplication.getId());
421
+                                columnValueList.add(columnValue);
422
+                            });
423
+                        }
424
+                        BeanUtil.copyProperties(caseApplication, caseApplicationVO);
425
+                        // 组装附件
426
+                        buildAttach(fileMap, caseApplicationVO, attachList);
427
+                        caseApplicationVO.setAffiliate(affiliate);
428
+                        caseApplicationVO.setCaseAttachList(attachList);
429
+                        caseApplicationVO.setColumnValueList(columnValueList);
430
+                        caseApplicationVO.setImportFlag(true);
431
+                        insert(caseApplicationVO);
432
+
433
+                    }
434
+                }
435
+            }
436
+
437
+        }
438
+        return AjaxResult.success();
439
+    }
440
+
441
+    /**
442
+     * 组装附件
443
+     *
444
+     * @param fileMap
445
+     * @param caseApplication
446
+     * @param attachList
447
+     */
448
+    private void buildAttach(Map<String, String> fileMap, MsCaseApplicationVO caseApplication, List<MsCaseAttach> attachList) {
449
+        for (Map.Entry<String, String> entry : fileMap.entrySet()) {
450
+            String fileUrl = entry.getValue();
451
+            if (StrUtil.isEmpty(fileUrl)) {
452
+                continue;
453
+            }
454
+            // 上传
455
+            //  String filePath = RuoYiConfig.getUploadPath();
456
+            MsCaseAttach caseAttach = new MsCaseAttach();
457
+            caseAttach.setCaseAppliId(caseApplication.getId());
458
+            caseAttach.setAnnexPath(entry.getValue());
459
+            caseAttach.setAnnexName(entry.getKey());
460
+            // todo
461
+//                                    if (StrUtil.isNotEmpty(fileUrl)) {
462
+//                                        String fileName = fileUrl.replace(filePath, "/profile/upload");
463
+//                                        caseAttach.setAnnexName(entry.getKey());
464
+//                                    }
465
+            // 申请人提供的证据材料
466
+            caseAttach.setAnnexType(2);
467
+            attachList.add(caseAttach);
468
+            if (fileUrl.contains("仲裁申请书")) {
469
+                MsCaseAttach applyFile = new MsCaseAttach();
470
+                BeanUtil.copyProperties(caseAttach, applyFile);
471
+                applyFile.setAnnexType(1);
472
+                attachList.add(applyFile);
473
+            }
474
+
475
+        }
476
+    }
477
+
478
+    /**
479
+     * 获取抓取内容
480
+     *
481
+     * @param andConvertPDF 文件路径map
482
+     * @param mapKey        文件名
483
+     * @param map           抓取内容map
484
+     * @param fatchRules    抓取规则
485
+     */
486
+    private void getFatchContent(Map<String, String> andConvertPDF, String mapKey, Map<String, String> map, List<FatchRule> fatchRules) {
487
+        String fileURL = null;
488
+        for (Map.Entry<String, String> entry : andConvertPDF.entrySet()) {
489
+            if (entry.getKey().contains(mapKey)) {
490
+                fileURL = entry.getValue();
491
+            }
492
+        }
493
+        if (StrUtil.isEmpty(fileURL)) {
494
+            return;
495
+        }
496
+        if (fileURL.endsWith("txt")) {
497
+            String readerFile = ReadFileUtils.readerTxtFile(fileURL);
498
+            OCRUtils.fatchRuleGetContent(readerFile, fatchRules, map);
499
+        } else if (fileURL.endsWith("doc") || fileURL.endsWith("docx")) {
500
+            // doc,docx,text识别内容
501
+            String readerFile = null;
502
+            try {
503
+                readerFile = ReadFileUtils.readWord(fileURL);
504
+            } catch (Exception e) {
505
+                e.printStackTrace();
506
+            }
507
+            OCRUtils.fatchRuleGetContent(readerFile, fatchRules, map);
508
+
509
+        } else if (fileURL.endsWith("pdf")) {
510
+            //获取文件的页数
511
+            int fileNumPage = getFileNumPage(fileURL);
512
+            //文件转成base64
513
+            String base64 = OCRUtils.pdfConvertBase64(fileURL);
514
+            if (base64 == null) {
515
+                throw new ServiceException("pdf转base64失败");
516
+                //  return false;
517
+            }
518
+            StringBuilder ocrText = new StringBuilder(); // 创建一个StringBuilder对象
519
+            for (int i = 1; i <= fileNumPage; i++) {
520
+                //对接腾讯云接口.识别里面的数据
521
+                String text = OCRUtils.pdfIdentifyText(base64, i, fatchRules);
522
+                ocrText.append(text); // 拼接当前的字符串
523
+
524
+
525
+            }
526
+            // 根据抓取规则截取内容
527
+            OCRUtils.fatchRuleGetContent(ocrText.toString(), fatchRules, map);
528
+        }
529
+
530
+
531
+    }
532
+
533
+    /**
534
+     * 获取pdf页数
535
+     *
536
+     * @param pdfUrl
537
+     * @return
538
+     */
539
+    private static int getFileNumPage(String pdfUrl) {
540
+        File pdfFile = new File(pdfUrl);
541
+        int pageCount = 0;
542
+        try (PDDocument document = PDDocument.load(pdfFile)) {
543
+            pageCount = document.getNumberOfPages();
544
+        } catch (IOException e) {
545
+            e.printStackTrace();
546
+        }
547
+        return pageCount;
548
+    }
549
+
550
+    /**
551
+     * 查找文件
552
+     *
553
+     * @param directory
554
+     * @param
555
+     * @return
556
+     */
557
+    private Map<String, String> findFile(File directory) {
558
+        Map<String, String> filePathMap = new HashMap<>();
559
+        if (directory.isFile()) {
560
+            String path = "";
561
+            // 如果传入的参数是一个文件
562
+            path = directory.getAbsolutePath();
563
+            filePathMap.put(directory.getName(), path);
564
+
565
+        } else if (directory.isDirectory()) {
566
+            searchFile(directory, filePathMap);
567
+        } else {
568
+            return null;
569
+        }
570
+        return filePathMap;
571
+    }
572
+
573
+    /**
574
+     * 递归查找文件夹
575
+     *
576
+     * @param directory
577
+     * @param filePathMap
578
+     */
579
+    public static void searchFile(File directory, Map<String, String> filePathMap) {
580
+        File[] files = directory.listFiles();
581
+
582
+        if (files != null) {
583
+            for (File file : files) {
584
+                if (file.getName().contains("zip") || file.getName().contains("rar")) {
585
+                    continue;
586
+                }
587
+                if (file.isFile()) {
588
+
589
+                    filePathMap.put(file.getName(), file.getAbsolutePath());
590
+                } else if (file.isDirectory()) {
591
+                    // 如果是目录,递归查找
592
+                    searchFile(file, filePathMap);
593
+                }
594
+            }
595
+        }
596
+    }
597
+
598
+    public void inputChangeToFile(InputStream instream, File file) {
599
+        try {
600
+            OutputStream outStr = new FileOutputStream(file);
601
+            int bytesRead = 0;
602
+            byte[] buffer = new byte[8192];
603
+            while ((bytesRead = instream.read(buffer, 0, 1024)) != -1) {
604
+                outStr.write(buffer, 0, bytesRead);
605
+            }
606
+            outStr.flush();
607
+            outStr.close();
608
+            instream.close();
609
+        } catch (Exception e) {
610
+            e.printStackTrace();
611
+        }
612
+    }
613
+
614
+    /**
615
+     * 新增申请机构代理人
616
+     *
617
+     * @param affiliate
618
+     */
619
+    @Transactional
620
+    public void insertAgentUser(MsCaseAffiliate affiliate) {
621
+        // 查询申请人角色id
622
+        Long roleId = roleMapper.selectRoleIdByName("申请人");
623
+        // 根据代理人手机号去用户表查询,有修改,么有新增
624
+        SysUser agentUser = userMapper.selectUserByPhone(affiliate.getContactTelphoneAgent());
625
+        // 代理人为空,新增代理人
626
+        if (agentUser == null) {
627
+            agentUser = new SysUser();
628
+            agentUser.setUserName(affiliate.getContactTelphoneAgent());
629
+            agentUser.setNickName(affiliate.getNameAgent());
630
+            agentUser.setPhonenumber(affiliate.getContactTelphoneAgent());
631
+            agentUser.setPassword(SecurityUtils.encryptPassword("abc123456"));
632
+            agentUser.setDeptId(Long.valueOf(affiliate.getApplicationOrganId()));
633
+            userMapper.insertUser(agentUser);
634
+            userRoleMapper.insertUserRole(agentUser.getUserId(), roleId);
635
+        } else if (null != agentUser.getDeptId() && !String.valueOf(agentUser.getDeptId()).equals(affiliate.getApplicationOrganId())) {
636
+            if (null != agentUser.getDept() && StrUtil.isNotEmpty(agentUser.getDept().getDeptName())) {
637
+                throw new ServiceException("该申请代理人已在【" + agentUser.getDept().getDeptName() + "】申请机构下存在,请检查填写信息是否正确");
638
+            } else {
639
+                throw new ServiceException("该申请代理人已存在,与申请机构不匹配,请检查填写信息是否正确");
640
+            }
641
+        } else if (null != agentUser.getDeptId() && String.valueOf(agentUser.getDeptId()).equals(affiliate.getApplicationOrganId())) {
642
+            // 同步用户表和案件关联人表的手机号和名称
643
+            affiliate.setContactTelphoneAgent(StrUtil.isNotEmpty(agentUser.getPhonenumber()) ? agentUser.getPhonenumber() : affiliate.getContactTelphoneAgent());
644
+            affiliate.setNameAgent(agentUser.getNickName());
645
+            affiliate.setAgentEmail(StrUtil.isNotEmpty(agentUser.getEmail()) ? agentUser.getEmail() : affiliate.getAgentEmail());
646
+            List<Long> longList = new ArrayList<>();
647
+            // 新增角色为申请人
648
+            if (CollectionUtil.isNotEmpty(agentUser.getRoles())) {
649
+                longList = agentUser.getRoles().stream().map(SysRole::getRoleId).collect(Collectors.toList());
650
+                if (!longList.contains(roleId)) {
651
+                    userRoleMapper.insertUserRole(agentUser.getUserId(), roleId);
652
+                }
653
+            } else {
654
+                userRoleMapper.insertUserRole(agentUser.getUserId(), roleId);
655
+            }
656
+
657
+        }
658
+    }
659
+
220 660
     /**
221 661
      * 新增部门
662
+     *
222 663
      * @param affiliate
223 664
      */
224 665
     @Transactional
225
-     void insertDept(MsCaseAffiliate affiliate) {
666
+    void insertDept(MsCaseAffiliate affiliate) {
226 667
         // 查询所有的组织机构,组装成map
227 668
         List<SysDept> deptList = sysDeptMapper.selectDeptList(new SysDept());
228 669
         if (CollectionUtil.isEmpty(deptList)) {
@@ -252,6 +693,7 @@ public class MsCaseApplicationServiceImpl  implements MsCaseApplicationService {
252 693
 
253 694
     /**
254 695
      * 获取案件编码
696
+     *
255 697
      * @return
256 698
      */
257 699
     private String getCaseNum() {
@@ -265,7 +707,7 @@ public class MsCaseApplicationServiceImpl  implements MsCaseApplicationService {
265 707
         if (null == maxCaseNum) {
266 708
             caseNum = caseNum + "00001";
267 709
         } else {
268
-            maxCaseNum=maxCaseNum+1;
710
+            maxCaseNum = maxCaseNum + 1;
269 711
             caseNum = caseNum + String.format("%05d", maxCaseNum);
270 712
         }
271 713
         return caseNum;
@@ -273,14 +715,15 @@ public class MsCaseApplicationServiceImpl  implements MsCaseApplicationService {
273 715
 
274 716
     /**
275 717
      * 获取批次号
718
+     *
276 719
      * @return
277 720
      */
278 721
     private String getBatchNumber() {
279 722
         Integer batchNumber = msCaseApplicationMapper.selectMaxBatchNumber();
280
-        if(batchNumber==null){
281
-        return "000001";
282
-        }else {
283
-            return  String.format("%06d", batchNumber+1);
723
+        if (batchNumber == null) {
724
+            return "000001";
725
+        } else {
726
+            return String.format("%06d", batchNumber + 1);
284 727
         }
285 728
 
286 729
     }

+ 2
- 25
ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/utils/CaseLogUtils.java Просмотреть файл

@@ -27,7 +27,7 @@ public class CaseLogUtils
27 27
      * @param caseNode 案件节点,不能为空
28 28
      * @param notes 备注
29 29
      */
30
-    public static void insertCaseLog(@NotNull Long caseAppliId, @NotEmpty Integer caseNode, String notes  ){
30
+    public static void insertCaseLog(@NotNull Long caseAppliId, @NotEmpty Integer caseNode,String caseStatusName, String notes  ){
31 31
         MsCaseLogRecord operLog = new MsCaseLogRecord();
32 32
         // 获取当前的用户
33 33
         LoginUser loginUser = SecurityUtils.getLoginUser();
@@ -41,30 +41,7 @@ public class CaseLogUtils
41 41
             operLog.setCreateNickName("管理员");
42 42
             operLog.setUpdateBy("admin");
43 43
         }
44
-        operLog.setCaseAppliId(caseAppliId);
45
-        operLog.setCaseNode(caseNode);
46
-        operLog.setNotes(notes);
47
-        caseLogRecordMapper.insert(operLog);
48
-    }
49
-    /**
50
-     * 新增案件日志
51
-     * @param caseAppliId 案件id,不能为空
52
-     * @param caseNode 案件节点,不能为空
53
-     * @param notes 备注
54
-     */
55
-    public static void insertCaseLog(@NotNull Long caseAppliId, @NotEmpty Integer caseNode, String notes ,LoginUser loginUser ){
56
-        MsCaseLogRecord operLog = new MsCaseLogRecord();
57
-        // 获取当前的用户
58
-        if(loginUser!=null) {
59
-            SysUser sysUser = userMapper.selectUserById(loginUser.getUserId());
60
-            operLog.setCreateBy(sysUser.getUserName());
61
-            operLog.setCreateNickName(sysUser.getNickName());
62
-            operLog.setUpdateBy(sysUser.getUserName());
63
-        }else {
64
-            operLog.setCreateBy("admin");
65
-            operLog.setCreateNickName("管理员");
66
-            operLog.setUpdateBy("admin");
67
-        }
44
+        operLog.setCaseStatusName(caseStatusName);
68 45
         operLog.setCaseAppliId(caseAppliId);
69 46
         operLog.setCaseNode(caseNode);
70 47
         operLog.setNotes(notes);

+ 6
- 6
ruoyi-system/src/main/resources/mapper/system/SysUserMapper.xml Просмотреть файл

@@ -274,20 +274,20 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
274 274
     <update id="updateUser" parameterType="com.ruoyi.common.core.domain.entity.SysUser">
275 275
  		update ms_sys_user
276 276
  		<set>
277
- 			<if test="deptId != null and deptId != 0">dept_id = #{deptId},</if>
277
+ 			dept_id = #{deptId},
278 278
  			<if test="userName != null and userName != ''">user_name = #{userName},</if>
279 279
  			<if test="nickName != null and nickName != ''">nick_name = #{nickName},</if>
280
- 			<if test="idCard != null and idCard != ''">id_card = #{idCard},</if>
281
- 			<if test="email != null ">email = #{email},</if>
282
- 			<if test="phonenumber != null ">phonenumber = #{phonenumber},</if>
283
- 			<if test="sex != null and sex != ''">sex = #{sex},</if>
280
+ 			id_card = #{idCard},
281
+ 			email = #{email},
282
+ 			phonenumber = #{phonenumber},
283
+ 			sex = #{sex},
284 284
  			<if test="avatar != null and avatar != ''">avatar = #{avatar},</if>
285 285
  			<if test="password != null and password != ''">password = #{password},</if>
286 286
  			<if test="status != null and status != ''">status = #{status},</if>
287 287
  			<if test="loginIp != null and loginIp != ''">login_ip = #{loginIp},</if>
288 288
  			<if test="loginDate != null">login_date = #{loginDate},</if>
289 289
  			<if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if>
290
- 			<if test="remark != null">remark = #{remark},</if>
290
+ 			remark = #{remark},
291 291
  			specialty = #{specialty},
292 292
  			update_time = sysdate()
293 293
  		</set>