...
This commit is contained in:
parent
413c6c2f29
commit
ae8f9ec881
@ -21,6 +21,7 @@
|
||||
<ClCompile Include="..\..\..\source\Data\DataManipulation\Excel\LoadFromExcel.cpp" />
|
||||
<ClCompile Include="..\..\..\source\Data\Datastructure\CarDealerAchievement\CarDealerAchievement.cpp" />
|
||||
<ClCompile Include="..\..\..\source\Data\Datastructure\CarDealerScheme\CarDealerScheme.cpp" />
|
||||
<ClCompile Include="..\..\..\source\data\Datastructure\RepairOrder\RepairOrder.cpp" />
|
||||
<ClCompile Include="..\..\..\source\data\excel\excel.cpp" />
|
||||
<ClCompile Include="..\..\..\source\main.cpp" />
|
||||
<ClCompile Include="..\..\..\source\test\test.cpp" />
|
||||
@ -40,6 +41,7 @@
|
||||
<ClInclude Include="..\..\..\source\Data\DataManipulation\Excel\LoadFromExcel.h" />
|
||||
<ClInclude Include="..\..\..\source\Data\Datastructure\CarDealerAchievement\CarDealerAchievement.h" />
|
||||
<ClInclude Include="..\..\..\source\Data\Datastructure\CarDealerScheme\CarDealerScheme.h" />
|
||||
<ClInclude Include="..\..\..\source\data\Datastructure\RepairOrder\RepairOrder.h" />
|
||||
<ClInclude Include="..\..\..\source\data\excel\excel.h" />
|
||||
<ClInclude Include="..\..\..\source\test\test.h" />
|
||||
</ItemGroup>
|
||||
|
@ -56,6 +56,9 @@
|
||||
<Filter Include="excel">
|
||||
<UniqueIdentifier>{61d5dd61-6b1f-4507-bb22-4ce463ad5b85}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="数据\数据结构\送返修工单">
|
||||
<UniqueIdentifier>{985188c7-d233-46c8-bc1f-f7079c27bb2e}</UniqueIdentifier>
|
||||
</Filter>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="..\..\..\source\main.cpp">
|
||||
@ -82,6 +85,9 @@
|
||||
<ClCompile Include="..\..\..\source\data\excel\excel.cpp">
|
||||
<Filter>excel</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\..\source\data\Datastructure\RepairOrder\RepairOrder.cpp">
|
||||
<Filter>数据\数据结构\送返修工单</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<QtRcc Include="..\..\..\source\resource.qrc">
|
||||
@ -127,5 +133,8 @@
|
||||
<ClInclude Include="..\..\..\source\data\excel\excel.h">
|
||||
<Filter>excel</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\..\source\data\Datastructure\RepairOrder\RepairOrder.h">
|
||||
<Filter>数据\数据结构\送返修工单</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
</Project>
|
@ -66,6 +66,14 @@ void LoadCarDealerSchemeFromXlsx( const wstring & filePath,
|
||||
const wstring && scheme = ReadCellStringFromXlsx( pBook, sheetIndex, rowIndex, colunmIndex + 7, true );
|
||||
const wstring && isQualified = ReadCellStringFromXlsx( pBook, sheetIndex, rowIndex, colunmIndex + 8, true );
|
||||
|
||||
//空行跳过
|
||||
if (carDealerCode.empty() == true)
|
||||
{
|
||||
rowIndex++;
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
CarDealerScheme carDealerScheme( theYear,
|
||||
theMonth,
|
||||
carDealerCode,
|
||||
@ -82,3 +90,182 @@ void LoadCarDealerSchemeFromXlsx( const wstring & filePath,
|
||||
|
||||
pBook->release();
|
||||
}
|
||||
|
||||
void LoadCarDealerAchievementFromXlsx( const std::wstring & filePath,
|
||||
unsigned sheetIndex,
|
||||
unsigned startRowIndex,
|
||||
std::vector<CarDealerAchievement> & achievementVector )
|
||||
{
|
||||
Book * pBook = xlCreateXMLBookW();
|
||||
Sheet * pSheet = nullptr;
|
||||
|
||||
if ( pBook == nullptr )
|
||||
{
|
||||
throw runtime_error( "libxl库加载失败!" );
|
||||
}
|
||||
|
||||
setKey( pBook );
|
||||
|
||||
if ( pBook->load( filePath.c_str() ) != true )
|
||||
{
|
||||
string errorMessage = "打开文件失败!";
|
||||
errorMessage.append( pBook->errorMessage() );
|
||||
|
||||
throw runtime_error( errorMessage );
|
||||
}
|
||||
|
||||
pSheet = pBook->getSheet( sheetIndex );
|
||||
|
||||
if ( pSheet == nullptr )
|
||||
{
|
||||
string errorMessage = "读取sheet失败!";
|
||||
errorMessage.append( pBook->errorMessage() );
|
||||
|
||||
pBook->release();
|
||||
|
||||
throw runtime_error( errorMessage );
|
||||
}
|
||||
|
||||
int lastRowIndex = pSheet->lastRow();
|
||||
int firstRowIndex = pSheet->firstRow();
|
||||
int firstColumnIndex = pSheet->firstCol();
|
||||
int rowIndex = firstRowIndex + startRowIndex;
|
||||
|
||||
while ( rowIndex <= lastRowIndex )
|
||||
{
|
||||
int colunmIndex = firstRowIndex;
|
||||
|
||||
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 );
|
||||
long double checkedAchievement = 0;
|
||||
int policyAmount = 0;
|
||||
int cpicAmount = 0;
|
||||
int piccAmount = 0;
|
||||
int pinganAmount = 0;
|
||||
int othersAmount = 0;
|
||||
|
||||
//空行跳过
|
||||
if ( carDealerCode.empty() == true )
|
||||
{
|
||||
rowIndex++;
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
//每个字段都要先判断数据类型再读写,防止填写表格的人填错内容。
|
||||
CellType type = pSheet->cellType( rowIndex, firstColumnIndex + 4 );
|
||||
char errorMessage[1000];
|
||||
|
||||
//产值
|
||||
if ( type == CELLTYPE_NUMBER )
|
||||
{
|
||||
checkedAchievement = pSheet->readNum( rowIndex, firstColumnIndex + 4 );
|
||||
}
|
||||
else
|
||||
{
|
||||
pBook->release();
|
||||
|
||||
sprintf( errorMessage, "第%d行第%d列,格式错误,不是数字类型!", rowIndex, firstColumnIndex + 4 );
|
||||
|
||||
throw runtime_error( errorMessage );
|
||||
}
|
||||
|
||||
//签单数量
|
||||
type = pSheet->cellType( rowIndex, firstColumnIndex + 5 );
|
||||
|
||||
if ( type == CELLTYPE_NUMBER )
|
||||
{
|
||||
policyAmount = static_cast<int>(pSheet->readNum( rowIndex, firstColumnIndex + 5 ));
|
||||
}
|
||||
else
|
||||
{
|
||||
pBook->release();
|
||||
|
||||
sprintf( errorMessage, "第%d行第%d列,格式错误,不是数字类型!", rowIndex, firstColumnIndex + 5 );
|
||||
|
||||
throw runtime_error( errorMessage );
|
||||
}
|
||||
|
||||
//太平洋保险新车签单台次
|
||||
type = pSheet->cellType( rowIndex, firstColumnIndex + 6 );
|
||||
|
||||
if ( type == CELLTYPE_NUMBER )
|
||||
{
|
||||
cpicAmount = static_cast<int>(pSheet->readNum( rowIndex, firstColumnIndex + 6 ));
|
||||
}
|
||||
else
|
||||
{
|
||||
pBook->release();
|
||||
|
||||
sprintf( errorMessage, "第%d行第%d列,格式错误,不是数字类型!", rowIndex, firstColumnIndex + 6 );
|
||||
|
||||
throw runtime_error( errorMessage );
|
||||
}
|
||||
|
||||
//中国人保新车签单台次
|
||||
type = pSheet->cellType( rowIndex, firstColumnIndex + 7 );
|
||||
|
||||
if ( type == CELLTYPE_NUMBER )
|
||||
{
|
||||
piccAmount = static_cast<int>(pSheet->readNum( rowIndex, firstColumnIndex + 7 ));
|
||||
}
|
||||
else
|
||||
{
|
||||
pBook->release();
|
||||
|
||||
sprintf( errorMessage, "第%d行第%d列,格式错误,不是数字类型!", rowIndex, firstColumnIndex + 7 );
|
||||
|
||||
throw runtime_error( errorMessage );
|
||||
}
|
||||
|
||||
//中国平安新车签单台次
|
||||
type = pSheet->cellType( rowIndex, firstColumnIndex + 8 );
|
||||
|
||||
if ( type == CELLTYPE_NUMBER )
|
||||
{
|
||||
pinganAmount = static_cast<int>(pSheet->readNum( rowIndex, firstColumnIndex + 8 ));
|
||||
}
|
||||
else
|
||||
{
|
||||
pBook->release();
|
||||
|
||||
sprintf( errorMessage, "第%d行第%d列,格式错误,不是数字类型!", rowIndex, firstColumnIndex + 8 );
|
||||
|
||||
throw runtime_error( errorMessage );
|
||||
}
|
||||
|
||||
//其他保险公司新车签单台次
|
||||
type = pSheet->cellType( rowIndex, firstColumnIndex + 9 );
|
||||
|
||||
if ( type == CELLTYPE_NUMBER )
|
||||
{
|
||||
othersAmount = static_cast<int>(pSheet->readNum( rowIndex, firstColumnIndex + 9 ));
|
||||
}
|
||||
else
|
||||
{
|
||||
pBook->release();
|
||||
|
||||
sprintf( errorMessage, "第%d行第%d列,格式错误,不是数字类型!", rowIndex, firstColumnIndex + 9 );
|
||||
|
||||
throw runtime_error( errorMessage );
|
||||
}
|
||||
|
||||
CarDealerAchievement achievement( theYear,
|
||||
theMonth,
|
||||
carDealerCode,
|
||||
checkedAchievement,
|
||||
policyAmount,
|
||||
cpicAmount,
|
||||
piccAmount,
|
||||
pinganAmount,
|
||||
othersAmount );
|
||||
|
||||
achievementVector.push_back( achievement );
|
||||
|
||||
rowIndex++;
|
||||
}
|
||||
|
||||
pBook->release();
|
||||
}
|
||||
|
@ -9,3 +9,10 @@ void LoadCarDealerSchemeFromXlsx( const std::wstring & filePath,
|
||||
unsigned int sheetIndex,
|
||||
unsigned int startRowIndex,
|
||||
std::vector<CarDealerScheme> & schemeVector );
|
||||
|
||||
void LoadCarDealerAchievementFromXlsx( const std::wstring & filePath,
|
||||
unsigned int sheetIndex,
|
||||
unsigned int startRowIndex,
|
||||
std::vector<CarDealerAchievement> & achievementVector );
|
||||
|
||||
//void LoadRepairOrderFromXlsx();
|
||||
|
@ -0,0 +1,2 @@
|
||||
|
||||
#include "RepairOrder.h"
|
@ -0,0 +1,11 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
|
||||
class RepairOrder
|
||||
{
|
||||
|
||||
private:
|
||||
|
||||
};
|
@ -4,6 +4,10 @@
|
||||
|
||||
#include <libxl.h>
|
||||
|
||||
/************************************************
|
||||
* \brief 注册libxl产品
|
||||
* \param pBook
|
||||
************************************************/
|
||||
void setKey( libxl::Book * pBook );
|
||||
|
||||
/************************************************
|
||||
@ -12,6 +16,7 @@ void setKey( libxl::Book * pBook );
|
||||
* \param sheetIndex sheet的索引值
|
||||
* \param rowIndex 行号
|
||||
* \param colIndex 列号
|
||||
* \param isInteger 单元格为数字类型时,选择是输出整形还是浮点型字符串
|
||||
* \return 返回的字符串
|
||||
************************************************/
|
||||
std::wstring ReadCellStringFromXlsx( libxl::IBookT<wchar_t> * pBook,
|
||||
|
@ -1,5 +1,4 @@
|
||||
|
||||
#include <vector>
|
||||
#include <vector>
|
||||
#include <string>
|
||||
#include "test.h"
|
||||
#include "../data/DataManipulation/Excel/LoadFromExcel.h"
|
||||
@ -15,10 +14,13 @@ void test()
|
||||
|
||||
void excelTest()
|
||||
{
|
||||
vector<CarDealerScheme> schemeVector;
|
||||
wstring filePath = L"D:/develop/projects_win/2019/car_dealer_util/数据/PC端导入模板(管理员版).xlsx";
|
||||
vector<CarDealerScheme> schemeVector;
|
||||
vector<CarDealerAchievement> achievementsVector;
|
||||
|
||||
LoadCarDealerSchemeFromXlsx(filePath, 0, 1, schemeVector);
|
||||
wstring filePath = L"D:/develop/projects_win/2019/car_dealer_util/数据/PC端导入模板(客户经理版).xlsx";
|
||||
|
||||
//LoadCarDealerSchemeFromXlsx(filePath, 0, 1, schemeVector);
|
||||
LoadCarDealerAchievementFromXlsx( filePath, 0, 1, achievementsVector );
|
||||
|
||||
return;
|
||||
}
|
42
代码/数据库/建表/车商业绩表.sql
Normal file
42
代码/数据库/建表/车商业绩表.sql
Normal file
@ -0,0 +1,42 @@
|
||||
DROP TABLE CAR_DEALER_ACHIEVEMENT;
|
||||
-- Create table
|
||||
create table CAR_DEALER_ACHIEVEMENT
|
||||
(
|
||||
the_year VARCHAR2(4),
|
||||
the_month VARCHAR2(2),
|
||||
car_dealer_code VARCHAR2(20),
|
||||
checked_achievement NUMBER(16,2),
|
||||
policy_amount INTEGER,
|
||||
cpic_amount INTEGER,
|
||||
picc_amount INTEGER,
|
||||
pingan_amount INTEGER,
|
||||
others_amount INTEGER
|
||||
)
|
||||
tablespace CAR_DEALER;
|
||||
-- Add comments to the table
|
||||
comment on table CAR_DEALER_ACHIEVEMENT
|
||||
is '车商业绩表';
|
||||
-- Add comments to the columns
|
||||
comment on column CAR_DEALER_ACHIEVEMENT.the_year
|
||||
is '统计年份';
|
||||
comment on column CAR_DEALER_ACHIEVEMENT.the_month
|
||||
is '统计月份';
|
||||
comment on column CAR_DEALER_ACHIEVEMENT.car_dealer_code
|
||||
is '车商代码';
|
||||
comment on column CAR_DEALER_ACHIEVEMENT.checked_achievement
|
||||
is '店内双签产值';
|
||||
comment on column CAR_DEALER_ACHIEVEMENT.policy_amount
|
||||
is '店内新车开票数';
|
||||
comment on column CAR_DEALER_ACHIEVEMENT.cpic_amount
|
||||
is '太平洋保险新车签单台次';
|
||||
comment on column CAR_DEALER_ACHIEVEMENT.picc_amount
|
||||
is '中国人保新车签单台次';
|
||||
comment on column CAR_DEALER_ACHIEVEMENT.pingan_amount
|
||||
is '中国平安新车签单台次';
|
||||
comment on column CAR_DEALER_ACHIEVEMENT.others_amount
|
||||
is '其他保险公司新车签单台次';
|
||||
-- Create/Recreate indexes
|
||||
create index CAR_DEALER_ACHIEVEMENT_IDX01 on CAR_DEALER_ACHIEVEMENT (THE_YEAR, THE_MONTH, CAR_DEALER_CODE)
|
||||
tablespace CAR_DEALER_IDX;
|
||||
-- Grant/Revoke object privileges
|
||||
grant select on CAR_DEALER_ACHIEVEMENT to DATACENTER;
|
59
代码/数据库/建表/车商方案表.sql
Normal file
59
代码/数据库/建表/车商方案表.sql
Normal file
@ -0,0 +1,59 @@
|
||||
--DROP TABLE CAR_DEALER_SCHEME;
|
||||
-- Create table
|
||||
create table CAR_DEALER_SCHEME
|
||||
(
|
||||
the_year VARCHAR2(4),
|
||||
the_month VARCHAR2(2),
|
||||
car_dealer_code VARCHAR2(20),
|
||||
man_hour_price VARCHAR2(200 CHAR),
|
||||
part_price VARCHAR2(200 CHAR),
|
||||
claim_support VARCHAR2(200 CHAR),
|
||||
scheme VARCHAR2(1000 CHAR),
|
||||
is_qualified CHAR(2)
|
||||
)
|
||||
tablespace CAR_DEALER
|
||||
pctfree 10
|
||||
initrans 1
|
||||
maxtrans 255
|
||||
storage
|
||||
(
|
||||
initial 64K
|
||||
next 1M
|
||||
minextents 1
|
||||
maxextents unlimited
|
||||
);
|
||||
-- Add comments to the table
|
||||
comment on table CAR_DEALER_SCHEME
|
||||
is '车商方案表';
|
||||
-- Add comments to the columns
|
||||
comment on column CAR_DEALER_SCHEME.the_year
|
||||
is '年份';
|
||||
comment on column CAR_DEALER_SCHEME.the_month
|
||||
is '月份';
|
||||
comment on column CAR_DEALER_SCHEME.car_dealer_code
|
||||
is '车商代码';
|
||||
comment on column CAR_DEALER_SCHEME.man_hour_price
|
||||
is '工时标准';
|
||||
comment on column CAR_DEALER_SCHEME.part_price
|
||||
is '配件价格';
|
||||
comment on column CAR_DEALER_SCHEME.claim_support
|
||||
is '其他理赔支持';
|
||||
comment on column CAR_DEALER_SCHEME.scheme
|
||||
is '营销活动方案';
|
||||
comment on column CAR_DEALER_SCHEME.is_qualified
|
||||
is '是否达成预期';
|
||||
-- Create/Recreate indexes
|
||||
create index CAR_DEALER_SCHEME_IDX on CAR_DEALER_SCHEME (THE_YEAR, THE_MONTH, CAR_DEALER_CODE)
|
||||
tablespace CAR_DEALER_IDX
|
||||
pctfree 10
|
||||
initrans 2
|
||||
maxtrans 255
|
||||
storage
|
||||
(
|
||||
initial 64K
|
||||
next 1M
|
||||
minextents 1
|
||||
maxextents unlimited
|
||||
);
|
||||
-- Grant/Revoke object privileges
|
||||
grant select on CAR_DEALER_SCHEME to DATACENTER;
|
BIN
数据/测试数据.rar
BIN
数据/测试数据.rar
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user