|
@@ -148,223 +148,56 @@ public class UserWithBeisenController {
|
|
|
@RequestMapping("/syncAttendanceFromBeisen")
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
public HttpRespMsg syncAttendanceFromBeisen(String startDate,String endDate){
|
|
|
+ Integer companyId = userMapper.selectById(request.getHeader("token")).getCompanyId();
|
|
|
+ return userWithBeisenService.syncAttendanceFromBeisen(startDate,endDate,companyId);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ @RequestMapping("/getAttendanceStatisticWithUser")
|
|
|
+ public HttpRespMsg getAttendanceStatisticWithUser(String userId,String createDate){
|
|
|
HttpRespMsg msg=new HttpRespMsg();
|
|
|
DateTimeFormatter df=DateTimeFormatter.ofPattern("yyyy-MM-dd");
|
|
|
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();
|
|
|
+ if(StringUtils.isEmpty(userId)){
|
|
|
+ userId=request.getHeader("token");
|
|
|
+ }
|
|
|
+ User user = userMapper.selectById(userId);
|
|
|
+ Integer companyId = user.getCompanyId();
|
|
|
TimeType timeType = timeTypeMapper.selectById(companyId);
|
|
|
List<User> userList = userMapper.selectList(new LambdaQueryWrapper<User>().eq(User::getCompanyId, companyId));
|
|
|
List<UserWithBeisen> userWithBeisenList = userWithBeisenService.list(new LambdaQueryWrapper<UserWithBeisen>().eq(UserWithBeisen::getCompanyId, companyId));
|
|
|
BeisenConfig beisenConfig = beisenConfigMapper.selectById(companyId);
|
|
|
- //获取特殊节假日设置
|
|
|
- List<HolidaySetting> holidaySettings = holidaySettingService.list(new LambdaQueryWrapper<HolidaySetting>().eq(HolidaySetting::getCompanyId, companyId));
|
|
|
if(beisenConfig==null){
|
|
|
msg.setError("北森基础数据配置未完成,请联系服务商完成配置");
|
|
|
return msg;
|
|
|
}
|
|
|
+ Optional<UserWithBeisen> withBeisen = userWithBeisenList.stream().filter(u ->u.getJobNumber()!=null&& u.getJobNumber().equals(user.getJobNumber())).findFirst();
|
|
|
+ if(!withBeisen.isPresent()){
|
|
|
+ msg.setError("当前员工在北森系统中不存在,请完成录入员工信息");
|
|
|
+ return msg;
|
|
|
+ }
|
|
|
//todo 获取到指定日期的考勤数据
|
|
|
- JSONArray attendanceStatistics=new JSONArray();
|
|
|
+ JSONObject item = BeiSenUtils.getAttendanceStatisticWithUser(createDate,withBeisen.get().getUserId(), beisenConfig.getAppKey(), beisenConfig.getAppSecret());
|
|
|
//todo 获取到指定日期的加班数据
|
|
|
- List<LocalDate> workDaysListInRange = WorkDayCalculateUtils.getWorkDaysListInRange(startDate, endDate, 1);
|
|
|
- JSONArray allOverTimeList=new JSONArray();
|
|
|
- JSONArray allVacationList=new JSONArray();
|
|
|
- List<LeaveSheet> leaveSheetList=new ArrayList<>();
|
|
|
- List<UserFvTime> userFvTimeList=new ArrayList<>();
|
|
|
- for (LocalDate localDate : workDaysListInRange) {
|
|
|
- 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 vacationList = BeiSenUtils.getVacationList(df.format(localDate), beisenConfig.getAppKey(), beisenConfig.getAppSecret(),1,100);
|
|
|
- allOverTimeList.addAll(overTimeList);
|
|
|
- attendanceStatistics.addAll(statisticList);
|
|
|
- allVacationList.addAll(vacationList);
|
|
|
- }
|
|
|
- for (LocalDate localDate : workDaysListInRange) {
|
|
|
- Stream<JSONObject> swipingCardsStream = attendanceStatistics.stream().map(item -> (JSONObject) item);
|
|
|
- //todo: 获取当天的考勤数据
|
|
|
- List<JSONObject> swipingCardDateList = swipingCardsStream.filter(i -> LocalDateTime.parse(i.getString("SwipingCardDate"),df1).toLocalDate().equals(localDate)).collect(Collectors.toList());
|
|
|
- for (JSONObject item : swipingCardDateList) {
|
|
|
- //获取当前数据下的人员工号对应到工时管家
|
|
|
- String cardNumber = item.getString("CardNumber");
|
|
|
- Optional<User> first = userList.stream().filter(f -> f.getJobNumber().equals(cardNumber)).findFirst();
|
|
|
- //todo: 获取考勤打卡时间集合
|
|
|
- JSONArray times = item.getJSONArray("Times");
|
|
|
- Stream<JSONObject> timeStream = times.stream().map(time -> (JSONObject) time);
|
|
|
- Stream<JSONObject> timeStream1 = times.stream().map(time -> (JSONObject) time);
|
|
|
- //获取最早上班打卡时间
|
|
|
- List<LocalTime> minLocalTimeList = timeStream.filter(t -> t.getIntValue("Type") == 1).map(i -> LocalDateTime.parse(i.getString("ActualTime"),df1).toLocalTime()).collect(Collectors.toList());
|
|
|
- Optional<LocalTime> minOp = 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());
|
|
|
- Optional<LocalTime> maxOp = maxLocalTimeList.stream().max(LocalTime::compareTo);
|
|
|
- if(first.isPresent()){
|
|
|
- boolean workDay = WorkDayCalculateUtils.isWorkDay(localDate);
|
|
|
- //todo:针对景昱 工作日默认以8小时工作制度加上加班时长 非工作日以加班时长为准
|
|
|
- Double workTime;
|
|
|
- LocalTime min = minOp.get();
|
|
|
- LocalTime max = maxOp.get();
|
|
|
- Duration between = Duration.between(min,max);
|
|
|
- if(between.toHours()<=0){
|
|
|
- continue;
|
|
|
- }else {
|
|
|
- if(workDay){
|
|
|
- //去掉休息时长
|
|
|
- workTime=8.0;
|
|
|
- }else {
|
|
|
- //去掉休息时长
|
|
|
- workTime=0.0;
|
|
|
- }
|
|
|
- }
|
|
|
- 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();
|
|
|
- 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") == 2||a.getIntValue("ApproveStatus") == 1)).collect(Collectors.toList());
|
|
|
- //加班数据可能存在结束日期是当前日期的情况的情况
|
|
|
- BigDecimal overTimeBigDecimal= new BigDecimal(0);
|
|
|
- //计算加班时长 工作日打卡超过19:00:00算加班那 非工作日全天算加班
|
|
|
- if(workDay){
|
|
|
- //工作日打卡超过19:00:00算加班那 非工作日全天算加班
|
|
|
- if(max.isAfter(LocalTime.parse("19:00:00", df4))){
|
|
|
- overTimeBigDecimal = new BigDecimal(Duration.between(LocalTime.parse("18:00:00", df4),max).toMinutes());
|
|
|
- }
|
|
|
- }else {
|
|
|
- //非工作日全天 去掉休息时长 都算加班
|
|
|
- overTimeBigDecimal=new BigDecimal(Duration.between(min, max).toMinutes()) ;
|
|
|
- long rest1 = DateTimeUtil.calculateOverlap(min, max, LocalTime.parse("12:00:00", df4), LocalTime.parse("13:00:00", df4));
|
|
|
- long rest2 = DateTimeUtil.calculateOverlap(min, max, LocalTime.parse("17:30:00", df4), LocalTime.parse("18:00:00", df4));
|
|
|
- overTimeBigDecimal=overTimeBigDecimal.subtract(new BigDecimal(rest1)).subtract(new BigDecimal(rest2));
|
|
|
- }
|
|
|
- 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())){
|
|
|
- //开始日期和结束日期是相同的情况 说明是加班区间只存在于当天的情况
|
|
|
- //对比打卡体现的加班时长和加班单时长取小
|
|
|
- BigDecimal divide = overTimeBigDecimal.divide(new BigDecimal(60), 1, RoundingMode.HALF_DOWN);
|
|
|
- if(divide.doubleValue()>o.getDouble("OverTimeDuration")){
|
|
|
- //打卡获取到的加班时长大于加班单时长 需要在打卡体现的时长-打卡体现的加班时长+加班单时长
|
|
|
- workTime=workTime+o.getDouble("OverTimeDuration");
|
|
|
- }else{
|
|
|
- workTime=workTime+round(divide.doubleValue(),0.5);
|
|
|
- }
|
|
|
- }else {
|
|
|
- //开始日期和结束日期是不相同的情况 说明是加班区间存在加班到第二天的情况
|
|
|
- LocalDateTime start = LocalDateTime.parse(o.getString("StartDate"), df1);
|
|
|
- LocalDateTime stop = start.toLocalDate().atTime(LocalTime.MAX);
|
|
|
- Duration duration = Duration.between(start, stop);
|
|
|
- BigDecimal decimal = new BigDecimal(duration.toMinutes());
|
|
|
- decimal=decimal.divide(new BigDecimal(60),1,RoundingMode.HALF_DOWN);
|
|
|
- double l = decimal.doubleValue();
|
|
|
- //对比打卡体现的加班时长和加班单时长取小
|
|
|
- BigDecimal divide = overTimeBigDecimal.divide(new BigDecimal(60), 1, RoundingMode.HALF_DOWN);
|
|
|
- if(divide.doubleValue()>l){
|
|
|
- //打卡获取到的加班时长大于加班单时长 需要在打卡体现的时长-打卡体现的加班时长+加班单时长
|
|
|
- workTime=workTime+l;
|
|
|
- }else {
|
|
|
- workTime=workTime+round(divide.doubleValue(),0.5);
|
|
|
- }
|
|
|
- }
|
|
|
- }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())){
|
|
|
- //开始日期和结束日期是相同的情况 说明是加班区间只存在于当天的情况
|
|
|
- //判断打卡时间是不是大于19:00 通过打卡计算加班时长 与加班单作比较 取小
|
|
|
- BigDecimal divide = overTimeBigDecimal.divide(new BigDecimal(60), 1, RoundingMode.HALF_DOWN);
|
|
|
- if(divide.doubleValue()>o.getDouble("OverTimeDuration")){
|
|
|
- //打卡获取到的加班时长大于加班单时长 需要在打卡体现的时长-打卡体现的加班时长+加班单时长
|
|
|
- workTime=workTime+o.getDouble("OverTimeDuration");
|
|
|
- }else {
|
|
|
- workTime=workTime+round(divide.doubleValue(),0.5);
|
|
|
- }
|
|
|
- }else {
|
|
|
- //开始日期和结束日期是不相同的情况 说明是加班区间存在加班到第二天的情况
|
|
|
- LocalDateTime stop = LocalDateTime.parse(o.getString("StopDate"), df1);
|
|
|
- LocalDateTime start = stop.toLocalDate().atTime(LocalTime.MIN);
|
|
|
- Duration duration = Duration.between(start, stop);
|
|
|
- BigDecimal decimal = new BigDecimal(duration.toMinutes());
|
|
|
- decimal=decimal.divide(new BigDecimal(60),1,RoundingMode.HALF_DOWN);
|
|
|
- double l = decimal.doubleValue();
|
|
|
- //对比打卡体现的加班时长和加班单时长取小
|
|
|
- BigDecimal divide = overTimeBigDecimal.divide(new BigDecimal(60), 1, RoundingMode.HALF_DOWN);
|
|
|
- if(divide.doubleValue()>l){
|
|
|
- //打卡获取到的加班时长大于加班单时长 需要在打卡体现的时长-打卡体现的加班时长+加班单时长
|
|
|
- workTime=workTime+l;
|
|
|
- }else {
|
|
|
- workTime=workTime+round(divide.doubleValue(),0.5);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- //处理修改
|
|
|
- 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("DocumentType").equals("请假")
|
|
|
- && (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_DOWN);
|
|
|
-// //可能存在休假多天 只减去一天
|
|
|
- if(decimal.doubleValue()>=8){
|
|
|
- workTime= workTime-8;
|
|
|
- }else {
|
|
|
- workTime= workTime-decimal.doubleValue();
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- UserFvTime userFvTime=new UserFvTime();
|
|
|
- userFvTime.setWorkDate(localDate);
|
|
|
- userFvTime.setStartTime(df2.format(min));
|
|
|
- userFvTime.setEndTime(df2.format(max));
|
|
|
- userFvTime.setUserId(first.get().getId());
|
|
|
- userFvTime.setCompanyId(companyId);
|
|
|
- userFvTime.setWorkHours(workTime.floatValue());
|
|
|
- UserFvTime one = userFvTimeService.getOne(new LambdaQueryWrapper<UserFvTime>().eq(UserFvTime::getCompanyId, companyId).eq(UserFvTime::getUserId, first.get().getId()).eq(UserFvTime::getWorkDate, localDate));
|
|
|
- if(one!=null){
|
|
|
- userFvTime.setId(one.getId());
|
|
|
- }
|
|
|
- userFvTimeList.add(userFvTime);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- if(userFvTimeList.size()>0){
|
|
|
- if(!userFvTimeService.saveOrUpdateBatch(userFvTimeList)){
|
|
|
- msg.setError("同步验证失败");
|
|
|
- }
|
|
|
- }
|
|
|
+ JSONArray allOverTimeList = BeiSenUtils.getOverTimeList(createDate,beisenConfig.getAppKey(),beisenConfig.getAppSecret(),1,100);
|
|
|
+ //todo 获取到指定日期的休假数据
|
|
|
+ JSONArray vacationList = BeiSenUtils.getVacationList(createDate, beisenConfig.getAppKey(), beisenConfig.getAppSecret(),1,100);
|
|
|
//同步休假数据到工时管家
|
|
|
- for (int i = 0; i < allVacationList.size(); i++) {
|
|
|
- JSONObject jsonObject = allVacationList.getJSONObject(i);
|
|
|
- Optional<UserWithBeisen> beisen = userWithBeisenList.stream().filter(b -> b.getUserId().equals(jsonObject.getString("StaffId"))).findFirst();
|
|
|
- if(beisen.isPresent()){
|
|
|
- Optional<User> first = userList.stream().filter(u -> u.getJobNumber().equals(beisen.get().getJobNumber())).findFirst();
|
|
|
- if(first.isPresent()){
|
|
|
+ List<LeaveSheet> leaveSheetList=new ArrayList<>();
|
|
|
+ for (int i = 0; i < vacationList.size(); i++) {
|
|
|
+ JSONObject jsonObject = vacationList.getJSONObject(i);
|
|
|
+ Optional<UserWithBeisen> beisen1 = userWithBeisenList.stream().filter(b -> b.getUserId().equals(jsonObject.getString("StaffId"))).findFirst();
|
|
|
+ if(beisen1.isPresent()){
|
|
|
+ Optional<User> first1 = userList.stream().filter(u -> u.getJobNumber().equals(beisen1.get().getJobNumber())).findFirst();
|
|
|
+ if(first1.isPresent()){
|
|
|
LeaveSheet leaveSheet=new LeaveSheet();
|
|
|
leaveSheet.setCompanyId(beisenConfig.getCompanyId());
|
|
|
leaveSheet.setStatus(0);
|
|
|
- leaveSheet.setOwnerId(first.get().getId());
|
|
|
- leaveSheet.setOwnerName(first.get().getName());
|
|
|
+ leaveSheet.setOwnerId(first1.get().getId());
|
|
|
+ leaveSheet.setOwnerName(first1.get().getName());
|
|
|
leaveSheet.setStartDate(LocalDateTime.parse(String.valueOf(jsonObject.get("VacationStartDateTime")),df3).toLocalDate());
|
|
|
leaveSheet.setEndDate(LocalDateTime.parse(String.valueOf(jsonObject.get("VacationStopDateTime")),df3).toLocalDate());
|
|
|
leaveSheet.setTimeType(1);
|
|
@@ -394,8 +227,8 @@ public class UserWithBeisenController {
|
|
|
leaveSheet.setRemark(jsonObject.getString("Reason"));
|
|
|
leaveSheet.setStatus(jsonObject.getString("ApproveStatus").equals("通过")?0:jsonObject.getString("ApproveStatus").equals("审批中")?1:2);
|
|
|
leaveSheet.setProcinstId(jsonObject.getString("VacationId"));
|
|
|
- LeaveSheet one = leaveSheetService.getOne(new LambdaQueryWrapper<LeaveSheet>().eq(LeaveSheet::getProcinstId,leaveSheet.getProcinstId()).eq(LeaveSheet::getOwnerId, first.get().getId()).eq(LeaveSheet::getStartDate, leaveSheet.getStartDate()).eq(LeaveSheet::getEndDate, leaveSheet.getEndDate()));
|
|
|
- if(one==null){
|
|
|
+ LeaveSheet one1 = leaveSheetService.getOne(new LambdaQueryWrapper<LeaveSheet>().eq(LeaveSheet::getOwnerId, first1.get().getId()).eq(LeaveSheet::getStartDate, leaveSheet.getStartDate()).eq(LeaveSheet::getProcinstId,leaveSheet.getProcinstId()).eq(LeaveSheet::getEndDate, leaveSheet.getEndDate()));
|
|
|
+ if(one1==null){
|
|
|
leaveSheetList.add(leaveSheet);
|
|
|
}
|
|
|
}
|
|
@@ -404,42 +237,6 @@ public class UserWithBeisenController {
|
|
|
if(leaveSheetList.size()>0){
|
|
|
leaveSheetService.saveOrUpdateBatch(leaveSheetList);
|
|
|
}
|
|
|
- return msg;
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- @RequestMapping("/getAttendanceStatisticWithUser")
|
|
|
- public HttpRespMsg getAttendanceStatisticWithUser(String userId,String createDate){
|
|
|
- HttpRespMsg msg=new HttpRespMsg();
|
|
|
- DateTimeFormatter df=DateTimeFormatter.ofPattern("yyyy-MM-dd");
|
|
|
- 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");
|
|
|
- if(StringUtils.isEmpty(userId)){
|
|
|
- userId=request.getHeader("token");
|
|
|
- }
|
|
|
- User user = userMapper.selectById(userId);
|
|
|
- Integer companyId = user.getCompanyId();
|
|
|
- TimeType timeType = timeTypeMapper.selectById(companyId);
|
|
|
- List<User> userList = userMapper.selectList(new LambdaQueryWrapper<User>().eq(User::getCompanyId, companyId));
|
|
|
- List<UserWithBeisen> userWithBeisenList = userWithBeisenService.list(new LambdaQueryWrapper<UserWithBeisen>().eq(UserWithBeisen::getCompanyId, companyId));
|
|
|
- BeisenConfig beisenConfig = beisenConfigMapper.selectById(companyId);
|
|
|
- if(beisenConfig==null){
|
|
|
- msg.setError("北森基础数据配置未完成,请联系服务商完成配置");
|
|
|
- return msg;
|
|
|
- }
|
|
|
- Optional<UserWithBeisen> withBeisen = userWithBeisenList.stream().filter(u ->u.getJobNumber()!=null&& u.getJobNumber().equals(user.getJobNumber())).findFirst();
|
|
|
- if(!withBeisen.isPresent()){
|
|
|
- msg.setError("当前员工在北森系统中不存在,请完成录入员工信息");
|
|
|
- return msg;
|
|
|
- }
|
|
|
- //todo 获取到指定日期的考勤数据
|
|
|
- JSONObject item = BeiSenUtils.getAttendanceStatisticWithUser(createDate,withBeisen.get().getUserId(), beisenConfig.getAppKey(), beisenConfig.getAppSecret());
|
|
|
- //todo 获取到指定日期的加班数据
|
|
|
- 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();
|
|
|
System.out.println("考勤数据:"+item.toString());
|
|
@@ -601,58 +398,6 @@ public class UserWithBeisenController {
|
|
|
userFvTime.setId(one.getId());
|
|
|
}
|
|
|
userFvTimeService.saveOrUpdate(userFvTime);
|
|
|
- //同步休假数据到工时管家
|
|
|
- List<LeaveSheet> leaveSheetList=new ArrayList<>();
|
|
|
- for (int i = 0; i < vacationList.size(); i++) {
|
|
|
- JSONObject jsonObject = vacationList.getJSONObject(i);
|
|
|
- Optional<UserWithBeisen> beisen1 = userWithBeisenList.stream().filter(b -> b.getUserId().equals(jsonObject.getString("StaffId"))).findFirst();
|
|
|
- if(beisen.isPresent()){
|
|
|
- Optional<User> first1 = userList.stream().filter(u -> u.getJobNumber().equals(beisen.get().getJobNumber())).findFirst();
|
|
|
- if(first.isPresent()){
|
|
|
- LeaveSheet leaveSheet=new LeaveSheet();
|
|
|
- leaveSheet.setCompanyId(beisenConfig.getCompanyId());
|
|
|
- leaveSheet.setStatus(0);
|
|
|
- leaveSheet.setOwnerId(first.get().getId());
|
|
|
- leaveSheet.setOwnerName(first.get().getName());
|
|
|
- leaveSheet.setStartDate(LocalDateTime.parse(String.valueOf(jsonObject.get("VacationStartDateTime")),df3).toLocalDate());
|
|
|
- leaveSheet.setEndDate(LocalDateTime.parse(String.valueOf(jsonObject.get("VacationStopDateTime")),df3).toLocalDate());
|
|
|
- leaveSheet.setTimeType(1);
|
|
|
- leaveSheet.setTimeDays(jsonObject.getFloatValue("DayValueOfDuration"));
|
|
|
- leaveSheet.setTimeHours(jsonObject.getFloatValue("VacationDuration")/60);
|
|
|
- Integer leaveType;
|
|
|
- switch (jsonObject.getString("VacationType")){
|
|
|
- case "事假":leaveType=0;
|
|
|
- break;
|
|
|
- case "病假":leaveType=1;
|
|
|
- break;
|
|
|
- case "年假":leaveType=2;
|
|
|
- break;
|
|
|
- case "产假":leaveType=3;
|
|
|
- break;
|
|
|
- case "婚假":leaveType=4;
|
|
|
- break;
|
|
|
- case "丧假":leaveType=5;
|
|
|
- break;
|
|
|
- case "调休":leaveType=6;
|
|
|
- break;
|
|
|
- case "陪产假":leaveType=7;
|
|
|
- break;
|
|
|
- default:leaveType=8;
|
|
|
- }
|
|
|
- leaveSheet.setLeaveType(leaveType);
|
|
|
- leaveSheet.setRemark(jsonObject.getString("Reason"));
|
|
|
- leaveSheet.setStatus(jsonObject.getString("ApproveStatus").equals("通过")?0:jsonObject.getString("ApproveStatus").equals("审批中")?1:2);
|
|
|
- leaveSheet.setProcinstId(jsonObject.getString("VacationId"));
|
|
|
- LeaveSheet one1 = leaveSheetService.getOne(new LambdaQueryWrapper<LeaveSheet>().eq(LeaveSheet::getOwnerId, first.get().getId()).eq(LeaveSheet::getStartDate, leaveSheet.getStartDate()).eq(LeaveSheet::getProcinstId,leaveSheet.getProcinstId()).eq(LeaveSheet::getEndDate, leaveSheet.getEndDate()));
|
|
|
- if(one1==null){
|
|
|
- leaveSheetList.add(leaveSheet);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- if(leaveSheetList.size()>0){
|
|
|
- leaveSheetService.saveOrUpdateBatch(leaveSheetList);
|
|
|
- }
|
|
|
msg.setData(userFvTime);
|
|
|
} else {
|
|
|
msg.setError("未找到对应员工信息:staffId="+withBeisen.get().getUserId());
|