Commit 79bcfb8d authored by 高滢's avatar 高滢
parents 6284ea32 6db5389f
package com.ruoyi.common;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.domain.*;
import com.ruoyi.mapper.TaskMapper;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
public class DataStatisticsUtils {
public static int calculateStandards(List<ReviewStandard> standards) {
return standards.size();
}
public static int calculateStandardsPass(List<ReviewStandard> standards, Map<Long, ReviewDetailsResult> resultMap) {
int standardsPass = 0;
for(ReviewStandard standard : standards) {
List<ReviewDetails> details = getDetailsByStandard(standard);
boolean isPass = true;
for(ReviewDetails reviewDetails : details) {
Integer passed = detailsIsPass(reviewDetails, resultMap);
if(passed == null) {
isPass = false;
}
if(passed == ReviewStandard.NO_PASSED) {
isPass = false;
}
}
if(isPass) {
standardsPass = standardsPass + 1;
}
}
return standardsPass;
}
public static int calculateStandardsNoPass(List<ReviewStandard> standards, Map<Long, ReviewDetailsResult> resultMap) {
int standardsNoPass = 0;
for(ReviewStandard standard : standards) {
List<ReviewDetails> details = getDetailsByStandard(standard);
boolean isPass = true;
for(ReviewDetails reviewDetails : details) {
Integer passed = detailsIsPass(reviewDetails, resultMap);
if(passed == null) {
isPass = false;
}
if(passed == ReviewStandard.PASSED) {
isPass = false;
}
}
if(isPass) {
standardsNoPass = standardsNoPass + 1;
}
}
return standardsNoPass;
}
public static int calculateDetails(List<ReviewStandard> standards) {
//审查细则(条)
int detailsNum = 0;
for(ReviewStandard standard : standards) {
List<ReviewDetails> details = getDetailsByStandard(standard);
detailsNum = detailsNum + details.size();
}
return detailsNum;
}
public static int calculateDetailsPass(List<ReviewStandard> standards, Map<Long, ReviewDetailsResult> resultMap) {
int detailsPass = 0;
for(ReviewStandard standard : standards) {
List<ReviewDetails> details = getDetailsByStandard(standard);
for(ReviewDetails reviewDetails : details) {
if (detailsIsPass(reviewDetails, resultMap) == null) {
continue;
}
if(detailsIsPass(reviewDetails, resultMap) == ReviewStandard.PASSED) {
detailsPass = detailsPass + 1;
}
}
}
return detailsPass;
}
public static int calculateDetailsNoPass(List<ReviewStandard> standards, Map<Long, ReviewDetailsResult> resultMap) {
int detailsNoPass = 0;
for(ReviewStandard standard : standards) {
List<ReviewDetails> details = getDetailsByStandard(standard);
for(ReviewDetails reviewDetails : details) {
if(detailsIsPass(reviewDetails, resultMap) == ReviewStandard.NO_PASSED) {
detailsNoPass = detailsNoPass + 1;
}
}
}
return detailsNoPass;
}
public static List<ReviewDetails> getDetailsByStandard(ReviewStandard standard) {
List<ReviewDetails> details = new ArrayList();
List<ReviewKeyPoint> keyPointList = standard.getKeyPointList();
for(ReviewKeyPoint keyPoint : keyPointList) {
details.addAll(keyPoint.getReviewDetailsList());
}
return details;
}
public static Integer detailsIsPass(ReviewDetails reviewDetails, Map<Long, ReviewDetailsResult> resultMap) {
ReviewDetailsResult result = resultMap.get(reviewDetails.getId());
if(result == null) {
return null;
}
return result.getPassed();
}
}
......@@ -3,6 +3,7 @@ package com.ruoyi.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.ruoyi.domain.Task;
import com.ruoyi.web.request.*;
import com.ruoyi.web.response.DataStatisticsResponse;
import com.ruoyi.web.response.TaskFindResponse;
import com.ruoyi.web.response.TaskGetInfoResponse;
......@@ -17,7 +18,7 @@ public interface TaskService extends IService<Task> {
*/
List<Task> findList(TaskListRequest request);
void createTask(TaskCreateRequest request);
void createTask(TaskCreateRequest request,Long userId);
/**
* 查询进行中的任务
......@@ -57,7 +58,11 @@ public interface TaskService extends IService<Task> {
void temporaryStorageTask(TaskCreateRequest request);
void editTemporaryStorageTask(TaskEditRequest request);
TaskGetInfoResponse getByUserId(Long userId);
TaskGetInfoResponse getBySubtaskId(TaskSubGetInfoRequest request);
DataStatisticsResponse dataStatistics(TaskGetInfoRequest request);
}
package com.ruoyi.service.impl;
import com.baomidou.mybatisplus.annotation.TableField;
import com.ruoyi.common.DataStatisticsUtils;
import com.ruoyi.common.constant.HttpStatus;
import com.ruoyi.common.core.domain.entity.SysUser;
import com.ruoyi.common.exception.ServiceException;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.domain.*;
import com.ruoyi.mapper.*;
import com.ruoyi.service.*;
import com.ruoyi.web.response.CarReviewTaskViewResponse;
import io.swagger.annotations.ApiModelProperty;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
......@@ -21,6 +18,8 @@ import java.util.*;
import java.util.function.Function;
import java.util.stream.Collectors;
import static com.ruoyi.common.DataStatisticsUtils.calculateStandardsPass;
@Transactional
@Service
public class StrategyCarReviewTaskPending implements StrategyCarReviewTask, InitializingBean {
......@@ -190,98 +189,16 @@ public class StrategyCarReviewTaskPending implements StrategyCarReviewTask, Init
List<TaskUserRelation> relationList = taskUserRelationMapper.selectQTeamMembers(taskMapper.findByCarReviewTaskId(carReviewTask.getId()));
carReviewTask.setStandards(calculateStandards(standards));
carReviewTask.setStandards(DataStatisticsUtils.calculateStandards(standards));
BigDecimal standardPass = new BigDecimal(calculateStandardsPass(standards, resultMap) / (double) carReviewTask.getStandards());
carReviewTask.setStandardsPass(standardPass.setScale(3,BigDecimal.ROUND_UP).doubleValue() * 100);
carReviewTask.setDetails(calculateDetails(standards));
BigDecimal detailsPass = new BigDecimal(calculateDetailsPass(standards, resultMap) / (double) carReviewTask.getDetails());
carReviewTask.setDetails(DataStatisticsUtils.calculateDetails(standards));
BigDecimal detailsPass = new BigDecimal(DataStatisticsUtils.calculateDetailsPass(standards, resultMap) / (double) carReviewTask.getDetails());
carReviewTask.setDetailsPass(detailsPass.setScale(3,BigDecimal.ROUND_UP).doubleValue() * 100);
carReviewTask.setPerson(relationList.size());
}
private int calculateStandards(List<ReviewStandard> standards) {
return standards.size();
}
private long calculateStandardsPass(List<ReviewStandard> standards, Map<Long, ReviewDetailsResult> resultMap) {
long standardsPass = 0;
for(ReviewStandard standard : standards) {
List<ReviewDetails> details = getDetailsByStandard(standard);
boolean isPass = true;
for(ReviewDetails reviewDetails : details) {
if(!detailsIsPass(reviewDetails, resultMap)) {
isPass = false;
}
}
if(isPass) {
standardsPass = standardsPass + 1;
}
}
return standardsPass;
}
private int calculateDetails(List<ReviewStandard> standards) {
//审查细则(条)
int detailsNum = 0;
for(ReviewStandard standard : standards) {
List<ReviewDetails> details = getDetailsByStandard(standard);
detailsNum = detailsNum + details.size();
}
return detailsNum;
}
private long calculateDetailsPass(List<ReviewStandard> standards, Map<Long, ReviewDetailsResult> resultMap) {
long detailsPass = 0L;
for(ReviewStandard standard : standards) {
List<ReviewDetails> details = getDetailsByStandard(standard);
for(ReviewDetails reviewDetails : details) {
if(detailsIsPass(reviewDetails, resultMap)) {
detailsPass = detailsPass + 1;
}
}
}
return detailsPass;
}
private List<ReviewDetails> getDetailsByStandard(ReviewStandard standard) {
List<ReviewDetails> details = new ArrayList();
List<ReviewKeyPoint> keyPointList = standard.getKeyPointList();
for(ReviewKeyPoint keyPoint : keyPointList) {
details.addAll(keyPoint.getReviewDetailsList());
}
return details;
}
private boolean detailsIsPass(ReviewDetails reviewDetails, Map<Long, ReviewDetailsResult> resultMap) {
ReviewDetailsResult result = resultMap.get(reviewDetails.getId());
if (result != null ) {
return Objects.equals(result.getPassed(), ReviewStandard.PASSED);
} else {
return false;
}
}
@Override
public void afterPropertiesSet() throws Exception {
......
package com.ruoyi.service.impl;
import com.ruoyi.common.DataStatisticsUtils;
import com.ruoyi.common.constant.HttpStatus;
import com.ruoyi.common.core.domain.entity.SysUser;
import com.ruoyi.common.exception.ServiceException;
......@@ -185,97 +186,15 @@ public class StrategySystemReviewTaskPending implements StrategySystemReviewTask
List<TaskUserRelation> relationList = taskUserRelationMapper.selectQTeamMembers(taskMapper.findBySystemReviewTaskId(systemReviewTask.getId()));
systemReviewTask.setStandards(calculateStandards(standards));
BigDecimal standardPass = new BigDecimal(calculateStandardsPass(standards, resultMap) / (double) systemReviewTask.getStandards());
systemReviewTask.setStandards(DataStatisticsUtils.calculateStandards(standards));
BigDecimal standardPass = new BigDecimal(DataStatisticsUtils.calculateStandardsPass(standards, resultMap) / (double) systemReviewTask.getStandards());
systemReviewTask.setStandardsPass(standardPass.setScale(3,BigDecimal.ROUND_UP).doubleValue() * 100);
systemReviewTask.setDetails(calculateDetails(standards));
BigDecimal detailsPass = new BigDecimal(calculateDetailsPass(standards, resultMap) / (double) systemReviewTask.getDetails());
systemReviewTask.setDetails(DataStatisticsUtils.calculateDetails(standards));
BigDecimal detailsPass = new BigDecimal(DataStatisticsUtils.calculateDetailsPass(standards, resultMap) / (double) systemReviewTask.getDetails());
systemReviewTask.setDetailsPass(detailsPass.setScale(3,BigDecimal.ROUND_UP).doubleValue() * 100);
systemReviewTask.setPerson(relationList.size());
}
private int calculateStandards(List<ReviewStandard> standards) {
return standards.size();
}
private long calculateStandardsPass(List<ReviewStandard> standards, Map<Long, ReviewDetailsResult> resultMap) {
long standardsPass = 0;
for(ReviewStandard standard : standards) {
List<ReviewDetails> details = getDetailsByStandard(standard);
boolean isPass = true;
for(ReviewDetails reviewDetails : details) {
if(!detailsIsPass(reviewDetails, resultMap)) {
isPass = false;
}
}
if(isPass) {
standardsPass = standardsPass + 1;
}
}
return standardsPass;
}
private int calculateDetails(List<ReviewStandard> standards) {
//审查细则(条)
int detailsNum = 0;
for(ReviewStandard standard : standards) {
List<ReviewDetails> details = getDetailsByStandard(standard);
detailsNum = detailsNum + details.size();
}
return detailsNum;
}
private long calculateDetailsPass(List<ReviewStandard> standards, Map<Long, ReviewDetailsResult> resultMap) {
long detailsPass = 0L;
for(ReviewStandard standard : standards) {
List<ReviewDetails> details = getDetailsByStandard(standard);
for(ReviewDetails reviewDetails : details) {
if(detailsIsPass(reviewDetails, resultMap)) {
detailsPass = detailsPass + 1;
}
}
}
return detailsPass;
}
private List<ReviewDetails> getDetailsByStandard(ReviewStandard standard) {
List<ReviewDetails> details = new ArrayList();
List<ReviewKeyPoint> keyPointList = standard.getKeyPointList();
for(ReviewKeyPoint keyPoint : keyPointList) {
details.addAll(keyPoint.getReviewDetailsList());
}
return details;
}
private boolean detailsIsPass(ReviewDetails reviewDetails, Map<Long, ReviewDetailsResult> resultMap) {
ReviewDetailsResult result = resultMap.get(reviewDetails.getId());
if (result != null ) {
return Objects.equals(result.getPassed(), ReviewStandard.PASSED);
} else {
return false;
}
}
@Override
public void afterPropertiesSet() throws Exception {
......
......@@ -13,6 +13,7 @@ import com.ruoyi.service.TaskSampleRelationService;
import com.ruoyi.service.TaskService;
import com.ruoyi.service.TaskUserRelationService;
import com.ruoyi.web.request.*;
import com.ruoyi.web.response.DataStatisticsResponse;
import com.ruoyi.web.response.TaskFindResponse;
import com.ruoyi.web.response.TaskGetInfoResponse;
import io.swagger.annotations.Api;
......@@ -57,7 +58,7 @@ public class TaskController extends BaseController {
@Log(title = "总任务", businessType = BusinessType.INSERT)
@RequestMapping(method = RequestMethod.POST, value = "/add")
public R<String> createTask(@Validated @RequestBody TaskCreateRequest request) {
taskService.createTask(request);
taskService.createTask(request,getUserId());
return R.ok();
}
......@@ -148,6 +149,16 @@ 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.UPDATE)
@RequestMapping(method = RequestMethod.POST, value = "/editTemporaryStorage")
public R<String> editTemporaryStorage(@Validated @RequestBody TaskEditRequest request) {
taskService.editTemporaryStorageTask(request);
return R.ok();
}
@ApiOperation("删除任务")
@Trace
@Tags({@Tag(key = "param", value = "arg[0]"), @Tag(key = "result", value = "returnedObj")})
......@@ -169,4 +180,14 @@ public class TaskController extends BaseController {
}
@ApiOperation("查看任务数据统计")
@Trace
@Tags({@Tag(key = "param", value = "arg[0]"), @Tag(key = "result", value = "returnedObj")})
@RequestMapping(method = RequestMethod.POST, value = "/dataStatistics")
public R<DataStatisticsResponse> dataStatistics(@Validated @RequestBody TaskGetInfoRequest request) {
DataStatisticsResponse response = taskService.dataStatistics(request);
return R.ok(response);
}
}
package com.ruoyi.web.response;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
@ApiModel(value = "DataStatisticsResponse", description = "任务数据统计")
@Data
public class DataStatisticsResponse {
@ApiModelProperty("体系用例审查通过率")
private Double systemDetailsPass;
@ApiModelProperty("体系审查细则")
private Integer systemDetails;
@ApiModelProperty("体系审查细则通过")
private Integer systemDetailsPassNum;
@ApiModelProperty("体系审查细则未通过")
private Integer systemDetailsNoPassNum;
@ApiModelProperty("体系细则审查中")
private Integer systemDetailsUnderNum;
@ApiModelProperty("体系标准审查通过率")
private Double systemStandardsPass;
@ApiModelProperty("体系标准条款")
private Integer systemStandards;
@ApiModelProperty("体系标准条款通过")
private Integer systemStandardsPassNum;
@ApiModelProperty("体系标准条款未通过")
private Integer systemStandardsNoPassNum;
@ApiModelProperty("体系标准审查中")
private Integer systemStandardsUnderNum;
@ApiModelProperty(" 车型审查用例审查通过率")
private Double carDetailsPass;
@ApiModelProperty(" 车型审查审查细则")
private Integer carDetails;
@ApiModelProperty(" 车型审查审查细则通过")
private Integer carDetailsPassNum;
@ApiModelProperty(" 车型审查审查细则未通过")
private Integer carDetailsNoPassNum;
@ApiModelProperty(" 车型审查细则审查中")
private Integer carDetailsUnderNum;
@ApiModelProperty(" 车型审查标准审查通过率")
private Double carStandardsPass;
@ApiModelProperty(" 车型审查标准条款")
private Integer carStandards;
@ApiModelProperty(" 车型审查标准条款通过")
private Integer carStandardsPassNum;
@ApiModelProperty(" 车型审查标准条款未通过")
private Integer carStandardsNoPassNum;
@ApiModelProperty(" 车型审查标准审查中")
private Integer carStandardsUnderNum;
@ApiModelProperty(" 车型试验用例审查通过率")
private Double testDetailsPass;
@ApiModelProperty(" 车型试验审查细则")
private Integer testDetails;
@ApiModelProperty(" 车型试验审查细则通过")
private Integer testDetailsPassNum;
@ApiModelProperty(" 车型试验审查细则未通过")
private Integer testDetailsNoPassNum;
@ApiModelProperty(" 车型试验细则审查中")
private Integer testDetailsUnderNum;
@ApiModelProperty(" 车型试验标准审查通过率")
private Double testStandardsPass;
@ApiModelProperty(" 车型试验标准条款")
private Integer testStandards;
@ApiModelProperty(" 车型试验标准条款通过")
private Integer testStandardsPassNum;
@ApiModelProperty(" 车型试验标准条款未通过")
private Integer testStandardsNoPassNum;
@ApiModelProperty(" 车型试验标准审查中")
private Integer testStandardsUnderNum;
}
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