|
@@ -783,6 +783,7 @@ public class ReportController {
|
|
|
LocalDate cDate = report.getCreateDate();
|
|
|
//查找同一个人同一天的日报合计工作时长
|
|
|
double dailyWorktime = reportList.stream().filter(r->r.getCreatorId().equals(creatorId) && r.getCreateDate().isEqual(cDate)).mapToDouble(Report::getWorkingTime).sum();
|
|
|
+
|
|
|
if (dailyWorktime > comTimeType.getAllday()) {
|
|
|
HttpRespMsg httpRespMsg = new HttpRespMsg();
|
|
|
httpRespMsg.setError("每日工作时长不得超过"+comTimeType.getAllday()+"小时");
|
|
@@ -790,6 +791,45 @@ public class ReportController {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+ //校验填报工时
|
|
|
+ List<Report> checkedUserDayList = new ArrayList<>();
|
|
|
+ for (Report report : reportList) {
|
|
|
+ String creatorId = report.getCreatorId();
|
|
|
+ LocalDate cDate = report.getCreateDate();
|
|
|
+ if (checkedUserDayList.stream().anyMatch(item->item.getCreatorId().equals(creatorId) && item.getCreateDate().isEqual(cDate))) {
|
|
|
+ //避免重复校验
|
|
|
+ continue;
|
|
|
+ } else {
|
|
|
+ //加入
|
|
|
+ checkedUserDayList.add(report);
|
|
|
+ }
|
|
|
+ //查找同一个人同一天的日报合计工作时长
|
|
|
+ double dailyWorktime = reportList.stream().filter(r->r.getCreatorId().equals(creatorId) && r.getCreateDate().isEqual(cDate)).mapToDouble(Report::getWorkingTime).sum();
|
|
|
+ //数据库中已经填报过的工时
|
|
|
+ if (dailyWorktime > comTimeType.getMaxReportTime()) {
|
|
|
+ HttpRespMsg httpRespMsg = new HttpRespMsg();
|
|
|
+ httpRespMsg.setError("每日工作时长不得超过"+comTimeType.getMaxReportTime()+"小时");
|
|
|
+ return httpRespMsg;
|
|
|
+ } else {
|
|
|
+ //查找数据库中可能已有老的记录
|
|
|
+ List<Report> oldList = reportMapper.selectList(new QueryWrapper<Report>().select("id, state, working_time").eq("create_date", cDate).eq("creator_id", creatorId));
|
|
|
+ //老的记录需要合并计算不在本次reportList中,并且状态是0(待审核)或者1(已通过)的
|
|
|
+ //按周填报都可能会有已存在日报的情况,前端没有传过来
|
|
|
+ double existingWorktime = oldList.stream().filter(old->!reportList.stream().anyMatch(newItem->old.getId().equals(newItem.getId()))
|
|
|
+ && (old.getState() == 0 || old.getState() == 1)).mapToDouble(Report::getWorkingTime).sum();
|
|
|
+ if (existingWorktime > 0) {
|
|
|
+ dailyWorktime += existingWorktime;
|
|
|
+ if (dailyWorktime > comTimeType.getMaxReportTime()) {
|
|
|
+ HttpRespMsg httpRespMsg = new HttpRespMsg();
|
|
|
+ httpRespMsg.setError("每日工作时长不得超过"+comTimeType.getMaxReportTime()+"小时");
|
|
|
+ return httpRespMsg;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
|
|
|
//只有项目管理专业版才要检查成本预算
|
|
|
if (company.getPackageProject() == 1) {
|