EventMapper.xml 11 KB

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="cn.cslg.pas.mapper.EventMapper">
  4. <!--根据名称和租户id统计数量-->
  5. <!--int countByNameAndTenantId(String questionName, Integer tenantId);-->
  6. <select id="countByNameAndTenantId" resultType="int">
  7. select count(*)
  8. from event
  9. where question_name = #{questionName}
  10. and tenant_id = #{tenantId}
  11. </select>
  12. <!--分页查询事件列表-->
  13. <!--List<EventListItemVO> queryList(EventQueryPageDTO eventQueryPageDTO);-->
  14. <select id="queryList" resultMap="queryListMap">
  15. select eve.id eventId,
  16. question_name,
  17. description,
  18. application_scenario as applicationScenario,
  19. event_date,
  20. tenant_id,
  21. create_person_id,
  22. create_person_name,
  23. create_time,
  24. modified_time
  25. <if test="projectId != null and projectId != ''">
  26. , project_id
  27. </if>
  28. from event eve
  29. <if test="projectId != null and projectId != ''">
  30. join asso_event_project asso on eve.id = asso.event_id
  31. </if>
  32. <where>
  33. <if test="projectId != null and projectId != ''">
  34. and project_id = #{projectId}
  35. </if>
  36. <if test="questionName != null and questionName != ''">
  37. and question_name like '%${questionName}%'
  38. </if>
  39. <if test="true">
  40. and tenant_id = #{tenantId}
  41. </if>
  42. </where>
  43. order by
  44. <choose>
  45. <when test="orderBy != null and orderBy != ''">
  46. ${orderBy} ${orderType}
  47. </when>
  48. <otherwise>
  49. create_time desc
  50. </otherwise>
  51. </choose>
  52. </select>
  53. <resultMap id="queryListMap" type="cn.cslg.pas.common.model.vo.EventListItemVO">
  54. <id column="eventId" property="id"/>
  55. <result column="question_name" property="questionName"/>
  56. <result column="description" property="description"/>
  57. <result column="applicationScenario" property="applicationScenario"/>
  58. <result column="event_date" property="eventDate"/>
  59. <result column="tenant_id" property="tenantId"/>
  60. <result column="create_person_id" property="createPersonId"/>
  61. <result column="create_person_name" property="createPersonName"/>
  62. <result column="create_time" property="createTime"/>
  63. <result column="modified_time" property="modifiedTime"/>
  64. <collection property="scenarioNames" ofType="string"
  65. select="select1" column="{applicationScenario=applicationScenario}">
  66. </collection>
  67. <collection property="projectIds" ofType="integer"
  68. select="select2" column="{eventId=eventId}">
  69. </collection>
  70. </resultMap>
  71. <select id="select1" resultType="string">
  72. select label
  73. from os_system_dict
  74. where FIND_IN_SET(value, #{applicationScenario})
  75. and type = "ENTERPRISE_APPLICATION_SCENARIO"
  76. order by id
  77. </select>
  78. <select id="select2" resultType="integer">
  79. select project_id
  80. from asso_event_project
  81. where event_id = #{eventId}
  82. order by id
  83. </select>
  84. <!--根据应用场景value和事件名称分页查询事件清单-->
  85. <!--List<EventListItemVO> queryEvents(EventQueryPageDTO eventQueryPageDTO);-->
  86. <select id="queryEvents" resultMap="queryByApplicationScenarioMap">
  87. select id,
  88. question_name,
  89. description,
  90. application_scenario,
  91. event_date,
  92. tenant_id,
  93. create_person_id,
  94. create_person_name,
  95. create_time,
  96. modified_time
  97. from event
  98. <where>
  99. <if test="applicationScenario != null and applicationScenario != ''">
  100. and id in(select id from event where find_in_set(#{applicationScenario}, application_scenario)
  101. union select even.id
  102. from os_thematic proj
  103. join asso_event_project asso on proj.id = asso.project_id
  104. join event even on asso.event_id = even.id
  105. where find_in_set(#{applicationScenario}, proj.scenarioid)
  106. and even.application_scenario is null
  107. )
  108. </if>
  109. <if test="questionName != null and questionName != ''">
  110. and question_name like '%${questionName}%'
  111. </if>
  112. <if test="true">
  113. and tenant_id = #{tenantId}
  114. </if>
  115. </where>
  116. order by create_time
  117. </select>
  118. <resultMap id="queryByApplicationScenarioMap" type="cn.cslg.pas.common.model.vo.EventListItemVO">
  119. <id column="id" property="id"/>
  120. <result column="question_name" property="questionName"/>
  121. <result column="description" property="description"/>
  122. <result column="application_scenario" property="applicationScenario"/>
  123. <result column="event_date" property="eventDate"/>
  124. <result column="tenant_id" property="tenantId"/>
  125. <result column="create_person_id" property="createPersonId"/>
  126. <result column="create_person_name" property="createPersonName"/>
  127. <result column="create_time" property="createTime"/>
  128. <result column="modified_time" property="modifiedTime"/>
  129. </resultMap>
  130. <!--查询9大应用场景及分别对应的事件数量-->
  131. <!--List<ApplicationScenarioEventNumber> queryApplicationScenarioEventNumber(Integer tenantId);-->
  132. <!-- <select id="queryApplicationScenarioEventNumber" resultMap="queryApplicationScenarioEventNumberMap">-->
  133. <!-- select label,-->
  134. <!-- value as applicationScenarioValue,-->
  135. <!-- #{tenantId} as tenantId-->
  136. <!-- from os_system_dict-->
  137. <!-- where type = "ENTERPRISE_APPLICATION_SCENARIO"-->
  138. <!-- </select>-->
  139. <!-- <resultMap id="queryApplicationScenarioEventNumberMap"-->
  140. <!-- type="cn.cslg.pas.common.model.vo.ApplicationScenarioEventNumberVO">-->
  141. <!-- <result column="label" property="applicationScenarioName"/>-->
  142. <!-- <result column="value" property="applicationScenarioName"/>-->
  143. <!-- <collection property="eventNumberFromEvent" ofType="integer"-->
  144. <!-- select="selectEventCount1"-->
  145. <!-- column="{applicationScenarioValue=applicationScenarioValue, tenantId=tenantId}">-->
  146. <!-- </collection>-->
  147. <!-- <collection property="eventNumberFromProject" ofType="integer"-->
  148. <!-- select="selectEventCount2"-->
  149. <!-- column="{applicationScenarioValue=applicationScenarioValue, tenantId=tenantId}">-->
  150. <!-- </collection>-->
  151. <!-- </resultMap>-->
  152. <!-- <select id="selectEventCount1" resultType="integer">-->
  153. <!-- select count(*)-->
  154. <!-- from event-->
  155. <!-- where find_in_set(#{applicationScenarioValue}, application_scenario)-->
  156. <!-- and tenant_id = #{tenantId}-->
  157. <!-- </select>-->
  158. <!-- <select id="selectEventCount2" resultType="integer">-->
  159. <!-- select count(*)-->
  160. <!-- from os_thematic proj-->
  161. <!-- join asso_event_project asso on proj.id = asso.project_id-->
  162. <!-- join event even on asso.event_id = even.id-->
  163. <!-- where find_in_set(#{applicationScenarioValue}, proj.scenarioid)-->
  164. <!-- and even.application_scenario is null-->
  165. <!-- and tenant_id = #{tenantId}-->
  166. <!-- </select>-->
  167. <!--查询所有应用场景-->
  168. <!--List<ApplicationScenario> queryApplicationScenarios();-->
  169. <select id="queryApplicationScenarios" resultMap="queryApplicationScenariosMap">
  170. select label, value
  171. from os_system_dict
  172. where type = "ENTERPRISE_APPLICATION_SCENARIO"
  173. </select>
  174. <resultMap id="queryApplicationScenariosMap" type="cn.cslg.pas.domain.ApplicationScenario">
  175. <result column="label" property="applicationScenarioName"/>
  176. <result column="value" property="applicationScenarioValue"/>
  177. </resultMap>
  178. <!--查询所有应用场景不是null的事件-->
  179. <!--List<EventListItemVO> queryEventsDirectApplicationScenario(Integer tenantId);-->
  180. <select id="queryEventsDirectApplicationScenario" resultMap="queryEventsHaveApplicationScenarioMap">
  181. select application_scenario
  182. from event
  183. where application_scenario is not null
  184. and tenant_id = #{tenantId}
  185. </select>
  186. <resultMap id="queryEventsHaveApplicationScenarioMap" type="cn.cslg.pas.common.model.vo.EventListItemVO">
  187. <result column="application_scenario" property="applicationScenario"/>
  188. </resultMap>
  189. <!--查询所有应用场景是null的事件(去关联专题库表查询出应用场景,就作为事件的应用场景)-->
  190. <!--List<EventListItemVO> queryEventsInDirectApplicationScenario(Integer tenantId);-->
  191. <select id="queryEventsInDirectApplicationScenario" resultMap="queryEventsInDirectApplicationScenarioMap">
  192. select even.application_scenario, proj.scenarioid
  193. from event even
  194. join asso_event_project asso on even.id = asso.event_id
  195. join os_thematic proj on asso.project_id = proj.id
  196. where even.application_scenario is null
  197. and proj.scenarioid is not null
  198. and even.tenant_id = #{tenantId}
  199. </select>
  200. <resultMap id="queryEventsInDirectApplicationScenarioMap" type="cn.cslg.pas.common.model.vo.EventListItemVO">
  201. <result column="scenarioid" property="applicationScenario"/>
  202. </resultMap>
  203. <!--根据应用场景查询调查类型-->
  204. <!--List<Type> queryTypeid(Integer applicationScenario);-->
  205. <select id="queryTypeid" resultMap="queryTypeidMap">
  206. select DICT_CHILD_VALUE, DICT_CHILD_LABEL
  207. from os_system_dict_associate
  208. where DICT_PARENT_VALUE = #{applicationScenario}
  209. </select>
  210. <resultMap id="queryTypeidMap" type="cn.cslg.pas.domain.Type">
  211. <result column="DICT_CHILD_VALUE" property="typeId"/>
  212. <result column="DICT_CHILD_LABEL" property="typeName"/>
  213. </resultMap>
  214. <!--根据应用场景和事件id查询专题库-->
  215. <!--List<Project> queryProjects(Integer applicationScenario, Integer eventId);-->
  216. <select id="queryProjects" resultMap="queryProjectsMap">
  217. select id, typeid
  218. from os_thematic
  219. where find_in_set(#{applicationScenario}, scenarioid)
  220. and id in (select project_id from asso_event_project where event_id = #{eventId})
  221. </select>
  222. <resultMap id="queryProjectsMap" type="cn.cslg.pas.domain.Project">
  223. <result column="typeid" property="type"/>
  224. </resultMap>
  225. </mapper>