From 58a5f083fe571245eef14f98422a0cbffeb5ee6a Mon Sep 17 00:00:00 2001 From: 18792927508 <1322446236@qq.com> Date: Thu, 18 Apr 2024 09:36:21 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8A=9F=E8=83=BD=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../mscase/MsCaseApplicationService.java | 10 +- .../impl/MsCaseApplicationServiceImpl.java | 238 +----------------- 2 files changed, 6 insertions(+), 242 deletions(-) diff --git a/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/service/mscase/MsCaseApplicationService.java b/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/service/mscase/MsCaseApplicationService.java index 051e931..e20ac23 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/service/mscase/MsCaseApplicationService.java +++ b/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/service/mscase/MsCaseApplicationService.java @@ -103,18 +103,13 @@ public interface MsCaseApplicationService { */ AjaxResult userIdentify(MultipartFile file); + /** * 生成调解申请书 * @param req * @return */ AjaxResult generateApplication(MsCaseApplicationReq req); - /** - * 生成调解申请书 - * @param req - * @return - */ - AjaxResult generateApplication1(MsCaseApplicationReq req); /** * 根据批次号和流程id查找未锁定的案件 @@ -232,8 +227,7 @@ public interface MsCaseApplicationService { * @param bookmarkList 标签 * @param dictDataList 内置字段 */ - void createMediateApplication(MsCaseApplication application, List affiliates, String templatePath, List bookmarkList, List dictDataList, Integer templateType) ; - void createMediateApplication1(MsCaseApplication application, List affiliates, String templatePath, List bookmarkList, List dictDataList, Integer templateType) ; + void createMediateApplication(MsCaseApplication application, List affiliates, String templatePath, List bookmarkList, List dictDataList, Integer templateType) ; /** * 调解书上传到onlyoffice服务器 * @param annexPath diff --git a/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/service/mscase/impl/MsCaseApplicationServiceImpl.java b/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/service/mscase/impl/MsCaseApplicationServiceImpl.java index ff0647b..391c22d 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/service/mscase/impl/MsCaseApplicationServiceImpl.java +++ b/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/service/mscase/impl/MsCaseApplicationServiceImpl.java @@ -683,7 +683,7 @@ public class MsCaseApplicationServiceImpl implements MsCaseApplicationService { // 生成调解申请书 req.setTemplateType(TemplateTypeEnum.PERSON_MEDIATION_APPLICATION.getCode()); req.setTemplateId(String.valueOf(caseApplication.getTemplateId())); - caseApplicationService.generateApplication1(req); + caseApplicationService.generateApplication(req); // 保存案件附件 if (CollectionUtil.isNotEmpty(caseAttachList)) { for (MsCaseAttach caseAttach : caseAttachList) { @@ -1057,7 +1057,7 @@ public class MsCaseApplicationServiceImpl implements MsCaseApplicationService { // 自然人 req.setTemplateType(TemplateTypeEnum.PERSON_MEDIATION_APPLICATION.getCode()); req.setTemplateId(String.valueOf(selectByPrimaryKey.getTemplateId())); - caseApplicationService.generateApplication1(req); + caseApplicationService.generateApplication(req); // 新增日志 CaseLogUtils.insertCaseLog(caseApplication.getId(), 0, "修改案件",null); @@ -1443,85 +1443,6 @@ public class MsCaseApplicationServiceImpl implements MsCaseApplicationService { // MsCaseAffiliate affiliate = affiliateMap.get(application.getId()); // if(affiliate==null){ // continue; -// } - // caseApplicationService.createMediateApplication(application, affiliate, templatePath, bookmarkList,dictDataList,req.getTemplateType()); - - } - }else { - // 单独生成调解申请书 - // 根据案件id查询案件信息 - MsCaseApplication application = msCaseApplicationMapper.selectByPrimaryKey(req.getId()); - // 查询案件关联人员 - List msCaseAffiliates = selectAffliatesByCaseId(req.getId()); - if (application == null || msCaseAffiliates == null) { - throw new ServiceException("该案件不存在"); - } - - caseApplicationService.createMediateApplication(application, msCaseAffiliates, templatePath, bookmarkList,dictDataList,req.getTemplateType()); - } - - - return AjaxResult.success(); - } - /** - * 生成调解申请书 - * @param req - * @return - */ - @Transactional - @Override - public AjaxResult generateApplication1(MsCaseApplicationReq req) { - // 根据模板id查询申请书 - if(req.getTemplateId()==null || req.getTemplateType()==null){ - return AjaxResult.error("模板id不能为空"); - } - TemplateManage templateManage=templateManageMapper.selectByIdAndType(Long.valueOf(req.getTemplateId()),req.getTemplateType()); - if(templateManage==null||StrUtil.isEmpty(templateManage.getTemOrigPath())){ - throw new ServiceException("未找到模板"); - } - String templatePath = "/home/ruoyi" + templateManage.getTemOrigPath(); - templatePath=templatePath.replace("/profile","/uploadPath"); - try { - File file = new File(templatePath); - } catch (Exception e) { - throw new ServiceException("未找到模板"); - } -// // 获取模板中的占位符key - List bookmarkList = getBookmarkByDocx(templatePath); - if (CollectionUtil.isEmpty(bookmarkList)) { - throw new ServiceException("请检查模板是否配置正确,未获取到占位符"); - } - // 在系统表中查询案件内置字段 - SysDictData sysDictData = new SysDictData(); - sysDictData.setDictType("case_built_type"); - List dictDataList = dictDataMapper.selectDictDataList(sysDictData); - if(CollectionUtil.isEmpty(dictDataList)){ - throw new ServiceException("未找到系统内置字段"); - } - // 如果批号不为空,则为批量操作,根据批号查询未锁定的案件 - if(StrUtil.isNotEmpty(req.getBatchNumber())){ - List caseApplicationList=listByBatchNumber(req.getBatchNumber(),req.getCaseFlowId()); - if(CollectionUtil.isEmpty(caseApplicationList)){ - throw new ServiceException("该批次号下未找到案件"); - } - // 案件ids - List caseIds = caseApplicationList.stream().map(MsCaseApplication::getId).collect(Collectors.toList()); - // 根据ids查询案件关联人员 - Example afflicateExample = new Example(MsCaseAffiliate.class); - afflicateExample.createCriteria().andIn("caseAppliId", caseIds); - List affiliateList = msCaseAffiliateMapper.selectByExample(afflicateExample); - if(CollectionUtil.isEmpty(affiliateList)){ - throw new ServiceException("该批次号下未找到案件关联人员"); - } - - Map affiliateMap = affiliateList.stream().collect(Collectors.toMap(MsCaseAffiliate::getCaseAppliId, Function.identity())); - - // 循环生成调解申请书 - for (MsCaseApplication application : caseApplicationList) { - // todo 批量的未改案件相关人员,结构已发生变化 -// MsCaseAffiliate affiliate = affiliateMap.get(application.getId()); -// if(affiliate==null){ -// continue; // } // caseApplicationService.createMediateApplication(application, affiliate, templatePath, bookmarkList,dictDataList,req.getTemplateType()); @@ -1536,7 +1457,7 @@ public class MsCaseApplicationServiceImpl implements MsCaseApplicationService { throw new ServiceException("该案件不存在"); } - caseApplicationService.createMediateApplication1(application, msCaseAffiliates, templatePath, bookmarkList,dictDataList,req.getTemplateType()); + caseApplicationService.createMediateApplication(application, msCaseAffiliates, templatePath, bookmarkList,dictDataList,req.getTemplateType()); } @@ -3175,7 +3096,7 @@ public class MsCaseApplicationServiceImpl implements MsCaseApplicationService { req.setTemplateType(TemplateTypeEnum.MEDIATION_AGREEMENT.getCode()); } - AjaxResult result = caseApplicationService.generateApplication1(req); + AjaxResult result = caseApplicationService.generateApplication(req); // 修改案件结果 application.setMediaResult(req.getMediaResult()); msCaseApplicationMapper.updateByPrimaryKeySelective(application); @@ -3231,159 +3152,8 @@ public class MsCaseApplicationServiceImpl implements MsCaseApplicationService { return nextFlow; } - /** - * 生成调解申请书 - * @param application 案件基本信息 - * @param affiliates 案件相关人员 - * @param templatePath 模板路径 - * @param bookmarkList 标签 - * @param dictDataList 内置字段 - */ @Transactional public void createMediateApplication(MsCaseApplication application, List affiliates, String templatePath, List bookmarkList, List dictDataList,Integer templateType) { - // 申请书需要的字段和内容,valueMap<占位符,替换的值> - Map valueMap = new HashMap<>(); - // 操作人信息 - Map> operatorMap = affiliates.stream().collect(Collectors.groupingBy(MsCaseAffiliate::getOperatorFlag, Collectors.toList())); - // 按角色分类 - Map roleTypeMap = affiliates.stream().collect(Collectors.toMap(MsCaseAffiliate::getRoleType, Function.identity(), (k1, k2) -> k1)); -// Map> roleTypeMap = affiliates.stream().collect(Collectors.groupingBy(MsCaseAffiliate::getRoleType, Collectors.toList())); - - for (SysDictData dictData : dictDataList) { - if (CASE_BASE_COLUMN.contains(dictData.getDictValue())) { - valueMap.put(dictData.getDictLabel(), ObjectFieldUtils.getValue(application, dictData.getDictValue())); - } else { - // todo 相关人员字段,如果有多个申请人,被申请人,模板需要变化,待讨论,暂做成取第一个操作人 - List msCaseAffiliates = operatorMap.get(1); - if(CollectionUtil.isNotEmpty(msCaseAffiliates)) { - Map roleTypeOperatorMap = msCaseAffiliates.stream().collect(Collectors.toMap(MsCaseAffiliate::getRoleType, Function.identity(), (k1, k2) -> k1)); - if(dictData.getDictLabel().contains("被申请人")){ - if(roleTypeOperatorMap.get(3)!=null ) { - valueMap.put(dictData.getDictLabel(), ObjectFieldUtils.getValue(roleTypeOperatorMap.get(3), dictData.getDictValue())); - }else { - valueMap.put(dictData.getDictLabel(), ObjectFieldUtils.getValue(roleTypeMap.get(3), dictData.getDictValue())); - } - }else if(dictData.getDictLabel().contains("被申请人委托代理人")){ - if(roleTypeOperatorMap.get(4)!=null ) { - valueMap.put(dictData.getDictLabel(), ObjectFieldUtils.getValue(roleTypeOperatorMap.get(4), dictData.getDictValue())); - }else { - valueMap.put(dictData.getDictLabel(), ObjectFieldUtils.getValue(roleTypeMap.get(4), dictData.getDictValue())); - } - }else if(dictData.getDictLabel().contains("申请人") - || dictData.getDictLabel().equals("统一社会信用代码") - || dictData.getDictLabel().equals("法定代表人") - ){ - if(roleTypeOperatorMap.get(1)!=null ) { - valueMap.put(dictData.getDictLabel(), ObjectFieldUtils.getValue(roleTypeOperatorMap.get(1), dictData.getDictValue())); - }else { - valueMap.put(dictData.getDictLabel(), ObjectFieldUtils.getValue(roleTypeMap.get(1), dictData.getDictValue())); - } - }else if(dictData.getDictLabel().contains("委托代理人")){ - if(roleTypeOperatorMap.get(2)!=null ) { - valueMap.put(dictData.getDictLabel(), ObjectFieldUtils.getValue(roleTypeOperatorMap.get(2), dictData.getDictValue())); - }else { - valueMap.put(dictData.getDictLabel(), ObjectFieldUtils.getValue(roleTypeMap.get(2), dictData.getDictValue())); - } - } - } - } - - } - // 书签对应值 - Map bookmarkValueMap = new HashMap<>(); - // 读取调节申请书,找到占位符,替换值 - // 遍历书签,给书签赋值 - replaceBookmark(bookmarkList, bookmarkValueMap, valueMap); - // 申请书生成时间 - LocalDate now = LocalDate.now(); - int year = now.getYear(); - DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy年MM月dd日"); - // 格式化当前日期 - String formattedDate = now.format(formatter); - bookmarkValueMap.put("日期", formattedDate); - - String month = String.format("%02d", now.getMonthValue()); - String day = String.format("%02d", now.getDayOfMonth()); - String saveFolderPath = RuoYiConfig.getUploadPath()+"/"+ year + "/" + month + "/" + day; - Integer annexType = null; - if(templateType==null - || templateType.equals(TemplateTypeEnum.MEDIATION_APPLICATION.getCode()) - || templateType.equals(TemplateTypeEnum.PERSON_MEDIATION_APPLICATION.getCode()) ){ - // 调解申请书 - annexType = AnnexTypeEnum.MEDIATION_APPLICATION.getCode(); - }else if(templateType.equals(TemplateTypeEnum.MEDIATION_AGREEMENT.getCode()) - || templateType.equals(TemplateTypeEnum.MEDIATE_BOOK.getCode()) ){ - // 调解书和解协议 - annexType = AnnexTypeEnum.MEDIATE_BOOK.getCode(); - } - - String orgFileName = "调解申请书"; - if (annexType != null && annexType.equals(AnnexTypeEnum.MEDIATE_BOOK.getCode())) { - orgFileName = "调解书"; - } - String fileName = UUID.randomUUID().toString().replace("-", "")+orgFileName + ".docx"; - String resultFilePath = saveFolderPath + "/" + fileName; - // 将word中的标签替换掉,生成新的word - wordChangeText(templatePath, bookmarkValueMap,saveFolderPath,resultFilePath); - - MsCaseAttach caseAttach = null; - String annexPath=resultFilePath.replace(RuoYiConfig.getProfile(),Constants.RESOURCE_PREFIX); - // 如果是调解书或者调解协议上传到onlyoffice服务器 - if(annexType != null && annexType.equals(AnnexTypeEnum.MEDIATE_BOOK.getCode())){ - JSONArray jsonArray = caseApplicationService.uploadOnlyOffice(annexPath,application.getId()); - if(jsonArray!=null && jsonArray.size() > 0){ - for (Object obj : jsonArray) { - JSONObject jsonObject = (JSONObject) obj; - caseAttach= MsCaseAttach.builder() - .caseAppliId(application.getId()) - .annexName(jsonObject.getString("fileName")) - .annexPath(jsonObject.getString("filePath")) - .annexType(annexType) - .onlyOfficeFileId(jsonObject.getString("fileId")) - .build(); - - } - //保存到附件表里,先删除之前的在保存 - msCaseAttachMapper.deleteCaseAttachByCasedIdAndType(caseAttach.getCaseAppliId(), annexType); - msCaseAttachMapper.save(caseAttach); - } - - }else { - caseAttach = MsCaseAttach.builder() - .caseAppliId(application.getId()) - .annexName(orgFileName+".docx") - .annexPath(resultFilePath.replace(RuoYiConfig.getProfile(),Constants.RESOURCE_PREFIX)) - .annexType(annexType) - .build(); - // 查找已经存在的附件 - List existAttach = msCaseAttachMapper.listCaseAttachByCaseIdAndType(application.getId(), annexType); - if(CollectionUtil.isNotEmpty(existAttach)){ - // todo 对接北明,同步案件状态,删除 - for (MsCaseAttach msCaseAttach : existAttach) { - if(StrUtil.isEmpty(msCaseAttach.getOtherSysFileId())||StrUtil.isEmpty(msCaseAttach.getAnnexPath())){ - continue; - } - beiMingInterfaceService.deleteAttachmentInfo(application.getCaseNum(), msCaseAttach.getOtherSysFileId(), FileUtil.getName(msCaseAttach.getAnnexPath())); - } - } - msCaseAttachMapper.deleteCaseAttachByCasedIdAndType(caseAttach.getCaseAppliId(), annexType); - if(StrUtil.isEmpty(application.getCaseSource())) { - // 北明推送 - String path = "/home/ruoyi" + caseAttach.getAnnexPath(); - File file = new File(path.replace("/profile", "/uploadPath")); - MsCaseFileInfo caseFileInfo = beiMingInterfaceService.pushAttachmentInfo(BMUserName, BMPassword, file, BMSyncSource, application.getCaseNum(), AttachmentOperateTypeEnum.ADD, DocumentTypeEnum.EVEDENT_APPLY_BOOK); - - // 更新附件表 - if (caseFileInfo != null && StrUtil.isNotEmpty(caseFileInfo.getFileId())) { - caseAttach.setOtherSysFileId(caseFileInfo.getFileId()); - } - } - msCaseAttachMapper.save(caseAttach); - } - - } - @Transactional - public void createMediateApplication1(MsCaseApplication application, List affiliates, String templatePath, List bookmarkList, List dictDataList,Integer templateType) { // 申请书需要的字段和内容,valueMap<占位符,替换的值> Map valueMap = new HashMap<>(); for (SysDictData dictData : dictDataList) {