Переглянути джерело

实现及调试APP动环诊断

jiawuxian 1 рік тому
батько
коміт
6b3927c0f6

+ 10 - 0
project_data/sql/0.0.6-iot/soc/soc.sql

@@ -846,3 +846,13 @@ INSERT INTO `sys_dict_data`(`dict_sort`, `dict_label`, `dict_value`, `dict_type`
 INSERT INTO `sys_dict_data`(`dict_sort`, `dict_label`, `dict_value`, `dict_type`, `css_class`, `list_class`, `is_default`, `status`, `create_by`, `create_time`, `update_by`, `update_time`, `remark`) VALUES (400, '水浸传感器', '4184', 'sensor_device_type', NULL, 'default', 'N', '0', NULL, now(), NULL, NULL, NULL);
 INSERT INTO `sys_dict_data`(`dict_sort`, `dict_label`, `dict_value`, `dict_type`, `css_class`, `list_class`, `is_default`, `status`, `create_by`, `create_time`, `update_by`, `update_time`, `remark`) VALUES (500, '门磁、窗磁传感器', '4188', 'sensor_device_type', NULL, 'default', 'N', '0', NULL, now(), NULL, NULL, NULL);
 INSERT INTO `sys_dict_data`(`dict_sort`, `dict_label`, `dict_value`, `dict_type`, `css_class`, `list_class`, `is_default`, `status`, `create_by`, `create_time`, `update_by`, `update_time`, `remark`) VALUES (600, '燃气报警器', '41885', 'sensor_device_type', NULL, 'default', 'N', '0', NULL, now(), NULL, NULL, NULL);
+
+delete from sys_dict_type where dict_type in ('app_sensor_device_type');
+delete from sys_dict_data where dict_type in ('app_sensor_device_type');
+INSERT INTO `sys_dict_type` (`dict_id`, `dict_name`, `dict_type`, `status`, `create_by`, `create_time`, `update_by`, `update_time`, `remark`) VALUES (20231113254, 'App动环传感器设备类型', 'app_sensor_device_type', '0', '超级管理员', '2024-03-04 16:21:31', '', NULL, '值与web应保持一致,文本有差异');
+INSERT INTO `sys_dict_data` (`dict_code`, `dict_sort`, `dict_label`, `dict_value`, `dict_type`, `css_class`, `list_class`, `is_default`, `status`, `create_by`, `create_time`, `update_by`, `update_time`, `remark`) VALUES (20231115451, 0, '温湿度', '4183', 'app_sensor_device_type', NULL, 'default', 'N', '0', '超级管理员', '2024-03-04 16:22:31', '', NULL, NULL);
+INSERT INTO `sys_dict_data` (`dict_code`, `dict_sort`, `dict_label`, `dict_value`, `dict_type`, `css_class`, `list_class`, `is_default`, `status`, `create_by`, `create_time`, `update_by`, `update_time`, `remark`) VALUES (20231115452, 1, '红外', '4181', 'app_sensor_device_type', NULL, 'default', 'N', '0', '超级管理员', '2024-03-04 16:22:41', '超级管理员', '2024-03-04 16:22:45', NULL);
+INSERT INTO `sys_dict_data` (`dict_code`, `dict_sort`, `dict_label`, `dict_value`, `dict_type`, `css_class`, `list_class`, `is_default`, `status`, `create_by`, `create_time`, `update_by`, `update_time`, `remark`) VALUES (20231115453, 2, '烟感', '4182', 'app_sensor_device_type', NULL, 'default', 'N', '0', '超级管理员', '2024-03-04 16:22:58', '', NULL, NULL);
+INSERT INTO `sys_dict_data` (`dict_code`, `dict_sort`, `dict_label`, `dict_value`, `dict_type`, `css_class`, `list_class`, `is_default`, `status`, `create_by`, `create_time`, `update_by`, `update_time`, `remark`) VALUES (20231115454, 3, '水浸', '4184', 'app_sensor_device_type', NULL, 'default', 'N', '0', '超级管理员', '2024-03-04 16:23:16', '', NULL, NULL);
+INSERT INTO `sys_dict_data` (`dict_code`, `dict_sort`, `dict_label`, `dict_value`, `dict_type`, `css_class`, `list_class`, `is_default`, `status`, `create_by`, `create_time`, `update_by`, `update_time`, `remark`) VALUES (20231115455, 4, '门窗磁', '4188', 'app_sensor_device_type', NULL, 'default', 'N', '0', '超级管理员', '2024-03-04 16:23:38', '', NULL, NULL);
+INSERT INTO `sys_dict_data` (`dict_code`, `dict_sort`, `dict_label`, `dict_value`, `dict_type`, `css_class`, `list_class`, `is_default`, `status`, `create_by`, `create_time`, `update_by`, `update_time`, `remark`) VALUES (20231115456, 5, '燃气', '41885', 'app_sensor_device_type', NULL, 'default', 'N', '0', '超级管理员', '2024-03-04 16:23:49', '', NULL, NULL);

+ 5 - 0
soc-common/soc-common-core/src/main/java/com/xunmei/common/core/constant/DictConstants.java

@@ -291,4 +291,9 @@ public class DictConstants {
      * 动环传感器设备类型
      */
     public static final String SENSOR_DEVICE_TYPE = "sensor_device_type";
+
+    /**
+     * APP动环传感器设备类型
+     */
+    public static final String APP_SENSOR_DEVICE_TYPE = "app_sensor_device_type";
 }

+ 1 - 1
soc-modules/soc-modules-iot/src/main/java/com/xunmei/iot/mapper/IotCommonSensorMapper.java

@@ -37,5 +37,5 @@ public interface IotCommonSensorMapper extends BaseMapper<IotSensor> {
 
     Page<SensorAppPageVo> selectAppPageData(Page<SensorAppPageVo> pageRequest, @Param("request") SensorAppPageDto request);
 
-    SensorAppStateVo stateStatistic(SensorAppPageDto request);
+    SensorAppStateVo stateStatistic(@Param("request") SensorAppPageDto request);
 }

+ 11 - 6
soc-modules/soc-modules-iot/src/main/java/com/xunmei/iot/service/impl/IotCommonSensorServiceImpl.java

@@ -113,17 +113,13 @@ public class IotCommonSensorServiceImpl extends ServiceImpl<IotCommonSensorMappe
 
     @Override
     public TableDataInfo<SensorAppPageVo> selectSensorDataAppPage(SensorAppPageDto request) {
-        final SysOrg sysOrg = orgService.selectOrgById(request.getOrgId(), SecurityConstants.INNER);
-        if (ObjectUtil.equal(Boolean.TRUE, request.getCheckSub())) {
-            request.setOrgPath(sysOrg.getPath());
-            request.setOrgId(null);
-        }
+        dealAppPageParam(request);
 
         Page<SensorAppPageVo> page = sensorMapper.selectAppPageData(request.getPageRequest(), request);
         for (SensorAppPageVo record : page.getRecords()) {
             final String info = record.getInfo();
             record.setInfo(dealInfoData(info));
-            record.setDeviceType(DictUtils.getDictLabel(DictConstants.SENSOR_DEVICE_TYPE, Integer.parseInt(record.getDeviceType())));
+            record.setDeviceType(DictUtils.getDictLabel(DictConstants.APP_SENSOR_DEVICE_TYPE, Integer.parseInt(record.getDeviceType())));
             record.setStateText(DictUtils.getDictLabel(DictConstants.SENSOR_ALARM_STATUS, record.getState()));
         }
 
@@ -132,6 +128,7 @@ public class IotCommonSensorServiceImpl extends ServiceImpl<IotCommonSensorMappe
 
     @Override
     public SensorAppStateVo stateStatistic(SensorAppPageDto request) {
+        dealAppPageParam(request);
         SensorAppStateVo vo = baseMapper.stateStatistic(request);
 
         return vo;
@@ -153,6 +150,14 @@ public class IotCommonSensorServiceImpl extends ServiceImpl<IotCommonSensorMappe
         return vo;
     }
 
+    private void dealAppPageParam(SensorAppPageDto request) {
+        final SysOrg sysOrg = orgService.selectOrgById(request.getOrgId(), SecurityConstants.INNER);
+        if (ObjectUtil.equal(Boolean.TRUE, request.getCheckSub())) {
+            request.setOrgPath(sysOrg.getPath());
+            request.setOrgId(null);
+        }
+    }
+
     private void dealPageParam(SensorPageDto request) {
         final SysOrg sysOrg = orgService.selectOrgById(request.getOrgId(), SecurityConstants.INNER);
         if (ObjectUtil.equal(Boolean.TRUE, request.getCheckSub())) {

+ 1 - 1
soc-modules/soc-modules-iot/src/main/java/com/xunmei/iot/vo/sensor/SensorAppPageVo.java

@@ -33,7 +33,7 @@ public class SensorAppPageVo {
 
     @JsonFormat(pattern = Constants.HMS_FORMAT)
     @ApiModelProperty("上报时间")
-    private LocalDateTime statusUpdateTime;
+    private LocalDateTime stateUpdateTime;
 
     @ApiModelProperty("上报内容")
     private String info;

+ 6 - 2
soc-modules/soc-modules-iot/src/main/java/com/xunmei/iot/vo/sensor/SensorAppVo.java

@@ -36,8 +36,12 @@ public class SensorAppVo {
 
     @JsonFormat(pattern = Constants.HMS_FORMAT)
     @ApiModelProperty("上报时间")
-    private LocalDateTime statusUpdateTime;
+    private LocalDateTime stateUpdateTime;
+
+    @JsonFormat(pattern = Constants.HMS_FORMAT)
+    @ApiModelProperty("状态变化时间")
+    private LocalDateTime stateStartTime;
 
     @ApiModelProperty("上报内容")
-    private String info;
+    private String infos;
 }

+ 3 - 2
soc-modules/soc-modules-iot/src/main/resources/mapper/IotSensorMapper.xml

@@ -28,7 +28,7 @@
         </if>
     </select>
     <select id="selectAppPageData" resultType="com.xunmei.iot.vo.sensor.SensorAppPageVo">
-        select s.id,org_name, device_name, device_type, infos as info,device_code, status_update_time ,state
+        select s.id,org_name, device_name, device_type, infos as info,device_code, state_update_time ,state
         from iot_sensor s
         where s.deleted=0
         <if test="request.orgId!= null">
@@ -45,7 +45,8 @@
         </if>
     </select>
     <select id="stateStatistic" resultType="com.xunmei.iot.vo.sensor.SensorAppStateVo">
-        SELECT count(state=0) as normal,count(state=1) as alarm from iot_sensor
+        SELECT sum(state=0) as normal,
+        sum(state=1) as alarm
         from iot_sensor s
         where s.deleted=0
         <if test="request.orgId!= null">