|
@@ -448,7 +448,8 @@ public class UserWithBeisenController {
|
|
DateTimeFormatter df=DateTimeFormatter.ofPattern("yyyy-MM-dd");
|
|
DateTimeFormatter df=DateTimeFormatter.ofPattern("yyyy-MM-dd");
|
|
DateTimeFormatter df1=DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
|
|
DateTimeFormatter df1=DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
|
|
DateTimeFormatter df2=DateTimeFormatter.ofPattern("HH:mm");
|
|
DateTimeFormatter df2=DateTimeFormatter.ofPattern("HH:mm");
|
|
- DateTimeFormatter df3=DateTimeFormatter.ofPattern("HH:mm:ss");
|
|
|
|
|
|
+ DateTimeFormatter df3=DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm");
|
|
|
|
+ DateTimeFormatter df4=DateTimeFormatter.ofPattern("HH:mm:ss");
|
|
User user = userMapper.selectById(request.getHeader("token"));
|
|
User user = userMapper.selectById(request.getHeader("token"));
|
|
Integer companyId = user.getCompanyId();
|
|
Integer companyId = user.getCompanyId();
|
|
TimeType timeType = timeTypeMapper.selectById(companyId);
|
|
TimeType timeType = timeTypeMapper.selectById(companyId);
|
|
@@ -481,44 +482,170 @@ public class UserWithBeisenController {
|
|
boolean workDay = WorkDayCalculateUtils.isWorkDay(LocalDate.parse(createDate,df));
|
|
boolean workDay = WorkDayCalculateUtils.isWorkDay(LocalDate.parse(createDate,df));
|
|
//todo:针对景昱 工作日默认以8小时工作制度加上加班时长 非工作日以加班时长为准
|
|
//todo:针对景昱 工作日默认以8小时工作制度加上加班时长 非工作日以加班时长为准
|
|
Double workTime;
|
|
Double workTime;
|
|
- Duration between = Duration.between(LocalTime.parse(firstCard, df3), LocalTime.parse(lastCard, df3));
|
|
|
|
- if(between.toHours()>8){
|
|
|
|
- workTime=8.0;
|
|
|
|
- }else if(between.toHours()<0) {
|
|
|
|
- workTime=0.0;
|
|
|
|
|
|
+ Duration between = Duration.between(LocalTime.parse(firstCard, df4), LocalTime.parse(lastCard, df4));
|
|
|
|
+ LocalTime min = LocalTime.parse(firstCard, df4);
|
|
|
|
+ LocalTime max = LocalTime.parse(lastCard, df4);
|
|
|
|
+ if(timeType.getCompanyId()==5978){
|
|
|
|
+ if(workDay){
|
|
|
|
+ workTime=8.0;
|
|
|
|
+ }else {
|
|
|
|
+ workTime=0.0;
|
|
|
|
+ }
|
|
}else {
|
|
}else {
|
|
- BigDecimal decimal = new BigDecimal(between.toMinutes());
|
|
|
|
- decimal=decimal.divide(new BigDecimal(60),1,RoundingMode.HALF_UP);
|
|
|
|
- workTime=decimal.doubleValue();
|
|
|
|
|
|
+ if(between.toHours()<0){
|
|
|
|
+ workTime=0.0;
|
|
|
|
+ }else {
|
|
|
|
+ BigDecimal decimal = new BigDecimal(between.toMinutes());
|
|
|
|
+ decimal=decimal.divide(new BigDecimal(60),1,RoundingMode.HALF_UP);
|
|
|
|
+ workTime=decimal.doubleValue();
|
|
|
|
+ }
|
|
}
|
|
}
|
|
Stream<JSONObject> overTimeStream = allOverTimeList.stream().map(elment -> (JSONObject) elment);
|
|
Stream<JSONObject> overTimeStream = allOverTimeList.stream().map(elment -> (JSONObject) elment);
|
|
Stream<JSONObject> vacationStream = vacationList.stream().map(elment -> (JSONObject) elment);
|
|
Stream<JSONObject> vacationStream = vacationList.stream().map(elment -> (JSONObject) elment);
|
|
Optional<UserWithBeisen> beisen = userWithBeisenList.stream().filter(u -> u.getJobNumber() != null && u.getJobNumber().equals(first.get().getJobNumber())).findFirst();
|
|
Optional<UserWithBeisen> beisen = userWithBeisenList.stream().filter(u -> u.getJobNumber() != null && u.getJobNumber().equals(first.get().getJobNumber())).findFirst();
|
|
if(beisen.isPresent()){
|
|
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())
|
|
List<JSONObject> overTimeList = overTimeStream.filter(a -> a.getString("StaffId").equals(beisen.get().getUserId())
|
|
&& (a.getIntValue("ApproveStatus") == 2||a.getIntValue("ApproveStatus") == 1)).collect(Collectors.toList());
|
|
&& (a.getIntValue("ApproveStatus") == 2||a.getIntValue("ApproveStatus") == 1)).collect(Collectors.toList());
|
|
- if(overTimeList.size()>0){
|
|
|
|
- double actualOverTimeDuration = overTimeList.stream().mapToDouble(i -> i.getDouble("OverTimeDuration")).sum();
|
|
|
|
- if(workDay){
|
|
|
|
- workTime= workTime+actualOverTimeDuration;
|
|
|
|
|
|
+ //加班数据可能存在结束日期是当前日期的情况的情况
|
|
|
|
+ BigDecimal overTimeBigDecimal = new BigDecimal(0);
|
|
|
|
+ LocalDate localDate = LocalDate.parse(createDate, df);
|
|
|
|
+ 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.isAfter(LocalTime.parse("19:00:00",df4))){
|
|
|
|
+ //判断打卡时间是不是大于19:00 大于才算加班 通过打卡计算加班时长 与加班单作比较 取小
|
|
|
|
+ Duration timeDurantion = Duration.between(LocalTime.parse("19:00:00", df4), max);
|
|
|
|
+ //如果结束时间大于13:00
|
|
|
|
+ if(max.isAfter(LocalTime.parse("13:00:00",df4))){
|
|
|
|
+ timeDurantion.minusHours(1);
|
|
|
|
+ }
|
|
|
|
+ //如果结束时间大于18:00
|
|
|
|
+ if(max.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.isAfter(LocalTime.parse("19:00:00",df4))){
|
|
|
|
+ //判断打卡时间是不是大于19:00 通过打卡计算加班时长 与加班单作比较 取小
|
|
|
|
+ Duration timeDurantion = Duration.between(LocalTime.parse("19:00:00", df4), max);
|
|
|
|
+ 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.isAfter(LocalTime.parse("19:00:00",df4))){
|
|
|
|
+ //判断打卡时间是不是大于19:00 通过打卡计算加班时长 与加班单作比较 取小
|
|
|
|
+ Duration timeDurantion = Duration.between(LocalTime.parse("19:00:00", df4), max);
|
|
|
|
+ //如果结束时间大于13:00
|
|
|
|
+ if(max.isAfter(LocalTime.parse("13:00:00",df4))){
|
|
|
|
+ timeDurantion.minusHours(1);
|
|
|
|
+ }
|
|
|
|
+ //如果结束时间大于18:00
|
|
|
|
+ if(max.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.isAfter(LocalTime.parse("19:00:00",df4))){
|
|
|
|
+ //判断打卡时间是不是大于19:00 通过打卡计算加班时长 与加班单作比较 取小
|
|
|
|
+ Duration timeDurantion = Duration.between(LocalTime.parse("19:00:00", df4), max);
|
|
|
|
+ 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 {
|
|
}else {
|
|
- workTime= actualOverTimeDuration;
|
|
|
|
|
|
+ workTime= workTime+(between.toMinutes()/60);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- //计算休假
|
|
|
|
- List<JSONObject> targetVacation = vacationStream.filter(a -> a.getString("StaffId").equals(beisen.get().getUserId())
|
|
|
|
- && (a.getString("ApproveStatus").equals("通过") || a.getString("ApproveStatus").equals("审批中"))).collect(Collectors.toList());
|
|
|
|
- if(targetVacation.size()>0){
|
|
|
|
- double vacationDuration = targetVacation.stream().mapToDouble(i -> i.getDouble("VacationDuration")).sum();
|
|
|
|
|
|
+ //处理修改
|
|
|
|
+ List<JSONObject> lastVacationList = vacationStream.filter(a ->{
|
|
|
|
+ LocalDate vacationStartDate = LocalDateTime.parse(a.getString("VacationStartDateTime"), df3).toLocalDate();
|
|
|
|
+ LocalDate vacationStopDate = LocalDateTime.parse(a.getString("VacationStopDateTime"), df3).toLocalDate();
|
|
|
|
+ boolean b=false;
|
|
|
|
+ if((localDate.isAfter(vacationStartDate)||localDate.isEqual(vacationStartDate))
|
|
|
|
+ &&(localDate.isBefore(vacationStopDate)||localDate.isEqual(vacationStopDate))){
|
|
|
|
+ b=true;
|
|
|
|
+ }
|
|
|
|
+ if(a.getString("StaffId").equals(beisen.get().getUserId())
|
|
|
|
+ && b
|
|
|
|
+ && (a.getString("ApproveStatus").equals("通过") || a.getString("ApproveStatus").equals("审批中"))){
|
|
|
|
+ return true;
|
|
|
|
+ }
|
|
|
|
+ return false;
|
|
|
|
+ }).collect(Collectors.toList());
|
|
|
|
+ if(lastVacationList.size()>0){
|
|
|
|
+ double vacationDuration = lastVacationList.stream().mapToDouble(i -> i.getDouble("VacationDuration")).sum();
|
|
BigDecimal decimal = new BigDecimal(vacationDuration);
|
|
BigDecimal decimal = new BigDecimal(vacationDuration);
|
|
decimal=decimal.divide(new BigDecimal(60),1,RoundingMode.HALF_UP);
|
|
decimal=decimal.divide(new BigDecimal(60),1,RoundingMode.HALF_UP);
|
|
- //考勤打卡区间大于8小时 但是存在休假数据
|
|
|
|
- if(between.toHours()>8){
|
|
|
|
- if(decimal.doubleValue()>8){
|
|
|
|
- workTime= workTime-8;
|
|
|
|
- }else {
|
|
|
|
- workTime= workTime-decimal.doubleValue();
|
|
|
|
- }
|
|
|
|
|
|
+// //可能存在休假多天 只减去一天
|
|
|
|
+ if(decimal.doubleValue()>=8){
|
|
|
|
+ workTime= workTime-8;
|
|
|
|
+ }else {
|
|
|
|
+ workTime= workTime-decimal.doubleValue();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|