excel解析二维数组结构的excel

public void fileImport(Ufile ufile) throws Exception {
String filePath = ufile.getFilePath();
List<AuthTransaction> parseResult = ExcelUtils.parseExcelInterface(filePath, new ParseExcelSheets<AuthTransaction>() {
@Override
public List<AuthTransaction> doParse(List<Sheet> sheets) {
List<AuthTransaction> tempResult = new ArrayList<AuthTransaction>();
DecimalFormat df = new DecimalFormat("0");
for (Sheet sheet : sheets) {
int rowCount = sheet.getPhysicalNumberOfRows();// 总行数
int startRowIndex = 1;
int endRowIndex = rowCount;
int startColumnIndex = 0;
int endColumnIndex = 50;
for (int i = startRowIndex; i < endRowIndex; i++) {
try {
int flag=0;
AuthTransaction authTransaction = new AuthTransaction();
Row row = sheet.getRow(i);
if(row==null){
break;
}
for (int j = startColumnIndex; j < endColumnIndex; j++) {
Cell cell = row.getCell(j);
if(cell==null){
flag=1;
break;
}
switch (j % endColumnIndex) {
case 0:// 年份 ->编号

if (cell.getCellType() == Cell.CELL_TYPE_NUMERIC) {
df = new DecimalFormat("########");
String cellValue = df.format(cell.getNumericCellValue());
authTransaction.setAuthApplicationNo(cellValue);
flag=0;
break;
//authTransaction.setAuthApplicationYear(cellValue);
} else if (cell.getCellType() == Cell.CELL_TYPE_STRING && StringUtils.isNotBlank(cell.getStringCellValue())) {
String cellValue = cell.getStringCellValue().trim();
if (DataUtils.isInteger(cellValue)) {
authTransaction.setAuthApplicationNo(cellValue);
}
flag=0;
break;
}else{
flag=1;
break;
}

case 1:// 编号->船名
if (cell != null && cell.getCellType() == Cell.CELL_TYPE_STRING && StringUtils.isNotBlank(cell.getStringCellValue())) {
String cellValue = cell.getStringCellValue().trim();
authTransaction.setShipName(cellValue);
//authTransaction.setAuthApplicationNo(cellValue);
}
break;
case 2:// 船名->船舶类型
if (cell != null && cell.getCellType() == Cell.CELL_TYPE_STRING && StringUtils.isNotBlank(cell.getStringCellValue())) {
String cellValue = cell.getStringCellValue().trim();
authTransaction.setShipTypeName(cellValue);
Dictionary dictionary = dictionaryService.getEntityByName(cellValue);
if (dictionary != null) {
authTransaction.setShipTypeId(dictionary.getId());
} else {
throw new ServiceException("请先在用户字典中维护船型:" + cellValue);
}
}
else {
throw new ServiceException(authTransaction.getShipName() + "为设置船型");
}
break;
/*if (cell != null && cell.getCellType() == Cell.CELL_TYPE_STRING && StringUtils.isNotBlank(cell.getStringCellValue())) {
String cellValue = cell.getStringCellValue().trim();
authTransaction.setShipName(cellValue);
}
break;*/
case 3:// 曾用名->船舶识别号
if (cell != null && cell.getCellType() == Cell.CELL_TYPE_STRING && StringUtils.isNotBlank(cell.getStringCellValue())) {
String cellValue = cell.getStringCellValue().trim();
authTransaction.setShipRegisterNo(cellValue);
} else if (cell != null && cell.getCellType() == Cell.CELL_TYPE_NUMERIC) {
String cellValue = df.format(cell.getNumericCellValue());
authTransaction.setShipRegisterNo(cellValue);
}
break;
/*if (cell != null && cell.getCellType() == Cell.CELL_TYPE_STRING && StringUtils.isNotBlank(cell.getStringCellValue())) {
String cellValue = cell.getStringCellValue().trim();
authTransaction.setShipFormerName(cellValue);
}
break;*/
case 4:// 船型->初次登记号码
if (cell != null && cell.getCellType() == Cell.CELL_TYPE_STRING && StringUtils.isNotBlank(cell.getStringCellValue())) {
String cellValue = cell.getStringCellValue().trim();
authTransaction.setFirstRegisterNo(cellValue);
} else if (cell != null && cell.getCellType() == Cell.CELL_TYPE_NUMERIC) {
String cellValue = df.format(cell.getNumericCellValue());
authTransaction.setFirstRegisterNo(cellValue);
}
break;
/*if (cell != null && cell.getCellType() == Cell.CELL_TYPE_STRING && StringUtils.isNotBlank(cell.getStringCellValue())) {
String cellValue = cell.getStringCellValue().trim();
authTransaction.setShipTypeName(cellValue);
Dictionary dictionary = dictionaryService.getEntityByName(cellValue);
if (dictionary != null) {
authTransaction.setShipTypeId(dictionary.getId());
} else {
throw new ServiceException("请先在用户字典中维护船型:" + cellValue);
}
} else {
throw new ServiceException(authTransaction.getShipName() + "为设置船型");
}
break;*/
case 5:// 船舶登记号->总吨
if (cell != null) {
if (cell.getCellType() == Cell.CELL_TYPE_NUMERIC) {
authTransaction.setGrossTon(cell.getNumericCellValue());
} else if (cell.getCellType() == Cell.CELL_TYPE_STRING && StringUtils.isNotBlank(cell.getStringCellValue())) {
String cellValue = cell.getStringCellValue().trim();
if (DataUtils.isNumeric(cellValue)) {
authTransaction.setGrossTon(Double.valueOf(cellValue));
}
}
}
break;
/*if (cell != null && cell.getCellType() == Cell.CELL_TYPE_STRING && StringUtils.isNotBlank(cell.getStringCellValue())) {
String cellValue = cell.getStringCellValue().trim();
authTransaction.setShipRegisterNo(cellValue);
} else if (cell != null && cell.getCellType() == Cell.CELL_TYPE_NUMERIC) {
String cellValue = df.format(cell.getNumericCellValue());
authTransaction.setShipRegisterNo(cellValue);
}
break;*/
case 6:// 总吨 ->净吨
if (cell != null) {
if (cell.getCellType() == Cell.CELL_TYPE_NUMERIC) {
authTransaction.setNetTon(cell.getNumericCellValue());
} else if (cell.getCellType() == Cell.CELL_TYPE_STRING && StringUtils.isNotBlank(cell.getStringCellValue())) {
String cellValue = cell.getStringCellValue().trim();
if (DataUtils.isNumeric(cellValue)) {
authTransaction.setNetTon(cell.getNumericCellValue());
}
}
}
break;
/* if (cell != null) {
if (cell.getCellType() == Cell.CELL_TYPE_NUMERIC) {
authTransaction.setGrossTon(cell.getNumericCellValue());
} else if (cell.getCellType() == Cell.CELL_TYPE_STRING && StringUtils.isNotBlank(cell.getStringCellValue())) {
String cellValue = cell.getStringCellValue().trim();
if (DataUtils.isNumeric(cellValue)) {
authTransaction.setGrossTon(Double.valueOf(cellValue));
}
}
}
break;*/
case 7:// 载重吨
if (cell != null) {
if (cell.getCellType() == Cell.CELL_TYPE_NUMERIC) {
authTransaction.setDeadWeight(cell.getNumericCellValue());
} else if (cell.getCellType() == Cell.CELL_TYPE_STRING && StringUtils.isNotBlank(cell.getStringCellValue())) {
String cellValue = cell.getStringCellValue().trim();
if (DataUtils.isNumeric(cellValue)) {
authTransaction.setDeadWeight(Double.valueOf(cellValue));
}
}
}
break;
case 8:// 船龄-> 成交价格
if (cell != null) {
if (cell.getCellType() == Cell.CELL_TYPE_NUMERIC) {
String cellValue = df.format(cell.getNumericCellValue());
if (DataUtils.isInteger(cellValue)) {
authTransaction.setPrice(Double.valueOf(cellValue));
}
} else if (cell.getCellType() == Cell.CELL_TYPE_STRING && StringUtils.isNotBlank(cell.getStringCellValue())) {
String cellValue = cell.getStringCellValue().trim();
if (DataUtils.isInteger(cellValue)) {
authTransaction.setPrice(Double.valueOf(cellValue));
}
}
}
break;
/*if (cell != null) {
if (cell.getCellType() == Cell.CELL_TYPE_NUMERIC) {
String cellValue = df.format(cell.getNumericCellValue());
if (DataUtils.isInteger(cellValue)) {
authTransaction.setShipAge(Integer.valueOf(cellValue));
}
} else if (cell.getCellType() == Cell.CELL_TYPE_STRING && StringUtils.isNotBlank(cell.getStringCellValue())) {
String cellValue = cell.getStringCellValue().trim();
if (DataUtils.isInteger(cellValue)) {
authTransaction.setShipAge(Integer.valueOf(cellValue));
}
}
}
break;*/
case 9:// 建造年份->成交日期
if (cell != null && HSSFDateUtil.isCellDateFormatted(cell)) {
authTransaction.setTradeDate(cell.getDateCellValue());
}
break;
/*if (cell != null && HSSFDateUtil.isCellDateFormatted(cell)) {
authTransaction.setBuildDate(cell.getDateCellValue());
}
break;*/
case 10:// 建造船厂->鉴证费
/*if (cell != null && cell.getCellType() == Cell.CELL_TYPE_STRING && StringUtils.isNotBlank(cell.getStringCellValue())) {
String cellValue = cell.getStringCellValue().trim();
authTransaction.setBuildShipyard(cellValue);
}
break;*/
if (cell != null) {
if (cell.getCellType() == Cell.CELL_TYPE_NUMERIC) {
authTransaction.setAuthCharge(cell.getNumericCellValue());
} else if (cell.getCellType() == Cell.CELL_TYPE_STRING && StringUtils.isNotBlank(cell.getStringCellValue())) {
String cellValue = cell.getStringCellValue().trim();
if (DataUtils.isNumeric(cellValue)) {
authTransaction.setAuthCharge(Double.valueOf(cellValue));
}
}
}
break;
case 11:// 船籍港->鉴证日期
/*if (cell != null && cell.getCellType() == Cell.CELL_TYPE_STRING && StringUtils.isNotBlank(cell.getStringCellValue())) {
String cellValue = cell.getStringCellValue().trim();
authTransaction.setHomePort(cellValue);
}
break;*/
if (cell != null && HSSFDateUtil.isCellDateFormatted(cell)) {
authTransaction.setAuthDate(cell.getDateCellValue());
}
break;
case 12:// 海、河船->船龄
if (cell != null) {
df = new DecimalFormat("#.0");
String cellValue = df.format(cell.getNumericCellValue());
authTransaction.setShipAge(Double.valueOf(cellValue));
/*if (cell.getCellType() == Cell.CELL_TYPE_NUMERIC) {
if (DataUtils.isNumeric(cellValue)) {
authTransaction.setShipAge(Double.valueOf(cellValue));
}
} else if (cell.getCellType() == Cell.CELL_TYPE_STRING && StringUtils.isNotBlank(cell.getStringCellValue())) {
cellValue = cell.getStringCellValue().trim();
if (DataUtils.isNumeric(cellValue)) {
authTransaction.setShipAge(Double.valueOf(cellValue));
}
}*/
}
break;
/*authTransaction.setIsShip(0);//默认河船
if (cell != null && cell.getCellType() == Cell.CELL_TYPE_STRING && StringUtils.isNotBlank(cell.getStringCellValue())) {
String cellValue = cell.getStringCellValue().trim();
if (cellValue.equals("海船")) {
authTransaction.setIsShip(1);
}
}
break;*/
case 13:// 船级->建造年份
if (cell != null && HSSFDateUtil.isCellDateFormatted(cell)) {
authTransaction.setBuildDate(cell.getDateCellValue());
}
break;
/*if (cell != null && cell.getCellType() == Cell.CELL_TYPE_STRING && StringUtils.isNotBlank(cell.getStringCellValue())) {
String cellValue = cell.getStringCellValue().trim();
authTransaction.setClassificationSociety(cellValue);
}
break;*/
case 14:// 航区 ->建造船厂
if (cell != null && cell.getCellType() == Cell.CELL_TYPE_STRING && StringUtils.isNotBlank(cell.getStringCellValue())) {
String cellValue = cell.getStringCellValue().trim();
authTransaction.setBuildShipyard(cellValue);
}
break;
/*if (cell != null && cell.getCellType() == Cell.CELL_TYPE_STRING && StringUtils.isNotBlank(cell.getStringCellValue())) {
String cellValue = cell.getStringCellValue().trim();
authTransaction.setNavigationArea(cellValue);
}
break;*/
case 15:// 总长->建造地点
if (cell != null && cell.getCellType() == Cell.CELL_TYPE_STRING && StringUtils.isNotBlank(cell.getStringCellValue())) {
String cellValue = cell.getStringCellValue().trim();
authTransaction.setBuildArea(cellValue);
}
break;
/*if (cell != null) {
if (cell.getCellType() == Cell.CELL_TYPE_NUMERIC) {
authTransaction.setShipLength(cell.getNumericCellValue());
} else if (cell.getCellType() == Cell.CELL_TYPE_STRING && StringUtils.isNotBlank(cell.getStringCellValue())) {
String cellValue = cell.getStringCellValue().trim();
if (DataUtils.isNumeric(cellValue)) {
authTransaction.setShipLength(Double.valueOf(cellValue));
}
}
}
break;*/
case 16:// 型宽->船名(原)
if (cell != null && cell.getCellType() == Cell.CELL_TYPE_STRING && StringUtils.isNotBlank(cell.getStringCellValue())) {
String cellValue = cell.getStringCellValue().trim();
authTransaction.setShipFormerName(cellValue);
}
break;
/*if (cell != null) {
if (cell.getCellType() == Cell.CELL_TYPE_NUMERIC) {
authTransaction.setShipWidth(cell.getNumericCellValue());
} else if (cell.getCellType() == Cell.CELL_TYPE_STRING && StringUtils.isNotBlank(cell.getStringCellValue())) {
String cellValue = cell.getStringCellValue().trim();
if (DataUtils.isNumeric(cellValue)) {
authTransaction.setShipWidth(Double.valueOf(cellValue));
}
}
}
break;*/
case 17:// 型深->船名(现)不解析
/*if (cell != null) {
if (cell.getCellType() == Cell.CELL_TYPE_NUMERIC) {
authTransaction.setShipHeight(cell.getNumericCellValue());
} else if (cell.getCellType() == Cell.CELL_TYPE_STRING && StringUtils.isNotBlank(cell.getStringCellValue())) {
String cellValue = cell.getStringCellValue().trim();
if (DataUtils.isNumeric(cellValue)) {
authTransaction.setShipHeight(Double.valueOf(cellValue));
}
}
}*/
break;
case 18:// 主机型号->船籍港(原)
if (cell != null && cell.getCellType() == Cell.CELL_TYPE_STRING && StringUtils.isNotBlank(cell.getStringCellValue())) {
String cellValue = cell.getStringCellValue().trim();
authTransaction.setHomePort(cellValue);
}
break;
/* if (cell != null && cell.getCellType() == Cell.CELL_TYPE_STRING && StringUtils.isNotBlank(cell.getStringCellValue())) {
String cellValue = cell.getStringCellValue().trim();
authTransaction.setHostModel(cellValue);
}
break;*/
case 19:// 主机功率—>船籍港(现)不解析
/*if (cell != null) {
if (cell.getCellType() == Cell.CELL_TYPE_NUMERIC) {
authTransaction.setHostPower(cell.getNumericCellValue());
} else if (cell.getCellType() == Cell.CELL_TYPE_STRING && StringUtils.isNotBlank(cell.getStringCellValue())) {
String cellValue = cell.getStringCellValue().trim();
if (DataUtils.isNumeric(cellValue)) {
authTransaction.setHostPower(Double.valueOf(cellValue));
}
}
}
break;*/
case 20:// 主机转速->海/河船
authTransaction.setIsShip(0);//默认河船
if (cell != null && cell.getCellType() == Cell.CELL_TYPE_STRING && StringUtils.isNotBlank(cell.getStringCellValue())) {
String cellValue = cell.getStringCellValue().trim();
if (cellValue.equals("海船")) {
authTransaction.setIsShip(1);
}
}
break;
/*if (cell != null && cell.getCellType() == Cell.CELL_TYPE_STRING && StringUtils.isNotBlank(cell.getStringCellValue())) {
String cellValue = cell.getStringCellValue().trim();
authTransaction.setShipRateType(cellValue);
}
break;*/
/*if (cell != null) {
if (cell.getCellType() == Cell.CELL_TYPE_NUMERIC) {
authTransaction.setHostSpeed(cell.getNumericCellValue());
} else if (cell.getCellType() == Cell.CELL_TYPE_STRING && StringUtils.isNotBlank(cell.getStringCellValue())) {
String cellValue = cell.getStringCellValue().trim();
if (DataUtils.isNumeric(cellValue)) {
authTransaction.setHostSpeed(Double.valueOf(cellValue));
}
}
}
break;*/
case 21:// 主机台数->船检机构
if (cell != null && cell.getCellType() == Cell.CELL_TYPE_STRING && StringUtils.isNotBlank(cell.getStringCellValue())) {
String cellValue = cell.getStringCellValue().trim();
authTransaction.setShipCheck(cellValue);
}
break;
/*if (cell != null) {
if (cell.getCellType() == Cell.CELL_TYPE_NUMERIC) {
String cellValue = df.format(cell.getNumericCellValue());
if (DataUtils.isInteger(cellValue)) {
authTransaction.setHosts(Integer.valueOf(cellValue));
}
} else if (cell.getCellType() == Cell.CELL_TYPE_STRING && StringUtils.isNotBlank(cell.getStringCellValue())) {
String cellValue = cell.getStringCellValue().trim();
if (DataUtils.isInteger(cellValue)) {
authTransaction.setHosts(Integer.valueOf(cellValue));
}
}
}
break;*/
case 22:// 主机制造厂->航区
if (cell != null && cell.getCellType() == Cell.CELL_TYPE_STRING && StringUtils.isNotBlank(cell.getStringCellValue())) {
String cellValue = cell.getStringCellValue().trim();
authTransaction.setNavigationArea(cellValue);
}
break;
/*if (cell != null && cell.getCellType() == Cell.CELL_TYPE_STRING && StringUtils.isNotBlank(cell.getStringCellValue())) {
String cellValue = cell.getStringCellValue().trim();
authTransaction.setHostFactory(cellValue);
}
break;*/
case 23:// 副机型号->总长
if (cell != null) {
if (cell.getCellType() == Cell.CELL_TYPE_NUMERIC) {
authTransaction.setShipLength(cell.getNumericCellValue());
} else if (cell.getCellType() == Cell.CELL_TYPE_STRING && StringUtils.isNotBlank(cell.getStringCellValue())) {
String cellValue = cell.getStringCellValue().trim();
if (DataUtils.isNumeric(cellValue)) {
authTransaction.setShipLength(Double.valueOf(cellValue));
}
}
}
break;
/*if (cell != null && cell.getCellType() == Cell.CELL_TYPE_STRING && StringUtils.isNotBlank(cell.getStringCellValue())) {
String cellValue = cell.getStringCellValue().trim();
authTransaction.setSideModel(cellValue);
}
break;*/
case 24:// 副机台数->型宽.
if (cell != null) {
if (cell.getCellType() == Cell.CELL_TYPE_NUMERIC) {
authTransaction.setShipWidth(cell.getNumericCellValue());
} else if (cell.getCellType() == Cell.CELL_TYPE_STRING && StringUtils.isNotBlank(cell.getStringCellValue())) {
String cellValue = cell.getStringCellValue().trim();
if (DataUtils.isNumeric(cellValue)) {
authTransaction.setShipWidth(Double.valueOf(cellValue));
}
}
}
break;
/*if (cell != null) {
if (cell.getCellType() == Cell.CELL_TYPE_NUMERIC) {
String cellValue = df.format(cell.getNumericCellValue());
if (DataUtils.isInteger(cellValue)) {
authTransaction.setSides(Integer.valueOf(cellValue));
}
} else if (cell.getCellType() == Cell.CELL_TYPE_STRING && StringUtils.isNotBlank(cell.getStringCellValue())) {
String cellValue = cell.getStringCellValue().trim();
if (DataUtils.isInteger(cellValue)) {
authTransaction.setSides(Integer.valueOf(cellValue));
}
}
}
break;*/
case 25:// 副机制造厂->型深
if (cell != null) {
if (cell.getCellType() == Cell.CELL_TYPE_NUMERIC) {
authTransaction.setShipHeight(cell.getNumericCellValue());
} else if (cell.getCellType() == Cell.CELL_TYPE_STRING && StringUtils.isNotBlank(cell.getStringCellValue())) {
String cellValue = cell.getStringCellValue().trim();
if (DataUtils.isNumeric(cellValue)) {
authTransaction.setShipHeight(Double.valueOf(cellValue));
}
}
}
/*if (cell != null && cell.getCellType() == Cell.CELL_TYPE_STRING && StringUtils.isNotBlank(cell.getStringCellValue())) {
String cellValue = cell.getStringCellValue().trim();
authTransaction.setSideFactory(cellValue);
}
break;*/
case 26:// 成交价格->主机型号
if (cell != null && cell.getCellType() == Cell.CELL_TYPE_STRING && StringUtils.isNotBlank(cell.getStringCellValue())) {
String cellValue = cell.getStringCellValue().trim();
authTransaction.setHostModel(cellValue);
}
break;
/*if (cell != null) {
if (cell.getCellType() == Cell.CELL_TYPE_NUMERIC) {
authTransaction.setPrice(cell.getNumericCellValue());
} else if (cell.getCellType() == Cell.CELL_TYPE_STRING && StringUtils.isNotBlank(cell.getStringCellValue())) {
String cellValue = cell.getStringCellValue().trim();
if (DataUtils.isNumeric(cellValue)) {
authTransaction.setPrice(Double.valueOf(cellValue));
}
}
}
break;*/
case 27:// 成交日期->主机功率
if (cell != null) {
if (cell.getCellType() == Cell.CELL_TYPE_NUMERIC) {
authTransaction.setHostPower(cell.getNumericCellValue());
} else if (cell.getCellType() == Cell.CELL_TYPE_STRING && StringUtils.isNotBlank(cell.getStringCellValue())) {
String cellValue = cell.getStringCellValue().trim();
if (DataUtils.isNumeric(cellValue)) {
authTransaction.setHostPower(Double.valueOf(cellValue));
}
}
}
break;
/* if (cell != null && HSSFDateUtil.isCellDateFormatted(cell)) {
authTransaction.setTradeDate(cell.getDateCellValue());
}
break;*/
case 28:// 鉴证费->主机转速
if (cell != null) {
if (cell.getCellType() == Cell.CELL_TYPE_NUMERIC) {
authTransaction.setHostSpeed(cell.getNumericCellValue());
} else if (cell.getCellType() == Cell.CELL_TYPE_STRING && StringUtils.isNotBlank(cell.getStringCellValue())) {
String cellValue = cell.getStringCellValue().trim();
if (DataUtils.isNumeric(cellValue)) {
authTransaction.setHostSpeed(Double.valueOf(cellValue));
}
}
}
break;
/*if (cell != null) {
if (cell.getCellType() == Cell.CELL_TYPE_NUMERIC) {
authTransaction.setAuthCharge(cell.getNumericCellValue());
} else if (cell.getCellType() == Cell.CELL_TYPE_STRING && StringUtils.isNotBlank(cell.getStringCellValue())) {
String cellValue = cell.getStringCellValue().trim();
if (DataUtils.isNumeric(cellValue)) {
authTransaction.setAuthCharge(Double.valueOf(cellValue));
}
}
}
break;*/
case 29:// 鉴证日期->主机台数
if (cell != null) {
if (cell.getCellType() == Cell.CELL_TYPE_NUMERIC) {
String cellValue = df.format(cell.getNumericCellValue());
if (DataUtils.isInteger(cellValue)) {
authTransaction.setHosts(Integer.valueOf(cellValue));
}
} else if (cell.getCellType() == Cell.CELL_TYPE_STRING && StringUtils.isNotBlank(cell.getStringCellValue())) {
String cellValue = cell.getStringCellValue().trim();
if (DataUtils.isInteger(cellValue)) {
authTransaction.setHosts(Integer.valueOf(cellValue));
}
}
}
break;
/*if (cell != null && HSSFDateUtil.isCellDateFormatted(cell)) {
authTransaction.setAuthDate(cell.getDateCellValue());
}
break;*/
case 30:// 卖方->主机制造厂
if (cell != null && cell.getCellType() == Cell.CELL_TYPE_STRING && StringUtils.isNotBlank(cell.getStringCellValue())) {
String cellValue = cell.getStringCellValue().trim();
authTransaction.setHostFactory(cellValue);
}
break;
/*if (cell != null && cell.getCellType() == Cell.CELL_TYPE_STRING && StringUtils.isNotBlank(cell.getStringCellValue())) {
String cellValue = cell.getStringCellValue().trim();
authTransaction.setSeller(cellValue);
}
break;*/
case 31:// 卖方所在地->副机型号
if (cell != null && cell.getCellType() == Cell.CELL_TYPE_STRING && StringUtils.isNotBlank(cell.getStringCellValue())) {
String cellValue = cell.getStringCellValue().trim();
authTransaction.setSideModel(cellValue);
}
break;
/*if (cell != null && cell.getCellType() == Cell.CELL_TYPE_STRING && StringUtils.isNotBlank(cell.getStringCellValue())) {
String cellValue = cell.getStringCellValue().trim();
authTransaction.setSellerLocation(cellValue);
}
break;*/
case 32:// 买方->副机台数
if (cell != null) {
if (cell.getCellType() == Cell.CELL_TYPE_NUMERIC) {
String cellValue = df.format(cell.getNumericCellValue());
if (DataUtils.isInteger(cellValue)) {
authTransaction.setSides(Integer.valueOf(cellValue));
}
} else if (cell.getCellType() == Cell.CELL_TYPE_STRING && StringUtils.isNotBlank(cell.getStringCellValue())) {
String cellValue = cell.getStringCellValue().trim();
if (DataUtils.isInteger(cellValue)) {
authTransaction.setSides(Integer.valueOf(cellValue));
}
}
}
break;
/*if (cell != null && cell.getCellType() == Cell.CELL_TYPE_STRING && StringUtils.isNotBlank(cell.getStringCellValue())) {
String cellValue = cell.getStringCellValue().trim();
authTransaction.setBuyer(cellValue);
}
break;*/
case 33:// 买方所在地->最近一次船检时间
if (cell != null && cell.getCellType() == Cell.CELL_TYPE_STRING && StringUtils.isNotBlank(cell.getStringCellValue())) {
String cellValue = cell.getStringCellValue().trim();
authTransaction.setRecentlyCheckTime(cellValue);
}
break;
case 34:// 下一次船检时间
if (cell != null && cell.getCellType() == Cell.CELL_TYPE_STRING && StringUtils.isNotBlank(cell.getStringCellValue())) {
String cellValue = cell.getStringCellValue().trim();
authTransaction.setNextCheckTime(cellValue);
}
break;
/*if (cell != null && cell.getCellType() == Cell.CELL_TYPE_STRING && StringUtils.isNotBlank(cell.getStringCellValue())) {
String cellValue = cell.getStringCellValue().trim();
authTransaction.setBuyerLocation(cellValue);
}
break;*/
case 35:// 卖方所在地->保险
if (cell != null && cell.getCellType() == Cell.CELL_TYPE_STRING && StringUtils.isNotBlank(cell.getStringCellValue())) {
String cellValue = cell.getStringCellValue().trim();
authTransaction.setBuySafe(cellValue);
}
break;
case 36:// 下一次船检时间
if (cell != null && HSSFDateUtil.isCellDateFormatted(cell)) {
authTransaction.setBuyTime(cell.getDateCellValue());
}
break;
case 38://卖方
if (cell != null && cell.getCellType() == Cell.CELL_TYPE_STRING && StringUtils.isNotBlank(cell.getStringCellValue())) {
String cellValue = cell.getStringCellValue().trim();
authTransaction.setSeller(cellValue);
}
break;
case 39://卖方所在地
if (cell != null && cell.getCellType() == Cell.CELL_TYPE_STRING && StringUtils.isNotBlank(cell.getStringCellValue())) {
String cellValue = cell.getStringCellValue().trim();
authTransaction.setSellerLocation(cellValue);
}
break;
case 40://卖方联系方式
if (cell != null && cell.getCellType() == Cell.CELL_TYPE_STRING && StringUtils.isNotBlank(cell.getStringCellValue())) {
String cellValue = cell.getStringCellValue().trim();
authTransaction.setSellPhone(cellValue);
}
break;
case 41://买方
if (cell != null && cell.getCellType() == Cell.CELL_TYPE_STRING && StringUtils.isNotBlank(cell.getStringCellValue())) {
String cellValue = cell.getStringCellValue().trim();
authTransaction.setBuyer(cellValue);
}
break;
case 42://买方所在地
if (cell != null && cell.getCellType() == Cell.CELL_TYPE_STRING && StringUtils.isNotBlank(cell.getStringCellValue())) {
String cellValue = cell.getStringCellValue().trim();
authTransaction.setBuyerLocation(cellValue);
}
break;
case 43://买方联系方式
if (cell != null && cell.getCellType() == Cell.CELL_TYPE_STRING && StringUtils.isNotBlank(cell.getStringCellValue())) {
String cellValue = cell.getStringCellValue().trim();
authTransaction.setBuyPhone(cellValue);
}
break;
case 44://经纪人
if (cell != null && cell.getCellType() == Cell.CELL_TYPE_STRING && StringUtils.isNotBlank(cell.getStringCellValue())) {
String cellValue = cell.getStringCellValue().trim();
authTransaction.setAgent(cellValue);
}
break;
case 45://经纪人联系方式
if (cell != null && cell.getCellType() == Cell.CELL_TYPE_STRING && StringUtils.isNotBlank(cell.getStringCellValue())) {
String cellValue = cell.getStringCellValue().trim();
authTransaction.setAgentPhone(cellValue);
}
break;
case 49://备注
if (cell != null && cell.getCellType() == Cell.CELL_TYPE_STRING && StringUtils.isNotBlank(cell.getStringCellValue())) {
String cellValue = cell.getStringCellValue().trim();
authTransaction.setBref(cellValue);
}
break;
default:
break;
}
if(flag == 0)
continue;
else if(flag == 1)
break;
}

authTransaction.setStatus(AuditStatus.NEW.getValue());
if(StringUtils.isNotEmpty(authTransaction.getAuthApplicationNo())){
tempResult.add(authTransaction);
}
} catch (Exception e) {
e.printStackTrace();
}
}
}
return tempResult;
}
});

if (CollectionUtils.isNotEmpty(parseResult)) {
for (AuthTransaction obj : parseResult) {
this.saveEntity(obj);
}
} else {
throw new Exception("导入数据为空");
}
}

原文地址:https://www.cnblogs.com/chenweida/p/6149356.html