You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

407 lines
17 KiB

5 years ago
<?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.ccsens.mt.persist.dao.CompeteProjectConfigDao">
<resultMap id="BaseResultMap" type="com.ccsens.mt.bean.po.CompeteProjectConfig">
<id column="id" jdbcType="BIGINT" property="id" />
<result column="project_id" jdbcType="BIGINT" property="projectId" />
<result column="site_num" jdbcType="INTEGER" property="siteNum" />
<result column="start_time" jdbcType="BIGINT" property="startTime" />
<result column="end_time" jdbcType="BIGINT" property="endTime" />
<result column="created_at" jdbcType="TIMESTAMP" property="createdAt" />
<result column="updated_at" jdbcType="TIMESTAMP" property="updatedAt" />
<result column="rec_status" jdbcType="TINYINT" property="recStatus" />
<result column="project_duration" jdbcType="BIGINT" property="projectDuration" />
</resultMap>
5 years ago
<resultMap id="startOrderByCompany" type="com.ccsens.mt.bean.vo.ProvinceCompeteVo$StartOrderByCompanyAndProject">
<id column="projectId" property="projectId" />
<result column="projectName" property="projectName" />
<result column="startTime" property="startTime" />
<collection property="startOrderList" ofType="com.ccsens.mt.bean.vo.ProvinceCompeteVo$StartOrder">
<id column="startOrderId" property="startOrderId" />
<result column="competeOrder" property="competeOrder" />
<result column="site" property="site" />
<result column="team" property="team" />
<result column="groupName" property="groupName" />
<result column="videoUrl" property="videoUrl" />
5 years ago
<result column="playerOrTeamId" property="playerOrTeamId" />
5 years ago
<collection property="playerNameList" ofType="String">
<result column="playerName"/>
</collection>
</collection>
</resultMap>
5 years ago
<resultMap id="qwe" type="com.ccsens.mt.bean.vo.TableVo$SchedulePlan">
<id column="startDate" property="date" />
<collection property="schedulePlanDetailListMorning" ofType="com.ccsens.mt.bean.vo.TableVo$SchedulePlanDetail">
<id column="projectName" property="projectName" />
<result column="start_time" property="startTime" />
<result column="endTime" property="endTime" />
</collection>
<collection property="schedulePlanDetailListAfternoon" ofType="com.ccsens.mt.bean.vo.TableVo$SchedulePlanDetail">
<id column="projectNameP" property="projectName" />
<result column="start_timeP" property="startTime" />
<result column="endTimeP" property="endTime" />
</collection>
</resultMap>
5 years ago
<select id="selectByProjectId" resultMap="BaseResultMap" parameterType="java.util.Map">
select * from t_compete_project_config
5 years ago
where project_id = #{projectId}
and rec_status = 0
5 years ago
</select>
5 years ago
<select id="selectDetail" resultMap="qwe" parameterType="java.util.Map">
SELECT
FROM_UNIXTIME(start_time/1000,'%y-%m-%d') as startDate,
if(a.aa = 1,p.`name`,null) as projectName,
if(a.aa = 0,p.`name`,null) as projectNamep,
if(a.aa = 1,c.start_time,null) as start_time,
if(a.aa = 0,c.start_time,null) as start_timeP,
if(a.aa = 1,c.end_time,null) as endTime,
if(a.aa = 0,c.end_time,null) as endTimeP
FROM
`t_compete_project_config` c
LEFT JOIN t_compete_project p on c.project_id = p.id
LEFT JOIN (
SELECT
id,
5 years ago
if(FROM_UNIXTIME(start_time/1000,'%h') &lt;= 12,1 ,0) as aa
5 years ago
FROM
t_compete_project_config
)a on c.id = a.id
where c.project_id = p.id
ORDER BY c.start_time
5 years ago
</select>
5 years ago
<select id="selectStartTime" resultType="com.ccsens.mt.bean.po.CompeteProjectConfig" parameterType="java.util.Map">
5 years ago
SELECT
project_id
5 years ago
FROM t_compete_project_config
where project_id = #{projectId}
</select>
5 years ago
<select id="selectPeople" resultType="com.ccsens.mt.bean.vo.TableVo$CompeteJoin" parameterType="java.util.Map">
SELECT
tcpro.id as projectId,
tcpro.name as competeProject,
tcg.group_name as competeGroup,
tcc.`name` as joinTeam,
tcp.`name` as name,
tcp.gender as gender,
tcp.id_card as idCard,
(SELECT visit_location from t_common_file where tcp.id_card_front_file = id ) as idCardPromiseFront,
(SELECT visit_location from t_common_file where tcp.id_card_back_file = id ) as idCardPromiseBack,
(SELECT visit_location from t_common_file where tcp.id_photo_file = id ) as picture,
(SELECT visit_location from t_common_file where tcp.student_record_file = id ) as studentPromise,
(SELECT visit_location from t_common_file where tcp.health_record_file = id ) as bodyTest,
(SELECT visit_location from t_common_file where tcp.insurance_record_file = id ) as bodyProtect
from
t_compete_project tcpro LEFT JOIN t_compete_team tct on tcpro.id = tct.project_id
LEFT JOIN t_compete_team_member tctm on tct.id = tctm.compete_team_id
LEFT JOIN t_compete_player tcp on tcp.id = tctm.player_id
LEFT JOIN t_compete_company tcc on tcc.id = tcp.company_id
LEFT JOIN t_compete_group tcg on tcg.id = tcp.compete_group_id
WHERE
<trim prefix="(" prefixOverrides="and" suffix=")">
<if test="projectId != null">
tcpro.id = #{projectId}
</if>
<if test="groupId != null">
and tcg.id = #{groupId}
</if>
<if test="companyId != null">
and tcc.id = #{companyId}
</if>
<if test="name != null and name != ''">
and tcp.name like concat('%',#{name, jdbcType=VARCHAR},'%')
</if>
<if test="idCard != null and idCard != ''">
and tcp.id_card = #{idCard}
</if>
and tcpro.type=0
and tcpro.`level` =2
and tcpro.team=1
and tcpro.rec_status = 0
and tctm.rec_status = 0
and tcp.rec_status = 0
and tcc.rec_status = 0
and tcg.rec_status = 0
and tct.rec_status = 0
</trim>
UNION
SELECT
tcpro.id as projectId,
tcpro.name as competeProject,
tcg.group_name as competeGroup,
tcc.`name` as joinTeam,
tcp.`name` as name,
tcp.gender as gender,
tcp.id_card as idCard,
(SELECT visit_location from t_common_file where tcp.id_card_front_file = id ) as idCardPromiseFront,
(SELECT visit_location from t_common_file where tcp.id_card_back_file = id ) as idCardPromiseBack,
(SELECT visit_location from t_common_file where tcp.id_photo_file = id ) as picture,
(SELECT visit_location from t_common_file where tcp.student_record_file = id ) as studentPromise,
(SELECT visit_location from t_common_file where tcp.health_record_file = id ) as bodyTest,
(SELECT visit_location from t_common_file where tcp.insurance_record_file = id ) as bodyProtect
from
t_compete_project tcpro LEFT JOIN t_compete_project_player tcpp on tcpro.id = tcpp.project_id
LEFT JOIN t_compete_player tcp on tcpp.player_id = tcp.id
LEFT JOIN t_compete_group tcg on tcg.id = tcp.compete_group_id
LEFT JOIN t_compete_company tcc on tcc.id = tcp.company_id
where
<trim prefix="(" prefixOverrides="and" suffix=")">
<if test="projectId != null">
tcpro.id = #{projectId}
</if>
<if test="groupId != null">
and tcg.id = #{groupId}
</if>
<if test="companyId != null">
and tcc.id = #{companyId}
</if>
<if test="name != null and name != ''">
and tcp.name like concat('%',#{name, jdbcType=VARCHAR},'%')
</if>
<if test="idCard != null and idCard != ''">
and tcp.id_card = #{idCard}
</if>
and tcpro.type=0
and tcpro.`level` =2
and tcpro.team=0
and tcp.rec_status = 0
and tcc.rec_status = 0
and tcpp.rec_status = 0
and tcpro.rec_status = 0
</trim>
</select>
5 years ago
<select id="selectSingle" resultType="com.ccsens.mt.bean.vo.TableVo$CompeteJoin" parameterType="java.util.Map">
5 years ago
SELECT
tcpro.id as projectId,
tcpro.name as competeProject,
tcg.group_name as competeGroup,
tcc.`name` as joinTeam,
tcp.`name` as name,
tcp.gender as gender,
tcp.id_card as idCard,
(SELECT visit_location from t_common_file where tcp.id_card_front_file = id ) as idCardPromiseFront,
(SELECT visit_location from t_common_file where tcp.id_card_back_file = id ) as idCardPromiseBack,
(SELECT visit_location from t_common_file where tcp.id_photo_file = id ) as picture,
(SELECT visit_location from t_common_file where tcp.student_record_file = id ) as studentPromise,
(SELECT visit_location from t_common_file where tcp.health_record_file = id ) as bodyTest,
(SELECT visit_location from t_common_file where tcp.insurance_record_file = id ) as bodyProtect
from
t_compete_project tcpro LEFT JOIN t_compete_project_player tcpp on tcpro.id = tcpp.project_id
LEFT JOIN t_compete_player tcp on tcpp.player_id = tcp.id
LEFT JOIN t_compete_group tcg on tcg.id = tcp.compete_group_id
LEFT JOIN t_compete_company tcc on tcc.id = tcp.company_id
where
<trim prefix="(" prefixOverrides="and" suffix=")">
<if test="projectId != null">
tcpro.id = #{projectId}
</if>
<if test="groupId != null">
and tcg.id = #{groupId}
</if>
<if test="companyId != null">
and tcc.id = #{companyId}
</if>
<if test="name != null and name != ''">
and tcp.name like concat('%',#{name, jdbcType=VARCHAR},'%')
</if>
<if test="idCard != null and idCard != ''">
and tcp.id_card = #{idCard}
</if>
and tcpro.type=0
and tcpro.`level` =2
and tcpro.team=0
and tcp.rec_status = 0
and tcc.rec_status = 0
and tcpp.rec_status = 0
and tcpro.rec_status = 0
</trim>
5 years ago
</select>
5 years ago
5 years ago
<select id="selectGroup" resultType="com.ccsens.mt.bean.vo.TableVo$CompeteJoin" parameterType="java.util.Map">
5 years ago
SELECT
tcpro.id as projectId,
tcpro.name as competeProject,
tcg.group_name as competeGroup,
tcc.`name` as joinTeam,
tcp.`name` as name,
tcp.gender as gender,
tcp.id_card as idCard,
(SELECT visit_location from t_common_file where tcp.id_card_front_file = id ) as idCardPromiseFront,
(SELECT visit_location from t_common_file where tcp.id_card_back_file = id ) as idCardPromiseBack,
(SELECT visit_location from t_common_file where tcp.id_photo_file = id ) as picture,
(SELECT visit_location from t_common_file where tcp.student_record_file = id ) as studentPromise,
(SELECT visit_location from t_common_file where tcp.health_record_file = id ) as bodyTest,
(SELECT visit_location from t_common_file where tcp.insurance_record_file = id ) as bodyProtect
from
t_compete_project tcpro LEFT JOIN t_compete_team tct on tcpro.id = tct.project_id
LEFT JOIN t_compete_team_member tctm on tct.id = tctm.compete_team_id
LEFT JOIN t_compete_player tcp on tcp.id = tctm.player_id
LEFT JOIN t_compete_company tcc on tcc.id = tcp.company_id
LEFT JOIN t_compete_group tcg on tcg.id = tcp.compete_group_id
WHERE
<trim prefix="(" prefixOverrides="and" suffix=")">
5 years ago
<if test="projectId != null">
5 years ago
tcpro.id = #{projectId}
5 years ago
</if>
5 years ago
<if test="groupId != null">
5 years ago
and tcg.id = #{groupId}
</if>
5 years ago
<if test="companyId != null">
5 years ago
and tcc.id = #{companyId}
</if>
5 years ago
<if test="name != null and name != ''">
5 years ago
and tcp.name like concat('%',#{name, jdbcType=VARCHAR},'%')
5 years ago
</if>
5 years ago
<if test="idCard != null and idCard != ''">
5 years ago
and tcp.id_card = #{idCard}
</if>
5 years ago
and tcpro.type=0
and tcpro.`level` =2
and tcpro.team=1
and tcpro.rec_status = 0
and tctm.rec_status = 0
and tcp.rec_status = 0
and tcc.rec_status = 0
and tcg.rec_status = 0
and tct.rec_status = 0
</trim>
5 years ago
</select>
<select id="queryProjectConfig" resultType="com.ccsens.mt.bean.vo.TableVo$CompeteProjectConfig">
SELECT
p.id as projectId,
p.`name` as projectName,
if(p.team = 0,count(a.projectId),count(b.projectId)) as joinNum,
pc.project_duration as duration,
pc.site_num as siteNum,
pc.start_time as startTime,
pc.end_time as endTime
FROM
5 years ago
t_compete_project p
LEFT JOIN (SELECT * FROM t_compete_project_config WHERE rec_status = 0 and rec_status is null) pc on pc.project_id = p.id
LEFT JOIN
(
SELECT
pp.project_id as projectId
FROM
t_compete_project_player pp LEFT JOIN t_compete_player pl on pp.player_id = pl.id
5 years ago
LEFT JOIN t_compete_company c on pl.company_id = c.id
WHERE
pp.rec_status = 0
and pl .rec_status = 0
5 years ago
and c.rec_status = 0
)a on a.projectId = p.id
LEFT JOIN
(
SELECT
t.project_id as projectId
FROM
t_compete_team t LEFT JOIN t_compete_team_member m on t.id = m.compete_team_id
LEFT JOIN t_compete_player pl on m.player_id = pl.id
5 years ago
LEFT JOIN t_compete_company c on t.company_id = c.id
WHERE
t.rec_status = 0
and m .rec_status = 0
and pl .rec_status = 0
5 years ago
and c.rec_status = 0
GROUP BY t.id
)b on b.projectId = p.id
WHERE
p.type = #{type}
and p.`level` = 2
5 years ago
and p.certificate = 0
and p.rec_status = 0
GROUP BY p.id
</select>
5 years ago
<select id="queryStartOrderByCompany" resultMap="startOrderByCompany">
5 years ago
SELECT
so.id as startOrderId,
so.compete_order as competeOrder,
so.site as site,
5 years ago
pc.start_time as startTime,
5 years ago
pr.id as projectId,
pr.`name` as projectName,
5 years ago
pr.`team` as team,
5 years ago
if(pr.team = 0,a.plName,b.plName) as playerName,
5 years ago
if(pr.team = 0,a.groupName,b.groupName) as groupName,
5 years ago
if(pr.team = 0,a.videoUrl,b.videoUrl) as videoUrl,
if(pr.team = 0,a.ppId,b.teamId) as playerOrTeamId
5 years ago
from
t_compete_start_order so
LEFT JOIN t_compete_project pr on so.project_id = pr.id
LEFT JOIN t_compete_time ti on pr.type = ti.type
5 years ago
LEFT JOIN t_compete_project_config pc on pc.project_id = pr.id
5 years ago
LEFT JOIN
(
SELECT
pp.id as ppId,
pl.`name` as plName,
5 years ago
g.group_name as groupName,
v.video_url as videoUrl
5 years ago
FROM
t_compete_project_player pp LEFT JOIN t_compete_player pl on pp.player_id = pl.id
LEFT JOIN t_compete_group g on g.id = pl.compete_group_id
5 years ago
LEFT JOIN t_compete_video v on pp.id = v.player_id
5 years ago
WHERE
pl.company_id = #{companyId}
and pp.rec_status = 0
and pl.rec_status = 0
)a on a.ppId = so.player_id
LEFT JOIN
(
SELECT
t.id as teamId,
5 years ago
pl.`name` as plName,
g.group_name as groupName,
v.video_url as videoUrl
5 years ago
FROM
t_compete_team t LEFT JOIN t_compete_team_member m on t.id = m.compete_team_id
LEFT JOIN t_compete_player pl on m.player_id = pl.id
LEFT JOIN t_compete_group g on t.group_remark = g.group_remark and t.gender_group = g.sex
5 years ago
LEFT JOIN t_compete_video v on t.id = v.player_id
5 years ago
WHERE
t.company_id = #{companyId}
and t.rec_status = 0
and m.rec_status = 0
and pl.rec_status = 0
)b on b.teamId = so.player_id
WHERE
<if test="projectId != null">
pr.id = #{projectId}
and
</if>
ti.id = #{competeTimeId}
and(a.ppId is not null or b.teamId is not null)
and so.rec_status = 0
and pr.rec_status = 0
ORDER BY so.start_time
</select>
5 years ago
<select id="queryProjectByTaskDetailId" resultType="com.ccsens.mt.bean.vo.ProvinceCompeteVo$QueryProjectByTall">
SELECT
s.id as startOrderId,
p.id as projectId,
if(p.parent_id = 2001,0,1) as projectType
FROM
`t_compete_start_order` s LEFT JOIN t_compete_project p on s.project_id = p.id
WHERE
s.task_id = #{taskDetailId}
and s.rec_status = 0
and p.rec_status = 0
LIMIT 1
</select>
5 years ago
5 years ago
</mapper>