qa-prevention-gwj/src/main/resources/mybatis/dsno2/keyProjects/OutSourcedMapper.xml

912 lines
34 KiB
XML

<?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.zcloud.mapper.dsno2.keyProjects.OutSourcedMapper">
<!--表名 -->
<sql id="tableName">
`qa-czks-regulatory`.BUS_OUTSOURCED
</sql>
<!--数据字典表名 -->
<sql id="dicTableName">
SYS_DICTIONARIES
</sql>
<!-- 字段 -->
<sql id="Field">
f.DEPARTMENT_ID,
f.CONTRACT_PIC,
f.OUTSOURCED_NAME,
f.INVOLVING_CORPS,
f.STARTTIME,
f.ENDTIME,
f.CONTRACT_STIME,
f.CONTRACT_ETIME,
f.UNITS_ID,
f.CONTRACT_NUM,
f.UNITS_APTITUDE,
f.UNITS_PIC,
f.UNITS_PHONE,
f.MANAGE_NAME,
f.MANAGE_APTITUDE,
f.MANAGE_PIC,
f.MANAGE_PHONE,
f.DESIGE,
f.MEASURES,
f.ATTACHMENTS,
f.REMARKS,
f.TRAINING_NAME,
f.TRAINING_PIC,
f.TRAINING_STIME,
f.TRAINING_ETIME,
f.RECORDS,
f.SHEET,
f.EXAMINATION,
f.OATTACHMENTS,
f.CREATOR,
f.CREATTIME,
f.OPERATOR,
f.OPERATTIME,
f.ISDELETE,
f.APPLICANT,
f.STATE,
f.IS_CORP_TYPE,
f.PUNISH_THE_PERSON,
f.INVOLVING_CORPS_DEPART_ID,
f.OUTSOURCED_ID,
f.COMPETENT_DEPT_ID,
f.IS_SMS,
f.GROUP_UNIT,
f.MANAGER_DEPARTMENT_ID,
f.JURISDICTION_UNIT,
f.LOCATION
</sql>
<!-- 字段用于新增 -->
<sql id="Field2">
DEPARTMENT_ID,
CONTRACT_PIC,
OUTSOURCED_NAME,
INVOLVING_CORPS,
STARTTIME,
ENDTIME,
CONTRACT_STIME,
CONTRACT_ETIME,
UNITS_ID,
CONTRACT_NUM,
UNITS_APTITUDE,
UNITS_PIC,
UNITS_PHONE,
MANAGE_NAME,
MANAGE_APTITUDE,
MANAGE_PIC,
MANAGE_PHONE,
DESIGE,
MEASURES,
ATTACHMENTS,
REMARKS,
TRAINING_NAME,
TRAINING_PIC,
TRAINING_STIME,
TRAINING_ETIME,
RECORDS,
SHEET,
EXAMINATION,
OATTACHMENTS,
CREATOR,
CREATTIME,
OPERATOR,
OPERATTIME,
ISDELETE,
APPLICANT,
STATE,
IS_CORP_TYPE,
PUNISH_THE_PERSON,
INVOLVING_CORPS_DEPART_ID,
OUTSOURCED_ID,
COMPETENT_DEPT_ID,
GROUP_UNIT,
MANAGER_DEPARTMENT_ID,
JURISDICTION_UNIT,
IS_SMS,
LOCATION
</sql>
<!-- 字段值 -->
<sql id="FieldValue">
#{DEPARTMENT_ID},
#{CONTRACT_PIC},
#{OUTSOURCED_NAME},
#{INVOLVING_CORPS},
#{STARTTIME},
#{ENDTIME},
#{CONTRACT_STIME},
#{CONTRACT_ETIME},
#{UNITS_ID},
#{CONTRACT_NUM},
#{UNITS_APTITUDE},
#{UNITS_PIC},
#{UNITS_PHONE},
#{MANAGE_NAME},
#{MANAGE_APTITUDE},
#{MANAGE_PIC},
#{MANAGE_PHONE},
#{DESIGE},
#{MEASURES},
#{ATTACHMENTS},
#{REMARKS},
#{TRAINING_NAME},
#{TRAINING_PIC},
#{TRAINING_STIME},
#{TRAINING_ETIME},
#{RECORDS},
#{SHEET},
#{EXAMINATION},
#{OATTACHMENTS},
#{CREATOR},
#{CREATTIME},
#{OPERATOR},
#{OPERATTIME},
#{ISDELETE},
#{APPLICANT},
#{STATE},
#{IS_CORP_TYPE},
#{PUNISH_THE_PERSON},
#{INVOLVING_CORPS_DEPART_ID},
#{OUTSOURCED_ID},
#{COMPETENT_DEPT_ID},
#{GROUP_UNIT},
#{MANAGER_DEPARTMENT_ID},
#{JURISDICTION_UNIT},
#{IS_SMS},
#{LOCATION}
</sql>
<!-- 新增-->
<insert id="save" parameterType="pd">
insert into
<include refid="tableName"></include>
(
<include refid="Field2"></include>
) values (
<include refid="FieldValue"></include>
)
</insert>
<!-- 删除-->
<delete id="delete" parameterType="pd">
update
<include refid="tableName"></include>
set
ISDELETE = '1'
where
OUTSOURCED_ID = #{OUTSOURCED_ID}
</delete>
<!-- 修改 -->
<update id="edit" parameterType="pd">
update
<include refid="tableName"></include>
set
DEPARTMENT_ID = #{DEPARTMENT_ID},
CONTRACT_PIC = #{CONTRACT_PIC},
OUTSOURCED_NAME = #{OUTSOURCED_NAME},
INVOLVING_CORPS = #{INVOLVING_CORPS},
STARTTIME = #{STARTTIME},
ENDTIME = #{ENDTIME},
CONTRACT_STIME = #{CONTRACT_STIME},
CONTRACT_ETIME = #{CONTRACT_ETIME},
UNITS_ID = #{UNITS_ID},
CONTRACT_NUM = #{CONTRACT_NUM},
UNITS_APTITUDE = #{UNITS_APTITUDE},
UNITS_PIC = #{UNITS_PIC},
UNITS_PHONE = #{UNITS_PHONE},
MANAGE_NAME = #{MANAGE_NAME},
DESIGE = #{DESIGE},
MANAGE_APTITUDE = #{MANAGE_APTITUDE},
MANAGE_PIC = #{MANAGE_PIC},
MANAGE_PHONE = #{MANAGE_PHONE},
MEASURES = #{MEASURES},
ATTACHMENTS = #{ATTACHMENTS},
REMARKS = #{REMARKS},
TRAINING_NAME = #{TRAINING_NAME},
TRAINING_PIC = #{TRAINING_PIC},
TRAINING_STIME = #{TRAINING_STIME},
TRAINING_ETIME = #{TRAINING_ETIME},
RECORDS = #{RECORDS},
SHEET = #{SHEET},
EXAMINATION = #{EXAMINATION},
OATTACHMENTS = #{OATTACHMENTS},
APPLICANT = #{APPLICANT},
STATE = #{STATE},
PUNISH_THE_PERSON = #{PUNISH_THE_PERSON},
INVOLVING_CORPS_DEPART_ID = #{INVOLVING_CORPS_DEPART_ID},
COMPETENT_DEPT_ID = #{COMPETENT_DEPT_ID},
IS_SMS = #{IS_SMS},
GROUP_UNIT=#{GROUP_UNIT},
<if test="MANAGER_DEPARTMENT_ID != null and MANAGER_DEPARTMENT_ID !=''">
MANAGER_DEPARTMENT_ID=#{MANAGER_DEPARTMENT_ID},
</if>
<if test="JURISDICTION_UNIT != null and JURISDICTION_UNIT !=''">
JURISDICTION_UNIT=#{JURISDICTION_UNIT},
</if>
OUTSOURCED_ID = OUTSOURCED_ID
where
OUTSOURCED_ID = #{OUTSOURCED_ID}
</update>
<!-- 通过ID获取数据 -->
<select id="findById" parameterType="pd" resultType="pd">
select
f.*,
(select GROUP_CONCAT(t.CORP_NAME) from `qa-czks-prevention`.BUS_CORP_INFO t where FIND_IN_SET(t.CORPINFO_ID, f.INVOLVING_CORPS)) as INVOLVING_CORPS_NAME,
( SELECT GROUP_CONCAT( t.NAME ) FROM `qa-czks-prevention`.oa_department t WHERE FIND_IN_SET( t.DEPARTMENT_ID, f.INVOLVING_CORPS_DEPART_ID ) ) AS INVOLVING_CORPS_DEPART_NAME,
( SELECT GROUP_CONCAT( t.NAME ) FROM `qa-czks-prevention`.vi_department_all t WHERE FIND_IN_SET( t.DEPARTMENT_ID, f.DEPARTMENT_ID ) ) AS DEPARTMENT_NAME,
(select GROUP_CONCAT(t.CORP_NAME) from `qa-czks-prevention`.BUS_CORP_INFO t where FIND_IN_SET(t.CORPINFO_ID, f.GROUP_UNIT)) as GROUP_UNIT_NAME,
(select GROUP_CONCAT(t.CORP_NAME) from `qa-czks-prevention`.BUS_CORP_INFO t where FIND_IN_SET(t.CORPINFO_ID, f.MANAGE_NAME)) as MANAGE_CORPS_NAME,
(select GROUP_CONCAT(t.NAME) from (
SELECT
CONCAT( CONCAT( c.CORP_NAME, '-' ), t.NAME ) NAME ,t.DEPARTMENT_ID
FROM
`qa-czks-prevention`.OA_DEPARTMENT t
LEFT JOIN `qa-czks-prevention`.bus_corp_info c ON c.CORPINFO_ID = t.CORPINFO_ID
) t where FIND_IN_SET(t.DEPARTMENT_ID, f.JURISDICTION_UNIT)) as JURISDICTION_UNIT_NAME,
-- isd.NAME DEPARTMENT_NAME,
isdd.NAME MANAGER_DEPARTMENT_NAME,
isu.NAME USER_NAME,
pci.NAME Q_COMPETENT_DEPT_NAME,
pcij.NAME Q_DEPARTMENT_NAME,
pcijd.NAME Q_INVOLVING_CORPS_DEPART_NAME,
b.UNITS_NAME as UNITS_ID,
b.UNITS_NAME as UNITS_NAME,
p.`NAME` as UNITS_PIC_NAME
from
<include refid="tableName"></include> f
-- LEFT JOIN `qa-czks-prevention`.vi_department_all isd ON isd.DEPARTMENT_ID = f.DEPARTMENT_ID
LEFT JOIN `qa-czks-regulatory`.SYS_DEPARTMENT isdd ON isdd.DEPARTMENT_ID = f.MANAGER_DEPARTMENT_ID
LEFT JOIN `qa-czks-prevention`.vi_user_all isu ON isu.USER_ID = f.CONTRACT_PIC
LEFT JOIN `qa-czks-prevention`.oa_department pci ON pci.DEPARTMENT_ID = f.COMPETENT_DEPT_ID
LEFT JOIN `qa-czks-prevention`.oa_department pcij ON pcij.DEPARTMENT_ID = f.DEPARTMENT_ID
LEFT JOIN `qa-czks-prevention`.oa_department pcijd ON pcijd.DEPARTMENT_ID = f.INVOLVING_CORPS_DEPART_ID
left join bus_units b using (UNITS_ID)
left join `qa-czks-regulatory`.bus_personnelmanagement p on p.PERSONNELMANAGEMENT_ID = f.UNITS_PIC
where
f.OUTSOURCED_ID = #{OUTSOURCED_ID}
and f.ISDELETE = '0'
</select>
<!-- 列表 -->
<select id="datalistPage" parameterType="page" resultType="pd">
select
f.*,
(select GROUP_CONCAT(t.CORP_NAME) from `qa-czks-prevention`.BUS_CORP_INFO t where FIND_IN_SET(t.CORPINFO_ID, f.INVOLVING_CORPS)) as INVOLVING_CORPS_NAME,
(select GROUP_CONCAT(t.CORP_NAME) from `qa-czks-prevention`.BUS_CORP_INFO t where FIND_IN_SET(t.CORPINFO_ID, f.MANAGE_NAME)) as MANAGE_CORPS_NAME,
( SELECT GROUP_CONCAT( t.NAME ) FROM `qa-czks-prevention`.oa_department t WHERE FIND_IN_SET( t.DEPARTMENT_ID, f.INVOLVING_CORPS_DEPART_ID ) ) AS INVOLVING_CORPS_DEPART_NAME,
(select GROUP_CONCAT(t.CORP_NAME) from `qa-czks-prevention`.BUS_CORP_INFO t where FIND_IN_SET(t.CORPINFO_ID, f.GROUP_UNIT)) as GROUP_UNIT_NAME,
( SELECT GROUP_CONCAT( t.NAME ) FROM `qa-czks-prevention`.vi_department_all t WHERE FIND_IN_SET( t.DEPARTMENT_ID, f.DEPARTMENT_ID ) ) AS DEPARTMENT_NAME,
(select GROUP_CONCAT(t.NAME) from (
SELECT
CONCAT( CONCAT( c.CORP_NAME, '-' ), t.NAME ) NAME ,t.DEPARTMENT_ID
FROM
`qa-czks-prevention`.OA_DEPARTMENT t
LEFT JOIN `qa-czks-prevention`.bus_corp_info c ON c.CORPINFO_ID = t.CORPINFO_ID
) t where FIND_IN_SET(t.DEPARTMENT_ID, f.JURISDICTION_UNIT)) as JURISDICTION_UNIT_NAME,
isdd.NAME MANAGER_DEPARTMENT_NAME,
isu.NAME USER_NAME,
b.UNITS_NAME as UNITS_NAME,
isu.NAME as AIWARNING_PEOPLE,
pci.NAME Q_COMPETENT_DEPT_NAME,
cc.co as CHECK_COUNT,
(select count(1) from `qa-czks-regulatory`.BUS_AIWARNING a left join bus_videomanager avid on avid.VIDEOMANAGER_ID = a.VIDEOMANAGER_ID where avid.OUTSOURCED_ID= f.OUTSOURCED_ID and a.ISDELETE = '0') as AI_COUNT,
(select count(1) from `qa-czks-regulatory`.BUS_VIDEOMANAGER v where v.OUTSOURCED_ID = f.OUTSOURCED_ID and v.ISDELETE = '0') as VIDEO_COUNT,
(SELECT count( 1 ) FROM `qa-czks-prevention`.BUS_KEYPROJECTPUNISH k left join `qa-czks-prevention`.bus_keyprojectcheck kjc on kjc.KEYPROJECTCHECK_ID = k.KEYPROJECTCHECK_ID WHERE kjc.OUTSOURCED_ID =f.OUTSOURCED_ID AND k.ISDELETE = '0' ) as KEY_COUNT,
vua.NAME OUTSOURCED_CREATOR_NAME,
ifnull(vac.CORP_NAME,'秦港股份有限公司') CORP_NAME,
p.`NAME` as UNITS_PIC_NAME,
ifnull(h.HIDDEN_COUNT,0) HIDDEN_COUNT
from
<include refid="tableName"></include> f
left join bus_units b using (UNITS_ID)
LEFT JOIN `qa-czks-regulatory`.SYS_DEPARTMENT isdd ON isdd.DEPARTMENT_ID = f.MANAGER_DEPARTMENT_ID
LEFT JOIN `qa-czks-regulatory`.SYS_USER isu ON isu.USER_ID = f.CONTRACT_PIC
LEFT JOIN `qa-czks-prevention`.oa_department pcij ON pcij.DEPARTMENT_ID = f.DEPARTMENT_ID
LEFT JOIN `qa-czks-prevention`.oa_department pci ON pci.DEPARTMENT_ID = f.COMPETENT_DEPT_ID
LEFT JOIN `qa-czks-prevention`.vi_user_all vua on f.CREATOR = vua.USER_ID
LEFT JOIN `qa-czks-regulatory`.vi_all_corp vac on vua.CORPINFO_ID = vac.CORPINFO_ID
left join `qa-czks-regulatory`.bus_personnelmanagement p on p.PERSONNELMANAGEMENT_ID = f.UNITS_PIC
LEFT JOIN ( select count(c.KEYPROJECTCHECK_ID) co, c.OUTSOURCED_ID from `qa-czks-prevention`.BUS_KEYPROJECTCHECK c where c.ISDELETE = '0' group by c.OUTSOURCED_ID ) cc on cc.OUTSOURCED_ID = f.OUTSOURCED_ID
left join ( SELECT t.OUTSOURCED_ID, COUNT( t.HIDDEN_ID ) HIDDEN_COUNT
FROM
( SELECT IFNULL( k.OUTSOURCED_ID, h.FOREIGN_ID ) OUTSOURCED_ID, h.* FROM `qa-czks-prevention`.bus_keyproject_hidden h LEFT JOIN `qa-czks-prevention`.bus_keyprojectcheck k ON h.FOREIGN_ID = k.KEYPROJECTCHECK_ID ) t GROUP BY t.OUTSOURCED_ID ) h on h.OUTSOURCED_ID = f.OUTSOURCED_ID
where f.ISDELETE = '0'
<if test="pd.CORPINFO_ID != null and pd.CORPINFO_ID != ''"><!-- 关键词检索 -->
and
(
f.INVOLVING_CORPS LIKE CONCAT(CONCAT('%', #{pd.CORPINFO_ID}),'%')
or
f.GROUP_UNIT LIKE CONCAT(CONCAT('%', #{pd.CORPINFO_ID}),'%')
)
</if>
<if test="pd.KEYWORDS != null and pd.KEYWORDS != ''"><!-- 关键词检索 -->
and
(
<!-- 根据需求自己加检索条件-->
f.OUTSOURCED_NAME LIKE CONCAT(CONCAT('%', #{pd.KEYWORDS}),'%')
or
b.UNITS_NAME LIKE CONCAT(CONCAT('%', #{pd.KEYWORDS}),'%')
or
f.UNITS_PIC LIKE CONCAT(CONCAT('%', #{pd.KEYWORDS}),'%')
or
pcij.NAME LIKE CONCAT(CONCAT('%', #{pd.KEYWORDS}),'%')
)
</if>
<if test="pd.OUTSOURCED_NAME != null and pd.OUTSOURCED_NAME !=''">
and f.OUTSOURCED_NAME = #{pd.OUTSOURCED_NAME}
</if>
<if test="pd.UNITS_ID != null and pd.UNITS_ID !=''">
and f.UNITS_ID = #{pd.UNITS_ID}
</if>
<if test="pd.INVOLVING_CORP != null and pd.INVOLVING_CORP !=''">
and f.INVOLVING_CORPS LIKE CONCAT(CONCAT('%', #{pd.INVOLVING_CORP}),'%')
</if>
<if test="pd.DEPARTMENT_ID != null and pd.DEPARTMENT_ID !=''">
and f.DEPARTMENT_ID LIKE CONCAT(CONCAT('%', #{pd.DEPARTMENT_ID}),'%')
</if>
<if test="pd.COMPETENT_DEPT_ID != null and pd.COMPETENT_DEPT_ID !=''">
and f.COMPETENT_DEPT_ID LIKE CONCAT(CONCAT('%', #{pd.COMPETENT_DEPT_ID}),'%')
</if>
<if test="pd.GROUP_UNIT != null and pd.GROUP_UNIT !=''">
and f.GROUP_UNIT LIKE CONCAT(CONCAT('%', #{pd.GROUP_UNIT}),'%')
</if>
<if test="pd.CORP_NAME != null and pd.CORP_NAME !=''">
and vac.CORP_NAME LIKE CONCAT(CONCAT('%', #{pd.CORP_NAME}),'%')
</if>
<if test="pd.STATE != null and pd.STATE !=''">
and f.STATE = #{pd.STATE}
</if>
<if test="pd.CONTRACT_STIME != null and pd.CONTRACT_STIME !=''">
and (f.CONTRACT_STIME between #{pd.CONTRACT_STIME} and #{pd.CONTRACT_ETIME}
or f.CONTRACT_ETIME between #{pd.CONTRACT_STIME} and #{pd.CONTRACT_ETIME}
or (f.CONTRACT_STIME &lt; #{pd.CONTRACT_STIME} and f.CONTRACT_ETIME &gt; #{pd.CONTRACT_ETIME}))
</if>
<if test="pd.DeptId != null and pd.DeptId !=''">
and ( f.DEPARTMENT_ID LIKE CONCAT(CONCAT('%', #{pd.DeptId}),'%')
or f.COMPETENT_DEPT_ID LIKE CONCAT(CONCAT('%', #{pd.DeptId}),'%')
or f.INVOLVING_CORPS LIKE CONCAT(CONCAT('%', #{pd.DeptId}),'%')
or f.INVOLVING_CORPS_DEPART_ID LIKE CONCAT(CONCAT('%', #{pd.DeptId}),'%')
or f.JURISDICTION_UNIT LIKE CONCAT(CONCAT('%', #{pd.DeptId}),'%')
or f.PUNISH_THE_PERSON LIKE CONCAT(CONCAT('%', #{pd.UserId}),'%')
or f.CREATOR = #{pd.UserId}
)
</if>
ORDER BY
cc.co DESC,
f.OPERATTIME DESC
</select>
<select id="getDeptId" resultType="string">
SELECT
DEPARTMENT_ID
FROM
`qa-czks-prevention`.`sys_user`
WHERE
ISMAIN = '0' and
`USER_ID` =#{userId}
</select>
<!-- 列表(全部) -->
<select id="listAll" parameterType="pd" resultType="pd">
select
<include refid="Field"></include>
from
<include refid="tableName"></include> f
where f.ISDELETE = '0'
<if test="CORPINFO_ID != null and CORPINFO_ID != ''"><!-- 关键词检索 -->
and
(
f.INVOLVING_CORPS LIKE CONCAT(CONCAT('%', #{CORPINFO_ID}),'%')
or
f.MANAGE_NAME LIKE CONCAT(CONCAT('%', #{CORPINFO_ID}),'%')
)
</if>
</select>
<!-- 批量删除 -->
<delete id="deleteAll" parameterType="String">
update
<include refid="tableName"></include>
set
ISDELETE = '1'
where
OUTSOURCED_ID in
<foreach item="item" index="index" collection="ArrayDATA_IDS" open="(" separator="," close=")">
#{item}
</foreach>
</delete>
<!-- 修改 -->
<update id="jie" parameterType="pd">
update
<include refid="tableName"></include>
set
DEPARTMENT_ID = #{DEPARTMENT_ID},
CONTRACT_PIC = #{CONTRACT_PIC},
OUTSOURCED_NAME = #{OUTSOURCED_NAME},
INVOLVING_CORPS = #{INVOLVING_CORPS},
STARTTIME = #{STARTTIME},
ENDTIME = #{ENDTIME},
CONTRACT_STIME = #{CONTRACT_STIME},
CONTRACT_ETIME = #{CONTRACT_ETIME},
UNITS_ID = #{UNITS_ID},
CONTRACT_NUM = #{CONTRACT_NUM},
UNITS_APTITUDE = #{UNITS_APTITUDE},
UNITS_PIC = #{UNITS_PIC},
UNITS_PHONE = #{UNITS_PHONE},
MANAGE_NAME = #{MANAGE_NAME},
DESIGE = #{DESIGE},
MANAGE_APTITUDE = #{MANAGE_APTITUDE},
MANAGE_PIC = #{MANAGE_PIC},
MANAGE_PHONE = #{MANAGE_PHONE},
MEASURES = #{MEASURES},
ATTACHMENTS = #{ATTACHMENTS},
REMARKS = #{REMARKS},
TRAINING_NAME = #{TRAINING_NAME},
TRAINING_PIC = #{TRAINING_PIC},
TRAINING_STIME = #{TRAINING_STIME},
TRAINING_ETIME = #{TRAINING_ETIME},
RECORDS = #{RECORDS},
SHEET = #{SHEET},
EXAMINATION = #{EXAMINATION},
OATTACHMENTS = #{OATTACHMENTS},
APPLICANT = #{APPLICANT},
PUNISH_THE_PERSON = #{PUNISH_THE_PERSON},
STATE = '2',
OUTSOURCED_ID = OUTSOURCED_ID
where
OUTSOURCED_ID = #{OUTSOURCED_ID}
</update>
<select id="getPUNISHlistPage" parameterType="page" resultType="pd">
select
f.*,
(select GROUP_CONCAT(t.CORP_NAME) from `qa-czks-prevention`.BUS_CORP_INFO t where FIND_IN_SET(t.CORPINFO_ID, f.INVOLVING_CORPS)) as INVOLVING_CORPS_NAME,
(select GROUP_CONCAT(t.CORP_NAME) from `qa-czks-prevention`.BUS_CORP_INFO t where FIND_IN_SET(t.CORPINFO_ID, f.MANAGE_NAME)) as MANAGE_CORPS_NAME,
( SELECT GROUP_CONCAT( t.NAME ) FROM `qa-czks-prevention`.oa_department t WHERE FIND_IN_SET( t.DEPARTMENT_ID, f.INVOLVING_CORPS_DEPART_ID ) ) AS INVOLVING_CORPS_DEPART_NAME,
( SELECT GROUP_CONCAT( t.NAME ) FROM `qa-czks-prevention`.vi_department_all t WHERE FIND_IN_SET( t.DEPARTMENT_ID, f.DEPARTMENT_ID ) ) AS DEPARTMENT_NAME,
(select GROUP_CONCAT(t.NAME) from (
SELECT
CONCAT( CONCAT( c.CORP_NAME, '-' ), t.NAME ) NAME ,t.DEPARTMENT_ID
FROM
`qa-czks-prevention`.OA_DEPARTMENT t
LEFT JOIN `qa-czks-prevention`.bus_corp_info c ON c.CORPINFO_ID = t.CORPINFO_ID
) t where FIND_IN_SET(t.DEPARTMENT_ID, f.JURISDICTION_UNIT)) as JURISDICTION_UNIT_NAME,
isdd.NAME MANAGER_DEPARTMENT_NAME,
isu.NAME USER_NAME,
b.UNITS_NAME as UNITS_NAME,
isu.NAME as AIWARNING_PEOPLE,
pci.NAME Q_COMPETENT_DEPT_NAME,
(select count(1) from `qa-czks-regulatory`.BUS_AIWARNING a left join bus_videomanager avid on avid.VIDEOMANAGER_ID = a.VIDEOMANAGER_ID where avid.OUTSOURCED_ID= f.OUTSOURCED_ID and a.ISDELETE = '0') as AI_COUNT,
(SELECT count( 1 ) FROM `qa-czks-prevention`.BUS_KEYPROJECTPUNISH k left join `qa-czks-prevention`.bus_keyprojectcheck kjc on kjc.KEYPROJECTCHECK_ID = k.KEYPROJECTCHECK_ID WHERE kjc.OUTSOURCED_ID =f.OUTSOURCED_ID AND k.ISDELETE = '0' ) as KEY_COUNT,
vua.NAME OUTSOURCED_CREATOR_NAME,
ifnull(vac.CORP_NAME,'秦港股份有限公司') CORP_NAME,
p.`NAME` as UNITS_PIC_NAME
,ifnull(cfsl.co,0) as cfcount
from
<include refid="tableName"></include> f
left join bus_units b using (UNITS_ID)
LEFT JOIN `qa-czks-regulatory`.SYS_DEPARTMENT isdd ON isdd.DEPARTMENT_ID = f.MANAGER_DEPARTMENT_ID
LEFT JOIN `qa-czks-regulatory`.SYS_USER isu ON isu.USER_ID = f.CONTRACT_PIC
LEFT JOIN `qa-czks-prevention`.oa_department pcij ON pcij.DEPARTMENT_ID = f.DEPARTMENT_ID
LEFT JOIN `qa-czks-prevention`.oa_department pci ON pci.DEPARTMENT_ID = f.COMPETENT_DEPT_ID
LEFT JOIN `qa-czks-prevention`.vi_user_all vua on f.CREATOR = vua.USER_ID
LEFT JOIN `qa-czks-regulatory`.vi_all_corp vac on vua.CORPINFO_ID = vac.CORPINFO_ID
left join `qa-czks-regulatory`.bus_personnelmanagement p on p.PERSONNELMANAGEMENT_ID = f.UNITS_PIC
left join (SELECT PUN.OUTSOURCED_ID,COUNT( distinct PUN.HIDDEN_ID) co FROM (
SELECT
f.HIDDEN_ID,ifnull(bo.OUTSOURCED_ID,boai.OUTSOURCED_ID) OUTSOURCED_ID
FROM
`qa-czks-prevention`.BUS_KEYPROJECT_HIDDEN f
LEFT JOIN `qa-czks-prevention`.bus_keyprojectcheck keycheck ON keycheck.KEYPROJECTCHECK_ID = f.FOREIGN_ID
LEFT JOIN `qa-czks-regulatory`.BUS_OUTSOURCED bo ON keycheck.OUTSOURCED_ID = bo.OUTSOURCED_ID
LEFT JOIN `qa-czks-regulatory`.BUS_OUTSOURCED boai ON f.FOREIGN_ID = boai.OUTSOURCED_ID
WHERE
f.ISDELETE = '0'
AND f.SOURCE IN ( '4', '5', '1' )
AND ifnull(bo.OUTSOURCED_ID,boai.OUTSOURCED_ID) IS NOT NULL
and f.ISPUNISH is null
) PUN GROUP BY PUN.OUTSOURCED_ID ) cfsl on cfsl.OUTSOURCED_ID = f.OUTSOURCED_ID
where f.ISDELETE = '0'
<if test="pd.KEYWORDS != null and pd.KEYWORDS != ''"><!-- 关键词检索 -->
and
(
<!-- 根据需求自己加检索条件-->
f.OUTSOURCED_NAME LIKE CONCAT(CONCAT('%', #{pd.KEYWORDS}),'%')
or
b.UNITS_NAME LIKE CONCAT(CONCAT('%', #{pd.KEYWORDS}),'%')
or
f.UNITS_PIC LIKE CONCAT(CONCAT('%', #{pd.KEYWORDS}),'%')
or
pcij.NAME LIKE CONCAT(CONCAT('%', #{pd.KEYWORDS}),'%')
)
</if>
and f.PUNISH_THE_PERSON LIKE CONCAT( CONCAT( '%', #{pd.PUNISHUser} ), '%' )
AND f.STATE = '1'
ORDER BY
cfsl.co DESC,
f.OPERATTIME DESC
</select>
<select id="jieshuOutSourced" parameterType="pd" resultType="pd">
SELECT
o.OUTSOURCED_ID,
IFNULL( QR.qr, 0 ) qr,
IFNULL( ZG.zg, 0 ) zg,
IFNULL( YS.ys, 0 ) ys,
IFNULL( CF.cf, 0 ) cf,
IFNULL( FK.fk, 0 ) fk,
IFNULL( AI.ai, 0 ) ai
FROM
`qa-czks-regulatory`.bus_outsourced o
<!-- 检查待确认 -->
LEFT JOIN (
SELECT
COUNT( 1 ) qr,
c.OUTSOURCED_ID
FROM
`qa-czks-prevention`.bus_keyprojectcheck c
WHERE
c.INSPECTION_STATUS = 0
AND c.ISDELETE = 0
GROUP BY
c.OUTSOURCED_ID
) QR ON QR.OUTSOURCED_ID = o.OUTSOURCED_ID
<!-- 隐患待整改 -->
LEFT JOIN (
SELECT
COUNT( f.OUTSOURCED_ID ) zg,
f.OUTSOURCED_ID
FROM
(
SELECT
h.HIDDEN_ID,
IFNULL( c.OUTSOURCED_ID, h.FOREIGN_ID ) OUTSOURCED_ID
FROM
`qa-czks-prevention`.bus_keyproject_hidden h
LEFT JOIN `qa-czks-prevention`.bus_keyprojectcheck c ON h.FOREIGN_ID = c.KEYPROJECTCHECK_ID
WHERE
h.STATE = 1
AND h.ISDELETE = 0
) f
GROUP BY
f.OUTSOURCED_ID
) ZG ON ZG.OUTSOURCED_ID = o.OUTSOURCED_ID
<!-- 隐患待验收 -->
LEFT JOIN (
SELECT
COUNT( DISTINCT t.OUTSOURCED_ID ) ys,
t.OUTSOURCED_ID
FROM
(
SELECT
f.HIDDEN_ID,
IFNULL( c.OUTSOURCED_ID, f.FOREIGN_ID ) OUTSOURCED_ID
FROM
`qa-czks-prevention`.BUS_KEYPROJECT_HIDDEN f
LEFT JOIN `qa-czks-prevention`.bus_keyprojectcheck c ON c.KEYPROJECTCHECK_ID = f.FOREIGN_ID
WHERE
f.ISDELETE = '0'
AND f.SOURCE IN ( '4', '5', '1' )
AND f.STATE = '2'
) t
GROUP BY
t.OUTSOURCED_ID
) YS ON YS.OUTSOURCED_ID = o.OUTSOURCED_ID
<!-- 隐患待处罚 -->
LEFT JOIN (
SELECT
COUNT( DISTINCT t.OUTSOURCED_ID ) cf,
t.OUTSOURCED_ID
FROM
(
SELECT
f.HIDDEN_ID,
IFNULL( c.OUTSOURCED_ID, f.FOREIGN_ID ) OUTSOURCED_ID
FROM
`qa-czks-prevention`.BUS_KEYPROJECT_HIDDEN f
LEFT JOIN `qa-czks-prevention`.bus_keyprojectcheck c ON c.KEYPROJECTCHECK_ID = f.FOREIGN_ID
WHERE
f.ISDELETE = '0'
AND f.SOURCE IN ( '4', '5', '1' )
AND (f.ISPUNISH is NULL OR f.ISPUNISH = '')
) t
GROUP BY
t.OUTSOURCED_ID
) CF on CF.OUTSOURCED_ID = o.OUTSOURCED_ID
<!-- 处罚待反馈 -->
LEFT JOIN (
SELECT
COUNT( DISTINCT t.OUTSOURCED_ID ) fk,
t.OUTSOURCED_ID
FROM
(
SELECT
p.HIDDEN_ID,
IFNULL( c.OUTSOURCED_ID, f.FOREIGN_ID ) OUTSOURCED_ID
FROM
`qa-czks-prevention`.bus_keyprojectpunish p
LEFT JOIN `qa-czks-prevention`.BUS_KEYPROJECT_HIDDEN f on p.HIDDEN_ID = f.HIDDEN_ID
LEFT JOIN `qa-czks-prevention`.bus_keyprojectcheck c ON c.KEYPROJECTCHECK_ID = f.FOREIGN_ID
WHERE
p.ISDELETE = '0'
AND p.HANDLED = '0'
) t
GROUP BY
t.OUTSOURCED_ID
) FK ON FK.OUTSOURCED_ID = o.OUTSOURCED_ID
<!-- ai报警待处置 -->
LEFT JOIN (
SELECT
count( 1 ) AS ai ,t.OUTSOURCED_ID
FROM
`qa-czks-regulatory`.bus_aiwarning f
LEFT JOIN (
SELECT DISTINCT
vi.VIDEOMANAGER_ID,
aip.OUTSOURCED_ID
FROM
`qa-czks-regulatory`.bus_aiwarning_people aip
LEFT JOIN `qa-czks-regulatory`.bus_videomanager vi ON vi.OUTSOURCED_ID = aip.OUTSOURCED_ID
WHERE
aip.ISDELETE = 0
AND vi.VIDEOMANAGER_ID IS NOT NULL
) t ON t.VIDEOMANAGER_ID = f.VIDEOMANAGER_ID
WHERE
f.ISDELETE = 0
AND f.STATUS = 0
GROUP BY t.OUTSOURCED_ID
) AI ON AI.OUTSOURCED_ID = o.OUTSOURCED_ID
WHERE o.OUTSOURCED_ID=#{OUTSOURCED_ID}
</select>
<update id="updateState" parameterType="pd">
update
<include refid="tableName"></include>
set
STATE = #{STATE},
OPERATOR = #{OPERATOR},
OPERATTIME = #{OPERATTIME}
where
OUTSOURCED_ID = #{OUTSOURCED_ID}
</update>
<!-- 列表 -->
<select id="hiddenOutsourcedlistPage" parameterType="page" resultType="pd">
select
f.*,
(select GROUP_CONCAT(t.CORP_NAME) from `qa-czks-prevention`.BUS_CORP_INFO t where FIND_IN_SET(t.CORPINFO_ID, f.INVOLVING_CORPS)) as INVOLVING_CORPS_NAME,
(select GROUP_CONCAT(t.CORP_NAME) from `qa-czks-prevention`.BUS_CORP_INFO t where FIND_IN_SET(t.CORPINFO_ID, f.MANAGE_NAME)) as MANAGE_CORPS_NAME,
( SELECT GROUP_CONCAT( t.NAME ) FROM `qa-czks-prevention`.oa_department t WHERE FIND_IN_SET( t.DEPARTMENT_ID, f.INVOLVING_CORPS_DEPART_ID ) ) AS INVOLVING_CORPS_DEPART_NAME,
(select GROUP_CONCAT(t.CORP_NAME) from `qa-czks-prevention`.BUS_CORP_INFO t where FIND_IN_SET(t.CORPINFO_ID, f.GROUP_UNIT)) as GROUP_UNIT_NAME,
( SELECT GROUP_CONCAT( t.NAME ) FROM `qa-czks-prevention`.vi_department_all t WHERE FIND_IN_SET( t.DEPARTMENT_ID, f.DEPARTMENT_ID ) ) AS DEPARTMENT_NAME,
(select GROUP_CONCAT(t.NAME) from (
SELECT
CONCAT( CONCAT( c.CORP_NAME, '-' ), t.NAME ) NAME ,t.DEPARTMENT_ID
FROM
`qa-czks-prevention`.OA_DEPARTMENT t
LEFT JOIN `qa-czks-prevention`.bus_corp_info c ON c.CORPINFO_ID = t.CORPINFO_ID
) t where FIND_IN_SET(t.DEPARTMENT_ID, f.JURISDICTION_UNIT)) as JURISDICTION_UNIT_NAME,
isdd.NAME MANAGER_DEPARTMENT_NAME,
isu.NAME USER_NAME,
b.UNITS_NAME as UNITS_NAME,
isu.NAME as AIWARNING_PEOPLE,
pci.NAME Q_COMPETENT_DEPT_NAME,
(select count(1) from `qa-czks-prevention`.BUS_KEYPROJECTCHECK c where c.OUTSOURCED_ID = f.OUTSOURCED_ID) as CHECK_COUNT,
(select count(1) from `qa-czks-regulatory`.BUS_AIWARNING a left join bus_videomanager avid on avid.VIDEOMANAGER_ID = a.VIDEOMANAGER_ID where avid.OUTSOURCED_ID= f.OUTSOURCED_ID and a.ISDELETE = '0') as AI_COUNT,
(select count(1) from `qa-czks-regulatory`.BUS_VIDEOMANAGER v where v.OUTSOURCED_ID = f.OUTSOURCED_ID and v.ISDELETE = '0') as VIDEO_COUNT,
(SELECT count( 1 ) FROM `qa-czks-prevention`.BUS_KEYPROJECTPUNISH k left join `qa-czks-prevention`.bus_keyprojectcheck kjc on kjc.KEYPROJECTCHECK_ID = k.KEYPROJECTCHECK_ID WHERE kjc.OUTSOURCED_ID =f.OUTSOURCED_ID AND k.ISDELETE = '0' ) as KEY_COUNT,
vua.NAME OUTSOURCED_CREATOR_NAME,
ifnull(vac.CORP_NAME,'秦港股份有限公司') CORP_NAME,
p.`NAME` as UNITS_PIC_NAME
,ifnull(dbsl.co,0) as co
from
<include refid="tableName"></include> f
left join bus_units b using (UNITS_ID)
LEFT JOIN `qa-czks-regulatory`.SYS_DEPARTMENT isdd ON isdd.DEPARTMENT_ID = f.MANAGER_DEPARTMENT_ID
LEFT JOIN `qa-czks-regulatory`.SYS_USER isu ON isu.USER_ID = f.CONTRACT_PIC
LEFT JOIN `qa-czks-prevention`.oa_department pcij ON pcij.DEPARTMENT_ID = f.DEPARTMENT_ID
LEFT JOIN `qa-czks-prevention`.oa_department pci ON pci.DEPARTMENT_ID = f.COMPETENT_DEPT_ID
LEFT JOIN `qa-czks-prevention`.vi_user_all vua on f.CREATOR = vua.USER_ID
LEFT JOIN `qa-czks-regulatory`.vi_all_corp vac on vua.CORPINFO_ID = vac.CORPINFO_ID
left join `qa-czks-regulatory`.bus_personnelmanagement p on p.PERSONNELMANAGEMENT_ID = f.UNITS_PIC
left join (SELECT t.OUTSOURCED_ID,COUNT( distinct t.HIDDEN_ID) co FROM (
SELECT
f.HIDDEN_ID,ifnull(bo.OUTSOURCED_ID,boai.OUTSOURCED_ID) OUTSOURCED_ID
FROM
`qa-czks-prevention`.BUS_KEYPROJECT_HIDDEN f
LEFT JOIN `qa-czks-prevention`.bus_keyprojectcheck keycheck ON keycheck.KEYPROJECTCHECK_ID = f.FOREIGN_ID
LEFT JOIN `qa-czks-regulatory`.BUS_OUTSOURCED bo ON keycheck.OUTSOURCED_ID = bo.OUTSOURCED_ID
LEFT JOIN `qa-czks-regulatory`.BUS_OUTSOURCED boai ON f.FOREIGN_ID = boai.OUTSOURCED_ID
LEFT JOIN `qa-czks-prevention`.BUS_KEYPROJECTPUNISH pu ON pu.HIDDEN_ID = f.HIDDEN_ID
WHERE
f.ISDELETE = '0'
AND f.SOURCE IN ( '4', '5', '1' )
AND f.STATE = '2'
AND f.CREATOR = #{pd.UserId}
AND ifnull(bo.OUTSOURCED_ID,boai.OUTSOURCED_ID) IS NOT NULL
) t GROUP BY t.OUTSOURCED_ID ) dbsl on dbsl.OUTSOURCED_ID = f.OUTSOURCED_ID
where f.ISDELETE = '0'
<if test="pd.CORPINFO_ID != null and pd.CORPINFO_ID != ''"><!-- 关键词检索 -->
and
(
f.INVOLVING_CORPS LIKE CONCAT(CONCAT('%', #{pd.CORPINFO_ID}),'%')
or
f.GROUP_UNIT LIKE CONCAT(CONCAT('%', #{pd.CORPINFO_ID}),'%')
)
</if>
<if test="pd.KEYWORDS != null and pd.KEYWORDS != ''"><!-- 关键词检索 -->
and
(
<!-- 根据需求自己加检索条件-->
f.OUTSOURCED_NAME LIKE CONCAT(CONCAT('%', #{pd.KEYWORDS}),'%')
or
b.UNITS_NAME LIKE CONCAT(CONCAT('%', #{pd.KEYWORDS}),'%')
or
f.UNITS_PIC LIKE CONCAT(CONCAT('%', #{pd.KEYWORDS}),'%')
or
pcij.NAME LIKE CONCAT(CONCAT('%', #{pd.KEYWORDS}),'%')
)
</if>
<if test="pd.OUTSOURCED_NAME != null and pd.OUTSOURCED_NAME !=''">
and f.OUTSOURCED_NAME = #{pd.OUTSOURCED_NAME}
</if>
<if test="pd.UNITS_ID != null and pd.UNITS_ID !=''">
and f.UNITS_ID = #{pd.UNITS_ID}
</if>
<if test="pd.INVOLVING_CORP != null and pd.INVOLVING_CORP !=''">
and f.INVOLVING_CORPS LIKE CONCAT(CONCAT('%', #{pd.INVOLVING_CORP}),'%')
</if>
<if test="pd.DEPARTMENT_ID != null and pd.DEPARTMENT_ID !=''">
and f.DEPARTMENT_ID LIKE CONCAT(CONCAT('%', #{pd.DEPARTMENT_ID}),'%')
</if>
<if test="pd.COMPETENT_DEPT_ID != null and pd.COMPETENT_DEPT_ID !=''">
and f.COMPETENT_DEPT_ID LIKE CONCAT(CONCAT('%', #{pd.COMPETENT_DEPT_ID}),'%')
</if>
<if test="pd.GROUP_UNIT != null and pd.GROUP_UNIT !=''">
and f.GROUP_UNIT LIKE CONCAT(CONCAT('%', #{pd.GROUP_UNIT}),'%')
</if>
<if test="pd.CORP_NAME != null and pd.CORP_NAME !=''">
and vac.CORP_NAME LIKE CONCAT(CONCAT('%', #{pd.CORP_NAME}),'%')
</if>
<if test="pd.STATE != null and pd.STATE !=''">
and f.STATE = #{pd.STATE}
</if>
<if test="pd.CONTRACT_STIME != null and pd.CONTRACT_STIME !=''">
and (f.CONTRACT_STIME between #{pd.CONTRACT_STIME} and #{pd.CONTRACT_ETIME}
or f.CONTRACT_ETIME between #{pd.CONTRACT_STIME} and #{pd.CONTRACT_ETIME}
or (f.CONTRACT_STIME &lt; #{pd.CONTRACT_STIME} and f.CONTRACT_ETIME &gt; #{pd.CONTRACT_ETIME}))
</if>
<if test="pd.DeptId != null and pd.DeptId !=''">
and ( f.DEPARTMENT_ID LIKE CONCAT(CONCAT('%', #{pd.DeptId}),'%')
or f.COMPETENT_DEPT_ID LIKE CONCAT(CONCAT('%', #{pd.DeptId}),'%')
or f.INVOLVING_CORPS LIKE CONCAT(CONCAT('%', #{pd.DeptId}),'%')
or f.INVOLVING_CORPS_DEPART_ID LIKE CONCAT(CONCAT('%', #{pd.DeptId}),'%')
or f.JURISDICTION_UNIT LIKE CONCAT(CONCAT('%', #{pd.DeptId}),'%')
or f.PUNISH_THE_PERSON LIKE CONCAT(CONCAT('%', #{pd.UserId}),'%')
or f.CREATOR = #{pd.UserId}
)
</if>
ORDER BY
dbsl.co DESC,
f.OPERATTIME DESC
</select>
<!-- 列表 -->
<select id="outSouceslistPage" parameterType="page" resultType="pd">
select
f.*,
(select GROUP_CONCAT(t.CORP_NAME) from `qa-czks-prevention`.BUS_CORP_INFO t where FIND_IN_SET(t.CORPINFO_ID, f.INVOLVING_CORPS)) as INVOLVING_CORPS_NAME,
(select GROUP_CONCAT(t.CORP_NAME) from `qa-czks-prevention`.BUS_CORP_INFO t where FIND_IN_SET(t.CORPINFO_ID, f.MANAGE_NAME)) as MANAGE_CORPS_NAME,
( SELECT GROUP_CONCAT( t.NAME ) FROM `qa-czks-prevention`.oa_department t WHERE FIND_IN_SET( t.DEPARTMENT_ID, f.INVOLVING_CORPS_DEPART_ID ) ) AS INVOLVING_CORPS_DEPART_NAME,
(select GROUP_CONCAT(t.CORP_NAME) from `qa-czks-prevention`.BUS_CORP_INFO t where FIND_IN_SET(t.CORPINFO_ID, f.GROUP_UNIT)) as GROUP_UNIT_NAME,
( SELECT GROUP_CONCAT( t.NAME ) FROM `qa-czks-prevention`.vi_department_all t WHERE FIND_IN_SET( t.DEPARTMENT_ID, f.DEPARTMENT_ID ) ) AS DEPARTMENT_NAME,
(select GROUP_CONCAT(t.NAME) from (
SELECT
CONCAT( CONCAT( c.CORP_NAME, '-' ), t.NAME ) NAME ,t.DEPARTMENT_ID
FROM
`qa-czks-prevention`.OA_DEPARTMENT t
LEFT JOIN `qa-czks-prevention`.bus_corp_info c ON c.CORPINFO_ID = t.CORPINFO_ID
) t where FIND_IN_SET(t.DEPARTMENT_ID, f.JURISDICTION_UNIT)) as JURISDICTION_UNIT_NAME,
isdd.NAME MANAGER_DEPARTMENT_NAME,
isu.NAME USER_NAME,
b.UNITS_NAME as UNITS_NAME,
isu.NAME as AIWARNING_PEOPLE,
pci.NAME Q_COMPETENT_DEPT_NAME,
(select count(1) from `qa-czks-regulatory`.BUS_AIWARNING a left join bus_videomanager avid on avid.VIDEOMANAGER_ID = a.VIDEOMANAGER_ID where avid.OUTSOURCED_ID= f.OUTSOURCED_ID and a.ISDELETE = '0') as AI_COUNT,
(select count(1) from `qa-czks-regulatory`.BUS_VIDEOMANAGER v where v.OUTSOURCED_ID = f.OUTSOURCED_ID and v.ISDELETE = '0') as VIDEO_COUNT,
(SELECT count( 1 ) FROM `qa-czks-prevention`.BUS_KEYPROJECTPUNISH k left join `qa-czks-prevention`.bus_keyprojectcheck kjc on kjc.KEYPROJECTCHECK_ID = k.KEYPROJECTCHECK_ID WHERE kjc.OUTSOURCED_ID =f.OUTSOURCED_ID AND k.ISDELETE = '0' ) as KEY_COUNT,
vua.NAME OUTSOURCED_CREATOR_NAME,
ifnull(vac.CORP_NAME,'秦港股份有限公司') CORP_NAME,
p.`NAME` as UNITS_PIC_NAME
from
<include refid="tableName"></include> f
left join bus_units b using (UNITS_ID)
LEFT JOIN `qa-czks-regulatory`.SYS_DEPARTMENT isdd ON isdd.DEPARTMENT_ID = f.MANAGER_DEPARTMENT_ID
LEFT JOIN `qa-czks-regulatory`.SYS_USER isu ON isu.USER_ID = f.CONTRACT_PIC
LEFT JOIN `qa-czks-prevention`.oa_department pcij ON pcij.DEPARTMENT_ID = f.DEPARTMENT_ID
LEFT JOIN `qa-czks-prevention`.oa_department pci ON pci.DEPARTMENT_ID = f.COMPETENT_DEPT_ID
LEFT JOIN `qa-czks-prevention`.vi_user_all vua on f.CREATOR = vua.USER_ID
LEFT JOIN `qa-czks-regulatory`.vi_all_corp vac on vua.CORPINFO_ID = vac.CORPINFO_ID
left join `qa-czks-regulatory`.bus_personnelmanagement p on p.PERSONNELMANAGEMENT_ID = f.UNITS_PIC
where f.ISDELETE = '0'
<if test="pd.CORPINFO_ID != null and pd.CORPINFO_ID != ''"><!-- 关键词检索 -->
and
(
f.INVOLVING_CORPS LIKE CONCAT(CONCAT('%', #{pd.CORPINFO_ID}),'%')
or
f.GROUP_UNIT LIKE CONCAT(CONCAT('%', #{pd.CORPINFO_ID}),'%')
)
</if>
<if test="pd.KEYWORDS != null and pd.KEYWORDS != ''"><!-- 关键词检索 -->
and
(
<!-- 根据需求自己加检索条件-->
f.OUTSOURCED_NAME LIKE CONCAT(CONCAT('%', #{pd.KEYWORDS}),'%')
or
b.UNITS_NAME LIKE CONCAT(CONCAT('%', #{pd.KEYWORDS}),'%')
or
f.UNITS_PIC LIKE CONCAT(CONCAT('%', #{pd.KEYWORDS}),'%')
or
pcij.NAME LIKE CONCAT(CONCAT('%', #{pd.KEYWORDS}),'%')
)
</if>
<if test="pd.OUTSOURCED_NAME != null and pd.OUTSOURCED_NAME !=''">
and f.OUTSOURCED_NAME = #{pd.OUTSOURCED_NAME}
</if>
<if test="pd.UNITS_ID != null and pd.UNITS_ID !=''">
and f.UNITS_ID = #{pd.UNITS_ID}
</if>
<if test="pd.INVOLVING_CORP != null and pd.INVOLVING_CORP !=''">
and f.INVOLVING_CORPS LIKE CONCAT(CONCAT('%', #{pd.INVOLVING_CORP}),'%')
</if>
<if test="pd.DEPARTMENT_ID != null and pd.DEPARTMENT_ID !=''">
and f.DEPARTMENT_ID LIKE CONCAT(CONCAT('%', #{pd.DEPARTMENT_ID}),'%')
</if>
<if test="pd.COMPETENT_DEPT_ID != null and pd.COMPETENT_DEPT_ID !=''">
and f.COMPETENT_DEPT_ID LIKE CONCAT(CONCAT('%', #{pd.COMPETENT_DEPT_ID}),'%')
</if>
<if test="pd.GROUP_UNIT != null and pd.GROUP_UNIT !=''">
and f.GROUP_UNIT LIKE CONCAT(CONCAT('%', #{pd.GROUP_UNIT}),'%')
</if>
<if test="pd.CORP_NAME != null and pd.CORP_NAME !=''">
and vac.CORP_NAME LIKE CONCAT(CONCAT('%', #{pd.CORP_NAME}),'%')
</if>
<if test="pd.STATE != null and pd.STATE !=''">
and f.STATE = #{pd.STATE}
</if>
<if test="pd.CONTRACT_STIME != null and pd.CONTRACT_STIME !=''">
and (f.CONTRACT_STIME between #{pd.CONTRACT_STIME} and #{pd.CONTRACT_ETIME}
or f.CONTRACT_ETIME between #{pd.CONTRACT_STIME} and #{pd.CONTRACT_ETIME}
or (f.CONTRACT_STIME &lt; #{pd.CONTRACT_STIME} and f.CONTRACT_ETIME &gt; #{pd.CONTRACT_ETIME}))
</if>
<if test="pd.DeptId != null and pd.DeptId !=''">
and ( f.DEPARTMENT_ID LIKE CONCAT(CONCAT('%', #{pd.DeptId}),'%')
or f.COMPETENT_DEPT_ID LIKE CONCAT(CONCAT('%', #{pd.DeptId}),'%')
or f.INVOLVING_CORPS LIKE CONCAT(CONCAT('%', #{pd.DeptId}),'%')
or f.INVOLVING_CORPS_DEPART_ID LIKE CONCAT(CONCAT('%', #{pd.DeptId}),'%')
or f.JURISDICTION_UNIT LIKE CONCAT(CONCAT('%', #{pd.DeptId}),'%')
or f.PUNISH_THE_PERSON LIKE CONCAT(CONCAT('%', #{pd.UserId}),'%')
or f.CREATOR = #{pd.UserId}
)
</if>
ORDER BY
f.STATE,
f.OPERATTIME DESC
</select>
</mapper>