|
@@ -33,12 +33,14 @@ import java.math.BigDecimal;
|
|
|
import java.math.RoundingMode;
|
|
|
import java.text.DecimalFormat;
|
|
|
import java.text.SimpleDateFormat;
|
|
|
+import java.time.Duration;
|
|
|
import java.time.LocalDate;
|
|
|
import java.time.LocalDateTime;
|
|
|
import java.time.format.DateTimeFormatter;
|
|
|
import java.time.format.DateTimeParseException;
|
|
|
import java.time.temporal.ChronoUnit;
|
|
|
import java.util.*;
|
|
|
+import java.util.concurrent.CopyOnWriteArrayList;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
@@ -627,6 +629,8 @@ public class ReportServiceImpl extends ServiceImpl<ReportMapper, Report> impleme
|
|
|
//新增或编辑报告
|
|
|
@Override
|
|
|
public HttpRespMsg editReport(List<Report> reportList, String date, List<User> userList, BigDecimal hourCost, Integer companyId) {
|
|
|
+ System.out.println("传过来的数据"+reportList.toString()+"=========="+reportList.size()+"===="+reportList.get(0));
|
|
|
+ System.out.println(date);
|
|
|
HttpRespMsg httpRespMsg = new HttpRespMsg();
|
|
|
TimeType timeType = timeTypeMapper.selectById(companyId);
|
|
|
//删除不在本次更新名单中的老记录
|
|
@@ -2016,19 +2020,44 @@ public class ReportServiceImpl extends ServiceImpl<ReportMapper, Report> impleme
|
|
|
List<UserDailyWorkItem> noReportDataList = new ArrayList<UserDailyWorkItem>();
|
|
|
//准备部门数据
|
|
|
List<Department> departmentList = departmentMapper.selectList(new QueryWrapper<Department>().eq("company_id", companyId));
|
|
|
-
|
|
|
+ //获取所有同步的企业微信数据
|
|
|
+ LocalDateTime a=LocalDateTime.now();
|
|
|
+ List<Map> userCorpwxTimeMapList = userCorpwxTimeMapper.selectByAsk(companyId,startDate,endDate);
|
|
|
+ LocalDateTime b=LocalDateTime.now();
|
|
|
+ long l = Duration.between(a, b).toMillis();
|
|
|
+ System.out.println("查询耗时======================"+l+"毫秒");
|
|
|
String lastUserId = null;
|
|
|
UserMonthWork lastUserData = null;
|
|
|
List<String> fillReportUserIds = new ArrayList<>();
|
|
|
+ SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
+ System.out.println("初始数据========="+userCorpwxTimeMapList.toString()+"=========size"+userCorpwxTimeMapList.size());
|
|
|
+ final CopyOnWriteArrayList<Map> cowList = new CopyOnWriteArrayList<Map>(userCorpwxTimeMapList);
|
|
|
for (Map<String, Object> data : list) {
|
|
|
String id = (String)data.get("id");
|
|
|
String name = (String)data.get("name");
|
|
|
String departmentName = (String) data.get("departmentName");
|
|
|
Map<String, Object> map = new HashMap<>();
|
|
|
String date = new SimpleDateFormat("yyyy-MM-dd").format((Date)data.get("createDate"));
|
|
|
-
|
|
|
+ String corpwxUserid = (String) data.get("corpwxUserId");
|
|
|
+ List<Map> userCorpwxListOn = userCorpwxTimeMapList.stream().filter(mapList -> mapList.get("create_date").toString().equals(data.get("createDate").toString())
|
|
|
+ && mapList.get("corpwx_userid").equals(corpwxUserid)).collect(Collectors.toList());
|
|
|
+ if(!userCorpwxListOn.isEmpty()){
|
|
|
+ Map mapCheck=userCorpwxListOn.get(0);
|
|
|
+ for (Map item : cowList) {
|
|
|
+ if (item.get("corpwx_userid").equals(mapCheck.get("corpwx_userid"))&&item.get("create_date").toString().equals(mapCheck.get("create_date").toString())) {
|
|
|
+ cowList.remove(item);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(!userCorpwxListOn.isEmpty()){
|
|
|
+ userCorpwxTimeMapList.remove(userCorpwxListOn.get(0));
|
|
|
+ }
|
|
|
+ if(!userCorpwxListOn.isEmpty()&&(double) data.get("workingTime")==0){
|
|
|
+ map.put("workingTime", "请假");
|
|
|
+ }else{
|
|
|
+ map.put("workingTime", data.get("workingTime"));
|
|
|
+ }
|
|
|
map.put("createDate", date);
|
|
|
- map.put("workingTime", data.get("workingTime"));
|
|
|
if (id.equals(lastUserId)) {
|
|
|
//同一个用户的数据
|
|
|
lastUserData.worktimeList.add(map);
|
|
@@ -2038,12 +2067,28 @@ public class ReportServiceImpl extends ServiceImpl<ReportMapper, Report> impleme
|
|
|
lastUserData.userId = id;
|
|
|
lastUserData.name = name;
|
|
|
lastUserData.departmentName = departmentName;
|
|
|
+ lastUserData.corpwxUserId=corpwxUserid;
|
|
|
lastUserData.worktimeList = new ArrayList<>();
|
|
|
lastUserData.worktimeList.add(map);
|
|
|
userMonthWorks.add(lastUserData);
|
|
|
}
|
|
|
lastUserId = id;
|
|
|
}
|
|
|
+ System.out.println("结束数据=========="+userCorpwxTimeMapList.toString()+"=========size"+userCorpwxTimeMapList.size());
|
|
|
+ for(UserMonthWork userMonthWork:userMonthWorks){
|
|
|
+ for(Map map:userCorpwxTimeMapList){
|
|
|
+ if(userMonthWork.corpwxUserId.equals(map.get("corpwx_userid"))){
|
|
|
+ Map mapIt=new HashMap();
|
|
|
+ mapIt.put("workingTime", "请假");
|
|
|
+ String date = new SimpleDateFormat("yyyy-MM-dd").format((Date)map.get("create_date"));
|
|
|
+ mapIt.put("createDate", date);
|
|
|
+ userMonthWork.worktimeList.add(mapIt);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ LocalDateTime c=LocalDateTime.now();
|
|
|
+ long l1 = Duration.between(b, c).toMillis();
|
|
|
+ System.out.println("数据处理耗时==========="+l1+"毫秒");
|
|
|
//计算未填的人员
|
|
|
List<User> noReportUserList = allRangeUserList.stream()
|
|
|
.filter(au->!userMonthWorks.stream().anyMatch(mon->mon.userId.equals(au.getId())))
|
|
@@ -2843,6 +2888,8 @@ public class ReportServiceImpl extends ServiceImpl<ReportMapper, Report> impleme
|
|
|
List<UserDailyWorkItem> noReportDataList = new ArrayList<UserDailyWorkItem>();
|
|
|
//准备部门数据
|
|
|
List<Department> departmentList = departmentMapper.selectList(new QueryWrapper<Department>().eq("company_id", companyId));
|
|
|
+ //获取企业微信同步数据
|
|
|
+ List<Map> userCorpwxTimeMapList = userCorpwxTimeMapper.selectByAsk(companyId,startDate,endDate);
|
|
|
String lastUserId = null;
|
|
|
UserMonthWork lastUserData = null;
|
|
|
DateTimeFormatter dtf = DateTimeFormatter.ofPattern("yyyy-MM-dd");
|
|
@@ -2866,7 +2913,14 @@ public class ReportServiceImpl extends ServiceImpl<ReportMapper, Report> impleme
|
|
|
if (!list.stream().anyMatch(item->item.get("id").equals(curUser.getId())&&sdf.format((java.sql.Date)item.get("createDate")).equals(dateStr))) {
|
|
|
UserDailyWorkItem noRecord = new UserDailyWorkItem();
|
|
|
noRecord.userId = curUser.getId();
|
|
|
- noRecord.createDate = dtf.format(date);
|
|
|
+ List<Map> userCorpwxListOn = userCorpwxTimeMapList.stream().filter(mapList -> mapList.get("create_date").toString().equals(dateStr)
|
|
|
+ && mapList.get("corpwx_userid").equals(curUser.getCorpwxUserid())).collect(Collectors.toList());
|
|
|
+ if(!userCorpwxListOn.isEmpty()){
|
|
|
+ noRecord.createDate = dtf.format(date)+"/请假";
|
|
|
+ }else{
|
|
|
+ noRecord.createDate = dtf.format(date);
|
|
|
+ }
|
|
|
+
|
|
|
if (curUser.getDepartmentId() != null && curUser.getDepartmentId() != 0) {
|
|
|
noRecord.department = departmentList.stream().filter(d->d.getDepartmentId().equals(curUser.getDepartmentId())).findFirst().get().getDepartmentName();
|
|
|
} else {
|