Min 1 yıl önce
ebeveyn
işleme
6258bf5215

+ 0 - 27
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/controller/UserWithBeisenController.java

@@ -122,33 +122,6 @@ public class UserWithBeisenController {
         return httpRespMsg;
     }
 
-    @RequestMapping("/getSwipingCardsTest")
-    public HttpRespMsg getSwipingCardsTest(String createDate){
-        HttpRespMsg httpRespMsg=new HttpRespMsg();
-        JSONArray swipingCards = BeiSenUtils.getSwipingCards(createDate,"97BF1F7DF8314F268D91E09C12772CAD","D52BE666683C408087063B422275C289DE09488E28D64B7FB4E5190C43F8AA66",1,300);
-        System.out.println("获取到的打卡数据====>"+swipingCards.toJSONString());
-        httpRespMsg.setData(swipingCards);
-        return httpRespMsg;
-    }
-
-    @RequestMapping("/getOverTimeListTest")
-    public HttpRespMsg getOverTimeListTest(String createDate){
-        HttpRespMsg httpRespMsg=new HttpRespMsg();
-        JSONArray swipingCards = BeiSenUtils.getOverTimeList(createDate,"97BF1F7DF8314F268D91E09C12772CAD","D52BE666683C408087063B422275C289DE09488E28D64B7FB4E5190C43F8AA66",1,100);
-        System.out.println("获取到的加班那数据====>"+swipingCards.toJSONString());
-        httpRespMsg.setData(swipingCards);
-        return httpRespMsg;
-    }
-
-    @RequestMapping("/getAttendanceStatisticsTest")
-    public HttpRespMsg getAttendanceStatisticsTest(String startDate,String endDate){
-        HttpRespMsg httpRespMsg=new HttpRespMsg();
-        JSONArray swipingCards = BeiSenUtils.getAttendanceStatistics(startDate,endDate,"97BF1F7DF8314F268D91E09C12772CAD","D52BE666683C408087063B422275C289DE09488E28D64B7FB4E5190C43F8AA66",1,100);
-        System.out.println("获取到的考勤数据====>"+swipingCards.toJSONString());
-        httpRespMsg.setData(swipingCards);
-        return httpRespMsg;
-    }
-
 
     @RequestMapping("/syncAttendanceFromBeisen")
     @Transactional(rollbackFor = Exception.class)

+ 110 - 20
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/task/TimingTask.java

@@ -52,6 +52,7 @@ import java.util.*;
 import java.util.concurrent.*;
 import java.util.stream.Collectors;
 import java.util.stream.IntStream;
+import java.util.stream.Stream;
 
 import static org.apache.logging.log4j.message.ParameterizedMessage.format;
 
@@ -1997,36 +1998,125 @@ public class TimingTask {
     //每天凌晨  2:30 获取前一天时间增量的人员数据  BeiSenHR---->工时管家  针对威派格
     @Scheduled(cron = "0 30 2 ? * *")
     public void getByTimeWindow(){
+        if(isDev){
+            return;
+        }
         List<UserWithBeisen> allBeisenList = userWithBeisenService.list(new LambdaQueryWrapper<UserWithBeisen>().eq(UserWithBeisen::getCompanyId, 936));
         List<UserWithBeisen> userWithBeisenList=new ArrayList<>();
         LocalDate now=LocalDate.now();
         DateTimeFormatter df=DateTimeFormatter.ofPattern("yyyy-MM-dd");
         String time=df.format(now.plusDays(1));
-        BeisenConfig beisenConfig = beisenConfigMapper.selectById(936);
-        if(beisenConfig!=null){
-            List<JSONArray> byTimeWindow = BeiSenUtils.getByTimeWindow("",time,time,beisenConfig.getAppKey(),beisenConfig.getAppSecret());
-            for (JSONArray array : byTimeWindow) {
-                for (int i = 0; i < array.size(); i++) {
-                    UserWithBeisen userWithBeisen=new UserWithBeisen();
-                    JSONObject targetItem = array.getJSONObject(i);
-                    JSONObject employeeInfo = targetItem.getJSONObject("employeeInfo");
-                    JSONObject recordInfo = targetItem.getJSONObject("recordInfo");
-                    userWithBeisen.setCompanyId(936);
-                    userWithBeisen.setJobNumber(recordInfo.getString("jobNumber"));
-                    userWithBeisen.setMobilePhone(employeeInfo.getString("mobilePhone"));
-                    userWithBeisen.setName(employeeInfo.getString("name"));
-                    userWithBeisen.setUserId(employeeInfo.getString("userID"));
-                    Optional<UserWithBeisen> first = allBeisenList.stream().filter(a -> a.getUserId().equals(employeeInfo.getString("userID"))).findFirst();
-                    if(first.isPresent()){
-                        userWithBeisen.setId(first.get().getId());
+        List<BeisenConfig> beisenConfigs = beisenConfigMapper.selectList(null);
+        for (BeisenConfig beisenConfig : beisenConfigs) {
+            if(beisenConfig!=null){
+                List<JSONArray> byTimeWindow = BeiSenUtils.getByTimeWindow("",time,time,beisenConfig.getAppKey(),beisenConfig.getAppSecret());
+                for (JSONArray array : byTimeWindow) {
+                    for (int i = 0; i < array.size(); i++) {
+                        UserWithBeisen userWithBeisen=new UserWithBeisen();
+                        JSONObject targetItem = array.getJSONObject(i);
+                        JSONObject employeeInfo = targetItem.getJSONObject("employeeInfo");
+                        JSONObject recordInfo = targetItem.getJSONObject("recordInfo");
+                        userWithBeisen.setCompanyId(beisenConfig.getCompanyId());
+                        userWithBeisen.setJobNumber(recordInfo.getString("jobNumber"));
+                        userWithBeisen.setMobilePhone(employeeInfo.getString("mobilePhone"));
+                        userWithBeisen.setName(employeeInfo.getString("name"));
+                        userWithBeisen.setUserId(employeeInfo.getString("userID"));
+                        Optional<UserWithBeisen> first = allBeisenList.stream().filter(a -> a.getUserId().equals(employeeInfo.getString("userID"))).findFirst();
+                        if(first.isPresent()){
+                            userWithBeisen.setId(first.get().getId());
+                        }
+                        userWithBeisenList.add(userWithBeisen);
                     }
-                    userWithBeisenList.add(userWithBeisen);
+                }
+                if(userWithBeisenList.size()>0){
+                    userWithBeisenService.saveOrUpdateBatch(userWithBeisenList);
                 }
             }
-            if(userWithBeisenList.size()>0){
-                userWithBeisenService.saveOrUpdateBatch(userWithBeisenList);
+        }
+    }
+
+    /**
+     * 每天凌晨2:50同步前一天的北森考勤数据 暂时固定公司id(5978)针对景昱
+     * */
+    @Scheduled(cron ="0 50 2 ? * *")
+    public void syncAttendanceFromBeisen(){
+        if(isDev){
+            return;
+        }
+        DateTimeFormatter df=DateTimeFormatter.ofPattern("yyyy-MM-dd");
+        DateTimeFormatter df1=DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
+        DateTimeFormatter df2=DateTimeFormatter.ofPattern("HH:mm");
+        String startDate=LocalDate.now().plusDays(1).format(df);
+        String endDate=LocalDate.now().plusDays(1).format(df);
+        List<User> userList = userMapper.selectList(new LambdaQueryWrapper<User>().eq(User::getCompanyId, 5978));
+        List<UserWithBeisen> userWithBeisenList = userWithBeisenService.list(new LambdaQueryWrapper<UserWithBeisen>().eq(UserWithBeisen::getCompanyId, 5978));
+        BeisenConfig beisenConfig = beisenConfigMapper.selectById(5978);
+        if(beisenConfig==null){
+            return;
+        }
+        //todo 获取到指定日期的考勤数据
+        JSONArray attendanceStatistics = BeiSenUtils.getAttendanceStatistics(startDate, endDate, beisenConfig.getAppKey(), beisenConfig.getAppSecret(), 1, 100);
+        //todo 获取到指定日期的加班数据
+        List<LocalDate> workDaysListInRange = WorkDayCalculateUtils.getWorkDaysListInRange(startDate, endDate, 1);
+        JSONArray allOverTimeList=new JSONArray();
+        List<UserFvTime> userFvTimeList=new ArrayList<>();
+        for (LocalDate localDate : workDaysListInRange) {
+            JSONArray overTimeList = BeiSenUtils.getOverTimeList(df.format(localDate), beisenConfig.getAppKey(), beisenConfig.getAppSecret(), 1, 100);
+            allOverTimeList.addAll(overTimeList);
+        }
+        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> 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());
+                Optional<LocalTime> max = maxLocalTimeList.stream().max(LocalTime::compareTo);
+                //获取最晚下班时间
+                if(first.isPresent()){
+                    boolean workDay = WorkDayCalculateUtils.isWorkDay(localDate);
+                    //todo:针对景昱 工作日默认以8小时工作制度加上加班时长 非工作日以加班时长为准
+                    Double workTime=8.0;
+                    Stream<JSONObject> overTimeStream = allOverTimeList.stream().map(elment -> (JSONObject) elment);
+                    Optional<UserWithBeisen> beisen = userWithBeisenList.stream().filter(u -> u.getJobNumber() != null && u.getJobNumber().equals(first.get().getJobNumber())).findFirst();
+                    List<JSONObject> overTimeList = overTimeStream.filter(a -> a.getString("StaffId").equals(beisen.get().getUserId())
+                            && a.getIntValue("ApproveStatus") == 2).collect(Collectors.toList());
+                    if(overTimeList.size()>0){
+                        double actualOverTimeDuration = overTimeList.stream().mapToDouble(i -> i.getDouble("ActualOverTimeDuration")).sum();
+                        if(workDay){
+                            workTime= workTime+actualOverTimeDuration;
+                        }else {
+                            workTime= actualOverTimeDuration;
+                        }
+                    }
+                    UserFvTime userFvTime=new UserFvTime();
+                    userFvTime.setWorkDate(localDate);
+                    userFvTime.setStartTime(min.isPresent()?df2.format(min.get()):"08:30");
+                    userFvTime.setEndTime(max.isPresent()?df2.format(max.get()):"17:30");
+                    userFvTime.setUserId(first.get().getId());
+                    userFvTime.setCompanyId(5978);
+                    userFvTime.setWorkHours(workTime.floatValue());
+                    UserFvTime one = userFvTimeService.getOne(new LambdaQueryWrapper<UserFvTime>().eq(UserFvTime::getCompanyId, 5978).eq(UserFvTime::getUserId, first.get().getId()).eq(UserFvTime::getWorkDate, localDate));
+                    if(one!=null){
+                        userFvTime.setId(one.getId());
+                    }
+                    userFvTimeList.add(userFvTime);
+                }
             }
         }
+        if(userFvTimeList.size()>0){
+            userFvTimeService.saveOrUpdateBatch(userFvTimeList);
+        }
     }
 
 

+ 0 - 1
fhKeeper/formulahousekeeper/timesheet/src/views/workReport/daily.vue

@@ -5385,7 +5385,6 @@
                 param.stateKey = this.stateKey
                 // param.departmentId = this.user.departmentId
                 console.log(param, '《=== 导出传的参数')
-                return
                 this.http.post( this.port.report.export, param,
                 res => {
                     this.exportingData = false;