Commit 6fab7ef5 authored by jichao's avatar jichao

上传参数模板,当没有参数code时,不保存

parent c72c009d
......@@ -132,42 +132,47 @@ public class ParamLibraryServiceImpl implements ParamLibraryService {
String code1 = this.getCode(sheet, 3),
code2 = this.getCode(sheet, 4),
code3 = this.getCode(sheet, 5);
//读取需要保存的数据
for (int i = 8; i < sheet.getLastRowNum() + 1; i++) {
BusParamLibrary b = new BusParamLibrary();
HSSFRow row = sheet.getRow(i);
if (row != null) {
String power = this.getValue(row.getCell(1));//功率
String speed = this.getValue(row.getCell(2));//用气速率
String code1Value = this.getValue(row.getCell(3));//参数1
String code2Value = this.getValue(row.getCell(4));//参数2
String code3Value = this.getValue(row.getCell(5));//参数3
//如果都为null,表明已经没有数据,跳出循环
if (power == null && speed == null && code1Value == null && code2Value == null && code3Value == null) break;
//赋值
//如果code1、2、3都没有值,表示没有添加参数模板
if (code1 == null && code2 == null && code3 == null) {
} else {
//读取需要保存的数据
for (int i = 8; i < sheet.getLastRowNum() + 1; i++) {
BusParamLibrary b = new BusParamLibrary();
HSSFRow row = sheet.getRow(i);
if (row != null) {
String power = this.getValue(row.getCell(1));//功率
String speed = this.getValue(row.getCell(2));//用气速率
String code1Value = this.getValue(row.getCell(3));//参数1
String code2Value = this.getValue(row.getCell(4));//参数2
String code3Value = this.getValue(row.getCell(5));//参数3
//如果都为null,表明已经没有数据,跳出循环
if (power == null && speed == null && code1Value == null && code2Value == null && code3Value == null) break;
//赋值
b.setDevNum(devNum);
b.setPower(power == null ? null : new BigDecimal(power));
b.setGasSpeed(speed == null ? null : new BigDecimal(speed));
b.setYear(year);
b.setP1(code1);
b.setP1V(code1Value == null ? null : new BigDecimal(code1Value));
b.setP2(code2);
b.setP2V(code2Value == null ? null : new BigDecimal(code2Value));
b.setP3(code3);
b.setP3V(code3Value == null ? null : new BigDecimal(code3Value));
resultList.add(b);
}
}
//先删除数据库的数据,再保存
if (resultList.size() > 0) {
BusParamLibrary b = new BusParamLibrary();
b.setDevNum(devNum);
b.setPower(power == null ? null : new BigDecimal(power));
b.setGasSpeed(speed == null ? null : new BigDecimal(speed));
b.setYear(year);
b.setP1(code1);
b.setP1V(code1Value == null ? null : new BigDecimal(code1Value));
b.setP2(code2);
b.setP2V(code2Value == null ? null : new BigDecimal(code2Value));
b.setP3(code3);
b.setP3V(code3Value == null ? null : new BigDecimal(code3Value));
resultList.add(b);
//先删除
paramLibraryRepository.delete(b);
//添加
result = paramLibraryRepository.saveBusParamLibraryList(resultList);
}
}
//先删除数据库的数据,再保存
if (resultList.size() > 0) {
BusParamLibrary b = new BusParamLibrary();
b.setDevNum(devNum);
b.setYear(year);
//先删除
paramLibraryRepository.delete(b);
//添加
result = paramLibraryRepository.saveBusParamLibraryList(resultList);
}
} catch (IOException e) {
e.printStackTrace();
} finally {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment