Bläddra i källkod

* 储能分析增加容量等状态属性的展示

chen.cheng 3 veckor sedan
förälder
incheckning
40721a70fc

+ 28 - 17
ems/ems-cloud/ems-server/src/main/java/com/ruoyi/ems/controller/DeviceController.java

@@ -1,5 +1,22 @@
 package com.ruoyi.ems.controller;
 
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.servlet.http.HttpServletResponse;
+
+import org.apache.commons.lang3.StringUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.DeleteMapping;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.PutMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.RestController;
+
 import com.huashe.common.domain.AjaxResult;
 import com.huashe.common.exception.BusinessException;
 import com.ruoyi.common.core.utils.poi.ExcelUtil;
@@ -10,27 +27,14 @@ import com.ruoyi.common.log.enums.BusinessType;
 import com.ruoyi.common.security.annotation.RequiresPermissions;
 import com.ruoyi.ems.domain.Area;
 import com.ruoyi.ems.domain.EmsDevice;
+import com.ruoyi.ems.domain.EmsDeviceModel;
 import com.ruoyi.ems.model.QueryDevice;
 import com.ruoyi.ems.service.IAreaService;
 import com.ruoyi.ems.service.IEmsDeviceService;
 import com.ruoyi.ems.service.IEmsFacsService;
 import com.ruoyi.ems.util.AreaUtils;
-import io.swagger.annotations.Api;
-import org.apache.commons.lang3.StringUtils;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.web.bind.annotation.DeleteMapping;
-import org.springframework.web.bind.annotation.GetMapping;
-import org.springframework.web.bind.annotation.PathVariable;
-import org.springframework.web.bind.annotation.PostMapping;
-import org.springframework.web.bind.annotation.PutMapping;
-import org.springframework.web.bind.annotation.RequestBody;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RequestParam;
-import org.springframework.web.bind.annotation.RestController;
 
-import javax.servlet.http.HttpServletResponse;
-import java.util.ArrayList;
-import java.util.List;
+import io.swagger.annotations.Api;
 
 /**
  * 能源设备Controller
@@ -110,7 +114,8 @@ public class DeviceController extends BaseController {
             startPage();
             List<EmsDevice> list = deviceService.selectByAreaTree(queryDevice);
             tabInfo = getDataTable(list);
-        } catch (BusinessException e) {
+        }
+        catch (BusinessException e) {
             tabInfo = new TableDataInfo();
             tabInfo.setCode(e.getCode());
             tabInfo.setMsg(e.getMessage());
@@ -128,7 +133,7 @@ public class DeviceController extends BaseController {
     @RequiresPermissions("basecfg:device:list")
     @GetMapping("/getTreeByFacs")
     public AjaxResult getTreeByFacs(@RequestParam(value = "areaCode", required = false) String areaCode,
-                                    @RequestParam(value = "deviceCategory", required = false) String deviceCategory) {
+        @RequestParam(value = "deviceCategory", required = false) String deviceCategory) {
         QueryDevice queryDevice = new QueryDevice();
         queryDevice.setAreaCode(areaCode);
         queryDevice.setDeviceCategory(deviceCategory);
@@ -212,4 +217,10 @@ public class DeviceController extends BaseController {
     public AjaxResult cntTotalDevice(@RequestParam(value = "areaCode", required = false) String areaCode) {
         return success(deviceService.cntTotalDevice(areaCode));
     }
+
+    @GetMapping(value = "/device/model")
+    public AjaxResult getDeviceModel(EmsDeviceModel params) {
+        return success(deviceService.selectSubSystemDeviceState(params));
+    }
+
 }

+ 33 - 0
ems/ems-core/src/main/java/com/ruoyi/ems/domain/EmsDeviceModel.java

@@ -0,0 +1,33 @@
+package com.ruoyi.ems.domain;
+
+import com.alibaba.fastjson2.JSONArray;
+
+/**
+ * 能源设备对象 adm_ems_device
+ *
+ * @author ruoyi
+ * @date 2024-07-10
+ */
+public class EmsDeviceModel extends EmsDevice {
+    private static final long serialVersionUID = 1L;
+
+    private String attrGroup;
+
+    private String attributesArray;
+
+    public String getAttrGroup() {
+        return attrGroup;
+    }
+
+    public void setAttrGroup(String attrGroup) {
+        this.attrGroup = attrGroup;
+    }
+
+    public JSONArray getAttrJson() {
+        return JSONArray.parse(this.attributesArray);
+    }
+
+    public void setAttrJson(String attrJson) {
+        this.attributesArray = attrJson;
+    }
+}

+ 8 - 5
ems/ems-core/src/main/java/com/ruoyi/ems/mapper/EmsDeviceMapper.java

@@ -1,12 +1,14 @@
 package com.ruoyi.ems.mapper;
 
-import com.ruoyi.ems.domain.EmsDevice;
-import com.ruoyi.ems.model.QueryDevice;
+import java.util.List;
+import java.util.Map;
+
 import org.apache.ibatis.annotations.Mapper;
 import org.apache.ibatis.annotations.Param;
 
-import java.util.List;
-import java.util.Map;
+import com.ruoyi.ems.domain.EmsDevice;
+import com.ruoyi.ems.domain.EmsDeviceModel;
+import com.ruoyi.ems.model.QueryDevice;
 
 /**
  * 能源设备Mapper接口
@@ -108,6 +110,7 @@ public interface EmsDeviceMapper {
 
     List<Map<String, Object>> calcDeviceOnlineSummary(@Param("areaCode") String areaCode);
 
-
     Map<String, Object> cntTotalDevice(@Param("areaCode") String areaCode);
+
+    List<EmsDeviceModel> selectSubSystemDeviceState(EmsDeviceModel params);
 }

+ 3 - 0
ems/ems-core/src/main/java/com/ruoyi/ems/service/IEmsDeviceService.java

@@ -1,6 +1,7 @@
 package com.ruoyi.ems.service;
 
 import com.ruoyi.ems.domain.EmsDevice;
+import com.ruoyi.ems.domain.EmsDeviceModel;
 import com.ruoyi.ems.model.QueryDevice;
 
 import java.util.List;
@@ -106,4 +107,6 @@ public interface IEmsDeviceService {
     List<Map<String, Object>> calcDeviceOnlineSummary(String areaCode);
 
     Map<String, Object> cntTotalDevice(String areaCode);
+
+    List<EmsDeviceModel> selectSubSystemDeviceState(EmsDeviceModel params);
 }

+ 17 - 12
ems/ems-core/src/main/java/com/ruoyi/ems/service/impl/EmsDeviceServiceImpl.java

@@ -1,20 +1,22 @@
 package com.ruoyi.ems.service.impl;
 
+import java.util.List;
+import java.util.Map;
+import java.util.function.Function;
+import java.util.stream.Collectors;
+
+import org.apache.commons.collections4.CollectionUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
 import com.ruoyi.ems.domain.Area;
 import com.ruoyi.ems.domain.EmsDevice;
+import com.ruoyi.ems.domain.EmsDeviceModel;
 import com.ruoyi.ems.mapper.EmsDeviceMapper;
 import com.ruoyi.ems.model.QueryDevice;
 import com.ruoyi.ems.service.IAreaService;
 import com.ruoyi.ems.service.IEmsDeviceService;
 import com.ruoyi.ems.util.AreaUtils;
-import org.apache.commons.collections4.CollectionUtils;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Service;
-
-import java.util.List;
-import java.util.Map;
-import java.util.function.Function;
-import java.util.stream.Collectors;
 
 /**
  * 能源设备Service业务层处理
@@ -147,12 +149,16 @@ public class EmsDeviceServiceImpl implements IEmsDeviceService {
         return emsDeviceMapper.calcDeviceOnlineSummary(areaCode);
     }
 
-
     @Override
     public Map<String, Object> cntTotalDevice(String areaCode) {
         return emsDeviceMapper.cntTotalDevice(areaCode);
     }
 
+    @Override
+    public List<EmsDeviceModel> selectSubSystemDeviceState(EmsDeviceModel params) {
+        return emsDeviceMapper.selectSubSystemDeviceState(params);
+    }
+
     /**
      * 批量填充字段
      *
@@ -162,7 +168,7 @@ public class EmsDeviceServiceImpl implements IEmsDeviceService {
         if (CollectionUtils.isNotEmpty(list)) {
             List<Area> areas = areaService.selectArea(new Area());
             Map<String, Area> areaMap = areas.stream()
-                    .collect(Collectors.toMap(Area::getAreaCode, Function.identity()));
+                .collect(Collectors.toMap(Area::getAreaCode, Function.identity()));
 
             for (EmsDevice device : list) {
                 fillAreaName(device, areaMap);
@@ -172,8 +178,7 @@ public class EmsDeviceServiceImpl implements IEmsDeviceService {
 
     private void fillAreaName(EmsDevice emsDevice) {
         List<Area> areas = areaService.selectArea(new Area());
-        Map<String, Area> areaMap = areas.stream()
-                .collect(Collectors.toMap(Area::getAreaCode, Function.identity()));
+        Map<String, Area> areaMap = areas.stream().collect(Collectors.toMap(Area::getAreaCode, Function.identity()));
         fillAreaName(emsDevice, areaMap);
     }
 

+ 166 - 89
ems/ems-core/src/main/resources/mapper/ems/EmsDeviceMapper.xml

@@ -1,106 +1,140 @@
 <?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">
+        PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
+        "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="com.ruoyi.ems.mapper.EmsDeviceMapper">
 
     <resultMap type="com.ruoyi.ems.domain.EmsDevice" id="EmsDeviceResult">
-        <result property="id"    column="id"    />
-        <result property="deviceCode"          column="device_code"    />
-        <result property="deviceName"          column="device_name"    />
-        <result property="deviceCategory"      column="device_category"    />
-        <result property="deviceCategoryName"  column="device_category_name"    />
-        <result property="deviceBrand"         column="device_brand"    />
-        <result property="deviceSpec"          column="device_spec"    />
-        <result property="deviceStatus"        column="device_status"    />
-        <result property="location"            column="location"    />
-        <result property="locationRef"         column="location_ref"    />
-        <result property="areaCode"            column="area_code"    />
-        <result property="deviceModel"         column="device_model"    />
-        <result property="psCode"              column="ps_code"    />
-        <result property="psName"              column="ps_name"    />
-        <result property="refFacs"             column="ref_facs"    />
-        <result property="refFacsName"         column="ref_facs_name"    />
-        <result property="subsystemCode"       column="subsystem_code"    />
-        <result property="subsystemName"       column="subsystem_name"    />
-        <result property="createTime"          column="create_time"    />
-        <result property="updateTime"          column="update_time"    />
+        <result property="id" column="id"/>
+        <result property="deviceCode" column="device_code"/>
+        <result property="deviceName" column="device_name"/>
+        <result property="deviceCategory" column="device_category"/>
+        <result property="deviceCategoryName" column="device_category_name"/>
+        <result property="deviceBrand" column="device_brand"/>
+        <result property="deviceSpec" column="device_spec"/>
+        <result property="deviceStatus" column="device_status"/>
+        <result property="location" column="location"/>
+        <result property="locationRef" column="location_ref"/>
+        <result property="areaCode" column="area_code"/>
+        <result property="deviceModel" column="device_model"/>
+        <result property="psCode" column="ps_code"/>
+        <result property="psName" column="ps_name"/>
+        <result property="refFacs" column="ref_facs"/>
+        <result property="refFacsName" column="ref_facs_name"/>
+        <result property="subsystemCode" column="subsystem_code"/>
+        <result property="subsystemName" column="subsystem_name"/>
+        <result property="createTime" column="create_time"/>
+        <result property="updateTime" column="update_time"/>
     </resultMap>
 
     <sql id="selectDeviceVo">
-        select
-            d.`id`, d.`device_code`, d.`device_name`, d.`device_brand`, d.`device_spec`, d.`device_status`, d.`location`, d.`location_ref`, d.`area_code`, d.`device_model`, d.`ref_facs`, d.`subsystem_code`, d.`ps_code`, d.`create_time`, d.`update_time`
+        select d.`id`,
+               d.`device_code`,
+               d.`device_name`,
+               d.`device_brand`,
+               d.`device_spec`,
+               d.`device_status`,
+               d.`location`,
+               d.`location_ref`,
+               d.`area_code`,
+               d.`device_model`,
+               d.`ref_facs`,
+               d.`subsystem_code`,
+               d.`ps_code`,
+               d.`create_time`,
+               d.`update_time`
         from adm_ems_device d
     </sql>
 
     <sql id="selectDetailDeviceVo">
-        select
-            d.`id`, d.`device_code`, d.`device_name`, d.`device_brand`, d.`device_spec`, d.`device_status`, d.`location`, d.`location_ref`, d.`area_code`, d.`device_model`, d.`ref_facs`, d.`subsystem_code`, d.`ps_code`, d.`create_time`, d.`update_time`,
-            dp.`ps_name`,
-            s.`system_name` as subsystem_name,
-            f.`facs_name` as ref_facs_name,
-            f.`facs_subcategory` as device_category,
-            sc.`name` as device_category_name
+        select d.`id`,
+               d.`device_code`,
+               d.`device_name`,
+               d.`device_brand`,
+               d.`device_spec`,
+               d.`device_status`,
+               d.`location`,
+               d.`location_ref`,
+               d.`area_code`,
+               d.`device_model`,
+               d.`ref_facs`,
+               d.`subsystem_code`,
+               d.`ps_code`,
+               d.`create_time`,
+               d.`update_time`,
+               dp.`ps_name`,
+               s.`system_name`      as subsystem_name,
+               f.`facs_name`        as ref_facs_name,
+               f.`facs_subcategory` as device_category,
+               sc.`name`            as device_category_name
         from adm_ems_device d
-            LEFT JOIN dim_ems_dev_process dp ON d.`ps_code` = dp.`ps_code`
-            LEFT JOIN adm_ems_subsystem s ON d.`subsystem_code` = s.`system_code`
-            LEFT JOIN adm_ems_facs f ON d.`ref_facs` = f.`facs_code`
-            LEFT JOIN dim_ems_facs_subcategory sc ON f.`facs_subcategory` = sc.`code`
+                 LEFT JOIN dim_ems_dev_process dp ON d.`ps_code` = dp.`ps_code`
+                 LEFT JOIN adm_ems_subsystem s ON d.`subsystem_code` = s.`system_code`
+                 LEFT JOIN adm_ems_facs f ON d.`ref_facs` = f.`facs_code`
+                 LEFT JOIN dim_ems_facs_subcategory sc ON f.`facs_subcategory` = sc.`code`
     </sql>
 
     <select id="selectDeviceList" parameterType="com.ruoyi.ems.model.QueryDevice" resultMap="EmsDeviceResult">
         <include refid="selectDeviceVo"/>
         <where>
-            <if test="deviceCode != null  and deviceCode != ''"> and d.`device_code` = #{deviceCode}</if>
-            <if test="areaCode != null  and areaCode != ''"> and d.`area_code` = #{areaCode}</if>
-            <if test="deviceName != null  and deviceName != ''"> and d.`device_name` like concat('%', #{deviceName}, '%')</if>
-            <if test="deviceStatus != null "> and d.`device_status` = #{deviceStatus}</if>
-            <if test="locationRef != null  and locationRef != ''"> and d.`location_ref` = #{locationRef}</if>
-            <if test="refFacs != null  and refFacs != ''"> and d.`ref_facs` = #{refFacs}</if>
-            <if test="psCode != null  and psCode != ''"> and d.`ps_code` = #{psCode}</if>
-            <if test="deviceModel != null  and deviceModel != ''"> and d.`device_model` = #{deviceModel}</if>
-            <if test="subsystemCode != null  and subsystemCode != ''"> and d.`subsystem_code` = #{subsystemCode}</if>
+            <if test="deviceCode != null  and deviceCode != ''">and d.`device_code` = #{deviceCode}</if>
+            <if test="areaCode != null  and areaCode != ''">and d.`area_code` = #{areaCode}</if>
+            <if test="deviceName != null  and deviceName != ''">and d.`device_name` like concat('%', #{deviceName},
+                '%')
+            </if>
+            <if test="deviceStatus != null ">and d.`device_status` = #{deviceStatus}</if>
+            <if test="locationRef != null  and locationRef != ''">and d.`location_ref` = #{locationRef}</if>
+            <if test="refFacs != null  and refFacs != ''">and d.`ref_facs` = #{refFacs}</if>
+            <if test="psCode != null  and psCode != ''">and d.`ps_code` = #{psCode}</if>
+            <if test="deviceModel != null  and deviceModel != ''">and d.`device_model` = #{deviceModel}</if>
+            <if test="subsystemCode != null  and subsystemCode != ''">and d.`subsystem_code` = #{subsystemCode}</if>
         </where>
     </select>
 
     <select id="selectByFlowRel" parameterType="com.ruoyi.ems.model.QueryDevice" resultMap="EmsDeviceResult">
         select
-            d.`id`, d.`device_code`, d.`device_name`, d.`device_brand`, d.`device_spec`, d.`device_status`, d.`location`, d.`location_ref`, d.`area_code`, d.`device_model`, d.`ref_facs`, d.`subsystem_code`, d.`ps_code`, p.`ps_name`, d.`create_time`, d.`update_time`
+        d.`id`, d.`device_code`, d.`device_name`, d.`device_brand`, d.`device_spec`, d.`device_status`, d.`location`,
+        d.`location_ref`, d.`area_code`, d.`device_model`, d.`ref_facs`, d.`subsystem_code`, d.`ps_code`, p.`ps_name`,
+        d.`create_time`, d.`update_time`
         from adm_ems_device d
         LEFT JOIN adm_ems_flow_rel rel ON d.`device_code` = rel.`input_obj`
         LEFT JOIN dim_ems_dev_process p ON p.`ps_code` = d.`ps_code`
         <where>
-            <if test="areaCode != null  and areaCode != ''"> and d.`area_code` = #{areaCode}</if>
-            <if test="locationRef != null  and locationRef != ''"> and d.`location_ref` = #{locationRef}</if>
-            <if test="psCode != null  and psCode != ''"> and d.`ps_code` = #{psCode}</if>
-            <if test="psCodes != null"> and d.`ps_code` in
+            <if test="areaCode != null  and areaCode != ''">and d.`area_code` = #{areaCode}</if>
+            <if test="locationRef != null  and locationRef != ''">and d.`location_ref` = #{locationRef}</if>
+            <if test="psCode != null  and psCode != ''">and d.`ps_code` = #{psCode}</if>
+            <if test="psCodes != null">and d.`ps_code` in
                 (
-                  <foreach collection="psCodes" item="item" index="index" separator=",">
-                      #{item}
-                  </foreach>
+                <foreach collection="psCodes" item="item" index="index" separator=",">
+                    #{item}
+                </foreach>
                 )
             </if>
-            <if test="subsystemCode != null  and subsystemCode != ''"> and d.`subsystem_code` = #{subsystemCode}</if>
-            <if test="refFacs != null  and refFacs != ''"> and d.`ref_facs` = #{refFacs}</if>
-            <if test="upstreamObjType != null"> and rel.`export_obj_type` = #{upstreamObjType}</if>
-            <if test="upstreamObjCode != null  and upstreamObjCode != ''"> and rel.`export_obj` = #{upstreamObjCode}</if>
+            <if test="subsystemCode != null  and subsystemCode != ''">and d.`subsystem_code` = #{subsystemCode}</if>
+            <if test="refFacs != null  and refFacs != ''">and d.`ref_facs` = #{refFacs}</if>
+            <if test="upstreamObjType != null">and rel.`export_obj_type` = #{upstreamObjType}</if>
+            <if test="upstreamObjCode != null  and upstreamObjCode != ''">and rel.`export_obj` = #{upstreamObjCode}</if>
         </where>
     </select>
 
     <select id="selectDetailList" parameterType="com.ruoyi.ems.model.QueryDevice" resultMap="EmsDeviceResult">
         <include refid="selectDetailDeviceVo"/>
         <where>
-            <if test="deviceCode != null  and deviceCode != ''"> and d.`device_code` = #{deviceCode}</if>
-            <if test="areaCode != null  and areaCode != ''"> and d.`area_code` = #{areaCode}</if>
-            <if test="deviceName != null  and deviceName != ''"> and d.`device_name` like concat('%', #{deviceName}, '%')</if>
-            <if test="deviceStatus != null "> and d.`device_status` = #{deviceStatus}</if>
-            <if test="locationRef != null and locationRef != ''"> and d.`location_ref` = #{locationRef}</if>
-            <if test="refFacs != null  and refFacs != ''"> and d.`ref_facs` = #{refFacs}</if>
-            <if test="psCode != null  and psCode != ''"> and d.`ps_code` = #{psCode}</if>
-            <if test="deviceModel != null  and deviceModel != ''"> and d.`device_model` = #{device_model}</if>
-            <if test="subsystemCode != null  and subsystemCode != ''"> and d.`subsystem_code` = #{subsystemCode}</if>
-            <if test="deviceCategory != null and deviceCategory !=''"> and sc.`parent_code` = #{deviceCategory}</if>
-            <if test="deviceSubCategory != null and deviceSubCategory !=''"> and f.`facs_subcategory` = #{deviceSubCategory}</if>
+            <if test="deviceCode != null  and deviceCode != ''">and d.`device_code` = #{deviceCode}</if>
+            <if test="areaCode != null  and areaCode != ''">and d.`area_code` = #{areaCode}</if>
+            <if test="deviceName != null  and deviceName != ''">and d.`device_name` like concat('%', #{deviceName},
+                '%')
+            </if>
+            <if test="deviceStatus != null ">and d.`device_status` = #{deviceStatus}</if>
+            <if test="locationRef != null and locationRef != ''">and d.`location_ref` = #{locationRef}</if>
+            <if test="refFacs != null  and refFacs != ''">and d.`ref_facs` = #{refFacs}</if>
+            <if test="psCode != null  and psCode != ''">and d.`ps_code` = #{psCode}</if>
+            <if test="deviceModel != null  and deviceModel != ''">and d.`device_model` = #{device_model}</if>
+            <if test="subsystemCode != null  and subsystemCode != ''">and d.`subsystem_code` = #{subsystemCode}</if>
+            <if test="deviceCategory != null and deviceCategory !=''">and sc.`parent_code` = #{deviceCategory}</if>
+            <if test="deviceSubCategory != null and deviceSubCategory !=''">and f.`facs_subcategory` =
+                #{deviceSubCategory}
+            </if>
         </where>
     </select>
 
@@ -108,20 +142,24 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
     <select id="selectByAreaTree" parameterType="com.ruoyi.ems.model.QueryDevice" resultMap="EmsDeviceResult">
         <include refid="selectDetailDeviceVo"/>
         <where>
-            <if test="deviceCode != null  and deviceCode != ''"> and d.`device_code` = #{deviceCode}</if>
-            <if test="deviceName != null  and deviceName != ''"> and d.`device_name` like concat('%', #{deviceName}, '%')</if>
-            <if test="refFacs != null  and refFacs != ''"> and d.`ref_facs` = #{refFacs}</if>
-            <if test="psCode != null  and psCode != ''"> and d.`ps_code` = #{psCode}</if>
-            <if test="deviceModel != null  and deviceModel != ''"> and d.`device_model` = #{device_model}</if>
-            <if test="subsystemCode != null  and subsystemCode != ''"> and d.`subsystem_code` = #{subsystemCode}</if>
+            <if test="deviceCode != null  and deviceCode != ''">and d.`device_code` = #{deviceCode}</if>
+            <if test="deviceName != null  and deviceName != ''">and d.`device_name` like concat('%', #{deviceName},
+                '%')
+            </if>
+            <if test="refFacs != null  and refFacs != ''">and d.`ref_facs` = #{refFacs}</if>
+            <if test="psCode != null  and psCode != ''">and d.`ps_code` = #{psCode}</if>
+            <if test="deviceModel != null  and deviceModel != ''">and d.`device_model` = #{device_model}</if>
+            <if test="subsystemCode != null  and subsystemCode != ''">and d.`subsystem_code` = #{subsystemCode}</if>
             <if test="locationRef != null and locationRef != '' and areaCodes != null">
                 and d.`location_ref` in
                 <foreach item="areaCode" collection="areaCodes" open="(" separator="," close=")">
                     #{areaCode}
                 </foreach>
             </if>
-            <if test="deviceCategory != null and deviceCategory !=''"> and sc.`parent_code` = #{deviceCategory}</if>
-            <if test="deviceSubCategory != null and deviceSubCategory !=''"> and f.`facs_subcategory` = #{deviceSubCategory}</if>
+            <if test="deviceCategory != null and deviceCategory !=''">and sc.`parent_code` = #{deviceCategory}</if>
+            <if test="deviceSubCategory != null and deviceSubCategory !=''">and f.`facs_subcategory` =
+                #{deviceSubCategory}
+            </if>
         </where>
         ORDER BY d.`location_ref`
     </select>
@@ -141,7 +179,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         where d.`device_code` = #{code}
     </select>
 
-    <insert id="insertEmsDevice" parameterType="com.ruoyi.ems.domain.EmsDevice" useGeneratedKeys="true" keyProperty="id">
+    <insert id="insertEmsDevice" parameterType="com.ruoyi.ems.domain.EmsDevice" useGeneratedKeys="true"
+            keyProperty="id">
         insert into adm_ems_device
         <trim prefix="(" suffix=")" suffixOverrides=",">
             <if test="deviceCode != null and deviceCode != ''">device_code,</if>
@@ -157,7 +196,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="refFacs != null">ref_facs,</if>
             <if test="psCode != null">ps_code,</if>
             <if test="subsystemCode != null">subsystem_code,</if>
-         </trim>
+        </trim>
         <trim prefix="values (" suffix=")" suffixOverrides=",">
             <if test="deviceCode != null and deviceCode != ''">#{deviceCode},</if>
             <if test="deviceName != null and deviceName != ''">#{deviceName},</if>
@@ -172,7 +211,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="refFacs != null">#{refFacs},</if>
             <if test="psCode != null">#{psCode},</if>
             <if test="subsystemCode != null">#{subsystemCode},</if>
-         </trim>
+        </trim>
     </insert>
 
     <update id="updateEmsDevice" parameterType="com.ruoyi.ems.domain.EmsDevice">
@@ -196,7 +235,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
     </update>
 
     <delete id="deleteEmsDeviceById" parameterType="Long">
-        delete from adm_ems_device where id = #{id}
+        delete
+        from adm_ems_device
+        where id = #{id}
     </delete>
 
     <delete id="deleteEmsDeviceByIds" parameterType="String">
@@ -223,23 +264,23 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
 
     <select id="calcDeviceOnlineSummary">
         SELECT
-            sc.`name` typeName,
-            count( devc.id ) total,
-            SUM( CASE WHEN device_status = 1 THEN 1 ELSE 0 END ) AS onlineCount
+        sc.`name` typeName,
+        count( devc.id ) total,
+        SUM( CASE WHEN device_status = 1 THEN 1 ELSE 0 END ) AS onlineCount
         FROM
-            adm_ems_device devc
-            LEFT JOIN adm_ems_facs f ON devc.`ref_facs` = f.`facs_code`
-            LEFT JOIN dim_ems_facs_subcategory sc ON f.facs_subcategory = sc.`code`
-            <if test="areaCode !=null and areaCode!=''">
-                LEFT JOIN adm_area area ON devc.location_ref = area.area_code
-            </if>
+        adm_ems_device devc
+        LEFT JOIN adm_ems_facs f ON devc.`ref_facs` = f.`facs_code`
+        LEFT JOIN dim_ems_facs_subcategory sc ON f.facs_subcategory = sc.`code`
+        <if test="areaCode !=null and areaCode!=''">
+            LEFT JOIN adm_area area ON devc.location_ref = area.area_code
+        </if>
         <where>
             <if test="areaCode !=null and areaCode!=''">
                 area.ancestors like CONCAT('%',#{areaCode},'%')
             </if>
         </where>
         GROUP BY
-          facs_subcategory
+        facs_subcategory
     </select>
     <select id="cntTotalDevice">
         SELECT count(1) as total,
@@ -253,4 +294,40 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         </where>
     </select>
 
+    <select id="selectSubSystemDeviceState" parameterType="EmsDeviceModel" resultType="EmsDeviceModel">
+        select
+        device.device_code ,
+        device.device_name,
+        device.location,
+        JSON_ARRAYAGG(
+        JSON_OBJECT(
+        'attr_key', aeo.attr_key,
+        'attr_value', IFNULL(aeoa.attr_value, ''),
+        'attr_name', aeo.attr_name,
+        'attr_unit', IFNULL(aeo.attr_unit, '')
+        )
+        ) AS attributes_array
+        from
+        adm_ems_device device
+        left join adm_ems_obj_attr_value aeoa
+        on
+        device.device_model = aeoa.model_code
+        and device.device_code = aeoa.obj_code
+        left join adm_ems_obj_attr aeo on
+        aeo.model_code = aeoa.model_code and aeo.attr_key = aeoa.attr_key
+        <where>
+            <if test="areaCode !=null and areaCode!='' and areaCode != '-1'">
+                and device.area_code = #{areaCode}
+            </if>
+            <if test="subsystemCode !=''">
+                and device.subsystem_code = #{subsystemCode}
+            </if>
+            <if test="attrGroup !=null and attrGroup!=''">
+                and aeo.attr_group = #{attrGroup}
+            </if>
+        </where>
+        group by
+        device.device_code
+    </select>
+
 </mapper>