DeviceMapper.xml 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. <!DOCTYPE mapper
  2. PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
  3. "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  4. <mapper namespace="com.bosshand.virgo.ringzle.dao.DeviceDao">
  5. <resultMap type="com.bosshand.virgo.ringzle.model.Device" id="deviceResult">
  6. <id column="id" property="id"/>
  7. <result column="deviceId" property="deviceId"/>
  8. <result column="type" property="type"/>
  9. <result column="status" property="status"/>
  10. <result column="isHalt" property="isHalt"/>
  11. <result column="createDate" property="createDate"/>
  12. <result column="deviceName" property="deviceName"/>
  13. <result column="simcardId" property="simcardId"/>
  14. <result column="lastDeployTime" property="lastDeployTime"/>
  15. <result column="lastHeartBeat" property="lastHeartBeat"/>
  16. <result column="longitude" property="longitude"/>
  17. <result column="latitude" property="latitude"/>
  18. <result column="organizationId" property="organizationId"/>
  19. <result column="projectId" property="projectId"/>
  20. <result column="bimIntegrateId" property="bimIntegrateId"/>
  21. <result column="elementId" property="elementId"/>
  22. <result column="equipmentId" property="equipmentId"/>
  23. </resultMap>
  24. <insert id="save" parameterType="com.bosshand.virgo.ringzle.model.Device" useGeneratedKeys="true" keyProperty="id">
  25. INSERT INTO iot_device (deviceId, type, status, isHalt, createDate, deviceName, simcardId, lastDeployTime, lastHeartBeat, longitude,
  26. latitude, organizationId, projectId, bimIntegrateId, elementId, equipmentId)
  27. VALUES (#{deviceId}, #{type}, #{status}, #{isHalt}, now(), #{deviceName}, #{simcardId}, #{lastDeployTime}, #{lastHeartBeat}, #{longitude},
  28. #{latitude}, #{organizationId}, #{projectId}, #{bimIntegrateId}, #{elementId}, #{equipmentId});
  29. </insert>
  30. <select id="getList" resultMap="deviceResult">
  31. select * from iot_device
  32. <where>
  33. <if test="id != -1">
  34. and id =#{id}
  35. </if>
  36. <if test="organizationId != 0">
  37. and organizationId =#{organizationId}
  38. </if>
  39. <if test="projectId != 0">
  40. and projectId =#{projectId}
  41. </if>
  42. <if test="type != -1">
  43. and type =#{type}
  44. </if>
  45. <if test="status != -1">
  46. and status =#{status}
  47. </if>
  48. <if test="isHalt != -1">
  49. and isHalt =#{isHalt}
  50. </if>
  51. <if test="deviceName != null">
  52. and deviceName =#{deviceName}
  53. </if>
  54. <if test="simcardId != 0">
  55. and simcardId =#{simcardId}
  56. </if>
  57. <if test="bimIntegrateId != null">
  58. and bimIntegrateId =#{bimIntegrateId}
  59. </if>
  60. <if test="equipmentId != 0">
  61. and equipmentId =#{equipmentId}
  62. </if>
  63. </where>
  64. </select>
  65. <select id="getListByElement" resultMap="deviceResult">
  66. select * from iot_device where projectId =#{projectId} and bimIntegrateId=#{bimIntegrateId} and elementId =#{elementId}
  67. </select>
  68. <select id="getDevice" resultMap="deviceResult">
  69. select * from iot_device where deviceId =#{deviceId}
  70. </select>
  71. <update id="update">
  72. update iot_device
  73. <trim prefix="set" suffixOverrides=",">
  74. <if test="deviceId!=null">deviceId=#{deviceId},</if>
  75. <if test="type!=-1">type=#{type},</if>
  76. <if test="status==-1">status=#{status},</if>
  77. <if test="isHalt!=-1">isHalt=#{isHalt},</if>
  78. <if test="deviceName!=null">deviceName=#{deviceName},</if>
  79. <if test="simcardId!=0">simcardId=#{simcardId},</if>
  80. <if test="lastDeployTime!=null">lastDeployTime=#{lastDeployTime},</if>
  81. <if test="lastHeartBeat!=null">lastHeartBeat=#{lastHeartBeat},</if>
  82. <if test="longitude!=0">longitude=#{longitude},</if>
  83. <if test="latitude!=0">latitude=#{latitude},</if>
  84. <if test="organizationId!=0">organizationId=#{organizationId},</if>
  85. <if test="projectId!=0">projectId=#{projectId},</if>
  86. <if test="bimIntegrateId!=null">bimIntegrateId=#{bimIntegrateId},</if>
  87. <if test="elementId!=null">elementId=#{elementId},</if>
  88. <if test="equipmentId!=0">equipmentId=#{equipmentId},</if>
  89. </trim>
  90. where id=#{id}
  91. </update>
  92. <delete id="delete">
  93. delete FROM iot_device where id=#{id}
  94. </delete>
  95. </mapper>