Commit 9f6ba851 authored by 盖献康's avatar 盖献康

Merge branch 'dev' into 'master'

dev - master 6.0

See merge request !300
parents 2a8263fa 2e3b739d
......@@ -46,6 +46,14 @@ public class ModelTestTask {
@TableField(exist = false)
public static final String TASK_STATUS_FINISH = "FINISH";
/**
* 任务结果
*/
@TableField(exist = false)
public static final String TASK_STATUS_PASS = "PASS";
@TableField(exist = false)
public static final String TASK_STATUS_REJECT = "REJECT";
@ApiModelProperty("主键")
@TableId(type = IdType.ASSIGN_ID)
@JsonFormat(shape = JsonFormat.Shape.STRING)
......
......@@ -30,11 +30,14 @@ public class TestRecords {
@ApiModelProperty("用例名称")
private String usecase;
@ApiModelProperty("用例编号")
private String usecaseNo;
@ApiModelProperty("用例id")
private String usecaseId;
@ApiModelProperty("测试时间")
private Date testTime;
private String testTime;
@ApiModelProperty("用例简述")
private String description;
......
......@@ -28,6 +28,12 @@ public class CaseResultVO {
@ApiModelProperty("用例检测状态枚举 UNPROCESSED: 未处理 PASSED: 通过 FAILED: 失败 PROCESSING: 处理中 IGNORED: 已忽略")
private String status;
@ApiModelProperty("用例编号")
private String serial_number;
@ApiModelProperty("用例开始时间")
private Integer start_time;
@ApiModelProperty("用例步骤结果列表")
List<StepResultVO> step_result_list;
}
package com.ruoyi.domain.vo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
* 检验项目VO
* @author gxk
*/
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@ApiModel("检验项目VO")
public class InspectionItemVO {
@ApiModelProperty("检验项目名")
private String inspectionItemName;
@ApiModelProperty("检验项目结果")
private String taskResult;
}
package com.ruoyi.domain.vo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
* 总任务 - 检验人员VO
* @author gxk
*/
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@ApiModel("检验人员VO")
public class InspectionPersonnelVO {
@ApiModelProperty("负责人")
private String principal;
@ApiModelProperty("检验人员")
private String inspectionPersonnel;
@ApiModelProperty("检验日期")
private String inspectionDate;
}
package com.ruoyi.domain.vo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
* 用于检验报告PDF 的 检验结论
* @author gxk
*/
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@ApiModel("检验结论VO")
public class TestConclusionVO {
@ApiModelProperty("体系审查任务结论")
private String systemReviewTaskResult;
@ApiModelProperty("车辆检验任务结论")
private String carReviewTaskResult;
@ApiModelProperty("车型试验任务结论")
private String modelTestTaskResult;
@ApiModelProperty("系统审查任务完成日期")
private String systemReviewTaskDate;
@ApiModelProperty("车辆检验任务完成日期")
private String carReviewTaskDate;
@ApiModelProperty("车型试验任务完成日期")
private String modelTestTaskDate;
}
......@@ -4,7 +4,9 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.ruoyi.domain.Task;
import com.ruoyi.domain.TaskUserRelation;
import com.ruoyi.domain.vo.EnterpriseFilePdfVO;
import com.ruoyi.domain.vo.InspectionPersonnelVO;
import com.ruoyi.domain.vo.InspectionReportPdfVO;
import com.ruoyi.domain.vo.TestConclusionVO;
import com.ruoyi.web.request.TaskFindFinishRequest;
import com.ruoyi.web.request.TaskFindPendingRequest;
import com.ruoyi.web.request.TaskFindRequest;
......@@ -67,4 +69,17 @@ public interface TaskMapper extends BaseMapper<Task> {
List<UserNameResponse> findByFinishTaskList(@Param("taskList") List<Task> taskList);
/**
* 通过总任务ID查询当前任务的每个子任务的结果
* @param taskId
* @return
*/
TestConclusionVO selectTestConclusion(Long taskId);
/**
* 通过总任务ID查询当前任务的小组成员
* @param taskId
* @return
*/
InspectionPersonnelVO selectInspectionPersonnelById(Long taskId);
}
......@@ -27,11 +27,10 @@ import com.ruoyi.common.core.domain.entity.SysDictData;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.PdfBaseWriter;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.domain.ModelTestTask;
import com.ruoyi.domain.Sample;
import com.ruoyi.domain.TestRecords;
import com.ruoyi.domain.vo.EnterpriseFilePdfVO;
import com.ruoyi.domain.vo.InspectionReportPdfVO;
import com.ruoyi.domain.vo.ReviewEnterpriseArchiveViewVO;
import com.ruoyi.domain.vo.*;
import com.ruoyi.mapper.SampleManagementMapper;
import com.ruoyi.mapper.TaskMapper;
import com.ruoyi.mapper.TestRecordsMapper;
......@@ -42,11 +41,6 @@ import io.minio.MinioClient;
import io.minio.ObjectWriteArgs;
import io.minio.PutObjectArgs;
import lombok.SneakyThrows;
import org.commonmark.node.Node;
import org.commonmark.parser.Parser;
import org.commonmark.renderer.html.HtmlRenderer;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Entities;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
......@@ -283,13 +277,15 @@ public class PdfTemplateManagementServiceImpl implements PdfTemplateManagementSe
List<TestRecords> recordsList = testRecordsMapper.selectListByGeneralTaskId(taskId);
// 查询本任务对应的所有样品编号、样品照片
InspectionReportPdfVO reportData = taskMapper.selectInspectionReportData(taskId);
// 查询检验负责人
InspectionPersonnelVO inspectionPersonnel = taskMapper.selectInspectionPersonnelById(taskId);
// 创建临时文档
String templateName = temporaryDocument(sample, recordsList, reportData);
String templateName = temporaryDocument(sample, recordsList, reportData, inspectionPersonnel);
PdfReader pdfReader = new PdfReader(minioUrl() + templateName);
totalNum = pdfReader.getNumberOfPages() - 1;
// 真正文档
String currentName = temporaryDocument(sample, recordsList, reportData);
String currentName = temporaryDocument(sample, recordsList, reportData, inspectionPersonnel);
// copy - 分割
Document currentDoc = new Document();
ByteArrayOutputStream arrayOutputStream = new ByteArrayOutputStream();
......@@ -304,7 +300,7 @@ public class PdfTemplateManagementServiceImpl implements PdfTemplateManagementSe
currentDoc.close();
templateReader.close();
copy.close();
return uploadMinio(arrayOutputStream, "原始记录");
return uploadMinio(arrayOutputStream, "车型审查原始记录-" + getReportName());
}
/**
......@@ -312,11 +308,12 @@ public class PdfTemplateManagementServiceImpl implements PdfTemplateManagementSe
* @param sample 样品信息
* @param recordsList 定时任务接收数据List
* @param reportData
* @param inspectionPersonnel 检验人员信息
* @return
* @throws Exception
*/
@SneakyThrows
private String temporaryDocument(Sample sample, List<TestRecords> recordsList, InspectionReportPdfVO reportData) throws Exception {
private String temporaryDocument(Sample sample, List<TestRecords> recordsList, InspectionReportPdfVO reportData, InspectionPersonnelVO inspectionPersonnel) throws Exception {
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
......@@ -337,9 +334,9 @@ public class PdfTemplateManagementServiceImpl implements PdfTemplateManagementSe
// 3.仪器设备信息
instrumentInformationSection(document);
// 第一页下方信息
bottomOfTheFirstPage(document, writer);
bottomOfTheFirstPage(document, writer,reportData, inspectionPersonnel);
// 4.检验结果(循环遍历用例)
testResultSection(document, recordsList, reportData);
testResultSection(document, recordsList, reportData, inspectionPersonnel);
// 5.附录
document.setParagraph("5.附录", 10f, Element.ALIGN_LEFT, 0,2f, 0f);
// 样品照片
......@@ -451,20 +448,22 @@ public class PdfTemplateManagementServiceImpl implements PdfTemplateManagementSe
* 车型试验原始记录 - 第一页下方固定内容
* @param document
* @param writer
* @param reportData
* @param inspectionPersonnel
*/
private void bottomOfTheFirstPage(PdfBaseWriter document, PdfWriter writer) {
PdfPTable inspectorTable = new PdfPTable(new float[]{20, 20, 10, 40});
private void bottomOfTheFirstPage(PdfBaseWriter document, PdfWriter writer,InspectionReportPdfVO reportData, InspectionPersonnelVO inspectionPersonnel) {
PdfPTable inspectorTable = new PdfPTable(new float[]{12, 28, 10, 40});
inspectorTable.setWidthPercentage(100);
inspectorTable.setTotalWidth(PageSize.A4.getWidth() - 80);
document.writeNoBorderCell("检验人员:", Element.ALIGN_LEFT, 1, 1, inspectorTable);
document.writeNoBorderCell("", Element.ALIGN_LEFT, 1, 1, inspectorTable);
document.writeNoBorderCell(inspectionPersonnel.getInspectionPersonnel(), Element.ALIGN_LEFT, 1, 1, inspectorTable);
document.writeNoBorderCell("检验日期:", Element.ALIGN_LEFT, 1, 1, inspectorTable);
document.writeNoBorderCell("", Element.ALIGN_LEFT, 1, 1, inspectorTable);
document.writeNoBorderCell(inspectionPersonnel.getInspectionDate(), Element.ALIGN_LEFT, 1, 1, inspectorTable);
document.writeBottomCell("检验负责人:", Element.ALIGN_LEFT, 1, 1, inspectorTable);
document.writeBottomCell("", Element.ALIGN_LEFT, 1, 1, inspectorTable);
document.writeBottomCell(inspectionPersonnel.getPrincipal(), Element.ALIGN_LEFT, 1, 1, inspectorTable);
document.writeBottomCell("检验地点:", Element.ALIGN_LEFT, 1, 1, inspectorTable);
document.writeBottomCell("口中汽研软件测评有限公司 口其他:", Element.ALIGN_LEFT, 1, 1, inspectorTable);
inspectorTable.writeSelectedRows(0, -1, document.left(), document.bottom() + 60, writer.getDirectContent());
document.writeBottomCell("口" + reportData.getInspectionCenterAddress() + " 口其他:", Element.ALIGN_LEFT, 1, 1, inspectorTable);
inspectorTable.writeSelectedRows(0, -1, document.left(), document.bottom() + 80, writer.getDirectContent());
// 开启下一页
document.newPage();
}
......@@ -474,8 +473,9 @@ public class PdfTemplateManagementServiceImpl implements PdfTemplateManagementSe
* @param document
* @param recordsList
* @param reportData
* @param inspectionPersonnel
*/
private void testResultSection(PdfBaseWriter document, List<TestRecords> recordsList, InspectionReportPdfVO reportData) {
private void testResultSection(PdfBaseWriter document, List<TestRecords> recordsList, InspectionReportPdfVO reportData, InspectionPersonnelVO inspectionPersonnel) {
document.setParagraph("4.检验结果", 10f, Element.ALIGN_LEFT, 0,10f, 0f);
// 获取数据 - 渲染
if (CollUtil.isNotEmpty(recordsList)) {
......@@ -486,13 +486,13 @@ public class PdfTemplateManagementServiceImpl implements PdfTemplateManagementSe
PdfPTable useCaseTable = new PdfPTable(new float[]{15, 35, 15, 35});
useCaseTable.setWidthPercentage(100);
document.writeCell("测试编号", Element.ALIGN_LEFT, 1, 1, useCaseTable);
document.writeCell("xxxxxxx", Element.ALIGN_LEFT, 1, 1, useCaseTable);
document.writeCell(record.getUsecaseNo(), Element.ALIGN_LEFT, 1, 1, useCaseTable);
document.writeCell("测试时间", Element.ALIGN_LEFT, 1, 1, useCaseTable);
document.writeCell(String.valueOf(record.getTestTime()), Element.ALIGN_LEFT, 1, 1, useCaseTable);
document.writeCell("样品编号", Element.ALIGN_LEFT, 1, 1, useCaseTable);
document.writeCell(reportData.getSampleNumberSummary(), Element.ALIGN_LEFT, 1, 1, useCaseTable);
document.writeCell("测试人员", Element.ALIGN_LEFT, 1, 1, useCaseTable);
document.writeCell("", Element.ALIGN_LEFT, 1, 1, useCaseTable);
document.writeCell(inspectionPersonnel.getInspectionPersonnel(), Element.ALIGN_LEFT, 1, 1, useCaseTable);
document.writeCell("简述", Element.ALIGN_LEFT, 1, 1, useCaseTable);
document.writeCell(record.getDescription(), Element.ALIGN_LEFT, 3, 1, useCaseTable);
document.writeCell("风险等级", Element.ALIGN_LEFT, 1, 1, useCaseTable);
......@@ -670,30 +670,6 @@ public class PdfTemplateManagementServiceImpl implements PdfTemplateManagementSe
}
/**
*
* @param markdownContent
* @return
*/
public static String convertMarkdownToHtml(String markdownContent) {
// 创建 Markdown 解析器
Parser parser = Parser.builder().build();
// 解析 Markdown
Node document = parser.parse(markdownContent);
// 创建 HTML 渲染器
HtmlRenderer renderer = HtmlRenderer.builder().build();
// 渲染 HTML
org.jsoup.nodes.Document doc = Jsoup.parse(renderer.render(document).replaceAll("\\\\n", "<br>"));
// jsoup标准化标签,生成闭合标签
doc.outputSettings().syntax(org.jsoup.nodes.Document.OutputSettings.Syntax.xml);
doc.outputSettings().escapeMode(Entities.EscapeMode.xhtml);
return doc.html();
}
private static String headerText;
public static class MyHeaderFooter extends PdfPageEventHelper {
......@@ -792,10 +768,77 @@ public class PdfTemplateManagementServiceImpl implements PdfTemplateManagementSe
+ inspectionReport.getTaskBeginTime() + "至"
+ inspectionReport.getTaskEndTime() + "在"
+ inspectionReport.getInspectionCenterName() + "进行");
inspectionReport.setInspectionItem(getInspectionItemByTaskItem(inspectionReport.getInspectionItem()));
String taskItem = getInspectionItemByTaskItem(inspectionReport.getInspectionItem());
inspectionReport.setInspectionItem(taskItem);
// 检验结论
inspectionReport.setTestConclusion(getTestConclusion(taskItem, taskId, inspectionReport));
return inspectionReport;
}
/**
* 获取检验结论
* @return
*/
private String getTestConclusion(String taskItem, Long taskId, InspectionReportPdfVO inspectionReport) {
int num = 0;
String result = "";
String issueDate = "";
String passItemName = "";
String failItemName = "";
List<String> taskItemList = Arrays.asList(taskItem.split(","));
List<InspectionItemVO> list = new ArrayList<>();
TestConclusionVO testConclusionVO = taskMapper.selectTestConclusion(taskId);
if (ObjectUtil.isNotEmpty(testConclusionVO.getSystemReviewTaskResult())) {
list.add(InspectionItemVO.builder()
.inspectionItemName(taskItemList.get(num))
.taskResult(testConclusionVO.getSystemReviewTaskResult()).build());
issueDate = testConclusionVO.getSystemReviewTaskDate();
num++;
}
if (ObjectUtil.isNotEmpty(testConclusionVO.getCarReviewTaskResult())) {
list.add(InspectionItemVO.builder()
.inspectionItemName(taskItemList.get(num))
.taskResult(testConclusionVO.getCarReviewTaskResult()).build());
issueDate = testConclusionVO.getCarReviewTaskDate();
num++;
}
if (ObjectUtil.isNotEmpty(testConclusionVO.getModelTestTaskResult())) {
list.add(InspectionItemVO.builder()
.inspectionItemName(taskItemList.get(num))
.taskResult(testConclusionVO.getModelTestTaskResult()).build());
issueDate = testConclusionVO.getModelTestTaskDate();
}
inspectionReport.setIssueDate(issueDate);
for (InspectionItemVO item : list) {
if (item.getTaskResult().equals(ModelTestTask.TASK_STATUS_PASS)) {
passItemName += item.getInspectionItemName() + "、";
}
if (item.getTaskResult().equals(ModelTestTask.TASK_STATUS_REJECT)) {
failItemName += item.getInspectionItemName() + "、";
}
}
if (StrUtil.isNotEmpty(passItemName)) {
passItemName = passItemName.substring(0, passItemName.length() - 1);
result = "经检验,该样品的"
+ passItemName
+ "检验项目的检验结果符合"
+ inspectionReport.getInspectionBasis()
+ "的要求,";
}
if (StrUtil.isNotEmpty(failItemName)) {
failItemName = failItemName.substring(0, failItemName.length() - 1);
result += "该样品的"
+ failItemName
+ "检验项目的检验结果不符合"
+ inspectionReport.getInspectionBasis()
+ "的要求。";
}
if (result.endsWith(",")) {
result = result.substring(0, result.length() - 1) + "。";
}
return " " + result;
}
/**
* 渲染数据
* @param fields
......
......@@ -63,22 +63,26 @@ public class StrategyModelTestTaskPending implements StrategyModelTestTask, Init
JSONObject jsonObject = testUseCaseService.callThirdPartyInterface(url, map);
Integer sumCount = (Integer) jsonObject.get("case_count");
AtomicReference<Integer> currentCount = new AtomicReference<>(0);
AtomicReference<Integer> failedCount = new AtomicReference<>(0);
List<CaseStatistics> caseStatisticsList = jsonObject.getList("case_statistics", CaseStatistics.class);
if (CollUtil.isNotEmpty(caseStatisticsList)) {
caseStatisticsList.forEach(obj -> {
if (CaseStatistics.CASE_STATUS_FAILED.equals(obj.status) || CaseStatistics.CASE_STATUS_PASSED.equals(obj.status)) {
currentCount.updateAndGet(v -> v + obj.getCount());
}
if (CaseStatistics.CASE_STATUS_FAILED.equals(obj.status)) {
failedCount.updateAndGet(v -> v + obj.getCount());
}
});
}
Integer integer = currentCount.get();
System.out.println(integer);
// 进行中的任务, 点击返回后, 判断当前用例完成程度, 用例都完成后状态改为待签字
if (sumCount.equals(currentCount.get())) {
modelTestTaskMapper.update(new ModelTestTask(),
new LambdaUpdateWrapper<ModelTestTask>()
.set(ModelTestTask::getTaskEndTime, new Date())
.set(ModelTestTask::getTaskStatus, ModelTestTask.TASK_STATUS_SIGNED)
.set(failedCount.get() > 0, ModelTestTask::getTaskResult, ModelTestTask.TASK_STATUS_REJECT)
.set(failedCount.get().equals(0), ModelTestTask::getTaskResult, ModelTestTask.TASK_STATUS_PASS)
.eq(ModelTestTask::getId, modelTestTask.getId()));
}
}
......
......@@ -2,6 +2,7 @@ package com.ruoyi.service.impl;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.http.HttpUtil;
import com.alibaba.fastjson2.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
......@@ -112,6 +113,10 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task>implements Tas
return taskMapper.findList(request);
}
/**
* 创建任务
* @param request
*/
@Override
public void createTask(TaskCreateRequest request) {
......@@ -147,9 +152,8 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task>implements Tas
}
}
Long sum = taskMapper.findTaskName(request.getTaskName());
// TODO 任务名称验重
// Long sum = taskMapper.findTaskName(request.getTaskName());
// if (sum > 0) {
// throw new ServiceException("任务名称重复,请检查", HttpStatus.ERROR);
// } else {
......@@ -200,9 +204,6 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task>implements Tas
taskService.save(task);
// 总任务包含车型试验,添加任务-场景关联信息
saveTaskScenario(task.getId(), request.getTestScenarioList());
// 构建并保存该任务所关联的审核组信息
saveUserRelation(auditors,task);
......@@ -219,6 +220,12 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task>implements Tas
// }
}
/**
* 查询用户待办任务
* @param request
* @param userId
* @return
*/
@Override
public List<TaskFindResponse> findPending(TaskFindPendingRequest request,Long userId) {
List<TaskFindResponse> responses = taskMapper.findPending(request,userId);
......@@ -236,17 +243,10 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task>implements Tas
List<CarReviewTask> carReviewTaskList = carReviewTaskMapper.findByTaskList(responses);
setCarProgress(carReviewTaskList,responses);
// 车型试验子任务列表
// List<ModelTestTask> modelTestTaskList = modelTestTaskMapper.findByTaskList(responses);
// setModelProgress(modelTestTaskList,responses);
// 设置车型试验进度
setModelSchedule(responses);
// 任务是否有选择场景
// List<TaskScenarioResponse> scenarioResponseList = taskMapper.findByTaskList(responses);
// setTaskScenario(scenarioResponseList,responses);
// 显示下一任务节点
for (TaskFindResponse response : responses) {
String[] taskList = response.getTaskList().split(",");
if (response.getPointer() < taskList.length) {
......@@ -261,6 +261,11 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task>implements Tas
return responses;
}
/**
* 已归档任务
* @param request
* @return
*/
@Override
public List<Task> findFinish(TaskFindFinishRequest request) {
......@@ -276,12 +281,15 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task>implements Tas
return taskList;
}
/**
* 编辑任务
* @param request
*/
@Override
public void editTask(TaskEditRequest request) {
Task oldTask = taskMapper.findByName(request.getTaskName());
// TODO 任务名称验重
// Task oldTask = taskMapper.findByName(request.getTaskName());
// if (oldTask == null || Objects.equals(oldTask.getId(), request.getId())) {
// 构建任务创建者
LoginUser loginUser = SecurityUtils.getLoginUser();
......@@ -306,7 +314,7 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task>implements Tas
setTaskList(request.getTaskList(),task);
BeanUtils.copyBeanProp(task, request);
// 子任务发变化
// 子任务发变化
changeSubTask(request,task,initiator,standard,leader);
task.setMaxPointer(request.getTaskList().size());
......@@ -333,6 +341,10 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task>implements Tas
}
/**
* 删除任务
* @param request
*/
@Override
public void deleteTask(TaskDeleteRequest request) {
Task task = taskMapper.selectById(request.getId());
......@@ -366,12 +378,22 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task>implements Tas
taskMapper.deleteById(request.getId());
}
/**
* 开始任务
* @param request
*/
@Override
public void startTask(TaskStartRequest request) {
Task task = taskMapper.selectById(request.getId());
taskStateFacade.doStart(task, request);
}
/**
* 用户创建的任务
* @param request
* @param userId
* @return
*/
@Override
public List<TaskFindResponse> findCreate(TaskFindRequest request,Long userId) {
List<TaskFindResponse> responses = taskMapper.findByUserId(request,userId);
......@@ -389,12 +411,10 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task>implements Tas
List<CarReviewTask> carReviewTaskList = carReviewTaskMapper.findByTaskList(responses);
setCarProgress(carReviewTaskList,responses);
// 车型试验子任务列表
// List<ModelTestTask> modelTestTaskList = modelTestTaskMapper.findByTaskList(responses);
// setModelProgress(modelTestTaskList,responses);
// 设置车型试验进度
setModelSchedule(responses);
// 显示下一任务节点
for (TaskFindResponse response : responses) {
String[] taskList = response.getTaskList().split(",");
if (response.getPointer() < taskList.length) {
......@@ -408,6 +428,11 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task>implements Tas
return responses;
}
/**
* 获取任务详情
* @param request
* @return
*/
@Override
public TaskGetInfoResponse getInfo(TaskGetInfoRequest request) {
......@@ -422,9 +447,6 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task>implements Tas
response.setTaskList(taskList);
}
// 测试场景
response.setTestScenarioList(selectTestScenarioList(task));
// 小组成员
response.setAuditors(setAuditors(request.getId()));
......@@ -463,6 +485,12 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task>implements Tas
return list;
}
/**
* 已办任务
* @param request
* @param userId
* @return
*/
@Override
public List<Task> findUserFinish(TaskFindFinishRequest request,Long userId) {
......@@ -478,80 +506,95 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task>implements Tas
return taskList;
}
/**
* 新增暂存任务
* @param request
*/
@Override
public void temporaryStorageTask(TaskCreateRequest request) {
Long sum = taskMapper.findTaskName(request.getTaskName());
// TODO 任务名称验重
// Long sum = taskMapper.findTaskName(request.getTaskName());
// if (sum > 0) {
// throw new ServiceException("任务名称重复,请检查", HttpStatus.ERROR);
// } else {
// 构建任务创建者
LoginUser loginUser = SecurityUtils.getLoginUser();
SysUser initiator = sysUserService.selectUserById(loginUser.getUserId());
Standard standard = standardService.findListById(request.getStandardId());
// 构建并保存任务信息
// 总任务
Task task = new Task();
task.setTaskInitiatorId(loginUser.getUserId());
task.setTaskInitiator(initiator.getNickName());
if (initiator.getDept() != null) {
task.setTaskInitiatorDept(initiator.getDept().getDeptName());
}
task.setTaskStatus(Task.TASK_STATUS_TEMPORARILY);
String joinTaskList = StringUtils.join(request.getTaskList(),",");
task.setTaskList(joinTaskList);
BeanUtils.copyBeanProp(task, request);
TaskGetInfoResponse temporaryStorageTask = taskService.getByUserId(loginUser.getUserId());
if (temporaryStorageTask != null) {
TaskEditRequest editRequest = new TaskEditRequest();
BeanUtils.copyBeanProp(editRequest,request);
editRequest.setId(temporaryStorageTask.getId());
taskService.editTemporaryStorageTask(editRequest);
} else {
SysUser initiator = sysUserService.selectUserById(loginUser.getUserId());
Standard standard = standardService.findListById(request.getStandardId());
// 构建并保存任务信息
// 总任务
Task task = new Task();
task.setTaskInitiatorId(loginUser.getUserId());
task.setTaskInitiator(initiator.getNickName());
if (initiator.getDept() != null) {
task.setTaskInitiatorDept(initiator.getDept().getDeptName());
}
task.setTaskStatus(Task.TASK_STATUS_TEMPORARILY);
String joinTaskList = StringUtils.join(request.getTaskList(),",");
if (StrUtil.isNotEmpty(joinTaskList)) {
task.setTaskList(joinTaskList);
}
BeanUtils.copyBeanProp(task, request);
if (standard != null) {
task.setName(standard.getName());
task.setStandardNo(standard.getStandardNo());
task.setFile(standard.getFile());
}
if (standard != null) {
task.setName(standard.getName());
task.setStandardNo(standard.getStandardNo());
task.setFile(standard.getFile());
}
// 找到审查组长
TaskUserRelation leader = null;
List<TaskUserRelation> auditors = request.getAuditors();
if (auditors != null && auditors.size() != 0) {
for(TaskUserRelation auditor : auditors) {
if(auditor.getIsLeader() == 1) {
leader = auditor;
break;
// 找到审查组长
TaskUserRelation leader = null;
List<TaskUserRelation> auditors = request.getAuditors();
if (auditors != null && auditors.size() != 0) {
for(TaskUserRelation auditor : auditors) {
if(auditor.getIsLeader() == 1) {
leader = auditor;
break;
}
}
}
// 任务组长
task.setLeaderId(leader.getUserId());
task.setLeader(leader.getName());
}
// 任务组长
task.setLeaderId(leader.getUserId());
task.setLeader(leader.getName());
}
// 暂存
taskService.save(task);
// 暂存
taskService.save(task);
// 测试场景
saveTaskScenario(task.getId(), request.getTestScenarioList());
// 保存任务与小组信息
saveUserRelation(auditors,task);
// 保存任务与小组信息
saveUserRelation(auditors,task);
// 保存关联的整车样品信息和零部件样品信息
List<TaskSampleRelation> relations = request.getSample();
List<TaskSampleRelation> partRelations = request.getPartSample();
saveSampleRelation(relations,partRelations,task);
// 保存关联的整车样品信息和零部件样品信息
List<TaskSampleRelation> relations = request.getSample();
List<TaskSampleRelation> partRelations = request.getPartSample();
saveSampleRelation(relations,partRelations,task);
// 保存任务关联的文件信息
saveFileList(request.getFileList(),task);
}
// 保存任务关联的文件信息
saveFileList(request.getFileList(),task);
// }
}
/**
* 编辑暂存
* @param request
*/
@Override
public void editTemporaryStorageTask(TaskEditRequest request) {
Task oldTask = taskMapper.findByName(request.getTaskName());
// TODO 任务名称验重
// Task oldTask = taskMapper.findByName(request.getTaskName());
// if (oldTask == null || Objects.equals(oldTask.getId(), request.getId())) {
// 构建任务创建者
LoginUser loginUser = SecurityUtils.getLoginUser();
......@@ -562,7 +605,9 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task>implements Tas
// 总任务
Task task = new Task();
String joinTaskList = StringUtils.join(request.getTaskList(),",");
task.setTaskList(joinTaskList);
if (StrUtil.isNotEmpty(joinTaskList)) {
task.setTaskList(joinTaskList);
}
BeanUtils.copyBeanProp(task, request);
if (standard != null) {
......@@ -571,9 +616,6 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task>implements Tas
task.setFile(standard.getFile());
}
taskScenarioRelationMapper.delete(new QueryWrapper<TaskScenarioRelation>().lambda().eq(TaskScenarioRelation::getTaskId, task.getId()));
saveTaskScenario(task.getId(), request.getTestScenarioList());
// 找到审查组长
TaskUserRelation leader = null;
List<TaskUserRelation> auditors = request.getAuditors();
......@@ -609,6 +651,11 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task>implements Tas
}
/**
* 获取用户暂存任务
* @param userId
* @return
*/
@Override
public TaskGetInfoResponse getByUserId(Long userId) {
......@@ -619,13 +666,10 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task>implements Tas
BeanUtils.copyBeanProp(response, task);
if (response.getTaskList().startsWith(",")) {
String taskList = response.getTaskList().substring(1);
response.setTaskList(taskList);
}
// 测试场景
response.setTestScenarioList(selectTestScenarioList(task));
// if (response.getTaskList().startsWith(",")) {
// String taskList = response.getTaskList().substring(1);
// response.setTaskList(taskList);
// }
// 小组成员
response.setAuditors(setAuditors(task.getId()));
......@@ -647,6 +691,11 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task>implements Tas
}
/**
* 根据子任务获取总任务详情
* @param request
* @return
*/
@Override
public TaskGetInfoResponse getBySubtaskId(TaskSubGetInfoRequest request) {
TaskGetInfoResponse response = new TaskGetInfoResponse();
......@@ -670,6 +719,11 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task>implements Tas
}
/**
* 数据统计
* @param request
* @return
*/
@Override
public DataStatisticsResponse dataStatistics(TaskGetInfoRequest request) {
......@@ -1055,14 +1109,14 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task>implements Tas
BeanUtils.copyBeanProp(createRequest, request);
task.setModelTestTaskId(saveModelTest(createRequest,initiator,standard,leader));
// 任务-场景
saveTaskScenario(task.getId(), createRequest.getTestScenarioList());
// saveTaskScenario(task.getId(), createRequest.getTestScenarioList());
}
if (!request.getTaskList().contains(Task.SUB_TASK_TRFIS) && ObjectUtil.isNotNull(task.getModelTestTaskId())) {
// 删除
modelTestTaskService.removeById(task.getModelTestTaskId());
task.setModelTestTaskIdNull();
// 删除 任务-场景
taskScenarioRelationMapper.delete(new QueryWrapper<TaskScenarioRelation>().lambda().eq(TaskScenarioRelation::getTaskId, task.getId()));
// taskScenarioRelationMapper.delete(new QueryWrapper<TaskScenarioRelation>().lambda().eq(TaskScenarioRelation::getTaskId, task.getId()));
}
if (request.getTaskList().contains(Task.SUB_TASK_TRFIS) &&
!request.getTaskList().contains(Task.SUB_TASK_GRFIS) &&
......@@ -1075,8 +1129,8 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task>implements Tas
) {
TaskCreateRequest createRequest = new TaskCreateRequest();
BeanUtils.copyBeanProp(createRequest, request);
taskScenarioRelationMapper.delete(new QueryWrapper<TaskScenarioRelation>().lambda().eq(TaskScenarioRelation::getTaskId, task.getId()));
saveTaskScenario(task.getId(), createRequest.getTestScenarioList());
// taskScenarioRelationMapper.delete(new QueryWrapper<TaskScenarioRelation>().lambda().eq(TaskScenarioRelation::getTaskId, task.getId()));
// saveTaskScenario(task.getId(), createRequest.getTestScenarioList());
}
}
}
......
......@@ -18,6 +18,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.text.SimpleDateFormat;
import java.util.*;
......@@ -85,6 +86,14 @@ public class TestRecordsServiceImpl extends ServiceImpl<TestRecordsMapper, TestR
testRecords.setRiskLevel(caseResultVO.getRisk_level());
testRecords.setTestResult(caseResultVO.getStatus());
testRecords.setRemediation(caseResultVO.getRemediation());
testRecords.setUsecaseNo(caseResultVO.getSerial_number());
//测试开始时间
if (caseResultVO.getStart_time() != null) {
Date date = new Date(caseResultVO.getStart_time());
SimpleDateFormat sdf = new SimpleDateFormat("yyyy年MM月dd日");
String testTime = sdf.format(date);
testRecords.setTestTime(testTime);
}
// 用例步骤
List<StepResultVO> stepResultVOS = caseResultVO.getStep_result_list();
......@@ -107,12 +116,12 @@ public class TestRecordsServiceImpl extends ServiceImpl<TestRecordsMapper, TestR
// 测试详情
String testDetails = stepResultVO.getDescription();
if (testDetails != null) {
convertMarkdownToHtml(testDetails);
testDetails = convertMarkdownToHtml(testDetails);
}
testDetailsVO += testDetails + "`";
testDetailsVO += testDetails + "<br> ";
}
testDetailsVO = testDetailsVO.substring(0, testDetailsVO.length() - 1);
testRecords.setTestMethod(StringUtils.join(stepList,"`"));
testRecords.setTestMethod(StringUtils.join(stepList,"\n"));
testRecords.setTestDetails(testDetailsVO);
}
......@@ -163,6 +172,14 @@ public class TestRecordsServiceImpl extends ServiceImpl<TestRecordsMapper, TestR
testRecords.setRiskLevel(caseResultVO.getRisk_level());
testRecords.setTestResult(caseResultVO.getStatus());
testRecords.setRemediation(caseResultVO.getRemediation());
testRecords.setUsecaseNo(caseResultVO.getSerial_number());
//测试开始时间
if (caseResultVO.getStart_time() != null) {
Date date = new Date(caseResultVO.getStart_time());
SimpleDateFormat sdf = new SimpleDateFormat("yyyy年MM月dd日");
String testTime = sdf.format(date);
testRecords.setTestTime(testTime);
}
// 用例步骤
List<StepResultVO> stepResultVOS = caseResultVO.getStep_result_list();
......@@ -185,7 +202,7 @@ public class TestRecordsServiceImpl extends ServiceImpl<TestRecordsMapper, TestR
// 测试详情
String testDetails = stepResultVO.getDescription();
if (testDetails != null) {
convertMarkdownToHtml(testDetails);
testDetails = convertMarkdownToHtml(testDetails);
}
testDetailsVO += testDetails + "`";
}
......@@ -220,7 +237,7 @@ public class TestRecordsServiceImpl extends ServiceImpl<TestRecordsMapper, TestR
// jsoup标准化标签,生成闭合标签
doc.outputSettings().syntax(org.jsoup.nodes.Document.OutputSettings.Syntax.xml);
doc.outputSettings().escapeMode(Entities.EscapeMode.xhtml);
return doc.html();
return doc.body().html();
}
@Override
......
......@@ -390,5 +390,38 @@
</foreach>
</select>
<select id="selectTestConclusion" parameterType="java.lang.Long" resultType="com.ruoyi.domain.vo.TestConclusionVO">
select
srt.task_result AS systemReviewTaskResult,
DATE_FORMAT(srt.task_end_time, '%Y-%m-%d') AS systemReviewTaskDate,
crt.task_result AS carReviewTaskResult,
DATE_FORMAT(crt.task_end_time, '%Y-%m-%d') AS carReviewTaskDate,
mtt.task_result AS modelTestTaskResult,
DATE_FORMAT(mtt.task_end_time, '%Y-%m-%d') AS modelTestTaskDate
from
t_task t
left join t_system_review_task srt on t.system_review_task_id = srt.id
left join t_car_review_task crt on t.car_review_task_id = crt.id
left join t_model_test_task mtt on t.model_test_task_id = mtt.id
where
t.id = #{taskId}
</select>
<select id="selectInspectionPersonnelById" parameterType="java.lang.Long" resultType="com.ruoyi.domain.vo.InspectionPersonnelVO">
select
su.nick_name AS principal,
GROUP_CONCAT(distinct u.nick_name) AS inspectionPersonnel,
DATE_FORMAT(mtt.task_begin_time, '%Y-%m-%d') AS inspectionDate
from
t_task t
left join t_task_user_relation tur on t.id = tur.task_id
left join sys_user u on tur.user_id = u.user_id
left join sys_user su on t.leader_id = su.user_id
left join t_model_test_task mtt on t.model_test_task_id = mtt.id
where
t.id = #{taskId}
group by t.id
</select>
</mapper>
......@@ -9,8 +9,9 @@
<result property="projectId" column="project_id" jdbcType="VARCHAR"/>
<result property="taskId" column="task_id" jdbcType="BIGINT"/>
<result property="usecase" column="usecase" jdbcType="VARCHAR"/>
<result property="usecaseNo" column="usecase_no" jdbcType="VARCHAR"/>
<result property="usecaseId" column="usecase_id" jdbcType="VARCHAR"/>
<result property="testTime" column="test_time" jdbcType="TIMESTAMP"/>
<result property="testTime" column="test_time" jdbcType="VARCHAR"/>
<result property="description" column="description" jdbcType="LONGNVARCHAR"/>
<result property="riskLevel" column="risk_level" jdbcType="VARCHAR"/>
<result property="testMethod" column="test_method" jdbcType="LONGNVARCHAR"/>
......@@ -19,7 +20,7 @@
<result property="testDetails" column="test_details" jdbcType="LONGNVARCHAR"/>
</resultMap>
<select id="findByTaskId" resultType="com.ruoyi.domain.TestRecords">
SELECT id, project_id, task_id, usecase, usecase_id, test_time, description, risk_level, test_method, test_result, remediation, test_details
SELECT id, project_id, task_id, usecase, usecase_no, usecase_id, test_time, description, risk_level, test_method, test_result, remediation, test_details
FROM t_test_records
WHERE project_id = #{id}
</select>
......@@ -39,7 +40,8 @@
tr.test_method,
tr.test_result,
tr.remediation,
tr.test_details
tr.test_details,
tr.usecase_no
from
t_test_records tr
left join t_task t on tr.task_id = t.model_test_task_id
......
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