IotDvsTemplateChannelMapper.xml 3.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  3. <mapper namespace="com.xunmei.iot.mapper.IotDvsTemplateChannelMapper">
  4. <select id="getChannelPlanList" resultType="com.xunmei.iot.vo.videoTemplateAndPlan.VideoChannelPlanVo">
  5. SELECT
  6. d.id as device_id,
  7. d.device_name as channel_name,
  8. d.device_code as channel_code,
  9. i.device_name as dvs_name,
  10. e.net_address,
  11. d.org_name,
  12. a.`name` as template_name,
  13. p.plan_type,
  14. p.update_time as plan_update_time,
  15. p.fail_remark,
  16. p.min_time,
  17. p.max_time
  18. FROM
  19. iot_device_info d
  20. LEFT JOIN iot_device_info i ON d.host_code = i.device_code
  21. LEFT JOIN iot_device_info_extend e ON e.device_id = i.id
  22. LEFT JOIN iot_dvs_template_channel t ON d.iot_token = t.iot_token and d.host_code = t.dvs_code and d.device_code = t.channel_code
  23. LEFT JOIN iot_dvs_template a ON t.iot_token = a.iot_token and t.template_md5 = a.template_md5
  24. LEFT JOIN iot_dvs_plantype p ON d.iot_token = p.iot_token and d.host_code = p.dvs_code and d.device_code = p.channel_code
  25. WHERE
  26. d.device_type = 3
  27. and d.deleted = 0
  28. <choose>
  29. <when test="req.checkSub == false">
  30. and d.org_id=#{req.orgId}
  31. </when>
  32. <otherwise>
  33. and d.org_path like concat(#{req.orgPath},'%')
  34. </otherwise>
  35. </choose>
  36. <if test="req.channelName != null and req.channelName != ''">
  37. and d.device_name like concat('%',#{req.channelName},'%')
  38. </if>
  39. <if test="req.dvsName != null and req.dvsName != ''">
  40. and i.device_name like concat('%',#{req.dvsName},'%')
  41. </if>
  42. <if test="req.planType != null">
  43. and p.plan_type = #{req.planType}
  44. </if>
  45. <if test="req.templateName != null and req.templateName != ''">
  46. <choose>
  47. <when test="req.templateName == '未绑定'">
  48. and a.`name` is null
  49. </when>
  50. <otherwise>
  51. and a.`name` = #{req.templateName}
  52. </otherwise>
  53. </choose>
  54. </if>
  55. order by p.plan_type desc
  56. </select>
  57. <select id="getChannelPlanTimeList" resultType="com.xunmei.iot.vo.videoTemplateAndPlan.VideoChannelPlanTimeVo">
  58. SELECT
  59. p.type,
  60. p.`week`,
  61. p.start_time,
  62. p.end_time
  63. FROM
  64. iot_dvs_plantime p
  65. LEFT JOIN iot_device_info d ON p.dvs_code = d.host_code AND p.channel_code = d.device_code AND p.iot_token = d.iot_token
  66. WHERE
  67. d.id = #{req.deviceId}
  68. <if test="req.week != null and req.week != -1">
  69. AND p.`week` = #{req.week}
  70. </if>
  71. ORDER BY
  72. p.`week` ASC
  73. </select>
  74. <select id="getTemplateNameList" resultType="java.lang.String">
  75. SELECT `name` FROM iot_dvs_template GROUP BY `name` ORDER BY `name`
  76. </select>
  77. </mapper>