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

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

hejinbo 2 лет назад
Родитель
Сommit
341be38f87

+ 56
- 6
ruoyi-common/src/main/java/com/ruoyi/common/utils/WordUtil.java Просмотреть файл

@@ -7,8 +7,14 @@ import com.deepoove.poi.data.*;
7 7
 import com.deepoove.poi.data.style.ParagraphStyle;
8 8
 import com.deepoove.poi.data.style.Style;
9 9
 import com.deepoove.poi.util.PoitlIOUtils;
10
-import org.apache.poi.xwpf.usermodel.ParagraphAlignment;
10
+import org.apache.poi.ss.usermodel.Cell;
11
+import org.apache.poi.ss.usermodel.CellType;
12
+import org.apache.poi.ss.usermodel.Row;
13
+import org.apache.poi.ss.usermodel.Sheet;
14
+import org.apache.poi.wp.usermodel.Paragraph;
15
+import org.apache.poi.xwpf.usermodel.*;
11 16
 
17
+import javax.print.Doc;
12 18
 import javax.servlet.http.HttpServletResponse;
13 19
 import java.io.BufferedOutputStream;
14 20
 import java.io.FileOutputStream;
@@ -93,7 +99,7 @@ public class WordUtil {
93 99
             style.setFontSize(12.0);
94 100
             ParagraphStyle paragraphStyle = ParagraphStyle.builder()
95 101
                     .withAlign(ParagraphAlignment.CENTER)
96
-                  //  .withBackgroundColor(headerBackgroundColor)
102
+                    //  .withBackgroundColor(headerBackgroundColor)
97 103
                     .withDefaultTextStyle(style)
98 104
                     .build();
99 105
             paragraphRenderData.addText(headerList.get(i));
@@ -139,18 +145,62 @@ public class WordUtil {
139 145
     public static PictureRenderData rebuildImageContent(Integer with, Integer height, String imageUrl, String relatedPath, Byte[] imageBytes) {
140 146
         PictureRenderData pictureRenderData = null;
141 147
         if (!StringUtils.isBlank(imageUrl)) {
142
-           // pictureRenderData = Pictures.of(imageUrl).size(with, height).create();
148
+            // pictureRenderData = Pictures.of(imageUrl).size(with, height).create();
143 149
             //Pictures.PictureBuilder pictureBuilder = Pictures.of("https://res.wx.qq.com/a/wx_fed/weixin_portal/res/static/img/1EtCRvm.png");
144
-        }else  if (!StringUtils.isBlank(relatedPath)) {
145
-            pictureRenderData = Pictures.ofLocal(relatedPath).size(with,height).create();
150
+        } else if (!StringUtils.isBlank(relatedPath)) {
151
+            pictureRenderData = Pictures.ofLocal(relatedPath).size(with, height).create();
146 152
 //            Pictures.PictureBuilder pictureBuilder = Pictures.of("https://res.wx.qq.com/a/wx_fed/weixin_portal/res/static/img/1EtCRvm.png");
147 153
         }
148 154
         return pictureRenderData;
149 155
     }
156
+
150 157
     public static String getResultFilePath(Map<String, Object> datas, Configure config, String modalFilePath, String resultFilePath) throws IOException {
151 158
         //获取word模板和填充数据
152
-        XWPFTemplate template = XWPFTemplate.compile(modalFilePath,config).render(datas);
159
+        XWPFTemplate template = XWPFTemplate.compile(modalFilePath, config).render(datas);
153 160
         template.writeAndClose(new FileOutputStream(resultFilePath));
154 161
         return resultFilePath;
155 162
     }
163
+
164
+    public static void changeText(XWPFDocument document) {
165
+        //获取文字段落集合
166
+        List<XWPFParagraph> paragraphs = document.getParagraphs();
167
+        //所有类型集合(文字段落、表格、图片等)
168
+        List<IBodyElement> listBe = document.getBodyElements();
169
+        List<Integer> runList = new ArrayList<>();
170
+        int n = 0;
171
+
172
+        for (int i = 0; i < listBe.size(); i++) {
173
+
174
+            //BodyElementType.PARAGRAPH : 枚举中的文字段落
175
+            //文字为空时,先添加到list中;
176
+            //注意picture类型也在PARAGRAPH中,需要校验embeddedPictures的长度是否为0
177
+            //为0表示空行,大于0表示有图片,可能还有其他类型,暂时没遇到,各位自行斟酌
178
+            if (paragraphs.size() > n && !paragraphs.get(n).getRuns().isEmpty()) {
179
+                if (StringUtils.isEmpty(paragraphs.get(n).getRuns().get(0).text())
180
+                        && paragraphs.get(n).getRuns().get(0).getEmbeddedPictures().size() == 0) {
181
+
182
+                    runList.add(i);
183
+
184
+                }
185
+            }
186
+            n++;
187
+
188
+            //非文字段落n-1
189
+            if (listBe.get(i).getElementType() != BodyElementType.PARAGRAPH) {
190
+                n--;
191
+            }
192
+
193
+        }
194
+
195
+        //遍历list删除
196
+        if (!runList.isEmpty()) {
197
+            for (int i = runList.size() - 1; i >= 0; i--) {
198
+                int index = runList.get(i);
199
+                if (index >= 0 && index < document.getBodyElements().size()) {
200
+                    document.removeBodyElement(index);
201
+                }
202
+            }
203
+        }
204
+    }
205
+
156 206
 }

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

@@ -2,15 +2,16 @@ package com.ruoyi.wisdomarbitrate.mapper;
2 2
 
3 3
 import com.ruoyi.wisdomarbitrate.domain.CaseApplication;
4 4
 import com.ruoyi.wisdomarbitrate.domain.CaseAttach;
5
-import com.ruoyi.wisdomarbitrate.domain.SealSignRecord;
5
+import org.apache.ibatis.annotations.Mapper;
6 6
 import org.apache.ibatis.annotations.Param;
7 7
 
8 8
 import java.util.List;
9 9
 
10
+@Mapper
10 11
 public interface CaseAttachMapper {
11 12
     int save(CaseAttach caseAttach);
12 13
 
13
-    List<CaseAttach> queryAnnexPathByCaseId(Long id);
14
+    List<CaseAttach>  queryAnnexPathByCaseId(Long id);
14 15
 
15 16
     List<CaseAttach> queryCaseAttachList(CaseApplication caseApplication);
16 17
 
@@ -20,4 +21,6 @@ public interface CaseAttachMapper {
20 21
     int updateCaseAttachBycaseid(CaseAttach caseAttach);
21 22
 
22 23
     int deleteByFileIds(@Param("ids") List<Integer> fileIds);
24
+
25
+    List<CaseAttach> getCaseAttachByCaseIdAndType(CaseAttach caseAttach);
23 26
 }

+ 29
- 17
ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/service/impl/AdjudicationServiceImpl.java Просмотреть файл

@@ -17,6 +17,9 @@ import com.ruoyi.wisdomarbitrate.service.IAdjudicationService;
17 17
 import com.ruoyi.wisdomarbitrate.service.ICaseApplicationService;
18 18
 import com.ruoyi.wisdomarbitrate.service.ICaseLogRecordService;
19 19
 import lombok.extern.slf4j.Slf4j;
20
+import org.apache.poi.ss.usermodel.Sheet;
21
+import org.apache.poi.xssf.usermodel.XSSFWorkbook;
22
+import org.apache.poi.xwpf.usermodel.XWPFDocument;
20 23
 import org.springframework.beans.factory.annotation.Autowired;
21 24
 import org.springframework.mail.MailSendException;
22 25
 import org.springframework.mail.javamail.JavaMailSender;
@@ -57,7 +60,6 @@ public class AdjudicationServiceImpl implements IAdjudicationService {
57 60
     private ICaseLogRecordService caseLogRecordService;
58 61
     @Autowired
59 62
     private RedisCache redisCache;
60
-
61 63
     @Autowired
62 64
     private SendMailRecordMapper sendMailRecordMapper;
63 65
 
@@ -160,7 +162,7 @@ public class AdjudicationServiceImpl implements IAdjudicationService {
160 162
             datas.put("arbitratorName", arbitratorName);
161 163
             Integer arbitratMethod = caseApplication1.getArbitratMethod();
162 164
             Date hearDate = caseApplication1.getHearDate();
163
-            if (hearDate!=null){
165
+            if (hearDate != null) {
164 166
                 String hearDateStr = sdf.format(hearDate);
165 167
                 //线上开庭时
166 168
                 if (arbitratMethod == 1) {
@@ -264,10 +266,10 @@ public class AdjudicationServiceImpl implements IAdjudicationService {
264 266
             datas.put("year", year);
265 267
             String month = String.format("%02d", now.getMonthValue());
266 268
             String day = String.format("%02d", now.getDayOfMonth());
267
-            String modalFilePath = "/data/arbitrate-document/template/新裁决书模板.docx";
268
-            //String modalFilePath = "D:/develop/新裁决书模板.docx";
269
-            String saveFolderPath = "/home/ruoyi/uploadPath/upload/" + year + "/" + month + "/" + day;
270
-            //String saveFolderPath = "D:/data/" + year + "/" + month + "/" + day;
269
+            //String modalFilePath = "/data/arbitrate-document/template/新裁决书模板.docx";
270
+            String modalFilePath = "D:/develop/新裁决书模板.docx";
271
+            //String saveFolderPath = "/home/ruoyi/uploadPath/upload/" + year + "/" + month + "/" + day;
272
+            String saveFolderPath = "D:/data/" + year + "/" + month + "/" + day;
271 273
             String fileName = UUID.randomUUID().toString().replace("-", "") + ".docx";
272 274
             String saveName = "/profile/upload/" + year + "/" + month + "/" + day + "/" + fileName;
273 275
             String resultFilePath = saveFolderPath + "/" + fileName;
@@ -280,24 +282,34 @@ public class AdjudicationServiceImpl implements IAdjudicationService {
280 282
             Path destinationPath = new File(resultFilePath).toPath();
281 283
             Files.copy(sourcePath, destinationPath, StandardCopyOption.REPLACE_EXISTING);
282 284
             String docFilePath = WordUtil.getDocFilePath(datas, modalFilePath, resultFilePath);
285
+            File file = new File(docFilePath);
286
+            if (file.exists()) {
287
+                InputStream in = new FileInputStream(file);
288
+                XWPFDocument xwpfDocument = new XWPFDocument(in);
289
+                WordUtil.changeText(xwpfDocument);
290
+            }
283 291
             String savePath = docFilePath.substring(0, docFilePath.indexOf("/upload/") + 8);
284
-            //修改案件状态
285
-            caseApplication1.setCaseStatus(CaseApplicationConstants.VERPRIF_ARBITRATION);
286
-            caseApplicationMapper.submitCaseApplication(caseApplication1);
287
-            //将裁决书保存到附件表里
288 292
             CaseAttach caseAttach = CaseAttach.builder()
289 293
                     .caseAppliId(id)
290 294
                     .annexName(saveName)
291 295
                     .annexPath(savePath)
292 296
                     .annexType(3)
293 297
                     .build();
294
-            int i = caseAttachMapper.save(caseAttach);
295
-            if (i > 0) {
296
-                if (arbitrateRecord1 != null) {
297
-                    Integer annexId = caseAttach.getAnnexId();
298
-                    //将附件id保存到仲裁记录表里面
299
-                    arbitrateRecord1.setAnnexId(annexId);
300
-                    arbitrateRecordMapper.updataArbitrateRecord(arbitrateRecord1);
298
+            //保存到附件表里,先判断之前有没有,有的话更新,没有的话新增
299
+            List<CaseAttach> caseAttachList = caseAttachMapper.getCaseAttachByCaseIdAndType(caseAttach);
300
+            if (caseAttachList != null ) {
301
+                //之前已经生成过了,更新
302
+                caseAttachMapper.updateCaseAttachBycaseid(caseAttach);
303
+            }else {
304
+                //之前没生成过,新增
305
+                int i = caseAttachMapper.save(caseAttach);
306
+                if (i > 0) {
307
+                    if (arbitrateRecord1 != null) {
308
+                        Integer annexId = caseAttach.getAnnexId();
309
+                        //将附件id保存到仲裁记录表里面
310
+                        arbitrateRecord1.setAnnexId(annexId);
311
+                        arbitrateRecordMapper.updataArbitrateRecord(arbitrateRecord1);
312
+                    }
301 313
                 }
302 314
             }
303 315
             return AjaxResult.success("裁决书已生成");

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

@@ -2073,7 +2073,6 @@ public class CaseApplicationServiceImpl implements ICaseApplicationService {
2073 2073
                 caseApplication.setFilearbitraUrl(filearbitraUrl);
2074 2074
             }
2075 2075
         }
2076
-
2077 2076
         return caseApplication;
2078 2077
     }
2079 2078
 

+ 357
- 27
ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/service/impl/CaseArbitrateServiceImpl.java Просмотреть файл

@@ -3,21 +3,27 @@ package com.ruoyi.wisdomarbitrate.service.impl;
3 3
 import cn.hutool.core.collection.CollectionUtil;
4 4
 import com.ruoyi.common.constant.CaseApplicationConstants;
5 5
 import com.ruoyi.common.core.domain.AjaxResult;
6
+import com.ruoyi.common.core.redis.RedisCache;
6 7
 import com.ruoyi.common.utils.WordUtil;
7 8
 import com.ruoyi.wisdomarbitrate.domain.*;
8 9
 import com.ruoyi.wisdomarbitrate.mapper.*;
10
+import com.ruoyi.wisdomarbitrate.service.IAdjudicationService;
9 11
 import com.ruoyi.wisdomarbitrate.utils.CaseLogUtils;
10 12
 import com.ruoyi.common.utils.SmsUtils;
11 13
 import com.ruoyi.wisdomarbitrate.service.ICaseArbitrateService;
14
+import org.apache.poi.xwpf.usermodel.XWPFDocument;
12 15
 import org.springframework.beans.factory.annotation.Autowired;
13 16
 import org.springframework.stereotype.Service;
14 17
 import org.springframework.transaction.annotation.Transactional;
15 18
 
16 19
 import java.io.File;
20
+import java.io.FileInputStream;
17 21
 import java.io.IOException;
22
+import java.io.InputStream;
18 23
 import java.nio.file.Files;
19 24
 import java.nio.file.Path;
20 25
 import java.nio.file.StandardCopyOption;
26
+import java.text.SimpleDateFormat;
21 27
 import java.time.LocalDate;
22 28
 import java.time.ZoneId;
23 29
 import java.util.*;
@@ -40,6 +46,10 @@ public class CaseArbitrateServiceImpl implements ICaseArbitrateService {
40 46
     private CaseAttachMapper caseAttachMapper;
41 47
     @Autowired
42 48
     private SmsRecordMapper smsRecordMapper;
49
+    @Autowired
50
+    private IAdjudicationService adjudicationService;
51
+    @Autowired
52
+    private RedisCache redisCache;
43 53
 
44 54
     @Override
45 55
     @Transactional
@@ -155,7 +165,6 @@ public class CaseArbitrateServiceImpl implements ICaseArbitrateService {
155 165
         } else {
156 166
             //提交仲裁结果
157 167
             int i = arbitrateRecordMapper.insertArbitrateRecord(arbitrateRecord);
158
-
159 168
             if (i > 0) {
160 169
                 //案件日志表里添加数据
161 170
                 CaseLogRecord caseLogRecord = new CaseLogRecord();
@@ -167,16 +176,50 @@ public class CaseArbitrateServiceImpl implements ICaseArbitrateService {
167 176
                 caseLogRecordMapper.insertCaseLogRecord(caseLogRecord);
168 177
                 // 新增日志
169 178
                 CaseLogUtils.insertCaseLog(caseApplication.getId(), CaseApplicationConstants.GENERATED_ARBITRATION, "");
179
+            }
180
+        }
181
+
170 182
 
183
+        //根据仲裁方式决定生成裁决书还是庭审笔录
184
+        Integer arbitratMethod = caseApplication1.getArbitratMethod();
185
+        if (arbitratMethod == 1) {
186
+            //开庭审理,需要生成裁决书和庭审笔录
187
+            Boolean aBoolean = generateTrialTranscripts(arbitrateRecord);
188
+            Boolean aBoolean1 = generateAward(arbitrateRecord);
189
+            if (aBoolean && aBoolean1) {
190
+                //修改案件状态
191
+                caseApplication1.setCaseStatus(CaseApplicationConstants.VERPRIF_ARBITRATION);
192
+                int i = caseApplicationMapper.submitCaseApplication(caseApplication1);
193
+                if (i > 0) {
194
+                    return AjaxResult.success("审理成功");
195
+                }
196
+            }
197
+        } else if (arbitratMethod == 2) {
198
+            //书面审理,只生成裁决书
199
+            Boolean aBoolean = generateAward(arbitrateRecord);
200
+            if (aBoolean) {
201
+                //修改案件状态
202
+                caseApplication1.setCaseStatus(CaseApplicationConstants.VERPRIF_ARBITRATION);
203
+                int i = caseApplicationMapper.submitCaseApplication(caseApplication1);
204
+                if (i > 0) {
205
+                    return AjaxResult.success("审理成功");
206
+                }
171 207
             }
208
+        } else {
209
+            return AjaxResult.error("请确认仲裁方式");
172 210
         }
211
+        return null;
212
+    }
173 213
 
174
-        //生成庭审笔录
214
+
215
+    //生成庭审笔录
216
+    private Boolean generateTrialTranscripts(ArbitrateRecord arbitrateRecord) {
175 217
         try {
176 218
             Map<String, Object> datas = new HashMap<>();
177
-            Long id = caseApplication.getId();
178
-
179
-
219
+            Long id = arbitrateRecord.getCaseAppliId();
220
+            CaseApplication caseApplication = new CaseApplication();
221
+            caseApplication.setId(id);
222
+            CaseApplication caseApplication1 = caseApplicationMapper.selectCaseApplication(caseApplication);
180 223
             //获取案件关联人信息
181 224
             CaseAffiliate caseAffiliate = new CaseAffiliate();
182 225
             caseAffiliate.setCaseAppliId(id);
@@ -200,10 +243,10 @@ public class CaseArbitrateServiceImpl implements ICaseArbitrateService {
200 243
                     }
201 244
                 }
202 245
             }
203
-            String arbitratorName = caseApplication.getArbitratorName();
204
-            datas.put("caseName", caseApplication.getCaseName());
246
+            String arbitratorName = caseApplication1.getArbitratorName();
247
+            datas.put("caseName", caseApplication1.getCaseName());
205 248
             datas.put("arbitratorName", arbitratorName);
206
-            Date hearDate = caseApplication.getHearDate();
249
+            Date hearDate = caseApplication1.getHearDate();
207 250
             if (hearDate != null) {
208 251
                 LocalDate localDate = hearDate.toInstant()
209 252
                         .atZone(ZoneId.systemDefault())
@@ -216,7 +259,7 @@ public class CaseArbitrateServiceImpl implements ICaseArbitrateService {
216 259
                 datas.put("hearMonths", null);
217 260
                 datas.put("hearDay", null);
218 261
             }
219
-            datas.put("appArbitrationClaims", caseApplication.getArbitratClaims());
262
+            datas.put("appArbitrationClaims", caseApplication1.getArbitratClaims());
220 263
             datas.put("evidenDetermi", arbitrateRecord.getEvidenDetermi());
221 264
             datas.put("factDetermi", arbitrateRecord.getFactDetermi());
222 265
             datas.put("caseSketch", arbitrateRecord.getCaseSketch());
@@ -231,9 +274,9 @@ public class CaseArbitrateServiceImpl implements ICaseArbitrateService {
231 274
             datas.put("months", month);
232 275
             datas.put("day", day);
233 276
             String modalFilePath = "/data/arbitrate-document/template/仲裁裁决书模板.docx";
234
-//            String modalFilePath = "D:/develop/仲裁裁决书模板 (2).docx";
277
+            //String modalFilePath = "D:/develop/仲裁裁决书模板 (2).docx";
235 278
             String saveFolderPath = "/home/ruoyi/uploadPath/upload/" + year + "/" + month + "/" + day;
236
-//            String saveFolderPath = "D:/data/" + now.getYear() + "/" + now.getMonthValue() + "/" + now.getDayOfMonth();
279
+            //String saveFolderPath = "D:/data/" + now.getYear() + "/" + now.getMonthValue() + "/" + now.getDayOfMonth();
237 280
             String fileName = UUID.randomUUID().toString().replace("-", "") + ".docx";
238 281
             String saveName = "/profile/upload/" + year + "/" + month + "/" + day + "/" + fileName;
239 282
             String resultFilePath = saveFolderPath + "/" + fileName;
@@ -247,34 +290,321 @@ public class CaseArbitrateServiceImpl implements ICaseArbitrateService {
247 290
             Files.copy(sourcePath, destinationPath, StandardCopyOption.REPLACE_EXISTING);
248 291
             String docFilePath = WordUtil.getDocFilePath(datas, modalFilePath, resultFilePath);
249 292
             String savePath = docFilePath.substring(0, docFilePath.indexOf("/upload/") + 8);
250
-
251
-            //修改案件状态
252
-            caseApplication1.setCaseStatus(CaseApplicationConstants.VERPRIF_ARBITRATION);
253
-            caseApplicationMapper.submitCaseApplication(caseApplication1);
254
-
255
-            //将裁决书保存到附件表里
256 293
             CaseAttach caseAttach = CaseAttach.builder()
257 294
                     .caseAppliId(id)
258 295
                     .annexName(saveName)
259 296
                     .annexPath(savePath)
260
-                    .annexType(3)
297
+                    .annexType(7)
261 298
                     .build();
262
-            int i = caseAttachMapper.save(caseAttach);
263
-            if (i > 0) {
264
-                if (arbitrateRecord1 != null) {
265
-                    Integer annexId = caseAttach.getAnnexId();
266
-                    //将附件id保存到仲裁记录表里面
267
-                    arbitrateRecord1.setAnnexId(annexId);
268
-                    arbitrateRecordMapper.updataArbitrateRecord(arbitrateRecord1);
299
+            //保存到附件表里,先判断之前有没有,有的话更新,没有的话新增
300
+            CaseAttach caseAttach1 = new CaseAttach();
301
+            caseAttach1.setAnnexType(7);
302
+            caseAttach1.setCaseAppliId(id);
303
+            List<CaseAttach> caseAttachList = caseAttachMapper.getCaseAttachByCaseIdAndType(caseAttach1);
304
+            if (caseAttachList != null && caseAttachList.size() > 0) {
305
+                //之前已经生成过了,更新
306
+                caseAttachMapper.updateCaseAttachBycaseid(caseAttach);
307
+            } else {
308
+                //之前没生成过,新增
309
+                int i = caseAttachMapper.save(caseAttach);
310
+                ArbitrateRecord arbitrateRecord1 = arbitrateRecordMapper.selectArbitrateRecord(arbitrateRecord);
311
+                if (i > 0) {
312
+                    if (arbitrateRecord1 != null) {
313
+                        Integer annexId = caseAttach.getAnnexId();
314
+                        //将附件id保存到仲裁记录表里面
315
+                        arbitrateRecord1.setAnnexId(annexId);
316
+                        arbitrateRecordMapper.updataArbitrateRecord(arbitrateRecord1);
317
+                    }
269 318
                 }
270 319
             }
271
-            return AjaxResult.success("裁决书已生成");
320
+            return Boolean.TRUE;
272 321
 
273 322
         } catch (IOException e) {
274 323
             e.printStackTrace();
275
-            return AjaxResult.error("裁决书生成异常");
324
+            return Boolean.FALSE;
276 325
         }
326
+    }
327
+
328
+    //生成仲裁文书
329
+    private Boolean generateAward(ArbitrateRecord arbitrateRecord) {
330
+        try {
331
+            Map<String, Object> datas = new HashMap<>();
332
+            Long id = arbitrateRecord.getCaseAppliId();
333
+            if (id == null) {
334
+                return null;
335
+            }
336
+            //获取案件详细信息
337
+            CaseApplication caseApplication = new CaseApplication();
338
+            caseApplication.setId(id);
339
+            CaseApplication caseApplication1 = caseApplicationMapper.selectCaseApplication(caseApplication);
340
+            //生成编码
341
+            String equipmentNo = getNewEquipmentNo();
342
+            datas.put("num", equipmentNo);
343
+            //获取仲裁记录表里的相关信息
344
+            ArbitrateRecord arbitrateRecord1 = arbitrateRecordMapper.selectArbitrateRecord(arbitrateRecord);
345
+            //获取案件关联人信息
346
+            CaseAffiliate caseAffiliate = new CaseAffiliate();
347
+            caseAffiliate.setCaseAppliId(id);
348
+            List<CaseAffiliate> caseAffiliates = caseAffiliateMapper.selectCaseAffiliate(caseAffiliate);
349
+            List<String> nameAgentList = new ArrayList<>();
350
+            if (caseAffiliates != null && caseAffiliates.size() > 0) {
351
+                for (CaseAffiliate affiliate : caseAffiliates) {
352
+                    //获取身份类型
353
+                    int identityType = affiliate.getIdentityType();
354
+                    if (identityType == 1) {    //申请人
355
+                        datas.put("appName", affiliate.getName());
356
+                        datas.put("appAddress", affiliate.getResidenAffili());
357
+                        datas.put("appContactAddress", affiliate.getContactAddress());
358
+                        datas.put("appLegalPerson", affiliate.getCompLegalPerson());
359
+                        datas.put("appLegalPersonTitle", affiliate.getCompLegalperPost());
360
+                        datas.put("appAgentName", affiliate.getNameAgent());
361
+                        datas.put("appAgentTitle", affiliate.getAppliAgentTitle());
362
+                        nameAgentList.add(affiliate.getNameAgent());
363
+                    } else if (identityType == 2) {  //被申请人
364
+                        datas.put("resName", affiliate.getName());
365
+                        datas.put("resAddress", affiliate.getResidenAffili());
366
+                        datas.put("resSex", affiliate.getResponSex());
367
+                        Date responBirth = affiliate.getResponBirth();
368
+                        if (responBirth != null) {
369
+                            SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
370
+                            String responBirthStr = sdf.format(responBirth);
371
+                            datas.put("resDateOfBirth", responBirthStr);
372
+
373
+                        }
277 374
 
375
+                        datas.put("resContactAddress", affiliate.getContactAddress());
376
+                        nameAgentList.add(affiliate.getNameAgent());
377
+                    }
378
+                }
379
+            }
380
+            Date createTime = caseApplication1.getCreateTime();
381
+            SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
382
+            // 将日期格式化为字符串
383
+            String createTimeStr = sdf.format(createTime);
384
+            datas.put("submissionDate", createTimeStr);
385
+            Date registerDate = caseApplication1.getRegisterDate();
386
+            String registerDateStr = sdf.format(registerDate);
387
+            datas.put("acceptDate", registerDateStr);
388
+            //反请求
389
+            Integer adjudicaCounter = caseApplication1.getAdjudicaCounter();
390
+            String counterclaim = "在《2022年版仲裁规则》第十八条第(一)项规定的期限内,被申请人向秘书处提交了" +
391
+                    "《仲裁反请求申请书》及证据材料。仲裁委依据《2022年版仲裁规则》第十八条的规定受理了该仲裁反请求案申请。" +
392
+                    "仲裁反请求案件受理后,秘书处向被申请人发送了仲裁反请求通知书及附件,向申请人发送了仲裁反请求通知书及附件、仲裁反请求申请书及附件。";
393
+            if (adjudicaCounter == null) {
394
+                datas.put("counterclaim", null);
395
+            } else if (adjudicaCounter == 1) {
396
+                datas.put("counterclaim", counterclaim);
397
+            } else {
398
+                datas.put("counterclaim", null);
399
+            }
400
+            //财产保全
401
+            Integer properPreser = caseApplication1.getProperPreser();
402
+            String preservation = "本案受理后,申请人向仲裁委提交了财产保全申请,仲裁委根据《中华人民共和国仲裁法》" +
403
+                    "第二十八条之规定,将该申请提交至法院。";
404
+            if (properPreser == null) {
405
+                datas.put("preservation", null);
406
+            } else if (properPreser == 1) {
407
+                datas.put("preservation", preservation);
408
+            } else {
409
+                datas.put("preservation", null);
410
+            }
411
+            //管辖权异议
412
+            Integer objectiJuris = caseApplication1.getObjectiJuris();
413
+            String jurisdictionalObjection = "本案受理后,被申请人向仲裁委提交了《XX管辖异议申请书》,认为XXXXXX" +
414
+                    ",仲裁委经审理,当庭驳回了被申请人的管辖异议申请,并告知被申请人具体的事实和理由将在裁决书中一并列明。";
415
+            if (objectiJuris == null) {
416
+                datas.put("jurisdictionalObjection", null);
417
+            } else if (objectiJuris == 1) {
418
+                datas.put("jurisdictionalObjection", jurisdictionalObjection);
419
+            } else {
420
+                datas.put("jurisdictionalObjection", null);
421
+            }
422
+            String arbitratorName = caseApplication1.getArbitratorName();
423
+            datas.put("arbitratorName", arbitratorName);
424
+            Integer arbitratMethod = caseApplication1.getArbitratMethod();
425
+            Date hearDate = caseApplication1.getHearDate();
426
+            if (hearDate != null) {
427
+                String hearDateStr = sdf.format(hearDate);
428
+                //线上开庭时
429
+                if (arbitratMethod == 1) {
430
+                    String onLine1 = "仲裁庭审阅了申请人提交的仲裁申请书、证据材料后,于";
431
+                    String onLine2 = "通过仲裁委智慧仲裁平台开庭审理了本案。";
432
+                    datas.put("onLine1", onLine1);
433
+                    datas.put("hearDate", hearDateStr);
434
+                    datas.put("onLine2", onLine2);
435
+                } else {
436
+                    //书面仲裁时
437
+                    String written1 = "仲裁庭审阅了申请人提交的仲裁申请书、证据材料后,于";
438
+                    String written2 = "在仲裁委所在地开庭审理了本案。";
439
+                    datas.put("written1", written1);
440
+                    datas.put("hearDate1", hearDateStr);
441
+                    datas.put("written2", written2);
442
+                }
443
+            }
444
+            Integer isAbsence = caseApplication1.getIsAbsence();
445
+            if (isAbsence == null) {
446
+                datas.put("absent1", null);
447
+                datas.put("absent2", null);
448
+                datas.put("absent3", null);
449
+                datas.put("absent4", null);
450
+                datas.put("absent5", null);
451
+                datas.put("attend1", null);
452
+                datas.put("attend2", null);
453
+                datas.put("attend3", null);
454
+                datas.put("attend4", null);
455
+                datas.put("attend5", null);
456
+                datas.put("attend6", null);
457
+                datas.put("attend7", null);
458
+                datas.put("appAgentName1", null);
459
+                datas.put("appAgentName2", null);
460
+                datas.put("resAgentName", null);
461
+            } else if (isAbsence == 1) {
462
+                //缺席审理
463
+                String absent1 = "申请人的特别授权委托代理人";
464
+                String absent2 = "出席了庭审。被申请人经依法送达开庭通知,无正当理由未出席庭审,故仲裁庭依据" +
465
+                        "《2022年版仲裁规则》第四十条第(二)项的规定,对本案进行了缺席审理。";
466
+                String absent3 = "庭审中,申请人陈述了仲裁请求事项及事实与理由,出示了证据材料并进行了说明," +
467
+                        "发表了意见,回答了仲裁庭的提问,并作了最后陈述。因被申请人缺席庭审,故仲裁庭无法组织调解。";
468
+                String absent4 = "(二/三)当事人提供的证据材料\n" +
469
+                        "申请人为证明其主张的事实和理由,向仲裁庭提交了如下证据材料:";
470
+                String absent5 = "综上,仲裁庭依据《上海仲裁委员会仲裁规则》(2022年7月1日起施行的版本)" +
471
+                        "第四十条第(二)项、第五十一条的规定,缺席裁决如下:";
472
+                datas.put("absent1", absent1);
473
+                datas.put("absent2", absent2);
474
+                datas.put("absent3", absent3);
475
+                datas.put("absent4", absent4);
476
+                datas.put("absent5", absent5);
477
+                datas.put("appAgentName1", nameAgentList.get(0));
478
+            } else {
479
+                //出席审理
480
+                String attend1 = "申请人的特别授权委托代理人";
481
+                String attend2 = "和被申请人本人/的特别授权委托代理人";
482
+                String attend3 = "出席了庭审。";
483
+                String attend4 = "庭审中,申请人陈述了仲裁请求事项及所依据的事实与理由,被申请人进行了答辩;" +
484
+                        "双方当事人均出示了证据材料并对对方的证据材料进行了质证;申请人出示了证据材料," +
485
+                        "被申请人对对方的证据材料进行了质证;双方当事人均回答了仲裁庭的提问,进行了辩论," +
486
+                        "并分别作了最后陈述。双方当事人在仲裁庭的主持下进行了调解,但未能达成调解协议。";
487
+                String attend5 = "(二)被申请人的答辩意见";
488
+                String attend6 = "(二/三)当事人提供的证据材料及对方的质证意见\n" +
489
+                        "申请人为证明其主张的事实和理由,向仲裁庭提交了如下证据材料:";
490
+                String attend7 = "被申请人对上述材料的质证意见为:";
491
+                datas.put("attend1", attend1);
492
+                datas.put("attend2", attend2);
493
+                datas.put("attend3", attend3);
494
+                datas.put("attend4", attend4);
495
+                datas.put("attend5", attend5);
496
+                datas.put("attend6", attend6);
497
+                datas.put("attend7", attend7);
498
+                datas.put("responCrossOpin", caseApplication1.getResponCrossOpin());
499
+                datas.put("appAgentName2", nameAgentList.get(0));
500
+                datas.put("resAgentName", nameAgentList.get(1));
501
+                if (arbitratMethod == 1) {
502
+                    //被申出席+开庭
503
+                    String attend8 = "综上,仲裁庭依据《上海仲裁委员会仲裁规则》(2022年7月1日起施行的版本)" +
504
+                            "第五十一条的规定,裁决如下:";
505
+                    datas.put("attend8", attend8);
506
+                } else {
507
+                    //被申出席+书面
508
+                    String attend9 = "综上,仲裁庭依据《上海仲裁委员会仲裁规则》(2022年7月1日起施行的版本)" +
509
+                            "第五十一条、第五十八条的规定,裁决如下:";
510
+                    datas.put("attend9", attend9);
511
+                }
512
+            }
513
+            datas.put("claims", caseApplication1.getArbitratClaims());
514
+            datas.put("request", caseApplication1.getRequestRule());
515
+            //申请人证据材料
516
+            datas.put("appEvidenceMaterial", null);
517
+            //被申请人证据材料
518
+            datas.put("resEvidenceMaterial", null);
519
+            datas.put("applicaCrossOpin", caseApplication1.getApplicaCrossOpin());
520
+            if (arbitrateRecord1 != null) {
521
+                datas.put("factDetermi", arbitrateRecord1.getFactDetermi());
522
+                datas.put("arbitrateThink", arbitrateRecord1.getArbitrateThink());
523
+                datas.put("rulingFollows", arbitrateRecord1.getRulingFollows());
524
+            }
525
+            LocalDate now = LocalDate.now();
526
+            String year = Integer.toString(now.getYear());
527
+            datas.put("year", year);
528
+            String month = String.format("%02d", now.getMonthValue());
529
+            String day = String.format("%02d", now.getDayOfMonth());
530
+            String modalFilePath = "/data/arbitrate-document/template/新裁决书模板.docx";
531
+            //String modalFilePath = "D:/develop/新裁决书模板.docx";
532
+            String saveFolderPath = "/home/ruoyi/uploadPath/upload/" + year + "/" + month + "/" + day;
533
+            //String saveFolderPath = "D:/data/" + year + "/" + month + "/" + day;
534
+            String fileName = UUID.randomUUID().toString().replace("-", "") + ".docx";
535
+            String saveName = "/profile/upload/" + year + "/" + month + "/" + day + "/" + fileName;
536
+            String resultFilePath = saveFolderPath + "/" + fileName;
537
+            // 创建日期目录
538
+            File saveFolder = new File(saveFolderPath);
539
+            if (!saveFolder.exists()) {
540
+                saveFolder.mkdirs();
541
+            }
542
+            Path sourcePath = new File(modalFilePath).toPath();
543
+            Path destinationPath = new File(resultFilePath).toPath();
544
+            Files.copy(sourcePath, destinationPath, StandardCopyOption.REPLACE_EXISTING);
545
+            String docFilePath = WordUtil.getDocFilePath(datas, modalFilePath, resultFilePath);
546
+            File file = new File(docFilePath);
547
+            if (file.exists()) {
548
+                InputStream in = new FileInputStream(file);
549
+                XWPFDocument xwpfDocument = new XWPFDocument(in);
550
+                WordUtil.changeText(xwpfDocument);
551
+            }
552
+            String savePath = docFilePath.substring(0, docFilePath.indexOf("/upload/") + 8);
553
+            CaseAttach caseAttach = CaseAttach.builder()
554
+                    .caseAppliId(id)
555
+                    .annexName(saveName)
556
+                    .annexPath(savePath)
557
+                    .annexType(3)
558
+                    .build();
559
+            //保存到附件表里,先判断之前有没有,有的话更新,没有的话新增
560
+            CaseAttach caseAttach1 = new CaseAttach();
561
+            caseAttach1.setAnnexType(3);
562
+            caseAttach1.setCaseAppliId(id);
563
+            List<CaseAttach> caseAttachList = caseAttachMapper.getCaseAttachByCaseIdAndType(caseAttach1);
564
+            if (caseAttachList != null && caseAttachList.size() > 0) {
565
+                //之前已经生成过了,更新
566
+                caseAttachMapper.updateCaseAttachBycaseid(caseAttach);
567
+            } else {
568
+                //之前没生成过,新增
569
+                int i = caseAttachMapper.save(caseAttach);
570
+                if (i > 0) {
571
+                    if (arbitrateRecord1 != null) {
572
+                        Integer annexId = caseAttach.getAnnexId();
573
+                        //将附件id保存到仲裁记录表里面
574
+                        arbitrateRecord1.setAnnexId(annexId);
575
+                        arbitrateRecordMapper.updataArbitrateRecord(arbitrateRecord1);
576
+                    }
577
+                }
578
+            }
579
+            return Boolean.TRUE;
580
+        } catch (IOException e) {
581
+            return Boolean.FALSE;
582
+        }
583
+    }
278 584
 
585
+    public String getNewEquipmentNo() {
586
+        Object awardNum = redisCache.getCacheObject("awardNum");
587
+        if (awardNum == null) {
588
+            redisCache.setCacheObject("awardNum", "00001");
589
+            String s = redisCache.getCacheObject("awardNum").toString();
590
+            // 字符串数字解析为整数
591
+            int no = Integer.parseInt(s);
592
+            // 最新设备编号自增1
593
+            int newEquipment = ++no;
594
+            // 将整数格式化为5位数字
595
+            s = String.format("%05d", newEquipment);
596
+            redisCache.setCacheObject("awardNum", s);
597
+            return s;
598
+        } else {
599
+            String s = awardNum.toString();
600
+            // 字符串数字解析为整数
601
+            int no = Integer.parseInt(s);
602
+            // 最新设备编号自增1
603
+            int newEquipment = ++no;
604
+            // 将整数格式化为5位数字
605
+            s = String.format("%05d", newEquipment);
606
+            redisCache.setCacheObject("awardNum", s);
607
+            return s;
608
+        }
279 609
     }
280 610
 }

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

@@ -0,0 +1,37 @@
1
+package com.ruoyi.wisdomarbitrate.utils;
2
+
3
+import java.io.BufferedInputStream;
4
+import java.io.FileOutputStream;
5
+import java.io.IOException;
6
+import java.io.InputStream;
7
+import java.net.URL;
8
+
9
+public class MyTest {
10
+    public static void download(String fileUrl, String saveFilePath) throws IOException {
11
+        URL url = new URL(fileUrl);
12
+        InputStream inputStream = url.openStream();
13
+        BufferedInputStream bufferedInputStream = new BufferedInputStream(inputStream);
14
+        FileOutputStream fileOutputStream = new FileOutputStream(saveFilePath);
15
+
16
+        byte[] buffer = new byte[1024];
17
+        int bytesRead = 0;
18
+        while ((bytesRead = bufferedInputStream.read(buffer, 0, buffer.length)) != -1) {
19
+            fileOutputStream.write(buffer, 0, bytesRead);
20
+        }
21
+
22
+        fileOutputStream.close();
23
+        bufferedInputStream.close();
24
+        inputStream.close();
25
+    }
26
+
27
+    public static void main(String[] args) {
28
+        String fileUrl = "https://esignoss.esign.cn/1111563786/0e16cc53-fe2e-403b-b901-587778a8ea92/3ed8f1b0bd2640e895fcfbaffdec0a1e.pdf?Expires=1698742492&OSSAccessKeyId=LTAI4G23YViiKnxTC28ygQzF&Signature=K%2Bb5k7DqNmaxeu%2Fct5qis4qor7s%3D";
29
+        String saveFilePath = "D:\\home\\example.pdf";
30
+        try {
31
+            download(fileUrl, saveFilePath);
32
+            System.out.println("File downloaded successfully.");
33
+        } catch (IOException e) {
34
+            e.printStackTrace();
35
+        }
36
+    }
37
+}

+ 13
- 0
ruoyi-system/src/main/resources/mapper/wisdomarbitrate/CaseAttachMapper.xml Просмотреть файл

@@ -31,6 +31,19 @@
31 31
         where case_appli_id =#{id}
32 32
     </select>
33 33
 
34
+    <select id="getCaseAttachByCaseIdAndType" resultType="com.ruoyi.wisdomarbitrate.domain.CaseAttach" resultMap="CaseAttachResult">
35
+        select annex_id,case_appli_id,annex_name,annex_path,annex_type,note,use_id,use_account
36
+        from case_attach
37
+        <where>
38
+            <if test="caseAppliId != null ">
39
+                AND case_appli_id = #{caseAppliId}
40
+            </if>
41
+            <if test="annexType != null ">
42
+                AND annex_type = #{annexType}
43
+            </if>
44
+        </where>
45
+    </select>
46
+
34 47
     <select id="queryCaseAttachList" resultMap="CaseAttachResult">
35 48
         select annex_id,case_appli_id,annex_name,annex_path,annex_type,note,use_id,use_account
36 49
         from case_attach