Browse Source

补充部件接口

lv.wenbin 10 months ago
parent
commit
e9d029b41b

+ 18 - 18
ems-cloud/ems-modules/ems-server/src/main/java/com/ruoyi/ems/controller/DeviceComponentController.java

@@ -1,12 +1,10 @@
 package com.ruoyi.ems.controller;
 
-import com.ruoyi.common.core.utils.poi.ExcelUtil;
 import com.ruoyi.common.core.web.controller.BaseController;
 import com.ruoyi.common.core.web.domain.AjaxResult;
 import com.ruoyi.common.core.web.page.TableDataInfo;
 import com.ruoyi.common.log.annotation.Log;
 import com.ruoyi.common.log.enums.BusinessType;
-import com.ruoyi.common.security.annotation.RequiresPermissions;
 import com.ruoyi.ems.domain.EmsDeviceComponent;
 import com.ruoyi.ems.service.IEmsDeviceComponentService;
 import io.swagger.annotations.Api;
@@ -21,7 +19,6 @@ 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.List;
 
 /**
@@ -35,16 +32,15 @@ import java.util.List;
 @Api(value = "DeviceController", description = "设备部件管理")
 public class DeviceComponentController extends BaseController {
     @Autowired
-    private IEmsDeviceComponentService deviceComponentService;
+    private IEmsDeviceComponentService componentService;
 
     /**
      * 查询能源设备部件列表
      */
-    @RequiresPermissions("ems:device:list")
     @GetMapping("/list")
-    public TableDataInfo list(EmsDeviceComponent deviceComponent) {
+    public TableDataInfo list(EmsDeviceComponent component) {
         startPage();
-        List<EmsDeviceComponent> list = deviceComponentService.selectDeviceComponentList(deviceComponent);
+        List<EmsDeviceComponent> list = componentService.selectList(component);
         return getDataTable(list);
     }
 
@@ -56,46 +52,50 @@ public class DeviceComponentController extends BaseController {
      */
     @GetMapping("/listByDevice")
     public AjaxResult list(@RequestParam(name = "deviceCode") String deviceCode) {
-        List<EmsDeviceComponent> list = deviceComponentService.selectByDeviceCode(deviceCode);
+        List<EmsDeviceComponent> list = componentService.selectByDeviceCode(deviceCode);
         return success(list);
     }
 
     /**
      * 获取能源设备部件详细信息
      */
-    @RequiresPermissions("ems:device:query")
     @GetMapping(value = "/{id}")
     public AjaxResult getInfo(@PathVariable("id") Long id) {
-        return success(deviceComponentService.selectDeviceComponentById(id));
+        return success(componentService.selectById(id));
+    }
+
+    /**
+     * 获取能源设备部件详细信息
+     */
+    @GetMapping(value = "/getByCode")
+    public AjaxResult getByCode(@RequestParam("compoCode") String compoCode) {
+        return success(componentService.selectByCode(compoCode));
     }
 
     /**
      * 新增能源设备部件
      */
-    @RequiresPermissions("ems:device:add")
     @Log(title = "能源设备部件", businessType = BusinessType.INSERT)
     @PostMapping
-    public AjaxResult add(@RequestBody EmsDeviceComponent deviceComponent) {
-        return toAjax(deviceComponentService.insertDeviceComponent(deviceComponent));
+    public AjaxResult add(@RequestBody EmsDeviceComponent component) {
+        return toAjax(componentService.insertComponent(component));
     }
 
     /**
      * 修改能源设备部件
      */
-    @RequiresPermissions("ems:device:edit")
     @Log(title = "能源设备部件", businessType = BusinessType.UPDATE)
     @PutMapping
-    public AjaxResult edit(@RequestBody EmsDeviceComponent deviceComponent) {
-        return toAjax(deviceComponentService.updateDeviceComponent(deviceComponent));
+    public AjaxResult edit(@RequestBody EmsDeviceComponent component) {
+        return toAjax(componentService.updateComponent(component));
     }
 
     /**
      * 删除能源设备部件
      */
-    @RequiresPermissions("ems:device:remove")
     @Log(title = "能源设备部件", businessType = BusinessType.DELETE)
     @DeleteMapping("/{ids}")
     public AjaxResult remove(@PathVariable Long[] ids) {
-        return toAjax(deviceComponentService.deleteDeviceComponentByIds(ids));
+        return toAjax(componentService.deleteComponentByIds(ids));
     }
 }

+ 14 - 4
ems-cloud/ems-modules/ems-server/src/main/java/com/ruoyi/ems/controller/EmsObjAttrController.java

@@ -7,10 +7,12 @@ import com.ruoyi.common.core.web.page.TableDataInfo;
 import com.ruoyi.common.log.annotation.Log;
 import com.ruoyi.common.log.enums.BusinessType;
 import com.ruoyi.ems.domain.EmsDevice;
+import com.ruoyi.ems.domain.EmsDeviceComponent;
 import com.ruoyi.ems.domain.EmsFacs;
 import com.ruoyi.ems.domain.EmsObjAttr;
 import com.ruoyi.ems.domain.EmsObjAttrValue;
 import com.ruoyi.ems.domain.common.ObjType;
+import com.ruoyi.ems.service.IEmsDeviceComponentService;
 import com.ruoyi.ems.service.IEmsDeviceService;
 import com.ruoyi.ems.service.IEmsFacsService;
 import com.ruoyi.ems.service.IEmsObjAttrService;
@@ -55,7 +57,10 @@ public class EmsObjAttrController extends BaseController {
     private IEmsDeviceService deviceService;
 
     @Autowired
-    private IEmsFacsService emsFacsService;
+    private IEmsFacsService facsService;
+
+    @Autowired
+    private IEmsDeviceComponentService componentService;
 
     /**
      * 查询能源对象属性列表
@@ -87,15 +92,20 @@ public class EmsObjAttrController extends BaseController {
             String modeCode = null;
 
             if (objType == ObjType.FACS.getCode()) {
-                EmsFacs facs = emsFacsService.selectEmsFacsByCode(objCode);
-                Assert.notNull(facs, -1, "能源对象不存在");
+                EmsFacs facs = facsService.selectEmsFacsByCode(objCode);
+                Assert.notNull(facs, -1, "能源设施不存在");
                 modeCode = facs.getFacsModel();
             }
             else if (objType == ObjType.DEVC.getCode()) {
                 EmsDevice device = deviceService.selectByCode(objCode);
-                Assert.notNull(device, -1, "能源对象不存在");
+                Assert.notNull(device, -1, "能源设备不存在");
                 modeCode = device.getDeviceModel();
             }
+            else if (objType == ObjType.COMPONENT.getCode()) {
+                EmsDeviceComponent devCompo = componentService.selectByCode(objCode);
+                Assert.notNull(devCompo, -1, "设备部件不存在");
+                modeCode = devCompo.getCompoModel();
+            }
 
             JSONObject json = new JSONObject();
             json.put("objType", objType);

+ 39 - 2
ems-cloud/ems-modules/ems-server/src/main/java/com/ruoyi/ems/domain/EmsDeviceComponent.java

@@ -23,9 +23,20 @@ public class EmsDeviceComponent extends BaseEntity
     /** 部件编码 */
     private String compoCode;
 
+    /** 部件标签 */
+    private String compoTag;
+
     /** 外部系统编码 */
     private String extCompoCode;
 
+    /**
+     * 工艺代码
+     */
+    private String psCode;
+
+    /** 工艺名称 */
+    private String psName;
+
     /** 部件模型 */
     private String compoModel;
 
@@ -68,7 +79,16 @@ public class EmsDeviceComponent extends BaseEntity
     {
         return compoCode;
     }
-    public void setExtCompoCode(String extCompoCode) 
+
+    public String getCompoTag() {
+        return compoTag;
+    }
+
+    public void setCompoTag(String compoTag) {
+        this.compoTag = compoTag;
+    }
+
+    public void setExtCompoCode(String extCompoCode)
     {
         this.extCompoCode = extCompoCode;
     }
@@ -77,7 +97,24 @@ public class EmsDeviceComponent extends BaseEntity
     {
         return extCompoCode;
     }
-    public void setCompoModel(String compoModel) 
+
+    public String getPsCode() {
+        return psCode;
+    }
+
+    public void setPsCode(String psCode) {
+        this.psCode = psCode;
+    }
+
+    public String getPsName() {
+        return psName;
+    }
+
+    public void setPsName(String psName) {
+        this.psName = psName;
+    }
+
+    public void setCompoModel(String compoModel)
     {
         this.compoModel = compoModel;
     }

+ 14 - 6
ems-cloud/ems-modules/ems-server/src/main/java/com/ruoyi/ems/mapper/EmsDeviceComponentMapper.java

@@ -18,7 +18,15 @@ public interface EmsDeviceComponentMapper {
      * @param id 能源设备部件主键
      * @return 能源设备部件
      */
-    EmsDeviceComponent selectDeviceComponentById(Long id);
+    EmsDeviceComponent selectById(Long id);
+
+    /**
+     * 查询能源设备部件
+     *
+     * @param componentCode 能源设备部件代码
+     * @return 能源设备部件
+     */
+    EmsDeviceComponent selectByCode(@Param("compoCode") String compoCode);
 
     /**
      * 查询能源设备部件列表
@@ -26,7 +34,7 @@ public interface EmsDeviceComponentMapper {
      * @param deviceComponent 能源设备部件
      * @return 能源设备部件集合
      */
-    List<EmsDeviceComponent> selectDeviceComponentList(EmsDeviceComponent deviceComponent);
+    List<EmsDeviceComponent> selectList(EmsDeviceComponent deviceComponent);
 
     /**
      * 查询能源设备部件列表
@@ -42,7 +50,7 @@ public interface EmsDeviceComponentMapper {
      * @param deviceComponent 能源设备部件
      * @return 结果
      */
-    int insertDeviceComponent(EmsDeviceComponent deviceComponent);
+    int insertComponent(EmsDeviceComponent deviceComponent);
 
     /**
      * 修改能源设备部件
@@ -50,7 +58,7 @@ public interface EmsDeviceComponentMapper {
      * @param deviceComponent 能源设备部件
      * @return 结果
      */
-    int updateDeviceComponent(EmsDeviceComponent deviceComponent);
+    int updateComponent(EmsDeviceComponent deviceComponent);
 
     /**
      * 删除能源设备部件
@@ -58,7 +66,7 @@ public interface EmsDeviceComponentMapper {
      * @param id 能源设备部件主键
      * @return 结果
      */
-    int deleteDeviceComponentById(Long id);
+    int deleteComponentById(Long id);
 
     /**
      * 批量删除能源设备部件
@@ -66,5 +74,5 @@ public interface EmsDeviceComponentMapper {
      * @param ids 需要删除的数据主键集合
      * @return 结果
      */
-    int deleteDeviceComponentByIds(Long[] ids);
+    int deleteComponentByIds(Long[] ids);
 }

+ 16 - 8
ems-cloud/ems-modules/ems-server/src/main/java/com/ruoyi/ems/service/IEmsDeviceComponentService.java

@@ -1,9 +1,9 @@
 package com.ruoyi.ems.service;
 
-import java.util.List;
-
 import com.ruoyi.ems.domain.EmsDeviceComponent;
 
+import java.util.List;
+
 /**
  * 能源设备部件Service接口
  *
@@ -17,7 +17,15 @@ public interface IEmsDeviceComponentService {
      * @param id 能源设备部件主键
      * @return 能源设备部件
      */
-    EmsDeviceComponent selectDeviceComponentById(Long id);
+    EmsDeviceComponent selectById(Long id);
+
+    /**
+     * 查询能源设备部件
+     *
+     * @param componentCode 设备部件代码
+     * @return 能源设备部件
+     */
+    EmsDeviceComponent selectByCode(String componentCode);
 
     /**
      * 查询能源设备部件列表
@@ -25,7 +33,7 @@ public interface IEmsDeviceComponentService {
      * @param deviceComponent 能源设备部件
      * @return 能源设备部件集合
      */
-    List<EmsDeviceComponent> selectDeviceComponentList(EmsDeviceComponent deviceComponent);
+    List<EmsDeviceComponent> selectList(EmsDeviceComponent deviceComponent);
 
     /**
      * 查询能源设备部件列表
@@ -41,7 +49,7 @@ public interface IEmsDeviceComponentService {
      * @param deviceComponent 能源设备部件
      * @return 结果
      */
-    int insertDeviceComponent(EmsDeviceComponent deviceComponent);
+    int insertComponent(EmsDeviceComponent deviceComponent);
 
     /**
      * 修改能源设备部件
@@ -49,7 +57,7 @@ public interface IEmsDeviceComponentService {
      * @param deviceComponent 能源设备部件
      * @return 结果
      */
-    int updateDeviceComponent(EmsDeviceComponent deviceComponent);
+    int updateComponent(EmsDeviceComponent deviceComponent);
 
     /**
      * 批量删除能源设备部件
@@ -57,7 +65,7 @@ public interface IEmsDeviceComponentService {
      * @param ids 需要删除的能源设备部件主键集合
      * @return 结果
      */
-    int deleteDeviceComponentByIds(Long[] ids);
+    int deleteComponentByIds(Long[] ids);
 
     /**
      * 删除能源设备部件信息
@@ -65,5 +73,5 @@ public interface IEmsDeviceComponentService {
      * @param id 能源设备部件主键
      * @return 结果
      */
-    int deleteDeviceComponentById(Long id);
+    int deleteComponentById(Long id);
 }

+ 19 - 14
ems-cloud/ems-modules/ems-server/src/main/java/com/ruoyi/ems/service/impl/EmsDeviceComponentServiceImpl.java

@@ -17,7 +17,7 @@ import java.util.List;
 @Service
 public class EmsDeviceComponentServiceImpl implements IEmsDeviceComponentService {
     @Autowired
-    private EmsDeviceComponentMapper deviceComponentMapper;
+    private EmsDeviceComponentMapper componentMapper;
 
     /**
      * 查询能源设备部件
@@ -26,8 +26,13 @@ public class EmsDeviceComponentServiceImpl implements IEmsDeviceComponentService
      * @return 能源设备部件
      */
     @Override
-    public EmsDeviceComponent selectDeviceComponentById(Long id) {
-        return deviceComponentMapper.selectDeviceComponentById(id);
+    public EmsDeviceComponent selectById(Long id) {
+        return componentMapper.selectById(id);
+    }
+
+    @Override
+    public EmsDeviceComponent selectByCode(String componentCode) {
+        return componentMapper.selectByCode(componentCode);
     }
 
     /**
@@ -37,8 +42,8 @@ public class EmsDeviceComponentServiceImpl implements IEmsDeviceComponentService
      * @return 能源设备部件
      */
     @Override
-    public List<EmsDeviceComponent> selectDeviceComponentList(EmsDeviceComponent deviceComponent) {
-        return deviceComponentMapper.selectDeviceComponentList(deviceComponent);
+    public List<EmsDeviceComponent> selectList(EmsDeviceComponent deviceComponent) {
+        return componentMapper.selectList(deviceComponent);
     }
 
     /**
@@ -49,7 +54,7 @@ public class EmsDeviceComponentServiceImpl implements IEmsDeviceComponentService
      */
     @Override
     public List<EmsDeviceComponent> selectByDeviceCode(String deviceCode) {
-        return deviceComponentMapper.selectByDeviceCode(deviceCode);
+        return componentMapper.selectByDeviceCode(deviceCode);
     }
 
     /**
@@ -59,8 +64,8 @@ public class EmsDeviceComponentServiceImpl implements IEmsDeviceComponentService
      * @return 结果
      */
     @Override
-    public int insertDeviceComponent(EmsDeviceComponent deviceComponent) {
-        return deviceComponentMapper.insertDeviceComponent(deviceComponent);
+    public int insertComponent(EmsDeviceComponent deviceComponent) {
+        return componentMapper.insertComponent(deviceComponent);
     }
 
     /**
@@ -70,8 +75,8 @@ public class EmsDeviceComponentServiceImpl implements IEmsDeviceComponentService
      * @return 结果
      */
     @Override
-    public int updateDeviceComponent(EmsDeviceComponent deviceComponent) {
-        return deviceComponentMapper.updateDeviceComponent(deviceComponent);
+    public int updateComponent(EmsDeviceComponent deviceComponent) {
+        return componentMapper.updateComponent(deviceComponent);
     }
 
     /**
@@ -81,8 +86,8 @@ public class EmsDeviceComponentServiceImpl implements IEmsDeviceComponentService
      * @return 结果
      */
     @Override
-    public int deleteDeviceComponentByIds(Long[] ids) {
-        return deviceComponentMapper.deleteDeviceComponentByIds(ids);
+    public int deleteComponentByIds(Long[] ids) {
+        return componentMapper.deleteComponentByIds(ids);
     }
 
     /**
@@ -92,7 +97,7 @@ public class EmsDeviceComponentServiceImpl implements IEmsDeviceComponentService
      * @return 结果
      */
     @Override
-    public int deleteDeviceComponentById(Long id) {
-        return deviceComponentMapper.deleteDeviceComponentById(id);
+    public int deleteComponentById(Long id) {
+        return componentMapper.deleteComponentById(id);
     }
 }

+ 39 - 20
ems-cloud/ems-modules/ems-server/src/main/resources/mapper/ems/EmsDeviceComponentMapper.xml

@@ -6,25 +6,29 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
     
     <resultMap type="com.ruoyi.ems.domain.EmsDeviceComponent" id="DeviceComponentResult">
         <result property="id"    column="id"    />
-        <result property="deviceCode"    column="device_code"    />
-        <result property="compoCode"    column="compo_code"    />
+        <result property="deviceCode"      column="device_code"    />
+        <result property="compoCode"       column="compo_code"    />
+        <result property="compoTag"        column="compo_tag"    />
         <result property="extCompoCode"    column="ext_compo_code"    />
-        <result property="compoModel"    column="compo_model"    />
-        <result property="compoBrand"    column="compo_brand"    />
-        <result property="compoSpec"    column="compo_spec"    />
-        <result property="ancestors"    column="ancestors"    />
-        <result property="parentCompo"    column="parent_compo"    />
+        <result property="psCode"          column="ps_code"    />
+        <result property="psName"          column="ps_name"    />
+        <result property="compoModel"      column="compo_model"    />
+        <result property="compoBrand"      column="compo_brand"    />
+        <result property="compoSpec"       column="compo_spec"    />
+        <result property="ancestors"       column="ancestors"    />
+        <result property="parentCompo"     column="parent_compo"    />
     </resultMap>
 
-    <sql id="selectDeviceComponentVo">
-        select id, device_code, compo_code, ext_compo_code, compo_model, compo_brand, compo_spec, ancestors, parent_compo from adm_ems_device_component
+    <sql id="selectComponentVo">
+        select id, device_code, compo_code, compo_tag, ps_code, ext_compo_code, compo_model, compo_brand, compo_spec, ancestors, parent_compo from adm_ems_device_component
     </sql>
 
-    <select id="selectDeviceComponentList" parameterType="com.ruoyi.ems.domain.EmsDeviceComponent" resultMap="DeviceComponentResult">
-        <include refid="selectDeviceComponentVo"/>
+    <select id="selectList" parameterType="com.ruoyi.ems.domain.EmsDeviceComponent" resultMap="DeviceComponentResult">
+        <include refid="selectComponentVo"/>
         <where>  
             <if test="deviceCode != null  and deviceCode != ''"> and device_code = #{deviceCode}</if>
             <if test="compoCode != null  and compoCode != ''"> and compo_code = #{compoCode}</if>
+            <if test="psCode != null  and psCode != ''"> and ps_code = #{psCode}</if>
             <if test="extCompoCode != null  and extCompoCode != ''"> and ext_compo_code = #{extCompoCode}</if>
             <if test="compoModel != null  and compoModel != ''"> and compo_model = #{compoModel}</if>
             <if test="parentCompo != null  and parentCompo != ''"> and parent_compo = #{parentCompo}</if>
@@ -32,20 +36,31 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
     </select>
 
     <select id="selectByDeviceCode" parameterType="java.lang.String" resultMap="DeviceComponentResult">
-        <include refid="selectDeviceComponentVo"/>
-        where deviceCode = #{deviceCode}
+        select
+            c.id, c.device_code, c.compo_code, c.compo_tag, c.ps_code, c.ext_compo_code, c.compo_model, c.compo_brand, c.compo_spec, c.ancestors, c.parent_compo,
+            p.ps_name
+        from adm_ems_device_component c
+          left join dim_ems_dev_process p on c.ps_code = p.ps_code
+        where device_code = #{deviceCode}
     </select>
 
-    <select id="selectDeviceComponentById" parameterType="Long" resultMap="DeviceComponentResult">
-        <include refid="selectDeviceComponentVo"/>
+    <select id="selectById" parameterType="Long" resultMap="DeviceComponentResult">
+        <include refid="selectComponentVo"/>
         where id = #{id}
     </select>
-        
-    <insert id="insertDeviceComponent" parameterType="com.ruoyi.ems.domain.EmsDeviceComponent" useGeneratedKeys="true" keyProperty="id">
+
+    <select id="selectByCode"  resultMap="DeviceComponentResult">
+        <include refid="selectComponentVo"/>
+        where compo_code = #{compoCode}
+    </select>
+
+    <insert id="insertComponent" parameterType="com.ruoyi.ems.domain.EmsDeviceComponent" useGeneratedKeys="true" keyProperty="id">
         insert into adm_ems_device_component
         <trim prefix="(" suffix=")" suffixOverrides=",">
             <if test="deviceCode != null and deviceCode != ''">device_code,</if>
             <if test="compoCode != null and compoCode != ''">compo_code,</if>
+            <if test="compoTag != null and compoTag != ''">compo_tag,</if>
+            <if test="psCode != null and psCode != ''">ps_code,</if>
             <if test="extCompoCode != null">ext_compo_code,</if>
             <if test="compoModel != null">compo_model,</if>
             <if test="compoBrand != null">compo_brand,</if>
@@ -56,6 +71,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         <trim prefix="values (" suffix=")" suffixOverrides=",">
             <if test="deviceCode != null and deviceCode != ''">#{deviceCode},</if>
             <if test="compoCode != null and compoCode != ''">#{compoCode},</if>
+            <if test="compoTag != null and compoTag != ''">#{compoTag},</if>
+            <if test="psCode != null and psCode != ''">#{psCode},</if>
             <if test="extCompoCode != null">#{extCompoCode},</if>
             <if test="compoModel != null">#{compoModel},</if>
             <if test="compoBrand != null">#{compoBrand},</if>
@@ -65,11 +82,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
          </trim>
     </insert>
 
-    <update id="updateDeviceComponent" parameterType="com.ruoyi.ems.domain.EmsDeviceComponent">
+    <update id="updateComponent" parameterType="com.ruoyi.ems.domain.EmsDeviceComponent">
         update adm_ems_device_component
         <trim prefix="SET" suffixOverrides=",">
             <if test="deviceCode != null and deviceCode != ''">device_code = #{deviceCode},</if>
             <if test="compoCode != null and compoCode != ''">compo_code = #{compoCode},</if>
+            <if test="compoTag != null and compoTag != ''">compo_tag = #{compoTag},</if>
+            <if test="psCode != null and psCode != ''">ps_code = #{psCode},</if>
             <if test="extCompoCode != null">ext_compo_code = #{extCompoCode},</if>
             <if test="compoModel != null">compo_model = #{compoModel},</if>
             <if test="compoBrand != null">compo_brand = #{compoBrand},</if>
@@ -80,11 +99,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         where id = #{id}
     </update>
 
-    <delete id="deleteDeviceComponentById" parameterType="Long">
+    <delete id="deleteComponentById" parameterType="Long">
         delete from adm_ems_device_component where id = #{id}
     </delete>
 
-    <delete id="deleteDeviceComponentByIds" parameterType="String">
+    <delete id="deleteComponentByIds" parameterType="String">
         delete from adm_ems_device_component where id in 
         <foreach item="id" collection="array" open="(" separator="," close=")">
             #{id}

+ 15 - 6
ems-cloud/sql/ems_init_data.sql

@@ -127,6 +127,10 @@ INSERT INTO `adm_ems_obj_model` (`model_code`, `model_name`, `obj_type`) VALUES
 INSERT INTO `adm_ems_obj_attr` (`model_code`, `attr_type`, `attr_key`, `attr_name`, `attr_unit`) VALUES ('M_Z010', 0, 'power',   '功率', 'kW-h');
 
 -- 对象属性DEMO数据
+INSERT INTO `adm_ems_obj_attr_value` (`obj_code`, `obj_type`, `attr_key`, `attr_value`, `model_code`) VALUES ('D-B-1001-QR_00', 3, 'onOffState', 'on', 'M_W2_QR');
+INSERT INTO `adm_ems_obj_attr_value` (`obj_code`, `obj_type`, `attr_key`, `attr_value`, `model_code`) VALUES ('D-B-1001-QF_01', 3, 'onOffState', 'off', 'M_W2_QF');
+INSERT INTO `adm_ems_obj_attr_value` (`obj_code`, `obj_type`, `attr_key`, `attr_value`, `model_code`) VALUES ('D-B-1001-QF_02', 3, 'onOffState', 'on', 'M_W2_QF');
+
 INSERT INTO `adm_ems_obj_attr_value` (`obj_code`, `obj_type`, `attr_key`, `attr_value`, `model_code`) VALUES ('D-B-T-1001', 2, 'ratedCapacity', '1000', 'M_W2_T');
 INSERT INTO `adm_ems_obj_attr_value` (`obj_code`, `obj_type`, `attr_key`, `attr_value`, `model_code`) VALUES ('D-B-T-1001', 2, 'ratedVoltage', '10', 'M_W2_T');
 INSERT INTO `adm_ems_obj_attr_value` (`obj_code`, `obj_type`, `attr_key`, `attr_value`, `model_code`) VALUES ('D-B-T-1001', 2, 'ratedFrequency', '50', 'M_W2_T');
@@ -259,12 +263,17 @@ INSERT INTO `adm_ems_device` (`device_code`, `device_name`, `device_category`, `
 INSERT INTO `adm_ems_device` (`device_code`, `device_name`, `device_category`, `device_brand`, `device_spec`, `location`, `device_status`, `area_type`, `ref_area`, `area_ancestors`, `device_model`, `ref_facs`, `ps_code`, `subsystem_code`) VALUES ( 'E503-K140-K150-002', '光伏板2',      'E5', null, null, null, '1', 'Building', 'S30K140-S30K150', '321283124S3003,S30K140-S30K150', null, 'E503', null, 'SYS_GF');
 INSERT INTO `adm_ems_device` (`device_code`, `device_name`, `device_category`, `device_brand`, `device_spec`, `location`, `device_status`, `area_type`, `ref_area`, `area_ancestors`, `device_model`, `ref_facs`, `ps_code`, `subsystem_code`) VALUES ( 'E503-K140-K150-003', '光伏板3',      'E5', null, null, null, '1', 'Building', 'S30K150-S30K180', '321283124S3003,S30K150-S30K180', null, 'E503', null, 'SYS_GF');
 
-INSERT INTO `adm_ems_device` (`device_code`, `device_name`, `device_category`, `device_brand`, `device_spec`, `location`, `device_status`, `area_type`, `ref_area`, `area_ancestors`, `device_model`, `ref_facs`, `ps_code`, `subsystem_code`) VALUES ('D-B-T-1001', '(变)D-B-T-1001', 'W2', '西门子', 'T221123', '北区', 1, 'Area', '321283124S3001', '321283124S3001', 'M_W2_T', 'W201', 'T', null);
-INSERT INTO `adm_ems_device` (`device_code`, `device_name`, `device_category`, `device_brand`, `device_spec`, `location`, `device_status`, `area_type`, `ref_area`, `area_ancestors`, `device_model`, `ref_facs`, `ps_code`, `subsystem_code`) VALUES ('D-N-T-1002', '(变)D-N-T-1002', 'W2', '西门子', 'T221212', '南区', 1, 'Area', '321283124S3002', '321283124S3002', 'M_W2_T', 'W201', 'T', null);
-INSERT INTO `adm_ems_device` (`device_code`, `device_name`, `device_category`, `device_brand`, `device_spec`, `location`, `device_status`, `area_type`, `ref_area`, `area_ancestors`, `device_model`, `ref_facs`, `ps_code`, `subsystem_code`) VALUES ('D-B-1001', '(配)D-B-1001', 'W2', '安科瑞', 'DX2121021', '综合楼配电间', 1, 'Area', '321283124S3001', '321283124S3001', null, 'W201', 'AP', null);
-INSERT INTO `adm_ems_device` (`device_code`, `device_name`, `device_category`, `device_brand`, `device_spec`, `location`, `device_status`, `area_type`, `ref_area`, `area_ancestors`, `device_model`, `ref_facs`, `ps_code`, `subsystem_code`) VALUES ('D-B-1002', '(配)D-B-1002', 'W2', '安科瑞', 'DX2121021', '广场配电柜',   1, 'Area', '321283124S3001', '321283124S3001', null, 'W201', 'AP', null);
-INSERT INTO `adm_ems_device` (`device_code`, `device_name`, `device_category`, `device_brand`, `device_spec`, `location`, `device_status`, `area_type`, `ref_area`, `area_ancestors`, `device_model`, `ref_facs`, `ps_code`, `subsystem_code`) VALUES ('D-N-1001', '(配)D-N-1001', 'W2', '安科瑞', 'DX2121021', '综合楼配电间', 1, 'Area', '321283124S3002', '321283124S3002', null, 'W202', 'AP', null);
-INSERT INTO `adm_ems_device` (`device_code`, `device_name`, `device_category`, `device_brand`, `device_spec`, `location`, `device_status`, `area_type`, `ref_area`, `area_ancestors`, `device_model`, `ref_facs`, `ps_code`, `subsystem_code`) VALUES ('D-N-1002', '(配)D-N-1002', 'W2', '安科瑞', 'DX2121021', '广场配电柜',   1, 'Area', '321283124S3002', '321283124S3002', null, 'W202', 'AP', null);
+INSERT INTO `adm_ems_device` (`device_code`, `device_name`, `device_category`, `device_brand`, `device_spec`, `location`, `device_status`, `area_type`, `ref_area`, `area_ancestors`, `device_model`, `ref_facs`, `ps_code`, `subsystem_code`) VALUES ('D-B-T-1001', '北区总变', 'W2', '西门子', 'T221123', '北区', 1, 'Area', '321283124S3001', '321283124S3001', 'M_W2_T', 'W201', 'T', null);
+INSERT INTO `adm_ems_device` (`device_code`, `device_name`, `device_category`, `device_brand`, `device_spec`, `location`, `device_status`, `area_type`, `ref_area`, `area_ancestors`, `device_model`, `ref_facs`, `ps_code`, `subsystem_code`) VALUES ('D-N-T-1002', '南区总变', 'W2', '西门子', 'T221212', '南区', 1, 'Area', '321283124S3002', '321283124S3002', 'M_W2_T', 'W201', 'T', null);
+INSERT INTO `adm_ems_device` (`device_code`, `device_name`, `device_category`, `device_brand`, `device_spec`, `location`, `device_status`, `area_type`, `ref_area`, `area_ancestors`, `device_model`, `ref_facs`, `ps_code`, `subsystem_code`) VALUES ('D-B-1001', '北区-综合楼配电', 'W2', '安科瑞', 'DX2121021', '综合楼配电间', 1, 'Area', '321283124S3001', '321283124S3001', null, 'W201', 'AP', null);
+INSERT INTO `adm_ems_device` (`device_code`, `device_name`, `device_category`, `device_brand`, `device_spec`, `location`, `device_status`, `area_type`, `ref_area`, `area_ancestors`, `device_model`, `ref_facs`, `ps_code`, `subsystem_code`) VALUES ('D-B-1002', '北区-广场配电', 'W2', '安科瑞', 'DX2121021', '广场配电柜',   1, 'Area', '321283124S3001', '321283124S3001', null, 'W201', 'AP', null);
+INSERT INTO `adm_ems_device` (`device_code`, `device_name`, `device_category`, `device_brand`, `device_spec`, `location`, `device_status`, `area_type`, `ref_area`, `area_ancestors`, `device_model`, `ref_facs`, `ps_code`, `subsystem_code`) VALUES ('D-N-1001', '南区-综合楼配电', 'W2', '安科瑞', 'DX2121021', '综合楼配电间', 1, 'Area', '321283124S3002', '321283124S3002', null, 'W202', 'AP', null);
+INSERT INTO `adm_ems_device` (`device_code`, `device_name`, `device_category`, `device_brand`, `device_spec`, `location`, `device_status`, `area_type`, `ref_area`, `area_ancestors`, `device_model`, `ref_facs`, `ps_code`, `subsystem_code`) VALUES ('D-N-1002', '南区-广场配电', 'W2', '安科瑞', 'DX2121021', '广场配电柜',   1, 'Area', '321283124S3002', '321283124S3002', null, 'W202', 'AP', null);
+
+-- 设备部件表
+INSERT INTO `adm_ems_device_component` (`device_code`, `compo_code`, `compo_tag`, `ps_code`, `ext_compo_code`, `compo_model`, `compo_brand`, `compo_spec`, `ancestors`, `parent_compo`) VALUES ('D-B-1001', 'D-B-1001-QR_00', '总开', 'QR', '0x000101', 'M_W2_QR', '德力西', 'DZ47P-C10', '', '');
+INSERT INTO `adm_ems_device_component` (`device_code`, `compo_code`, `compo_tag`, `ps_code`, `ext_compo_code`, `compo_model`, `compo_brand`, `compo_spec`, `ancestors`, `parent_compo`) VALUES ('D-B-1001', 'D-B-1001-QF_01', '照明', 'QF', '0x000102', 'M_W2_QF', '施耐德', 'NXB-63-C16', 'D-B-1001-QS_00/D-B-1001-QF_01', 'D-B-1001-QS_00');
+INSERT INTO `adm_ems_device_component` (`device_code`, `compo_code`, `compo_tag`, `ps_code`, `ext_compo_code`, `compo_model`, `compo_brand`, `compo_spec`, `ancestors`, `parent_compo`) VALUES ('D-B-1001', 'D-B-1001-QF_02', '风机', 'QF', '0x000103', 'M_W2_QF', '施耐德', 'NXB-63-C16', 'D-B-1001-QS_00/D-B-1001-QF_02', 'D-B-1001-QS_00');
 
 
 -- 动力箱柜电气设备表

+ 2 - 0
ems-cloud/sql/ems_server.sql

@@ -491,6 +491,8 @@ create table adm_ems_device_component  (
   `id`              bigint(20)      not null auto_increment      comment '序号',
   `device_code`     varchar(64)     not null                     comment '设备编码',
   `compo_code`      varchar(64)     not null                     comment '部件编码',
+  `compo_tag`       varchar(256)    default null                 comment '部件标签',
+  `ps_code`         varchar(16)     not null                     comment '工艺标识',
   `ext_compo_code`  varchar(256)    default null                 comment '外部系统编码',
   `compo_model`     varchar(16)     default null                 comment '部件模型',
   `compo_brand`     varchar(128)    default null                 comment '部件品牌',