@@ -57,7 +57,7 @@ public class ApplyController extends BaseController { | |||||
@ApiOperation(value = "查询所有应用列表", httpMethod = "GET", response = Apply.class) | @ApiOperation(value = "查询所有应用列表", httpMethod = "GET", response = Apply.class) | ||||
@GetMapping("/listAll") | @GetMapping("/listAll") | ||||
public AjaxResult listAll(Apply apply) { | public AjaxResult listAll(Apply apply) { | ||||
List<Apply> list = applyService.list(apply); | |||||
List<Apply> list = applyService.listAll(apply); | |||||
return AjaxResult.success(list); | return AjaxResult.success(list); | ||||
} | } | ||||
@@ -80,6 +80,10 @@ public class Apply extends BaseEntity | |||||
@Excel(name = "是否支持应用参数") | @Excel(name = "是否支持应用参数") | ||||
@ApiModelProperty(name="supportParam",value = "是否支持应用参数") | @ApiModelProperty(name="supportParam",value = "是否支持应用参数") | ||||
private Integer supportParam; | private Integer supportParam; | ||||
/** 应用参数 */ | |||||
@Excel(name = "应用参数") | |||||
@ApiModelProperty(name="param",value = "应用参数") | |||||
private String param; | |||||
/** icon图下载地址 */ | /** icon图下载地址 */ | ||||
@Excel(name = "icon图下载地址") | @Excel(name = "icon图下载地址") | ||||
@ApiModelProperty(name="icon",value = "icon图下载地址") | @ApiModelProperty(name="icon",value = "icon图下载地址") | ||||
@@ -74,6 +74,11 @@ public class ApplyPlan extends BaseEntity | |||||
@ApiModelProperty(name="appType",value = "应用类型枚举") | @ApiModelProperty(name="appType",value = "应用类型枚举") | ||||
private String appType; | private String appType; | ||||
/** 是否支持应用参数 */ | |||||
@Excel(name = "是否支持应用参数") | |||||
@ApiModelProperty(name="supportParam",value = "是否支持应用参数") | |||||
private Integer supportParam; | |||||
/** 计划参数 */ | /** 计划参数 */ | ||||
@Excel(name = "计划参数") | @Excel(name = "计划参数") | ||||
@ApiModelProperty(name="planParams",value = "计划参数") | @ApiModelProperty(name="planParams",value = "计划参数") | ||||
@@ -77,6 +77,11 @@ public class AddApplyPlanBO extends BaseEntity | |||||
@ApiModelProperty(name="manualTime",value = "预计人工耗时") | @ApiModelProperty(name="manualTime",value = "预计人工耗时") | ||||
private String manualTime; | private String manualTime; | ||||
/** 是否支持应用参数 */ | |||||
@Excel(name = "是否支持应用参数") | |||||
@ApiModelProperty(name="supportParam",value = "是否支持应用参数") | |||||
private Integer supportParam; | |||||
/** 参数 */ | /** 参数 */ | ||||
@Excel(name = "参数") | @Excel(name = "参数") | ||||
@ApiModelProperty(name="planParams",value = "参数") | @ApiModelProperty(name="planParams",value = "参数") | ||||
@@ -89,7 +89,7 @@ public class ApplyStartBO { | |||||
* 应用运行参数 | * 应用运行参数 | ||||
*/ | */ | ||||
@Data | @Data | ||||
private static class RobotParam { | |||||
public static class RobotParam { | |||||
// 参数名 | // 参数名 | ||||
private String name; | private String name; | ||||
// 参数值 | // 参数值 | ||||
@@ -21,4 +21,12 @@ public interface ApplyMapper extends BaseMapper<Apply> | |||||
*/ | */ | ||||
List<Apply> selectApplyList(Apply apply); | List<Apply> selectApplyList(Apply apply); | ||||
/** | |||||
* 查询所有应用信息列表 | |||||
* | |||||
* @param apply 应用信息管理 | |||||
* @return 应用信息管理集合 | |||||
*/ | |||||
List<Apply> selectApplyAllList(Apply apply); | |||||
} | } |
@@ -30,6 +30,12 @@ public interface IApplyPlanService extends IService<ApplyPlan> { | |||||
*/ | */ | ||||
boolean execPlan(ApplyStartBO applyStartBO) throws IllegalAccessException; | boolean execPlan(ApplyStartBO applyStartBO) throws IllegalAccessException; | ||||
/** | |||||
* 定时查询指定时间执行的数据 | |||||
* @return | |||||
*/ | |||||
boolean runAppBySetTime() throws IllegalAccessException; | |||||
/** | /** | ||||
* 创建计划 | * 创建计划 | ||||
* @param addApplyPlanBO | * @param addApplyPlanBO | ||||
@@ -41,4 +41,12 @@ public interface IApplyService extends IService<Apply> | |||||
*/ | */ | ||||
List<Apply> list(Apply apply); | List<Apply> list(Apply apply); | ||||
/** | |||||
* 查询所有应用信息列表 | |||||
* | |||||
* @param apply 应用信息管理 | |||||
* @return 应用信息管理集合 | |||||
*/ | |||||
List<Apply> listAll(Apply apply); | |||||
} | } |
@@ -4,6 +4,8 @@ import java.util.*; | |||||
import java.util.concurrent.atomic.AtomicBoolean; | import java.util.concurrent.atomic.AtomicBoolean; | ||||
import java.util.stream.Collectors; | import java.util.stream.Collectors; | ||||
import com.alibaba.fastjson2.JSON; | |||||
import com.alibaba.fastjson2.JSONArray; | |||||
import com.ruoyi.business.domain.Apply; | import com.ruoyi.business.domain.Apply; | ||||
import com.ruoyi.business.domain.Rebot; | import com.ruoyi.business.domain.Rebot; | ||||
import com.ruoyi.business.domain.bo.*; | import com.ruoyi.business.domain.bo.*; | ||||
@@ -18,6 +20,7 @@ import com.ruoyi.common.enums.ExcTypeStatus; | |||||
import com.ruoyi.common.enums.PlanRunStatus; | import com.ruoyi.common.enums.PlanRunStatus; | ||||
import com.ruoyi.common.enums.RebotStatus; | import com.ruoyi.common.enums.RebotStatus; | ||||
import com.ruoyi.common.utils.SecurityUtils; | import com.ruoyi.common.utils.SecurityUtils; | ||||
import com.ruoyi.common.utils.StringUtils; | |||||
import com.ruoyi.common.utils.bean.BeanUtils; | import com.ruoyi.common.utils.bean.BeanUtils; | ||||
import org.springframework.beans.factory.annotation.Autowired; | import org.springframework.beans.factory.annotation.Autowired; | ||||
import org.springframework.stereotype.Service; | import org.springframework.stereotype.Service; | ||||
@@ -41,6 +44,66 @@ public class ApplyPlanServiceImpl extends ServiceImpl<ApplyPlanMapper, ApplyPlan | |||||
@Autowired | @Autowired | ||||
private IRebotService rebotService; | private IRebotService rebotService; | ||||
/** | |||||
* 指定时间执行 | |||||
* | |||||
* @return | |||||
*/ | |||||
@Override | |||||
@Transactional | |||||
public boolean runAppBySetTime() throws IllegalAccessException { | |||||
ListRebotBO listRebotBO = new ListRebotBO(); | |||||
listRebotBO.setStatus(RebotStatus.IDLE.getKey()); | |||||
listRebotBO.setPage(1); | |||||
listRebotBO.setSize(100); | |||||
// 只获取空闲的机器人 | |||||
List<ListRebotVO> listRebotVos = YinDaoHttpUtils.listRebot(listRebotBO); | |||||
if (listRebotVos.isEmpty()) { | |||||
log.error("暂无空闲机器人"); | |||||
// 刷新机器人数据 | |||||
// rebotService.syn(new Rebot()); | |||||
return false; | |||||
} | |||||
List<ApplyPlan> applyPlanList = this.lambdaQuery().eq(ApplyPlan::getExcType, ExcTypeStatus.TWO.getKey()).isNull(ApplyPlan::getTaskUuid).orderByAsc(ApplyPlan::getExcTime).list(); | |||||
listRebotVos.forEach(rebot -> { | |||||
applyPlanList.forEach(e -> { | |||||
if (e.getExcTime().getTime() <= System.currentTimeMillis() && PlanRunStatus.AWAIT_CREATE.getKey().equals(e.getTaskStatus())) { | |||||
ApplyStartBO applyStartBO = new ApplyStartBO(); | |||||
applyStartBO.setRobotUuid(e.getAppId()); | |||||
applyStartBO.setAccountName(rebot.getRobotClientName()); | |||||
applyStartBO.setManualTime(e.getManualTime()); | |||||
//high 高 middle 中 low 低 | |||||
applyStartBO.setPriority("high"); | |||||
String planParams = e.getPlanParams(); | |||||
if(StringUtils.isNotEmpty(planParams)){ | |||||
JSONArray jsonArray = JSON.parseArray(planParams); | |||||
// 直接转换成List | |||||
List<ApplyStartBO.RobotParam> list = jsonArray.toJavaList(ApplyStartBO.RobotParam.class); | |||||
applyStartBO.setPlanParamsList(list); | |||||
} | |||||
try { | |||||
JobStartVO jobStartVO = YinDaoHttpUtils.appStart(applyStartBO); | |||||
ApplyPlan applyPlan = new ApplyPlan(); | |||||
applyPlan.setId(e.getId()); | |||||
applyPlan.setUpdateBy("-1"); | |||||
applyPlan.setUpdateTime(new Date()); | |||||
applyPlan.setTaskUuid(jobStartVO.getJobUuid()); | |||||
applyPlan.setTaskStatus(PlanRunStatus.CREATED.getKey()); | |||||
this.updateById(applyPlan); | |||||
Rebot updateRebot = new Rebot(); | |||||
updateRebot.setStatus(RebotStatus.RUNNING.getKey()); | |||||
rebotService.lambdaUpdate().eq(Rebot::getRobotClientName, rebot.getRobotClientName()).update(updateRebot); | |||||
} catch (IllegalAccessException ex) { | |||||
throw new RuntimeException(ex); | |||||
} | |||||
} | |||||
}); | |||||
}); | |||||
return false; | |||||
} | |||||
/** | /** | ||||
* 获取应用执行结果 | * 获取应用执行结果 | ||||
* | * | ||||
@@ -166,6 +229,13 @@ public class ApplyPlanServiceImpl extends ServiceImpl<ApplyPlanMapper, ApplyPlan | |||||
applyStartBO.setAccountName(listRebotVO.getRobotClientName()); | applyStartBO.setAccountName(listRebotVO.getRobotClientName()); | ||||
//high 高 middle 中 low 低 | //high 高 middle 中 low 低 | ||||
applyStartBO.setPriority("high"); | applyStartBO.setPriority("high"); | ||||
String planParams = applyPlan.getPlanParams(); | |||||
if(StringUtils.isNotEmpty(planParams)){ | |||||
JSONArray jsonArray = JSON.parseArray(planParams); | |||||
// 直接转换成List | |||||
List<ApplyStartBO.RobotParam> list = jsonArray.toJavaList(ApplyStartBO.RobotParam.class); | |||||
applyStartBO.setPlanParamsList(list); | |||||
} | |||||
JobStartVO jobStartVO = YinDaoHttpUtils.appStart(applyStartBO); | JobStartVO jobStartVO = YinDaoHttpUtils.appStart(applyStartBO); | ||||
ApplyPlan updateApplyPlan = new ApplyPlan(); | ApplyPlan updateApplyPlan = new ApplyPlan(); | ||||
@@ -182,11 +252,11 @@ public class ApplyPlanServiceImpl extends ServiceImpl<ApplyPlanMapper, ApplyPlan | |||||
if (this.saveOrUpdate(updateApplyPlan)) { | if (this.saveOrUpdate(updateApplyPlan)) { | ||||
i++; | i++; | ||||
} | } | ||||
} | } | ||||
return i > 0; | return i > 0; | ||||
} | } | ||||
@Override | @Override | ||||
@Transactional | @Transactional | ||||
public boolean save(AddApplyPlanBO addApplyPlanBO) { | public boolean save(AddApplyPlanBO addApplyPlanBO) { | ||||
@@ -204,6 +274,10 @@ public class ApplyPlanServiceImpl extends ServiceImpl<ApplyPlanMapper, ApplyPlan | |||||
applyPlan.setAppType(apply.getAppType()); | applyPlan.setAppType(apply.getAppType()); | ||||
applyPlan.setAppTypeName(apply.getAppTypeName()); | applyPlan.setAppTypeName(apply.getAppTypeName()); | ||||
applyPlan.setManualTime(apply.getManualTime()); | applyPlan.setManualTime(apply.getManualTime()); | ||||
if(addApplyPlanBO.getSupportParam() == 1){ | |||||
applyPlan.setPlanParams(apply.getParam()); | |||||
} | |||||
applyPlan.setManualTime(apply.getParam()); | |||||
applyPlan.setDeptId(SecurityUtils.getDeptId()); | applyPlan.setDeptId(SecurityUtils.getDeptId()); | ||||
// try { | // try { | ||||
@@ -130,4 +130,16 @@ public class ApplyServiceImpl extends ServiceImpl<ApplyMapper, Apply> implements | |||||
public List<Apply> list(Apply apply) { | public List<Apply> list(Apply apply) { | ||||
return baseMapper.selectApplyList(apply); | return baseMapper.selectApplyList(apply); | ||||
} | } | ||||
/** | |||||
* 查询所有应用信息列表 | |||||
* | |||||
* @param apply 应用信息管理 | |||||
* @return 应用信息管理 | |||||
*/ | |||||
@Override | |||||
@DataScope(deptAlias = "apply") | |||||
public List<Apply> listAll(Apply apply) { | |||||
return baseMapper.selectApplyAllList(apply); | |||||
} | |||||
} | } |
@@ -85,6 +85,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" | |||||
<if test="ownerName != null and ownerName != ''"> and owner_name like concat(#{ownerName}, '%')</if> | <if test="ownerName != null and ownerName != ''"> and owner_name like concat(#{ownerName}, '%')</if> | ||||
<if test="ownerAccount != null and ownerAccount != ''"> and owner_account like concat(#{ownerAccount}, '%')</if> | <if test="ownerAccount != null and ownerAccount != ''"> and owner_account like concat(#{ownerAccount}, '%')</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="version != null and version != ''"> and version = #{version}</if> | |||||
<if test="appTypeName != null and appTypeName != ''"> and app_type_name like concat(#{appTypeName}, '%')</if> | <if test="appTypeName != null and appTypeName != ''"> and app_type_name like concat(#{appTypeName}, '%')</if> | ||||
<if test="appType != null and appType != ''"> and app_type = #{appType}</if> | <if test="appType != null and appType != ''"> and app_type = #{appType}</if> | ||||
<if test="supportParam != null "> and support_param = #{supportParam}</if> | <if test="supportParam != null "> and support_param = #{supportParam}</if> | ||||
@@ -94,4 +95,24 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" | |||||
<!-- 数据范围过滤 --> | <!-- 数据范围过滤 --> | ||||
${params.dataScope} | ${params.dataScope} | ||||
</select> | </select> | ||||
<!--查询所有已发版的应用列表--> | |||||
<select id="selectApplyAllList" parameterType="Apply" resultMap="ApplyResult"> | |||||
<include refid="selectApplyVo"/> | |||||
from ct_apply apply | |||||
<where> | |||||
deleted = 0 | |||||
<if test="ownerName != null and ownerName != ''"> and owner_name like concat(#{ownerName}, '%')</if> | |||||
<if test="ownerAccount != null and ownerAccount != ''"> and owner_account like concat(#{ownerAccount}, '%')</if> | |||||
<if test="appName != null and appName != ''"> and app_name like concat(#{appName}, '%')</if> | |||||
<if test="appTypeName != null and appTypeName != ''"> and app_type_name like concat(#{appTypeName}, '%')</if> | |||||
<if test="appType != null and appType != ''"> and app_type = #{appType}</if> | |||||
<if test="supportParam != null "> and support_param = #{supportParam}</if> | |||||
<if test="deptId != null "> and dept_id = #{deptId}</if> | |||||
<if test="deptName != null and deptName != ''"> and dept_name like concat(#{deptName}, '%')</if> | |||||
and version != '未发版' | |||||
</where> | |||||
<!-- 数据范围过滤 --> | |||||
${params.dataScope} | |||||
</select> | |||||
</mapper> | </mapper> |
@@ -21,6 +21,8 @@ | |||||
<result property="appId" column="app_id"/> | <result property="appId" column="app_id"/> | ||||
<!-- 应用类型枚举(app:应用 activity:指令) --> | <!-- 应用类型枚举(app:应用 activity:指令) --> | ||||
<result property="appType" column="app_type"/> | <result property="appType" column="app_type"/> | ||||
<!-- 是否支持应用参数 --> | |||||
<result property="supportParam" column="support_param" /> | |||||
<!-- 计划参数 --> | <!-- 计划参数 --> | ||||
<result property="planParams" column="plan_params"/> | <result property="planParams" column="plan_params"/> | ||||
<!-- 等待超时时间 --> | <!-- 等待超时时间 --> | ||||
@@ -73,6 +75,7 @@ | |||||
plan.app_name,<!-- 应用名称 --> | plan.app_name,<!-- 应用名称 --> | ||||
plan.app_id,<!-- appid --> | plan.app_id,<!-- appid --> | ||||
plan.app_type,<!-- 应用类型枚举(app:应用 activity:指令) --> | plan.app_type,<!-- 应用类型枚举(app:应用 activity:指令) --> | ||||
plan.support_param,<!-- 是否支持应用参数 --> | |||||
plan.plan_params,<!-- 计划参数 --> | plan.plan_params,<!-- 计划参数 --> | ||||
plan.wait_timeout,<!-- 等待超时时间 --> | plan.wait_timeout,<!-- 等待超时时间 --> | ||||
plan.priority,<!-- 优先级 --> | plan.priority,<!-- 优先级 --> | ||||
@@ -108,6 +111,7 @@ | |||||
<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="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="excType != null and excType != ''"> and exc_type = #{excType}</if> | ||||
@@ -41,6 +41,15 @@ public class RyTask { | |||||
log.debug("执行顺序启动应用结束"); | log.debug("执行顺序启动应用结束"); | ||||
} | } | ||||
/** | |||||
* 指定时间执行一次 | |||||
*/ | |||||
public void runAppBySetTime() throws IllegalAccessException { | |||||
log.debug("指定时间执行一次开始"); | |||||
applyPlanService.runAppBySetTime(); | |||||
log.debug("指定时间执行一次结束"); | |||||
} | |||||
/** | /** | ||||
* 获取应用执行结果 | * 获取应用执行结果 | ||||
*/ | */ | ||||
@@ -49,4 +58,9 @@ public class RyTask { | |||||
applyPlanService.queryAppStartResult(); | applyPlanService.queryAppStartResult(); | ||||
log.debug("更新应用执行结果结束"); | log.debug("更新应用执行结果结束"); | ||||
} | } | ||||
} | } |