puzhibing
2026-08-14 74bce573f6eb00f9f4942afd903cfad53addc9cf
ruoyi-service/ruoyi-integration/src/main/java/com/ruoyi/integration/drainage/TCECController.java
@@ -5,6 +5,7 @@
import com.alibaba.nacos.common.utils.JacksonUtils;
import com.ruoyi.chargingPile.api.feignClient.*;
import com.ruoyi.chargingPile.api.model.*;
import com.ruoyi.chargingPile.api.vo.GetChargingGunByChargingPileIdsVo;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.core.dto.ChargingPercentProvinceDto;
import com.ruoyi.common.core.utils.StringUtils;
@@ -91,6 +92,9 @@
   private SystemConfigurationClient systemConfigurationClient;
   @Autowired
   private TCECSuperviseUtil tcecSuperviseUtil;
    ThreadPoolExecutor threadPoolExecutor = new ThreadPoolExecutor(10, 50, 1L, TimeUnit.MINUTES, new LinkedBlockingQueue<Runnable>());
   private final static String operatorId = "906171535";
   
   /**
@@ -150,31 +154,7 @@
      }
      return baseResult;
   }
   public BaseResult requestCheckJianGuan(Boolean tokenCheck, BaseRequest baseRequest, HttpServletRequest request){
      Operator operator = new Operator();
      BaseResult baseResult = new BaseResult();
      baseResult.setRet(0);
      baseResult.setMsg("成功");
      baseResult.setOperatorID(baseRequest.getOperatorID());
      operator.setOperatorId(baseRequest.getOperatorID());
      Long mapKey = Long.valueOf(LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyyMMddHHmmss")));
      baseResult.setTimeStamp(mapKey);
      baseResult.setSeq("0001");
      //校验token和签名
      String operatorID = baseRequest.getOperatorID();
      String sig = baseRequest.getSig();
      Long timeStamp = baseRequest.getTimeStamp();
      String data = baseRequest.getData();
      String seq = baseRequest.getSeq();
      baseResult.setOperator(operator);
      if(StringUtils.isEmpty(operatorID) || StringUtils.isEmpty(sig) || StringUtils.isEmpty(data) || StringUtils.isEmpty(seq) || null == timeStamp){
         baseResult.setRet(4003);
         baseResult.setMsg("参数异常");
         return baseResult;
      }
      return baseResult;
   }
   
   
   
@@ -321,7 +301,7 @@
      if(null == pageSize){
         pageSize = 10;
      }
      PageInfo<Site> siteListPaging = siteClient.getSiteListPaging(pageNo, pageSize, new ArrayList<>());
      PageInfo<Site> siteListPaging = siteClient.getSiteListPaging(pageNo, pageSize, new ArrayList<>(), 1);
      List<TParkingLot> parkingLots = parkingLotClient.getAllParkingLot().getData();
      QueryStationsInfoResult queryStationsInfoResult = new QueryStationsInfoResult();
      queryStationsInfoResult.setPageNo(pageNo);
@@ -348,7 +328,9 @@
      List<Integer> siteIds = sites.stream().map(Site::getId).collect(Collectors.toList());
      List<TChargingPile> tChargingPiles = chargingPileClient.getChargingPileBySiteIds(siteIds).getData();
      List<Integer> collect1 = tChargingPiles.stream().map(TChargingPile::getId).collect(Collectors.toList());
      List<TChargingGun> chargingGunList = chargingGunClient.getChargingGunByChargingPileIds(collect1).getData();
      GetChargingGunByChargingPileIdsVo vo = new GetChargingGunByChargingPileIdsVo();
      vo.setChargingPileIds(collect1);
      List<TChargingGun> chargingGunList = chargingGunClient.getChargingGunByChargingPileIds(vo).getData();
      String serviceTel = systemConfigurationClient.getServerPhone().getData();
      List<StationInfo> StationInfos = new ArrayList<>();
      for (Site datum : sites) {
@@ -651,7 +633,9 @@
      List<Integer> siteIds = data.stream().map(Site::getId).collect(Collectors.toList());
      List<TChargingPile> tChargingPiles = chargingPileClient.getChargingPileBySiteIds(siteIds).getData();
      List<Integer> collect1 = tChargingPiles.stream().map(TChargingPile::getId).collect(Collectors.toList());
      List<TChargingGun> chargingGunList = chargingGunClient.getChargingGunByChargingPileIds(collect1).getData();
      GetChargingGunByChargingPileIdsVo vo = new GetChargingGunByChargingPileIdsVo();
      vo.setChargingPileIds(collect1);
      List<TChargingGun> chargingGunList = chargingGunClient.getChargingGunByChargingPileIds(vo).getData();
      
      QueryStationStatusResult result = new QueryStationStatusResult();
      result.setTotal(data.size());
@@ -950,7 +934,7 @@
      NotificationStationChangeResult notificationStationChange = TCECKDUtil.notificationStationChange(operator, 3, siteIds);
      //启动重试推送机制
      if(null == notificationStationChange || 1 == notificationStationChange.getSuccStat()){
         ThreadPoolExecutor threadPoolExecutor = new ThreadPoolExecutor(1, 1, 0L, TimeUnit.MILLISECONDS, new LinkedBlockingQueue<Runnable>());
         threadPoolExecutor.execute(new Runnable() {
            //计数器
            Integer size = 0;
@@ -1112,7 +1096,6 @@
      //启动重试推送机制
      if(null == notificationStartChargeResult || 1 == notificationStartChargeResult.getSuccStat()){
         
         ThreadPoolExecutor threadPoolExecutor = new ThreadPoolExecutor(1, 1, 0L, TimeUnit.MILLISECONDS, new LinkedBlockingQueue<Runnable>());
         threadPoolExecutor.execute(new Runnable() {
            //计数器
            Integer size = 0;
@@ -1250,9 +1233,10 @@
      if(data.size() > 0){
         BigDecimal totalElectricity = data.stream().map(TChargingOrderAccountingStrategy::getPeriodElectricPrice).reduce(BigDecimal.ZERO, BigDecimal::add);
         BigDecimal serviceCharge = data.stream().map(TChargingOrderAccountingStrategy::getPeriodServicePrice).reduce(BigDecimal.ZERO, BigDecimal::add);
         BigDecimal totalMoney = totalElectricity.add(serviceCharge).setScale(4, RoundingMode.HALF_EVEN);
         queryEquipChargeStatusResult.setElecMoney(totalElectricity);
         queryEquipChargeStatusResult.setSeviceMoney(serviceCharge);
         queryEquipChargeStatusResult.setTotalMoney(chargingOrder.getPaymentAmount());
         queryEquipChargeStatusResult.setTotalMoney(totalMoney);
      }else if(null != chargingOrder.getRechargeAmount() && null != chargingOrder.getResidualAmount()){
         queryEquipChargeStatusResult.setElecMoney(chargingOrder.getRechargeAmount().subtract(chargingOrder.getResidualAmount()));
         queryEquipChargeStatusResult.setSeviceMoney(BigDecimal.ZERO);
@@ -1309,7 +1293,6 @@
      NotificationEquipChargeStatusResult notificationEquipChargeStatusResult = TCECUtil.notificationEquipChargeStatus(operator, queryEquipChargeStatusResult);
      //启动重试推送机制
      if(null == notificationEquipChargeStatusResult || 1 == notificationEquipChargeStatusResult.getSuccStat()){
         ThreadPoolExecutor threadPoolExecutor = new ThreadPoolExecutor(1, 1, 0L, TimeUnit.MILLISECONDS, new LinkedBlockingQueue<Runnable>());
         threadPoolExecutor.execute(new Runnable() {
            //计数器
            Integer size = 0;
@@ -1368,6 +1351,7 @@
      //执行停机操作
      R r = chargingOrderClient.tripartitePlatformStopCharge(queryStopCharge.getStartChargeSeq());
      if(200 != r.getCode()){
         log.info("三方平台请求停止充电失败:" + r.getMsg());
         queryStopChargeResult.setStartChargeSeqStat(5);
         queryStopChargeResult.setSuccStat(1);
         queryStopChargeResult.setFailReason(3);
@@ -1401,17 +1385,26 @@
   @PostMapping("/notificationStopChargeResult")
   public R notificationStopChargeResult(@RequestParam("startChargeSeq") String startChargeSeq, @RequestParam("connectorID") String connectorID,
                                         @RequestParam("operatorId") Integer operatorId){
        TChargingOrder chargingOrder = chargingOrderClient.getChargingOrderByStartChargeSeq(startChargeSeq).getData();
        if(null == chargingOrder){
            return null;
        }
        List<TChargingOrderAccountingStrategy> data = chargingOrderAccountingStrategyClient.getChargingOrderAccountingStrategyByOrderId(chargingOrder.getId()).getData();
      Operator operator = operatorClient.getOperatorById(operatorId).getData();
      NotificationStopChargeResult info = new NotificationStopChargeResult();
      info.setStartChargeSeq(startChargeSeq);
      info.setStartChargeSeqStat(4);
      info.setConnectorID(connectorID);
      info.setSuccStat(0);
      info.setFailReason(0);
        info.setStartChargeSeqStat(4);
        if(data.isEmpty()){
            info.setSuccStat(1);
            info.setFailReason(3);
        }else{
            info.setSuccStat(0);
            info.setFailReason(0);
        }
      NotificationStopCharge notificationStopCharge = TCECUtil.notificationStopChargeResult(operator, info);
      //启动重试推送机制
      if(null == notificationStopCharge || 1 == notificationStopCharge.getSuccStat()){
         ThreadPoolExecutor threadPoolExecutor = new ThreadPoolExecutor(1, 1, 0L, TimeUnit.MILLISECONDS, new LinkedBlockingQueue<Runnable>());
         threadPoolExecutor.execute(new Runnable() {
            //计数器
            Integer size = 0;
@@ -1449,11 +1442,13 @@
   @PostMapping("/notificationChargeOrderInfo")
   public R notificationChargeOrderInfo(@RequestParam("startChargeSeq") String startChargeSeq, @RequestParam("operatorId") Integer operatorId){
      NotificationChargeOrderInfo info = buildNotificationChargeOrderInfo(startChargeSeq);
      if(null == info){
         return R.fail("引流平台同步数据失败");
      }
      Operator operator = operatorClient.getOperatorById(operatorId).getData();
      NotificationChargeOrderInfoResult notificationChargeOrderInfoResult = TCECUtil.notificationChargeOrderInfo(operator, info);
      //启动重试推送机制
      if(null == notificationChargeOrderInfoResult || 1 == notificationChargeOrderInfoResult.getConfirmResult()){
         ThreadPoolExecutor threadPoolExecutor = new ThreadPoolExecutor(1, 1, 0L, TimeUnit.MILLISECONDS, new LinkedBlockingQueue<Runnable>());
         threadPoolExecutor.execute(new Runnable() {
            //计数器
            Integer size = 0;
@@ -1504,12 +1499,16 @@
      notificationChargeOrderInfo.setTotalPower(chargingOrder.getElectricity());
      
      List<TChargingOrderAccountingStrategy> data = chargingOrderAccountingStrategyClient.getChargingOrderAccountingStrategyByOrderId(chargingOrder.getId()).getData();
      if(data.isEmpty()){
         return null;
      }
      if(data.size() > 0){
         BigDecimal totalElectricity = data.stream().map(TChargingOrderAccountingStrategy::getPeriodElectricPrice).reduce(BigDecimal.ZERO, BigDecimal::add);
         BigDecimal serviceCharge = data.stream().map(TChargingOrderAccountingStrategy::getPeriodServicePrice).reduce(BigDecimal.ZERO, BigDecimal::add);
         notificationChargeOrderInfo.setTotalElecMoney(totalElectricity.setScale(2, RoundingMode.HALF_EVEN));
         notificationChargeOrderInfo.setTotalSeviceMoney(serviceCharge.setScale(2, RoundingMode.HALF_EVEN));
         notificationChargeOrderInfo.setTotalMoney(chargingOrder.getPaymentAmount());
         BigDecimal totalElectricity = data.stream().map(TChargingOrderAccountingStrategy::getPeriodElectricPrice).reduce(BigDecimal.ZERO, BigDecimal::add).setScale(4, RoundingMode.HALF_EVEN);
         BigDecimal serviceCharge = data.stream().map(TChargingOrderAccountingStrategy::getPeriodServicePrice).reduce(BigDecimal.ZERO, BigDecimal::add).setScale(4, RoundingMode.HALF_EVEN);
         BigDecimal totalMoney = totalElectricity.add(serviceCharge).setScale(4, RoundingMode.HALF_EVEN);
         notificationChargeOrderInfo.setTotalElecMoney(totalElectricity);
         notificationChargeOrderInfo.setTotalSeviceMoney(serviceCharge);
         notificationChargeOrderInfo.setTotalMoney(totalMoney);
      }else{
         notificationChargeOrderInfo.setTotalElecMoney(chargingOrder.getRechargeAmount().subtract(chargingOrder.getResidualAmount()));
         notificationChargeOrderInfo.setTotalSeviceMoney(BigDecimal.ZERO);
@@ -1845,7 +1844,7 @@
      if(null == pageSize){
         pageSize = 50;
      }
      PageInfo<Site> siteListPaging = siteClient.getSiteListPaging(pageNo, pageSize, stationIDs);
      PageInfo<Site> siteListPaging = siteClient.getSiteListPaging(pageNo, pageSize, stationIDs, -1);
      List<TParkingLot> parkingLots = parkingLotClient.getAllParkingLot().getData();
      QueryStationsInfoResult queryStationsInfoResult = new QueryStationsInfoResult();
      queryStationsInfoResult.setPageNo(pageNo);
@@ -1894,7 +1893,9 @@
      List<TChargingPile> chargingPiles = chargingPileClient.getChargingPileBySiteIds(stationIDList).getData();
      if(!CollectionUtils.isEmpty(chargingPiles)){
         List<Integer> pileIds = chargingPiles.stream().map(TChargingPile::getId).collect(Collectors.toList());
         List<TChargingGun> chargingGuns = chargingGunClient.getChargingGunByChargingPileIds(pileIds).getData();
         GetChargingGunByChargingPileIdsVo vo = new GetChargingGunByChargingPileIdsVo();
         vo.setChargingPileIds(pileIds);
         List<TChargingGun> chargingGuns = chargingGunClient.getChargingGunByChargingPileIds(vo).getData();
         if(!CollectionUtils.isEmpty(chargingGuns)){
            for (Integer stationID : stationIDList) {
               StationStatusInfo stationStatusInfo = new StationStatusInfo();
@@ -2069,7 +2070,7 @@
            break;
      }
      supEquipChargeStatus.setCurrentA(chargingOrder.getCurrent());
      supEquipChargeStatus.setSOC(new BigDecimal(chargingOrder.getEndSoc()));
      supEquipChargeStatus.setSOC(chargingOrder.getEndSoc());
      supEquipChargeStatus.setStartTime(chargingOrder.getStartTime() != null ? chargingOrder.getStartTime().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")) : "");
      supEquipChargeStatus.setEndTime(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()));
      supEquipChargeStatus.setTotalPower(chargingOrder.getElectrovalence());