新增 宁夏交投Controller

This commit is contained in:
Lemon
2023-11-15 10:08:30 +08:00
parent d58a8c8c7f
commit 501e1b6348
7 changed files with 264 additions and 7 deletions

View File

@@ -0,0 +1,230 @@
package com.jsowell.thirdparty.ningxiajiaotou;
import com.alibaba.fastjson2.JSONObject;
import com.jsowell.common.annotation.Anonymous;
import com.jsowell.common.core.controller.BaseController;
import com.jsowell.common.util.JWTUtils;
import com.jsowell.pile.dto.QueryStationInfoDTO;
import com.jsowell.pile.dto.ningxiajiaotou.NXJTQueryOrdersInfoDTO;
import com.jsowell.pile.dto.ningxiajiaotou.NXJTQueryStationInfoDTO;
import com.jsowell.thirdparty.lianlian.common.CommonResult;
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.ningxiajiaotou.service.NXJTService;
import org.springframework.beans.factory.annotation.Autowired;
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 javax.servlet.http.HttpServletRequest;
import java.io.UnsupportedEncodingException;
import java.nio.charset.StandardCharsets;
import java.util.Map;
/**
* 宁夏交投 Controller
*
* @author Lemon
* @Date 2023/11/15 8:36:42
*/
@Anonymous
@RestController
@RequestMapping("/nxjt")
public class NXJTController extends BaseController {
@Autowired
private NXJTService nxjtService;
@Autowired
private LianLianService lianLianService;
/**
* 获取token接口
* http://localhost:8080/nxjt/v1/query_token
*/
@PostMapping("/v1/query_token")
public CommonResult<?> queryToken(@RequestBody CommonParamsDTO dto) {
logger.info("宁夏交投平台请求令牌 params:{}", JSONObject.toJSONString(dto));
try {
Map<String, String> map = nxjtService.generateToken(dto);
logger.info("宁夏交投平台请求令牌 result:{}", JSONObject.toJSONString(map));
return CommonResult.success(0, "请求令牌成功!", map.get("Data"), map.get("Sig"));
} catch (UnsupportedEncodingException e) {
logger.error("获取token接口 异常");
return CommonResult.failed("获取token发生异常");
}
}
/**
* 宁夏交投平台查询充电站信息
* http://localhost:8080/nxjt/v1/query_stations_info
* @param dto
* @return
*/
@PostMapping("/v1/query_stations_info")
public CommonResult<?> queryStationsInfo(HttpServletRequest request, @RequestBody CommonParamsDTO dto) {
logger.info("宁夏交投平台查询充电站信息 params:{}", JSONObject.toJSONString(dto));
try {
// 校验令牌
String token = request.getHeader("Authorization");
if (!JWTUtils.checkThirdPartyToken(token)) {
// 校验失败
return CommonResult.failed("令牌校验错误");
}
// 校验签名
Map<String, String> resultMap = lianLianService.checkoutSign(dto);
if (resultMap == null) {
// 签名错误
return CommonResult.failed("签名校验错误");
}
String operatorSecret = resultMap.get("OperatorSecret");
String dataString = resultMap.get("Data");
String dataSecret = resultMap.get("DataSecret");
String dataSecretIV = resultMap.get("DataSecretIV");
// 解密data
byte[] plainText = Cryptos.aesDecrypt(Encodes.decodeBase64(dataString), dataSecret.getBytes(), dataSecretIV.getBytes());
String dataStr = new String(plainText, StandardCharsets.UTF_8);
// 转换成相应对象
NXJTQueryStationInfoDTO nxjtQueryStationInfoDTO = JSONObject.parseObject(dataStr, NXJTQueryStationInfoDTO.class);
nxjtQueryStationInfoDTO.setOperatorId(dto.getOperatorID());
Map<String, String> map = nxjtService.queryStationsInfo(nxjtQueryStationInfoDTO);
// return CommonResult.success(map);
return CommonResult.success(0, "查询充电站信息成功!", map.get("Data"), map.get("Sig"));
} catch (Exception e) {
logger.info("宁夏交投平台查询充电站信息 error:", e);
e.printStackTrace();
}
return CommonResult.failed("查询充电站信息发生异常");
}
/**
* 宁夏交投平台查询充电站中空闲桩数量
* http://localhost:8080/nxjt/v1/query_free_pile_number
* @param dto
* @return
*/
@PostMapping("/v1/query_free_pile_number")
public CommonResult<?> queryFreePileNumber(HttpServletRequest request, @RequestBody CommonParamsDTO dto) {
logger.info("宁夏交投平台查询充电站中空闲桩数量 params:{}", JSONObject.toJSONString(dto));
try {
// 校验令牌
String token = request.getHeader("Authorization");
if (!JWTUtils.checkThirdPartyToken(token)) {
// 校验失败
return CommonResult.failed("令牌校验错误");
}
// 校验签名
Map<String, String> resultMap = lianLianService.checkoutSign(dto);
if (resultMap == null) {
// 签名错误
return CommonResult.failed("签名校验错误");
}
String operatorSecret = resultMap.get("OperatorSecret");
String dataString = resultMap.get("Data");
String dataSecret = resultMap.get("DataSecret");
String dataSecretIV = resultMap.get("DataSecretIV");
// 解密data
byte[] plainText = Cryptos.aesDecrypt(Encodes.decodeBase64(dataString), dataSecret.getBytes(), dataSecretIV.getBytes());
String dataStr = new String(plainText, StandardCharsets.UTF_8);
// 转换成相应对象
NXJTQueryStationInfoDTO nxjtQueryStationInfoDTO = JSONObject.parseObject(dataStr, NXJTQueryStationInfoDTO.class);
nxjtQueryStationInfoDTO.setOperatorId(dto.getOperatorID());
Map<String, String> map = nxjtService.queryFreePileNumber(nxjtQueryStationInfoDTO);
// return CommonResult.success(map);
return CommonResult.success(0, "查询充电站中空闲桩数量信息成功!", map.get("Data"), map.get("Sig"));
} catch (Exception e) {
logger.info("宁夏交投平台查询充电站中空闲桩数量 error:", e);
e.printStackTrace();
}
return CommonResult.failed("查询充电站中空闲桩数量信息发生异常");
}
/**
* 宁夏交投平台查询某车牌号消费记录
* http://localhost:8080/nxjt/v1/query_free_pile_number
* @param dto
* @return
*/
@PostMapping("/v1/query_orders_info_by_Plate_number")
public CommonResult<?> queryOrdersInfoByPlateNumber(HttpServletRequest request, @RequestBody CommonParamsDTO dto) {
logger.info("宁夏交投平台查询某车牌号消费记录 params:{}", JSONObject.toJSONString(dto));
try {
// 校验令牌
String token = request.getHeader("Authorization");
if (!JWTUtils.checkThirdPartyToken(token)) {
// 校验失败
return CommonResult.failed("令牌校验错误");
}
// 校验签名
Map<String, String> resultMap = lianLianService.checkoutSign(dto);
if (resultMap == null) {
// 签名错误
return CommonResult.failed("签名校验错误");
}
String operatorSecret = resultMap.get("OperatorSecret");
String dataString = resultMap.get("Data");
String dataSecret = resultMap.get("DataSecret");
String dataSecretIV = resultMap.get("DataSecretIV");
// 解密data
byte[] plainText = Cryptos.aesDecrypt(Encodes.decodeBase64(dataString), dataSecret.getBytes(), dataSecretIV.getBytes());
String dataStr = new String(plainText, StandardCharsets.UTF_8);
// 转换成相应对象
NXJTQueryOrdersInfoDTO nxjtQueryOrdersInfoDTO = JSONObject.parseObject(dataStr, NXJTQueryOrdersInfoDTO.class);
nxjtQueryOrdersInfoDTO.setOperatorId(dto.getOperatorID());
Map<String, String> map = nxjtService.queryOrdersInfoByPlateNumber(nxjtQueryOrdersInfoDTO);
// return CommonResult.success(map);
return CommonResult.success(0, "查询充电站中空闲桩数量信息成功!", map.get("Data"), map.get("Sig"));
} catch (Exception e) {
logger.info("宁夏交投平台查询某车牌号消费记录 error:", e);
e.printStackTrace();
}
return CommonResult.failed("查询某车牌号消费记录发生异常");
}
/**
* 宁夏交投平台查询某段时间内消费记录
* http://localhost:8080/nxjt/v1/query_orders_info
* @param dto
* @return
*/
@PostMapping("/v1/query_orders_info")
public CommonResult<?> queryOrdersInfo(HttpServletRequest request, @RequestBody CommonParamsDTO dto) {
logger.info("宁夏交投平台查询某段时间内消费记录 params:{}", JSONObject.toJSONString(dto));
try {
// 校验令牌
String token = request.getHeader("Authorization");
if (!JWTUtils.checkThirdPartyToken(token)) {
// 校验失败
return CommonResult.failed("令牌校验错误");
}
// 校验签名
Map<String, String> resultMap = lianLianService.checkoutSign(dto);
if (resultMap == null) {
// 签名错误
return CommonResult.failed("签名校验错误");
}
String operatorSecret = resultMap.get("OperatorSecret");
String dataString = resultMap.get("Data");
String dataSecret = resultMap.get("DataSecret");
String dataSecretIV = resultMap.get("DataSecretIV");
// 解密data
byte[] plainText = Cryptos.aesDecrypt(Encodes.decodeBase64(dataString), dataSecret.getBytes(), dataSecretIV.getBytes());
String dataStr = new String(plainText, StandardCharsets.UTF_8);
// 转换成相应对象
NXJTQueryOrdersInfoDTO nxjtQueryOrdersInfoDTO = JSONObject.parseObject(dataStr, NXJTQueryOrdersInfoDTO.class);
nxjtQueryOrdersInfoDTO.setOperatorId(dto.getOperatorID());
Map<String, String> map = nxjtService.queryOrdersInfo(nxjtQueryOrdersInfoDTO);
// return CommonResult.success(map);
return CommonResult.success(0, "查询充电站中空闲桩数量信息成功!", map.get("Data"), map.get("Sig"));
} catch (Exception e) {
logger.info("宁夏交投平台查询某段时间内消费记录 error:", e);
e.printStackTrace();
}
return CommonResult.failed("查询某段时间内消费记录发生异常");
}
}

View File

@@ -5,6 +5,7 @@ import com.jsowell.pile.dto.QueryStationDTO;
import com.jsowell.pile.dto.QueryStationInfoDTO;
import com.jsowell.pile.dto.ningxiajiaotou.NXJTQueryStationInfoDTO;
import com.jsowell.pile.vo.base.ThirdPartyStationInfoVO;
import com.jsowell.pile.vo.ningxiajiaotou.NXJTStationInfoVO;
import com.jsowell.pile.vo.web.PileStationVO;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;
@@ -113,5 +114,5 @@ public interface PileStationInfoMapper {
* @param dto
* @return
*/
List<PileStationInfo> NXJTQueryStationsInfo(NXJTQueryStationInfoDTO dto);
List<NXJTStationInfoVO> NXJTQueryStationsInfo(NXJTQueryStationInfoDTO dto);
}

View File

@@ -8,6 +8,7 @@ import com.jsowell.pile.dto.QueryStationInfoDTO;
import com.jsowell.pile.dto.lutongyunting.BindParkingPlatformDTO;
import com.jsowell.pile.dto.ningxiajiaotou.NXJTQueryStationInfoDTO;
import com.jsowell.pile.vo.base.ThirdPartyStationInfoVO;
import com.jsowell.pile.vo.ningxiajiaotou.NXJTStationInfoVO;
import com.jsowell.pile.vo.web.PileStationVO;
import java.util.List;
@@ -129,5 +130,5 @@ public interface IPileStationInfoService {
* @param dto
* @return
*/
List<PileStationInfo> NXJTQueryStationsInfo(NXJTQueryStationInfoDTO dto);
List<NXJTStationInfoVO> NXJTQueryStationsInfo(NXJTQueryStationInfoDTO dto);
}

View File

@@ -31,6 +31,7 @@ import com.jsowell.pile.vo.base.MerchantInfoVO;
import com.jsowell.pile.vo.base.PileInfoVO;
import com.jsowell.pile.vo.base.StationInfoVO;
import com.jsowell.pile.vo.base.ThirdPartyStationInfoVO;
import com.jsowell.pile.vo.ningxiajiaotou.NXJTStationInfoVO;
import com.jsowell.pile.vo.uniapp.CurrentTimePriceDetails;
import com.jsowell.pile.vo.web.PileStationVO;
import com.jsowell.system.service.SysDeptService;
@@ -580,7 +581,7 @@ public class PileStationInfoServiceImpl implements IPileStationInfoService {
* @return
*/
@Override
public List<PileStationInfo> NXJTQueryStationsInfo(NXJTQueryStationInfoDTO dto) {
public List<NXJTStationInfoVO> NXJTQueryStationsInfo(NXJTQueryStationInfoDTO dto) {
return pileStationInfoMapper.NXJTQueryStationsInfo(dto);
}
}

View File

@@ -0,0 +1,22 @@
package com.jsowell.pile.vo.ningxiajiaotou;
import lombok.Data;
/**
* 宁夏交投站点信息VO
*
* @author Lemon
* @Date 2023/11/15 9:21:28
*/
@Data
public class NXJTStationInfoVO {
private String stationId;
private String stationName;
private String address;
private String stationLng;
private String stationLat;
private String supportOrder;
}

View File

@@ -537,7 +537,7 @@
and amap_flag = '1'
</select>
<select id="NXJTQueryStationsInfo" resultMap="PileStationInfoResult">
<select id="NXJTQueryStationsInfo" resultType="com.jsowell.pile.vo.ningxiajiaotou.NXJTStationInfoVO">
SELECT
id AS stationId,
station_name AS stationName,

View File

@@ -10,6 +10,7 @@ import com.jsowell.pile.dto.ningxiajiaotou.NXJTQueryOrdersInfoDTO;
import com.jsowell.pile.service.*;
import com.jsowell.pile.vo.base.ConnectorInfoVO;
import com.jsowell.pile.vo.ningxiajiaotou.NXJTOrderVO;
import com.jsowell.pile.vo.ningxiajiaotou.NXJTStationInfoVO;
import com.jsowell.pile.vo.uniapp.OrderVO;
import com.jsowell.thirdparty.lianlian.dto.CommonParamsDTO;
import com.jsowell.thirdparty.lianlian.service.LianLianService;
@@ -97,8 +98,8 @@ public class NXJTServiceImpl implements NXJTService {
}
// 分页
PageUtils.startPage(pageNo, pageSize);
List<PileStationInfo> stationInfos = pileStationInfoService.NXJTQueryStationsInfo(dto);
PageInfo<PileStationInfo> pageInfo = new PageInfo<>(stationInfos);
List<NXJTStationInfoVO> stationInfos = pileStationInfoService.NXJTQueryStationsInfo(dto);
PageInfo<NXJTStationInfoVO> pageInfo = new PageInfo<>(stationInfos);
Map<String, Object> map = new LinkedHashMap<>();
map.put("pageNo", pageInfo.getPageNum());
@@ -195,7 +196,7 @@ public class NXJTServiceImpl implements NXJTService {
vo = new NXJTOrderVO();
vo.setLicensePlateNumber(orderVO.getLicensePlateNumber());
vo.setOrderAmount(orderVO.getOrderAmount());
vo.setChargeTime(orderVO.getChargingTime());
vo.setChargeTime(orderVO.getStartTime());
vo.setStationName(orderVO.getStationName());
vo.setLicensePlateNumberColor(1);
@@ -232,5 +233,6 @@ public class NXJTServiceImpl implements NXJTService {
// 由于调用的查询方法、拼装的参数均相同,因此直接调用上面方法
// 两个方法仅入参不同
return queryOrdersInfoByPlateNumber(dto);
// return null;
}
}