自动化立体仓库 - WCS系统
zc
3 天以前 292ad975aaa9f3a4a74ac2a3f89b5cf3bf9a1bbb
src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java
@@ -1,6 +1,7 @@
package com.zy.asrs.service.impl;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.core.common.Cools;
@@ -25,10 +26,7 @@
import com.zy.core.model.LiftSlave;
import com.zy.core.model.ShuttleSlave;
import com.zy.core.model.Task;
import com.zy.core.model.command.LiftAssignCommand;
import com.zy.core.model.command.LiftCommand;
import com.zy.core.model.command.ShuttleAssignCommand;
import com.zy.core.model.command.ShuttleCommand;
import com.zy.core.model.command.*;
import com.zy.core.model.protocol.ForkLiftStaProtocol;
import com.zy.core.model.protocol.LiftProtocol;
import com.zy.core.model.protocol.ShuttleProtocol;
@@ -45,6 +43,7 @@
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import java.io.IOException;
import java.util.*;
/**
@@ -232,6 +231,8 @@
                            wrkMast.setWrkSts(WrkStsType.INBOUND_DEVICE_RUN.sts);
                            wrkMast.setModiTime(new Date());
                            wrkMastService.updateById(wrkMast);
                            setLedData(wrkMast.getWrkNo(), wrkMast.getStaNo());
                        } else if (wrkMast != null && wrkMast.getWrkSts() != WrkStsType.NEW_INBOUND.sts) {
                            continue;
                        }
@@ -328,6 +329,7 @@
                                JSONObject jsonObject = JSON.parseObject(response);
                                Integer code = jsonObject.getInteger("code");
                                if (code.equals(200)) {
                                    setLedData(wrkMast.getWrkNo(), wrkMast.getStaNo());
                                } else {
                                    String msg = jsonObject.getString("msg");
@@ -514,12 +516,39 @@
                        wrkMast.setModiTime(new Date());
                        wrkMast.setShuttleNo(null);
                        wrkMastService.updateById(wrkMast);
                        setLedData(wrkMast.getWrkNo(), wrkMast.getStaNo());
                    }
                }
            }
        }
    }
    private void setLedData(Integer wrkNo, Integer staNo) {
        try {
            List<LedCommand> commands = new ArrayList<>();
            Map<String, Object> param = new HashMap<>();
            param.put("taskNo", wrkNo);
            String response = null;
            response = new HttpHandler.Builder()
                    .setUri(wmsUrl)
                    .setPath("/rpc/led/getTask2")
                    .setJson(JSON.toJSONString(param))
                    .build()
                    .doPost();
            JSONObject jsonObject = JSON.parseObject(response);
            Integer code = jsonObject.getInteger("code");
            if (code.equals(200)) {
                String data = jsonObject.getString("data");
                List<LedCommand> wrkDetls = JSONArray.parseArray(data, LedCommand.class);
                commands.addAll(wrkDetls);
                redisUtil.set("LED_" + staNo, commands, 10);
                log.info("电视机数据设置:{}", data);
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
    /**
     * 初始化实时地图
@@ -957,7 +986,7 @@
            staProtocol = staProtocol.clone();
            staProtocol.setStaNo(staNo);
            staProtocol.setWorkNo(wrkMast.getMainWrkNo().shortValue());
            staProtocol.setWorkNo(wrkMast.getWrkNo().shortValue());
            boolean result = MessageQueue.offer(SlaveType.Devp, 1, new Task(2, staProtocol));
            wrkMast.setWrkSts(WrkStsType.INBOUND_DEVICE_RUN.sts);
@@ -1043,7 +1072,7 @@
                    return false;
                }
            } else if (sourceStaNo == 1012) {
                if (staProtocol.getWorkNo().intValue() != wrkMast.getWrkNo()) {
                if (staProtocol.getFinishWorkNo().intValue() != wrkMast.getWrkNo()) {
                    News.info("{}任务,{}站点,任务号不一致", wrkMast.getWrkNo(), staProtocol.getSiteId());
                    return false;
                }
@@ -1060,7 +1089,7 @@
            } else if (wrkMast.getSourceStaNo() == 1032) {
                locNo = "0200308";
            }
            boolean dispatchShuttle = shuttleDispatchUtils.searchDispatchShuttleS(wrkMast.getWrkNo(), locNo, wrkMast.getLocNo(), "TRANSPORT_LIFT");
            boolean dispatchShuttle = shuttleDispatchUtils.searchDispatchShuttleNoLift(wrkMast.getWrkNo(), locNo, wrkMast.getLocNo(), "TRANSPORT_LIFT");
            if (!dispatchShuttle) {
                News.info("{}任务,调度小车失败", wrkMast.getWrkNo());
                return false;
@@ -1287,10 +1316,10 @@
            Integer sourceLev = liftThread.getLevToStaNo(Utils.getLev(wrkMast.getSourceLocNo()));
            //获取提升机命令
            List<LiftCommand> liftCommands = liftThread.getPalletOutCommand(wrkMast.getMainWrkNo(), sourceLev, wrkMast.getStaNo());
            List<LiftCommand> liftCommands = liftThread.getPalletOutCommand(wrkMast.getWrkNo(), sourceLev, wrkMast.getStaNo());
            LiftCommand liftCommand = liftCommands.get(0);
//            if (wrkMast.getMainWrkNo() != null) {
            liftCommand.setTaskNo(wrkMast.getMainWrkNo());
            liftCommand.setTaskNo(wrkMast.getWrkNo());
//            } else {
//                int deviceWrk = commonService.getWorkNo(8);//生成提升机设备工作号
//                liftCommand.setTaskNo(deviceWrk);//更换随机任务号
@@ -1303,7 +1332,7 @@
            LiftAssignCommand assignCommand = new LiftAssignCommand();
            assignCommand.setCommands(commands);
            assignCommand.setLiftNo(liftProtocol.getLiftNo().shortValue());
            assignCommand.setTaskNo(wrkMast.getMainWrkNo().shortValue());
            assignCommand.setTaskNo(wrkMast.getWrkNo().shortValue());
            assignCommand.setTaskMode(LiftCommandModeType.PALLET_OUT.id.shortValue());
            wrkMast.setWrkSts(WrkStsType.OUTBOUND_LIFT_RUN.sts);
@@ -1312,6 +1341,7 @@
            wrkMast.setModiTime(now);
            if (wrkMastService.updateById(wrkMast)) {
                setLedData(wrkMast.getWrkNo(), wrkMast.getStaNo());
                //下发任务
                liftAction.assignWork(wrkMast.getLiftNo(), assignCommand);
                return false;