| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306 |
- /**************************************************************************************************
- 版本所有(C), 2021-2022, 北京普达迪泰
- ***************************************************************************************************
- 文 件 名:EquipDataPointRelatedManager.cpp
- 版 本 号: 1.00初版
- 作 者: HYF
- 生成日期:2021-12-20
- 最近修改:
- 功能描述: 点关联信息
- 函数列表:
- 修改历史:
- 1.日 期 : 2021-12-20
- 作 者 : HYF
- 修改内容 : 创建文件
- **************************************************************************************************/
- #include "pch.h"
- #include "EquipDataPointRelatedManager.h"
- #include "CppSQLite3.h"
- #include "DBFactory.h"
- #include "EquipDataPointRelated.h"
- EquipDataPointRelatedManager::EquipDataPointRelatedManager()
- {
- }
- EquipDataPointRelatedManager::~EquipDataPointRelatedManager()
- {
- }
- /**************************************************************************************************
- 函 数 名 :QueryAll
- 功能描述 :查询
- 输出参数 :略
- 返 回 值 :CppSQLite3Query
- **************************************************************************************************/
- CppSQLite3Query EquipDataPointRelatedManager::Query()
- {
- try
- {
- CppSQLite3DB* pDB = DBFactory::GetSQLite();
- return pDB->execQuery(_T("SELECT * FROM equip_data_point_related;"));
- }
- catch (CppSQLite3Exception& e)
- {
- LOG::E(e.errorMessage());
- }
- }
- CppSQLite3Query EquipDataPointRelatedManager::Query(DWORD iTaskId)
- {
- try
- {
- CppSQLite3DB* pDB = DBFactory::GetSQLite();
- char szCmd[256];
- sprintf_s(szCmd, "SELECT * FROM equip_data_point_related WHERE task_id=%d;", iTaskId);
- return pDB->execQuery(szCmd);
- }
- catch (CppSQLite3Exception& e)
- {
- LOG::E(e.errorMessage());
- }
- }
- CppSQLite3Query EquipDataPointRelatedManager::Query(DWORD iTaskId, LPCTSTR szEquipCode)
- {
- try
- {
- CppSQLite3DB* pDB = DBFactory::GetSQLite();
- char szCmd[256];
- sprintf_s(szCmd, "SELECT * FROM equip_data_point_related WHERE task_id=%d AND equip_code='%s';", iTaskId, szEquipCode);
- return pDB->execQuery(szCmd);
- }
- catch (CppSQLite3Exception& e)
- {
- LOG::E(e.errorMessage());
- }
- }
- /**************************************************************************************************
- 函 数 名 :Query
- 功能描述 :基于设备编码查询
- 输出参数 :无
- 返 回 值 :CppSQLite3Query
- **************************************************************************************************/
- CppSQLite3Query EquipDataPointRelatedManager::Query(DWORD iTaskId, LPCTSTR szEquipCode, DWORD iItemId, DWORD iSubItemId)
- {
- try
- {
- CppSQLite3DB* pDB = DBFactory::GetSQLite();
- char szCmd[256];
- sprintf_s(szCmd,
- "SELECT * FROM equip_data_point_related WHERE task_id=%d AND equip_code='%s' AND item_id=%d AND subitem_id=%d;",
- iTaskId,
- szEquipCode,
- iItemId,
- iSubItemId);
- return pDB->execQuery(szCmd);
- }
- catch (CppSQLite3Exception& e)
- {
- LOG::E(e.errorMessage());
- }
- }
- /**************************************************************************************************
- 函 数 名 :Add
- 功能描述 :增加
- 输入参数 :略
- 输出参数 :略
- 返 回 值 :TRUE 成功;FALSE 失败
- **************************************************************************************************/
- BOOL EquipDataPointRelatedManager::Add(const EquipDataPointRelated& data)
- {
- DWORD iTaskId = data.GetTaskId();
- CString szEquipCode = data.GetEquipCode();
- DWORD iItemId = data.GetItemId();
- DWORD iItemType = data.GetItemType();
- DWORD iSubItemId = data.GetSubItemId();
- DWORD iPointSubItemId = data.GetPointSubItemId();
- DOUBLE fDX = data.GetDX();
- DOUBLE fDY = data.GetDY();
- DOUBLE fDZ = data.GetDZ();
- DOUBLE fTotal = data.GetTotal();
- DOUBLE fOffset = data.GetOffset();
- DOUBLE fOnPlane = data.GetOnPlane();
- DOUBLE fOutPlane = data.GetOutPlane();
- try
- {
- CppSQLite3DB* pDB = DBFactory::GetSQLite();
- CppSQLite3Buffer bufSQL;
- bufSQL.format("INSERT INTO equip_data_point_related "
- " ( "
- " task_id, "
- " equip_code, "
- " item_id, "
- " item_type, "
- " subitem_id, "
- " point_subitem_id, "
- " dx, "
- " dy, "
- " dz, "
- " total, "
- " offset, "
- " on_plane, "
- " out_plane "
- " ) "
- " VALUES (%d, %Q, %d, %d, %d, %d, %.3f, %.3f, %.3f, %.3f, %.3f, %.3f, %.3f); ",
- iTaskId,
- szEquipCode,
- iItemId,
- iItemType,
- iSubItemId,
- iPointSubItemId,
- fDX,
- fDY,
- fDZ,
- fTotal,
- fOffset,
- fOnPlane,
- fOutPlane
- );
- pDB->execDML("begin transaction;");
- pDB->execDML(bufSQL);
- pDB->execDML("commit transaction;");
- bufSQL.clear();
- }
- catch (CppSQLite3Exception& e)
- {
- LOG::E(e.errorMessage());
- return FALSE;
- }
- return TRUE;
- }
- /**************************************************************************************************
- 函 数 名 :Delete
- 功能描述 :删除
- 输入参数 :略
- 输出参数 :略
- 返 回 值 :TRUE 成功;FALSE 失败
- **************************************************************************************************/
- BOOL EquipDataPointRelatedManager::Delete(DWORD iTaskId)
- {
- try
- {
- CppSQLite3DB* pDB = DBFactory::GetSQLite();
- CppSQLite3Buffer bufSQL;
- bufSQL.format("DELETE FROM equip_data_point_related WHERE task_id=%d;", iTaskId);
- pDB->execDML("begin transaction;");
- pDB->execDML(bufSQL);
- pDB->execDML("commit transaction;");
- bufSQL.clear();
- }
- catch (CppSQLite3Exception& e)
- {
- LOG::E(e.errorMessage());
- return FALSE;
- }
- return TRUE;
- }
- BOOL EquipDataPointRelatedManager::Delete(DWORD iTaskId, LPCTSTR szEquipCode)
- {
- try
- {
- CppSQLite3DB* pDB = DBFactory::GetSQLite();
- CppSQLite3Buffer bufSQL;
- bufSQL.format("DELETE FROM equip_data_point_related WHERE task_id=%d AND equip_code=%Q;", iTaskId, szEquipCode);
- pDB->execDML("begin transaction;");
- pDB->execDML(bufSQL);
- pDB->execDML("commit transaction;");
- bufSQL.clear();
- }
- catch (CppSQLite3Exception& e)
- {
- LOG::E(e.errorMessage());
- return FALSE;
- }
- return TRUE;
- }
- BOOL EquipDataPointRelatedManager::Delete(DWORD iTaskId, LPCTSTR szEquipCode, DWORD iItemId)
- {
- try
- {
- CppSQLite3DB* pDB = DBFactory::GetSQLite();
- CppSQLite3Buffer bufSQL;
- bufSQL.format("DELETE FROM equip_data_point_related WHERE task_id=%d AND equip_code=%Q AND item_id=%d;", iTaskId, szEquipCode, iItemId);
- pDB->execDML("begin transaction;");
- pDB->execDML(bufSQL);
- pDB->execDML("commit transaction;");
- bufSQL.clear();
- }
- catch (CppSQLite3Exception& e)
- {
- LOG::E(e.errorMessage());
- return FALSE;
- }
- return TRUE;
- }
- BOOL EquipDataPointRelatedManager::Delete(DWORD iTaskId, LPCTSTR szEquipCode, DWORD iItemId, DWORD iSubitemId)
- {
- try
- {
- CppSQLite3DB* pDB = DBFactory::GetSQLite();
- CppSQLite3Buffer bufSQL;
- bufSQL.format("DELETE FROM equip_data_point_related WHERE task_id=%d AND equip_code=%Q AND item_id=%d AND subitem_id=%d;", iTaskId, szEquipCode, iItemId, iSubitemId);
- pDB->execDML("begin transaction;");
- pDB->execDML(bufSQL);
- pDB->execDML("commit transaction;");
- bufSQL.clear();
- }
- catch (CppSQLite3Exception& e)
- {
- LOG::E(e.errorMessage());
- return FALSE;
- }
- return TRUE;
- }
- /**************************************************************************************************
- 函 数 名 :ClearAll
- 功能描述 :清除所有数据
- 输入参数 :略
- 输出参数 :略
- 返 回 值 :TRUE 成功;FALSE 失败
- **************************************************************************************************/
- BOOL EquipDataPointRelatedManager::ClearAll()
- {
- try
- {
- CppSQLite3DB* pDB = DBFactory::GetSQLite();
- CppSQLite3Buffer bufSQL;
- bufSQL.format("DELETE FROM equip_data_point_related;");//删除语句
- pDB->execDML("begin transaction;");
- pDB->execDML(bufSQL);
- pDB->execDML("commit transaction;");
- bufSQL.clear();
- }
- catch (CppSQLite3Exception& e)
- {
- LOG::E(e.errorMessage());
- return FALSE;
- }
- return TRUE;
- }
|