diff --git a/jsowell-admin/src/main/java/com/jsowell/thirdparty/nanrui/NRController.java b/jsowell-admin/src/main/java/com/jsowell/thirdparty/nanrui/NRController.java index bbe0647ea..0047f1e42 100644 --- a/jsowell-admin/src/main/java/com/jsowell/thirdparty/nanrui/NRController.java +++ b/jsowell-admin/src/main/java/com/jsowell/thirdparty/nanrui/NRController.java @@ -1,10 +1,91 @@ package com.jsowell.thirdparty.nanrui; +import com.alibaba.fastjson2.JSON; +import com.jsowell.common.annotation.Anonymous; +import com.jsowell.common.core.controller.BaseController; +import com.jsowell.common.response.RestApiResponse; +import com.jsowell.pile.domain.nanrui.NROrderInfo; +import com.jsowell.pile.dto.QueryStationInfoDTO; +import com.jsowell.pile.dto.nanrui.NRQueryOrderDTO; +import com.jsowell.thirdparty.nanrui.service.NRService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import java.util.List; +import java.util.Map; + /** - * TODO + * 南瑞平台 controller * * @author Lemon * @Date 2023/10/11 13:26 */ -public class NRController { +@Anonymous +@RestController +@RequestMapping("/nanrui") +public class NRController extends BaseController { + + @Autowired + private NRService nrService; + + /** + * 查询充电站信息 + * @param dto + */ + @RequestMapping("/v1/query_stations_info") + public RestApiResponse query_stations_info(@RequestBody QueryStationInfoDTO dto) { + logger.info("南瑞平台查询充电站信息 params:{}", JSON.toJSONString(dto)); + RestApiResponse response = null; + try { + Map map = nrService.query_stations_info(dto); + response = new RestApiResponse<>(map); + } catch (Exception e) { + logger.error("南瑞平台查询充电站信息 error", e); + response = new RestApiResponse<>(e); + } + logger.info("南瑞平台查询充电站信息 result:{}", response); + return response; + } + + + /** + * 查询设备接口状态 + * @param dto + */ + @RequestMapping("/v1/query_station_status") + public RestApiResponse query_station_status(@RequestBody QueryStationInfoDTO dto) { + logger.info("南瑞平台查询设备接口状态 params:{}", JSON.toJSONString(dto)); + RestApiResponse response = null; + try { + Map map = nrService.query_station_status(dto.getStationIds()); + response = new RestApiResponse<>(map); + } catch (Exception e) { + logger.error("南瑞平台查询设备接口状态 error", e); + response = new RestApiResponse<>(e); + } + logger.info("南瑞平台查询设备接口状态 result:{}", response); + return response; + } + + + /** + * 查询设备接口状态 + * @param dto + */ + @RequestMapping("/v1/query_order_info") + public RestApiResponse query_order_info(@RequestBody NRQueryOrderDTO dto) { + logger.info("南瑞平台查询设备接口状态 params:{}", JSON.toJSONString(dto)); + RestApiResponse response = null; + try { + List nrOrderInfos = nrService.query_order_info(dto); + response = new RestApiResponse<>(nrOrderInfos); + } catch (Exception e) { + logger.error("南瑞平台查询设备接口状态 error", e); + response = new RestApiResponse<>(e); + } + logger.info("南瑞平台查询设备接口状态 result:{}", response); + return response; + } } diff --git a/jsowell-pile/src/main/java/com/jsowell/pile/dto/QueryStationInfoDTO.java b/jsowell-pile/src/main/java/com/jsowell/pile/dto/QueryStationInfoDTO.java index ebea1ec2d..860b2bb6b 100644 --- a/jsowell-pile/src/main/java/com/jsowell/pile/dto/QueryStationInfoDTO.java +++ b/jsowell-pile/src/main/java/com/jsowell/pile/dto/QueryStationInfoDTO.java @@ -25,42 +25,42 @@ public class QueryStationInfoDTO { * 不填写,则查询所有的充电站信息 */ @JsonProperty(value = "LastQueryTime") - private String LastQueryTime; + private String lastQueryTime; /** * 查询页码 * 不填写默认为 1 */ @JsonProperty(value = "PageNo") - private Integer PageNo; + private Integer pageNo; /** * 每页数量 * 不填写默认为 10 */ @JsonProperty(value = "PageSize") - private Integer PageSize; + private Integer pageSize; /** * 充电站 ID */ @JsonProperty(value = "StationID") - private String StationID; + private String stationID; /** * 统计开始时间 * 格式“yyyy-MM-dd” */ @JsonProperty(value = "StartTime") - private String StartTime; + private String startTime; /** * 统计结束时间 * 格式“yyyy-MM-dd” */ @JsonProperty(value = "EndTime") - private String EndTime; + private String endTime; /** * 运营商id diff --git a/jsowell-pile/src/main/java/com/jsowell/pile/dto/nanrui/NRQueryOrderDTO.java b/jsowell-pile/src/main/java/com/jsowell/pile/dto/nanrui/NRQueryOrderDTO.java index 2679397a1..eda0eaabb 100644 --- a/jsowell-pile/src/main/java/com/jsowell/pile/dto/nanrui/NRQueryOrderDTO.java +++ b/jsowell-pile/src/main/java/com/jsowell/pile/dto/nanrui/NRQueryOrderDTO.java @@ -1,6 +1,7 @@ package com.jsowell.pile.dto.nanrui; import com.alibaba.fastjson2.annotation.JSONField; +import com.fasterxml.jackson.annotation.JsonProperty; import lombok.Data; /** @@ -17,12 +18,12 @@ public class NRQueryOrderDTO { /** * yyyy-MM-dd HH:mm:ss 格式,必填,以充电结束时间为准 */ - @JSONField(name = "QueryStartTime") + @JsonProperty(value = "QueryStartTime") private String queryStartTime; /** * yyyy-MM-dd HH:mm:ss 格式,必填,以充电结束时间为准 */ - @JSONField(name = "QueryEndTime") + @JsonProperty(value = "QueryEndTime") private String queryEndTime; } \ No newline at end of file diff --git a/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/nanrui/domain/NRAlarmInfo.java b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/nanrui/domain/NRAlarmInfo.java index 708cf8e03..f99707187 100644 --- a/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/nanrui/domain/NRAlarmInfo.java +++ b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/nanrui/domain/NRAlarmInfo.java @@ -1,6 +1,7 @@ package com.jsowell.thirdparty.nanrui.domain; import com.alibaba.fastjson2.annotation.JSONField; +import com.fasterxml.jackson.annotation.JsonProperty; import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Data; @@ -20,27 +21,27 @@ public class NRAlarmInfo { /** * 枪口编号 */ - @JSONField(name = "ConnectorID") + @JsonProperty(value = "ConnectorID") private String connectorId; /** * 告警时间 * 格 式 为 yyyy-MM-dd HH:mm:ss */ - @JSONField(name = "Alert_time") + @JsonProperty(value = "Alert_time") private String alertTime; /** * 告警代码 */ - @JSONField(name = "Alert_code") + @JsonProperty(value = "Alert_code") private Integer alertCode; /** * 描述 * 文字描述,最大长度 256 字符 */ - @JSONField(name = "Describe") + @JsonProperty(value = "Describe") private String describe; /** @@ -48,6 +49,6 @@ public class NRAlarmInfo { * 告警发生:0;告警恢复:1 * 默认为 0 */ - @JSONField(name = "Status") + @JsonProperty(value = "Status") private Integer status; } diff --git a/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/nanrui/domain/NRConnectorInfo.java b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/nanrui/domain/NRConnectorInfo.java index 6e34afb87..92f65e694 100644 --- a/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/nanrui/domain/NRConnectorInfo.java +++ b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/nanrui/domain/NRConnectorInfo.java @@ -1,6 +1,7 @@ package com.jsowell.thirdparty.nanrui.domain; import com.alibaba.fastjson2.annotation.JSONField; +import com.fasterxml.jackson.annotation.JsonProperty; import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Data; @@ -22,13 +23,13 @@ public class NRConnectorInfo { /** * 充电设备接口编码 */ - @JSONField(name = "ConnectorID") + @JsonProperty(value = "ConnectorID") private String connectorId; /** * 充电设备接口名称 */ - @JSONField(name = "ConnectorName") + @JsonProperty(value = "ConnectorName") private String connectorName; /** @@ -39,35 +40,35 @@ public class NRConnectorInfo { * 4:直流接口枪头(带枪线,模式 4) * 5:无线充电座; */ - @JSONField(name = "ConnectorType") + @JsonProperty(value = "ConnectorType") private Integer connectorType; /** * 额定电压上限 * 单位:V */ - @JSONField(name = "VoltageUpperLimits") + @JsonProperty(value = "VoltageUpperLimits") private Integer voltageUpperLimits; /** * 额定电压下限 * 单位:V */ - @JSONField(name = "VoltageLowerLimits") + @JsonProperty(value = "VoltageLowerLimits") private Integer voltageLowerLimits; /** * 额定电流 * 单位:A */ - @JSONField(name = "Current") + @JsonProperty(value = "Current") private Integer current; /** * 额定功率 * 单位:kW */ - @JSONField(name = "Power") + @JsonProperty(value = "Power") private BigDecimal power; /** @@ -75,6 +76,6 @@ public class NRConnectorInfo { * 1:2011 * 2:2015 */ - @JSONField(name = "NationalStandard") + @JsonProperty(value = "NationalStandard") private Integer nationalStandard; } diff --git a/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/nanrui/domain/NRConnectorStatusInfo.java b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/nanrui/domain/NRConnectorStatusInfo.java index d75c185d1..f81b51ec9 100644 --- a/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/nanrui/domain/NRConnectorStatusInfo.java +++ b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/nanrui/domain/NRConnectorStatusInfo.java @@ -1,6 +1,7 @@ package com.jsowell.thirdparty.nanrui.domain; import com.alibaba.fastjson2.annotation.JSONField; +import com.fasterxml.jackson.annotation.JsonProperty; import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Data; @@ -23,25 +24,25 @@ public class NRConnectorStatusInfo { /** * 充电设备接口编码 */ - @JSONField(name = "ConnectorID") + @JsonProperty(value = "ConnectorID") private String connectorID; /** * 充电设备接口状态 */ - @JSONField(name = "Status") + @JsonProperty(value = "Status") private Integer status; /** * A 相电流 */ - @JSONField(name = "CurrentA") + @JsonProperty(value = "CurrentA") private Integer currentA; /** * A 相电压 */ - @JSONField(name = "VoltageA") + @JsonProperty(value = "VoltageA") private Integer voltageA; /** @@ -51,14 +52,14 @@ public class NRConnectorStatusInfo { * 默认:0 * 交流充电桩采集不到SOC 值的填 0 */ - @JSONField(name = "SOC") + @JsonProperty(value = "SOC") private BigDecimal soc; /** * 开始充电时间 * 格 式 为 yyyy-MM-dd HH:mm:ss */ - @JSONField(name = "Begin_time") + @JsonProperty(value = "Begin_time") private String beginTime; /** @@ -67,13 +68,13 @@ public class NRConnectorStatusInfo { * * 单位:kWh */ - @JSONField(name = "Current_kwh") + @JsonProperty(value = "Current_kwh") private BigDecimal currentKwh; /** * 时间戳 * 数据生成时间(秒级时间戳) */ - @JSONField(name = "Time_stamp") + @JsonProperty(value = "Time_stamp") private Integer timeStamp; } diff --git a/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/nanrui/domain/NREquipmentInfo.java b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/nanrui/domain/NREquipmentInfo.java index 8762c42e4..ab1e07ab1 100644 --- a/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/nanrui/domain/NREquipmentInfo.java +++ b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/nanrui/domain/NREquipmentInfo.java @@ -1,6 +1,7 @@ package com.jsowell.thirdparty.nanrui.domain; import com.alibaba.fastjson2.annotation.JSONField; +import com.fasterxml.jackson.annotation.JsonProperty; import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Data; @@ -24,20 +25,20 @@ public class NREquipmentInfo { * 设备编码 * 设备唯一编码,对同一运营商,保证唯一 */ - @JSONField(name = "EquipmentID") + @JsonProperty(value = "EquipmentID") private String equipmentID; /** * 设备名称 */ - @JSONField(name = "EquipmentName") + @JsonProperty(value = "EquipmentName") private String equipmentName; /** * 充电桩投运日期 * yyyy-MM-dd 格式 */ - @JSONField(name = "OpenForBusinessDate") + @JsonProperty(value = "OpenForBusinessDate") private String openForBusinessDate; /** @@ -46,7 +47,7 @@ public class NREquipmentInfo { * 2:交流设备 * 3:交直流一体设备 */ - @JSONField(name = "EquipmentType") + @JsonProperty(value = "EquipmentType") private Integer equipmentType; /** @@ -57,19 +58,19 @@ public class NREquipmentInfo { * 6:维护中 * 50:正常使用 */ - @JSONField(name = "EquipmentStatus") + @JsonProperty(value = "EquipmentStatus") private Integer equipmentStatus; /** * 额定功率 * 单位:kW */ - @JSONField(name = "Power") + @JsonProperty(value = "Power") private BigDecimal power; /** * 充电设备接口列表 */ - @JSONField(name = "ConnectorInfos") + @JsonProperty(value = "ConnectorInfos") private List connectorInfos; } diff --git a/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/nanrui/domain/NRStationInfo.java b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/nanrui/domain/NRStationInfo.java index e45ea913b..5d24b68f8 100644 --- a/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/nanrui/domain/NRStationInfo.java +++ b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/nanrui/domain/NRStationInfo.java @@ -1,6 +1,7 @@ package com.jsowell.thirdparty.nanrui.domain; import com.alibaba.fastjson2.annotation.JSONField; +import com.fasterxml.jackson.annotation.JsonProperty; import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Data; @@ -24,52 +25,52 @@ public class NRStationInfo { * 充电站id * 运营商自定义的唯一编码 */ - @JSONField(name = "StationID") + @JsonProperty(value = "StationID") private String stationId; /** * 运营商id * 统一社会信用代码 */ - @JSONField(name = "OperatorID") + @JsonProperty(value = "OperatorID") private String operatorID; /** * 设备所属方ID * 设备所属方组织机构代码 */ - @JSONField(name = "EquipmentOwnerID") + @JsonProperty(value = "EquipmentOwnerID") private String equipmentOwnerID; /** * 充电站名称 */ - @JSONField(name = "StationName") + @JsonProperty(value = "StationName") private String stationName; /** * 充电站国家代码 * 比如 CN */ - @JSONField(name = "CountryCode") + @JsonProperty(value = "CountryCode") private String countryCode; /** * 充电站省市辖区编码 */ - @JSONField(name = "AreaCode") + @JsonProperty(value = "AreaCode") private String areaCode; /** * 详细地址 */ - @JSONField(name = "Address") + @JsonProperty(value = "Address") private String address; /** * 服务电话 */ - @JSONField(name = "ServiceTel") + @JsonProperty(value = "ServiceTel") private String serviceTel; /** @@ -79,7 +80,7 @@ public class NRStationInfo { * 3:居民充电区 * 255:其他 */ - @JSONField(name = "StationType") + @JsonProperty(value = "StationType") private Integer stationType; /** @@ -90,7 +91,7 @@ public class NRStationInfo { * 6:维护中 * 50:正常使用 */ - @JSONField(name = "StationStatus") + @JsonProperty(value = "StationStatus") private Integer stationStatus; /** @@ -99,19 +100,19 @@ public class NRStationInfo { * 默认:0 未知 * */ - @JSONField(name = "ParkNums") + @JsonProperty(value = "ParkNums") private Integer parkNums; /** * 经度 */ - @JSONField(name = "StationLng") + @JsonProperty(value = "StationLng") private BigDecimal stationLng; /** * 纬度 */ - @JSONField(name = "StationLat") + @JsonProperty(value = "StationLat") private BigDecimal stationLat; /** @@ -133,21 +134,21 @@ public class NRStationInfo { * 301:居民(小)区 * 255:其他 */ - @JSONField(name = "Construction") + @JsonProperty(value = "Construction") private Integer construction; /** * 站点照片 * 充电设备照片、充电车位照片、停车场入口照片 */ - @JSONField(name = "Pictures") + @JsonProperty(value = "Pictures") private List pictures; /** * 站点投运日期 * yyyy-MM-dd 格式 */ - @JSONField(name = "OpenForBusinessDate") + @JsonProperty(value = "OpenForBusinessDate") private String openForBusinessDate; /** @@ -155,24 +156,24 @@ public class NRStationInfo { * 0:否 * 1:是 */ - @JSONField(name = "OpenAllDay") + @JsonProperty(value = "OpenAllDay") private Integer openAllDay; /** * 营业时间 */ - @JSONField(name = "BusineHours") + @JsonProperty(value = "BusineHours") private String busineHours; /** * 最低单价 */ - @JSONField(name = "MinElectricityPrice") + @JsonProperty(value = "MinElectricityPrice") private BigDecimal minElectricityPrice; /** * 充电设备信息 */ - @JSONField(name = "EquipmentInfos") + @JsonProperty(value = "EquipmentInfos") private List equipmentInfos; } diff --git a/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/nanrui/domain/NRStationStatusInfo.java b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/nanrui/domain/NRStationStatusInfo.java index 0ff04a798..b6489d8b3 100644 --- a/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/nanrui/domain/NRStationStatusInfo.java +++ b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/nanrui/domain/NRStationStatusInfo.java @@ -1,6 +1,7 @@ package com.jsowell.thirdparty.nanrui.domain; import com.alibaba.fastjson2.annotation.JSONField; +import com.fasterxml.jackson.annotation.JsonProperty; import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Data; @@ -20,9 +21,9 @@ import java.util.List; @Builder public class NRStationStatusInfo { - @JSONField(name = "StationID") + @JsonProperty(value = "StationID") private String stationId; - @JSONField(name = "ConnectorStatusInfos") + @JsonProperty(value = "ConnectorStatusInfos") private List connectorStatusInfos; } diff --git a/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/nanrui/service/NRService.java b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/nanrui/service/NRService.java index 7752f96ab..83a6d524b 100644 --- a/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/nanrui/service/NRService.java +++ b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/nanrui/service/NRService.java @@ -33,7 +33,7 @@ public interface NRService { * @param dto * @return */ - Map query_stations_info(QueryStationInfoDTO dto); + Map query_stations_info(QueryStationInfoDTO dto); /** * 推送告警信息 diff --git a/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/nanrui/service/impl/NRServiceImpl.java b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/nanrui/service/impl/NRServiceImpl.java index 2cbbfbb64..30d2a35f0 100644 --- a/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/nanrui/service/impl/NRServiceImpl.java +++ b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/nanrui/service/impl/NRServiceImpl.java @@ -24,6 +24,7 @@ import com.jsowell.thirdparty.nanrui.domain.*; import com.jsowell.thirdparty.nanrui.service.NRService; import org.apache.commons.collections4.CollectionUtils; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; import java.math.BigDecimal; import java.text.ParseException; @@ -36,6 +37,7 @@ import java.util.stream.Collectors; * @author Lemon * @Date 2023/9/26 9:20 */ +@Service public class NRServiceImpl implements NRService { @Autowired @@ -84,7 +86,7 @@ public class NRServiceImpl implements NRService { .parkNums(0) .stationLng(new BigDecimal(stationInfoVO.getStationLng()).setScale(6, BigDecimal.ROUND_HALF_UP)) .stationLat(new BigDecimal(stationInfoVO.getStationLat()).setScale(6, BigDecimal.ROUND_HALF_UP)) - .openForBusinessDate(DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD, DateUtils.parseDate(stationInfoVO.getCreateTime()))) + .openForBusinessDate(stationInfoVO.getCreateTime()) .openAllDay(Integer.parseInt(stationInfoVO.getOpenAllDay())) .busineHours(stationInfoVO.getBusinessHours()) .minElectricityPrice(stationInfoVO.getElectricityPrice().add(stationInfoVO.getServicePrice())) @@ -110,7 +112,7 @@ public class NRServiceImpl implements NRService { } @Override - public Map query_stations_info(QueryStationInfoDTO dto) { + public Map query_stations_info(QueryStationInfoDTO dto) { List resultList = new ArrayList<>(); int pageNo = dto.getPageNo() == null ? 1 : dto.getPageNo(); int pageSize = dto.getPageSize() == null ? 10 : dto.getPageSize(); @@ -142,7 +144,7 @@ public class NRServiceImpl implements NRService { .parkNums(0) .stationLng(new BigDecimal(pileStationInfo.getStationLng()).setScale(6, BigDecimal.ROUND_HALF_UP)) .stationLat(new BigDecimal(pileStationInfo.getStationLat()).setScale(6, BigDecimal.ROUND_HALF_UP)) - .openForBusinessDate(DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD, DateUtils.parseDate(pileStationInfo.getCreateTime()))) + .openForBusinessDate(DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD, pileStationInfo.getCreateTime())) .openAllDay(Integer.parseInt(pileStationInfo.getOpenAllDay())) .busineHours(pileStationInfo.getBusinessHours()) .build(); @@ -186,9 +188,7 @@ public class NRServiceImpl implements NRService { map.put("ItemSize", resultList.size()); map.put("StationInfos", resultList); - // TODO 发送数据 - - return null; + return map; } @@ -346,6 +346,13 @@ public class NRServiceImpl implements NRService { if (CollectionUtils.isEmpty(nrOrderInfos)) { return new ArrayList<>(); } + // 将组织机构代码只取后9位数 + for (NROrderInfo nrOrderInfo : nrOrderInfos) { + String operatorId = nrOrderInfo.getOperatorId(); + if (StringUtils.isNotBlank(operatorId)) { + nrOrderInfo.setOperatorId(StringUtils.substring(operatorId, operatorId.length() - 9)); + } + } return nrOrderInfos; }