|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import com.alibaba.fastjson2.JSONObject; | 
|---|
|  |  |  | import com.ruoyi.integration.iotda.constant.ServiceIdConstant; | 
|---|
|  |  |  | import com.ruoyi.integration.mongodb.model.*; | 
|---|
|  |  |  | import com.ruoyi.integration.api.model.*; | 
|---|
|  |  |  | import com.ruoyi.integration.iotda.enums.ServiceIdMenu; | 
|---|
|  |  |  | import com.ruoyi.integration.mongodb.service.*; | 
|---|
|  |  |  | import org.apache.poi.ss.formula.functions.T; | 
|---|
|  |  |  | import lombok.extern.slf4j.Slf4j; | 
|---|
|  |  |  | import org.springframework.beans.factory.annotation.Autowired; | 
|---|
|  |  |  | import org.springframework.stereotype.Component; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Slf4j | 
|---|
|  |  |  | @Component | 
|---|
|  |  |  | public class MessageUtil { | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private WorkingParameterSettingService workingParameterSettingService; | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private TimingSettingService timingSettingService; | 
|---|
|  |  |  | private TimingSettingReplyService timingSettingReplyService; | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private SetupBillingModelService setupBillingModelService; | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | public String onlineReply(OnlineReply onlineReply){ | 
|---|
|  |  |  | onlineReplyService.create(onlineReply); | 
|---|
|  |  |  | return getMessageJsonString(onlineReply, ServiceIdConstant.ONLINE_REPLY); | 
|---|
|  |  |  | return  getMessageJsonString(onlineReply, ServiceIdMenu.ONLINE_REPLY.getValue()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | public String pong(Pong pong){ | 
|---|
|  |  |  | pongService.create(pong); | 
|---|
|  |  |  | return getMessageJsonString(pong, ServiceIdConstant.PONG); | 
|---|
|  |  |  | return  getMessageJsonString(pong, ServiceIdMenu.PONG.getValue()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | public String billingModeVerifyReply(BillingModeVerifyReply billingModeVerifyReply){ | 
|---|
|  |  |  | billingModeVerifyReplyService.create(billingModeVerifyReply); | 
|---|
|  |  |  | return getMessageJsonString(billingModeVerifyReply, ServiceIdConstant.BILLING_MODE_VERIFY_REPLY); | 
|---|
|  |  |  | return  getMessageJsonString(billingModeVerifyReply, ServiceIdMenu.BILLING_MODE_VERIFY_REPLY.getValue()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | public String acquisitionBillingModeReply(AcquisitionBillingModeReply acquisitionBillingModeReply){ | 
|---|
|  |  |  | acquisitionBillingModeReplyService.create(acquisitionBillingModeReply); | 
|---|
|  |  |  | return getMessageJsonString(acquisitionBillingModeReply, ServiceIdConstant.ACQUISITION_BILLING_MODE_REPLY); | 
|---|
|  |  |  | return  getMessageJsonString(acquisitionBillingModeReply, ServiceIdMenu.ACQUISITION_BILLING_MODE_REPLY.getValue()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | public String readRealTimeMonitoringData(ReadRealTimeMonitoringData readRealTimeMonitoringData){ | 
|---|
|  |  |  | readRealTimeMonitoringDataService.create(readRealTimeMonitoringData); | 
|---|
|  |  |  | return getMessageJsonString(readRealTimeMonitoringData, ServiceIdConstant.READ_REAL_TIME_MONITORING_DATA); | 
|---|
|  |  |  | return  getMessageJsonString(readRealTimeMonitoringData, ServiceIdMenu.READ_REAL_TIME_MONITORING_DATA.getValue()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | 
|---|
|  |  |  | * @param endCharge 实体对象 | 
|---|
|  |  |  | * @return | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | public String endCharge(EndCharge endCharge){ | 
|---|
|  |  |  | endChargeService.create(endCharge); | 
|---|
|  |  |  | return getMessageJsonString(endCharge, ServiceIdConstant.END_CHARGE); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | //    public String endCharge(EndCharge endCharge){ | 
|---|
|  |  |  | //        endChargeService.create(endCharge); | 
|---|
|  |  |  | //        return  getMessageJsonString(endCharge, ServiceIdMenu.END_CHARGE.getValue()); | 
|---|
|  |  |  | //    } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 运营平台确认启动充电 | 
|---|
|  |  |  | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | public String platformConfirmationCharging(PlatformConfirmationCharging platformConfirmationCharging){ | 
|---|
|  |  |  | platformConfirmationChargingService.create(platformConfirmationCharging); | 
|---|
|  |  |  | return getMessageJsonString(platformConfirmationCharging, ServiceIdConstant.PLATFORM_CONFIRMATION_CHARGING); | 
|---|
|  |  |  | return  getMessageJsonString(platformConfirmationCharging, ServiceIdMenu.PLATFORM_CONFIRMATION_CHARGING.getValue()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | 
|---|
|  |  |  | * @param platformStartCharging 实体对象 | 
|---|
|  |  |  | * @return | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | public String platformConfirmationCharging(PlatformStartCharging platformStartCharging){ | 
|---|
|  |  |  | public String platformStartCharging(PlatformStartCharging platformStartCharging){ | 
|---|
|  |  |  | platformStartChargingService.create(platformStartCharging); | 
|---|
|  |  |  | return getMessageJsonString(platformStartCharging, ServiceIdConstant.PLATFORM_START_CHARGING); | 
|---|
|  |  |  | return  getMessageJsonString(platformStartCharging, ServiceIdMenu.PLATFORM_START_CHARGING.getValue()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | public String platformStopCharging(PlatformStopCharging platformStopCharging){ | 
|---|
|  |  |  | platformStopChargingService.create(platformStopCharging); | 
|---|
|  |  |  | return getMessageJsonString(platformStopCharging, ServiceIdConstant.PLATFORM_STOP_CHARGING); | 
|---|
|  |  |  | return  getMessageJsonString(platformStopCharging, ServiceIdMenu.PLATFORM_STOP_CHARGING.getValue()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | public String confirmTransactionRecord(ConfirmTransactionRecord confirmTransactionRecord){ | 
|---|
|  |  |  | confirmTransactionRecordService.create(confirmTransactionRecord); | 
|---|
|  |  |  | return getMessageJsonString(confirmTransactionRecord, ServiceIdConstant.CONFIRM_TRANSACTION_RECORD); | 
|---|
|  |  |  | return  getMessageJsonString(confirmTransactionRecord, ServiceIdMenu.CONFIRM_TRANSACTION_RECORD.getValue()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | public String updateBalance(UpdateBalance updateBalance){ | 
|---|
|  |  |  | updateBalanceService.create(updateBalance); | 
|---|
|  |  |  | return getMessageJsonString(updateBalance, ServiceIdConstant.UPDATE_BALANCE); | 
|---|
|  |  |  | return  getMessageJsonString(updateBalance, ServiceIdMenu.UPDATE_BALANCE.getValue()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | public String synchronizeOfflineCard(SynchronizeOfflineCard synchronizeOfflineCard){ | 
|---|
|  |  |  | synchronizeOfflineCardService.create(synchronizeOfflineCard); | 
|---|
|  |  |  | return getMessageJsonString(synchronizeOfflineCard, ServiceIdConstant.SYNCHRONIZE_OFFLINE_CARD); | 
|---|
|  |  |  | return  getMessageJsonString(synchronizeOfflineCard, ServiceIdMenu.SYNCHRONIZE_OFFLINE_CARD.getValue()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | public String clearOfflineCard(ClearOfflineCard clearOfflineCard){ | 
|---|
|  |  |  | clearOfflineCardService.create(clearOfflineCard); | 
|---|
|  |  |  | return getMessageJsonString(clearOfflineCard, ServiceIdConstant.CLEAR_OFFLINE_CARD); | 
|---|
|  |  |  | return  getMessageJsonString(clearOfflineCard, ServiceIdMenu.CLEAR_OFFLINE_CARD.getValue()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | public String queryOfflineCard(QueryOfflineCard queryOfflineCard){ | 
|---|
|  |  |  | queryOfflineCardService.create(queryOfflineCard); | 
|---|
|  |  |  | return getMessageJsonString(queryOfflineCard, ServiceIdConstant.QUERY_OFFLINE_CARD); | 
|---|
|  |  |  | return  getMessageJsonString(queryOfflineCard, ServiceIdMenu.QUERY_OFFLINE_CARD.getValue()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | public String workingParameterSetting(WorkingParameterSetting workingParameterSetting){ | 
|---|
|  |  |  | workingParameterSettingService.create(workingParameterSetting); | 
|---|
|  |  |  | return getMessageJsonString(workingParameterSetting, ServiceIdConstant.WORKING_PARAMETER_SETTING); | 
|---|
|  |  |  | return  getMessageJsonString(workingParameterSetting, ServiceIdMenu.WORKING_PARAMETER_SETTING.getValue()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 对时设置 | 
|---|
|  |  |  | * @param timingSetting 实体对象 | 
|---|
|  |  |  | * 对时设置应答 | 
|---|
|  |  |  | * @param timingSettingReply 实体对象 | 
|---|
|  |  |  | * @return | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | public String timingSetting(TimingSetting timingSetting){ | 
|---|
|  |  |  | timingSettingService.create(timingSetting); | 
|---|
|  |  |  | return getMessageJsonString(timingSetting, ServiceIdConstant.TIMING_SETTING); | 
|---|
|  |  |  | public String timingSettingReply(TimingSettingReply timingSettingReply){ | 
|---|
|  |  |  | timingSettingReplyService.create(timingSettingReply); | 
|---|
|  |  |  | return  getMessageJsonString(timingSettingReply, ServiceIdMenu.TIMING_SETTING_REPLY.getValue()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | public String setupBillingModel(SetupBillingModel setupBillingModel){ | 
|---|
|  |  |  | setupBillingModelService.create(setupBillingModel); | 
|---|
|  |  |  | return getMessageJsonString(setupBillingModel, ServiceIdConstant.SETUP_BILLING_MODEL); | 
|---|
|  |  |  | return  getMessageJsonString(setupBillingModel, ServiceIdMenu.SETUP_BILLING_MODEL.getValue()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | public String openOrCloseGroundLock(OpenOrCloseGroundLock openOrCloseGroundLock){ | 
|---|
|  |  |  | openOrCloseGroundLockService.create(openOrCloseGroundLock); | 
|---|
|  |  |  | return getMessageJsonString(openOrCloseGroundLock, ServiceIdConstant.OPEN_OR_CLOSE_GROUND_LOCK); | 
|---|
|  |  |  | return  getMessageJsonString(openOrCloseGroundLock, ServiceIdMenu.OPEN_OR_CLOSE_GROUND_LOCK.getValue()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 远程重启 | 
|---|
|  |  |  | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | public String platformRestart(PlatformRestart platformRestart){ | 
|---|
|  |  |  | platformRestartService.create(platformRestart); | 
|---|
|  |  |  | return getMessageJsonString(platformRestart, ServiceIdConstant.PLATFORM_RESTART); | 
|---|
|  |  |  | return  getMessageJsonString(platformRestart, ServiceIdMenu.PLATFORM_RESTART.getValue()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 远程更新 | 
|---|
|  |  |  | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | public String platformRemoteUpdate(PlatformRemoteUpdate platformRemoteUpdate){ | 
|---|
|  |  |  | platformRemoteUpdateService.create(platformRemoteUpdate); | 
|---|
|  |  |  | return getMessageJsonString(platformRemoteUpdate, ServiceIdConstant.PLATFORM_REMOTE_UPDATE); | 
|---|
|  |  |  | return  getMessageJsonString(platformRemoteUpdate, ServiceIdMenu.PLATFORM_REMOTE_UPDATE.getValue()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | 
|---|
|  |  |  | * @param serviceId 服务ID | 
|---|
|  |  |  | * @return | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | private String getMessageJsonString(Object object, String serviceId){ | 
|---|
|  |  |  | public String getMessageJsonString(Object object, String serviceId){ | 
|---|
|  |  |  | JSONObject jsonObject = JSONObject.parseObject(JSONObject.toJSONString(object)); | 
|---|
|  |  |  | jsonObject.put("service_id", serviceId); | 
|---|
|  |  |  | return jsonObject.toJSONString(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | } | 
|---|