package cn.cslg.pas.service.business; import cn.cslg.pas.common.dto.business.ReportAffairDTO; import cn.cslg.pas.common.dto.invalidDTO.*; import cn.cslg.pas.common.model.cronModel.Personnel; import cn.cslg.pas.common.model.cronModel.PersonnelVO; import cn.cslg.pas.common.model.cronModel.SystemFile; import cn.cslg.pas.common.model.report.ExtraEmailDTO; import cn.cslg.pas.common.model.report.MailMessageDTO; import cn.cslg.pas.common.utils.CacheUtils; import cn.cslg.pas.common.utils.LoginUtils; import cn.cslg.pas.common.vo.business.CronVO; import cn.cslg.pas.common.vo.invalidVO.*; import cn.cslg.pas.domain.BaseEntity; import cn.cslg.pas.domain.business.*; import cn.cslg.pas.exception.XiaoShiException; import cn.cslg.pas.mapper.ReportAffairCasePhaseMapper; import cn.cslg.pas.mapper.ReportAffairMapper; import cn.cslg.pas.mapper.ReportProjectMapper; import cn.cslg.pas.service.MailSendService; import cn.cslg.pas.service.common.FileManagerService; import cn.cslg.pas.service.permissions.PermissionService; import cn.cslg.pas.service.report.SendReportMailService; import com.alibaba.fastjson.JSONObject; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang3.ObjectUtils; import org.apache.commons.lang3.StringUtils; import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Lazy; import org.springframework.stereotype.Service; import org.springframework.util.CollectionUtils; import org.springframework.web.bind.annotation.RequestBody; import java.io.IOException; import java.util.ArrayList; import java.util.List; import java.util.stream.Collectors; /** * 报告事务Service层 * * @Author xiexiang * @Date 2023/12/23 */ @Slf4j @Service public class ReportAffairService extends ServiceImpl { @Autowired private CacheUtils cacheUtils; @Autowired private LoginUtils loginUtils; @Autowired private AssoReportAffairFileService assoReportAffairFileService; @Autowired private FileManagerService fileManagerService; @Autowired @Lazy private InvalidRequestFileService invalidRequestFileService; @Autowired private PermissionService permissionService; @Autowired @Lazy private OralTrailService oralTrailService; @Autowired @Lazy private InvalidDecisionFileService invalidDecisionFileService; @Autowired @Lazy private AdminProceedService adminProceedService; @Autowired @Lazy private OtherDocumentsService otherDocumentsService; @Autowired private CourtOrderService courtOrderService; @Autowired private SendReportMailService sendReportMailService; @Autowired private MailSendService mailSendService; @Autowired private ReportAffairCasePhaseMapper reportAffairCasePhaseMapper; @Autowired private AssoInvalidDecisionCronService assoInvalidDecisionCronService; @Autowired private SystemDictService systemDictService; @Autowired private AssoReportCronService assoReportCronService; @Autowired private ReportProjectMapper reportProjectMapper; /** * 创建报告事务 * * @param reportAffairDTO */ public Integer addReportAffair(ReportAffairDTO reportAffairDTO) { PersonnelVO personnelVO = cacheUtils.getLoginUser(loginUtils.getId()); if (reportAffairDTO != null) { ReportAffair reportAffair = new ReportAffair(); BeanUtils.copyProperties(reportAffairDTO, reportAffair); reportAffair.setCreateId(personnelVO.getId()); reportAffair.insert(); return reportAffair.getId(); } else { throw new XiaoShiException("入参为空"); } } /** * 删除报告事务 * @param ids */ public void delete(List ids) { for (Integer id : ids) { LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); queryWrapper.eq(ReportAffair::getId, id); ReportAffair reportAffair = this.getOne(queryWrapper, false); if (reportAffair != null) { //删除事务关联的文件 LambdaQueryWrapper queryWrapper2 = new LambdaQueryWrapper<>(); queryWrapper2.eq(AssoReportAffairFile::getReportAffairId, id); assoReportAffairFileService.remove(queryWrapper2); Integer assoCasePhaseId = reportAffair.getAssoCasePhaseId(); ReportAffairCasePhase casePhase = reportAffairCasePhaseMapper.selectById(assoCasePhaseId); Integer flowType = casePhase.getFlowType(); // 根据类型删除对应信息 if (flowType.equals(1)) { //无效请求书 LambdaQueryWrapper queryWrapper1 = new LambdaQueryWrapper<>(); queryWrapper1.eq(InvalidRequestFile::getReportAffairId, id); invalidRequestFileService.remove(queryWrapper1); } else if (flowType.equals(6) || flowType.equals(31)) {//口审记录 口审通知书 LambdaQueryWrapper queryWrapper1 = new LambdaQueryWrapper<>(); queryWrapper1.eq(OralTrail::getReportAffairId, id); oralTrailService.remove(queryWrapper1); Integer projectId = reportAffair.getProjectId(); if (assoCasePhaseId.equals(31)) { oralTrailService.updateParticipator(projectId, assoCasePhaseId); } } else if (flowType.equals(7)) {//无效决定书 Integer projectId = reportAffair.getProjectId(); //删除报告中的发文序号 ReportProject reportProject = reportProjectMapper.selectOne(new LambdaQueryWrapper() .eq(ReportProject::getProjectId, projectId)); reportProject.setId(reportProject.getId()); reportProject.setIssueNumber(null); reportProject.updateById(); //删除报告无效结果与报告关联 LambdaQueryWrapper reportCronWrapper = new LambdaQueryWrapper<>(); reportCronWrapper.eq(AssoReportCron::getProjectId, projectId); assoReportCronService.remove(reportCronWrapper); //删除无效决定书和无效结果关联 InvalidDecisionFile decisionFile = invalidDecisionFileService.getOne(new LambdaQueryWrapper() .eq(InvalidDecisionFile::getReportAffairId, id)); LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); wrapper.eq(AssoInvalidDecisionCron::getInvalidDecisionId, decisionFile.getId()); assoInvalidDecisionCronService.remove(wrapper); //无效决定书 LambdaQueryWrapper queryWrapper1 = new LambdaQueryWrapper<>(); queryWrapper1.eq(InvalidDecisionFile::getReportAffairId, id); invalidDecisionFileService.remove(queryWrapper1); } else if (flowType.equals(16) || flowType.equals(26)) {//行政诉讼判决书 LambdaQueryWrapper queryWrapper1 = new LambdaQueryWrapper<>(); queryWrapper1.eq(CourtOrder::getReportAffairId, id); courtOrderService.remove(queryWrapper1); } else if (flowType.equals(17) || flowType.equals(27) || flowType.equals(28)) {//其他文档 LambdaQueryWrapper queryWrapper1 = new LambdaQueryWrapper<>(); queryWrapper1.eq(OtherDocuments::getReportAffairId, id); otherDocumentsService.remove(queryWrapper1); } this.removeById(id); //判断是否需要同步更新报告官限 String deadline = casePhase.getCalOfficialDeadline(); if (StringUtils.isNotEmpty(deadline) || assoCasePhaseId.equals(31)) { invalidRequestFileService.getCommonMethod(reportAffair.getProjectId()); } } } } /** * 查询报告事务 * * @param queryReportAffairDTO */ public List queryReportAffair(QueryReportAffairDTO queryReportAffairDTO) { Integer projectId = queryReportAffairDTO.getProjectId(); List reportAffairVOS = new ArrayList<>(); //判空 if (projectId == null) { throw new XiaoShiException("projectId为空"); } //根据报告id查询事务 LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); queryWrapper.eq(ReportAffair::getProjectId, projectId) .orderByAsc(ReportAffair::getOccurredTime); List reportAffairs = this.list(queryWrapper); if (reportAffairs.isEmpty()) { return reportAffairVOS; } reportAffairVOS = this.loadReportAffairVOS(reportAffairs); return reportAffairVOS; } public List loadReportAffairVOS(List reportAffairs) { List collect = reportAffairs.stream().map(ReportAffair::getAssoCasePhaseId).collect(Collectors.toList()); List phaseList = new ArrayList<>(); if (!CollectionUtils.isEmpty(collect)) { List phases = reportAffairCasePhaseMapper.selectList(new LambdaQueryWrapper() .in(BaseEntity::getId, collect)); phaseList.addAll(phases); } List reportAffairVOS = new ArrayList<>(); reportAffairs.forEach(item -> { ReportAffairVO reportAffairVO = new ReportAffairVO(); BeanUtils.copyProperties(item, reportAffairVO); ReportAffairCasePhase casePhase = phaseList.stream().filter(i -> i.getId().equals(item.getAssoCasePhaseId())).findFirst().orElse(null); if (ObjectUtils.isNotEmpty(casePhase)) { Integer type = casePhase.getFlowType(); reportAffairVO.setFlowName(casePhase.getFlowName()); reportAffairVO.setFlowType(type); reportAffairVO.setCasePhase(casePhase.getCasePhase()); reportAffairVO.setCaseChildPhase(casePhase.getCaseChildPhase()); reportAffairVO.setDocumentType(casePhase.getDocumentType()); if (type.equals(6) || type.equals(31)) {//6 口审记录 this.loadOralTrail(reportAffairVO); } else if (type.equals(1)) {//1 无效请求书 this.loadInvalidRequestFile(reportAffairVO); } else if (type.equals(5)) {//5 陈述意见书 this.loadStateOpinion(reportAffairVO); } else if (type.equals(7)) {//7 无效决定书 this.loadInvalidDecisionFile(reportAffairVO); } else if (type.equals(8) || type.equals(18)) {//8 18 原告起诉状 上诉人上诉状 this.loadAdminProceed(reportAffairVO); } else if (type.equals(16) || type.equals(26)) {//16 26 行政诉讼判决书 this.loadJudgment(reportAffairVO); } else if (type.equals(2)) {//2 权要修改记录 this.loadClaimHistory(reportAffairVO); } else if (type.equals(3)) {//3 补充证据及理由 this.loadSupplyEvidence(reportAffairVO); } else if (type.equals(17) || type.equals(27) || type.equals(28)) {//17 27 28其他文档 this.loadOtherDocuments(reportAffairVO); reportAffairVO.setCaseChildPhase(item.getCaseChildPhase()); reportAffairVO.setDocumentType(item.getDocumentType()); } } reportAffairVOS.add(reportAffairVO); }); if (!reportAffairVOS.isEmpty()) { //装载文件信息 this.loadSystemFile(reportAffairVOS); //装载创建人名 this.loadCreateName(reportAffairVOS); List affairVOS = reportAffairVOS.stream().filter(i -> i.getFlowType().equals(7)).collect(Collectors.toList()); if (!CollectionUtils.isEmpty(affairVOS)) { //装载无效决定书与无效结果关联 this.loadAssoInvalidDecisionCron(affairVOS); } } return reportAffairVOS; } /** * 装载文件 * * @param reportAffairVOS */ public void loadSystemFile(List reportAffairVOS) { reportAffairVOS.forEach(item -> { Integer reportAffairId = item.getId(); List systemFiles = new ArrayList<>(); LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); queryWrapper.eq(AssoReportAffairFile::getReportAffairId, reportAffairId); List files = assoReportAffairFileService.list(queryWrapper); if (!files.isEmpty()) { List fileGuids = files.stream().map(AssoReportAffairFile::getFileGuid).collect(Collectors.toList()); //根据fileGuids查询文件信息 //查询文件 if (fileGuids.size() != 0) { try { String res = fileManagerService.getSystemFileFromFMS(fileGuids); if (res != null && !res.trim().equals("")) { systemFiles = JSONObject.parseArray(res, SystemFile.class); } } catch (Exception e) { throw new XiaoShiException("查询文件详情错误"); } } } item.setSystemFileList(systemFiles); }); } /** * 装载无效请求书 * * @param reportAffairVO */ public void loadInvalidRequestFile(ReportAffairVO reportAffairVO) { Integer reportAffairId = reportAffairVO.getId(); InvalidRequestFileVO invalidRequestFileVO = invalidRequestFileService.getInvalidRequestFileVO(reportAffairId); reportAffairVO.setInvalidRequestFileVO(invalidRequestFileVO); } public void loadCreateName(List reportAffairVOS) { List createIds = new ArrayList<>(); reportAffairVOS.forEach(item -> { if (item.getCreateId() != null) { createIds.add(item.getCreateId()); } }); List personnels = new ArrayList<>(); //查询创建人名称 if (createIds.size() != 0) { try { String res = permissionService.getPersonnelByIdsFromPCS(createIds); JSONObject jsonObject = JSONObject.parseObject(res); personnels = JSONObject.parseArray(jsonObject.getString("data"), Personnel.class); } catch (Exception e) { } } for (ReportAffairVO reportAffairVO : reportAffairVOS) { Personnel personnel = personnels.stream().filter(item -> item.getId().equals(reportAffairVO.getCreateId())).findFirst().orElse(null); if (personnel != null) { reportAffairVO.setCreateName(personnel.getPersonnelName()); } } } /** * 装载口审记录 * * @param reportAffairVO */ public void loadOralTrail(ReportAffairVO reportAffairVO) { Integer reportAffairId = reportAffairVO.getId(); OralTrailVO oralTrailVO = oralTrailService.getOralTrailVO(reportAffairId); reportAffairVO.setOralTrailVO(oralTrailVO); } /** * 装载无效决定书 * * @param reportAffairVO */ public void loadInvalidDecisionFile(ReportAffairVO reportAffairVO) { Integer reportAffairId = reportAffairVO.getId(); InvalidDecisionFileVO invalidDecisionFileVO = invalidDecisionFileService.getInvalidDecisionFile(reportAffairId); reportAffairVO.setInvalidDecisionFileVO(invalidDecisionFileVO); } /** * 装载无效决定书与无效结果关联 * @param reportAffairVOS */ public void loadAssoInvalidDecisionCron(List reportAffairVOS) { if (!CollectionUtils.isEmpty(reportAffairVOS)) { List decisionFileVOS = reportAffairVOS.stream().map(ReportAffairVO::getInvalidDecisionFileVO).collect(Collectors.toList()); List invalidDecisionIds = decisionFileVOS.stream().map(InvalidDecisionFileVO::getInvalidDecisionFileId).collect(Collectors.toList()); //查询核心结论 LambdaQueryWrapper reportCronLambdaQueryWrapper = new LambdaQueryWrapper<>(); reportCronLambdaQueryWrapper.in(AssoInvalidDecisionCron::getInvalidDecisionId, invalidDecisionIds); List crons = assoInvalidDecisionCronService.list(reportCronLambdaQueryWrapper); List systemDictList = new ArrayList<>(); if (!CollectionUtils.isEmpty(crons)) { LambdaQueryWrapper systemDictLambdaQueryWrapper = new LambdaQueryWrapper<>(); systemDictLambdaQueryWrapper.eq(SystemDict::getGroupType, "ASSESS"); systemDictList = systemDictService.list(systemDictLambdaQueryWrapper); } for (InvalidDecisionFileVO decisionFileVO : decisionFileVOS) { List reCronIds = new ArrayList<>(); List reCronNames = new ArrayList<>(); if (!CollectionUtils.isEmpty(crons)) { List decisionCrons = crons.stream().filter(item -> item.getInvalidDecisionId().equals(decisionFileVO.getInvalidDecisionFileId())).collect(Collectors.toList()); if (!CollectionUtils.isEmpty(decisionCrons)) { //过滤出事件 List cronIds = decisionCrons.stream().map(AssoInvalidDecisionCron::getCronId).collect(Collectors.toList()); List systemDicts = systemDictList.stream().filter(item -> cronIds.contains(Integer.parseInt(item.getValue()))).collect(Collectors.toList()); systemDicts.forEach(item -> { reCronIds.add(Integer.parseInt(item.getValue())); reCronNames.add(item.getLabel()); }); } } decisionFileVO.setCronIds(reCronIds); decisionFileVO.setCronNames(reCronNames); } } } /** * 装载行政诉讼书 * * @param reportAffairVO */ public void loadAdminProceed(ReportAffairVO reportAffairVO) { Integer reportAffairId = reportAffairVO.getId(); AdminProceedVO adminProceedVO = adminProceedService.getAdminProceed(reportAffairId); reportAffairVO.setAdminProceedVO(adminProceedVO); } /** * 上传陈述意见书 * @param addStateOpinionDTO * @return */ public Integer addStateOpinion(AddStateOpinionDTO addStateOpinionDTO){ if (addStateOpinionDTO == null) { throw new XiaoShiException("入参为空"); } Integer projectId = addStateOpinionDTO.getProjectId(); if (projectId == null) { throw new XiaoShiException("报告id为空"); } if (ObjectUtils.isEmpty(addStateOpinionDTO.getAssoCasePhaseId())) { throw new XiaoShiException("案件流程阶段id为空"); } //1. 首先上传报告事务,拿到报告事务id ReportAffairDTO reportAffairDTO = new ReportAffairDTO(); reportAffairDTO.setProjectId(projectId); //发生时间是无效请求日 reportAffairDTO.setOccurredTime(addStateOpinionDTO.getStateReplyTime()); //备注 reportAffairDTO.setDescription(addStateOpinionDTO.getDescription()); reportAffairDTO.setAssoCasePhaseId(addStateOpinionDTO.getAssoCasePhaseId()); Integer reportAffairId = this.addReportAffair(reportAffairDTO); if (reportAffairId == null) { throw new XiaoShiException("上传报告事务失败"); } //3. 添加报告事务与文件关联 List fileGuids = addStateOpinionDTO.getFileGuids(); if (fileGuids != null && !fileGuids.isEmpty()) { List assoReportAffairFiles = new ArrayList<>(); fileGuids.forEach(item -> { AssoReportAffairFile assoReportAffairFile = new AssoReportAffairFile(); assoReportAffairFile.setReportAffairId(reportAffairId); assoReportAffairFile.setFileGuid(item); assoReportAffairFiles.add(assoReportAffairFile); }); assoReportAffairFileService.saveBatch(assoReportAffairFiles); } if (addStateOpinionDTO.getIfSendEmail()) { sendReportMailService.finalSendEmail(projectId, fileGuids, addStateOpinionDTO.getExtraEmailDTOS()); } return reportAffairId; } /** * 更新陈述意见 * @param updateStateOpinionDTO * @return */ public Integer updateStateOpinion(UpdateStateOpinionDTO updateStateOpinionDTO){ if (updateStateOpinionDTO == null) { throw new XiaoShiException("入参为空"); } Integer projectId = updateStateOpinionDTO.getProjectId(); Integer reportAffairId = updateStateOpinionDTO.getStateOpinionId(); if (reportAffairId == null) { throw new XiaoShiException("reportAffairId为空"); } if (projectId == null) { throw new XiaoShiException("报告id为空"); } if (ObjectUtils.isEmpty(updateStateOpinionDTO.getAssoCasePhaseId())) { throw new XiaoShiException("案件流程阶段id为空"); } //2. 拿到报告事务id,获取报告事务 ReportAffair reportAffair = this.getById(reportAffairId); reportAffair.setProjectId(projectId); //发生时间是无效请求日 reportAffair.setOccurredTime(updateStateOpinionDTO.getStateReplyTime()); //备注 reportAffair.setDescription(updateStateOpinionDTO.getDescription()); reportAffair.setAssoCasePhaseId(updateStateOpinionDTO.getAssoCasePhaseId()); reportAffair.updateById(); //3. 更新报告事务与文件关联 List fileGuids = updateStateOpinionDTO.getFileGuids(); assoReportAffairFileService.updateAffairFile(reportAffairId, fileGuids); if (updateStateOpinionDTO.getIfSendEmail()) { sendReportMailService.finalSendEmail(projectId, fileGuids, updateStateOpinionDTO.getExtraEmailDTOS()); } return reportAffairId; } /** * 装载陈述意见书 * * @param reportAffairVO */ public void loadStateOpinion(ReportAffairVO reportAffairVO) { Integer reportAffairId = reportAffairVO.getId(); StateOpinionVO stateOpinionVO = new StateOpinionVO(); ReportAffair reportAffair = this.getById(reportAffairId); stateOpinionVO.setStateOpinionId(reportAffairId); stateOpinionVO.setDescription(reportAffair.getDescription()); stateOpinionVO.setStateReplyTime(reportAffair.getOccurredTime()); stateOpinionVO.setProjectId(reportAffair.getProjectId()); reportAffairVO.setStateOpinionVO(stateOpinionVO); } /** * 装载行政诉讼判决书 * * @param reportAffairVO */ public void loadJudgment(ReportAffairVO reportAffairVO) { Integer reportAffairId = reportAffairVO.getId(); JudgementVO judgementVO = adminProceedService.getJudgment(reportAffairId); //获取判决书结论 List courtOrders = courtOrderService.list(new LambdaQueryWrapper() .eq(CourtOrder::getReportAffairId, reportAffairId) .orderByDesc(BaseEntity::getId)); if (!CollectionUtils.isEmpty(courtOrders)) { CourtOrder courtOrder = courtOrders.get(0); judgementVO.setConclusion(courtOrder.getConclusion()); } reportAffairVO.setJudgementVO(judgementVO); } /** * 上传权要修改记录 * @param addClaimHistoryDTO * @return */ public Integer addClaimHistory(AddClaimHistoryDTO addClaimHistoryDTO){ if (addClaimHistoryDTO == null) { throw new XiaoShiException("入参为空"); } Integer projectId = addClaimHistoryDTO.getProjectId(); if (projectId == null) { throw new XiaoShiException("报告id为空"); } if (ObjectUtils.isEmpty(addClaimHistoryDTO.getAssoCasePhaseId())) { throw new XiaoShiException("案件流程阶段id为空"); } //1. 首先上传报告事务,拿到报告事务id ReportAffairDTO reportAffairDTO = new ReportAffairDTO(); reportAffairDTO.setProjectId(projectId); //发生时间是无效请求日 reportAffairDTO.setOccurredTime(addClaimHistoryDTO.getClaimHistoryTime()); //备注 reportAffairDTO.setDescription(addClaimHistoryDTO.getDescription()); reportAffairDTO.setAssoCasePhaseId(addClaimHistoryDTO.getAssoCasePhaseId()); Integer reportAffairId = this.addReportAffair(reportAffairDTO); if (reportAffairId == null) { throw new XiaoShiException("上传报告事务失败"); } //3. 添加报告事务与文件关联 List fileGuids = addClaimHistoryDTO.getFileGuids(); if (fileGuids != null && !fileGuids.isEmpty()) { List assoReportAffairFiles = new ArrayList<>(); fileGuids.forEach(item -> { AssoReportAffairFile assoReportAffairFile = new AssoReportAffairFile(); assoReportAffairFile.setReportAffairId(reportAffairId); assoReportAffairFile.setFileGuid(item); assoReportAffairFiles.add(assoReportAffairFile); }); assoReportAffairFileService.saveBatch(assoReportAffairFiles); } if (addClaimHistoryDTO.getIfSendEmail()) { sendReportMailService.finalSendEmail(projectId, fileGuids, addClaimHistoryDTO.getExtraEmailDTOS()); } return reportAffairId; } /** * 更新权要修改历史 * @param updateClaimHistoryDTO * @return */ public Integer updateClaimHistory(UpdateClaimHistoryDTO updateClaimHistoryDTO){ if (updateClaimHistoryDTO == null) { throw new XiaoShiException("入参为空"); } Integer projectId = updateClaimHistoryDTO.getProjectId(); Integer reportAffairId = updateClaimHistoryDTO.getClaimHistoryId(); if (reportAffairId == null) { throw new XiaoShiException("reportAffairId为空"); } if (projectId == null) { throw new XiaoShiException("报告id为空"); } if (ObjectUtils.isEmpty(updateClaimHistoryDTO.getAssoCasePhaseId())) { throw new XiaoShiException("案件流程阶段id为空"); } //2. 拿到报告事务id,获取报告事务 ReportAffair reportAffair = this.getById(reportAffairId); reportAffair.setProjectId(projectId); //发生时间是无效请求日 reportAffair.setOccurredTime(updateClaimHistoryDTO.getClaimHistoryTime()); //备注 reportAffair.setDescription(updateClaimHistoryDTO.getDescription()); reportAffair.setAssoCasePhaseId(updateClaimHistoryDTO.getAssoCasePhaseId()); reportAffair.updateById(); //3. 更新报告事务与文件关联 List fileGuids = updateClaimHistoryDTO.getFileGuids(); assoReportAffairFileService.updateAffairFile(reportAffairId, fileGuids); if (updateClaimHistoryDTO.getIfSendEmail()) { sendReportMailService.finalSendEmail(projectId, fileGuids, updateClaimHistoryDTO.getExtraEmailDTOS()); } return reportAffairId; } /** * 上传补充证据及理由 * @param addSupplyEvidenceDTO * @return */ public Integer addSupplyEvidence(AddSupplyEvidenceDTO addSupplyEvidenceDTO){ if (addSupplyEvidenceDTO == null) { throw new XiaoShiException("入参为空"); } Integer projectId = addSupplyEvidenceDTO.getProjectId(); if (projectId == null) { throw new XiaoShiException("报告id为空"); } if (ObjectUtils.isEmpty(addSupplyEvidenceDTO.getAssoCasePhaseId())) { throw new XiaoShiException("案件流程阶段id为空"); } //1. 首先上传报告事务,拿到报告事务id ReportAffairDTO reportAffairDTO = new ReportAffairDTO(); reportAffairDTO.setProjectId(projectId); //发生时间是无效请求日 reportAffairDTO.setOccurredTime(addSupplyEvidenceDTO.getSupplyEvidenceTime()); //备注 reportAffairDTO.setDescription(addSupplyEvidenceDTO.getDescription()); reportAffairDTO.setAssoCasePhaseId(addSupplyEvidenceDTO.getAssoCasePhaseId()); Integer reportAffairId = this.addReportAffair(reportAffairDTO); if (reportAffairId == null) { throw new XiaoShiException("上传报告事务失败"); } //3. 添加报告事务与文件关联 List fileGuids = addSupplyEvidenceDTO.getFileGuids(); if (fileGuids != null && !fileGuids.isEmpty()) { List assoReportAffairFiles = new ArrayList<>(); fileGuids.forEach(item -> { AssoReportAffairFile assoReportAffairFile = new AssoReportAffairFile(); assoReportAffairFile.setReportAffairId(reportAffairId); assoReportAffairFile.setFileGuid(item); assoReportAffairFiles.add(assoReportAffairFile); }); assoReportAffairFileService.saveBatch(assoReportAffairFiles); } if (addSupplyEvidenceDTO.getIfSendEmail()) { sendReportMailService.finalSendEmail(projectId, fileGuids, addSupplyEvidenceDTO.getExtraEmailDTOS()); } return reportAffairId; } /** * 更新补充证据及理由 * @param updateSupplyEvidenceDTO * @return */ public Integer updateSupplyEvidence(UpdateSupplyEvidenceDTO updateSupplyEvidenceDTO){ if (updateSupplyEvidenceDTO == null) { throw new XiaoShiException("入参为空"); } Integer projectId = updateSupplyEvidenceDTO.getProjectId(); Integer reportAffairId = updateSupplyEvidenceDTO.getSupplyEvidenceId(); if (reportAffairId == null) { throw new XiaoShiException("reportAffairId为空"); } if (projectId == null) { throw new XiaoShiException("报告id为空"); } if (ObjectUtils.isEmpty(updateSupplyEvidenceDTO.getAssoCasePhaseId())) { throw new XiaoShiException("案件流程阶段id为空"); } //2. 拿到报告事务id,获取报告事务 ReportAffair reportAffair = this.getById(reportAffairId); reportAffair.setProjectId(projectId); //发生时间是无效请求日 reportAffair.setOccurredTime(updateSupplyEvidenceDTO.getSupplyEvidenceTime()); //备注 reportAffair.setDescription(updateSupplyEvidenceDTO.getDescription()); reportAffair.setAssoCasePhaseId(updateSupplyEvidenceDTO.getAssoCasePhaseId()); reportAffair.updateById(); //3. 更新报告事务与文件关联 List fileGuids = updateSupplyEvidenceDTO.getFileGuids(); assoReportAffairFileService.updateAffairFile(reportAffairId, fileGuids); if (updateSupplyEvidenceDTO.getIfSendEmail()) { sendReportMailService.finalSendEmail(projectId, fileGuids, updateSupplyEvidenceDTO.getExtraEmailDTOS()); } return reportAffairId; } /** * 装载权利要求修改记录 * @param reportAffairVO */ public void loadClaimHistory(ReportAffairVO reportAffairVO) { Integer reportAffairId = reportAffairVO.getId(); ClaimHistoryVO claimHistoryVO = new ClaimHistoryVO(); ReportAffair reportAffair = this.getById(reportAffairId); claimHistoryVO.setClaimHistoryId(reportAffairId); claimHistoryVO.setDescription(reportAffair.getDescription()); claimHistoryVO.setClaimHistoryTime(reportAffair.getOccurredTime()); claimHistoryVO.setProjectId(reportAffair.getProjectId()); reportAffairVO.setClaimHistoryVO(claimHistoryVO); } /** * 装载补充证据及理由 * @param reportAffairVO */ public void loadSupplyEvidence(ReportAffairVO reportAffairVO) { Integer reportAffairId = reportAffairVO.getId(); SupplyEvidenceVO supplyEvidenceVO = new SupplyEvidenceVO(); ReportAffair reportAffair = this.getById(reportAffairId); supplyEvidenceVO.setSupplyEvidenceId(reportAffairId); supplyEvidenceVO.setDescription(reportAffair.getDescription()); supplyEvidenceVO.setSupplyEvidenceTime(reportAffair.getOccurredTime()); supplyEvidenceVO.setProjectId(reportAffair.getProjectId()); reportAffairVO.setSupplyEvidenceVO(supplyEvidenceVO); } /** * 装载其他文档 * @param reportAffairVO */ public void loadOtherDocuments(ReportAffairVO reportAffairVO) { Integer reportAffairId = reportAffairVO.getId(); OtherDocumentsVO otherDocumentsVO = otherDocumentsService.getOtherDocuments(reportAffairId); reportAffairVO.setOtherDocumentsVO(otherDocumentsVO); } /** * 添加案件文档 * 详情有以下流程案件添加接口: * 添加请求人意见陈述书 添加合议组无效宣告受理通知书 添加原告意见陈述书 添加原告证据 添加第三人意见陈述 * 添加法院行政诉讼传票 添加法院转送文件 添加上诉人意见陈述 添加上诉人证据 添加第三人意见 添加被上诉人意见 * 添加法院转送文件 添加法院行政诉讼传票 * @param vo * @return */ public Integer addReportAffairCase(ReportAffairCaseDTO vo){ if (ObjectUtils.isEmpty(vo)) { throw new XiaoShiException("入参为空"); } Integer projectId = vo.getProjectId(); if (projectId == null) { throw new XiaoShiException("报告id为空"); } if (ObjectUtils.isEmpty(vo.getAssoCasePhaseId())) { throw new XiaoShiException("案件流程阶段id为空"); } //1. 首先上传报告事务,拿到报告事务id ReportAffairDTO reportAffairDTO = new ReportAffairDTO(); reportAffairDTO.setProjectId(projectId); //发生时间是无效请求日 reportAffairDTO.setOccurredTime(vo.getOccurredTime()); //备注 reportAffairDTO.setDescription(vo.getDescription()); reportAffairDTO.setAssoCasePhaseId(vo.getAssoCasePhaseId()); Integer reportAffairId = this.addReportAffair(reportAffairDTO); if (reportAffairId == null) { throw new XiaoShiException("上传报告事务失败"); } //2.同步报告官限 if (vo.getAssoCasePhaseId().equals(29) || vo.getAssoCasePhaseId().equals(30)) { invalidRequestFileService.getCommonMethod(projectId); } //3. 添加报告事务与文件关联 List fileGuids = vo.getFileGuids(); if (!CollectionUtils.isEmpty(fileGuids)) { List assoReportAffairFiles = new ArrayList<>(); fileGuids.forEach(item -> { AssoReportAffairFile assoReportAffairFile = new AssoReportAffairFile(); assoReportAffairFile.setReportAffairId(reportAffairId); assoReportAffairFile.setFileGuid(item); assoReportAffairFiles.add(assoReportAffairFile); }); assoReportAffairFileService.saveBatch(assoReportAffairFiles); } if (vo.getIfSendEmail()) { sendReportMailService.finalSendEmail(projectId, fileGuids, vo.getExtraEmailDTOS()); } return reportAffairId; } /** * 修改案件文档 * @param vo * @return */ public Integer updateReportAffairCase(ReportAffairCaseDTO vo){ if (ObjectUtils.isEmpty(vo)) { throw new XiaoShiException("入参为空"); } Integer projectId = vo.getProjectId(); Integer reportAffairId = vo.getId(); if (reportAffairId == null) { throw new XiaoShiException("reportAffairId为空"); } if (projectId == null) { throw new XiaoShiException("报告id为空"); } if (ObjectUtils.isEmpty(vo.getAssoCasePhaseId())) { throw new XiaoShiException("案件流程阶段id为空"); } //2. 拿到报告事务id,获取报告事务 ReportAffair reportAffair = this.getById(reportAffairId); reportAffair.setProjectId(projectId); //发生时间是无效请求日 reportAffair.setOccurredTime(vo.getOccurredTime()); //备注 reportAffair.setDescription(vo.getDescription()); reportAffair.setAssoCasePhaseId(vo.getAssoCasePhaseId()); reportAffair.updateById(); //同步报告官限 if (vo.getAssoCasePhaseId().equals(29) || vo.getAssoCasePhaseId().equals(30)) { invalidRequestFileService.getCommonMethod(projectId); } //3. 更新报告事务与文件关联 List fileGuids = vo.getFileGuids(); assoReportAffairFileService.updateAffairFile(reportAffairId, fileGuids); if (vo.getIfSendEmail()) { sendReportMailService.finalSendEmail(projectId, fileGuids, vo.getExtraEmailDTOS()); } return reportAffairId; } }