selectStatisticsMapper.xml 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  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. <if test="bgqx != null and bgqx != ''">
  49. and a.bgqx=#{bgqx}
  50. </if>
  51. ) AS archive_count
  52. , (
  53. SELECT count(af.id)
  54. FROM tab_archives a
  55. LEFT JOIN tab_archive_file af ON a.id = af.archive_id
  56. WHERE a1.`gdnd` = a.gdnd
  57. AND a.deleted = 0
  58. AND af.deleted = 0
  59. <if test="mlCodes != null and mlCodes.size > 0">
  60. AND a.ml in
  61. <foreach collection="mlCodes" item="item" index="index" open="(" close=")" separator=",">
  62. #{item}
  63. </foreach>
  64. </if>
  65. <if test="bgqx != null and bgqx != ''">
  66. and a.bgqx=#{bgqx}
  67. </if>
  68. ) AS file_count
  69. FROM tab_archives a1
  70. <where>
  71. <if test="startTime != null and startTime != '' and endTime != null and endTime != ''">
  72. AND a1.gdnd BETWEEN #{startTime} AND #{endTime}
  73. </if>
  74. </where>
  75. GROUP BY a1.gdnd
  76. </select>
  77. <select id="selectBorrowStatistics" resultType="com.gz.rvo.statistics.BorrowStatisticsRVO">
  78. SELECT (
  79. SELECT max(ab1.create_time)
  80. FROM tab_archive_borrow ab1
  81. WHERE ab.archive_id = ab1.archive_id
  82. AND ab1.deleted = 0
  83. ) AS create_time, ab.return_time, ab.estimate_return_time, a.tm, a.dh
  84. , IF(ata.parent_id = -1, ata.title, (
  85. SELECT title
  86. FROM tab_archives_tree ata1
  87. WHERE ata1.id = ata.parent_id
  88. AND ata1.deleted = 0
  89. )) AS ml
  90. , count(ab.id) AS borrow_count
  91. FROM tab_archive_borrow ab
  92. LEFT JOIN tab_archives a ON ab.archive_id = a.id
  93. LEFT JOIN tab_archives_tree ata ON a.ml = ata.CODE
  94. WHERE ab.deleted = 0
  95. AND a.deleted = 0
  96. AND ata.deleted = 0
  97. <if test="gjz != null and gjz != ''">
  98. and (a.dh like concat(concat('%',#{gjz}),'%') or a.tm like concat(concat('%',#{gjz}),'%'))
  99. </if>
  100. <if test="startTime != null and startTime != '' and endTime != null and endTime != ''">
  101. AND ab.create_time BETWEEN #{startTime} AND #{endTime}
  102. </if>
  103. <if test="mlCodes != null and mlCodes.size > 0">
  104. AND a.ml in
  105. <foreach collection="mlCodes" item="item" index="index" open="(" close=")" separator=",">
  106. #{item}
  107. </foreach>
  108. </if>
  109. GROUP BY ab.archive_id
  110. </select>
  111. </mapper>