浏览代码

导入相关

qianxb 1 年之前
父节点
当前提交
9e4a267da1

+ 1 - 0
src/main/java/org/springblade/common/config/BladeConfiguration.java

@@ -66,6 +66,7 @@ public class BladeConfiguration implements WebMvcConfigurer {
 		secureRegistry.excludePathPatterns("/webjars/**");
 		secureRegistry.excludePathPatterns("/swagger-resources/**");
 		secureRegistry.excludePathPatterns("/druid/**");
+		secureRegistry.excludePathPatterns("/blade-attach/**");
 		return secureRegistry;
 	}
 

+ 92 - 33
src/main/java/org/springblade/modules/project/service/impl/ProjectInfoServiceImpl.java

@@ -14,6 +14,7 @@ import org.apache.poi.ss.usermodel.*;
 import org.apache.poi.xssf.usermodel.XSSFWorkbook;
 import org.apache.poi.xwpf.usermodel.*;
 import org.bouncycastle.asn1.isismtt.x509.ProfessionInfo;
+import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTR;
 import org.springblade.core.log.exception.ServiceException;
 import org.springblade.core.mp.base.BaseServiceImpl;
 import org.springblade.core.redis.cache.BladeRedis;
@@ -1330,19 +1331,21 @@ public class ProjectInfoServiceImpl extends BaseServiceImpl<ProjectInfoMapper, P
 
     @Override
     public ResponseEntity<FileSystemResource> buildReport(Integer year, Integer quarter, HttpServletResponse response) {
+        //转换季度
+        String[] quarterValue = {"","一","二","三","四",};
+        String quarterZh = quarterValue[quarter];
         //文件地址
         String rootUrl = System.getProperty("user.dir")+ File.separator + "temporaryFile";
         String tempFile = rootUrl + File.separator + "季度报告模板.docx";
         System.out.println("模板地址:"+tempFile);
-        String fileName = year+"年"+quarter+"季度报告"+".docx";
+        String fileName = year+"年"+quarterZh+"季度报告"+".docx";
         String fileOutUrl = rootUrl+File.separator+fileName;
         System.out.println(fileOutUrl);
-        //转换季度
-        String[] quarterValue = {"","一","二","三","四",};
-        String quarterZh = quarterValue[quarter];
         //项目类型值
-        String[] typeValue = {"","高速公路","铁路","水运","枢纽","城市轨道","城市道路","民航"};
-        String[] typeValue2 = {"","(一)高速公路类型","(二)铁路类型","(三)水运类型","(四)枢纽类型","(五)城市轨道类型","(六)城市道路类型","(七)民航类型"};
+        List<Integer> trafficType = Arrays.asList(1,2,3,4,7);
+        List<Integer> houseType = Arrays.asList(5,6);
+        String[] typeValue = {"","公路","铁路","水运","枢纽","城市轨道","城市道路","民航"};
+        String[] typeValue2 = {"","(一)公路","(二)铁路","(三)水运","(四)枢纽","(五)城市轨道","(六)城市道路","(七)民航"};
         /** 投资计划情况*/
         //重大项目个数(当年所有项目)
         List<ProjectInvestPlanVO2> projectList = investPlanService.getYearAllProject(year);
@@ -1357,15 +1360,15 @@ public class ProjectInfoServiceImpl extends BaseServiceImpl<ProjectInfoMapper, P
             throw new ServiceException(year+"年没有投资计划,请重新选择时间");
         }
         //市交通运输委完成金额
-        BigDecimal trafficMoney = projectList.stream().filter(l -> l.getDutyUnit().contains("市交通运输委") && ObjectUtil.isNotEmpty(l.getYearFinishInvest()))
+        BigDecimal trafficMoney = projectList.stream().filter(l -> trafficType.contains(l.getProjectType()) && ObjectUtil.isNotEmpty(l.getYearFinishInvest()))
                 .map(ProjectInvestPlan::getYearFinishInvest).reduce(BigDecimal.ZERO, BigDecimal::add);
         //铁路公路等项目个数
-        long trafficTotal = projectList.stream().filter(l -> l.getDutyUnit().contains("市交通运输委") && "1,2,3,4,7".contains(l.getProjectType()+"")).count();
+        long trafficTotal = projectList.stream().filter(l -> trafficType.contains(l.getProjectType())).count();
         //市住房城乡建委完成金额
-        BigDecimal houseMoney = projectList.stream().filter(l -> l.getDutyUnit().contains("市住房城乡建委") && ObjectUtil.isNotEmpty(l.getYearFinishInvest()))
+        BigDecimal houseMoney = projectList.stream().filter(l -> houseType.contains(l.getProjectType()) && ObjectUtil.isNotEmpty(l.getYearFinishInvest()))
                 .map(ProjectInvestPlan::getYearFinishInvest).reduce(BigDecimal.ZERO, BigDecimal::add);
         //城市轨道和城市项目个数
-        long houseTotal = projectList.stream().filter(l -> l.getDutyUnit().contains("市住房城乡建委") && "5,6".contains(l.getProjectType()+"")).count();
+        long houseTotal = projectList.stream().filter(l -> houseType.contains(l.getProjectType())).count();
         //一季度计划完成投资
         BigDecimal oneInvest = projectList.stream().filter(l-> ObjectUtil.isNotEmpty(l.getOneInvest()) && l.getOneInvest().compareTo(BigDecimal.ZERO) != 0)
                 .map(ProjectInvestPlan::getOneInvest).reduce(BigDecimal.ZERO, BigDecimal::add);
@@ -1382,8 +1385,7 @@ public class ProjectInfoServiceImpl extends BaseServiceImpl<ProjectInfoMapper, P
 
         /** 投资完成情况表*/
         //总计
-        ReportVO1 vo1 = this.calculateTableOne(projectList.stream().filter(l -> (l.getDutyUnit().contains("市交通运输委") ||
-                        l.getDutyUnit().contains("市住房城乡建委")) && ObjectUtil.isNotEmpty(l.getYearlyInvest()))
+        ReportVO1 vo1 = this.calculateTableOne(projectList.stream().filter(l -> ObjectUtil.isNotEmpty(l.getYearlyInvest()))
                         .collect(Collectors.toList()), quarter);
         Map<String,ReportVO1> reportVOMap1 = new HashMap<>();
         Map<String,ReportVO1> reportVOMap2 = new HashMap<>();
@@ -1396,22 +1398,19 @@ public class ProjectInfoServiceImpl extends BaseServiceImpl<ProjectInfoMapper, P
         //占全年投资计划
         BigDecimal currentYearlyFinishedRatio = vo1.getQuarterAddRatioYearPlan();
         //市交通运输委
-        List<ProjectInvestPlanVO2> traffics = projectList.stream().filter(l -> l.getDutyUnit().contains("市交通运输委") && ObjectUtil.isNotEmpty(l.getYearlyInvest()))
+        List<ProjectInvestPlanVO2> traffics = projectList.stream().filter(l -> trafficType.contains(l.getProjectType()) && ObjectUtil.isNotEmpty(l.getYearlyInvest()))
                 .collect(Collectors.toList());
         reportVOMap1.put("一、市交通运输委",this.calculateTableOne(traffics, quarter));
-        for (int i = 1; i < typeValue.length; i++) {
-            int j = i;
-            reportVOMap1.put(typeValue[i], this.calculateTableOne(traffics.stream().filter(l->l.getProjectType()==j).collect(Collectors.toList()), quarter));
+        for (Integer i : trafficType) {
+            reportVOMap1.put(typeValue[i], this.calculateTableOne(traffics.stream().filter(l->l.getProjectType()==i).collect(Collectors.toList()), quarter));
         }
         //市住房城乡建委
-        List<ProjectInvestPlanVO2> houses = projectList.stream().filter(l -> l.getDutyUnit().contains("市住房城乡建委") && ObjectUtil.isNotEmpty(l.getYearlyInvest()))
+        List<ProjectInvestPlanVO2> houses = projectList.stream().filter(l -> houseType.contains(l.getProjectType()) && ObjectUtil.isNotEmpty(l.getYearlyInvest()))
                 .collect(Collectors.toList());
         reportVOMap2.put("二、市住房城乡建委",this.calculateTableOne(houses, quarter));
-        for (int i = 1; i < typeValue.length; i++) {
-            int j = i;
-            reportVOMap2.put(typeValue[i], this.calculateTableOne(houses.stream().filter(l->l.getProjectType()==j).collect(Collectors.toList()), quarter));
+        for (Integer i : houseType) {
+            reportVOMap2.put(typeValue[i], this.calculateTableOne(houses.stream().filter(l->l.getProjectType()==i).collect(Collectors.toList()), quarter));
         }
-
         Set<String> heads1 = reportVOMap1.keySet();
         Set<String> heads2 = reportVOMap2.keySet();
         /** 各板块完成情况*/
@@ -1432,6 +1431,24 @@ public class ProjectInfoServiceImpl extends BaseServiceImpl<ProjectInfoMapper, P
             VO3listList.add(this.calculateTableSeven(list,projectWarning));
         }
         Set<String> heads3 = reportVO2Map.keySet();
+        /** 存在问题*/
+        List<String> question = new ArrayList<>();
+        List<ProjectInvestPlanVO2> questionList = projectList.stream().filter(l -> StringUtils.isNotBlank(l.getQuestionable())).collect(Collectors.toList());
+        if (questionList.size() > 0){
+            for (int i = 1; i <= questionList.size(); i++) {
+                ProjectInvestPlanVO2 vo2 = questionList.get(i - 1);
+                question.add(i+"."+vo2.getName()+"存在"+vo2.getQuestionable()+"问题。");
+            }
+        }
+        /** 工作意见*/
+        List<String> advice = new ArrayList<>();
+        List<ProjectInvestPlanVO2> adviceList = projectList.stream().filter(l -> StringUtils.isNotBlank(l.getWorkAdvise())).collect(Collectors.toList());
+        if (adviceList.size() > 0){
+            for (int i = 1; i <= adviceList.size(); i++) {
+                ProjectInvestPlanVO2 vo2 = adviceList.get(i - 1);
+                advice.add(i+".建议"+vo2.getName()+vo2.getWorkAdvise()+"。");
+            }
+        }
 
         /** 读取模板文件*/
         File directory = new File(rootUrl);
@@ -1490,17 +1507,16 @@ public class ProjectInfoServiceImpl extends BaseServiceImpl<ProjectInfoMapper, P
                 if (tag == 2 && heads2.contains(rowHead)){
                     rowData = reportVOMap2.get(rowHead);
                 }
-
                 if (rowData != null) {
                     cells.get(1).getParagraphs().get(0).getRuns().get(0).setText(rowData.getYearProjectTotal() + "", 0);
                     cells.get(2).getParagraphs().get(0).getRuns().get(0).setText(rowData.getYearPlanInvest() + "", 0);
                     cells.get(3).getParagraphs().get(0).getRuns().get(0).setText(rowData.getQuarterPlanInvest() + "", 0);
                     cells.get(4).getParagraphs().get(0).getRuns().get(0).setText(rowData.getQuarterFinishedInvest() + "", 0);
-                    cells.get(5).getParagraphs().get(0).getRuns().get(0).setText(rowData.getQuarterCompare() + "", 0);
-                    cells.get(6).getParagraphs().get(0).getRuns().get(0).setText(rowData.getQuarterFinishedRatio() + "", 0);
+                    cells.get(5).getParagraphs().get(0).getRuns().get(0).setText(rowData.getQuarterFinishedRatio() + "%", 0);
+                    cells.get(6).getParagraphs().get(0).getRuns().get(0).setText(rowData.getQuarterCompare() + "", 0);
                     cells.get(7).getParagraphs().get(0).getRuns().get(0).setText(rowData.getQuarterAddFinishedInvest() + "", 0);
                     cells.get(8).getParagraphs().get(0).getRuns().get(0).setText(rowData.getQuarterAddRatioYearPlan() + "", 0);
-                    cells.get(9).getParagraphs().get(0).getRuns().get(0).setText(rowData.getLeadOrLag() + "", 0);
+                    cells.get(9).getParagraphs().get(0).getRuns().get(0).setText(rowData.getLeadOrLag() + "%", 0);
                 }
             }
             //批量处理后面7张相同格式表单
@@ -1511,17 +1527,17 @@ public class ProjectInfoServiceImpl extends BaseServiceImpl<ProjectInfoMapper, P
                 //小计
                 ReportVO3 v1 = vo3List.get(0);
                 List<XWPFTableCell> cells = rows.get(2).getTableCells();
-                cells.get(1).getParagraphs().get(0).getRuns().get(0).setText(v1.getOneInvestRatio().toString() , 0);
+                cells.get(1).getParagraphs().get(0).getRuns().get(0).setText(v1.getOneInvestRatio().toString()+"%" , 0);
                 cells.get(2).getParagraphs().get(0).getRuns().get(0).setText(v1.getOneProjectTotal().toString()  , 0);
-                cells.get(3).getParagraphs().get(0).getRuns().get(0).setText(v1.getTwoInvestRatio().toString() , 0);
+                cells.get(3).getParagraphs().get(0).getRuns().get(0).setText(v1.getTwoInvestRatio().toString() +"%", 0);
                 cells.get(4).getParagraphs().get(0).getRuns().get(0).setText(v1.getTwoProjectTotal().toString() , 0);
-                cells.get(5).getParagraphs().get(0).getRuns().get(0).setText(v1.getTwoAggregateRatio().toString() , 0);
-                cells.get(6).getParagraphs().get(0).getRuns().get(0).setText(v1.getThreeInvestRatio().toString() , 0);
+                cells.get(5).getParagraphs().get(0).getRuns().get(0).setText(v1.getTwoAggregateRatio().toString() +"%", 0);
+                cells.get(6).getParagraphs().get(0).getRuns().get(0).setText(v1.getThreeInvestRatio().toString() +"%", 0);
                 cells.get(7).getParagraphs().get(0).getRuns().get(0).setText(v1.getThreeProjectTotal().toString() , 0);
-                cells.get(8).getParagraphs().get(0).getRuns().get(0).setText(v1.getThreeAggregateRatio().toString() , 0);
-                cells.get(9).getParagraphs().get(0).getRuns().get(0).setText(v1.getFourInvestRatio().toString() , 0);
+                cells.get(8).getParagraphs().get(0).getRuns().get(0).setText(v1.getThreeAggregateRatio().toString() +"%", 0);
+                cells.get(9).getParagraphs().get(0).getRuns().get(0).setText(v1.getFourInvestRatio().toString() +"%", 0);
                 cells.get(10).getParagraphs().get(0).getRuns().get(0).setText(v1.getFourProjectTotal().toString() , 0);
-                cells.get(11).getParagraphs().get(0).getRuns().get(0).setText(v1.getFourAggregateRatio().toString() , 0);
+                cells.get(11).getParagraphs().get(0).getRuns().get(0).setText(v1.getFourAggregateRatio().toString() +"%", 0);
                 //正常
                 v1 = vo3List.get(1);
                 cells = rows.get(3).getTableCells();
@@ -1588,6 +1604,9 @@ public class ProjectInfoServiceImpl extends BaseServiceImpl<ProjectInfoMapper, P
                 if ("投资完成情况表".equals(paragraphText)){
                     status = 1;
                 }
+                if ("存在问题".equals(paragraphText)){
+                    status = 2;
+                }
                 if (status == 0) {
                     //paragraph为一个段落
                     List<XWPFRun> runs = paragraph.getRuns();
@@ -1672,6 +1691,46 @@ public class ProjectInfoServiceImpl extends BaseServiceImpl<ProjectInfoMapper, P
                             run.setText(text, 0);
                         }
                     }
+                }else if (status == 2){
+                    //paragraph为一个段落
+                    List<XWPFRun> runs = paragraph.getRuns();
+                    //runs为一个段落数据分词后集合
+                    for (XWPFRun run : runs) {
+                        String text = run.getText(0);
+                        if (text != null && text.contains("${")) {
+                            if (text.contains("${QUESTION}")) {
+                                if (question.size() > 0){
+                                    for (int i = 0; i < question.size(); i++) {
+                                        if (i == 0){
+                                            run.setText(text.replace("${QUESTION}", question.get(0)),0);
+                                        }else {
+                                            run.setText("   "+question.get(i));
+                                        }
+                                        if (i != (question.size() - 1)){
+                                            run.addBreak();
+                                        }
+                                    }
+                                }else {
+                                    run.setText(text.replace("${QUESTION}", ""),0);
+                                }
+                            } else if (text.contains("${ADVICE}")) {
+                                if (advice.size() > 0){
+                                    for (int i = 0; i < advice.size(); i++) {
+                                        if (i == 0){
+                                            run.setText(text.replace("${ADVICE}", advice.get(0)),0);
+                                        }else {
+                                            run.setText("   "+advice.get(i));
+                                        }
+                                        if (i != (advice.size() -1)) {
+                                            run.addBreak();
+                                        }
+                                    }
+                                }else {
+                                    run.setText(text.replace("${ADVICE}", ""),0);
+                                }
+                            }
+                        }
+                    }
                 }
             }
             /** 写入指定位置,上传并返回URL*/
@@ -2107,7 +2166,7 @@ public class ProjectInfoServiceImpl extends BaseServiceImpl<ProjectInfoMapper, P
         if (currentLastQuarterFinished.compareTo(BigDecimal.ZERO) == 0 || currentQuarterFinished.compareTo(BigDecimal.ZERO) == 0){
             vo1.setQuarterCompare(BigDecimal.ZERO);
         }else {
-            vo1.setQuarterCompare( currentQuarterFinished.multiply(new BigDecimal(100))
+            vo1.setQuarterCompare( currentQuarterFinished
                             .divide(currentLastQuarterFinished,2, RoundingMode.HALF_UP));
         }
         vo1.setQuarterFinishedRatio(currentQuarterFinishedRatio);