diff --git a/jsowell-pile/src/main/java/com/jsowell/pile/service/impl/PileBasicInfoServiceImpl.java b/jsowell-pile/src/main/java/com/jsowell/pile/service/impl/PileBasicInfoServiceImpl.java index ed185e640..fb50aea81 100644 --- a/jsowell-pile/src/main/java/com/jsowell/pile/service/impl/PileBasicInfoServiceImpl.java +++ b/jsowell-pile/src/main/java/com/jsowell/pile/service/impl/PileBasicInfoServiceImpl.java @@ -1114,6 +1114,7 @@ public class PileBasicInfoServiceImpl implements PileBasicInfoService { equipmentInfo.setManufacturerID(Constants.OPERATORID_LIANLIAN); equipmentInfo.setManufacturerName(Constants.MANUFACTURER_NAME); equipmentInfo.setConstructionTime(DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD, pileBasicInfo.getCreateTime())); + equipmentInfo.setProductionDate(DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD, pileBasicInfo.getCreateTime())); PileModelInfoVO modelInfo = pileModelInfoService.getPileModelInfoByPileSn(pileSn); equipmentInfo.setEquipmentType(Integer.valueOf(modelInfo.getSpeedType())); @@ -1211,6 +1212,7 @@ public class PileBasicInfoServiceImpl implements PileBasicInfoService { connectorInfo.setCurrent(Integer.valueOf(modelInfo.getRatedCurrent())); connectorInfo.setConnectorName(pileConnectorInfo.getPileConnectorCode()); connectorInfo.setOperateStatus(50); // 50-正常使用 + connectorInfo.setOpreateStatus(50); // 50-正常使用 connectorInfo.setNationalStandard(2); // 2-2015 connectorInfo.setAuxPower(3); // 3-兼容12V和24V diff --git a/jsowell-pile/src/main/java/com/jsowell/pile/thirdparty/ConnectorInfo.java b/jsowell-pile/src/main/java/com/jsowell/pile/thirdparty/ConnectorInfo.java index 7f2edf0bc..1b021e141 100644 --- a/jsowell-pile/src/main/java/com/jsowell/pile/thirdparty/ConnectorInfo.java +++ b/jsowell-pile/src/main/java/com/jsowell/pile/thirdparty/ConnectorInfo.java @@ -82,6 +82,17 @@ public class ConnectorInfo { @JSONField(name = "OperateStatus") private Integer operateStatus; + /** + * 运营状态 + * 0-未知 + * 1-建设中 + * 5-关闭下线 + * 6-维护中 + * 50-正常使用 + */ + @JSONField(name = "OpreateStatus") + private Integer opreateStatus; + /** * 国家标准 */ diff --git a/jsowell-pile/src/main/java/com/jsowell/pile/thirdparty/EquipmentInfo.java b/jsowell-pile/src/main/java/com/jsowell/pile/thirdparty/EquipmentInfo.java index f1cc24ad5..35ae8fffa 100644 --- a/jsowell-pile/src/main/java/com/jsowell/pile/thirdparty/EquipmentInfo.java +++ b/jsowell-pile/src/main/java/com/jsowell/pile/thirdparty/EquipmentInfo.java @@ -53,7 +53,8 @@ public class EquipmentInfo { * 设备生产日期 N * YYYY-MM-DD */ - // private String ProductionDate; + @JSONField(name = "ProductionDate") + private String productionDate; /** * 建设时间 Y diff --git a/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/domain/SupStationInfo.java b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/domain/SupStationInfo.java index b42624455..0246ddf00 100644 --- a/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/domain/SupStationInfo.java +++ b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/domain/SupStationInfo.java @@ -24,6 +24,14 @@ public class SupStationInfo extends StationInfo { @JSONField(name = "StationUniqueNumber") private String stationUniqueNumber; + /** + * 设备接口分类 + * 1:车辆充电设备接口 + * 2:换电站内的电池箱充电设备接口 + */ + @JSONField(name = "EquipmentClassification") + private Integer equipmentClassification; + /** * 充换电站所在县以下行政区划代码 * 填写内容为12位行政区划代码,1-6位为县及以上行政区划代码,7-12位为县以下区划代码; diff --git a/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/service/impl/GuiZhouPlatformServiceImpl.java b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/service/impl/GuiZhouPlatformServiceImpl.java index bd7414d11..1f901e328 100644 --- a/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/service/impl/GuiZhouPlatformServiceImpl.java +++ b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/service/impl/GuiZhouPlatformServiceImpl.java @@ -25,8 +25,10 @@ import com.jsowell.pile.dto.QueryOperatorInfoDTO; import com.jsowell.pile.dto.QueryStationInfoDTO; import com.jsowell.pile.service.*; import com.jsowell.pile.thirdparty.CommonParamsDTO; +import com.jsowell.pile.thirdparty.ConnectorInfo; import com.jsowell.pile.thirdparty.EquipmentInfo; import com.jsowell.pile.util.MerchantUtils; +import com.jsowell.pile.vo.SupStationStatsVO; import com.jsowell.pile.vo.ThirdPartySecretInfoVO; import com.jsowell.pile.vo.base.ConnectorInfoVO; import com.jsowell.pile.vo.base.MerchantInfoVO; @@ -34,6 +36,7 @@ import com.jsowell.pile.vo.base.ThirdPartyStationInfoVO; import com.jsowell.pile.vo.uniapp.customer.BillingPriceVO; import com.jsowell.pile.vo.web.PileConnectorInfoVO; import com.jsowell.pile.vo.web.PileMerchantInfoVO; +import com.jsowell.pile.vo.web.PileModelInfoVO; import com.jsowell.pile.vo.web.PileStationVO; import com.jsowell.thirdparty.lianlian.domain.ConnectorChargeStatusInfo; import com.jsowell.thirdparty.lianlian.domain.ConnectorStatusInfo; @@ -59,6 +62,7 @@ import java.math.BigDecimal; import java.math.RoundingMode; import java.util.*; import java.util.concurrent.TimeUnit; +import java.util.function.Function; import java.util.stream.Collectors; /** @@ -85,6 +89,8 @@ public class GuiZhouPlatformServiceImpl implements ThirdPartyPlatformService { @Autowired private OrderBasicInfoService orderBasicInfoService; @Autowired + private PileModelInfoService pileModelInfoService; + @Autowired private PileBillingTemplateService pileBillingTemplateService; @Autowired private RedisCache redisCache; @@ -195,7 +201,7 @@ public class GuiZhouPlatformServiceImpl implements ThirdPartyPlatformService { /** * 查询充电站信息 query_stations_info - * supervise_query_operator_info + * supervise_query_stations_info * 此接口用于查询对接平台的充电站的信息 * * @param dto 查询站点信息dto @@ -236,6 +242,7 @@ public class GuiZhouPlatformServiceImpl implements ThirdPartyPlatformService { stationInfo.setStationLat(new BigDecimal(pileStationInfo.getStationLat())); stationInfo.setConstruction(Integer.valueOf(pileStationInfo.getConstruction())); stationInfo.setOpenAllDay(Integer.valueOf(pileStationInfo.getOpenAllDay())); + stationInfo.setPeriodFee(1); // stationInfo.setMinElectricityPrice(pileStationInfo); // 最低充电电费率 // stationInfo.setElectricityFee(); // 电费 xx元/度 // stationInfo.setServiceFee(); // 服务费 xx元/度 @@ -243,6 +250,7 @@ public class GuiZhouPlatformServiceImpl implements ThirdPartyPlatformService { stationInfo.setPayment(pileStationInfo.getPayment()); stationInfo.setSupportOrder(Integer.valueOf(pileStationInfo.getSupportOrder())); // stationInfo.setParkFeeType(pileStationInfo); // 停车收费类型 + stationInfo.setBusinessExpandType(Integer.parseInt(pileStationInfo.getAloneApply())); stationInfo.setToiletFlag(Integer.valueOf(pileStationInfo.getToiletFlag())); stationInfo.setStoreFlag(Integer.valueOf(pileStationInfo.getStoreFlag())); stationInfo.setRestaurantFlag(Integer.valueOf(pileStationInfo.getRestaurantFlag())); @@ -308,6 +316,8 @@ public class GuiZhouPlatformServiceImpl implements ThirdPartyPlatformService { .parkFree(Integer.valueOf(pileStationInfo.getParkFree())) .supportOrder(Integer.valueOf(pileStationInfo.getSupportOrder())) .parkFeeType(0) + .periodFee(1) // 峰谷分时 0-否;1-是 + .equipmentClassification(1) .toiletFlag(Integer.valueOf(pileStationInfo.getToiletFlag())) .storeFlag(Integer.valueOf(pileStationInfo.getStoreFlag())) .restaurantFlag(Integer.valueOf(pileStationInfo.getRestaurantFlag())) @@ -539,6 +549,7 @@ public class GuiZhouPlatformServiceImpl implements ThirdPartyPlatformService { .connectorID(orderInfo.getPileConnectorCode()) .orderNo(orderInfo.getOrderCode()) .orderStatus(2) + .equipmentClassification(1) .pushTimeStamp(dateTime) .connectorStatus(info.getStatus()) // 3-充电中 .currentA(current.setScale(1, BigDecimal.ROUND_HALF_UP)) @@ -686,6 +697,155 @@ public class GuiZhouPlatformServiceImpl implements ThirdPartyPlatformService { return result; } + /** + * 推送充换电站用能统计信息 supervise_notification_operation_stats_info + * + * @param stationId + * @throws UnsupportedOperationException 未实现异常 + */ + @Override + public String notificationOperationStatsInfo(String stationId) { + SupStationStatsInfo. + EquipmentStatsInfo equipmentStatsInfo = new SupStationStatsInfo.EquipmentStatsInfo(); + List equipmentStatsInfoList = new ArrayList<>(); + + SupStationStatsInfo. + EquipmentStatsInfo. + ConnectorStatsInfo connectorStatsInfo = null; + List connectorStatsInfoList = new ArrayList<>(); + + // 根据站点id查询订单记录 (新建Service方法) + List orderVOS = orderBasicInfoService.queryOrderListByStationId(stationId); + // 根据订单信息汇总出站点充电数据 + BigDecimal stationTotalElectricity = BigDecimal.ZERO; // 充电站累计用电量 + int stationChargeTime = Constants.zero; // 充电站累计充电次数 + for (SupStationStatsVO orderVO : orderVOS) { + // 充电站累计用电量 + BigDecimal totalPower = orderVO.getTotalPower(); + if (totalPower == null || orderVO.getChargingTime() == null) { + continue; + } + stationTotalElectricity = stationTotalElectricity.add(totalPower); + // 充电站累计充电时长(分钟) + stationChargeTime += orderVO.getChargingTime(); + } + + // 根据枪口排序,分组,将充电时长和充电量累加 + Map collect = orderVOS.stream() + .sorted(Comparator.comparing(SupStationStatsVO::getPileConnectorCode)) + .filter(vo -> vo.getChargingTime() != null && vo.getTotalPower() != null) + .collect(Collectors.toMap(SupStationStatsVO::getPileConnectorCode, Function.identity(), + (a, b) -> { + a.setChargingTime(a.getChargingTime() + b.getChargingTime()); + a.setTotalPower(a.getTotalPower().add(b.getTotalPower())); + return a; + })); + TreeMap sortedMap = new TreeMap<>(collect); + + // 初始化相关数据 + String pileSn = ""; + BigDecimal pileTotalPower = BigDecimal.ZERO; + int pileChargeTime = Constants.zero; + // key : pileConnectorCode + // value: SupStationStatsVO + for (Map.Entry entry : sortedMap.entrySet()) { + + String pileConnectorCode = entry.getKey(); + SupStationStatsVO vo = entry.getValue(); + + connectorStatsInfo = new SupStationStatsInfo.EquipmentStatsInfo.ConnectorStatsInfo(); + + // 先封装枪口数据 + connectorStatsInfo.setConnectorId(pileConnectorCode); + + connectorStatsInfo.setEquipmentClassification(1); + connectorStatsInfo.setConnectorElectricity(vo.getTotalPower()); + connectorStatsInfo.setConnectorTotalChargeTime(vo.getChargingTime()); + // TODO connectorStatsInfo.setConnectorTotalChargeNum(); + connectorStatsInfo.setConnectorTotalWarningNum(0); + + // 对比这次循环到的桩编号和上次的桩编号,如果是同一台桩,将数据进行汇总,如果不是,新建桩数据,并将之前的累计数据清0 + String newPileSn = vo.getPileSn(); + if (!StringUtils.equals(pileSn, newPileSn)) { + pileSn = newPileSn; + pileTotalPower = BigDecimal.ZERO; + pileChargeTime = Constants.zero; + + equipmentStatsInfo = new SupStationStatsInfo.EquipmentStatsInfo(); + connectorStatsInfoList = new ArrayList<>(); + + equipmentStatsInfo.setEquipmentId(pileSn); + equipmentStatsInfo.setEquipmentClassification(1); + equipmentStatsInfo.setEquipmentElectricity(vo.getTotalPower()); + equipmentStatsInfo.setEquipmentTotalChargeTime(vo.getChargingTime()); + // TODO equipmentStatsInfo.setEquipmentTotalChargeNum(); + + pileTotalPower = pileTotalPower.add(vo.getTotalPower()); + pileChargeTime += vo.getChargingTime(); + + connectorStatsInfoList.add(connectorStatsInfo); + equipmentStatsInfo.setConnectorStatsInfos(connectorStatsInfoList); + equipmentStatsInfoList.add(equipmentStatsInfo); + } else { + // 同一台桩,枪口号不同,累加桩数据,将枪口数据新建 + + pileTotalPower = pileTotalPower.add(vo.getTotalPower()); + pileChargeTime += vo.getChargingTime(); + + equipmentStatsInfo.setEquipmentElectricity(pileTotalPower); // 第一次判断时一定不会进入到这里,所以不用判断 equipmentStatsInfo 是否为 null + equipmentStatsInfo.setEquipmentTotalChargeTime(pileChargeTime); + + connectorStatsInfoList.add(connectorStatsInfo); + equipmentStatsInfo.setConnectorStatsInfos(connectorStatsInfoList); + equipmentStatsInfoList.add(equipmentStatsInfo); + } + + } + + // 创建对象 + String startTime = DateUtils.getYesterdayStr() + " 00:00:00"; + String endTime = DateUtils.getYesterdayStr() + " 23:59:59"; + SupStationStatsInfo supStationStatsInfo = SupStationStatsInfo.builder() + .stationId(stationId) + .operatorId(Constants.OPERATORID_JIANG_SU) + // .equipmentOwnerId(orderVOS.get(0).getOrganizationCode()) + .stationClassification(1) + .startTime(startTime) + .endTime(endTime) + .stationElectricity(stationTotalElectricity) + .stationTotalChargeEnergy(stationTotalElectricity) + .stationTotalChargeNum(orderVOS.size()) + .stationTotalChargeTime(stationChargeTime) + .stationTotalWarningNum(0) + .equipmentStatsInfos(equipmentStatsInfoList) + + .build(); + JSONObject json = new JSONObject(); + json.put("StationStatsInfos", supStationStatsInfo); + String jsonString = JSON.toJSONString(json); + // 发送推送请求 + ThirdPartySecretInfoVO guiZhouPlatformSecretInfo = getGuiZhouPlatformSecretInfo(); + + String operatorId = guiZhouPlatformSecretInfo.getOurOperatorId(); + String operatorSecret = guiZhouPlatformSecretInfo.getTheirOperatorSecret(); + String signSecret = guiZhouPlatformSecretInfo.getTheirSigSecret(); + String dataSecret = guiZhouPlatformSecretInfo.getTheirDataSecret(); + String dataSecretIv = guiZhouPlatformSecretInfo.getTheirDataSecretIv(); + String urlAddress = guiZhouPlatformSecretInfo.getTheirUrlPrefix(); + String url = urlAddress + "supervise_notification_operation_stats_info"; + // 获取令牌 + String token = getToken(urlAddress, operatorId, operatorSecret, dataSecretIv, signSecret, dataSecret); + if (StringUtils.isBlank(token)) { + return null; + } + // 调用平台接口 + String result = HttpRequestUtil.sendPost(token, jsonString, url, dataSecret, dataSecretIv, operatorId, signSecret); + return result; + } + /** * 推送充换电站实时功率 supervise_notification_realtime_power_info * @@ -802,7 +962,7 @@ public class GuiZhouPlatformServiceImpl implements ThirdPartyPlatformService { private ThirdPartySecretInfoVO getGuiZhouPlatformSecretInfo() { String thirdPartyType = ThirdPlatformTypeEnum.GUI_ZHOU_PLATFORM.getTypeCode(); // 通过第三方平台类型查询相关配置信息 - ThirdPartySecretInfoVO thirdPartySecretInfoVO = thirdpartySecretInfoService.queryByThirdPlatformType(ThirdPlatformTypeEnum.GUI_ZHOU_PLATFORM.getTypeCode()); + ThirdPartySecretInfoVO thirdPartySecretInfoVO = thirdpartySecretInfoService.queryByThirdPlatformType(thirdPartyType); if (thirdPartySecretInfoVO == null) { throw new BusinessException(ReturnCodeEnum.CODE_SELECT_INFO_IS_NULL); }