LSH
2023-08-04 73ea4525cb88472e6e80370eb182b4c61d165896
#穿梭车 ===>> 小车电量检测充电,自动关闭充电
2个文件已修改
49 ■■■■■ 已修改文件
src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java 47 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/zy/core/MainProcess.java 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java
@@ -4561,4 +4561,51 @@
        }
    }
    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()+"号小车;");
                }
            }
        }
    }
}
src/main/java/com/zy/core/MainProcess.java
@@ -76,6 +76,8 @@
                    mainService.ledReset();
                    // 穿梭车 ===>> 小车电量检测充电
                    mainService.loopSteCharge();
                    // 穿梭车 ===>> 小车电量检测充电,自动关闭充电
                    mainService.automaticallyTurnOffCharging();
                    // 其他  ===>> 入出库模式切换
                    i++;