Browse Source

任务相关

master
DX 5 days ago
parent
commit
fc404ea39f
  1. 4
      ruoyi-admin/src/main/java/com/ruoyi/web/controller/app/EnterpriseController.java
  2. 24
      ruoyi-admin/src/main/java/com/ruoyi/web/controller/app/TaskController.java
  3. 1
      ruoyi-admin/src/main/java/com/ruoyi/web/controller/app/WeChatLoginController.java
  4. 12
      ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/EnterprisesController.java
  5. 27
      ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysLoginController.java
  6. 106
      ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/TasksController.java
  7. 8
      ruoyi-common/pom.xml
  8. 19
      ruoyi-common/src/main/java/com/ruoyi/common/config/WeChatConfig.java
  9. 24
      ruoyi-common/src/main/java/com/ruoyi/common/core/domain/TaskDTO.java
  10. 41
      ruoyi-common/src/main/java/com/ruoyi/common/utils/ScheduleUtils.java
  11. 2
      ruoyi-framework/src/main/java/com/ruoyi/framework/config/SecurityConfig.java
  12. 15
      ruoyi-framework/src/main/java/com/ruoyi/framework/utils/WeChatUtils.java
  13. 22
      ruoyi-framework/src/main/java/com/ruoyi/framework/web/service/SysLoginService.java
  14. 2
      ruoyi-generator/src/main/resources/vm/java/controller.java.vm
  15. 124
      ruoyi-generator/src/main/resources/vm/java/domain.java.vm
  16. 73
      ruoyi-generator/src/main/resources/vm/java/mapper.java.vm
  17. 46
      ruoyi-generator/src/main/resources/vm/java/service.java.vm
  18. 130
      ruoyi-generator/src/main/resources/vm/java/serviceImpl.java.vm
  19. 2
      ruoyi-quartz/pom.xml
  20. 22
      ruoyi-quartz/src/main/java/com/ruoyi/quartz/config/AutowiringSpringBeanJobFactory.java
  21. 30
      ruoyi-quartz/src/main/java/com/ruoyi/quartz/config/QuartzConfig.java
  22. 2
      ruoyi-quartz/src/main/java/com/ruoyi/quartz/config/ScheduleConfig.java
  23. 25
      ruoyi-quartz/src/main/java/com/ruoyi/quartz/task/AutoTaskJob.java
  24. 32
      ruoyi-system/src/main/java/com/ruoyi/system/domain/TaskEnterprises.java
  25. 86
      ruoyi-system/src/main/java/com/ruoyi/system/domain/Tasks.java
  26. 9
      ruoyi-system/src/main/java/com/ruoyi/system/domain/vo/LabelValueVo.java
  27. 6
      ruoyi-system/src/main/java/com/ruoyi/system/domain/vo/RegisterVo.java
  28. 25
      ruoyi-system/src/main/java/com/ruoyi/system/domain/vo/TaskSaveVo.java
  29. 16
      ruoyi-system/src/main/java/com/ruoyi/system/mapper/TaskEnterprisesMapper.java
  30. 17
      ruoyi-system/src/main/java/com/ruoyi/system/mapper/TasksMapper.java
  31. 3
      ruoyi-system/src/main/java/com/ruoyi/system/service/IEnterprisesService.java
  32. 15
      ruoyi-system/src/main/java/com/ruoyi/system/service/ITaskEnterprisesService.java
  33. 19
      ruoyi-system/src/main/java/com/ruoyi/system/service/ITasksService.java
  34. 23
      ruoyi-system/src/main/java/com/ruoyi/system/service/impl/EnterprisesServiceImpl.java
  35. 19
      ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TaskEnterprisesServiceImpl.java
  36. 74
      ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TasksServiceImpl.java
  37. 106
      ruoyi-system/src/main/resources/mapper/system/TasksMapper.xml

4
ruoyi-admin/src/main/java/com/ruoyi/web/controller/app/EnterpriseController.java

@ -68,6 +68,10 @@ public class EnterpriseController extends BaseController{
return success(enterprisesService.selectEnterprisesById(id)); return success(enterprisesService.selectEnterprisesById(id));
} }
// public AjaxResult getEnterprisesByUserId(Long userId) {
//
// }
/** /**
* 新增企业 * 新增企业
*/ */

24
ruoyi-admin/src/main/java/com/ruoyi/web/controller/app/TaskController.java

@ -0,0 +1,24 @@
package com.ruoyi.web.controller.app;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.system.service.ITasksService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
@RequestMapping("/app/task")
@Slf4j
public class TaskController {
@Autowired
private ITasksService iTasksService;
@RequestMapping("/list")
public AjaxResult getTask() {
iTasksService.getAppTaskList();
return AjaxResult.success();
}
}

1
ruoyi-admin/src/main/java/com/ruoyi/web/controller/app/WeChatLoginController.java

@ -83,5 +83,4 @@ public class WeChatLoginController {
ajax.put("permissions", permissions); ajax.put("permissions", permissions);
return ajax; return ajax;
} }
} }

12
ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/EnterprisesController.java

@ -5,6 +5,7 @@ import javax.servlet.http.HttpServletResponse;
import com.ruoyi.system.domain.EnterpriseUsers; import com.ruoyi.system.domain.EnterpriseUsers;
import com.ruoyi.system.domain.vo.EnterpriseUserInsertVo; import com.ruoyi.system.domain.vo.EnterpriseUserInsertVo;
import com.ruoyi.system.domain.vo.LabelValueVo;
import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.GetMapping;
@ -49,6 +50,17 @@ public class EnterprisesController extends BaseController
return getDataTable(list); return getDataTable(list);
} }
/**
* 查询企业简易列表
*/
// @PreAuthorize("@ss.hasPermi('system:enterprises:list')")
@GetMapping("/simpleList")
public AjaxResult simpleList(Enterprises enterprises)
{
List<LabelValueVo> list = enterprisesService.simpleList(enterprises);
return success(list);
}
/** /**
* 导出企业列表 * 导出企业列表
*/ */

27
ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysLoginController.java

@ -2,6 +2,8 @@ package com.ruoyi.web.controller.system;
import java.util.List; import java.util.List;
import java.util.Set; import java.util.Set;
import com.ruoyi.framework.utils.WeChatUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import com.ruoyi.common.constant.Constants; import com.ruoyi.common.constant.Constants;
@ -37,13 +39,16 @@ public class SysLoginController
@Autowired @Autowired
private TokenService tokenService; private TokenService tokenService;
@Autowired
private WeChatUtils weChatUtils;
/** /**
* 登录方法 * 登录方法
* *
* @param loginBody 登录信息 * @param loginBody 登录信息
* @return 结果 * @return 结果
*/ */
@PostMapping("/login") @PostMapping("login")
public AjaxResult login(@RequestBody LoginBody loginBody) public AjaxResult login(@RequestBody LoginBody loginBody)
{ {
AjaxResult ajax = AjaxResult.success(); AjaxResult ajax = AjaxResult.success();
@ -92,4 +97,24 @@ public class SysLoginController
List<SysMenu> menus = menuService.selectMenuTreeByUserId(userId); List<SysMenu> menus = menuService.selectMenuTreeByUserId(userId);
return AjaxResult.success(menuService.buildMenus(menus)); return AjaxResult.success(menuService.buildMenus(menus));
} }
/**
* 获取微信二维码 URL
*/
@GetMapping("/wechat/qrcode")
public AjaxResult getWeChatQRCode(@RequestParam String state) {
String url = weChatUtils.getQRCodeUrl(state);
return AjaxResult.success("成功获取二维码", url);
}
@GetMapping("/login/callback")
public AjaxResult weChatCallback(@RequestParam String code, @RequestParam String state) {
// 校验 state 是否匹配(防止 CSRF 攻击)
if (!"veryGood".equals(state)) {
return AjaxResult.error("非法请求");
}
// 使用 code 获取微信用户信息
String token = loginService.weChatLogin(code, "00");
return AjaxResult.success("登录成功", token);
}
} }

106
ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/TasksController.java

@ -0,0 +1,106 @@
package com.ruoyi.web.controller.system;
import java.util.List;
import javax.servlet.http.HttpServletResponse;
import com.ruoyi.system.domain.vo.TaskSaveVo;
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.system.domain.Tasks;
import com.ruoyi.system.service.ITasksService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;
/**
* 任务用于存储所有的任务信息任务可由不同用户创建并管理Controller
*
* @author ruoyi
* @date 2025-01-14
*/
@RestController
@RequestMapping("/system/tasks")
public class TasksController extends BaseController
{
@Autowired
private ITasksService tasksService;
/**
* 查询任务用于存储所有的任务信息任务可由不同用户创建并管理列表
*/
// @PreAuthorize("@ss.hasPermi('system:tasks:list')")
// @GetMapping("/list")
// public TableDataInfo list(Tasks tasks)
// {
// startPage();
// List<Tasks> list = tasksService.(tasks);
// return getDataTable(list);
// }
//
// /**
// * 导出任务,用于存储所有的任务信息,任务可由不同用户创建并管理。列表
// */
// @PreAuthorize("@ss.hasPermi('system:tasks:export')")
// @Log(title = "任务,用于存储所有的任务信息,任务可由不同用户创建并管理。", businessType = BusinessType.EXPORT)
// @PostMapping("/export")
// public void export(HttpServletResponse response, Tasks tasks)
// {
// List<Tasks> list = tasksService.selectTasksList(tasks);
// ExcelUtil<Tasks> util = new ExcelUtil<Tasks>(Tasks.class);
// util.exportExcel(response, list, "任务,用于存储所有的任务信息,任务可由不同用户创建并管理。数据");
// }
//
// /**
// * 获取任务,用于存储所有的任务信息,任务可由不同用户创建并管理。详细信息
// */
// @PreAuthorize("@ss.hasPermi('system:tasks:query')")
// @GetMapping(value = "/{id}")
// public AjaxResult getInfo(@PathVariable("id") Long id)
// {
// return success(tasksService.selectTasksById(id));
// }
//
// /**
// * 新增任务,用于存储所有的任务信息,任务可由不同用户创建并管理。
// */
@PreAuthorize("@ss.hasPermi('system:tasks:add')")
@Log(title = "任务,用于存储所有的任务信息,任务可由不同用户创建并管理。", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@RequestBody TaskSaveVo taskSaveVo)
{
return toAjax(tasksService.insertTasks(taskSaveVo));
}
//
// /**
// * 修改任务,用于存储所有的任务信息,任务可由不同用户创建并管理。
// */
// @PreAuthorize("@ss.hasPermi('system:tasks:edit')")
// @Log(title = "任务,用于存储所有的任务信息,任务可由不同用户创建并管理。", businessType = BusinessType.UPDATE)
// @PutMapping
// public AjaxResult edit(@RequestBody Tasks tasks)
// {
// return toAjax(tasksService.updateTasks(tasks));
// }
//
// /**
// * 删除任务,用于存储所有的任务信息,任务可由不同用户创建并管理。
// */
// @PreAuthorize("@ss.hasPermi('system:tasks:remove')")
// @Log(title = "任务,用于存储所有的任务信息,任务可由不同用户创建并管理。", businessType = BusinessType.DELETE)
// @DeleteMapping("/{ids}")
// public AjaxResult remove(@PathVariable Long[] ids)
// {
// return toAjax(tasksService.deleteTasksByIds(ids));
// }
}

8
ruoyi-common/pom.xml

@ -128,6 +128,14 @@
<artifactId>mybatis-plus-boot-starter</artifactId> <artifactId>mybatis-plus-boot-starter</artifactId>
</dependency> </dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-validation</artifactId>
</dependency>
<dependency>
<groupId>org.quartz-scheduler</groupId>
<artifactId>quartz</artifactId>
</dependency>
</dependencies> </dependencies>
</project> </project>

19
ruoyi-common/src/main/java/com/ruoyi/common/config/WeChatConfig.java

@ -1,28 +1,15 @@
package com.ruoyi.common.config; package com.ruoyi.common.config;
import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties; import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
@Component @Component
@ConfigurationProperties(prefix = "wx") @ConfigurationProperties(prefix = "wx")
@Data
public class WeChatConfig { public class WeChatConfig {
private String appId; private String appId;
private String appSecret; private String appSecret;
private String callBackUrl;
public String getAppId() {
return appId;
}
public void setAppId(String appId) {
this.appId = appId;
}
public String getAppSecret() {
return appSecret;
}
public void setAppSecret(String appSecret) {
this.appSecret = appSecret;
}
} }

24
ruoyi-common/src/main/java/com/ruoyi/common/core/domain/TaskDTO.java

@ -0,0 +1,24 @@
package com.ruoyi.common.core.domain;
import lombok.Data;
import java.time.LocalDate;
import java.util.List;
@Data
public class TaskDTO {
//任务标题
private String title;
//任务类型
private Integer taskType;
//任务优先级
private String priority;
//任务状态
private String status;
//任务计划开始时间
private LocalDate startDate;
//任务计划结束时间
private LocalDate endDate;
//企业集合
private List<Long> enterprisesList;
}

41
ruoyi-common/src/main/java/com/ruoyi/common/utils/ScheduleUtils.java

@ -0,0 +1,41 @@
package com.ruoyi.common.utils;
import org.quartz.*;
import org.springframework.stereotype.Component;
/**
* 定时任务工具类支持创建和删除任务
*/
@Component
public class ScheduleUtils {
/**
* 创建定时任务
*
* @param scheduler Quartz调度器
* @param jobName 任务名称
* @param groupName 任务分组
* @param cronExpression Cron表达式
* @param jobDetail 任务详情
*/
public static void createJob(Scheduler scheduler, String jobName, String groupName, String cronExpression, JobDetail jobDetail) throws SchedulerException {
CronScheduleBuilder cronScheduleBuilder = CronScheduleBuilder.cronSchedule(cronExpression);
CronTrigger trigger = TriggerBuilder.newTrigger()
.withIdentity(jobName, groupName)
.withSchedule(cronScheduleBuilder)
.build();
scheduler.scheduleJob(jobDetail, trigger);
}
/**
* 删除定时任务
*
* @param scheduler Quartz调度器
* @param jobName 任务名称
* @param groupName 任务分组
*/
public static void deleteJob(Scheduler scheduler, String jobName, String groupName) throws SchedulerException {
JobKey jobKey = JobKey.jobKey(jobName, groupName);
scheduler.deleteJob(jobKey);
}
}

2
ruoyi-framework/src/main/java/com/ruoyi/framework/config/SecurityConfig.java

@ -111,7 +111,7 @@ public class SecurityConfig
.authorizeHttpRequests((requests) -> { .authorizeHttpRequests((requests) -> {
permitAllUrl.getUrls().forEach(url -> requests.antMatchers(url).permitAll()); permitAllUrl.getUrls().forEach(url -> requests.antMatchers(url).permitAll());
// 对于登录login 注册register 验证码captchaImage 允许匿名访问 // 对于登录login 注册register 验证码captchaImage 允许匿名访问
requests.antMatchers("/login", "/register","/app/login", "/captchaImage").permitAll() requests.antMatchers("/admin/login", "/register","/app/login", "/captchaImage").permitAll()
// 静态资源,可匿名访问 // 静态资源,可匿名访问
.antMatchers(HttpMethod.GET, "/", "/*.html", "/**/*.html", "/**/*.css", "/**/*.js", "/profile/**").permitAll() .antMatchers(HttpMethod.GET, "/", "/*.html", "/**/*.html", "/**/*.css", "/**/*.js", "/profile/**").permitAll()
.antMatchers("/swagger-ui.html", "/swagger-resources/**", "/webjars/**", "/*/api-docs", "/druid/**").permitAll() .antMatchers("/swagger-ui.html", "/swagger-resources/**", "/webjars/**", "/*/api-docs", "/druid/**").permitAll()

15
ruoyi-framework/src/main/java/com/ruoyi/framework/utils/WeChatUtils.java

@ -16,6 +16,7 @@ public class WeChatUtils {
private final RestTemplate restTemplate = new RestTemplate(); private final RestTemplate restTemplate = new RestTemplate();
//获取openid
public JSONObject getSession(String code) { public JSONObject getSession(String code) {
String appId = weChatConfig.getAppId(); String appId = weChatConfig.getAppId();
String appSecret = weChatConfig.getAppSecret(); String appSecret = weChatConfig.getAppSecret();
@ -61,5 +62,19 @@ public class WeChatUtils {
} }
} }
/**
* 构建微信扫码登录的二维码 URL
*/
public String getQRCodeUrl(String state) {
String appId = weChatConfig.getAppId();
String callBackUrl = weChatConfig.getCallBackUrl();
return String.format(
"https://open.weixin.qq.com/connect/qrconnect?appid=%s&redirect_uri=%s&response_type=code&scope=snsapi_login&state=%s",
appId, callBackUrl, state
);
}
//
} }

22
ruoyi-framework/src/main/java/com/ruoyi/framework/web/service/SysLoginService.java

@ -73,6 +73,9 @@ public class SysLoginService
@Autowired @Autowired
private ISysConfigService configService; private ISysConfigService configService;
// @Autowired
// private SysPermissionService permissionService;
@Autowired @Autowired
private SysUserMapper sysUserMapper; private SysUserMapper sysUserMapper;
@Autowired @Autowired
@ -231,23 +234,25 @@ public class SysLoginService
@Transactional @Transactional
public void register(RegisterVo registerVo) { public void register(RegisterVo registerVo) {
final Long userId = SecurityUtils.getUserId(); final Long userId = SecurityUtils.getUserId();
final SysUser sysUser = userService.selectUserById(userId); final SysUser sysUser = userService.selectUserById(userId);
if (sysUser == null) { if (sysUser == null) {
throw new ServiceException(); throw new ServiceException("用户不存在");
} }
// if (registerVo.getUserType() != null && "01".equals(registerVo.getUserType())) {
// }
BeanUtils.copyProperties(registerVo, sysUser);
// sysUserMapper.selectUserByWxOpenid() // sysUser.setStatus("1");
// BeanUtils.copyProperties(user, registerVo);
//
// sysUserMapper.updateUser(user);
final int res = sysUserMapper.updateUser(sysUser);
if (res < 0) {
throw new ServiceException("添加失败");
}
} }
public String weChatLogin(String code, String type) { public String weChatLogin(String code, String type) {
// Map<String, String> wxSession = this.getWxSession(code); Map<String, String> wxSession = this.getWxSession(code);
// if (type == null || "".equals(type)) { // if (type == null || "".equals(type)) {
// throw new ServiceException("缺少类型"); // throw new ServiceException("缺少类型");
@ -273,6 +278,7 @@ public class SysLoginService
// user.setPhonenumber(""); // user.setPhonenumber("");
// user.setSex(""); // user.setSex("");
user.setStatus("1"); // 默认停用状态 user.setStatus("1"); // 默认停用状态
user.setUserType("03"); //初始用户类型
// 保存用户信息 // 保存用户信息
int rows = sysUserMapper.insertUser(user); int rows = sysUserMapper.insertUser(user);
if (rows <= 0) { if (rows <= 0) {

2
ruoyi-generator/src/main/resources/vm/java/controller.java.vm

@ -26,7 +26,7 @@ import com.ruoyi.common.core.page.TableDataInfo;
/** /**
* ${functionName}Controller * ${functionName}Controller
* *
* @author ${author} * @author ${author}
* @date ${datetime} * @date ${datetime}
*/ */

124
ruoyi-generator/src/main/resources/vm/java/domain.java.vm

@ -9,11 +9,6 @@ import com.baomidou.mybatisplus.annotation.TableName;
import org.apache.commons.lang3.builder.ToStringBuilder; import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle; import org.apache.commons.lang3.builder.ToStringStyle;
import com.rchuing.sis.common.annotation.Excel; import com.rchuing.sis.common.annotation.Excel;
import java.io.Serializable;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
#if($table.crud || $table.sub) #if($table.crud || $table.sub)
import com.rchuing.sis.common.core.domain.BaseEntity; import com.rchuing.sis.common.core.domain.BaseEntity;
#elseif($table.tree) #elseif($table.tree)
@ -27,48 +22,91 @@ import com.fenghuang.common.core.domain.TreeEntity;
* @date ${datetime} * @date ${datetime}
*/ */
#if($table.crud || $table.sub) #if($table.crud || $table.sub)
#set($Entity="BaseEntity") #set($Entity="BaseEntity")
#elseif($table.tree) #elseif($table.tree)
#set($Entity="TreeEntity") #set($Entity="TreeEntity")
#end #end
@Data @TableName(resultMap = "${packageName}.mapper.${ClassName}Mapper.${ClassName}Result")
@Builder public class ${ClassName} extends ${Entity}
@AllArgsConstructor {
@NoArgsConstructor private static final long serialVersionUID = 1L;
@TableName("${tableName}")
public class ${ClassName} implements Serializable
{
private static final long serialVersionUID = 1L;
#foreach ($column in $columns) #foreach ($column in $columns)
#if(!$table.isSuperColumn($column.javaField)) #if(!$table.isSuperColumn($column.javaField))
/** $column.columnComment */ /** $column.columnComment */
#if($column.list) #if($column.list)
#set($parentheseIndex=$column.columnComment.indexOf("(")) #set($parentheseIndex=$column.columnComment.indexOf("("))
#if($parentheseIndex != -1) #if($parentheseIndex != -1)
#set($comment=$column.columnComment.substring(0, $parentheseIndex)) #set($comment=$column.columnComment.substring(0, $parentheseIndex))
#else #else
#set($comment=$column.columnComment) #set($comment=$column.columnComment)
#end #end
#if($parentheseIndex != -1) #if($parentheseIndex != -1)
@Excel(name = "${comment}", readConverterExp = "$column.readConverterExp()") @Excel(name = "${comment}", readConverterExp = "$column.readConverterExp()")
@TableField("`$column.columnName`") #elseif($column.javaType == 'Date')
#elseif($column.javaType == 'Date') @JsonFormat(pattern = "yyyy-MM-dd")
@JsonFormat(pattern = "yyyy-MM-dd") @Excel(name = "${comment}", width = 30, dateFormat = "yyyy-MM-dd")
@Excel(name = "${comment}", width = 30, dateFormat = "yyyy-MM-dd") #else
@TableField("`$column.columnName`") @Excel(name = "${comment}")
#else #end
@Excel(name = "${comment}") #end
@TableField("`$column.columnName`") #if($column.isPk == 1)
#end @TableId(value = "$column.columnName",type = IdType.AUTO)
#end #end
#if($column.isPk == 1) private $column.javaType $column.javaField;
@TableId(type = IdType.AUTO)
#end
private $column.javaType $column.javaField; #end
#end
#if($table.sub)
/** $table.subTable.functionName信息 */
private List<${subClassName}> ${subclassName}List;
#end #end
#end #foreach ($column in $columns)
#if(!$table.isSuperColumn($column.javaField))
#if($column.javaField.length() > 2 && $column.javaField.substring(1,2).matches("[A-Z]"))
#set($AttrName=$column.javaField)
#else
#set($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)})
#end
public void set${AttrName}($column.javaType $column.javaField)
{
this.$column.javaField = $column.javaField;
}
public $column.javaType get${AttrName}()
{
return $column.javaField;
}
#end
#end
#if($table.sub)
public List<${subClassName}> get${subClassName}List()
{
return ${subclassName}List;
}
public void set${subClassName}List(List<${subClassName}> ${subclassName}List)
{
this.${subclassName}List = ${subclassName}List;
}
#end
@Override
public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
#foreach ($column in $columns)
#if($column.javaField.length() > 2 && $column.javaField.substring(1,2).matches("[A-Z]"))
#set($AttrName=$column.javaField)
#else
#set($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)})
#end
.append("${column.javaField}", get${AttrName}())
#end
#if($table.sub)
.append("${subclassName}List", get${subClassName}List())
#end
.toString();
}
}

73
ruoyi-generator/src/main/resources/vm/java/mapper.java.vm

@ -14,5 +14,78 @@ import ${packageName}.domain.${subClassName};
* @date ${datetime} * @date ${datetime}
*/ */
public interface ${ClassName}Mapper extends BaseMapper<${ClassName}> { public interface ${ClassName}Mapper extends BaseMapper<${ClassName}> {
/**
* 查询${functionName}
*
* @param ${pkColumn.javaField} ${functionName}主键
* @return ${functionName}
*/
public ${ClassName} select${ClassName}By${pkColumn.capJavaField}(${pkColumn.javaType} ${pkColumn.javaField});
/**
* 查询${functionName}列表
*
* @param ${className} ${functionName}
* @return ${functionName}集合
*/
public List<${ClassName}> select${ClassName}List(${ClassName} ${className});
/**
* 新增${functionName}
*
* @param ${className} ${functionName}
* @return 结果
*/
public int insert${ClassName}(${ClassName} ${className});
/**
* 修改${functionName}
*
* @param ${className} ${functionName}
* @return 结果
*/
public int update${ClassName}(${ClassName} ${className});
/**
* 删除${functionName}
*
* @param ${pkColumn.javaField} ${functionName}主键
* @return 结果
*/
public int delete${ClassName}By${pkColumn.capJavaField}(${pkColumn.javaType} ${pkColumn.javaField});
/**
* 批量删除${functionName}
*
* @param ${pkColumn.javaField}s 需要删除的数据主键集合
* @return 结果
*/
public int delete${ClassName}By${pkColumn.capJavaField}s(${pkColumn.javaType}[] ${pkColumn.javaField}s);
#if($table.sub)
/**
* 批量删除${subTable.functionName}
*
* @param ${pkColumn.javaField}s 需要删除的数据主键集合
* @return 结果
*/
public int delete${subClassName}By${subTableFkClassName}s(${pkColumn.javaType}[] ${pkColumn.javaField}s);
/**
* 批量新增${subTable.functionName}
*
* @param ${subclassName}List ${subTable.functionName}列表
* @return 结果
*/
public int batch${subClassName}(List<${subClassName}> ${subclassName}List);
/**
* 通过${functionName}主键删除${subTable.functionName}信息
*
* @param ${pkColumn.javaField} ${functionName}ID
* @return 结果
*/
public int delete${subClassName}By${subTableFkClassName}(${pkColumn.javaType} ${pkColumn.javaField});
#end
} }

46
ruoyi-generator/src/main/resources/vm/java/service.java.vm

@ -11,5 +11,51 @@ import com.baomidou.mybatisplus.extension.service.IService;
* @date ${datetime} * @date ${datetime}
*/ */
public interface I${ClassName}Service extends IService<${ClassName}> { public interface I${ClassName}Service extends IService<${ClassName}> {
/**
* 查询${functionName}
*
* @param ${pkColumn.javaField} ${functionName}主键
* @return ${functionName}
*/
public ${ClassName} select${ClassName}By${pkColumn.capJavaField}(${pkColumn.javaType} ${pkColumn.javaField});
/**
* 查询${functionName}列表
*
* @param ${className} ${functionName}
* @return ${functionName}集合
*/
public List<${ClassName}> select${ClassName}List(${ClassName} ${className});
/**
* 新增${functionName}
*
* @param ${className} ${functionName}
* @return 结果
*/
public int insert${ClassName}(${ClassName} ${className});
/**
* 修改${functionName}
*
* @param ${className} ${functionName}
* @return 结果
*/
public int update${ClassName}(${ClassName} ${className});
/**
* 批量删除${functionName}
*
* @param ${pkColumn.javaField}s 需要删除的${functionName}主键集合
* @return 结果
*/
public int delete${ClassName}By${pkColumn.capJavaField}s(${pkColumn.javaType}[] ${pkColumn.javaField}s);
/**
* 删除${functionName}信息
*
* @param ${pkColumn.javaField} ${functionName}主键
* @return 结果
*/
public int delete${ClassName}By${pkColumn.capJavaField}(${pkColumn.javaType} ${pkColumn.javaField});
} }

130
ruoyi-generator/src/main/resources/vm/java/serviceImpl.java.vm

@ -28,5 +28,135 @@ import ${packageName}.service.I${ClassName}Service;
*/ */
@Service @Service
public class ${ClassName}ServiceImpl extends ServiceImpl<${ClassName}Mapper, ${ClassName}> implements I${ClassName}Service { public class ${ClassName}ServiceImpl extends ServiceImpl<${ClassName}Mapper, ${ClassName}> implements I${ClassName}Service {
@Autowired
private ${ClassName}Mapper ${className}Mapper;
/**
* 查询${functionName}
*
* @param ${pkColumn.javaField} ${functionName}主键
* @return ${functionName}
*/
@Override
public ${ClassName} select${ClassName}By${pkColumn.capJavaField}(${pkColumn.javaType} ${pkColumn.javaField}) {
return ${className}Mapper.select${ClassName}By${pkColumn.capJavaField}(${pkColumn.javaField});
}
/**
* 查询${functionName}列表
*
* @param ${className} ${functionName}
* @return ${functionName}
*/
@Override
public List<${ClassName}> select${ClassName}List(${ClassName} ${className}) {
return ${className}Mapper.select${ClassName}List(${className});
}
/**
* 新增${functionName}
*
* @param ${className} ${functionName}
* @return 结果
*/
#if($table.sub)
@Transactional
#end
@Override
public int insert${ClassName}(${ClassName} ${className}) {
#foreach ($column in $columns)
#if($column.javaField == 'createTime')
${className}.setCreateTime(DateUtils.getNowDate());
#end
#end
#if($table.sub)
int rows = ${className}Mapper.insert${ClassName}(${className});
insert${subClassName}(${className});
return rows;
#else
return ${className}Mapper.insert${ClassName}(${className});
#end
}
/**
* 修改${functionName}
*
* @param ${className} ${functionName}
* @return 结果
*/
#if($table.sub)
@Transactional
#end
@Override
public int update${ClassName}(${ClassName} ${className}) {
#foreach ($column in $columns)
#if($column.javaField == 'updateTime')
${className}.setUpdateTime(DateUtils.getNowDate());
#end
#end
#if($table.sub)
${className}Mapper.delete${subClassName}By${subTableFkClassName}(${className}.get${pkColumn.capJavaField}());
insert${subClassName}(${className});
#end
return ${className}Mapper.update${ClassName}(${className});
}
/**
* 批量删除${functionName}
*
* @param ${pkColumn.javaField}s 需要删除的${functionName}主键
* @return 结果
*/
#if($table.sub)
@Transactional
#end
@Override
public int delete${ClassName}By${pkColumn.capJavaField}s(${pkColumn.javaType}[] ${pkColumn.javaField}s) {
#if($table.sub)
${className}Mapper.delete${subClassName}By${subTableFkClassName}s(${pkColumn.javaField}s);
#end
return ${className}Mapper.delete${ClassName}By${pkColumn.capJavaField}s(${pkColumn.javaField}s);
}
/**
* 删除${functionName}信息
*
* @param ${pkColumn.javaField} ${functionName}主键
* @return 结果
*/
#if($table.sub)
@Transactional
#end
@Override
public int delete${ClassName}By${pkColumn.capJavaField}(${pkColumn.javaType} ${pkColumn.javaField}) {
#if($table.sub)
${className}Mapper.delete${subClassName}By${subTableFkClassName}(${pkColumn.javaField});
#end
return ${className}Mapper.delete${ClassName}By${pkColumn.capJavaField}(${pkColumn.javaField});
}
#if($table.sub)
/**
* 新增${subTable.functionName}信息
*
* @param ${className} ${functionName}对象
*/
public void insert${subClassName}(${ClassName} ${className}) {
List<${subClassName}> ${subclassName}List = ${className}.get${subClassName}List();
${pkColumn.javaType} ${pkColumn.javaField} = ${className}.get${pkColumn.capJavaField}();
if (StringUtils.isNotNull(${subclassName}List))
{
List<${subClassName}> list = new ArrayList<${subClassName}>();
for (${subClassName} ${subclassName} : ${subclassName}List)
{
${subclassName}.set${subTableFkClassName}(${pkColumn.javaField});
list.add(${subclassName});
}
if (list.size() > 0)
{
${className}Mapper.batch${subClassName}(list);
}
}
}
#end
} }

2
ruoyi-quartz/pom.xml

@ -37,4 +37,4 @@
</dependencies> </dependencies>
</project> </project>

22
ruoyi-quartz/src/main/java/com/ruoyi/quartz/config/AutowiringSpringBeanJobFactory.java

@ -0,0 +1,22 @@
package com.ruoyi.quartz.config;
import org.quartz.spi.TriggerFiredBundle;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Configurable;
import org.springframework.context.ApplicationContext;
import org.springframework.scheduling.quartz.SpringBeanJobFactory;
import org.springframework.stereotype.Component;
@Component
public class AutowiringSpringBeanJobFactory extends SpringBeanJobFactory {
@Autowired
private ApplicationContext applicationContext;
@Override
protected Object createJobInstance(TriggerFiredBundle bundle) throws Exception {
Object jobInstance = super.createJobInstance(bundle);
applicationContext.getAutowireCapableBeanFactory().autowireBean(jobInstance);
return jobInstance;
}
}

30
ruoyi-quartz/src/main/java/com/ruoyi/quartz/config/QuartzConfig.java

@ -0,0 +1,30 @@
package com.ruoyi.quartz.config;
import org.quartz.Scheduler;
import org.quartz.SchedulerException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.quartz.SchedulerFactoryBean;
@Configuration
public class QuartzConfig {
private final AutowiringSpringBeanJobFactory jobFactory;
public QuartzConfig(AutowiringSpringBeanJobFactory jobFactory) {
this.jobFactory = jobFactory;
}
@Bean
public SchedulerFactoryBean schedulerFactoryBean() {
SchedulerFactoryBean factory = new SchedulerFactoryBean();
factory.setJobFactory(jobFactory); // 设置自定义 Job 工厂
return factory;
}
@Bean
public Scheduler scheduler(SchedulerFactoryBean schedulerFactoryBean) throws SchedulerException {
return schedulerFactoryBean.getScheduler();
}
}

2
ruoyi-quartz/src/main/java/com/ruoyi/quartz/config/ScheduleConfig.java

@ -8,7 +8,7 @@
// //
///** ///**
// * 定时任务配置(单机部署建议删除此类和qrtz数据库表,默认走内存会最高效) // * 定时任务配置(单机部署建议删除此类和qrtz数据库表,默认走内存会最高效)
// * // *
// * @author ruoyi // * @author ruoyi
// */ // */
//@Configuration //@Configuration

25
ruoyi-quartz/src/main/java/com/ruoyi/quartz/task/AutoTaskJob.java

@ -0,0 +1,25 @@
package com.ruoyi.quartz.task;
import com.ruoyi.common.core.domain.TaskDTO;
import org.quartz.Job;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
@Component("autoTask")
public class AutoTaskJob implements Job {
@Override
public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
// 获取任务信息
TaskDTO task = (TaskDTO) jobExecutionContext.getJobDetail().getJobDataMap().get("task");
System.out.println("AutoTaskJob execute");
System.out.println("执行任务:" + task.getTitle());
jobExecutionContext.getJobDetail().getKey().getName();
}
//
}

32
ruoyi-system/src/main/java/com/ruoyi/system/domain/TaskEnterprises.java

@ -0,0 +1,32 @@
package com.ruoyi.system.domain;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.ruoyi.common.core.domain.BaseEntity;
import lombok.Data;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
/**
* 任务企业映射用于关联任务与企业的对应关系对象 task_enterprises
*
* @author ruoyi
* @date 2025-01-14
*/
@TableName("tasks_enterprises")
@Data
public class TaskEnterprises extends BaseEntity
{
private static final long serialVersionUID = 1L;
/** 映射记录ID,主键 */
@TableId(value = "id",type = IdType.AUTO)
private Long id;
/** 任务ID */
private Long taskId;
/** 企业ID */
private Long enterpriseId;
}

86
ruoyi-system/src/main/java/com/ruoyi/system/domain/Tasks.java

@ -0,0 +1,86 @@
package com.ruoyi.system.domain;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.Date;
import com.baomidou.mybatisplus.annotation.TableField;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.ruoyi.common.core.domain.BaseEntity;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import java.io.Serializable;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
* 任务用于存储所有的任务信息任务可由不同用户创建并管理对象 tasks
*
* @author ruoyi
* @date 2025-01-14
*/
@Data
@AllArgsConstructor
@NoArgsConstructor
@TableName("tasks")
public class Tasks extends BaseEntity implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 任务ID主键
*/
@TableId(type = IdType.AUTO)
private Long id;
/**
* 任务标题
*/
@TableField("`title`")
private String title;
/**
* 任务描述
*/
@TableField("`description`")
private String description;
/**
* 任务类型表示任务的类别例如1.发布任务2.自动任务等
*/
@TableField("`task_type`")
private Integer taskType;
/**
* 任务优先级
*/
@TableField("`priority`")
private String priority;
/**
* 任务状态
*/
@TableField("`status`")
private String status;
/**
* 任务计划开始时间
*/
@JsonFormat(pattern = "yyyy-MM-dd")
@TableField("`start_date`")
private LocalDate startDate;
/**
* 任务计划结束时间
*/
@JsonFormat(pattern = "yyyy-MM-dd")
@TableField("`end_date`")
private LocalDate endDate;
}

9
ruoyi-system/src/main/java/com/ruoyi/system/domain/vo/LabelValueVo.java

@ -0,0 +1,9 @@
package com.ruoyi.system.domain.vo;
import lombok.Data;
@Data
public class LabelValueVo {
private String label;
private Long value;
}

6
ruoyi-system/src/main/java/com/ruoyi/system/domain/vo/RegisterVo.java

@ -2,11 +2,13 @@ package com.ruoyi.system.domain.vo;
import lombok.Data; import lombok.Data;
import javax.validation.constraints.NotBlank;
@Data @Data
public class RegisterVo { public class RegisterVo {
private String nickName; private String nickName;
private String sex; private String sex;
private String phonenumber; private String phonenumber;
private String deptId; private Long deptId;
private String code; private String userType;
} }

25
ruoyi-system/src/main/java/com/ruoyi/system/domain/vo/TaskSaveVo.java

@ -0,0 +1,25 @@
package com.ruoyi.system.domain.vo;
import lombok.Data;
import java.time.LocalDate;
import java.util.List;
@Data
public class TaskSaveVo {
//任务标题
private String title;
//任务类型
private Integer taskType;
//任务优先级
private String priority;
//任务状态
private String status;
//任务计划开始时间
private LocalDate startDate;
//任务计划结束时间
private LocalDate endDate;
//企业集合
private List<Long> enterprisesList;
}

16
ruoyi-system/src/main/java/com/ruoyi/system/mapper/TaskEnterprisesMapper.java

@ -0,0 +1,16 @@
package com.ruoyi.system.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.ruoyi.system.domain.TaskEnterprises;
import com.ruoyi.system.domain.TaskEnterprises;
import org.apache.ibatis.annotations.Mapper;
/**
* ${comments} Mapper 接口
*
* @author ruoyi
* @date ${date}
*/
@Mapper
public interface TaskEnterprisesMapper extends BaseMapper<TaskEnterprises> {
}

17
ruoyi-system/src/main/java/com/ruoyi/system/mapper/TasksMapper.java

@ -0,0 +1,17 @@
package com.ruoyi.system.mapper;
import java.util.List;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.ruoyi.system.domain.Tasks;
import org.apache.ibatis.annotations.Mapper;
/**
* 任务用于存储所有的任务信息任务可由不同用户创建并管理Mapper接口
*
* @author ruoyi
* @date 2025-01-14
*/
@Mapper
public interface TasksMapper extends BaseMapper<Tasks> {
}

3
ruoyi-system/src/main/java/com/ruoyi/system/service/IEnterprisesService.java

@ -3,6 +3,7 @@ package com.ruoyi.system.service;
import java.util.List; import java.util.List;
import com.ruoyi.system.domain.Enterprises; import com.ruoyi.system.domain.Enterprises;
import com.ruoyi.system.domain.vo.EnterpriseUserInsertVo; import com.ruoyi.system.domain.vo.EnterpriseUserInsertVo;
import com.ruoyi.system.domain.vo.LabelValueVo;
/** /**
* 企业Service接口 * 企业Service接口
@ -61,4 +62,6 @@ public interface IEnterprisesService
public int deleteEnterprisesById(Long id); public int deleteEnterprisesById(Long id);
public void addEnterpriseUsers(EnterpriseUserInsertVo enterpriseUserInsertVo); public void addEnterpriseUsers(EnterpriseUserInsertVo enterpriseUserInsertVo);
public List<LabelValueVo> simpleList(Enterprises enterprises);
} }

15
ruoyi-system/src/main/java/com/ruoyi/system/service/ITaskEnterprisesService.java

@ -0,0 +1,15 @@
package com.ruoyi.system.service;
import java.util.List;
import com.ruoyi.system.domain.TaskEnterprises;
import com.baomidou.mybatisplus.extension.service.IService;
/**
* 任务企业映射用于关联任务与企业的对应关系Service接口
*
* @author ruoyi
* @date 2025-01-14
*/
public interface ITaskEnterprisesService extends IService<TaskEnterprises> {
}

19
ruoyi-system/src/main/java/com/ruoyi/system/service/ITasksService.java

@ -0,0 +1,19 @@
package com.ruoyi.system.service;
import java.util.List;
import com.ruoyi.system.domain.Tasks;
import com.baomidou.mybatisplus.extension.service.IService;
import com.ruoyi.system.domain.vo.TaskSaveVo;
/**
* 任务用于存储所有的任务信息任务可由不同用户创建并管理Service接口
*
* @author ruoyi
* @date 2025-01-14
*/
public interface ITasksService extends IService<Tasks> {
int insertTasks(TaskSaveVo taskSaveVo);
List<Tasks> getAppTaskList();
}

23
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/EnterprisesServiceImpl.java

@ -1,5 +1,6 @@
package com.ruoyi.system.service.impl; package com.ruoyi.system.service.impl;
import java.util.ArrayList;
import java.util.List; import java.util.List;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
@ -7,7 +8,9 @@ import com.ruoyi.common.exception.ServiceException;
import com.ruoyi.common.utils.DateUtils; import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.system.domain.EnterpriseUsers; import com.ruoyi.system.domain.EnterpriseUsers;
import com.ruoyi.system.domain.vo.EnterpriseUserInsertVo; import com.ruoyi.system.domain.vo.EnterpriseUserInsertVo;
import com.ruoyi.system.domain.vo.LabelValueVo;
import com.ruoyi.system.mapper.EnterpriseUsersMapper; import com.ruoyi.system.mapper.EnterpriseUsersMapper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import com.ruoyi.system.mapper.EnterprisesMapper; import com.ruoyi.system.mapper.EnterprisesMapper;
@ -22,6 +25,8 @@ import org.springframework.transaction.annotation.Transactional;
* @date 2025-01-08 * @date 2025-01-08
*/ */
@Service @Service
@Slf4j
public class EnterprisesServiceImpl implements IEnterprisesService public class EnterprisesServiceImpl implements IEnterprisesService
{ {
@Autowired @Autowired
@ -123,4 +128,22 @@ public class EnterprisesServiceImpl implements IEnterprisesService
enterpriseUsersMapper.insert(enterpriseUsers); enterpriseUsersMapper.insert(enterpriseUsers);
}); });
} }
@Override
public List<LabelValueVo> simpleList(Enterprises enterprises) {
LambdaQueryWrapper<Enterprises> wrapper = new LambdaQueryWrapper<>();
wrapper.select(Enterprises::getId, Enterprises::getEnterprisesName);
final List<Enterprises> enterprisesList = enterprisesMapper.selectList(wrapper);
List<LabelValueVo> labelValueVo = new ArrayList<>();
enterprisesList.forEach(item->{
LabelValueVo res = new LabelValueVo();
res.setLabel(item.getEnterprisesName());
res.setValue(item.getId());
labelValueVo.add(res);
});
return labelValueVo;
}
} }

19
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TaskEnterprisesServiceImpl.java

@ -0,0 +1,19 @@
package com.ruoyi.system.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.system.mapper.TaskEnterprisesMapper;
import com.ruoyi.system.domain.TaskEnterprises;
import com.ruoyi.system.service.ITaskEnterprisesService;
/**
* 任务企业映射用于关联任务与企业的对应关系Service业务层处理
*
* @author ruoyi
* @date 2025-01-14
*/
@Service
public class TaskEnterprisesServiceImpl extends ServiceImpl<TaskEnterprisesMapper, TaskEnterprises> implements ITaskEnterprisesService {
}

74
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TasksServiceImpl.java

@ -0,0 +1,74 @@
package com.ruoyi.system.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.common.exception.ServiceException;
import com.ruoyi.system.domain.TaskEnterprises;
import com.ruoyi.system.domain.vo.TaskSaveVo;
import com.ruoyi.system.mapper.TaskEnterprisesMapper;
import com.ruoyi.system.service.ITaskEnterprisesService;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.system.mapper.TasksMapper;
import com.ruoyi.system.domain.Tasks;
import com.ruoyi.system.service.ITasksService;
import com.ruoyi.system.mapper.TasksMapper;
import reactor.core.scheduler.Scheduler;
import java.util.List;
//import org.quartz.Scheduler;
/**
* 任务用于存储所有的任务信息任务可由不同用户创建并管理Service业务层处理
*
* @author ruoyi
* @date 2025-01-14
*/
@Service
public class TasksServiceImpl extends ServiceImpl<TasksMapper, Tasks> implements ITasksService {
@Autowired
private TaskEnterprisesMapper taskEnterprisesMapper;
@Autowired
private TasksMapper tasksMapper;
@Override
public int insertTasks(TaskSaveVo taskSaveVo) {
//任务类型
Tasks tasks = new Tasks();
BeanUtils.copyProperties(taskSaveVo, tasks);
final int insert = tasksMapper.insert(tasks);
if (insert < 1) {
throw new ServiceException("插入失败");
}
if (taskSaveVo.getTaskType() == 2) {
//自动执行
} else {
}
final List<Long> enterprisesList = taskSaveVo.getEnterprisesList();
for (Long id : enterprisesList) {
TaskEnterprises enterprises = new TaskEnterprises();
enterprises.setTaskId(tasks.getId());
enterprises.setEnterpriseId(id);
taskEnterprisesMapper.insert(enterprises);
}
return 0;
}
@Override
public List<Tasks> getAppTaskList() {
LambdaQueryWrapper<Tasks> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(Tasks::getTaskType, 1);
return tasksMapper.selectList(wrapper);
}
}

106
ruoyi-system/src/main/resources/mapper/system/TasksMapper.xml

@ -0,0 +1,106 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.ruoyi.system.mapper.TasksMapper">
<resultMap type="Tasks" id="TasksResult">
<result property="id" column="id" />
<result property="title" column="title" />
<result property="description" column="description" />
<result property="taskType" column="task_type" />
<result property="priority" column="priority" />
<result property="status" column="status" />
<result property="startDate" column="start_date" />
<result property="endDate" column="end_date" />
<result property="createTime" column="create_time" />
<result property="updateTime" column="update_time" />
</resultMap>
<sql id="selectTasksVo">
select id, creator, title, description, task_type, priority, status, start_date, end_date, create_time, update_time, updater, deleted from tasks
</sql>
<select id="selectTasksList" parameterType="Tasks" resultMap="TasksResult">
<include refid="selectTasksVo"/>
<where>
<if test="creator != null "> and creator = #{creator}</if>
<if test="title != null and title != ''"> and title = #{title}</if>
<if test="description != null and description != ''"> and description = #{description}</if>
<if test="taskType != null "> and task_type = #{taskType}</if>
<if test="priority != null and priority != ''"> and priority = #{priority}</if>
<if test="status != null and status != ''"> and status = #{status}</if>
<if test="startDate != null "> and start_date = #{startDate}</if>
<if test="endDate != null "> and end_date = #{endDate}</if>
<if test="updater != null "> and updater = #{updater}</if>
<if test="deleted != null "> and deleted = #{deleted}</if>
</where>
</select>
<select id="selectTasksById" parameterType="Long" resultMap="TasksResult">
<include refid="selectTasksVo"/>
where id = #{id}
</select>
<insert id="insertTasks" parameterType="Tasks" useGeneratedKeys="true" keyProperty="id">
insert into tasks
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="creator != null">creator,</if>
<if test="title != null and title != ''">title,</if>
<if test="description != null">description,</if>
<if test="taskType != null">task_type,</if>
<if test="priority != null and priority != ''">priority,</if>
<if test="status != null and status != ''">status,</if>
<if test="startDate != null">start_date,</if>
<if test="endDate != null">end_date,</if>
<if test="createTime != null">create_time,</if>
<if test="updateTime != null">update_time,</if>
<if test="updater != null">updater,</if>
<if test="deleted != null">deleted,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="creator != null">#{creator},</if>
<if test="title != null and title != ''">#{title},</if>
<if test="description != null">#{description},</if>
<if test="taskType != null">#{taskType},</if>
<if test="priority != null and priority != ''">#{priority},</if>
<if test="status != null and status != ''">#{status},</if>
<if test="startDate != null">#{startDate},</if>
<if test="endDate != null">#{endDate},</if>
<if test="createTime != null">#{createTime},</if>
<if test="updateTime != null">#{updateTime},</if>
<if test="updater != null">#{updater},</if>
<if test="deleted != null">#{deleted},</if>
</trim>
</insert>
<update id="updateTasks" parameterType="Tasks">
update tasks
<trim prefix="SET" suffixOverrides=",">
<if test="creator != null">creator = #{creator},</if>
<if test="title != null and title != ''">title = #{title},</if>
<if test="description != null">description = #{description},</if>
<if test="taskType != null">task_type = #{taskType},</if>
<if test="priority != null and priority != ''">priority = #{priority},</if>
<if test="status != null and status != ''">status = #{status},</if>
<if test="startDate != null">start_date = #{startDate},</if>
<if test="endDate != null">end_date = #{endDate},</if>
<if test="createTime != null">create_time = #{createTime},</if>
<if test="updateTime != null">update_time = #{updateTime},</if>
<if test="updater != null">updater = #{updater},</if>
<if test="deleted != null">deleted = #{deleted},</if>
</trim>
where id = #{id}
</update>
<delete id="deleteTasksById" parameterType="Long">
delete from tasks where id = #{id}
</delete>
<delete id="deleteTasksByIds" parameterType="String">
delete from tasks where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
</mapper>
Loading…
Cancel
Save