Browse Source

优化逻辑

pull/4/head
lcr 5 months ago
parent
commit
0e9227bc42
6 changed files with 111 additions and 55 deletions
  1. +25
    -23
      ruoyi-business/src/main/java/com/ruoyi/business/controller/ApplyPlanController.java
  2. +5
    -0
      ruoyi-business/src/main/java/com/ruoyi/business/mapper/ApplyPlanMapper.java
  3. +8
    -0
      ruoyi-business/src/main/java/com/ruoyi/business/service/IApplyPlanService.java
  4. +22
    -5
      ruoyi-business/src/main/java/com/ruoyi/business/service/impl/ApplyPlanServiceImpl.java
  5. +13
    -1
      ruoyi-business/src/main/java/com/ruoyi/business/util/YinDaoHttpUtils.java
  6. +38
    -26
      ruoyi-business/src/main/resources/mapper/business/ApplyPlanMapper.xml

+ 25
- 23
ruoyi-business/src/main/java/com/ruoyi/business/controller/ApplyPlanController.java View File

@@ -39,15 +39,23 @@ import com.ruoyi.common.core.page.TableDataInfo;
@Api(tags = "应用执行计划管理接口") @Api(tags = "应用执行计划管理接口")
@RestController @RestController
@RequestMapping("/business/ctApplyPlan") @RequestMapping("/business/ctApplyPlan")
public class ApplyPlanController extends BaseController
{
public class ApplyPlanController extends BaseController {
@Autowired @Autowired
private IApplyPlanService applyPlanService; private IApplyPlanService applyPlanService;


/** /**
* 查询应用执行计划管理列表
* 重新运行
*/
@ApiOperation(value = "重新运行", httpMethod = "POST", response = ApplyPlan.class)
@PostMapping("/appRetry")
public AjaxResult appRetry(@RequestBody JobQueryBO jobQueryBO) throws IllegalAccessException {
return toAjax(applyPlanService.appRetry(jobQueryBO));
}

/**
* 停止计划运行
*/ */
@ApiOperation(value="停止计划运行", httpMethod = "POST", response = ApplyPlan.class)
@ApiOperation(value = "停止计划运行", httpMethod = "POST", response = ApplyPlan.class)
@PostMapping("/stopRun") @PostMapping("/stopRun")
public AjaxResult stopRun(@RequestBody JobQueryBO jobQueryBO) throws IllegalAccessException { public AjaxResult stopRun(@RequestBody JobQueryBO jobQueryBO) throws IllegalAccessException {
return toAjax(applyPlanService.stopRun(jobQueryBO)); return toAjax(applyPlanService.stopRun(jobQueryBO));
@@ -56,10 +64,9 @@ public class ApplyPlanController extends BaseController
/** /**
* 查询应用执行计划管理列表 * 查询应用执行计划管理列表
*/ */
@ApiOperation(value="查询应用执行计划管理列表", httpMethod = "GET", response = ApplyPlan.class)
@ApiOperation(value = "查询应用执行计划管理列表", httpMethod = "GET", response = ApplyPlan.class)
@GetMapping("/list") @GetMapping("/list")
public TableDataInfo list(ApplyPlan applyPlan)
{
public TableDataInfo list(ApplyPlan applyPlan) {
startPage(); startPage();
List<ApplyPlan> list = applyPlanService.list(applyPlan); List<ApplyPlan> list = applyPlanService.list(applyPlan);
return getDataTable(list); return getDataTable(list);
@@ -68,11 +75,10 @@ public class ApplyPlanController extends BaseController
/** /**
* 导出应用执行计划管理列表 * 导出应用执行计划管理列表
*/ */
@ApiOperation(value="导出应用执行计划管理列表", httpMethod = "POST")
@ApiOperation(value = "导出应用执行计划管理列表", httpMethod = "POST")
@Log(title = "应用执行计划管理", businessType = BusinessType.EXPORT) @Log(title = "应用执行计划管理", businessType = BusinessType.EXPORT)
@PostMapping("/export") @PostMapping("/export")
public void export(HttpServletResponse response, ApplyPlan applyPlan)
{
public void export(HttpServletResponse response, ApplyPlan applyPlan) {
List<ApplyPlan> list = applyPlanService.list(applyPlan); List<ApplyPlan> list = applyPlanService.list(applyPlan);
ExcelUtil<ApplyPlan> util = new ExcelUtil<ApplyPlan>(ApplyPlan.class); ExcelUtil<ApplyPlan> util = new ExcelUtil<ApplyPlan>(ApplyPlan.class);
util.exportExcel(response, list, "应用执行计划管理数据"); util.exportExcel(response, list, "应用执行计划管理数据");
@@ -81,43 +87,39 @@ public class ApplyPlanController extends BaseController
/** /**
* 获取应用执行计划管理详细信息 * 获取应用执行计划管理详细信息
*/ */
@ApiOperation(value="获取应用执行计划管理详细信息", httpMethod = "GET", response = ApplyPlan.class)
@ApiOperation(value = "获取应用执行计划管理详细信息", httpMethod = "GET", response = ApplyPlan.class)
@GetMapping(value = "/{id}") @GetMapping(value = "/{id}")
public AjaxResult getInfo(@PathVariable("id") Long id)
{
public AjaxResult getInfo(@PathVariable("id") Long id) {
return success(applyPlanService.getById(id)); return success(applyPlanService.getById(id));
} }


/** /**
* 新增应用执行计划管理 * 新增应用执行计划管理
*/ */
@ApiOperation(value="新增应用执行计划管理", httpMethod = "POST")
@ApiOperation(value = "新增应用执行计划管理", httpMethod = "POST")
@Log(title = "应用执行计划管理", businessType = BusinessType.INSERT) @Log(title = "应用执行计划管理", businessType = BusinessType.INSERT)
@PostMapping @PostMapping
public AjaxResult add(@RequestBody AddApplyPlanBO addApplyPlanBO)
{
public AjaxResult add(@RequestBody AddApplyPlanBO addApplyPlanBO) {
return toAjax(applyPlanService.save(addApplyPlanBO)); return toAjax(applyPlanService.save(addApplyPlanBO));
} }


/** /**
* 修改应用执行计划管理 * 修改应用执行计划管理
*/ */
@ApiOperation(value="修改应用执行计划管理", httpMethod = "PUT")
@ApiOperation(value = "修改应用执行计划管理", httpMethod = "PUT")
@Log(title = "应用执行计划管理", businessType = BusinessType.UPDATE) @Log(title = "应用执行计划管理", businessType = BusinessType.UPDATE)
@PutMapping @PutMapping
public AjaxResult edit(@RequestBody AddApplyPlanBO addApplyPlanBO)
{
public AjaxResult edit(@RequestBody AddApplyPlanBO addApplyPlanBO) {
return toAjax(applyPlanService.update(addApplyPlanBO)); return toAjax(applyPlanService.update(addApplyPlanBO));
} }


/** /**
* 删除应用执行计划管理 * 删除应用执行计划管理
*/ */
@ApiOperation(value="删除应用执行计划管理", httpMethod = "DELETE")
@ApiOperation(value = "删除应用执行计划管理", httpMethod = "DELETE")
@Log(title = "应用执行计划管理", businessType = BusinessType.DELETE) @Log(title = "应用执行计划管理", businessType = BusinessType.DELETE)
@DeleteMapping("/{ids}")
public AjaxResult remove(@PathVariable Long[] ids)
{
@DeleteMapping("/{ids}")
public AjaxResult remove(@PathVariable Long[] ids) {
return toAjax(applyPlanService.removeByIds(Arrays.asList(ids))); return toAjax(applyPlanService.removeByIds(Arrays.asList(ids)));
} }
} }

+ 5
- 0
ruoyi-business/src/main/java/com/ruoyi/business/mapper/ApplyPlanMapper.java View File

@@ -21,4 +21,9 @@ public interface ApplyPlanMapper extends BaseMapper<ApplyPlan>
*/ */
List<ApplyPlan> selectApplyPlanList(ApplyPlan applyPlan); List<ApplyPlan> selectApplyPlanList(ApplyPlan applyPlan);


/**
* 重新运行
* @return
*/
Integer appRetry(String taskUuid);
} }

+ 8
- 0
ruoyi-business/src/main/java/com/ruoyi/business/service/IApplyPlanService.java View File

@@ -17,6 +17,14 @@ import com.ruoyi.business.domain.vo.JobQueryVO;
*/ */
public interface IApplyPlanService extends IService<ApplyPlan> { public interface IApplyPlanService extends IService<ApplyPlan> {


/**
* 重新运行
*
* @param
* @return
*/
boolean appRetry(JobQueryBO jobQueryBO) throws IllegalAccessException;

/** /**
* 停止运行 * 停止运行
* *


+ 22
- 5
ruoyi-business/src/main/java/com/ruoyi/business/service/impl/ApplyPlanServiceImpl.java View File

@@ -56,6 +56,23 @@ public class ApplyPlanServiceImpl extends ServiceImpl<ApplyPlanMapper, ApplyPlan
@Autowired @Autowired
private IResourceLibraryService resourceLibraryService; private IResourceLibraryService resourceLibraryService;


/**
* 重新运行
*
* @param jobQueryBO
* @return
* @throws IllegalAccessException
*/
@Override
public boolean appRetry(JobQueryBO jobQueryBO) throws IllegalAccessException {
BaseDTO baseDTO = YinDaoHttpUtils.appRetry(jobQueryBO);
if (baseDTO.getSuccess()) {
return baseMapper.appRetry(jobQueryBO.getJobUuid()) > 0;
} else {
return false;
}
}

/** /**
* 停止计划运行 * 停止计划运行
* *
@@ -87,7 +104,7 @@ public class ApplyPlanServiceImpl extends ServiceImpl<ApplyPlanMapper, ApplyPlan
// 只获取空闲的机器人 // 只获取空闲的机器人
List<ListRebotVO> listRebotVos = YinDaoHttpUtils.listRebot(listRebotBO); List<ListRebotVO> listRebotVos = YinDaoHttpUtils.listRebot(listRebotBO);
if (listRebotVos.isEmpty()) { if (listRebotVos.isEmpty()) {
log.error("暂无空闲机器人");
log.debug("暂无空闲机器人");
// 刷新机器人数据 // 刷新机器人数据
// rebotService.syn(new Rebot()); // rebotService.syn(new Rebot());
return false; return false;
@@ -170,7 +187,7 @@ public class ApplyPlanServiceImpl extends ServiceImpl<ApplyPlanMapper, ApplyPlan
} }
}); });
if (execApplyPlan.isEmpty()) { if (execApplyPlan.isEmpty()) {
log.error("没有待执行的计划");
log.debug("没有待执行的计划");
return false; return false;
} }


@@ -181,7 +198,7 @@ public class ApplyPlanServiceImpl extends ServiceImpl<ApplyPlanMapper, ApplyPlan
// 只获取空闲的机器人 // 只获取空闲的机器人
List<ListRebotVO> listRebotVos = YinDaoHttpUtils.listRebot(listRebotBO); List<ListRebotVO> listRebotVos = YinDaoHttpUtils.listRebot(listRebotBO);
if (listRebotVos.isEmpty()) { if (listRebotVos.isEmpty()) {
log.error("暂无空闲机器人");
log.debug("暂无空闲机器人");
// 刷新机器人数据 // 刷新机器人数据
// rebotService.syn(new Rebot()); // rebotService.syn(new Rebot());
return false; return false;
@@ -352,7 +369,7 @@ public class ApplyPlanServiceImpl extends ServiceImpl<ApplyPlanMapper, ApplyPlan
// 只获取空闲的机器人 // 只获取空闲的机器人
List<ListRebotVO> listRebotVos = YinDaoHttpUtils.listRebot(listRebotBO); List<ListRebotVO> listRebotVos = YinDaoHttpUtils.listRebot(listRebotBO);
if (listRebotVos.isEmpty()) { if (listRebotVos.isEmpty()) {
log.error("暂无空闲机器人");
log.debug("暂无空闲机器人");
// 刷新机器人数据 // 刷新机器人数据
// rebotService.syn(new Rebot()); // rebotService.syn(new Rebot());
return false; return false;
@@ -447,7 +464,7 @@ public class ApplyPlanServiceImpl extends ServiceImpl<ApplyPlanMapper, ApplyPlan
robotParam.setType(item.getResourceType()); robotParam.setType(item.getResourceType());
return robotParam; return robotParam;
}).collect(Collectors.toList()); }).collect(Collectors.toList());
if (paramList.isEmpty()) {
if (!paramList.isEmpty()) {
// json集合转字符串 // json集合转字符串
applyPlan.setPlanParams(JSONArray.toJSONString(paramList)); applyPlan.setPlanParams(JSONArray.toJSONString(paramList));
} }


+ 13
- 1
ruoyi-business/src/main/java/com/ruoyi/business/util/YinDaoHttpUtils.java View File

@@ -38,6 +38,8 @@ public class YinDaoHttpUtils {
private static final String APP_START = REQUEST_PREFIX + "/dispatch/v2/job/start"; private static final String APP_START = REQUEST_PREFIX + "/dispatch/v2/job/start";
// 停止应用 // 停止应用
private static final String APP_STOP = REQUEST_PREFIX + "/dispatch/v2/job/stop"; private static final String APP_STOP = REQUEST_PREFIX + "/dispatch/v2/job/stop";
// 重新运行
private static final String APP_RETRY = REQUEST_PREFIX + "/dispatch/v2/job/retry";
// 查询应用运行结果 // 查询应用运行结果
private static final String QUERY_APP_START_RESULT = REQUEST_PREFIX + "/dispatch/v2/job/query"; private static final String QUERY_APP_START_RESULT = REQUEST_PREFIX + "/dispatch/v2/job/query";
// 查询应用运行日志(异常时可以查询原因) // 查询应用运行日志(异常时可以查询原因)
@@ -55,7 +57,7 @@ public class YinDaoHttpUtils {
} }


/** /**
* 启动应用
* 停止运行
*/ */
public static BaseDTO appStop(JobQueryBO jobQueryBO) throws IllegalAccessException { public static BaseDTO appStop(JobQueryBO jobQueryBO) throws IllegalAccessException {
// 实体类转map // 实体类转map
@@ -64,6 +66,16 @@ public class YinDaoHttpUtils {
return baseDTO; return baseDTO;
} }


/**
* 重新运行
*/
public static BaseDTO appRetry(JobQueryBO jobQueryBO) throws IllegalAccessException {
// 实体类转map
Map<String, Object> data = BeanToMapUtil.convertEntityToMap(jobQueryBO);
BaseDTO baseDTO = sendPost(APP_RETRY, data);
return baseDTO;
}

/** /**
* 查询应用运行结果 * 查询应用运行结果
*/ */


+ 38
- 26
ruoyi-business/src/main/resources/mapper/business/ApplyPlanMapper.xml View File

@@ -22,7 +22,7 @@
<!-- 应用类型枚举(app:应用 activity:指令) --> <!-- 应用类型枚举(app:应用 activity:指令) -->
<result property="appType" column="app_type"/> <result property="appType" column="app_type"/>
<!-- 是否支持应用参数 --> <!-- 是否支持应用参数 -->
<result property="supportParam" column="support_param" />
<result property="supportParam" column="support_param"/>
<!-- 计划参数 --> <!-- 计划参数 -->
<result property="planParams" column="plan_params"/> <result property="planParams" column="plan_params"/>
<!-- 输出参数 --> <!-- 输出参数 -->
@@ -38,25 +38,25 @@
<!-- 执行表达式 --> <!-- 执行表达式 -->
<result property="cronExpression" column="cron_expression"/> <result property="cronExpression" column="cron_expression"/>
<!-- 上次执行时间 --> <!-- 上次执行时间 -->
<result property="lastExecTime" column="last_exec_time" />
<result property="lastExecTime" column="last_exec_time"/>
<!-- 下次执行时间 --> <!-- 下次执行时间 -->
<result property="nextExecTime" column="next_exec_time" />
<result property="nextExecTime" column="next_exec_time"/>
<!-- 任务执行状态 --> <!-- 任务执行状态 -->
<result property="taskStatus" column="task_status" />
<result property="taskStatus" column="task_status"/>
<!-- 任务运行uuid --> <!-- 任务运行uuid -->
<result property="taskUuid" column="task_uuid" />
<result property="taskUuid" column="task_uuid"/>
<!-- 任务开始运行的时间 --> <!-- 任务开始运行的时间 -->
<result property="startTime" column="start_time" />
<result property="startTime" column="start_time"/>
<!-- 任务结束运行的时间 --> <!-- 任务结束运行的时间 -->
<result property="endTime" column="end_time" />
<result property="endTime" column="end_time"/>
<!-- 实际耗时 --> <!-- 实际耗时 -->
<result property="planTime" column="plan_time" />
<result property="planTime" column="plan_time"/>
<!-- 节约时间 --> <!-- 节约时间 -->
<result property="timeSaving" column="time_saving" />
<result property="timeSaving" column="time_saving"/>
<!-- 部门id --> <!-- 部门id -->
<result property="deptId" column="dept_id" />
<result property="deptId" column="dept_id"/>
<!-- 部门名称 --> <!-- 部门名称 -->
<result property="deptName" column="dept_name" />
<result property="deptName" column="dept_name"/>
<!-- 创建者 --> <!-- 创建者 -->
<result property="createBy" column="create_by"/> <result property="createBy" column="create_by"/>
<!-- 创建时间 --> <!-- 创建时间 -->
@@ -120,26 +120,38 @@
<if test="robotName != null and robotName != ''">and robot_name like concat(#{robotName}, '%')</if> <if test="robotName != null and robotName != ''">and robot_name like concat(#{robotName}, '%')</if>
<if test="appTypeName != null and appTypeName != ''">and app_type_name like concat(#{appTypeName}, '%') <if test="appTypeName != null and appTypeName != ''">and app_type_name like concat(#{appTypeName}, '%')
</if> </if>
<if test="supportParam != null "> and support_param = #{supportParam}</if>
<if test="supportParam != null ">and support_param = #{supportParam}</if>
<if test="appName != null and appName != ''">and app_name like concat(#{appName}, '%')</if> <if test="appName != null and appName != ''">and app_name like concat(#{appName}, '%')</if>
<if test="appId != null and appId != ''">and app_id = #{appId}</if> <if test="appId != null and appId != ''">and app_id = #{appId}</if>
<if test="excType != null and excType != ''"> and exc_type = #{excType}</if>
<if test="excTime != null "> and exc_time = #{excTime}</if>
<if test="cronExpression != null and cronExpression != ''"> and cron_expression = #{cronExpression}</if>
<if test="lastExecTime != null "> and last_exec_time = #{lastExecTime}</if>
<if test="nextExecTime != null "> and next_exec_time = #{nextExecTime}</if>
<if test="taskStatus != null and taskStatus != ''"> and task_status = #{taskStatus}</if>
<if test="taskUuid != null and taskUuid != ''"> and task_uuid = #{taskUuid}</if>
<if test="manualTime != null and manualTime != ''"> and manual_time = #{manualTime}</if>
<if test="startTime != null "> and start_time = #{startTime}</if>
<if test="endTime != null "> and end_time = #{endTime}</if>
<if test="planTime != null and planTime != ''"> and plan_time = #{planTime}</if>
<if test="timeSaving != null and timeSaving != ''"> and time_saving = #{timeSaving}</if>
<if test="deptId != null "> and dept_id = #{deptId}</if>
<if test="deptName != null and deptName != ''"> and dept_name like concat(#{deptName}, '%')</if>
<if test="excType != null and excType != ''">and exc_type = #{excType}</if>
<if test="excTime != null ">and exc_time = #{excTime}</if>
<if test="cronExpression != null and cronExpression != ''">and cron_expression = #{cronExpression}</if>
<if test="lastExecTime != null ">and last_exec_time = #{lastExecTime}</if>
<if test="nextExecTime != null ">and next_exec_time = #{nextExecTime}</if>
<if test="taskStatus != null and taskStatus != ''">and task_status = #{taskStatus}</if>
<if test="taskUuid != null and taskUuid != ''">and task_uuid = #{taskUuid}</if>
<if test="manualTime != null and manualTime != ''">and manual_time = #{manualTime}</if>
<if test="startTime != null ">and start_time = #{startTime}</if>
<if test="endTime != null ">and end_time = #{endTime}</if>
<if test="planTime != null and planTime != ''">and plan_time = #{planTime}</if>
<if test="timeSaving != null and timeSaving != ''">and time_saving = #{timeSaving}</if>
<if test="deptId != null ">and dept_id = #{deptId}</if>
<if test="deptName != null and deptName != ''">and dept_name like concat(#{deptName}, '%')</if>
</where> </where>
<!-- 数据范围过滤 --> <!-- 数据范围过滤 -->
${params.dataScope} ${params.dataScope}
order by plan.priority asc,plan.create_time desc order by plan.priority asc,plan.create_time desc
</select> </select>

<update id="appRetry">
update ct_apply_plan
set task_status = 'await_create',
start_time = null,
end_time = null,
plan_time = null,
time_saving = null,
last_exec_time = null,
next_exec_time = null
where task_uuid = #{taskUuid}
</update>
</mapper> </mapper>

Loading…
Cancel
Save