mental-health-api/ruoyi-modules/rouyi-scale/src/main/resources/mapper/scale/StatisticMapper.xml

55 lines
2.6 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="org.dromara.scale.mapper.StatisticMapper">
<select id="selectCompleteAvaluation" resultType="org.dromara.scale.domain.vo.StatisticNumVo">
select d.dept_name,
parent.dept_name as `parentName`,
count(if(er.status = 1, 1, null)) as `value`,
count(if(er.status = 0, 1, null)) as `spareValue`
from sys_evaluation_record er
left join sys_dept d on d.dept_id = er.dept_id
left join sys_dept parent on parent.dept_id = d.parent_id
where er.batch_no = #{batchNo}
and er.scale_id = #{scaleId}
group by d.dept_id
</select>
<select id="selectStatisticWarn" resultType="org.dromara.scale.domain.vo.StatisticWarnVo">
select d.dept_name,
parent.dept_name as `parentName`,
count(if(sfr.situation = 1, 1, null)) as `noneNum`,
count(if(sfr.situation = 2, 1, null)) as `lowNum`,
count(if(sfr.situation = 3, 1, null)) as `middleNum`,
count(if(sfr.situation = 4, 1, null)) as `highNum`,
count(if(sfr.situation = 5, 1, null)) as `majorNum`
from sys_evaluation_record er
left join sys_dept d on d.dept_id = er.dept_id
left join sys_dept parent on parent.dept_id = d.parent_id
left join sys_evaluation_conclusion ec on ec.record_id = er.record_id
left join sys_scale_factor_range sfr on sfr.range_id = ec.factor_range_id
where er.batch_no = #{batchNo}
and er.scale_id = #{scaleId}
and er.status = 1
and ec.status = 1
group by d.dept_id
</select>
<select id="selectStatisticFactor" resultType="org.dromara.scale.domain.vo.StatisticFactorVo">
select sfr.range_name as `factorName`,
d.dept_name,
parent.dept_name as `parentName`
from sys_evaluation_record er
left join sys_dept d on d.dept_id = er.dept_id
left join sys_dept parent on parent.dept_id = d.parent_id
left join sys_evaluation_conclusion ec on ec.record_id = er.record_id
left join sys_scale_factor_range sfr on sfr.range_id = ec.factor_range_id
where er.batch_no = #{batchNo}
and er.scale_id = #{scaleId}
and er.status = 1
and ec.status = 1
</select>
</mapper>