2026-01-26 17:41:11 +08:00
<?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.czlis.liswork.mapper.QcGraphMapper" >
<select id= "querysample" resultType= "com.czlis.common.core.domain.entity.lis.QcSample" >
select * from qc_sample
<where >
<if test= "yq != null and yq !=''" > and yq = #{yq}</if>
<if test= "xmdh != null and xmdh !=''" > and xmdh = #{xmdh}</if>
<if test= "zkph != null and zkph !=''" > and zkph = #{zkph}</if>
<if test= "zkpph != null and zkpph !=''" > and zkpph = #{zkpph}</if>
<if test= "yq != null and yq !=''" > and yq = #{yq}</if>
<if test= "yq != null and yq !=''" > and yq = #{yq}</if>
<if test= "zkrq1 != null" > and ksrq >=(select max(ksrq) from qc_sample x where x.yq=qc_sample.yq and x.xmdh=qc_sample.xmdh and x.zkph=qc_sample.zkph and #{zkrq1}>=x.ksrq)</if>
<if test= "zkrq2 != null" > and #{zkrq2}>= ksrq </if>
</where>
and xmdh not in('_pj_','_skxj_') and (zkph not like '%bz' )
order by yq,xmdh,ksrq,zkph
</select>
<select id= "query" resultType= "com.czlis.liswork.pojo.DTO.QcValDTO" >
SELECT qc_val.yq,qc_val.xmdh,xm_info.xmmc,xm_info.dyxh,qc_val.zkph,
qc_val.cs,qc_val.zkrq,qc_val.zkjg,isnull((select yhxm from com_usr where com_usr.yhdh=qc_val.yhdh),qc_val.yhdh) as yhdh,
qc_sample.zkbz,qc_sample.sd,qc_sample.cv
FROM qc_val join xm_info on xm_info.yq=qc_val.yq and xm_info.xmdh=qc_val.xmdh
join qc_sample on qc_sample.yq=qc_val.yq and qc_sample.xmdh=qc_val.xmdh and qc_sample.zkph=qc_val.zkph
and qc_sample.ksrq=(select max(ksrq) from qc_sample x
where x.yq=qc_val.yq and x.xmdh=qc_val.xmdh and x.zkph=qc_val.zkph and qc_val.zkrq>=x.ksrq)
<where >
<if test= "yq != null and yq !=''" > and qc_val.yq = #{yq}</if>
<if test= "xmdh != null and xmdh !=''" > and qc_val.xmdh = #{xmdh}</if>
<if test= "zkph != null and zkph !=''" > and qc_val.zkph = #{zkph}</if>
<if test= "zkpph != null and zkpph !=''" > and qc_sample.zkpph = #{zkpph}</if>
<if test= "zkrq1 != null" > and qc_val.ksrq>= #{zkrq1} </if>
<if test= "zkrq2 != null" > and #{zkrq2}>= qc_val.ksrq </if>
<if test= "cs != null and cs !=10" > and qc_val.cs = #{cs}</if>
</where>
order by qc_val.zkrq,qc_val.cs
</select>
2026-01-27 18:01:21 +08:00
<select id= "query8" resultType= "com.czlis.liswork.pojo.DTO.QcValDTO" >
SELECT qc_val.yq,qc_val.xmdh,xm_info.xmmc,xm_info.dyxh,qc_val.zkph,
qc_val.cs,qc_val.zkrq,qc_val.zkjg,isnull((select yhxm from com_usr where com_usr.yhdh=qc_val.yhdh),qc_val.yhdh) as yhdh,
qc_sample.zkbz,qc_sample.sd,qc_sample.cv
FROM qc_val join xm_info on xm_info.yq=qc_val.yq and xm_info.xmdh=qc_val.xmdh
join qc_sample on qc_sample.yq=qc_val.yq and qc_sample.xmdh=qc_val.xmdh and qc_sample.zkph=qc_val.zkph
and qc_sample.ksrq=(select max(ksrq) from qc_sample x
where x.yq=qc_val.yq and x.xmdh=qc_val.xmdh and x.zkph=qc_val.zkph and qc_val.zkrq>=x.ksrq)
<where >
<if test= "yq != null and yq !=''" > and qc_val.yq = #{yq}</if>
<if test= "xmdh != null and xmdh !=''" > and qc_val.xmdh = #{xmdh}</if>
<if test= "zkph != null and zkph !=''" > and qc_val.zkph = #{zkph}</if>
<if test= "zkpph != null and zkpph !=''" > and qc_sample.zkpph = #{zkpph}</if>
<if test= "zkrq1 != null" > and qc_val.ksrq>= #{zkrq1} </if>
<if test= "zkrq2 != null" > and #{zkrq2}>= qc_val.ksrq </if>
<if test= "cs != null and cs !=10" > and qc_val.cs =(select max(cs) from qc_val a where a.yq=qc_val.yq and a.xmdh=qc_val.xmdh and a.zkph=qc_val.zkph and a.zkrq=qc_val.zkrq) </if>
</where>
order by qc_val.zkrq,qc_val.cs
</select>
<select id= "query9" resultType= "com.czlis.liswork.pojo.DTO.QcValDTO" >
SELECT qc_val.yq,qc_val.xmdh,xm_info.xmmc,xm_info.dyxh,qc_val.zkph,
qc_val.cs,qc_val.zkrq,qc_val.zkjg,isnull((select yhxm from com_usr where com_usr.yhdh=qc_val.yhdh),qc_val.yhdh) as yhdh,
qc_sample.zkbz,qc_sample.sd,qc_sample.cv
FROM qc_val join xm_info on xm_info.yq=qc_val.yq and xm_info.xmdh=qc_val.xmdh
join qc_sample on qc_sample.yq=qc_val.yq and qc_sample.xmdh=qc_val.xmdh and qc_sample.zkph=qc_val.zkph
and qc_sample.ksrq=(select max(ksrq) from qc_sample x
where x.yq=qc_val.yq and x.xmdh=qc_val.xmdh and x.zkph=qc_val.zkph and qc_val.zkrq>=x.ksrq)
<where >
<if test= "yq != null and yq !=''" > and qc_val.yq = #{yq}</if>
<if test= "xmdh != null and xmdh !=''" > and qc_val.xmdh = #{xmdh}</if>
<if test= "zkph != null and zkph !=''" > and qc_val.zkph = #{zkph}</if>
<if test= "zkpph != null and zkpph !=''" > and qc_sample.zkpph = #{zkpph}</if>
<if test= "zkrq1 != null" > and qc_val.ksrq>= #{zkrq1} </if>
<if test= "zkrq2 != null" > and #{zkrq2}>= qc_val.ksrq </if>
<if test= "cs != null and cs !=10" > and abs(qc_sample.zkbz - qc_val.zkjg)=(select min(abs(qc_sample.zkbz - a.zkjg)) from qc_val a where a.yq=qc_val.yq and a.xmdh=qc_val.xmdh and a.zkph=qc_val.zkph and a.zkrq=qc_val.zkrq) </if>
</where>
order by qc_val.zkrq,qc_val.cs
</select>
<select id= "query0" resultType= "com.czlis.liswork.pojo.DTO.QcValDTO" >
SELECT qc_val.yq,qc_val.xmdh,xm_info.xmmc,xm_info.dyxh,qc_val.zkph,
0 as cs,qc_val.zkrq,a.zkjg,isnull((select yhxm from com_usr where com_usr.yhdh=qc_val.yhdh),qc_val.yhdh) as yhdh,
qc_sample.zkbz,qc_sample.sd,qc_sample.cv
FROM qc_val join xm_info on xm_info.yq=qc_val.yq and xm_info.xmdh=qc_val.xmdh
join (select qc_val.yq,qc_val.zkph,qc_val.xmdh,qc_val.zkrq,avg(zkjg)as zkjg from qc_val
group by qc_val.yq,qc_val.zkph,qc_val.xmdh,qc_val.zkrq) a
on a.yq=qc_val.yq and a.xmdh=qc_val.xmdh and a.zkph=qc_val.zkph and a.zkrq=qc_val.zkrq
join qc_sample on qc_sample.yq=qc_val.yq and qc_sample.xmdh=qc_val.xmdh and qc_sample.zkph=qc_val.zkph
and qc_sample.ksrq=(select max(ksrq) from qc_sample x
where x.yq=qc_val.yq and x.xmdh=qc_val.xmdh and x.zkph=qc_val.zkph and qc_val.zkrq>=x.ksrq)
<where >
<if test= "yq != null and yq !=''" > and qc_val.yq = #{yq}</if>
<if test= "xmdh != null and xmdh !=''" > and qc_val.xmdh = #{xmdh}</if>
<if test= "zkph != null and zkph !=''" > and qc_val.zkph = #{zkph}</if>
<if test= "zkpph != null and zkpph !=''" > and qc_sample.zkpph = #{zkpph}</if>
<if test= "zkrq1 != null" > and qc_val.ksrq>= #{zkrq1} </if>
<if test= "zkrq2 != null" > and #{zkrq2}>= qc_val.ksrq </if>
<if test= "cs != null and cs !=10" > and qc_val.cs =1</if>
</where>
order by qc_val.zkrq,qc_val.cs
</select>
2026-01-26 17:41:11 +08:00
<select id= "queryhead" resultType= "com.czlis.liswork.pojo.DTO.QcMonthstDTO" >
SELECT qc_val.yq,qc_val.xmdh,xm_info.xmmc,xm_info.dyxh,qc_val.zkph,count(1) cnt,
sum((case when qc_val.zkjg>(zkbz + 3*sd) then 1 when (zkbz - 3*sd)>qc_val.zkjg then 1 when isnull(outreason,'')!='' then 1 else 0 end) ) as badcnt,
sum(case when isnull(bz,'')!='' then 1 else 0 end) as process,
cast(qc_sample.zkbz as decimal(12, 3)) as avg0,
cast(qc_sample.sd as decimal(12, 3)) as sd0,
cast(qc_sample.cv as decimal(12, 3)) as cv0,
cast(avg(zkjg) as decimal(12, 3)) avg1,
cast(STDEV(zkjg) as decimal(12, 3)) sd1,
cast(100*STDEV(zkjg)/avg(zkjg) as decimal(12, 3)) as cv1,
max(qc_sample.zkpph) as zkpph,
max(isnull(qc_sample.qccv,xm_info.qccv)) as qccv,
max(qc_sample.ld) as ld
FROM qc_val join xm_info on xm_info.yq=qc_val.yq and xm_info.xmdh=qc_val.xmdh
join qc_sample on qc_sample.yq=qc_val.yq and qc_sample.xmdh=qc_val.xmdh and qc_sample.zkph=qc_val.zkph
and qc_sample.ksrq=(select max(ksrq) from qc_sample x where x.yq=qc_val.yq and x.xmdh=qc_val.xmdh and x.zkph=qc_val.zkph and qc_val.zkrq>=x.ksrq)
2026-01-27 18:01:21 +08:00
<where >
2026-01-26 17:41:11 +08:00
<if test= "yq != null and yq !=''" > and qc_val.yq = #{yq}</if>
<if test= "xmdh != null and xmdh !=''" > and qc_val.xmdh = #{xmdh}</if>
<if test= "zkph != null and zkph !=''" > and qc_val.zkph = #{zkph}</if>
<if test= "zkpph != null and zkpph !=''" > and qc_sample.zkpph = #{zkpph}</if>
<if test= "zkrq1 != null" > and qc_val.ksrq>= #{zkrq1} </if>
<if test= "zkrq2 != null" > and #{zkrq2}>= qc_val.ksrq </if>
<if test= "cs != null and cs !=10" > and qc_val.cs = #{cs}</if>
2026-01-27 18:01:21 +08:00
</where>
2026-01-26 17:41:11 +08:00
group by qc_val.yq,qc_val.zkph,qc_val.xmdh,xm_info.xmmc,xm_info.dyxh,qc_sample.zkbz,qc_sample.sd,qc_sample.cv
2026-01-27 18:01:21 +08:00
order by xm_info.dyxh,qc_val.zkph
2026-01-26 17:41:11 +08:00
</select>
2026-01-27 18:01:21 +08:00
<select id= "queryhead3" resultType= "com.czlis.liswork.pojo.DTO.QcMonthstDTO" >
2026-01-26 17:41:11 +08:00
SELECT qc_val.yq,qc_val.xmdh,qc_val.zkph,count(1) cnt3,cast(avg(zkjg) as decimal(12, 3)) avg3,
cast(STDEV(zkjg) as decimal(12, 3)) sd3,cast(100*STDEV(zkjg)/avg(zkjg) as decimal(12, 3)) as cv3
2026-01-27 18:01:21 +08:00
FROM qc_val join qc_sample on qc_sample.yq=qc_val.yq and qc_sample.xmdh=qc_val.xmdh and qc_sample.zkph=qc_val.zkph
and qc_sample.ksrq=(select max(ksrq) from qc_sample x where x.yq=qc_val.yq and x.xmdh=qc_val.xmdh and x.zkph=qc_val.zkph and qc_val.zkrq>=x.ksrq)
join qc_sample s on s.yq=qc_val.yq and s.xmdh=qc_val.xmdh and s.zkph=qc_val.zkph
and s.ksrq=isnull((select max(ksrq) from qc_sample x where x.yq=qc_val.yq and x.xmdh=qc_val.xmdh and x.zkph=qc_val.zkph and #{zkrq1}>=x.ksrq),(select min(ksrq) from qc_sample x where x.yq=qc_val.yq and x.xmdh=qc_val.xmdh and x.zkph=qc_val.zkph and #{zkrq2}>=x.ksrq and x.ksrq>=#{zkrq1}))
<where >
<if test= "yq != null and yq !=''" > and qc_val.yq = #{yq}</if>
<if test= "xmdh != null and xmdh !=''" > and qc_val.xmdh = #{xmdh}</if>
<if test= "zkph != null and zkph !=''" > and qc_val.zkph = #{zkph}</if>
2026-01-27 18:18:29 +08:00
<if test= "zkrq1 != null" > and qc_val.zkrq>=(select min(ksrq) from qc_sample x where x.yq=qc_val.yq and x.xmdh=qc_val.xmdh and x.zkph=qc_val.zkph and qc_sample.zkpph=x.zkpph)</if>
<if test= "zkrq2 != null" > and #{zkrq2}>= qc_val.zkrq </if>
2026-01-27 18:01:21 +08:00
</where>
and qc_sample.zkpph=s.zkpph
2026-01-26 17:41:11 +08:00
group by qc_val.yq,qc_val.zkph,qc_val.xmdh
</select>
<select id= "queryMonthskzj" resultType= "String" >
select bz1 FROM qc_val where ksrq=convert(datetime,convert(char(8),#{zkrq},120)+'01') and xmdh='_skxj_'
and qc_val.yq=#{yq} and qc_val.zkph=#{zkph}
</select>
<select id= "queryMonthpj" resultType= "String" >
select bz1 FROM qc_val where ksrq=convert(datetime,convert(char(8),#{zkrq},120)+'01') and xmdh='_pj_'
and qc_val.yq=#{yq} and qc_val.zkph=#{zkph}
</select>
</mapper>