Browse Source

对象属性值接口

lv.wenbin 10 months ago
parent
commit
456a8becad

+ 108 - 0
ems-cloud/ems-modules/ems-server/src/main/java/com/ruoyi/ems/controller/EmsObjAttrValueController.java

@@ -0,0 +1,108 @@
+package com.ruoyi.ems.controller;
+
+import com.ruoyi.common.core.web.controller.BaseController;
+import com.ruoyi.common.core.web.domain.AjaxResult;
+import com.ruoyi.common.log.annotation.Log;
+import com.ruoyi.common.log.enums.BusinessType;
+import com.ruoyi.ems.domain.EmsObjAttrValue;
+import com.ruoyi.ems.service.IEmsObjAttrValueService;
+import io.swagger.annotations.Api;
+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 java.util.List;
+
+/**
+ * 能源对象属性值Controller
+ *
+ * @author ruoyi
+ * @date 2024-09-25
+ */
+@RestController
+@RequestMapping("/object/attr/value")
+@Api(value = "EmsObjAttrValueController", description = "能源对象属性值管理")
+public class EmsObjAttrValueController extends BaseController {
+    @Autowired
+    private IEmsObjAttrValueService objAttrValueService;
+
+    /**
+     * 查询能源对象属性值列表
+     */
+    @GetMapping("/list")
+    public AjaxResult list(EmsObjAttrValue objAttrValue) {
+        List<EmsObjAttrValue> list = objAttrValueService.selectObjAttrValueList(objAttrValue);
+        return success(list);
+    }
+
+    /**
+     * 查询能源对象属性值列表
+     */
+    @GetMapping("/getByObj")
+    public AjaxResult list(@RequestParam(name = "objType") Integer objType,
+        @RequestParam(name = "objCode") String objCode) {
+        List<EmsObjAttrValue> list = objAttrValueService.selectByObjCode(objType, objCode);
+        return success(list);
+    }
+
+    /**
+     * 获取能源对象属性值详细信息
+     */
+    @GetMapping(value = "/{id}")
+    public AjaxResult getInfo(@PathVariable("id") Long id) {
+        return success(objAttrValueService.selectObjAttrValueById(id));
+    }
+
+    /**
+     * 新增能源对象属性值
+     */
+    @Log(title = "能源对象属性值", businessType = BusinessType.INSERT)
+    @PostMapping
+    public AjaxResult add(@RequestBody EmsObjAttrValue EmsObjAttrValue) {
+        return toAjax(objAttrValueService.insertObjAttrValue(EmsObjAttrValue));
+    }
+
+    /**
+     * 新增能源对象属性值
+     */
+    @Log(title = "能源对象属性值", businessType = BusinessType.INSERT)
+    @PostMapping("/batch")
+    public AjaxResult addBatch(@RequestBody List<EmsObjAttrValue> list) {
+        return toAjax(objAttrValueService.insertBatch(list));
+    }
+
+    /**
+     * 修改能源对象属性值
+     */
+    @Log(title = "能源对象属性值", businessType = BusinessType.UPDATE)
+    @PutMapping
+    public AjaxResult edit(@RequestBody EmsObjAttrValue EmsObjAttrValue) {
+        return toAjax(objAttrValueService.updateObjAttrValue(EmsObjAttrValue));
+    }
+
+    /**
+     * 删除能源对象属性值
+     */
+    @Log(title = "能源对象属性值", businessType = BusinessType.DELETE)
+    @DeleteMapping("/{ids}")
+    public AjaxResult remove(@PathVariable Long[] ids) {
+        return toAjax(objAttrValueService.deleteObjAttrValueByIds(ids));
+    }
+
+    /**
+     * 删除能源对象属性值
+     */
+    @Log(title = "能源对象属性值", businessType = BusinessType.DELETE)
+    @DeleteMapping("/deleteByObj")
+    public AjaxResult removeByObj(@RequestParam(name = "objType") Integer objType,
+        @RequestParam(name = "objCode") String objCode) {
+        return toAjax(objAttrValueService.deleteByObjCode(objType, objCode));
+    }
+}

+ 0 - 12
ems-cloud/ems-modules/ems-server/src/main/java/com/ruoyi/ems/domain/EmsObjAttr.java

@@ -27,9 +27,6 @@ public class EmsObjAttr extends BaseEntity
     /** 属性名称 */
     private String attrName;
 
-    /** 属性值 */
-    private String attrValue;
-
     /** 属性单位 */
     private String attrUnit;
 
@@ -69,15 +66,7 @@ public class EmsObjAttr extends BaseEntity
     {
         return attrName;
     }
-    public void setAttrValue(String attrValue) 
-    {
-        this.attrValue = attrValue;
-    }
 
-    public String getAttrValue() 
-    {
-        return attrValue;
-    }
     public void setAttrUnit(String attrUnit) 
     {
         this.attrUnit = attrUnit;
@@ -95,7 +84,6 @@ public class EmsObjAttr extends BaseEntity
             .append("modelCode", getModelCode())
             .append("attrKey", getAttrKey())
             .append("attrName", getAttrName())
-            .append("attrValue", getAttrValue())
             .append("attrUnit", getAttrUnit())
             .toString();
     }

+ 102 - 0
ems-cloud/ems-modules/ems-server/src/main/java/com/ruoyi/ems/domain/EmsObjAttrValue.java

@@ -0,0 +1,102 @@
+package com.ruoyi.ems.domain;
+
+import org.apache.commons.lang3.builder.ToStringBuilder;
+import org.apache.commons.lang3.builder.ToStringStyle;
+import com.ruoyi.common.core.annotation.Excel;
+import com.ruoyi.common.core.web.domain.BaseEntity;
+
+/**
+ * 能源对象属性值对象 adm_ems_obj_attr_value
+ * 
+ * @author ruoyi
+ * @date 2024-09-25
+ */
+public class EmsObjAttrValue extends BaseEntity
+{
+    private static final long serialVersionUID = 1L;
+
+    /** 序号 */
+    private Long id;
+
+    /** 对象代码 */
+    private String objCode;
+
+    /** 对象类型 */
+    private Long objType;
+
+    /** 属性标识 */
+    private String attrKey;
+
+    /** 属性值 */
+    private String attrValue;
+
+    /** 模型code */
+    private String modelCode;
+
+    public void setId(Long id) 
+    {
+        this.id = id;
+    }
+
+    public Long getId() 
+    {
+        return id;
+    }
+    public void setObjCode(String objCode) 
+    {
+        this.objCode = objCode;
+    }
+
+    public String getObjCode() 
+    {
+        return objCode;
+    }
+    public void setObjType(Long objType) 
+    {
+        this.objType = objType;
+    }
+
+    public Long getObjType() 
+    {
+        return objType;
+    }
+    public void setAttrKey(String attrKey) 
+    {
+        this.attrKey = attrKey;
+    }
+
+    public String getAttrKey() 
+    {
+        return attrKey;
+    }
+    public void setAttrValue(String attrValue) 
+    {
+        this.attrValue = attrValue;
+    }
+
+    public String getAttrValue() 
+    {
+        return attrValue;
+    }
+    public void setModelCode(String modelCode) 
+    {
+        this.modelCode = modelCode;
+    }
+
+    public String getModelCode() 
+    {
+        return modelCode;
+    }
+
+    @Override
+    public String toString() {
+        return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
+            .append("id", getId())
+            .append("objCode", getObjCode())
+            .append("objType", getObjType())
+            .append("attrKey", getAttrKey())
+            .append("attrValue", getAttrValue())
+            .append("modelCode", getModelCode())
+            .toString();
+    }
+}

+ 89 - 0
ems-cloud/ems-modules/ems-server/src/main/java/com/ruoyi/ems/mapper/EmsObjAttrValueMapper.java

@@ -0,0 +1,89 @@
+package com.ruoyi.ems.mapper;
+
+import com.ruoyi.ems.domain.EmsObjAttrValue;
+import io.swagger.models.auth.In;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
+
+/**
+ * 能源对象属性值Mapper接口
+ *
+ * @author ruoyi
+ * @date 2024-09-25
+ */
+public interface EmsObjAttrValueMapper {
+    /**
+     * 查询能源对象属性值
+     *
+     * @param id 能源对象属性值主键
+     * @return 能源对象属性值
+     */
+    EmsObjAttrValue selectObjAttrValueById(Long id);
+
+    /**
+     * 查询能源对象属性值列表
+     *
+     * @param objAttrValue 能源对象属性值
+     * @return 能源对象属性值集合
+     */
+    List<EmsObjAttrValue> selectObjAttrValueList(EmsObjAttrValue objAttrValue);
+
+    /**
+     * 查询能源对象属性值列表
+     *
+     * @param objType 对象类型
+     * @param objCode 对象代码
+     * @return 能源对象属性值集合
+     */
+    List<EmsObjAttrValue> selectByObjCode(@Param("objType") Integer objType, @Param("objCode") String objCode);
+
+    /**
+     * 新增能源对象属性值
+     *
+     * @param objAttrValue 能源对象属性值
+     * @return 结果
+     */
+    int insertObjAttrValue(EmsObjAttrValue objAttrValue);
+
+    /**
+     * 批量新增能源对象属性值
+     *
+     * @param list 能源对象属性值
+     * @return 结果
+     */
+    int insertBatch(List<EmsObjAttrValue> list);
+
+    /**
+     * 修改能源对象属性值
+     *
+     * @param objAttrValue 能源对象属性值
+     * @return 结果
+     */
+    int updateObjAttrValue(EmsObjAttrValue objAttrValue);
+
+    /**
+     * 删除能源对象属性值
+     *
+     * @param objType 对象类型
+     * @param objCode 对象代码
+     * @return 结果
+     */
+    int deleteByObjCode(@Param("objType") Integer objType, @Param("objCode") String objCode);
+
+    /**
+     * 删除能源对象属性值
+     *
+     * @param id 能源对象属性值主键
+     * @return 结果
+     */
+    int deleteObjAttrValueById(Long id);
+
+    /**
+     * 批量删除能源对象属性值
+     *
+     * @param ids 需要删除的数据主键集合
+     * @return 结果
+     */
+    int deleteObjAttrValueByIds(Long[] ids);
+}

+ 87 - 0
ems-cloud/ems-modules/ems-server/src/main/java/com/ruoyi/ems/service/IEmsObjAttrValueService.java

@@ -0,0 +1,87 @@
+package com.ruoyi.ems.service;
+
+import com.ruoyi.ems.domain.EmsObjAttrValue;
+
+import java.util.List;
+
+/**
+ * 能源对象属性值Service接口
+ *
+ * @author ruoyi
+ * @date 2024-09-25
+ */
+public interface IEmsObjAttrValueService {
+    /**
+     * 查询能源对象属性值
+     *
+     * @param id 能源对象属性值主键
+     * @return 能源对象属性值
+     */
+    EmsObjAttrValue selectObjAttrValueById(Long id);
+
+    /**
+     * 查询能源对象属性值列表
+     *
+     * @param objAttrValue 能源对象属性值
+     * @return 能源对象属性值集合
+     */
+    List<EmsObjAttrValue> selectObjAttrValueList(EmsObjAttrValue objAttrValue);
+
+    /**
+     * 查询能源对象属性值列表
+     *
+     * @param objType 对象类型
+     * @param objCode 对象代码
+     * @return 能源对象属性值集合
+     */
+    List<EmsObjAttrValue> selectByObjCode(Integer objType, String objCode);
+
+    /**
+     * 新增能源对象属性值
+     *
+     * @param objAttrValue 能源对象属性值
+     * @return 结果
+     */
+    int insertObjAttrValue(EmsObjAttrValue objAttrValue);
+
+    /**
+     * 批量新增能源对象属性值
+     *
+     * @param list 能源对象属性值
+     * @return 结果
+     */
+    int insertBatch(List<EmsObjAttrValue> list);
+
+    /**
+     * 修改能源对象属性值
+     *
+     * @param objAttrValue 能源对象属性值
+     * @return 结果
+     */
+    int updateObjAttrValue(EmsObjAttrValue objAttrValue);
+
+    /**
+     * 批量删除能源对象属性值
+     *
+     * @param ids 需要删除的能源对象属性值主键集合
+     * @return 结果
+     */
+    int deleteObjAttrValueByIds(Long[] ids);
+
+    /**
+     * 删除能源对象属性值信息
+     *
+     * @param id 能源对象属性值主键
+     * @return 结果
+     */
+    int deleteObjAttrValueById(Long id);
+
+    /**
+     * 删除能源对象属性值
+     *
+     * @param objType 对象类型
+     * @param objCode 对象代码
+     * @return 结果
+     */
+    int deleteByObjCode(Integer objType, String objCode);
+}

+ 109 - 0
ems-cloud/ems-modules/ems-server/src/main/java/com/ruoyi/ems/service/impl/EmsObjAttrValueServiceImpl.java

@@ -0,0 +1,109 @@
+package com.ruoyi.ems.service.impl;
+
+import com.ruoyi.ems.domain.EmsObjAttrValue;
+import com.ruoyi.ems.mapper.EmsObjAttrValueMapper;
+import com.ruoyi.ems.service.IEmsObjAttrValueService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.List;
+
+/**
+ * 能源对象属性值Service业务层处理
+ * 
+ * @author ruoyi
+ * @date 2024-09-25
+ */
+@Service
+public class EmsObjAttrValueServiceImpl implements IEmsObjAttrValueService
+{
+    @Autowired
+    private EmsObjAttrValueMapper objAttrValueMapper;
+
+    /**
+     * 查询能源对象属性值
+     * 
+     * @param id 能源对象属性值主键
+     * @return 能源对象属性值
+     */
+    @Override
+    public EmsObjAttrValue selectObjAttrValueById(Long id)
+    {
+        return objAttrValueMapper.selectObjAttrValueById(id);
+    }
+
+    /**
+     * 查询能源对象属性值列表
+     * 
+     * @param objAttrValue 能源对象属性值
+     * @return 能源对象属性值
+     */
+    @Override
+    public List<EmsObjAttrValue> selectObjAttrValueList(EmsObjAttrValue objAttrValue)
+    {
+        return objAttrValueMapper.selectObjAttrValueList(objAttrValue);
+    }
+
+    @Override
+    public List<EmsObjAttrValue> selectByObjCode(Integer objType, String objCode) {
+        return objAttrValueMapper.selectByObjCode(objType, objCode);
+    }
+
+    /**
+     * 新增能源对象属性值
+     * 
+     * @param objAttrValue 能源对象属性值
+     * @return 结果
+     */
+    @Override
+    public int insertObjAttrValue(EmsObjAttrValue objAttrValue)
+    {
+        return objAttrValueMapper.insertObjAttrValue(objAttrValue);
+    }
+
+    @Override
+    public int insertBatch(List<EmsObjAttrValue> list) {
+        return objAttrValueMapper.insertBatch(list);
+    }
+
+    /**
+     * 修改能源对象属性值
+     * 
+     * @param objAttrValue 能源对象属性值
+     * @return 结果
+     */
+    @Override
+    public int updateObjAttrValue(EmsObjAttrValue objAttrValue)
+    {
+        return objAttrValueMapper.updateObjAttrValue(objAttrValue);
+    }
+
+    /**
+     * 批量删除能源对象属性值
+     * 
+     * @param ids 需要删除的能源对象属性值主键
+     * @return 结果
+     */
+    @Override
+    public int deleteObjAttrValueByIds(Long[] ids)
+    {
+        return objAttrValueMapper.deleteObjAttrValueByIds(ids);
+    }
+
+    /**
+     * 删除能源对象属性值信息
+     * 
+     * @param id 能源对象属性值主键
+     * @return 结果
+     */
+    @Override
+    public int deleteObjAttrValueById(Long id)
+    {
+        return objAttrValueMapper.deleteObjAttrValueById(id);
+    }
+
+    @Override
+    public int deleteByObjCode(Integer objType, String objCode) {
+        return objAttrValueMapper.deleteByObjCode(objType, objCode);
+    }
+}

+ 3 - 7
ems-cloud/ems-modules/ems-server/src/main/resources/mapper/ems/EmsObjAttrMapper.xml

@@ -9,12 +9,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         <result property="modelCode"    column="model_code"    />
         <result property="attrKey"    column="attr_key"    />
         <result property="attrName"    column="attr_name"    />
-        <result property="attrValue"    column="attr_value"    />
         <result property="attrUnit"    column="attr_unit"    />
     </resultMap>
 
     <sql id="selectAdmEmsObjAttrVo">
-        select id, model_code, attr_key, attr_name, attr_value, attr_unit from adm_ems_obj_attr
+        select id, model_code, attr_key, attr_name, attr_unit from adm_ems_obj_attr
     </sql>
 
     <select id="selectObjAttrList" parameterType="com.ruoyi.ems.domain.EmsObjAttr" resultMap="ObjAttrResult">
@@ -42,23 +41,21 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="modelCode != null and modelCode != ''">model_code,</if>
             <if test="attrKey != null and attrKey != ''">attr_key,</if>
             <if test="attrName != null and attrName != ''">attr_name,</if>
-            <if test="attrValue != null">attr_value,</if>
             <if test="attrUnit != null">attr_unit,</if>
          </trim>
         <trim prefix="values (" suffix=")" suffixOverrides=",">
             <if test="modelCode != null and modelCode != ''">#{modelCode},</if>
             <if test="attrKey != null and attrKey != ''">#{attrKey},</if>
             <if test="attrName != null and attrName != ''">#{attrName},</if>
-            <if test="attrValue != null">#{attrValue},</if>
             <if test="attrUnit != null">#{attrUnit},</if>
          </trim>
     </insert>
 
     <insert id="insertBatch" parameterType="java.util.List">
-        insert into adm_ems_obj_attr (model_code, attr_key, attr_name, attr_value, attr_unit)
+        insert into adm_ems_obj_attr (model_code, attr_key, attr_name, attr_unit)
         values
         <foreach collection="list" item="item" index="index" separator=",">
-            (#{item.modelCode}, #{item.attrKey}, #{item.attrName}, #{item.attrValue}, #{item.attrUnit})
+            (#{item.modelCode}, #{item.attrKey}, #{item.attrName}, #{item.attrUnit})
         </foreach>
     </insert>
 
@@ -68,7 +65,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="modelCode != null and modelCode != ''">model_code = #{modelCode},</if>
             <if test="attrKey != null and attrKey != ''">attr_key = #{attrKey},</if>
             <if test="attrName != null and attrName != ''">attr_name = #{attrName},</if>
-            <if test="attrValue != null">attr_value = #{attrValue},</if>
             <if test="attrUnit != null">attr_unit = #{attrUnit},</if>
         </trim>
         where id = #{id}

+ 92 - 0
ems-cloud/ems-modules/ems-server/src/main/resources/mapper/ems/EmsObjAttrValueMapper.xml

@@ -0,0 +1,92 @@
+<?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="com.ruoyi.ems.mapper.EmsObjAttrValueMapper">
+    
+    <resultMap type="com.ruoyi.ems.domain.EmsObjAttrValue" id="objAttrValueResult">
+        <result property="id"    column="id"    />
+        <result property="objCode"    column="obj_code"    />
+        <result property="objType"    column="obj_type"    />
+        <result property="attrKey"    column="attr_key"    />
+        <result property="attrValue"    column="attr_value"    />
+        <result property="modelCode"    column="model_code"    />
+    </resultMap>
+
+    <sql id="selectObjAttrValueVo">
+        select id, obj_code, obj_type, attr_key, attr_value, model_code from adm_ems_obj_attr_value
+    </sql>
+
+    <select id="selectObjAttrValueList" parameterType="com.ruoyi.ems.domain.EmsObjAttrValue" resultMap="objAttrValueResult">
+        <include refid="selectObjAttrValueVo"/>
+        <where>  
+            <if test="objCode != null  and objCode != ''"> and obj_code = #{objCode}</if>
+            <if test="objType != null "> and obj_type = #{objType}</if>
+            <if test="attrKey != null  and attrKey != ''"> and attr_key = #{attrKey}</if>
+            <if test="modelCode != null  and modelCode != ''"> and model_code = #{modelCode}</if>
+        </where>
+    </select>
+
+    <select id="selectByObjCode" resultMap="objAttrValueResult">
+        <include refid="selectObjAttrValueVo"/>
+        where obj_type = #{objType} and obj_code = #{objCode}
+    </select>
+
+    <select id="selectObjAttrValueById" parameterType="Long" resultMap="objAttrValueResult">
+        <include refid="selectObjAttrValueVo"/>
+        where id = #{id}
+    </select>
+        
+    <insert id="insertObjAttrValue" parameterType="com.ruoyi.ems.domain.EmsObjAttrValue" useGeneratedKeys="true" keyProperty="id">
+        insert into adm_ems_obj_attr_value
+        <trim prefix="(" suffix=")" suffixOverrides=",">
+            <if test="objCode != null and objCode != ''">obj_code,</if>
+            <if test="objType != null">obj_type,</if>
+            <if test="attrKey != null and attrKey != ''">attr_key,</if>
+            <if test="attrValue != null">attr_value,</if>
+            <if test="modelCode != null">model_code,</if>
+         </trim>
+        <trim prefix="values (" suffix=")" suffixOverrides=",">
+            <if test="objCode != null and objCode != ''">#{objCode},</if>
+            <if test="objType != null">#{objType},</if>
+            <if test="attrKey != null and attrKey != ''">#{attrKey},</if>
+            <if test="attrValue != null">#{attrValue},</if>
+            <if test="modelCode != null">#{modelCode},</if>
+         </trim>
+    </insert>
+
+    <insert id="insertBatch" parameterType="java.util.List" >
+        insert into adm_ems_obj_attr_value (obj_code, obj_type, attr_key, attr_value, model_code)
+        values
+        <foreach collection="list" item="item" index="index" separator=",">
+            (#{item.objCode}, #{item.objType}, #{item.attrKey}, #{item.attrValue}, #{item.modelCode})
+        </foreach>
+    </insert>
+
+    <update id="updateObjAttrValue" parameterType="com.ruoyi.ems.domain.EmsObjAttrValue">
+        update adm_ems_obj_attr_value
+        <trim prefix="SET" suffixOverrides=",">
+            <if test="objCode != null and objCode != ''">obj_code = #{objCode},</if>
+            <if test="objType != null">obj_type = #{objType},</if>
+            <if test="attrKey != null and attrKey != ''">attr_key = #{attrKey},</if>
+            <if test="attrValue != null">attr_value = #{attrValue},</if>
+            <if test="modelCode != null">model_code = #{modelCode},</if>
+        </trim>
+        where id = #{id}
+    </update>
+
+    <delete id="deleteObjAttrValueById" parameterType="Long">
+        delete from adm_ems_obj_attr_value where id = #{id}
+    </delete>
+
+    <delete id="deleteByObjCode" parameterType="Long">
+        delete from adm_ems_obj_attr_value where obj_type = {objType} and obj_code = #{objCode} and
+    </delete>
+
+    <delete id="deleteObjAttrValueByIds" parameterType="String">
+        delete from adm_ems_obj_attr_value where id in 
+        <foreach item="id" collection="array" open="(" separator="," close=")">
+            #{id}
+        </foreach>
+    </delete>
+</mapper>

+ 8 - 7
ems-cloud/sql/ems_init_data.sql

@@ -129,14 +129,15 @@ INSERT INTO `adm_ems_obj_model` (`model_code`, `model_name`, `obj_type`) VALUES
 INSERT INTO `adm_ems_obj_model` (`model_code`, `model_name`, `obj_type`) VALUES ('M_C102', '南区储能模型', 1);
 INSERT INTO `adm_ems_obj_model` (`model_code`, `model_name`, `obj_type`) VALUES ('M_Z010', '照明设备模型', 2);
 
+
 -- 对象属性DEMO数据
-INSERT INTO `adm_ems_obj_attr` (`model_code`, `attr_key`, `attr_name`, `attr_value`, `attr_unit`) VALUES ('M_W2',    'voltageLevel',      '电压等级', '10', 'kV');
-INSERT INTO `adm_ems_obj_attr` (`model_code`, `attr_key`, `attr_name`, `attr_value`, `attr_unit`) VALUES ('M_E501',  'installedCapacity', '装机容量', '150', 'kw');
-INSERT INTO `adm_ems_obj_attr` (`model_code`, `attr_key`, `attr_name`, `attr_value`, `attr_unit`) VALUES ('M_E502',  'installedCapacity', '装机容量', '150', 'kw');
-INSERT INTO `adm_ems_obj_attr` (`model_code`, `attr_key`, `attr_name`, `attr_value`, `attr_unit`) VALUES ('M_E503',  'installedCapacity', '装机容量', '150', 'kw');
-INSERT INTO `adm_ems_obj_attr` (`model_code`, `attr_key`, `attr_name`, `attr_value`, `attr_unit`) VALUES ('M_C101',  'storageCapacity',   '储能容量', '100', 'kW-h');
-INSERT INTO `adm_ems_obj_attr` (`model_code`, `attr_key`, `attr_name`, `attr_value`, `attr_unit`) VALUES ('M_C102',  'storageCapacity',   '储能容量', '100', 'kW-h');
-INSERT INTO `adm_ems_obj_attr` (`model_code`, `attr_key`, `attr_name`, `attr_value`, `attr_unit`) VALUES ('M_Z010',  'power',   '功率', '100', 'kW-h');
+INSERT INTO `adm_ems_obj_attr` (`model_code`, `attr_key`, `attr_name`, `attr_unit`) VALUES ('M_W2',    'voltageLevel',      '电压等级', 'kV');
+INSERT INTO `adm_ems_obj_attr` (`model_code`, `attr_key`, `attr_name`, `attr_unit`) VALUES ('M_E501',  'installedCapacity', '装机容量', 'kw');
+INSERT INTO `adm_ems_obj_attr` (`model_code`, `attr_key`, `attr_name`, `attr_unit`) VALUES ('M_E502',  'installedCapacity', '装机容量', 'kw');
+INSERT INTO `adm_ems_obj_attr` (`model_code`, `attr_key`, `attr_name`, `attr_unit`) VALUES ('M_E503',  'installedCapacity', '装机容量', 'kw');
+INSERT INTO `adm_ems_obj_attr` (`model_code`, `attr_key`, `attr_name`, `attr_unit`) VALUES ('M_C101',  'storageCapacity',   '储能容量', 'kW-h');
+INSERT INTO `adm_ems_obj_attr` (`model_code`, `attr_key`, `attr_name`, `attr_unit`) VALUES ('M_C102',  'storageCapacity',   '储能容量', 'kW-h');
+INSERT INTO `adm_ems_obj_attr` (`model_code`, `attr_key`, `attr_name`, `attr_unit`) VALUES ('M_Z010',  'power',   '功率', 'kW-h');
 
 -- 对象能力DEMO数据
 INSERT INTO `adm_ems_obj_ability` (`model_code`, `ability_key`, `ability_name`, `ability_desc`, `ability_param`) VALUES ('M_W2', 'checkLine', '线路检测', '执行xx方法进行测试', '{\"enable\":\"1\"}');

+ 16 - 1
ems-cloud/sql/ems_server.sql

@@ -547,7 +547,6 @@ create table adm_ems_obj_attr  (
   `model_code`      varchar(16)     not null                     comment '模型code',
   `attr_key`        varchar(128)    not null                     comment '属性标识',
   `attr_name`       varchar(256)    default null                 comment '属性名称',
-  `attr_value`      varchar(1024)   default null                 comment '属性值',
   `attr_unit`       varchar(32)     default null                 comment '属性单位',
   primary key (`id`),
   unique key ux_ems_obj_attr(`model_code`, `attr_key`)
@@ -555,6 +554,22 @@ create table adm_ems_obj_attr  (
 
 
 -- ----------------------------
+-- 能源对象属性值表
+-- ----------------------------
+drop table if exists adm_ems_obj_attr_value;
+create table adm_ems_obj_attr_value  (
+  `id`              bigint(20)      not null auto_increment      comment '序号',
+  `obj_code`        varchar(64)     not null                     comment '对象代码',
+  `obj_type`        int             not null                     comment '对象类型',
+  `attr_key`        varchar(128)    not null                     comment '属性标识',
+  `attr_value`      varchar(32)     default null                 comment '属性值',
+  `model_code`      varchar(16)     default null                 comment '模型code',
+  primary key (`id`),
+  unique key ux_ems_obj_attr_value(`obj_code`, `obj_type`, `attr_key`)
+) engine=innodb auto_increment=1 comment = '能源对象属性值表';
+
+
+-- ----------------------------
 -- 能源对象能力表
 -- ----------------------------
 drop table if exists adm_ems_obj_ability;