yangyj 1 rok pred
rodič
commit
1f9578b473

+ 4 - 0
blade-service-api/blade-manager-api/src/main/java/org/springblade/manager/vo/MeterPeriodInfo.java

@@ -80,6 +80,10 @@ public class MeterPeriodInfo implements  DataModel{
     private LocalDate startDate;
     /**结束日期*/
     private LocalDate endDate;
+    /**动员预付关联*/
+    private String startIds;
+    /**动员预付关联*/
+    private String materialIds;
 
     public String getStartDateStr() {
         return BaseUtils.toDateStr(startDate);

+ 93 - 28
blade-service/blade-manager/src/main/java/com/mixsmart/utils/FormulaUtils.java

@@ -37,6 +37,7 @@ import org.jfree.chart.renderer.category.LineAndShapeRenderer;
 import org.jfree.chart.renderer.xy.XYLineAndShapeRenderer;
 import org.jfree.chart.renderer.xy.XYSplineRenderer;
 import org.jfree.chart.title.TextTitle;
+import org.jfree.chart.ui.RectangleEdge;
 import org.jfree.data.category.CategoryDataset;
 import org.jfree.data.category.DefaultCategoryDataset;
 import org.jfree.data.xy.XYSeries;
@@ -67,6 +68,7 @@ import javax.imageio.ImageIO;
 import java.awt.*;
 import java.awt.Font;
 import java.awt.Shape;
+import java.awt.geom.AffineTransform;
 import java.awt.geom.Ellipse2D;
 import java.awt.geom.Rectangle2D;
 import java.awt.image.BufferedImage;
@@ -1247,27 +1249,6 @@ public class FormulaUtils {
         return chart;
     }
 
-    public static void mainT2(String[] args) {
-        double[] actualProgress = {10, 15, 18, 27, 35, 48};
-        double[] plannedProgress = {10, 15, 20, 25, 30, 35};
-        CategoryDataset dataset = createDataset(actualProgress,plannedProgress);
-        JFreeChart chart = createChart(dataset);
-
-        try (ByteArrayOutputStream out = new ByteArrayOutputStream()) {
-            BufferedImage bufferedImage = chart.createBufferedImage(800, 600);
-            ImageIO.write(bufferedImage, "png", out);
-            FileOutputStream fos = new FileOutputStream("C:/Users/yangyj/Desktop/Swap_space/poi_statistics.png");
-            fos.write(out.toByteArray());
-        } catch (IOException e) {
-            e.printStackTrace();
-        }
-/*        try {
-            ChartUtils.saveChartAsPNG(new File("C:/Users/yangyj/Desktop/Swap_space/poi_statistics.png"), chart, 800, 600);
-            // 保存图表到内存
-        } catch (Exception e) {
-            e.printStackTrace();
-        }*/
-    }
 
     public static String getSysLocalFileUrl() {
         String file_path = ParamCache.getValue(CommonConstant.SYS_LOCAL_URL);
@@ -1310,10 +1291,6 @@ public class FormulaUtils {
        XYSeries actualProgress = new XYSeries("实际进度");
        XYSeries plannedProgress = new XYSeries("计划进度");
 
-    /*   // 数据
-       double[][] actualProgressData = {{1, 10}, {2, 15}, {3, 18}, {4, 27}, {5, 35}, {6, 48}};
-       double[][] plannedProgressData = {{1, 10}, {2, 15}, {3, 20}, {4, 25}, {5, 30}, {6, 35}};*/
-
        // 填充数据集
        for (int i = 0; i < actualProgressData.length; i++) {
            actualProgress.add(i, actualProgressData[i]);
@@ -1362,11 +1339,21 @@ public class FormulaUtils {
 
 
        // 设置顶部的月份轴
-       String[] months = {"一月", "二月", "三月", "四月", "五月", "六月", "七月", "八月", "九月", "十月", "十一月", "十二月"};
-       SymbolAxis monthAxis = new SymbolAxis("月份", months);
+      /* String[] months = {"一月", "二月", "三月", "四月", "五月", "六月", "七月", "八月", "九月", "十月", "十一月", "十二月"};
+       String[] years = {"2023年", "2024年", "2025年", "2026年"};*/
+       String[] months =new String[4 * 12];
+       for(int i=2023;i<=2026;i++){
+           for(int n=1;n<=12;n++){
+               int index=(i-2023)*12+n-1;
+               months[index]=i+"年"+n+"月";
+           }
+       }
+       // 设置顶部的月份轴
+       SymbolAxis monthAxis = new SymbolAxis("月份", months) ;
        monthAxis.setTickLabelFont(font);
        monthAxis.setLabelFont(font);
-       monthAxis.setRange(0, 11); // 设置范围来适应月份标签
+       monthAxis.setVerticalTickLabels(true);
+       monthAxis.setRange(0, 47); // 设置范围来适应月份标签
        plot.setDomainAxis(monthAxis);
 
        // 设置Y轴的范围
@@ -1382,6 +1369,84 @@ public class FormulaUtils {
 
        return chart;
     }
+    public static JFreeChart chartTest2(double[] actualProgressData, double[] plannedProgressData) {
+        // 创建数据集
+        DefaultCategoryDataset dataset = new DefaultCategoryDataset();
+        String[] months = new String[4 * 12];
+        for (int i = 2023; i <= 2026; i++) {
+            for (int n = 1; n <= 12; n++) {
+                int index = (i - 2023) * 12 + n - 1;
+                months[index] = i + "年" + n + "月";
+            }
+        }
+
+        for (int i = 0; i < months.length; i++) {
+            dataset.addValue(actualProgressData.length-1>i?actualProgressData[i]:0, "实际进度", months[i]);
+            dataset.addValue(plannedProgressData.length-1>i?plannedProgressData[i]:0, "计划进度", months[i]);
+        }
+
+        // 创建图表
+        JFreeChart chart = ChartFactory.createLineChart(
+                "施工进度对比图", // 标题
+                "日期进度 (%)", // X轴标签
+                "完成量 (%)", // Y轴标签
+                dataset // 数据集
+        );
+
+        // 设置中文字体以避免乱码
+        Font font = new Font("宋体", Font.PLAIN, 12);
+        chart.getTitle().setFont(font);
+        chart.getLegend().setItemFont(font);
+
+        CategoryPlot plot = (CategoryPlot) chart.getPlot();
+        plot.setDomainGridlinesVisible(true);
+        plot.setRangeGridlinesVisible(true);
+        plot.setDomainGridlinePaint(Color.LIGHT_GRAY);
+        plot.setRangeGridlinePaint(Color.LIGHT_GRAY);
+        plot.setBackgroundPaint(Color.WHITE);
+
+        LineAndShapeRenderer renderer = new LineAndShapeRenderer();
+        renderer.setSeriesPaint(0, Color.BLUE);
+        renderer.setSeriesPaint(1, Color.GREEN);
+        plot.setRenderer(renderer);
+
+        // 设置顶部的月份轴
+        CategoryAxis monthAxis = new CategoryAxis("月份");
+        monthAxis.setTickLabelFont(font);
+        monthAxis.setLabelFont(font);
+        monthAxis.setCategoryLabelPositions(CategoryLabelPositions.UP_45); // 设置标签倾斜45度
+        monthAxis.setMaximumCategoryLabelWidthRatio(1.0f); // 确保所有标签显示
+        plot.setDomainAxis(monthAxis);
+
+        // 设置Y轴的范围
+        NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
+        rangeAxis.setRange(0, 100); // Y轴从0到100
+        rangeAxis.setTickUnit(new NumberTickUnit(10));
+        rangeAxis.setLabelFont(font);
+        rangeAxis.setTickLabelFont(font);
+
+        return chart;
+    }
+    public static void main(String[] args) throws IOException {
+        double[] actualProgress = {10, 15, 18, 27, 35, 48};
+        double[] plannedProgress = {10, 15, 20, 25, 30, 35};
+
+        JFreeChart chart = chartTest2(actualProgress,plannedProgress);
+/*        try (ByteArrayOutputStream out = new ByteArrayOutputStream()) {
+            BufferedImage bufferedImage = chart.createBufferedImage(800, 600);
+            ImageIO.write(bufferedImage, "png", out);
+            FileOutputStream fos = new FileOutputStream("C:/Users/yangyj/Desktop/Swap_space/poi_statistics.png");
+            fos.write(out.toByteArray());
+        } catch (IOException e) {
+            e.printStackTrace();
+        }*/
+        try {
+            ChartUtils.saveChartAsPNG(new File("C:/Users/yangyj/Desktop/Swap_space/poi_statistics.png"), chart, 800, 600);
+            // 保存图表到内存
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+    }
 
 
     /**字符串sha256映射*/

+ 20 - 6
blade-service/blade-manager/src/main/java/org/springblade/manager/formula/impl/ExecutorMeter.java

@@ -985,15 +985,29 @@ public class ExecutorMeter extends FormulaExecutor {
                      if(tec.meterInfo.getStartPayFormAll()!=null){
                         List<StartPayForm> startPayForm = tec.getMeterInfo().getStartPayFormAll();
                         if(startPayForm.size()>0){
-                           BigDecimal  end = startPayForm.stream().filter(s->s.getPeriodSort()<=tec.periodInfo.getSort()).map(s->BaseUtils.str2BigDecimal(s.getMeterMoney())).reduce(BigDecimal.ZERO,BigDecimal::add);
+                            String[] startIds=tec.getPeriodInfo().getStartIds().split(",");
+                            if(Arrays.stream(startIds).anyMatch(BaseUtils::isNumber)) {
+                                List<StartPayForm> list = startPayForm.stream().sorted(Comparator.comparingInt(StartPayForm::getPeriodSort)).filter(e ->{
+                                    for(String s:startIds){
+                                        if(StringUtils.isEquals(s,e.getMeterPeriodId()))return  true;
+                                    }
+                                    return false;
+                                }).collect(Collectors.toList());
+                                if (Func.isNotEmpty(list)) {
+                                    StartPayForm relate = list.get(list.size() - 1);
+                                    BigDecimal pre = startPayForm.stream().filter(s -> s.getPeriodSort() <= relate.getPeriodSort()).map(s -> BaseUtils.str2BigDecimal(s.getMeterMoney())).reduce(BigDecimal.ZERO, BigDecimal::add);
+                                    startPay.setPreviousPeriodEndPay(pre.toPlainString());
+                                }
+                            }
+                          /* BigDecimal  end = startPayForm.stream().filter(s->s.getPeriodSort()<=tec.periodInfo.getSort()).map(s->BaseUtils.str2BigDecimal(s.getMeterMoney())).reduce(BigDecimal.ZERO,BigDecimal::add);
                            BigDecimal  current= startPayForm.stream().filter(s-> s.getPeriodSort().equals(tec.periodInfo.getSort())).map(s->BaseUtils.str2BigDecimal(s.getMeterMoney())).reduce(BigDecimal.ZERO,BigDecimal::add);
-                           /*startPay.setCurrentPeriodPay(current.toPlainString());*/
+                           *//*startPay.setCurrentPeriodPay(current.toPlainString());*//*
                            startPay.setCurrentPeriodEndPay(end.toPlainString());
                            String pre=subtractFc.apply(end.toPlainString(),current.toPlainString());
                            if(!pre.contains("-")) {
-                               /*非负数*/
+                               *//*非负数*//*
                                startPay.setPreviousPeriodEndPay(pre);
-                           }
+                           }*/
                         }
                      }
                      payItemZj.add(startPay);
@@ -1002,7 +1016,7 @@ public class ExecutorMeter extends FormulaExecutor {
                      payItemZj.add(new InterimPaymentCertificate("扣回材料设备垫付款"));
                       blj=new InterimPaymentCertificate("保留金");
                      payItemZj.add(blj);
-                     InterimPaymentCertificate thblj=new InterimPaymentCertificate("退还保金",true);
+                     InterimPaymentCertificate thblj=new InterimPaymentCertificate("退还保金",true);
                      thblj.setNoApply(1);
                      payItemZj.add(thblj);
                      InterimPaymentCertificate sjzf=new InterimPaymentCertificate("实际支付",true);
@@ -1078,7 +1092,7 @@ public class ExecutorMeter extends FormulaExecutor {
                              certificate.setCurrentPeriodEndPay(rebateIncentiveAdvPay.getEndPay());
                              certificate.setCurrentPeriodPay(rebateIncentiveAdvPay.getCurrentPay());
                              certificate.setPreviousPeriodEndPay(rebateIncentiveAdvPay.getPreviousPay());
-                         }else if("退还保金".equals(certificate.getChapterSeq())){
+                         }else if("退还保金".equals(certificate.getChapterSeq())){
                              certificate.setCurrentPeriodPay(ic.getCurrentPeriodPay());
                          }
                          BeanUtils.copyProperties(certificate,ic);

+ 1 - 1
blade-service/blade-manager/src/main/java/org/springblade/manager/service/impl/FormulaDaoImpl.java

@@ -150,7 +150,7 @@ public class FormulaDaoImpl implements IFormulaDao {
     @Override
     public Function<Long, List<MeterPeriodInfo>> getInterimMeterPeriodAllFc() {
           return contractId->{
-            String sql="select a.id,a.pay_number,a.start_date,b.end_date, a.period_number periodNumber,a.sort ,b.print_date formPrintDate ,b.pay_money curTotal,b.id reportId,b.start_date,b.end_date  from  s_contract_meter_period a join s_interim_pay_certificate b on a.id=b.contract_period_id where a.is_deleted=0 and  b.is_deleted=0 and b.contract_id="+contractId+" order by a.sort";
+            String sql="select a.id,a.pay_number,a.start_date,b.end_date, a.period_number periodNumber,a.sort ,b.print_date formPrintDate ,b.pay_money curTotal,b.id reportId,b.start_date,b.end_date,b.start_period_ids start_ids ,b.material_period_ids material_ids  from  s_contract_meter_period a join s_interim_pay_certificate b on a.id=b.contract_period_id where a.is_deleted=0 and  b.is_deleted=0 and b.contract_id="+contractId+" order by a.sort";
             return   getEntityList(sql,MeterPeriodInfo.class);
         };
     }