Browse Source

修改组返回信息添加数据模型表达式

zhoupeng 2 years ago
parent
commit
7b62678c7b

+ 2 - 0
chaunyi_opc/opc_common/src/main/java/com/example/opc_common/entity/Item.java

@@ -37,6 +37,8 @@ public class Item implements Serializable {
      */
     private Integer dataModelId;
 
+    private String operationRule;
+
     /**
      * 虚拟数据源名称,返回给前端的
      */

+ 6 - 0
chaunyi_opc/opc_da/src/main/java/com/example/opc_da/service/impl/ItemGroupServiceImpl.java

@@ -109,6 +109,12 @@ public class ItemGroupServiceImpl implements ItemGroupService {
     @Override
     public Result getItemGroupById(Integer id) {
         ItemGroup itemGroup = itemGroupDao.getItemGroupById(id);
+        if (Blank.isEmpty(itemGroup)) {
+            return Result.no(ResultEnum.REQUEST_WRONGPARAMS.getRespCode(), "不存在此itemGroup,请重试");
+        }
+        if (Blank.isEmpty(itemGroup.getDataSourceId())) {
+            return Result.no(ResultEnum.REQUEST_WRONGPARAMS.getRespCode(), "请刷新重试");
+        }
         DataSource dataSource = dataSourceDao.getDataSourceById(itemGroup.getDataSourceId());
         List<Item> itemList = itemGroupDao.getItemListByGroupId(id);
         if (Blank.isNotEmpty(itemList)) {

+ 1 - 0
chaunyi_opc/opc_da/src/main/java/com/example/opc_da/util/OpcDaUtil.java

@@ -436,6 +436,7 @@ public class OpcDaUtil {
                                     jsonObject.put("dataValue", val.get("value"));
                                 }
                             }
+                            jsonObject.put("operationRule", Blank.isNotEmpty(dm) ? dm.getOperationRule() : "");
                             jsonObject.put("createTime", date);
                             jsonObject.put("describe", map.get(itemName));
                             jsonObjectList.add(jsonObject);

+ 2 - 2
chaunyi_opc/opc_da/src/main/resources/mapper/DataModelDao.xml

@@ -31,7 +31,7 @@
         from t_data_model
         where user_id = #{userId}
         <if test="operationRule != null">
-            AND (remark LIKE CONCAT('%', #{operationRuleg}, '%') or operation_rule LIKE CONCAT('%', #{operationRuleg},
+            AND (remark LIKE CONCAT('%', #{operationRule}, '%') or operation_rule LIKE CONCAT('%', #{operationRule},
             '%'))
         </if>
     </select>
@@ -42,7 +42,7 @@
         from t_data_model
         where user_id = #{userId}
         <if test="operationRule != null">
-            AND (remark LIKE CONCAT('%', #{operationRuleg}, '%') or operation_rule LIKE CONCAT('%', #{operationRuleg},
+            AND (remark LIKE CONCAT('%', #{operationRule}, '%') or operation_rule LIKE CONCAT('%', #{operationRule},
             '%'))
         </if>
         limit #{startNum},#{limitNum}

+ 11 - 3
chaunyi_opc/opc_da/src/main/resources/mapper/ItemGroupDao.xml

@@ -108,9 +108,17 @@
     </select>
 
     <select id="getItemListByGroupId" resultType="com.example.opc_common.entity.Item">
-        select
-        <include refid="item"/>
-        from t_item
+        select ti.id,
+               ti.item_group_id,
+               ti.item_name,
+               ti.item_read_name,
+               ti.node_index,
+               ti.data_type,
+               ti.`describe`,
+               ti.data_model_id,
+               tdm.operation_rule
+        FROM t_item ti
+        LEFT JOIN t_data_model tdm ON ti.data_model_id = tdm.id
         where item_group_id = #{itemGroupId}
         order by item_name
     </select>

+ 1 - 1
chaunyi_opc/opc_ua/src/main/java/com/example/opc_ua/util/OpcUaUtil.java

@@ -289,7 +289,7 @@ public class OpcUaUtil {
                     jsonObject.put("dataType", null);
                     jsonObject.put("dataValue", null);
                 }
-
+                jsonObject.put("operationRule", Blank.isNotEmpty(dm) ? dm.getOperationRule() : "");
                 jsonObject.put("describe", map.get(itemName));
                 jsonObject.put("createTime", date);
                 jsonObjectList.add(jsonObject);