Merge branch 'dev-new' into dev-new-rabbitmq

# Conflicts:
#	jsowell-admin/src/test/java/PaymentTestController.java
This commit is contained in:
Guoqs
2024-12-19 13:30:11 +08:00
64 changed files with 2858 additions and 767 deletions

View File

@@ -0,0 +1,39 @@
package com.jsowell.api.thirdparty;
import com.jsowell.common.annotation.Anonymous;
import com.jsowell.common.core.controller.BaseController;
import com.jsowell.common.response.RestApiResponse;
import com.jsowell.thirdparty.platform.service.impl.ChargeAlgorithmService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/**
* 算法应用Controller
*
* @author Lemon
* @Date 2024/12/17 15:20:36
*/
@Anonymous
@RestController
@RequestMapping("/chargealgorithm")
public class ChargeAlgorithmController extends BaseController {
@Autowired
private ChargeAlgorithmService chargeAlgorithmService;
@GetMapping("/pushOrderInfo/{orderCode}")
public RestApiResponse<?> pushOrderInfo(@PathVariable("orderCode") String orderCode) {
RestApiResponse<?> response = null;
try {
String result = chargeAlgorithmService.pushOrderInfo(orderCode);
response = new RestApiResponse<>(result);
}catch (Exception e) {
logger.error("算法应用推送订单信息 error, ", e);
response = new RestApiResponse<>(e);
}
return response;
}
}

View File

@@ -1,10 +1,11 @@
package com.jsowell.api.thirdparty;
import com.alibaba.fastjson2.JSON;
import com.jsowell.common.annotation.Anonymous;
import com.jsowell.common.core.domain.AjaxResult;
import com.jsowell.common.enums.thirdparty.ThirdPartyReturnCodeEnum;
import com.jsowell.common.exception.BusinessException;
import com.jsowell.common.response.RestApiResponse;
import com.jsowell.pile.dto.QueryOperatorInfoDTO;
import com.jsowell.pile.dto.QueryStationInfoDTO;
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 org.springframework.beans.factory.annotation.Autowired;
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 java.util.List;
import java.util.Map;
/**
@@ -33,6 +32,7 @@ public class GuiZhouPlatformController extends ThirdPartyBaseController {
@Qualifier("guiZhouPlatformServiceImpl")
private ThirdPartyPlatformService platformLogic;
/**
* getToken
*/
@@ -150,4 +150,63 @@ public class GuiZhouPlatformController extends ThirdPartyBaseController {
}
return CommonResult.failed("查询充电站状态信息发生异常");
}
}
/**
* 历史充电订单信息推送
*/
@GetMapping("/v1/notificationChargeOrderInfoHistory/{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/notificationOperationStatsInfo/{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/notificationPowerInfo/{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

@@ -11,14 +11,12 @@ import com.jsowell.common.exception.BusinessException;
import com.jsowell.common.response.RestApiResponse;
import com.jsowell.common.util.JWTUtils;
import com.jsowell.common.util.StringUtils;
import com.jsowell.pile.dto.PushInfoParamDTO;
import com.jsowell.pile.dto.PushRealTimeInfoDTO;
import com.jsowell.pile.dto.PushStationInfoDTO;
import com.jsowell.pile.dto.QueryStationInfoDTO;
import com.jsowell.pile.dto.*;
import com.jsowell.thirdparty.lianlian.common.CommonResult;
import com.jsowell.pile.thirdparty.CommonParamsDTO;
import com.jsowell.thirdparty.lianlian.service.LianLianService;
import com.jsowell.thirdparty.platform.service.ThirdPartyPlatformService;
import com.jsowell.thirdparty.platform.service.impl.ZhongDianLianPlatformServiceImpl;
import com.jsowell.thirdparty.platform.util.Cryptos;
import com.jsowell.thirdparty.platform.util.Encodes;
import com.jsowell.thirdparty.zhongdianlian.service.ZDLService;
@@ -383,4 +381,12 @@ public class ZDLController extends ThirdPartyBaseController {
logger.info("宁波平台推送订单信息 result:{}", response);
return response;
}
@PostMapping("/tempPushHistoryOrderInfo")
public RestApiResponse<?> tempPushHistoryOrderInfo(@RequestBody QueryOrderDTO dto) {
RestApiResponse<?> response = null;
String result = platformLogic.pushOrderInfo(dto);
response = new RestApiResponse<>(result);
return response;
}
}

View File

@@ -422,6 +422,7 @@ public class OrderService {
order.setStartTime(DateUtils.formatDateTime(orderBasicInfo.getChargeStartTime()));
order.setEndTime(DateUtils.formatDateTime(orderBasicInfo.getChargeEndTime()));
order.setCreateTime(DateUtils.formatDateTime(orderBasicInfo.getCreateTime()));
order.setStopReasonCode(orderBasicInfo.getStopReasonCode());
order.setStopReasonMsg(orderBasicInfo.getReason());
order.setStartSOC(orderBasicInfo.getStartSoc());
order.setEndSOC(orderBasicInfo.getEndSoc());
@@ -580,6 +581,7 @@ public class OrderService {
}
PileStationVO stationInfo = pileStationInfoService.getStationInfo(orderBasicInfo.getStationId());
vo.setStationName(stationInfo.getStationName());
vo.setStopReasonCode(orderBasicInfo.getStopReasonCode());
vo.setReason(orderBasicInfo.getReason());
vo.setOrderAmount(String.valueOf(orderBasicInfo.getOrderAmount()));
vo.setPayAmount(String.valueOf(orderBasicInfo.getPayAmount()));

View File

@@ -112,15 +112,17 @@ public class PileService {
public int batchCreatePile(BatchCreatePileDTO dto) {
String softwareProtocol = dto.getSoftwareProtocol();
if (StringUtils.isBlank(softwareProtocol)) {
throw new BusinessException(ReturnCodeEnum.valueOf("软件协议不能为空"));
}
// if (StringUtils.isBlank(softwareProtocol)) {
// throw new BusinessException(ReturnCodeEnum.valueOf("软件协议不能为空"));
// }
// 批量生成sn号
List<String> snList = null;
if (StringUtils.equals(SoftwareProtocolEnum.YOU_DIAN.getValue(), softwareProtocol)) {
snList = snUtils.generateEBikeSN(dto.getNum());
} else {
} else if (StringUtils.equals(SoftwareProtocolEnum.YUN_KUAI_CHONG.getValue(), softwareProtocol)){
snList = snUtils.generateEVPileSN(dto.getNum());
} else {
throw new BusinessException(ReturnCodeEnum.valueOf("软件协议不正确"));
}
//
@@ -488,42 +490,54 @@ public class PileService {
// 为空说明此用户未注册平台账号
throw new BusinessException(ReturnCodeEnum.CODE_USER_IS_NOT_REGISTER);
}
// 被分享的用户memberId
String memberId = memberBasicInfo.getMemberId();
List<PileMemberRelation> relationList = pileMemberRelationService.selectPileMemberRelationByPileSn(dto.getPileSn());
if (CollectionUtils.isEmpty(relationList)) {
// 充电桩没有绑定任何人
throw new BusinessException(ReturnCodeEnum.CODE_NO_ADMIN_FOR_PILE);
}
// 使用stream把relationList转为map, key为type, value为List<PileMemberRelation>
Map<String, List<PileMemberRelation>> map = relationList.stream().collect(Collectors.groupingBy(PileMemberRelation::getType));
List<PileMemberRelation> adminMemberRelationList = map.get(Constants.ONE); // 管理员列表
List<String> adminList = relationList.stream()
.filter(x -> x.getType().equals(Constants.ONE)) // 1-管理员用户
if (CollectionUtils.isEmpty(adminMemberRelationList)) {
// 充电桩没有管理员
throw new BusinessException(ReturnCodeEnum.CODE_NO_ADMIN_FOR_PILE);
}
List<String> adminList = adminMemberRelationList.stream()
.map(PileMemberRelation::getMemberId)
.collect(Collectors.toList());
if (CollectionUtils.isEmpty(adminList)) {
// 没有管理员
}
// 校验身份
if (adminList.contains(dto.getMemberId())) {
// 校验身份 入参是否是管理员
if (adminList.contains(memberId)) {
// 如果不为空,说明被分享的用户是管理员,抛出异常
throw new BusinessException(ReturnCodeEnum.CODE_AUTHENTICATION_ERROR);
throw new BusinessException(ReturnCodeEnum.CODE_ALREADY_AN_ADMIN);
}
List<String> userList = relationList.stream()
.filter(x -> !x.getType().equals(Constants.TWO)) // 2-普通用户
.map(PileMemberRelation::getMemberId)
.collect(Collectors.toList());
if (userList.contains(memberBasicInfo.getMemberId())) {
List<String> userList = Lists.newArrayList();
List<PileMemberRelation> userMemberRelations = map.get(Constants.TWO); // 普通用户列表
if (CollectionUtils.isNotEmpty(userMemberRelations)) {
userList = userMemberRelations.stream()
.map(PileMemberRelation::getMemberId)
.collect(Collectors.toList());
}
// 校验身份 入参是否是普通用户
if (userList.contains(memberId)) {
// 不为空说明已绑定
throw new BusinessException(ReturnCodeEnum.CODE_USER_HAS_BEEN_THIS_PILE);
} else {
// 进行绑定,此用户为普通用户
PileMemberRelation info = new PileMemberRelation();
info.setPileSn(dto.getPileSn());
info.setMemberId(memberBasicInfo.getMemberId());
info.setType(Constants.TWO);
pileMemberRelationService.insertPileMemberRelation(info);
throw new BusinessException(ReturnCodeEnum.CODE_ALREADY_AN_USER);
}
PileMemberRelation pileMemberRelation = adminMemberRelationList.get(0); // 获取管理员列表的第一个元素
// 进行绑定,此用户为普通用户
PileMemberRelation info = new PileMemberRelation();
info.setPileSn(dto.getPileSn());
info.setMemberId(memberId);
info.setType(Constants.TWO);
if (pileMemberRelation != null && StringUtils.isNotBlank(pileMemberRelation.getDeviceId())) {
info.setDeviceId(pileMemberRelation.getDeviceId());
info.setDeviceName(pileMemberRelation.getDeviceName());
}
pileMemberRelationService.insertPileMemberRelation(info);
}
/**
@@ -650,6 +664,7 @@ public class PileService {
}
vo.setMemberId(personalChargingRecord.getMemberId());
vo.setSumChargingDegree(personalChargingRecord.getTotalUsedElectricity().toString());
vo.setStopReasonCode(personalChargingRecord.getStopReasonCode());
vo.setStopReasonMsg(personalChargingRecord.getReason());
list.add(vo);
}