浏览代码

压缩包上传,裁决书生成,案件修改,修改后对比信息

18792927508 2 年前
父节点
当前提交
5d4929f36b
共有 17 个文件被更改,包括 898 次插入1781 次删除
  1. 3
    0
      ruoyi-admin/src/main/java/com/ruoyi/web/controller/wisdomarbitrate/AdjudicationController.java
  2. 8
    0
      ruoyi-common/src/main/java/com/ruoyi/common/utils/ObjectFieldUtils.java
  3. 12
    975
      ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/domain/CaseApplication.java
  4. 7
    1
      ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/domain/vo/ColumnValue.java
  5. 4
    1
      ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/domain/vo/CompareCaseVO.java
  6. 3
    9
      ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/mapper/CaseApplicationMapper.java
  7. 29
    0
      ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/mapper/ColumnValueLogMapper.java
  8. 5
    0
      ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/mapper/ColumnValueMapper.java
  9. 2
    1
      ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/service/ICaseApplicationService.java
  10. 359
    212
      ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/service/impl/AdjudicationServiceImpl.java
  11. 70
    4
      ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/service/impl/CaseApplicationLogServiceImpl.java
  12. 292
    198
      ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/service/impl/CaseApplicationServiceImpl.java
  13. 17
    17
      ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/utils/OCRUtils.java
  14. 24
    363
      ruoyi-system/src/main/resources/mapper/wisdomarbitrate/CaseApplicationMapper.xml
  15. 50
    0
      ruoyi-system/src/main/resources/mapper/wisdomarbitrate/ColumnValueLogMapper.xml
  16. 12
    0
      ruoyi-system/src/main/resources/mapper/wisdomarbitrate/ColumnValueMapper.xml
  17. 1
    0
      ruoyi-system/src/main/resources/mapper/wisdomarbitrate/FatchRuleMapper.xml

+ 3
- 0
ruoyi-admin/src/main/java/com/ruoyi/web/controller/wisdomarbitrate/AdjudicationController.java 查看文件

@@ -32,6 +32,9 @@ public class AdjudicationController extends BaseController {
32 32
      */
33 33
     @PostMapping("/document")
34 34
     public AjaxResult createDocument(@Validated @RequestBody CaseApplication caseApplication){
35
+        if (caseApplication.getId() == null) {
36
+            return AjaxResult.error("案件id不能为空");
37
+        }
35 38
         return adjudicationService.createDocument(caseApplication);
36 39
     }
37 40
 

+ 8
- 0
ruoyi-common/src/main/java/com/ruoyi/common/utils/ObjectFieldUtils.java 查看文件

@@ -1,5 +1,7 @@
1 1
 package com.ruoyi.common.utils;
2 2
 
3
+import cn.hutool.core.util.StrUtil;
4
+
3 5
 import java.lang.reflect.Field;
4 6
 
5 7
 /**
@@ -7,6 +9,9 @@ import java.lang.reflect.Field;
7 9
  */
8 10
 public class ObjectFieldUtils {
9 11
     public static String getValue(Object obj,String fieldName){
12
+        if(obj==null || StrUtil.isEmpty(fieldName)){
13
+            return "";
14
+        }
10 15
         Field field=null;
11 16
         try{
12 17
             field=obj.getClass().getDeclaredField(fieldName);
@@ -28,6 +33,9 @@ public class ObjectFieldUtils {
28 33
     }
29 34
 
30 35
     public static void setValue(Object obj,String fieldName,Object value){
36
+        if(obj==null || StrUtil.isEmpty(fieldName)||value==null){
37
+            return;
38
+        }
31 39
         Field field=null;
32 40
         try{
33 41
             field=obj.getClass().getDeclaredField(fieldName);

+ 12
- 975
ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/domain/CaseApplication.java
文件差异内容过多而无法显示
查看文件


+ 7
- 1
ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/domain/vo/ColumnValue.java 查看文件

@@ -33,7 +33,13 @@ public class ColumnValue {
33 33
      * 案件id
34 34
      */
35 35
     private Long caseId;
36
-
36
+    /**
37
+     * 是否为自定义字段,0-否,1-是
38
+     */
37 39
     private Integer isDefault;
40
+    /**
41
+     * 案件日志表id
42
+     */
43
+    private Long caseAppliLogId;
38 44
 
39 45
 }

+ 4
- 1
ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/domain/vo/CompareCaseVO.java 查看文件

@@ -29,6 +29,9 @@ public class CompareCaseVO {
29 29
      * 变化字段,多个用,拼接
30 30
      */
31 31
     private String changeColumn;
32
-
32
+    /**
33
+     * 自定义字段变化字段,多个用,拼接
34
+     */
35
+    private String columnValueChangeColumn;
33 36
 
34 37
 }

+ 3
- 9
ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/mapper/CaseApplicationMapper.java 查看文件

@@ -118,17 +118,11 @@ public interface CaseApplicationMapper {
118 118
      */
119 119
     void updateVersionById(@Param("id")Long id, @Param("version")Integer version);
120 120
 
121
-    /**
122
-     * 查询秘书案件
123
-     * @param caseApplication
124
-     * @return
125
-     */
126
-    List<CaseApplication> selectSecretaryCase(CaseApplication caseApplication);
127 121
 
128 122
     /**
129
-     * 查询申请人案件
130
-     * @param caseApplication
123
+     * 查询最大批号
131 124
      * @return
132 125
      */
133
-    List<CaseApplication> selectApplicationCase(CaseApplication caseApplication);
126
+    Integer selectBatchNumberLike();
127
+
134 128
 }

+ 29
- 0
ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/mapper/ColumnValueLogMapper.java 查看文件

@@ -0,0 +1,29 @@
1
+package com.ruoyi.wisdomarbitrate.mapper;
2
+
3
+import com.ruoyi.wisdomarbitrate.domain.vo.ColumnValue;
4
+import org.apache.ibatis.annotations.Param;
5
+import org.springframework.stereotype.Repository;
6
+
7
+import java.util.List;
8
+
9
+/**
10
+ * 动态配置字段表
11
+ */
12
+@Repository
13
+public interface ColumnValueLogMapper {
14
+
15
+    /**
16
+     * 批量新增
17
+     */
18
+    void batchSave(@Param("list") List<ColumnValue> list);
19
+    void batchUpdate(@Param("list") List<ColumnValue> list);
20
+
21
+    /**
22
+     * 根据案件id查询字段及值
23
+     * @param caseId
24
+     * @return
25
+     */
26
+    List<ColumnValue> listBycaseAppliLogId(@Param("caseId") Long caseId);
27
+
28
+    List<ColumnValue> queryColumnValueList(ColumnValue columnValue);
29
+}

+ 5
- 0
ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/mapper/ColumnValueMapper.java 查看文件

@@ -27,4 +27,9 @@ public interface ColumnValueMapper {
27 27
     List<ColumnValue> listByCaseId(@Param("caseId") Long caseId);
28 28
 
29 29
     List<ColumnValue> queryColumnValueList(ColumnValue columnValue);
30
+    /**
31
+     * 批量修改
32
+     */
33
+    void batchUpdate(@Param("list") List<ColumnValue> list);
34
+
30 35
 }

+ 2
- 1
ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/service/ICaseApplicationService.java 查看文件

@@ -3,6 +3,7 @@ package com.ruoyi.wisdomarbitrate.service;
3 3
 import com.ruoyi.common.core.domain.AjaxResult;
4 4
 import com.ruoyi.common.exception.EsignDemoException;
5 5
 import com.ruoyi.wisdomarbitrate.domain.*;
6
+import com.ruoyi.wisdomarbitrate.domain.vo.ColumnValue;
6 7
 import com.ruoyi.wisdomarbitrate.domain.vo.ReservedConferenceVO;
7 8
 import com.ruoyi.wisdomarbitrate.domain.vo.SendRoomNoMessageVO;
8 9
 import com.ruoyi.wisdomarbitrate.domain.vo.ToDoCount;
@@ -18,7 +19,7 @@ public interface ICaseApplicationService {
18 19
     List<CaseApplication> selectCaseApplicationListByRole(CaseApplication caseApplication);
19 20
 
20 21
 
21
-    int insertcaseApplication(CaseApplication caseApplication, Map<String,String> fatchMap);
22
+    int insertcaseApplication(CaseApplication caseApplication, List<ColumnValue> columnValueList);
22 23
 
23 24
     int selectCaseApplicationCount(CaseApplication caseApplication);
24 25
 

+ 359
- 212
ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/service/impl/AdjudicationServiceImpl.java 查看文件

@@ -7,15 +7,14 @@ import com.alibaba.fastjson.JSONObject;
7 7
 import com.deepoove.poi.data.PictureRenderData;
8 8
 import com.ruoyi.common.constant.CaseApplicationConstants;
9 9
 import com.ruoyi.common.core.domain.AjaxResult;
10
+import com.ruoyi.common.core.domain.entity.SysDictData;
10 11
 import com.ruoyi.common.core.redis.RedisCache;
11
-import com.ruoyi.common.utils.DateUtils;
12
-import com.ruoyi.common.utils.SmsUtils;
12
+import com.ruoyi.common.utils.*;
13
+import com.ruoyi.system.mapper.SysDictDataMapper;
13 14
 import com.ruoyi.wisdomarbitrate.domain.vo.BookSendVO;
14 15
 import com.ruoyi.wisdomarbitrate.domain.vo.ColumnValue;
15 16
 import com.ruoyi.wisdomarbitrate.mapper.*;
16 17
 import com.ruoyi.wisdomarbitrate.utils.CaseLogUtils;
17
-import com.ruoyi.common.utils.EmailOutUtil;
18
-import com.ruoyi.common.utils.WordUtil;
19 18
 import com.ruoyi.wisdomarbitrate.domain.*;
20 19
 import com.ruoyi.wisdomarbitrate.domain.vo.ArchivesDetailVO;
21 20
 import com.ruoyi.wisdomarbitrate.domain.vo.LogisticsInfoVO;
@@ -49,6 +48,7 @@ import java.text.NumberFormat;
49 48
 import java.text.SimpleDateFormat;
50 49
 import java.time.LocalDate;
51 50
 import java.util.*;
51
+import java.util.function.Function;
52 52
 import java.util.regex.Matcher;
53 53
 import java.util.regex.Pattern;
54 54
 import java.util.stream.Collectors;
@@ -84,6 +84,11 @@ public class AdjudicationServiceImpl implements IAdjudicationService {
84 84
     private TemplateManageMapper templateManageMapper;
85 85
     @Autowired
86 86
     private ColumnValueMapper columnValueMapper;
87
+    @Autowired
88
+    private FatchRuleMapper fatchRuleMapper;
89
+    @Autowired
90
+    private SysDictDataMapper dictDataMapper;
91
+
87 92
     // 仲裁反请求模板内容
88 93
     private final String counterclaim= "在《2022年版仲裁规则》第十八条第(一)项规定的期限内,被申请人向秘书处提交了" +
89 94
             "《仲裁反请求申请书》及证据材料。仲裁委依据《2022年版仲裁规则》第十八条的规定受理了该仲裁反请求案申请。" +
@@ -123,276 +128,418 @@ public class AdjudicationServiceImpl implements IAdjudicationService {
123 128
     // 被申请人缺席
124 129
     String resAbsent="(二)当事人提供的证据材料\n" +
125 130
             "申请人为证明其主张的事实和理由,向仲裁庭提交了如下证据材料:\n{{applicantFile}}";
131
+    // 日期格式化年月日
132
+    SimpleDateFormat sdf = new SimpleDateFormat("yyyy年MM月dd日");
126 133
     @Override
127 134
     @Transactional
128 135
     public AjaxResult createDocument(CaseApplication caseApplicationReq) {
129
-        String templatePath="";
130
-        String templateName="";
131
-        String agentName="";
132
-        String resName="";
136
+        String templatePath = "";
137
+        String templateName = "";
138
+        String agentName = "";
139
+        String resName = "";
133 140
         try {
134 141
             Map<String, Object> datas = new HashMap<>();
135 142
             Long id = caseApplicationReq.getId();
136
-            if (id == null) {
137
-                return AjaxResult.error("案件id不能为空");
138
-            }
139
-
140 143
             //获取案件详细信息
141 144
             CaseApplication caseApplicationById = caseApplicationService.selectCaseApplication(caseApplicationReq);
142
-
143
-            if(caseApplicationById==null){
145
+            if (caseApplicationById == null) {
144 146
                 return AjaxResult.error("案件不存在");
145 147
             }
148
+
149
+            if (caseApplicationById.getTemplateId() == null) {
150
+                return AjaxResult.error("请先指定裁决书模板");
151
+            }
146 152
             // 根据模板id查找对应的模板
147
-            if(caseApplicationById.getTemplateId()!=null) {
148
-                TemplateManage templateManage = new TemplateManage();
149
-                templateManage.setId(caseApplicationById.getTemplateId());
150
-                List<TemplateManage> templateManages = templateManageMapper.selectTemplateList(templateManage);
151
-                if(CollectionUtil.isEmpty(templateManages)){
152
-                    return AjaxResult.error("请先指定裁决书模板");
153
-                }
154
-                templatePath=templateManages.get(0).getTemOrigPath();
155
-                templateName=templateManages.get(0).getFileName();
153
+            TemplateManage templateManage = new TemplateManage();
154
+            templateManage.setId(caseApplicationById.getTemplateId());
155
+            List<TemplateManage> templateManages = templateManageMapper.selectTemplateList(templateManage);
156
+            if (CollectionUtil.isEmpty(templateManages)) {
157
+                return AjaxResult.error("请先指定裁决书模板");
156 158
             }
159
+            templatePath = templateManages.get(0).getTemOrigPath();
160
+            templateName = templateManages.get(0).getFileName();
161
+            // 查询案件相关表信息
162
+            CaseAffiliate caseAffiliate = new CaseAffiliate();
163
+            caseAffiliate.setCaseAppliId(id);
164
+            List<CaseAffiliate> caseAffiliates = caseAffiliateMapper.selectCaseAffiliate(caseAffiliate);
157 165
             //获取仲裁记录表里的相关信息
158 166
             ArbitrateRecord arbitrateRecord = new ArbitrateRecord();
159 167
             arbitrateRecord.setCaseAppliId(id);
160 168
             ArbitrateRecord arbitrateRecordSelect = arbitrateRecordMapper.selectArbitrateRecord(arbitrateRecord);
169
+            // 在系统表中查询案件内置字段
170
+            SysDictData sysDictData = new SysDictData();
171
+            sysDictData.setDictType("case_built_type");
172
+            List<SysDictData> dictDataList = dictDataMapper.selectDictDataList(sysDictData);
173
+            // 根据模板id查询抓取规则,判断从主表取值还是从columnValue值取
174
+            List<FatchRule> fatchRuleList = fatchRuleMapper.listByTemplateId(caseApplicationById.getTemplateId());
175
+            // 抓取规则,0-内置字段,1-自定义字段
176
+            Map<Integer, List<FatchRule>> fatchRuleMap = new HashMap<>();
177
+            // 裁决书需要的字段和内容,占位符需要配置成中文
178
+            Map<String, String> valueMap = new HashMap<>();
179
+            // 如果未设置抓取规则,则从主表取数据,设置内置字段值
180
+            if (CollectionUtil.isNotEmpty(fatchRuleList)) {
181
+                fatchRuleMap = fatchRuleList.stream().collect(Collectors.groupingBy(FatchRule::getIsDefault));
182
+            }
183
+            // 自定义字段,从columnValue值取
184
+            if (fatchRuleMap.size()>0&&fatchRuleMap.containsKey(1)) {
185
+                // 根据案件id查询key-value表
186
+                List<ColumnValue> columnValueList = columnValueMapper.listByCaseId(caseApplicationReq.getId());
187
+                if (CollectionUtil.isNotEmpty(columnValueList)) {
188
+                    columnValueList.forEach(columnValue -> valueMap.put(columnValue.getName(), columnValue.getValue()));
189
+                }
190
+            }
191
+                // 组装内置字段,在主表中查出内容
192
+                buildDefaultColumnValue(dictDataList,caseAffiliates,valueMap,caseApplicationById);
161 193
 
162
-            // todo 获取模板中的所有占位符,该占位符字段必须和抓取字段一致,暂时写死
163
-            // todo 生成裁决书的内容从key-value表中取,不从案件基本信息表取,会有问题,如果修改的话会有问题,暂不考虑该情况
164
-
165
-            // 根据案件id查询key-value表
166
-            List<ColumnValue> columnValueList = columnValueMapper.listByCaseId(caseApplicationReq.getId());
167 194
             // 获取模板中的占位符key
168 195
             List<String> bookmarkList = getBookmarkByDocx(templatePath);
169
-            if(CollectionUtil.isEmpty(bookmarkList)){
196
+            if (CollectionUtil.isEmpty(bookmarkList)) {
170 197
                 // 直接保存模板为裁决书
171
-                saveArbitorFile(id,templateName,templatePath,caseApplicationById,arbitrateRecordSelect);
198
+                saveArbitorFile(id, templateName, templatePath, caseApplicationById, arbitrateRecordSelect);
172 199
                 return AjaxResult.success("生成裁决书成功");
173 200
             }
174
-            // 如果该表没值,在从主表填充裁决书模板
175
-            if(CollectionUtil.isNotEmpty(columnValueList)){
176
-                Map<String, String> columnValueMap = columnValueList.stream().collect(Collectors.toMap(ColumnValue::getColumn, ColumnValue::getValue));
177
-                agentName=columnValueMap.get("agentName");
178
-                resName=columnValueMap.get("respondentName");
179
-                // 懒得if,暂时这样
180
-                //
181
-                for (String bookmark : bookmarkList) {
182
-                    if(columnValueMap.containsKey(bookmark)){
183
-                        if(bookmark.equals("resSex")){
184
-                            String responSex = columnValueMap.get(bookmark);
185
-                            if (responSex.equals("0")) {
186
-                                datas.put(bookmark, "男");
187
-                            } else {
188
-                                datas.put(bookmark, "女");
189
-                            }
190
-                        }else if(bookmark.equals("arbitratClaims")){
191
-                            // 请求仲裁庭裁决
192
-                            String arbitratClaims = columnValueMap.get(bookmark);
193
-                            if(StrUtil.isNotEmpty(arbitratClaims)){
194
-                                String replace = arbitratClaims.replace("甲方", "被申请人").replace("乙方", "申请人");
195
-                                datas.put("arbitratClaims", replace);
196
-
197
-                            }else {
198
-                                datas.put("arbitratClaims", "");
199
-                            }
200
-                        }else if(bookmark.equals("mediationAgreement")){
201
-                            // 查询本案事实如下
202
-                            String mediationAgreement = columnValueMap.get(bookmark);
203
-                            if(StrUtil.isNotEmpty(mediationAgreement)){
204
-                                String replace = mediationAgreement.replace("甲方", "被申请人").replace("乙方", "申请人");
205
-                                datas.put("mediationAgreement", replace);
206
-
207
-                            }else {
208
-                                datas.put("mediationAgreement", "");
209
-                            }
210
-                        }
211
-                        else {
212
-                            datas.put(bookmark, columnValueMap.get(bookmark));
213
-                        }
214
-                    }
215
-                }
216
-            }else {
217
-
218
-            }
219
-
201
+            // 遍历书签,给书签赋值
202
+            replaceBookmark(bookmarkList,datas,valueMap);
203
+            // 根据条件替换书签
204
+            conditionReplaceBookmark(caseApplicationById,datas,agentName,resName,arbitrateRecordSelect);
220 205
             // 裁决书生成时间
221 206
             LocalDate now = LocalDate.now();
222 207
             String year = Integer.toString(now.getYear());
223
-            datas.put("year", year);
208
+            datas.put("裁决书生成时间", year);
224 209
             //生成编码
225 210
             String equipmentNo = getNewEquipmentNo();
226 211
             // 裁决书编号
227
-            datas.put("num", equipmentNo);
212
+            datas.put("裁决书编号", equipmentNo);
228 213
             // 仲裁费
229
-            datas.put("arbitrationFee", caseApplicationById.getFeePayable().toString());
214
+            datas.put("仲裁费", caseApplicationById.getFeePayable().toString());
230 215
             // 案件创建时间
231 216
             Date createTime = caseApplicationById.getCreateTime();
232
-            SimpleDateFormat sdf = new SimpleDateFormat("yyyy年MM月dd日");
233 217
             // 将日期格式化为字符串
234 218
             String createTimeStr = sdf.format(createTime);
235
-            datas.put("submissionDate", createTimeStr);
219
+            datas.put("案件创建时间", createTimeStr);
236 220
             // 立案日期
237 221
             Date registerDate = caseApplicationById.getRegisterDate();
238 222
             String registerDateStr = sdf.format(registerDate);
239
-            datas.put("acceptDate", registerDateStr);
223
+            datas.put("立案日期", registerDateStr);
240 224
 
241
-            // 如果有仲裁反请求,该字段设置值
242
-            Integer adjudicaCounter = caseApplicationById.getAdjudicaCounter();
243
-             if (adjudicaCounter!=null&&adjudicaCounter == 1) {
244
-                datas.put("counterclaim", counterclaim);
245
-            }
246
-            //财产保全
247
-            Integer properPreser = caseApplicationById.getProperPreser();
248
-            if (properPreser!=null&&properPreser == 1) {
249
-                datas.put("preservation", preservation);
250
-            }
251
-            //管辖权异议
252
-            Integer objectiJuris = caseApplicationById.getObjectiJuris();
253
-            if (objectiJuris!=null&&objectiJuris == 1) {
254
-                datas.put("jurisdictionalObjection", jurisdictionalObjection);
255
-            }
256 225
 
257
-            // 出席庭审人员角色名称
258
-            String attendName="秘书、";
259
-            boolean isAbsenceFlag = caseApplicationById.getIsAbsence() != null && caseApplicationById.getIsAbsence().equals(0);
260
-            boolean appIsAbsenceFlag = caseApplicationById.getAppliIsAbsen() != null && caseApplicationById.getAppliIsAbsen().equals(0);
261
-            if(isAbsenceFlag||appIsAbsenceFlag){
262
-                if(isAbsenceFlag) {
263
-                    attendName += "申请代理人" + agentName+"、";
264
-                }
265
-                if(appIsAbsenceFlag) {
266
-                    attendName += "被申请人" + resName;
267
-                }
268
-                if(attendName.endsWith("、")){
269
-                    attendName=attendName.replace("、","");
270
-                }
271
-                datas.put("attendName", attendName);
272
-            }
226
+            String month = String.format("%02d", now.getMonthValue());
227
+            String day = String.format("%02d", now.getDayOfMonth());
228
+            // todo
229
+//            String modalFilePath = "/data/arbitrate-document/template/新裁决书模板.docx";
230
+            // todo
231
+//            String saveFolderPath = "/home/ruoyi/uploadPath/upload/" + year + "/" + month + "/" + day;
232
+            String saveFolderPath = "D:/home/ruoyi/uploadPath/upload/" + year + "/" + month + "/" + day;
233
+            String fileName = UUID.randomUUID().toString().replace("-", "") + ".docx";
234
+            // todo
235
+//            String saveName = "/profile/upload/" + year + "/" + month + "/" + day + "/" + fileName;
236
+            String saveName = "D:/home/ruoyi/uploadPath/upload/" + year + "/" + month + "/" + day + "/" + fileName;
237
+            // 将word中的标签替换掉,生成新的word
238
+            String docFilePath =  wordChangeText(templatePath,datas,saveFolderPath,fileName);
273 239
 
274
-            // 仲裁员名称
275
-            datas.put("arbitratorName", caseApplicationById.getArbitratorName());
276
-            // 审理方式
277
-            Integer arbitratMethod = caseApplicationById.getArbitratMethod();
278
-            Date hearDate = caseApplicationById.getHearDate();
279
-            if (hearDate != null) {
280
-                // 审理日期
281
-                String hearDateStr = sdf.format(hearDate);
282
-                datas.put("hearDate",hearDateStr);
283
-                // todo 线上仲裁/线下仲裁方式未选择
284
-                //线上开庭时
285
-                if (arbitratMethod == 1) {
286
-                    String replace = onLine.replace(onLineDate, Optional.ofNullable(hearDateStr).orElse(""));
287
-                    datas.put("onLine", replace);
240
+            String savePath = docFilePath.substring(0, docFilePath.indexOf("/upload/") + 8);
241
+            // 保存裁决书附件
242
+            saveArbitorFile(id, saveName, savePath, caseApplicationById, arbitrateRecordSelect);
288 243
 
289
-                } else {
290
-                    //书面仲裁时
291
-                    String replace = written.replace(writtenDate, Optional.ofNullable(hearDateStr).orElse(""));
292
-                    datas.put("written", replace);
244
+            return AjaxResult.success("裁决书已生成");
245
+        } catch (IOException e) {
246
+            return AjaxResult.error(e + "请检查文件路径是否有误");
247
+        }
248
+    }
293 249
 
294
-                }
250
+    /**
251
+     * 将word中的标签替换掉,生成新的word
252
+     * @param modalFilePath 裁决书模板路径
253
+     * @param datas 替换标签的内容
254
+     * @param saveFolderPath 保存路径
255
+     * @param fileName 保存文件名
256
+     * @return
257
+     * @throws IOException
258
+     */
259
+    private String wordChangeText(String modalFilePath, Map<String, Object> datas, String saveFolderPath,String fileName) throws IOException {
260
+        String resultFilePath = saveFolderPath + "/" + fileName;
261
+        // 创建日期目录
262
+        File saveFolder = new File(saveFolderPath);
263
+        if (!saveFolder.exists()) {
264
+            saveFolder.mkdirs();
265
+        }
266
+        Path sourcePath = new File(modalFilePath).toPath();
267
+        Path destinationPath = new File(resultFilePath).toPath();
268
+        Files.copy(sourcePath, destinationPath, StandardCopyOption.REPLACE_EXISTING);
269
+        String docFilePath = WordUtil.getDocFilePath(datas, modalFilePath, resultFilePath);
270
+        File file = new File(docFilePath);
271
+        if (file.exists()) {
272
+            InputStream in = new FileInputStream(file);
273
+            XWPFDocument xwpfDocument = new XWPFDocument(in);
274
+            WordUtil.changeText(xwpfDocument);
275
+        }
276
+        return docFilePath;
277
+    }
278
+
279
+    /**
280
+     * 根据条件判断裁决书中是否需要该内容
281
+     * @param caseApplicationById 案件信息
282
+     * @param datas 替换标签值
283
+     * @param agentName 代理人名称
284
+     * @param resName 被申请人名称
285
+     * @param   arbitrateRecordSelect  仲裁记录
286
+     */
287
+    private void conditionReplaceBookmark(CaseApplication caseApplicationById, Map<String, Object> datas,String agentName,String resName, ArbitrateRecord arbitrateRecordSelect ) {
288
+        // 如果有仲裁反请求,该字段设置值
289
+        Integer adjudicaCounter = caseApplicationById.getAdjudicaCounter();
290
+        if (adjudicaCounter != null && adjudicaCounter == 1) {
291
+            datas.put("仲裁反请求", counterclaim);
292
+        }
293
+        //财产保全
294
+        Integer properPreser = caseApplicationById.getProperPreser();
295
+        if (properPreser != null && properPreser == 1) {
296
+            datas.put("财产保全", preservation);
297
+        }
298
+        //管辖权异议
299
+        Integer objectiJuris = caseApplicationById.getObjectiJuris();
300
+        if (objectiJuris != null && objectiJuris == 1) {
301
+            datas.put("管辖权异议", jurisdictionalObjection);
302
+        }
303
+
304
+        // 出席庭审人员角色名称
305
+        String attendName = "秘书、";
306
+        boolean isAbsenceFlag = caseApplicationById.getIsAbsence() != null && caseApplicationById.getIsAbsence().equals(0);
307
+        boolean appIsAbsenceFlag = caseApplicationById.getAppliIsAbsen() != null && caseApplicationById.getAppliIsAbsen().equals(0);
308
+        if (isAbsenceFlag || appIsAbsenceFlag) {
309
+            if (isAbsenceFlag) {
310
+                attendName += "申请代理人" + agentName + "、";
311
+            }
312
+            if (appIsAbsenceFlag) {
313
+                attendName += "被申请人" + resName;
295 314
             }
315
+            if (attendName.endsWith("、")) {
316
+                attendName = attendName.replace("、", "");
317
+            }
318
+            datas.put("出席庭审人员", attendName);
319
+        }
320
+
321
+        // 仲裁员名称
322
+        datas.put("仲裁员姓名", caseApplicationById.getArbitratorName());
323
+        // 审理方式
324
+        Integer arbitratMethod = caseApplicationById.getArbitratMethod();
325
+        Date hearDate = caseApplicationById.getHearDate();
326
+        String hearDateStr = "";
327
+        if (hearDate != null) {
328
+            // 审理日期
329
+            hearDateStr = sdf.format(hearDate);
330
+            datas.put("审理日期", hearDateStr);
331
+        }
332
+        // todo 线上仲裁/线下仲裁方式未选择
333
+        //线上开庭时+线上仲裁
334
+        if (arbitratMethod!=null&&arbitratMethod == 1) {
335
+            String replace = onLine.replace(onLineDate, Optional.of(hearDateStr).orElse(""));
336
+            datas.put("线上开庭并线上仲裁", replace);
296 337
             // 所有附件
297 338
             List<CaseAttach> caseAttachList = caseApplicationById.getCaseAttachList();
298
-            Map<Integer, List<CaseAttach>> caseAttachMap=new HashMap<>();
299
-            if(caseAttachList!=null&&caseAttachList.size()>0){
339
+            Map<Integer, List<CaseAttach>> caseAttachMap = new HashMap<>();
340
+            if (caseAttachList != null && caseAttachList.size() > 0) {
300 341
                 caseAttachMap = caseAttachList.stream().collect(Collectors.groupingBy(CaseAttach::getAnnexType));
301 342
             }
302 343
             // 被申请人是否缺席
303 344
             Integer isAbsence = caseApplicationById.getIsAbsence();
304
-            // 线上开庭
305
-            if (arbitratMethod == 1) {
306
-                if (isAbsence != null && isAbsence == 1) {
307
-                    // 被申请人缺席
308
-                    String absentReplace = absent.replace("{{agentName}}", Optional.ofNullable(agentName).orElse(""));
309
-                    datas.put("absent",absentReplace);
310
-                    // 被申请人缺席
311
-                    String resAbsentReplace=resAbsent;
312
-                    if(caseAttachMap!=null && CollectionUtil.isNotEmpty(caseAttachMap.get(2))){
313
-                        List<CaseAttach> caseAttaches = caseAttachMap.get(2);
345
+            if (isAbsence != null && isAbsence == 1) {
346
+                // 被申请人缺席,开庭+缺席审理
347
+                String absentReplace = absent.replace("{{agentName}}", Optional.of(agentName).orElse(""));
348
+
349
+                // 被申请人缺席
350
+                String resAbsentReplace = resAbsent;
351
+                if (caseAttachMap != null && CollectionUtil.isNotEmpty(caseAttachMap.get(2))) {
352
+                    List<CaseAttach> caseAttaches = caseAttachMap.get(2);
353
+                    StringBuilder stringBuilder = new StringBuilder();
354
+                    for (CaseAttach caseAttach : caseAttaches) {
355
+                        stringBuilder.append(caseAttach.getAnnexName()).append("\n");
356
+                    }
357
+                    resAbsentReplace = resAttendOpinion.replace("{{applicantFile}}", stringBuilder.toString());
358
+                }
359
+                datas.put("开庭并缺席", absentReplace + resAbsentReplace);
360
+            } else {
361
+                // 被申出席
362
+                String attendReplace = attend.replace("{{agentName}}", Optional.ofNullable(agentName).orElse(""));
363
+                datas.put("开庭并出席", attendReplace);
364
+                // 被申请人证据
365
+                if (caseAttachMap != null && CollectionUtil.isNotEmpty(caseAttachMap.get(6))) {
366
+                    // 开庭+出席+被申提供证据
367
+
368
+                    //  开庭+出席+被申提供证据
369
+                    String resFileReplace = resFile;
370
+                    if (CollectionUtil.isNotEmpty(caseAttachMap.get(6))) {
371
+                        List<CaseAttach> caseAttaches = caseAttachMap.get(6);
314 372
                         StringBuilder stringBuilder = new StringBuilder();
315 373
                         for (CaseAttach caseAttach : caseAttaches) {
316 374
                             stringBuilder.append(caseAttach.getAnnexName()).append("\n");
317 375
                         }
318
-                        resAbsentReplace = resAttendOpinion.replace("{{applicantFile}}", stringBuilder.toString());
376
+                        resFileReplace = resFile.replace("{{resFile}}", stringBuilder.toString()).replace("{{applicantOpinion}}", (arbitrateRecordSelect == null || arbitrateRecordSelect.getApplicantOpinion() == null ? "" : arbitrateRecordSelect.getApplicantOpinion()));
319 377
                     }
320
-                    datas.put("resAbsent",resAbsentReplace);
378
+                    datas.put("开庭并出席并被申提供证据", onLineAttendFile + resFileReplace);
321 379
                 } else {
322
-                    // 出席
323
-                    String attendReplace = attend.replace("{{agentName}}", Optional.ofNullable(agentName).orElse(""));
324
-                    datas.put("attend",attendReplace);
325
-                    // 被申请人证据
326
-                    if(caseAttachMap!=null && CollectionUtil.isNotEmpty(caseAttachMap.get(6))){
327
-                       // 开庭+出席+被申提供证据
328
-                        datas.put("onLineAttendFile",onLineAttendFile);
329
-                        // 被申请人出席+被申请人提供了资料
330
-                        String resFileRplace=resFile;
331
-                        if(caseAttachMap!=null && CollectionUtil.isNotEmpty(caseAttachMap.get(6))){
332
-                            List<CaseAttach> caseAttaches = caseAttachMap.get(6);
333
-                            StringBuilder stringBuilder = new StringBuilder();
334
-                            for (CaseAttach caseAttach : caseAttaches) {
335
-                                stringBuilder.append(caseAttach.getAnnexName()).append("\n");
336
-                            }
337
-                            resFileRplace = resFile.replace("{{resFile}}", stringBuilder.toString()).replace("{{applicantOpinion}}", (arbitrateRecordSelect==null||arbitrateRecordSelect.getApplicantOpinion()==null?"":arbitrateRecordSelect.getApplicantOpinion()));
338
-                        }
339
-                        datas.put("resFile",resFileRplace);
340
-                    }else {
341
-                        // 开庭+出席+被申未提供证据
342
-                        datas.put("onLineAttend",onLineAttend);
343
-                    }
344
-                    // 被申请人出席答辩意见
345
-                    String resAttendOpinionReplace=resAttendOpinion;
346
-                    if(caseAttachMap!=null && CollectionUtil.isNotEmpty(caseAttachMap.get(2))){
347
-                        List<CaseAttach> caseAttaches = caseAttachMap.get(2);
348
-                        StringBuilder stringBuilder = new StringBuilder();
349
-                        for (CaseAttach caseAttach : caseAttaches) {
350
-                            stringBuilder.append(caseAttach.getAnnexName()).append("\n");
351
-                        }
352
-                         resAttendOpinionReplace = resAttendOpinion.replace("{{applicantFile}}", stringBuilder.toString()).replace("{{respondentOpinion}}", (arbitrateRecordSelect==null||arbitrateRecordSelect.getRespondentOpinion()==null)?"":arbitrateRecordSelect.getRespondentOpinion());
380
+                    // 开庭+出席+被申未提供证据
381
+                    datas.put("开庭并出席并被申未提供证据", onLineAttend);
382
+                }
383
+                // 被申请人出席答辩意见
384
+                String resAttendOpinionReplace = resAttendOpinion;
385
+                if (caseAttachMap != null && CollectionUtil.isNotEmpty(caseAttachMap.get(2))) {
386
+                    List<CaseAttach> caseAttaches = caseAttachMap.get(2);
387
+                    StringBuilder stringBuilder = new StringBuilder();
388
+                    for (CaseAttach caseAttach : caseAttaches) {
389
+                        stringBuilder.append(caseAttach.getAnnexName()).append("\n");
353 390
                     }
354
-
355
-                    datas.put("resAttendOpinion",resAttendOpinionReplace);
391
+                    resAttendOpinionReplace = resAttendOpinion.replace("{{applicantFile}}", stringBuilder.toString()).replace("{{respondentOpinion}}", (arbitrateRecordSelect == null || arbitrateRecordSelect.getRespondentOpinion() == null) ? "" : arbitrateRecordSelect.getRespondentOpinion());
356 392
                 }
393
+
394
+                datas.put("被申请人出席答辩意见", resAttendOpinionReplace);
357 395
             }
358 396
 
397
+        } else {
398
+            //书面仲裁时
399
+            String replace = written.replace(writtenDate, Optional.of(hearDateStr).orElse(""));
400
+            datas.put("书面仲裁", replace);
359 401
 
402
+        }
360 403
 
361
-            String month = String.format("%02d", now.getMonthValue());
362
-            String day = String.format("%02d", now.getDayOfMonth());
363
-            // todo
364
-//            String modalFilePath = "/data/arbitrate-document/template/新裁决书模板.docx";
365
-             String modalFilePath = templatePath;
366
-            // todo
367
-//            String saveFolderPath = "/home/ruoyi/uploadPath/upload/" + year + "/" + month + "/" + day;
368
-            String saveFolderPath = "D:/home/ruoyi/uploadPath/upload/" + year + "/" + month + "/" + day;
369
-            String fileName = UUID.randomUUID().toString().replace("-", "") + ".docx";
370
-            // todo
371
-//            String saveName = "/profile/upload/" + year + "/" + month + "/" + day + "/" + fileName;
372
-            String saveName = "D:/home/ruoyi/uploadPath/upload/" + year + "/" + month + "/" + day + "/" + fileName;
373
-            String resultFilePath = saveFolderPath + "/" + fileName;
374
-            // 创建日期目录
375
-            File saveFolder = new File(saveFolderPath);
376
-            if (!saveFolder.exists()) {
377
-                saveFolder.mkdirs();
378
-            }
379
-            Path sourcePath = new File(modalFilePath).toPath();
380
-            Path destinationPath = new File(resultFilePath).toPath();
381
-            Files.copy(sourcePath, destinationPath, StandardCopyOption.REPLACE_EXISTING);
382
-            String docFilePath = WordUtil.getDocFilePath(datas, modalFilePath, resultFilePath);
383
-            File file = new File(docFilePath);
384
-            if (file.exists()) {
385
-                InputStream in = new FileInputStream(file);
386
-                XWPFDocument xwpfDocument = new XWPFDocument(in);
387
-                WordUtil.changeText(xwpfDocument);
404
+    }
405
+
406
+    /**
407
+     * 给模板中的占位符赋值
408
+     * @param bookmarkList 书签
409
+     * @param datas 书签赋值
410
+     * @param valueMap 案件内容
411
+     */
412
+    private void replaceBookmark(List<String> bookmarkList, Map<String, Object> datas, Map<String, String> valueMap) {
413
+        for (String bookmark : bookmarkList) {
414
+            if (valueMap.containsKey(bookmark)) {
415
+                if (bookmark.equals("仲裁请求")) {
416
+                    // 请求仲裁庭裁决
417
+                    String arbitratClaims = valueMap.get(bookmark);
418
+                    if (StrUtil.isNotEmpty(arbitratClaims)) {
419
+                        String replace = arbitratClaims.replace("甲方", "被申请人").replace("乙方", "申请人");
420
+                        datas.put(bookmark, replace);
421
+
422
+                    } else {
423
+                        datas.put(bookmark, "");
424
+                    }
425
+                } else if (bookmark.equals("本案事实")) {
426
+                    // 查询本案事实如下
427
+                    String mediationAgreement = valueMap.get(bookmark);
428
+                    if (StrUtil.isNotEmpty(mediationAgreement)) {
429
+                        String replace = mediationAgreement.replace("甲方", "被申请人").replace("乙方", "申请人");
430
+                        datas.put(bookmark, replace);
431
+
432
+                    } else {
433
+                        datas.put(bookmark, "");
434
+                    }
435
+                } else {
436
+                    datas.put(bookmark, valueMap.get(bookmark));
437
+                }
388 438
             }
389
-            String savePath = docFilePath.substring(0, docFilePath.indexOf("/upload/") + 8);
390
-            // 保存裁决书附件
391
-            saveArbitorFile(id,saveName,savePath,caseApplicationById,arbitrateRecordSelect);
439
+        }
440
+    }
392 441
 
393
-            return AjaxResult.success("裁决书已生成");
394
-        } catch (IOException e) {
395
-            return AjaxResult.error(e + "请检查文件路径是否有误");
442
+    /**
443
+     * 组装案件内置字段值,即主表和相关人员表信息
444
+     * @param dictDataList 内置字段
445
+     * @param caseAffiliates 关联人员
446
+     * @param valueMap 组装的值
447
+     */
448
+    private void buildDefaultColumnValue(List<SysDictData> dictDataList, List<CaseAffiliate> caseAffiliates, Map<String, String> valueMap, CaseApplication caseApplication) {
449
+        if (CollectionUtil.isNotEmpty(dictDataList)) {
450
+            Map<Integer, CaseAffiliate> affiliateMap = caseAffiliates.stream().collect(Collectors.toMap(CaseAffiliate::getIdentityType, Function.identity(), (n1, n2) -> n2));
451
+            for (SysDictData dictData : dictDataList) {
452
+                if (StrUtil.isNotEmpty(dictData.getDictLabel())) {
453
+                    if (dictData.getDictLabel().contains("被申请人")) {
454
+                        CaseAffiliate affiliate = affiliateMap.get(2);
455
+                        if (affiliate == null) {
456
+                            continue;
457
+                        }
458
+                        // 被申请人
459
+                        switch (dictData.getDictLabel()) {
460
+                            case "被申请人姓名":
461
+                                valueMap.put(dictData.getDictLabel(), affiliate.getName());
462
+                                break;
463
+                            case "被申请人身份证号":
464
+                                valueMap.put(dictData.getDictLabel(), affiliate.getIdentityNum());
465
+                                break;
466
+                            case "被申请人住所":
467
+                                valueMap.put(dictData.getDictLabel(), affiliate.getResidenAffili());
468
+                                break;
469
+                            case "被申请人联系电话":
470
+                                valueMap.put(dictData.getDictLabel(), affiliate.getContactTelphone());
471
+                                break;
472
+                            case "被申请人电子邮件":
473
+                                valueMap.put(dictData.getDictLabel(), affiliate.getEmail());
474
+                                break;
475
+                            case "被申请人性别":
476
+                                if (dictData.getDictLabel().equals("被申请人性别")) {
477
+                                    String responSex = affiliate.getResponSex();
478
+                                    if (responSex.equals("0")) {
479
+                                        valueMap.put(dictData.getDictLabel(), "男");
480
+                                    } else {
481
+                                        valueMap.put(dictData.getDictLabel(), "女");
482
+                                    }
483
+                                }
484
+                                break;
485
+                            case "被申请人出生年月日":
486
+                                Date responBirth = affiliate.getResponBirth();
487
+                                if (responBirth != null) {
488
+                                    valueMap.put(dictData.getDictLabel(), sdf.format(responBirth));
489
+                                } else {
490
+                                    valueMap.put(dictData.getDictLabel(), "");
491
+                                }
492
+                                break;
493
+                            default:
494
+                                break;
495
+                        }
496
+                    } else if (dictData.getDictLabel().contains("申请人") || dictData.getDictLabel().contains("统一社会信用代码")
497
+                            || dictData.getDictLabel().contains("法定代表人") || dictData.getDictLabel().contains("法定代表人职位")
498
+                            || dictData.getDictLabel().contains("代理人")) {
499
+                        CaseAffiliate affiliate = affiliateMap.get(1);
500
+                        if (affiliate == null) {
501
+                            continue;
502
+                        }
503
+                        // 申请人
504
+                        switch (dictData.getDictLabel()) {
505
+                            case "申请人姓名":
506
+                                valueMap.put(dictData.getDictLabel(), affiliate.getName());
507
+                                break;
508
+                            case "统一社会信用代码":
509
+                                valueMap.put(dictData.getDictLabel(), affiliate.getIdentityNum());
510
+                                break;
511
+                            case "法定代表人":
512
+                                valueMap.put(dictData.getDictLabel(), affiliate.getCompLegalPerson());
513
+                                break;
514
+                            case "法定代表人职位":
515
+                                valueMap.put(dictData.getDictLabel(), affiliate.getCompLegalperPost());
516
+                                break;
517
+                            case "申请人住所":
518
+                                valueMap.put(dictData.getDictLabel(), affiliate.getResidenAffili());
519
+                                break;
520
+                            case "申请人联系地址":
521
+                                valueMap.put(dictData.getDictLabel(), affiliate.getContactAddress());
522
+                                break;
523
+                            case "委托代理人姓名":
524
+                                valueMap.put(dictData.getDictLabel(), affiliate.getNameAgent());
525
+                                break;
526
+                            case "委托代理人联系电话":
527
+                                valueMap.put(dictData.getDictLabel(), affiliate.getContactTelphoneAgent());
528
+                                break;
529
+                            case "委托代理人电子邮件":
530
+                                valueMap.put(dictData.getDictLabel(), affiliate.getAgentEmail());
531
+                                break;
532
+                            default:
533
+                                break;
534
+                        }
535
+                    }else {
536
+                        valueMap.put(dictData.getDictLabel(), ObjectFieldUtils.getValue(caseApplication, dictData.getDictValue()));
537
+                    }
538
+                }else {
539
+                    valueMap.put(dictData.getDictLabel(), ObjectFieldUtils.getValue(caseApplication, dictData.getDictValue()));
540
+                }
541
+
542
+            }
396 543
         }
397 544
     }
398 545
 

+ 70
- 4
ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/service/impl/CaseApplicationLogServiceImpl.java 查看文件

@@ -12,6 +12,7 @@ import com.ruoyi.wisdomarbitrate.domain.CaseAffiliate;
12 12
 import com.ruoyi.wisdomarbitrate.domain.CaseApplication;
13 13
 import com.ruoyi.wisdomarbitrate.domain.CaseAttach;
14 14
 import com.ruoyi.wisdomarbitrate.domain.SmsSendRecord;
15
+import com.ruoyi.wisdomarbitrate.domain.vo.ColumnValue;
15 16
 import com.ruoyi.wisdomarbitrate.domain.vo.CompareCaseVO;
16 17
 import com.ruoyi.wisdomarbitrate.domain.vo.UpdateSubmitVO;
17 18
 import com.ruoyi.wisdomarbitrate.mapper.*;
@@ -50,6 +51,8 @@ public class CaseApplicationLogServiceImpl implements CaseApplicationLogService
50 51
     private SmsRecordMapper smsRecordMapper;
51 52
     @Autowired
52 53
     private ICaseApplicationService caseApplicationService;
54
+    @Autowired
55
+    private ColumnValueLogMapper columnValueLogMapper;
53 56
     // 对比两个版本修改的字段,基本字段对比
54 57
     private static final String[] columns = {"caseName","caseSubjectAmount","loanStartDate", "loanEndDate","contractNumber","claimInterestOwed","claimLiquidDamag",
55 58
             "claimPrinciOwed","arbitratClaims","properPreser","requestRule"};
@@ -158,6 +161,16 @@ public class CaseApplicationLogServiceImpl implements CaseApplicationLogService
158 161
                         caseAttachMapper.updateCaseAttach(caseAttach);
159 162
                     }
160 163
                 }
164
+                // 更新自定义字段表
165
+                // 根据caseLogId查询自定义字段表
166
+                List<ColumnValue> columnValueList = columnValueLogMapper.listBycaseAppliLogId(caseApplicationLog.getCaseLogId());
167
+                if(CollectionUtil.isNotEmpty(columnValueList)){
168
+                    for (ColumnValue columnValue : columnValueList) {
169
+                        columnValue.setCaseAppliLogId(vo.getCaseId());
170
+
171
+                    }
172
+                    columnValueLogMapper.batchUpdate(columnValueList);
173
+                }
161 174
             } else {
162 175
                 // 拒绝,将日志表改版本的状态改为拒绝
163 176
                 vo.setUpdateSubmitStatus(UpdateSubmitStatus.REFUSE.getCode());
@@ -231,10 +244,12 @@ public class CaseApplicationLogServiceImpl implements CaseApplicationLogService
231 244
         CaseApplication caseApplication = new CaseApplication();
232 245
         caseApplication.setCaseAppliId(vo.getCaseId());
233 246
         caseApplication.setId(vo.getCaseId());
234
-        CaseApplication beforeCase=   caseApplicationService.selectCaseApplication(caseApplication);
247
+        CaseApplication beforeCase = caseApplicationService.selectCaseApplication(caseApplication);
235 248
 
236 249
         // 查询案件关联人员
237 250
         afterCase.setCaseAffiliates(caseAffiliateLogMapper.selectCaseAffiliate(afterCase.getCaseLogId()));
251
+        // 查询自定义字段表
252
+        afterCase.setColumnValues(columnValueLogMapper.listBycaseAppliLogId(afterCase.getCaseLogId()));
238 253
         // 查询附件
239 254
         CaseAttach caseAttach = new CaseAttach();
240 255
         caseAttach.setCaseAppliLogId(beforeCase.getCaseLogId());
@@ -242,7 +257,7 @@ public class CaseApplicationLogServiceImpl implements CaseApplicationLogService
242 257
         caseAttachLogMapper.getCaseAttachByCaseIdAndType(caseAttach);
243 258
         caseAttach.setCaseAppliLogId(afterCase.getCaseLogId());
244 259
         List<CaseAttach> afterAttachList = caseAttachLogMapper.getCaseAttachByCaseIdAndType(caseAttach);
245
-        if(CollectionUtil.isNotEmpty(afterAttachList)){
260
+        if (CollectionUtil.isNotEmpty(afterAttachList)) {
246 261
             for (CaseAttach attach : afterAttachList) {
247 262
                 String annexName = attach.getAnnexName();
248 263
                 String prefix = "/profile";
@@ -284,9 +299,49 @@ public class CaseApplicationLogServiceImpl implements CaseApplicationLogService
284 299
 
285 300
         }
286 301
         // 对比案件人员字段
287
-        compareAffilate(beforeCase,afterCase);
302
+        compareAffilate(beforeCase, afterCase);
288 303
         // 对比申请人证据资料
289
-        compareCaseVO.setChangeColumn(compareApplicantFile(beforeCase,afterCase,changeColumn).toString());
304
+        compareCaseVO.setChangeColumn(compareApplicantFile(beforeCase, afterCase, changeColumn).toString());
305
+        // 对比自定义字段
306
+        //
307
+        List<ColumnValue> beforeColumnValues = beforeCase.getColumnValues();
308
+        List<ColumnValue> afterColumnValues = afterCase.getColumnValues();
309
+        StringBuilder columnValueChange = new StringBuilder();
310
+
311
+        if (CollectionUtil.isNotEmpty(beforeColumnValues) && CollectionUtil.isNotEmpty(afterColumnValues)) {
312
+            Map<String, String> beforeColumnValueMap = beforeColumnValues.stream().collect(Collectors.toMap(ColumnValue::getColumn, ColumnValue::getValue, (n1, n2) -> n2));
313
+            for (ColumnValue afterColumnValue : afterColumnValues) {
314
+                // 改变前字段不包含改变后字段
315
+                if (!beforeColumnValueMap.containsKey(afterColumnValue.getColumn())) {
316
+                    columnValueChange.append(afterColumnValue.getColumn()).append(",");
317
+                } else {
318
+                    // 都有这个字段,比较内容是否相同
319
+                    // 修改后为空,修改前不为空
320
+                    if (StrUtil.isEmpty(afterColumnValue.getValue()) && StrUtil.isNotEmpty(beforeColumnValueMap.get(afterColumnValue.getColumn()))) {
321
+                        columnValueChange.append(afterColumnValue.getColumn()).append(",");
322
+                    } else if (StrUtil.isNotEmpty(afterColumnValue.getValue()) && StrUtil.isEmpty(beforeColumnValueMap.get(afterColumnValue.getColumn()))) {
323
+                        // 修改前为空,修改后不为空
324
+                        columnValueChange.append(afterColumnValue.getColumn()).append(",");
325
+                    } else if (StrUtil.isNotEmpty(afterColumnValue.getValue()) && StrUtil.isNotEmpty(beforeColumnValueMap.get(afterColumnValue.getColumn()))
326
+                            && !afterColumnValue.getValue().equals(beforeColumnValueMap.get(afterColumnValue.getColumn()))) {
327
+                        // 修改前不为空,修改后不为空,内容不同
328
+                        columnValueChange.append(afterColumnValue.getColumn()).append(",");
329
+                    }
330
+                }
331
+            }
332
+
333
+        } else if (CollectionUtil.isEmpty(beforeColumnValues) && CollectionUtil.isNotEmpty(afterColumnValues)) {
334
+            for (ColumnValue afterColumnValue : afterColumnValues) {
335
+                columnValueChange.append(afterColumnValue.getColumn()).append(",");
336
+            }
337
+
338
+        } else if (CollectionUtil.isNotEmpty(beforeColumnValues) && CollectionUtil.isEmpty(afterColumnValues)) {
339
+            for (ColumnValue beforeColumn : beforeColumnValues) {
340
+                columnValueChange.append(beforeColumn.getColumn()).append(",");
341
+            }
342
+
343
+        }
344
+        compareCaseVO.setColumnValueChangeColumn(columnValueChange.toString());
290 345
 
291 346
         return AjaxResult.success(compareCaseVO);
292 347
     }
@@ -442,5 +497,16 @@ public class CaseApplicationLogServiceImpl implements CaseApplicationLogService
442 497
                 caseAttachMapper.updateCaseAttach(caseAttach);
443 498
             }
444 499
         }
500
+        // 根据caseLogId查询自定义字段表
501
+        List<ColumnValue> columnValueList = columnValueLogMapper.listBycaseAppliLogId(caseApplicationLog.getCaseLogId());
502
+
503
+        // 更新相关人员主表
504
+        if(CollectionUtil.isNotEmpty(columnValueList)){
505
+            for (ColumnValue columnValue : columnValueList) {
506
+                columnValue.setCaseAppliLogId(vo.getCaseId());
507
+
508
+            }
509
+            columnValueLogMapper.batchUpdate(columnValueList);
510
+        }
445 511
     }
446 512
 }

+ 292
- 198
ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/service/impl/CaseApplicationServiceImpl.java 查看文件

@@ -3,6 +3,7 @@ package com.ruoyi.wisdomarbitrate.service.impl;
3 3
 
4 4
 import cn.hutool.core.collection.CollectionUtil;
5 5
 import cn.hutool.core.util.IdcardUtil;
6
+import cn.hutool.core.util.ObjectUtil;
6 7
 import cn.hutool.core.util.StrUtil;
7 8
 import cn.hutool.core.util.ZipUtil;
8 9
 import com.alibaba.fastjson.JSON;
@@ -31,10 +32,7 @@ import com.ruoyi.common.utils.file.SaaSAPIFileUtils;
31 32
 import com.ruoyi.common.core.domain.entity.SysUser;
32 33
 import com.ruoyi.common.utils.thread.ThreadPoolUtil;
33 34
 import com.ruoyi.system.domain.SysUserRole;
34
-import com.ruoyi.system.mapper.SysDeptMapper;
35
-import com.ruoyi.system.mapper.SysRoleMapper;
36
-import com.ruoyi.system.mapper.SysUserMapper;
37
-import com.ruoyi.system.mapper.SysUserRoleMapper;
35
+import com.ruoyi.system.mapper.*;
38 36
 import com.ruoyi.wisdomarbitrate.domain.vo.ColumnValue;
39 37
 import com.ruoyi.wisdomarbitrate.domain.vo.ReservedConferenceVO;
40 38
 import com.ruoyi.wisdomarbitrate.domain.vo.ToDoCount;
@@ -67,6 +65,7 @@ import java.math.RoundingMode;
67 65
 import java.nio.file.Files;
68 66
 import java.nio.file.Path;
69 67
 import java.nio.file.StandardCopyOption;
68
+import java.text.NumberFormat;
70 69
 import java.text.ParseException;
71 70
 import java.text.SimpleDateFormat;
72 71
 import java.time.LocalDate;
@@ -140,7 +139,10 @@ public class CaseApplicationServiceImpl implements ICaseApplicationService {
140 139
     private FatchRuleMapper fatchRuleMapper;
141 140
     @Autowired
142 141
     private ColumnValueMapper columnValueMapper;
143
-
142
+    @Autowired
143
+    private ColumnValueLogMapper columnValueLogMapper;
144
+    @Autowired
145
+    private SysDictDataMapper dictDataMapper;
144 146
     // 手机号正则
145 147
     private static final Pattern TELEPHONE_REGX = Pattern.compile("^1(3\\d|4[5-9]|5[0-35-9]|6[2567]|7[0-8]|8\\d|9[0-35-9])\\d{8}$");
146 148
     // 邮箱正则
@@ -938,7 +940,7 @@ public class CaseApplicationServiceImpl implements ICaseApplicationService {
938 940
      */
939 941
     @Override
940 942
     @Transactional
941
-    public int insertcaseApplication(CaseApplication caseApplication,Map<String,String> fatchMap)  {
943
+    public int insertcaseApplication(CaseApplication caseApplication, List<ColumnValue> columnValueList)  {
942 944
 
943 945
         caseApplication.setCaseStatus(CaseApplicationConstants.CASE_APPLICATION);
944 946
         //根据仲裁费用计费规则计算应缴费用
@@ -949,6 +951,15 @@ public class CaseApplicationServiceImpl implements ICaseApplicationService {
949 951
         // 获取自动编码
950 952
         String caseNum = generateCaseNum();
951 953
         caseApplication.setCaseNum(caseNum);
954
+        // 设置批号
955
+        if(StrUtil.isEmpty(caseApplication.getBatchNumber())){
956
+            Integer maxBatchNumber = caseApplicationMapper.selectBatchNumberLike();
957
+            if(maxBatchNumber==null){
958
+                caseApplication.setBatchNumber("1");
959
+            }else {
960
+                caseApplication.setBatchNumber(maxBatchNumber+1+"");
961
+            }
962
+        }
952 963
         caseApplication.setCreateBy(getUsername());
953 964
         caseApplication.setVersion(1);
954 965
         // 新增立案信息
@@ -1016,29 +1027,42 @@ public class CaseApplicationServiceImpl implements ICaseApplicationService {
1016 1027
         insertCaseLog(caseApplication.getId(), CaseApplicationConstants.CASE_APPLICATION, "");
1017 1028
         // 异步新增案件日志
1018 1029
         ThreadPoolUtil.execute(() -> {
1030
+            // 批量新增columnValue自定义字段
1031
+            if(CollectionUtil.isNotEmpty(columnValueList)) {
1032
+                columnValueList.forEach(columnValue -> columnValue.setCaseId(caseApplication.getId()));
1033
+                columnValueMapper.batchSave(columnValueList);
1034
+            }
1035
+            // 新增案件日志表
1019 1036
             caseApplication.setCaseAppliId(caseApplication.getId());
1020 1037
             caseApplication.setUpdateSubmitStatus(UpdateSubmitStatus.UNCOMMITTED.getCode());
1021 1038
             int insertRow = caseApplicationLogMapper.insert(caseApplication);
1039
+            // 插入案件相关人员表日志
1022 1040
             if (insertRow != 0 && CollectionUtil.isNotEmpty(caseAffiliates)) {
1023 1041
                 caseAffiliates.forEach(caseAffiliate -> caseAffiliate.setCaseAppliLogId(caseApplication.getId()));
1024
-                // 插入案件日志人员相关表
1025
-                if (CollectionUtil.isNotEmpty(caseAttachList)) {
1026
-                    List<CaseAttach> filterList = caseAttachList.stream().filter(c -> c.getAnnexType().equals(2)).collect(Collectors.toList());
1027
-                    // 插入日志附件表
1028
-                    if (CollectionUtil.isNotEmpty(filterList)) {
1029
-                        for (CaseAttach caseAttach : filterList) {
1030
-                            // 查询附件表
1031
-                            CaseAttach attach = caseAttachMapper.queryAnnexById(caseAttach.getAnnexId());
1032
-                            attach.setCaseAppliLogId(caseApplication.getId());
1033
-                            caseAttachLogMapper.save(attach);
1034
-                        }
1035
-                    }
1036 1042
 
1037
-                }
1038 1043
                 caseAffiliateLogMapper.batchCaseAffiliate(caseAffiliates);
1039 1044
             }
1040
-            // 新增动态配置字段值表
1041
-            insertColumnValue(fatchMap,caseApplication.getCaseAppliId());
1045
+            // 插入附件表日志
1046
+            if (CollectionUtil.isNotEmpty(caseAttachList)) {
1047
+                List<CaseAttach> filterList = caseAttachList.stream().filter(c -> c.getAnnexType().equals(2)).collect(Collectors.toList());
1048
+                // 插入日志附件表
1049
+                if (CollectionUtil.isNotEmpty(filterList)) {
1050
+                    for (CaseAttach caseAttach : filterList) {
1051
+                        // 查询附件表
1052
+                        CaseAttach attach = caseAttachMapper.queryAnnexById(caseAttach.getAnnexId());
1053
+                        attach.setCaseAppliLogId(caseApplication.getId());
1054
+                        caseAttachLogMapper.save(attach);
1055
+                    }
1056
+                }
1057
+
1058
+            }
1059
+            // 插入columnValueLog自定义字段日志表
1060
+            if (CollectionUtil.isNotEmpty(columnValueList)) {
1061
+                columnValueList.forEach(caseAffiliate -> caseAffiliate.setCaseAppliLogId(caseApplication.getId()));
1062
+                columnValueLogMapper.batchSave(columnValueList);
1063
+
1064
+            }
1065
+
1042 1066
 
1043 1067
         });
1044 1068
 
@@ -1082,8 +1106,13 @@ public class CaseApplicationServiceImpl implements ICaseApplicationService {
1082 1106
         caseApplication.setUpdateBy(getUsername());
1083 1107
         // 立案申请状态直接修改主表信息
1084 1108
         if (caseApplication.getCaseStatus() != null && caseApplication.getCaseStatus().equals(CaseApplicationConstants.CASE_APPLICATION)) {
1085
-
1086
-            caseApplicationMapper.updataCaseApplication(caseApplication);
1109
+            // 修改内置字段
1110
+            if(CollectionUtil.isNotEmpty(caseApplication.getColumnValues())) {
1111
+                caseApplicationMapper.updataCaseApplication(caseApplication);
1112
+            }else {
1113
+                // 修改自定义字段
1114
+                columnValueMapper.batchUpdate(caseApplication.getColumnValues());
1115
+            }
1087 1116
             // 修改记录表状态为同意提交修改的内容
1088 1117
             caseApplication.setUpdateSubmitStatus(0);
1089 1118
         } else {
@@ -1193,6 +1222,12 @@ public class CaseApplicationServiceImpl implements ICaseApplicationService {
1193 1222
                         }
1194 1223
 
1195 1224
                     }
1225
+                    // 插入案件columnValueLog自定义字段表
1226
+                    if (CollectionUtil.isNotEmpty(caseApplication.getColumnValues())) {
1227
+                        caseApplication.getColumnValues().forEach(columnValue -> columnValue.setCaseAppliLogId(caseApplication.getId()));
1228
+
1229
+                        columnValueLogMapper.batchSave(caseApplication.getColumnValues());
1230
+                    }
1196 1231
                 }
1197 1232
             } catch (Exception e) {
1198 1233
                 throw new RuntimeException(e);
@@ -3042,185 +3077,55 @@ public class CaseApplicationServiceImpl implements ICaseApplicationService {
3042 3077
                     }
3043 3078
                 }
3044 3079
                 if (fatchMap.size() <= 0) {
3045
-                  return   error("从压缩包中未抓取到内容,请检查抓取字段配置");
3080
+                  return  error("从压缩包中未抓取到内容,请检查抓取字段配置");
3046 3081
                 }
3047
-
3048
-                    // todo 从压缩包中识别各字段填充到数据库
3049
-                    //调用新增案件的接口
3082
+                  // 组装案件内置字段主表内容
3050 3083
                     CaseApplication caseApplication = new CaseApplication();
3051 3084
                     caseApplication.setTemplateId(templateId);
3052 3085
                     //默认案件标的 todo 案件标的是什么,默认写死
3053 3086
                     caseApplication.setCaseSubjectAmount(new BigDecimal(10000));
3054
-                    // todo 这些以后要去掉,不在案件基本信息表维护,现在往基本信息表设置字段是因为修改以及查询详情的时候页面中字段是固定的,以后也要动态维护字段
3055
-                    // 仲裁请求
3056
-                    caseApplication.setArbitratClaims(fatchMap.get("arbitrationClaims"));
3057
-                    // 事实和理由
3058
-                    caseApplication.setFacts(fatchMap.get("factsAndReason"));
3059
-                    // 合同编号
3060
-                    String contractNumber = fatchMap.get("contractNumber");
3061
-                    if (StrUtil.isNotEmpty(contractNumber)) {
3062
-                        // 提取字母和数字
3063
-                        String regx = "[^a-zA-Z0-9]";
3064
-                        String replaceAll = contractNumber.replaceAll(regx, "");
3065
-
3066
-                        caseApplication.setContractNumber(replaceAll.toUpperCase());
3067
-                    }
3087
+                // todo 从抓取规则表取字段和字典表取基本字段,字典表的字段名塞到基本表,is_default=1自定义字段塞到columnValue
3088
+                // 抓取规则,0-内置字段,1-自定义字段
3089
+                Map<Integer, List<FatchRule>> fatchRuleMap = fatchRuleList.stream().collect(Collectors.groupingBy(FatchRule::getIsDefault));
3090
+                // 自定义字段,组装columnValue表
3091
+                List<ColumnValue> columnValueList = new ArrayList<>();
3092
+                if (fatchRuleMap.size() > 0 && fatchRuleMap.containsKey(1)) {
3093
+                    List<FatchRule> columnRules = fatchRuleMap.get(1);
3094
+                    columnRules.forEach(columnRule -> {
3095
+                        ColumnValue columnValue = new ColumnValue();
3096
+                        columnValue.setColumn(columnRule.getColumn());
3097
+                        columnValue.setName(columnRule.getColumnName());
3098
+                        columnValue.setValue(fatchMap.get(columnRule.getColumnName())); columnValue.setIsDefault(columnRule.getIsDefault());
3099
+                        columnValueList.add(columnValue);
3100
+                    });
3101
+                }
3102
+                // 在系统表中查询案件内置字段
3103
+                SysDictData sysDictData = new SysDictData();
3104
+                sysDictData.setDictType("case_built_type");
3105
+                List<SysDictData> dictDataList = dictDataMapper.selectDictDataList(sysDictData);
3106
+                // 组装内置字段
3107
+                buildDefaultColumn(caseApplication,dictDataList,fatchMap);
3068 3108
                     // 借款开始日期
3069
-                    String lonStartDate = fatchMap.get("lonStartDate:");
3070
-                    SimpleDateFormat sdf = new SimpleDateFormat();
3071
-                    sdf.applyPattern("yyyy年MM月dd日");
3072
-                    if (StrUtil.isNotEmpty(lonStartDate)) {
3073
-                        try {
3074
-                            caseApplication.setLoanStartDate(sdf.parse(lonStartDate));
3075
-                        } catch (ParseException e) {
3076
-                            e.printStackTrace();
3077
-                        }
3078
-                    }
3079
-                    // todo 查询同一批号的模板
3080
-                    // 金融消费纠纷基本情况
3081
-                    String disputes = fatchMap.get("disputes");
3082
-                    caseApplication.setDisputes(disputes);
3083
-//                    String disputesTemplate="本案当事人甲{1}(下称“甲方”)于{2}向本案当事人乙{3}(下称“乙方”)申请{3}贷款,贷款金额人民币{4}元,贷款期限{5}期。截至{6},甲方尚欠乙方金额总计人民币{7}元。因甲方诉求与乙方进行协商还款。乙方为妥善解决纠纷,故申请调解中心进行调解。";
3084
-//                    List<String> disputeList = getReplaceList(disputesTemplate, disputes);
3085
-//                    if(CollectionUtil.isNotEmpty(disputeList)){
3086
-//                        if(disputeList.size()>3){
3087
-//                        caseApplication.setLoanType(disputeList.get(3));
3088
-//                        }
3089
-//                        if(disputeList.size()>4) {
3090
-//                            String claimPrinciOwed = disputeList.get(4);
3091
-//                            // 金额格式化
3092
-//                            try {
3093
-//                                Double.parseDouble(claimPrinciOwed);
3094
-//
3095
-//                                caseApplication.setClaimPrinciOwed(new BigDecimal(claimPrinciOwed));
3096
-//                            } catch (NumberFormatException e) {
3097
-//
3098
-//                                String regEx = "[^0-9]";
3099
-//                                Pattern p = Pattern.compile(regEx);
3100
-//                                Matcher m = p.matcher(claimPrinciOwed);
3101
-//                                String result = m.replaceAll("").trim();
3102
-//                                BigDecimal bigDecimal = null;
3103
-//                                if (claimPrinciOwed.contains("百")) {
3104
-//                                    bigDecimal = new BigDecimal(result).multiply(new BigDecimal("100"));
3105
-//                                } else if (claimPrinciOwed.contains("千")) {
3106
-//                                    bigDecimal = new BigDecimal(result).multiply(new BigDecimal("1000"));
3107
-//                                } else if (claimPrinciOwed.contains("万")) {
3108
-//                                    bigDecimal = new BigDecimal(result).multiply(new BigDecimal("10000"));
3109
-//                                } else if (claimPrinciOwed.contains("百万")) {
3110
-//                                    bigDecimal = new BigDecimal(result).multiply(new BigDecimal("1000000"));
3111
-//                                } else if (claimPrinciOwed.contains("千万")) {
3112
-//                                    bigDecimal = new BigDecimal(result).multiply(new BigDecimal("10000000"));
3113
-//                                } else if (claimPrinciOwed.contains("亿")) {
3114
-//                                    bigDecimal = new BigDecimal(result).multiply(new BigDecimal("100000000"));
3115
-//                                }
3116
-//                                // todo  生产裁决书时金额格式增加千分位
3117
-//                              //  NumberFormat format = NumberFormat.getInstance();
3118
-//                              //  String format1 = format.format(bigDecimal);
3119
-//
3120
-//                                caseApplication.setClaimPrinciOwed(bigDecimal);
3121
-//                            }
3122
-//                        }
3123
-//
3124
-//                        if(disputeList.size()>5){
3125
-//                            caseApplication.setLoanTerm(disputeList.get(5));
3126
-//                        }
3127
-//                    }
3128
-                    // 调解协议内容
3129
-                    String mediationAgreement = fatchMap.get("mediationAgreement");
3130
-                    caseApplication.setMediationAgreement(mediationAgreement);
3131
-//                    String mediationAgreementTemplate="1、乙方从维系客户的角度出发,同意为甲方申请停催至{1},停催期间正常计息,且征信影响由甲方自行承担。2、甲方应于{2}停催到期前向乙方申请费息减免业务,并按人民币{3}元一次性结清剩余贷款。3、今后双方无涉,就此结案。";
3132
-//                    // 对比模板和pdf识别的内容,取出占位符对应的值
3133
-//                    List<String> mediationAgreementList = getReplaceList(mediationAgreementTemplate, mediationAgreement);
3134
-//                    if(CollectionUtil.isNotEmpty(mediationAgreementList)){
3135
-//                        // 截止日期
3136
-//                        String lonEndDate = mediationAgreementList.get(0);
3109
+//                    String lonStartDate = fatchMap.get("借款开始日期:");
3110
+//                    SimpleDateFormat sdf = new SimpleDateFormat("yyyy年MM月dd日");
3111
+//                    if (StrUtil.isNotEmpty(lonStartDate)) {
3137 3112
 //                        try {
3138
-//                            caseApplication.setLoanEndDate( sdf.parse(lonEndDate));
3113
+//                            caseApplication.setLoanStartDate(sdf.parse(lonStartDate));
3139 3114
 //                        } catch (ParseException e) {
3140 3115
 //                            e.printStackTrace();
3141 3116
 //                        }
3142
-//                        if(mediationAgreementList.size()>2){
3143
-//                            // 待还金额
3144
-//                            caseApplication.setOutstandingMoney(mediationAgreementList.get(2));
3145
-//                        }
3146 3117
 //                    }
3147
-                    // 合同甲方(贷款人)
3148
-                    caseApplication.setPartyA(fatchMap.get("partyA"));
3149
-                    List<CaseAffiliate> caseAffiliates = new ArrayList<>();
3150
-                    CaseAffiliate caseAffiliate = new CaseAffiliate();
3151
-                    caseAffiliate.setIdentityType(1);
3152
-                    // 申请人
3153
-                    caseAffiliate.setName(fatchMap.get("applicantName"));
3154
-                    // 统一社会信用代码
3155
-                    caseAffiliate.setIdentityNum(fatchMap.get("creditCode"));
3156
-                    // 法定代表人
3157
-                    caseAffiliate.setCompLegalPerson(fatchMap.get("legalRepresentative"));
3158
-                    // 申请人联系电话
3159
-                    caseAffiliate.setContactTelphone(fatchMap.get("applicantPhone"));
3160
-                    // 申请人住所
3161
-                    caseAffiliate.setResidenAffili(fatchMap.get("applicantHome"));
3162
-                    // 申请人联系地址
3163
-                    caseAffiliate.setContactAddress(fatchMap.get("applicantAddress"));
3164
-//                            // 法定代表人职务
3165
-                   caseAffiliate.setCompLegalperPost(fatchMap.get("compLegalperPost"));
3166
-                    // 委托代理人
3167
-                    caseAffiliate.setNameAgent(fatchMap.get("agentName"));
3168
-                    // 委托代理人联系电话
3169
-                    caseAffiliate.setContactTelphoneAgent(fatchMap.get("agentPhone"));
3170
-
3171
-                    // 代理人电子邮件
3172
-                    caseAffiliate.setAgentEmail(StrUtil.isNotEmpty(fatchMap.get("agentEmail")) ? fatchMap.get("agentEmail").replaceAll("\\s", "") : null);
3173
-
3174
-
3175
-                    //设置默认代理人的身份证号码,暂时写死 要不然新增方法报错
3176
-                    //      caseAffiliate.setIdentityNumAgent("610423199603171716");
3177
-                    caseAffiliates.add(caseAffiliate);
3178
-                    // 被申请人信息
3179
-                    CaseAffiliate respondentAffiliate = new CaseAffiliate();
3180
-                    respondentAffiliate.setIdentityType(2);
3181
-                    // 被申请人名称
3182
-                    respondentAffiliate.setName(fatchMap.get("respondentName"));
3183
-                    // 被申请人身份证
3184
-                    String identityNum = fatchMap.get("respondentCard");
3185
-                    // 出生年月日,从身份证抓取
3186
-                    if (StrUtil.isNotEmpty(identityNum)) {
3187
-                        Map<String, String> identityNumMap = getBirAgeSex(identityNum);
3188
-                        String birthday = identityNumMap.get("birthday");
3189
-                        if (StrUtil.isNotEmpty(birthday)) {
3190
-                            SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
3191
-                            Date birthdayDate = null;
3192
-                            try {
3193
-                                birthdayDate = simpleDateFormat.parse(birthday);
3194
-                            } catch (Exception e) {
3195
-                                e.printStackTrace();
3196
-                            }
3197
-                            fatchMap.put("resDateOfBirth", sdf.format(birthdayDate));
3198
-                            respondentAffiliate.setResponBirth(birthdayDate);
3199
-                        }
3200
-                        //从身份证抓取性别
3201
-                        fatchMap.put("resSex", identityNumMap.get("sexCode"));
3202
-                        respondentAffiliate.setResponSex(identityNumMap.get("sexCode"));
3118
+                // 设置批号
3119
+                if(StrUtil.isEmpty(caseApplication.getBatchNumber())){
3120
+                    Integer maxBatchNumber = caseApplicationMapper.selectBatchNumberLike();
3121
+                    if(maxBatchNumber==null){
3122
+                        caseApplication.setBatchNumber("1");
3123
+                    }else {
3124
+                        caseApplication.setBatchNumber(maxBatchNumber+1+"");
3203 3125
                     }
3204
-                    respondentAffiliate.setIdentityNum(identityNum);
3205
-                    // 被申请人电子邮件
3206
-//                    if(map.get("乙方确认有效的电子信箱地址为").size()>1) {
3207
-//                        if(map.get("乙方确认有效的电子信箱地址为").get(0).contains("/")) {
3208
-//                            respondentAffiliate.setEmail(map.get("乙方确认有效的电子信箱地址为").get(1).replaceAll("\\s", ""));
3209
-//                        }else {
3210
-//                            respondentAffiliate.setEmail(map.get("乙方确认有效的电子信箱地址为").get(0).replaceAll("\\s", ""));
3211
-//                        }
3212
-//                    }
3213
-                    // 被申请人电子邮件
3214
-                    respondentAffiliate.setEmail(StrUtil.isNotEmpty(fatchMap.get("respondentEmail")) ? fatchMap.get("respondentEmail").replaceAll("\\s", "") : null);
3215
-                    // 被申请人联系电话
3216
-                    respondentAffiliate.setContactTelphone(fatchMap.get("respondentPhone"));
3217
-                    // 被申请人住所
3218
-                    respondentAffiliate.setResidenAffili(fatchMap.get("respondentHome"));
3219
-
3220
-                    caseAffiliates.add(respondentAffiliate);
3221
-                    caseApplication.setCaseAffiliates(caseAffiliates);
3126
+                }
3222 3127
                     // 新增案件基本信息表
3223
-                    this.insertcaseApplication(caseApplication, fatchMap);
3128
+                    this.insertcaseApplication(caseApplication, columnValueList);
3224 3129
                     if (null != caseApplication.getId()) {
3225 3130
                         List<CaseAttach> caseAttachs = new ArrayList<>();
3226 3131
                         for (Map.Entry<String, String> entry : andConvertPDF.entrySet()) {
@@ -3254,6 +3159,195 @@ public class CaseApplicationServiceImpl implements ICaseApplicationService {
3254 3159
         return null;
3255 3160
     }
3256 3161
 
3162
+    /**
3163
+     * 组装内置字段
3164
+     * @param caseApplication  案件信息
3165
+     * @param dictDataList 内置字段
3166
+     * @param fatchMap 抓取字段内容
3167
+     */
3168
+    private void buildDefaultColumn(CaseApplication caseApplication, List<SysDictData> dictDataList, Map<String, String> fatchMap) {
3169
+        // 组装内置字段
3170
+        if (CollectionUtil.isEmpty(dictDataList)) {
3171
+            return;
3172
+        }
3173
+        List<CaseAffiliate> caseAffiliates = new ArrayList<>();
3174
+        CaseAffiliate debtorAffiliate = new CaseAffiliate();
3175
+        CaseAffiliate affiliate = new CaseAffiliate();
3176
+        for (SysDictData dictData : dictDataList) {
3177
+            if (StrUtil.isNotEmpty(dictData.getDictLabel())) {
3178
+                if(dictData.getDictLabel().contains("被申请人")) {
3179
+                    // 组装被申请人内置自段
3180
+                    buildDebtorColumn(dictData, fatchMap, debtorAffiliate);
3181
+                }else if( dictData.getDictLabel().contains("申请人")|| dictData.getDictLabel().contains("统一社会信用代码")
3182
+                        || dictData.getDictLabel().contains("法定代表人")|| dictData.getDictLabel().contains("委托代理人")) {
3183
+                    // 组装申请人内置自段
3184
+                    buildAffilcateColumn(dictData, fatchMap, affiliate);
3185
+                }else if( dictData.getDictLabel().contains("合同编号")) {
3186
+                    // 合同编号
3187
+                    String contractNumber = fatchMap.get("合同编号");
3188
+                    if (StrUtil.isNotEmpty(contractNumber)) {
3189
+                        // 提取字母和数字
3190
+                        String regx = "[^a-zA-Z0-9]";
3191
+                        String replaceAll = contractNumber.replaceAll(regx, "");
3192
+                        caseApplication.setContractNumber(replaceAll.toUpperCase());
3193
+                    }
3194
+                }else {
3195
+                    ObjectFieldUtils.setValue(caseApplication, dictData.getDictValue(), fatchMap.get(dictData.getDictLabel()));
3196
+                }
3197
+
3198
+            } else {
3199
+                ObjectFieldUtils.setValue(caseApplication, dictData.getDictValue(), fatchMap.get(dictData.getDictLabel()));
3200
+
3201
+            }
3202
+
3203
+        }
3204
+        if(ObjectUtil.isNotEmpty(debtorAffiliate)){
3205
+            caseAffiliates.add(debtorAffiliate);
3206
+        }
3207
+        if(ObjectUtil.isNotEmpty(affiliate)){
3208
+            caseAffiliates.add(affiliate);
3209
+        }
3210
+        caseApplication.setCaseAffiliates(caseAffiliates);
3211
+
3212
+    }
3213
+    /**
3214
+     * 组装申请人内置字段
3215
+     * @param dictData 内置字段
3216
+     * @param fatchMap 抓取内容
3217
+     * @param affiliate 案件人员
3218
+     */
3219
+    private void buildAffilcateColumn(SysDictData dictData, Map<String, String> fatchMap,   CaseAffiliate affiliate) {
3220
+
3221
+        affiliate.setIdentityType(1);
3222
+
3223
+        // 申请人
3224
+        switch (dictData.getDictLabel()) {
3225
+            case "申请人姓名":
3226
+                affiliate.setName((fatchMap.get(dictData.getDictLabel())));
3227
+                break;
3228
+            case "统一社会信用代码":
3229
+                affiliate.setIdentityNum((fatchMap.get(dictData.getDictLabel())));
3230
+                break;
3231
+            case "法定代表人":
3232
+                affiliate.setCompLegalPerson(fatchMap.get(dictData.getDictLabel()));
3233
+                break;
3234
+            case "法定代表人职位":
3235
+                affiliate.setCompLegalperPost((fatchMap.get(dictData.getDictLabel())));
3236
+                break;
3237
+            case "申请人住所":
3238
+                affiliate.setResidenAffili((fatchMap.get(dictData.getDictLabel())));
3239
+                break;
3240
+            case "申请人联系地址":
3241
+                affiliate.setContactAddress(fatchMap.get(dictData.getDictLabel()));
3242
+                break;
3243
+            case "委托代理人姓名":
3244
+                affiliate.setNameAgent(fatchMap.get(dictData.getDictLabel()));
3245
+                break;
3246
+            case "委托代理人联系电话":
3247
+                affiliate.setContactTelphoneAgent(fatchMap.get(dictData.getDictLabel()));
3248
+                break;
3249
+            case "委托代理人电子邮件":
3250
+                affiliate.setAgentEmail(StrUtil.isNotEmpty(fatchMap.get(dictData.getDictLabel())) ? fatchMap.get(dictData.getDictLabel()).replace("\n","").replaceAll("\\s", "") : null);
3251
+
3252
+                break;
3253
+            default:
3254
+                break;
3255
+        }
3256
+    }
3257
+
3258
+    /**
3259
+     * 组装被申请人内置字段
3260
+     * @param dictData 内置字段
3261
+     * @param fatchMap 抓取内容
3262
+     * @param debtorAffiliate 被申请人
3263
+     */
3264
+    private void buildDebtorColumn(SysDictData dictData, Map<String, String> fatchMap,  CaseAffiliate debtorAffiliate) {
3265
+
3266
+        debtorAffiliate.setIdentityType(2);
3267
+        // 被申请人
3268
+        switch (dictData.getDictLabel()) {
3269
+            case "被申请人姓名":
3270
+                debtorAffiliate.setName(fatchMap.get(dictData.getDictLabel()));
3271
+                break;
3272
+            case "被申请人身份证号":
3273
+                String identityNum = fatchMap.get(dictData.getDictLabel());
3274
+                debtorAffiliate.setIdentityNum(fatchMap.get(dictData.getDictLabel()));
3275
+                // 出生年月日,从身份证抓取
3276
+                if (StrUtil.isNotEmpty(identityNum)) {
3277
+                    identityNum=identityNum.replace("\n","");
3278
+                    Map<String, String> identityNumMap = getBirAgeSex(identityNum);
3279
+                    String birthday = identityNumMap.get("birthday");
3280
+                    if (StrUtil.isNotEmpty(birthday)) {
3281
+                        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
3282
+                        Date birthdayDate = null;
3283
+                        try {
3284
+                            birthdayDate = simpleDateFormat.parse(birthday);
3285
+                        } catch (Exception e) {
3286
+                            e.printStackTrace();
3287
+                        }
3288
+                        debtorAffiliate.setResponBirth(birthdayDate);
3289
+                    }
3290
+                    //从身份证抓取性别
3291
+                    debtorAffiliate.setResponSex(identityNumMap.get("sexCode"));
3292
+                }
3293
+
3294
+                break;
3295
+            case "被申请人住所":
3296
+                debtorAffiliate.setResidenAffili(fatchMap.get(dictData.getDictLabel()));
3297
+                break;
3298
+            case "被申请人联系电话":
3299
+                debtorAffiliate.setContactTelphone(fatchMap.get(dictData.getDictLabel()));
3300
+                break;
3301
+            case "被申请人电子邮件":
3302
+                debtorAffiliate.setEmail(StrUtil.isNotEmpty(fatchMap.get(dictData.getDictLabel())) ? fatchMap.get(dictData.getDictLabel()).replace("\n","").replaceAll("\\s", "") : null);
3303
+
3304
+                break;
3305
+            default:
3306
+                break;
3307
+        }
3308
+
3309
+    }
3310
+
3311
+    /**
3312
+     * 金额格式化,增加千分位
3313
+     * @param money
3314
+     * @return
3315
+     */
3316
+    private String moneyFormat(String money) {
3317
+        // 金额格式化
3318
+        try {
3319
+            Double.parseDouble(money);
3320
+
3321
+        } catch (NumberFormatException e) {
3322
+
3323
+            String regEx = "[^0-9]";
3324
+            Pattern p = Pattern.compile(regEx);
3325
+            Matcher m = p.matcher(money);
3326
+            String result = m.replaceAll("").trim();
3327
+            BigDecimal bigDecimal = null;
3328
+            if (money.contains("百")) {
3329
+                bigDecimal = new BigDecimal(result).multiply(new BigDecimal("100"));
3330
+            } else if (money.contains("千")) {
3331
+                bigDecimal = new BigDecimal(result).multiply(new BigDecimal("1000"));
3332
+            } else if (money.contains("万")) {
3333
+                bigDecimal = new BigDecimal(result).multiply(new BigDecimal("10000"));
3334
+            } else if (money.contains("百万")) {
3335
+                bigDecimal = new BigDecimal(result).multiply(new BigDecimal("1000000"));
3336
+            } else if (money.contains("千万")) {
3337
+                bigDecimal = new BigDecimal(result).multiply(new BigDecimal("10000000"));
3338
+            } else if (money.contains("亿")) {
3339
+                bigDecimal = new BigDecimal(result).multiply(new BigDecimal("100000000"));
3340
+            }
3341
+
3342
+              NumberFormat format = NumberFormat.getInstance();
3343
+              return format.format(bigDecimal);
3344
+
3345
+        }
3346
+        return "";
3347
+    }
3348
+
3349
+
3350
+
3257 3351
     /**
3258 3352
      * 新增动态配置字段值表
3259 3353
      * @param fatchMap
@@ -3327,19 +3421,19 @@ public class CaseApplicationServiceImpl implements ICaseApplicationService {
3327 3421
                 XWPFDocument xdoc = new XWPFDocument(fis);
3328 3422
                 XWPFWordExtractor extractor = new XWPFWordExtractor(xdoc);
3329 3423
                 buffer = extractor.getText();
3330
-
3424
+                sb.append(buffer!=null?buffer:"");
3331 3425
 
3332 3426
 
3333 3427
 //                OPCPackage opcPackage = POIXMLDocument.openPackage(filePath);
3334 3428
 //                XWPFWordExtractor extractor = new XWPFWordExtractor(opcPackage);
3335 3429
 //                buffer = extractor.getText();
3336
-                if(buffer.length() > 0){
3337
-                    //使用换行符分割字符串
3338
-                    String [] arry = buffer.split("\r\n");
3339
-                    for (String string : arry) {
3340
-                        sb.append(string.trim());
3341
-                    }
3342
-                }
3430
+//                if(buffer.length() > 0){
3431
+//                    //使用换行符分割字符串
3432
+//                    String [] arry = buffer.split("\n");
3433
+//                    for (String string : arry) {
3434
+//                        sb.append(string.trim());
3435
+//                    }
3436
+//                }
3343 3437
             } else {
3344 3438
                 return null;
3345 3439
             }
@@ -3379,7 +3473,7 @@ public class CaseApplicationServiceImpl implements ICaseApplicationService {
3379 3473
                 //文件转成base64
3380 3474
                 String base64 = OCRUtils.pdfConvertBase64(pdfUrl);
3381 3475
                 if (base64 == null) {
3382
-                    throw new ServiceException("文件转成base64,转码失败");
3476
+                    throw new ServiceException("pdf转base64失败");
3383 3477
                     //  return false;
3384 3478
                 }
3385 3479
                 StringBuilder ocrText = new StringBuilder(); // 创建一个StringBuilder对象

+ 17
- 17
ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/utils/OCRUtils.java 查看文件

@@ -4,6 +4,7 @@ import cn.hutool.core.collection.CollectionUtil;
4 4
 import cn.hutool.core.util.StrUtil;
5 5
 import com.ruoyi.common.constant.Constants;
6 6
 import com.ruoyi.common.exception.ServiceException;
7
+import com.ruoyi.common.utils.StringUtils;
7 8
 import com.ruoyi.wisdomarbitrate.domain.FatchRule;
8 9
 import com.tencentcloudapi.bsca.v20210811.models.LicenseSummary;
9 10
 import com.tencentcloudapi.common.Credential;
@@ -218,27 +219,26 @@ public class OCRUtils {
218 219
                 if (StrUtil.isEmpty(fatchRule.getStartContent())) {
219 220
                     continue;
220 221
                 }
221
-                // 开始截取字符串 申请人:赵会
222
-                //   String[] startContentSplit = ocrText.split(fatchRule.getStartContent());
223
-                int startFirstIndex = ocrText.indexOf(fatchRule.getStartContent()) + fatchRule.getStartContent().length();
224
-                if(startFirstIndex<0){
225
-                    continue;
226
-                }
227
-                if (ocrText.length() >= startFirstIndex) {
228
-                    ocrText = ocrText.substring(startFirstIndex);
229
-                }
230 222
 
231
-                if (StrUtil.isNotEmpty(fatchRule.getEndContent())) {
232
-                    if(ocrText.indexOf(fatchRule.getEndContent())>=0) {
233
-                        int endFirstIndex = ocrText.indexOf(fatchRule.getEndContent()) + fatchRule.getEndContent().length();
234
-                        if (ocrText.length() >= (endFirstIndex - fatchRule.getEndContent().length())) {
235
-                            fatchMap.put(fatchRule.getColumn(), ocrText.substring(0, endFirstIndex - fatchRule.getEndContent().length()));
236
-                            ocrText = ocrText.substring(endFirstIndex - fatchRule.getEndContent().length());
237
-                        }
223
+                if (StrUtil.isNotEmpty(fatchRule.getStartContent()) && StrUtil.isNotEmpty(fatchRule.getEndContent())) {
224
+                    String s = StringUtils.substringBetween(ocrText, fatchRule.getStartContent(), fatchRule.getEndContent());
225
+                    if(StrUtil.isNotEmpty(s)){
226
+                        fatchMap.put(fatchRule.getColumnName(), StrUtil.trim(s));
227
+                    }else {
228
+                        fatchMap.put(fatchRule.getColumnName(),"");
229
+                    }
230
+
231
+                }else if(StrUtil.isNotEmpty(fatchRule.getStartContent()) && StrUtil.isEmpty(fatchRule.getEndContent())){
232
+                    String s = StringUtils.substringAfter(ocrText,fatchRule.getStartContent());
233
+                    if(StrUtil.isNotEmpty(s)){
234
+                        fatchMap.put(fatchRule.getColumnName(), StrUtil.trim(s));
235
+                    }else {
236
+                        fatchMap.put(fatchRule.getColumnName(),"");
238 237
                     }
239 238
                 }
240 239
             }
241
-
242 240
         }
241
+
242
+
243 243
     }
244 244
 }

+ 24
- 363
ruoyi-system/src/main/resources/mapper/wisdomarbitrate/CaseApplicationMapper.xml 查看文件

@@ -46,13 +46,9 @@
46 46
         <result property="properPreser"   column="proper_preser"  />
47 47
         <result property="adjudicaCounter"   column="adjudica_counter"  />
48 48
         <result property="lockStatus"   column="lock_status"  />
49
-        <result property="interestRate"   column="interest_rate"  />
50
-        <result property="outstandingMoney"   column="outstanding_money"  />
51 49
         <result property="facts"   column="facts"  />
52
-        <result property="partyA"   column="party_a"  />
53
-        <result property="disputes"   column="disputes"  />
54
-        <result property="loanType"   column="loan_type"  />
55
-        <result property="loanTerm"   column="loan_term"  />
50
+
51
+        <result property="batchNumber"   column="batch_number"  />
56 52
         <result property="mediationAgreement"   column="mediation_agreement"  />
57 53
     </resultMap>
58 54
 
@@ -63,7 +59,7 @@
63 59
         t1.loan_start_date,t1.loan_end_date,t1.claim_princi_owed,t1.claim_interest_owed,t1.claim_liquid_damag,t1.fee_payable,
64 60
         t1.begin_video_date,t1.online_video_person,t1.contract_number,t1.create_by,t1.create_time,t1.update_by,t1.update_time,
65 61
         t1.arbitrator_name,t1.name,t1.application_organ_id,t1.applicantName,t1.arbitrator_id,t1.identity_num,t1.identity_type,
66
-        t1.filearbitra_url,t1.lock_status,t1.version,t1.updateSubmitStatus
62
+        t1.filearbitra_url,t1.lock_status,t1.version,t1.updateSubmitStatus,t1.batch_number
67 63
         from(
68 64
         <trim suffixOverrides="union">
69 65
             <!--申请人,被申请人,仲裁员,部门长,财务,代理人案件-->
@@ -76,7 +72,7 @@
76 72
                 t.begin_video_date ,t.online_video_person ,t.contract_number ,t.create_by ,t.create_time ,
77 73
                 t.update_by ,t.update_time , t.arbitrator_name,t.name,t.application_organ_id,t.applicantName,
78 74
                 t.arbitrator_id,t.identity_num ,
79
-                t.identity_type,t.filearbitra_url,t.lock_status,t.version,t.updateSubmitStatus
75
+                t.identity_type,t.filearbitra_url,t.lock_status,t.version,t.updateSubmitStatus,t.batch_number
80 76
                 from(
81 77
                 select c.id ,'' AS caseLogId,c.case_num ,c.case_subject_amount ,c.register_date ,c.arbitrat_method ,
82 78
                 CASE c.arbitrat_method when 1 then '开庭审理' when 2 then '书面审理'
@@ -100,7 +96,7 @@
100 96
                 c.update_by ,c.update_time , c.arbitrator_name,ca.name,ca.application_organ_id,ca.application_organ_name
101 97
                 as applicantName,
102 98
                 c.arbitrator_id,ca.identity_num ,ca.identity_type,c.filearbitra_url,c.lock_status,c.version,null as
103
-                updateSubmitStatus
99
+                updateSubmitStatus,c.batch_number
104 100
                 from case_application c
105 101
                 JOIN case_affiliate ca ON ca.case_appli_id = c.id
106 102
                 <!--查询条件-->
@@ -207,7 +203,7 @@
207 203
                 c.arbitrator_id,ca.identity_num , ca.identity_type,c.filearbitra_url,c.lock_status,(select version from
208 204
                 case_application_log where case_appli_id=c.id order by version desc limit 1) as version,(select
209 205
                 update_submit_status from case_application_log where case_appli_id=c.id order by version desc limit 1)
210
-                as updateSubmitStatus
206
+                as updateSubmitStatus,c.batch_number
211 207
                 from case_application c
212 208
                 JOIN case_affiliate ca ON ca.case_appli_id =c.id AND ca.identity_type = 1
213 209
 
@@ -287,7 +283,8 @@
287 283
                 c.arbitrator_id,ca.identity_num ,ca.identity_type,
288 284
                 c.filearbitra_url,
289 285
                 c.lock_status,c.version,
290
-                null as updateSubmitStatus
286
+                null as updateSubmitStatus,
287
+                c.batch_number
291 288
                 FROM
292 289
                 case_application c
293 290
                 JOIN case_affiliate ca ON ca.case_appli_id = c.id AND ca.identity_type = 1
@@ -382,7 +379,7 @@
382 379
                 ca.application_organ_id ,
383 380
                 ca.application_organ_name AS applicantName,
384 381
                 c.arbitrator_id,ca.identity_num ,ca.identity_type,
385
-                c.filearbitra_url,c.lock_status,l.version,l.update_submit_status as updateSubmitStatus
382
+                c.filearbitra_url,c.lock_status,l.version,l.update_submit_status as updateSubmitStatus,c.batch_number
386 383
                 FROM
387 384
                 case_application c
388 385
                 JOIN case_application_log l ON c.id = l.case_appli_id
@@ -814,7 +811,7 @@
814 811
         c.update_by ,c.update_time , c.arbitrator_name,ca.application_organ_id applicationOrganId ,ca.application_organ_name as applicantName,c.filearbitra_url,(select version from
815 812
         case_application_log where case_appli_id=c.id order by version desc limit 1) as version,(select
816 813
         update_submit_status from case_application_log where case_appli_id=c.id order by version desc limit 1)
817
-        as updateSubmitStatus
814
+        as updateSubmitStatus,c.batch_number
818 815
         from case_application c
819 816
         JOIN case_affiliate ca ON ca.case_appli_id = c.id AND ca.identity_type=1
820 817
         JOIN case_application_log l ON c.id = l.case_appli_id and c.version=l.version
@@ -902,328 +899,6 @@
902 899
             </if>
903 900
         </where>
904 901
     </select>
905
-    <select id="selectApplicationCase" resultMap="CaseApplicationResult">
906
-        SELECT
907
-        l.case_appli_id id,
908
-        l.id AS caseLogId,
909
-        l.version,
910
-        l.case_num,
911
-        l.case_subject_amount,
912
-        c.register_date,
913
-        c.arbitrat_method,
914
-        CASE
915
-        c.arbitrat_method
916
-        WHEN 1 THEN
917
-        '开庭审理'
918
-        WHEN 2 THEN
919
-        '书面审理' ELSE '无审理方式'
920
-        END arbitratMethodName,
921
-        c.case_status,
922
-        CASE
923
-        c.case_status
924
-        when 0 then '立案申请' when 1 then '待立案审查' when 2 then '待缴费'
925
-        when 3 then '待缴费确认' when 4 then '待案件质证' when 5 then '待组庭审核'
926
-        when 6 then '待组庭确定' when 7 then '待审核仲裁方式' when 8 then '待开庭审理'
927
-        when 9 then '待书面审理' when 10 then '待生成仲裁文书' when 11 then '待核验仲裁文书'
928
-        when 12 then '待部门长审核仲裁文书' when 13 then '待仲裁文书签名' when 14 then '待仲裁文书用印'
929
-        when 15 then '待仲裁文书送达' when 16 then '待案件归档' when 17 then '已归档'
930
-        when 18 then '待仲裁员审核仲裁文书'
931
-        when 31 then '待修改开庭时间' ELSE '无案件状态'
932
-        END caseStatusName,
933
-        c.hear_date,
934
-        l.arbitrat_claims,
935
-        l.loan_start_date,
936
-        l.loan_end_date,
937
-        l.claim_princi_owed,
938
-        l.claim_interest_owed,
939
-        l.claim_liquid_damag,
940
-        l.fee_payable,
941
-        c.begin_video_date,
942
-        c.online_video_person,
943
-        l.contract_number,
944
-        l.create_by,
945
-        c.create_time,
946
-        c.lock_status,
947
-        l.update_by,
948
-        l.update_time,
949
-        c.arbitrator_name,
950
-        ca.application_organ_id applicationOrganId,
951
-        ca.application_organ_name AS applicantName,
952
-        c.filearbitra_url,l.update_submit_status as updateSubmitStatus,l.case_name
953
-        FROM
954
-        case_application c
955
-        JOIN case_application_log l ON c.id = l.case_appli_id
956
-        JOIN case_affiliate_log ca ON ca.case_appli_log_id = l.id
957
-        AND ca.identity_type = 1
958
-        WHERE
959
-        ca.identity_type=1
960
-
961
-        <if test="applicationOrganId != null and applicationOrganId != ''">
962
-            or ( t.application_organ_id = #{applicationOrganId} AND t.identity_type=1
963
-            <!--暂时改为可以查询到生成裁决书之前所有的案件状态-->
964
-            and (t.case_status &lt;= 10 or t.case_status=31))
965
-            <!-- and t.case_status in (0,2,17))-->
966
-
967
-        </if>
968
-        <if test="caseStatus != null">
969
-            AND c.case_status = #{caseStatus}
970
-        </if>
971
-        <if test="lockStatus != null">
972
-            AND c.lock_status = #{lockStatus}
973
-        </if>
974
-        <if test="caseNum != null and caseNum != ''">
975
-            AND c.case_num = #{caseNum}
976
-        </if>
977
-        <if test="nameId != null and nameId != ''">
978
-            AND ca.application_organ_id=#{nameId}  AND ca.identity_type=1
979
-        </if>
980
-        <!--                    <if test="caseStatusList != null and caseStatusList.size() > 0">-->
981
-        <!--                        and c.case_status in (1,5)-->
982
-        <!--                    </if>-->
983
-        <!-- 查询该案件的最新记录 -->
984
-        AND l.version = (
985
-        SELECT
986
-        max( version ) version
987
-        FROM
988
-        case_application_log
989
-        WHERE case_appli_id = t.id
990
-        update_submit_status IN ( 1, 2 ))
991
-        order by c.create_time desc,c.case_num desc
992
-    </select>
993
-    <select id="selectSecretaryCase" parameterType="CaseApplication" resultMap="CaseApplicationResult">
994
-        SELECT
995
-        t.id,
996
-        t.caseLogId,
997
-        max( version ) version,
998
-        t.case_num,
999
-        t.case_subject_amount,
1000
-        t.register_date,
1001
-        t.arbitrat_method,
1002
-        t.caseStatusName,
1003
-        t.hear_date,
1004
-        t.arbitrat_claims,
1005
-        t.loan_start_date,
1006
-        t.loan_end_date,
1007
-        t.claim_princi_owed,
1008
-        t.claim_interest_owed,
1009
-        t.claim_liquid_damag,
1010
-        t.fee_payable,
1011
-        t.begin_video_date,
1012
-        t.online_video_person,
1013
-        t.contract_number,
1014
-        t.create_by,
1015
-        t.create_time,
1016
-        t.lock_status,
1017
-        t.update_by,
1018
-        t.update_time,
1019
-        t.arbitrator_name,
1020
-        t.applicationOrganId,
1021
-        t.applicantName,
1022
-        t.filearbitra_url,
1023
-        t.updateSubmitStatus,t.case_name
1024
-        FROM
1025
-        (
1026
-        <!-- 查询案件主表 -->
1027
-        SELECT
1028
-        c.id,
1029
-        '' AS caseLogId,
1030
-        c.version,
1031
-        c.case_num,
1032
-        c.case_subject_amount,
1033
-        c.register_date,
1034
-        c.arbitrat_method,
1035
-        CASE
1036
-        c.arbitrat_method
1037
-        WHEN 1 THEN
1038
-        '开庭审理'
1039
-        WHEN 2 THEN
1040
-        '书面审理' ELSE '无审理方式'
1041
-        END arbitratMethodName,
1042
-        c.case_status,
1043
-        CASE
1044
-        c.case_status
1045
-        when 0 then '立案申请' when 1 then '待立案审查' when 2 then '待缴费'
1046
-        when 3 then '待缴费确认' when 4 then '待案件质证' when 5 then '待组庭审核'
1047
-        when 6 then '待组庭确定' when 7 then '待审核仲裁方式' when 8 then '待开庭审理'
1048
-        when 9 then '待书面审理' when 10 then '待生成仲裁文书' when 11 then '待核验仲裁文书'
1049
-        when 12 then '待部门长审核仲裁文书' when 13 then '待仲裁文书签名' when 14 then '待仲裁文书用印'
1050
-        when 15 then '待仲裁文书送达' when 16 then '待案件归档' when 17 then '已归档'
1051
-        when 18 then '待仲裁员审核仲裁文书'
1052
-        when 31 then '待修改开庭时间' ELSE '无案件状态'
1053
-        END caseStatusName,
1054
-        c.hear_date,
1055
-        c.arbitrat_claims,
1056
-        c.loan_start_date,
1057
-        c.loan_end_date,
1058
-        c.claim_princi_owed,
1059
-        c.claim_interest_owed,
1060
-        c.claim_liquid_damag,
1061
-        c.fee_payable,
1062
-        c.begin_video_date,
1063
-        c.online_video_person,
1064
-        c.contract_number,
1065
-        c.create_by,
1066
-        c.create_time,
1067
-        c.lock_status,
1068
-        c.update_by,
1069
-        c.update_time,
1070
-        c.arbitrator_name,
1071
-        ca.application_organ_id applicationOrganId,
1072
-        ca.application_organ_name AS applicantName,
1073
-        c.filearbitra_url,null as updateSubmitStatus,c.case_name
1074
-        FROM
1075
-        case_application c
1076
-        JOIN case_affiliate ca ON ca.case_appli_id = c.id AND ca.identity_type = 1
1077
-        JOIN case_application_log l on l.case_appli_id=c.id and l.update_submit_status not in(1, 2) and    l.version = (
1078
-        SELECT
1079
-        max( version ) version
1080
-        FROM
1081
-        case_application_log
1082
-        WHERE case_appli_id = c.id
1083
-        update_submit_status IN ( 1, 2 ))
1084
-        WHERE
1085
-        ca.identity_type=1 and c.case_status in (1,5)
1086
-        <if test="deptIds != null and deptIds.size() > 0">
1087
-            and ca.application_organ_id in
1088
-            <foreach item="item" collection="deptIds" open="(" separator="," close=")">
1089
-                #{item}
1090
-            </foreach>
1091
-        </if>
1092
-        <if test="caseStatus != null">
1093
-            AND c.case_status = #{caseStatus}
1094
-        </if>
1095
-        <if test="lockStatus != null">
1096
-            AND c.lock_status = #{lockStatus}
1097
-        </if>
1098
-        <if test="caseNum != null and caseNum != ''">
1099
-            AND c.case_num = #{caseNum}
1100
-        </if>
1101
-        <if test="nameId != null and nameId != ''">
1102
-            AND ca.application_organ_id=#{nameId}  AND ca.identity_type=1
1103
-        </if>
1104
-
1105
-        UNION
1106
-        <!-- 查询案件记录表修改提交申请和撤销申请的案件 -->
1107
-        SELECT
1108
-        l.case_appli_id id,
1109
-        l.id AS caseLogId,
1110
-        l.version,
1111
-        l.case_num,
1112
-        l.case_subject_amount,
1113
-        c.register_date,
1114
-        c.arbitrat_method,
1115
-        CASE
1116
-        c.arbitrat_method
1117
-        WHEN 1 THEN
1118
-        '开庭审理'
1119
-        WHEN 2 THEN
1120
-        '书面审理' ELSE '无审理方式'
1121
-        END arbitratMethodName,
1122
-        c.case_status,
1123
-        CASE
1124
-        c.case_status
1125
-        when 0 then '立案申请' when 1 then '待立案审查' when 2 then '待缴费'
1126
-        when 3 then '待缴费确认' when 4 then '待案件质证' when 5 then '待组庭审核'
1127
-        when 6 then '待组庭确定' when 7 then '待审核仲裁方式' when 8 then '待开庭审理'
1128
-        when 9 then '待书面审理' when 10 then '待生成仲裁文书' when 11 then '待核验仲裁文书'
1129
-        when 12 then '待部门长审核仲裁文书' when 13 then '待仲裁文书签名' when 14 then '待仲裁文书用印'
1130
-        when 15 then '待仲裁文书送达' when 16 then '待案件归档' when 17 then '已归档'
1131
-        when 18 then '待仲裁员审核仲裁文书'
1132
-        when 31 then '待修改开庭时间' ELSE '无案件状态'
1133
-        END caseStatusName,
1134
-        c.hear_date,
1135
-        l.arbitrat_claims,
1136
-        l.loan_start_date,
1137
-        l.loan_end_date,
1138
-        l.claim_princi_owed,
1139
-        l.claim_interest_owed,
1140
-        l.claim_liquid_damag,
1141
-        l.fee_payable,
1142
-        c.begin_video_date,
1143
-        c.online_video_person,
1144
-        l.contract_number,
1145
-        l.create_by,
1146
-        c.create_time,
1147
-        c.lock_status,
1148
-        l.update_by,
1149
-        l.update_time,
1150
-        c.arbitrator_name,
1151
-        ca.application_organ_id applicationOrganId,
1152
-        ca.application_organ_name AS applicantName,
1153
-        c.filearbitra_url,l.update_submit_status as updateSubmitStatus,l.case_name
1154
-        FROM
1155
-        case_application c
1156
-        JOIN case_application_log l ON c.id = l.case_appli_id
1157
-        JOIN case_affiliate_log ca ON ca.case_appli_log_id = l.id
1158
-        AND ca.identity_type = 1
1159
-        WHERE
1160
-        l.update_submit_status IN ( 1, 2 ) and  ca.identity_type=1
1161
-        <if test="deptIds != null and deptIds.size() > 0">
1162
-            and ca.application_organ_id in
1163
-            <foreach item="item" collection="deptIds" open="(" separator="," close=")">
1164
-                #{item}
1165
-            </foreach>
1166
-        </if>
1167
-        <if test="caseStatus != null">
1168
-            AND c.case_status = #{caseStatus}
1169
-        </if>
1170
-        <if test="lockStatus != null">
1171
-            AND c.lock_status = #{lockStatus}
1172
-        </if>
1173
-        <if test="caseNum != null and caseNum != ''">
1174
-            AND c.case_num = #{caseNum}
1175
-        </if>
1176
-        <if test="nameId != null and nameId != ''">
1177
-            AND ca.application_organ_id=#{nameId}  AND ca.identity_type=1
1178
-        </if>
1179
-        <!--                    <if test="caseStatusList != null and caseStatusList.size() > 0">-->
1180
-        <!--                        and c.case_status in (1,5)-->
1181
-        <!--                    </if>-->
1182
-        <!-- 查询该案件的最新记录 -->
1183
-        AND l.version = (
1184
-        SELECT
1185
-        max( version ) version
1186
-        FROM
1187
-        case_application_log
1188
-        WHERE
1189
-        update_submit_status IN ( 1, 2 ))
1190
-        ) t
1191
-        GROUP BY
1192
-        t.id,
1193
-        t.caseLogId,
1194
-        t.version,
1195
-        t.case_num,
1196
-        t.case_subject_amount,
1197
-        t.register_date,
1198
-        t.arbitrat_method,
1199
-        t.caseStatusName,
1200
-        t.hear_date,
1201
-        t.arbitrat_claims,
1202
-        t.loan_start_date,
1203
-        t.loan_end_date,
1204
-        t.claim_princi_owed,
1205
-        t.claim_interest_owed,
1206
-        t.claim_liquid_damag,
1207
-        t.fee_payable,
1208
-        t.begin_video_date,
1209
-        t.online_video_person,
1210
-        t.contract_number,
1211
-        t.create_by,
1212
-        t.create_time,
1213
-        t.lock_status,
1214
-        t.update_by,
1215
-        t.update_time,
1216
-        t.arbitrator_name,
1217
-        t.applicationOrganId,
1218
-        t.applicantName,
1219
-        t.filearbitra_url,
1220
-        t.updateSubmitStatus,
1221
-        t.case_name
1222
-        ORDER BY
1223
-        t.create_time DESC,
1224
-        t.case_num DESC
1225
-
1226
-    </select>
1227 902
     <insert id="insertCaseApplication" parameterType="CaseApplication" useGeneratedKeys="true" keyProperty="id">
1228 903
         insert into case_application(
1229 904
         <if test="caseName != null  and caseName != ''">case_name ,</if>
@@ -1254,14 +929,9 @@
1254 929
         <if test="importFlag != null ">import_flag,</if>
1255 930
         <if test="version != null ">version,</if>
1256 931
         <if test="templateId != null ">template_id,</if>
1257
-        interest_rate,
1258
-        outstanding_money,
1259 932
         facts,
1260
-        party_a,
1261
-        disputes,
1262
-        loan_type,
1263
-        loan_term,
1264 933
         mediation_agreement,
934
+        batch_number,
1265 935
         create_time
1266 936
         )values(
1267 937
         <if test="caseName != null and caseName != ''">#{caseName},</if>
@@ -1292,14 +962,10 @@
1292 962
         <if test="importFlag != null ">#{importFlag},</if>
1293 963
         <if test="version != null ">#{version},</if>
1294 964
         <if test="templateId != null ">#{templateId},</if>
1295
-        #{interestRate},
1296
-        #{outstandingMoney},
965
+
1297 966
         #{facts},
1298
-        #{partyA},
1299
-        #{disputes},
1300
-        #{loanType},
1301
-        #{loanTerm},
1302 967
         #{mediationAgreement},
968
+        #{batchNumber},
1303 969
         sysdate()
1304 970
         )
1305 971
     </insert>
@@ -1333,13 +999,7 @@
1333 999
             <if test="updateBy != null  and updateBy != ''">update_by = #{updateBy},</if>
1334 1000
             <if test="caseNum != null and caseNum != ''">case_num = #{caseNum},</if>
1335 1001
             <if test="version != null ">version = #{version},</if>
1336
-            <if test="interestRate != null and interestRate != ''">interest_rate = #{interestRate},</if>
1337
-            <if test="outstandingMoney != null and outstandingMoney != ''">outstanding_money = #{outstandingMoney},</if>
1338
-            <if test="facts != null and facts != ''">facts = #{facts},</if>
1339
-            <if test="partyA != null and partyA != ''">party_a = #{partyA},</if>
1340
-            <if test="disputes != null and disputes != ''">disputes = #{disputes},</if>
1341
-            <if test="loanType != null and loanType != ''">loan_type = #{loanType},</if>
1342
-            <if test="loanTerm != null and loanTerm != ''">loan_term = #{loanTerm},</if>
1002
+             <if test="facts != null and facts != ''">facts = #{facts},</if>
1343 1003
             <if test="mediationAgreement != null and mediationAgreement != ''">mediation_agreement = #{mediationAgreement},</if>
1344 1004
             update_time = sysdate()
1345 1005
         </set>
@@ -1425,13 +1085,8 @@
1425 1085
         c.begin_video_date ,c.online_video_person ,c.contract_number ,c.create_by ,c.create_time ,c.request_rule,c.adjudica_counter,c.proper_preser,
1426 1086
         c.is_absence ,c.respon_cross_opin ,c.applica_cross_opin ,c.respon_defen_opini ,
1427 1087
         c.update_by ,c.update_time,c.arbitrator_id,c.arbitrator_name,ca.application_organ_id applicationOrganId ,ca.application_organ_name as applicantName,
1428
-        c.interest_rate,
1429
-        c.outstanding_money,
1088
+        c.batch_number,
1430 1089
         c.facts,
1431
-        c.party_a,
1432
-        c.disputes,
1433
-        c.loan_type,
1434
-        c.loan_term,
1435 1090
         c.mediation_agreement,c.template_id templateId
1436 1091
         from case_application c
1437 1092
         LEFT JOIN case_affiliate ca ON ca.case_appli_id = c.id and ca.identity_type=1
@@ -1463,7 +1118,10 @@
1463 1118
         c.loan_start_date ,c.loan_end_date ,c.claim_princi_owed ,c.claim_interest_owed ,c.claim_liquid_damag ,c.fee_payable ,
1464 1119
         c.begin_video_date ,c.online_video_person ,c.contract_number ,c.create_by ,c.create_time ,c.request_rule,c.adjudica_counter,c.proper_preser,
1465 1120
         c.is_absence ,c.respon_cross_opin ,c.applica_cross_opin ,c.respon_defen_opini ,
1466
-        c.update_by ,c.update_time,c.arbitrator_id,c.arbitrator_name,ca.application_organ_id applicationOrganId ,ca.application_organ_name as applicantName
1121
+        c.update_by ,c.update_time,c.arbitrator_id,c.arbitrator_name,ca.application_organ_id applicationOrganId ,ca.application_organ_name as applicantName,
1122
+        c.batch_number,
1123
+        c.facts,
1124
+        c.mediation_agreement,c.template_id templateId
1467 1125
         from case_application c
1468 1126
         LEFT JOIN case_affiliate ca ON ca.case_appli_id = c.id and ca.identity_type=1
1469 1127
 
@@ -1492,7 +1150,7 @@
1492 1150
         when 31 then '待修改开庭时间'
1493 1151
                                   ELSE '无案件状态'
1494 1152
                    END caseStatusName,
1495
-               c.hear_date ,c.arbitrat_claims ,
1153
+               c.hear_date ,c.arbitrat_claims , c.batch_number,c.facts,c.mediation_agreement,c.template_id templateId,
1496 1154
                c.loan_start_date ,c.loan_end_date ,c.claim_princi_owed ,c.claim_interest_owed ,c.claim_liquid_damag ,c.fee_payable ,
1497 1155
                c.begin_video_date ,c.online_video_person ,c.contract_number ,c.create_by ,c.create_time ,
1498 1156
                c.update_by ,c.update_time,c.arbitrator_id,c.arbitrator_name,
@@ -1521,7 +1179,10 @@
1521 1179
         select max(room_id+1) as maxRoomId
1522 1180
         from reserved_conference ;
1523 1181
     </select>
1524
-
1182
+    <select id="selectBatchNumberLike" resultType="java.lang.Integer">
1183
+        select max(batch_number) as maxBatchNumber
1184
+        from case_application ;
1185
+    </select>
1525 1186
 
1526 1187
 
1527 1188
 </mapper>

+ 50
- 0
ruoyi-system/src/main/resources/mapper/wisdomarbitrate/ColumnValueLogMapper.xml 查看文件

@@ -0,0 +1,50 @@
1
+<?xml version="1.0" encoding="UTF-8" ?>
2
+<!DOCTYPE mapper
3
+        PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
4
+        "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
5
+<mapper namespace="com.ruoyi.wisdomarbitrate.mapper.ColumnValueLogMapper">
6
+    <resultMap id="BaseResultMap" type="com.ruoyi.wisdomarbitrate.domain.vo.ColumnValue" >
7
+        <result column="id" property="id" />
8
+        <result column="column" property="column" />
9
+        <result column="name" property="name" />
10
+        <result column="value" property="value" />
11
+        <result column="case_appli_log_id" property="caseAppliLogId" />
12
+    </resultMap>
13
+    <insert id="batchSave">
14
+        INSERT INTO column_value_log ( `COLUMN`, `NAME`, `VALUE`, case_appli_log_id )
15
+        values
16
+        <foreach item="item" index="index" collection="list" separator=",">
17
+
18
+        (#{item.column},#{item.name},#{item.value},#{item.caseAppliLogId})
19
+        </foreach>
20
+    </insert>
21
+    <select id="listBycaseAppliLogId" resultMap="BaseResultMap">
22
+        select * from column_value_log where case_appli_log_id=#{caseAppliLogId}
23
+    </select>
24
+    <update id="batchUpdate">
25
+        <foreach collection="list" item="item" >
26
+            update  column_value_log
27
+            <set>
28
+                <if test="item.value != null and item.value != ''">
29
+                    `VALUE` = #{item.value},
30
+                </if>
31
+                `id`=#{item.id}
32
+            </set>
33
+            where `COLUMN`=#{item.column} and `NAME`=#{item.name} and case_appli_log_id=#{item.caseAppliLogId};
34
+        </foreach>
35
+    </update>
36
+    <select id="queryColumnValueList"  parameterType="ColumnValue"  resultMap="BaseResultMap">
37
+        select * from column_value_log c
38
+        <where>
39
+            <if test="caseAppliLogId != null">
40
+                AND c.case_appli_log_id  = #{caseAppliLogId}
41
+            </if>
42
+            <if test="isDefault != null">
43
+                AND c.is_default  = #{isDefault}
44
+            </if>
45
+
46
+        </where>
47
+    </select>
48
+
49
+
50
+</mapper>

+ 12
- 0
ruoyi-system/src/main/resources/mapper/wisdomarbitrate/ColumnValueMapper.xml 查看文件

@@ -18,6 +18,18 @@
18 18
         (#{item.column},#{item.name},#{item.value},#{item.caseId})
19 19
         </foreach>
20 20
     </insert>
21
+    <update id="batchUpdate">
22
+        <foreach collection="list" item="item" >
23
+            update  column_value
24
+            <set>
25
+                <if test="item.value != null and item.value != ''">
26
+                    `VALUE` = #{item.value},
27
+                </if>
28
+                `id`=#{item.id}
29
+            </set>
30
+            where id=#{item.id};
31
+        </foreach>
32
+    </update>
21 33
     <select id="listByCaseId" resultMap="BaseResultMap">
22 34
         select * from column_value where case_id=#{caseId}
23 35
     </select>

+ 1
- 0
ruoyi-system/src/main/resources/mapper/wisdomarbitrate/FatchRuleMapper.xml 查看文件

@@ -11,6 +11,7 @@
11 11
         <result column="end_content" property="endContent" />
12 12
         <result column="column" property="column" />
13 13
         <result column="column_name" property="columnName" />
14
+        <result column="is_default" property="isDefault" />
14 15
     </resultMap>
15 16
     <select id="listByTemplateId" resultMap="BaseResultMap">
16 17
         select fr.* from fatch_rule fr join template_fatch_rule tfr on fr.id=tfr.fatch_rule_id