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("导入数据为空");
}
}

excel解析二维数组结构的excel的更多相关文章

  1. PHP导出excel文件,第二步先实现自写二维数组加入模板excel文件后导出

    今天主要研究数据加入EXCEL并导出的问题,先不从数据库提取数据导出,自己先写一个二维数组,然后遍历二维数组写入excel模板中导出,首先根据模板excel的内容书写对应的二维数组 $arr=arra ...

  2. 将一,二维数组转化为Excel格式

    首先,我们来看一下一维数组的, 其代码可以如下: import numpy as np import pandas as pd x = pd.Series([1, 3, 5, np.nan]) pri ...

  3. Highcharts使用二维数组生成图表

    Highcharts使用二维数组生成图表 二维数组是更为灵活的一种数据存储方式.在Highcharts中.能够使用配置项column和rows二维数组.对于使用columns构建的二维数组,Highc ...

  4. Java读取excel指定sheet中的各行数据,存入二维数组,包括首行,并打印

    1. 读取 //读取excel指定sheet中的各行数据,存入二维数组,包括首行 public static String[][] getSheetData(XSSFSheet sheet) thro ...

  5. Excel 二维数组(数据块)旋转/翻转技巧

    Excel 二维数组(数据块)旋转/翻转技巧 原创 2017-12-30 久石六 久石六 工作中遇到个问题,需要将Excel中的数据块或者说二维数组向右旋转90度,才能再加工处理.当然,不是旋转文本方 ...

  6. 使用POI对excel进行操作生成二维数组

    import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; import ja ...

  7. php上传excle文件,csv文件解析为二维数组

    解析上传的CSV文件不是什么难事,直接读取转成你想要的数组样子就OK了. public function putStoreStockIn ($filePath = '') { $file = fope ...

  8. jquery解析php通过ajax传过来的json二维数组对象

    ajax获得php传过来的json二维数组对象,jquery解析 php代码: <?php $news = array( '武汉'=>array(1,2,3), '广州'=>arra ...

  9. C语言一维数组、二维数组、结构体的初始化

    C语言数组的初始化表示方法 一.C语言一维数组初始化: (1)在定义数组时对数组元素赋以初值.如: static int a[10]={0,1,2,3,4,5,6,7,8,9}; 经过上面的定义和初始 ...

随机推荐

  1. 【转】关于启用 HTTPS 的一些经验分享

    随着国内网络环境的持续恶化,各种篡改和劫持层出不穷,越来越多的网站选择了全站 HTTPS.HTTPS 通过 TLS 层和证书机制提供了内容加密.身份认证和数据完整性三大功能,可以有效防止数据被查看或篡 ...

  2. [原]php远程odbc连接sqlsvr数据库,自定义端口,命名实例的连接方式

    远程odbc连接sqlsvr数据库,自定义端口,命名实例的连接方式,默认如果不修改的话sqlsvr的端口号是1433,默认实例名就是机器名,,如果既用了命名实例,又改了默认端口,改怎么连接数据库呢? ...

  3. MySQL服务 - MySQL变量类型及变量设置

    一.MySQL变量类型: MySQL通过变量来定义当前服务器的特性,保存状态信息等.我们可以通过手动更改变量的值来配置MySQL,也可以通过变量获得MySQL的当前状态信息.MySQL的变量类型可以从 ...

  4. CentOS_7 OpenWrt Eclipse 环境搭建与 Dr.com 开发笔记

    一:内核的编译. 1,linux 编译环境的搭建与源码的准备工作 2,常用软件的安装 (make menuconfig) 3,  针对TP-Link WR740N 一些软件的openwrt 的移植 4 ...

  5. oracle之集合操作函数---minus、union、intersect

    集合操作符专门用于合并多条select语句的结果,包括:UNION,UNION ALL,INTERSECT,MINUS.当使用集合操作函数时,需保证数据集的字段数据类型和数目一致. 使用集合操作符需要 ...

  6. Python基础(二)之元组及字典

    元组:以一对小括号表示,不可以增删改,只可查看. 字典:以一对大括号表示,字典中含key及value,字典是无序的. 下面介绍字典和元组的一些常见操作: 一.元组 a = ('haha','xixi' ...

  7. 重写类的Equals以及重写Linq下的Distinct方法

    当自定义一个类的时候,如果需要用到对比的功能,可以自己重写Equals方法,最整洁的方法是重写GetHashCode()方法. 但是,这个方法只适用于对象自身的对比(如if(a==b))以及字典下的C ...

  8. oracle修改字符集

    在linux下面安装了oracle 11G,由于安装的时候没有注意导致字符集问题,impdp导入操作后中文乱码. 1.用命令select userenv('language') from dual; ...

  9. java删除文件

    public boolean deleteFile(String fileName) { File file = new File("D:/NovaPluto/xml/"+file ...

  10. Druid 基础使用-操作篇(Imply )

    一.Imply Druid 原生的配置较麻烦,在上一篇单机版安装中有所涉及   Imply 基于Druid 进行了一些组件的开发,提供开源社区版本和商业版,简化了部署,开发了一些应用.https:// ...