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.

301 lines
12 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 qct.remark projectName,
count(0) quality
from qc_check_task qct
where qct.type_code = 'produce' and qct.check_result = 'N' and qct.remark is not null
<if test='ymdType=="yyyy"'>
and CONVERT(varchar(4),qct.check_time, 120) = SUBSTRING(#{ymd},0,5)
</if>
<if test='ymdType=="mm"'>
and CONVERT(varchar(7),qct.check_time, 120) = SUBSTRING(#{ymd},0,8)
</if>
<if test='ymdType=="dd"'>
and CONVERT(varchar(10),qct.check_time, 120) = SUBSTRING(#{ymd},0,11)
</if>
group by qct.remark-->
</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.record_id recordId,
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,
CONVERT(varchar(10),qct.income_time, 120) incomeTime,
qct.check_status checkStatus,
qct.check_result checkResult,
qct.check_man_name checkManName,
qc.check_name checkName,
qct.check_time checkTime
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.check_no
</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_time checkTime,
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'
<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 qctd.update_time desc
</select>
<select id="getProduceHz" resultType="com.op.quality.domain.QcInterface">
select
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.workorder_name,t.ymd) ymd,
sum(t.noOk_quality) noOkQuality,
t.workorder_name machineCode
from(
select CONVERT(varchar(10),qct.income_time, 120) ymd,
qct.noOk_quality,
pow.workorder_name
from qc_check_task qct
left join pro_order_workorder pow on qct.order_no = pow.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.workorder_name,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>
<select id="getReasons" resultType="com.op.quality.domain.QcCheckTaskDetail">
select concat(rule_name,':',check_standard) ruleName
from qc_check_task_detail
where belong_to = #{recordId}
and status = 'N' and del_flag='0'
</select>
<select id="getLineChartsNames" resultType="java.lang.String">
select
distinct supplier_name
from qc_check_task
where type_code = 'produce' and del_flag = '0'
and CONVERT(varchar(10),income_time, 120) >= #{productDateStart}
and #{productDateEnd} >= CONVERT(varchar(10),income_time, 120)
</select>
<select id="getLineChartsDatas" resultType="com.op.quality.domain.QcInterface">
select
sum(sample_quality) quality,
sum(noOk_quality) noOkQuality,
concat(supplier_name,CONVERT(varchar(10),income_time, 120)) nameDate
from qc_check_task
where type_code = 'produce' and del_flag = '0'
and CONVERT(varchar(10),income_time, 120) >= #{productDateStart}
and #{productDateEnd} >= CONVERT(varchar(10),income_time, 120)
group by supplier_name,CONVERT(varchar(10),income_time, 120)
</select>
<select id="getProduceHz1" resultType="com.op.quality.domain.QcInterface">
select sum(mrw.quantity_feedback*be.umrez) quality
from mes_report_work mrw
left join base_product be on be.product_code = mrw.product_code
where mrw.del_flag = '0' and mrw.parent_order = '0' and be.del_flag = '0'
<if test='ymdType=="mm"'>
and CONVERT(varchar(7),mrw.create_time, 120) = CONVERT(varchar(7),GETDATE(), 120)
</if>
<if test='ymdType=="dd"'>
and CONVERT(varchar(10),mrw.create_time, 120) = CONVERT(varchar(10),GETDATE(), 120)
</if>
</select>
</mapper>