Przeglądaj źródła

[电表][修复]:电表导入数字字段时报错问题

release_toaliyun_real
hupeng 6 lat temu
rodzic
commit
1a78dc8e15
1 zmienionych plików z 10 dodań i 8 usunięć
  1. +10
    -8
      mallinkAdmin/src/main/java/com/iformall/controller/device/KwMeterController.java

+ 10
- 8
mallinkAdmin/src/main/java/com/iformall/controller/device/KwMeterController.java Wyświetl plik

@@ -24,7 +24,9 @@ import org.apache.poi.hssf.usermodel.HSSFSheet;
import org.apache.poi.hssf.usermodel.HSSFWorkbook; import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.poifs.filesystem.POIFSFileSystem; import org.apache.poi.poifs.filesystem.POIFSFileSystem;
import org.apache.poi.ss.usermodel.Cell; import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.CellType;
import org.apache.poi.ss.usermodel.Row; import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.xssf.usermodel.XSSFCell;
import org.apache.poi.xssf.usermodel.XSSFRow; import org.apache.poi.xssf.usermodel.XSSFRow;
import org.apache.poi.xssf.usermodel.XSSFSheet; import org.apache.poi.xssf.usermodel.XSSFSheet;
import org.apache.poi.xssf.usermodel.XSSFWorkbook; import org.apache.poi.xssf.usermodel.XSSFWorkbook;
@@ -202,22 +204,22 @@ public class KwMeterController extends BaseController {
continue; continue;
KwMeter kwMeter = new KwMeter(); KwMeter kwMeter = new KwMeter();
Cell c = row.getCell(0,Row.MissingCellPolicy.RETURN_BLANK_AS_NULL); Cell c = row.getCell(0,Row.MissingCellPolicy.RETURN_BLANK_AS_NULL);
if (c != null) {
if (c != null && c.getCellType() == CellType.STRING ) {
kwMeter.setAddress(c.getStringCellValue()); kwMeter.setAddress(c.getStringCellValue());
} else { } else {
continue; continue;
} }
c = row.getCell(1,Row.MissingCellPolicy.RETURN_BLANK_AS_NULL); c = row.getCell(1,Row.MissingCellPolicy.RETURN_BLANK_AS_NULL);
if (c != null) {kwMeter.setPlace(c.getStringCellValue());}
if (c != null && c.getCellType() == CellType.STRING ) {kwMeter.setPlace(c.getStringCellValue());}
c = row.getCell(2,Row.MissingCellPolicy.RETURN_BLANK_AS_NULL); c = row.getCell(2,Row.MissingCellPolicy.RETURN_BLANK_AS_NULL);
if (c != null) {kwMeter.setBrand(c.getStringCellValue());}
if (c != null && c.getCellType() == CellType.STRING ) {kwMeter.setBrand(c.getStringCellValue());}
c = row.getCell(3,Row.MissingCellPolicy.RETURN_BLANK_AS_NULL); c = row.getCell(3,Row.MissingCellPolicy.RETURN_BLANK_AS_NULL);
if (c != null) {kwMeter.setModel(c.getStringCellValue());}
if (c != null && c.getCellType() == CellType.STRING ) {kwMeter.setModel(c.getStringCellValue());}


c = row.getCell(4,Row.MissingCellPolicy.RETURN_BLANK_AS_NULL); c = row.getCell(4,Row.MissingCellPolicy.RETURN_BLANK_AS_NULL);
if (c != null) {kwMeter.setProtocol(Integer.parseInt(c.getStringCellValue()));}
if (c != null && c.getCellType() == CellType.STRING ) {kwMeter.setProtocol(Integer.parseInt(c.getStringCellValue()));}
c = row.getCell(5,Row.MissingCellPolicy.RETURN_BLANK_AS_NULL); c = row.getCell(5,Row.MissingCellPolicy.RETURN_BLANK_AS_NULL);
if (c != null) {kwMeter.setBandrate(Integer.parseInt(c.getStringCellValue()));}
if (c != null && c.getCellType() == CellType.STRING ) {kwMeter.setBandrate(Integer.parseInt(c.getStringCellValue()));}


if (kwMeter.getProtocol() != null || kwMeter.getBandrate() != null) { if (kwMeter.getProtocol() != null || kwMeter.getBandrate() != null) {
JSONObject jsonObject = new JSONObject(); JSONObject jsonObject = new JSONObject();
@@ -227,7 +229,7 @@ public class KwMeterController extends BaseController {
} }


c = row.getCell(6,Row.MissingCellPolicy.RETURN_BLANK_AS_NULL); c = row.getCell(6,Row.MissingCellPolicy.RETURN_BLANK_AS_NULL);
if (c != null) {
if (c != null && c.getCellType() == CellType.STRING ) {
String imei = c.getStringCellValue(); String imei = c.getStringCellValue();
KwBox kwBox = new KwBox(); KwBox kwBox = new KwBox();
kwBox.setImei(imei); kwBox.setImei(imei);
@@ -243,7 +245,7 @@ public class KwMeterController extends BaseController {
addOrUpdate(kwMeter); addOrUpdate(kwMeter);


c = row.getCell(7,Row.MissingCellPolicy.RETURN_BLANK_AS_NULL); c = row.getCell(7,Row.MissingCellPolicy.RETURN_BLANK_AS_NULL);
if (c != null) {
if (c != null && c.getCellType() == CellType.STRING ) {
String merchantName = c.getStringCellValue(); String merchantName = c.getStringCellValue();
Optional<WxMerchant> wxMerchant = wxMerchantService.findByName(merchantName); Optional<WxMerchant> wxMerchant = wxMerchantService.findByName(merchantName);
if (wxMerchant.isPresent()) { if (wxMerchant.isPresent()) {


Ładowanie…
Anuluj
Zapisz