From c6e10d635df2cdf2bcab81a47b1ceb92e0da2b92 Mon Sep 17 00:00:00 2001 From: lcr <977192391@qq.com> Date: Fri, 14 Jun 2024 18:27:14 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8A=9F=E8=83=BD=E6=8F=90=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ruoyi-business/pom.xml | 6 + .../business/controller/ApplyController.java | 12 +- .../controller/ApplyPlanController.java | 113 ++++++++++++++ .../controller/ApplyPlanLogController.java | 110 +++++++++++++ .../business/controller/RebotController.java | 15 +- .../java/com/ruoyi/business/domain/Apply.java | 12 +- .../com/ruoyi/business/domain/ApplyPlan.java | 145 ++++++++++++++++++ .../ruoyi/business/domain/ApplyPlanLog.java | 142 +++++++++++++++++ .../java/com/ruoyi/business/domain/Rebot.java | 2 +- .../business/domain/bo/AddApplyPlanBO.java | 136 ++++++++++++++++ .../business/domain/bo/ApplyStartBO.java | 97 ++++++++++++ .../ruoyi/business/domain/bo/JobQueryBO.java | 19 +++ .../ruoyi/business/domain/vo/JobQueryVO.java | 104 +++++++++++++ .../ruoyi/business/domain/vo/JobStartVO.java | 18 +++ .../business/mapper/ApplyPlanLogMapper.java | 24 +++ .../business/mapper/ApplyPlanMapper.java | 24 +++ .../service/IApplyPlanLogService.java | 24 +++ .../business/service/IApplyPlanService.java | 45 ++++++ .../ruoyi/business/service/IApplyService.java | 19 ++- .../ruoyi/business/service/IRebotService.java | 2 +- .../service/impl/ApplyPlanLogServiceImpl.java | 34 ++++ .../service/impl/ApplyPlanServiceImpl.java | 139 +++++++++++++++++ .../service/impl/ApplyServiceImpl.java | 76 +++++++-- .../service/impl/RebotServiceImpl.java | 17 +- .../ruoyi/business/util/YinDaoHttpUtils.java | 84 ++++++++-- .../com/ruoyi/business/yddoman/BaseDTO.java | 15 +- .../resources/mapper/business/ApplyMapper.xml | 53 ++++--- .../mapper/business/ApplyPlanLogMapper.xml | 91 +++++++++++ .../mapper/business/ApplyPlanMapper.xml | 102 ++++++++++++ .../resources/mapper/business/RebotMapper.xml | 6 +- .../com/ruoyi/common/enums/ExcTypeStatus.java | 35 +++++ .../com/ruoyi/common/enums/RebotStatus.java | 39 +++++ .../com/ruoyi/common/utils/BeanToMapUtil.java | 30 ++++ ruoyi-quartz/pom.xml | 6 + .../java/com/ruoyi/quartz/task/RyTask.java | 30 ++-- .../ruoyi/system/mapper/SysDeptMapper.java | 6 + .../ruoyi/system/service/ISysDeptService.java | 8 + .../service/impl/SysDeptServiceImpl.java | 11 ++ .../resources/mapper/system/SysDeptMapper.xml | 19 ++- 39 files changed, 1784 insertions(+), 86 deletions(-) create mode 100644 ruoyi-business/src/main/java/com/ruoyi/business/controller/ApplyPlanController.java create mode 100644 ruoyi-business/src/main/java/com/ruoyi/business/controller/ApplyPlanLogController.java create mode 100644 ruoyi-business/src/main/java/com/ruoyi/business/domain/ApplyPlan.java create mode 100644 ruoyi-business/src/main/java/com/ruoyi/business/domain/ApplyPlanLog.java create mode 100644 ruoyi-business/src/main/java/com/ruoyi/business/domain/bo/AddApplyPlanBO.java create mode 100644 ruoyi-business/src/main/java/com/ruoyi/business/domain/bo/ApplyStartBO.java create mode 100644 ruoyi-business/src/main/java/com/ruoyi/business/domain/bo/JobQueryBO.java create mode 100644 ruoyi-business/src/main/java/com/ruoyi/business/domain/vo/JobQueryVO.java create mode 100644 ruoyi-business/src/main/java/com/ruoyi/business/domain/vo/JobStartVO.java create mode 100644 ruoyi-business/src/main/java/com/ruoyi/business/mapper/ApplyPlanLogMapper.java create mode 100644 ruoyi-business/src/main/java/com/ruoyi/business/mapper/ApplyPlanMapper.java create mode 100644 ruoyi-business/src/main/java/com/ruoyi/business/service/IApplyPlanLogService.java create mode 100644 ruoyi-business/src/main/java/com/ruoyi/business/service/IApplyPlanService.java create mode 100644 ruoyi-business/src/main/java/com/ruoyi/business/service/impl/ApplyPlanLogServiceImpl.java create mode 100644 ruoyi-business/src/main/java/com/ruoyi/business/service/impl/ApplyPlanServiceImpl.java create mode 100644 ruoyi-business/src/main/resources/mapper/business/ApplyPlanLogMapper.xml create mode 100644 ruoyi-business/src/main/resources/mapper/business/ApplyPlanMapper.xml create mode 100644 ruoyi-common/src/main/java/com/ruoyi/common/enums/ExcTypeStatus.java create mode 100644 ruoyi-common/src/main/java/com/ruoyi/common/enums/RebotStatus.java create mode 100644 ruoyi-common/src/main/java/com/ruoyi/common/utils/BeanToMapUtil.java diff --git a/ruoyi-business/pom.xml b/ruoyi-business/pom.xml index 596d0b5..5093bb5 100644 --- a/ruoyi-business/pom.xml +++ b/ruoyi-business/pom.xml @@ -23,6 +23,12 @@ ruoyi-common + + + com.ruoyi + ruoyi-system + + io.springfox springfox-swagger-ui diff --git a/ruoyi-business/src/main/java/com/ruoyi/business/controller/ApplyController.java b/ruoyi-business/src/main/java/com/ruoyi/business/controller/ApplyController.java index 973eed3..0942c34 100644 --- a/ruoyi-business/src/main/java/com/ruoyi/business/controller/ApplyController.java +++ b/ruoyi-business/src/main/java/com/ruoyi/business/controller/ApplyController.java @@ -46,11 +46,21 @@ public class ApplyController extends BaseController { */ @ApiOperation(value = "同步应用数据", httpMethod = "POST", response = Rebot.class) @PostMapping("/syn") - public AjaxResult syn(Apply apply) { + public AjaxResult syn(Apply apply) throws IllegalAccessException { applyService.syn(apply); return AjaxResult.success(); } + /** + * 查询所有应用列表 + */ + @ApiOperation(value = "查询所有应用列表", httpMethod = "GET", response = Apply.class) + @GetMapping("/listAll") + public AjaxResult listAll(Apply apply) { + List list = applyService.list(apply); + return AjaxResult.success(list); + } + /** * 查询应用信息管理列表 diff --git a/ruoyi-business/src/main/java/com/ruoyi/business/controller/ApplyPlanController.java b/ruoyi-business/src/main/java/com/ruoyi/business/controller/ApplyPlanController.java new file mode 100644 index 0000000..b54f9ab --- /dev/null +++ b/ruoyi-business/src/main/java/com/ruoyi/business/controller/ApplyPlanController.java @@ -0,0 +1,113 @@ +package com.ruoyi.business.controller; + +import java.util.List; +import javax.servlet.http.HttpServletResponse; +import java.util.Arrays; + +import com.ruoyi.business.domain.bo.AddApplyPlanBO; +import com.ruoyi.common.utils.bean.BeanUtils; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiImplicitParam; +import io.swagger.annotations.ApiImplicitParams; +import io.swagger.annotations.ApiOperation; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.PutMapping; +import org.springframework.web.bind.annotation.DeleteMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; +import com.ruoyi.common.annotation.Log; +import com.ruoyi.common.core.controller.BaseController; +import com.ruoyi.common.core.domain.AjaxResult; +import com.ruoyi.common.enums.BusinessType; +import com.ruoyi.business.domain.ApplyPlan; +import com.ruoyi.business.service.IApplyPlanService; +import com.ruoyi.common.utils.poi.ExcelUtil; +import com.ruoyi.common.core.page.TableDataInfo; + +/** + * 应用执行计划管理Controller + * + * @author LiuChengRan + * @date 2024-06-14 + */ +@Api(tags = "应用执行计划管理接口") +@RestController +@RequestMapping("/business/ctApplyPlan") +public class ApplyPlanController extends BaseController +{ + @Autowired + private IApplyPlanService applyPlanService; + + /** + * 查询应用执行计划管理列表 + */ + @ApiOperation(value="查询应用执行计划管理列表", httpMethod = "GET", response = ApplyPlan.class) + @GetMapping("/list") + public TableDataInfo list(ApplyPlan applyPlan) + { + startPage(); + List list = applyPlanService.list(applyPlan); + return getDataTable(list); + } + + /** + * 导出应用执行计划管理列表 + */ + @ApiOperation(value="导出应用执行计划管理列表", httpMethod = "POST") + @Log(title = "应用执行计划管理", businessType = BusinessType.EXPORT) + @PostMapping("/export") + public void export(HttpServletResponse response, ApplyPlan applyPlan) + { + List list = applyPlanService.list(applyPlan); + ExcelUtil util = new ExcelUtil(ApplyPlan.class); + util.exportExcel(response, list, "应用执行计划管理数据"); + } + + /** + * 获取应用执行计划管理详细信息 + */ + @ApiOperation(value="获取应用执行计划管理详细信息", httpMethod = "GET", response = ApplyPlan.class) + @GetMapping(value = "/{id}") + public AjaxResult getInfo(@PathVariable("id") Long id) + { + return success(applyPlanService.getById(id)); + } + + /** + * 新增应用执行计划管理 + */ + @ApiOperation(value="新增应用执行计划管理", httpMethod = "POST") + @Log(title = "应用执行计划管理", businessType = BusinessType.INSERT) + @PostMapping + public AjaxResult add(@RequestBody AddApplyPlanBO addApplyPlanBO) + { + return toAjax(applyPlanService.save(addApplyPlanBO)); + } + + /** + * 修改应用执行计划管理 + */ + @ApiOperation(value="修改应用执行计划管理", httpMethod = "PUT") + @Log(title = "应用执行计划管理", businessType = BusinessType.UPDATE) + @PutMapping + public AjaxResult edit(@RequestBody AddApplyPlanBO addApplyPlanBO) + { + return toAjax(applyPlanService.update(addApplyPlanBO)); + } + + /** + * 删除应用执行计划管理 + */ + @ApiOperation(value="删除应用执行计划管理", httpMethod = "DELETE") + @Log(title = "应用执行计划管理", businessType = BusinessType.DELETE) + @DeleteMapping("/{ids}") + public AjaxResult remove(@PathVariable Long[] ids) + { + return toAjax(applyPlanService.removeByIds(Arrays.asList(ids))); + } +} diff --git a/ruoyi-business/src/main/java/com/ruoyi/business/controller/ApplyPlanLogController.java b/ruoyi-business/src/main/java/com/ruoyi/business/controller/ApplyPlanLogController.java new file mode 100644 index 0000000..d793d3c --- /dev/null +++ b/ruoyi-business/src/main/java/com/ruoyi/business/controller/ApplyPlanLogController.java @@ -0,0 +1,110 @@ +package com.ruoyi.business.controller; + +import java.util.List; +import javax.servlet.http.HttpServletResponse; +import java.util.Arrays; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiImplicitParam; +import io.swagger.annotations.ApiImplicitParams; +import io.swagger.annotations.ApiOperation; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.PutMapping; +import org.springframework.web.bind.annotation.DeleteMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; +import com.ruoyi.common.annotation.Log; +import com.ruoyi.common.core.controller.BaseController; +import com.ruoyi.common.core.domain.AjaxResult; +import com.ruoyi.common.enums.BusinessType; +import com.ruoyi.business.domain.ApplyPlanLog; +import com.ruoyi.business.service.IApplyPlanLogService; +import com.ruoyi.common.utils.poi.ExcelUtil; +import com.ruoyi.common.core.page.TableDataInfo; + +/** + * 应用执行结果记录管理Controller + * + * @author LiuChengRan + * @date 2024-06-14 + */ +@Api(tags = "应用执行结果记录管理接口") +@RestController +@RequestMapping("/business/ctApplyPlanLog") +public class ApplyPlanLogController extends BaseController +{ + @Autowired + private IApplyPlanLogService applyPlanLogService; + + /** + * 查询应用执行结果记录管理列表 + */ + @ApiOperation(value="查询应用执行结果记录管理列表", httpMethod = "GET", response = ApplyPlanLog.class) + @GetMapping("/list") + public TableDataInfo list(ApplyPlanLog applyPlanLog) + { + startPage(); + List list = applyPlanLogService.list(applyPlanLog); + return getDataTable(list); + } + + /** + * 导出应用执行结果记录管理列表 + */ + @ApiOperation(value="导出应用执行结果记录管理列表", httpMethod = "POST") + @Log(title = "应用执行结果记录管理", businessType = BusinessType.EXPORT) + @PostMapping("/export") + public void export(HttpServletResponse response, ApplyPlanLog applyPlanLog) + { + List list = applyPlanLogService.list(applyPlanLog); + ExcelUtil util = new ExcelUtil(ApplyPlanLog.class); + util.exportExcel(response, list, "应用执行结果记录管理数据"); + } + + /** + * 获取应用执行结果记录管理详细信息 + */ + @ApiOperation(value="获取应用执行结果记录管理详细信息", httpMethod = "GET", response = ApplyPlanLog.class) + @GetMapping(value = "/{id}") + public AjaxResult getInfo(@PathVariable("id") Long id) + { + return success(applyPlanLogService.getById(id)); + } + + /** + * 新增应用执行结果记录管理 + */ + @ApiOperation(value="新增应用执行结果记录管理", httpMethod = "POST") + @Log(title = "应用执行结果记录管理", businessType = BusinessType.INSERT) + @PostMapping + public AjaxResult add(@RequestBody ApplyPlanLog applyPlanLog) + { + return toAjax(applyPlanLogService.save(applyPlanLog)); + } + + /** + * 修改应用执行结果记录管理 + */ + @ApiOperation(value="修改应用执行结果记录管理", httpMethod = "PUT") + @Log(title = "应用执行结果记录管理", businessType = BusinessType.UPDATE) + @PutMapping + public AjaxResult edit(@RequestBody ApplyPlanLog applyPlanLog) + { + return toAjax(applyPlanLogService.updateById(applyPlanLog)); + } + + /** + * 删除应用执行结果记录管理 + */ + @ApiOperation(value="删除应用执行结果记录管理", httpMethod = "DELETE") + @Log(title = "应用执行结果记录管理", businessType = BusinessType.DELETE) + @DeleteMapping("/{ids}") + public AjaxResult remove(@PathVariable Long[] ids) + { + return toAjax(applyPlanLogService.removeByIds(Arrays.asList(ids))); + } +} diff --git a/ruoyi-business/src/main/java/com/ruoyi/business/controller/RebotController.java b/ruoyi-business/src/main/java/com/ruoyi/business/controller/RebotController.java index e7b953f..3c96968 100644 --- a/ruoyi-business/src/main/java/com/ruoyi/business/controller/RebotController.java +++ b/ruoyi-business/src/main/java/com/ruoyi/business/controller/RebotController.java @@ -4,6 +4,8 @@ import java.util.List; import javax.servlet.http.HttpServletResponse; import java.util.Arrays; +import com.ruoyi.common.enums.RebotStatus; +import com.ruoyi.common.utils.SecurityUtils; import io.swagger.annotations.Api; import io.swagger.annotations.ApiImplicitParam; import io.swagger.annotations.ApiImplicitParams; @@ -45,11 +47,22 @@ public class RebotController extends BaseController { */ @ApiOperation(value = "同步机器人数据", httpMethod = "POST", response = Rebot.class) @PostMapping("/syn") - public AjaxResult syn(Rebot rebot) { + public AjaxResult syn(Rebot rebot) throws IllegalAccessException { rebotService.syn(rebot); return AjaxResult.success(); } + /** + * 查询所有可用(空闲)机器人 + */ + @ApiOperation(value = "查询所有可用(空闲)机器人", httpMethod = "GET", response = Rebot.class) + @GetMapping("/listAll") + public AjaxResult listAll(Rebot rebot) { + rebot.setStatus(RebotStatus.IDLE.getKey()); + List list = rebotService.list(rebot); + return AjaxResult.success(list); + } + /** * 查询机器人管理列表 */ diff --git a/ruoyi-business/src/main/java/com/ruoyi/business/domain/Apply.java b/ruoyi-business/src/main/java/com/ruoyi/business/domain/Apply.java index 3a53611..fbcb750 100644 --- a/ruoyi-business/src/main/java/com/ruoyi/business/domain/Apply.java +++ b/ruoyi-business/src/main/java/com/ruoyi/business/domain/Apply.java @@ -88,10 +88,16 @@ public class Apply extends BaseEntity @Excel(name = "预计人工耗时") @ApiModelProperty(name="manualTime",value = "预计人工耗时") private String manualTime; - /** 所属公司 */ - @Excel(name = "所属公司") - @ApiModelProperty(name="deptId",value = "所属公司") + + /** 部门id */ + @Excel(name = "部门id") + @ApiModelProperty(name="deptId",value = "部门id") private Long deptId; + + /** 部门名称 */ + @Excel(name = "部门名称") + @ApiModelProperty(name="deptName",value = "部门名称") + private String deptName; @Override public String toString() { return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) diff --git a/ruoyi-business/src/main/java/com/ruoyi/business/domain/ApplyPlan.java b/ruoyi-business/src/main/java/com/ruoyi/business/domain/ApplyPlan.java new file mode 100644 index 0000000..7bfe626 --- /dev/null +++ b/ruoyi-business/src/main/java/com/ruoyi/business/domain/ApplyPlan.java @@ -0,0 +1,145 @@ +package com.ruoyi.business.domain; + +import java.util.Date; +import com.fasterxml.jackson.annotation.JsonFormat; +import com.baomidou.mybatisplus.annotation.*; +import org.apache.commons.lang3.builder.ToStringBuilder; +import org.apache.commons.lang3.builder.ToStringStyle; +import com.ruoyi.common.annotation.Excel; +import lombok.Data; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.NoArgsConstructor; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import com.baomidou.mybatisplus.annotation.TableName; +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.IdType; +import com.ruoyi.common.core.domain.BaseEntity; + +/** + * 应用执行计划管理对象 ct_apply_plan + * + * @author LiuChengRan + * @date 2024-06-14 + */ +@Data +@Builder(toBuilder = true) +@NoArgsConstructor +@AllArgsConstructor +@ApiModel(value="ApplyPlan",description = "应用执行计划管理") +@TableName(value = "ct_apply_plan") +public class ApplyPlan extends BaseEntity +{ + @TableField(exist = false) + private static final long serialVersionUID = 1L; + + + + /** 计划名称 */ + @Excel(name = "计划名称") + @ApiModelProperty(name="planName",value = "计划名称") + private String planName; + + + /** 执行类型(0指定机器人 1随机分配空闲) */ + @Excel(name = "执行类型", readConverterExp = "0=指定机器人,1=随机分配空闲") + @ApiModelProperty(name="planType",value = "执行类型") + private String planType; + + /** 计划执行的机器人名称 */ + @Excel(name = "计划执行的机器人名称") + @ApiModelProperty(name="robotName",value = "计划执行的机器人名称") + private String robotName; + + /** 应用类型名称 */ + @Excel(name = "应用类型名称") + @ApiModelProperty(name="appTypeName",value = "应用类型名称") + private String appTypeName; + + /** 应用名称 */ + @Excel(name = "应用名称") + @ApiModelProperty(name="appName",value = "应用名称") + private String appName; + + /** appid */ + @Excel(name = "appid") + @ApiModelProperty(name="appId",value = "appid") + private String appId; + + + /** 应用类型枚举(app:应用 activity:指令) */ + @Excel(name = "应用类型枚举", readConverterExp = "app:应用,activity:指令") + @ApiModelProperty(name="appType",value = "应用类型枚举") + private String appType; + + /** 预计人工耗时 */ + @Excel(name = "预计人工耗时") + @ApiModelProperty(name="manualTime",value = "预计人工耗时") + private String manualTime; + + /** 计划参数 */ + @Excel(name = "计划参数") + @ApiModelProperty(name="planParams",value = "计划参数") + private String planParams; + + /** 等待超时时间 */ + @Excel(name = "等待超时时间") + @ApiModelProperty(name="waitTimeout",value = "等待超时时间") + private String waitTimeout; + + /** 优先级 */ + @Excel(name = "优先级") + @ApiModelProperty(name="priority",value = "优先级") + private Integer priority; + + + /** 执行类型(0立即执行 1指定时间执行 2周期执行) */ + @Excel(name = "执行类型", readConverterExp = "0=立即执行,1=指定时间执行,2=周期执行") + @ApiModelProperty(name="excType",value = "执行类型") + private String excType; + + + /** 执行时间 */ + @JsonFormat(pattern = "yyyy-MM-dd") + @Excel(name = "执行时间", width = 30, dateFormat = "yyyy-MM-dd") + @ApiModelProperty(name="excTime",value = "执行时间") + private Date excTime; + + /** 执行表达式 */ + @Excel(name = "执行表达式") + @ApiModelProperty(name="cronExpression",value = "执行表达式") + private String cronExpression; + /** 任务运行uuid */ + @Excel(name = "任务运行uuid") + @ApiModelProperty(name="taskUuid",value = "任务运行uuid") + private String taskUuid; + + @Override + public String toString() { + return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) + .append("id", getId()) + .append("planName", getPlanName()) + .append("planType", getPlanType()) + .append("robotName", getRobotName()) + .append("appTypeName", getAppTypeName()) + .append("appName", getAppName()) + .append("appId", getAppId()) + .append("appType", getAppType()) + .append("manualTime", getManualTime()) + .append("planParams", getPlanParams()) + .append("waitTimeout", getWaitTimeout()) + .append("priority", getPriority()) + .append("excType", getExcType()) + .append("excTime", getExcTime()) + .append("cronExpression", getCronExpression()) + .append("createBy", getCreateBy()) + .append("createTime", getCreateTime()) + .append("updateBy", getUpdateBy()) + .append("updateTime", getUpdateTime()) + .append("remark", getRemark()) + .append("deleted", getDeleted()) + .toString(); + } +} \ No newline at end of file diff --git a/ruoyi-business/src/main/java/com/ruoyi/business/domain/ApplyPlanLog.java b/ruoyi-business/src/main/java/com/ruoyi/business/domain/ApplyPlanLog.java new file mode 100644 index 0000000..e0f38ad --- /dev/null +++ b/ruoyi-business/src/main/java/com/ruoyi/business/domain/ApplyPlanLog.java @@ -0,0 +1,142 @@ +package com.ruoyi.business.domain; + +import java.util.Date; +import com.fasterxml.jackson.annotation.JsonFormat; +import com.baomidou.mybatisplus.annotation.*; +import org.apache.commons.lang3.builder.ToStringBuilder; +import org.apache.commons.lang3.builder.ToStringStyle; +import com.ruoyi.common.annotation.Excel; +import lombok.Data; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.NoArgsConstructor; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import com.baomidou.mybatisplus.annotation.TableName; +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.IdType; +import com.ruoyi.common.core.domain.BaseEntity; + +/** + * 应用执行结果记录管理对象 ct_apply_plan_log + * + * @author LiuChengRan + * @date 2024-06-14 + */ +@Data +@Builder(toBuilder = true) +@NoArgsConstructor +@AllArgsConstructor +@ApiModel(value="ApplyPlanLog",description = "应用执行结果记录管理") +@TableName(value = "ct_apply_plan_log") +public class ApplyPlanLog extends BaseEntity +{ + @TableField(exist = false) + private static final long serialVersionUID = 1L; + + + + /** 启动的任务的uuid */ + @Excel(name = "启动的任务的uuid") + @ApiModelProperty(name="jobUuid",value = "启动的任务的uuid") + private String jobUuid; + + /** 计划名称 */ + @Excel(name = "计划名称") + @ApiModelProperty(name="planName",value = "计划名称") + private String planName; + + + /** 执行类型(0指定机器人 1随机分配空闲) */ + @Excel(name = "执行类型", readConverterExp = "0=指定机器人,1=随机分配空闲") + @ApiModelProperty(name="planType",value = "执行类型") + private String planType; + + /** 计划执行的机器人名称 */ + @Excel(name = "计划执行的机器人名称") + @ApiModelProperty(name="robotName",value = "计划执行的机器人名称") + private String robotName; + + /** 应用类型名称 */ + @Excel(name = "应用类型名称") + @ApiModelProperty(name="appTypeName",value = "应用类型名称") + private String appTypeName; + + /** 应用名称 */ + @Excel(name = "应用名称") + @ApiModelProperty(name="appName",value = "应用名称") + private String appName; + + /** appid */ + @Excel(name = "appid") + @ApiModelProperty(name="appId",value = "appid") + private String appId; + + /** 任务状态 */ + @Excel(name = "任务状态") + @ApiModelProperty(name="status",value = "任务状态") + private String status; + + /** 任务状态名称 */ + @Excel(name = "任务状态名称") + @ApiModelProperty(name="statusName",value = "任务状态名称") + private String statusName; + + + /** 任务开始运行的时间 */ + @JsonFormat(pattern = "yyyy-MM-dd") + @Excel(name = "任务开始运行的时间", width = 30, dateFormat = "yyyy-MM-dd") + @ApiModelProperty(name="startTime",value = "任务开始运行的时间") + private Date startTime; + + + /** 任务结束运行的时间 */ + @JsonFormat(pattern = "yyyy-MM-dd") + @Excel(name = "任务结束运行的时间", width = 30, dateFormat = "yyyy-MM-dd") + @ApiModelProperty(name="endTime",value = "任务结束运行的时间") + private Date endTime; + + /** 预计人工耗时 */ + @Excel(name = "预计人工耗时") + @ApiModelProperty(name="manualTime",value = "预计人工耗时") + private String manualTime; + + /** 实际耗时 */ + @Excel(name = "实际耗时") + @ApiModelProperty(name="planTime",value = "实际耗时") + private String planTime; + + /** 节约时间 */ + @Excel(name = "节约时间") + @ApiModelProperty(name="timeSaving",value = "节约时间") + private String timeSaving; + + + @Override + public String toString() { + return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) + .append("id", getId()) + .append("jobUuid", getJobUuid()) + .append("planName", getPlanName()) + .append("planType", getPlanType()) + .append("robotName", getRobotName()) + .append("appTypeName", getAppTypeName()) + .append("appName", getAppName()) + .append("appId", getAppId()) + .append("status", getStatus()) + .append("statusName", getStatusName()) + .append("startTime", getStartTime()) + .append("endTime", getEndTime()) + .append("manualTime", getManualTime()) + .append("planTime", getPlanTime()) + .append("timeSaving", getTimeSaving()) + .append("createBy", getCreateBy()) + .append("createTime", getCreateTime()) + .append("updateBy", getUpdateBy()) + .append("updateTime", getUpdateTime()) + .append("remark", getRemark()) + .append("deleted", getDeleted()) + .toString(); + } +} diff --git a/ruoyi-business/src/main/java/com/ruoyi/business/domain/Rebot.java b/ruoyi-business/src/main/java/com/ruoyi/business/domain/Rebot.java index f4fdb0a..0c2dda3 100644 --- a/ruoyi-business/src/main/java/com/ruoyi/business/domain/Rebot.java +++ b/ruoyi-business/src/main/java/com/ruoyi/business/domain/Rebot.java @@ -48,7 +48,7 @@ public class Rebot extends BaseEntity /** 运行状态(waiting:等待调度 running:任务运行中 finish:任务运行结束 stopping:任务正在停止 stopped:已结束 error:异常) */ - @Excel(name = "运行状态", readConverterExp = "w=aiting:等待调度,r=unning:任务运行中,f=inish:任务运行结束,s=topping:任务正在停止,s=topped:已结束,e=rror:异常") + @Excel(name = "运行状态", readConverterExp = "waiting:等待调度,running:任务运行中,finish:任务运行结束,stopping:任务正在停止,stopped:已结束,error:异常") @ApiModelProperty(name="status",value = "运行状态") private String status; diff --git a/ruoyi-business/src/main/java/com/ruoyi/business/domain/bo/AddApplyPlanBO.java b/ruoyi-business/src/main/java/com/ruoyi/business/domain/bo/AddApplyPlanBO.java new file mode 100644 index 0000000..1ad8b42 --- /dev/null +++ b/ruoyi-business/src/main/java/com/ruoyi/business/domain/bo/AddApplyPlanBO.java @@ -0,0 +1,136 @@ +package com.ruoyi.business.domain.bo; + +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableName; +import com.fasterxml.jackson.annotation.JsonFormat; +import com.ruoyi.common.annotation.Excel; +import com.ruoyi.common.core.domain.BaseEntity; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; +import org.apache.commons.lang3.builder.ToStringBuilder; +import org.apache.commons.lang3.builder.ToStringStyle; + +import java.util.Date; +import java.util.List; + +/** + * 应用执行计划管理对象 ct_apply_plan + * + * @author LiuChengRan + * @date 2024-06-14 + */ +@Data +@Builder(toBuilder = true) +@NoArgsConstructor +@AllArgsConstructor +@ApiModel(value="ApplyPlan",description = "应用执行计划管理") +public class AddApplyPlanBO extends BaseEntity +{ + @TableField(exist = false) + private static final long serialVersionUID = 1L; + + + + /** 计划名称 */ + @Excel(name = "计划名称") + @ApiModelProperty(name="planName",value = "计划名称") + private String planName; + + + /** 执行类型(0指定机器人 1随机分配空闲) */ + @Excel(name = "执行类型", readConverterExp = "0=指定机器人,1=随机分配空闲") + @ApiModelProperty(name="planType",value = "执行类型") + private String planType; + + /** 计划执行的机器人名称 */ + @Excel(name = "计划执行的机器人名称") + @ApiModelProperty(name="robotName",value = "计划执行的机器人名称") + private String robotName; + + /** 应用类型名称 */ + @Excel(name = "应用类型名称") + @ApiModelProperty(name="appTypeName",value = "应用类型名称") + private String appTypeName; + + /** 应用名称 */ + @Excel(name = "应用名称") + @ApiModelProperty(name="appName",value = "应用名称") + private String appName; + + /** appid */ + @Excel(name = "appid") + @ApiModelProperty(name="appId",value = "appid") + private List appId; + + + /** 应用类型枚举(app:应用 activity:指令) */ + @Excel(name = "应用类型枚举", readConverterExp = "a=pp:应用,a=ctivity:指令") + @ApiModelProperty(name="appType",value = "应用类型枚举") + private String appType; + + /** 预计人工耗时 */ + @Excel(name = "预计人工耗时") + @ApiModelProperty(name="manualTime",value = "预计人工耗时") + private String manualTime; + + /** 参数 */ + @Excel(name = "参数") + @ApiModelProperty(name="planParams",value = "参数") + private String planParams; + + /** 等待超时时间 */ + @Excel(name = "等待超时时间") + @ApiModelProperty(name="waitTimeout",value = "等待超时时间") + private String waitTimeout; + + /** 优先级 */ + @Excel(name = "优先级") + @ApiModelProperty(name="priority",value = "优先级") + private Integer priority; + + + /** 执行类型(0立即执行 1指定时间执行 2周期执行) */ + @Excel(name = "执行类型", readConverterExp = "0=立即执行,1=指定时间执行,2=周期执行") + @ApiModelProperty(name="excType",value = "执行类型") + private String excType; + + + /** 执行时间 */ + @JsonFormat(pattern = "yyyy-MM-dd") + @Excel(name = "执行时间", width = 30, dateFormat = "yyyy-MM-dd") + @ApiModelProperty(name="excTime",value = "执行时间") + private Date excTime; + + /** 执行表达式 */ + @Excel(name = "执行表达式") + @ApiModelProperty(name="cronExpression",value = "执行表达式") + private String cronExpression; + + @Override + public String toString() { + return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) + .append("id", getId()) + .append("planName", getPlanName()) + .append("planType", getPlanType()) + .append("robotName", getRobotName()) + .append("appTypeName", getAppTypeName()) + .append("appName", getAppName()) + .append("appId", getAppId()) + .append("appType", getAppType()) + .append("manualTime", getManualTime()) + .append("params", getParams()) + .append("waitTimeout", getWaitTimeout()) + .append("priority", getPriority()) + .append("createBy", getCreateBy()) + .append("createTime", getCreateTime()) + .append("updateBy", getUpdateBy()) + .append("updateTime", getUpdateTime()) + .append("remark", getRemark()) + .append("deleted", getDeleted()) + .toString(); + } +} diff --git a/ruoyi-business/src/main/java/com/ruoyi/business/domain/bo/ApplyStartBO.java b/ruoyi-business/src/main/java/com/ruoyi/business/domain/bo/ApplyStartBO.java new file mode 100644 index 0000000..20875d3 --- /dev/null +++ b/ruoyi-business/src/main/java/com/ruoyi/business/domain/bo/ApplyStartBO.java @@ -0,0 +1,97 @@ +package com.ruoyi.business.domain.bo; + +import com.fasterxml.jackson.annotation.JsonFormat; +import com.ruoyi.common.annotation.Excel; +import com.ruoyi.common.core.domain.BaseEntity; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; +import org.apache.commons.lang3.builder.ToStringBuilder; +import org.apache.commons.lang3.builder.ToStringStyle; + +import java.util.Date; +import java.util.List; + +/** + * 应用信息管理对象 ct_apply + * + * @author LiuChengRan + * @date 2024-06-13 + */ +@Data +@Builder(toBuilder = true) +@NoArgsConstructor +@AllArgsConstructor +@ApiModel(value = "ApplyStartBO", description = "启动应用") +public class ApplyStartBO { + private static final long serialVersionUID = 1L; + + /** + * 指定的机器人名称 + *

+ * 与robotClientGroupUuid二选一 + */ + private String accountName; + + /** + * 机器人分组Id + *

+ * 与accountName二选一 + */ + private String robotClientGroupUuid; + + /** + * 需要运行的应用 + *

+ * 必填 + */ + private String robotUuid; + /** 计划参数 */ + @Excel(name = "计划参数") + @ApiModelProperty(name="planParams",value = "计划参数") + private String planParams; + /** + * 应用运行参数 + *

+ * 非必填 + */ + private List planParamsList; + + /** + * 等待超时时间 + * + * @see com.xybot.api.sdk.enums.WaitTimeoutEnum + *

+ * 非必填,不填,默认为10分钟 + */ + private String waitTimeout; + + /** + * 优先级 + * + * @see com.xybot.api.sdk.enums.PriorityEnum + * 非必填,不填,默认为middle + */ + private String priority; + + @Excel(name = "所属公司") + @ApiModelProperty(name = "deptId", value = "所属公司") + private Long deptId; + + /** + * 应用运行参数 + */ + @Data + private static class RobotParam { + // 参数名 + private String name; + // 参数值 + private String value; + // 参数类型 + private String type; + + } +} diff --git a/ruoyi-business/src/main/java/com/ruoyi/business/domain/bo/JobQueryBO.java b/ruoyi-business/src/main/java/com/ruoyi/business/domain/bo/JobQueryBO.java new file mode 100644 index 0000000..ed79165 --- /dev/null +++ b/ruoyi-business/src/main/java/com/ruoyi/business/domain/bo/JobQueryBO.java @@ -0,0 +1,19 @@ +package com.ruoyi.business.domain.bo; + +import lombok.Data; + +/** + * 停止job请求 + * + * @author boyi + * @since 2022/8/26 10:16 + */ +@Data +public class JobQueryBO { + + /** + * 应用运行的uuid, 由job/start接口返回 + */ + private String jobUuid; +} + diff --git a/ruoyi-business/src/main/java/com/ruoyi/business/domain/vo/JobQueryVO.java b/ruoyi-business/src/main/java/com/ruoyi/business/domain/vo/JobQueryVO.java new file mode 100644 index 0000000..1676add --- /dev/null +++ b/ruoyi-business/src/main/java/com/ruoyi/business/domain/vo/JobQueryVO.java @@ -0,0 +1,104 @@ +package com.ruoyi.business.domain.vo; + +import com.fasterxml.jackson.annotation.JsonFormat; +import lombok.Data; + +import java.util.Date; + +/** + * 查询job响应 + * + * @author boyi + * @since 2022/8/26 10:17 + */ +@Data +public class JobQueryVO { + + /** + * 启动的任务的uuid + * + * 不为空 + */ + private String jobUuid; + + /** + * 任务状态 + * + * 不为空 + * @see com.xybot.api.sdk.enums.JobStatusEnum + */ + private String status; + + /** + * 任务状态名称 + * + * 不为空 + * + * @see com.xybot.api.sdk.enums.JobStatusEnum + */ + private String statusName; + + /** + * 运行的应用 + * + * 不为空 + */ + private String robotUuid; + + /** + * 运行的应用名称 + * + * 不为空 + */ + private String robotName; + + /** + * 任务开始运行的时间 + */ + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") + private Date startTime; + + /** + * 任务结束运行的时间 + */ + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") + private Date endTime; + + /** + * 备注 + */ + private String remark; + + /** + * 应用运行参数 + */ + private RobotParam robotParams; + + /** + * 机器人账号 + * + * 不为空 + */ + private String robotClientUuid; + + /** + * 机器人名称 + * + * 不为空 + */ + private String robotClientName; + + /** + * 应用运行参数 + */ + @Data + private static class RobotParam { + // 参数名 + private String name; + // 参数值 + private String value; + // 参数类型 + private String type; + + } +} \ No newline at end of file diff --git a/ruoyi-business/src/main/java/com/ruoyi/business/domain/vo/JobStartVO.java b/ruoyi-business/src/main/java/com/ruoyi/business/domain/vo/JobStartVO.java new file mode 100644 index 0000000..32c992b --- /dev/null +++ b/ruoyi-business/src/main/java/com/ruoyi/business/domain/vo/JobStartVO.java @@ -0,0 +1,18 @@ +package com.ruoyi.business.domain.vo; + +import lombok.Data; + +/** + * jobStart响应 + * + * @author boyi + * @since 2022/8/24 10:54 + */ +@Data +public class JobStartVO { + + /** + * 启动的job的uuid + */ + private String jobUuid; +} diff --git a/ruoyi-business/src/main/java/com/ruoyi/business/mapper/ApplyPlanLogMapper.java b/ruoyi-business/src/main/java/com/ruoyi/business/mapper/ApplyPlanLogMapper.java new file mode 100644 index 0000000..8729312 --- /dev/null +++ b/ruoyi-business/src/main/java/com/ruoyi/business/mapper/ApplyPlanLogMapper.java @@ -0,0 +1,24 @@ +package com.ruoyi.business.mapper; + +import java.util.List; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.ruoyi.business.domain.ApplyPlanLog; + +/** + * 应用执行结果记录管理Mapper接口 + * + * @author LiuChengRan + * @date 2024-06-14 + */ +public interface ApplyPlanLogMapper extends BaseMapper +{ + + /** + * 查询应用执行结果记录管理列表 + * + * @param applyPlanLog 应用执行结果记录管理 + * @return 应用执行结果记录管理集合 + */ + List selectApplyPlanLogList(ApplyPlanLog applyPlanLog); + +} diff --git a/ruoyi-business/src/main/java/com/ruoyi/business/mapper/ApplyPlanMapper.java b/ruoyi-business/src/main/java/com/ruoyi/business/mapper/ApplyPlanMapper.java new file mode 100644 index 0000000..69bfaa5 --- /dev/null +++ b/ruoyi-business/src/main/java/com/ruoyi/business/mapper/ApplyPlanMapper.java @@ -0,0 +1,24 @@ +package com.ruoyi.business.mapper; + +import java.util.List; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.ruoyi.business.domain.ApplyPlan; + +/** + * 应用执行计划管理Mapper接口 + * + * @author LiuChengRan + * @date 2024-06-14 + */ +public interface ApplyPlanMapper extends BaseMapper +{ + + /** + * 查询应用执行计划管理列表 + * + * @param applyPlan 应用执行计划管理 + * @return 应用执行计划管理集合 + */ + List selectApplyPlanList(ApplyPlan applyPlan); + +} diff --git a/ruoyi-business/src/main/java/com/ruoyi/business/service/IApplyPlanLogService.java b/ruoyi-business/src/main/java/com/ruoyi/business/service/IApplyPlanLogService.java new file mode 100644 index 0000000..000035a --- /dev/null +++ b/ruoyi-business/src/main/java/com/ruoyi/business/service/IApplyPlanLogService.java @@ -0,0 +1,24 @@ +package com.ruoyi.business.service; + +import java.util.List; +import com.ruoyi.business.domain.ApplyPlanLog; +import com.baomidou.mybatisplus.extension.service.IService; + +/** + * 应用执行结果记录管理Service接口 + * + * @author LiuChengRan + * @date 2024-06-14 + */ +public interface IApplyPlanLogService extends IService +{ + + /** + * 查询应用执行结果记录管理列表 + * + * @param applyPlanLog 应用执行结果记录管理 + * @return 应用执行结果记录管理集合 + */ + List list(ApplyPlanLog applyPlanLog); + +} diff --git a/ruoyi-business/src/main/java/com/ruoyi/business/service/IApplyPlanService.java b/ruoyi-business/src/main/java/com/ruoyi/business/service/IApplyPlanService.java new file mode 100644 index 0000000..1c3c215 --- /dev/null +++ b/ruoyi-business/src/main/java/com/ruoyi/business/service/IApplyPlanService.java @@ -0,0 +1,45 @@ +package com.ruoyi.business.service; + +import java.util.List; + +import com.ruoyi.business.domain.ApplyPlan; +import com.baomidou.mybatisplus.extension.service.IService; +import com.ruoyi.business.domain.bo.AddApplyPlanBO; + +/** + * 应用执行计划管理Service接口 + * + * @author LiuChengRan + * @date 2024-06-14 + */ +public interface IApplyPlanService extends IService { + + /** + * 执行计划 + * @param addApplyPlanBO + * @return + */ + boolean execPlan() throws IllegalAccessException; + + /** + * 创建计划 + * @param addApplyPlanBO + * @return + */ + boolean save(AddApplyPlanBO addApplyPlanBO); + + /** + * 修改计划 + * @param addApplyPlanBO + * @return + */ + boolean update(AddApplyPlanBO addApplyPlanBO); + /** + * 查询应用执行计划管理列表 + * + * @param applyPlan 应用执行计划管理 + * @return 应用执行计划管理集合 + */ + List list(ApplyPlan applyPlan); + +} diff --git a/ruoyi-business/src/main/java/com/ruoyi/business/service/IApplyService.java b/ruoyi-business/src/main/java/com/ruoyi/business/service/IApplyService.java index 1742379..6f169a8 100644 --- a/ruoyi-business/src/main/java/com/ruoyi/business/service/IApplyService.java +++ b/ruoyi-business/src/main/java/com/ruoyi/business/service/IApplyService.java @@ -4,6 +4,11 @@ import java.util.List; import com.ruoyi.business.domain.Apply; import com.baomidou.mybatisplus.extension.service.IService; import com.ruoyi.business.domain.Rebot; +import com.ruoyi.business.domain.bo.ApplyStartBO; +import com.ruoyi.business.domain.bo.JobQueryBO; +import com.ruoyi.business.domain.vo.JobQueryVO; +import com.ruoyi.business.domain.vo.JobStartVO; +import com.ruoyi.common.annotation.DataScope; /** * 应用信息管理Service接口 @@ -14,10 +19,20 @@ import com.ruoyi.business.domain.Rebot; public interface IApplyService extends IService { /** - * 同步机器人数据 + * 启动应用 * @return */ - void syn(Apply apply); + JobStartVO appStart(ApplyStartBO applyStartBO) throws IllegalAccessException; + /** + * 查询应用运行结果 + * @return + */ + JobQueryVO queryAppStartResult(JobQueryBO jobQueryBO) throws IllegalAccessException; + /** + * 同步应用数据 + * @return + */ + void syn(Apply apply) throws IllegalAccessException; /** * 查询应用信息管理列表 * diff --git a/ruoyi-business/src/main/java/com/ruoyi/business/service/IRebotService.java b/ruoyi-business/src/main/java/com/ruoyi/business/service/IRebotService.java index 716df27..a1d5299 100644 --- a/ruoyi-business/src/main/java/com/ruoyi/business/service/IRebotService.java +++ b/ruoyi-business/src/main/java/com/ruoyi/business/service/IRebotService.java @@ -17,7 +17,7 @@ public interface IRebotService extends IService * 同步机器人数据 * @return */ - void syn(Rebot rebot); + void syn(Rebot rebot) throws IllegalAccessException; /** * 查询机器人管理列表 * diff --git a/ruoyi-business/src/main/java/com/ruoyi/business/service/impl/ApplyPlanLogServiceImpl.java b/ruoyi-business/src/main/java/com/ruoyi/business/service/impl/ApplyPlanLogServiceImpl.java new file mode 100644 index 0000000..7f622e2 --- /dev/null +++ b/ruoyi-business/src/main/java/com/ruoyi/business/service/impl/ApplyPlanLogServiceImpl.java @@ -0,0 +1,34 @@ +package com.ruoyi.business.service.impl; + +import java.util.List; +import com.ruoyi.common.utils.DateUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import com.ruoyi.business.mapper.ApplyPlanLogMapper; +import com.ruoyi.business.domain.ApplyPlanLog; +import com.ruoyi.business.service.IApplyPlanLogService; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; + +/** + * 应用执行结果记录管理Service业务层处理 + * + * @author LiuChengRan + * @date 2024-06-14 + */ +@Service +public class ApplyPlanLogServiceImpl extends ServiceImpl implements IApplyPlanLogService +{ + + + /** + * 查询应用执行结果记录管理列表 + * + * @param applyPlanLog 应用执行结果记录管理 + * @return 应用执行结果记录管理 + */ + @Override + public List list(ApplyPlanLog applyPlanLog) + { + return baseMapper.selectApplyPlanLogList(applyPlanLog); + } +} diff --git a/ruoyi-business/src/main/java/com/ruoyi/business/service/impl/ApplyPlanServiceImpl.java b/ruoyi-business/src/main/java/com/ruoyi/business/service/impl/ApplyPlanServiceImpl.java new file mode 100644 index 0000000..2542dbd --- /dev/null +++ b/ruoyi-business/src/main/java/com/ruoyi/business/service/impl/ApplyPlanServiceImpl.java @@ -0,0 +1,139 @@ +package com.ruoyi.business.service.impl; + +import java.util.ArrayList; +import java.util.Date; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; + +import com.ruoyi.business.domain.Apply; +import com.ruoyi.business.domain.Rebot; +import com.ruoyi.business.domain.bo.AddApplyPlanBO; +import com.ruoyi.business.domain.bo.ApplyStartBO; +import com.ruoyi.business.domain.bo.ListApplyBO; +import com.ruoyi.business.domain.bo.ListRebotBO; +import com.ruoyi.business.domain.vo.JobStartVO; +import com.ruoyi.business.domain.vo.ListRebotVO; +import com.ruoyi.business.service.IApplyService; +import com.ruoyi.business.service.IRebotService; +import com.ruoyi.business.util.YinDaoHttpUtils; +import com.ruoyi.common.annotation.DataScope; +import com.ruoyi.common.enums.ExcTypeStatus; +import com.ruoyi.common.utils.DateUtils; +import com.ruoyi.common.utils.SecurityUtils; +import com.ruoyi.common.utils.bean.BeanUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import com.ruoyi.business.mapper.ApplyPlanMapper; +import com.ruoyi.business.domain.ApplyPlan; +import com.ruoyi.business.service.IApplyPlanService; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import org.springframework.transaction.annotation.Transactional; + +import static cn.hutool.json.XMLTokener.entity; + +/** + * 应用执行计划管理Service业务层处理 + * + * @author LiuChengRan + * @date 2024-06-14 + */ +@Service +public class ApplyPlanServiceImpl extends ServiceImpl implements IApplyPlanService { + @Autowired + private IApplyService applyService; + + @Autowired + private IRebotService rebotService; + + /** + * 执行计划(针对立即执行的计划) + * + * @return + */ + @Override + @Transactional + public boolean execPlan() throws IllegalAccessException { + ListRebotBO listRebotBO = new ListRebotBO(); + listRebotBO.setStatus("idle"); + listRebotBO.setPage(1); + listRebotBO.setSize(100); + // 只获取空闲的机器人 + List listRebotVOS = YinDaoHttpUtils.listRebot(listRebotBO); + if (listRebotVOS.isEmpty()) { + log.error("暂无空闲机器人"); + // 刷新机器人数据 +// rebotService.syn(new Rebot()); + } + for (ListRebotVO listRebotVO : listRebotVOS) { + List list = this.lambdaQuery().eq(ApplyPlan::getExcType, ExcTypeStatus.ONE.getKey()).isNull(ApplyPlan::getTaskUuid).orderByAsc(ApplyPlan::getPriority).list(); + if (list.isEmpty()) { + log.debug("没有等待执行的计划"); + break; + } + ApplyStartBO applyStartBO = new ApplyStartBO(); + ApplyPlan applyPlan = list.get(0); + applyStartBO.setRobotUuid(applyPlan.getAppId()); + applyStartBO.setAccountName(listRebotVO.getRobotClientName()); + //high 高 middle 中 low 低 + applyStartBO.setPriority("high"); + JobStartVO jobStartVO = YinDaoHttpUtils.appStart(applyStartBO); + ApplyPlan updateApplyPlan = new ApplyPlan(); + updateApplyPlan.setId(applyPlan.getId()); + updateApplyPlan.setUpdateBy("-1"); + updateApplyPlan.setUpdateTime(new Date()); + updateApplyPlan.setTaskUuid(jobStartVO.getJobUuid()); + this.updateById(updateApplyPlan); + } + + return false; + } + + @Override + public boolean save(AddApplyPlanBO addApplyPlanBO) { + List applyPlanList = new ArrayList<>(); + Map> appMap = applyService.lambdaQuery().in(Apply::getAppId, addApplyPlanBO.getAppId()).list().stream().collect(Collectors.groupingBy(Apply::getAppId)); + addApplyPlanBO.getAppId().forEach(e -> { + ApplyPlan applyPlan = new ApplyPlan(); + BeanUtils.copyBeanProp(applyPlan, addApplyPlanBO); + Apply apply = appMap.get(e).get(0); + applyPlan.setAppName(apply.getAppName()); + applyPlan.setAppId(apply.getAppId()); + applyPlan.setAppType(apply.getAppType()); + applyPlan.setAppTypeName(apply.getAppTypeName()); + applyPlanList.add(applyPlan); + }); + + return super.saveBatch(applyPlanList); + } + + @Override + public boolean update(AddApplyPlanBO addApplyPlanBO) { + List applyPlanList = new ArrayList<>(); + Map> appMap = applyService.lambdaQuery().in(Apply::getAppId, addApplyPlanBO.getAppId()).eq(Apply::getDeptId, SecurityUtils.getDeptId()).list().stream().collect(Collectors.groupingBy(Apply::getAppId)); + addApplyPlanBO.getAppId().forEach(e -> { + ApplyPlan applyPlan = new ApplyPlan(); + BeanUtils.copyBeanProp(applyPlan, addApplyPlanBO); + Apply apply = appMap.get(e).get(0); + applyPlan.setAppName(apply.getAppName()); + applyPlan.setAppId(apply.getAppId()); + applyPlan.setAppType(apply.getAppType()); + applyPlan.setAppTypeName(apply.getAppTypeName()); + applyPlanList.add(applyPlan); + }); + + return super.updateBatchById(applyPlanList); + } + + /** + * 查询应用执行计划管理列表 + * + * @param applyPlan 应用执行计划管理 + * @return 应用执行计划管理 + */ + @Override + @DataScope(deptAlias = "d") + public List list(ApplyPlan applyPlan) { + return baseMapper.selectApplyPlanList(applyPlan); + } +} diff --git a/ruoyi-business/src/main/java/com/ruoyi/business/service/impl/ApplyServiceImpl.java b/ruoyi-business/src/main/java/com/ruoyi/business/service/impl/ApplyServiceImpl.java index 73e1c5a..24c93d1 100644 --- a/ruoyi-business/src/main/java/com/ruoyi/business/service/impl/ApplyServiceImpl.java +++ b/ruoyi-business/src/main/java/com/ruoyi/business/service/impl/ApplyServiceImpl.java @@ -6,15 +6,21 @@ import java.util.stream.Collectors; import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; import com.ruoyi.business.domain.Rebot; +import com.ruoyi.business.domain.bo.ApplyStartBO; +import com.ruoyi.business.domain.bo.JobQueryBO; import com.ruoyi.business.domain.bo.ListApplyBO; import com.ruoyi.business.domain.bo.ListRebotBO; +import com.ruoyi.business.domain.vo.JobQueryVO; +import com.ruoyi.business.domain.vo.JobStartVO; import com.ruoyi.business.domain.vo.ListApplyVO; import com.ruoyi.business.domain.vo.ListRebotVO; import com.ruoyi.business.util.YinDaoHttpUtils; import com.ruoyi.common.annotation.DataScope; +import com.ruoyi.common.core.domain.entity.SysDept; import com.ruoyi.common.utils.DateUtils; import com.ruoyi.common.utils.SecurityUtils; import com.ruoyi.common.utils.bean.BeanUtils; +import com.ruoyi.system.service.ISysDeptService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import com.ruoyi.business.mapper.ApplyMapper; @@ -25,13 +31,37 @@ import org.springframework.transaction.annotation.Transactional; /** * 应用信息管理Service业务层处理 - * + * * @author LiuChengRan * @date 2024-06-13 */ @Service -public class ApplyServiceImpl extends ServiceImpl implements IApplyService -{ +public class ApplyServiceImpl extends ServiceImpl implements IApplyService { + + @Autowired + private ISysDeptService sysDeptService; + /** + * 启动应用 + * + * @param applyStartBO + */ + @Override + @Transactional + public JobStartVO appStart(ApplyStartBO applyStartBO) throws IllegalAccessException { + JobStartVO jobStartVO = YinDaoHttpUtils.appStart(applyStartBO); + return jobStartVO; + } + + /** + * 查询应用运行结果 + * + * @param jobQueryBO + */ + @Override + public JobQueryVO queryAppStartResult(JobQueryBO jobQueryBO) throws IllegalAccessException { + JobQueryVO jobQueryVO = YinDaoHttpUtils.queryAppStartResult(jobQueryBO); + return jobQueryVO; + } /** @@ -40,50 +70,64 @@ public class ApplyServiceImpl extends ServiceImpl implements * @return */ @Override - @DataScope(deptAlias = "d", userAlias = "u") + @DataScope(deptAlias = "apply") @Transactional - public void syn(Apply entity) { + public void syn(Apply entity) throws IllegalAccessException { ListApplyBO listApplyBO = new ListApplyBO(); listApplyBO.setPage(1); - listApplyBO.setSize(10000); + // 影刀最大限制 + listApplyBO.setSize(100); List applyList = baseMapper.selectApplyList(new Apply()); Map> applyMap = applyList.stream().collect(Collectors.groupingBy(Apply::getAppId)); List listApplyVOList = YinDaoHttpUtils.listApp(listApplyBO); // 获取客户端名称集合 List appIdList = listApplyVOList.stream().map(ListApplyVO::getAppId).collect(Collectors.toList()); + // 只能移除当前用户部门的 this.remove(new LambdaUpdateWrapper().notIn(Apply::getAppId, appIdList).eq(Apply::getDeptId, SecurityUtils.getDeptId())); + + Map> deptMap = sysDeptService.selectDeptAllList(new SysDept()).stream().collect(Collectors.groupingBy(SysDept::getDeptName)); listApplyVOList.forEach(listRebotVO -> { // 数据库里是否存在 List applys = applyMap.get(listRebotVO.getAppId()); + String[] deptName = listRebotVO.getAppName().split("-"); + List sysDepts = deptMap.get(deptName[0]); + if (null == applys) { Apply newApply = new Apply(); BeanUtils.copyBeanProp(newApply, listRebotVO); - newApply.setAppCreateTime(listRebotVO.getAppCreateTime()); - newApply.setAppUpdateTime(listRebotVO.getAppUpdateTime()); - newApply.setDeptId(SecurityUtils.getDeptId()); + newApply.setAppCreateTime(listRebotVO.getCreateTime()); + newApply.setAppUpdateTime(listRebotVO.getUpdateTime()); + if(null != sysDepts){ + newApply.setDeptId(sysDepts.get(0).getDeptId()); + newApply.setDeptName(sysDepts.get(0).getDeptName()); + } save(newApply); } else { Apply apply = applys.get(0); - Apply newApply =new Apply(); + Apply newApply = new Apply(); BeanUtils.copyBeanProp(newApply, listRebotVO); - newApply.setAppCreateTime(listRebotVO.getAppCreateTime()); - newApply.setAppUpdateTime(listRebotVO.getAppUpdateTime()); + newApply.setAppCreateTime(listRebotVO.getCreateTime()); + newApply.setAppUpdateTime(listRebotVO.getUpdateTime()); newApply.setId(apply.getId()); - newApply.setDeptId(SecurityUtils.getDeptId()); + if(null != sysDepts){ + newApply.setDeptId(sysDepts.get(0).getDeptId()); + newApply.setDeptName(sysDepts.get(0).getDeptName()); + } updateById(newApply); } }); } + /** * 查询应用信息管理列表 - * + * * @param apply 应用信息管理 * @return 应用信息管理 */ @Override - public List list(Apply apply) - { + @DataScope(deptAlias = "apply") + public List list(Apply apply) { return baseMapper.selectApplyList(apply); } } diff --git a/ruoyi-business/src/main/java/com/ruoyi/business/service/impl/RebotServiceImpl.java b/ruoyi-business/src/main/java/com/ruoyi/business/service/impl/RebotServiceImpl.java index 5909100..e43e6ac 100644 --- a/ruoyi-business/src/main/java/com/ruoyi/business/service/impl/RebotServiceImpl.java +++ b/ruoyi-business/src/main/java/com/ruoyi/business/service/impl/RebotServiceImpl.java @@ -9,7 +9,10 @@ import com.ruoyi.business.domain.bo.ListRebotBO; import com.ruoyi.business.domain.vo.ListRebotVO; import com.ruoyi.business.util.YinDaoHttpUtils; import com.ruoyi.common.annotation.DataScope; +import com.ruoyi.common.core.domain.entity.SysDept; import com.ruoyi.common.utils.SecurityUtils; +import com.ruoyi.system.service.ISysDeptService; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import com.ruoyi.business.mapper.RebotMapper; import com.ruoyi.business.domain.Rebot; @@ -25,27 +28,26 @@ import org.springframework.transaction.annotation.Transactional; */ @Service public class RebotServiceImpl extends ServiceImpl implements IRebotService { - - /** * 同步机器人数据 * * @return */ @Override - @DataScope(deptAlias = "d", userAlias = "u") @Transactional - public void syn(Rebot entity) { + public void syn(Rebot entity) throws IllegalAccessException { ListRebotBO listRebotBO = new ListRebotBO(); listRebotBO.setPage(1); - listRebotBO.setSize(10000); + listRebotBO.setSize(100); List rebotsList = baseMapper.selectRebotList(new Rebot()); Map> rebotMap = rebotsList.stream().collect(Collectors.groupingBy(Rebot::getRobotClientName)); List listRebotVoList = YinDaoHttpUtils.listRebot(listRebotBO); // 获取客户端名称集合 List clientNameList = listRebotVoList.stream().map(ListRebotVO::getRobotClientName).collect(Collectors.toList()); - this.remove(new LambdaUpdateWrapper().notIn(Rebot::getRobotClientName, clientNameList).eq(Rebot::getDeptId, SecurityUtils.getDeptId())); + // 删除不存在的机器人 + this.remove(new LambdaUpdateWrapper().notIn(Rebot::getRobotClientName, clientNameList)); + listRebotVoList.forEach(listRebotVO -> { // 数据库里是否存在 List rebots = rebotMap.get(listRebotVO.getRobotClientName()); @@ -56,7 +58,6 @@ public class RebotServiceImpl extends ServiceImpl implements rebot.setRobotClientName(listRebotVO.getRobotClientName()); rebot.setWindowsAccount(listRebotVO.getWindowsAccount()); rebot.setClientIp(listRebotVO.getClientIp()); - rebot.setDeptId(SecurityUtils.getDeptId()); save(rebot); } else { Rebot rebot = rebots.get(0); @@ -65,7 +66,6 @@ public class RebotServiceImpl extends ServiceImpl implements rebot.setRobotClientName(listRebotVO.getRobotClientName()); rebot.setWindowsAccount(listRebotVO.getWindowsAccount()); rebot.setClientIp(listRebotVO.getClientIp()); - rebot.setDeptId(SecurityUtils.getDeptId()); updateById(rebot); } }); @@ -78,6 +78,7 @@ public class RebotServiceImpl extends ServiceImpl implements * @return 机器人管理 */ @Override + @DataScope(deptAlias = "d", userAlias = "u") public List list(Rebot rebot) { return baseMapper.selectRebotList(rebot); } diff --git a/ruoyi-business/src/main/java/com/ruoyi/business/util/YinDaoHttpUtils.java b/ruoyi-business/src/main/java/com/ruoyi/business/util/YinDaoHttpUtils.java index b450c37..7ddca8b 100644 --- a/ruoyi-business/src/main/java/com/ruoyi/business/util/YinDaoHttpUtils.java +++ b/ruoyi-business/src/main/java/com/ruoyi/business/util/YinDaoHttpUtils.java @@ -2,17 +2,23 @@ package com.ruoyi.business.util; import cn.hutool.json.JSONUtil; import com.alibaba.fastjson2.JSON; +import com.ruoyi.business.domain.bo.ApplyStartBO; +import com.ruoyi.business.domain.bo.JobQueryBO; import com.ruoyi.business.domain.bo.ListApplyBO; import com.ruoyi.business.domain.bo.ListRebotBO; +import com.ruoyi.business.domain.vo.JobQueryVO; +import com.ruoyi.business.domain.vo.JobStartVO; import com.ruoyi.business.domain.vo.ListApplyVO; import com.ruoyi.business.domain.vo.ListRebotVO; import com.ruoyi.business.yddoman.BaseDTO; import com.ruoyi.business.yddoman.CreateTokenDTO; import com.ruoyi.common.exception.ServiceException; +import com.ruoyi.common.utils.BeanToMapUtil; import com.ruoyi.common.utils.StringUtils; import com.ruoyi.common.utils.http.HttpClientUtil; import lombok.extern.slf4j.Slf4j; +import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -34,31 +40,81 @@ public class YinDaoHttpUtils { private static final String CLIENT_LIST = REQUEST_PREFIX + "/dispatch/v2/client/list"; // 查询应用列表 private static final String APP_LIST = REQUEST_PREFIX + "/app/open/query/list"; + // 启动应用 + private static final String APP_START = REQUEST_PREFIX + "/dispatch/v2/job/start"; + // 启动应用 + private static final String QUERY_APP_START_RESULT = REQUEST_PREFIX + "/dispatch/v2/job/query"; /** - * 查询机器人列表 + * 启动应用 + */ + public static JobStartVO appStart(ApplyStartBO applyStartBO) throws IllegalAccessException { + // 实体类转map + Map data = BeanToMapUtil.convertEntityToMap(applyStartBO); + BaseDTO baseDTO = sendPost(APP_START, data); + return JSON.parseObject(baseDTO.getData().toString(), JobStartVO.class); + } + + /** + * 查询应用运行结果 + */ + public static JobQueryVO queryAppStartResult(JobQueryBO jobQueryBO) throws IllegalAccessException { + // 实体类转map + Map data = BeanToMapUtil.convertEntityToMap(jobQueryBO); + BaseDTO baseDTO = sendPost(QUERY_APP_START_RESULT, data); + return JSON.parseObject(baseDTO.getData().toString(), JobQueryVO.class); + } + + /** + * 查询应用列表 */ - public static List listApp(ListApplyBO ListApplyBO) { - Map data = new HashMap<>(); - data.put("page", ListApplyBO.getPage().toString()); - data.put("size", ListApplyBO.getSize().toString()); + public static List listApp(ListApplyBO ListApplyBO) throws IllegalAccessException { + Map data = BeanToMapUtil.convertEntityToMap(ListApplyBO); BaseDTO baseDTO = sendPost(APP_LIST, data); - return JSON.parseArray(baseDTO.getData().toString(), ListApplyVO.class); + BaseDTO.Page page = baseDTO.getPage(); + List allList = new ArrayList<>(); + boolean isNext = true; + while (isNext) { + List ListApplyVos = JSON.parseArray(baseDTO.getData().toString(), ListApplyVO.class); + allList.addAll(ListApplyVos); + data = new HashMap<>(); + data.put("page", page.getPage() + 1); + data.put("size", ListApplyBO.getSize()); + if (page.getPage() + 1 > page.getPages()) { + isNext = false; + } else { + baseDTO = sendGet(APP_LIST, data); + page = baseDTO.getPage(); + } + } + return allList; } /** * 查询机器人列表 */ - public static List listRebot(ListRebotBO listRebotBO) { - Map data = new HashMap<>(); - data.put("page", listRebotBO.getPage().toString()); - data.put("size", listRebotBO.getSize().toString()); -// data.put("status", listRebotBO.getStatus()); -// data.put("key", listRebotBO.getKey()); -// data.put("robotClientUuid", "176befff-0dc4-4df1-badf-346305c28ae8"); + public static List listRebot(ListRebotBO listRebotBO) throws IllegalAccessException { + Map data = BeanToMapUtil.convertEntityToMap(listRebotBO); BaseDTO baseDTO = sendGet(CLIENT_LIST, data); - return JSON.parseArray(baseDTO.getData().toString(), ListRebotVO.class); + BaseDTO.Page page = baseDTO.getPage(); + List allList = new ArrayList<>(); + boolean isNext = true; + while (isNext) { + List listRebotVOS = JSON.parseArray(baseDTO.getData().toString(), ListRebotVO.class); + allList.addAll(listRebotVOS); + data = new HashMap<>(); + data.put("page", page.getPage() + 1 + ""); + data.put("size", listRebotBO.getSize().toString()); + if (page.getPage() + 1 > page.getPages()) { + isNext = false; + } else { + baseDTO = sendGet(CLIENT_LIST, data); + page = baseDTO.getPage(); + } + + } + return allList; } diff --git a/ruoyi-business/src/main/java/com/ruoyi/business/yddoman/BaseDTO.java b/ruoyi-business/src/main/java/com/ruoyi/business/yddoman/BaseDTO.java index 82110ba..e18efb9 100644 --- a/ruoyi-business/src/main/java/com/ruoyi/business/yddoman/BaseDTO.java +++ b/ruoyi-business/src/main/java/com/ruoyi/business/yddoman/BaseDTO.java @@ -4,16 +4,25 @@ import lombok.Data; /** * 影刀统一响应父类 - * + * * @author #author# */ @Data -public class BaseDTO -{ +public class BaseDTO { private Integer code; private Boolean success; private String msg; private Object data; + private Page page; + @Data + public static class Page { + private Integer page; + private Integer total; + private Integer size; + private Integer pages; + private Integer offset; + private String order; + } } diff --git a/ruoyi-business/src/main/resources/mapper/business/ApplyMapper.xml b/ruoyi-business/src/main/resources/mapper/business/ApplyMapper.xml index 0a2cacb..165e5f8 100644 --- a/ruoyi-business/src/main/resources/mapper/business/ApplyMapper.xml +++ b/ruoyi-business/src/main/resources/mapper/business/ApplyMapper.xml @@ -33,6 +33,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" + + + + @@ -49,30 +53,33 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" select - id, - owner_name, - owner_account, - owner_id, - app_id, - app_name, - app_type_name, - app_type, - app_create_time, - app_update_time, - version, - support_param, - icon, - manual_time, - create_by, - create_time, - update_by, - update_time, - remark, - deleted + apply.id, + apply.owner_name, + apply.owner_account, + apply.owner_id, + apply.app_id, + apply.app_name, + apply.app_type_name, + apply.app_type, + apply.app_create_time, + apply.app_update_time, + apply.version, + apply.support_param, + apply.icon, + apply.manual_time, + apply.dept_id, + apply.dept_name, + apply.create_by, + apply.create_time, + apply.update_by, + apply.update_time, + apply.remark, + apply.deleted + \ No newline at end of file diff --git a/ruoyi-business/src/main/resources/mapper/business/ApplyPlanLogMapper.xml b/ruoyi-business/src/main/resources/mapper/business/ApplyPlanLogMapper.xml new file mode 100644 index 0000000..1701b2c --- /dev/null +++ b/ruoyi-business/src/main/resources/mapper/business/ApplyPlanLogMapper.xml @@ -0,0 +1,91 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + select + id, + job_uuid, + plan_name, + plan_type, + robot_name, + app_type_name, + app_name, + app_id, + status, + status_name, + start_time, + end_time, + manual_time, + plan_time, + time_saving, + create_by, + create_time, + update_by, + update_time, + remark, + deleted + + + \ No newline at end of file diff --git a/ruoyi-business/src/main/resources/mapper/business/ApplyPlanMapper.xml b/ruoyi-business/src/main/resources/mapper/business/ApplyPlanMapper.xml new file mode 100644 index 0000000..fba1a5a --- /dev/null +++ b/ruoyi-business/src/main/resources/mapper/business/ApplyPlanMapper.xml @@ -0,0 +1,102 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + select + plan.id, + plan.plan_name, + plan.plan_type, + plan.robot_name, + plan.app_type_name, + plan.app_name, + plan.app_id, + plan.app_type, + plan.manual_time, + plan.plan_params, + plan.wait_timeout, + plan.priority, + plan.exc_type, + plan.exc_time, + plan.cron_expression, + plan.task_uuid, + plan.create_by, + plan.create_time, + plan.update_by, + plan.update_time, + plan.remark, + plan.deleted + + + + \ No newline at end of file diff --git a/ruoyi-business/src/main/resources/mapper/business/RebotMapper.xml b/ruoyi-business/src/main/resources/mapper/business/RebotMapper.xml index 98501f1..d7d95db 100644 --- a/ruoyi-business/src/main/resources/mapper/business/RebotMapper.xml +++ b/ruoyi-business/src/main/resources/mapper/business/RebotMapper.xml @@ -57,19 +57,15 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" \ No newline at end of file diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/enums/ExcTypeStatus.java b/ruoyi-common/src/main/java/com/ruoyi/common/enums/ExcTypeStatus.java new file mode 100644 index 0000000..a2a7e75 --- /dev/null +++ b/ruoyi-common/src/main/java/com/ruoyi/common/enums/ExcTypeStatus.java @@ -0,0 +1,35 @@ +package com.ruoyi.common.enums; + +/** + * 机器人状态枚举 + */ + +public enum ExcTypeStatus { + ONE("0", "立即执行"), + TWO("1", "指定时间执行"), + TREE("2", "周期执行"); + + private String key; + private String value; + + public String getKey() { + return key; + } + + public void setKey(String key) { + this.key = key; + } + + public String getValue() { + return value; + } + + public void setValue(String value) { + this.value = value; + } + + ExcTypeStatus(String key, String value) { + this.key = key; + this.value = value; + } +} diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/enums/RebotStatus.java b/ruoyi-common/src/main/java/com/ruoyi/common/enums/RebotStatus.java new file mode 100644 index 0000000..76e8ef8 --- /dev/null +++ b/ruoyi-common/src/main/java/com/ruoyi/common/enums/RebotStatus.java @@ -0,0 +1,39 @@ +package com.ruoyi.common.enums; + +import lombok.Data; + +/** + * 机器人状态枚举 + */ + +public enum RebotStatus { + CONNECTED("connected", "已连接"), + IDLE("idle", "空闲"), + ALLOCATED("allocated", "已分配"), + RUNNING("running", "运行中"), + OFFLINE("offline", "离线"); + + private String key; + private String value; + + public String getKey() { + return key; + } + + public void setKey(String key) { + this.key = key; + } + + public String getValue() { + return value; + } + + public void setValue(String value) { + this.value = value; + } + + RebotStatus(String key, String value) { + this.key = key; + this.value = value; + } +} diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/utils/BeanToMapUtil.java b/ruoyi-common/src/main/java/com/ruoyi/common/utils/BeanToMapUtil.java new file mode 100644 index 0000000..d7ebe37 --- /dev/null +++ b/ruoyi-common/src/main/java/com/ruoyi/common/utils/BeanToMapUtil.java @@ -0,0 +1,30 @@ +package com.ruoyi.common.utils; + +import java.lang.reflect.Field; +import java.util.HashMap; +import java.util.Map; + +/** + * 实体类转map + */ +public class BeanToMapUtil { + public static Map convertEntityToMap(T entity) throws IllegalAccessException { + Map map = new HashMap<>(); + // 获取对象的类 + Class clazz = entity.getClass(); + // 获取类中的所有字段 + Field[] fields = clazz.getDeclaredFields(); + // 遍历字段,将字段名和值存入Map + for (Field field : fields) { + // 设置字段可访问(非public字段需要设置访问权限) + field.setAccessible(true); + // 获取字段名 + String fieldName = field.getName(); + // 获取字段值 + Object fieldValue = field.get(entity); + // 将字段名和值存入Map + map.put(fieldName, fieldValue); + } + return map; + } +} diff --git a/ruoyi-quartz/pom.xml b/ruoyi-quartz/pom.xml index 1922bcf..5084016 100644 --- a/ruoyi-quartz/pom.xml +++ b/ruoyi-quartz/pom.xml @@ -35,6 +35,12 @@ ruoyi-common + + + com.ruoyi + ruoyi-business + + \ No newline at end of file diff --git a/ruoyi-quartz/src/main/java/com/ruoyi/quartz/task/RyTask.java b/ruoyi-quartz/src/main/java/com/ruoyi/quartz/task/RyTask.java index 086eda4..fe12948 100644 --- a/ruoyi-quartz/src/main/java/com/ruoyi/quartz/task/RyTask.java +++ b/ruoyi-quartz/src/main/java/com/ruoyi/quartz/task/RyTask.java @@ -1,28 +1,40 @@ package com.ruoyi.quartz.task; +import com.ruoyi.business.domain.ApplyPlan; +import com.ruoyi.business.service.IApplyPlanService; +import com.ruoyi.common.enums.ExcTypeStatus; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; import com.ruoyi.common.utils.StringUtils; /** * 定时任务调度测试 - * + * * @author #author# */ @Component("ryTask") -public class RyTask -{ - public void ryMultipleParams(String s, Boolean b, Long l, Double d, Integer i) - { +public class RyTask { + @Autowired + private IApplyPlanService applyPlanService; + + public void ryMultipleParams(String s, Boolean b, Long l, Double d, Integer i) { System.out.println(StringUtils.format("执行多参方法: 字符串类型{},布尔类型{},长整型{},浮点型{},整形{}", s, b, l, d, i)); } - public void ryParams(String params) - { + public void ryParams(String params) { System.out.println("执行有参方法:" + params); } - public void ryNoParams() - { + public void ryNoParams() { System.out.println("执行无参方法"); } + + /** + * 按优先级执行立即执行的计划任务 + */ + public void runAppNow() throws IllegalAccessException { + System.out.println("执行顺序启动应用开始"); + applyPlanService.execPlan(); + System.out.println("执行顺序启动应用结束"); + } } diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysDeptMapper.java b/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysDeptMapper.java index 355d7f2..04cfb68 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysDeptMapper.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysDeptMapper.java @@ -17,6 +17,12 @@ public interface SysDeptMapper * @param dept 部门信息 * @return 部门信息集合 */ + public List selectDeptAllList(SysDept dept); /** + * 查询部门管理数据 + * + * @param dept 部门信息 + * @return 部门信息集合 + */ public List selectDeptList(SysDept dept); /** diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/ISysDeptService.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/ISysDeptService.java index 42f7cbe..54617fa 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/service/ISysDeptService.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/ISysDeptService.java @@ -11,6 +11,14 @@ import com.ruoyi.common.core.domain.entity.SysDept; */ public interface ISysDeptService { + + /** + * 查询部门管理数据 + * + * @param dept 部门信息 + * @return 部门信息集合 + */ + public List selectDeptAllList(SysDept dept); /** * 查询部门管理数据 * diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysDeptServiceImpl.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysDeptServiceImpl.java index fd65555..27ac3b7 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysDeptServiceImpl.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysDeptServiceImpl.java @@ -1,6 +1,7 @@ package com.ruoyi.system.service.impl; import java.util.ArrayList; +import java.util.Collections; import java.util.Iterator; import java.util.List; import java.util.stream.Collectors; @@ -34,6 +35,16 @@ public class SysDeptServiceImpl implements ISysDeptService @Autowired private SysRoleMapper roleMapper; + /** + * 查询部门管理数据 + * + * @param dept 部门信息 + * @return 部门信息集合 + */ + @Override + public List selectDeptAllList(SysDept dept) { + return deptMapper.selectDeptAllList(dept); + } /** * 查询部门管理数据 diff --git a/ruoyi-system/src/main/resources/mapper/system/SysDeptMapper.xml b/ruoyi-system/src/main/resources/mapper/system/SysDeptMapper.xml index cf439f6..b7e9e8f 100644 --- a/ruoyi-system/src/main/resources/mapper/system/SysDeptMapper.xml +++ b/ruoyi-system/src/main/resources/mapper/system/SysDeptMapper.xml @@ -26,7 +26,24 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" select d.dept_id, d.parent_id, d.ancestors, d.dept_name, d.order_num, d.leader, d.phone, d.email, d.status, d.del_flag, d.create_by, d.create_time from sys_dept d - + + +