李林
2023-10-07 658d4927d468c47208fd012d9128b09249c07eff
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
<?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.chinaztt.mes.quality.mapper.ResultMapper">
 
    <resultMap id="qualityResultMap" type="com.chinaztt.mes.quality.dto.ResultDTO">
        <id property="id" column="id"/>
        <result property="systemNo" column="system_no"/>
        <result property="partId" column="part_id"/>
        <result property="checkStatus" column="check_status"/>
        <result property="isQualified" column="is_qualified"/>
        <result property="isSelfQualified" column="is_self_qualified"/>
        <result property="isUsed" column="is_used"/>
        <result property="isErp" column="is_erp"/>
        <result property="remark" column="remark"/>
        <result property="partNo" column="part_no"/>
        <result property="partName" column="part_name"/>
        <result property="outBatchNo" column="out_batch_no"/>
        <result property="partBatchNo" column="part_batch_no"/>
        <result property="operationName" column="operation_name"/>
        <result property="applyType" column="apply_type"/>
        <result property="reportNo" column="report_no"/>
        <result property="isSubmit" column="is_submit"/>
    </resultMap>
    <update id="revokeApplyByApplyId">
        update quality_result
        set check_status= null,
            is_qualified= null,
            is_used= null,
            apply_id= null
        where apply_id = #{applyId}
    </update>
 
    <update id="batchUpdateResultBySystemNo">
        update quality_result
        set is_used = #{result.isUsed}
        where system_no = #{result.systemNo}
    </update>
 
    <update id="batchUpdateResultById">
        update quality_result
        set is_used = #{result.isUsed}
        where id = #{result.id}
    </update>
 
    <select id="getResultPage" resultMap="qualityResultMap">
        select temp.*
        from (
        select qr.*, bp.part_no, bp.part_name, ppo.out_batch_no, top."name" operation_name, qre.report_no,qre.is_submit
        from quality_result qr
        left join basic_part bp on bp."id" = qr.part_id
        left join production_product_output ppo on ppo.system_no = qr.system_no
        left join production_product_main ppm on ppm."id" = ppo.product_main_id
        left join production_operation_task pot on pot."id" = ppm.operation_task_id
        left join plan_manufacturing_order_routing_operation pmoro ON pot.mo_routing_operation_id = pmoro."id"
        left join technology_operation top ON pmoro.operation_id = top."id"
        inner join quality_apply_part qap on qr.system_no = qap.system_no AND
        qr.part_batch_no = qap.lot_batch_no
        inner join quality_apply qa on qr.apply_type = qa.apply_type and qa.id = qap.apply_id
        left join quality_report qre on qre.id = qap.report_id
        ) temp
        <if test="ew.emptyOfWhere == false">
            ${ew.customSqlSegment}
        </if>
    </select>
 
    <update id="clearCheckStatusBySystemNosAndType">
        update quality_result set check_status = '01untested',is_qualified = null,is_used = false
        where
        system_no in
        <foreach collection="systemNos" item="systemNo" separator="," open="(" close=")">
            #{systemNo}
        </foreach>
        and apply_type = #{reportType}
    </update>
 
    <delete id="deleteBySystemNo">
        delete from quality_result
        where system_no = #{systemNo} and apply_type != '00outputfirst'
        <!-- 这里删除检测结果只有工作台的产出记录从提交到草稿中用到了,该状态不需要删除首检的检测结果,如果用户不重新删除产出记录后再创建,会出现检测结果有尾无首的情况【2022-09-20】 -->
        <!--delete from quality_result
        where system_no = #{systemNo}-->
    </delete>
 
    <delete id="deleteAllBySystemNo">
        delete from quality_result
        where system_no = #{systemNo}
    </delete>
</mapper>