项目库-项目详情-参数收集统计
This commit is contained in:
+50
@@ -0,0 +1,50 @@
|
||||
package com.jero.modules.cert.collect.controller;
|
||||
|
||||
import com.jero.common.api.vo.Result;
|
||||
import com.jero.common.aspect.annotation.AutoLog;
|
||||
import com.jero.modules.cert.collect.service.IParamsManifestEOService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Api(tags="项目详情-参数收集统计接口")
|
||||
@RestController
|
||||
@RequestMapping("/project/projectLibraryBase")
|
||||
@Slf4j
|
||||
public class ProjectDetailsStatisticsCollectManifestController {
|
||||
@Autowired
|
||||
private IParamsManifestEOService paramsManifestEOService;
|
||||
|
||||
/**
|
||||
* 项目详情-参数收集统计接口-清单下拉选项
|
||||
* @return
|
||||
*/
|
||||
@AutoLog(value = "项目详情-参数收集统计接口-清单下拉选项")
|
||||
@ApiOperation(value="项目详情-参数收集统计接口-清单下拉选项", notes="项目详情-参数收集统计接口-清单下拉选项")
|
||||
@GetMapping(value = "/getProjectDetailsStatisticsCollectManifestLabel")
|
||||
public Result<?> getProjectDetailsStatisticsCollectManifestLabel(@RequestParam(name="id",required=true) String id) {
|
||||
List<Map<String, String>> labelList = paramsManifestEOService.labelListForProjectDetails(id);
|
||||
return Result.OK(labelList);
|
||||
}
|
||||
|
||||
/**
|
||||
* 项目详情-参数收集统计接口-统计结果
|
||||
* @return
|
||||
*/
|
||||
@AutoLog(value = "项目详情-参数收集统计接口-统计结果")
|
||||
@ApiOperation(value="项目详情-参数收集统计接口-统计结果", notes="项目详情-参数收集统计接口-统计结果")
|
||||
@GetMapping(value = "/getProjectDetailsStatisticsCollectManifestData")
|
||||
public Result<?> getProjectDetailsStatisticsCollectManifestData(@RequestParam(name="paramsManifestId",required=true) String paramsManifestId,
|
||||
@RequestParam(name="cut",required=true) String cut) {
|
||||
List<Map<String, Object>> data = paramsManifestEOService.getStatisticsForProjectDetails(paramsManifestId, cut);
|
||||
return Result.OK(data);
|
||||
}
|
||||
}
|
||||
+61
@@ -0,0 +1,61 @@
|
||||
package com.jero.modules.cert.collect.enums;
|
||||
|
||||
import com.jero.common.constant.enums.CutEnum;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public enum CollectManifestStatisticsStateEnum {
|
||||
NOT_START("未开始","Not start","not start"),
|
||||
COLLECTING("收集中","Collecting","collecting"),
|
||||
SUBMIT("已提交","Submit","submit"),
|
||||
SYNC_REPORT("已同步至上报库","Sync Report","sync report");
|
||||
|
||||
String name;
|
||||
String enName;
|
||||
String value;
|
||||
|
||||
CollectManifestStatisticsStateEnum(String name, String enName, String value) {
|
||||
this.name = name;
|
||||
this.enName = enName;
|
||||
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 String getEnName() {
|
||||
return enName;
|
||||
}
|
||||
|
||||
public void setEnName(String enName) {
|
||||
this.enName = enName;
|
||||
}
|
||||
|
||||
public static Map<String,String> toMap(String cut){
|
||||
Map<String,String> map = new HashMap<>();
|
||||
if (CutEnum.CN.getValue().equals(cut)) {
|
||||
for (CollectManifestStatisticsStateEnum collectManifestStatisticsStateEnum : CollectManifestStatisticsStateEnum.values()) {
|
||||
map.put(collectManifestStatisticsStateEnum.getValue(), collectManifestStatisticsStateEnum.getName());
|
||||
}
|
||||
} else if (CutEnum.EN.getValue().equals(cut)) {
|
||||
for (CollectManifestStatisticsStateEnum collectManifestStatisticsStateEnum : CollectManifestStatisticsStateEnum.values()) {
|
||||
map.put(collectManifestStatisticsStateEnum.getValue(), collectManifestStatisticsStateEnum.getEnName());
|
||||
}
|
||||
}
|
||||
return map;
|
||||
}
|
||||
}
|
||||
+2
@@ -7,6 +7,7 @@ import com.jero.modules.cert.collect.vo.ParamsManifestVO;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @Description: 参数清单
|
||||
@@ -25,4 +26,5 @@ public interface ParamsManifestEOMapper extends BaseMapper<ParamsManifestEO> {
|
||||
|
||||
ParamsManifestVO getProjectById(@Param("projectId") String projectId);
|
||||
|
||||
List<Map<String, String>> labelListForProjectDetails(@Param("projectId") String projectId);
|
||||
}
|
||||
|
||||
+9
@@ -124,4 +124,13 @@
|
||||
) tmp_tb
|
||||
where project_id = #{projectId}
|
||||
</select>
|
||||
|
||||
<select id="labelListForProjectDetails" resultType="java.util.LinkedHashMap">
|
||||
select
|
||||
id as label,
|
||||
title as value
|
||||
from params_manifest
|
||||
where project_id = #{projectId}
|
||||
order by create_time desc
|
||||
</select>
|
||||
</mapper>
|
||||
+5
@@ -9,6 +9,7 @@ import com.jero.modules.cert.collect.vo.ParamsManifestVO;
|
||||
import com.jero.modules.cert.template.entity.ParamsTemplateEO;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @Description: 参数清单
|
||||
@@ -82,4 +83,8 @@ public interface IParamsManifestEOService extends IService<ParamsManifestEO> {
|
||||
ParamsManifestEO copy(ParamsManifestEO paramsManifestEO, String sourceManifestId);
|
||||
|
||||
ParamsManifestVO getProjectById(String projectId);
|
||||
|
||||
List<Map<String, String>> labelListForProjectDetails(String projectId);
|
||||
|
||||
List<Map<String, Object>> getStatisticsForProjectDetails(String paramsManifestId, String cut);
|
||||
}
|
||||
|
||||
+98
@@ -8,12 +8,14 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.jero.common.constant.enums.CutEnum;
|
||||
import com.jero.common.exception.JeroBootException;
|
||||
import com.jero.common.system.vo.DictModel;
|
||||
import com.jero.modules.cert.collect.entity.ParamsCollectManifestEO;
|
||||
import com.jero.modules.cert.collect.entity.ParamsConfigDataEO;
|
||||
import com.jero.modules.cert.collect.entity.ParamsConfigEO;
|
||||
import com.jero.modules.cert.collect.entity.ParamsManifestEO;
|
||||
import com.jero.modules.cert.collect.enums.CollectManifestChangeFlagEnum;
|
||||
import com.jero.modules.cert.collect.enums.CollectManifestStateEnum;
|
||||
import com.jero.modules.cert.collect.enums.CollectManifestStatisticsStateEnum;
|
||||
import com.jero.modules.cert.collect.enums.ManifestStateEnum;
|
||||
import com.jero.modules.cert.collect.mapper.ParamsCollectManifestEOMapper;
|
||||
import com.jero.modules.cert.collect.mapper.ParamsConfigEOMapper;
|
||||
@@ -30,6 +32,7 @@ import com.jero.modules.cert.template.service.IParamsTemplateEOService;
|
||||
import com.jero.modules.project.entity.ProjectRelatedPersonnel;
|
||||
import com.jero.modules.project.service.IProjectRelatedPersonnelService;
|
||||
import com.jero.modules.system.entity.SysUser;
|
||||
import com.jero.modules.system.mapper.SysDictMapper;
|
||||
import com.jero.modules.system.service.ISysUserService;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
@@ -38,6 +41,7 @@ import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Propagation;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.text.NumberFormat;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@@ -87,6 +91,8 @@ public class ParamsManifestEOServiceImpl extends ServiceImpl<ParamsManifestEOMap
|
||||
@Autowired
|
||||
private IParamsReportEOService paramsReportEOService;
|
||||
|
||||
@Autowired
|
||||
private SysDictMapper sysDictMapper;
|
||||
|
||||
|
||||
|
||||
@@ -624,4 +630,96 @@ public class ParamsManifestEOServiceImpl extends ServiceImpl<ParamsManifestEOMap
|
||||
public ParamsManifestVO getProjectById(String projectId) {
|
||||
return paramsManifestEOMapper.getProjectById(projectId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Map<String, String>> labelListForProjectDetails(String projectId) {
|
||||
return paramsManifestEOMapper.labelListForProjectDetails(projectId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Map<String, Object>> getStatisticsForProjectDetails(String paramsManifestId, String cut) {
|
||||
// 查询所有责任领域
|
||||
List<DictModel> dutyTerritoryDictList = sysDictMapper.queryDictItemsByCode("duty_territory");
|
||||
|
||||
// 统计清单参数
|
||||
ParamsCollectManifestEO paramsCollectManifestEO = new ParamsCollectManifestEO();
|
||||
paramsCollectManifestEO.setParamsManifestId(paramsManifestId);
|
||||
List<Map<String, Object>> listAll = paramsCollectManifestEOMapper.listInfoForExport(paramsCollectManifestEO);
|
||||
|
||||
double total = listAll.size();
|
||||
|
||||
if (total > 0) {
|
||||
List<Map<String, Object>> result = new LinkedList<>();
|
||||
dutyTerritoryDictList.forEach(item->{
|
||||
// 计算数量
|
||||
double notStartNumber = listAll.stream().filter(e -> (CollectManifestStateEnum.WAIT_COLLECT.getValue().equals(e.get("state"))
|
||||
|| CollectManifestStateEnum.SDT_BACK.getValue().equals(e.get("state"))
|
||||
|| CollectManifestStateEnum.CHANGE.getValue().equals(e.get("state"))) && item.getValue().equals(e.get("duty_territory")))
|
||||
.count(); // 未开始的参数项 数量
|
||||
|
||||
double collectingNumber = listAll.stream().filter(e -> (CollectManifestStateEnum.WAIT_SDT.getValue().equals(e.get("state"))
|
||||
|| CollectManifestStateEnum.WAIT_FILL.getValue().equals(e.get("state"))
|
||||
|| CollectManifestStateEnum.DRE_BACK.getValue().equals(e.get("state"))
|
||||
|| CollectManifestStateEnum.CERT_BACK.getValue().equals(e.get("state"))) && item.getValue().equals(e.get("duty_territory")))
|
||||
.count(); // 收集中的参数项 数量
|
||||
|
||||
double submitNumber = listAll.stream().filter(e -> CollectManifestStateEnum.SUBMIT.getValue().equals(e.get("state")) && item.getValue().equals(e.get("duty_territory")))
|
||||
.count(); // 已提交的参数项 数量
|
||||
|
||||
double syncReportNumber = listAll.stream().filter(e -> CollectManifestStateEnum.SYNC_REPORT.getValue().equals(e.get("state")) && item.getValue().equals(e.get("duty_territory")))
|
||||
.count(); // 已同步上报库的参数项 数量
|
||||
|
||||
// 计算百分比
|
||||
String notStartPercent = getRatio(notStartNumber, total); // 未开始的参数项 百分比
|
||||
String collectingPercent = getRatio(collectingNumber, total); // 收集中的参数项 百分比
|
||||
String submitPercent = getRatio(submitNumber, total); // 已提交的参数项 百分比
|
||||
String syncReportPercent = getRatio(syncReportNumber, total); // 已同步上报库的参数项 百分比
|
||||
|
||||
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
// 组装数据 返回前端
|
||||
List<Map<String, Object>> data = new LinkedList<>();
|
||||
getData(data, cut, notStartNumber, notStartPercent);
|
||||
getData(data, cut, collectingNumber, collectingPercent);
|
||||
getData(data, cut, submitNumber, submitPercent);
|
||||
getData(data, cut, syncReportNumber, syncReportPercent);
|
||||
|
||||
if (CutEnum.EN.getValue().equals(cut)) {
|
||||
map.put(item.getTextEn(), data);
|
||||
} else {
|
||||
map.put(item.getText(), data);
|
||||
}
|
||||
|
||||
result.add(map);
|
||||
});
|
||||
return result;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private void getData(List<Map<String, Object>> data, String cut, double quantity, String percentage) {
|
||||
|
||||
Map<String, Object> notStartMap = new HashMap<>();
|
||||
if (CutEnum.EN.getValue().equals(cut)) {
|
||||
notStartMap.put("name", CollectManifestStatisticsStateEnum.NOT_START.getEnName());
|
||||
} else {
|
||||
notStartMap.put("name", CollectManifestStatisticsStateEnum.NOT_START.getName());
|
||||
}
|
||||
notStartMap.put("type", CollectManifestStatisticsStateEnum.NOT_START.getValue());
|
||||
notStartMap.put("quantity", quantity);
|
||||
notStartMap.put("percentage", percentage);
|
||||
data.add(notStartMap);
|
||||
}
|
||||
|
||||
private String getRatio(Double d1, Double d2) {
|
||||
if (d1 == null || d2 == null || d2 <= 0) {
|
||||
return "0%";
|
||||
}
|
||||
NumberFormat percent = NumberFormat.getPercentInstance();
|
||||
percent.setMaximumFractionDigits(2);
|
||||
percent.setMinimumFractionDigits(2);
|
||||
return percent.format(d1/d2);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user