|
@@ -237,206 +237,39 @@ public class ReportServiceImpl extends ServiceImpl<ReportMapper, Report> impleme
|
|
|
//首先根据日期获取当天所有提交过日志的人
|
|
|
String userId = request.getHeader("Token");
|
|
|
User user = userMapper.selectById(userId);
|
|
|
- TimeType timeType = timeTypeMapper.selectById(user.getCompanyId());
|
|
|
+ String viewUserId = user.getId();
|
|
|
+ Integer companyId = user.getCompanyId();
|
|
|
+ TimeType timeType = timeTypeMapper.selectById(companyId);
|
|
|
List<Map<String, Object>> nameList = new ArrayList<>();
|
|
|
List<SysRichFunction> functionList = sysFunctionMapper.getRoleFunctions(user.getRoleId(), "查看全公司工时");
|
|
|
Integer totalMembCount = 0;
|
|
|
if (functionList.size() == 0) {
|
|
|
- String leaderId = user.getId();
|
|
|
- //不是项目经理,只看自己的报告
|
|
|
List<Map<String, Object>> list = new ArrayList<>();
|
|
|
- //没有指定员工或者指定的就是自己
|
|
|
- if (targetUid == null || targetUid.equals(user.getId())) {
|
|
|
- //查看自己的日报
|
|
|
- if (pageIndex != null && pageIndex == 0) {
|
|
|
- //仅第一页显示自己的
|
|
|
- Map<String, Object> map = new HashMap<>();
|
|
|
- map.put("id", user.getId());
|
|
|
- map.put("name", user.getName());
|
|
|
- List<String> uids = new ArrayList<>();
|
|
|
- uids.add(user.getId());
|
|
|
- list = reportMapper.getUserReportByDateOrId(date, uids, null);
|
|
|
- if (list.size() > 0) {
|
|
|
- //个人日报
|
|
|
- nameList.add(map);
|
|
|
- map.put("data", list);
|
|
|
- double reportTime = 0;
|
|
|
- BigDecimal total = new BigDecimal(0);
|
|
|
- int state = (int)list.get(0).get("state");
|
|
|
- boolean hasDeny = false;
|
|
|
- boolean hasWaiting = false;
|
|
|
- for (Map<String, Object> m : list) {
|
|
|
- double t = (double) m.get("time");
|
|
|
- reportTime += t;
|
|
|
- total = total.add((BigDecimal)m.get("cost"));
|
|
|
- int curState = (int)m.get("state");
|
|
|
- if (curState == 2) {
|
|
|
- hasDeny = true;
|
|
|
- }
|
|
|
- if (curState == 0) {
|
|
|
- hasWaiting = true;
|
|
|
- }
|
|
|
- }
|
|
|
- if(hasDeny) {
|
|
|
- state = 2;
|
|
|
- } else if (hasWaiting) {
|
|
|
- state = 0;
|
|
|
- }
|
|
|
- DecimalFormat df = new DecimalFormat("0.00");
|
|
|
- map.put("reportTime", df.format(reportTime));
|
|
|
- map.put("cost", total);
|
|
|
- map.put("state", state);
|
|
|
- }
|
|
|
+ List<Integer> allVisibleDeptIdList = null;
|
|
|
+ if (deptId != null) {
|
|
|
+ //指定了部门进行查看
|
|
|
+ allVisibleDeptIdList = new ArrayList<>();
|
|
|
+ allVisibleDeptIdList.add(deptId);
|
|
|
+ //找到该部门的所有子部门
|
|
|
+ List<Department> allDepts = departmentMapper.selectList(new QueryWrapper<Department>().eq("company_id", companyId));
|
|
|
+ Optional<Department> first = allDepts.stream().filter(d -> d.getDepartmentId().equals(deptId)).findFirst();
|
|
|
+ if (first.isPresent()) {
|
|
|
+ Department department = first.get();
|
|
|
+ //递归获取全部子部门
|
|
|
+ List<Department> deptList = getSubDepts(department, allDepts);
|
|
|
+ deptList.add(department);
|
|
|
+ List<Integer> ids = deptList.stream().map(Department::getDepartmentId).collect(Collectors.toList());
|
|
|
+ allVisibleDeptIdList.addAll(ids);
|
|
|
}
|
|
|
+ } else {
|
|
|
+ allVisibleDeptIdList = getAllVisibleDeptIdList(user, null);
|
|
|
}
|
|
|
-
|
|
|
- List<Integer> allVisibleDeptIdList = getAllVisibleDeptIdList(user, null);
|
|
|
//需要看可见部门(部门主要负责人和其他负责人以及查看本部门工时权限)所有人员的日报
|
|
|
- if (allVisibleDeptIdList.size() > 0) {
|
|
|
- if (nameList.size() > 0) {
|
|
|
- //自己填写的日报
|
|
|
- List<Map<String, Object>> deptNameList = reportMapper.getReportNameByDateAndDept(date,
|
|
|
- allVisibleDeptIdList, targetUid, null, pageStart, pageSize);
|
|
|
- totalMembCount = reportMapper.getReportNameByDateAndDeptCount(date, allVisibleDeptIdList, targetUid, null);
|
|
|
- for (Map<String, Object> deptNameItem : deptNameList) {
|
|
|
- if (!deptNameItem.get("id").equals(user.getId())) {
|
|
|
- nameList.add(deptNameItem);
|
|
|
- }
|
|
|
- }
|
|
|
- } else {
|
|
|
- nameList = reportMapper.getReportNameByDateAndDept(date,
|
|
|
- allVisibleDeptIdList, targetUid, null, pageStart, pageSize);
|
|
|
- totalMembCount = reportMapper.getReportNameByDateAndDeptCount(date, allVisibleDeptIdList, targetUid, null);
|
|
|
- }
|
|
|
- if (nameList.size() > 0) {
|
|
|
- List<String> userIds = new ArrayList<>();
|
|
|
- nameList.forEach(n->{
|
|
|
- String id = (String) n.get("id");
|
|
|
- userIds.add(id);
|
|
|
- });
|
|
|
- List<Map<String, Object>> reportList = reportMapper.getUserReportByDateOrId(date, userIds, null);
|
|
|
- for (Map<String, Object> memb : nameList) {
|
|
|
- //再根据人分别获取当天的报告
|
|
|
- List<Map<String, Object>> rList = new ArrayList<Map<String, Object>>();
|
|
|
- BigDecimal total = new BigDecimal(0);
|
|
|
- for (Map<String, Object> report : reportList) {
|
|
|
- if (((String)report.get("creatorId")).equals((String)memb.get("id"))) {
|
|
|
- rList.add(report);
|
|
|
- total = total.add((BigDecimal) report.get("cost"));
|
|
|
- }
|
|
|
- }
|
|
|
- memb.put("data", rList);
|
|
|
- memb.put("cost", total);
|
|
|
- double reportTime = 0;
|
|
|
- if (rList.size() > 0) {
|
|
|
- int state = 1;
|
|
|
- for (Map<String, Object> m : rList) {
|
|
|
- double t = (double) m.get("time");
|
|
|
- reportTime += t;
|
|
|
-
|
|
|
- //取最低的状态
|
|
|
- if (state == 2) {
|
|
|
- continue;
|
|
|
- }
|
|
|
- if (state == 0) {
|
|
|
- if ((int)m.get("state") == 2) {
|
|
|
- state = 2;
|
|
|
- } else {
|
|
|
- continue;
|
|
|
- }
|
|
|
- } else {
|
|
|
- state = (int)m.get("state");
|
|
|
- }
|
|
|
- }
|
|
|
- memb.put("state", state);
|
|
|
- }
|
|
|
- DecimalFormat df = new DecimalFormat("0.00");
|
|
|
- memb.put("reportTime", df.format(reportTime));
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- if(deptId==null&&targetUid==null){
|
|
|
- //担任项目经理或者日报审核人,查找相关的人员的日报
|
|
|
- List<Map<String, Object>> puserNames = reportMapper.getReportNameByDate(date, user.getCompanyId(), leaderId);
|
|
|
- List<Map<String, Object>> inchargeReportList= reportMapper.getInchargeReportByDate(date, leaderId, null);
|
|
|
-
|
|
|
- if ((timeType.getReportAuditType() == 5 || timeType.getReportAuditType() == 6)&& timeType.getReportCc() == 1) {
|
|
|
- //存在抄送人的设置,需要把抄送人的项目相关日报也加上
|
|
|
- List<Map<String, Object>> viewUserNames = reportMapper.getCcReportNameByDate(date, user.getCompanyId(),leaderId);
|
|
|
- for (Map<String, Object> viewItem : viewUserNames) {
|
|
|
- boolean exists = false;
|
|
|
- for (Map<String, Object> u : puserNames) {
|
|
|
- if (u.get("id").equals(viewItem.get("id"))) {
|
|
|
- exists = true;
|
|
|
- break;
|
|
|
- }
|
|
|
- }
|
|
|
- if (!exists) {
|
|
|
- puserNames.add(viewItem);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- List<Map<String, Object>> viewReportList = reportMapper.getCcReportByDate(date, leaderId, null);
|
|
|
- for (Map<String, Object> viewItem : viewReportList) {
|
|
|
- boolean exists = false;
|
|
|
- for (Map<String, Object> u : inchargeReportList) {
|
|
|
- if (u.get("id").equals(viewItem.get("id"))) {
|
|
|
- exists = true;
|
|
|
- break;
|
|
|
- }
|
|
|
- }
|
|
|
- if (!exists) {
|
|
|
- inchargeReportList.add(viewItem);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- for (Map<String, Object> map2 : puserNames) {
|
|
|
-
|
|
|
- if (nameList.size() > 0) {
|
|
|
- String myUserId = (String)nameList.get(0).get("id");
|
|
|
- if (myUserId.equals(map2.get("id"))) {
|
|
|
- //自己的报告,之前已经添加过了,排重
|
|
|
- continue;
|
|
|
- }
|
|
|
- }
|
|
|
- List<Object> collect = nameList.stream().map(nl -> nl.get("")).collect(Collectors.toList());
|
|
|
- if(!collect.contains(map2.get("id"))){
|
|
|
- nameList.add(map2);
|
|
|
- }
|
|
|
- //再根据人分别获取当天的报告
|
|
|
- List<Map<String, Object>> list2 =
|
|
|
- inchargeReportList.stream().filter(i->i.get("creatorId").equals(map2.get("id"))).collect(Collectors.toList());
|
|
|
- map2.put("data", list2);
|
|
|
-
|
|
|
- double reportTime = 0;
|
|
|
- BigDecimal total = new BigDecimal(0);
|
|
|
- int state = 1;
|
|
|
- for (Map<String, Object> m : list2) {
|
|
|
- double t = (double) m.get("time");
|
|
|
- reportTime += t;
|
|
|
- total = total.add((BigDecimal)m.get("cost"));
|
|
|
- //取最低的状态
|
|
|
- if (state == 2) {
|
|
|
- continue;
|
|
|
- }
|
|
|
- if (state == 0) {
|
|
|
- if ((int)m.get("state") == 2) {
|
|
|
- state = 2;
|
|
|
- } else {
|
|
|
- continue;
|
|
|
- }
|
|
|
- } else {
|
|
|
- state = (int)m.get("state");
|
|
|
- }
|
|
|
- }
|
|
|
- DecimalFormat df = new DecimalFormat("0.00");
|
|
|
- map2.put("reportTime", df.format(reportTime));
|
|
|
- map2.put("cost", total);
|
|
|
- map2.put("state", state);
|
|
|
- }
|
|
|
- }
|
|
|
+ nameList = reportMapper.getReportNameByDateAndDept(date,
|
|
|
+ allVisibleDeptIdList.size() > 0?allVisibleDeptIdList:null, targetUid, companyId, (deptId == null?viewUserId:null), pageStart, pageSize);
|
|
|
+ totalMembCount = reportMapper.getReportNameByDateAndDeptCount(date, allVisibleDeptIdList.size() > 0?allVisibleDeptIdList:null, targetUid, companyId, (deptId == null?viewUserId:null));
|
|
|
} else {
|
|
|
- Integer companyId = userMapper.selectById(request.getHeader("Token")).getCompanyId();
|
|
|
+ //查看全公司的数据
|
|
|
List<Integer> ids = null;
|
|
|
if (deptId != null) {
|
|
|
if (deptId == 0) {
|
|
@@ -457,53 +290,53 @@ public class ReportServiceImpl extends ServiceImpl<ReportMapper, Report> impleme
|
|
|
}
|
|
|
}
|
|
|
nameList = reportMapper.getReportNameByDateAndDept(date,
|
|
|
- ids, targetUid, companyId, pageStart, pageSize);
|
|
|
- totalMembCount = reportMapper.getReportNameByDateAndDeptCount(date, ids, targetUid, companyId);
|
|
|
- if (nameList.size() > 0) {
|
|
|
- List<String> userIds = new ArrayList<>();
|
|
|
- nameList.forEach(n->{
|
|
|
- String id = (String) n.get("id");
|
|
|
- userIds.add(id);
|
|
|
- });
|
|
|
- List<Map<String, Object>> reportList = reportMapper.getUserReportByDateOrId(date, userIds, null);
|
|
|
- for (Map<String, Object> map : nameList) {
|
|
|
- //再根据人分别获取当天的报告
|
|
|
- List<Map<String, Object>> list = new ArrayList<Map<String, Object>>();
|
|
|
- BigDecimal total = new BigDecimal(0);
|
|
|
- for (Map<String, Object> report : reportList) {
|
|
|
- if (((String)report.get("creatorId")).equals((String)map.get("id"))) {
|
|
|
- list.add(report);
|
|
|
- total = total.add((BigDecimal) report.get("cost"));
|
|
|
- }
|
|
|
-
|
|
|
+ ids, targetUid, companyId, null, pageStart, pageSize);
|
|
|
+ totalMembCount = reportMapper.getReportNameByDateAndDeptCount(date, ids, targetUid, companyId, null);
|
|
|
+ }
|
|
|
+ if (nameList.size() > 0) {
|
|
|
+ List<String> userIds = new ArrayList<>();
|
|
|
+ nameList.forEach(n->{
|
|
|
+ String id = (String) n.get("id");
|
|
|
+ userIds.add(id);
|
|
|
+ });
|
|
|
+ List<Map<String, Object>> reportList = reportMapper.getUserReportByDateOrId(date, userIds, null);
|
|
|
+ for (Map<String, Object> memb : nameList) {
|
|
|
+ //再根据人分别获取当天的报告
|
|
|
+ List<Map<String, Object>> rList = new ArrayList<Map<String, Object>>();
|
|
|
+ BigDecimal total = new BigDecimal(0);
|
|
|
+ for (Map<String, Object> report : reportList) {
|
|
|
+ if (((String)report.get("creatorId")).equals((String)memb.get("id"))) {
|
|
|
+ rList.add(report);
|
|
|
+ total = total.add((BigDecimal) report.get("cost"));
|
|
|
}
|
|
|
- map.put("data", list);
|
|
|
- map.put("cost", total);
|
|
|
- double reportTime = 0;
|
|
|
- if (list.size() > 0) {
|
|
|
- int state = 1;
|
|
|
- for (Map<String, Object> m : list) {
|
|
|
- double t = (double) m.get("time");
|
|
|
- reportTime += t;
|
|
|
- //取最低的状态
|
|
|
- if (state == 2) {
|
|
|
- continue;
|
|
|
- }
|
|
|
- if (state == 0) {
|
|
|
- if ((int)m.get("state") == 2) {
|
|
|
- state = 2;
|
|
|
- } else {
|
|
|
- continue;
|
|
|
- }
|
|
|
+ }
|
|
|
+ memb.put("data", rList);
|
|
|
+ memb.put("cost", total);
|
|
|
+ double reportTime = 0;
|
|
|
+ if (rList.size() > 0) {
|
|
|
+ int state = 1;
|
|
|
+ for (Map<String, Object> m : rList) {
|
|
|
+ double t = (double) m.get("time");
|
|
|
+ reportTime += t;
|
|
|
+
|
|
|
+ //取最低的状态
|
|
|
+ if (state == 2) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ if (state == 0) {
|
|
|
+ if ((int)m.get("state") == 2) {
|
|
|
+ state = 2;
|
|
|
} else {
|
|
|
- state = (int)m.get("state");
|
|
|
+ continue;
|
|
|
}
|
|
|
+ } else {
|
|
|
+ state = (int)m.get("state");
|
|
|
}
|
|
|
- map.put("state", state);
|
|
|
}
|
|
|
- DecimalFormat df = new DecimalFormat("0.00");
|
|
|
- map.put("reportTime", df.format(reportTime));
|
|
|
+ memb.put("state", state);
|
|
|
}
|
|
|
+ DecimalFormat df = new DecimalFormat("0.00");
|
|
|
+ memb.put("reportTime", df.format(reportTime));
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -7067,6 +6900,36 @@ public class ReportServiceImpl extends ServiceImpl<ReportMapper, Report> impleme
|
|
|
if (defaultDegree!=null && "-1".equals(defaultDegree.get("id").toString())){
|
|
|
defaultDegree = null;
|
|
|
}
|
|
|
+ //如果该项目已经没有绑定该维度,则取消
|
|
|
+ if (defaultDegree != null) {
|
|
|
+ Integer degreeId = (Integer) defaultDegree.get("id");
|
|
|
+ Integer companyId = user.getCompanyId();
|
|
|
+ TimeType timeType = timeTypeMapper.selectById(companyId);
|
|
|
+ List<ReportExtraDegree> extraDegreeList = reportExtraDegreeMapper.selectList(new QueryWrapper<ReportExtraDegree>().eq("company_id", companyId));
|
|
|
+ String associateDegrees = "";
|
|
|
+ List<String> associateDegreeList = new ArrayList<>();
|
|
|
+ if(timeType.getCustomDegreeWithPro()==0){
|
|
|
+ associateDegrees=extraDegreeList.stream().map(a->String.valueOf(a.getId())).collect(Collectors.joining(","));
|
|
|
+ }else {
|
|
|
+ Project project = projectMapper.selectById(projectId);
|
|
|
+ associateDegrees = project.getAssociateDegrees();
|
|
|
+ }
|
|
|
+ boolean find = false;
|
|
|
+ if (!StringUtils.isEmpty(associateDegrees)) {
|
|
|
+ String[] id = associateDegrees.split("\\,");
|
|
|
+ for (int i=0;i<id.length; i++) {
|
|
|
+ if (id[i].equals(degreeId.toString())) {
|
|
|
+ find = true;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (!find) {
|
|
|
+ //该维度已不存在,或者从项目上解绑了
|
|
|
+ defaultDegree = null;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
HttpRespMsg httpRespMsg = new HttpRespMsg();
|
|
|
httpRespMsg.data = defaultDegree;
|
|
|
return httpRespMsg;
|