From 43e80e0148b02f1cc54409971dd565e7ff6402b6 Mon Sep 17 00:00:00 2001
From: yaozc <unbelievers@yeah.net>
Date: Tue, 17 Jan 2023 02:33:42 +0000
Subject: [PATCH] Merge branch 'master' of http://192.168.1.110:5678/r/pms-upgrade into yaozc
---
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/quartz/task/WeekReportMethod.java | 49 ++++++++++++++++++++++++++++++++++++++++++++-----
1 files changed, 44 insertions(+), 5 deletions(-)
diff --git a/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/quartz/task/WeekReportMethod.java b/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/quartz/task/WeekReportMethod.java
index 520768e..94b93e8 100644
--- a/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/quartz/task/WeekReportMethod.java
+++ b/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/quartz/task/WeekReportMethod.java
@@ -1,13 +1,19 @@
package me.zhengjie.modules.quartz.task;
import java.math.BigDecimal;
+import java.text.SimpleDateFormat;
import java.time.DayOfWeek;
import java.time.LocalDate;
import java.time.ZoneId;
import java.time.temporal.WeekFields;
import java.util.Date;
+import java.util.HashMap;
import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
+import java.util.stream.Collectors;
+import me.zhengjie.modules.task.domain.TaskDailyInterface;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;
@@ -18,8 +24,9 @@
import me.zhengjie.modules.project.domain.ProjectProgress;
import me.zhengjie.modules.project.repository.ProjectProgressRepository;
import me.zhengjie.modules.project.repository.ProjectRepository;
+import me.zhengjie.modules.project.service.ProjectCostService;
import me.zhengjie.modules.task.domain.Task;
-import me.zhengjie.modules.task.domain.TaskDaliyCollectInterface;
+import me.zhengjie.modules.task.domain.TaskDaliy;
import me.zhengjie.modules.task.repository.TaskDaliyRepository;
import me.zhengjie.modules.task.repository.TaskRepository;
@@ -39,6 +46,8 @@
private final TaskRepository taskRepository;
private final TaskDaliyRepository taskDaliyRepository;
+
+ private final ProjectCostService projectCostService;
/**
* 生成周报
@@ -86,18 +95,44 @@
// 真实时长
Double realLastCost = 0.0;
List<Task> taskList = taskRepository.findByProjectIdUntilDate(project.getId(), projectProgress.getBelongDate());
+
+// List<TaskDaliyCostGroupByUserInterface> taskDaliyCostGroupByUserList = taskDaliyRepository.collectCostByProjectIdGroupUser(project.getId());
+// for (TaskDaliyCostGroupByUserInterface taskDaliyCostGroupByUser : taskDaliyCostGroupByUserList) {
+//
+// }
+
+ List<TaskDaliy> taskDaliyList = taskDaliyRepository.findByProjectId(project.getId());
+ Map<Long, List<TaskDaliy>> collectMap = taskDaliyList.stream().collect(Collectors.groupingBy(TaskDaliy::getUserId));
+
+ SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
+ BigDecimal totalCost = BigDecimal.valueOf(0.0);
+ for (Entry<Long, List<TaskDaliy>> entry : collectMap.entrySet()) {
+ List<TaskDaliy> taskDaliyListSub = entry.getValue();
+ Map<String, Double> costHourMap = new HashMap<String, Double>();
+ taskDaliyListSub.forEach(taskDaliy -> {
+ costHourMap.put(sdf.format(taskDaliy.getFillDate()), taskDaliy.getConsumedHours());
+ });
+ String startDate = sdf.format(taskDaliyListSub.get(0).getFillDate());
+ String endDate = sdf.format(taskDaliyListSub.get(taskDaliyListSub.size() - 1).getFillDate());
+ try {
+ totalCost = totalCost.add(projectCostService.calcUserCostByDate(entry.getKey(), startDate + " 00:00:00", endDate + " 00:00:00", costHourMap));
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
for (Task task : taskList) {
timeTotalInit = timeTotalInit + task.getPlanHours();
workTotalInit = workTotalInit + (task.getPlanWorkload() == null ? 0.0 : task.getPlanWorkload());
- TaskDaliyCollectInterface taskDaliyCollection = taskDaliyRepository.collectTaskDaliyUntilDate(task.getId(), projectProgress.getBelongDate());
+ TaskDailyInterface taskDailyInterface = taskDaliyRepository.collectTaskDaliyUntilDate(task.getId(), projectProgress.getBelongDate());
boolean flg = true;
if (flg) { // TODO 任务状态:未结束 task.getStatus()
- timeTotalCost += BigDecimal.valueOf(task.getPlanHours()).multiply(BigDecimal.valueOf(taskDaliyCollection.getTaskProgress())).divide(BigDecimal.valueOf(100), 2, BigDecimal.ROUND_CEILING).doubleValue();
+ timeTotalCost += BigDecimal.valueOf(task.getPlanHours()).multiply(BigDecimal.valueOf(taskDailyInterface.getTaskProgress())).divide(BigDecimal.valueOf(100), 2, BigDecimal.ROUND_CEILING).doubleValue();
} else {
timeTotalCost += task.getPlanHours();
}
- workTotalCost += taskDaliyCollection.getConsumedWorkload();
- realLastCost += taskDaliyCollection.getConsumedHours();
+ workTotalCost += taskDailyInterface.getConsumedWorkload();
+ realLastCost += taskDailyInterface.getConsumedHours();
}
// 真实时长
projectProgress.setRealLastCost(realLastCost);
@@ -109,6 +144,10 @@
projectProgress.setWorkTotalCost(workTotalCost);
// 总工作量
projectProgress.setWorkTotalInit(workTotalInit);
+ // 计划总成本
+ projectProgress.setMoneyTotalInit(project.getPerformancePrice().multiply(BigDecimal.valueOf(timeTotalInit)));
+ // 总消耗成本
+ projectProgress.setMoneyTotalCost(totalCost);
// 存在则更新,不存在则插入
projectProgressRepository.save(projectProgress);
--
Gitblit v1.9.3