skyouc
2025-01-04 3c52f39678034ce21c1158a01b4885e3afde4443
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
package com.zy.asrs.wms.asrs.service.impl;
 
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.zy.asrs.framework.exception.CoolException;
import com.zy.asrs.wms.asrs.entity.Order;
import com.zy.asrs.wms.asrs.entity.WaitPakin;
import com.zy.asrs.wms.asrs.entity.enums.LocTypeHeightType;
import com.zy.asrs.wms.asrs.entity.enums.OrderType;
import com.zy.asrs.wms.asrs.entity.enums.TaskStsType;
import com.zy.asrs.wms.asrs.entity.param.BatchMergeOrdersParam;
import com.zy.asrs.wms.asrs.entity.param.GeneratePakInParam;
import com.zy.asrs.wms.asrs.service.MobileService;
import com.zy.asrs.wms.asrs.service.OrderService;
import com.zy.asrs.wms.asrs.service.WaitPakinService;
import com.zy.asrs.wms.asrs.service.WorkService;
import com.zy.asrs.wms.system.entity.Host;
import com.zy.asrs.wms.system.service.HostService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
 
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
 
@Service
public class MobileServiceImpl implements MobileService {
 
    @Autowired
    private WaitPakinService waitPakinService;
    @Autowired
    private WorkService workService;
    @Autowired
    private HostService hostService;
 
    @Autowired
    private OrderService orderService;
 
 
    @Override
    @Transactional(rollbackFor = Exception.class)
    public boolean batchMergeOrders(BatchMergeOrdersParam ordersParam) {
        Order order = orderService.getOne(new LambdaQueryWrapper<Order>().eq(Order::getOrderNo, ordersParam.getOrderNo()));
        if (Objects.isNull(order)) {
            throw new CoolException("订单不存在!!");
        }
 
        ArrayList<WaitPakin> waitPakins = new ArrayList<>();
        ordersParam.getOrderDetls().forEach(orderdetl -> {
            WaitPakin waitPakin = new WaitPakin();
            waitPakin.setBatch(orderdetl.getBatch())
                    .setAnfme(orderdetl.getMergeNum())
                    .setBarcode(ordersParam.getMergeNo())
                    .setMatnr(orderdetl.getMatnr())
                    .setDetlId(orderdetl.getDetlId())
                    .setIoStatus(0)
                    .setOrderNo(orderdetl.getOrderNo()).setOrderId(orderdetl.getOrderId()).setStatus(1);
            waitPakins.add(waitPakin);
        });
 
        //组拖通知档
        waitPakins.forEach(pakin -> {
            waitPakinService.comb(pakin);
        });
 
        // UTC入库单据(非平库入库单据)
        if (order.getOrderType() != OrderType.PK_IN_ORDER.id) {
            /*** 项目下发流程 * 1. PDA组拖通知档* 2. 生成任务档* 3. 通过定时任务下发至ESS** */
            //生成任务档
            GeneratePakInParam generatePakInParam = new GeneratePakInParam();
            //当前没有起始站点,默认101, 高低位默认传低库位
            generatePakInParam.setBarcode(ordersParam.getMergeNo())
                    .setOriginSite("101")
                    .setTaskType(TaskStsType.GENERATE_IN.id).setLocTypeHeight(LocTypeHeightType.LOW.id);
            if (workService.generatePakIn(generatePakInParam)) {
                return true;
            }
        } else {
            //fixme 平库是否需要预约入库
        }
        return false;
    }
 
    @Override
    public List<Host> getHosts() {
        return hostService.list();
    }
}