Compare commits

...

5 Commits

Author SHA1 Message Date
Kane Wang 5765a4b411 修改导入转介绍推荐信息表的导入函数,以适应用户。 2021-07-05 09:33:43 +08:00
Kane Wang 6406fe1784 ... 2021-06-15 17:41:20 +08:00
Kane Wang dc162b3180 做了一点点重构 2021-06-15 11:42:42 +08:00
Kane Wang 173aa6655f 提交信息! 2021-03-18 16:19:57 +08:00
Kane Wang 92681a8cfe 提交信息! 2021-03-18 11:44:01 +08:00
10 changed files with 376 additions and 24 deletions

View File

@ -1,4 +1,4 @@
#include <libxl.h>
#include <libxl.h>
#include <stdexcept>
#include "LoadFromExcel.h"
#include "../../excel/excel.h"
@ -76,10 +76,14 @@ const wchar_t * pwszRepairRecommandationCaption[] = {
L"报案号",
L"推荐车商代码",
L"推荐车商名称",
L"机构",
L"出险日期",
L"车牌号",
L"品牌名称",
L"短信类型",
L"接收人"
L"手机号"
L"短信内容"
L"发送时间",
L"数据来源",
};
@ -784,18 +788,18 @@ void LoadRepairRecommandationFromXlsx( const std::wstring &
//起始列索引
int colunmIndex = pSheet->firstCol();
wstring branchName = ReadCellStringFromXlsx( pBook, sheetIndex, rowIndex, colunmIndex++, true );
wstring orderNo = ReadCellStringFromXlsx( pBook, sheetIndex, rowIndex, colunmIndex++, true );
wstring orderType = ReadCellStringFromXlsx( pBook, sheetIndex, rowIndex, colunmIndex++, true );
wstring notifyNo = ReadCellStringFromXlsx( pBook, sheetIndex, rowIndex, colunmIndex++, true );
wstring RecommandCarDealerCode = ReadCellStringFromXlsx( pBook, sheetIndex, rowIndex, colunmIndex++, true );
wstring RecommandCarDealerName = ReadCellStringFromXlsx( pBook, sheetIndex, rowIndex, colunmIndex++, true );
wstring damageDate = ReadCellStringFromXlsx( pBook, sheetIndex, rowIndex, colunmIndex++, true );
wstring plateNumber = ReadCellStringFromXlsx( pBook, sheetIndex, rowIndex, colunmIndex++, true );
wstring brandName = ReadCellStringFromXlsx( pBook, sheetIndex, rowIndex, colunmIndex++, true );
wstring messageType = ReadCellStringFromXlsx( pBook, sheetIndex, rowIndex, colunmIndex++, true );
wstring messageSendingDate = ReadCellStringFromXlsx( pBook, sheetIndex, rowIndex, colunmIndex++, true );
wstring dataSource = ReadCellStringFromXlsx( pBook, sheetIndex, rowIndex, colunmIndex++, true );
wstring branchName = ReadCellStringFromXlsx( pBook, sheetIndex, rowIndex, colunmIndex, true );
wstring orderNo = ReadCellStringFromXlsx( pBook, sheetIndex, rowIndex, colunmIndex+1, true );
wstring orderType = ReadCellStringFromXlsx( pBook, sheetIndex, rowIndex, colunmIndex+2, true );
wstring notifyNo = ReadCellStringFromXlsx( pBook, sheetIndex, rowIndex, colunmIndex+3, true );
wstring RecommandCarDealerCode = ReadCellStringFromXlsx( pBook, sheetIndex, rowIndex, colunmIndex+4, true );
wstring RecommandCarDealerName = ReadCellStringFromXlsx( pBook, sheetIndex, rowIndex, colunmIndex+5, true );
wstring damageDate = ReadCellStringFromXlsx( pBook, sheetIndex, rowIndex, colunmIndex+7, true );
wstring plateNumber = ReadCellStringFromXlsx( pBook, sheetIndex, rowIndex, colunmIndex+8, true );
wstring brandName = ReadCellStringFromXlsx( pBook, sheetIndex, rowIndex, colunmIndex+9, true );
wstring messageType = ReadCellStringFromXlsx( pBook, sheetIndex, rowIndex, colunmIndex+10, true );
wstring messageSendingDate = ReadCellStringFromXlsx( pBook, sheetIndex, rowIndex, colunmIndex+14, true );
wstring dataSource = ReadCellStringFromXlsx( pBook, sheetIndex, rowIndex, colunmIndex+15, true );
//空行跳过
if ( notifyNo.empty() == true )
@ -1072,7 +1076,7 @@ void LoadNewRepairMonitorReportFromXlsx( const std::wstring &
* \param pszCaptionFormat
* \return
************************************************/
bool checkExcelFileFormat( Book * pBook, int sheetIndex, int captionRowIndex, const wchar_t * pszCaptionFormat[], int captionCount )
/*bool checkExcelFileFormat( Book * pBook, int sheetIndex, int captionRowIndex, const wchar_t * pszCaptionFormat[], int captionCount )
{
if ( pBook == nullptr )
{
@ -1103,4 +1107,4 @@ bool checkExcelFileFormat( Book * pBook, int sheetIndex, int captionRowIndex, co
}
return isEqual;
}
}*/

View File

@ -1111,3 +1111,113 @@ void ImportNewRepairMonitorToOracle( const std::string &
OCI_ConnectionFree( pConnection );
OCI_Cleanup();
}
/************************************************
* \brief -
* \param userName
* \param password
* \param tnsName
* \param recordVector
************************************************/
void ImportPriceCheckedListToOracle( const std::string & userName,
const std::string & password,
const std::string & tnsName,
const std::vector<NewRepairMonitorReportRecord> & recordVector )
{
OCI_Connection * pConn = nullptr;
OCI_Statement * pStatement = nullptr;
int returnCode = 0;
QString sql = QString::fromUtf8( "begin \n"
" car_dealer.data_import_util_pkg.import_pricecheck_list( \n"
" :a_caseno, \n"
" :a_report_date, \n"
" :a_damage_date, \n"
" :a_damage_address, \n"
" :a_plateno, \n"
" :a_brandname, \n"
" :a_carseries, \n"
" :a_policyno, \n"
" :a_insuredcar, \n"
" :a_checked_premium, \n"
" :a_step, \n"
" :a_branch_name, \n"
" :a_cardealer_code, \n"
" :a_cardealer_name, \n"
" :a_check_date \n"
" ); \n"
"end;" );
returnCode = OCI_Initialize( l_error_handler, nullptr, OCI_ENV_DEFAULT );
if ( static_cast<bool>(returnCode) == false )
{
string errorMessage( "ocilib初始化错误:" );
errorMessage.append( get_last_error_message() );
throw runtime_error( errorMessage );
}
try
{
pConn = OCI_ConnectionCreate( tnsName.c_str(),
userName.c_str(),
password.c_str(),
OCI_SESSION_DEFAULT );
pStatement = OCI_StatementCreate( pConn );
OCI_AllowRebinding( pStatement, true );
OCI_Prepare( pStatement, sql.toLocal8Bit().data() );
for ( auto iterRecord = recordVector.begin();
iterRecord != recordVector.end();
++iterRecord )
{
string a_caseno = QString::fromStdWString( iterRecord->_ ).toLocal8Bit();
string a_report_date = QString::fromStdWString( iterRecord->_ ).toLocal8Bit();
string a_damage_date = QString::fromStdWString( iterRecord->_ ).toLocal8Bit();
string a_damage_address = QString::fromStdWString( iterRecord->_ ).toLocal8Bit();
string a_plateno = QString::fromStdWString( iterRecord->_ ).toLocal8Bit();
string a_brandname = QString::fromStdWString( iterRecord->_ ).toLocal8Bit();
string a_carseries = QString::fromStdWString( iterRecord->_ ).toLocal8Bit();
string a_policyno = QString::fromStdWString( iterRecord->_ ).toLocal8Bit();
string a_insuredcar = QString::fromStdWString( iterRecord->_三者车_ ).toLocal8Bit();
string a_checked_premium = QString::fromStdWString( iterRecord->_ ).toLocal8Bit();
string a_step = QString::fromStdWString( iterRecord->_核价通过环节_ ).toLocal8Bit();
string a_branch_name = QString::fromStdWString( iterRecord->_ ).toLocal8Bit();
string a_cardealer_code = QString::fromStdWString( iterRecord->_ ).toLocal8Bit();
string a_cardealer_name = QString::fromStdWString( iterRecord->_ ).toLocal8Bit();
string a_check_date = QString::fromStdWString( iterRecord->_ ).toLocal8Bit();
//OCI_BindString(pStatement, (const otext*)(":"), (otext*)(.c_str()), .size());
OCI_BindString( pStatement, (const otext*)(":a_caseno"), (otext*)(a_caseno.c_str()), a_caseno.size() );
OCI_BindString( pStatement, (const otext*)(":a_report_date"), (otext*)(a_report_date.c_str()), a_report_date.size() );
OCI_BindString( pStatement, (const otext*)(":a_damage_date"), (otext*)(a_damage_date.c_str()), a_damage_date.size() );
OCI_BindString( pStatement, (const otext*)(":a_damage_address"), (otext*)(a_damage_address.c_str()), a_damage_address.size() );
OCI_BindString( pStatement, (const otext*)(":a_plateno"), (otext*)(a_plateno.c_str()), a_plateno.size() );
OCI_BindString( pStatement, (const otext*)(":a_brandname"), (otext*)(a_brandname.c_str()), a_brandname.size() );
OCI_BindString( pStatement, (const otext*)(":a_carseries"), (otext*)(a_carseries.c_str()), a_carseries.size() );
OCI_BindString( pStatement, (const otext*)(":a_policyno"), (otext*)(a_policyno.c_str()), a_policyno.size() );
OCI_BindString( pStatement, (const otext*)(":a_insuredcar"), (otext*)(a_insuredcar.c_str()), a_insuredcar.size() );
OCI_BindString( pStatement, (const otext*)(":a_checked_premium"), (otext*)(a_checked_premium.c_str()), a_checked_premium.size() );
OCI_BindString( pStatement, (const otext*)(":a_step"), (otext*)(a_step.c_str()), a_step.size() );
OCI_BindString( pStatement, (const otext*)(":a_branch_name"), (otext*)(a_branch_name.c_str()), a_branch_name.size() );
OCI_BindString( pStatement, (const otext*)(":a_cardealer_code"), (otext*)(a_cardealer_code.c_str()), a_cardealer_code.size() );
OCI_BindString( pStatement, (const otext*)(":a_cardealer_name"), (otext*)(a_cardealer_name.c_str()), a_cardealer_name.size() );
OCI_BindString( pStatement, (const otext*)(":a_check_date"), (otext*)(a_check_date.c_str()), a_check_date.size() );
OCI_Execute( pStatement );
}
}
catch ( runtime_error & error )
{
OCI_ConnectionFree( pConn );
OCI_Cleanup();
throw error;
}
OCI_Commit( pConn );
OCI_ConnectionFree( pConn );
OCI_Cleanup();
}

View File

@ -1,4 +1,4 @@
#pragma once
#pragma once
#include <string>
#include <vector>
@ -75,3 +75,16 @@ void ImportNewRepairMonitorToOracle( const std::string &
const std::string & password,
const std::string & tnsName,
const std::vector<NewRepairMonitorReportRecord> & recordVector );
/************************************************
* \brief -
* \param userName
* \param password
* \param tnsName
* \param recordVector
************************************************/
void ImportPriceCheckedListToOracle( const std::string & userName,
const std::string & password,
const std::string & tnsName,
const std::vector<NewRepairMonitorReportRecord> & recordVector );

View File

@ -163,3 +163,41 @@ libxl::Sheet * getXlsxSheetByName( libxl::IBookT<wchar_t> * pBook, const std::ws
return pSheet;
}
bool checkExcelFileFormat(Book* pBook,
int sheetIndex,
int captionRowIndex,
const wchar_t* pszCaptionFormat[],
int captionCount)
{
if (pBook == nullptr)
{
throw logic_error("Excel文件指针为空");
}
if (sheetIndex < 0 || captionRowIndex < 0)
{
throw logic_error("标题行参数错误!");
}
Sheet* pSheet = pBook->getSheet(sheetIndex);
int captionIndex = 0;
bool isEqual = true;
while (captionIndex < captionCount)
{
const wchar_t* pwszCaption = pSheet->readStr(captionRowIndex, captionIndex);
if (wcscmp(pwszCaption, pszCaptionFormat[captionIndex]) != 0)
{
isEqual = false;
break;
}
captionIndex++;
}
return isEqual;
}

View File

@ -1,6 +1,4 @@
#pragma once
#ifndef EXCEL_H_
#define EXCEL_H_
#include <libxl.h>
@ -31,7 +29,20 @@ std::wstring ReadCellStringFromXlsx( libxl::IBookT<wchar_t> * pBook,
* \param sheetName
* \return
************************************************/
libxl::Sheet * getXlsxSheetByName( libxl::IBookT<wchar_t> * pBook, const std::wstring & sheetName );
libxl::Sheet * getXlsxSheetByName( libxl::IBookT<wchar_t> * pBook,
const std::wstring & sheetName );
#endif
/************************************************
* \brief excel表格的内容pszCaptionFormat参数提供的表头数组来核对
* \param pBook excel文件指针
* \param sheetIndex sheet索引
* \param captionRowIndex
* \param pszCaptionFormat
* \param captionCount
* \return
************************************************/
bool checkExcelFileFormat( libxl::Book * pBook,
int sheetIndex,
int captionRowIndex,
const wchar_t * pszCaptionFormat[],
int captionCount );

View File

@ -71,7 +71,8 @@ void QNewRepairMonitorWidget::onImport()
string password = "cpic123456";
string tnsName = "xmcx1";
ImportNewRepairMonitorToOracle( userName, password, tnsName, recordVector );
//ImportNewRepairMonitorToOracle( userName, password, tnsName, recordVector );
ImportPriceCheckedListToOracle(userName, password, tnsName, recordVector);
//showNewRepairMonitorRecords();
}

View File

@ -0,0 +1,43 @@
#include <stdexcept>
#include <cwchar>
#include "excel_util.h"
using namespace libxl;
using namespace std;
bool checkExcelFileFormat( Book * pBook,
int sheetIndex,
int captionRowIndex,
const wchar_t * pszCaptionFormat[],
int captionCount )
{
if ( pBook == nullptr )
{
throw logic_error( "Excel文件指针为空" );
}
if ( sheetIndex < 0 || captionRowIndex < 0 )
{
throw logic_error( "标题行参数错误!" );
}
Sheet * pSheet = pBook->getSheet( sheetIndex );
int captionIndex = 0;
bool isEqual = true;
while ( captionIndex < captionCount )
{
const wchar_t * pwszCaption = pSheet->readStr( captionRowIndex, captionIndex );
if ( wcscmp( pwszCaption, pszCaptionFormat[captionIndex] ) != 0 )
{
isEqual = false;
break;
}
captionIndex++;
}
return isEqual;
}

View File

@ -0,0 +1,26 @@
#pragma once
#include <libxl.h>
/************************************************
* \brief excel表格的内容pszCaptionFormat参数提供的表头数组来核对
* \param pBook excel文件指针
* \param sheetIndex sheet索引
* \param captionRowIndex
* \param pszCaptionFormat
* \param captionCount
* \return
************************************************/
bool checkExcelFileFormat( libxl::Book * pBook,
int sheetIndex,
int captionRowIndex,
const wchar_t * pszCaptionFormat[],
int captionCount );
/************************************************
* \brief sheet
* \param sheetName
* \return
************************************************/
libxl::Sheet* getXlsxSheetByName(libxl::IBookT<wchar_t>* pBook, const std::wstring& sheetName);

View File

@ -85,6 +85,26 @@ CREATE OR REPLACE PACKAGE data_import_util_pkg IS
a_data_source VARCHAR2
);
--导入核价清单(新送返修监控报表)
PROCEDURE import_pricecheck_list
(
a_报案号 VARCHAR2,
a_报案日期 VARCHAR2,
a_出险日期 VARCHAR2,
a_出险地点 VARCHAR2,
a_车牌 VARCHAR2,
a_品牌名称 VARCHAR2,
a_车系名称 VARCHAR2,
a_保单号 VARCHAR2,
a_标的车三者车 VARCHAR2,
a_核价金额 VARCHAR2,
a_车辆状态名称核价通过环节 VARCHAR2,
a_核价车商分公司名称 VARCHAR2,
a_核价车商代码 VARCHAR2,
a_核价车商名称 VARCHAR2,
a_核价通过时间 VARCHAR2
);
PROCEDURE 导入新送返修监控报表
(
a_分公司名称 VARCHAR2,
@ -408,7 +428,8 @@ CREATE OR REPLACE PACKAGE BODY data_import_util_pkg IS
--先删除旧数据
BEGIN
DELETE car_dealer.repair_order_info a WHERE a_order_no = a.order_no;
DELETE car_dealer.repair_order_info a
WHERE a_order_no = a.order_no;
EXCEPTION
WHEN OTHERS THEN
NULL;
@ -539,7 +560,8 @@ CREATE OR REPLACE PACKAGE BODY data_import_util_pkg IS
--删除旧数据
BEGIN
DELETE FROM car_dealer.送返修推荐表 a WHERE a.报案号 = a_notify_no;
DELETE FROM car_dealer.送返修推荐表 a
WHERE a.报案号 = a_notify_no;
EXCEPTION
WHEN OTHERS THEN
NULL;
@ -584,6 +606,90 @@ CREATE OR REPLACE PACKAGE BODY data_import_util_pkg IS
END;
PROCEDURE import_pricecheck_list
(
a_报案号 VARCHAR2,
a_报案日期 VARCHAR2,
a_出险日期 VARCHAR2,
a_出险地点 VARCHAR2,
a_车牌 VARCHAR2,
a_品牌名称 VARCHAR2,
a_车系名称 VARCHAR2,
a_保单号 VARCHAR2,
a_标的车三者车 VARCHAR2,
a_核价金额 VARCHAR2,
a_车辆状态名称核价通过环节 VARCHAR2,
a_核价车商分公司名称 VARCHAR2,
a_核价车商代码 VARCHAR2,
a_核价车商名称 VARCHAR2,
a_核价通过时间 VARCHAR2
) IS
l_报案日期 DATE;
l_出险日期 DATE;
l_核价通过时间 DATE;
BEGIN
NULL;
IF a_报案号 IS NULL OR
a_车牌 IS NULL
THEN
raise_application_error(no_notify_no_excpt,
no_notify_no_text);
END IF;
BEGIN
DELETE 核价清单 hj
--DELETE check_price_list hj
WHERE hj.报案号 = a_报案号
AND hj.车牌 = a_车牌;
EXCEPTION
WHEN OTHERS THEN
NULL;
END;
l_报案日期 := 日期字符串转换(a_报案日期,
'yyyy-mm-dd hh24:mi:ss');
l_出险日期 := 日期字符串转换(a_出险日期,
'yyyy-mm-dd hh24:mi:ss');
l_核价通过时间 := 日期字符串转换(a_核价通过时间,
'yyyy-mm-dd hh24:mi:ss');
INSERT INTO 核价清单
--INSERT INTO check_price_list
(报案号,
报案日期,
出险日期,
出险地点,
车牌,
品牌名称,
车系名称,
保单号,
标的车三者车,
核价金额,
车辆状态名称核价通过环节,
核价车商分公司名称,
核价车商代码,
核价车商名称,
核价通过时间)
VALUES
(a_报案号,
l_报案日期,
l_出险日期,
a_出险地点,
a_车牌,
a_品牌名称,
a_车系名称,
a_保单号,
a_标的车三者车,
a_核价金额,
a_车辆状态名称核价通过环节,
a_核价车商分公司名称,
a_核价车商代码,
a_核价车商名称,
l_核价通过时间);
END;
PROCEDURE 导入新送返修监控报表
(
a_分公司名称 VARCHAR2,