|
|
@@ -1564,75 +1564,71 @@ public class ReportController {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- if (!abnormalTime) {//非异常填报,需要校验加班时长
|
|
|
- //校验工作时长
|
|
|
- for (Report report : reportList) {
|
|
|
- if (report.getIsOvertime() != null && report.getIsOvertime() == 1) {
|
|
|
- if (report.getOvertimeHours() <= 0) {
|
|
|
- HttpRespMsg httpRespMsg = new HttpRespMsg();
|
|
|
- //httpRespMsg.setError("加班时长必须大于0");
|
|
|
- httpRespMsg.setError(MessageUtils.message("profession.workDurationError"));
|
|
|
- return httpRespMsg;
|
|
|
- } else if ((report.getOvertimeHours() - report.getWorkingTime() > 0.1)) {
|
|
|
+ //校验工作时长
|
|
|
+ for (Report report : reportList) {
|
|
|
+ if (report.getIsOvertime() != null && report.getIsOvertime() == 1) {
|
|
|
+ if (report.getOvertimeHours() <= 0) {
|
|
|
+ HttpRespMsg httpRespMsg = new HttpRespMsg();
|
|
|
+ //httpRespMsg.setError("加班时长必须大于0");
|
|
|
+ httpRespMsg.setError(MessageUtils.message("profession.workDurationError"));
|
|
|
+ return httpRespMsg;
|
|
|
+ } else if ((report.getOvertimeHours() - report.getWorkingTime() > 0.1)) {
|
|
|
+ HttpRespMsg httpRespMsg = new HttpRespMsg();
|
|
|
+ DecimalFormat decimalFormat = new DecimalFormat("0.0");
|
|
|
+ decimalFormat.setRoundingMode(RoundingMode.HALF_UP);
|
|
|
+ //httpRespMsg.setError("加班时长("+report.getOvertimeHours()+"h)不能超过工作时长("+report.getWorkingTime()+"h)");
|
|
|
+ httpRespMsg.setError(MessageUtils.message("profession.OvertimeHoursError",decimalFormat.format(report.getOvertimeHours()),
|
|
|
+ decimalFormat.format(report.getWorkingTime())));
|
|
|
+ return httpRespMsg;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //如果开启了加班时长校验
|
|
|
+ if(comTimeType.getFillOvertime()==1){
|
|
|
+ if (comTimeType.getWorkOvertimeNeedCheck()==1) {
|
|
|
+ for (Report report : reportList) {
|
|
|
+ if(WorkDayCalculateUtils.isWorkDay(report.getCreateDate())){
|
|
|
HttpRespMsg httpRespMsg = new HttpRespMsg();
|
|
|
- DecimalFormat decimalFormat = new DecimalFormat("0.0");
|
|
|
- decimalFormat.setRoundingMode(RoundingMode.HALF_UP);
|
|
|
- //httpRespMsg.setError("加班时长("+report.getOvertimeHours()+"h)不能超过工作时长("+report.getWorkingTime()+"h)");
|
|
|
- httpRespMsg.setError(MessageUtils.message("profession.OvertimeHoursError",decimalFormat.format(report.getOvertimeHours()),
|
|
|
- decimalFormat.format(report.getWorkingTime())));
|
|
|
- return httpRespMsg;
|
|
|
+ double sum = reportList.stream().filter(rl -> rl.getCreateDate().equals(report.getCreateDate()) && rl.getCreatorId().equals(report.getCreatorId())).mapToDouble(Report::getWorkingTime).sum();
|
|
|
+ BigDecimal bigDecimal = new BigDecimal(sum);
|
|
|
+ bigDecimal=bigDecimal.subtract(new BigDecimal(comTimeType.getAllday()));
|
|
|
+ if(report.getOvertimeHours() != null && report.getOvertimeHours()>0 && report.getOvertimeHours()-bigDecimal.doubleValue() > 0.001){
|
|
|
+ httpRespMsg.setError("加班时长不得超过总工作时长("+sum+"h)-正常工作时长"+(comTimeType.getAllday())+"h");
|
|
|
+ return httpRespMsg;
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- //如果开启了加班时长校验
|
|
|
- if(comTimeType.getFillOvertime()==1){
|
|
|
- if (comTimeType.getWorkOvertimeNeedCheck()==1) {
|
|
|
- for (Report report : reportList) {
|
|
|
- if(WorkDayCalculateUtils.isWorkDay(report.getCreateDate())){
|
|
|
- HttpRespMsg httpRespMsg = new HttpRespMsg();
|
|
|
- double sum = reportList.stream().filter(rl -> rl.getCreateDate().equals(report.getCreateDate()) && rl.getCreatorId().equals(report.getCreatorId())).mapToDouble(Report::getWorkingTime).sum();
|
|
|
- BigDecimal bigDecimal = new BigDecimal(sum);
|
|
|
- bigDecimal=bigDecimal.subtract(new BigDecimal(comTimeType.getAllday()));
|
|
|
- if(report.getOvertimeHours() != null && report.getOvertimeHours()>0 && report.getOvertimeHours()-bigDecimal.doubleValue() > 0.001){
|
|
|
- httpRespMsg.setError("加班时长不得超过总工作时长("+sum+"h)-正常工作时长"+(comTimeType.getAllday())+"h");
|
|
|
+ //校验加班时长是否超过打卡中的加班时长
|
|
|
+ if (draft == 0 && comTimeType.getVerifyCardOvertime() == 1) {//包括周末也要提交加班申请单才行
|
|
|
+ User curReporter = userMapper.selectById(reportList.get(0).getCreatorId());
|
|
|
+ for (Report report : reportList) {
|
|
|
+ HttpRespMsg httpRespMsg = new HttpRespMsg();
|
|
|
+ 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()).eq("status", 2));
|
|
|
+ if (overtime == null) {
|
|
|
+ httpRespMsg.setError("尚无审核通过的加班单");
|
|
|
return httpRespMsg;
|
|
|
+ } else {
|
|
|
+ System.out.println("加班申请时长=="+overtime.getDuration());
|
|
|
+ double applyOvertime = 1.0*overtime.getDuration()/3600;//转化为小时
|
|
|
+ if (overTimeSum - applyOvertime > allowMoreThan) {
|
|
|
+ httpRespMsg.setError("填报加班时长不得超过加班申请时长("+applyOvertime+"h)" + (allowMoreThan > 0.001? "+2h" : ""));
|
|
|
+ return httpRespMsg;
|
|
|
+ }
|
|
|
}
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- //校验加班时长是否超过打卡中的加班时长
|
|
|
- if (draft == 0 && comTimeType.getVerifyCardOvertime() == 1) {
|
|
|
- User curReporter = userMapper.selectById(reportList.get(0).getCreatorId());
|
|
|
- for (Report report : reportList) {
|
|
|
- if(WorkDayCalculateUtils.isWorkDay(report.getCreateDate())){
|
|
|
- HttpRespMsg httpRespMsg = new HttpRespMsg();
|
|
|
- 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("尚无审核通过的加班单");
|
|
|
- return httpRespMsg;
|
|
|
- } else {
|
|
|
- System.out.println("加班申请时长=="+overtime.getDuration());
|
|
|
- double applyOvertime = 1.0*overtime.getDuration()/3600;//转化为小时
|
|
|
- if (overTimeSum - applyOvertime > allowMoreThan) {
|
|
|
- httpRespMsg.setError("填报加班时长不得超过加班申请时长("+applyOvertime+"h)" + (allowMoreThan > 0.001? "+2h" : ""));
|
|
|
- return httpRespMsg;
|
|
|
- }
|
|
|
- }
|
|
|
- } else {
|
|
|
- if (userCorpwxTime == null || userCorpwxTime.getOtTime() == 0) {
|
|
|
- httpRespMsg.setError("未同步到企微加班时长,请先补填加班申请");
|
|
|
- return httpRespMsg;
|
|
|
- } else {
|
|
|
- if (overTimeSum - userCorpwxTime.getOtTime() > allowMoreThan) {
|
|
|
- httpRespMsg.setError("填报加班时长("+overTimeSum+"h)不得超过考勤加班时长("+userCorpwxTime.getOtTime()+"h)" + (allowMoreThan > 0.001? "+2h" : ""));
|
|
|
- return httpRespMsg;
|
|
|
- }
|
|
|
- }
|
|
|
+ } else {
|
|
|
+ if (userCorpwxTime == null || userCorpwxTime.getOtTime() == 0) {
|
|
|
+ httpRespMsg.setError("未同步到企微加班时长,请先补填加班申请");
|
|
|
+ return httpRespMsg;
|
|
|
+ } else {
|
|
|
+ if (overTimeSum - userCorpwxTime.getOtTime() > allowMoreThan) {
|
|
|
+ httpRespMsg.setError("填报加班时长("+overTimeSum+"h)不得超过考勤加班时长("+userCorpwxTime.getOtTime()+"h)" + (allowMoreThan > 0.001? "+2h" : ""));
|
|
|
+ return httpRespMsg;
|
|
|
}
|
|
|
}
|
|
|
}
|