| | |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | 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.model.*; |
| | | 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.GetChargingGunMonitoring; |
| | | import com.ruoyi.chargingPile.service.*; |
| | | import com.ruoyi.common.core.domain.R; |
| | | import com.ruoyi.common.core.utils.StringUtils; |
| | | import com.ruoyi.common.core.web.domain.AjaxResult; |
| | | import com.ruoyi.common.core.web.page.PageInfo; |
| | | import com.ruoyi.chargingPile.api.dto.PageChargingPileListDTO; |
| | |
| | | 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.elutong.model.ConnectorStatusInfo; |
| | | import com.ruoyi.integration.api.elutong.model.ConnectorStatusReq; |
| | | import com.ruoyi.integration.api.elutong.model.StationStausInfo; |
| | | import com.ruoyi.integration.api.elutong.model.StationsStatusReq; |
| | | import com.ruoyi.integration.api.feignClient.ELuTongClient; |
| | | import com.ruoyi.integration.api.feignClient.TCECClient; |
| | | import com.ruoyi.order.api.feignClient.ChargingOrderClient; |
| | | import com.ruoyi.order.api.model.TChargingOrder; |
| | |
| | | import io.swagger.annotations.ApiImplicitParam; |
| | | import io.swagger.annotations.ApiImplicitParams; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.data.redis.core.RedisTemplate; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import javax.annotation.Resource; |
| | |
| | | * @author xiaochen |
| | | * @since 2024-08-06 |
| | | */ |
| | | @Slf4j |
| | | @Api(tags = "充电桩") |
| | | @RestController |
| | | @RequestMapping("/t-charging-pile") |
| | |
| | | |
| | | private final TChargingPileService chargingPileService; |
| | | private final TChargingGunService chargingGunService; |
| | | |
| | | |
| | | @Resource |
| | | private RedisService redisService; |
| | | private RedisTemplate redisTemplate; |
| | | |
| | | @Resource |
| | | private TFaultMessageService faultMessageService; |
| | |
| | | |
| | | @Resource |
| | | private TCECClient tcecClient; |
| | | |
| | | @Resource |
| | | private ELuTongClient eLuTongClient; |
| | | |
| | | @Resource |
| | | private ISiteService siteService; |
| | | |
| | | |
| | | |
| | | |
| | | @Autowired |
| | |
| | | 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(); |
| | | Map<String, Object> charging_pile_online = redisService.getCacheMap("charging_gun_online"); |
| | | Long time = (Long) charging_pile_online.get(pile_code + gun_code); |
| | | //小于30秒才处理数据,防止频繁查询数据 |
| | | Long time = (Long) redisTemplate.opsForHash().get("charging_gun_online", (pile_code + gun_code)); |
| | | //小于1分钟才处理数据,防止频繁查询数据 |
| | | if(null != time && (System.currentTimeMillis() - time) < 30000){ |
| | | return; |
| | | } |
| | | TChargingGun tChargingGun = chargingGunService.getOne(new LambdaQueryWrapper<TChargingGun>().eq(TChargingGun::getFullNumber, (pile_code + gun_code)).eq(TChargingGun::getDelFlag, 0)); |
| | | if(null != tChargingGun){ |
| | | charging_pile_online.put(tChargingGun.getFullNumber(), System.currentTimeMillis()); |
| | | redisService.setCacheMap("charging_gun_online", charging_pile_online); |
| | | redisTemplate.opsForHash().put("charging_gun_online", tChargingGun.getFullNumber(), System.currentTimeMillis()); |
| | | |
| | | TChargingPile chargingPile = chargingPileService.getById(tChargingGun.getChargingPileId()); |
| | | //枪处于离线或者故障,返回状态为正常,则修改其状态 |
| | |
| | | tChargingGun1.setId(tChargingGun.getId()); |
| | | tChargingGun1.setStatus(2); |
| | | chargingGunService.updateById(tChargingGun1); |
| | | //推送状态给三方平台 |
| | | tcecClient.pushChargingGunStatus(tChargingGun.getId(), tChargingGun1.getStatus()); |
| | | new Thread(new Runnable() { |
| | | @Override |
| | | public void run() { |
| | | //推送状态给三方平台 |
| | | tcecClient.pushChargingGunStatus(tChargingGun.getFullNumber(), tChargingGun1.getStatus()); |
| | | pushConnectorStatus(tChargingGun); |
| | | } |
| | | }).start(); |
| | | |
| | | if(chargingPile.getStatus() != 1){ |
| | | TChargingPile chargingPile1 = new TChargingPile(); |
| | |
| | | tChargingGun1.setId(tChargingGun.getId()); |
| | | tChargingGun1.setStatus(7); |
| | | chargingGunService.updateById(tChargingGun1); |
| | | //推送状态给三方平台 |
| | | tcecClient.pushChargingGunStatus(tChargingGun.getId(), tChargingGun1.getStatus()); |
| | | new Thread(new Runnable() { |
| | | @Override |
| | | public void run() { |
| | | //推送状态给三方平台 |
| | | tcecClient.pushChargingGunStatus(tChargingGun.getFullNumber(), tChargingGun1.getStatus()); |
| | | pushConnectorStatus(tChargingGun); |
| | | } |
| | | }).start(); |
| | | |
| | | //桩处于正常,桩所属的枪都处于非正常,修改桩状态为异常 |
| | | List<TChargingGun> list = chargingGunService.list(new LambdaQueryWrapper<TChargingGun>().eq(TChargingGun::getChargingPileId, chargingPile.getId()).eq(TChargingGun::getDelFlag, 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); |
| | | } |
| | | tChargingGun1.setId(tChargingGun.getId()); |
| | | chargingGunService.updateById(tChargingGun1); |
| | | |
| | | //推送状态给三方平台 |
| | | tcecClient.pushChargingGunStatus(tChargingGun.getId(), tChargingGun1.getStatus()); |
| | | new Thread(new Runnable() { |
| | | @Override |
| | | public void run() { |
| | | //推送状态给三方平台 |
| | | tcecClient.pushChargingGunStatus(tChargingGun.getFullNumber(), tChargingGun1.getStatus()); |
| | | pushConnectorStatus(tChargingGun); |
| | | } |
| | | }).start(); |
| | | }else{ |
| | | TChargingGun tChargingGun1 = new TChargingGun(); |
| | | tChargingGun1.setId(tChargingGun.getId()); |
| | | tChargingGun1.setStatus(3); |
| | | chargingGunService.updateById(tChargingGun1); |
| | | //推送状态给三方平台 |
| | | tcecClient.pushChargingGunStatus(tChargingGun.getId(), tChargingGun1.getStatus()); |
| | | new Thread(new Runnable() { |
| | | @Override |
| | | public void run() { |
| | | //推送状态给三方平台 |
| | | tcecClient.pushChargingGunStatus(tChargingGun.getFullNumber(), tChargingGun1.getStatus()); |
| | | pushConnectorStatus(tChargingGun); |
| | | } |
| | | }).start(); |
| | | } |
| | | |
| | | List<TFaultMessage> list = faultMessageService.list(new LambdaQueryWrapper<TFaultMessage>().eq(TFaultMessage::getChargingGunId, tChargingGun.getId()) |
| | |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 推送设备接口状态信息 |
| | | * @param chargingGun |
| | | */ |
| | | private void pushConnectorStatus(TChargingGun chargingGun){ |
| | | Site site = siteService.getById(chargingGun.getSiteId()); |
| | | if(StringUtils.isNotEmpty(site.getSerAreaCode())){ |
| | | ConnectorStatusReq connectorStatusReq = new ConnectorStatusReq(); |
| | | connectorStatusReq.setOperatorId("91510903906171535D"); |
| | | connectorStatusReq.setSerAreaCode(site.getSerAreaCode()); |
| | | connectorStatusReq.setStationId(site.getId().toString()); |
| | | List<ConnectorStatusInfo> connectorStatusInfos = new ArrayList<>(); |
| | | connectorStatusInfos.add(buildConnectorStatus(chargingGun)); |
| | | connectorStatusReq.setItemSize(connectorStatusInfos.size()); |
| | | connectorStatusReq.setConnectorStatusInfos(connectorStatusInfos); |
| | | R r = eLuTongClient.pushConnectorStatus(connectorStatusReq); |
| | | if(200 != r.getCode()){ |
| | | log.error(r.getMsg()); |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | | private ConnectorStatusInfo buildConnectorStatus(TChargingGun chargingGun){ |
| | | ConnectorStatusInfo connectorStatusInfo = new ConnectorStatusInfo(); |
| | | connectorStatusInfo.setConnectorId(chargingGun.getId().toString()); |
| | | switch (chargingGun.getStatus()){ |
| | | case 1: |
| | | connectorStatusInfo.setStatus(0); |
| | | break; |
| | | case 2: |
| | | connectorStatusInfo.setStatus(1); |
| | | break; |
| | | case 3: |
| | | connectorStatusInfo.setStatus(2); |
| | | break; |
| | | case 4: |
| | | connectorStatusInfo.setStatus(3); |
| | | break; |
| | | case 5: |
| | | connectorStatusInfo.setStatus(3); |
| | | break; |
| | | case 6: |
| | | connectorStatusInfo.setStatus(4); |
| | | break; |
| | | case 7: |
| | | connectorStatusInfo.setStatus(255); |
| | | break; |
| | | } |
| | | connectorStatusInfo.setSoc(0D); |
| | | connectorStatusInfo.setRemainingTime(0); |
| | | return connectorStatusInfo; |
| | | } |
| | | } |
| | | |