| | |
| | | import com.zy.core.thread.RgvThread; |
| | | import com.zy.core.thread.SiemensDevpThread; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.apache.poi.ss.formula.functions.T; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.beans.factory.annotation.Value; |
| | | import org.springframework.stereotype.Service; |
| | |
| | | |
| | | @Autowired |
| | | private SlaveProperties slaveProperties; |
| | | @Autowired |
| | | private WrkMastMapper wrkMastMapper; |
| | | @Autowired |
| | | private LocMastService locMastService; |
| | | @Autowired |
| | |
| | | |
| | | @Value("${constant-parameters.avoidDistance}") |
| | | private Long avoidDistance; |
| | | @Autowired |
| | | private TaskWrkLogServiceImpl taskWrkLogService; |
| | | |
| | | public void generateStoreWrkFile() { |
| | | try { |
| | |
| | | boolean back = false; |
| | | String errMsg = "-"; |
| | | if (staProtocol.getGrossWt()>=600){ |
| | | errMsg = "超重"; |
| | | errMsg = "超重:"+staProtocol.getGrossWt()+"kg"; |
| | | back = true; |
| | | } |
| | | if (staProtocol.isFrontErr()) { |
| | |
| | | errMsg = "右超限"; |
| | | back = true; |
| | | } |
| | | if (!back && staProtocol.isWeightErr()) { |
| | | errMsg = "超重"; |
| | | back = true; |
| | | } |
| | | // if (!back && staProtocol.isWeightErr()) { |
| | | // errMsg = "超重"; |
| | | // back = true; |
| | | // } |
| | | if (!back && staProtocol.isBarcodeErr()) { |
| | | errMsg = "扫码失败"; |
| | | back = true; |
| | |
| | | errMsg = "右超限"; |
| | | back = true; |
| | | } |
| | | if (!back && staProtocol.isWeightErr()) { |
| | | errMsg = "超重"; |
| | | back = true; |
| | | } |
| | | // if (!back && staProtocol.isWeightErr()) { |
| | | // errMsg = "超重"; |
| | | // back = true; |
| | | // } |
| | | // 退回 |
| | | if (back) { |
| | | if (stano == inSta.getBackSta().shortValue()) { |
| | |
| | | log.error("出库到出库站异常:异常信息:" + e); |
| | | } |
| | | } |
| | | |
| | | } |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 堆垛机5分钟无任务则回到源点 |
| | | */ |
| | | public void crnStnToOutStnSou() { |
| | | for (CrnSlave crn : slaveProperties.getCrn()) { |
| | | try{ |
| | | // 获取堆垛机信息 |
| | | CrnThread crnThread = (CrnThread) SlaveConnection.get(SlaveType.Crn, crn.getId()); |
| | | CrnProtocol crnProtocol = crnThread.getCrnProtocol(); |
| | | if (crnProtocol == null) { |
| | | continue; |
| | | } |
| | | BasCrnp basCrnp = basCrnpService.selectById(crn.getId()); |
| | | if (basCrnp == null) { |
| | | log.error("{}号堆垛机尚未在数据库进行维护!", crn.getId()); |
| | | continue; |
| | | } |
| | | |
| | | if (crnProtocol.getLaneNo()!=0 && (crnProtocol.getBay()!=1 || crnProtocol.getLevel()!=1)){ |
| | | if (crnProtocol.modeType == CrnModeType.AUTO && crnProtocol.statusType == CrnStatusType.IDLE && crnProtocol.getTaskNo() != 0) { |
| | | //获取工作档 |
| | | List<TaskWrk> taskWrks = taskWrkMapper.selectByLaneNo(crnProtocol.getLaneNo()); |
| | | if (!taskWrks.isEmpty()) { |
| | | continue; |
| | | } |
| | | List<TaskWrkLog> taskWrkLogs = taskWrkLogService.selectList(new EntityWrapper<TaskWrkLog>().eq("CRN_NO",crnProtocol.getLaneNo()).orderBy("COMPLETE_TIME",true)); |
| | | if (taskWrkLogs.isEmpty()) { |
| | | CrnCommand command = new CrnCommand(); |
| | | if (!MessageQueue.offer(SlaveType.Crn, crnProtocol.getCrnNo(), new Task(4, command))) { |
| | | log.error("堆垛机自动回源点失败,堆垛机号={}", crnProtocol.getCrnNo()); |
| | | } |
| | | } |
| | | // long differenceInSeconds = TimeCalculatorUtils.differenceInMilliseconds(taskWrkLogs.get(0).getCompleteTime(), new Date()); |
| | | // if (differenceInSeconds <= 1000) { |
| | | // return; |
| | | // } |
| | | |
| | | } |
| | | } |
| | | } catch (Exception e){ |
| | | |
| | | } |
| | | } |
| | |
| | | if (crnProtocol == null) { |
| | | continue; |
| | | } |
| | | if (false) { |
| | | // if (crnProtocol.getModeType() != CrnModeType.STOP) { |
| | | if (crnProtocol.getModeType() != CrnModeType.STOP) { |
| | | // 有任务 |
| | | if (crnProtocol.getTaskNo() != 0) { |
| | | BasErrLog latest = basErrLogService.findLatestByTaskNo(crn.getId(), crnProtocol.getTaskNo().intValue()); |
| | | // 有异常 |
| | | if (latest == null) { |
| | | if (crnProtocol.getAlarm() != null && crnProtocol.getAlarm() > 0) { |
| | | WrkMast wrkMast = wrkMastMapper.selectById(crnProtocol.getTaskNo()); |
| | | if (wrkMast == null) { |
| | | TaskWrk taskWrk = taskWrkMapper.selectByWrkNo(Integer.valueOf(crnProtocol.getTaskNo())); |
| | | if (taskWrk == null) { |
| | | continue; |
| | | } |
| | | BasCrnError crnError = basCrnErrorMapper.selectById(crnProtocol.getAlarm()); |
| | | BasCrnError crnError = basCrnErrorMapper.selectById(crnProtocol.getAlarm().intValue()); |
| | | String errName = crnError == null ? String.valueOf(crnProtocol.getAlarm()) : crnError.getErrName(); |
| | | BasErrLog basErrLog = new BasErrLog( |
| | | null, // 编号 |
| | | wrkMast.getWrkNo(), // 工作号 |
| | | taskWrk.getWrkNo(), // 工作号 |
| | | now, // 发生时间 |
| | | null, // 结束时间 |
| | | wrkMast.getWrkSts(), // 工作状态 |
| | | wrkMast.getIoType(), // 入出库类型 |
| | | taskWrk.getWrkSts().longValue(), // 工作状态 |
| | | taskWrk.getIoType(), // 入出库类型 |
| | | crn.getId(), // 堆垛机 |
| | | null, // plc |
| | | wrkMast.getLocNo(), // 目标库位 |
| | | wrkMast.getStaNo(), // 目标站 |
| | | wrkMast.getSourceStaNo(), // 源站 |
| | | wrkMast.getSourceLocNo(), // 源库位 |
| | | wrkMast.getBarcode(), // 条码 |
| | | taskWrk.getTargetPoint(), // 目标库位 |
| | | 0, // 目标站 |
| | | 0, // 源站 |
| | | taskWrk.getStartPoint(), // 源库位 |
| | | taskWrk.getBarcode(), // 条码 |
| | | (int) crnProtocol.getAlarm(), // 异常码 |
| | | errName, // 异常 |
| | | 1, // 异常情况 |
| | |
| | | boolean back = false; |
| | | String errMsg = "-"; |
| | | if (staProtocol.getGrossWt()>=600){ |
| | | errMsg = "超重"; |
| | | errMsg = "超重:"+staProtocol.getGrossWt()+"kg"; |
| | | back = true; |
| | | } |
| | | if (staProtocol.isFrontErr()) { |
| | |
| | | errMsg = "右超限"; |
| | | back = true; |
| | | } |
| | | if (!back && staProtocol.isWeightErr()) { |
| | | errMsg = "超重"; |
| | | back = true; |
| | | } |
| | | // if (!back && staProtocol.isWeightErr()) { |
| | | // errMsg = "超重"; |
| | | // back = true; |
| | | // } |
| | | if (!back && staProtocol.isBarcodeErr()) { |
| | | errMsg = "扫码失败"; |
| | | back = true; |
| | |
| | | // 命令集合 |
| | | List<LedCommand> commands = new ArrayList<>(); |
| | | // 工作档集合 |
| | | List<WrkMast> wrkMasts = new ArrayList<>(); |
| | | List<TaskWrk> taskWrks = new ArrayList<>(); |
| | | for (Integer staNo : led.getStaArr()) { |
| | | // 获取叉车站点 |
| | | StaProtocol staProtocol = devpThread.getStation().get(staNo); |
| | |
| | | ledCommand.getMatDtos().add(matDto); |
| | | commands.add(ledCommand); |
| | | } |
| | | Set<Integer> workNos = wrkMasts.stream().map(WrkMast::getWrkNo).collect(Collectors.toSet()); |
| | | Set<Integer> workNos = taskWrks.stream().map(TaskWrk::getWrkNo).collect(Collectors.toSet()); |
| | | // 获取LED线程 |
| | | LedThread ledThread = (LedThread) SlaveConnection.get(SlaveType.Led, led.getId()); |
| | | // 相同工作号集合则过滤 |
| | |
| | | |
| | | try { |
| | | // 修改主档led标记 |
| | | for (WrkMast wrkMast : wrkMasts) { |
| | | wrkMast.setOveMk("Y"); |
| | | wrkMast.setModiTime(new Date()); |
| | | if (wrkMastMapper.updateById(wrkMast) == 0) { |
| | | for (TaskWrk taskWrk : taskWrks) { |
| | | // taskWrk.setOveMk("Y"); |
| | | taskWrk.setModiTime(new Date()); |
| | | if (taskWrkMapper.updateById(taskWrk) == 0) { |
| | | // News.errorNoLog(""+mark+" - 4"+" - 更新工作档失败"); |
| | | throw new CoolException("更新工作档失败"); |
| | | } |