自动化立体仓库 - WMS系统
#
1
1 天以前 eeda896972c8408a797bab5980d732e4c8982e0a
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
package com.zy.asrs.task;
 
import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.zy.asrs.entity.*;
import com.zy.asrs.entity.param.OrderToLine;
import com.zy.asrs.service.*;
import com.zy.asrs.service.impl.OrderDetlServiceImpl;
import com.zy.asrs.task.core.ReturnT;
import com.zy.asrs.task.handler.OrderToLineHandler;
import com.zy.asrs.utils.GroupedLockerOptimizerUtils;
import com.zy.asrs.utils.OptimizedLockerPackingUtils;
import com.zy.asrs.utils.OrderInAndOutUtil;
import com.zy.asrs.utils.ToSortLineUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
 
import java.util.ArrayList;
import java.util.List;
 
@Slf4j
@Component
//订单下发至分拣线
public class OrderToSortLineScheduler {
    @Autowired
    private OrderPakinService orderPakinService;
    @Autowired
    private OrderDetlPakinService orderDetlPakinService;
    @Autowired
    private BasArmRulesService basArmRulesService;
    @Autowired
    private OrderToLineHandler orderToLineHandler;
    @Autowired
    private BasArmMastSignService basArmMastSignService;
 
    @Scheduled(cron = "0/3 * * * * ? ")
    private void orderToSortLine() {
        //获取未下发单据
        List<String> orderNos = orderPakinService.AllStatusSatisfyOrder(0);
        if(orderNos == null || orderNos.isEmpty()) {
//            log.info("未有新订单");
            return;
        }
 
        //遍历单据
        for (String orderNo : orderNos) {
            try{
                List<OrderDetlPakin> orderDetlPakinList = orderDetlPakinService.selectList(new EntityWrapper<OrderDetlPakin>().eq("order_no",orderNo));
//                List<GroupedLockerOptimizerUtils.Item> items = new ArrayList<>();
                if (orderDetlPakinList.size()<1){
                    continue;
                }
 
                List<OptimizedLockerPackingUtils.Item> items = new ArrayList<>();
                for (OrderDetlPakin orderDetl:orderDetlPakinList){
                    Integer number =  basArmRulesService.getNumber(orderDetl.getWeight(),orderDetl.getVolume(),orderDetl.getManLength(),orderDetl.getWidth(),orderDetl.getHeight());
                    if (number == null) {
                        BasArmRules basArmRules = new BasArmRules();
                        basArmRules.setMaterialHeight(orderDetl.getHeight());
                        basArmRules.setMaterialWeight(orderDetl.getWeight());
                        basArmRules.setMaterialLength(orderDetl.getManLength());
                        basArmRules.setMaterialWidth(orderDetl.getWidth());
                        basArmRulesService.insert(basArmRules);
                        return;
                    } else if (number == 0){
                        return;
                    }
                    String name = ToSortLineUtils.MergerParameter(orderDetl.getMatnr(),orderDetl.getStandby1(),orderDetl.getStandby2());
                    int maxCapacity = number;
                    int stock = orderDetl.getAnfme().intValue();
//                    items.add(new GroupedLockerOptimizerUtils.Item(name, maxCapacity, stock));
                    items.add(new OptimizedLockerPackingUtils.Item(name, maxCapacity, stock));
                }
 
                OrderToLine orderToLine = new OrderToLine();
                orderToLine.setOrderNo(orderNo);  //单据编号
                orderToLine.setCreateTime(System.currentTimeMillis());  //创建时间
//                OrderToLine orderToLineR = ToSortLineUtils.GetOrderToLineGro(items, orderToLine);
                OrderToLine orderToLineR = ToSortLineUtils.GetOrderToLineOpt(items, orderToLine);
 
                try{
                    ReturnT<String> returnT = orderToLineHandler.start(orderToLineR);
                    if (!returnT.isSuccess()) {
                        log.error("下发单据失败===>"+ JSON.toJSON(orderToLineR));
                    } else {
                        try{
                            for (OrderToLine.MatList matList:orderToLineR.getMatList()){
                                BasArmMastSign basArmMastSign = new BasArmMastSign();
                                basArmMastSign.setMatnr(matList.getSku());
                                basArmMastSign.setOrderNo(orderNo);
                                basArmMastSign.setSku(matList.getSku());
                                basArmMastSign.setPo(matList.getPo());
                                basArmMastSign.setUpc(matList.getUpc());
                                basArmMastSign.setSupplier(matList.getSupplier());
                                basArmMastSign.setStatus(0);
                                basArmMastSign.setAnfme(matList.getCtns());
                                basArmMastSign.setCreateTime(matList.getBindingTags());
                                basArmMastSignService.insert(basArmMastSign);
                            }
                        }catch (Exception e){}
                    }
                } catch (Exception e){
                    log.error("下发单据异常===>"+e.getMessage());
                }
            } catch (Exception e){
                log.error("下发单据异常,跳转下一个订单===>"+e.getMessage());
            }
        }
    }
 
}