Nessuna descrizione

TOffeStatisticsMapper.xml 9.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247
  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.yt.zhylplat.moduleOffe.statistics.mapper.TOffeStatisticsMapper">
  4. <!-- 通用查询映射结果 -->
  5. <resultMap id="BaseResultMap" type="com.yt.zhylplat.moduleOffe.statistics.entity.TOffeStatistics">
  6. <id column="id" property="id" />
  7. <result column="statistics_name" property="statisticsName" />
  8. <result column="dept_id" property="deptId" />
  9. <result column="dept_name" property="deptName" />
  10. <result column="start_date" property="startDate" />
  11. <result column="end_date" property="endDate" />
  12. <result column="file_name" property="fileName" />
  13. <result column="file_url" property="fileUrl" />
  14. <result column="is_all_visible" property="isAllVisible" />
  15. <result column="create_user_id" property="createUserId" />
  16. <result column="create_user_name" property="createUserName" />
  17. <result column="create_date" property="createDate" />
  18. <result column="update_user_id" property="updateUserId" />
  19. <result column="update_user_name" property="updateUserName" />
  20. <result column="update_date" property="updateDate" />
  21. <result column="del_flg" property="delFlg" />
  22. </resultMap>
  23. <!-- 通用查询结果列 -->
  24. <sql id="Base_Column_List">
  25. id, statistics_name, dept_id, dept_name, start_date, end_date, file_name, file_url, is_all_visible, create_user_id, create_user_name, create_date, update_user_id, update_user_name, update_date, del_flg
  26. </sql>
  27. <select id="selectStatisticsIsUpload"
  28. resultType="com.yt.zhylplat.moduleOffe.statistics.entity.TOffeStatistics">
  29. select distinct
  30. s.id,
  31. if(sd.detail_count is null or sd.detail_count = 0, 0, 1) as isUpload
  32. from
  33. T_Offe_Statistics s
  34. left join
  35. (
  36. select
  37. statistics_id,
  38. count(1) as detail_count
  39. from
  40. T_Offe_Statistics_Detail
  41. where
  42. del_flg = 0
  43. and
  44. maintenance_company_id = #{maintenanceCompanyId}
  45. group by
  46. statistics_id
  47. ) sd on sd.statistics_id = s.id
  48. where
  49. s.del_flg = 0
  50. and (
  51. s.is_all_visible = 1
  52. or
  53. exists(
  54. select
  55. 1
  56. from
  57. T_Offe_Statistics_Company
  58. where
  59. del_flg = 0
  60. and
  61. statistics_id = s.id
  62. and
  63. maintenance_company_id = #{maintenanceCompanyId})
  64. )
  65. </select>
  66. <resultMap id="statisticsMap" type="com.yt.zhylplat.moduleOffe.statistics.entity.TOffeStatistics">
  67. <id column="id" property="id" />
  68. <result column="statistics_name" property="statisticsName" />
  69. <result column="dept_id" property="deptId" />
  70. <result column="dept_name" property="deptName" />
  71. <result column="start_date" property="startDate" />
  72. <result column="end_date" property="endDate" />
  73. <result column="file_name" property="fileName" />
  74. <result column="file_url" property="fileUrl" />
  75. <result column="is_all_visible" property="isAllVisible" />
  76. <result column="statistic_type" property="statisticType" />
  77. <result column="is_warning" property="isWarning" />
  78. <result column="warning_time" property="warningTime" />
  79. <result column="is_expedited" property="isExpedited" />
  80. <result column="create_user_id" property="createUserId" />
  81. <result column="create_user_name" property="createUserName" />
  82. <result column="create_date" property="createDate" />
  83. <result column="update_user_id" property="updateUserId" />
  84. <result column="update_user_name" property="updateUserName" />
  85. <result column="update_date" property="updateDate" />
  86. <result column="del_flg" property="delFlg" />
  87. <collection property="companyList" ofType="com.yt.zhylplat.moduleOffe.statistics.entity.TOffeStatisticsCompany">
  88. <id column="osc_id" property="id" />
  89. <result column="osc_statistics_id" property="statisticsId" />
  90. <result column="osc_maintenance_company_id" property="maintenanceCompanyId" />
  91. <result column="osc_maintenance_company_name" property="maintenanceCompanyName" />
  92. </collection>
  93. <collection property="sectionList" ofType="com.yt.zhylplat.moduleOffe.statistics.entity.TOffeStatisticsSection">
  94. <id column="oss_id" property="id" />
  95. <result column="oss_statistics_id" property="statisticsId" />
  96. <result column="oss_section_type" property="sectionType" />
  97. <result column="oss_section_id" property="sectionId" />
  98. </collection>
  99. <collection property="statisticsDetailList" ofType="com.yt.zhylplat.moduleOffe.statistics.entity.TOffeStatisticsDetail">
  100. <id column="osd_id" property="id" />
  101. <result column="osd_statistics_id" property="statisticsId" />
  102. <result column="osd_section_id" property="sectionId" />
  103. <result column="osd_section_name" property="sectionName" />
  104. <result column="osd_maintenance_company_id" property="maintenanceCompanyId" />
  105. <result column="osd_maintenance_company_name" property="maintenanceCompanyName" />
  106. <result column="osd_file_name" property="fileName" />
  107. <result column="osd_file_url" property="fileUrl" />
  108. <result column="osd_file_list" property="fileList" />
  109. </collection>
  110. </resultMap>
  111. <select id="selectStatisticsByBean" resultMap="statisticsMap">
  112. SELECT
  113. os.*,
  114. osc.id as osc_id,
  115. osc.statistics_id as osc_statistics_id,
  116. osc.maintenance_company_id as osc_maintenance_company_id,
  117. oscmc.maintenance_company_name as osc_maintenance_company_name,
  118. oss.id as oss_id,
  119. oss.statistics_id as oss_statistics_id,
  120. oss.section_type as oss_section_type,
  121. oss.section_id as oss_section_id,
  122. osd.id as osd_id,
  123. osd.statistics_id as osd_statistics_id,
  124. osd.section_id as osd_section_id,
  125. osd.section_name as osd_section_name,
  126. osd.maintenance_company_id as osd_maintenance_company_id,
  127. osd.maintenance_company_name as osd_maintenance_company_name,
  128. osd.file_name as osd_file_name,
  129. osd.file_url as osd_file_url,
  130. osd.file_list as osd_file_list
  131. FROM
  132. T_Offe_Statistics os
  133. LEFT JOIN
  134. T_Offe_Statistics_Company osc on os.id = osc.statistics_id
  135. left join
  136. T_Lhzx_Maintenance_Company oscmc on osc.maintenance_company_id = oscmc.id
  137. LEFT JOIN
  138. T_Offe_Statistics_Detail osd on os.id = osd.statistics_id
  139. LEFT JOIN
  140. T_Offe_Statistics_Section oss on os.id = oss.statistics_id
  141. WHERE
  142. os.del_flg = 0
  143. and
  144. os.is_all_visible != 0
  145. <if test="queryEndDate != null and queryEndDate != ''">
  146. AND DATE_FORMAT(os.end_date, '%Y-%m-%d') = DATE_FORMAT(#{queryEndDate}, '%Y-%m-%d')
  147. </if>
  148. <if test="queryEndDate == null or queryEndDate == ''">
  149. AND DATE_FORMAT(os.end_date, '%Y-%m-%d') = DATE_FORMAT(now(), '%Y-%m-%d')
  150. </if>
  151. </select>
  152. <select id="selectStatisticsByCenter"
  153. resultType="com.yt.zhylplat.moduleOffe.statistics.entity.TOffeStatistics">
  154. select
  155. temp.*
  156. from
  157. (<include refid="selectStatisticsSql"/>) temp
  158. </select>
  159. <select id="getStatisticsSumCountByCenter"
  160. resultType="com.yt.zhylplat.moduleOffe.statistics.entity.TOffeStatistics">
  161. select
  162. sum(if(temp.uploadCount is null, 0, temp.uploadCount)) as uploadCount
  163. from
  164. (<include refid="selectStatisticsSql"/>) temp
  165. </select>
  166. <sql id="selectStatisticsSql">
  167. select
  168. temp.statistic_type,
  169. IF(s.uploadCount is null, 0, s.uploadCount) as uploadCount
  170. from (
  171. SELECT
  172. 1 as statistic_type
  173. FROM
  174. dual
  175. union
  176. SELECT
  177. 2 as statistic_type
  178. FROM
  179. dual
  180. union
  181. SELECT
  182. 3 as statistic_type
  183. FROM
  184. dual
  185. union
  186. SELECT
  187. 4 as statistic_type
  188. FROM
  189. dual
  190. union
  191. SELECT
  192. 5 as statistic_type
  193. FROM
  194. dual
  195. union
  196. SELECT
  197. 6 as statistic_type
  198. FROM
  199. dual
  200. union
  201. SELECT
  202. 7 as statistic_type
  203. FROM
  204. dual
  205. ) temp
  206. left join (
  207. SELECT
  208. statistic_type,
  209. COUNT(1) as uploadCount
  210. FROM
  211. T_Offe_Statistics
  212. where
  213. del_flg = 0
  214. <if test="statistics.createUserName != null and statistics.createUserName != ''">
  215. and create_user_name like concat('%', #{statistics.createUserName}, '%')
  216. </if>
  217. <if test="statistics.uploadMonth != null and statistics.uploadMonth != ''">
  218. and date_format(create_date, '%Y-%m') = #{statistics.uploadMonth}
  219. </if>
  220. <if test="statistics.uploadYear != null and statistics.uploadYear != ''">
  221. and date_format(create_date, '%Y') = #{statistics.uploadYear}
  222. </if>
  223. group by
  224. statistic_type
  225. ) s on s.statistic_type = temp.statistic_type
  226. order by
  227. temp.statistic_type
  228. </sql>
  229. </mapper>