Bladeren bron

Merge remote-tracking branch 'origin/master'

liuyc 2 jaren geleden
bovenliggende
commit
4a237856ac

+ 3 - 0
blade-service-api/blade-control-api/src/main/java/org/springblade/control/entity/DepartmentPlanLog.java

@@ -113,4 +113,7 @@ public class DepartmentPlanLog extends BaseEntity {
 
     @ApiModelProperty(value = "上一次计划工时(天)")
     private BigDecimal lastOpenPlanStartEndDays;
+
+    @ApiModelProperty(value = "0不显示提示,1显示提示")
+    private Integer isShowTips;
 }

+ 3 - 0
blade-service-api/blade-control-api/src/main/java/org/springblade/control/entity/PlanRelationReturned.java

@@ -29,4 +29,7 @@ public class PlanRelationReturned extends BaseEntity {
     @ApiModelProperty(value = "回款id")
     private Long returnedId;
 
+    @ApiModelProperty(value = "项目id")
+    private Long projectId;
+
 }

+ 7 - 1
blade-service-api/blade-control-api/src/main/java/org/springblade/control/vo/ProjectCostBudgetVO2.java

@@ -35,7 +35,7 @@ public class ProjectCostBudgetVO2 extends ProjectCostBudget {
     @ApiModelProperty(value = "岗位类型值")
     private String postTypeValue;
 
-    @ApiModelProperty(value = "任务完成状态,1黄色,2绿色")
+    @ApiModelProperty(value = "任务状态,1黄色超预算,2绿色已完成")
     private Integer taskFinishedStatus;
 
     @ApiModelProperty(value = "计划总金额")
@@ -44,10 +44,16 @@ public class ProjectCostBudgetVO2 extends ProjectCostBudget {
     @ApiModelProperty(value = "项目名称")
     private String projectName;
 
+    @ApiModelProperty(value = "任务类型值")
+    private String planTaskTypeValue;
+
     @ApiModelProperty(value = "0不显示分解子计划,1显示分解子计划")
     private Integer isShowChildren;
 
     @ApiModelProperty(value = "0不显示编辑,1显示编辑")
     private Integer isShowEdit;
 
+    @ApiModelProperty(value = "超出预算提示信息")
+    private String outMoneyTips;
+
 }

+ 2 - 2
blade-service/blade-control/src/main/java/org/springblade/control/controller/PlanRelationReturnedController.java

@@ -45,8 +45,8 @@ public class PlanRelationReturnedController {
             @ApiImplicitParam(name = "returnedId", value = "回款id", required = true),
             @ApiImplicitParam(name = "type", value = "关联类型:0取消关联,1关联", required = true),
     })
-    public R relationPlanAndReturned(Long returnedId,Long planId,Integer type){
-        String msg = planRelationReturnedService.relationPlanAndReturned(returnedId, planId, type);
+    public R relationPlanAndReturned(Long projectId,Long returnedId,Long planId,Integer type){
+        String msg = planRelationReturnedService.relationPlanAndReturned(projectId,returnedId, planId, type);
         return R.success(msg);
     }
 

+ 8 - 0
blade-service/blade-control/src/main/java/org/springblade/control/mapper/ProjectCostBudgetMapper.java

@@ -79,4 +79,12 @@ public interface ProjectCostBudgetMapper extends BaseMapper<ProjectCostBudget> {
     List<DictInfo> getCostType();
 
     List<DictInfo> getUnitType();
+
+    List<DictInfo> getAllPostType();
+
+    List<DictInfo> getAllTaskInfo();
+
+    List<PlanRelationReturned> getAllRelationInfo(@Param("projectId") Long projectId);
+
+    List<ContractReturnedInfo> getAllReturnedInfo(@Param("projectId") Long id);
 }

+ 18 - 2
blade-service/blade-control/src/main/java/org/springblade/control/mapper/ProjectCostBudgetMapper.xml

@@ -72,7 +72,8 @@
             (select di.dict_name from c_dict_info di where di.type = 1 and di.dict_value = pcb.task_detail and di.parent_id =
             (select di.id from c_dict_info di where di.type = 1 and di.dict_value = pcb.budget_type and di.parent_id = 0)) as taskDetailValue,
             (select cri.returned_condition from c_contract_returned_info cri where cri.id = pcb.contract_returned_id) as returnedValue,
-            (select di.dict_name from c_dict_info di where di.type = 3 and di.code = pcb.post_type) as postTypeValue
+            (select di.dict_name from c_dict_info di where di.type = 3 and di.id = pcb.post_type) as postTypeValue,
+            (select di.dict_name from c_dict_info di where di.type = 2 and di.id = pcb.plan_task_type) as planTaskTypeValue
         FROM c_project_cost_budget pcb WHERE pcb.project_id = #{id} AND pcb.approve = 1
     </select>
 
@@ -168,7 +169,8 @@
                (select cpp.name from c_project_process cpp where cpp.id = pcb.project_process) as projectProcessValue,
                (select di.dict_name from c_dict_info di where di.type = 1 and di.dict_value = pcb.budget_type and di.parent_id = 0) as budgetTypeValue,
                (select di.dict_name from c_dict_info di where di.type = 1 and di.dict_value = pcb.task_detail and di.parent_id =
-                                                                                                                  (select di.id from c_dict_info di where di.type = 1 and di.dict_value = pcb.budget_type and di.parent_id = 0)) as taskDetailValue
+                       (select di.id from c_dict_info di where di.type = 1 and di.dict_value = pcb.budget_type and di.parent_id = 0)) as taskDetailValue,
+               (select di.dict_name from c_dict_info di where di.type = 2 and di.id = pcb.plan_task_type) as planTaskTypeValue
         FROM c_project_cost_budget pcb WHERE pcb.project_id = #{id} AND pcb.parent_id > 0
     </select>
     <select id="getBudgetByYear" resultType="org.springblade.control.entity.ProjectCostBudget">
@@ -250,6 +252,20 @@
         select dict_value
         from c_dict_info where `type` = 3 and id = #{type}
     </select>
+    <select id="getAllPostType" resultType="org.springblade.control.entity.DictInfo">
+        select * from c_dict_info
+        where `type` = 3 and  is_deleted = 0
+    </select>
+    <select id="getAllTaskInfo" resultType="org.springblade.control.entity.DictInfo">
+        select * from c_dict_info
+        where `type` = 2 and  is_deleted = 0
+    </select>
+    <select id="getAllRelationInfo" resultType="org.springblade.control.entity.PlanRelationReturned">
+        select * from c_plan_relation_returned WHERE project_id = #{projectId} and is_deleted = 0
+    </select>
+    <select id="getAllReturnedInfo" resultType="org.springblade.control.entity.ContractReturnedInfo">
+        select * from c_contract_returned_info WHERE project_id = #{projectId} and is_deleted = 0
+    </select>
 
 
 </mapper>

+ 1 - 1
blade-service/blade-control/src/main/java/org/springblade/control/service/IPlanRelationReturnedService.java

@@ -14,5 +14,5 @@ public interface IPlanRelationReturnedService extends BaseService<PlanRelationRe
     /**
      * 计划关联回款
      */
-    String relationPlanAndReturned(Long returnedId, Long planId, Integer type);
+    String relationPlanAndReturned(Long projectId,Long returnedId, Long planId, Integer type);
 }

+ 3 - 2
blade-service/blade-control/src/main/java/org/springblade/control/service/impl/AnnualBudgetServiceImpl.java

@@ -566,8 +566,9 @@ public class AnnualBudgetServiceImpl extends BaseServiceImpl<AnnualBudgetMapper,
         List<AllProjectStatsVO> vos = new ArrayList<>();
         //获取部门映射值
         List<DictInfo> costTypeDict = monthPlanService.getDepartmentDict();
-        Map<Double, List<DictInfo>> collect = costTypeDict.parallelStream()
-                .collect(Collectors.groupingBy(DictInfo::getDictValue));
+//        Map<Double, List<DictInfo>> collect = costTypeDict.parallelStream()
+//                .collect(Collectors.groupingBy(DictInfo::getDictValue));
+        Map<Integer, List<DictInfo>> collect = costTypeDict.stream().collect(Collectors.groupingBy(s -> s.getDictValue().intValue()));
         //风险计划按项目分组,再按照部门分组,再统计计划总数
         Map<Long, List<ProjectCostBudget>> map = riskPlan.parallelStream()
                 .collect(Collectors.groupingBy(ProjectCostBudget::getProjectId));

+ 1 - 1
blade-service/blade-control/src/main/java/org/springblade/control/service/impl/DepartmentPlanLogImpl.java

@@ -116,7 +116,7 @@ public class DepartmentPlanLogImpl extends BaseServiceImpl<DepartmentPlanLogMapp
 //            log.setOpenPlanEndTime(null);
 //            log.setOpenPlanStartEndDays(null);
 //        }
-        log.setOpenPlanStartTime(null);
+        log.setOpenPlanStartTime(LocalDate.now());
         log.setOpenPlanEndTime(null);
         log.setOpenPlanStartEndDays(null);
         return log;

+ 2 - 1
blade-service/blade-control/src/main/java/org/springblade/control/service/impl/PlanRelationReturnedServiceImpl.java

@@ -45,12 +45,13 @@ public class PlanRelationReturnedServiceImpl extends BaseServiceImpl<PlanRelatio
      * 计划关联回款
      */
     @Override
-    public String relationPlanAndReturned(Long returnedId, Long planId, Integer type) {
+    public String relationPlanAndReturned(Long projectId ,Long returnedId, Long planId, Integer type) {
         //关联类型:0取消关联,1关联
         if (type == 1){
             PlanRelationReturned relation = new PlanRelationReturned();
             relation.setPlanId(planId);
             relation.setReturnedId(returnedId);
+            relation.setProjectId(projectId);
             baseMapper.insert(relation);
             return "关联成功";
         }else {

+ 138 - 21
blade-service/blade-control/src/main/java/org/springblade/control/service/impl/ProjectCostBudgetServiceImpl.java

@@ -11,10 +11,7 @@ import org.springblade.common.utils.SnowFlakeUtil;
 import org.springblade.control.dto.ControlProjectInfoDTO;
 import org.springblade.control.dto.ProjectCostBudgetDTO;
 import org.springblade.control.dto.ProjectCostBudgetStatsDTO;
-import org.springblade.control.entity.ControlProjectInfo;
-import org.springblade.control.entity.DictInfo;
-import org.springblade.control.entity.ProjectCostBudget;
-import org.springblade.control.entity.ProjectCostBudgetStats;
+import org.springblade.control.entity.*;
 import org.springblade.control.mapper.ProjectCostBudgetMapper;
 import org.springblade.control.mapper.ProjectInfoMapper;
 import org.springblade.control.service.IProjectCostBudgetService;
@@ -177,17 +174,62 @@ public class ProjectCostBudgetServiceImpl extends BaseServiceImpl<ProjectCostBud
         ProjectCostBudgetVO vo = new ProjectCostBudgetVO();
         vo.setProjectName(projectInfo.getName());
         vo.setProjectId(id);
+        //获取所有岗位信息
+        List<DictInfo> allPostType = baseMapper.getAllPostType();
+        Map<Long, List<DictInfo>> postMap = new HashMap<>();
+        if (allPostType != null && allPostType.size() >0){
+            postMap = allPostType.parallelStream()
+                    .collect(Collectors.groupingBy(DictInfo::getId));
+        }else {
+            throw new ServiceException("参数配置暂无岗位信息");
+        }
+        //获取所有任务信息
+        List<DictInfo> allTaskInfo = baseMapper.getAllTaskInfo();
+        Map<Long, List<DictInfo>> taskMap = new HashMap<>();
+        if (allPostType != null && allPostType.size() >0){
+            taskMap = allTaskInfo.parallelStream()
+                    .collect(Collectors.groupingBy(DictInfo::getId));
+        }else {
+            throw new ServiceException("参数配置暂无任务信息");
+        }
+        //获取项目下所有计划关联回款信息
+        List<PlanRelationReturned> allRelationInfo = baseMapper.getAllRelationInfo(id);
+        Map<Long, List<PlanRelationReturned>> relationMap = null;
+        if (allRelationInfo != null && allRelationInfo.size() > 0){
+            relationMap = allRelationInfo.parallelStream()
+                    .collect(Collectors.groupingBy(PlanRelationReturned::getPlanId));
+        }
+        //获取项目下所有回款信息
+        List<ContractReturnedInfo> allReturnedInfo = baseMapper.getAllReturnedInfo(id);
+        Map<Long, List<ContractReturnedInfo>> returnedMap = null;
+        if (allReturnedInfo != null && allReturnedInfo.size() > 0){
+            returnedMap = allReturnedInfo.parallelStream()
+                    .collect(Collectors.groupingBy(ContractReturnedInfo::getId));
+        }
         //获取项目下所有已审批的计划
         List<ProjectCostBudgetVO2> list = baseMapper.getApprovePlan(id);
-        list.stream().forEach(l->{
-            if (l.getPlanTaskType() != null || l.getPlanTaskDesc() != null || l.getPlanDays() != null){
+        for (ProjectCostBudgetVO2 l : list) {
+            if (l.getPlanTaskType() != null || l.getPlanDays() != null || l.getPlanStartTime() != null || l.getPlanEndTime() != null){
                 l.setIsShowChildren(0);
             }else {
                 l.setIsShowChildren(1);
             }
-        });
+            if (relationMap != null){
+                List<PlanRelationReturned> returnedList = relationMap.get(l.getId());
+                if (returnedList != null && returnedList.size() > 0){
+                    StringBuilder str = new StringBuilder();
+                    int j = 1;
+                    for (PlanRelationReturned returned : returnedList) {
+                        ContractReturnedInfo info = returnedMap.get(returned.getReturnedId()).get(0);
+                        str.append(j+"."+info.getReturnedCondition()+"。");
+                    }
+                    l.setReturnedValue(str.toString());
+                }
+            }
+        }
         //获取项目下所有的子计划
         List<ProjectCostBudgetVO2> childrenList = baseMapper.getAllChildrenPlan(id);
+        //有子计划就插入父计划,没有子计划直接跳过
         if (childrenList != null && childrenList.size() >0) {
             //把子计划按parentId分组
             Map<Long, List<ProjectCostBudgetVO2>> listMap = childrenList.parallelStream()
@@ -200,38 +242,113 @@ public class ProjectCostBudgetServiceImpl extends BaseServiceImpl<ProjectCostBud
                 }
                 //如果子计划,把子计划插入计划里
                 if (key.contains(vo2.getId())) {
-                    //如果计划的status为1,2,3,或者计划有子计划,则不能编辑
+                    //如果计划的status为2,3,4,或者计划有子计划,则不能编辑
                     vo2.setIsShowEdit(0);
-                    //如果计划已经完成,则不计算超时
-                    if (vo2.getTaskFinishedStatus() == null) {
-                        //有子计划,判断子计划加起来是否超过预算天数
-                        BigDecimal workDays = new BigDecimal(0);
-                        List<ProjectCostBudgetVO2> vo2List = listMap.get(vo2.getId());
-                        for (ProjectCostBudgetVO2 budgetVO2 : vo2List) {
-                            if (budgetVO2.getPlanDays() != null) {
-                                workDays = workDays.add(budgetVO2.getPlanDays());
-                            }
+                    //有子计划,判断子计划加起来是否超过预算天数
+                    BigDecimal workDays = new BigDecimal(0);
+                    List<ProjectCostBudgetVO2> vo2List = listMap.get(vo2.getId());
+                    LocalDate startDate = LocalDate.MAX;
+                    LocalDate endDate = LocalDate.MIN;
+                    StringBuilder descStr = new StringBuilder();
+                    StringBuilder targetStr = new StringBuilder();
+                    int j = 1;
+                    for (ProjectCostBudgetVO2 budgetVO2 : vo2List) {
+                        //计算总天数
+                        if (budgetVO2.getPlanDays() != null) {
+                            workDays = workDays.add(budgetVO2.getPlanDays());
+                        }
+                        //计算最大日期和最小日期
+                        if (budgetVO2.getPlanStartTime().isBefore(startDate)){
+                            startDate = budgetVO2.getPlanStartTime();
                         }
-                        if (workDays.compareTo(vo2.getBudgetDays()) == 1) {
+                        if (budgetVO2.getPlanEndTime().isAfter(endDate)){
+                            endDate = budgetVO2.getPlanEndTime();
+                        }
+                        //拼接子计划的任务描述
+                        descStr.append(j + "."+budgetVO2.getPlanTaskDesc()+"。");
+                        //拼接子计划的完成指标
+                        targetStr.append(j+"."+budgetVO2.getPlanTarget()+"。");
+                        j++;
+                    }
+                    //如果计划已经完成,则不计算超预算
+                    if (vo2.getTaskFinishedStatus() == null) {
+                        if ((workDays.multiply(new BigDecimal((postMap.get(vo2.getPostType()).get(0).getDictValue())))).compareTo(vo2.getBudgetStaffCost()) == 1) {
                             vo2.setTaskFinishedStatus(1);
                         }
                     }
+                    //根据子计划设置父计划任务类型
+                    vo2.setPlanTaskType(vo2List.get(0).getPlanTaskType());
+                    //根据子计划设置父计划任务类型值
+                    vo2.setPlanTaskTypeValue(vo2List.get(0).getPlanTaskTypeValue());
+                    //根据子计划设置父计划任务描述
+                    vo2.setPlanTaskDesc(descStr.toString());
+                    //根据子计划设置父计划完成指标
+                    vo2.setPlanTarget(targetStr.toString());
+                    //根据子计划设置父计划起止日期
+                    vo2.setPlanStartTime(startDate);
+                    vo2.setPlanEndTime(endDate);
+                    //根据任务类型设置父计划的工作天数,固定任务1,临时任务2
+                    if (taskMap.get(vo2.getPlanTaskType()).get(0).getDictValue().intValue() == 1){
+                        vo2.setPlanDays(new BigDecimal(endDate.compareTo(startDate)));
+                    }else {
+                        if (endDate.compareTo(startDate) > 35){
+                            //工作天数,工具只能获取50天之内的
+                            int i = 0;
+                            while (endDate.compareTo(startDate) > 0){
+                                i += CommonUtil.getWorkDays(startDate, startDate.plusDays(35L));
+                                startDate = startDate.plusDays(36L);
+                            }
+                            vo2.setPlanDays(new BigDecimal(i));
+                        }else {
+                            vo2.setPlanDays(new BigDecimal(CommonUtil.getWorkDays(startDate, endDate)));
+                        }
+                    }
                     vo2.setChildrenList(listMap.get(vo2.getId()));
                 }else {
-                    //如果计划的status为1,2,3,或者计划有子计划,则不能编辑
+                    //如果计划的status为2,3,4,或者计划有子计划,则不能编辑
                     if (vo2.getStatus() == 1){
                         vo2.setIsShowEdit(1);
                     }else {
                         vo2.setIsShowEdit(0);
                     }
-                    //没有子计划,则计划父计划的时间是否超时
-                    if (vo2.getTaskFinishedStatus() == null && vo2.getPlanDays() != null){
+                    //没有子计划,则计算父计划成本是否超过测算,如果计划没有完成,有选择日期,有员工支出,则判断
+                    if (vo2.getTaskFinishedStatus() == null && vo2.getPlanDays() != null && vo2.getBudgetStaffCost() != null){
                         if (vo2.getPlanDays().compareTo(vo2.getBudgetDays()) == 1) {
                             vo2.setTaskFinishedStatus(1);
                         }
                     }
                 }
             }
+        }else {
+            //没有子计划也要为父计划设置颜色,是否显示编辑,是否显示分解子计划
+            for (ProjectCostBudgetVO2 vo2 : list) {
+                //设置颜色,已完成绿色,并且不能编辑,不能分解子计划
+                if (vo2.getTaskApprove() == 1){
+                    vo2.setTaskFinishedStatus(2);
+                    vo2.setIsShowChildren(0);
+                    vo2.setIsShowEdit(0);
+                }else {
+                    //如果计划正在进行就不能编辑
+                    if (vo2.getStatus() == 1){
+                        vo2.setIsShowEdit(1);
+                    }else {
+                        vo2.setIsShowEdit(0);
+                    }
+                    //如果已经填写了任务类型和选择了任务时间,就不显示子计划
+                    if (vo2.getPostType() != null && vo2.getPlanDays() != null){
+                        vo2.setIsShowChildren(0);
+                        //计算是否超过预算
+                        if ((vo2.getPlanDays().multiply(new BigDecimal(postMap.get(vo2.getPostType()).get(0).getDictValue()))).compareTo(vo2.getBudgetStaffCost()) == 1){
+                            vo2.setTaskFinishedStatus(1);
+//                            vo2.setOutMoneyTips("成本增加!该项计划完成时间超过当初测算时间工作时长("+vo2.getPlanDays().+"天)");
+                        }
+                    }else {
+                        vo2.setIsShowChildren(1);
+                    }
+
+                }
+
+            }
         }
         //根据单位分类
         Map<Integer, List<ProjectCostBudgetVO2>> map = list.parallelStream()

+ 10 - 0
blade-service/blade-control/src/main/java/org/springblade/control/service/impl/ProjectInfoServiceImpl.java

@@ -14,11 +14,14 @@ import org.springblade.control.vo.ControlProjectInfoVO;
 import org.springblade.core.log.exception.ServiceException;
 import org.springblade.core.mp.base.BaseServiceImpl;
 import org.springblade.core.mp.support.Query;
+import org.springblade.manager.entity.ContractInfo;
 import org.springblade.system.entity.DictBiz;
 import org.springblade.system.user.entity.User;
 import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.context.annotation.Lazy;
+import org.springframework.jdbc.core.BeanPropertyRowMapper;
+import org.springframework.jdbc.core.JdbcTemplate;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
@@ -44,6 +47,8 @@ public class ProjectInfoServiceImpl extends BaseServiceImpl<ProjectInfoMapper, C
 
     private final IProjectCostBudgetService budgetService;
 
+    private final JdbcTemplate jdbcTemplate;
+
     /**
      * 自定义分页
      *
@@ -107,6 +112,11 @@ public class ProjectInfoServiceImpl extends BaseServiceImpl<ProjectInfoMapper, C
         if (one1 != null){
             throw new ServiceException("项目存在合同,不能删除");
         }
+        String sql = "select id from c_project_cost_budget_stats where is_deleted = 0 and project_id = " + id;
+        List<ProjectCostBudgetStats> query = jdbcTemplate.query(sql, new BeanPropertyRowMapper<>(ProjectCostBudgetStats.class));
+        if (query != null && query.size() > 0){
+            throw new ServiceException("项目已经做了预算,不能删除");
+        }
         List<ProjectCostBudget> list = budgetService.list(new LambdaQueryWrapper<ProjectCostBudget>().eq(ProjectCostBudget::getProjectId, id));
         if (list != null && list.size() > 0){
             throw new ServiceException("项目已经做了预算,不能删除");