|
@@ -131,6 +131,8 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
|
|
|
@Resource
|
|
|
ProjectBasecostMapper projectBasecostMapper;
|
|
|
@Resource
|
|
|
+ CategoryRatioTblSettingMapper categoryRatioTblSettingMapper;
|
|
|
+ @Resource
|
|
|
CompanyMapper companyMapper;
|
|
|
@Resource
|
|
|
StagesMapper stagesMapper;
|
|
@@ -11957,6 +11959,55 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
|
|
|
return msg;
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public HttpRespMsg getMembProjectCateRatio(String startDate, String endDate, Integer onlyShowWarning) {
|
|
|
+ HttpRespMsg msg = new HttpRespMsg();
|
|
|
+ Integer companyId = userMapper.selectById(request.getHeader("token")).getCompanyId();
|
|
|
+ List<UserCateTimeVo> timeList = projectMapper.getMembProjectCateTime(companyId, startDate, endDate);
|
|
|
+ CategoryRatioTblSetting categoryRatioTblSetting = categoryRatioTblSettingMapper.selectById(companyId);
|
|
|
+ //把timeList按照用户分组
|
|
|
+ Map<String, List<UserCateTimeVo>> userMap = timeList.stream().collect(Collectors.groupingBy(UserCateTimeVo::getUserId));
|
|
|
+ List<ProjectCategory> categoryList = projectCategoryMapper.selectList(new QueryWrapper<ProjectCategory>().eq("company_id", companyId));
|
|
|
+ List<Map> retList = new ArrayList();
|
|
|
+ for (Map.Entry<String, List<UserCateTimeVo>> entry : userMap.entrySet()) {
|
|
|
+ Map<String, Object> map = new HashMap<>();
|
|
|
+ map.put("userId", entry.getKey());
|
|
|
+ List<UserCateTimeVo> value = entry.getValue();
|
|
|
+ map.put("userName", value.get(0).getName());
|
|
|
+ map.put("cateTimeList", value);
|
|
|
+ //是否仅达到预警的用户列表
|
|
|
+ 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()) {
|
|
|
+ UserCateTimeVo userCateTimeVo = first.get();
|
|
|
+ //获取用户的总工时预警
|
|
|
+ int ratio = categoryRatioTblSetting.getRatio();
|
|
|
+ if (categoryRatioTblSetting.getMoreOrLess() == 1) {
|
|
|
+ //大于预设比例的需要预警,小于等于则跳过
|
|
|
+ if (userCateTimeVo.getWorkingTime() <= sum * ratio / 100) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ //小于预设比例的需要预警;大于等于则跳过
|
|
|
+ if (userCateTimeVo.getWorkingTime() >= sum * ratio / 100) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ retList.add(map);
|
|
|
+ }
|
|
|
+ HashMap retMap = new HashMap();
|
|
|
+ retMap.put("categoryList", categoryList);
|
|
|
+ retMap.put("userList", retList);
|
|
|
+ msg.data = retMap;
|
|
|
+ return msg;
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
// public void setDeptIdList(Integer departmentId,List<Integer> deptIds){
|
|
|
// LambdaQueryWrapper<Department> lqw = new LambdaQueryWrapper<>();
|