...
This commit is contained in:
parent
a1e6e71ebc
commit
3b45aea501
3
代码/jsp/telsale_import/.idea/libraries/lib.xml
generated
3
代码/jsp/telsale_import/.idea/libraries/lib.xml
generated
@ -9,13 +9,12 @@
|
||||
<root url="jar://$PROJECT_DIR$/web/WEB-INF/lib/commons-logging-1.2.jar!/" />
|
||||
<root url="jar://$PROJECT_DIR$/web/WEB-INF/lib/junit-4.12.jar!/" />
|
||||
<root url="jar://$PROJECT_DIR$/web/WEB-INF/lib/log4j-1.2.17.jar!/" />
|
||||
<root url="jar://$PROJECT_DIR$/web/WEB-INF/lib/ojdbc5.jar!/" />
|
||||
<root url="jar://$PROJECT_DIR$/web/WEB-INF/lib/ojdbc6.jar!/" />
|
||||
<root url="jar://$PROJECT_DIR$/web/WEB-INF/lib/poi-3.15.jar!/" />
|
||||
<root url="jar://$PROJECT_DIR$/web/WEB-INF/lib/poi-excelant-3.15.jar!/" />
|
||||
<root url="jar://$PROJECT_DIR$/web/WEB-INF/lib/poi-ooxml-3.15.jar!/" />
|
||||
<root url="jar://$PROJECT_DIR$/web/WEB-INF/lib/poi-ooxml-schemas-3.15.jar!/" />
|
||||
<root url="jar://$PROJECT_DIR$/web/WEB-INF/lib/poi-scratchpad-3.15.jar!/" />
|
||||
<root url="jar://$PROJECT_DIR$/web/WEB-INF/lib/ojdbc8.jar!/" />
|
||||
</CLASSES>
|
||||
<JAVADOC>
|
||||
<root url="jar://$PROJECT_DIR$/web/WEB-INF/lib/commons-compress-1.12-javadoc.jar!/" />
|
||||
|
@ -7,6 +7,7 @@ package com.cpic.telsale.DataImport;
|
||||
import java.io.*;
|
||||
import java.sql.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
|
||||
import org.apache.poi.hssf.usermodel.*;
|
||||
import com.cpic.telsale.TelsalePolicyRecord;
|
||||
@ -412,10 +413,123 @@ public class DataImport
|
||||
String userName,
|
||||
String password,
|
||||
ArrayList<TelsalePolicyRecord> policyList )
|
||||
throws NullPointerException,
|
||||
TesalePolicyDataSaveToOracleException,
|
||||
SQLException
|
||||
|
||||
{
|
||||
Connection conn = null;
|
||||
CallableStatement statement = null;
|
||||
CallableStatement callStmt = null;
|
||||
|
||||
String callProcedureSql = "{call telsale_policy_check_pkg.save_policy(?,?,?,?,?,?,?,?,?,?,?,?,?)}";
|
||||
String errorMessage = "写入oracle数据库错误,请按照提示修正后重新上传!<br>\n";
|
||||
|
||||
//用来记录异常记录的数量
|
||||
int errorCount = 0;
|
||||
|
||||
if ( policyList == null )
|
||||
{
|
||||
throw new NullPointerException( "policyList参数为Null" );
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
Class.forName( "oracle.jdbc.driver.OracleDriver" );
|
||||
conn = DriverManager.getConnection( dbURL, userName, password );
|
||||
callStmt = conn.prepareCall( callProcedureSql );
|
||||
|
||||
conn.setAutoCommit( false );
|
||||
|
||||
for ( TelsalePolicyRecord recordIterator : policyList )
|
||||
{
|
||||
callStmt.setString( 1, recordIterator.getPolicyNo() );
|
||||
callStmt.setString( 2, recordIterator.getOperatorCode() );
|
||||
callStmt.registerOutParameter( 3, Types.VARCHAR );
|
||||
callStmt.registerOutParameter( 4, Types.VARCHAR );
|
||||
callStmt.registerOutParameter( 5, Types.VARCHAR );
|
||||
callStmt.registerOutParameter( 6, Types.VARCHAR );
|
||||
callStmt.registerOutParameter( 7, Types.VARCHAR );
|
||||
callStmt.setString( 8, recordIterator.getEntryStaffCode() );
|
||||
callStmt.registerOutParameter( 9, Types.VARCHAR );
|
||||
callStmt.registerOutParameter( 10, Types.VARCHAR );
|
||||
callStmt.registerOutParameter( 11, Types.VARCHAR );
|
||||
callStmt.registerOutParameter( 12, Types.VARCHAR );
|
||||
callStmt.registerOutParameter( 13, Types.VARCHAR );
|
||||
|
||||
try
|
||||
{
|
||||
callStmt.execute();
|
||||
|
||||
recordIterator.setOperatorName( callStmt.getString( 3 ) );
|
||||
recordIterator.setOperatorSectionOfficeCode( callStmt.getString( 4 ) );
|
||||
recordIterator.setOperatorSectionOfficeName( callStmt.getString( 5 ) );
|
||||
recordIterator.setOperatorDepartmentCode( callStmt.getString( 6 ) );
|
||||
recordIterator.setOperatorDepartmentName( callStmt.getString( 7 ) );
|
||||
recordIterator.setEntryStaffName( callStmt.getString( 9 ) );
|
||||
recordIterator.setEntryStaffSectionOfficeCode( callStmt.getString( 10 ) );
|
||||
recordIterator.setEntryStaffSectionOfficeName( callStmt.getString( 11 ) );
|
||||
recordIterator.setEntryStaffDepartmentCode( callStmt.getString( 12 ) );
|
||||
recordIterator.setEntryStaffDepartmentName( callStmt.getString( 13 ) );
|
||||
}
|
||||
catch ( SQLException error )
|
||||
{
|
||||
//写入时发生错误,记录下错误!
|
||||
switch ( error.getErrorCode() )
|
||||
{
|
||||
case -20001:
|
||||
{
|
||||
errorMessage += "保单号" +
|
||||
recordIterator.getPolicyNo() +
|
||||
",已存在,如需修改数据请联系信息技术部。<br> \n";
|
||||
}
|
||||
default:
|
||||
{
|
||||
errorMessage += "保单号" +
|
||||
recordIterator.getPolicyNo() +
|
||||
"保存失败,错误提示:" +
|
||||
error.getMessage() + "<br>\n";
|
||||
}
|
||||
}
|
||||
|
||||
errorCount++;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch ( SQLException error )
|
||||
{
|
||||
throw error;
|
||||
}
|
||||
catch ( ClassNotFoundException error )
|
||||
{
|
||||
error.printStackTrace();
|
||||
}
|
||||
finally
|
||||
{
|
||||
//关闭连接
|
||||
try
|
||||
{
|
||||
if ( errorCount == 0 )
|
||||
{
|
||||
conn.commit();
|
||||
}
|
||||
else
|
||||
{
|
||||
conn.rollback();
|
||||
}
|
||||
|
||||
conn.close();
|
||||
}
|
||||
catch ( SQLException error )
|
||||
{
|
||||
//不处理了
|
||||
}
|
||||
}
|
||||
|
||||
//根据错误数量,判断是否抛出异常
|
||||
if ( errorCount > 0 )
|
||||
{
|
||||
throw new TesalePolicyDataSaveToOracleException( errorMessage );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,15 @@
|
||||
package com.cpic.telsale.DataImport;
|
||||
|
||||
/**
|
||||
* @program: 2018版电销管理系统
|
||||
* @description: 保存电销数据至oracle数据库错误。
|
||||
* @author: Kane Wang
|
||||
* @create: 2021-06-23 11:29
|
||||
**/
|
||||
public class TesalePolicyDataSaveToOracleException extends Exception
|
||||
{
|
||||
public TesalePolicyDataSaveToOracleException( String message )
|
||||
{
|
||||
super( message );
|
||||
}
|
||||
}
|
@ -9,8 +9,8 @@ public class TelsalePolicyRecord
|
||||
{
|
||||
/**
|
||||
* @Description: 构造函数
|
||||
* @Param: policyNo
|
||||
* @Param: operatorCode
|
||||
* @Param: policyNo 保单号
|
||||
* @Param: operatorCode 经办人工号
|
||||
* @return:
|
||||
* @Author: 王炜
|
||||
* @Date: 2021/6/21 */
|
||||
@ -70,24 +70,24 @@ public class TelsalePolicyRecord
|
||||
this.operatorSectionOfficeName = operatorSectionOfficeName;
|
||||
}
|
||||
|
||||
public String getOperatorSectionDepartmentCode()
|
||||
public String getOperatorDepartmentCode()
|
||||
{
|
||||
return operatorSectionDepartmentCode;
|
||||
return operatorDepartmentCode;
|
||||
}
|
||||
|
||||
public void setOperatorSectionDepartmentCode( String operatorSectionDepartmentCode )
|
||||
public void setOperatorDepartmentCode( String operatorDepartmentCode )
|
||||
{
|
||||
this.operatorSectionDepartmentCode = operatorSectionDepartmentCode;
|
||||
this.operatorDepartmentCode = operatorDepartmentCode;
|
||||
}
|
||||
|
||||
public String getOperatorSectionDepartmentName()
|
||||
public String getOperatorDepartmentName()
|
||||
{
|
||||
return operatorSectionDepartmentName;
|
||||
return operatorDepartmentName;
|
||||
}
|
||||
|
||||
public void setOperatorSectionDepartmentName( String operatorSectionDepartmentName )
|
||||
public void setOperatorDepartmentName( String operatorDepartmentName )
|
||||
{
|
||||
this.operatorSectionDepartmentName = operatorSectionDepartmentName;
|
||||
this.operatorDepartmentName = operatorDepartmentName;
|
||||
}
|
||||
|
||||
public String getEntryStaffCode()
|
||||
@ -130,24 +130,24 @@ public class TelsalePolicyRecord
|
||||
this.entryStaffSectionOfficeName = entryStaffSectionOfficeName;
|
||||
}
|
||||
|
||||
public String getEntryStaffSectionDepartmentCode()
|
||||
public String getEntryStaffDepartmentCode()
|
||||
{
|
||||
return entryStaffSectionDepartmentCode;
|
||||
return entryStaffDepartmentCode;
|
||||
}
|
||||
|
||||
public void setEntryStaffSectionDepartmentCode( String entryStaffSectionDepartmentCode )
|
||||
public void setEntryStaffDepartmentCode( String entryStaffDepartmentCode )
|
||||
{
|
||||
this.entryStaffSectionDepartmentCode = entryStaffSectionDepartmentCode;
|
||||
this.entryStaffDepartmentCode = entryStaffDepartmentCode;
|
||||
}
|
||||
|
||||
public String getEntryStaffSectionDepartmentName()
|
||||
public String getEntryStaffDepartmentName()
|
||||
{
|
||||
return entryStaffSectionDepartmentName;
|
||||
return entryStaffDepartmentName;
|
||||
}
|
||||
|
||||
public void setEntryStaffSectionDepartmentName( String entryStaffSectionDepartmentName )
|
||||
public void setEntryStaffDepartmentName( String entryStaffDepartmentName )
|
||||
{
|
||||
this.entryStaffSectionDepartmentName = entryStaffSectionDepartmentName;
|
||||
this.entryStaffDepartmentName = entryStaffDepartmentName;
|
||||
}
|
||||
|
||||
private String policyNo;
|
||||
@ -156,13 +156,13 @@ public class TelsalePolicyRecord
|
||||
private String operatorName;
|
||||
private String operatorSectionOfficeCode;
|
||||
private String operatorSectionOfficeName;
|
||||
private String operatorSectionDepartmentCode;
|
||||
private String operatorSectionDepartmentName;
|
||||
private String operatorDepartmentCode;
|
||||
private String operatorDepartmentName;
|
||||
//录入人
|
||||
private String entryStaffCode;
|
||||
private String entryStaffName;
|
||||
private String entryStaffSectionOfficeCode;
|
||||
private String entryStaffSectionOfficeName;
|
||||
private String entryStaffSectionDepartmentCode;
|
||||
private String entryStaffSectionDepartmentName;
|
||||
private String entryStaffDepartmentCode;
|
||||
private String entryStaffDepartmentName;
|
||||
}
|
||||
|
@ -17,6 +17,8 @@ import java.util.*;
|
||||
|
||||
import com.cpic.telsale.DataImport.*;
|
||||
|
||||
import static com.cpic.telsale.DataImport.DataImport.saveTelsalePolicyDataToOracle;
|
||||
|
||||
public class uploadDataProcessor extends HttpServlet
|
||||
{
|
||||
private String tempPathRoot; //临时文件目录
|
||||
@ -75,10 +77,15 @@ public class uploadDataProcessor extends HttpServlet
|
||||
|
||||
//测试
|
||||
policyRecordList = DataImport.readTelsalePolicyDataFromXlsx( upLoadedFileName, 0 );
|
||||
saveTelsalePolicyDataToOracle( oracleURL,
|
||||
oracleUserName,
|
||||
oraclePassword,
|
||||
policyRecordList );
|
||||
|
||||
// importMessage = DataImport.importTelsalePolicyDataFromXlsx( upLoadedFileName,
|
||||
// telsalePolicyOperatorListTableName,
|
||||
// informixURL );
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -92,6 +99,11 @@ public class uploadDataProcessor extends HttpServlet
|
||||
//文件格式异常
|
||||
importMessage = error.getMessage();
|
||||
}
|
||||
catch ( TesalePolicyDataSaveToOracleException error )
|
||||
{
|
||||
//保存到oracle异常
|
||||
importMessage = error.getMessage();
|
||||
}
|
||||
catch ( IOException error )
|
||||
{
|
||||
//包装一下重新抛出
|
||||
|
Binary file not shown.
Binary file not shown.
BIN
代码/jsp/telsale_import/web/WEB-INF/lib/ojdbc8.jar
Normal file
BIN
代码/jsp/telsale_import/web/WEB-INF/lib/ojdbc8.jar
Normal file
Binary file not shown.
BIN
代码/jsp/telsale_import/web/WEB-INF/lib/ojdbc8_g.jar
Normal file
BIN
代码/jsp/telsale_import/web/WEB-INF/lib/ojdbc8_g.jar
Normal file
Binary file not shown.
BIN
代码/jsp/telsale_import/web/WEB-INF/lib/ojdbc8dms.jar
Normal file
BIN
代码/jsp/telsale_import/web/WEB-INF/lib/ojdbc8dms.jar
Normal file
Binary file not shown.
BIN
代码/jsp/telsale_import/web/WEB-INF/lib/ojdbc8dms_g.jar
Normal file
BIN
代码/jsp/telsale_import/web/WEB-INF/lib/ojdbc8dms_g.jar
Normal file
Binary file not shown.
@ -21,7 +21,7 @@
|
||||
</context-param>
|
||||
<context-param>
|
||||
<param-name>oracleURL</param-name>
|
||||
<param-value>jdbc:oracle:thin:@10.39.0.86:1521:xmcx1</param-value>
|
||||
<param-value>jdbc:oracle:thin:@10.39.0.85:1521:dev01</param-value>
|
||||
</context-param>
|
||||
<context-param>
|
||||
<param-name>oracleUserName</param-name>
|
||||
@ -29,7 +29,7 @@
|
||||
</context-param>
|
||||
<context-param>
|
||||
<param-name>oraclePassword</param-name>
|
||||
<param-value>cpic123456</param-value>
|
||||
<param-value>Cpic#1234</param-value>
|
||||
</context-param>
|
||||
<context-param>
|
||||
<param-name>informixURL</param-name>
|
||||
|
@ -148,6 +148,8 @@ CREATE OR REPLACE PACKAGE BODY telsale_policy_check_pkg IS
|
||||
END;
|
||||
|
||||
--验证录入人是否存在
|
||||
IF a_entry_staff_code IS NOT NULL
|
||||
THEN
|
||||
BEGIN
|
||||
SELECT ry.staff_name,
|
||||
ksh.section_office_code,
|
||||
@ -170,13 +172,14 @@ CREATE OR REPLACE PACKAGE BODY telsale_policy_check_pkg IS
|
||||
raise_application_error(OPERATOE_CODE_NOT_EXIST_EXCEPT_CODE,
|
||||
OPERATOE_CODE_NOT_EXIST_EXCEPT_TEXT);
|
||||
END;
|
||||
END IF;
|
||||
|
||||
--判断保单归属和经办人所在部门是否匹配,不匹配视为错误
|
||||
IF l_policy_sectionoffice_code != a_operator_sectionoffice_code OR
|
||||
l_policy_department_code != a_operator_department_code
|
||||
THEN
|
||||
raise_application_error(OPERATOE_CODE_NOT_MATCH_EXCEPT_CODE,
|
||||
OPERATOE_CODE_NOT_MATCH_EXCEPT_TEXT);
|
||||
raise_application_error(ENTRY_STAFF_CODE_NOT_EXIST_EXCEPT_CODE,
|
||||
ENTRY_STAFF_CODE_NOT_EXIST_EXCEPT_TEXT);
|
||||
END IF;
|
||||
|
||||
--没错误后,保存记录
|
||||
|
BIN
数据/测试数据/有空行,有保单号错误 - 副本.xls
Normal file
BIN
数据/测试数据/有空行,有保单号错误 - 副本.xls
Normal file
Binary file not shown.
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