DataMapper.xml 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  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.bootdo.datas.dao.DataDao">
  4. <!--统计数据 省地图 根据数据级别-->
  5. <select id="mapDataList" resultType="com.bootdo.datas.dto.MapDataDTO">
  6. SELECT
  7. b.UNIT_CITY as cityName,
  8. COUNT(DISTINCT(a.ID)) AS amount
  9. FROM
  10. gy_data AS a
  11. LEFT JOIN gy_unit AS b ON b.CREDIT_CODE = a.GY_NUIT_ID
  12. <where>
  13. <if test="dataLevel != null and dataLevel != ''"> and a.DATA_LEVEL = #{dataLevel}</if>
  14. <if test="auditStage != null and auditStage != ''">and a.AUDIT_STAGE = #{auditStage}</if>
  15. and a.DATA_STATUS = '3'
  16. AND a.DELETE_STATUS != '1'
  17. </where>
  18. GROUP BY
  19. b.UNIT_CITY
  20. ORDER BY
  21. amount DESC
  22. </select>
  23. <!--统计数据近七天趋势-->
  24. <select id="trendData" resultType="com.bootdo.datas.dto.DateAndCountDTO">
  25. SELECT
  26. COUNT( a.ID ) AS amount,
  27. date(DATE_FORMAT( a.UPLOAD_TIME, '%Y-%m-%d' )) AS date
  28. FROM
  29. gy_data AS a ,
  30. gy_unit AS b
  31. WHERE
  32. DATE_SUB( CURDATE(), INTERVAL 7 DAY ) &lt;= date(
  33. DATE_FORMAT( a.UPLOAD_TIME, '%Y-%m-%d' ))
  34. <if test="city != null and city != ''"> AND b.UNIT_CITY = #{city} </if>
  35. <if test="auditStage != null and auditStage != ''">and a.AUDIT_STAGE = #{auditStage}</if>
  36. AND b.CREDIT_CODE = a.GY_NUIT_ID
  37. and a.DATA_STATUS = '3'
  38. AND a.DELETE_STATUS != '1'
  39. GROUP BY
  40. DATE_FORMAT(
  41. a.UPLOAD_TIME,
  42. '%Y-%m-%d')
  43. ORDER BY
  44. date DESC
  45. </select>
  46. <!--统计数据所属行业子类-->
  47. <select id="industryData" resultType="com.bootdo.datas.dto.NameAndValueDTO">
  48. SELECT
  49. b.DATA_INDUSTRY_TWO AS name,
  50. COUNT( a.ID ) AS value
  51. FROM
  52. gy_data AS a ,
  53. gy_unit AS b
  54. <where>
  55. <if test="city != null and city != ''"> AND b.UNIT_CITY = #{city} </if>
  56. <if test="auditStage != null and auditStage != ''">and a.AUDIT_STAGE = #{auditStage}</if>
  57. AND b.CREDIT_CODE = a.GY_NUIT_ID
  58. AND a.DELETE_STATUS != '1'
  59. AND a.DATA_STATUS = '3'
  60. </where>
  61. GROUP BY
  62. b.DATA_INDUSTRY_TWO
  63. ORDER BY
  64. value DESC
  65. </select>
  66. <!--统计数据所属级别-->
  67. <select id="dataLevelData" resultType="com.bootdo.datas.dto.DateAndCountDTO">
  68. SELECT
  69. COUNT( a.ID ) AS amount,
  70. date(DATE_FORMAT( a.UPLOAD_TIME, '%Y-%m-%d' )) AS date
  71. FROM
  72. gy_data AS a ,
  73. gy_unit AS b
  74. WHERE
  75. DATE_SUB( CURDATE(), INTERVAL 7 DAY ) &lt;= date(
  76. DATE_FORMAT( a.UPLOAD_TIME, '%Y-%m-%d' ))
  77. <if test="dataLevel != null and dataLevel != ''"> AND a.DATA_LEVEL = #{dataLevel} </if>
  78. <if test="city != null and city != ''"> AND b.UNIT_CITY = #{city} </if>
  79. <if test="auditStage != null and auditStage != ''">and a.AUDIT_STAGE = #{auditStage}</if>
  80. AND b.CREDIT_CODE = a.GY_NUIT_ID
  81. AND a.DELETE_STATUS != '1'
  82. AND a.DATA_STATUS = '3'
  83. GROUP BY
  84. DATE_FORMAT(
  85. a.UPLOAD_TIME,
  86. '%Y-%m-%d')
  87. ORDER BY
  88. date DESC
  89. </select>
  90. <!--各市时需要的统计 计算审核通过率-->
  91. <select id="dataAuditData" resultType="java.lang.Double">
  92. SELECT
  93. ROUND( currentCount / allData * 100, 1 )
  94. FROM
  95. ( SELECT COUNT( a.ID ) AS allData FROM gy_data AS a ,
  96. gy_unit AS b
  97. WHERE
  98. b.UNIT_CITY = #{city}
  99. AND b.CREDIT_CODE = a.GY_NUIT_ID
  100. AND a.`DELETE_STATUS` != 1) AS allData,
  101. ( SELECT COUNT( a.ID ) AS currentCount FROM gy_data AS a ,
  102. gy_unit AS b
  103. WHERE
  104. b.UNIT_CITY = #{city}
  105. AND b.CREDIT_CODE = a.GY_NUIT_ID
  106. <if test="auditStage != null and auditStage != ''">and a.AUDIT_STAGE = #{auditStage}</if>
  107. AND a.DATA_STATUS = '3'
  108. AND a.DELETE_STATUS != '1'
  109. ) AS currentCount
  110. </select>
  111. <!--各市时需要的统计 统计数据所属类别-->
  112. <select id="dataCategoryData" resultType="com.bootdo.datas.dto.NameAndValueDTO">
  113. SELECT
  114. a.DATA_TYPE_ONE AS name,
  115. COUNT( a.ID ) AS value
  116. FROM
  117. gy_data AS a ,
  118. gy_unit AS b
  119. WHERE
  120. b.UNIT_CITY = #{city}
  121. AND b.CREDIT_CODE = a.GY_NUIT_ID
  122. AND a.DELETE_STATUS != '1'
  123. AND a.DATA_STATUS != '4'
  124. GROUP BY
  125. a.DATA_TYPE_ONE
  126. ORDER BY
  127. value DESC
  128. </select>
  129. </mapper>