temp commit, to fix compile issue
This commit is contained in:
parent
732e93ef11
commit
2787fec834
@ -0,0 +1,45 @@
|
|||||||
|
package com.xhpc.evcs.dto;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonAutoDetect;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
@JsonAutoDetect(fieldVisibility = JsonAutoDetect.Visibility.ANY, getterVisibility = JsonAutoDetect.Visibility.NONE,
|
||||||
|
setterVisibility = JsonAutoDetect.Visibility.NONE, creatorVisibility = JsonAutoDetect.Visibility.NONE)
|
||||||
|
//定义该对象转换后的json对象的键值对顺序
|
||||||
|
@JsonPropertyOrder({
|
||||||
|
"EquipBizSeq",
|
||||||
|
"ConnectorID",
|
||||||
|
"SuccStat",
|
||||||
|
"FailReason",
|
||||||
|
"SumPeriod",
|
||||||
|
"PolicyInfos",
|
||||||
|
})
|
||||||
|
public class EquipBizResponse {
|
||||||
|
|
||||||
|
@JsonProperty("EquipBizSeq")
|
||||||
|
String equipBizSeq;
|
||||||
|
@JsonProperty("ConnectorID")
|
||||||
|
String connectorId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 操作结果
|
||||||
|
*/
|
||||||
|
//JsonProperty的作用是将该字段,按照所指定的key转换成json键值对。
|
||||||
|
@JsonProperty("SuccStat")
|
||||||
|
int succStat;
|
||||||
|
|
||||||
|
@JsonProperty("FailReason")
|
||||||
|
int failReason;
|
||||||
|
|
||||||
|
@JsonProperty("SumPeriod")
|
||||||
|
int sumPeriod;
|
||||||
|
|
||||||
|
@JsonProperty("PolicyInfos")
|
||||||
|
PolicyInfos[] policyInfos;
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,20 @@
|
|||||||
|
package com.xhpc.evcs.dto;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonAutoDetect;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
@JsonAutoDetect(fieldVisibility = JsonAutoDetect.Visibility.ANY, getterVisibility = JsonAutoDetect.Visibility.NONE,
|
||||||
|
setterVisibility = JsonAutoDetect.Visibility.NONE, creatorVisibility = JsonAutoDetect.Visibility.NONE)
|
||||||
|
public class PolicyInfos {
|
||||||
|
|
||||||
|
@JsonProperty("StartTime")
|
||||||
|
String startTime;
|
||||||
|
@JsonProperty("ElecPrice")
|
||||||
|
double elecPrice;
|
||||||
|
@JsonProperty("ServicePrice")
|
||||||
|
double servicePrice;
|
||||||
|
}
|
||||||
@ -0,0 +1,128 @@
|
|||||||
|
package com.xhpc.evcs.api;
|
||||||
|
|
||||||
|
import com.xhpc.common.data.redis.CacheRateModel;
|
||||||
|
import com.xhpc.common.domain.XhpcTerminal;
|
||||||
|
import com.xhpc.evcs.dto.EquipBizRequest;
|
||||||
|
import com.xhpc.evcs.dto.EquipBizResponse;
|
||||||
|
import com.xhpc.evcs.dto.PolicyInfos;
|
||||||
|
import com.xhpc.evcs.jpa.XhpcTerminalRepository;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
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.RestController;
|
||||||
|
|
||||||
|
import java.util.*;
|
||||||
|
|
||||||
|
import static com.xhpc.common.data.redis.StaticBeanUtil.REDIS;
|
||||||
|
|
||||||
|
@Slf4j
|
||||||
|
@RestController
|
||||||
|
public class QueryEquipBusinessPolicyController {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private XhpcTerminalRepository XhpcTerminalRepository;
|
||||||
|
|
||||||
|
@PostMapping("/v1/query_equip_business_policy")
|
||||||
|
public EquipBizResponse queryEquipBusinessPolicy(@RequestBody EquipBizRequest equipBizRequest) {
|
||||||
|
//获取充电设备接口编码(枪编码)
|
||||||
|
String connectorId = equipBizRequest.getConnectorId();
|
||||||
|
//获取枪所对应的桩编码
|
||||||
|
Optional<XhpcTerminal> bySerialNumber = XhpcTerminalRepository.findBySerialNumber(connectorId);
|
||||||
|
XhpcTerminal xhpcTerminal = bySerialNumber.get();
|
||||||
|
String pileSerialNumber = xhpcTerminal.getPileSerialNumber();
|
||||||
|
//通过桩编码,进入redis,找到其所用的费率模型id
|
||||||
|
Map<String, Object> cacheMap = REDIS.getCacheMap("pile:" + pileSerialNumber);
|
||||||
|
Long rateModelId = (Long) cacheMap.get("rateModelId");
|
||||||
|
//通过指定费率模型id,找到其对应的费率模型
|
||||||
|
CacheRateModel rateModel = REDIS.getCacheObject("rateModel:" + rateModelId);
|
||||||
|
String[] tfPricesSeq = rateModel.getTfPricesSeq();
|
||||||
|
|
||||||
|
//查询所需要的数据
|
||||||
|
EquipBizResponse equipBizResponse = load(tfPricesSeq,equipBizRequest);
|
||||||
|
|
||||||
|
|
||||||
|
/*//遍历获取每一个值
|
||||||
|
ArrayList<String> intervalList = new ArrayList<>();
|
||||||
|
|
||||||
|
//添加计数器:
|
||||||
|
int flag = 0;
|
||||||
|
for (int i = 0; i < tfPricesSeq.length-1; i++) {
|
||||||
|
if (!tfPricesSeq[i].equals(tfPricesSeq[i+1])){
|
||||||
|
intervalList.add(tfPricesSeq[i]);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (String value : tfPricesSeq) {
|
||||||
|
if(!value.equals(store)){
|
||||||
|
flag = 0; //将计数器置为0
|
||||||
|
}
|
||||||
|
flag++;
|
||||||
|
store = value;
|
||||||
|
}*/
|
||||||
|
return equipBizResponse;
|
||||||
|
}
|
||||||
|
|
||||||
|
public EquipBizResponse load(String[] arr,EquipBizRequest equipBizRequest) {
|
||||||
|
Map<String, String> priceMap = new HashMap<>();
|
||||||
|
Map<String, String> svcPriceMap = new HashMap<>();
|
||||||
|
String[] keys = {"01","02","03","04"};
|
||||||
|
String[] values1 = {"t1Price","t2Price","t3Price","t4Price"};
|
||||||
|
String[] values2 = {"t1SvcPrice","t2SvcPrice","t3SvcPrice","t4SvcPrice"};
|
||||||
|
for(int i = 0; i < keys.length; i ++){
|
||||||
|
priceMap.put(keys[i],values1[i]);
|
||||||
|
svcPriceMap.put(keys[i],values2[i]);
|
||||||
|
}
|
||||||
|
List<String> timeSigns = new ArrayList<>();
|
||||||
|
List<Integer> locations = new ArrayList<>();
|
||||||
|
for (int i = 0; i < arr.length - 1; i++) {
|
||||||
|
if (arr[i].equals(arr[i + 1])) {
|
||||||
|
timeSigns.add(arr[i]);
|
||||||
|
locations.add(i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
timeSigns.add(arr[arr.length - 1]);
|
||||||
|
locations.add(arr.length - 1);
|
||||||
|
List<Integer> time = new ArrayList<>();
|
||||||
|
time.add(0);
|
||||||
|
time.add(locations.get(0));
|
||||||
|
for (int i = 1; i < locations.size(); i++) {
|
||||||
|
time.add(locations.get(i - 1));
|
||||||
|
time.add(locations.get(i));
|
||||||
|
}
|
||||||
|
List<Integer> startTimes = new ArrayList<>();
|
||||||
|
List<Double> priceResult = new ArrayList<>();
|
||||||
|
List<Double> svcPriceResult = new ArrayList<>();
|
||||||
|
for(int i = 0, j = 0; i < locations.size(); i += 2, j ++){
|
||||||
|
priceResult.add(REDIS.getCacheObject(priceMap.get(timeSigns.get(j))));
|
||||||
|
svcPriceResult.add(REDIS.getCacheObject(svcPriceMap.get(timeSigns.get(j))));
|
||||||
|
startTimes.add((int) (i * 10000 * 0.5));
|
||||||
|
}
|
||||||
|
PolicyInfos[] repsData = new PolicyInfos[startTimes.size()];
|
||||||
|
for(int i = 0; i < startTimes.size(); i ++){
|
||||||
|
PolicyInfos policyInfos = new PolicyInfos();
|
||||||
|
policyInfos.setStartTime(String.valueOf(startTimes.get(i)));
|
||||||
|
policyInfos.setElecPrice(priceResult.get(i));
|
||||||
|
policyInfos.setServicePrice(svcPriceResult.get(i));
|
||||||
|
repsData[i] = policyInfos;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//封装数据
|
||||||
|
EquipBizResponse equipBizResponse = new EquipBizResponse();
|
||||||
|
equipBizResponse.setEquipBizSeq(equipBizRequest.getEquipBizSeq());
|
||||||
|
equipBizResponse.setConnectorId(equipBizRequest.getConnectorId());
|
||||||
|
equipBizResponse.setSuccStat(0);
|
||||||
|
equipBizResponse.setFailReason(0);
|
||||||
|
equipBizResponse.setSumPeriod(3);
|
||||||
|
equipBizResponse.setPolicyInfos(repsData);
|
||||||
|
|
||||||
|
return equipBizResponse;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,16 @@
|
|||||||
|
package com.xhpc.evcs.jpa;
|
||||||
|
|
||||||
|
import com.xhpc.evcs.domain.AuthSecretToken;
|
||||||
|
import com.xhpc.evcs.domain.XhpcChargingPile;
|
||||||
|
import com.xhpc.evcs.dto.EquipBizResponse;
|
||||||
|
import org.springframework.data.jpa.repository.JpaRepository;
|
||||||
|
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
|
||||||
|
import org.springframework.data.repository.query.QueryByExampleExecutor;
|
||||||
|
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
|
public interface EquipBizPolicyRepository extends JpaRepository<XhpcChargingPile, String>,
|
||||||
|
QueryByExampleExecutor<XhpcChargingPile>, JpaSpecificationExecutor<XhpcChargingPile> {
|
||||||
|
|
||||||
|
Optional<XhpcChargingPile> findByConnectorId(String connectorId);
|
||||||
|
}
|
||||||
@ -0,0 +1,24 @@
|
|||||||
|
package com.xhpc.evcs.jpa;
|
||||||
|
|
||||||
|
import com.xhpc.common.domain.XhpcTerminal;
|
||||||
|
import com.xhpc.evcs.domain.XhpcChargingPile;
|
||||||
|
import org.springframework.data.jpa.repository.JpaRepository;
|
||||||
|
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
|
||||||
|
import org.springframework.data.repository.query.QueryByExampleExecutor;
|
||||||
|
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* SpringJPA框架,DAO层
|
||||||
|
* 继承三个接口,泛型为将记录封装到哪个实体类对象中。
|
||||||
|
*/
|
||||||
|
public interface XhpcTerminalRepository extends JpaRepository<XhpcTerminal, String>,
|
||||||
|
QueryByExampleExecutor<XhpcTerminal>, JpaSpecificationExecutor<XhpcTerminal> {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 通过枪序列号查询到枪所在的桩的桩编码
|
||||||
|
* @param serialNumber
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
Optional<XhpcTerminal> findBySerialNumber(String serialNumber);
|
||||||
|
}
|
||||||
@ -28,7 +28,6 @@
|
|||||||
<spring-boot.version>2.5.1</spring-boot.version>
|
<spring-boot.version>2.5.1</spring-boot.version>
|
||||||
<spring-cloud.version>2020.0.3</spring-cloud.version>
|
<spring-cloud.version>2020.0.3</spring-cloud.version>
|
||||||
<spring-cloud-alibaba.version>2021.1</spring-cloud-alibaba.version>
|
<spring-cloud-alibaba.version>2021.1</spring-cloud-alibaba.version>
|
||||||
<alibaba.nacos.version>2.0.2</alibaba.nacos.version>
|
|
||||||
<spring-boot-admin.version>2.4.1</spring-boot-admin.version>
|
<spring-boot-admin.version>2.4.1</spring-boot-admin.version>
|
||||||
<swagger.fox.version>3.0.0</swagger.fox.version>
|
<swagger.fox.version>3.0.0</swagger.fox.version>
|
||||||
<swagger.core.version>1.6.2</swagger.core.version>
|
<swagger.core.version>1.6.2</swagger.core.version>
|
||||||
|
|||||||
@ -53,7 +53,7 @@ public class QrImgUtils {
|
|||||||
// 创建OSSClient实例
|
// 创建OSSClient实例
|
||||||
OSSClient ossClient = new OSSClient(environment.getProperty("oss.endpoint"), environment.getProperty("oss.access-key"), environment.getProperty("oss.secret-key"));
|
OSSClient ossClient = new OSSClient(environment.getProperty("oss.endpoint"), environment.getProperty("oss.access-key"), environment.getProperty("oss.secret-key"));
|
||||||
// 上传文件流
|
// 上传文件流
|
||||||
ossClient.putObject(environment.getProperty("oss.bucket-name"), xhpcTerminal.getPileSerialNumber() + "/" + finallyImgFileName, new File(environment.getProperty("destPath") +finallyImgFileName));
|
ossClient.putObject(environment.getProperty("oss.bucket-name"), xhpcTerminal.getPileSerialNumber() + "/" + finallyImgFileName, new File(environment.getProperty("oss.destPath") + "\\" + finallyImgFileName));
|
||||||
ossClient.shutdown();
|
ossClient.shutdown();
|
||||||
|
|
||||||
//5.将放在阿里云上的生成的图片的路径和图片所对应的终端的id放入数据库xhpc_img表中
|
//5.将放在阿里云上的生成的图片的路径和图片所对应的终端的id放入数据库xhpc_img表中
|
||||||
@ -61,10 +61,10 @@ public class QrImgUtils {
|
|||||||
xhpcImgMapper.insert(xhpcTerminal.getPileSerialNumber() + "/" + finallyImgFileName, terminalId);
|
xhpcImgMapper.insert(xhpcTerminal.getPileSerialNumber() + "/" + finallyImgFileName, terminalId);
|
||||||
|
|
||||||
//6.删除生成的二维码图片
|
//6.删除生成的二维码图片
|
||||||
File QrImg = new File(environment.getProperty("destPath") + qrFileName);
|
File QrImg = new File(environment.getProperty("oss.destPath") + "\\" + qrFileName);
|
||||||
QrImg.delete();
|
QrImg.delete();
|
||||||
//7.删除生成本地生成的完整图片
|
//7.删除生成本地生成的完整图片
|
||||||
File finallyImg = new File(environment.getProperty("fullImgDestPath") + finallyImgFileName);
|
File finallyImg = new File(environment.getProperty("oss.fullImgDestPath") + finallyImgFileName);
|
||||||
finallyImg.delete();
|
finallyImg.delete();
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
|||||||
@ -0,0 +1,295 @@
|
|||||||
|
/*
|
||||||
|
package com.xhpc.test.excel;
|
||||||
|
|
||||||
|
import com.xhpc.common.domain.XhpcChargingPile;
|
||||||
|
import org.apache.poi.ss.usermodel.*;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
*/
|
||||||
|
/**
|
||||||
|
* 读取Excel表格工具类
|
||||||
|
*//*
|
||||||
|
|
||||||
|
public class ReadExcelUtil {
|
||||||
|
|
||||||
|
private void parseExcel(){}
|
||||||
|
private void dataToDatabase(){}
|
||||||
|
private void writeToExcel(){}
|
||||||
|
|
||||||
|
public static void main(String[] args) throws IOException {
|
||||||
|
|
||||||
|
//1.存储要读取的Excel的文件路径
|
||||||
|
String pileExcelPath = "D:\\Enterprise_Resources\\XiaoHuaMaterialImgs\\pile.xlsx";
|
||||||
|
|
||||||
|
//2.加载Excel进内存
|
||||||
|
File pileExcel = new File(pileExcelPath);
|
||||||
|
|
||||||
|
//3.创建Workbook对象,将其转换成可操作的Excel
|
||||||
|
Workbook workBook = WorkbookFactory.create(pileExcel);
|
||||||
|
|
||||||
|
//4.获取Excel表中的sheet1表
|
||||||
|
Sheet sheet1 = workBook.getSheet("Sheet1");
|
||||||
|
|
||||||
|
//5.获取sheet1表的名称
|
||||||
|
String sheetName = sheet1.getSheetName();
|
||||||
|
|
||||||
|
System.out.println("工作表名称:"+sheetName);
|
||||||
|
|
||||||
|
//6.获取工作表的总行数
|
||||||
|
int totalRows = sheet1.getPhysicalNumberOfRows();
|
||||||
|
System.out.println("当前工作表总行数:"+totalRows);
|
||||||
|
|
||||||
|
//7.获取工作表中的总列数
|
||||||
|
//7.1获取第一行的记录,行索引从0开始的
|
||||||
|
Row twoRow = sheet1.getRow(2);
|
||||||
|
int totalColumns = twoRow.getPhysicalNumberOfCells();
|
||||||
|
System.out.println("当前sheet表中的总列数:"+totalColumns);
|
||||||
|
|
||||||
|
//8.获取第二行的记录中的第一个单元格,单元格索引从0开始
|
||||||
|
Cell cell = twoRow.getCell(0);
|
||||||
|
String pileName = cell.getStringCellValue();
|
||||||
|
System.out.println("电桩名称为:"+pileName);
|
||||||
|
|
||||||
|
//9.获取第二行的记录中的第二个单元格
|
||||||
|
Cell cell2 = twoRow.getCell(1);
|
||||||
|
String brandModel = cell2.getStringCellValue();
|
||||||
|
System.out.println("品牌型号为:"+brandModel);
|
||||||
|
|
||||||
|
//10.获取第二行的记录中的第三个单元格
|
||||||
|
Cell cell3 = twoRow.getCell(2);
|
||||||
|
String pileNational = cell3.getStringCellValue();
|
||||||
|
System.out.println("电桩国际:"+pileNational);
|
||||||
|
|
||||||
|
//11.获取第二行的记录中的第四个单元格
|
||||||
|
Cell cell4 = twoRow.getCell(3);
|
||||||
|
String pilePower = cell4.getStringCellValue();
|
||||||
|
System.out.println("电桩功率:"+pilePower);
|
||||||
|
|
||||||
|
//12.获取第二行的记录中的第五个单元格
|
||||||
|
Cell cell5 = twoRow.getCell(4);
|
||||||
|
int powerSupport = (int) cell5.getNumericCellValue();
|
||||||
|
System.out.println("辅助电源支持:"+powerSupport);
|
||||||
|
|
||||||
|
//13.获取第二行的记录中的第六个单元格
|
||||||
|
Cell cell6 = twoRow.getCell(5);
|
||||||
|
int inputVoltage = (int) cell6.getNumericCellValue();
|
||||||
|
System.out.println("输入电压:"+inputVoltage);
|
||||||
|
|
||||||
|
//14.获取第二行的记录中的第六个单元格
|
||||||
|
Cell cell7 = twoRow.getCell(6);
|
||||||
|
int maxVoltage = (int) cell7.getNumericCellValue();
|
||||||
|
System.out.println("最大电压:"+maxVoltage);
|
||||||
|
|
||||||
|
//15.获取第二行的记录中的第七个单元格
|
||||||
|
Cell cell8 = twoRow.getCell(7);
|
||||||
|
int minVoltage = (int) cell8.getNumericCellValue();
|
||||||
|
System.out.println("最小电压:"+minVoltage);
|
||||||
|
|
||||||
|
//16.获取第二行的记录中的第八个单元格
|
||||||
|
Cell cell9 = twoRow.getCell(8);
|
||||||
|
int maxCurrent = (int) cell9.getNumericCellValue();
|
||||||
|
System.out.println("最大电流:"+maxCurrent);
|
||||||
|
|
||||||
|
//17.获取第二行的记录中的第九个单元格
|
||||||
|
Cell cell10 = twoRow.getCell(9);
|
||||||
|
int minCurrent = (int) cell10.getNumericCellValue();
|
||||||
|
System.out.println("最小电流:"+minCurrent);
|
||||||
|
|
||||||
|
//18.获取第二行的记录中的第十个单元格
|
||||||
|
Cell cell11 = twoRow.getCell(10);
|
||||||
|
String pileNumber = cell11.getStringCellValue();
|
||||||
|
System.out.println("桩编码:"+pileNumber);
|
||||||
|
|
||||||
|
//19.获取第二行的记录中的第十一个单元格
|
||||||
|
Cell cell12 = twoRow.getCell(11);
|
||||||
|
String StationName = cell12.getStringCellValue();
|
||||||
|
System.out.println("场站名称:"+StationName);
|
||||||
|
|
||||||
|
//20.获取第二行的记录中的第十二个单元格
|
||||||
|
Cell cell13 = twoRow.getCell(12);
|
||||||
|
String terminalCount = cell13.getStringCellValue();
|
||||||
|
System.out.println("终端数量:"+terminalCount);
|
||||||
|
|
||||||
|
//21.获取第二行的记录中的第十三个单元格
|
||||||
|
Cell cell14 = twoRow.getCell(13);
|
||||||
|
String pileType = cell14.getStringCellValue();
|
||||||
|
System.out.println("电桩类型:"+pileType);
|
||||||
|
|
||||||
|
System.out.println("==================分割线====================");
|
||||||
|
|
||||||
|
for (int i = 0;i<twoRow.getPhysicalNumberOfCells();i++){
|
||||||
|
//获取该行中的每一个单元格对象
|
||||||
|
Cell cellf = twoRow.getCell(i);
|
||||||
|
|
||||||
|
//获取单元格对象类型
|
||||||
|
CellType cellType = cellf.getCellType();
|
||||||
|
String type = cellType.name();
|
||||||
|
|
||||||
|
//判断单元格对象类型
|
||||||
|
//如果单元格中的类型不是字符串的话,那么则调用获取数值类型的方法
|
||||||
|
if (!type.equals("STRING")){
|
||||||
|
//获取该单元格中的值
|
||||||
|
int cellValue = (int) cellf.getNumericCellValue();
|
||||||
|
System.out.println(cellValue);
|
||||||
|
}else {
|
||||||
|
//获取该单元格中的值
|
||||||
|
String cellValue = cellf.getStringCellValue();
|
||||||
|
System.out.println(cellValue);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
System.out.println("================分割线2====================");
|
||||||
|
new ReadExcelUtil().getOneRowWithHeader(sheet1.getRow(0),sheet1.getRow(1));
|
||||||
|
workBook.close();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
*/
|
||||||
|
/**
|
||||||
|
* 获取一行记录的数据(带标题)
|
||||||
|
* @param headerRow 标题行
|
||||||
|
* @param row 获取第几行
|
||||||
|
*//*
|
||||||
|
|
||||||
|
public void getOneRowWithHeader(Row headerRow,Row row){
|
||||||
|
|
||||||
|
XhpcChargingPile xhpcChargingPile = new XhpcChargingPile();
|
||||||
|
|
||||||
|
HashMap<String, Object> storeMap = new HashMap<>();
|
||||||
|
|
||||||
|
for (int i = 0;i<headerRow.getPhysicalNumberOfCells();i++){
|
||||||
|
//获取标题行中的每一个单元格对象
|
||||||
|
Cell headerCell = headerRow.getCell(i);
|
||||||
|
|
||||||
|
//获取单元格对象类型
|
||||||
|
CellType cellType = headerCell.getCellType();
|
||||||
|
String type = cellType.name();
|
||||||
|
|
||||||
|
//获取标题行单元格中的值
|
||||||
|
String headerCellValue = headerCell.getStringCellValue();
|
||||||
|
|
||||||
|
//获取与标题行对应的普通单元格内容
|
||||||
|
Cell plainCell = row.getCell(i);
|
||||||
|
|
||||||
|
//判断单元格对象类型
|
||||||
|
//如果单元格中的类型不是字符串的话,那么则调用获取数值类型的方法
|
||||||
|
CellType cellType1 = plainCell.getCellType();
|
||||||
|
String type1 = cellType1.name();
|
||||||
|
|
||||||
|
if (!type1.equals("STRING")){
|
||||||
|
//获取该单元格中的值
|
||||||
|
int cellValue = (int) plainCell.getNumericCellValue();
|
||||||
|
System.out.println(headerCellValue+":"+cellValue);
|
||||||
|
|
||||||
|
//判断headerCellValue当中的值,放入到pojo中
|
||||||
|
switch (headerCellValue){
|
||||||
|
case "桩编码":
|
||||||
|
storeMap.put("pileSerialNumber",cellValue);
|
||||||
|
break;
|
||||||
|
case "电站":
|
||||||
|
storeMap.put("StationName",cellValue);
|
||||||
|
break;
|
||||||
|
case "终端数量":
|
||||||
|
storeMap.put("terminalCount",cellValue);
|
||||||
|
break;
|
||||||
|
case "电桩类型":
|
||||||
|
storeMap.put("pileType",cellValue);
|
||||||
|
break;
|
||||||
|
case "程序版本":
|
||||||
|
storeMap.put("programVersion",cellValue);
|
||||||
|
break;
|
||||||
|
case "网络连接类型":
|
||||||
|
storeMap.put("networkLinkType",cellValue);
|
||||||
|
break;
|
||||||
|
case "通讯协议版本":
|
||||||
|
storeMap.put("communicationProtocolVersion",cellValue);
|
||||||
|
break;
|
||||||
|
case "通讯运营商":
|
||||||
|
storeMap.put("communicationOperator",cellValue);
|
||||||
|
break;
|
||||||
|
case "SIMK":
|
||||||
|
storeMap.put("terminalCount",cellValue);
|
||||||
|
break;
|
||||||
|
case "终端数量":
|
||||||
|
storeMap.put("terminalCount",cellValue);
|
||||||
|
break;
|
||||||
|
case "终端数量":
|
||||||
|
storeMap.put("terminalCount",cellValue);
|
||||||
|
break;
|
||||||
|
case "终端数量":
|
||||||
|
storeMap.put("terminalCount",cellValue);
|
||||||
|
break;case "终端数量":
|
||||||
|
storeMap.put("terminalCount",cellValue);
|
||||||
|
break;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
}else {
|
||||||
|
//获取该单元格中的值
|
||||||
|
String cellValue = plainCell.getStringCellValue();
|
||||||
|
System.out.println(headerCellValue + ":" + cellValue);
|
||||||
|
switch (headerCellValue){
|
||||||
|
case "电桩名称":
|
||||||
|
xhpcChargingPile.setName(cellValue);
|
||||||
|
break;
|
||||||
|
case "品牌型号":
|
||||||
|
xhpcChargingPile.setBrandModel(cellValue);
|
||||||
|
break;
|
||||||
|
case "电桩国际":
|
||||||
|
xhpcChargingPile.setNationalStandard(cellValue);
|
||||||
|
break;
|
||||||
|
case "电桩功率(KW)":
|
||||||
|
xhpcChargingPile.setPower(Double.parseDouble(cellValue));
|
||||||
|
break;
|
||||||
|
case "辅助电源支持(V)":
|
||||||
|
xhpcChargingPile.put("powerSupport",cellValue);
|
||||||
|
break;
|
||||||
|
case "输入电压(V)":
|
||||||
|
xhpcChargingPile.put("inputVoltage",cellValue);
|
||||||
|
break;
|
||||||
|
case "最大电压(V)":
|
||||||
|
xhpcChargingPile.put("maxVoltage",cellValue);
|
||||||
|
break;
|
||||||
|
case "最小电压(V)":
|
||||||
|
xhpcChargingPile.put("minVoltage",cellValue);
|
||||||
|
break;
|
||||||
|
case "最大电流(A)":
|
||||||
|
xhpcChargingPile.put("maxCurrent",cellValue);
|
||||||
|
break;
|
||||||
|
case "最小电流(A)":
|
||||||
|
xhpcChargingPile.put("minCurrent",cellValue);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// for (int i = 0;i<row.getPhysicalNumberOfCells();i++){
|
||||||
|
// //获取该行中的每一个单元格对象
|
||||||
|
// Cell plainCell = row.getCell(i);
|
||||||
|
//
|
||||||
|
// //获取单元格对象类型
|
||||||
|
// CellType cellType = plainCell.getCellType();
|
||||||
|
// String plainCell = cellType.name();
|
||||||
|
//
|
||||||
|
// //判断单元格对象类型
|
||||||
|
// //如果单元格中的类型不是字符串的话,那么则调用获取数值类型的方法
|
||||||
|
// if (!type.equals("STRING")){
|
||||||
|
// //获取该单元格中的值
|
||||||
|
// int cellValue = (int) plainCell.getNumericCellValue();
|
||||||
|
// System.out.println(cellValue);
|
||||||
|
// }else {
|
||||||
|
// //获取该单元格中的值
|
||||||
|
// String cellValue = plainCell.getStringCellValue();
|
||||||
|
// System.out.println(cellValue);
|
||||||
|
// }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
*/
|
||||||
Loading…
x
Reference in New Issue
Block a user