完成表格模板验证

This commit is contained in:
Kane Wang 2020-12-09 10:46:16 +08:00
parent 96bd16a290
commit aff4ec48f6
3 changed files with 105 additions and 40 deletions

View File

@ -36909,94 +36909,94 @@ static const unsigned char qt_resource_struct[] = {
0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
// :/QMainFrame/Resources/8218_box1.png
0x0,0x0,0x1,0x2,0x0,0x0,0x0,0x0,0x0,0x1,0x0,0x1,0x3f,0xef,
0x0,0x0,0x1,0x72,0x96,0xa9,0x44,0x6a,
0x0,0x0,0x1,0x76,0x41,0xcb,0xdd,0xfa,
// :/QMainFrame/Resources/find.png
0x0,0x0,0x1,0x22,0x0,0x0,0x0,0x0,0x0,0x1,0x0,0x1,0xaa,0x5f,
0x0,0x0,0x1,0x72,0x96,0xa9,0x44,0x75,
0x0,0x0,0x1,0x76,0x41,0xcb,0xde,0x4,
// :/QMainFrame/Resources/print.png
0x0,0x0,0x1,0x62,0x0,0x0,0x0,0x0,0x0,0x1,0x0,0x2,0x47,0x63,
0x0,0x0,0x1,0x72,0x96,0xa9,0x44,0x7c,
0x0,0x0,0x1,0x76,0x41,0xcb,0xde,0x8,
// :/QMainFrame/Resources/option.png
0x0,0x0,0x2,0x94,0x0,0x0,0x0,0x0,0x0,0x1,0x0,0x7,0x6,0xb8,
0x0,0x0,0x1,0x72,0x96,0xa9,0x44,0x7b,
0x0,0x0,0x1,0x76,0x41,0xcb,0xde,0x7,
// :/QMainFrame/Resources/x.png
0x0,0x0,0x2,0x2c,0x0,0x0,0x0,0x0,0x0,0x1,0x0,0x5,0x6a,0x2d,
0x0,0x0,0x1,0x72,0x96,0xa9,0x44,0x80,
0x0,0x0,0x1,0x76,0x41,0xcb,0xde,0xb,
// :/QMainFrame/Resources/telephone.png
0x0,0x0,0x2,0xc4,0x0,0x0,0x0,0x0,0x0,0x1,0x0,0x7,0xb2,0x8,
0x0,0x0,0x1,0x72,0x96,0xa9,0x44,0x7e,
0x0,0x0,0x1,0x76,0x41,0xcb,0xde,0xa,
// :/QMainFrame/Resources/plus.png
0x0,0x0,0x2,0x52,0x0,0x0,0x0,0x0,0x0,0x1,0x0,0x6,0x5d,0x5f,
0x0,0x0,0x1,0x72,0x96,0xa9,0x44,0x7b,
0x0,0x0,0x1,0x76,0x41,0xcb,0xde,0x7,
// :/QMainFrame/Resources/20121016085311441_easyicon_cn_128.png
0x0,0x0,0x0,0x82,0x0,0x0,0x0,0x0,0x0,0x1,0x0,0x0,0x77,0x17,
0x0,0x0,0x1,0x72,0x96,0xa9,0x44,0x69,
0x0,0x0,0x1,0x76,0x41,0xcb,0xdd,0xf9,
// :/QMainFrame/Resources/new.png
0x0,0x0,0x2,0xe4,0x0,0x0,0x0,0x0,0x0,0x1,0x0,0x7,0xcc,0x61,
0x0,0x0,0x1,0x72,0x96,0xa9,0x44,0x7a,
0x0,0x0,0x1,0x76,0x41,0xcb,0xde,0x6,
// :/QMainFrame/Resources/CPIC.png
0x0,0x0,0x2,0x3c,0x0,0x0,0x0,0x0,0x0,0x1,0x0,0x5,0xc9,0x50,
0x0,0x0,0x1,0x72,0x96,0xa9,0x44,0x6c,
0x0,0x0,0x1,0x76,0x41,0xcb,0xdd,0xfc,
// :/QMainFrame/Resources/ok.png
0x0,0x0,0x1,0x38,0x0,0x0,0x0,0x0,0x0,0x1,0x0,0x1,0xe8,0x27,
0x0,0x0,0x1,0x72,0x96,0xa9,0x44,0x7a,
0x0,0x0,0x1,0x76,0x41,0xcb,0xde,0x7,
// :/QMainFrame/Resources/face.png
0x0,0x0,0x1,0xc8,0x0,0x0,0x0,0x0,0x0,0x1,0x0,0x4,0x29,0xa6,
0x0,0x0,0x1,0x72,0x96,0xa9,0x44,0x75,
0x0,0x0,0x1,0x76,0x41,0xcb,0xde,0x3,
// :/QMainFrame/Resources/CNY_Red.png
0x0,0x0,0x1,0xf8,0x0,0x0,0x0,0x0,0x0,0x1,0x0,0x4,0xfc,0xe0,
0x0,0x0,0x1,0x72,0x96,0xa9,0x44,0x6b,
0x0,0x0,0x1,0x76,0x41,0xcb,0xdd,0xfb,
// :/QMainFrame/Resources/car2.png
0x0,0x0,0x3,0x10,0x0,0x0,0x0,0x0,0x0,0x1,0x0,0x8,0x69,0x71,
0x0,0x0,0x1,0x72,0x96,0xa9,0x44,0x71,
0x0,0x0,0x1,0x76,0x41,0xcb,0xdd,0xff,
// :/QMainFrame/Resources/app.ico
0x0,0x0,0x0,0x46,0x0,0x1,0x0,0x0,0x0,0x1,0x0,0x0,0x2,0x22,
0x0,0x0,0x1,0x72,0x96,0xa9,0x44,0x6f,
0x0,0x0,0x1,0x76,0x41,0xcb,0xdd,0xfe,
// :/QMainFrame/Resources/save.png
0x0,0x0,0x2,0x7e,0x0,0x0,0x0,0x0,0x0,0x1,0x0,0x6,0xcf,0x1,
0x0,0x0,0x1,0x72,0x96,0xa9,0x44,0x7d,
0x0,0x0,0x1,0x76,0x41,0xcb,0xde,0x9,
// :/QMainFrame/Resources/car.png
0x0,0x0,0x0,0x5a,0x0,0x0,0x0,0x0,0x0,0x1,0x0,0x0,0x1f,0x7e,
0x0,0x0,0x1,0x72,0x96,0xa9,0x44,0x70,
0x0,0x0,0x1,0x76,0x41,0xcb,0xdd,0xfe,
// :/QMainFrame/Resources/cat.png
0x0,0x0,0x0,0x6e,0x0,0x0,0x0,0x0,0x0,0x1,0x0,0x0,0x55,0x58,
0x0,0x0,0x1,0x72,0x96,0xa9,0x44,0x72,
0x0,0x0,0x1,0x76,0x41,0xcb,0xdd,0xff,
// :/QMainFrame/Resources/excel.png
0x0,0x0,0x2,0x14,0x0,0x0,0x0,0x0,0x0,0x1,0x0,0x5,0x51,0x43,
0x0,0x0,0x1,0x72,0x96,0xa9,0x44,0x74,
0x0,0x0,0x1,0x76,0x41,0xcb,0xde,0x2,
// :/QMainFrame/Resources/CPIC??.png
0x0,0x0,0x1,0x7a,0x0,0x0,0x0,0x0,0x0,0x1,0x0,0x2,0x9e,0xab,
0x0,0x0,0x1,0x72,0x96,0xa9,0x44,0x6d,
0x0,0x0,0x1,0x76,0x41,0xcb,0xdd,0xfd,
// :/QMainFrame/Resources/dec.png
0x0,0x0,0x0,0x32,0x0,0x0,0x0,0x0,0x0,0x1,0x0,0x0,0x0,0x0,
0x0,0x0,0x1,0x72,0x96,0xa9,0x44,0x73,
0x0,0x0,0x1,0x76,0x41,0xcb,0xde,0x0,
// :/QMainFrame/Resources/folder.png
0x0,0x0,0x0,0xd2,0x0,0x0,0x0,0x0,0x0,0x1,0x0,0x0,0xcc,0x2a,
0x0,0x0,0x1,0x72,0x96,0xa9,0x44,0x76,
0x0,0x0,0x1,0x76,0x41,0xcb,0xde,0x4,
// :/QMainFrame/Resources/edit.png
0x0,0x0,0x2,0x68,0x0,0x0,0x0,0x0,0x0,0x1,0x0,0x6,0x61,0x1b,
0x0,0x0,0x1,0x72,0x96,0xa9,0x44,0x74,
0x0,0x0,0x1,0x76,0x41,0xcb,0xde,0x1,
// :/QMainFrame/Resources/clean.png
0x0,0x0,0x2,0xf8,0x0,0x0,0x0,0x0,0x0,0x1,0x0,0x8,0x3a,0x47,
0x0,0x0,0x1,0x72,0x96,0xa9,0x44,0x73,
0x0,0x0,0x1,0x76,0x41,0xcb,0xde,0x0,
// :/QMainFrame/Resources/gear.png
0x0,0x0,0x2,0xae,0x0,0x0,0x0,0x0,0x0,0x1,0x0,0x7,0x5c,0x60,
0x0,0x0,0x1,0x72,0x96,0xa9,0x44,0x78,
0x0,0x0,0x1,0x76,0x41,0xcb,0xde,0x5,
// :/QMainFrame/Resources/quit.png
0x0,0x0,0x0,0xec,0x0,0x0,0x0,0x0,0x0,0x1,0x0,0x0,0xe0,0xcc,
0x0,0x0,0x1,0x72,0x96,0xa9,0x44,0x7c,
0x0,0x0,0x1,0x76,0x41,0xcb,0xde,0x8,
// :/QMainFrame/Resources/save2.png
0x0,0x0,0x1,0x4a,0x0,0x0,0x0,0x0,0x0,0x1,0x0,0x2,0x29,0x5d,
0x0,0x0,0x1,0x72,0x96,0xa9,0x44,0x7e,
0x0,0x0,0x1,0x76,0x41,0xcb,0xde,0x9,
// :/QMainFrame/Resources/manager.png
0x0,0x0,0x1,0x94,0x0,0x0,0x0,0x0,0x0,0x1,0x0,0x3,0x55,0x8f,
0x0,0x0,0x1,0x72,0x96,0xa9,0x44,0x79,
0x0,0x0,0x1,0x76,0x41,0xcb,0xde,0x6,
// :/QMainFrame/Resources/login.png
0x0,0x0,0x1,0xb0,0x0,0x0,0x0,0x0,0x0,0x1,0x0,0x3,0xb9,0xe4,
0x0,0x0,0x1,0x72,0x96,0xa9,0x44,0x79,
0x0,0x0,0x1,0x76,0x41,0xcb,0xde,0x5,
// :/QMainFrame/Resources/tongji.png
0x0,0x0,0x1,0xde,0x0,0x0,0x0,0x0,0x0,0x1,0x0,0x4,0x8a,0x1,
0x0,0x0,0x1,0x72,0x96,0xa9,0x44,0x7f,
0x0,0x0,0x1,0x76,0x41,0xcb,0xde,0xa,
};

View File

@ -8,6 +8,28 @@
using namespace std;
using namespace libxl;
//车商方案表
const unsigned int CARDEALER_SCHEMA_CAPTION_COUNT = 9;
const wchar_t * pwszSchema[] = {L"年度", L"月份", L"车商代码", L"车商名称", L"工时标准", L"配件价格", L"其他理赔支持", L"营销活动方案", L"是否达成预期"};
//车商业绩表
const unsigned int CARDEALER_ACHIEVEMENT_CAPTION_COUNT = 10;
const wchar_t* pwszAchievement[] = { L"年度", L"月份", L"车商代码", L"车商名称", L"店内双签产值(万元)", L"店内新车开票数", L"我司新车签单台次", L"人保新车签单台次", L"平安新车签单台次", L"其他保险公司新车签单台次" };
/************************************************
* \brief
* \param pBook
* \param sheetIndex
* \param captionRowIndex
* \param pszCaptionFormat
* \param captionCount
* \return
************************************************/
bool checkExcelFileFormat( Book * pBook,
int sheetIndex,
int captionRowIndex,
const wchar_t * pszCaptionFormat[],
int captionCount );
/************************************************
* \brief Excel文件读取车商方案表
@ -37,6 +59,19 @@ void LoadCarDealerSchemeFromXlsx( const wstring & filePath,
throw runtime_error( errorMessage );
}
//验证表格内容是否相符
bool isEqual = checkExcelFileFormat( pBook, sheetIndex, startRowIndex - 1, pwszSchema, CARDEALER_SCHEMA_CAPTION_COUNT );
if ( isEqual == false )
{
//内容不相符,抛出异常
string errorMessage = "Excel文件内容不符\n请核对后再导入!";
pBook->release();
throw runtime_error( errorMessage );
}
pSheet = pBook->getSheet( sheetIndex );
if ( pSheet == nullptr )
@ -54,7 +89,7 @@ void LoadCarDealerSchemeFromXlsx( const wstring & filePath,
int firstColumnIndex = pSheet->firstCol();
int rowIndex = firstRowIndex + startRowIndex;
//车商名称表
//车商名称表,用于验证表格中的车商代码
auto * pCarDealerMap = GetCarDealerMap();
while ( rowIndex <= lastRowIndex )
@ -132,6 +167,19 @@ void LoadCarDealerAchievementFromXlsx( const std::wstring & fileP
throw runtime_error( errorMessage );
}
//验证表格内容是否相符
bool isEqual = checkExcelFileFormat(pBook, sheetIndex, startRowIndex - 1, pwszAchievement, CARDEALER_ACHIEVEMENT_CAPTION_COUNT);
if (isEqual == false)
{
//内容不相符,抛出异常
string errorMessage = "Excel文件内容不符\n请核对后再导入!";
pBook->release();
throw runtime_error(errorMessage);
}
pSheet = pBook->getSheet( sheetIndex );
if ( pSheet == nullptr )
@ -149,6 +197,7 @@ void LoadCarDealerAchievementFromXlsx( const std::wstring & fileP
int firstColumnIndex = pSheet->firstCol();
int rowIndex = firstRowIndex + startRowIndex;
//车商名称表
unordered_map<wstring, CarDealer> * pCarDealerMap = GetCarDealerMap();
while ( rowIndex <= lastRowIndex )
@ -158,7 +207,7 @@ void LoadCarDealerAchievementFromXlsx( const std::wstring & fileP
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 );
long double checkedAchievement = 0;
int policyAmount = 0;
int cpicAmount = 0;
@ -366,7 +415,7 @@ void LoadRepairOrderFromXlsx( const std::wstring & filePath,
const wstring && isSuccess = ReadCellStringFromXlsx( pBook, sheetIndex, rowIndex, colunmIndex++, true );
const wstring && recommandDealerCode = ReadCellStringFromXlsx( pBook, sheetIndex, rowIndex, colunmIndex++, true );
const wstring && recommandDealerName = ReadCellStringFromXlsx( pBook, sheetIndex, rowIndex, colunmIndex++, true );
const wstring && recommandDealerCodeInNotify = L""; // ReadCellStringFromXlsx(pBook, sheetIndex, rowIndex, colunmIndex, true);
const wstring && recommandDealerCodeInNotify = L""; //表格中没有报案推荐车商代码
const wstring && recommandDealerNameInNotify = ReadCellStringFromXlsx( pBook, sheetIndex, rowIndex, colunmIndex++, true );
const wstring && recommandDealerNameInSurvey = ReadCellStringFromXlsx( pBook, sheetIndex, rowIndex, colunmIndex++, true );
const wstring && agentName = ReadCellStringFromXlsx( pBook, sheetIndex, rowIndex, colunmIndex++, true );
@ -726,18 +775,35 @@ void LoadNewRepairMonitorReportFromXlsx( const std::wstring &
* \param pszCaptionFormat
* \return
************************************************/
bool checkExcelFileFormat( Book * pBook, int sheetIndex, int captionRowIndex, wchar_t * pszCaptionFormat[], int captionCount )
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,11 +1,8 @@
#include <QFileDialog>
#include "QCarDealerAchievementWidget.h"
#include <QMessageBox>
#include <stdexcept>
#include "QCarDealerAchievementWidget.h"
#include "../../Data/Datastructure/CarDealer/CarDealerMap.h"
#include "../../../data/DataManipulation/oracle/ImportToOracle.h"
#include "../../Data/DataManipulation/Excel/LoadFromExcel.h"
#include "../../../util/qt/qt_util.h"
@ -98,6 +95,8 @@ void QCarDealerAchievementWidget::showCarDealerAchievement()
ui.pTableWidgetAchievement->setItem( rowIndex, columnIndex++, pItem );
//车商名称
QString carDealerName = QString::fromStdWString(GetCarDealerName(iter->getCarDealerCode()));
pItem = new QTableWidgetItem( QString::fromStdWString( iter->getCarDealerCode() ) );
pItem->setTextAlignment( Qt::AlignVCenter | Qt::AlignHCenter );