自动化立体仓库 - WMS系统
1
IZCD4L12RTSW0VZ\Administrator
11 小时以前 4df7d6e74b42acb1c5716ed87f26d236568b60df
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
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
package com.zy.api.service.impl;
 
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.plugins.Page;
import com.core.common.SnowflakeIdWorker;
import com.core.exception.CoolException;
import com.zy.api.controller.params.PageRequestParams;
import com.zy.api.entity.OrderItemsParam;
import com.zy.api.entity.OrderParams;
import com.zy.api.entity.OutOrderParams;
import com.zy.api.entity.PubOrderParams;
import com.zy.api.entity.ReportOrderParam;
import com.zy.api.entity.StockAdjustParams;
import com.zy.api.entity.StockUpOrderParams;
import com.zy.api.entity.SyncMatParmas;
import com.zy.api.entity.dto.XSR;
import com.zy.api.enums.MatLocType;
import com.zy.api.enums.OrderType;
import com.zy.api.enums.OrderWkType;
import com.zy.api.service.KopenApiService;
import com.zy.asrs.entity.CheckOrder;
import com.zy.asrs.entity.CheckOrderDetl;
import com.zy.asrs.entity.LocDetl;
import com.zy.asrs.entity.Mat;
import com.zy.asrs.entity.Order;
import com.zy.asrs.entity.OrderDetl;
import com.zy.asrs.enums.CommonEnum;
import com.zy.asrs.enums.OrderSettle;
import com.zy.asrs.enums.OrderTypeEnum;
import com.zy.asrs.service.CheckOrderDetlService;
import com.zy.asrs.service.CheckOrderService;
import com.zy.asrs.service.LocDetlService;
import com.zy.asrs.service.MatService;
import com.zy.asrs.service.OrderDetlService;
import com.zy.asrs.service.OrderService;
 
import com.zy.asrs.utils.Utils;
import com.zy.common.utils.HttpHandler;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
 
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Objects;
 
@Service("kopenApiServiceImpl")
public class KopenApiServiceImpl implements KopenApiService {
 
    @Autowired
    private OrderService orderService;
    @Autowired
    private OrderDetlService orderDetlService;
    @Autowired
    private MatService matService;
    @Autowired
    private LocDetlService locDetlService;
    @Autowired
    private CheckOrderService checkOrderService;
    @Autowired
    private SnowflakeIdWorker snowflakeIdWorker;
    @Autowired
    private CheckOrderDetlService checkOrderDetlService;
 
    /**
     * 接收下发订单信息
     *
     * @param orderParams
     * @return com.core.common.R
     * @author Ryan
     * @date 2025/11/24 14:49
     */
    @Override
    public XSR receiveOrders(List<PubOrderParams> orderParams) {
        orderParams.forEach(params -> {
            if (params.getType().equals(OrderWkType.getTypeVal(params.getType()))) {
                throw new CoolException("当前类型不是上架派工单!!");
            }
            addOrUpdateOrders(params, "add");
        });
 
        return XSR.ok("单据下发成功!!");
    }
 
    /**
     * 上架派工单反馈
     *
     * @author Ryan
     * @date 2025/11/24 15:33
     */
    @Override
    @Transactional(rollbackFor = Exception.class)
    public XSR getInDispatchResult(List<ReportOrderParam> params) {
        if (Objects.isNull(params)) {
            return XSR.error("参数不能为空!!");
        }
        String response = null;
        try {
            response = new HttpHandler.Builder()
                    .setUri("127.0.0.1:8081")
                    .setPath("/wms/order/getInDispatchResult")
                    .setJson(JSONObject.toJSONString(params))
                    .build()
                    .doPost();
            if (Objects.isNull(response) || response.trim().isEmpty()) {
                return XSR.error("外网接口无响应!!");
            }
            JSONObject jsonObject = JSONObject.parseObject(response);
            Integer code = jsonObject.getInteger("code");
            if (!Objects.isNull(code) && code.equals(1)) {
                return XSR.ok("入库单上报完成!!");
            } else {
                String msg = jsonObject.getString("message");
                return XSR.error(Objects.isNull(msg) ? "上报失败!!" : msg);
            }
        } catch (Exception e) {
            return XSR.error(e.getMessage());
        }
    }
 
    /* */
 
    /**
     * 备货指示派工单下发
     *
     * @param pubOrderParams
     * @return com.core.common.R
     * @author Ryan
     * @date 2025/11/24 15:21
     */
    @Override
    @Transactional(rollbackFor = Exception.class)
    public XSR sendOutDispatch(List<PubOrderParams> pubOrderParams) {
        if (Objects.isNull(pubOrderParams) || pubOrderParams.isEmpty()) {
            return XSR.error("参数不能为空!!");
        }
        pubOrderParams.forEach(params -> {
            // 校验参数
            if (Objects.isNull(params.getDispatch_no())) {
                throw new CoolException("派工单编号不能为空!!");
            }
            if (Objects.isNull(params.getKopen_id())) {
                throw new CoolException("流水号不能为空!!");
            }
            if (Objects.isNull(params.getCompany_id())) {
                throw new CoolException("公司ID不能为空!!");
            }
 
            addOrUpdateOrders(params, "add");
        });
 
        return XSR.ok("备货指示派工单下发成功!!");
    }
 
    // /**
    // * 备货指示派工单
    // *
    // * @author Ryan
    // * @date 2025/12/16 9:15
    // * @param params
    // */
    // private void outOrderAddAndUpdate(PubOrderParams params, String type) {
    // if (Objects.isNull(params)) {
    // throw new CoolException("参数不能为空!!");
    // }
    // if (Objects.isNull(params.getType())) {
    // throw new CoolException("订单类型不能为空!!");
    // }
 
    // OrderParams orderParams =
    // JSONObject.parseObject(JSONObject.toJSONString(params), OrderParams.class);
    // Order order = orderService.selectOne(new
    // EntityWrapper<Order>().eq("order_no", orderParams.getInv_no()));
    // if (type.equals("add") && !Objects.isNull(order)) {
    // throw new CoolException("单据已存在, 不可重复添加!!");
    // }
    // // 判断订单是否存在
    // if (Objects.isNull(order)) {
    // /** 不存在,新增订单 */
    // generateOrders(params);
    // } else {
    // /** 存在,删除老订单,更新插入新订单 */
    // // 删除旧订单明细
    // if (!orderDetlService.delete(new EntityWrapper<OrderDetl>().eq("order_id",
    // order.getId()))) {
    // throw new CoolException("订单明细删除失败!!");
    // }
    // ;
    // if (!orderService.deleteById(order.getId())) {
    // throw new CoolException("原单据删除失败!!");
    // }
    // generateOrders(params);
    // }
 
    // }
 
    /**
     * 基础零件变更
     *
     * @param params
     * @return com.core.common.R
     * @author Ryan
     * @date 2025/11/24 15:05
     */
    @Override
    @Transactional(rollbackFor = Exception.class)
    public synchronized XSR basMatupdate(List<SyncMatParmas> params) {
        if (Objects.isNull(params) || params.isEmpty()) {
            return XSR.error("参数不能为空!!");
        }
        params.forEach(mats -> {
            if (Objects.isNull(mats)) {
                throw new CoolException("物料编码不能为空!!");
            }
            if (Objects.isNull(mats.getPro_type())) {
                throw new CoolException("零件类型不能为空!!");
            }
            Mat matnr = matService.selectOne(new EntityWrapper<Mat>().eq("matnr", mats.getPro_komcode()));
            if (!Objects.isNull(matnr)) {
                // 订单时间
                if (Utils.isValidFormat(mats.getUpdate_time(), "yyyy-MM-dd HH:mm:ss")) {
                    Date date1 = Utils.getFormateDate(mats.getUpdate_time());
                    matnr.setUpdateTime(date1);
                }
                matnr.setMaktx(mats.getPro_name());
                matnr.setSpecs(mats.getPro_size());
                matnr.setWeight(Objects.isNull(mats.getPro_wet()) ? 0.0 : Double.parseDouble(mats.getPro_wet()));
                matnr.setSuppCode(mats.getPro_id());
                matnr.setTagId(MatLocType.getTag(mats.getPro_type()));
                matnr.setLocType(MatLocType.getTag(mats.getPro_type()));
                matnr.setManu(mats.getCompany_id());
                if (!matService.updateById(matnr)) {
                    throw new CoolException("物料更新失败或无需更新!!");
                }
            } else {
                if (Objects.isNull(matnr)) {
                    matnr = new Mat();
                }
                // 订单时间
                if (Utils.isValidFormat(mats.getUpdate_time(), "yyyy-MM-dd HH:mm:ss")) {
                    Date date1 = Utils.getFormateDate(mats.getUpdate_time());
                    matnr.setUpdateTime(date1);
                }
                matnr.setMaktx(mats.getPro_name());
                matnr.setMatnr(mats.getPro_komcode());
                matnr.setSpecs(mats.getPro_size());
                matnr.setWeight(Double.parseDouble(mats.getPro_wet()));
                matnr.setSuppCode(mats.getPro_id());
                matnr.setTagId(MatLocType.getTag(mats.getPro_type()));
                matnr.setLocType(MatLocType.getTag(mats.getPro_type()));
                matnr.setManu(mats.getCompany_id());
                if (!matService.insert(matnr)) {
                    throw new CoolException("物料更新失败!!");
                }
            }
        });
 
        return XSR.ok("保存成功!!");
    }
 
    /**
     * 新增或修改订单信息
     *
     * @author Ryan
     * @date 2025/11/24 15:32
     */
    @Override
    @Transactional(rollbackFor = Exception.class)
    public void addOrUpdateOrders(PubOrderParams params, String type) {
        if (Objects.isNull(params)) {
            throw new CoolException("参数不能为空!!");
        }
        if (Objects.isNull(params.getType())) {
            throw new CoolException("订单类型不能为空!!");
        }
        OrderParams orderParams = JSONObject.parseObject(JSONObject.toJSONString(params), OrderParams.class);
        // Order order = orderService.selectOne(new
        // EntityWrapper<Order>().eq("order_no", orderParams.getDispatch_no()));
        Order order = null;
        if (OrderType.ORDER_IN.type.equals(OrderWkType.getTypeVal(params.getType()))) {
            // 入库
            order = orderService.selectOne(new EntityWrapper<Order>().eq("order_no",
                    orderParams.getDispatch_no()));
        } else if (OrderType.ORDER_OUT.type.equals(OrderWkType.getTypeVal(params.getType()))) {
            // 出库
            if (OrderWkType.ORDER_WK_ORDER_OUT.val.equals(params.getType())) {
                // 备货单出库
                order = orderService.selectOne(new EntityWrapper<Order>().eq("order_no",
                        orderParams.getPick_no()));
            } else if (OrderWkType.ORDER_WK_ORDER_OUT_EO.val.equals(params.getType())
                    || OrderWkType.ORDER_WK_ORDER_OUT_SO.val.equals(params.getType())) {
                // 备货指示派工单(EO/SO)出库
                order = orderService.selectOne(new EntityWrapper<Order>().eq("order_no",
                        orderParams.getDispatch_no()));
            } else {
                throw new CoolException("单据类型不存在,不支持添加!!");
            }
        } else {
            throw new CoolException("单据类型不存在,不支持添加!!");
        }
        // 出库
        if (type.equals("add") && !Objects.isNull(order)) {
            throw new CoolException("单据已存在, 不可重复添加!!");
        }
        // 判断订单是否存在
        if (Objects.isNull(order)) {
            /** 不存在,新增订单 */
            generateOrders(params);
        } else {
            /** 存在,删除老订单,更新插入新订单 */
            // 删除旧订单明细
            if (!orderDetlService.delete(new EntityWrapper<OrderDetl>().eq("order_id", order.getId()))) {
                throw new CoolException("订单明细删除失败!!");
            }
 
            if (!orderService.deleteById(order.getId())) {
                throw new CoolException("原单据删除失败!!");
            }
            generateOrders(params);
        }
    }
 
    public static String generateUUID(OrderParams params) {
        return java.util.UUID.randomUUID().toString();
    }
 
    /**
     * 生成订单信息
     *
     * @param params
     */
    @Transactional(rollbackFor = Exception.class)
    public void generateOrders(PubOrderParams params) {
        // 将数据当新订单插入
        Order newOrder = new Order();
        // 派工单号
        newOrder.setOrderNo(params.getDispatch_no());
        if (OrderType.ORDER_IN.type.equals(OrderWkType.getTypeVal(params.getType()))) {
            // 入库
            newOrder.setPakinPakoutStatus(1);
            newOrder.setDocType(Long.parseLong(params.getType()));
            newOrder.setNumber(params.getInv_no());
        } else if (OrderType.ORDER_OUT.type.equals(OrderWkType.getTypeVal(params.getType()))) {
            // 出库
            if (OrderWkType.ORDER_WK_ORDER_OUT.val.equals(params.getType())) {
                // 备货单出库
                newOrder.setOrderNo(params.getPick_no());
                newOrder.setNumber(params.getDispatch_no());
                newOrder.setShipCode(params.getOrder_no());
                newOrder.setCstmrName(params.getCus_id());
                newOrder.setTel(params.getCus_address());
                newOrder.setDocType(Long.parseLong(OrderTypeEnum.STOCK.type + ""));
            } else if (OrderWkType.ORDER_WK_ORDER_OUT_EO.val.equals(params.getType())
                    || OrderWkType.ORDER_WK_ORDER_OUT_SO.val.equals(params.getType())) {
                // 备货指示派工单(EO/SO)出库
                newOrder.setDocType(Long.parseLong(OrderTypeEnum.TRANSFER.type + ""));
            }
            newOrder.setPakinPakoutStatus(2);
        }
 
        newOrder.setUuid(generateUUID(params));
        // 流水号(唯一)
        newOrder.setDefNumber(params.getKopen_id());
        newOrder.setTargetLocation(params.getTarget_location());
        // 箱号
        newOrder.setItemName(params.getPm_tktid());
        newOrder.setSettle(OrderSettle.ORDER_SETTLE_HOLDING.type);
        newOrder.setStatus(CommonEnum.COMMON_ENUM_Y.type);
        // 订单时间
        if (Utils.isValidFormat(params.getUpdate_time(), "yyyy-MM-dd HH:mm:ss")) {
            newOrder.setOrderTime(params.getUpdate_time());
        }
        // 公司ID
        newOrder.setCstmrName(params.getCompany_id());
        newOrder.setCreateTime(new Date());
        newOrder.setUpdateTime(new Date());
        if (!orderService.insert(newOrder)) {
            throw new RuntimeException("新增订单失败!!");
        }
        if (!Objects.isNull(params.getDetails()) && !params.getDetails().isEmpty()) {
            params.getDetails().forEach(item -> {
                Mat matnr = matService.selectOne(new EntityWrapper<Mat>().eq("matnr", item.getPro_komcode()));
                if (Objects.isNull(matnr)) {
                    throw new CoolException("物料编码不存在!!");
                }
                OrderDetl orderItem = new OrderDetl();
                BeanUtils.copyProperties(matnr, orderItem);
                orderItem.setOrderId(newOrder.getId());
                orderItem.setOrderNo(newOrder.getOrderNo());
 
                if (OrderType.ORDER_IN.type.equals(OrderWkType.getTypeVal(params.getType()))) {
                    // 入库
                    orderItem.setAnfme(Math.round(item.getInv_qty() * 10000) / 10000.0);
                } else if (OrderType.ORDER_OUT.type.equals(OrderWkType.getTypeVal(params.getType()))) {
                    // 出库
                    if (OrderWkType.ORDER_WK_ORDER_OUT.val.equals(params.getType())) {
                        // 备货单出库
                        orderItem.setAnfme(Math.round(item.getPick_qty() * 10000) / 10000.0);
                    } else if (OrderWkType.ORDER_WK_ORDER_OUT_EO.val.equals(params.getType())
                            || OrderWkType.ORDER_WK_ORDER_OUT_SO.val.equals(params.getType())) {
                        // 备货指示派工单(EO/SO)出库
                        orderItem.setAnfme(Math.round(item.getOrder_qty() * 10000) / 10000.0);
                    }
                }
                orderItem.setMatnr(matnr.getMatnr());
                orderItem.setMaktx(matnr.getMaktx());
                orderItem.setBrand(matnr.getBrand());
                orderItem.setBatch(1 + "");
                orderItem.setStandby1(item.getPro_id());
                // 关联上加派工单号+零件代码+供应商代码
                orderItem.setThreeCode(item.getTotal_serial());
                // 供应商代码
                orderItem.setSuppCode(item.getPro_id());
                orderItem.setCreateTime(new Date());
                orderItem.setUpdateTime(new Date());
                if (!orderDetlService.insert(orderItem)) {
                    throw new CoolException("订单明细新增失败!!");
                }
            });
        }
    }
 
    /**
     * 备货单下发
     *
     * @param stockUpParams
     * @return com.core.common.R
     * @author Ryan
     * @date 2025/11/24 15:40
     */
    @Override
    public XSR getOutDetails(List<StockUpOrderParams> stockUpParams) {
        if (Objects.isNull(stockUpParams)) {
            return XSR.error("参数不能为空!!");
        }
        stockUpParams.forEach(params -> {
            if (Objects.isNull(params.getDispatch_no())) {
                throw new CoolException("派工单编号不能为空!!");
            }
            if (Objects.isNull(params.getKopen_id())) {
                throw new CoolException("流水号不能为空!!");
            }
            if (Objects.isNull(params.getCompany_id())) {
                throw new CoolException("公司ID不能为空!!");
            }
            if (Objects.isNull(params.getDetails()) || params.getDetails().isEmpty()) {
                throw new CoolException("订单明细不能为空!!");
            }
            List<OrderItemsParam> items = new ArrayList<>();
            if (params.getDetails() != null) {
                for (OutOrderParams detail : params.getDetails()) {
                    if (detail.getPartList() != null) {
                        items.addAll(detail.getPartList());
                    }
                }
            }
 
            params.getDetails().forEach(item -> {
                PubOrderParams pubOrderParams = new PubOrderParams();
                BeanUtils.copyProperties(params, pubOrderParams);
                pubOrderParams.setType(item.getType())
                        .setPick_no(item.getPick_no())
                        .setCus_address(item.getCus_address())
                        .setOrder_no(item.getOrder_no())
                        .setUpdate_time(params.getUpdate_time())
                        .setCus_id(item.getCus_id());
                pubOrderParams.setDetails(item.getPartList());
                addOrUpdateOrders(pubOrderParams, "add");
            });
        });
 
        return XSR.ok("备货单下发成功!!");
    }
 
    /**
     * 查询WMS库存信息
     *
     * @param params
     * @return com.core.common.R
     */
    @Override
    public XSR getStockInfo(PageRequestParams params) {
        EntityWrapper<LocDetl> wrapper = new EntityWrapper<>();
        if (!Objects.isNull(params.getPro_id())) {
            wrapper.eq("supp_code", params.getPro_id());
        }
        if (!Objects.isNull(params.getPro_komcode())) {
            wrapper.eq("matnr", params.getPro_komcode());
        }
 
        Page<LocDetl> locDetls = locDetlService.selectPage(new Page<>(params.getCurr(), params.getLimit()),  wrapper);
 
        return XSR.ok(locDetls.getRecords());
    }
 
    /**
     * 零件损溢单下发
     * 
     * @author Ryan
     * @date 2025/11/24 15:22
     * @param params
     * @return com.core.common.R
     */
    @Override
    @Transactional(rollbackFor = Exception.class)
    public XSR sendStockAdjust(List<StockAdjustParams> params, Long userId) {
        if (Objects.isNull(params)) {
            return XSR.error("参数不能为空!!");
        }
        params.forEach(param -> {
            gentCheckOrders(param, userId);
        });
 
        return XSR.ok("零件损溢单下发成功!!");
    }
 
    /** 生成新的零件损溢单 
     * @param userId */
    @Transactional(rollbackFor = Exception.class)   
    public void gentCheckOrders(StockAdjustParams params, Long userId) {
        if (Objects.isNull(params.getDetails()) || params.getDetails().isEmpty()) {
            throw new CoolException("订单明细不能为空!!");
        }
        // 校验参数
        if (Objects.isNull(params.getBsby_no())) {
            throw new CoolException("损溢单编号不能为空!!");
        }
 
        CheckOrder checkOrder = checkOrderService
                .selectOne(new EntityWrapper<CheckOrder>().eq("order_no", params.getBsby_no()));
        if (!Objects.isNull(checkOrder)) {
            throw new CoolException("损溢单已存在!!");
        }
 
        CheckOrder order = new CheckOrder();
        order.setOrderNo(params.getBsby_no());
        order.setCstmrName(params.getCompany_id());
        order.setDefNumber(params.getKopen_id());
        order.setDocType(4L);
        order.setUuid(String.valueOf(snowflakeIdWorker.nextId()));
        order.setSettle(Long.valueOf(CommonEnum.COMMON_ENUM_Y.type + ""));
        order.setStatus(CommonEnum.COMMON_ENUM_Y.type);
        order.setOrderTime(params.getUpdate_time());
        order.setMemo(params.getResason());
        order.setShipName(params.getReason_name());
        order.setCreateTime(new Date());
        order.setUpdateTime(new Date());
 
        if (!checkOrderService.insert(order)) {
            throw new CoolException("损溢单新增失败!!");
        }
 
        if (Objects.isNull(params.getDetails()) || params.getDetails().isEmpty()) {
            throw new CoolException("订单明细不能为空!!");
        }
 
        params.getDetails().forEach(item -> {
            CheckOrderDetl checkOrderDetl = new CheckOrderDetl();
            //通过托盘, 物料编码, 供应商编码查询库存明细
            LocDetl locDetl = locDetlService.selectOne(new EntityWrapper<LocDetl>()
                    .eq("matnr", item.getPro_komcode())
                    .eq("zpallet", item.getLocation_no())
                    .eq("supp_code", item.getPro_id()));
            if (Objects.isNull(locDetl)) {
                throw new CoolException("库存不存在!!");
            }
            BeanUtils.copyProperties(locDetl, checkOrderDetl);
            checkOrderDetl.setLocDetlId(locDetl.getId());
            checkOrderDetl.setOrderId(order.getId());
            checkOrderDetl.setOrderNo(order.getOrderNo());
            checkOrderDetl.setMatnr(locDetl.getMatnr());
            checkOrderDetl.setMaktx(locDetl.getMaktx());
            checkOrderDetl.setBatch(locDetl.getBatch());
            checkOrderDetl.setSpecs(locDetl.getSpecs());
            checkOrderDetl.setThreeCode(locDetl.getThreeCode());
            checkOrderDetl.setSuppCode(locDetl.getSuppCode());
            checkOrderDetl.setStandby1(locDetl.getSuppCode());
            checkOrderDetl.setAnfme(new BigDecimal(locDetl.getAnfme().toString()));
            checkOrderDetl.setDiffQty(BigDecimal.ZERO);
            checkOrderDetl.setWorkQty(BigDecimal.ZERO);
            checkOrderDetl.setStatus(1);
            checkOrderDetl.setZpallet(locDetl.getZpallet());
            checkOrderDetl.setCreateBy(userId);
            checkOrderDetl.setCreateTime(new Date());
            checkOrderDetl.setUpdateBy(userId);
            checkOrderDetl.setUpdateTime(new Date());
 
            if (!checkOrderDetlService.insert(checkOrderDetl)) {
                throw new CoolException("保存盘点单明细失败");
            }
        });
    }
 
}