PipeEquipmentMapper.xml 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  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="cn.start.tz.module.pressure.dal.mysql.pipeequipment.PipeEquipmentMapper">
  4. <!--
  5. 一般情况下,尽可能使用 Mapper 进行 CRUD 增删改查即可。
  6. 无法满足的场景,例如说多表关联查询,才使用 XML 编写 SQL。
  7. 代码生成器暂时只生成 Mapper XML 文件本身,更多推荐 MybatisX 快速开发插件来生成查询。
  8. 文档可见:https://www.iocoder.cn/MyBatis/x-plugins/
  9. -->
  10. <select id="selectPlanPage">
  11. select USE_PROJECT_CODE,USE_PROJECT_NAME,USE_UNIT_NAME,PIPE_ADDRESS,sum(PIPE_LEN) total_len , use_unit_security_man,use_unit_security_man_phone ,
  12. pipe_administrative_region,pipe_street,min(NEXT_LEGAL_INSPECTION_DATE) NEXT_LEGAL_INSPECTION_DATE,min(NEXT_ANNUAL_DATE) NEXT_ANNUAL_DATE,
  13. sum(case when NEXT_LEGAL_INSPECTION_DATE is not null and IS_SCHEDULING = 0
  14. <if test="nextDate != null and nextDate.size()>= 2">
  15. and NEXT_LEGAL_INSPECTION_DATE between #{nextDate[0]} and #{nextDate[1]}
  16. </if>
  17. then 1 else 0 end) LEGAL_INSPECTION_COUNT,
  18. sum(case when NEXT_ANNUAL_DATE is not null and IS_YEAR_SCHEDULING = 0
  19. <if test="nextDate != null and nextDate.size()>= 2">
  20. and NEXT_ANNUAL_DATE between #{nextDate[0]} and #{nextDate[1]}
  21. </if>
  22. then 1 else 0 end) ANNUAL_COUNT,
  23. listagg(case when NEXT_LEGAL_INSPECTION_DATE is not null and IS_SCHEDULING = 0 then id else null end,',') equip_ids,
  24. listagg(case when NEXT_ANNUAL_DATE is not null and IS_YEAR_SCHEDULING = 0 then id else null end,',') annual_equip_ids
  25. from PRESSURE_PIPE_EQUIPMENT
  26. where DELETED = 0 and (IS_SCHEDULING = 0 or IS_YEAR_SCHEDULING = 0) and USE_UNIT_NAME is not null
  27. <where>
  28. <if test="useUnitName != null">
  29. and use_unit_name like concat('%',#{useUnitName},'%')
  30. </if>
  31. <if test="pipeAddress != null">
  32. and pipe_address like concat('%',#{pipeAddress},'%')
  33. </if>
  34. <if test="pipeAdministrativeRegion != null">
  35. and pipe_administrative_region = #{pipeAdministrativeRegion}
  36. </if>
  37. <if test="pipeStreet != null">
  38. and pipe_street = #{pipeStreet}
  39. </if>
  40. </where>
  41. group by pipe_administrative_region,pipe_street,USE_UNIT_NAME
  42. </select>
  43. <select id="countPlanPage">
  44. select count(1) from (
  45. select USE_UNIT_NAME,PIPE_ADDRESS,sum(PIPE_LEN) total_len , use_unit_security_man,use_unit_security_man_phone ,
  46. pipe_administrative_region,pipe_street,min(NEXT_LEGAL_INSPECTION_DATE) NEXT_LEGAL_INSPECTION_DATE,min(NEXT_ANNUAL_DATE) NEXT_ANNUAL_DATE,
  47. sum(case when NEXT_LEGAL_INSPECTION_DATE is not null and IS_SCHEDULING = 0
  48. <if test="nextDate != null and nextDate.size()>= 2">
  49. and NEXT_LEGAL_INSPECTION_DATE between #{nextDate[0]} and #{nextDate[1]}
  50. </if>
  51. then 1 else 0 end) LEGAL_INSPECTION_COUNT,
  52. sum(case when NEXT_ANNUAL_DATE is not null and IS_YEAR_SCHEDULING = 0
  53. <if test="nextDate != null and nextDate.size()>= 2">
  54. and NEXT_ANNUAL_DATE between #{nextDate[0]} and #{nextDate[1]}
  55. </if>
  56. then 1 else 0 end) ANNUAL_COUNT
  57. from PRESSURE_PIPE_EQUIPMENT
  58. where DELETED = 0 and (IS_SCHEDULING = 0 or IS_YEAR_SCHEDULING = 0) and USE_UNIT_NAME is not null
  59. <where>
  60. <if test="useUnitName != null">
  61. and use_unit_name like concat('%',#{useUnitName},'%')
  62. </if>
  63. <if test="pipeAddress != null">
  64. and pipe_address like concat('%',#{pipeAddress},'%')
  65. </if>
  66. <if test="pipeAdministrativeRegion != null">
  67. and pipe_administrative_region = #{pipeAdministrativeRegion}
  68. </if>
  69. <if test="pipeStreet != null">
  70. and pipe_street = #{pipeStreet}
  71. </if>
  72. </where>
  73. group by pipe_administrative_region,pipe_street,USE_UNIT_NAME
  74. ) as aa
  75. </select>
  76. <select id="selectPlanPageGroupProject">
  77. select USE_PROJECT_CODE,USE_PROJECT_NAME,PIPE_STREET,PIPE_ADMINISTRATIVE_REGION,
  78. sum(PIPE_LEN) total_len,min(NEXT_LEGAL_INSPECTION_DATE) NEXT_LEGAL_INSPECTION_DATE,min(NEXT_ANNUAL_DATE) NEXT_ANNUAL_DATE,
  79. sum(case when NEXT_LEGAL_INSPECTION_DATE is not null and IS_SCHEDULING = 0
  80. then 1 else 0 end) LEGAL_INSPECTION_COUNT,
  81. sum(case when NEXT_ANNUAL_DATE is not null and IS_YEAR_SCHEDULING = 0
  82. then 1 else 0 end) ANNUAL_COUNT,
  83. listagg(case when NEXT_LEGAL_INSPECTION_DATE is not null and IS_SCHEDULING = 0 then id else null end,',') equip_ids,
  84. listagg(case when NEXT_ANNUAL_DATE is not null and IS_YEAR_SCHEDULING = 0 then id else null end,',') annual_equip_ids
  85. from PRESSURE_PIPE_EQUIPMENT
  86. where DELETED = 0 and (IS_SCHEDULING = 0 or IS_YEAR_SCHEDULING = 0) and USE_UNIT_NAME is not null
  87. and id in
  88. <foreach close=")" collection="ids" item="listItem" open="(" separator=",">
  89. #{listItem}
  90. </foreach>
  91. group by USE_PROJECT_NAME
  92. </select>
  93. </mapper>