OrgStatsDataMapper.xml 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182
  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.ubitech.ttc.dao.OrgStatsDataMapper">
  4. <!-- 开启二级缓存 -->
  5. <!--<cache type="org.mybatis.caches.ehcache.LoggingEhcache"/>-->
  6. <select id="getOrgstatsDatalist" resultType="cn.ubitech.ttc.model.datatools.reportform.reportDataModel"
  7. useCache="false">
  8. SELECT
  9. d.*, c.dataname,
  10. c.datacode AS datacode,
  11. c.datakind,
  12. c.datatypename,
  13. c.untit
  14. FROM
  15. org_stats_data d
  16. RIGHT JOIN org_stats_code c ON d.dataparmcode = c.datacode
  17. AND d.datatype = #{datatype}
  18. AND d.datatimeyear = #{datatimeyear}
  19. AND d.datatimemonth = #{datatimemonth}
  20. AND d.orgid = #{orgid}
  21. ORDER BY
  22. c.datacode ASC
  23. </select>
  24. <select id="getStatsCount" resultType="java.lang.Integer" useCache="false">
  25. SELECT
  26. count(g.id)
  27. FROM
  28. (
  29. SELECT
  30. (count(o.id)) id
  31. FROM
  32. org_stats_data o
  33. WHERE
  34. o.datatype = #{datatype}
  35. AND o.nodeid IN
  36. <foreach collection="nodeList" item="id" index="index"
  37. open="(" close=")" separator=",">
  38. #{id}
  39. </foreach>
  40. GROUP BY
  41. o.datacreatetime,
  42. o.datatimemonth,
  43. o.orgid
  44. ) g
  45. </select>
  46. <select id="getOrgstatsCompanylist" resultType="cn.ubitech.ttc.entity.OrganizationInfo">
  47. SELECT
  48. *
  49. FROM
  50. organization_info g
  51. WHERE
  52. g.id IN (
  53. SELECT DISTINCT
  54. (o.id)
  55. FROM
  56. company_node_lk n,
  57. organization_info o
  58. WHERE
  59. n.companyid = o.id
  60. <if test="key != null and key != ''">
  61. AND name like '%${key}%'
  62. </if>
  63. AND n.comefrom IN
  64. <foreach collection="nodeList" item="id" index="index"
  65. open="(" close=")" separator=",">
  66. #{id}
  67. </foreach>
  68. ORDER BY
  69. NAME ASC
  70. )
  71. </select>
  72. <select id="getOrgstatsCompanycount" resultType="java.lang.Integer">
  73. SELECT
  74. count(g.id)
  75. FROM
  76. organization_info g
  77. WHERE
  78. g.id IN (
  79. SELECT DISTINCT
  80. (o.id)
  81. FROM
  82. company_node_lk n,
  83. organization_info o
  84. WHERE
  85. n.companyid = o.id
  86. <if test="key != null and key != ''">
  87. AND name like '%${key}%'
  88. </if>
  89. AND n.comefrom IN
  90. <foreach collection="nodeList" item="id" index="index"
  91. open="(" close=")" separator=",">
  92. #{id}
  93. </foreach>
  94. )
  95. </select>
  96. <select id="getTongluMonthReportList" resultType="cn.ubitech.ttc.model.datatools.reportform.reportDataModel"
  97. useCache="false">
  98. SELECT
  99. d.*, c.dataname,
  100. c.datacode AS datacode,
  101. c.datakind,
  102. c.datatypename,
  103. c.untit
  104. FROM
  105. org_stats_data d
  106. INNER JOIN org_stats_code c ON d.dataparmcode = c.datacode
  107. AND d.nodeid = #{node}
  108. AND d.datatimeyear = #{datatimeyear}
  109. AND d.datatimemonth = #{datatimemonth}
  110. AND d.orgid = #{oid}
  111. AND d.datatype != 2
  112. AND d.linktype = -1
  113. AND d.connid = -1
  114. ORDER BY
  115. d.createtime desc, c.datacode ASC
  116. </select>
  117. <select id="getDataValueBySomeIndex" resultType="java.lang.String">
  118. select d.datavalue
  119. from org_stats_data d
  120. inner join org_stats_code code on code.datacode = d.dataparmcode
  121. inner join organization_info org on org.id = d.orgid
  122. where org.name = #{orgName}
  123. and code.id = #{indexid}
  124. and d.linktype = -1 and d.connid = -1 and d.nodeid = #{node}
  125. and d.datatimeyear = #{year}
  126. and d.datatimemonth = #{month}
  127. and d.datastate = 0
  128. </select>
  129. <select id="getOrgNameAndIdList" resultType="cn.ubitech.ttc.entity.OrganizationInfo">
  130. SELECT DISTINCT o.*
  131. FROM organization_info o, org_stats_data d
  132. where d.orgid = o.id
  133. AND d.nodeid = #{node}
  134. AND d.linktype = -1
  135. AND d.connid = -1
  136. </select>
  137. <select id="getAnalysisTimeList" resultType="java.lang.String">
  138. select DISTINCT d.datatimemonth
  139. from org_stats_data d, org_stats_code code
  140. where code.node = #{node} and d.nodeid = #{node}
  141. and d.linktype = -1 and d.connid = -1
  142. and code.type = 1
  143. and code.datacode = d.dataparmcode
  144. and d.datatimeyear = #{year}
  145. and d.orgid in (
  146. select o.id
  147. from organization_info o
  148. where o.name in
  149. <foreach collection="orglist" item="id" index="index" open="(" close=")" separator=",">
  150. #{id}
  151. </foreach>
  152. )
  153. </select>
  154. <select id="getAnalysisYear" resultType="java.lang.String">
  155. select DISTINCT d.datatimeyear
  156. from org_stats_data d, org_stats_code code
  157. where code.node = #{node} and d.nodeid = #{node}
  158. and d.linktype = -1 and d.connid = -1
  159. and code.type = 1
  160. and code.datacode = d.dataparmcode
  161. and d.orgid in (
  162. select o.id
  163. from organization_info o
  164. where o.name in
  165. <foreach collection="orglist" item="id" index="index" open="(" close=")" separator=",">
  166. #{id}
  167. </foreach>
  168. )
  169. order by d.datatimeyear desc
  170. </select>
  171. </mapper>