18792927508 hace 2 años
padre
commit
58a5f083fe

+ 2
- 8
ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/service/mscase/MsCaseApplicationService.java Ver fichero

@@ -103,18 +103,13 @@ public interface MsCaseApplicationService {
103 103
      */
104 104
     AjaxResult userIdentify(MultipartFile file);
105 105
 
106
+
106 107
     /**
107 108
      * 生成调解申请书
108 109
      * @param req
109 110
      * @return
110 111
      */
111 112
     AjaxResult generateApplication(MsCaseApplicationReq req);
112
-    /**
113
-     * 生成调解申请书
114
-     * @param req
115
-     * @return
116
-     */
117
-    AjaxResult generateApplication1(MsCaseApplicationReq req);
118 113
 
119 114
     /**
120 115
      * 根据批次号和流程id查找未锁定的案件
@@ -232,8 +227,7 @@ public interface MsCaseApplicationService {
232 227
      * @param bookmarkList 标签
233 228
      * @param dictDataList 内置字段
234 229
      */
235
-     void createMediateApplication(MsCaseApplication application, List<MsCaseAffiliate> affiliates, String templatePath, List<String> bookmarkList, List<SysDictData> dictDataList, Integer templateType) ;
236
-     void createMediateApplication1(MsCaseApplication application, List<MsCaseAffiliate> affiliates, String templatePath, List<String> bookmarkList, List<SysDictData> dictDataList, Integer templateType) ;
230
+    void createMediateApplication(MsCaseApplication application, List<MsCaseAffiliate> affiliates, String templatePath, List<String> bookmarkList, List<SysDictData> dictDataList, Integer templateType) ;
237 231
     /**
238 232
      * 调解书上传到onlyoffice服务器
239 233
      * @param annexPath

+ 4
- 234
ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/service/mscase/impl/MsCaseApplicationServiceImpl.java Ver fichero

@@ -683,7 +683,7 @@ public class MsCaseApplicationServiceImpl implements MsCaseApplicationService {
683 683
             // 生成调解申请书
684 684
             req.setTemplateType(TemplateTypeEnum.PERSON_MEDIATION_APPLICATION.getCode());
685 685
             req.setTemplateId(String.valueOf(caseApplication.getTemplateId()));
686
-            caseApplicationService.generateApplication1(req);
686
+            caseApplicationService.generateApplication(req);
687 687
             // 保存案件附件
688 688
             if (CollectionUtil.isNotEmpty(caseAttachList)) {
689 689
                 for (MsCaseAttach caseAttach : caseAttachList) {
@@ -1057,7 +1057,7 @@ public class MsCaseApplicationServiceImpl implements MsCaseApplicationService {
1057 1057
             // 自然人
1058 1058
         req.setTemplateType(TemplateTypeEnum.PERSON_MEDIATION_APPLICATION.getCode());
1059 1059
         req.setTemplateId(String.valueOf(selectByPrimaryKey.getTemplateId()));
1060
-        caseApplicationService.generateApplication1(req);
1060
+        caseApplicationService.generateApplication(req);
1061 1061
         // 新增日志
1062 1062
         CaseLogUtils.insertCaseLog(caseApplication.getId(), 0, "修改案件",null);
1063 1063
 
@@ -1443,85 +1443,6 @@ public class MsCaseApplicationServiceImpl implements MsCaseApplicationService {
1443 1443
 //                MsCaseAffiliate affiliate = affiliateMap.get(application.getId());
1444 1444
 //                if(affiliate==null){
1445 1445
 //                    continue;
1446
-//                }
1447
-             //   caseApplicationService.createMediateApplication(application, affiliate, templatePath, bookmarkList,dictDataList,req.getTemplateType());
1448
-
1449
-            }
1450
-        }else {
1451
-            // 单独生成调解申请书
1452
-            // 根据案件id查询案件信息
1453
-            MsCaseApplication application = msCaseApplicationMapper.selectByPrimaryKey(req.getId());
1454
-            // 查询案件关联人员
1455
-            List<MsCaseAffiliate> msCaseAffiliates = selectAffliatesByCaseId(req.getId());
1456
-            if (application == null || msCaseAffiliates == null) {
1457
-                throw new ServiceException("该案件不存在");
1458
-            }
1459
-
1460
-            caseApplicationService.createMediateApplication(application, msCaseAffiliates, templatePath, bookmarkList,dictDataList,req.getTemplateType());
1461
-        }
1462
-
1463
-
1464
-        return AjaxResult.success();
1465
-    }
1466
-    /**
1467
-     * 生成调解申请书
1468
-     * @param req
1469
-     * @return
1470
-     */
1471
-    @Transactional
1472
-    @Override
1473
-    public AjaxResult generateApplication1(MsCaseApplicationReq req) {
1474
-        // 根据模板id查询申请书
1475
-        if(req.getTemplateId()==null || req.getTemplateType()==null){
1476
-            return AjaxResult.error("模板id不能为空");
1477
-        }
1478
-        TemplateManage templateManage=templateManageMapper.selectByIdAndType(Long.valueOf(req.getTemplateId()),req.getTemplateType());
1479
-        if(templateManage==null||StrUtil.isEmpty(templateManage.getTemOrigPath())){
1480
-            throw new ServiceException("未找到模板");
1481
-        }
1482
-        String templatePath = "/home/ruoyi" + templateManage.getTemOrigPath();
1483
-        templatePath=templatePath.replace("/profile","/uploadPath");
1484
-        try {
1485
-            File file = new File(templatePath);
1486
-        } catch (Exception e) {
1487
-            throw new ServiceException("未找到模板");
1488
-        }
1489
-//        // 获取模板中的占位符key
1490
-        List<String> bookmarkList = getBookmarkByDocx(templatePath);
1491
-        if (CollectionUtil.isEmpty(bookmarkList)) {
1492
-            throw new ServiceException("请检查模板是否配置正确,未获取到占位符");
1493
-        }
1494
-        // 在系统表中查询案件内置字段
1495
-        SysDictData sysDictData = new SysDictData();
1496
-        sysDictData.setDictType("case_built_type");
1497
-        List<SysDictData> dictDataList = dictDataMapper.selectDictDataList(sysDictData);
1498
-        if(CollectionUtil.isEmpty(dictDataList)){
1499
-            throw new ServiceException("未找到系统内置字段");
1500
-        }
1501
-        // 如果批号不为空,则为批量操作,根据批号查询未锁定的案件
1502
-        if(StrUtil.isNotEmpty(req.getBatchNumber())){
1503
-            List<MsCaseApplication> caseApplicationList=listByBatchNumber(req.getBatchNumber(),req.getCaseFlowId());
1504
-            if(CollectionUtil.isEmpty(caseApplicationList)){
1505
-                throw new ServiceException("该批次号下未找到案件");
1506
-            }
1507
-            // 案件ids
1508
-            List<Long> caseIds = caseApplicationList.stream().map(MsCaseApplication::getId).collect(Collectors.toList());
1509
-            // 根据ids查询案件关联人员
1510
-            Example afflicateExample = new Example(MsCaseAffiliate.class);
1511
-            afflicateExample.createCriteria().andIn("caseAppliId", caseIds);
1512
-            List<MsCaseAffiliate> affiliateList = msCaseAffiliateMapper.selectByExample(afflicateExample);
1513
-            if(CollectionUtil.isEmpty(affiliateList)){
1514
-                throw new ServiceException("该批次号下未找到案件关联人员");
1515
-            }
1516
-
1517
-            Map<Long, MsCaseAffiliate> affiliateMap = affiliateList.stream().collect(Collectors.toMap(MsCaseAffiliate::getCaseAppliId, Function.identity()));
1518
-
1519
-            // 循环生成调解申请书
1520
-            for (MsCaseApplication application : caseApplicationList) {
1521
-                // todo 批量的未改案件相关人员,结构已发生变化
1522
-//                MsCaseAffiliate affiliate = affiliateMap.get(application.getId());
1523
-//                if(affiliate==null){
1524
-//                    continue;
1525 1446
 //                }
1526 1447
                 //   caseApplicationService.createMediateApplication(application, affiliate, templatePath, bookmarkList,dictDataList,req.getTemplateType());
1527 1448
 
@@ -1536,7 +1457,7 @@ public class MsCaseApplicationServiceImpl implements MsCaseApplicationService {
1536 1457
                 throw new ServiceException("该案件不存在");
1537 1458
             }
1538 1459
 
1539
-            caseApplicationService.createMediateApplication1(application, msCaseAffiliates, templatePath, bookmarkList,dictDataList,req.getTemplateType());
1460
+            caseApplicationService.createMediateApplication(application, msCaseAffiliates, templatePath, bookmarkList,dictDataList,req.getTemplateType());
1540 1461
         }
1541 1462
 
1542 1463
 
@@ -3175,7 +3096,7 @@ public class MsCaseApplicationServiceImpl implements MsCaseApplicationService {
3175 3096
             req.setTemplateType(TemplateTypeEnum.MEDIATION_AGREEMENT.getCode());
3176 3097
 
3177 3098
         }
3178
-        AjaxResult result = caseApplicationService.generateApplication1(req);
3099
+        AjaxResult result = caseApplicationService.generateApplication(req);
3179 3100
         // 修改案件结果
3180 3101
         application.setMediaResult(req.getMediaResult());
3181 3102
         msCaseApplicationMapper.updateByPrimaryKeySelective(application);
@@ -3231,159 +3152,8 @@ public class MsCaseApplicationServiceImpl implements MsCaseApplicationService {
3231 3152
         return nextFlow;
3232 3153
     }
3233 3154
 
3234
-    /**
3235
-     * 生成调解申请书
3236
-     * @param application 案件基本信息
3237
-     * @param affiliates 案件相关人员
3238
-     * @param templatePath 模板路径
3239
-     * @param bookmarkList 标签
3240
-     * @param dictDataList 内置字段
3241
-     */
3242 3155
     @Transactional
3243 3156
     public void createMediateApplication(MsCaseApplication application, List<MsCaseAffiliate> affiliates, String templatePath, List<String> bookmarkList, List<SysDictData> dictDataList,Integer templateType) {
3244
-        // 申请书需要的字段和内容,valueMap<占位符,替换的值>
3245
-        Map<String, String> valueMap = new HashMap<>();
3246
-        // 操作人信息
3247
-        Map<Integer, List<MsCaseAffiliate>> operatorMap = affiliates.stream().collect(Collectors.groupingBy(MsCaseAffiliate::getOperatorFlag, Collectors.toList()));
3248
-        // 按角色分类
3249
-        Map<Integer, MsCaseAffiliate> roleTypeMap = affiliates.stream().collect(Collectors.toMap(MsCaseAffiliate::getRoleType, Function.identity(), (k1, k2) -> k1));
3250
-//        Map<Integer, List<MsCaseAffiliate>> roleTypeMap = affiliates.stream().collect(Collectors.groupingBy(MsCaseAffiliate::getRoleType, Collectors.toList()));
3251
-
3252
-        for (SysDictData dictData : dictDataList) {
3253
-            if (CASE_BASE_COLUMN.contains(dictData.getDictValue())) {
3254
-                valueMap.put(dictData.getDictLabel(), ObjectFieldUtils.getValue(application, dictData.getDictValue()));
3255
-            } else {
3256
-                // todo 相关人员字段,如果有多个申请人,被申请人,模板需要变化,待讨论,暂做成取第一个操作人
3257
-                List<MsCaseAffiliate> msCaseAffiliates = operatorMap.get(1);
3258
-                if(CollectionUtil.isNotEmpty(msCaseAffiliates)) {
3259
-                    Map<Integer, MsCaseAffiliate> roleTypeOperatorMap = msCaseAffiliates.stream().collect(Collectors.toMap(MsCaseAffiliate::getRoleType, Function.identity(), (k1, k2) -> k1));
3260
-                      if(dictData.getDictLabel().contains("被申请人")){
3261
-                        if(roleTypeOperatorMap.get(3)!=null ) {
3262
-                            valueMap.put(dictData.getDictLabel(), ObjectFieldUtils.getValue(roleTypeOperatorMap.get(3), dictData.getDictValue()));
3263
-                        }else {
3264
-                            valueMap.put(dictData.getDictLabel(), ObjectFieldUtils.getValue(roleTypeMap.get(3), dictData.getDictValue()));
3265
-                        }
3266
-                    }else if(dictData.getDictLabel().contains("被申请人委托代理人")){
3267
-                          if(roleTypeOperatorMap.get(4)!=null ) {
3268
-                              valueMap.put(dictData.getDictLabel(), ObjectFieldUtils.getValue(roleTypeOperatorMap.get(4), dictData.getDictValue()));
3269
-                          }else {
3270
-                              valueMap.put(dictData.getDictLabel(), ObjectFieldUtils.getValue(roleTypeMap.get(4), dictData.getDictValue()));
3271
-                          }
3272
-                    }else if(dictData.getDictLabel().contains("申请人")
3273
-                            || dictData.getDictLabel().equals("统一社会信用代码")
3274
-                            || dictData.getDictLabel().equals("法定代表人")
3275
-                    ){
3276
-                          if(roleTypeOperatorMap.get(1)!=null ) {
3277
-                              valueMap.put(dictData.getDictLabel(), ObjectFieldUtils.getValue(roleTypeOperatorMap.get(1), dictData.getDictValue()));
3278
-                          }else {
3279
-                              valueMap.put(dictData.getDictLabel(), ObjectFieldUtils.getValue(roleTypeMap.get(1), dictData.getDictValue()));
3280
-                          }
3281
-                    }else if(dictData.getDictLabel().contains("委托代理人")){
3282
-                          if(roleTypeOperatorMap.get(2)!=null ) {
3283
-                              valueMap.put(dictData.getDictLabel(), ObjectFieldUtils.getValue(roleTypeOperatorMap.get(2), dictData.getDictValue()));
3284
-                          }else {
3285
-                              valueMap.put(dictData.getDictLabel(), ObjectFieldUtils.getValue(roleTypeMap.get(2), dictData.getDictValue()));
3286
-                          }
3287
-                    }
3288
-                }
3289
-            }
3290
-
3291
-        }
3292
-        // 书签对应值
3293
-        Map<String, Object> bookmarkValueMap = new HashMap<>();
3294
-        // 读取调节申请书,找到占位符,替换值
3295
-        // 遍历书签,给书签赋值
3296
-        replaceBookmark(bookmarkList, bookmarkValueMap, valueMap);
3297
-        // 申请书生成时间
3298
-        LocalDate now = LocalDate.now();
3299
-        int year = now.getYear();
3300
-        DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy年MM月dd日");
3301
-        // 格式化当前日期
3302
-        String formattedDate = now.format(formatter);
3303
-        bookmarkValueMap.put("日期", formattedDate);
3304
-
3305
-        String month = String.format("%02d", now.getMonthValue());
3306
-        String day = String.format("%02d", now.getDayOfMonth());
3307
-        String saveFolderPath = RuoYiConfig.getUploadPath()+"/"+ year + "/" + month + "/" + day;
3308
-        Integer annexType = null;
3309
-        if(templateType==null
3310
-                || templateType.equals(TemplateTypeEnum.MEDIATION_APPLICATION.getCode())
3311
-                || templateType.equals(TemplateTypeEnum.PERSON_MEDIATION_APPLICATION.getCode()) ){
3312
-            // 调解申请书
3313
-            annexType = AnnexTypeEnum.MEDIATION_APPLICATION.getCode();
3314
-        }else if(templateType.equals(TemplateTypeEnum.MEDIATION_AGREEMENT.getCode())
3315
-                || templateType.equals(TemplateTypeEnum.MEDIATE_BOOK.getCode()) ){
3316
-            // 调解书和解协议
3317
-            annexType = AnnexTypeEnum.MEDIATE_BOOK.getCode();
3318
-        }
3319
-
3320
-        String orgFileName = "调解申请书";
3321
-        if (annexType != null && annexType.equals(AnnexTypeEnum.MEDIATE_BOOK.getCode())) {
3322
-            orgFileName = "调解书";
3323
-        }
3324
-        String fileName = UUID.randomUUID().toString().replace("-", "")+orgFileName + ".docx";
3325
-        String resultFilePath = saveFolderPath + "/" + fileName;
3326
-        // 将word中的标签替换掉,生成新的word
3327
-        wordChangeText(templatePath, bookmarkValueMap,saveFolderPath,resultFilePath);
3328
-
3329
-        MsCaseAttach caseAttach = null;
3330
-       String annexPath=resultFilePath.replace(RuoYiConfig.getProfile(),Constants.RESOURCE_PREFIX);
3331
-       // 如果是调解书或者调解协议上传到onlyoffice服务器
3332
-        if(annexType != null   && annexType.equals(AnnexTypeEnum.MEDIATE_BOOK.getCode())){
3333
-            JSONArray jsonArray = caseApplicationService.uploadOnlyOffice(annexPath,application.getId());
3334
-            if(jsonArray!=null && jsonArray.size() > 0){
3335
-                    for (Object obj : jsonArray) {
3336
-                        JSONObject jsonObject = (JSONObject) obj;
3337
-                        caseAttach=    MsCaseAttach.builder()
3338
-                                .caseAppliId(application.getId())
3339
-                                .annexName(jsonObject.getString("fileName"))
3340
-                                .annexPath(jsonObject.getString("filePath"))
3341
-                                .annexType(annexType)
3342
-                                .onlyOfficeFileId(jsonObject.getString("fileId"))
3343
-                                .build();
3344
-
3345
-                }
3346
-                //保存到附件表里,先删除之前的在保存
3347
-                msCaseAttachMapper.deleteCaseAttachByCasedIdAndType(caseAttach.getCaseAppliId(), annexType);
3348
-                msCaseAttachMapper.save(caseAttach);
3349
-            }
3350
-
3351
-        }else {
3352
-            caseAttach = MsCaseAttach.builder()
3353
-                    .caseAppliId(application.getId())
3354
-                    .annexName(orgFileName+".docx")
3355
-                    .annexPath(resultFilePath.replace(RuoYiConfig.getProfile(),Constants.RESOURCE_PREFIX))
3356
-                    .annexType(annexType)
3357
-                    .build();
3358
-            // 查找已经存在的附件
3359
-            List<MsCaseAttach> existAttach = msCaseAttachMapper.listCaseAttachByCaseIdAndType(application.getId(), annexType);
3360
-            if(CollectionUtil.isNotEmpty(existAttach)){
3361
-                // todo 对接北明,同步案件状态,删除
3362
-                for (MsCaseAttach msCaseAttach : existAttach) {
3363
-                    if(StrUtil.isEmpty(msCaseAttach.getOtherSysFileId())||StrUtil.isEmpty(msCaseAttach.getAnnexPath())){
3364
-                        continue;
3365
-                    }
3366
-                    beiMingInterfaceService.deleteAttachmentInfo(application.getCaseNum(), msCaseAttach.getOtherSysFileId(), FileUtil.getName(msCaseAttach.getAnnexPath()));
3367
-                }
3368
-            }
3369
-            msCaseAttachMapper.deleteCaseAttachByCasedIdAndType(caseAttach.getCaseAppliId(), annexType);
3370
-            if(StrUtil.isEmpty(application.getCaseSource())) {
3371
-                // 北明推送
3372
-                String path = "/home/ruoyi" + caseAttach.getAnnexPath();
3373
-                File file = new File(path.replace("/profile", "/uploadPath"));
3374
-                MsCaseFileInfo caseFileInfo = beiMingInterfaceService.pushAttachmentInfo(BMUserName, BMPassword, file, BMSyncSource, application.getCaseNum(), AttachmentOperateTypeEnum.ADD, DocumentTypeEnum.EVEDENT_APPLY_BOOK);
3375
-
3376
-                // 更新附件表
3377
-                if (caseFileInfo != null && StrUtil.isNotEmpty(caseFileInfo.getFileId())) {
3378
-                    caseAttach.setOtherSysFileId(caseFileInfo.getFileId());
3379
-                }
3380
-            }
3381
-            msCaseAttachMapper.save(caseAttach);
3382
-        }
3383
-
3384
-    }
3385
-    @Transactional
3386
-    public void createMediateApplication1(MsCaseApplication application, List<MsCaseAffiliate> affiliates, String templatePath, List<String> bookmarkList, List<SysDictData> dictDataList,Integer templateType) {
3387 3157
         // 申请书需要的字段和内容,valueMap<占位符,替换的值>
3388 3158
         Map<String, String> valueMap = new HashMap<>();
3389 3159
         for (SysDictData dictData : dictDataList) {