Commit 45007f7c authored by wdy's avatar wdy

暂存任务&查看暂存任务详情

parent 6543fc46
......@@ -34,6 +34,8 @@ public class Task {
public static final String TASK_STATUS_PENDING = "PENDING";
@TableField(exist = false)
public static final String TASK_STATUS_FINISH = "FINISH";
@TableField(exist = false)
public static final String TASK_STATUS_TEMPORARILY = "TEMPORARILY";
/**
* 汽车信息安全一般要求
......@@ -66,7 +68,7 @@ public class Task {
@JsonFormat(shape = JsonFormat.Shape.STRING)
private Long carReviewTaskId;
@ApiModelProperty("任务状态NEW(新建的)、PENDING(运行中的)、FINISH(已结束的)")
@ApiModelProperty("任务状态NEW(新建的)、PENDING(运行中的)、FINISH(已结束的)、TEMPORARILY(暂存)")
private String taskStatus;
@ApiModelProperty("任务运行状态[RUNNABLE(可运行的)、RUNNING(运行中的)]")
......
......@@ -9,6 +9,7 @@ import com.ruoyi.web.request.TaskFindPendingRequest;
import com.ruoyi.web.request.TaskFindRequest;
import com.ruoyi.web.request.TaskListRequest;
import com.ruoyi.web.response.TaskFindResponse;
import com.ruoyi.web.response.TaskGetInfoResponse;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;
......@@ -30,4 +31,6 @@ public interface TaskMapper extends BaseMapper<Task> {
Long findByCarReviewTaskId(@Param("carReviewId") Long carReviewId);
Long findBySystemReviewTaskId(@Param("systemReviewId") Long systemReviewId);
Task getByUserIdTemporary(@Param("userId") Long userId);
}
......@@ -54,4 +54,8 @@ public interface TaskService extends IService<Task> {
* @return
*/
List<Task> findUserFinish(TaskFindFinishRequest request,Long userId);
void temporaryStorageTask(TaskCreateRequest request);
TaskGetInfoResponse getByUserId(Long userId);
}
......@@ -325,6 +325,103 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task> implements Ta
return taskMapper.findUserFinish(request,userId);
}
@Override
public void temporaryStorageTask(TaskCreateRequest request) {
// 构建任务创建者
LoginUser loginUser = SecurityUtils.getLoginUser();
SysUser initiator = sysUserService.selectUserById(loginUser.getUserId());
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.setTaskInitiatorId(loginUser.getUserId());
task.setTaskInitiator(initiator.getNickName());
task.setTaskInitiatorDept(initiator.getDept().getDeptName());
task.setTaskStatus(Task.TASK_STATUS_TEMPORARILY);
task.setLeaderId(leader.getUserId());
task.setLeader(leader.getName());
task.setName(standard.getName());
task.setStandardNo(standard.getStandardNo());
task.setFile(standard.getFile());
String joinTaskList = StringUtils.join(request.getTaskList(),",");
task.setTaskList(joinTaskList);
BeanUtils.copyBeanProp(task, request);
taskService.save(task);
// 构建并保存该任务所关联的审核组信息
for(TaskUserRelation auditor : auditors) {
auditor.setTaskId(task.getId());
}
taskUserRelationService.saveBatch(auditors);
// 保存关联的整车样品信息
List<TaskSampleRelation> relations = request.getSample();
if (relations.size() != 0 && relations != null) {
for (TaskSampleRelation sampleRelation : relations) {
sampleRelation.setTaskId(task.getId());
}
taskSampleRelationService.saveBatch(relations);
}
// 保存关联的零部件样品信息
List<TaskSampleRelation> partRelations = request.getPartSample();
if (partRelations.size() != 0 && partRelations != null) {
for (TaskSampleRelation sampleRelation : partRelations) {
sampleRelation.setTaskId(task.getId());
}
taskSampleRelationService.saveBatch(partRelations);
}
}
@Override
public TaskGetInfoResponse getByUserId(Long userId) {
TaskGetInfoResponse response = new TaskGetInfoResponse();
Task task = taskMapper.getByUserIdTemporary(userId);
if (task != null && task.getId() != null) {
BeanUtils.copyBeanProp(response, task);
// 小组成员
List<TaskUserRelation> relation = taskUserRelationService.selectQTeamMembers(task.getId());
response.setAuditors(relation);
// 整车样品信息
List<TaskSampleRelation> relationList = taskSampleRelationService.selectByTaskId(task.getId(), TaskSampleRelation.COMPLETE_VEHICLE_SAMPLE);
if (relationList.size() != 0 && relationList != null) {
List<Sample> completeVehicleSampleList = sampleManagementMapper.findByIdList(relationList);
response.setCompleteVehicleSample(completeVehicleSampleList);
}
// 零部件样品信息
List<TaskSampleRelation> partRelationList = taskSampleRelationService.selectByTaskId(task.getId(), TaskSampleRelation.PART_VEHICLE_SAMPLE);
if (partRelationList.size() != 0 && partRelationList != null) {
List<Sample> partVehicleSampleList = sampleManagementMapper.findByIdList(partRelationList);
response.setPartVehicleSample(partVehicleSampleList);
}
return response;
} else {
return null;
}
}
public Long saveSystemReview(TaskCreateRequest request,SysUser initiator,Standard standard,TaskUserRelation leader) {
// 构建并保存任务信息
......
......@@ -61,6 +61,26 @@ public class TaskController extends BaseController {
return R.ok();
}
@ApiOperation("暂存任务")
@Trace
@Tags({@Tag(key = "param", value = "arg[0]"), @Tag(key = "result", value = "returnedObj")})
@Log(title = "总任务", businessType = BusinessType.INSERT)
@RequestMapping(method = RequestMethod.POST, value = "/temporaryStorage")
public R<String> temporaryStorage(@Validated @RequestBody TaskCreateRequest request) {
taskService.temporaryStorageTask(request);
return R.ok();
}
@ApiOperation("查看暂存任务详情")
@Trace
@Tags({@Tag(key = "param", value = "arg[0]"), @Tag(key = "result", value = "returnedObj")})
@RequestMapping(method = RequestMethod.POST, value = "/getTemporaryStorage")
public R<TaskGetInfoResponse> getTemporaryStorage() {
TaskGetInfoResponse response = taskService.getByUserId(getUserId());
return R.ok(response);
}
@ApiOperation("查看任务详情")
@Trace
@Tags({@Tag(key = "param", value = "arg[0]"), @Tag(key = "result", value = "returnedObj")})
......
......@@ -180,6 +180,7 @@
left join t_car_review_task crt on t.car_review_task_id = crt.id
<where>
and t.task_initiator_id = #{userId}
and t.task_status not in ("TEMPORARILY")
<if test="request.standardId != null and request.standardId != ''">
and t.standard_id = #{request.standardId}
</if>
......@@ -238,6 +239,19 @@
</if>
</where>
</select>
<select id="getByUserIdTemporary" resultType="com.ruoyi.domain.Task">
SELECT id, system_review_task_id, car_review_task_id,
task_status,run_status,next_node,task_no,task_name,confidentiality_level,
product_name,product_model,
entrusted_unit,entrusted_unit_address,entrusted_unit_phone,
entrusted_unit_code,vehicle_sample_information,part_sample_information,
task_initiator_id,task_initiator,task_initiator_dept,
task_begin_time,task_end_time,create_time,
leader_id,leader,standard_id,name,
standard_no,file,task_list
FROM t_task
WHERE task_initiator_id = #{userId} and task_status = 'TEMPORARILY'
</select>
</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