package com.prolog.eis.enums.wms;

import com.prolog.framework.utils.MapUtils;
import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.function.Function;
import java.util.stream.Collectors;

/**
 * @desc: wms入库区域编码
 * @author: zhangJie
 * @date: 2023/9/4 9:26
 */
@AllArgsConstructor
@Getter
public enum WmsCarryTaskInCode {

    MJZ("MJZ", "四向库"),
    AGVZ("AGVZ", "AGV整件药品托盘库"),
    AGVSP("AGVSP", "AGV整件食品托盘库"),
    AGVQX("AGVQX", "AGV整件器械托盘库"),
    AGVZY("AGVZY", "AGV整件中药饮片库"),
    AGVL("AGVL", "拆零库"),
    ZJK01("ZJK01", "一楼四向库北面平库整件地堆"),
    ZYYP("ZYYP", "中药饮片库区站台"),
    WL("WL", "物料库区站台"),
    NG01("NG01", "不合格库区"),
    ZYYPRKJBW("ZYYPRKJBW", "中药饮片库区支架"),
    WLRKJBW("WLRKJBW", "物料库区支架"),
    ;

    private String code;
    private String desc;

    private static Map<String, WmsCarryTaskInCode> cache;

    static {
        cache = Arrays.stream(WmsCarryTaskInCode.values()).collect(Collectors.toMap(WmsCarryTaskInCode::getCode, Function.identity()));
    }

    public static WmsCarryTaskInCode of(String code) {
        return cache.get(code);
    }

    //借道入库可入的区域
    public static List<Map<String,Object>> getJdList() {
        List<Map<String,Object>> result = new ArrayList<>();
        result.add(MapUtils.put("code", ZJK01.code).put("desc", ZJK01.desc).getMap());
//        result.add(MapUtils.put("code", ZYYP.code).put("desc", ZYYP.desc).getMap());
        result.add(MapUtils.put("code", ZYYPRKJBW.code).put("desc", ZYYPRKJBW.desc).getMap());
//        result.add(MapUtils.put("code", WL.code).put("desc", WL.desc).getMap());
        result.add(MapUtils.put("code", WLRKJBW.code).put("desc", WLRKJBW.desc).getMap());
        result.add(MapUtils.put("code", NG01.code).put("desc", NG01.desc).getMap());
        return result;
    }

    //正常任务下发可入的区域
    public static List<Map<String,Object>> getRkList() {
        List<Map<String,Object>> result = new ArrayList<>();
        result.add(MapUtils.put("code", MJZ.code).put("desc", MJZ.desc).getMap());
        result.add(MapUtils.put("code", AGVZ.code).put("desc", AGVZ.desc).getMap());
        result.add(MapUtils.put("code", AGVSP.code).put("desc", AGVSP.desc).getMap());
        result.add(MapUtils.put("code", AGVQX.code).put("desc", AGVQX.desc).getMap());
        result.add(MapUtils.put("code", AGVZY.code).put("desc", AGVZY.desc).getMap());
        result.add(MapUtils.put("code", AGVL.code).put("desc", AGVL.desc).getMap());
        return result;
    }

    public static Map<String, Object> AREA_TYPE = MapUtils.put(MJZ.code, 1)
            .put(AGVZ.code, 2)
            .put(AGVSP.code, 3)
            .put(AGVQX.code, 4)
            .put(AGVL.code, 5)
            .put(AGVZY.code, 6)
            .getMap();

}
