This commit is contained in:
YAS\29473
2024-12-11 08:29:36 +08:00
parent 053531e7ff
commit efe56dc82f
9 changed files with 267 additions and 182 deletions

View File

@@ -1,10 +1,11 @@
package com.jsowell.api.thirdparty; package com.jsowell.api.thirdparty;
import com.alibaba.fastjson2.JSON; import com.alibaba.fastjson2.JSON;
import com.jsowell.common.annotation.Anonymous; import com.jsowell.common.annotation.Anonymous;
import com.jsowell.common.core.domain.AjaxResult;
import com.jsowell.common.enums.thirdparty.ThirdPartyReturnCodeEnum; import com.jsowell.common.enums.thirdparty.ThirdPartyReturnCodeEnum;
import com.jsowell.common.exception.BusinessException; import com.jsowell.common.exception.BusinessException;
import com.jsowell.common.response.RestApiResponse;
import com.jsowell.pile.dto.QueryOperatorInfoDTO; import com.jsowell.pile.dto.QueryOperatorInfoDTO;
import com.jsowell.pile.dto.QueryStationInfoDTO; import com.jsowell.pile.dto.QueryStationInfoDTO;
import com.jsowell.pile.thirdparty.CommonParamsDTO; import com.jsowell.pile.thirdparty.CommonParamsDTO;
@@ -12,12 +13,10 @@ import com.jsowell.thirdparty.lianlian.common.CommonResult;
import com.jsowell.thirdparty.platform.service.ThirdPartyPlatformService; import com.jsowell.thirdparty.platform.service.ThirdPartyPlatformService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import java.util.List;
import java.util.Map; import java.util.Map;
/** /**
@@ -33,6 +32,7 @@ public class GuiZhouPlatformController extends ThirdPartyBaseController {
@Qualifier("guiZhouPlatformServiceImpl") @Qualifier("guiZhouPlatformServiceImpl")
private ThirdPartyPlatformService platformLogic; private ThirdPartyPlatformService platformLogic;
/** /**
* getToken * getToken
*/ */
@@ -150,4 +150,63 @@ public class GuiZhouPlatformController extends ThirdPartyBaseController {
} }
return CommonResult.failed("查询充电站状态信息发生异常"); return CommonResult.failed("查询充电站状态信息发生异常");
} }
/**
* 历史充电订单信息推送
*/
@GetMapping("/v1/supervise_notification_charge_order_info_history/{orderCode}")
public RestApiResponse<?> notificationChargeOrderInfoHistory(@PathVariable("orderCode") String orderCode) {
RestApiResponse<?> response = null;
String result = null;
try {
result = platformLogic.notificationChargeOrderInfoHistory(orderCode);
response = new RestApiResponse<>(result);
} catch (Exception e) {
logger.error("贵州平台推送充电站历史充电订单信息 error", e);
return new RestApiResponse<>(e);
}
logger.info("贵州平台推送充电站历史充电订单信息 result:{}", result);
return response;
}
/**
* 推送充换电站用能统计信息
* @param stationId
* @return
*/
@GetMapping("/v1/supervise_notification_operation_stats_info/{stationId}")
public RestApiResponse<?> notificationOperationStatsInfo(@PathVariable("stationId") String stationId) {
RestApiResponse<?> response = null;
String result = null;
try {
result = platformLogic.notificationOperationStatsInfo(stationId);
response = new RestApiResponse<>(result);
} catch (Exception e) {
logger.error("贵州平台推送充换电站用能统计信息 error", e);
return new RestApiResponse<>(e);
}
logger.info("贵州平台推送充换电站用能统计信息 result:{}", result);
return response;
}
/**
* 推送充换电站实时功率
* @param stationIds
* @return
*/
@GetMapping("/v1/supervise_notification_realtime_power_info/{stationIds}")
public RestApiResponse<?> notificationPowerInfo(@PathVariable("stationIds") List<String> stationIds) {
RestApiResponse<?> response = null;
String result = null;
try {
result = platformLogic.notificationPowerInfo(stationIds);
response = new RestApiResponse<>(result);
} catch (Exception e) {
logger.error("贵州平台推送充换电站用能统计信息 error", e);
return new RestApiResponse<>(e);
}
logger.info("贵州平台推送充换电站用能统计信息 result:{}", result);
return response;
}
} }

View File

@@ -95,6 +95,7 @@ public class Constants {
public static final String OPERATORID_LIANLIAN = "MA1JLFUU8"; public static final String OPERATORID_LIANLIAN = "MA1JLFUU8";
public static final String OPERATORID_JIANG_SU = "MA1X78KH5"; public static final String OPERATORID_JIANG_SU = "MA1X78KH5";
public static final String OPERATORID_GUI_ZHOU = "MAC9K4RRX";
public static final String MANUFACTURER_NAME = "举视(江苏)新能源设备制造有限公司"; public static final String MANUFACTURER_NAME = "举视(江苏)新能源设备制造有限公司";

View File

@@ -383,6 +383,11 @@ public class PileStationInfo extends BaseEntity {
@Excel(name = "周边配套设施") @Excel(name = "周边配套设施")
private String supportingFacilities; private String supportingFacilities;
/**
* 站点额定总功率
*/
@Excel(name = "站点额定总功率")
private BigDecimal ratedPower;
/** /**
* 删除标识0-正常1-删除) * 删除标识0-正常1-删除)
@@ -436,6 +441,7 @@ public class PileStationInfo extends BaseEntity {
.append("delFlag", delFlag) .append("delFlag", delFlag)
.append("swapMatchCars", swapMatchCars) .append("swapMatchCars", swapMatchCars)
.append("generalApplicationType",generalApplicationType) .append("generalApplicationType",generalApplicationType)
.append("ratedPower",ratedPower)
.toString(); .toString();
} }
} }

View File

@@ -110,7 +110,6 @@ public interface PileBasicInfoService {
/** /**
* 通过桩sn查询basic信息 * 通过桩sn查询basic信息
* *
* @param id 桩id
* @return 结果集合 * @return 结果集合
*/ */
PileDetailVO selectPileDetailByPileSn(String pileSn); PileDetailVO selectPileDetailByPileSn(String pileSn);
@@ -206,7 +205,6 @@ public interface PileBasicInfoService {
/** /**
* 获取充电桩列表 * 获取充电桩列表
* 提供给联联平台 * 提供给联联平台
* @param pileStationInfo
* @return * @return
*/ */
// List<EquipmentInfo> getPileList(PileStationInfo pileStationInfo); // List<EquipmentInfo> getPileList(PileStationInfo pileStationInfo);

View File

@@ -81,7 +81,7 @@ public class EquipmentInfo {
* 1车辆充电设备 2换电站内的电池箱 充电设备 * 1车辆充电设备 2换电站内的电池箱 充电设备
*/ */
@JSONField(name = "EquipmentClassification") @JSONField(name = "EquipmentClassification")
private Integer EquipmentClassification; private Integer equipmentClassification;
/** /**
* 设备状态 Y * 设备状态 Y

View File

@@ -2912,8 +2912,10 @@
JOIN pile_merchant_info t3 on t1.merchant_id = t3.id JOIN pile_merchant_info t3 on t1.merchant_id = t3.id
WHERE WHERE
t1.station_id = #{stationId,jdbcType=VARCHAR} t1.station_id = #{stationId,jdbcType=VARCHAR}
AND t1.charge_start_time <![CDATA[ >= ]]> DATE_SUB( CURDATE(), INTERVAL 1 DAY ) -- AND t1.charge_start_time <![CDATA[ >= ]]> DATE_SUB( CURDATE(), INTERVAL 1 DAY )
AND t1.charge_start_time <![CDATA[ < ]]> CURDATE() -- AND t1.charge_start_time <![CDATA[ < ]]> CURDATE()
AND t1.charge_start_time <![CDATA[ >= ]]> '2024-07-08'
AND t1.charge_start_time <![CDATA[ < ]]> '2024-8-19'
</select> </select>
<select id="queryOrderByOccupyTime" resultType="com.jsowell.pile.vo.web.OrderListVO"> <select id="queryOrderByOccupyTime" resultType="com.jsowell.pile.vo.web.OrderListVO">

View File

@@ -68,6 +68,12 @@ public class SupStationPowerInfo {
@JSONField(name = "EquipmentPowerInfos") @JSONField(name = "EquipmentPowerInfos")
private List<EquipmentPowerInfo> equipmentPowerInfos; private List<EquipmentPowerInfo> equipmentPowerInfos;
/**
* 充电设备功率信息列表
*/
@JSONField(name = "SupEquipmentPowerInfos")
private List<EquipmentPowerInfo> supEquipmentPowerInfos;
@Data @Data
public static class EquipmentPowerInfo{ public static class EquipmentPowerInfo{
/** /**
@@ -104,6 +110,11 @@ public class SupStationPowerInfo {
@JSONField(name = "ConnectorPowerInfos") @JSONField(name = "ConnectorPowerInfos")
private List<ConnectorPowerInfo> connectorPowerInfos; private List<ConnectorPowerInfo> connectorPowerInfos;
/**
* 充电设备接口实时功率列表
*/
@JSONField(name = "SupConnectorPowerInfos")
private List<ConnectorPowerInfo> supConnectorPowerInfos;
@Data @Data
public static class ConnectorPowerInfo{ public static class ConnectorPowerInfo{

View File

@@ -26,6 +26,15 @@ public class ChargeOrderInfo {
@JSONField(name = "OperatorID") @JSONField(name = "OperatorID")
private String operatorID; private String operatorID;
/**
* 设备分类
* 1车辆充电设备
* 2换电站内的电池箱充电设备
*/
@JSONField(name = "EquipmentClassification")
private Integer equipmentClassification;
/** /**
* 设备所属方 * 设备所属方
* IDEquipmentOwnerID * IDEquipmentOwnerID
@@ -233,6 +242,17 @@ public class ChargeOrderInfo {
@JSONField(name = "TotalSeviceMoney") @JSONField(name = "TotalSeviceMoney")
private BigDecimal totalSeviceMoney; private BigDecimal totalSeviceMoney;
/**
* 总服务费
* TotalSeviceMoney
* 本单总服务费单位小数点后4位
* 是
* 浮点数
* ≤8字符小数点后4位
*/
@JSONField(name = "TotalServiceMoney")
private BigDecimal totalServiceMoney;
/** /**
* 累计总金额 * 累计总金额
* TotalMoney * TotalMoney

View File

@@ -13,6 +13,7 @@ import com.jsowell.common.core.redis.RedisCache;
import com.jsowell.common.enums.lianlian.StationPaymentEnum; import com.jsowell.common.enums.lianlian.StationPaymentEnum;
import com.jsowell.common.enums.thirdparty.ThirdPlatformTypeEnum; import com.jsowell.common.enums.thirdparty.ThirdPlatformTypeEnum;
import com.jsowell.common.enums.ykc.BillingTimeTypeEnum; import com.jsowell.common.enums.ykc.BillingTimeTypeEnum;
import com.jsowell.common.enums.ykc.OrderStatusEnum;
import com.jsowell.common.enums.ykc.PileConnectorDataBaseStatusEnum; import com.jsowell.common.enums.ykc.PileConnectorDataBaseStatusEnum;
import com.jsowell.common.enums.ykc.ReturnCodeEnum; import com.jsowell.common.enums.ykc.ReturnCodeEnum;
import com.jsowell.common.exception.BusinessException; import com.jsowell.common.exception.BusinessException;
@@ -30,10 +31,10 @@ import com.jsowell.pile.vo.ThirdPartySecretInfoVO;
import com.jsowell.pile.vo.base.ConnectorInfoVO; import com.jsowell.pile.vo.base.ConnectorInfoVO;
import com.jsowell.pile.vo.base.MerchantInfoVO; import com.jsowell.pile.vo.base.MerchantInfoVO;
import com.jsowell.pile.vo.base.ThirdPartyStationInfoVO; import com.jsowell.pile.vo.base.ThirdPartyStationInfoVO;
import com.jsowell.pile.vo.base.ThirdPartyStationRelationVO;
import com.jsowell.pile.vo.uniapp.customer.BillingPriceVO; import com.jsowell.pile.vo.uniapp.customer.BillingPriceVO;
import com.jsowell.pile.vo.web.PileConnectorInfoVO; import com.jsowell.pile.vo.web.PileConnectorInfoVO;
import com.jsowell.pile.vo.web.PileMerchantInfoVO; import com.jsowell.pile.vo.web.PileMerchantInfoVO;
import com.jsowell.thirdparty.lianlian.domain.ConnectorChargeStatusInfo;
import com.jsowell.thirdparty.lianlian.domain.ConnectorStatusInfo; import com.jsowell.thirdparty.lianlian.domain.ConnectorStatusInfo;
import com.jsowell.thirdparty.lianlian.domain.StationStatusInfo; import com.jsowell.thirdparty.lianlian.domain.StationStatusInfo;
import com.jsowell.thirdparty.lianlian.vo.AccessTokenVO; import com.jsowell.thirdparty.lianlian.vo.AccessTokenVO;
@@ -41,7 +42,6 @@ import com.jsowell.thirdparty.platform.domain.*;
import com.jsowell.thirdparty.platform.factory.ThirdPartyPlatformFactory; import com.jsowell.thirdparty.platform.factory.ThirdPartyPlatformFactory;
import com.jsowell.thirdparty.platform.service.ThirdPartyPlatformService; import com.jsowell.thirdparty.platform.service.ThirdPartyPlatformService;
import com.jsowell.thirdparty.platform.util.Cryptos; import com.jsowell.thirdparty.platform.util.Cryptos;
import com.jsowell.thirdparty.platform.util.GBSignUtils;
import com.jsowell.thirdparty.platform.util.HttpRequestUtil; import com.jsowell.thirdparty.platform.util.HttpRequestUtil;
import com.jsowell.thirdparty.platform.util.ThirdPartyPlatformUtils; import com.jsowell.thirdparty.platform.util.ThirdPartyPlatformUtils;
import com.jsowell.thirdparty.service.ThirdpartySecretInfoService; import com.jsowell.thirdparty.service.ThirdpartySecretInfoService;
@@ -55,6 +55,7 @@ import org.springframework.stereotype.Service;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.math.RoundingMode; import java.math.RoundingMode;
import java.text.DecimalFormat;
import java.util.*; import java.util.*;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import java.util.function.Function; import java.util.function.Function;
@@ -78,14 +79,10 @@ public class GuiZhouPlatformServiceImpl implements ThirdPartyPlatformService {
@Autowired @Autowired
private PileMerchantInfoService pileMerchantInfoService; private PileMerchantInfoService pileMerchantInfoService;
@Autowired @Autowired
private ThirdPartyPlatformConfigService thirdPartyPlatformConfigService;
@Autowired
private PileConnectorInfoService pileConnectorInfoService; private PileConnectorInfoService pileConnectorInfoService;
@Autowired @Autowired
private OrderBasicInfoService orderBasicInfoService; private OrderBasicInfoService orderBasicInfoService;
@Autowired @Autowired
private PileModelInfoService pileModelInfoService;
@Autowired
private PileBillingTemplateService pileBillingTemplateService; private PileBillingTemplateService pileBillingTemplateService;
@Autowired @Autowired
private RedisCache redisCache; private RedisCache redisCache;
@@ -222,7 +219,7 @@ public class GuiZhouPlatformServiceImpl implements ThirdPartyPlatformService {
String stationId = String.valueOf(pileStationInfo.getId()); String stationId = String.valueOf(pileStationInfo.getId());
stationInfo.setStationID(stationId); stationInfo.setStationID(stationId);
// MerchantInfoVO merchantInfo = pileMerchantInfoService.getMerchantInfo(String.valueOf(pileStationInfo.getMerchantId())); // MerchantInfoVO merchantInfo = pileMerchantInfoService.getMerchantInfo(String.valueOf(pileStationInfo.getMerchantId()));
stationInfo.setOperatorID(Constants.OPERATORID_LIANLIAN); // 组织机构代码 stationInfo.setOperatorID(Constants.OPERATORID_JIANG_SU); // 组织机构代码
stationInfo.setEquipmentOwnerID(String.valueOf(pileStationInfo.getMerchantId())); stationInfo.setEquipmentOwnerID(String.valueOf(pileStationInfo.getMerchantId()));
stationInfo.setStationName(pileStationInfo.getStationName()); stationInfo.setStationName(pileStationInfo.getStationName());
stationInfo.setIsAloneApply(Integer.valueOf(pileStationInfo.getAloneApply())); stationInfo.setIsAloneApply(Integer.valueOf(pileStationInfo.getAloneApply()));
@@ -243,7 +240,17 @@ public class GuiZhouPlatformServiceImpl implements ThirdPartyPlatformService {
// stationInfo.setServiceFee(); // 服务费 xx元/度 // stationInfo.setServiceFee(); // 服务费 xx元/度
stationInfo.setParkFree(Integer.valueOf(pileStationInfo.getParkFree())); stationInfo.setParkFree(Integer.valueOf(pileStationInfo.getParkFree()));
stationInfo.setPayment(pileStationInfo.getPayment()); stationInfo.setPayment(pileStationInfo.getPayment());
stationInfo.setStationClassification(1);
stationInfo.setSupportOrder(Integer.valueOf(pileStationInfo.getSupportOrder())); stationInfo.setSupportOrder(Integer.valueOf(pileStationInfo.getSupportOrder()));
stationInfo.setStationStatus(Integer.valueOf(pileStationInfo.getStationStatus()));
stationInfo.setParkNums(Integer.valueOf(pileStationInfo.getParkNums()));
stationInfo.setRoundTheClock(Constants.ONE);
stationInfo.setParkType("255");
stationInfo.setElectricityType(1);
stationInfo.setCapacity(pileStationInfo.getCapacity().setScale(2, RoundingMode.HALF_UP));
stationInfo.setRatedPower(pileStationInfo.getRatedPower().setScale(1, RoundingMode.HALF_UP));
stationInfo.setOfficialRunTime(DateUtils.dateTime(pileStationInfo.getCreateTime()));
stationInfo.setVideoMonitor(0);
// stationInfo.setParkFeeType(pileStationInfo); // 停车收费类型 // stationInfo.setParkFeeType(pileStationInfo); // 停车收费类型
stationInfo.setBusinessExpandType(Integer.parseInt(pileStationInfo.getAloneApply())); stationInfo.setBusinessExpandType(Integer.parseInt(pileStationInfo.getAloneApply()));
@@ -260,7 +267,15 @@ public class GuiZhouPlatformServiceImpl implements ThirdPartyPlatformService {
stationInfo.setEquipmentInfos(pileList); // 充电设备信息列表 stationInfo.setEquipmentInfos(pileList); // 充电设备信息列表
} }
resultList.add(stationInfo); resultList.add(stationInfo);
// areaCodeCountryside
GeoCodeInfo geoCode = TermRelationTreeCoordinate.completeGeoCode(pileStationInfo.getAddress());
if (geoCode != null) {
String areaCodeCountryside = geoCode.getCounty_code();
stationInfo.setAreaCodeCountryside(areaCodeCountryside);
}
} }
Map<String, Object> map = new LinkedHashMap<>(); Map<String, Object> map = new LinkedHashMap<>();
map.put("PageNo", pageInfo.getPageNum()); map.put("PageNo", pageInfo.getPageNum());
map.put("PageCount", pageInfo.getPages()); map.put("PageCount", pageInfo.getPages());
@@ -292,6 +307,8 @@ public class GuiZhouPlatformServiceImpl implements ThirdPartyPlatformService {
// 组装所需要的数据格式 // 组装所需要的数据格式
SupStationInfo info = SupStationInfo.builder() SupStationInfo info = SupStationInfo.builder()
.stationID(stationId) .stationID(stationId)
.equipmentClassification(Constants.ONE)
.generalApplicationType(2)
.operatorID(operatorId) .operatorID(operatorId)
.stationName(pileStationInfo.getStationName()) .stationName(pileStationInfo.getStationName())
.periodFee(1) // 峰谷分时 0-否1-是 .periodFee(1) // 峰谷分时 0-否1-是
@@ -318,6 +335,9 @@ public class GuiZhouPlatformServiceImpl implements ThirdPartyPlatformService {
.parkFree(Integer.valueOf(pileStationInfo.getParkFree())) .parkFree(Integer.valueOf(pileStationInfo.getParkFree()))
.supportOrder(Integer.valueOf(pileStationInfo.getSupportOrder())) .supportOrder(Integer.valueOf(pileStationInfo.getSupportOrder()))
.parkFeeType(0) .parkFeeType(0)
.ratedPower(BigDecimal.ONE)//站点额定总功率
.officialRunTime(DateUtils.dateTime(pileStationInfo.getCreateTime()))//正式投运时间
.businessExpandType(1)//报装类型
.toiletFlag(Integer.valueOf(pileStationInfo.getToiletFlag())) .toiletFlag(Integer.valueOf(pileStationInfo.getToiletFlag()))
.storeFlag(Integer.valueOf(pileStationInfo.getStoreFlag())) .storeFlag(Integer.valueOf(pileStationInfo.getStoreFlag()))
@@ -334,20 +354,8 @@ public class GuiZhouPlatformServiceImpl implements ThirdPartyPlatformService {
// 只取最后一部分 330213 // 只取最后一部分 330213
String subAreaCode = split[split.length - 1]; String subAreaCode = split[split.length - 1];
info.setAreaCode(subAreaCode); info.setAreaCode(subAreaCode);
// 截取运营商组织机构代码(去除最后一位后的最后九位)
String organizationCode = ""; info.setEquipmentOwnerID(Constants.OPERATORID_GUI_ZHOU);
if (StringUtils.equals(ThirdPlatformTypeEnum.LIAN_LIAN_PLATFORM.getTypeCode(), thirdPlatformType)) {
// 联联平台先使用自己运营商的组织机构代码
organizationCode = Constants.OPERATORID_LIANLIAN;
info.setEquipmentOwnerID(organizationCode);
} else {
MerchantInfoVO merchantInfo = pileMerchantInfoService.getMerchantInfoVO(String.valueOf(pileStationInfo.getMerchantId()));
organizationCode = merchantInfo.getOrganizationCode();
if (StringUtils.isNotBlank(organizationCode) && organizationCode.length() == 18) {
String equipmentOwnerId = StringUtils.substring(organizationCode, organizationCode.length() - 10, organizationCode.length() - 1);
info.setEquipmentOwnerID(equipmentOwnerId);
}
}
info.setPayment(StationPaymentEnum.getPaymentByCode(pileStationInfo.getPayment())); info.setPayment(StationPaymentEnum.getPaymentByCode(pileStationInfo.getPayment()));
if (StringUtils.isNotBlank(pileStationInfo.getParkingNumber())) { if (StringUtils.isNotBlank(pileStationInfo.getParkingNumber())) {
@@ -361,7 +369,7 @@ public class GuiZhouPlatformServiceImpl implements ThirdPartyPlatformService {
// 容量 // 容量
if (StringUtils.isNotBlank(String.valueOf(pileStationInfo.getCapacity()))) { if (StringUtils.isNotBlank(String.valueOf(pileStationInfo.getCapacity()))) {
info.setCapacity(pileStationInfo.getCapacity().setScale(4, RoundingMode.HALF_UP)); info.setCapacity(pileStationInfo.getCapacity().setScale(2, RoundingMode.HALF_UP));
} }
List<EquipmentInfo> pileList = pileBasicInfoService.getPileListForLianLian(stationId); List<EquipmentInfo> pileList = pileBasicInfoService.getPileListForLianLian(stationId);
if (CollectionUtils.isNotEmpty(pileList)) { if (CollectionUtils.isNotEmpty(pileList)) {
@@ -400,54 +408,37 @@ public class GuiZhouPlatformServiceImpl implements ThirdPartyPlatformService {
public Map<String, String> queryStationStatus(QueryStationInfoDTO dto) { public Map<String, String> queryStationStatus(QueryStationInfoDTO dto) {
List<String> stationIds = dto.getStationIds(); List<String> stationIds = dto.getStationIds();
List<StationStatusInfo> StationStatusInfos = new ArrayList<>(); List<StationStatusInfo> StationStatusInfos = new ArrayList<>();
List<Object> ConnectorStatusInfos = new ArrayList<>(); List<Object> connectorStatusInfos = new ArrayList<>();
ThirdPartyPlatformConfig configInfo = thirdPartyPlatformConfigService.getInfoByOperatorId(dto.getOperatorId()); ThirdPartySecretInfoVO thirdPartySecretInfoVO = thirdpartySecretInfoService.queryByThirdPlatformType(thirdPlatformType);
if (configInfo == null) { if (thirdPartySecretInfoVO == null) {
return null; return null;
} }
ConnectorStatusInfo connectorStatusInfo; ConnectorStatusInfo connectorStatusInfo;
for (String stationId : stationIds) { for (String stationId : stationIds) {
PileMerchantInfoVO pileMerchantInfoVO = pileMerchantInfoService.queryMerchantInfoByStationId(stationId);
StationStatusInfo stationStatusInfo = new StationStatusInfo(); StationStatusInfo stationStatusInfo = new StationStatusInfo();
stationStatusInfo.setStationId(stationId); stationStatusInfo.setStationId(stationId);
stationStatusInfo.setOperatorId(Constants.OPERATORID_JIANG_SU);
stationStatusInfo.setStationStatus(50);
String equipmentOwnerID = ThirdPartyPlatformUtils.extractEquipmentOwnerID(pileMerchantInfoVO.getOrganizationCode());
stationStatusInfo.setEquipmentOwnerId(equipmentOwnerID);
// 根据站点id查询 // 根据站点id查询
List<ConnectorInfoVO> list = pileConnectorInfoService.getConnectorListForLianLian(Long.parseLong(stationId)); List<ConnectorInfoVO> list = pileConnectorInfoService.getConnectorListForLianLian(Long.parseLong(stationId));
for (ConnectorInfoVO connectorInfoVO : list) { for (ConnectorInfoVO connectorInfoVO : list) {
connectorStatusInfo = new ConnectorStatusInfo();
String connectorStatus = connectorInfoVO.getConnectorStatus(); String connectorStatus = connectorInfoVO.getConnectorStatus();
if (StringUtils.equals(connectorStatus, PileConnectorDataBaseStatusEnum.OCCUPIED_CHARGING.getValue())) { connectorStatusInfo.setEquipmentClassification(1);
// 充电中 connectorStatusInfo.setStationId(stationId);
ConnectorChargeStatusInfo info = new ConnectorChargeStatusInfo(); connectorStatusInfo.setConnectorID(connectorInfoVO.getPileConnectorCode());
OrderBasicInfo orderBasicInfo = orderBasicInfoService.queryChargingByPileConnectorCode(connectorInfoVO.getPileConnectorCode()); connectorStatusInfo.setEquipmentOwnerId(equipmentOwnerID);
if (orderBasicInfo == null) { connectorStatusInfo.setOperatorId(Constants.OPERATORID_JIANG_SU);
continue; connectorStatusInfo.setEquipmentId(connectorInfoVO.getPileSn());
} connectorStatusInfo.setStatus(Integer.parseInt(connectorStatus));
List<RealTimeMonitorData> chargingRealTimeData = orderBasicInfoService.getChargingRealTimeData(orderBasicInfo.getTransactionCode()); connectorStatusInfo.setUpdateTime(DateUtils.getDateTime());
if (CollectionUtils.isNotEmpty(chargingRealTimeData)) {
RealTimeMonitorData realTimeMonitorData = chargingRealTimeData.get(0);
info.setStartChargeSeq(orderBasicInfo.getOrderCode()); connectorStatusInfos.add(connectorStatusInfo);
info.setConnectorID(orderBasicInfo.getPileConnectorCode());
info.setConnectorStatus(Integer.valueOf(connectorInfoVO.getConnectorStatus()));
info.setCurrentA(new BigDecimal(realTimeMonitorData.getOutputCurrent()));
info.setVoltageA(new BigDecimal(realTimeMonitorData.getOutputVoltage()));
info.setSoc(new BigDecimal(realTimeMonitorData.getSOC()));
info.setStartTime(DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD_HH_MM_SS, orderBasicInfo.getChargeStartTime()));
info.setEndTime(DateUtils.getDateTime()); // 本次采样时间
info.setTotalPower(new BigDecimal(realTimeMonitorData.getChargingDegree())); // 累计充电量
info.setTotalMoney(new BigDecimal(realTimeMonitorData.getChargingAmount()));
ConnectorStatusInfos.add(info);
}
} else {
// 其他
connectorStatusInfo = new ConnectorStatusInfo();
connectorStatusInfo.setConnectorID(connectorInfoVO.getPileConnectorCode());
connectorStatusInfo.setStatus(Integer.parseInt(connectorInfoVO.getConnectorStatus()));
ConnectorStatusInfos.add(connectorStatusInfo);
}
} }
stationStatusInfo.setConnectorStatusInfos(ConnectorStatusInfos); stationStatusInfo.setConnectorStatusInfos(connectorStatusInfos);
StationStatusInfos.add(stationStatusInfo); StationStatusInfos.add(stationStatusInfo);
} }
// 将 StationStatusInfos 分页 // 将 StationStatusInfos 分页
@@ -458,20 +449,10 @@ public class GuiZhouPlatformServiceImpl implements ThirdPartyPlatformService {
.limit(pageSize) .limit(pageSize)
.collect(Collectors.toList()); .collect(Collectors.toList());
int total = StationStatusInfos.size();
int pages = PageUtil.totalPage(total, pageSize);
Map<String, Object> map = new LinkedHashMap<>(); Map<String, Object> map = new LinkedHashMap<>();
map.put("Total", total);
map.put("StationStatusInfos", collect); map.put("StationStatusInfos", collect);
Map<String, String> resultMap = Maps.newLinkedHashMap(); Map<String, String> resultMap = ThirdPartyPlatformUtils.generateResultMap(map, thirdPartySecretInfoVO);
// 加密数据
String encryptData = Cryptos.aesEncrypt(JSON.toJSONString(map), configInfo.getDataSecret(), configInfo.getDataSecretIv());
resultMap.put("Data", encryptData);
// 生成sig
String resultSign = GBSignUtils.sign(resultMap, configInfo.getSignSecret());
resultMap.put("Sig", resultSign);
return resultMap; return resultMap;
} }
@@ -514,7 +495,7 @@ public class GuiZhouPlatformServiceImpl implements ThirdPartyPlatformService {
String dataSecret = secretInfoVO.getTheirDataSecret(); String dataSecret = secretInfoVO.getTheirDataSecret();
String dataSecretIv = secretInfoVO.getTheirDataSecretIv(); String dataSecretIv = secretInfoVO.getTheirDataSecretIv();
String urlAddress = secretInfoVO.getTheirUrlPrefix(); String urlAddress = secretInfoVO.getTheirUrlPrefix();
String url = urlAddress + "supervise_notification_connector_status"; String url = urlAddress + "supervise_notification_station_status";
String jsonString = JSON.toJSONString(info); String jsonString = JSON.toJSONString(info);
// 获取令牌 // 获取令牌
@@ -534,11 +515,6 @@ public class GuiZhouPlatformServiceImpl implements ThirdPartyPlatformService {
public String notificationEquipChargeStatus(String orderCode) { public String notificationEquipChargeStatus(String orderCode) {
// 根据订单号查询订单信息 // 根据订单号查询订单信息
OrderBasicInfo orderInfo = orderBasicInfoService.getOrderInfoByOrderCode(orderCode); OrderBasicInfo orderInfo = orderBasicInfoService.getOrderInfoByOrderCode(orderCode);
// 查询枪口状态
PileConnectorInfoVO info = pileConnectorInfoService.getPileConnectorInfoByConnectorCode(orderInfo.getPileConnectorCode());
BigDecimal current = info.getCurrent() == null ? BigDecimal.ZERO : info.getCurrent();
BigDecimal voltage = info.getVoltage() == null ? BigDecimal.ZERO : info.getVoltage();
String soc = info.getSOC() == null ? Constants.ZERO : info.getSOC();
// 查询相关配置信息 // 查询相关配置信息
ThirdPartySecretInfoVO guiZhouPlatformSecretInfo = getGuiZhouPlatformSecretInfo(); ThirdPartySecretInfoVO guiZhouPlatformSecretInfo = getGuiZhouPlatformSecretInfo();
@@ -549,35 +525,69 @@ public class GuiZhouPlatformServiceImpl implements ThirdPartyPlatformService {
String dataSecretIv = guiZhouPlatformSecretInfo.getTheirDataSecretIv(); String dataSecretIv = guiZhouPlatformSecretInfo.getTheirDataSecretIv();
String urlAddress = guiZhouPlatformSecretInfo.getTheirUrlPrefix(); String urlAddress = guiZhouPlatformSecretInfo.getTheirUrlPrefix();
List<RealTimeMonitorData> chargingRealTimeData = orderBasicInfoService.getChargingRealTimeData(orderInfo.getTransactionCode());
RealTimeMonitorData realTimeMonitorData;
if (CollectionUtils.isEmpty(chargingRealTimeData)) {
realTimeMonitorData = RealTimeMonitorData.builder()
.chargingDegree("0")
.build();
chargingRealTimeData.add(realTimeMonitorData);
} else {
realTimeMonitorData = chargingRealTimeData.get(0);
}
// 查询枪口状态
PileConnectorInfoVO info = pileConnectorInfoService.getPileConnectorInfoByConnectorCode(orderInfo.getPileConnectorCode());
if (Objects.isNull(info)) {
throw new BusinessException(ReturnCodeEnum.CODE_CONNECTOR_INFO_NULL_ERROR);
}
String merchantId = info.getMerchantId();
MerchantInfoVO merchantInfoVO = pileMerchantInfoService.getMerchantInfoVO(merchantId);
if (Objects.isNull(merchantInfoVO)) {
throw new BusinessException(ReturnCodeEnum.CODE_CONNECTOR_INFO_NULL_ERROR);
}
String orderStatus = orderInfo.getOrderStatus();
if (StringUtils.equals(OrderStatusEnum.IN_THE_CHARGING.getValue(), orderStatus)) {
// 充电中
orderStatus = "2";
} else if (StringUtils.equals(OrderStatusEnum.ORDER_COMPLETE.getValue(), orderStatus)) {
// 充电完成
orderStatus = "4";
}
BigDecimal current = info.getCurrent() == null ? BigDecimal.ZERO : info.getCurrent();
BigDecimal voltage = info.getVoltage() == null ? BigDecimal.ZERO : info.getVoltage();
String soc = info.getSOC() == null ? Constants.ZERO : info.getSOC();
String dateTime = DateUtils.getDateTime(); String dateTime = DateUtils.getDateTime();
SupEquipChargeStatusInfo supEquipChargeStatusInfo = SupEquipChargeStatusInfo.builder() SupEquipChargeStatusInfo supEquipChargeStatusInfo = SupEquipChargeStatusInfo.builder()
.operatorID(Constants.OPERATORID_JIANG_SU) .operatorID(Constants.OPERATORID_JIANG_SU)
.equipmentOwnerID(Constants.OPERATORID_JIANG_SU) .equipmentOwnerID(Constants.OPERATORID_GUI_ZHOU)
.stationID(orderInfo.getStationId()) .stationID(orderInfo.getStationId())
.equipmentID(orderInfo.getPileSn()) .equipmentID(orderInfo.getPileSn())
.startChargeSeqStat(Integer.parseInt(orderStatus))
.connectorID(orderInfo.getPileConnectorCode()) .connectorID(orderInfo.getPileConnectorCode())
.orderNo(orderInfo.getOrderCode()) .orderNo(orderInfo.getOrderCode())
.orderStatus(2) .orderStatus(2)
.equipmentClassification(1) .equipmentClassification(1)
.pushTimeStamp(dateTime) .pushTimeStamp(dateTime)
.connectorStatus(info.getStatus()) // 3-充电中 .connectorStatus(3) // 3-充电中
.currentA(current.setScale(1, BigDecimal.ROUND_HALF_UP)) .currentA(current.setScale(1, BigDecimal.ROUND_HALF_UP))
.voltageA(voltage.setScale(1, BigDecimal.ROUND_HALF_UP)) .voltageA(voltage.setScale(1, BigDecimal.ROUND_HALF_UP))
.soc(new BigDecimal(soc)) .soc(new BigDecimal(soc))
// .currentA(BigDecimal.ONE)
// .voltageA(BigDecimal.ONE)
// .soc(BigDecimal.ZERO)
.startTime(DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD_HH_MM_SS, orderInfo.getChargeStartTime())) .startTime(DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD_HH_MM_SS, orderInfo.getChargeStartTime()))
.endTime(dateTime) .endTime(dateTime)
.totalPower(info.getChargingDegree()) .totalPower(new BigDecimal(realTimeMonitorData.getChargingDegree()))
.eventTime(dateTime) .eventTime(dateTime)
.chargeVoltage(voltage.setScale(1, BigDecimal.ROUND_HALF_UP)) .chargeVoltage(voltage.setScale(1, BigDecimal.ROUND_HALF_UP))
.chargeCurrent(current.setScale(1, BigDecimal.ROUND_HALF_UP)) .chargeCurrent(current.setScale(1, BigDecimal.ROUND_HALF_UP))
.build(); .build();
// 查询运营商信息 supEquipChargeStatusInfo.setEquipmentOwnerID(Constants.OPERATORID_GUI_ZHOU);
PileMerchantInfoVO pileMerchantInfoVO = pileMerchantInfoService.queryMerchantInfoByStationId(orderInfo.getStationId()); if (StringUtils.isNotBlank(info.getSOC())) {
String organizationCode = pileMerchantInfoVO.getOrganizationCode(); supEquipChargeStatusInfo.setSoc(new BigDecimal(info.getSOC()));
if (StringUtils.isNotBlank(organizationCode) && organizationCode.length() == 18) {
String equipmentOwnerId = StringUtils.substring(organizationCode, organizationCode.length() - 10, organizationCode.length() - 1);
supEquipChargeStatusInfo.setEquipmentOwnerID(equipmentOwnerId);
} }
String url = urlAddress + "supervise_notification_equip_charge_status"; String url = urlAddress + "supervise_notification_equip_charge_status";
@@ -621,19 +631,9 @@ public class GuiZhouPlatformServiceImpl implements ThirdPartyPlatformService {
// 拼装成平台所需格式对象 // 拼装成平台所需格式对象
ChargeOrderInfo orderInfo = transformChargeOrderInfo(orderBasicInfo, orderDetail); ChargeOrderInfo orderInfo = transformChargeOrderInfo(orderBasicInfo, orderDetail);
orderInfo.setOperatorID(operatorId); orderInfo.setOperatorID(operatorId);
String equipmentOwnerID; orderInfo.setEquipmentOwnerID(Constants.OPERATORID_GUI_ZHOU);
if (MerchantUtils.isXiXiaoMerchant(orderBasicInfo.getMerchantId())) { orderInfo.setTotalServiceMoney(orderInfo.getTotalSeviceMoney());
equipmentOwnerID = Constants.OPERATORID_XI_XIAO; orderInfo.setTotalElecMoney(orderDetail.getTotalElectricityAmount());
} else {
PileMerchantInfoVO pileMerchantInfoVO = pileMerchantInfoService.queryMerchantInfoByStationId(orderInfo.getStationID());
String organizationCode = pileMerchantInfoVO.getOrganizationCode();
if (StringUtils.isNotBlank(organizationCode) && organizationCode.length() == 18) {
equipmentOwnerID = ThirdPartyPlatformUtils.extractEquipmentOwnerID(pileMerchantInfoVO.getOrganizationCode());
} else {
equipmentOwnerID = Constants.OPERATORID_JIANG_SU;
}
}
orderInfo.setEquipmentOwnerID(equipmentOwnerID);
List<BillingPriceVO> billingList = pileBillingTemplateService.queryBillingPrice(orderBasicInfo.getStationId()); List<BillingPriceVO> billingList = pileBillingTemplateService.queryBillingPrice(orderBasicInfo.getStationId());
// 先将list按照 尖、峰、平、谷 时段排序 // 先将list按照 尖、峰、平、谷 时段排序
@@ -664,27 +664,21 @@ public class GuiZhouPlatformServiceImpl implements ThirdPartyPlatformService {
// 根据订单号查询出信息 // 根据订单号查询出信息
OrderBasicInfo orderBasicInfo = orderBasicInfoService.getOrderInfoByOrderCode(orderCode); OrderBasicInfo orderBasicInfo = orderBasicInfoService.getOrderInfoByOrderCode(orderCode);
ThirdPartySecretInfoVO guiZhouPlatformSecretInfo = getGuiZhouPlatformSecretInfo();
OrderDetail orderDetail = orderBasicInfoService.getOrderDetailByOrderCode(orderCode); OrderDetail orderDetail = orderBasicInfoService.getOrderDetailByOrderCode(orderCode);
String operatorId = guiZhouPlatformSecretInfo.getTheirOperatorId(); String operatorId = Constants.OPERATORID_JIANG_SU;
String operatorSecret = guiZhouPlatformSecretInfo.getTheirOperatorSecret(); String operatorSecret = getGuiZhouPlatformSecretInfo().getTheirOperatorSecret();
String signSecret = guiZhouPlatformSecretInfo.getTheirSigSecret(); String signSecret = getGuiZhouPlatformSecretInfo().getTheirSigSecret();
String dataSecret = guiZhouPlatformSecretInfo.getTheirDataSecret(); String dataSecret = getGuiZhouPlatformSecretInfo().getTheirDataSecret();
String dataSecretIv = guiZhouPlatformSecretInfo.getTheirDataSecretIv(); String dataSecretIv = getGuiZhouPlatformSecretInfo().getTheirDataSecretIv();
String urlAddress = guiZhouPlatformSecretInfo.getTheirUrlPrefix(); String urlAddress = getGuiZhouPlatformSecretInfo().getTheirUrlPrefix();
String url = urlAddress + "supervise_notification_charge_order_info_history"; String url = urlAddress + "supervise_notification_charge_order_info_history";
ChargeOrderInfo orderInfo = transformChargeOrderInfo(orderBasicInfo, orderDetail); ChargeOrderInfo orderInfo = transformChargeOrderInfo(orderBasicInfo, orderDetail);
orderInfo.setOperatorID(operatorId); orderInfo.setOperatorID(operatorId);
String equipmentOwnerID; orderInfo.setEquipmentOwnerID(Constants.OPERATORID_GUI_ZHOU);
if (MerchantUtils.isXiXiaoMerchant(orderBasicInfo.getMerchantId())) {
equipmentOwnerID = Constants.OPERATORID_XI_XIAO;
} else {
equipmentOwnerID = Constants.OPERATORID_LIANLIAN;
}
orderInfo.setEquipmentOwnerID(equipmentOwnerID);
List<BillingPriceVO> billingList = pileBillingTemplateService.queryBillingPrice(orderBasicInfo.getStationId()); List<BillingPriceVO> billingList = pileBillingTemplateService.queryBillingPrice(orderBasicInfo.getStationId());
// 先将list按照 尖、峰、平、谷 时段排序 // 先将list按照 尖、峰、平、谷 时段排序
@@ -699,9 +693,7 @@ public class GuiZhouPlatformServiceImpl implements ThirdPartyPlatformService {
return null; return null;
} }
// 调用联联平台接口 // 调用联联平台接口
JSONObject json = new JSONObject(); String jsonString = JSON.toJSONString(orderInfo);
json.put("ChargeOrderInfo", orderInfo);
String jsonString = JSON.toJSONString(json);
String result = HttpRequestUtil.sendPost(token, jsonString, url, dataSecret, dataSecretIv, operatorId, signSecret); String result = HttpRequestUtil.sendPost(token, jsonString, url, dataSecret, dataSecretIv, operatorId, signSecret);
return result; return result;
} }
@@ -714,17 +706,11 @@ public class GuiZhouPlatformServiceImpl implements ThirdPartyPlatformService {
*/ */
@Override @Override
public String notificationOperationStatsInfo(String stationId) { public String notificationOperationStatsInfo(String stationId) {
SupStationStatsInfo. SupStationStatsInfo.EquipmentStatsInfo equipmentStatsInfo = new SupStationStatsInfo.EquipmentStatsInfo();
EquipmentStatsInfo equipmentStatsInfo = new SupStationStatsInfo.EquipmentStatsInfo(); List<SupStationStatsInfo.EquipmentStatsInfo> equipmentStatsInfoList = new ArrayList<>();
List<SupStationStatsInfo.
EquipmentStatsInfo> equipmentStatsInfoList = new ArrayList<>();
SupStationStatsInfo. SupStationStatsInfo.EquipmentStatsInfo.ConnectorStatsInfo connectorStatsInfo = null;
EquipmentStatsInfo. List<SupStationStatsInfo.EquipmentStatsInfo.ConnectorStatsInfo> connectorStatsInfoList = new ArrayList<>();
ConnectorStatsInfo connectorStatsInfo = null;
List<SupStationStatsInfo.
EquipmentStatsInfo.
ConnectorStatsInfo> connectorStatsInfoList = new ArrayList<>();
// 根据站点id查询订单记录 (新建Service方法) // 根据站点id查询订单记录 (新建Service方法)
List<SupStationStatsVO> orderVOS = orderBasicInfoService.queryOrderListByStationId(stationId); List<SupStationStatsVO> orderVOS = orderBasicInfoService.queryOrderListByStationId(stationId);
@@ -733,13 +719,12 @@ public class GuiZhouPlatformServiceImpl implements ThirdPartyPlatformService {
int stationChargeTime = Constants.zero; // 充电站累计充电次数 int stationChargeTime = Constants.zero; // 充电站累计充电次数
for (SupStationStatsVO orderVO : orderVOS) { for (SupStationStatsVO orderVO : orderVOS) {
// 充电站累计用电量 // 充电站累计用电量
BigDecimal totalPower = orderVO.getTotalPower(); BigDecimal totalPower = (orderVO.getTotalPower() != null) ? orderVO.getTotalPower() : BigDecimal.ZERO;
if (totalPower == null || orderVO.getChargingTime() == null) { Integer chargingTime = (orderVO.getChargingTime() != null) ? orderVO.getChargingTime() : Constants.zero;
continue;
}
stationTotalElectricity = stationTotalElectricity.add(totalPower); stationTotalElectricity = stationTotalElectricity.add(totalPower);
// 充电站累计充电时长(分钟) // 充电站累计充电时长(分钟)
stationChargeTime += orderVO.getChargingTime(); stationChargeTime += chargingTime;
} }
// 根据枪口排序,分组,将充电时长和充电量累加 // 根据枪口排序,分组,将充电时长和充电量累加
@@ -761,7 +746,6 @@ public class GuiZhouPlatformServiceImpl implements ThirdPartyPlatformService {
// key : pileConnectorCode // key : pileConnectorCode
// value: SupStationStatsVO // value: SupStationStatsVO
for (Map.Entry<String, SupStationStatsVO> entry : sortedMap.entrySet()) { for (Map.Entry<String, SupStationStatsVO> entry : sortedMap.entrySet()) {
String pileConnectorCode = entry.getKey(); String pileConnectorCode = entry.getKey();
SupStationStatsVO vo = entry.getValue(); SupStationStatsVO vo = entry.getValue();
@@ -771,9 +755,9 @@ public class GuiZhouPlatformServiceImpl implements ThirdPartyPlatformService {
connectorStatsInfo.setConnectorId(pileConnectorCode); connectorStatsInfo.setConnectorId(pileConnectorCode);
connectorStatsInfo.setEquipmentClassification(1); connectorStatsInfo.setEquipmentClassification(1);
connectorStatsInfo.setConnectorElectricity(vo.getTotalPower()); connectorStatsInfo.setConnectorElectricity((vo.getTotalPower() != null) ? vo.getTotalPower() : BigDecimal.ZERO);
connectorStatsInfo.setConnectorTotalChargeTime(vo.getChargingTime()); connectorStatsInfo.setConnectorTotalChargeTime((vo.getChargingTime() != null) ? vo.getChargingTime() : Constants.zero);
// TODO connectorStatsInfo.setConnectorTotalChargeNum(); connectorStatsInfo.setConnectorTotalChargeNum(orderVOS.size());
connectorStatsInfo.setConnectorTotalWarningNum(0); connectorStatsInfo.setConnectorTotalWarningNum(0);
// 对比这次循环到的桩编号和上次的桩编号如果是同一台桩将数据进行汇总如果不是新建桩数据并将之前的累计数据清0 // 对比这次循环到的桩编号和上次的桩编号如果是同一台桩将数据进行汇总如果不是新建桩数据并将之前的累计数据清0
@@ -788,21 +772,21 @@ public class GuiZhouPlatformServiceImpl implements ThirdPartyPlatformService {
equipmentStatsInfo.setEquipmentId(pileSn); equipmentStatsInfo.setEquipmentId(pileSn);
equipmentStatsInfo.setEquipmentClassification(1); equipmentStatsInfo.setEquipmentClassification(1);
equipmentStatsInfo.setEquipmentElectricity(vo.getTotalPower()); equipmentStatsInfo.setEquipmentElectricity((vo.getTotalPower() != null) ? vo.getTotalPower() : BigDecimal.ZERO);
equipmentStatsInfo.setEquipmentTotalChargeTime(vo.getChargingTime()); equipmentStatsInfo.setEquipmentTotalChargeTime((vo.getChargingTime() != null) ? vo.getChargingTime() : Constants.zero);
// TODO equipmentStatsInfo.setEquipmentTotalChargeNum(); equipmentStatsInfo.setEquipmentTotalChargeNum(orderVOS.size());
equipmentStatsInfo.setEquipmentTotalWarningNum(0);
pileTotalPower = pileTotalPower.add(vo.getTotalPower()); pileTotalPower = pileTotalPower.add((vo.getTotalPower() != null) ? vo.getTotalPower() : BigDecimal.ZERO);
pileChargeTime += vo.getChargingTime(); pileChargeTime += (vo.getChargingTime() != null) ? vo.getChargingTime() : Constants.zero;
connectorStatsInfoList.add(connectorStatsInfo); connectorStatsInfoList.add(connectorStatsInfo);
equipmentStatsInfo.setConnectorStatsInfos(connectorStatsInfoList); equipmentStatsInfo.setConnectorStatsInfos(connectorStatsInfoList);
equipmentStatsInfoList.add(equipmentStatsInfo); equipmentStatsInfoList.add(equipmentStatsInfo);
} else { } else {
// 同一台桩,枪口号不同,累加桩数据,将枪口数据新建 // 同一台桩,枪口号不同,累加桩数据,将枪口数据新建
pileTotalPower = pileTotalPower.add((vo.getTotalPower() != null) ? vo.getTotalPower() : BigDecimal.ZERO);
pileTotalPower = pileTotalPower.add(vo.getTotalPower()); pileChargeTime += (vo.getChargingTime() != null) ? vo.getChargingTime() : Constants.zero;
pileChargeTime += vo.getChargingTime();
equipmentStatsInfo.setEquipmentElectricity(pileTotalPower); // 第一次判断时一定不会进入到这里,所以不用判断 equipmentStatsInfo 是否为 null equipmentStatsInfo.setEquipmentElectricity(pileTotalPower); // 第一次判断时一定不会进入到这里,所以不用判断 equipmentStatsInfo 是否为 null
equipmentStatsInfo.setEquipmentTotalChargeTime(pileChargeTime); equipmentStatsInfo.setEquipmentTotalChargeTime(pileChargeTime);
@@ -811,7 +795,6 @@ public class GuiZhouPlatformServiceImpl implements ThirdPartyPlatformService {
equipmentStatsInfo.setConnectorStatsInfos(connectorStatsInfoList); equipmentStatsInfo.setConnectorStatsInfos(connectorStatsInfoList);
equipmentStatsInfoList.add(equipmentStatsInfo); equipmentStatsInfoList.add(equipmentStatsInfo);
} }
} }
// 创建对象 // 创建对象
@@ -830,7 +813,7 @@ public class GuiZhouPlatformServiceImpl implements ThirdPartyPlatformService {
.stationTotalChargeTime(stationChargeTime) .stationTotalChargeTime(stationChargeTime)
.stationTotalWarningNum(0) .stationTotalWarningNum(0)
.equipmentStatsInfos(equipmentStatsInfoList) .equipmentStatsInfos(equipmentStatsInfoList)
.equipmentOwnerId(Constants.OPERATORID_GUI_ZHOU)
.build(); .build();
JSONObject json = new JSONObject(); JSONObject json = new JSONObject();
json.put("StationStatsInfos", supStationStatsInfo); json.put("StationStatsInfos", supStationStatsInfo);
@@ -855,37 +838,31 @@ public class GuiZhouPlatformServiceImpl implements ThirdPartyPlatformService {
return result; return result;
} }
/** /**
* 推送充换电站实时功率 supervise_notification_realtime_power_info * 推送充换电站实时功率 supervise_notification_realtime_power_info
* *
* @return * @return
*/ */
public String notificationPowerInfo(List<String> stationIds) { public String notificationPowerInfo(List<String> stationIds) {
com.jsowell.thirdparty.platform.common.SupStationPowerInfo supStationPowerInfo = null;
List<com.jsowell.thirdparty.platform.common.SupStationPowerInfo> list = new ArrayList<>(); List<com.jsowell.thirdparty.platform.common.SupStationPowerInfo> list = new ArrayList<>();
String dateTimeNow = DateUtils.dateTimeNow(DateUtils.YYYY_MM_DD_HH_MM_SS); String dateTimeNow = DateUtils.dateTimeNow(DateUtils.YYYY_MM_DD_HH_MM_SS);
List<com.jsowell.thirdparty.platform.common.SupStationPowerInfo.EquipmentPowerInfo> supPileInfoList = null;
com.jsowell.thirdparty.platform.common.SupStationPowerInfo.EquipmentPowerInfo supPileInfo = null;
List<com.jsowell.thirdparty.platform.common.SupStationPowerInfo.EquipmentPowerInfo.ConnectorPowerInfo> connectorPowerInfoList;
com.jsowell.thirdparty.platform.common.SupStationPowerInfo.EquipmentPowerInfo.ConnectorPowerInfo connectorPowerInfo;
for (String stationId : stationIds) { for (String stationId : stationIds) {
BigDecimal stationPower = BigDecimal.ZERO; BigDecimal stationPower = BigDecimal.ZERO;
supStationPowerInfo = new com.jsowell.thirdparty.platform.common.SupStationPowerInfo(); com.jsowell.thirdparty.platform.common.SupStationPowerInfo supStationPowerInfo = new com.jsowell.thirdparty.platform.common.SupStationPowerInfo();
supStationPowerInfo.setOperatorID(Constants.OPERATORID_JIANG_SU); supStationPowerInfo.setOperatorID(Constants.OPERATORID_JIANG_SU);
supStationPowerInfo.setStationId(stationId); supStationPowerInfo.setStationId(stationId);
supStationPowerInfo.setDataTime(dateTimeNow); supStationPowerInfo.setDataTime(dateTimeNow);
supStationPowerInfo.setStationClassification(Constants.one); supStationPowerInfo.setStationClassification(Constants.one);
supStationPowerInfo.setStationRealTimePower(stationPower);
// 查询运营商基本信息 // 查询运营商基本信息
PileMerchantInfoVO pileMerchantInfoVO = pileMerchantInfoService.queryMerchantInfoByStationId(stationId); PileMerchantInfoVO pileMerchantInfoVO = pileMerchantInfoService.queryMerchantInfoByStationId(stationId);
String organizationCode = pileMerchantInfoVO.getOrganizationCode(); String organizationCode = pileMerchantInfoVO.getOrganizationCode();
if (StringUtils.isNotBlank(organizationCode) && organizationCode.length() == 18) { if (StringUtils.isNotBlank(organizationCode) && organizationCode.length() == 18) {
String equipmentOwnerId = StringUtils.substring(organizationCode, organizationCode.length() - 10, organizationCode.length() - 1); supStationPowerInfo.setEquipmentOwnerID(Constants.OPERATORID_GUI_ZHOU);
supStationPowerInfo.setEquipmentOwnerID(equipmentOwnerId);
} else {
supStationPowerInfo.setEquipmentOwnerID(Constants.OPERATORID_JIANG_SU);
} }
// 根据站点id查询桩信息 // 根据站点id查询桩信息
@@ -894,6 +871,7 @@ public class GuiZhouPlatformServiceImpl implements ThirdPartyPlatformService {
logger.error("推送充换电站实时功率 error, 查询桩列表信息为空"); logger.error("推送充换电站实时功率 error, 查询桩列表信息为空");
throw new BusinessException(ReturnCodeEnum.CODE_SELECT_INFO_IS_NULL); throw new BusinessException(ReturnCodeEnum.CODE_SELECT_INFO_IS_NULL);
} }
// 将桩id筛选出来用于批量查询枪口数据 // 将桩id筛选出来用于批量查询枪口数据
List<Long> pileIds = pileList.stream() List<Long> pileIds = pileList.stream()
.map(PileBasicInfo::getId) .map(PileBasicInfo::getId)
@@ -905,20 +883,22 @@ public class GuiZhouPlatformServiceImpl implements ThirdPartyPlatformService {
logger.error("推送充换电站实时功率 error, 查询枪口列表信息为空"); logger.error("推送充换电站实时功率 error, 查询枪口列表信息为空");
throw new BusinessException(ReturnCodeEnum.CODE_SELECT_INFO_IS_NULL); throw new BusinessException(ReturnCodeEnum.CODE_SELECT_INFO_IS_NULL);
} }
supPileInfoList = new ArrayList<>();
List<com.jsowell.thirdparty.platform.common.SupStationPowerInfo.EquipmentPowerInfo> supPileInfoList = new ArrayList<>();
for (PileBasicInfo pileBasicInfo : pileList) { for (PileBasicInfo pileBasicInfo : pileList) {
supPileInfo = new com.jsowell.thirdparty.platform.common.SupStationPowerInfo.EquipmentPowerInfo(); com.jsowell.thirdparty.platform.common.SupStationPowerInfo.EquipmentPowerInfo supPileInfo = new com.jsowell.thirdparty.platform.common.SupStationPowerInfo.EquipmentPowerInfo();
supPileInfo.setEquipmentID(pileBasicInfo.getSn()); supPileInfo.setEquipmentID(pileBasicInfo.getSn());
supPileInfo.setEquipmentClassification(Constants.one); supPileInfo.setEquipmentClassification(Constants.one);
supPileInfo.setDataTime(dateTimeNow); supPileInfo.setDataTime(dateTimeNow);
supPileInfo.setEquipRealTimePower(BigDecimal.ZERO);
BigDecimal pileInstantPower = BigDecimal.ZERO; BigDecimal pileInstantPower = BigDecimal.ZERO;
connectorPowerInfoList = new ArrayList<>(); List<com.jsowell.thirdparty.platform.common.SupStationPowerInfo.EquipmentPowerInfo.ConnectorPowerInfo> connectorPowerInfoList = new ArrayList<>();
for (PileConnectorInfoVO pileConnectorInfoVO : connectorList) { for (PileConnectorInfoVO pileConnectorInfoVO : connectorList) {
if (!StringUtils.equals(pileBasicInfo.getSn(), pileConnectorInfoVO.getPileSn())) { if (!StringUtils.equals(pileBasicInfo.getSn(), pileConnectorInfoVO.getPileSn())) {
continue; continue;
} }
BigDecimal instantPower = pileConnectorInfoVO.getInstantPower() == null ? BigDecimal.ZERO : pileConnectorInfoVO.getInstantPower(); BigDecimal instantPower = pileConnectorInfoVO.getInstantPower() == null ? BigDecimal.ZERO : pileConnectorInfoVO.getInstantPower();
connectorPowerInfo = new com.jsowell.thirdparty.platform.common.SupStationPowerInfo.EquipmentPowerInfo.ConnectorPowerInfo(); com.jsowell.thirdparty.platform.common.SupStationPowerInfo.EquipmentPowerInfo.ConnectorPowerInfo connectorPowerInfo = new com.jsowell.thirdparty.platform.common.SupStationPowerInfo.EquipmentPowerInfo.ConnectorPowerInfo();
connectorPowerInfo.setConnectorID(pileConnectorInfoVO.getPileConnectorCode()); connectorPowerInfo.setConnectorID(pileConnectorInfoVO.getPileConnectorCode());
connectorPowerInfo.setEquipmentClassification(Constants.one); connectorPowerInfo.setEquipmentClassification(Constants.one);
connectorPowerInfo.setDataTime(dateTimeNow); connectorPowerInfo.setDataTime(dateTimeNow);
@@ -933,16 +913,17 @@ public class GuiZhouPlatformServiceImpl implements ThirdPartyPlatformService {
// 桩实时功率 // 桩实时功率
supPileInfo.setEquipRealTimePower(pileInstantPower); supPileInfo.setEquipRealTimePower(pileInstantPower);
stationPower = stationPower.add(pileInstantPower); stationPower = stationPower.add(pileInstantPower);
supPileInfoList.add(supPileInfo); supPileInfoList.add(supPileInfo);
} }
supStationPowerInfo.setEquipmentPowerInfos(supPileInfoList); supStationPowerInfo.setEquipmentPowerInfos(supPileInfoList);
supStationPowerInfo.setStationRealTimePower(stationPower); supStationPowerInfo.setStationRealTimePower(stationPower);
list.add(supStationPowerInfo);
} }
list.add(supStationPowerInfo);
// 获取推送配置密钥信息
ThirdPartySecretInfoVO guiZhouPlatformSecretInfo = getGuiZhouPlatformSecretInfo(); ThirdPartySecretInfoVO guiZhouPlatformSecretInfo = getGuiZhouPlatformSecretInfo();
String operatorId = guiZhouPlatformSecretInfo.getTheirOperatorId(); String operatorId = guiZhouPlatformSecretInfo.getOurOperatorId();
String operatorSecret = guiZhouPlatformSecretInfo.getTheirOperatorSecret(); String operatorSecret = guiZhouPlatformSecretInfo.getTheirOperatorSecret();
String signSecret = guiZhouPlatformSecretInfo.getTheirSigSecret(); String signSecret = guiZhouPlatformSecretInfo.getTheirSigSecret();
String dataSecret = guiZhouPlatformSecretInfo.getTheirDataSecret(); String dataSecret = guiZhouPlatformSecretInfo.getTheirDataSecret();
@@ -987,18 +968,24 @@ public class GuiZhouPlatformServiceImpl implements ThirdPartyPlatformService {
* @return * @return
*/ */
private ChargeOrderInfo transformChargeOrderInfo(OrderBasicInfo orderBasicInfo, OrderDetail orderDetail) { private ChargeOrderInfo transformChargeOrderInfo(OrderBasicInfo orderBasicInfo, OrderDetail orderDetail) {
DecimalFormat df2 = new DecimalFormat("#.######");
BigDecimal totalPower = new BigDecimal(df2.format(orderDetail.getTotalUsedElectricity()));
totalPower = totalPower.setScale(4, RoundingMode.HALF_UP);
ChargeOrderInfo chargeOrderInfo = ChargeOrderInfo.builder() ChargeOrderInfo chargeOrderInfo = ChargeOrderInfo.builder()
.operatorID(Constants.OPERATORID_JIANG_SU)
.stationID(orderBasicInfo.getStationId()) .stationID(orderBasicInfo.getStationId())
.equipmentID(orderBasicInfo.getPileSn()) .equipmentID(orderBasicInfo.getPileSn())
.orderNo(orderBasicInfo.getOrderCode()) .orderNo(orderBasicInfo.getOrderCode())
.connectorID(orderBasicInfo.getPileConnectorCode()) .connectorID(orderBasicInfo.getPileConnectorCode())
.equipmentClassification(1)
.licensePlate(orderBasicInfo.getPlateNumber()) .licensePlate(orderBasicInfo.getPlateNumber())
.vin(orderBasicInfo.getVinCode()) .vin(orderBasicInfo.getVinCode())
.startSOC(orderBasicInfo.getStartSoc()) .startSOC(orderBasicInfo.getStartSoc())
.endSOC(orderBasicInfo.getEndSoc()) .endSOC(orderBasicInfo.getEndSoc())
.startTime(DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD_HH_MM_SS, orderBasicInfo.getChargeStartTime())) .startTime(DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD_HH_MM_SS, orderBasicInfo.getChargeStartTime()))
.endTime(DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD_HH_MM_SS, orderBasicInfo.getChargeEndTime())) .endTime(DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD_HH_MM_SS, orderBasicInfo.getChargeEndTime()))
.totalPower(orderDetail.getTotalUsedElectricity()) .totalPower(totalPower)
.cuspElect(orderDetail.getSharpUsedElectricity()) .cuspElect(orderDetail.getSharpUsedElectricity())
.peakElect(orderDetail.getSharpUsedElectricity()) .peakElect(orderDetail.getSharpUsedElectricity())
.flatElect(orderDetail.getFlatUsedElectricity()) .flatElect(orderDetail.getFlatUsedElectricity())
@@ -1006,8 +993,9 @@ public class GuiZhouPlatformServiceImpl implements ThirdPartyPlatformService {
.pushTimeStamp(DateUtils.getDateTime()) .pushTimeStamp(DateUtils.getDateTime())
.totalElecMoney(orderDetail.getTotalElectricityAmount()) .totalElecMoney(orderDetail.getTotalElectricityAmount())
.totalSeviceMoney(orderDetail.getTotalServiceAmount()) .totalSeviceMoney(orderDetail.getTotalServiceAmount())
.totalServiceMoney(orderDetail.getTotalServiceAmount())
.totalMoney(orderDetail.getTotalOrderAmount()) .totalMoney(orderDetail.getTotalOrderAmount())
.stopReason(0) .stopReason(2)
.stopDesc(orderBasicInfo.getReason()) // TODO 停止原因 .stopDesc(orderBasicInfo.getReason()) // TODO 停止原因
.sumPeriod(0) .sumPeriod(0)
.build(); .build();
@@ -1028,8 +1016,8 @@ public class GuiZhouPlatformServiceImpl implements ThirdPartyPlatformService {
detail = new SupChargeDetails(); detail = new SupChargeDetails();
if (StringUtils.equals(billingPriceVO.getTimeType(), BillingTimeTypeEnum.SHARP.getValue())) { if (StringUtils.equals(billingPriceVO.getTimeType(), BillingTimeTypeEnum.SHARP.getValue())) {
// 尖时段 // 尖时段
detail.setDetailStartTime(billingPriceVO.getStartTime()); detail.setDetailStartTime(DateUtils.getDateTime());
detail.setDetailEndTime(billingPriceVO.getEndTime()); detail.setDetailEndTime(DateUtils.getDateTime());
detail.setElecPrice(new BigDecimal(billingPriceVO.getElectricityPrice()).setScale(4, BigDecimal.ROUND_HALF_UP)); detail.setElecPrice(new BigDecimal(billingPriceVO.getElectricityPrice()).setScale(4, BigDecimal.ROUND_HALF_UP));
detail.setSevicePrice(new BigDecimal(billingPriceVO.getServicePrice()).setScale(4, BigDecimal.ROUND_HALF_UP)); detail.setSevicePrice(new BigDecimal(billingPriceVO.getServicePrice()).setScale(4, BigDecimal.ROUND_HALF_UP));
detail.setDetailPower(orderDetail.getSharpUsedElectricity()); detail.setDetailPower(orderDetail.getSharpUsedElectricity());
@@ -1037,8 +1025,8 @@ public class GuiZhouPlatformServiceImpl implements ThirdPartyPlatformService {
detail.setDetailSeviceMoney(orderDetail.getSharpServicePrice()); detail.setDetailSeviceMoney(orderDetail.getSharpServicePrice());
} else if (StringUtils.equals(billingPriceVO.getTimeType(), BillingTimeTypeEnum.PEAK.getValue())) { } else if (StringUtils.equals(billingPriceVO.getTimeType(), BillingTimeTypeEnum.PEAK.getValue())) {
// 峰时段 // 峰时段
detail.setDetailStartTime(billingPriceVO.getStartTime()); detail.setDetailStartTime(DateUtils.getDateTime());
detail.setDetailEndTime(billingPriceVO.getEndTime()); detail.setDetailEndTime(DateUtils.getDateTime());
detail.setElecPrice(new BigDecimal(billingPriceVO.getElectricityPrice()).setScale(4, BigDecimal.ROUND_HALF_UP)); detail.setElecPrice(new BigDecimal(billingPriceVO.getElectricityPrice()).setScale(4, BigDecimal.ROUND_HALF_UP));
detail.setSevicePrice(new BigDecimal(billingPriceVO.getServicePrice()).setScale(4, BigDecimal.ROUND_HALF_UP)); detail.setSevicePrice(new BigDecimal(billingPriceVO.getServicePrice()).setScale(4, BigDecimal.ROUND_HALF_UP));
detail.setDetailPower(orderDetail.getPeakUsedElectricity()); detail.setDetailPower(orderDetail.getPeakUsedElectricity());
@@ -1046,8 +1034,8 @@ public class GuiZhouPlatformServiceImpl implements ThirdPartyPlatformService {
detail.setDetailSeviceMoney(orderDetail.getPeakServicePrice()); detail.setDetailSeviceMoney(orderDetail.getPeakServicePrice());
} else if (StringUtils.equals(billingPriceVO.getTimeType(), BillingTimeTypeEnum.FLAT.getValue())) { } else if (StringUtils.equals(billingPriceVO.getTimeType(), BillingTimeTypeEnum.FLAT.getValue())) {
// 平时段 // 平时段
detail.setDetailStartTime(billingPriceVO.getStartTime()); detail.setDetailStartTime(DateUtils.getDateTime());
detail.setDetailEndTime(billingPriceVO.getEndTime()); detail.setDetailEndTime(DateUtils.getDateTime());
detail.setElecPrice(new BigDecimal(billingPriceVO.getElectricityPrice()).setScale(4, BigDecimal.ROUND_HALF_UP)); detail.setElecPrice(new BigDecimal(billingPriceVO.getElectricityPrice()).setScale(4, BigDecimal.ROUND_HALF_UP));
detail.setSevicePrice(new BigDecimal(billingPriceVO.getServicePrice()).setScale(4, BigDecimal.ROUND_HALF_UP)); detail.setSevicePrice(new BigDecimal(billingPriceVO.getServicePrice()).setScale(4, BigDecimal.ROUND_HALF_UP));
detail.setDetailPower(orderDetail.getFlatUsedElectricity()); detail.setDetailPower(orderDetail.getFlatUsedElectricity());
@@ -1055,8 +1043,8 @@ public class GuiZhouPlatformServiceImpl implements ThirdPartyPlatformService {
detail.setDetailSeviceMoney(orderDetail.getFlatServicePrice()); detail.setDetailSeviceMoney(orderDetail.getFlatServicePrice());
} else if (StringUtils.equals(billingPriceVO.getTimeType(), BillingTimeTypeEnum.VALLEY.getValue())) { } else if (StringUtils.equals(billingPriceVO.getTimeType(), BillingTimeTypeEnum.VALLEY.getValue())) {
// 谷时段 // 谷时段
detail.setDetailStartTime(billingPriceVO.getStartTime()); detail.setDetailStartTime(DateUtils.getDateTime());
detail.setDetailEndTime(billingPriceVO.getEndTime()); detail.setDetailEndTime(DateUtils.getDateTime());
detail.setElecPrice(new BigDecimal(billingPriceVO.getElectricityPrice()).setScale(4, BigDecimal.ROUND_HALF_UP)); detail.setElecPrice(new BigDecimal(billingPriceVO.getElectricityPrice()).setScale(4, BigDecimal.ROUND_HALF_UP));
detail.setSevicePrice(new BigDecimal(billingPriceVO.getServicePrice()).setScale(4, BigDecimal.ROUND_HALF_UP)); detail.setSevicePrice(new BigDecimal(billingPriceVO.getServicePrice()).setScale(4, BigDecimal.ROUND_HALF_UP));
detail.setDetailPower(orderDetail.getValleyUsedElectricity()); detail.setDetailPower(orderDetail.getValleyUsedElectricity());