package com.ruoyi.jianguan.controller;
|
|
import com.alibaba.fastjson.JSON;
|
import com.alibaba.fastjson.JSONArray;
|
import com.alibaba.fastjson.JSONObject;
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
import com.ruoyi.chargingPile.api.feignClient.ChargingGunClient;
|
import com.ruoyi.chargingPile.api.feignClient.ChargingPileClient;
|
import com.ruoyi.chargingPile.api.feignClient.SiteClient;
|
import com.ruoyi.chargingPile.api.model.Site;
|
import com.ruoyi.chargingPile.api.model.TChargingGun;
|
import com.ruoyi.chargingPile.api.model.TChargingPile;
|
import com.ruoyi.common.core.domain.R;
|
import com.ruoyi.common.core.utils.DateUtils;
|
import com.ruoyi.common.core.web.page.PageInfo;
|
import com.ruoyi.jianguan.dto.*;
|
import com.ruoyi.jianguan.service.ISiteService;
|
import com.ruoyi.jianguan.service.TChargingGunService;
|
import com.ruoyi.jianguan.service.TChargingPileService;
|
import com.ruoyi.jianguan.util.ChargePileHttpUtil;
|
import com.ruoyi.order.api.feignClient.ChargingOrderAccountingStrategyClient;
|
import com.ruoyi.order.api.feignClient.ChargingOrderClient;
|
import com.ruoyi.order.api.model.TChargingOrder;
|
import com.ruoyi.order.api.model.TChargingOrderAccountingStrategy;
|
import com.ruoyi.other.api.domain.Region;
|
import com.ruoyi.other.api.feignClient.OtherClient;
|
import io.swagger.annotations.ApiImplicitParam;
|
import io.swagger.annotations.ApiImplicitParams;
|
import io.swagger.annotations.ApiOperation;
|
import lombok.extern.slf4j.Slf4j;
|
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.util.CollectionUtils;
|
import org.springframework.util.StringUtils;
|
import org.springframework.web.bind.annotation.PostMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.ResponseBody;
|
import org.springframework.web.bind.annotation.RestController;
|
|
import java.math.BigDecimal;
|
import java.text.SimpleDateFormat;
|
import java.time.LocalDate;
|
import java.time.LocalDateTime;
|
import java.util.*;
|
import java.util.stream.Collectors;
|
|
/**
|
* 站桩枪、订单 临时数据接口
|
*
|
* @author stylefeng
|
* @Date 2018/7/20 23:39
|
*/
|
@RestController
|
@RequestMapping("/chargingPileInfo")
|
@Slf4j
|
public class ChargingPileInfoController {
|
@Autowired
|
private ChargePileHttpUtil chargePileHttpUtil;
|
|
@Autowired
|
private ChargingOrderAccountingStrategyClient chargingOrderAccountingStrategyClient;
|
@Autowired
|
private ChargingGunClient chargingGunClient;
|
@Autowired
|
private ChargingPileClient chargingPileClient;
|
@Autowired
|
private SiteClient siteClient;
|
@Autowired
|
private ChargingOrderClient chargingOrderClient;
|
@Autowired
|
private OtherClient otherClient;
|
private static final double EARTH_RADIUS = 6371.0; // 地球半径,单位为千米
|
|
/**
|
* 计算两点之间的距离,单位为千米
|
*
|
* @param lat1 第一个点的纬度
|
* @param lon1 第一个点的经度
|
* @param lat2 第二个点的纬度
|
* @param lon2 第二个点的经度
|
* @return 两点之间的距离,单位为千米
|
*/
|
public static double calculateDistance(double lat1, double lon1, double lat2, double lon2) {
|
double dLat = Math.toRadians(lat2 - lat1);
|
double dLon = Math.toRadians(lon2 - lon1);
|
|
lat1 = Math.toRadians(lat1);
|
lat2 = Math.toRadians(lat2);
|
|
double a = Math.sin(dLat / 2) * Math.sin(dLat / 2) +
|
Math.sin(dLon / 2) * Math.sin(dLon / 2) * Math.cos(lat1) * Math.cos(lat2);
|
double c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a));
|
|
return EARTH_RADIUS * c;
|
}
|
|
/**
|
* 司机端-获取充电桩列表
|
*/
|
@ResponseBody
|
@PostMapping("/orderList")
|
@ApiOperation(value = "获取充电订单", tags = {"司机端-获取充电订单"}, notes = "")
|
public R<String> chargingPileList(Integer pageNo, Integer pageSize){
|
List<TChargingGun> chargingGun = chargingGunClient.getAllGun().getData();
|
|
chargingGun = chargingGun.stream().filter(e->StringUtils.hasLength(e.getConnectorID()))
|
.collect(Collectors.toList());
|
List<ChargeOrder> result = getOrderList(pageNo, pageSize);
|
List<TChargingOrder> orders = new ArrayList<>();
|
|
List<TChargingOrderAccountingStrategy> accountingStrategies = new ArrayList<>();
|
// 封装订单数据
|
for (ChargeOrder chargeOrder : result) {
|
TChargingOrder chargingOrder = new TChargingOrder();
|
chargingOrder.setOrderType(1);
|
chargingOrder.setOrderClassification(1);
|
chargingOrder.setAppUserId(1939601394823290882L);
|
chargingOrder.setAppUserCarId(2017427572505907202L);
|
chargingOrder.setRefundAmount(new BigDecimal(chargeOrder.getTotalMoney()));
|
chargingOrder.setRechargeSerialNumber("4200002747202505247686188393");
|
chargingOrder.setCouponDiscountAmount(BigDecimal.ZERO);
|
chargingOrder.setVipDiscount(BigDecimal.ZERO);
|
chargingOrder.setVipDiscountAmount(BigDecimal.ZERO);
|
chargingOrder.setCouponDiscountAmount(BigDecimal.ZERO);
|
chargingOrder.setCommissionAmount(BigDecimal.ZERO);
|
chargingOrder.setSharingAmount(BigDecimal.ZERO);
|
chargingOrder.setDelFlag(false);
|
chargingOrder.setNeedElec(new BigDecimal(chargeOrder.getTotalPower()));
|
chargingOrder.setStartSoc(BigDecimal.ZERO);
|
chargingOrder.setEndSoc(new BigDecimal("100"));
|
chargingOrder.setPower(new BigDecimal(chargeOrder.getTotalPower()));
|
chargingOrder.setElectricity(new BigDecimal(chargeOrder.getTotalPower()));
|
chargingOrder.setVoltage(new BigDecimal(chargeOrder.getTotalPower()));
|
chargingOrder.setCurrent(new BigDecimal(chargeOrder.getTotalPower()));
|
chargingOrder.setChargingPower(new BigDecimal(chargeOrder.getTotalPower()));
|
chargingOrder.setChargingCapacity(new BigDecimal(chargeOrder.getTotalPower()));
|
chargingOrder.setCode(chargeOrder.getStartChargeSeq());
|
chargingOrder.setOrderSource(2);
|
chargingOrder.setOperatorId(999);
|
chargingOrder.setTripartitePlatformName("途来电");
|
chargingOrder.setStartChargeSeq(chargeOrder.getStartChargeSeq());
|
chargingOrder.setSourceName("途来电");
|
chargingOrder.setStartTime(DateUtils.stringToLocalDateTime(chargeOrder.getStartTime()));
|
chargingOrder.setEndTime(DateUtils.stringToLocalDateTime(chargeOrder.getEndTime()));
|
chargingOrder.setStatus(5);
|
chargingOrder.setEndMode(1);
|
chargingOrder.setElectrovalence(new BigDecimal(chargeOrder.getSeviceMoney()).multiply(new BigDecimal("1.19")));
|
chargingOrder.setServiceCharge(new BigDecimal(chargeOrder.getSeviceMoney()));
|
chargingOrder.setTotalElectricity(new BigDecimal(chargeOrder.getElecMoney()));
|
chargingOrder.setPaymentAmount(new BigDecimal(chargeOrder.getTotalMoney()));
|
chargingOrder.setRechargePaymentType(1);
|
chargingOrder.setRechargePaymentStatus(2);
|
chargingOrder.setChargeAmount(new BigDecimal(chargeOrder.getTotalMoney()));
|
chargingOrder.setOrderAmount(new BigDecimal(chargeOrder.getTotalMoney()));
|
chargingOrder.setResidualAmount(BigDecimal.ZERO);
|
chargingOrder.setPaymentAmount(new BigDecimal(chargeOrder.getTotalMoney()));
|
chargingOrder.setPayTime(DateUtils.stringToLocalDateTime(chargeOrder.getStartTime()));
|
chargingOrder.setCreateTime(DateUtils.stringToLocalDateTime(chargeOrder.getStartTime()));
|
if (!StringUtils.hasLength(chargeOrder.getConnectorID())){
|
continue;
|
}
|
// 通过枪编号查询枪
|
TChargingGun tChargingGun = chargingGun.stream().filter(e ->chargeOrder.getConnectorID().equals(e.getConnectorID()))
|
.findFirst().orElse(null);
|
if(Objects.nonNull(tChargingGun)){
|
chargingOrder.setChargingGunId(tChargingGun.getId());
|
chargingOrder.setChargingPileId(tChargingGun.getChargingPileId());
|
chargingOrder.setSiteId(tChargingGun.getSiteId());
|
}else{
|
continue;
|
}
|
R<Long> orderIdR = chargingOrderClient.addChargingOrder(chargingOrder);
|
if(orderIdR.getCode() == 200){
|
// 充电明细
|
List<com.ruoyi.jianguan.dto.ChargeDetail> chargeDetails = chargeOrder.getChargeDetails();
|
if(!CollectionUtils.isEmpty(chargeDetails)){
|
List<TChargingOrderAccountingStrategy> accountingStrategyList = new ArrayList<>();
|
for (ChargeDetail chargeDetail : chargeDetails) {
|
TChargingOrderAccountingStrategy accountingStrategy = new TChargingOrderAccountingStrategy();
|
accountingStrategy.setChargingOrderId(orderIdR.getData());
|
accountingStrategy.setAccountingStrategyDetailId(232);
|
accountingStrategy.setType(1);
|
accountingStrategy.setStartTime(chargeDetail.getDetailStartTime());
|
accountingStrategy.setEndTime(chargeDetail.getDetailEndTime());
|
accountingStrategy.setElectrovalence(chargeDetail.getElecPrice());
|
accountingStrategy.setServiceCharge(chargeDetail.getSevicePrice());
|
accountingStrategy.setCostServiceCharge(chargeDetail.getDetailSeviceMoney());
|
accountingStrategy.setChargingCapacity(chargeDetail.getDetailPower());
|
accountingStrategy.setPeriodElectricPrice(chargeDetail.getDetailSeviceMoney().multiply(new BigDecimal("1.19")));
|
accountingStrategy.setCouponDiscountAmount(BigDecimal.ZERO);
|
accountingStrategy.setVipDiscountAmount(BigDecimal.ZERO);
|
accountingStrategy.setPeriodServicePrice(chargeDetail.getDetailSeviceMoney());
|
accountingStrategy.setPeriodOriginalServicePrice(chargeDetail.getDetailSeviceMoney());
|
accountingStrategy.setCreateTime(LocalDateTime.now());
|
accountingStrategyList.add(accountingStrategy);
|
}
|
chargingOrderAccountingStrategyClient.addChargingOrderAccountingStrategy(accountingStrategyList);
|
}
|
}
|
}
|
|
return R.ok();
|
}
|
|
@ResponseBody
|
@PostMapping("/chargingPileList")
|
@ApiOperation(value = "获取充电桩列表", tags = {"获取充电桩列表"}, notes = "")
|
@ApiImplicitParams({
|
@ApiImplicitParam(value = "电站类型 0=不限 1=公共 50=个人 100=公交 101=环卫(专用) 102=物流(专用) 103=出租车(专用) 255=其他", name = "type", required = false, dataType = "string"),
|
@ApiImplicitParam(value = "电站距离 不限=0 1km内=1 2km内=2 3km内=3 5km内=4 10km内=5 50km内=6 100km内=7 ", name = "distance", required = false, dataType = "int"),
|
@ApiImplicitParam(value = "设备状态 不限=0 1=只看空闲", name = "status", required = false, dataType = "int"),
|
@ApiImplicitParam(value = "电站名称/目标地址", name = "name", required = false, dataType = "string"),
|
@ApiImplicitParam(value = "pageNo", name = "pageNo", required = false, dataType = "string"),
|
@ApiImplicitParam(value = "pageSize", name = "pageSize", required = false, dataType = "string"),
|
@ApiImplicitParam(value = "lon", name = "经度", required = false, dataType = "string"),
|
@ApiImplicitParam(value = "lat", name = "纬度", required = false, dataType = "string"),
|
@ApiImplicitParam(name = "Authorization", value = "Bearer +token", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9....."),
|
})
|
public R<String> chargingPileList(String type, Integer distance,
|
Integer status,
|
String name,
|
String lon,
|
String lat,
|
Integer pageNo, Integer pageSize){
|
PageInfo pageInfo = new PageInfo();
|
List<StationInfos> result = getStationInfos();
|
// 电站类型
|
if (StringUtils.hasLength(type) && (!type.equals("0"))){
|
List<Integer> list = Arrays.stream(type.split(",")).map(Integer::parseInt).collect(Collectors.toList());
|
result = result.stream().filter(item -> list.contains(item.getStationType())).collect(Collectors.toList());
|
}
|
// 电站名称/目标地址
|
if(StringUtils.hasLength(name)){
|
result = result.stream().filter(item -> item.getStationName().contains(name) ||
|
item.getAddress().contains(name)).collect(Collectors.toList());
|
}
|
|
for (StationInfos stationInfo : result) {
|
if (StringUtils.hasLength(lon)){
|
double v = calculateDistance(
|
stationInfo.getStationLat(),
|
stationInfo.getStationLng(),
|
Double.parseDouble(lat),
|
Double.parseDouble(lon)
|
);
|
stationInfo.setDistance(String.valueOf(Math.abs(v)));
|
}else {
|
stationInfo.setDistance("0");
|
}
|
|
List<EquipmentInfos> equipmentInfos = stationInfo.getEquipmentInfos();
|
int a = 0;
|
int b = 0;
|
for (EquipmentInfos equipmentInfo : equipmentInfos) {
|
if (equipmentInfo.getEquipmentType()==1){
|
a++;
|
}
|
if (equipmentInfo.getEquipmentType()==2){
|
b++;
|
}
|
}
|
stationInfo.setFastTotal(a);
|
stationInfo.setSnowTotal(b);
|
stationInfo.setFast(a);
|
stationInfo.setSnow(b);
|
}
|
if(Objects.nonNull(distance) && distance != 0){
|
switch (distance){
|
case 1:
|
result = result.stream().filter(item -> Double.parseDouble(item.getDistance()) <= 1).collect(Collectors.toList());
|
break;
|
case 2:
|
result = result.stream().filter(item -> Double.parseDouble(item.getDistance()) <= 2).collect(Collectors.toList());
|
break;
|
case 3:
|
result = result.stream().filter(item -> Double.parseDouble(item.getDistance()) <= 3).collect(Collectors.toList());
|
break;
|
case 4:
|
result = result.stream().filter(item -> Double.parseDouble(item.getDistance()) <= 5).collect(Collectors.toList());
|
break;
|
case 5:
|
result = result.stream().filter(item -> Double.parseDouble(item.getDistance()) <= 10).collect(Collectors.toList());
|
break;
|
case 6:
|
result = result.stream().filter(item -> Double.parseDouble(item.getDistance()) <= 50).collect(Collectors.toList());
|
break;
|
case 7:
|
result = result.stream().filter(item -> Double.parseDouble(item.getDistance()) <= 100).collect(Collectors.toList());
|
break;
|
}
|
}
|
List<String> stationIDs = result.stream()
|
.map(StationInfos::getStationID)
|
.collect(Collectors.toList());
|
String obj = chargePileHttpUtil.queryStationStatus(stationIDs);
|
JSONObject jsonObject1 = JSONObject.parseObject(obj);
|
JSONArray stationStatusInfos = jsonObject1.getJSONArray("StationStatusInfos");
|
for (StationInfos stationInfo : result) {
|
for (EquipmentInfos equipmentInfo : stationInfo.getEquipmentInfos()) {
|
for (ConnectorInfo connectorInfo : equipmentInfo.getConnectorInfos()) {
|
for (Object stationStatusInfo : stationStatusInfos) {
|
JSONObject jsonObject2 = (JSONObject) stationStatusInfo;
|
String stationID = jsonObject2.getString("StationID");
|
JSONArray connectorStatusInfos = jsonObject2.getJSONArray("ConnectorStatusInfos");
|
if (connectorStatusInfos != null) {
|
for (Object connectorStatusInfo : connectorStatusInfos) {
|
JSONObject jsonObject3 = (JSONObject) connectorStatusInfo;
|
String status1 = jsonObject3.getString("ConnectorID");
|
if (connectorInfo.getConnectorID().equals(status1)){
|
Integer status2 = jsonObject3.getInteger("Status");
|
if (status2==1){
|
connectorInfo.setStatus(1);
|
}else {
|
connectorInfo.setStatus(2);
|
}
|
break;
|
}
|
}
|
}
|
}
|
}
|
}
|
}
|
// 电站状态
|
if (Objects.nonNull(status) && status == 1) {
|
Iterator<StationInfos> iterator1 = result.iterator();
|
while (iterator1.hasNext()) {
|
StationInfos next = iterator1.next();
|
for (Object stationStatusInfo : stationStatusInfos) {
|
JSONObject jsonObject2 = (JSONObject) stationStatusInfo;
|
String stationID = jsonObject2.getString("StationID");
|
if (stationID != null && stationID.equals(next.getStationID())) {
|
JSONArray connectorStatusInfos = jsonObject2.getJSONArray("ConnectorStatusInfos");
|
if (connectorStatusInfos != null) {
|
for (Object connectorStatusInfo : connectorStatusInfos) {
|
JSONObject jsonObject3 = (JSONObject) connectorStatusInfo;
|
Integer status1 = jsonObject3.getInteger("Status");
|
if (status1 != null && status1 == 1) {
|
break;
|
}else {
|
iterator1.remove();
|
break;
|
}
|
}
|
}
|
}
|
}
|
}
|
}
|
result.sort(Comparator.comparing(StationInfos::getDistance));
|
pageInfo.setTotal(result.size());
|
|
// List<StationInfos> testing = testing(result.size(), pageNo, pageSize, result);
|
Map<String, Region> regionMap = otherClient.listAllRegion().getData()
|
.stream().collect(Collectors.toMap(Region::getCode, e -> e));
|
Map<Integer, Region> regionIdMap = otherClient.listAllRegion().getData()
|
.stream().collect(Collectors.toMap(Region::getId, e -> e));
|
List<Site> sites = new ArrayList<>();
|
List<TChargingPile> piles = new ArrayList<>();
|
List<TChargingGun> guns = new ArrayList<>();
|
for (StationInfos stationInfos : result) {
|
if (StringUtils.hasLength(stationInfos.getAreaCode())){
|
if (stationInfos.getAreaCode().equals("0")){
|
continue;
|
}
|
}
|
Site site = new Site();
|
site.setStationID(stationInfos.getStationID());
|
site.setPartnerId(26);
|
Calendar calendar = Calendar.getInstance();
|
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyyMMdd");
|
String dateTime = dateFormat.format(calendar.getTime());
|
dateTime = dateTime.substring(2);
|
String timestampPart = "" + (Math.random() * 10000) * (System.currentTimeMillis() / 10000);
|
timestampPart = timestampPart.replace(".", "").replace("E", "");
|
timestampPart = timestampPart.substring(0, 4);
|
site.setCode(dateTime+timestampPart);
|
site.setName(stationInfos.getStationName());
|
site.setSiteType(stationInfos.getStationType());
|
site.setBusinessCategory(2);
|
site.setStatus(1);
|
site.setConstructionSite(1);
|
site.setImgUrl("");
|
Region region = regionMap.get(stationInfos.getAreaCode());
|
if (region!=null){
|
site.setDistricts(region.getName());
|
site.setDistrictsCode(region.getCode());
|
Integer parentId = region.getParentId();
|
Region parentRegion = regionIdMap.get(parentId);
|
if (parentRegion != null) {
|
site.setCity(parentRegion.getName());
|
site.setCityCode(parentRegion.getCode());
|
Region region1 = regionIdMap.get(parentRegion.getParentId());
|
if (region1!=null){
|
site.setProvince(region1.getName());
|
site.setProvinceCode(region1.getCode());
|
}
|
}
|
}
|
site.setLon(stationInfos.getStationLng()+"");
|
site.setLat(stationInfos.getStationLat()+"");
|
site.setAddress(stationInfos.getAddress());
|
// site.setCountryCode();
|
site.setPhone(stationInfos.getServiceTel());
|
site.setServicePhone(stationInfos.getServiceTel());
|
site.setGuide(stationInfos.getSiteGuide());
|
site.setStartServiceTime("24小时");
|
// site.setEndServiceTime();
|
// site.setServiceDescription();
|
// site.setVehicleDescription();
|
site.setParkingSpace(stationInfos.getParkNums());
|
// site.setRateDescription();
|
// site.setSpaceChargeExplain();
|
// todo 临时写死一个
|
site.setAccountingStrategyId(232);
|
// site.setEstablishmentTime();
|
site.setSort(180);
|
// site.setRemark();
|
// site.setMark();
|
// site.setAreaCodeCountryside();
|
site.setStationClassification(1);
|
site.setGeneralApplicationType(1);
|
site.setSwapMatchCars(stationInfos.getMatchCars());
|
site.setRoundTheClock(1);
|
site.setParkType(4);
|
// site.setParkFee();
|
// site.setParkFeeFree();
|
site.setBusinessExpandType(1);
|
site.setElectricityType(1);
|
site.setCapacity(new BigDecimal("1250"));
|
site.setRatedPower(new BigDecimal("1200"));
|
site.setPeriodFee(1);
|
site.setOfficialRunTime("2025-06-22");
|
// site.setStationOrientation();
|
// site.setStationArea();
|
site.setHavePerson(1);
|
site.setVideoMonitor(1);
|
// site.setSupportingFacilities();
|
site.setPrinterFlag(1);
|
site.setBarrierFlag(1);
|
site.setParkingLockFlag(1);
|
// site.setElectricityFee();
|
site.setEquipmentOwnerName("途来电");
|
site.setSupplyType(1);
|
site.setResidentNo("0110043462");
|
site.setWattHourMeterNo("MX01D05054000217");
|
site.setForwardPower(new BigDecimal("0"));
|
site.setServiceFee("0:00-23:59:\"0.20\"");
|
Calendar calendar1 = Calendar.getInstance();
|
SimpleDateFormat dateFormat1 = new SimpleDateFormat("yyyyMMdd");
|
String dateTime1 = dateFormat1.format(calendar1.getTime());
|
dateTime1 = dateTime1.substring(2);
|
String timestampPart1 = "" + (Math.random() * 10000) * (System.currentTimeMillis() / 10000);
|
timestampPart1 = timestampPart1.replace(".", "").replace("E", "");
|
timestampPart1 = timestampPart1.substring(0, 4);
|
site.setRecordUniqueNo(dateTime+timestampPart);
|
site.setPayment(1);
|
site.setSupportOrder(1);
|
// site.setSerAreaCode();
|
site.setIsOpenSynchronization(0);
|
site.setIsEnergyStorage(0);
|
if (site.getProvince()==null){
|
continue;
|
}
|
Integer siteId = siteClient.addSiteTemp(site).getData();
|
sites.add(site);
|
int i = 1;
|
|
for (EquipmentInfos equipmentInfo : stationInfos.getEquipmentInfos()) {
|
TChargingPile chargingPile = new TChargingPile();
|
Calendar calendar2 = Calendar.getInstance();
|
SimpleDateFormat dateFormat3 = new SimpleDateFormat("yyyyMMddHHmmss");
|
String dateTime4 = dateFormat3.format(calendar2.getTime());
|
dateTime4 = dateTime4.substring(2);
|
String timestampPart5 = "" + (Math.random() * 10000) * (System.currentTimeMillis() / 10000);
|
timestampPart5 = timestampPart5.replace(".", "").replace("E", "");
|
timestampPart5 = timestampPart5.substring(0, 4);
|
chargingPile.setCode(dateTime4+timestampPart5);
|
chargingPile.setName(equipmentInfo.getEquipmentName());
|
chargingPile.setNumber(i);
|
chargingPile.setType(equipmentInfo.getEquipmentType());
|
chargingPile.setSiteId(siteId);
|
chargingPile.setPartnerId(26);
|
chargingPile.setManufacturerCode(equipmentInfo.getManufacturerID());
|
chargingPile.setManufacturer(equipmentInfo.getManufacturerName());
|
chargingPile.setEquipmentType(equipmentInfo.getEquipmentModel());
|
String productionDate = equipmentInfo.getProductionDate();
|
if (StringUtils.hasLength(productionDate)){
|
// 转化为LocalDate
|
chargingPile.setProductionDate(LocalDate.parse(productionDate));
|
}
|
chargingPile.setRatedPower(new BigDecimal(120));
|
// chargingPile.setChargingStationNumber();
|
chargingPile.setStatus(1);
|
// chargingPile.setIotdDeviceId();
|
chargingPile.setEquipmentClassification(1);
|
// chargingPile.setEquipmentUniqueNumber(equipmentInfo.getEquipmentID());
|
chargingPile.setEquipmentLng(equipmentInfo.getEquipmentLng()+"");
|
chargingPile.setEquipmentLat(equipmentInfo.getEquipmentLat()+"");
|
// chargingPile.setEquipmentProductCode();
|
chargingPile.setEquipmentPurpose(1);
|
chargingPile.setNewNationalStandard(1);
|
chargingPile.setVinFlag(1);
|
chargingPile.setName(site.getName()+chargingPile.getNumber()+"号桩");
|
Integer pileId = chargingPileClient.addPileTemp(chargingPile).getData();
|
piles.add(chargingPile);
|
i++;
|
int j = 1;
|
|
for (ConnectorInfo connectorInfo : equipmentInfo.getConnectorInfos()) {
|
TChargingGun gun = new TChargingGun();
|
gun.setConnectorID(connectorInfo.getConnectorID());
|
gun.setCode(j+"");
|
gun.setSiteId(siteId);
|
gun.setPartnerId(26);
|
gun.setChargingPileId(pileId);
|
gun.setName(connectorInfo.getConnectorName());
|
gun.setType(connectorInfo.getConnectorType());
|
gun.setStatus(2);
|
gun.setChargeMode(connectorInfo.getGunType());
|
// todo 临时写死
|
gun.setAccountingStrategyId(232);
|
gun.setUpperRatedVoltage(new BigDecimal("240"));
|
gun.setLowerLimitOfRatedVoltage(new BigDecimal("200"));
|
gun.setRatedCurrent(new BigDecimal("32"));
|
gun.setRatedPower(new BigDecimal("7"));
|
gun.setChargingPower(new BigDecimal("200"));
|
gun.setParkingNumber("39");
|
gun.setParkingStatus(1);
|
gun.setParkingLockState(0);
|
gun.setNationalStandard("3");
|
// gun.setRemark();
|
// gun.setSoc();
|
gun.setFullNumber(chargingPile.getNumber()+j+"");
|
gun.setEquipmentClassification(1);
|
gun.setConstantVoltageUpperLimits(new BigDecimal("240"));
|
gun.setConstantVoltageLowerLimits(new BigDecimal("200"));
|
gun.setConstantCurrentUpperLimits(new BigDecimal("32"));
|
gun.setConstantCurrentLowerLimits(new BigDecimal("7"));
|
gun.setAuxPower(3);
|
gun.setOpreateStatus(50);
|
gun.setChargeMode(2);
|
// gun.setOpreateHours();
|
guns.add(gun);
|
chargingGunClient.addGunTemp(gun);
|
j++;
|
|
}
|
}
|
}
|
log.info("新增的站点数据:{}", sites);
|
log.info("新增的桩数据:{}", piles);
|
log.info("新增的枪数据:{}", guns);
|
|
return R.ok();
|
}
|
|
private List<StationInfos> getStationInfos(){
|
String s = chargePileHttpUtil.queryStationsInfo(1, 199);
|
// 将s字符串转化为json 然后转化为实体类PageInfo
|
JSONObject jsonObject = JSONObject.parseObject(s);
|
com.ruoyi.jianguan.domain.PageInfo pageInfo = JSON.parseObject(jsonObject.toJSONString(), com.ruoyi.jianguan.domain.PageInfo.class);
|
List<StationInfos> result = new ArrayList<>();
|
int itemSize = pageInfo.getItemSize();
|
if(itemSize>199){
|
result.addAll(pageInfo.getStationInfos());
|
int i = itemSize / 199;
|
// int k =1;
|
for (int j = 2; j < i + 2; j++) {
|
s = chargePileHttpUtil.queryStationsInfo(j, 199);
|
// 将s字符串转化为json 然后转化为实体类PageInfo
|
jsonObject = JSONObject.parseObject(s);
|
pageInfo = JSON.parseObject(jsonObject.toJSONString(), com.ruoyi.jianguan.domain.PageInfo.class);
|
result.addAll(pageInfo.getStationInfos());
|
// if (k==10){
|
// break;
|
// }
|
// k++;
|
}
|
}else {
|
result.addAll(pageInfo.getStationInfos());
|
}
|
return result;
|
}
|
private List<ChargeOrder> getOrderList(Integer pageNo, Integer pageSize){
|
|
String s = chargePileHttpUtil.getOrderList(pageNo, pageSize);
|
// 将s字符串转化为json 然后转化为实体类PageInfo
|
JSONObject jsonObject = JSONObject.parseObject(s);
|
com.ruoyi.jianguan.domain.PageInfo pageInfo = JSON.parseObject(jsonObject.toJSONString(), com.ruoyi.jianguan.domain.PageInfo.class);
|
List<ChargeOrder> result = new ArrayList<>();
|
int itemSize = pageInfo.getItemSize();
|
int temp = 0;
|
// if(itemSize>pageSize){
|
// result.addAll(pageInfo.getChargeOrders());
|
// int i = itemSize / pageNo;
|
// for (int j = 2; j < i + 2; j++) {
|
// s = chargePileHttpUtil.getOrderList(j, pageSize);
|
// // 将s字符串转化为json 然后转化为实体类PageInfo
|
// jsonObject = JSONObject.parseObject(s);
|
// pageInfo = JSON.parseObject(jsonObject.toJSONString(), com.ruoyi.jianguan.domain.PageInfo.class);
|
// result.addAll(pageInfo.getChargeOrders());
|
// if (temp ==20){
|
// break;
|
// }
|
// temp++;
|
// }
|
// }else {
|
result.addAll(pageInfo.getChargeOrders());
|
// }
|
return result;
|
}
|
|
}
|