| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477 |
- <?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.moduleLhzx.employee.mapper.TLhzxEmployeeMapper">
- <!-- 通用查询映射结果 -->
- <resultMap id="BaseResultMap" type="com.yt.zhylplat.moduleLhzx.employee.entity.TLhzxEmployee">
- <id column="id" property="id"/>
- <result column="maintenance_company_id" property="maintenanceCompanyId"/>
- <result column="maintenance_company_name" property="maintenanceCompanyName"/>
- <result column="real_name" property="realName"/>
- <result column="job_name" property="jobName"/>
- <result column="job_title" property="jobTitle"/>
- <result column="job_level" property="jobLevel"/>
- <result column="sex" property="sex"/>
- <result column="id_card_num" property="idCardNum"/>
- <result column="tel_phone" property="telPhone"/>
- <result column="before_address" property="beforeAddress"/>
- <result column="now_address" property="nowAddress"/>
- <result column="address_type" property="addressType"/>
- <result column="age" property="age"/>
- <result column="post_card_num" property="postCardNum"/>
- <result column="emp_type" property="empType"/>
- <result column="remark" property="remark"/>
- <result column="create_user_id" property="createUserId"/>
- <result column="create_date" property="createDate"/>
- <result column="update_user_id" property="updateUserId"/>
- <result column="update_date" property="updateDate"/>
- <result column="del_flg" property="delFlg"/>
- </resultMap>
- <!-- 通用查询结果列 -->
- <sql id="Base_Column_List">
- id, yh_company_id, yh_company_name, section_id, section_name, real_name, job_name, job_title, job_level, sex, id_card_num, tel_phone, before_address, now_address, address_type, age, post_card_num, emp_type, remark, create_user_id, create_date, update_user_id, update_date, del_flg
- </sql>
- <select id="findEmpByCompany"
- resultType="com.yt.zhylplat.moduleLhzx.road.entity.TLhzxRoadSectionMaintenanceCompany">
- </select>
- <select id="findEmpBySection"
- resultType="com.yt.zhylplat.moduleLhzx.road.entity.TLhzxRoadSectionMaintenanceCompany">
- </select>
- <select id="findEmpByCompanyId" resultType="com.yt.zhylplat.moduleLhzx.employee.entity.TLhzxEmployee">
- select
- e.*
- from
- T_Lhzx_Employee e left join T_Lhzx_Employee_Section TLES on e.id = TLES.employee_id
- <where>
- and e.del_flg=0
- and TLES.del_flg = 0
- <if test="allEmp.maintenanceCompanyId!=null">
- and e.maintenance_company_id=#{allEmp.maintenanceCompanyId}
- </if>
- <if test="allEmp.idCardNum!=null and allEmp.idCardNum!=''">
- and e.id_card_num =#{allEmp.idCardNum}
- </if>
- <if test="allEmp.telPhone!=null and allEmp.telPhone!=''">
- and e.tel_phone=#{allEmp.telPhone}
- </if>
- <if test="allEmp.realName!=null and allEmp.realName!=''">
- and e.real_name like concat('%',#{allEmp.realName},'%')
- </if>
- <if test="allEmp.sectionId!=null">
- and section_id=#{allEmp.sectionId}
- </if>
- </where>
- </select>
- <select id="findEmpAll" resultType="com.yt.zhylplat.moduleLhzx.employee.entity.TLhzxEmployee">
- select
- *
- from
- T_Lhzx_Employee e
- where
- e.del_flg=0
- <if test="allEmptwo.idCardNum!=null and allEmptwo.idCardNum!=''">
- and e.id_card_num=#{allEmptwo.idCardNum}
- </if>
- <if test="allEmptwo.telPhone!=null and allEmptwo.telPhone!=''">
- and e.tel_phone=#{allEmptwo.telPhone}
- </if>
- <if test="allEmptwo.realName!=null and allEmptwo.realName!=''">
- and e.real_name like concat('%',#{allEmptwo.realName},'%')
- </if>
- </select>
- <select id="sectionPage" resultType="com.yt.zhylplat.moduleLhzx.road.entity.TLhzxRoadSectionMaintenanceCompany">
- SELECT DISTINCT
- emp.section_id as sectionId,
- emp.section_name,
- emp.maintenance_company_id,
- emp.maintenance_company_name,
- emp.section_type as sectionType,
- project_manager AS projectManager,
- project_manager_tel,
- charge_leader AS chargeLeader,
- charge_leader_tel AS chargeLeaderTel,
- maneger AS managerCount,
- worker AS workerCount,
- emp.OnSh as sumOnSh,
- emp.LeaveSh as sumLeaveSh,
- emp.BackSh as sumBackSh,
- emp.Isolation as sumIsolation,
- (select operation_num FROM T_Lhzx_Maintenance_Completion_Record where del_flg=0 and section_id = emp.section_id and maintenance_company_id = emp.maintenance_company_id order by create_date desc limit 1) as operation_num
- FROM (
- SELECT
- es.section_id,
- s.section_name,
- maintenance_company_id,
- maintenance_company_name,
- s.section_type,
- sum(IF(emp_type=0, 1, 0)) AS maneger,
- sum(IF(emp_type!=0, 1, 0)) AS worker,
- sum(IF(leaving_shanghai_sta=0,1,0)) as OnSh,
- sum(IF(leaving_shanghai_sta=1, 1, 0)) as LeaveSh,
- sum(IF(leaving_shanghai_sta=2, 1, 0)) as BackSh,
- sum(IF(leaving_shanghai_sta=3, 1, 0)) as Isolation
- FROM T_Lhzx_Employee e
- left join T_Lhzx_Employee_Section es on e.id = es.employee_id
- left join T_Lhzx_Section s on es.section_id = s.id
- WHERE e.del_flg = 0
- and e.emp_sta=0
- and es.section_id is not null
- GROUP BY
- es.section_id,
- s.section_name,
- maintenance_company_id,
- maintenance_company_name
- ) AS emp
- LEFT JOIN (
- SELECT DISTINCT section_id,
- maintenance_company_id,
- project_manager,
- project_manager_tel,
- charge_leader,
- charge_leader_tel
- FROM T_Lhzx_Road_Section_Maintenance_Company
- WHERE del_flg = 0
- ) AS rsmc ON emp.maintenance_company_id = rsmc.maintenance_company_id and rsmc.section_id = emp.section_id
- <where>
- <if test="spage.maintenanceCompanyId!=null and spage.maintenanceCompanyId!=''">
- and rsmc.maintenance_company_id=#{spage.maintenanceCompanyId}
- </if>
- <if test="spage.maintenanceCompanyName!=null and spage.maintenanceCompanyName!=''">
- and emp.maintenance_company_name like concat('%',#{spage.maintenanceCompanyName},'%')
- </if>
- <if test="spage.sectionName!=null and spage.sectionName!=''">
- and emp.section_name like concat('%',#{spage.sectionName},'%')
- </if>
- <if test="spage.sectionType!=null">
- and emp.section_type =#{spage.sectionType}
- </if>
- </where>
- ORDER BY
- emp.section_type, emp.section_id asc,emp.maintenance_company_id asc
- </select>
- <select id="comPanyPage" resultType="com.yt.zhylplat.moduleLhzx.road.entity.TLhzxRoadSectionMaintenanceCompany">
- SELECT DISTINCT
- emp.section_id as sectionId,
- emp.section_name,
- emp.maintenance_company_id,
- emp.maintenance_company_name,
- emp.section_type as sectionType,
- project_manager AS projectManager,
- project_manager_tel,
- charge_leader AS chargeLeader,
- charge_leader_tel AS chargeLeaderTel,
- maneger AS managerCount,
- worker AS workerCount,
- emp.OnSh as sumOnSh,
- emp.LeaveSh as sumLeaveSh,
- emp.BackSh as sumBackSh,
- emp.Isolation as sumIsolation,
- emp.leavecount as leaveCount,
- emp.entrycount as entryCount
- FROM (
- SELECT
- es.section_id,
- s.section_name,
- maintenance_company_id,
- maintenance_company_name,
- s.section_type,
- sum(IF(emp_type=0, 1, 0)) AS maneger,
- sum(IF(emp_type!=0, 1, 0)) AS worker,
- sum(IF(leaving_shanghai_sta=0,1,0)) as OnSh,
- sum(IF(leaving_shanghai_sta=1, 1, 0)) as LeaveSh,
- sum(IF(leaving_shanghai_sta=2, 1, 0)) as BackSh,
- sum(IF(leaving_shanghai_sta=3, 1, 0)) as Isolation,
- sum(if(emp_change_date = CURDATE() and emp_sta=1,1,0)) as leavecount,
- sum(if(emp_change_date = CURDATE() and emp_sta=0,1,0)) as entrycount
- FROM T_Lhzx_Employee e
- left join T_Lhzx_Employee_Section es on e.id = es.employee_id
- left join T_Lhzx_Section s on es.section_id = s.id
- WHERE e.del_flg = 0
- and es.section_id is not null
- GROUP BY
- es.section_id,
- s.section_name,
- maintenance_company_id,
- maintenance_company_name
- ) AS emp
- LEFT JOIN (
- SELECT DISTINCT section_id,
- maintenance_company_id,
- project_manager,
- project_manager_tel,
- charge_leader,
- charge_leader_tel
- FROM T_Lhzx_Road_Section_Maintenance_Company
- WHERE del_flg = 0
- ) AS rsmc ON emp.maintenance_company_id = rsmc.maintenance_company_id and rsmc.section_id = emp.section_id
- <where>
- <if test="cpage.maintenanceCompanyId!=null and cpage.maintenanceCompanyId!=''">
- and rsmc.maintenance_company_id=#{cpage.maintenanceCompanyId}
- </if>
- <if test="cpage.maintenanceCompanyName!=null and cpage.maintenanceCompanyName!=''">
- and emp.maintenance_company_name like concat('%',#{cpage.maintenanceCompanyName},'%')
- </if>
- <if test="cpage.sectionName!=null and cpage.sectionName!=''">
- and emp.section_name like concat('%',#{cpage.sectionName},'%')
- </if>
- <if test="cpage.sectionType!=null">
- and emp.section_type =#{cpage.sectionType}
- </if>
- </where>
- ORDER BY
- emp.maintenance_company_id,emp.section_id
- </select>
- <select id="sumOfManagerAndWorker"
- resultType="com.yt.zhylplat.moduleLhzx.road.entity.TLhzxRoadSectionMaintenanceCompany">
- select
- sum(IF(emp_type=0, 1, 0)) as sumManager,
- sum(IF(emp_type!=0, 1, 0)) as sumWorker,
- sum(IF(leaving_shanghai_sta=0,1,0)) as sumOnSh,
- sum(IF(leaving_shanghai_sta=1, 1, 0)) as sumLeaveSh,
- sum(IF(leaving_shanghai_sta=2, 1, 0)) as sumBackSh,
- sum(IF(leaving_shanghai_sta=3, 1, 0)) as sumIsolation,
- (SELECT
- sum(mcr.operation_num)
- FROM
- T_Lhzx_Maintenance_Completion_Record mcr
- LEFT JOIN (
- select maintenance_company_id,section_id,max(create_date) as maxCreateDate
- FROM T_Lhzx_Maintenance_Completion_Record
- where del_flg=0
- GROUP BY maintenance_company_id,section_id
- ) max on mcr.section_id = max.section_id and mcr.maintenance_company_id = max.maintenance_company_id
- left join T_Lhzx_Section TLS on mcr.section_id = TLS.id
- WHERE mcr.create_date = max.maxCreateDate
- <if test="sumall.maintenanceCompanyId!=null">
- and mcr.maintenance_company_id=#{sumall.maintenanceCompanyId}
- </if>
- <if test="sumall.sectionName!=null and sumall.sectionName!=''">
- and mcr.section_name like concat('%',#{sumall.sectionName},'%')
- </if>
- <if test="sumall.maintenanceCompanyName!=null and sumall.maintenanceCompanyName!=''">
- and maintenance_company_name like concat('%',#{sumall.maintenanceCompanyName},'%')
- </if>
- <if test="sumall.sectionType!=null">
- and section_type =(#{sumall.sectionType})
- </if> ) as sumOnJob
- from
- (SELECT
- e.*,
- section_id
- FROM
- T_Lhzx_Employee e
- LEFT JOIN T_Lhzx_Employee_Section es ON e.id = es.employee_id
- where e.del_flg=0
- and e.emp_sta=0
- ) AS se
- LEFT JOIN T_Lhzx_Section s ON se.section_id = s.id
- where
- se.del_flg=0
- and s.del_flg=0
- <if test="sumall.maintenanceCompanyId!=null and sumall.maintenanceCompanyId!=''">
- and maintenance_company_id=#{sumall.maintenanceCompanyId}
- </if>
- <if test="sumall.maintenanceCompanyName!=null and sumall.maintenanceCompanyName!=''">
- and maintenance_company_name like concat('%',#{sumall.maintenanceCompanyName},'%')
- </if>
- <if test="sumall.sectionName!=null and sumall.sectionName!=''">
- and section_name like concat('%',#{sumall.sectionName},'%')
- </if>
- LIMIT 1
- </select>
- <select id="countManager" resultType="java.lang.Integer">
- select count(*)
- from T_Lhzx_Employee e
- left join
- T_Lhzx_Employee_Section es
- ON e.id = es.employee_id
- where section_id = #{sectionId}
- and job_name = '项目经理'
- and maintenance_company_id = #{maintenanceCompanyId}
- </select>
- <select id="residue" resultType="com.yt.zhylplat.moduleLhzx.employee.entity.TLhzxEmployee">
- select e.real_name,
- e.tel_phone
- from T_Lhzx_Employee e
- left join
- T_Lhzx_Employee_Section es
- ON e.id = es.employee_id
- where es.section_id = #{sectionId}
- and e.job_name = '项目经理'
- and e.maintenance_company_id = #{maintenanceCompanyId}
- and e.del_flg = 0
- and es.del_flg = 0
- </select>
- <select id="findBySectionIdAndMaintenanceCompanyId"
- resultType="com.yt.zhylplat.moduleLhzx.employee.entity.TLhzxEmployee">
- SELECT id,
- real_name,
- tel_phone
- FROM (SELECT * FROM T_Lhzx_Employee WHERE maintenance_company_id = #{maintenanceCompanyId} and del_flg = 0) t
- LEFT JOIN (SELECT employee_id
- FROM T_Lhzx_Employee_Section
- WHERE section_id = #{sectionId}
- and del_flg = 0) t1
- ON t.id = t1.employee_id
- WHERE t.job_name = '项目经理'
- AND t.real_name not in (SELECT DISTINCT project_manager
- FROM T_Lhzx_Road_Section_Maintenance_Company
- WHERE maintenance_company_id = #{maintenanceCompanyId}
- and del_flg = 0)
- </select>
- <select id="sectionTypePage"
- resultType="com.yt.zhylplat.moduleLhzx.road.entity.TLhzxRoadSectionMaintenanceCompany">
- SELECT
- s.section_type as sectionType,
- sum( IF ( emp_type = 0, 1, 0 )) AS managerCount,
- sum( IF ( emp_type != 0, 1, 0 )) AS workerCount,
- sum( IF ( leaving_shanghai_sta = 0, 1, 0 )) AS sumOnSh,
- sum( IF ( leaving_shanghai_sta = 1, 1, 0 )) AS sumLeaveSh,
- sum( IF ( leaving_shanghai_sta = 2, 1, 0 )) AS sumBackSh,
- sum( IF ( leaving_shanghai_sta = 3, 1, 0 )) AS sumIsolation,
- sum( IF ( emp_change_date = CURDATE() AND emp_sta = 1, 1, 0 )) AS leaveCount,
- sum( IF ( emp_change_date = CURDATE() AND emp_sta = 0, 1, 0 )) AS entryCount,
- IF(temp.operation_num is null, 0, temp.operation_num) as sumOnJob
- FROM
- T_Lhzx_Employee e
- LEFT JOIN T_Lhzx_Employee_Section es ON e.id = es.employee_id
- LEFT JOIN T_Lhzx_Section s ON es.section_id = s.id
- LEFT JOIN (
- SELECT
- max.section_type as section_type,
- sum(IF(mcr.operation_num is null, 0, mcr.operation_num)) as operation_num
- from
- T_Lhzx_Maintenance_Completion_Record mcr
- LEFT JOIN (
- SELECT
- r.maintenance_company_id,
- r.section_id,
- s.section_type,
- max( r.create_date ) AS maxCreateDate
- FROM
- T_Lhzx_Maintenance_Completion_Record r
- LEFT JOIN T_Lhzx_Section s ON r.section_id = s.id
- WHERE
- r.del_flg = 0
- GROUP BY
- section_type,
- r.maintenance_company_id,
- r.section_id
- ) max ON mcr.section_id = max.section_id AND mcr.maintenance_company_id = max.maintenance_company_id
- WHERE
- mcr.create_date = max.maxCreateDate
- GROUP BY
- max.section_type
- ) temp on s.section_type = temp.section_type
- WHERE
- e.del_flg = 0
- and
- s.section_type is not null
- GROUP BY
- s.section_type,
- temp.operation_num
- </select>
- <select id="selectEmployeePage" resultType="com.yt.zhylplat.moduleLhzx.employee.vo.TLhzxEmployeeVO">
- select
- s.section_name,
- e.maintenance_company_name,
- e.real_name,
- e.job_name,
- e.job_title,
- e.sex,
- e.tel_phone
- from
- T_Lhzx_Employee e
- left join
- T_Lhzx_Employee_Section es on e.id = es.employee_id
- left join
- T_Lhzx_Section s on s.id = es.section_id
- <where>
- and
- e.del_flg=0
- and
- es.del_flg = 0
- <if test="employee.empType != null and employee.empType == 0">
- and e.emp_type = 0
- </if>
- <if test="employee.empType != null and employee.empType != 0">
- and find_in_set(e.emp_type, '1, 2')
- </if>
- <if test="employee.sectionName != null and employee.sectionName != ''">
- and s.section_name like concat('%', #{employee.sectionName}, '%')
- </if>
- <if test="employee.maintenanceCompanyName != null and employee.maintenanceCompanyName != ''">
- and e.maintenance_company_name like concat('%', #{employee.maintenanceCompanyName}, '%')
- </if>
- </where>
- order by
- s.id, e.maintenance_company_id, e.create_date desc
- </select>
- <select id="employeeStatus"
- resultType="com.yt.zhylplat.moduleLhzx.road.entity.TLhzxRoadSectionMaintenanceCompany">
- SELECT DISTINCT
- emp.section_id as sectionId,
- emp.section_name,
- emp.maintenance_company_id,
- emp.maintenance_company_name,
- emp.section_type as sectionType,
- project_manager AS projectManager,
- project_manager_tel,
- charge_leader AS chargeLeader,
- charge_leader_tel AS chargeLeaderTel,
- maneger AS managerCount,
- worker AS workerCount,
- emp.OnSh as sumOnSh,
- emp.LeaveSh as sumLeaveSh,
- emp.BackSh as sumBackSh,
- emp.Isolation as sumIsolation,
- emp.leavecount as leaveCount,
- emp.entrycount as entryCount,
- (select operation_num FROM T_Lhzx_Maintenance_Completion_Record where del_flg=0 and section_id = emp.section_id and maintenance_company_id = emp.maintenance_company_id order by create_date desc limit 1) as operation_num
- FROM (
- SELECT
- es.section_id,
- s.section_name,
- maintenance_company_id,
- maintenance_company_name,
- s.section_type,
- sum(IF(emp_type=0, 1, 0)) AS maneger,
- sum(IF(emp_type!=0, 1, 0)) AS worker,
- sum(IF(leaving_shanghai_sta=0,1,0)) as OnSh,
- sum(IF(leaving_shanghai_sta=1, 1, 0)) as LeaveSh,
- sum(IF(leaving_shanghai_sta=2, 1, 0)) as BackSh,
- sum(IF(leaving_shanghai_sta=3, 1, 0)) as Isolation,
- sum(if(emp_change_date = CURDATE() and emp_sta=1,1,0)) as leavecount,
- sum(if(emp_change_date = CURDATE() and emp_sta=0,1,0)) as entrycount
- FROM T_Lhzx_Employee e
- left join T_Lhzx_Employee_Section es on e.id = es.employee_id
- left join T_Lhzx_Section s on es.section_id = s.id
- WHERE e.del_flg = 0
- and es.section_id is not null
- GROUP BY
- es.section_id,
- s.section_name,
- maintenance_company_id,
- maintenance_company_name
- ) AS emp
- LEFT JOIN (
- SELECT DISTINCT section_id,
- maintenance_company_id,
- project_manager,
- project_manager_tel,
- charge_leader,
- charge_leader_tel
- FROM T_Lhzx_Road_Section_Maintenance_Company
- WHERE del_flg = 0
- ) AS rsmc ON emp.maintenance_company_id = rsmc.maintenance_company_id and rsmc.section_id = emp.section_id
- ORDER BY
- emp.section_type, emp.section_id asc,emp.maintenance_company_id asc
- </select>
- </mapper>
|