项目库-项目详情-统计接口。。

This commit is contained in:
wangzhijiang
2022-05-16 15:42:14 +08:00
parent 77d54b1ae0
commit 06fdebeaf2
11 changed files with 391 additions and 2 deletions
@@ -159,4 +159,19 @@ public class ProjectLibraryBaseController extends JeroController<ProjectLibraryB
return super.importExcel(request, response, ProjectLibraryBase.class);
}
/**
* 项目详情-统计接口
* @param id 项目库id
* @return
*/
@AutoLog(value = "项目详情-统计接口")
@ApiOperation(value="项目详情-统计接口", notes="项目详情-统计接口")
@GetMapping(value = "/getProjectDetailsStatistics")
public Result<?> getProjectDetailsStatistics(@RequestParam(name="id",required=true) String id,
@RequestParam(name="cut",required=true) String cut) {
Map<String,Object> data = projectLibraryBaseService.getProjectDetailsStatistics(id);
return Result.OK(cut,data);
}
}
@@ -0,0 +1,47 @@
package com.jero.modules.project.enums;
/**
* 认证进度枚举类
*/
public enum CertificationProgressEnum {
TEST_PASSED("实验通过","Test passed"),
TEST_FAILED("实验失败","Test failed"),
NOT_START("待开始","Not start"),
IN_PROGRESS("进行中","In progress"),
NA("不涉及","NA"),
;
String name;
String value;
private CertificationProgressEnum(String name, String value) {
this.name = name;
this.value = value;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getValue() {
return value;
}
public void setValue(String value) {
this.value = value;
}
public static String getTextByValue(String value) {
CertificationProgressEnum[] values = values();
for (CertificationProgressEnum certificationProgressEnum : values) {
if (certificationProgressEnum.value.equals(value)) {
return certificationProgressEnum.name;
}
}
return null;
}
}
@@ -0,0 +1,47 @@
package com.jero.modules.project.enums;
/**
* 当前项目状态枚举类
*/
public enum CurrentProjectStatusEnum {
BLUE("蓝色","0"),
RED("红色","1"),
YELLOW("黄色","2"),
GREEN("绿色","3"),
;
String name;
String value;
private CurrentProjectStatusEnum(String name, String value) {
this.name = name;
this.value = value;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getValue() {
return value;
}
public void setValue(String value) {
this.value = value;
}
public static String getTextByValue(String value) {
CurrentProjectStatusEnum[] values = values();
for (CurrentProjectStatusEnum currentProjectStatusEnum : values) {
if (currentProjectStatusEnum.value.equals(value)) {
return currentProjectStatusEnum.name;
}
}
return null;
}
}
@@ -1,6 +1,7 @@
package com.jero.modules.project.mapper;
import java.util.List;
import java.util.Map;
import com.jero.modules.project.entity.ConditionAssessmentEO;
import org.apache.ibatis.annotations.Param;
@@ -13,5 +14,10 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
* @Version: V1.0
*/
public interface ConditionAssessmentEOMapper extends BaseMapper<ConditionAssessmentEO> {
/**
* 获取当前项目状态统计数据
* @param projectLawsInventoryIdList
* @return
*/
List<Map<String, Object>> getCurrentProjectStatusStatistics(@Param("projectLawsInventoryIdList") List<String> projectLawsInventoryIdList);
}
@@ -1,6 +1,7 @@
package com.jero.modules.project.mapper;
import java.util.List;
import java.util.Map;
import org.apache.ibatis.annotations.Param;
import com.jero.modules.project.entity.ProjectLawsInventoryEO;
@@ -14,4 +15,17 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
*/
public interface ProjectLawsInventoryEOMapper extends BaseMapper<ProjectLawsInventoryEO> {
/**
* 获取清单确认统计
* @param projectLibraryId 项目库id
* @return
*/
List<Map<String, Object>> getlistingToConfirmStatistics(@Param("projectLibraryId") String projectLibraryId);
/**
* 获取清单确认统计
* @param projectLibraryId 项目库id
* @return
*/
List<Map<String, Object>> getTaskToConfirmStatistics(@Param("projectLibraryId")String projectLibraryId);
}
@@ -1,6 +1,7 @@
package com.jero.modules.project.mapper;
import java.util.List;
import java.util.Map;
import org.apache.ibatis.annotations.Param;
import com.jero.modules.project.entity.ProjectTaskInventoryEO;
@@ -14,4 +15,29 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
*/
public interface ProjectTaskInventoryEOMapper extends BaseMapper<ProjectTaskInventoryEO> {
/**
* 获取认证进度统计数据
* @param projectLawsInventoryIdList
* @return
*/
List<Map<String,Object>> getCertificationProgressStatistics(@Param("projectLawsInventoryIdList") List<String> projectLawsInventoryIdList);
/**
* 获取设计符合性统计数据
* @param projectLawsInventoryIdList
* @return
*/
List<Map<String, Object>> getDesignComplianceStatistice(@Param("projectLawsInventoryIdList") List<String> projectLawsInventoryIdList);
/**
* 获取prehomo确认统计数据
* @param projectLawsInventoryIdList
* @return
*/
List<Map<String, Object>> getPrehomoStatistice(@Param("projectLawsInventoryIdList") List<String> projectLawsInventoryIdList);
/**
* 获取验证符合性统计数据
* @param projectLawsInventoryIdList
* @return
*/
List<Map<String, Object>> getVerifyComplianceStatistice(@Param("projectLawsInventoryIdList") List<String> projectLawsInventoryIdList);
}
@@ -13,4 +13,19 @@
<result column="project_laws_inventory_id" property="projectLawsInventoryId" />
<result column="role_code" property="roleCode" />
</resultMap>
<select id="getCurrentProjectStatusStatistics" resultType="hashMap">
select
count(condition_assessment) as "conditionAssessmentCount",
condition_assessment as "conditionAssessment",
project_laws_inventory_id as "projectLawsInventoryId"
from
project_task_inventory_condition_assessment
where
project_laws_inventory_id in
<foreach collection="projectLawsInventoryIdList" index="index" item="item" open="(" separator="," close=")">
#{item}
</foreach>
group by condition_assessment
</select>
</mapper>
@@ -41,4 +41,28 @@
<result column="verify_due_date" property="verifyDueDate" />
<result column="region" property="region" />
</resultMap>
<select id="getlistingToConfirmStatistics" resultType="hashmap">
select
count(inventory_affirm_status) as "inventoryAffirmStatusCount",
inventory_affirm_status as "inventoryAffirmStatus",
id as "id"
from
project_laws_inventory
where
project_library_id = #{projectLibraryId}
group by inventory_affirm_status
</select>
<select id="getTaskToConfirmStatistics" resultType="hashmap">
select
count(task_affirm_status) as "taskAffirmStatusCount",
task_affirm_status as "taskAffirmStatus",
id as "id"
from
project_laws_inventory
where
project_library_id = #{projectLibraryId}
group by task_affirm_status
</select>
</mapper>
@@ -18,4 +18,64 @@
<result column="certification_progress" property="certificationProgress" />
<result column="project_status_assess" property="projectStatusAssess" />
</resultMap>
</mapper>
<select id="getCertificationProgressStatistics" resultType="hashmap">
select
count(certification_progress) as "certificationProgressCount",
certification_progress as "certificationProgress",
project_laws_inventory_id as "projectLawsInventoryId"
from
project_task_inventory
where
project_laws_inventory_id in
<foreach collection="projectLawsInventoryIdList" index="index" item="item" open="(" separator="," close=")">
#{item}
</foreach>
group by certification_progress;
</select>
<select id="getDesignComplianceStatistice" resultType="hashmap">
select
count(design_flow_task_status) as "designFlowTaskStatusCount",
design_flow_task_status as "designFlowTaskStatus",
id as "id"
from
project_task_inventory
where
project_laws_inventory_id in
<foreach collection="projectLawsInventoryIdList" index="index" item="item" open="(" separator="," close=")">
#{item}
</foreach>
group by design_flow_task_status
</select>
<select id="getPrehomoStatistice" resultType="hashmap">
select
count(prehomo_flow_task_status) as "prehomoFlowTaskStatusCount",
prehomo_flow_task_status as "prehomoFlowTaskStatus",
id as "id"
from
project_task_inventory
where
project_laws_inventory_id in
<foreach collection="projectLawsInventoryIdList" index="index" item="item" open="(" separator="," close=")">
#{item}
</foreach>
group by prehomo_flow_task_status
</select>
<select id="getVerifyComplianceStatistice" resultType="hashmap">
select
count(verify_flow_task_status) as "verifyFlowTaskStatusCount",
verify_flow_task_status as "verifyFlowTaskStatus",
id as "id"
from
project_task_inventory
where
project_laws_inventory_id in
<foreach collection="projectLawsInventoryIdList" index="index" item="item" open="(" separator="," close=")">
#{item}
</foreach>
group by verify_flow_task_status
</select>
</mapper>
@@ -69,4 +69,11 @@ public interface IProjectLibraryBaseService extends IService<ProjectLibraryBase>
* @return
*/
IPage<ProjectLibraryBase> queryPageList(Map<String, Object> params);
/**
* 项目详情-统计接口
* @param id
* @return
*/
Map<String, Object> getProjectDetailsStatistics(String id);
}
@@ -5,8 +5,17 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.jero.common.system.vo.LoginUser;
import com.jero.modules.project.entity.ConditionAssessmentEO;
import com.jero.modules.project.entity.ProjectLawsInventoryEO;
import com.jero.modules.project.entity.ProjectLibraryBase;
import com.jero.modules.project.enums.CertificationProgressEnum;
import com.jero.modules.project.enums.CurrentProjectStatusEnum;
import com.jero.modules.project.enums.InventoryAffirmStatusEnum;
import com.jero.modules.project.enums.TaskAffirmStatusEnum;
import com.jero.modules.project.mapper.ProjectLawsInventoryEOMapper;
import com.jero.modules.project.mapper.ProjectLibraryBaseMapper;
import com.jero.modules.project.mapper.ProjectTaskInventoryEOMapper;
import com.jero.modules.project.service.IConditionAssessmentEOService;
import com.jero.modules.project.service.IProjectLibraryBaseService;
import com.jero.modules.system.entity.SysUser;
import com.jero.modules.system.mapper.SysDictItemMapper;
@@ -43,6 +52,15 @@ public class ProjectLibraryBaseServiceImpl extends ServiceImpl<ProjectLibraryBas
@Autowired
private ProjectTaskPlanningServiceImpl projectTaskPlanningService;
@Autowired
private ProjectLawsInventoryEOMapper projectLawsInventoryEOMapper;
@Autowired
private ProjectTaskInventoryEOMapper projectTaskInventoryEOMapper;
@Autowired
private IConditionAssessmentEOService conditionAssessmentEOService;
/**
* 保存
*
@@ -170,6 +188,116 @@ public class ProjectLibraryBaseServiceImpl extends ServiceImpl<ProjectLibraryBas
}
}
}
@Override
public Map<String, Object> getProjectDetailsStatistics(String id) {
Map<String,Object> result = new HashMap<>();
//当前项目状态
Map<String,Object> currentProjectStatusMap = new HashMap<>();
//清单确认
Map<String,Object> listingToConfirmMap = new HashMap<>();
//任务确认
Map<String,Object> taskToConfirmMap = new HashMap<>();
//设计符合性
Map<String,Object> designComplianceMap = new HashMap<>();
//prehomo确认
Map<String,Object> prehomoMap = new HashMap<>();
//验证符合性
Map<String,Object> verifyComplianceMap = new HashMap<>();
//认证进度
Map<String,Object> certificationProgressMap = new HashMap<>();
QueryWrapper<ProjectLawsInventoryEO> lawsInventoryEOQueryWrapper = new QueryWrapper<>();
lawsInventoryEOQueryWrapper.lambda().eq(ProjectLawsInventoryEO::getProjectLibraryId,id);
lawsInventoryEOQueryWrapper.lambda().eq(ProjectLawsInventoryEO::getInventoryAffirmStatus, InventoryAffirmStatusEnum.ACCEPTED.getValue());
lawsInventoryEOQueryWrapper.lambda().eq(ProjectLawsInventoryEO::getTaskAffirmStatus, TaskAffirmStatusEnum.ACCEPTED.getValue());
List<ProjectLawsInventoryEO> projectLawsInventoryEOList = projectLawsInventoryEOMapper.selectList(lawsInventoryEOQueryWrapper);
if(CollectionUtils.isNotEmpty(projectLawsInventoryEOList)){
List<String> projectLawsInventoryIdList = projectLawsInventoryEOList.stream().distinct().map(ProjectLawsInventoryEO::getId).collect(Collectors.toList());
//当前项目状态统计 获取一个 最差的结果 统计的数据 就是studio看到的数据。
List<Map<String,Object>> currentProjectStatusMapList = new ArrayList<>();
CurrentProjectStatusEnum[] values = CurrentProjectStatusEnum.values();
for (CurrentProjectStatusEnum value : values) {
Map<String,Object> map = new HashMap<>();
map.put("color",value.getValue());
currentProjectStatusMapList.add(map);
}
int currentProjectStatusTotal;
List<ConditionAssessmentEO> projectStatusAssessList = this.conditionAssessmentEOService.getProjectStatusAssessList(projectLawsInventoryIdList);
for (Map<String, Object> map : currentProjectStatusMapList) {
List<ConditionAssessmentEO> collect = projectStatusAssessList.stream().filter(
projectStatusAssess -> StringUtils.equals(projectStatusAssess.getConditionAssessment(),map.get("color").toString())
).collect(Collectors.toList());
map.put("conditionAssessmentCount",collect.size());
}
currentProjectStatusTotal = currentProjectStatusMapList.stream().filter(
currentProjectStatus -> Integer.parseInt(currentProjectStatus.get("conditionAssessmentCount").toString()) != 0
).mapToInt(currentProjectStatus -> Integer.parseInt(currentProjectStatus.get("conditionAssessmentCount").toString())).sum();
currentProjectStatusMap.put("currentProjectStatusMapList",currentProjectStatusMapList);
currentProjectStatusMap.put("currentProjectStatusTotal",currentProjectStatusTotal);
result.put("currentProjectStatusMap",currentProjectStatusMap);
//清单确认统计
List<Map<String,Object>> listingToConfirmMapList = this.projectLawsInventoryEOMapper.getlistingToConfirmStatistics(id);
listingToConfirmMap.put("listingToConfirmMapList",listingToConfirmMapList);
result.put("listingToConfirmMap",listingToConfirmMap);
//任务确认统计
List<Map<String,Object>> taskToConfirmMapList = this.projectLawsInventoryEOMapper.getTaskToConfirmStatistics(id);
taskToConfirmMap.put("taskToConfirmMapList",taskToConfirmMapList);
result.put("taskToConfirmMap",taskToConfirmMap);
//设计符合性
List<Map<String,Object>> designComplianceMapList = this.projectTaskInventoryEOMapper.getDesignComplianceStatistice(projectLawsInventoryIdList);
designComplianceMap.put("designComplianceMapList",designComplianceMapList);
result.put("designComplianceMap",designComplianceMap);
//prehomo确认
List<Map<String,Object>> prehomoMapList = this.projectTaskInventoryEOMapper.getPrehomoStatistice(projectLawsInventoryIdList);
prehomoMap.put("prehomoMapList",prehomoMapList);
result.put("prehomoMap",prehomoMap);
//验证符合性
List<Map<String,Object>> verifyComplianceMapList = this.projectTaskInventoryEOMapper.getVerifyComplianceStatistice(projectLawsInventoryIdList);
verifyComplianceMap.put("verifyComplianceMapList",verifyComplianceMapList);
result.put("verifyComplianceMap",verifyComplianceMap);
//认证进度统计
int certificationProgressTotal;
List<Map<String,Object>> certificationProgressMapList = this.projectTaskInventoryEOMapper.getCertificationProgressStatistics(projectLawsInventoryIdList);
certificationProgressTotal = certificationProgressMapList.stream().filter(
certificationProgress -> Integer.parseInt(certificationProgress.get("certificationProgressCount").toString()) != 0
).mapToInt(certificationProgress -> Integer.parseInt(certificationProgress.get("certificationProgressCount").toString())).sum();
CertificationProgressEnum[] CertificationProgressEnumValues = CertificationProgressEnum.values();
for (CertificationProgressEnum certificationProgressEnumValue : CertificationProgressEnumValues) {
boolean flag = true;
for (Map<String, Object> map : certificationProgressMapList) {
if(StringUtils.equals(certificationProgressEnumValue.getValue(),map.get("certificationProgress").toString())){
flag = false;
break;
}
}
if(flag){
Map<String,Object> map = new HashMap<>();
map.put("certificationProgress",certificationProgressEnumValue.getValue());
map.put("certificationProgressCount",0);
certificationProgressMapList.add(map);
}
}
certificationProgressMap.put("certificationProgressTotal",certificationProgressTotal);
certificationProgressMap.put("certificationProgressMapList",certificationProgressMapList);
result.put("certificationProgressMap",certificationProgressMap);
}
return result;
}
}