| | |
| | | package com.sandu.ximon.admin.service; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.github.pagehelper.PageHelper; |
| | | import com.sandu.common.execption.BusinessException; |
| | | import com.sandu.common.object.BaseConditionVO; |
| | | import com.sandu.common.service.impl.BaseServiceImpl; |
| | | import com.sandu.ximon.admin.manager.iot.frame.A5Frame; |
| | | import com.sandu.ximon.admin.manager.iot.frame.inner.report.*; |
| | | import com.sandu.ximon.admin.manager.iot.frame.inner.report.A5LightPoleHeelingHeartbeatReportInnerFrame; |
| | | import com.sandu.ximon.admin.manager.iot.frame.inner.report.A5LightPoleHeelingOperationReportInnerFrame; |
| | | import com.sandu.ximon.admin.manager.iot.frame.inner.report.A5LightPoleHeelingQueryReportInnerFrame; |
| | | import com.sandu.ximon.admin.manager.iot.frame.inner.request.*; |
| | | import com.sandu.ximon.admin.manager.iot.rrpc.dto.CommonFrame; |
| | | import com.sandu.ximon.admin.manager.iot.rrpc.enums.A5OrderEnum; |
| | | import com.sandu.ximon.admin.manager.iot.rrpc.enums.LightPoleHeelingEnum; |
| | | import com.sandu.ximon.admin.manager.iot.rrpc.mainboard.MainBoardInvokeSyncService; |
| | | import com.sandu.ximon.admin.param.LightPoleHeelingListParam; |
| | | import com.sandu.ximon.admin.security.SecurityUtils; |
| | | import com.sandu.ximon.admin.utils.RedisUtils; |
| | | import com.sandu.ximon.admin.utils.StoreOperationRecordsUtils; |
| | | import com.sandu.ximon.admin.vo.EquipmentInfomation; |
| | | import com.sandu.ximon.dao.domain.LightPoleHeeling; |
| | | import com.sandu.ximon.dao.domain.LightPoleHeelingEquipment; |
| | | import com.sandu.ximon.dao.mapper.LightPoleHeelingMapper; |
| | | import lombok.AllArgsConstructor; |
| | | import org.springframework.stereotype.Service; |
| | |
| | | @AllArgsConstructor |
| | | public class LightPoleHeelingService extends BaseServiceImpl<LightPoleHeelingMapper, LightPoleHeeling> { |
| | | private LightPoleHeelingMapper lightPoleHeelingMapper; |
| | | private LightPoleHeelingEquipmentService lightPoleHeelingEquipmentService; |
| | | |
| | | /** |
| | | * 模糊查询 |
| | | */ |
| | | public List<LightPoleHeeling> listLightPoleHeelingByKeyword(BaseConditionVO baseConditionVO, LightPoleHeelingListParam lightPoleHeelingListParam) { |
| | | PageHelper.startPage(baseConditionVO.getPageNo(), baseConditionVO.getPageSize()); |
| | | if (baseConditionVO != null) { |
| | | PageHelper.startPage(baseConditionVO.getPageNo(), baseConditionVO.getPageSize()); |
| | | } |
| | | if (lightPoleHeelingListParam == null) { |
| | | lightPoleHeelingListParam = new LightPoleHeelingListParam(); |
| | | } |
| | |
| | | lightPoleHeelingListParam.setKeyword(lightPoleHeelingListParam.getKeyword().trim()); |
| | | } |
| | | |
| | | List<LightPoleHeeling> lightPoleHeelings |
| | | = lightPoleHeelingMapper.listLightPoleHeeling(lightPoleHeelingListParam.getKeyword(), lightPoleHeelingListParam.getProcessingState()); |
| | | List<LightPoleHeeling> lightPoleHeelings; |
| | | if (SecurityUtils.getClientId() == null) { |
| | | lightPoleHeelings = lightPoleHeelingMapper.listLightPoleHeeling(lightPoleHeelingListParam.getKeyword() |
| | | , lightPoleHeelingListParam.getProcessingState(), null); |
| | | } else { |
| | | lightPoleHeelings = lightPoleHeelingMapper.listLightPoleHeeling(lightPoleHeelingListParam.getKeyword() |
| | | , lightPoleHeelingListParam.getProcessingState(), SecurityUtils.getUserId()); |
| | | } |
| | | |
| | | return lightPoleHeelings; |
| | | } |
| | | |
| | | /** |
| | | * 根据Mac获取最新数据 |
| | | */ |
| | | public EquipmentInfomation getLightPoleHeelingByMac(String mac) { |
| | | EquipmentInfomation equipmentInfo = new EquipmentInfomation(); |
| | | equipmentInfo.setEquipmentType("杆体倾测"); |
| | | if (mac == null || mac.trim().length() == 0) { |
| | | return equipmentInfo; |
| | | } |
| | | |
| | | LightPoleHeeling one = getOne(Wrappers.lambdaQuery(LightPoleHeeling.class).eq(LightPoleHeeling::getMac, mac)); |
| | | if (one != null) { |
| | | equipmentInfo.setEquipmentCreateTime(one.getCreateTime()); |
| | | equipmentInfo.setEquipmentMac(one.getMac()); |
| | | |
| | | } |
| | | //存储设备状态到缓存 |
| | | String s = RedisUtils.getBean().get(LightPoleHeelingEnum.LIGHT_POLE_HEELING_STATE.getCode() + mac); |
| | | if (s == null) { |
| | | equipmentInfo.setEquipmentState("离线"); |
| | | } else { |
| | | equipmentInfo.setEquipmentState("在线"); |
| | | } |
| | | return equipmentInfo; |
| | | } |
| | | |
| | | /** |
| | |
| | | System.out.println(a5Frame + " -----a5Frame"); |
| | | |
| | | CommonFrame commonFrame = MainBoardInvokeSyncService.getInstance().sendRRPC(deviceName, a5Frame); |
| | | StoreOperationRecordsUtils.storeInnerFrameData(deviceName, "杆体倾斜-心跳包", a5Frame, commonFrame); |
| | | System.out.println(commonFrame + " -----commonFrame"); |
| | | |
| | | |
| | |
| | | System.out.println(a5Frame + " -----a5Frame"); |
| | | |
| | | CommonFrame commonFrame = MainBoardInvokeSyncService.getInstance().sendRRPC(deviceName, a5Frame); |
| | | StoreOperationRecordsUtils.storeInnerFrameData(deviceName, "杆体倾斜-查询心跳包间隔时间", a5Frame, commonFrame); |
| | | System.out.println(commonFrame + " -----commonFrame"); |
| | | |
| | | |
| | |
| | | System.out.println(a5Frame + " -----a5Frame"); |
| | | |
| | | CommonFrame commonFrame = MainBoardInvokeSyncService.getInstance().sendRRPC(deviceName, a5Frame); |
| | | StoreOperationRecordsUtils.storeInnerFrameData(deviceName, "杆体倾斜-软重启", a5Frame, commonFrame); |
| | | System.out.println(commonFrame + " -----commonFrame"); |
| | | |
| | | |
| | |
| | | LightPoleHeelingSetHeartbeatPacketTimeReqInnerFrame setHeartbeatPacketTimeReqInnerFrame = |
| | | new LightPoleHeelingSetHeartbeatPacketTimeReqInnerFrame(setTime); |
| | | |
| | | A5Frame a5Frame = new A5Frame(A5OrderEnum.REQUEST_C3_DATA.getCode(), setHeartbeatPacketTimeReqInnerFrame); |
| | | A5Frame a5Frame = new A5Frame(A5OrderEnum.REQUEST_POLE_MONITOR_DATA.getCode(), setHeartbeatPacketTimeReqInnerFrame); |
| | | System.out.println(a5Frame + " -----a5Frame"); |
| | | |
| | | CommonFrame commonFrame = MainBoardInvokeSyncService.getInstance().sendRRPC(devicesName, a5Frame); |
| | | StoreOperationRecordsUtils.storeInnerFrameData(devicesName, "杆体倾斜-设置心跳包间隔时间", a5Frame, commonFrame); |
| | | System.out.println(commonFrame + " -----commonFrame"); |
| | | |
| | | A5LightPoleHeelingOperationReportInnerFrame operationReportInnerFrame |
| | |
| | | LightPoleHeelingSetSensorStateReqInnerFrame setSensorStateReqInnerFrame = |
| | | new LightPoleHeelingSetSensorStateReqInnerFrame(); |
| | | |
| | | A5Frame a5Frame = new A5Frame(A5OrderEnum.REQUEST_C3_DATA.getCode(), setSensorStateReqInnerFrame); |
| | | A5Frame a5Frame = new A5Frame(A5OrderEnum.REQUEST_POLE_MONITOR_DATA.getCode(), setSensorStateReqInnerFrame); |
| | | System.out.println(a5Frame + " -----a5Frame"); |
| | | |
| | | CommonFrame commonFrame = MainBoardInvokeSyncService.getInstance().sendRRPC(devicesName, a5Frame); |
| | | StoreOperationRecordsUtils.storeInnerFrameData(devicesName, "杆体倾斜-设置传感器为初始状态", a5Frame, commonFrame); |
| | | |
| | | System.out.println(commonFrame + " -----commonFrame"); |
| | | |
| | | A5LightPoleHeelingOperationReportInnerFrame operationReportInnerFrame |
| | |
| | | lightPoleHeeling.setWarningLevel(0);//正常 |
| | | } |
| | | |
| | | //存储设备状态到缓存 |
| | | RedisUtils.getBean().set(LightPoleHeelingEnum.LIGHT_POLE_HEELING_STATE.getCode() + deviceName |
| | | , heartBeatDataPackage, 300L); |
| | | /** |
| | | * 将灯杆倾斜硬件添加到硬件表 |
| | | */ |
| | | LightPoleHeelingEquipment one = lightPoleHeelingEquipmentService.getOne(Wrappers.lambdaQuery(LightPoleHeelingEquipment.class).eq(LightPoleHeelingEquipment::getMac, deviceName)); |
| | | if (one == null) { |
| | | LightPoleHeelingEquipment equipment = new LightPoleHeelingEquipment(); |
| | | equipment.setMac(deviceName); |
| | | } |
| | | |
| | | return save(lightPoleHeeling); |
| | | } |
| | | } |