新增习讲话树形表单,新增对发起流程中间表的写接口,待测试
This commit is contained in:
+42
@@ -0,0 +1,42 @@
|
||||
package org.jeecg.modules.tasktask.constant;
|
||||
|
||||
public final class FlowConstants {
|
||||
private FlowConstants() {
|
||||
}
|
||||
public static final class Strategy {
|
||||
/** 立即发起 */
|
||||
public static final Integer IMMEDIATE_ONLY = 1;
|
||||
|
||||
/** 周期发起 */
|
||||
public static final Integer RECURRING_ONLY = 2;
|
||||
|
||||
/** 延迟发起 */
|
||||
public static final Integer IMMEDIATE_AND_RECURRING = 3;
|
||||
}
|
||||
public static final class IntervalType {
|
||||
/**
|
||||
* 每天
|
||||
*/
|
||||
public static final Integer EVERY_DAY = 1;
|
||||
/**
|
||||
* 每周
|
||||
*/
|
||||
public static final Integer EVERY_WEEK = 2;
|
||||
/**
|
||||
* 每两周
|
||||
*/
|
||||
public static final Integer EVERY_TWO_WEEKS = 3;
|
||||
/**
|
||||
* 每月
|
||||
*/
|
||||
public static final Integer EVERY_MONTH = 4;
|
||||
/**
|
||||
* 每季
|
||||
*/
|
||||
public static final Integer EVERY_QUARTER = 5;
|
||||
}
|
||||
public static final class taskCount{
|
||||
public static final Integer MAX = 24;
|
||||
public static final Integer MIN = 0;
|
||||
}
|
||||
}
|
||||
+199
-121
@@ -1,20 +1,25 @@
|
||||
package org.jeecg.modules.tasktask.controller;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.ZoneId;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
import java.io.IOException;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.net.URLDecoder;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.apache.shiro.SecurityUtils;
|
||||
import org.jeecg.common.api.vo.Result;
|
||||
import org.jeecg.common.system.query.QueryGenerator;
|
||||
import org.jeecg.common.system.query.QueryRuleEnum;
|
||||
import org.jeecg.common.system.vo.LoginUser;
|
||||
import org.jeecg.common.util.oConvertUtils;
|
||||
import org.jeecg.modules.extbpm.process.service.impl.BpmBaseExtApiImpl;
|
||||
import org.jeecg.modules.tasktask.constant.FlowConstants;
|
||||
import org.jeecg.modules.tasktask.entity.TaskTask;
|
||||
import org.jeecg.modules.tasktask.mapper.TaskTaskMapper;
|
||||
import org.jeecg.modules.tasktask.service.ITaskTaskService;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
@@ -28,6 +33,7 @@ import org.jeecgframework.poi.excel.entity.ExportParams;
|
||||
import org.jeecgframework.poi.excel.entity.ImportParams;
|
||||
import org.jeecgframework.poi.excel.view.JeecgEntityExcelView;
|
||||
import org.jeecg.common.system.base.controller.JeecgController;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
@@ -38,133 +44,205 @@ import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import org.jeecg.common.aspect.annotation.AutoLog;
|
||||
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||||
/**
|
||||
|
||||
/**
|
||||
* @Description: 事项任务计划表(发起流程)
|
||||
* @Author: jeecg-boot
|
||||
* @Date: 2026-04-17
|
||||
* @Date: 2026-04-17
|
||||
* @Version: V1.0
|
||||
*/
|
||||
@Tag(name="事项任务计划表(发起流程)")
|
||||
@Tag(name = "事项任务计划表(发起流程)")
|
||||
@RestController
|
||||
@RequestMapping("/tasktask/taskTask")
|
||||
@Slf4j
|
||||
public class TaskTaskController extends JeecgController<TaskTask, ITaskTaskService> {
|
||||
@Autowired
|
||||
private ITaskTaskService taskTaskService;
|
||||
|
||||
/**
|
||||
* 分页列表查询
|
||||
*
|
||||
* @param taskTask
|
||||
* @param pageNo
|
||||
* @param pageSize
|
||||
* @param req
|
||||
* @return
|
||||
*/
|
||||
//@AutoLog(value = "事项任务计划表(发起流程)-分页列表查询")
|
||||
@Operation(summary="事项任务计划表(发起流程)-分页列表查询")
|
||||
@GetMapping(value = "/list")
|
||||
public Result<IPage<TaskTask>> queryPageList(TaskTask taskTask,
|
||||
@RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
|
||||
@RequestParam(name="pageSize", defaultValue="10") Integer pageSize,
|
||||
HttpServletRequest req) {
|
||||
@Autowired
|
||||
private ITaskTaskService taskTaskService;
|
||||
|
||||
/**
|
||||
* 分页列表查询
|
||||
*
|
||||
* @param taskTask
|
||||
* @param pageNo
|
||||
* @param pageSize
|
||||
* @param req
|
||||
* @return
|
||||
*/
|
||||
//@AutoLog(value = "事项任务计划表(发起流程)-分页列表查询")
|
||||
@Operation(summary = "事项任务计划表(发起流程)-分页列表查询")
|
||||
@GetMapping(value = "/list")
|
||||
public Result<IPage<TaskTask>> queryPageList(TaskTask taskTask,
|
||||
@RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
|
||||
@RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
|
||||
HttpServletRequest req) {
|
||||
|
||||
|
||||
// 自定义查询规则
|
||||
Map<String, QueryRuleEnum> customeRuleMap = new HashMap<>();
|
||||
// 自定义多选的查询规则为:LIKE_WITH_OR
|
||||
customeRuleMap.put("urgencyLevel", QueryRuleEnum.LIKE_WITH_OR);
|
||||
QueryWrapper<TaskTask> queryWrapper = QueryGenerator.initQueryWrapper(taskTask, req.getParameterMap(),customeRuleMap);
|
||||
Page<TaskTask> page = new Page<TaskTask>(pageNo, pageSize);
|
||||
IPage<TaskTask> pageList = taskTaskService.page(page, queryWrapper);
|
||||
return Result.OK(pageList);
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加
|
||||
*
|
||||
* @param taskTask
|
||||
* @return
|
||||
*/
|
||||
@AutoLog(value = "事项任务计划表(发起流程)-添加")
|
||||
@Operation(summary="事项任务计划表(发起流程)-添加")
|
||||
@RequiresPermissions("tasktask:task_task:add")
|
||||
@PostMapping(value = "/add")
|
||||
public Result<String> add(@RequestBody TaskTask taskTask) {
|
||||
taskTask.setBpmStatus("1");
|
||||
taskTaskService.save(taskTask);
|
||||
|
||||
return Result.OK("添加成功!");
|
||||
}
|
||||
|
||||
/**
|
||||
* 编辑
|
||||
*
|
||||
* @param taskTask
|
||||
* @return
|
||||
*/
|
||||
@AutoLog(value = "事项任务计划表(发起流程)-编辑")
|
||||
@Operation(summary="事项任务计划表(发起流程)-编辑")
|
||||
@RequiresPermissions("tasktask:task_task:edit")
|
||||
@RequestMapping(value = "/edit", method = {RequestMethod.PUT,RequestMethod.POST})
|
||||
public Result<String> edit(@RequestBody TaskTask taskTask) {
|
||||
taskTaskService.updateById(taskTask);
|
||||
return Result.OK("编辑成功!");
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过id删除
|
||||
*
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
@AutoLog(value = "事项任务计划表(发起流程)-通过id删除")
|
||||
@Operation(summary="事项任务计划表(发起流程)-通过id删除")
|
||||
@RequiresPermissions("tasktask:task_task:delete")
|
||||
@DeleteMapping(value = "/delete")
|
||||
public Result<String> delete(@RequestParam(name="id",required=true) String id) {
|
||||
taskTaskService.removeById(id);
|
||||
return Result.OK("删除成功!");
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量删除
|
||||
*
|
||||
* @param ids
|
||||
* @return
|
||||
*/
|
||||
@AutoLog(value = "事项任务计划表(发起流程)-批量删除")
|
||||
@Operation(summary="事项任务计划表(发起流程)-批量删除")
|
||||
@RequiresPermissions("tasktask:task_task:deleteBatch")
|
||||
@DeleteMapping(value = "/deleteBatch")
|
||||
public Result<String> deleteBatch(@RequestParam(name="ids",required=true) String ids) {
|
||||
this.taskTaskService.removeByIds(Arrays.asList(ids.split(",")));
|
||||
return Result.OK("批量删除成功!");
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过id查询
|
||||
*
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
//@AutoLog(value = "事项任务计划表(发起流程)-通过id查询")
|
||||
@Operation(summary="事项任务计划表(发起流程)-通过id查询")
|
||||
@GetMapping(value = "/queryById")
|
||||
public Result<TaskTask> queryById(@RequestParam(name="id",required=true) String id) {
|
||||
TaskTask taskTask = taskTaskService.getById(id);
|
||||
if(taskTask==null) {
|
||||
return Result.error("未找到对应数据");
|
||||
}
|
||||
return Result.OK(taskTask);
|
||||
}
|
||||
QueryWrapper<TaskTask> queryWrapper = QueryGenerator.initQueryWrapper(taskTask, req.getParameterMap(), customeRuleMap);
|
||||
Page<TaskTask> page = new Page<TaskTask>(pageNo, pageSize);
|
||||
IPage<TaskTask> pageList = taskTaskService.page(page, queryWrapper);
|
||||
return Result.OK(pageList);
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出excel
|
||||
*
|
||||
* @param request
|
||||
* @param taskTask
|
||||
*/
|
||||
* 添加
|
||||
*
|
||||
* @param taskTask
|
||||
* @return
|
||||
*/
|
||||
@AutoLog(value = "事项任务计划表(发起流程)-添加")
|
||||
@Operation(summary = "事项任务计划表(发起流程)-添加")
|
||||
@RequiresPermissions("tasktask:task_task:add")
|
||||
@PostMapping(value = "/add")
|
||||
public Result<String> add(@RequestBody TaskTask taskTask) {
|
||||
taskTask.setBpmStatus("1");
|
||||
taskTaskService.save(taskTask);
|
||||
|
||||
return Result.OK("添加成功!");
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加
|
||||
*
|
||||
* @param taskTask
|
||||
* @return
|
||||
*/
|
||||
@AutoLog(value = "事项任务计划表(发起周期性流程)-添加")
|
||||
@Operation(summary = "事项任务计划表(发起周期性流程)-添加")
|
||||
@RequiresPermissions("tasktask:task_task:add")
|
||||
@PostMapping(value = "/flow-schedules")
|
||||
public Result<String> addRecurringTask(@RequestBody TaskTask taskTask,
|
||||
@RequestParam(name = "intervalType", required = false) Integer intervalType,
|
||||
@RequestParam(name = "startCount", required = false) Integer startCount) throws Exception {
|
||||
if (taskTask.getTriggerType() == null) {
|
||||
return Result.error("触发类型不能为空");
|
||||
}
|
||||
Integer triggerType = taskTask.getTriggerType();
|
||||
LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
|
||||
if (sysUser.getUsername() == null || sysUser.getUsername().isEmpty()) {
|
||||
return Result.error("无法获取当前流程发起人信息");
|
||||
}
|
||||
if (startCount > FlowConstants.taskCount.MAX) return Result.error("单词生成周期任务不能超过100个");
|
||||
|
||||
if (FlowConstants.Strategy.IMMEDIATE_ONLY.equals(triggerType)) {
|
||||
if (taskTaskService.singleFlowStart(taskTask, sysUser.getUsername())) {
|
||||
return Result.ok("单次流程发起成功");
|
||||
}
|
||||
return Result.error("立即发起流程失败");
|
||||
} else if (FlowConstants.Strategy.RECURRING_ONLY.equals(triggerType)) {
|
||||
//向中间表写入n个待发起流程,由定时器扫描发起
|
||||
List<TaskTask> temTaskList = new ArrayList<>();
|
||||
Date baseDate = Optional.ofNullable(taskTask.getStartTime())
|
||||
.orElseThrow(() -> new IllegalArgumentException("周期性流程开始时间不能为空!"));
|
||||
|
||||
LocalDateTime currentLdt = baseDate.toInstant().atZone(ZoneId.systemDefault()).toLocalDateTime();
|
||||
|
||||
for (int i = 0; i < startCount; i++) {
|
||||
// 计算下一次执行时间
|
||||
if (FlowConstants.IntervalType.EVERY_DAY.equals(intervalType)) {
|
||||
currentLdt = currentLdt.plusDays(1);
|
||||
} else if (FlowConstants.IntervalType.EVERY_WEEK.equals(intervalType)) {
|
||||
currentLdt = currentLdt.plusWeeks(1);
|
||||
} else if (FlowConstants.IntervalType.EVERY_TWO_WEEKS.equals(intervalType)) {
|
||||
currentLdt = currentLdt.plusWeeks(2);
|
||||
} else if (FlowConstants.IntervalType.EVERY_MONTH.equals(intervalType)) {
|
||||
currentLdt = currentLdt.plusMonths(1);
|
||||
} else if (FlowConstants.IntervalType.EVERY_QUARTER.equals(intervalType)) {
|
||||
currentLdt = currentLdt.plusMonths(3);
|
||||
} else {
|
||||
throw new IllegalArgumentException("未知的周期类型: " + intervalType);
|
||||
}
|
||||
|
||||
// 2. 创建新的任务对象并添加到列表
|
||||
TaskTask newTask = new TaskTask();
|
||||
// 复制基础属性 (建议使用 BeanUtils.copyProperties)
|
||||
BeanUtils.copyProperties(taskTask, newTask);
|
||||
|
||||
// 设置计算后的触发时间
|
||||
Date nextExecutionDate = Date.from(currentLdt.atZone(ZoneId.systemDefault()).toInstant());
|
||||
newTask.setStartTime(nextExecutionDate);
|
||||
|
||||
temTaskList.add(newTask);
|
||||
}
|
||||
taskTaskService.saveBatch(temTaskList);
|
||||
} else {
|
||||
// 这个 else 很重要,处理那些“意料之外”的数值
|
||||
return Result.error("非法的触发类型数值: " + triggerType);
|
||||
}
|
||||
return Result.OK("添加成功!");
|
||||
}
|
||||
|
||||
/**
|
||||
* 编辑
|
||||
*
|
||||
* @param taskTask
|
||||
* @return
|
||||
*/
|
||||
@AutoLog(value = "事项任务计划表(发起流程)-编辑")
|
||||
@Operation(summary = "事项任务计划表(发起流程)-编辑")
|
||||
@RequiresPermissions("tasktask:task_task:edit")
|
||||
@RequestMapping(value = "/edit", method = {RequestMethod.PUT, RequestMethod.POST})
|
||||
public Result<String> edit(@RequestBody TaskTask taskTask) {
|
||||
taskTaskService.updateById(taskTask);
|
||||
return Result.OK("编辑成功!");
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过id删除
|
||||
*
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
@AutoLog(value = "事项任务计划表(发起流程)-通过id删除")
|
||||
@Operation(summary = "事项任务计划表(发起流程)-通过id删除")
|
||||
@RequiresPermissions("tasktask:task_task:delete")
|
||||
@DeleteMapping(value = "/delete")
|
||||
public Result<String> delete(@RequestParam(name = "id", required = true) String id) {
|
||||
taskTaskService.removeById(id);
|
||||
return Result.OK("删除成功!");
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量删除
|
||||
*
|
||||
* @param ids
|
||||
* @return
|
||||
*/
|
||||
@AutoLog(value = "事项任务计划表(发起流程)-批量删除")
|
||||
@Operation(summary = "事项任务计划表(发起流程)-批量删除")
|
||||
@RequiresPermissions("tasktask:task_task:deleteBatch")
|
||||
@DeleteMapping(value = "/deleteBatch")
|
||||
public Result<String> deleteBatch(@RequestParam(name = "ids", required = true) String ids) {
|
||||
this.taskTaskService.removeByIds(Arrays.asList(ids.split(",")));
|
||||
return Result.OK("批量删除成功!");
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过id查询
|
||||
*
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
//@AutoLog(value = "事项任务计划表(发起流程)-通过id查询")
|
||||
@Operation(summary = "事项任务计划表(发起流程)-通过id查询")
|
||||
@GetMapping(value = "/queryById")
|
||||
public Result<TaskTask> queryById(@RequestParam(name = "id", required = true) String id) {
|
||||
TaskTask taskTask = taskTaskService.getById(id);
|
||||
if (taskTask == null) {
|
||||
return Result.error("未找到对应数据");
|
||||
}
|
||||
return Result.OK(taskTask);
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出excel
|
||||
*
|
||||
* @param request
|
||||
* @param taskTask
|
||||
*/
|
||||
@RequiresPermissions("tasktask:task_task:exportXls")
|
||||
@RequestMapping(value = "/exportXls")
|
||||
public ModelAndView exportXls(HttpServletRequest request, TaskTask taskTask) {
|
||||
@@ -172,12 +250,12 @@ public class TaskTaskController extends JeecgController<TaskTask, ITaskTaskServi
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过excel导入数据
|
||||
*
|
||||
* @param request
|
||||
* @param response
|
||||
* @return
|
||||
*/
|
||||
* 通过excel导入数据
|
||||
*
|
||||
* @param request
|
||||
* @param response
|
||||
* @return
|
||||
*/
|
||||
@RequiresPermissions("tasktask:task_task:importExcel")
|
||||
@RequestMapping(value = "/importExcel", method = RequestMethod.POST)
|
||||
public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response) {
|
||||
|
||||
+3
@@ -231,6 +231,9 @@ public class TaskTask implements Serializable {
|
||||
/**流程变量*/
|
||||
@Excel(name = "流程变量", width = 15)
|
||||
private transient java.lang.String jsonDataString;
|
||||
@Excel(name = "是否立即发起流程", width = 15)
|
||||
@Schema(description = "1立即发起且非周期性发起,2不立即发起但周期性发起,3立即发起且周期性发起")
|
||||
private java.lang.Integer triggerType;
|
||||
|
||||
private byte[] jsonData;
|
||||
|
||||
|
||||
+1
-1
@@ -10,5 +10,5 @@ import com.baomidou.mybatisplus.extension.service.IService;
|
||||
* @Version: V1.0
|
||||
*/
|
||||
public interface ITaskTaskService extends IService<TaskTask> {
|
||||
|
||||
boolean singleFlowStart(TaskTask taskTask,String userName) throws Exception;
|
||||
}
|
||||
|
||||
+31
-1
@@ -1,19 +1,49 @@
|
||||
package org.jeecg.modules.tasktask.service.impl;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.apache.shiro.util.Assert;
|
||||
import org.jeecg.common.api.vo.Result;
|
||||
import org.jeecg.modules.extbpm.process.exception.BpmException;
|
||||
import org.jeecg.modules.extbpm.process.service.impl.BpmBaseExtApiImpl;
|
||||
import org.jeecg.modules.tasktask.entity.TaskTask;
|
||||
import org.jeecg.modules.tasktask.mapper.TaskTaskMapper;
|
||||
import org.jeecg.modules.tasktask.service.ITaskTaskService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Optional;
|
||||
|
||||
/**
|
||||
* @Description: 事项任务计划表(发起流程)
|
||||
* @Author: jeecg-boot
|
||||
* @Date: 2026-04-17
|
||||
* @Date: 2026-04-17
|
||||
* @Version: V1.0
|
||||
*/
|
||||
@Service
|
||||
public class TaskTaskServiceImpl extends ServiceImpl<TaskTaskMapper, TaskTask> implements ITaskTaskService {
|
||||
@Autowired
|
||||
private BpmBaseExtApiImpl bpmBaseExtApiImpl;
|
||||
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public boolean singleFlowStart(TaskTask taskTask, String userName) throws Exception {
|
||||
if (StringUtils.isBlank(taskTask.getFlowCode())) {
|
||||
throw new IllegalArgumentException("flowCode不能为空");
|
||||
}
|
||||
if (StringUtils.isBlank(taskTask.getBusinessId())) {
|
||||
throw new IllegalArgumentException("businessId不能为空");
|
||||
}
|
||||
if (StringUtils.isBlank(taskTask.getFormUrl())) {
|
||||
throw new IllegalArgumentException("formUrl不能为空");
|
||||
}
|
||||
String jsonString = Optional.ofNullable(taskTask.getJsonData())
|
||||
.map(JSON::toJSONString) // 使用 Fastjson 或 Jackson
|
||||
.orElse("{}");
|
||||
Result<String> res = bpmBaseExtApiImpl.startMutilProcess(taskTask.getFlowCode(), taskTask.getBusinessId(), taskTask.getFormUrl(), taskTask.getFormUrl(), userName, jsonString);
|
||||
return res.isSuccess();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user