接口返回值修改

main
zhangyu 2023-02-20 09:28:12 +08:00
parent 2ec9a26365
commit 7f855e50eb
4 changed files with 31 additions and 6 deletions

View File

@ -0,0 +1,14 @@
package com.hbt.safety.supervision.pojo.vo;
import lombok.Data;
/**
* vo
*/
@Data
public class StatisticsVo {
private int classify; // 分类
private int count; // 数量
}

View File

@ -34,8 +34,7 @@ public class EscalateRiskServiceImpl implements IEscalateRiskService
/**
*
*
* @param escalateRisk
*
* @return
*/
@Override

View File

@ -5,6 +5,7 @@ import java.util.stream.Collectors;
import com.alibaba.fastjson.JSONObject;
import com.hbt.safety.supervision.pojo.HazardousOperation;
import com.hbt.safety.supervision.pojo.vo.StatisticsVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.hbt.safety.supervision.mapper.HazardousOperationMapper;
@ -114,9 +115,12 @@ public class HazardousOperationServiceImpl implements IHazardousOperationService
Map<Object, List<HazardousOperation>> typeList = list.stream()
.collect(Collectors.groupingBy(HazardousOperation::getOperationType));
// 组装类型统计数据
Map<Object, Integer> operationTypeList = new HashMap<>();
List<StatisticsVo> operationTypeList = new ArrayList<>();
for(Object key : typeList.keySet()) {
operationTypeList.put(key, typeList.get(key).size());
StatisticsVo statisticsVo = new StatisticsVo();
statisticsVo.setClassify(Integer.parseInt(key.toString()));
statisticsVo.setCount(typeList.get(key).size());
operationTypeList.add(statisticsVo);
}
map.put("operationTypeList", operationTypeList);

View File

@ -1,11 +1,15 @@
package com.hbt.safety.supervision.service.impl;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.hbt.safety.supervision.pojo.vo.StatisticsVo;
import com.hbt.safety.supervision.service.IMajorHazardSourcesService;
import com.hbt.safety.supervision.pojo.MajorHazardSources;
import org.springframework.beans.factory.annotation.Autowired;
@ -108,10 +112,14 @@ public class MajorHazardSourcesServiceImpl implements IMajorHazardSourcesService
// 根据风险等级分组
Map<Object, List<MajorHazardSources>> typeList = list.stream()
.collect(Collectors.groupingBy(MajorHazardSources::getDangerLevel));
// 组装风险等级统计数据
Map<Object, Integer> dangerLevelList = new HashMap<>();
List<StatisticsVo> dangerLevelList = new ArrayList<>();
for(Object key : typeList.keySet()) {
dangerLevelList.put(key, typeList.get(key).size());
StatisticsVo statisticsVo = new StatisticsVo();
statisticsVo.setClassify(Integer.parseInt(key.toString()));
statisticsVo.setCount(typeList.get(key).size());
dangerLevelList.add(statisticsVo);
}
map.put("dangerLevelList", dangerLevelList);