提交信息!
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,7 +63,7 @@ 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 && 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 );
|
||||
|
@ -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()
|
||||
{
|
||||
|
@ -78,17 +78,17 @@ 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 )
|
||||
|
@ -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,6 +3,7 @@
|
|||
#include <stdexcept>
|
||||
#include "Widgets/MainFrame/QMainFrame.h"
|
||||
#include "QLoginDialog.h"
|
||||
#include "Data/Datastructure/CarDealer/CarDealerMap.h"
|
||||
#include "test/test.h"
|
||||
|
||||
using namespace std;
|
||||
|
@ -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
|
||||
{
|
||||
|
|
|
@ -55,7 +55,7 @@ void excelTest()
|
|||
//LoadNewRepairMonitorReportFromXlsx(filePathNewRepairMonitor, 0, 1, repairMonitorVector);
|
||||
//ImportNewRepairMonitorToOracle(userName, password, tnsName, repairMonitorVector);
|
||||
|
||||
initCarDealerMap();
|
||||
//initCarDealerMap();
|
||||
|
||||
return;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue