mirror of
https://codeup.aliyun.com/67c68d4e484ca2f0a13ac3c1/ydc/jsowell-charger-web.git
synced 2026-05-17 08:18:34 +08:00
update
This commit is contained in:
@@ -533,6 +533,29 @@ public class LianLianController extends ThirdPartyBaseController {
|
||||
return CommonResult.failed("推送订单结算信息发生异常");
|
||||
}
|
||||
|
||||
/**
|
||||
* 推送站点累计电量接口
|
||||
* @param thirdpartyType
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/v1/notification_station_electStatsInfo/{thirdpartyType}")
|
||||
public RestApiResponse<?> notification_station_electStatsInfo(@PathVariable("thirdpartyType") String thirdpartyType) {
|
||||
logger.info("推送站点累计电量接口 params:{}", thirdpartyType);
|
||||
RestApiResponse<?> response = null;
|
||||
try {
|
||||
String result = platformLogic.notificationStationElectStatsInfo(thirdpartyType);
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 推送充电状态
|
||||
|
||||
@@ -2,8 +2,12 @@ package com.jsowell.pile.mapper;
|
||||
|
||||
import com.jsowell.pile.domain.OrderDetail;
|
||||
import java.util.List;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import com.jsowell.pile.vo.lianlian.OrderTempVO;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
@Repository
|
||||
public interface OrderDetailMapper {
|
||||
/**
|
||||
* delete by primary key
|
||||
@@ -56,4 +60,6 @@ public interface OrderDetailMapper {
|
||||
int updateBatchSelective(List<OrderDetail> list);
|
||||
|
||||
int batchInsert(@Param("list") List<OrderDetail> list);
|
||||
|
||||
List<OrderTempVO> selectByStationId(String stationId);
|
||||
}
|
||||
@@ -3372,6 +3372,11 @@ public class OrderBasicInfoServiceImpl implements OrderBasicInfoService {
|
||||
String type = ThirdPartyOperatorIdEnum.getTypeByOperatorId(operatorId);
|
||||
// 生成订单
|
||||
String orderCode = dto.getStartChargeSeq();
|
||||
//2025.5.23发现生成的订单为425010765000000000273551033向对方平台推送订单信息接口,对方平台反差错误,使用MA1JLFUU8成功
|
||||
//但是在启动充电接口中只能使用425010765运营商id,才能启动成功,使用MA1JLFUU8错误
|
||||
if(orderCode.substring(0,9).equals(ThirdPartyOperatorIdEnum.LIAN_LIAN_PLATFORM.getOperatorId())){
|
||||
orderCode = "MA1JLFUU8" + orderCode.substring(9);
|
||||
}
|
||||
String pileConnectorCode = dto.getConnectorID();
|
||||
// String pileSn = StringUtils.substring(pileConnectorCode, 0, 14);
|
||||
String pileSn = YKCUtils.getPileSn(pileConnectorCode);
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
package com.jsowell.pile.vo.lianlian;
|
||||
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
@Data
|
||||
@Builder
|
||||
public class OrderTempVO {
|
||||
|
||||
private String orderCode;
|
||||
|
||||
private String transactionCode;
|
||||
|
||||
private BigDecimal totalUsedElectricity;
|
||||
|
||||
private String createTime;
|
||||
|
||||
private String settlementTime;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,76 @@
|
||||
package com.jsowell.pile.vo.lianlian;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
/**
|
||||
* 站点用电统计VO
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class StationElectStatsInfos {
|
||||
|
||||
/**
|
||||
* 站点ID
|
||||
*/
|
||||
private String stationId;
|
||||
|
||||
/**
|
||||
* 统计开始时间(格式:yyyy-MM-dd HH:mm:ss)
|
||||
*/
|
||||
private String startTime;
|
||||
|
||||
/**
|
||||
* 统计结束时间(格式:yyyy-MM-dd HH:mm:ss)
|
||||
*/
|
||||
private String endTime;
|
||||
|
||||
/**
|
||||
* 充电站累计电量(保留1位小数)
|
||||
* 示例:100.5(单位:kWh)
|
||||
*/
|
||||
private BigDecimal stationElectricity;
|
||||
|
||||
/**
|
||||
* 当前总输出电流(保留2位小数)
|
||||
* 示例:25.30(单位:A)
|
||||
*/
|
||||
private BigDecimal currentOutput;
|
||||
|
||||
/**
|
||||
* 当前总输出电压(保留2位小数)
|
||||
* 示例:380.00(单位:V)
|
||||
*/
|
||||
private BigDecimal voltageOutput;
|
||||
|
||||
/**
|
||||
* 当前总输出功率(保留1位小数)
|
||||
* 示例:95.5(单位:kW)
|
||||
*/
|
||||
private BigDecimal powerOutput;
|
||||
|
||||
/**
|
||||
* 当前总需求电流(保留2位小数)
|
||||
* 示例:30.00(单位:A)
|
||||
*/
|
||||
private BigDecimal currentNeed;
|
||||
|
||||
/**
|
||||
* 当前总需求电压(保留2位小数)
|
||||
* 示例:220.00(单位:V)
|
||||
*/
|
||||
private BigDecimal voltageNeed;
|
||||
|
||||
/**
|
||||
* 当前总需求功率(保留1位小数)
|
||||
* 示例:66.0(单位:kW)
|
||||
*/
|
||||
private BigDecimal powerNeed;
|
||||
|
||||
}
|
||||
@@ -55,6 +55,19 @@
|
||||
from order_detail
|
||||
where id = #{id,jdbcType=INTEGER}
|
||||
</select>
|
||||
<select id="selectByStationId" resultType="com.jsowell.pile.vo.lianlian.OrderTempVO">
|
||||
SELECT
|
||||
t1.order_code,
|
||||
t2.transaction_code,
|
||||
t1.total_used_electricity,
|
||||
DATE_FORMAT(t2.create_time, '%Y-%m-%d %H:%i:%s') AS create_time,
|
||||
DATE_FORMAT(t2.settlement_time, '%Y-%m-%d %H:%i:%s') AS settlement_time
|
||||
FROM order_detail t1
|
||||
JOIN order_basic_info t2
|
||||
ON t1.order_code = t2.order_code
|
||||
WHERE t2.station_id = #{stationId,jdbcType=INTEGER}
|
||||
AND t1.del_flag = '0';
|
||||
</select>
|
||||
<delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
|
||||
<!--@mbg.generated-->
|
||||
delete from order_detail
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.jsowell.thirdparty.common;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import com.jsowell.common.enums.thirdparty.ThirdPlatformTypeEnum;
|
||||
import com.jsowell.common.enums.ykc.ReturnCodeEnum;
|
||||
import com.jsowell.common.exception.BusinessException;
|
||||
import com.jsowell.common.util.StringUtils;
|
||||
@@ -168,8 +169,14 @@ public class NotificationService {
|
||||
ThirdPartyPlatformService platformService = ThirdPartyPlatformFactory.getInvokeStrategy(secretInfoVO.getPlatformType());
|
||||
//充电订单信息推送
|
||||
platformService.notificationChargeOrderInfo(orderCode, secretInfoVO);
|
||||
//订单信息推送
|
||||
platformService.notificationChargeOrderInfo(orderCode);
|
||||
// 测试联联之禾时发现会同时有两条notification_orderInfo请求发送,原因是异步走了lianLianService中的方法,因此请求一条出错,一条成功
|
||||
// 注释掉另一个异步方法中的判断联联的if判断,看看效果
|
||||
if(secretInfoVO.getPlatformType().equals(ThirdPlatformTypeEnum.LIAN_LIAN_PLATFORM.getTypeCode())){
|
||||
//订单信息推送
|
||||
platformService.notificationChargeOrderInfo(orderCode);
|
||||
//推送停止充电结果
|
||||
platformService.notificationStopChargeResult(orderCode);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
logger.error("充电订单信息推送error", e);
|
||||
}
|
||||
|
||||
@@ -454,6 +454,16 @@ public interface ThirdPartyPlatformService extends InitializingBean {
|
||||
throw new UnsupportedOperationException("This method is not yet implemented");
|
||||
}
|
||||
|
||||
/**
|
||||
* 5.10 推送站点累计电量接口( notification_station_electStatsInfo)
|
||||
* 对接平台定时将当天站点累计电量,实时电流,实时电压推送到市级平台,最低推送频率15分钟/次
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
default String notificationStationElectStatsInfo (String thirdpartyType) {
|
||||
throw new UnsupportedOperationException("This method is not yet implemented");
|
||||
}
|
||||
|
||||
|
||||
// -------------------------------------- 以下是公用方法 --------------------------------------- //
|
||||
/**
|
||||
|
||||
@@ -27,6 +27,8 @@ import com.jsowell.common.util.bean.BeanUtils;
|
||||
import com.jsowell.pile.domain.*;
|
||||
import com.jsowell.pile.domain.ykcCommond.StartChargingCommand;
|
||||
import com.jsowell.pile.dto.*;
|
||||
import com.jsowell.pile.mapper.OrderDetailMapper;
|
||||
import com.jsowell.pile.mapper.ThirdPartyStationRelationMapper;
|
||||
import com.jsowell.pile.service.*;
|
||||
import com.jsowell.pile.thirdparty.CommonParamsDTO;
|
||||
import com.jsowell.pile.thirdparty.EquipmentInfo;
|
||||
@@ -34,7 +36,9 @@ import com.jsowell.pile.util.MerchantUtils;
|
||||
import com.jsowell.pile.vo.ThirdPartySecretInfoVO;
|
||||
import com.jsowell.pile.vo.base.*;
|
||||
import com.jsowell.pile.vo.lianlian.AccumulativeInfoVO;
|
||||
import com.jsowell.pile.vo.lianlian.OrderTempVO;
|
||||
import com.jsowell.pile.vo.lianlian.PushStationFeeVO;
|
||||
import com.jsowell.pile.vo.lianlian.StationElectStatsInfos;
|
||||
import com.jsowell.pile.vo.uniapp.customer.BillingPriceVO;
|
||||
import com.jsowell.pile.vo.web.PileConnectorInfoVO;
|
||||
import com.jsowell.pile.vo.web.PileStationVO;
|
||||
@@ -105,6 +109,12 @@ public class LianLianPlatformServiceImpl implements ThirdPartyPlatformService {
|
||||
@Autowired
|
||||
private ThirdpartySecretInfoService thirdpartySecretInfoService;
|
||||
|
||||
@Autowired
|
||||
private ThirdPartyStationRelationMapper thirdPartyStationRelationMapper;
|
||||
|
||||
@Autowired
|
||||
private OrderDetailMapper orderDetailMapper;
|
||||
|
||||
@Override
|
||||
public void afterPropertiesSet() throws Exception {
|
||||
ThirdPartyPlatformFactory.register(thirdPlatformType, this);
|
||||
@@ -654,7 +664,7 @@ public class LianLianPlatformServiceImpl implements ThirdPartyPlatformService {
|
||||
* 设备状态变化推送 notification_stationStatus
|
||||
* 推送充电设备接口状态信息 supervise_notification_station_status
|
||||
*
|
||||
* @param dto 枪口状态
|
||||
* @param
|
||||
* @throws UnsupportedOperationException 未实现异常
|
||||
*/
|
||||
@Override
|
||||
@@ -1208,6 +1218,122 @@ public class LianLianPlatformServiceImpl implements ThirdPartyPlatformService {
|
||||
|
||||
//TODO 5.10 推送站点累计电量接口( notification_station_electStatsInfo)
|
||||
|
||||
/**
|
||||
* 5.10 推送站点累计电量接口( notification_station_electStatsInfo)
|
||||
* 对接平台定时将当天站点累计电量,实时电流,实时电压推送到市级平台,最低推送频率15分钟/次
|
||||
*
|
||||
* @param thirdPlatformType
|
||||
* @return
|
||||
*/
|
||||
public String notificationStationElectStatsInfo(String thirdPlatformType) {
|
||||
//获取第三方平台下的站点
|
||||
List<StationInfoVO> stationInfoVOS = thirdPartyStationRelationMapper.selectStationList(thirdPlatformType);
|
||||
|
||||
ThirdPartySecretInfoVO lianLianPlatformSecretInfo = getLianLianPlatformSecretInfo();
|
||||
String operatorId = lianLianPlatformSecretInfo.getOurOperatorId();
|
||||
String operatorSecret = lianLianPlatformSecretInfo.getTheirOperatorSecret();
|
||||
String signSecret = lianLianPlatformSecretInfo.getTheirSigSecret();
|
||||
String dataSecret = lianLianPlatformSecretInfo.getTheirDataSecret();
|
||||
String dataSecretIv = lianLianPlatformSecretInfo.getTheirDataSecretIv();
|
||||
String urlAddress = lianLianPlatformSecretInfo.getTheirUrlPrefix();
|
||||
|
||||
String url = urlAddress + "notification_station_electStatsInfo";
|
||||
|
||||
if (CollectionUtils.isEmpty(stationInfoVOS)){
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
|
||||
List<StationElectStatsInfos> chargeFeeDetailList = new ArrayList<>();
|
||||
|
||||
// 循环站点列表
|
||||
for (StationInfoVO stationInfoVO : stationInfoVOS) {
|
||||
StationElectStatsInfos chargeFeeDetail = new StationElectStatsInfos();
|
||||
|
||||
chargeFeeDetail.setStationId("LC"+stationInfoVO.getStationId());
|
||||
|
||||
//获取当前站点的充电订单列表
|
||||
List<OrderTempVO> tempVOS = orderDetailMapper.selectByStationId(stationInfoVO.getStationId());
|
||||
if (CollectionUtils.isEmpty(tempVOS)){
|
||||
return null;
|
||||
}
|
||||
|
||||
// 统计该站点累计电量 保留1位小数
|
||||
BigDecimal stationElectricity = tempVOS.stream()
|
||||
.map(OrderTempVO::getTotalUsedElectricity) // 电量
|
||||
.reduce(BigDecimal.ZERO , BigDecimal::add);// 累计电量
|
||||
|
||||
stationElectricity = stationElectricity.setScale(1, RoundingMode.HALF_UP);
|
||||
chargeFeeDetail.setStationElectricity(stationElectricity);
|
||||
|
||||
//开始时间
|
||||
//将订单列表按字符串时间排序
|
||||
List<OrderTempVO> sortedOrderList = tempVOS.stream()
|
||||
.sorted(Comparator.comparing(OrderTempVO::getCreateTime))
|
||||
.collect(Collectors.toList());
|
||||
//获取开始时间
|
||||
String startTime = sortedOrderList.get(0).getCreateTime();
|
||||
//获取结束时间
|
||||
String endTime = sortedOrderList.get(sortedOrderList.size() - 1).getCreateTime();
|
||||
chargeFeeDetail.setStartTime(startTime);
|
||||
chargeFeeDetail.setEndTime(endTime);
|
||||
|
||||
BigDecimal currentOutPut = BigDecimal.ZERO; //当前总输出电流 保2小数
|
||||
BigDecimal voltageOutPut = BigDecimal.ZERO; //当前总输出电压 保2小数
|
||||
BigDecimal powerOutPut = BigDecimal.ZERO; //当前总输出功率 保1小数
|
||||
BigDecimal currentNeed = BigDecimal.ZERO; //站点当前总需求电流 保2小数
|
||||
BigDecimal VoltageNeed = BigDecimal.ZERO; //站点当前总需求电压 保2小数
|
||||
BigDecimal PowerNeed = BigDecimal.ZERO; //站点当前总需求功率 保1小数
|
||||
|
||||
|
||||
|
||||
for (OrderTempVO tempVO : tempVOS) {
|
||||
//随便获取一个实时数据中的数据
|
||||
List<RealTimeMonitorData> chargingRealTimeDataList = orderBasicInfoService.getChargingRealTimeData(tempVO.getTransactionCode());
|
||||
if (CollectionUtils.isEmpty(chargingRealTimeDataList)) {
|
||||
// 没有查询到该订单的实时数据
|
||||
continue;
|
||||
}
|
||||
|
||||
RealTimeMonitorData realTimeMonitorData = chargingRealTimeDataList.stream()
|
||||
.filter(data -> data.getOutputCurrent() != null && data.getOutputVoltage() != null && data.getOutputPower() != null)
|
||||
.findFirst()
|
||||
.orElse(null); // 过滤出有输出电流、输出电压、输出功率的实时数据
|
||||
if (realTimeMonitorData == null) {
|
||||
// 跳过没有输出电流、输出电压、输出功率的实时数据
|
||||
continue;
|
||||
}
|
||||
powerOutPut = powerOutPut.add(new BigDecimal(realTimeMonitorData.getOutputPower()));
|
||||
currentOutPut = currentOutPut.add(new BigDecimal(realTimeMonitorData.getOutputCurrent()));
|
||||
voltageOutPut = voltageOutPut.add(new BigDecimal(realTimeMonitorData.getOutputVoltage()));
|
||||
}
|
||||
chargeFeeDetail.setCurrentOutput(currentOutPut.setScale(2, RoundingMode.HALF_UP));
|
||||
chargeFeeDetail.setVoltageOutput(voltageOutPut.setScale(2, RoundingMode.HALF_UP));
|
||||
chargeFeeDetail.setPowerOutput(powerOutPut.setScale(1, RoundingMode.HALF_UP));
|
||||
// 总需求电流,电压,功率,就同上
|
||||
chargeFeeDetail.setCurrentNeed(currentOutPut.setScale(2, RoundingMode.HALF_UP));
|
||||
chargeFeeDetail.setVoltageNeed(voltageOutPut.setScale(2, RoundingMode.HALF_UP));
|
||||
chargeFeeDetail.setPowerNeed(powerOutPut.setScale(1, RoundingMode.HALF_UP));
|
||||
|
||||
chargeFeeDetailList.add(chargeFeeDetail);
|
||||
|
||||
}
|
||||
|
||||
// 获取令牌
|
||||
String token = getToken(urlAddress, operatorId, operatorSecret, dataSecretIv, signSecret, dataSecret);
|
||||
if (StringUtils.isBlank(token)) {
|
||||
return null;
|
||||
}
|
||||
// 调用联联平台接口
|
||||
JSONObject json = new JSONObject();
|
||||
json.put("OperatorId", Constants.OPERATORID_LIANLIAN);
|
||||
json.put("StationElectStatsInfos", chargeFeeDetailList);
|
||||
String jsonString = JSON.toJSONString(json);
|
||||
log.info("notificationStationElectStatsInfo jsonString: " + jsonString);
|
||||
String result = HttpRequestUtil.sendPost(token, jsonString, url, dataSecret, dataSecretIv, operatorId, signSecret);
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 站点费率变化推送 notification_stationFee
|
||||
|
||||
Reference in New Issue
Block a user