Explorar o código

设备、产品接口自测

xucaiqin %!s(int64=2) %!d(string=hai) anos
pai
achega
b9eb63e3a3

+ 2 - 3
iot-module/iot-module-manage/iot-module-manage-biz/src/main/resources/bootstrap.yaml

@@ -18,7 +18,6 @@ spring:
       write-date-timestamps-as-nanoseconds: false # 设置不使用 nanoseconds 的格式。例如说 1611460870.401,而是直接 1611460870401
       write-durations-as-timestamps: true # 设置 Duration 的格式,使用时间戳
       fail-on-empty-beans: false # 允许序列化无属性的 Bean
-#  main:
-#    allow-bean-definition-overriding: true
-
+  main:
+    allow-circular-references: true # 允许循环依赖,因为项目是三层架构,无法避免这个情况。
 

+ 51 - 1
iot-module/iot-module-manage/iot-module-manage-biz/src/main/resources/mapper/IotDeviceMapper.xml

@@ -40,12 +40,62 @@
     </select>
 
   <select id="pageQuery" resultType="com.middle.platform.manage.biz.domain.vo.IotDeviceVo">
-      select *
+      select id.*, ip.name as productName
       from iot_device id
+               inner join iot_product ip on id.product_id = ip.id and ip.del_flag = 0
       <where>
           <if test="keywords != null and keywords != ''">
               and id.name like concat('%', #{keywords,jdbcType=VARCHAR}, '%')
           </if>
+        <if test="productId != null">
+            and id.product_id = #{productId,jdbcType=BIGINT}
+        </if>
+          and id.del_flag = 0
       </where>
   </select>
+
+  <select id="count" resultType="java.util.Map">
+      select count(case when id.status = 1 then 1 end) online,
+             count(case when id.status = 0 then 1 end) offline
+      from iot_device id
+      <where>
+          <if test="productId != null">
+              and id.product_id = #{productId,jdbcType=BIGINT}
+          </if>
+          and id.del_flag = 0
+      </where>
+  </select>
+
+  <select id="detail" resultType="com.middle.platform.manage.biz.domain.vo.IotDeviceDetailVo">
+      select id.id,
+             id.name,
+             id.sn,
+             id.guid,
+             id.subtitle,
+             id.lat,
+             id.lon,
+             id.address,
+             id.online_time,
+             id.status,
+             id.enable_flag,
+             id.remark,
+             id.create_time,
+             id.create_by,
+             id.update_time,
+             id.update_by,
+             ip.code            productCode,
+             ip.name            productName,
+             ip.secret,
+             ip.node_type       nodeType,
+             ip.network_type    networkType,
+             ip.report_protocol reportProtocol,
+             ip.data_format     dataFormat,
+             ip.auth_type       authType,
+             ip.vendors,
+             ip.tag
+      from iot_device id
+               inner join iot_product ip on id.product_id = ip.id and ip.del_flag = 0
+      where id.id = #{id,jdbcType=BIGINT}
+        and id.del_flag = 0
+  </select>
 </mapper>

+ 8 - 0
iot-module/iot-module-manage/iot-module-manage-biz/src/main/resources/mapper/IotProductMapper.xml

@@ -41,4 +41,12 @@
           and ip.del_flag = 0
       </where>
   </select>
+
+  <select id="list" resultType="com.middle.platform.manage.biz.domain.vo.IotProductDownVo">
+      select ip.id, ip.name, ip.code
+      from iot_product ip
+      <where>
+          and ip.del_flag = 0
+      </where>
+  </select>
 </mapper>