管道统计数据
This commit is contained in:
@ -161,6 +161,8 @@ public class PipelineDataController {
|
||||
* - totalCount: 污水管网总数量
|
||||
* - materialLengthRatio: 污水管网【材质-长度】比例
|
||||
* - materialCountRatio: 污水管网【材质-数量】比例
|
||||
* - diameterLengthRatio: 污水管网【管径-长度】分布
|
||||
* - diameterCountRatio: 污水管网【管径-数量】分布
|
||||
*/
|
||||
@RequestMapping("/getStatistics.do")
|
||||
public ModelAndView getStatistics(HttpServletRequest request, Model model) {
|
||||
@ -239,6 +241,57 @@ public class PipelineDataController {
|
||||
|
||||
result.put("materialLengthRatio", materialLengthRatio);
|
||||
result.put("materialCountRatio", materialCountRatio);
|
||||
|
||||
// 获取按管径分组的统计数据
|
||||
List<Map<String, Object>> diameterStats = pipelineDataService.selectDiameterStats();
|
||||
|
||||
// 管径-长度分布
|
||||
JSONArray diameterLengthRatio = new JSONArray();
|
||||
// 管径-数量分布
|
||||
JSONArray diameterCountRatio = new JSONArray();
|
||||
|
||||
if (diameterStats != null && !diameterStats.isEmpty()) {
|
||||
for (Map<String, Object> stat : diameterStats) {
|
||||
String diameter = (String) stat.get("diameter");
|
||||
if (diameter == null || diameter.isEmpty()) {
|
||||
diameter = "未知";
|
||||
}
|
||||
|
||||
Object countObj = stat.get("count");
|
||||
Object lengthObj = stat.get("totalLength");
|
||||
|
||||
int count = 0;
|
||||
double length = 0.0;
|
||||
|
||||
if (countObj != null) {
|
||||
count = ((Number) countObj).intValue();
|
||||
}
|
||||
if (lengthObj != null) {
|
||||
length = ((Number) lengthObj).doubleValue();
|
||||
}
|
||||
|
||||
// 计算比例
|
||||
double lengthRatio = totalLength > 0 ? Math.round(length / totalLength * 10000) / 100.0 : 0;
|
||||
double countRatio = totalCount > 0 ? Math.round(count * 1.0 / totalCount * 10000) / 100.0 : 0;
|
||||
|
||||
// 管径-长度分布
|
||||
JSONObject lengthItem = new JSONObject();
|
||||
lengthItem.put("diameter", diameter);
|
||||
lengthItem.put("length", Math.round(length * 100) / 100.0);
|
||||
lengthItem.put("ratio", lengthRatio); // 百分比
|
||||
diameterLengthRatio.add(lengthItem);
|
||||
|
||||
// 管径-数量分布
|
||||
JSONObject countItem = new JSONObject();
|
||||
countItem.put("diameter", diameter);
|
||||
countItem.put("count", count);
|
||||
countItem.put("ratio", countRatio); // 百分比
|
||||
diameterCountRatio.add(countItem);
|
||||
}
|
||||
}
|
||||
|
||||
result.put("diameterLengthRatio", diameterLengthRatio);
|
||||
result.put("diameterCountRatio", diameterCountRatio);
|
||||
result.put("success", true);
|
||||
|
||||
} catch (Exception e) {
|
||||
|
||||
@ -27,4 +27,11 @@ public class PipelineDataDao extends CommDaoImpl<PipelineData> {
|
||||
public Map<String, Object> selectTotalStats() {
|
||||
return this.getSqlSession().selectOne(this.getMappernamespace() + ".selectTotalStats");
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取按管径分组的统计数据
|
||||
*/
|
||||
public List<Map<String, Object>> selectDiameterStats() {
|
||||
return this.getSqlSession().selectList(this.getMappernamespace() + ".selectDiameterStats");
|
||||
}
|
||||
}
|
||||
|
||||
@ -200,4 +200,15 @@
|
||||
SUM(COALESCE(length_m, 0)) as totalLength
|
||||
FROM tb_pipeline_data
|
||||
</select>
|
||||
|
||||
<!-- 获取管道统计信息:按管径分组 -->
|
||||
<select id="selectDiameterStats" resultType="java.util.Map">
|
||||
SELECT
|
||||
COALESCE(CAST(diameter_mm AS VARCHAR(50)), '未知') as diameter,
|
||||
COUNT(*) as count,
|
||||
SUM(COALESCE(length_m, 0)) as totalLength
|
||||
FROM tb_pipeline_data
|
||||
GROUP BY diameter_mm
|
||||
ORDER BY count DESC
|
||||
</select>
|
||||
</mapper>
|
||||
|
||||
@ -77,4 +77,11 @@ public class PipelineDataService implements CommService<PipelineData> {
|
||||
public Map<String, Object> selectTotalStats() {
|
||||
return pipelineDataDao.selectTotalStats();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取按管径分组的统计数据
|
||||
*/
|
||||
public List<Map<String, Object>> selectDiameterStats() {
|
||||
return pipelineDataDao.selectDiameterStats();
|
||||
}
|
||||
}
|
||||
|
||||
@ -152,9 +152,9 @@
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="col-sm-3 control-label">直径(mm)</label>
|
||||
<label class="col-sm-3 control-label">管径(mm)</label>
|
||||
<div class="col-sm-8">
|
||||
<input type="text" class="form-control" id="diameterMm" name="diameterMm" placeholder="请输入管道直径">
|
||||
<input type="text" class="form-control" id="diameterMm" name="diameterMm" placeholder="请输入管道管径">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
|
||||
@ -158,10 +158,10 @@
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="col-sm-3 control-label">直径(mm)</label>
|
||||
<label class="col-sm-3 control-label">管径(mm)</label>
|
||||
<div class="col-sm-8">
|
||||
<input type="text" class="form-control" id="diameterMm" name="diameterMm"
|
||||
value="${pipelineData.diameterMm}" placeholder="请输入管道直径">
|
||||
value="${pipelineData.diameterMm}" placeholder="请输入管道管径">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
|
||||
@ -208,7 +208,7 @@
|
||||
width: '10%'
|
||||
}, {
|
||||
field: 'diameterMm',
|
||||
title: '直径(mm)',
|
||||
title: '管径(mm)',
|
||||
align: 'center',
|
||||
valign: 'middle',
|
||||
width: '10%'
|
||||
|
||||
@ -57,7 +57,7 @@
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="col-sm-3 control-label">直径(mm)</label>
|
||||
<label class="col-sm-3 control-label">管径(mm)</label>
|
||||
<div class="col-sm-8">
|
||||
<p class="form-control-static">${pipelineData.diameterMm}</p>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user