李林
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
91
92
93
94
95
96
97
98
99
100
<?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.TestStandardMapper">
 
    <resultMap id="qualityTestStandardMap" type="com.chinaztt.mes.quality.dto.TestStandardDTO">
        <id property="id" column="id"/>
        <result property="standardNo" column="standard_no"/>
        <result property="standardName" column="standard_name"/>
        <result property="remark" column="remark"/>
        <result property="version" column="version"/>
        <result property="createTime" column="create_time"/>
        <result property="updateTime" column="update_time"/>
        <result property="createUser" column="create_user"/>
        <result property="updateUser" column="update_user"/>
        <result property="active" column="active"/>
        <result property="state" column="state"/>
        <result property="judgeFormula" column="judge_formula"/>
        <result property="inspectionType" column="inspection_type"/>
        <result property="layoutJson" column="layout_json"/>
        <result property="operationId" column="operation_id"/>
        <result property="operationName" column="operation_name"/>
        <result property="operationNo" column="operation_no"/>
    </resultMap>
 
    <select id="findMoTestStandardBySystemNo" resultType="com.chinaztt.mes.quality.entity.TestStandard">
        SELECT pmts.*
        FROM production_product_output ppo
                 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 production_operation_task_supply pots ON pots.operation_task_id = ppm.operation_task_id
                 LEFT JOIN plan_mo_test_standard pmts ON pmts.mo_id = pots.mo_id AND pmts.routing_operation_id = pot.routing_operation_id
        WHERE ppo.system_no = #{systemNo}
    </select>
 
    <delete id="deleteBatchIds">
        delete from quality_test_standard where id in
        <foreach collection="ids" item="id" separator="," open="(" close=")">
            #{id}
        </foreach>
    </delete>
 
    <select id="getTestStandard" resultMap="qualityTestStandardMap">
        SELECT A.*
        FROM quality_test_standard A
                 LEFT JOIN technology_join_document_test_standard B ON A."id" = B.test_standard_id
        WHERE B.document_id = #{id}
    </select>
 
    <select id="getTestStand" resultMap="qualityTestStandardMap">
        SELECT A.*
        FROM quality_test_standard A
        LEFT JOIN technology_join_document_test_standard B ON A."id" = B.test_standard_id
        WHERE B.document_id = #{id}
        <if test="ew.emptyOfWhere == false">
            and ${ew.SqlSegment}
        </if>
    </select>
    <select id="pageInfo" resultMap="qualityTestStandardMap">
        select * from (
        SELECT
        qts.* ,o.name as operation_name ,o.operation_no
        FROM
        quality_test_standard qts
        LEFT JOIN technology_operation o on qts.operation_id = o.id
        ) a
        <if test="ew.emptyOfWhere == false">
            <where>
                ${ew.SqlSegment}
            </where>
        </if>
    </select>
    <select id="getInfoById" resultType="com.chinaztt.mes.quality.dto.TestStandardDTO">
        SELECT
            qts.* ,o.name as operation_name ,o.operation_no
        FROM
            quality_test_standard qts
                LEFT JOIN technology_operation o on qts.operation_id = o.id
        where qts.id = #{id}
    </select>
 
    <select id="getOperationIdByOperationName" resultType="java.lang.Long">
        SELECT "id" FROM technology_operation WHERE "name" = #{operationName} LIMIT 1
    </select>
 
    <select id="selectMoTestStandardDTOList" resultType="com.chinaztt.mes.quality.dto.MoTestStandardDTO">
        SELECT
        pmts.*,
        pmoro.inspection,
        too.name AS operation_name
        FROM production_product_output ppo
        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 pmoro.id = pot.mo_routing_operation_id
        LEFT JOIN plan_mo_test_standard pmts ON pmts.mo_id = pmoro.mo_id AND pmts.mo_routing_operation_id = pot.mo_routing_operation_id
        LEFT JOIN technology_operation too ON too.id = pmoro.operation_id
        WHERE ppo.system_no = #{systemNo}
    </select>
</mapper>