|
|
@@ -3,33 +3,43 @@ package com.ruoyi.wisdomarbitrate.service.mscase.impl;
|
|
3
|
3
|
import cn.hutool.core.bean.BeanUtil;
|
|
4
|
4
|
import cn.hutool.core.collection.CollectionUtil;
|
|
5
|
5
|
import cn.hutool.core.util.StrUtil;
|
|
|
6
|
+import com.ruoyi.common.config.RuoYiConfig;
|
|
6
|
7
|
import com.ruoyi.common.core.domain.AjaxResult;
|
|
7
|
8
|
import com.ruoyi.common.core.domain.entity.SysDept;
|
|
8
|
9
|
import com.ruoyi.common.core.domain.entity.SysDictData;
|
|
9
|
10
|
import com.ruoyi.common.core.domain.entity.SysRole;
|
|
10
|
11
|
import com.ruoyi.common.core.domain.entity.SysUser;
|
|
11
|
12
|
import com.ruoyi.common.core.domain.model.LoginUser;
|
|
|
13
|
+import com.ruoyi.common.enums.AnnexTypeEnum;
|
|
|
14
|
+import com.ruoyi.common.enums.YesOrNoEnum;
|
|
12
|
15
|
import com.ruoyi.common.exception.ServiceException;
|
|
13
|
16
|
import com.ruoyi.common.utils.*;
|
|
|
17
|
+import com.ruoyi.common.utils.file.FileUploadUtils;
|
|
14
|
18
|
import com.ruoyi.system.domain.entity.flow.MsCaseFlow;
|
|
15
|
19
|
import com.ruoyi.system.domain.entity.flow.MsCaseFlowRoleRelated;
|
|
16
|
20
|
import com.ruoyi.system.mapper.*;
|
|
17
|
21
|
import com.ruoyi.system.mapper.flow.MsCaseFlowMapper;
|
|
18
|
22
|
import com.ruoyi.system.mapper.flow.MsCaseFlowRoleRelatedMapper;
|
|
|
23
|
+import com.ruoyi.wisdomarbitrate.domain.dto.sendrecord.SmsSendRecord;
|
|
19
|
24
|
import com.ruoyi.wisdomarbitrate.domain.dto.template.FatchRule;
|
|
|
25
|
+import com.ruoyi.wisdomarbitrate.domain.dto.template.TemplateManage;
|
|
20
|
26
|
import com.ruoyi.wisdomarbitrate.domain.entity.mscase.MsCaseAffiliate;
|
|
21
|
27
|
import com.ruoyi.wisdomarbitrate.domain.entity.mscase.MsCaseApplication;
|
|
22
|
28
|
import com.ruoyi.wisdomarbitrate.domain.entity.mscase.MsCaseAttach;
|
|
|
29
|
+import com.ruoyi.wisdomarbitrate.domain.vo.mscase.MediatorVO;
|
|
23
|
30
|
import com.ruoyi.wisdomarbitrate.domain.vo.mscase.MsCaseApplicationReq;
|
|
24
|
31
|
import com.ruoyi.wisdomarbitrate.domain.vo.mscase.MsCaseApplicationVO;
|
|
25
|
32
|
import com.ruoyi.wisdomarbitrate.domain.vo.mscase.MsColumnValueVO;
|
|
26
|
33
|
import com.ruoyi.wisdomarbitrate.mapper.mscase.*;
|
|
|
34
|
+import com.ruoyi.wisdomarbitrate.mapper.sendrecord.SmsRecordMapper;
|
|
27
|
35
|
import com.ruoyi.wisdomarbitrate.mapper.template.FatchRuleMapper;
|
|
|
36
|
+import com.ruoyi.wisdomarbitrate.mapper.template.TemplateManageMapper;
|
|
28
|
37
|
import com.ruoyi.wisdomarbitrate.service.mscase.MsCaseApplicationService;
|
|
29
|
38
|
import com.ruoyi.wisdomarbitrate.utils.CaseLogUtils;
|
|
30
|
39
|
import com.ruoyi.wisdomarbitrate.utils.OCRUtils;
|
|
31
|
40
|
import com.ruoyi.wisdomarbitrate.utils.UnZipFileUtils;
|
|
32
|
41
|
import org.apache.pdfbox.pdmodel.PDDocument;
|
|
|
42
|
+import org.apache.poi.xwpf.usermodel.XWPFDocument;
|
|
33
|
43
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
34
|
44
|
import org.springframework.stereotype.Service;
|
|
35
|
45
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
@@ -39,10 +49,17 @@ import tk.mybatis.mapper.entity.Example;
|
|
39
|
49
|
import java.io.*;
|
|
40
|
50
|
import java.math.BigDecimal;
|
|
41
|
51
|
import java.math.RoundingMode;
|
|
|
52
|
+import java.nio.file.Files;
|
|
|
53
|
+import java.nio.file.Path;
|
|
|
54
|
+import java.nio.file.StandardCopyOption;
|
|
42
|
55
|
import java.text.SimpleDateFormat;
|
|
|
56
|
+import java.time.LocalDate;
|
|
|
57
|
+import java.time.format.DateTimeFormatter;
|
|
43
|
58
|
import java.util.*;
|
|
|
59
|
+import java.util.function.Function;
|
|
44
|
60
|
import java.util.stream.Collectors;
|
|
45
|
61
|
|
|
|
62
|
+import static com.ruoyi.common.utils.BookMarkUtil.getBookmarkByDocx;
|
|
46
|
63
|
import static com.ruoyi.common.utils.SecurityUtils.getUsername;
|
|
47
|
64
|
|
|
48
|
65
|
/**
|
|
|
@@ -86,6 +103,10 @@ public class MsCaseApplicationServiceImpl implements MsCaseApplicationService {
|
|
86
|
103
|
FatchRuleMapper fatchRuleMapper;
|
|
87
|
104
|
@Autowired
|
|
88
|
105
|
SysDictDataMapper dictDataMapper;
|
|
|
106
|
+ @Autowired
|
|
|
107
|
+ TemplateManageMapper templateManageMapper;
|
|
|
108
|
+ @Autowired
|
|
|
109
|
+ private SmsRecordMapper smsRecordMapper;
|
|
89
|
110
|
// 案件基本字段
|
|
90
|
111
|
public static final List<String> CASE_BASE_COLUMN = Arrays.asList("caseSubjectAmount", "arbitratClaims", "facts", "requestRule");
|
|
91
|
112
|
public static final SimpleDateFormat yyyymmddFormat = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
@@ -233,11 +254,16 @@ public class MsCaseApplicationServiceImpl implements MsCaseApplicationService {
|
|
233
|
254
|
}
|
|
234
|
255
|
// 保存案件附件
|
|
235
|
256
|
|
|
236
|
|
- if (CollectionUtil.isNotEmpty(caseAttachList) && !caseApplication.isImportFlag()) {
|
|
|
257
|
+ if (CollectionUtil.isNotEmpty(caseAttachList)) {
|
|
237
|
258
|
for (MsCaseAttach caseAttach : caseAttachList) {
|
|
238
|
259
|
caseAttach.setCaseAppliId(caseApplication.getId());
|
|
|
260
|
+ }
|
|
|
261
|
+ if(!caseApplication.isImportFlag()) {
|
|
239
|
262
|
// 修改案件附件
|
|
240
|
|
- msCaseAttachMapper.updateCaseAttach(caseAttach);
|
|
|
263
|
+ msCaseAttachMapper.batchUpdate(caseAttachList);
|
|
|
264
|
+ }else {
|
|
|
265
|
+ // 压缩包导入保存附件
|
|
|
266
|
+ msCaseAttachMapper.batchSave(caseAttachList);
|
|
241
|
267
|
}
|
|
242
|
268
|
}
|
|
243
|
269
|
List<MsColumnValueVO> columnValueList = caseApplication.getColumnValueList();
|
|
|
@@ -373,8 +399,9 @@ public class MsCaseApplicationServiceImpl implements MsCaseApplicationService {
|
|
373
|
399
|
}
|
|
374
|
400
|
//查询批次号
|
|
375
|
401
|
String batchNumber = getBatchNumber();
|
|
376
|
|
- // 抓取内容
|
|
377
|
|
- Map<String, String> fatchMap = new HashMap<>();
|
|
|
402
|
+ // 案件数量
|
|
|
403
|
+ int caseCount = 0;
|
|
|
404
|
+
|
|
378
|
405
|
for (File outFile : files) {
|
|
379
|
406
|
if (!outFile.isDirectory() || outFile.listFiles() == null) {
|
|
380
|
407
|
continue;
|
|
|
@@ -384,6 +411,8 @@ public class MsCaseApplicationServiceImpl implements MsCaseApplicationService {
|
|
384
|
411
|
// 所有的文件,fileMap<fileName,filePath>
|
|
385
|
412
|
Map<String, String> fileMap = findFile(inFile);
|
|
386
|
413
|
if (fileMap != null && !fileMap.isEmpty()) {
|
|
|
414
|
+ // 抓取内容
|
|
|
415
|
+ Map<String, String> fatchMap = new HashMap<>();
|
|
387
|
416
|
// 根据抓取规则设置字段值
|
|
388
|
417
|
for (Map.Entry<String, List<FatchRule>> entry : fatchRuleMap.entrySet()) {
|
|
389
|
418
|
getFatchContent(fileMap, entry.getKey(), fatchMap, entry.getValue());
|
|
|
@@ -429,15 +458,406 @@ public class MsCaseApplicationServiceImpl implements MsCaseApplicationService {
|
|
429
|
458
|
caseApplicationVO.setColumnValueList(columnValueList);
|
|
430
|
459
|
caseApplicationVO.setImportFlag(true);
|
|
431
|
460
|
insert(caseApplicationVO);
|
|
|
461
|
+ caseCount++;
|
|
432
|
462
|
|
|
433
|
463
|
}
|
|
434
|
464
|
}
|
|
435
|
465
|
}
|
|
436
|
466
|
|
|
437
|
467
|
}
|
|
438
|
|
- return AjaxResult.success();
|
|
|
468
|
+ if(caseCount>0) {
|
|
|
469
|
+ return AjaxResult.success();
|
|
|
470
|
+ }else {
|
|
|
471
|
+ return AjaxResult.error("请检查压缩包!");
|
|
|
472
|
+ }
|
|
|
473
|
+ }
|
|
|
474
|
+
|
|
|
475
|
+ /**
|
|
|
476
|
+ * 生成调解申请书
|
|
|
477
|
+ * @param req
|
|
|
478
|
+ * @return
|
|
|
479
|
+ */
|
|
|
480
|
+ @Override
|
|
|
481
|
+ public AjaxResult generateApplication(MsCaseApplicationReq req) {
|
|
|
482
|
+ // 根据模板id查询申请书
|
|
|
483
|
+ TemplateManage templateManage=templateManageMapper.selectById(req.getTemplateId());
|
|
|
484
|
+ if(templateManage==null||StrUtil.isEmpty(templateManage.getTemOrigPath())){
|
|
|
485
|
+ return AjaxResult.error("未找到调解申请书模板");
|
|
|
486
|
+ }
|
|
|
487
|
+ String templatePath = templateManage.getTemOrigPath();
|
|
|
488
|
+ try {
|
|
|
489
|
+ File file = new File(templatePath);
|
|
|
490
|
+ } catch (Exception e) {
|
|
|
491
|
+ return AjaxResult.error("未找到调解申请书模板");
|
|
|
492
|
+ }
|
|
|
493
|
+
|
|
|
494
|
+ // 获取模板中的占位符key
|
|
|
495
|
+ List<String> bookmarkList = getBookmarkByDocx(templatePath);
|
|
|
496
|
+ if (CollectionUtil.isEmpty(bookmarkList)) {
|
|
|
497
|
+ return AjaxResult.success("请检查模板是否配置正确,未获取到占位符");
|
|
|
498
|
+ }
|
|
|
499
|
+ // 在系统表中查询案件内置字段
|
|
|
500
|
+ SysDictData sysDictData = new SysDictData();
|
|
|
501
|
+ sysDictData.setDictType("case_built_type");
|
|
|
502
|
+ List<SysDictData> dictDataList = dictDataMapper.selectDictDataList(sysDictData);
|
|
|
503
|
+ if(CollectionUtil.isEmpty(dictDataList)){
|
|
|
504
|
+ return AjaxResult.error("未找到系统内置字段");
|
|
|
505
|
+ }
|
|
|
506
|
+ // 如果批号不为空,则为批量操作,根据批号查询未锁定的案件
|
|
|
507
|
+ if(StrUtil.isNotEmpty(req.getBatchNumber())){
|
|
|
508
|
+ List<MsCaseApplication> caseApplicationList=listByBatchNumber(req.getBatchNumber(),req.getCaseFlowId());
|
|
|
509
|
+ if(CollectionUtil.isEmpty(caseApplicationList)){
|
|
|
510
|
+ return AjaxResult.error("该批次号下未找到案件");
|
|
|
511
|
+ }
|
|
|
512
|
+ // 案件ids
|
|
|
513
|
+ List<Long> caseIds = caseApplicationList.stream().map(MsCaseApplication::getId).collect(Collectors.toList());
|
|
|
514
|
+ // 根据ids查询案件关联人员
|
|
|
515
|
+ Example afflicateExample = new Example(MsCaseFlow.class);
|
|
|
516
|
+ afflicateExample.createCriteria().andIn("case_appli_id", caseIds);
|
|
|
517
|
+ List<MsCaseAffiliate> affiliateList = msCaseAffiliateMapper.selectByExample(caseIds);
|
|
|
518
|
+ if(CollectionUtil.isEmpty(affiliateList)){
|
|
|
519
|
+ return AjaxResult.error("该批次号下未找到案件关联人员");
|
|
|
520
|
+ }
|
|
|
521
|
+
|
|
|
522
|
+ Map<Long, MsCaseAffiliate> affiliateMap = affiliateList.stream().collect(Collectors.toMap(MsCaseAffiliate::getCaseAppliId, Function.identity()));
|
|
|
523
|
+
|
|
|
524
|
+ // 循环生成调解申请书
|
|
|
525
|
+ for (MsCaseApplication application : caseApplicationList) {
|
|
|
526
|
+
|
|
|
527
|
+ // 案件相关人员
|
|
|
528
|
+ MsCaseAffiliate affiliate = affiliateMap.get(application.getId());
|
|
|
529
|
+ if(affiliate==null){
|
|
|
530
|
+ continue;
|
|
|
531
|
+ }
|
|
|
532
|
+ createMediateApplication(application, affiliate, templatePath, bookmarkList,dictDataList);
|
|
|
533
|
+
|
|
|
534
|
+ }
|
|
|
535
|
+ }else {
|
|
|
536
|
+ // 单独生成调解申请书
|
|
|
537
|
+ // 根据案件id查询案件信息
|
|
|
538
|
+ MsCaseApplication application = msCaseApplicationMapper.selectByPrimaryKey(req.getId());
|
|
|
539
|
+ // 查询案件关联人员
|
|
|
540
|
+ MsCaseAffiliate caseAffiliate = msCaseAffiliateMapper.selectByPrimaryKey(req.getId());
|
|
|
541
|
+ if (application == null || caseAffiliate == null) {
|
|
|
542
|
+ return AjaxResult.error("该案件不存在");
|
|
|
543
|
+ }
|
|
|
544
|
+ createMediateApplication(application, caseAffiliate, templatePath, bookmarkList,dictDataList);
|
|
|
545
|
+ }
|
|
|
546
|
+
|
|
|
547
|
+
|
|
|
548
|
+ return AjaxResult.success("调解申请书生成成功");
|
|
|
549
|
+ }
|
|
|
550
|
+
|
|
|
551
|
+ public List<MsCaseApplication> listByBatchNumber(String batchNumber,Integer caseFlowId) {
|
|
|
552
|
+ Example example = new Example(MsCaseFlow.class);
|
|
|
553
|
+ example.createCriteria().andEqualTo("batch_number", batchNumber);
|
|
|
554
|
+ example.createCriteria().andEqualTo("lock_status", 0);
|
|
|
555
|
+ if(caseFlowId!=null){
|
|
|
556
|
+ example.createCriteria().andEqualTo("case_flow_id",caseFlowId);
|
|
|
557
|
+ }
|
|
|
558
|
+ return msCaseApplicationMapper.selectByExample(example);
|
|
|
559
|
+
|
|
439
|
560
|
}
|
|
440
|
561
|
|
|
|
562
|
+ @Override
|
|
|
563
|
+ public AjaxResult batchUpdateAttach(MsCaseApplicationVO req) {
|
|
|
564
|
+ for (MsCaseAttach attach : req.getCaseAttachList()) {
|
|
|
565
|
+ attach.setCaseAppliId(req.getId());
|
|
|
566
|
+ msCaseAttachMapper.updateCaseAttach(attach);
|
|
|
567
|
+ }
|
|
|
568
|
+ return null;
|
|
|
569
|
+ }
|
|
|
570
|
+
|
|
|
571
|
+ @Override
|
|
|
572
|
+ public AjaxResult batchUpload(MultipartFile[] files, Integer annexType, Long id) {
|
|
|
573
|
+ List<MsCaseAttach> successList = new ArrayList<>();
|
|
|
574
|
+ try {
|
|
|
575
|
+ String filePath = RuoYiConfig.getUploadPath();
|
|
|
576
|
+ for (MultipartFile file : files) {
|
|
|
577
|
+ // 上传
|
|
|
578
|
+ String path = FileUploadUtils.upload(filePath, file);
|
|
|
579
|
+ MsCaseAttach caseAttach = MsCaseAttach.builder().caseAppliId(id)
|
|
|
580
|
+ .annexName(file.getOriginalFilename())
|
|
|
581
|
+ .annexPath(path)
|
|
|
582
|
+ .annexType(annexType)
|
|
|
583
|
+ .useId(SecurityUtils.getUserId())
|
|
|
584
|
+ .useAccount(SecurityUtils.getUsername())
|
|
|
585
|
+ .isBatchUpload(1L)
|
|
|
586
|
+ .build();
|
|
|
587
|
+ int count = msCaseAttachMapper.save(caseAttach);
|
|
|
588
|
+ if (count > 0 ) {
|
|
|
589
|
+ MsCaseAttach caseAttachselect = new MsCaseAttach();
|
|
|
590
|
+ caseAttachselect.setAnnexId(caseAttach.getAnnexId());
|
|
|
591
|
+ caseAttachselect.setAnnexName(caseAttach.getAnnexName());
|
|
|
592
|
+ caseAttachselect.setAnnexType(caseAttach.getAnnexType());
|
|
|
593
|
+ successList.add(caseAttachselect);
|
|
|
594
|
+ }
|
|
|
595
|
+ }
|
|
|
596
|
+
|
|
|
597
|
+
|
|
|
598
|
+ } catch (IOException e) {
|
|
|
599
|
+ e.printStackTrace();
|
|
|
600
|
+ return AjaxResult.error("上传失败");
|
|
|
601
|
+ }
|
|
|
602
|
+ return AjaxResult.success("上传成功", successList);
|
|
|
603
|
+ }
|
|
|
604
|
+
|
|
|
605
|
+ /**
|
|
|
606
|
+ * 案件受理
|
|
|
607
|
+ * @param req
|
|
|
608
|
+ * @return
|
|
|
609
|
+ */
|
|
|
610
|
+ @Override
|
|
|
611
|
+ public AjaxResult accept(MsCaseApplication req) {
|
|
|
612
|
+ if (StrUtil.isNotEmpty(req.getBatchNumber())) {
|
|
|
613
|
+ // 根据批号查询未锁定的案件
|
|
|
614
|
+ List<MsCaseApplication> applicationList = listByBatchNumber(req.getBatchNumber(), req.getCaseFlowId());
|
|
|
615
|
+ if (CollectionUtil.isEmpty(applicationList)) {
|
|
|
616
|
+ return AjaxResult.error("该批次号下未找到案件");
|
|
|
617
|
+ }
|
|
|
618
|
+ // 查询案件关联人员
|
|
|
619
|
+ Example example = new Example(MsCaseAffiliate.class);
|
|
|
620
|
+ example.createCriteria().andIn("case_appli_id", applicationList.stream().map(MsCaseApplication::getId).collect(Collectors.toList()));
|
|
|
621
|
+ List<MsCaseAffiliate> affiliateList = msCaseAffiliateMapper.selectByExample(example);
|
|
|
622
|
+ if (CollectionUtil.isEmpty(affiliateList)) {
|
|
|
623
|
+ return AjaxResult.error("该批次号下未找到案件");
|
|
|
624
|
+ }
|
|
|
625
|
+ Map<Long, MsCaseAffiliate> affiliateMap = affiliateList.stream().collect(Collectors.toMap(MsCaseAffiliate::getCaseAppliId, Function.identity()));
|
|
|
626
|
+ for (MsCaseApplication application : applicationList) {
|
|
|
627
|
+ accept(application,req,affiliateMap);
|
|
|
628
|
+ }
|
|
|
629
|
+
|
|
|
630
|
+ } else {
|
|
|
631
|
+ // 根据案件id查询案件相关人
|
|
|
632
|
+ MsCaseAffiliate caseAffiliate = msCaseAffiliateMapper.selectByPrimaryKey(req.getId());
|
|
|
633
|
+ if (caseAffiliate == null) {
|
|
|
634
|
+ return AjaxResult.error("该案件不存在");
|
|
|
635
|
+ }
|
|
|
636
|
+ // 锁定该案件
|
|
|
637
|
+ req.setLockStatus(YesOrNoEnum.YES.getCode());
|
|
|
638
|
+ Map<Long, MsCaseAffiliate> affiliateMap=new HashMap<>();
|
|
|
639
|
+ affiliateMap.put(req.getId(),caseAffiliate);
|
|
|
640
|
+ accept(req,req,affiliateMap);
|
|
|
641
|
+ }
|
|
|
642
|
+
|
|
|
643
|
+ return AjaxResult.success("受理成功");
|
|
|
644
|
+ }
|
|
|
645
|
+
|
|
|
646
|
+ /**
|
|
|
647
|
+ * 案件提交
|
|
|
648
|
+ * @param req
|
|
|
649
|
+ * @return
|
|
|
650
|
+ */
|
|
|
651
|
+ @Override
|
|
|
652
|
+ public AjaxResult submit(MsCaseApplication req) {
|
|
|
653
|
+ if(StrUtil.isNotEmpty(req.getBatchNumber())){
|
|
|
654
|
+ // 批量提交
|
|
|
655
|
+ List<MsCaseApplication> list = listByBatchNumber(req.getBatchNumber(), req.getCaseFlowId());
|
|
|
656
|
+ if(CollectionUtil.isEmpty(list)){
|
|
|
657
|
+ return AjaxResult.error("该批次号下未找到案件");
|
|
|
658
|
+ }
|
|
|
659
|
+ for (MsCaseApplication application : list) {
|
|
|
660
|
+ MsCaseFlow caseFlow = nextFlow(application.getId(), req.getCaseFlowId(), YesOrNoEnum.NO.getCode());
|
|
|
661
|
+ CaseLogUtils.insertCaseLog(application.getId(), caseFlow.getNodeId(), caseFlow.getCaseStatusName(), "提交成功");
|
|
|
662
|
+ }
|
|
|
663
|
+ }else {
|
|
|
664
|
+ MsCaseFlow caseFlow = nextFlow(req.getId(), req.getCaseFlowId(), YesOrNoEnum.NO.getCode());
|
|
|
665
|
+ CaseLogUtils.insertCaseLog(req.getId(), caseFlow.getNodeId(), caseFlow.getCaseStatusName(), "提交成功");
|
|
|
666
|
+
|
|
|
667
|
+ }
|
|
|
668
|
+ return AjaxResult.success("提交成功");
|
|
|
669
|
+ }
|
|
|
670
|
+
|
|
|
671
|
+ @Override
|
|
|
672
|
+ public AjaxResult listMediator() {
|
|
|
673
|
+ List<MediatorVO> mediatorVOS = new ArrayList<MediatorVO>();
|
|
|
674
|
+ mediatorVOS= msCaseApplicationMapper.listMediator();
|
|
|
675
|
+
|
|
|
676
|
+ return null;
|
|
|
677
|
+ }
|
|
|
678
|
+
|
|
|
679
|
+ /**
|
|
|
680
|
+ * 案件受理
|
|
|
681
|
+ * @param application
|
|
|
682
|
+ * @param req
|
|
|
683
|
+ * @param affiliateMap
|
|
|
684
|
+ */
|
|
|
685
|
+ private void accept(MsCaseApplication application, MsCaseApplication req, Map<Long, MsCaseAffiliate> affiliateMap) {
|
|
|
686
|
+ application.setUpdateBy(SecurityUtils.getUsername());
|
|
|
687
|
+ application.setUpdateTime(new Date());
|
|
|
688
|
+ msCaseApplicationMapper.updateByPrimaryKeySelective(application);
|
|
|
689
|
+ MsCaseFlow caseFlow = nextFlow(application.getId(), req.getCaseFlowId(),req.getLockStatus());
|
|
|
690
|
+ // 给申请人被申请人发送短信
|
|
|
691
|
+ if (affiliateMap.containsKey(application.getId())) {
|
|
|
692
|
+ MsCaseAffiliate affiliate = affiliateMap.get(application.getId());
|
|
|
693
|
+
|
|
|
694
|
+ if (StrUtil.isNotEmpty(affiliate.getContactTelphoneAgent())) {
|
|
|
695
|
+ String sendContent = "尊敬的" + affiliate.getNameAgent() + "用户,您的" + application.getCaseNum() + "{2}仲裁案件,已成功受理,请知晓,如非本人操作,请忽略本短信";
|
|
|
696
|
+ // 给申请人发送案件受理短信 尊敬的{1}用户,您的{2}仲裁案件,已成功受理,请知晓,如非本人操作,请忽略本短信
|
|
|
697
|
+ Boolean smsFlag = SmsUtils.sendSms(application.getId(), "2049503", affiliate.getContactTelphoneAgent(), new String[]{affiliate.getNameAgent(), application.getCaseNum()});
|
|
|
698
|
+ CaseLogUtils.insertCaseLog(application.getId(), caseFlow.getNodeId(), caseFlow.getNodeName(), "向申请人发送短信," + sendContent);
|
|
|
699
|
+ SmsSendRecord smsSendRecord = new SmsSendRecord(application.getId(), application.getCaseNum(), affiliate.getContactTelphoneAgent(), new Date(), sendContent);
|
|
|
700
|
+ if (smsFlag) {
|
|
|
701
|
+ // 发送成功
|
|
|
702
|
+ smsSendRecord.setSendStatus(YesOrNoEnum.YES.getCode());
|
|
|
703
|
+ } else {
|
|
|
704
|
+ smsSendRecord.setSendStatus(YesOrNoEnum.NO.getCode());
|
|
|
705
|
+ }
|
|
|
706
|
+ smsRecordMapper.saveSmsSendRecord(smsSendRecord);
|
|
|
707
|
+ }
|
|
|
708
|
+ // 给申请人被申请人发送短信
|
|
|
709
|
+ if (StrUtil.isNotEmpty(affiliate.getRespondentPhone())) {
|
|
|
710
|
+ String sendContent = "尊敬的" + affiliate.getRespondentName() + "用户,您的" + application.getCaseNum() + "{2}仲裁案件,已成功受理,请知晓,如非本人操作,请忽略本短信";
|
|
|
711
|
+ // 给被申请人发送案件受理短信 尊敬的{1}用户,您的{2}仲裁案件,已成功受理,请知晓,如非本人操作,请忽略本短信
|
|
|
712
|
+ Boolean smsFlag = SmsUtils.sendSms(application.getId(), "2049503", affiliate.getRespondentPhone(), new String[]{affiliate.getRespondentName(), application.getCaseNum()});
|
|
|
713
|
+ CaseLogUtils.insertCaseLog(application.getId(), caseFlow.getNodeId(), caseFlow.getNodeName(), "向被申请人发送短信," + sendContent);
|
|
|
714
|
+ SmsSendRecord smsSendRecord = new SmsSendRecord(application.getId(), application.getCaseNum(), affiliate.getRespondentPhone(), new Date(), sendContent);
|
|
|
715
|
+ if (smsFlag) {
|
|
|
716
|
+ // 发送成功
|
|
|
717
|
+ smsSendRecord.setSendStatus(YesOrNoEnum.YES.getCode());
|
|
|
718
|
+ } else {
|
|
|
719
|
+ smsSendRecord.setSendStatus(YesOrNoEnum.NO.getCode());
|
|
|
720
|
+ }
|
|
|
721
|
+ smsRecordMapper.saveSmsSendRecord(smsSendRecord);
|
|
|
722
|
+ }
|
|
|
723
|
+ }
|
|
|
724
|
+ }
|
|
|
725
|
+
|
|
|
726
|
+ /**
|
|
|
727
|
+ * 流向下一个流程节点
|
|
|
728
|
+ * @param caseId 案件id
|
|
|
729
|
+ * @param caseFlowId 案件流程id
|
|
|
730
|
+ * @param lockStatus '是否锁定,0-否,1-是',单独操作案件时需要锁定
|
|
|
731
|
+ * @return
|
|
|
732
|
+ */
|
|
|
733
|
+ @Override
|
|
|
734
|
+ public MsCaseFlow nextFlow(Long caseId,Integer caseFlowId,Integer lockStatus) {
|
|
|
735
|
+ MsCaseFlow nextFlow = caseFlowMapper.nextFlow(caseFlowId);
|
|
|
736
|
+ if (nextFlow == null) {
|
|
|
737
|
+ throw new ServiceException("未找到下一个流程节点");
|
|
|
738
|
+ }
|
|
|
739
|
+ MsCaseApplication application = new MsCaseApplication();
|
|
|
740
|
+ application.setId(caseId);
|
|
|
741
|
+ // 更改案件流程id和案件状态
|
|
|
742
|
+ application.setCaseFlowId(nextFlow.getId());
|
|
|
743
|
+ application.setCaseStatusName(nextFlow.getCaseStatusName());
|
|
|
744
|
+ application.setLockStatus(lockStatus);
|
|
|
745
|
+ msCaseApplicationMapper.updateByPrimaryKeySelective(application);
|
|
|
746
|
+ // 新增日志
|
|
|
747
|
+ CaseLogUtils.insertCaseLog(application.getId(), nextFlow.getNodeId(), nextFlow.getCaseStatusName(),"");
|
|
|
748
|
+ return nextFlow;
|
|
|
749
|
+ }
|
|
|
750
|
+
|
|
|
751
|
+ /**
|
|
|
752
|
+ * 生成调解申请书
|
|
|
753
|
+ * @param application 案件基本信息
|
|
|
754
|
+ * @param affiliate 案件相关人员
|
|
|
755
|
+ * @param templatePath 模板路径
|
|
|
756
|
+ * @param bookmarkList 标签
|
|
|
757
|
+ * @param dictDataList 内置字段
|
|
|
758
|
+ */
|
|
|
759
|
+ private void createMediateApplication(MsCaseApplication application, MsCaseAffiliate affiliate, String templatePath, List<String> bookmarkList, List<SysDictData> dictDataList) {
|
|
|
760
|
+ // 申请书需要的字段和内容,valueMap<占位符,替换的值>
|
|
|
761
|
+ Map<String, String> valueMap = new HashMap<>();
|
|
|
762
|
+ for (SysDictData dictData : dictDataList) {
|
|
|
763
|
+ if (CASE_BASE_COLUMN.contains(dictData.getDictValue())) {
|
|
|
764
|
+ valueMap.put(dictData.getDictLabel(), ObjectFieldUtils.getValue(application, dictData.getDictValue()));
|
|
|
765
|
+ } else {
|
|
|
766
|
+ // 相关人员字段
|
|
|
767
|
+ valueMap.put(dictData.getDictLabel(), ObjectFieldUtils.getValue(affiliate, dictData.getDictValue()));
|
|
|
768
|
+ }
|
|
|
769
|
+
|
|
|
770
|
+ }
|
|
|
771
|
+ // 书签对应值
|
|
|
772
|
+ Map<String, Object> bookmarkValueMap = new HashMap<>();
|
|
|
773
|
+ // 读取调节申请书,找到占位符,替换值
|
|
|
774
|
+ // 遍历书签,给书签赋值
|
|
|
775
|
+ replaceBookmark(bookmarkList, bookmarkValueMap, valueMap);
|
|
|
776
|
+ // 根据条件替换书签
|
|
|
777
|
+// conditionReplaceBookmark(caseApplicationById, bookmarkValueMap, agentName, resName, arbitrateRecordSelect);
|
|
|
778
|
+ // 申请书生成时间
|
|
|
779
|
+ LocalDate now = LocalDate.now();
|
|
|
780
|
+ int year = now.getYear();
|
|
|
781
|
+ DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy年MM月dd日");
|
|
|
782
|
+ // 格式化当前日期
|
|
|
783
|
+ String formattedDate = now.format(formatter);
|
|
|
784
|
+ bookmarkValueMap.put("日期", formattedDate);
|
|
|
785
|
+
|
|
|
786
|
+ String month = String.format("%02d", now.getMonthValue());
|
|
|
787
|
+ String day = String.format("%02d", now.getDayOfMonth());
|
|
|
788
|
+ // todo
|
|
|
789
|
+ String saveFolderPath = "/home/ruoyi/uploadPath/upload/" + year + "/" + month + "/" + day;
|
|
|
790
|
+// String saveFolderPath = "D:/home/ruoyi/uploadPath/upload/" + year + "/" + month + "/" + day;
|
|
|
791
|
+ String orgFileName="调解申请书";
|
|
|
792
|
+ String fileName = UUID.randomUUID().toString().replace("-", "")+orgFileName + ".docx";
|
|
|
793
|
+ // todo
|
|
|
794
|
+ String saveName = "/profile/upload/" + year + "/" + month + "/" + day + "/" + fileName;
|
|
|
795
|
+// String saveName = "D:/home/ruoyi/uploadPath/upload/" + year + "/" + month + "/" + day + "/" + fileName;
|
|
|
796
|
+ String resultFilePath = saveFolderPath + "/" + fileName;
|
|
|
797
|
+ // 将word中的标签替换掉,生成新的word
|
|
|
798
|
+ wordChangeText(templatePath, bookmarkValueMap,saveFolderPath,resultFilePath);
|
|
|
799
|
+
|
|
|
800
|
+ // String savePath = docFilePath.substring(0, docFilePath.indexOf("/upload/") + 8);
|
|
|
801
|
+ // 保存裁决书附件
|
|
|
802
|
+ // saveArbitorFile(id, saveName, savePath, caseApplicationById, arbitrateRecordSelect);
|
|
|
803
|
+ MsCaseAttach caseAttach = MsCaseAttach.builder()
|
|
|
804
|
+ .caseAppliId(application.getId())
|
|
|
805
|
+ .annexName(orgFileName)
|
|
|
806
|
+ .annexPath(resultFilePath)
|
|
|
807
|
+ .annexType(AnnexTypeEnum.MEDIATION_APPLICATION.getCode())
|
|
|
808
|
+ .build();
|
|
|
809
|
+ //保存到附件表里,先删除之前的在保存
|
|
|
810
|
+ msCaseAttachMapper.deleteCaseAttachByCasedIdAndType(caseAttach.getCaseAppliId(), 3);
|
|
|
811
|
+ msCaseAttachMapper.save(caseAttach);
|
|
|
812
|
+ }
|
|
|
813
|
+
|
|
|
814
|
+ /**
|
|
|
815
|
+ * 将word中的标签替换掉,生成新的word
|
|
|
816
|
+ *
|
|
|
817
|
+ * @param modalFilePath 调解申请书模板路径
|
|
|
818
|
+ * @param datas 替换标签的内容
|
|
|
819
|
+ * @param resultFilePath 保存路径
|
|
|
820
|
+
|
|
|
821
|
+ * @return
|
|
|
822
|
+ * @throws IOException
|
|
|
823
|
+ */
|
|
|
824
|
+ private void wordChangeText(String modalFilePath, Map<String, Object> datas, String saveFolderPath, String resultFilePath) {
|
|
|
825
|
+ // 调解申请书保存的路径
|
|
|
826
|
+
|
|
|
827
|
+ // 创建日期目录
|
|
|
828
|
+ File saveFolder = new File(saveFolderPath);
|
|
|
829
|
+ if (!saveFolder.exists()) {
|
|
|
830
|
+ saveFolder.mkdirs();
|
|
|
831
|
+ }
|
|
|
832
|
+ Path sourcePath = new File(modalFilePath).toPath();
|
|
|
833
|
+ Path destinationPath = new File(resultFilePath).toPath();
|
|
|
834
|
+ try {
|
|
|
835
|
+ Files.copy(sourcePath, destinationPath, StandardCopyOption.REPLACE_EXISTING);
|
|
|
836
|
+ WordUtil.getDocFilePath(datas, modalFilePath, resultFilePath);
|
|
|
837
|
+ File file = new File(resultFilePath);
|
|
|
838
|
+ if (file.exists()) {
|
|
|
839
|
+ InputStream in = new FileInputStream(file);
|
|
|
840
|
+ XWPFDocument xwpfDocument = new XWPFDocument(in);
|
|
|
841
|
+ WordUtil.changeText(xwpfDocument);
|
|
|
842
|
+ }
|
|
|
843
|
+ } catch (IOException e) {
|
|
|
844
|
+ throw new RuntimeException("请检查文件路径是否有误");
|
|
|
845
|
+ }
|
|
|
846
|
+ }
|
|
|
847
|
+ /**
|
|
|
848
|
+ * 给模板中的占位符赋值
|
|
|
849
|
+ *
|
|
|
850
|
+ * @param bookmarkList 书签
|
|
|
851
|
+ * @param bookmarkValueMap 书签赋值
|
|
|
852
|
+ * @param valueMap 案件内容
|
|
|
853
|
+ */
|
|
|
854
|
+ private void replaceBookmark(List<String> bookmarkList, Map<String, Object> bookmarkValueMap, Map<String, String> valueMap) {
|
|
|
855
|
+ for (String bookmark : bookmarkList) {
|
|
|
856
|
+ if (valueMap.containsKey(bookmark)) {
|
|
|
857
|
+ bookmarkValueMap.put(bookmark, valueMap.get(bookmark));
|
|
|
858
|
+ }
|
|
|
859
|
+ }
|
|
|
860
|
+ }
|
|
441
|
861
|
/**
|
|
442
|
862
|
* 组装附件
|
|
443
|
863
|
*
|
|
|
@@ -463,12 +883,12 @@ public class MsCaseApplicationServiceImpl implements MsCaseApplicationService {
|
|
463
|
883
|
// caseAttach.setAnnexName(entry.getKey());
|
|
464
|
884
|
// }
|
|
465
|
885
|
// 申请人提供的证据材料
|
|
466
|
|
- caseAttach.setAnnexType(2);
|
|
|
886
|
+ caseAttach.setAnnexType(AnnexTypeEnum.APPLICATION_EVIDENCE.getCode());
|
|
467
|
887
|
attachList.add(caseAttach);
|
|
468
|
888
|
if (fileUrl.contains("仲裁申请书")) {
|
|
469
|
889
|
MsCaseAttach applyFile = new MsCaseAttach();
|
|
470
|
890
|
BeanUtil.copyProperties(caseAttach, applyFile);
|
|
471
|
|
- applyFile.setAnnexType(1);
|
|
|
891
|
+ applyFile.setAnnexType(AnnexTypeEnum.APPLICATION.getCode());
|
|
472
|
892
|
attachList.add(applyFile);
|
|
473
|
893
|
}
|
|
474
|
894
|
|