Merge remote-tracking branch 'origin/master'
# Conflicts: # jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/tasktask/entity/TaskTask.java
This commit is contained in:
+4
-3
@@ -19,6 +19,7 @@ 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.dto.RecurringTaskDTO;
|
||||
import org.jeecg.modules.tasktask.entity.TaskTask;
|
||||
import org.jeecg.modules.tasktask.mapper.TaskTaskMapper;
|
||||
import org.jeecg.modules.tasktask.service.ITaskTaskService;
|
||||
@@ -108,14 +109,14 @@ public class TaskTaskController extends JeecgController<TaskTask, ITaskTaskServi
|
||||
/**
|
||||
* 添加
|
||||
*
|
||||
* @param taskTask
|
||||
* @param recurringTaskDTO
|
||||
* @return
|
||||
*/
|
||||
@AutoLog(value = "事项任务计划表(发起周期性流程)-添加")
|
||||
@Operation(summary = "事项任务计划表(发起周期性流程)-添加")
|
||||
@RequiresPermissions("tasktask:task_task:add")
|
||||
@PostMapping(value = "/flow-schedules")
|
||||
public Result<?> addRecurringTask(@RequestBody TaskTask taskTask, Integer intervalType, Integer startCount) {
|
||||
public Result<?> addRecurringTask(@RequestBody RecurringTaskDTO recurringTaskDTO) throws Exception {
|
||||
// 获取用户信息
|
||||
LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
|
||||
String username = sysUser.getUsername();
|
||||
@@ -126,7 +127,7 @@ public class TaskTaskController extends JeecgController<TaskTask, ITaskTaskServi
|
||||
}
|
||||
|
||||
// 业务逻辑全部交给 Service
|
||||
return taskTaskService.handleFlowStart(taskTask, username, intervalType, startCount);
|
||||
return taskTaskService.handleFlowStart(recurringTaskDTO.getTaskTask(), username, recurringTaskDTO.getIntervalType(), recurringTaskDTO.getStartCount());
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
package org.jeecg.modules.tasktask.dto;
|
||||
|
||||
import lombok.Data;
|
||||
import org.jeecg.modules.tasktask.entity.TaskTask;
|
||||
|
||||
@Data
|
||||
public class RecurringTaskDTO {
|
||||
private TaskTask taskTask; // 或者直接展开 TaskTask 的属性
|
||||
private Integer intervalType;
|
||||
private Integer startCount;
|
||||
}
|
||||
+5
-1
@@ -10,6 +10,10 @@ import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.annotation.*;
|
||||
import com.baomidou.mybatisplus.extension.handlers.FastjsonTypeHandler;
|
||||
import java.util.Map;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.*;
|
||||
import com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler;
|
||||
import org.jeecg.common.constant.ProvinceCityArea;
|
||||
import org.jeecg.common.util.SpringContextUtils;
|
||||
import lombok.Data;
|
||||
@@ -28,7 +32,7 @@ import lombok.experimental.Accessors;
|
||||
* @Version: V1.0
|
||||
*/
|
||||
@Data
|
||||
@TableName("task_task")
|
||||
@TableName(value = "task_task", autoResultMap = true)
|
||||
@Accessors(chain = true)
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@Schema(description="事项任务计划表(发起流程)")
|
||||
|
||||
+1
-1
@@ -13,5 +13,5 @@ import com.baomidou.mybatisplus.extension.service.IService;
|
||||
public interface ITaskTaskService extends IService<TaskTask> {
|
||||
boolean singleFlowStart(TaskTask taskTask,String userName) throws Exception;
|
||||
boolean multiFlowStart(TaskTask taskTask,String userName,Integer intervalType, Integer startCount) throws Exception;
|
||||
Result<?> handleFlowStart(TaskTask taskTask, String username, Integer intervalType, Integer startCount);
|
||||
Result<?> handleFlowStart(TaskTask taskTask, String username, Integer intervalType, Integer startCount)throws Exception;
|
||||
}
|
||||
|
||||
+26
-25
@@ -33,15 +33,6 @@ public class TaskTaskServiceImpl extends ServiceImpl<TaskTaskMapper, TaskTask> i
|
||||
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("{}");
|
||||
@@ -73,9 +64,9 @@ public class TaskTaskServiceImpl extends ServiceImpl<TaskTaskMapper, TaskTask> i
|
||||
}
|
||||
return this.saveBatch(temTaskList);
|
||||
}
|
||||
public Result<?> handleFlowStart(TaskTask taskTask, String username, Integer intervalType, Integer startCount) throws Exception {
|
||||
public Result<?> handleFlowStart(TaskTask taskTask, String username, Integer intervalType, Integer startCount) throws Exception{
|
||||
// 1. 显式校验:代替 Assert
|
||||
Result<?> checkResult = validateBusinessParams(taskTask, startCount);
|
||||
Result<?> checkResult = validateBusinessParams(taskTask);
|
||||
if (!checkResult.isSuccess()) {
|
||||
return checkResult; // 校验不通过直接返回错误
|
||||
}
|
||||
@@ -89,20 +80,6 @@ public class TaskTaskServiceImpl extends ServiceImpl<TaskTaskMapper, TaskTask> i
|
||||
}
|
||||
|
||||
if (FlowConstants.Strategy.RECURRING_ONLY.equals(triggerType)) {
|
||||
boolean success = multiFlowStart(taskTask, username, intervalType, startCount);
|
||||
return success ? Result.ok("周期性流程添加成功") : Result.error("周期性流程添加失败");
|
||||
}
|
||||
|
||||
// 3. 保底处理
|
||||
return Result.error("未知的触发类型: " + triggerType);
|
||||
}
|
||||
private Result<?> validateBusinessParams(TaskTask taskTask, Integer startCount) {
|
||||
if (taskTask.getTriggerType() == null) {
|
||||
return Result.error("触发类型不能为空");
|
||||
}
|
||||
|
||||
// 如果是周期任务,校验次数和开始时间
|
||||
if (FlowConstants.Strategy.RECURRING_ONLY.equals(taskTask.getTriggerType())) {
|
||||
if (startCount == null || startCount <= 0) {
|
||||
return Result.error("周期任务生成数量必须大于0");
|
||||
}
|
||||
@@ -112,7 +89,31 @@ public class TaskTaskServiceImpl extends ServiceImpl<TaskTaskMapper, TaskTask> i
|
||||
if (taskTask.getStartTime() == null) {
|
||||
return Result.error("周期性流程开始时间不能为空");
|
||||
}
|
||||
boolean success = multiFlowStart(taskTask, username, intervalType, startCount);
|
||||
return success ? Result.ok("周期性流程添加成功") : Result.error("周期性流程添加失败");
|
||||
}
|
||||
|
||||
// 3. 保底处理
|
||||
return Result.error("未知的触发类型: " + triggerType);
|
||||
}
|
||||
private Result<?> validateBusinessParams(TaskTask taskTask) {
|
||||
if(taskTask == null){
|
||||
return Result.error("Task对象不能未空");
|
||||
}
|
||||
if (taskTask.getTriggerType() == null) {
|
||||
return Result.error("触发类型不能为空");
|
||||
}
|
||||
//立即督办或周期性督办都需要该校验流程
|
||||
if (StringUtils.isBlank(taskTask.getFlowCode())) {
|
||||
return Result.error("flowCode不能为空");
|
||||
}
|
||||
if (StringUtils.isBlank(taskTask.getBusinessId())) {
|
||||
return Result.error("businessId不能为空");
|
||||
}
|
||||
if (StringUtils.isBlank(taskTask.getFormUrl())) {
|
||||
return Result.error("formUrl不能为空");
|
||||
}
|
||||
|
||||
return Result.ok();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user