chenr 2 ماه پیش
والد
کامیت
6372eee650

+ 39 - 4
src/main/java/org/springblade/modules/project/controller/ProjectInfoController.java

@@ -18,12 +18,20 @@ import org.springblade.modules.project.pojo.dto.*;
 import org.springblade.modules.project.pojo.vo.*;
 import org.springblade.modules.project.service.IProjectInfoService;
 import org.springframework.core.io.FileSystemResource;
+import org.springframework.http.HttpHeaders;
+import org.springframework.http.MediaType;
 import org.springframework.http.ResponseEntity;
 import org.springframework.jdbc.core.JdbcTemplate;
 import org.springframework.web.bind.annotation.*;
 import org.springframework.web.multipart.MultipartFile;
 
+import java.io.File;
+import java.io.IOException;
+import java.net.URLEncoder;
+import java.util.ArrayList;
+import java.util.HashMap;
 import java.util.List;
+import java.util.Map;
 
 /**
  * @Param
@@ -57,6 +65,18 @@ public class ProjectInfoController extends BladeController {
         return R.data(page);
     }
 
+    @GetMapping("/allYear")
+    @ApiOperationSupport(order = 0)
+    @Operation(summary = "获取所有年", description = "获取所有年")
+    public R<List<YearDto>>allYear(){
+        List<YearDto> yearList=new ArrayList<>();
+        List<String> list = jdbcTemplate.queryForList("select distinct plan_year from d_project_invest_plan where is_deleted=0", String.class);
+        for (String s : list) {
+            yearList.add(new YearDto(s,s+"年"));
+        }
+        return R.data(yearList);
+    }
+
     @GetMapping("/detail")
     @ApiOperationSupport(order = 3)
     @Operation(summary = "项目详情", description = "项目详情,传入项目id")
@@ -160,12 +180,27 @@ public class ProjectInfoController extends BladeController {
         return R.success("撤销成功");
     }
 
-    @PostMapping("/import-temp")
+    @GetMapping("/import-temp")
     @ApiOperationSupport(order = 16)
     @Operation(summary = "项目导入模板", description = "")
-    public R<String> importProject() {
-        String url = jdbcTemplate.queryForObject("select dict_value from blade_dict where code = 'project_template' and dict_key = 1 and is_deleted = 0", String.class);
-        return R.data(url);
+    public ResponseEntity<FileSystemResource> importProject() {
+        try {
+            String rootUrl = System.getProperty("user.dir")+ File.separator + "temporaryFile";
+            String tempFile = rootUrl + File.separator + "xiangmudaoru.xlsx";
+            FileSystemResource file = new FileSystemResource(tempFile);
+            String  fileName = URLEncoder.encode("项目导入模版.xlsx", "UTF-8").replaceAll("\\+", "%20");
+            HttpHeaders headers = new HttpHeaders();
+            headers.add(HttpHeaders.CONTENT_DISPOSITION, "attachment; filename=" + fileName);
+            return ResponseEntity.ok()
+                .headers(headers)
+                .contentLength(file.contentLength())
+                .contentType(MediaType.APPLICATION_OCTET_STREAM)
+                .body(file);
+        } catch (IOException e) {
+            throw new RuntimeException(e);
+        }
+//        String url = jdbcTemplate.queryForObject("select dict_value from blade_dict where code = 'project_template' and dict_key = 1 and is_deleted = 0", String.class);
+//        return R.data(url);
     }
 
     @PostMapping("/import-project")

+ 0 - 3
src/main/java/org/springblade/modules/project/mapper/ProjectInfoMapper.xml

@@ -140,7 +140,6 @@
         WHERE
             #{dto.year} NOT BETWEEN dpi.start_year AND dpi.end_year
           AND dpip.plan_year = #{dto.year}
-          AND (dpip.yearly_invest IS NOT NULL AND dpip.yearly_invest != 0)
           AND dpi.is_deleted = 0
         <if test="dto.projectStage != null ">
             and dpi.project_stage = #{dto.projectStage}
@@ -157,7 +156,6 @@
         from d_project_info dpi JOIN d_project_invest_plan dpip ON dpi.id = dpip.project_id
         where #{dto.year} NOT BETWEEN dpi.start_year AND dpi.end_year
         AND dpip.plan_year = #{dto.year}
-        AND (dpip.yearly_invest IS NOT NULL AND dpip.yearly_invest != 0)
         AND dpi.is_deleted = 0
         <if test="dto.projectStage != null ">
             and dpi.project_stage = #{dto.projectStage}
@@ -174,7 +172,6 @@
         from d_project_info dpi JOIN d_project_invest_plan dpip ON dpi.id = dpip.project_id
         where #{dto.year} NOT BETWEEN dpi.start_year AND dpi.end_year
         AND dpip.plan_year = #{dto.year}
-        AND (dpip.yearly_invest IS NOT NULL AND dpip.yearly_invest != 0)
         AND dpi.is_deleted = 0
         <if test="dto.projectStage != null ">
             and dpi.project_stage = #{dto.projectStage}

+ 3 - 1
src/main/java/org/springblade/modules/project/mapper/ProjectInvestPlanMapper.java

@@ -48,7 +48,9 @@ public interface ProjectInvestPlanMapper extends BaseMapper<ProjectInvestPlan> {
 
     void updateAllInvestYearAllByProjectId(@Param("id")Long id, @Param("finalInvestYearAllToTal")BigDecimal finalInvestYearAllToTal);
 
-    BigDecimal getYearAllByType(@Param("type") Integer type,@Param("year") String year);
+    BigDecimal getYearAllByType(@Param("type") Integer type,@Param("year") String year,@Param("projectIds") List<Long>projectIds);
 
     BigDecimal getYearAll(@Param("year")String year);
+
+    ProjectInvestPlan getInvestYearAndYearlyInvest(@Param("projectId")Long id, @Param("planYear")String planYear);
 }

+ 11 - 0
src/main/java/org/springblade/modules/project/mapper/ProjectInvestPlanMapper.xml

@@ -18,8 +18,19 @@
     </select>
     <select id="getYearAllByType" resultType="java.math.BigDecimal">
        SELECT ifNull(sum(dpip.invest_year),0) from d_project_invest_plan dpip left join d_project_info dpi on dpi.id = dpip.project_id where dpi.project_type = #{type} and dpi.is_deleted = 0 and dpip.plan_year = #{year} and dpip.is_deleted = 0
+       and dpi.id in
+       <foreach collection="projectIds" item="id" open="("  close=")" separator=",">
+           #{id}
+       </foreach>
     </select>
     <select id="getYearAll" resultType="java.math.BigDecimal">
         select ifNull(sum(invest_year),0) from d_project_invest_plan where plan_year=#{year} and is_deleted = 0
     </select>
+    <select id="getInvestYear" resultType="java.math.BigDecimal">
+        select ifNull(sum(invest_year),0) from d_project_invest_plan where project_id = #{id} and plan_year = #{planYear} and is_deleted = 0
+    </select>
+    <select id="getInvestYearAndYearlyInvest"
+            resultType="org.springblade.modules.project.pojo.entity.ProjectInvestPlan">
+        select yearly_invest,invest_year from d_project_invest_plan where project_id = #{projectId} and plan_year = #{planYear} and is_deleted = 0
+    </select>
 </mapper>

+ 1 - 1
src/main/java/org/springblade/modules/project/pojo/dto/DataStatDTO.java

@@ -20,7 +20,7 @@ public class DataStatDTO {
     @Schema(description = "月")
     private Integer month;
 
-    @Schema(description = "项目进度类型1常规2超进度3滞后所有传-1")
+    @Schema(description = "项目进度类型 1常规2超进度3滞后 所有传-1")
     private Integer projectScheduleType;
 
     @Schema(description = "滞后等级所有传-1")

+ 3 - 0
src/main/java/org/springblade/modules/project/pojo/dto/ProjectInfoPageDTO.java

@@ -42,5 +42,8 @@ public class ProjectInfoPageDTO {
     @Schema(description = "删除使用")
     private String ids;
 
+    @Schema(description = "计划年份")
+    private String planYear;
+
 
 }

+ 14 - 0
src/main/java/org/springblade/modules/project/pojo/dto/YearDto.java

@@ -0,0 +1,14 @@
+package org.springblade.modules.project.pojo.dto;
+
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.NoArgsConstructor;
+
+@Data
+@NoArgsConstructor
+@AllArgsConstructor
+public class YearDto {
+    private String key;
+    private String value;
+}

+ 2 - 0
src/main/java/org/springblade/modules/project/pojo/vo/DataInvestStatVO.java

@@ -43,6 +43,8 @@ public class DataInvestStatVO {
     @Schema(description = "投资数据表单")
     private List<InvestInfo> list;
 
+    private Map<String,List<BigDecimal>> map2;
+
     @Data
     public static class InvestInfo{
         @Schema(description = "项目阶段名称")

+ 14 - 1
src/main/java/org/springblade/modules/project/pojo/vo/ProjectInfoVO.java

@@ -50,7 +50,20 @@ public class ProjectInfoVO extends ProjectInfo {
     @Schema(description = "项目已经设置计划的年个数")
     private Integer hasPlanYearTotal;
 
-    @Schema(description = "统计每年累计投资")
+    @Schema(description = "今年累计投资完成")
+    private BigDecimal investYear;
+
+    @Schema(description = "项目累计完成投资")
     private BigDecimal investYearAll;
 
+    @Schema(description = "今年计划投资")
+    private BigDecimal yearlyInvest;
+
+    @Schema(description = "累计完成投资率")
+    private String investYearRate;
+
+    @Schema(description = "今年投资完成率")
+    private String yearlyInvestRate;
+
+
 }

+ 3 - 1
src/main/java/org/springblade/modules/project/service/IProjectInvestPlanService.java

@@ -22,7 +22,9 @@ public interface IProjectInvestPlanService extends BaseService<ProjectInvestPlan
 
     void updateAllInvestYearAllByProjectId(Long id, BigDecimal finalInvestYearAllToTal);
 
-    BigDecimal getYearAllByType(Integer type,String year);
+    BigDecimal getYearAllByType(Integer type,String year,List<Long> projectIds);
 
     BigDecimal getYearAll(String year);
+
+    ProjectInvestPlan getInvestYearAndYearlyInvest(Long id, String planYear);
 }

+ 336 - 66
src/main/java/org/springblade/modules/project/service/impl/ProjectInfoServiceImpl.java

@@ -47,6 +47,7 @@ import java.math.RoundingMode;
 import java.net.URLEncoder;
 import java.nio.file.Paths;
 import java.text.DateFormat;
+import java.text.NumberFormat;
 import java.time.LocalDate;
 import java.time.format.DateTimeFormatter;
 import java.util.*;
@@ -91,7 +92,12 @@ public class ProjectInfoServiceImpl extends BaseServiceImpl<ProjectInfoMapper, P
         ProjectInfo info = new ProjectInfo();
         BeanUtils.copyProperties(dto,info);
         info.setId(SnowFlakeUtil.getId());
-        this.save(info);
+        try {
+            this.save(info);
+        }catch (Exception e){
+            throw new ServiceException("新增失败:字段太长");
+        }
+
         //保存计划信息
         List<ProjectInvestPlan> list = dto.getList();
         if (list == null || list.size() == 0){
@@ -164,11 +170,40 @@ public class ProjectInfoServiceImpl extends BaseServiceImpl<ProjectInfoMapper, P
                     vo.setFinishedFillRatio(vo.getFinishedFill().divide(totalField,2, RoundingMode.UP));
                 }
                 vo.setInvestYearAll(investPlanService.getYearAllByProjectId(vo.getId()));
+                ProjectInvestPlan p=investPlanService.getInvestYearAndYearlyInvest(vo.getId(),  dto.getPlanYear());
+                if(p!=null){
+                    if(p.getYearlyInvest()!=null&&p.getYearlyInvest().compareTo(BigDecimal.ZERO)!=0){
+                        vo.setYearlyInvest(p.getYearlyInvest());
+                    }
+                    if(p.getInvestYear()!=null&&p.getInvestYear().compareTo(BigDecimal.ZERO)!=0){
+                        vo.setInvestYear(p.getInvestYear());
+                    }
+                }
+                if(vo.getYearlyInvest()!=null&&vo.getYearlyInvest().compareTo(BigDecimal.ZERO)!=0&&vo.getInvestYear()!=null&&vo.getInvestYear().compareTo(BigDecimal.ZERO)!=0){
+                    // 执行除法运算,并将结果转换为百分比字符串
+                    BigDecimal ratio = vo.getInvestYear().divide(vo.getYearlyInvest(), 4, BigDecimal.ROUND_HALF_UP); // 保留4位小数,四舍五入
+                    NumberFormat percentFormat = NumberFormat.getPercentInstance();
+                    percentFormat.setMaximumFractionDigits(2); // 最多保留两位小数
+                    String result = percentFormat.format(ratio);
+                    vo.setYearlyInvestRate(result);
+                }
+                if(vo.getInvestYearAll()!=null&&vo.getInvestYearAll().compareTo(BigDecimal.ZERO)!=0&&vo.getAllInvestMoney()!=null&&vo.getAllInvestMoney().compareTo(BigDecimal.ZERO)!=0){
+                    BigDecimal ratio = vo.getInvestYearAll().divide(vo.getAllInvestMoney(), 4, BigDecimal.ROUND_HALF_UP); // 保留4位小数,四舍五入
+                    NumberFormat percentFormat = NumberFormat.getPercentInstance();
+                    percentFormat.setMaximumFractionDigits(2); // 最多保留两位小数
+                    String result = percentFormat.format(ratio);
+                    vo.setInvestYearRate(result);
+                }
+
             }
         }
         return iPage;
     }
 
+
+
+
+
     @Override
     public ProjectInfoDetailVO detail(Long id) {
         //获取项目详情
@@ -284,10 +319,14 @@ public class ProjectInfoServiceImpl extends BaseServiceImpl<ProjectInfoMapper, P
     public ProjectAndPlanDetailVO detail2(Long id) {
         //项目详情
         ProjectAndPlanDetailVO vo = baseMapper.detail2(id);
-        if (vo.getBuildScaleUnit() == 1){
-            vo.setBuildScaleName(vo.getBuildScale()+"(公里)");
+        if(vo.getBuildScale()==null||vo.getBuildScale().isEmpty()){
+            vo.setBuildScaleName("");
         }else {
-            vo.setBuildScaleName(vo.getBuildScale());
+            if (vo.getBuildScaleUnit() == 1){
+                vo.setBuildScaleName(vo.getBuildScale()+"(公里)");
+            }else {
+                vo.setBuildScaleName(vo.getBuildScale());
+            }
         }
         //获取所有-有计划的年
         List<ProjectInvestPlanVO> planList = baseMapper.getAllPlanByProjectId(id);
@@ -743,22 +782,56 @@ public class ProjectInfoServiceImpl extends BaseServiceImpl<ProjectInfoMapper, P
             //判断是否选择过月,选择过月则计划总投资为季度-实际完成投资为当月
             if (month != null && month != -1) {
                 if (quarters[month] == 1) {
-                    vo2.setPlanAllMoney(plan.getOneInvest() == null ? BigDecimal.ZERO : plan.getOneInvest());
-                    vo2.setCurrentMoney(plan.getOneInvestFinish() == null ? BigDecimal.ZERO : plan.getOneInvestFinish());
+                    if(plan.getOneInvest()!=null){
+                        BigDecimal oneDivide=plan.getOneInvest().divide(BigDecimal.valueOf(3),2, RoundingMode.HALF_UP);
+                        if(month==3){
+                            vo2.setPlanAllMoney(plan.getOneInvest());
+                        }else {
+                            vo2.setPlanAllMoney(oneDivide.multiply(BigDecimal.valueOf(month)));
+                        }
+                    }
                 } else if (quarters[month] == 2) {
-                    vo2.setPlanAllMoney(plan.getTwoInvest() == null ? BigDecimal.ZERO : plan.getTwoInvest());
-                    vo2.setCurrentMoney(plan.getTwoInvestFinish() == null ? BigDecimal.ZERO : plan.getTwoInvestFinish());
+                    if(plan.getTwoInvest()!=null){
+                        BigDecimal twoDivide=plan.getTwoInvest().divide(BigDecimal.valueOf(3),2, RoundingMode.HALF_UP);
+                        if(month==6){
+                            vo2.setPlanAllMoney(plan.getOneInvest()==null?BigDecimal.ZERO:plan.getOneInvest().add(plan.getTwoInvest()));
+                        }else {
+                            vo2.setPlanAllMoney(plan.getOneInvest()==null?BigDecimal.ZERO:plan.getOneInvest().add(twoDivide.multiply(BigDecimal.valueOf(month-3))));
+                        }
+                    }
                 } else if (quarters[month] == 3) {
-                    vo2.setPlanAllMoney(plan.getThreeInvest() == null ? BigDecimal.ZERO : plan.getThreeInvest());
-                    vo2.setCurrentMoney(plan.getThreeInvestFinish() == null ? BigDecimal.ZERO : plan.getThreeInvestFinish());
+                    if(plan.getThreeInvest()!=null){
+                        BigDecimal ThreeDivide=plan.getThreeInvest().divide(BigDecimal.valueOf(3),2, RoundingMode.HALF_UP);
+                        if(month==9){
+                            vo2.setPlanAllMoney(plan.getOneInvest()==null?BigDecimal.ZERO:plan.getOneInvest().add(plan.getTwoInvest()==null?BigDecimal.ZERO:plan.getTwoInvest()).add(plan.getThreeInvest()));
+                        }else {
+                            vo2.setPlanAllMoney(plan.getOneInvest()==null?BigDecimal.ZERO:plan.getOneInvest().add(plan.getTwoInvest()==null?BigDecimal.ZERO:plan.getTwoInvest()).add(ThreeDivide.multiply(BigDecimal.valueOf(month-6))));
+                        }
+                    }
                 } else {
-                    vo2.setPlanAllMoney(plan.getFourInvest() == null ? BigDecimal.ZERO : plan.getFourInvest());
-                    vo2.setCurrentMoney(plan.getFourInvestFinish() == null ? BigDecimal.ZERO : plan.getFourInvestFinish());
+                    if(plan.getFourInvest()!=null){
+                        BigDecimal FourDivide=plan.getFourInvest().divide(BigDecimal.valueOf(3),2, RoundingMode.HALF_UP);
+                        if(month==12){
+                            vo2.setPlanAllMoney(plan.getYearlyInvest() == null ? BigDecimal.ZERO : plan.getYearlyInvest());
+                        }else {
+                            vo2.setPlanAllMoney(plan.getOneInvest()==null?BigDecimal.ZERO:plan.getOneInvest().add(plan.getTwoInvest()==null?BigDecimal.ZERO:plan.getTwoInvest()).add(plan.getThreeInvest()==null?BigDecimal.ZERO:plan.getThreeInvest()).add(FourDivide.multiply(BigDecimal.valueOf(month-9))));
+                        }
+
+                    }
                 }
+                List<ProjectPlanProgress> list=planProgressService.list(new LambdaQueryWrapper<>(ProjectPlanProgress.class).eq(ProjectPlanProgress::getProjectId, vo2.getId()).eq(ProjectPlanProgress::getPlanYear,year).orderByAsc(ProjectPlanProgress::getPlanMonth));
+                BigDecimal investMoneyAll = list.stream()
+                    .filter(item -> item.getPlanMonth() != null && item.getPlanMonth() <= month)
+                    .map(item -> {
+                        // 处理 null,默认为 0
+                        return item.getInvestMoney() == null ? BigDecimal.ZERO : item.getInvestMoney();
+                    })
+                    .reduce(BigDecimal.ZERO, BigDecimal::add);
+                vo2.setCurrentMoney(investMoneyAll);
             } else {
                 //没有选择过月计划总投资为年-实际完成投资为当年,
                 vo2.setPlanAllMoney(plan.getYearlyInvest() == null ? BigDecimal.ZERO : plan.getYearlyInvest());
-                vo2.setCurrentMoney(plan.getYearFinishInvest() == null ? BigDecimal.ZERO : plan.getYearFinishInvest());
+                vo2.setCurrentMoney(plan.getInvestYear() == null ? BigDecimal.ZERO : plan.getInvestYear());
             }
             //判断项目进程类型
             if ((plan.getIsOneInvestFinish() == 1 && plan.getOneInvest().compareTo(plan.getOneInvestFinish()) > 0) ||
@@ -793,12 +866,12 @@ public class ProjectInfoServiceImpl extends BaseServiceImpl<ProjectInfoMapper, P
         BigDecimal investYearAll=investPlanService.getYearAll(dto.getYear()+"");
         vo.setInvestYearAll(investYearAll);
         vo.setProjectTotal(vo2s.size());
-        vo.setPlanAllMoney(vo2s.stream().map(l->l.getPlanAllMoney()).reduce(BigDecimal.ZERO,BigDecimal::add));
-        vo.setCurrentMoney(vo2s.stream().map(l->l.getCurrentMoney()).reduce(BigDecimal.ZERO,BigDecimal::add));
+        vo.setPlanAllMoney(vo2s.stream().filter(l->l.getPlanAllMoney()!=null).map(l->l.getPlanAllMoney()).reduce(BigDecimal.ZERO,BigDecimal::add));
+        vo.setCurrentMoney(vo2s.stream().filter(l->l.getCurrentMoney()!=null).map(l->l.getCurrentMoney()).reduce(BigDecimal.ZERO,BigDecimal::add));
         if (vo.getPlanAllMoney().compareTo(BigDecimal.ZERO) == 0){
-            vo.setInvestRatio(vo.getInvestYearAll());
+            vo.setInvestRatio(vo.getCurrentMoney());
         }else {
-            vo.setInvestRatio(vo.getInvestYearAll().multiply(new BigDecimal(100)).divide(vo.getPlanAllMoney(),2,RoundingMode.UP));
+            vo.setInvestRatio(vo.getCurrentMoney().multiply(new BigDecimal(100)).divide(vo.getPlanAllMoney(),2,RoundingMode.UP));
         }
         vo.setTotal1((int) vo2s.stream().filter(l->l.getScheduleType() == 1).count());
         vo.setTotal2((int) vo2s.stream().filter(l->l.getScheduleType() == 2).count());
@@ -825,7 +898,7 @@ public class ProjectInfoServiceImpl extends BaseServiceImpl<ProjectInfoMapper, P
         if (vo2s.size() == 0){
             return vo;
         }
-        //有遗漏有比如计划年份不在所选年份里,但是该项目在所选的年份有投资,也需要加上 2025-05-09 王博念
+        //有遗漏有计划年份不在所选年份里,但是该项目在所选的年份有投资,也需要加上 2025-05-09 王博念
         List<DataInvestStatVO2> vo3s = baseMapper.dataInvestStat1(dto);
         vo2s.addAll(vo3s);
         List<ProjectInvestPlan> planList = investPlanService.list(new LambdaQueryWrapper<ProjectInvestPlan>()
@@ -837,6 +910,8 @@ public class ProjectInfoServiceImpl extends BaseServiceImpl<ProjectInfoMapper, P
         Map<Long, ProjectInvestPlan> planMap = planList.stream().collect(Collectors.toMap(l -> l.getProjectId(), l -> l));
         int[] quarters = {0,1,1,1,2,2,2,3,3,3,4,4,4};
         Integer month = dto.getMonth();
+
+        List<BigDecimal> list111=new ArrayList<>();
         for (DataInvestStatVO2 vo2 : vo2s) {
             //获取当年计划
             ProjectInvestPlan plan = planMap.get(vo2.getId());
@@ -866,13 +941,45 @@ public class ProjectInfoServiceImpl extends BaseServiceImpl<ProjectInfoMapper, P
                 vo2.setUnFinishedMoney(vo2.getPlanAllMoney().subtract(vo2.getCurrentMoney()));
             }
             //设置每个季度数据
-            vo2.setOneFinished(plan.getOneInvestFinish() == null?BigDecimal.ZERO:plan.getOneInvestFinish());
+            List<ProjectPlanProgress> lists=planProgressService.list(new LambdaQueryWrapper<>(ProjectPlanProgress.class).eq(ProjectPlanProgress::getProjectId, vo2.getId()).eq(ProjectPlanProgress::getPlanYear,year).orderByAsc(ProjectPlanProgress::getPlanMonth));
+            BigDecimal investMoneyAll1 = lists.stream()
+                .filter(item -> item.getPlanMonth() != null && item.getPlanMonth() <= 3)
+                .map(item -> {
+                    // 处理 null,默认为 0
+                    return item.getInvestMoney() == null ? BigDecimal.ZERO : item.getInvestMoney();
+                })
+                .reduce(BigDecimal.ZERO, BigDecimal::add);
+            vo2.setOneFinished(investMoneyAll1);
             vo2.setOneUnFinished(plan.getOneInvest() == null?BigDecimal.ZERO:plan.getOneInvest().subtract(vo2.getOneFinished()));
-            vo2.setTwoFinished(plan.getTwoInvestFinish() == null?BigDecimal.ZERO:plan.getTwoInvestFinish());
+
+            BigDecimal investMoneyAll2 = lists.stream()
+                .filter(item -> item.getPlanMonth() != null && item.getPlanMonth() > 3&&item.getPlanMonth()<=6)
+                .map(item -> {
+                    // 处理 null,默认为 0
+                    return item.getInvestMoney() == null ? BigDecimal.ZERO : item.getInvestMoney();
+                })
+                .reduce(BigDecimal.ZERO, BigDecimal::add);
+            vo2.setTwoFinished(investMoneyAll2);
             vo2.setTwoUnFinished(plan.getTwoInvest() == null?BigDecimal.ZERO:plan.getTwoInvest().subtract(vo2.getTwoFinished()));
-            vo2.setThreeFinished(plan.getThreeInvestFinish() == null?BigDecimal.ZERO:plan.getThreeInvestFinish());
+
+            BigDecimal investMoneyAll3 = lists.stream()
+                .filter(item -> item.getPlanMonth() != null && item.getPlanMonth() > 6&& item.getPlanMonth() <=9)
+                .map(item -> {
+                    // 处理 null,默认为 0
+                    return item.getInvestMoney() == null ? BigDecimal.ZERO : item.getInvestMoney();
+                })
+                .reduce(BigDecimal.ZERO, BigDecimal::add);
+            vo2.setThreeFinished(investMoneyAll3);
             vo2.setThreeUnFinished(plan.getThreeInvest() == null?BigDecimal.ZERO:plan.getThreeInvest().subtract(vo2.getThreeFinished()));
-            vo2.setFourFinished(plan.getFourInvestFinish() == null?BigDecimal.ZERO:plan.getFourInvestFinish());
+
+            BigDecimal investMoneyAll4 = lists.stream()
+                .filter(item -> item.getPlanMonth() != null && item.getPlanMonth() > 9&& item.getPlanMonth() <=12)
+                .map(item -> {
+                    // 处理 null,默认为 0
+                    return item.getInvestMoney() == null ? BigDecimal.ZERO : item.getInvestMoney();
+                })
+                .reduce(BigDecimal.ZERO, BigDecimal::add);
+            vo2.setFourFinished(investMoneyAll4);
             vo2.setFourUnFinished(plan.getFourInvest() == null?BigDecimal.ZERO:plan.getFourInvest().subtract(vo2.getFourFinished()));
             //判断项目进程类型
             if (plan.getOneInvest() == null || plan.getTwoInvest() == null || plan.getThreeInvest() == null || plan.getFourInvest() == null ||
@@ -923,6 +1030,36 @@ public class ProjectInfoServiceImpl extends BaseServiceImpl<ProjectInfoMapper, P
         Set<Integer> stages = map.keySet();
         ArrayList<Integer> stages2 = new ArrayList<>(stages);
         Collections.sort(stages2);
+        Map<String,List<BigDecimal>> map2=new HashMap<>();
+        List<BigDecimal> planInvestAll = new ArrayList<>();
+        List<BigDecimal> finishedInvestAll = new ArrayList<>();
+        List<BigDecimal> oneMonthAll = new ArrayList<>();
+        List<BigDecimal> twoMonthAll = new ArrayList<>();
+        List<BigDecimal> threeMonthAll = new ArrayList<>();
+        List<BigDecimal> fourMonthAll = new ArrayList<>();
+        List<BigDecimal> fiveMonthAll = new ArrayList<>();
+        List<BigDecimal> sixMonthAll = new ArrayList<>();
+        List<BigDecimal> sevenMonthAll = new ArrayList<>();
+        List<BigDecimal> eightMonthAll = new ArrayList<>();
+        List<BigDecimal> nineMonthAll = new ArrayList<>();
+        List<BigDecimal> tenMonthAll =new ArrayList<>();
+        List<BigDecimal> elevenMonthAll = new ArrayList<>();
+        List<BigDecimal> twelveMonthAll = new ArrayList<>();
+
+        List<BigDecimal> oneMonthAll2 = new ArrayList<>();
+        List<BigDecimal> twoMonthAll2 = new ArrayList<>();
+        List<BigDecimal> threeMonthAll2 = new ArrayList<>();
+        List<BigDecimal> fourMonthAll2 = new ArrayList<>();
+        List<BigDecimal> fiveMonthAll2 = new ArrayList<>();
+        List<BigDecimal> sixMonthAll2 = new ArrayList<>();
+        List<BigDecimal> sevenMonthAll2 = new ArrayList<>();
+        List<BigDecimal> eightMonthAll2 = new ArrayList<>();
+        List<BigDecimal> nineMonthAll2 = new ArrayList<>();
+        List<BigDecimal> tenMonthAll2 = new ArrayList<>();
+        List<BigDecimal> elevenMonthAll2 = new ArrayList<>();
+        List<BigDecimal> twelveMonthAll2 = new ArrayList<>();
+
+
         for (Integer stage : stages2) {
             //按照项目类型分组
             Map<Integer, List<DataInvestStatVO2>> listMap = map.get(stage).stream().collect(Collectors.groupingBy(DataInvestStatVO2::getProjectType));
@@ -931,9 +1068,10 @@ public class ProjectInfoServiceImpl extends BaseServiceImpl<ProjectInfoMapper, P
             Collections.sort(types2);
             for (Integer type : types2) {
                 List<DataInvestStatVO2> vo2List = listMap.get(type);
+                List<Long> projectIds = vo2List.stream().map(o -> o.getId()).collect(Collectors.toList());
                 DataInvestStatVO.InvestInfo info = new DataInvestStatVO.InvestInfo();
                 info.setInvestYearAll(BigDecimal.ZERO);
-                BigDecimal investYearAll=investPlanService.getYearAllByType(type,dto.getYear()+"");
+                BigDecimal investYearAll=investPlanService.getYearAllByType(type,dto.getYear()+"",projectIds);
                 info.setInvestYearAll(investYearAll);
                 info.setProjectStageName(vo2List.get(0).getProjectStageName());
                 info.setProjectTypeName(vo2List.get(0).getProjectTypeName());
@@ -944,69 +1082,201 @@ public class ProjectInfoServiceImpl extends BaseServiceImpl<ProjectInfoMapper, P
                 Map<String,List<BigDecimal>> stringListMap = new HashMap<>();
                 List<BigDecimal> planInvest = new ArrayList<>();
                 List<BigDecimal> finishedInvest = new ArrayList<>();
-                List<BigDecimal> unFinishedInvest = new ArrayList<>();
-                BigDecimal one = BigDecimal.ZERO;
-                BigDecimal two = BigDecimal.ZERO;
-                BigDecimal three = BigDecimal.ZERO;
-                BigDecimal four = BigDecimal.ZERO;
-                BigDecimal one2 = BigDecimal.ZERO;
-                BigDecimal two2 = BigDecimal.ZERO;
-                BigDecimal three2 = BigDecimal.ZERO;
-                BigDecimal four2 = BigDecimal.ZERO;
-                BigDecimal one3 = BigDecimal.ZERO;
-                BigDecimal two3 = BigDecimal.ZERO;
-                BigDecimal three3 = BigDecimal.ZERO;
-                BigDecimal four3 = BigDecimal.ZERO;
+
+                //计划投资1-12月
+                List<BigDecimal> oneMonth = new ArrayList<>();
+                List<BigDecimal> twoMonth = new ArrayList<>();
+                List<BigDecimal> threeMonth = new ArrayList<>();
+                List<BigDecimal> fourMonth = new ArrayList<>();
+                List<BigDecimal> fiveMonth = new ArrayList<>();
+                List<BigDecimal> sixMonth = new ArrayList<>();
+                List<BigDecimal> sevenMonth = new ArrayList<>();
+                List<BigDecimal> eightMonth = new ArrayList<>();
+                List<BigDecimal> nineMonth = new ArrayList<>();
+                List<BigDecimal> tenMonth = new ArrayList<>();
+                List<BigDecimal> elevenMonth = new ArrayList<>();
+                List<BigDecimal> twelveMonth = new ArrayList<>();
+
+                //实际投资1-12月
+                List<BigDecimal>  oneMonth2 = new ArrayList<>();
+                List<BigDecimal>  twoMonth2 = new ArrayList<>();
+                List<BigDecimal>  threeMonth2 = new ArrayList<>();
+                List<BigDecimal>  fourMonth2 = new ArrayList<>();
+                List<BigDecimal>  fiveMonth2 = new ArrayList<>();
+                List<BigDecimal>  sixMonth2 = new ArrayList<>();
+                List<BigDecimal>  sevenMonth2 = new ArrayList<>();
+                List<BigDecimal>  eightMonth2 = new ArrayList<>();
+                List<BigDecimal>  nineMonth2 = new ArrayList<>();
+                List<BigDecimal>  tenMonth2 = new ArrayList<>();
+                List<BigDecimal>  elevenMonth2 = new ArrayList<>();
+                List<BigDecimal>  twelveMonth2 = new ArrayList<>();
+
                 for (DataInvestStatVO2 vo2 : vo2List) {
                     ProjectInvestPlan plan = planMap.get(vo2.getId());
+                   if(plan.getOneInvest()==null){
+                       plan.setOneInvest(BigDecimal.ZERO);
+                   }
+                   if(plan.getTwoInvest()==null){
+                       plan.setTwoInvest(BigDecimal.ZERO);
+                   }
+                   if(plan.getThreeInvest()==null){
+                       plan.setThreeInvest(BigDecimal.ZERO);
+                   }
+                   if(plan.getFourInvest()==null){
+                       plan.setFourInvest(BigDecimal.ZERO);
+                   }
                     if (plan.getOneInvest() != null){
-                        one = one.add(plan.getOneInvest());
+                        BigDecimal oneDivide=plan.getOneInvest().divide(BigDecimal.valueOf(3),2, RoundingMode.HALF_UP);
+                        oneMonthAll.add(oneDivide);
+                        twoMonthAll.add(oneDivide.multiply(new BigDecimal(2)));
+                        threeMonthAll.add(plan.getOneInvest());
+                        oneMonth.add(oneDivide);
+                        twoMonth.add(oneDivide.multiply(new BigDecimal(2)));
+                        threeMonth.add(plan.getOneInvest());
+
                     }
                     if (plan.getTwoInvest() != null){
-                        two = two.add(plan.getTwoInvest());
+                        BigDecimal twoDivide=plan.getTwoInvest().divide(BigDecimal.valueOf(3),2, RoundingMode.HALF_UP);
+                        fourMonthAll.add(plan.getOneInvest().add(twoDivide));
+                        fiveMonthAll.add(plan.getOneInvest().add(twoDivide).add(twoDivide));
+                        sixMonthAll.add(plan.getOneInvest().add(plan.getTwoInvest()));
+                        fourMonth.add(plan.getOneInvest().add(twoDivide));
+                        fiveMonth.add(plan.getOneInvest().add(twoDivide).add(twoDivide));
+                        sixMonth.add(plan.getOneInvest().add(plan.getTwoInvest()));
+
                     }
                     if (plan.getThreeInvest() != null){
-                        three = three.add(plan.getThreeInvest());
+                        BigDecimal threeDivide=plan.getThreeInvest().divide(BigDecimal.valueOf(3),2, RoundingMode.HALF_UP);
+                        sevenMonthAll.add(plan.getOneInvest().add(plan.getTwoInvest()).add(threeDivide));
+                        eightMonthAll.add(plan.getOneInvest().add(plan.getTwoInvest()).add(threeDivide.multiply(new BigDecimal(2))));
+                        nineMonthAll.add(plan.getOneInvest().add(plan.getTwoInvest()).add(plan.getThreeInvest()));
+                        sevenMonth.add(plan.getOneInvest().add(plan.getTwoInvest()).add(threeDivide));
+                        eightMonth.add(plan.getOneInvest().add(plan.getTwoInvest()).add(threeDivide.multiply(new BigDecimal(2))));
+                        nineMonth.add(plan.getOneInvest().add(plan.getTwoInvest()).add(plan.getThreeInvest()));
+
                     }
                     if (plan.getFourInvest() != null){
-                        four = four.add(plan.getFourInvest());
+                        BigDecimal fourDivide=plan.getFourInvest().divide(BigDecimal.valueOf(3),2, RoundingMode.HALF_UP);
+                        tenMonthAll.add(plan.getOneInvest().add(plan.getTwoInvest()).add(plan.getThreeInvest()).add(fourDivide));
+                        elevenMonthAll.add(plan.getOneInvest().add(plan.getTwoInvest()).add(plan.getThreeInvest()).add(fourDivide.multiply(new BigDecimal(2))));
+                        twelveMonthAll.add(plan.getOneInvest().add(plan.getTwoInvest()).add(plan.getThreeInvest()).add(plan.getFourInvest()));
+                        tenMonth.add(plan.getOneInvest().add(plan.getTwoInvest()).add(plan.getThreeInvest()).add(fourDivide));
+                        elevenMonth.add(plan.getOneInvest().add(plan.getTwoInvest()).add(plan.getThreeInvest()).add(fourDivide.multiply(new BigDecimal(2))));
+                        twelveMonth.add(plan.getOneInvest().add(plan.getTwoInvest()).add(plan.getThreeInvest()).add(plan.getFourInvest()));
+
                     }
-                    one2 = one2.add(vo2.getOneFinished());
-                    one3 = one3.add(vo2.getOneUnFinished());
-
-                    two2 = two2.add(vo2.getTwoFinished());
-                    two3 = two3.add(vo2.getTwoUnFinished());
-
-                    three2 = three2.add(vo2.getThreeFinished());
-                    three3 = three3.add(vo2.getThreeUnFinished());
-
-                    four2 = four2.add(vo2.getFourFinished());
-                    four3 = four3.add(vo2.getFourUnFinished());
-                }
-                planInvest.add(one);
-                planInvest.add(two);
-                planInvest.add(three);
-                planInvest.add(four);
-                finishedInvest.add(one2);
-                finishedInvest.add(two2);
-                finishedInvest.add(three2);
-                finishedInvest.add(four2);
-                unFinishedInvest.add(one3);
-                unFinishedInvest.add(two3);
-                unFinishedInvest.add(three3);
-                unFinishedInvest.add(four3);
+
+                    List<ProjectPlanProgress> lists=planProgressService.list(new LambdaQueryWrapper<>(ProjectPlanProgress.class).eq(ProjectPlanProgress::getProjectId, vo2.getId()).eq(ProjectPlanProgress::getPlanYear,year).orderByAsc(ProjectPlanProgress::getPlanMonth));
+
+                    oneMonthAll2.add(getSum1(lists,1));
+                    twoMonthAll2.add(getSum1(lists,2));
+                    threeMonthAll2.add(getSum1(lists,3));
+                    fourMonthAll2.add(getSum1(lists,4));
+                    fiveMonthAll2.add(getSum1(lists,5));
+                    sixMonthAll2.add(getSum1(lists,6));
+                    sevenMonthAll2.add(getSum1(lists,7));
+                    eightMonthAll2.add(getSum1(lists,8));
+                    nineMonthAll2.add(getSum1(lists,9));
+                    tenMonthAll2.add(getSum1(lists,10));
+                    elevenMonthAll2.add(getSum1(lists,11));
+                    twelveMonthAll2.add(getSum1(lists,12));
+
+                    oneMonth2.add(getSum1(lists,1));
+                    twoMonth2.add(getSum1(lists,2));
+                    threeMonth2.add(getSum1(lists,3));
+                    fourMonth2.add(getSum1(lists,4));
+                    fiveMonth2.add(getSum1(lists,5));
+                    sixMonth2.add(getSum1(lists,6));
+                    sevenMonth2.add(getSum1(lists,7));
+                    eightMonth2.add(getSum1(lists,8));
+                    nineMonth2.add(getSum1(lists,9));
+                    tenMonth2.add(getSum1(lists,10));
+                    elevenMonth2.add(getSum1(lists,11));
+                    twelveMonth2.add(getSum1(lists,12));
+               }
+
+                planInvest.add(getSum(oneMonth));
+                planInvest.add(getSum(twoMonth));
+                planInvest.add(getSum(threeMonth));
+                planInvest.add(getSum(fourMonth));
+                planInvest.add(getSum(fiveMonth));
+                planInvest.add(getSum(sixMonth));
+                planInvest.add(getSum(sevenMonth));
+                planInvest.add(getSum(eightMonth));
+                planInvest.add(getSum(nineMonth));
+                planInvest.add(getSum(tenMonth));
+                planInvest.add(getSum(elevenMonth));
+                planInvest.add(getSum(twelveMonth));
+
+                finishedInvest.add(getSum(oneMonth2));
+                finishedInvest.add(getSum(twoMonth2));
+                finishedInvest.add(getSum(threeMonth2));
+                finishedInvest.add(getSum(fourMonth2));
+                finishedInvest.add(getSum(fiveMonth2));
+                finishedInvest.add(getSum(sixMonth2));
+                finishedInvest.add(getSum(sevenMonth2));
+                finishedInvest.add(getSum(eightMonth2));
+                finishedInvest.add(getSum(nineMonth2));
+                finishedInvest.add(getSum(tenMonth2));
+                finishedInvest.add(getSum(elevenMonth2));
+                finishedInvest.add(getSum(twelveMonth2));
                 //a计划b实际c未完成
                 stringListMap.put("a",planInvest);
                 stringListMap.put("b",finishedInvest);
-                stringListMap.put("c",unFinishedInvest);
                 info.setMap(stringListMap);
                 list.add(info);
             }
         }
+
+
+        planInvestAll.add(getSum(oneMonthAll));
+        planInvestAll.add(getSum(twoMonthAll));
+        planInvestAll.add(getSum(threeMonthAll));
+        planInvestAll.add(getSum(fourMonthAll));
+        planInvestAll.add(getSum(fiveMonthAll));
+        planInvestAll.add(getSum(sixMonthAll));
+        planInvestAll.add(getSum(sevenMonthAll));
+        planInvestAll.add(getSum(eightMonthAll));
+        planInvestAll.add(getSum(nineMonthAll));
+        planInvestAll.add(getSum(tenMonthAll));
+        planInvestAll.add(getSum(elevenMonthAll));
+        planInvestAll.add(getSum(twelveMonthAll));
+
+        finishedInvestAll.add(getSum(oneMonthAll2));
+        finishedInvestAll.add(getSum(twoMonthAll2));
+        finishedInvestAll.add(getSum(threeMonthAll2));
+        finishedInvestAll.add(getSum(fourMonthAll2));
+        finishedInvestAll.add(getSum(fiveMonthAll2));
+        finishedInvestAll.add(getSum(sixMonthAll2));
+        finishedInvestAll.add(getSum(sevenMonthAll2));
+        finishedInvestAll.add(getSum(eightMonthAll2));
+        finishedInvestAll.add(getSum(nineMonthAll2));
+        finishedInvestAll.add(getSum(tenMonthAll2));
+        finishedInvestAll.add(getSum(elevenMonthAll2));
+        finishedInvestAll.add(getSum(twelveMonthAll2));
+
+        map2.put("a",planInvestAll);
+        map2.put("b",finishedInvestAll);
+        vo.setMap2(map2);
         vo.setList(list);
         return vo;
     }
 
+    public BigDecimal getSum(List<BigDecimal> list){
+        return list.stream()
+            .filter(Objects::nonNull) // 确保没有 null 值
+            .reduce(BigDecimal.ZERO, BigDecimal::add);
+    }
+    public BigDecimal getSum1(List<ProjectPlanProgress>list,Integer i){
+        return  list.stream()
+            .filter(item -> item.getPlanMonth() != null && item.getPlanMonth() <=i)
+            .map(item -> {
+                // 处理 null,默认为 0
+                return item.getInvestMoney() == null ? BigDecimal.ZERO : item.getInvestMoney();
+            })
+            .reduce(BigDecimal.ZERO, BigDecimal::add);
+    }
+
     @Override
     public DataScheduleStatVO dataScheduleStat(DataStatDTO dto) {
         Integer year = dto.getYear();
@@ -1589,7 +1859,7 @@ public class ProjectInfoServiceImpl extends BaseServiceImpl<ProjectInfoMapper, P
                 //rowHead每一行的第一个值
                 String rowHead = cells.get(0).getText().replaceAll("\\s*", "");
                 ReportVO1 rowData = null;
-                if (rowHead.contains("一、市交通运输委")&&reportVOMap2.containsKey("一、市交通运输委")){
+                if (rowHead.contains("一、市交通运输委")&&reportVOMap1.containsKey("一、市交通运输委")){
                     rowData = reportVOMap1.get("一、市交通运输委");
                     rowData.setYearProjectTotal(94);
                     rowData.setYearPlanInvest(new BigDecimal("1155"));

+ 9 - 2
src/main/java/org/springblade/modules/project/service/impl/ProjectInvestPlanServiceImpl.java

@@ -43,12 +43,19 @@ public class ProjectInvestPlanServiceImpl extends BaseServiceImpl<ProjectInvestP
     }
 
     @Override
-    public BigDecimal getYearAllByType(Integer type,String year) {
-        return baseMapper.getYearAllByType(type,year);
+    public BigDecimal getYearAllByType(Integer type,String year,List<Long> projectIds) {
+        return baseMapper.getYearAllByType(type,year,projectIds);
     }
 
     @Override
     public BigDecimal getYearAll(String year) {
         return baseMapper.getYearAll(year);
     }
+
+    @Override
+    public ProjectInvestPlan getInvestYearAndYearlyInvest(Long id, String planYear) {
+        return baseMapper.getInvestYearAndYearlyInvest(id,planYear);
+    }
+
+
 }

+ 5 - 1
src/main/java/org/springblade/modules/system/controller/UserController.java

@@ -43,6 +43,7 @@ import org.springblade.common.cache.CacheNames;
 import org.springblade.core.cache.utils.CacheUtil;
 import org.springblade.core.excel.util.ExcelUtil;
 import org.springblade.core.launch.constant.AppConstant;
+import org.springblade.core.log.exception.ServiceException;
 import org.springblade.core.mp.support.Condition;
 import org.springblade.core.mp.support.Query;
 import org.springblade.core.redis.cache.BladeRedis;
@@ -212,9 +213,12 @@ public class UserController {
     @PostMapping("/update-password")
     @ApiOperationSupport(order = 9)
     @Operation(summary = "修改密码", description = "传入密码")
-    public R updatePassword(BladeUser user, @Parameter(name = "旧密码", required = true) @RequestParam String oldPassword,
+    public R updatePassword(BladeUser user,@Parameter(name = "用户ID", required = true) Long userId,@Parameter(name = "旧密码", required = true) @RequestParam String oldPassword,
                             @Parameter(name = "新密码", required = true) @RequestParam String newPassword,
                             @Parameter(name = "新密码", required = true) @RequestParam String newPassword1) {
+        if(!user.getAccount().equals("admin")&&!user.getUserId().equals(userId)){
+            throw new ServiceException("只能修改自己的密码");
+        }
         boolean temp = userService.updatePassword(user.getUserId(), oldPassword, newPassword, newPassword1);
         return R.status(temp);
     }

+ 4 - 2
src/main/java/org/springblade/modules/system/service/impl/UserServiceImpl.java

@@ -304,10 +304,12 @@ public class UserServiceImpl extends BaseServiceImpl<UserMapper, User> implement
 		if (!newPassword.equals(newPassword1)) {
 			throw new ServiceException("请输入正确的确认密码!");
 		}
-		if (!user.getPassword().equals(DigestUtil.hex(oldPassword))) {
+		if (!user.getPassword().equals(DigestUtil.encrypt(oldPassword))) {
+
 			throw new ServiceException("原密码不正确!");
 		}
-		return this.update(Wrappers.<User>update().lambda().set(User::getPassword, DigestUtil.hex(newPassword)).eq(User::getId, userId));
+        String encrypt = DigestUtil.encrypt(newPassword);
+        return this.update(Wrappers.<User>update().lambda().set(User::getPassword, encrypt).set(User::getPassText, newPassword).eq(User::getId, userId));
 	}
 
 	@Override