Browse Source

修复成本分摊的bug

seyason 1 year ago
parent
commit
f082cc2ccb

+ 80 - 75
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/service/impl/FinanceServiceImpl.java

@@ -775,65 +775,65 @@ public class FinanceServiceImpl extends ServiceImpl<FinanceMapper, Finance> impl
                     if (userFinance.getCustomField3() != null) {
                         field3Item = userFinance.getCustomField3().multiply(new BigDecimal(workingTime)).divide(userTime.get(creatorId).workingTime, 4, BigDecimal.ROUND_HALF_UP);
                     }
-                } else {
-//                    System.out.println("财务数据中未找到用户:"+creatorId);
-                }
 
-                //改成按照projectId匹配,之前projectname可能存在重名问题。
-                if (projectId.equals(item.projectId)) {
-                    item.workingTime += workingTime;
-                    item.cost = item.cost.add(cost);
-                    item.salary = item.salary.add(salary);
-                    item.bonus = item.bonus.add(bonus);
-                    item.allowance = item.allowance.add(allowance);
-                    item.old = item.old.add(old);
-                    item.medical = item.medical.add(medical);
-                    item.loseJob = item.loseJob.add(loseJob);
-                    item.injury = item.injury.add(injury);
-                    item.house = item.house.add(house);
+                    //改成按照projectId匹配,之前projectname可能存在重名问题。
+                    if (projectId.equals(item.projectId)) {
+                        item.workingTime += workingTime;
+                        item.cost = item.cost.add(cost);
+                        item.salary = item.salary.add(salary);
+                        item.bonus = item.bonus.add(bonus);
+                        item.allowance = item.allowance.add(allowance);
+                        item.old = item.old.add(old);
+                        item.medical = item.medical.add(medical);
+                        item.loseJob = item.loseJob.add(loseJob);
+                        item.injury = item.injury.add(injury);
+                        item.house = item.house.add(house);
 //                    item.other = item.other.add(other);
-                    item.field1 = item.field1.add(field1Item);
-                    item.field2 = item.field2.add(field2Item);
-                    item.field3 = item.field3.add(field3Item);
-                } else {
-                    item = new ProjectSumItem();
-                    pList.add(item);
-                    item.project = curProject;
-                    item.projectId = projectId;
-                    item.projectCode = curProjectCode;
-                    item.categoryName = categoryName;
-                    item.workingTime = workingTime;
-                    item.cost = cost;
-                    item.salary = salary;
-                    item.bonus = bonus;
-                    item.allowance = allowance;
-                    item.old = old;
-                    item.medical = medical;
-                    item.loseJob = loseJob;
-                    item.injury = injury;
-                    item.house = house;
-                    item.field1 = field1Item;
-                    item.field2 = field2Item;
-                    item.field3 = field3Item;
-                }
-                totalMoneyCost = totalMoneyCost.add(cost);
-                totalSalary = totalSalary.add(salary);
-                totalBonus = totalBonus.add(bonus);
-                totalAllowance = totalAllowance.add(allowance);
-                totalOld = totalOld.add(old);
-                totalMedical = totalMedical.add(medical);
-                totalLoseJob = totalLoseJob.add(loseJob);
-                totalInjury = totalInjury.add(injury);
-                totalHouse = totalHouse.add(house);
+                        item.field1 = item.field1.add(field1Item);
+                        item.field2 = item.field2.add(field2Item);
+                        item.field3 = item.field3.add(field3Item);
+                    } else {
+                        item = new ProjectSumItem();
+                        pList.add(item);
+                        item.project = curProject;
+                        item.projectId = projectId;
+                        item.projectCode = curProjectCode;
+                        item.categoryName = categoryName;
+                        item.workingTime = workingTime;
+                        item.cost = cost;
+                        item.salary = salary;
+                        item.bonus = bonus;
+                        item.allowance = allowance;
+                        item.old = old;
+                        item.medical = medical;
+                        item.loseJob = loseJob;
+                        item.injury = injury;
+                        item.house = house;
+                        item.field1 = field1Item;
+                        item.field2 = field2Item;
+                        item.field3 = field3Item;
+                    }
+                    totalMoneyCost = totalMoneyCost.add(cost);
+                    totalSalary = totalSalary.add(salary);
+                    totalBonus = totalBonus.add(bonus);
+                    totalAllowance = totalAllowance.add(allowance);
+                    totalOld = totalOld.add(old);
+                    totalMedical = totalMedical.add(medical);
+                    totalLoseJob = totalLoseJob.add(loseJob);
+                    totalInjury = totalInjury.add(injury);
+                    totalHouse = totalHouse.add(house);
 //                totalOther = totalOther.add(other);
-                if (totalField1 != null) {
-                    totalField1 = totalField1.add(field1Item);
-                }
-                if (totalField2 != null) {
-                    totalField2 = totalField2.add(field2Item);
-                }
-                if (totalField3 != null) {
-                    totalField3 = totalField3.add(field3Item);
+                    if (totalField1 != null) {
+                        totalField1 = totalField1.add(field1Item);
+                    }
+                    if (totalField2 != null) {
+                        totalField2 = totalField2.add(field2Item);
+                    }
+                    if (totalField3 != null) {
+                        totalField3 = totalField3.add(field3Item);
+                    }
+                } else {
+//                    System.out.println("财务数据中未找到用户:"+creatorId);
                 }
             }
 
@@ -841,7 +841,7 @@ public class FinanceServiceImpl extends ServiceImpl<FinanceMapper, Finance> impl
             if (assignNoProUser != null && assignNoProUser) {
                 List<FinanceProjects> notInFPList = new ArrayList<FinanceProjects>();
                 financeProjects.forEach(f->{
-                    if (!projectTimeList.stream().anyMatch(map->(((Long)map.get("projectId"))).intValue() == f.getProjectId())) {
+                    if (!pList.stream().anyMatch(pItem->pItem.getProjectId().intValue() == f.getProjectId())) {
                         notInFPList.add(f);
                     }
                 });
@@ -1296,7 +1296,12 @@ public class FinanceServiceImpl extends ServiceImpl<FinanceMapper, Finance> impl
             endDate = endDate.plusMonths(1);
 
             List<Map<String, Object>> projectTimeList = reportMapper.getRealProjectTime(startDate, endDate, companyId);
-
+            for (Map<String, Object> map : projectTimeList) {
+                String p = (String) map.get("project");
+                if (p.equals("10G OLT Driver-XGs combo")) {
+                    System.out.println("找到项目 10G OLT Driver-XGs combo");
+                }
+            }
             BigDecimal totalMoneyCost = BigDecimal.valueOf(0);
             //计算每个项目的时间和成本
             ProjectSumItem item = new ProjectSumItem();
@@ -1363,27 +1368,27 @@ public class FinanceServiceImpl extends ServiceImpl<FinanceMapper, Finance> impl
                 BigDecimal cost = new BigDecimal(0);
                 if (first.isPresent()) {
                     cost = first.get().getHourCost().multiply(new BigDecimal(workingTime));
+                    if (curProject == null) {
+                        System.out.println("projectId="+projectId+", creatorId="+creatorId);
+                    }
+                    //改成按照projectId匹配,之前projectname可能存在重名问题。
+                    if (projectId.equals(item.projectId)) {
+                        item.workingTime += workingTime;
+                        item.cost = item.cost.add(cost);
+                    } else {
+                        item = new ProjectSumItem();
+                        pList.add(item);
+                        item.projectId = projectId;
+                        item.project = curProject;
+                        item.workingTime = workingTime;
+                        item.cost = cost;
+                    }
+                    totalMoneyCost = totalMoneyCost.add(cost);
                 } else {
                     if (!missingFinanceUserIds.contains(creatorId)) {
                         missingFinanceUserIds.add(creatorId);
                     }
-                    continue;
-                }
-                if (curProject == null) {
-                    System.out.println("projectId="+projectId+", creatorId="+creatorId);
                 }
-                if (projectId.equals(item.projectId)) {
-                    item.workingTime += workingTime;
-                    item.cost = item.cost.add(cost);
-                } else {
-                    item = new ProjectSumItem();
-                    pList.add(item);
-                    item.projectId = projectId;
-                    item.project = curProject;
-                    item.workingTime = workingTime;
-                    item.cost = cost;
-                }
-                totalMoneyCost = totalMoneyCost.add(cost);
             }
             BigDecimal bgCostTotal = new BigDecimal(0);
             for (ProjectSumItem p : pList) {
@@ -1441,7 +1446,7 @@ public class FinanceServiceImpl extends ServiceImpl<FinanceMapper, Finance> impl
 
                 List<FinanceProjects> notInFPList = new ArrayList<FinanceProjects>();
                 financeProjects.forEach(f->{
-                    if (!projectTimeList.stream().anyMatch(map->(((Long)map.get("projectId"))).intValue() == f.getProjectId())) {
+                    if (!pList.stream().anyMatch(pItem->pItem.getProjectId().intValue() == f.getProjectId())) {
                         notInFPList.add(f);
                     }
                 });