فهرست منبع

门户所有维护支出精确到天

qianxb 2 سال پیش
والد
کامیت
53fcab8153

+ 6 - 0
blade-service/blade-control/src/main/java/org/springblade/control/mapper/EmployeeTaskInfoMapper.java

@@ -43,4 +43,10 @@ public interface EmployeeTaskInfoMapper extends BaseMapper<EmployeeTaskInfo> {
     void setAvgOtherCostByParentId(@Param("id") Long id,@Param("avg") BigDecimal avg);
 
     void deleteMaintainByBudgetId(@Param("id") Long id);
+
+    BigDecimal getAllMaintainSalaryByYear(@Param("year") int y);
+
+    List<EmployeeTaskInfo> getAllMaintainSalaryByYear2(@Param("year") int y);
+
+    List<EmployeeTaskInfo> getAllMaintainSalaryByProject(@Param("projectId") Long projectId);
 }

+ 22 - 1
blade-service/blade-control/src/main/java/org/springblade/control/mapper/EmployeeTaskInfoMapper.xml

@@ -29,7 +29,11 @@
         where budget_id = #{id} and work_type = 2
     </delete>
     <select id="getAllEmployeeSalaryByYear" resultType="java.math.BigDecimal">
-        select SUM(employee_salary) from c_employee_task_info WHERE work_type = 1 and DATE_FORMAT(one_day, '%Y') = #{year}
+        select SUM(employee_salary) from c_employee_task_info
+        WHERE work_type = 1
+        <if test="year != 0">
+            and DATE_FORMAT(one_day ,'%Y') = #{year}
+        </if>
     </select>
     <select id="getAllEmployeeSalaryByYear2" resultType="org.springblade.control.entity.EmployeeTaskInfo">
         select * from c_employee_task_info WHERE work_type = 1 and DATE_FORMAT(one_day, '%Y') = #{year}
@@ -43,4 +47,21 @@
     <select id="getAllBudgetSalaryByYear" resultType="org.springblade.control.entity.EmployeeTaskInfo">
         select * from c_employee_task_info WHERE work_type = 0 and DATE_FORMAT(one_day, '%Y') = #{year}
     </select>
+    <select id="getAllMaintainSalaryByYear" resultType="java.math.BigDecimal">
+        select SUM(employee_salary) from c_employee_task_info
+        WHERE work_type = 2
+        <if test="year != 0">
+            and DATE_FORMAT(one_day ,'%Y') = #{year}
+        </if>
+    </select>
+    <select id="getAllMaintainSalaryByYear2" resultType="org.springblade.control.entity.EmployeeTaskInfo">
+        select * from c_employee_task_info
+        WHERE work_type = 2
+        <if test="year != 0">
+            and DATE_FORMAT(one_day ,'%Y') = #{year}
+        </if>
+    </select>
+    <select id="getAllMaintainSalaryByProject" resultType="org.springblade.control.entity.EmployeeTaskInfo">
+        select * from c_employee_task_info WHERE work_type = 2 and project_id = #{projectId}
+    </select>
 </mapper>

+ 19 - 0
blade-service/blade-control/src/main/java/org/springblade/control/service/IEmployeeTaskInfoService.java

@@ -24,6 +24,9 @@ import java.util.Set;
  **/
 public interface IEmployeeTaskInfoService extends BaseService<EmployeeTaskInfo> {
 
+    /**
+     *  删除工作日相关接口
+     */
     //根据预算id删除工作信息
     void deleteByBudgetId(Long id);
 
@@ -40,6 +43,22 @@ public interface IEmployeeTaskInfoService extends BaseService<EmployeeTaskInfo>
     void deleteMaintainByBudgetId(Long id);
 
 
+    /**
+     * 维护支出相关接口
+     */
+    //根据年查询当年所有的维护支出
+    BigDecimal getAllMaintainSalaryByYear(int y);
+
+    //根据年查询当年所有的维护支出,并按照项目分组,组里的数据是每个月的支出,如果该项目没有支出将不会插入
+    Map<Long,Map<Integer, BigDecimal>> getAllMaintainSalaryByYear2(int y);
+
+    //根据年查询当年所有的维护支出,并按照项目分组,组里的数据是项目年支出,如果该项目没有支出将不会插入
+    Map<Long,BigDecimal> getAllMaintainSalaryByYear3(int y);
+
+    //获取项目的所有支出,按环节分组,如果该环节没有支出,将不会插入
+    Map<Long,BigDecimal> getAllMaintainSalaryByProject(Long projectId);
+
+
     /**
      *  实际支出相关接口
      */

+ 14 - 28
blade-service/blade-control/src/main/java/org/springblade/control/service/impl/AnnualBudgetServiceImpl.java

@@ -424,7 +424,7 @@ public class AnnualBudgetServiceImpl extends BaseServiceImpl<AnnualBudgetMapper,
         //获取今年人工支出
         BigDecimal yearStaffDisburse = employeeTaskInfoService.getAllEmployeeSalaryByYear(year);
         //获取今年维护支出
-        BigDecimal cost = budgetService.getAllMaintainCost(LocalDate.now().getYear());
+        BigDecimal cost = employeeTaskInfoService.getAllMaintainSalaryByYear(year);
         //获取今年报销支出
         BigDecimal decimal = projectInfoService.getThisYearReimburse(LocalDate.now().getYear());
         vo3.setYearProfit(yearReturned.subtract(yearStaffDisburse).subtract(cost).subtract(decimal));
@@ -499,12 +499,7 @@ public class AnnualBudgetServiceImpl extends BaseServiceImpl<AnnualBudgetMapper,
         //人工支出
         BigDecimal yearStaffDisburse = employeeTaskInfoService.getAllEmployeeSalaryByYear(y);
         //维护支出
-        BigDecimal cost;
-        if (y == 0){
-            cost = budgetService.getAllMaintainCost2();
-        }else {
-            cost = budgetService.getAllMaintainCost(y);
-        }
+        BigDecimal cost = employeeTaskInfoService.getAllMaintainSalaryByYear(y);
         //报销支出
         BigDecimal yearReimburse = projectInfoService.getThisYearReimburse(y);
         map.put("yearStaffDisburse",yearStaffDisburse.add(cost).add(yearReimburse));
@@ -566,11 +561,7 @@ public class AnnualBudgetServiceImpl extends BaseServiceImpl<AnnualBudgetMapper,
             isCost = false;
         }
         //维护支出
-        Map<Long, List<BigDecimal>> listMap = budgetService.getAllMaintainCost3(y);
-        Boolean isMaintain = true;
-        if (listMap == null || listMap.size() <= 0){
-            isMaintain = false;
-        }
+        Map<Long, Map<Integer, BigDecimal>> maintainMap = employeeTaskInfoService.getAllMaintainSalaryByYear2(y);
         //报销支出
         Map<Long, List<BigDecimal>> reimburseMap = projectInfoService.getYearReimburseByMonth(y);
         Boolean isReimburse = true;
@@ -590,10 +581,10 @@ public class AnnualBudgetServiceImpl extends BaseServiceImpl<AnnualBudgetMapper,
                     }
                 }
                 //计算维护
-                if (isMaintain){
-                    List<BigDecimal> decimals = listMap.get(project.getId());
-                    if (decimals != null && decimals.size() > 0){
-                        big = big.add(decimals.get(i -1));
+                if (maintainMap != null && maintainMap.get(project.getId()) != null){
+                    Map<Integer, BigDecimal> map = maintainMap.get(project.getId());
+                    if (map.get(i) != null) {
+                        big = big.add(map.get(i));
                     }
                 }
                 //计算报销
@@ -760,6 +751,7 @@ public class AnnualBudgetServiceImpl extends BaseServiceImpl<AnnualBudgetMapper,
         if (listMap == null || listMap.size() <= 0){
             isMaintain = false;
         }
+        Map<Long, BigDecimal> maintainMap = employeeTaskInfoService.getAllMaintainSalaryByYear3(y);
         //报销支出
         Map<Long, BigDecimal> reimburseMap = projectInfoService.getYearReimburseByYear(Integer.parseInt(date.substring(0,4)));
         Boolean isReimburse = true;
@@ -795,10 +787,8 @@ public class AnnualBudgetServiceImpl extends BaseServiceImpl<AnnualBudgetMapper,
                 big = big.add(costMap.get(info.getId()));
             }
             //维护支出
-            if (isMaintain){
-                if (listMap.get(info.getId()) != null){
-                    big = big.add(listMap.get(info.getId()));
-                }
+            if (maintainMap != null && maintainMap.get(info.getId()) != null){
+                big = big.add(maintainMap.get(info.getId()));
             }
             //计算报销
             if (isReimburse){
@@ -873,16 +863,12 @@ public class AnnualBudgetServiceImpl extends BaseServiceImpl<AnnualBudgetMapper,
         }else {
             isPlan2 = false;
         }
-        //获取项目的所有支出,按环节分组
+        //获取项目的所有预算支出,按环节分组
         Map<Long, BigDecimal> budgetMap = employeeTaskInfoService.getAllBudgetSalaryByProject(projectId);
         //获取项目的所有支出,按环节分组
         Map<Long, BigDecimal> costMap = employeeTaskInfoService.getAllEmployeeSalaryByProject(projectId);
         //项目每个进程的维护支出
-        Map<Long, BigDecimal> maintainMap = budgetService.getAllMaintainCost8(projectId);
-        Boolean isMaintain = true;
-        if (maintainMap == null || maintainMap.size() <= 0){
-            isMaintain = false;
-        }
+        Map<Long, BigDecimal> maintainMap = employeeTaskInfoService.getAllMaintainSalaryByProject(projectId);
 
         //项目每个进程的报销支出
         Map<Long, BigDecimal> reimburseMap = projectInfoService.getProjectReimburseByProcess(projectId);
@@ -942,12 +928,12 @@ public class AnnualBudgetServiceImpl extends BaseServiceImpl<AnnualBudgetMapper,
                 }
             }
             //设置维护支出
-            if (isMaintain && maintainMap.get(process.getId()) != null){
+            if (maintainMap != null && maintainMap.get(process.getId()) != null){
                    big = big.add(maintainMap.get(process.getId()));
             }
             vo.setProcessCostCount(big);
             //设置进程支出金额百分比,统计实际支出和预算的百分比
-            if (budgetMap != null){
+            if (isPlan2){
                 List<ProjectCostBudget> budgets = collect2.get(process.getId());
                 if (budgets != null && budgets.size() > 0) {
                     BigDecimal allMoney = new BigDecimal(0);

+ 82 - 0
blade-service/blade-control/src/main/java/org/springblade/control/service/impl/EmployeeTaskInfoServiceImpl.java

@@ -88,6 +88,88 @@ public class EmployeeTaskInfoServiceImpl extends BaseServiceImpl<EmployeeTaskInf
         baseMapper.deleteMaintainByBudgetId(id);
     }
 
+    /**
+     * 根据年查询当年所有的维护支出
+     * @param y
+     * @return
+     */
+    @Override
+    public BigDecimal getAllMaintainSalaryByYear(int y) {
+        BigDecimal decimal = baseMapper.getAllMaintainSalaryByYear(y);
+        if (decimal == null){
+            return new BigDecimal(0);
+        }
+        return decimal;
+    }
+
+    /**
+     * 根据年查询当年所有的维护支出,并按照项目分组,组里的数据是每个月的支出,如果该项目没有支出将不会插入
+     * @param y
+     * @return
+     */
+    @Override
+    public Map<Long, Map<Integer, BigDecimal>> getAllMaintainSalaryByYear2(int y) {
+        List<EmployeeTaskInfo> list = baseMapper.getAllMaintainSalaryByYear2(y);
+        if (list != null && list.size() > 0){
+            Map<Long, Map<Integer, BigDecimal>> map = new HashMap<>();
+            Map<Long, List<EmployeeTaskInfo>> listMap = list.parallelStream()
+                    .collect(Collectors.groupingBy(EmployeeTaskInfo::getProjectId));
+            for (Long aLong : listMap.keySet()) {
+                //该项目所有支出
+                List<EmployeeTaskInfo> infoList = listMap.get(aLong);
+                //按月份分组
+                Map<Integer, BigDecimal> monthMap = infoList.stream().collect(
+                        Collectors.groupingBy(
+                                o -> o.getOneDay().getMonthValue(),
+                                Collectors.mapping(EmployeeTaskInfo::getEmployeeSalary, Collectors.reducing(BigDecimal.ZERO, BigDecimal::add))
+                        ));
+                map.put(aLong,monthMap);
+            }
+            return map;
+        }
+        return null;
+    }
+
+    /**
+     * 根据年查询当年所有的维护支出,并按照项目分组,组里的数据是项目年支出,如果该项目没有支出将不会插入
+     * @param y
+     * @return
+     */
+    @Override
+    public Map<Long, BigDecimal> getAllMaintainSalaryByYear3(int y) {
+        List<EmployeeTaskInfo> list = baseMapper.getAllMaintainSalaryByYear2(y);
+        if (list != null && list.size() > 0){
+            //按项目分组
+            Map<Long, BigDecimal> monthMap = list.stream().collect(
+                    Collectors.groupingBy(
+                            o -> o.getProjectId(),
+                            Collectors.mapping(EmployeeTaskInfo::getEmployeeSalary, Collectors.reducing(BigDecimal.ZERO, BigDecimal::add))
+                    ));
+            return monthMap;
+        }
+        return null;
+    }
+
+    /**
+     * 获取项目的所有支出,按环节分组,如果该环节没有支出,将不会插入
+     * @param projectId
+     * @return
+     */
+    @Override
+    public Map<Long, BigDecimal> getAllMaintainSalaryByProject(Long projectId) {
+        List<EmployeeTaskInfo> list = baseMapper.getAllMaintainSalaryByProject(projectId);
+        if (list != null && list.size() > 0){
+            //按项目分组
+            Map<Long, BigDecimal> monthMap = list.stream().collect(
+                    Collectors.groupingBy(
+                            o -> o.getProjectProcess(),
+                            Collectors.mapping(EmployeeTaskInfo::getEmployeeSalary, Collectors.reducing(BigDecimal.ZERO, BigDecimal::add))
+                    ));
+            return monthMap;
+        }
+        return null;
+    }
+
     /**
      * 根据年查询当年所有的人工支出
      * @param y