From 92ad6c4e1242a21e6d8340a8e29ac71c11a487e7 Mon Sep 17 00:00:00 2001 From: 无关风月 <443237572@qq.com> Date: 星期五, 17 一月 2025 18:33:01 +0800 Subject: [PATCH] Merge branch 'master' of http://120.76.84.145:10101/gitblit/r/java/mx_charging_pile --- ruoyi-service/ruoyi-chargingPile/src/main/java/com/ruoyi/chargingPile/service/impl/TChargingPileServiceImpl.java | 73 ++++++++++++++++++++++++------------ 1 files changed, 49 insertions(+), 24 deletions(-) diff --git a/ruoyi-service/ruoyi-chargingPile/src/main/java/com/ruoyi/chargingPile/service/impl/TChargingPileServiceImpl.java b/ruoyi-service/ruoyi-chargingPile/src/main/java/com/ruoyi/chargingPile/service/impl/TChargingPileServiceImpl.java index 5c6bf3b..3e1df54 100644 --- a/ruoyi-service/ruoyi-chargingPile/src/main/java/com/ruoyi/chargingPile/service/impl/TChargingPileServiceImpl.java +++ b/ruoyi-service/ruoyi-chargingPile/src/main/java/com/ruoyi/chargingPile/service/impl/TChargingPileServiceImpl.java @@ -3,7 +3,9 @@ import com.alibaba.fastjson.JSON; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.ruoyi.account.api.dto.SendMessageDTO; import com.ruoyi.account.api.feignClient.AppUserCarClient; +import com.ruoyi.account.api.feignClient.AppUserClient; import com.ruoyi.account.api.model.TAppUserCar; import com.ruoyi.chargingPile.api.dto.PageChargingPileListDTO; import com.ruoyi.chargingPile.api.model.*; @@ -117,11 +119,14 @@ private SendMessageClient sendMessageClient; @Resource private TokenService tokenService; + @Resource + private TChargingPileNotificationService chargingPileNotificationService; + + @Resource + private AppUserClient appUserClient; - - - + /** * 获取充电桩列表数据 * @param page @@ -258,32 +263,37 @@ return AjaxResult.error("设备编号已存在"); } TChargingPile tChargingPile = this.getById(chargingPile.getId()); - ShowDeviceResp showDeviceResp = iotInterfaceClient.showDeviceRequest(tChargingPile.getCode()).getData(); - if(null != showDeviceResp){ - DeleteDeviceResp deleteDeviceResp = iotInterfaceClient.deleteDevice(tChargingPile.getCode()).getData(); - if(null == deleteDeviceResp || (deleteDeviceResp.getHttpStatusCode() != 200 && deleteDeviceResp.getHttpStatusCode() != 201 && deleteDeviceResp.getHttpStatusCode() != 204)){ - return AjaxResult.error("删除设备异常,请查看华为设备管理"); + //桩号不相同,需要重新绑定设备 + if(!tChargingPile.getCode().equals(chargingPile.getCode())){ + ShowDeviceResp showDeviceResp = iotInterfaceClient.showDeviceRequest(tChargingPile.getCode()).getData(); + if(null != showDeviceResp){ + DeleteDeviceResp deleteDeviceResp = iotInterfaceClient.deleteDevice(tChargingPile.getCode()).getData(); + if(null == deleteDeviceResp){ + return AjaxResult.error("删除设备异常,请查看华为设备管理"); + } } } - - //调用华为Iot创建设备 - AddDevice addDevice = new AddDevice(); - addDevice.setProductId("66da68d21837002b28b34ec0"); - addDevice.setNodeId(chargingPile.getCode()); - addDevice.setDeviceName(chargingPile.getName()); - addDevice.setDescription(chargingPile.getNumber().toString()); - AddDeviceResp deviceResp = iotInterfaceClient.addDevice(addDevice).getData(); - if(null != deviceResp){ - int httpStatusCode = deviceResp.getHttpStatusCode(); - if(httpStatusCode == 201){ - chargingPile.setIotdDeviceId(deviceResp.getDeviceId()); + ShowDeviceResp showDeviceResp = iotInterfaceClient.showDeviceRequest(tChargingPile.getCode()).getData(); + if(null == showDeviceResp){ + //调用华为Iot创建设备 + AddDevice addDevice = new AddDevice(); + addDevice.setProductId("66da68d21837002b28b34ec0"); + addDevice.setNodeId(chargingPile.getCode()); + addDevice.setDeviceName(chargingPile.getName()); + addDevice.setDescription(chargingPile.getNumber().toString()); + AddDeviceResp deviceResp = iotInterfaceClient.addDevice(addDevice).getData(); + if(null != deviceResp){ + int httpStatusCode = deviceResp.getHttpStatusCode(); + if(httpStatusCode == 201){ + chargingPile.setIotdDeviceId(deviceResp.getDeviceId()); + }else{ + log.error("华为创建设备失败" + JSON.toJSONString(deviceResp)); + return AjaxResult.error("华为创建设备失败"); + } }else{ - log.error("华为创建设备失败" + JSON.toJSONString(deviceResp)); return AjaxResult.error("华为创建设备失败"); } - }else{ - return AjaxResult.error("华为创建设备失败"); } this.updateById(chargingPile); @@ -334,7 +344,7 @@ } chargingPile.setIotdDeviceId(""); } - + } this.removeById(chargingPile); } @@ -703,6 +713,21 @@ faultMessage.setDelFlag(false); faultMessage.setContent("设备离线"); faultMessageService.save(faultMessage); + + // 发送故障短信 + Site site = siteService.getById(faultMessage.getSiteId()); + String siteName = site.getName(); + SendMessageDTO sendMessageDTO = new SendMessageDTO(); + sendMessageDTO.setPhone(site.getPhone()); + sendMessageDTO.setSite(site.getName()); + sendMessageDTO.setChargeGun(chargingPile.getNumber() + ""); + sendMessageDTO.setType(3); + String result = appUserClient.sendMessage(sendMessageDTO).getData(); + if(siteName.length()>10){ + siteName = siteName.substring(0,10); + } + chargingPileNotificationService.saveData(4,faultMessage.getSiteId(),faultMessage.getChargingPileId(),site.getPhone(),"检测到"+siteName+"..."+chargingPile.getNumber()+"号桩设备离线,请及时查看处理!"); + } } } -- Gitblit v1.7.1