Browse Source

首页——设备当前运行数

LLL 1 year ago
parent
commit
ef9eef334a

+ 16 - 0
module_tpm/src/main/java/org/jeecg/modules/Statistics/controller/StatisticsController.java

@@ -11,6 +11,7 @@ import org.jeecg.common.system.base.controller.JeecgController;
 import org.jeecg.common.system.query.QueryGenerator;
 import org.jeecg.common.system.query.QueryGenerator;
 import org.jeecg.modules.Statistics.entity.Statistics;
 import org.jeecg.modules.Statistics.entity.Statistics;
 import org.jeecg.modules.Statistics.service.IStatisticsService;
 import org.jeecg.modules.Statistics.service.IStatisticsService;
+import org.jeecg.modules.Statistics.vo.StatisticsVo;
 import org.jeecg.modules.equipmentOnoffSection.entity.EquipmentOnoffSection;
 import org.jeecg.modules.equipmentOnoffSection.entity.EquipmentOnoffSection;
 import org.jeecg.modules.tpmTag.entity.TpmTag;
 import org.jeecg.modules.tpmTag.entity.TpmTag;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -20,6 +21,9 @@ import org.springframework.web.bind.annotation.RequestParam;
 import org.springframework.web.bind.annotation.RestController;
 import org.springframework.web.bind.annotation.RestController;
 
 
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletRequest;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.List;
 import java.util.Map;
 import java.util.Map;
 
 
 /**
 /**
@@ -38,6 +42,18 @@ public class StatisticsController extends JeecgController<Statistics, IStatistic
     private IStatisticsService statisticsService;
     private IStatisticsService statisticsService;
 
 
     /**
     /**
+     * 今日开机数
+     */
+    @ApiOperation("今日开机数")
+    @GetMapping("/machineSum")
+    public Result<List<StatisticsVo>> firstLoad()
+    {
+        // 今日开机数
+        List<StatisticsVo> list = statisticsService.selectEquipmentStatus();
+        return Result.OK(list);
+    }
+
+    /**
      * 获取某设备实时数据-列表(按日期)
      * 获取某设备实时数据-列表(按日期)
      *
      *
      * @param statistics
      * @param statistics

+ 8 - 0
module_tpm/src/main/java/org/jeecg/modules/Statistics/mapper/StatisticsMapper.java

@@ -5,11 +5,19 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import org.apache.ibatis.annotations.Param;
 import org.apache.ibatis.annotations.Param;
 import org.jeecg.modules.Statistics.entity.Statistics;
 import org.jeecg.modules.Statistics.entity.Statistics;
+import org.jeecg.modules.Statistics.vo.StatisticsVo;
 
 
 import java.util.List;
 import java.util.List;
 
 
 public interface StatisticsMapper extends BaseMapper<Statistics> {
 public interface StatisticsMapper extends BaseMapper<Statistics> {
 
 
+    /**
+     * 分类查询设备状态
+     *
+     * @return 设备状态汇总
+     */
+    public List<StatisticsVo> selectEquipmentStatus();
+
 
 
     /**
     /**
      * 依据设备ID和日期查询 实时数据-翻页(日期段)
      * 依据设备ID和日期查询 实时数据-翻页(日期段)

+ 36 - 1
module_tpm/src/main/java/org/jeecg/modules/Statistics/mapper/xml/StatisticsMapper.xml

@@ -20,6 +20,41 @@
         <result property="dayofweek"    column="dayofweek"    />
         <result property="dayofweek"    column="dayofweek"    />
     </resultMap>
     </resultMap>
 
 
+    <resultMap type="org.jeecg.modules.Statistics.vo.StatisticsVo" id="TpmStatisticsResult">
+        <result property="equipmentid"    column="equipmentid"    />
+        <result property="equipmentname"    column="equipmentname"    />
+        <result property="year"    column="year"    />
+        <result property="month"    column="month"    />
+        <result property="week"    column="week"    />
+        <result property="day"    column="day"    />
+        <result property="dayofweek"    column="dayofweek"    />
+        <result property="howManyTimes"    column="howManyTimes"    />
+        <result property="howManyTimes2"    column="howManyTimes2"    />
+        <result property="type"    column="type"    />
+    </resultMap>
+
+    <!--分类查询设备状态-->
+    <select id="selectEquipmentStatus" resultMap="TpmStatisticsResult">
+        select 'normal' as type, count(*) as howManyTimes
+        from tpm_equipment_status
+        where status in ('0')
+        union
+        select 'run' as type, count(*) as howManyTimes
+        from tpm_equipment_status
+        where status in ('1')
+        union
+        select 'standby' as type, count(*) as howManyTimes
+        from tpm_equipment_status
+        where status in ('2')
+        union
+        select 'stop' as type, count(*) as howManyTimes
+        from tpm_equipment_status
+        where status in ('3')
+        union
+        select 'all' as type, count(*) as howManyTimes
+        from tpm_equipment_status
+    </select>
+
     <!--依据设备ID和日期查询 实时数据-翻页(日期段)-->
     <!--依据设备ID和日期查询 实时数据-翻页(日期段)-->
     <select id="selectDataPagesBySectionDay" resultMap="StatisticsResult">
     <select id="selectDataPagesBySectionDay" resultMap="StatisticsResult">
         select *
         select *
@@ -52,4 +87,4 @@
         order by id asc
         order by id asc
     </select>
     </select>
 
 
-</mapper>
+</mapper>

+ 8 - 0
module_tpm/src/main/java/org/jeecg/modules/Statistics/service/IStatisticsService.java

@@ -5,6 +5,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.baomidou.mybatisplus.extension.service.IService;
 import com.baomidou.mybatisplus.extension.service.IService;
 import org.jeecg.common.api.vo.Result;
 import org.jeecg.common.api.vo.Result;
 import org.jeecg.modules.Statistics.entity.Statistics;
 import org.jeecg.modules.Statistics.entity.Statistics;
+import org.jeecg.modules.Statistics.vo.StatisticsVo;
 import org.jeecg.modules.equipmentOnoffSection.entity.EquipmentOnoffSection;
 import org.jeecg.modules.equipmentOnoffSection.entity.EquipmentOnoffSection;
 import org.jeecg.modules.tpmTag.entity.TpmTag;
 import org.jeecg.modules.tpmTag.entity.TpmTag;
 
 
@@ -15,6 +16,13 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 public interface IStatisticsService extends IService<Statistics> {
 public interface IStatisticsService extends IService<Statistics> {
 
 
     /**
     /**
+     * 分类查询设备状态
+     *
+     * @return 设备状态汇总
+     */
+    public List<StatisticsVo> selectEquipmentStatus();
+
+    /**
      * 依据设备ID和日期查询 实时数据(日期)
      * 依据设备ID和日期查询 实时数据(日期)
      *
      *
      * @param equipmentid 设备ID
      * @param equipmentid 设备ID

+ 10 - 0
module_tpm/src/main/java/org/jeecg/modules/Statistics/service/impl/StatisticsServiceImpl.java

@@ -8,6 +8,7 @@ import org.jeecg.common.system.query.QueryGenerator;
 import org.jeecg.modules.Statistics.entity.Statistics;
 import org.jeecg.modules.Statistics.entity.Statistics;
 import org.jeecg.modules.Statistics.mapper.StatisticsMapper;
 import org.jeecg.modules.Statistics.mapper.StatisticsMapper;
 import org.jeecg.modules.Statistics.service.IStatisticsService;
 import org.jeecg.modules.Statistics.service.IStatisticsService;
+import org.jeecg.modules.Statistics.vo.StatisticsVo;
 import org.jeecg.modules.common.TableNameConstants;
 import org.jeecg.modules.common.TableNameConstants;
 import org.jeecg.modules.common.TagTypeConstants;
 import org.jeecg.modules.common.TagTypeConstants;
 import org.jeecg.modules.tpmTag.entity.TpmTag;
 import org.jeecg.modules.tpmTag.entity.TpmTag;
@@ -31,6 +32,15 @@ public class StatisticsServiceImpl extends ServiceImpl<StatisticsMapper, Statist
     private TpmTagMapper tagMapper;
     private TpmTagMapper tagMapper;
 
 
     /**
     /**
+     * 分类查询设备状态
+     *
+     * @return 设备状态汇总
+     */
+    public List<StatisticsVo> selectEquipmentStatus(){
+        return statisticsMapper.selectEquipmentStatus();
+    }
+
+    /**
      * 依据设备ID和日期查询 实时数据-列表(日期)
      * 依据设备ID和日期查询 实时数据-列表(日期)
      * @param page
      * @param page
      * @param equipmentid 设备id
      * @param equipmentid 设备id

+ 43 - 0
module_tpm/src/main/java/org/jeecg/modules/Statistics/vo/StatisticsVo.java

@@ -0,0 +1,43 @@
+package org.jeecg.modules.Statistics.vo;
+
+import lombok.Data;
+
+import java.util.List;
+
+@Data
+public class StatisticsVo {
+
+    /** 设备id */
+    private Long equipmentid;
+
+    /** 设备名称 */
+    private String equipmentname;
+
+    /** 所属年*/
+    private Long year;
+
+    /** 所属月*/
+    private Long month;
+
+    /** 所属周*/
+    private Long week;
+
+    /** 日期*/
+    private String day;
+
+    /** 周几*/
+    private Long dayofweek;
+
+    /**发生次数*/
+    private Long howManyTimes;
+
+    /**发生次数*/
+    private Long howManyTimes2;
+
+    /**查询ids*/
+    private List<Long> ids;
+
+    /** 类别 */
+    private String type;
+
+}