|
|
@@ -127,6 +127,8 @@ public class WxCorpInfoServiceImpl extends ServiceImpl<WxCorpInfoMapper, WxCorpI
|
|
|
public static final int TEXT_CARD_MSG_PROJECT_REJECTED = 31;
|
|
|
public static final int TEXT_CARD_MSG_PROJECT_APPROVED = 32;
|
|
|
public static final int TEXT_CARD_MSG_MEMB_MISS_REPORT = 33;
|
|
|
+ public static final int TEXT_CARD_MSG_OVERTIME_APPLY = 34;//加班申请待审核消息
|
|
|
+ public static final int TEXT_CARD_MSG_OVERTIME_DENY = 35;//加班申请待审核消息
|
|
|
private static Object userLock = new Object();
|
|
|
|
|
|
@Value("${suitId}")
|
|
|
@@ -167,6 +169,8 @@ public class WxCorpInfoServiceImpl extends ServiceImpl<WxCorpInfoMapper, WxCorpI
|
|
|
SysConfigMapper sysConfigMapper;
|
|
|
@Resource
|
|
|
TimeTypeService timeTypeService;
|
|
|
+ @Resource
|
|
|
+ private ReportMapper reportMapper;
|
|
|
|
|
|
@Resource
|
|
|
UserMapper userMapper;
|
|
|
@@ -390,6 +394,10 @@ public class WxCorpInfoServiceImpl extends ServiceImpl<WxCorpInfoMapper, WxCorpI
|
|
|
title = "日报提交提醒";
|
|
|
} else if (msgType.equals(TEXT_CARD_MSG_MEMB_MISS_REPORT)) {
|
|
|
title = "员工漏填提醒";
|
|
|
+ } else if (msgType.equals(TEXT_CARD_MSG_OVERTIME_APPLY)) {
|
|
|
+ title = "加班申请审核提醒";
|
|
|
+ } else if (msgType.equals(TEXT_CARD_MSG_OVERTIME_DENY)) {
|
|
|
+ title = "加班申请驳回提醒";
|
|
|
}
|
|
|
} else {
|
|
|
jumpUrl = jumpUrl.replace("STATE", pageRouter);
|
|
|
@@ -1200,14 +1208,37 @@ public class WxCorpInfoServiceImpl extends ServiceImpl<WxCorpInfoMapper, WxCorpI
|
|
|
}
|
|
|
//处理曦合超导的加班补贴
|
|
|
if (corpInfo.getCompanyId() == Constant.XI_HE_CHAO_DAO_COMPANY_ID || corpInfo.getCompanyId() == Constant.XI_HE_CHAO_DAO_JIA_XING_COMPANY_ID || corpInfo.getCompanyId() == 8128) {
|
|
|
- handleAllowance(userCorpwxTime, baseMorningStart, baseMorningEnd, baseAfternoonStart, baseAfternoonEnd, restTime);
|
|
|
+// handleAllowance(userCorpwxTime, baseMorningStart, baseMorningEnd, baseAfternoonStart, baseAfternoonEnd, restTime);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- private void handleAllowance(UserCorpwxTime userCorpwxTime, String baseMorningStart, String baseMorningEnd, String baseAfternoonStart, String baseAfternoonEnd, double restTime) {
|
|
|
+ @Async
|
|
|
+ public void handleUserAllowanceByReport(List<Report> reportList) {
|
|
|
+ //从reportList中按照createDate和creatorId进行分组,去重,得到一个新的reportList, 里面的createDate和creatorId组合都是唯一的
|
|
|
+ List<Report> distinctReportList = new ArrayList<>();
|
|
|
+ for (Report report : reportList) {
|
|
|
+ if (!distinctReportList.stream().anyMatch(r -> r.getCreatorId().equals(report.getCreatorId()) && r.getCreateDate().equals(report.getCreateDate()))) {
|
|
|
+ distinctReportList.add(report);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ for (Report item : distinctReportList) {
|
|
|
+ String userId = item.getCreatorId();
|
|
|
+ LocalDate date = item.getCreateDate();
|
|
|
+ //查询日报的合计加班时长
|
|
|
+ Report report = reportMapper.selectOne(new QueryWrapper<Report>().select("sum(overtime_hours) as overtime_hours").eq("creator_id", userId).eq("create_date", date));
|
|
|
+ double reportOvertime = report == null ? 0 : report.getOvertimeHours();
|
|
|
+ User user = userMapper.selectById(userId);
|
|
|
+ UserCorpwxTime userCorpwxTime = userCorpwxTimeMapper.selectOne(new QueryWrapper<UserCorpwxTime>().eq("corpwx_userid", user.getCorpwxUserid()).eq("create_date", date));
|
|
|
+ if (userCorpwxTime != null) {
|
|
|
+ handleAllowance(userCorpwxTime, "08:00", "12:00", "13:00", "17:00", 1.0, reportOvertime);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private void handleAllowance(UserCorpwxTime userCorpwxTime, String baseMorningStart, String baseMorningEnd, String baseAfternoonStart, String baseAfternoonEnd, double restTime, double reportOvertime) {
|
|
|
//注意,为了方便开发,对于表overtime-allowance的type类型增加-1值,表示只有考勤加班但是无补贴。
|
|
|
OvertimeAllowance allowance = new OvertimeAllowance();
|
|
|
allowance.setCompanyId(userCorpwxTime.getCompanyId());
|
|
|
@@ -1217,6 +1248,7 @@ public class WxCorpInfoServiceImpl extends ServiceImpl<WxCorpInfoMapper, WxCorpI
|
|
|
DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
|
|
|
DateTimeFormatter timeFormatter = DateTimeFormatter.ofPattern("HH:mm");
|
|
|
LocalDateTime startTime = LocalDateTime.parse(dateTimeFormatter.format(userCorpwxTime.getCreateDate()) + " " + userCorpwxTime.getStartTime(), df);
|
|
|
+ String endTimeStr = userCorpwxTime.getEndTime();
|
|
|
LocalDateTime endTime = LocalDateTime.parse(dateTimeFormatter.format(userCorpwxTime.getCreateDate()) + " " + userCorpwxTime.getEndTime(), df);
|
|
|
if (endTime.isBefore(startTime)) {
|
|
|
endTime = endTime.plusDays(1);
|
|
|
@@ -1233,7 +1265,6 @@ public class WxCorpInfoServiceImpl extends ServiceImpl<WxCorpInfoMapper, WxCorpI
|
|
|
BigDecimal bigDecimal = new BigDecimal(Duration.between(startTime,endTime).toMinutes());
|
|
|
bigDecimal = bigDecimal.divide(BigDecimal.valueOf(60),1,BigDecimal.ROUND_HALF_UP);//按小时为单位
|
|
|
double standWorkHours = 8.0;
|
|
|
-// System.out.println("打卡时长(分钟):" + bigDecimal);
|
|
|
double onDutyTime = bigDecimal.doubleValue();
|
|
|
allowance.setOnDutyHours(onDutyTime);
|
|
|
double time = onDutyTime;
|
|
|
@@ -1248,59 +1279,57 @@ public class WxCorpInfoServiceImpl extends ServiceImpl<WxCorpInfoMapper, WxCorpI
|
|
|
time = 0;
|
|
|
}
|
|
|
allowance.setWorkHours(time);//实际工作时长
|
|
|
- System.out.println("计算加班时长==" + (time - standWorkHours));
|
|
|
+ System.out.println("加班时长==" + reportOvertime);
|
|
|
//是否是工作日加班
|
|
|
if (WorkDayCalculateUtils.isWorkDay(userCorpwxTime.getCreateDate())) {
|
|
|
- if (time - standWorkHours >= 0) {//小夜班情况下是正好8小时工作,所以等于也要进行判断
|
|
|
- if (startTimeTxt.compareTo(baseMorningEnd) < 0) {
|
|
|
- //白班,正常工作上午来上班的情况,计算晚上加班的时间
|
|
|
- if (time - standWorkHours >= 3.0) {
|
|
|
- //当天加班,补贴20
|
|
|
- if (endTime.toLocalDate().compareTo(startTime.toLocalDate()) == 0) {
|
|
|
- allowance.setType(0);
|
|
|
- allowance.setOvertimeDuration(time - standWorkHours);
|
|
|
- allowance.setAllowance(20);
|
|
|
- } else {
|
|
|
- //跨天,加班超过凌晨了,补贴30
|
|
|
- allowance.setType(1);
|
|
|
- allowance.setOvertimeDuration(time - standWorkHours);
|
|
|
- allowance.setAllowance(30);
|
|
|
- }
|
|
|
- } else {
|
|
|
- //不足3小时
|
|
|
-// System.out.println("工作日加班不足3小时:"+(time - standWorkHours));
|
|
|
- allowance.setType(-1);
|
|
|
- allowance.setOvertimeDuration(time - standWorkHours);
|
|
|
- allowance.setAllowance(0);
|
|
|
- }
|
|
|
- } else if (startTimeTxt.compareTo("16:00") >= 0) {
|
|
|
- //晚班,计算白班加班的时间
|
|
|
- if (time >= 12.0) {
|
|
|
- //大夜班,超过12小时了
|
|
|
- allowance.setType(3);
|
|
|
- allowance.setOvertimeDuration(time - standWorkHours);
|
|
|
- allowance.setAllowance(50);
|
|
|
+ if (startTimeTxt.compareTo(baseMorningEnd) < 0) {
|
|
|
+ //白班,正常工作上午来上班的情况,计算晚上加班的时间
|
|
|
+ if (reportOvertime >= 3.0) {
|
|
|
+ //当天加班,补贴20
|
|
|
+ if (endTime.toLocalDate().compareTo(startTime.toLocalDate()) == 0) {
|
|
|
+ allowance.setType(0);
|
|
|
+ allowance.setOvertimeDuration(reportOvertime);
|
|
|
+ allowance.setAllowance(20);
|
|
|
} else {
|
|
|
//跨天,加班超过凌晨了,补贴30
|
|
|
- allowance.setType(2);
|
|
|
- allowance.setOvertimeDuration(time - standWorkHours);
|
|
|
+ allowance.setType(1);
|
|
|
+ allowance.setOvertimeDuration(reportOvertime);
|
|
|
allowance.setAllowance(30);
|
|
|
}
|
|
|
+ } else {
|
|
|
+ //不足3小时
|
|
|
+// System.out.println("工作日加班不足3小时:"+(time - standWorkHours));
|
|
|
+ allowance.setType(-1);
|
|
|
+ allowance.setOvertimeDuration(reportOvertime);
|
|
|
+ allowance.setAllowance(0);
|
|
|
+ }
|
|
|
+ } else if (startTimeTxt.compareTo("16:00") >= 0) {
|
|
|
+ //晚班,计算白班加班的时间
|
|
|
+ if (time >= 12.0) {
|
|
|
+ //大夜班,超过12小时了
|
|
|
+ allowance.setType(3);
|
|
|
+ allowance.setOvertimeDuration(reportOvertime);
|
|
|
+ allowance.setAllowance(50);
|
|
|
+ } else if (time >= standWorkHours && endTime.toLocalDate().isAfter(startTime.toLocalDate())) {//工作超过凌晨了
|
|
|
+ //小夜班,补贴30
|
|
|
+ allowance.setType(2);
|
|
|
+ allowance.setOvertimeDuration(reportOvertime);
|
|
|
+ allowance.setAllowance(30);
|
|
|
}
|
|
|
}
|
|
|
} else {
|
|
|
+ System.out.println(""+reportOvertime + ", " + standWorkHours + ", baseMorningEnd= "+baseMorningEnd + ", time=" + time + ", startTimeTxt=" + startTimeTxt + ", endTimeTxt=" + endTimeTxt);
|
|
|
//非工作日,判断是否为全天加班
|
|
|
- if (time - standWorkHours >= 0) {
|
|
|
+ if (reportOvertime >= standWorkHours) {
|
|
|
if (startTimeTxt.compareTo(baseMorningEnd) < 0) {
|
|
|
if (endTime.toLocalDate().isEqual(startTime.toLocalDate())) {
|
|
|
allowance.setType(4);
|
|
|
- allowance.setOvertimeDuration(time);
|
|
|
+ allowance.setOvertimeDuration(reportOvertime);
|
|
|
allowance.setAllowance(20);
|
|
|
-// System.out.println("非工作日,加班白班全天");
|
|
|
} else {
|
|
|
//加班超过凌晨了
|
|
|
allowance.setType(1);
|
|
|
- allowance.setOvertimeDuration(time - standWorkHours);
|
|
|
+ allowance.setOvertimeDuration(reportOvertime);
|
|
|
allowance.setAllowance(30);
|
|
|
}
|
|
|
} else if (startTimeTxt.compareTo("16:00") >= 0) {
|
|
|
@@ -1308,26 +1337,20 @@ public class WxCorpInfoServiceImpl extends ServiceImpl<WxCorpInfoMapper, WxCorpI
|
|
|
if (time >= 12.0) {
|
|
|
//大夜班,超过12小时了
|
|
|
allowance.setType(3);
|
|
|
- allowance.setOvertimeDuration(time);
|
|
|
+ allowance.setOvertimeDuration(reportOvertime);
|
|
|
allowance.setAllowance(50);
|
|
|
- } else {
|
|
|
+ } else if (time >= standWorkHours){
|
|
|
//跨天,加班超过凌晨了,补贴30
|
|
|
allowance.setType(2);
|
|
|
- allowance.setOvertimeDuration(time);
|
|
|
+ allowance.setOvertimeDuration(reportOvertime);
|
|
|
allowance.setAllowance(30);
|
|
|
}
|
|
|
}
|
|
|
- } else if (time > 0) {
|
|
|
- //排除午休外的工作时长超过3小时,补20元
|
|
|
- if (startTimeTxt.compareTo("12:00") <= 0 && endTimeTxt.compareTo("13:00") >= 0) {
|
|
|
- //午休
|
|
|
- time -= 1.0;
|
|
|
- }
|
|
|
- if (time >= 3.0) {
|
|
|
- allowance.setType(0);
|
|
|
- allowance.setOvertimeDuration(time);
|
|
|
- allowance.setAllowance(20);
|
|
|
- }
|
|
|
+ } else if (reportOvertime >= 3.0) {
|
|
|
+ //加班工作时长超过3小时,补20元
|
|
|
+ allowance.setType(0);
|
|
|
+ allowance.setOvertimeDuration(reportOvertime);
|
|
|
+ allowance.setAllowance(20);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -2137,7 +2160,7 @@ public class WxCorpInfoServiceImpl extends ServiceImpl<WxCorpInfoMapper, WxCorpI
|
|
|
userCorpwxTimeMapper.updateById(ct);
|
|
|
}
|
|
|
if (corpInfo.getCompanyId() == Constant.XI_HE_CHAO_DAO_COMPANY_ID || corpInfo.getCompanyId() == Constant.XI_HE_CHAO_DAO_JIA_XING_COMPANY_ID || corpInfo.getCompanyId() == 8128) {
|
|
|
- handleAllowance(item, baseMorningStart, baseMorningEnd, baseAfternoonStart, baseAfternoonEnd, restTime);
|
|
|
+// handleAllowance(item, baseMorningStart, baseMorningEnd, baseAfternoonStart, baseAfternoonEnd, restTime);
|
|
|
}
|
|
|
}
|
|
|
} else {
|
|
|
@@ -2145,7 +2168,7 @@ public class WxCorpInfoServiceImpl extends ServiceImpl<WxCorpInfoMapper, WxCorpI
|
|
|
if (showLog) System.out.println("插入考勤记录"+curUserid+", "+localDate);
|
|
|
userCorpwxTimeMapper.insert(ct);
|
|
|
if (corpInfo.getCompanyId() == Constant.XI_HE_CHAO_DAO_COMPANY_ID || corpInfo.getCompanyId() == Constant.XI_HE_CHAO_DAO_JIA_XING_COMPANY_ID || corpInfo.getCompanyId() == 8128) {
|
|
|
- handleAllowance(ct, baseMorningStart, baseMorningEnd, baseAfternoonStart, baseAfternoonEnd, restTime);
|
|
|
+// handleAllowance(ct, baseMorningStart, baseMorningEnd, baseAfternoonStart, baseAfternoonEnd, restTime);
|
|
|
}
|
|
|
|
|
|
} else {
|
|
|
@@ -2907,12 +2930,6 @@ public class WxCorpInfoServiceImpl extends ServiceImpl<WxCorpInfoMapper, WxCorpI
|
|
|
} else {
|
|
|
userCorpwxTimeMapper.insert(userCorpWxCardTime);
|
|
|
}
|
|
|
- String baseMorningStart = "08:00";
|
|
|
- String baseMorningEnd = "12:00";
|
|
|
- String baseAfternoonStart = "13:00";
|
|
|
- String baseAfternoonEnd = "17:00";
|
|
|
- double restTime = 1.0;
|
|
|
- handleAllowance(userCorpWxCardTime, baseMorningStart, baseMorningEnd, baseAfternoonStart, baseAfternoonEnd, restTime);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -3079,6 +3096,9 @@ public class WxCorpInfoServiceImpl extends ServiceImpl<WxCorpInfoMapper, WxCorpI
|
|
|
String resp = ResponseEntity.getBody();
|
|
|
System.out.println("返回加班审批单号==+ resp==" + resp);
|
|
|
JSONObject jsonObject = JSONObject.parseObject(resp);
|
|
|
+ if (jsonObject.getInteger("errcode") != 0) {
|
|
|
+ throw new Exception("获取审批单号失败:" + jsonObject.toJSONString());
|
|
|
+ }
|
|
|
JSONArray sp_no_list = jsonObject.getJSONArray("sp_no_list");
|
|
|
jsonArray.addAll(sp_no_list);
|
|
|
if(jsonObject.containsKey("new_next_cursor")){
|