Нет описания

TSecTrainingEducationMapper.xml 7.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180
  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.moduleSec.trainingEducation.mapper.TSecTrainingEducationMapper">
  4. <!-- 通用查询映射结果 -->
  5. <resultMap id="BaseResultMap" type="com.yt.zhylplat.moduleSec.trainingEducation.entity.TSecTrainingEducation">
  6. <id column="id" property="id" />
  7. <result column="create_user_id" property="createUserId" />
  8. <result column="create_date" property="createDate" />
  9. <result column="update_user_id" property="updateUserId" />
  10. <result column="maintenance_company_id" property="maintenanceCompanyId" />
  11. <result column="maintenance_company_name" property="maintenanceCompanyName" />
  12. <result column="section_id" property="sectionId" />
  13. <result column="section_name" property="sectionName" />
  14. <result column="file_name" property="fileName" />
  15. <result column="file_url" property="fileUrl" />
  16. <result column="update_date" property="updateDate" />
  17. <result column="del_flg" property="delFlg" />
  18. <result column="remark" property="remark" />
  19. </resultMap>
  20. <!-- 通用查询结果列 -->
  21. <sql id="Base_Column_List">
  22. id, create_user_id, create_date, update_user_id, maintenance_company_id, maintenance_company_name, section_id, section_name, file_name, file_url, update_date, del_flg, remark
  23. </sql>
  24. <select id="trainingStatistics"
  25. resultType="com.yt.zhylplat.moduleSec.trainingEducation.entity.TSecTrainingEducation">
  26. SELECT
  27. te.maintenance_company_id,
  28. te.maintenance_company_name,
  29. te.section_id,
  30. te.section_name,
  31. COUNT(*) as trainCount
  32. FROM
  33. T_Sec_Training_Education te
  34. WHERE
  35. te.del_flg = 0
  36. <if test="train.maintenanceCompanyId != null">
  37. and te.maintenance_company_id=#{train.maintenanceCompanyId}
  38. </if>
  39. <if test="train.sectionId != null">
  40. and te.section_id=#{train.sectionId}
  41. </if>
  42. <if test="train.startTime !=null and train.startTime!=''">
  43. and date_format(te.create_date,'%Y-%m') = date_format(STR_TO_DATE(#{train.startTime},'%Y-%m'),'%Y-%m')
  44. </if>
  45. <if test="train.startTime != null and train.startTime!=''">
  46. and date_format(te.create_date,'%Y') = date_format(STR_TO_DATE(#{train.startTime},'%Y'),'%Y')
  47. </if>
  48. group by te.maintenance_company_id,
  49. te.maintenance_company_name,
  50. te.section_id,
  51. te.section_name
  52. </select>
  53. <select id="centerStatistics"
  54. resultType="com.yt.zhylplat.moduleSec.trainingEducation.entity.TSecTrainingEducation">
  55. SELECT
  56. count(*) as centerTrainCount
  57. FROM
  58. T_Pub_Train t
  59. WHERE
  60. type = 2
  61. and delete_flag=0
  62. <if test="centerTrain.startTime !=null and centerTrain.startTime!=''">
  63. and date_format(t.create_date,'%Y-%m') = date_format(STR_TO_DATE(#{centerTrain.startTime},'%Y-%m'),'%Y-%m')
  64. </if>
  65. <if test="centerTrain.startTime != null and centerTrain.startTime!=''">
  66. and date_format(t.create_date,'%Y') = date_format(STR_TO_DATE(#{centerTrain.startTime},'%Y'),'%Y')
  67. </if>
  68. </select>
  69. <select id="allStatistics"
  70. resultType="com.yt.zhylplat.moduleSec.trainingEducation.entity.TSecTrainingEducation">
  71. select
  72. count(*) as mTrainCount
  73. from
  74. T_Sec_Training_Education ts
  75. where
  76. ts.del_flg=0
  77. <if test="allCount.startTime !=null and allCount.startTime!=''">
  78. and date_format(ts.create_date,'%Y-%m') = date_format(STR_TO_DATE(#{allCount.startTime},'%Y-%m'),'%Y-%m')
  79. </if>
  80. <if test="allCount.startTime != null and allCount.startTime!=''">
  81. and date_format(ts.create_date,'%Y') = date_format(STR_TO_DATE(#{allCount.startTime},'%Y'),'%Y')
  82. </if>
  83. <if test="allCount.maintenanceCompanyId != null">
  84. and ts.maintenance_company_id=#{allCount.maintenanceCompanyId}
  85. </if>
  86. </select>
  87. <select id="selectTSecTrainingEducationBySection"
  88. resultType="com.yt.zhylplat.moduleSec.trainingEducation.entity.TSecTrainingEducation">
  89. SELECT
  90. s.id as sectionId,
  91. s.section_name as sectionName,
  92. m.id as maintenanceCompanyId,
  93. m.maintenance_company_name as maintenanceCompanyName,
  94. IFNULL
  95. (b.sumCount,0) AS sumCount
  96. FROM
  97. T_Lhzx_Section s
  98. LEFT JOIN T_Lhzx_Road_Section_Maintenance_Company rsmc ON s.id = rsmc.section_id
  99. LEFT JOIN T_Lhzx_Maintenance_Company m ON m.id = rsmc.maintenance_company_id
  100. LEFT JOIN (
  101. SELECT
  102. section_id,
  103. section_name,
  104. maintenance_company_id,
  105. maintenance_company_name,
  106. COUNT(id) as sumCount
  107. FROM
  108. T_Sec_Training_Education
  109. WHERE
  110. del_flg = 0
  111. <if test="uploadYear != null and uploadYear != ''">
  112. and DATE_FORMAT(create_date, '%Y') = #{uploadYear}
  113. </if>
  114. GROUP BY
  115. section_id,
  116. section_name,
  117. maintenance_company_id,
  118. maintenance_company_name
  119. order by
  120. section_id,
  121. maintenance_company_id) b ON rsmc.section_id = b.section_id
  122. AND rsmc.maintenance_company_id = b.maintenance_company_id
  123. WHERE
  124. m.id IS NOT NULL
  125. <if test="sectionId != null">
  126. AND rsmc.section_id = #{sectionId}
  127. </if>
  128. <if test="maintenanceCompanyId != null">
  129. AND rsmc.maintenance_company_id = #{maintenanceCompanyId}
  130. </if>
  131. GROUP BY
  132. s.id,
  133. s.section_name,
  134. m.id,
  135. m.maintenance_company_name,
  136. b.sumCount
  137. ORDER BY
  138. s.id,
  139. m.id
  140. </select>
  141. <select id="selectTSecSecurityPatrolSumCount"
  142. resultType="com.yt.zhylplat.moduleSec.trainingEducation.entity.TSecTrainingEducation">
  143. select
  144. sum(if(temp.sumCount is null, 0, temp.sumCount)) as sumCount
  145. from
  146. (<include refid="TSecTrainingEducationSql"/>) temp
  147. </select>
  148. <sql id="TSecTrainingEducationSql">
  149. SELECT
  150. section_id,
  151. section_name,
  152. maintenance_company_id,
  153. maintenance_company_name,
  154. COUNT(id) as sumCount
  155. FROM
  156. T_Sec_Training_Education
  157. WHERE
  158. del_flg = 0
  159. <if test="sectionId != null">
  160. AND section_id = #{sectionId}
  161. </if>
  162. <if test="maintenanceCompanyId != null">
  163. AND maintenance_company_id = #{maintenanceCompanyId}
  164. </if>
  165. <if test="uploadYear != null and uploadYear != ''">
  166. and DATE_FORMAT(create_date, '%Y') = #{uploadYear}
  167. </if>
  168. GROUP BY
  169. section_id,
  170. section_name,
  171. maintenance_company_id,
  172. maintenance_company_name
  173. order by
  174. section_id,
  175. maintenance_company_id
  176. </sql>
  177. </mapper>