| | |
| | | import com.zy.core.properties.SlaveProperties; |
| | | import com.zy.core.thread.BarcodeThread; |
| | | import com.zy.core.thread.LedThread; |
| | | import com.zy.core.thread.RgvThread; |
| | | import com.zy.core.thread.SiemensDevpThread; |
| | | import com.zy.core.model.RgvSlave; |
| | | import com.zy.core.model.protocol.RgvProtocol; |
| | | import com.zy.entity.*; |
| | | import com.zy.mapper.*; |
| | | import com.zy.mapper.BasRgvErrMapper; |
| | | import com.zy.service.*; |
| | | import com.zy.utils.*; |
| | | import lombok.extern.slf4j.Slf4j; |
| | |
| | | |
| | | @Resource |
| | | private BasDevpErrLogService basDevpErrLogService; |
| | | |
| | | @Autowired |
| | | private BasRgvErrMapper basRgvErrMapper; |
| | | |
| | | @Value("${wms.url}") |
| | | private String wmsUrl; |
| | |
| | | continue; |
| | | } |
| | | |
| | | // 尺寸检测异常(复刻generateStoreWrkFile的逻辑,但不包括扫码失败) |
| | | 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; |
| | | } |
| | | // 退回(空托入库的条件是isEmptyMk为true) |
| | | if (back && staProtocol.isInEnable() && staProtocol.isLoading() && staProtocol.isPakMk() && staProtocol.isEmptyMk()) { |
| | | Integer ledId = emptyInSta.getLed(); |
| | | if (ledId != null) { |
| | | MessageQueue.offer(SlaveType.Led, ledId, new Task(3, errMsg)); |
| | | } |
| | | News.info("{}空板入库回退:{},任务号:{}", emptyInSta.getStaNo(), errMsg, staProtocol.getWorkNo()); |
| | | staProtocol.setWorkNo(9999); |
| | | staProtocol.setStaNo(emptyInSta.getBackSta().shortValue()); |
| | | devpThread.setPakMk(staProtocol.getSiteId(), false); |
| | | MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol)); |
| | | log.error("输送线下发1(空板):"+staProtocol.getWorkNo()+","+emptyInSta.getBackSta()); |
| | | continue; |
| | | } |
| | | |
| | | News.warnNoLog(""+mark+" - 0"+" - 开始执行:空栈板初始化入库,叉车入库站放货,条码:{}", barcode); |
| | | |
| | | try { |
| | |
| | | ledCommand.setStaNo(dto.getStaNo()); |
| | | commands.add(ledCommand); |
| | | MessageQueue.offer(SlaveType.Led, emptyInSta.getLed(), new Task(1, commands)); |
| | | // ledThread.errorReset(); |
| | | } |
| | | // 成功时重置LED错误 |
| | | if (ledThread != null) { |
| | | ledThread.errorReset(); |
| | | } |
| | | } else { |
| | | String errorMsg = jsonObject.getString("msg"); |
| | | // 如果任务回退,并且站点不是自动状态,则不触发回退 |
| | | if (!staProtocol.isAutoing()) { |
| | | log.error("空板入库回退"+staProtocol.getWorkNo()+","+errorMsg+",站点不是自动状态,不触发回退"); |
| | | log.error("空板入库回退,"+staProtocol.getWorkNo()+","+errorMsg+",站点不是自动状态,不触发回退"); |
| | | continue; |
| | | } |
| | | log.error("空板入库回退"+staProtocol.getWorkNo()+","+errorMsg); |
| | | staProtocol.setWorkNo(9999); |
| | | staProtocol.setStaNo(emptyInSta.getBackSta().shortValue()); |
| | | devpThread.setPakMk(staProtocol.getSiteId(), false); |
| | | boolean result = MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol)); |
| | | if (!result) { |
| | | News.errorNoLog(""+mark+" - 2"+" - 更新plc站点信息失败"); |
| | | throw new CoolException("更新plc站点信息失败"); |
| | | } |
| | | |
| | | if (ledThread != null) { |
| | | |
| | | if (!Cools.isEmpty(errorMsg)) { |
| | | MessageQueue.offer(SlaveType.Led, emptyInSta.getLed(), new Task(3, errorMsg)); |
| | | } |
| | | MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol)); |
| | | log.error("空板入库回退,"+staProtocol.getWorkNo()+","+errorMsg); |
| | | if (!Cools.isEmpty(errorMsg)) { |
| | | MessageQueue.offer(SlaveType.Led, emptyInSta.getLed(), new Task(3, errorMsg)); |
| | | } |
| | | // News.error(""+mark+" - 3"+" - 请求接口失败!!!url:{};request:{};response:{}", wmsUrl + "/rpc/pakin/loc/v1", JSON.toJSONString(param), response); |
| | | } |
| | |
| | | ); |
| | | if (!basDevpErrLogService.insert(basErrLog)) { |
| | | News.error("输送线异常信息插入表asr_bas_devp_err_log异常:{}", basErrLog); |
| | | } |
| | | |
| | | // 输送线报警时托盘退回 |
| | | if (staProtocol.isInEnable() && staProtocol.isLoading() && staProtocol.isPakMk() && !staProtocol.isEmptyMk()) { |
| | | Integer backSta = findBackSta(devp, siteNo); |
| | | if (backSta != null) { |
| | | log.info("【输送线报警退回】站点:{},工作号:{},报警:{},退回站:{}", siteNo, workNo, plcErr, backSta); |
| | | // 推送到LED显示报警信息 |
| | | Integer ledId = findLedId(devp, siteNo); |
| | | if (ledId != null) { |
| | | MessageQueue.offer(SlaveType.Led, ledId, new Task(3, plcErr)); |
| | | } |
| | | // 设置退回站 |
| | | staProtocol.setWorkNo(9999); |
| | | staProtocol.setStaNo(backSta.shortValue()); |
| | | devpThread.setPakMk(staProtocol.getSiteId(), false); |
| | | boolean result = MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol)); |
| | | if (!result) { |
| | | News.error("输送线报警退回失败,站点:{},工作号:{}", siteNo, workNo); |
| | | } else { |
| | | log.info("【输送线报警退回】成功下发退回指令,站点:{},工作号:{},退回站:{}", siteNo, workNo, backSta); |
| | | } |
| | | } else { |
| | | log.warn("【输送线报警退回】未找到退回站配置,站点:{},工作号:{}", siteNo, workNo); |
| | | } |
| | | } |
| | | } |
| | | } else { |
| | |
| | | } |
| | | |
| | | /** |
| | | * 根据站点号查找退回站 |
| | | */ |
| | | private Integer findBackSta(DevpSlave devp, Integer siteNo) { |
| | | // 查找入库站 |
| | | for (DevpSlave.Sta inSta : devp.getInSta()) { |
| | | if (inSta.getStaNo().equals(siteNo)) { |
| | | return inSta.getBackSta(); |
| | | } |
| | | } |
| | | // 查找拣料站 |
| | | for (DevpSlave.Sta pickSta : devp.getPickSta()) { |
| | | if (pickSta.getStaNo().equals(siteNo)) { |
| | | return pickSta.getBackSta(); |
| | | } |
| | | } |
| | | // 查找空板入库站 |
| | | for (DevpSlave.Sta emptyInSta : devp.getEmptyInSta()) { |
| | | if (emptyInSta.getStaNo().equals(siteNo)) { |
| | | return emptyInSta.getBackSta(); |
| | | } |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | /** |
| | | * 根据站点号查找LED ID |
| | | */ |
| | | private Integer findLedId(DevpSlave devp, Integer siteNo) { |
| | | // 查找入库站 |
| | | for (DevpSlave.Sta inSta : devp.getInSta()) { |
| | | if (inSta.getStaNo().equals(siteNo)) { |
| | | return inSta.getLed(); |
| | | } |
| | | } |
| | | // 查找拣料站 |
| | | for (DevpSlave.Sta pickSta : devp.getPickSta()) { |
| | | if (pickSta.getStaNo().equals(siteNo)) { |
| | | return pickSta.getLed(); |
| | | } |
| | | } |
| | | // 查找空板入库站 |
| | | for (DevpSlave.Sta emptyInSta : devp.getEmptyInSta()) { |
| | | if (emptyInSta.getStaNo().equals(siteNo)) { |
| | | return emptyInSta.getLed(); |
| | | } |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | /** |
| | | * 出库 ===>> 工作档信息写入led显示器 |
| | | */ |
| | | public synchronized void ledExecute() { |