|
@@ -95,17 +95,17 @@ public class UserCorpwxTimeController {
|
|
|
List<SysRichFunction> functionList = sysFunctionMapper.getRoleFunctions(user.getRoleId(), "全部企微考勤");
|
|
|
if (functionList.size() > 0) {
|
|
|
//查看全部人员的
|
|
|
- list = userCorpwxTimeMapper.getUserDataList(user.getCompanyId(), startDate, endDate, null);
|
|
|
+ list = userCorpwxTimeMapper.getUserDataList(user.getCompanyId(), startDate, endDate, null, null);
|
|
|
} else {
|
|
|
Integer manageDeptId = user.getManageDeptId();
|
|
|
if (manageDeptId != null && manageDeptId != 0) {
|
|
|
//一个人可能担任多个部门负责人
|
|
|
List<Department> departments = departmentMapper.selectList(new QueryWrapper<Department>().eq("manager_id", user.getId()));
|
|
|
if (departments.size() == 1) {
|
|
|
- list = userCorpwxTimeMapper.getUserDataList(user.getCompanyId(), startDate, endDate, manageDeptId);
|
|
|
+ list = userCorpwxTimeMapper.getUserDataList(user.getCompanyId(), startDate, endDate, manageDeptId, null);
|
|
|
} else {
|
|
|
for (Department d:departments) {
|
|
|
- list.addAll(userCorpwxTimeMapper.getUserDataList(user.getCompanyId(), startDate, endDate, d.getDepartmentId()));
|
|
|
+ list.addAll(userCorpwxTimeMapper.getUserDataList(user.getCompanyId(), startDate, endDate, d.getDepartmentId(), null));
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -200,6 +200,99 @@ public class UserCorpwxTimeController {
|
|
|
return msg;
|
|
|
}
|
|
|
|
|
|
+ @RequestMapping("/getMyData")
|
|
|
+ public HttpRespMsg getMyData(String startDate, String endDate) {
|
|
|
+ String token = request.getHeader("TOKEN");
|
|
|
+ User user = userMapper.selectById(token);
|
|
|
+ List<Map> list = new ArrayList<Map>();
|
|
|
+ list = userCorpwxTimeMapper.getUserDataList(user.getCompanyId(), startDate, endDate, null, user.getId());
|
|
|
+ //工作日处理,排除常规周末和法定节假日
|
|
|
+ DateTimeFormatter dtf = DateTimeFormatter.ofPattern("yyyy/MM/dd");
|
|
|
+ list = list.stream().filter(time->{
|
|
|
+ String date = (String)time.get("createDate");
|
|
|
+ if (WorkDayCalculateUtils.isWorkDay(LocalDate.parse(date, dtf))) {
|
|
|
+ return true;
|
|
|
+ } else {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ }).collect(Collectors.toList());
|
|
|
+ DateTimeFormatter standFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
|
|
|
+ HashMap item = new HashMap();
|
|
|
+ item.put("list", list);
|
|
|
+ if (list.size() > 0) {
|
|
|
+ List<String> userIdList = new ArrayList<>();
|
|
|
+ for (int i=0;i<list.size(); i++) {
|
|
|
+ Map map = list.get(i);
|
|
|
+ String userId = (String)map.get("userId");
|
|
|
+ userIdList.add(userId);
|
|
|
+ }
|
|
|
+ //员工参与的项目
|
|
|
+ List<Participation> participationList = participationMapper.selectList(new QueryWrapper<Participation>().in("user_id", userIdList));
|
|
|
+ List<String> names = new ArrayList<>();
|
|
|
+ LocalDate localStart = LocalDate.parse(startDate, standFormatter);
|
|
|
+ LocalDate localEnd = LocalDate.parse(endDate, standFormatter);
|
|
|
+ if (participationList.size() > 0) {
|
|
|
+ List<Integer> collect = participationList.stream().map(Participation::getProjectId).collect(Collectors.toList());
|
|
|
+ List<Project> projectList = projectMapper.selectList(new QueryWrapper<Project>().in("id", collect).eq("is_public", 0).eq("company_id", user.getCompanyId()).orderByAsc("id"));
|
|
|
+
|
|
|
+ names = projectList.stream().filter(p->{
|
|
|
+ if (p.getPlanStartDate() != null) {
|
|
|
+ if (p.getPlanStartDate().isAfter(localEnd)) {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (p.getPlanEndDate() != null) {
|
|
|
+ if (p.getPlanEndDate().isBefore(localStart)) {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return true;
|
|
|
+ }).map(Project::getProjectName).collect(Collectors.toList());
|
|
|
+ }
|
|
|
+ //添加公共项目
|
|
|
+ List<Project> publicProjects = projectMapper.selectList(new QueryWrapper<Project>().eq("company_id", user.getCompanyId()).eq("is_public", 1));
|
|
|
+ if (publicProjects.size() > 0) {
|
|
|
+ List<String> collect = publicProjects.stream().filter(p->{
|
|
|
+ if (p.getPlanStartDate() != null) {
|
|
|
+ if (p.getPlanStartDate().isAfter(localEnd)) {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (p.getPlanEndDate() != null) {
|
|
|
+ if (p.getPlanEndDate().isBefore(localStart)) {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return true;
|
|
|
+ }).map(Project::getProjectName).collect(Collectors.toList());
|
|
|
+ names.addAll(collect);
|
|
|
+ }
|
|
|
+ item.put("projects", names);
|
|
|
+ } else {
|
|
|
+ item.put("projects", new ArrayList<String>());
|
|
|
+ }
|
|
|
+
|
|
|
+ //获取该时间段已经审核通过的报告
|
|
|
+ List<Report> reportList = reportService.list(new QueryWrapper<Report>()
|
|
|
+ .eq("company_id", user.getCompanyId()).between("create_date", startDate, endDate).eq("state", 1));
|
|
|
+
|
|
|
+ DateTimeFormatter splashDtf = DateTimeFormatter.ofPattern("yyyy/MM/dd");
|
|
|
+ //数据填充
|
|
|
+ for (Map dataItem : list) {
|
|
|
+ List<String> dataList = new ArrayList<>();
|
|
|
+ String userId = (String)dataItem.get("userId");
|
|
|
+ String createDate = (String)dataItem.get("createDate");
|
|
|
+ //检查该人员当天是否已经有审核通过的
|
|
|
+ boolean hasPassed = reportList.stream().anyMatch(r->r.getCreatorId().equals(userId) && splashDtf.format(r.getCreateDate()).equals(createDate));
|
|
|
+ dataItem.put("hasPassed", hasPassed);
|
|
|
+ }
|
|
|
+
|
|
|
+ //返回数据
|
|
|
+ HttpRespMsg msg = new HttpRespMsg();
|
|
|
+ msg.data = item;
|
|
|
+ return msg;
|
|
|
+ }
|
|
|
+
|
|
|
@RequestMapping("/submitProjectTime")
|
|
|
public HttpRespMsg submitProjectTime(String json, String projectColumns) {
|
|
|
String token = request.getHeader("TOKEN");
|