Files
dc_project/src/main/resources/mapper/RecordEntrustMapper.xml
2025-11-13 17:38:10 +08:00

34 lines
1.5 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.dc.dc_project.mapper.RecordEntrustMapper">
<sql id="Base_Column_List">
id,entrust_no,org_id,client_name,entrust_date,contact_name,
contact_phone,sample_name,sample_code,sample_type,receive_date,
test_type,status,remark,created_by,updated_by,
created_at,updated_at,is_deleted
</sql>
<select id="getCountByTime" resultType="java.lang.Long">
select count(*) from sys_record_entrust where entrust_date between #{startTime} and #{endTime}
</select>
<select id="getCountByTimeGroupE" resultType="com.dc.dc_project.model.vo.bigScreen.RecordStatisticsVo">
SELECT
p.id AS engineering_id,
p.engineering_name AS engineering_name,
COUNT(DISTINCT e.id) AS entrust_count,
COUNT(r.id) AS report_count,
SUM(CASE WHEN r.conclusion = '不合格' OR r.conclusion LIKE '%不合格%' THEN 1 ELSE 0 END) AS unqualified_count
FROM sys_record_engineering p
LEFT JOIN sys_record_entrust e ON p.id = e.engineering_id
LEFT JOIN sys_record_report r ON e.id = r.entrust_id
<where>
e.create_time &gt;= #{startTimeStr}
AND e.create_time &lt;= #{endTimeStr}
</where>
GROUP BY p.id, p.engineering_name
ORDER BY entrust_count DESC;
</select>
</mapper>