啊鑫
2025-02-18 f91c09e452ce121a66755e8b6f133efeac4edead
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
package com.gs.xky.task;
 
 
import cn.hutool.core.collection.ListUtil;
import com.gs.xky.config.DingTalkParam;
import com.gs.xky.config.DingTalkResponse;
import com.gs.xky.dto.EmployeeInfo;
import com.gs.xky.service.ApiService;
import com.gs.xky.service.MesStaffService;
import com.gs.xky.service.XkyService;
import lombok.RequiredArgsConstructor;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
 
import java.io.IOException;
import java.util.List;
import java.util.stream.Collectors;
 
@Component
@RequiredArgsConstructor
public class ScheduledTasks {
 
    private final XkyService xkyService;
 
    private final ApiService apiService;
 
    private final MesStaffService staffService;
 
    /**
     * 每五分钟执行一次
     * 获取设备最近的一条记录
     *
     * @return void
     * @author tjx
     * @description TODO
     * @date 2024/9/27 21:48
     */
    @Scheduled(cron = "0 0/5 * * * ?")
    public void getDeviceRealTimeData() throws IOException {
        xkyService.GetSaveDetail();
    }
 
    @Scheduled(cron = "0 0 0/1 * * ?")
    public void getDinTalkData() throws IOException {
        DingTalkParam dingTalkParam = new DingTalkParam(1);
 
        DingTalkResponse<EmployeeInfo> employeeInfoDingTalkResponse = apiService.sendListRequest(dingTalkParam, EmployeeInfo.class, "http://192.168.1.64/eHR/eHRExternalService/Service.ashx");
 
 
        List<EmployeeInfo> collect = employeeInfoDingTalkResponse.getData().stream().filter(s -> "造梦者(浙江)科技有限公司".equals(s.getCUnitName())).collect(Collectors.toList());
        System.out.println(collect.size());
 
        List<List<EmployeeInfo>> partition = ListUtil.partition(collect, 100);
 
        partition.forEach(staffService::UpdateStaff);
    }
}