提交信息!
This commit is contained in:
parent
6572379132
commit
1e628ccc30
|
@ -2,6 +2,7 @@
|
|||
#include <stdexcept>
|
||||
#include "LoadFromExcel.h"
|
||||
#include "../../excel/excel.h"
|
||||
#include "../../Data/Datastructure/CarDealer/CarDealerMap.h"
|
||||
|
||||
using namespace std;
|
||||
using namespace libxl;
|
||||
|
@ -52,6 +53,9 @@ void LoadCarDealerSchemeFromXlsx( const wstring & filePath,
|
|||
int firstColumnIndex = pSheet->firstCol();
|
||||
int rowIndex = firstRowIndex + startRowIndex;
|
||||
|
||||
//车商名称表
|
||||
auto * pCarDealerMap = getCarDealerMap();
|
||||
|
||||
while ( rowIndex <= lastRowIndex )
|
||||
{
|
||||
int colunmIndex = firstRowIndex;
|
||||
|
@ -59,12 +63,12 @@ void LoadCarDealerSchemeFromXlsx( const wstring & filePath,
|
|||
const wstring && theYear = ReadCellStringFromXlsx( pBook, sheetIndex, rowIndex, colunmIndex, true );
|
||||
const wstring && theMonth = ReadCellStringFromXlsx( pBook, sheetIndex, rowIndex, colunmIndex + 1, true );
|
||||
const wstring && carDealerCode = ReadCellStringFromXlsx( pBook, sheetIndex, rowIndex, colunmIndex + 2, true );
|
||||
const wstring && carDealerName = ReadCellStringFromXlsx( pBook, sheetIndex, rowIndex, colunmIndex + 3, true );
|
||||
const wstring && manHourPrice = ReadCellStringFromXlsx( pBook, sheetIndex, rowIndex, colunmIndex + 4, true );
|
||||
const wstring && partPrice = ReadCellStringFromXlsx( pBook, sheetIndex, rowIndex, colunmIndex + 5, true );
|
||||
const wstring && claimSupport = ReadCellStringFromXlsx( pBook, sheetIndex, rowIndex, colunmIndex + 6, true );
|
||||
const wstring && scheme = ReadCellStringFromXlsx( pBook, sheetIndex, rowIndex, colunmIndex + 7, true );
|
||||
const wstring && isQualified = ReadCellStringFromXlsx( pBook, sheetIndex, rowIndex, colunmIndex + 8, true );
|
||||
//const wstring && carDealerName = ReadCellStringFromXlsx( pBook, sheetIndex, rowIndex, colunmIndex + 3, true );
|
||||
const wstring && manHourPrice = ReadCellStringFromXlsx( pBook, sheetIndex, rowIndex, colunmIndex + 4, true );
|
||||
const wstring && partPrice = ReadCellStringFromXlsx( pBook, sheetIndex, rowIndex, colunmIndex + 5, true );
|
||||
const wstring && claimSupport = ReadCellStringFromXlsx( pBook, sheetIndex, rowIndex, colunmIndex + 6, true );
|
||||
const wstring && scheme = ReadCellStringFromXlsx( pBook, sheetIndex, rowIndex, colunmIndex + 7, true );
|
||||
const wstring && isQualified = ReadCellStringFromXlsx( pBook, sheetIndex, rowIndex, colunmIndex + 8, true );
|
||||
|
||||
//空行跳过
|
||||
if ( carDealerCode.empty() == true )
|
||||
|
@ -74,6 +78,19 @@ void LoadCarDealerSchemeFromXlsx( const wstring & filePath,
|
|||
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,
|
||||
theMonth,
|
||||
carDealerCode,
|
||||
|
@ -131,6 +148,8 @@ void LoadCarDealerAchievementFromXlsx( const std::wstring & fileP
|
|||
int firstColumnIndex = pSheet->firstCol();
|
||||
int rowIndex = firstRowIndex + startRowIndex;
|
||||
|
||||
unordered_map<wstring, CarDealer>* pCarDealerMap = getCarDealerMap();
|
||||
|
||||
while ( rowIndex <= lastRowIndex )
|
||||
{
|
||||
int colunmIndex = firstRowIndex;
|
||||
|
@ -154,6 +173,19 @@ void LoadCarDealerAchievementFromXlsx( const std::wstring & fileP
|
|||
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 );
|
||||
char errorMessage[1000];
|
||||
|
@ -309,6 +341,8 @@ void LoadRepairOrderFromXlsx( const std::wstring & filePath,
|
|||
int firstRowIndex = pSheet->firstRow();
|
||||
int rowIndex = firstRowIndex + startRowIndex;
|
||||
|
||||
auto* pCarDealerMap = getCarDealerMap();
|
||||
|
||||
while ( rowIndex <= lastRowIndex )
|
||||
{
|
||||
int colunmIndex = pSheet->firstCol();
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
using namespace std;
|
||||
using namespace ocilib;
|
||||
|
||||
unordered_map<string, CarDealer> * pCarDealerMap = nullptr;
|
||||
unordered_map<wstring, CarDealer> * pCarDealerMap = nullptr;
|
||||
|
||||
void initCarDealerMap()
|
||||
{
|
||||
|
@ -63,11 +63,11 @@ void initCarDealerMap()
|
|||
//连接数据库失败
|
||||
string errorMessage = "连接数据库失败!";
|
||||
|
||||
errorMessage.append(error.what());
|
||||
errorMessage.append( error.what() );
|
||||
|
||||
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() );
|
||||
|
||||
pResult = OCI_GetResultset( pStatement );
|
||||
pCarDealerMap = new unordered_map<string, CarDealer>;
|
||||
pCarDealerMap = new unordered_map<wstring, CarDealer>;
|
||||
|
||||
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 carDealerName = QString::fromLocal8Bit( OCI_GetString( pResult, 2 ) );
|
||||
|
||||
CarDealer dealer( carDealerCode, carDealerName );
|
||||
|
||||
pCarDealerMap->insert( pair<string, CarDealer>( carDealerCodeIndex, dealer ) );
|
||||
pCarDealerMap->insert( pair<wstring, CarDealer>( carDealerCodeIndex, dealer ) );
|
||||
}
|
||||
}
|
||||
catch ( runtime_error & error )
|
||||
{
|
||||
string errorMessage = "执行查询失败!";
|
||||
|
||||
errorMessage.append(error.what());
|
||||
errorMessage.append( error.what() );
|
||||
|
||||
OCI_Cleanup();
|
||||
|
||||
throw runtime_error(errorMessage.c_str());
|
||||
throw runtime_error( errorMessage.c_str() );
|
||||
}
|
||||
|
||||
OCI_Cleanup();
|
||||
|
@ -187,7 +187,12 @@ void initCarDealerMapCpp()
|
|||
Environment::Cleanup();
|
||||
}
|
||||
|
||||
std::unordered_map<string, CarDealer> * getCarDealerMap()
|
||||
std::unordered_map<wstring, CarDealer> * getCarDealerMap()
|
||||
{
|
||||
if ( pCarDealerMap != nullptr )
|
||||
{
|
||||
initCarDealerMap();
|
||||
}
|
||||
|
||||
return pCarDealerMap;
|
||||
}
|
||||
|
|
|
@ -22,4 +22,4 @@ void initCarDealerMap();
|
|||
* \brief
|
||||
* \return
|
||||
************************************************/
|
||||
std::unordered_map<std::string, CarDealer> * getCarDealerMap();
|
||||
std::unordered_map<std::wstring, CarDealer> * getCarDealerMap();
|
||||
|
|
|
@ -3,26 +3,27 @@
|
|||
#include <stdexcept>
|
||||
#include "Widgets/MainFrame/QMainFrame.h"
|
||||
#include "QLoginDialog.h"
|
||||
#include "Data/Datastructure/CarDealer/CarDealerMap.h"
|
||||
#include "test/test.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
int main( int argc, char * argv[] )
|
||||
{
|
||||
QApplication* pApp = nullptr;
|
||||
QMainFrame* pMainFrame = nullptr;
|
||||
QLoginDialog* pLoginDialog = nullptr;
|
||||
int returnCode = -1;
|
||||
QApplication * pApp = nullptr;
|
||||
QMainFrame * pMainFrame = nullptr;
|
||||
QLoginDialog * pLoginDialog = nullptr;
|
||||
int returnCode = -1;
|
||||
|
||||
try
|
||||
{
|
||||
pApp = new QApplication(argc, argv);
|
||||
pApp = new QApplication( argc, argv );
|
||||
}
|
||||
catch (...)
|
||||
catch ( ... )
|
||||
{
|
||||
QMessageBox::critical(nullptr,
|
||||
"错误!",
|
||||
"1创建QApplication错误!\n请联系开发人员。");
|
||||
QMessageBox::critical( nullptr,
|
||||
"错误!",
|
||||
"1创建QApplication错误!\n请联系开发人员。" );
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
@ -31,6 +32,20 @@ int main(int argc, char* argv[])
|
|||
|
||||
//return 1;
|
||||
|
||||
//加载资源
|
||||
try
|
||||
{
|
||||
initCarDealerMap();
|
||||
}
|
||||
catch ( runtime_error & error )
|
||||
{
|
||||
QMessageBox::critical( nullptr,
|
||||
"错误!",
|
||||
error.what() );
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
//登录界面
|
||||
try
|
||||
{
|
||||
|
@ -38,17 +53,17 @@ int main(int argc, char* argv[])
|
|||
|
||||
pLoginDialog->exec();
|
||||
|
||||
if (pLoginDialog->getReturnCode() == QLoginDialog::ReturnCode::EXIT)
|
||||
if ( pLoginDialog->getReturnCode() == QLoginDialog::ReturnCode::EXIT )
|
||||
{
|
||||
//用户点了退出
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
catch (std::runtime_error error)
|
||||
catch ( std::runtime_error error )
|
||||
{
|
||||
QMessageBox::critical(nullptr,
|
||||
"错误!",
|
||||
error.what());
|
||||
QMessageBox::critical( nullptr,
|
||||
"错误!",
|
||||
error.what() );
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
@ -57,19 +72,19 @@ int main(int argc, char* argv[])
|
|||
{
|
||||
pMainFrame = new QMainFrame();
|
||||
}
|
||||
catch (std::runtime_error& error)
|
||||
catch ( std::runtime_error & error )
|
||||
{
|
||||
QMessageBox::critical(nullptr,
|
||||
"错误!",
|
||||
error.what());
|
||||
QMessageBox::critical( nullptr,
|
||||
"错误!",
|
||||
error.what() );
|
||||
|
||||
return -1;
|
||||
}
|
||||
catch (...)
|
||||
catch ( ... )
|
||||
{
|
||||
QMessageBox::critical(nullptr,
|
||||
"错误!",
|
||||
"创建窗口过程错误!\n请联系开发人员。");
|
||||
QMessageBox::critical( nullptr,
|
||||
"错误!",
|
||||
"创建窗口过程错误!\n请联系开发人员。" );
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
@ -80,19 +95,19 @@ int main(int argc, char* argv[])
|
|||
|
||||
returnCode = pApp->exec();
|
||||
}
|
||||
catch (std::runtime_error& error)
|
||||
catch ( std::runtime_error & error )
|
||||
{
|
||||
QMessageBox::critical(nullptr,
|
||||
"错误!",
|
||||
error.what());
|
||||
QMessageBox::critical( nullptr,
|
||||
"错误!",
|
||||
error.what() );
|
||||
|
||||
return -1;
|
||||
}
|
||||
catch (...)
|
||||
catch ( ... )
|
||||
{
|
||||
QMessageBox::critical(nullptr,
|
||||
"错误!",
|
||||
"创建窗口过程错误!\n请联系开发人员。");
|
||||
QMessageBox::critical( nullptr,
|
||||
"错误!",
|
||||
"创建窗口过程错误!\n请联系开发人员。" );
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
|
|
@ -55,7 +55,7 @@ void excelTest()
|
|||
//LoadNewRepairMonitorReportFromXlsx(filePathNewRepairMonitor, 0, 1, repairMonitorVector);
|
||||
//ImportNewRepairMonitorToOracle(userName, password, tnsName, repairMonitorVector);
|
||||
|
||||
initCarDealerMap();
|
||||
//initCarDealerMap();
|
||||
|
||||
return;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue