You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

238 lines
8.2 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.op.quality.mapper.QcInterfaceMapper">
<select id="getDictData" resultType="com.op.quality.domain.QcInterface">
select dict_label ymdTypeName,
dict_value ymdType
from sys_dict_data
where dict_type = #{dictType} and status = '0'
</select>
<select id="getOverallInfo" resultType="com.op.quality.domain.QcInterface">
select count(0) quality,'all' ymdTypeName
from wms_raw_order_in
where active_flag = '1'
<if test='ymdType=="yyyy"'>
and CONVERT(varchar(4),receipt_time, 120) = SUBSTRING(#{ymd},0,5)
</if>
<if test='ymdType=="mm"'>
and CONVERT(varchar(7),receipt_time, 120) =SUBSTRING(#{ymd},0,8)
</if>
<if test='ymdType=="dd"'>
and CONVERT(varchar(10),receipt_time, 120) = SUBSTRING(#{ymd},0,11)
</if>
union ALL
select count(0),'unOk'
from qc_check_unqualified qcu
left join qc_check_type qct on qcu.type = qct.order_code
where qct.type_code = #{typeCode} and qcu.del_flag = '0'
<if test='ymdType=="yyyy"'>
and CONVERT(varchar(4),qcu.create_time, 120) = SUBSTRING(#{ymd},0,5)
</if>
<if test='ymdType=="mm"'>
and CONVERT(varchar(7),qcu.create_time, 120) = SUBSTRING(#{ymd},0,8)
</if>
<if test='ymdType=="dd"'>
and CONVERT(varchar(10),qcu.create_time, 120) = SUBSTRING(#{ymd},0,11)
</if>
</select>
<select id="getCheckProjectsPie" resultType="com.op.quality.domain.QcInterface">
select count(0) quality,
qctd.project_no,
qctd.rule_name projectName
from qc_check_task_detail qctd
left join qc_check_task qct on qctd.belong_to = qct.record_id
where qct.check_result = 'N' and qct.type_code = #{typeCode}
<if test='ymdType=="yyyy"'>
and CONVERT(varchar(4),qctd.update_time, 120) = SUBSTRING(#{ymd},0,5)
</if>
<if test='ymdType=="mm"'>
and CONVERT(varchar(7),qcu.update_time, 120) = SUBSTRING(#{ymd},0,8)
</if>
<if test='ymdType=="dd"'>
and CONVERT(varchar(10),qcu.update_time, 120) = SUBSTRING(#{ymd},0,11)
</if>
group by qctd.project_no,qctd.rule_name
</select>
<select id="getSupplierBadTOP5" resultType="com.op.quality.domain.QcInterface">
select top 5 * from(
select
concat(t1.supplier_name,'-',t1.material_name) supplierName,
ROUND(t2.noOkNum*100.00/t1.allNum, 2) quality
from (
select count(0) allNum,
qct.supplier_code,qct.supplier_name,qct.material_code,qct.material_name
from qc_check_task qct
where qct.type_code = #{typeCode}
<if test='ymdType=="yyyy"'>
and CONVERT(varchar(4),qct.income_time, 120) = SUBSTRING(#{ymd},0,5)
</if>
<if test='ymdType=="mm"'>
and CONVERT(varchar(7),qct.income_time, 120) = SUBSTRING(#{ymd},0,8)
</if>
<if test='ymdType=="dd"'>
and CONVERT(varchar(10),qct.income_time, 120) = SUBSTRING(#{ymd},0,11)
</if>
group by
qct.supplier_code,qct.supplier_name,qct.material_code,qct.material_name
) t1
left join (
select
count(0) noOkNum,qct.supplier_code,qct.supplier_name,qct.material_code,qct.material_name
from qc_check_task qct
where qct.type_code = #{typeCode} and qct.check_result = 'N'
<if test='ymdType=="yyyy"'>
and CONVERT(varchar(4),qct.income_time, 120) = SUBSTRING(#{ymd},0,5)
</if>
<if test='ymdType=="mm"'>
and CONVERT(varchar(7),qct.income_time, 120) = SUBSTRING(#{ymd},0,8)
</if>
<if test='ymdType=="dd"'>
and CONVERT(varchar(10),qct.income_time, 120) = SUBSTRING(#{ymd},0,11)
</if>
group by
qct.supplier_code,qct.supplier_name,qct.material_code,qct.material_name
) t2 on t1.supplier_code = t2.supplier_code and t1.material_code = t2.material_code
) t order by t.quality desc
</select>
<select id="getSupplierTaskList" resultType="com.op.quality.domain.QcInterface">
select
qct.check_no checkNo,
qct.income_batch_no incomeBatchNo,
qct.order_no orderNo,
qct.material_name materialName,
qct.quality,
qct.unit,
qct.supplier_name supplierName,
qct.income_time incomeTime,
qct.check_status checkStatus,
qct.check_result checkResult,
qct.check_man_name checkManName,
qc.check_name checkName
from qc_check_task qct
left join qc_check_type qc on qct.check_type = qc.order_code
where qct.del_flag = '0' and qct.status = '1'
and qct.type_code = #{typeCode}
<if test='ymdType=="yyyy"'>
and CONVERT(varchar(4),qct.income_time, 120) = SUBSTRING(#{ymd},0,5)
</if>
<if test='ymdType=="mm"'>
and CONVERT(varchar(7),qct.income_time, 120) = SUBSTRING(#{ymd},0,8)
</if>
<if test='ymdType=="dd"'>
and CONVERT(varchar(10),qct.income_time, 120) = SUBSTRING(#{ymd},0,11)
</if>
order by qct.income_time desc,qct.check_status asc
</select>
<select id="getSupplierNoOkList" resultType="com.op.quality.domain.QcInterface">
select
qct.check_no checkNo,
qct.income_batch_no incomeBatchNo,
qct.order_no orderNo,
qct.material_name materialName,
qct.quality,
qct.unit,
qct.supplier_name supplierName,
qct.income_time incomeTime,
qct.check_result checkResult,
qct.check_man_name checkManName,
qc.check_name checkName
from qc_check_task qct
left join qc_check_type qc on qct.check_type = qc.order_code
where qct.type_code = #{typeCode} and qct.check_result = 'N'
<if test='ymdType=="yyyy"'>
and CONVERT(varchar(4),qct.income_time, 120) = SUBSTRING(#{ymd},0,5)
</if>
<if test='ymdType=="mm"'>
and CONVERT(varchar(7),qct.income_time, 120) = SUBSTRING(#{ymd},0,8)
</if>
<if test='ymdType=="dd"'>
and CONVERT(varchar(10),qct.income_time, 120) = SUBSTRING(#{ymd},0,11)
</if>
order by qct.income_time desc
</select>
<select id="getProduceNoOkList" resultType="com.op.quality.domain.QcInterface">
select qctd.rule_name projectName,
qct.check_man_name checkManName,
qctd.update_time checkTime
from qc_check_task_detail qctd
left join qc_check_task qct on qctd.belong_to = qct.record_id
where qct.type_code = #{typeCode} and qctd.status = 'N'
and CONVERT(varchar(10),qct.income_time, 120) = SUBSTRING(#{ymd},0,11)
order by qctd.update_time desc
</select>
<select id="getProduceHz" resultType="com.op.quality.domain.QcInterface">
select sum(qct.quality) quality,
sum(sample_quality) sampleQuality,
sum(noOk_quality) noOkQuality
from qc_check_task qct
where qct.type_code = #{typeCode}
and qct.del_flag='0'
<if test='ymdType=="mm"'>
and CONVERT(varchar(7),qct.income_time, 120) = SUBSTRING(#{ymd},0,8)
</if>
<if test='ymdType=="dd"'>
and CONVERT(varchar(10),qct.income_time, 120) = SUBSTRING(#{ymd},0,11)
</if>
</select>
<select id="getYearNoOkHz" resultType="com.op.quality.domain.QcInterface">
select
t.ymd,
sum(t.noOk_quality) noOkQuality
from(
select CONVERT(varchar(7),qct.income_time, 120) ymd,
qct.noOk_quality
from qc_check_task qct
where qct.type_code = #{typeCode}
and qct.del_flag='0'
and CONVERT(varchar(4),qct.income_time, 120) = SUBSTRING(#{ymd},0,5)
) t
group by t.ymd
</select>
<select id="getLineNames" resultType="com.op.quality.domain.QcProCheck">
select DISTINCT machine_code machineCode,
machine_name machineName
from mes_report_work
where del_flag = '0'
and CONVERT(varchar(7),feedback_time, 120) = SUBSTRING(#{ymd},0,8)
</select>
<select id="getDayNoOkHz" resultType="com.op.quality.domain.QcInterface">
SELECT
concat(t.machine_code,t.ymd) ymd,
sum(t.noOk_quality) noOkQuality,
t.machine_code machineCode
from(
select CONVERT(varchar(10),qct.income_time, 120) ymd,
qct.noOk_quality,
mrw.machine_code
from qc_check_task qct
left join pro_order_workorder pow on qct.order_no = pow.workorder_code_sap
left join mes_report_work mrw on pow.workorder_code = mrw.workorder_code
where qct.type_code = #{typeCode}
and qct.del_flag='0'
and CONVERT(varchar(7),qct.income_time, 120) = SUBSTRING(#{ymd},0,8)
) t
group by t.machine_code,t.ymd
</select>
<select id="getMothNoOkNum" resultType="com.op.quality.domain.QcInterface">
select
t.ymd,
sum(t.quality) quality,
sum(t.noOk_quality) noOkQuality
from(
select CONVERT(varchar(7),qct.income_time, 120) ymd,
qct.quality,
qct.noOk_quality
from qc_check_task qct
where qct.type_code = #{typeCode}
and qct.del_flag='0'
and CONVERT(varchar(4),qct.income_time, 120) in (${ymd})
) t
group by t.ymd
</select>
</mapper>