Commit b3de2e52 authored by 高滢's avatar 高滢
parents 1c29b7c4 508c8ae5
......@@ -7,6 +7,7 @@ import com.ruoyi.mapper.TaskMapper;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Objects;
public class DataStatisticsUtils {
......@@ -31,7 +32,7 @@ public class DataStatisticsUtils {
isPass = false;
}
if(passed == ReviewStandard.NO_PASSED) {
if(Objects.equals(passed, ReviewStandard.NO_PASSED)) {
isPass = false;
}
......@@ -62,7 +63,7 @@ public class DataStatisticsUtils {
isPass = false;
}
if(passed == ReviewStandard.NO_PASSED) {
if(Objects.equals(passed, ReviewStandard.NO_PASSED)) {
isPass = true;
}
......@@ -106,7 +107,7 @@ public class DataStatisticsUtils {
continue;
}
if(detailsIsPass(reviewDetails, resultMap) == ReviewStandard.PASSED) {
if(Objects.equals(detailsIsPass(reviewDetails, resultMap), ReviewStandard.PASSED)) {
detailsPass = detailsPass + 1;
}
}
......@@ -124,7 +125,7 @@ public class DataStatisticsUtils {
List<ReviewDetails> details = getDetailsByStandard(standard);
for(ReviewDetails reviewDetails : details) {
if(detailsIsPass(reviewDetails, resultMap) == ReviewStandard.NO_PASSED) {
if(Objects.equals(detailsIsPass(reviewDetails, resultMap), ReviewStandard.NO_PASSED)) {
detailsNoPass = detailsNoPass + 1;
}
}
......
......@@ -21,7 +21,11 @@ public class TestRecords {
private Long id;
@ApiModelProperty("关联项目id")
private String taskId;
private String projectId;
@ApiModelProperty("关联任务id")
@JsonFormat(shape = JsonFormat.Shape.STRING)
private Long taskId;
@ApiModelProperty("用例名称")
private String usecase;
......
......@@ -160,4 +160,9 @@ public class InspectionReportPdfVO {
*/
private String sampleNumberSummary;
/**
* 品牌图片
*/
private String brandImage;
}
......@@ -30,7 +30,7 @@ public class ScheduledTask implements Runnable{
for (ModelTestTask testTask : modelList) {
if (testTask.getTestSchemeId() != null) {
testRecordsService.sendPost(testTask.getTestSchemeId());
testRecordsService.sendPost(testTask.getTestSchemeId(),testTask.getId());
}
}
......
......@@ -18,5 +18,12 @@ public interface TestRecordsService extends IService<TestRecords> {
* 发送请求
* @param id
*/
void sendPost(String id);
void sendPost(String id,Long taskId);
/**
* 单个任务发送请求
* @param id
* @param taskId
*/
void singleSendPost(String id,Long taskId);
}
package com.ruoyi.service.impl;
import cn.hutool.core.util.StrUtil;
import com.itextpdf.text.*;
import com.itextpdf.text.pdf.*;
import com.ruoyi.common.core.domain.entity.SysDictData;
......@@ -89,7 +90,7 @@ public class PdfTemplateManagementServiceImpl implements PdfTemplateManagementSe
InspectionReportPdfVO inspectionReportPdfVO = requireData(taskId);
// 渲染数据
renderData(fields, inspectionReportPdfVO);
renderData(fields, inspectionReportPdfVO, ps);
//必须要调用这个,否则文档不会生成的
ps.setFormFlattening(true);
......@@ -106,7 +107,12 @@ public class PdfTemplateManagementServiceImpl implements PdfTemplateManagementSe
}
}
assert bos != null;
return uploadMinio(bos, "检验报告_" + taskId);
// 名字
return uploadMinio(bos, "整车信息安全检验报告-" + getReportName());
}
private String getReportName() {
return DateUtils.parseDateToStr("yyyyMMddHHmm", new Date());
}
/**
......@@ -252,8 +258,9 @@ public class PdfTemplateManagementServiceImpl implements PdfTemplateManagementSe
* 渲染数据
* @param fields
*/
private void renderData(AcroFields fields, InspectionReportPdfVO inspectionReportPdfVO) throws Exception {
private void renderData(AcroFields fields, InspectionReportPdfVO inspectionReportPdfVO, PdfStamper ps) throws Exception {
// 取出当前对象所有属性,并赋值到模板里
// 文本域
Class<? extends InspectionReportPdfVO> aClass = inspectionReportPdfVO.getClass();
Field[] declaredFields = aClass.getDeclaredFields();
for (Field field : declaredFields) {
......@@ -266,6 +273,15 @@ public class PdfTemplateManagementServiceImpl implements PdfTemplateManagementSe
fields.setField(key, value);
}
}
// 图片域
// 样品
String url = inspectionReportPdfVO.getBrandImage();
if (StrUtil.isNotBlank(url)) {
if (url.startsWith(",")) {
url = inspectionReportPdfVO.getBrandImage().substring(1);
}
addImageToPdf("brand", fields, ps, "http://49.232.167.247:22038" + url.split(",")[0]);
}
}
......@@ -314,7 +330,7 @@ public class PdfTemplateManagementServiceImpl implements PdfTemplateManagementSe
// 获取操作的页面
PdfContentByte under = stamper.getOverContent(pageNo);
// 根据域的大小缩放图片
image.scaleToFit(signRect.getWidth() * 2, signRect.getHeight());
image.scaleToFit(signRect.getWidth(), signRect.getHeight());
// 添加图片并设置位置(个人通过此设置使得图片垂直水平居中,可参考,具体情况已实际为准)
image.setAbsolutePosition(x, y);
under.addImage(image);
......
......@@ -24,6 +24,7 @@ import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Objects;
/**
* @author wangfei
......@@ -83,6 +84,18 @@ public class ReviewEnterpriseArchiveServiceImpl extends ServiceImpl<ReviewEnterp
throw new ServiceException("新增文件名称重复,请检查", HttpStatus.ERROR);
} else {
reviewEnterpriseArchiveService.save(reviewEnterpriseArchive);
ReviewEnterpriseArchiveFindByTaskIdRequest request = new ReviewEnterpriseArchiveFindByTaskIdRequest();
request.setTaskId(reviewEnterpriseArchive.getTaskId());
List<ReviewEnterpriseArchive> list = reviewEnterpriseArchiveMapper.findEnterpriseArchiveByTaskId(request);
if (list != null && list.size() != 0) {
for (ReviewEnterpriseArchive archive : list) {
if (!Objects.equals(archive.getEnterpriseName(), reviewEnterpriseArchive.getEnterpriseName())) {
archive.setEnterpriseName(reviewEnterpriseArchive.getEnterpriseName());
}
}
reviewEnterpriseArchiveService.updateBatchById(list);
}
}
return reviewEnterpriseArchive.getId();
......
......@@ -28,9 +28,13 @@ public class StrategyModelTestTaskPending implements StrategyModelTestTask, Init
@Autowired
private ModelTestTaskMapper modelTestTaskMapper;
@Autowired
private StrategyModelTestTaskNew strategyModelTestTaskNew;
@Override
public List<ModelTestTaskViewResponse> doView(ModelTestTask modelTestTask) {
throw new ServiceException("能查看一个进行中的任务", HttpStatus.ERROR);
List<ModelTestTaskViewResponse> list = strategyModelTestTaskNew.getTestScheme(modelTestTask.getId());
return list;
}
@Override
......
......@@ -28,7 +28,7 @@ public class TestRecordsServiceImpl extends ServiceImpl<TestRecordsMapper, TestR
@Override
public void sendPost(String id) {
public void sendPost(String id,Long taskId) {
Map<String, Object> map = new HashMap<>();
map.put("id", id);
......@@ -49,12 +49,12 @@ public class TestRecordsServiceImpl extends ServiceImpl<TestRecordsMapper, TestR
List<TestRecords> recordsList = testRecordsService.findByTaskId(id);
List<TestRecords> list = new ArrayList<>();
if (caseResultVOS.size() != 0 && caseResultVOS != null) {
if (caseResultVOS != null && caseResultVOS.size() != 0) {
for (CaseResultVO caseResultVO : caseResultVOS) {
// 检查 usecaseId 是否在 recordsList 中存在
boolean exists = false;
if (recordsList.size() != 0 && recordsList != null) {
if (recordsList != null && recordsList.size() != 0) {
for (TestRecords records : recordsList) {
if (Objects.equals(caseResultVO.getId(), records.getUsecaseId())) {
......@@ -66,7 +66,8 @@ public class TestRecordsServiceImpl extends ServiceImpl<TestRecordsMapper, TestR
if ((Objects.equals(caseResultVO.getStatus(), "PASSED") || Objects.equals(caseResultVO.getStatus(), "FAILED")) && !exists) {
TestRecords testRecords = new TestRecords();
testRecords.setTaskId(projectId);
testRecords.setProjectId(projectId);
testRecords.setTaskId(taskId);
testRecords.setUsecase(caseResultVO.getName());
testRecords.setUsecaseId(caseResultVO.getId());
testRecords.setDescription(caseResultVO.getDescription());
......@@ -77,7 +78,68 @@ public class TestRecordsServiceImpl extends ServiceImpl<TestRecordsMapper, TestR
// 用例步骤
List<StepResultVO> stepResultVOS = caseResultVO.getStep_result_list();
if (stepResultVOS.size() != 0 && stepResultVOS != null) {
if (stepResultVOS != null && stepResultVOS.size() != 0) {
List<String> stepList = new ArrayList<>();
for (StepResultVO stepResultVO :stepResultVOS) {
String stepName = stepResultVO.getName();
stepList.add(stepName);
}
testRecords.setTestMethod(StringUtils.join(stepList,","));
}
list.add(testRecords);
}
}
testRecordsService.saveBatch(list);
}
}
@Override
public void singleSendPost(String id, Long taskId) {
Map<String, Object> map = new HashMap<>();
map.put("id", id);
map.put("verbose", "ALL");
//以post形式请求接口
String result= HttpUtil.post("https://10.12.48.78:8090/DescribeProjectTestResult",JSONObject.toJSONString(map));
JSONObject jsonObject = JSONObject.parseObject(result);
// 获取项目id
String projectId = (String) jsonObject.get("id");
// 获取项目用例结果列表
List<CaseResultVO> caseResultVOS = jsonObject.getList("case_result_list", CaseResultVO.class);
// 获取当前任务本地存储的列表
List<TestRecords> recordsList = testRecordsService.findByTaskId(id);
if (recordsList != null && recordsList.size() != 0) {
testRecordsService.removeBatchByIds(recordsList);
}
List<TestRecords> list = new ArrayList<>();
if (caseResultVOS != null && caseResultVOS.size() != 0) {
for (CaseResultVO caseResultVO : caseResultVOS) {
if (Objects.equals(caseResultVO.getStatus(), "PASSED") || Objects.equals(caseResultVO.getStatus(), "FAILED")) {
TestRecords testRecords = new TestRecords();
testRecords.setProjectId(projectId);
testRecords.setTaskId(taskId);
testRecords.setUsecase(caseResultVO.getName());
testRecords.setUsecaseId(caseResultVO.getId());
testRecords.setDescription(caseResultVO.getDescription());
testRecords.setRiskLevel(caseResultVO.getRisk_level());
testRecords.setTestResult(caseResultVO.getStatus());
testRecords.setRemediation(caseResultVO.getRemediation());
// 用例步骤
List<StepResultVO> stepResultVOS = caseResultVO.getStep_result_list();
if (stepResultVOS != null && stepResultVOS.size() != 0) {
List<String> stepList = new ArrayList<>();
for (StepResultVO stepResultVO :stepResultVOS) {
String stepName = stepResultVO.getName();
......
......@@ -311,14 +311,15 @@
GROUP_CONCAT(distinct s.sample_sender) AS sampleSender,
GROUP_CONCAT(distinct DATE_FORMAT(s.delivery_date, '%Y-%m-%d')) AS sampleDeliveryDate,
count(s.id) AS sampleQuantity,
sum(s.number_of_samples) AS sampleSum,
CONVERT(sum(s.number_of_samples), UNSIGNED) AS sampleSum,
GROUP_CONCAT(distinct DATE_FORMAT(s.manufacture_date, '%Y-%m-%d')) AS sampleDeliveryDate,
t.product_model AS vehicleType,
t.product_model AS vehicleModel,
t.id AS taskNumber,
GROUP_CONCAT(distinct s.sample_number) AS sampleNumberSummary,
GROUP_CONCAT(distinct s.identification_code) AS vehicleIdentificationNumber,
t.task_list AS inspectionItem,
DATE_FORMAT(t.create_time, '%Y-%m-%d') AS productionDate
DATE_FORMAT(t.create_time, '%Y-%m-%d') AS productionDate,
GROUP_CONCAT(distinct s.trademark) AS brandImage
from
t_task t
left join t_task_sample_relation tsr on t.id = tsr.task_id
......
......@@ -6,7 +6,8 @@
<resultMap id="BaseResultMap" type="com.ruoyi.domain.TestRecords">
<id property="id" column="id" jdbcType="BIGINT"/>
<result property="taskId" column="task_id" jdbcType="VARCHAR"/>
<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="usecaseId" column="usecase_id" jdbcType="VARCHAR"/>
<result property="testTime" column="test_time" jdbcType="TIMESTAMP"/>
......@@ -17,9 +18,9 @@
<result property="remediation" column="remediation" jdbcType="VARCHAR"/>
</resultMap>
<select id="findByTaskId" resultType="com.ruoyi.domain.TestRecords">
SELECT id, task_id, usecase, usecase_id, test_time, description, risk_level, test_method, test_result, remediation
SELECT id, project_id, task_id, usecase, usecase_id, test_time, description, risk_level, test_method, test_result, remediation
FROM t_test_records
WHERE task_id = #{id}
WHERE project_id = #{id}
</select>
......
......@@ -63,7 +63,7 @@ public class TestRecordsTest {
if ((Objects.equals(caseResultVO.getStatus(), "PASSED") || Objects.equals(caseResultVO.getStatus(), "FAILED")) && !exists) {
TestRecords testRecords = new TestRecords();
testRecords.setTaskId(projectId);
testRecords.setProjectId(projectId);
testRecords.setUsecase(caseResultVO.getName());
testRecords.setUsecaseId(caseResultVO.getId());
testRecords.setDescription(caseResultVO.getDescription());
......
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