| | |
| | | } |
| | | } |
| | | |
| | | public synchronized void automaticallyTurnOffCharging() { |
| | | // 获取当前时间戳 |
| | | long timestamp = System.currentTimeMillis(); |
| | | Date date = new Date(timestamp); |
| | | TimeZone timeZone = TimeZone.getTimeZone("Asia/Shanghai"); |
| | | java.util.Calendar calendar = java.util.Calendar.getInstance(timeZone); |
| | | calendar.setTime(date); |
| | | int hour = calendar.get(java.util.Calendar.HOUR_OF_DAY); |
| | | if (hour>8 && hour<18){ |
| | | for (SteSlave ste : slaveProperties.getSte()) { |
| | | SteThread steThread = (SteThread) SlaveConnection.get(SlaveType.Ste, ste.getId()); |
| | | SteProtocol steProtocol = steThread.getSteProtocol(); |
| | | BasSte basSte = basSteService.selectById(ste.getId()); |
| | | if (Cools.isEmpty(steProtocol, basSte)) { continue; } |
| | | try{ |
| | | // 在线 空闲 无作业标记 不在充电 |
| | | if (steProtocol.getMode() == 0 |
| | | || !steProtocol.statusType.equals(SteStatusType.IDLE) |
| | | || basSte.getPakMk().equals("Y") |
| | | || steProtocol.getChargeStatus() == 0 |
| | | ) { |
| | | continue; |
| | | } |
| | | if (!steProtocol.isEnable()) { |
| | | continue; |
| | | } |
| | | if (steProtocol.getCharge() > Float.parseFloat(basSte.getChargeLine())) { |
| | | WrkCharge wrkCharge = wrkChargeService.selectWorking(steProtocol.getSteNo().intValue()); |
| | | if (wrkCharge == null) { |
| | | if (steProtocol.getChargeStatus() == 1){ |
| | | SteCommand steCommand = new SteCommand(); |
| | | steCommand.setSteNo(ste.getId()); // 穿梭车编号 |
| | | steCommand.setTaskNo(9999); // 工作号 |
| | | steCommand.setTaskMode(SteTaskModeType.CLOSE_CHARGE); |
| | | if (!MessageQueue.offer(SlaveType.Ste, ste.getId(), new Task(2, steCommand))) { |
| | | News.error("穿梭车命令下发失败,穿梭车号={},任务数据={}", ste.getId(), JSON.toJSON(steCommand)); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | }catch (Exception e){ |
| | | News.error("自动关闭充电出错,联系管理员!"+hour+"点;"+ste.getId()+"号小车;"); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | } |