Sfoglia il codice sorgente

优化首页数据大屏接口

Simon 1 anno fa
parent
commit
aa873fb2d6

+ 61 - 37
ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/TDataDisplayController.java

@@ -7,6 +7,7 @@ import com.ruoyi.common.core.domain.entity.SysDictData;
 import com.ruoyi.common.core.page.TableDataInfo;
 import com.ruoyi.common.utils.LocationUtils;
 import com.ruoyi.common.utils.StringUtils;
+import com.ruoyi.system.domain.TEarlyWarning;
 import com.ruoyi.system.domain.dto.*;
 import com.ruoyi.system.service.*;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -41,6 +42,8 @@ public class TDataDisplayController extends BaseController {
 
     @Autowired
     private ISysDictDataService sysDictDataService;
+    @Autowired
+    private ITEarlyWarningService tEarlyWarningService;
 
     @Autowired
     private LocationUtils locationUtils;
@@ -49,21 +52,10 @@ public class TDataDisplayController extends BaseController {
      * 查询SOS预警处理列表
      */
     @GetMapping("/list")
-    public TableDataInfo list(DataAlarmListDto dataAlarmListDto) {
+    public TableDataInfo list(TEarlyWarning earlyWarning) {
         startPage();
-        List<DataAlarmListDto> list = tShouhuanAlarmListService.selectTShouhuanAlarmList(dataAlarmListDto);
-        List<AlarmListDto> alarmListDtos = list.stream().map(
-                mapper -> {
-                    AlarmListDto alarmListDto = new AlarmListDto();
-                    alarmListDto.setName(mapper.getName());
-                    alarmListDto.setTelno(mapper.getTel_one());
-                    alarmListDto.setLocation(getCounterLocation(mapper.getGps_long() + "," + mapper.getGps_lat()));
-                    alarmListDto.setAlarmMessage(tDeviceListService.checkMessage(mapper.getAlarm_type()));
-                    alarmListDto.setCreatetime(mapper.getCreatetime());
-                    return alarmListDto;
-                }
-        ).collect(Collectors.toList());
-        return getDataTable1(alarmListDtos, tShouhuanAlarmListService.selectTShouhuanAlarmListCount());
+        List<TEarlyWarning> tEarlyWarnings = tEarlyWarningService.selectTEarlyWarningList_SOS(earlyWarning);
+        return getDataTable(tEarlyWarnings);
     }
 
     @GetMapping("/count")
@@ -73,33 +65,65 @@ public class TDataDisplayController extends BaseController {
 
     @GetMapping("/alarm")
     public AjaxResult alarm() {
-        AlarmStatusDto dto = new AlarmStatusDto();
-        dto.setAlarmSOSSolve(tShouhuanAlarmListService.selectTShouhuanAlarmSOSSolve());
-        dto.setUn_alarmSOSSolve(tShouhuanAlarmListService.selectTShouhuanAlarmSOS() - tShouhuanAlarmListService.selectTShouhuanAlarmSOSSolve());
-        dto.setAlarmRailSolve(tShouhuanAlarmListService.selectTShouhuanAlarmRailSolve());
-        dto.setUn_alarmRailSolve(tShouhuanAlarmListService.selectTShouhuanAlarmRail() - tShouhuanAlarmListService.selectTShouhuanAlarmRailSolve());
-        dto.setAlarmHeartSolve(tShouhuanAlarmListService.selectTShouhuanAlarmRailSolve());
-        dto.setUn_alarmHeartSolve(tShouhuanAlarmListService.selectTShouhuanAlarmHeart() - tShouhuanAlarmListService.selectTShouhuanAlarmHeartSolve());
-        dto.setAlarmFallSolve(tShouhuanAlarmListService.selectTShouhuanAlarmFallSolve());
-        dto.setUn_alarmFallSolve(tShouhuanAlarmListService.selectTShouhuanAlarmFall() - tShouhuanAlarmListService.selectTShouhuanAlarmFallSolve());
-        dto.setAlarmLowSolve(tShouhuanAlarmListService.selectTShouhuanAlarmLowSolve());
-        dto.setUn_alarmLowSolve(tShouhuanAlarmListService.selectTShouhuanAlarmLow() - tShouhuanAlarmListService.selectTShouhuanAlarmLowSolve());
-        dto.setAlarmStatusSolve(tShouhuanAlarmListService.selectTShouhuanAlarmStatus());
-        dto.setUn_alarmStatusSolve(tShouhuanAlarmListService.selectTShouhuanAlarmStatusSolve());
-        return success(dto);
+        AlarmStatusDto alarmStatusDto = new AlarmStatusDto();
+        /** SOS告警处理 */
+        int alarmSOSSolve = tEarlyWarningService.selectTEarlyWarningCompletedCountByType(16);
+        alarmStatusDto.setAlarmSOSSolve(alarmSOSSolve);
+        /** SOS未告警处理 */
+        int un_alarmSOSSolve = tEarlyWarningService.selectTEarlyWarningUnCompletedCountByType(16);
+        alarmStatusDto.setUn_alarmSOSSolve(un_alarmSOSSolve);
+        /** 围栏告警处理 alarmRailSolve */
+//        int alarmRailSolve = tEarlyWarningService.selectTEarlyWarningCompletedCountByType();
+        alarmStatusDto.setAlarmRailSolve(0);
+        /** 围栏未告警处理 un_alarmRailSolve */
+//        int un_alarmRailSolve = tEarlyWarningService.selectTEarlyWarningUnCompletedCountByType();
+        alarmStatusDto.setUn_alarmRailSolve(0);
+        /** 心率告警处理 */
+        int alarmHeartSolve = tEarlyWarningService.selectTEarlyWarningCompletedCountByType(22);
+        alarmStatusDto.setAlarmHeartSolve(alarmHeartSolve);
+        /** 心率未告警处理 */
+        int un_alarmHeartSolve = tEarlyWarningService.selectTEarlyWarningUnCompletedCountByType(22);
+        alarmStatusDto.setUn_alarmHeartSolve(un_alarmHeartSolve);
+        /** 跌倒告警处理  */
+        int alarmFallSolve = tEarlyWarningService.selectTEarlyWarningCompletedCountByType(21);
+        alarmStatusDto.setAlarmFallSolve(alarmFallSolve);
+        /** 跌倒未告警处理  */
+        int un_alarmFallSolve = tEarlyWarningService.selectTEarlyWarningUnCompletedCountByType(21);
+        alarmStatusDto.setUn_alarmFallSolve(un_alarmFallSolve);
+        /** 低电告警处理 alarmLowSolve */
+        int alarmLowSolve = tEarlyWarningService.selectTEarlyWarningCompletedCountByType(17);
+        alarmStatusDto.setAlarmLowSolve(alarmLowSolve);
+        /** 低电未告警处理 un_alarmLowSolve */
+        int un_alarmLowSolve = tEarlyWarningService.selectTEarlyWarningUnCompletedCountByType(17);
+        alarmStatusDto.setUn_alarmLowSolve(un_alarmLowSolve);
+        /** 设备状态告警处理 alarmStatusSolve */
+        int alarmStatusSolve = tEarlyWarningService.selectTEarlyWarningCompletedCountByType(20);
+        alarmStatusDto.setAlarmStatusSolve(alarmStatusSolve);
+        /** 设备状态未告警处理 un_alarmStatusSolve */
+        int un_alarmStatusSolve = tEarlyWarningService.selectTEarlyWarningUnCompletedCountByType(20);
+        alarmStatusDto.setUn_alarmStatusSolve(un_alarmStatusSolve);
+        return success(alarmStatusDto);
     }
 
     @GetMapping("/percent")
     public AjaxResult percent() {
-        AlarmPercentDto dto = new AlarmPercentDto();
-        dto.setAlarmSOS(checkPercent(tShouhuanAlarmListService.selectTShouhuanAlarmSOSSolve(), tShouhuanAlarmListService.selectTShouhuanAlarmSOS()));
-        dto.setAlarmRail(checkPercent(tShouhuanAlarmListService.selectTShouhuanAlarmRailSolve(), tShouhuanAlarmListService.selectTShouhuanAlarmRail()));
-        dto.setAlarmFall(checkPercent(tShouhuanAlarmListService.selectTShouhuanAlarmFallSolve(), tShouhuanAlarmListService.selectTShouhuanAlarmFall()));
-        int statusSum = tShouhuanAlarmListService.selectTShouhuanAlarmStatus() + tShouhuanAlarmListService.selectTShouhuanAlarmStatusSolve();
-        dto.setAlarmStauts(checkPercent(tShouhuanAlarmListService.selectTShouhuanAlarmStatus(), statusSum));
-        int alarmAll = tShouhuanAlarmListService.selectTShouhuanAlarmSOSSolve() + tShouhuanAlarmListService.selectTShouhuanAlarmRailSolve() + tShouhuanAlarmListService.selectTShouhuanAlarmRailSolve() + tShouhuanAlarmListService.selectTShouhuanAlarmFallSolve() + tShouhuanAlarmListService.selectTShouhuanAlarmOtherSolve();
-        dto.setAlarmAll(checkPercent(alarmAll, tShouhuanAlarmListService.selectTShouhuanAlarmListCount()));
-        return success(dto);
+        AlarmPercentDto alarmPercentDto = new AlarmPercentDto();
+        /** SOS alarmSOS*/
+        Double alarmSOS = tEarlyWarningService.selectTEarlyWarningUnCompletedPercentageByType(16);
+        alarmPercentDto.setAlarmSOS((alarmSOS == null || alarmSOS.isNaN()) ? "0.00" : alarmSOS.toString());
+        /** 围栏 alarmRail*/
+//        Double alarmRail = tEarlyWarningService.selectTEarlyWarningUnCompletedPercentageByType();
+        alarmPercentDto.setAlarmRail("0.00");
+        /** 跌倒 alarmFall*/
+        Double alarmFall = tEarlyWarningService.selectTEarlyWarningUnCompletedPercentageByType(21);
+        alarmPercentDto.setAlarmFall((alarmFall == null || alarmFall.isNaN()) ? "0.00" : alarmFall.toString());
+        /** 在线 alarmStauts*/
+        Double alarmStauts = itShouhuanInfoService.selectTShouhuanInfoPercentage();
+        alarmPercentDto.setAlarmStauts((alarmStauts == null || alarmStauts.isNaN()) ? "0.00" : alarmStauts.toString());
+        /** 全部 alarmAll*/
+        Double alarmAll = tEarlyWarningService.selectTEarlyWarningUnCompletedPercentageByAllType();
+        alarmPercentDto.setAlarmAll((alarmAll == null || alarmAll.isNaN()) ? "0.00" : alarmAll.toString());
+        return success(alarmPercentDto);
     }
 
     @GetMapping("/deviceView")

+ 1 - 1
ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/TEarlyWarningController.java

@@ -1,4 +1,4 @@
-package com.ruoyi.system.controller;
+package com.ruoyi.web.controller.system;
 
 import java.util.List;
 import javax.servlet.http.HttpServletResponse;

+ 130 - 104
ruoyi-system/src/main/java/com/ruoyi/system/domain/TDeviceList.java

@@ -10,214 +10,240 @@ import java.util.Date;
 
 /**
  * 设备列对象 t_device_list
- * 
+ *
  * @author zhengjie
  * @date 2023-08-30
  */
-public class TDeviceList extends BaseEntity
-{
+public class TDeviceList extends BaseEntity {
     private static final long serialVersionUID = 1L;
 
-    /** id */
+    /**
+     * id
+     */
     private Integer id;
 
-    /** fid */
+    /**
+     * fid
+     */
     private Integer fid;
 
-    /** 设备属性 */
+    /**
+     * 设备属性
+     */
     private Integer deviceProper;
 
-    /** 用户ID */
+    /**
+     * 用户ID
+     */
     private Integer userid;
 
-    /** 身份证号码 */
+    /**
+     * 身份证号码
+     */
     @Excel(name = "身份证号码")
     private String sfzid;
 
-    /** 手机号 */
+    /**
+     * 手机号
+     */
     @Excel(name = "手机号")
     private String telno;
 
-    /** 工厂 */
+    /**
+     * 工厂
+     */
     @Excel(name = "工厂")
     private Integer factory;
 
-    /** 设备型号 */
+    /**
+     * 设备型号
+     */
     @Excel(name = "设备型号")
     private Integer deviceModel;
 
-    /** 设备标识ID */
+    /**
+     * 设备标识ID
+     */
     @Excel(name = "设备标识ID")
     private String deviceId;
 
-    /** SIM卡号 */
+    /**
+     * SIM卡号
+     */
     @Excel(name = "SIM卡号")
     private String simCode;
 
-    /** 设备序列号 */
+    /**
+     * 设备序列号
+     */
     @Excel(name = "设备序列号")
     private String serialNumber;
 
-    /** 发放方式 */
+    /**
+     * 发放方式
+     */
     @Excel(name = "发放方式")
     private Integer grantType;
 
-    /** 销售价格 */
+    /**
+     * 销售价格
+     */
     @Excel(name = "销售价格")
     private String price;
 
-    /** 服务费用 */
+    /**
+     * 服务费用
+     */
     @Excel(name = "服务费用")
     private String cost;
 
-    /** 支付方式 */
+    /**
+     * 支付方式
+     */
     @Excel(name = "支付方式")
     private Integer payment;
 
-    /** 是否注册成功 */
+    /**
+     * 是否注册成功
+     */
     private Integer status;
 
-    /** 用户姓名 */
+    /**
+     * 用户姓名
+     */
     @Excel(name = "用户姓名")
     private String name;
 
-    /** 联系方式 */
+    /**
+     * 联系方式
+     */
     private String tel_one;
 
-    /** 在线状态 */
+    /**
+     * 在线状态
+     */
     private Integer online_statis;
 
-    /** 设备电量 */
+    /**
+     * 设备电量
+     */
     private Integer electric_quantity;
 
-    /** 最后在线时间 */
+    /**
+     * 最后在线时间
+     */
     @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
     private Date offlinetime;
 
-    public void setId(Integer id) 
-    {
+    public void setId(Integer id) {
         this.id = id;
     }
 
-    public Integer getId() 
-    {
+    public Integer getId() {
         return id;
     }
-    public void setDeviceProper(Integer deviceProper) 
-    {
+
+    public void setDeviceProper(Integer deviceProper) {
         this.deviceProper = deviceProper;
     }
 
-    public Integer getDeviceProper() 
-    {
+    public Integer getDeviceProper() {
         return deviceProper;
     }
-    public void setUserid(Integer userid) 
-    {
+
+    public void setUserid(Integer userid) {
         this.userid = userid;
     }
 
-    public Integer getUserid() 
-    {
+    public Integer getUserid() {
         return userid;
     }
-    public void setSfzid(String sfzid) 
-    {
+
+    public void setSfzid(String sfzid) {
         this.sfzid = sfzid;
     }
 
-    public String getSfzid() 
-    {
+    public String getSfzid() {
         return sfzid;
     }
-    public void setTelno(String telno) 
-    {
+
+    public void setTelno(String telno) {
         this.telno = telno;
     }
 
-    public String getTelno() 
-    {
+    public String getTelno() {
         return telno;
     }
-    public void setFactory(Integer factory) 
-    {
+
+    public void setFactory(Integer factory) {
         this.factory = factory;
     }
 
-    public Integer getFactory() 
-    {
+    public Integer getFactory() {
         return factory;
     }
-    public void setDeviceModel(Integer deviceModel) 
-    {
+
+    public void setDeviceModel(Integer deviceModel) {
         this.deviceModel = deviceModel;
     }
 
-    public Integer getDeviceModel() 
-    {
+    public Integer getDeviceModel() {
         return deviceModel;
     }
-    public void setDeviceId(String deviceId) 
-    {
+
+    public void setDeviceId(String deviceId) {
         this.deviceId = deviceId;
     }
 
-    public String getDeviceId() 
-    {
+    public String getDeviceId() {
         return deviceId;
     }
-    public void setSimCode(String simCode) 
-    {
+
+    public void setSimCode(String simCode) {
         this.simCode = simCode;
     }
 
-    public String getSimCode() 
-    {
+    public String getSimCode() {
         return simCode;
     }
-    public void setSerialNumber(String serialNumber) 
-    {
+
+    public void setSerialNumber(String serialNumber) {
         this.serialNumber = serialNumber;
     }
 
-    public String getSerialNumber() 
-    {
+    public String getSerialNumber() {
         return serialNumber;
     }
-    public void setGrantType(Integer grantType) 
-    {
+
+    public void setGrantType(Integer grantType) {
         this.grantType = grantType;
     }
 
-    public Integer getGrantType() 
-    {
+    public Integer getGrantType() {
         return grantType;
     }
-    public void setPrice(String price) 
-    {
+
+    public void setPrice(String price) {
         this.price = price;
     }
 
-    public String getPrice() 
-    {
+    public String getPrice() {
         return price;
     }
-    public void setCost(String cost) 
-    {
+
+    public void setCost(String cost) {
         this.cost = cost;
     }
 
-    public String getCost() 
-    {
+    public String getCost() {
         return cost;
     }
-    public void setPayment(Integer payment) 
-    {
+
+    public void setPayment(Integer payment) {
         this.payment = payment;
     }
 
-    public Integer getPayment() 
-    {
+    public Integer getPayment() {
         return payment;
     }
 
@@ -279,29 +305,29 @@ public class TDeviceList extends BaseEntity
 
     @Override
     public String toString() {
-        return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
-            .append("id", getId())
-            .append("fid", getFid())
-            .append("deviceProper", getDeviceProper())
-            .append("userid", getUserid())
-            .append("sfzid", getSfzid())
-            .append("telno", getTelno())
-            .append("factory", getFactory())
-            .append("deviceModel", getDeviceModel())
-            .append("deviceId", getDeviceId())
-            .append("simCode", getSimCode())
-            .append("serialNumber", getSerialNumber())
-            .append("grantType", getGrantType())
-            .append("price", getPrice())
-            .append("cost", getCost())
-            .append("payment", getPayment())
-            .append("createTime", getCreateTime())
-            .append("status", getStatus())
-            .append("name", getName())
-            .append("tel_one", getTel_one())
-            .append("online_statis", getOnline_statis())
-            .append("electric_quantity", getElectric_quantity())
-            .append("offlinetime", getOfflinetime())
-            .toString();
+        return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE)
+                .append("id", getId())
+                .append("fid", getFid())
+                .append("deviceProper", getDeviceProper())
+                .append("userid", getUserid())
+                .append("sfzid", getSfzid())
+                .append("telno", getTelno())
+                .append("factory", getFactory())
+                .append("deviceModel", getDeviceModel())
+                .append("deviceId", getDeviceId())
+                .append("simCode", getSimCode())
+                .append("serialNumber", getSerialNumber())
+                .append("grantType", getGrantType())
+                .append("price", getPrice())
+                .append("cost", getCost())
+                .append("payment", getPayment())
+                .append("createTime", getCreateTime())
+                .append("status", getStatus())
+                .append("name", getName())
+                .append("tel_one", getTel_one())
+                .append("online_statis", getOnline_statis())
+                .append("electric_quantity", getElectric_quantity())
+                .append("offlinetime", getOfflinetime())
+                .toString();
     }
 }

+ 18 - 0
ruoyi-system/src/main/java/com/ruoyi/system/domain/TEarlyWarning.java

@@ -152,6 +152,12 @@ public class TEarlyWarning extends BaseEntity {
     @Excel(name = "事件类型")
     private Integer alarm_type;
 
+    /**
+     * 类型描述
+     */
+    @Excel(name = "类型描述")
+    private String typeDesc;
+
     public Long getId() {
         return id;
     }
@@ -225,6 +231,9 @@ public class TEarlyWarning extends BaseEntity {
     }
 
     public String getLocation() {
+        if (location == null) {
+            location = "";
+        }
         return location;
     }
 
@@ -344,6 +353,14 @@ public class TEarlyWarning extends BaseEntity {
         this.alarm_type = alarm_type;
     }
 
+    public String getTypeDesc() {
+        return typeDesc;
+    }
+
+    public void setTypeDesc(String typeDesc) {
+        this.typeDesc = typeDesc;
+    }
+
     @Override
     public String toString() {
         return new StringJoiner(", ", TEarlyWarning.class.getSimpleName() + "[", "]")
@@ -371,6 +388,7 @@ public class TEarlyWarning extends BaseEntity {
                 .add("store_name='" + store_name + "'")
                 .add("device_model='" + device_model + "'")
                 .add("alarm_type=" + alarm_type)
+                .add("typeDesc='" + typeDesc + "'")
                 .toString();
     }
 }

+ 31 - 0
ruoyi-system/src/main/java/com/ruoyi/system/mapper/TEarlyWarningMapper.java

@@ -72,4 +72,35 @@ public interface TEarlyWarningMapper {
     List<TEarlyWarning> selectTEarlyWarningList_HEALTHSOLVE(TEarlyWarning earlyWarning);
 
     List<TEarlyWarning> selectTEarlyWarningList_OTHERSOLVE(TEarlyWarning earlyWarning);
+
+    /**
+     * 查询类型已完成数量
+     *
+     * @param type
+     * @return
+     */
+    Integer selectTEarlyWarningCompletedCountByType(Integer type);
+
+    /**
+     * 查询类型未完成数量
+     *
+     * @param type
+     * @return
+     */
+    Integer selectTEarlyWarningUnCompletedCountByType(Integer type);
+
+    /**
+     * 查询类型未完成百分比
+     *
+     * @param type
+     * @return
+     */
+    Double selectTEarlyWarningUnCompletedPercentageByType(Integer type);
+
+    /**
+     * 查询类型未完成百分比
+     *
+     * @return
+     */
+    Double selectTEarlyWarningUnCompletedPercentageByAllType();
 }

+ 2 - 0
ruoyi-system/src/main/java/com/ruoyi/system/mapper/TShouhuanInfoMapper.java

@@ -75,4 +75,6 @@ public interface TShouhuanInfoMapper
     public List<MapGpsDto> selectMapGpsView();
 
     List<TShouhuanInfo> selectTShouhuanInfoListBydeviceIdCode(String deviceIdCode);
+
+    Double selectTShouhuanInfoPercentage();
 }

+ 32 - 0
ruoyi-system/src/main/java/com/ruoyi/system/service/ITEarlyWarningService.java

@@ -98,4 +98,36 @@ public interface ITEarlyWarningService {
      * @return
      */
     List<TEarlyWarning> selectTEarlyWarningList_OTHERSOLVE(TEarlyWarning earlyWarning);
+
+    /**
+     * 查询类型已完成数量
+     *
+     * @param type
+     * @return
+     */
+    Integer selectTEarlyWarningCompletedCountByType(Integer type);
+
+    /**
+     * 查询类型未完成数量
+     *
+     * @param type
+     * @return
+     */
+    Integer selectTEarlyWarningUnCompletedCountByType(Integer type);
+
+    /**
+     * 查询类型未完成百分比
+     *
+     * @param type
+     * @return
+     */
+    Double selectTEarlyWarningUnCompletedPercentageByType(Integer type);
+
+    /**
+     * 查询类型未完成百分比
+     *
+     * @return
+     */
+    Double selectTEarlyWarningUnCompletedPercentageByAllType();
+
 }

+ 16 - 9
ruoyi-system/src/main/java/com/ruoyi/system/service/ITShouhuanInfoService.java

@@ -1,20 +1,20 @@
 package com.ruoyi.system.service;
 
 import java.util.List;
+
 import com.ruoyi.system.domain.TShouhuanInfo;
 import com.ruoyi.system.domain.dto.MapGpsDto;
 
 /**
  * 手环信息 实时数据Service接口
- * 
+ *
  * @author ruoyi
  * @date 2023-09-07
  */
-public interface ITShouhuanInfoService 
-{
+public interface ITShouhuanInfoService {
     /**
      * 查询手环信息 实时数据
-     * 
+     *
      * @param id 手环信息 实时数据主键
      * @return 手环信息 实时数据
      */
@@ -22,7 +22,7 @@ public interface ITShouhuanInfoService
 
     /**
      * 查询手环信息 实时数据列表
-     * 
+     *
      * @param tShouhuanInfo 手环信息 实时数据
      * @return 手环信息 实时数据集合
      */
@@ -38,7 +38,7 @@ public interface ITShouhuanInfoService
 
     /**
      * 新增手环信息 实时数据
-     * 
+     *
      * @param tShouhuanInfo 手环信息 实时数据
      * @return 结果
      */
@@ -46,7 +46,7 @@ public interface ITShouhuanInfoService
 
     /**
      * 修改手环信息 实时数据
-     * 
+     *
      * @param tShouhuanInfo 手环信息 实时数据
      * @return 结果
      */
@@ -54,7 +54,7 @@ public interface ITShouhuanInfoService
 
     /**
      * 批量删除手环信息 实时数据
-     * 
+     *
      * @param ids 需要删除的手环信息 实时数据主键集合
      * @return 结果
      */
@@ -62,7 +62,7 @@ public interface ITShouhuanInfoService
 
     /**
      * 删除手环信息 实时数据信息
-     * 
+     *
      * @param id 手环信息 实时数据主键
      * @return 结果
      */
@@ -74,4 +74,11 @@ public interface ITShouhuanInfoService
      * @return 结果
      */
     public List<MapGpsDto> selectMapGpsView();
+
+    /**
+     * 查询在线百分比
+     *
+     * @return
+     */
+    Double selectTShouhuanInfoPercentage();
 }

+ 20 - 0
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TEarlyWarningServiceImpl.java

@@ -121,4 +121,24 @@ public class TEarlyWarningServiceImpl implements ITEarlyWarningService {
         //其他 预警类型
         return tEarlyWarningMapper.selectTEarlyWarningList_OTHERSOLVE(earlyWarning);
     }
+
+    @Override
+    public Integer selectTEarlyWarningCompletedCountByType(Integer type) {
+        return tEarlyWarningMapper.selectTEarlyWarningCompletedCountByType(type);
+    }
+
+    @Override
+    public Integer selectTEarlyWarningUnCompletedCountByType(Integer type) {
+        return tEarlyWarningMapper.selectTEarlyWarningUnCompletedCountByType(type);
+    }
+
+    @Override
+    public Double selectTEarlyWarningUnCompletedPercentageByType(Integer type) {
+        return tEarlyWarningMapper.selectTEarlyWarningUnCompletedPercentageByType(type);
+    }
+
+    @Override
+    public Double selectTEarlyWarningUnCompletedPercentageByAllType() {
+        return tEarlyWarningMapper.selectTEarlyWarningUnCompletedPercentageByAllType();
+    }
 }

+ 5 - 0
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TShouhuanInfoServiceImpl.java

@@ -102,4 +102,9 @@ public class TShouhuanInfoServiceImpl implements ITShouhuanInfoService
     public List<MapGpsDto> selectMapGpsView() {
         return tShouhuanInfoMapper.selectMapGpsView();
     }
+
+    @Override
+    public Double selectTShouhuanInfoPercentage() {
+        return tShouhuanInfoMapper.selectTShouhuanInfoPercentage();
+    }
 }

+ 35 - 14
ruoyi-system/src/main/java/com/ruoyi/system/timing/CallPoliceTiming.java

@@ -11,7 +11,9 @@ import org.springframework.stereotype.Component;
 
 import java.text.SimpleDateFormat;
 import java.util.Date;
+import java.util.HashMap;
 import java.util.List;
+import java.util.Map;
 
 @Component("callPoliceTiming")
 public class CallPoliceTiming {
@@ -37,7 +39,7 @@ public class CallPoliceTiming {
                 //已经处理过的不处理
                 List<TEarlyWarning> tEarlyWarnings = itEarlyWarningService.selectTEarlyWarningByAlarmId(info.getId());
                 if (tEarlyWarnings != null && !tEarlyWarnings.isEmpty()) {
-                    return;
+                    continue;
                 }
                 TEarlyWarning earlyWarning = new TEarlyWarning();
                 //查找对应的手环绑定用户
@@ -51,7 +53,9 @@ public class CallPoliceTiming {
                 // 类型:0-其他;1-SOS;2-跌倒;3-围栏;4-健康
                 earlyWarning.setType(info.getAlarm_type());
                 //告警内容
-                earlyWarning.setContent(getContentByType(info.getAlarm_type(), info.getCreatetime(), earlyWarning.getUserId()));
+                Map<String, String> map = getContentByType(info.getAlarm_type(), info.getCreatetime(), earlyWarning.getUserId());
+                earlyWarning.setTypeDesc(map.get("type_desc"));
+                earlyWarning.setContent(map.get("content"));
                 //事件记录
                 earlyWarning.setEventRecord("");
                 //预警定位
@@ -79,7 +83,7 @@ public class CallPoliceTiming {
      * @param userId
      * @return
      */
-    private String getContentByType(Integer alarmType, Date createtime, Long userId) {
+    private Map<String, String> getContentByType(Integer alarmType, Date createtime, Long userId) {
         //健康告警求助:成浪平于2023-09-27 15:17:02发起健康告警求助
         //设备对应的用户
         TUserProfile tUserProfile = null;
@@ -91,12 +95,15 @@ public class CallPoliceTiming {
         // 使用SimpleDateFormat对象将日期格式化为指定格式的字符串
         String time = dateFormat.format(createtime);
         StringBuilder stringBuilder = new StringBuilder();
+        String typeDesc = "";
         if (alarmType != null) {
             if (alarmType == 0) {
-                stringBuilder.append("无效报警!");
+                typeDesc = "无效报警";
+                stringBuilder.append(typeDesc).append("!");
             } else if (alarmType == 16) {
                 //16:SOS报警;
-                stringBuilder.append("SOS报警求助:");
+                typeDesc = "SOS报警";
+                stringBuilder.append(typeDesc).append("求助:");
                 if (tUserProfile != null) {
                     stringBuilder.append(tUserProfile.getName());
                 } else {
@@ -105,7 +112,8 @@ public class CallPoliceTiming {
                 stringBuilder.append("于").append(time).append("发起SOS报警求助!");
             } else if (alarmType == 17) {
                 //17:低电报警;
-                stringBuilder.append("低电报警:");
+                typeDesc = "低电报警";
+                stringBuilder.append(typeDesc).append(":");
                 if (tUserProfile != null) {
                     stringBuilder.append(tUserProfile.getName());
                 } else {
@@ -114,7 +122,8 @@ public class CallPoliceTiming {
                 stringBuilder.append("于").append(time).append("发起低电报警!");
             } else if (alarmType == 20) {
                 //20:手环拆除报警;
-                stringBuilder.append("手环拆除报警:");
+                typeDesc = "手环拆除报警";
+                stringBuilder.append(typeDesc).append(":");
                 if (tUserProfile != null) {
                     stringBuilder.append(tUserProfile.getName());
                 } else {
@@ -123,7 +132,8 @@ public class CallPoliceTiming {
                 stringBuilder.append("于").append(time).append("发起手环拆除报警!");
             } else if (alarmType == 21) {
                 //21:跌倒报警;
-                stringBuilder.append("跌倒报警:");
+                typeDesc = "跌倒报警";
+                stringBuilder.append(typeDesc).append(":");
                 if (tUserProfile != null) {
                     stringBuilder.append(tUserProfile.getName());
                 } else {
@@ -132,7 +142,8 @@ public class CallPoliceTiming {
                 stringBuilder.append("于").append(time).append("发起跌倒报警求助!");
             } else if (alarmType == 22) {
                 //22:心率异常报警,
-                stringBuilder.append("心率异常报警:");
+                typeDesc = "心率异常报警";
+                stringBuilder.append(typeDesc).append(":");
                 if (tUserProfile != null) {
                     stringBuilder.append(tUserProfile.getName());
                 } else {
@@ -141,7 +152,8 @@ public class CallPoliceTiming {
                 stringBuilder.append("于").append(time).append("发起心率异常报警求助!");
             } else if (alarmType == 23) {
                 //23:血压异常报警,
-                stringBuilder.append("血压异常报警:");
+                typeDesc = "血压异常报警";
+                stringBuilder.append(typeDesc).append(":");
                 if (tUserProfile != null) {
                     stringBuilder.append(tUserProfile.getName());
                 } else {
@@ -150,7 +162,8 @@ public class CallPoliceTiming {
                 stringBuilder.append("于").append(time).append("发起血压异常报警求助!");
             } else if (alarmType == 24) {
                 //24:体温异常报警
-                stringBuilder.append("体温异常报警:");
+                typeDesc = "体温异常报警";
+                stringBuilder.append(typeDesc).append(":");
                 if (tUserProfile != null) {
                     stringBuilder.append(tUserProfile.getName());
                 } else {
@@ -159,18 +172,26 @@ public class CallPoliceTiming {
                 stringBuilder.append("于").append(time).append("发起体温异常报警求助!");
             } else if (alarmType == 25) {
                 //25:血氧异常报警
-                stringBuilder.append("血氧异常报警:");
+                typeDesc = "血氧异常报警";
+                stringBuilder.append(typeDesc).append(":");
                 if (tUserProfile != null) {
                     stringBuilder.append(tUserProfile.getName());
                 } else {
                     stringBuilder.append("设备");
                 }
                 stringBuilder.append("于").append(time).append("发起血氧异常报警求助!");
+            } else {
+                typeDesc = "无效报警";
+                stringBuilder.append(typeDesc).append("!");
             }
         } else {
-
+            typeDesc = "无效报警";
+            stringBuilder.append(typeDesc).append("!");
         }
-        return stringBuilder.toString();
+        Map<String, String> map = new HashMap<>();
+        map.put("content", stringBuilder.toString());
+        map.put("type_desc", typeDesc);
+        return map;
     }
 
 }

+ 1 - 0
ruoyi-system/src/main/resources/mapper/system/TDeviceListMapper.xml

@@ -68,6 +68,7 @@
             <if test="price != null  and price != ''">and a.price = #{price}</if>
             <if test="cost != null  and cost != ''">and a.cost = #{cost}</if>
             <if test="payment != null ">and a.payment = #{payment}</if>
+            <if test="name != null ">and c.name = #{name}</if>
             <if test="online_statis != null ">and d.online_statis = #{online_statis}</if>
             <if test="offlinetime != null ">and d.offlinetime = #{offlinetime}</if>
         </where>

+ 33 - 3
ruoyi-system/src/main/resources/mapper/system/TEarlyWarningMapper.xml

@@ -19,6 +19,7 @@
         <result property="facilityId" column="facility_id"/>
         <result property="deviceIdCode" column="device_id_code"/>
         <result property="alarmId" column="alarm_id"/>
+        <result property="typeDesc"    column="type_desc"    />
     </resultMap>
 
     <sql id="selectTEarlyWarningVo">
@@ -35,7 +36,8 @@
                update_time,
                facility_id,
                device_id_code,
-               alarm_id
+               alarm_id,
+               type_desc
         from t_early_warning
     </sql>
 
@@ -57,6 +59,7 @@
             <if test="facilityId != null ">and facility_id = #{facilityId}</if>
             <if test="deviceIdCode != null  and deviceIdCode != ''">and device_id_code = #{deviceIdCode}</if>
             <if test="alarmId != null ">and alarm_id = #{alarmId}</if>
+            <if test="typeDesc != null  and typeDesc != ''"> and type_desc = #{typeDesc}</if>
         </where>
     </select>
 
@@ -72,7 +75,7 @@
         a.state as solve_status,
         a.type,
         a.type as alarm_type,
-        a.content as alarmMsg,
+        a.content ,
         a.event_record,
         a.event_record as msg,
         a.location,
@@ -87,6 +90,8 @@
         a.device_id_code,
         a.device_id_code as deviceIdCode,
         a.alarm_id,
+        a.type_desc as typeDesc,
+        a.type_desc as alarmMsg,
         b.name,
         b.tel_one,
         c.id as service_id,
@@ -124,6 +129,7 @@
         a.device_id_code,
         a.device_id_code as deviceIdCode,
         a.alarm_id,
+        a.type_desc,
         b.name,
         b.tel_one,
         c.id as service_id,
@@ -162,6 +168,7 @@
         a.device_id_code,
         a.device_id_code as deviceIdCode,
         a.alarm_id,
+        a.type_desc,
         b.name,
         b.tel_one,
         c.id as service_id,
@@ -182,7 +189,27 @@
             <if test="solve_status != null ">and a.state = #{solve_status}</if>
         </where>
     </select>
-
+    <select id="selectTEarlyWarningCompletedCountByType" parameterType="Integer" resultType="java.lang.Integer">
+        SELECT COUNT(*)
+        FROM t_early_warning
+        WHERE type = #{type}
+          AND state = 1;
+    </select>
+    <select id="selectTEarlyWarningUnCompletedCountByType" parameterType="Integer" resultType="java.lang.Integer">
+        SELECT COUNT(*)
+        FROM t_early_warning
+        WHERE type = #{type}
+          AND state = 0;
+    </select>
+    <select id="selectTEarlyWarningUnCompletedPercentageByType" parameterType="Integer" resultType="java.lang.Double">
+        SELECT (COUNT(CASE WHEN state = 1 THEN 0 END) / COUNT(*) * 100)
+        FROM t_early_warning
+        WHERE type = #{type}
+    </select>
+    <select id="selectTEarlyWarningUnCompletedPercentageByAllType" resultType="java.lang.Double">
+        SELECT (COUNT(CASE WHEN state = 1 THEN 0 END) / COUNT(*) * 100)
+        FROM t_early_warning
+    </select>
     <insert id="insertTEarlyWarning" parameterType="TEarlyWarning" useGeneratedKeys="true" keyProperty="id">
         insert into t_early_warning
         <trim prefix="(" suffix=")" suffixOverrides=",">
@@ -199,6 +226,7 @@
             <if test="facilityId != null">facility_id,</if>
             <if test="deviceIdCode != null">device_id_code,</if>
             <if test="alarmId != null">alarm_id,</if>
+            <if test="typeDesc != null">type_desc,</if>
         </trim>
         <trim prefix="values (" suffix=")" suffixOverrides=",">
             <if test="userId != null">#{userId},</if>
@@ -214,6 +242,7 @@
             <if test="facilityId != null">#{facilityId},</if>
             <if test="deviceIdCode != null">#{deviceIdCode},</if>
             <if test="alarmId != null">#{alarmId},</if>
+            <if test="typeDesc != null">#{typeDesc},</if>
         </trim>
     </insert>
 
@@ -233,6 +262,7 @@
             <if test="facilityId != null">facility_id = #{facilityId},</if>
             <if test="deviceIdCode != null">device_id_code = #{deviceIdCode},</if>
             <if test="alarmId != null">alarm_id = #{alarmId},</if>
+            <if test="typeDesc != null">type_desc = #{typeDesc},</if>
         </trim>
         where id = #{id}
     </update>

+ 5 - 0
ruoyi-system/src/main/resources/mapper/system/TShouhuanInfoMapper.xml

@@ -149,6 +149,11 @@
         <include refid="selectTShouhuanInfoVo"/>
         where device_id_code = #{device_id_code}
     </select>
+    <select id="selectTShouhuanInfoPercentage" resultType="java.lang.Double">
+        SELECT (COUNT(*) * 100 / (SELECT COUNT(*) FROM t_device_list))
+        FROM t_shouhuan_info
+        WHERE online_statis = 1;
+    </select>
 
     <insert id="insertTShouhuanInfo" parameterType="TShouhuanInfo" useGeneratedKeys="true" keyProperty="id">
         insert into t_shouhuan_info