1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980 |
- package com.yiidata.intergration.web.task;
- import com.yiidata.intergration.web.config.IntenetProperties;
- import com.yiidata.intergration.web.config.TaskProperties;
- import com.yiidata.intergration.web.modules.dingtalk.service.DingTalkMessageService;
- import com.yiidata.intergration.web.modules.dingtalk.task.CzscAnalysisTask;
- import com.yiidata.intergration.web.modules.dingtalk.task.XGAnalysisTask;
- import lombok.extern.slf4j.Slf4j;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.jdbc.core.JdbcTemplate;
- import org.springframework.stereotype.Component;
- import java.util.HashMap;
- import java.util.Map;
- import java.util.Optional;
- /**
- * <pre>
- *
- * Created by zhaopx.
- * User: zhaopx
- * Date: 2020/11/17
- * Time: 12:54
- *
- * </pre>
- *
- * @author zhaopx
- */
- @Component
- @Slf4j
- public class DefaultTaskFactory {
- @Autowired
- TaskProperties taskProperties;
- @Autowired
- IntenetProperties intenetProperties;
- @Autowired
- DingTalkMessageService dingTalkMessageService;
- @Autowired
- JdbcTemplate jdbcTemplate;
- /**
- * 根据 TaskInfo 生成 Task,不同 Task 类型
- * @param taskId TaskID
- * @param taskInfo
- * @return
- */
- public SuperTask newTask(String taskId, Map<String, Object> taskInfo) {
- String type = Optional.ofNullable((String)taskInfo.get("taskType")).orElse("TEST");
- switch (type) {
- case "CZSC_ANALYSIS":
- //缠中说禅 分析任务
- CzscAnalysisTask task = new CzscAnalysisTask(
- taskId, taskInfo);
- task.setDingTalkMessageService(dingTalkMessageService);
- task.setIntenetProperties(intenetProperties);
- task.setJdbcTemplate(jdbcTemplate);
- return task;
- case "XG_ANALYSIS":
- // 选股任务
- XGAnalysisTask xgAnalysisTask = new XGAnalysisTask(taskId, taskInfo);
- xgAnalysisTask.setDingTalkMessageService(dingTalkMessageService);
- xgAnalysisTask.setIntenetProperties(intenetProperties);
- xgAnalysisTask.setJdbcTemplate(jdbcTemplate);
- return xgAnalysisTask;
- default:
- // 测试任务,未知任务
- return new TestTask(taskId);
- }
- }
- }
|