selectStatisticsMapper.xml 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  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.gz.mapper.statistics.SelectStatisticsMapper">
  4. <select id="selectArchiveStatistics" resultType="com.gz.rvo.statistics.ArchiveStatisticsRVO">
  5. SELECT atr.title, atr.id, atr.`code`, atr.parent_id
  6. , (
  7. SELECT count(id)
  8. FROM tab_archives a
  9. WHERE atr.`code` = a.ml
  10. AND a.deleted = 0
  11. <if test="startTime != null and startTime != '' and endTime != null and endTime != ''">
  12. AND a.create_time BETWEEN #{startTime} AND #{endTime}
  13. </if>
  14. ) AS archive_count
  15. , (
  16. SELECT count(af.id)
  17. FROM tab_archives a
  18. LEFT JOIN tab_archive_file af ON a.id = af.archive_id
  19. WHERE atr.`code` = a.ml
  20. AND a.deleted = 0
  21. AND af.deleted = 0
  22. <if test="startTime != null and startTime != '' and endTime != null and endTime != ''">
  23. AND af.create_time BETWEEN #{startTime} AND #{endTime}
  24. </if>
  25. ) AS file_count
  26. FROM tab_archives_tree atr
  27. WHERE atr.deleted = 0
  28. <if test="mlCodes != null and mlCodes.size > 0">
  29. AND atr.code in
  30. <foreach collection="mlCodes" item="item" index="index" open="(" close=")" separator=",">
  31. #{item}
  32. </foreach>
  33. </if>
  34. </select>
  35. <select id="selectArchiveYearStatistics" resultType="com.gz.rvo.statistics.ArchiveYearStatisticsRVO">
  36. SELECT a1.gdnd
  37. , (
  38. SELECT count(a.id)
  39. FROM tab_archives a
  40. WHERE a1.`gdnd` = a.gdnd
  41. AND a.deleted = 0
  42. <if test="mlCodes != null and mlCodes.size > 0">
  43. AND a.ml in
  44. <foreach collection="mlCodes" item="item" index="index" open="(" close=")" separator=",">
  45. #{item}
  46. </foreach>
  47. </if>
  48. ) AS archive_count
  49. , (
  50. SELECT count(af.id)
  51. FROM tab_archives a
  52. LEFT JOIN tab_archive_file af ON a.id = af.archive_id
  53. WHERE a1.`gdnd` = a.gdnd
  54. AND a.deleted = 0
  55. AND af.deleted = 0
  56. <if test="mlCodes != null and mlCodes.size > 0">
  57. AND a.ml in
  58. <foreach collection="mlCodes" item="item" index="index" open="(" close=")" separator=",">
  59. #{item}
  60. </foreach>
  61. </if>
  62. ) AS file_count
  63. FROM tab_archives a1
  64. <where>
  65. <if test="startTime != null and startTime != '' and endTime != null and endTime != ''">
  66. AND a1.gdnd BETWEEN #{startTime} AND #{endTime}
  67. </if>
  68. <if test="bgqx != null and bgqx != ''">
  69. and a1.bgqx=#{bgqx}
  70. </if>
  71. </where>
  72. GROUP BY a1.gdnd
  73. </select>
  74. <select id="selectBorrowStatistics" resultType="com.gz.rvo.statistics.BorrowStatisticsRVO">
  75. SELECT (
  76. SELECT max(ab1.create_time)
  77. FROM tab_archive_borrow ab1
  78. WHERE ab.archive_id = ab1.archive_id
  79. AND ab1.deleted = 0
  80. ) AS create_time, ab.return_time, ab.estimate_return_time, a.tm, a.dh
  81. , IF(ata.parent_id = -1, ata.title, (
  82. SELECT title
  83. FROM tab_archives_tree ata1
  84. WHERE ata1.id = ata.parent_id
  85. AND ata1.deleted = 0
  86. )) AS ml
  87. , count(ab.id) AS borrow_count
  88. FROM tab_archive_borrow ab
  89. LEFT JOIN tab_archives a ON ab.archive_id = a.id
  90. LEFT JOIN tab_archives_tree ata ON a.ml = ata.CODE
  91. WHERE ab.deleted = 0
  92. AND a.deleted = 0
  93. AND ata.deleted = 0
  94. <if test="gjz != null and gjz != ''">
  95. and (a.dh like concat(concat('%',#{gjz}),'%') or a.tm like concat(concat('%',#{gjz}),'%'))
  96. </if>
  97. <if test="startTime != null and startTime != '' and endTime != null and endTime != ''">
  98. AND ab.create_time BETWEEN #{startTime} AND #{endTime}
  99. </if>
  100. <if test="mlCodes != null and mlCodes.size > 0">
  101. AND a.ml in
  102. <foreach collection="mlCodes" item="item" index="index" open="(" close=")" separator=",">
  103. #{item}
  104. </foreach>
  105. </if>
  106. GROUP BY ab.archive_id
  107. </select>
  108. </mapper>