项目库-项目详情-参数收集统计-前端接收数据结构修改

This commit is contained in:
liyawei
2022-08-01 16:53:23 +08:00
parent 049fbb3534
commit 5aa1214154
3 changed files with 56 additions and 56 deletions
@@ -44,7 +44,7 @@ public class ProjectDetailsStatisticsCollectManifestController {
@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);
Map<String, Object> data = paramsManifestEOService.getStatisticsForProjectDetails(paramsManifestId, cut);
return Result.OK(data);
}
}
@@ -86,5 +86,5 @@ public interface IParamsManifestEOService extends IService<ParamsManifestEO> {
List<Map<String, String>> labelListForProjectDetails(String projectId);
List<Map<String, Object>> getStatisticsForProjectDetails(String paramsManifestId, String cut);
Map<String, Object> getStatisticsForProjectDetails(String paramsManifestId, String cut);
}
@@ -15,7 +15,6 @@ 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;
@@ -637,10 +636,17 @@ public class ParamsManifestEOServiceImpl extends ServiceImpl<ParamsManifestEOMap
}
@Override
public List<Map<String, Object>> getStatisticsForProjectDetails(String paramsManifestId, String cut) {
public Map<String, Object> getStatisticsForProjectDetails(String paramsManifestId, String cut) {
// 查询所有责任领域
List<DictModel> dutyTerritoryDictList = sysDictMapper.queryDictItemsByCode("duty_territory");
Map<String, Object> result = new LinkedHashMap<>();
List<String> dutyTerritoryNameList = new LinkedList<>();
List<Map<String, Object>> notStartList = new LinkedList<>();
List<Map<String, Object>> collectingList = new LinkedList<>();
List<Map<String, Object>> submitList = new LinkedList<>();
List<Map<String, Object>> syncReportList = new LinkedList<>();
// 统计清单参数
ParamsCollectManifestEO paramsCollectManifestEO = new ParamsCollectManifestEO();
paramsCollectManifestEO.setParamsManifestId(paramsManifestId);
@@ -648,68 +654,62 @@ public class ParamsManifestEOServiceImpl extends ServiceImpl<ParamsManifestEOMap
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(); // 未开始的参数项 数量
dutyTerritoryDictList.forEach(item->{
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(); // 收集中的参数项 数量
if (CutEnum.EN.getValue().equals(cut)) {
dutyTerritoryNameList.add(item.getTextEn());
double submitNumber = listAll.stream().filter(e -> CollectManifestStateEnum.SUBMIT.getValue().equals(e.get("state")) && item.getValue().equals(e.get("duty_territory")))
.count(); // 已提交的参数项 数量
} else {
dutyTerritoryNameList.add(item.getText());
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); // 已同步上报库的参数项 百分比
// 计算数量
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(); // 收集中的参数项 数量
Map<String, Object> map = new HashMap<>();
// 组装数据 返回前端
List<Map<String, Object>> data = new LinkedList<>();
getData(data, cut, CollectManifestStatisticsStateEnum.NOT_START, notStartNumber, notStartPercent);
getData(data, cut, CollectManifestStatisticsStateEnum.COLLECTING, collectingNumber, collectingPercent);
getData(data, cut, CollectManifestStatisticsStateEnum.SUBMIT, submitNumber, submitPercent);
getData(data, cut, CollectManifestStatisticsStateEnum.SYNC_REPORT, syncReportNumber, syncReportPercent);
double submitNumber = listAll.stream().filter(e -> CollectManifestStateEnum.SUBMIT.getValue().equals(e.get("state")) && item.getValue().equals(e.get("duty_territory")))
.count(); // 已提交的参数项 数量
if (CutEnum.EN.getValue().equals(cut)) {
map.put(item.getTextEn(), data);
} else {
map.put(item.getText(), data);
}
double syncReportNumber = listAll.stream().filter(e -> CollectManifestStateEnum.SYNC_REPORT.getValue().equals(e.get("state")) && item.getValue().equals(e.get("duty_territory")))
.count(); // 已同步上报库的参数项 数量
result.add(map);
});
return result;
}
// 计算百分比
String notStartPercent = getRatio(notStartNumber, total); // 未开始的参数项 百分比
String collectingPercent = getRatio(collectingNumber, total); // 收集中的参数项 百分比
String submitPercent = getRatio(submitNumber, total); // 已提交的参数项 百分比
String syncReportPercent = getRatio(syncReportNumber, total); // 已同步上报库的参数项 百分比
return null;
// 组装数据 返回前端
getData(notStartList, notStartNumber, notStartPercent);
getData(collectingList, collectingNumber, collectingPercent);
getData(submitList, submitNumber, submitPercent);
getData(syncReportList, syncReportNumber, syncReportPercent);
});
result.put("dutyTerritory", dutyTerritoryNameList);
result.put("notStart", notStartList);
result.put("collecting", collectingList);
result.put("submit", submitList);
result.put("syncReport", syncReportList);
return result;
}
private void getData(List<Map<String, Object>> data, String cut, CollectManifestStatisticsStateEnum statisticsStateEnum, double quantity, String percentage) {
Map<String, Object> notStartMap = new HashMap<>();
if (CutEnum.EN.getValue().equals(cut)) {
notStartMap.put("name", statisticsStateEnum.getEnName());
} else {
notStartMap.put("name", statisticsStateEnum.getName());
}
notStartMap.put("type", statisticsStateEnum.getValue());
notStartMap.put("quantity", quantity);
notStartMap.put("percentage", percentage);
data.add(notStartMap);
private void getData(List<Map<String, Object>> data, double quantity, String percentage) {
Map<String, Object> map = new HashMap<>();
map.put("quantity", quantity);
map.put("percentage", percentage);
data.add(map);
}
/**
@@ -720,7 +720,7 @@ public class ParamsManifestEOServiceImpl extends ServiceImpl<ParamsManifestEOMap
*/
private String getRatio(Double d1, Double d2) {
if (d1 == null || d2 == null || d2 <= 0) {
return "0%";
return "0.00%";
}
NumberFormat percent = NumberFormat.getPercentInstance();
percent.setMaximumFractionDigits(2);