lis8.0/liswork/src/main/resources/mapper/QcGraphMapper.xml

93 lines
6.9 KiB
XML
Raw Normal View History

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>
<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)
<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>
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
order by xm_info.dyxh
</select>
<select id="queryMonthst2" resultType="com.czlis.liswork.pojo.DTO.QcMonthstDTO">
SELECT qc_val.yq,qc_val.xmdh,qc_val.zkph,count(1) cnt,cast(avg(zkjg) as decimal(12, 3)) avg2,
cast(STDEV(zkjg) as decimal(12, 3)) sd2,cast(100*STDEV(zkjg)/avg(zkjg) as decimal(12, 3)) as cv2
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 convert(char(8),zkrq,120) = convert(char(8),#{zkrq} ,120)
and (zkbz + 3*sd)>qc_val.zkjg and qc_val.zkjg>(zkbz - 3*sd) and isnull(outreason,'')=''
and qc_val.yq=#{yq} and qc_val.zkph=#{zkph}
group by qc_val.yq,qc_val.zkph,qc_val.xmdh
</select>
<select id="queryMonthst3" resultType="com.czlis.liswork.pojo.DTO.QcMonthstDTO">
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
FROM qc_val where zkrq>=(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 convert(datetime,convert(char(8),#{zkrq},120)+'01') >=x.ksrq)
and isnull((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 x.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 convert(datetime,convert(char(8),#{zkrq},120)+'01')>=x.ksrq ) and convert(datetime,convert(char(8),DATEADD(month,1,#{zkrq}),120)+'01')>=x.ksrq ),convert(datetime,convert(char(8),DATEADD(month,1,#{zkrq}),120)+'01') )>zkrq
and qc_val.yq=#{yq} and qc_val.zkph=#{zkph}
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>