|
@@ -24,6 +24,8 @@ import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
import javax.annotation.Resource;
|
|
import javax.servlet.http.HttpServletRequest;
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
|
+import java.math.BigDecimal;
|
|
|
|
+import java.math.RoundingMode;
|
|
import java.time.Duration;
|
|
import java.time.Duration;
|
|
import java.time.LocalDate;
|
|
import java.time.LocalDate;
|
|
import java.time.LocalDateTime;
|
|
import java.time.LocalDateTime;
|
|
@@ -147,6 +149,7 @@ 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("yyyy-MM-dd HH:mm");
|
|
Integer companyId = userMapper.selectById(request.getHeader("token")).getCompanyId();
|
|
Integer companyId = userMapper.selectById(request.getHeader("token")).getCompanyId();
|
|
TimeType timeType = timeTypeMapper.selectById(companyId);
|
|
TimeType timeType = timeTypeMapper.selectById(companyId);
|
|
List<User> userList = userMapper.selectList(new LambdaQueryWrapper<User>().eq(User::getCompanyId, companyId));
|
|
List<User> userList = userMapper.selectList(new LambdaQueryWrapper<User>().eq(User::getCompanyId, companyId));
|
|
@@ -161,12 +164,15 @@ public class UserWithBeisenController {
|
|
//todo 获取到指定日期的加班数据
|
|
//todo 获取到指定日期的加班数据
|
|
List<LocalDate> workDaysListInRange = WorkDayCalculateUtils.getWorkDaysListInRange(startDate, endDate, 1);
|
|
List<LocalDate> workDaysListInRange = WorkDayCalculateUtils.getWorkDaysListInRange(startDate, endDate, 1);
|
|
JSONArray allOverTimeList=new JSONArray();
|
|
JSONArray allOverTimeList=new JSONArray();
|
|
|
|
+ JSONArray allVacationList=new JSONArray();
|
|
List<UserFvTime> userFvTimeList=new ArrayList<>();
|
|
List<UserFvTime> userFvTimeList=new ArrayList<>();
|
|
for (LocalDate localDate : workDaysListInRange) {
|
|
for (LocalDate localDate : workDaysListInRange) {
|
|
JSONArray statisticList = BeiSenUtils.getAttendanceStatistics(df.format(localDate), df.format(localDate), beisenConfig.getAppKey(), beisenConfig.getAppSecret(), 1, 100);
|
|
JSONArray statisticList = BeiSenUtils.getAttendanceStatistics(df.format(localDate), df.format(localDate), beisenConfig.getAppKey(), beisenConfig.getAppSecret(), 1, 100);
|
|
JSONArray overTimeList = BeiSenUtils.getOverTimeList(df.format(localDate), beisenConfig.getAppKey(), beisenConfig.getAppSecret(), 1, 100);
|
|
JSONArray overTimeList = BeiSenUtils.getOverTimeList(df.format(localDate), beisenConfig.getAppKey(), beisenConfig.getAppSecret(), 1, 100);
|
|
|
|
+ JSONArray vacationList = BeiSenUtils.getVacationList(df.format(localDate), beisenConfig.getAppKey(), beisenConfig.getAppSecret(),1,100);
|
|
allOverTimeList.addAll(overTimeList);
|
|
allOverTimeList.addAll(overTimeList);
|
|
attendanceStatistics.addAll(statisticList);
|
|
attendanceStatistics.addAll(statisticList);
|
|
|
|
+ allVacationList.addAll(vacationList);
|
|
}
|
|
}
|
|
for (LocalDate localDate : workDaysListInRange) {
|
|
for (LocalDate localDate : workDaysListInRange) {
|
|
Stream<JSONObject> swipingCardsStream = attendanceStatistics.stream().map(item -> (JSONObject) item);
|
|
Stream<JSONObject> swipingCardsStream = attendanceStatistics.stream().map(item -> (JSONObject) item);
|
|
@@ -183,28 +189,68 @@ public class UserWithBeisenController {
|
|
//获取最早上班打卡时间
|
|
//获取最早上班打卡时间
|
|
List<LocalTime> minLocalTimeList = timeStream.filter(t -> t.getIntValue("Type") == 1).map(i -> LocalDateTime.parse(i.getString("ActualTime"),df1).toLocalTime()).collect(Collectors.toList());
|
|
List<LocalTime> minLocalTimeList = timeStream.filter(t -> t.getIntValue("Type") == 1).map(i -> LocalDateTime.parse(i.getString("ActualTime"),df1).toLocalTime()).collect(Collectors.toList());
|
|
Optional<LocalTime> min = minLocalTimeList.stream().min(LocalTime::compareTo);
|
|
Optional<LocalTime> min = minLocalTimeList.stream().min(LocalTime::compareTo);
|
|
- //获取最早上班打卡时间
|
|
|
|
|
|
+ //获取最晚下班时间
|
|
List<LocalTime> maxLocalTimeList = timeStream1.filter(t -> t.getIntValue("Type") == 9).map(i -> LocalDateTime.parse(i.getString("ActualTime"),df1).toLocalTime()).collect(Collectors.toList());
|
|
List<LocalTime> maxLocalTimeList = timeStream1.filter(t -> t.getIntValue("Type") == 9).map(i -> LocalDateTime.parse(i.getString("ActualTime"),df1).toLocalTime()).collect(Collectors.toList());
|
|
Optional<LocalTime> max = maxLocalTimeList.stream().max(LocalTime::compareTo);
|
|
Optional<LocalTime> max = maxLocalTimeList.stream().max(LocalTime::compareTo);
|
|
- //获取最晚下班时间
|
|
|
|
if(first.isPresent()){
|
|
if(first.isPresent()){
|
|
boolean workDay = WorkDayCalculateUtils.isWorkDay(localDate);
|
|
boolean workDay = WorkDayCalculateUtils.isWorkDay(localDate);
|
|
//todo:针对景昱 工作日默认以8小时工作制度加上加班时长 非工作日以加班时长为准
|
|
//todo:针对景昱 工作日默认以8小时工作制度加上加班时长 非工作日以加班时长为准
|
|
- Double workTime=8.0;
|
|
|
|
|
|
+ Duration between = Duration.between(min.get(), max.get());
|
|
|
|
+ Double workTime;
|
|
|
|
+ if(between.toHours()>8){
|
|
|
|
+ workTime=8.0;
|
|
|
|
+ }else 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 = allVacationList.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()){
|
|
//审核通过以及审批中都算
|
|
//审核通过以及审批中都算
|
|
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") == 1||a.getIntValue("ApproveStatus") == 2)).collect(Collectors.toList());
|
|
|
|
|
|
+ && (a.getIntValue("ApproveStatus") == 1||a.getIntValue("ApproveStatus") == 2)
|
|
|
|
+ &&LocalDateTime.parse(a.getString("StartDate"),df1).toLocalDate().isEqual(localDate)).collect(Collectors.toList());
|
|
if(overTimeList.size()>0){
|
|
if(overTimeList.size()>0){
|
|
- double actualOverTimeDuration = overTimeList.stream().mapToDouble(i -> i.getDouble("ActualOverTimeDuration")).sum();
|
|
|
|
|
|
+ double actualOverTimeDuration = overTimeList.stream().mapToDouble(i -> i.getDouble("OverTimeDuration")).sum();
|
|
if(workDay){
|
|
if(workDay){
|
|
workTime= workTime+actualOverTimeDuration;
|
|
workTime= workTime+actualOverTimeDuration;
|
|
}else {
|
|
}else {
|
|
workTime= actualOverTimeDuration;
|
|
workTime= actualOverTimeDuration;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+ //处理修改
|
|
|
|
+ List<JSONObject> vacationList = 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(vacationList.size()>0){
|
|
|
|
+ double vacationDuration = vacationList.stream().mapToDouble(i -> i.getDouble("VacationDuration")).sum();
|
|
|
|
+ BigDecimal decimal = new BigDecimal(vacationDuration);
|
|
|
|
+ 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();
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
}
|
|
}
|
|
UserFvTime userFvTime=new UserFvTime();
|
|
UserFvTime userFvTime=new UserFvTime();
|
|
userFvTime.setWorkDate(localDate);
|
|
userFvTime.setWorkDate(localDate);
|
|
@@ -236,6 +282,7 @@ 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");
|
|
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);
|
|
@@ -246,15 +293,17 @@ public class UserWithBeisenController {
|
|
msg.setError("北森基础数据配置未完成,请联系服务商完成配置");
|
|
msg.setError("北森基础数据配置未完成,请联系服务商完成配置");
|
|
return msg;
|
|
return msg;
|
|
}
|
|
}
|
|
- //todo 获取到指定日期的考勤数据
|
|
|
|
- //todo 获取到指定日期的加班数据
|
|
|
|
Optional<UserWithBeisen> withBeisen = userWithBeisenList.stream().filter(u ->u.getJobNumber()!=null&& u.getJobNumber().equals(user.getJobNumber())).findFirst();
|
|
Optional<UserWithBeisen> withBeisen = userWithBeisenList.stream().filter(u ->u.getJobNumber()!=null&& u.getJobNumber().equals(user.getJobNumber())).findFirst();
|
|
if(!withBeisen.isPresent()){
|
|
if(!withBeisen.isPresent()){
|
|
msg.setError("当前员工在北森系统中不存在,请完成录入员工信息");
|
|
msg.setError("当前员工在北森系统中不存在,请完成录入员工信息");
|
|
return msg;
|
|
return msg;
|
|
}
|
|
}
|
|
|
|
+ //todo 获取到指定日期的考勤数据
|
|
JSONObject item = BeiSenUtils.getAttendanceStatisticWithUser(createDate,withBeisen.get().getUserId(), beisenConfig.getAppKey(), beisenConfig.getAppSecret());
|
|
JSONObject item = BeiSenUtils.getAttendanceStatisticWithUser(createDate,withBeisen.get().getUserId(), beisenConfig.getAppKey(), beisenConfig.getAppSecret());
|
|
|
|
+ //todo 获取到指定日期的加班数据
|
|
JSONArray allOverTimeList = BeiSenUtils.getOverTimeList(createDate,beisenConfig.getAppKey(),beisenConfig.getAppSecret(),1,100);
|
|
JSONArray allOverTimeList = BeiSenUtils.getOverTimeList(createDate,beisenConfig.getAppKey(),beisenConfig.getAppSecret(),1,100);
|
|
|
|
+ //todo 获取到指定日期的休假数据
|
|
|
|
+ JSONArray vacationList = BeiSenUtils.getVacationList(createDate, beisenConfig.getAppKey(), beisenConfig.getAppSecret(),1,100);
|
|
//获取当前数据下的人员工号对应到工时管家
|
|
//获取当前数据下的人员工号对应到工时管家
|
|
Optional<User> first = userList.stream().filter(f -> f.getJobNumber().equals(withBeisen.get().getJobNumber())).findFirst();
|
|
Optional<User> first = userList.stream().filter(f -> f.getJobNumber().equals(withBeisen.get().getJobNumber())).findFirst();
|
|
System.out.println("考勤数据:"+item.toString());
|
|
System.out.println("考勤数据:"+item.toString());
|
|
@@ -265,25 +314,52 @@ public class UserWithBeisenController {
|
|
if(first.isPresent()){
|
|
if(first.isPresent()){
|
|
boolean workDay = WorkDayCalculateUtils.isWorkDay(LocalDate.parse(createDate,df));
|
|
boolean workDay = WorkDayCalculateUtils.isWorkDay(LocalDate.parse(createDate,df));
|
|
//todo:针对景昱 工作日默认以8小时工作制度加上加班时长 非工作日以加班时长为准
|
|
//todo:针对景昱 工作日默认以8小时工作制度加上加班时长 非工作日以加班时长为准
|
|
- Double workTime=8.0;
|
|
|
|
|
|
+ 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;
|
|
|
|
+ }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);
|
|
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()){
|
|
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).collect(Collectors.toList());
|
|
|
|
|
|
+ && (a.getIntValue("ApproveStatus") == 2||a.getIntValue("ApproveStatus") == 1)).collect(Collectors.toList());
|
|
if(overTimeList.size()>0){
|
|
if(overTimeList.size()>0){
|
|
- double actualOverTimeDuration = overTimeList.stream().mapToDouble(i -> i.getDouble("ActualOverTimeDuration")).sum();
|
|
|
|
|
|
+ double actualOverTimeDuration = overTimeList.stream().mapToDouble(i -> i.getDouble("OverTimeDuration")).sum();
|
|
if(workDay){
|
|
if(workDay){
|
|
workTime= workTime+actualOverTimeDuration;
|
|
workTime= workTime+actualOverTimeDuration;
|
|
}else {
|
|
}else {
|
|
workTime= actualOverTimeDuration;
|
|
workTime= actualOverTimeDuration;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+ //计算休假
|
|
|
|
+ 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();
|
|
|
|
+ BigDecimal decimal = new BigDecimal(vacationDuration);
|
|
|
|
+ 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();
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
}
|
|
}
|
|
UserFvTime userFvTime=new UserFvTime();
|
|
UserFvTime userFvTime=new UserFvTime();
|
|
userFvTime.setWorkDate(LocalDate.parse(createDate,df));
|
|
userFvTime.setWorkDate(LocalDate.parse(createDate,df));
|
|
- userFvTime.setStartTime(!StringUtils.isEmpty(firstCard)?firstCard:"08:30");
|
|
|
|
- userFvTime.setEndTime(!StringUtils.isEmpty(lastCard)?lastCard:"17:30");
|
|
|
|
|
|
+ userFvTime.setStartTime(!StringUtils.isEmpty(firstCard)?firstCard:"08:30:00");
|
|
|
|
+ userFvTime.setEndTime(!StringUtils.isEmpty(lastCard)?lastCard:"17:30:00");
|
|
userFvTime.setUserId(first.get().getId());
|
|
userFvTime.setUserId(first.get().getId());
|
|
userFvTime.setCompanyId(companyId);
|
|
userFvTime.setCompanyId(companyId);
|
|
userFvTime.setWorkHours(workTime.floatValue());
|
|
userFvTime.setWorkHours(workTime.floatValue());
|