Commit 12dfe673 authored by yuanshuo's avatar yuanshuo

1.添加新接口/home/statistics/quantityStatisticsNew用于标准应用数据库首页数据获取

parent 57992389
package com.ruoyi.domain.vo;
import io.swagger.annotations.ApiModel;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@ApiModel(value = "标准应用数据库—首页数量统计—对象vo")
public class NumberStatistics {
private Long standardId;
private String standardName;
private Long keypointNum;
private Long detailsNum;
private Long sceneNum;
private Integer usecaseNum;
}
package com.ruoyi.domain.vo;
import io.swagger.annotations.ApiModel;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.util.List;
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@ApiModel(value = "标准应用数据库—首页数量统计")
public class QuantityStatisticsNewVO {
private List<NumberStatistics> numberStatisticsList;
}
package com.ruoyi.mapper;
import com.ruoyi.domain.Standard;
import com.ruoyi.domain.vo.*;
import org.springframework.stereotype.Repository;
......@@ -21,5 +22,10 @@ public interface StatisticsHomeMapper {
// 参与任务情况统计
public List<TaskParticipationStatisticsVO> selectTaskParticipationStatistics();
//获取当前标准下的要点数
Long selectKeypointNum(Standard standard);
//获取当前标准下的细则数
Long selectDetailsNum(Standard standard);
//获取当前标准下的场景数
Long selectSceneNum(Standard standard);
}
package com.ruoyi.service;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.domain.vo.*;
import java.io.IOException;
import java.util.List;
public interface StatisticsHomeService {
......@@ -19,4 +21,9 @@ public interface StatisticsHomeService {
// 参与任务情况统计
public List<TaskParticipationStatisticsVO> selectTaskParticipationStatistics();
/*
* 标准应用数据库—首页—要点细则场景用例数量统计
* */
QuantityStatisticsNewVO selectQuantityStatisticsNew() throws IOException;
}
package com.ruoyi.service.impl;
import cn.hutool.json.JSONUtil;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.domain.Standard;
import com.ruoyi.domain.vo.*;
import com.ruoyi.mapper.ReviewStandardMapper;
import com.ruoyi.mapper.StandardMapper;
import com.ruoyi.mapper.StatisticsHomeMapper;
import com.ruoyi.service.StatisticsHomeService;
import com.ruoyi.service.TestUseCaseService;
import com.ruoyi.web.request.GetSerialNumberRequest;
import com.ruoyi.web.request.Offset;
import com.ruoyi.web.response.TestUserCaseListNewResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
......@@ -21,6 +29,9 @@ public class StatisticsHomeServiceImpl implements StatisticsHomeService {
@Autowired
private StandardMapper standardMapper;
@Autowired
private TestUseCaseService testUseCaseService;
@Override
public QuantityStatisticsVO selectQuantityStatistics(QuantityStatisticsVO quantityStatisticsHome){
......@@ -72,6 +83,54 @@ public class StatisticsHomeServiceImpl implements StatisticsHomeService {
return statisticsHomeMapper.selectTaskParticipationStatistics();
}
/*
*
* 标准应用数据库—首页—要点细则场景用例数量统计
* */
@Override
public QuantityStatisticsNewVO selectQuantityStatisticsNew() throws IOException {
//创建对象
QuantityStatisticsNewVO quantityStatisticsNewVO = new QuantityStatisticsNewVO();
List<NumberStatistics> numberStatisticsList = new ArrayList<>();
//获取当前库里所有标准
List<Standard> standardList = standardMapper.selectListAll();
//准备调用科恩接口的请求参数
Offset offset = new Offset();
offset.setOffset(0);
offset.setLimit(9999);
for (Standard standard : standardList){
NumberStatistics numberStatistics = new NumberStatistics();
numberStatistics.setStandardName(standard.getName());
numberStatistics.setStandardId(standard.getId());
//获取当前标准下的要点数
numberStatistics.setKeypointNum(statisticsHomeMapper.selectKeypointNum(standard));
//获取当前标准下的细则数
numberStatistics.setDetailsNum(statisticsHomeMapper.selectDetailsNum(standard));
//获取当前标准下的场景数
numberStatistics.setSceneNum(statisticsHomeMapper.selectSceneNum(standard));
//窜 调用科恩接口的 request
GetSerialNumberRequest getSerialNumberRequest = new GetSerialNumberRequest();
getSerialNumberRequest.setOffset(offset);
getSerialNumberRequest.setName(standard.getName());
String request = JSONUtil.toJsonStr(getSerialNumberRequest);
//获取当前标准下的用例数
TestUserCaseListNewResponse useCaseListNew = testUseCaseService.getUseCaseListNew(request);
Integer usecaseNum = useCaseListNew.getUseCaseNum();
if (usecaseNum == null){
usecaseNum = 0;
}
numberStatistics.setUsecaseNum(usecaseNum);
numberStatisticsList.add(numberStatistics);
}
quantityStatisticsNewVO.setNumberStatisticsList(numberStatisticsList);
return quantityStatisticsNewVO;
}
// 计算两个数各占比
public int percentageCalculation(Integer a, Integer b){
int total = a+b;
......
......@@ -12,6 +12,7 @@ import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.io.IOException;
import java.util.List;
@Api(tags = {"首页统计"})
......@@ -46,4 +47,10 @@ public class StatisticsHomeController {
public R<List<TaskParticipationStatisticsVO>> selectTaskParticipationStatistics(){
return R.ok(statisticsHomeService.selectTaskParticipationStatistics());
}
@ApiOperation("标准应用数据库—首页—要点细则场景用例数量统计")
@PostMapping("/quantityStatisticsNew")
public R<QuantityStatisticsNewVO> selectQuantityStatisticsNew () throws IOException {
return R.ok(statisticsHomeService.selectQuantityStatisticsNew());
}
}
......@@ -70,4 +70,31 @@
GROUP BY
tur.user_id
</select>
</mapper>
\ No newline at end of file
<select id="selectKeypointNum" resultType="java.lang.Long">
select
count(trk.text)
from t_review_keypoint trk
left join t_review_standard trs on trk.review_standard_id = trs.id
left join t_standard ts on trs.standard_id = ts.id
where ts.id = #{id} and ts.name =#{name}
</select>
<select id="selectDetailsNum" resultType="java.lang.Long">
select
count(trs.text)
from t_review_details trd
left join t_review_keypoint trk on trd.review_keypoint_id = trk.id
left join t_review_standard trs on trk.review_standard_id = trs.id
left join t_standard ts on trs.standard_id = ts.id
where ts.id = #{id} and ts.name =#{name}
</select>
<select id="selectSceneNum" resultType="java.lang.Long">
select
count(trsc.text)
from t_review_scene trsc
left join t_review_details trd on trsc.review_details_id = trd.id
left join t_review_keypoint trk on trd.review_keypoint_id = trk.id
left join t_review_standard trs on trk.review_standard_id = trs.id
left join t_standard ts on trs.standard_id = ts.id
where ts.id = #{id} and ts.name =#{name}
</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