修复bug
This commit is contained in:
		| @@ -44,7 +44,8 @@ public class DataImport | ||||
|     { | ||||
|         String importResult = ""; | ||||
|         String importMessage = null; | ||||
|         int rowCount = 1; //excel文件行索引 | ||||
|         int rowIndex = 1; //excel文件行索引 | ||||
|         int rowCount = -1; | ||||
|         int successCount = 0; //成功写入的行计数 | ||||
|         int failCount = 0; //写入失败的行计数 | ||||
|  | ||||
| @@ -59,7 +60,9 @@ public class DataImport | ||||
|             xlsFileIn = new FileInputStream( fileName ); | ||||
|             xlsFile = new HSSFWorkbook( xlsFileIn ); | ||||
|             sheet = xlsFile.getSheetAt( 0 ); //第一个sheet | ||||
|             row = sheet.getRow( rowCount ); | ||||
|             rowIndex = sheet.getFirstRowNum() + 1; | ||||
|             rowCount = sheet.getLastRowNum(); | ||||
|             row = sheet.getRow( rowIndex ); | ||||
|         } | ||||
|         catch( IOException error ) //有文件格式错误的可能。 | ||||
|         { | ||||
| @@ -115,15 +118,24 @@ public class DataImport | ||||
|         StaffInfo staff = null; | ||||
|         boolean isSuccess = true; //标志位,用来指示在保存过程中是否出现错误。 | ||||
|  | ||||
|         while ( row != null ) | ||||
|         while ( rowIndex <= rowCount ) | ||||
|         { | ||||
|             //用来判断是不是空行 | ||||
|             HSSFCell cell = row.getCell( 0 ); | ||||
|  | ||||
|             if ( cell == null) | ||||
|             { | ||||
|                 rowIndex++; | ||||
|                 continue; | ||||
|             } | ||||
|  | ||||
|             policyNo = row.getCell( 0 ).getStringCellValue().trim(); | ||||
|             operatorCode = getStringValueFromHSSFCell( row.getCell( 1 ) ); | ||||
|  | ||||
|             //判断一下是不是空的单元格 | ||||
|             if ( policyNo.length() == 0 || operatorCode.length() == 0 ) | ||||
|             { | ||||
|                 importResult = importResult + "第" + rowCount + "行数据为空。<br>"; | ||||
|                 importResult = importResult + "第" + rowIndex + "行数据为空。<br>"; | ||||
|  | ||||
|                 //isSuccess = false; | ||||
|             } | ||||
| @@ -153,7 +165,7 @@ public class DataImport | ||||
|                 catch( StaffCodeNotExistException error ) | ||||
|                 { | ||||
|                     //经办人不存在 | ||||
|                     importResult = importResult + "第" + rowCount + "行,保单号" + policyNo + ",经办人" + operatorCode + "不存在。<br>"; | ||||
|                     importResult = importResult + "第" + rowIndex + "行,保单号" + policyNo + ",经办人" + operatorCode + "不存在。<br>"; | ||||
|  | ||||
|                     //标志位 | ||||
|                     isSuccess = false; | ||||
| @@ -164,7 +176,7 @@ public class DataImport | ||||
|                 catch( SQLException error ) | ||||
|                 { | ||||
|                     //写入错误 | ||||
|                     importResult = importResult + "第" + rowCount + "行,保单号" + policyNo + ",数据库写入错误,错误信息:" + error.getMessage() + "。<br>"; | ||||
|                     importResult = importResult + "第" + rowIndex + "行,保单号" + policyNo + ",数据库写入错误,错误信息:" + error.getMessage() + "。<br>"; | ||||
|  | ||||
|                     //标志位 | ||||
|                     isSuccess = false; | ||||
| @@ -175,7 +187,7 @@ public class DataImport | ||||
|                 catch( Exception error ) | ||||
|                 { | ||||
|                     //写入错误 | ||||
|                     importResult = importResult + "第" + rowCount + "行,保单号" + policyNo + ",数据库写入错误,错误信息:" + error.getMessage() + "。<br>"; | ||||
|                     importResult = importResult + "第" + rowIndex + "行,保单号" + policyNo + ",数据库写入错误,错误信息:" + error.getMessage() + "。<br>"; | ||||
|  | ||||
|                     //标志位 | ||||
|                     isSuccess = false; | ||||
| @@ -185,8 +197,8 @@ public class DataImport | ||||
|                 } | ||||
|             } | ||||
|  | ||||
|             rowCount++; | ||||
|             row = sheet.getRow( rowCount ); | ||||
|             rowIndex++; | ||||
|             row = sheet.getRow( rowIndex ); | ||||
|         } | ||||
|  | ||||
|         //判断标志位,如果为false,则说明在保存过程中出现了错误,放弃所有过程,进行回滚。 | ||||
| @@ -205,7 +217,7 @@ public class DataImport | ||||
|         xlsFileIn.close(); | ||||
|  | ||||
|         //日志 | ||||
|         importMessage = "读取记录数量:" + (rowCount - 1) + | ||||
|         importMessage = "读取记录数量:" + (rowIndex - 1) + | ||||
|                 "<br>正确记录数量:" + successCount + | ||||
|                 "<br>错误记录数量:" + failCount; | ||||
|  | ||||
|   | ||||
| @@ -33,7 +33,7 @@ | ||||
|     </context-param> | ||||
|     <context-param> | ||||
|         <param-name>informixURL</param-name> | ||||
|         <param-value>jdbc:informix-sqli://10.39.0.92:16192/ywgl_xm:INFORMIXSERVER=xmcx2;newcodeset=GBK,8859-1,819;user=ccx99;password=c92IT09</param-value> | ||||
|         <param-value>jdbc:informix-sqli://10.187.11.163:9096/ywgl_xm:INFORMIXSERVER=pxmcx2;newcodeset=GBK,8859-1,819;user=ccx99;password=ct0IT17!</param-value> | ||||
|     </context-param> | ||||
|     <context-param> | ||||
|         <param-name>telsalePolicyOperatorListTableName</param-name> | ||||
|   | ||||
		Reference in New Issue
	
	Block a user