Browse Source

add queryByProcessDefinitionId

pull/2/head
ligang 6 years ago
parent
commit
e577776c03
  1. 2
      escheduler-api/src/main/java/cn/escheduler/api/service/ProcessDefinitionService.java
  2. 24
      escheduler-dao/src/main/java/cn/escheduler/dao/mapper/ScheduleMapper.java
  3. 14
      escheduler-dao/src/main/java/cn/escheduler/dao/mapper/ScheduleMapperProvider.java

2
escheduler-api/src/main/java/cn/escheduler/api/service/ProcessDefinitionService.java

@ -370,7 +370,7 @@ public class ProcessDefinitionService extends BaseDAGService {
}
// get the timing according to the process definition
List<Schedule> schedules = scheduleMapper.selectAllByProcessDefineArray(new int[processDefinitionId]);
List<Schedule> schedules = scheduleMapper.queryByProcessDefinitionId(processDefinitionId);
if (!schedules.isEmpty() && schedules.size() > 1) {
logger.warn("scheduler num is {},Greater than 1",schedules.size());
putMsg(result, Status.DELETE_PROCESS_DEFINE_BY_ID_ERROR);

24
escheduler-dao/src/main/java/cn/escheduler/dao/mapper/ScheduleMapper.java

@ -173,6 +173,30 @@ public interface ScheduleMapper {
@SelectProvider(type = ScheduleMapperProvider.class, method = "selectAllByProcessDefineArray")
List<Schedule> selectAllByProcessDefineArray(@Param("processDefineIds") int[] processDefineIds);
/**
* query schedule list by definition id
* @param processDefinitionId
* @return
*/
@Results(value = {
@Result(property = "id", column = "id", id = true, javaType = Integer.class, jdbcType = JdbcType.INTEGER),
@Result(property = "processDefinitionId", column = "process_definition_id", id = true, javaType = int.class, jdbcType = JdbcType.INTEGER),
@Result(property = "startTime", column = "start_time", javaType = Date.class, jdbcType = JdbcType.TIMESTAMP),
@Result(property = "endTime", column = "end_time", javaType = Date.class, jdbcType = JdbcType.TIMESTAMP),
@Result(property = "crontab", column = "crontab", javaType = String.class, jdbcType = JdbcType.VARCHAR),
@Result(property = "failureStrategy", column = "failure_strategy", typeHandler = EnumOrdinalTypeHandler.class, javaType = FailureStrategy.class, jdbcType = JdbcType.TINYINT),
@Result(property = "warningType", column = "warning_type", typeHandler = EnumOrdinalTypeHandler.class, javaType = WarningType.class, jdbcType = JdbcType.TINYINT),
@Result(property = "createTime", column = "create_time", javaType = Date.class, jdbcType = JdbcType.TIMESTAMP),
@Result(property = "updateTime", column = "update_time", javaType = Date.class, jdbcType = JdbcType.TIMESTAMP),
@Result(property = "userId", column = "user_id", javaType = int.class, jdbcType = JdbcType.INTEGER),
@Result(property = "releaseState", column = "release_state", typeHandler = EnumOrdinalTypeHandler.class, javaType = ReleaseState.class, jdbcType = JdbcType.TINYINT),
@Result(property = "warningGroupId", column = "warning_group_id", javaType = int.class, jdbcType = JdbcType.INTEGER),
@Result(property = "workerGroupId", column = "worker_group_id", javaType = int.class, jdbcType = JdbcType.INTEGER),
@Result(property = "processInstancePriority", column = "process_instance_priority", javaType = Priority.class, typeHandler = EnumOrdinalTypeHandler.class, jdbcType = JdbcType.TINYINT)
})
@SelectProvider(type = ScheduleMapperProvider.class, method = "queryByProcessDefinitionId")
List<Schedule> queryByProcessDefinitionId(@Param("processDefinitionId") int processDefinitionId);
/**
* delete schedule by id
* @param scheduleId

14
escheduler-dao/src/main/java/cn/escheduler/dao/mapper/ScheduleMapperProvider.java

@ -181,6 +181,20 @@ public class ScheduleMapperProvider {
}}.toString();
}
/**
* query schedule by process definition id
* @param parameter
* @return
*/
public String queryByProcessDefinitionId(Map<String, Object> parameter) {
return new SQL() {{
SELECT("*");
FROM(DB_NAME);
WHERE("process_definition_id = #{processDefinitionId}");
}}.toString();
}
/**
* delete schedule by id
*

Loading…
Cancel
Save