啊鑫
2025-05-11 e9f2a48f3e8df3af26a270341e9ed1e5b79eda68
src/main/java/com/gs/xky/task/ScheduledTasks.java
@@ -1,18 +1,33 @@
package com.gs.xky.task;
import com.gs.xky.service.XkyService;
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.entity.MesInvItemArn;
import com.gs.xky.service.*;
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;
    private final DeliveryNoticeService deliveryNoticeService;
    private final MesInvItemArnService invItemArnService;
    /**
     * 每五分钟执行一次
@@ -27,4 +42,26 @@
    public void getDeviceRealTimeData() throws IOException {
        xkyService.GetSaveDetail();
    }
    @Scheduled(cron = "10 3,8,13,18,23,28,33,38,43,48,53,58 * * * ?")
    public void compensateMethod() throws IOException {
        // 补偿逻辑
        List<MesInvItemArn> itemArnMinus = invItemArnService.getItemArnMinus();
        deliveryNoticeService.processMesInvItemArnStatusAsync(itemArnMinus);
    }
    @Scheduled(cron = "0 0/53 * * * ?")
    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);
    }
}