| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180 |
- <?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="com.yt.zhylplat.moduleSec.trainingEducation.mapper.TSecTrainingEducationMapper">
- <!-- 通用查询映射结果 -->
- <resultMap id="BaseResultMap" type="com.yt.zhylplat.moduleSec.trainingEducation.entity.TSecTrainingEducation">
- <id column="id" property="id" />
- <result column="create_user_id" property="createUserId" />
- <result column="create_date" property="createDate" />
- <result column="update_user_id" property="updateUserId" />
- <result column="maintenance_company_id" property="maintenanceCompanyId" />
- <result column="maintenance_company_name" property="maintenanceCompanyName" />
- <result column="section_id" property="sectionId" />
- <result column="section_name" property="sectionName" />
- <result column="file_name" property="fileName" />
- <result column="file_url" property="fileUrl" />
- <result column="update_date" property="updateDate" />
- <result column="del_flg" property="delFlg" />
- <result column="remark" property="remark" />
- </resultMap>
- <!-- 通用查询结果列 -->
- <sql id="Base_Column_List">
- 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
- </sql>
- <select id="trainingStatistics"
- resultType="com.yt.zhylplat.moduleSec.trainingEducation.entity.TSecTrainingEducation">
- SELECT
- te.maintenance_company_id,
- te.maintenance_company_name,
- te.section_id,
- te.section_name,
- COUNT(*) as trainCount
- FROM
- T_Sec_Training_Education te
- WHERE
- te.del_flg = 0
- <if test="train.maintenanceCompanyId != null">
- and te.maintenance_company_id=#{train.maintenanceCompanyId}
- </if>
- <if test="train.sectionId != null">
- and te.section_id=#{train.sectionId}
- </if>
- <if test="train.startTime !=null and train.startTime!=''">
- and date_format(te.create_date,'%Y-%m') = date_format(STR_TO_DATE(#{train.startTime},'%Y-%m'),'%Y-%m')
- </if>
- <if test="train.startTime != null and train.startTime!=''">
- and date_format(te.create_date,'%Y') = date_format(STR_TO_DATE(#{train.startTime},'%Y'),'%Y')
- </if>
- group by te.maintenance_company_id,
- te.maintenance_company_name,
- te.section_id,
- te.section_name
- </select>
- <select id="centerStatistics"
- resultType="com.yt.zhylplat.moduleSec.trainingEducation.entity.TSecTrainingEducation">
- SELECT
- count(*) as centerTrainCount
- FROM
- T_Pub_Train t
- WHERE
- type = 2
- and delete_flag=0
- <if test="centerTrain.startTime !=null and centerTrain.startTime!=''">
- and date_format(t.create_date,'%Y-%m') = date_format(STR_TO_DATE(#{centerTrain.startTime},'%Y-%m'),'%Y-%m')
- </if>
- <if test="centerTrain.startTime != null and centerTrain.startTime!=''">
- and date_format(t.create_date,'%Y') = date_format(STR_TO_DATE(#{centerTrain.startTime},'%Y'),'%Y')
- </if>
- </select>
- <select id="allStatistics"
- resultType="com.yt.zhylplat.moduleSec.trainingEducation.entity.TSecTrainingEducation">
- select
- count(*) as mTrainCount
- from
- T_Sec_Training_Education ts
- where
- ts.del_flg=0
- <if test="allCount.startTime !=null and allCount.startTime!=''">
- and date_format(ts.create_date,'%Y-%m') = date_format(STR_TO_DATE(#{allCount.startTime},'%Y-%m'),'%Y-%m')
- </if>
- <if test="allCount.startTime != null and allCount.startTime!=''">
- and date_format(ts.create_date,'%Y') = date_format(STR_TO_DATE(#{allCount.startTime},'%Y'),'%Y')
- </if>
- <if test="allCount.maintenanceCompanyId != null">
- and ts.maintenance_company_id=#{allCount.maintenanceCompanyId}
- </if>
- </select>
- <select id="selectTSecTrainingEducationBySection"
- resultType="com.yt.zhylplat.moduleSec.trainingEducation.entity.TSecTrainingEducation">
- SELECT
- s.id as sectionId,
- s.section_name as sectionName,
- m.id as maintenanceCompanyId,
- m.maintenance_company_name as maintenanceCompanyName,
- IFNULL
- (b.sumCount,0) AS sumCount
- FROM
- T_Lhzx_Section s
- LEFT JOIN T_Lhzx_Road_Section_Maintenance_Company rsmc ON s.id = rsmc.section_id
- LEFT JOIN T_Lhzx_Maintenance_Company m ON m.id = rsmc.maintenance_company_id
- LEFT JOIN (
- SELECT
- section_id,
- section_name,
- maintenance_company_id,
- maintenance_company_name,
- COUNT(id) as sumCount
- FROM
- T_Sec_Training_Education
- WHERE
- del_flg = 0
- <if test="uploadYear != null and uploadYear != ''">
- and DATE_FORMAT(create_date, '%Y') = #{uploadYear}
- </if>
- GROUP BY
- section_id,
- section_name,
- maintenance_company_id,
- maintenance_company_name
- order by
- section_id,
- maintenance_company_id) b ON rsmc.section_id = b.section_id
- AND rsmc.maintenance_company_id = b.maintenance_company_id
- WHERE
- m.id IS NOT NULL
- <if test="sectionId != null">
- AND rsmc.section_id = #{sectionId}
- </if>
- <if test="maintenanceCompanyId != null">
- AND rsmc.maintenance_company_id = #{maintenanceCompanyId}
- </if>
- GROUP BY
- s.id,
- s.section_name,
- m.id,
- m.maintenance_company_name,
- b.sumCount
- ORDER BY
- s.id,
- m.id
- </select>
- <select id="selectTSecSecurityPatrolSumCount"
- resultType="com.yt.zhylplat.moduleSec.trainingEducation.entity.TSecTrainingEducation">
- select
- sum(if(temp.sumCount is null, 0, temp.sumCount)) as sumCount
- from
- (<include refid="TSecTrainingEducationSql"/>) temp
- </select>
- <sql id="TSecTrainingEducationSql">
- SELECT
- section_id,
- section_name,
- maintenance_company_id,
- maintenance_company_name,
- COUNT(id) as sumCount
- FROM
- T_Sec_Training_Education
- WHERE
- del_flg = 0
- <if test="sectionId != null">
- AND section_id = #{sectionId}
- </if>
- <if test="maintenanceCompanyId != null">
- AND maintenance_company_id = #{maintenanceCompanyId}
- </if>
- <if test="uploadYear != null and uploadYear != ''">
- and DATE_FORMAT(create_date, '%Y') = #{uploadYear}
- </if>
- GROUP BY
- section_id,
- section_name,
- maintenance_company_id,
- maintenance_company_name
- order by
- section_id,
- maintenance_company_id
- </sql>
- </mapper>
|