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.
303 lines
11 KiB
303 lines
11 KiB
<?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.CompetePlayerDao">
|
|
|
|
<resultMap id="getDepartment" type="com.ccsens.mt.bean.vo.CompeteVo$DepartmentInfo">
|
|
<id column="id" property="id"/>
|
|
<result column="name" property="name"/>
|
|
<collection property="departmentRoles" ofType="com.ccsens.mt.bean.vo.CompeteVo$DepartmentRole">
|
|
<id column="rId" property="id"/>
|
|
<result column="rName" property="name"/>
|
|
<result column="rPhone" property="phone"/>
|
|
<result column="role" property="role"/>
|
|
</collection>
|
|
</resultMap>
|
|
|
|
<resultMap id="compete_project" type="com.ccsens.mt.bean.vo.CompeteVo$DepartmentProject">
|
|
<id column="parentProjectId" property="parentProjectId"/>
|
|
<result column="parentProjectName" property="parentProjectName"/>
|
|
<result column="type" property="type"/>
|
|
<collection property="secondProjects" ofType="com.ccsens.mt.bean.vo.CompeteVo$DepartmentSecondProject">
|
|
<id column="id" property="competeProjectId"/>
|
|
<result column="name" property="competeProjectName"/>
|
|
<result column="team" property="team"/>
|
|
</collection>
|
|
</resultMap>
|
|
|
|
<resultMap id="teamNum" type="com.ccsens.mt.bean.vo.TableVo$CompeteAllCount">
|
|
<id column="projectId" property="projectId"/>
|
|
<result column="projectName" property="projectName"/>
|
|
<collection property="nums" ofType="Integer" column="projectId" select="getTeamJoinNumByProjectId">
|
|
</collection>
|
|
</resultMap>
|
|
<resultMap id="singleOrderPlayer" type="com.ccsens.mt.bean.vo.CompeteExcelVo$TeamOrderPlayer">
|
|
<id column="groupId" property="groupId" />
|
|
<result column="groupName" property="groupName" />
|
|
<collection property="companyNameList" ofType="com.ccsens.mt.bean.vo.CompeteExcelVo$TeamOrderPlayerList">
|
|
<id column="companyId" property="teamId"/>
|
|
<result column="companyName" property="companyName"/>
|
|
<result column="playerName" property="playerNames"/>
|
|
</collection>
|
|
</resultMap>
|
|
<select id="getInfo" resultType="com.ccsens.mt.bean.vo.CompeteVo$GetPlayerInfo">
|
|
SELECT
|
|
p.id AS playerId,
|
|
p.NAME,
|
|
p.gender,
|
|
p.phone,
|
|
p.id_card AS idCard,
|
|
p.compete_group_id AS groupId,
|
|
g.group_name AS groupName,
|
|
c.`name` AS companyName,
|
|
p.id_card_front AS idCardFront,
|
|
p.id_card_back AS idCardBack,
|
|
p.prove_img AS proveImg
|
|
FROM
|
|
t_compete_player p LEFT JOIN
|
|
t_compete_group g on p.compete_group_id = g.id LEFT JOIN
|
|
t_compete_company c on p.company_id = c.id
|
|
WHERE
|
|
p.user_id = #{userId}
|
|
and p.compete_time_id = #{competeTimeId}
|
|
AND p.rec_status = 0
|
|
AND (g.rec_status = 0 or g.rec_status is null)
|
|
LIMIT 1
|
|
</select>
|
|
<select id="getDepartment" resultMap="getDepartment">
|
|
SELECT
|
|
r.type as role,
|
|
c.`id`,
|
|
c.`name`,
|
|
p.`id` as rId,
|
|
p.`name` as rName,
|
|
p.phone as rPhone
|
|
FROM
|
|
t_compete_company_role r
|
|
LEFT JOIN t_compete_company c on r.compete_company_id = c.id
|
|
LEFT JOIN t_compete_player p on r.player_id = p.id
|
|
WHERE
|
|
c.rec_status = 0
|
|
and
|
|
p.rec_status = 0
|
|
and
|
|
r.rec_status = 0
|
|
and
|
|
r.compete_company_id = #{id}
|
|
</select>
|
|
|
|
|
|
<select id="getDepartmentProject" parameterType="java.util.Map" resultMap="compete_project">
|
|
SELECT
|
|
p.id as parentProjectId,
|
|
p.`name` as parentProjectName,
|
|
p.type as type,
|
|
t.id as id,
|
|
t.`name` as name,
|
|
t.team as team
|
|
FROM
|
|
t_compete_project p LEFT JOIN
|
|
(
|
|
SELECT
|
|
id,
|
|
parent_id,
|
|
`name`,
|
|
team
|
|
FROM
|
|
t_compete_project
|
|
WHERE
|
|
rec_status = 0
|
|
and
|
|
level = 2
|
|
) t on t.parent_id = p.id
|
|
WHERE
|
|
rec_status = 0
|
|
and
|
|
type = #{type}
|
|
and
|
|
level = 1
|
|
</select>
|
|
<select id="getMemberNamesByProjectId" resultType="java.lang.String">
|
|
SELECT
|
|
GROUP_CONCAT(e.`name` separator '、')
|
|
FROM
|
|
t_compete_project_player p LEFT JOIN t_compete_player e on p.player_id = e.id
|
|
WHERE
|
|
e.company_id = #{companyId}
|
|
and
|
|
p.rec_status = 0
|
|
and
|
|
e.rec_status = 0
|
|
and
|
|
p.project_id = #{competeProjectId}
|
|
and
|
|
p.gender_group = #{genderGroup}
|
|
</select>
|
|
<select id="getTeamMemberNamesByProjectId" resultType="java.lang.String">
|
|
SELECT
|
|
GROUP_CONCAT(p.`name` separator '、')
|
|
FROM
|
|
t_compete_team t LEFT JOIN t_compete_team_member m on t.id = m.compete_team_id
|
|
LEFT JOIN t_compete_player p on m.player_id = p.id
|
|
WHERE
|
|
p.company_id = #{companyId}
|
|
and
|
|
t.rec_status = 0
|
|
and
|
|
m.rec_status = 0
|
|
and
|
|
p.rec_status = 0
|
|
and
|
|
t.project_id = #{competeProjectId}
|
|
and
|
|
t.gender_group = #{genderGroup}
|
|
</select>
|
|
|
|
<select id="getCompanyIdByUser" resultType="java.lang.Long">
|
|
SELECT
|
|
c.id
|
|
FROM
|
|
t_compete_company c LEFT JOIN t_compete_company_role r on c.id = r.compete_company_id
|
|
LEFT JOIN t_compete_player p on r.player_id = p.id
|
|
WHERE
|
|
c.type = 1
|
|
and
|
|
r.type = 2
|
|
and
|
|
p.user_id = #{userId}
|
|
and c.rec_status = 0
|
|
and r.rec_status = 0
|
|
and p.rec_status = 0
|
|
LIMIT 1
|
|
</select>
|
|
<select id="queryPlayerByCompanyId" resultType="com.ccsens.mt.bean.vo.ProvinceCompeteVo$PlayerByCompanyId">
|
|
SELECT
|
|
p.id as playerId,
|
|
p.`name` as playerName,
|
|
g.group_name as groupName
|
|
FROM `t_compete_player` p LEFT JOIN t_compete_group g on p.compete_group_id = g.id
|
|
WHERE p.company_id = #{companyId}
|
|
and p.rec_status = 0
|
|
</select>
|
|
<select id="getPlayerByPlayerId" resultType="com.ccsens.mt.bean.vo.ProvinceCompeteVo$PlayerInfo">
|
|
SELECT
|
|
id as playerId,
|
|
`name` as playerName,
|
|
gender,
|
|
id_card as idCard,
|
|
company_id as competeId,
|
|
compete_group_id as groupId,
|
|
group_remark as groupRemark,
|
|
(SELECT id FROM t_common_file WHERE id = id_card_front_file) as idCardFrontId,
|
|
(SELECT visit_location FROM t_common_file WHERE id = id_card_front_file) as idCardFront,
|
|
(SELECT id FROM t_common_file WHERE id = id_card_back_file) as idCardBackId,
|
|
(SELECT visit_location FROM t_common_file WHERE id = id_card_back_file) as idCardBack,
|
|
(SELECT id FROM t_common_file WHERE id = id_photo_file) as idPhoneId,
|
|
(SELECT visit_location FROM t_common_file WHERE id = id_photo_file) as idPhone,
|
|
(SELECT id FROM t_common_file WHERE id = student_record_file) as studentRecordId,
|
|
(SELECT visit_location FROM t_common_file WHERE id = student_record_file) as studentRecord,
|
|
(SELECT id FROM t_common_file WHERE id = health_record_file) as healthRecordId,
|
|
(SELECT visit_location FROM t_common_file WHERE id = health_record_file) as healthRecord,
|
|
(SELECT id FROM t_common_file WHERE id = insurance_record_file) as insuranceRecordId,
|
|
(SELECT visit_location FROM t_common_file WHERE id = insurance_record_file) as insuranceRecord
|
|
FROM
|
|
t_compete_player
|
|
WHERE
|
|
id = #{playerId}
|
|
and rec_status = 0
|
|
</select>
|
|
|
|
<select id="getTeamGroupRemark" resultType="com.ccsens.mt.bean.vo.ProvinceCompeteVo$TeamGroupRemark">
|
|
SELECT
|
|
g.group_name as groupRemark,
|
|
p.name as playerName,
|
|
if(AVG(p.gender)=0 or AVG(p.gender)=1, AVG(p.gender),2) as sexGroup
|
|
|
|
FROM
|
|
t_compete_player p
|
|
LEFT JOIN t_compete_team_member m on p.id = m.player_id
|
|
LEFT JOIN t_compete_group g on p.compete_group_id = g.id
|
|
WHERE
|
|
m.compete_team_id = #{teamId}
|
|
and p.rec_status = 0
|
|
and m.rec_status = 0
|
|
and g.rec_status = 0
|
|
</select>
|
|
<select id="getTeamJoinNumByType" resultMap="teamNum">
|
|
SELECT
|
|
p.id as projectId,
|
|
p.`name` as projectName
|
|
FROM
|
|
t_compete_project p LEFT JOIN t_compete_time t on p.type = t.type
|
|
WHERE
|
|
t.id = #{timeId}
|
|
and p.`level` = 2
|
|
and t.rec_status = 0
|
|
and p.rec_status = 0
|
|
</select>
|
|
|
|
<select id="getTeamJoinNumByProjectId" resultType="Integer">
|
|
SELECT
|
|
if(p.team = 1,(if(t1.co is null,0,t1.co)),(if(t2.co is null,0,t2.co)))
|
|
from
|
|
t_compete_project p
|
|
LEFT JOIN
|
|
t_compete_group g on p.type = g.type
|
|
LEFT JOIN
|
|
(
|
|
SELECT
|
|
count(id) as co,
|
|
group_remark as re,
|
|
gender_group as ge,
|
|
project_id as tpId
|
|
FROM
|
|
t_compete_team
|
|
WHERE
|
|
rec_status = 0
|
|
GROUP BY group_remark,gender_group
|
|
)t1 on g.sequence = (t1.re*10 + t1.ge) and t1.tpId = p.id
|
|
LEFT JOIN
|
|
(
|
|
SELECT
|
|
pl.compete_group_id as groupId,
|
|
count(pp.id) as co
|
|
FROM
|
|
t_compete_project_player pp
|
|
LEFT JOIN t_compete_player pl on pp.player_id = pl.id
|
|
WHERE
|
|
pl.rec_status = 0 and pp.rec_status = 0
|
|
GROUP BY pl.compete_group_id
|
|
)t2 on g.id = t2.groupId
|
|
WHERE
|
|
p.id = #{projectId}
|
|
and g.rec_status in (0,1)
|
|
ORDER BY g.sequence
|
|
</select>
|
|
<select id="selectBySexAndRemark" resultType="com.ccsens.mt.bean.po.CompeteGroup">
|
|
SELECT
|
|
tcg.`group_name` as groupName
|
|
FROM
|
|
t_compete_group tcg
|
|
WHERE
|
|
tcg.`sex`=#{sex}
|
|
and tcg.`group_remark`=#{remark}
|
|
</select>
|
|
<select id="selectSinglePlayerByProjectId" resultMap="singleOrderPlayer">
|
|
select
|
|
tcg.id as groupId,
|
|
tcg.group_name as groupName,
|
|
tcc.id as companyId,
|
|
tcc.name as companyName,
|
|
tcp.name as playerName
|
|
FROM
|
|
t_compete_project_player tcpp
|
|
LEFT JOIN t_compete_player tcp on tcp.id=tcpp.player_id
|
|
LEFT JOIN t_compete_company tcc on tcp.company_id=tcc.id
|
|
LEFT JOIN t_compete_group tcg on tcg.id=tcp.compete_group_id
|
|
WHERE
|
|
tcpp.project_id=#{id}
|
|
and tcpp.rec_status=0
|
|
and tcp.rec_status=0
|
|
and tcc.rec_status=0
|
|
and tcg.rec_status=0
|
|
</select>
|
|
</mapper>
|