|
|
@@ -4,6 +4,7 @@ import cn.hutool.core.bean.BeanUtil;
|
|
4
|
4
|
import cn.hutool.core.collection.CollectionUtil;
|
|
5
|
5
|
import cn.hutool.core.util.StrUtil;
|
|
6
|
6
|
import com.ruoyi.common.config.RuoYiConfig;
|
|
|
7
|
+import com.ruoyi.common.constant.Constants;
|
|
7
|
8
|
import com.ruoyi.common.core.domain.AjaxResult;
|
|
8
|
9
|
import com.ruoyi.common.core.domain.entity.SysDept;
|
|
9
|
10
|
import com.ruoyi.common.core.domain.entity.SysDictData;
|
|
|
@@ -481,37 +482,40 @@ public class MsCaseApplicationServiceImpl implements MsCaseApplicationService {
|
|
481
|
482
|
* @param req
|
|
482
|
483
|
* @return
|
|
483
|
484
|
*/
|
|
|
485
|
+ @Transactional
|
|
484
|
486
|
@Override
|
|
485
|
487
|
public AjaxResult generateApplication(MsCaseApplicationReq req) {
|
|
486
|
488
|
// 根据模板id查询申请书
|
|
487
|
489
|
TemplateManage templateManage=templateManageMapper.selectById(req.getTemplateId());
|
|
488
|
490
|
if(templateManage==null||StrUtil.isEmpty(templateManage.getTemOrigPath())){
|
|
489
|
|
- return AjaxResult.error("未找到调解申请书模板");
|
|
|
491
|
+ throw new ServiceException("未找到模板");
|
|
490
|
492
|
}
|
|
491
|
|
- String templatePath = templateManage.getTemOrigPath();
|
|
|
493
|
+ String templatePath = "/home/ruoyi/" + templateManage.getTemOrigPath();
|
|
|
494
|
+ templatePath=templatePath.replace("/profile","/uploadPath");
|
|
|
495
|
+
|
|
492
|
496
|
try {
|
|
493
|
497
|
File file = new File(templatePath);
|
|
494
|
498
|
} catch (Exception e) {
|
|
495
|
|
- return AjaxResult.error("未找到调解申请书模板");
|
|
|
499
|
+ throw new ServiceException("未找到模板");
|
|
496
|
500
|
}
|
|
497
|
501
|
|
|
498
|
502
|
// 获取模板中的占位符key
|
|
499
|
503
|
List<String> bookmarkList = getBookmarkByDocx(templatePath);
|
|
500
|
504
|
if (CollectionUtil.isEmpty(bookmarkList)) {
|
|
501
|
|
- return AjaxResult.success("请检查模板是否配置正确,未获取到占位符");
|
|
|
505
|
+ throw new ServiceException("请检查模板是否配置正确,未获取到占位符");
|
|
502
|
506
|
}
|
|
503
|
507
|
// 在系统表中查询案件内置字段
|
|
504
|
508
|
SysDictData sysDictData = new SysDictData();
|
|
505
|
509
|
sysDictData.setDictType("case_built_type");
|
|
506
|
510
|
List<SysDictData> dictDataList = dictDataMapper.selectDictDataList(sysDictData);
|
|
507
|
511
|
if(CollectionUtil.isEmpty(dictDataList)){
|
|
508
|
|
- return AjaxResult.error("未找到系统内置字段");
|
|
|
512
|
+ throw new ServiceException("未找到系统内置字段");
|
|
509
|
513
|
}
|
|
510
|
514
|
// 如果批号不为空,则为批量操作,根据批号查询未锁定的案件
|
|
511
|
515
|
if(StrUtil.isNotEmpty(req.getBatchNumber())){
|
|
512
|
516
|
List<MsCaseApplication> caseApplicationList=listByBatchNumber(req.getBatchNumber(),req.getCaseFlowId());
|
|
513
|
517
|
if(CollectionUtil.isEmpty(caseApplicationList)){
|
|
514
|
|
- return AjaxResult.error("该批次号下未找到案件");
|
|
|
518
|
+ throw new ServiceException("该批次号下未找到案件");
|
|
515
|
519
|
}
|
|
516
|
520
|
// 案件ids
|
|
517
|
521
|
List<Long> caseIds = caseApplicationList.stream().map(MsCaseApplication::getId).collect(Collectors.toList());
|
|
|
@@ -520,20 +524,19 @@ public class MsCaseApplicationServiceImpl implements MsCaseApplicationService {
|
|
520
|
524
|
afflicateExample.createCriteria().andIn("case_appli_id", caseIds);
|
|
521
|
525
|
List<MsCaseAffiliate> affiliateList = msCaseAffiliateMapper.selectByExample(caseIds);
|
|
522
|
526
|
if(CollectionUtil.isEmpty(affiliateList)){
|
|
523
|
|
- return AjaxResult.error("该批次号下未找到案件关联人员");
|
|
|
527
|
+ throw new ServiceException("该批次号下未找到案件关联人员");
|
|
524
|
528
|
}
|
|
525
|
529
|
|
|
526
|
530
|
Map<Long, MsCaseAffiliate> affiliateMap = affiliateList.stream().collect(Collectors.toMap(MsCaseAffiliate::getCaseAppliId, Function.identity()));
|
|
527
|
531
|
|
|
528
|
532
|
// 循环生成调解申请书
|
|
529
|
533
|
for (MsCaseApplication application : caseApplicationList) {
|
|
530
|
|
-
|
|
531
|
534
|
// 案件相关人员
|
|
532
|
535
|
MsCaseAffiliate affiliate = affiliateMap.get(application.getId());
|
|
533
|
536
|
if(affiliate==null){
|
|
534
|
537
|
continue;
|
|
535
|
538
|
}
|
|
536
|
|
- createMediateApplication(application, affiliate, templatePath, bookmarkList,dictDataList);
|
|
|
539
|
+ createMediateApplication(application, affiliate, templatePath, bookmarkList,dictDataList,req.getTemplateType());
|
|
537
|
540
|
|
|
538
|
541
|
}
|
|
539
|
542
|
}else {
|
|
|
@@ -543,13 +546,14 @@ public class MsCaseApplicationServiceImpl implements MsCaseApplicationService {
|
|
543
|
546
|
// 查询案件关联人员
|
|
544
|
547
|
MsCaseAffiliate caseAffiliate = msCaseAffiliateMapper.selectByPrimaryKey(req.getId());
|
|
545
|
548
|
if (application == null || caseAffiliate == null) {
|
|
546
|
|
- return AjaxResult.error("该案件不存在");
|
|
|
549
|
+ throw new ServiceException("该案件不存在");
|
|
547
|
550
|
}
|
|
548
|
|
- createMediateApplication(application, caseAffiliate, templatePath, bookmarkList,dictDataList);
|
|
|
551
|
+
|
|
|
552
|
+ createMediateApplication(application, caseAffiliate, templatePath, bookmarkList,dictDataList,req.getTemplateType());
|
|
549
|
553
|
}
|
|
550
|
554
|
|
|
551
|
555
|
|
|
552
|
|
- return AjaxResult.success("调解申请书生成成功");
|
|
|
556
|
+ return AjaxResult.success();
|
|
553
|
557
|
}
|
|
554
|
558
|
|
|
555
|
559
|
/**
|
|
|
@@ -738,11 +742,57 @@ public class MsCaseApplicationServiceImpl implements MsCaseApplicationService {
|
|
738
|
742
|
@Transactional
|
|
739
|
743
|
@Override
|
|
740
|
744
|
public AjaxResult updateBooking(BookingVO vo) {
|
|
|
745
|
+ // 查询被申请人是否预约过(从日志表查),否则不更新流程节点
|
|
|
746
|
+ MsCaseAffiliate msCaseAffiliate = msCaseAffiliateMapper.selectByPrimaryKey(vo.getId());
|
|
|
747
|
+ if(msCaseAffiliate==null) {
|
|
|
748
|
+ return AjaxResult.error("该案件不存在");
|
|
|
749
|
+ }
|
|
741
|
750
|
MsCaseApplication application = new MsCaseApplication();
|
|
742
|
751
|
application.setId(vo.getId());
|
|
743
|
752
|
setMediatorAndDate(application,vo);
|
|
744
|
|
- msCaseApplicationMapper.updateByPrimaryKeySelective(application);
|
|
745
|
|
- nextFlow(vo.getId(),vo.getCaseFlowId(),null);
|
|
|
753
|
+ int applicantCount = msCaseApplicationMapper.updateByPrimaryKeySelective(application);
|
|
|
754
|
+ if(applicantCount<1){
|
|
|
755
|
+ return AjaxResult.error("保存失败");
|
|
|
756
|
+ }
|
|
|
757
|
+ // 新增申请人签署日志
|
|
|
758
|
+ MsCaseFlow currentFlow = caseFlowMapper.selectByPrimaryKey(vo.getCaseFlowId());
|
|
|
759
|
+ if(currentFlow==null){
|
|
|
760
|
+ return AjaxResult.error("当前流程不存在");
|
|
|
761
|
+ }
|
|
|
762
|
+ CaseLogUtils.insertCaseLog(application.getId(), currentFlow.getNodeId(), currentFlow.getCaseStatusName(),"申请人选择调解员");
|
|
|
763
|
+
|
|
|
764
|
+ if(StrUtil.isNotEmpty(msCaseAffiliate.getRespondentIdentityNum())){
|
|
|
765
|
+ // 根据身份证查询用户表
|
|
|
766
|
+ SysUser user = userMapper.selectUserByIdCard(msCaseAffiliate.getRespondentIdentityNum());
|
|
|
767
|
+ if(user!=null){
|
|
|
768
|
+ MsCaseFlow nextFlow = caseFlowMapper.nextFlow(vo.getCaseFlowId());
|
|
|
769
|
+ if(nextFlow==null){
|
|
|
770
|
+ return AjaxResult.error("未找到下一个流程");
|
|
|
771
|
+ }
|
|
|
772
|
+ // 查询日志中是否有该节点的被申请人操作
|
|
|
773
|
+ Example example = new Example(MsCaseLogRecord.class);
|
|
|
774
|
+ Example.Criteria criteria = example.createCriteria();
|
|
|
775
|
+ criteria.andEqualTo("case_appli_id", vo.getId());
|
|
|
776
|
+ criteria.andEqualTo("case_node", nextFlow.getNodeId());
|
|
|
777
|
+ criteria.andEqualTo("case_status_name", nextFlow.getCaseStatusName());
|
|
|
778
|
+ criteria.andEqualTo("create_by", user.getUserName());
|
|
|
779
|
+ int count = caseLogRecordMapper.selectCountByExample(example);
|
|
|
780
|
+ if(count>0){
|
|
|
781
|
+ // 被申请人已预约,更新流程节点
|
|
|
782
|
+ // 更改案件流程id和案件状态
|
|
|
783
|
+ application.setCaseFlowId(nextFlow.getId());
|
|
|
784
|
+ application.setCaseStatusName(nextFlow.getCaseStatusName());
|
|
|
785
|
+ application.setLockStatus(null);
|
|
|
786
|
+ msCaseApplicationMapper.updateByPrimaryKeySelective(application);
|
|
|
787
|
+ }
|
|
|
788
|
+// else {
|
|
|
789
|
+// return AjaxResult.error("被申请人未选择调解员");
|
|
|
790
|
+// }
|
|
|
791
|
+ }
|
|
|
792
|
+// else {
|
|
|
793
|
+// return AjaxResult.error("被申请人未选择调解员");
|
|
|
794
|
+// }
|
|
|
795
|
+ }
|
|
746
|
796
|
return AjaxResult.success();
|
|
747
|
797
|
}
|
|
748
|
798
|
|
|
|
@@ -853,6 +903,79 @@ public class MsCaseApplicationServiceImpl implements MsCaseApplicationService {
|
|
853
|
903
|
return AjaxResult.success(result);
|
|
854
|
904
|
}
|
|
855
|
905
|
|
|
|
906
|
+ /**
|
|
|
907
|
+ * 调解
|
|
|
908
|
+ * @param req
|
|
|
909
|
+ * @return
|
|
|
910
|
+ */
|
|
|
911
|
+ @Transactional
|
|
|
912
|
+ @Override
|
|
|
913
|
+ public AjaxResult mediation(MsCaseApplicationReq req) {
|
|
|
914
|
+ String templateId=null;
|
|
|
915
|
+ // 批量
|
|
|
916
|
+ if(StrUtil.isNotEmpty(req.getBatchNumber())){
|
|
|
917
|
+ // 查询调解书模板是否存在
|
|
|
918
|
+ Example example = new Example(MsCaseFlow.class);
|
|
|
919
|
+ Example.Criteria criteria = example.createCriteria();
|
|
|
920
|
+ criteria.andEqualTo("batch_number", req.getBatchNumber());
|
|
|
921
|
+ criteria.andIsNotNull("template_id");
|
|
|
922
|
+ MsCaseApplication caseApplication = msCaseApplicationMapper.selectOneByExample(example);
|
|
|
923
|
+ if(caseApplication==null||caseApplication.getTemplateId()==null){
|
|
|
924
|
+ return AjaxResult.error("未找到模板");
|
|
|
925
|
+ }
|
|
|
926
|
+ templateId= String.valueOf(caseApplication.getTemplateId());
|
|
|
927
|
+
|
|
|
928
|
+ }else {
|
|
|
929
|
+ // 单独生成
|
|
|
930
|
+ // 查询调解书模板是否存在
|
|
|
931
|
+ MsCaseApplication application = msCaseApplicationMapper.selectByPrimaryKey(req.getId());
|
|
|
932
|
+ if(application==null||application.getTemplateId()==null){
|
|
|
933
|
+ return AjaxResult.error("未找到模板");
|
|
|
934
|
+ }
|
|
|
935
|
+ templateId= String.valueOf(application.getTemplateId());
|
|
|
936
|
+ }
|
|
|
937
|
+ req.setTemplateId(templateId);
|
|
|
938
|
+ req.setTemplateType(1);
|
|
|
939
|
+ AjaxResult result = generateApplication(req);
|
|
|
940
|
+ if(result!=null && result.isSuccess()){
|
|
|
941
|
+ return result;
|
|
|
942
|
+ }
|
|
|
943
|
+ return AjaxResult.error("生成失败");
|
|
|
944
|
+ }
|
|
|
945
|
+
|
|
|
946
|
+ /**
|
|
|
947
|
+ * 修改庭审笔录
|
|
|
948
|
+ * @param attach
|
|
|
949
|
+ * @return
|
|
|
950
|
+ */
|
|
|
951
|
+ @Transactional
|
|
|
952
|
+ @Override
|
|
|
953
|
+ public AjaxResult updateTrialPen(MsCaseAttach attach) {
|
|
|
954
|
+ // 删除之前的庭审笔录
|
|
|
955
|
+ msCaseAttachMapper.deleteCaseAttachByCasedIdAndType(attach.getCaseAppliId(), AnnexTypeEnum.MEDIATE.getCode());
|
|
|
956
|
+ // 更新庭审笔录
|
|
|
957
|
+ msCaseAttachMapper.updateCaseAttach(attach);
|
|
|
958
|
+ return AjaxResult.success();
|
|
|
959
|
+ }
|
|
|
960
|
+
|
|
|
961
|
+ /**
|
|
|
962
|
+ * 确认调解书
|
|
|
963
|
+ * @param attach
|
|
|
964
|
+ * @return
|
|
|
965
|
+ */
|
|
|
966
|
+ @Transactional
|
|
|
967
|
+
|
|
|
968
|
+ @Override
|
|
|
969
|
+ public AjaxResult confirmMediation(MsCaseAttachVO attach) {
|
|
|
970
|
+ if(attach.getAnnexId()!=null){
|
|
|
971
|
+ // 删除之前的调解书
|
|
|
972
|
+ msCaseAttachMapper.deleteCaseAttachByCasedIdAndType(attach.getCaseAppliId(),AnnexTypeEnum.MEDIATE_BOOK.getCode());
|
|
|
973
|
+ msCaseAttachMapper.updateCaseAttach(attach);
|
|
|
974
|
+ }
|
|
|
975
|
+ // 更新流程节点
|
|
|
976
|
+ nextFlow(attach.getCaseAppliId(),attach.getCaseFlowId(),YesOrNoEnum.YES.getCode());
|
|
|
977
|
+ return AjaxResult.success();
|
|
|
978
|
+ }
|
|
856
|
979
|
|
|
857
|
980
|
|
|
858
|
981
|
/**
|
|
|
@@ -956,7 +1079,7 @@ public class MsCaseApplicationServiceImpl implements MsCaseApplicationService {
|
|
956
|
1079
|
* @param bookmarkList 标签
|
|
957
|
1080
|
* @param dictDataList 内置字段
|
|
958
|
1081
|
*/
|
|
959
|
|
- private void createMediateApplication(MsCaseApplication application, MsCaseAffiliate affiliate, String templatePath, List<String> bookmarkList, List<SysDictData> dictDataList) {
|
|
|
1082
|
+ private void createMediateApplication(MsCaseApplication application, MsCaseAffiliate affiliate, String templatePath, List<String> bookmarkList, List<SysDictData> dictDataList,Integer templateType) {
|
|
960
|
1083
|
// 申请书需要的字段和内容,valueMap<占位符,替换的值>
|
|
961
|
1084
|
Map<String, String> valueMap = new HashMap<>();
|
|
962
|
1085
|
for (SysDictData dictData : dictDataList) {
|
|
|
@@ -973,8 +1096,6 @@ public class MsCaseApplicationServiceImpl implements MsCaseApplicationService {
|
|
973
|
1096
|
// 读取调节申请书,找到占位符,替换值
|
|
974
|
1097
|
// 遍历书签,给书签赋值
|
|
975
|
1098
|
replaceBookmark(bookmarkList, bookmarkValueMap, valueMap);
|
|
976
|
|
- // 根据条件替换书签
|
|
977
|
|
-// conditionReplaceBookmark(caseApplicationById, bookmarkValueMap, agentName, resName, arbitrateRecordSelect);
|
|
978
|
1099
|
// 申请书生成时间
|
|
979
|
1100
|
LocalDate now = LocalDate.now();
|
|
980
|
1101
|
int year = now.getYear();
|
|
|
@@ -986,29 +1107,34 @@ public class MsCaseApplicationServiceImpl implements MsCaseApplicationService {
|
|
986
|
1107
|
String month = String.format("%02d", now.getMonthValue());
|
|
987
|
1108
|
String day = String.format("%02d", now.getDayOfMonth());
|
|
988
|
1109
|
// todo
|
|
989
|
|
- String saveFolderPath = "/home/ruoyi/uploadPath/upload/" + year + "/" + month + "/" + day;
|
|
990
|
|
-// String saveFolderPath = "D:/home/ruoyi/uploadPath/upload/" + year + "/" + month + "/" + day;
|
|
991
|
|
- String orgFileName="调解申请书";
|
|
|
1110
|
+ String saveFolderPath = RuoYiConfig.getUploadPath()+"/"+ year + "/" + month + "/" + day;
|
|
|
1111
|
+ Integer annexType = AnnexTypeEnum.MEDIATION_APPLICATION.getCode();
|
|
|
1112
|
+ String orgFileName = "调解申请书";
|
|
|
1113
|
+ if(templateType!=null&&templateType==1) {
|
|
|
1114
|
+ orgFileName = "调解书";
|
|
|
1115
|
+ annexType=AnnexTypeEnum.MEDIATE_BOOK.getCode();
|
|
|
1116
|
+ }
|
|
992
|
1117
|
String fileName = UUID.randomUUID().toString().replace("-", "")+orgFileName + ".docx";
|
|
993
|
|
- // todo
|
|
994
|
|
- String saveName = "/profile/upload/" + year + "/" + month + "/" + day + "/" + fileName;
|
|
995
|
|
-// String saveName = "D:/home/ruoyi/uploadPath/upload/" + year + "/" + month + "/" + day + "/" + fileName;
|
|
996
|
1118
|
String resultFilePath = saveFolderPath + "/" + fileName;
|
|
997
|
1119
|
// 将word中的标签替换掉,生成新的word
|
|
998
|
1120
|
wordChangeText(templatePath, bookmarkValueMap,saveFolderPath,resultFilePath);
|
|
999
|
1121
|
|
|
1000
|
|
- // String savePath = docFilePath.substring(0, docFilePath.indexOf("/upload/") + 8);
|
|
1001
|
|
- // 保存裁决书附件
|
|
1002
|
|
- // saveArbitorFile(id, saveName, savePath, caseApplicationById, arbitrateRecordSelect);
|
|
1003
|
1122
|
MsCaseAttach caseAttach = MsCaseAttach.builder()
|
|
1004
|
1123
|
.caseAppliId(application.getId())
|
|
1005
|
1124
|
.annexName(orgFileName)
|
|
1006
|
|
- .annexPath(resultFilePath)
|
|
1007
|
|
- .annexType(AnnexTypeEnum.MEDIATION_APPLICATION.getCode())
|
|
|
1125
|
+ .annexPath(resultFilePath.replace(RuoYiConfig.getProfile(),Constants.RESOURCE_PREFIX))
|
|
|
1126
|
+ .annexType(annexType)
|
|
1008
|
1127
|
.build();
|
|
1009
|
1128
|
//保存到附件表里,先删除之前的在保存
|
|
1010
|
|
- msCaseAttachMapper.deleteCaseAttachByCasedIdAndType(caseAttach.getCaseAppliId(), 3);
|
|
|
1129
|
+ msCaseAttachMapper.deleteCaseAttachByCasedIdAndType(caseAttach.getCaseAppliId(), AnnexTypeEnum.MEDIATION_APPLICATION.getCode());
|
|
|
1130
|
+ if (templateType!=null&&templateType==1) {
|
|
|
1131
|
+ msCaseAttachMapper.deleteCaseAttachByCasedIdAndType(caseAttach.getCaseAppliId(), AnnexTypeEnum.MEDIATE_BOOK.getCode());
|
|
|
1132
|
+ }
|
|
1011
|
1133
|
msCaseAttachMapper.save(caseAttach);
|
|
|
1134
|
+ // 生成调解书成功,需要更新流程节点
|
|
|
1135
|
+ if (templateType!=null&&templateType==1) {
|
|
|
1136
|
+ nextFlow(application.getId(), application.getCaseFlowId(), application.getLockStatus());
|
|
|
1137
|
+ }
|
|
1012
|
1138
|
}
|
|
1013
|
1139
|
|
|
1014
|
1140
|
/**
|
|
|
@@ -1041,7 +1167,9 @@ public class MsCaseApplicationServiceImpl implements MsCaseApplicationService {
|
|
1041
|
1167
|
WordUtil.changeText(xwpfDocument);
|
|
1042
|
1168
|
}
|
|
1043
|
1169
|
} catch (IOException e) {
|
|
1044
|
|
- throw new RuntimeException("请检查文件路径是否有误");
|
|
|
1170
|
+
|
|
|
1171
|
+ throw new RuntimeException("modalFilePath:"+modalFilePath+"==saveFolderPath:"
|
|
|
1172
|
+ +saveFolderPath+"==resultFilePath:"+resultFilePath+"==sourcePath:"+sourcePath+"==destinationPath:"+destinationPath);
|
|
1045
|
1173
|
}
|
|
1046
|
1174
|
}
|
|
1047
|
1175
|
/**
|