⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 preuser.hpp

📁 可以对从数据库导出的数据文件进行纠错处理
💻 HPP
字号:
/****************************preuser.hpp****************************
 * 文件类型:	.hpp
 * 功    能:	用户资料预处理
 * 开发平台:	Sun OS 2.6 , c++ 3.3
 * 编    者:	郭世强
 * 完成日期: 	2004-04-1
 * 修改日期: 	2004-08-20
 ***********************************************************************/
 
#ifndef		__INC_PREUSER_H_
#define		__INC_PREUSER_H_

#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <stdarg.h>
#include <iostream>
#include <string>
#include <ext/hash_map>
#include <ext/hash_set>

using namespace __gnu_cxx;
using namespace std;

#define		PREUSER_ERR(errno)	(-1000 + (errno))

struct hashstring
{
	size_t operator()(const string& s) const { return __stl_hash_string(s.c_str()); }
};

const int 	SERV_FIELD_COUNT 				= 42;			// 用户表的字段个数
const int 	CUST_FIELD_COUNT 				= 26;			// 客户表的字段个数
const int 	ACCT_FIELD_COUNT 				= 29;			// 帐户表的字段个数
const int	SERV_ACCT_FIELD_COUNT			= 11;			// 帐务关系表的字段个数
const int	SERV_PRODUCT_FIELD_COUNT		= 13;			// 占用资源表的字段个数
                                        	
const int 	SERV_SERV_ID_POS 				= 0;
const int 	SERV_SEQ_NBR_POS 				= 1;
const int	SERV_ACC_NBR_POS				= 4;
const int	SERV_EXCHANGE_ID_POS			= 5;
const int 	SERV_AREA_ID_POS 				= 7;
const int 	SERV_EXCHANGE_97_POS 			= 8;
const int 	SERV_TYPE_ID_POS 				= 9;
const int	SERV_BILLING_TYPE_ID_POS		= 10;
const int	SERV_VIP_FLAG_POS				= 15;
const int 	SERV_CUST_ID_POS 				= 16;
const int 	SERV_STATE_POS 					= 18;
const int 	SERV_CREATED_DATE_POS			= 26;
const int 	SERV_LATN_ID_POS 				= 23;
const int 	SERV_OCCUPATION_ID_POS 			= 32;
const int 	SERV_PROPERTY_ID_POS 			= 35;
const int 	SERV_BILLING_FLAG_ID_POS 		= 36;
const int	SERV_CUST_GROUP_ID_POS			= 42;
const int	SERV_ACCT_ID_POS				= 43;
const int	SERV_ACCT_NAME_POS				= 44;

                                        	
const int 	CUST_CUST_ID_POS 				= 0;
const int 	CUST_SEQ_NBR_POS 				= 1;
const int 	CUST_CUST_NAME_POS 				= 2;
const int 	CUST_TYPE_ID_POS 				= 4;
const int 	CUST_VIP_FLAG_POS 				= 7;
const int 	CUST_STATE_POS 					= 11;

const int 	CUST_CUST_ID_1_POS 				= 0;
const int 	CUST_CUST_NAME_1_POS 			= 1;
const int 	CUST_TYPE_ID_1_POS 				= 2;
const int 	CUST_VIP_FLAG_1_POS 			= 3;
const int 	CUST_STATE_1_POS 				= 4;

const int 	ACCT_ACCT_ID_POS 				= 0;
const int 	ACCT_SEQ_NBR_POS 				= 1;
const int	ACCT_ACCT_NAME_POS				= 2;
const int 	ACCT_PAYMENT_METHOD_POS 		= 5;
const int 	ACCT_SITE_ID_POS 				= 22;
const int 	ACCT_STATE_POS 					= 15;

const int 	SERV_ACCT_SERV_ID_POS 			= 1;
const int 	SERV_ACCT_SEQ_NBR_POS 			= 2;
const int 	SERV_ACCT_ACCT_ID_POS 			= 3;
const int 	SERV_ACCT_ACCT_ITEM_TYPE_ID_POS = 4;
const int 	SERV_ACCT_STATE_POS 			= 5;

const int	SERV_PROD_SERV_ID_POS			= 1;
const int	SERV_PROD_PRODUCT_ID_POS		= 2;
const int	SERV_PROD_SEQ_NBR_POS			= 3;
const int	SERV_PROD_PRODUCT_QUANTITY_POS	= 4;
const int	SERV_PROD_STATE_POS				= 5;

const int 	LINE_MAX_LEN 					= 1024;			// 原始数据一行的最大字符数
const int	FILTER_LINE_LEN					= 256;			// 过滤后一行的最大字符数
const char* SERV_STATE_NORMAL 				= "F0A";		// 用户状态正常
const char* CUST_STATE_NORMAL 				= "70A";		// 客户状态正常
const char* ACCT_STATE_NORMAL 				= "10A";		// 帐户状态正常
const char* SERV_ACCT_STATE_NORMAL			= "H0A";		// 帐务关系状态正常
const char* SERV_PRODUCT_STATE_NORMAL		= "H0A";		// 占用资源状态正常

// serv_acct表的存储结构
typedef struct __serv_acct{
	char serv_id[17];
	char seq_nbr[7];
	char acct_id[17];
	char acct_item_type_id[10];
	char state[3];
} TServAcct;

// 过滤后的serv_acct表的存储结构
typedef struct __serv_acct1{
	char serv_id[17];
	char acct_id[17];
} TServAcct1;

// serv_product表的存储结构
typedef struct __serv_product{
	char serv_id[17];
	char seq_nbr[7];
	char product_id[9];
	char product_quantity[21];
	char state[3];
} TServProd;

// 过滤后的serv_product表的存储结构
typedef struct __serv_product1{
	char serv_id[17];
	char product_id[9];
	char product_quantity[21];
} TServProd1;

typedef		vector<string>								TVector;
typedef		TVector::value_type							TVecType;
typedef		TVector::iterator							TVecIt;

typedef 	hash_map<string, string, hashstring>		TMap;
typedef		TMap::value_type							TMaptype;
typedef 	TMap::iterator								TMapit;

typedef 	hash_map<string, TVector, hashstring>		TServMap;
typedef		TServMap::value_type						TServMaptype;
typedef 	TServMap::iterator							TServMapit;
        	
typedef 	hash_map<string, TVector, hashstring>		TCustMap;
typedef		TCustMap::value_type						TCustMaptype;
typedef 	TCustMap::iterator							TCustMapit;
        	
typedef 	hash_map<string, TVector, hashstring>		TAcctMap;
typedef		TAcctMap::value_type						TAcctMaptype;
typedef 	TAcctMap::iterator							TAcctMapit;

typedef 	hash_map<string, TServAcct, hashstring>		TServAcctMap;
typedef		TServAcctMap::value_type					TServAcctMaptype;
typedef 	TServAcctMap::iterator						TServAcctMapit;

typedef 	hash_map<string, TServProd, hashstring>		TServProdMap;
typedef		TServProdMap::value_type					TServProdMaptype;
typedef 	TServProdMap::iterator						TServProdMapit;

typedef 	hash_map<string, TServAcct1, hashstring>	TServAcct1Map;
typedef		TServAcct1Map::value_type					TServAcct1Maptype;
typedef 	TServAcct1Map::iterator						TServAcct1Mapit;

typedef 	hash_map<string, TServProd1, hashstring>	TServProd1Map;
typedef		TServProd1Map::value_type					TServProd1Maptype;
typedef 	TServProd1Map::iterator						TServProd1Mapit;

typedef 	hash_set<string, hashstring> 				TSet;
typedef 	TSet::value_type 							TSettype;
typedef 	TSet::iterator								TSetit;

/************************* judgeError() ************************
 *
 * 函数名称: judgeError
 * 输入参数: const char* strLine			需要判断的数据(一条记录)
 * 输出参数: int iFlag						1,serv;2,cust;3,acct;4,serv_acct;5,serv_product.
 * 返 回 值: 无
 * 功能描述: 判断预处理数据是否为错单
 *
 ********************************************************************/
int judgeError(const char* strLine, int iFlag);
/************************* getServInfo() ************************
 *
 * 函数名称: getServInfo
 * 输入参数: const string& strServ			用户信息记录
 * 输出参数: TVector& serv					获得的拆分后的用户信息结构
 * 返 回 值: 无
 * 功能描述: 获取用户信息
 *
 ********************************************************************/
void getServInfo(const string& strServ, TVector& serv);
/************************* getCustInfo() ************************
 *
 * 函数名称: getCustInfo
 * 输入参数: const string& strCust			客户信息记录
 * 输出参数: TVector& cust					获得的拆分后的客户信息结构
 * 返 回 值: 无
 * 功能描述: 获取客户信息
 *
 ********************************************************************/
void getCustInfo(const string& strCust, TVector& cust);
/************************* getAcctInfo() ************************
 *
 * 函数名称: getAcctInfo
 * 输入参数: const string& strAcct			帐户信息记录
 * 输出参数: TVector& acct					获得的拆分后的帐户信息结构
 * 返 回 值: 无
 * 功能描述: 获取账户信息
 *
 ********************************************************************/
void getAcctInfo(const string& strAcct, TVector& acct);

/************************* getServAcctInfo() ************************
 *
 * 函数名称: getServAcctInfo
 * 输入参数: const string& strServAcct		帐务关系信息记录
 * 输出参数: TServAcct* serv_acct			获得的拆分后的帐务关系信息结构
 * 返 回 值: 无
 * 功能描述: 获取帐务关系信息
 *
 ********************************************************************/
void getServAcctInfo(const string& strServAcct, TServAcct* serv_acct);

/************************* getServProdInfo() ************************
 *
 * 函数名称: getServProdInfo
 * 输入参数: const string& strServProd		占用资源信息记录
 * 输出参数: TServProd* serv_prod			获得的拆分后的占用资源信息结构
 * 返 回 值: 无
 * 功能描述: 获取占用资源信息
 *
 ********************************************************************/
void getServProdInfo(const string& strServProd, TServProd* serv_prod);

/************************* preServInfo() ************************
 *
 * 函数名称: preServInfo
 * 输入参数: 无
 * 输出参数: 无
 * 返 回 值: 无
 * 功能描述: 预处理用户资料表
 *
 ********************************************************************/
void preServInfo();
/************************* preCustInfo() ************************
 *
 * 函数名称: preCustInfo
 * 输入参数: 无
 * 输出参数: 无
 * 返 回 值: 无
 * 功能描述: 预处理客户信息表
 *
 ********************************************************************/
void preCustInfo();
/************************* preAcctInfo() ************************
 *
 * 函数名称: preAcctInfo
 * 输入参数: 无
 * 输出参数: 无
 * 返 回 值: 无
 * 功能描述: 预处理帐户信息表
 *
 ********************************************************************/
void preAcctInfo();

/************************* preServAcctInfo() ************************
 *
 * 函数名称: preServAcctInfo
 * 输入参数: 无
 * 输出参数: 无
 * 返 回 值: 无
 * 功能描述: 预处理帐务关系表
 *
 ********************************************************************/
void preServAcctInfo();

/************************* preServProdInfo() ************************
 *
 * 函数名称: preServProdInfo
 * 输入参数: 无
 * 输出参数: 无
 * 返 回 值: 无
 * 功能描述: 预处理占用资源表
 *
 ********************************************************************/
void preServProdInfo();

void writeErrorInfo(const string& strLine, const string& strErrInfo);

// 拆分处理过的帐务关系数据
void splitServAcctInfo(const string& strServAcct, TServAcct1& serv_acct);

// 拆分处理过的占用资源数据
void splitServProdInfo(const string& strServProd, TServProd1& serv_prod);

// 装载帐务关系信息
void loadServAcctInfo();
// 装载帐户信息
void loadAcctInfo();
// 装载客户信息
void loadCustInfo();
// 装载占用资源信息
void loadServProdInfo();
/************************* IsComment() ********************************
 *
 * 函数名称: IsComment
 * 输入参数: const char *strLine	    		配置文件中的行信息
 * 输出参数: 无
 * 返 回 值: 0,不是;1,是
 * 功能描述: 判断配置文件中的信息是否是注释
 *
 ********************************************************************/
int IsComment(const char *strLine);
/************************* GetInfoBySection() *************************
 *
 * 函数名称: GetInfoBySection
 * 输入参数: const string& strFileName	    	配置文件名称
 *			  const string& strSection			配置项名称
 * 输出参数: TMap& mapInfo						配置信息HASH表
 * 返 回 值: 0,成功;非0,不成功
 * 功能描述: 配置信息读取
 *
 ********************************************************************/
int GetInfoBySection(const string& strFileName, const string& strSection, TMap& mapInfo);

// 去掉字符串右边的空格
void rtrim(char *strIn);

// 去掉字符串左边的空格
char* ltrim(char *strIn);

/************************* trim() ***********************************
 *
 * 函数名称: trim
 * 输入参数: char *strIn	    	输入的字符串
 * 输出参数: 无
 * 返 回 值: 去掉空白字符的字符串
 * 功能描述: 去掉空白字符
 *
 ********************************************************************/
char* trim(char *strIn);

/************************* _rlogit() *******************************
 *
 * 函数名称: _rlogit
 * 输入参数: 
 			  int	iErrorId		错误代码
 			  const char *format	日志格式
 			  ...					变参列表
 * 输出参数: 无
 * 返 回 值: 无
 * 功能描述: 将日志信息打印到屏幕或写入文件
 *
 ********************************************************************/
void _rlogit(int iErrorId, const char *format, ...);

void (*rlogit) (int, const char *, ...) = _rlogit;

#endif

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -