Commit 318b4c9b authored by W_Y's avatar W_Y

创建总任务

parent f39b4e8c
...@@ -23,6 +23,8 @@ import lombok.experimental.Accessors; ...@@ -23,6 +23,8 @@ import lombok.experimental.Accessors;
@Data @Data
public class CarReviewTask implements Serializable { public class CarReviewTask implements Serializable {
@TableField(exist = false)
public static final String TASK_STATUS_NEW = "NEW";
@TableField(exist = false) @TableField(exist = false)
public static final String TASK_STATUS_PENDING = "PENDING"; public static final String TASK_STATUS_PENDING = "PENDING";
@TableField(exist = false) @TableField(exist = false)
......
...@@ -30,6 +30,15 @@ public class Task { ...@@ -30,6 +30,15 @@ public class Task {
@TableField(exist = false) @TableField(exist = false)
public static final String STATUS_FINISH = "FINISH"; public static final String STATUS_FINISH = "FINISH";
@TableField(exist = false)
public static final String SUB_TASK_GRFIS = "grfis";
@TableField(exist = false)
public static final String SUB_TASK_TRFIS = "trfis";
@TableField(exist = false)
public static final String SUB_TASK_SRAIF = "sraif";
@ApiModelProperty("主键") @ApiModelProperty("主键")
@TableId(type = IdType.ASSIGN_ID) @TableId(type = IdType.ASSIGN_ID)
@JsonFormat(shape = JsonFormat.Shape.STRING) @JsonFormat(shape = JsonFormat.Shape.STRING)
...@@ -94,7 +103,7 @@ public class Task { ...@@ -94,7 +103,7 @@ public class Task {
@ApiModelProperty("样品数量") @ApiModelProperty("样品数量")
private String sampleNumber; private String sampleNumber;
@ApiModelProperty("生日期") @ApiModelProperty("生日期")
private Date productionDate; private Date productionDate;
@ApiModelProperty("商标") @ApiModelProperty("商标")
......
...@@ -14,7 +14,7 @@ import java.util.List; ...@@ -14,7 +14,7 @@ import java.util.List;
* @Entity com.ruoyi.domain.SystemReviewTaskUserRelation * @Entity com.ruoyi.domain.SystemReviewTaskUserRelation
*/ */
@Repository @Repository
public interface ReviewTaskUserRelationMapper extends BaseMapper<TaskUserRelation> { public interface TaskUserRelationMapper extends BaseMapper<TaskUserRelation> {
/** /**
* 根据任务id查询小组成员 * 根据任务id查询小组成员
......
...@@ -2,6 +2,7 @@ package com.ruoyi.service; ...@@ -2,6 +2,7 @@ package com.ruoyi.service;
import com.baomidou.mybatisplus.extension.service.IService; import com.baomidou.mybatisplus.extension.service.IService;
import com.ruoyi.domain.Task; import com.ruoyi.domain.Task;
import com.ruoyi.web.request.TaskCreateRequest;
import com.ruoyi.web.request.TaskListRequest; import com.ruoyi.web.request.TaskListRequest;
import java.util.List; import java.util.List;
...@@ -14,4 +15,6 @@ public interface TaskService extends IService<Task> { ...@@ -14,4 +15,6 @@ public interface TaskService extends IService<Task> {
* @return * @return
*/ */
List<Task> findList(TaskListRequest request); List<Task> findList(TaskListRequest request);
void createTask(TaskCreateRequest request);
} }
...@@ -7,10 +7,10 @@ import java.util.List; ...@@ -7,10 +7,10 @@ import java.util.List;
/** /**
* @author wangfei * @author wangfei
* @description 针对表【t_system_review_task_user_relation(体系审查任务&用户映射关系)】的数据库操作Service * @description 针对表【t_task_user_relation(体系审查任务&用户映射关系)】的数据库操作Service
* @createDate 2023-12-15 10:41:16 * @createDate 2023-12-15 10:41:16
*/ */
public interface ReviewTaskUserRelationService extends IService<TaskUserRelation> { public interface TaskUserRelationService extends IService<TaskUserRelation> {
/** /**
* 根据任务id查询小组成员 * 根据任务id查询小组成员
......
...@@ -9,7 +9,7 @@ import com.ruoyi.domain.*; ...@@ -9,7 +9,7 @@ import com.ruoyi.domain.*;
import com.ruoyi.mapper.ReviewDetailsMapper; import com.ruoyi.mapper.ReviewDetailsMapper;
import com.ruoyi.service.CarReviewTaskService; import com.ruoyi.service.CarReviewTaskService;
import com.ruoyi.mapper.CarReviewTaskMapper; import com.ruoyi.mapper.CarReviewTaskMapper;
import com.ruoyi.service.ReviewTaskUserRelationService; import com.ruoyi.service.TaskUserRelationService;
import com.ruoyi.service.StandardService; import com.ruoyi.service.StandardService;
import com.ruoyi.system.service.ISysUserService; import com.ruoyi.system.service.ISysUserService;
import com.ruoyi.web.request.CarReviewTaskCreateRequest; import com.ruoyi.web.request.CarReviewTaskCreateRequest;
...@@ -46,7 +46,7 @@ public class CarReviewTaskServiceImpl extends ServiceImpl<CarReviewTaskMapper, C ...@@ -46,7 +46,7 @@ public class CarReviewTaskServiceImpl extends ServiceImpl<CarReviewTaskMapper, C
private CarReviewTaskService carReviewTaskService; private CarReviewTaskService carReviewTaskService;
@Autowired @Autowired
private ReviewTaskUserRelationService relationService; private TaskUserRelationService relationService;
@Autowired @Autowired
private StrategyCarReviewTaskContext strategyCarReviewTaskContext; private StrategyCarReviewTaskContext strategyCarReviewTaskContext;
...@@ -82,7 +82,7 @@ public class CarReviewTaskServiceImpl extends ServiceImpl<CarReviewTaskMapper, C ...@@ -82,7 +82,7 @@ public class CarReviewTaskServiceImpl extends ServiceImpl<CarReviewTaskMapper, C
.setTaskNo(SnowflakeUtil.generate().toString()) .setTaskNo(SnowflakeUtil.generate().toString())
.setTaskInitiator(initiator.getNickName()) .setTaskInitiator(initiator.getNickName())
.setTaskInitiatorDept(initiator.getDept().getDeptName()) .setTaskInitiatorDept(initiator.getDept().getDeptName())
.setTaskStatus(CarReviewTask.TASK_STATUS_PENDING) .setTaskStatus(CarReviewTask.TASK_STATUS_NEW)
.setLeaderId(leader.getUserId()) .setLeaderId(leader.getUserId())
.setLeader(leader.getName()) .setLeader(leader.getName())
.setCreateTime(new Date()) .setCreateTime(new Date())
......
...@@ -99,8 +99,10 @@ public class ReviewSceneChangeTaskServiceImpl extends ServiceImpl<ReviewSceneCha ...@@ -99,8 +99,10 @@ public class ReviewSceneChangeTaskServiceImpl extends ServiceImpl<ReviewSceneCha
public void audit(ReviewSceneChangeTaskPassRequest request) { public void audit(ReviewSceneChangeTaskPassRequest request) {
if (request.getPassed().equals("0")) { if (request.getPassed().equals("0")) {
doProcess(request.getTaskId(), request.getComment(), ReviewSceneChangeTask.RESULT_REJECT); doProcess(request.getTaskId(), request.getComment(), ReviewSceneChangeTask.RESULT_REJECT);
} else { } else if(request.getPassed().equals("1")){
doProcess(request.getTaskId(), request.getComment(), ReviewSceneChangeTask.RESULT_PASS); doProcess(request.getTaskId(), request.getComment(), ReviewSceneChangeTask.RESULT_PASS);
} else {
throw new ServiceException("审核状态不正确",HttpStatus.ERROR);
} }
} }
......
...@@ -30,7 +30,7 @@ import java.util.*; ...@@ -30,7 +30,7 @@ import java.util.*;
public class SystemReviewTaskServiceImpl extends ServiceImpl<SystemReviewTaskMapper, SystemReviewTask> implements SystemReviewTaskService { public class SystemReviewTaskServiceImpl extends ServiceImpl<SystemReviewTaskMapper, SystemReviewTask> implements SystemReviewTaskService {
@Autowired @Autowired
private ReviewTaskUserRelationService systemReviewTaskUserRelationService; private TaskUserRelationService systemReviewTaskUserRelationService;
@Autowired @Autowired
private SystemReviewTaskService systemReviewTaskService; private SystemReviewTaskService systemReviewTaskService;
......
package com.ruoyi.service.impl; package com.ruoyi.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.domain.Task; import com.ruoyi.common.core.domain.entity.SysDictData;
import com.ruoyi.common.core.domain.entity.SysUser;
import com.ruoyi.common.core.domain.model.LoginUser;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.common.utils.SnowflakeUtil;
import com.ruoyi.common.utils.bean.BeanUtils;
import com.ruoyi.domain.*;
import com.ruoyi.mapper.TaskMapper; import com.ruoyi.mapper.TaskMapper;
import com.ruoyi.service.TaskService; import com.ruoyi.service.*;
import com.ruoyi.system.service.ISysUserService;
import com.ruoyi.web.request.TaskCreateRequest;
import com.ruoyi.web.request.TaskListRequest; import com.ruoyi.web.request.TaskListRequest;
import org.checkerframework.checker.units.qual.A; import org.checkerframework.checker.units.qual.A;
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 org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import java.util.Date;
import java.util.List; import java.util.List;
@Transactional @Transactional
...@@ -19,8 +28,129 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task> implements Ta ...@@ -19,8 +28,129 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task> implements Ta
@Autowired @Autowired
private TaskMapper taskMapper; private TaskMapper taskMapper;
@Autowired
private ISysUserService sysUserService;
@Autowired
private StandardService standardService;
@Autowired
private TaskUserRelationService taskUserRelationService;
@Autowired
private TaskService taskService;
@Autowired
private SystemReviewTaskService systemReviewTaskService;
@Autowired
private CarReviewTaskService carReviewTaskService;
@Override @Override
public List<Task> findList(TaskListRequest request) { public List<Task> findList(TaskListRequest request) {
return taskMapper.findList(request); return taskMapper.findList(request);
} }
@Override
public void createTask(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.setTaskInitiator(initiator.getNickName());
task.setTaskInitiatorDept(initiator.getDept().getDeptName());
task.setTaskStatus(Task.STATUS_NEW);
task.setLeaderId(leader.getUserId());
task.setLeader(leader.getName());
task.setCreateTime(new Date());
task.setName(standard.getName());
task.setStandardNo(standard.getStandardNo());
task.setFile(standard.getFile());
BeanUtils.copyBeanProp(task, request);
Long systemReviewTaskId = null;
Long carReviewTaskId = null;
if (request.getTaskList().contains(Task.SUB_TASK_SRAIF)) {
// 保存体系审查任务
systemReviewTaskId = saveSystemReview(request,initiator,standard,leader);
}
if (request.getTaskList().contains(Task.SUB_TASK_GRFIS) || request.getTaskList().contains(Task.SUB_TASK_TRFIS)) {
// 保存车型审查问卷任务
carReviewTaskId = saveCarReview(request,initiator,standard,leader);
}
task.setCarReviewTaskId(carReviewTaskId);
task.setSystemReviewTaskId(systemReviewTaskId);
taskService.save(task);
// 构建并保存该任务所关联的审核组信息
for(TaskUserRelation auditor : auditors) {
auditor.setTaskId(task.getId());
}
taskUserRelationService.saveBatch(auditors);
}
public Long saveSystemReview(TaskCreateRequest request,SysUser initiator,Standard standard,TaskUserRelation leader) {
// 构建并保存任务信息
SystemReviewTask task = new SystemReviewTask()
.setTaskNo(request.getTaskNo())
.setTaskInitiator(initiator.getNickName())
.setTaskInitiatorDept(initiator.getDept().getDeptName())
.setTaskStatus(SystemReviewTask.STATUS_NEW)
.setLeaderId(leader.getUserId())
.setLeader(leader.getName())
.setCreateTime(new Date())
.setStandardId(standard.getId())
.setName(standard.getName())
.setStandardNo(standard.getStandardNo())
.setFile(standard.getFile());
systemReviewTaskService.save(task);
return task.getId();
}
public Long saveCarReview(TaskCreateRequest request,SysUser initiator,Standard standard,TaskUserRelation leader) {
List<String> taskList = request.getTaskList();
// 构建并保存任务信息
CarReviewTask task = new CarReviewTask()
.setTaskNo(request.getTaskNo())
.setTaskInitiator(initiator.getNickName())
.setTaskInitiatorDept(initiator.getDept().getDeptName())
.setTaskStatus(CarReviewTask.TASK_STATUS_NEW)
.setLeaderId(leader.getUserId())
.setLeader(leader.getName())
.setCreateTime(new Date())
.setTaskBeginTime(new Date())
.setStandardId(standard.getId())
.setName(standard.getName())
.setStandardNo(standard.getStandardNo())
.setFile(standard.getFile())
.setReviewStatus(taskList.contains(Task.SUB_TASK_GRFIS) ? CarReviewTask.REVIEW_STATUS_NEW : CarReviewTask.REVIEW_STATUS_NONE)
.setTestStatus(taskList.contains(Task.SUB_TASK_TRFIS) ? CarReviewTask.TEST_STATUS_NEW : CarReviewTask.TEST_STATUS_NONE);
carReviewTaskService.save(task);
return task.getId();
}
} }
...@@ -2,8 +2,8 @@ package com.ruoyi.service.impl; ...@@ -2,8 +2,8 @@ package com.ruoyi.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.domain.TaskUserRelation; import com.ruoyi.domain.TaskUserRelation;
import com.ruoyi.service.ReviewTaskUserRelationService; import com.ruoyi.service.TaskUserRelationService;
import com.ruoyi.mapper.ReviewTaskUserRelationMapper; import com.ruoyi.mapper.TaskUserRelationMapper;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
...@@ -15,11 +15,11 @@ import java.util.List; ...@@ -15,11 +15,11 @@ import java.util.List;
* @createDate 2023-12-15 10:41:16 * @createDate 2023-12-15 10:41:16
*/ */
@Service @Service
public class ReviewTaskUserRelationServiceImpl extends ServiceImpl<ReviewTaskUserRelationMapper, TaskUserRelation> public class TaskUserRelationServiceImpl extends ServiceImpl<TaskUserRelationMapper, TaskUserRelation>
implements ReviewTaskUserRelationService { implements TaskUserRelationService {
@Autowired @Autowired
ReviewTaskUserRelationMapper reviewTaskUserRelationMapper; TaskUserRelationMapper reviewTaskUserRelationMapper;
/** /**
* 根据任务id查询小组成员 * 根据任务id查询小组成员
......
...@@ -4,8 +4,8 @@ package com.ruoyi.web; ...@@ -4,8 +4,8 @@ package com.ruoyi.web;
import com.ruoyi.common.core.controller.BaseController; import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.R; import com.ruoyi.common.core.domain.R;
import com.ruoyi.domain.TaskUserRelation; import com.ruoyi.domain.TaskUserRelation;
import com.ruoyi.service.ReviewTaskUserRelationService; import com.ruoyi.service.TaskUserRelationService;
import com.ruoyi.web.request.ReviewTaskUserRelationMembersRequest; import com.ruoyi.web.request.TaskUserRelationMembersRequest;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import org.apache.skywalking.apm.toolkit.trace.Tag; import org.apache.skywalking.apm.toolkit.trace.Tag;
...@@ -24,7 +24,7 @@ import java.util.List; ...@@ -24,7 +24,7 @@ import java.util.List;
public class ReviewTaskUserRelationController extends BaseController { public class ReviewTaskUserRelationController extends BaseController {
@Autowired @Autowired
ReviewTaskUserRelationService reviewTaskUserRelationService; TaskUserRelationService reviewTaskUserRelationService;
/** /**
...@@ -35,7 +35,7 @@ public class ReviewTaskUserRelationController extends BaseController { ...@@ -35,7 +35,7 @@ public class ReviewTaskUserRelationController extends BaseController {
@Trace @Trace
@Tags({@Tag(key = "param", value = "arg[0]"), @Tag(key = "result", value = "returnedObj")}) @Tags({@Tag(key = "param", value = "arg[0]"), @Tag(key = "result", value = "returnedObj")})
@RequestMapping(method = RequestMethod.POST, value = "/members") @RequestMapping(method = RequestMethod.POST, value = "/members")
public R<List<TaskUserRelation>> selectQTeamMemberList(@Validated @RequestBody ReviewTaskUserRelationMembersRequest request){ public R<List<TaskUserRelation>> selectQTeamMemberList(@Validated @RequestBody TaskUserRelationMembersRequest request){
List<TaskUserRelation> list = reviewTaskUserRelationService.selectQTeamMembers(request.getTaskId()); List<TaskUserRelation> list = reviewTaskUserRelationService.selectQTeamMembers(request.getTaskId());
return R.ok(list); return R.ok(list);
} }
......
package com.ruoyi.web;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.domain.Task;
import com.ruoyi.service.TaskService;
import com.ruoyi.web.request.TaskCreateRequest;
import com.ruoyi.web.request.TaskListRequest;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.skywalking.apm.toolkit.trace.Tag;
import org.apache.skywalking.apm.toolkit.trace.Tags;
import org.apache.skywalking.apm.toolkit.trace.Trace;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
@Api(tags = "总任务")
@RestController
@RequestMapping("/task")
public class TaskController extends BaseController {
@Autowired
private TaskService taskService;
@ApiOperation("查询任务列表")
@Trace
@Tags({@Tag(key = "param", value = "arg[0]"), @Tag(key = "result", value = "returnedObj")})
@RequestMapping(method = RequestMethod.POST, value = "/findList")
public TableDataInfo<Task> findList(@Validated @RequestBody TaskListRequest request) {
startPage(request);
return getDataTable(taskService.findList(request));
}
@ApiOperation("创建任务")
@Trace
@Tags({@Tag(key = "param", value = "arg[0]"), @Tag(key = "result", value = "returnedObj")})
@Log(title = "总任务", businessType = BusinessType.INSERT)
@RequestMapping(method = RequestMethod.POST, value = "/createTask")
public R<String> createTask(@Validated @RequestBody TaskCreateRequest request) {
taskService.createTask(request);
return R.ok();
}
}
package com.ruoyi.web.request;
import com.ruoyi.common.core.domain.entity.SysDictData;
import com.ruoyi.domain.TaskUserRelation;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.Date;
import java.util.List;
@ApiModel(value = "TaskCreateRequest", description = "创建总任务")
@Data
public class TaskCreateRequest {
@ApiModelProperty("小组成员")
private List<TaskUserRelation> auditors;
@ApiModelProperty("任务编号")
private String taskNo;
@ApiModelProperty("任务名称")
private String taskName;
@ApiModelProperty("产品名称")
private String productName;
@ApiModelProperty("产品型号")
private String productModel;
@ApiModelProperty("委托单位")
private String entrustedUnit;
@ApiModelProperty("委托单位地址")
private String entrustedUnitAddress;
@ApiModelProperty("委托单位电话")
private String entrustedUnitPhone;
@ApiModelProperty("委托单位邮政编码")
private String entrustedUnitCode;
@ApiModelProperty("车辆类型")
private String carType;
@ApiModelProperty("车辆识别码")
private String carIdentificationCode;
@ApiModelProperty("保密等级")
private String confidentialityLevel;
@ApiModelProperty("样品名称")
private String sampleName;
@ApiModelProperty("生产企业")
private String productionEnterprise;
@ApiModelProperty("送样者")
private String sampleSender;
@ApiModelProperty("送样日期")
private Date sendDate;
@ApiModelProperty("样品数量")
private String sampleNumber;
@ApiModelProperty("生产日期")
private Date productionDate;
@ApiModelProperty("商标")
private String trademark;
@ApiModelProperty("检验依据")
private String inspectionBasis;
@ApiModelProperty("选择的任务")
List<String> taskList;
/**
* 标准id
* 根据哪个标准新建的审查任务
*/
@ApiModelProperty("标准id(根据哪个标准新建的任务)")
private Long standardId;
}
...@@ -5,7 +5,7 @@ import io.swagger.annotations.ApiModelProperty; ...@@ -5,7 +5,7 @@ import io.swagger.annotations.ApiModelProperty;
import lombok.Data; import lombok.Data;
@Data @Data
public class ReviewTaskUserRelationMembersRequest { public class TaskUserRelationMembersRequest {
@ApiModelProperty("任务id") @ApiModelProperty("任务id")
private Long taskId; private Long taskId;
} }
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
<!DOCTYPE mapper <!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd"> "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.ruoyi.mapper.ReviewTaskUserRelationMapper"> <mapper namespace="com.ruoyi.mapper.TaskUserRelationMapper">
<resultMap id="BaseResultMap" type="com.ruoyi.domain.TaskUserRelation"> <resultMap id="BaseResultMap" type="com.ruoyi.domain.TaskUserRelation">
<result property="taskId" column="task_id" jdbcType="BIGINT"/> <result property="taskId" column="task_id" jdbcType="BIGINT"/>
......
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