Преглед изворни кода

Merge branch 'wq' of SH-Arbitrate/Arbitrate-Backend into dev

wangqiong123 пре 2 година
родитељ
комит
f9c3609b8b

+ 1
- 1
ruoyi-admin/src/main/java/com/ruoyi/web/controller/wisdomarbitrate/CaseApplicationController.java Прегледај датотеку

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

+ 12
- 0
ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/domain/CaseApplication.java Прегледај датотеку

@@ -25,6 +25,10 @@ public class CaseApplication  extends BaseEntity {
25 25
     /** 案件标的 */
26 26
     @Excel(name = "案件标的")
27 27
     private BigDecimal caseSubjectAmount;
28
+    /**
29
+     * 模板id
30
+     */
31
+    private Long templateId;
28 32
 
29 33
 
30 34
     /** 立案日期 */
@@ -37,6 +41,14 @@ public class CaseApplication  extends BaseEntity {
37 41
      */
38 42
     private Integer importFlag;
39 43
 
44
+    public Long getTemplateId() {
45
+        return templateId;
46
+    }
47
+
48
+    public void setTemplateId(Long templateId) {
49
+        this.templateId = templateId;
50
+    }
51
+
40 52
     public Integer getImportFlag() {
41 53
         return importFlag;
42 54
     }

+ 3
- 0
ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/domain/FatchRule.java Прегледај датотеку

@@ -19,6 +19,9 @@ public class FatchRule extends BaseEntity {
19 19
     private String fileName;
20 20
     private String startContent;
21 21
     private String endContent;
22
+    private String column;
23
+    private String columnName;
24
+
22 25
 
23 26
     private String column;
24 27
     private String columnName;

+ 37
- 0
ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/domain/vo/ColumnValue.java Прегледај датотеку

@@ -0,0 +1,37 @@
1
+package com.ruoyi.wisdomarbitrate.domain.vo;
2
+
3
+import lombok.Data;
4
+
5
+/**
6
+ * 动态配置字段表
7
+ */
8
+@Data
9
+public class ColumnValue {
10
+    private static final long serialVersionUID = 1L;
11
+
12
+    /**
13
+     * id
14
+     */
15
+    private Long id;
16
+
17
+    /**
18
+     * 字段,同一个批号,column不可重复
19
+     */
20
+    private String column;
21
+
22
+    /**
23
+     * 字段名
24
+     */
25
+    private String name;
26
+
27
+    /**
28
+     * 字段值
29
+     */
30
+    private String value;
31
+
32
+    /**
33
+     * 案件id
34
+     */
35
+    private Long caseId;
36
+
37
+}

+ 28
- 0
ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/mapper/ColumnValueMapper.java Прегледај датотеку

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

+ 1
- 1
ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/mapper/FatchRuleMapper.java Прегледај датотеку

@@ -15,7 +15,7 @@ public interface FatchRuleMapper {
15 15
 /**
16 16
  * 根据批次查询
17 17
  */
18
-   List<FatchRule> list(@Param("batchNumber")String batchNumber);
18
+   List<FatchRule> listByTemplateId(@Param("templateId")String templateId);
19 19
 
20 20
    List<FatchRule> selectFatchRuleList(FatchRule fatchRule);
21 21
 

+ 2
- 1
ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/service/ICaseApplicationService.java Прегледај датотеку

@@ -11,13 +11,14 @@ import org.springframework.web.multipart.MultipartFile;
11 11
 
12 12
 import javax.servlet.http.HttpServletRequest;
13 13
 import java.util.List;
14
+import java.util.Map;
14 15
 
15 16
 public interface ICaseApplicationService {
16 17
     List<CaseApplication> selectCaseApplicationList(CaseApplication caseApplication);
17 18
     List<CaseApplication> selectCaseApplicationListByRole(CaseApplication caseApplication);
18 19
 
19 20
 
20
-    int insertcaseApplication(CaseApplication caseApplication);
21
+    int insertcaseApplication(CaseApplication caseApplication, Map<String,String> fatchMap);
21 22
 
22 23
     int selectCaseApplicationCount(CaseApplication caseApplication);
23 24
 

+ 263
- 263
ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/service/impl/AdjudicationServiceImpl.java Прегледај датотеку

@@ -11,6 +11,7 @@ import com.ruoyi.common.core.redis.RedisCache;
11 11
 import com.ruoyi.common.utils.DateUtils;
12 12
 import com.ruoyi.common.utils.SmsUtils;
13 13
 import com.ruoyi.wisdomarbitrate.domain.vo.BookSendVO;
14
+import com.ruoyi.wisdomarbitrate.domain.vo.ColumnValue;
14 15
 import com.ruoyi.wisdomarbitrate.mapper.*;
15 16
 import com.ruoyi.wisdomarbitrate.utils.CaseLogUtils;
16 17
 import com.ruoyi.common.utils.EmailOutUtil;
@@ -25,11 +26,16 @@ import lombok.extern.slf4j.Slf4j;
25 26
 import org.apache.poi.ss.usermodel.Sheet;
26 27
 import org.apache.poi.xssf.usermodel.XSSFWorkbook;
27 28
 import org.apache.poi.xwpf.usermodel.XWPFDocument;
29
+import org.apache.poi.xwpf.usermodel.XWPFParagraph;
30
+import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTBookmark;
31
+import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTP;
28 32
 import org.springframework.beans.factory.annotation.Autowired;
29 33
 import org.springframework.mail.MailSendException;
30 34
 import org.springframework.mail.javamail.JavaMailSender;
31 35
 import org.springframework.stereotype.Service;
32 36
 import org.springframework.transaction.annotation.Transactional;
37
+import org.w3c.dom.Node;
38
+import org.w3c.dom.NodeList;
33 39
 
34 40
 import java.io.*;
35 41
 import java.math.BigDecimal;
@@ -43,7 +49,9 @@ import java.text.NumberFormat;
43 49
 import java.text.SimpleDateFormat;
44 50
 import java.time.LocalDate;
45 51
 import java.util.*;
52
+import java.util.regex.Matcher;
46 53
 import java.util.regex.Pattern;
54
+import java.util.stream.Collectors;
47 55
 
48 56
 import static com.ruoyi.common.utils.SecurityUtils.getUsername;
49 57
 
@@ -72,284 +80,230 @@ public class AdjudicationServiceImpl implements IAdjudicationService {
72 80
     private SendMailRecordMapper sendMailRecordMapper;
73 81
     @Autowired
74 82
     private SmsRecordMapper smsRecordMapper;
75
-
83
+    @Autowired
84
+    private TemplateManageMapper templateManageMapper;
85
+    @Autowired
86
+    private ColumnValueMapper columnValueMapper;
87
+    // 仲裁反请求模板内容
88
+    private final String counterclaim= "在《2022年版仲裁规则》第十八条第(一)项规定的期限内,被申请人向秘书处提交了" +
89
+            "《仲裁反请求申请书》及证据材料。仲裁委依据《2022年版仲裁规则》第十八条的规定受理了该仲裁反请求案申请。" +
90
+            "仲裁反请求案件受理后,秘书处向被申请人发送了仲裁反请求通知书及附件,向申请人发送了仲裁反请求通知书及附件、仲裁反请求申请书及附件。";
91
+    // 财产保全内容
92
+    String preservation = "本案受理后,申请人向仲裁委提交了财产保全申请,仲裁委根据《中华人民共和国仲裁法》" +
93
+            "第二十八条之规定,将该申请提交至法院。";
94
+    // 管辖权异议
95
+    String jurisdictionalObjection = "本案受理后,被申请人向仲裁委提交了《管辖异议申请书》,认为" +
96
+            ",仲裁委经审理,当庭驳回了被申请人的管辖异议申请,并告知被申请人具体的事实和理由将在裁决书中一并列明。";
97
+    // 线上开庭时+线上仲裁
98
+    String onLineDate="{{onLineDate}}";
99
+    String onLine = "仲裁庭审阅了申请人提交的仲裁申请书、证据材料后,于"+onLineDate+"通过仲裁委智慧仲裁平台开庭审理了本案。";
100
+    // 开庭+线下仲裁
101
+    String offLineDate="{{offLineDate}}";
102
+    String offLine = "仲裁庭审阅了申请人提交的仲裁申请书、证据材料后,于 "+offLineDate+"在仲裁委所在地开庭审理了本案。";
103
+    //书面仲裁时
104
+    String writtenDate="{{writtenDate}}";
105
+    String written = "仲裁庭审阅了申请人提交的仲裁申请书、证据材料后,于"+writtenDate+"在仲裁委所在地开庭审理了本案。";
106
+    //开庭+缺席审理
107
+    String absent = "申请人的特别授权委托代理人{{agentName}}"+"出席了庭审。被申请人经依法送达开庭通知,无正当理由未出席庭审,故仲裁庭依据" +
108
+            "《2022年版仲裁规则》第四十条第(二)项的规定,对本案进行了缺席审理。庭审中,申请人陈述了仲裁请求事项及事实与理由,出示了证据材料并进行了说明,\" +\n" +
109
+            "            \"发表了意见,回答了仲裁庭的提问,并作了最后陈述。因被申请人缺席庭审,故仲裁庭无法组织调解。"+"综上,仲裁庭依据《上海仲裁委员会仲裁规则》(2022年7月1日起施行的版本)" +
110
+            "第四十条第(二)项、第五十一条的规定,缺席裁决如下:";
111
+    // 开庭+出席
112
+    String attend="申请人的特别授权委托代理人{{agentName}}和被申请人本人出席了庭审。 ";
113
+    // 开庭+出席+被申提供证据
114
+    String onLineAttendFile="庭审中,申请人陈述了仲裁请求事项及所依据的事实与理由,被申请人进行了答辩;双方当事人均出示了证据材料并对对方的证据材料进行了质证;双方当事人均回答了仲裁庭的提问,进行了辩论,并分别作了最后陈述。双方当事人在仲裁庭的主持下进行了调解,但未能达成调解协议。 ";
115
+    // 开庭+出席+被申未提供证据
116
+    String onLineAttend="庭审中,申请人陈述了仲裁请求事项及所依据的事实与理由,被申请人进行了答辩;申请人出示了证据材料,被申请人对对方的证据材料进行了质证; 双方当事人均回答了仲裁庭的提问,进行了辩论,并分别作了最后陈述。双方当事人在仲裁庭的主持下进行了调解,但未能达成调解协议。 ";
117
+    // 被申请人出席答辩意见
118
+    String resAttendOpinion="\n(二)被申请人的答辩意见  \n(三)当事人提供的证据材料及对方的质证意见\n" +
119
+            "申请人为证明其主张的事实和理由,向仲裁庭提交了如下证据材料:\n{{applicantFile}}\n被申请人对上述材料的质证意见为:{{respondentOpinion}}\n";
120
+    // 被申请人出席+被申请人提供了资料
121
+    String resFile="被申请人向仲裁庭提交了如下证据材料:\n{{resFile}}" +
122
+            "申请人对上述材料的质证意见为:{{applicantOpinion}}";
123
+    // 被申请人缺席
124
+    String resAbsent="(二)当事人提供的证据材料\n" +
125
+            "申请人为证明其主张的事实和理由,向仲裁庭提交了如下证据材料:\n{{applicantFile}}";
76 126
     @Override
77 127
     @Transactional
78
-    public AjaxResult createDocument(CaseApplication caseApplication) {
128
+    public AjaxResult createDocument(CaseApplication caseApplicationReq) {
129
+        String templatePath="";
130
+        String templateName="";
131
+        String agentName="";
132
+        String resName="";
79 133
         try {
80 134
             Map<String, Object> datas = new HashMap<>();
81
-            Long id = caseApplication.getId();
135
+            Long id = caseApplicationReq.getId();
82 136
             if (id == null) {
83
-                return null;
137
+                return AjaxResult.error("案件id不能为空");
84 138
             }
139
+
85 140
             //获取案件详细信息
86
-            CaseApplication caseApplication1 = caseApplicationMapper.selectCaseApplication(caseApplication);
87
-            //生成编码
88
-            String equipmentNo = getNewEquipmentNo();
89
-            datas.put("num", equipmentNo);
141
+            CaseApplication caseApplicationById = caseApplicationService.selectCaseApplication(caseApplicationReq);
142
+
143
+            if(caseApplicationById==null){
144
+                return AjaxResult.error("案件不存在");
145
+            }
146
+            // 根据模板id查找对应的模板
147
+            if(caseApplicationById.getTemplateId()!=null) {
148
+                TemplateManage templateManage = new TemplateManage();
149
+                templateManage.setId(caseApplicationById.getTemplateId());
150
+                List<TemplateManage> templateManages = templateManageMapper.selectTemplateList(templateManage);
151
+                if(CollectionUtil.isEmpty(templateManages)){
152
+                    return AjaxResult.error("请先指定裁决书模板");
153
+                }
154
+                templatePath=templateManages.get(0).getTemOrigPath();
155
+                templateName=templateManages.get(0).getFileName();
156
+            }
90 157
             //获取仲裁记录表里的相关信息
91 158
             ArbitrateRecord arbitrateRecord = new ArbitrateRecord();
92 159
             arbitrateRecord.setCaseAppliId(id);
93
-            ArbitrateRecord arbitrateRecord1 = arbitrateRecordMapper.selectArbitrateRecord(arbitrateRecord);
94
-            //获取案件关联人信息
95
-            CaseAffiliate caseAffiliate = new CaseAffiliate();
96
-            caseAffiliate.setCaseAppliId(id);
97
-            List<CaseAffiliate> caseAffiliates = caseAffiliateMapper.selectCaseAffiliate(caseAffiliate);
98
-            String applicantName="";
99
-            String debtorName = "";
100
-            List<String> nameAgentList = new ArrayList<>();
101
-            if (caseAffiliates != null && caseAffiliates.size() > 0) {
102
-                for (CaseAffiliate affiliate : caseAffiliates) {
103
-                    //获取身份类型
104
-                    int identityType = affiliate.getIdentityType();
105
-                    if (identityType == 1) {    //申请人
106
-                        applicantName=affiliate.getName();
107
-                        datas.put("appName", affiliate.getName());
108
-                        datas.put("appAddress", affiliate.getResidenAffili());
109
-                        datas.put("appContactAddress", affiliate.getContactAddress());
110
-                        datas.put("appLegalPerson", affiliate.getCompLegalPerson());
111
-                        datas.put("appLegalPersonTitle", affiliate.getCompLegalperPost());
112
-                        datas.put("appAgentName", affiliate.getNameAgent());
113
-                        datas.put("appAgentTitle", affiliate.getAppliAgentTitle());
114
-                        nameAgentList.add(affiliate.getNameAgent());
115
-                    } else if (identityType == 2) {  //被申请人
116
-                        debtorName=affiliate.getName();
117
-                        datas.put("resName", affiliate.getName());
118
-                        datas.put("resAddress", affiliate.getResidenAffili());
119
-                        String responSex = affiliate.getResponSex();
120
-                        if (responSex.equals("0")) {
121
-                            datas.put("resSex", "男");
122
-                        } else if (responSex.equals("1")){
123
-                            datas.put("resSex", "女");
124
-                        }else {
125
-                            datas.put("resSex", "未知");
126
-                        }
127
-                        Date responBirth = affiliate.getResponBirth();
128
-                        if (responBirth != null) {
129
-                            SimpleDateFormat sdf = new SimpleDateFormat("yyyy年MM月dd日");
130
-                            String responBirthStr = sdf.format(responBirth);
131
-                            datas.put("resDateOfBirth", responBirthStr);
132
-                        }
133
-                        datas.put("resContactAddress", affiliate.getContactAddress());
134
-                        nameAgentList.add(affiliate.getNameAgent());
160
+            ArbitrateRecord arbitrateRecordSelect = arbitrateRecordMapper.selectArbitrateRecord(arbitrateRecord);
161
+
162
+            // todo 获取模板中的所有占位符,该占位符字段必须和抓取字段一致,暂时写死
163
+            // todo 生成裁决书的内容从key-value表中取,不从案件基本信息表取,会有问题,如果修改的话会有问题,暂不考虑该情况
164
+
165
+            // 根据案件id查询key-value表
166
+            List<ColumnValue> columnValueList = columnValueMapper.listByCaseId(caseApplicationReq.getId());
167
+            // 获取模板中的占位符key
168
+            List<String> bookmarkList = getBookmarkByDocx(templatePath);
169
+            if(CollectionUtil.isEmpty(bookmarkList)){
170
+                // 直接保存模板为裁决书
171
+                saveArbitorFile(id,templateName,templatePath,caseApplicationById,arbitrateRecordSelect);
172
+                return AjaxResult.success("生成裁决书成功");
173
+            }
174
+            // 如果该表没值,在从主表填充裁决书模板
175
+            if(CollectionUtil.isNotEmpty(columnValueList)){
176
+                Map<String, String> columnValueMap = columnValueList.stream().collect(Collectors.toMap(ColumnValue::getColumn, ColumnValue::getValue));
177
+                agentName=columnValueMap.get("agentName");
178
+                resName=columnValueMap.get("respondentName");
179
+                // 懒得if,暂时这样
180
+                //
181
+                for (String bookmark : bookmarkList) {
182
+                    if(columnValueMap.containsKey(bookmark)){
183
+                        datas.put(bookmark,columnValueMap.get(bookmark));
135 184
                     }
136 185
                 }
186
+            }else {
187
+
137 188
             }
138
-            Date createTime = caseApplication1.getCreateTime();
189
+            // 裁决书生成时间
190
+            LocalDate now = LocalDate.now();
191
+            String year = Integer.toString(now.getYear());
192
+            datas.put("year", year);
193
+            //生成编码
194
+            String equipmentNo = getNewEquipmentNo();
195
+            // 裁决书编号
196
+            datas.put("num", equipmentNo);
197
+            // 案件创建时间
198
+            Date createTime = caseApplicationById.getCreateTime();
139 199
             SimpleDateFormat sdf = new SimpleDateFormat("yyyy年MM月dd日");
140 200
             // 将日期格式化为字符串
141 201
             String createTimeStr = sdf.format(createTime);
142 202
             datas.put("submissionDate", createTimeStr);
143
-            Date registerDate = caseApplication1.getRegisterDate();
203
+            // 立案日期
204
+            Date registerDate = caseApplicationById.getRegisterDate();
144 205
             String registerDateStr = sdf.format(registerDate);
145 206
             datas.put("acceptDate", registerDateStr);
146
-            //反请求
147
-            Integer adjudicaCounter = caseApplication1.getAdjudicaCounter();
148
-            String counterclaim = "在《2022年版仲裁规则》第十八条第(一)项规定的期限内,被申请人向秘书处提交了" +
149
-                    "《仲裁反请求申请书》及证据材料。仲裁委依据《2022年版仲裁规则》第十八条的规定受理了该仲裁反请求案申请。" +
150
-                    "仲裁反请求案件受理后,秘书处向被申请人发送了仲裁反请求通知书及附件,向申请人发送了仲裁反请求通知书及附件、仲裁反请求申请书及附件。";
151
-            if (adjudicaCounter == null) {
152
-                datas.put("counterclaim", null);
153
-            } else if (adjudicaCounter == 1) {
207
+
208
+            // 如果有仲裁反请求,该字段设置值
209
+            Integer adjudicaCounter = caseApplicationById.getAdjudicaCounter();
210
+             if (adjudicaCounter!=null&&adjudicaCounter == 1) {
154 211
                 datas.put("counterclaim", counterclaim);
155
-            } else {
156
-                datas.put("counterclaim", null);
157 212
             }
158 213
             //财产保全
159
-            Integer properPreser = caseApplication1.getProperPreser();
160
-            String preservation = "本案受理后,申请人向仲裁委提交了财产保全申请,仲裁委根据《中华人民共和国仲裁法》" +
161
-                    "第二十八条之规定,将该申请提交至法院。";
162
-            if (properPreser == null) {
163
-                datas.put("preservation", null);
164
-            } else if (properPreser == 1) {
214
+            Integer properPreser = caseApplicationById.getProperPreser();
215
+            if (properPreser!=null&&properPreser == 1) {
165 216
                 datas.put("preservation", preservation);
166
-            } else {
167
-                datas.put("preservation", null);
168 217
             }
169 218
             //管辖权异议
170
-            Integer objectiJuris = caseApplication1.getObjectiJuris();
171
-            String jurisdictionalObjection = "本案受理后,被申请人向仲裁委提交了《管辖异议申请书》,认为" +
172
-                    ",仲裁委经审理,当庭驳回了被申请人的管辖异议申请,并告知被申请人具体的事实和理由将在裁决书中一并列明。";
173
-            if (objectiJuris == null) {
174
-                datas.put("jurisdictionalObjection", null);
175
-            } else if (objectiJuris == 1) {
219
+            Integer objectiJuris = caseApplicationById.getObjectiJuris();
220
+            if (objectiJuris!=null&&objectiJuris == 1) {
176 221
                 datas.put("jurisdictionalObjection", jurisdictionalObjection);
177
-            } else {
178
-                datas.put("jurisdictionalObjection", null);
179 222
             }
180
-            String arbitratorName = caseApplication1.getArbitratorName();
181
-            datas.put("arbitratorName", arbitratorName);
182
-            Integer arbitratMethod = caseApplication1.getArbitratMethod();
183
-            Date hearDate = caseApplication1.getHearDate();
223
+            // 仲裁员名称
224
+            datas.put("arbitratorName", caseApplicationById.getArbitratorName());
225
+            // 审理方式
226
+            Integer arbitratMethod = caseApplicationById.getArbitratMethod();
227
+            Date hearDate = caseApplicationById.getHearDate();
184 228
             if (hearDate != null) {
229
+                // 审理日期
185 230
                 String hearDateStr = sdf.format(hearDate);
186
-
187
-
231
+                // todo 线上仲裁/线下仲裁方式未选择
188 232
                 //线上开庭时
189 233
                 if (arbitratMethod == 1) {
190
-                    String onLine1 = "仲裁庭审阅了申请人提交的仲裁申请书、证据材料后,于";
191
-                    String onLine2 = "通过仲裁委智慧仲裁平台开庭审理了本案。";
192
-                    datas.put("onLine1", onLine1);
193
-                    datas.put("hearDate", hearDateStr);
194
-                    datas.put("onLine2", onLine2);
234
+                    String replace = onLine.replace(onLineDate, hearDateStr);
235
+                    datas.put("onLine", replace);
195 236
                 } else {
196 237
                     //书面仲裁时
197
-                    String written1 = "仲裁庭审阅了申请人提交的仲裁申请书、证据材料后,于";
198
-                    String written2 = "在仲裁委所在地开庭审理了本案。";
199
-                    datas.put("written1", written1);
200
-                    datas.put("hearDate1", hearDateStr);
201
-                    datas.put("written2", written2);
202
-                }
203
-            }
238
+                    String replace = written.replace(writtenDate, hearDateStr);
239
+                    datas.put("written", replace);
204 240
 
205
-            Integer isAbsence = caseApplication1.getIsAbsence();
206
-            if (isAbsence == null) {
207
-                datas.put("absent1", null);
208
-                datas.put("absent2", null);
209
-                datas.put("absent3", null);
210
-                datas.put("absent4", null);
211
-                datas.put("absent5", null);
212
-                datas.put("attend1", null);
213
-                datas.put("attend2", null);
214
-                datas.put("attend3", null);
215
-                datas.put("attend4", null);
216
-                datas.put("attend5", null);
217
-                datas.put("attend6", null);
218
-                datas.put("attend7", null);
219
-                datas.put("appAgentName1", null);
220
-                datas.put("appAgentName2", null);
221
-                datas.put("resAgentName", null);
222
-            } else if (isAbsence == 1) {
223
-                //缺席审理
224
-                String absent1 = "申请人的特别授权委托代理人";
225
-                String absent2 = "出席了庭审。被申请人经依法送达开庭通知,无正当理由未出席庭审,故仲裁庭依据" +
226
-                        "《2022年版仲裁规则》第四十条第(二)项的规定,对本案进行了缺席审理。";
227
-                String absent3 = "庭审中,申请人陈述了仲裁请求事项及事实与理由,出示了证据材料并进行了说明," +
228
-                        "发表了意见,回答了仲裁庭的提问,并作了最后陈述。因被申请人缺席庭审,故仲裁庭无法组织调解。";
229
-                String absent4 = "(二/三)当事人提供的证据材料\n" +
230
-                        "申请人为证明其主张的事实和理由,向仲裁庭提交了如下证据材料:";
231
-                String absent5 = "综上,仲裁庭依据《上海仲裁委员会仲裁规则》(2022年7月1日起施行的版本)" +
232
-                        "第四十条第(二)项、第五十一条的规定,缺席裁决如下:";
233
-                datas.put("absent1", absent1);
234
-                datas.put("absent2", absent2);
235
-                datas.put("absent3", absent3);
236
-                datas.put("absent4", absent4);
237
-                datas.put("absent5", absent5);
238
-                datas.put("appAgentName1", nameAgentList.get(0));
239
-            } else {
240
-                //出席审理
241
-                String attend1 = "申请人的特别授权委托代理人";
242
-                String attend2 = "和被申请人本人/的特别授权委托代理人";
243
-                String attend3 = "出席了庭审。";
244
-                String attend4 = "庭审中,申请人陈述了仲裁请求事项及所依据的事实与理由,被申请人进行了答辩;" +
245
-                        "双方当事人均出示了证据材料并对对方的证据材料进行了质证;申请人出示了证据材料," +
246
-                        "被申请人对对方的证据材料进行了质证;双方当事人均回答了仲裁庭的提问,进行了辩论," +
247
-                        "并分别作了最后陈述。双方当事人在仲裁庭的主持下进行了调解,但未能达成调解协议。";
248
-                String attend5 = "(二)被申请人的答辩意见";
249
-                String attend6 = "(二/三)当事人提供的证据材料及对方的质证意见\n" +
250
-                        "申请人为证明其主张的事实和理由,向仲裁庭提交了如下证据材料:";
251
-                String attend7 = "被申请人对上述材料的质证意见为:";
252
-                datas.put("attend1", attend1);
253
-                datas.put("attend2", attend2);
254
-                datas.put("attend3", attend3);
255
-                datas.put("attend4", attend4);
256
-                datas.put("attend5", attend5);
257
-                datas.put("attend6", attend6);
258
-                datas.put("attend7", attend7);
259
-                datas.put("responCrossOpin", arbitrateRecord1.getRespondentOpinion());
260
-                datas.put("appAgentName2", nameAgentList.get(0));
261
-                datas.put("resAgentName", nameAgentList.get(1));
262
-                if (arbitratMethod == 1) {
263
-                    //被申出席+开庭
264
-                    String attend8 = "综上,仲裁庭依据《上海仲裁委员会仲裁规则》(2022年7月1日起施行的版本)" +
265
-                            "第五十一条的规定,裁决如下:";
266
-                    datas.put("attend8", attend8);
267
-                } else {
268
-                    //被申出席+书面
269
-                    String attend9 = "综上,仲裁庭依据《上海仲裁委员会仲裁规则》(2022年7月1日起施行的版本)" +
270
-                            "第五十一条、第五十八条的规定,裁决如下:";
271
-                    datas.put("attend9", attend9);
272 241
                 }
273 242
             }
274
-            // 申请人的仲裁请求及事实和理由   申请人称  在事实与理由抓取
275
-            datas.put("claims", caseApplication1.getFacts());
276
-//            datas.put("request", caseApplication1.getRequestRule());
277
-            CaseApplication caseApplication2 = caseApplicationService.selectCaseApplication(caseApplication);
278
-            // todo 合同编号
279
-            SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy年MM月dd日");
280
-          //  datas.put("partyA", caseApplication2.getContractNumber());
281
-         //   Date loanStartDate = caseApplication2.getLoanStartDate();
282
-          //  datas.put("lonStartDate",simpleDateFormat.format(loanStartDate));
283
-          //  datas.put("contractNumber",caseApplication2.getContractNumber());
284
-            // 合同名称
285
-           // datas.put("contractName",caseApplication2.getContractName());
286
-            // todo 查询该批号的裁决内容模板
287
-            String template="一、被申请人{1}应于{2}前向申请人{3}一次性支付剩余贷款{4}元。\n" +
288
-                    "二、本案仲裁费人民币{5}元(已由申请人预缴),由申请人{6}承担\n";
289
-            Date loanEndDate = caseApplication2.getLoanEndDate();
290
-
291
-            String outstandingMoney = caseApplication2.getOutstandingMoney();
292
-            NumberFormat format = NumberFormat.getInstance();
293
-            String outstandingMoneyFormat="";
294
-
295
-            if(StrUtil.isNotEmpty(outstandingMoney)) {
296
-                 outstandingMoneyFormat = format.format(new BigDecimal(outstandingMoney));
243
+            // 所有附件
244
+            List<CaseAttach> caseAttachList = caseApplicationById.getCaseAttachList();
245
+            Map<Integer, List<CaseAttach>> caseAttachMap=new HashMap<>();
246
+            if(caseAttachList!=null&&caseAttachList.size()>0){
247
+                caseAttachMap = caseAttachList.stream().collect(Collectors.groupingBy(CaseAttach::getAnnexType));
297 248
             }
298
-            String rulingFollows = template.replace("{1}", debtorName).replace("{2}", simpleDateFormat.format(loanEndDate))
299
-                    .replace("{3}", applicantName).replace("{4}", outstandingMoneyFormat)
300
-                    .replace("{5}", String.valueOf(caseApplication2.getFeePayable()))
301
-                    .replace("{6}", applicantName);
302
-            // 请求仲裁庭裁决
303
-            datas.put("request", caseApplication1.getArbitratClaims());
304
-            List<CaseAttach> caseAttachList1 = caseApplication2.getCaseAttachList();
305
-            if (caseAttachList1 != null && caseAttachList1.size() > 0) {
306
-                StringBuilder debtorFiles=new StringBuilder();
307
-                StringBuilder applicantFiles=new StringBuilder();
308
-                for (CaseAttach caseAttach : caseAttachList1) {
309
-                    if (caseAttach.getAnnexType() == 6) {   //被申请人证据材料
310
-                        debtorFiles.append(caseAttach.getAnnexName()).append("\r\n");
311
-//                        boolean isImageFile = Pattern.matches(".*\\.(jpg|png|gif|bmp)$", annexName);
312
-//                        if (isImageFile) {
313
-//                            String annexPath = "/home/ruoyi" + caseAttach.getAnnexPath();
314
-//                            System.out.println("路径是===========" + annexPath);
315
-//                            PictureRenderData pictureRenderData = WordUtil
316
-//                                    .rebuildImageContent(100, 100, null, annexPath);
317
-//                            datas.put("resEvidenceMaterial", pictureRenderData);
318
-//                        }
319
-
320
-                    } else if (caseAttach.getAnnexType() == 2) {   //申请人证据材料
321
-//                        String annexName = caseAttach.getAnnexName();
322
-//                        boolean isImageFile = Pattern.matches(".*\\.(jpg|png|gif|bmp)$", annexName);
323
-//                        if (isImageFile) {
324
-//                            String annexPath = "/home/ruoyi" + caseAttach.getAnnexPath();
325
-//                            System.out.println("路径是===========" + annexPath);
326
-//                            PictureRenderData pictureRenderData = WordUtil
327
-//                                    .rebuildImageContent(100, 100, null, annexPath);
328
-//                            //申请人证据材料
329
-//                            datas.put("appEvidenceMaterial", pictureRenderData);
330
-//                        }
331
-                        applicantFiles.append(caseAttach.getAnnexName()).append("\r\n");
332
-
249
+            // 被申请人是否缺席
250
+            Integer isAbsence = caseApplicationById.getIsAbsence();
251
+            // 线上开庭
252
+            if (arbitratMethod == 1) {
253
+                if (isAbsence != null && isAbsence == 1) {
254
+                    // 被申请人缺席
255
+                    String absentReplace = absent.replace("{{agentName}}", agentName);
256
+                    datas.put("absent",absentReplace);
257
+                    // 被申请人缺席
258
+                    String resAbsentReplace=resAbsent;
259
+                    if(caseAttachMap!=null && CollectionUtil.isNotEmpty(caseAttachMap.get(2))){
260
+                        List<CaseAttach> caseAttaches = caseAttachMap.get(2);
261
+                        StringBuilder stringBuilder = new StringBuilder();
262
+                        for (CaseAttach caseAttach : caseAttaches) {
263
+                            stringBuilder.append(caseAttach.getAnnexName()).append("\n");
264
+                        }
265
+                        resAbsentReplace = resAttendOpinion.replace("{{applicantFile}}", stringBuilder.toString());
266
+                    }
267
+                    datas.put("resAbsent",resAbsentReplace);
268
+                } else {
269
+                    // 出席
270
+                    String attendReplace = attend.replace("{{agentName}}", agentName);
271
+                    datas.put("attend",attend);
272
+                    // 被申请人证据
273
+                    if(caseAttachMap!=null && CollectionUtil.isNotEmpty(caseAttachMap.get(6))){
274
+                       // 开庭+出席+被申提供证据
275
+                        datas.put("onLineAttendFile",onLineAttendFile);
276
+                        // 被申请人出席+被申请人提供了资料
277
+                        String resFileRplace=resFile;
278
+                        if(caseAttachMap!=null && CollectionUtil.isNotEmpty(caseAttachMap.get(6))){
279
+                            List<CaseAttach> caseAttaches = caseAttachMap.get(6);
280
+                            StringBuilder stringBuilder = new StringBuilder();
281
+                            for (CaseAttach caseAttach : caseAttaches) {
282
+                                stringBuilder.append(caseAttach.getAnnexName()).append("\n");
283
+                            }
284
+                            resFileRplace = resFile.replace("{{resFile}}", stringBuilder.toString()).replace("{{applicantOpinion}}", arbitrateRecordSelect.getApplicantOpinion());
285
+                        }
286
+                        datas.put("resFile",resFileRplace);
287
+                    }else {
288
+                        // 开庭+出席+被申未提供证据
289
+                        datas.put("onLineAttend",onLineAttend);
333 290
                     }
291
+                    // 被申请人出席答辩意见
292
+                    String resAttendOpinionReplace=resAttendOpinion;
293
+                    if(caseAttachMap!=null && CollectionUtil.isNotEmpty(caseAttachMap.get(2))){
294
+                        List<CaseAttach> caseAttaches = caseAttachMap.get(2);
295
+                        StringBuilder stringBuilder = new StringBuilder();
296
+                        for (CaseAttach caseAttach : caseAttaches) {
297
+                            stringBuilder.append(caseAttach.getAnnexName()).append("\n");
298
+                        }
299
+                         resAttendOpinionReplace = resAttendOpinion.replace("{{applicantFile}}", stringBuilder.toString()).replace("{{respondentOpinion}}", arbitrateRecordSelect.getRespondentOpinion());
300
+                    }
301
+
302
+                    datas.put("resAttendOpinion",resAttendOpinionReplace);
334 303
                 }
335
-                // //被申请人证据材料
336
-                datas.put("resEvidenceMaterial", debtorFiles.toString());
337
-                //申请人证据材料
338
-                datas.put("appEvidenceMaterial", applicantFiles.toString());
339 304
             }
340
-            // 申请人对上述材料的质证意见为
341
-            datas.put("applicaCrossOpin", arbitrateRecord1.getApplicantOpinion());
342
-            // 仲裁庭经审理,查明本案事实如下:
343
-            datas.put("factDetermi", arbitrateRecord1.getCaseFacts());
344
-            // 关于本案争议焦点
345
-            datas.put("arbitrateThink", arbitrateRecord1.getCaseFocus());
346
-//            datas.put("rulingFollows", "被申请人依法偿还申请人欠款");
347
-            // 最终裁决
348
-            datas.put("rulingFollows", rulingFollows);
349 305
 
350
-            LocalDate now = LocalDate.now();
351
-            String year = Integer.toString(now.getYear());
352
-            datas.put("year", year);
306
+
353 307
             String month = String.format("%02d", now.getMonthValue());
354 308
             String day = String.format("%02d", now.getDayOfMonth());
355 309
             String modalFilePath = "/data/arbitrate-document/template/新裁决书模板.docx";
@@ -376,38 +330,52 @@ public class AdjudicationServiceImpl implements IAdjudicationService {
376 330
                 WordUtil.changeText(xwpfDocument);
377 331
             }
378 332
             String savePath = docFilePath.substring(0, docFilePath.indexOf("/upload/") + 8);
379
-            CaseAttach caseAttach = CaseAttach.builder()
380
-                    .caseAppliId(id)
381
-                    .annexName(saveName)
382
-                    .annexPath(savePath)
383
-                    .annexType(3)
384
-                    .build();
385
-            //保存到附件表里,先判断之前有没有,有的话更新,没有的话新增
386
-            List<CaseAttach> caseAttachList = caseAttachMapper.getCaseAttachByCaseIdAndType(caseAttach);
387
-            if (caseAttachList != null && caseAttachList.size() > 0) {
388
-                //之前已经生成过了,更新
389
-                int i = caseAttachMapper.updateCaseAttachBycaseid(caseAttach);
390
-            } else {
391
-                //之前没生成过,新增
392
-                int i = caseAttachMapper.save(caseAttach);
393
-                if (i > 0) {
394
-                    if (arbitrateRecord1 != null) {
395
-                        Integer annexId = caseAttach.getAnnexId();
396
-                        //将附件id保存到仲裁记录表里面
397
-                        arbitrateRecord1.setAnnexId(annexId);
398
-                        arbitrateRecordMapper.updataArbitrateRecord(arbitrateRecord1);
399
-                    }
400
-                }
401
-            }
402
-            //修改案件状态
403
-            caseApplication1.setCaseStatus(CaseApplicationConstants.VERPRIF_ARBITRATION);
404
-            caseApplicationMapper.submitCaseApplication(caseApplication1);
333
+            // 保存裁决书附件
334
+            saveArbitorFile(id,saveName,savePath,caseApplicationById,arbitrateRecordSelect);
335
+
405 336
             return AjaxResult.success("裁决书已生成");
406 337
         } catch (IOException e) {
407 338
             return AjaxResult.error(e + "请检查文件路径是否有误");
408 339
         }
409 340
     }
410 341
 
342
+    /**
343
+     * 保存裁决书附件
344
+     * @param id 案件id
345
+     * @param saveName 保存的文件名
346
+     * @param savePath 保存路径
347
+     * @param caseApplicationById 案件基本信息
348
+     * @param arbitrateRecordSelect 出裁决书生成记录
349
+     */
350
+    private void saveArbitorFile(Long id, String saveName, String savePath, CaseApplication caseApplicationById, ArbitrateRecord arbitrateRecordSelect) {
351
+        CaseAttach caseAttach = CaseAttach.builder()
352
+                .caseAppliId(id)
353
+                .annexName(saveName)
354
+                .annexPath(savePath)
355
+                .annexType(3)
356
+                .build();
357
+        //保存到附件表里,先判断之前有没有,有的话更新,没有的话新增
358
+        List<CaseAttach> caseAttachList = caseAttachMapper.getCaseAttachByCaseIdAndType(caseAttach);
359
+        if (caseAttachList != null && caseAttachList.size() > 0) {
360
+            //之前已经生成过了,更新
361
+            int i = caseAttachMapper.updateCaseAttachBycaseid(caseAttach);
362
+        } else {
363
+            //之前没生成过,新增
364
+            int i = caseAttachMapper.save(caseAttach);
365
+            if (i > 0) {
366
+                if (arbitrateRecordSelect != null) {
367
+                    Integer annexId = caseAttach.getAnnexId();
368
+                    //将附件id保存到仲裁记录表里面
369
+                    arbitrateRecordSelect.setAnnexId(annexId);
370
+                    arbitrateRecordMapper.updataArbitrateRecord(arbitrateRecordSelect);
371
+                }
372
+            }
373
+        }
374
+        //修改案件状态
375
+        caseApplicationById.setCaseStatus(CaseApplicationConstants.VERPRIF_ARBITRATION);
376
+        caseApplicationMapper.submitCaseApplication(caseApplicationById);
377
+    }
378
+
411 379
     @Override
412 380
     @Transactional
413 381
     public AjaxResult sendDocumentByEmail(Long id, String appEmail, String resEmail, String apptrackingNum, String restrackingNum) {
@@ -1097,5 +1065,37 @@ public class AdjudicationServiceImpl implements IAdjudicationService {
1097 1065
         }
1098 1066
     }
1099 1067
 
1068
+    /**
1069
+     * 根据裁决书模板获取所有的占位符,占位符必须是{{name}}格式
1070
+     * @param path
1071
+     * @return
1072
+     */
1073
+    public List<String> getBookmarkByDocx(String path){
1074
+        XWPFDocument xwpfDocument = null;
1075
+        try {
1076
+            FileInputStream fileInputStream = new FileInputStream(path);
1077
+            xwpfDocument = new XWPFDocument(fileInputStream);
1078
+        } catch (IOException e) {
1079
+            e.printStackTrace();
1080
+        }
1081
+        List<XWPFParagraph> paragraphs = xwpfDocument.getParagraphs();
1082
+        String regex = "\\{\\{.*?\\}\\}"; // 定义占位符的正则表达式
1083
+        Pattern pattern = Pattern.compile(regex);
1084
+        List<String> bookmarkList=new ArrayList<>();
1085
+        for (XWPFParagraph paragraph : paragraphs) {
1086
+            String text = paragraph.getText();
1087
+            Matcher matcher = pattern.matcher(text);
1088
+
1089
+            while (matcher.find()) {
1090
+                String placeholder = matcher.group();
1091
+                String keyword = placeholder.substring(2, placeholder.length() - 2);
1092
+                bookmarkList.add(keyword);
1093
+            }
1094
+        }
1095
+        return bookmarkList;
1096
+    }
1097
+
1098
+
1099
+
1100 1100
 
1101 1101
 }

+ 238
- 263
ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/service/impl/CaseApplicationServiceImpl.java Прегледај датотеку

@@ -34,6 +34,7 @@ import com.ruoyi.system.mapper.SysDeptMapper;
34 34
 import com.ruoyi.system.mapper.SysRoleMapper;
35 35
 import com.ruoyi.system.mapper.SysUserMapper;
36 36
 import com.ruoyi.system.mapper.SysUserRoleMapper;
37
+import com.ruoyi.wisdomarbitrate.domain.vo.ColumnValue;
37 38
 import com.ruoyi.wisdomarbitrate.domain.vo.ReservedConferenceVO;
38 39
 import com.ruoyi.wisdomarbitrate.domain.vo.ToDoCount;
39 40
 import com.ruoyi.wisdomarbitrate.utils.CaseLogUtils;
@@ -136,6 +137,10 @@ public class CaseApplicationServiceImpl implements ICaseApplicationService {
136 137
     private CaseAffiliateLogMapper caseAffiliateLogMapper;
137 138
     @Autowired
138 139
     private CaseAttachLogMapper caseAttachLogMapper;
140
+    @Autowired
141
+    private FatchRuleMapper fatchRuleMapper;
142
+    @Autowired
143
+    private ColumnValueMapper columnValueMapper;
139 144
 
140 145
     // 手机号正则
141 146
     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}$");
@@ -412,6 +417,7 @@ public class CaseApplicationServiceImpl implements ICaseApplicationService {
412 417
         String zipName = file.getOriginalFilename();
413 418
         String subzipName = zipName.substring(0, zipName.indexOf(".zip"));
414 419
 //        String zipPath = "F:\\testZip\\uploadPath\\upload\\upload1\\unzipFile\\"+subzipName;
420
+        // todo 服务器路径需要改
415 421
         String zipPath = "/home/ruoyi/uploadPath/upload/unzipFile/" + subzipName;
416 422
 //        String zipPath = "D:/" + subzipName;
417 423
 
@@ -934,7 +940,7 @@ public class CaseApplicationServiceImpl implements ICaseApplicationService {
934 940
      */
935 941
     @Override
936 942
     @Transactional
937
-    public int insertcaseApplication(CaseApplication caseApplication) {
943
+    public int insertcaseApplication(CaseApplication caseApplication,Map<String,String> fatchMap)  {
938 944
 
939 945
         caseApplication.setCaseStatus(CaseApplicationConstants.CASE_APPLICATION);
940 946
         //根据仲裁费用计费规则计算应缴费用
@@ -1033,6 +1039,9 @@ public class CaseApplicationServiceImpl implements ICaseApplicationService {
1033 1039
                 }
1034 1040
                 caseAffiliateLogMapper.batchCaseAffiliate(caseAffiliates);
1035 1041
             }
1042
+            // 新增动态配置字段值表
1043
+            insertColumnValue(fatchMap,caseApplication.getCaseAppliId());
1044
+
1036 1045
         });
1037 1046
 
1038 1047
         return rows;
@@ -2989,180 +2998,204 @@ public class CaseApplicationServiceImpl implements ICaseApplicationService {
2989 2998
         //解压缩上传的压缩包
2990 2999
         boolean unzipSuccess = UnZipFileUtils.unZipFile(zipFile, targetPath);
2991 3000
         if (unzipSuccess) {
3001
+            // 查询抓取规则
3002
+            // todo 批次需要再上传压缩包时用户填写
3003
+            List<FatchRule> fatchRuleList = fatchRuleMapper.listByTemplateId("9");
2992 3004
             File directory = new File(targetPath);
2993
-           Map<String,String>  andConvertPDF = findAndConvertPDF(directory);
3005
+           Map<String,String>  andConvertPDF = findAndConvertPDF(directory,fatchRuleList);
2994 3006
             if (andConvertPDF != null && andConvertPDF.size() > 0) {
2995
-                   Map<String, List<String>> map = new HashMap<>();
2996
-                    // oc识别pdf并组装数据
2997
-                    // 抓取申请书
2998
-                    if(!OCRAndBuildInfo(andConvertPDF, "仲裁申请书", map)){
2999
-                        return AjaxResult.error("未找到该路径:"+andConvertPDF);
3007
+                   Map<String,String> fatchMap = new HashMap<>();
3008
+                    if(CollectionUtil.isNotEmpty(fatchRuleList)){
3009
+                        Map<String, List<FatchRule>> fatchRuleMap = fatchRuleList.stream().collect(Collectors.groupingBy(FatchRule::getFileName));
3010
+                        // 根据抓取规则循环抓取
3011
+                        for (Map.Entry<String, List<FatchRule>> entry : fatchRuleMap.entrySet()) {
3012
+                            OCRAndBuildInfo(andConvertPDF,entry.getKey(),fatchMap,entry.getValue());
3013
+                        }
3000 3014
                     }
3001
-                    // 抓取调节协议书
3002
-                if(!OCRAndBuildInfo(andConvertPDF, "调解协议", map)){
3003
-                    return AjaxResult.error("未找到该路径:"+andConvertPDF);
3004
-                }
3005
-                // 抓取合同
3006
-                if(!OCRAndBuildInfo(andConvertPDF, "贷款合同", map)){
3007
-                    return AjaxResult.error("未找到该路径:"+andConvertPDF);
3008
-                }
3009
-                if(!OCRAndBuildInfo(andConvertPDF, "授权委托书", map)){
3010
-                    return AjaxResult.error("未找到该路径:"+andConvertPDF);
3011
-                }
3012 3015
 
3013
-                if (map.size()>0){
3016
+                if (fatchMap.size()>0){
3017
+
3014 3018
                     // todo 从压缩包中识别各字段填充到数据库
3015 3019
                         //调用新增案件的接口
3016 3020
                         CaseApplication caseApplication = new CaseApplication();
3017 3021
                         //默认案件标的 todo 案件标的是什么
3018 3022
                         caseApplication.setCaseSubjectAmount(new BigDecimal(1));
3019
-                        caseApplication.setApplicationOrganId(map.get("统一社会信用代码").get(0));
3020
-                        caseApplication.setArbitratClaims(map.get("仲裁请求").get(0));
3021
-                        caseApplication.setFacts(map.get("事实和理由").get(0));
3022
-                    String contractNumber = map.get("合同编号").get(0);
3023
-                    // 提取字母和数字
3024
-                  String regx="[^a-zA-Z0-9]";
3025
-                    String replaceAll = contractNumber.replaceAll(regx, "");
3026
-
3027
-                    caseApplication.setContractNumber(replaceAll.toUpperCase());
3028
-                    String lonStartDate = map.get("或委托代理人签字:").get(0);
3023
+                        // todo 这些以后要去掉,不在案件基本信息表维护,现在往基本信息表设置字段是因为修改以及查询详情的时候页面中字段是固定的,以后也要动态维护字段
3024
+                    // 仲裁请求
3025
+                    caseApplication.setArbitratClaims(fatchMap.get("arbitrationClaims"));
3026
+                    // 事实和理由
3027
+                    caseApplication.setFacts(fatchMap.get("factsAndReason"));
3028
+                    // 合同编号
3029
+                    String contractNumber = fatchMap.get("contractNumber");
3030
+                    if(StrUtil.isNotEmpty(contractNumber)) {
3031
+                        // 提取字母和数字
3032
+                        String regx = "[^a-zA-Z0-9]";
3033
+                        String replaceAll = contractNumber.replaceAll(regx, "");
3034
+
3035
+                        caseApplication.setContractNumber(replaceAll.toUpperCase());
3036
+                    }
3037
+                    // 借款开始日期
3038
+                    String lonStartDate = fatchMap.get("lonStartDate:");
3029 3039
                     SimpleDateFormat sdf = new SimpleDateFormat();
3030 3040
                     sdf.applyPattern("yyyy年MM月dd日");
3031
-                    try {
3032
-                        caseApplication.setLoanStartDate( sdf.parse(lonStartDate));
3033
-                    } catch (ParseException e) {
3034
-                        e.printStackTrace();
3035
-                    }
3036
-                    // todo 查询同一批号的模板
3037
-                    // 金融消费纠纷基本情况
3038
-                    String disputes = map.get("金融消费纠纷基本情况").get(0);
3039
-                    String disputesTemplate="本案当事人甲{1}(下称“甲方”)于{2}向本案当事人乙{3}(下称“乙方”)申请{3}贷款,贷款金额人民币{4}元,贷款期限{5}期。截至{6},甲方尚欠乙方金额总计人民币{7}元。因甲方诉求与乙方进行协商还款。乙方为妥善解决纠纷,故申请调解中心进行调解。";
3040
-                    List<String> disputeList = getReplaceList(disputesTemplate, disputes);
3041
-                    if(CollectionUtil.isNotEmpty(disputeList)){
3042
-                        if(disputeList.size()>3){
3043
-                        caseApplication.setLoanType(disputeList.get(3));
3044
-                        }
3045
-                        if(disputeList.size()>4) {
3046
-                            String claimPrinciOwed = disputeList.get(4);
3047
-                            // 金额格式化
3048
-                            try {
3049
-                                Double.parseDouble(claimPrinciOwed);
3050
-
3051
-                                caseApplication.setClaimPrinciOwed(new BigDecimal(claimPrinciOwed));
3052
-                            } catch (NumberFormatException e) {
3053
-
3054
-                                String regEx = "[^0-9]";
3055
-                                Pattern p = Pattern.compile(regEx);
3056
-                                Matcher m = p.matcher(claimPrinciOwed);
3057
-                                String result = m.replaceAll("").trim();
3058
-                                BigDecimal bigDecimal = null;
3059
-                                if (claimPrinciOwed.contains("百")) {
3060
-                                    bigDecimal = new BigDecimal(result).multiply(new BigDecimal("100"));
3061
-                                } else if (claimPrinciOwed.contains("千")) {
3062
-                                    bigDecimal = new BigDecimal(result).multiply(new BigDecimal("1000"));
3063
-                                } else if (claimPrinciOwed.contains("万")) {
3064
-                                    bigDecimal = new BigDecimal(result).multiply(new BigDecimal("10000"));
3065
-                                } else if (claimPrinciOwed.contains("百万")) {
3066
-                                    bigDecimal = new BigDecimal(result).multiply(new BigDecimal("1000000"));
3067
-                                } else if (claimPrinciOwed.contains("千万")) {
3068
-                                    bigDecimal = new BigDecimal(result).multiply(new BigDecimal("10000000"));
3069
-                                } else if (claimPrinciOwed.contains("亿")) {
3070
-                                    bigDecimal = new BigDecimal(result).multiply(new BigDecimal("100000000"));
3071
-                                }
3072
-                                // todo  生产裁决书时金额格式增加千分位
3073
-                              //  NumberFormat format = NumberFormat.getInstance();
3074
-                              //  String format1 = format.format(bigDecimal);
3075
-
3076
-                                caseApplication.setClaimPrinciOwed(bigDecimal);
3077
-                            }
3078
-                        }
3079
-
3080
-                        if(disputeList.size()>5){
3081
-                            caseApplication.setLoanTerm(disputeList.get(5));
3082
-                        }
3083
-                    }
3084
-                    // 调解协议
3085
-                    String mediationAgreement = map.get("经调解,双方自愿达成如下协议").get(0);
3086
-                    caseApplication.setMediationAgreement(mediationAgreement);
3087
-                    String mediationAgreementTemplate="1、乙方从维系客户的角度出发,同意为甲方申请停催至{1},停催期间正常计息,且征信影响由甲方自行承担。2、甲方应于{2}停催到期前向乙方申请费息减免业务,并按人民币{3}元一次性结清剩余贷款。3、今后双方无涉,就此结案。";
3088
-                    // 对比模板和pdf识别的内容,取出占位符对应的值
3089
-                    List<String> mediationAgreementList = getReplaceList(mediationAgreementTemplate, mediationAgreement);
3090
-                    if(CollectionUtil.isNotEmpty(mediationAgreementList)){
3091
-                        // 截止日期
3092
-                        String lonEndDate = mediationAgreementList.get(0);
3041
+                    if(StrUtil.isNotEmpty(lonStartDate)) {
3093 3042
                         try {
3094
-                            caseApplication.setLoanEndDate( sdf.parse(lonEndDate));
3043
+                            caseApplication.setLoanStartDate(sdf.parse(lonStartDate));
3095 3044
                         } catch (ParseException e) {
3096 3045
                             e.printStackTrace();
3097 3046
                         }
3098
-                        if(mediationAgreementList.size()>2){
3099
-                            // 待还金额
3100
-                            caseApplication.setOutstandingMoney(mediationAgreementList.get(2));
3101
-                        }
3102 3047
                     }
3103
-                        // 合同甲方
3104
-                        caseApplication.setPartyA(map.get("甲方(贷款人)").get(0));
3048
+                    // todo 查询同一批号的模板
3049
+                    // 金融消费纠纷基本情况
3050
+                    String disputes = fatchMap.get("disputes");
3051
+                    caseApplication.setDisputes(disputes);
3052
+//                    String disputesTemplate="本案当事人甲{1}(下称“甲方”)于{2}向本案当事人乙{3}(下称“乙方”)申请{3}贷款,贷款金额人民币{4}元,贷款期限{5}期。截至{6},甲方尚欠乙方金额总计人民币{7}元。因甲方诉求与乙方进行协商还款。乙方为妥善解决纠纷,故申请调解中心进行调解。";
3053
+//                    List<String> disputeList = getReplaceList(disputesTemplate, disputes);
3054
+//                    if(CollectionUtil.isNotEmpty(disputeList)){
3055
+//                        if(disputeList.size()>3){
3056
+//                        caseApplication.setLoanType(disputeList.get(3));
3057
+//                        }
3058
+//                        if(disputeList.size()>4) {
3059
+//                            String claimPrinciOwed = disputeList.get(4);
3060
+//                            // 金额格式化
3061
+//                            try {
3062
+//                                Double.parseDouble(claimPrinciOwed);
3063
+//
3064
+//                                caseApplication.setClaimPrinciOwed(new BigDecimal(claimPrinciOwed));
3065
+//                            } catch (NumberFormatException e) {
3066
+//
3067
+//                                String regEx = "[^0-9]";
3068
+//                                Pattern p = Pattern.compile(regEx);
3069
+//                                Matcher m = p.matcher(claimPrinciOwed);
3070
+//                                String result = m.replaceAll("").trim();
3071
+//                                BigDecimal bigDecimal = null;
3072
+//                                if (claimPrinciOwed.contains("百")) {
3073
+//                                    bigDecimal = new BigDecimal(result).multiply(new BigDecimal("100"));
3074
+//                                } else if (claimPrinciOwed.contains("千")) {
3075
+//                                    bigDecimal = new BigDecimal(result).multiply(new BigDecimal("1000"));
3076
+//                                } else if (claimPrinciOwed.contains("万")) {
3077
+//                                    bigDecimal = new BigDecimal(result).multiply(new BigDecimal("10000"));
3078
+//                                } else if (claimPrinciOwed.contains("百万")) {
3079
+//                                    bigDecimal = new BigDecimal(result).multiply(new BigDecimal("1000000"));
3080
+//                                } else if (claimPrinciOwed.contains("千万")) {
3081
+//                                    bigDecimal = new BigDecimal(result).multiply(new BigDecimal("10000000"));
3082
+//                                } else if (claimPrinciOwed.contains("亿")) {
3083
+//                                    bigDecimal = new BigDecimal(result).multiply(new BigDecimal("100000000"));
3084
+//                                }
3085
+//                                // todo  生产裁决书时金额格式增加千分位
3086
+//                              //  NumberFormat format = NumberFormat.getInstance();
3087
+//                              //  String format1 = format.format(bigDecimal);
3088
+//
3089
+//                                caseApplication.setClaimPrinciOwed(bigDecimal);
3090
+//                            }
3091
+//                        }
3092
+//
3093
+//                        if(disputeList.size()>5){
3094
+//                            caseApplication.setLoanTerm(disputeList.get(5));
3095
+//                        }
3096
+//                    }
3097
+                    // 调解协议内容
3098
+                    String mediationAgreement = fatchMap.get("mediationAgreement");
3099
+                    caseApplication.setMediationAgreement(mediationAgreement);
3100
+//                    String mediationAgreementTemplate="1、乙方从维系客户的角度出发,同意为甲方申请停催至{1},停催期间正常计息,且征信影响由甲方自行承担。2、甲方应于{2}停催到期前向乙方申请费息减免业务,并按人民币{3}元一次性结清剩余贷款。3、今后双方无涉,就此结案。";
3101
+//                    // 对比模板和pdf识别的内容,取出占位符对应的值
3102
+//                    List<String> mediationAgreementList = getReplaceList(mediationAgreementTemplate, mediationAgreement);
3103
+//                    if(CollectionUtil.isNotEmpty(mediationAgreementList)){
3104
+//                        // 截止日期
3105
+//                        String lonEndDate = mediationAgreementList.get(0);
3106
+//                        try {
3107
+//                            caseApplication.setLoanEndDate( sdf.parse(lonEndDate));
3108
+//                        } catch (ParseException e) {
3109
+//                            e.printStackTrace();
3110
+//                        }
3111
+//                        if(mediationAgreementList.size()>2){
3112
+//                            // 待还金额
3113
+//                            caseApplication.setOutstandingMoney(mediationAgreementList.get(2));
3114
+//                        }
3115
+//                    }
3116
+                        // 合同甲方(贷款人)
3117
+                        caseApplication.setPartyA(fatchMap.get("partyA"));
3105 3118
                         List<CaseAffiliate> caseAffiliates = new ArrayList<>();
3106 3119
                         CaseAffiliate caseAffiliate = new CaseAffiliate();
3107 3120
                         caseAffiliate.setIdentityType(1);
3108
-                        caseAffiliate.setName(map.get("申请人").get(0));
3109
-                        caseAffiliate.setIdentityNum(map.get("统一社会信用代码").get(0));
3110
-                        caseAffiliate.setCompLegalPerson(map.get("负责人").get(0));
3111
-                        if(map.get("职务").size()>0) {
3112
-                            // 法定代表人职务
3113
-                            caseAffiliate.setCompLegalperPost(map.get("职务").get(0));
3114
-                            if(map.get("职务").size()>1) {
3115
-                                // 代理人职务
3116
-                                caseAffiliate.setAppliAgentTitle(map.get("职务").get(1));
3117
-                            }
3118
-                        }
3119
-                        caseAffiliate.setNameAgent(map.get("委托代理人").get(0));
3120
-                        caseAffiliate.setContactTelphoneAgent(map.get("联系电话").get(0));
3121
-                        caseAffiliate.setResidenAffili(map.get("住所").get(0));
3122
-                        caseAffiliate.setContactAddress(map.get("联系地址").get(0));
3123
-                        caseAffiliate.setAgentEmail(map.get("电子邮件").get(0).replaceAll("\\s", ""));
3121
+                        // 申请人
3122
+                        caseAffiliate.setName(fatchMap.get("applicantName"));
3123
+                        // 统一社会信用代码
3124
+                        caseAffiliate.setIdentityNum(fatchMap.get("creditCode"));
3125
+                        // 法定代表人
3126
+                        caseAffiliate.setCompLegalPerson(fatchMap.get("legalRepresentative"));
3127
+                        // 申请人联系电话
3128
+                        caseAffiliate.setContactTelphone(fatchMap.get("applicantPhone"));
3129
+                    // 申请人住所
3130
+                    caseAffiliate.setResidenAffili(fatchMap.get("applicantHome"));
3131
+                    // 申请人联系地址
3132
+                    caseAffiliate.setContactAddress(fatchMap.get("applicantAddress"));
3133
+//                        if(map.get("职务").size()>0) {
3134
+//                            // 法定代表人职务
3135
+//                            caseAffiliate.setCompLegalperPost(map.get("职务").get(0));
3136
+//                            if(map.get("职务").size()>1) {
3137
+//                                // 代理人职务
3138
+//                                caseAffiliate.setAppliAgentTitle(map.get("职务").get(1));
3139
+//                            }
3140
+//                        }
3141
+                        // 委托代理人
3142
+                        caseAffiliate.setNameAgent(fatchMap.get("agentName"));
3143
+                        // 委托代理人联系电话
3144
+                        caseAffiliate.setContactTelphoneAgent(fatchMap.get("agentPhone"));
3145
+
3146
+                        // 代理人电子邮件
3147
+                        caseAffiliate.setAgentEmail(fatchMap.get("agentEmail").replaceAll("\\s", ""));
3124 3148
 
3125 3149
 
3126 3150
                         //设置默认代理人的身份证号码,暂时写死 要不然新增方法报错
3127 3151
                   //      caseAffiliate.setIdentityNumAgent("610423199603171716");
3128 3152
                         caseAffiliates.add(caseAffiliate);
3129
-                        CaseAffiliate caseAffiliate1 = new CaseAffiliate();
3130
-                        caseAffiliate1.setIdentityType(2);
3131
-                        caseAffiliate1.setName(map.get("被申请人").get(0));
3153
+                        // 被申请人信息
3154
+                        CaseAffiliate respondentAffiliate = new CaseAffiliate();
3155
+                    respondentAffiliate.setIdentityType(2);
3156
+                    // 被申请人名称
3157
+                    respondentAffiliate.setName(fatchMap.get("respondentName"));
3132 3158
                         // 被申请人身份证
3133
-                        String identityNum = map.get("居民身份证号码").get(0);
3134
-                        caseAffiliate1.setIdentityNum(identityNum);
3135
-                        // 被申请人电子邮件
3136
-                    if(map.get("乙方确认有效的电子信箱地址为").size()>1) {
3137
-                        if(map.get("乙方确认有效的电子信箱地址为").get(0).contains("/")) {
3138
-                            caseAffiliate1.setEmail(map.get("乙方确认有效的电子信箱地址为").get(1).replaceAll("\\s", ""));
3139
-                        }else {
3140
-                            caseAffiliate1.setEmail(map.get("乙方确认有效的电子信箱地址为").get(0).replaceAll("\\s", ""));
3141
-                        }
3142
-                    }
3143
-                        // 出生年月日,从身份证抓取
3144
-                        if(StrUtil.isNotEmpty(identityNum)) {
3145
-                            Map<String, String> identityNumMap = getBirAgeSex(identityNum);
3146
-                            String birthday = identityNumMap.get("birthday");
3147
-                            if(StrUtil.isNotEmpty(birthday)) {
3148
-                                SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
3149
-                                Date birthdayDate = null;
3150
-                                try {
3151
-                                    birthdayDate = simpleDateFormat.parse(birthday);
3152
-                                } catch (Exception e) {
3153
-                                    e.printStackTrace();
3154
-                                }
3155
-                                caseAffiliate1.setResponBirth(birthdayDate);
3159
+                        String identityNum = fatchMap.get("respondentCard");
3160
+                    // 出生年月日,从身份证抓取
3161
+                    if(StrUtil.isNotEmpty(identityNum)) {
3162
+                        Map<String, String> identityNumMap = getBirAgeSex(identityNum);
3163
+                        String birthday = identityNumMap.get("birthday");
3164
+                        if(StrUtil.isNotEmpty(birthday)) {
3165
+                            SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
3166
+                            Date birthdayDate = null;
3167
+                            try {
3168
+                                birthdayDate = simpleDateFormat.parse(birthday);
3169
+                            } catch (Exception e) {
3170
+                                e.printStackTrace();
3156 3171
                             }
3157
-                            //从身份证抓取性别
3158
-                            caseAffiliate1.setResponSex(identityNumMap.get("sexCode"));
3172
+                            fatchMap.put("resDateOfBirth", sdf.format(birthdayDate));
3173
+                            respondentAffiliate.setResponBirth(birthdayDate);
3159 3174
                         }
3160
-                        caseAffiliate1.setContactTelphone(map.get("联系电话").get(1));
3161
-                        caseAffiliate1.setResidenAffili(map.get("住所").get(1));
3162
-
3163
-                        caseAffiliates.add(caseAffiliate1);
3175
+                        //从身份证抓取性别
3176
+                        fatchMap.put("resSex",identityNumMap.get("sexCode"));
3177
+                        respondentAffiliate.setResponSex(identityNumMap.get("sexCode"));
3178
+                    }
3179
+                    respondentAffiliate.setIdentityNum(identityNum);
3180
+                        // 被申请人电子邮件
3181
+//                    if(map.get("乙方确认有效的电子信箱地址为").size()>1) {
3182
+//                        if(map.get("乙方确认有效的电子信箱地址为").get(0).contains("/")) {
3183
+//                            respondentAffiliate.setEmail(map.get("乙方确认有效的电子信箱地址为").get(1).replaceAll("\\s", ""));
3184
+//                        }else {
3185
+//                            respondentAffiliate.setEmail(map.get("乙方确认有效的电子信箱地址为").get(0).replaceAll("\\s", ""));
3186
+//                        }
3187
+//                    }
3188
+                    // 被申请人电子邮件
3189
+                    respondentAffiliate.setEmail(fatchMap.get("respondentEmail").replaceAll("\\s", ""));
3190
+                    // 被申请人联系电话
3191
+                    respondentAffiliate.setContactTelphone(fatchMap.get("respondentPhone"));
3192
+                    // 被申请人住所
3193
+                    respondentAffiliate.setResidenAffili(fatchMap.get("respondentHome"));
3194
+
3195
+                        caseAffiliates.add(respondentAffiliate);
3164 3196
                         caseApplication.setCaseAffiliates(caseAffiliates);
3165
-                        this.insertcaseApplication(caseApplication);
3197
+                        // 新增案件基本信息表
3198
+                        this.insertcaseApplication(caseApplication,fatchMap);
3166 3199
                         if (null != caseApplication.getId()) {
3167 3200
                             List<CaseAttach> caseAttachs=new ArrayList<>();
3168 3201
                             for (Map.Entry<String, String> entry : andConvertPDF.entrySet()) {
@@ -3199,49 +3232,54 @@ public class CaseApplicationServiceImpl implements ICaseApplicationService {
3199 3232
         return null;
3200 3233
     }
3201 3234
 
3202
-    private boolean OCRAndBuildInfo( Map<String, String> andConvertPDF, String mapKey, Map<String, List<String>> map) {
3235
+    /**
3236
+     * 新增动态配置字段值表
3237
+     * @param fatchMap
3238
+     * @param caseApplicId
3239
+     */
3240
+    private void insertColumnValue(Map<String, String> fatchMap, Long caseApplicId) {
3241
+        if(fatchMap==null){
3242
+            return;
3243
+        }
3244
+        // 新增到动态配置字段表
3245
+        List<ColumnValue> columnValueList=new ArrayList<>();
3246
+        // todo 新增完案件信息表后这样改
3247
+
3248
+        fatchMap.forEach((key,value)->{
3249
+            ColumnValue columnValue = new ColumnValue();
3250
+            columnValue.setCaseId(caseApplicId);
3251
+            columnValue.setColumn(key);
3252
+            columnValue.setValue(value);
3253
+            // todo 组装的map中的key需要column+@+columnName拼接
3254
+            columnValue.setName("");
3255
+            columnValueList.add(columnValue);
3256
+        });
3257
+        if(CollectionUtil.isNotEmpty(columnValueList)){
3258
+            // 批量新增
3259
+            columnValueMapper.batchSave(columnValueList);
3260
+        }
3261
+    }
3262
+
3263
+    private boolean OCRAndBuildInfo( Map<String, String> andConvertPDF,String mapKey,  Map<String, String> map, List<FatchRule> fatchRules) {
3203 3264
         String pdfUrl = andConvertPDF.get(mapKey);
3204 3265
 
3205
-        if(StrUtil.isEmpty(pdfUrl)){
3206
-            throw new ServiceException("pdfUrl:"+pdfUrl+"===mapKey:"+mapKey);
3207
-          //  return false;
3208
-        }
3209
-        //获取文件的页数
3210
-        int fileNumPage = getFileNumPage(pdfUrl);
3211
-        //文件转成base64
3212
-        String base64 = OCRUtils.pdfConvertBase64(pdfUrl);
3213
-        if (base64 == null){
3214
-            throw new ServiceException("文件转成base64 pdfUrl:"+pdfUrl+"===mapKey:"+mapKey);
3215
-          //  return false;
3216
-        }
3217
-        StringBuilder stringBuilder = new StringBuilder(); // 创建一个StringBuilder对象
3218
-        for (int i = 0; i < fileNumPage; i++) {
3219
-            //对接腾讯云接口.识别里面的数据
3220
-            String text = OCRUtils.pdfIdentifyText(base64, i + 1,mapKey);
3221
-            if (stringBuilder.length() > 0) {
3222
-                stringBuilder.append(Constants.BR); // 在已有内容的情况下添加逗号分隔符
3223
-            }
3224
-            stringBuilder.append(text); // 拼接当前的字符串
3225
-        }
3226
-        // 将字符串按逗号分隔符切割
3227
-        String[] fields = stringBuilder.toString().split(Constants.BR);
3228
-        for (String field : fields) {
3229
-            // 对于每个字段,再按冒号分隔符拆分出键和值
3230
-            String[] keyValue = field.split(Constants.PDFSTR);
3231
-            if (keyValue.length >= 2) {
3232
-                String key = keyValue[0];
3233
-                String value = keyValue[1];
3234
-                // 判断Map中是否已存在该键
3235
-                if (map.containsKey(key)) {
3236
-                    // 如果已存在,获取该键对应的值,并将新的值添加到集合中
3237
-                    List<String> values = map.get(key);
3238
-                    values.add(value);
3239
-                } else {
3240
-                    // 如果不存在,创建一个新的集合,并将值添加到集合中
3241
-                    List<String> values = new ArrayList<>();
3242
-                    values.add(value);
3243
-                    map.put(key, values);
3244
-                }
3266
+        if(StrUtil.isNotEmpty(pdfUrl)) {
3267
+            //获取文件的页数
3268
+            int fileNumPage = getFileNumPage(pdfUrl);
3269
+            //文件转成base64
3270
+            String base64 = OCRUtils.pdfConvertBase64(pdfUrl);
3271
+            if (base64 == null) {
3272
+                throw new ServiceException("文件转成base64,转码失败");
3273
+                //  return false;
3274
+            }
3275
+            StringBuilder ocrText = new StringBuilder(); // 创建一个StringBuilder对象
3276
+            for (int i = 0; i < fileNumPage; i++) {
3277
+                //对接腾讯云接口.识别里面的数据
3278
+                String text = OCRUtils.pdfIdentifyText(base64, i + 1, fatchRules);
3279
+                ocrText.append(text); // 拼接当前的字符串
3280
+            }
3281
+            if(StrUtil.isNotEmpty(ocrText)){
3282
+               OCRUtils.fatchRuleGetContent(ocrText.toString(), fatchRules,map);
3245 3283
             }
3246 3284
         }
3247 3285
         return true;
@@ -3303,7 +3341,7 @@ public class CaseApplicationServiceImpl implements ICaseApplicationService {
3303 3341
     }
3304 3342
 
3305 3343
 
3306
-    public static Map<String,String> findAndConvertPDF(File directory) {
3344
+    public static Map<String,String> findAndConvertPDF(File directory, List<FatchRule> fatchRuleList ) {
3307 3345
        Map<String,String> pdfPathMap= new HashMap<>();
3308 3346
         if (directory.isFile()) {
3309 3347
             String path = "";
@@ -3320,46 +3358,16 @@ public class CaseApplicationServiceImpl implements ICaseApplicationService {
3320 3358
                         path = pdfPath;
3321 3359
                     }
3322 3360
                 }
3323
-                if (path != null) {
3324 3361
                     // 如果文件名包含"仲裁申请书"且是PDF格式,直接返回路径
3325 3362
                     // 如果是PDF格式,直接添加到列表中
3326
-                    String name="";
3327
-                    if (directory.getName().contains("仲裁申请书")) {
3328
-                        name="仲裁申请书";
3329
-                    }
3330
-                    if (directory.getName().contains("调解协议")) {
3331
-                        name="调解协议";
3332
-                    }
3333
-                    if (directory.getName().contains("情况说明")) {
3334
-                        name="情况说明";
3335
-                    }
3336
-                    if (directory.getName().contains("贷款合同")) {
3337
-                        name="贷款合同";
3338
-                    }
3339
-                    if (directory.getName().contains("营业执照")) {
3340
-                        name="营业执照";
3341
-                    }
3342
-                    if (directory.getName().contains("负责人证明")) {
3343
-                        name="负责人证明";
3344
-                    }
3345
-                    if (directory.getName().contains("负责人身份证")) {
3346
-                        name="负责人身份证";
3347
-                    }
3348
-                    if (directory.getName().contains("授权委托书")) {
3349
-                        name="授权委托书";
3350
-                    }
3351
-                    if (directory.getName().contains("经办人员的劳动合同")) {
3352
-                        name="经办人员的劳动合同";
3353
-                    }
3354
-                    if (directory.getName().contains("经办人员身份证")) {
3355
-                        name="经办人员的身份证";
3356
-                    }
3357
-                    if (directory.getName().contains("自然人身份证")) {
3358
-                        name="自然人身份证";
3359
-                    }
3360
-
3361
-                    pdfPathMap.put(name,path);
3362
-                }
3363
+//                    if(CollectionUtil.isNotEmpty(fatchRuleList)) {
3364
+//                        for (FatchRule fatchRule : fatchRuleList) {
3365
+//                            if(fatchRule.getFileName().contains(directory.getName())){
3366
+                                pdfPathMap.put(directory.getName(), path);
3367
+//                            }
3368
+//                        }
3369
+//
3370
+//                    }
3363 3371
          //   }
3364 3372
         } else if (directory.isDirectory()) {
3365 3373
             searchAndConvertPDF(directory, pdfPathMap);
@@ -3391,51 +3399,18 @@ public class CaseApplicationServiceImpl implements ICaseApplicationService {
3391 3399
                     continue;
3392 3400
                 }
3393 3401
                 if (file.isFile()) {
3394
-                    String name="";
3395
-                    if (file.getName().contains("仲裁申请书")) {
3396
-                        name="仲裁申请书";
3397
-                    }
3398
-                    if (file.getName().contains("调解协议")) {
3399
-                        name="调解协议";
3400
-                    }
3401
-                    if (file.getName().contains("情况说明")) {
3402
-                        name="情况说明";
3403
-                    }
3404
-                    if (file.getName().contains("贷款合同")) {
3405
-                        name="贷款合同";
3406
-                    }
3407
-                    if (file.getName().contains("营业执照")) {
3408
-                        name="营业执照";
3409
-                    }
3410
-                    if (file.getName().contains("负责人证明")) {
3411
-                        name="负责人证明";
3412
-                    }
3413
-                    if (file.getName().contains("负责人身份证")) {
3414
-                        name="负责人身份证";
3415
-                    }
3416
-                    if (file.getName().contains("授权委托书")) {
3417
-                        name="授权委托书";
3418
-                    }
3419
-                    if (file.getName().contains("经办人员的劳动合同")) {
3420
-                        name="经办人员的劳动合同";
3421
-                    }
3422
-                    if (file.getName().contains("经办人员的身份证")) {
3423
-                        name="经办人员身份证";
3424
-                    }
3425
-                    if (file.getName().contains("自然人身份证")) {
3426
-                        name="自然人身份证";
3427
-                    }
3402
+
3428 3403
                     // 如果是文件且文件名包含"仲裁申请书"
3429 3404
                 //    if (file.getName().contains("仲裁申请书")) {
3430 3405
                         if (isPDF(file)) {
3431 3406
                             // 如果是PDF格式,直接添加到列表中
3432
-                            pdfPathMap.put(name,file.getAbsolutePath());
3407
+                            pdfPathMap.put(file.getName(),file.getAbsolutePath());
3433 3408
                         } else {
3434 3409
                             // 如果不是PDF格式,进行转换成PDF并添加转换后的路径到列表中
3435 3410
                         String   pdfPath = convertToPDF(file);
3436 3411
                             if (pdfPath != null) {
3437 3412
                                 // 如果是PDF格式,直接添加到列表中
3438
-                                pdfPathMap.put(name,pdfPath);
3413
+                                pdfPathMap.put(file.getName(),pdfPath);
3439 3414
                             }
3440 3415
                         }
3441 3416
 

+ 120
- 6
ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/utils/OCRUtils.java Прегледај датотеку

@@ -1,23 +1,25 @@
1 1
 package com.ruoyi.wisdomarbitrate.utils;
2 2
 
3
+import cn.hutool.core.collection.CollectionUtil;
4
+import cn.hutool.core.util.StrUtil;
3 5
 import com.ruoyi.common.constant.Constants;
6
+import com.ruoyi.common.exception.ServiceException;
7
+import com.ruoyi.wisdomarbitrate.domain.FatchRule;
4 8
 import com.tencentcloudapi.bsca.v20210811.models.LicenseSummary;
5 9
 import com.tencentcloudapi.common.Credential;
6 10
 import com.tencentcloudapi.common.exception.TencentCloudSDKException;
7 11
 import com.tencentcloudapi.common.profile.ClientProfile;
8 12
 import com.tencentcloudapi.common.profile.HttpProfile;
9 13
 import com.tencentcloudapi.ocr.v20181119.OcrClient;
10
-import com.tencentcloudapi.ocr.v20181119.models.SmartStructuralOCRV2Request;
11
-import com.tencentcloudapi.ocr.v20181119.models.SmartStructuralOCRV2Response;
14
+import com.tencentcloudapi.ocr.v20181119.models.*;
12 15
 import org.json.JSONArray;
13 16
 import org.json.JSONObject;
14 17
 
15 18
 import java.io.File;
16 19
 import java.io.FileInputStream;
17 20
 import java.io.IOException;
18
-import java.util.ArrayList;
19
-import java.util.Base64;
20
-import java.util.List;
21
+import java.util.*;
22
+import java.util.stream.Collectors;
21 23
 
22 24
 public class OCRUtils {
23 25
     //API的SecretId
@@ -34,8 +36,88 @@ public class OCRUtils {
34 36
     private static final String[] accordName = {"金融消费纠纷基本情况","经调解,双方自愿达成如下协议"};
35 37
     // 授权委托书识别字段
36 38
     private static final String[] powerAttorneyName = {"职务"};
39
+    /**
40
+     * pdf识别成文字
41
+     * @param imageBase64
42
+     * @param pageNumber
43
+     * @param fatchRules 抓取规则
44
+     * @return
45
+     */
46
+    public static String pdfIdentifyText(String imageBase64, Integer pageNumber, List<FatchRule> fatchRules) {
47
+        StringBuilder respStr=new StringBuilder();
48
+        try {
49
+            // 实例化一个认证对象,入参需要传入腾讯云账户 SecretId 和 SecretKey,此处还需注意密钥对的保密
50
+            // 代码泄露可能会导致 SecretId 和 SecretKey 泄露,并威胁账号下所有资源的安全性。以下代码示例仅供参考,建议采用更安全的方式来使用密钥,请参见:https://cloud.tencent.com/document/product/1278/85305
51
+            // 密钥可前往官网控制台 https://console.cloud.tencent.com/cam/capi 进行获取
52
+            Credential cred = new Credential(SECRET_ID, SECRET_KEY);
53
+            // 实例化一个http选项,可选的,没有特殊需求可以跳过
54
+            HttpProfile httpProfile = new HttpProfile();
55
+            httpProfile.setEndpoint("ocr.tencentcloudapi.com");
56
+            // 实例化一个client选项,可选的,没有特殊需求可以跳过
57
+            ClientProfile clientProfile = new ClientProfile();
58
+            clientProfile.setHttpProfile(httpProfile);
59
+            // 实例化要请求产品的client对象,clientProfile是可选的
60
+            OcrClient client = new OcrClient(cred, "ap-beijing", clientProfile);
61
+            // 实例化一个请求对象,每个接口都会对应一个request对象
62
+            GeneralAccurateOCRRequest req = new GeneralAccurateOCRRequest();
63
+            req.setImageBase64(imageBase64);
64
+            req.setIsPdf(true);
65
+            req.setPdfPageNumber(pageNumber.longValue());
66
+            // 返回的resp是一个SmartStructuralOCRV2Response的实例,与请求对象对应
67
+            GeneralAccurateOCRResponse resp = client.GeneralAccurateOCR(req);
68
+            // 输出json格式的字符串回包
69
+            System.out.println(GeneralAccurateOCRResponse.toJsonString(resp));
70
+            // 获取响应内容
71
+            TextDetection[] textDetections = resp.getTextDetections();
72
+            if (textDetections == null || textDetections.length == 0) {
73
+                return respStr.toString();
74
+            }
75
+            for (TextDetection textDetection : textDetections) {
76
+                respStr.append(textDetection.getDetectedText());
77
+            }
78
+        }catch (TencentCloudSDKException e){
79
+            throw new ServiceException("ocr识别失败");
80
+        }
81
+        if(respStr.toString().endsWith(String.valueOf(pageNumber))){
82
+            int lastIndexOf = respStr.toString().lastIndexOf(String.valueOf(pageNumber));
83
+            return respStr.toString().substring(0,lastIndexOf);
84
+        }
85
+        return respStr.toString();
37 86
 
38 87
 
88
+
89
+//
90
+//            //解析数据
91
+//            String s = GeneralAccurateOCRResponse.toJsonString(resp);
92
+//            // 解析JSON数据
93
+//            JSONObject jsonObject = new JSONObject(s);
94
+//            JSONArray structuralList = jsonObject.getJSONArray("TextDetections");
95
+//            // 遍历StructuralList中的Groups,获取Key对应的AutoName和Value对应的AutoConten
96
+//            StringBuilder stringBuilder = new StringBuilder(); // 创建一个StringBuilder对象
97
+//            for (int i = 0; i < structuralList.length(); i++) {
98
+//                JSONArray groups = structuralList.getJSONObject(i).getJSONArray("Groups");
99
+//                for (int j = 0; j < groups.length(); j++) {
100
+//                    JSONArray lines = groups.getJSONObject(j).getJSONArray("Lines");
101
+//                    for (int k = 0; k < lines.length(); k++) {
102
+//                        JSONObject line = lines.getJSONObject(k);
103
+//                        JSONObject key = line.getJSONObject("Key");
104
+//                        JSONObject value = line.getJSONObject("Value");
105
+//                        String autoName = key.getString("AutoName");
106
+//                        String autoContent = value.getString("AutoContent");
107
+//                        String text = autoName + Constants.PDFSTR + autoContent;
108
+//                        if (stringBuilder.length() > 0) {
109
+//                            stringBuilder.append(Constants.BR); // 在已有内容的情况下添加逗号分隔符
110
+//                        }
111
+//                        stringBuilder.append(text); // 拼接当前的字符串
112
+//                    }
113
+//                }
114
+//            }
115
+//            return stringBuilder.toString(); // 获取最终的拼接结果
116
+//        } catch (TencentCloudSDKException e) {
117
+//            System.out.println(e.toString());
118
+//        }
119
+    }
120
+
39 121
     /**
40 122
      * pdf识别成文字
41 123
      * @param imageBase64
@@ -43,7 +125,7 @@ public class OCRUtils {
43 125
      * @param type pdf类型
44 126
      * @return
45 127
      */
46
-    public static String pdfIdentifyText(String imageBase64, Integer pageNumber,String type) {
128
+    public static String pdfIdentifyText1(String imageBase64, Integer pageNumber,String type) {
47 129
         try {
48 130
             // 实例化一个认证对象,入参需要传入腾讯云账户 SecretId 和 SecretKey,此处还需注意密钥对的保密
49 131
             // 代码泄露可能会导致 SecretId 和 SecretKey 泄露,并威胁账号下所有资源的安全性。以下代码示例仅供参考,建议采用更安全的方式来使用密钥,请参见:https://cloud.tencent.com/document/product/1278/85305
@@ -122,4 +204,36 @@ public class OCRUtils {
122 204
         return null;
123 205
     }
124 206
 
207
+    /**
208
+     * 根据抓取规则获取内容
209
+     * @param ocrText ocr识别的text
210
+     * @param fatchRules 抓取规则
211
+     * @return
212
+     */
213
+    public static void fatchRuleGetContent(String ocrText, List<FatchRule> fatchRules, Map<String, String> fatchMap) {
214
+
215
+        if (CollectionUtil.isNotEmpty(fatchRules)) {
216
+
217
+            for (FatchRule fatchRule : fatchRules) {
218
+                if (StrUtil.isEmpty(fatchRule.getStartContent())) {
219
+                    continue;
220
+                }
221
+                // 开始截取字符串 申请人:赵会
222
+                //   String[] startContentSplit = ocrText.split(fatchRule.getStartContent());
223
+                int startFirstIndex = ocrText.indexOf(fatchRule.getStartContent()) + fatchRule.getStartContent().length();
224
+                if (ocrText.length() >= startFirstIndex) {
225
+                    ocrText = ocrText.substring(startFirstIndex);
226
+                }
227
+
228
+                if (StrUtil.isNotEmpty(fatchRule.getEndContent())) {
229
+                    int endFirstIndex = ocrText.indexOf(fatchRule.getEndContent()) + fatchRule.getEndContent().length();
230
+                    if (ocrText.length() >= (endFirstIndex-fatchRule.getEndContent().length())) {
231
+                        fatchMap.put(fatchRule.getColumn(), ocrText.substring(0, endFirstIndex-fatchRule.getEndContent().length()));
232
+                        ocrText = ocrText.substring(endFirstIndex-fatchRule.getEndContent().length());
233
+                    }
234
+                }
235
+            }
236
+
237
+        }
238
+    }
125 239
 }

+ 26
- 0
ruoyi-system/src/main/resources/mapper/wisdomarbitrate/ColumnValueMapper.xml Прегледај датотеку

@@ -0,0 +1,26 @@
1
+<?xml version="1.0" encoding="UTF-8" ?>
2
+<!DOCTYPE mapper
3
+        PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
4
+        "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
5
+<mapper namespace="com.ruoyi.wisdomarbitrate.mapper.ColumnValueMapper">
6
+    <resultMap id="BaseResultMap" type="com.ruoyi.wisdomarbitrate.domain.vo.ColumnValue" >
7
+        <result column="id" property="id" />
8
+        <result column="column" property="column" />
9
+        <result column="name" property="name" />
10
+        <result column="value" property="value" />
11
+        <result column="case_id" property="caseId" />
12
+    </resultMap>
13
+    <insert id="batchSave">
14
+        INSERT INTO column_value ( `COLUMN`, `NAME`, `VALUE`, case_id )
15
+        values
16
+        <foreach item="item" index="index" collection="list" separator=",">
17
+
18
+        (#{item.column},#{item.name},#{item.value},#{item.caseId})
19
+        </foreach>
20
+    </insert>
21
+    <select id="listByCaseId" resultMap="BaseResultMap">
22
+        select * from column_value where case_id=#{caseId}
23
+    </select>
24
+
25
+
26
+</mapper>

+ 5
- 5
ruoyi-system/src/main/resources/mapper/wisdomarbitrate/FatchRuleMapper.xml Прегледај датотеку

@@ -5,16 +5,16 @@
5 5
 <mapper namespace="com.ruoyi.wisdomarbitrate.mapper.FatchRuleMapper">
6 6
     <resultMap id="BaseResultMap" type="com.ruoyi.wisdomarbitrate.domain.FatchRule" >
7 7
         <result column="id" property="id" />
8
+        <result column="batch_number" property="batchNumber" />
8 9
         <result column="file_name" property="fileName" />
9 10
         <result column="start_content" property="startContent" />
10 11
         <result column="end_content" property="endContent" />
11
-
12 12
         <result column="column" property="column" />
13
-        <result column="is_default" property="isDefault" />
14
-        <result column="columnName" property="columnName" />
13
+        <result column="column_name" property="columnName" />
15 14
     </resultMap>
16
-    <select id="list" resultMap="BaseResultMap">
17
-        select * from fatch_rule where batch_number=#{batchNumber}
15
+    <select id="listByTemplateId" resultMap="BaseResultMap">
16
+        select fr.* from fatch_rule fr join template_fatch_rule tfr on fr.id=tfr.fatch_rule_id
17
+        where template_id=#{templateId}
18 18
     </select>
19 19
 
20 20
     <select id="selectFatchRuleList" parameterType="FatchRule" resultMap="BaseResultMap">