| | |
| | | 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.api.vo.UpdateChargingPileStatusVo; |
| | | import com.ruoyi.chargingPile.dto.ChargeMonitoring; |
| | | import com.ruoyi.chargingPile.dto.ChargingGunCountMonitoring; |
| | | import com.ruoyi.chargingPile.dto.ChargingGunMonitoring; |
| | |
| | | import com.ruoyi.common.log.enums.BusinessType; |
| | | import com.ruoyi.common.log.enums.OperatorType; |
| | | import com.ruoyi.common.redis.service.RedisService; |
| | | import com.ruoyi.common.security.annotation.Logical; |
| | | import com.ruoyi.common.security.annotation.RequiresPermissions; |
| | | import com.ruoyi.integration.api.feignClient.TCECClient; |
| | | import com.ruoyi.order.api.feignClient.ChargingOrderClient; |
| | | import com.ruoyi.order.api.model.TChargingOrder; |
| | | import com.ruoyi.order.api.vo.TChargingOrderVo; |
| | | import com.ruoyi.other.api.domain.TVip; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiImplicitParam; |
| | | import io.swagger.annotations.ApiImplicitParams; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import org.springframework.data.redis.core.RedisTemplate; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import javax.annotation.Resource; |
| | |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.time.LocalDateTime; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * <p> |
| | |
| | | |
| | | private final TChargingPileService chargingPileService; |
| | | private final TChargingGunService chargingGunService; |
| | | |
| | | |
| | | @Resource |
| | | private RedisService redisService; |
| | | private RedisTemplate redisTemplate; |
| | | |
| | | @Resource |
| | | private TFaultMessageService faultMessageService; |
| | | |
| | | @Resource |
| | | private ChargingOrderClient chargingOrderClient; |
| | | |
| | | @Resource |
| | | private TCECClient tcecClient; |
| | | |
| | | |
| | | @Autowired |
| | |
| | | return R.ok(chargingPileService.list(Wrappers.lambdaQuery(TChargingPile.class) |
| | | .in(!siteIds.isEmpty(),TChargingPile::getSiteId,siteIds))); |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | @RequiresPermissions(value = {"/chargingPile", "/chargingGun"}, logical = Logical.OR) |
| | | @ResponseBody |
| | | @GetMapping("/pageChargingPileList") |
| | | @ApiOperation(value = "获取充电桩列表数据", tags = {"管理后台-充电桩信息"}) |
| | |
| | | PageInfo<PageChargingPileListDTO> list = chargingPileService.pageChargingPileList(page); |
| | | return AjaxResult.success(list); |
| | | } |
| | | |
| | | |
| | | |
| | | @RequiresPermissions(value = {"/chargingPile/add"}, logical = Logical.OR) |
| | | @ResponseBody |
| | | @Log(title = "【充电桩信息】添加充电桩数据", businessType = BusinessType.INSERT,operatorType = OperatorType.MANAGE) |
| | | @PostMapping("/addChargingPile") |
| | |
| | | public AjaxResult addChargingPile(@RequestBody TChargingPile chargingPile){ |
| | | return chargingPileService.addChargingPile(chargingPile); |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | @RequiresPermissions(value = {"/chargingPile/select", "/chargingPile/update"}, logical = Logical.OR) |
| | | @ResponseBody |
| | | @GetMapping("/getChargingPile/{id}") |
| | | @ApiOperation(value = "获取充电桩详情数据", tags = {"管理后台-充电桩信息"}) |
| | |
| | | TChargingPile chargingPile = chargingPileService.getChargingPile(id); |
| | | return AjaxResult.success(chargingPile); |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | @RequiresPermissions(value = {"/chargingPile/update"}, logical = Logical.OR) |
| | | @ResponseBody |
| | | @Log(title = "【充电桩信息】编辑充电桩数据", businessType = BusinessType.UPDATE,operatorType = OperatorType.MANAGE) |
| | | @PostMapping("/editChargingPile") |
| | |
| | | public AjaxResult editChargingPile(@RequestBody TChargingPile chargingPile){ |
| | | return chargingPileService.editChargingPile(chargingPile); |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | @RequiresPermissions(value = {"/chargingPile/del", "/chargingPile/batch_del"}, logical = Logical.OR) |
| | | @ResponseBody |
| | | @DeleteMapping("/delChargingPile") |
| | | @Log(title = "【充电桩信息】删除充电桩", businessType = BusinessType.DELETE,operatorType = OperatorType.MANAGE) |
| | |
| | | public AjaxResult delChargingPile(@RequestParam("id") Integer[] id){ |
| | | return chargingPileService.delChargingPile(id); |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | @RequiresPermissions(value = {"/chargingPile/accountingStrategy"}, logical = Logical.OR) |
| | | @ResponseBody |
| | | @Log(title = "【充电桩信息】批量设置计费策略", businessType = BusinessType.UPDATE,operatorType = OperatorType.MANAGE) |
| | | @PostMapping("/batchSetAccountingStrategy") |
| | |
| | | chargingPileService.batchSetAccountingStrategy(setAccountingStrategy); |
| | | return AjaxResult.success(); |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | @RequiresPermissions(value = {"/chargingEquipmentMonitoring"}, logical = Logical.OR) |
| | | @ResponseBody |
| | | @GetMapping("/chargeMonitoring/{siteId}") |
| | | @ApiOperation(value = "获取充电设施监控数据", tags = {"管理后台-充电设备监控"}) |
| | |
| | | ChargeMonitoring chargeMonitoring = chargingPileService.chargeMonitoring(siteId); |
| | | return AjaxResult.success(chargeMonitoring); |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | @RequiresPermissions(value = {"/chargingEquipmentMonitoring"}, logical = Logical.OR) |
| | | @ResponseBody |
| | | @GetMapping("/getChargingGunCountMonitoring/{siteId}") |
| | | @ApiOperation(value = "获取充电枪各种状态汇总监控数据", tags = {"管理后台-充电设备监控"}) |
| | |
| | | ChargingGunCountMonitoring chargingGunCountMonitoring = chargingPileService.getChargingGunCountMonitoring(siteId); |
| | | return AjaxResult.success(chargingGunCountMonitoring); |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | @RequiresPermissions(value = {"/operationMaintenanceAnalysis", "/chargingEquipmentMonitoring"}, logical = Logical.OR) |
| | | @ResponseBody |
| | | @GetMapping("/getChargingGunMonitoring") |
| | | @ApiOperation(value = "获取充电枪监控数据", tags = {"管理后台-充电设备监控"}) |
| | |
| | | */ |
| | | @ResponseBody |
| | | @PostMapping("/getChargingPileById/{id}") |
| | | public R<TChargingPile> getChargingPileById(@PathVariable Integer id){ |
| | | public R<TChargingPile> getChargingPileById(@PathVariable("id") Integer id){ |
| | | TChargingPile chargingPile = chargingPileService.getById(id); |
| | | 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); |
| | | |
| | | public void updateChargingPileStatus(@RequestBody UpdateChargingPileStatusVo vo){ |
| | | String pile_code = vo.getPile_code(); |
| | | String gun_code = vo.getGun_code(); |
| | | //0:正常,1:故障,2=插枪 |
| | | Integer status = vo.getStatus(); |
| | | Long time = (Long) redisTemplate.opsForHash().get("charging_gun_online", (pile_code + gun_code)); |
| | | //小于1分钟才处理数据,防止频繁查询数据 |
| | | if(null != time && (System.currentTimeMillis() - time) < 60000){ |
| | | return; |
| | | } |
| | | TChargingGun tChargingGun = chargingGunService.getOne(new LambdaQueryWrapper<TChargingGun>().eq(TChargingGun::getFullNumber, (pile_code + gun_code)).eq(TChargingGun::getDelFlag, 0)); |
| | | if(null != tChargingGun){ |
| | | redisTemplate.opsForHash().put("charging_gun_online", tChargingGun.getFullNumber(), System.currentTimeMillis()); |
| | | |
| | | TChargingPile chargingPile = chargingPileService.getById(tChargingGun.getChargingPileId()); |
| | | //枪处于离线或者故障,返回状态为正常,则修改其状态 |
| | | if(0 == status && tChargingGun.getStatus() != 2){ |
| | | TChargingGun tChargingGun1 = new TChargingGun(); |
| | | tChargingGun1.setId(tChargingGun.getId()); |
| | | tChargingGun1.setStatus(2); |
| | | chargingGunService.updateById(tChargingGun1); |
| | | new Thread(new Runnable() { |
| | | @Override |
| | | public void run() { |
| | | //推送状态给三方平台 |
| | | tcecClient.pushChargingGunStatus(tChargingGun.getFullNumber(), tChargingGun1.getStatus()); |
| | | } |
| | | }).start(); |
| | | |
| | | if(chargingPile.getStatus() != 1){ |
| | | TChargingPile chargingPile1 = new TChargingPile(); |
| | | chargingPile1.setId(chargingPile.getId()); |
| | | chargingPile1.setStatus(1); |
| | | chargingPileService.updateById(chargingPile1); |
| | | } |
| | | |
| | | List<TFaultMessage> list = faultMessageService.list(new LambdaQueryWrapper<TFaultMessage>().eq(TFaultMessage::getChargingGunId, tChargingGun.getId()) |
| | | .isNull(TFaultMessage::getEndTime)); |
| | | if(!list.isEmpty()){ |
| | | list.forEach(s->s.setEndTime(LocalDateTime.now())); |
| | | faultMessageService.updateBatchById(list); |
| | | } |
| | | } |
| | | //枪处于正常,返回状态为故障,则修改其状态 |
| | | if(1 == status && tChargingGun.getStatus() != 1 && tChargingGun.getStatus() != 7){ |
| | | TChargingGun tChargingGun1 = new TChargingGun(); |
| | | tChargingGun1.setId(tChargingGun.getId()); |
| | | tChargingGun1.setStatus(7); |
| | | chargingGunService.updateById(tChargingGun1); |
| | | new Thread(new Runnable() { |
| | | @Override |
| | | public void run() { |
| | | //推送状态给三方平台 |
| | | tcecClient.pushChargingGunStatus(tChargingGun.getFullNumber(), tChargingGun1.getStatus()); |
| | | } |
| | | }).start(); |
| | | |
| | | //桩处于正常,桩所属的枪都处于非正常,修改桩状态为异常 |
| | | List<TChargingGun> list = chargingGunService.list(new LambdaQueryWrapper<TChargingGun>().eq(TChargingGun::getChargingPileId, chargingPile.getId()).eq(TChargingGun::getDelFlag, 0)); |
| | | int size = list.stream().filter(s -> s.getStatus() == 1 || s.getStatus() == 7).collect(Collectors.toList()).size(); |
| | | if(chargingPile.getStatus() == 1 && list.size() == size){ |
| | | 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); |
| | | } |
| | | |
| | | TFaultMessage faultMessage = new TFaultMessage(); |
| | | faultMessage.setSiteId(chargingPile.getSiteId()); |
| | | faultMessage.setChargingPileId(chargingPile.getId()); |
| | | faultMessage.setChargingGunId(tChargingGun.getId()); |
| | | faultMessage.setStatus(2); |
| | | faultMessage.setDownTime(LocalDateTime.now()); |
| | | faultMessage.setCreateTime(LocalDateTime.now()); |
| | | faultMessage.setDelFlag(false); |
| | | faultMessage.setContent("设备故障"); |
| | | faultMessageService.save(faultMessage); |
| | | } |
| | | if(2 == status){ |
| | | TChargingOrderVo order = new TChargingOrderVo(); |
| | | order.setChargingPileId(tChargingGun.getChargingPileId()); |
| | | order.setChargingGunId(tChargingGun.getId()); |
| | | order.setStatusList(Arrays.asList(1, 2, 3, 4, 5)); |
| | | List<TChargingOrder> orders = chargingOrderClient.getChargingOrder(order).getData(); |
| | | if(orders.size() > 0){ |
| | | TChargingOrder chargingOrder = orders.get(0); |
| | | TChargingGun tChargingGun1 = new TChargingGun(); |
| | | if(Arrays.asList(1, 2, 5).contains(chargingOrder.getStatus())){ |
| | | tChargingGun1.setStatus(3); |
| | | tChargingGun1.setId(tChargingGun.getId()); |
| | | chargingGunService.updateById(tChargingGun1); |
| | | } |
| | | if(Arrays.asList(3).contains(chargingOrder.getStatus())){ |
| | | tChargingGun1.setStatus(4); |
| | | tChargingGun1.setId(tChargingGun.getId()); |
| | | chargingGunService.updateById(tChargingGun1); |
| | | } |
| | | if(Arrays.asList(4).contains(chargingOrder.getStatus()) && chargingOrder.getEndMode() == 2){ |
| | | tChargingGun1.setStatus(5); |
| | | tChargingGun1.setId(tChargingGun.getId()); |
| | | chargingGunService.updateById(tChargingGun1); |
| | | } |
| | | new Thread(new Runnable() { |
| | | @Override |
| | | public void run() { |
| | | //推送状态给三方平台 |
| | | tcecClient.pushChargingGunStatus(tChargingGun.getFullNumber(), tChargingGun1.getStatus()); |
| | | } |
| | | }).start(); |
| | | }else{ |
| | | TChargingGun tChargingGun1 = new TChargingGun(); |
| | | tChargingGun1.setId(tChargingGun.getId()); |
| | | tChargingGun1.setStatus(3); |
| | | chargingGunService.updateById(tChargingGun1); |
| | | new Thread(new Runnable() { |
| | | @Override |
| | | public void run() { |
| | | //推送状态给三方平台 |
| | | tcecClient.pushChargingGunStatus(tChargingGun.getFullNumber(), tChargingGun1.getStatus()); |
| | | } |
| | | }).start(); |
| | | } |
| | | } |
| | | if(chargingPile.getStatus() != 1 && 0 == status){ |
| | | TFaultMessage one = faultMessageService.getOne(new LambdaQueryWrapper<TFaultMessage>().eq(TFaultMessage::getChargingPileId, chargingPile.getId()) |
| | | |
| | | List<TFaultMessage> list = faultMessageService.list(new LambdaQueryWrapper<TFaultMessage>().eq(TFaultMessage::getChargingGunId, tChargingGun.getId()) |
| | | .isNull(TFaultMessage::getEndTime)); |
| | | if(null != one){ |
| | | one.setEndTime(LocalDateTime.now()); |
| | | faultMessageService.updateById(one); |
| | | if(!list.isEmpty()){ |
| | | list.forEach(s->s.setEndTime(LocalDateTime.now())); |
| | | faultMessageService.updateBatchById(list); |
| | | } |
| | | |
| | | 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); |
| | | } |
| | | } |
| | | } |