李林
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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
<?xml version="1.0" encoding="UTF-8"?>
 
<!--
  ~
  ~      Copyright (c) 2018-2025, ztt All rights reserved.
  ~
  ~  Redistribution and use in source and binary forms, with or without
  ~  modification, are permitted provided that the following conditions are met:
  ~
  ~ Redistributions of source code must retain the above copyright notice,
  ~  this list of conditions and the following disclaimer.
  ~  Redistributions in binary form must reproduce the above copyright
  ~  notice, this list of conditions and the following disclaimer in the
  ~  documentation and/or other materials provided with the distribution.
  ~  Neither the name of the pig4cloud.com developer nor the names of its
  ~  contributors may be used to endorse or promote products derived from
  ~  this software without specific prior written permission.
  ~  Author: ztt
  ~
  -->
 
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 
<mapper namespace="com.chinaztt.mes.plan.mapper.OperationTaskProduceMapper">
 
    <resultMap id="planMpsStructureComponentMap" type="com.chinaztt.mes.plan.dto.OperationTaskProduceDTO">
        <id property="id" column="id"/>
        <result property="otcCustomerOrderNo" column="otc_customer_order_no"/>
        <result property="otcLineNo" column="otc_line_no"/>
        <result property="snNo" column="sn_no"/>
        <result property="selfNo" column="self_no"/>
        <result property="print" column="print"/>
        <result property="section" column="section"/>
        <result property="begining" column="begining"/>
        <result property="ending" column="ending"/>
        <result property="direction" column="direction"/>
        <result property="purpose" column="purpose"/>
        <result property="endClassification" column="end_classification"/>
        <result property="company" column="company"/>
        <result property="crccNumber" column="crcc_number"/>
        <result property="customerOrderId" column="customer_order_id"/>
        <result property="mpsId" column="mps_id"/>
        <result property="moId" column="mo_id"/>
        <result property="operationTaskId" column="operation_task_id"/>
        <result property="qty" column="qty"/>
        <result property="customerPartSpec" column="customer_part_spec"/>
        <result property="finishedProductSpecification" column="finished_product_specification"/>
        <result property="ymd" column="ymd"/>
        <result property="isGenerateTask" column="is_generate_task"/>
        <result property="discToolMeasurement" column="disc_tool_measurement"/>
        <result property="createTime" column="create_time"/>
        <result property="createUser" column="create_user"/>
        <result property="updateTime" column="update_time"/>
        <result property="updateUser" column="update_user"/>
        <result property="partId" column="part_id"/>
        <result property="partNo" column="part_no"/>
        <result property="partName" column="part_name"/>
        <result property="customerName" column="customer_name"/>
        <result property="technologyDocumentId" column="technology_document_id"/>
        <result property="meterMark" column="meter_mark"/>
        <result property="orderUploadRemark" column="order_upload_remark"/>
        <result property="sort" column="sort"/>
    </resultMap>
 
    <select id="getPage" resultType="com.chinaztt.mes.plan.dto.OperationTaskProduceDTO">
        SELECT *
        FROM (
            SELECT
                potp.*,
                bp."id" part_id,
                bp.part_no,
                bp.part_name,
                pco.technology_document_id,
                pc.customer_name
            FROM production_operation_task_produce potp
            LEFT JOIN plan_customer_order pco ON pco."id" = potp."customer_order_id"
            LEFT JOIN plan_customer pc ON pc."id" = pco.customer_id
            LEFT JOIN basic_part bp ON bp.part_no = pco.part_no
            WHERE
                pco.is_audit = '03accepted'
                AND (potp.is_generate_task IS NULL OR potp.is_generate_task = false)
                <if test="ids != null and ids.size() != 0">
                    AND potp.id IN
                    <foreach collection="ids" item="id" open="(" separator="," close=")">
                        #{id}
                    </foreach>
                </if>
            ORDER BY potp.otc_line_no, potp.sort ASC
        ) TEMP
        <if test="ew.emptyOfWhere == false">
            ${ew.customSqlSegment}
        </if>
    </select>
 
    <select id="getSnNumbers" resultType="java.lang.String">
        SELECT sn_no
        FROM (
                 SELECT sn_no
                 FROM production_operation_task_produce
                 WHERE sn_no LIKE #{outBatchNo}
                 UNION
                 SELECT out_batch_no AS sn_no
                 FROM production_product_output
                 WHERE out_batch_no LIKE #{outBatchNo}
                UNION
                SELECT sn AS sn_no
                FROM plan_manufacturing_order_sn_generate
                WHERE sn LIKE #{outBatchNo}
        ) oot
        ORDER BY substr(sn_no, 7, 6) DESC
    </select>
 
    <select id="getLastSnNumber" resultType="java.lang.String">
        SELECT sn_no
        FROM (
                 SELECT sn_no
                 FROM production_operation_task_produce
                 WHERE sn_no LIKE #{snNo}
        ) oot
        ORDER BY substr(sn_no, 9, 3) DESC
        LIMIT 1
    </select>
 
    <select id="getListByOrderNo" resultType="com.chinaztt.mes.plan.dto.OperationTaskProduceDTO">
        SELECT
            potp.*,
            bp."id" part_id,
            bp.part_no,
            bp.part_name,
            pco.technology_document_id,
            pc.customer_name
        FROM production_operation_task_produce potp
                 LEFT JOIN plan_customer_order pco ON pco."id" = potp."customer_order_id"
                 LEFT JOIN plan_customer pc ON pc."id" = pco.customer_id
                 LEFT JOIN basic_part bp ON bp.part_no = pco.part_no
        WHERE
            potp.otc_customer_order_no = #{otcCustomerOrderNo}
        ORDER BY potp.otc_line_no, potp.sort ASC
    </select>
</mapper>