|  |  |  | 
|---|
|  |  |  | import com.zy.core.cache.SlaveConnection; | 
|---|
|  |  |  | import com.zy.core.enums.SlaveType; | 
|---|
|  |  |  | import com.zy.core.model.ShuttleSlave; | 
|---|
|  |  |  | import com.zy.core.model.protocol.NyShuttleProtocol; | 
|---|
|  |  |  | import com.zy.core.model.protocol.ShuttleProtocol; | 
|---|
|  |  |  | import com.zy.core.properties.SlaveProperties; | 
|---|
|  |  |  | import com.zy.core.thread.NyShuttleThread; | 
|---|
|  |  |  | import com.zy.core.thread.ShuttleThread; | 
|---|
|  |  |  | import com.zy.system.entity.Config; | 
|---|
|  |  |  | import com.zy.system.service.ConfigService; | 
|---|
|  |  |  | import lombok.extern.slf4j.Slf4j; | 
|---|
|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 小车电量预警检测 => 强制预警 | 
|---|
|  |  |  | * 每30分钟扫描一次 | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | @Scheduled(cron = "1 * * * * ? ") | 
|---|
|  |  |  | @Scheduled(cron = "0 30 * * * ? ") | 
|---|
|  |  |  | public synchronized void shuttlePowerEarlyWarning() { | 
|---|
|  |  |  | Config config = configService.selectOne(new EntityWrapper<Config>().eq("code","dingdingReportUrl")); | 
|---|
|  |  |  | if (config == null) { | 
|---|
|  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | StringBuffer buffer = new StringBuffer(); | 
|---|
|  |  |  | buffer.append("【通知】三凯四向库\n");//消息标题 | 
|---|
|  |  |  | buffer.append("【通知】四向库\n");//消息标题 | 
|---|
|  |  |  |  | 
|---|
|  |  |  | boolean hasReport = false;//是否有需要报告的数据 | 
|---|
|  |  |  | for (ShuttleSlave slave : slaveProperties.getShuttle()) { | 
|---|
|  |  |  | NyShuttleThread shuttleThread = (NyShuttleThread) SlaveConnection.get(SlaveType.Shuttle, slave.getId()); | 
|---|
|  |  |  | ShuttleThread shuttleThread = (ShuttleThread) SlaveConnection.get(SlaveType.Shuttle, slave.getId()); | 
|---|
|  |  |  | if (shuttleThread == null) { | 
|---|
|  |  |  | continue; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | NyShuttleProtocol shuttleProtocol = shuttleThread.getShuttleProtocol(); | 
|---|
|  |  |  | ShuttleProtocol shuttleProtocol = shuttleThread.getStatus(); | 
|---|
|  |  |  | if (shuttleProtocol == null) { | 
|---|
|  |  |  | continue; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | if (shuttleProtocol.getChargState() == 1) { | 
|---|
|  |  |  | if (shuttleThread.isCharging()) { | 
|---|
|  |  |  | continue;//充电中,无需通知 | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | if (shuttleProtocol.getPowerPercent() < shuttlePowerEarlyValue) { | 
|---|
|  |  |  | buffer.append(shuttleProtocol.getShuttleNo()).append("号小车,电量").append(shuttleProtocol.getPowerPercent$()).append(",请注意。\n"); | 
|---|
|  |  |  | if (Integer.parseInt(shuttleProtocol.getBatteryPower()) < shuttlePowerEarlyValue) { | 
|---|
|  |  |  | buffer.append(shuttleProtocol.getShuttleNo()).append("号小车,电量").append(shuttleProtocol.getBatteryPower()).append(",请注意。\n"); | 
|---|
|  |  |  | hasReport = true; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|