| package com.zy.asrs.service.impl; | 
|   | 
| import com.alibaba.fastjson.JSON; | 
| import com.alibaba.fastjson.JSONObject; | 
| import com.baomidou.mybatisplus.mapper.EntityWrapper; | 
| import com.baomidou.mybatisplus.mapper.Wrapper; | 
| import com.core.common.Cools; | 
| import com.core.common.SpringUtils; | 
| import com.core.exception.CoolException; | 
| import com.zy.asrs.entity.*; | 
| import com.zy.asrs.mapper.*; | 
| import com.zy.asrs.service.*; | 
| import com.zy.asrs.utils.Utils; | 
| import com.zy.common.model.*; | 
| import com.zy.common.model.enums.NavigationMapType; | 
| import com.zy.common.service.CommonService; | 
| import com.zy.common.service.erp.ErpService; | 
| import com.zy.common.utils.*; | 
| import com.zy.core.DevpThread; | 
| import com.zy.core.News; | 
| import com.zy.core.cache.MessageQueue; | 
| import com.zy.core.cache.SlaveConnection; | 
| import com.zy.core.enums.*; | 
| import com.zy.core.model.*; | 
| import com.zy.core.model.command.*; | 
| import com.zy.core.model.protocol.*; | 
| import com.zy.core.properties.SlaveProperties; | 
| import com.zy.core.thread.*; | 
| import com.zy.system.entity.Config; | 
| import com.zy.system.service.ConfigService; | 
| import lombok.extern.slf4j.Slf4j; | 
| import org.springframework.beans.factory.annotation.Autowired; | 
| import org.springframework.beans.factory.annotation.Value; | 
| import org.springframework.stereotype.Service; | 
| import org.springframework.transaction.annotation.Transactional; | 
| import org.springframework.transaction.interceptor.TransactionAspectSupport; | 
|   | 
| import java.util.*; | 
| import java.util.stream.Collectors; | 
|   | 
| /** | 
|  * 立体仓库WCS系统主流程业务 | 
|  * Created by vincent on 2020/8/6 | 
|  */ | 
| @Slf4j | 
| @Service("mainService") | 
| public class MainServiceImpl { | 
|   | 
|     @Value("${wms.url}") | 
|     private String wmsUrl; | 
|     @Autowired | 
|     private SlaveProperties slaveProperties; | 
|     @Autowired | 
|     private WrkMastMapper wrkMastMapper; | 
|     @Autowired | 
|     private WrkMastService wrkMastService; | 
|     @Autowired | 
|     private WrkDetlService wrkDetlService; | 
|     @Autowired | 
|     private LocMastService locMastService; | 
|     @Autowired | 
|     private LocDetlService locDetlService; | 
|     @Autowired | 
|     private StaDescService staDescService; | 
|     @Autowired | 
|     private BasDevpService basDevpService; | 
|     @Autowired | 
|     private BasErrLogService basErrLogService; | 
|     @Autowired | 
|     private BasSteErrLogService basSteErrLogService; | 
|     @Autowired | 
|     private BasShuttleService basShuttleService; | 
|     @Autowired | 
|     private BasShuttleErrLogService basShuttleErrLogService; | 
|     @Autowired | 
|     private BasLiftErrLogService basLiftErrLogService; | 
|     @Autowired | 
|     private BasShuttleErrService basShuttleErrService; | 
|     @Autowired | 
|     private BasCrnErrorMapper basCrnErrorMapper; | 
|     @Autowired | 
|     private BasSteService basSteService; | 
|     @Autowired | 
|     private WrkChargeService wrkChargeService; | 
|     @Autowired | 
|     private BasSteErrService basSteErrService; | 
|     @Autowired | 
|     private CommonService commonService; | 
|     @Autowired | 
|     private WrkChargeMapper wrkChargeMapper; | 
|     @Autowired | 
|     private BasMapService basMapService; | 
|     @Autowired | 
|     private ErpService erpService; | 
|     @Autowired | 
|     private OrderMapper orderMapper; | 
|     @Autowired | 
|     private OrderDetlMapper orderDetlMapper; | 
|     @Autowired | 
|     private BasLiftService basLiftService; | 
|     @Autowired | 
|     private ShuttleDispatchUtils shuttleDispatchUtils; | 
|     @Autowired | 
|     private RedisUtil redisUtil; | 
|     @Autowired | 
|     private WrkMastLogMapper wrkMastLogMapper; | 
|     @Autowired | 
|     private BasLiftOptService basLiftOptService; | 
|     @Autowired | 
|     private ConfigService configService; | 
|     @Autowired | 
|     private NavigateMapUtils navigateMapUtils; | 
|     @Autowired | 
|     private WrkDetlLogService wrkDetlLogService; | 
|     @Autowired | 
|     private MatService matService; | 
|     @Autowired | 
|     private NavigateMapData navigateMapData; | 
|   | 
|   | 
|     /** | 
|      * 组托 | 
|      * 入库站,根据条码扫描生成入库工作档,工作状态 2 | 
|      */ | 
|     public void generateStoreWrkFile() { | 
|         try { | 
|             // 根据输送线plc遍历 | 
|             for (DevpSlave devp : slaveProperties.getDevp()) { | 
|                 // 遍历入库口 | 
|                 for (DevpSlave.Sta inSta : devp.getInSta()) { | 
|                     // 获取入库站信息 | 
|                     DevpThread devpThread = (DevpThread) SlaveConnection.get(SlaveType.Devp, devp.getId()); | 
|                     StaProtocol staProtocol = devpThread.getStation().get(inSta.getStaNo()); | 
|                     if (staProtocol == null) { | 
|                         continue; | 
|                     } else { | 
|                         staProtocol = staProtocol.clone(); | 
|                     } | 
|                     Short workNo = staProtocol.getWorkNo(); | 
|                     // 尺寸检测异常 | 
|                     boolean back = false; | 
|                     String errMsg = "异常:"; | 
|                     if (staProtocol.isFrontErr()) { | 
|                         errMsg = errMsg + "前超限;"; | 
|                         back = true; | 
|                     } | 
|                     if (staProtocol.isBackErr()) { | 
|                         errMsg = errMsg + "后超限"; | 
|                         back = true; | 
|                     } | 
|                     if (staProtocol.isHighErr()) { | 
|                         errMsg = errMsg + "高超限"; | 
|                         back = true; | 
|                     } | 
|                     if (staProtocol.isLeftErr()) { | 
|                         errMsg = errMsg + "左超限"; | 
|                         back = true; | 
|                     } | 
|                     if (staProtocol.isRightErr()) { | 
|                         errMsg = errMsg + "右超限"; | 
|                         back = true; | 
|                     } | 
|                     if (staProtocol.isWeightErr()) { | 
|                         errMsg = errMsg + "超重"; | 
|                         back = true; | 
|                     } | 
|                     if (staProtocol.isBarcodeErr()) { | 
|                         errMsg = errMsg + "扫码失败"; | 
|                         back = true; | 
|                     } | 
|                     // 退回 | 
|                     if (back) { | 
|                         // led 异常显示 | 
|                         LedThread ledThread = (LedThread) SlaveConnection.get(SlaveType.Led, inSta.getLed()); | 
|                         if (ledThread != null) { | 
|                             MessageQueue.offer(SlaveType.Led, inSta.getLed(), new Task(3, errMsg)); | 
|                         } | 
|                         continue; | 
|                     } | 
|   | 
|                     // 判断是否满足入库条件 | 
|                     if (staProtocol.isAutoing() && staProtocol.isLoading() | 
|                             && staProtocol.isInEnable() | 
|                             && !staProtocol.isEmptyMk() && (workNo == 0 || (workNo >= 9990 && workNo <= 9999)) | 
|                     ) { | 
|   | 
|                         // 获取条码扫描仪信息 | 
|                         BarcodeThread barcodeThread = (BarcodeThread) SlaveConnection.get(SlaveType.Barcode, inSta.getBarcode()); | 
|                         if (barcodeThread == null) { | 
|                             continue; | 
|                         } | 
|                         String barcode = barcodeThread.getBarcode(); | 
|                         if (!Cools.isEmpty(barcode)) { | 
| //                        News.info("{}号条码扫描器检测条码信息:{}", inSta.getBarcode(), barcode); | 
|                             if ("NG".endsWith(barcode) || "NoRead".equals(barcode) || "empty".equals(barcode) || "00000000".equals(barcode)) { | 
| //                            staProtocol.setWorkNo((short) 32002); | 
| //                            staProtocol.setStaNo(inSta.getBackSta().shortValue()); | 
| //                            devpThread.setPakMk(staProtocol.getSiteId(), false); | 
| //                            MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol)); | 
|   | 
|                                 // led 异常显示 | 
|                                 LedThread ledThread = (LedThread) SlaveConnection.get(SlaveType.Led, inSta.getLed()); | 
|                                 if (ledThread != null) { | 
|                                     String errorMsg = "扫码失败,请重试"; | 
|                                     MessageQueue.offer(SlaveType.Led, inSta.getLed(), new Task(3, errorMsg)); | 
|                                 } | 
|                                 continue; | 
|                             } | 
|                         } else { | 
| //                        staProtocol.setWorkNo((short) 32002); | 
| //                        staProtocol.setStaNo(inSta.getBackSta().shortValue()); | 
| //                        devpThread.setPakMk(staProtocol.getSiteId(), false); | 
| //                        MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol)); | 
|   | 
| //                        // led 异常显示 | 
| //                        LedThread ledThread = (LedThread) SlaveConnection.get(SlaveType.Led, inSta.getLed()); | 
| //                        if (ledThread != null) { | 
| //                            String errorMsg = "扫码失败,请重试"; | 
| //                            MessageQueue.offer(SlaveType.Led, inSta.getLed(), new Task(3, errorMsg)); | 
| //                        } | 
|                             continue; | 
|                         } | 
|   | 
|                         // 过滤盘点/拣料/并板任务 | 
|                         WrkMast wrkMast1 = wrkMastMapper.selectPickStepByBarcode(barcode); | 
|                         if (null != wrkMast1) { | 
|                             continue; | 
|                         } | 
|   | 
|                         // 判断重复工作档 | 
|                         WrkMast wrkMast2 = wrkMastMapper.selectPakInStep1(inSta.getStaNo(), barcode); | 
|                         if (wrkMast2 != null) { | 
|                             News.error("工作档中已存在该站状态为( 2.设备上走 )的数据,工作号={}", wrkMast2.getWrkNo()); | 
|                             continue; | 
|                         } | 
|   | 
|                         try { | 
|                             LocTypeDto locTypeDto = new LocTypeDto(staProtocol); | 
|                             SearchLocParam param = new SearchLocParam(); | 
|                             param.setBarcode(barcode); | 
|                             param.setIoType(1); | 
|                             param.setSourceStaNo(inSta.getStaNo()); | 
|                             param.setLocType1(locTypeDto.getLocType1()); | 
|                             String response = new HttpHandler.Builder() | 
|                                     .setUri(wmsUrl) | 
|                                     .setPath("/rpc/pakin/loc/v2") | 
|                                     .setJson(JSON.toJSONString(param)) | 
|                                     .build() | 
|                                     .doPost(); | 
|                             JSONObject jsonObject = JSON.parseObject(response); | 
|                             LedThread ledThread = (LedThread) SlaveConnection.get(SlaveType.Led, inSta.getLed()); | 
|                             Integer code = jsonObject.getInteger("code"); | 
|                             if (code.equals(200)) { | 
|                                 StartupDto dto = jsonObject.getObject("data", StartupDto.class); | 
|                                 // plc 处理 | 
|                                 barcodeThread.setBarcode(""); | 
| //                            staProtocol.setWorkNo(dto.getWorkNo().shortValue()); | 
| //                            staProtocol.setStaNo(dto.getStaNo().shortValue()); | 
| //                            devpThread.setPakMk(staProtocol.getSiteId(), false); | 
| // | 
| //                            boolean result = MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol)); | 
| //                            if (!result) { | 
| //                                throw new CoolException("更新plc站点信息失败"); | 
| //                            } | 
|   | 
|                                 // 判断重复工作档 | 
|                                 WrkMast wrkMast = wrkMastMapper.selectPakInStep11(inSta.getStaNo()); | 
|                                 if (wrkMast == null) { | 
|                                     continue; | 
|                                 } | 
|   | 
|                                 // 更新工作主档 | 
|                                 wrkMast.setWrkSts(2L); // 工作状态:2.设备上走 | 
|                                 wrkMast.setModiTime(new Date()); | 
|                                 if (wrkMastMapper.updateById(wrkMast) == 0) { | 
|                                     News.error("更新工作档失败!!! [工作号:{}]", wrkMast.getWrkNo()); | 
|                                 } | 
|   | 
|                             } else if (code == 500) { | 
|                                 if (ledThread != null) { | 
|                                     String errorMsg = jsonObject.getString("msg"); | 
|                                     if (!Cools.isEmpty(errorMsg)) { | 
|                                         MessageQueue.offer(SlaveType.Led, inSta.getLed(), new Task(3, errorMsg)); | 
|                                         ledThread.setLedMk(false); | 
|                                     } | 
|                                 } | 
|                                 News.error("请求接口失败!!!url:{};request:{};response:{}", wmsUrl + "/rpc/pakin/loc/v2", JSON.toJSONString(param), response); | 
|                             } else if (code == 700) { | 
| //                            staProtocol.setWorkNo((short) 32002); | 
| //                            staProtocol.setRollback102(1);//102站回退信号 | 
| //                            devpThread.setPakMk(staProtocol.getSiteId(), false); | 
| //                            MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(5, staProtocol)); | 
|   | 
|                                 // led 异常显示 | 
|                                 if (ledThread != null) { | 
|                                     String errorMsg = barcode + "托盘识别异常,请先进行组托!"; | 
|                                     MessageQueue.offer(SlaveType.Led, inSta.getLed(), new Task(3, errorMsg)); | 
|                                     ledThread.setLedMk(false); | 
|                                 } | 
|                             } | 
|                         } catch (Exception e) { | 
|                             e.printStackTrace(); | 
|                             TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); | 
|                         } | 
|                     } | 
|                 } | 
|             } | 
|         } catch (Exception e) { | 
|             e.printStackTrace(); | 
|         } | 
|     } | 
|   | 
|     /** | 
|      * wms入库 | 
|      * 入库站,根据条码扫描生成入库工作档,工作状态 1 ==>> 2 | 
|      */ | 
|     @Deprecated | 
|     public void generateStoreWrkFile0() { | 
|         // 根据输送线plc遍历 | 
|         for (DevpSlave devp : slaveProperties.getDevp()) { | 
|             // 遍历入库口 | 
|             for (DevpSlave.Sta inSta : devp.getInSta()) { | 
|                 // 获取入库站信息 | 
|                 DevpThread devpThread = (DevpThread) SlaveConnection.get(SlaveType.Devp, devp.getId()); | 
|                 StaProtocol staProtocol = devpThread.getStation().get(inSta.getStaNo()); | 
|                 if (staProtocol == null) { | 
|                     continue; | 
|                 } else { | 
|                     staProtocol = staProtocol.clone(); | 
|                 } | 
|                 Short workNo = staProtocol.getWorkNo(); | 
|                 // 判断是否满足入库条件 | 
|                 if (staProtocol.isAutoing() && staProtocol.isLoading() | 
|                         && staProtocol.isInEnable() | 
|                         && !staProtocol.isEmptyMk() && (workNo == 0 || (workNo >= 9990 && workNo <= 9999)) | 
|                         && staProtocol.isPakMk()) { | 
|   | 
|                     // 尺寸检测异常 | 
|                     boolean back = false; | 
|                     String errMsg = ""; | 
|                     if (staProtocol.isFrontErr()) { | 
|                         errMsg = "前超限"; | 
|                         back = true; | 
|                     } | 
|                     if (!back && staProtocol.isBackErr()) { | 
|                         errMsg = "后超限"; | 
|                         back = true; | 
|                     } | 
|                     if (!back && staProtocol.isHighErr()) { | 
|                         errMsg = "高超限"; | 
|                         back = true; | 
|                     } | 
|                     if (!back && staProtocol.isLeftErr()) { | 
|                         errMsg = "左超限"; | 
|                         back = true; | 
|                     } | 
|                     if (!back && staProtocol.isRightErr()) { | 
|                         errMsg = "右超限"; | 
|                         back = true; | 
|                     } | 
|                     if (!back && staProtocol.isWeightErr()) { | 
|                         errMsg = "超重"; | 
|                         back = true; | 
|                     } | 
|                     if (!back && staProtocol.isBarcodeErr()) { | 
|                         errMsg = "扫码失败"; | 
|                         back = true; | 
|                     } | 
|   | 
|                     // 退回 | 
|                     if (back) { | 
|                         News.warn("扫码入库失败,{}入库站因{}异常,托盘已被退回", inSta.getStaNo(), errMsg); | 
|                         staProtocol.setWorkNo((short) 32002); | 
|                         staProtocol.setStaNo(inSta.getBackSta().shortValue()); | 
|                         devpThread.setPakMk(staProtocol.getSiteId(), false); | 
|                         MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol)); | 
|   | 
|                         // led 异常显示 | 
|                         LedThread ledThread = (LedThread) SlaveConnection.get(SlaveType.Led, inSta.getLed()); | 
|                         if (ledThread != null) { | 
|                             MessageQueue.offer(SlaveType.Led, inSta.getLed(), new Task(3, errMsg)); | 
|                         } | 
|                         continue; | 
|                     } | 
|   | 
|                     // 判断重复工作档 | 
|                     WrkMast wrkMast = wrkMastMapper.selectPakInStep11(inSta.getStaNo()); | 
|                     if (wrkMast == null) { continue; } | 
|   | 
|                     // 命令下发区 -------------------------------------------------------------------------- | 
|   | 
|                     // 更新站点信息 且 下发plc命令 | 
|                     staProtocol.setWorkNo(wrkMast.getWrkNo().shortValue()); | 
|                     staProtocol.setStaNo(wrkMast.getStaNo().shortValue()); | 
|                     devpThread.setPakMk(staProtocol.getSiteId(), false); | 
|                     boolean result = MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol)); | 
|                     if (result) { | 
|                         // 更新工作主档 | 
|                         wrkMast.setWrkSts(2L); // 工作状态:2.设备上走 | 
|                         wrkMast.setModiTime(new Date()); | 
|                         if (wrkMastMapper.updateById(wrkMast) == 0) { | 
|                             News.error("更新工作档失败!!! [工作号:{}]", wrkMast.getWrkNo()); | 
|                         } | 
|                     } else { | 
|                         News.error("发布命令至输送线队列失败!!! [plc编号:{}]", devp.getId()); | 
|                     } | 
|                 } | 
|             } | 
|         } | 
|     } | 
|   | 
|     /** | 
|      * 拣料、并板再入库 | 
|      */ | 
|     @Transactional | 
|     public synchronized void stnToCrnStnPick(){ | 
|         try { | 
|             for (DevpSlave devp : slaveProperties.getDevp()) { | 
|                 // 遍历拣料入库口 | 
|                 for (DevpSlave.Sta pickSta : devp.getPickInSta()) { | 
|                     // 获取拣料入库站信息 | 
|                     DevpThread devpThread = (DevpThread) SlaveConnection.get(SlaveType.Devp, devp.getId()); | 
|                     StaProtocol staProtocol = devpThread.getStation().get(pickSta.getStaNo()); | 
|                     if (staProtocol == null) { | 
|                         continue; | 
|                     } else { | 
|                         staProtocol = staProtocol.clone(); | 
|                     } | 
|                     if (staProtocol.isAutoing() | 
|                             && staProtocol.isLoading() | 
|                             && staProtocol.isInEnable() | 
| //                        && (staProtocol.getWorkNo() > 0) | 
|                             && staProtocol.isPakMk()) { | 
|   | 
|                         // 获取条码扫描仪信息 | 
|                         BarcodeThread barcodeThread = (BarcodeThread) SlaveConnection.get(SlaveType.Barcode, pickSta.getBarcode()); | 
|                         if (barcodeThread == null) { | 
|                             continue; | 
|                         } | 
|                         String barcode = barcodeThread.getBarcode(); | 
|                         if (Cools.isEmpty(barcode)) { | 
|                             continue; | 
|                         } | 
|                         if ("NG".endsWith(barcode) || "NoRead".equals(barcode) || "empty".equals(barcode)) { | 
|                             continue; | 
|                         } | 
|   | 
|                         WrkMast wrkMast = wrkMastMapper.selectPickStepByBarcode(barcode); | 
|                         if (wrkMast == null) {//找不到工作档 | 
|                             continue; | 
|                         } | 
|   | 
|                         if ((wrkMast.getIoType() != 103 && wrkMast.getIoType() != 104) | 
|                                 || Cools.isEmpty(wrkMast.getStaNo()) || Cools.isEmpty(wrkMast.getSourceStaNo())) { | 
|                             continue; | 
|                         } | 
|   | 
| //                        //*********************同库位组校验********************* | 
| //                        boolean flag = false; | 
| //                        String th = ""; | 
| //                        List<String> innerLoc = Utils.getGroupInnerLoc(wrkMast.getSourceLocNo()); | 
| //                        for (String loc : innerLoc) { | 
| //                            LocMast locMast = locMastService.selectById(loc); | 
| //                            if (locMast == null) { | 
| //                                continue; | 
| //                            } | 
| // | 
| //                            if (!locMast.getLocSts().equals("F")) { | 
| //                                flag = true; | 
| //                                th = loc + "库位存在未回库任务"; | 
| //                                break; | 
| //                            } | 
| //                        } | 
| //                        if (flag) { | 
| //                            News.info(th); | 
| //                            continue; | 
| //                        } | 
| //                        //*********************同库位组校验********************* | 
|   | 
| //                        // 保存工作主档历史档 | 
| //                        if (wrkMastMapper.saveWrkMastLog(wrkMast.getWrkNo()) == 0) { | 
| //                            News.info(wrkMast.getWrkNo() + "保存工作主档历史档失败"); | 
| //                            continue; | 
| //                        } | 
|   | 
|                         try { | 
|                             LocMast locMast = locMastService.selectById(wrkMast.getSourceLocNo());//源库位 | 
|                             SearchLocParam param = new SearchLocParam(); | 
|                             param.setWrkNo(wrkMast.getWrkNo()); | 
|                             param.setBarcode(wrkMast.getBarcode()); | 
|                             param.setIoType(wrkMast.getIoType()); | 
|                             param.setSourceStaNo(pickSta.getStaNo()); | 
|                             param.setLiftNo(pickSta.getLiftNo()); | 
|                             param.setLocType1(locMast.getLocType1()); | 
|                             String response = new HttpHandler.Builder() | 
|                                     .setUri(wmsUrl) | 
|                                     .setPath("/rpc/pakin/loc/v2") | 
|                                     .setJson(JSON.toJSONString(param)) | 
|                                     .build() | 
|                                     .doPost(); | 
|                             JSONObject jsonObject = JSON.parseObject(response); | 
|                             Integer code = jsonObject.getInteger("code"); | 
|                             if (code.equals(200)) { | 
|                                 StartupDto dto = jsonObject.getObject("data", StartupDto.class); | 
|   | 
| //                                //获取回库提升机目标站 | 
| //                                LiftStaProtocol liftStaProtocol = NyLiftUtils.getLiftStaByLev(pickSta.getLiftNo(), Utils.getLev(dto.getLocNo())); | 
| //                                if (liftStaProtocol == null) { | 
| //                                    News.info(wrkMast.getWrkNo() + "获取回库提升机目标站失败"); | 
| //                                    continue; | 
| //                                } | 
| // | 
| //                                // 更新工作档数据状态 | 
| //                                wrkMast.setIoType(wrkMast.getIoType() - 50); // 入出库类型: 103->53,104->54 | 
| //                                wrkMast.setWrkSts(2L); // 工作状态: 2.设备上走 | 
| //                                wrkMast.setSourceStaNo(dto.getSourceStaNo()); // 源站 | 
| //                                wrkMast.setStaNo(liftStaProtocol.getStaNo());//目标站 | 
| //                                wrkMast.setLocNo(dto.getLocNo()); // 目标库位 | 
| //                                wrkMast.setShuttleNo(null); // 穿梭车清空 | 
| //                                wrkMast.setLiftNo(null);// 提升机清空 | 
| //                                wrkMast.setModiTime(new Date()); | 
| //                                if (wrkMastMapper.updateById(wrkMast) == 0) { | 
| //                                    News.info(wrkMast.getWrkNo() + "更新工作档数据状态失败"); | 
| //                                    continue; | 
| //                                } | 
|                             } else if (code == 500) { | 
|                                 News.error("请求接口失败!!!url:{};request:{};response:{}", wmsUrl + "/rpc/pakin/loc/v2", JSON.toJSONString(param), response); | 
|                             } | 
|                         } catch (Exception e) { | 
|                             e.printStackTrace(); | 
|                             TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); | 
|                         } | 
|                     } | 
|                 } | 
|   | 
|             } | 
|         } catch (Exception e) { | 
|             e.printStackTrace(); | 
|         } | 
|     } | 
|   | 
|     /** | 
|      * 拣料、并板再入库(325、331、333、339) | 
|      */ | 
|     @Transactional | 
|     public synchronized void stnToCrnStnPick2(){ | 
|         try { | 
|             for (DevpSlave devp : slaveProperties.getDevp()) { | 
|                 // 遍历拣料入库口 | 
|                 for (DevpSlave.Sta pickSta : devp.getPickInSta2()) { | 
|                     // 获取拣料入库站信息 | 
|                     DevpThread devpThread = (DevpThread) SlaveConnection.get(SlaveType.Devp, devp.getId()); | 
|                     StaProtocol staProtocol = devpThread.getStation().get(pickSta.getStaNo()); | 
|                     if (staProtocol == null) { | 
|                         continue; | 
|                     } else { | 
|                         staProtocol = staProtocol.clone(); | 
|                     } | 
|                     if (staProtocol.isAutoing() | 
|                             && staProtocol.isLoading() | 
|                             && staProtocol.isInEnable() | 
|                             && (staProtocol.getWorkNo() > 0) | 
|                             && staProtocol.isPakMk()) { | 
|   | 
|                         WrkMast wrkMast = wrkMastMapper.selectByWorkNo(staProtocol.getWorkNo().intValue()); | 
|                         if (wrkMast == null) { | 
|                             continue; | 
|                         } | 
|                         if (wrkMast.getSteNo() == null) { | 
|                             wrkMast.setSteNo(1); | 
|                             wrkMastMapper.updateById(wrkMast); | 
|                             staProtocol.setStaNo((short) 341);//写入目标站 | 
|                             staProtocol.setPakMk(false); | 
|                             MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol)); | 
|                         } | 
|                     } | 
|                 } | 
|   | 
|             } | 
|         } catch (Exception e) { | 
|             e.printStackTrace(); | 
|         } | 
|     } | 
|   | 
|     /** | 
|      * 盘点再入库 | 
|      */ | 
|     @Transactional | 
|     public synchronized void stnToCrnStnPlate(){ | 
|         try { | 
|             for (DevpSlave devp : slaveProperties.getDevp()) { | 
|                 // 遍历拣料入库口 | 
|                 for (DevpSlave.Sta pickSta : devp.getPickInSta()) { | 
|                     // 获取拣料入库站信息 | 
|                     DevpThread devpThread = (DevpThread) SlaveConnection.get(SlaveType.Devp, devp.getId()); | 
|                     StaProtocol staProtocol = devpThread.getStation().get(pickSta.getStaNo()); | 
|                     if (staProtocol == null) { | 
|                         continue; | 
|                     } else { | 
|                         staProtocol = staProtocol.clone(); | 
|                     } | 
|                     if (staProtocol.isAutoing() | 
|                             && staProtocol.isLoading() | 
|                             && staProtocol.isInEnable() | 
| //                            && (staProtocol.getWorkNo() > 0) | 
|                             && staProtocol.isPakMk()) { | 
|   | 
|                         // 获取条码扫描仪信息 | 
|                         BarcodeThread barcodeThread = (BarcodeThread) SlaveConnection.get(SlaveType.Barcode, pickSta.getBarcode()); | 
|                         if (barcodeThread == null) { | 
|                             continue; | 
|                         } | 
|                         String barcode = barcodeThread.getBarcode(); | 
|                         if (Cools.isEmpty(barcode)) { | 
|                             continue; | 
|                         } | 
|                         if ("NG".endsWith(barcode) || "NoRead".equals(barcode) || "empty".equals(barcode)) { | 
|                             continue; | 
|                         } | 
|                         WrkMast wrkMast = wrkMastMapper.selectByBarcode(barcode); | 
|                         if (wrkMast == null) {//找不到工作档 | 
|                             continue; | 
|                         } | 
|   | 
|                         if ((wrkMast.getIoType() != 107) | 
|                                 || Cools.isEmpty(wrkMast.getStaNo()) || Cools.isEmpty(wrkMast.getSourceStaNo())) { | 
|                             continue; | 
|                         } | 
|   | 
| //                        // 保存工作主档历史档 | 
| //                        if (wrkMastMapper.saveWrkMastLog(wrkMast.getWrkNo()) == 0) { | 
| //                            News.info(wrkMast.getWrkNo() + "保存工作主档历史档失败"); | 
| //                            continue; | 
| //                        } | 
|   | 
|                         //盘点找新库位 | 
|                         try { | 
|                             LocMast locMast = locMastService.selectById(wrkMast.getSourceLocNo());//源库位 | 
|                             SearchLocParam param = new SearchLocParam(); | 
|                             param.setWrkNo(wrkMast.getWrkNo()); | 
|                             param.setBarcode(wrkMast.getBarcode()); | 
|                             param.setIoType(107);//盘点 | 
|                             param.setSourceStaNo(pickSta.getStaNo()); | 
|                             param.setLiftNo(pickSta.getLiftNo()); | 
|                             param.setLocType1(locMast.getLocType1()); | 
|                             String response = new HttpHandler.Builder() | 
|                                     .setUri(wmsUrl) | 
|                                     .setPath("/rpc/pakin/loc/v2") | 
|                                     .setJson(JSON.toJSONString(param)) | 
|                                     .build() | 
|                                     .doPost(); | 
|                             JSONObject jsonObject = JSON.parseObject(response); | 
|                             Integer code = jsonObject.getInteger("code"); | 
|                             if (code.equals(200)) { | 
|                                 StartupDto dto = jsonObject.getObject("data", StartupDto.class); | 
|   | 
| //                                //获取回库提升机目标站 | 
| //                                LiftStaProtocol liftStaProtocol = NyLiftUtils.getLiftStaByLev(pickSta.getLiftNo(), Utils.getLev(dto.getLocNo())); | 
| //                                if (liftStaProtocol == null) { | 
| //                                    News.info(wrkMast.getWrkNo() + "获取回库提升机目标站失败"); | 
| //                                    continue; | 
| //                                } | 
| // | 
| //                                // 更新工作档数据状态 | 
| //                                wrkMast.setIoType(wrkMast.getIoType() - 50); // 入出库类型: 107->57 | 
| //                                wrkMast.setWrkSts(2L); // 工作状态: 2.设备上走 | 
| //                                wrkMast.setSourceStaNo(dto.getSourceStaNo()); // 源站 | 
| //                                wrkMast.setStaNo(liftStaProtocol.getStaNo());//目标站 | 
| //                                wrkMast.setLocNo(dto.getLocNo()); // 目标库位 | 
| //                                wrkMast.setShuttleNo(null); // 穿梭车清空 | 
| //                                wrkMast.setLiftNo(null);// 提升机清空 | 
| //                                wrkMast.setModiTime(new Date()); | 
| //                                if (wrkMastMapper.updateById(wrkMast) == 0) { | 
| //                                    News.info(wrkMast.getWrkNo() + "更新工作档数据状态失败"); | 
| //                                    continue; | 
| //                                } | 
|   | 
| //                                staProtocol.setStaNo(dto.getSourceStaNo().shortValue());//写入目标站 | 
| //                                MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol)); | 
|   | 
|                             } else if (code == 500) { | 
|                                 News.error("请求接口失败!!!url:{};request:{};response:{}", wmsUrl + "/rpc/pakin/loc/v2", JSON.toJSONString(param), response); | 
|                             } | 
|                         } catch (Exception e) { | 
|                             e.printStackTrace(); | 
|                             TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); | 
|                         } | 
|   | 
|                     } | 
|                 } | 
|             } | 
|         } catch (Exception e) { | 
|             e.printStackTrace(); | 
|         } | 
|     } | 
|   | 
| //    /** | 
| //     * 拣料、并板、盘点再入库 | 
| //     */ | 
| //    @Transactional | 
| //    public synchronized void stnToCrnStnPick(){ | 
| //        for (DevpSlave devp : slaveProperties.getDevp()) { | 
| //            // 遍历拣料入库口 | 
| //            for (DevpSlave.Sta pickSta : devp.getPickInSta()) { | 
| // | 
| //                // 获取拣料入库站信息 | 
| //                DevpThread devpThread = (DevpThread) SlaveConnection.get(SlaveType.Devp, devp.getId()); | 
| //                StaProtocol staProtocol = devpThread.getStation().get(pickSta.getStaNo()); | 
| //                if (staProtocol == null) { | 
| //                    continue; | 
| //                } else { | 
| //                    staProtocol = staProtocol.clone(); | 
| //                } | 
| //                if (staProtocol.isAutoing() | 
| //                        && staProtocol.isLoading() | 
| ////                        && (staProtocol.getWorkNo() > 0 && staProtocol.getWorkNo() < 9999) | 
| ////                        && staProtocol.getStaNo().equals(staProtocol.getSiteId().shortValue()) | 
| //                        && staProtocol.isPakMk()){ | 
| // | 
| //                    // 获取条码扫描仪信息 | 
| //                    BarcodeThread barcodeThread = (BarcodeThread) SlaveConnection.get(SlaveType.Barcode, pickSta.getBarcode()); | 
| //                    if (barcodeThread == null) { | 
| //                        continue; | 
| //                    } | 
| //                    String barcode = barcodeThread.getBarcode(); | 
| // | 
| //                    WrkMast wrkMast = null; | 
| //                    wrkMast = wrkMastMapper.selectPickStepByBarcode(barcode); | 
| //                    if (wrkMast == null) { | 
| //                        continue; | 
| //                    } | 
| ////                    if (staProtocol.getWorkNo() == 9996) { | 
| ////                        String barcode = barcodeThread.getBarcode(); | 
| ////                        if(!Cools.isEmpty(barcode)) { | 
| ////                            News.info("{}号条码扫描器检测条码信息:{}", pickSta.getBarcode(), barcode); | 
| ////                            if("NG".endsWith(barcode) || "NoRead".equals(barcode) || "empty".equals(barcode)) { | 
| ////                                staProtocol.setWorkNo((short) 32002); | 
| ////                                staProtocol.setStaNo(pickSta.getBackSta().shortValue()); | 
| ////                                devpThread.setPakMk(staProtocol.getSiteId(), false); | 
| ////                                MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol)); | 
| //// | 
| ////                                // led 异常显示 | 
| ////                                LedThread ledThread = (LedThread) SlaveConnection.get(SlaveType.Led, pickSta.getLed()); | 
| ////                                if (ledThread != null) { | 
| ////                                    String errorMsg = "扫码失败,请重试"; | 
| ////                                    MessageQueue.offer(SlaveType.Led, pickSta.getLed(), new Task(3, errorMsg)); | 
| ////                                } | 
| ////                                continue; | 
| ////                            } | 
| ////                        } else { | 
| ////                            staProtocol.setWorkNo((short) 32002); | 
| ////                            staProtocol.setStaNo(pickSta.getBackSta().shortValue()); | 
| ////                            devpThread.setPakMk(staProtocol.getSiteId(), false); | 
| ////                            MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol)); | 
| //// | 
| ////                            // led 异常显示 | 
| ////                            LedThread ledThread = (LedThread) SlaveConnection.get(SlaveType.Led, pickSta.getLed()); | 
| ////                            if (ledThread != null) { | 
| ////                                String errorMsg = "扫码失败,请重试"; | 
| ////                                MessageQueue.offer(SlaveType.Led, pickSta.getLed(), new Task(3, errorMsg)); | 
| ////                            } | 
| ////                            continue; | 
| ////                        } | 
| ////                        wrkMast = wrkMastMapper.selectPickStepByBarcode(barcode); | 
| ////                        if (null == wrkMast) { | 
| ////                            News.error("{}条码错误,暂无拣料任务!", barcode); | 
| ////                        } | 
| ////                    } | 
| // | 
| //                    if ((wrkMast.getIoType() != 103 && wrkMast.getIoType() != 104 && wrkMast.getIoType() != 107) | 
| //                        || Cools.isEmpty(wrkMast.getStaNo()) || Cools.isEmpty(wrkMast.getSourceStaNo()) ) { | 
| //                        continue; | 
| //                    } | 
| // | 
| //                    // 保存工作主档历史档 | 
| //                    if (wrkMastMapper.saveWrkMastLog(wrkMast.getWrkNo()) == 0) { | 
| //                        throw new CoolException(wrkMast.getWrkNo() + "保存工作主档历史档失败"); | 
| //                    } | 
| // | 
| //                    String sourceLocNo = wrkMast.getSourceLocNo().trim(); | 
| //                    LiftStaProtocol liftStaProtocol = NyLiftUtils.getLiftStaByLev(pickSta.getLiftNo(), Utils.getLev(sourceLocNo));//获取回库提升机目标站 | 
| //                    if (liftStaProtocol == null) { | 
| //                        continue; | 
| //                    } | 
| // | 
| //                    // 更新工作档数据状态 | 
| //                    wrkMast.setIoType(wrkMast.getIoType() - 50); // 入出库类型: 103->53,104->54,107->57 | 
| //                    wrkMast.setWrkSts(2L); // 工作状态: 2.设备上走 | 
| //                    wrkMast.setSourceStaNo(pickSta.getStaNo()); // 源站 | 
| ////                            wrkMast.setStaNo(dto.getStaNo()); // 目标站 | 
| ////                            wrkMast.setCrnNo(dto.getCrnNo()); | 
| //                    wrkMast.setStaNo(liftStaProtocol.getStaNo());//目标站 | 
| //                    wrkMast.setLocNo(sourceLocNo); // 目标库位 = 出库时的源库位 | 
| //                    wrkMast.setShuttleNo(null); // 穿梭车清空 | 
| //                    wrkMast.setLiftNo(null);// 提升机清空 | 
| //                    wrkMast.setModiTime(new Date()); | 
| //                    if (wrkMastMapper.updateById(wrkMast) == 0) { | 
| //                        throw new CoolException(wrkMast.getWrkNo() + "更新工作档数据状态失败"); | 
| //                    } | 
| //                    if (wrkMastMapper.setSteEmpty(wrkMast.getWrkNo()) == 0) { | 
| //                        throw new CoolException(wrkMast.getWrkNo() + "更新工作档数据状态失败"); | 
| //                    } | 
| // | 
| //                    // 修改库位状态 Q.拣料/盘点/并板再入库 | 
| //                    LocMast locMast = locMastService.selectById(sourceLocNo); | 
| //                    locMast.setLocSts("Q"); | 
| //                    locMast.setModiTime(new Date()); | 
| //                    if (!locMastService.updateById(locMast)) { | 
| //                        throw new CoolException("修改库位状态失败"); | 
| //                    } | 
| //                    barcodeThread.setBarcode("");//清理条码 | 
| // | 
| ////                    try { | 
| ////                        // 访问 WMS 获取入库库位 | 
| ////                        LocTypeDto locTypeDto = new LocTypeDto(staProtocol); | 
| ////                        SearchLocParam param = new SearchLocParam(); | 
| ////                        param.setWrkNo(wrkMast.getWrkNo()); | 
| ////                        param.setIoType(wrkMast.getIoType()); | 
| ////                        param.setSourceStaNo(pickSta.getStaNo()); | 
| //////                        param.setLocType1(locTypeDto.getLocType1()); | 
| ////                        String response = new HttpHandler.Builder() | 
| ////                                .setUri(wmsUrl) | 
| ////                                .setPath("/rpc/pakin/loc/v1") | 
| ////                                .setJson(JSON.toJSONString(param)) | 
| ////                                .build() | 
| ////                                .doPost(); | 
| ////                        JSONObject jsonObject = JSON.parseObject(response); | 
| ////                        LedThread ledThread = (LedThread) SlaveConnection.get(SlaveType.Led, pickSta.getLed()); | 
| ////                        Integer code = jsonObject.getInteger("code"); | 
| ////                        if (code.equals(200)) { | 
| ////                            StartupDto dto = jsonObject.getObject("data", StartupDto.class); | 
| //// | 
| //////                            // 获取目标站 | 
| //////                            Wrapper<StaDesc> wrapper = new EntityWrapper<StaDesc>() | 
| //////                                    .eq("type_no", wrkMast.getIoType() - 50) | 
| //////                                    .eq("stn_no", pickSta.getStaNo()) // 作业站点 = 拣料出库的目标站 | 
| //////                                    .eq("crn_no", dto.getCrnNo()); // 堆垛机号 | 
| //////                            StaDesc staDesc = staDescService.selectOne(wrapper); | 
| //////                            if (Cools.isEmpty(staDesc)) { | 
| //////                                News.error("入库路径不存在!type_no={},stn_no={},crn_no={}", wrkMast.getIoType(), pickSta.getStaNo(), wrkMast.getCrnNo()); | 
| //////                                continue; | 
| //////                            } | 
| //////                            // 堆垛机站点(目标站) | 
| //////                            Integer staNo = staDesc.getCrnStn(); | 
| //// | 
| ////                            // 保存工作明细档历史档 | 
| //////                        if (wrkMastMapper.saveWrkDetlLog(wrkMast.getWrkNo()) == 0) { | 
| //////                            throw new CoolException("保存工作明细档历史档失败"); | 
| //////                        } | 
| ////                            // 保存工作主档历史档 | 
| ////                            if (wrkMastMapper.saveWrkMastLog(wrkMast.getWrkNo()) == 0) { | 
| ////                                throw new CoolException(wrkMast.getWrkNo() + "保存工作主档历史档失败"); | 
| ////                            } | 
| //// | 
| ////                            String sourceLocNo = wrkMast.getSourceLocNo().trim(); | 
| ////                            LiftStaProtocol liftStaProtocol = NyLiftUtils.getLiftStaByLev(pickSta.getLiftNo(), Utils.getLev(sourceLocNo));//获取回库提升机目标站 | 
| ////                            if (liftStaProtocol == null) { | 
| ////                                continue; | 
| ////                            } | 
| //// | 
| ////                            // 更新工作档数据状态 | 
| ////                            wrkMast.setIoType(wrkMast.getIoType() - 50); // 入出库类型: 103->53,104->54,107->57 | 
| ////                            wrkMast.setWrkSts(2L); // 工作状态: 2.设备上走 | 
| ////                            wrkMast.setSourceStaNo(pickSta.getStaNo()); // 源站 | 
| //////                            wrkMast.setStaNo(dto.getStaNo()); // 目标站 | 
| //////                            wrkMast.setCrnNo(dto.getCrnNo()); | 
| ////                            wrkMast.setStaNo(liftStaProtocol.getStaNo());//目标站 | 
| ////                            wrkMast.setLocNo(sourceLocNo); // 目标库位 = 出库时的源库位 | 
| ////                            wrkMast.setShuttleNo(null); // 穿梭车清空 | 
| ////                            wrkMast.setLiftNo(null);// 提升机清空 | 
| ////                            wrkMast.setModiTime(new Date()); | 
| ////                            if (wrkMastMapper.updateById(wrkMast) == 0) { | 
| ////                                throw new CoolException(wrkMast.getWrkNo() + "更新工作档数据状态失败"); | 
| ////                            } | 
| ////                            if (wrkMastMapper.setSteEmpty(wrkMast.getWrkNo()) == 0) { | 
| ////                                throw new CoolException(wrkMast.getWrkNo() + "更新工作档数据状态失败"); | 
| ////                            } | 
| //// | 
| ////                            // 修改库位状态 Q.拣料/盘点/并板再入库 | 
| ////                            LocMast locMast = locMastService.selectById(sourceLocNo); | 
| ////                            locMast.setLocSts("Q"); | 
| ////                            locMast.setModiTime(new Date()); | 
| ////                            if (!locMastService.updateById(locMast)) { | 
| ////                                throw new CoolException("修改库位状态失败"); | 
| ////                            } | 
| //// | 
| //////                            // 更新站点信息 且 下发plc命令 | 
| //////                            staProtocol.setWorkNo(wrkMast.getWrkNo().shortValue()); | 
| //////                            staProtocol.setStaNo(wrkMast.getStaNo().shortValue()); | 
| //////                            devpThread.setPakMk(staProtocol.getSiteId(), false); | 
| //////                            boolean result = MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol)); | 
| //////                            if (!result) { | 
| //////                                News.error("发布命令至输送线队列失败!!! [plc编号:{}]", devp.getId()); | 
| //////                            } | 
| //// | 
| ////                            barcodeThread.setBarcode("");//清理条码 | 
| //// | 
| ////                        } else if (code == 500){ | 
| ////                            if (ledThread != null) { | 
| ////                                String errorMsg = jsonObject.getString("msg"); | 
| ////                                if (!Cools.isEmpty(errorMsg)) { | 
| ////                                    MessageQueue.offer(SlaveType.Led, pickSta.getLed(), new Task(3, errorMsg)); | 
| ////                                } | 
| ////                            } | 
| ////                            News.error("请求接口失败!!!url:{};request:{};response:{}", wmsUrl + "/rpc/pakin/loc/v1", JSON.toJSONString(param), response); | 
| ////                        } else { | 
| //////                            staProtocol.setWorkNo((short) 32002); | 
| //////                            staProtocol.setStaNo(pickSta.getBackSta().shortValue()); | 
| //////                            devpThread.setPakMk(staProtocol.getSiteId(), false); | 
| //////                            MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol)); | 
| //// | 
| ////                            // led 异常显示 | 
| ////                            if (ledThread != null) { | 
| ////                                String errorMsg = jsonObject.getString("msg"); | 
| //////                                String errorMsg = barcode + "托盘识别异常,请先进行组托!"; | 
| ////                                MessageQueue.offer(SlaveType.Led, pickSta.getLed(), new Task(3, errorMsg)); | 
| ////                            } | 
| ////                        } | 
| //// | 
| ////                    } catch (Exception e) { | 
| ////                        e.printStackTrace(); | 
| ////                        TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); | 
| ////                    } | 
| // | 
| //                } | 
| //            } | 
| // | 
| //        } | 
| //    } | 
|   | 
|     /** | 
|      * 初始化实时地图 | 
|      */ | 
|     public synchronized void initRealtimeBasMap() { | 
|         try { | 
|             for (int i = 1; i <= 10; i++) {//总共四层楼 | 
|                 Object data = redisUtil.get(RedisKeyType.MAP.key + i); | 
|                 if (data == null) {//redis地图数据为空,从数据库中获取 | 
|                     BasMap basMap = basMapService.selectLatestMap(i); | 
|                     if (basMap == null) { | 
|                         //数据库中也不存在地图数据,从地图文件中获取 | 
|                         //载入地图 | 
|                         navigateMapData.setLev(i); | 
|                         List<List<MapNode>> lists = navigateMapData.getJsonData(-1, null, null);//获取完整地图(包括入库出库) | 
|   | 
|                         //存入数据库 | 
|                         basMap = new BasMap(); | 
|                         basMap.setData(JSON.toJSONString(lists)); | 
|                         basMap.setCreateTime(new Date()); | 
|                         basMap.setUpdateTime(new Date()); | 
|                         basMap.setLev(i); | 
|   | 
|                         if (!basMapService.insert(basMap)) { | 
|                             log.info("地图数据存储失败"); | 
|                         } | 
|                     } | 
|   | 
|                     //将数据库地图数据存入redis | 
|                     redisUtil.set(RedisKeyType.MAP.key + i, JSON.toJSONString(basMap)); | 
|                 } | 
|             } | 
|         } catch (Exception e) { | 
|             e.printStackTrace(); | 
|         } | 
|     } | 
|   | 
|     /** | 
|      * 从redis中重启任务 | 
|      */ | 
|     public synchronized void restartTaskFromRedis() { | 
|         HashMap<Object, Object> map = redisUtil.getRedis(); | 
|         for (Object key : map.keySet()) { | 
|             if (key.toString().contains(RedisKeyType.LIFT.key)) {//提升机任务 | 
|                 LiftRedisCommand redisCommand = JSON.parseObject(map.get(key).toString(), LiftRedisCommand.class); | 
|                 if (redisCommand == null) { | 
|                     continue; | 
|                 } | 
|   | 
|                 Short liftNo = redisCommand.getLiftNo(); | 
|                 LiftThread liftThread = (LiftThread) SlaveConnection.get(SlaveType.Lift, liftNo.intValue()); | 
|                 if (liftThread == null) { | 
|                     continue; | 
|                 } | 
|                 LiftProtocol liftProtocol = liftThread.getLiftProtocol(); | 
|                 if (liftProtocol == null) { | 
|                     continue; | 
|                 } | 
|                 if (!liftProtocol.isIdle()) { | 
|                     continue; | 
|                 } | 
|   | 
|                 //提升机处于空闲状态,进行任务的恢复 | 
|                 liftProtocol.setTaskNo(redisCommand.getWrkNo());//将提升机线程分配任务号 | 
|                 liftProtocol.setProtocolStatus(LiftProtocolStatusType.WORKING);//工作状态 | 
|   | 
|             }else if(key.toString().contains(RedisKeyType.SHUTTLE.key)){//四向穿梭车任务 | 
|                 ShuttleRedisCommand redisCommand = JSON.parseObject(map.get(key).toString(), ShuttleRedisCommand.class); | 
|                 if (redisCommand == null) { | 
|                     continue; | 
|                 } | 
|   | 
|                 Short shuttleNo = redisCommand.getShuttleNo(); | 
|                 NyShuttleThread shuttleThread = (NyShuttleThread) SlaveConnection.get(SlaveType.Shuttle, shuttleNo.intValue()); | 
|                 if (shuttleThread == null) { | 
|                     continue; | 
|                 } | 
|                 NyShuttleProtocol shuttleProtocol = shuttleThread.getShuttleProtocol(); | 
|                 if (shuttleProtocol == null) { | 
|                     continue; | 
|                 } | 
|                 if (!shuttleProtocol.isIdle()) { | 
|                     continue; | 
|                 } | 
|   | 
|                 //四向穿梭车处于空闲状态,进行任务的恢复 | 
|                 shuttleProtocol.setTaskNo(redisCommand.getWrkNo().intValue());//将四向穿梭车线程分配任务号 | 
|                 shuttleProtocol.setProtocolStatus(ShuttleProtocolStatusType.WORKING);//工作状态 | 
|             } | 
|         } | 
|   | 
|     } | 
|   | 
|     /** | 
|      * 入库  ===>>  四向穿梭车入库作业下发 | 
|      */ | 
|     public synchronized void shuttleInExecute() { | 
|         try { | 
|             List<WrkMast> wrkMasts = wrkMastMapper.selectInStep4(); | 
|             for (WrkMast wrkMast : wrkMasts) { | 
|                 //获取源站 | 
|                 BasDevp sourceBasDevp = basDevpService.selectById(wrkMast.getSourceStaNo()); | 
|                 if (sourceBasDevp == null) { | 
|                     continue;//站点不存在 | 
|                 } | 
|   | 
|                 //获取目标站 | 
|                 LiftStaProtocol liftStaProtocol = NyLiftUtils.getLiftStaByLev(sourceBasDevp.getLiftNo(), Utils.getLev(wrkMast.getLocNo())); | 
|                 if (liftStaProtocol == null) { | 
|                     continue;//站点不存在 | 
|                 } | 
|   | 
|                 // 判断是否满足入库条件,自动、空闲、有物 | 
|                 if (!(liftStaProtocol.getModel() && !liftStaProtocol.getBusy() && liftStaProtocol.getHasTray())) { | 
|                     News.info("{}任务,输送站点状态不满足入库。输送站点:{}", wrkMast.getWrkNo(), JSON.toJSONString(liftStaProtocol)); | 
|                     continue; | 
|                 } | 
|   | 
|                 boolean step1 = this.shuttleInExecuteStep1(wrkMast, liftStaProtocol);//小车搬入库中 | 
|                 if (!step1) { | 
|                     continue; | 
|                 } | 
|             } | 
|         } catch (Exception e) { | 
|             e.printStackTrace(); | 
|         } | 
|     } | 
|   | 
| //    /** | 
| //     * 入库  ===>>  四向穿梭车入库作业下发 | 
| //     */ | 
| //    public synchronized void shuttleInExecute() { | 
| //        // 根据输送线plc遍历 | 
| //        for (DevpSlave devp : slaveProperties.getDevp()) { | 
| //            // 遍历入库站 | 
| //            for (DevpSlave.StaRack staRack : devp.getRackInStn()) { | 
| //                // 获取入库站信息 | 
| //                DevpThread devpThread = (DevpThread) SlaveConnection.get(SlaveType.Devp, devp.getId()); | 
| //                StaProtocol staProtocol = devpThread.getStation().get(staRack.getStaNo()); | 
| //                if (staProtocol == null) { | 
| //                    continue; | 
| //                } else { | 
| //                    staProtocol = staProtocol.clone(); | 
| //                } | 
| //                Short workNo = staProtocol.getWorkNo(); | 
| //                BasDevp basDevp = basDevpService.selectById(staProtocol.getSiteId()); | 
| //                if (basDevp == null) { | 
| //                    continue;//站点信息不存在 | 
| //                } | 
| // | 
| //                // 判断是否满足入库条件,自动、有物、四向穿梭车可取信号 | 
| //                if (!(staProtocol.isAutoing() && staProtocol.isLoading() && staProtocol.isShuttleTakeEnable())) { | 
| //                    continue; | 
| //                } | 
| // | 
| //                WrkMast wrkMast = wrkMastMapper.selectRackInStep4(workNo, staProtocol.getSiteId()); | 
| //                if (wrkMast == null) { | 
| //                    continue; | 
| //                } | 
| // | 
| //                boolean step1 = this.shuttleInExecuteStep1(wrkMast, basDevp);//小车搬入库中 | 
| //                if (!step1) { | 
| //                    continue; | 
| //                } | 
| // | 
| //            } | 
| //        } | 
| // | 
| //    } | 
|   | 
|     /** | 
|      * 入库-小车搬入库中 | 
|      * 如需主方法执行continue,请返回false | 
|      * ps:返回值true并不代表该方法执行成功,返回值仅做标记用于主方法是否执行continue | 
|      */ | 
|     public boolean shuttleInExecuteStep1(WrkMast wrkMast, LiftStaProtocol liftStaProtocol) { | 
|         if (wrkMast.getWrkSts() == 4) { | 
|             if (wrkMast.getShuttleNo() == null) {//没有绑定小车,进行调度 | 
|                 boolean result = shuttleDispatchUtils.dispatchShuttle(wrkMast.getWrkNo(), liftStaProtocol.getLocNo());//调度小车到货物所在输送站点进行取货 | 
|                 News.info("{}任务,调度小车{}系统等待中", wrkMast.getWrkNo(), result ? "成功" : "失败"); | 
|                 return false; | 
|             } | 
|   | 
|             //获取四向穿梭车线程 | 
|             NyShuttleThread shuttleThread = (NyShuttleThread) SlaveConnection.get(SlaveType.Shuttle, wrkMast.getShuttleNo()); | 
|             if (shuttleThread == null) { | 
|                 return false; | 
|             } | 
|             NyShuttleProtocol shuttleProtocol = shuttleThread.getShuttleProtocol(); | 
|             if (shuttleProtocol == null) { | 
|                 return false; | 
|             } | 
|             if (!shuttleProtocol.isIdle()) { | 
|                 News.info("{}任务,{}小车忙碌中", wrkMast.getWrkNo(), shuttleProtocol.getShuttleNo()); | 
|                 return false; | 
|             } | 
|             //判断小车令牌是否未被占领 | 
|             if (shuttleProtocol.getToken() != 0) { | 
|                 News.info("{}任务,{}小车,令牌已被独占,禁止派发任务", wrkMast.getWrkNo(), shuttleProtocol.getShuttleNo()); | 
|                 return false;//小车已被独占,禁止再派发任务 | 
|             } | 
|   | 
|             //判断小车是否存在移动任务 | 
|             WrkMast hasMoveWorking = wrkMastMapper.selectShuttleHasMoveWorking(wrkMast.getShuttleNo()); | 
|             if (hasMoveWorking != null) { | 
|                 News.info("{}任务,{}小车,存在移动任务,禁止派发任务", wrkMast.getWrkNo(), shuttleProtocol.getShuttleNo()); | 
|                 return false;//存在移动任务,禁止执行入库任务 | 
|             } | 
|   | 
|             //判断小车是否到达输送站点库位 | 
|             if (!shuttleProtocol.getCurrentLocNo().equals(liftStaProtocol.getLocNo())) { | 
|                 //小车不在输送站点位置 | 
|                 shuttleDispatchUtils.dispatchShuttle(wrkMast.getWrkNo(), liftStaProtocol.getLocNo(), wrkMast.getShuttleNo());//调度小车到货物所在输送站点进行取货 | 
|                 News.info("{}任务,{}小车,未到达输送站点,系统等待中", wrkMast.getWrkNo(), shuttleProtocol.getShuttleNo()); | 
|                 return false; | 
|             } | 
|   | 
|             //小车已抵达输送站点位置,进行搬运货物 | 
|             NyShuttleOperaResult result = NyShuttleOperaUtils.getShuttleTransportCommands(wrkMast.getShuttleNo(), wrkMast.getWrkNo(), shuttleProtocol.getCurrentLocNo(), wrkMast.getLocNo()); | 
|             if (result == null) {//路径计算失败 | 
|                 News.info("{}任务,{}小车,路径计算失败,系统等待中", wrkMast.getWrkNo(), shuttleProtocol.getShuttleNo()); | 
|                 return false; | 
|             } | 
|   | 
|             //创建分配命令 | 
|             ShuttleAssignCommand assignCommand = new ShuttleAssignCommand(); | 
|             assignCommand.setShuttleNo(shuttleProtocol.getShuttleNo());//四向穿梭车号 | 
|             assignCommand.setTaskNo(wrkMast.getWrkNo().shortValue());//任务号 | 
|             assignCommand.setTaskMode(ShuttleTaskModeType.PAK_IN.id.shortValue());//入库模式 | 
|             assignCommand.setSourceLocNo(shuttleProtocol.getCurrentLocNo());//源库位(小车当前位置) | 
|             assignCommand.setCommands(result.getCommands());//运行命令 | 
|             assignCommand.setNodes(result.getNodes());//路径节点 | 
|   | 
|             wrkMast.setWrkSts(5L);//4.提升机搬运完成 => 5.小车搬运中 | 
|             wrkMast.setModiTime(new Date()); | 
|             shuttleProtocol.setToken(wrkMast.getWrkNo());//独占小车令牌 | 
|             if (wrkMastMapper.updateById(wrkMast) > 0) { | 
|                 //下发任务 | 
|                 MessageQueue.offer(SlaveType.Shuttle, assignCommand.getShuttleNo().intValue(), new Task(3, assignCommand)); | 
|             } | 
|   | 
|             return false; | 
|         } | 
|         return true; | 
|     } | 
|   | 
|     /** | 
|      * 出库  ===>>  四向穿梭车出库作业下发 | 
|      */ | 
|     public synchronized void shuttleOutExecute() { | 
|         try { | 
|             for (WrkMast wrkMast : wrkMastMapper.selectBy2125()) { | 
|                 boolean step1 = this.shuttleOutExecuteStep1(wrkMast);//小车搬出库中 | 
|                 if (!step1) { | 
|                     continue; | 
|                 } | 
|             } | 
|         } catch (Exception e) { | 
|             e.printStackTrace(); | 
|         } | 
|     } | 
|   | 
|     /** | 
|      * 出库-小车搬出库中 | 
|      * 如需主方法执行continue,请返回false | 
|      * ps:返回值true并不代表该方法执行成功,返回值仅做标记用于主方法是否执行continue | 
|      */ | 
|     public boolean shuttleOutExecuteStep1(WrkMast wrkMast) { | 
|         //21.生成出库任务 => 22.小车搬运中 | 
|         if (wrkMast.getWrkSts() == 21) { | 
|             EntityWrapper<StaDesc> wrapper = new EntityWrapper<>(); | 
|             wrapper.eq("type_no", wrkMast.getIoType());//路径类型 | 
|             wrapper.eq("stn_no", wrkMast.getStaNo());//出库站点编号 | 
|             StaDesc staDesc = staDescService.selectOne(wrapper); | 
|             if (staDesc == null) { | 
|                 News.info("{}任务,出库路径不存在", wrkMast.getWrkNo()); | 
|                 return false;//出库路径不存在 | 
|             } | 
|   | 
|             //获取出库站点 | 
|             BasDevp basDevp = basDevpService.selectById(wrkMast.getStaNo()); | 
|             if (basDevp == null) { | 
|                 return false;//出库站点不存在 | 
|             } | 
|   | 
| //            if (!basDevp.getAutoing().equals("Y")) { | 
| //                News.info("{}任务,{}站点,不是自动状态",wrkMast.getWrkNo(),basDevp.getDevNo()); | 
| //                return false;//不是自动状态 | 
| //            } | 
| // | 
| //            if (!basDevp.getOutEnable().equals("Y")) { | 
| //                News.info("{}任务,{}站点,没有可出信号", wrkMast.getWrkNo(), basDevp.getDevNo()); | 
| //                return false;//出库站点不可出 | 
| //            } | 
|   | 
|             Integer liftNo = basDevp.getLiftNo();//搜索出库提升机是否存在入库任务,如存在禁止出库 | 
|             List<WrkMast> liftWrkMasts = wrkMastMapper.selectInWrkMastByLiftNo(liftNo); | 
|             if (!liftWrkMasts.isEmpty()) { | 
|                 News.info("{}任务,{}号提升机,存在入库任务,系统禁止出库", wrkMast.getWrkNo(), liftNo); | 
|                 return false;//存在入库任务,禁止出库 | 
|             } | 
|   | 
|             //同库位组校验 | 
|             List<String> outerLoc = Utils.getGroupOuterLoc(wrkMast.getSourceLocNo()); | 
|             List<LocMast> outerLocMasts = locMastService.selectNotEmptyLocNos(outerLoc); | 
|             if (!outerLocMasts.isEmpty()) { | 
|                 News.info("{}任务,浅库位存在货物,系统等待中", wrkMast.getWrkNo()); | 
|                 return false;//浅库位存在未执行任务 | 
|             } | 
|   | 
|             //获取源站 | 
|             LiftStaProtocol liftStaProtocol = NyLiftUtils.getLiftStaByLev(basDevp.getLiftNo(), Utils.getLev(wrkMast.getSourceLocNo())); | 
|             if (liftStaProtocol == null) { | 
|                 return false;//找不到站点 | 
|             } | 
|   | 
|             if (!(liftStaProtocol.getModel() && !liftStaProtocol.getBusy() && !liftStaProtocol.getHasTray())) { | 
|                 News.info("{}任务,{}内部输送站,不满足自动、空闲、无托盘状态", wrkMast.getWrkNo(), liftStaProtocol.getStaNo()); | 
|                 return false;//站点必须自动、空闲、没有托盘 | 
|             } | 
|   | 
|             if (wrkMast.getStaNo() == 300) { | 
|                 //出300站,检测300站任务数量 | 
|                 List<WrkMast> wrkMasts = wrkMastMapper.select300Wrk(); | 
|                 if (wrkMasts.size() >= 20) { | 
|                     News.info("{}任务,输送线任务过载{}", wrkMast.getWrkNo(), wrkMasts.size()); | 
|                     return false; | 
|                 } | 
|             } | 
|   | 
|             if (wrkMast.getShuttleNo() == null) {//没有绑定小车,进行调度 | 
|                 //强制预留一台小车给入库任务 | 
|                 int lev = Utils.getLev(wrkMast.getSourceLocNo()); | 
|                 //获取当前楼层有几台可用小车 | 
|                 int shuttleCount = shuttleDispatchUtils.getShuttleCountByLev(lev); | 
|                 if (shuttleCount >= 2) {//只有可用小车数量大于2,才进行入库任务预留小车 | 
|                     int shuttleWrkInObligateCount = 1;//预留小车数量 | 
|                     Config config = configService.selectOne(new EntityWrapper<Config>().eq("code", "shuttleWrkInObligateCount").eq("status", 1)); | 
|                     if (config != null) { | 
|                         shuttleWrkInObligateCount = Integer.parseInt(config.getValue()); | 
|                     } | 
|                     //可用出库小车数量(给入库任务预留一台车) | 
|                     int useShuttleCount = shuttleCount - shuttleWrkInObligateCount; | 
|                     //查询楼层已分配车辆的出库任务数量 | 
|                     List<WrkMast> wrkMasts = wrkMastService.selectShuttleOutWrkByLev(lev); | 
|                     if (wrkMasts.size() >= useShuttleCount) { | 
|                         News.info("{}任务,当前楼层可用小车{}台,出库任务已分配{}台,系统等待中。", wrkMast.getWrkNo(), useShuttleCount, wrkMasts.size()); | 
|                         return false; | 
|                     } | 
|                 } | 
|                 boolean result = shuttleDispatchUtils.dispatchShuttle(wrkMast.getWrkNo(), wrkMast.getSourceLocNo());//调度小车到货物所在库位进行取货 | 
|                 News.info("{}任务,调度小车{}系统等待中。", wrkMast.getWrkNo(), result ? "成功" : "失败"); | 
|                 return false; | 
|             } | 
|   | 
|             //获取四向穿梭车线程 | 
|             NyShuttleThread shuttleThread = (NyShuttleThread) SlaveConnection.get(SlaveType.Shuttle, wrkMast.getShuttleNo()); | 
|             if (shuttleThread == null) { | 
|                 return false; | 
|             } | 
|             NyShuttleProtocol shuttleProtocol = shuttleThread.getShuttleProtocol(); | 
|             if (shuttleProtocol == null) { | 
|                 return false; | 
|             } | 
|             if (!shuttleProtocol.isIdle()) { | 
|                 News.info("{}任务,{}小车,忙碌中", wrkMast.getWrkNo(), shuttleProtocol.getShuttleNo()); | 
|                 return false; | 
|             } | 
|             //判断小车令牌是否未被占领 | 
|             if (shuttleProtocol.getToken() != 0) { | 
|                 News.info("{}任务,{}小车,令牌已被独占,禁止派发任务", wrkMast.getWrkNo(), shuttleProtocol.getShuttleNo()); | 
|                 return false;//小车已被独占,禁止再派发任务 | 
|             } | 
|   | 
|             //判断小车是否到达货物库位 | 
|             if (!shuttleProtocol.getCurrentLocNo().equals(wrkMast.getSourceLocNo())) { | 
|                 //小车不在输送站点位置 | 
|                 shuttleDispatchUtils.dispatchShuttle(wrkMast.getWrkNo(), wrkMast.getSourceLocNo(), wrkMast.getShuttleNo());//调度小车到货物所在库位进行取货 | 
|                 News.info("{}任务,{}小车,未到达输送站点,系统等待中", wrkMast.getWrkNo(), shuttleProtocol.getShuttleNo()); | 
|                 return false; | 
|             } | 
|   | 
|             //小车已抵达货物位置,进行搬运货物 | 
|             NyShuttleOperaResult result = NyShuttleOperaUtils.getShuttleTransportCommands(wrkMast.getShuttleNo(), wrkMast.getWrkNo(), wrkMast.getSourceLocNo(), liftStaProtocol.getLocNo());//将货物搬运至提升机输送站点 | 
|             if (result == null) {//出库路径计算失败 | 
|                 News.info("{}任务,{}小车,路径计算失败,系统等待中", wrkMast.getWrkNo(), shuttleProtocol.getShuttleNo()); | 
|                 return false; | 
|             } | 
|   | 
|             //创建分配命令 | 
|             ShuttleAssignCommand assignCommand = new ShuttleAssignCommand(); | 
|             assignCommand.setShuttleNo(shuttleProtocol.getShuttleNo());//四向穿梭车号 | 
|             assignCommand.setTaskNo(wrkMast.getWrkNo().shortValue());//任务号 | 
|             assignCommand.setTaskMode(ShuttleTaskModeType.PAK_OUT.id.shortValue());//出库模式 | 
|             assignCommand.setSourceLocNo(shuttleProtocol.getCurrentLocNo());//源库位(小车当前位置) | 
|             assignCommand.setCommands(result.getCommands());//运行命令 | 
|             assignCommand.setNodes(result.getNodes());//路径节点 | 
|   | 
|             wrkMast.setWrkSts(22L);//21.生成出库任务 => 22.小车搬运中 | 
|             wrkMast.setModiTime(new Date()); | 
|             shuttleProtocol.setToken(wrkMast.getWrkNo());//独占小车令牌 | 
|             if (wrkMastMapper.updateById(wrkMast) > 0) { | 
|                 //下发任务 | 
|                 MessageQueue.offer(SlaveType.Shuttle, assignCommand.getShuttleNo().intValue(), new Task(3, assignCommand)); | 
|             } | 
|             return false; | 
|         } | 
|         return true; | 
|     } | 
|   | 
|     /** | 
|      * 四向穿梭车任务完成 | 
|      */ | 
|     public synchronized void shuttleFinished() { | 
|         try { | 
|             for (ShuttleSlave shuttle : slaveProperties.getShuttle()) { | 
|                 //获取四向穿梭车信息 | 
|                 NyShuttleThread shuttleThread = (NyShuttleThread) SlaveConnection.get(SlaveType.Shuttle, shuttle.getId()); | 
|                 NyShuttleProtocol shuttleProtocol = shuttleThread.getShuttleProtocol(); | 
|                 if (shuttleProtocol == null) { | 
|                     continue; | 
|                 } | 
|   | 
|                 //四向穿梭车状态为等待确认、小车处于空闲状态 | 
|                 if (shuttleProtocol.getProtocolStatus() == ShuttleProtocolStatusType.WAITING.id  //任务完成等待确认 | 
|                         && shuttleProtocol.getTaskNo() != 0 | 
|                         && shuttleProtocol.getFree() == ShuttleStatusType.IDLE.id | 
|                 ) { | 
|                     //将任务档标记为完成 | 
|                     WrkMast wrkMast = wrkMastMapper.selectByWorkNo(shuttleProtocol.getTaskNo()); | 
|                     if (wrkMast != null) { | 
|                         switch (wrkMast.getWrkSts().intValue()) { | 
|                             case 5://5.小车搬运中 ==> 9.入库完成 | 
|                                 wrkMast.setWrkSts(9L); | 
|                                 shuttleProtocol.setTaskNo(0); | 
|                                 if (shuttleProtocol.getToken().equals(wrkMast.getWrkNo())) { | 
|                                     //释放小车令牌 | 
|                                     shuttleProtocol.setToken(0); | 
|                                 } | 
|                                 break; | 
|                             case 22://22.小车搬运中 ==> 23.小车搬运完成 | 
|                                 wrkMast.setWrkSts(23L); | 
|                                 shuttleProtocol.setTaskNo(0); | 
|                                 if (shuttleProtocol.getToken().equals(wrkMast.getWrkNo())) { | 
|                                     //释放小车令牌 | 
|                                     shuttleProtocol.setToken(0); | 
|                                 } | 
|                                 break; | 
|                             case 102://102.小车移动至站点 ==> 103.小车移动至站点完成 | 
|                                 wrkMast.setWrkSts(103L); | 
|                                 break; | 
|                             case 104://104.小车迁入提升机中 ==> 105.小车迁入提升机完成 | 
|                                 wrkMast.setWrkSts(105L); | 
|                                 shuttleProtocol.setTaskNo(0);//清理工作号 | 
|                                 break; | 
|                             case 108://108.小车迁出提升机中 ==> 109.小车迁出提升机完成 | 
|                                 wrkMast.setWrkSts(109L); | 
|                                 break; | 
|                             case 110://110.小车移动中 ==> 111.小车移动完成 | 
|                                 wrkMast.setWrkSts(111L); | 
|                                 shuttleProtocol.setTaskNo(0); | 
|                                 if (shuttleProtocol.getToken().equals(wrkMast.getWrkNo())) { | 
|                                     //释放小车令牌 | 
|                                     shuttleProtocol.setToken(0); | 
|                                 } | 
|                                 break; | 
|                             default: | 
|                         } | 
|   | 
|                         if (wrkMastMapper.updateById(wrkMast) > 0) { | 
|                             if (wrkMast.getWrkSts() == 111) { | 
|                                 // 保存工作主档历史档 | 
|                                 if (wrkMastLogMapper.save(wrkMast.getWrkNo()) <= 0) { | 
|                                     log.info("保存工作历史档[workNo={0}]失败", wrkMast.getWrkNo()); | 
|                                 } | 
|                                 // 删除工作主档 | 
|                                 if (!wrkMastService.deleteById(wrkMast)) { | 
|                                     log.info("删除工作主档[workNo={0}]失败", wrkMast.getWrkNo()); | 
|                                 } | 
|                             } | 
|   | 
|                             //设置四向穿梭车为空闲状态 | 
|                             shuttleProtocol.setProtocolStatus(ShuttleProtocolStatusType.IDLE); | 
|                             //源库位清零 | 
|                             shuttleProtocol.setSourceLocNo(null); | 
|                             //目标库位清零 | 
|                             shuttleProtocol.setLocNo(null); | 
|                             //任务指令清零 | 
|                             shuttleProtocol.setAssignCommand(null); | 
|                             News.info("四向穿梭车已确认且任务完成状态,复位。四向穿梭车号={}", shuttleProtocol.getShuttleNo()); | 
|                         } else { | 
|                             News.error("四向穿梭车已确认且任务完成状态,复位失败,但未找到工作档。四向穿梭车号={},工作号={}", shuttleProtocol.getShuttleNo(), shuttleProtocol.getTaskNo()); | 
|                         } | 
|                     } else { | 
|                         ShuttleAssignCommand assignCommand = shuttleProtocol.getAssignCommand(); | 
|                         if (!assignCommand.getAuto()) { | 
|                             //手动模式 | 
|                             //工作号清零 | 
|                             shuttleProtocol.setTaskNo(0); | 
|                             //设置四向穿梭车为空闲状态 | 
|                             shuttleProtocol.setProtocolStatus(ShuttleProtocolStatusType.IDLE); | 
|                             //源库位清零 | 
|                             shuttleProtocol.setSourceLocNo(null); | 
|                             //目标库位清零 | 
|                             shuttleProtocol.setLocNo(null); | 
|                             //任务指令清零 | 
|                             shuttleProtocol.setAssignCommand(null); | 
|                             //清零令牌 | 
|                             shuttleProtocol.setToken(0); | 
|                             News.info("四向穿梭车已确认且任务完成状态,复位。四向穿梭车号={}", shuttleProtocol.getShuttleNo()); | 
|                         } | 
|                     } | 
|   | 
|                 } | 
|   | 
|             } | 
|         } catch (Exception e) { | 
|             e.printStackTrace(); | 
|         } | 
|     } | 
|   | 
|     /** | 
|      * 提升机任务 | 
|      */ | 
|     public synchronized void liftIoExecute() { | 
|         try { | 
|             for (LiftSlave liftSlave : slaveProperties.getLift()) { | 
|                 LiftThread liftThread = (LiftThread) SlaveConnection.get(SlaveType.Lift, liftSlave.getId()); | 
|                 if (liftThread == null) { | 
|                     continue; | 
|                 } | 
|                 LiftProtocol liftProtocol = liftThread.getLiftProtocol(); | 
|                 if (liftProtocol == null) { | 
|                     continue; | 
|                 } | 
|   | 
|                 if (!liftProtocol.isIdle()) { | 
|                     News.info("{}号提升机,忙碌中", liftSlave.getId()); | 
|                     continue; | 
|                 } | 
|   | 
|                 //判断提升机令牌是否被占用 | 
|                 if (liftProtocol.getToken() != 0) { | 
|                     News.info("{}号提升机,令牌已被独占", liftSlave.getId()); | 
|                     continue; | 
|                 } | 
|   | 
|                 //搜索是否有待处理的任务 | 
|                 List<WrkMast> wrkMasts = wrkMastMapper.selectLiftStep223103(); | 
|                 if (wrkMasts.isEmpty()) { | 
|                     continue; | 
|                 } | 
|   | 
|                 for (WrkMast wrkMast : wrkMasts) { | 
|                     //搜索是否有其他任务占用了提升机,如果占用提升机的任务和当前任务相同,则运行执行 | 
|                     WrkMast wrkMast1 = wrkMastMapper.selectLiftWrkMast(liftProtocol.getLiftNo().intValue()); | 
|                     if (wrkMast1 != null && wrkMast1.getWrkNo().intValue() != wrkMast.getWrkNo().intValue()) { | 
|                         News.info("{}号提升机,被其他任务{}占用且和当前任务{}不相同,禁止派发", liftSlave.getId(), wrkMast1.getWrkNo(), wrkMast.getWrkNo()); | 
|                         continue; | 
|                     } | 
|   | 
|                     boolean stepIn = this.liftIoExecuteStepIn(wrkMast);//提升机入库 | 
|                     if (!stepIn) { | 
|                         continue; | 
|                     } | 
|   | 
|                     boolean stepOut = this.liftIoExecuteStepOut(wrkMast);//提升机出库 | 
|                     if (!stepOut) { | 
|                         continue; | 
|                     } | 
|                 } | 
|   | 
|             } | 
|         } catch (Exception e) { | 
|             e.printStackTrace(); | 
|         } | 
|     } | 
|   | 
|     /** | 
|      * 提升机入库 | 
|      * 如需主方法执行continue,请返回false | 
|      * ps:返回值true并不代表该方法执行成功,返回值仅做标记用于主方法是否执行continue | 
|      */ | 
|     private boolean liftIoExecuteStepIn(WrkMast wrkMast) { | 
|         //--------------------------------------提升机入库-----------------------------------------// | 
|         Date now = new Date(); | 
|   | 
|         //2.设备上走 ==> 3.提升机搬运中 | 
|         if (wrkMast.getWrkSts() == 2) { | 
|             //获取源站 | 
|             BasDevp sourceBasDevp = basDevpService.selectById(wrkMast.getSourceStaNo()); | 
|             if (sourceBasDevp == null) { | 
|                 return false;//找不到站点 | 
|             } | 
|   | 
|             if (!sourceBasDevp.getInEnable().equals("Y")) { | 
|                 News.info("{}任务,{}源站,没有可入信号", wrkMast.getWrkNo(), sourceBasDevp.getDevNo()); | 
|                 return false;//站点不可入 | 
|             } | 
|   | 
|             Integer barcodeId = Utils.getBarcodeIdByStaNo(wrkMast.getSourceStaNo()); | 
|             if (barcodeId == null) { | 
|                 News.info("{}任务,{}源站,找不到可用条码器ID", wrkMast.getWrkNo(), sourceBasDevp.getDevNo()); | 
|                 return false;//站点不可入 | 
|             } | 
|   | 
|             BarcodeThread barcodeThread = (BarcodeThread) SlaveConnection.get(SlaveType.Barcode, barcodeId); | 
|             if (barcodeThread == null) { | 
|                 News.info("{}任务,{}源站,条码器{}线程为空", wrkMast.getWrkNo(), sourceBasDevp.getDevNo(), barcodeId); | 
|                 return false;//站点不可入 | 
|             } | 
|             String barcode = barcodeThread.getBarcode(); | 
|             if(!Cools.isEmpty(barcode)) { | 
|                 if(!("NG".endsWith(barcode) || "NoRead".equals(barcode) || "empty".equals(barcode))) { | 
|                     //存在条码值,判断是否和当前工作档一致 | 
|                     if (!barcode.equals(wrkMast.getBarcode())) { | 
|                         News.info("{}任务,{}站点,条码器{}值{}与工作档条码值{}不一致,系统跳过执行", wrkMast.getWrkNo(), sourceBasDevp.getDevNo(), barcodeId, barcode,wrkMast.getBarcode()); | 
|                         return false;//站点不可入 | 
|                     } | 
|                 } | 
|             }else { | 
|                 return false; | 
|             } | 
|   | 
|             //判断提升机整个三楼是否都处于入库模式 | 
|             Integer outInModel1 = Utils.getOutInModelByLift(sourceBasDevp.getLiftNo(), 1); | 
|             Integer outInModel2 = Utils.getOutInModelByLift(sourceBasDevp.getLiftNo(), 5); | 
|             Integer outInModel3 = Utils.getOutInModelByLift(sourceBasDevp.getLiftNo(), 8); | 
|             if (outInModel1 == null || outInModel2 == null || outInModel3 == null) { | 
|                 News.info("{}任务,没有出入库模式", wrkMast.getWrkNo()); | 
|                 return false;//不存在出入库模式 | 
|             } | 
|   | 
|             if (outInModel1 == 2 || outInModel2 == 2 && outInModel3 == 2) { | 
|                 News.info("{}任务,有站点处于出库模式,禁止入库", wrkMast.getWrkNo()); | 
|                 return false;//只要有一个处于出库模式,禁止入库 | 
|             } | 
|   | 
|             LiftThread liftThread = (LiftThread) SlaveConnection.get(SlaveType.Lift, sourceBasDevp.getLiftNo()); | 
|             if (liftThread == null) { | 
|                 return false; | 
|             } | 
|             LiftProtocol liftProtocol = liftThread.getLiftProtocol(); | 
|             if (liftProtocol == null) { | 
|                 return false; | 
|             } | 
|             if (!liftProtocol.isIdle()) { | 
|                 News.info("{}任务,{}号提升机,忙碌中", wrkMast.getWrkNo(), liftProtocol.getLiftNo()); | 
|                 return false; | 
|             } | 
|             //判断提升机令牌是否未被占领 | 
|             if (liftProtocol.getToken() != 0) { | 
|                 News.info("{}任务,{}号提升机,令牌已被独占,禁止派发", wrkMast.getWrkNo(), liftProtocol.getLiftNo()); | 
|                 return false;//提升机已被独占,禁止再派发任务 | 
|             } | 
|   | 
|             //判断提升机内是否有小车 | 
|             if (liftProtocol.getHasCar()) { | 
|                 News.info("{}任务,{}号提升机,提升机内部有小车,禁止派发", wrkMast.getWrkNo(), liftProtocol.getLiftNo()); | 
|                 return false;//有小车,禁止派发 | 
|             } | 
|   | 
|             //判断提升机内是否有托盘 | 
|             if (liftProtocol.getHasTray()) { | 
|                 News.info("{}任务,{}号提升机,提升机内部有托盘,禁止派发", wrkMast.getWrkNo(), liftProtocol.getLiftNo()); | 
|                 return false;//有托盘,禁止派发 | 
|             } | 
|   | 
|             //判断提升机是否有其他任务 | 
|             WrkMast liftWrkMast = wrkMastMapper.selectLiftWrkMast(liftThread.getSlave().getId()); | 
|             if (liftWrkMast != null) { | 
|                 News.info("{}任务,{}号提升机,当前提升机存在未完成任务,禁止派发", wrkMast.getWrkNo(), liftProtocol.getLiftNo()); | 
|                 return false;//当前提升机存在未完成任务,等待下一次轮询 | 
|             } | 
|   | 
|             //获取源站对应的牛眼提升机站点编号(起点编号) | 
|             Integer startSta = Integer.parseInt(sourceBasDevp.getQrCodeValue()); | 
|             //获取提升机站点 | 
|             LiftStaProtocol targetStaProtocol = NyLiftUtils.getLiftStaByLev(liftThread.getSlave().getId(), Utils.getLev(wrkMast.getLocNo())); | 
|             if (targetStaProtocol == null) { | 
|                 return false;//站点不存在 | 
|             } | 
|   | 
|             if (targetStaProtocol.getHasTray()) { | 
|                 News.info("{}任务,{}号提升机,{}站点,提升机站点有托盘,禁止派发", wrkMast.getWrkNo(), liftProtocol.getLiftNo(), targetStaProtocol.getStaNo()); | 
|                 return false;//提升机站点有托盘,禁止派发 | 
|             } | 
|   | 
|             Integer targetSta = targetStaProtocol.getStaNo(); | 
|   | 
|             //获取提升机命令 | 
|             NyLiftCommand liftCommand = NyLiftUtils.getLiftCommand(liftProtocol.getLiftNo().intValue(), NyLiftTaskModelType.MOVE_TRAY.id, startSta, targetSta, wrkMast.getWrkNo()); | 
|             if (wrkMast.getIoType() == 53 || wrkMast.getIoType() == 57) { | 
|                 //拣料再回库,重新分配设备工作号 | 
|                 int deviceWrk = commonService.getWorkNo(8);//生成提升机设备工作号 | 
|                 BasLiftOpt basLiftOpt = basLiftOptService.selectByDeviceWrk(String.valueOf(deviceWrk), liftThread.getSlave().getId()); | 
|                 if (basLiftOpt != null) { | 
|                     News.info("{}任务,{}号提升机,设备工作号出现重复情况,请联系技术人员支持。", wrkMast.getWrkNo(), liftProtocol.getLiftNo()); | 
|                     return false; | 
|                 } | 
|                 liftCommand.setTaskNo((short) deviceWrk); | 
|             } | 
|             ArrayList<NyLiftCommand> commands = new ArrayList<>(); | 
|             commands.add(liftCommand); | 
|   | 
|             //提交到线程去工作 | 
|             LiftAssignCommand assignCommand = new LiftAssignCommand(); | 
|             assignCommand.setCommands(commands); | 
|             assignCommand.setLiftNo(liftProtocol.getLiftNo()); | 
|             assignCommand.setTaskNo(wrkMast.getWrkNo().shortValue()); | 
|             assignCommand.setTaskMode(NyLiftTaskModelType.MOVE_TRAY.id.shortValue()); | 
|   | 
|             wrkMast.setWrkSts(3L);//2.设备上走 ==> 3.提升机搬运中 | 
|             wrkMast.setLiftNo(liftThread.getSlave().getId());//任务档绑定提升机号 | 
|             wrkMast.setModiTime(now); | 
|             liftProtocol.setToken(wrkMast.getWrkNo());//独占提升机令牌 | 
|             if (wrkMastMapper.updateById(wrkMast) > 0) { | 
|                 //下发任务 | 
|                 MessageQueue.offer(SlaveType.Lift, liftProtocol.getLiftNo().intValue(), new Task(3, assignCommand)); | 
|             } | 
|   | 
|             return false; | 
|         } | 
|         return true; | 
|     } | 
|   | 
|     /** | 
|      * 提升机出库 | 
|      * 如需主方法执行continue,请返回false | 
|      * ps:返回值true并不代表该方法执行成功,返回值仅做标记用于主方法是否执行continue | 
|      */ | 
|     private boolean liftIoExecuteStepOut(WrkMast wrkMast) { | 
|         //--------------------------------------提升机出库-----------------------------------------// | 
|         Date now = new Date(); | 
|   | 
|         //23.小车搬运完成 ==> 24.提升机搬运中 | 
|         if (wrkMast.getWrkSts() == 23) { | 
|             NyShuttleThread shuttleThread = (NyShuttleThread) SlaveConnection.get(SlaveType.Shuttle, wrkMast.getShuttleNo()); | 
|             if (shuttleThread == null) { | 
|                 return false; | 
|             } | 
|   | 
|             //获取出库站点(目标站) | 
|             BasDevp basDevp = basDevpService.selectById(wrkMast.getStaNo()); | 
|             if (basDevp == null) { | 
|                 News.info("{}任务,出库站点不存在,禁止派发", wrkMast.getWrkNo()); | 
|                 return false;//出库站点不存在 | 
|             } | 
|   | 
|             //获取源站对应的牛眼提升机站点编号(起点编号) | 
|             LiftStaProtocol liftStaProtocol = NyLiftUtils.getLiftStaByLev(basDevp.getLiftNo(), Utils.getLev(wrkMast.getSourceLocNo())); | 
|             if (liftStaProtocol == null) { | 
|                 News.info("{}任务,找不到站点,禁止派发", wrkMast.getWrkNo()); | 
|                 return false;//找不到站点 | 
|             } | 
|             Integer startSta = liftStaProtocol.getStaNo(); | 
|   | 
|             NyShuttleProtocol shuttleProtocol = shuttleThread.getShuttleProtocol(); | 
|             if (shuttleProtocol.getCurrentLocNo().equals(liftStaProtocol.getLocNo())) { | 
|                 //小车还在输送站点 | 
|                 //调度小车避让 | 
|                 boolean result = Utils.searchEmptyGroupToMoveShuttle(Utils.getLev(wrkMast.getSourceLocNo()), wrkMast.getShuttleNo(), shuttleThread); | 
|                 if (!result) { | 
|                     News.info("{}任务,{}小车,小车在输送站点调度小车避让失败", wrkMast.getWrkNo(), shuttleProtocol.getShuttleNo()); | 
|                     return false; | 
|                 } | 
|             } | 
|   | 
|             if (!basDevp.getAutoing().equals("Y")) { | 
|                 News.info("{}任务,{}站点,没有自动信号,禁止派发", wrkMast.getWrkNo(), basDevp.getDevNo()); | 
|                 return false;//出库站点不可出 | 
|             } | 
|   | 
|             if (basDevp.getLoading().equals("Y")) { | 
|                 News.info("{}任务,{}站点,存在有物信号,禁止派发", wrkMast.getWrkNo(), basDevp.getDevNo()); | 
|                 return false;//出库站点不可出 | 
|             } | 
|   | 
|             if (!basDevp.getOutEnable().equals("Y")) { | 
|                 News.info("{}任务,{}站点,没有可出信号,禁止派发", wrkMast.getWrkNo(), basDevp.getDevNo()); | 
|                 return false;//出库站点不可出 | 
|             } | 
|   | 
|             LiftThread liftThread = (LiftThread) SlaveConnection.get(SlaveType.Lift, basDevp.getLiftNo()); | 
|             if (liftThread == null) { | 
|                 return false; | 
|             } | 
|             LiftProtocol liftProtocol = liftThread.getLiftProtocol(); | 
|             if (liftProtocol == null) { | 
|                 return false; | 
|             } | 
|   | 
|             if (!liftProtocol.isIdle()) { | 
|                 News.info("{}任务,{}号提升机,忙碌中", wrkMast.getWrkNo(), liftProtocol.getLiftNo()); | 
|                 return false; | 
|             } | 
|             //判断提升机令牌是否未被占领 | 
|             if (liftProtocol.getToken() != 0) { | 
|                 News.info("{}任务,{}号提升机,令牌已被独占,禁止派发", wrkMast.getWrkNo(), liftProtocol.getLiftNo()); | 
|                 return false;//提升机已被独占,禁止再派发任务 | 
|             } | 
|             //判断提升机是否有其他任务 | 
|             WrkMast liftWrkMast = wrkMastMapper.selectLiftWrkMast(liftThread.getSlave().getId()); | 
|             if (liftWrkMast != null) { | 
|                 News.info("{}任务,{}号提升机,当前提升机存在未完成任务,禁止派发", wrkMast.getWrkNo(), liftProtocol.getLiftNo()); | 
|                 return false;//当前提升机存在未完成任务,等待下一次轮询 | 
|             } | 
|   | 
|             //获目标站源站对应的输送站点 | 
|             BasDevp targetBasDevp = basDevpService.selectById(wrkMast.getStaNo()); | 
|             if (targetBasDevp == null) { | 
|                 News.info("{}任务,{}站点,站点不存在,禁止派发", wrkMast.getWrkNo(), wrkMast.getStaNo()); | 
|                 return false;//站点不存在 | 
|             } | 
|             //获取牛眼提升机站点编号(目标编号) | 
|             Integer targetSta = Integer.parseInt(targetBasDevp.getQrCodeValue()); | 
|   | 
|             //获取提升机命令 | 
|             NyLiftCommand liftCommand = NyLiftUtils.getLiftCommand(liftThread.getSlave().getId(), NyLiftTaskModelType.MOVE_TRAY.id, startSta, targetSta, wrkMast.getWrkNo()); | 
|   | 
|             ArrayList<NyLiftCommand> commands = new ArrayList<>(); | 
|             commands.add(liftCommand); | 
|   | 
|             //提交到线程去工作 | 
|             LiftAssignCommand assignCommand = new LiftAssignCommand(); | 
|             assignCommand.setCommands(commands); | 
|             assignCommand.setLiftNo(liftProtocol.getLiftNo()); | 
|             assignCommand.setTaskNo(wrkMast.getWrkNo().shortValue()); | 
|             assignCommand.setTaskMode(NyLiftTaskModelType.MOVE_TRAY.id.shortValue()); | 
|   | 
|             wrkMast.setWrkSts(24L);//23.小车搬运完成 ==> 24.提升机搬运中 | 
|             wrkMast.setLiftNo(liftThread.getSlave().getId());//任务档绑定提升机号 | 
|             wrkMast.setModiTime(now); | 
|             liftProtocol.setToken(wrkMast.getWrkNo());//独占提升机令牌 | 
|             if (wrkMastMapper.updateById(wrkMast) > 0) { | 
|                 //下发任务 | 
|                 MessageQueue.offer(SlaveType.Lift, liftProtocol.getLiftNo().intValue(), new Task(3, assignCommand)); | 
|             } | 
|   | 
|             return false; | 
|         } | 
|         return true; | 
|     } | 
|   | 
|     /** | 
|      * 提升机任务完成 | 
|      */ | 
|     public synchronized void liftFinished() { | 
|         try { | 
|             for (LiftSlave liftSlave : slaveProperties.getLift()) { | 
|                 //获取提升机信息 | 
|                 LiftThread liftThread = (LiftThread) SlaveConnection.get(SlaveType.Lift, liftSlave.getId()); | 
|                 LiftProtocol liftProtocol = liftThread.getLiftProtocol(); | 
|                 if (liftProtocol == null) { | 
|                     continue; | 
|                 } | 
|   | 
|                 //提升机为等待确认且空闲 | 
|                 if (liftProtocol.getProtocolStatus() == LiftProtocolStatusType.WAITING.id | 
|                         && liftProtocol.getTaskNo() != 0 | 
|                         && !liftProtocol.getBusy() | 
|                 ) { | 
|                     int taskNo = liftProtocol.getTaskNo().intValue(); | 
|                     if (taskNo >= 20000 && taskNo <= 30000) { | 
|                         //提升机设备工作号,需要查询对应任务号 | 
|                         BasLiftOpt basLiftOpt = basLiftOptService.selectByDeviceWrk(liftProtocol.getTaskNo().toString(), liftSlave.getId()); | 
|                         if (basLiftOpt != null) { | 
|                             taskNo = basLiftOpt.getWrkNo(); | 
|                         } | 
|                     } | 
|   | 
|                     //将任务档标记为完成 | 
|                     WrkMast wrkMast = wrkMastMapper.selectByWorkNo324104(taskNo); | 
|                     if (wrkMast != null) { | 
|                         switch (wrkMast.getWrkSts().intValue()) { | 
|                             case 3://3.提升机搬运中 ==> 4.提升机搬运完成 | 
|                                 wrkMast.setWrkSts(4L); | 
|                                 wrkMast.setLiftNo(null);//释放提升机 | 
|                                 if (liftProtocol.getToken().equals(wrkMast.getWrkNo())) { | 
|                                     //释放提升机令牌 | 
|                                     liftProtocol.setToken(0); | 
|                                 } | 
|                                 break; | 
|                             case 24://24.提升机搬运中 ==> 25.提升机搬运完成 | 
|                                 wrkMast.setWrkSts(25L); | 
|                                 if (wrkMast.getIoType() == 11) {//库位移转 | 
|                                     wrkMast.setWrkSts(4L);//4.提升机搬运完成 | 
|                                 } else { | 
|                                     if (wrkMast.getMk() == null || !wrkMast.getMk().equals("Y")) { | 
|                                         //不需要用到机械臂,直接转29.出库完成 | 
|                                         wrkMast.setWrkSts(29L); | 
|                                         wrkMast.setShuttleNo(null);//释放小车 | 
|                                         wrkMast.setLiftNo(null);//释放提升机 | 
|                                         wrkMast.setModiTime(new Date()); | 
|                                     } | 
|                                 } | 
|   | 
|                                 if (liftProtocol.getToken().equals(wrkMast.getWrkNo())) { | 
|                                     //释放提升机令牌 | 
|                                     liftProtocol.setToken(0); | 
|                                 } | 
|   | 
|                                 break; | 
|                             case 106://106.提升机搬运中 ==> 107.提升机搬运完成 | 
|                                 wrkMast.setWrkSts(107L); | 
|                                 break; | 
|                             default: | 
|                         } | 
|   | 
|                         if (wrkMastMapper.updateById(wrkMast) > 0) { | 
|                             //设置提升机为空闲状态 | 
|                             liftProtocol.setProtocolStatus(LiftProtocolStatusType.IDLE); | 
|                             //任务指令清零 | 
|                             liftProtocol.setAssignCommand(null); | 
|                             News.info("提升机已确认且任务完成状态。提升机号={}", liftProtocol.getLiftNo()); | 
|                         } else { | 
|                             News.error("提升机已确认且任务完成状态,复位失败,但未找到工作档。提升机号={},工作号={}", liftProtocol.getLiftNo(), liftProtocol.getTaskNo()); | 
|                         } | 
|                     } else { | 
|                         LiftAssignCommand assignCommand = liftProtocol.getAssignCommand(); | 
|                         if (assignCommand != null) { | 
|                             if (!assignCommand.getAuto()) { | 
|                                 //手动操作 | 
|                                 //设置提升机为空闲状态 | 
|                                 liftProtocol.setProtocolStatus(LiftProtocolStatusType.IDLE); | 
|                                 //任务指令清零 | 
|                                 liftProtocol.setAssignCommand(null); | 
|                                 News.info("提升机已确认手动操作。提升机号={}", liftProtocol.getLiftNo()); | 
|                             } | 
|                         } | 
|                     } | 
|                 } | 
|             } | 
|         } catch (Exception e) { | 
|             e.printStackTrace(); | 
|         } | 
|     } | 
|   | 
|     /** | 
|      * 库位移转 | 
|      */ | 
|     public synchronized void locToLocExecute() { | 
|         try { | 
|             //获取出入库工作档 | 
| //        List<WrkMast> wrkMasts = wrkMastMapper.selectInOutWrkMast(); | 
| //        if (wrkMasts.size() > 0) { | 
| //            //有出入库任务,必须等待任务执行完毕再执行库位移转 | 
| //            return; | 
| //        } | 
|   | 
|             //查询库位移转工作档 | 
|             List<WrkMast> wrkMasts1 = wrkMastMapper.selectLocToLocWrkMast(); | 
|             for (WrkMast wrkMast : wrkMasts1) { | 
|                 if (Utils.getLev(wrkMast.getSourceLocNo()) == Utils.getLev(wrkMast.getLocNo())) { | 
|                     boolean step1 = this.locToLocExecuteStep1(wrkMast);//同楼层库位移转 | 
|                     if (!step1) { | 
|                         continue; | 
|                     } | 
|                 } else { | 
|                     //跨楼层库位移转 | 
|                     boolean step2 = this.locToLocExecuteStep2(wrkMast);//调度车辆取货并运送到出库口 | 
|                     if (!step2) { | 
|                         continue; | 
|                     } | 
|   | 
|                     boolean step3 = this.locToLocExecuteStep3(wrkMast);//提升机搬运货物 | 
|                     if (!step3) { | 
|                         continue; | 
|                     } | 
|   | 
|                     boolean step4 = this.locToLocExecuteStep4(wrkMast);//调度车辆取货并运送到目标库位 | 
|                     if (!step4) { | 
|                         continue; | 
|                     } | 
|   | 
|                 } | 
|   | 
|             } | 
|         } catch (Exception e) { | 
|             e.printStackTrace(); | 
|         } | 
|     } | 
|   | 
|     /** | 
|      * 同楼层库位移转 | 
|      * 如需主方法执行continue,请返回false | 
|      * ps:返回值true并不代表该方法执行成功,返回值仅做标记用于主方法是否执行continue | 
|      */ | 
|     private boolean locToLocExecuteStep1(WrkMast wrkMast) { | 
|         if (wrkMast.getWrkSts() == 21) {//21.生成出库任务 | 
|             if (wrkMast.getShuttleNo() == null) { | 
|                 shuttleDispatchUtils.dispatchShuttle(wrkMast.getWrkNo(), wrkMast.getSourceLocNo());//调度小车到源库位进行取货 | 
|                 return false; | 
|             } | 
|   | 
|             //获取四向穿梭车线程 | 
|             NyShuttleThread shuttleThread = (NyShuttleThread) SlaveConnection.get(SlaveType.Shuttle, wrkMast.getShuttleNo()); | 
|             if (shuttleThread == null) { | 
|                 return false; | 
|             } | 
|             NyShuttleProtocol shuttleProtocol = shuttleThread.getShuttleProtocol(); | 
|             if (shuttleProtocol == null) { | 
|                 return false; | 
|             } | 
|             if (!shuttleProtocol.isIdle()) { | 
|                 return false; | 
|             } | 
|   | 
|             //判断小车是否到达源库位 | 
|             if (!shuttleProtocol.getCurrentLocNo().equals(wrkMast.getSourceLocNo())) { | 
|                 //小车不在源库位位置 | 
|                 shuttleDispatchUtils.dispatchShuttle(wrkMast.getWrkNo(), wrkMast.getSourceLocNo(), wrkMast.getShuttleNo());//调度小车到源库位进行取货 | 
|                 return false; | 
|             } | 
|   | 
|             //小车已抵达源库位,进行搬运货物 | 
|             NyShuttleOperaResult result = NyShuttleOperaUtils.getShuttleTransportCommands(wrkMast.getShuttleNo(), wrkMast.getWrkNo(), wrkMast.getSourceLocNo(), wrkMast.getLocNo()); | 
|             if (result == null) {//路径计算失败 | 
|                 return false; | 
|             } | 
|   | 
|             //创建分配命令 | 
|             ShuttleAssignCommand assignCommand = new ShuttleAssignCommand(); | 
|             assignCommand.setShuttleNo(shuttleProtocol.getShuttleNo());//四向穿梭车号 | 
|             assignCommand.setTaskNo(wrkMast.getWrkNo().shortValue());//任务号 | 
|             assignCommand.setTaskMode(ShuttleTaskModeType.PAK_IN.id.shortValue());//入库模式 | 
|             assignCommand.setSourceLocNo(shuttleProtocol.getCurrentLocNo());//源库位(小车当前位置) | 
|             assignCommand.setCommands(result.getCommands());//运行命令 | 
|             assignCommand.setNodes(result.getNodes());//路径节点 | 
|   | 
|             wrkMast.setWrkSts(5L);//21.生成出库任务 => 5.小车搬运中 | 
|             wrkMast.setModiTime(new Date()); | 
|             if (wrkMastMapper.updateById(wrkMast) > 0) { | 
|                 //下发任务 | 
|                 MessageQueue.offer(SlaveType.Shuttle, assignCommand.getShuttleNo().intValue(), new Task(3, assignCommand)); | 
|             } | 
|   | 
|             return false; | 
|         } | 
|         return true; | 
|     } | 
|   | 
|     /** | 
|      * 跨楼层库位移转-调度车辆取货并运送到出库口 | 
|      * 如需主方法执行continue,请返回false | 
|      * ps:返回值true并不代表该方法执行成功,返回值仅做标记用于主方法是否执行continue | 
|      */ | 
|     private boolean locToLocExecuteStep2(WrkMast wrkMast) { | 
|         if (wrkMast.getWrkSts() == 21) {//21.生成出库任务 | 
|             if (wrkMast.getShuttleNo() == null) { | 
|                 shuttleDispatchUtils.dispatchShuttle(wrkMast.getWrkNo(), wrkMast.getSourceLocNo());//调度小车到源库位进行取货 | 
|                 return false; | 
|             } | 
|   | 
|             //获取四向穿梭车线程 | 
|             NyShuttleThread shuttleThread = (NyShuttleThread) SlaveConnection.get(SlaveType.Shuttle, wrkMast.getShuttleNo()); | 
|             if (shuttleThread == null) { | 
|                 return false; | 
|             } | 
|             NyShuttleProtocol shuttleProtocol = shuttleThread.getShuttleProtocol(); | 
|             if (shuttleProtocol == null) { | 
|                 return false; | 
|             } | 
|             if (!shuttleProtocol.isIdle()) { | 
|                 return false; | 
|             } | 
|   | 
|             //判断小车是否到达源库位 | 
|             if (!shuttleProtocol.getCurrentLocNo().equals(wrkMast.getSourceLocNo())) { | 
|                 //小车不在源库位位置 | 
|                 shuttleDispatchUtils.dispatchShuttle(wrkMast.getWrkNo(), wrkMast.getSourceLocNo(), wrkMast.getShuttleNo());//调度小车到源库位进行取货 | 
|                 return false; | 
|             } | 
|   | 
|             //获取穿梭车最近且空闲的提升机输送站点 | 
|             LiftStaProtocol liftSta = shuttleDispatchUtils.getRecentLiftSta(shuttleThread.getSlave().getId(), Utils.getLev(wrkMast.getLocNo())); | 
|             if (liftSta == null) { | 
|                 return false;//没有可用且空闲的输送站点 | 
|             } | 
|             //源站 | 
|             Integer sourceStaNo = liftSta.getStaNo(); | 
|             //提升机号*100+目标楼层=目标站点 | 
|             Integer staNo = liftSta.getLiftNo() * 100 + Utils.getLev(wrkMast.getLocNo());//目标站 | 
|   | 
|             //小车已抵达源库位,将货物搬运到输送站点 | 
|             NyShuttleOperaResult result = NyShuttleOperaUtils.getShuttleTransportCommands(wrkMast.getShuttleNo(), wrkMast.getWrkNo(), wrkMast.getSourceLocNo(), liftSta.getLocNo()); | 
|             if (result == null) {//路径计算失败 | 
|                 return false; | 
|             } | 
|   | 
|             //创建分配命令 | 
|             ShuttleAssignCommand assignCommand = new ShuttleAssignCommand(); | 
|             assignCommand.setShuttleNo(shuttleProtocol.getShuttleNo());//四向穿梭车号 | 
|             assignCommand.setTaskNo(wrkMast.getWrkNo().shortValue());//任务号 | 
|             assignCommand.setTaskMode(ShuttleTaskModeType.SHUTTLE_LOC_TO_LOC.id.shortValue());//库位移转模式 | 
|             assignCommand.setSourceLocNo(shuttleProtocol.getCurrentLocNo());//源库位(小车当前位置) | 
|             assignCommand.setCommands(result.getCommands());//运行命令 | 
|             assignCommand.setNodes(result.getNodes());//路径节点 | 
|   | 
|             wrkMast.setWrkSts(22L);//21.生成出库任务 => 22.小车搬运中 | 
|             wrkMast.setSourceStaNo(sourceStaNo);//源站 | 
|             wrkMast.setStaNo(staNo);//目标站 | 
|             wrkMast.setModiTime(new Date()); | 
|             if (wrkMastMapper.updateById(wrkMast) > 0) { | 
|                 //下发任务 | 
|                 MessageQueue.offer(SlaveType.Shuttle, assignCommand.getShuttleNo().intValue(), new Task(3, assignCommand)); | 
|             } | 
|   | 
|             return false; | 
|         } | 
|         return true; | 
|     } | 
|   | 
|     /** | 
|      * 跨楼层库位移转-提升机搬运货物 | 
|      * 如需主方法执行continue,请返回false | 
|      * ps:返回值true并不代表该方法执行成功,返回值仅做标记用于主方法是否执行continue | 
|      */ | 
|     private boolean locToLocExecuteStep3(WrkMast wrkMast) { | 
|         Date now = new Date(); | 
|         if (wrkMast.getWrkSts() == 23) {//23.小车搬运完成 | 
|             //源站 | 
|             Integer sourceStaNo = wrkMast.getSourceStaNo(); | 
|             //目标站 | 
|             Integer staNo = wrkMast.getStaNo(); | 
|             if (sourceStaNo == null || staNo == null) { | 
|                 return false;//源站或目标站为空 | 
|             } | 
|   | 
|             int liftNo = staNo / 100;//获取提升机号 | 
|   | 
|             //获取提升机线程 | 
|             LiftThread liftThread = (LiftThread) SlaveConnection.get(SlaveType.Lift, liftNo); | 
|             if (liftThread == null) { | 
|                 return false; | 
|             } | 
|             LiftProtocol liftProtocol = liftThread.getLiftProtocol(); | 
|             if (liftProtocol == null) { | 
|                 return false; | 
|             } | 
|   | 
|             //获取源站对应的输送站点 | 
|             LiftStaProtocol liftStaProtocol = NyLiftUtils.getLiftStaByLev(liftNo, Utils.getLev(wrkMast.getSourceLocNo())); | 
|             if (liftStaProtocol == null) { | 
|                 return false;//找不到站点 | 
|             } | 
|   | 
|             if (!(liftStaProtocol.getModel() && !liftStaProtocol.getBusy() && liftStaProtocol.getHasTray())) { | 
|                 return false;//站点必须自动、空闲、有托盘 | 
|             } | 
|             NyShuttleThread shuttleThread = (NyShuttleThread) SlaveConnection.get(SlaveType.Shuttle, wrkMast.getShuttleNo()); | 
|             if (shuttleThread == null) { | 
|                 return false; | 
|             } | 
|             NyShuttleProtocol shuttleProtocol = shuttleThread.getShuttleProtocol(); | 
|             if (shuttleProtocol.getCurrentLocNo().equals(liftStaProtocol.getLocNo())) { | 
|                 //小车还在输送站点 | 
|                 //调度小车避让 | 
|                 boolean result = Utils.searchEmptyGroupToMoveShuttle(Utils.getLev(wrkMast.getSourceLocNo()), wrkMast.getShuttleNo(), shuttleThread); | 
|                 if (!result) { | 
|                     return false; | 
|                 } | 
|             } | 
|   | 
|             if (!liftProtocol.isIdle()) { | 
|                 return false; | 
|             } | 
|   | 
|             //搜索是否有其他任务占用了提升机,如果占用提升机的任务和当前任务相同,则运行执行 | 
|             WrkMast wrkMast1 = wrkMastMapper.selectLiftWrkMast(liftProtocol.getLiftNo().intValue()); | 
|             if (wrkMast1 != null && wrkMast1.getWrkNo().intValue() != wrkMast.getWrkNo().intValue()) { | 
|                 return false; | 
|             } | 
|   | 
|             //获取提升机命令 | 
|             NyLiftCommand liftCommand = NyLiftUtils.getLiftCommand(liftProtocol.getLiftNo().intValue(), NyLiftTaskModelType.MOVE_TRAY.id, sourceStaNo, staNo, wrkMast.getWrkNo()); | 
|   | 
|             ArrayList<NyLiftCommand> commands = new ArrayList<>(); | 
|             commands.add(liftCommand); | 
|   | 
|             //提交到线程去工作 | 
|             LiftAssignCommand assignCommand = new LiftAssignCommand(); | 
|             assignCommand.setCommands(commands); | 
|             assignCommand.setLiftNo(liftProtocol.getLiftNo()); | 
|             assignCommand.setTaskNo(wrkMast.getWrkNo().shortValue()); | 
|             assignCommand.setTaskMode(NyLiftTaskModelType.MOVE_TRAY.id.shortValue()); | 
|   | 
|             wrkMast.setWrkSts(24L);//23.小车搬运完成 ==> 24.提升机搬运中 | 
|             wrkMast.setLiftNo(liftThread.getSlave().getId());//任务档绑定提升机号 | 
|             wrkMast.setShuttleNo(null);//清空小车号,等货物搬运完成后,到目标楼层重新搜索小车 | 
|             wrkMast.setModiTime(now); | 
|             if (wrkMastMapper.updateById(wrkMast) > 0) { | 
|                 //下发任务 | 
|                 MessageQueue.offer(SlaveType.Lift, liftProtocol.getLiftNo().intValue(), new Task(3, assignCommand)); | 
|             } | 
|             return false; | 
|         } | 
|         return true; | 
|     } | 
|   | 
|     /** | 
|      * 跨楼层库位移转-调度车辆取货并运送到目标库位 | 
|      * 如需主方法执行continue,请返回false | 
|      * ps:返回值true并不代表该方法执行成功,返回值仅做标记用于主方法是否执行continue | 
|      */ | 
|     private boolean locToLocExecuteStep4(WrkMast wrkMast) { | 
|         if (wrkMast.getWrkSts() == 4) {//4.提升机搬运完成 | 
|             //获取目标站对应的输送站点 | 
|             LiftStaProtocol liftStaProtocol = NyLiftUtils.getLiftStaByLev(wrkMast.getLiftNo(), Utils.getLev(wrkMast.getLocNo())); | 
|             if (liftStaProtocol == null) { | 
|                 return false;//找不到站点 | 
|             } | 
|   | 
|             if (!(liftStaProtocol.getModel() && !liftStaProtocol.getBusy() && liftStaProtocol.getHasTray())) { | 
|                 return false;//站点必须自动、空闲、有托盘 | 
|             } | 
|   | 
|             if (wrkMast.getShuttleNo() == null) { | 
|                 shuttleDispatchUtils.dispatchShuttle(wrkMast.getWrkNo(), liftStaProtocol.getLocNo());//调度小车到目标输送站点进行取货 | 
|                 return false; | 
|             } | 
|   | 
|             //获取四向穿梭车线程 | 
|             NyShuttleThread shuttleThread = (NyShuttleThread) SlaveConnection.get(SlaveType.Shuttle, wrkMast.getShuttleNo()); | 
|             if (shuttleThread == null) { | 
|                 return false; | 
|             } | 
|             NyShuttleProtocol shuttleProtocol = shuttleThread.getShuttleProtocol(); | 
|             if (shuttleProtocol == null) { | 
|                 return false; | 
|             } | 
|             if (!shuttleProtocol.isIdle()) { | 
|                 return false; | 
|             } | 
|   | 
|             //判断小车是否到达目标输送站点 | 
|             if (!shuttleProtocol.getCurrentLocNo().equals(liftStaProtocol.getLocNo())) { | 
|                 //小车不在目标输送站点 | 
|                 shuttleDispatchUtils.dispatchShuttle(wrkMast.getWrkNo(), liftStaProtocol.getLocNo(), wrkMast.getShuttleNo());//调度小车到目标输送站点进行取货 | 
|                 return false; | 
|             } | 
|   | 
|             //小车已抵达目标输送站点,将货物搬运到目标库位 | 
|             NyShuttleOperaResult result = NyShuttleOperaUtils.getShuttleTransportCommands(wrkMast.getShuttleNo(), wrkMast.getWrkNo(), liftStaProtocol.getLocNo(), wrkMast.getLocNo()); | 
|             if (result == null) {//路径计算失败 | 
|                 return false; | 
|             } | 
|   | 
|             //创建分配命令 | 
|             ShuttleAssignCommand assignCommand = new ShuttleAssignCommand(); | 
|             assignCommand.setShuttleNo(shuttleProtocol.getShuttleNo());//四向穿梭车号 | 
|             assignCommand.setTaskNo(wrkMast.getWrkNo().shortValue());//任务号 | 
|             assignCommand.setTaskMode(ShuttleTaskModeType.SHUTTLE_LOC_TO_LOC.id.shortValue());//库位移转模式 | 
|             assignCommand.setSourceLocNo(shuttleProtocol.getCurrentLocNo());//源库位(小车当前位置) | 
|             assignCommand.setCommands(result.getCommands());//运行命令 | 
|             assignCommand.setNodes(result.getNodes());//路径节点 | 
|   | 
|             wrkMast.setWrkSts(5L);//4.提升机搬运完成 => 5.小车搬运中 | 
|             wrkMast.setLiftNo(null);//释放提升机 | 
|             wrkMast.setModiTime(new Date()); | 
|             if (wrkMastMapper.updateById(wrkMast) > 0) { | 
|                 //下发任务 | 
|                 MessageQueue.offer(SlaveType.Shuttle, assignCommand.getShuttleNo().intValue(), new Task(3, assignCommand)); | 
|             } | 
|   | 
|             return false; | 
|         } | 
|         return true; | 
|     } | 
|   | 
|     /** | 
|      * 异常信息记录 | 
|      */ | 
|     public void recErr() { | 
|         try { | 
|             this.recShuttleErr(); | 
|             this.recLiftErr(); | 
|         } catch (Exception e) { | 
|             News.error("recErr fail", e); | 
|         } | 
|     } | 
|   | 
|     /** | 
|      * 四向穿梭车异常信息记录 | 
|      */ | 
|     private void recShuttleErr() { | 
|         Date now = new Date(); | 
|         for (ShuttleSlave shuttleSlave : slaveProperties.getShuttle()) { | 
|             // 获取四向穿梭车信息 | 
|             NyShuttleThread shuttleThread = (NyShuttleThread) SlaveConnection.get(SlaveType.Shuttle, shuttleSlave.getId()); | 
|             if (shuttleThread == null) { | 
|                 continue; | 
|             } | 
|             NyShuttleProtocol shuttleProtocol = shuttleThread.getShuttleProtocol(); | 
|             if (shuttleProtocol == null) { | 
|                 continue; | 
|             } | 
|   | 
|             if (shuttleProtocol.getTaskNo() != 0) { | 
|                 //有任务 | 
|                 BasShuttleErrLog latest = basShuttleErrLogService.findLatestByTaskNo(shuttleSlave.getId(), shuttleProtocol.getTaskNo()); | 
|                 // 有异常 | 
|                 if (latest == null) { | 
|                     if (shuttleProtocol.getErrState() != null && shuttleProtocol.getErrState() == 1) { | 
|                         WrkMast wrkMast = wrkMastMapper.selectById(shuttleProtocol.getTaskNo()); | 
|                         if (wrkMast == null) { | 
|                             continue; | 
|                         } | 
|                         BasShuttleErr basShuttleErr = basShuttleErrService.queryByCode(shuttleProtocol.getErrCode()); | 
|                         String errName = basShuttleErr==null? "未知异常":basShuttleErr.getErrName(); | 
|                         BasShuttleErrLog basShuttleErrLog = new BasShuttleErrLog( | 
|                                 null,    // 编号 | 
|                                 wrkMast.getWrkNo(),    // 工作号 | 
|                                 now,    // 发生时间 | 
|                                 null,    // 结束时间 | 
|                                 wrkMast.getWrkSts(),    // 工作状态 | 
|                                 wrkMast.getIoType(),    // 入出库类型 | 
|                                 shuttleSlave.getId(),    // 四向穿梭车 | 
|                                 null,    // plc | 
|                                 wrkMast.getLocNo(),    // 目标库位 | 
|                                 wrkMast.getStaNo(),    // 目标站 | 
|                                 wrkMast.getSourceStaNo(),    // 源站 | 
|                                 wrkMast.getSourceLocNo(),    // 源库位 | 
|                                 wrkMast.getBarcode(),    // 条码 | 
|                                 shuttleProtocol.getErrCode(),    // 异常码 | 
|                                 errName,    // 异常 | 
|                                 1,    // 异常情况 | 
|                                 now,    // 添加时间 | 
|                                 null,    // 添加人员 | 
|                                 now,    // 修改时间 | 
|                                 null,    // 修改人员 | 
|                                 "任务中异常",    // 备注 | 
|                                 JSON.toJSONString(shuttleProtocol)    // 系统状态数据 | 
|                         ); | 
|                         if (!basShuttleErrLogService.insert(basShuttleErrLog)) { | 
|                             News.error("四向穿梭车plc异常记录失败 ===>> [id:{}] [error:{}]", shuttleSlave.getId(), errName); | 
|                         } | 
|                     } | 
|                 } else { | 
|                     // 异常修复 | 
|                     if (shuttleProtocol.getErrState() == null || shuttleProtocol.getErrState() == 0) { | 
|                         latest.setEndTime(now); | 
|                         latest.setUpdateTime(now); | 
|                         latest.setStatus(2); | 
|                         if (!basShuttleErrLogService.updateById(latest)) { | 
|                             News.error("四向穿梭车plc异常记录修复失败 ===>> [id:{}] [errLogId:{}]", shuttleSlave.getId(), latest.getId()); | 
|                         } | 
|                     } | 
|                 } | 
|             }else { | 
| //                //无任务 | 
| //                BasShuttleErrLog latest = basShuttleErrLogService.findLatest(shuttleSlave.getId()); | 
| //                // 有异常 | 
| //                if (shuttleProtocol.getStatusErrorCode() != null && shuttleProtocol.getStatusErrorCode() > 0) { | 
| //                    // 记录新异常 | 
| //                    if (latest == null || (latest.getErrCode() != shuttleProtocol.getStatusErrorCode().intValue())) { | 
| //                        BasShuttleErr basShuttleErr = basShuttleErrService.queryByCode(shuttleProtocol.getStatusErrorCode().intValue()); | 
| //                        String errName = basShuttleErr==null? "未知异常":basShuttleErr.getErrName(); | 
| //                        BasShuttleErrLog basShuttleErrLog = new BasShuttleErrLog( | 
| //                                null,    // 编号 | 
| //                                null,    // 工作号 | 
| //                                now,    // 发生时间 | 
| //                                null,    // 结束时间 | 
| //                                null,    // 工作状态 | 
| //                                null,    // 入出库类型 | 
| //                                shuttleSlave.getId(),    // 四向穿梭车 | 
| //                                null,    // plc | 
| //                                null,    // 目标库位 | 
| //                                null,    // 目标站 | 
| //                                null,    // 源站 | 
| //                                null,    // 源库位 | 
| //                                null,    // 条码 | 
| //                                (int)shuttleProtocol.getStatusErrorCode(),    // 异常码 | 
| //                                errName,    // 异常 | 
| //                                1,    // 异常情况 | 
| //                                now,    // 添加时间 | 
| //                                null,    // 添加人员 | 
| //                                now,    // 修改时间 | 
| //                                null,    // 修改人员 | 
| //                                "无任务异常"    // 备注 | 
| //                        ); | 
| //                        if (!basShuttleErrLogService.insert(basShuttleErrLog)) { | 
| //                            News.error("四向穿梭车plc异常记录失败 ===>> [id:{}] [error:{}]", shuttleSlave.getId(), errName); | 
| //                        } | 
| //                    } | 
| //                    // 无异常 | 
| //                } else { | 
| //                    // 异常修复 | 
| //                    if (latest != null && latest.getStatus() == 1) { | 
| //                        latest.setEndTime(now); | 
| //                        latest.setUpdateTime(now); | 
| //                        latest.setStatus(2); | 
| //                        if (!basShuttleErrLogService.updateById(latest)) { | 
| //                            News.error("四向穿梭车plc异常记录修复失败 ===>> [id:{}] [errLogId:{}]", shuttleSlave.getId(), latest.getId()); | 
| //                        } | 
| //                    } | 
| //                } | 
|             } | 
|         } | 
|     } | 
|   | 
|     /** | 
|      * 提升机异常信息记录 | 
|      */ | 
|     private void recLiftErr() { | 
|         Date now = new Date(); | 
|         for (LiftSlave liftSlave : slaveProperties.getLift()) { | 
|             // 获取提升机信息 | 
|             LiftThread liftThread = (LiftThread) SlaveConnection.get(SlaveType.Lift, liftSlave.getId()); | 
|             if (liftThread == null) { | 
|                 continue; | 
|             } | 
|             LiftProtocol liftProtocol = liftThread.getLiftProtocol(); | 
|             if (liftProtocol == null) { | 
|                 continue; | 
|             } | 
|   | 
|             if (liftProtocol.getTaskNo() != 0) { | 
|                 //有任务 | 
|                 BasLiftErrLog latest = basLiftErrLogService.findLatestByTaskNo(liftSlave.getId(), liftProtocol.getTaskNo().intValue()); | 
|                 // 有异常 | 
|                 if (latest == null) { | 
|                     if (liftProtocol.getDeviceError() != null && liftProtocol.getDeviceError()) { | 
|                         WrkMast wrkMast = wrkMastMapper.selectById(liftProtocol.getTaskNo()); | 
|                         if (wrkMast == null) { | 
|                             continue; | 
|                         } | 
|   | 
|                         String errName = ""; | 
|                         if (liftProtocol.getFrontOverrun()) { | 
|                             errName = "前超限"; | 
|                         } else if (liftProtocol.getBackOverrun()) { | 
|                             errName = "后超限"; | 
|                         } else if (liftProtocol.getLeftOverrun()) { | 
|                             errName = "左超限"; | 
|                         } else if (liftProtocol.getRightOverrun()) { | 
|                             errName = "右超限"; | 
|                         } else if (liftProtocol.getOverHeight()) { | 
|                             errName = "超高"; | 
|                         } else if (liftProtocol.getOverWeight()) { | 
|                             errName = "超重"; | 
|                         } | 
|   | 
|                         BasLiftErrLog basLiftErrLog = new BasLiftErrLog( | 
|                                 null,    // 编号 | 
|                                 wrkMast.getWrkNo(),    // 工作号 | 
|                                 now,    // 发生时间 | 
|                                 null,    // 结束时间 | 
|                                 wrkMast.getWrkSts(),    // 工作状态 | 
|                                 wrkMast.getIoType(),    // 入出库类型 | 
|                                 liftSlave.getId(),    // 提升机 | 
|                                 null,    // plc | 
|                                 wrkMast.getLocNo(),    // 目标库位 | 
|                                 wrkMast.getStaNo(),    // 目标站 | 
|                                 wrkMast.getSourceStaNo(),    // 源站 | 
|                                 wrkMast.getSourceLocNo(),    // 源库位 | 
|                                 wrkMast.getBarcode(),    // 条码 | 
|                                 null,    // 异常码 | 
|                                 errName,    // 异常 | 
|                                 1,    // 异常情况 | 
|                                 now,    // 添加时间 | 
|                                 null,    // 添加人员 | 
|                                 now,    // 修改时间 | 
|                                 null,    // 修改人员 | 
|                                 "任务中异常",    // 备注 | 
|                                 JSON.toJSONString(liftProtocol)    // 系统状态数据 | 
|                         ); | 
|                         if (!basLiftErrLogService.insert(basLiftErrLog)) { | 
|                             News.error("提升机plc异常记录失败 ===>> [id:{}] [error:{}]", liftSlave.getId(), errName); | 
|                         } | 
|                     } | 
|                 } else { | 
|                     // 异常修复 | 
|                     if (liftProtocol.getDeviceError() == null || !liftProtocol.getDeviceError()) { | 
|                         latest.setEndTime(now); | 
|                         latest.setUpdateTime(now); | 
|                         latest.setStatus(2); | 
|                         if (!basLiftErrLogService.updateById(latest)) { | 
|                             News.error("提升机plc异常记录修复失败 ===>> [id:{}] [errLogId:{}]", liftSlave.getId(), latest.getId()); | 
|                         } | 
|                     } | 
|                 } | 
|             } | 
|         } | 
|     } | 
|   | 
|     // ------------------------------------------------------------------------------- | 
|   | 
|     /** | 
|      * 空栈板初始化入库,叉车入库站放货 | 
|      */ | 
|     public void storeEmptyPlt(){ | 
|         try { | 
|             for (DevpSlave devp : slaveProperties.getDevp()) { | 
|                 // 遍历空板入库口 | 
|                 for (DevpSlave.Sta emptyInSta : devp.getEmptyInSta()) { | 
|                     // 获取空板入库站信息 | 
|                     DevpThread devpThread = (DevpThread) SlaveConnection.get(SlaveType.Devp, devp.getId()); | 
|                     StaProtocol staProtocol = devpThread.getStation().get(emptyInSta.getStaNo()); | 
|                     if (staProtocol == null) { | 
|                         continue; | 
|                     } else { | 
|                         staProtocol = staProtocol.clone(); | 
|                     } | 
|                     // 站点条件判断 | 
|                     if (staProtocol.isAutoing() | 
|                             && staProtocol.isLoading() | 
|                             && staProtocol.isInEnable() | 
|                             && staProtocol.isEmptyMk() | 
|                             && (staProtocol.getWorkNo() == 0 || (staProtocol.getWorkNo() >= 9990 || staProtocol.getWorkNo() <= 9999)) | 
|                             && staProtocol.isPakMk()) { | 
|   | 
|                         // 获取条码扫描仪信息 | 
|                         String barcode = null; | 
|                         BarcodeThread barcodeThread = (BarcodeThread) SlaveConnection.get(SlaveType.Barcode, emptyInSta.getBarcode()); | 
|                         if (barcodeThread != null) { | 
|                             String barcode0 = barcodeThread.getBarcode(); | 
|                             if (!Cools.isEmpty(barcode0)) { | 
| //                            News.info("{}号条码扫描器检测条码信息:{}", emptyInSta.getBarcode(), barcode0); | 
|                                 if (!"NG".endsWith(barcode0) && !"NoRead".equals(barcode0) && !"empty".equals(barcode0)) { | 
|                                     barcode = barcode0; | 
|                                 } | 
|                             } | 
|                         } | 
|   | 
|                         if (!Cools.isEmpty(barcode)) { | 
|                             WrkMast wrkMast = wrkMastMapper.selectByBarcode(barcode);//条码存在工作档 | 
|                             if (wrkMast != null) { | 
|                                 continue; | 
|                             } | 
|                         } | 
|   | 
|                         LedThread ledThread = (LedThread) SlaveConnection.get(SlaveType.Led, emptyInSta.getLed()); | 
|   | 
|                         try { | 
|                             LocTypeDto locTypeDto = new LocTypeDto(staProtocol); | 
|   | 
|                             SearchLocParam param = new SearchLocParam(); | 
|                             param.setIoType(10); | 
|                             if (!Cools.isEmpty(barcode)) { | 
|                                 param.setBarcode(barcode); | 
|                             } | 
|                             param.setSourceStaNo(emptyInSta.getStaNo()); | 
| //                        param.setLocType1(locTypeDto.getLocType1()); | 
|                             String response = new HttpHandler.Builder() | 
|                                     .setUri(wmsUrl) | 
|                                     .setPath("/rpc/pakin/loc/v2") | 
|                                     .setJson(JSON.toJSONString(param)) | 
|                                     .build() | 
|                                     .doPost(); | 
|                             JSONObject jsonObject = JSON.parseObject(response); | 
|                             Integer code = jsonObject.getInteger("code"); | 
|                             if (code.equals(200)) { | 
|                                 StartupDto dto = jsonObject.getObject("data", StartupDto.class); | 
|                                 barcodeThread.setBarcode(""); | 
| //                            // 更新站点信息 且 下发plc命令 | 
| //                            staProtocol.setWorkNo(dto.getWorkNo().shortValue()); | 
| //                            staProtocol.setStaNo(dto.getStaNo().shortValue()); | 
| //                            devpThread.setPakMk(staProtocol.getSiteId(), false); | 
| //                            boolean result = MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol)); | 
| //                            if (!result) { | 
| //                                throw new CoolException("更新plc站点信息失败"); | 
| //                            } | 
|                             } else { | 
|                                 if (ledThread != null) { | 
|                                     String errorMsg = jsonObject.getString("msg"); | 
|                                     if (!Cools.isEmpty(errorMsg)) { | 
|                                         MessageQueue.offer(SlaveType.Led, emptyInSta.getLed(), new Task(3, errorMsg)); | 
|                                     } | 
|                                 } | 
|                                 News.error("请求接口失败!!!url:{};request:{};response:{}", wmsUrl + "/rpc/pakin/loc/v2", JSON.toJSONString(param), response); | 
|                             } | 
|                         } catch (Exception e) { | 
|                             e.printStackTrace(); | 
|                             TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); | 
|                         } | 
|   | 
|                     } | 
|   | 
|   | 
|                 } | 
|             } | 
|         } catch (Exception e) { | 
|             e.printStackTrace(); | 
|         } | 
|     } | 
|   | 
|     /** | 
|      * AGV补货 => 生成入库通知档 | 
|      */ | 
|     public synchronized void robotGenerateAgvTask() { | 
|         try { | 
|             //检测300站是否自动、有物、工作号 | 
|             for (DevpSlave devp : slaveProperties.getDevp()) { | 
|                 // 获取入库站信息 | 
|                 DevpThread devpThread = (DevpThread) SlaveConnection.get(SlaveType.Devp, devp.getId()); | 
|                 StaProtocol staProtocol = devpThread.getStation().get(300); | 
|                 if (staProtocol == null) { | 
|                     continue; | 
|                 } | 
|                 if (staProtocol.isAutoing() && staProtocol.isLoading() && staProtocol.getWorkNo() != 0) { | 
|                     //查询是否有工作档 | 
|                     WrkMast wrkMast = wrkMastMapper.selectByWorkNo(staProtocol.getWorkNo().intValue()); | 
|                     if (wrkMast == null) { | 
|                         continue; | 
|                     } | 
|   | 
|                     if (wrkMast.getWrkSts() != 25) {//25.提升机搬运完成 | 
|                         continue; | 
|                     } | 
|   | 
|                     if (wrkMast.getMk() != null && wrkMast.getMk().equals("Y")) {//标记为Y表示需要用到机械臂拣料 | 
|                         Short targetSta = null;//目标站 | 
|                         //判断机械臂拣料站是否空闲 | 
|                         StaProtocol staProtocol303 = devpThread.getStation().get(303); | 
|                         StaProtocol staProtocol317 = devpThread.getStation().get(317); | 
|   | 
|                         List<WrkMast> wrkMasts303 = wrkMastService.selectList(new EntityWrapper<WrkMast>().eq("wrk_sts", 25).eq("sta_no", 303)); | 
|                         List<WrkMast> wrkMasts317 = wrkMastService.selectList(new EntityWrapper<WrkMast>().eq("wrk_sts", 25).eq("sta_no", 317)); | 
|                         if (staProtocol303.isAutoing() && !staProtocol303.isLoading() && wrkMasts303.isEmpty()) { | 
|                             //自动、无物 | 
|                             targetSta = (short) 303; | 
|                         } else if (staProtocol317.isAutoing() && !staProtocol317.isLoading() && wrkMasts317.isEmpty()) { | 
|                             //自动、无物 | 
|                             targetSta = (short) 317; | 
|                         } else { | 
|                             continue;//没有空闲站点 | 
|                         } | 
|   | 
|                         if (wrkMast.getStaNo() != 303 && wrkMast.getStaNo() != 317) { | 
|                             //向AGV发起组托请求 | 
|                             try { | 
|                                 HashMap<String, Object> param = new HashMap<>(); | 
|                                 param.put("wrkNo", wrkMast.getWrkNo()); | 
|                                 String response = new HttpHandler.Builder() | 
|                                         .setUri(wmsUrl) | 
|                                         .setPath("/rpc/replenishment") | 
|                                         .setJson(JSON.toJSONString(param)) | 
|                                         .build() | 
|                                         .doPost(); | 
|                                 JSONObject jsonObject = JSON.parseObject(response); | 
|                                 Integer code = jsonObject.getInteger("code"); | 
|                                 if (code.equals(200)) {//AGV组托成功 | 
|                                     //覆盖工作档目标站 | 
|                                     wrkMast.setStaNo(targetSta.intValue()); | 
|                                     wrkMast.setShuttleNo(null);//释放小车 | 
|                                     wrkMast.setLiftNo(null);//释放提升机 | 
|                                     if (wrkMastMapper.updateById(wrkMast) > 0) { | 
|                                         //向300站写入目标站 | 
|                                         staProtocol = staProtocol.clone(); | 
|                                         staProtocol.setStaNo(targetSta);//移动到目标站 | 
|                                         boolean result = MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol)); | 
|                                         try { | 
|                                             Thread.sleep(500); | 
|                                         } catch (Exception e) { | 
|                                             e.printStackTrace(); | 
|                                         } | 
|                                         continue; | 
|                                     } | 
|                                 } | 
|                             } catch (Exception e) { | 
| //                                e.printStackTrace(); | 
|                                 TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); | 
|                             } | 
|   | 
| //                        //覆盖工作档目标站 | 
| //                        wrkMast.setStaNo(targetSta.intValue()); | 
| //                        wrkMast.setShuttleNo(null);//释放小车 | 
| //                        wrkMast.setLiftNo(null);//释放提升机 | 
| //                        if (wrkMastMapper.updateById(wrkMast) > 0) { | 
| //                            //向300站写入目标站 | 
| //                            staProtocol = staProtocol.clone(); | 
| //                            staProtocol.setStaNo(targetSta);//移动到目标站 | 
| //                            boolean result = MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol)); | 
| //                            try { | 
| //                                Thread.sleep(500); | 
| //                            } catch (Exception e) { | 
| //                                e.printStackTrace(); | 
| //                            } | 
| //                            continue; | 
| //                        } | 
|                         } | 
|                     } | 
|                 } | 
|             } | 
|         } catch (Exception e) { | 
| //            e.printStackTrace(); | 
|         } | 
|     } | 
|   | 
|     /** | 
|      * AGV补货 => 机械臂拣料 | 
|      */ | 
|     public synchronized void agvRestockByRobot() { | 
|         try { | 
|             //检测300站是否自动、有物、工作号 | 
|             for (DevpSlave devp : slaveProperties.getDevp()) { | 
|                 // 获取入库站信息 | 
|                 DevpThread devpThread = (DevpThread) SlaveConnection.get(SlaveType.Devp, devp.getId()); | 
|                 StaProtocol staProtocol303 = devpThread.getStation().get(303); | 
|                 StaProtocol staProtocol317 = devpThread.getStation().get(317); | 
|                 if (staProtocol303 == null || staProtocol317 == null) { | 
|                     continue; | 
|                 } | 
|   | 
|                 if (staProtocol303.isAutoing() && staProtocol303.isLoading() && staProtocol303.getWorkNo() != 0) { | 
|                     //调度机械臂 | 
|                     //查询是否有工作档 | 
|                     WrkMast wrkMast = wrkMastMapper.selectByWorkNo(staProtocol303.getWorkNo().intValue()); | 
|                     if (wrkMast == null) { | 
|                         continue; | 
|                     } | 
|                     List<WrkDetl> wrkDetls = wrkDetlService.findByWorkNo(wrkMast.getWrkNo()); | 
|                     if (wrkDetls.isEmpty()) { | 
|                         continue; | 
|                     } | 
|   | 
|                     if (wrkMast.getInvWh() == null) { | 
|                         boolean result = RobotUtils.sendTask(staProtocol303.getWorkNo().toString(), wrkDetls.size(), "303"); | 
|                         if (result) { | 
|                             wrkMast.setInvWh("Y");//标记已经下发机械臂任务 | 
|                             wrkMastMapper.updateById(wrkMast); | 
|                         } | 
|                     } | 
|                 } | 
|   | 
|                 if (staProtocol317.isAutoing() && staProtocol317.isLoading() && staProtocol317.getWorkNo() != 0) { | 
|                     //调度机械臂 | 
|                     //查询是否有工作档 | 
|                     WrkMast wrkMast = wrkMastMapper.selectByWorkNo(staProtocol317.getWorkNo().intValue()); | 
|                     if (wrkMast == null) { | 
|                         continue; | 
|                     } | 
|                     List<WrkDetl> wrkDetls = wrkDetlService.findByWorkNo(wrkMast.getWrkNo()); | 
|                     if (wrkDetls.isEmpty()) { | 
|                         continue; | 
|                     } | 
|                     if (wrkMast.getInvWh() == null) { | 
|                         boolean result = RobotUtils.sendTask(staProtocol317.getWorkNo().toString(), wrkDetls.size(), "317"); | 
|                         if (result) { | 
|                             wrkMast.setInvWh("Y");//标记已经下发机械臂任务 | 
|                             wrkMastMapper.updateById(wrkMast); | 
|                         } | 
|                     } | 
|                 } | 
|             } | 
|         } catch (Exception e) { | 
|             e.printStackTrace(); | 
|         } | 
|     } | 
|   | 
|     /** | 
|      * AGV补货(通知AGV取货) | 
|      */ | 
|     public synchronized void agvRestockInto() { | 
|         try { | 
|             //检测309和312站是否自动、有物 | 
|             for (DevpSlave devp : slaveProperties.getDevp()) { | 
|                 // 获取入库站信息 | 
|                 DevpThread devpThread = (DevpThread) SlaveConnection.get(SlaveType.Devp, devp.getId()); | 
|                 StaProtocol staProtocol309 = devpThread.getStation().get(309); | 
|                 StaProtocol staProtocol312 = devpThread.getStation().get(312); | 
|                 if (staProtocol309 == null || staProtocol312 == null) { | 
|                     continue; | 
|                 } | 
|   | 
|                 if (staProtocol309.isAutoing() && staProtocol309.isLoading() && staProtocol309.isInEnable()) { | 
|                     // 获取条码扫描仪信息 | 
|                     BarcodeThread barcodeThread = (BarcodeThread) SlaveConnection.get(SlaveType.Barcode, 9);//308站条码器 | 
|                     if (barcodeThread == null) { | 
|                         continue; | 
|                     } | 
|                     String barcode = barcodeThread.getBarcode(); | 
|                     if (!Cools.isEmpty(barcode)) { | 
|                         //通知AGV取货 | 
|                         boolean result = agvRestockCall("301-1", barcode); | 
|                         log.info("机械臂通知AGV取货,条码号:" + barcode); | 
|                         if (result) { | 
|                             barcodeThread.setBarcode(""); | 
|                         } | 
|                     } | 
|                 } | 
|   | 
|                 if (staProtocol312.isAutoing() && staProtocol312.isLoading() && staProtocol312.isInEnable()) { | 
|                     // 获取条码扫描仪信息 | 
|                     BarcodeThread barcodeThread = (BarcodeThread) SlaveConnection.get(SlaveType.Barcode, 10);//311站条码器 | 
|                     if (barcodeThread == null) { | 
|                         continue; | 
|                     } | 
|                     String barcode = barcodeThread.getBarcode(); | 
|                     if (!Cools.isEmpty(barcode)) { | 
|                         //通知AGV取货 | 
|                         boolean result = agvRestockCall("302-1", barcode); | 
|                         log.info("机械臂通知AGV取货,条码号:" + barcode); | 
|                         if (result) { | 
|                             barcodeThread.setBarcode(""); | 
|                         } | 
|                     } | 
|                 } | 
|             } | 
|         } catch (Exception e) { | 
|             e.printStackTrace(); | 
|         } | 
|     } | 
|   | 
|     //通知AGV取货 | 
|     private boolean agvRestockCall(String staNo, String barcode) { | 
|         try { | 
|             HashMap<String, Object> param = new HashMap<>(); | 
|             param.put("devNo", staNo); | 
|             param.put("containerCode", barcode); | 
|             String response = new HttpHandler.Builder() | 
|                     .setUri(wmsUrl) | 
|                     .setPath("/rpc/start") | 
|                     .setJson(JSON.toJSONString(param)) | 
|                     .build() | 
|                     .doPost(); | 
|             JSONObject jsonObject = JSON.parseObject(response); | 
|             News.info("悬挂线,WMS返回结果:" + jsonObject); | 
|             Integer code = jsonObject.getInteger("code"); | 
|             if (code.equals(200)) {//呼叫AGV | 
|                 return true; | 
|             } | 
|         } catch (Exception e) { | 
|             e.printStackTrace(); | 
|             TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); | 
|         } | 
|         return false; | 
|     } | 
|   | 
|     //通知WMS当前拣料站点信息 | 
|     private boolean agvCureentCall(String staNo, String barcode) { | 
|         try { | 
|             HashMap<String, Object> param = new HashMap<>(); | 
|             param.put("devNo", staNo); | 
|             param.put("containerCode", barcode); | 
|             String response = new HttpHandler.Builder() | 
|                     .setUri(wmsUrl) | 
|                     .setPath("/rpc/current/containerCode") | 
|                     .setJson(JSON.toJSONString(param)) | 
|                     .build() | 
|                     .doPost(); | 
|             JSONObject jsonObject = JSON.parseObject(response); | 
|             News.info("悬挂线,WMS返回结果:" + jsonObject); | 
|             Integer code = jsonObject.getInteger("code"); | 
|             if (code.equals(200)) {//呼叫AGV | 
|                 return true; | 
|             } | 
|         } catch (Exception e) { | 
|             e.printStackTrace(); | 
|             TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); | 
|         } | 
|         return false; | 
|     } | 
|   | 
|     /** | 
|      * AGV补货(悬挂线通知AGV取货) | 
|      */ | 
|     public synchronized void agvRestockIntoByHangingWire() { | 
|         try { | 
|             //检测350和351扫码器 | 
|             int[] barcodeStaNo = {11, 12,14,16,18,20};//11 => 350站扫码器,12 => 351站扫码器 | 
|             for (int staNo : barcodeStaNo) { | 
|                 // 获取条码扫描仪信息 | 
|                 BarcodeThread barcodeThread = (BarcodeThread) SlaveConnection.get(SlaveType.Barcode, staNo); | 
|                 if (barcodeThread == null) { | 
|                     continue; | 
|                 } | 
|                 String barcode = barcodeThread.getBarcode(); | 
|                 if (!Cools.isEmpty(barcode)) { | 
|                     if (barcode.contains("NoRead")) { | 
|                         continue; | 
|                     } | 
|   | 
|                     String agvStaNo = null; | 
|                     if (staNo == 11) { | 
|                         agvStaNo = "303-1"; | 
|                     } else if(staNo == 12){ | 
|                         agvStaNo = "304-1"; | 
|                     } else if(staNo == 14){ | 
|                         agvStaNo = "311-1"; | 
|                     } else if(staNo == 16){ | 
|                         agvStaNo = "313-1"; | 
|                     } else if(staNo == 18){ | 
|                         agvStaNo = "315-1"; | 
|                     } else if(staNo == 20){ | 
|                         agvStaNo = "317-1"; | 
|                     } | 
|                     //通知AGV取货 | 
|                     boolean result = agvRestockCall(agvStaNo, barcode); | 
|                     if (result) { | 
|                         barcodeThread.setBarcode(""); | 
|                     } | 
|                     log.info(barcodeThread.getSlave().getId() + "号扫码器,通知AGV取货,条码号:" + barcode); | 
|                 } | 
|             } | 
|         } catch (Exception e) { | 
|             e.printStackTrace(); | 
|         } | 
|     } | 
|   | 
|     /** | 
|      * AGV拣料站点信息 | 
|      */ | 
|     public synchronized void agvCurrentContainerCodeInfoWire() { | 
|         try { | 
|             //检测350和351扫码器 | 
|             int[] barcodeStaNo = {13, 15,17,19};//11 => 350站扫码器,12 => 351站扫码器 | 
|             for (int staNo : barcodeStaNo) { | 
|                 // 获取条码扫描仪信息 | 
|                 BarcodeThread barcodeThread = (BarcodeThread) SlaveConnection.get(SlaveType.Barcode, staNo); | 
|                 if (barcodeThread == null) { | 
|                     continue; | 
|                 } | 
|                 String barcode = barcodeThread.getBarcode(); | 
|                 if (!Cools.isEmpty(barcode)) { | 
|                     if (barcode.contains("NoRead")) { | 
|                         continue; | 
|                     } | 
|   | 
|                     String agvStaNo = null; | 
|                     if (staNo == 13) { | 
|                         agvStaNo = "CS-310"; | 
|                     } else if(staNo == 15){ | 
|                         agvStaNo = "CS-311"; | 
|                     } else if(staNo == 17){ | 
|                         agvStaNo = "CS-312"; | 
|                     } else if(staNo == 19){ | 
|                         agvStaNo = "CS-313"; | 
|                     } | 
|                     //通知WMS当前容器码 | 
|                     boolean result = agvCureentCall(agvStaNo, barcode); | 
|                     if (result) { | 
|                         barcodeThread.setBarcode(""); | 
|                     } | 
|                     log.info(barcodeThread.getSlave().getId() + "号扫码器,通知AGV取货,条码号:" + barcode); | 
|                 } | 
|             } | 
|         } catch (Exception e) { | 
|             e.printStackTrace(); | 
|         } | 
|     } | 
|   | 
|     // 300站拣料 | 
|     public void pick300() { | 
|         try { | 
|             //检测300站是否自动、有物、工作号 | 
|             for (DevpSlave devp : slaveProperties.getDevp()) { | 
|                 // 获取入库站信息 | 
|                 DevpThread devpThread = (DevpThread) SlaveConnection.get(SlaveType.Devp, devp.getId()); | 
|                 StaProtocol staProtocol = devpThread.getStation().get(300); | 
|                 if (staProtocol == null) { | 
|                     continue; | 
|                 }else { | 
|                     staProtocol = staProtocol.clone(); | 
|                 } | 
|   | 
|                 if (staProtocol.isAutoing() && staProtocol.isLoading() && staProtocol.getWorkNo() != 0) { | 
|                     //查询是否有工作档 | 
|                     WrkMast wrkMast = wrkMastMapper.selectByWorkNo(staProtocol.getWorkNo().intValue()); | 
|                     if (wrkMast == null) { | 
|                         continue; | 
|                     } | 
|   | 
|                     if (wrkMast.getWrkSts() != 29) {//29.出库完成 | 
|                         continue; | 
|                     } | 
|   | 
|                     if (wrkMast.getMk() == null) { | 
|                         Integer sourceStaNo = wrkMast.getSourceStaNo();//源站 | 
|                         Integer staNo = wrkMast.getStaNo();//目标站 | 
|                         //覆盖工作档目标站 | 
|                         wrkMast.setStaNo(sourceStaNo); | 
|                         wrkMast.setSourceStaNo(staNo); | 
|                         wrkMast.setMk("N"); | 
|                         if (wrkMastMapper.updateById(wrkMast) > 0) { | 
|                             //向300站写入目标站 | 
|                             staProtocol = staProtocol.clone(); | 
|                             staProtocol.setStaNo(wrkMast.getStaNo().shortValue());//移动到目标站 | 
|                             boolean result = MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol)); | 
|                             try { | 
|                                 Thread.sleep(500); | 
|                             } catch (Exception e) { | 
|                                 e.printStackTrace(); | 
|                             } | 
|                         } | 
|                     } | 
|                 } | 
|             } | 
|         } catch (Exception e) { | 
|             e.printStackTrace(); | 
|         } | 
|     } | 
|   | 
|     /** | 
|      * 出库  ===>> 工作档信息写入led显示器 | 
|      */ | 
|     public void ledExecute() { | 
|         try { | 
|             for (LedSlave led : slaveProperties.getLed()) { | 
|                 // 获取输送线plc线程 | 
|                 DevpThread devpThread = (DevpThread) SlaveConnection.get(SlaveType.Devp, led.getDevpPlcId()); | 
|                 // 命令集合 | 
|                 List<LedCommand> commands = new ArrayList<>(); | 
|                 // 工作档集合 | 
|                 List<WrkMast> wrkMasts = new ArrayList<>(); | 
|                 List<WrkMastLog> wrkMastLogs = new ArrayList<>(); | 
|                 for (Integer staNo : led.getStaArr()) { | 
|                     // 获取叉车站点 | 
|                     StaProtocol staProtocol = devpThread.getStation().get(staNo); | 
|                     if (null == staProtocol || null == staProtocol.getWorkNo() || 0 == staProtocol.getWorkNo() || !staProtocol.isLoading()) { | 
|                         continue; | 
|                     } else { | 
|                         staProtocol = staProtocol.clone(); | 
|                     } | 
|                     // 获取工作档数据 | 
|                     WrkMast wrkMast = wrkMastMapper.selectById(staProtocol.getWorkNo()); | 
|                     Integer wrkNo = staProtocol.getWorkNo().intValue(); | 
|                     Integer ioType = null; | 
|                     String sourceLocNo = null; | 
|                     String locNo = null; | 
|                     Integer wrkStaNo = null; | 
|                     String barcode = null; | 
|                     if (wrkMast == null) { | 
|                         //查询历史档 | 
|                         WrkMastLog wrkMastLog = wrkMastLogMapper.selectLatestByWorkNo(staProtocol.getWorkNo().intValue()); | 
|                         if (wrkMastLog == null) { | 
|                             continue; | 
|                         } | 
|                         ioType = wrkMastLog.getIoType(); | 
|                         sourceLocNo = wrkMastLog.getSourceLocNo(); | 
|                         locNo = wrkMastLog.getLocNo(); | 
|                         wrkStaNo = wrkMastLog.getStaNo(); | 
|                         barcode = wrkMastLog.getBarcode(); | 
|                         wrkMastLogs.add(wrkMastLog); | 
|                     }else { | 
|                         if (wrkMast.getWrkSts() < 14 || wrkMast.getIoType() < 100) { | 
|                             continue; | 
|                         } | 
|                         ioType = wrkMast.getIoType(); | 
|                         sourceLocNo = wrkMast.getSourceLocNo(); | 
|                         locNo = wrkMast.getLocNo(); | 
|                         wrkStaNo = wrkMast.getStaNo(); | 
|                         barcode = wrkMast.getBarcode(); | 
|                         wrkMasts.add(wrkMast); | 
|                     } | 
|                     // 组装命令 | 
|                     LedCommand ledCommand = new LedCommand(); | 
|                     ledCommand.setWorkNo(wrkNo); | 
|                     ledCommand.setIoType(ioType); | 
|                     // 出库模式 | 
|                     switch (ioType) { | 
|                         case 101: | 
|                             ledCommand.setTitle("全板出库"); | 
|                             break; | 
|                         case 103: | 
|                             ledCommand.setTitle("拣料出库"); | 
|                             break; | 
|                         case 104: | 
|                             ledCommand.setTitle("并板出库"); | 
|                             break; | 
|                         case 107: | 
|                             ledCommand.setTitle("盘点出库"); | 
|                             break; | 
|                         case 110: | 
|                             ledCommand.setTitle("空板出库"); | 
|                             ledCommand.setEmptyMk(true); | 
|                             break; | 
|                         default: | 
|                             News.error("任务入出库类型错误!!![工作号:{}] [入出库类型:{}]", wrkNo, ioType); | 
|                             break; | 
|                     } | 
|                     ledCommand.setSourceLocNo(sourceLocNo); | 
|                     ledCommand.setLocNo(locNo); | 
|                     ledCommand.setStaNo(wrkStaNo); | 
|                     ledCommand.setBarcode(barcode); | 
|                     if (ioType != 110 && ioType != 10) { | 
|                         List<WrkDetl> wrkDetls = wrkDetlService.selectList(new EntityWrapper<WrkDetl>().eq("wrk_no", wrkNo)); | 
|                         if (!wrkDetls.isEmpty()) { | 
|                             wrkDetls.forEach(wrkDetl -> { | 
|                                 double remainNum = wrkDetl.getStock() - wrkDetl.getAnfme();//剩余数量 | 
|                                 if (remainNum < 0) { | 
|                                     remainNum = 0; | 
|                                 } | 
|                                 String matnr = wrkDetl.getMatnr(); | 
|                                 Mat mat = matService.selectByMatnr(wrkDetl.getMatnr()); | 
|                                 if (mat != null) { | 
|                                     if (!mat.getMatnr().equals(mat.getMatnr2())) { | 
|                                         matnr += " - " + mat.getMatnr2(); | 
|                                     } | 
|                                 } | 
|                                 ledCommand.getMatDtos().add(new MatDto(matnr, wrkDetl.getMaktx(), wrkDetl.getAnfme(), remainNum, wrkDetl.getSpecs(), wrkDetl.getSuppCode(), wrkDetl.getOrderNo())); | 
|                             }); | 
|                         }else { | 
|                             List<WrkDetlLog> wrkDetlLogs = wrkDetlLogService.selectLatestByWorkNo(wrkNo, barcode); | 
|                             for (WrkDetlLog wrkDetlLog : wrkDetlLogs) { | 
|                                 double remainNum = wrkDetlLog.getStock() - wrkDetlLog.getAnfme();//剩余数量 | 
|                                 if (remainNum < 0) { | 
|                                     remainNum = 0; | 
|                                 } | 
|                                 String matnr = wrkDetlLog.getMatnr(); | 
|                                 Mat mat = matService.selectByMatnr(wrkDetlLog.getMatnr()); | 
|                                 if (mat != null) { | 
|                                     if (!mat.getMatnr().equals(mat.getMatnr2())) { | 
|                                         matnr += " - " + mat.getMatnr2(); | 
|                                     } | 
|                                 } | 
|                                 ledCommand.getMatDtos().add(new MatDto(matnr, wrkDetlLog.getMaktx(), wrkDetlLog.getAnfme(), remainNum, wrkDetlLog.getSpecs(), wrkDetlLog.getSuppCode())); | 
|                             } | 
|                         } | 
|   | 
| //                        List<LocDetl> locDetls = locDetlService.selectList(new EntityWrapper<LocDetl>().eq("loc_no", sourceLocNo)); | 
| //                        if (ioType == 101) { | 
| //                            List<WrkDetl> wrkDetls = wrkDetlService.selectList(new EntityWrapper<WrkDetl>().eq("wrk_no", wrkNo)); | 
| //                            wrkDetls.forEach(wrkDetl -> { | 
| //                                ledCommand.getMatDtos().add(new MatDto(wrkDetl.getMatnr(), wrkDetl.getMaktx(), wrkDetl.getAnfme(), 0D, wrkDetl.getSpecs(), wrkDetl.getSuppCode())); | 
| //                            }); | 
| ////                            locDetls.forEach(locDetl -> { | 
| ////                                Wrapper<WrkDetl> wrapper = new EntityWrapper<WrkDetl>().eq("matnr", locDetl.getMatnr()).eq("wrk_no", wrkNo); | 
| ////                                Utils.wapperSetCondition(wrapper, "batch", locDetl.getBatch()); | 
| ////                                Utils.wapperSetCondition(wrapper, "three_code", locDetl.getThreeCode()); | 
| ////                                Utils.wapperSetCondition(wrapper, "dead_time", locDetl.getDeadTime()); | 
| ////                                Utils.wapperSetCondition(wrapper, "supp_code", locDetl.getSuppCode());//料箱码 | 
| ////                                List<WrkDetl> detl = wrkDetlService.selectList(wrapper); | 
| ////                                if (Cools.isEmpty(detl)) { | 
| ////                                    String suppCode = ""; | 
| ////                                    if (locDetl.getSuppCode() != null) { | 
| ////                                        suppCode = locDetl.getSuppCode(); | 
| ////                                    } | 
| ////                                    ledCommand.getMatDtos().add(new MatDto(locDetl.getMatnr(), locDetl.getMaktx(), 0D, locDetl.getAnfme(), locDetl.getSpecs(), suppCode)); | 
| ////                                } else { | 
| ////                                    //出库数量累计 | 
| ////                                    Double conut = 0.0; | 
| ////                                    for (WrkDetl wrkDetl : detl) { | 
| ////                                        conut = conut + wrkDetl.getAnfme(); | 
| ////                                    } | 
| //// | 
| ////                                    for (WrkDetl wrkDetl : detl) { | 
| ////                                        String suppCode = ""; | 
| ////                                        if (wrkDetl.getSuppCode() != null) { | 
| ////                                            suppCode = wrkDetl.getSuppCode(); | 
| ////                                        } | 
| ////                                        ledCommand.getMatDtos().add(new MatDto(wrkDetl.getMatnr(), wrkDetl.getMaktx(), wrkDetl.getAnfme(), (locDetl.getAnfme() - conut), wrkDetl.getSpecs(), suppCode, wrkDetl.getOrderNo())); | 
| ////                                    } | 
| ////                                } | 
| //// | 
| ////                            }); | 
| //                        } else { | 
| //                            locDetls.forEach(locDetl -> { | 
| //                                Wrapper<WrkDetl> wrapper = new EntityWrapper<WrkDetl>().eq("matnr", locDetl.getMatnr()).eq("wrk_no", wrkNo); | 
| //                                Utils.wapperSetCondition(wrapper, "batch", locDetl.getBatch()); | 
| //                                Utils.wapperSetCondition(wrapper, "three_code", locDetl.getThreeCode()); | 
| //                                Utils.wapperSetCondition(wrapper, "dead_time", locDetl.getDeadTime()); | 
| //                                Utils.wapperSetCondition(wrapper, "supp_code", locDetl.getSuppCode());//料箱码 | 
| //                                List<WrkDetl> detl = wrkDetlService.selectList(wrapper); | 
| //                                if (Cools.isEmpty(detl)) { | 
| //                                    String suppCode = ""; | 
| //                                    if (locDetl.getSuppCode() != null) { | 
| //                                        suppCode = locDetl.getSuppCode(); | 
| //                                    } | 
| //                                    ledCommand.getMatDtos().add(new MatDto(locDetl.getMatnr(), locDetl.getMaktx(), 0D, locDetl.getAnfme(), locDetl.getSpecs(), suppCode)); | 
| //                                } else { | 
| //                                    //出库数量累计 | 
| //                                    Double conut = 0.0; | 
| //                                    for (WrkDetl wrkDetl : detl) { | 
| //                                        conut = conut + wrkDetl.getAnfme(); | 
| //                                    } | 
| // | 
| //                                    for (WrkDetl wrkDetl : detl) { | 
| //                                        String suppCode = ""; | 
| //                                        if (wrkDetl.getSuppCode() != null) { | 
| //                                            suppCode = wrkDetl.getSuppCode(); | 
| //                                        } | 
| //                                        ledCommand.getMatDtos().add(new MatDto(wrkDetl.getMatnr(), wrkDetl.getMaktx(), wrkDetl.getAnfme(), (wrkDetl.getStock() - conut), wrkDetl.getSpecs(), suppCode, wrkDetl.getOrderNo())); | 
| //                                    } | 
| //                                } | 
| // | 
| //                            }); | 
| //                        } | 
| // | 
| // | 
| //                        if (ioType == 107) { | 
| //                            locDetls = new ArrayList<>(); | 
| //                            ledCommand.setMatDtos(new ArrayList<>()); | 
| //                        } | 
| // | 
| //                        if (locDetls.isEmpty() && ioType != 101) { | 
| //                            List<WrkDetl> wrkDetls = wrkDetlService.selectList(new EntityWrapper<WrkDetl>().eq("wrk_no", wrkNo)); | 
| //                            wrkDetls.forEach(wrkDetl -> { | 
| //                                if (wrkDetl.getAnfme() > 0D) { | 
| //                                    ledCommand.getMatDtos().add(new MatDto(wrkDetl.getMatnr(), wrkDetl.getMaktx(), wrkDetl.getAnfme(), wrkDetl.getAnfme(), wrkDetl.getSpecs(), wrkDetl.getSuppCode())); | 
| //                                } | 
| //                            }); | 
| // | 
| //                            if (wrkDetls.isEmpty()) {//从历史档查询 | 
| //                                List<WrkDetlLog> wrkDetlLogs = wrkDetlLogService.selectLatestByWorkNo(wrkNo, barcode); | 
| //                                for (WrkDetlLog wrkDetlLog : wrkDetlLogs) { | 
| //                                    if (wrkDetlLog.getAnfme() > 0D) { | 
| //                                        ledCommand.getMatDtos().add(new MatDto(wrkDetlLog.getMatnr(), wrkDetlLog.getMaktx(), wrkDetlLog.getAnfme(), wrkDetlLog.getAnfme(), wrkDetlLog.getSpecs(), wrkDetlLog.getSuppCode())); | 
| //                                    } | 
| //                                } | 
| //                            } | 
| //                        } | 
|                     } | 
|   | 
|                     commands.add(ledCommand); | 
|                 } | 
|                 Set<Integer> workNos = null; | 
|                 if (!wrkMasts.isEmpty()) { | 
|                     workNos = wrkMasts.stream().map(WrkMast::getWrkNo).collect(Collectors.toSet()); | 
|                 }else { | 
|                     workNos = wrkMastLogs.stream().map(WrkMastLog::getWrkNo).collect(Collectors.toSet()); | 
|                 } | 
|                 // 获取LED线程 | 
|                 LedThread ledThread = (LedThread) SlaveConnection.get(SlaveType.Led, led.getId()); | 
|                 // 相同工作号集合则过滤 | 
|                 if (CollectionUtils.equals(ledThread.getWorkNos(), workNos)) { | 
|                     continue; | 
|                 } | 
|                 // 命令下发 ------------------------------------------------------------------------------- | 
|                 if (!commands.isEmpty()) { | 
|                     if (!MessageQueue.offer(SlaveType.Led, led.getId(), new Task(1, commands))) { | 
|                         log.error("{}号LED命令下发失败!!![ip:{}] [port:{}]", led.getId(), led.getIp(), led.getPort()); | 
|                         continue; | 
|                     } else { | 
|                         ledThread.setLedMk(false); | 
|                     } | 
|                 } | 
|   | 
|                 try { | 
|                     // 修改主档led标记 | 
|                     for (WrkMast wrkMast : wrkMasts) { | 
|                         wrkMast.setOveMk("Y"); | 
|                         wrkMast.setModiTime(new Date()); | 
|                         if (wrkMastMapper.updateById(wrkMast) == 0) { | 
|                             throw new CoolException("更新工作档失败"); | 
|                         } | 
|                     } | 
|   | 
|                     // 更新线程当前工作号集合 | 
|                     ledThread.setWorkNos(workNos); | 
|   | 
|                 } catch (Exception e) { | 
|                     e.printStackTrace(); | 
|                     TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); | 
|                 } | 
|   | 
|             } | 
|         } catch (Exception e) { | 
|             e.printStackTrace(); | 
|         } | 
|     } | 
|   | 
|     /** | 
|      * 其他  ===>> LED显示器复位,显示默认信息 | 
|      */ | 
|     public void ledReset() { | 
|         try { | 
|             //        for (LedSlave led : slaveProperties.getLed()) { | 
| // | 
| //            // 获取输送线plc线程 | 
| //            DevpThread devpThread = (DevpThread) SlaveConnection.get(SlaveType.Devp, led.getDevpPlcId()); | 
| //            // 命令集合 | 
| //            boolean reset = true; | 
| //            for (Integer staNo : led.getStaArr()) { | 
| //                // 获取叉车站点 | 
| //                StaProtocol staProtocol = devpThread.getStation().get(staNo); | 
| //                if (staProtocol == null) { | 
| //                    continue; | 
| //                } | 
| //                if (staProtocol.getWorkNo() != 0 && staProtocol.isLoading()) { | 
| //                    reset = false; | 
| //                    break; | 
| //                } | 
| //            } | 
| //            // 获取led线程 | 
| //            LedThread ledThread = (LedThread) SlaveConnection.get(SlaveType.Led, led.getId()); | 
| //            // led显示默认内容 | 
| //            if (reset && !ledThread.isLedMk()) { | 
| //                ledThread.setLedMk(true); | 
| //                if (!MessageQueue.offer(SlaveType.Led, led.getId(), new Task(4, new ArrayList<>()))) { | 
| //                    News.error(" - {}号LED命令下发失败!!![ip:{}] [port:{}]", led.getId(), led.getIp(), led.getPort()); | 
| //                } else { | 
| //                    News.error("{}号LED命令下发成功!!![ip:{}] [port:{}]", led.getId(), led.getIp(), led.getPort()); | 
| //                    ledThread.setLedMk(false); | 
| //                } | 
| //            } | 
| //        } | 
|             for (LedSlave led : slaveProperties.getLed()) { | 
|                 // 获取输送线plc线程 | 
|                 DevpThread devpThread = (DevpThread) SlaveConnection.get(SlaveType.Devp, led.getDevpPlcId()); | 
|                 // 命令集合 | 
|                 boolean reset = true; | 
|                 for (Integer staNo : led.getStaArr()) { | 
|                     // 获取叉车站点 | 
|                     StaProtocol staProtocol = devpThread.getStation().get(staNo); | 
|                     if (staProtocol == null) { | 
|                         continue; | 
|                     } | 
|                     if (staProtocol.isLoading()) { | 
|                         reset = false; | 
|                         break; | 
|                     } | 
|                 } | 
|                 // 获取led线程 | 
|                 LedThread ledThread = (LedThread) SlaveConnection.get(SlaveType.Led, led.getId()); | 
|                 // led显示默认内容 | 
|                 if (reset) { | 
|                     ledThread.setLedMk(true); | 
|                     if (!MessageQueue.offer(SlaveType.Led, led.getId(), new Task(2, new ArrayList<>()))) { | 
|                         log.error("{}号LED命令下发失败!!![ip:{}] [port:{}]", led.getId(), led.getIp(), led.getPort()); | 
|                     } | 
|                 } | 
|             } | 
|         } catch (Exception e) { | 
|             e.printStackTrace(); | 
|         } | 
|     } | 
|   | 
|     /** | 
|      * 四向穿梭车电量检测 ===>> 发起充电 | 
|      */ | 
|     public synchronized void loopShuttleCharge() { | 
|         try { | 
|             for (ShuttleSlave shuttle : slaveProperties.getShuttle()) { | 
|                 //获取四向穿梭车线程 | 
|                 NyShuttleThread shuttleThread = (NyShuttleThread) SlaveConnection.get(SlaveType.Shuttle, shuttle.getId()); | 
|                 NyShuttleProtocol shuttleProtocol = shuttleThread.getShuttleProtocol(); | 
|                 if (shuttleProtocol == null) { | 
|                     continue; | 
|                 } | 
|   | 
|                 //判断当前小车是否满足需要充电要求 | 
|                 if (!shuttleProtocol.isRequireCharge()) { | 
|                     continue; | 
|                 } | 
|   | 
|                 WrkCharge wrkCharge = wrkChargeService.selectWorking(shuttleProtocol.getShuttleNo().intValue()); | 
|                 if (wrkCharge != null) {//已有充电任务 | 
|                     continue; | 
|                 } | 
|   | 
|                 //小车所在楼层 | 
|                 int lev = Utils.getLev(shuttleProtocol.getCurrentLocNo()); | 
|                 ShuttleChargeType shuttleCharge = null; | 
|   | 
|                 //搜索小车所在楼层有没有充电桩 | 
|                 for (ShuttleChargeType chargeType : ShuttleChargeType.values()) { | 
|                     if (lev != Utils.getLev(chargeType.locNo)) { | 
|                         continue;//小车和充电桩不在同一层 | 
|                     } | 
|   | 
|                     //小车和充电桩在同一层 | 
|                     if (wrkChargeService.selectWorkingOfCharge(chargeType.id) == null) { | 
|                         shuttleCharge = chargeType; | 
|                         break; | 
|                     } | 
|                 } | 
|   | 
|                 if (shuttleCharge == null) { | 
|                     //同楼层没有找到充电桩,找可用充电桩 | 
|                     //小车同楼层没有充电桩,只要充电桩可用就生成充电任务 | 
|                     for (ShuttleChargeType chargeType : ShuttleChargeType.values()) { | 
|                         if (wrkChargeService.selectWorkingOfCharge(chargeType.id) == null) { | 
|                             //判断当前充电桩楼层是否有小车,如有小车,不分配该充电桩 | 
|                             int chargeLev = Utils.getLev(chargeType.locNo);//充电桩楼层 | 
|                             boolean checkLevHasShuttle = Utils.checkLevHasShuttle(chargeLev);//检测楼层是否有穿梭车 | 
|                             if (checkLevHasShuttle) { | 
|                                 //当前充电桩楼层有穿梭车,不分配该充电桩 | 
|                                 continue; | 
|                             } | 
|   | 
|                             shuttleCharge = chargeType; | 
|                             break; | 
|                         } | 
|                     } | 
|                 } | 
|   | 
|                 if (shuttleCharge == null) { | 
|                     continue; | 
|                 } | 
|   | 
|                 String chargeLocNo = shuttleCharge.locNo; | 
|                 wrkCharge = new WrkCharge(); | 
|                 wrkCharge.setShuttleNo(shuttle.getId()); | 
|                 wrkCharge.setCharge(shuttleCharge.id); | 
|                 wrkCharge.setWrkNo(commonService.getChargeWorkNo(4)); | 
|                 wrkCharge.setWrkSts(51L);   // 51.准备充电 | 
|                 wrkCharge.setIoPri((double) 10); | 
|                 wrkCharge.setLocNo(chargeLocNo); | 
|                 wrkCharge.setMemo("charge"); | 
|                 wrkCharge.setAppeTime(new Date()); | 
|                 if (!wrkChargeService.insert(wrkCharge)) { | 
|                     News.error("保存{}号四向穿梭车充电任务失败!!!", shuttle.getId()); | 
|                     continue; | 
|                 } | 
|   | 
|                 News.info("保存{}号四向穿梭车充电任务成功!!!", shuttle.getId()); | 
|             } | 
|         } catch (Exception e) { | 
|             e.printStackTrace(); | 
|         } | 
|     } | 
|   | 
|     /** | 
|      * 执行四向穿梭车充电任务 | 
|      */ | 
|     public synchronized void executeShuttleCharge() { | 
|         try { | 
|             for (ShuttleSlave shuttle : slaveProperties.getShuttle()) { | 
|                 WrkCharge wrkCharge = wrkChargeService.selectWorking(shuttle.getId()); | 
|                 if (wrkCharge == null) { | 
|                     continue; | 
|                 } | 
|   | 
|                 NyShuttleThread shuttleThread = (NyShuttleThread) SlaveConnection.get(SlaveType.Shuttle, wrkCharge.getShuttleNo()); | 
|                 if (shuttleThread == null) { | 
|                     continue; | 
|                 } | 
|                 NyShuttleProtocol shuttleProtocol = shuttleThread.getShuttleProtocol(); | 
|                 if (shuttleProtocol == null) { | 
|                     continue; | 
|                 } | 
|   | 
|                 if (wrkCharge.getWrkSts() == 51) { | 
|                     if (!shuttleProtocol.isIdleNoCharge()) { | 
|                         continue; | 
|                     } | 
|   | 
|                     if (shuttleProtocol.getSuspendState() == 1) { | 
|                         continue;//管制中 | 
|                     } | 
|   | 
|                     if (!shuttleProtocol.getCurrentLocNo().equals(wrkCharge.getLocNo())) { | 
|                         //小车不在充电桩位置 | 
|                         shuttleDispatchUtils.dispatchShuttle(wrkCharge.getWrkNo(), wrkCharge.getLocNo(), shuttle.getId());//调度小车去充电桩 | 
|                         continue; | 
|                     } | 
|   | 
|                     //小车已经在充电桩位置,下发充电命令 | 
|                     NyShuttleHttpCommand chargeCommand = NyHttpUtils.getChargeCommand(shuttle.getId(), wrkCharge.getWrkNo(), true); | 
|                     ArrayList<NyShuttleHttpCommand> commands = new ArrayList<>(); | 
|                     commands.add(chargeCommand); | 
|                     //创建分配命令 | 
|                     ShuttleAssignCommand assignCommand = new ShuttleAssignCommand(); | 
|                     assignCommand.setShuttleNo(shuttleProtocol.getShuttleNo());//四向穿梭车号 | 
|                     assignCommand.setTaskNo(wrkCharge.getWrkNo().shortValue());//任务号 | 
|                     assignCommand.setTaskMode(ShuttleTaskModeType.CHARGE.id.shortValue());//出库模式 | 
|                     assignCommand.setSourceLocNo(shuttleProtocol.getCurrentLocNo());//源库位(小车当前位置) | 
|                     assignCommand.setCommands(commands);//运行命令 | 
|   | 
|                     wrkCharge.setWrkSts(52L);//51.生成充电任务 => 52.小车去充电中 | 
|                     wrkCharge.setModiTime(new Date()); | 
|                     if (wrkChargeMapper.updateById(wrkCharge) > 0) { | 
|                         //下发任务 | 
|                         MessageQueue.offer(SlaveType.Shuttle, assignCommand.getShuttleNo().intValue(), new Task(3, assignCommand)); | 
|                     } | 
|                 } else if (wrkCharge.getWrkSts() == 52) { | 
|                     //检测小车是否满电 | 
|   | 
|                     //获取满电阈值 | 
|                     int maxPower = 95; | 
|                     EntityWrapper<Config> wrapper = new EntityWrapper<>(); | 
|                     wrapper.eq("code", "chargeMaxValue"); | 
|                     Config config = configService.selectOne(wrapper); | 
|                     if (config != null) { | 
|                         maxPower = Integer.parseInt(config.getValue()); | 
|                     } | 
|   | 
|                     if (shuttleProtocol.getPowerPercent() < maxPower) { | 
|                         continue; | 
|                     } | 
|   | 
|                     //***************判断是否满充校准*************** | 
|                     EntityWrapper<Config> wrapper1 = new EntityWrapper<>(); | 
|                     wrapper.eq("code", "shuttleMaxPowerVerify"); | 
|                     Config config1 = configService.selectOne(wrapper1); | 
|                     if (config1 != null) { | 
|                         if (config1.getValue().equals("true")) { | 
|                             if (shuttleProtocol.getVoltage() < 5630) { | 
|                                 continue;//电压不够继续充电 | 
|                             } | 
|                         } | 
|                     } | 
|                     //***************判断是否满充校准*************** | 
|   | 
|                     //小车满电,结束充电任务 | 
|                     NyShuttleHttpCommand chargeCommand = NyHttpUtils.getChargeCommand(shuttle.getId(), wrkCharge.getWrkNo(), false); | 
|                     ArrayList<NyShuttleHttpCommand> commands = new ArrayList<>(); | 
|                     commands.add(chargeCommand); | 
|                     //创建分配命令 | 
|                     ShuttleAssignCommand assignCommand = new ShuttleAssignCommand(); | 
|                     assignCommand.setShuttleNo(shuttleProtocol.getShuttleNo());//四向穿梭车号 | 
|                     assignCommand.setTaskNo(wrkCharge.getWrkNo().shortValue());//任务号 | 
|                     assignCommand.setTaskMode(ShuttleTaskModeType.CHARGE.id.shortValue());//出库模式 | 
|                     assignCommand.setSourceLocNo(shuttleProtocol.getCurrentLocNo());//源库位(小车当前位置) | 
|                     assignCommand.setCommands(commands);//运行命令 | 
|   | 
|                     //下发任务 | 
|                     MessageQueue.offer(SlaveType.Shuttle, assignCommand.getShuttleNo().intValue(), new Task(3, assignCommand)); | 
|                     try { | 
|                         Thread.sleep(3000); | 
|                     } catch (Exception e) { | 
|                         e.printStackTrace(); | 
|                     } | 
|   | 
|                     wrkCharge.setWrkSts(53L);//52.小车去充电中 => 53.小车充电完成 | 
|                     wrkCharge.setModiTime(new Date()); | 
|                     if (wrkChargeMapper.updateById(wrkCharge) > 0) { | 
|                         shuttleProtocol.setProtocolStatus(ShuttleProtocolStatusType.IDLE.id); | 
|                         shuttleProtocol.setTaskNo(0); | 
|                         shuttleProtocol.setPakMk(false); | 
|                     } | 
|                 } else if (wrkCharge.getWrkSts() == 53) { | 
|                     if (shuttleProtocol.getChargState() == 0) {//小车处于未充电状态 | 
|                         boolean result = Utils.searchEmptyGroupToMoveShuttle(Utils.getLev(wrkCharge.getLocNo()), shuttleThread.getSlave().getId(), shuttleThread); | 
|                         if (!result) { | 
|                             continue; | 
|                         } | 
|   | 
|                         wrkCharge.setWrkSts(60L);//53.小车充电完成 => 60.充电任务完成 | 
|                         wrkCharge.setModiTime(new Date()); | 
|                         if (wrkChargeMapper.updateById(wrkCharge) > 0) { | 
|   | 
|                         } | 
|                     } | 
|                 } | 
|   | 
|             } | 
|         } catch (Exception e) { | 
|             e.printStackTrace(); | 
|         } | 
|     } | 
|   | 
|     /** | 
|      * 执行小车移库任务 | 
|      */ | 
|     public synchronized void shuttleMoveExecute() { | 
|         try { | 
|             //查询小车移库任务 | 
|             List<WrkMast> wrkMasts = wrkMastMapper.selectShuttleMoveWrk(); | 
|             for (WrkMast wrkMast : wrkMasts) { | 
|                 boolean stepMoveSta = this.shuttleMoveExecuteStepMoveSta(wrkMast);//小车移动到站点 | 
|                 if (!stepMoveSta) { | 
|                     continue; | 
|                 } | 
|   | 
|                 boolean stepIntoLift = this.shuttleMoveExecuteStepIntoLift(wrkMast);//小车迁入提升机 | 
|                 if (!stepIntoLift) { | 
|                     continue; | 
|                 } | 
|   | 
|                 boolean stepLiftMove = this.shuttleMoveExecuteStepLiftMove(wrkMast);//提升机搬运中 | 
|                 if (!stepLiftMove) { | 
|                     continue; | 
|                 } | 
|   | 
|                 boolean stepOutLift = this.shuttleMoveExecuteStepOutLift(wrkMast);//小车迁出提升机 | 
|                 if (!stepOutLift) { | 
|                     continue; | 
|                 } | 
|   | 
|                 boolean stepMoveLoc = this.shuttleMoveExecuteStepMoveLoc(wrkMast);//小车移动到目标库位中 | 
|                 if (!stepMoveLoc) { | 
|                     continue; | 
|                 } | 
|   | 
|             } | 
|         } catch (Exception e) { | 
|             e.printStackTrace(); | 
|         } | 
|     } | 
|   | 
|     /** | 
|      * 小车迁移-小车移动到站点 | 
|      * 如需主方法执行continue,请返回false | 
|      * ps:返回值true并不代表该方法执行成功,返回值仅做标记用于主方法是否执行continue | 
|      */ | 
|     private boolean shuttleMoveExecuteStepMoveSta(WrkMast wrkMast) { | 
|         //--------------------------------------小车移动至站点-----------------------------------------// | 
|         Date now = new Date(); | 
|   | 
|         //小车移动至站点  101.生成小车移库任务 ==> 102.小车移动至站点中 | 
|         if (wrkMast.getWrkSts() == 101) { | 
|             //获取四向穿梭车线程 | 
|             NyShuttleThread shuttleThread = (NyShuttleThread) SlaveConnection.get(SlaveType.Shuttle, wrkMast.getShuttleNo()); | 
|             if (shuttleThread == null) { | 
|                 return false; | 
|             } | 
|             NyShuttleProtocol shuttleProtocol = shuttleThread.getShuttleProtocol(); | 
|             if (shuttleProtocol == null) { | 
|                 return false; | 
|             } | 
|   | 
|             //小车处于空闲状态 | 
|             if (!shuttleProtocol.isIdleNoCharge(wrkMast.getWrkNo())) { | 
|                 News.info("{}任务,{}小车,小车忙碌中", wrkMast.getWrkNo(), shuttleProtocol.getShuttleNo()); | 
|                 return false; | 
|             } | 
|   | 
|             //判断小车令牌是否未被占领 | 
|             if (shuttleProtocol.getToken() != 0) { | 
|                 News.info("{}任务,{}小车,令牌已被独占,禁止派发", wrkMast.getWrkNo(), shuttleProtocol.getShuttleNo()); | 
|                 return false;//小车已被独占,禁止再派发任务 | 
|             } | 
|   | 
|             if (Utils.getLev(wrkMast.getLocNo()) == shuttleProtocol.getPoint().getZ()) { | 
|                 //目标库位和小车库位处于同一楼层,不需要通过提升机调度 | 
|                 wrkMast.setWrkSts(109L);// 109.小车迁出提升机完成 ==> 110.小车移动中 | 
|                 wrkMast.setModiTime(now); | 
|                 shuttleProtocol.setToken(wrkMast.getWrkNo());//独占该小车令牌 | 
|                 if (wrkMastMapper.updateById(wrkMast) > 0) { | 
|                     //下发任务 | 
|                     return true;//直接进入109.小车迁出提升机完成 ==> 110.小车移动中 | 
|                 } | 
|                 return false; | 
|             } | 
|   | 
|             //获取源输送站 | 
|             LiftStaProtocol liftSta = NyLiftUtils.getLiftStaByStaNo(wrkMast.getSourceStaNo()); | 
|             if (liftSta == null) { | 
|                 return false;//找不到站点 | 
|             } | 
|   | 
|             //判断提升机是否有其他任务(该任务需要换层必须提前独占提升机) | 
|             WrkMast liftWrkMast = wrkMastMapper.selectLiftWrkMast(liftSta.getLiftNo()); | 
|             if (liftWrkMast != null) { | 
|                 News.info("{}任务,{}号提升机,提升机存在未完成任务,禁止派发", wrkMast.getWrkNo(), liftSta.getLiftNo()); | 
|                 return false;//当前提升机存在未完成任务,等待下一次轮询 | 
|             } | 
|   | 
|             //*************尝试锁定目标站路径*************** | 
|             List<NavigateNode> targetNodes = NyLiftUtils.getLiftStaNodes(wrkMast.getStaNo()); | 
|             if (targetNodes == null) { | 
|                 return false;//未获取到节点 | 
|             } | 
|             boolean checkPathIsAvailable = NavigateUtils.checkPathIsAvailable(targetNodes, shuttleProtocol.getShuttleNo().intValue(), Utils.getLev(wrkMast.getLocNo()), null); | 
|             if (!checkPathIsAvailable) { | 
|                 News.info("{}任务,{}小车,目标站点路径被占用,禁止派发", wrkMast.getWrkNo(), shuttleProtocol.getShuttleNo()); | 
|                 return false;//检测目标站点路径是否未被占用 | 
|             } | 
|             //尝试锁定目标站路径 | 
|             boolean result2 = navigateMapUtils.writeNavigateNodeToRedisMap(Utils.getLev(wrkMast.getLocNo()), shuttleProtocol.getShuttleNo().intValue(), targetNodes, true);//所使用的路径进行锁定禁用 | 
|             if (!result2) { | 
|                 News.info("{}任务,{}小车,路径锁定失败,禁止派发", wrkMast.getWrkNo(), shuttleProtocol.getShuttleNo()); | 
|                 return false;//路径锁定失败 | 
|             } | 
|             //*************尝试锁定目标站路径*************** | 
|   | 
|             //获取小车到输送站点行走命令 | 
|             NyShuttleOperaResult result = NyShuttleOperaUtils.getStartToTargetCommands(shuttleThread.getSlave().getId(), wrkMast.getWrkNo(), shuttleProtocol.getCurrentLocNo(), liftSta.getLocNo(), NavigationMapType.NORMAL.id); | 
|             if (result == null) { | 
|                 //路径获取失败,需要解锁上面锁定的路径 | 
|                 //尝试解锁目标站路径 | 
|                 boolean result3 = navigateMapUtils.writeNavigateNodeToRedisMap(Utils.getLev(wrkMast.getLocNo()), shuttleProtocol.getShuttleNo().intValue(), targetNodes, false);//所使用的路径进行解锁 | 
|                 if (!result3) { | 
|                     News.info("{}任务,{}小车,路径解锁失败", wrkMast.getWrkNo(), shuttleProtocol.getShuttleNo()); | 
|                     return false;//路径解锁失败 | 
|                 } | 
|                 News.info("{}任务,{}小车,路径计算失败", wrkMast.getWrkNo(), shuttleProtocol.getShuttleNo()); | 
|                 return false;//路径解锁失败 | 
|             } | 
|             List<NyShuttleHttpCommand> commands = result.getCommands(); | 
|   | 
|             ShuttleAssignCommand assignCommand = new ShuttleAssignCommand(); | 
|             assignCommand.setShuttleNo(shuttleProtocol.getShuttleNo()); // 四向穿梭车编号 | 
|             assignCommand.setTaskMode(ShuttleTaskModeType.SHUTTLE_MOVE_LOC_NO.id.shortValue());//小车移库任务 | 
|             assignCommand.setTaskNo(wrkMast.getWrkNo().shortValue());//任务号 | 
|             assignCommand.setAuto(true);//自动模式 | 
|             assignCommand.setCommands(commands); | 
|             assignCommand.setNodes(result.getNodes()); | 
|   | 
|             wrkMast.setWrkSts(102L);//小车移动到提升机中  101.生成小车移库任务 ==> 102.小车移动至站点 | 
|             wrkMast.setModiTime(now); | 
|             wrkMast.setLiftNo(liftSta.getLiftNo());//提前锁定提升机 | 
|             shuttleProtocol.setToken(wrkMast.getWrkNo());//独占该小车令牌 | 
|             if (wrkMastMapper.updateById(wrkMast) > 0) { | 
|                 //下发任务 | 
|                 MessageQueue.offer(SlaveType.Shuttle, assignCommand.getShuttleNo().intValue(), new Task(3, assignCommand)); | 
|                 return false; | 
|             } | 
|             return false; | 
|         } | 
|         return true; | 
|     } | 
|   | 
|     /** | 
|      * 小车迁移-小车迁入提升机 | 
|      * 如需主方法执行continue,请返回false | 
|      * ps:返回值true并不代表该方法执行成功,返回值仅做标记用于主方法是否执行continue | 
|      */ | 
|     private boolean shuttleMoveExecuteStepIntoLift(WrkMast wrkMast) { | 
|         //--------------------------------------小车迁入提升机-----------------------------------------// | 
|         Date now = new Date(); | 
|   | 
|         //小车移动到提升机中  103.小车移动至站点完成 ==> 104.小车迁入提升机中 | 
|         if (wrkMast.getWrkSts() == 103) { | 
|             //获取源站 | 
|             LiftStaProtocol sourceLiftSta = NyLiftUtils.getLiftStaByStaNo(wrkMast.getSourceStaNo()); | 
|             if (sourceLiftSta == null) { | 
|                 return false;//找不到站点 | 
|             } | 
|   | 
|             //获取目标输送站 | 
|             LiftStaProtocol liftSta = NyLiftUtils.getLiftStaByStaNo(wrkMast.getStaNo()); | 
|             if (liftSta == null) { | 
|                 return false;//找不到站点 | 
|             } | 
|   | 
|             //获取提升机数据 | 
|             BasLift basLift = basLiftService.selectById(liftSta.getLiftNo()); | 
|             if (basLift == null) { | 
|                 return false;//没有提升机数据 | 
|             } | 
|   | 
|             if (basLift.getPoint() == null) { | 
|                 News.info("{}任务,{}号提升机,没有提升机点位坐标,禁止派发", wrkMast.getWrkNo(), basLift.getLiftNo()); | 
|                 return false;//没有设置提升机点位坐标 | 
|             } | 
|   | 
|             //判断提升机是否有其他任务 | 
|             WrkMast liftWrkMast = wrkMastMapper.selectLiftWrkMast(basLift.getLiftNo()); | 
|             if (liftWrkMast != null) { | 
|                 if (!liftWrkMast.getWrkNo().equals(wrkMast.getWrkNo())) {//提升机任务和当前任务不相同 | 
|                     News.info("{}任务,{}号提升机,提升机存在未完成任务,禁止派发", wrkMast.getWrkNo(), basLift.getLiftNo()); | 
|                     return false;//当前提升机存在未完成任务,等待下一次轮询 | 
|                 } | 
|             } | 
|   | 
|             LiftThread liftThread = (LiftThread) SlaveConnection.get(SlaveType.Lift, liftSta.getLiftNo()); | 
|             if (liftThread == null) { | 
|                 return false; | 
|             } | 
|             LiftProtocol liftProtocol = liftThread.getLiftProtocol(); | 
|             if (liftProtocol == null) { | 
|                 return false; | 
|             } | 
|   | 
|             if (!liftProtocol.isIdle(wrkMast.getWrkNo().shortValue())) { | 
|                 News.info("{}任务,{}号提升机,提升机忙碌中,禁止派发", wrkMast.getWrkNo(), basLift.getLiftNo()); | 
|                 return false; | 
|             } | 
|   | 
|             //获取四向穿梭车线程 | 
|             NyShuttleThread shuttleThread = (NyShuttleThread) SlaveConnection.get(SlaveType.Shuttle, wrkMast.getShuttleNo()); | 
|             if (shuttleThread == null) { | 
|                 return false; | 
|             } | 
|             NyShuttleProtocol shuttleProtocol = shuttleThread.getShuttleProtocol(); | 
|             if (shuttleProtocol == null) { | 
|                 return false; | 
|             } | 
|   | 
|             //小车处于空闲状态 | 
|             if (!shuttleProtocol.isIdleNoCharge(wrkMast.getWrkNo())) { | 
|                 News.info("{}任务,{}小车,小车忙碌中,禁止派发", wrkMast.getWrkNo(), shuttleProtocol.getShuttleNo()); | 
|                 return false; | 
|             } | 
|   | 
|             //小车令牌是否被任务独占 | 
|             if (!shuttleProtocol.getToken().equals(wrkMast.getWrkNo())) { | 
|                 News.info("{}任务,{}小车,小车令牌被独占,禁止派发", wrkMast.getWrkNo(), shuttleProtocol.getShuttleNo()); | 
|                 return false; | 
|             } | 
|   | 
|             //判断提升机楼层 | 
|             if (liftProtocol.getLev().intValue() != shuttleProtocol.getPoint().getZ()) { | 
|                 //提升机不在小车楼层 | 
|                 //调度提升机 | 
|   | 
|                 if (liftProtocol.getToken() != 0) { | 
|                     News.info("{}任务,{}号提升机,提升机令牌被独占,禁止派发", wrkMast.getWrkNo(), liftProtocol.getLiftNo()); | 
|                     return false;//提升机令牌被占用 | 
|                 } | 
|   | 
|                 //获取提升机命令,调度提升机到源站位置 | 
|                 NyLiftCommand liftCommand = NyLiftUtils.getLiftCommand(liftProtocol.getLiftNo().intValue(), NyLiftTaskModelType.MOVE_CAR.id, sourceLiftSta.getStaNo(), sourceLiftSta.getStaNo(), wrkMast.getWrkNo()); | 
|   | 
|                 int deviceWrk = commonService.getWorkNo(8);//生成提升机设备工作号 | 
|                 BasLiftOpt basLiftOpt = basLiftOptService.selectByDeviceWrk(String.valueOf(deviceWrk), liftThread.getSlave().getId()); | 
|                 if (basLiftOpt != null) { | 
|                     News.info("{}任务,{}号提升机,设备工作号出现重复情况,请联系技术人员支持。", wrkMast.getWrkNo(), liftProtocol.getLiftNo()); | 
|                     return false; | 
|                 } | 
|                 liftCommand.setTaskNo((short) deviceWrk);//更换随机任务号 | 
|   | 
|                 ArrayList<NyLiftCommand> commands = new ArrayList<>(); | 
|                 commands.add(liftCommand); | 
|   | 
|                 //提交到线程去工作 | 
|                 LiftAssignCommand assignCommand = new LiftAssignCommand(); | 
|                 assignCommand.setCommands(commands); | 
|                 assignCommand.setLiftNo(liftProtocol.getLiftNo()); | 
|                 assignCommand.setTaskNo(wrkMast.getWrkNo().shortValue()); | 
|                 assignCommand.setTaskMode(NyLiftTaskModelType.MOVE_CAR.id.shortValue()); | 
|                 assignCommand.setAuto(false); | 
|   | 
|                 wrkMast.setLiftNo(liftThread.getSlave().getId());//锁定提升机防止被占用 | 
|                 wrkMast.setModiTime(now); | 
|                 liftProtocol.setToken(wrkMast.getShuttleNo());//提升机令牌绑定当前小车 | 
|                 if (wrkMastMapper.updateById(wrkMast) > 0) { | 
|                     //下发任务 | 
|                     MessageQueue.offer(SlaveType.Lift, liftProtocol.getLiftNo().intValue(), new Task(3, assignCommand)); | 
|                 } | 
|                 return false;//等待提升机到小车楼层 | 
|             } | 
|   | 
|             if (liftProtocol.getToken() == 0) {//提升机令牌未被占用 | 
|                 //独占提升机 | 
|                 liftProtocol.setToken(wrkMast.getShuttleNo()); | 
|                 return false;//等待下一次执行 | 
|             } | 
|   | 
|             //判断提升机令牌是否为当前小车 | 
|             if (!liftProtocol.getToken().equals(wrkMast.getShuttleNo())) { | 
|                 News.info("{}任务,{}号提升机,提升机令牌被独占,禁止派发", wrkMast.getWrkNo(), liftProtocol.getLiftNo()); | 
|                 return false;//提升机已被独占,禁止再派发任务 | 
|             } | 
|   | 
|             //判断小车是否为当前任务独占 | 
|             if (!shuttleProtocol.getToken().equals(wrkMast.getWrkNo())) { | 
|                 News.info("{}任务,{}小车,小车令牌被独占,禁止派发", wrkMast.getWrkNo(), shuttleProtocol.getShuttleNo()); | 
|                 return false; | 
|             } | 
|   | 
|             //站点节点 | 
|             NavigateNode staNode = NavigatePositionConvert.locNoToNode(sourceLiftSta.getLocNo()); | 
|   | 
|             //提升机节点 | 
|             NavigateNode liftNode = new NavigateNode(basLift.getPoint$().getX(), basLift.getPoint$().getY()); | 
|             liftNode.setZ(staNode.getZ()); | 
|   | 
|             //获取小车进提升机行走命令 | 
|             NyShuttleHttpCommand moveCommand = NyHttpUtils.getInOutLiftCommand(wrkMast.getShuttleNo(), wrkMast.getWrkNo(), staNode, liftNode, true); | 
|             List<NyShuttleHttpCommand> commands = new ArrayList<>(); | 
|             commands.add(moveCommand); | 
|             List<NavigateNode> nodes = new ArrayList<>();//行走节点路径 | 
|             nodes.add(staNode); | 
|             nodes.add(liftNode); | 
|   | 
|             ShuttleAssignCommand assignCommand = new ShuttleAssignCommand(); | 
|             assignCommand.setShuttleNo(shuttleProtocol.getShuttleNo()); // 四向穿梭车编号 | 
|             assignCommand.setTaskMode(ShuttleTaskModeType.SHUTTLE_MOVE_LOC_NO.id.shortValue());//小车移库任务 | 
|             assignCommand.setTaskNo(wrkMast.getWrkNo().shortValue());//任务号 | 
|             assignCommand.setAuto(true);//自动模式 | 
|             assignCommand.setCommands(commands); | 
|             assignCommand.setNodes(nodes); | 
|   | 
|             wrkMast.setWrkSts(104L);//小车移动到提升机中  103.小车移动至站点完成 ==> 104.小车迁入提升机中 | 
|             wrkMast.setModiTime(now); | 
|             wrkMast.setLiftNo(liftThread.getSlave().getId());//锁定提升机防止被占用 | 
|             liftProtocol.setToken(wrkMast.getShuttleNo());//提升机令牌绑定当前小车 | 
|             if (wrkMastMapper.updateById(wrkMast) > 0) { | 
|                 //下发任务 | 
|                 MessageQueue.offer(SlaveType.Shuttle, assignCommand.getShuttleNo().intValue(), new Task(3, assignCommand)); | 
|                 return false; | 
|             } | 
|             return false; | 
|         } | 
|   | 
|         return true; | 
|     } | 
|   | 
|     /** | 
|      * 小车迁移-提升机搬运中 | 
|      * 如需主方法执行continue,请返回false | 
|      * ps:返回值true并不代表该方法执行成功,返回值仅做标记用于主方法是否执行continue | 
|      */ | 
|     private boolean shuttleMoveExecuteStepLiftMove(WrkMast wrkMast) { | 
|         //--------------------------------------提升机搬运中-----------------------------------------// | 
|         Date now = new Date(); | 
|   | 
|         //提升机搬运中  105.小车迁入提升机完成 ==> 106.提升机搬运中 | 
|         if (wrkMast.getWrkSts() == 105) { | 
|   | 
|             LiftThread liftThread = (LiftThread) SlaveConnection.get(SlaveType.Lift, wrkMast.getLiftNo()); | 
|             if (liftThread == null) { | 
|                 return false; | 
|             } | 
|             LiftProtocol liftProtocol = liftThread.getLiftProtocol(); | 
|             if (liftProtocol == null) { | 
|                 return false; | 
|             } | 
|             if (!liftProtocol.isIdle(wrkMast.getWrkNo().shortValue())) { | 
|                 News.info("{}任务,{}号提升机,提升机忙碌中,禁止派发", wrkMast.getWrkNo(), liftProtocol.getLiftNo()); | 
|                 return false; | 
|             } | 
|             //判断提升机是否有其他任务 | 
|             WrkMast liftWrkMast = wrkMastMapper.selectLiftWrkMast(liftThread.getSlave().getId()); | 
|             if (liftWrkMast != null) { | 
|                 if (!liftWrkMast.getWrkNo().equals(wrkMast.getWrkNo())) {//提升机任务和当前任务不相同 | 
|                     News.info("{}任务,{}号提升机,提升机存在未完成任务,禁止派发", wrkMast.getWrkNo(), liftProtocol.getLiftNo()); | 
|                     return false;//当前提升机存在未完成任务,等待下一次轮询 | 
|                 } | 
|             } | 
|   | 
|             //判断提升机令牌是否为当前小车 | 
|             if (!liftProtocol.getToken().equals(wrkMast.getShuttleNo())) { | 
|                 News.info("{}任务,{}号提升机,提升机令牌和当前小车不一致,禁止派发", wrkMast.getWrkNo(), liftProtocol.getLiftNo()); | 
|                 return false;//提升机令牌和当前小车不一致,禁止派发 | 
|             } | 
|   | 
|             //判断提升机内是否有小车 | 
|             if (!liftProtocol.getHasCar()) { | 
|                 News.info("{}任务,{}号提升机,提升机内无小车,禁止派发", wrkMast.getWrkNo(), liftProtocol.getLiftNo()); | 
|                 return false;//提升机内无小车 | 
|             } | 
|   | 
|             //获取四向穿梭车线程 | 
|             NyShuttleThread shuttleThread = (NyShuttleThread) SlaveConnection.get(SlaveType.Shuttle, wrkMast.getShuttleNo()); | 
|             if (shuttleThread == null) { | 
|                 return false; | 
|             } | 
|             NyShuttleProtocol shuttleProtocol = shuttleThread.getShuttleProtocol(); | 
|             if (shuttleProtocol == null) { | 
|                 return false; | 
|             } | 
|   | 
|             //小车处于空闲状态 | 
|             if (!shuttleProtocol.isIdleNoCharge()) { | 
|                 News.info("{}任务,{}号提升机,提升机忙碌中,禁止派发", wrkMast.getWrkNo(), liftProtocol.getLiftNo()); | 
|                 return false; | 
|             } | 
|   | 
|             //判断小车是否为当前任务独占 | 
|             if (!shuttleProtocol.getToken().equals(wrkMast.getWrkNo())) { | 
|                 News.info("{}任务,{}小车,小车当前任务未被独占,禁止派发", wrkMast.getWrkNo(), shuttleProtocol.getShuttleNo()); | 
|                 return false; | 
|             } | 
|   | 
|             //获取源站 | 
|             LiftStaProtocol sourceLiftSta = NyLiftUtils.getLiftStaByStaNo(wrkMast.getSourceStaNo()); | 
|             //获取目标站 | 
|             LiftStaProtocol liftSta = NyLiftUtils.getLiftStaByStaNo(wrkMast.getStaNo()); | 
|             if (sourceLiftSta == null || liftSta == null) { | 
|                 News.info("{}任务,缺少站点信息,禁止派发", wrkMast.getWrkNo()); | 
|                 return false;//缺少站点信息 | 
|             } | 
|   | 
|             //获取提升机命令 | 
|             NyLiftCommand liftCommand = NyLiftUtils.getLiftCommand(liftProtocol.getLiftNo().intValue(), NyLiftTaskModelType.MOVE_CAR.id, sourceLiftSta.getStaNo(), liftSta.getStaNo(), wrkMast.getWrkNo()); | 
|   | 
|             ArrayList<NyLiftCommand> commands = new ArrayList<>(); | 
|             commands.add(liftCommand); | 
|   | 
|             //提交到线程去工作 | 
|             LiftAssignCommand assignCommand = new LiftAssignCommand(); | 
|             assignCommand.setCommands(commands); | 
|             assignCommand.setLiftNo(liftProtocol.getLiftNo()); | 
|             assignCommand.setTaskNo(wrkMast.getWrkNo().shortValue()); | 
|             assignCommand.setTaskMode(NyLiftTaskModelType.MOVE_CAR.id.shortValue()); | 
|   | 
|             wrkMast.setWrkSts(106L);//提升机搬运中  105.小车迁入提升机完成 ==> 106.提升机搬运中 | 
|             wrkMast.setLiftNo(liftThread.getSlave().getId());//锁定提升机防止被占用 | 
|             wrkMast.setModiTime(now); | 
|             if (wrkMastMapper.updateById(wrkMast) > 0) { | 
|                 //下发任务 | 
|                 MessageQueue.offer(SlaveType.Lift, liftProtocol.getLiftNo().intValue(), new Task(3, assignCommand)); | 
|             } | 
|   | 
|         } | 
|         return true; | 
|     } | 
|   | 
|     /** | 
|      * 小车迁移-小车迁出提升机 | 
|      * 如需主方法执行continue,请返回false | 
|      * ps:返回值true并不代表该方法执行成功,返回值仅做标记用于主方法是否执行continue | 
|      */ | 
|     private boolean shuttleMoveExecuteStepOutLift(WrkMast wrkMast) { | 
|         //--------------------------------------小车迁出提升机-----------------------------------------// | 
|         Date now = new Date(); | 
|         //小车移动到提升机中  107.提升机搬运完成 ==> 108.小车迁出提升机中 | 
|         if (wrkMast.getWrkSts() == 107) { | 
|   | 
|             LiftThread liftThread = (LiftThread) SlaveConnection.get(SlaveType.Lift, wrkMast.getLiftNo()); | 
|             if (liftThread == null) { | 
|                 return false; | 
|             } | 
|             LiftProtocol liftProtocol = liftThread.getLiftProtocol(); | 
|             if (liftProtocol == null) { | 
|                 return false; | 
|             } | 
|             if (!liftProtocol.isIdle(wrkMast.getWrkNo().shortValue())) { | 
|                 News.info("{}任务,{}号提升机,提升机忙碌中,禁止派发", wrkMast.getWrkNo(), liftProtocol.getLiftNo()); | 
|                 return false; | 
|             } | 
|   | 
|             //判断提升机是否有其他任务 | 
|             WrkMast liftWrkMast = wrkMastMapper.selectLiftWrkMast(liftThread.getSlave().getId()); | 
|             if (liftWrkMast != null) { | 
|                 if (!liftWrkMast.getWrkNo().equals(wrkMast.getWrkNo())) {//提升机任务和当前任务不相同 | 
|                     News.info("{}任务,{}号提升机,提升机存在未完成任务,禁止派发", wrkMast.getWrkNo(), liftProtocol.getLiftNo()); | 
|                     return false;//当前提升机存在未完成任务,等待下一次轮询 | 
|                 } | 
|             } | 
|   | 
|             //判断提升机令牌是否为当前小车 | 
|             if (!liftProtocol.getToken().equals(wrkMast.getShuttleNo())) { | 
|                 News.info("{}任务,{}号提升机,提升机令牌和当前小车不一致,禁止派发", wrkMast.getWrkNo(), liftProtocol.getLiftNo()); | 
|                 return false;//提升机令牌和当前小车不一致,禁止派发 | 
|             } | 
|   | 
|             //获取四向穿梭车线程 | 
|             NyShuttleThread shuttleThread = (NyShuttleThread) SlaveConnection.get(SlaveType.Shuttle, wrkMast.getShuttleNo()); | 
|             if (shuttleThread == null) { | 
|                 return false; | 
|             } | 
|             NyShuttleProtocol shuttleProtocol = shuttleThread.getShuttleProtocol(); | 
|             if (shuttleProtocol == null) { | 
|                 return false; | 
|             } | 
|   | 
|             //小车处于空闲状态 | 
|             if (!shuttleProtocol.isIdleNoCharge()) { | 
|                 News.info("{}任务,{}小车,小车忙碌中,禁止派发", wrkMast.getWrkNo(), shuttleProtocol.getShuttleNo()); | 
|                 return false; | 
|             } | 
|   | 
|             //判断小车是否为当前任务独占 | 
|             if (!shuttleProtocol.getToken().equals(wrkMast.getWrkNo())) { | 
|                 News.info("{}任务,{}小车,小车令牌被独占,禁止派发", wrkMast.getWrkNo(), shuttleProtocol.getShuttleNo()); | 
|                 return false; | 
|             } | 
|   | 
|             //获取目标站 | 
|             LiftStaProtocol liftSta = NyLiftUtils.getLiftStaByStaNo(wrkMast.getStaNo()); | 
|             if (liftSta == null) { | 
|                 return false;//找不到站点 | 
|             } | 
|   | 
|             //获取提升机数据 | 
|             BasLift basLift = basLiftService.selectById(liftProtocol.getLiftNo().intValue()); | 
|             if (basLift == null) { | 
|                 return false;//没有提升机数据 | 
|             } | 
|             if (basLift.getPoint() == null) { | 
|                 News.info("{}任务,{}号提升机,缺少提升机点位坐标,禁止派发", wrkMast.getWrkNo(), liftProtocol.getLiftNo()); | 
|                 return false;//没有设置提升机点位坐标 | 
|             } | 
|   | 
|             NavigateNode liftNode = new NavigateNode(basLift.getPoint$().getX(), basLift.getPoint$().getY()); | 
|             liftNode.setZ(liftSta.getLev()); | 
|   | 
|             List<NyShuttleHttpCommand> commands = new ArrayList<>(); | 
|             //获取小车更新楼层命令 | 
|             NyShuttleHttpCommand updateZCommand = NyHttpUtils.getUpdateZCommand(shuttleThread.getSlave().getId(), liftProtocol.getLev().intValue(), wrkMast.getWrkNo()); | 
|             commands.add(updateZCommand); | 
|   | 
|             //获取小车出提升机行走命令 | 
|             NyShuttleHttpCommand moveCommand = NyHttpUtils.getInOutLiftCommand(shuttleThread.getSlave().getId(), wrkMast.getWrkNo(), liftNode, NavigatePositionConvert.locNoToNode(liftSta.getLocNo()), false); | 
|             commands.add(moveCommand);//添加小车迁出提升机命令 | 
|   | 
|             ShuttleAssignCommand assignCommand = new ShuttleAssignCommand(); | 
|             assignCommand.setShuttleNo(shuttleProtocol.getShuttleNo()); // 四向穿梭车编号 | 
|             assignCommand.setTaskMode(ShuttleTaskModeType.SHUTTLE_MOVE_LOC_NO.id.shortValue());//小车移库任务 | 
|             assignCommand.setTaskNo(wrkMast.getWrkNo().shortValue());//任务号 | 
|             assignCommand.setAuto(true);//自动模式 | 
|             assignCommand.setCommands(commands); | 
|             assignCommand.setNodes(null); | 
|   | 
|             wrkMast.setWrkSts(108L);//小车迁出提升机中  107.提升机搬运完成 ==> 108.小车迁出提升机中 | 
|             wrkMast.setModiTime(now); | 
|             if (wrkMastMapper.updateById(wrkMast) > 0) { | 
|                 //下发任务 | 
|                 MessageQueue.offer(SlaveType.Shuttle, assignCommand.getShuttleNo().intValue(), new Task(3, assignCommand)); | 
|                 return false; | 
|             } | 
|             return false; | 
|         } | 
|         return true; | 
|     } | 
|   | 
|     /** | 
|      * 小车迁移-小车移动到目标库位中 | 
|      * 如需主方法执行continue,请返回false | 
|      * ps:返回值true并不代表该方法执行成功,返回值仅做标记用于主方法是否执行continue | 
|      */ | 
|     private boolean shuttleMoveExecuteStepMoveLoc(WrkMast wrkMast) { | 
|         //--------------------------------------小车移动到目标库位中-----------------------------------------// | 
|         Date now = new Date(); | 
|   | 
|         //小车移动到目标库位中  109.小车迁出提升机完成 ==> 110.小车移动中 | 
|         if (wrkMast.getWrkSts() == 109) { | 
|   | 
|             //获取四向穿梭车线程 | 
|             NyShuttleThread shuttleThread = (NyShuttleThread) SlaveConnection.get(SlaveType.Shuttle, wrkMast.getShuttleNo()); | 
|             if (shuttleThread == null) { | 
|                 return false; | 
|             } | 
|             NyShuttleProtocol shuttleProtocol = shuttleThread.getShuttleProtocol(); | 
|             if (shuttleProtocol == null) { | 
|                 return false; | 
|             } | 
|   | 
|             //小车处于空闲状态 | 
|             if (!shuttleProtocol.isIdleNoCharge(wrkMast.getWrkNo())) { | 
|                 News.info("{}任务,{}小车,小车忙碌中,禁止派发", wrkMast.getWrkNo(), shuttleProtocol.getShuttleNo()); | 
|                 return false; | 
|             } | 
|   | 
|             //判断小车令牌是否为当前任务 | 
|             if (shuttleProtocol.getToken() != 0 && !shuttleProtocol.getToken().equals(wrkMast.getWrkNo())) { | 
|                 News.info("{}任务,{}小车,小车令牌被独占,禁止派发", wrkMast.getWrkNo(), shuttleProtocol.getShuttleNo()); | 
|                 return false; | 
|             } | 
|   | 
| //            //跨楼层移动任务 | 
| //            if (Utils.getLev(wrkMast.getSourceLocNo()) != Utils.getLev(wrkMast.getLocNo())) { | 
| //                //获取目标站 | 
| //                LiftStaProtocol liftSta = NyLiftUtils.getLiftStaByStaNo(wrkMast.getStaNo()); | 
| //                if (liftSta == null) { | 
| //                    return false;//找不到站点 | 
| //                } | 
| // | 
| //                //*************尝试解锁目标站路径*************** | 
| //                List<NavigateNode> targetNodes = NyLiftUtils.getLiftStaNodes(liftSta.getStaNo()); | 
| //                if (targetNodes == null) { | 
| //                    return false;//未获取到节点 | 
| //                } | 
| //                //尝试解锁目标站路径 | 
| //                boolean result = navigateMapUtils.writeNavigateNodeToRedisMap(Utils.getLev(wrkMast.getLocNo()), targetNodes, false);//所使用的路径进行解锁 | 
| //                if (!result) { | 
| //                    return false;//路径解锁失败 | 
| //                } | 
| //                //*************尝试解锁目标站路径*************** | 
| //            } | 
|   | 
|             //小车已经在目标库位,直接认定小车移动任务完成 | 
|             if (shuttleProtocol.getCurrentLocNo().equals(wrkMast.getLocNo())) { | 
|                 if (shuttleProtocol.getToken().equals(wrkMast.getWrkNo())) { | 
|                     //释放小车令牌 | 
|                     shuttleProtocol.setToken(0); | 
|                 } | 
|                 wrkMast.setWrkSts(111L);//111.小车移动完成 | 
|                 wrkMast.setLiftNo(null);//释放提升机 | 
|                 wrkMast.setModiTime(now); | 
|                 wrkMastMapper.updateById(wrkMast); | 
|   | 
|                 shuttleProtocol.setShuttleNo((short) 0);//释放小车 | 
|                 shuttleProtocol.setToken(0);//释放小车 | 
|   | 
|                 if (wrkMast.getWrkSts() == 111) { | 
|                     // 保存工作主档历史档 | 
|                     if (wrkMastLogMapper.save(wrkMast.getWrkNo()) <= 0) { | 
|                         log.info("保存工作历史档[workNo={0}]失败", wrkMast.getWrkNo()); | 
|                     } | 
|                     // 删除工作主档 | 
|                     if (!wrkMastService.deleteById(wrkMast)) { | 
|                         log.info("删除工作主档[workNo={0}]失败", wrkMast.getWrkNo()); | 
|                     } | 
|                 } | 
|                 return false; | 
|             } | 
|   | 
|             NyShuttleOperaResult result = null; | 
|             //跨楼层移动任务 | 
|             if (Utils.getLev(wrkMast.getSourceLocNo()) != Utils.getLev(wrkMast.getLocNo())) { | 
|                 //需要将前两个节点作为白名单节点传入 | 
|                 //获取目标站 | 
|                 LiftStaProtocol liftSta = NyLiftUtils.getLiftStaByStaNo(wrkMast.getStaNo()); | 
|                 if (liftSta == null) { | 
|                     return false;//找不到站点 | 
|                 } | 
|   | 
|                 List<NavigateNode> targetNodes = NyLiftUtils.getLiftStaNodes(liftSta.getStaNo()); | 
|                 if (targetNodes == null) { | 
|                     return false;//未获取到节点 | 
|                 } | 
|   | 
|                 //设置计算节点的白名单 | 
|                 ArrayList<int[]> whiteList = new ArrayList<>();//设置计算节点的白名单 | 
|                 for (NavigateNode node : targetNodes) { | 
|                     whiteList.add(new int[]{node.getX(), node.getY()}); | 
|                 } | 
|                 result = NyShuttleOperaUtils.getStartToTargetCommandsByWhites(shuttleThread.getSlave().getId(), wrkMast.getWrkNo(), shuttleProtocol.getCurrentLocNo(), wrkMast.getLocNo(), NavigationMapType.NORMAL.id, whiteList); | 
|             }else { | 
|                 //获取小车到目标库位命令 | 
|                 result = NyShuttleOperaUtils.getStartToTargetCommands(shuttleThread.getSlave().getId(), wrkMast.getWrkNo(), shuttleProtocol.getCurrentLocNo(), wrkMast.getLocNo(), NavigationMapType.NORMAL.id); | 
|             } | 
|   | 
|             if (result == null) { | 
|                 return false;//路径计算失败 | 
|             } | 
|             List<NyShuttleHttpCommand> commands = result.getCommands(); | 
|   | 
|             ShuttleAssignCommand assignCommand = new ShuttleAssignCommand(); | 
|             assignCommand.setShuttleNo(shuttleProtocol.getShuttleNo()); // 四向穿梭车编号 | 
|             assignCommand.setTaskMode(ShuttleTaskModeType.SHUTTLE_MOVE_LOC_NO.id.shortValue());//小车移库任务 | 
|             assignCommand.setTaskNo(wrkMast.getWrkNo().shortValue());//任务号 | 
|             assignCommand.setAuto(true);//自动模式 | 
|             assignCommand.setCommands(commands); | 
|             assignCommand.setNodes(result.getNodes()); | 
|             assignCommand.setSourceLocNo(shuttleProtocol.getCurrentLocNo());//源库位 | 
|             assignCommand.setLocNo(wrkMast.getLocNo());//目标库位 | 
|   | 
|             if (wrkMast.getLiftNo() != null) { | 
|                 LiftThread liftThread = (LiftThread) SlaveConnection.get(SlaveType.Lift, wrkMast.getLiftNo()); | 
|                 if (liftThread == null) { | 
|                     return false; | 
|                 } | 
|                 LiftProtocol liftProtocol = liftThread.getLiftProtocol(); | 
|                 if (liftProtocol == null) { | 
|                     return false; | 
|                 } | 
|                 if (liftProtocol.getToken().equals(shuttleProtocol.getShuttleNo().intValue())) { | 
|                     liftProtocol.setToken(0);//释放提升机令牌 | 
|                 } | 
|             } | 
|   | 
|             wrkMast.setWrkSts(110L);//小车移动到目标库位中  109.小车迁出提升机完成 ==> 110.小车移动中 | 
|             wrkMast.setLiftNo(null);//释放提升机 | 
|             wrkMast.setModiTime(now); | 
|   | 
|             if (wrkMastMapper.updateById(wrkMast) > 0) { | 
|                 //下发任务 | 
|                 MessageQueue.offer(SlaveType.Shuttle, assignCommand.getShuttleNo().intValue(), new Task(3, assignCommand)); | 
|             } | 
|         } | 
|         return true; | 
|     } | 
|   | 
|     //扫描设备PakMk标记是否超时 | 
|     public synchronized void scanDevicePakMk() { | 
|         try { | 
|             //扫描小车 | 
|             for (ShuttleSlave slave : slaveProperties.getShuttle()) { | 
|                 NyShuttleThread shuttleThread = (NyShuttleThread) SlaveConnection.get(SlaveType.Shuttle, slave.getId()); | 
|                 NyShuttleProtocol shuttleProtocol = shuttleThread.getShuttleProtocol(); | 
|                 if (shuttleProtocol == null) { | 
|                     continue; | 
|                 } | 
|   | 
|                 if ((System.currentTimeMillis() - shuttleProtocol.getSendTime() > (1000 * 60 * 5)) && shuttleProtocol.getPakMk()) { | 
|                     //设备超过5分钟还没复位标记 | 
|                     shuttleProtocol.setPakMk(false);//复位标记 | 
|                 } | 
|             } | 
|   | 
|             //扫描提升机 | 
|             for (LiftSlave slave : slaveProperties.getLift()) { | 
|                 LiftThread liftThread = (LiftThread) SlaveConnection.get(SlaveType.Lift, slave.getId()); | 
|                 LiftProtocol liftProtocol = liftThread.getLiftProtocol(); | 
|                 if (liftProtocol == null) { | 
|                     continue; | 
|                 } | 
|   | 
|                 if ((System.currentTimeMillis() - liftProtocol.getSendTime() > (1000 * 60 * 5)) && liftProtocol.getPakMk()) { | 
|                     //设备超过5分钟还没复位标记 | 
|                     liftProtocol.setPakMk(false);//复位标记 | 
|                 } | 
|             } | 
|         } catch (Exception e) { | 
|             e.printStackTrace(); | 
|         } | 
|   | 
|     } | 
|   | 
| } |