Commit 781882bb authored by tianyiming's avatar tianyiming

任务30565 大屏隐患列表后端调整

parent cde9ccf2
...@@ -139,4 +139,13 @@ public class SafetyProblemTracingDto extends BaseDto { ...@@ -139,4 +139,13 @@ public class SafetyProblemTracingDto extends BaseDto {
@ApiModelProperty(value = "问题等级code") @ApiModelProperty(value = "问题等级code")
private String problemLevelCode; private String problemLevelCode;
@ApiModelProperty(value = "隐患等级(红:隐患状态为未处理、黄:暂无、绿:隐患状态为已处理、灰:暂无)")
private String hiddenDangersLevel;
@ApiModelProperty(value = "设备类别code")
private String equCategoryCode;
@ApiModelProperty(value = "设备类别")
private String equCategory;
} }
...@@ -24,4 +24,8 @@ public interface SafetyProblemTracingMapper extends BaseMapper<SafetyProblemTrac ...@@ -24,4 +24,8 @@ public interface SafetyProblemTracingMapper extends BaseMapper<SafetyProblemTrac
Page<Map<String, Object>> queryPrincipalUnitByProblemId(Page<Map<String, Object>> page, String problemId, String sourceTypeCode); Page<Map<String, Object>> queryPrincipalUnitByProblemId(Page<Map<String, Object>> page, String problemId, String sourceTypeCode);
List<Map<String, Object>> queryOutOfMaintenanceRecord(); List<Map<String, Object>> queryOutOfMaintenanceRecord();
List<String> getBusinessType(@Param("sourceTypeCode") String sourceTypeCode);
List<Map<String, Object>> getBusinessCount(@Param("sourceTypeCode") String sourceTypeCode);
} }
...@@ -6,6 +6,8 @@ ...@@ -6,6 +6,8 @@
resultType="com.yeejoin.amos.boot.module.jg.api.dto.SafetyProblemTracingDto"> resultType="com.yeejoin.amos.boot.module.jg.api.dto.SafetyProblemTracingDto">
select select
spt.*, spt.*,
case when spt."problem_status_code" = '0' then '红'
else '绿' end hiddenDangersLevel,
(select extend::json->>'pic' from cb_data_dictionary where type = 'ISSUE_TYPE' and code = spt.problem_type_code) problemTypePic (select extend::json->>'pic' from cb_data_dictionary where type = 'ISSUE_TYPE' and code = spt.problem_type_code) problemTypePic
from tzs_safety_problem_tracing spt from tzs_safety_problem_tracing spt
<where> <where>
...@@ -46,6 +48,9 @@ ...@@ -46,6 +48,9 @@
<if test="problemModel.principalUnitType != null and problemModel.principalUnitType != ''"> <if test="problemModel.principalUnitType != null and problemModel.principalUnitType != ''">
and spt.principal_unit_type = #{problemModel.principalUnitType} and spt.principal_unit_type = #{problemModel.principalUnitType}
</if> </if>
<if test="problemModel.hiddenDangersLevel != null and problemModel.hiddenDangersLevel != ''">
and spt.problem_status_code = #{problemModel.hiddenDangersLevel}
</if>
<if test="problemModel.regionCode != null and problemModel.regionCode != ''"> <if test="problemModel.regionCode != null and problemModel.regionCode != ''">
and spt.region_code like CONCAT(#{problemModel.regionCode}, '%') and spt.region_code like CONCAT(#{problemModel.regionCode}, '%')
</if> </if>
...@@ -126,4 +131,33 @@ ...@@ -126,4 +131,33 @@
spt.sequence_nbr = #{problemId} spt.sequence_nbr = #{problemId}
) t WHERE t.sourceTypeCode = #{sourceTypeCode} ) t WHERE t.sourceTypeCode = #{sourceTypeCode}
</select> </select>
<select id="getBusinessType" resultType="java.lang.String">
SELECT
problem_type
FROM
tzs_safety_problem_tracing
where
is_delete = '0'
<if test="sourceTypeCode != null and sourceTypeCode != ''">
and source_type_code = #{sourceTypeCode}
</if>
GROUP BY problem_type
</select>
<select id="getBusinessCount" resultType="java.util.Map">
SELECT
source_type sourceType,
COUNT ( 1 ) num,
problem_type problemType,
problem_status_code problemStatusCode
FROM
tzs_safety_problem_tracing
WHERE
is_delete = '0'
<if test="sourceTypeCode != null and sourceTypeCode != ''">
and source_type_code = #{sourceTypeCode}
</if>
GROUP BY
problem_type,
problem_status_code;
</select>
</mapper> </mapper>
...@@ -502,6 +502,18 @@ public class JGDPStatisticsController { ...@@ -502,6 +502,18 @@ public class JGDPStatisticsController {
} }
/** /**
* 隐患列表分组等级柱状折线图
*
*/
@TycloudOperation(ApiLevel = UserType.AGENCY, needAuth = false)
@PostMapping(value = "/safety-problem-tracing/chart/dp")
@ApiOperation(httpMethod = "POST",value = "隐患列表分组等级柱状折线图", notes = "隐患列表分组等级柱状折线图")
public ResponseModel<Map<String, Object>> getProblemChart(@RequestBody(required = false) SafetyProblemTracingDto problemModel) {
return ResponseHelper.buildResponse(statisticsService.getProblemChart(problemModel));
}
/**
* 列表分页查询-大屏监督管理使用 * 列表分页查询-大屏监督管理使用
* *
* @param current 当前页 * @param current 当前页
......
...@@ -3249,4 +3249,67 @@ public class JGDPStatisticsServiceImpl { ...@@ -3249,4 +3249,67 @@ public class JGDPStatisticsServiceImpl {
String orgCode = stCommonService.getAndSetOrgCode(cityCode); String orgCode = stCommonService.getAndSetOrgCode(cityCode);
return jgUseRegistrationManageMapper.getRecords(page, dto, orgCode); return jgUseRegistrationManageMapper.getRecords(page, dto, orgCode);
} }
public Map<String, Object> getProblemChart(SafetyProblemTracingDto problemModel) {
Map<String,Object> resultMap = new HashMap<>();
String sourceTypeCode = problemModel.getSourceTypeCode();
List<String> xdata = safetyProblemTracingMapper.getBusinessType(sourceTypeCode);
if(ObjectUtils.isEmpty(xdata)){
return resultMap;
}
List<Map<String, Object>> countMap = safetyProblemTracingMapper.getBusinessCount(sourceTypeCode);
List<String> redCount = new ArrayList<>();
List<String> yellowCount = new ArrayList<>();
List<String> greenCount = new ArrayList<>();
List<String> greyCount = new ArrayList<>();
List<String> stationRates = new ArrayList<>();
xdata.forEach(r -> {
List<Map<String, Object>> redList = countMap.stream().filter(map -> map.get("problemType").equals(r) && "0".equals(map.get("problemStatusCode").toString())).collect(Collectors.toList());
List<Map<String, Object>> greenList = countMap.stream().filter(map -> map.get("problemType").equals(r) && "1".equals(map.get("problemStatusCode").toString())).collect(Collectors.toList());
String red = ObjectUtils.isEmpty(redList) ? "0" : redList.get(0).get("num").toString();
String green = ObjectUtils.isEmpty(greenList) ? "0" : greenList.get(0).get("num").toString();
redCount.add(red);
greenCount.add(green);
yellowCount.add("0");
greyCount.add("0");
Long problemSum = Long.valueOf(red) + Long.valueOf(green);
BigDecimal percent = (new BigDecimal(Double.valueOf(green) * 100).divide(new BigDecimal(problemSum.doubleValue()), 2, RoundingMode.HALF_UP));
stationRates.add(percent.toString());
});
Set<Map<String,String>> legendData = new HashSet<>();
for (int i = 0; i < 5; i++) {
Map<String, String> map = new HashMap<>();
if (i == 0) {
map.put("dataKey", "redCount");
map.put("value", "红");
map.put("chartType", "bar");
} else if (i == 1) {
map.put("dataKey", "yellowCount");
map.put("value", "黄");
map.put("chartType", "bar");
} else if (i == 2) {
map.put("dataKey", "greenCount");
map.put("value", "绿");
map.put("chartType", "bar");
} else if (i == 3) {
map.put("dataKey", "greyCount");
map.put("value", "灰");
map.put("chartType", "bar");
} else {
map.put("dataKey", "stationRate");
map.put("value", "闭环率");
map.put("chartType", "line");
}
legendData.add(map);
}
resultMap.put("legendData", legendData);
resultMap.put("xdata", xdata);
resultMap.put("redCount", redCount);
resultMap.put("yellowCount", yellowCount);
resultMap.put("greenCount", greenCount);
resultMap.put("greyCount", greyCount);
resultMap.put("stationRate", stationRates);
return resultMap;
}
} }
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