...
This commit is contained in:
parent
83c26ecec9
commit
92d5d75e59
@ -25,10 +25,9 @@ public class DataImport
|
|||||||
* @Author: 王炜
|
* @Author: 王炜
|
||||||
* @Date: 2021/6/21
|
* @Date: 2021/6/21
|
||||||
*/
|
*/
|
||||||
public static ArrayList<TelsalePolicyRecord> readTelsalePolicyDataFromXlsx(String fileName, int sheetIndex) throws
|
public static ArrayList<TelsalePolicyRecord> readTelsalePolicyDataFromXlsx( String fileName, int sheetIndex )
|
||||||
IOException,
|
throws IOException,
|
||||||
SQLException,
|
XlsFileFormatException
|
||||||
XlsFileFormatException
|
|
||||||
{
|
{
|
||||||
ArrayList<TelsalePolicyRecord> policyList = new ArrayList<TelsalePolicyRecord>();
|
ArrayList<TelsalePolicyRecord> policyList = new ArrayList<TelsalePolicyRecord>();
|
||||||
|
|
||||||
@ -39,32 +38,79 @@ public class DataImport
|
|||||||
HSSFSheet sheet = null;
|
HSSFSheet sheet = null;
|
||||||
HSSFRow row = null;
|
HSSFRow row = null;
|
||||||
|
|
||||||
int rowIndex = 0;
|
int rowIndex = 0;
|
||||||
int rowCount = 0;
|
int rowCount = 0;
|
||||||
|
int errorCount = 0;
|
||||||
|
String errorMessage = "数据错误,请修正后重新上传!<br>\n";
|
||||||
|
|
||||||
try {
|
try
|
||||||
xlsxFile = new FileInputStream(fileName);
|
{
|
||||||
workBook = new HSSFWorkbook(xlsxFile);
|
xlsxFile = new FileInputStream( fileName );
|
||||||
sheet = workBook.getSheetAt(sheetIndex);
|
workBook = new HSSFWorkbook( xlsxFile );
|
||||||
rowIndex = sheet.getFirstRowNum() + 1;
|
sheet = workBook.getSheetAt( sheetIndex );
|
||||||
|
rowIndex = sheet.getFirstRowNum();
|
||||||
rowCount = sheet.getLastRowNum();
|
rowCount = sheet.getLastRowNum();
|
||||||
row = sheet.getRow(rowIndex);
|
|
||||||
|
|
||||||
while (rowIndex <= rowCount) {
|
while ( rowIndex <= rowCount )
|
||||||
|
{
|
||||||
//用第一个单元格判断是不是空行,如果cell为null视为空行
|
//用第一个单元格判断是不是空行,如果cell为null视为空行
|
||||||
HSSFCell cell = row.getCell(0);
|
row = sheet.getRow( rowIndex );
|
||||||
|
HSSFCell cell = row.getCell( 0 );
|
||||||
|
|
||||||
if (cell == null) {
|
if ( cell == null )
|
||||||
|
{
|
||||||
rowIndex++;
|
rowIndex++;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
String policyNo = cell.getStringCellValue();
|
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;
|
return policyList;
|
||||||
@ -82,13 +128,13 @@ public class DataImport
|
|||||||
* @throws SQLException 数据库异常
|
* @throws SQLException 数据库异常
|
||||||
* @throws XlsFileFormatException xls文件格式错误异常
|
* @throws XlsFileFormatException xls文件格式错误异常
|
||||||
*/
|
*/
|
||||||
public static String importTelsalePolicyDataFromXlsx(String fileName,
|
public static String importTelsalePolicyDataFromXlsx( String fileName,
|
||||||
String telsalePolicyOperatorListTableName,
|
String telsalePolicyOperatorListTableName,
|
||||||
String informixURL) throws
|
String informixURL )
|
||||||
IOException,
|
throws IOException,
|
||||||
ClassNotFoundException,
|
ClassNotFoundException,
|
||||||
SQLException,
|
SQLException,
|
||||||
XlsFileFormatException
|
XlsFileFormatException
|
||||||
{
|
{
|
||||||
String importResult = "";
|
String importResult = "";
|
||||||
String importMessage = null;
|
String importMessage = null;
|
||||||
@ -103,23 +149,25 @@ public class DataImport
|
|||||||
HSSFSheet sheet = null;
|
HSSFSheet sheet = null;
|
||||||
HSSFRow row = null;
|
HSSFRow row = null;
|
||||||
|
|
||||||
try {
|
try
|
||||||
xlsFileIn = new FileInputStream(fileName);
|
{
|
||||||
xlsFile = new HSSFWorkbook(xlsFileIn);
|
xlsFileIn = new FileInputStream( fileName );
|
||||||
sheet = xlsFile.getSheetAt(0); //第一个sheet
|
xlsFile = new HSSFWorkbook( xlsFileIn );
|
||||||
|
sheet = xlsFile.getSheetAt( 0 ); //第一个sheet
|
||||||
rowIndex = sheet.getFirstRowNum() + 1;
|
rowIndex = sheet.getFirstRowNum() + 1;
|
||||||
rowCount = sheet.getLastRowNum();
|
rowCount = sheet.getLastRowNum();
|
||||||
row = sheet.getRow(rowIndex);
|
row = sheet.getRow( rowIndex );
|
||||||
} catch (IOException error) //有文件格式错误的可能。
|
}
|
||||||
|
catch ( IOException error ) //有文件格式错误的可能。
|
||||||
{
|
{
|
||||||
xlsFile.close();
|
xlsFile.close();
|
||||||
xlsFileIn.close();
|
xlsFileIn.close();
|
||||||
|
|
||||||
throw new XlsFileFormatException("文件格式错误,请检查是否xls格式文件。");
|
throw new XlsFileFormatException( "文件格式错误,请检查是否xls格式文件。" );
|
||||||
}
|
}
|
||||||
|
|
||||||
//informix相关
|
//informix相关
|
||||||
Class.forName("com.informix.jdbc.IfxDriver");
|
Class.forName( "com.informix.jdbc.IfxDriver" );
|
||||||
String ifxSql =
|
String ifxSql =
|
||||||
"INSERT INTO " + telsalePolicyOperatorListTableName + " \n" +
|
"INSERT INTO " + telsalePolicyOperatorListTableName + " \n" +
|
||||||
" (bdh,\n" +
|
" (bdh,\n" +
|
||||||
@ -153,10 +201,10 @@ public class DataImport
|
|||||||
" 1,\n" +
|
" 1,\n" +
|
||||||
" '800',\n" +
|
" '800',\n" +
|
||||||
" today)";
|
" today)";
|
||||||
Connection ifxConn = DriverManager.getConnection(informixURL);
|
Connection ifxConn = DriverManager.getConnection( informixURL );
|
||||||
PreparedStatement ifxStmt = ifxConn.prepareStatement(ifxSql);
|
PreparedStatement ifxStmt = ifxConn.prepareStatement( ifxSql );
|
||||||
|
|
||||||
ifxConn.setAutoCommit(false);//关闭自动提交,整个表格要么全部成写入,要么全部失败。
|
ifxConn.setAutoCommit( false );//关闭自动提交,整个表格要么全部成写入,要么全部失败。
|
||||||
|
|
||||||
//数据相关
|
//数据相关
|
||||||
String policyNo = null;
|
String policyNo = null;
|
||||||
@ -164,38 +212,42 @@ public class DataImport
|
|||||||
StaffInfo staff = null;
|
StaffInfo staff = null;
|
||||||
boolean isSuccess = true; //标志位,用来指示在保存过程中是否出现错误。
|
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++;
|
rowIndex++;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
policyNo = row.getCell(0).getStringCellValue().trim();
|
policyNo = row.getCell( 0 ).getStringCellValue().trim();
|
||||||
operatorCode = getStringValueFromHSSFCell(row.getCell(1));
|
operatorCode = getStringValueFromHSSFCell( row.getCell( 1 ) );
|
||||||
|
|
||||||
//判断一下是不是空的单元格
|
//判断一下是不是空的单元格
|
||||||
if (policyNo.length() == 0 || operatorCode.length() == 0) {
|
if ( policyNo.length() == 0 || operatorCode.length() == 0 )
|
||||||
|
{
|
||||||
importResult = importResult + "第" + rowIndex + "行数据为空。<br>";
|
importResult = importResult + "第" + rowIndex + "行数据为空。<br>";
|
||||||
|
|
||||||
//isSuccess = false;
|
//isSuccess = false;
|
||||||
}
|
}
|
||||||
else //不是空单元格,进行处理
|
else //不是空单元格,进行处理
|
||||||
{
|
{
|
||||||
try {
|
try
|
||||||
|
{
|
||||||
//取得经办人信息
|
//取得经办人信息
|
||||||
staff = new StaffInfo(operatorCode);
|
staff = new StaffInfo( operatorCode );
|
||||||
|
|
||||||
//写入informix
|
//写入informix
|
||||||
ifxStmt.setString(1, policyNo);
|
ifxStmt.setString( 1, policyNo );
|
||||||
ifxStmt.setString(2, staff.getStaffCode());
|
ifxStmt.setString( 2, staff.getStaffCode() );
|
||||||
ifxStmt.setString(3, staff.getStaffName());
|
ifxStmt.setString( 3, staff.getStaffName() );
|
||||||
ifxStmt.setString(4, staff.getSectionOfficeCode());
|
ifxStmt.setString( 4, staff.getSectionOfficeCode() );
|
||||||
ifxStmt.setString(5, staff.getSectionOfficeName());
|
ifxStmt.setString( 5, staff.getSectionOfficeName() );
|
||||||
ifxStmt.setString(6, staff.getDepartmentCode());
|
ifxStmt.setString( 6, staff.getDepartmentCode() );
|
||||||
ifxStmt.setString(7, staff.getDepartmentName());
|
ifxStmt.setString( 7, staff.getDepartmentName() );
|
||||||
//ifxStmt.setString( 8, getStringValueFromHSSFCell( row.getCell( 6 ) ) );
|
//ifxStmt.setString( 8, getStringValueFromHSSFCell( row.getCell( 6 ) ) );
|
||||||
//ifxStmt.setString( 9, getStringValueFromHSSFCell( row.getCell( 3 ) ) );
|
//ifxStmt.setString( 9, getStringValueFromHSSFCell( row.getCell( 3 ) ) );
|
||||||
//ifxStmt.setString( 10, getStringValueFromHSSFCell( row.getCell( 2 ) ) );
|
//ifxStmt.setString( 10, getStringValueFromHSSFCell( row.getCell( 2 ) ) );
|
||||||
@ -206,7 +258,9 @@ public class DataImport
|
|||||||
importResult = importResult + "第" + rowIndex + "行,保单号" + policyNo + ",转介绍信息入成功!<br>";
|
importResult = importResult + "第" + rowIndex + "行,保单号" + policyNo + ",转介绍信息入成功!<br>";
|
||||||
|
|
||||||
successCount++;
|
successCount++;
|
||||||
} catch (StaffCodeNotExistException error) {
|
}
|
||||||
|
catch ( StaffCodeNotExistException error )
|
||||||
|
{
|
||||||
//经办人不存在
|
//经办人不存在
|
||||||
importResult = importResult + "第" + rowIndex + "行,保单号" + policyNo + ",经办人" + operatorCode + "不存在。<br>";
|
importResult = importResult + "第" + rowIndex + "行,保单号" + policyNo + ",经办人" + operatorCode + "不存在。<br>";
|
||||||
|
|
||||||
@ -215,7 +269,9 @@ public class DataImport
|
|||||||
|
|
||||||
//计数
|
//计数
|
||||||
failCount++;
|
failCount++;
|
||||||
} catch (OracleConnectionException error) {
|
}
|
||||||
|
catch ( OracleConnectionException error )
|
||||||
|
{
|
||||||
//查询工号失败
|
//查询工号失败
|
||||||
importResult = importResult + "第" + rowIndex + "行,保单号" + policyNo + ",经办人" + operatorCode + ",查询工号失败。<br>";
|
importResult = importResult + "第" + rowIndex + "行,保单号" + policyNo + ",经办人" + operatorCode + ",查询工号失败。<br>";
|
||||||
|
|
||||||
@ -224,10 +280,13 @@ public class DataImport
|
|||||||
|
|
||||||
//计数
|
//计数
|
||||||
failCount++;
|
failCount++;
|
||||||
} catch (SQLException error) {
|
}
|
||||||
|
catch ( SQLException error )
|
||||||
|
{
|
||||||
int errorCode = error.getErrorCode();
|
int errorCode = error.getErrorCode();
|
||||||
|
|
||||||
switch (errorCode) {
|
switch ( errorCode )
|
||||||
|
{
|
||||||
case -268: //保单号重复
|
case -268: //保单号重复
|
||||||
importResult = importResult + "第" + rowIndex + "行,保单号" + policyNo + ",已录入过转介绍信息!" + error.getCause() + "。<br>";
|
importResult = importResult + "第" + rowIndex + "行,保单号" + policyNo + ",已录入过转介绍信息!" + error.getCause() + "。<br>";
|
||||||
break;
|
break;
|
||||||
@ -243,7 +302,9 @@ public class DataImport
|
|||||||
|
|
||||||
//计数
|
//计数
|
||||||
failCount++;
|
failCount++;
|
||||||
} catch (Exception error) {
|
}
|
||||||
|
catch ( Exception error )
|
||||||
|
{
|
||||||
//写入错误
|
//写入错误
|
||||||
importResult = importResult + "第" + rowIndex + "行,保单号" + policyNo + ",数据库写入错误,错误信息:" + error.getMessage() + "。<br>";
|
importResult = importResult + "第" + rowIndex + "行,保单号" + policyNo + ",数据库写入错误,错误信息:" + error.getMessage() + "。<br>";
|
||||||
|
|
||||||
@ -252,13 +313,15 @@ public class DataImport
|
|||||||
|
|
||||||
//计数
|
//计数
|
||||||
failCount++;
|
failCount++;
|
||||||
} finally {
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
ifxConn.commit();
|
ifxConn.commit();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
rowIndex++;
|
rowIndex++;
|
||||||
row = sheet.getRow(rowIndex);
|
row = sheet.getRow( rowIndex );
|
||||||
}
|
}
|
||||||
|
|
||||||
//判断标志位,如果为false,则说明在保存过程中出现了错误,放弃所有过程,进行回滚。
|
//判断标志位,如果为false,则说明在保存过程中出现了错误,放弃所有过程,进行回滚。
|
||||||
@ -277,7 +340,7 @@ public class DataImport
|
|||||||
xlsFileIn.close();
|
xlsFileIn.close();
|
||||||
|
|
||||||
//日志
|
//日志
|
||||||
importMessage = "读取记录数量:" + (rowIndex - 1) +
|
importMessage = "读取记录数量:" + ( rowIndex - 1 ) +
|
||||||
"<br>写入记录数量:" + successCount +
|
"<br>写入记录数量:" + successCount +
|
||||||
"<br>错误记录数量:" + failCount + "<br>";
|
"<br>错误记录数量:" + failCount + "<br>";
|
||||||
|
|
||||||
@ -298,37 +361,45 @@ public class DataImport
|
|||||||
return importMessage;
|
return importMessage;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static String getStringValueFromHSSFCell(HSSFCell cell)
|
private static String getStringValueFromHSSFCell( HSSFCell cell )
|
||||||
{
|
{
|
||||||
String value = null;
|
String value = null;
|
||||||
|
|
||||||
if (cell == null) {
|
if ( cell == null )
|
||||||
|
{
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (cell.getCellType()) {
|
switch ( cell.getCellType() )
|
||||||
case HSSFCell.CELL_TYPE_NUMERIC: {
|
{
|
||||||
|
case HSSFCell.CELL_TYPE_NUMERIC:
|
||||||
|
{
|
||||||
//判断是不是整数
|
//判断是不是整数
|
||||||
double dValue = cell.getNumericCellValue();
|
double dValue = cell.getNumericCellValue();
|
||||||
|
|
||||||
if (dValue == (int) dValue) {
|
if ( dValue == (int) dValue )
|
||||||
value = String.valueOf((int) dValue);
|
{
|
||||||
|
value = String.valueOf( (int) dValue );
|
||||||
}
|
}
|
||||||
else {
|
else
|
||||||
value = String.valueOf(dValue);
|
{
|
||||||
|
value = String.valueOf( dValue );
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case HSSFCell.CELL_TYPE_STRING: {
|
case HSSFCell.CELL_TYPE_STRING:
|
||||||
|
{
|
||||||
value = cell.getStringCellValue();
|
value = cell.getStringCellValue();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case HSSFCell.CELL_TYPE_BLANK: {
|
case HSSFCell.CELL_TYPE_BLANK:
|
||||||
|
{
|
||||||
value = "";
|
value = "";
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default: {
|
default:
|
||||||
|
{
|
||||||
value = "";
|
value = "";
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -336,6 +407,14 @@ public class DataImport
|
|||||||
|
|
||||||
return value;
|
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 */
|
* @Date: 2021/6/21 */
|
||||||
public TelsalePolicyRecord( String policyNo, String operatorCode )
|
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 policyNo;
|
||||||
//经办人
|
//经办人
|
||||||
private String operatorCode;
|
private String operatorCode;
|
||||||
|
@ -4,6 +4,7 @@ package com.cpic.telsale.uploadData;
|
|||||||
* Created by Kane on 2017/3/27.
|
* Created by Kane on 2017/3/27.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
import com.cpic.telsale.TelsalePolicyRecord;
|
||||||
import org.apache.commons.fileupload.*;
|
import org.apache.commons.fileupload.*;
|
||||||
import org.apache.commons.fileupload.disk.DiskFileItemFactory;
|
import org.apache.commons.fileupload.disk.DiskFileItemFactory;
|
||||||
import org.apache.commons.fileupload.servlet.ServletFileUpload;
|
import org.apache.commons.fileupload.servlet.ServletFileUpload;
|
||||||
@ -26,23 +27,31 @@ public class uploadDataProcessor extends HttpServlet
|
|||||||
private String telsalePolicyOperatorListTableName; //informix库电销转介绍表名
|
private String telsalePolicyOperatorListTableName; //informix库电销转介绍表名
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void init( ServletConfig config ) throws ServletException
|
public void init( ServletConfig config )
|
||||||
|
throws
|
||||||
|
ServletException
|
||||||
{
|
{
|
||||||
//获取参数
|
//获取参数
|
||||||
oracleURL = ( String )config.getServletContext().getInitParameter( "oracleURL" );
|
oracleURL = (String) config.getServletContext().getInitParameter( "oracleURL" );
|
||||||
oracleUserName = ( String )config.getServletContext().getInitParameter( "oracleUserName" );
|
oracleUserName = (String) config.getServletContext().getInitParameter( "oracleUserName" );
|
||||||
oraclePassword = ( String )config.getServletContext().getInitParameter( "oraclePassword" );
|
oraclePassword = (String) config.getServletContext().getInitParameter( "oraclePassword" );
|
||||||
|
|
||||||
//informix
|
//informix
|
||||||
informixURL = ( String )config.getServletContext().getInitParameter( "informixURL" );
|
informixURL = (String) config.getServletContext().getInitParameter( "informixURL" );
|
||||||
telsalePolicyOperatorListTableName = (String)config.getServletContext().getInitParameter( "telsalePolicyOperatorListTableName" );
|
telsalePolicyOperatorListTableName = (String) config.getServletContext()
|
||||||
|
.getInitParameter( "telsalePolicyOperatorListTableName" );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@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( "临时文件根目录" );
|
tempPathRoot = (String) request.getSession().getAttribute( "临时文件根目录" );
|
||||||
String importMessage = null;
|
|
||||||
|
String importMessage = null;
|
||||||
|
ArrayList<TelsalePolicyRecord> policyRecordList = new ArrayList<TelsalePolicyRecord>();
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@ -53,39 +62,42 @@ public class uploadDataProcessor extends HttpServlet
|
|||||||
ServletFileUpload upload = new ServletFileUpload( factory );
|
ServletFileUpload upload = new ServletFileUpload( factory );
|
||||||
|
|
||||||
List<FileItem> uploadFiles = upload.parseRequest( request );
|
List<FileItem> uploadFiles = upload.parseRequest( request );
|
||||||
Iterator iterFiles = uploadFiles.iterator();
|
Iterator iterFiles = uploadFiles.iterator();
|
||||||
|
|
||||||
while ( iterFiles.hasNext() )
|
while ( iterFiles.hasNext() )
|
||||||
{
|
{
|
||||||
FileItem fileItem = ( FileItem )iterFiles.next();
|
FileItem fileItem = (FileItem) iterFiles.next();
|
||||||
|
|
||||||
if ( !fileItem.isFormField() )
|
if ( !fileItem.isFormField() )
|
||||||
{
|
{
|
||||||
//保存上传的文件,返回文件完整路径。
|
//保存上传的文件,返回文件完整路径。
|
||||||
String upLoadedFileName = saveUploadedFile( fileItem );
|
String upLoadedFileName = saveUploadedFile( fileItem );
|
||||||
|
|
||||||
importMessage = DataImport.importTelsalePolicyDataFromXlsx( upLoadedFileName,
|
//测试
|
||||||
telsalePolicyOperatorListTableName,
|
policyRecordList = DataImport.readTelsalePolicyDataFromXlsx( upLoadedFileName, 0 );
|
||||||
informixURL );
|
|
||||||
|
// importMessage = DataImport.importTelsalePolicyDataFromXlsx( upLoadedFileName,
|
||||||
|
// telsalePolicyOperatorListTableName,
|
||||||
|
// informixURL );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch( FileUploadException error )
|
catch ( FileUploadException error )
|
||||||
{
|
{
|
||||||
//文件上传有异常,包装一下重新抛出
|
//文件上传有异常,包装一下重新抛出
|
||||||
throw new ServletException( error.getMessage() );
|
throw new ServletException( error.getMessage() );
|
||||||
}
|
}
|
||||||
catch( XlsFileFormatException error )
|
catch ( XlsFileFormatException error )
|
||||||
{
|
{
|
||||||
//文件格式异常
|
//文件格式异常
|
||||||
importMessage = error.getMessage();
|
importMessage = error.getMessage();
|
||||||
}
|
}
|
||||||
catch( IOException error )
|
catch ( IOException error )
|
||||||
{
|
{
|
||||||
//包装一下重新抛出
|
//包装一下重新抛出
|
||||||
throw new ServletException( error.getMessage() );
|
throw new ServletException( error.getMessage() );
|
||||||
}
|
}
|
||||||
catch( Exception error )
|
catch ( Exception error )
|
||||||
{
|
{
|
||||||
throw new ServletException( error.getMessage() );
|
throw new ServletException( error.getMessage() );
|
||||||
}
|
}
|
||||||
@ -104,12 +116,14 @@ public class uploadDataProcessor extends HttpServlet
|
|||||||
* @return
|
* @return
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
private String saveUploadedFile( FileItem item ) throws Exception
|
private String saveUploadedFile( FileItem item )
|
||||||
|
throws
|
||||||
|
Exception
|
||||||
{
|
{
|
||||||
String fileName = item.getName();
|
String fileName = item.getName();
|
||||||
|
|
||||||
int fileNameIndex = 0;
|
int fileNameIndex = 0;
|
||||||
long fileSize = item.getSize();
|
long fileSize = item.getSize();
|
||||||
|
|
||||||
//文件路径中可能有使用\和/作为目录分隔符,要分别判断
|
//文件路径中可能有使用\和/作为目录分隔符,要分别判断
|
||||||
fileNameIndex = fileName.lastIndexOf( "\\" );
|
fileNameIndex = fileName.lastIndexOf( "\\" );
|
||||||
|
@ -4,14 +4,51 @@ CREATE OR REPLACE PACKAGE telsale_policy_check_pkg IS
|
|||||||
-- Created : 2021/6/21 10:18:01
|
-- Created : 2021/6/21 10:18:01
|
||||||
-- Purpose : µçÏú±£µ¥Êý¾ÝÑéÖ¤
|
-- 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 policy_check(a_policy_no VARCHAR2) RETURN BOOLEAN;
|
||||||
|
|
||||||
FUNCTION staff_check(a_stuff_code 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;
|
END telsale_policy_check_pkg;
|
||||||
/
|
/
|
||||||
CREATE OR REPLACE PACKAGE BODY telsale_policy_check_pkg IS
|
CREATE OR REPLACE PACKAGE BODY telsale_policy_check_pkg IS
|
||||||
|
|
||||||
|
/*********************************************************************************/
|
||||||
FUNCTION staff_check(a_stuff_code VARCHAR2) RETURN BOOLEAN IS
|
FUNCTION staff_check(a_stuff_code VARCHAR2) RETURN BOOLEAN IS
|
||||||
l_count INTEGER;
|
l_count INTEGER;
|
||||||
BEGIN
|
BEGIN
|
||||||
@ -28,6 +65,7 @@ CREATE OR REPLACE PACKAGE BODY telsale_policy_check_pkg IS
|
|||||||
RETURN TRUE;
|
RETURN TRUE;
|
||||||
END;
|
END;
|
||||||
|
|
||||||
|
/*********************************************************************************/
|
||||||
FUNCTION policy_check(a_policy_no VARCHAR2) RETURN BOOLEAN IS
|
FUNCTION policy_check(a_policy_no VARCHAR2) RETURN BOOLEAN IS
|
||||||
l_count INTEGER;
|
l_count INTEGER;
|
||||||
BEGIN
|
BEGIN
|
||||||
@ -43,6 +81,33 @@ CREATE OR REPLACE PACKAGE BODY telsale_policy_check_pkg IS
|
|||||||
|
|
||||||
RETURN TRUE;
|
RETURN TRUE;
|
||||||
END;
|
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
|
BEGIN
|
||||||
NULL;
|
NULL;
|
||||||
END telsale_policy_check_pkg;
|
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]
|
[Desktop]
|
||||||
SavePath=D:\develop\projects_win\2018\telsale_management_2017\代码\oracle\项目\
|
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]
|
[Files]
|
||||||
|
|
||||||
[MRU]
|
[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
|
||||||
|
1,D:\develop\projects_win\2018\telsale_management_2017\덜쯤\oracle\淃커\쉔깊\든饋괏데斤口쩌흙휑羚깊.sql
|
||||||
|
|
||||||
[Layout]
|
[Layout]
|
||||||
Group=
|
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