Pārlūkot izejas kodu

工具类,案件压缩包导入优化

18792927508 2 gadus atpakaļ
vecāks
revīzija
a78e3e23d6
28 mainītis faili ar 1836 papildinājumiem un 1056 dzēšanām
  1. 1
    1
      ruoyi-admin/src/main/java/com/ruoyi/web/controller/wisdomarbitrate/CaseApplicationController.java
  2. 57
    0
      ruoyi-common/src/main/java/com/ruoyi/common/utils/IdCardUtils.java
  3. 48
    0
      ruoyi-common/src/main/java/com/ruoyi/common/utils/IdWorkerUtil.java
  4. 53
    0
      ruoyi-common/src/main/java/com/ruoyi/common/utils/MoneyFormatUtils.java
  5. 86
    0
      ruoyi-common/src/main/java/com/ruoyi/common/utils/ReadFileUtils.java
  6. 34
    0
      ruoyi-common/src/main/java/com/ruoyi/common/utils/SpringUtil.java
  7. 14
    0
      ruoyi-common/src/main/java/com/ruoyi/common/utils/file/FileUtils.java
  8. 46
    1
      ruoyi-common/src/main/java/com/ruoyi/common/utils/thread/MultipleThreadWorkUtil.java
  9. 7
    0
      ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysDeptMapper.java
  10. 6
    1
      ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysUserMapper.java
  11. 2
    0
      ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/mapper/CaseApplicationLogMapper.java
  12. 6
    0
      ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/mapper/CaseApplicationMapper.java
  13. 1
    0
      ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/mapper/CaseAttachLogMapper.java
  14. 1
    1
      ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/mapper/ColumnValueLogMapper.java
  15. 1
    1
      ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/mapper/ColumnValueMapper.java
  16. 7
    0
      ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/service/IAdjudicationService.java
  17. 1
    1
      ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/service/ICaseApplicationService.java
  18. 30
    0
      ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/service/impl/AdjudicationServiceImpl.java
  19. 24
    985
      ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/service/impl/CaseApplicationServiceImpl.java
  20. 328
    0
      ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/service/impl/CaseImportValid.java
  21. 811
    0
      ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/service/impl/CaseZipImportImpl.java
  22. 48
    58
      ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/utils/OCRUtils.java
  23. 35
    2
      ruoyi-system/src/main/resources/mapper/system/SysDeptMapper.xml
  24. 43
    3
      ruoyi-system/src/main/resources/mapper/system/SysUserMapper.xml
  25. 1
    1
      ruoyi-system/src/main/resources/mapper/wisdomarbitrate/CaseAffiliateLogMapper.xml
  26. 62
    0
      ruoyi-system/src/main/resources/mapper/wisdomarbitrate/CaseApplicationLogMapper.xml
  27. 76
    1
      ruoyi-system/src/main/resources/mapper/wisdomarbitrate/CaseApplicationMapper.xml
  28. 7
    0
      ruoyi-system/src/main/resources/mapper/wisdomarbitrate/CaseAttachLogMapper.xml

+ 1
- 1
ruoyi-admin/src/main/java/com/ruoyi/web/controller/wisdomarbitrate/CaseApplicationController.java Parādīt failu

@@ -78,7 +78,7 @@ public class CaseApplicationController extends BaseController {
78 78
     {
79 79
 
80 80
         caseApplication.setCreateBy(getUsername());
81
-        return toAjax(caseApplicationService.insertcaseApplication(caseApplication,null));
81
+        return toAjax(caseApplicationService.insertcaseApplication(caseApplication));
82 82
     }
83 83
 
84 84
     /**

+ 57
- 0
ruoyi-common/src/main/java/com/ruoyi/common/utils/IdCardUtils.java Parādīt failu

@@ -0,0 +1,57 @@
1
+package com.ruoyi.common.utils;
2
+
3
+import java.util.Calendar;
4
+import java.util.HashMap;
5
+import java.util.Map;
6
+
7
+/**
8
+ * @author wangqiong
9
+ * @description 根据身份证号提取有效信息
10
+ * @date 2023-12-11 11:45
11
+ */
12
+public class IdCardUtils {
13
+    /**
14
+     * 通过身份证号码获取出生日期、性别、年龄
15
+     * @param certificateNo
16
+     * @return 返回的出生日期格式:1990-01-01   性别格式:1-女,0-男
17
+     */
18
+    public static Map<String, String> getBirAgeSex(String certificateNo) {
19
+        String birthday = "";
20
+        String age = "";
21
+        String sexCode = "";
22
+
23
+        int year = Calendar.getInstance().get(Calendar.YEAR);
24
+        char[] number = certificateNo.toCharArray();
25
+        boolean flag = true;
26
+        if (number.length == 15) {
27
+            for (int x = 0; x < number.length; x++) {
28
+                if (!flag) return new HashMap<String, String>();
29
+                flag = Character.isDigit(number[x]);
30
+            }
31
+        } else if (number.length == 18) {
32
+            for (int x = 0; x < number.length - 1; x++) {
33
+                if (!flag) return new HashMap<String, String>();
34
+                flag = Character.isDigit(number[x]);
35
+            }
36
+        }
37
+        if (flag && certificateNo.length() == 15) {
38
+            birthday = "19" + certificateNo.substring(6, 8) + "-"
39
+                    + certificateNo.substring(8, 10) + "-"
40
+                    + certificateNo.substring(10, 12);
41
+            sexCode = Integer.parseInt(certificateNo.substring(certificateNo.length() - 3, certificateNo.length())) % 2 == 0 ? "1" : "0";
42
+            age = (year - Integer.parseInt("19" + certificateNo.substring(6, 8))) + "";
43
+        } else if (flag && certificateNo.length() == 18) {
44
+            birthday = certificateNo.substring(6, 10) + "-"
45
+                    + certificateNo.substring(10, 12) + "-"
46
+                    + certificateNo.substring(12, 14);
47
+            sexCode = Integer.parseInt(certificateNo.substring(certificateNo.length() - 4, certificateNo.length() - 1)) % 2 == 0 ? "1" : "0";
48
+            age = (year - Integer.parseInt(certificateNo.substring(6, 10))) + "";
49
+        }
50
+        Map<String, String> map = new HashMap<String, String>();
51
+        map.put("birthday", birthday);
52
+        map.put("age", age);
53
+        map.put("sexCode", sexCode);
54
+        return map;
55
+    }
56
+
57
+}

+ 48
- 0
ruoyi-common/src/main/java/com/ruoyi/common/utils/IdWorkerUtil.java Parādīt failu

@@ -0,0 +1,48 @@
1
+package com.ruoyi.common.utils;
2
+
3
+import cn.hutool.core.lang.Snowflake;
4
+import cn.hutool.core.util.IdUtil;
5
+import com.ruoyi.common.utils.uuid.UUID;
6
+
7
+import java.math.BigInteger;
8
+import java.util.Random;
9
+
10
+/**
11
+ * 雪花算法工具类
12
+ * zq
13
+ * @since 2020/10/30 9:59
14
+ **/
15
+public class IdWorkerUtil {
16
+    private static final long EPOCH = 1479533469598L; //开始时间,固定一个小于当前时间的毫秒数
17
+    private static final int max12bit = 4095;
18
+    private static final long max41bit= 1099511627775L;
19
+    private static String machineId = "" ; // 机器ID
20
+
21
+    /**
22
+     *
23
+     * 创建ID
24
+     *
25
+     * @return
26
+     *
27
+     */
28
+    public static Long getId(){
29
+
30
+        long time = System.currentTimeMillis() - EPOCH  + max41bit;
31
+        // 二进制的 毫秒级时间戳
32
+        String base = Long.toBinaryString(time);
33
+
34
+        // 序列数
35
+        String randomStr = StringUtils.leftPad(Integer.toBinaryString(new Random().nextInt(max12bit)),12,'0');
36
+        if(StringUtils.isNotEmpty(machineId)){
37
+            machineId = StringUtils.leftPad(machineId, 10, '0');
38
+        }
39
+
40
+        //拼接
41
+        String appendStr = base + machineId + randomStr;
42
+        // 转化为十进制 返回
43
+        BigInteger bi = new BigInteger(appendStr, 2);
44
+
45
+        return  Long.valueOf(bi.toString());
46
+    }
47
+
48
+}

+ 53
- 0
ruoyi-common/src/main/java/com/ruoyi/common/utils/MoneyFormatUtils.java Parādīt failu

@@ -0,0 +1,53 @@
1
+package com.ruoyi.common.utils;
2
+
3
+import java.math.BigDecimal;
4
+import java.text.NumberFormat;
5
+import java.util.regex.Matcher;
6
+import java.util.regex.Pattern;
7
+/**
8
+ * @author wangqiong
9
+ * @description 金额格式化
10
+ * @date 2023-12-11 11:45
11
+ */
12
+public class MoneyFormatUtils {
13
+
14
+    /**
15
+     * 增加千分位
16
+     * @param money
17
+     * @return
18
+     */
19
+    public static String moneyFormat(String money) {
20
+        // 金额格式化
21
+        try {
22
+            Double.parseDouble(money);
23
+
24
+        } catch (NumberFormatException e) {
25
+
26
+            String regEx = "[^0-9]";
27
+            Pattern p = Pattern.compile(regEx);
28
+            Matcher m = p.matcher(money);
29
+            String result = m.replaceAll("").trim();
30
+            BigDecimal bigDecimal = null;
31
+            if (money.contains("百")) {
32
+                bigDecimal = new BigDecimal(result).multiply(new BigDecimal("100"));
33
+            } else if (money.contains("千")) {
34
+                bigDecimal = new BigDecimal(result).multiply(new BigDecimal("1000"));
35
+            } else if (money.contains("万")) {
36
+                bigDecimal = new BigDecimal(result).multiply(new BigDecimal("10000"));
37
+            } else if (money.contains("百万")) {
38
+                bigDecimal = new BigDecimal(result).multiply(new BigDecimal("1000000"));
39
+            } else if (money.contains("千万")) {
40
+                bigDecimal = new BigDecimal(result).multiply(new BigDecimal("10000000"));
41
+            } else if (money.contains("亿")) {
42
+                bigDecimal = new BigDecimal(result).multiply(new BigDecimal("100000000"));
43
+            }
44
+
45
+            NumberFormat format = NumberFormat.getInstance();
46
+            return format.format(bigDecimal);
47
+
48
+        }
49
+        return "";
50
+    }
51
+
52
+
53
+}

+ 86
- 0
ruoyi-common/src/main/java/com/ruoyi/common/utils/ReadFileUtils.java Parādīt failu

@@ -0,0 +1,86 @@
1
+package com.ruoyi.common.utils;
2
+
3
+import org.apache.poi.hwpf.extractor.WordExtractor;
4
+import org.apache.poi.xwpf.extractor.XWPFWordExtractor;
5
+import org.apache.poi.xwpf.usermodel.XWPFDocument;
6
+
7
+import java.io.*;
8
+
9
+/**
10
+ * @author wangqiong
11
+ * @description 读取文件内容
12
+ * @date 2023-12-11 11:45
13
+ */
14
+public class ReadFileUtils {
15
+
16
+
17
+    public static String readerTxtFile(String filePath){
18
+        BufferedReader br=null;
19
+        StringBuilder result=new StringBuilder();
20
+        try {
21
+            br = new BufferedReader(new InputStreamReader(new FileInputStream(new File(filePath)),"GBK"));
22
+            String line=null;
23
+            while ((line=br.readLine())!=null) {
24
+                result.append(line).append("\n");
25
+            }
26
+        } catch (IOException e) {
27
+            e.printStackTrace();
28
+        } finally {
29
+            if (null!=br){
30
+                try {
31
+                    br.close();
32
+                } catch (IOException e) {
33
+                    e.printStackTrace();
34
+                }
35
+            }
36
+        }
37
+        return result.toString();
38
+    }
39
+    public static String readWord(String filePath) throws Exception{
40
+
41
+        File file = new File(filePath);
42
+        if(file.length()==0) return ""; // 需要操作原因是可能会空文件问题,如果不做处理,在下面读取中会报错
43
+        StringBuffer sb = new StringBuffer();
44
+        String buffer = "";
45
+        try {
46
+            if (filePath.endsWith(".doc")) {
47
+                InputStream is = new FileInputStream(file);
48
+                WordExtractor ex = new WordExtractor(is);
49
+                buffer = ex.getText();
50
+                if(buffer.length() > 0){
51
+                    //使用回车换行符分割字符串
52
+                    String [] arry = buffer.split("r\\n");
53
+                    for (String string : arry) {
54
+                        sb.append(string.trim());
55
+                    }
56
+                }
57
+            } else if (filePath.endsWith(".docx")) {
58
+                FileInputStream fis = new FileInputStream(file);
59
+                XWPFDocument xdoc = new XWPFDocument(fis);
60
+                XWPFWordExtractor extractor = new XWPFWordExtractor(xdoc);
61
+                buffer = extractor.getText();
62
+                sb.append(buffer!=null?buffer:"");
63
+
64
+
65
+//                OPCPackage opcPackage = POIXMLDocument.openPackage(filePath);
66
+//                XWPFWordExtractor extractor = new XWPFWordExtractor(opcPackage);
67
+//                buffer = extractor.getText();
68
+//                if(buffer.length() > 0){
69
+//                    //使用换行符分割字符串
70
+//                    String [] arry = buffer.split("\n");
71
+//                    for (String string : arry) {
72
+//                        sb.append(string.trim());
73
+//                    }
74
+//                }
75
+            } else {
76
+                return null;
77
+            }
78
+            return sb.toString();
79
+        } catch (Exception e) {
80
+            System.out.print("error---->"+filePath);
81
+            e.printStackTrace();
82
+            return null;
83
+        }
84
+    }
85
+
86
+}

+ 34
- 0
ruoyi-common/src/main/java/com/ruoyi/common/utils/SpringUtil.java Parādīt failu

@@ -0,0 +1,34 @@
1
+package com.ruoyi.common.utils;
2
+
3
+import org.springframework.beans.BeansException;
4
+import org.springframework.context.ApplicationContext;
5
+import org.springframework.context.ApplicationContextAware;
6
+import org.springframework.stereotype.Component;
7
+
8
+/**
9
+ * @author wangqiong
10
+ * @description 获取bean工具类
11
+ * @date 2023-12-11 11:45
12
+ */
13
+@Component
14
+public class SpringUtil implements ApplicationContextAware {
15
+    private static ApplicationContext applicationContext;
16
+    @Override
17
+    public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
18
+        if(SpringUtil.applicationContext==null){
19
+            SpringUtil.applicationContext=applicationContext;
20
+        }
21
+    }
22
+
23
+    public static ApplicationContext getApplicationContext(){
24
+        return applicationContext;
25
+    }
26
+
27
+    public static <T>T getBean(Class<T> clazz){
28
+        return getApplicationContext().getBean(clazz);
29
+    }
30
+
31
+    public static <T>T getBean(String name, Class<T> clazz){
32
+        return getApplicationContext().getBean(name,clazz);
33
+    }
34
+}

+ 14
- 0
ruoyi-common/src/main/java/com/ruoyi/common/utils/file/FileUtils.java Parādīt failu

@@ -288,4 +288,18 @@ public class FileUtils
288 288
         String baseName = FilenameUtils.getBaseName(fileName);
289 289
         return baseName;
290 290
     }
291
+    /**
292
+     * 获取文件后缀名
293
+     * @param file
294
+     * @return
295
+     */
296
+    public static String getFileExtension(File file) {
297
+        String name = file.getName();
298
+        int lastIndexOfDot = name.lastIndexOf(".");
299
+        if (lastIndexOfDot != -1 && lastIndexOfDot < name.length() - 1) {
300
+            return name.substring(lastIndexOfDot + 1);
301
+        } else {
302
+            return "";
303
+        }
304
+    }
291 305
 }

+ 46
- 1
ruoyi-common/src/main/java/com/ruoyi/common/utils/thread/MultipleThreadWorkUtil.java Parādīt failu

@@ -185,7 +185,52 @@ public class MultipleThreadWorkUtil {
185 185
                 mainLatch,threadLatch,rollBack,times);
186 186
         return returnList;
187 187
     }
188
-
188
+    public static <R,A>List<R> execListFun(MultipleThreadListParam<R,A> ...params){
189
+        List<R> returnList=new ArrayList<>();
190
+        if(ArrayUtil.isEmpty(params)){
191
+            return returnList;
192
+        }
193
+        List<Integer> threadCountList=new ArrayList<>();
194
+        for (MultipleThreadListParam param : params) {
195
+            if(param.getList().size()<SIMPLE_TIME_COUNT){
196
+                threadCountList.add(1);
197
+            }else{
198
+                if(param.getList().size()%SIMPLE_TIME_COUNT>0){
199
+                    threadCountList.add(param.getList().size()/SIMPLE_TIME_COUNT+1);
200
+                }else{
201
+                    threadCountList.add(param.getList().size()/SIMPLE_TIME_COUNT);
202
+                }
203
+            }
204
+        }
205
+        int times=0;
206
+        for (Integer count : threadCountList) {
207
+            times+=count;
208
+        }
209
+        CountDownLatch mainLatch=new CountDownLatch(1);
210
+        //监控子线程
211
+        CountDownLatch threadLatch=new CountDownLatch(times);
212
+        //根据子线程执行结果判断是否需要回滚
213
+        BlockingDeque<Boolean>  resultList=new LinkedBlockingDeque<>();
214
+        //必须使用对象,如果使用变量会造成线程之间不能共享变量值
215
+        RollBack rollBack=new RollBack(false);
216
+        ExecutorService executorService=Executors.newFixedThreadPool(times);
217
+        List<Future<R>> futureList=new ArrayList<>();
218
+        for (int i = 0; i < params.length; i++) {
219
+            MultipleThreadListParam param=params[i];
220
+            for (int j = 0; j <threadCountList.get(i) ; j++) {
221
+                if(j*SIMPLE_TIME_COUNT+SIMPLE_TIME_COUNT<param.getList().size()){
222
+                    Future<R> future=executorService.submit(new ExecThread(mainLatch,threadLatch,rollBack,resultList,param.getList().subList(j*SIMPLE_TIME_COUNT,j*SIMPLE_TIME_COUNT+SIMPLE_TIME_COUNT),param.getFunction()));
223
+                    futureList.add(future);
224
+                }else{
225
+                    Future<R> future=executorService.submit(new ExecThread(mainLatch,threadLatch,rollBack,resultList,param.getList().subList(j*SIMPLE_TIME_COUNT,param.getList().size()),param.getFunction()));
226
+                    futureList.add(future);
227
+                }
228
+            }
229
+        }
230
+        setResult(executorService,returnList,futureList,resultList,
231
+                mainLatch,threadLatch,rollBack,times);
232
+        return returnList;
233
+    }
189 234
     public static <R>List<R> execByIds(Function<String,R> execFun,String ids){
190 235
         List<R> returnList=new ArrayList<>();
191 236
         if(StrUtil.isEmpty(ids)){

+ 7
- 0
ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysDeptMapper.java Parādīt failu

@@ -117,4 +117,11 @@ public interface SysDeptMapper
117 117
     public int deleteDeptById(Long deptId);
118 118
 
119 119
     List<Long> selectUserDeptListByRoleId(@Param("roleId")Long roleId);
120
+
121
+    /**
122
+     * 批量新增
123
+     * @param sysDepts
124
+     * @return
125
+     */
126
+    int batchSave(@Param("list")List<SysDept> sysDepts);
120 127
 }

+ 6
- 1
ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysUserMapper.java Parādīt failu

@@ -165,5 +165,10 @@ public interface SysUserMapper
165 165
 
166 166
     List<SysUser>  selectRoleUserByDeptId(@Param("deptId")Long deptId,@Param("roleId") Long roleId );
167 167
 
168
-
168
+    /**
169
+     * 批量新增用户
170
+     * @param addUsers
171
+     * @return
172
+     */
173
+    int batchSave(@Param("list")List<SysUser> addUsers);
169 174
 }

+ 2
- 0
ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/mapper/CaseApplicationLogMapper.java Parādīt failu

@@ -44,4 +44,6 @@ public interface CaseApplicationLogMapper {
44 44
     void batchDeleteLog(@Param("ids") List<Long> ids);
45 45
 
46 46
     CaseApplication selectBeforeCase(@Param("caseId") Long caseId, @Param("version")Integer version);
47
+
48
+    Integer batchSave(@Param("list")List<CaseApplication> caseApplications);
47 49
 }

+ 6
- 0
ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/mapper/CaseApplicationMapper.java Parādīt failu

@@ -125,4 +125,10 @@ public interface CaseApplicationMapper {
125 125
      */
126 126
     Integer selectBatchNumberLike();
127 127
 
128
+    /**
129
+     * 批量新增案件
130
+     * @param caseApplications
131
+     * @return
132
+     */
133
+    int batchSave(@Param("list")List<CaseApplication> caseApplications);
128 134
 }

+ 1
- 0
ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/mapper/CaseAttachLogMapper.java Parādīt failu

@@ -27,4 +27,5 @@ public interface CaseAttachLogMapper {
27 27
     CaseAttach queryAnnexById(Integer annexId);
28 28
 
29 29
 
30
+    Integer batchSave(@Param("list")List<CaseAttach> caseAttaches);
30 31
 }

+ 1
- 1
ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/mapper/ColumnValueLogMapper.java Parādīt failu

@@ -15,7 +15,7 @@ public interface ColumnValueLogMapper {
15 15
     /**
16 16
      * 批量新增
17 17
      */
18
-    void batchSave(@Param("list") List<ColumnValue> list);
18
+    int batchSave(@Param("list") List<ColumnValue> list);
19 19
     void batchUpdate(@Param("list") List<ColumnValue> list);
20 20
 
21 21
     /**

+ 1
- 1
ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/mapper/ColumnValueMapper.java Parādīt failu

@@ -17,7 +17,7 @@ public interface ColumnValueMapper {
17 17
     /**
18 18
      * 批量新增
19 19
      */
20
-    void batchSave(@Param("list") List<ColumnValue> list);
20
+    int batchSave(@Param("list") List<ColumnValue> list);
21 21
 
22 22
     /**
23 23
      * 根据案件id查询字段及值

+ 7
- 0
ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/service/IAdjudicationService.java Parādīt failu

@@ -32,4 +32,11 @@ public interface IAdjudicationService {
32 32
      * @return
33 33
      */
34 34
     AjaxResult emailByCaseId(Long id);
35
+
36
+    /**
37
+     * 批量生成裁决书
38
+     * @param ids
39
+     * @return
40
+     */
41
+    AjaxResult batchDocument(List<Long> ids);
35 42
 }

+ 1
- 1
ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/service/ICaseApplicationService.java Parādīt failu

@@ -19,7 +19,7 @@ public interface ICaseApplicationService {
19 19
     List<CaseApplication> selectCaseApplicationListByRole(CaseApplication caseApplication);
20 20
 
21 21
 
22
-    int insertcaseApplication(CaseApplication caseApplication, List<ColumnValue> columnValueList);
22
+    int insertcaseApplication(CaseApplication caseApplication);
23 23
 
24 24
     int selectCaseApplicationCount(CaseApplication caseApplication);
25 25
 

+ 30
- 0
ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/service/impl/AdjudicationServiceImpl.java Parādīt failu

@@ -11,6 +11,8 @@ import com.ruoyi.common.core.domain.entity.SysDictData;
11 11
 import com.ruoyi.common.core.redis.RedisCache;
12 12
 import com.ruoyi.common.exception.ServiceException;
13 13
 import com.ruoyi.common.utils.*;
14
+import com.ruoyi.common.utils.thread.MultipleThreadListParam;
15
+import com.ruoyi.common.utils.thread.MultipleThreadWorkUtil;
14 16
 import com.ruoyi.system.mapper.SysDictDataMapper;
15 17
 import com.ruoyi.wisdomarbitrate.domain.vo.BookSendVO;
16 18
 import com.ruoyi.wisdomarbitrate.domain.vo.ColumnValue;
@@ -49,6 +51,7 @@ import java.text.NumberFormat;
49 51
 import java.text.SimpleDateFormat;
50 52
 import java.time.LocalDate;
51 53
 import java.util.*;
54
+import java.util.concurrent.CountDownLatch;
52 55
 import java.util.function.Function;
53 56
 import java.util.regex.Matcher;
54 57
 import java.util.regex.Pattern;
@@ -1252,6 +1255,33 @@ public class AdjudicationServiceImpl implements IAdjudicationService {
1252 1255
         }
1253 1256
         return AjaxResult.success(bookSendVO);
1254 1257
     }
1258
+    private void setExecList(List<MultipleThreadListParam> execList, List<ColumnValue> columnValueList){
1259
+        if(CollectionUtil.isNotEmpty(columnValueList)){
1260
+            Function<List<ColumnValue>,Integer> function= columnValueMapper::batchSave;
1261
+            execList.add(new MultipleThreadListParam(function,columnValueList));
1262
+        }
1263
+
1264
+    }
1265
+   @Transactional
1266
+    @Override
1267
+    public AjaxResult batchDocument(List<Long> ids) {
1268
+        // todo 多线程生成裁决书
1269
+//       List<MultipleThreadListParam> execList=new ArrayList<>();
1270
+//       if(CollectionUtil.isNotEmpty(columnValueList)) {
1271
+//           setExecList(execList, columnValueList);
1272
+//       }
1273
+//
1274
+//       if(CollectionUtil.isNotEmpty(execList)){
1275
+//           MultipleThreadWorkUtil.execListFun(execList.toArray(new MultipleThreadListParam[execList.size()]));
1276
+//       }
1277
+        for (Long id : ids) {
1278
+            CaseApplication caseApplication = new CaseApplication();
1279
+            caseApplication.setId(id);
1280
+            createDocument(caseApplication);
1281
+        }
1282
+
1283
+        return AjaxResult.success();
1284
+    }
1255 1285
 
1256 1286
     public String getNewEquipmentNo() {
1257 1287
         Object awardNum = redisCache.getCacheObject("awardNum");

+ 24
- 985
ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/service/impl/CaseApplicationServiceImpl.java
Failā izmaiņas netiks attēlotas, jo tās ir par lielu
Parādīt failu


+ 328
- 0
ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/service/impl/CaseImportValid.java Parādīt failu

@@ -0,0 +1,328 @@
1
+package com.ruoyi.wisdomarbitrate.service.impl;
2
+
3
+import cn.hutool.core.util.IdcardUtil;
4
+import cn.hutool.core.util.StrUtil;
5
+import com.ruoyi.common.core.domain.entity.SysUser;
6
+import com.ruoyi.common.utils.SpringUtil;
7
+import com.ruoyi.system.mapper.SysUserMapper;
8
+import com.ruoyi.wisdomarbitrate.domain.CaseApplication;
9
+import lombok.AllArgsConstructor;
10
+import lombok.Data;
11
+import lombok.NoArgsConstructor;
12
+
13
+import java.math.BigDecimal;
14
+import java.util.Date;
15
+import java.util.Map;
16
+import java.util.regex.Pattern;
17
+
18
+/**
19
+ * @author wangqiong
20
+ * @description excel导入校验
21
+ * @date 2023-12-11 11:45
22
+ */
23
+@Data
24
+@NoArgsConstructor
25
+@AllArgsConstructor
26
+public class CaseImportValid {
27
+    private CaseApplication caseApplication;
28
+    private Map<String, Long> deptMap;
29
+    // 手机号正则
30
+    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}$");
31
+    // 邮箱正则
32
+    private static final Pattern EMAIL_PATTERN = Pattern.compile("^[a-zA-Z0-9_+&*-]+(?:\\.[a-zA-Z0-9_+&*-]+)*@(?:[a-zA-Z0-9-]+\\.)+[a-zA-Z]{2,7}$");
33
+    private static SysUserMapper sysUserMapper= SpringUtil.getBean(SysUserMapper.class);
34
+
35
+    /**
36
+     * 导入校验
37
+     *
38
+     * @param caseApplication
39
+     * @param
40
+     */
41
+    public void importValid(CaseApplication caseApplication, Map<String, Long> deptMap) {
42
+        StringBuilder failureMsg = new StringBuilder();
43
+        caseApplication.setErrorMsg(failureMsg);
44
+        // 校验基本字段
45
+        validBaseColumn(caseApplication, failureMsg);
46
+        // 校验申请人信息
47
+        validApplicationColumn(caseApplication, failureMsg);
48
+        // 校验申请人代理信息
49
+        validApplicationAgentColumn(caseApplication, failureMsg, deptMap);
50
+        // 校验被申请人信息
51
+        validDebtorApplicationColumn(caseApplication, failureMsg);
52
+        // 校验被申请人代理信息
53
+        validDebtorApplicationAgentColumn(caseApplication, failureMsg);
54
+    }
55
+
56
+    /**
57
+     * 校验被申请人代理信息
58
+     *
59
+     * @param caseApplication
60
+     * @param failureMsg
61
+     */
62
+    private void validDebtorApplicationAgentColumn(CaseApplication caseApplication, StringBuilder failureMsg) {
63
+        if (StrUtil.isEmpty(caseApplication.getDebtorNameAgent())) {
64
+            failureMsg.append("【被申请人主体信息-代理人姓名】字段不能为空;");
65
+        } else if (caseApplication.getDebtorNameAgent().length() > 50) {
66
+            failureMsg.append("【被申请人主体信息-代理人姓名】字段超出指定长度,最大长度为50;");
67
+        }
68
+        if (StrUtil.isEmpty(caseApplication.getDebtorIdentityNumAgent())) {
69
+            failureMsg.append("【被申请人主体信息-代理人身份证号】字段不能为空;");
70
+        } else if (!IdcardUtil.isValidCard((caseApplication.getDebtorIdentityNumAgent()))) {
71
+            failureMsg.append("【被申请人主体信息-代理人身份证号】不合法;");
72
+        }
73
+        String debtorContactTelphoneAgent = caseApplication.getDebtorContactTelphoneAgent();
74
+        if (StrUtil.isEmpty(debtorContactTelphoneAgent)) {
75
+            failureMsg.append("【被申请人主体信息-代理人联系电话】字段不能为空;");
76
+        } else if (!TELEPHONE_REGX.matcher(debtorContactTelphoneAgent).matches()) {
77
+            failureMsg.append("【被申请人主体信息-代理人联系电话】字段不合法;");
78
+        }
79
+        if (StrUtil.isEmpty(caseApplication.getDebtorContactAddressAgent())) {
80
+            failureMsg.append("【被申请人主体信息-代理人联系地址】字段不能为空;");
81
+        } else if (caseApplication.getDebtorContactAddressAgent().length() > 50) {
82
+            failureMsg.append("【被申请人主体信息-代理人联系地址】字段超出指定长度,最大长度为50;");
83
+        }
84
+    }
85
+
86
+    /**
87
+     * 校验被申请人信息
88
+     *
89
+     * @param caseApplication
90
+     * @param failureMsg
91
+     */
92
+    private void validDebtorApplicationColumn(CaseApplication caseApplication, StringBuilder failureMsg) {
93
+        if (StrUtil.isEmpty(caseApplication.getDebtorName())) {
94
+            failureMsg.append("【被申请人主体信息-申请人姓名】字段不能为空;");
95
+        } else if (caseApplication.getDebtorName().length() > 50) {
96
+            failureMsg.append("【被申请人主体信息-申请人姓名】字段超出指定长度,最大长度为50;");
97
+        }
98
+        if (StrUtil.isEmpty(caseApplication.getDebtorIdentityNum())) {
99
+            failureMsg.append("【被申请人主体信息-身份证号】字段不能为空;");
100
+        } else if (!IdcardUtil.isValidCard(caseApplication.getDebtorIdentityNum())) {
101
+            failureMsg.append("【被申请人主体信息-身份证号】不合法;");
102
+        }
103
+        String debtorContactTelphone = caseApplication.getDebtorContactTelphone();
104
+        if (StrUtil.isEmpty(debtorContactTelphone)) {
105
+            failureMsg.append("【被申请人主体信息-联系电话】字段不能为空;");
106
+        } else if (!TELEPHONE_REGX.matcher(debtorContactTelphone).matches()) {
107
+            failureMsg.append("【被申请人主体信息-联系电话】字段不合法;");
108
+        }
109
+        if (StrUtil.isEmpty(caseApplication.getDebtorContactAddress())) {
110
+            failureMsg.append("【被申请人主体信息-联系地址】字段不能为空;");
111
+        } else if (caseApplication.getDebtorContactAddress().length() > 50) {
112
+            failureMsg.append("【被申请人主体信息-联系地址】字段超出指定长度,最大长度为50;");
113
+        }
114
+        String debtorWorkTelphone = caseApplication.getDebtorWorkTelphone();
115
+        if (StrUtil.isEmpty(debtorWorkTelphone)) {
116
+            failureMsg.append("【被申请人主体信息-单位电话】字段不能为空;");
117
+        } else if (!TELEPHONE_REGX.matcher(debtorWorkTelphone).matches()) {
118
+            failureMsg.append("【被申请人主体信息-单位电话】字段不合法;");
119
+        }
120
+        if (StrUtil.isEmpty(caseApplication.getDebtorWorkAddress())) {
121
+            failureMsg.append("【被申请人主体信息-单位地址】字段不能为空;");
122
+        } else if (caseApplication.getDebtorWorkAddress().length() > 50) {
123
+            failureMsg.append("【被申请人主体信息-单位地址】字段超出指定长度,最大长度为50;");
124
+        }
125
+        if (StrUtil.isEmpty(caseApplication.getResponSex())) {
126
+            failureMsg.append("【被申请人主体信息-性别】字段不能为空;");
127
+        } else if (caseApplication.getResponSex().length() > 1) {
128
+            failureMsg.append("【被申请人主体信息-性别】字段超出指定长度,最大长度为1;");
129
+        }
130
+        if (caseApplication.getResponBirth() == null) {
131
+            failureMsg.append("【被申请人主体信息-出生年月日】字段不合法;");
132
+        } else if (caseApplication.getResponBirth().after(new Date())) {
133
+            failureMsg.append("【被申请人主体信息-出生年月日】字段不合法,不能超过当前日期;");
134
+        }
135
+        if (StrUtil.isEmpty(caseApplication.getDebtorEmail())) {
136
+            failureMsg.append("【被申请人主体信息-邮箱】字段不能为空;");
137
+        } else if (!EMAIL_PATTERN.matcher(caseApplication.getDebtorEmail()).matches()) {
138
+
139
+            failureMsg.append("【被申请人主体信息-邮箱】字段不合法;");
140
+        }
141
+    }
142
+
143
+    /**
144
+     * 校验申请人代理信息
145
+     *
146
+     * @param caseApplication
147
+     * @param failureMsg
148
+     */
149
+    private void validApplicationAgentColumn(CaseApplication caseApplication, StringBuilder failureMsg, Map<String, Long> deptMap) {
150
+        if (StrUtil.isEmpty(caseApplication.getNameAgent())) {
151
+            failureMsg.append("【申请人主体信息-代理人姓名】字段不能为空;");
152
+        } else if (caseApplication.getNameAgent().length() > 50) {
153
+            failureMsg.append("【申请人主体信息-代理人姓名】字段超出指定长度,最大长度为50;");
154
+        }
155
+        if (StrUtil.isEmpty(caseApplication.getIdentityNumAgent())) {
156
+            failureMsg.append("【申请人主体信息-代理人身份证号】字段不能为空;");
157
+        } else if (!IdcardUtil.isValidCard(caseApplication.getIdentityNumAgent())) {
158
+            failureMsg.append("【申请人主体信息-代理人身份证号】不合法;");
159
+        }
160
+        validAgentInfo(caseApplication, failureMsg, deptMap);
161
+        String contactTelphoneAgent = caseApplication.getContactTelphoneAgent();
162
+        if (StrUtil.isEmpty(contactTelphoneAgent)) {
163
+            failureMsg.append("【申请人主体信息-代理人联系电话】字段不能为空;");
164
+        } else if (!TELEPHONE_REGX.matcher(contactTelphoneAgent).matches()) {
165
+            failureMsg.append("【申请人主体信息-代理人联系电话】字段不合法;");
166
+        }
167
+        if (StrUtil.isEmpty(caseApplication.getContactAddressAgent())) {
168
+            failureMsg.append("【申请人主体信息-代理人联系地址】字段不能为空;");
169
+        } else if (caseApplication.getContactAddressAgent().length() > 50) {
170
+            failureMsg.append("【申请人主体信息-代理人联系地址】字段超出指定长度,最大长度为50;");
171
+        }
172
+    }
173
+
174
+    /**
175
+     * 校验代理人与组织机构关系
176
+     *
177
+     * @param caseApplication
178
+     * @param failureMsg
179
+     * @return
180
+     */
181
+    private void validAgentInfo(CaseApplication caseApplication, StringBuilder failureMsg, Map<String, Long> deptMap) {
182
+        // 申请机构与代理人都不为空,校验代理人与组织机构关系(代理人必须在该部门下)
183
+        if (StrUtil.isNotEmpty(caseApplication.getName()) && StrUtil.isNotEmpty(caseApplication.getNameAgent())) {
184
+            String applicationOrganId = "";
185
+            // 申请机构已经存在
186
+            if (deptMap.containsKey(caseApplication.getName())) {
187
+                applicationOrganId = String.valueOf(deptMap.get(caseApplication.getName()));
188
+            }
189
+            // 根据代理人身份证去用户表查询
190
+            SysUser agentUser = sysUserMapper.selectUserByIdCard(caseApplication.getIdentityNumAgent());
191
+            // 代理人的部门和申请机构不匹配
192
+            if (null != agentUser && null != agentUser.getDeptId() && !String.valueOf(agentUser.getDeptId()).equals(applicationOrganId)) {
193
+//                return "该申请代理人已在"+agentUser.getDeptName()+"申请机构下存在,请检查填写信息是否正确";
194
+                if (null != agentUser.getDept() && StrUtil.isNotEmpty(agentUser.getDept().getDeptName())) {
195
+                    failureMsg.append("该申请代理人已在【").append(agentUser.getDept().getDeptName()).append("】申请机构下存在,请检查填写信息是否正确");
196
+                } else {
197
+                    failureMsg.append("该申请代理人已存在,与申请机构不匹配,请检查填写信息是否正确");
198
+                }
199
+            }
200
+
201
+        }
202
+    }
203
+
204
+    /**
205
+     * 校验申请人主题信息
206
+     *
207
+     * @param caseApplication
208
+     * @param failureMsg
209
+     */
210
+    private void validApplicationColumn(CaseApplication caseApplication, StringBuilder failureMsg) {
211
+        if (StrUtil.isEmpty(caseApplication.getName())) {
212
+            failureMsg.append("【申请人主体信息-申请人(机构)】字段不能为空;");
213
+        } else if (caseApplication.getName().length() > 20) {
214
+            failureMsg.append("【申请人主体信息-申请人(机构)】字段超出指定长度,最大长度为20;");
215
+        }
216
+        if (StrUtil.isNotEmpty(caseApplication.getIdentityNum()) && caseApplication.getIdentityNum().length() > 50) {
217
+            failureMsg.append("【申请人主体信息-代码】字段超出指定长度,最大长度为50;");
218
+        }
219
+        String contactTelphone = caseApplication.getContactTelphone();
220
+        if (StrUtil.isEmpty(contactTelphone)) {
221
+            failureMsg.append("【申请人主体信息-联系电话】字段不能为空;");
222
+        } else if (!TELEPHONE_REGX.matcher(contactTelphone).matches()) {
223
+            failureMsg.append("【申请人主体信息-联系电话】字段不合法;");
224
+        }
225
+        if (StrUtil.isEmpty(caseApplication.getContactAddress())) {
226
+            failureMsg.append("【申请人主体信息-联系地址】字段不能为空;");
227
+        } else if (caseApplication.getName().length() > 50) {
228
+            failureMsg.append("【申请人主体信息-联系地址】字段超出指定长度,最大长度为50;");
229
+        }
230
+        String workTelphone = caseApplication.getWorkTelphone();
231
+        if (StrUtil.isEmpty(workTelphone)) {
232
+            failureMsg.append("【申请人主体信息-单位电话】字段不能为空;");
233
+        } else if (!TELEPHONE_REGX.matcher(workTelphone).matches()) {
234
+            failureMsg.append("【申请人主体信息-单位电话】字段不合法;");
235
+        }
236
+        if (StrUtil.isEmpty(caseApplication.getWorkAddress())) {
237
+            failureMsg.append("【申请人主体信息-单位地址】字段不能为空;");
238
+        } else if (caseApplication.getWorkAddress().length() > 50) {
239
+            failureMsg.append("【申请人主体信息-单位地址】字段超出指定长度,最大长度为50;");
240
+        }
241
+        if (StrUtil.isEmpty(caseApplication.getEmail())) {
242
+            failureMsg.append("【申请人主体信息-邮箱】字段不能为空;");
243
+        } else if (!EMAIL_PATTERN.matcher(caseApplication.getEmail()).matches()) {
244
+
245
+            failureMsg.append("【申请人主体信息-邮箱】字段不合法;");
246
+        }
247
+    }
248
+
249
+    /**
250
+     * 校验基本字段
251
+     *
252
+     * @param caseApplication
253
+     * @param failureMsg
254
+     */
255
+    private void validBaseColumn(CaseApplication caseApplication, StringBuilder failureMsg) {
256
+        if (StrUtil.isEmpty(caseApplication.getCaseName())) {
257
+            failureMsg.append("【案件名称】字段不能为空;");
258
+        } else if (caseApplication.getCaseName().length() > 50) {
259
+            failureMsg.append("【案件名称】字段超出指定长度,最大长度为50;");
260
+        }
261
+        BigDecimal caseSubjectAmount = caseApplication.getCaseSubjectAmount();
262
+        if (null == caseSubjectAmount) {
263
+            failureMsg.append("【案件标的】字段不合法;");
264
+        } else {
265
+            if (caseSubjectAmount.compareTo(new BigDecimal("0")) < 0 || caseSubjectAmount.compareTo(new BigDecimal("99999999.99")) > 0) {
266
+                failureMsg.append("【案件标的】字段超出范围,范围为[0,100000000);");
267
+            }
268
+            if (caseSubjectAmount.scale() > 2) {
269
+                failureMsg.append("【案件标的】字段超出指定精度(10^-2);");
270
+            }
271
+        }
272
+        if (caseApplication.getLoanStartDate() == null) {
273
+            failureMsg.append("【借款开始日期】字段不合法;");
274
+        }
275
+        if (caseApplication.getLoanEndDate() == null) {
276
+            failureMsg.append("【借款结束日期】字段不合法;");
277
+        }
278
+        if (caseApplication.getLoanStartDate() != null && caseApplication.getLoanEndDate() != null && caseApplication.getLoanStartDate().after(caseApplication.getLoanEndDate())) {
279
+            failureMsg.append("【借款结束日期】不能早于【借款开始日期】;");
280
+        }
281
+        if (StrUtil.isEmpty(caseApplication.getContractNumber())) {
282
+            failureMsg.append("【合同编号】字段不能为空;");
283
+        } else if (caseApplication.getContractNumber().length() > 50) {
284
+            failureMsg.append("【合同编号】字段超出指定长度,最大长度为50;");
285
+        }
286
+        BigDecimal claimPrinciOwed = caseApplication.getClaimPrinciOwed();
287
+        if (null == claimPrinciOwed) {
288
+            failureMsg.append("【申请人主张欠本金】字段不合法;");
289
+        } else {
290
+            if (claimPrinciOwed.compareTo(new BigDecimal("0")) < 0 || claimPrinciOwed.compareTo(new BigDecimal("99999999.99")) > 0) {
291
+                failureMsg.append("【申请人主张欠本金】字段超出范围,范围为[0,100000000);");
292
+            }
293
+            if (claimPrinciOwed.scale() > 2) {
294
+                failureMsg.append("【申请人主张欠本金】字段超出指定精度(10^-2);");
295
+            }
296
+        }
297
+        BigDecimal claimInterestOwed = caseApplication.getClaimInterestOwed();
298
+        if (null == claimInterestOwed) {
299
+            failureMsg.append("【申请人主张欠利息】字段不合法;");
300
+        } else {
301
+            if (claimInterestOwed.compareTo(new BigDecimal("0")) < 0 || claimInterestOwed.compareTo(new BigDecimal("99999999.99")) > 0) {
302
+                failureMsg.append("【申请人主张欠利息】字段超出范围,范围为[0,100000000);");
303
+            }
304
+            if (claimInterestOwed.scale() > 2) {
305
+                failureMsg.append("【申请人主张欠利息】字段超出指定精度(10^-2);");
306
+            }
307
+        }
308
+        BigDecimal claimLiquidDamag = caseApplication.getClaimLiquidDamag();
309
+        if (null == claimLiquidDamag) {
310
+            failureMsg.append("【申请人主张违约金】字段不合法;");
311
+        } else {
312
+            if (claimLiquidDamag.compareTo(new BigDecimal("0")) < 0 || claimLiquidDamag.compareTo(new BigDecimal("99999999.99")) > 0) {
313
+                failureMsg.append("【申请人主张违约金】字段超出范围,范围为[0,100000000);");
314
+            }
315
+            if (claimLiquidDamag.scale() > 2) {
316
+                failureMsg.append("【申请人主张违约金】字段超出指定精度(10^-2);");
317
+            }
318
+        }
319
+        if (StrUtil.isEmpty(caseApplication.getArbitratClaims())) {
320
+            failureMsg.append("【申请人仲裁请求及事实和理由】字段不能为空;");
321
+        } else if (caseApplication.getArbitratClaims().length() > 10000) {
322
+            failureMsg.append("【申请人仲裁请求及事实和理由】字段超出指定长度,最大长度为10000;");
323
+        }
324
+        if (StrUtil.isNotEmpty(caseApplication.getArbitratClaims()) && caseApplication.getArbitratClaims().length() > 10000) {
325
+            failureMsg.append("【申请人请求仲裁庭裁决】字段超出指定长度,最大长度为10000;");
326
+        }
327
+    }
328
+}

+ 811
- 0
ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/service/impl/CaseZipImportImpl.java Parādīt failu

@@ -0,0 +1,811 @@
1
+package com.ruoyi.wisdomarbitrate.service.impl;
2
+
3
+import cn.hutool.core.bean.BeanUtil;
4
+import cn.hutool.core.collection.CollectionUtil;
5
+import cn.hutool.core.util.ObjectUtil;
6
+import cn.hutool.core.util.StrUtil;
7
+import com.ruoyi.common.constant.CaseApplicationConstants;
8
+import com.ruoyi.common.constant.Constants;
9
+import com.ruoyi.common.core.domain.entity.SysDept;
10
+import com.ruoyi.common.core.domain.entity.SysRole;
11
+import com.ruoyi.common.core.domain.entity.SysUser;
12
+import com.ruoyi.common.enums.UpdateSubmitStatus;
13
+import com.ruoyi.common.utils.*;
14
+import com.ruoyi.common.config.RuoYiConfig;
15
+import com.ruoyi.common.core.domain.AjaxResult;
16
+import com.ruoyi.common.core.domain.entity.SysDictData;
17
+import com.ruoyi.common.exception.ServiceException;
18
+import com.ruoyi.common.utils.file.FileUtils;
19
+import com.ruoyi.common.utils.thread.MultipleThreadListParam;
20
+import com.ruoyi.common.utils.thread.MultipleThreadWorkUtil;
21
+import com.ruoyi.system.domain.SysUserRole;
22
+import com.ruoyi.system.mapper.*;
23
+import com.ruoyi.wisdomarbitrate.domain.CaseAffiliate;
24
+import com.ruoyi.wisdomarbitrate.domain.CaseApplication;
25
+import com.ruoyi.wisdomarbitrate.domain.CaseAttach;
26
+import com.ruoyi.wisdomarbitrate.domain.FatchRule;
27
+import com.ruoyi.wisdomarbitrate.domain.vo.ColumnValue;
28
+import com.ruoyi.wisdomarbitrate.mapper.*;
29
+import com.ruoyi.wisdomarbitrate.utils.OCRUtils;
30
+import com.ruoyi.wisdomarbitrate.utils.UnZipFileUtils;
31
+import org.apache.pdfbox.pdmodel.PDDocument;
32
+import org.springframework.beans.factory.annotation.Autowired;
33
+import org.springframework.stereotype.Service;
34
+import org.springframework.web.multipart.MultipartFile;
35
+
36
+import java.io.*;
37
+import java.math.BigDecimal;
38
+import java.text.SimpleDateFormat;
39
+import java.util.*;
40
+import java.util.function.Function;
41
+import java.util.regex.Matcher;
42
+import java.util.regex.Pattern;
43
+import java.util.stream.Collectors;
44
+
45
+import static com.ruoyi.common.core.domain.AjaxResult.error;
46
+import static com.ruoyi.common.core.domain.AjaxResult.success;
47
+import static com.ruoyi.common.utils.SecurityUtils.getUsername;
48
+
49
+/**
50
+ * @author wangqiong
51
+ * @description 案件压缩包导入
52
+ * @date 2023-12-11 11:45
53
+ */
54
+@Service
55
+public class CaseZipImportImpl {
56
+    @Autowired
57
+    private CaseApplicationServiceImpl caseApplicationService;
58
+    @Autowired
59
+    private FatchRuleMapper fatchRuleMapper;
60
+    @Autowired
61
+    private SysDictDataMapper dictDataMapper;
62
+    @Autowired
63
+    private CaseApplicationMapper caseApplicationMapper;
64
+    @Autowired
65
+    private SysDeptMapper sysDeptMapper;
66
+    @Autowired
67
+    private SysRoleMapper roleMapper;
68
+    @Autowired
69
+    private SysUserMapper userMapper;
70
+    @Autowired
71
+    private SysUserRoleMapper userRoleMapper;
72
+    @Autowired
73
+    private CaseApplicationLogMapper caseApplicationLogMapper;
74
+    @Autowired
75
+    private CaseAffiliateLogMapper caseAffiliateLogMapper;
76
+    @Autowired
77
+    private CaseAttachLogMapper caseAttachLogMapper;
78
+    @Autowired
79
+    private SmsRecordMapper smsRecordMapper;
80
+    @Autowired
81
+    private CaseAttachMapper caseAttachMapper;
82
+    @Autowired
83
+    private ColumnValueMapper columnValueMapper;
84
+    @Autowired
85
+    private ColumnValueLogMapper columnValueLogMapper;
86
+    @Autowired
87
+    private CaseAffiliateMapper caseAffiliateMapper;
88
+    // 申请人角色id
89
+    private long roleId;
90
+    private Integer maxCaseNum;
91
+    private Integer maxBatchNumber;
92
+
93
+    public AjaxResult zipImport(MultipartFile file, Long templateId) {
94
+        UUID uuid = UUID.randomUUID();
95
+        // todo
96
+        String targetPath = "/home/ruoyi/uploadPath/upload/unzipFile/" + uuid + "/";
97
+//        String targetPath = "D:/home/ruoyi/uploadPath/upload/unzipFile/"+uuid+ "/";
98
+        File zipFile = null;
99
+        InputStream ins = null;
100
+        try {
101
+            ins = file.getInputStream();
102
+            //上传的压缩包保存的路径
103
+            // todo
104
+            String savePath = "/home/ruoyi/uploadPath/upload/zipFile/";
105
+//           String savePath = "D:/home/ruoyi/uploadPath/upload/zipFile/";
106
+            String saveName = uuid + "_" + file.getOriginalFilename();
107
+            zipFile = new File(savePath + saveName);
108
+            inputChangeToFile(ins, zipFile);
109
+        } catch (IOException e) {
110
+            e.printStackTrace();
111
+        }
112
+        //解压缩上传的压缩包
113
+        boolean unzipSuccess = UnZipFileUtils.unZipFile(zipFile, targetPath);
114
+        if (!unzipSuccess) {
115
+            // 解压失败
116
+            return AjaxResult.error("解压失败");
117
+        }
118
+        // 查询抓取规则
119
+        // todo 批次需要再上传压缩包时用户填写
120
+        List<FatchRule> fatchRuleList = fatchRuleMapper.listByTemplateId(templateId);
121
+        if (CollectionUtil.isEmpty(fatchRuleList)) {
122
+            return error("未设置抓取规则");
123
+        }
124
+        File directory = new File(targetPath);
125
+        // fileMap<caseId, List<File>>
126
+        Map<Long, List<File>> fileMap = findAndConvertPDF(directory);
127
+        if (fileMap == null || fileMap.size() <= 0) {
128
+            // 解压失败
129
+            return AjaxResult.error("未获取到文件");
130
+        }
131
+        Map<String, String> fatchMap = new HashMap<>();
132
+        if (CollectionUtil.isNotEmpty(fatchRuleList)) {
133
+
134
+            Map<String, List<FatchRule>> fatchRuleMap = fatchRuleList.stream().collect(Collectors.groupingBy(FatchRule::getFileName));
135
+            // 根据抓取规则循环抓取
136
+            fileMap.forEach((key, fileList) -> {
137
+                if (CollectionUtil.isNotEmpty(fileList)) {
138
+                    for (File caseFile : fileList) {
139
+                        if (fatchRuleMap.containsKey(caseFile.getName())) {
140
+                            // 抓取内容
141
+                            List<FatchRule> fatchRules = fatchRuleMap.get(caseFile.getName());
142
+                            getFatchContentList(caseFile, fatchMap, fatchRules, key);
143
+                        }
144
+                    }
145
+                }
146
+            });
147
+
148
+        }
149
+        if (fatchMap.size() <= 0) {
150
+            return error("从压缩包中未抓取到内容,请检查抓取字段配置");
151
+        }
152
+        // 新增的案件
153
+        List<CaseApplication> caseApplications = new ArrayList<>();
154
+        //  从抓取规则表取字段和字典表取基本字段,字典表的字段名塞到基本表,is_default=1自定义字段塞到columnValue
155
+        // 抓取规则,0-内置字段,1-自定义字段
156
+        Map<Integer, List<FatchRule>> fatchRuleMap = fatchRuleList.stream().collect(Collectors.groupingBy(FatchRule::getIsDefault));
157
+        // 在系统表中查询案件内置字段
158
+        SysDictData sysDictData = new SysDictData();
159
+        sysDictData.setDictType("case_built_type");
160
+        List<SysDictData> dictDataList = dictDataMapper.selectDictDataList(sysDictData);
161
+        // 查询所有的组织机构,组装成map
162
+        List<SysDept> deptList = sysDeptMapper.selectDeptList(new SysDept());
163
+        // 所有部门
164
+        Map<String, Long> deptMap = new HashMap<>();
165
+        if (CollectionUtil.isNotEmpty(deptList)) {
166
+            deptMap = deptList.stream().collect(Collectors.toMap(SysDept::getDeptName, SysDept::getDeptId, (oldV, newV) -> newV));
167
+
168
+        }
169
+        // 角色用户
170
+        List<SysUserRole> userRoleList = new ArrayList<>();
171
+        // 查询申请人角色id
172
+        roleId = roleMapper.selectRoleIdByName("申请人");
173
+
174
+        // 案件基本信息
175
+        caseApplications = new ArrayList<>();
176
+        // 自定义字段,组装columnValue表
177
+        List<ColumnValue> columnValueList = new ArrayList<>();
178
+        // 案件人员
179
+        List<CaseAffiliate> caseAffiliates = new ArrayList<>();
180
+        // 组装机构
181
+        List<SysDept> sysDepts = new ArrayList<>();
182
+        // 案件附件
183
+        List<CaseAttach> caseAttachs = new ArrayList<>();
184
+        /**
185
+         * 用户表已存在的用户
186
+         */
187
+        List<SysUser> existUsers = userMapper.selectUserList(new SysUser());
188
+        Map<String, SysUser> userMap = new HashMap<>();
189
+        if (CollectionUtil.isNotEmpty(existUsers)) {
190
+            userMap = existUsers.stream().collect(Collectors.toMap(SysUser::getPhonenumber, Function.identity(), (n1, n2) -> n2));
191
+        }
192
+        //查询出当天的案件编号的最大值
193
+        String currentDay = DateUtils.dateTime();
194
+        String caseNum = "zc" + currentDay;
195
+         maxCaseNum = caseApplicationMapper.selectCaseNumLike(caseNum, caseNum.length());
196
+        // 需要新增的用户
197
+        List<SysUser> addUsers = new ArrayList<>();
198
+        for (Long caseId : fileMap.keySet()) {
199
+            if (CollectionUtil.isEmpty(fileMap.get(caseId))) {
200
+                continue;
201
+            }
202
+            CaseApplication caseApplication = new CaseApplication();
203
+            caseApplications.add(caseApplication);
204
+            caseApplication.setId(caseId);
205
+            caseApplication.setTemplateId(templateId);
206
+
207
+            caseApplication.setCaseStatus(CaseApplicationConstants.CASE_APPLICATION);
208
+            caseApplication.setCaseLogId(IdWorkerUtil.getId());
209
+            caseApplication.setUpdateSubmitStatus(UpdateSubmitStatus.UNCOMMITTED.getCode());
210
+            caseApplication.setCaseAppliId(caseApplication.getId());
211
+            //默认案件标的 todo 案件标的是什么,默认写死
212
+            caseApplication.setCaseSubjectAmount(new BigDecimal(100000));
213
+            //todo 暂时设置计费比率为0.01
214
+            BigDecimal feeRate = new BigDecimal(0.01);
215
+            BigDecimal feePayable = caseApplication.getCaseSubjectAmount().multiply(feeRate).setScale(2, BigDecimal.ROUND_HALF_UP);
216
+            caseApplication.setFeePayable(feePayable);
217
+            // 设置批号
218
+            if (StrUtil.isEmpty(caseApplication.getBatchNumber())) {
219
+                maxBatchNumber = caseApplicationMapper.selectBatchNumberLike();
220
+                if (maxBatchNumber == null) {
221
+                    maxBatchNumber=1;
222
+                    caseApplication.setBatchNumber(maxBatchNumber.toString());
223
+                } else {
224
+                    maxBatchNumber=maxBatchNumber+1;
225
+                    caseApplication.setBatchNumber( maxBatchNumber.toString());
226
+                }
227
+            }
228
+            // 设置编号
229
+            String maxCaseNumStr=generateCaseNum();
230
+            caseApplication.setCaseNum(maxCaseNumStr);
231
+            caseApplication.setCreateBy(getUsername());
232
+            caseApplication.setVersion(1);
233
+            // 组装案件内置字段主表内容
234
+
235
+            if (fatchRuleMap.size() > 0 && fatchRuleMap.containsKey(1)) {
236
+                List<FatchRule> columnRules = fatchRuleMap.get(1);
237
+                columnRules.forEach(columnRule -> {
238
+                    ColumnValue columnValue = new ColumnValue();
239
+                    columnValue.setColumn(columnRule.getColumn());
240
+                    columnValue.setName(columnRule.getColumnName());
241
+                    columnValue.setName(columnRule.getColumnName());
242
+                    columnValue.setValue(fatchMap.get(columnRule.getColumnName() + Constants.PDFSTR + caseId));
243
+                    columnValue.setIsDefault(1);
244
+                    columnValue.setCaseId(caseId);
245
+                    columnValue.setCaseAppliLogId(caseApplication.getCaseLogId());
246
+                    columnValueList.add(columnValue);
247
+                });
248
+            }
249
+            caseApplication.setColumnValues(columnValueList);
250
+            // 组装内置字段
251
+            buildDefaultColumn(caseApplication, dictDataList, fatchMap, caseAffiliates, deptMap, sysDepts, userMap, addUsers, userRoleList);
252
+            for (File caseFile : fileMap.get(caseId)) {
253
+                String fileUrl = caseFile.getAbsolutePath();
254
+                if (StrUtil.isEmpty(fileUrl)) {
255
+                    continue;
256
+                }
257
+                // 上传
258
+                String filePath = RuoYiConfig.getUploadPath();
259
+
260
+                CaseAttach caseAttach = new CaseAttach();
261
+                caseAttach.setCaseAppliId(caseApplication.getId());
262
+                caseAttach.setCaseAppliLogId(caseApplication.getCaseLogId());
263
+                caseAttach.setAnnexPath(filePath);
264
+                if (StrUtil.isNotEmpty(fileUrl)) {
265
+                    String fileName = fileUrl.replace(filePath, "/profile/upload");
266
+                    caseAttach.setAnnexName(fileName);
267
+                }
268
+                // 申请人提供的证据材料
269
+                caseAttach.setAnnexType(2);
270
+                caseAttachs.add(caseAttach);
271
+                if (fileUrl.contains("仲裁申请书")) {
272
+                    CaseAttach applyFile = new CaseAttach();
273
+                    BeanUtil.copyProperties(caseAttach, applyFile);
274
+                    applyFile.setAnnexType(1);
275
+                    caseAttachs.add(applyFile);
276
+                }
277
+            }
278
+            // 案件压缩包导入
279
+            caseApplication.setImportFlag(2);
280
+
281
+        }
282
+        // 多线程执行
283
+        List<MultipleThreadListParam> execList=new ArrayList<>();
284
+        if (CollectionUtil.isNotEmpty(addUsers)) {
285
+            Function<List<SysUser>,Integer> function=userMapper::batchSave;
286
+            execList.add(new MultipleThreadListParam(function,addUsers));
287
+        }
288
+        if (CollectionUtil.isNotEmpty(userRoleList)) {
289
+            Function<List<SysUserRole>,Integer> function=userRoleMapper::batchUserRole;
290
+            execList.add(new MultipleThreadListParam(function,userRoleList));
291
+
292
+        }
293
+        if (CollectionUtil.isNotEmpty(sysDepts)) {
294
+            Function<List<SysDept>,Integer> function=sysDeptMapper::batchSave;
295
+            execList.add(new MultipleThreadListParam(function,sysDepts));
296
+
297
+        }
298
+        if (CollectionUtil.isNotEmpty(caseApplications)) {
299
+            Function<List<CaseApplication>,Integer> function=caseApplicationMapper::batchSave;
300
+            execList.add(new MultipleThreadListParam(function,caseApplications));
301
+            Function<List<CaseApplication>,Integer> functionLog=caseApplicationLogMapper::batchSave;
302
+            execList.add(new MultipleThreadListParam(functionLog,caseApplications));
303
+
304
+        }
305
+        if (CollectionUtil.isNotEmpty(caseAffiliates)) {
306
+            Function<List<CaseAffiliate>,Integer> function=caseAffiliateMapper::batchCaseAffiliate;
307
+            execList.add(new MultipleThreadListParam(function,caseAffiliates));
308
+            Function<List<CaseAffiliate>,Integer> functionLog=caseAffiliateLogMapper::batchCaseAffiliate;
309
+            execList.add(new MultipleThreadListParam(functionLog,caseAffiliates));
310
+        }
311
+        if (CollectionUtil.isNotEmpty(caseAttachs)) {
312
+            Function<List<CaseAttach>,Integer> function=caseAttachMapper::batchSave;
313
+            execList.add(new MultipleThreadListParam(function,caseAttachs));
314
+            Function<List<CaseAttach>,Integer> functionLog=caseAttachLogMapper::batchSave;
315
+            execList.add(new MultipleThreadListParam(functionLog,caseAttachs));
316
+        }
317
+        if (CollectionUtil.isNotEmpty(columnValueList)) {
318
+            Function<List<ColumnValue>,Integer> function=columnValueMapper::batchSave;
319
+            execList.add(new MultipleThreadListParam(function,columnValueList));
320
+            Function<List<ColumnValue>,Integer> functionLog=columnValueLogMapper::batchSave;
321
+            execList.add(new MultipleThreadListParam(functionLog,columnValueList));
322
+        }
323
+        if(CollectionUtil.isNotEmpty(execList)){
324
+            MultipleThreadWorkUtil.execListFun(execList.toArray(new MultipleThreadListParam[execList.size()]));
325
+        }
326
+        return success("导入成功");
327
+
328
+    }
329
+    /**
330
+     * 获取自动编码
331
+     *
332
+     * @return
333
+     */
334
+
335
+    public String generateCaseNum() {
336
+        // 自动编码格式 zc+yyyyMMdd+001
337
+        String currentDay = DateUtils.dateTime();
338
+        String caseNum = "zc" + currentDay;
339
+
340
+
341
+        if (null == maxCaseNum) {
342
+            maxCaseNum=1;
343
+            caseNum = caseNum + "001";
344
+        } else {
345
+            maxCaseNum=maxCaseNum+1;
346
+            caseNum = caseNum + String.format("%03d", maxCaseNum);
347
+        }
348
+        return caseNum;
349
+
350
+    }
351
+    public void inputChangeToFile(InputStream instream, File file) {
352
+        try {
353
+            OutputStream outStr = new FileOutputStream(file);
354
+            int bytesRead = 0;
355
+            byte[] buffer = new byte[8192];
356
+            while ((bytesRead = instream.read(buffer, 0, 1024)) != -1) {
357
+                outStr.write(buffer, 0, bytesRead);
358
+            }
359
+            outStr.flush();
360
+            outStr.close();
361
+            instream.close();
362
+        } catch (Exception e) {
363
+            e.printStackTrace();
364
+        }
365
+    }
366
+
367
+    /**
368
+     * 查找文件
369
+     *
370
+     * @param directory
371
+     * @param
372
+     * @return
373
+     */
374
+    public static Map<Long, List<File>> findAndConvertPDF(File directory) {
375
+        //  caseMap<caseId,Map<fileName,filePath>>
376
+        Map<Long, List<File>> caseMap = new HashMap<>();
377
+        if (directory.isFile()) {
378
+            String path = "";
379
+            // 如果传入的参数是一个文件
380
+            path = directory.getAbsolutePath();
381
+            List<File> fileList = new ArrayList<>();
382
+            fileList.add(directory);
383
+            caseMap.put(IdWorkerUtil.getId(), fileList);
384
+
385
+        } else if (directory.isDirectory()) {
386
+            searchAndConvertPDF(directory, caseMap, 1, new HashMap<>());
387
+        } else {
388
+            return null;
389
+        }
390
+        return caseMap;
391
+    }
392
+
393
+    public static boolean isPDF(File file) {
394
+        String extension = FileUtils.getFileExtension(file);
395
+        return extension.equalsIgnoreCase("pdf");
396
+    }
397
+
398
+
399
+    /**
400
+     * 递归查找文件夹
401
+     *
402
+     * @param directory
403
+     * @param caseMap<caseId,List<file>>
404
+     * @param i                          第几层文件夹
405
+     * @param fileMap<filePath,caseId>>
406
+     */
407
+    public static void searchAndConvertPDF(File directory, Map<Long, List<File>> caseMap, int i, Map<String, Long> fileMap) {
408
+        File[] files = directory.listFiles();
409
+        // 约定压缩包第二层一个文件夹为一个案件
410
+        if (files != null) {
411
+            if (i == 2) {
412
+                for (File file : files) {
413
+                    fileMap.put(file.getAbsolutePath(), IdWorkerUtil.getId());
414
+                }
415
+            }
416
+            i++;
417
+            for (File file : files) {
418
+
419
+                if (file.getName().contains("zip") || file.getName().contains("rar")) {
420
+                    continue;
421
+                }
422
+                if (file.isFile()) {
423
+                    for (Map.Entry<String, Long> entry : fileMap.entrySet()) {
424
+                        // 为同一个案件
425
+                        if (!file.getAbsolutePath().contains(entry.getKey())) {
426
+                            continue;
427
+                        }
428
+                        List<File> fileList;
429
+                        if (caseMap.containsKey(entry.getValue())) {
430
+                            fileList = caseMap.get(entry.getValue());
431
+                        } else {
432
+                            fileList = new ArrayList<>();
433
+                        }
434
+                        fileList.add(file);
435
+                        caseMap.put(entry.getValue(), fileList);
436
+
437
+                    }
438
+
439
+                } else if (file.isDirectory()) {
440
+                    // 如果是目录,递归查找
441
+                    searchAndConvertPDF(file, caseMap, i, fileMap);
442
+                }
443
+            }
444
+        }
445
+    }
446
+
447
+
448
+    private static int getFileNumPage(String pdfUrl) {
449
+        File pdfFile = new File(pdfUrl);
450
+        int pageCount = 0;
451
+        try (PDDocument document = PDDocument.load(pdfFile)) {
452
+            pageCount = document.getNumberOfPages();
453
+        } catch (IOException e) {
454
+            e.printStackTrace();
455
+        }
456
+        return pageCount;
457
+    }
458
+
459
+    /**
460
+     * 获取模板和正文中替换符的内容
461
+     *
462
+     * @param a
463
+     * @param b
464
+     * @return
465
+     */
466
+    public static List<String> getReplaceList(String a, String b) {
467
+        String aTmpe = filterString(a);
468
+        String bTmpe = filterString(b);
469
+        String regex = "(\\{[^}}]*})";
470
+        String[] ptTemplate = aTmpe.replaceAll(regex, "@=").split("@=");
471
+        String replace = "";
472
+        for (int i = 0; i < ptTemplate.length; i++) {
473
+            if (ptTemplate[i] == null || ptTemplate[i].equals(" ")) continue;
474
+            if (replace.equals("")) {
475
+                replace = bTmpe.replace(ptTemplate[i], "@=");
476
+            } else {
477
+                replace = replace.replace(ptTemplate[i], "@=");
478
+            }
479
+        }
480
+        List<String> aList = new ArrayList<>();
481
+        String[] split = replace.split("@=");
482
+        for (int i = 0; i < split.length; i++) {
483
+            if (split[i] == "" || split[i].equals("")) continue;
484
+            aList.add(split[i]);
485
+        }
486
+        return aList;
487
+    }
488
+
489
+    // 去掉内容中的换行符
490
+    public static String filterString(String str) {
491
+        if (str == null || str.equals("")) {
492
+            return null;
493
+        }
494
+        String regEx = "[\\r\\n]";
495
+        Pattern p = Pattern.compile(regEx);
496
+        Matcher m = p.matcher(str);
497
+        return m.replaceAll(" ").trim();
498
+    }
499
+
500
+    // 检索时,转换特殊字符
501
+    public static String escapeQueryChars(String s) {
502
+        if (StringUtils.isBlank(s)) {
503
+            return s;
504
+        }
505
+        StringBuilder sb = new StringBuilder();
506
+        for (int i = 0; i < s.length(); i++) {
507
+            char c = s.charAt(i);
508
+            // These characters are part of the query syntax and must be escaped
509
+            if (c == '\\' || c == '+' || c == '-' || c == '!' || c == '(' || c == ')'
510
+                    || c == ':' || c == '^' || c == '[' || c == ']' || c == '\"'
511
+                    || c == '{' || c == '}' || c == '~' || c == '*' || c == '?'
512
+                    || c == '|' || c == '&' || c == ';' || c == '/' || c == '.'
513
+                    || c == '$' || Character.isWhitespace(c)) {
514
+                sb.append('\\');
515
+            }
516
+            sb.append(c);
517
+        }
518
+        return sb.toString();
519
+    }
520
+
521
+    /**
522
+     * 组装内置字段
523
+     *
524
+     * @param caseApplication 案件信息
525
+     * @param dictDataList    内置字段
526
+     * @param fatchMap        抓取字段内容
527
+     */
528
+    private void buildDefaultColumn(CaseApplication caseApplication, List<SysDictData> dictDataList, Map<String, String> fatchMap,
529
+                                    List<CaseAffiliate> caseAffiliates, Map<String, Long> deptMap, List<SysDept> sysDepts,
530
+                                    Map<String, SysUser> userMap, List<SysUser> addUsers, List<SysUserRole> userRoleList) {
531
+        // 组装内置字段
532
+        if (CollectionUtil.isEmpty(dictDataList)) {
533
+            return;
534
+        }
535
+        // 被申请人
536
+        CaseAffiliate debtorAffiliate = new CaseAffiliate();
537
+        debtorAffiliate.setCaseAppliId(caseApplication.getId());
538
+        debtorAffiliate.setCaseAppliLogId(caseApplication.getCaseLogId());
539
+        // 申请人
540
+        CaseAffiliate affiliate = new CaseAffiliate();
541
+        affiliate.setCaseAppliLogId(caseApplication.getCaseLogId());
542
+        affiliate.setCaseAppliId(caseApplication.getId());
543
+        for (SysDictData dictData : dictDataList) {
544
+            if (StrUtil.isNotEmpty(dictData.getDictLabel())) {
545
+                if (dictData.getDictLabel().contains("被申请人")) {
546
+                    // 组装被申请人内置自段
547
+                    buildDebtorColumn(dictData, fatchMap, debtorAffiliate,caseApplication.getId());
548
+                } else if (dictData.getDictLabel().contains("申请人") || dictData.getDictLabel().contains("统一社会信用代码")
549
+                        || dictData.getDictLabel().contains("法定代表人") || dictData.getDictLabel().contains("委托代理人")) {
550
+                    // 组装申请人内置自段
551
+                    buildAffilcateColumn(dictData, fatchMap, affiliate, deptMap, sysDepts, userMap, addUsers, userRoleList,caseApplication.getId());
552
+                } else if (dictData.getDictLabel().contains("合同编号")) {
553
+                    // 合同编号
554
+                    String contractNumber = fatchMap.get("合同编号"+ Constants.PDFSTR + caseApplication.getId());
555
+                    if (StrUtil.isNotEmpty(contractNumber)) {
556
+                        // 提取字母和数字
557
+                        String regx = "[^a-zA-Z0-9]";
558
+                        String replaceAll = contractNumber.replaceAll(regx, "");
559
+                        caseApplication.setContractNumber(replaceAll.toUpperCase());
560
+                    }
561
+                } else {
562
+                    ObjectFieldUtils.setValue(caseApplication, dictData.getDictValue(), fatchMap.get(dictData.getDictLabel()+ Constants.PDFSTR + caseApplication.getId()));
563
+                }
564
+
565
+            } else {
566
+                ObjectFieldUtils.setValue(caseApplication, dictData.getDictValue(), fatchMap.get(dictData.getDictLabel()+ Constants.PDFSTR + caseApplication.getId()));
567
+
568
+            }
569
+
570
+        }
571
+        if (ObjectUtil.isNotEmpty(affiliate)) {
572
+            caseAffiliates.add(affiliate);
573
+        }
574
+        if (ObjectUtil.isNotEmpty(debtorAffiliate)) {
575
+            caseAffiliates.add(debtorAffiliate);
576
+        }
577
+
578
+
579
+    }
580
+
581
+    /**
582
+     * 组装申请人内置字段
583
+     *
584
+     * @param dictData  内置字段
585
+     * @param fatchMap  抓取内容
586
+     * @param affiliate 案件人员
587
+     */
588
+    private void buildAffilcateColumn(SysDictData dictData, Map<String, String> fatchMap, CaseAffiliate affiliate,
589
+                                      Map<String, Long> deptMap, List<SysDept> sysDepts,
590
+                                      Map<String, SysUser> userMap, List<SysUser> addUsers, List<SysUserRole> userRoleList,Long caseId) {
591
+
592
+        affiliate.setIdentityType(1);
593
+
594
+        // 申请人
595
+        switch (dictData.getDictLabel()) {
596
+            case "申请人姓名":
597
+                affiliate.setName((fatchMap.get(dictData.getDictLabel()+ Constants.PDFSTR + caseId)));
598
+                if (StrUtil.isNotEmpty(affiliate.getName())) {
599
+                    // 组装申请机构
600
+                    // 将组织机构id设为申请人名称
601
+                    if (deptMap.containsKey(affiliate.getName())) {
602
+                        affiliate.setApplicationOrganId(String.valueOf(deptMap.get(affiliate.getName())));
603
+                        affiliate.setApplicationOrganName(affiliate.getName());
604
+                    } else {
605
+                        // 如果不存在则新增
606
+                        SysDept dept = new SysDept();
607
+                        dept.setParentId(0L);
608
+                        dept.setDeptName(affiliate.getName());
609
+                        dept.setAncestors("0");
610
+                        dept.setOrderNum(1);
611
+                        dept.setStatus("0");
612
+                        dept.setDelFlag("0");
613
+                        dept.setCreateBy(getUsername());
614
+                        dept.setUpdateBy(getUsername());
615
+                        dept.setDeptId(Long.valueOf(IdWorkerUtil.getId()));
616
+                        sysDepts.add(dept);
617
+                        deptMap.put(dept.getDeptName(), dept.getDeptId());
618
+                        affiliate.setApplicationOrganId(String.valueOf(dept.getDeptId()));
619
+                        affiliate.setApplicationOrganName(affiliate.getName());
620
+
621
+                    }
622
+                }
623
+                break;
624
+            case "统一社会信用代码":
625
+                affiliate.setIdentityNum((fatchMap.get(dictData.getDictLabel()+ Constants.PDFSTR + caseId)));
626
+                break;
627
+            case "法定代表人":
628
+                affiliate.setCompLegalPerson(fatchMap.get(dictData.getDictLabel()+ Constants.PDFSTR + caseId));
629
+                break;
630
+            case "法定代表人职位":
631
+                affiliate.setCompLegalperPost((fatchMap.get(dictData.getDictLabel()+ Constants.PDFSTR + caseId)));
632
+                break;
633
+            case "申请人住所":
634
+                affiliate.setResidenAffili((fatchMap.get(dictData.getDictLabel()+ Constants.PDFSTR + caseId)));
635
+                break;
636
+            case "申请人联系地址":
637
+                affiliate.setContactAddress(fatchMap.get(dictData.getDictLabel()+ Constants.PDFSTR + caseId));
638
+                break;
639
+            case "委托代理人姓名":
640
+                affiliate.setNameAgent(fatchMap.get(dictData.getDictLabel()+ Constants.PDFSTR + caseId));
641
+                break;
642
+            case "委托代理人联系电话":
643
+                affiliate.setContactTelphoneAgent(fatchMap.get(dictData.getDictLabel()+ Constants.PDFSTR + caseId));
644
+                if (StrUtil.isNotEmpty(affiliate.getContactTelphoneAgent())) {
645
+                    // 用户已存在
646
+                    if (userMap.containsKey(affiliate.getContactTelphoneAgent())) {
647
+                        SysUser agentUser = userMap.get(affiliate.getContactTelphoneAgent());
648
+                        if (null != agentUser.getDeptId() && String.valueOf(agentUser.getDeptId()).equals(affiliate.getApplicationOrganId())) {
649
+                            // 同步用户表和案件关联人表的手机号和名称
650
+                            affiliate.setContactTelphoneAgent(agentUser.getPhonenumber());
651
+                            affiliate.setNameAgent(agentUser.getNickName());
652
+                            affiliate.setApplicantAgentUserId(String.valueOf(agentUser.getUserId()));
653
+                            if (StrUtil.isNotEmpty(agentUser.getIdCard())) {
654
+                                affiliate.setIdentityNumAgent(agentUser.getIdCard());
655
+                            } else {
656
+                                affiliate.setIdentityNumAgent(affiliate.getIdentityNumAgent());
657
+                            }
658
+                            List<Long> longList = new ArrayList<>();
659
+                            // 新增角色为申请人
660
+                            if (CollectionUtil.isNotEmpty(agentUser.getRoles())) {
661
+                                longList = agentUser.getRoles().stream().map(SysRole::getRoleId).collect(Collectors.toList());
662
+                                if (!longList.contains(roleId)) {
663
+                                    insertAgentUserRole(agentUser, roleId, userRoleList);
664
+                                }
665
+                            } else {
666
+
667
+                                insertAgentUserRole(agentUser, roleId, userRoleList);
668
+                            }
669
+
670
+                        }
671
+                    } else {
672
+                        // 用户不存在,新增
673
+                        SysUser agentUser = new SysUser();
674
+                        agentUser.setUserId(Long.valueOf(IdWorkerUtil.getId()));
675
+                        agentUser.setIdCard(affiliate.getIdentityNumAgent());
676
+                        agentUser.setNickName(affiliate.getNameAgent());
677
+                        agentUser.setUserName(affiliate.getContactTelphoneAgent());
678
+                        agentUser.setPhonenumber(affiliate.getContactTelphoneAgent());
679
+                        agentUser.setPassword(SecurityUtils.encryptPassword("abc123456"));
680
+                        agentUser.setDeptId(Long.valueOf(affiliate.getApplicationOrganId()));
681
+                        addUsers.add(agentUser);
682
+                        userMap.put(agentUser.getPhonenumber(), agentUser);
683
+                        insertAgentUserRole(agentUser, roleId, userRoleList);
684
+
685
+                    }
686
+                }
687
+                break;
688
+            case "委托代理人电子邮件":
689
+                affiliate.setAgentEmail(StrUtil.isNotEmpty(fatchMap.get(dictData.getDictLabel()+ Constants.PDFSTR + caseId)) ? fatchMap.get(dictData.getDictLabel()+ Constants.PDFSTR + caseId).replace("\n", "").replaceAll("\\s", "") : null);
690
+
691
+                break;
692
+            default:
693
+                break;
694
+        }
695
+    }
696
+
697
+    /**
698
+     * 新增角色为申请人
699
+     *
700
+     * @param agentUser
701
+     * @param roleId
702
+     */
703
+    private void insertAgentUserRole(SysUser agentUser, Long roleId, List<SysUserRole> userRoleList) {
704
+
705
+        SysUserRole sysUserRole = new SysUserRole();
706
+        sysUserRole.setUserId(agentUser.getUserId());
707
+        sysUserRole.setRoleId(roleId);
708
+        userRoleList.add(sysUserRole);
709
+
710
+    }
711
+
712
+    /**
713
+     * 组装被申请人内置字段
714
+     *
715
+     * @param dictData        内置字段
716
+     * @param fatchMap        抓取内容
717
+     * @param debtorAffiliate 被申请人
718
+     */
719
+    private void buildDebtorColumn(SysDictData dictData, Map<String, String> fatchMap, CaseAffiliate debtorAffiliate,Long caseId) {
720
+
721
+        debtorAffiliate.setIdentityType(2);
722
+        // 被申请人
723
+        switch (dictData.getDictLabel()) {
724
+            case "被申请人姓名":
725
+                debtorAffiliate.setName(fatchMap.get(dictData.getDictLabel()+ Constants.PDFSTR + caseId));
726
+                break;
727
+            case "被申请人身份证号":
728
+                String identityNum = fatchMap.get(dictData.getDictLabel()+ Constants.PDFSTR + caseId);
729
+                debtorAffiliate.setIdentityNum(fatchMap.get(dictData.getDictLabel()+ Constants.PDFSTR + caseId));
730
+                // 出生年月日,从身份证抓取
731
+                if (StrUtil.isNotEmpty(identityNum)) {
732
+                    identityNum = identityNum.replace("\n", "");
733
+                    Map<String, String> identityNumMap = IdCardUtils.getBirAgeSex(identityNum);
734
+                    String birthday = identityNumMap.get("birthday");
735
+                    if (StrUtil.isNotEmpty(birthday)) {
736
+                        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
737
+                        Date birthdayDate = null;
738
+                        try {
739
+                            birthdayDate = simpleDateFormat.parse(birthday);
740
+                        } catch (Exception e) {
741
+                            e.printStackTrace();
742
+                        }
743
+                        debtorAffiliate.setResponBirth(birthdayDate);
744
+                    }
745
+                    //从身份证抓取性别
746
+                    debtorAffiliate.setResponSex(identityNumMap.get("sexCode"));
747
+                }
748
+
749
+                break;
750
+            case "被申请人住所":
751
+                debtorAffiliate.setResidenAffili(fatchMap.get(dictData.getDictLabel()+ Constants.PDFSTR + caseId));
752
+                break;
753
+            case "被申请人联系电话":
754
+                debtorAffiliate.setContactTelphone(fatchMap.get(dictData.getDictLabel()+ Constants.PDFSTR + caseId));
755
+                break;
756
+            case "被申请人电子邮件":
757
+                debtorAffiliate.setEmail(StrUtil.isNotEmpty(fatchMap.get(dictData.getDictLabel()+ Constants.PDFSTR + caseId)) ? fatchMap.get(dictData.getDictLabel()+ Constants.PDFSTR + caseId).replace("\n", "").replaceAll("\\s", "") : null);
758
+
759
+                break;
760
+            default:
761
+                break;
762
+        }
763
+
764
+    }
765
+
766
+    /**
767
+     * 获取抓取内容
768
+     *
769
+     * @param fatchRules 抓取规则
770
+     */
771
+    private void getFatchContentList(File caseFile, Map<String, String> fatchMap, List<FatchRule> fatchRules, Long caseId) {
772
+        String fileURL = caseFile.getAbsolutePath();
773
+        if (fileURL.endsWith("txt")) {
774
+            String readerFile = ReadFileUtils.readerTxtFile(fileURL);
775
+            OCRUtils.fatchRuleGetContent(readerFile, fatchRules, fatchMap, caseId);
776
+        } else if (fileURL.endsWith("doc") || fileURL.endsWith("docx")) {
777
+            // doc,docx,text识别内容
778
+            String readerFile = null;
779
+            try {
780
+                readerFile = ReadFileUtils.readWord(fileURL);
781
+            } catch (Exception e) {
782
+                e.printStackTrace();
783
+            }
784
+            OCRUtils.fatchRuleGetContent(readerFile, fatchRules, fatchMap, caseId);
785
+
786
+        } else if (fileURL.endsWith("pdf")) {
787
+            //获取文件的页数
788
+            int fileNumPage = getFileNumPage(fileURL);
789
+            //文件转成base64
790
+            String base64 = OCRUtils.pdfConvertBase64(fileURL);
791
+            if (base64 == null) {
792
+                throw new ServiceException("pdf转base64失败");
793
+                //  return false;
794
+            }
795
+            StringBuilder ocrText = new StringBuilder(); // 创建一个StringBuilder对象
796
+            for (int i = 1; i <= fileNumPage; i++) {
797
+                //对接腾讯云接口.识别里面的数据
798
+                String text = OCRUtils.pdfIdentifyText(base64, i, fatchRules);
799
+                ocrText.append(text); // 拼接当前的字符串
800
+                // 根据抓取规则截取内容
801
+                OCRUtils.fatchRuleGetContent(ocrText.toString(), fatchRules, fatchMap, caseId);
802
+
803
+            }
804
+        }
805
+
806
+
807
+    }
808
+
809
+
810
+
811
+}

+ 48
- 58
ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/utils/OCRUtils.java Parādīt failu

@@ -118,10 +118,10 @@ public class OCRUtils {
118 118
         for (FatchRule fatchRule : fatchRules) {
119 119
             // 从后往前抓取
120 120
             if (fatchRule.getFatchOrder() != null && fatchRule.getFatchOrder() == 1) {
121
-                reverseSubstringText(ocrText, fatchRule, fatchMap);
121
+                reverseSubstringText(ocrText, fatchRule, fatchMap,null);
122 122
             } else {
123 123
                 // 从前往后抓取
124
-                substringText(ocrText, fatchRule, fatchMap);
124
+                substringText(ocrText, fatchRule, fatchMap,null);
125 125
 
126 126
             }
127 127
         }
@@ -129,43 +129,32 @@ public class OCRUtils {
129 129
 
130 130
     }
131 131
 
132
-    public static void sub1(String text, FatchRule fatchRule, Map<String, String> fatchMap) {
133
-        if (StrUtil.isEmpty(fatchRule.getStartContent()) && StrUtil.isEmpty(fatchRule.getEndContent())) {
134
-            fatchMap.put(fatchRule.getColumnName(), trimStr(text));
135
-        } else if (StrUtil.isNotEmpty(fatchRule.getStartContent())) {
136
-            int startContIndex = StrUtil.ordinalIndexOf(text, fatchRule.getStartContent(), fatchRule.getStartContentRepeatOrder());
137
-            if (startContIndex != -1) {
138
-                // 开始不为空结束为空
139
-                if (StrUtil.isEmpty(fatchRule.getEndContent())) {
140
-                    if ((startContIndex + fatchRule.getStartContent().length()) <= text.length()) {
141
-                        String substring = text.substring(startContIndex + fatchRule.getStartContent().length());
142
-                        // 去除\n
143
-                        fatchMap.put(fatchRule.getColumnName(), trimStr(substring));
144
-                    }
145
-
146
-                } else {
147
-                    // 开始不为空结束不为空
148
-                    int endContIndex = StrUtil.ordinalIndexOf(text, fatchRule.getEndContent(), fatchRule.getEndContentRepeatOrder());
149
-                    if (endContIndex != -1 && endContIndex <= text.length() && (startContIndex + fatchRule.getStartContent().length()) <= endContIndex) {
150
-                        String substring = text.substring(startContIndex + fatchRule.getStartContent().length(), endContIndex);
151
-                        // 去除\n
152
-                        fatchMap.put(fatchRule.getColumnName(), trimStr(substring));
153
-                    }
154
-
155
-                }
156
-//
157
-            }
132
+    /**
133
+     * 根据抓取规则获取内容
134
+     *
135
+     * @param ocrText    ocr识别的text
136
+     * @param fatchRules 抓取规则
137
+     * @return
138
+     */
139
+    public static void fatchRuleGetContent(String ocrText, List<FatchRule> fatchRules, Map<String, String> fatchMap, Long caseId) {
140
+        if (StrUtil.isEmpty(ocrText) || CollectionUtil.isEmpty(fatchRules)) {
141
+            return;
142
+        }
143
+        for (FatchRule fatchRule : fatchRules) {
144
+            // 从后往前抓取
145
+            if (fatchRule.getFatchOrder() != null && fatchRule.getFatchOrder() == 1) {
146
+                reverseSubstringText(ocrText, fatchRule, fatchMap, caseId);
147
+            } else {
148
+                // 从前往后抓取
149
+                substringText(ocrText, fatchRule, fatchMap, caseId);
158 150
 
159
-        } else if (StrUtil.isEmpty(fatchRule.getStartContent()) && StrUtil.isNotEmpty(fatchRule.getEndContent())) {
160
-            // 开始为空结束不为空
161
-            int endContIndex = StrUtil.ordinalIndexOf(text, fatchRule.getEndContent(), fatchRule.getEndContentRepeatOrder());
162
-            if (endContIndex != -1) {
163
-                String substring = text.substring(0, endContIndex);
164
-                fatchMap.put(fatchRule.getColumnName(), trimStr(substring));
165 151
             }
166 152
         }
153
+
154
+
167 155
     }
168 156
 
157
+
169 158
     /**
170 159
      * 正向截取字段
171 160
      *
@@ -173,19 +162,19 @@ public class OCRUtils {
173 162
      * @param fatchRule
174 163
      * @param fatchMap
175 164
      */
176
-    private static void substringText(String text, FatchRule fatchRule, Map<String, String> fatchMap) {
165
+    private static void substringText(String text, FatchRule fatchRule, Map<String, String> fatchMap, Long caseId) {
177 166
         String startContent = fatchRule.getStartContent();
178 167
         String endContent = fatchRule.getEndContent();
179 168
         // 开始为空结束为空
180 169
         if (StrUtil.isEmpty(startContent) && StrUtil.isEmpty(endContent)) {
181
-            fatchMap.put(fatchRule.getColumnName(), trimStr(text));
170
+            fatchMap.put(fatchRule.getColumnName()+Constants.PDFSTR+caseId, trimStr(text));
182 171
         } else if (StrUtil.isNotEmpty(startContent) && StrUtil.isEmpty(endContent)) {
183 172
             // 开始不为空结束为空
184 173
             int startContIndex = StrUtil.ordinalIndexOf(text, startContent, fatchRule.getStartContentRepeatOrder());
185 174
             if (startContIndex != -1 && text.length() >= (startContIndex + startContent.length())) {
186 175
                 String substring = text.substring(startContIndex + startContent.length());
187 176
                 // 去除\n
188
-                fatchMap.put(fatchRule.getColumnName(), trimStr(substring));
177
+                fatchMap.put(fatchRule.getColumnName()+Constants.PDFSTR+caseId, trimStr(substring));
189 178
             }
190 179
 
191 180
         } else if (StrUtil.isEmpty(startContent) && StrUtil.isNotEmpty(endContent)) {
@@ -193,7 +182,7 @@ public class OCRUtils {
193 182
             int endContIndex = StrUtil.ordinalIndexOf(text, endContent, fatchRule.getEndContentRepeatOrder());
194 183
             if (endContIndex != -1) {
195 184
                 String substring = text.substring(0, endContIndex);
196
-                fatchMap.put(fatchRule.getColumnName(), trimStr(substring));
185
+                fatchMap.put(fatchRule.getColumnName()+Constants.PDFSTR+caseId, trimStr(substring));
197 186
             }
198 187
         } else if (StrUtil.isNotEmpty(startContent) && StrUtil.isNotEmpty(endContent)) {
199 188
             // 开始结束不为空
@@ -202,26 +191,12 @@ public class OCRUtils {
202 191
             if (startIndexOf != -1 && endIndexOf != -1 && endIndexOf >= (startIndexOf + startContent.length()) && text.length() >= endIndexOf) {
203 192
                 String substring = text.substring(startIndexOf + startContent.length(), endIndexOf);
204 193
 
205
-                fatchMap.put(fatchRule.getColumnName(), trimStr(substring));
194
+                fatchMap.put(fatchRule.getColumnName()+Constants.PDFSTR+caseId, trimStr(substring));
206 195
 
207 196
             }
208 197
         }
209 198
     }
210 199
 
211
-    /**
212
-     * 去除末尾空格
213
-     *
214
-     * @param substring
215
-     * @return
216
-     */
217
-    private static String trimStr(String substring) {
218
-        if (StrUtil.isNotEmpty(substring)) {
219
-            return StrUtil.trim(substring);
220
-        } else {
221
-            return "";
222
-        }
223
-
224
-    }
225 200
 
226 201
     /**
227 202
      * 从后往前截取字符串
@@ -230,7 +205,7 @@ public class OCRUtils {
230 205
      * @param fatchRule
231 206
      * @param fatchMap
232 207
      */
233
-    public static void reverseSubstringText(String text, FatchRule fatchRule, Map<String, String> fatchMap) {
208
+    public static void reverseSubstringText(String text, FatchRule fatchRule, Map<String, String> fatchMap, Long caseId) {
234 209
 
235 210
         // 反正字符串
236 211
         String reverseText = StrUtil.reverse(text);
@@ -246,7 +221,7 @@ public class OCRUtils {
246 221
         }
247 222
         // 开始和结束截取都为空
248 223
         if (StrUtil.isEmpty(reverseStartContent) && StrUtil.isEmpty(reverseEndContent)) {
249
-            fatchMap.put(fatchRule.getColumnName(), trimStr(text));
224
+            fatchMap.put(fatchRule.getColumnName()+Constants.PDFSTR+caseId, trimStr(text));
250 225
         } else if (StrUtil.isEmpty(reverseStartContent) && StrUtil.isNotEmpty(reverseEndContent)) {
251 226
             // 开始为空,结束不为空
252 227
             // 根据截取的序号查找出位置
@@ -254,7 +229,7 @@ public class OCRUtils {
254 229
             if (indexOf != -1) {
255 230
                 String substring = reverseText.substring(0, indexOf);
256 231
                 if (StrUtil.isNotEmpty(substring)) {
257
-                    fatchMap.put(fatchRule.getColumnName(), trimStr(StrUtil.reverse(substring)));
232
+                    fatchMap.put(fatchRule.getColumnName()+Constants.PDFSTR+caseId, trimStr(StrUtil.reverse(substring)));
258 233
                 }
259 234
             }
260 235
         } else if (StrUtil.isNotEmpty(reverseStartContent) && StrUtil.isEmpty(reverseEndContent)) {
@@ -263,7 +238,7 @@ public class OCRUtils {
263 238
             if (indexOf != -1 && (indexOf + reverseStartContent.length() <= text.length())) {
264 239
                 String substring = reverseText.substring(indexOf + reverseStartContent.length());
265 240
                 if (StrUtil.isNotEmpty(substring)) {
266
-                    fatchMap.put(fatchRule.getColumnName(), trimStr(StrUtil.reverse(substring)));
241
+                    fatchMap.put(fatchRule.getColumnName()+Constants.PDFSTR+caseId, trimStr(StrUtil.reverse(substring)));
267 242
                 }
268 243
             }
269 244
 
@@ -274,7 +249,7 @@ public class OCRUtils {
274 249
             if (startIndexOf != -1 && endIndexOf != -1 && endIndexOf >= (startIndexOf + reverseStartContent.length()) && text.length() >= endIndexOf) {
275 250
                 String substring = reverseText.substring(startIndexOf + reverseStartContent.length(), endIndexOf);
276 251
                 if (StrUtil.isNotEmpty(substring)) {
277
-                    fatchMap.put(fatchRule.getColumnName(), trimStr(StrUtil.reverse(substring)));
252
+                    fatchMap.put(fatchRule.getColumnName()+Constants.PDFSTR+caseId, trimStr(StrUtil.reverse(substring)));
278 253
                 }
279 254
             }
280 255
         }
@@ -282,4 +257,19 @@ public class OCRUtils {
282 257
 
283 258
     }
284 259
 
260
+    /**
261
+     * 去除末尾空格
262
+     *
263
+     * @param substring
264
+     * @return
265
+     */
266
+    private static String trimStr(String substring) {
267
+        if (StrUtil.isNotEmpty(substring)) {
268
+            return StrUtil.trim(substring);
269
+        } else {
270
+            return "";
271
+        }
272
+
273
+    }
274
+
285 275
 }

+ 35
- 2
ruoyi-system/src/main/resources/mapper/system/SysDeptMapper.xml Parādīt failu

@@ -121,8 +121,41 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
121 121
  			sysdate()
122 122
  		);
123 123
 	</insert>
124
-	
125
-	<update id="updateDept" parameterType="SysDept">
124
+    <insert id="batchSave">
125
+		insert into sys_dept(
126
+		dept_id,
127
+		parent_id,
128
+		dept_name,
129
+		dept_type,
130
+		ancestors,
131
+		order_num,
132
+		leader,
133
+		phone,
134
+		email,
135
+		status,
136
+		create_by,
137
+		create_time
138
+		)values
139
+		<foreach item="item" index="index" collection="list" separator=",">
140
+		(
141
+		#{item.deptId},
142
+		#{item.parentId},
143
+		#{item.deptName},
144
+		#{item.deptType},
145
+		#{item.ancestors},
146
+		#{item.orderNum},
147
+		#{item.leader},
148
+		#{item.phone},
149
+		#{item.email},
150
+		#{item.status},
151
+		#{item.createBy},
152
+		sysdate()
153
+		)
154
+		</foreach>;
155
+
156
+	</insert>
157
+
158
+    <update id="updateDept" parameterType="SysDept">
126 159
  		update sys_dept
127 160
  		<set>
128 161
  			<if test="parentId != null and parentId != 0">parent_id = #{parentId},</if>

+ 43
- 3
ruoyi-system/src/main/resources/mapper/system/SysUserMapper.xml Parādīt failu

@@ -59,8 +59,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
59 59
     </sql>
60 60
     
61 61
     <select id="selectUserList" parameterType="SysUser" resultMap="SysUserResult">
62
-		select u.user_id, u.dept_id, u.nick_name, u.user_name,u.id_card, u.email, u.avatar, u.phonenumber, u.sex, u.status, u.del_flag, u.login_ip, u.login_date, u.create_by, u.create_time, u.remark, d.dept_name, d.leader from sys_user u
62
+		select u.user_id, u.dept_id, u.nick_name, u.user_name,u.id_card, u.email, u.avatar, u.phonenumber, u.sex, u.status, u.del_flag, u.login_ip, u.login_date, u.create_by, u.create_time, u.remark, d.dept_name,
63
+		 d.leader , r.role_id, r.role_name, d.dept_id
64
+		from sys_user u
63 65
 		left join sys_dept d on u.dept_id = d.dept_id
66
+		left join sys_user_role ur on u.user_id = ur.user_id
67
+		left join sys_role r on r.role_id = ur.role_id
64 68
 		where u.del_flag = '0'
65 69
 		<if test="userId != null and userId != 0">
66 70
 			AND u.user_id = #{userId}
@@ -244,8 +248,44 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
244 248
  			sysdate()
245 249
  		)
246 250
 	</insert>
247
-	
248
-	<update id="updateUser" parameterType="SysUser">
251
+    <insert id="batchSave">
252
+		insert into sys_user(
253
+		user_id,
254
+		dept_id,
255
+		user_name,
256
+		nick_name,
257
+		id_card,
258
+		email,
259
+		avatar,
260
+		phonenumber,
261
+		sex,
262
+		password,
263
+		status,
264
+		create_by,
265
+		remark,
266
+		create_time
267
+		)values
268
+		<foreach item="item" index="index" collection="list" separator=",">
269
+		(
270
+		#{item.userId},
271
+		#{item.deptId},
272
+		#{item.userName},
273
+		#{item.nickName},
274
+		#{item.idCard},
275
+		#{item.email},
276
+		#{item.avatar},
277
+		#{item.phonenumber},
278
+		#{item.sex},
279
+		#{item.password},
280
+		#{item.status},
281
+		#{item.createBy},
282
+		#{item.remark},
283
+		sysdate()
284
+		)
285
+		</foreach>;
286
+	</insert>
287
+
288
+    <update id="updateUser" parameterType="SysUser">
249 289
  		update sys_user
250 290
  		<set>
251 291
  			<if test="deptId != null and deptId != 0">dept_id = #{deptId},</if>

+ 1
- 1
ruoyi-system/src/main/resources/mapper/wisdomarbitrate/CaseAffiliateLogMapper.xml Parādīt failu

@@ -80,7 +80,7 @@
80 80
             #{item.applicantAgentUserId},
81 81
             #{item.agentEmail}
82 82
             )
83
-        </foreach>
83
+        </foreach>;
84 84
     </insert>
85 85
 
86 86
 

+ 62
- 0
ruoyi-system/src/main/resources/mapper/wisdomarbitrate/CaseApplicationLogMapper.xml Parādīt failu

@@ -119,6 +119,68 @@
119 119
         sysdate()
120 120
         )
121 121
     </insert>
122
+    <insert id="batchSave">
123
+        insert into case_application_log(
124
+        id,
125
+       case_appli_id ,
126
+       case_name ,
127
+       case_num,
128
+       case_subject_amount,
129
+       arbitrat_claims,
130
+        request_rule,
131
+        loan_start_date,
132
+        loan_end_date,
133
+        claim_princi_owed,
134
+        claim_interest_owed,
135
+        claim_liquid_damag,
136
+        fee_payable,
137
+        contract_number,
138
+        create_by,
139
+        version,
140
+        update_submit_status,
141
+        proper_preser,
142
+        interest_rate,
143
+        outstanding_money,
144
+        facts,
145
+        party_a,
146
+        disputes,
147
+        loan_type,
148
+        loan_term,
149
+        mediation_agreement,
150
+        create_time
151
+        )values
152
+        <foreach item="item" index="index" collection="list" separator=",">
153
+        (
154
+        id=#{item.id},
155
+       #{item.caseAppliId},
156
+        #{item.caseName},
157
+        #{item.caseNum},
158
+        #{item.caseSubjectAmount},
159
+        #{item.arbitratClaims},
160
+       #{item.requestRule},
161
+        #{item.loanStartDate},
162
+        #{item.loanEndDate},
163
+        #{item.claimPrinciOwed},
164
+        #{item.claimInterestOwed},
165
+        #{item.claimLiquidDamag},
166
+       #{item.feePayable},
167
+        #{item.contractNumber},
168
+        #{item.createBy},
169
+        #{item.version},
170
+        #{item.updateSubmitStatus},
171
+        #{item.properPreser},
172
+        #{item.interestRate},
173
+        #{item.outstandingMoney},
174
+        #{item.facts},
175
+        #{item.partyA},
176
+        #{item.disputes},
177
+        #{item.loanType},
178
+        #{item.loanTerm},
179
+        #{item.mediationAgreement},
180
+        sysdate()
181
+        )
182
+        </foreach>
183
+    </insert>
122 184
     <update id="updateStatus">
123 185
         update case_application_log
124 186
 

+ 76
- 1
ruoyi-system/src/main/resources/mapper/wisdomarbitrate/CaseApplicationMapper.xml Parādīt failu

@@ -969,6 +969,81 @@
969 969
         sysdate()
970 970
         )
971 971
     </insert>
972
+    <insert id="batchSave">
973
+        insert into case_application(
974
+        id,
975
+        case_name ,
976
+        case_num,
977
+       case_subject_amount,
978
+        register_date,
979
+        arbitrat_method,
980
+        case_status,
981
+        hear_date,
982
+        arbitrat_claims,
983
+        request_rule,
984
+        loan_start_date,
985
+        loan_end_date,
986
+        claim_princi_owed,
987
+
988
+        claim_interest_owed,
989
+        claim_liquid_damag,
990
+        fee_payable,
991
+        begin_video_date,
992
+        online_video_person,
993
+
994
+        contract_number,
995
+
996
+        adjudica_counter,
997
+        proper_preser,
998
+
999
+        create_by,
1000
+        import_flag,
1001
+        version,
1002
+       template_id,
1003
+        facts,
1004
+        mediation_agreement,
1005
+        batch_number,
1006
+        create_time
1007
+        )values
1008
+        <foreach item="item" index="index" collection="list" separator=",">
1009
+        (
1010
+        #{item.id},
1011
+        #{item.caseName},
1012
+        #{item.caseNum},
1013
+        #{item.caseSubjectAmount},
1014
+        sysdate(),
1015
+        #{item.arbitratMethod},
1016
+        #{item.caseStatus},
1017
+        #{item.hearDate},
1018
+        #{item.arbitratClaims},
1019
+        #{item.requestRule},
1020
+       #{item.loanStartDate},
1021
+        #{item.loanEndDate},
1022
+        #{item.claimPrinciOwed},
1023
+
1024
+        #{item.claimInterestOwed},
1025
+        #{item.claimLiquidDamag},
1026
+        #{item.feePayable},
1027
+        #{item.beginVideoDate},
1028
+        #{item.onlineVideoPerson},
1029
+
1030
+        #{item.contractNumber},
1031
+
1032
+       #{item.adjudicaCounter},
1033
+        #{item.properPreser},
1034
+
1035
+        #{item.createBy},
1036
+        #{item.importFlag},
1037
+        #{item.version},
1038
+       #{item.templateId},
1039
+
1040
+        #{item.facts},
1041
+        #{item.mediationAgreement},
1042
+        #{item.batchNumber},
1043
+        sysdate()
1044
+        )
1045
+        </foreach>;
1046
+    </insert>
972 1047
 
973 1048
     <update id="updataCaseApplication" parameterType="CaseApplication">
974 1049
         update case_application
@@ -1164,7 +1239,7 @@
1164 1239
 
1165 1240
     </select>
1166 1241
     <select id="selectCaseNumLike" resultType="java.lang.Integer">
1167
-        select max(substring(case_num, #{length}+1,12)+1) as maxCaseNum
1242
+        select max(substring(case_num, #{length}+1,12)) as maxCaseNum
1168 1243
         from case_application where case_num like CONCAT(#{caseNum},'%') ;
1169 1244
     </select>
1170 1245
     <select id="selectArbitratorList" resultType="java.lang.String">

+ 7
- 0
ruoyi-system/src/main/resources/mapper/wisdomarbitrate/CaseAttachLogMapper.xml Parādīt failu

@@ -19,6 +19,13 @@
19 19
         INSERT INTO case_attach_log (case_appli_log_id, annex_id,annex_name, annex_path , annex_type,note,use_id,use_account,seal_status)
20 20
         VALUES (#{caseAppliLogId},#{annexId}, #{annexName}, #{annexPath},#{annexType},#{note},#{userId},#{userName},#{sealStatus})
21 21
     </insert>
22
+    <insert id="batchSave">
23
+        INSERT INTO case_attach_log (case_appli_log_id, annex_id,annex_name, annex_path , annex_type,note,use_id,use_account,seal_status)
24
+        VALUES
25
+        <foreach item="item" index="index" collection="list" separator=",">
26
+        (#{item.caseAppliLogId},#{item.annexId}, #{item.annexName}, #{item.annexPath},#{item.annexType},#{item.note},#{item.userId},#{item.userName},#{item.sealStatus})
27
+        </foreach>
28
+    </insert>
22 29
     <delete id="deleteByFileIds">
23 30
         delete from case_attach_log
24 31
         where annex_id in