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.

450 lines
24 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.QcCheckReportIncomeMapper">
<resultMap type="QcCheckReportIncome" id="QcCheckReportIncomeResult">
<result property="recordId" column="record_id"/>
<result property="checkNo" column="check_no"/>
<result property="incomeBatchNo" column="income_batch_no"/>
<result property="orderNo" column="order_no"/>
<result property="materialCode" column="material_code"/>
<result property="materialName" column="material_name"/>
<result property="quality" column="quality"/>
<result property="unit" column="unit"/>
<result property="supplierCode" column="supplier_code"/>
<result property="supplierName" column="supplier_name"/>
<result property="incomeTime" column="income_time"/>
<result property="checkLoc" column="check_loc"/>
<result property="checkStatus" column="check_status"/>
<result property="checkManCode" column="check_man_code"/>
<result property="checkManName" column="check_man_name"/>
<result property="checkTime" column="check_time"/>
<result property="checkResult" column="check_result"/>
<result property="status" column="status"/>
<result property="attr1" column="attr1"/>
<result property="attr2" column="attr2"/>
<result property="attr3" column="attr3"/>
<result property="attr4" column="attr4"/>
<result property="createBy" column="create_by"/>
<result property="createTime" column="create_time"/>
<result property="updateBy" column="update_by"/>
<result property="updateTime" column="update_time"/>
<result property="factoryCode" column="factory_code"/>
<result property="delFlag" column="del_flag"/>
<result property="sampleQuality" column="sample_quality"/>
<result property="checkName" column="check_name"/>
<result property="checkType" column="check_type"/>
<result property="reason" column="reason"/>
<result property="productType" column="product_type"/>
<result property="orderType" column="order_type"/>
<result property="standardNo" column="standardNo"/>
<result property="jgy" column="jgy"/>
<result property="pgy" column="pgy"/>
<result property="cxzz" column="cxzz"/>
<result property="workorderCodeSap" column="workorder_code_sap"/>
<result property="modelType" column="modelType"/>
<result property="remark" column="remark"/>
</resultMap>
<sql id="selectQcCheckReportIncomeVo">
select record_id, check_no, income_batch_no, order_no, material_code, material_name, quality, unit,
supplier_code, supplier_name, income_time, check_loc, check_status, check_man_code, check_man_name,sample_quality,
check_time, check_result, status, check_type, attr1, attr2, attr3, attr4, create_by, create_time, update_by, update_time,
factory_code, del_flag,reason,product_type,order_type
from qc_check_task
</sql>
<select id="selectQcCheckReportIncomeList" parameterType="QcCheckReportIncome"
resultMap="QcCheckReportIncomeResult">
select qct.record_id, qct.check_no, qct.income_batch_no,
qct.order_no, qct.material_code, qct.material_name, qct.quality, qct.unit,
qct.supplier_code, qct.supplier_name, qct.income_time, qct.check_loc, qct.check_status,
qct.check_man_code, qct.check_man_name,qct.check_time, qct.check_result, qct.status,qct.sample_quality,
qct.create_by,qct.create_time, qct.update_by, qct.update_time,qct.check_type,
q.type_code,q.check_name,pow.workorder_code_sap
from qc_check_task qct
left join qc_check_type q on q.id = qct.check_type
left join pro_order_workorder pow on pow.workorder_code = qct.order_no and pow.del_flag = '0'
<where>
<if test="checkNo != null and checkNo != ''">and qct.check_no = #{checkNo}</if>
<if test="incomeBatchNo != null and incomeBatchNo != ''">and qct.income_batch_no = #{incomeBatchNo}</if>
<if test="orderNo != null and orderNo != ''">and qct.order_no = #{orderNo}</if>
<if test="materialCode != null and materialCode != ''">and qct.material_code = #{materialCode}</if>
<if test="materialName != null and materialName != ''">and qct.material_name like concat('%',#{materialName}, '%')</if>
<if test="supplierCode != null and supplierCode != ''">and qct.supplier_code = #{supplierCode}</if>
<if test="supplierName != null and supplierName != ''">and qct.supplier_name like concat('%',#{supplierName}, '%')</if>
<if test="checkLoc != null and checkLoc != ''">and qct.check_loc like concat('%', #{checkLoc}, '%')</if>
<if test="checkStatus != null and checkStatus != ''">and qct.check_status = #{checkStatus}</if>
<if test="checkManCode != null and checkManCode != ''">and qct.check_man_code = #{checkManCode}</if>
<if test="checkManName != null and checkManName != ''">and qct.check_man_name like concat('%',#{checkManName}, '%')</if>
and qct.del_flag = '0'
<if test="checkResult != null and checkResult != ''">and qct.check_result = #{checkResult}</if>
<if test="status != null and status != ''">and qct.status = #{status}</if>
<if test="delFlag != null and delFlag != ''">and qct.del_flag = #{delFlag}</if>
<if test="incomeTimeStart != null ">and CONVERT(varchar(30),qct.income_time, 120) >= #{incomeTimeStart}</if>
<if test="incomeTimeEnd != null ">and #{incomeTimeEnd} > CONVERT(varchar(30),qct.income_time, 120)</if>
<if test="checkTimeStart != null ">and CONVERT(varchar(30),qct.check_time, 120) >= #{checkTimeStart}</if>
<if test="checkTimeEnd != null ">and #{checkTimeEnd} > CONVERT(varchar(30),qct.check_time, 120)</if>
<if test="typeCode != null ">and q.type_code = #{typeCode}</if>
<if test="checkType != null ">and qct.check_type = #{checkType}</if>
<if test="workorderCodeSap != null ">and pow.workorder_code_sap like concat('%',#{workorderCodeSap}, '%')</if>
</where>
</select>
<select id="selectQcCheckReportIncomeByRecordId" parameterType="String" resultMap="QcCheckReportIncomeResult">
select qct.record_id, qct.check_no, qct.income_batch_no, qct.order_no, qct.material_code, qct.material_name,
qct.quality, qct.unit,qct.supplier_code, qct.supplier_name, qct.income_time, qct.check_loc,
qct.check_status, qct.check_man_code, qct.check_man_name,
qct.check_time, qct.check_result, qct.status, qct.check_type, qct.attr1, qct.attr2, qct.attr3, qct.attr4,
qct.create_by, qct.create_time, qct.update_by, qct.update_time,
qct.factory_code, qct.del_flag,qct.reason,qct.product_type,bp.product_group_name order_type,qct.jgy,qct.pgy,qct.cxzz,
ISNULL(bp.mvgr5, '09JS08S-048B') standardNo
from qc_check_task qct
left join base_product bp on bp.product_code = qct.material_code
where qct.record_id = #{recordId}
</select>
<select id="getQcListBom" resultType="com.op.quality.domain.QcBomComponent">
select product_code component,product_desc_zh componentName
from base_product
where del_flag = '0'
<if test="component != null and component != ''">and product_code like concat('%', #{component}, '%')</if>
<if test="componentName != null and componentName != ''">and product_desc_zh like concat('%', #{componentName},
'%')
</if>
</select>
<select id="getQcListSupplier" resultType="com.op.quality.domain.QcSupplier">
select supplier_code supplierCode,
zh_desc supplierName,
address,
contact_phone contactPhone
from base_supplier where active_flag = '1' and del_flag ='0'
<if test="supplierCode != null and supplierCode != ''">and supplier_code like concat('%', #{supplierCode},
'%')
</if>
<if test="supplierName != null and supplierName != ''">and zh_desc like concat('%', #{supplierName}, '%')</if>
</select>
<select id="getQcListUser" resultType="com.op.system.api.domain.SysUser">
select user_id userId,
user_name userCode,
nick_name userName,
phonenumber
from sys_user where del_flag = '0' and status = '0'
<if test="userCode != null and userCode != ''">and user_name like concat('%', #{userCode}, '%')</if>
<if test="userName != null and userName != ''">and nick_name like concat('%', #{userName}, '%')</if>
</select>
<select id="getTodayMaxNum" resultType="java.lang.Integer">
select count(0)+1
from qc_check_task
where CONVERT(varchar(10),create_time, 120) = CONVERT(varchar(10),GETDATE(), 120)
</select>
<select id="getCkeckProjectList" resultType="com.op.quality.domain.QcCheckTaskDetail">
select td.record_id recordId,
td.project_id projectId,
td.project_no projectNo,
td.rule_name ruleName,
td.property_code propertyCode,
td.check_mode checkMode,
td.check_tool checkTool,
td.unit_code unitCode,
td.check_standard checkStandard,
td.actual_value actualValue,
td.status,
td.remark,
td.create_by createBy,
td.create_time createTime,
td.update_by updateBy,
td.update_time updateTime,
td.defect_code defectCode,
td.defect_quality defectQuality,
qctp.upper_diff upperDiff,
qctp.down_diff downDiff,
qctp.sample,
td.sample_quality samplePlan,
qcp.item_type itemType,
qctp.judge_rate judgeRate,
qpt.standard_no standardNo,
qctp.upper_diff upperDiff,
qctp.down_diff downDiff
from qc_check_task_detail td
left join qc_check_type_project qctp on td.type_project_id = qctp.id
left join qc_check_project qcp on qcp.id = qctp.project_id
left join qc_project_type qpt on qpt.project_type_code = qcp.project_type
where td.belong_to = #{recordId}
order by qctp.sort
</select>
<select id="getTopInfo" resultType="com.op.quality.domain.QcCheckTaskProduce">
select t.*,be.equipment_name lineName,
pow.product_date checkTimeStart from(
SELECT
c.order_no orderNo,
c.supplier_name supplierName,
c.supplier_code supplierCode,
c.material_name materialName,
c.material_code materialCode,
stuff( ( SELECT ';' + income_batch_no FROM qc_check_task WHERE c.order_no= order_no FOR xml path ( '' ) ), 1, 1, '' ) as incomeBatchNo
FROM
qc_check_task c
where c.check_type='checkTypeSCXJ' and c.order_no = #{orderNo}
GROUP BY
c.order_no,c.supplier_name,c.supplier_code,c.material_name,c.material_code
) t
left join pro_order_workorder pow on pow.workorder_code = t.orderNo
left join base_equipment be on be.equipment_code = pow.workorder_name
where pow.del_flag = '0' and be.del_flag ='0'
</select>
<select id="getTaskInfo" resultType="com.op.quality.domain.QcCheckReportIncome">
select record_id recordId, check_no checkNo, income_batch_no incomeBatchNo,
order_no orderNo, material_code materialCode, material_name materialName,
quality, unit, supplier_code supplierCode, supplier_name supplierName,
income_time incomeTime, check_loc checkLoc, check_status checkStatus,
check_man_code checkManCode, check_man_name checkManName, check_time checkTime,
check_result checkResult,create_by createBy, create_time createTime,
check_type checkType,sample_quality sampleQuality,noOk_quality noOkQuality,
reason,product_type productType,
confirm,
confirm_man_code confirmManCode,
confirm_man_name confirmManName,
confirm_remark confirmRemark,
confirm_time confirmTime
from qc_check_task where record_id = #{recordId}
</select>
<select id="getXJTaskInfo" resultType="com.op.quality.domain.QcCheckReportIncome">
SELECT top 1
c.check_type checkType,
c.quality,
c.unit,
c.order_no orderNo,
c.supplier_name supplierName,
c.supplier_code supplierCode,
c.material_name materialName,
c.material_code materialCode,
c.income_time incomeTime
FROM
qc_check_task c
where c.check_type='checkTypeSCXJ' and c.order_no = #{orderNo}
order by c.income_time desc
</select>
<select id="getLastXJTaskInfo" resultType="com.op.quality.domain.QcCheckReportIncome">
SELECT
top 1
c.confirm,
c.product_type productType,
c.confirm_man_code confirmManCode,
c.confirm_man_name confirmManName,
c.confirm_remark confirmRemark,
c.confirm_time confirmTime
FROM
qc_check_task c
where c.check_type='checkTypeSCXJ' and c.order_no = #{orderNo}
order by c.create_time desc
</select>
<select id="getLastProductTypeInfo" resultType="com.op.quality.domain.QcCheckTaskProduce">
SELECT
distinct
c.product_type productType,
c.check_man_code checkManCode,
c.check_man_name checkManName,
c.confirm_man_code confirmManCode,
c.confirm_man_name confirmManName
FROM
qc_check_task c
where c.check_type='checkTypeSCXJ' and c.order_no = #{orderNo}
</select>
<select id="getBatchsByTaskId" resultType="java.lang.String">
select powb.batch_code incomeBatchNo
from qc_check_task qct
left join pro_order_workorder pow on pow.workorder_code = qct.order_no
left join pro_order_workorder_batch powb on powb.workorder_id = pow.workorder_id
where qct.record_id = #{recordId} and qct.del_flag = '0' and pow.del_flag = '0' and powb.del_flag = '0'
order by powb.batch_code
</select>
<select id="getLastXJ" resultType="com.op.quality.domain.QcCheckTaskProduce">
SELECT
top 1 c.bz
FROM
qc_check_task c
where c.check_type='checkTypeSCXJ' and c.order_no = #{orderNo}
and c.bz is not null
order by c.create_time desc
</select>
<select id="getStandardNo" resultType="java.lang.String">
select top 1 qctf.file_no
from qc_check_type_file qctf
where qctf.del_flag = '0' and qctf.check_type = #{checkType}
and CONVERT(varchar(10),#{incomeTime}, 120) BETWEEN qctf.start_time and qctf.end_time
order by create_time desc
</select>
<select id="getPrintXJList" parameterType="QcCheckReportIncome"
resultMap="QcCheckReportIncomeResult">
select qct.order_no,qct.material_code, qct.material_name, qct.check_no, qct.income_batch_no,
qct.check_result, CONVERT(varchar(10),qct.income_time, 120),concat(bp.umrez,'装') modelType,
qct.supplier_code, qct.supplier_name, qct.income_time, qct.check_loc, qct.check_status,
qct.check_man_code, qct.check_man_name,qct.check_time, qct.check_result, qct.status,qct.sample_quality,
qct.remark,qct.attr3,qct.check_type
from qc_check_task qct
left join base_product bp on qct.material_code = bp.product_code and bp.del_flag = '0'
<where>
<if test="checkNo != null and checkNo != ''">and qct.check_no = #{checkNo}</if>
<if test="incomeBatchNo != null and incomeBatchNo != ''">and qct.income_batch_no = #{incomeBatchNo}</if>
<if test="orderNo != null and orderNo != ''">and qct.order_no = #{orderNo}</if>
<if test="materialCode != null and materialCode != ''">and qct.material_code = #{materialCode}</if>
<if test="materialName != null and materialName != ''">and qct.material_name like concat('%',#{materialName}, '%')</if>
<if test="supplierCode != null and supplierCode != ''">and qct.supplier_code = #{supplierCode}</if>
<if test="supplierName != null and supplierName != ''">and qct.supplier_name like concat('%',#{supplierName}, '%')</if>
<if test="checkLoc != null and checkLoc != ''">and qct.check_loc = #{checkLoc}</if>
<if test="checkStatus != null and checkStatus != ''">and qct.check_status = #{checkStatus}</if>
<if test="checkManCode != null and checkManCode != ''">and qct.check_man_code = #{checkManCode}</if>
<if test="checkManName != null and checkManName != ''">and qct.check_man_name like concat('%',#{checkManName}, '%')</if>
and qct.del_flag = '0'
<if test="checkResult != null and checkResult != ''">and qct.check_result = #{checkResult}</if>
<if test="status != null and status != ''">and qct.status = #{status}</if>
<if test="delFlag != null and delFlag != ''">and qct.del_flag = #{delFlag}</if>
<if test="incomeTimeStart != null ">and CONVERT(varchar(30),qct.income_time, 120) >= #{incomeTimeStart}</if>
<if test="incomeTimeEnd != null ">and #{incomeTimeEnd} > CONVERT(varchar(30),qct.income_time, 120)</if>
<if test="checkTimeStart != null ">and CONVERT(varchar(30),qct.check_time, 120) >= #{checkTimeStart}</if>
<if test="checkTimeEnd != null ">and #{checkTimeEnd} > CONVERT(varchar(30),qct.check_time, 120)</if>
<if test="typeCode != null ">and qct.type_code = #{typeCode}</if>
</where>
</select>
<select id="getActProductQty" resultType="java.lang.Long">
select sum(quantity_feedback) from mes_report_work where workorder_code = #{workOrderCode} and del_flag = '0'
</select>
<insert id="insertQcCheckReportIncome" parameterType="QcCheckReportIncome">
insert into qc_check_task
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="recordId != null">record_id,</if>
<if test="checkNo != null">check_no,</if>
<if test="incomeBatchNo != null">income_batch_no,</if>
<if test="orderNo != null">order_no,</if>
<if test="materialCode != null">material_code,</if>
<if test="materialName != null">material_name,</if>
<if test="quality != null">quality,</if>
<if test="unit != null">unit,</if>
<if test="supplierCode != null">supplier_code,</if>
<if test="supplierName != null">supplier_name,</if>
<if test="incomeTime != null">income_time,</if>
<if test="checkLoc != null">check_loc,</if>
<if test="checkStatus != null">check_status,</if>
<if test="checkManCode != null">check_man_code,</if>
<if test="checkManName != null">check_man_name,</if>
<if test="checkTime != null">check_time,</if>
<if test="checkResult != null">check_result,</if>
<if test="status != null">status,</if>
<if test="attr1 != null">attr1,</if>
<if test="attr2 != null">attr2,</if>
<if test="attr3 != null">attr3,</if>
<if test="attr4 != null">attr4,</if>
<if test="createBy != null">create_by,</if>
<if test="createTime != null">create_time,</if>
<if test="updateBy != null">update_by,</if>
<if test="updateTime != null">update_time,</if>
<if test="factoryCode != null and factoryCode != ''">factory_code,</if>
<if test="delFlag != null">del_flag,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="recordId != null">#{recordId},</if>
<if test="checkNo != null">#{checkNo},</if>
<if test="incomeBatchNo != null">#{incomeBatchNo},</if>
<if test="orderNo != null">#{orderNo},</if>
<if test="materialCode != null">#{materialCode},</if>
<if test="materialName != null">#{materialName},</if>
<if test="quality != null">#{quality},</if>
<if test="unit != null">#{unit},</if>
<if test="supplierCode != null">#{supplierCode},</if>
<if test="supplierName != null">#{supplierName},</if>
<if test="incomeTime != null">#{incomeTime},</if>
<if test="checkLoc != null">#{checkLoc},</if>
<if test="checkStatus != null">#{checkStatus},</if>
<if test="checkManCode != null">#{checkManCode},</if>
<if test="checkManName != null">#{checkManName},</if>
<if test="checkTime != null">#{checkTime},</if>
<if test="checkResult != null">#{checkResult},</if>
<if test="status != null">#{status},</if>
<if test="attr1 != null">#{attr1},</if>
<if test="attr2 != null">#{attr2},</if>
<if test="attr3 != null">#{attr3},</if>
<if test="attr4 != null">#{attr4},</if>
<if test="createBy != null">#{createBy},</if>
<if test="createTime != null">#{createTime},</if>
<if test="updateBy != null">#{updateBy},</if>
<if test="updateTime != null">#{updateTime},</if>
<if test="factoryCode != null and factoryCode != ''">#{factoryCode},</if>
<if test="delFlag != null">#{delFlag},</if>
</trim>
</insert>
<update id="updateQcCheckReportIncome" parameterType="QcCheckReportIncome">
update qc_check_task
<trim prefix="SET" suffixOverrides=",">
<if test="checkNo != null">check_no = #{checkNo},</if>
<if test="incomeBatchNo != null">income_batch_no = #{incomeBatchNo},</if>
<if test="orderNo != null">order_no = #{orderNo},</if>
<if test="materialCode != null">material_code = #{materialCode},</if>
<if test="materialName != null">material_name = #{materialName},</if>
<if test="quality != null">quality = #{quality},</if>
<if test="unit != null">unit = #{unit},</if>
<if test="supplierCode != null">supplier_code = #{supplierCode},</if>
<if test="supplierName != null">supplier_name = #{supplierName},</if>
<if test="incomeTime != null">income_time = #{incomeTime},</if>
<if test="checkLoc != null">check_loc = #{checkLoc},</if>
<if test="checkStatus != null">check_status = #{checkStatus},</if>
<if test="checkManCode != null">check_man_code = #{checkManCode},</if>
<if test="checkManName != null">check_man_name = #{checkManName},</if>
<if test="checkTime != null">check_time = #{checkTime},</if>
<if test="checkResult != null">check_result = #{checkResult},</if>
<if test="status != null">status = #{status},</if>
<if test="attr1 != null">attr1 = #{attr1},</if>
<if test="attr2 != null">attr2 = #{attr2},</if>
<if test="attr3 != null">attr3 = #{attr3},</if>
<if test="attr4 != null">attr4 = #{attr4},</if>
<if test="createBy != null">create_by = #{createBy},</if>
<if test="createTime != null">create_time = #{createTime},</if>
<if test="updateBy != null">update_by = #{updateBy},</if>
<if test="updateTime != null">update_time = #{updateTime},</if>
<if test="factoryCode != null and factoryCode != ''">factory_code = #{factoryCode},</if>
<if test="delFlag != null">del_flag = #{delFlag},</if>
</trim>
where record_id = #{recordId}
</update>
<update id="submitConfirm">
update qc_check_task
set confirm = #{confirm},
confirm_man_code = #{confirmManCode},
confirm_man_name = #{confirmManName},
confirm_remark = #{confirmRemark},
confirm_time = #{confirmTime}
<where>
<if test="recordId != null">
and record_id = #{recordId}
</if>
<if test="orderNo != null">
and order_no = #{orderNo}
</if>
</where>
</update>
<delete id="deleteQcCheckReportIncomeByRecordId" parameterType="String">
delete from qc_check_task where record_id = #{recordId}
</delete>
<delete id="deleteQcCheckReportIncomeByRecordIds" parameterType="String">
delete from qc_check_task where record_id in
<foreach item="recordId" collection="array" open="(" separator="," close=")">
#{recordId}
</foreach>
</delete>
</mapper>