guoyuji
2024-01-26 deb789b123fc47b37859da8a6dd16910cf7c96cb
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
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
<?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.example.erp.mapper.mm.FinishedGoodsInventoryMapper">
 
    <resultMap id="selectFinishedGoodsInventory" type="com.example.erp.entity.mm.FinishedGoodsInventory">
        <id column="fid" property="id"/>
        <result column="inventory" property="inventory"/>
        <result column="area" property="area"/>
        <result column="actual_signal_area" property="actualSignalArea"/>
        <result column="quantity_available" property="quantityAvailable"/>
        <result column="warehouse_number" property="warehouseNumber"/>
        <result column="storage_region" property="storageRegion"/>
        <result column="status" property="status"/>
        <result column="enter_storage_time" property="enterStorageTime"/>
        <result column="remark" property="remark"/>
        <result column="update_time" property="updateTime"/>
        <result column="end_time" property="endTime"/>
 
        <result column="order_id" property="order.orderId"/>
        <result column="project" property="order.project"/>
        <result column="order_type" property="order.orderType"/>
 
 
        <result column="order_number" property="orderDetail.orderNumber"/>
        <result column="width" property="orderDetail.width"/>
        <result column="height" property="orderDetail.height"/>
        <result column="product_name" property="orderDetail.productName"/>
        <result column="product_id" property="orderDetail.productId"/>
 
    </resultMap>
 
    <resultMap id="selectFlowCard" type="com.example.erp.entity.pp.FlowCard">
        <id column="id" property="id"/>
        <result column="order_number" property="orderNumber"/>
        <result column="inventory_quantity" property="inventoryQuantity"/>
        <result column="process_id" property="processId"/>
        <result column="received_quantity" property="receivedQuantity"/>
 
 
        <result column="order_id" property="order.orderId"/>
        <result column="project" property="order.project"/>
        <result column="creater" property="order.creater"/>
        <result column="area" property="order.area"/>
        <result column="batch" property="order.batch"/>
 
        <result column="building_number" property="orderDetail.buildingNumber"/>
        <result column="width" property="orderDetail.width"/>
        <result column="height" property="orderDetail.height"/>
        <result column="product_name" property="orderDetail.productName"/>
        <result column="product_id" property="orderDetail.productId"/>
        <result column="quantity" property="orderDetail.quantity"/>
    </resultMap>
 
    <update id="updateflowcard">
        update pp.flow_card
        set received_quantity=received_quantity+${inventoryQuantity}
        where order_number=#{orderNumber} and process_id=#{processId}
    </update>
 
    <update id="updateInventory">
        update mm.finished_goods_inventory
        set inventory=inventory+${inventoryQuantity},quantity_available=quantity_available+${inventoryQuantity},
            update_time=now(),area=area+actual_signal_area*${inventoryQuantity}
        where order_number=#{orderNumber}
    </update>
 
    <insert id="insertFinishedGoodsInventory"  useGeneratedKeys="true"  >
        insert into mm.finished_goods_inventory (order_id,
                                                 order_number,
                                                 inventory,
                                                 actual_signal_area,
                                                 area,
                                                 quantity_available,
                                                 warehouse_number,
                                                 storage_region,
                                                 `status`,
                                                 enter_storage_time,
                                                 update_time,
                                                 end_time,
                                                 remark
        )
        values (
                   #{flowCard.order.orderId} ,#{flowCard.orderNumber},#{flowCard.inventoryQuantity},ROUND(#{flowCard.orderDetail.width}*#{flowCard.orderDetail.height}/1000000,2),
                   ROUND(#{flowCard.orderDetail.width}*#{flowCard.orderDetail.height}*#{flowCard.inventoryQuantity}/1000000,2),
                #{flowCard.inventoryQuantity},null,#{storageRegion},
                0,now(),now(),null,#{remark}
               )
    </insert>
 
    <select id="findOrderNumberdcount" >
        select count(*)
        from  mm.`finished_goods_inventory`
        where order_number = #{orderNumber}
 
    </select>
 
    <select id="findOrderNumberd" >
        select *
        from  sd.finished_goods_inventory
         where order_number = #{orderNumber}
 
    </select>
 
    <select id="getseletwarehousing" resultMap="selectFlowCard">
        select
        fc.id,
        o.order_id,
        od.building_number,
        od.product_id,
        od.product_name,
        od.width,
        od.height,
        o.creater,
        o.project,
        fc.order_number,
        od.quantity,
        fc.inventory_quantity,
        o.area,
        fc.process_id,
        fc.received_quantity,
        o.batch
        from pp.flow_card fc left join sd.order_detail od on fc.order_number=od.order_number inner join sd.`order` o on
        o.order_id=fc.order_id
        <where>
                and fc.received_quantity <![CDATA[<]]> fc.inventory_quantity
            <if test="flowCard.order.orderId != null and flowCard.order.orderId != ''">
                and o.order_id regexp #{flowCard.order.orderId}
            </if>
            <if test="flowCard.orderDetail.buildingNumber != null and flowCard.orderDetail.buildingNumber != ''">
                and od.building_number regexp #{flowCard.orderDetail.buildingNumber}
            </if>
            <if test="flowCard.orderDetail.productId != null and flowCard.orderDetail.productId != ''">
                and od.product_id regexp #{flowCard.orderDetail.productId}
            </if>
            <if test="flowCard.orderDetail.productName != null and flowCard.orderDetail.productName != ''">
                and od.product_name regexp #{flowCard.orderDetail.productName}
            </if>
            <if test="flowCard.orderDetail.width != null and flowCard.orderDetail.width != ''">
                and od.width regexp #{flowCard.orderDetail.width}
            </if>
            <if test="flowCard.orderDetail.height != null and flowCard.orderDetail.height != ''">
                and od.height regexp #{flowCard.orderDetail.height}
            </if>
            <if test="flowCard.order.creater != null and flowCard.order.creater != ''">
                and o.creater regexp #{flowCard.order.creater}
            </if>
            <if test="flowCard.order.project != null and flowCard.order.project != ''">
                and o.project regexp #{flowCard.order.project}
            </if>
            <if test="flowCard.orderNumber != null and flowCard.orderNumber != ''">
                and fc.order_number regexp #{flowCard.orderNumber}
            </if>
            <if test="flowCard.orderDetail.quantity != null and flowCard.orderDetail.quantity != ''">
                and od.quantity regexp #{flowCard.orderDetail.quantity}
            </if>
            <if test="flowCard.inventoryQuantity != null and flowCard.inventoryQuantity != ''">
                and fc.inventory_quantity regexp #{flowCard.inventoryQuantity}
            </if>
            <if test="flowCard.order.area != null and flowCard.order.area != ''">
                and o.area regexp #{flowCard.order.area}
            </if>
            <if test="flowCard.order.batch != null and flowCard.order.batch != ''">
                and o.batch regexp #{flowCard.order.batch}
            </if>
            <if test="flowCard.processId != null and flowCard.processId != ''">
                and fc.process_id regexp #{flowCard.processId}
            </if>
            <if test="flowCard.receivedQuantity != null and flowCard.receivedQuantity != ''">
                and fc.received_quantity regexp #{flowCard.receivedQuantity}
            </if>
 
        </where>
        group by fc.order_number,fc.process_id order by fc.create_time
        limit #{offset},#{pageSize};
    </select>
    <select id="getseletwarehousingPageTotal" >
        select  CEILING(count(zu.order_number)/#{pageSize}) from (
        select fc.order_number as order_number,fc.process_id from pp.flow_card fc left join sd.order_detail od on
        fc.order_number=od.order_number inner join sd.`order` o on o.order_id=fc.order_id
        <where>
            and fc.received_quantity <![CDATA[<]]> fc.inventory_quantity
            <if test="flowCard.order.orderId != null and flowCard.order.orderId != ''">
                and o.order_id regexp #{flowCard.order.orderId}
            </if>
            <if test="flowCard.orderDetail.buildingNumber != null and flowCard.orderDetail.buildingNumber != ''">
                and od.building_number regexp #{flowCard.orderDetail.buildingNumber}
            </if>
            <if test="flowCard.orderDetail.productId != null and flowCard.orderDetail.productId != ''">
                and od.product_id regexp #{flowCard.orderDetail.productId}
            </if>
            <if test="flowCard.orderDetail.productName != null and flowCard.orderDetail.productName != ''">
                and od.product_name regexp #{flowCard.orderDetail.productName}
            </if>
            <if test="flowCard.orderDetail.width != null and flowCard.orderDetail.width != ''">
                and od.width regexp #{flowCard.orderDetail.width}
            </if>
            <if test="flowCard.orderDetail.height != null and flowCard.orderDetail.height != ''">
                and od.height regexp #{flowCard.orderDetail.height}
            </if>
            <if test="flowCard.order.creater != null and flowCard.order.creater != ''">
                and o.creater regexp #{flowCard.order.creater}
            </if>
            <if test="flowCard.order.project != null and flowCard.order.project != ''">
                and o.project regexp #{flowCard.order.project}
            </if>
            <if test="flowCard.orderNumber != null and flowCard.orderNumber != ''">
                and fc.order_number regexp #{flowCard.orderNumber}
            </if>
            <if test="flowCard.orderDetail.quantity != null and flowCard.orderDetail.quantity != ''">
                and od.quantity regexp #{flowCard.orderDetail.quantity}
            </if>
            <if test="flowCard.inventoryQuantity != null and flowCard.inventoryQuantity != ''">
                and fc.inventory_quantity regexp #{flowCard.inventoryQuantity}
            </if>
            <if test="flowCard.order.area != null and flowCard.order.area != ''">
                and o.area regexp #{flowCard.order.area}
            </if>
            <if test="flowCard.order.batch != null and flowCard.order.batch != ''">
                and o.batch regexp #{flowCard.order.batch}
            </if>
            <if test="flowCard.processId != null and flowCard.processId != ''">
                and fc.process_id regexp #{flowCard.processId}
            </if>
            <if test="flowCard.receivedQuantity != null and flowCard.receivedQuantity != ''">
                and fc.received_quantity regexp #{flowCard.receivedQuantity}
            </if>
 
        </where>
        group by fc.order_number,fc.process_id order by fc.create_time) as zu
    </select>
 
 
    <select id="defaultfinishedGoods" resultMap="selectFinishedGoodsInventory">
        select od.order_number,
        o.order_id,
        o.project,
        o.order_type,
        od.product_name,
        od.product_id,
        od.width,
        od.height,
        fgi.inventory,
        fgi.quantity_available,
        fgi.actual_signal_area,
        fgi.area,
        fgi.warehouse_number,
        fgi.storage_region,
        fgi.`status`,
        fgi.update_time,
        fgi.enter_storage_time,
        fgi.end_time,
        fgi.remark
        from finished_goods_inventory fgi
        left join sd.order_detail od on fgi.order_number = od.order_number
        inner join sd.`order` o on fgi.order_id = o.order_id
        <where>
            <if test="finishedGoodsInventory.orderDetail.width != null and finishedGoodsInventory.orderDetail.width != ''">
                and od.width regexp #{finishedGoodsInventory.orderDetail.width}
            </if>
            <if test="finishedGoodsInventory.orderDetail.orderNumber != null and finishedGoodsInventory.orderDetail.orderNumber != ''">
                and od.order_number regexp #{finishedGoodsInventory.orderDetail.orderNumber}
            </if>
            <if test="finishedGoodsInventory.orderDetail.productName != null and finishedGoodsInventory.orderDetail.productName != ''">
                and od.product_name regexp #{finishedGoodsInventory.orderDetail.productName}
            </if>
            <if test="finishedGoodsInventory.orderDetail.productId != null and finishedGoodsInventory.orderDetail.productId != ''">
                and od.product_id regexp #{finishedGoodsInventory.orderDetail.productId}
            </if>
            <if test="finishedGoodsInventory.order.orderId != null and finishedGoodsInventory.order.orderId != ''">
                and o.order_id regexp #{finishedGoodsInventory.order.orderId}
            </if>
            <if test="finishedGoodsInventory.order.project != null and finishedGoodsInventory.order.project != ''">
                and o.project regexp #{finishedGoodsInventory.order.project}
            </if>
            <if test="finishedGoodsInventory.order.orderType != null and finishedGoodsInventory.order.orderType != ''">
                and o.order_type regexp #{finishedGoodsInventory.order.orderType}
            </if>
            <if test="finishedGoodsInventory.orderDetail.height != null and finishedGoodsInventory.orderDetail.height != ''">
                and od.height regexp #{finishedGoodsInventory.orderDetail.height}
            </if>
            <if test="finishedGoodsInventory.inventory != null and finishedGoodsInventory.inventory != ''">
                and fgi.inventory regexp #{finishedGoodsInventory.inventory}
            </if>
            <if test="finishedGoodsInventory.quantityAvailable != null and finishedGoodsInventory.quantityAvailable != ''">
                and fgi.quantity_available regexp #{finishedGoodsInventory.quantityAvailable}
            </if>
            <if test="finishedGoodsInventory.actualSignalArea != null and finishedGoodsInventory.actualSignalArea != ''">
                and fgi.actual_signal_area regexp #{finishedGoodsInventory.actualSignalArea}
            </if>
            <if test="finishedGoodsInventory.area != null and finishedGoodsInventory.area != ''">
                and fgi.area regexp #{finishedGoodsInventory.area}
            </if>
            <if test="finishedGoodsInventory.warehouseNumber != null and finishedGoodsInventory.warehouseNumber != ''">
                and fgi.warehouse_number regexp #{finishedGoodsInventory.warehouseNumber}
            </if>
            <if test="finishedGoodsInventory.storageRegion != null and finishedGoodsInventory.storageRegion != ''">
                and fgi.storage_region regexp #{finishedGoodsInventory.storageRegion}
            </if>
            <if test="finishedGoodsInventory.status != null and finishedGoodsInventory.status != ''">
                and fgi.`status` regexp #{finishedGoodsInventory.status}
            </if>
            <if test="finishedGoodsInventory.enterStorageTime != null and finishedGoodsInventory.enterStorageTime != ''">
                and fgi.enter_storage_time regexp #{finishedGoodsInventory.enterStorageTime}
            </if>
            <if test="finishedGoodsInventory.updateTime != null and finishedGoodsInventory.updateTime != ''">
                and fgi.update_time regexp #{finishedGoodsInventory.updateTime}
            </if>
            <if test="finishedGoodsInventory.endTime != null and finishedGoodsInventory.endTime != ''">
                and fgi.end_time regexp #{finishedGoodsInventory.endTime}
            </if>
            <if test="finishedGoodsInventory.remark != null and finishedGoodsInventory.remark != ''">
                and fgi.remark regexp #{finishedGoodsInventory.remark}
            </if>
 
        </where>
        order by fgi.id
 
        limit #{offset},#{pageSize}
        ;
    </select>
 
 
    <select id="getPageTotal">
        select
        CEILING(count(fgi.id)/#{pageSize})
        from finished_goods_inventory fgi
        left join sd.order_detail od on fgi.order_number = od.order_number
        inner join sd.`order` o on fgi.order_id = o.order_id
        <where>
            <if test="finishedGoodsInventory.orderDetail.width != null and finishedGoodsInventory.orderDetail.width != ''">
                and od.width regexp #{finishedGoodsInventory.orderDetail.width}
            </if>
            <if test="finishedGoodsInventory.orderDetail.orderNumber != null and finishedGoodsInventory.orderDetail.orderNumber != ''">
                and od.order_number regexp #{finishedGoodsInventory.orderDetail.orderNumber}
            </if>
            <if test="finishedGoodsInventory.orderDetail.productName != null and finishedGoodsInventory.orderDetail.productName != ''">
                and od.product_name regexp #{finishedGoodsInventory.orderDetail.productName}
            </if>
            <if test="finishedGoodsInventory.orderDetail.productId != null and finishedGoodsInventory.orderDetail.productId != ''">
                and od.product_id regexp #{finishedGoodsInventory.orderDetail.productId}
            </if>
            <if test="finishedGoodsInventory.order.orderId != null and finishedGoodsInventory.order.orderId != ''">
                and o.order_id regexp #{finishedGoodsInventory.order.orderId}
            </if>
            <if test="finishedGoodsInventory.order.project != null and finishedGoodsInventory.order.project != ''">
                and o.project regexp #{finishedGoodsInventory.order.project}
            </if>
            <if test="finishedGoodsInventory.order.orderType != null and finishedGoodsInventory.order.orderType != ''">
                and o.order_type regexp #{finishedGoodsInventory.order.orderType}
            </if>
            <if test="finishedGoodsInventory.orderDetail.height != null and finishedGoodsInventory.orderDetail.height != ''">
                and od.height regexp #{finishedGoodsInventory.orderDetail.height}
            </if>
            <if test="finishedGoodsInventory.inventory != null and finishedGoodsInventory.inventory != ''">
                and fgi.inventory regexp #{finishedGoodsInventory.inventory}
            </if>
            <if test="finishedGoodsInventory.quantityAvailable != null and finishedGoodsInventory.quantityAvailable != ''">
                and fgi.quantity_available regexp #{finishedGoodsInventory.quantityAvailable}
            </if>
            <if test="finishedGoodsInventory.actualSignalArea != null and finishedGoodsInventory.actualSignalArea != ''">
                and fgi.actual_signal_area regexp #{finishedGoodsInventory.actualSignalArea}
            </if>
            <if test="finishedGoodsInventory.area != null and finishedGoodsInventory.area != ''">
                and fgi.area regexp #{finishedGoodsInventory.area}
            </if>
            <if test="finishedGoodsInventory.warehouseNumber != null and finishedGoodsInventory.warehouseNumber != ''">
                and fgi.warehouse_number regexp #{finishedGoodsInventory.warehouseNumber}
            </if>
            <if test="finishedGoodsInventory.storageRegion != null and finishedGoodsInventory.storageRegion != ''">
                and fgi.storage_region regexp #{finishedGoodsInventory.storageRegion}
            </if>
            <if test="finishedGoodsInventory.status != null and finishedGoodsInventory.status != ''">
                and fgi.`status` regexp #{finishedGoodsInventory.status}
            </if>
            <if test="finishedGoodsInventory.enterStorageTime != null and finishedGoodsInventory.enterStorageTime != ''">
                and fgi.enter_storage_time regexp #{finishedGoodsInventory.enterStorageTime}
            </if>
            <if test="finishedGoodsInventory.updateTime != null and finishedGoodsInventory.updateTime != ''">
                and fgi.update_time regexp #{finishedGoodsInventory.updateTime}
            </if>
            <if test="finishedGoodsInventory.endTime != null and finishedGoodsInventory.endTime != ''">
                and fgi.end_time regexp #{finishedGoodsInventory.endTime}
            </if>
            <if test="finishedGoodsInventory.remark != null and finishedGoodsInventory.remark != ''">
                and fgi.remark regexp #{finishedGoodsInventory.remark}
            </if>
 
        </where>
 
        order by fgi.id desc
        limit #{offset},#{pageSize}
        ;
    </select>
 
</mapper>