瀏覽代碼

几个小的修改

dongjh 1 年之前
父節點
當前提交
a3e11cbd8c

+ 1 - 1
module_ems/src/main/java/org/jeecg/modules/cronJob/GenerateDataJob.java

@@ -83,7 +83,7 @@ public class GenerateDataJob  {
                     DataElectricity dataElectricity = new DataElectricity();
                     BeanUtils.copyProperties(dataDemand, dataElectricity);
                     Double value = randomData(7);
-                    dataElectricity.setElectricityvalue(value);
+                    dataElectricity.setTagvalue2(value);
 /*
                     LambdaQueryWrapper<DataElectricity> wrapper = new LambdaQueryWrapper<>();
                     wrapper.eq(DataElectricity::getEquipmentid, equipment.getId());

+ 1 - 1
module_ems/src/main/java/org/jeecg/modules/dataElectricity/entity/DataElectricity.java

@@ -65,7 +65,7 @@ public class DataElectricity implements Serializable {
 	/**分时电量*/
 	@Excel(name = "分时电量", width = 15)
     @ApiModelProperty(value = "分时电量")
-    private java.lang.Double electricityvalue;
+    private java.lang.Double tagvalue2;
 	/**所属年*/
 	@Excel(name = "所属年", width = 15)
     @ApiModelProperty(value = "所属年")

+ 2 - 2
module_ems/src/main/java/org/jeecg/modules/dataElectricity/mapper/xml/DataElectricityMapper.xml

@@ -10,7 +10,7 @@
         <result property="equipmentname"    column="equipmentname"    />
         <result property="logtime"    column="logtime"    />
         <result property="tagvalue"    column="tagvalue"    />
-        <result property="electricityvalue"    column="electricityvalue"    />
+        <result property="tagvalue2"    column="tagvalue2"    />
         <result property="year"    column="year"    />
         <result property="month"    column="month"    />
         <result property="day"    column="day"    />
@@ -24,7 +24,7 @@
 
     <!--按日期查询电量-->
     <select id="selectElectricityByDay" parameterType="org.jeecg.modules.dataElectricity.entity.DataElectricity" resultMap="DataElectricityResult">
-        select tagname, equipmentid, equipmentname, logtime, electricityvalue as tagvalue, time
+        select tagname, equipmentid, equipmentname, logtime, tagvalue2 as tagvalue, time
         from ems_data_electricity
         <where>
             <if test="equipmentid != null and equipmentid != ''"> and equipmentid = #{equipmentid}</if>

+ 1 - 1
module_ems/src/main/java/org/jeecg/modules/dataElectricityDay/entity/DataElectricityDay.java

@@ -61,7 +61,7 @@ public class DataElectricityDay implements Serializable {
 	/**一天电量*/
 	@Excel(name = "一天电量", width = 15)
     @ApiModelProperty(value = "一天电量")
-    private java.lang.Double electricityvalue;
+    private java.lang.Double tagvalue2;
 	/**所属年*/
 	@Excel(name = "所属年", width = 15)
     @ApiModelProperty(value = "所属年")

+ 15 - 15
module_ems/src/main/java/org/jeecg/modules/emsStatistics/mapper/xml/EmsStatisticsMapper.xml

@@ -6,7 +6,7 @@
 
 
     <select id="selectMonthElectricity" resultType="org.jeecg.modules.emsStatistics.entity.EmsStatistics">
-        select equipmentid,equipmentname,year,month,ifnull(sum(electricityvalue),0) as howManyValue
+        select equipmentid,equipmentname,year,month,ifnull(sum(tagvalue2),0) as howManyValue
         from ems_data_electricity_day
         where year=#{year} and month=#{month}
         and equipmentid in
@@ -18,7 +18,7 @@
         limit 5;
     </select>
     <select id="selectMonthEquipElectricity" resultType="org.jeecg.modules.emsStatistics.entity.EmsStatistics">
-        select equipmentid,equipmentname,year,month,ifnull(sum(electricityvalue),0) as howManyValue2
+        select equipmentid,equipmentname,year,month,ifnull(sum(tagvalue2),0) as howManyValue2
         from ems_data_electricity_day
         where year=#{year} and month=#{month} and equipmentid=#{equipmentid}
         limit 1;
@@ -45,7 +45,7 @@
                         ) as b
     </select>
     <select id="selectEnvironment" resultType="org.jeecg.modules.emsStatistics.entity.EmsStatistics">
-        select 'CO2排放' as type, round(max(electricityvalue)*(select co2 from base_energy_type where name='电' limit 1), 3) as howManyValue
+        select 'CO2排放' as type, round(max(tagvalue2)*(select co2 from base_energy_type where name='电' limit 1), 3) as howManyValue
         from ems_data_electricity_day
         where year=#{year} and month=#{month}
         and equipmentid in
@@ -68,28 +68,28 @@
         ) as b
     </select>
     <select id="selectKgceMonthTotal" resultType="org.jeecg.modules.emsStatistics.entity.EmsStatistics">
-        select 290016788021249 as energyitemid,'动力用电' as type,round(ifnull(sum(e.electricityvalue),0)*y.kgce,3) as howManyValue
+        select 290016788021249 as energyitemid,'动力用电' as type,round(ifnull(sum(e.tagvalue2),0)*y.kgce,3) as howManyValue
         from ems_data_electricity_day as e,base_energy_type as y
         where e.year=#{year} and e.month=#{month} and e.equipmentid in (301156930748417,301156962205697) and y.name='电'
         union
-        select 290016823672833 as energyitemid,'空调用电' as type,round(ifnull(sum(e.electricityvalue),0)*y.kgce,3) as howManyValue
+        select 290016823672833 as energyitemid,'空调用电' as type,round(ifnull(sum(e.tagvalue2),0)*y.kgce,3) as howManyValue
         from ems_data_electricity_day as e,base_energy_type as y
         where e.year=#{year} and e.month=#{month} and e.equipmentid in (301156947525633) and y.name='电'
         union
         select 290016857227265 as energyitemid,'其它用电' as type,
                round((
                              (
-                                 select ifnull(sum(electricityvalue),0)
+                                 select ifnull(sum(tagvalue2),0)
                                  from ems_data_electricity_day
                                  where equipmentid in (301156882513921) and year=#{year} and month=#{month}
                              ) -
                              (
-                                 select ifnull(sum(electricityvalue),0)
+                                 select ifnull(sum(tagvalue2),0)
                                  from ems_data_electricity_day
                                  where equipmentid in (301156930748417,301156962205697) and year=#{year} and month=#{month}
                              ) -
                              (
-                                 select ifnull(sum(electricityvalue),0)
+                                 select ifnull(sum(tagvalue2),0)
                                  from ems_data_electricity_day
                                  where equipmentid in (301156947525633) and year=#{year} and month=#{month}
                              )
@@ -98,7 +98,7 @@
         where y.name='电'
     </select>
     <select id="selectKgceMonth" resultType="org.jeecg.modules.emsStatistics.entity.EmsStatistics">
-        select t.energyitemid,i.energyitemname as type,round(ifnull(sum(e.electricityvalue),0)*y.kgce,3) as howManyValue
+        select t.energyitemid,i.energyitemname as type,round(ifnull(sum(e.tagvalue2),0)*y.kgce,3) as howManyValue
         from ems_data_electricity_day as e,tpm_tag as t,base_energy_item as i,base_energy_type as y
         where e.tagid=t.id and t.energyitemid=i.id and e.year=#{year} and e.month=#{month}
         and i.energytypeid=y.id and y.name='电'
@@ -110,33 +110,33 @@
     </select>
     <select id="selectItemByEquipidAndDayTotal"
             resultType="org.jeecg.modules.emsStatistics.entity.EmsStatistics">
-        select 290016788021249 as energyitemid,'动力用电' as equipmentname, '能耗分项' as type,ifnull(sum(e.electricityvalue),0) as howManyValue
+        select 290016788021249 as energyitemid,'动力用电' as equipmentname, '能耗分项' as type,ifnull(sum(e.tagvalue2),0) as howManyValue
         from ems_data_electricity_day as e
         where e.day=#{day} and e.equipmentid in (301156930748417,301156962205697)
         union
-        select 290016823672833 as energyitemid,'空调用电' as equipmentname, '能耗分项' as type,ifnull(sum(e.electricityvalue),0) as howManyValue
+        select 290016823672833 as energyitemid,'空调用电' as equipmentname, '能耗分项' as type,ifnull(sum(e.tagvalue2),0) as howManyValue
         from ems_data_electricity_day as e
         where e.day=#{day} and e.equipmentid in (301156947525633)
         union
         select 290016857227265 as energyitemid,'其它用电' as equipmentname, '能耗分项' as type,
                (
-                   select ifnull(sum(electricityvalue),0)
+                   select ifnull(sum(tagvalue2),0)
                    from ems_data_electricity_day
                    where equipmentid in (301156882513921) and day=#{day}
                ) -
                (
-                   select ifnull(sum(electricityvalue),0)
+                   select ifnull(sum(tagvalue2),0)
                    from ems_data_electricity_day
                    where equipmentid in (301156930748417,301156962205697) and day=#{day}
                ) -
                (
-                   select ifnull(sum(electricityvalue),0)
+                   select ifnull(sum(tagvalue2),0)
                    from ems_data_electricity_day
                    where equipmentid in (301156947525633) and day=#{day}
                ) as howManyValue
     </select>
     <select id="selectItemByEquipidAndDay" resultType="org.jeecg.modules.emsStatistics.entity.EmsStatistics">
-        select t.energyitemid as equipmentid,i.energyitemname as equipmentname, '能耗分项' as type,ifnull(sum(e.electricityvalue),0) as howManyValue
+        select t.energyitemid as equipmentid,i.energyitemname as equipmentname, '能耗分项' as type,ifnull(sum(e.tagvalue2),0) as howManyValue
         from ems_data_electricity_day as e,tpm_tag as t,base_energy_item as i,base_energy_type as y
         where e.tagid=t.id t.energyitemid=i.energyitemid and e.day=#{day}
         and i.energytypeid=y.energytypeid and y.name='电'

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

@@ -0,0 +1,22 @@
+package org.jeecg.modules.Statistics.controller;
+
+import io.swagger.annotations.Api;
+import lombok.extern.slf4j.Slf4j;
+import org.jeecg.common.system.base.controller.JeecgController;
+import org.jeecg.modules.Statistics.entity.Statistics;
+import org.jeecg.modules.Statistics.service.IStatisticsService;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+/**
+ * @Description: 统计报表
+ * @Author: jeecg-boot
+ * @Date:   2024-02-16
+ * @Version: V1.0
+ */
+@Api(tags="统计报表")
+@RestController
+@RequestMapping("/equipmentStatistics/equipmentStatistics")
+@Slf4j
+public class StatisticsController extends JeecgController<Statistics, IStatisticsService> {
+}

+ 40 - 0
module_tpm/src/main/java/org/jeecg/modules/Statistics/entity/Statistics.java

@@ -0,0 +1,40 @@
+package org.jeecg.modules.Statistics.entity;
+
+import lombok.Data;
+
+import java.io.Serializable;
+
+@Data
+public class Statistics implements Serializable {
+
+    /**设备实时电流ID*/
+    private java.lang.Long id;
+    /**点位ID*/
+    private java.lang.String tagid;
+    /**点位名*/
+    private java.lang.String tagname;
+    /**设备ID*/
+    private java.lang.String equipmentid;
+    /**设备名称*/
+    private java.lang.String equipmentname;
+    /**时间*/
+    private java.util.Date logtime;
+    /**点位值(电流)*/
+    private java.lang.Double tagvalue;
+    /**分时电量*/
+    private java.lang.Double othervalue;
+    /**所属年*/
+    private java.lang.Integer year;
+    /**所属月*/
+    private java.lang.Integer month;
+    /**日期*/
+    private java.lang.String day;
+    /**时间*/
+    private java.lang.String time;
+    /**所属年月*/
+    private java.lang.String yearmonth;
+    /**所属周*/
+    private java.lang.Integer week;
+    /**周几*/
+    private java.lang.Integer dayofweek;
+}

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

@@ -0,0 +1,129 @@
+package org.jeecg.modules.Statistics.mapper;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import org.apache.ibatis.annotations.Param;
+import org.jeecg.modules.Statistics.entity.Statistics;
+
+import java.util.List;
+
+public interface StatisticsMapper extends BaseMapper<Statistics> {
+
+
+    /**
+     * 依据设备ID和日期查询 温度
+     *
+     * @param equipmentid 设备ID
+     * @param day 日期
+     * @return 分析统计
+     */
+    public List<Statistics> selectTemperature(@Param("equipmentid") String equipmentid, @Param("beginTime") String day);
+
+    /**
+     * 依据设备ID和日期查询 湿度
+     *
+     * @param equipmentid 设备ID
+     * @param day 日期
+     * @return 分析统计
+     */
+    public List<Statistics> selectHumidity(@Param("equipmentid") String equipmentid, @Param("beginTime") String day);
+
+    /**
+     * 依据设备ID和日期查询 需量
+     *
+     * @param equipmentid 设备ID
+     * @param day 日期
+     * @return 分析统计
+     */
+    public List<Statistics> selectDemand(@Param("equipmentid") String equipmentid, @Param("beginTime") String day);
+
+    /**
+     * 依据设备ID和日期查询 电流
+     *
+     * @param equipmentid 设备ID
+     * @param day 日期
+     * @return 分析统计
+     */
+    public List<Statistics> selectCurrent(@Param("equipmentid") String equipmentid, @Param("beginTime") String day);
+
+    /**
+     * 依据设备ID和日期查询 电压
+     *
+     * @param equipmentid 设备ID
+     * @param day 日期
+     * @return 分析统计
+     */
+    public List<Statistics> selectVoltage(@Param("equipmentid") String equipmentid, @Param("beginTime") String day);
+
+    /**
+     * 依据设备ID和日期查询 电量
+     *
+     * @param equipmentid 设备ID
+     * @param day 日期
+     * @return 分析统计
+     */
+    public List<Statistics> selectElectricity(@Param("equipmentid") String equipmentid, @Param("beginTime") String day);
+
+    /**
+     * 依据设备ID和日期查询 功率
+     *
+     * @param equipmentid 设备ID
+     * @param day 日期
+     * @return 分析统计
+     */
+    public List<Statistics> selectPower(@Param("equipmentid") String equipmentid, @Param("beginTime") String day);
+
+    /**
+     * 依据设备ID和日期查询 故障状态
+     *
+     * @param equipmentid 设备ID
+     * @param day 日期
+     * @return 分析统计
+     */
+    public List<Statistics> selectFault(@Param("equipmentid") String equipmentid, @Param("beginTime") String day);
+
+    /**
+     * 依据设备ID和日期查询 转速
+     *
+     * @param equipmentid 设备ID
+     * @param day 日期
+     * @return 分析统计
+     */
+    public List<Statistics> selectSpeed(@Param("equipmentid") String equipmentid, @Param("beginTime") String day);
+
+    /**
+     * 依据设备ID和日期查询 真空度
+     *
+     * @param equipmentid 设备ID
+     * @param day 日期
+     * @return 分析统计
+     */
+    public List<Statistics> selectVacuum(@Param("equipmentid") String equipmentid, @Param("beginTime") String day);
+
+    /**
+     * 依据设备ID和日期查询 压力
+     *
+     * @param equipmentid 设备ID
+     * @param day 日期
+     * @return 分析统计
+     */
+    public List<Statistics> selectPressure(@Param("equipmentid") String equipmentid, @Param("beginTime") String day);
+
+    /**
+     * 依据设备ID和日期查询 流量
+     *
+     * @param equipmentid 设备ID
+     * @param day 日期
+     * @return 分析统计
+     */
+    public List<Statistics> selectFlow(@Param("equipmentid") String equipmentid, @Param("beginTime") String day);
+
+    /**
+     * 依据设备ID和日期查询 PH计
+     *
+     * @param equipmentid 设备ID
+     * @param day 日期
+     * @return 分析统计
+     */
+    public List<Statistics> selectPh(@Param("equipmentid") String equipmentid, @Param("beginTime") String day);
+
+}

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

@@ -0,0 +1,65 @@
+<?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="org.jeecg.modules.equipmentStatus.mapper.EquipmentStatusMapper">
+
+    <resultMap type="org.jeecg.modules.Statistics.entity.Statistics" id="StatisticsResult">
+        <result property="id"    column="id"    />
+        <result property="tagid"    column="tagid"    />
+        <result property="tagname"    column="tagname"    />
+        <result property="equipmentid"    column="equipmentid"    />
+        <result property="equipmentname"    column="equipmentname"    />
+        <result property="logtime"    column="logtime"    />
+        <result property="tagvalue"    column="tagvalue"    />
+        <result property="othervalue"    column="othervalue"    />
+        <result property="year"    column="year"    />
+        <result property="month"    column="month"    />
+        <result property="day"    column="day"    />
+        <result property="time"    column="time"    />
+        <result property="yearmonth"    column="yearmonth"    />
+        <result property="week"    column="week"    />
+        <result property="dayofweek"    column="dayofweek"    />
+    </resultMap>
+
+    <!--依据设备ID和日期查询电流-->
+    <select id="selectCurrent" resultMap="StatisticsResult">
+        select *
+        from ems_data_current
+        where equipmentid= #{equipmentid} and day = #{day}
+    </select>
+
+    <!--依据设备ID和日期查询需量-->
+    <select id="selectDemand" resultMap="StatisticsResult">
+        select *
+        from ems_data_demand
+        where equipmentid= #{equipmentid} and day = #{day}
+    </select>
+
+    <!--依据设备ID和日期查询电量-->
+    <select id="selectElectricity" resultMap="StatisticsResult">
+        select *
+        from ems_data_electricity
+        where equipmentid= #{equipmentid} and day = #{day}
+    </select>
+
+    <!--依据设备ID和日期查询功率-->
+    <select id="selectPower" resultMap="StatisticsResult">
+        select *
+        from ems_data_power
+        where equipmentid= #{equipmentid} and day = #{day}
+    </select>
+
+    <!--依据设备ID和日期查询电压-->
+    <select id="selectVoltage" resultMap="StatisticsResult">
+        select *
+        from ems_data_voltage
+        where equipmentid= #{equipmentid} and day = #{day}
+    </select>
+
+    <!--依据设备ID和日期查询温湿度-->
+    <select id="selectEnvironment" resultMap="StatisticsResult">
+        select *
+        from hsms_environment
+        where equipmentid= #{equipmentid} and day = #{day}
+    </select>
+
+</mapper>

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

@@ -0,0 +1,20 @@
+package org.jeecg.modules.Statistics.service;
+
+import com.baomidou.mybatisplus.extension.service.IService;
+import org.jeecg.common.api.vo.Result;
+import org.jeecg.modules.Statistics.entity.Statistics;
+
+import java.util.List;
+
+public interface IStatisticsService extends IService<Statistics> {
+
+    /**
+     * 依据设备ID和日期查询电流
+     *
+     * @param equipmentid 设备ID
+     * @param day 日期
+     * @return 分析统计
+     */
+    public Result getRunInfo(String equipmentid, String day, String tagType);
+
+}

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

@@ -0,0 +1,86 @@
+package org.jeecg.modules.Statistics.service.impl;
+
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import org.jeecg.common.system.query.QueryGenerator;
+import org.jeecg.modules.Statistics.mapper.StatisticsMapper;
+import org.jeecg.modules.Statistics.service.IStatisticsService;
+import org.jeecg.modules.tpmTag.entity.TpmTag;
+import org.jeecg.modules.tpmTag.mapper.TpmTagMapper;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import org.jeecg.modules.Statistics.entity.Statistics;
+import org.jeecg.common.api.vo.Result;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+@Service
+public class StatisticsServiceImpl extends ServiceImpl<StatisticsMapper, Statistics> implements IStatisticsService {
+
+    @Autowired
+    private StatisticsMapper statisticsMapper;
+
+    @Autowired
+    private TpmTagMapper tagMapper;
+
+    /**
+     * 获取某设备运行信息
+     * @param equipmentid 设备ID
+     * @param day 日期
+     * @param tagtype 点位类型
+     * @return
+     */
+    @Override
+    public Result getRunInfo(String equipmentid, String day, String tagtype) {
+        // 获取某种点位类型的点位信息
+        TpmTag tpmTag = new TpmTag();
+        tpmTag.setEquipmentid(equipmentid);
+        QueryWrapper<TpmTag> queryWrapper = QueryGenerator.initQueryWrapper(tpmTag, null);
+        List<TpmTag> tags = tagMapper.selectList(queryWrapper);
+
+        // 获取设备下点位的实时数据
+        List<Statistics> statistics = null;
+        if (tagtype != null && !"".equals(tagtype)) {
+            switch (tagtype) {
+                case "temp": // 温度
+                    statistics = statisticsMapper.selectTemperature(equipmentid, day);
+                    break;
+                case "humi": // 湿度
+                    statistics = statisticsMapper.selectHumidity(equipmentid, day);
+                    break;
+                case "curr": // 电流
+                    statistics = statisticsMapper.selectCurrent(equipmentid, day);
+                    break;
+                case "volt": // 电压
+                    statistics = statisticsMapper.selectVoltage(equipmentid, day);
+                    break;
+                case "power": // 功率
+                    statistics = statisticsMapper.selectPower(equipmentid, day);
+                    break;
+                case "speed": // 转速
+//                    statistics = statisticsMapper.selectCurrent(equipmentid, day);
+                    break;
+                case "vacu": // 真空度
+//                    statistics = statisticsMapper.selectCurrent(equipmentid, day);
+                    break;
+                case "pres": // 压力
+//                    statistics = statisticsMapper.selectCurrent(equipmentid, day);
+                    break;
+                case "flow": // 流量
+//                    statistics = statisticsMapper.selectCurrent(equipmentid, day);
+                    break;
+                case "ph": // PH计
+//                    statistics = statisticsMapper.selectCurrent(equipmentid, day);
+                    break;
+                default:
+                    break;
+            }
+        }
+
+        Result result = null;
+
+        return result;
+    }
+}

+ 1 - 1
module_tpm/src/main/java/org/jeecg/modules/equipmentStatus/mapper/xml/EquipmentStatusMapper.xml

@@ -32,7 +32,7 @@
     </resultMap>
 
     <select id="getEquipmentElectricity" resultMap="EquipmentStatusResult">
-        select s.equipmentid,s.status, e.equipmentcode, d.electricityvalue as tagvalue,
+        select s.equipmentid,s.status, e.equipmentcode, d.tagvalue2 as tagvalue,
             s.tagvaluep, s.tagvalueca, s.tagvalueva, s.tagvaluecb, s.tagvaluevb, s.tagvaluecc, s.tagvaluevc
         from tpm_equipment_status as s
         left join tpm_equipment as e