linwe
2024-05-25 749f2fe0ee4061c502ab9a2c22773c1e2e51b595
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
58
59
package org.springblade.xxljob.jobhandler;
 
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.xxl.job.core.context.XxlJobHelper;
import com.xxl.job.core.handler.annotation.XxlJob;
import org.apache.logging.log4j.util.Strings;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springblade.modules.resource.service.IAttachDataService;
import org.springblade.modules.system.service.ILogService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
 
/**
 * 数据处理任务
 * @author zhongrj
 * @date 2024-05-25
 */
@Component
public class DataHandleJob {
 
    private static Logger logger = LoggerFactory.getLogger(LabelHandleJob.class);
 
    @Autowired
    private ILogService logService;
 
    @Autowired
    private IAttachDataService attachDataService;
 
    /**
     * 清理时间范围外的日志记录信息
     */
    @XxlJob("logJobHandler")
    public void logJobHandler (String param){
        XxlJobHelper.log("开始执行任务...清理时间范围外的日志记录信息");
        // 解析参数
        JSONObject jsonParam = JSON.parseObject(param);
//        String dayString = jsonParam.getString("day");
        // 开始执行
        boolean result = logService.removeLogs(param);
        XxlJobHelper.log("任务响应结果..." + result);
        // 结束
        XxlJobHelper.log("结束自动创建任务...");
    }
 
    /**
     * 附件临时文件信息清理
     */
    @XxlJob("attachDataJobHandler")
    public void attachDataJobHandler (String param){
        XxlJobHelper.log("开始执行任务...附件临时文件信息清理");
        // 开始执行
        boolean result = attachDataService.removeBladeAttachDatas(param);
        XxlJobHelper.log("任务响应结果..." + result);
        // 结束
        XxlJobHelper.log("结束自动创建任务...");
    }
}