|
@@ -152,6 +152,7 @@ public class UserWithBeisenController {
|
|
|
DateTimeFormatter df1=DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
|
|
|
DateTimeFormatter df2=DateTimeFormatter.ofPattern("HH:mm");
|
|
|
DateTimeFormatter df3=DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm");
|
|
|
+ DateTimeFormatter df4=DateTimeFormatter.ofPattern("HH:mm:ss");
|
|
|
Integer companyId = userMapper.selectById(request.getHeader("token")).getCompanyId();
|
|
|
TimeType timeType = timeTypeMapper.selectById(companyId);
|
|
|
List<User> userList = userMapper.selectList(new LambdaQueryWrapper<User>().eq(User::getCompanyId, companyId));
|
|
@@ -221,13 +222,121 @@ public class UserWithBeisenController {
|
|
|
Stream<JSONObject> vacationStream = allVacationList.stream().map(elment -> (JSONObject) elment);
|
|
|
Optional<UserWithBeisen> beisen = userWithBeisenList.stream().filter(u -> u.getJobNumber() != null && u.getJobNumber().equals(first.get().getJobNumber())).findFirst();
|
|
|
if(beisen.isPresent()){
|
|
|
- //审核通过以及审批中都算
|
|
|
+ //todo:之前的逻辑
|
|
|
+// List<JSONObject> overTimeList = overTimeStream.filter(a -> a.getString("StaffId").equals(beisen.get().getUserId())
|
|
|
+// && (a.getIntValue("ApproveStatus") == 2||a.getIntValue("ApproveStatus") == 1)
|
|
|
+// &&LocalDateTime.parse(a.getString("StartDate"),df1).toLocalDate().isEqual(localDate)).collect(Collectors.toList());
|
|
|
List<JSONObject> overTimeList = overTimeStream.filter(a -> a.getString("StaffId").equals(beisen.get().getUserId())
|
|
|
- && (a.getIntValue("ApproveStatus") == 1||a.getIntValue("ApproveStatus") == 2)
|
|
|
- &&LocalDateTime.parse(a.getString("StartDate"),df1).toLocalDate().isEqual(localDate)).collect(Collectors.toList());
|
|
|
- if(overTimeList.size()>0){
|
|
|
- double actualOverTimeDuration = overTimeList.stream().mapToDouble(i -> i.getDouble("OverTimeDuration")).sum();
|
|
|
- workTime= workTime+actualOverTimeDuration;
|
|
|
+ && (a.getIntValue("ApproveStatus") == 2||a.getIntValue("ApproveStatus") == 1)).collect(Collectors.toList());
|
|
|
+ //加班数据可能存在结束日期是当前日期的情况的情况
|
|
|
+ BigDecimal overTimeBigDecimal = new BigDecimal(0);
|
|
|
+ for (JSONObject o : overTimeList) {
|
|
|
+ //存在开始日期为当前日期的数据以及结束日期为当天日期的数据 分开计算
|
|
|
+ if(LocalDateTime.parse(o.getString("StartDate"),df1).toLocalDate().isEqual(localDate)){
|
|
|
+ //存在开始日期为当天的数据
|
|
|
+ if(LocalDateTime.parse(o.getString("StartDate"),df1).toLocalDate().isEqual(LocalDateTime.parse(o.getString("StopDate"),df1).toLocalDate())){
|
|
|
+ //开始日期和结束日期是相同的情况 说明是加班区间只存在于当天的情况
|
|
|
+ if(max.get().isAfter(LocalTime.parse("19:00:00",df4))){
|
|
|
+ //判断打卡时间是不是大于19:00 大于才算加班 通过打卡计算加班时长 与加班单作比较 取小
|
|
|
+ Duration timeDurantion = Duration.between(LocalTime.parse("19:00:00", df4), max.get());
|
|
|
+ //如果结束时间大于13:00
|
|
|
+ if(max.get().isAfter(LocalTime.parse("13:00:00",df4))){
|
|
|
+ timeDurantion.minusHours(1);
|
|
|
+ }
|
|
|
+ //如果结束时间大于18:00
|
|
|
+ if(max.get().isAfter(LocalTime.parse("18:00:00",df4))){
|
|
|
+ timeDurantion.minusMinutes(30);
|
|
|
+ }
|
|
|
+ long l = timeDurantion.toMinutes() / 60;
|
|
|
+ if(l<o.getDouble("OverTimeDuration")){
|
|
|
+ overTimeBigDecimal=overTimeBigDecimal.add(new BigDecimal(l));
|
|
|
+ }else {
|
|
|
+ overTimeBigDecimal=overTimeBigDecimal.add(new BigDecimal(o.getDouble("OverTimeDuration")));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }else {
|
|
|
+ //开始日期和结束日期是不相同的情况 说明是加班区间存在加班到第二天的情况
|
|
|
+ LocalDateTime start = LocalDateTime.parse(o.getString("StartDate"), df1);
|
|
|
+ LocalDateTime stop = start.toLocalDate().atTime(LocalTime.MAX);
|
|
|
+ Duration duration = Duration.between(start, stop);
|
|
|
+ if(stop.toLocalTime().isAfter(LocalTime.parse("13:00:00",df4))){
|
|
|
+ duration.minusHours(1);
|
|
|
+ }
|
|
|
+ //如果结束时间大于18:00
|
|
|
+ if(stop.toLocalTime().isAfter(LocalTime.parse("18:00:00",df4))){
|
|
|
+ duration.minusMinutes(30);
|
|
|
+ }
|
|
|
+ long l = duration.toMinutes() / 60;
|
|
|
+ if(max.get().isAfter(LocalTime.parse("19:00:00",df4))){
|
|
|
+ //判断打卡时间是不是大于19:00 通过打卡计算加班时长 与加班单作比较 取小
|
|
|
+ Duration timeDurantion = Duration.between(LocalTime.parse("19:00:00", df4), max.get());
|
|
|
+ long l1 = timeDurantion.toMinutes() / 60;
|
|
|
+ if(l1<l){
|
|
|
+ overTimeBigDecimal=overTimeBigDecimal.add(new BigDecimal(l1));
|
|
|
+ }else {
|
|
|
+ overTimeBigDecimal=overTimeBigDecimal.add(new BigDecimal(l));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }else if(LocalDateTime.parse(o.getString("StopDate"),df1).toLocalDate().isEqual(localDate)){
|
|
|
+ //存在结束日期为当天的数据
|
|
|
+ if(LocalDateTime.parse(o.getString("StartDate"),df1).toLocalDate().isEqual(LocalDateTime.parse(o.getString("StopDate"),df1).toLocalDate())){
|
|
|
+ //开始日期和结束日期是相同的情况 说明是加班区间只存在于当天的情况
|
|
|
+ if(max.get().isAfter(LocalTime.parse("19:00:00",df4))){
|
|
|
+ //判断打卡时间是不是大于19:00 通过打卡计算加班时长 与加班单作比较 取小
|
|
|
+ Duration timeDurantion = Duration.between(LocalTime.parse("19:00:00", df4), max.get());
|
|
|
+ //如果结束时间大于13:00
|
|
|
+ if(max.get().isAfter(LocalTime.parse("13:00:00",df4))){
|
|
|
+ timeDurantion.minusHours(1);
|
|
|
+ }
|
|
|
+ //如果结束时间大于18:00
|
|
|
+ if(max.get().isAfter(LocalTime.parse("18:00:00",df4))){
|
|
|
+ timeDurantion.minusMinutes(30);
|
|
|
+ }
|
|
|
+ long l = timeDurantion.toMinutes() / 60;
|
|
|
+ if(l<o.getDouble("OverTimeDuration")){
|
|
|
+ overTimeBigDecimal=overTimeBigDecimal.add(new BigDecimal(l));
|
|
|
+ }else {
|
|
|
+ overTimeBigDecimal=overTimeBigDecimal.add(new BigDecimal(o.getDouble("OverTimeDuration")));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }else {
|
|
|
+ //开始日期和结束日期是不相同的情况 说明是加班区间存在加班到第二天的情况
|
|
|
+ LocalDateTime stop = LocalDateTime.parse(o.getString("StopDate"), df1);
|
|
|
+ LocalDateTime start = stop.toLocalDate().atTime(LocalTime.MIN);
|
|
|
+ Duration duration = Duration.between(start, stop);
|
|
|
+ //如果结束时间大于13:00
|
|
|
+ if(stop.toLocalTime().isAfter(LocalTime.parse("13:00:00",df4))){
|
|
|
+ duration.minusHours(1);
|
|
|
+ }
|
|
|
+ //如果结束时间大于18:00
|
|
|
+ if(stop.toLocalTime().isAfter(LocalTime.parse("18:00:00",df4))){
|
|
|
+ duration.minusMinutes(30);
|
|
|
+ }
|
|
|
+ long l = duration.toMinutes() / 60;
|
|
|
+ if(max.get().isAfter(LocalTime.parse("19:00:00",df4))){
|
|
|
+ //判断打卡时间是不是大于19:00 通过打卡计算加班时长 与加班单作比较 取小
|
|
|
+ Duration timeDurantion = Duration.between(LocalTime.parse("19:00:00", df4), max.get());
|
|
|
+ long l1 = timeDurantion.toMinutes() / 60;
|
|
|
+ if(l1<l){
|
|
|
+ overTimeBigDecimal=overTimeBigDecimal.add(new BigDecimal(l1));
|
|
|
+ }else {
|
|
|
+ overTimeBigDecimal=overTimeBigDecimal.add(new BigDecimal(l));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(workDay){
|
|
|
+ //工作日计算按照前面的逻辑计算加班时长计算
|
|
|
+ workTime= workTime+overTimeBigDecimal.doubleValue();
|
|
|
+ }else {
|
|
|
+ //非工作日加班 根据实际打卡时长 比较 加班单时长
|
|
|
+ if((between.toMinutes()/60)>overTimeBigDecimal.doubleValue()){
|
|
|
+ workTime= workTime+overTimeBigDecimal.doubleValue();
|
|
|
+ }else {
|
|
|
+ workTime= workTime+(between.toMinutes()/60);
|
|
|
+ }
|
|
|
}
|
|
|
//处理修改
|
|
|
List<JSONObject> vacationList = vacationStream.filter(a ->{
|