seyason пре 1 година
родитељ
комит
348cd8be46

+ 3 - 0
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/entity/vo/UserCateTimeVo.java

@@ -9,5 +9,8 @@ public class UserCateTimeVo {
     public Integer category;
     public String categoryName;
     public Double workingTime;
+    public Double percent;
+
+    public boolean warning;
 
 }

+ 29 - 1
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/service/impl/ProjectServiceImpl.java

@@ -11975,10 +11975,38 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
             List<UserCateTimeVo> value = entry.getValue();
             map.put("userName", value.get(0).getName());
             map.put("cateTimeList", value);
+            //计算这个人的总工时
+            double sum = value.stream().mapToDouble(UserCateTimeVo::getWorkingTime).sum();
+            map.put("workingTime", sum);
+            //计算占比
+            value.forEach(v->{
+                if (sum > 0) {
+                    double v1 = v.getWorkingTime() * 100 / sum;
+                    v.setPercent(v1);
+                } else {
+                    v.setPercent(0.0);
+                }
+                if (categoryRatioTblSetting != null && categoryRatioTblSetting.getRatio() != null) {
+                    UserCateTimeVo userCateTimeVo = v;
+                    //获取用户的总工时预警
+                    int ratio = categoryRatioTblSetting.getRatio();
+                    if (categoryRatioTblSetting.getMoreOrLess() == 1) {
+                        //大于预设比例的需要预警
+                        if (userCateTimeVo.getPercent() > ratio) {
+                            v.setWarning(true);
+                        }
+                    } else {
+                        //小于预设比例的需要预警;
+                        if (userCateTimeVo.getPercent() < ratio) {
+                            v.setWarning(true);
+                        }
+                    }
+                }
+            });
+
             //是否仅达到预警的用户列表
             if (onlyShowWarning == 1) {
                 //获取用户的总工时
-                Double sum = value.stream().mapToDouble(UserCateTimeVo::getWorkingTime).sum();
                 if (categoryRatioTblSetting != null && categoryRatioTblSetting.getRatio() != null) {
                     Optional<UserCateTimeVo> first = value.stream().filter(v -> categoryRatioTblSetting.getMonitorCategoryId().equals(v.getCategory())).findFirst();
                     if (first.isPresent()) {