123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247 |
- <?xml version="1.0" encoding="UTF-8" ?>
- <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
- <mapper namespace="cn.cslg.pas.mapper.EventMapper">
- <!--根据名称和租户id统计数量-->
- <!--int countByNameAndTenantId(String questionName, Integer tenantId);-->
- <select id="countByNameAndTenantId" resultType="int">
- select count(*)
- from event
- where question_name = #{questionName}
- and tenant_id = #{tenantId}
- </select>
- <!--分页查询事件列表-->
- <!--List<EventListItemVO> queryList(EventQueryPageDTO eventQueryPageDTO);-->
- <select id="queryList" resultMap="queryListMap">
- select eve.id eventId,
- question_name,
- description,
- application_scenario as applicationScenario,
- event_date,
- tenant_id,
- create_person_id,
- create_person_name,
- create_time,
- modified_time
- <if test="projectId != null and projectId != ''">
- , project_id
- </if>
- from event eve
- <if test="projectId != null and projectId != ''">
- join asso_event_project asso on eve.id = asso.event_id
- </if>
- <where>
- <if test="projectId != null and projectId != ''">
- and project_id = #{projectId}
- </if>
- <if test="questionName != null and questionName != ''">
- and question_name like '%${questionName}%'
- </if>
- <if test="true">
- and tenant_id = #{tenantId}
- </if>
- </where>
- order by
- <choose>
- <when test="orderBy != null and orderBy != ''">
- ${orderBy} ${orderType}
- </when>
- <otherwise>
- create_time desc
- </otherwise>
- </choose>
- </select>
- <resultMap id="queryListMap" type="cn.cslg.pas.common.model.vo.EventListItemVO">
- <id column="eventId" property="id"/>
- <result column="question_name" property="questionName"/>
- <result column="description" property="description"/>
- <result column="applicationScenario" property="applicationScenario"/>
- <result column="event_date" property="eventDate"/>
- <result column="tenant_id" property="tenantId"/>
- <result column="create_person_id" property="createPersonId"/>
- <result column="create_person_name" property="createPersonName"/>
- <result column="create_time" property="createTime"/>
- <result column="modified_time" property="modifiedTime"/>
- <collection property="scenarioNames" ofType="string"
- select="select1" column="{applicationScenario=applicationScenario}">
- </collection>
- <collection property="projectIds" ofType="integer"
- select="select2" column="{eventId=eventId}">
- </collection>
- </resultMap>
- <select id="select1" resultType="string">
- select label
- from os_system_dict
- where FIND_IN_SET(value, #{applicationScenario})
- and type = "ENTERPRISE_APPLICATION_SCENARIO"
- order by id
- </select>
- <select id="select2" resultType="integer">
- select project_id
- from asso_event_project
- where event_id = #{eventId}
- order by id
- </select>
- <!--根据应用场景value和事件名称分页查询事件清单-->
- <!--List<EventListItemVO> queryEvents(EventQueryPageDTO eventQueryPageDTO);-->
- <select id="queryEvents" resultMap="queryByApplicationScenarioMap">
- select id,
- question_name,
- description,
- application_scenario,
- event_date,
- tenant_id,
- create_person_id,
- create_person_name,
- create_time,
- modified_time
- from event
- <where>
- <if test="applicationScenario != null and applicationScenario != ''">
- and id in(select id from event where find_in_set(#{applicationScenario}, application_scenario)
- union select even.id
- from os_thematic proj
- join asso_event_project asso on proj.id = asso.project_id
- join event even on asso.event_id = even.id
- where find_in_set(#{applicationScenario}, proj.scenarioid)
- and even.application_scenario is null
- )
- </if>
- <if test="questionName != null and questionName != ''">
- and question_name like '%${questionName}%'
- </if>
- <if test="true">
- and tenant_id = #{tenantId}
- </if>
- </where>
- order by create_time
- </select>
- <resultMap id="queryByApplicationScenarioMap" type="cn.cslg.pas.common.model.vo.EventListItemVO">
- <id column="id" property="id"/>
- <result column="question_name" property="questionName"/>
- <result column="description" property="description"/>
- <result column="application_scenario" property="applicationScenario"/>
- <result column="event_date" property="eventDate"/>
- <result column="tenant_id" property="tenantId"/>
- <result column="create_person_id" property="createPersonId"/>
- <result column="create_person_name" property="createPersonName"/>
- <result column="create_time" property="createTime"/>
- <result column="modified_time" property="modifiedTime"/>
- </resultMap>
- <!--查询9大应用场景及分别对应的事件数量-->
- <!--List<ApplicationScenarioEventNumber> queryApplicationScenarioEventNumber(Integer tenantId);-->
- <!-- <select id="queryApplicationScenarioEventNumber" resultMap="queryApplicationScenarioEventNumberMap">-->
- <!-- select label,-->
- <!-- value as applicationScenarioValue,-->
- <!-- #{tenantId} as tenantId-->
- <!-- from os_system_dict-->
- <!-- where type = "ENTERPRISE_APPLICATION_SCENARIO"-->
- <!-- </select>-->
- <!-- <resultMap id="queryApplicationScenarioEventNumberMap"-->
- <!-- type="cn.cslg.pas.common.model.vo.ApplicationScenarioEventNumberVO">-->
- <!-- <result column="label" property="applicationScenarioName"/>-->
- <!-- <result column="value" property="applicationScenarioName"/>-->
- <!-- <collection property="eventNumberFromEvent" ofType="integer"-->
- <!-- select="selectEventCount1"-->
- <!-- column="{applicationScenarioValue=applicationScenarioValue, tenantId=tenantId}">-->
- <!-- </collection>-->
- <!-- <collection property="eventNumberFromProject" ofType="integer"-->
- <!-- select="selectEventCount2"-->
- <!-- column="{applicationScenarioValue=applicationScenarioValue, tenantId=tenantId}">-->
- <!-- </collection>-->
- <!-- </resultMap>-->
- <!-- <select id="selectEventCount1" resultType="integer">-->
- <!-- select count(*)-->
- <!-- from event-->
- <!-- where find_in_set(#{applicationScenarioValue}, application_scenario)-->
- <!-- and tenant_id = #{tenantId}-->
- <!-- </select>-->
- <!-- <select id="selectEventCount2" resultType="integer">-->
- <!-- select count(*)-->
- <!-- from os_thematic proj-->
- <!-- join asso_event_project asso on proj.id = asso.project_id-->
- <!-- join event even on asso.event_id = even.id-->
- <!-- where find_in_set(#{applicationScenarioValue}, proj.scenarioid)-->
- <!-- and even.application_scenario is null-->
- <!-- and tenant_id = #{tenantId}-->
- <!-- </select>-->
- <!--查询所有应用场景-->
- <!--List<ApplicationScenario> queryApplicationScenarios();-->
- <select id="queryApplicationScenarios" resultMap="queryApplicationScenariosMap">
- select label, value
- from os_system_dict
- where type = "ENTERPRISE_APPLICATION_SCENARIO"
- </select>
- <resultMap id="queryApplicationScenariosMap" type="cn.cslg.pas.domain.ApplicationScenario">
- <result column="label" property="applicationScenarioName"/>
- <result column="value" property="applicationScenarioValue"/>
- </resultMap>
- <!--查询所有应用场景不是null的事件-->
- <!--List<EventListItemVO> queryEventsDirectApplicationScenario(Integer tenantId);-->
- <select id="queryEventsDirectApplicationScenario" resultMap="queryEventsHaveApplicationScenarioMap">
- select application_scenario
- from event
- where application_scenario is not null
- and tenant_id = #{tenantId}
- </select>
- <resultMap id="queryEventsHaveApplicationScenarioMap" type="cn.cslg.pas.common.model.vo.EventListItemVO">
- <result column="application_scenario" property="applicationScenario"/>
- </resultMap>
- <!--查询所有应用场景是null的事件(去关联专题库表查询出应用场景,就作为事件的应用场景)-->
- <!--List<EventListItemVO> queryEventsInDirectApplicationScenario(Integer tenantId);-->
- <select id="queryEventsInDirectApplicationScenario" resultMap="queryEventsInDirectApplicationScenarioMap">
- select even.application_scenario, proj.scenarioid
- from event even
- join asso_event_project asso on even.id = asso.event_id
- join os_thematic proj on asso.project_id = proj.id
- where even.application_scenario is null
- and proj.scenarioid is not null
- and even.tenant_id = #{tenantId}
- </select>
- <resultMap id="queryEventsInDirectApplicationScenarioMap" type="cn.cslg.pas.common.model.vo.EventListItemVO">
- <result column="scenarioid" property="applicationScenario"/>
- </resultMap>
- <!--根据应用场景查询调查类型-->
- <!--List<Type> queryTypeid(Integer applicationScenario);-->
- <select id="queryTypeid" resultMap="queryTypeidMap">
- select DICT_CHILD_VALUE, DICT_CHILD_LABEL
- from os_system_dict_associate
- where DICT_PARENT_VALUE = #{applicationScenario}
- </select>
- <resultMap id="queryTypeidMap" type="cn.cslg.pas.domain.Type">
- <result column="DICT_CHILD_VALUE" property="typeId"/>
- <result column="DICT_CHILD_LABEL" property="typeName"/>
- </resultMap>
- <!--根据应用场景和事件id查询专题库-->
- <!--List<Project> queryProjects(Integer applicationScenario, Integer eventId);-->
- <select id="queryProjects" resultMap="queryProjectsMap">
- select id, typeid
- from os_thematic
- where find_in_set(#{applicationScenario}, scenarioid)
- and id in (select project_id from asso_event_project where event_id = #{eventId})
- </select>
- <resultMap id="queryProjectsMap" type="cn.cslg.pas.domain.Project">
- <result column="typeid" property="type"/>
- </resultMap>
- </mapper>
|