|
@@ -0,0 +1,164 @@
|
|
|
+package cn.cslg.pas.service.report;
|
|
|
+
|
|
|
+import cn.cslg.pas.common.model.novelty.LitigationDTO;
|
|
|
+import cn.cslg.pas.common.model.novelty.LitigationReVO;
|
|
|
+import cn.cslg.pas.common.model.report.ExportInvalidReportVO;
|
|
|
+import cn.cslg.pas.common.model.request.QueryRequest;
|
|
|
+import cn.cslg.pas.common.utils.FileUtils;
|
|
|
+import cn.cslg.pas.common.utils.StringUtils;
|
|
|
+import cn.cslg.pas.common.utils.excelUtils.ExcelUtil;
|
|
|
+import cn.cslg.pas.common.vo.business.ReportProjectVO;
|
|
|
+import cn.cslg.pas.common.vo.invalidVO.ReportAffairVO;
|
|
|
+import cn.cslg.pas.domain.FinalInvalidStatue;
|
|
|
+import cn.cslg.pas.domain.business.ReportAffairCasePhase;
|
|
|
+import cn.cslg.pas.domain.business.SystemDict;
|
|
|
+import cn.cslg.pas.service.FinalInvalidStatueService;
|
|
|
+import cn.cslg.pas.service.ReportAffairCasePhaseService;
|
|
|
+import cn.cslg.pas.service.business.ReportAffairService;
|
|
|
+import cn.cslg.pas.service.business.ReportProjectService;
|
|
|
+import cn.cslg.pas.service.business.SystemDictService;
|
|
|
+import cn.cslg.pas.service.novelty.LitigationService;
|
|
|
+import cn.hutool.core.bean.BeanUtil;
|
|
|
+import org.springframework.beans.BeanUtils;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.core.io.InputStreamResource;
|
|
|
+import org.springframework.http.ResponseEntity;
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
+
|
|
|
+import java.io.File;
|
|
|
+import java.util.*;
|
|
|
+import java.util.stream.Collectors;
|
|
|
+
|
|
|
+@Service
|
|
|
+public class ExportReportListService {
|
|
|
+ @Autowired
|
|
|
+ private ReportProjectService reportProjectService;
|
|
|
+ @Autowired
|
|
|
+ private ReportAffairService reportAffairService;
|
|
|
+ @Autowired
|
|
|
+ private FinalInvalidStatueService finalInvalidStatueService;
|
|
|
+ @Autowired
|
|
|
+ private SystemDictService systemDictService;
|
|
|
+ @Autowired
|
|
|
+ private LitigationService litigationService;
|
|
|
+ @Autowired
|
|
|
+ private ReportAffairCasePhaseService reportAffairCasePhaseService;
|
|
|
+
|
|
|
+ public ResponseEntity<InputStreamResource> exportInvalidReportList(QueryRequest queryRequest) throws Exception {
|
|
|
+ queryRequest.setIfInvalidReport(true);
|
|
|
+ List<ReportProjectVO> reportProjectVOS = reportProjectService.queryReportVOs(queryRequest);
|
|
|
+
|
|
|
+ ResponseEntity<InputStreamResource> resourceResponseEntity = this.loadExportInvalidReportVos(reportProjectVOS);
|
|
|
+ return resourceResponseEntity;
|
|
|
+ }
|
|
|
+
|
|
|
+ public ResponseEntity<InputStreamResource> loadExportInvalidReportVos(List<ReportProjectVO> reportProjectVOS) throws Exception {
|
|
|
+ List<Map<String, Object>> exportInvalidReportVOS = new ArrayList<>();
|
|
|
+ List<Integer> projectIds = reportProjectVOS.stream().map(ReportProjectVO::getId).collect(Collectors.toList());
|
|
|
+ List<ReportAffairVO> reportAffairVOS = reportAffairService.queryReportAffairs(projectIds);
|
|
|
+ List<FinalInvalidStatue> finalInvalidStatues = finalInvalidStatueService.getFinalInvalidStatues(projectIds);
|
|
|
+ List<SystemDict> systemDictList = systemDictService.getSystemDictListByType(Arrays.asList("STATUTE"));
|
|
|
+ for (ReportProjectVO reportProjectVO : reportProjectVOS) {
|
|
|
+ ExportInvalidReportVO exportInvalidReportVO = new ExportInvalidReportVO();
|
|
|
+ BeanUtils.copyProperties(reportProjectVO, exportInvalidReportVO);
|
|
|
+ this.loadInvalidAgency(exportInvalidReportVO, reportProjectVO);
|
|
|
+ this.loadAffair(exportInvalidReportVO, reportProjectVO, reportAffairVOS);
|
|
|
+ this.loadInvalidStatus(exportInvalidReportVO, reportProjectVO, systemDictList, finalInvalidStatues);
|
|
|
+ this.loadLitigation(exportInvalidReportVO, reportProjectVO,reportAffairVOS);
|
|
|
+ Map<String, Object> map = BeanUtil.beanToMap(exportInvalidReportVO);
|
|
|
+ exportInvalidReportVOS.add(map);
|
|
|
+
|
|
|
+ }
|
|
|
+ String readPath = "/invalidReportExport.xlsx";
|
|
|
+ readPath = FileUtils.getConfigFilePath(readPath);
|
|
|
+ File file = ExcelUtil.fullExcelTemple(readPath, exportInvalidReportVOS);
|
|
|
+ ResponseEntity<InputStreamResource> resourceResponseEntity = FileUtils.fileToResponse(file);
|
|
|
+ file.delete();
|
|
|
+ return resourceResponseEntity;
|
|
|
+ }
|
|
|
+
|
|
|
+ //装载无效代理所
|
|
|
+ public void loadInvalidAgency(ExportInvalidReportVO exportInvalidReportVO, ReportProjectVO reportProjectVO) {
|
|
|
+ if (reportProjectVO.getActType() != null && reportProjectVO.getActType() == 1) {
|
|
|
+ exportInvalidReportVO.setInvalidAgency(reportProjectVO.getApplicantAgency());
|
|
|
+ } else {
|
|
|
+ exportInvalidReportVO.setInvalidAgency(reportProjectVO.getRightHolderAgency());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //装载事务信息
|
|
|
+ public void loadAffair(ExportInvalidReportVO exportInvalidReportVO, ReportProjectVO reportProjectVO, List<ReportAffairVO> reportAffairVOS) {
|
|
|
+ List<ReportAffairVO> reportAffairVOList = reportAffairVOS.stream().filter(item -> item.getProjectId().equals(reportProjectVO.getId())).collect(Collectors.toList());
|
|
|
+ ReportAffairVO reportAffairNotification = reportAffairVOList.stream().filter(item -> item.getFlowType() != null && item.getFlowType().equals(29)).findFirst().orElse(null);
|
|
|
+ List<ReportAffairVO> reportAffairZhuanWen = reportAffairVOList.stream().filter(item -> item.getFlowType() != null && item.getFlowType().equals(30)).sorted(Comparator.comparing(ReportAffairVO::getOccurredTime)).collect(Collectors.toList());
|
|
|
+ ReportAffairVO invalidDecision = reportAffairVOList.stream().filter(item -> item.getFlowType() != null && item.getFlowType().equals(7)).findFirst().orElse(null);
|
|
|
+ for (ReportAffairVO reportAffairVO : reportAffairZhuanWen) {
|
|
|
+ if (exportInvalidReportVO.getZhuanwen1Date() == null) {
|
|
|
+ exportInvalidReportVO.setZhuanwen1Date(reportAffairVO.getOccurredTime());
|
|
|
+ } else if (exportInvalidReportVO.getZhuanwen2Date() == null) {
|
|
|
+ exportInvalidReportVO.setZhuanwen2Date(reportAffairVO.getOccurredTime());
|
|
|
+ } else if (exportInvalidReportVO.getZhuanwen3Date() == null) {
|
|
|
+ exportInvalidReportVO.setZhuanwen3Date(reportAffairVO.getOccurredTime());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (reportAffairNotification != null) {
|
|
|
+ exportInvalidReportVO.setNotificationDate(reportAffairNotification.getOccurredTime());
|
|
|
+ }
|
|
|
+ if (invalidDecision != null) {
|
|
|
+ exportInvalidReportVO.setInvalidDecisionDate(invalidDecision.getOccurredTime());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //装载无效法条信息
|
|
|
+ public void loadInvalidStatus(ExportInvalidReportVO exportInvalidReportVO, ReportProjectVO reportProjectVO, List<SystemDict> systemDictList, List<FinalInvalidStatue> finalInvalidStatues) {
|
|
|
+ List<FinalInvalidStatue> finalInvalidStatueList = finalInvalidStatues.stream().filter(item -> item.getProjectId().equals(reportProjectVO.getId())).collect(Collectors.toList());
|
|
|
+ List<String> statuesNames = new ArrayList<>();
|
|
|
+ finalInvalidStatueList.forEach(item -> {
|
|
|
+ SystemDict systemDict = systemDictList.stream().filter(tem -> tem.getValue().equals(item.getStatuteId().toString())).findFirst().orElse(null);
|
|
|
+ if (systemDict != null) {
|
|
|
+ statuesNames.add(systemDict.getLabel());
|
|
|
+ }
|
|
|
+ });
|
|
|
+ if (statuesNames.size() > 0) {
|
|
|
+ exportInvalidReportVO.setInvalidReason(StringUtils.join(statuesNames, "\n"));
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //装载诉讼结果
|
|
|
+ public void loadLitigation(ExportInvalidReportVO exportInvalidReportVO, ReportProjectVO reportProjectVO,List<ReportAffairVO> reportAffairVOS) {
|
|
|
+ Integer projectId = reportProjectVO.getId();
|
|
|
+ LitigationDTO litigationDTO = new LitigationDTO();
|
|
|
+ litigationDTO.setProjectId(projectId);
|
|
|
+ LitigationReVO litigationReVO = litigationService.queryLitigation(litigationDTO, false);
|
|
|
+ if (litigationReVO != null) {
|
|
|
+ if (litigationReVO.getLitigationVO1() != null) {
|
|
|
+ exportInvalidReportVO.setLitigation1Conclusion(litigationReVO.getLitigationVO1().getConclusion());
|
|
|
+ exportInvalidReportVO.setLitigation1CaseNumber(litigationReVO.getLitigationVO1().getCaseNumber());
|
|
|
+ exportInvalidReportVO.setLitigation1plaintiff(litigationReVO.getLitigationVO1().getPlaintiff());
|
|
|
+ exportInvalidReportVO.setLitigation1caseFieldTime(litigationReVO.getLitigationVO1().getCaseFieldTime());
|
|
|
+ String conclusion= this.loadLitigationConclusion(reportAffairVOS,projectId,"行政一审");
|
|
|
+ exportInvalidReportVO.setLitigation1Conclusion(conclusion);
|
|
|
+
|
|
|
+ }
|
|
|
+ if (litigationReVO.getLitigationVO2() != null) {
|
|
|
+ exportInvalidReportVO.setLitigation2Conclusion(litigationReVO.getLitigationVO2().getConclusion());
|
|
|
+ exportInvalidReportVO.setLitigation2CaseNumber(litigationReVO.getLitigationVO2().getCaseNumber());
|
|
|
+ exportInvalidReportVO.setLitigation2plaintiff(litigationReVO.getLitigationVO2().getPlaintiff());
|
|
|
+ exportInvalidReportVO.setLitigation2caseFieldTime(litigationReVO.getLitigationVO2().getCaseFieldTime());
|
|
|
+ String conclusion= this.loadLitigationConclusion(reportAffairVOS,projectId,"行政二审");
|
|
|
+ exportInvalidReportVO.setLitigation2Conclusion(conclusion);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ public String loadLitigationConclusion(List<ReportAffairVO> reportAffairVOS,Integer projectId,String type){
|
|
|
+ String conclusion="";
|
|
|
+ List<ReportAffairVO> temReportAffairVOs=reportAffairVOS.stream().filter(item->item.getCasePhase()!=null&&item.getCasePhase().equals(type)&&item.getProjectId().equals(projectId)&&item.getOccurredTime()!=null).sorted(Comparator.comparing(ReportAffairVO::getOccurredTime,Comparator.reverseOrder())).collect(Collectors.toList());
|
|
|
+ if(temReportAffairVOs.size()>0){
|
|
|
+ ReportAffairVO reportAffairVO =temReportAffairVOs.get(0);
|
|
|
+ if(reportAffairVO.getCaseChildPhase()!=null){
|
|
|
+ conclusion=reportAffairVO.getCaseChildPhase();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return conclusion;
|
|
|
+ }
|
|
|
+}
|