private void execRemindWithStatus(RoadConfig roadConfig) { String timeReminderStatus = roadConfig.getTimeReminderStatus(); VehicleRealTime vehicleRealTime = vehicleRealtimeDao.getGpsRealTimeInfoByVehicle(roadConfig.getHcVehicleId()); if (vehicleRealTime != null && vehicleRealTime.getLatitude() != null && vehicleRealTime.getLongitude() != null) { String addr = hczdWsService.getAddrByGps(vehicleRealTime.getLatitude(), vehicleRealTime.getLongitude()); String str = resourceBundle.getMessage( "road.config.remind.message", DateUtil.dateTime2String(new Date(vehicleRealTime.getTime())), roadConfig.getPlateNo(), addr); if (!StringUtils.isEmpty(roadConfig.getTelPhone1())) { hczdWsService.sendSmsToMobile(roadConfig.getTelPhone1(), str); } if (!StringUtils.isEmpty(roadConfig.getTelPhone2())) { hczdWsService.sendSmsToMobile(roadConfig.getTelPhone2(), str); } timeReminderStatus = timeReminderStatus.replace("[" + hour + ":0]", ""); timeReminderStatus = timeReminderStatus + "[" + hour + ":1]"; // 执行成功 } else { timeReminderStatus = timeReminderStatus.replace("[" + hour + ":0]", ""); timeReminderStatus = timeReminderStatus + "[" + hour + ":-1]"; // 执行失败 } roadConfig.setTimeReminderStatus(timeReminderStatus); }
@Override public void doHandler() { for (RoadConfig roadConfig : roadConfigs) { if (roadConfig != null && roadConfig.getIsTimedReminder() != null && roadConfig.getIsTimedReminder() && StringUtils.isNotEmpty(roadConfig.getWarnTime())) { String timeReminderStatus = roadConfig.getTimeReminderStatus() != null ? roadConfig.getTimeReminderStatus() : ""; roadConfig.setTimeReminderStatus(timeReminderStatus); try { this.execRemindWithStatus(roadConfig); } catch (Exception e) { logger.error("车辆hcVehicleId({})" + e.getMessage(), e.getMessage()); timeReminderStatus = timeReminderStatus.replace("[" + hour + ":0]", ""); timeReminderStatus = timeReminderStatus + "[" + hour + ":-1]"; // 执行失败 roadConfig.setTimeReminderStatus(timeReminderStatus); } roadConfigDao.updateRoadConfig(roadConfig); } } }