#
Junjie
2024-04-19 726da3c5a7edcde1fbaba1b04181cfd78510146a
#
1个文件已修改
72 ■■■■■ 已修改文件
zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/rcs/thread/FlowExecute.java 72 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/rcs/thread/FlowExecute.java
@@ -5,11 +5,17 @@
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.zy.asrs.framework.common.Cools;
import com.zy.asrs.framework.exception.CoolException;
import com.zy.asrs.wcs.asrs.entity.param.FlowLogicCodeParam;
import com.zy.asrs.wcs.core.entity.Task;
import com.zy.asrs.wcs.core.service.TaskService;
import com.zy.asrs.wcs.core.utils.RedisUtil;
import com.zy.asrs.wcs.core.utils.ShuttleDispatcher;
import com.zy.asrs.wcs.core.utils.Utils;
import com.zy.asrs.wcs.rcs.cache.SlaveConnection;
import com.zy.asrs.wcs.rcs.entity.Device;
import com.zy.asrs.wcs.rcs.model.enums.SlaveType;
import com.zy.asrs.wcs.rcs.model.protocol.ShuttleProtocol;
import org.apache.commons.codec.digest.DigestUtils;
import org.apache.commons.codec.digest.Md5Crypt;
import org.springframework.beans.factory.annotation.Autowired;
@@ -76,6 +82,8 @@
            result = executeDevpFlow(task, data, redisKey);
        } else if (type.equals("shuttle")) {
            result = executeShuttleFlow(task, data, redisKey);
        } else if (type.equals("lift")) {
            result = executeLiftFlow(task, data, redisKey);
        }
        return result;
    }
@@ -99,19 +107,63 @@
    private boolean executeShuttleFlow(Task task, JSONObject data, String redisKey) {
        JSONObject shuttleType = data.getJSONObject("shuttleType");
        JSONArray shuttleOper = shuttleType.getJSONArray("shuttleOper");
        for (Object object : shuttleOper) {
            String oper = String.valueOf(object);
        String oper = shuttleType.getString("shuttleOper");
            if (oper.equals("searchIdleShuttle")) {
                //搜索空闲车
                ShuttleThread shuttleThread = shuttleDispatcher.searchIdleShuttle(task);
                if (shuttleThread == null) {
                    return false;
                throw new CoolException("穿梭车不存在");
                }
                //存入缓存
                redisSet(redisKey, "shuttleDevice", shuttleThread.getDevice());
                return true;
        } else if (oper.equals("judgeShuttleCurrentTaskLev")) {
            //判断小车是否在任务楼层
            //取出缓存小车
            Object shuttleDeviceObj = redisGet(redisKey, "shuttleDevice");
            if (shuttleDeviceObj == null) {
                throw new CoolException("穿梭车缓存为空");
            }
            Device device = JSON.parseObject(String.valueOf(shuttleDeviceObj), Device.class);
            if (device == null) {
                throw new CoolException("穿梭车设备不存在");
            }
            ShuttleThread shuttleThread = (ShuttleThread) SlaveConnection.get(SlaveType.Shuttle, device.getId().intValue());
            if (shuttleThread == null) {
                throw new CoolException("穿梭车不存在");
            }
            ShuttleProtocol shuttleProtocol = shuttleThread.getStatus();
            if (shuttleProtocol == null) {
                throw new CoolException("穿梭车不存在");
            }
            //小车坐标
            String shuttleLocNo = shuttleProtocol.getCurrentLocNo();
            String taskLocNo = null;
            if (task.getTaskSts() < 100) {
                taskLocNo = task.getDestLoc();
            } else if (task.getTaskSts() > 100 && task.getTaskSts() < 200) {
                taskLocNo = task.getOriginLoc();
            }
            // 小车和任务楼层一致
            if (Utils.getLev(shuttleLocNo) == Utils.getLev(taskLocNo)) {
                return true;
            }else {
                return false;
            }
        }
        return true;
    }
    private boolean executeLiftFlow(Task task, JSONObject data, String redisKey) {
        JSONObject liftType = data.getJSONObject("liftType");
        String oper = liftType.getString("liftOper");
        if (oper.equals("move")) {
            //提升机升降
        }
        return true;
@@ -131,6 +183,18 @@
        return true;
    }
    private Object redisGet(String redisKey, String key) {
        if (redisUtil.hasKey(redisKey)) {
            Object obj = redisUtil.get(redisKey);
            JSONObject object = JSON.parseObject(String.valueOf(obj));
            if (!object.containsKey(key)) {
                return null;
            }
            return object.get(key);
        }
        return null;
    }
//    private boolean executeFlow(List<Map<String, Object>> list) {
//        for (Map<String, Object> map : list) {
//            JSONObject data = (JSONObject) map.get("data");