From 72a76cd3ad51a520100ec59481d99118ffebd33c Mon Sep 17 00:00:00 2001 From: Pu Zhibing <393733352@qq.com> Date: 星期一, 28 十月 2024 15:18:50 +0800 Subject: [PATCH] 合并代码 --- ruoyi-service/ruoyi-chargingPile/src/main/java/com/ruoyi/chargingPile/controller/TChargingPileController.java | 116 +++++++++++++++++++++++++++++++++++++++++++++++---------- 1 files changed, 95 insertions(+), 21 deletions(-) diff --git a/ruoyi-service/ruoyi-chargingPile/src/main/java/com/ruoyi/chargingPile/controller/TChargingPileController.java b/ruoyi-service/ruoyi-chargingPile/src/main/java/com/ruoyi/chargingPile/controller/TChargingPileController.java index 11b93a1..b499c19 100644 --- a/ruoyi-service/ruoyi-chargingPile/src/main/java/com/ruoyi/chargingPile/controller/TChargingPileController.java +++ b/ruoyi-service/ruoyi-chargingPile/src/main/java/com/ruoyi/chargingPile/controller/TChargingPileController.java @@ -5,6 +5,7 @@ import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.ruoyi.chargingPile.api.model.TChargingGun; import com.ruoyi.chargingPile.api.model.TChargingPile; +import com.ruoyi.chargingPile.api.model.TFaultMessage; import com.ruoyi.chargingPile.api.query.TChargingGunQuery; import com.ruoyi.chargingPile.api.vo.TChargingGunVO; import com.ruoyi.chargingPile.dto.ChargeMonitoring; @@ -25,6 +26,7 @@ import com.ruoyi.common.log.annotation.Log; import com.ruoyi.common.log.enums.BusinessType; import com.ruoyi.common.log.enums.OperatorType; +import com.ruoyi.common.redis.service.RedisService; import com.ruoyi.other.api.domain.TVip; import io.swagger.annotations.Api; import io.swagger.annotations.ApiImplicitParam; @@ -38,7 +40,10 @@ import org.springframework.web.bind.annotation.*; import java.math.BigDecimal; +import java.time.LocalDateTime; +import java.util.HashMap; import java.util.List; +import java.util.Map; /** * <p> @@ -56,11 +61,11 @@ private final TChargingPileService chargingPileService; private final TChargingGunService chargingGunService; - @Resource - private TAccountingStrategyService accountingStrategyService; + @Resource + private RedisService redisService; - @Resource - private TAccountingStrategyDetailService accountingStrategyDetailService; + @Resource + private TFaultMessageService faultMessageService; @Autowired @@ -108,7 +113,7 @@ return R.ok(chargingPileService.list(Wrappers.lambdaQuery(TChargingPile.class) .in(!siteIds.isEmpty(),TChargingPile::getSiteId,siteIds))); } - + @ResponseBody @GetMapping("/pageChargingPileList") @ApiOperation(value = "获取充电桩列表数据", tags = {"管理后台-充电桩信息"}) @@ -116,7 +121,7 @@ PageInfo<PageChargingPileListDTO> list = chargingPileService.pageChargingPileList(page); return AjaxResult.success(list); } - + @ResponseBody @Log(title = "【充电桩信息】添加充电桩数据", businessType = BusinessType.INSERT,operatorType = OperatorType.MANAGE) @PostMapping("/addChargingPile") @@ -124,8 +129,8 @@ public AjaxResult addChargingPile(@RequestBody TChargingPile chargingPile){ return chargingPileService.addChargingPile(chargingPile); } - - + + @ResponseBody @GetMapping("/getChargingPile/{id}") @ApiOperation(value = "获取充电桩详情数据", tags = {"管理后台-充电桩信息"}) @@ -133,8 +138,8 @@ TChargingPile chargingPile = chargingPileService.getChargingPile(id); return AjaxResult.success(chargingPile); } - - + + @ResponseBody @Log(title = "【充电桩信息】编辑充电桩数据", businessType = BusinessType.UPDATE,operatorType = OperatorType.MANAGE) @PostMapping("/editChargingPile") @@ -142,9 +147,9 @@ public AjaxResult editChargingPile(@RequestBody TChargingPile chargingPile){ return chargingPileService.editChargingPile(chargingPile); } - - - + + + @ResponseBody @DeleteMapping("/delChargingPile") @Log(title = "【充电桩信息】删除充电桩", businessType = BusinessType.DELETE,operatorType = OperatorType.MANAGE) @@ -155,8 +160,8 @@ public AjaxResult delChargingPile(@RequestParam("id") Integer[] id){ return chargingPileService.delChargingPile(id); } - - + + @ResponseBody @Log(title = "【充电桩信息】批量设置计费策略", businessType = BusinessType.UPDATE,operatorType = OperatorType.MANAGE) @PostMapping("/batchSetAccountingStrategy") @@ -165,8 +170,8 @@ chargingPileService.batchSetAccountingStrategy(setAccountingStrategy); return AjaxResult.success(); } - - + + @ResponseBody @GetMapping("/chargeMonitoring/{siteId}") @ApiOperation(value = "获取充电设施监控数据", tags = {"管理后台-充电设备监控"}) @@ -183,8 +188,8 @@ ChargingGunCountMonitoring chargingGunCountMonitoring = chargingPileService.getChargingGunCountMonitoring(siteId); return AjaxResult.success(chargingGunCountMonitoring); } - - + + @ResponseBody @GetMapping("/getChargingGunMonitoring") @ApiOperation(value = "获取充电枪监控数据", tags = {"管理后台-充电设备监控"}) @@ -192,8 +197,8 @@ PageInfo<ChargingGunMonitoring> chargingGunMonitoring = chargingPileService.getChargingGunMonitoring(query); return AjaxResult.success(chargingGunMonitoring); } - - + + /** * 根据id获取充电桩信息 * @param id @@ -206,5 +211,74 @@ return R.ok(chargingPile); } + + /** + * 更新充电桩状态 + * @param code + * @param status + */ + @ResponseBody + @PostMapping("/updateChargingPileStatus") + public void updateChargingPileStatus(@RequestParam("code") String code, @RequestParam("status") Integer status){ + TChargingPile chargingPile = chargingPileService.getOne(new LambdaQueryWrapper<TChargingPile>() + .eq(TChargingPile::getCode, code).eq(TChargingPile::getDelFlag, 0)); + if(null != chargingPile){ + //充电桩正常,返回异常,处理充电桩状态和添加故障记录 + if(chargingPile.getStatus() == 1 && 1 == status){ + TFaultMessage faultMessage = faultMessageService.getOne(new LambdaQueryWrapper<TFaultMessage>().eq(TFaultMessage::getChargingPileId, chargingPile.getId()) + .eq(TFaultMessage::getStatus, 2).eq(TFaultMessage::getDelFlag, 0).isNull(TFaultMessage::getEndTime)); + if(null == faultMessage){ + faultMessage = new TFaultMessage(); + faultMessage.setSiteId(chargingPile.getSiteId()); + faultMessage.setChargingPileId(chargingPile.getId()); + faultMessage.setStatus(2); + faultMessage.setDownTime(LocalDateTime.now()); + faultMessage.setCreateTime(LocalDateTime.now()); + faultMessage.setDelFlag(false); + faultMessage.setContent("设备故障"); + faultMessageService.save(faultMessage); + + TChargingPile chargingPile1 = new TChargingPile(); + chargingPile1.setId(chargingPile.getId()); + chargingPile1.setStatus(3); + chargingPileService.updateById(chargingPile1); + + List<TChargingGun> list1 = chargingGunService.list(new LambdaQueryWrapper<TChargingGun>().eq(TChargingGun::getChargingPileId, chargingPile.getId())); + for (TChargingGun chargingGun : list1) { + TChargingGun chargingGun1 = new TChargingGun(); + chargingGun1.setId(chargingGun.getId()); + chargingGun1.setStatus(7); + chargingGunService.updateById(chargingGun1); + } + } + } + if(chargingPile.getStatus() != 1 && 0 == status){ + TFaultMessage one = faultMessageService.getOne(new LambdaQueryWrapper<TFaultMessage>().eq(TFaultMessage::getChargingPileId, chargingPile.getId()) + .isNull(TFaultMessage::getEndTime)); + if(null != one){ + one.setEndTime(LocalDateTime.now()); + faultMessageService.updateById(one); + } + + TChargingPile chargingPile1 = new TChargingPile(); + chargingPile1.setId(chargingPile.getId()); + chargingPile1.setStatus(1); + chargingPileService.updateById(chargingPile1); + + List<TChargingGun> list1 = chargingGunService.list(new LambdaQueryWrapper<TChargingGun>().eq(TChargingGun::getChargingPileId, chargingPile.getId())); + for (TChargingGun chargingGun : list1) { + TChargingGun chargingGun1 = new TChargingGun(); + chargingGun1.setId(chargingGun.getId()); + chargingGun1.setStatus(2); + chargingGunService.updateById(chargingGun1); + } + } + if(0 == status){ + Map<String, Object> charging_pile_online = redisService.getCacheMap("charging_pile_online"); + charging_pile_online.put(code, System.currentTimeMillis()); + redisService.setCacheMap("charging_pile_online", charging_pile_online); + } + } + } } -- Gitblit v1.7.1