Commit 42f78adc authored by 耿迪迪's avatar 耿迪迪

用户统计大屏

parent 6b66ce72
...@@ -3,7 +3,11 @@ package com.zehong.web.controller.screenstatistic; ...@@ -3,7 +3,11 @@ package com.zehong.web.controller.screenstatistic;
import com.zehong.common.core.domain.AjaxResult; import com.zehong.common.core.domain.AjaxResult;
import com.zehong.system.service.TScreenStatisticService; import com.zehong.system.service.TScreenStatisticService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*; 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.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
...@@ -79,4 +83,13 @@ public class TScreenStatisticController { ...@@ -79,4 +83,13 @@ public class TScreenStatisticController {
public AjaxResult totalNumStatisticByType(){ public AjaxResult totalNumStatisticByType(){
return AjaxResult.success(screenStatisticService.totalNumStatisticByType()); return AjaxResult.success(screenStatisticService.totalNumStatisticByType());
} }
/**
* 新大屏用户统计
*/
@GetMapping("/userStatistic")
public AjaxResult userStatistic(){
return AjaxResult.success(screenStatisticService.userStatistic());
}
} }
...@@ -58,4 +58,11 @@ public interface TScreenStatisticMapper { ...@@ -58,4 +58,11 @@ public interface TScreenStatisticMapper {
*/ */
List<Map<String,Object>> stationStatisticByType(); List<Map<String,Object>> stationStatisticByType();
/**
* 用户统计
* @param type 用户类型
* @return
*/
List<Map<String,Object>> userStatistic(int type);
} }
...@@ -46,4 +46,10 @@ public interface TScreenStatisticService { ...@@ -46,4 +46,10 @@ public interface TScreenStatisticService {
* @return * @return
*/ */
Map<String,List<Map<String,Object>>> totalNumStatisticByType(); Map<String,List<Map<String,Object>>> totalNumStatisticByType();
/**
* 新大屏用户统计
*/
Map<String,List> userStatistic();
} }
...@@ -123,5 +123,21 @@ public class TScreenStatisticServiceImpl implements TScreenStatisticService{ ...@@ -123,5 +123,21 @@ public class TScreenStatisticServiceImpl implements TScreenStatisticService{
return result; return result;
} }
/**
* 新大屏用户统计
*/
@Override
public Map<String,List> userStatistic(){
Map<String,List> result = new HashMap<>();
//居民用户统计
List<Map<String,Object>> userStatistic = screenStatisticMapper.userStatistic(1);
result.put("categories", userStatistic.stream().map(item -> item.get("areaName")).collect(Collectors.toList()));
result.put("residential", userStatistic.stream().map(item -> item.get("num")).collect(Collectors.toList()));
//工商用户统计
List<Map<String,Object>> bussinessStatistic = screenStatisticMapper.userStatistic(2);
result.put("commercial", bussinessStatistic.stream().map(item -> item.get("num")).collect(Collectors.toList()));
return result;
}
} }
...@@ -131,4 +131,22 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" ...@@ -131,4 +131,22 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
ORDER BY station.site_station_type DESC ; ORDER BY station.site_station_type DESC ;
</select> </select>
<!-- 用户统计 -->
<select id="userStatistic" parameterType="int" resultType="Map">
SELECT
count(us.id) as num,
area.area_name as areaName
FROM
t_area area
<if test="type == 1">
LEFT JOIN t_user us ON area.id = us.street
</if>
<if test="type == 2">
LEFT JOIN t_business us ON area.id = us.street
</if>
WHERE area.parent_id = 8
GROUP BY area.id
ORDER BY area.id
</select>
</mapper> </mapper>
\ No newline at end of file
...@@ -58,3 +58,12 @@ export function totalNumStatisticByType(query) { ...@@ -58,3 +58,12 @@ export function totalNumStatisticByType(query) {
}) })
} }
//新大屏用户统计
export function userStatistic(query) {
return request({
url: '/screen/statistic/userStatistic',
method: 'get',
params: query
})
}
...@@ -100,7 +100,9 @@ export default { ...@@ -100,7 +100,9 @@ export default {
if(pipeLengthInfo){ if(pipeLengthInfo){
pipeLengthInfo.forEach(item =>{ pipeLengthInfo.forEach(item =>{
let info = this.itemArr[item.type-1]; let info = this.itemArr[item.type-1];
info.num = item.totalLength; if (info){
info.num = item.totalLength;
}
}) })
} }
//设备 //设备
......
...@@ -18,13 +18,13 @@ ...@@ -18,13 +18,13 @@
<img class="shu" src="@/assets/bigwindowImg/indImg/shu.png" alt="" /> <img class="shu" src="@/assets/bigwindowImg/indImg/shu.png" alt="" />
</div> </div>
<div class="b2"> <div class="b2">
<div class="b2t1">发生泄露报警</div> <div class="b2t1">{{ eventInfo.title }}</div>
<div class="b2t2"> <div class="b2t2">
<div class="dz">地址:</div> <div class="dz">地址:</div>
<div>河北省石家庄市平山西柏坡经济开发区经开路1号</div> <div>{{ eventInfo.address }}</div>
</div> </div>
</div> </div>
<div class="b3"> <div class="b3" @click="toEvent">
<img class="img1" src="@/assets/bigwindowImg/indImg/rimgb.png" alt="" /> <img class="img1" src="@/assets/bigwindowImg/indImg/rimgb.png" alt="" />
<div>点击定位</div> <div>点击定位</div>
</div> </div>
...@@ -32,7 +32,7 @@ ...@@ -32,7 +32,7 @@
</div> </div>
<div class="t2"> <div class="t2">
<Title text="事件定位" /> <Title text="用户统计" />
<div class="chars-box"> <div class="chars-box">
<UserTypeBarChartVue /> <UserTypeBarChartVue />
</div> </div>
...@@ -53,7 +53,7 @@ import Title from "@/views/bigWindow/PubCom/title.vue"; ...@@ -53,7 +53,7 @@ import Title from "@/views/bigWindow/PubCom/title.vue";
import d from "@/assets/bigwindowImg/index/rt.png"; import d from "@/assets/bigwindowImg/index/rt.png";
import UserTypeBarChartVue from "./UserTypeBarChart.vue"; import UserTypeBarChartVue from "./UserTypeBarChart.vue";
import Table from "@/views/bigWindow/Ind/components/DeviceScrollTable.vue" import Table from "@/views/bigWindow/Ind/components/DeviceScrollTable.vue"
import { listResponse } from "@/api/emergency/response";
export default { export default {
name: "", name: "",
...@@ -66,9 +66,30 @@ export default { ...@@ -66,9 +66,30 @@ export default {
data() { data() {
return { return {
d, d,
queryParams: {
pageNum: 1,
pageSize: 1
},
eventInfo: {}
}; };
}, },
methods: {}, created(){
this.getList();
},
methods: {
getList(){
listResponse(this.queryParams).then(res => {
if(res.code == 200 && res.rows){
//this.eventList = res.rows;
this.eventInfo = res.rows[0];
console.log(">>>>>>>>>>",this.eventInfo)
}
});
},
toEvent(){
this.$router.push("/urgent/emergency")
}
},
}; };
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
...@@ -143,6 +164,7 @@ export default { ...@@ -143,6 +164,7 @@ export default {
color: #fff; color: #fff;
padding-top: 25px; padding-top: 25px;
text-align: center; text-align: center;
cursor: pointer;
} }
} }
.t2 { .t2 {
......
...@@ -3,9 +3,10 @@ ...@@ -3,9 +3,10 @@
</template> </template>
<script> <script>
import { userStatistic } from "@/api/screenstatistic/statistic";
export default { export default {
name: "UserTypeBarChart", name: "UserTypeBarChart",
props: { /*props: {
categories: { categories: {
type: Array, type: Array,
default() { default() {
...@@ -18,20 +19,24 @@ export default { ...@@ -18,20 +19,24 @@ export default {
return [26, 34, 18, 22, 24, 28, 10]; return [26, 34, 18, 22, 24, 28, 10];
}, },
}, },
industrial: { commercial: {
type: Array, type: Array,
default() { default() {
return [18, 24, 8, 18, 20, 26, 22]; return [18, 24, 8, 18, 20, 26, 22];
}, },
}, },
}, },*/
data() { data() {
return { return {
chart: null, chart: null,
categories: [],
residential: [],
commercial: []
}; };
}, },
mounted() { mounted() {
this.initChart(); this.initChart();
this.getUserStatistic();
window.addEventListener("resize", this.handleResize); window.addEventListener("resize", this.handleResize);
}, },
beforeDestroy() { beforeDestroy() {
...@@ -41,18 +46,29 @@ export default { ...@@ -41,18 +46,29 @@ export default {
this.chart = null; this.chart = null;
} }
}, },
watch: { /* watch: {
categories() { categories() {
this.updateChart(); this.updateChart();
}, },
residential() { residential() {
this.updateChart(); this.updateChart();
}, },
industrial() { commercial() {
this.updateChart(); this.updateChart();
}, },
}, },*/
methods: { methods: {
getUserStatistic(){
userStatistic().then(res =>{
if(res.code == 200){
this.categories = res.data.categories;
this.residential = res.residential;
this.commercial = res.data.commercial;
console.log(">>>>>>>>>", res.data);
this.updateChart();
}
})
},
initChart() { initChart() {
if (!this.$refs.chart) { if (!this.$refs.chart) {
return; return;
...@@ -69,6 +85,19 @@ export default { ...@@ -69,6 +85,19 @@ export default {
if (!this.chart) { if (!this.chart) {
return; return;
} }
// 修复5: 检查数据是否有效
if (!this.categories.length || !this.residential.length || !this.commercial.length) {
console.warn("数据不完整,图表无法显示");
return;
}
// 修复6: 确保数据长度一致
const maxLength = Math.max(this.categories.length, this.residential.length, this.commercial.length);
if (this.categories.length !== maxLength ||
this.residential.length !== maxLength ||
this.commercial.length !== maxLength) {
console.warn("数据长度不一致,可能显示异常");
}
this.chart.setOption({ this.chart.setOption({
grid: { grid: {
left: 8, left: 8,
...@@ -90,9 +119,11 @@ export default { ...@@ -90,9 +119,11 @@ export default {
xAxis: { xAxis: {
type: "category", type: "category",
data: this.categories, data: this.categories,
boundaryGap: true,
axisLine: { lineStyle: { color: "rgba(255,255,255,0.2)" } }, axisLine: { lineStyle: { color: "rgba(255,255,255,0.2)" } },
axisTick: { show: false }, axisTick: { show: false },
axisLabel: { axisLabel: {
interval: 0,
color: "#ffffff", color: "#ffffff",
fontSize: 11, fontSize: 11,
}, },
...@@ -120,7 +151,7 @@ export default { ...@@ -120,7 +151,7 @@ export default {
{ {
name: "工商业用户", name: "工商业用户",
type: "bar", type: "bar",
data: this.industrial, data: this.commercial,
barWidth: 10, barWidth: 10,
itemStyle: { itemStyle: {
borderRadius: [2, 2, 0, 0], borderRadius: [2, 2, 0, 0],
......
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