#ifndef DATAACCESS_H_ #define DATAACCESS_H_ /********************************************************************* * * 文 件: DataAccess.h 电文数据处理接口 * * 版权所有: Shanghai Baosight Software Co., Ltd. * * 概述 :写原始数据接口 * :写轧辊数据接口 * : * * 版本历史 * 1.0 2010-05-06 echo_li * %USER% *********************************************************************/ #include #include #include #include #include #include #include namespace baosight { typedef vector VCTVALUE; /* [n]:value */ typedef map< string, VCTVALUE> MAPCOLUMN; /* [first]:columnname, [second]:value vector */ typedef map< string, MAPCOLUMN > MAPTABLE; /* [first]:tablename, [second]:column map */ typedef map< string, VCTVALUE> MAPSQL; /* [first]:columnname, [second]:sql vector */ /********************************************************************* * 类 名: DataAccess * 版权所有: Shanghai Baosight Software Co., Ltd. * 类 职 责:原始数据和轧辊数据写入时的逻辑处理 * : * : * 版本历史 * 1.0 2010-09-02 echo_li 增加注释 * *********************************************************************/ class DataAccess { public: /********************************************************************** * 概述: 将原始数据电文写入以MU_CODE,source为主键的表中,依赖InsertMaterial函数 * 函数名: WritePrimaryData * 返回值: short * 参数列表: 参数类型 取值范围 描述 * tele: AutoTele& * * 版本历史 * 1.0 2010-09-02 echo_li 增加注释 * **********************************************************************/ //short WritePrimarySingle(); short InsertPrimarySingle(); short UpdatePrimarySingle(); /********************************************************************** * 概述: 将电文写入以MU_CODE为主键的表中(单记录),依赖InsertMaterial函数 * 函数名: WriteSingleRecordByPH * 函数名: WriteSingleRecordByLO * 函数名: WriteSingleRecordByOR * 返回值: short * 参数列表: 参数类型 取值范围 描述 * tele: AutoTele& * * 版本历史 * 1.0 2010-09-02 echo_li 增加注释 * **********************************************************************/ //short WriteSingleRecordByPH( const string& table); //short WriteSingleRecordByLO( const string& table); //short WriteSingleRecordByOR( const string& table); short InsertSingleRecordByPH( const string& table); short InsertSingleRecordByLO( const string& table); short InsertSingleRecordByOR( const string& table); short UpdateSingleRecordByPH( const string& table); short UpdateSingleRecordByLO( const string& table); short UpdateSingleRecordByOR( const string& table); /********************************************************************** * 概述: 将电文写入普通表中(单记录) * 函数名: InsertSingleRecord * 返回值: short * 参数列表: 参数类型 取值范围 描述 * table: const string& * pkcolumn: const vector& 指定数据库表中的主键字段名 * 版本历史 * 1.0 2010-09-02 echo_li 增加注释 * **********************************************************************/ short InsertSingleRecord( const string& table); short InsertSingleRecord( const string& faketable, const string& table); short UpdateSingleRecord( const string& table, const vector& pkcolumn); short UpdateSingleRecord( const string& faketable, const vector& pkcolumn, const string& table); /********************************************************************** * 概述: 将电文写入以MU_CODE为主键的表中(多记录),依赖InsertMaterial函数 * 函数名: WriteMultiRecordsByPH * 函数名: WriteMultiRecordsByLO * 函数名: WriteMultiRecordsByOR * 返回值: short * 参数列表: 参数类型 取值范围 描述 * table: const string& * * 版本历史 * 1.0 2010-09-02 echo_li 增加注释 * **********************************************************************/ short WriteMultiRecordsByPH( const string& table, unsigned int count = 0, unsigned int index = 0); short WriteMultiRecordsByLO( const string& table, unsigned int count = 0, unsigned int index = 0); short WriteMultiRecordsByOR( const string& table, unsigned int count = 0, unsigned int index = 0); //short WriteMultiRecords( const string& table, const string& pkcoloumn="", const string& pkvalue="", int count = 0); /********************************************************************** * 概述: 使用Update方式将电文根据主键写入数据库 * 函数名: WriteTableByUpdate * 返回值: short * 参数列表: 参数类型 取值范围 描述 * tele: AutoTele& * table: const string& * where: const string& 记录更新条件 * 版本历史 * 1.0 2010-09-02 echo_li 增加注释 * **********************************************************************/ short WriteTableByUpdate( AutoTele& tele, const string& table, const string& where); /********************************************************************** * 概述: 在MU和MUR表中插入新卷记录并返回记录值 * 函数名: InsertMaterialInfo * 返回值: short * 参数列表: 参数类型 取值范围 描述 * coilid: char * 需要生成MU_CODE的钢卷卷号 * phMu: MU_CODE& 返回生成的PH MU_CODE * loMu: MU_CODE& 返回生成的LO MU_CODE * orMu: MU_CODE& 返回生成的OR MU_CODE * * 版本历史 * 1.0 2010-09-02 echo_li 增加注释 * **********************************************************************/ short InsertMaterialInfo( const string& coilid, MU_CODE &phMu, MU_CODE &loMu, MU_CODE &orMu); /********************************************************************** * 概述: 在MU和MUR表中插入新卷记录 * 函数名: InsertMaterialInfo * 返回值: short * 参数列表: 参数类型 取值范围 描述 * coilid: char * 需要生成MU_CODE的钢卷卷号 * * 版本历史 * 1.0 2010-09-02 echo_li 增加注释 * **********************************************************************/ short InsertMaterialInfo( const string& coilid); /********************************************************************** * 概述: 分析AutoTele并解析成数据表和字段值 * 函数名: InsertMaterialInfo * 返回值: short * 参数列表: 参数类型 取值范围 描述 * tele: AutoTele& 需要分析的AutoTele对象 * * 版本历史 * 1.0 2010-09-02 echo_li 增加注释 * **********************************************************************/ void Analyze( AutoTele& tele); void Analyze( BinaryTele& tele); void PrintSQLS(); public: DataAccess( ); ~DataAccess(); private: short InsertPDI( ); short UpdatePDI( ); void GetInsertSQL( const MAPTABLE& mapdata, MAPSQL& columnsql, MAPSQL& valuesql); void GetUpdateSQL( const MAPTABLE& mapdata, MAPSQL& valuesql); short InsertPhysicals( const string& table, const string& colPart, const string& valpart); short InsertLogicals( const string& table, const string& colPart, const string& valpart); short InsertOrders( const string& table, const string& colPart, const string& valpart); short UpdatePhysicals( const string& table, const string& valpart); short UpdateLogicals( const string& table, const string& valpart); short UpdateOrders( const string& table, const string& valpart); void GenItemBySingle( const TeleItem& item, MAPCOLUMN& maptable, unsigned int col); void GenItemByGroup( const TeleItem& item, MAPCOLUMN& maptable, unsigned int col); void GetItemData( AutoTele& arep); void GetItemData( BinaryTele& arep); string ValueToString( const TeleItem& item) const; short InsertDefectPH( const string& table, const VCTVALUE& colPart, const VCTVALUE& valpart); short UpdateDefectPH( const string& table, const VCTVALUE& valpart); // rmbai 2012-03-18 void SetItem( const TeleItem& eitem, string tabName, string cols); int FindRepeatGroupItemCount(AutoTele& arep,int index, string tabName); int SetRepeatItem(AutoTele& arep,int startindex,int reaptCount,int groupItemCount,string tabName); //void GetUpdateSQL( AutoTele& arep, MAPVCTSTRING& valpart); //void GetInsertSQL( AutoTele& arep, MAPVCTSTRING& colpart, MAPVCTSTRING& valpart); /********************************************************************** * 概述: 写MES和ME表 * 函数名: InsertMaterialInfo * 返回值: short * 参数列表: 参数类型 取值范围 描述 * coilInfo: S_COILINFO & * * 版本历史 * 1.0 2010-09-02 echo_li 增加注释 * **********************************************************************/ //short InsertMaterialInfo(S_COILINFO& coilInfo); /********************************************************************** * 概述: 获取需要写数据的表的集合 * 函数名: GetTableList * 返回值: short * 参数列表: 参数类型 取值范围 描述 * arep: S_TeleItem * * arepmax: int * * 版本历史 * 1.0 2010-09-02 echo_li 增加注释 * **********************************************************************/ //short GetTableList(S_TeleItem* arep, int arepmax); /********************************************************************** * 概述: 写普通表 * 函数名: InsertTables * 返回值: short * 参数列表: 参数类型 取值范围 描述 * eventNo: int * arep: S_TeleItem * * arepmax: int * tabcount: int * * 版本历史 * 1.0 2010-09-02 echo_li 增加注释 * **********************************************************************/ //short InsertTables(int eventNo, S_TeleItem* arep, int arepmax, int tabcount); /********************************************************************** * 概述: 写PrimaryLogicals表 * 函数名: InsertLogicals * 返回值: short * 参数列表: 参数类型 取值范围 描述 * eventNo: int * arep: S_TeleItem * * arepmax: int * * 版本历史 * 1.0 2010-09-02 echo_li 增加注释 * **********************************************************************/ //short InsertLogicals(int eventNo, S_TeleItem* arep, int arepmax); /********************************************************************** * 概述: 写PrimaryOrder表 * 函数名: InsertOrders * 返回值: short * 参数列表: 参数类型 取值范围 描述 * eventNo: int * arep: S_TeleItem * * arepmax: int * * 版本历史 * 1.0 2010-09-02 echo_li 增加注释 * **********************************************************************/ //short InsertOrders(int eventNo, S_TeleItem* arep, int arepmax); /********************************************************************** * 概述: 写EntryDefect表 * 函数名: InsertDefect * 返回值: short * 参数列表: 参数类型 取值范围 描述 * eventNo: int * arep: S_TeleItem * * arepmax: int * * 版本历史 * 1.0 2010-09-02 echo_li 增加注释 * **********************************************************************/ //short InsertDefect(int eventNo, S_TeleItem* arep, int arepmax); /********************************************************************** * * * 概述: delete data by materialInfo * 函数名: DeleteOneTable * 返回值: short * 参数列表: 参数类型 取值范围 描述 * eventNo: int * arep: S_TeleItem * * arepmax: int 1.0 2011-07-19 RMBAI 增加注释 * * ***********************************************************************/ //short DeleteOneTable(int eventNo,std::string tabelname); /********************************************************************** * 概述: 根据eventNo和naTabName获取KeyValue,再和stmtINS,stmtVAL组织成 * 完整的SQL语句,通过执行SQL语句插入数据 * 函数名: InsertOneTable * 返回值: short * 参数列表: 参数类型 取值范围 描述 * eventNo: int * naTabName: string * * 版本历史 * 1.0 2010-09-02 echo_li 增加注释 * **********************************************************************/ //short InsertOneTable(int eventNo, string naTabName); /********************************************************************** * 概述: 拼接SQL语句 * 函数名: GetInsertSQL * 返回值: void * 参数列表: 参数类型 取值范围 描述 * arep: S_TeleItem * * arepmax: int * tableName: string * * 版本历史 * 1.0 2010-09-02 echo_li 增加注释 * **********************************************************************/ //void GetInsertSQL(S_TeleItem* arep, int arepmax,string tableName); /********************************************************************** * 概述: 拼接SQL语句 * 函数名: GetUpdateSQL * 返回值: void * 参数列表: 参数类型 取值范围 描述 * arep: S_TeleItem * * arepmax: int * tableName: string * * 版本历史 * 1.0 2010-09-02 echo_li 增加注释 * **********************************************************************/ //void GetUpdateSQL(S_TeleItem* arep, int arepmax,string tableName); /********************************************************************** * 概述: 写普通表 * 函数名: UpdateTables * 返回值: short * 参数列表: 参数类型 取值范围 描述 * eventNo: int * arep: S_TeleItem * * arepmax: int * tabcount: int * * 版本历史 * 1.0 2010-09-02 echo_li 增加注释 * **********************************************************************/ //short UpdateTables(int eventNo, S_TeleItem* arep, int arepmax, int tabcount); /********************************************************************** * 概述: 写PrimaryLogicals表 * 函数名: UpdateLogicals * 返回值: short * 参数列表: 参数类型 取值范围 描述 * eventNo: int * arep: S_TeleItem * * arepmax: int * * 版本历史 * 1.0 2010-09-02 echo_li 增加注释 * **********************************************************************/ //short UpdateLogicals(int eventNo, S_TeleItem* arep, int arepmax); /********************************************************************** * 概述: 写PrimaryOrder表 * 函数名: UpdateOrders * 返回值: short * 参数列表: 参数类型 取值范围 描述 * eventNo: int * arep: S_TeleItem * * arepmax: int * * 版本历史 * 1.0 2010-09-02 echo_li 增加注释 * **********************************************************************/ //short UpdateOrders(int eventNo, S_TeleItem* arep, int arepmax); /********************************************************************** * 概述: 写EntryDefect表 * 函数名: UpdateDefect * 返回值: short * 参数列表: 参数类型 取值范围 描述 * eventNo: int * arep: S_TeleItem * * arepmax: int * * 版本历史 * 1.0 2010-09-02 echo_li 增加注释 * **********************************************************************/ //short UpdateDefect(int eventNo, S_TeleItem* arep, int arepmax); /********************************************************************** * 概述: insertOneTable 根据eventNo和naTabName获取KeyValue, * 再和stmtINS,stmtVAL组织成完整的SQL语句,通过执行SQL语句插入数据 * 函数名: UpdateOneTable * 返回值: short * 参数列表: 参数类型 取值范围 描述 * eventNo: int * naTabName: string * * 版本历史 * 1.0 2010-09-02 echo_li 增加注释 * **********************************************************************/ //short UpdateOneTable(int eventNo, string naTabName); /********************************************************************** * 概述: 剪切设定计算 * 函数名: CalculateDivLen * 返回值: short * 参数列表: 参数类型 取值范围 描述 * muCode: const MU_CODE & * arep: S_TeleItem * * arepmax: int * * 版本历史 * 1.0 2010-09-02 echo_li 增加注释 * **********************************************************************/ //short CalculateDivLen(const MU_CODE& muCode, S_TeleItem* arep, int arepmax); private: Schedule* mp_scheduleDao; MAT_STRUCTURE m_material; MaterialInfo m_matInfo; //vector m_tabList; int m_writemode; /* CN_RETURAL_INSERT or CN_RETURAL_UPDATE */ int tabCount; int m_stmLen; MAPTABLE m_teleItem; MAPSQL m_insColPart; MAPSQL m_insValPart; MAPSQL m_updatePart; S_INS_UPD_PARAMS insUpdParams; //S_DIVLEN m_divLen; private: }; } #endif