yangys
2024-05-18 c9b04383c77f91ac309e37e70783edcf8a9298b5
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
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
<?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.qianwen.smartman.modules.coproduction.mapper.OrderProcessMapper">
 
    <select id="startDetailGeneral" resultType="com.qianwen.smartman.modules.coproduction.vo.OrderProcessGeneralDetailVO">
        SELECT bop.id                                             AS orderProcessId,
               bop.process_code                                   AS processCode,
               bop.process_name                                   AS processName,
               bo.order_code                                      AS orderCode,
               bo.id                                              AS orderId,
               product.CODE                                       AS productCode,
               product.NAME                                       AS productName,
               product.id                                         AS productId,
               bop.input_num                                      AS inputNum,
               bop.qualify_num                                    AS qualifyNum,
               bop.scrapped_num                                   AS scrappedNum,
               bop.qualify_num + bop.scrapped_num                 AS reportNum,
               bop.input_num - bop.qualify_num - bop.scrapped_num AS waitReportNum,
               bop.workstation_id                                 AS workstationId,
               bop.workstation_name                               AS workstationName
        FROM blade_order_process bop
                 LEFT JOIN blade_order bo ON bop.order_id = bo.id
            AND bo.is_deleted = 0
                 LEFT JOIN blade_plan bp ON bo.plan_id = bp.id
            AND bp.is_deleted = 0
                 LEFT JOIN blade_product product ON bp.product_id = product.id
            AND product.is_deleted = 0
        WHERE bop.is_deleted = 0
          AND bop.id = #{orderProcessId}
    </select>
 
    <resultMap id="orderProcessRelateDetailVO"
               type="com.qianwen.smartman.modules.coproduction.vo.OrderProcessDetailVO">
        <id column="id" property="id"/>
        <result column="process_name" property="processName"/>
        <result column="process_code" property="processCode"/>
        <result column="sort" property="sort"/>
        <result column="remark" property="remark"/>
        <result column="plan_id" property="planId"/>
        <result column="order_id" property="orderId"/>
        <result column="program_id" property="programId"/>
        <result column="program_name" property="programName"/>
        <result column="process_status_before" property="processStatusBefore"/>
        <result column="process_status" property="processStatus"/>
        <result column="processStatusStr" property="processStatusStr"/>
        <result column="input_num" property="inputNum"/>
        <result column="qualify_num" property="qualifyNum"/>
        <result column="scrapped_num" property="scrappedNum"/>
        <result column="standard_time" property="standardTime"/>
        <result column="start_time" property="startTime"/>
        <result column="end_time" property="endTime"/>
        <result column="workstation_id" property="workstationId"/>
        <result column="workstation_name" property="workstationName"/>
        <result column="art_bag_id" property="artBagId"/>
        <result column="art_bag_name" property="artBagName"/>
        <result column="prepare_time" property="prepareTime"/>
        <result column="disassembly_time" property="disassemblyTime"/>
        <result column="transport_time" property="transportTime"/>
        <result column="whether_test" property="whetherTest"/>
        <result column="whether_parallel" property="whetherParallel"/>
        <result column="workType" property="workType"/>
        <result column="workTypeStr" property="workTypeStr"/>
        <result column="main_sequence_id" property="mainSequenceId"/>
        <result column="parentId" property="parentId"/>
    </resultMap>
 
    <select id="listByOrderId" resultType="com.qianwen.smartman.modules.coproduction.vo.OrderProcessDetailVO">
        select bop.id,
               bop.plan_id,
               bop.order_id,
               bop.sort,
               bop.process_code,
               bop.process_name,
               bop.program_id,
               bop.program_name,
               bop.process_status_before,
               bop.process_status,
               bd1.dict_value       processStatusStr,
               bop.input_num,
               bop.qualify_num,
               bop.scrapped_num,
               bop.standard_time,
               bop.start_time,
               bop.end_time,
               bop.workstation_id,
               bop.workstation_name,
               bop.art_bag_id,
               bop.art_bag_name,
               bop.prepare_time,
               bop.disassembly_time,
               bop.transport_time,
               bop.whether_test,
               bop.whether_parallel,
               bop.main_sequence_id,
               bop.main_sequence_id parentId,
               bpro.type            workType,
               bd.dict_value        workTypeStr,
               bp.craft_id,
               bp.craft_version
        from blade_order_process bop
                 left join blade_order bo on bo.id = bop.order_id and bo.is_deleted = 0
                 left join blade_process bpro on bpro.code = bop.process_code and bpro.is_deleted = 0
                 left join blade_plan bp on bp.id = bop.plan_id and bp.is_deleted = 0
                 left join blade_dict bd on bd.dict_key = bpro.type and bd.code = 'work_type' and bd.is_deleted = 0
                 left join blade_dict bd1
                           on bd1.dict_key = bop.process_status and bd1.code = 'process_status' and bd1.is_deleted = 0
        where bop.is_deleted = 0
          and bo.id = #{orderId}
        order by bop.sort
    </select>
 
    <select id="startDetailGeneralByParallel"
            resultType="com.qianwen.smartman.modules.coproduction.vo.OrderProcessGeneralDetailVO">
        SELECT bop.id                                             AS orderProcessId,
               bop.process_code                                   AS processCode,
               bop.process_name                                   AS processName,
               bo.order_code                                      AS orderCode,
               bo.id                                              AS orderId,
               product.CODE                                       AS productCode,
               product.NAME                                       AS productName,
               product.id                                         AS productId,
               bop.input_num                                      AS inputNum,
               bop.qualify_num                                    AS qualifyNum,
               bop.scrapped_num                                   AS scrappedNum,
               bop.qualify_num + bop.scrapped_num                 AS reportNum,
               bop.input_num - bop.qualify_num - bop.scrapped_num AS waitReportNum,
               bop.workstation_id                                 AS workstationId,
               bop.workstation_name                               AS workstationName
        FROM blade_order_process bop
                 LEFT JOIN blade_order bo ON bop.order_id = bo.id
            AND bo.is_deleted = 0
                 LEFT JOIN blade_plan bp ON bo.plan_id = bp.id
            AND bp.is_deleted = 0
                 LEFT JOIN blade_product product ON bp.product_id = product.id
            AND product.is_deleted = 0
        WHERE bop.is_deleted = 0
          AND bop.main_sequence_id = #{orderProcessId}
    </select>
 
    <resultMap id="orderProcessRelationVO"
               type="com.qianwen.smartman.modules.coproduction.vo.OrderProcessRelationVO">
        <id column="process_id" property="processId"/>
        <collection property="fixtureVOList" ofType="com.qianwen.smartman.modules.cps.vo.FixtureVO">
            <id column="fixtureId" property="id"/>
            <result column="fixtureCode" property="code"/>
            <result column="fixtureName" property="name"/>
            <result column="fixtureGroupId" property="fixtureGroupId"/>
            <result column="fixtureGroupName" property="fixtureGroupName"/>
            <result column="trayId" property="trayId"/>
            <result column="trayCode" property="trayCode"/>
            <result column="trayName" property="trayName"/>
        </collection>
        <collection property="toolManageVOList" ofType="com.qianwen.smartman.modules.tool.vo.ToolManageVO">
            <id column="toolId" property="id"/>
            <result column="toolCode" property="code"/>
            <result column="toolCategoryId" property="toolCategoryId"/>
            <result column="toolCategory" property="toolCategory"/>
            <result column="toolModelId" property="toolModelId"/>
            <result column="toolModel" property="toolModel"/>
        </collection>
    </resultMap>
 
    <select id="getRelation" resultMap="orderProcessRelationVO">
        select bcp.process_id,
               bf.id     fixtureId,
               bf.code   fixtureCode,
               bf.name   fixtureName,
               bcg.id    fixtureGroupId,
               bcg.name  fixtureGroupName,
               btr.id    trayId,
               btr.code  trayCode,
               btr.name  trayName,
               bt.id     toolId,
               bt.code   toolCode,
               btc.id    toolCategoryId,
               btc.name  toolCategory,
               btm.id    toolModelId,
               btm.model toolModel
        from blade_production_craft_version bcv
                 left join blade_production_craft_process bcp on bcp.version_id = bcv.id and bcp.is_deleted = 0
                 left join blade_production_craft_process_related_fixture bcf on bcf.version_process_id = bcp.id
                 left join blade_fixture bf on bf.id = bcf.fixture_id and bf.is_deleted = 0
                 left join blade_common_group_of_item bgi on bgi.item_id = bf.id
                 left join blade_common_group bcg
                           on bcg.group_type = 'group_fixture' and bcg.group_category = 1 and bcg.id = bgi.group_id
                               and bcg.is_deleted = 0
                 left join blade_tray_fixture btf on btf.fix_id = bf.id and btf.is_deleted = 0
                 left join blade_tray btr on btr.id = btf.tray_id and btr.is_deleted = 0
                 left join blade_production_craft_process_related_tool bct on bct.version_process_id = bcp.id
                 left join blade_tool bt on bt.id = bct.tool_id and bt.is_deleted = 0
                 left join blade_tool_category btc on btc.id = bt.tool_category_id and btc.is_deleted = 0
                 left join blade_tool_model btm on btm.id = bt.tool_model_id and btm.is_deleted = 0
        where bcv.craft_id = #{orderProcessRelationQueryVO.craftId}
          and bcv.id = #{orderProcessRelationQueryVO.craftVersionId}
          and bcv.is_deleted = 0
          and bcp.process_code = #{orderProcessRelationQueryVO.processCode}
          and bcp.sort = #{orderProcessRelationQueryVO.sort}
    </select>
    <select id="listDetailByOrderId" resultType="com.qianwen.smartman.modules.coproduction.vo.OrderProcessDetailVO">
        select bop.id,
               bop.plan_id,
               bop.order_id,
               bop.sort,
               bop.process_code,
               bop.process_name,
               bop.program_id,
               bop.program_name,
               bop.process_status_before,
               bop.process_status,
               bd1.dict_value       processStatusStr,
               bop.input_num,
               bop.qualify_num,
               bop.scrapped_num,
               bop.standard_time,
               bop.start_time,
               bop.end_time,
               bop.workstation_id,
               bop.workstation_name,
               bop.art_bag_id,
               bop.art_bag_name,
               bop.prepare_time,
               bop.disassembly_time,
               bop.transport_time,
               bop.whether_test,
               bop.whether_parallel,
               bop.main_sequence_id,
               bop.main_sequence_id parentId,
               bpro.type            workType,
               bd.dict_value        workTypeStr,
               bp.craft_id,
               bp.craft_version,
                <if test="_databaseId=='mysql'">
                    GROUP_CONCAT( DISTINCT (borr.producer_user_name) SEPARATOR ',' ) AS producerUserName
                </if>
                <if test="_databaseId=='dm'">
                    WM_CONCAT( DISTINCT (borr.producer_user_name)) AS producerUserName
                </if>
                <if test="_databaseId=='oracle'">
                    LISTAGG ( DISTINCT (borr.producer_user_name), ',' ) WITHIN GROUP ( ORDER BY borr.producer_user_name ) AS producerUserName
                </if>
        from blade_order_process bop
                 left join blade_order bo on bo.id = bop.order_id and bo.is_deleted = 0
                 left join blade_process bpro on bpro.code = bop.process_code and bpro.is_deleted = 0
                 left join blade_plan bp on bp.id = bop.plan_id and bp.is_deleted = 0
                 left join blade_dict bd on bd.dict_key = bpro.type and bd.code = 'work_type' and bd.is_deleted = 0
                 left join blade_dict bd1
                           on bd1.dict_key = bop.process_status and bd1.code = 'process_status' and bd1.is_deleted = 0
                 left join blade_order_report_record borr on borr.process_id = bop.id and borr.is_deleted = 0
        where bop.is_deleted = 0
          and bo.id = #{orderId}
        group by bop.id,
                 bop.plan_id,
                 bop.order_id,
                 bop.sort,
                 bop.process_code,
                 bop.process_name,
                 bop.program_id,
                 bop.program_name,
                 bop.process_status_before,
                 bop.process_status,
                 bd1.dict_value,
                 bop.input_num,
                 bop.qualify_num,
                 bop.scrapped_num,
                 bop.standard_time,
                 bop.start_time,
                 bop.end_time,
                 bop.workstation_id,
                 bop.workstation_name,
                 bop.art_bag_id,
                 bop.art_bag_name,
                 bop.prepare_time,
                 bop.disassembly_time,
                 bop.transport_time,
                 bop.whether_test,
                 bop.whether_parallel,
                 bop.main_sequence_id,
                 bop.main_sequence_id,
                 bpro.type,
                 bd.dict_value,
                 bp.craft_id,
                 bp.craft_version
        order by bop.sort
    </select>
</mapper>