...
This commit is contained in:
@@ -25,10 +25,9 @@ public class DataImport
|
||||
* @Author: 王炜
|
||||
* @Date: 2021/6/21
|
||||
*/
|
||||
public static ArrayList<TelsalePolicyRecord> readTelsalePolicyDataFromXlsx(String fileName, int sheetIndex) throws
|
||||
IOException,
|
||||
SQLException,
|
||||
XlsFileFormatException
|
||||
public static ArrayList<TelsalePolicyRecord> readTelsalePolicyDataFromXlsx( String fileName, int sheetIndex )
|
||||
throws IOException,
|
||||
XlsFileFormatException
|
||||
{
|
||||
ArrayList<TelsalePolicyRecord> policyList = new ArrayList<TelsalePolicyRecord>();
|
||||
|
||||
@@ -39,32 +38,79 @@ public class DataImport
|
||||
HSSFSheet sheet = null;
|
||||
HSSFRow row = null;
|
||||
|
||||
int rowIndex = 0;
|
||||
int rowCount = 0;
|
||||
int rowIndex = 0;
|
||||
int rowCount = 0;
|
||||
int errorCount = 0;
|
||||
String errorMessage = "数据错误,请修正后重新上传!<br>\n";
|
||||
|
||||
try {
|
||||
xlsxFile = new FileInputStream(fileName);
|
||||
workBook = new HSSFWorkbook(xlsxFile);
|
||||
sheet = workBook.getSheetAt(sheetIndex);
|
||||
rowIndex = sheet.getFirstRowNum() + 1;
|
||||
try
|
||||
{
|
||||
xlsxFile = new FileInputStream( fileName );
|
||||
workBook = new HSSFWorkbook( xlsxFile );
|
||||
sheet = workBook.getSheetAt( sheetIndex );
|
||||
rowIndex = sheet.getFirstRowNum();
|
||||
rowCount = sheet.getLastRowNum();
|
||||
row = sheet.getRow(rowIndex);
|
||||
|
||||
while (rowIndex <= rowCount) {
|
||||
while ( rowIndex <= rowCount )
|
||||
{
|
||||
//用第一个单元格判断是不是空行,如果cell为null视为空行
|
||||
HSSFCell cell = row.getCell(0);
|
||||
row = sheet.getRow( rowIndex );
|
||||
HSSFCell cell = row.getCell( 0 );
|
||||
|
||||
if (cell == null) {
|
||||
if ( cell == null )
|
||||
{
|
||||
rowIndex++;
|
||||
continue;
|
||||
}
|
||||
|
||||
String policyNo = cell.getStringCellValue();
|
||||
String operatorCode = getStringValueFromHSSFCell(row.getCell(1));
|
||||
String operatorCode = getStringValueFromHSSFCell( row.getCell( 1 ) );
|
||||
|
||||
//判断数据是否有效
|
||||
if ( policyNo.length() != 20 || operatorCode.length() == 0 || operatorCode.length() > 6 )
|
||||
{
|
||||
errorMessage += "第" + ( rowIndex + 1 ) + "行,";
|
||||
|
||||
if ( policyNo.length() != 20 )
|
||||
{
|
||||
//以后再加入正则表达式判断
|
||||
errorMessage += "保单号" + policyNo + "错误!";
|
||||
}
|
||||
|
||||
if ( operatorCode.length() == 0 || operatorCode.length() > 6 )
|
||||
{
|
||||
errorMessage += "经办人" + operatorCode + "错误!";
|
||||
}
|
||||
|
||||
errorMessage += "<br>\n";
|
||||
|
||||
rowIndex++;
|
||||
errorCount++;
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
//读取数据
|
||||
record = new TelsalePolicyRecord( policyNo, operatorCode );
|
||||
|
||||
policyList.add( record );
|
||||
|
||||
rowIndex++;
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
if ( workBook != null )
|
||||
{
|
||||
workBook.close();
|
||||
xlsxFile.close();
|
||||
}
|
||||
}
|
||||
|
||||
} catch (IOException error) {
|
||||
|
||||
//判断是否要抛出读取错误
|
||||
if ( errorCount > 0 )
|
||||
{
|
||||
throw new XlsFileFormatException( errorMessage );
|
||||
}
|
||||
|
||||
return policyList;
|
||||
@@ -82,13 +128,13 @@ public class DataImport
|
||||
* @throws SQLException 数据库异常
|
||||
* @throws XlsFileFormatException xls文件格式错误异常
|
||||
*/
|
||||
public static String importTelsalePolicyDataFromXlsx(String fileName,
|
||||
String telsalePolicyOperatorListTableName,
|
||||
String informixURL) throws
|
||||
IOException,
|
||||
ClassNotFoundException,
|
||||
SQLException,
|
||||
XlsFileFormatException
|
||||
public static String importTelsalePolicyDataFromXlsx( String fileName,
|
||||
String telsalePolicyOperatorListTableName,
|
||||
String informixURL )
|
||||
throws IOException,
|
||||
ClassNotFoundException,
|
||||
SQLException,
|
||||
XlsFileFormatException
|
||||
{
|
||||
String importResult = "";
|
||||
String importMessage = null;
|
||||
@@ -103,23 +149,25 @@ public class DataImport
|
||||
HSSFSheet sheet = null;
|
||||
HSSFRow row = null;
|
||||
|
||||
try {
|
||||
xlsFileIn = new FileInputStream(fileName);
|
||||
xlsFile = new HSSFWorkbook(xlsFileIn);
|
||||
sheet = xlsFile.getSheetAt(0); //第一个sheet
|
||||
try
|
||||
{
|
||||
xlsFileIn = new FileInputStream( fileName );
|
||||
xlsFile = new HSSFWorkbook( xlsFileIn );
|
||||
sheet = xlsFile.getSheetAt( 0 ); //第一个sheet
|
||||
rowIndex = sheet.getFirstRowNum() + 1;
|
||||
rowCount = sheet.getLastRowNum();
|
||||
row = sheet.getRow(rowIndex);
|
||||
} catch (IOException error) //有文件格式错误的可能。
|
||||
row = sheet.getRow( rowIndex );
|
||||
}
|
||||
catch ( IOException error ) //有文件格式错误的可能。
|
||||
{
|
||||
xlsFile.close();
|
||||
xlsFileIn.close();
|
||||
|
||||
throw new XlsFileFormatException("文件格式错误,请检查是否xls格式文件。");
|
||||
throw new XlsFileFormatException( "文件格式错误,请检查是否xls格式文件。" );
|
||||
}
|
||||
|
||||
//informix相关
|
||||
Class.forName("com.informix.jdbc.IfxDriver");
|
||||
Class.forName( "com.informix.jdbc.IfxDriver" );
|
||||
String ifxSql =
|
||||
"INSERT INTO " + telsalePolicyOperatorListTableName + " \n" +
|
||||
" (bdh,\n" +
|
||||
@@ -153,10 +201,10 @@ public class DataImport
|
||||
" 1,\n" +
|
||||
" '800',\n" +
|
||||
" today)";
|
||||
Connection ifxConn = DriverManager.getConnection(informixURL);
|
||||
PreparedStatement ifxStmt = ifxConn.prepareStatement(ifxSql);
|
||||
Connection ifxConn = DriverManager.getConnection( informixURL );
|
||||
PreparedStatement ifxStmt = ifxConn.prepareStatement( ifxSql );
|
||||
|
||||
ifxConn.setAutoCommit(false);//关闭自动提交,整个表格要么全部成写入,要么全部失败。
|
||||
ifxConn.setAutoCommit( false );//关闭自动提交,整个表格要么全部成写入,要么全部失败。
|
||||
|
||||
//数据相关
|
||||
String policyNo = null;
|
||||
@@ -164,38 +212,42 @@ public class DataImport
|
||||
StaffInfo staff = null;
|
||||
boolean isSuccess = true; //标志位,用来指示在保存过程中是否出现错误。
|
||||
|
||||
while (rowIndex <= rowCount) {
|
||||
while ( rowIndex <= rowCount )
|
||||
{
|
||||
//用来判断是不是空行
|
||||
HSSFCell cell = row.getCell(0);
|
||||
HSSFCell cell = row.getCell( 0 );
|
||||
|
||||
if (cell == null) {
|
||||
if ( cell == null )
|
||||
{
|
||||
rowIndex++;
|
||||
continue;
|
||||
}
|
||||
|
||||
policyNo = row.getCell(0).getStringCellValue().trim();
|
||||
operatorCode = getStringValueFromHSSFCell(row.getCell(1));
|
||||
policyNo = row.getCell( 0 ).getStringCellValue().trim();
|
||||
operatorCode = getStringValueFromHSSFCell( row.getCell( 1 ) );
|
||||
|
||||
//判断一下是不是空的单元格
|
||||
if (policyNo.length() == 0 || operatorCode.length() == 0) {
|
||||
if ( policyNo.length() == 0 || operatorCode.length() == 0 )
|
||||
{
|
||||
importResult = importResult + "第" + rowIndex + "行数据为空。<br>";
|
||||
|
||||
//isSuccess = false;
|
||||
}
|
||||
else //不是空单元格,进行处理
|
||||
{
|
||||
try {
|
||||
try
|
||||
{
|
||||
//取得经办人信息
|
||||
staff = new StaffInfo(operatorCode);
|
||||
staff = new StaffInfo( operatorCode );
|
||||
|
||||
//写入informix
|
||||
ifxStmt.setString(1, policyNo);
|
||||
ifxStmt.setString(2, staff.getStaffCode());
|
||||
ifxStmt.setString(3, staff.getStaffName());
|
||||
ifxStmt.setString(4, staff.getSectionOfficeCode());
|
||||
ifxStmt.setString(5, staff.getSectionOfficeName());
|
||||
ifxStmt.setString(6, staff.getDepartmentCode());
|
||||
ifxStmt.setString(7, staff.getDepartmentName());
|
||||
ifxStmt.setString( 1, policyNo );
|
||||
ifxStmt.setString( 2, staff.getStaffCode() );
|
||||
ifxStmt.setString( 3, staff.getStaffName() );
|
||||
ifxStmt.setString( 4, staff.getSectionOfficeCode() );
|
||||
ifxStmt.setString( 5, staff.getSectionOfficeName() );
|
||||
ifxStmt.setString( 6, staff.getDepartmentCode() );
|
||||
ifxStmt.setString( 7, staff.getDepartmentName() );
|
||||
//ifxStmt.setString( 8, getStringValueFromHSSFCell( row.getCell( 6 ) ) );
|
||||
//ifxStmt.setString( 9, getStringValueFromHSSFCell( row.getCell( 3 ) ) );
|
||||
//ifxStmt.setString( 10, getStringValueFromHSSFCell( row.getCell( 2 ) ) );
|
||||
@@ -206,7 +258,9 @@ public class DataImport
|
||||
importResult = importResult + "第" + rowIndex + "行,保单号" + policyNo + ",转介绍信息入成功!<br>";
|
||||
|
||||
successCount++;
|
||||
} catch (StaffCodeNotExistException error) {
|
||||
}
|
||||
catch ( StaffCodeNotExistException error )
|
||||
{
|
||||
//经办人不存在
|
||||
importResult = importResult + "第" + rowIndex + "行,保单号" + policyNo + ",经办人" + operatorCode + "不存在。<br>";
|
||||
|
||||
@@ -215,7 +269,9 @@ public class DataImport
|
||||
|
||||
//计数
|
||||
failCount++;
|
||||
} catch (OracleConnectionException error) {
|
||||
}
|
||||
catch ( OracleConnectionException error )
|
||||
{
|
||||
//查询工号失败
|
||||
importResult = importResult + "第" + rowIndex + "行,保单号" + policyNo + ",经办人" + operatorCode + ",查询工号失败。<br>";
|
||||
|
||||
@@ -224,10 +280,13 @@ public class DataImport
|
||||
|
||||
//计数
|
||||
failCount++;
|
||||
} catch (SQLException error) {
|
||||
}
|
||||
catch ( SQLException error )
|
||||
{
|
||||
int errorCode = error.getErrorCode();
|
||||
|
||||
switch (errorCode) {
|
||||
switch ( errorCode )
|
||||
{
|
||||
case -268: //保单号重复
|
||||
importResult = importResult + "第" + rowIndex + "行,保单号" + policyNo + ",已录入过转介绍信息!" + error.getCause() + "。<br>";
|
||||
break;
|
||||
@@ -243,7 +302,9 @@ public class DataImport
|
||||
|
||||
//计数
|
||||
failCount++;
|
||||
} catch (Exception error) {
|
||||
}
|
||||
catch ( Exception error )
|
||||
{
|
||||
//写入错误
|
||||
importResult = importResult + "第" + rowIndex + "行,保单号" + policyNo + ",数据库写入错误,错误信息:" + error.getMessage() + "。<br>";
|
||||
|
||||
@@ -252,13 +313,15 @@ public class DataImport
|
||||
|
||||
//计数
|
||||
failCount++;
|
||||
} finally {
|
||||
}
|
||||
finally
|
||||
{
|
||||
ifxConn.commit();
|
||||
}
|
||||
}
|
||||
|
||||
rowIndex++;
|
||||
row = sheet.getRow(rowIndex);
|
||||
row = sheet.getRow( rowIndex );
|
||||
}
|
||||
|
||||
//判断标志位,如果为false,则说明在保存过程中出现了错误,放弃所有过程,进行回滚。
|
||||
@@ -277,7 +340,7 @@ public class DataImport
|
||||
xlsFileIn.close();
|
||||
|
||||
//日志
|
||||
importMessage = "读取记录数量:" + (rowIndex - 1) +
|
||||
importMessage = "读取记录数量:" + ( rowIndex - 1 ) +
|
||||
"<br>写入记录数量:" + successCount +
|
||||
"<br>错误记录数量:" + failCount + "<br>";
|
||||
|
||||
@@ -298,37 +361,45 @@ public class DataImport
|
||||
return importMessage;
|
||||
}
|
||||
|
||||
private static String getStringValueFromHSSFCell(HSSFCell cell)
|
||||
private static String getStringValueFromHSSFCell( HSSFCell cell )
|
||||
{
|
||||
String value = null;
|
||||
|
||||
if (cell == null) {
|
||||
if ( cell == null )
|
||||
{
|
||||
return "";
|
||||
}
|
||||
|
||||
switch (cell.getCellType()) {
|
||||
case HSSFCell.CELL_TYPE_NUMERIC: {
|
||||
switch ( cell.getCellType() )
|
||||
{
|
||||
case HSSFCell.CELL_TYPE_NUMERIC:
|
||||
{
|
||||
//判断是不是整数
|
||||
double dValue = cell.getNumericCellValue();
|
||||
|
||||
if (dValue == (int) dValue) {
|
||||
value = String.valueOf((int) dValue);
|
||||
if ( dValue == (int) dValue )
|
||||
{
|
||||
value = String.valueOf( (int) dValue );
|
||||
}
|
||||
else {
|
||||
value = String.valueOf(dValue);
|
||||
else
|
||||
{
|
||||
value = String.valueOf( dValue );
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
case HSSFCell.CELL_TYPE_STRING: {
|
||||
case HSSFCell.CELL_TYPE_STRING:
|
||||
{
|
||||
value = cell.getStringCellValue();
|
||||
break;
|
||||
}
|
||||
case HSSFCell.CELL_TYPE_BLANK: {
|
||||
case HSSFCell.CELL_TYPE_BLANK:
|
||||
{
|
||||
value = "";
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
default:
|
||||
{
|
||||
value = "";
|
||||
break;
|
||||
}
|
||||
@@ -336,6 +407,14 @@ public class DataImport
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
public static void saveTelsalePolicyDataToOracle( String dbURL,
|
||||
String userName,
|
||||
String password,
|
||||
ArrayList<TelsalePolicyRecord> policyList )
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@@ -16,8 +16,140 @@ public class TelsalePolicyRecord
|
||||
* @Date: 2021/6/21 */
|
||||
public TelsalePolicyRecord( String policyNo, String operatorCode )
|
||||
{
|
||||
this.policyNo = policyNo;
|
||||
this.operatorCode = operatorCode;
|
||||
}
|
||||
|
||||
|
||||
public String getPolicyNo()
|
||||
{
|
||||
return policyNo;
|
||||
}
|
||||
|
||||
public void setPolicyNo( String policyNo )
|
||||
{
|
||||
this.policyNo = policyNo;
|
||||
}
|
||||
|
||||
public String getOperatorCode()
|
||||
{
|
||||
return operatorCode;
|
||||
}
|
||||
|
||||
public void setOperatorCode( String operatorCode )
|
||||
{
|
||||
this.operatorCode = operatorCode;
|
||||
}
|
||||
|
||||
public String getOperatorName()
|
||||
{
|
||||
return operatorName;
|
||||
}
|
||||
|
||||
public void setOperatorName( String operatorName )
|
||||
{
|
||||
this.operatorName = operatorName;
|
||||
}
|
||||
|
||||
public String getOperatorSectionOfficeCode()
|
||||
{
|
||||
return operatorSectionOfficeCode;
|
||||
}
|
||||
|
||||
public void setOperatorSectionOfficeCode( String operatorSectionOfficeCode )
|
||||
{
|
||||
this.operatorSectionOfficeCode = operatorSectionOfficeCode;
|
||||
}
|
||||
|
||||
public String getOperatorSectionOfficeName()
|
||||
{
|
||||
return operatorSectionOfficeName;
|
||||
}
|
||||
|
||||
public void setOperatorSectionOfficeName( String operatorSectionOfficeName )
|
||||
{
|
||||
this.operatorSectionOfficeName = operatorSectionOfficeName;
|
||||
}
|
||||
|
||||
public String getOperatorSectionDepartmentCode()
|
||||
{
|
||||
return operatorSectionDepartmentCode;
|
||||
}
|
||||
|
||||
public void setOperatorSectionDepartmentCode( String operatorSectionDepartmentCode )
|
||||
{
|
||||
this.operatorSectionDepartmentCode = operatorSectionDepartmentCode;
|
||||
}
|
||||
|
||||
public String getOperatorSectionDepartmentName()
|
||||
{
|
||||
return operatorSectionDepartmentName;
|
||||
}
|
||||
|
||||
public void setOperatorSectionDepartmentName( String operatorSectionDepartmentName )
|
||||
{
|
||||
this.operatorSectionDepartmentName = operatorSectionDepartmentName;
|
||||
}
|
||||
|
||||
public String getEntryStaffCode()
|
||||
{
|
||||
return entryStaffCode;
|
||||
}
|
||||
|
||||
public void setEntryStaffCode( String entryStaffCode )
|
||||
{
|
||||
this.entryStaffCode = entryStaffCode;
|
||||
}
|
||||
|
||||
public String getEntryStaffName()
|
||||
{
|
||||
return entryStaffName;
|
||||
}
|
||||
|
||||
public void setEntryStaffName( String entryStaffName )
|
||||
{
|
||||
this.entryStaffName = entryStaffName;
|
||||
}
|
||||
|
||||
public String getEntryStaffSectionOfficeCode()
|
||||
{
|
||||
return entryStaffSectionOfficeCode;
|
||||
}
|
||||
|
||||
public void setEntryStaffSectionOfficeCode( String entryStaffSectionOfficeCode )
|
||||
{
|
||||
this.entryStaffSectionOfficeCode = entryStaffSectionOfficeCode;
|
||||
}
|
||||
|
||||
public String getEntryStaffSectionOfficeName()
|
||||
{
|
||||
return entryStaffSectionOfficeName;
|
||||
}
|
||||
|
||||
public void setEntryStaffSectionOfficeName( String entryStaffSectionOfficeName )
|
||||
{
|
||||
this.entryStaffSectionOfficeName = entryStaffSectionOfficeName;
|
||||
}
|
||||
|
||||
public String getEntryStaffSectionDepartmentCode()
|
||||
{
|
||||
return entryStaffSectionDepartmentCode;
|
||||
}
|
||||
|
||||
public void setEntryStaffSectionDepartmentCode( String entryStaffSectionDepartmentCode )
|
||||
{
|
||||
this.entryStaffSectionDepartmentCode = entryStaffSectionDepartmentCode;
|
||||
}
|
||||
|
||||
public String getEntryStaffSectionDepartmentName()
|
||||
{
|
||||
return entryStaffSectionDepartmentName;
|
||||
}
|
||||
|
||||
public void setEntryStaffSectionDepartmentName( String entryStaffSectionDepartmentName )
|
||||
{
|
||||
this.entryStaffSectionDepartmentName = entryStaffSectionDepartmentName;
|
||||
}
|
||||
|
||||
private String policyNo;
|
||||
//经办人
|
||||
private String operatorCode;
|
||||
|
@@ -4,6 +4,7 @@ package com.cpic.telsale.uploadData;
|
||||
* Created by Kane on 2017/3/27.
|
||||
*/
|
||||
|
||||
import com.cpic.telsale.TelsalePolicyRecord;
|
||||
import org.apache.commons.fileupload.*;
|
||||
import org.apache.commons.fileupload.disk.DiskFileItemFactory;
|
||||
import org.apache.commons.fileupload.servlet.ServletFileUpload;
|
||||
@@ -26,23 +27,31 @@ public class uploadDataProcessor extends HttpServlet
|
||||
private String telsalePolicyOperatorListTableName; //informix库电销转介绍表名
|
||||
|
||||
@Override
|
||||
public void init( ServletConfig config ) throws ServletException
|
||||
public void init( ServletConfig config )
|
||||
throws
|
||||
ServletException
|
||||
{
|
||||
//获取参数
|
||||
oracleURL = ( String )config.getServletContext().getInitParameter( "oracleURL" );
|
||||
oracleUserName = ( String )config.getServletContext().getInitParameter( "oracleUserName" );
|
||||
oraclePassword = ( String )config.getServletContext().getInitParameter( "oraclePassword" );
|
||||
oracleURL = (String) config.getServletContext().getInitParameter( "oracleURL" );
|
||||
oracleUserName = (String) config.getServletContext().getInitParameter( "oracleUserName" );
|
||||
oraclePassword = (String) config.getServletContext().getInitParameter( "oraclePassword" );
|
||||
|
||||
//informix
|
||||
informixURL = ( String )config.getServletContext().getInitParameter( "informixURL" );
|
||||
telsalePolicyOperatorListTableName = (String)config.getServletContext().getInitParameter( "telsalePolicyOperatorListTableName" );
|
||||
informixURL = (String) config.getServletContext().getInitParameter( "informixURL" );
|
||||
telsalePolicyOperatorListTableName = (String) config.getServletContext()
|
||||
.getInitParameter( "telsalePolicyOperatorListTableName" );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void doPost( HttpServletRequest request, HttpServletResponse response ) throws ServletException, IOException
|
||||
public void doPost( HttpServletRequest request, HttpServletResponse response )
|
||||
throws
|
||||
ServletException,
|
||||
IOException
|
||||
{
|
||||
tempPathRoot = ( String )request.getSession().getAttribute( "临时文件根目录" );
|
||||
String importMessage = null;
|
||||
tempPathRoot = (String) request.getSession().getAttribute( "临时文件根目录" );
|
||||
|
||||
String importMessage = null;
|
||||
ArrayList<TelsalePolicyRecord> policyRecordList = new ArrayList<TelsalePolicyRecord>();
|
||||
|
||||
try
|
||||
{
|
||||
@@ -53,39 +62,42 @@ public class uploadDataProcessor extends HttpServlet
|
||||
ServletFileUpload upload = new ServletFileUpload( factory );
|
||||
|
||||
List<FileItem> uploadFiles = upload.parseRequest( request );
|
||||
Iterator iterFiles = uploadFiles.iterator();
|
||||
Iterator iterFiles = uploadFiles.iterator();
|
||||
|
||||
while ( iterFiles.hasNext() )
|
||||
{
|
||||
FileItem fileItem = ( FileItem )iterFiles.next();
|
||||
FileItem fileItem = (FileItem) iterFiles.next();
|
||||
|
||||
if ( !fileItem.isFormField() )
|
||||
{
|
||||
//保存上传的文件,返回文件完整路径。
|
||||
String upLoadedFileName = saveUploadedFile( fileItem );
|
||||
|
||||
importMessage = DataImport.importTelsalePolicyDataFromXlsx( upLoadedFileName,
|
||||
telsalePolicyOperatorListTableName,
|
||||
informixURL );
|
||||
//测试
|
||||
policyRecordList = DataImport.readTelsalePolicyDataFromXlsx( upLoadedFileName, 0 );
|
||||
|
||||
// importMessage = DataImport.importTelsalePolicyDataFromXlsx( upLoadedFileName,
|
||||
// telsalePolicyOperatorListTableName,
|
||||
// informixURL );
|
||||
}
|
||||
}
|
||||
}
|
||||
catch( FileUploadException error )
|
||||
catch ( FileUploadException error )
|
||||
{
|
||||
//文件上传有异常,包装一下重新抛出
|
||||
throw new ServletException( error.getMessage() );
|
||||
}
|
||||
catch( XlsFileFormatException error )
|
||||
catch ( XlsFileFormatException error )
|
||||
{
|
||||
//文件格式异常
|
||||
importMessage = error.getMessage();
|
||||
}
|
||||
catch( IOException error )
|
||||
catch ( IOException error )
|
||||
{
|
||||
//包装一下重新抛出
|
||||
throw new ServletException( error.getMessage() );
|
||||
}
|
||||
catch( Exception error )
|
||||
catch ( Exception error )
|
||||
{
|
||||
throw new ServletException( error.getMessage() );
|
||||
}
|
||||
@@ -104,12 +116,14 @@ public class uploadDataProcessor extends HttpServlet
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
private String saveUploadedFile( FileItem item ) throws Exception
|
||||
private String saveUploadedFile( FileItem item )
|
||||
throws
|
||||
Exception
|
||||
{
|
||||
String fileName = item.getName();
|
||||
|
||||
int fileNameIndex = 0;
|
||||
long fileSize = item.getSize();
|
||||
int fileNameIndex = 0;
|
||||
long fileSize = item.getSize();
|
||||
|
||||
//文件路径中可能有使用\和/作为目录分隔符,要分别判断
|
||||
fileNameIndex = fileName.lastIndexOf( "\\" );
|
||||
|
Reference in New Issue
Block a user