|
@@ -1,6 +1,7 @@
|
|
|
package com.management.platform.controller;
|
|
|
|
|
|
|
|
|
+import com.alibaba.fastjson.JSONArray;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.management.platform.entity.Report;
|
|
|
import com.management.platform.entity.User;
|
|
@@ -9,6 +10,7 @@ import com.management.platform.service.ReportService;
|
|
|
import com.management.platform.service.UserSalaryService;
|
|
|
import com.management.platform.service.UserService;
|
|
|
import com.management.platform.util.HttpRespMsg;
|
|
|
+import com.management.platform.util.ListUtil;
|
|
|
import org.apache.log4j.helpers.DateTimeDateFormat;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
@@ -101,34 +103,83 @@ public class ReportController {
|
|
|
String[] createDate,
|
|
|
Integer[] taskId,
|
|
|
Integer[] isOvertime,
|
|
|
- Integer[] progress) {
|
|
|
+ Integer[] progress,
|
|
|
+ String[] targetUids
|
|
|
+ ) {
|
|
|
List<Report> reportList = new ArrayList<>();
|
|
|
String token = request.getHeader("Token");
|
|
|
+ List<String> targetUidList = null;
|
|
|
+ List<User> targetUserList = null;
|
|
|
+ //代填
|
|
|
+ if (targetUids != null && targetUids.length > 0) {
|
|
|
+ String val = targetUids[0];
|
|
|
+ System.out.println("val===="+val);
|
|
|
+ String[] ids = val.split("@");
|
|
|
+ targetUidList = new ArrayList<>();
|
|
|
+ for (int i = 0; i < ids.length; i++) {
|
|
|
+ targetUidList.add(ids[i]);
|
|
|
+ System.out.println("用户ID=="+ids[i]);
|
|
|
+ }
|
|
|
+ targetUserList = userService.list(new QueryWrapper<User>().in("id", targetUidList));
|
|
|
+ }
|
|
|
User user = userService.getById(token);
|
|
|
LocalDate now = LocalDate.now();
|
|
|
DateTimeFormatter dtf = DateTimeFormatter.ofPattern("yyyy-MM-dd");
|
|
|
BigDecimal hourCost = null;
|
|
|
- if (user.getCostApplyDate() != null) {
|
|
|
- //检查有效期
|
|
|
- if (user.getCostApplyDate().compareTo(dtf.format(now)) > 0) {
|
|
|
- //取上一个历史成本
|
|
|
- List<UserSalary> list = userSalaryService.list(new QueryWrapper<UserSalary>().eq("user_id", user.getId()).orderByDesc("indate").last("limit 2"));
|
|
|
- if (list.size() > 1) {
|
|
|
- hourCost = list.get(1).getCost();
|
|
|
+ //自己填写的情况,计算个人自己的时薪
|
|
|
+ if (targetUidList == null) {
|
|
|
+ if (user.getCostApplyDate() != null) {
|
|
|
+ //检查有效期
|
|
|
+ if (user.getCostApplyDate().compareTo(dtf.format(now)) > 0) {
|
|
|
+ //取上一个历史成本
|
|
|
+ List<UserSalary> list = userSalaryService.list(new QueryWrapper<UserSalary>().eq("user_id", user.getId()).orderByDesc("indate").last("limit 2"));
|
|
|
+ if (list.size() > 1) {
|
|
|
+ hourCost = list.get(1).getCost();
|
|
|
+ } else {
|
|
|
+ //没有记录,又没有达到预设的起效时间,则默认为0
|
|
|
+ hourCost = new BigDecimal(0);
|
|
|
+ }
|
|
|
} else {
|
|
|
- //没有记录,又没有达到预设的起效时间,则默认为0
|
|
|
- hourCost = new BigDecimal(0);
|
|
|
+ hourCost = user.getCost();
|
|
|
}
|
|
|
} else {
|
|
|
hourCost = user.getCost();
|
|
|
}
|
|
|
+
|
|
|
+ if (hourCost == null) {
|
|
|
+ hourCost = new BigDecimal(0);
|
|
|
+ }
|
|
|
} else {
|
|
|
- hourCost = user.getCost();
|
|
|
- }
|
|
|
+ //代填的情况,计算每个人的时薪
|
|
|
+ for (User subsUser : targetUserList) {
|
|
|
+ BigDecimal tempCost = new BigDecimal(0);
|
|
|
+ if (subsUser.getCostApplyDate() != null) {
|
|
|
+ //检查有效期
|
|
|
+ if (subsUser.getCostApplyDate().compareTo(dtf.format(now)) > 0) {
|
|
|
+ //取上一个历史成本
|
|
|
+ List<UserSalary> list = userSalaryService.list(new QueryWrapper<UserSalary>().eq("user_id", subsUser.getId()).orderByDesc("indate").last("limit 2"));
|
|
|
+ if (list.size() > 1) {
|
|
|
+ tempCost = list.get(1).getCost();
|
|
|
+ } else {
|
|
|
+ //没有记录,又没有达到预设的起效时间,则默认为0
|
|
|
+ tempCost = new BigDecimal(0);
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ tempCost = subsUser.getCost();
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ tempCost = subsUser.getCost();
|
|
|
+ }
|
|
|
|
|
|
- if (hourCost == null) {
|
|
|
- hourCost = new BigDecimal(0);
|
|
|
+ if (tempCost == null) {
|
|
|
+ tempCost = new BigDecimal(0);
|
|
|
+ }
|
|
|
+ //设置好时薪
|
|
|
+ System.out.println(subsUser.getName()+"的时薪是"+tempCost);
|
|
|
+ subsUser.setCost(tempCost);
|
|
|
+ }
|
|
|
}
|
|
|
+
|
|
|
SimpleDateFormat sdf = new SimpleDateFormat("HH:mm");
|
|
|
|
|
|
try {
|
|
@@ -164,15 +215,172 @@ public class ReportController {
|
|
|
localStartDate = localStartDate.plusDays(daysOffset);
|
|
|
//跳过周末
|
|
|
if (localStartDate.getDayOfWeek() != DayOfWeek.SATURDAY && localStartDate.getDayOfWeek() != DayOfWeek.SUNDAY) {
|
|
|
+ if (targetUserList == null) {
|
|
|
+ Report report = new Report()
|
|
|
+ .setId(id[i] == -1 ? null : id[i])
|
|
|
+ .setProjectId(projectId[i])
|
|
|
+ .setSubProjectId(subProjectId[i] == 0?null:subProjectId[i])
|
|
|
+ .setReportTimeType(reportTimeType[i])
|
|
|
+ .setContent(content[i])
|
|
|
+ .setState(0)
|
|
|
+ .setCreateDate(localStartDate)
|
|
|
+ .setCreatorId(token);
|
|
|
+ if (taskId != null && taskId[i] != null && taskId[i] != 0) {
|
|
|
+ report.setTaskId(taskId[i]);
|
|
|
+ }
|
|
|
+ if (isOvertime != null && isOvertime[i] != null) {
|
|
|
+ report.setIsOvertime(isOvertime[i]);
|
|
|
+ }
|
|
|
+ if (progress != null && progress[i] != null) {
|
|
|
+ report.setProgress(progress[i]);
|
|
|
+ }
|
|
|
+ if (report.getReportTimeType() == 0) {
|
|
|
+ report.setWorkingTime(workingTime[i])
|
|
|
+ .setCost(hourCost.multiply(new BigDecimal(workingTime[i])))
|
|
|
+ .setTimeType(timeType[i]);
|
|
|
+ } else if (report.getReportTimeType() == 1) {
|
|
|
+ report.setWorkingTime(workingTime[i])
|
|
|
+ .setCost(hourCost.multiply(new BigDecimal(workingTime[i])));
|
|
|
+ } else if (report.getReportTimeType() == 2) {
|
|
|
+ //时间范围填报, 计算一下时长
|
|
|
+ try {
|
|
|
+ report.setStartTime(startTime[i]).setEndTime(endTime[i]);
|
|
|
+ long time = sdf.parse(report.getEndTime()).getTime() - sdf.parse(report.getStartTime()).getTime();
|
|
|
+ int minutes = (int)time/1000/60;
|
|
|
+ double hours = minutes*1.0f/60;
|
|
|
+ report.setWorkingTime(hours);
|
|
|
+ report.setCost(hourCost.multiply(new BigDecimal(hours)));
|
|
|
+ } catch (ParseException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ } else if (report.getReportTimeType() == 3) {
|
|
|
+ //计算时长
|
|
|
+ report.setWorkingTime(workingTime[i])
|
|
|
+ .setCost(hourCost.multiply(new BigDecimal(workingTime[i])));
|
|
|
+ }
|
|
|
+ reportList.add(report);
|
|
|
+ } else {
|
|
|
+ //批量代填报的
|
|
|
+ for (User subsUser : targetUserList) {
|
|
|
+ Report report = new Report()
|
|
|
+ .setId(id[i] == -1 ? null : id[i])
|
|
|
+ .setProjectId(projectId[i])
|
|
|
+ .setSubProjectId(subProjectId[i] == 0?null:subProjectId[i])
|
|
|
+ .setReportTimeType(reportTimeType[i])
|
|
|
+ .setContent(content[i])
|
|
|
+ .setState(1)//代填,直接是审核通过状态
|
|
|
+ .setCreateDate(localStartDate)
|
|
|
+ .setCreatorId(subsUser.getId());
|
|
|
+ if (taskId != null && taskId[i] != null && taskId[i] != 0) {
|
|
|
+ report.setTaskId(taskId[i]);
|
|
|
+ }
|
|
|
+ if (isOvertime != null && isOvertime[i] != null) {
|
|
|
+ report.setIsOvertime(isOvertime[i]);
|
|
|
+ }
|
|
|
+ if (progress != null && progress[i] != null) {
|
|
|
+ report.setProgress(progress[i]);
|
|
|
+ }
|
|
|
+ if (report.getReportTimeType() == 0) {
|
|
|
+ report.setWorkingTime(workingTime[i])
|
|
|
+ .setCost(subsUser.getCost().multiply(new BigDecimal(workingTime[i])))
|
|
|
+ .setTimeType(timeType[i]);
|
|
|
+ } else if (report.getReportTimeType() == 1) {
|
|
|
+ report.setWorkingTime(workingTime[i])
|
|
|
+ .setCost(subsUser.getCost().multiply(new BigDecimal(workingTime[i])));
|
|
|
+ } else if (report.getReportTimeType() == 2) {
|
|
|
+ //时间范围填报, 计算一下时长
|
|
|
+ try {
|
|
|
+ report.setStartTime(startTime[i]).setEndTime(endTime[i]);
|
|
|
+ long time = sdf.parse(report.getEndTime()).getTime() - sdf.parse(report.getStartTime()).getTime();
|
|
|
+ int minutes = (int)time/1000/60;
|
|
|
+ double hours = minutes*1.0f/60;
|
|
|
+ report.setWorkingTime(hours);
|
|
|
+ report.setCost(subsUser.getCost().multiply(new BigDecimal(hours)));
|
|
|
+ } catch (ParseException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ } else if (report.getReportTimeType() == 3) {
|
|
|
+ //计算时长
|
|
|
+ report.setWorkingTime(workingTime[i])
|
|
|
+ .setCost(subsUser.getCost().multiply(new BigDecimal(workingTime[i])));
|
|
|
+ }
|
|
|
+ reportList.add(report);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ //结束条件
|
|
|
+ if (localStartDate.isEqual(localEndDate)) {
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ daysOffset = 1;
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ if (targetUidList == null) {
|
|
|
+ Report report = new Report()
|
|
|
+ .setId(id[i] == -1 ? null : id[i])
|
|
|
+ .setProjectId(projectId[i])
|
|
|
+ .setSubProjectId(subProjectId[i] == 0?null:subProjectId[i])
|
|
|
+ .setReportTimeType(reportTimeType[i])
|
|
|
+ .setContent(content[i])
|
|
|
+ .setState(0)
|
|
|
+ .setCreateDate(LocalDate.parse(createDate[i], DateTimeFormatter.ofPattern("yyyy-MM-dd")))
|
|
|
+ .setCreatorId(token);
|
|
|
+ if (taskId != null && taskId[i] != null && taskId[i] != 0) {
|
|
|
+ report.setTaskId(taskId[i]);
|
|
|
+ }
|
|
|
+ if (isOvertime != null && isOvertime[i] != null) {
|
|
|
+ report.setIsOvertime(isOvertime[i]);
|
|
|
+ }
|
|
|
+ if (progress != null && progress[i] != null) {
|
|
|
+ report.setProgress(progress[i]);
|
|
|
+ }
|
|
|
+ if (report.getReportTimeType() == 0) {
|
|
|
+ report.setWorkingTime(workingTime[i])
|
|
|
+ .setCost(hourCost.multiply(new BigDecimal(workingTime[i])))
|
|
|
+ .setTimeType(timeType[i]);
|
|
|
+ } else if (report.getReportTimeType() == 1) {
|
|
|
+ report.setWorkingTime(workingTime[i])
|
|
|
+ .setCost(hourCost.multiply(new BigDecimal(workingTime[i])));
|
|
|
+ } else if (report.getReportTimeType() == 2) {
|
|
|
+ //时间范围填报, 计算一下时长
|
|
|
+ try {
|
|
|
+ report.setStartTime(startTime[i]).setEndTime(endTime[i]);
|
|
|
+ long time = sdf.parse(report.getEndTime()).getTime() - sdf.parse(report.getStartTime()).getTime();
|
|
|
+ int minutes = (int)time/1000/60;
|
|
|
+ double hours = minutes*1.0f/60;
|
|
|
+ report.setWorkingTime(hours);
|
|
|
+ report.setCost(hourCost.multiply(new BigDecimal(hours)));
|
|
|
+ } catch (ParseException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ } else if (report.getReportTimeType() == 3) {
|
|
|
+ //计算时长
|
|
|
+ report.setWorkingTime(workingTime[i])
|
|
|
+ .setCost(hourCost.multiply(new BigDecimal(workingTime[i])));
|
|
|
+ }
|
|
|
+ reportList.add(report);
|
|
|
+ /*后续需要加入状态*/
|
|
|
+ if (createDate[i] == null || projectId[i] == null) {
|
|
|
+ HttpRespMsg httpRespMsg = new HttpRespMsg();
|
|
|
+ httpRespMsg.setError("缺少数据");
|
|
|
+ return httpRespMsg;
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ //批量代填的情况
|
|
|
+ for (User subsUser : targetUserList) {
|
|
|
+ System.out.println("生成日报FOR=="+subsUser.getName()+", "+subsUser.getCost().toString());
|
|
|
Report report = new Report()
|
|
|
.setId(id[i] == -1 ? null : id[i])
|
|
|
.setProjectId(projectId[i])
|
|
|
.setSubProjectId(subProjectId[i] == 0?null:subProjectId[i])
|
|
|
.setReportTimeType(reportTimeType[i])
|
|
|
.setContent(content[i])
|
|
|
- .setState(0)
|
|
|
- .setCreateDate(localStartDate)
|
|
|
- .setCreatorId(token);
|
|
|
+ .setState(1)//代填的就直接审核通过了
|
|
|
+ .setCreateDate(LocalDate.parse(createDate[i], DateTimeFormatter.ofPattern("yyyy-MM-dd")))
|
|
|
+ .setCreatorId(subsUser.getId());
|
|
|
if (taskId != null && taskId[i] != null && taskId[i] != 0) {
|
|
|
report.setTaskId(taskId[i]);
|
|
|
}
|
|
@@ -184,11 +392,11 @@ public class ReportController {
|
|
|
}
|
|
|
if (report.getReportTimeType() == 0) {
|
|
|
report.setWorkingTime(workingTime[i])
|
|
|
- .setCost(hourCost.multiply(new BigDecimal(workingTime[i])))
|
|
|
+ .setCost(subsUser.getCost().multiply(new BigDecimal(workingTime[i])))
|
|
|
.setTimeType(timeType[i]);
|
|
|
} else if (report.getReportTimeType() == 1) {
|
|
|
report.setWorkingTime(workingTime[i])
|
|
|
- .setCost(hourCost.multiply(new BigDecimal(workingTime[i])));
|
|
|
+ .setCost(subsUser.getCost().multiply(new BigDecimal(workingTime[i])));
|
|
|
} else if (report.getReportTimeType() == 2) {
|
|
|
//时间范围填报, 计算一下时长
|
|
|
try {
|
|
@@ -197,74 +405,25 @@ public class ReportController {
|
|
|
int minutes = (int)time/1000/60;
|
|
|
double hours = minutes*1.0f/60;
|
|
|
report.setWorkingTime(hours);
|
|
|
- report.setCost(hourCost.multiply(new BigDecimal(hours)));
|
|
|
+ report.setCost(subsUser.getCost().multiply(new BigDecimal(hours)));
|
|
|
} catch (ParseException e) {
|
|
|
e.printStackTrace();
|
|
|
}
|
|
|
} else if (report.getReportTimeType() == 3) {
|
|
|
//计算时长
|
|
|
report.setWorkingTime(workingTime[i])
|
|
|
- .setCost(hourCost.multiply(new BigDecimal(workingTime[i])));
|
|
|
+ .setCost(subsUser.getCost().multiply(new BigDecimal(workingTime[i])));
|
|
|
}
|
|
|
reportList.add(report);
|
|
|
+ /*后续需要加入状态*/
|
|
|
+ if (createDate[i] == null || projectId[i] == null) {
|
|
|
+ HttpRespMsg httpRespMsg = new HttpRespMsg();
|
|
|
+ httpRespMsg.setError("缺少数据");
|
|
|
+ return httpRespMsg;
|
|
|
+ }
|
|
|
}
|
|
|
-
|
|
|
- //结束条件
|
|
|
- if (localStartDate.isEqual(localEndDate)) {
|
|
|
- break;
|
|
|
- }
|
|
|
- daysOffset = 1;
|
|
|
- }
|
|
|
- } else {
|
|
|
- Report report = new Report()
|
|
|
- .setId(id[i] == -1 ? null : id[i])
|
|
|
- .setProjectId(projectId[i])
|
|
|
- .setSubProjectId(subProjectId[i] == 0?null:subProjectId[i])
|
|
|
- .setReportTimeType(reportTimeType[i])
|
|
|
- .setContent(content[i])
|
|
|
- .setState(0)
|
|
|
- .setCreateDate(LocalDate.parse(createDate[i], DateTimeFormatter.ofPattern("yyyy-MM-dd")))
|
|
|
- .setCreatorId(token);
|
|
|
- if (taskId != null && taskId[i] != null && taskId[i] != 0) {
|
|
|
- report.setTaskId(taskId[i]);
|
|
|
- }
|
|
|
- if (isOvertime != null && isOvertime[i] != null) {
|
|
|
- report.setIsOvertime(isOvertime[i]);
|
|
|
- }
|
|
|
- if (progress != null && progress[i] != null) {
|
|
|
- report.setProgress(progress[i]);
|
|
|
- }
|
|
|
- if (report.getReportTimeType() == 0) {
|
|
|
- report.setWorkingTime(workingTime[i])
|
|
|
- .setCost(hourCost.multiply(new BigDecimal(workingTime[i])))
|
|
|
- .setTimeType(timeType[i]);
|
|
|
- } else if (report.getReportTimeType() == 1) {
|
|
|
- report.setWorkingTime(workingTime[i])
|
|
|
- .setCost(hourCost.multiply(new BigDecimal(workingTime[i])));
|
|
|
- } else if (report.getReportTimeType() == 2) {
|
|
|
- //时间范围填报, 计算一下时长
|
|
|
- try {
|
|
|
- report.setStartTime(startTime[i]).setEndTime(endTime[i]);
|
|
|
- long time = sdf.parse(report.getEndTime()).getTime() - sdf.parse(report.getStartTime()).getTime();
|
|
|
- int minutes = (int)time/1000/60;
|
|
|
- double hours = minutes*1.0f/60;
|
|
|
- report.setWorkingTime(hours);
|
|
|
- report.setCost(hourCost.multiply(new BigDecimal(hours)));
|
|
|
- } catch (ParseException e) {
|
|
|
- e.printStackTrace();
|
|
|
- }
|
|
|
- } else if (report.getReportTimeType() == 3) {
|
|
|
- //计算时长
|
|
|
- report.setWorkingTime(workingTime[i])
|
|
|
- .setCost(hourCost.multiply(new BigDecimal(workingTime[i])));
|
|
|
- }
|
|
|
- reportList.add(report);
|
|
|
- /*后续需要加入状态*/
|
|
|
- if (createDate[i] == null || projectId[i] == null) {
|
|
|
- HttpRespMsg httpRespMsg = new HttpRespMsg();
|
|
|
- httpRespMsg.setError("缺少数据");
|
|
|
- return httpRespMsg;
|
|
|
}
|
|
|
+
|
|
|
}
|
|
|
}
|
|
|
} catch (NullPointerException e) {
|
|
@@ -273,7 +432,7 @@ public class ReportController {
|
|
|
httpRespMsg.setError("验证失败");
|
|
|
return httpRespMsg;
|
|
|
}
|
|
|
- return reportService.editReport(reportList, createDate.length > 0 ? createDate[0] : null);
|
|
|
+ return reportService.editReport(reportList, createDate.length > 0 ? createDate[0] : null, targetUserList, hourCost);
|
|
|
}
|
|
|
|
|
|
/**
|