| | |
| | | package com.ruoyi.jianguan.governmentCloud; |
| | | |
| | | |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.ruoyi.common.core.utils.DateUtils; |
| | | import com.ruoyi.integration.api.model.*; |
| | | import com.ruoyi.jianguan.mongodb.service.*; |
| | | import com.ruoyi.jianguan.mqtt.config.TopicConstants; |
| | | import com.ruoyi.jianguan.mqtt.util.MqttPushUtil; |
| | | import com.ruoyi.jianguan.rocket.model.ErrorMessageMessage; |
| | | import io.netty.util.concurrent.DefaultThreadFactory; |
| | | import lombok.SneakyThrows; |
| | | import lombok.extern.slf4j.Slf4j; |
| | |
| | | import org.springframework.scheduling.annotation.Scheduled; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import java.text.ParseException; |
| | | import java.text.SimpleDateFormat; |
| | | import java.time.LocalDate; |
| | | import java.time.LocalDateTime; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import java.util.concurrent.*; |
| | | |
| | | /** |
| | |
| | | public class UploadDataTaskUtil { |
| | | |
| | | @Autowired |
| | | private AcquisitionBillingModeService acquisitionBillingModeService; |
| | | @Autowired |
| | | private BillingModeVerifyService billingModeVerifyService; |
| | | @Autowired |
| | | private BmsAbortService bmsAbortService; |
| | | @Autowired |
| | | private BmsDemandAndChargerExportationService bmsDemandAndChargerExportationService; |
| | | @Autowired |
| | | private OnlineService onlineService; |
| | | @Autowired |
| | | private EndChargeService endChargeService; |
| | | @Autowired |
| | | private ErrorMessageMessageService errorMessageMessageService; |
| | | @Autowired |
| | | private UploadRealTimeMonitoringDataService uploadRealTimeMonitoringDataService; |
| | | @Autowired |
| | | private ChargingHandshakeService chargingHandshakeService; |
| | | @Autowired |
| | | private ParameterSettingService parameterSettingService; |
| | | @Autowired |
| | | private MotorAbortService motorAbortService; |
| | | @Autowired |
| | | private BmsInformationService bmsInformationService; |
| | | @Autowired |
| | | private ChargingPileStartsChargingService chargingPileStartsChargingService; |
| | | @Autowired |
| | | private PlatformStartChargingReplyService platformStartChargingReplyService; |
| | | @Autowired |
| | | private PlatformStopChargingReplyService platformStopChargingReplyService; |
| | | @Autowired |
| | | private TransactionRecordService transactionRecordService; |
| | | @Autowired |
| | | private UpdateBalanceReplyService updateBalanceReplyService; |
| | | @Autowired |
| | | private SynchronizeOfflineCardReplyService synchronizeOfflineCardReplyService; |
| | | @Autowired |
| | | private ClearOfflineCardReplyService clearOfflineCardReplyService; |
| | | @Autowired |
| | | private WorkingParameterSettingReplyService workingParameterSettingReplyService; |
| | | @Autowired |
| | | private TimingSettingService timingSettingService; |
| | | @Autowired |
| | | private SetupBillingModelReplyService setupBillingModelReplyService; |
| | | @Autowired |
| | | private GroundLockRealTimeDataService groundLockRealTimeDataService; |
| | | @Autowired |
| | | private ChargingPileReturnsGroundLockDataService chargingPileReturnsGroundLockDataService; |
| | | @Autowired |
| | | private PlatformRestartReplyService platformRestartReplyService; |
| | | @Autowired |
| | | private PlatformRemoteUpdateReplyService platformRemoteUpdateReplyService; |
| | | @Autowired |
| | | private QrCodeDeliveryReplyService qrCodeDeliveryReplyService; |
| | | @Autowired |
| | | private SecurityDetectionService securityDetectionService; |
| | | private MqttPushUtil mqttPushUtil; |
| | | |
| | | /** |
| | | * 每天的9点执行的任务 |
| | | */ |
| | | @Scheduled(cron = "0 0 9 * * *") |
| | | // @Scheduled(cron = "0 0 9 * * *") |
| | | @Scheduled(fixedRate = 60000) |
| | | public void taskDay(){ |
| | | try { |
| | | // 传输mongodb的硬件数据 |
| | |
| | | * 3. 适用于需要定时执行或周期性执行的场景 |
| | | */ |
| | | @SneakyThrows |
| | | public static void createCustomThreadPool() { |
| | | public void createCustomThreadPool() { |
| | | /* |
| | | 创建自定义线程池 |
| | | 字段: |
| | |
| | | ); |
| | | |
| | | try { |
| | | LocalDate localDate = LocalDate.now().minusDays(1); |
| | | String start = localDate + " 00:00:00"; |
| | | String end = localDate + " 23:59:59"; |
| | | Date startTime = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(start); |
| | | Date endTime = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(end); |
| | | // 查询所有的mango数据 |
| | | List<UploadRealTimeMonitoringData> uploadRealTimeMonitoringDataList = uploadRealTimeMonitoringDataService.getRangeTimeData(startTime, endTime); |
| | | customthreadPoolExecutor.execute(() -> { |
| | | |
| | | |
| | | |
| | | if (uploadRealTimeMonitoringDataList != null && uploadRealTimeMonitoringDataList.size() > 0) { |
| | | for (UploadRealTimeMonitoringData uploadRealTimeMonitoringData : uploadRealTimeMonitoringDataList) { |
| | | JSONObject jsonObject = new JSONObject(); |
| | | jsonObject.put("device_code", uploadRealTimeMonitoringData.getCharging_pile_code()); |
| | | jsonObject.put("report_time", System.currentTimeMillis()); |
| | | jsonObject.put("properties", uploadRealTimeMonitoringData); |
| | | mqttPushUtil.pushChargePileData(TopicConstants.CHARGE_PILE_CODE.replace("CHARGE_PILE_CODE", uploadRealTimeMonitoringData.getCharging_pile_code()), jsonObject.toJSONString()); |
| | | } |
| | | } |
| | | }); |
| | | |
| | | TimeUnit.MILLISECONDS.sleep(1); |
| | |
| | | } |
| | | } |
| | | |
| | | public static void main(String[] args) { |
| | | System.err.println(System.currentTimeMillis()); |
| | | } |
| | | |
| | | } |