浏览代码

大屏统计

suntianwu 3 年之前
父节点
当前提交
92eeff399f

+ 93 - 0
src/main/java/com/care/bigscreen/controller/StStationController.java

@@ -0,0 +1,93 @@
+package com.care.bigscreen.controller;
+
+
+import com.care.bigscreen.service.StStationService;
+import com.care.bigscreen.vo.BigScreenStatisticsVO;
+
+import com.care.util.Result;
+import io.swagger.annotations.ApiImplicitParam;
+import io.swagger.annotations.ApiImplicitParams;
+import io.swagger.annotations.ApiOperation;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
+
+import java.util.ArrayList;
+import java.util.List;
+
+
+/**
+ * @author javadoc
+ * @version 1.0
+ * @description 系统设置-字典管理模块-前端控制器
+ * @date
+ */
+@Slf4j
+@RestController
+@RequestMapping("/bms/system/dictionaries")
+public class StStationController {
+
+    @Autowired
+    private StStationService stStationService;
+
+
+    /**
+     * 运营商大屏统计查询
+     */
+    @ApiOperation(value = "运营商大屏统计查询", notes = "运营商大屏统计查询")
+    @GetMapping("/selectBigScreenStatisticsByOp")
+
+    public Result<BigScreenStatisticsVO> selectBigScreenStatisticsByOp() {
+        try {
+            BigScreenStatisticsVO bigScreenStatisticsVO =  stStationService.selectBigScreenStatistics(null,null);
+            return Result.success(bigScreenStatisticsVO);
+        } catch (Exception e) {
+           log.error("运营商大屏统计查询出现异常",e);
+            return Result.error("系统错误,运营商大屏统计查询失败");
+        }
+    }
+
+    /**
+     * 机构大屏统计查询
+     */
+    @ApiOperation(value = "机构大屏统计查询", notes = "机构大屏统计查询")
+    @GetMapping("/selectBigScreenStatisticsByOrg")
+    @ApiImplicitParams(
+            {
+                    @ApiImplicitParam(name = "orgId", value = "机构ID", dataTypeClass = Long.class)
+            }
+    )
+    public Result<BigScreenStatisticsVO> selectBigScreenStatisticsByOrg(Long orgId) {
+        try {
+            BigScreenStatisticsVO bigScreenStatisticsVO =  stStationService.selectBigScreenStatistics(null,orgId);
+            return Result.success(bigScreenStatisticsVO);
+        } catch (Exception e) {
+            log.error("机构大屏统计查询异常",e);
+            return Result.error("系统错误,机构大屏统计查询失败");
+        }
+    }
+
+    /**
+     * 站点统计查询
+     */
+    @ApiOperation(value = "站点统计查询", notes = "站点统计查询")
+    @GetMapping("/selectBigScreenStatisticsByStation")
+    @ApiImplicitParams(
+            {
+                    @ApiImplicitParam(name = "stationId", value = "站点ID", dataTypeClass = Long.class)
+            }
+    )
+    public Result<BigScreenStatisticsVO> selectBigScreenStatisticsByStation(Long stationId) {
+        try {
+            List<Long> stationIds = new ArrayList<>();
+            stationIds.add(stationId);
+            BigScreenStatisticsVO bigScreenStatisticsVO =  stStationService.selectBigScreenStatistics(stationIds,null);
+            return Result.success(bigScreenStatisticsVO);
+        } catch (Exception e) {
+            log.error("站点统计查询出现异常",e);
+            return Result.error("系统错误,站点统计查询失败");
+        }
+    }
+
+
+}

+ 179 - 0
src/main/java/com/care/bigscreen/entity/StStation.java

@@ -0,0 +1,179 @@
+package com.care.bigscreen.entity;
+
+import com.baomidou.mybatisplus.annotation.*;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.experimental.Accessors;
+
+import java.io.Serializable;
+import java.math.BigDecimal;
+import java.time.LocalDateTime;
+import java.util.List;
+
+/**
+ * 站点统计表实体类
+ *
+ * @author stw
+ * @since 2021-05-20
+ */
+@Data
+@EqualsAndHashCode(callSuper = false)
+@Accessors(chain = true)
+@TableName("st_station")
+@ApiModel(value = "StStation对象")
+public class StStation implements Serializable {
+
+    private static final long serialVersionUID = 1L;
+
+    @ApiModelProperty(value = "主键")
+    @TableId(value = "id", type = IdType.AUTO)
+    private Long id;
+
+    @ApiModelProperty(value = "站点ID")
+    @TableField("station_id")
+    private Long stationId;
+
+    @ApiModelProperty(value = "站点名称")
+    @TableField("station_name")
+    private String stationName;
+
+    @ApiModelProperty(value = "机构ID")
+    @TableField("org_id")
+    private Long orgId;
+
+    @ApiModelProperty(value = "用户数")
+    @TableField("older_amount")
+    private Long olderAmount;
+
+    @ApiModelProperty(value = "60至80岁用户数")
+    @TableField("older_60_80_amount")
+    private Long older6080Amount;
+
+    @ApiModelProperty(value = "80岁以上用户数")
+    @TableField("older_80_above_amount")
+    private Long older80AboveAmount;
+
+    @ApiModelProperty(value = "独居人数")
+    @TableField("alone_living_amount")
+    private Long aloneLivingAmount;
+
+    @ApiModelProperty(value = "非独居人数")
+    @TableField("no_alone_living_amount")
+    private Long noAloneLivingAmount;
+
+    @ApiModelProperty(value = "集中居住人数")
+    @TableField("concentrate_living_amount")
+    private Long concentrateLivingAmount;
+
+    @ApiModelProperty(value = "其他居住人数")
+    @TableField("other_living_amount")
+    private Long otherLivingAmount;
+
+    @ApiModelProperty(value = "一级守护人数")
+    @TableField("one_level_amount")
+    private Long oneLevelAmount;
+
+    @ApiModelProperty(value = "二级守护人数")
+    @TableField("two_level_amount")
+    private Long twoLevelAmount;
+
+    @ApiModelProperty(value = "三级守护人数")
+    @TableField("three_level_amount")
+    private Long threeLevelAmount;
+
+    @ApiModelProperty(value = "安全管家总人数")
+    @TableField("safe_mgr_amount")
+    private Long safeMgrAmount;
+
+    @ApiModelProperty(value = "累计服务总人次")
+    @TableField("serve_amount")
+    private Long serveAmount;
+
+    @ApiModelProperty(value = "设备总数")
+    @TableField("device_amount")
+    private Long deviceAmount;
+
+    @ApiModelProperty(value = "室内在线总数")
+    @TableField("indoor_online_amount")
+    private Long indoorOnlineAmount;
+
+    @ApiModelProperty(value = "室内离线总数")
+    @TableField("indoor_offline_amount")
+    private Long indoorOfflineAmount;
+
+    @ApiModelProperty(value = "户外在线总数")
+    @TableField("outdoor_online_amount")
+    private Long outdoorOnlineAmount;
+
+    @ApiModelProperty(value = "户外离线总数")
+    @TableField("outdoor_offline_amount")
+    private Long outdoorOfflineAmount;
+
+    @ApiModelProperty(value = "实时_跌倒人数")
+    @TableField("rt_fall_amount")
+    private Long rtFallAmount;
+
+    @ApiModelProperty(value = "实时_久滞人数")
+    @TableField("rt_stagnation_amount")
+    private Long rtStagnationAmount;
+
+    @ApiModelProperty(value = "实时_坠床人数")
+    @TableField("rt_falling_bed_amount")
+    private Long rtFallingBedAmount;
+
+    @ApiModelProperty(value = "实时_主动呼叫人数")
+    @TableField("rt_active_call_amount")
+    private Long rtActiveCallAmount;
+
+    @ApiModelProperty(value = "实时_户外呼叫人数")
+    @TableField("rt_outdoors_call_amount")
+    private Long rtOutdoorsCallAmount;
+
+    @ApiModelProperty(value = "历史_跌倒人数")
+    @TableField("his_fall_amount")
+    private Long hisFallAmount;
+
+    @ApiModelProperty(value = "历史_久滞人数")
+    @TableField("his_stagnation_amount")
+    private Long hisStagnationAmount;
+
+    @ApiModelProperty(value = "历史_坠床人数")
+    @TableField("his_falling_bed_amount")
+    private Long hisFallingBedAmount;
+
+    @ApiModelProperty(value = "历史_主动呼叫人数")
+    @TableField("his_active_call_amount")
+    private Long hisActiveCallAmount;
+
+    @ApiModelProperty(value = "历史_户外呼叫人数")
+    @TableField("his_outdoors_call_amount")
+    private Long hisOutdoorsCallAmount;
+
+    @ApiModelProperty(value = "坐席总人数")
+    @TableField("seats_amount")
+    private Long seatsAmount;
+
+    @ApiModelProperty(value = "坐席总在线时长(秒)")
+    @TableField("seats_online_duration")
+    private Long seatsOnlineDuration;
+
+    @ApiModelProperty(value = "经度")
+    @TableField("longitude")
+    private BigDecimal longitude;
+
+    @ApiModelProperty(value = "纬度")
+    @TableField("latitude")
+    private BigDecimal latitude;
+
+    @ApiModelProperty(value = "创建时间")
+    @TableField("CREATE_TIME")
+    private LocalDateTime createTime;
+
+    @ApiModelProperty(value = "更新时间")
+    @TableField("MODIFY_TIME")
+    private LocalDateTime modifyTime;
+
+
+}

+ 27 - 0
src/main/java/com/care/bigscreen/mapper/StStationMapper.java

@@ -0,0 +1,27 @@
+package com.care.bigscreen.mapper;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.care.bigscreen.entity.StStation;
+import com.care.bigscreen.vo.BigScreenStatisticsVO;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
+
+
+/**
+ * @author stw
+ * @version 1.0
+ * @description 站点统计表DAO层接口
+ * @date 2021/05/20/19:41
+ */
+public interface StStationMapper extends BaseMapper<StStation> {
+
+
+    /**
+     * 大屏统计查询
+     * @return 搜索符合条件的大屏统计数据
+     */
+    BigScreenStatisticsVO selectBigScreenStatistics(@Param("stationIds") List<Long> stationIds, @Param("orgId") Long orgId);
+
+
+}

+ 27 - 0
src/main/java/com/care/bigscreen/service/StStationService.java

@@ -0,0 +1,27 @@
+package com.care.bigscreen.service;
+
+import com.care.bigscreen.vo.BigScreenStatisticsVO;
+import com.care.common.vo.PageResVO;
+import com.care.dic.entity.RimsDictionaries;
+import com.care.util.PageUtil;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
+import java.util.Map;
+
+
+/**
+ * @author stw
+ * @version 1.0
+ * @description 站点统计表接口实现类
+ * @date 2021/05/20/19:41
+ */
+public interface StStationService {
+
+    /**
+     * 大屏统计查询
+     * @return 搜索符合条件的大屏统计数据
+     */
+    BigScreenStatisticsVO selectBigScreenStatistics(List<Long> stationIds, Long orgId);
+
+}

+ 34 - 0
src/main/java/com/care/bigscreen/service/impl/StStationServiceImpl.java

@@ -0,0 +1,34 @@
+package com.care.bigscreen.service.impl;
+
+
+import com.care.bigscreen.mapper.StStationMapper;
+import com.care.bigscreen.service.StStationService;
+import com.care.bigscreen.vo.BigScreenStatisticsVO;
+import org.springframework.stereotype.Service;
+
+import javax.annotation.Resource;
+import java.util.*;
+
+
+/**
+ * @author stw
+ * @version 1.0
+ * @description 站点统计表接口实现类
+ * @date 2021/05/20/19:41
+ */
+@Service
+public class StStationServiceImpl implements StStationService {
+
+    @Resource
+    private StStationMapper stStationMapper;
+
+    /**
+     * 大屏统计查询
+     * @return 搜索符合条件的大屏统计数据
+     */
+    @Override
+    public BigScreenStatisticsVO selectBigScreenStatistics(List<Long> stationIds, Long orgId){
+        return stStationMapper.selectBigScreenStatistics(stationIds,orgId);
+    }
+
+}

+ 130 - 0
src/main/java/com/care/bigscreen/vo/BigScreenStatisticsVO.java

@@ -0,0 +1,130 @@
+package com.care.bigscreen.vo;
+
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.math.BigDecimal;
+
+
+/**
+ * 大屏统计响应类
+ *
+ * @author stw
+ * @since 2021-05-20
+ */
+@Data
+@ApiModel(value = "大屏统计响应类", description = "大屏统计响应类")
+public class BigScreenStatisticsVO {
+
+    @ApiModelProperty(value = "用户数")
+    private Long olderAmount;
+
+    @ApiModelProperty(value = "60至80岁用户数")
+    private Long older6080Amount;
+
+    @ApiModelProperty(value = "80岁以上用户数")
+    private Long older80AboveAmount;
+
+    @ApiModelProperty(value = "独居人数")
+    private Long aloneLivingAmount;
+
+    @ApiModelProperty(value = "独居人数占比")
+    private BigDecimal aloneLivingRate;
+
+    @ApiModelProperty(value = "非独居人数")
+    private Long noAloneLivingAmount;
+
+    @ApiModelProperty(value = "非独居人数占比")
+    private BigDecimal noAloneLivingRate;
+
+    @ApiModelProperty(value = "集中居住人数")
+    private Long concentrateLivingAmount;
+
+    @ApiModelProperty(value = "集中居住人数占比")
+    private BigDecimal concentrateLivingRate;
+
+    @ApiModelProperty(value = "其他居住人数")
+    private Long otherLivingAmount;
+
+    @ApiModelProperty(value = "其他居住人数占比")
+    private BigDecimal otherLivingRate;
+
+    @ApiModelProperty(value = "一级守护人数")
+    private Long oneLevelAmount;
+
+    @ApiModelProperty(value = "二级守护人数")
+    private Long twoLevelAmount;
+
+    @ApiModelProperty(value = "三级守护人数")
+    private Long threeLevelAmount;
+
+    @ApiModelProperty(value = "安全管家总人数")
+    private Long safeMgrAmount;
+
+    @ApiModelProperty(value = "平均每人服务用户数")
+    private BigDecimal serveAmountAvg;
+
+    @ApiModelProperty(value = "累计服务总人次")
+    private Long serveAmount;
+
+    @ApiModelProperty(value = "设备总数")
+    private Long deviceAmount;
+
+    @ApiModelProperty(value = "室内在线总数")
+    private Long indoorOnlineAmount;
+
+    @ApiModelProperty(value = "室内在线占比")
+    private BigDecimal indoorOnlineRate;
+
+    @ApiModelProperty(value = "室内离线总数")
+    private Long indoorOfflineAmount;
+
+    @ApiModelProperty(value = "户外在线总数")
+    private Long outdoorOnlineAmount;
+
+    @ApiModelProperty(value = "户外在线占比")
+    private BigDecimal outdoorOnlineRate;
+
+    @ApiModelProperty(value = "户外离线总数")
+    private Long outdoorOfflineAmount;
+
+    @ApiModelProperty(value = "实时_跌倒人数")
+    private Long rtFallAmount;
+
+    @ApiModelProperty(value = "实时_久滞人数")
+    private Long rtStagnationAmount;
+
+    @ApiModelProperty(value = "实时_坠床人数")
+    private Long rtFallingBedAmount;
+
+    @ApiModelProperty(value = "实时_主动呼叫人数")
+    private Long rtActiveCallAmount;
+
+    @ApiModelProperty(value = "实时_户外呼叫人数")
+    private Long rtOutdoorsCallAmount;
+
+    @ApiModelProperty(value = "历史_跌倒人数")
+    private Long hisFallAmount;
+
+    @ApiModelProperty(value = "历史_久滞人数")
+    private Long hisStagnationAmount;
+
+    @ApiModelProperty(value = "历史_坠床人数")
+    private Long hisFallingBedAmount;
+
+    @ApiModelProperty(value = "历史_主动呼叫人数")
+    private Long hisActiveCallAmount;
+
+    @ApiModelProperty(value = "历史_户外呼叫人数")
+    private Long hisOutdoorsCallAmount;
+
+    @ApiModelProperty(value = "坐席总人数")
+    private Long seatsAmount;
+
+    @ApiModelProperty(value = "坐席总在线时长(小时)")
+    private BigDecimal seatsOnlineDuration;
+
+
+}

+ 62 - 0
src/main/resources/mybatis/bigscreen/StStationMapper.xml

@@ -0,0 +1,62 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.care.bigscreen.mapper.StStationMapper">
+
+    <!--多条件分页查询-->
+    <select id="selectBigScreenStatistics" resultType="com.care.bigscreen.vo.BigScreenStatisticsVO">
+        SELECT
+        sum(older_amount) olderAmount,
+        sum(older_60_80_amount) older6080Amount,
+        sum(older_80_above_amount) older80AboveAmount,
+        sum(alone_living_amount) aloneLivingAmount,
+        convert(sum(alone_living_amount)/sum(older_amount),decimal(20,2)) aloneLivingRate,
+        sum(no_alone_living_amount) noAloneLivingAmount,
+        convert(sum(no_alone_living_amount)/sum(older_amount),decimal(20,2)) noAloneLivingRate,
+        sum(concentrate_living_amount) concentrateLivingAmount,
+        convert(sum(concentrate_living_amount)/sum(older_amount),decimal(20,2)) concentrateLivingRate,
+        sum(other_living_amount) otherLivingAmount,
+        convert(sum(other_living_amount)/sum(older_amount),decimal(20,2)) otherLivingRate,
+        sum(one_level_amount) oneLevelAmount,
+        sum(two_level_amount) twoLevelAmount,
+        sum(three_level_amount) threeLevelAmount,
+        sum(safe_mgr_amount) safeMgrAmount,
+        convert(sum(older_amount)/sum(safe_mgr_amount),decimal(20,2)) serveAmountAvg,
+        sum(serve_amount) serveAmount,
+        sum(device_amount) deviceAmount,
+        convert(sum(indoor_online_amount)/(sum(indoor_online_amount) + sum(indoor_offline_amount)),decimal(20,2)) indoorOnlineRate,
+        sum(indoor_online_amount) indoorOnlineAmount,
+        sum(indoor_offline_amount) indoorOfflineAmount,
+        convert(sum(outdoor_online_amount)/(sum(outdoor_online_amount) + sum(outdoor_offline_amount)),decimal(20,2)) outdoorOnlineRate,
+        sum(outdoor_online_amount) outdoorOnlineAmount,
+        sum(outdoor_offline_amount) outdoorOfflineAmount,
+        sum(rt_fall_amount) rtFallAmount,
+        sum(rt_stagnation_amount) rtStagnationAmount,
+        sum(rt_falling_bed_amount) rtFallingBedAmount,
+        sum(rt_active_call_amount) rtActiveCallAmount,
+        sum(rt_outdoors_call_amount) rtOutdoorsCallAmount,
+        sum(his_fall_amount) hisFallAmount,
+        sum(his_stagnation_amount) hisStagnationAmount,
+        sum(his_falling_bed_amount) hisFallingBedAmount,
+        sum(his_active_call_amount) hisActiveCallAmount,
+        sum(his_outdoors_call_amount) hisOutdoorsCallAmount,
+        sum(seats_amount) seatsAmount,
+        convert(sum(seats_online_duration)/3600,decimal(20,2)) seatsOnlineDuration
+        FROM st_station t
+
+        <where>
+            1 = 1
+            <if test="orgId != null and orgId != ''">
+                AND t.org_id = #{orgId}
+            </if>
+            <if test="stationIds != null and stationIds.size()>0" >
+                AND t.station_id in
+                <foreach collection="stationIds" item="item" open="(" close=")" separator="," >
+                    #{item}
+                </foreach>
+            </if>
+        </where>
+
+    </select>
+
+
+</mapper>