自动化立体仓库 - WMS系统
#
lsh
2024-12-11 ba89eb7e18be949742a20bc50bd0cc80b9ccc857
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
package com.zy.asrs.utils;
 
import com.core.exception.CoolException;
import com.zy.asrs.entity.Order;
import com.zy.asrs.entity.OrderDetl;
import com.zy.common.model.enumUtils.OrderEnumVo;
import com.zy.common.model.enumUtils.OrderInAndOutType;
import com.zy.common.model.enumUtils.OrderMethodVo;
import org.apache.poi.ss.formula.functions.T;
 
import java.lang.reflect.Method;
 
public class OrderInAndOutUtil {
 
    public static String enumUtil(boolean sign) {
       if (sign){
           return OrderEnumVo.PAKIN.getCode();
       }
       return OrderEnumVo.PAKOUT.getCode();
    }
 
    public static Method implement(boolean sign,OrderMethodVo orderMethodVo){
        Class<OrderInAndOutType> casual = OrderInAndOutType.class;
        try{
            switch (orderMethodVo){
                case QUERY:
                    return casual.getDeclaredMethod(OrderMethodVo.QUERY.getCode(), String.class);
                case INSERT_ORDER:
                    return casual.getDeclaredMethod(OrderMethodVo.INSERT_ORDER.getCode(), Order.class);
                case INSERT_ORDERDETL:
                    return casual.getDeclaredMethod(OrderMethodVo.INSERT_ORDERDETL.getCode(), Order.class, OrderDetl.class);
                case IMPLEMENT:
                    return casual.getDeclaredMethod(OrderMethodVo.IMPLEMENT.getCode(), Object.class,Object.class);
            }
        } catch (Exception e) {
            throw new CoolException(e.getMessage());
        }
        throw new CoolException("未知异常");
    }
 
    public static void query(boolean sign,OrderMethodVo orderMethodVo,String orderNo){
        OrderInAndOutType orderInAndOutType = OrderInAndOutType.valueOf(enumUtil(sign));
        try{
            implement(sign, orderMethodVo).invoke(orderInAndOutType,orderNo);
        } catch (Exception e) {
            throw new CoolException(e.getMessage());
        }
    }
 
    public static void insert(boolean sign,OrderMethodVo orderMethodVo,Order order){
        OrderInAndOutType orderInAndOutType = OrderInAndOutType.valueOf(enumUtil(sign));
        try{
            implement(sign, orderMethodVo).invoke(orderInAndOutType,order);
        } catch (Exception e) {
            throw new CoolException(e.getMessage());
        }
    }
 
    public static void insert(boolean sign,OrderMethodVo orderMethodVo,Order order,OrderDetl orderDetl){
        OrderInAndOutType orderInAndOutType = OrderInAndOutType.valueOf(enumUtil(sign));
        try{
            implement(sign, orderMethodVo).invoke(orderInAndOutType,order,orderDetl);
        } catch (Exception e) {
            throw new CoolException(e.getMessage());
        }
    }
 
 
}