mirror of
https://codeup.aliyun.com/67c68d4e484ca2f0a13ac3c1/ydc/jsowell-charger-web.git
synced 2026-04-20 11:05:18 +08:00
update 江苏省平台接口
This commit is contained in:
@@ -4,27 +4,28 @@ import com.alibaba.fastjson2.JSON;
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import com.jsowell.common.annotation.Anonymous;
|
||||
import com.jsowell.common.core.controller.BaseController;
|
||||
import com.jsowell.common.core.domain.ykc.RealTimeMonitorData;
|
||||
import com.jsowell.common.enums.ykc.ReturnCodeEnum;
|
||||
import com.jsowell.common.exception.BusinessException;
|
||||
import com.jsowell.common.response.RestApiResponse;
|
||||
import com.jsowell.common.util.JWTUtils;
|
||||
import com.jsowell.pile.domain.nanrui.NROrderInfo;
|
||||
import com.jsowell.pile.dto.QueryStartChargeDTO;
|
||||
import com.jsowell.common.util.StringUtils;
|
||||
import com.jsowell.pile.dto.PushStationInfoDTO;
|
||||
import com.jsowell.pile.dto.QueryStationInfoDTO;
|
||||
import com.jsowell.pile.dto.nanrui.GetTokenDTO;
|
||||
import com.jsowell.pile.dto.nanrui.NRQueryOrderDTO;
|
||||
import com.jsowell.pile.dto.nanrui.PushAlarmInfoDTO;
|
||||
import com.jsowell.thirdparty.lianlian.common.CommonResult;
|
||||
import com.jsowell.thirdparty.lianlian.dto.CommonParamsDTO;
|
||||
import com.jsowell.thirdparty.lianlian.util.Cryptos;
|
||||
import com.jsowell.thirdparty.lianlian.util.Encodes;
|
||||
import com.jsowell.thirdparty.nanrui.service.NRService;
|
||||
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 org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
@@ -35,7 +36,7 @@ import java.util.Map;
|
||||
*/
|
||||
@Anonymous
|
||||
@RestController
|
||||
@RequestMapping("/nanrui")
|
||||
@RequestMapping("/jiangsu")
|
||||
public class NRController extends BaseController {
|
||||
|
||||
@Autowired
|
||||
@@ -69,7 +70,7 @@ public class NRController extends BaseController {
|
||||
// 转换成相应对象
|
||||
QueryStationInfoDTO queryStationInfoDTO = JSONObject.parseObject(dataStr, QueryStationInfoDTO.class);
|
||||
Map<String, String> map = nrService.query_stations_info(queryStationInfoDTO);
|
||||
return CommonResult.success(0, "请求停止充电成功!", map.get("Data"), map.get("Sig"));
|
||||
return CommonResult.success(0, "查询充电站信息成功!", map.get("Data"), map.get("Sig"));
|
||||
} catch (Exception e) {
|
||||
logger.error("南瑞平台查询充电站信息 error", e);
|
||||
}
|
||||
@@ -148,7 +149,7 @@ public class NRController extends BaseController {
|
||||
} catch (Exception e) {
|
||||
logger.error("南瑞平台查询充电电量信息 error", e);
|
||||
}
|
||||
return CommonResult.failed("查询设备接口状态异常");
|
||||
return CommonResult.failed("查询充电电量信息异常");
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -167,4 +168,113 @@ public class NRController extends BaseController {
|
||||
return CommonResult.failed("获取token发生异常");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@RequestMapping("/v1/getToken")
|
||||
public String getToken(@RequestBody GetTokenDTO dto) {
|
||||
String token = nrService.getToken(dto.getUrlAddress(), dto.getOperatorId(), dto.getOperatorSecret(),
|
||||
dto.getDataSecretIv(), dto.getSignSecret(), dto.getDataSecret());
|
||||
return token;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 推送充电站信息
|
||||
* @param dto
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/v1/pushStationInfo")
|
||||
public RestApiResponse<?> pushStationInfo(@RequestBody PushStationInfoDTO dto) {
|
||||
logger.info("推送南瑞平台充电站信息 params:{}", JSONObject.toJSONString(dto));
|
||||
RestApiResponse<?> response = null;
|
||||
try {
|
||||
if (StringUtils.isBlank(String.valueOf(dto.getStationId()))) {
|
||||
throw new BusinessException(ReturnCodeEnum.CODE_PARAM_NOT_NULL_ERROR);
|
||||
}
|
||||
String s = nrService.pushStationInfo(dto);
|
||||
response = new RestApiResponse<>(s);
|
||||
}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;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 推送告警信息
|
||||
* @param dto
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/v1/pushAlarmInfo")
|
||||
public RestApiResponse<?> pushAlarmInfo(@RequestBody PushAlarmInfoDTO dto) {
|
||||
logger.info("推送南瑞平台告警信息 params:{}", JSONObject.toJSONString(dto));
|
||||
RestApiResponse<?> response = null;
|
||||
try {
|
||||
if (StringUtils.isBlank(String.valueOf(dto.getStationId()))) {
|
||||
throw new BusinessException(ReturnCodeEnum.CODE_PARAM_NOT_NULL_ERROR);
|
||||
}
|
||||
String s = nrService.pushAlarmInfo(dto);
|
||||
response = new RestApiResponse<>(s);
|
||||
}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;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设备状态变化推送
|
||||
* @param data
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/v1/pushPileStatus")
|
||||
public RestApiResponse<?> pushPileStatus(@RequestBody RealTimeMonitorData data) {
|
||||
logger.info("推送南瑞平台设备状态变化推送 params:{}", JSONObject.toJSONString(data));
|
||||
RestApiResponse<?> response = null;
|
||||
try {
|
||||
String s = nrService.pushPileStatus(data);
|
||||
response = new RestApiResponse<>(s);
|
||||
}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;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 充电电量信息推送
|
||||
* @param orderCode
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/v1/pushOrderInfo/{orderCode}")
|
||||
public RestApiResponse<?> pushOrderInfo(@PathVariable("orderCode") String orderCode) {
|
||||
logger.info("南瑞平台充电电量信息推送 params:{}", orderCode);
|
||||
RestApiResponse<?> response = null;
|
||||
try {
|
||||
String s = nrService.pushOrderInfo(orderCode);
|
||||
response = new RestApiResponse<>(s);
|
||||
}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;
|
||||
}
|
||||
}
|
||||
@@ -2336,7 +2336,7 @@ public class SpringBootTestController {
|
||||
String str = "JS160829";
|
||||
System.out.println(Md5Utils.hash(str).toUpperCase(Locale.ROOT));
|
||||
*/
|
||||
String s = RandomStringUtils.randomAlphanumeric(43).toUpperCase(Locale.ROOT);
|
||||
String s = RandomStringUtils.randomAlphanumeric(16).toUpperCase(Locale.ROOT);
|
||||
System.out.println(s);
|
||||
|
||||
Date startTimeDate = sdf.parse("2022-11-26 10:44:11");
|
||||
|
||||
Reference in New Issue
Block a user