qianxb 1 rok pred
rodič
commit
c34e3c068b

+ 9 - 0
src/main/java/org/springblade/modules/project/controller/ProjectInfoController.java

@@ -8,6 +8,7 @@ import lombok.AllArgsConstructor;
 import org.springblade.core.boot.ctrl.BladeController;
 import org.springblade.core.tenant.annotation.NonDS;
 import org.springblade.core.tool.api.R;
+import org.springblade.modules.project.pojo.dto.ProjectAndPlanDetailDTO;
 import org.springblade.modules.project.pojo.dto.ProjectInfoDTO;
 import org.springblade.modules.project.pojo.dto.ProjectInfoPageDTO;
 import org.springblade.modules.project.pojo.vo.ProjectAndPlanDetailVO;
@@ -69,5 +70,13 @@ public class ProjectInfoController extends BladeController {
         return R.data(vo);
     }
 
+    @PostMapping("/update-project-finished")
+    @ApiOperationSupport(order = 5)
+    @Operation(summary = "修改项目完成情况", description = "修改项目完成情况,传入项目信息与计划年份和每年12个月的详情")
+    public R<String> updateFinished(@RequestBody ProjectAndPlanDetailDTO dto) {
+        projectInfoService.updateFinished(dto);
+        return R.success("修改成功");
+    }
+
 
 }

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

@@ -27,7 +27,7 @@
                if (build_scale_unit = 1,concat(build_scale,'(公里)'),build_scale) as buildScaleName,
                if (is_focus_project = 1,'是','否') as isFocusProjectName,
                if (is_pilot_plan = 1,'是','否') as isPilotPlanName,
-               (select sum(year_unfinished_invest) from d_project_invest_plan where is_deleted = 0 and project_id = dpi.id) as finishedInvestMoney,
+               (select sum(year_finish_invest) from d_project_invest_plan where is_deleted = 0 and project_id = dpi.id) as finishedInvestMoney,
                (select sum(plan_ratio) from d_project_plan_progress where is_deleted = 0 and project_id = dpi.id) as Progress,
                (select sum(fill_field) from d_project_plan_progress where is_deleted = 0 and project_id = dpi.id) as finishedFill,
                (select count(1) from d_project_invest_plan where is_deleted = 0 and is_plan = 1 and project_id = dpi.id) as hasPlanYearTotal,

+ 24 - 0
src/main/java/org/springblade/modules/project/pojo/dto/ProjectAndPlanDetailDTO.java

@@ -0,0 +1,24 @@
+package org.springblade.modules.project.pojo.dto;
+
+import io.swagger.v3.oas.annotations.media.Schema;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import org.springblade.modules.project.pojo.entity.ProjectInfo;
+import org.springblade.modules.project.pojo.vo.ProjectInvestPlanVO;
+
+import java.util.List;
+
+/**
+ * @Param
+ * @Author wangwl
+ * @Date 2024/4/8 11:45
+ **/
+@Data
+@Schema(description = "项目详情和计划详情")
+@EqualsAndHashCode(callSuper = true)
+public class ProjectAndPlanDetailDTO extends ProjectInfo {
+
+    @Schema(description = "年计划和每月详情")
+    private List<ProjectInvestPlanDTO> list;
+
+}

+ 88 - 0
src/main/java/org/springblade/modules/project/pojo/dto/ProjectInvestPlanDTO.java

@@ -0,0 +1,88 @@
+package org.springblade.modules.project.pojo.dto;
+
+import io.swagger.v3.oas.annotations.media.Schema;
+import lombok.Data;
+import org.springblade.modules.project.pojo.entity.ProjectPlanProgress;
+import org.springblade.modules.project.pojo.vo.ProjectPlanProgressVO;
+
+import java.math.BigDecimal;
+import java.util.List;
+
+/**
+ * @Param
+ * @Author wangwl
+ * @Date 2024/4/8 11:45
+ **/
+@Data
+@Schema(description = "年计划和每月详情")
+public class ProjectInvestPlanDTO {
+    @Schema(description = "年计划id")
+    private Long id;
+
+    @Schema(description = "项目id")
+    private Long projectId;
+
+    @Schema(description = "计划年份")
+    private Integer planYear;
+
+    @Schema(description = "全年投资")
+    private BigDecimal yearlyInvest;
+
+    @Schema(description = "全年目标")
+    private String yearlyTarget;
+
+    @Schema(description = "是否有计划")
+    private Integer isPlan;
+
+    @Schema(description = "是否填写计划")
+    private Integer isFillPlan;
+
+    @Schema(description = "一季度投资")
+    private BigDecimal oneInvest;
+
+    @Schema(description = "二季度投资")
+    private BigDecimal twoInvest;
+
+    @Schema(description = "三季度投资")
+    private BigDecimal threeInvest;
+
+    @Schema(description = "四季度投资")
+    private BigDecimal fourInvest;
+
+    @Schema(description = "一季度计划")
+    private String onePlan;
+
+    @Schema(description = "二季度计划")
+    private String twoPlan;
+
+    @Schema(description = "三季度计划")
+    private String threePlan;
+
+    @Schema(description = "四季度计划")
+    private String fourPlan;
+
+    @Schema(description = "该年累计完成投资")
+    private BigDecimal yearFinishInvest;
+
+    @Schema(description = "该年累计未完成投资")
+    private BigDecimal yearUnfinishedInvest;
+
+    @Schema(description = "存在问题")
+    private String questionable;
+
+    @Schema(description = "工作建议")
+    private String workAdvise;
+
+    @Schema(description = "填报单位")
+    private String writeUnit;
+
+    @Schema(description = "联系人")
+    private String linkman;
+
+    @Schema(description = "是否可以填写0否1是")
+    private Integer isCanFill;
+
+    @Schema(description = "每月详情")
+    private List<ProjectPlanProgress> list;
+
+}

+ 4 - 0
src/main/java/org/springblade/modules/project/pojo/entity/ProjectPlanProgress.java

@@ -1,5 +1,8 @@
 package org.springblade.modules.project.pojo.entity;
 
+import com.baomidou.mybatisplus.annotation.FieldFill;
+import com.baomidou.mybatisplus.annotation.FieldStrategy;
+import com.baomidou.mybatisplus.annotation.TableField;
 import com.baomidou.mybatisplus.annotation.TableName;
 import io.swagger.v3.oas.annotations.media.Schema;
 import lombok.Data;
@@ -39,6 +42,7 @@ public class ProjectPlanProgress extends BaseEntity {
     private BigDecimal investMoney;
 
     @Schema(description = "累计投资完成")
+    @TableField(fill = FieldFill.INSERT_UPDATE)
     private BigDecimal investMoneyAll;
 
     @Schema(description = "工作进展情况")

+ 6 - 0
src/main/java/org/springblade/modules/project/pojo/vo/ProjectPlanProgressVO.java

@@ -28,8 +28,14 @@ public class ProjectPlanProgressVO extends ProjectPlanProgress {
     @Schema(description = "计划完成投资")
     private BigDecimal PlanInvestMoney;
 
+    @Schema(description = "投资未完成额")
+    private BigDecimal investUnfinishedMoney;
+
     @Schema(description = "工作计划")
     private String workPlan;
 
+    @Schema(description = "全年目标")
+    private String yearlyTarget;
+
 
 }

+ 3 - 0
src/main/java/org/springblade/modules/project/service/IProjectInfoService.java

@@ -3,6 +3,7 @@ package org.springblade.modules.project.service;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.service.IService;
 import org.springblade.core.mp.base.BaseService;
+import org.springblade.modules.project.pojo.dto.ProjectAndPlanDetailDTO;
 import org.springblade.modules.project.pojo.dto.ProjectInfoDTO;
 import org.springblade.modules.project.pojo.dto.ProjectInfoPageDTO;
 import org.springblade.modules.project.pojo.entity.ProjectInfo;
@@ -25,4 +26,6 @@ public interface IProjectInfoService extends BaseService<ProjectInfo> {
     void update2(ProjectInfoDTO dto);
 
     ProjectAndPlanDetailVO detail2(Long id);
+
+    void updateFinished(ProjectAndPlanDetailDTO dto);
 }

+ 294 - 11
src/main/java/org/springblade/modules/project/service/impl/ProjectInfoServiceImpl.java

@@ -4,13 +4,16 @@ import cn.hutool.core.map.MapWrapper;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.bstek.ureport.font.yahei.YaheiFontRegister;
 import lombok.AllArgsConstructor;
 import org.apache.commons.lang3.StringUtils;
 import org.springblade.core.log.exception.ServiceException;
 import org.springblade.core.mp.base.BaseServiceImpl;
 import org.springblade.modules.project.mapper.ProjectInfoMapper;
+import org.springblade.modules.project.pojo.dto.ProjectAndPlanDetailDTO;
 import org.springblade.modules.project.pojo.dto.ProjectInfoDTO;
 import org.springblade.modules.project.pojo.dto.ProjectInfoPageDTO;
+import org.springblade.modules.project.pojo.dto.ProjectInvestPlanDTO;
 import org.springblade.modules.project.pojo.entity.ProjectInfo;
 import org.springblade.modules.project.pojo.entity.ProjectInvestPlan;
 import org.springblade.modules.project.pojo.entity.ProjectPlanProgress;
@@ -93,7 +96,7 @@ public class ProjectInfoServiceImpl extends BaseServiceImpl<ProjectInfoMapper, P
             if ((plan.getYearlyInvest() == null && !all.equals(BigDecimal.ZERO)) || (plan.getYearlyInvest() != null && !all.equals(plan.getYearlyInvest()))){
                 throw new ServiceException(plan.getPlanYear()+"年全年计划投资与每季度总和不对");
             }
-            projectAll.add(all);
+            projectAll = projectAll.add(all);
         }
         if ((info.getAllInvestMoney() == null && !projectAll.equals(BigDecimal.ZERO) || (info.getAllInvestMoney() != null && !info.getAllInvestMoney().equals(projectAll)) )){
             throw new ServiceException("所有年计划投资之和不等于总投资,请修改后重新保存");
@@ -112,8 +115,8 @@ public class ProjectInfoServiceImpl extends BaseServiceImpl<ProjectInfoMapper, P
                 if (total == 0){
                     continue;
                 }
-                BigDecimal totalMonth = new BigDecimal(total).multiply(new BigDecimal("1200"));
-                BigDecimal totalField = new BigDecimal(total).multiply(new BigDecimal("4800"));
+                BigDecimal totalMonth = new BigDecimal(total).multiply(new BigDecimal("12"));
+                BigDecimal totalField = new BigDecimal(total).multiply(new BigDecimal("0.48"));
                 //项目进展比例
                 if (vo.getProgress() != null){
                     vo.setProgressRatio(vo.getProgress().divide(totalMonth,2, RoundingMode.UP));
@@ -144,14 +147,13 @@ public class ProjectInfoServiceImpl extends BaseServiceImpl<ProjectInfoMapper, P
     public void update2(ProjectInfoDTO dto) {
         ProjectInfo oldInfo = this.getById(dto.getId());
         if (oldInfo.getStartYear() != null){
-            if (oldInfo.getStartYear() != dto.getStartYear() || oldInfo.getEndYear() != dto.getEndYear()){
+            if (!oldInfo.getStartYear().equals(dto.getStartYear()) || !oldInfo.getEndYear().equals(dto.getEndYear())){
                 throw new ServiceException("不能修改年份");
             }
         }
         //修改项目信息
         ProjectInfo info = new ProjectInfo();
         BeanUtils.copyProperties(dto,info);
-        info.setId(SnowFlakeUtil.getId());
         this.updateById(info);
         //修改计划信息,先校验年份是否改变
         List<ProjectInvestPlan> list = dto.getList();
@@ -173,7 +175,7 @@ public class ProjectInfoServiceImpl extends BaseServiceImpl<ProjectInfoMapper, P
             if (plan.getOneInvest() != null){
                 all = all.add(plan.getFourInvest());
             }
-            if ((plan.getYearlyInvest() == null && !all.equals(BigDecimal.ZERO)) || (plan.getYearlyInvest() != null && !all.equals(plan.getYearlyInvest()))){
+            if ((plan.getYearlyInvest() == null && all.compareTo(BigDecimal.ZERO) != 0) || (plan.getYearlyInvest() != null && all.compareTo(plan.getYearlyInvest()) != 0)){
                 throw new ServiceException(plan.getPlanYear()+"年全年计划投资与每季度总和不对");
             }
             if (plan.getYearlyInvest() != null || StringUtils.isNotBlank(plan.getYearlyTarget()) || StringUtils.isNotBlank(plan.getOnePlan())
@@ -273,7 +275,9 @@ public class ProjectInfoServiceImpl extends BaseServiceImpl<ProjectInfoMapper, P
             planVO.setIsCanFill(1);
             //如果没有填写过完成情况,则创建构建完成情况信息
             List<ProjectPlanProgressVO> progresses = new ArrayList<>();
+            BigDecimal monthFinished = BigDecimal.ZERO;
             if (planVO.getIsFillPlan() == 0){
+
                 for (int i = 1; i <= 12; i++) {
                     ProjectPlanProgressVO progress = new ProjectPlanProgressVO();
                     progress.setProjectId(id);
@@ -281,6 +285,7 @@ public class ProjectInfoServiceImpl extends BaseServiceImpl<ProjectInfoMapper, P
                     progress.setPlanYear(planVO.getPlanYear());
                     progress.setPlanMonth(i);
                     progress.setPlanMonthName(monthNames[i]);
+                    progress.setYearlyTarget(planVO.getYearlyTarget());
                     if (i <= 3){
                         progress.setPlanQuarter(1);
                         progress.setPlanQuarterName("一季度");
@@ -306,24 +311,39 @@ public class ProjectInfoServiceImpl extends BaseServiceImpl<ProjectInfoMapper, P
                 }
             }else {
                 List<ProjectPlanProgressVO> vos = listMap.get(planVO.getId());
-                if (isPlanDetail || vos == null || vos.size() == 0){
+                if (!isPlanDetail || vos == null || vos.size() == 0){
                     throw new ServiceException("数据错误,请联系管理员");
                 }
                 for (ProjectPlanProgressVO progress : vos) {
                     Integer i = progress.getPlanMonth();
                     if (i <= 3){
-                        progress.setPlanInvestMoney(planVO.getOneInvest());
+                        if (planVO.getOneInvest() != null) {
+                            progress.setPlanInvestMoney(planVO.getOneInvest());
+                            progress.setInvestUnfinishedMoney(planVO.getOneInvest().subtract(monthFinished));
+                        }
                         progress.setWorkPlan(planVO.getOnePlan());
                     }else if (i <= 6){
-                        progress.setPlanInvestMoney(planVO.getTwoInvest());
+                        if (planVO.getTwoInvest() != null) {
+                            progress.setPlanInvestMoney(planVO.getTwoInvest());
+                            progress.setInvestUnfinishedMoney(planVO.getTwoInvest().subtract(monthFinished));
+                        }
                         progress.setWorkPlan(planVO.getTwoPlan());
                     }else if (i <= 9){
-                        progress.setPlanInvestMoney(planVO.getThreeInvest());
+                        if (planVO.getThreeInvest() != null) {
+                            progress.setPlanInvestMoney(planVO.getThreeInvest());
+                            progress.setInvestUnfinishedMoney(planVO.getThreeInvest().subtract(monthFinished));
+                        }
                         progress.setWorkPlan(planVO.getThreePlan());
                     }else {
-                        progress.setPlanInvestMoney(planVO.getFourInvest());
+                        if (planVO.getFourInvest() != null) {
+                            progress.setPlanInvestMoney(planVO.getFourInvest());
+                            progress.setInvestUnfinishedMoney(planVO.getFourInvest().subtract(monthFinished));
+                        }
                         progress.setWorkPlan(planVO.getFourPlan());
                     }
+                    if (i % 3 == 0){
+                        monthFinished = BigDecimal.ZERO;
+                    }
                 }
                 progresses = vos;
             }
@@ -332,4 +352,267 @@ public class ProjectInfoServiceImpl extends BaseServiceImpl<ProjectInfoMapper, P
         vo.setList(planList);
         return vo;
     }
+
+    @Override
+    @Transactional
+    public void updateFinished(ProjectAndPlanDetailDTO dto) {
+        //获取年数组,如果数组为null则跳过保存
+        List<ProjectInvestPlanDTO> years = dto.getList();
+        if (years == null || years.size() == 0){
+            return;
+        }
+        List<ProjectInvestPlan> updateYearPlan = new ArrayList<>();
+        for (ProjectInvestPlanDTO year : years) {
+            //如果此年不能填写,则直接跳过
+            if (year.getIsCanFill() == 0){
+                continue;
+            }
+            //统计当前整年数据
+            ProjectInvestPlan yearPlan = new ProjectInvestPlan();
+            //设置底部4条数据
+            yearPlan.setId(year.getId());
+            yearPlan.setQuestionable(year.getQuestionable());
+            yearPlan.setWorkAdvise(year.getWorkAdvise());
+            yearPlan.setWriteUnit(year.getWriteUnit());
+            yearPlan.setLinkman(year.getLinkman());
+            //整年累计完成投资
+            BigDecimal allInvestFinished = BigDecimal.ZERO;
+            //季度已投资
+            BigDecimal investFinished = BigDecimal.ZERO;
+            //前面所有季度计划投资
+            BigDecimal planInvest = BigDecimal.ZERO;
+            //当季投资填写次数
+            Integer quarterFillTotal = 0;
+            //季度进度总和
+            BigDecimal planFinished = BigDecimal.ZERO;
+            //当季进度填写次数
+            Integer quarterPlanTotal = 0;
+
+            List<ProjectPlanProgress> monthList = year.getList();
+            for (ProjectPlanProgress progress : monthList) {
+                progress.setInvestMoneyAll(null);
+                //设置当前行已经填写字段
+                Integer fillField = 0;
+                Integer i = progress.getPlanMonth();
+                if (i <= 3){
+                    if (year.getOneInvest() != null && year.getOneInvest().compareTo(BigDecimal.ZERO) != 0 && progress.getInvestMoney() != null) {
+                        fillField ++;
+                        quarterFillTotal++;
+                        investFinished = investFinished.add(progress.getInvestMoney());
+                        allInvestFinished = allInvestFinished.add(progress.getInvestMoney());
+                        progress.setInvestMoneyAll(allInvestFinished);
+                    }
+                   if (StringUtils.isNotBlank(year.getOnePlan())){
+                        if (StringUtils.isNotBlank(progress.getWorkProgress())){
+                            fillField++;
+                        }
+                       if (StringUtils.isNotBlank(progress.getWorkProgressAll())){
+                           fillField++;
+                       }
+                       if (progress.getPlanRatio() != null){
+                           fillField++;
+                           quarterPlanTotal++;
+                           planFinished = planFinished.add(progress.getPlanRatio());
+                       }
+
+                   }
+                    if (i == 3){
+                        if (year.getOneInvest() != null){
+                            planInvest = planInvest.add(year.getOneInvest());
+                        }
+                        //设置一季度已投资
+                        yearPlan.setOneInvestFinish(investFinished);
+                        if (quarterFillTotal > 0)yearPlan.setIsFillPlan(1);
+                        if (quarterFillTotal == 3){
+                            //一季度全部投资都填完,设置投资比例
+                            yearPlan.setIsOneInvestFinish(1);
+                            yearPlan.setOneInvestRatio(investFinished.divide(year.getOneInvest(),4, RoundingMode.UP).multiply(new BigDecimal(100)).setScale(2));
+                        }else {
+                            yearPlan.setIsOneInvestFinish(0);
+                        }
+                        if (quarterPlanTotal == 3){
+                            yearPlan.setIsOnePlanFinish(1) ;
+                            yearPlan.setOnePlanRatio(planFinished.divide(new BigDecimal(3),2,RoundingMode.UP));
+                        }else {
+                            yearPlan.setIsOnePlanFinish(0);
+                        }
+                        //重置季度填写统计
+                        quarterFillTotal = 0;
+                        quarterPlanTotal = 0;
+                        //重置季度已投资
+                        investFinished = BigDecimal.ZERO;
+                        planFinished = BigDecimal.ZERO;
+                    }
+                }else if (i <= 6){
+                    if (year.getTwoInvest() != null && year.getTwoInvest().compareTo(BigDecimal.ZERO) != 0 && progress.getInvestMoney() != null) {
+                        fillField += 1;
+                        quarterFillTotal++;
+                        investFinished = investFinished.add(progress.getInvestMoney());
+                        allInvestFinished = allInvestFinished.add(progress.getInvestMoney());
+                        progress.setInvestMoneyAll(allInvestFinished);
+                    }
+                    if (StringUtils.isNotBlank(year.getTwoPlan())){
+                        if (StringUtils.isNotBlank(progress.getWorkProgress())){
+                            fillField++;
+                        }
+                        if (StringUtils.isNotBlank(progress.getWorkProgressAll())){
+                            fillField++;
+                        }
+                        if (progress.getPlanRatio() != null){
+                            fillField++;
+                            quarterPlanTotal++;
+                            planFinished = planFinished.add(progress.getPlanRatio());
+                        }
+
+                    }
+                    if (i == 6){
+                        if (year.getTwoInvest() != null){
+                            planInvest = planInvest.add(year.getTwoInvest());
+                        }
+                        //设置季度已投资
+                        yearPlan.setOneInvestFinish(investFinished);
+                        if (quarterFillTotal > 0)yearPlan.setIsFillPlan(1);
+                        if (quarterFillTotal == 3){
+                            //季度全部投资都填完,设置投资比例
+                            yearPlan.setIsTwoInvestFinish(1);
+                            yearPlan.setTwoInvestRatio(investFinished.divide(year.getTwoInvest(),4, RoundingMode.UP).multiply(new BigDecimal(100)).setScale(2));
+                            //设置累计投资比例,前面所有季度之和
+                            if (planInvest.compareTo(BigDecimal.ZERO) != 0){
+                                yearPlan.setTwoAggregateRatio(allInvestFinished.divide(planInvest,4, RoundingMode.UP).multiply(new BigDecimal(100)).setScale(2));
+                            }
+                        }else {
+                            yearPlan.setIsTwoInvestFinish(0);
+                        }
+                        if (quarterPlanTotal == 3){
+                            yearPlan.setIsTwoPlanFinish(1); ;
+                            yearPlan.setTwoPlanRatio(planFinished.divide(new BigDecimal(3),2,RoundingMode.UP));
+                        }else {
+                            yearPlan.setIsTwoPlanFinish(0);
+                        }
+                        //重置季度填写统计
+                        quarterFillTotal = 0;
+                        quarterPlanTotal = 0;
+                        //重置季度已投资
+                        investFinished = BigDecimal.ZERO;
+                        planFinished = BigDecimal.ZERO;
+                    }
+                }else if (i <= 9){
+                    if (year.getThreeInvest() != null && year.getThreeInvest().compareTo(BigDecimal.ZERO) != 0 && progress.getInvestMoney() != null) {
+                        fillField += 1;
+                        quarterFillTotal++;
+                        investFinished = investFinished.add(progress.getInvestMoney());
+                        allInvestFinished = allInvestFinished.add(progress.getInvestMoney());
+                        progress.setInvestMoneyAll(allInvestFinished);
+                    }
+                    if (StringUtils.isNotBlank(year.getThreePlan())){
+                        if (StringUtils.isNotBlank(progress.getWorkProgress())){
+                            fillField++;
+                        }
+                        if (StringUtils.isNotBlank(progress.getWorkProgressAll())){
+                            fillField++;
+                        }
+                        if (progress.getPlanRatio() != null){
+                            fillField++;
+                            quarterPlanTotal++;
+                            planFinished = planFinished.add(progress.getPlanRatio());
+                        }
+
+                    }
+                    if (i == 9){
+                        if (year.getThreeInvest() != null){
+                            planInvest = planInvest.add(year.getThreeInvest());
+                        }
+                        //设置季度已投资
+                        yearPlan.setOneInvestFinish(investFinished);
+                        if (quarterFillTotal > 0)yearPlan.setIsFillPlan(1);
+                        if (quarterFillTotal == 3){
+                            //季度全部投资都填完,设置投资比例
+                            yearPlan.setIsThreeInvestFinish(1);
+                            yearPlan.setThreeInvestRatio(investFinished.divide(year.getThreeInvest(),4, RoundingMode.UP).multiply(new BigDecimal(100)).setScale(2));
+                            //设置累计投资比例,前面所有季度之和
+                            if (planInvest.compareTo(BigDecimal.ZERO) != 0){
+                                yearPlan.setThreeAggregateRatio(allInvestFinished.divide(planInvest,4, RoundingMode.UP).multiply(new BigDecimal(100)).setScale(2));
+                            }
+                        }else {
+                            yearPlan.setIsThreeInvestFinish(0);
+                        }
+                        if (quarterPlanTotal == 3){
+                            yearPlan.setIsThreePlanFinish(1); ;
+                            yearPlan.setThreePlanRatio(planFinished.divide(new BigDecimal(3),2,RoundingMode.UP));
+                        }else {
+                            yearPlan.setIsThreePlanFinish(0);
+                        }
+                        //重置季度填写统计
+                        quarterFillTotal = 0;
+                        quarterPlanTotal = 0;
+                        //重置季度已投资
+                        investFinished = BigDecimal.ZERO;
+                        planFinished = BigDecimal.ZERO;
+                    }
+                }else {
+                    if (year.getFourInvest() != null && year.getFourInvest().compareTo(BigDecimal.ZERO) != 0 && progress.getInvestMoney() != null) {
+                        fillField += 1;
+                        quarterFillTotal++;
+                        investFinished = investFinished.add(progress.getInvestMoney());
+                        allInvestFinished = allInvestFinished.add(progress.getInvestMoney());
+                        progress.setInvestMoneyAll(allInvestFinished);
+                    }
+                    if (StringUtils.isNotBlank(year.getFourPlan())){
+                        if (StringUtils.isNotBlank(progress.getWorkProgress())){
+                            fillField++;
+                        }
+                        if (StringUtils.isNotBlank(progress.getWorkProgressAll())){
+                            fillField++;
+                        }
+                        if (progress.getPlanRatio() != null){
+                            fillField++;
+                            quarterPlanTotal++;
+                            planFinished = planFinished.add(progress.getPlanRatio());
+                        }
+
+                    }
+                    if (i == 12){
+                        if (year.getFourInvest() != null){
+                            planInvest = planInvest.add(year.getFourInvest());
+                        }
+                        //设置季度已投资
+                        yearPlan.setFourInvestFinish(investFinished);
+                        if (quarterFillTotal > 0)yearPlan.setIsFillPlan(1);
+                        if (quarterFillTotal == 3){
+                            //季度全部投资都填完,设置投资比例
+                            yearPlan.setIsFourInvestFinish(1);
+                            yearPlan.setFourInvestRatio(investFinished.divide(year.getFourInvest(),4, RoundingMode.UP).multiply(new BigDecimal(100)).setScale(2));
+                            //设置累计投资比例,前面所有季度之和
+                            if (planInvest.compareTo(BigDecimal.ZERO) != 0){
+                                yearPlan.setFourAggregateRatio(allInvestFinished.divide(planInvest,4, RoundingMode.UP).multiply(new BigDecimal(100)).setScale(2));
+                            }
+                        }else {
+                            yearPlan.setIsFourInvestFinish(0);
+                        }
+                        if (quarterPlanTotal == 3){
+                            yearPlan.setIsFourPlanFinish(1); ;
+                            yearPlan.setFourPlanRatio(planFinished.divide(new BigDecimal(3),2,RoundingMode.UP));
+                        }else {
+                            yearPlan.setIsFourPlanFinish(0);
+                        }
+                        //重置季度填写统计
+                        quarterFillTotal = 0;
+                        quarterPlanTotal = 0;
+                        //重置季度已投资
+                        investFinished = BigDecimal.ZERO;
+                        planFinished = BigDecimal.ZERO;
+                    }
+                }
+                progress.setFillField(fillField);
+            }
+            //直接保存或修改月计划集合
+            planProgressService.saveOrUpdateBatch(monthList);
+            //添加要修改年计划
+            yearPlan.setYearFinishInvest(allInvestFinished);
+            yearPlan.setYearUnfinishedInvest(year.getYearlyInvest().subtract(allInvestFinished));
+            updateYearPlan.add(yearPlan);
+        }
+        //修改年计划
+        investPlanService.updateBatchById(updateYearPlan);
+    }
 }