| | |
| | | import com.sandu.ximon.admin.manager.iot.frame.inner.report.A5C3HeartbeatReportInnerFrame; |
| | | import com.sandu.ximon.admin.manager.iot.frame.inner.request.A1TernaryCodeReqInnerFrame; |
| | | import com.sandu.ximon.admin.manager.iot.frame.inner.request.A5LightResetReqInnerFrame; |
| | | import com.sandu.ximon.admin.manager.iot.frame.inner.request.A7PlcResetReqInnerFrame; |
| | | import com.sandu.ximon.admin.manager.iot.frame.inner.request.EmptyRequestInnerFrame; |
| | | import com.sandu.ximon.admin.manager.iot.frame.inner.response.A1DeviceMacRespInnerFrame; |
| | | import com.sandu.ximon.admin.manager.iot.frame.inner.response.A1TernaryCodeRespInnerFrame; |
| | |
| | | import com.sandu.ximon.dao.domain.*; |
| | | import com.sandu.ximon.dao.enums.OrderByEnums; |
| | | import com.sandu.ximon.dao.mapper.PoleMapper; |
| | | import eu.bitwalker.useragentutils.DeviceType; |
| | | import lombok.AllArgsConstructor; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.apache.commons.lang.RandomStringUtils; |
| | |
| | | /** |
| | | * 删除灯杆 |
| | | */ |
| | | public boolean deletePole(Long poleId) { |
| | | Pole pole = getById(poleId); |
| | | if (pole == null) { |
| | | public boolean deletePole(List<Long> poleIds) { |
| | | List<Pole> poles = listByIds(poleIds); |
| | | if (poles.isEmpty()) { |
| | | throw new BusinessException("未找到该灯杆"); |
| | | } |
| | | // 删除灯杆绑定关系 |
| | | poleBindingService.remove(Wrappers.<PoleBinding>lambdaQuery().eq(PoleBinding::getPoleId, poleId)); |
| | | poleBindingService.remove(Wrappers.<PoleBinding>lambdaQuery().in(PoleBinding::getPoleId, poleIds)); |
| | | SpringContextHolder.getBean(LightTaskPoleRelationService.class) |
| | | .remove(Wrappers.lambdaQuery(LightTaskPoleRelation.class).eq(LightTaskPoleRelation::getPoleId, poleId)); |
| | | .remove(Wrappers.lambdaQuery(LightTaskPoleRelation.class).in(LightTaskPoleRelation::getPoleId, poleIds)); |
| | | |
| | | /** |
| | | * 删除灯杆日志记录开始 |
| | | */ |
| | | String content = "{灯杆Code:" + pole.getDeviceCode() + ", 灯杆名称:" + pole.getPoleName() + " }"; |
| | | String content = "{灯杆id:" + poles + " }"; |
| | | |
| | | StoreOperationRecordsUtils.storeOperationData(null, null, "删除灯杆", content); |
| | | /** |
| | | * 删除灯杆日志记录结束 |
| | | */ |
| | | return removeById(poleId); |
| | | return removeByIds(poleIds); |
| | | } |
| | | |
| | | |
| | |
| | | if (deviceName.isEmpty()) { |
| | | throw new BusinessException("该灯杆Mac为空"); |
| | | } |
| | | IRequestFrame build = FrameBuilder.builderA5().orderType(A5OrderEnum.REQUEST_LIGHT_DATA.getCode()).innerFrame(new A5LightResetReqInnerFrame()).build(); |
| | | Integer deviceType = byId.getDeviceType(); |
| | | |
| | | IRequestFrame build = null; |
| | | if (deviceType < 2){ |
| | | build = FrameBuilder.builderA5().orderType(A5OrderEnum.REQUEST_LIGHT_DATA.getCode()).innerFrame(new A5LightResetReqInnerFrame()).build(); |
| | | } |
| | | else if (deviceType == 2){ |
| | | build = FrameBuilder.builderA7().orderType(A7OrderEnum.REQUEST_PLC_DATA.getCode()).innerFrame(new A7PlcResetReqInnerFrame()).build(); |
| | | |
| | | } |
| | | |
| | | CommonFrame commonFrame = MainBoardInvokeSyncService.getInstance().sendRRPC(deviceName, build); |
| | | |
| | | StoreOperationRecordsUtils.storeInnerFrameData(deviceName, "灯杆恢复出厂设置", build, commonFrame); |
| | | |
| | | System.out.println(commonFrame.toString()); |
| | | IRequestFrame iRequestFrame = FrameBuilder.builderA2().innerFrame(new EmptyRequestInnerFrame()).orderType(A2OrderEnum.REQUEST_MAIN_BOARD_RESET.getCode()).build(); |
| | | CommonFrame rebootFrame = MainBoardInvokeSyncService.getInstance().sendRRPC(deviceName, iRequestFrame); |
| | | StoreOperationRecordsUtils.storeInnerFrameData(deviceName, "灯杆重启", iRequestFrame, commonFrame); |
| | |
| | | pole.setDeviceType(0); |
| | | } else if ("01".equals(a1DeviceMacRespInnerFrame.getType())) { |
| | | pole.setDeviceType(1); |
| | | } else if ("02".equals(a1DeviceMacRespInnerFrame.getType())) { |
| | | pole.setDeviceType(2); |
| | | } |
| | | |
| | | pole.setPoleCode(generatePoleCode()); |
| | |
| | | boolean result = saveOrUpdate(pole); |
| | | |
| | | if (result) { |
| | | Light light = SpringContextHolder.getBean(LightService.class).getOne(Wrappers.lambdaQuery(Light.class).eq(Light::getDeviceCode, pole.getDeviceCode()).last("limit 1")); |
| | | if (light == null) { |
| | | light = new Light(); |
| | | light.setDeviceCode(uniqueMac); |
| | | light.setLightCount(2); |
| | | SpringContextHolder.getBean(LightService.class).save(light); |
| | | if (pole.getDeviceType() < 2) { |
| | | Light light = SpringContextHolder.getBean(LightService.class). |
| | | getOne(Wrappers.lambdaQuery(Light.class).eq(Light::getDeviceCode, pole.getDeviceCode()).last("limit 1")); |
| | | if (light == null) { |
| | | light = new Light(); |
| | | light.setDeviceCode(uniqueMac); |
| | | light.setLightCount(2); |
| | | SpringContextHolder.getBean(LightService.class).save(light); |
| | | } |
| | | } else if (pole.getDeviceType() == 2) { |
| | | Plc plc = SpringContextHolder.getBean(PlcService.class). |
| | | getOne(Wrappers.lambdaQuery(Plc.class).eq(Plc::getDeviceCode,pole.getDeviceCode()).last("limit 1")); |
| | | if (plc == null){ |
| | | plc = new Plc(); |
| | | plc.setDeviceCode(uniqueMac); |
| | | plc.setPlcCount(3); |
| | | SpringContextHolder.getBean(PlcService.class).save(plc); |
| | | } |
| | | } |
| | | } |
| | | |
| | |
| | | |
| | | } |
| | | |
| | | } |
| | | } |