mirror of
https://codeup.aliyun.com/67c68d4e484ca2f0a13ac3c1/ydc/jsowell-charger-web.git
synced 2026-04-21 19:45:09 +08:00
新增 宁夏交投 相关service方法
This commit is contained in:
@@ -1,10 +1,60 @@
|
||||
package com.jsowell.thirdparty.ningxiajiaotou.service;
|
||||
|
||||
import com.jsowell.pile.dto.ningxiajiaotou.NXJTQueryOrdersInfoDTO;
|
||||
import com.jsowell.thirdparty.lianlian.dto.CommonParamsDTO;
|
||||
import com.jsowell.pile.dto.ningxiajiaotou.NXJTQueryStationInfoDTO;
|
||||
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* TODO
|
||||
*
|
||||
* @author Lemon
|
||||
* @Date 2023/11/12 9:33:03
|
||||
*/
|
||||
public class NXJTService {
|
||||
public interface NXJTService {
|
||||
|
||||
/**
|
||||
* 生成令牌
|
||||
* @param dto
|
||||
* @return
|
||||
* @throws UnsupportedEncodingException
|
||||
*/
|
||||
Map<String, String> generateToken(CommonParamsDTO dto) throws UnsupportedEncodingException;
|
||||
|
||||
|
||||
/**
|
||||
* 获取令牌
|
||||
* @param urlAddress
|
||||
* @param operatorId
|
||||
* @param operatorSecret
|
||||
* @return
|
||||
*/
|
||||
String getToken(String urlAddress, String operatorId, String operatorSecret,
|
||||
String dataSecretIv, String signSecret, String dataSecret);
|
||||
|
||||
|
||||
/**
|
||||
* 获取充电站信息
|
||||
* @param dto
|
||||
* @return
|
||||
*/
|
||||
Map<String, String> queryStationsInfo(NXJTQueryStationInfoDTO dto);
|
||||
|
||||
|
||||
/**
|
||||
* 查询充电站中空闲桩数量
|
||||
* @param dto
|
||||
* @return
|
||||
*/
|
||||
Map<String, String> queryFreePileNumber(NXJTQueryStationInfoDTO dto);
|
||||
|
||||
|
||||
/**
|
||||
* 查询订单信息
|
||||
* @param dto
|
||||
* @return
|
||||
*/
|
||||
Map<String, String> queryOrdersInfo(NXJTQueryOrdersInfoDTO dto);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,214 @@
|
||||
package com.jsowell.thirdparty.ningxiajiaotou.service.impl;
|
||||
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import com.google.common.collect.Maps;
|
||||
import com.jsowell.common.enums.ykc.PileStatusEnum;
|
||||
import com.jsowell.common.util.PageUtils;
|
||||
import com.jsowell.common.util.StringUtils;
|
||||
import com.jsowell.pile.domain.PileBasicInfo;
|
||||
import com.jsowell.pile.domain.PileStationInfo;
|
||||
import com.jsowell.pile.domain.ThirdPartyPlatformConfig;
|
||||
import com.jsowell.pile.dto.ningxiajiaotou.NXJTQueryOrdersInfoDTO;
|
||||
import com.jsowell.pile.service.*;
|
||||
import com.jsowell.pile.vo.base.ConnectorInfoVO;
|
||||
import com.jsowell.pile.vo.uniapp.OrderVO;
|
||||
import com.jsowell.thirdparty.lianlian.domain.StationInfo;
|
||||
import com.jsowell.thirdparty.lianlian.dto.CommonParamsDTO;
|
||||
import com.jsowell.thirdparty.lianlian.service.LianLianService;
|
||||
import com.jsowell.thirdparty.lianlian.util.Cryptos;
|
||||
import com.jsowell.thirdparty.lianlian.util.Encodes;
|
||||
import com.jsowell.thirdparty.lianlian.util.GBSignUtils;
|
||||
import com.jsowell.thirdparty.ningxiajiaotou.service.NXJTService;
|
||||
import com.jsowell.pile.dto.ningxiajiaotou.NXJTQueryStationInfoDTO;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 宁夏交投Service
|
||||
*
|
||||
* @author Lemon
|
||||
* @Date 2023/11/13 8:58:06
|
||||
*/
|
||||
@Service
|
||||
public class NXJTServiceImpl implements NXJTService {
|
||||
|
||||
@Autowired
|
||||
private LianLianService lianLianService;
|
||||
|
||||
@Autowired
|
||||
private IPileStationInfoService pileStationInfoService;
|
||||
|
||||
@Autowired
|
||||
private IThirdPartyPlatformConfigService thirdPartyPlatformConfigService;
|
||||
|
||||
@Autowired
|
||||
private IPileBasicInfoService pileBasicInfoService;
|
||||
|
||||
@Autowired
|
||||
private IPileConnectorInfoService pileConnectorInfoService;
|
||||
|
||||
@Autowired
|
||||
private IOrderBasicInfoService orderBasicInfoService;
|
||||
|
||||
/**
|
||||
* 生成令牌
|
||||
* @param dto
|
||||
* @return
|
||||
* @throws UnsupportedEncodingException
|
||||
*/
|
||||
@Override
|
||||
public Map<String, String> generateToken(CommonParamsDTO dto) throws UnsupportedEncodingException {
|
||||
return lianLianService.generateToken(dto);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取令牌
|
||||
* @param urlAddress
|
||||
* @param operatorId
|
||||
* @param operatorSecret
|
||||
* @param dataSecretIv
|
||||
* @param signSecret
|
||||
* @param dataSecret
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public String getToken(String urlAddress, String operatorId, String operatorSecret, String dataSecretIv, String signSecret, String dataSecret) {
|
||||
return lianLianService.getToken(urlAddress, operatorId, operatorSecret, dataSecretIv, signSecret, dataSecret);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询站点信息
|
||||
* @param dto
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public Map<String, String> queryStationsInfo(NXJTQueryStationInfoDTO dto) {
|
||||
int pageNo = dto.getPageNo() == null ? 1 : dto.getPageNo();
|
||||
int pageSize = dto.getPageSize() == null ? 10 : dto.getPageSize();
|
||||
|
||||
ThirdPartyPlatformConfig configInfo = thirdPartyPlatformConfigService.getInfoByOperatorId(dto.getOperatorId());
|
||||
if (configInfo == null) {
|
||||
return null;
|
||||
}
|
||||
// 分页
|
||||
PageUtils.startPage(pageNo, pageSize);
|
||||
List<PileStationInfo> stationInfos = pileStationInfoService.NXJTQueryStationsInfo(dto);
|
||||
PageInfo<PileStationInfo> pageInfo = new PageInfo<>(stationInfos);
|
||||
|
||||
Map<String, Object> map = new LinkedHashMap<>();
|
||||
map.put("pageNo", pageInfo.getPageNum());
|
||||
map.put("pageCount", pageInfo.getPages());
|
||||
map.put("itemSize", pageInfo.getList().size());
|
||||
map.put("stationInfos", pageInfo.getList());
|
||||
|
||||
// 加密
|
||||
Map<String, String> resultMap = Maps.newLinkedHashMap();
|
||||
// 加密数据
|
||||
byte[] encryptText = Cryptos.aesEncrypt(JSONObject.toJSONString(map).getBytes(),
|
||||
configInfo.getDataSecret().getBytes(), configInfo.getDataSecretIv().getBytes());
|
||||
String encryptData = Encodes.encodeBase64(encryptText);
|
||||
|
||||
resultMap.put("Data", encryptData);
|
||||
// 生成sig
|
||||
String resultSign = GBSignUtils.sign(resultMap, configInfo.getSignSecret());
|
||||
resultMap.put("Sig", resultSign);
|
||||
|
||||
return resultMap;
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询充电站中空闲桩数量
|
||||
* @param dto
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public Map<String, String> queryFreePileNumber(NXJTQueryStationInfoDTO dto) {
|
||||
ThirdPartyPlatformConfig configInfo = thirdPartyPlatformConfigService.getInfoByOperatorId(dto.getOperatorId());
|
||||
if (configInfo == null) {
|
||||
return null;
|
||||
}
|
||||
long stationId = Long.parseLong(dto.getStationId());
|
||||
List<ConnectorInfoVO> connectorList = pileConnectorInfoService.getUniAppConnectorList(stationId);
|
||||
// 先根据pileSn分组,获取设备总数
|
||||
List<String> pileSnList = connectorList.stream()
|
||||
.map(ConnectorInfoVO::getPileSn)
|
||||
.collect(Collectors.toList());
|
||||
// 根据枪口编号批量查询枪口状态
|
||||
Map<String, Integer> pileTypeNum = pileConnectorInfoService.getPileTypeNum(stationId);
|
||||
// Integer fastTotal = pileTypeNum.get("fastTotal");// 快充总数
|
||||
Integer fastFree = pileTypeNum.get("fastFree"); // 快充空闲
|
||||
// Integer slowTotal = pileTypeNum.get("slowTotal");// 慢充总数
|
||||
Integer slowFree = pileTypeNum.get("slowFree");// 慢充空闲
|
||||
|
||||
int freePileNumber = fastFree + slowFree; // 总空闲数量 = 快充空闲 + 慢充空闲
|
||||
int pileNumber = pileSnList.size(); // 总设备数 就是桩号集合的长度
|
||||
|
||||
// 拼装参数
|
||||
Map<String, Object> map = new LinkedHashMap<>();
|
||||
map.put("pileNum", pileNumber);
|
||||
map.put("freePileNum", freePileNumber);
|
||||
|
||||
// 加密
|
||||
Map<String, String> resultMap = Maps.newLinkedHashMap();
|
||||
// 加密数据
|
||||
byte[] encryptText = Cryptos.aesEncrypt(JSONObject.toJSONString(map).getBytes(),
|
||||
configInfo.getDataSecret().getBytes(), configInfo.getDataSecretIv().getBytes());
|
||||
String encryptData = Encodes.encodeBase64(encryptText);
|
||||
|
||||
resultMap.put("Data", encryptData);
|
||||
// 生成sig
|
||||
String resultSign = GBSignUtils.sign(resultMap, configInfo.getSignSecret());
|
||||
resultMap.put("Sig", resultSign);
|
||||
|
||||
return resultMap;
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询订单信息
|
||||
* @param dto
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public Map<String, String> queryOrdersInfo(NXJTQueryOrdersInfoDTO dto) {
|
||||
int pageNo = dto.getPageNo() == null ? 1 : dto.getPageNo();
|
||||
int pageSize = dto.getPageSize() == null ? 10 : dto.getPageSize();
|
||||
|
||||
ThirdPartyPlatformConfig configInfo = thirdPartyPlatformConfigService.getInfoByOperatorId(dto.getOperatorId());
|
||||
if (configInfo == null) {
|
||||
return null;
|
||||
}
|
||||
// 分页
|
||||
PageUtils.startPage(pageNo, pageSize);
|
||||
// 根据车牌号查询消费情况
|
||||
List<OrderVO> orderVOList = orderBasicInfoService.getOrderInfoByLicensePlateNumber(dto.getLicensePlateNumber());
|
||||
PageInfo<OrderVO> pageInfo = new PageInfo<>(orderVOList);
|
||||
|
||||
Map<String, Object> map = new LinkedHashMap<>();
|
||||
map.put("pageNo", pageInfo.getPageNum());
|
||||
map.put("pageCount", pageInfo.getPages());
|
||||
map.put("itemSize", pageInfo.getList().size());
|
||||
map.put("orderInfos", pageInfo.getList());
|
||||
|
||||
// 加密
|
||||
Map<String, String> resultMap = Maps.newLinkedHashMap();
|
||||
// 加密数据
|
||||
byte[] encryptText = Cryptos.aesEncrypt(JSONObject.toJSONString(map).getBytes(),
|
||||
configInfo.getDataSecret().getBytes(), configInfo.getDataSecretIv().getBytes());
|
||||
String encryptData = Encodes.encodeBase64(encryptText);
|
||||
|
||||
resultMap.put("Data", encryptData);
|
||||
// 生成sig
|
||||
String resultSign = GBSignUtils.sign(resultMap, configInfo.getSignSecret());
|
||||
resultMap.put("Sig", resultSign);
|
||||
|
||||
return resultMap;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user