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.
868 lines
29 KiB
868 lines
29 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.carbasics.persist.dao.OrganizationDao">
|
|
|
|
<resultMap id="basicMap" type="com.ccsens.carbasics.bean.vo.OrganizationVo$Basic">
|
|
<id property="organizationId" column="organizationId"/>
|
|
<collection property="roles" ofType="String" javaType="List">
|
|
<result column="role"/>
|
|
</collection>
|
|
</resultMap>
|
|
<resultMap id="templateMap" type="com.ccsens.carbasics.bean.vo.OrganizationVo$Template">
|
|
<id property="organizationId" column="id"/>
|
|
<collection property="templates" ofType="String" javaType="List">
|
|
<result column="template"/>
|
|
</collection>
|
|
</resultMap>
|
|
<insert id="batchInsert">
|
|
replace into t_organization(id, organization_type, code, name, short_name, introduce, level, operator) value
|
|
<foreach collection="organizations" item="item" separator=",">
|
|
(#{item.id}, #{item.organizationType}, #{item.code}, #{item.name}, #{item.shortName}, #{item.introduce}, #{item.level}, #{item.operator})
|
|
</foreach>
|
|
</insert>
|
|
<insert id="batchInsertParent">
|
|
replace into t_organization_parent(id, organization_id, parent_id, operator) value
|
|
<foreach collection="parents" item="item" separator=",">
|
|
(#{item.id}, #{item.organizationId}, #{item.parentId}, #{item.operator})
|
|
</foreach>
|
|
</insert>
|
|
|
|
<select id="getOrganization" resultMap="basicMap">
|
|
SELECT
|
|
t2.organization_id as organizationId,
|
|
t2.code as role
|
|
FROM
|
|
(
|
|
SELECT
|
|
d.organization_id,
|
|
pt.code
|
|
FROM
|
|
(select * from t_organization_member where user_id = #{userId} and rec_status = 0) m,
|
|
t_organization_member_position mp,
|
|
t_organization_department d,
|
|
t_organization_position p,
|
|
t_organization_position_type AS pt,
|
|
t_organization_position_type_relation AS ptr
|
|
WHERE
|
|
m.id = mp.member_id
|
|
AND mp.department_id = d.id
|
|
AND mp.position_id = p.id
|
|
AND p.id = ptr.position_id
|
|
AND pt.id = ptr.position_type_id
|
|
AND d.rec_status = 0
|
|
AND mp.rec_status = 0
|
|
AND p.rec_status = 0
|
|
AND pt.rec_status = 0
|
|
AND ptr.rec_status = 0
|
|
) t2
|
|
WHERE
|
|
t2.organization_id = #{projectId}
|
|
</select>
|
|
<select id="getByProjectId" resultType="com.ccsens.carbasics.bean.po.Organization">
|
|
SELECT
|
|
o.id,
|
|
o.organization_type as organizationType,
|
|
o.`code`,
|
|
o.`name`,
|
|
o.short_name as shortName,
|
|
o.introduce,
|
|
o.`level`
|
|
FROM
|
|
t_organization o,
|
|
t_organization_project p
|
|
WHERE
|
|
p.project_id = #{projectId}
|
|
and o.id = p.organization_id
|
|
and o.rec_status = 0
|
|
and p.rec_status = 0
|
|
limit 1
|
|
</select>
|
|
<select id="getHospitalByParentId" resultType="com.ccsens.carbasics.bean.po.Organization">
|
|
SELECT
|
|
*
|
|
FROM
|
|
(
|
|
SELECT
|
|
t1.id,
|
|
t1.organization_type as organizationType,
|
|
t1.CODE,
|
|
t1.NAME,
|
|
t1.short_name AS shortName,
|
|
t1.introduce,
|
|
t1.LEVEL,
|
|
IF
|
|
( find_in_set( parent_id, @pids ) > 0, @pids := concat( @pids, ',', id ), 0 ) AS ischild
|
|
FROM
|
|
( SELECT t.*, p.parent_id FROM t_organization t, t_organization_parent p WHERE t.id = p.organization_id ORDER BY parent_id, id ) t1,
|
|
( SELECT @pids := #{parentId} ) t2
|
|
) t3
|
|
WHERE
|
|
ischild != 0
|
|
AND organizationType = 3
|
|
</select>
|
|
|
|
<select id="getByCode" resultType="com.ccsens.carbasics.bean.po.Organization">
|
|
SELECT
|
|
o.id,
|
|
o.organization_type AS organizationType,
|
|
o.`code`,
|
|
o.`name`,
|
|
o.short_name AS shortName,
|
|
o.introduce,
|
|
o.`level`
|
|
FROM
|
|
t_organization o
|
|
WHERE
|
|
o.`code` = #{code}
|
|
AND o.rec_status = 0
|
|
LIMIT 1
|
|
</select>
|
|
<select id="rankByType" resultType="com.ccsens.carbasics.bean.vo.OrganizationVo$RankItem">
|
|
select h.id, h.name, h.level, ifNULL(t.total, 0) as value from
|
|
(
|
|
<choose>
|
|
<when test="areaId == null or areaId == 0">
|
|
SELECT
|
|
t1.id,
|
|
t1.organization_type as organizationType,
|
|
t1.CODE,
|
|
t1.NAME,
|
|
t1.short_name AS shortName,
|
|
t1.introduce,
|
|
t1.level
|
|
from t_organization t1
|
|
WHERE
|
|
organization_type = 3
|
|
<if test="level != null">
|
|
AND level = #{level}
|
|
</if>
|
|
</when>
|
|
<otherwise>
|
|
SELECT
|
|
*
|
|
FROM
|
|
(
|
|
SELECT
|
|
t1.id,
|
|
t1.organization_type as organizationType,
|
|
t1.CODE,
|
|
t1.NAME,
|
|
t1.short_name AS shortName,
|
|
t1.introduce,
|
|
t1.level,
|
|
IF( find_in_set( parent_id, @pids ) > 0, @pids := concat( @pids, ',', id ), 0 ) AS ischild
|
|
FROM
|
|
( SELECT t.*, p.parent_id FROM t_organization t, t_organization_parent p WHERE t.id = p.organization_id ORDER BY parent_id, id ) t1,
|
|
<choose>
|
|
<when test="areaId == null">( SELECT @pids := 0 ) t2</when>
|
|
<otherwise>( SELECT @pids := #{areaId} ) t2</otherwise>
|
|
</choose>
|
|
) t3
|
|
WHERE
|
|
organizationType = 3
|
|
<if test="areaId != null">
|
|
and ischild != 0
|
|
</if>
|
|
<if test="level != null">
|
|
AND level = #{level}
|
|
</if>
|
|
</otherwise>
|
|
</choose>
|
|
) h
|
|
left join (
|
|
<choose>
|
|
<when test="type == 0">
|
|
select a.hospital_id, count(*) as total from t_qcp_first_aid a, t_qcp_first_aid_record r1 , t_qcp_first_aid_record r2
|
|
where a.id = r1.first_aid_id and r1.question_code = 'JBXX-FBTime'
|
|
and a.id = r2.first_aid_id and r2.question_code = 'JBXX-DYSJ'
|
|
and r2.answer - r1.answer > 6 * 60 * 60 * 1000
|
|
and a.rec_status = 0 and r1.rec_status = 0 and r2.rec_status = 0
|
|
group by a.hospital_id
|
|
</when>
|
|
<when test="type == 1">
|
|
select a.hospital_id, count(r1.id) as total from t_qcp_first_aid a, t_qcp_first_aid_record r1
|
|
where a.id = r1.first_aid_id
|
|
and r1.question_code = 'ZLFA-JMRS' and r1.answer = '是'
|
|
and a.rec_status = 0 and r1.rec_status = 0
|
|
group by a.hospital_id
|
|
</when>
|
|
<when test="type == 2">
|
|
select t1.hospital_id, round(t2.part * 100 / t1.total, 2) as total from
|
|
(select
|
|
a.hospital_id,
|
|
count(*) as total from t_qcp_first_aid a, t_qcp_first_aid_record r1 , t_qcp_first_aid_record r2
|
|
where a.id = r1.first_aid_id and r1.question_code = 'JBXX-FBTime'
|
|
and a.id = r2.first_aid_id and r2.question_code = 'JBXX-DYSJ'
|
|
and r2.answer - r1.answer < 6 * 60 * 60 * 1000
|
|
and a.rec_status = 0 and r1.rec_status = 0 and r2.rec_status = 0
|
|
group by a.hospital_id
|
|
) t1,
|
|
(select
|
|
a.hospital_id, count(a.id) as part from t_qcp_first_aid a, t_qcp_first_aid_record r1
|
|
where a.id = r1.first_aid_id
|
|
and r1.question_code = 'ZLFA-JMRS' and r1.answer = '是'
|
|
and a.rec_status = 0 and r1.rec_status = 0
|
|
group by a.hospital_id
|
|
)t2
|
|
where t1.hospital_id = t2.hospital_id
|
|
</when>
|
|
<when test="type == 4">
|
|
select a.hospital_id, count(a.id) as total from t_qcp_first_aid a, t_qcp_first_aid_record r1
|
|
where a.id = r1.first_aid_id
|
|
and r1.question_code = 'RYPG-ZDJG' and r1.answer = '出血性脑卒中'
|
|
and a.rec_status = 0 and r1.rec_status = 0
|
|
</when>
|
|
</choose>
|
|
|
|
) t on t.hospital_id = h.id
|
|
order by t.total desc
|
|
</select>
|
|
|
|
<select id="rankByDntMedian" resultType="com.ccsens.carbasics.bean.vo.OrganizationVo$RankItem">
|
|
select h.id, h.name, h.level, ifNULL(t.total, 0) as value from (
|
|
<choose>
|
|
<when test="areaId == null or areaId == 0">
|
|
SELECT
|
|
t1.id,
|
|
t1.organization_type as organizationType,
|
|
t1.CODE,
|
|
t1.NAME,
|
|
t1.short_name AS shortName,
|
|
t1.introduce,
|
|
t1.level
|
|
from t_organization t1
|
|
WHERE
|
|
organization_type = 3
|
|
<if test="level != null">
|
|
AND level = #{level}
|
|
</if>
|
|
</when>
|
|
<otherwise>
|
|
SELECT
|
|
*
|
|
FROM
|
|
(
|
|
SELECT
|
|
t1.id,
|
|
t1.organization_type as organizationType,
|
|
t1.CODE,
|
|
t1.NAME,
|
|
t1.short_name AS shortName,
|
|
t1.introduce,
|
|
t1.level,
|
|
IF( find_in_set( parent_id, @pids ) > 0, @pids := concat( @pids, ',', id ), 0 ) AS ischild
|
|
FROM
|
|
( SELECT t.*, p.parent_id FROM t_organization t, t_organization_parent p WHERE t.id = p.organization_id ORDER BY parent_id, id ) t1,
|
|
<choose>
|
|
<when test="areaId == null">( SELECT @pids := 0 ) t2</when>
|
|
<otherwise>( SELECT @pids := #{areaId} ) t2</otherwise>
|
|
</choose>
|
|
|
|
) t3
|
|
WHERE
|
|
organizationType = 3
|
|
<if test="areaId != null">
|
|
and ischild != 0
|
|
</if>
|
|
|
|
<if test="level != null">
|
|
AND level = #{level}
|
|
</if>
|
|
|
|
</otherwise>
|
|
</choose>
|
|
) h
|
|
left join (
|
|
select t1.hospital_id, avg(t1.val) as total from
|
|
(select hospital_id, val, @team,
|
|
case @team when hospital_id then @rk := @rk+1 else @rk := 1 end rk,
|
|
@team := hospital_id
|
|
from
|
|
(select
|
|
a.hospital_id,
|
|
ROUND((r1.answer - r2.answer)/60000, 2) as val
|
|
from t_qcp_first_aid a, t_qcp_first_aid_record r1 , t_qcp_first_aid_record r2
|
|
where a.id = r1.first_aid_id and r1.question_code = 'JMRSSJ'
|
|
and a.id = r2.first_aid_id and r2.question_code = 'JBXX-DYSJ'
|
|
and a.rec_status = 0 and r1.rec_status = 0 and r2.rec_status = 0
|
|
) d,
|
|
(select @rk := 0, @team := '') t
|
|
order by hospital_id, val) t1
|
|
left join (
|
|
select
|
|
a.hospital_id,
|
|
count(*) as cnt
|
|
from t_qcp_first_aid a, t_qcp_first_aid_record r1 , t_qcp_first_aid_record r2
|
|
where a.id = r1.first_aid_id and r1.question_code = 'JMRSSJ'
|
|
and a.id = r2.first_aid_id and r2.question_code = 'JBXX-DYSJ'
|
|
and a.rec_status = 0 and r1.rec_status = 0 and r2.rec_status = 0
|
|
group by a.hospital_id
|
|
) t2 on t1.hospital_id = t2.hospital_id
|
|
where t1.rk IN (t2.cnt + 0.5, t2.cnt, t2.cnt + 1)
|
|
group by t1.hospital_id
|
|
) t on t.hospital_id = h.id
|
|
order by t.total desc
|
|
</select>
|
|
<select id="getOrganizationByName" resultType="com.ccsens.carbasics.bean.po.Organization">
|
|
select * from t_organization where name = #{name} and rec_status = 0 order by updated_at desc limit 1
|
|
</select>
|
|
<select id="queryTemplate" resultMap="templateMap">
|
|
SELECT
|
|
o.id,
|
|
t.template
|
|
FROM
|
|
(
|
|
SELECT
|
|
o.id
|
|
FROM
|
|
t_organization o,
|
|
t_organization_project p
|
|
WHERE
|
|
o.id = p.organization_id
|
|
AND p.project_id = #{projectId}
|
|
AND o.rec_status = 0
|
|
AND p.rec_status = 0
|
|
) o,
|
|
(
|
|
SELECT
|
|
d.*
|
|
FROM
|
|
t_organization_member m,
|
|
t_organization_member_position p,
|
|
t_organization_department d
|
|
WHERE
|
|
m.id = p.member_id
|
|
AND p.department_id = d.id
|
|
AND m.user_id = #{userId}
|
|
AND m.rec_status = 0
|
|
AND p.rec_status = 0
|
|
AND d.rec_status = 0
|
|
) d,
|
|
t_organization_template t
|
|
WHERE
|
|
o.id = d.organization_id
|
|
AND d.CODE = t.CODE
|
|
AND t.code_type = 0
|
|
AND t.rec_status = 0
|
|
</select>
|
|
|
|
<select id="queryByName" resultType="com.ccsens.carbasics.bean.po.Organization">
|
|
SELECT
|
|
id,
|
|
organization_type,
|
|
`code`,
|
|
`name`,
|
|
short_name,
|
|
introduce,
|
|
`level`,
|
|
operator
|
|
FROM
|
|
t_organization
|
|
WHERE
|
|
rec_status = 0
|
|
AND organization_type = 3
|
|
AND `name` = #{name}
|
|
</select>
|
|
<select id="getByProject" resultType="com.ccsens.carbasics.bean.vo.OrganizationVo$Info">
|
|
SELECT
|
|
o.id as organizationId,
|
|
o.organization_type as organizationType,
|
|
o.code as code,
|
|
o.name as name,
|
|
o.short_name as shortName,
|
|
o.introduce as introduce,
|
|
o.level as level
|
|
FROM
|
|
t_organization o,
|
|
t_organization_project p
|
|
WHERE
|
|
o.id = p.organization_id
|
|
AND p.project_id = #{projectId}
|
|
AND p.rec_status = 0
|
|
AND o.rec_status = 0
|
|
</select>
|
|
<select id="getQcpHospitalId" resultType="java.lang.Long">
|
|
SELECT
|
|
h.id
|
|
FROM
|
|
t_organization o,
|
|
t_organization_project p,
|
|
qcp.t_qcp_hospital h
|
|
WHERE
|
|
o.id = p.organization_id
|
|
AND p.project_id = h.project_id
|
|
AND o.id = #{id}
|
|
AND o.rec_status = 0
|
|
AND p.rec_status = 0
|
|
AND h.rec_status = 0
|
|
</select>
|
|
|
|
<select id="hospitalRankStatistical" resultType="com.ccsens.carbasics.bean.vo.OrganizationVo$HospitalRankItem">
|
|
SELECT
|
|
d.user_id as userId,
|
|
h.hospitalName as name,
|
|
h.hospitalLevel as level,
|
|
if(t.count is null,0, t.count) as `value`
|
|
FROM
|
|
(
|
|
SELECT
|
|
t1.detail_id,
|
|
t1.hospitalName,
|
|
t3.hospitalLevel
|
|
FROM
|
|
(SELECT questionnaire_detail_id as detail_id,answer as hospitalName FROM `t_qcp_questionnaire_record`
|
|
WHERE question_code = 'HOS-NAME' and rec_status = 0) t1,
|
|
(SELECT questionnaire_detail_id as detail_id FROM `t_qcp_questionnaire_record`
|
|
WHERE question_code = 'CITY-COUNTY'
|
|
<if test="areaId != null">
|
|
AND answer LIKE concat('%',#{areaId},'%')
|
|
</if>
|
|
and rec_status = 0)t2,
|
|
(SELECT questionnaire_detail_id as detail_id,answer as hospitalLevel FROM `t_qcp_questionnaire_record`
|
|
WHERE question_code = 'HOS-LEVEL'
|
|
<if test="level != null">
|
|
and answer = #{level}
|
|
</if>
|
|
and rec_status = 0)t3
|
|
WHERE
|
|
t1.detail_id = t2.detail_id
|
|
and t1.detail_id = t2.detail_id
|
|
and t2.detail_id = t3.detail_id
|
|
GROUP BY t1.detail_id
|
|
)h
|
|
LEFT JOIN
|
|
(
|
|
<choose>
|
|
<when test="type == 1">
|
|
<include refid="nnt"></include>
|
|
</when>
|
|
<when test="type == 2">
|
|
<include refid="dnt45"></include>
|
|
</when>
|
|
<when test="type == 3">
|
|
<include refid="dnt60"></include>
|
|
</when>
|
|
<when test="type == 4">
|
|
<include refid="sich"></include>
|
|
</when>
|
|
<when test="type == 5">
|
|
<include refid="qjxgnzll"></include>
|
|
</when>
|
|
<when test="type == 6">
|
|
<include refid="fqjxgnzll"></include>
|
|
</when>
|
|
<when test="type == 7">
|
|
<include refid="fqjDPT90"></include>
|
|
</when>
|
|
<when test="type == 8">
|
|
<include refid="fqjDPT60"></include>
|
|
</when>
|
|
<when test="type == 9">
|
|
<include refid="fqjPRT60"></include>
|
|
</when>
|
|
<when test="type == 10">
|
|
<include refid="fqjPRT30"></include>
|
|
</when>
|
|
</choose>
|
|
)t on h.detail_id = t.detail_id
|
|
LEFT JOIN t_qcp_questionnaire_detail d on h.detail_id = d.id and rec_status = 0
|
|
WHERE
|
|
d.submit_status = 1
|
|
<if test="type == 4">
|
|
ORDER BY `value`
|
|
</if>
|
|
<if test="type != 4">
|
|
ORDER BY `value` DESC
|
|
</if>
|
|
</select>
|
|
|
|
<sql id="nnt">
|
|
SELECT
|
|
a1.detail_id as detail_id,
|
|
convert((a1.answer / a2.answer)*100,decimal(15,0)) as count
|
|
FROM
|
|
(
|
|
SELECT
|
|
questionnaire_detail_id as detail_id,
|
|
answer
|
|
FROM `t_qcp_questionnaire_record`
|
|
WHERE question_code = 'actual-Nnt' and rec_status = 0
|
|
)a1,
|
|
(
|
|
SELECT
|
|
questionnaire_detail_id as detail_id,
|
|
answer
|
|
FROM `t_qcp_questionnaire_record`
|
|
WHERE question_code = 'AIS-Nnt' and rec_status = 0
|
|
)a2
|
|
WHERE
|
|
a1.detail_id = a2.detail_id
|
|
</sql>
|
|
<sql id="dnt45">
|
|
SELECT
|
|
a1.detail_id as detail_id,
|
|
convert((a1.answer / (a1.answer + a2.answer + a3.answer))*100,decimal(15,0)) as count
|
|
FROM
|
|
(SELECT
|
|
questionnaire_detail_id as detail_id,
|
|
answer
|
|
FROM `t_qcp_questionnaire_record`
|
|
WHERE question_code = '45-Nnt' and rec_status = 0)a1,
|
|
(SELECT
|
|
questionnaire_detail_id as detail_id,
|
|
answer
|
|
FROM `t_qcp_questionnaire_record`
|
|
WHERE question_code = '60-Nnt' and rec_status = 0)a2,
|
|
(SELECT
|
|
questionnaire_detail_id as detail_id,
|
|
answer
|
|
FROM `t_qcp_questionnaire_record`
|
|
WHERE question_code = '61-Nnt' and rec_status = 0)a3
|
|
WHERE
|
|
a1.detail_id = a2.detail_id
|
|
and a2.detail_id = a3.detail_id
|
|
and a1.detail_id = a3.detail_id
|
|
</sql>
|
|
<sql id="dnt60">
|
|
SELECT
|
|
a1.detail_id as detail_id,
|
|
convert(((a1.answer + a2.answer) / (a1.answer + a2.answer + a3.answer))*100,decimal(15,0)) as count
|
|
FROM
|
|
(SELECT
|
|
questionnaire_detail_id as detail_id,
|
|
answer
|
|
FROM `t_qcp_questionnaire_record`
|
|
WHERE question_code = '45-Nnt' and rec_status = 0)a1,
|
|
(SELECT
|
|
questionnaire_detail_id as detail_id,
|
|
answer
|
|
FROM `t_qcp_questionnaire_record`
|
|
WHERE question_code = '60-Nnt' and rec_status = 0)a2,
|
|
(SELECT
|
|
questionnaire_detail_id as detail_id,
|
|
answer
|
|
FROM `t_qcp_questionnaire_record`
|
|
WHERE question_code = '61-Nnt' and rec_status = 0)a3
|
|
WHERE
|
|
a1.detail_id = a2.detail_id
|
|
and a2.detail_id = a3.detail_id
|
|
and a1.detail_id = a3.detail_id
|
|
</sql>
|
|
<sql id="sich">
|
|
SELECT
|
|
a1.detail_id AS detail_id,
|
|
CONVERT (
|
|
a1.answer * 100 / a2.answer,
|
|
DECIMAL (15, 0)
|
|
) AS count
|
|
FROM
|
|
(
|
|
SELECT
|
|
questionnaire_detail_id AS detail_id,
|
|
answer
|
|
FROM
|
|
`t_qcp_questionnaire_record`
|
|
WHERE
|
|
question_code = 'sICH-Nnt'
|
|
AND rec_status = 0
|
|
) AS a1,
|
|
(
|
|
SELECT
|
|
questionnaire_detail_id AS detail_id,
|
|
answer
|
|
FROM
|
|
`t_qcp_questionnaire_record`
|
|
WHERE
|
|
question_code = 'actual-Nnt'
|
|
AND rec_status = 0
|
|
) AS a2
|
|
WHERE
|
|
a1.detail_id = a2.detail_id
|
|
</sql>
|
|
<sql id="qjxgnzll">
|
|
SELECT
|
|
a1.detail_id AS detail_id,
|
|
CONVERT (
|
|
a1.answer * 100 / a2.answer,
|
|
DECIMAL (15, 0)
|
|
) AS count
|
|
FROM
|
|
(
|
|
SELECT
|
|
questionnaire_detail_id AS detail_id,
|
|
answer
|
|
FROM
|
|
`t_qcp_questionnaire_record`
|
|
WHERE
|
|
question_code = 'XGZL-sICH-Nnt'
|
|
AND rec_status = 0
|
|
) AS a1,
|
|
(
|
|
SELECT
|
|
questionnaire_detail_id AS detail_id,
|
|
answer
|
|
FROM
|
|
`t_qcp_questionnaire_record`
|
|
WHERE
|
|
question_code = 'XGZL-RSH-Nnt'
|
|
AND rec_status = 0
|
|
) AS a2
|
|
WHERE
|
|
a1.detail_id = a2.detail_id
|
|
</sql>
|
|
<sql id="fqjxgnzll">
|
|
SELECT
|
|
a1.detail_id AS detail_id,
|
|
CONVERT (
|
|
a1.answer * 100 / a2.answer,
|
|
DECIMAL (15, 0)
|
|
) AS count
|
|
FROM
|
|
(
|
|
SELECT
|
|
questionnaire_detail_id AS detail_id,
|
|
answer
|
|
FROM
|
|
`t_qcp_questionnaire_record`
|
|
WHERE
|
|
question_code = 'XGZL-actual-Nnt'
|
|
AND rec_status = 0
|
|
) AS a1,
|
|
(
|
|
SELECT
|
|
questionnaire_detail_id AS detail_id,
|
|
answer
|
|
FROM
|
|
`t_qcp_questionnaire_record`
|
|
WHERE
|
|
question_code = 'XGZL-FIT-Nnt'
|
|
AND rec_status = 0
|
|
) AS a2
|
|
WHERE
|
|
a1.detail_id = a2.detail_id
|
|
</sql>
|
|
<sql id="fqjDPT90">
|
|
SELECT
|
|
a1.detail_id AS detail_id,
|
|
CONVERT (
|
|
a1.answer * 100 / (
|
|
a1.answer + a2.answer + a3.answer
|
|
),
|
|
DECIMAL (15, 0)
|
|
) AS count
|
|
FROM
|
|
(
|
|
SELECT
|
|
questionnaire_detail_id AS detail_id,
|
|
answer
|
|
FROM
|
|
`t_qcp_questionnaire_record`
|
|
WHERE
|
|
question_code = 'XGZL-DPT-60'
|
|
AND rec_status = 0
|
|
) AS a1,
|
|
(
|
|
SELECT
|
|
questionnaire_detail_id AS detail_id,
|
|
answer
|
|
FROM
|
|
`t_qcp_questionnaire_record`
|
|
WHERE
|
|
question_code = 'XGZL-DPT-89'
|
|
AND rec_status = 0
|
|
) AS a2,
|
|
(
|
|
SELECT
|
|
questionnaire_detail_id AS detail_id,
|
|
answer
|
|
FROM
|
|
`t_qcp_questionnaire_record`
|
|
WHERE
|
|
question_code = 'XGZL-DPT-91'
|
|
AND rec_status = 0
|
|
) AS a3
|
|
WHERE
|
|
a1.detail_id = a2.detail_id
|
|
and a2.detail_id = a3.detail_id
|
|
and a1.detail_id = a3.detail_id
|
|
</sql>
|
|
<sql id="fqjDPT60">
|
|
SELECT
|
|
a1.detail_id AS detail_id,
|
|
CONVERT (
|
|
(a1.answer + a2.answer) / (
|
|
a1.answer + a2.answer + a3.answer
|
|
) * 100,
|
|
DECIMAL (15, 0)
|
|
) AS count
|
|
FROM
|
|
(
|
|
SELECT
|
|
questionnaire_detail_id AS detail_id,
|
|
answer
|
|
FROM
|
|
`t_qcp_questionnaire_record`
|
|
WHERE
|
|
question_code = 'XGZL-DPT-60'
|
|
AND rec_status = 0
|
|
) AS a1,
|
|
(
|
|
SELECT
|
|
questionnaire_detail_id AS detail_id,
|
|
answer
|
|
FROM
|
|
`t_qcp_questionnaire_record`
|
|
WHERE
|
|
question_code = 'XGZL-DPT-89'
|
|
AND rec_status = 0
|
|
) AS a2,
|
|
(
|
|
SELECT
|
|
questionnaire_detail_id AS detail_id,
|
|
answer
|
|
FROM
|
|
`t_qcp_questionnaire_record`
|
|
WHERE
|
|
question_code = 'XGZL-DPT-91'
|
|
AND rec_status = 0
|
|
) AS a3
|
|
WHERE
|
|
a1.detail_id = a2.detail_id
|
|
and a2.detail_id = a3.detail_id
|
|
and a1.detail_id = a3.detail_id
|
|
</sql>
|
|
<sql id="fqjPRT60">
|
|
SELECT
|
|
a1.detail_id AS detail_id,
|
|
CONVERT (
|
|
(a1.answer + a2.answer) / (
|
|
a1.answer + a2.answer + a3.answer
|
|
) * 100,
|
|
DECIMAL (15, 0)
|
|
) AS count
|
|
FROM
|
|
(
|
|
SELECT
|
|
questionnaire_detail_id AS detail_id,
|
|
answer
|
|
FROM
|
|
`t_qcp_questionnaire_record`
|
|
WHERE
|
|
question_code = 'XGZL-PRT-29'
|
|
AND rec_status = 0
|
|
) AS a1,
|
|
(
|
|
SELECT
|
|
questionnaire_detail_id AS detail_id,
|
|
answer
|
|
FROM
|
|
`t_qcp_questionnaire_record`
|
|
WHERE
|
|
question_code = 'XGZL-PRT-59'
|
|
AND rec_status = 0
|
|
) AS a2,
|
|
(
|
|
SELECT
|
|
questionnaire_detail_id AS detail_id,
|
|
answer
|
|
FROM
|
|
`t_qcp_questionnaire_record`
|
|
WHERE
|
|
question_code = 'XGZL-PRT-62'
|
|
AND rec_status = 0
|
|
) AS a3
|
|
WHERE
|
|
a1.detail_id = a2.detail_id
|
|
and a2.detail_id = a3.detail_id
|
|
and a1.detail_id = a3.detail_id
|
|
</sql>
|
|
<sql id="fqjPRT30">
|
|
SELECT
|
|
a1.detail_id AS detail_id,
|
|
CONVERT (
|
|
a1.answer / (
|
|
a1.answer + a2.answer + a3.answer
|
|
) * 100,
|
|
DECIMAL (15, 0)
|
|
) AS count
|
|
FROM
|
|
(
|
|
SELECT
|
|
questionnaire_detail_id AS detail_id,
|
|
answer
|
|
FROM
|
|
`t_qcp_questionnaire_record`
|
|
WHERE
|
|
question_code = 'XGZL-PRT-29'
|
|
AND rec_status = 0
|
|
) AS a1,
|
|
(
|
|
SELECT
|
|
questionnaire_detail_id AS detail_id,
|
|
answer
|
|
FROM
|
|
`t_qcp_questionnaire_record`
|
|
WHERE
|
|
question_code = 'XGZL-PRT-59'
|
|
AND rec_status = 0
|
|
) AS a2,
|
|
(
|
|
SELECT
|
|
questionnaire_detail_id AS detail_id,
|
|
answer
|
|
FROM
|
|
`t_qcp_questionnaire_record`
|
|
WHERE
|
|
question_code = 'XGZL-PRT-62'
|
|
AND rec_status = 0
|
|
) AS a3
|
|
WHERE
|
|
a1.detail_id = a2.detail_id
|
|
and a2.detail_id = a3.detail_id
|
|
and a1.detail_id = a3.detail_id
|
|
</sql>
|
|
|
|
<select id="queryUserIsExist" resultType="java.lang.Integer">
|
|
SELECT
|
|
COUNT( id )
|
|
FROM
|
|
t_organization_member_position
|
|
WHERE
|
|
rec_status = 0
|
|
AND member_id = ( SELECT id FROM t_organization_member WHERE rec_status = 0 AND user_id = #{userId} )
|
|
AND position_id = (
|
|
SELECT
|
|
op.id
|
|
FROM
|
|
t_organization_position AS op,
|
|
t_organization_department AS od,
|
|
t_organization AS o
|
|
WHERE
|
|
op.department_id = od.id
|
|
AND od.organization_id = o.id
|
|
AND op.rec_status = 0
|
|
AND od.rec_status = 0
|
|
AND o.rec_status = 0
|
|
AND o.`name` = #{name}
|
|
AND od.`name` = #{departmentName}
|
|
AND op.`name` = #{positionName}
|
|
)
|
|
</select>
|
|
|
|
<select id="queryDepartmentByUser" resultType="java.lang.Long">
|
|
SELECT DISTINCT
|
|
d.id
|
|
FROM
|
|
t_organization_member_position AS mp
|
|
LEFT JOIN t_organization_position AS p ON mp.position_id = p.id
|
|
LEFT JOIN t_organization_member AS m ON m.id = mp.member_id
|
|
LEFT JOIN t_organization_department AS d ON p.department_id = d.id
|
|
WHERE
|
|
mp.rec_status = 0
|
|
AND p.rec_status = 0
|
|
AND m.rec_status = 0
|
|
AND d.rec_status = 0
|
|
AND d.organization_id = #{projectId}
|
|
AND m.user_id = #{userId}
|
|
</select>
|
|
</mapper>
|
|
|