...
This commit is contained in:
parent
83c26ecec9
commit
92d5d75e59
@ -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( "\\" );
|
||||
|
@ -4,14 +4,51 @@ CREATE OR REPLACE PACKAGE telsale_policy_check_pkg IS
|
||||
-- Created : 2021/6/21 10:18:01
|
||||
-- Purpose : µçÏú±£µ¥Êý¾ÝÑéÖ¤
|
||||
|
||||
/***************************************************************************/
|
||||
--定义异常
|
||||
--保单号不存在
|
||||
POLICYNO_NOT_EXIST_EXCEPT_CODE CONSTANT INTEGER := -20000;
|
||||
POLICYNO_NOT_EXIST_EXCEPT_TEXT CONSTANT VARCHAR2(100) := '保单号不存在。';
|
||||
|
||||
--经办人不存在
|
||||
OPERATOE_CODE_NOT_EXIST_EXCEPT_CODE CONSTANT INTEGER := -20001;
|
||||
OPERATOE_CODE_NOT_EXIST_EXCEPT_TEXT CONSTANT VARCHAR2(100) := '经办人工号不存在。';
|
||||
|
||||
--录入人不存在
|
||||
ENTRY_STAFF_CODE_NOT_EXIST_EXCEPT_CODE CONSTANT INTEGER := -20002;
|
||||
ENTRY_STAFF_CODE_NOT_EXIST_EXCEPT_TEXT CONSTANT VARCHAR2(100) := '录入人工号不存在。';
|
||||
|
||||
--经办人工号所在科室与保单不匹配
|
||||
OPERATOE_CODE_NOT_MATCH_EXCEPT_CODE CONSTANT INTEGER := -20003;
|
||||
OPERATOE_CODE_NOT_MATCH_EXCEPT_TEXT CONSTANT VARCHAR2(100) := '经办人工号所在科室与保单归属不匹配。';
|
||||
|
||||
/***************************************************************************/
|
||||
FUNCTION policy_check(a_policy_no VARCHAR2) RETURN BOOLEAN;
|
||||
|
||||
FUNCTION staff_check(a_stuff_code VARCHAR2) RETURN BOOLEAN;
|
||||
|
||||
PROCEDURE save_policy
|
||||
(
|
||||
a_policy_no IN VARCHAR2,
|
||||
a_operator_code IN VARCHAR2,
|
||||
a_operator_name OUT VARCHAR2,
|
||||
a_operator_sectionoffice_code OUT VARCHAR2,
|
||||
a_operator_sectionoffice_name OUT VARCHAR2,
|
||||
a_operator_department_code OUT VARCHAR2,
|
||||
a_operator_department_name OUT VARCHAR2,
|
||||
a_entry_staff_code IN VARCHAR2,
|
||||
a_entry_staff_name OUT VARCHAR2,
|
||||
a_entry_staff_sectionoffice_code OUT VARCHAR2,
|
||||
a_entry_staff_sectionoffice_name OUT VARCHAR2,
|
||||
a_entry_staff_department_code OUT VARCHAR2,
|
||||
a_entry_staff_department_name OUT VARCHAR2
|
||||
);
|
||||
|
||||
END telsale_policy_check_pkg;
|
||||
/
|
||||
CREATE OR REPLACE PACKAGE BODY telsale_policy_check_pkg IS
|
||||
|
||||
/*********************************************************************************/
|
||||
FUNCTION staff_check(a_stuff_code VARCHAR2) RETURN BOOLEAN IS
|
||||
l_count INTEGER;
|
||||
BEGIN
|
||||
@ -28,6 +65,7 @@ CREATE OR REPLACE PACKAGE BODY telsale_policy_check_pkg IS
|
||||
RETURN TRUE;
|
||||
END;
|
||||
|
||||
/*********************************************************************************/
|
||||
FUNCTION policy_check(a_policy_no VARCHAR2) RETURN BOOLEAN IS
|
||||
l_count INTEGER;
|
||||
BEGIN
|
||||
@ -43,6 +81,33 @@ CREATE OR REPLACE PACKAGE BODY telsale_policy_check_pkg IS
|
||||
|
||||
RETURN TRUE;
|
||||
END;
|
||||
|
||||
/*********************************************************************************/
|
||||
PROCEDURE save_policy
|
||||
(
|
||||
a_policy_no IN VARCHAR2,
|
||||
a_operator_code IN VARCHAR2,
|
||||
a_operator_name OUT VARCHAR2,
|
||||
a_operator_sectionoffice_code OUT VARCHAR2,
|
||||
a_operator_sectionoffice_name OUT VARCHAR2,
|
||||
a_operator_department_code OUT VARCHAR2,
|
||||
a_operator_department_name OUT VARCHAR2,
|
||||
a_entry_staff_code IN VARCHAR2,
|
||||
a_entry_staff_name OUT VARCHAR2,
|
||||
a_entry_staff_sectionoffice_code OUT VARCHAR2,
|
||||
a_entry_staff_sectionoffice_name OUT VARCHAR2,
|
||||
a_entry_staff_department_code OUT VARCHAR2,
|
||||
a_entry_staff_department_name OUT VARCHAR2
|
||||
) IS
|
||||
l_policy_section_code VARCHAR2(6);
|
||||
l_policy_department_code VARCHAR2(6);
|
||||
BEGIN
|
||||
NULL;
|
||||
|
||||
--判断保单号是否存在,以及保单号的科室部门和经办人是否相同
|
||||
|
||||
END;
|
||||
|
||||
BEGIN
|
||||
NULL;
|
||||
END telsale_policy_check_pkg;
|
||||
|
100
代码/oracle/项目/包/telsale_policy_check_pkg.~pck
Normal file
100
代码/oracle/项目/包/telsale_policy_check_pkg.~pck
Normal file
@ -0,0 +1,100 @@
|
||||
CREATE OR REPLACE PACKAGE telsale_policy_check_pkg IS
|
||||
|
||||
-- Author : 王炜
|
||||
-- Created : 2021/6/21 10:18:01
|
||||
-- Purpose : 电销保单数据验证
|
||||
|
||||
--定义异常
|
||||
--保单号不存在
|
||||
POLICYNO_NOT_EXIST_EXCEPT_CODE CONSTANT INTEGER := -20000;
|
||||
POLICYNO_NOT_EXIST_EXCEPT_TEXT CONSTANT VARCHAR2(100) := '保单号不存在。';
|
||||
|
||||
FUNCTION policy_check(a_policy_no VARCHAR2) RETURN BOOLEAN;
|
||||
|
||||
FUNCTION staff_check(a_stuff_code VARCHAR2) RETURN BOOLEAN;
|
||||
|
||||
PROCEDURE save_policy
|
||||
(
|
||||
a_policy_no IN VARCHAR2,
|
||||
a_operator_code IN VARCHAR2,
|
||||
a_operator_name OUT VARCHAR2,
|
||||
a_operator_sectionoffice_code OUT VARCHAR2,
|
||||
a_operator_sectionoffice_name OUT VARCHAR2,
|
||||
a_operator_department_code OUT VARCHAR2,
|
||||
a_operator_department_name OUT VARCHAR2,
|
||||
a_entry_staff_code IN VARCHAR2,
|
||||
a_entry_staff_name OUT VARCHAR2,
|
||||
a_entry_staff_sectionoffice_code OUT VARCHAR2,
|
||||
a_entry_staff_sectionoffice_name OUT VARCHAR2,
|
||||
a_entry_staff_department_code OUT VARCHAR2,
|
||||
a_entry_staff_department_name OUT VARCHAR2
|
||||
);
|
||||
|
||||
END telsale_policy_check_pkg;
|
||||
/
|
||||
CREATE OR REPLACE PACKAGE BODY telsale_policy_check_pkg IS
|
||||
|
||||
/*********************************************************************************/
|
||||
FUNCTION staff_check(a_stuff_code VARCHAR2) RETURN BOOLEAN IS
|
||||
l_count INTEGER;
|
||||
BEGIN
|
||||
SELECT COUNT(*)
|
||||
INTO l_count
|
||||
FROM idst0.rydm_t@xmcx1.cpicxm ry
|
||||
WHERE ry.staff_code = a_stuff_code;
|
||||
|
||||
IF l_count = 0
|
||||
THEN
|
||||
RETURN FALSE;
|
||||
END IF;
|
||||
|
||||
RETURN TRUE;
|
||||
END;
|
||||
|
||||
/*********************************************************************************/
|
||||
FUNCTION policy_check(a_policy_no VARCHAR2) RETURN BOOLEAN IS
|
||||
l_count INTEGER;
|
||||
BEGIN
|
||||
SELECT COUNT(*)
|
||||
INTO l_count
|
||||
FROM idst0.auto_agreement_t@xmcx1.cpicxm a
|
||||
WHERE a.policy_no = a_policy_no;
|
||||
|
||||
IF l_count = 0
|
||||
THEN
|
||||
RETURN FALSE;
|
||||
END IF;
|
||||
|
||||
RETURN TRUE;
|
||||
END;
|
||||
|
||||
/*********************************************************************************/
|
||||
PROCEDURE save_policy
|
||||
(
|
||||
a_policy_no IN VARCHAR2,
|
||||
a_operator_code IN VARCHAR2,
|
||||
a_operator_name OUT VARCHAR2,
|
||||
a_operator_sectionoffice_code OUT VARCHAR2,
|
||||
a_operator_sectionoffice_name OUT VARCHAR2,
|
||||
a_operator_department_code OUT VARCHAR2,
|
||||
a_operator_department_name OUT VARCHAR2,
|
||||
a_entry_staff_code IN VARCHAR2,
|
||||
a_entry_staff_name OUT VARCHAR2,
|
||||
a_entry_staff_sectionoffice_code OUT VARCHAR2,
|
||||
a_entry_staff_sectionoffice_name OUT VARCHAR2,
|
||||
a_entry_staff_department_code OUT VARCHAR2,
|
||||
a_entry_staff_department_name OUT VARCHAR2
|
||||
) IS
|
||||
l_policy_section_code VARCHAR2(6);
|
||||
l_policy_department_code VARCHAR2(6);
|
||||
BEGIN
|
||||
NULL;
|
||||
|
||||
--判断保单号是否存在,以及保单号的科室部门和经办人是否相同
|
||||
|
||||
END;
|
||||
|
||||
BEGIN
|
||||
NULL;
|
||||
END telsale_policy_check_pkg;
|
||||
/
|
@ -3,10 +3,30 @@ PL/SQL Developer Project Desktop
|
||||
[Desktop]
|
||||
SavePath=D:\develop\projects_win\2018\telsale_management_2017\代码\oracle\项目\
|
||||
|
||||
Index=1
|
||||
Filename=D:\develop\projects_win\2018\telsale_management_2017\덜쯤\oracle\淃커\관\telsale_policy_check_pkg.pck
|
||||
VCSDBObject=0
|
||||
Connection=282441544404455840724370446043583456492241804558450434903180323832003290342849744968477032763302336047784788
|
||||
DPI=96
|
||||
Left=0
|
||||
Top=0
|
||||
Width=1329
|
||||
Height=719
|
||||
State=0
|
||||
Type=3
|
||||
ChildListIndex=1
|
||||
Pinned=0
|
||||
|
||||
Index=2
|
||||
Filename=
|
||||
Connection=226450024772463846324866505249184048433046445054493639223676363836323754389245424568427437403734382438343844
|
||||
|
||||
[Files]
|
||||
|
||||
[MRU]
|
||||
3,D:\develop\projects_win\2018\telsale_management_2017\덜쯤\oracle\淃커\관\telsale_policy_check_pkg.pck
|
||||
1,D:\develop\projects_win\2018\telsale_management_2017\代码\oracle\项目\建表\电销保单信息表.sql
|
||||
1,D:\develop\projects_win\2018\telsale_management_2017\덜쯤\oracle\淃커\쉔깊\든饋괏데斤口쩌흙휑羚깊.sql
|
||||
|
||||
[Layout]
|
||||
Group=
|
||||
|
BIN
数据/测试数据/有空行.xls
Normal file
BIN
数据/测试数据/有空行.xls
Normal file
Binary file not shown.
BIN
数据/测试数据/有空行,有保单号错误.xls
Normal file
BIN
数据/测试数据/有空行,有保单号错误.xls
Normal file
Binary file not shown.
BIN
数据/测试数据/转介绍模板.xls
Normal file
BIN
数据/测试数据/转介绍模板.xls
Normal file
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user