|
|
@@ -1281,7 +1281,12 @@ public class ReportController {
|
|
|
if (comTimeType.getReportAuditType() == 3) {
|
|
|
report.setAuditorSetting(auditorSettingList.get(i));
|
|
|
}
|
|
|
- setReportWorkflowAuditor(auditWorkflowList, allDeptList, report,comTimeType);
|
|
|
+ String errorMsg = setReportWorkflowAuditor(auditWorkflowList, allDeptList, report,comTimeType);
|
|
|
+ if (errorMsg != null) {
|
|
|
+ HttpRespMsg msg = new HttpRespMsg();
|
|
|
+ msg.setError(errorMsg);
|
|
|
+ return msg;
|
|
|
+ }
|
|
|
if (taskId != null && taskId[i] != null && taskId[i] != 0) {
|
|
|
report.setTaskId(taskId[i]);
|
|
|
}
|
|
|
@@ -1341,7 +1346,12 @@ public class ReportController {
|
|
|
if (comTimeType.getReportAuditType() == 3) {
|
|
|
report.setAuditorSetting(auditorSettingList.get(i));
|
|
|
}
|
|
|
- setReportWorkflowAuditor(auditWorkflowList, allDeptList, report,comTimeType);
|
|
|
+ String errorMsg = setReportWorkflowAuditor(auditWorkflowList, allDeptList, report,comTimeType);
|
|
|
+ if (errorMsg != null) {
|
|
|
+ HttpRespMsg msg = new HttpRespMsg();
|
|
|
+ msg.setError(errorMsg);
|
|
|
+ return msg;
|
|
|
+ }
|
|
|
if (taskId != null && taskId[i] != null && taskId[i] != 0) {
|
|
|
report.setTaskId(taskId[i]);
|
|
|
}
|
|
|
@@ -1401,7 +1411,12 @@ public class ReportController {
|
|
|
if (comTimeType.getReportAuditType() == 3) {
|
|
|
report.setAuditorSetting(auditorSettingList.get(i));
|
|
|
}
|
|
|
- setReportWorkflowAuditor(auditWorkflowList, allDeptList, report,comTimeType);
|
|
|
+ String errorMsg = setReportWorkflowAuditor(auditWorkflowList, allDeptList, report,comTimeType);
|
|
|
+ if (errorMsg != null) {
|
|
|
+ HttpRespMsg msg = new HttpRespMsg();
|
|
|
+ msg.setError(errorMsg);
|
|
|
+ return msg;
|
|
|
+ }
|
|
|
if (taskId != null && taskId[i] != null && taskId[i] != 0) {
|
|
|
report.setTaskId(taskId[i]);
|
|
|
}
|
|
|
@@ -1472,7 +1487,12 @@ public class ReportController {
|
|
|
} else {
|
|
|
//并非并行审核模式下的代填,需要设置审核状态
|
|
|
report.setState(0);
|
|
|
- setReportWorkflowAuditor(auditWorkflowList, allDeptList, report,comTimeType);
|
|
|
+ String errorMsg = setReportWorkflowAuditor(auditWorkflowList, allDeptList, report,comTimeType);
|
|
|
+ if (errorMsg != null) {
|
|
|
+ HttpRespMsg msg = new HttpRespMsg();
|
|
|
+ msg.setError(errorMsg);
|
|
|
+ return msg;
|
|
|
+ }
|
|
|
}
|
|
|
if (taskId != null && taskId[i] != null && taskId[i] != 0) {
|
|
|
report.setTaskId(taskId[i]);
|
|
|
@@ -1566,15 +1586,16 @@ public class ReportController {
|
|
|
double overTimeSum = reportList.stream().filter(rl -> rl.getCreateDate().equals(report.getCreateDate()) && rl.getCreatorId().equals(report.getCreatorId())).mapToDouble(Report::getOvertimeHours).sum();
|
|
|
UserCorpwxTime userCorpwxTime = userCorpwxTimeMapper.selectOne(new QueryWrapper<UserCorpwxTime>().ne("ot_status", 0).eq("corpwx_userid", curReporter.getCorpwxUserid()).eq("create_date", report.getCreateDate()));
|
|
|
if(overTimeSum > 0){
|
|
|
+ double allowMoreThan = (company.getId() == Constant.XI_HE_CHAO_DAO_COMPANY_ID || company.getId() == Constant.XI_HE_CHAO_DAO_JIA_XING_COMPANY_ID) ? 2.001 : 0.001;//允许超过打卡中的加班时长的范围
|
|
|
if (company.getPackageOvertime() == 1) {//启用了加班管理模块,去校验加班申请的时长
|
|
|
Overtime overtime = overtimeMapper.selectOne(new QueryWrapper<Overtime>().select("sum(duration) as duration").eq("user_id", curReporter.getId()).eq("date", report.getCreateDate()).ne("status", -1).ne("status", 3).ne("status", 4));
|
|
|
if (overtime == null) {
|
|
|
- httpRespMsg.setError("请先补填加班申请单");
|
|
|
+ httpRespMsg.setError("尚无审核通过的加班单");
|
|
|
return httpRespMsg;
|
|
|
} else {
|
|
|
double applyOvertime = 1.0*overtime.getDuration()/3600;//转化为小时
|
|
|
- if (overTimeSum - applyOvertime > 0.001) {
|
|
|
- httpRespMsg.setError("填报加班时长不得超过加班申请时长("+applyOvertime+"h)");
|
|
|
+ if (overTimeSum - applyOvertime > allowMoreThan) {
|
|
|
+ httpRespMsg.setError("填报加班时长不得超过加班申请时长("+applyOvertime+"h)" + (allowMoreThan > 0.001? "+2h" : ""));
|
|
|
return httpRespMsg;
|
|
|
}
|
|
|
}
|
|
|
@@ -1582,9 +1603,11 @@ public class ReportController {
|
|
|
if (userCorpwxTime == null || userCorpwxTime.getOtTime() == 0) {
|
|
|
httpRespMsg.setError("未同步到企微加班时长,请先补填加班申请");
|
|
|
return httpRespMsg;
|
|
|
- } else if (overTimeSum - userCorpwxTime.getOtTime() > 0.001) {
|
|
|
- httpRespMsg.setError("填报加班时长("+overTimeSum+"h)不得超过考勤加班时长("+userCorpwxTime.getOtTime()+"h)");
|
|
|
- return httpRespMsg;
|
|
|
+ } else {
|
|
|
+ if (overTimeSum - userCorpwxTime.getOtTime() > allowMoreThan) {
|
|
|
+ httpRespMsg.setError("填报加班时长("+overTimeSum+"h)不得超过考勤加班时长("+userCorpwxTime.getOtTime()+"h)" + (allowMoreThan > 0.001? "+2h" : ""));
|
|
|
+ return httpRespMsg;
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
@@ -1874,38 +1897,28 @@ public class ReportController {
|
|
|
}
|
|
|
}
|
|
|
//针对羲合超导-合肥,校验加班时长不得超过加班申请单的时长。同理,只要加班申请单有记录就校验。不然不校验。
|
|
|
- if (Constant.XI_HE_CHAO_DAO_COMPANY_ID == company.getId()) {
|
|
|
- //查找当前的填报的加班时长和数据库中的加班时长
|
|
|
- if (overtime > 0) {
|
|
|
- //存在加班时长的情况下,才去校验
|
|
|
- Overtime sumOverTimeApply = overtimeMapper.selectOne(new QueryWrapper<Overtime>().select("sum(duration) duration").eq("date", cDate).eq("user_id", creatorId));
|
|
|
- if (sumOverTimeApply != null) {
|
|
|
- if (sumOverTimeApply.getDuration() != null) {
|
|
|
- if (sumOverTimeApply.getDuration() < overtime*3600) {
|
|
|
- HttpRespMsg httpRespMsg = new HttpRespMsg();
|
|
|
- httpRespMsg.setError("合计加班时长"+overtime+"h不得超过加班申请单的时长"+sumOverTimeApply.getDuration()/3600+"h");
|
|
|
- return httpRespMsg;
|
|
|
- } else {
|
|
|
- //去查找数据库中已经填报的加班时长
|
|
|
- Report oldReportSum = reportMapper.selectOne(new QueryWrapper<Report>().select("sum(overtime_hours) as overTime").eq("create_date", cDate).eq("creator_id", creatorId).gt("overtime_hours", 0));
|
|
|
- if (oldReportSum != null) {
|
|
|
- if (oldReportSum.getOvertimeHours() != null) {
|
|
|
- if ((oldReportSum.getOvertimeHours() + overtime) * 3600 > sumOverTimeApply.getDuration()) {
|
|
|
- HttpRespMsg httpRespMsg = new HttpRespMsg();
|
|
|
- httpRespMsg.setError("合计加班时长"+(oldReportSum.getOvertimeHours() + overtime)+"h不得超过加班申请单的时长"+sumOverTimeApply.getDuration()/3600+"h");
|
|
|
- return httpRespMsg;
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- } else {
|
|
|
- HttpRespMsg httpRespMsg = new HttpRespMsg();
|
|
|
- httpRespMsg.setError(cDate.toString()+"的加班申请单不存在,无法填报加班日报");
|
|
|
- return httpRespMsg;
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
+// if (Constant.XI_HE_CHAO_DAO_COMPANY_ID == company.getId()) {
|
|
|
+// //查找当前的填报的加班时长和数据库中的加班时长
|
|
|
+// if (overtime > 0) {
|
|
|
+// //存在加班时长的情况下,才去校验
|
|
|
+// Overtime sumOverTimeApply = overtimeMapper.selectOne(new QueryWrapper<Overtime>().select("sum(duration) duration").eq("date", cDate).eq("user_id", creatorId));
|
|
|
+// if (sumOverTimeApply != null) {
|
|
|
+// if (sumOverTimeApply.getDuration() != null) {
|
|
|
+// if (sumOverTimeApply.getDuration() < overtime*3600) {
|
|
|
+// HttpRespMsg httpRespMsg = new HttpRespMsg();
|
|
|
+// httpRespMsg.setError("合计加班时长"+overtime+"h不得超过加班申请单的时长"+sumOverTimeApply.getDuration()/3600+"h");
|
|
|
+// return httpRespMsg;
|
|
|
+// } else {
|
|
|
+//
|
|
|
+// }
|
|
|
+// }
|
|
|
+// } else {
|
|
|
+// HttpRespMsg httpRespMsg = new HttpRespMsg();
|
|
|
+// httpRespMsg.setError(cDate.toString()+"的加班申请单不存在,无法填报加班日报");
|
|
|
+// return httpRespMsg;
|
|
|
+// }
|
|
|
+// }
|
|
|
+// }
|
|
|
|
|
|
//HardCode:对于正北两家公司,校验填报工时不得少于考勤时长。(代填的不校验)
|
|
|
if ((SysConstant.ZhengBeiCompIds.contains(company.getId())) && (report.getFillUserid() == null || creatorId.equals(report.getFillUserid()))) {
|
|
|
@@ -2457,6 +2470,12 @@ public class ReportController {
|
|
|
for (Report report : reportList) {
|
|
|
Optional<Project> first = projectList.stream().filter(pl -> pl.getId().equals(report.getProjectId())).findFirst();
|
|
|
if (first.isPresent()) {
|
|
|
+ LocalDate planStartDate = first.get().getPlanStartDate();
|
|
|
+ if (planStartDate != null && planStartDate.isAfter(report.getCreateDate())) {
|
|
|
+ HttpRespMsg msg = new HttpRespMsg();
|
|
|
+ msg.setError("项目["+first.get().getProjectName()+"]于"+dateTimeFormatter.format(planStartDate)+"开始,不得提前填报");
|
|
|
+ return msg;
|
|
|
+ }
|
|
|
LocalDate planEndDate = first.get().getPlanEndDate();
|
|
|
if (planEndDate != null && planEndDate.isBefore(report.getCreateDate())) {
|
|
|
HttpRespMsg msg = new HttpRespMsg();
|
|
|
@@ -2513,9 +2532,8 @@ public class ReportController {
|
|
|
if (companySetAutoApprove) {
|
|
|
List<String> reportIds = reportList.stream().map(Report::getId).map(String::valueOf).collect(Collectors.toList());
|
|
|
//直接修改状态为审核通过
|
|
|
-// reportMapper.update(new Report().setState(1), new LambdaQueryWrapper<Report>().in(Report::getId, reportIds));
|
|
|
String rIds = reportIds.stream().collect(Collectors.joining(","));
|
|
|
- approveReport(rIds, 0, request, null);
|
|
|
+ reportService.autoApproveReport(rIds);
|
|
|
} else if (company.getId() == 862 || company.getId() == 3344 || company.getId() == 936 || comTimeType.getAutoProjectApprove()) {
|
|
|
//项目审核人是提交人的情况,直接审核
|
|
|
List<String> reportIds = new ArrayList<>();
|
|
|
@@ -2790,7 +2808,8 @@ public class ReportController {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- private void setReportWorkflowAuditor(List<AuditWorkflowTimeSetting> auditWorkflowList, List<Department> allDeptList, Report report, TimeType comTimeType) {
|
|
|
+ private String setReportWorkflowAuditor(List<AuditWorkflowTimeSetting> auditWorkflowList, List<Department> allDeptList, Report report, TimeType comTimeType) {
|
|
|
+ String errorMsg = null;
|
|
|
//增加没有开通审批流的判断
|
|
|
if (comTimeType.getReportWorkflow() == 0 || comTimeType.getReportAuditType() > 1 || auditWorkflowList.size() == 0) {
|
|
|
//没有自定义审核流,默认的直接是项目负责人审核
|
|
|
@@ -2824,8 +2843,13 @@ public class ReportController {
|
|
|
} else {
|
|
|
report.setAuditDeptManagerid(curDeptManagerId);
|
|
|
}
|
|
|
+ if (report.getAuditDeptManagerid() == null) {
|
|
|
+ //没有设置好审核人
|
|
|
+ errorMsg = "员工所在部门尚未设置主要负责人";
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
+ return errorMsg;
|
|
|
}
|
|
|
|
|
|
/**
|