提交信息!
This commit is contained in:
parent
6572379132
commit
1e628ccc30
|
@ -2,6 +2,7 @@
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
#include "LoadFromExcel.h"
|
#include "LoadFromExcel.h"
|
||||||
#include "../../excel/excel.h"
|
#include "../../excel/excel.h"
|
||||||
|
#include "../../Data/Datastructure/CarDealer/CarDealerMap.h"
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
using namespace libxl;
|
using namespace libxl;
|
||||||
|
@ -52,6 +53,9 @@ void LoadCarDealerSchemeFromXlsx( const wstring & filePath,
|
||||||
int firstColumnIndex = pSheet->firstCol();
|
int firstColumnIndex = pSheet->firstCol();
|
||||||
int rowIndex = firstRowIndex + startRowIndex;
|
int rowIndex = firstRowIndex + startRowIndex;
|
||||||
|
|
||||||
|
//车商名称表
|
||||||
|
auto * pCarDealerMap = getCarDealerMap();
|
||||||
|
|
||||||
while ( rowIndex <= lastRowIndex )
|
while ( rowIndex <= lastRowIndex )
|
||||||
{
|
{
|
||||||
int colunmIndex = firstRowIndex;
|
int colunmIndex = firstRowIndex;
|
||||||
|
@ -59,7 +63,7 @@ void LoadCarDealerSchemeFromXlsx( const wstring & filePath,
|
||||||
const wstring && theYear = ReadCellStringFromXlsx( pBook, sheetIndex, rowIndex, colunmIndex, true );
|
const wstring && theYear = ReadCellStringFromXlsx( pBook, sheetIndex, rowIndex, colunmIndex, true );
|
||||||
const wstring && theMonth = ReadCellStringFromXlsx( pBook, sheetIndex, rowIndex, colunmIndex + 1, true );
|
const wstring && theMonth = ReadCellStringFromXlsx( pBook, sheetIndex, rowIndex, colunmIndex + 1, true );
|
||||||
const wstring && carDealerCode = ReadCellStringFromXlsx( pBook, sheetIndex, rowIndex, colunmIndex + 2, true );
|
const wstring && carDealerCode = ReadCellStringFromXlsx( pBook, sheetIndex, rowIndex, colunmIndex + 2, true );
|
||||||
const wstring && carDealerName = ReadCellStringFromXlsx( pBook, sheetIndex, rowIndex, colunmIndex + 3, true );
|
//const wstring && carDealerName = ReadCellStringFromXlsx( pBook, sheetIndex, rowIndex, colunmIndex + 3, true );
|
||||||
const wstring && manHourPrice = ReadCellStringFromXlsx( pBook, sheetIndex, rowIndex, colunmIndex + 4, true );
|
const wstring && manHourPrice = ReadCellStringFromXlsx( pBook, sheetIndex, rowIndex, colunmIndex + 4, true );
|
||||||
const wstring && partPrice = ReadCellStringFromXlsx( pBook, sheetIndex, rowIndex, colunmIndex + 5, true );
|
const wstring && partPrice = ReadCellStringFromXlsx( pBook, sheetIndex, rowIndex, colunmIndex + 5, true );
|
||||||
const wstring && claimSupport = ReadCellStringFromXlsx( pBook, sheetIndex, rowIndex, colunmIndex + 6, true );
|
const wstring && claimSupport = ReadCellStringFromXlsx( pBook, sheetIndex, rowIndex, colunmIndex + 6, true );
|
||||||
|
@ -74,6 +78,19 @@ void LoadCarDealerSchemeFromXlsx( const wstring & filePath,
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//核对车商代码
|
||||||
|
auto iterCarDealer = pCarDealerMap->find(carDealerCode);
|
||||||
|
|
||||||
|
if ( iterCarDealer == pCarDealerMap->end() )
|
||||||
|
{
|
||||||
|
//没查到这个车商,清除掉已经读取的数据
|
||||||
|
schemeVector.clear();
|
||||||
|
QString rowIndexString = QString::number(rowIndex, 'g', -1);
|
||||||
|
QString errorMessage = QString("第") + rowIndexString + QString("行车商代码错误!");
|
||||||
|
|
||||||
|
throw runtime_error(errorMessage.toStdString());
|
||||||
|
}
|
||||||
|
|
||||||
CarDealerScheme carDealerScheme( theYear,
|
CarDealerScheme carDealerScheme( theYear,
|
||||||
theMonth,
|
theMonth,
|
||||||
carDealerCode,
|
carDealerCode,
|
||||||
|
@ -131,6 +148,8 @@ void LoadCarDealerAchievementFromXlsx( const std::wstring & fileP
|
||||||
int firstColumnIndex = pSheet->firstCol();
|
int firstColumnIndex = pSheet->firstCol();
|
||||||
int rowIndex = firstRowIndex + startRowIndex;
|
int rowIndex = firstRowIndex + startRowIndex;
|
||||||
|
|
||||||
|
unordered_map<wstring, CarDealer>* pCarDealerMap = getCarDealerMap();
|
||||||
|
|
||||||
while ( rowIndex <= lastRowIndex )
|
while ( rowIndex <= lastRowIndex )
|
||||||
{
|
{
|
||||||
int colunmIndex = firstRowIndex;
|
int colunmIndex = firstRowIndex;
|
||||||
|
@ -154,6 +173,19 @@ void LoadCarDealerAchievementFromXlsx( const std::wstring & fileP
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//核对车商代码
|
||||||
|
auto iterCarDealer = pCarDealerMap->find(carDealerCode);
|
||||||
|
|
||||||
|
if (iterCarDealer == pCarDealerMap->end())
|
||||||
|
{
|
||||||
|
//没查到这个车商,清除掉已经读取的数据
|
||||||
|
achievementVector.clear();
|
||||||
|
QString rowIndexString = QString::number(rowIndex, 'g', -1);
|
||||||
|
QString errorMessage = QString("第") + rowIndexString + QString("行车商代码错误!");
|
||||||
|
|
||||||
|
throw runtime_error(errorMessage.toStdString());
|
||||||
|
}
|
||||||
|
|
||||||
//每个字段都要先判断数据类型再读写,防止填写表格的人填错内容。
|
//每个字段都要先判断数据类型再读写,防止填写表格的人填错内容。
|
||||||
CellType type = pSheet->cellType( rowIndex, firstColumnIndex + 4 );
|
CellType type = pSheet->cellType( rowIndex, firstColumnIndex + 4 );
|
||||||
char errorMessage[1000];
|
char errorMessage[1000];
|
||||||
|
@ -309,6 +341,8 @@ void LoadRepairOrderFromXlsx( const std::wstring & filePath,
|
||||||
int firstRowIndex = pSheet->firstRow();
|
int firstRowIndex = pSheet->firstRow();
|
||||||
int rowIndex = firstRowIndex + startRowIndex;
|
int rowIndex = firstRowIndex + startRowIndex;
|
||||||
|
|
||||||
|
auto* pCarDealerMap = getCarDealerMap();
|
||||||
|
|
||||||
while ( rowIndex <= lastRowIndex )
|
while ( rowIndex <= lastRowIndex )
|
||||||
{
|
{
|
||||||
int colunmIndex = pSheet->firstCol();
|
int colunmIndex = pSheet->firstCol();
|
||||||
|
|
|
@ -18,7 +18,7 @@
|
||||||
using namespace std;
|
using namespace std;
|
||||||
using namespace ocilib;
|
using namespace ocilib;
|
||||||
|
|
||||||
unordered_map<string, CarDealer> * pCarDealerMap = nullptr;
|
unordered_map<wstring, CarDealer> * pCarDealerMap = nullptr;
|
||||||
|
|
||||||
void initCarDealerMap()
|
void initCarDealerMap()
|
||||||
{
|
{
|
||||||
|
@ -63,11 +63,11 @@ void initCarDealerMap()
|
||||||
//连接数据库失败
|
//连接数据库失败
|
||||||
string errorMessage = "连接数据库失败!";
|
string errorMessage = "连接数据库失败!";
|
||||||
|
|
||||||
errorMessage.append(error.what());
|
errorMessage.append( error.what() );
|
||||||
|
|
||||||
OCI_Cleanup();
|
OCI_Cleanup();
|
||||||
|
|
||||||
throw runtime_error(errorMessage.c_str());
|
throw runtime_error( errorMessage.c_str() );
|
||||||
}
|
}
|
||||||
|
|
||||||
//查询
|
//查询
|
||||||
|
@ -78,28 +78,28 @@ void initCarDealerMap()
|
||||||
OCI_ExecuteStmt( pStatement, sql.c_str() );
|
OCI_ExecuteStmt( pStatement, sql.c_str() );
|
||||||
|
|
||||||
pResult = OCI_GetResultset( pStatement );
|
pResult = OCI_GetResultset( pStatement );
|
||||||
pCarDealerMap = new unordered_map<string, CarDealer>;
|
pCarDealerMap = new unordered_map<wstring, CarDealer>;
|
||||||
|
|
||||||
while ( OCI_FetchNext( pResult ) == true )
|
while ( OCI_FetchNext( pResult ) == true )
|
||||||
{
|
{
|
||||||
string carDealerCodeIndex = OCI_GetString( pResult, 1 );
|
wstring carDealerCodeIndex = QString::fromLocal8Bit( OCI_GetString( pResult, 1 ) ).toStdWString();
|
||||||
QString carDealerCode = QString::fromLocal8Bit( OCI_GetString( pResult, 1 ) );
|
QString carDealerCode = QString::fromLocal8Bit( OCI_GetString( pResult, 1 ) );
|
||||||
QString carDealerName = QString::fromLocal8Bit( OCI_GetString( pResult, 2 ) );
|
QString carDealerName = QString::fromLocal8Bit( OCI_GetString( pResult, 2 ) );
|
||||||
|
|
||||||
CarDealer dealer( carDealerCode, carDealerName );
|
CarDealer dealer( carDealerCode, carDealerName );
|
||||||
|
|
||||||
pCarDealerMap->insert( pair<string, CarDealer>( carDealerCodeIndex, dealer ) );
|
pCarDealerMap->insert( pair<wstring, CarDealer>( carDealerCodeIndex, dealer ) );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch ( runtime_error & error )
|
catch ( runtime_error & error )
|
||||||
{
|
{
|
||||||
string errorMessage = "执行查询失败!";
|
string errorMessage = "执行查询失败!";
|
||||||
|
|
||||||
errorMessage.append(error.what());
|
errorMessage.append( error.what() );
|
||||||
|
|
||||||
OCI_Cleanup();
|
OCI_Cleanup();
|
||||||
|
|
||||||
throw runtime_error(errorMessage.c_str());
|
throw runtime_error( errorMessage.c_str() );
|
||||||
}
|
}
|
||||||
|
|
||||||
OCI_Cleanup();
|
OCI_Cleanup();
|
||||||
|
@ -187,7 +187,12 @@ void initCarDealerMapCpp()
|
||||||
Environment::Cleanup();
|
Environment::Cleanup();
|
||||||
}
|
}
|
||||||
|
|
||||||
std::unordered_map<string, CarDealer> * getCarDealerMap()
|
std::unordered_map<wstring, CarDealer> * getCarDealerMap()
|
||||||
{
|
{
|
||||||
|
if ( pCarDealerMap != nullptr )
|
||||||
|
{
|
||||||
|
initCarDealerMap();
|
||||||
|
}
|
||||||
|
|
||||||
return pCarDealerMap;
|
return pCarDealerMap;
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,4 +22,4 @@ void initCarDealerMap();
|
||||||
* \brief
|
* \brief
|
||||||
* \return
|
* \return
|
||||||
************************************************/
|
************************************************/
|
||||||
std::unordered_map<std::string, CarDealer> * getCarDealerMap();
|
std::unordered_map<std::wstring, CarDealer> * getCarDealerMap();
|
||||||
|
|
|
@ -3,26 +3,27 @@
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
#include "Widgets/MainFrame/QMainFrame.h"
|
#include "Widgets/MainFrame/QMainFrame.h"
|
||||||
#include "QLoginDialog.h"
|
#include "QLoginDialog.h"
|
||||||
|
#include "Data/Datastructure/CarDealer/CarDealerMap.h"
|
||||||
#include "test/test.h"
|
#include "test/test.h"
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
int main(int argc, char* argv[])
|
int main( int argc, char * argv[] )
|
||||||
{
|
{
|
||||||
QApplication* pApp = nullptr;
|
QApplication * pApp = nullptr;
|
||||||
QMainFrame* pMainFrame = nullptr;
|
QMainFrame * pMainFrame = nullptr;
|
||||||
QLoginDialog* pLoginDialog = nullptr;
|
QLoginDialog * pLoginDialog = nullptr;
|
||||||
int returnCode = -1;
|
int returnCode = -1;
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
pApp = new QApplication(argc, argv);
|
pApp = new QApplication( argc, argv );
|
||||||
}
|
}
|
||||||
catch (...)
|
catch ( ... )
|
||||||
{
|
{
|
||||||
QMessageBox::critical(nullptr,
|
QMessageBox::critical( nullptr,
|
||||||
"错误!",
|
"错误!",
|
||||||
"1创建QApplication错误!\n请联系开发人员。");
|
"1创建QApplication错误!\n请联系开发人员。" );
|
||||||
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -31,6 +32,20 @@ int main(int argc, char* argv[])
|
||||||
|
|
||||||
//return 1;
|
//return 1;
|
||||||
|
|
||||||
|
//加载资源
|
||||||
|
try
|
||||||
|
{
|
||||||
|
initCarDealerMap();
|
||||||
|
}
|
||||||
|
catch ( runtime_error & error )
|
||||||
|
{
|
||||||
|
QMessageBox::critical( nullptr,
|
||||||
|
"错误!",
|
||||||
|
error.what() );
|
||||||
|
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
//登录界面
|
//登录界面
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
@ -38,17 +53,17 @@ int main(int argc, char* argv[])
|
||||||
|
|
||||||
pLoginDialog->exec();
|
pLoginDialog->exec();
|
||||||
|
|
||||||
if (pLoginDialog->getReturnCode() == QLoginDialog::ReturnCode::EXIT)
|
if ( pLoginDialog->getReturnCode() == QLoginDialog::ReturnCode::EXIT )
|
||||||
{
|
{
|
||||||
//用户点了退出
|
//用户点了退出
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (std::runtime_error error)
|
catch ( std::runtime_error error )
|
||||||
{
|
{
|
||||||
QMessageBox::critical(nullptr,
|
QMessageBox::critical( nullptr,
|
||||||
"错误!",
|
"错误!",
|
||||||
error.what());
|
error.what() );
|
||||||
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -57,19 +72,19 @@ int main(int argc, char* argv[])
|
||||||
{
|
{
|
||||||
pMainFrame = new QMainFrame();
|
pMainFrame = new QMainFrame();
|
||||||
}
|
}
|
||||||
catch (std::runtime_error& error)
|
catch ( std::runtime_error & error )
|
||||||
{
|
{
|
||||||
QMessageBox::critical(nullptr,
|
QMessageBox::critical( nullptr,
|
||||||
"错误!",
|
"错误!",
|
||||||
error.what());
|
error.what() );
|
||||||
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
catch (...)
|
catch ( ... )
|
||||||
{
|
{
|
||||||
QMessageBox::critical(nullptr,
|
QMessageBox::critical( nullptr,
|
||||||
"错误!",
|
"错误!",
|
||||||
"创建窗口过程错误!\n请联系开发人员。");
|
"创建窗口过程错误!\n请联系开发人员。" );
|
||||||
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -80,19 +95,19 @@ int main(int argc, char* argv[])
|
||||||
|
|
||||||
returnCode = pApp->exec();
|
returnCode = pApp->exec();
|
||||||
}
|
}
|
||||||
catch (std::runtime_error& error)
|
catch ( std::runtime_error & error )
|
||||||
{
|
{
|
||||||
QMessageBox::critical(nullptr,
|
QMessageBox::critical( nullptr,
|
||||||
"错误!",
|
"错误!",
|
||||||
error.what());
|
error.what() );
|
||||||
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
catch (...)
|
catch ( ... )
|
||||||
{
|
{
|
||||||
QMessageBox::critical(nullptr,
|
QMessageBox::critical( nullptr,
|
||||||
"错误!",
|
"错误!",
|
||||||
"创建窗口过程错误!\n请联系开发人员。");
|
"创建窗口过程错误!\n请联系开发人员。" );
|
||||||
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
|
@ -55,7 +55,7 @@ void excelTest()
|
||||||
//LoadNewRepairMonitorReportFromXlsx(filePathNewRepairMonitor, 0, 1, repairMonitorVector);
|
//LoadNewRepairMonitorReportFromXlsx(filePathNewRepairMonitor, 0, 1, repairMonitorVector);
|
||||||
//ImportNewRepairMonitorToOracle(userName, password, tnsName, repairMonitorVector);
|
//ImportNewRepairMonitorToOracle(userName, password, tnsName, repairMonitorVector);
|
||||||
|
|
||||||
initCarDealerMap();
|
//initCarDealerMap();
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue