| 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="com.yt.zhylplat.moduleOffe.statistics.mapper.TOffeStatisticsMapper">
- <!-- 通用查询映射结果 -->
- <resultMap id="BaseResultMap" type="com.yt.zhylplat.moduleOffe.statistics.entity.TOffeStatistics">
- <id column="id" property="id" />
- <result column="statistics_name" property="statisticsName" />
- <result column="dept_id" property="deptId" />
- <result column="dept_name" property="deptName" />
- <result column="start_date" property="startDate" />
- <result column="end_date" property="endDate" />
- <result column="file_name" property="fileName" />
- <result column="file_url" property="fileUrl" />
- <result column="is_all_visible" property="isAllVisible" />
- <result column="create_user_id" property="createUserId" />
- <result column="create_user_name" property="createUserName" />
- <result column="create_date" property="createDate" />
- <result column="update_user_id" property="updateUserId" />
- <result column="update_user_name" property="updateUserName" />
- <result column="update_date" property="updateDate" />
- <result column="del_flg" property="delFlg" />
- </resultMap>
- <!-- 通用查询结果列 -->
- <sql id="Base_Column_List">
- 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
- </sql>
- <select id="selectStatisticsIsUpload"
- resultType="com.yt.zhylplat.moduleOffe.statistics.entity.TOffeStatistics">
- select distinct
- s.id,
- if(sd.detail_count is null or sd.detail_count = 0, 0, 1) as isUpload
- from
- T_Offe_Statistics s
- left join
- (
- select
- statistics_id,
- count(1) as detail_count
- from
- T_Offe_Statistics_Detail
- where
- del_flg = 0
- and
- maintenance_company_id = #{maintenanceCompanyId}
- group by
- statistics_id
- ) sd on sd.statistics_id = s.id
- where
- s.del_flg = 0
- and (
- s.is_all_visible = 1
- or
- exists(
- select
- 1
- from
- T_Offe_Statistics_Company
- where
- del_flg = 0
- and
- statistics_id = s.id
- and
- maintenance_company_id = #{maintenanceCompanyId})
- )
- </select>
- <resultMap id="statisticsMap" type="com.yt.zhylplat.moduleOffe.statistics.entity.TOffeStatistics">
- <id column="id" property="id" />
- <result column="statistics_name" property="statisticsName" />
- <result column="dept_id" property="deptId" />
- <result column="dept_name" property="deptName" />
- <result column="start_date" property="startDate" />
- <result column="end_date" property="endDate" />
- <result column="file_name" property="fileName" />
- <result column="file_url" property="fileUrl" />
- <result column="is_all_visible" property="isAllVisible" />
- <result column="statistic_type" property="statisticType" />
- <result column="is_warning" property="isWarning" />
- <result column="warning_time" property="warningTime" />
- <result column="is_expedited" property="isExpedited" />
- <result column="create_user_id" property="createUserId" />
- <result column="create_user_name" property="createUserName" />
- <result column="create_date" property="createDate" />
- <result column="update_user_id" property="updateUserId" />
- <result column="update_user_name" property="updateUserName" />
- <result column="update_date" property="updateDate" />
- <result column="del_flg" property="delFlg" />
- <collection property="companyList" ofType="com.yt.zhylplat.moduleOffe.statistics.entity.TOffeStatisticsCompany">
- <id column="osc_id" property="id" />
- <result column="osc_statistics_id" property="statisticsId" />
- <result column="osc_maintenance_company_id" property="maintenanceCompanyId" />
- <result column="osc_maintenance_company_name" property="maintenanceCompanyName" />
- </collection>
- <collection property="sectionList" ofType="com.yt.zhylplat.moduleOffe.statistics.entity.TOffeStatisticsSection">
- <id column="oss_id" property="id" />
- <result column="oss_statistics_id" property="statisticsId" />
- <result column="oss_section_type" property="sectionType" />
- <result column="oss_section_id" property="sectionId" />
- </collection>
- <collection property="statisticsDetailList" ofType="com.yt.zhylplat.moduleOffe.statistics.entity.TOffeStatisticsDetail">
- <id column="osd_id" property="id" />
- <result column="osd_statistics_id" property="statisticsId" />
- <result column="osd_section_id" property="sectionId" />
- <result column="osd_section_name" property="sectionName" />
- <result column="osd_maintenance_company_id" property="maintenanceCompanyId" />
- <result column="osd_maintenance_company_name" property="maintenanceCompanyName" />
- <result column="osd_file_name" property="fileName" />
- <result column="osd_file_url" property="fileUrl" />
- <result column="osd_file_list" property="fileList" />
- </collection>
- </resultMap>
- <select id="selectStatisticsByBean" resultMap="statisticsMap">
- SELECT
- os.*,
- osc.id as osc_id,
- osc.statistics_id as osc_statistics_id,
- osc.maintenance_company_id as osc_maintenance_company_id,
- oscmc.maintenance_company_name as osc_maintenance_company_name,
- oss.id as oss_id,
- oss.statistics_id as oss_statistics_id,
- oss.section_type as oss_section_type,
- oss.section_id as oss_section_id,
- osd.id as osd_id,
- osd.statistics_id as osd_statistics_id,
- osd.section_id as osd_section_id,
- osd.section_name as osd_section_name,
- osd.maintenance_company_id as osd_maintenance_company_id,
- osd.maintenance_company_name as osd_maintenance_company_name,
- osd.file_name as osd_file_name,
- osd.file_url as osd_file_url,
- osd.file_list as osd_file_list
- FROM
- T_Offe_Statistics os
- LEFT JOIN
- T_Offe_Statistics_Company osc on os.id = osc.statistics_id
- left join
- T_Lhzx_Maintenance_Company oscmc on osc.maintenance_company_id = oscmc.id
- LEFT JOIN
- T_Offe_Statistics_Detail osd on os.id = osd.statistics_id
- LEFT JOIN
- T_Offe_Statistics_Section oss on os.id = oss.statistics_id
- WHERE
- os.del_flg = 0
- and
- os.is_all_visible != 0
- <if test="queryEndDate != null and queryEndDate != ''">
- AND DATE_FORMAT(os.end_date, '%Y-%m-%d') = DATE_FORMAT(#{queryEndDate}, '%Y-%m-%d')
- </if>
- <if test="queryEndDate == null or queryEndDate == ''">
- AND DATE_FORMAT(os.end_date, '%Y-%m-%d') = DATE_FORMAT(now(), '%Y-%m-%d')
- </if>
- </select>
- <select id="selectStatisticsByCenter"
- resultType="com.yt.zhylplat.moduleOffe.statistics.entity.TOffeStatistics">
- select
- temp.*
- from
- (<include refid="selectStatisticsSql"/>) temp
- </select>
- <select id="getStatisticsSumCountByCenter"
- resultType="com.yt.zhylplat.moduleOffe.statistics.entity.TOffeStatistics">
- select
- sum(if(temp.uploadCount is null, 0, temp.uploadCount)) as uploadCount
- from
- (<include refid="selectStatisticsSql"/>) temp
- </select>
- <sql id="selectStatisticsSql">
- select
- temp.statistic_type,
- IF(s.uploadCount is null, 0, s.uploadCount) as uploadCount
- from (
- SELECT
- 1 as statistic_type
- FROM
- dual
- union
- SELECT
- 2 as statistic_type
- FROM
- dual
- union
- SELECT
- 3 as statistic_type
- FROM
- dual
- union
- SELECT
- 4 as statistic_type
- FROM
- dual
- union
- SELECT
- 5 as statistic_type
- FROM
- dual
- union
- SELECT
- 6 as statistic_type
- FROM
- dual
- union
- SELECT
- 7 as statistic_type
- FROM
- dual
- ) temp
- left join (
- SELECT
- statistic_type,
- COUNT(1) as uploadCount
- FROM
- T_Offe_Statistics
- where
- del_flg = 0
- <if test="statistics.createUserName != null and statistics.createUserName != ''">
- and create_user_name like concat('%', #{statistics.createUserName}, '%')
- </if>
- <if test="statistics.uploadMonth != null and statistics.uploadMonth != ''">
- and date_format(create_date, '%Y-%m') = #{statistics.uploadMonth}
- </if>
- <if test="statistics.uploadYear != null and statistics.uploadYear != ''">
- and date_format(create_date, '%Y') = #{statistics.uploadYear}
- </if>
- group by
- statistic_type
- ) s on s.statistic_type = temp.statistic_type
- order by
- temp.statistic_type
- </sql>
- </mapper>
|