<?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.ruoyi.report.mapper.SampleProgressMapper">
|
|
<!-- 分页查询样品进度 -->
|
<select id="pageSampleProgress" resultType="com.ruoyi.report.vo.SampleProgressVo">
|
SELECT
|
s.id AS sampleId,
|
o.entrust_code AS entrustCode,
|
s.sample_code AS sampleCode,
|
s.sample AS sampleName,
|
r.code AS reportCode,
|
o.ins_state AS insState,
|
COUNT(p.id) AS totalItems,
|
SUM(CASE WHEN p.ins_result IS NOT NULL THEN 1 ELSE 0 END) AS finishedItems,
|
o.appointed AS planFinishTime,
|
o.ins_time AS actualFinishTime,
|
u.name AS chargeUser,
|
o.custom AS custom,
|
s.create_time AS createTime
|
FROM ins_sample s
|
LEFT JOIN ins_order o ON s.ins_order_id = o.id
|
LEFT JOIN ins_product p ON s.id = p.ins_sample_id
|
LEFT JOIN ins_report r ON o.id = r.ins_order_id
|
LEFT JOIN user u ON o.prepare_user_id = u.id
|
WHERE 1=1
|
<if test="dto.entrustCode != null and dto.entrustCode != ''">
|
AND o.entrust_code LIKE CONCAT('%', #{dto.entrustCode}, '%')
|
</if>
|
<if test="dto.sampleCode != null and dto.sampleCode != ''">
|
AND s.sample_code LIKE CONCAT('%', #{dto.sampleCode}, '%')
|
</if>
|
<if test="dto.sampleName != null and dto.sampleName != ''">
|
AND s.sample LIKE CONCAT('%', #{dto.sampleName}, '%')
|
</if>
|
<if test="dto.reportCode != null and dto.reportCode != ''">
|
AND r.code LIKE CONCAT('%', #{dto.reportCode}, '%')
|
</if>
|
<if test="dto.insState != null">
|
AND o.ins_state = #{dto.insState}
|
</if>
|
<if test="dto.custom != null and dto.custom != ''">
|
AND o.custom LIKE CONCAT('%', #{dto.custom}, '%')
|
</if>
|
<if test="dto.startTime != null and dto.startTime != ''">
|
AND s.create_time >= #{dto.startTime}
|
</if>
|
<if test="dto.endTime != null and dto.endTime != ''">
|
AND s.create_time <= #{dto.endTime}
|
</if>
|
GROUP BY s.id
|
ORDER BY s.create_time DESC
|
</select>
|
|
<!-- 获取统计数据 -->
|
<select id="getStatistics" resultType="java.util.Map">
|
SELECT
|
SUM(CASE WHEN o.ins_state = 0 THEN 1 ELSE 0 END) AS waitInspection,
|
SUM(CASE WHEN o.ins_state = 1 THEN 1 ELSE 0 END) AS inspecting,
|
SUM(CASE WHEN o.ins_state = 3 THEN 1 ELSE 0 END) AS waitAudit,
|
SUM(CASE WHEN o.ins_state = 5 THEN 1 ELSE 0 END) AS finished
|
FROM ins_sample s
|
LEFT JOIN ins_order o ON s.ins_order_id = o.id
|
WHERE 1=1
|
<if test="dto.custom != null and dto.custom != ''">
|
AND o.custom LIKE CONCAT('%', #{dto.custom}, '%')
|
</if>
|
<if test="dto.startTime != null and dto.startTime != ''">
|
AND s.create_time >= #{dto.startTime}
|
</if>
|
<if test="dto.endTime != null and dto.endTime != ''">
|
AND s.create_time <= #{dto.endTime}
|
</if>
|
</select>
|
|
<!-- 获取图表数据 -->
|
<select id="getChartData" resultType="java.util.Map">
|
SELECT
|
DATE_FORMAT(s.create_time, '%Y-%m-%d') AS date,
|
COUNT(*) AS totalCount,
|
SUM(CASE WHEN o.ins_state = 5 THEN 1 ELSE 0 END) AS finishedCount
|
FROM ins_sample s
|
LEFT JOIN ins_order o ON s.ins_order_id = o.id
|
WHERE 1=1
|
<if test="dto.custom != null and dto.custom != ''">
|
AND o.custom LIKE CONCAT('%', #{dto.custom}, '%')
|
</if>
|
<if test="dto.startTime != null and dto.startTime != ''">
|
AND s.create_time >= #{dto.startTime}
|
</if>
|
<if test="dto.endTime != null and dto.endTime != ''">
|
AND s.create_time <= #{dto.endTime}
|
</if>
|
GROUP BY DATE_FORMAT(s.create_time, '%Y-%m-%d')
|
ORDER BY date ASC
|
</select>
|
|
</mapper>
|