Commit 8fe49413 authored by wdy's avatar wdy

Merge branch 'wangdingyi' into 'dev'

新增任务名称验重

See merge request !202
parents 7d791f85 96f1f75e
...@@ -35,4 +35,6 @@ public interface TaskMapper extends BaseMapper<Task> { ...@@ -35,4 +35,6 @@ public interface TaskMapper extends BaseMapper<Task> {
Task getByUserIdTemporary(@Param("userId") Long userId); Task getByUserIdTemporary(@Param("userId") Long userId);
Task getBySubtaskId(@Param("subId") Long subId); Task getBySubtaskId(@Param("subId") Long subId);
Long findTaskName(@Param("taskName") String taskName);
} }
...@@ -5,8 +5,10 @@ import cn.hutool.core.util.ObjectUtil; ...@@ -5,8 +5,10 @@ import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.common.DataStatisticsUtils; import com.ruoyi.common.DataStatisticsUtils;
import com.ruoyi.common.constant.HttpStatus;
import com.ruoyi.common.core.domain.entity.SysUser; import com.ruoyi.common.core.domain.entity.SysUser;
import com.ruoyi.common.core.domain.model.LoginUser; import com.ruoyi.common.core.domain.model.LoginUser;
import com.ruoyi.common.exception.ServiceException;
import com.ruoyi.common.utils.DateUtils; import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.SecurityUtils; import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.common.utils.StringUtils; import com.ruoyi.common.utils.StringUtils;
...@@ -17,6 +19,7 @@ import com.ruoyi.service.*; ...@@ -17,6 +19,7 @@ import com.ruoyi.service.*;
import com.ruoyi.system.service.ISysUserService; import com.ruoyi.system.service.ISysUserService;
import com.ruoyi.web.request.*; import com.ruoyi.web.request.*;
import com.ruoyi.web.response.DataStatisticsResponse; import com.ruoyi.web.response.DataStatisticsResponse;
import com.ruoyi.web.response.ResultCountResponse;
import com.ruoyi.web.response.TaskFindResponse; import com.ruoyi.web.response.TaskFindResponse;
import com.ruoyi.web.response.TaskGetInfoResponse; import com.ruoyi.web.response.TaskGetInfoResponse;
import org.apache.poi.ss.formula.functions.T; import org.apache.poi.ss.formula.functions.T;
...@@ -105,70 +108,76 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task>implements Tas ...@@ -105,70 +108,76 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task>implements Tas
@Override @Override
public void createTask(TaskCreateRequest request) { public void createTask(TaskCreateRequest request) {
// 构建任务创建者 Long sum = taskMapper.findTaskName(request.getTaskName());
LoginUser loginUser = SecurityUtils.getLoginUser();
SysUser initiator = sysUserService.selectUserById(loginUser.getUserId());
Standard standard = standardService.findListById(request.getStandardId());
// 找到审查组长 if (sum > 0) {
TaskUserRelation leader = null; throw new ServiceException("任务名称重复,请检查", HttpStatus.ERROR);
List<TaskUserRelation> auditors = request.getAuditors(); } else {
for(TaskUserRelation auditor : auditors) { // 构建任务创建者
if(auditor.getIsLeader() == 1) { LoginUser loginUser = SecurityUtils.getLoginUser();
leader = auditor; SysUser initiator = sysUserService.selectUserById(loginUser.getUserId());
break; Standard standard = standardService.findListById(request.getStandardId());
// 找到审查组长
TaskUserRelation leader = null;
List<TaskUserRelation> auditors = request.getAuditors();
for(TaskUserRelation auditor : auditors) {
if(auditor.getIsLeader() == 1) {
leader = auditor;
break;
}
} }
}
// 构建并保存任务信息 // 构建并保存任务信息
// 总任务 // 总任务
Task task = new Task(); Task task = new Task();
task.setTaskInitiatorId(loginUser.getUserId()); task.setTaskInitiatorId(loginUser.getUserId());
task.setTaskInitiator(initiator.getNickName()); task.setTaskInitiator(initiator.getNickName());
if (initiator.getDept() != null) { if (initiator.getDept() != null) {
task.setTaskInitiatorDept(initiator.getDept().getDeptName()); task.setTaskInitiatorDept(initiator.getDept().getDeptName());
} }
task.setTaskStatus(Task.TASK_STATUS_NEW); task.setTaskStatus(Task.TASK_STATUS_NEW);
task.setRunStatus(Task.RUN_STATUS_RUNNABLE); task.setRunStatus(Task.RUN_STATUS_RUNNABLE);
task.setLeaderId(leader.getUserId()); task.setLeaderId(leader.getUserId());
task.setLeader(leader.getName()); task.setLeader(leader.getName());
task.setCreateTime(new Date()); task.setCreateTime(new Date());
task.setName(standard.getName()); task.setName(standard.getName());
task.setStandardNo(standard.getStandardNo()); task.setStandardNo(standard.getStandardNo());
task.setFile(standard.getFile()); task.setFile(standard.getFile());
setTaskList(request.getTaskList(),task); setTaskList(request.getTaskList(),task);
BeanUtils.copyBeanProp(task, request); BeanUtils.copyBeanProp(task, request);
if(request.getTaskList().contains(Task.SUB_TASK_GRFIS)) { if(request.getTaskList().contains(Task.SUB_TASK_GRFIS)) {
// 保存车型审查问卷任务 // 保存车型审查问卷任务
task.setCarReviewTaskId(saveCarReview(request,initiator,standard,leader)); task.setCarReviewTaskId(saveCarReview(request,initiator,standard,leader));
} }
if(request.getTaskList().contains(Task.SUB_TASK_SRAIF)) { if(request.getTaskList().contains(Task.SUB_TASK_SRAIF)) {
// 保存体系审查任务 // 保存体系审查任务
task.setSystemReviewTaskId(saveSystemReview(request,initiator,standard,leader)); task.setSystemReviewTaskId(saveSystemReview(request,initiator,standard,leader));
} }
if (request.getTaskList().contains(Task.SUB_TASK_TRFIS)) { if (request.getTaskList().contains(Task.SUB_TASK_TRFIS)) {
task.setModelTestTaskId(saveModelTest(request, initiator, standard, leader)); task.setModelTestTaskId(saveModelTest(request, initiator, standard, leader));
} }
taskService.save(task); taskService.save(task);
// 总任务包含车型试验,添加任务-场景关联信息 // 总任务包含车型试验,添加任务-场景关联信息
saveTaskScenario(task.getId(), request.getTestScenarioList()); saveTaskScenario(task.getId(), request.getTestScenarioList());
// 构建并保存该任务所关联的审核组信息 // 构建并保存该任务所关联的审核组信息
saveUserRelation(auditors,task); saveUserRelation(auditors,task);
// 保存关联的整车样品信息和零部件样品信息 // 保存关联的整车样品信息和零部件样品信息
List<TaskSampleRelation> relations = request.getSample(); List<TaskSampleRelation> relations = request.getSample();
List<TaskSampleRelation> partRelations = request.getPartSample(); List<TaskSampleRelation> partRelations = request.getPartSample();
saveSampleRelation(relations,partRelations,task); saveSampleRelation(relations,partRelations,task);
taskStateFacade.doCreate(task, request.getTaskList()); taskStateFacade.doCreate(task, request.getTaskList());
TaskGetInfoResponse temporaryStorageTask = taskService.getByUserId(loginUser.getUserId()); TaskGetInfoResponse temporaryStorageTask = taskService.getByUserId(loginUser.getUserId());
if(temporaryStorageTask != null) { if(temporaryStorageTask != null) {
taskMapper.deleteById(temporaryStorageTask.getId()); taskMapper.deleteById(temporaryStorageTask.getId());
}
} }
} }
......
package com.ruoyi.web.response;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@ApiModel("计算问卷结果VO")
public class ResultCountResponse {
@ApiModelProperty("任务id")
private Long taskId;
@ApiModelProperty("任务状态")
private String taskStatus;
@ApiModelProperty("进度")
private Double schedule;
}
...@@ -277,6 +277,10 @@ ...@@ -277,6 +277,10 @@
FROM t_task FROM t_task
WHERE system_review_task_id = #{subId} OR car_review_task_id = #{subId} WHERE system_review_task_id = #{subId} OR car_review_task_id = #{subId}
</select> </select>
<select id="findTaskName" resultType="java.lang.Long">
select COUNT(*) sum from t_task
where task_name = #{taskName}
</select>
</mapper> </mapper>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment