kimi
2020-05-27 c007f0ca1785db093d48f4846cda82fe8e955765
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
package com.highdatas.mdm.job;
 
import com.highdatas.mdm.entity.SysAssemble;
import com.highdatas.mdm.pojo.Result;
import com.highdatas.mdm.service.ISysAssembleService;
import com.highdatas.mdm.util.DbUtils;
import com.xxl.job.core.biz.model.ReturnT;
import com.xxl.job.core.handler.annotation.XxlJob;
import com.xxl.job.core.log.XxlJobLogger;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
 
import java.util.List;
 
 
/**
 * @author kimi
 * @description xxljob执行job的handler类
 * @date 2020-03-02 9:35
 */
@Slf4j
@Component
public class XxlJobHandler {
    @Autowired
    ISysAssembleService assembleService;
 
    @XxlJob("assembleJob")
    public ReturnT<String> assembleJobHandler(String assembleId) throws Exception {
        XxlJobLogger.log("assemble Job start");
        List<String> split = DbUtils.split(assembleId, "&&");
        if (split.size() < 1) {
            XxlJobLogger.log("params: assemble is not found");
            return ReturnT.FAIL;
        }
        assembleId = split.get(0);
        SysAssemble assemble = assembleService.selectById(assembleId);
        if (assemble == null) {
            XxlJobLogger.log("params: assemble is not found");
        }
 
        Result run = assembleService.run(assembleId);
        XxlJobLogger.log("log info:" + run.getMessage());
        if (run.getSuccess()) {
            return ReturnT.SUCCESS;
        }else {
            return ReturnT.FAIL;
        }
    }
 
}