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.

259 lines
12 KiB
XML

2 years ago
<?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.QcStaticTableMapper">
<select id="selectQcStaticTableList" parameterType="com.op.quality.domain.QcStaticTable" resultType="com.op.quality.domain.QcStaticTable">
SELECT
bs.supplier_id supplierId,
bs.supplier_code supplierCode,
bs.zh_desc supplierName
from base_supplier bs
where bs.del_flag = '0' and bs.active_flag = '1'
<if test="supplierCodes != null and supplierCodes.size()>0">
and bs.supplier_code in
<foreach collection="supplierCodes" item="supplierCode" index="index" separator="," open="(" close=")">
#{supplierCode}
</foreach>
</if>
</select>
<select id="selectPcMap" resultType="com.op.quality.domain.QcStaticTable">
SELECT
qct.supplier_code supplierCode,qct.supplier_name supplierName,
count(0) batchs,sum(qct.quality) nums
from qc_check_task qct
where qct.type_code = #{qc.typeCode}
and qct.del_flag = '0'
and CONVERT(varchar(7),qct.income_time, 120) = #{qc.yearMonth}
<if test="qc.checkResult != null">
and qct.check_result = #{qc.checkResult}
</if>
<if test="codes != null and codes.size()>0">
and qct.supplier_code in
<foreach collection="codes" item="item" index="index" separator="," open="(" close=")">
#{item.supplierCode}
</foreach>
</if>
group by qct.supplier_code,qct.supplier_name
</select>
<select id="selectNumMap" resultType="com.op.quality.domain.QcStaticTable">
SELECT
qct.supplier_code supplierCode,qct.supplier_name supplierName,
sum(qct.noOk_quality) noOkNums
from qc_check_task qct
where qct.type_code = #{qc.typeCode}
and qct.del_flag = '0'
and CONVERT(varchar(7),qct.income_time, 120) = #{qc.yearMonth}
<if test="codes != null and codes.size()>0">
and qct.supplier_code in
<foreach collection="codes" item="item" index="index" separator="," open="(" close=")">
#{item.supplierCode}
</foreach>
</if>
group by qct.supplier_code,qct.supplier_name
2 years ago
</select>
2 years ago
<select id="getProduceChartData" resultType="com.op.quality.domain.QcStaticTable">
select concat(qct.material_code,CONVERT(varchar(10),qct.income_time, 120)) materailDate,
qct.material_code materialCode,
qct.material_name materialName,
qct.sample_quality sampleQuality,
qct.aNoOkquality,
qct.bNoOkquality,
qct.cNoOkquality,
qct.income_time
from qc_check_task qct
where qct.del_flag = '0' and qct.type_code = 'produce'
<if test="materialCode != null "> and qct.material_code in (${materialCode})</if>
<if test="workCenter != null "> and qct.supplier_code = #{workCenter}</if>
<if test="ymArrayStart != null "> and CONVERT(varchar(10),qct.income_time, 120) >= #{ymArrayStart}</if>
<if test="ymArrayEnd != null "> and #{ymArrayEnd}>= CONVERT(varchar(10),qct.income_time, 120)</if>
</select>
<select id="getProduceNames" resultType="com.op.quality.domain.QcStaticTable">
select distinct qct.material_code materialCode,
qct.material_name materialName
from qc_check_task qct
where qct.del_flag = '0' and qct.type_code = 'produce'
<if test="materialCode != null "> and qct.material_code in (${materialCode})</if>
<if test="workCenter != null "> and qct.supplier_code = #{workCenter}</if>
<if test="ymArrayStart != null "> and CONVERT(varchar(10),qct.income_time, 120) >= #{ymArrayStart}</if>
<if test="ymArrayEnd != null "> and #{ymArrayEnd}>= CONVERT(varchar(10),qct.income_time, 120)</if>
</select>
<select id="getProduceChartDataYM" resultType="com.op.quality.domain.QcStaticTable">
select
concat(qct.material_code,CONVERT(varchar(7),qct.income_time, 120)) materailDate,
qct.material_code materialCode,
qct.material_name materialName,
sum(qct.sample_quality) sampleQuality,
sum(qct.aNoOkquality) aNoOkquality,
sum(qct.bNoOkquality) bNoOkquality,
sum(qct.cNoOkquality) cNoOkquality,
CONVERT(varchar(7),qct.income_time, 120) incomeTime
from qc_check_task qct
where qct.del_flag = '0' and qct.type_code = 'produce'
<if test="materialCode != null "> and qct.material_code in (${materialCode})</if>
<if test="workCenter != null "> and qct.supplier_code = #{workCenter}</if>
<if test="ymArrayStart != null "> and CONVERT(varchar(10),qct.income_time, 120) >= #{ymArrayStart}</if>
<if test="ymArrayEnd != null "> and #{ymArrayEnd}>= CONVERT(varchar(10),qct.income_time, 120)</if>
group by qct.material_code ,
qct.material_name ,
CONVERT(varchar(7),qct.income_time, 120)
</select>
<select id="getWorkcenterList" resultType="com.op.system.api.domain.quality.FactoryDto">
select factory_name factoryName,
factory_code factoryCode
from sys_factory where f_type = 'c'
2 years ago
</select>
2 years ago
<select id="getXJCheckTableList" resultType="com.op.quality.domain.QcStaticTable">
select distinct
order_no orderNo,
2 years ago
material_code materialCode, material_name materialName,
quality,unit,
supplier_code supplierCode,supplier_name supplierName,
income_time incomeTime
from qc_check_task
where check_type = 'checkTypeSCXJ' and del_flag = '0'
<if test="orderNo != null "> and check_no like concat('%',#{orderNo},'%')</if>
<if test="materialCode != null "> and material_code like concat('%',#{materialCode},'%')</if>
<if test="incomeBatchNo != null "> and income_batch_no like concat('%',#{incomeBatchNo},'%')</if>
<if test="incomeTime != null "> and CONVERT(varchar(10),income_time, 120) >= CONVERT(varchar(10),#{incomeTime}, 120)</if>
order by income_time desc
</select>
<select id="getXJProjects" resultType="com.op.quality.domain.QcStaticTable">
select qct.rule_name ruleName,
qctp.project_id projectId,
qctp.project_no projectNo
from qc_check_type_project qctp
left join qc_check_project qct on qctp.project_id = qct.id
where qctp.type_id = 'checkTypeSCXJ' and qctp.del_flag = '0' and qct.del_flag = '0'
order by qctp.sort
</select>
<select id="getProjectDetail" resultType="com.op.quality.domain.QcStaticTable">
1 year ago
select qctd.record_id recordId,
qctd.project_id projectId,
2 years ago
qctd.status,
1 year ago
qctd.remark,
CONVERT(VARCHAR(5),qctd.create_time, 108),
2 years ago
concat(qctd.project_id,
case when '09:00'>= CONVERT(VARCHAR(5),qctd.create_time, 108) and CONVERT(VARCHAR(5),qctd.create_time, 108)> '08:00' then '08'
when '10:00'>= CONVERT(VARCHAR(5),qctd.create_time, 108) and CONVERT(VARCHAR(5),qctd.create_time, 108)> '09:00' then '09'
when '11:00'>= CONVERT(VARCHAR(5),qctd.create_time, 108) and CONVERT(VARCHAR(5),qctd.create_time, 108)> '10:00' then '10'
when '12:00'>= CONVERT(VARCHAR(5),qctd.create_time, 108) and CONVERT(VARCHAR(5),qctd.create_time, 108)> '11:00' then '11'
when '13:30'>= CONVERT(VARCHAR(5),qctd.create_time, 108) and CONVERT(VARCHAR(5),qctd.create_time, 108)> '12:30' then '12'
when '14:30'>= CONVERT(VARCHAR(5),qctd.create_time, 108) and CONVERT(VARCHAR(5),qctd.create_time, 108)> '13:30' then '13'
when '15:30'>= CONVERT(VARCHAR(5),qctd.create_time, 108) and CONVERT(VARCHAR(5),qctd.create_time, 108)> '14:30' then '14'
when '16:30'>= CONVERT(VARCHAR(5),qctd.create_time, 108) and CONVERT(VARCHAR(5),qctd.create_time, 108)> '15:30' then '15'
when '17:30'>= CONVERT(VARCHAR(5),qctd.create_time, 108) and CONVERT(VARCHAR(5),qctd.create_time, 108)> '16:30' then '16'
when '19:00'>= CONVERT(VARCHAR(5),qctd.create_time, 108) and CONVERT(VARCHAR(5),qctd.create_time, 108)> '18:00' then '18'
when '20:00'>= CONVERT(VARCHAR(5),qctd.create_time, 108) and CONVERT(VARCHAR(5),qctd.create_time, 108)> '19:00' then '19'
when '21:00'>= CONVERT(VARCHAR(5),qctd.create_time, 108) and CONVERT(VARCHAR(5),qctd.create_time, 108)> '20:00' then '20'
2 years ago
else '-' end
)ymdms
from qc_check_task qct
left join qc_check_task_detail qctd on qct.record_id = qctd.belong_to
where qct.order_no = #{orderNo} and qct.check_type = 'checkTypeSCXJ' and qct.check_status = '2'
2 years ago
order by qctd.create_time
</select>
<select id="getBatchnos" resultType="java.lang.String">
select powb.batch_code batchCode
from pro_order_workorder_batch powb
left join pro_order_workorder pow on powb.workorder_id = pow.workorder_id
where powb.del_flag = '0' and pow.del_flag = '0'
and pow.workorder_code = #{orderNo}
</select>
<select id="getLegendData" resultType="com.op.quality.domain.QcStaticTable">
select DISTINCT supplier_code supplierCode,
supplier_name supplierName
from qc_check_task
where check_type = 'checkTypeSCXJ' and del_flag = '0'
and CONVERT(varchar(10),income_time, 120) = #{ymdms}
</select>
<select id="getXJMapData" resultType="com.op.quality.domain.QcStaticTable">
select qct.supplier_code supplierCode,
qct.supplier_name supplierName,
sum(qct.sample_quality) sampleQuality,
sum(qct.noOk_quality) noOkNums,
concat(qct.supplier_code,CONVERT(VARCHAR(2), qct.check_time, 108)) ymdms
from qc_check_task qct
where qct.check_type = 'checkTypeSCXJ' and qct.del_flag = '0'
and CONVERT(varchar(10),qct.income_time, 120) = #{ymdms}
<if test="orderNo != null "> and qct.check_no like concat('%',#{orderNo},'%')</if>
<if test="materialCode != null "> and qct.material_code like concat('%',#{materialCode},'%')</if>
group by qct.supplier_code,qct.supplier_name,CONVERT(VARCHAR(2), qct.check_time, 108)
</select>
<select id="getQmsRateTable" resultType="com.op.quality.domain.QcStaticTable">
select qct.supplier_code supplierCode,
qct.supplier_name supplierName,
<if test="orderNo != null ">qct.order_no orderNo, qct.unit,</if>
<if test="incomeBatchNo != null ">qct.income_batch_no,</if>
<if test="materialCode != null ">qct.material_code,qct.material_name,</if>
sum(quality) quality,
sum(qct.sample_quality) sampleQuality,
sum(qct.noOk_quality) noOkNums
from qc_check_task qct
where qct.del_flag = '0'
<if test="orderNo != null ">and qct.order_no = #{orderNo}</if>
<if test="incomeBatchNo != null ">and qct.income_batch_no like concat('%',#{incomeBatchNo},'%')</if>
<if test="materialCode != null ">and qct.material_code like concat('%',#{materialCode},'%')</if>
<if test="supplierCode != null ">and qct.supplier_code = #{supplierCode}</if>
<if test="typeCode != null ">and qct.type_code = #{typeCode}</if>
<if test="checkType != null ">and qct.check_type = #{checkType}</if>
<if test="ymArrayStart != null "> and CONVERT(varchar(10),qct.income_time, 120) >= CONVERT(varchar(10),#{ymArrayStart}, 120)</if>
<if test="ymArrayEnd != null "> and CONVERT(varchar(10),#{ymArrayEnd}, 120)>=CONVERT(varchar(10),qct.income_time, 120)</if>
group by qct.supplier_code,qct.supplier_name
<if test="orderNo != null ">,qct.order_no,qct.unit</if>
<if test="incomeBatchNo != null ">,qct.income_batch_no</if>
<if test="materialCode != null ">,qct.material_code,qct.material_name</if>
</select>
<select id="getCheckTypeList" resultType="com.op.quality.domain.QcCheckType">
select order_code checkType,
check_name checkName
from qc_check_type
where del_flag = '0' and type_code= #{typeCode}
</select>
<select id="getSupplier" resultType="com.op.quality.domain.QcStaticTable">
select supplier_code supplierCode,
zh_desc supplierName
from base_supplier where del_flag = '0'
</select>
<select id="getLocList" resultType="com.op.quality.domain.QcStaticTable">
select warehouse_code supplierCode,
warehouse_name supplierName
from base_warehouse
where del_flag = '0' and active_flag = '1'
</select>
<select id="getWorkcenter" resultType="com.op.quality.domain.QcStaticTable">
select factory_name supplierName,
factory_code supplierCode
from sys_factory where f_type = 'c'
</select>
<select id="picsMap" resultType="com.op.quality.domain.QcStaticTable">
SELECT
t.source_id recordId,
STUFF(
(SELECT ',' + file_address
FROM (
select file_address,source_id from base_file where source_id in(
select record_id from qc_check_task_detail where beLong_to in (
select record_id from qc_check_task
where order_no = #{orderNo} and check_type = 'checkTypeSCXJ')
)
) t0
WHERE t.source_id = t0.source_id
FOR xml path('')
),1,1,''
) projectId
FROM (
select file_address,source_id from base_file where source_id in(
select record_id from qc_check_task_detail where beLong_to in (
select record_id from qc_check_task
where order_no = #{orderNo} and check_type = 'checkTypeSCXJ')
)
) t
GROUP by t.source_id
</select>
2 years ago
</mapper>