湖州市监管平台对接接口

This commit is contained in:
YAS\29473
2025-05-27 17:02:58 +08:00
parent 26fc4ebbc9
commit 882e99d10b
5 changed files with 1112 additions and 19 deletions

View File

@@ -0,0 +1,277 @@
package com.jsowell.api.thirdparty;
import com.alibaba.fastjson2.JSON;
import com.jsowell.common.annotation.Anonymous;
import com.jsowell.common.enums.thirdparty.ThirdPartyReturnCodeEnum;
import com.jsowell.common.enums.thirdparty.ThirdPlatformTypeEnum;
import com.jsowell.common.exception.BusinessException;
import com.jsowell.common.response.RestApiResponse;
import com.jsowell.pile.dto.PushRealTimeInfoDTO;
import com.jsowell.pile.dto.QueryEquipChargeStatusDTO;
import com.jsowell.pile.dto.QueryOrderDTO;
import com.jsowell.pile.dto.QueryStationInfoDTO;
import com.jsowell.pile.thirdparty.CommonParamsDTO;
import com.jsowell.thirdparty.lianlian.common.CommonResult;
import com.jsowell.thirdparty.platform.service.ThirdPartyPlatformService;
import io.minio.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest;
import java.util.Map;
/**
* 湖州市监管平台接口
*/
@RestController
@RequestMapping("/huzhou")
@Anonymous
public class HuZhouController extends ThirdPartyBaseController {
private final String platformName = "湖州市监管平台";
private final String platformType = ThirdPlatformTypeEnum.HU_ZHOU_PLATFORM.getTypeCode();
@Autowired
@Qualifier("huZhouPlatformServiceImpl")
private ThirdPartyPlatformService platformLogic;
/**
* 获取token接口
*
*/
@PostMapping("/v1/query_token")
public CommonResult<?> queryToken(@RequestBody CommonParamsDTO dto) {
logger.info("{}-获取token接口params:{}", platformName, JSON.toJSONString(dto));
try {
Map<String, String> map = platformLogic.queryToken(dto);
logger.info("{}-获取token接口result:{}", platformName, JSON.toJSONString(map));
return CommonResult.success(0, "请求令牌成功!", map.get("Data"), map.get("Sig"));
} catch (Exception e) {
logger.error("{}-获取token接口异常", platformName);
return CommonResult.failed("获取token发生异常");
}
}
/**
* 查询充电站信息
*
*
* @param dto
* @return
*/
@PostMapping("/v1/query_stations_info")
public CommonResult<?> query_stations_info(HttpServletRequest request,@RequestBody CommonParamsDTO dto) {
// logger.info("{}-查询充电站信息 params:{}", platformName, JSON.toJSONString(dto));
try {
// 校验令牌
if (!verifyToken(request.getHeader("Authorization"))) {
// 校验失败
return CommonResult.failed(ThirdPartyReturnCodeEnum.TOKEN_ERROR);
}
// 校验签名
if (!verifySignature(dto)) {
// 签名错误
return CommonResult.failed(ThirdPartyReturnCodeEnum.SIGN_ERROR);
}
// 解析入参
QueryStationInfoDTO queryStationInfoDTO = parseParamsDTO(dto, QueryStationInfoDTO.class);
// 执行逻辑
Map<String, String> map = platformLogic.queryStationsInfo(queryStationInfoDTO);
return CommonResult.success(0, "查询充电站信息成功!", map.get("Data"), map.get("Sig"));
} catch (Exception e) {
logger.info("{}-查询充电站信息 error:", platformName, e);
}
return CommonResult.failed("查询充电站信息发生异常");
}
/**
* 设备接口状态查询 query_station_status
* @param request
* @param dto
* @return
*/
@PostMapping("/v1/query_station_status")
public CommonResult<?> query_stations_status(HttpServletRequest request, @RequestBody CommonParamsDTO dto) {
logger.info("{}-设备接口状态查询 params:{}", platformName, JSON.toJSONString(dto));
try {
// 校验令牌
if (!verifyToken(request.getHeader("Authorization"))) {
// 校验失败
return CommonResult.failed(ThirdPartyReturnCodeEnum.TOKEN_ERROR);
}
// 校验签名
if (!verifySignature(dto)) {
// 签名错误
return CommonResult.failed(ThirdPartyReturnCodeEnum.SIGN_ERROR);
}
// 解析入参
QueryStationInfoDTO queryStationInfoDTO = parseParamsDTO(dto, QueryStationInfoDTO.class);
// 执行逻辑
Map<String, String> map = platformLogic.queryStationStatus(queryStationInfoDTO);
logger.info("{}-设备接口状态查询 result:{}", platformName, map);
return CommonResult.success(0, "设备接口状态查询成功!", map.get("Data"), map.get("Sig"));
} catch (Exception e) {
logger.info("{}-设备接口状态查询 error:", platformName, e);
}
return CommonResult.failed("设备接口状态查询发生异常");
}
/**
* 查询充电状态
* http://localhost:8080/xindiantu/query_equip_charge_status/{startChargeSeq}
* @param dto
* @return
*/
@PostMapping("/v1/query_equip_charge_status")
public CommonResult<?> query_equip_charge_status(HttpServletRequest request, @RequestBody CommonParamsDTO dto) {
logger.info("{}-查询充电状态 params:{}", platformName, JSON.toJSONString(dto));
try {
// 校验令牌
if (!verifyToken(request.getHeader("Authorization"))) {
// 校验失败
return CommonResult.failed(ThirdPartyReturnCodeEnum.TOKEN_ERROR);
}
dto.setPlatformType(platformType);
// 校验签名
if (!verifySignature(dto)) {
// 签名错误
return CommonResult.failed(ThirdPartyReturnCodeEnum.SIGN_ERROR);
}
// 解析入参
QueryEquipChargeStatusDTO queryEquipChargeStatusDTO = parseParamsDTO(dto, QueryEquipChargeStatusDTO.class);
// 执行逻辑
Map<String, String> map = platformLogic.queryEquipChargeStatus(queryEquipChargeStatusDTO);
logger.info("{}-查询充电状态 result:{}", platformName, map);
return CommonResult.success(Integer.parseInt(map.get("Ret")), map.get("Msg"), map.get("Data"), map.get("Sig"));
} catch (Exception e) {
logger.error("{}-查询充电状态 error:", platformName, e);
}
return CommonResult.failed("查询充电状态发生异常");
}
/**
* 统计信息查询 query_station_stats
* @param request
* @param dto
* @return
*/
@PostMapping("/v1/query_station_stats")
public CommonResult<?> query_station_stats(HttpServletRequest request, @RequestBody CommonParamsDTO dto) {
logger.info("{}-查询统计信息 params:{}", platformName, JSON.toJSONString(dto));
try {
// 校验令牌
if (!verifyToken(request.getHeader("Authorization"))) {
// 校验失败
return CommonResult.failed(ThirdPartyReturnCodeEnum.TOKEN_ERROR);
}
// 校验签名
if (!verifySignature(dto)) {
// 签名错误
return CommonResult.failed(ThirdPartyReturnCodeEnum.SIGN_ERROR);
}
// 解析入参
QueryStationInfoDTO queryStationInfoDTO = parseParamsDTO(dto, QueryStationInfoDTO.class);
// 执行逻辑
Map<String, String> map = platformLogic.queryStationStats(queryStationInfoDTO);
logger.info("{}-查询统计信息 result:{}", platformName, map);
return CommonResult.success(0, "查询统计信息成功!", map.get("Data"), map.get("Sig"));
} catch (Exception e) {
logger.info("{}-查询统计信息 error:", platformName, e);
}
return CommonResult.failed("查询统计信息发生异常");
}
/**
* 设备状态推送
* notification_stationStatus
* @param request
* @return
*/
@PostMapping("/v1/notification_stationStatus")
public RestApiResponse<?> notification_stationStatus(@RequestBody PushRealTimeInfoDTO pushRealTimeInfoDTO, HttpServletRequest request) {
RestApiResponse<?> response = null;
try {
String result = platformLogic.notificationStationStatus(pushRealTimeInfoDTO);
logger.info("【{}】推送设备状态 result:{}", this.getClass().getSimpleName(), result);
response = new RestApiResponse<>(result);
}catch (BusinessException e) {
logger.error("【{}】推送设备状态 error:{}", this.getClass().getSimpleName(), e.getMessage());
response = new RestApiResponse<>(e.getCode(), e.getMessage());
}catch (Exception e) {
logger.error("【{}】推送设备状态 error:{}", this.getClass().getSimpleName(), e);
response = new RestApiResponse<>(e);
}
logger.info("【{}】推送设备状态 response:{}", this.getClass().getSimpleName(), response);
return response;
}
/**
* 推送充电状态
* http://localhost:8080/hainan/notificationEquipChargeStatus
* @param orderCode
* @return
*/
@GetMapping("/v1/notification_equip_charge_status/{orderCode}")
public RestApiResponse<?> notification_equip_charge_status(@PathVariable("orderCode") String orderCode) {
logger.info("推送充电状态 params:{}", orderCode);
RestApiResponse<?> response = null;
try {
String result = platformLogic.notificationEquipChargeStatus(orderCode);
logger.info("推送充电状态 result:{}", result);
response = new RestApiResponse<>(result);
}catch (BusinessException e) {
logger.error("推送充电状态 error",e);
response = new RestApiResponse<>(e.getCode(), e.getMessage());
}catch (Exception e) {
logger.error("推送充电状态 error", e);
response = new RestApiResponse<>(e);
}
logger.info("推送充电状态 result:{}", response);
return response;
}
/**
* 充电订单信息推送
*/
@PostMapping("/v1/notification_charge_order_info")
public RestApiResponse<?> notification_charge_order_info(@RequestBody QueryOrderDTO dto) {
RestApiResponse<?> response = null;
try {
String result = platformLogic.pushOrderInfo(dto);
response = new RestApiResponse<>(result);
}catch (BusinessException e){
logger.error("推送充电订单信息 error",e);
response = new RestApiResponse<>(e.getCode(), e.getMessage());
}catch (Exception e) {
logger.error("推送充电订单信息 error", e);
response = new RestApiResponse<>(e);
}
logger.info("推送充电订单信息 result:{}", response);
return response;
}
}

View File

@@ -33,7 +33,8 @@ public enum ThirdPlatformTypeEnum {
XIN_YUN_PLATFORM("21", "新运平台", "MADKXL8FX"),
HE_NAN_PLATFORM("22", "河南省平台", "050880341"),
WEI_WANG_XIN_DIAN("23", "微网新电", "MA005DBW1")
WEI_WANG_XIN_DIAN("23", "微网新电", "MA005DBW1"),
HU_ZHOU_PLATFORM("24", "湖州市监管平台", "MA27U00HZ"),
;
private String typeCode;

View File

@@ -205,4 +205,11 @@ public class EquipmentInfo {
*/
private BigDecimal stationRatedPower;
/**
*报装户号
* 如整个站按一个户号立户的则站内所以设备的户号为同一个如果是桩立户则为桩实际立户户号。20 字符。
*/
private String ConsNo;
}

View File

@@ -0,0 +1,807 @@
package com.jsowell.thirdparty.platform.service.impl;
import cn.hutool.http.HttpUtil;
import cn.hutool.json.JSONUtil;
import com.alibaba.fastjson2.JSON;
import com.alibaba.fastjson2.JSONObject;
import com.github.pagehelper.PageInfo;
import com.google.common.collect.Lists;
import com.jsowell.common.constant.Constants;
import com.jsowell.common.core.domain.ykc.RealTimeMonitorData;
import com.jsowell.common.enums.thirdparty.BusinessInformationExchangeEnum;
import com.jsowell.common.enums.thirdparty.ThirdPlatformTypeEnum;
import com.jsowell.common.enums.ykc.OrderStatusEnum;
import com.jsowell.common.enums.ykc.PileConnectorDataBaseStatusEnum;
import com.jsowell.common.enums.ykc.ReturnCodeEnum;
import com.jsowell.common.exception.BusinessException;
import com.jsowell.common.util.*;
import com.jsowell.pile.domain.*;
import com.jsowell.pile.dto.PushRealTimeInfoDTO;
import com.jsowell.pile.dto.QueryEquipChargeStatusDTO;
import com.jsowell.pile.dto.QueryOrderDTO;
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.vo.ThirdPartySecretInfoVO;
import com.jsowell.pile.vo.base.ConnectorInfoVO;
import com.jsowell.pile.vo.base.MerchantInfoVO;
import com.jsowell.pile.vo.base.ThirdPartyStationInfoVO;
import com.jsowell.pile.vo.lianlian.AccumulativeInfoVO;
import com.jsowell.pile.vo.web.PileConnectorInfoVO;
import com.jsowell.pile.vo.web.PileModelInfoVO;
import com.jsowell.pile.vo.web.PileStationVO;
import com.jsowell.thirdparty.lianlian.domain.*;
import com.jsowell.thirdparty.lianlian.vo.AccessTokenVO;
import com.jsowell.thirdparty.lianlian.vo.LianLianResultVO;
import com.jsowell.thirdparty.lianlian.vo.QueryChargingStatusVO;
import com.jsowell.thirdparty.platform.domain.SupStationInfo;
import com.jsowell.thirdparty.platform.factory.ThirdPartyPlatformFactory;
import com.jsowell.thirdparty.platform.service.ThirdPartyPlatformService;
import com.jsowell.thirdparty.platform.util.*;
import com.jsowell.thirdparty.service.ThirdpartySecretInfoService;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.math.BigDecimal;
import java.nio.charset.StandardCharsets;
import java.util.*;
import java.util.stream.Collectors;
@Service
@Slf4j
public class HuZhouPlatformServiceImpl implements ThirdPartyPlatformService {
// 平台类型
private final String thirdPlatformType = ThirdPlatformTypeEnum.HU_ZHOU_PLATFORM.getTypeCode();
@Autowired
private ThirdpartySecretInfoService thirdpartySecretInfoService;
@Autowired
private PileStationInfoService pileStationInfoService;
@Autowired
private PileBasicInfoService pileBasicInfoService;
@Autowired
private PileModelInfoService pileModelInfoService;
@Autowired
private PileConnectorInfoService pileConnectorInfoService;
@Autowired
private PileMerchantInfoService pileMerchantInfoService;
@Autowired
private OrderBasicInfoService orderBasicInfoService;
@Override
public void afterPropertiesSet() throws Exception {
ThirdPartyPlatformFactory.register(thirdPlatformType, this);
}
/**
* query_token 获取token提供给第三方平台使用
*
* @param dto
* @return
*/
@Override
public Map<String, String> queryToken(CommonParamsDTO dto) {
AccessTokenVO vo = new AccessTokenVO();
// 0:成功1:失败
int succStat = 0;
// 0:无1:无此对接平台2:密钥错误; 399:自定义
int failReason = 0;
String operatorId = StringUtils.isNotBlank(dto.getOperatorID()) ? dto.getOperatorID() : dto.getPlatformID();
// 通过operatorId 查出 operatorSecret
ThirdPartySecretInfoVO thirdPartySecretInfoVO = thirdpartySecretInfoService.queryByOperatorId(operatorId);
if (thirdPartySecretInfoVO == null) {
failReason = 1;
succStat = 1;
} else {
String theirOperatorSecret = thirdPartySecretInfoVO.getTheirOperatorSecret();
String dataSecret = thirdPartySecretInfoVO.getOurDataSecret();
String dataSecretIv = thirdPartySecretInfoVO.getOurDataSecretIv();
// 解密data 获取参数中的OperatorSecret
String decrypt = Cryptos.decrypt(dto.getData(), dataSecret, dataSecretIv);
String inputOperatorSecret = null;
if (StringUtils.isNotBlank(decrypt)) {
inputOperatorSecret = JSON.parseObject(decrypt).getString("OperatorSecret");
if (StringUtils.isBlank(inputOperatorSecret)) {
inputOperatorSecret = JSON.parseObject(decrypt).getString("PlatformSecret");
}
}
// 对比密钥
List<String> operatorSecretList = Lists.newArrayList(theirOperatorSecret, thirdPartySecretInfoVO.getOurOperatorSecret());
if (!operatorSecretList.contains(inputOperatorSecret)) {
failReason = 1;
succStat = 1;
} else {
// 生成token
String token = JWTUtils.createToken(operatorId, theirOperatorSecret, JWTUtils.ttlMillis);
vo.setAccessToken(token);
vo.setTokenAvailableTime((int) (JWTUtils.ttlMillis / 1000));
}
}
// 组装返回参数
vo.setPlatformId(operatorId);
vo.setFailReason(failReason);
vo.setSuccStat(succStat);
return ThirdPartyPlatformUtils.generateResultMapV2(vo, thirdPartySecretInfoVO.getTheirDataSecret(),
thirdPartySecretInfoVO.getTheirDataSecretIv(), thirdPartySecretInfoVO.getTheirSigSecret());
}
@Override
public String getToken(String urlAddress, String operatorId, String operatorSecret, String dataSecretIv, String signSecret, String dataSecret) {
String token = "";
log.info("operatorId:{}, operatorSecret:{}, dataSecretIv:{}, signSecret:{}, dataSecret:{}", operatorId, operatorSecret, dataSecretIv, signSecret, dataSecret);
try {
// 请求地址
String requestUrl = urlAddress + "query_token";
// 请求data
Map<String, String> data = new HashMap<>();
data.put("OperatorID", operatorId);
data.put("OperatorSecret", operatorSecret);
data.put("DataSecretIV", dataSecretIv);
String dataJson = JSONUtil.toJsonStr(data);
// 加密
byte[] encryptText = Cryptos.aesEncrypt(dataJson.getBytes(StandardCharsets.UTF_8),
dataSecret.getBytes(), dataSecretIv.getBytes());
String strData = Encodes.encodeBase64(encryptText);
Map<String, String> request = new LinkedHashMap<>();
request.put("OperatorID", operatorId);
request.put("Data", strData);
request.put("TimeStamp", DateUtils.parseDateToStr(DateUtils.YYYYMMDDHHMMSS, new Date()));
request.put("Seq", "0001");
// 生成签名
String sig = GBSignUtils.sign(request, signSecret);
request.put("Sig", sig);
String tokenRequest = JSONUtil.toJsonStr(request);
log.info("请求参数:{}", tokenRequest);
String response = HttpUtil.post(requestUrl, tokenRequest);
LianLianResultVO result = JSON.parseObject(response, LianLianResultVO.class);
log.info("返回参数:{}", response);
if (result.getRet() == 0) {
// 解密data
byte[] plainText = Cryptos.aesDecrypt(Encodes.decodeBase64((String) result.getData()),
dataSecret.getBytes(), dataSecretIv.getBytes());
String dataStr = new String(plainText, StandardCharsets.UTF_8);
Map<String, Object> resultMap = (Map<String, Object>) JSON.parse(dataStr);
token = String.valueOf(resultMap.get("AccessToken"));
}
} catch (Exception e) {
return token;
}
return token;
}
/**
* 查询站点信息
* query_stations_info
* @param dto 查询站点信息dto
* @return
*/
@Override
public Map<String, String> queryStationsInfo(QueryStationInfoDTO dto) {
int pageNo = dto.getPageNo() == null ? 1 : dto.getPageNo();
int pageSize = dto.getPageSize() == null ? 10 : dto.getPageSize();
dto.setThirdPlatformType(thirdPlatformType);
PageUtils.startPage(pageNo, pageSize);
List<ThirdPartyStationInfoVO> stationInfos = pileStationInfoService.selectStationInfosByThirdParty(dto);
if (CollectionUtils.isEmpty(stationInfos)) {
// 未查到数据
return null;
}
// ThirdPartyPlatformConfig configInfo = thirdPartyPlatformConfigService.getInfoByOperatorId(dto.getOperatorId());
ThirdPartySecretInfoVO thirdPartySecretInfoVO = getHuZhouPlatformSecretInfo();
PageInfo<ThirdPartyStationInfoVO> pageInfo = new PageInfo<>(stationInfos);
List<SupStationInfo> resultList = new ArrayList<>();
for (ThirdPartyStationInfoVO pileStationInfo : pageInfo.getList()) {
SupStationInfo stationInfo = new SupStationInfo();
stationInfo.setStationID(String.valueOf(pileStationInfo.getId()));
stationInfo.setOperatorID(Constants.OPERATORID_JIANG_SU); // 组织机构代码
String organizationCode = pileStationInfo.getOrganizationCode();
if (StringUtils.isNotBlank(organizationCode) && organizationCode.length() == 18) {
String equipmentOwnerId = StringUtils.substring(organizationCode, organizationCode.length() - 10, organizationCode.length() - 1);
stationInfo.setEquipmentOwnerID(equipmentOwnerId);
}else {
stationInfo.setEquipmentOwnerID(Constants.OPERATORID_JIANG_SU);
}
stationInfo.setStationName(pileStationInfo.getStationName());
stationInfo.setCountryCode(pileStationInfo.getCountryCode());
String areaCode = pileStationInfo.getAreaCode(); // 330000,330200,330213
// 根据逗号分组
String[] split = StringUtils.split(areaCode, ",");
// 只取最后一部分 330213
String subAreaCode = split[split.length - 1];
stationInfo.setAreaCode(subAreaCode);
stationInfo.setAddress(pileStationInfo.getAddress());
stationInfo.setServiceTel(pileStationInfo.getStationTel());
stationInfo.setStationType(Integer.parseInt(pileStationInfo.getStationType()));
stationInfo.setStationStatus(Integer.parseInt(pileStationInfo.getStationStatus()));
stationInfo.setParkNums(Integer.parseInt(pileStationInfo.getParkNums()));
stationInfo.setStationLng(new BigDecimal(pileStationInfo.getStationLng()));
stationInfo.setStationLat(new BigDecimal(pileStationInfo.getStationLat()));
stationInfo.setConstruction(Integer.parseInt(pileStationInfo.getConstruction()));
// 停车费率描述
if (StringUtils.isNotBlank(pileStationInfo.getParkFeeDescribe())) {
stationInfo.setParkFee(pileStationInfo.getParkFeeDescribe());
}
// 站点图片
if (StringUtils.isNotBlank(pileStationInfo.getPictures())) {
stationInfo.setPictures(Lists.newArrayList(pileStationInfo.getPictures().split(",")));
}
List<EquipmentInfo> pileList = getPileList(pileStationInfo);
if (CollectionUtils.isNotEmpty(pileList)) {
stationInfo.setEquipmentInfos(pileList); // 充电设备信息列表
}
resultList.add(stationInfo);
}
Map<String, Object> map = new LinkedHashMap<>();
map.put("ItemSize", resultList.size());
map.put("PageCount", pageInfo.getPages());
map.put("PageNo", pageInfo.getPageNum());
map.put("StationInfos", resultList);
log.info("返回参数:{}", JSON.toJSONString(map));
return ThirdPartyPlatformUtils.generateResultMap(map, thirdPartySecretInfoVO);
}
/* *//**
* 推送站点信息
*
* @param stationId 充电站id
* @return
*//*
@Override
public String notificationStationInfo(String stationId) {
List<SupStationInfo> stationInfos = new ArrayList<>();
// 通过id查询站点相关信息
PileStationInfo pileStationInfo = pileStationInfoService.selectPileStationInfoById(Long.parseLong(stationId));
// 查询相关配置信息
ThirdPartySecretInfoVO huZhouPlatformSecretInfo = getHuZhouPlatformSecretInfo();
String operatorId = Constants.OPERATORID_JIANG_SU;
String operatorSecret = huZhouPlatformSecretInfo.getTheirOperatorSecret();
String signSecret = huZhouPlatformSecretInfo.getTheirSigSecret();
String dataSecret = huZhouPlatformSecretInfo.getTheirDataSecret();
String dataSecretIv = huZhouPlatformSecretInfo.getTheirDataSecretIv();
String urlAddress = huZhouPlatformSecretInfo.getTheirUrlPrefix();
// 组装中电联平台所需要的数据格式
SupStationInfo info = SupStationInfo.builder()
.stationID(stationId)
.operatorID(Constants.OPERATORID_JIANG_SU)
// .equipmentOwnerId(Constants.OPERATORID_JIANG_SU)
.stationName(pileStationInfo.getStationName())
.countryCode(pileStationInfo.getCountryCode())
.areaCode(pileStationInfo.getAreaCode())
.address(pileStationInfo.getAddress())
.serviceTel(pileStationInfo.getStationTel())
.stationType(Integer.valueOf(pileStationInfo.getStationType()))
.stationStatus(Integer.valueOf(pileStationInfo.getStationStatus()))
.parkNums(Integer.valueOf(pileStationInfo.getParkNums()))
.stationLng(new BigDecimal(pileStationInfo.getStationLng()))
.stationLat(new BigDecimal(pileStationInfo.getStationLat()))
.construction(Integer.valueOf(pileStationInfo.getConstruction()))
.build();
String areaCode = pileStationInfo.getAreaCode(); // 330000,330200,330213
// 根据逗号分组
String[] split = StringUtils.split(areaCode, ",");
// 只取最后一部分 330213
String subAreaCode = split[split.length - 1];
info.setAreaCode(subAreaCode);
// 截取运营商组织机构代码(去除最后一位后的最后九位)
MerchantInfoVO merchantInfo = pileMerchantInfoService.getMerchantInfoVO(String.valueOf(pileStationInfo.getMerchantId()));
String organizationCode = merchantInfo.getOrganizationCode();
if (StringUtils.isNotBlank(organizationCode) && organizationCode.length() == 18) {
String equipmentOwnerId = StringUtils.substring(organizationCode, organizationCode.length() - 10, organizationCode.length() - 1);
info.setEquipmentOwnerID(equipmentOwnerId);
}
// 站点图片
if (StringUtils.isNotBlank(pileStationInfo.getPictures())) {
info.setPictures(Lists.newArrayList(pileStationInfo.getPictures().split(",")));
}
List<EquipmentInfo> pileList = getPileList(pileStationInfo);
if (CollectionUtils.isNotEmpty(pileList)) {
info.setEquipmentInfos(pileList); // 充电设备信息列表
}
stationInfos.add(info);
// 调用中电联平台接口
String url = urlAddress + "notification_stationInfo";
JSONObject data = new JSONObject();
data.put("StationInfos", stationInfos);
String jsonString = JSON.toJSONString(data);
System.out.println("jsonString : " + jsonString);
// 获取令牌
String token = getToken(urlAddress, operatorId, operatorSecret, dataSecretIv, signSecret, dataSecret);
String result = HttpRequestUtil.sendPost(token, jsonString, url, dataSecret, dataSecretIv, operatorId, signSecret);
return result;
}*/
/**
* 设备状态变化推送 notification_stationStatus
* @param dto
* @return
*/
@Override
public String notificationStationStatus(PushRealTimeInfoDTO dto) {
String status = dto.getStatus();
String pileConnectorCode = dto.getPileConnectorCode();
YKCUtils.getPileSn(pileConnectorCode);
// 通过站点id查询相关配置信息
ThirdPartySecretInfoVO thirdPartySecretInfoVO = getHuZhouPlatformSecretInfo();
String operatorId = thirdPartySecretInfoVO.getOurOperatorId();
String operatorSecret = thirdPartySecretInfoVO.getTheirOperatorSecret();
String signSecret = thirdPartySecretInfoVO.getTheirSigSecret();
String dataSecret = thirdPartySecretInfoVO.getTheirDataSecret();
String dataSecretIv = thirdPartySecretInfoVO.getTheirDataSecretIv();
String urlAddress = thirdPartySecretInfoVO.getTheirUrlPrefix();
String url = urlAddress + BusinessInformationExchangeEnum.NOTIFICATION_STATION_STATUS.getValue();
ConnectorStatusInfo info = ConnectorStatusInfo.builder()
.connectorID(pileConnectorCode)
.status(Integer.parseInt(status))
.build();
JSONObject json = new JSONObject();
json.put("ConnectorStatusInfo", info);
String jsonString = JSON.toJSONString(json);
log.info("参数:{}", jsonString);
// 获取令牌
String token = getToken(urlAddress, operatorId, operatorSecret, dataSecretIv, signSecret, dataSecret);
log.info("token{}", token);
String result = HttpRequestUtil.sendPost(token, jsonString, url, dataSecret, dataSecretIv, operatorId, signSecret);
log.info("返回结果:{}", result);
return result;
}
/**
* 设备接口状态查询 query_station_status
* @param dto 查询站点信息dto
* @return
*/
@Override
public Map<String, String> queryStationStatus(QueryStationInfoDTO dto) {
List<String> stationIds = dto.getStationIds();
List<StationStatusInfo> stationStatusInfos = new ArrayList<>();
ThirdPartySecretInfoVO huZhouPlatformSecretInfo = getHuZhouPlatformSecretInfo();
for (String stationId : stationIds) {
StationStatusInfo stationStatusInfo = new StationStatusInfo();
stationStatusInfo.setStationId(stationId);
// 根据站点id查询
List<ConnectorInfoVO> list = pileConnectorInfoService.getConnectorListForLianLian(Long.parseLong(stationId));
if (CollectionUtils.isEmpty(list)) {
throw new IllegalArgumentException("站点id" + stationId + "未查询到相关充电枪口信息");
}
List<Object> connectorStatusInfos = new ArrayList<>();
for (ConnectorInfoVO connectorInfoVO : list) {
ConnectorStatusInfo connectorStatusInfo = new ConnectorStatusInfo();
// 只在有值时设置,否则保持 null
connectorStatusInfo.setConnectorID(connectorInfoVO.getPileConnectorCode());
connectorStatusInfo.setStatus(Integer.parseInt(connectorInfoVO.getConnectorStatus()));
connectorStatusInfos.add(connectorStatusInfo);
}
stationStatusInfo.setConnectorStatusInfos(connectorStatusInfos);
stationStatusInfos.add(stationStatusInfo);
}
Map<String, Object> map = new LinkedHashMap<>();
map.put("StationStatusInfos", stationStatusInfos);
log.info("返回参数:{}", JSON.toJSONString(map));
return ThirdPartyPlatformUtils.generateResultMap(map, huZhouPlatformSecretInfo);
}
/**
* 推送充电状态 notification_equip_charge_status
* @param orderCode 订单编号
* @return
*/
@Override
public String notificationEquipChargeStatus(String orderCode) {
// 根据订单号查询订单信息
OrderBasicInfo orderInfo = orderBasicInfoService.getOrderInfoByOrderCode(orderCode);
OrderDetail orderDetail = orderBasicInfoService.getOrderDetailByOrderCode(orderInfo.getOrderCode());
// 查询枪口状态
PileConnectorInfoVO info = pileConnectorInfoService.getPileConnectorInfoByConnectorCode(orderInfo.getPileConnectorCode());
// 查询相关配置信息
ThirdPartySecretInfoVO ningBoSecretInfoVO = getHuZhouPlatformSecretInfo();
//获取最新soc
List<RealTimeMonitorData> chargingRealTimeData = orderBasicInfoService.getChargingRealTimeData(orderInfo.getTransactionCode());
String operatorId = Constants.OPERATORID_JIANG_SU;
String operatorSecret = ningBoSecretInfoVO.getTheirOperatorSecret();
String signSecret = ningBoSecretInfoVO.getTheirSigSecret();
String dataSecret = ningBoSecretInfoVO.getTheirDataSecret();
String dataSecretIv = ningBoSecretInfoVO.getTheirDataSecretIv();
String urlAddress = ningBoSecretInfoVO.getTheirUrlPrefix();
QueryChargingStatusVO vo = QueryChargingStatusVO.builder()
.startChargeSeq(orderInfo.getOrderCode()) // 订单号
.startChargeSeqStat(Integer.parseInt(orderInfo.getOrderStatus())) // 订单状态
.connectorID(orderInfo.getPileConnectorCode()) // 枪口编码
.connectorStatus(info.getStatus()) // 枪口状态
.currentA(info.getCurrent()) // 电流
.voltageA(info.getVoltage()) // 电压
.soc(new BigDecimal(chargingRealTimeData.get(0).getSOC()))
.startTime(DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD_HH_MM_SS, orderInfo.getChargeStartTime())) // 开始时间
.endTime(DateUtils.getDateTime()) // 本次采样时间
.totalPower(info.getChargingDegree()) // 累计充电量
/* .elecMoney(totalElectricityAmount.setScale(2, BigDecimal.ROUND_HALF_UP)) // 累计电费
.seviceMoney(totalServiceAmount.setScale(2, BigDecimal.ROUND_HALF_UP)) // 累计服务费
.totalMoney(info.getChargingAmount()) // 已充金额*/
.build();
String url = urlAddress + BusinessInformationExchangeEnum.NOTIFICATION_EQUIP_CHARGE_STATUS.getValue();
// 调用平台接口
String jsonString = JSON.toJSONString(vo);
log.info("请求参数:{}", jsonString);
String token = getToken(urlAddress, operatorId, operatorSecret, dataSecretIv, signSecret, dataSecret);
String result = HttpRequestUtil.sendPost(token, jsonString, url, dataSecret, dataSecretIv, operatorId, signSecret);
return result;
}
/**
* 查询充电状态 query equip charge status
* @param dto 查询充电状态DTO
* @return
*/
@Override
public Map<String, String> queryEquipChargeStatus(QueryEquipChargeStatusDTO dto) {
String operatorID = dto.getOperatorID();
// 通过订单号查询订单信息
OrderBasicInfo orderInfo = orderBasicInfoService.getOrderInfoByOrderCode(dto.getStartChargeSeq());
// logger.info(operatorName + "查询订单信息 orderInfo:{}", orderInfo);
if (orderInfo == null) {
return null;
}
ThirdPartySecretInfoVO huZhouPlatformSecretInfo = getHuZhouPlatformSecretInfo();
OrderDetail orderDetail = orderBasicInfoService.getOrderDetailByOrderCode(orderInfo.getOrderCode());
// 通过订单号查询实时数据
List<RealTimeMonitorData> realTimeData = orderBasicInfoService.getChargingRealTimeData(orderInfo.getTransactionCode());
QueryChargingStatusVO vo;
if (CollectionUtils.isEmpty(realTimeData)) {
vo = new QueryChargingStatusVO();
} else {
RealTimeMonitorData data = realTimeData.get(0);
String orderStatus = orderInfo.getOrderStatus();
if (StringUtils.equals(orderStatus, OrderStatusEnum.IN_THE_CHARGING.getValue())) {
// 充电中
orderStatus = "2";
}else if (StringUtils.equals(orderStatus, OrderStatusEnum.ORDER_COMPLETE.getValue())) {
// 充电完成
orderStatus = "4";
} else {
// 直接给 5-未知
orderStatus = "5";
}
String status = data.getConnectorStatus();
int connectorStatus = 0;
if (StringUtils.isBlank(status)) {
// 查询当前枪口状态
PileConnectorInfoVO connectorInfoVO = pileConnectorInfoService.getPileConnectorInfoByConnectorCode(orderInfo.getPileConnectorCode());
connectorStatus = connectorInfoVO.getStatus();
}else {
connectorStatus = Integer.parseInt(status);
}
BigDecimal totalElectricityAmount = orderDetail.getTotalElectricityAmount() == null ? BigDecimal.ZERO : orderDetail.getTotalElectricityAmount();
BigDecimal totalServiceAmount = orderDetail.getTotalServiceAmount() == null ? BigDecimal.ZERO : orderDetail.getTotalServiceAmount();
// 拼装联联平台数据
vo = QueryChargingStatusVO.builder()
.startChargeSeq(dto.getStartChargeSeq()) // 订单号
.startChargeSeqStat(Integer.parseInt(orderStatus)) // 订单状态
.connectorID(orderInfo.getPileConnectorCode()) // 枪口编码
.connectorStatus(connectorStatus) // 枪口状态
.currentA(new BigDecimal(data.getOutputCurrent())) // 电流
.voltageA(new BigDecimal(data.getOutputVoltage())) // 电压
.soc(new BigDecimal(data.getSOC()))
.startTime(DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD_HH_MM_SS, orderInfo.getChargeStartTime())) // 开始时间
.endTime(DateUtils.getDateTime()) // 本次采样时间
.totalPower(new BigDecimal(data.getChargingDegree()).setScale(2, BigDecimal.ROUND_HALF_UP)) // 累计充电量
// .elecMoney(totalElectricityAmount.setScale(2, BigDecimal.ROUND_HALF_UP)) // 累计电费
// .seviceMoney(totalServiceAmount.setScale(2, BigDecimal.ROUND_HALF_UP)) // 累计服务费
// .totalMoney(new BigDecimal(data.getChargingAmount())) // 已充金额
.build();
}
log.info("返回参数:{}", JSON.toJSONString(vo));
return ThirdPartyPlatformUtils.generateResultMap(vo, huZhouPlatformSecretInfo);
}
/**
* 查询统计信息 query_station_stats
* @param dto 查询站点信息dto
* @return
*/
@Override
public Map<String, String> queryStationStats(QueryStationInfoDTO dto) {
ThirdPartySecretInfoVO huZhouPlatformSecretInfo = getHuZhouPlatformSecretInfo();
// 根据站点id 查出这段时间的充电量
List<AccumulativeInfoVO> list = orderBasicInfoService.getAccumulativeInfoForLianLian(dto);
if (CollectionUtils.isEmpty(list)) {
return null;
}
// 根据充电桩编号分组 key=充电桩编号
Map<String, List<AccumulativeInfoVO>> pileMap = list.stream()
.collect(Collectors.groupingBy(AccumulativeInfoVO::getPileSn));
// 存放所有充电桩设备
List<EquipmentStatsInfo> equipmentStatsInfoList = Lists.newArrayList();
// 站点用电量
BigDecimal stationElectricity = BigDecimal.ZERO;
// 用于记录枪口用电量 在循环每个枪口的时候初始化
BigDecimal pileElec;
for (String pileSn : pileMap.keySet()) {
// 该充电桩下 所有枪口的用电数据
List<AccumulativeInfoVO> accumulativeInfoVOS = pileMap.get(pileSn);
if (CollectionUtils.isEmpty(accumulativeInfoVOS)) {
continue;
}
// 存放充电桩用电量
pileElec = BigDecimal.ZERO;
// key=枪口编号 value 该枪口的用电数据
Map<String, List<AccumulativeInfoVO>> collect = accumulativeInfoVOS.stream()
.collect(Collectors.groupingBy(AccumulativeInfoVO::getPileConnectorCode));
List<ConnectorStatsInfo> connectorStatsInfos = Lists.newArrayList();
for (Map.Entry<String, List<AccumulativeInfoVO>> entry : collect.entrySet()) {
String pileConnectorCode = entry.getKey();
List<AccumulativeInfoVO> value = entry.getValue();
// 枪口用电量求和
BigDecimal connectorElec = value.stream()
.map(AccumulativeInfoVO::getConnectorElectricity)
.map(BigDecimal::new)
.reduce(BigDecimal.ZERO, BigDecimal::add);
connectorStatsInfos.add(
ConnectorStatsInfo.builder()
.connectorID(pileConnectorCode)
.connectorElectricity(connectorElec)
.build()
);
// 充电桩电量为枪口用电量累计
pileElec = pileElec.add(connectorElec);
}
EquipmentStatsInfo build = EquipmentStatsInfo.builder()
.equipmentID(pileSn)
.equipmentElectricity(pileElec)
.connectorStatsInfos(connectorStatsInfos)
.build();
equipmentStatsInfoList.add(build);
// 所有充电桩用电量之和
stationElectricity = stationElectricity.add(pileElec);
}
StationStatsInfo stationStatsInfo = StationStatsInfo.builder()
.stationID(dto.getStationID())
.startTime(dto.getStartTime())
.endTime(dto.getEndTime())
.stationElectricity(stationElectricity)
.equipmentStatsInfos(equipmentStatsInfoList) // 设备列表
.build();
Map<String, Object> map = new LinkedHashMap<>();
map.put("StationStats", stationStatsInfo);
log.info("返回参数:{}", JSON.toJSONString(map));
return ThirdPartyPlatformUtils.generateResultMap(map, huZhouPlatformSecretInfo);
}
/**
* 6.9 推送充电订单信息
* @param orderCode
* @param thirdPartySecretInfoVO
* @return
*/
public String notificationChargeOrderInfo(String orderCode, ThirdPartySecretInfoVO thirdPartySecretInfoVO) {
OrderBasicInfo orderBasicInfo = orderBasicInfoService.getOrderInfoByOrderCode(orderCode);
OrderDetail orderDetail = orderBasicInfoService.getOrderDetailByOrderCode(orderCode);
String operatorId = Constants.OPERATORID_JIANG_SU;
String operatorSecret = thirdPartySecretInfoVO.getTheirOperatorSecret();
String signSecret = thirdPartySecretInfoVO.getTheirSigSecret();
String dataSecret = thirdPartySecretInfoVO.getTheirDataSecret();
String dataSecretIv = thirdPartySecretInfoVO.getTheirDataSecretIv();
String urlAddress = thirdPartySecretInfoVO.getTheirUrlPrefix();
String url = urlAddress + BusinessInformationExchangeEnum.NOTIFICATION_CHARGE_ORDER_INFO.getValue();
Date chargeStartTime = orderBasicInfo.getChargeStartTime();
if (chargeStartTime == null) {
chargeStartTime = orderBasicInfo.getCreateTime();
}
Date chargeEndTime = orderBasicInfo.getChargeEndTime();
if (chargeEndTime == null) {
chargeEndTime = orderBasicInfo.getCreateTime();
}
JSONObject json = new JSONObject();
json.put("StartChargeSeq", orderCode);
json.put("ConnectorID", orderBasicInfo.getPileConnectorCode());
json.put("StartTime", DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD_HH_MM_SS, chargeStartTime));
json.put("EndTime", DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD_HH_MM_SS, chargeEndTime));
json.put("TotalPower", orderDetail.getTotalUsedElectricity().setScale(3, BigDecimal.ROUND_HALF_UP));
json.put("ToppkPower", orderDetail.getSharpUsedElectricity().setScale(3, BigDecimal.ROUND_HALF_UP)); // 尖电
json.put("PeakPower",orderDetail.getPeakUsedElectricity().setScale(3, BigDecimal.ROUND_HALF_UP)); // 峰电
json.put("FlatPower",orderDetail.getFlatUsedElectricity().setScale(3, BigDecimal.ROUND_HALF_UP)) ; // 平电
json.put("ValleyPower",orderDetail.getValleyUsedElectricity().setScale(3, BigDecimal.ROUND_HALF_UP));// 谷电
json.put("TotalElecMoney", orderDetail.getTotalElectricityAmount().setScale(2, BigDecimal.ROUND_HALF_UP));
json.put("TotalSeviceMoney", orderDetail.getTotalServiceAmount().setScale(2, BigDecimal.ROUND_HALF_UP));
json.put("TotalMoney", orderDetail.getTotalOrderAmount().setScale(2, BigDecimal.ROUND_HALF_UP));
json.put("StopReason", 2); // 2BMS 停止充电
String jsonString = JSON.toJSONString(json);
log.info("请求参数:{}", jsonString);
String token = getToken(urlAddress, operatorId, operatorSecret, dataSecretIv, signSecret, dataSecret);
String result = HttpRequestUtil.sendPost(token, jsonString, url, dataSecret, dataSecretIv, operatorId, signSecret);
return result;
}
@Override
public String pushOrderInfo(QueryOrderDTO dto) {
ThirdPartySecretInfoVO wangKuaiDianPlatformSecretInfo = getHuZhouPlatformSecretInfo();
// 根据站点id 开始时间,结束时间查询出所有的订单信息
// List<OrderListVO> orderListVOS = orderBasicInfoService.selectOrderBasicInfoList(dto);
List<String> orderCodes = orderBasicInfoService.tempGetOrderCodes(dto);
if (CollectionUtils.isEmpty(orderCodes)) {
return "订单信息为空";
}
// List<String> orderCodeList = orderListVOS.stream().map(OrderListVO::getOrderCode).collect(Collectors.toList());
for (String orderCode : orderCodes) {
try {
String result = notificationChargeOrderInfo(orderCode, wangKuaiDianPlatformSecretInfo);
log.info("订单:{} 推送结果:{}", orderCode, result);
}catch (Exception e) {
log.error("订单:{} 推送error, ", orderCode, e);
}
}
return "Success";
}
/**
* 获取配置密钥信息
*
* @return
*/
private ThirdPartySecretInfoVO getHuZhouPlatformSecretInfo() {
// 通过第三方平台类型查询相关配置信息
ThirdPartySecretInfoVO thirdPartySecretInfoVO = thirdpartySecretInfoService.queryByThirdPlatformType(thirdPlatformType);
if (thirdPartySecretInfoVO == null) {
throw new BusinessException(ReturnCodeEnum.CODE_SELECT_INFO_IS_NULL);
}
thirdPartySecretInfoVO.setOurOperatorId(Constants.OPERATORID_JIANG_SU);
return thirdPartySecretInfoVO;
}
/**
* 获取桩列表信息
*
* @param pileStationInfo
* @return
*/
private List<EquipmentInfo> getPileList(PileStationInfo pileStationInfo) {
List<EquipmentInfo> resultList = new ArrayList<>();
// 通过站点id查询桩基本信息
List<PileBasicInfo> list = pileBasicInfoService.getPileListByStationId(String.valueOf(pileStationInfo.getId()));
// 封装成中电联平台对象
for (PileBasicInfo pileBasicInfo : list) {
EquipmentInfo equipmentInfo = new EquipmentInfo();
String pileSn = pileBasicInfo.getSn();
equipmentInfo.setEquipmentID(pileSn);
PileModelInfoVO modelInfo = pileModelInfoService.getPileModelInfoByPileSn(pileSn);
equipmentInfo.setEquipmentType(Integer.parseInt(modelInfo.getSpeedType()));
equipmentInfo.setPower(new BigDecimal(modelInfo.getRatedPower()).setScale(1, BigDecimal.ROUND_HALF_UP));
equipmentInfo.setConsNo(pileStationInfo.getAloneApply());
List<ConnectorInfo> connectorList = getConnectorList(pileBasicInfo);
equipmentInfo.setConnectorInfos(connectorList);
resultList.add(equipmentInfo);
}
return resultList;
}
/**
* 获取枪口列表
*
* @param pileBasicInfo
* @return
*/
private List<ConnectorInfo> getConnectorList(PileBasicInfo pileBasicInfo) {
List<ConnectorInfo> resultList = new ArrayList<>();
List<PileConnectorInfo> list = pileConnectorInfoService.selectPileConnectorInfoList(pileBasicInfo.getSn());
for (PileConnectorInfo pileConnectorInfo : list) {
ConnectorInfo connectorInfo = new ConnectorInfo();
connectorInfo.setConnectorID(pileConnectorInfo.getPileConnectorCode());
String pileSn = pileConnectorInfo.getPileSn();
PileModelInfoVO modelInfo = pileModelInfoService.getPileModelInfoByPileSn(pileSn);
int connectorType = StringUtils.equals("1", modelInfo.getSpeedType()) ? 4 : 3;
connectorInfo.setConnectorType(connectorType);
// 车位号
if (StringUtils.isNotBlank(pileConnectorInfo.getParkNo())) {
connectorInfo.setParkNo(pileConnectorInfo.getParkNo());
}
connectorInfo.setVoltageUpperLimits(Integer.valueOf(modelInfo.getRatedVoltage()));
connectorInfo.setVoltageLowerLimits(Integer.valueOf(modelInfo.getRatedVoltage()));
connectorInfo.setCurrent(Integer.valueOf(modelInfo.getRatedCurrent()));
connectorInfo.setNationalStandard(2);
// if (!StringUtils.equals(modelInfo.getConnectorNum(), "1")) {
// // 如果不是单枪,则枪口功率需要除以枪口数量
// String ratedPowerStr = modelInfo.getRatedPower();
// BigDecimal ratedPower = new BigDecimal(ratedPowerStr);
// connectorInfo.setPower(ratedPower.divide(new BigDecimal(modelInfo.getConnectorNum()), 1, BigDecimal.ROUND_HALF_UP));
// }else {
// }
connectorInfo.setPower(new BigDecimal(modelInfo.getRatedPower()).setScale(1, BigDecimal.ROUND_HALF_UP));
resultList.add(connectorInfo);
}
return resultList;
}
}

View File

@@ -343,9 +343,9 @@ public class LianLianPlatformServiceImpl implements ThirdPartyPlatformService {
// 如果是希晓运营商则把equipmentOwnerID换成希晓
stationInfo.setEquipmentOwnerID(Constants.OPERATORID_XI_XIAO);
}
/* if (MerchantUtils.isZhiHeMerchant(String.valueOf(pileStationInfo.getMerchantId()))) {
if (MerchantUtils.isZhiHeMerchant(String.valueOf(pileStationInfo.getMerchantId()))) {
stationInfo.setEquipmentOwnerID(Constants.OPERATORID_ZHI_HE);
}*/
}
List<EquipmentInfo> pileList = pileBasicInfoService.getPileListForLianLian(stationId);
if (CollectionUtils.isNotEmpty(pileList)) {
@@ -616,9 +616,9 @@ public class LianLianPlatformServiceImpl implements ThirdPartyPlatformService {
// 如果是希晓运营商则把equipmentOwnerID换成希晓
info.setEquipmentOwnerID(Constants.OPERATORID_XI_XIAO);
}
/* if (MerchantUtils.isZhiHeMerchant(String.valueOf(pileStationInfo.getMerchantId()))) {
if (MerchantUtils.isZhiHeMerchant(String.valueOf(pileStationInfo.getMerchantId()))) {
info.setEquipmentOwnerID(Constants.OPERATORID_ZHI_HE);
}*/
}
String payment = StationPaymentEnum.getPaymentByCode(pileStationInfo.getPayment());
info.setPayment(payment);
if (StringUtils.isNotBlank(pileStationInfo.getParkingNumber())) {
@@ -962,7 +962,8 @@ public class LianLianPlatformServiceImpl implements ThirdPartyPlatformService {
.elect(new BigDecimal(String.valueOf(orderDetail.getTotalUsedElectricity())).setScale(2, BigDecimal.ROUND_HALF_UP))
.startTime(DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD_HH_MM_SS, orderBasicInfo.getChargeStartTime()))
.endTime(DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD_HH_MM_SS, orderBasicInfo.getChargeEndTime()))
.paymentAmount(orderBasicInfo.getPayAmount())
.paymentAmount(orderBasicInfo.getPayAmount().setScale(2, RoundingMode.HALF_UP))
.orderType(1)
// .payChannel()
.stopReason(0)
// .chargeDetails()
@@ -975,10 +976,10 @@ public class LianLianPlatformServiceImpl implements ThirdPartyPlatformService {
// 远大
orderInfo.setEquipmentOwnerID(Constants.OPERATORID_YUAN_DA);
}
/* if (MerchantUtils.isZhiHeMerchant(orderBasicInfo.getMerchantId())) {
if (MerchantUtils.isZhiHeMerchant(orderBasicInfo.getMerchantId())) {
logger.info("订单号:{} 为之禾运营商订单", orderBasicInfo.getOrderCode());
orderInfo.setEquipmentOwnerID(Constants.OPERATORID_ZHI_HE);
}*/
}
// 支付方式
if (StringUtils.equals(orderBasicInfo.getPayMode(), OrderPayModeEnum.PAYMENT_OF_WECHATPAY.getValue())) {
// 微信支付
@@ -1000,7 +1001,7 @@ public class LianLianPlatformServiceImpl implements ThirdPartyPlatformService {
List<ChargeDetail> chargeDetails = new ArrayList<>();
for (BillingPriceVO billingPriceVO : billingList) {
detail = new ChargeDetail();
/* //改为YYYY-MM-DD HH:mm:ss格式
//改为YYYY-MM-DD HH:mm:ss格式
//拼接 开始时间和结束时间
String startTime = billingPriceVO.getStartTime();
String endTime = billingPriceVO.getEndTime();
@@ -1008,7 +1009,7 @@ public class LianLianPlatformServiceImpl implements ThirdPartyPlatformService {
billingPriceVO.setStartTime(DateUtils.formatTime(startTime));
billingPriceVO.setEndTime(DateUtils.formatTime(endTime));
billingPriceVO.getStartTime();*/
billingPriceVO.getStartTime();
if (StringUtils.equals(billingPriceVO.getTimeType(), "1")) {
// 尖时段
detail.setDetailStartTime(billingPriceVO.getStartTime());
@@ -1024,27 +1025,27 @@ public class LianLianPlatformServiceImpl implements ThirdPartyPlatformService {
detail.setDetailEndTime(billingPriceVO.getEndTime());
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.setDetailPower(orderDetail.getPeakUsedElectricity());
detail.setDetailElecMoney(orderDetail.getPeakElectricityPrice());
detail.setDetailSeviceMoney(orderDetail.getPeakServicePrice());
detail.setDetailPower(orderDetail.getPeakUsedElectricity().setScale(2, BigDecimal.ROUND_HALF_UP));
detail.setDetailElecMoney(orderDetail.getPeakElectricityPrice().setScale(2, BigDecimal.ROUND_HALF_UP));
detail.setDetailSeviceMoney(orderDetail.getPeakServicePrice().setScale(2, BigDecimal.ROUND_HALF_UP));
} else if (StringUtils.equals(billingPriceVO.getTimeType(), "3")) {
// 平时段
detail.setDetailStartTime(billingPriceVO.getStartTime());
detail.setDetailEndTime(billingPriceVO.getEndTime());
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.setDetailPower(orderDetail.getFlatUsedElectricity());
detail.setDetailElecMoney(orderDetail.getFlatElectricityPrice());
detail.setDetailSeviceMoney(orderDetail.getFlatServicePrice());
detail.setDetailPower(orderDetail.getFlatUsedElectricity().setScale(2, BigDecimal.ROUND_HALF_UP));
detail.setDetailElecMoney(orderDetail.getFlatElectricityPrice().setScale(2, BigDecimal.ROUND_HALF_UP));
detail.setDetailSeviceMoney(orderDetail.getFlatServicePrice().setScale(2, BigDecimal.ROUND_HALF_UP));
} else if (StringUtils.equals(billingPriceVO.getTimeType(), "4")) {
// 谷时段
detail.setDetailStartTime(billingPriceVO.getStartTime());
detail.setDetailEndTime(billingPriceVO.getEndTime());
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.setDetailPower(orderDetail.getValleyUsedElectricity());
detail.setDetailElecMoney(orderDetail.getValleyElectricityPrice());
detail.setDetailSeviceMoney(orderDetail.getValleyServicePrice());
detail.setDetailPower(orderDetail.getValleyUsedElectricity().setScale(2, BigDecimal.ROUND_HALF_UP));
detail.setDetailElecMoney(orderDetail.getValleyElectricityPrice().setScale(2, BigDecimal.ROUND_HALF_UP));
detail.setDetailSeviceMoney(orderDetail.getValleyServicePrice().setScale(2, BigDecimal.ROUND_HALF_UP));
}
chargeDetails.add(detail);
}