850 lines
20 KiB
C++
850 lines
20 KiB
C++
#include "stdafx.h"
|
|
#include "KTMtoTool.h"
|
|
#include "KTModelLayoutXData.h"
|
|
#include "KTCadUtility.h"
|
|
#include "AecDbEwPipe.h"
|
|
#include "AecDbEwfitting.h"
|
|
#include "AecDbEwEquipment.h"
|
|
#include "CoreTools.h"
|
|
#include "AecPipeSupport.h"
|
|
|
|
#ifdef _DEBUG
|
|
#undef THIS_FILE
|
|
static char THIS_FILE[]=__FILE__;
|
|
#define new DEBUG_NEW
|
|
#endif
|
|
|
|
#define DXF_PIPE_FITTING_EQU_ONLAY _T("AEC_EWPIPE,AEC_DBEWFIT,AEC_DBWEQUIPMENT")
|
|
|
|
KTMtoTool::KTMtoTool()
|
|
{
|
|
m_pDbSrv = NULL;
|
|
m_sDrawNo = _T("ZHH_001");
|
|
}
|
|
|
|
KTMtoTool::~KTMtoTool()
|
|
{
|
|
|
|
}
|
|
|
|
int KTMtoTool::DoMto()
|
|
{
|
|
EmptyTempTbl();
|
|
|
|
TCHAR szRes[132];//
|
|
int nRes = acedGetString(FALSE,_T("\n请输入本次报料的图纸图号<取消>:"),szRes);
|
|
if (nRes != RTNORM)
|
|
{
|
|
return 0;
|
|
}
|
|
m_sDrawNo = szRes;
|
|
|
|
//获取初始化数据
|
|
KTModelLayoutXData::ReSet(m_xDataMap);
|
|
KTModelLayoutXData::ReadModelXData(KT_PIPEINIT,m_xDataMap);
|
|
|
|
CString sProj;
|
|
m_xDataMap.GetAt(DOC_PROJECT,sProj);
|
|
if (sProj.IsEmpty())
|
|
{
|
|
acutPrintf(_T("\n没有配置项目无法报料,请初始化配置!"));
|
|
return 0;
|
|
}
|
|
|
|
ads_name ss;
|
|
struct resbuf* pRb = NULL;
|
|
pRb = acutBuildList(RTDXF0, DXF_PIPE_FITTING_EQU_ONLAY,NULL);
|
|
|
|
nRes = RTNONE;
|
|
AcDbObjectIdArray arIDs;
|
|
ads_name ent;
|
|
AcDbObjectId id;
|
|
int nFount = -1;
|
|
|
|
while(TRUE)
|
|
{
|
|
nRes = CKTCadUtility::SelectEntities(_T("\n请选择报料实体:"),ss,pRb);
|
|
if (nRes == RTNONE )
|
|
{
|
|
break;
|
|
}
|
|
|
|
if (nRes == RTCAN)
|
|
{
|
|
return 0;
|
|
}
|
|
|
|
if (nRes == RTNORM)
|
|
{
|
|
Adesk::Int32 lLen = 0l;
|
|
acedSSLength(ss,&lLen);
|
|
for (int i = 0;i < lLen;i++)
|
|
{
|
|
acedSSName(ss,i,ent);
|
|
if ( Acad::eOk == acdbGetObjectId(id,ent))
|
|
{
|
|
if (!arIDs.find(id,nFount))
|
|
{
|
|
arIDs.append(id);
|
|
}
|
|
}
|
|
}
|
|
acedSSFree(ss);
|
|
}
|
|
else
|
|
{
|
|
break;
|
|
}
|
|
}
|
|
acutRelRb(pRb);
|
|
return ImpMto(arIDs);
|
|
}
|
|
|
|
int KTMtoTool::ImpMto(const AcDbObjectIdArray& arIDs)
|
|
{
|
|
int nSize = arIDs.length();
|
|
AcDbObjectId id;
|
|
AcDbEntity* pEnt = NULL;
|
|
|
|
CMapStringToString mapKey2Len;
|
|
CString sFlag=_T("");
|
|
AecDbObjXDataMap *pXDataMap = NULL;
|
|
|
|
for (int i = 0;i < nSize;i++)
|
|
{
|
|
if (Acad::eOk == acdbOpenAcDbEntity(pEnt,arIDs.at(i),AcDb::kForRead))
|
|
{
|
|
AecDbEwPipe *pPipe = AecDbEwPipe::cast(pEnt);
|
|
if (pPipe != NULL)
|
|
{
|
|
pXDataMap = pPipe->GetSpecialtyData(AcDb::kForRead);
|
|
WPipe::PipeParam * pParam = pPipe->GetPipeParam();
|
|
double dLen = pPipe->GetLength();
|
|
|
|
AcArray<AecInterface> arInfs;
|
|
pPipe->GetInterface(arInfs);
|
|
|
|
ImpPipeMto(arInfs,*pParam,*pXDataMap,dLen, mapKey2Len);
|
|
delete pParam;
|
|
}
|
|
|
|
AecDbEwFitting* pFitting = AecDbEwFitting::cast(pEnt);
|
|
if (pFitting != NULL)
|
|
{
|
|
AcArray<AecInterface> arInfs;
|
|
pFitting->GetInterface(arInfs);
|
|
pXDataMap = pFitting->GetSpecialtyData(AcDb::kForRead);
|
|
ImpFitMto(arInfs,*pXDataMap, mapKey2Len);
|
|
}
|
|
|
|
AecDbEwEquipment *pEqu = AecDbEwEquipment::cast(pEnt);
|
|
if (pEqu != NULL)
|
|
{
|
|
AcArray<AecInterface> arInfs;
|
|
pEqu->GetInterface(arInfs);
|
|
pXDataMap = pEqu->GetSpecialtyData(AcDb::kForRead);
|
|
ImpEquMto(arInfs,*pXDataMap, mapKey2Len);
|
|
}
|
|
pEnt->close();
|
|
}
|
|
}
|
|
|
|
//写表
|
|
CString sKey,sLen;
|
|
POSITION ps = NULL;
|
|
for (ps = mapKey2Len.GetStartPosition();ps != NULL;)
|
|
{
|
|
mapKey2Len.GetNextAssoc(ps,sKey,sLen);
|
|
sKey.Replace(_T("[$]"),_T("[数量]"));
|
|
sKey.Replace(_T("[~]"),sLen);
|
|
if (m_pDbSrv != NULL)
|
|
m_pDbSrv->ExecuteSQL(sKey);
|
|
}
|
|
|
|
//写list 表
|
|
CString sPipeNo,sSQL,sProj;
|
|
m_xDataMap.GetAt(DOC_PROJECT,sProj);
|
|
for (ps = m_lstPipeLineNos.GetHeadPosition();ps != NULL;)
|
|
{
|
|
sPipeNo = m_lstPipeLineNos.GetNext(ps);
|
|
if (!sPipeNo.IsEmpty())
|
|
{
|
|
sSQL.Format(_T("insert into AecLineList ([项目名称],[管线名称]) values ('%s','%s')"),sProj,sPipeNo);
|
|
m_pDbSrv->ExecuteSQL(sSQL);
|
|
}
|
|
}
|
|
if (m_lstPipeLineNos.GetCount() > 0)
|
|
{
|
|
int nRes = AfxMessageBox(_T("材料统计完毕,是否执行BOM程序查看统计结果?"),MB_YESNO);
|
|
if (nRes == IDYES)
|
|
{
|
|
CString sMtoexe,sMtoPath;
|
|
sMtoPath = FilePath::GetSysDir();
|
|
sMtoexe = sMtoPath + _T("\\KTBOM.exe");
|
|
|
|
::ShellExecute(acedGetAcadFrame()->m_hWnd,_T("open"),sMtoexe,NULL,sMtoPath,SW_SHOWNORMAL);
|
|
}
|
|
}
|
|
return 0;
|
|
}
|
|
|
|
int KTMtoTool::EmptyTempTbl()
|
|
{
|
|
CString sSQL;
|
|
sSQL = _T("delete from AecMTOPipe");
|
|
m_pDbSrv->ExecuteSQL(sSQL);
|
|
|
|
sSQL = _T("delete from AecMTOFit");
|
|
m_pDbSrv->ExecuteSQL(sSQL);
|
|
|
|
sSQL = _T("delete from AecMTOValve");
|
|
m_pDbSrv->ExecuteSQL(sSQL);
|
|
|
|
sSQL = _T("delete from AecMTOBolt");
|
|
m_pDbSrv->ExecuteSQL(sSQL);
|
|
|
|
sSQL = _T("delete from AecMTOGasket");
|
|
m_pDbSrv->ExecuteSQL(sSQL);
|
|
|
|
sSQL = _T("delete from AecMTOFlange");
|
|
m_pDbSrv->ExecuteSQL(sSQL);
|
|
|
|
sSQL = _T("delete from AecMTOInsulation");
|
|
m_pDbSrv->ExecuteSQL(sSQL);
|
|
|
|
sSQL = _T("delete from AecMTOTracing");
|
|
m_pDbSrv->ExecuteSQL(sSQL);
|
|
|
|
sSQL = _T("delete from AecLineList");
|
|
m_pDbSrv->ExecuteSQL(sSQL);
|
|
|
|
return 0;
|
|
}
|
|
|
|
static void ParsalToArray(CString& sMtoAll,CStringArray& arValues)
|
|
{
|
|
int nIndex = -1;
|
|
CString sTemp = sMtoAll,sText;
|
|
|
|
while(TRUE)
|
|
{
|
|
nIndex = sTemp.Find(_T("^"),0);
|
|
if (nIndex != -1)
|
|
{
|
|
arValues.Add(sTemp.Mid(0,nIndex));
|
|
sText = sTemp.Mid(nIndex + 1,sTemp.GetLength() - nIndex - 1);
|
|
sTemp = sText;
|
|
}
|
|
else
|
|
{
|
|
if (!sTemp.IsEmpty())
|
|
{
|
|
arValues.Add(sTemp);
|
|
}
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
|
|
//项目名称 管线名称 等级名称 类别 类型
|
|
//KT-3 P-2000 1.6A1 管道 无缝钢管
|
|
|
|
//公称直径 材质 表号 标准号 外径 壁厚 外径系列
|
|
//20 20号钢/Q235B Sch40 GB 9948 27 2.9 A
|
|
|
|
//描述 数量 图纸号
|
|
//无缝钢管,20号钢/Q235B,GB 9948,Sch40,A 100 A-2
|
|
|
|
int KTMtoTool::ImpPipeMto(AcArray<AecInterface> &arInfs,const KPipe::PipeParam& param1, KTObjXDataMap &objXData,double dLen,CMapStringToString& mapKey2Len)
|
|
{
|
|
CString sSQL;
|
|
|
|
CString sProj,sPipeNo,sLevel,sType,sDescr;
|
|
m_xDataMap.GetAt(DOC_PROJECT,sProj);
|
|
sPipeNo = param1.szPipeno;
|
|
sLevel = param1.szLevel;
|
|
sDescr = param1.szDescr;
|
|
|
|
CString sMtoAll = param1.szMtoInfo;
|
|
|
|
CStringArray arValues;
|
|
ParsalToArray(sMtoAll,arValues);
|
|
|
|
//1.管道
|
|
if (arValues.GetSize() >= 11)
|
|
{
|
|
sSQL.Format(_T("insert into AecMTOPipe ([项目名称],[等级名称],[类别],[类型],")
|
|
_T("[公称直径],[材质],[表号],[标准号],[外径],[壁厚],[外径系列],[描述],[管线名称],[$],[图纸号])")
|
|
_T(" values ('%s','%s','%s','%s',%d,'%s','%s','%s',%g,%g,'%s','%s','%s',%s,'%s')"),
|
|
sProj,sLevel,arValues.GetAt(2),arValues.GetAt(3),
|
|
(int)param1.m_dDN,arValues.GetAt(5),arValues.GetAt(6),
|
|
arValues.GetAt(7),_ttof(arValues.GetAt(8)),_ttof(arValues.GetAt(9)),
|
|
arValues.GetAt(10),sDescr,sPipeNo,_T("[~]"),m_sDrawNo);
|
|
|
|
if (m_lstPipeLineNos.Find(sPipeNo) == NULL)
|
|
{
|
|
m_lstPipeLineNos.AddTail(sPipeNo);
|
|
}
|
|
|
|
CString sVal;
|
|
if (mapKey2Len.Lookup(sSQL,sVal))
|
|
{
|
|
dLen += _ttof(sVal);
|
|
sVal.Format(_T("%d"),(int)dLen);
|
|
mapKey2Len.SetAt(sSQL,sVal);
|
|
}
|
|
else
|
|
{
|
|
sVal.Format(_T("%d"),(int)dLen);
|
|
mapKey2Len.SetAt(sSQL,sVal);
|
|
}
|
|
}
|
|
|
|
//1.保温
|
|
if (param1.m_nInsAndHead == 1 ||
|
|
param1.m_nInsAndHead == 2)//保温
|
|
{
|
|
// 项目名称
|
|
// 管线名称
|
|
// 等级名称
|
|
// 公称直径
|
|
// 外径
|
|
// 壁厚
|
|
// 保温规格
|
|
// 保温材料
|
|
// 保温厚度
|
|
// 数量
|
|
// 图纸号
|
|
|
|
sSQL.Format(_T("insert into AecMTOInsulation ( [项目名称],[管线名称],[等级名称],[公称直径],")
|
|
_T("[外径],[壁厚],[保温规格],[保温材料],[保温厚度],[$],[图纸号])")
|
|
_T(" values ('%s','%s','%s',%d,%g,%g,'%s','%s',%g,%s,'%s')"),
|
|
sProj,sPipeNo,sLevel,(int)param1.m_dDN,
|
|
_ttof(arValues.GetAt(8)),_ttof(arValues.GetAt(9)),
|
|
param1.szInsSpec,
|
|
param1.szInsMateral,param1.m_dInsThk,_T("[~]"),m_sDrawNo);
|
|
|
|
if (m_lstPipeLineNos.Find(sPipeNo) == NULL)
|
|
{
|
|
m_lstPipeLineNos.AddTail(sPipeNo);
|
|
}
|
|
|
|
CString sVal;
|
|
if (mapKey2Len.Lookup(sSQL,sVal))
|
|
{
|
|
dLen += _ttof(sVal);
|
|
sVal.Format(_T("%d"),(int)dLen);
|
|
mapKey2Len.SetAt(sSQL,sVal);
|
|
}
|
|
else
|
|
{
|
|
sVal.Format(_T("%d"),(int)dLen);
|
|
mapKey2Len.SetAt(sSQL,sVal);
|
|
}
|
|
|
|
if(param1.m_nInsAndHead == 2) //伴热
|
|
{
|
|
sMtoAll = param1.szTraMtoInfo;
|
|
arValues.RemoveAll();
|
|
ParsalToArray(sMtoAll,arValues);
|
|
|
|
// 管线名称
|
|
|
|
// 项目名称 0
|
|
// 等级名称 1
|
|
// 类别 2
|
|
// 类型 3
|
|
// 公称直径 4
|
|
// 材质 5
|
|
// 表号 6
|
|
// 标准号 7
|
|
// 外径 8
|
|
// 壁厚 9
|
|
// 外径系列 10
|
|
|
|
// 描述
|
|
// 数量
|
|
// 图纸号
|
|
if (arValues.GetSize() >= 11)
|
|
{
|
|
CString sOD = arValues.GetAt(8);
|
|
sOD.TrimLeft();
|
|
CString sTH = arValues.GetAt(9);
|
|
sTH.TrimLeft();
|
|
if (sOD.IsEmpty()) sOD = _T("0");
|
|
if (sTH.IsEmpty()) sTH = _T("0");
|
|
sSQL.Format(_T("insert into AecMTOTracing ( [项目名称],[管线名称],[等级名称],[类别],[类型],")
|
|
_T("[公称直径],[材质],[表号],[标准号],[外径],[壁厚],[外径系列],[描述],[$],[图纸号])")
|
|
_T(" values ('%s','%s','%s','%s','%s',%s,'%s','%s','%s',%s,%s,'%s','%s',%s,'%s')"),
|
|
sProj,sPipeNo,sLevel,_T("管道"),arValues.GetAt(3),
|
|
arValues.GetAt(4),arValues.GetAt(5),arValues.GetAt(6),
|
|
arValues.GetAt(7),sOD,sTH,
|
|
arValues.GetAt(10),param1.szTraDescr,_T("[~]"),m_sDrawNo);
|
|
|
|
if (m_lstPipeLineNos.Find(sPipeNo) == NULL)
|
|
{
|
|
m_lstPipeLineNos.AddTail(sPipeNo);
|
|
}
|
|
|
|
CString sVal;
|
|
if (mapKey2Len.Lookup(sSQL,sVal))
|
|
{
|
|
dLen += _ttof(sVal);
|
|
sVal.Format(_T("%d"),(int)dLen);
|
|
mapKey2Len.SetAt(sSQL,sVal);
|
|
}
|
|
else
|
|
{
|
|
sVal.Format(_T("%d"),(int)dLen);
|
|
mapKey2Len.SetAt(sSQL,sVal);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
//法兰管
|
|
int nConnectType = 0;//0 焊接 1: 承插 2 螺纹 3 法兰管 4 卡箍 5 沟槽
|
|
if (param1.m_nConnectType == 3 || param1.m_nConnectType == 5)//有法兰
|
|
{
|
|
ImpFitMto(arInfs, objXData, mapKey2Len);
|
|
}
|
|
|
|
return 0;
|
|
}
|
|
|
|
//项目名称 管线名称 等级名称 类别 类型
|
|
//KT-4 P-2000 1.6A1 管件 弯头
|
|
//
|
|
//公称直径 材质 表号 标准号 外径系列
|
|
//90 20号钢 Sch40 GB 9948 A
|
|
//
|
|
//描述 数量 图纸号
|
|
//弯头,20号钢,GB 9 948,Sch40,A - -
|
|
|
|
int KTMtoTool::ImpFitMto(AcArray<AecInterface>& arInfs,KTObjXDataMap& objXData,CMapStringToString& mapKey2Len)
|
|
{
|
|
int nNum = 1;//每一个点代表该种类元件一个
|
|
|
|
CString sName,sFlag;
|
|
objXData.GetAt(_T("名称"),sName);
|
|
|
|
CString sVal;
|
|
CString sSQL;
|
|
CString sProj,sPipeNo,sLevel,sType,sKind;
|
|
CString sDN,sMotInf,sDescr,sOD, sEndF;
|
|
m_xDataMap.GetAt(DOC_PROJECT,sProj);
|
|
|
|
double dDn = 0.0,dOD = 0.0,dt = 0.0;
|
|
objXData.GetAt(PIPE_DN, dDn); //公称直径
|
|
objXData.GetAt(PIPE_LINENO,sPipeNo); //管线名称
|
|
objXData.GetAt(PIPE_LEVEL,sLevel); //等级名称
|
|
objXData.GetAt(PIPE_DESCR,sDescr);
|
|
objXData.GetAt(PIPE_OD,dOD);
|
|
objXData.GetAt(PIPE_THICK, dt);
|
|
|
|
if (m_lstPipeLineNos.Find(sPipeNo) == NULL)
|
|
{
|
|
m_lstPipeLineNos.AddTail(sPipeNo);
|
|
}
|
|
|
|
AcGeVector3d vtOff(0, 0, 0);
|
|
|
|
int nType = 0;
|
|
EFittingType eType = eMultInf;
|
|
|
|
if (objXData.GetAt(KEY_RUNTIME, nType))
|
|
{
|
|
sType = _T("管件");
|
|
eType = (EFittingType)nType;
|
|
|
|
switch (eType)
|
|
{
|
|
case eElbow:
|
|
sKind = _T("弯头");
|
|
break;
|
|
case eTee:
|
|
sKind = _T("三通");
|
|
break;
|
|
case eCross:
|
|
sKind = _T("四通");
|
|
break;
|
|
case eWye:
|
|
sKind = _T("Y三通");
|
|
break;
|
|
case eReduce:
|
|
sKind = _T("变径");
|
|
objXData.GetAt(KEY_OFFSET, vtOff);
|
|
if (!vtOff.isZeroLength())
|
|
{
|
|
sKind = _T("偏心变径");
|
|
}
|
|
break;
|
|
case eLateral:
|
|
sKind = _T("斜三通");
|
|
break;
|
|
case eFlange:
|
|
sKind = _T("法兰");
|
|
break;
|
|
case eWcap:
|
|
sKind = _T("管帽");
|
|
break;
|
|
case eFlxJoin:
|
|
sKind = _T("卡箍");
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
//来自法兰管
|
|
sKind = _T("法兰");
|
|
}
|
|
|
|
//管件
|
|
CString sMetia;
|
|
objXData.GetAt(PIPE_MATERIALFT, sMetia);
|
|
|
|
CString sTabNo;
|
|
objXData.GetAt(PIPE_SHTNO, sTabNo);
|
|
|
|
CString sGB;
|
|
objXData.GetAt(PIPE_STDNO, sGB);
|
|
|
|
CString sODT;
|
|
objXData.GetAt(PIPE_ODSN, sODT);
|
|
|
|
CString sStd;
|
|
objXData.GetAt(PIPE_STDNO, sStd);
|
|
|
|
objXData.GetAt(PIPE_DESCR, sDescr);
|
|
|
|
CString sSn;
|
|
objXData.GetAt(KEY_SN, sSn);
|
|
|
|
if (!sType.IsEmpty())
|
|
{
|
|
sSQL.Format(_T("insert into AecMTOFit ([项目名称],[等级名称],[类别],[类型],")
|
|
_T("[公称直径],[材质],[表号],[标准号],[外径系列],[描述],[管线名称],[图纸号],[外径],[壁厚],[$])")
|
|
_T(" values ('%s','%s','%s','%s',%d,'%s','%s','%s','%s','%s','%s','%s',%d,%f,[~])"),
|
|
sProj,sLevel,sType,sKind,
|
|
(int)(dDn+0.5),sMetia,sTabNo,sGB,sODT,sDescr,
|
|
sPipeNo,m_sDrawNo,(int)(dOD+0.5),(int)(dt+0.5));
|
|
|
|
if (mapKey2Len.Lookup(sSQL,sVal))
|
|
{
|
|
nNum += _ttof(sVal);
|
|
sVal.Format(_T("%d"), nNum);
|
|
mapKey2Len.SetAt(sSQL,sVal);
|
|
}
|
|
else
|
|
{
|
|
sVal.Format(_T("%d"), nNum);
|
|
mapKey2Len.SetAt(sSQL,sVal);
|
|
}
|
|
}
|
|
|
|
int nConnectType = 0;//焊接0 承插1 螺纹2 法兰管3
|
|
objXData.GetAt(PIPE_CONNECT, nConnectType);
|
|
|
|
if (nConnectType == 3 || nConnectType == 5 || eType == eFlange)//有法兰 或法兰
|
|
{
|
|
//法兰
|
|
objXData.GetAt(PIPE_FLANGF, sEndF);
|
|
objXData.GetAt(PIPE_FLANGF1, sEndF);
|
|
objXData.GetAt(PIPE_FLANGF2, sEndF);
|
|
|
|
double dPre = 1.0;
|
|
CString sTxt1, sTxt2, sTxt3, sTxt4, sTxt5, sTxt6, sKey, sBoltInfs;
|
|
CString sTxt7, sTxt8, sTxt9, sTxt10, sTxt11, sTxt12, sGasketInf;
|
|
CStringArray arVals;
|
|
|
|
for (int i = 0; i < arInfs.length(); i++)
|
|
{
|
|
nNum = 1;
|
|
AecInterface &inf = arInfs.at(i);
|
|
dDn = inf.dSize1;
|
|
|
|
//ID 项目名称 管线名称 等级名称 类别 类型
|
|
//公称直径 材质 标准号 端面 压力
|
|
//描述 数量 图纸号
|
|
|
|
//法兰
|
|
//if (sName.CompareNoCase(_T("法兰")) == 0)
|
|
{
|
|
sTxt1 = sProj;
|
|
//objXData.GetAt(_T("等级名称"), sTxt2);
|
|
sTxt2 = sLevel;
|
|
|
|
//objXData.GetAt(_T("类别"), sTxt3);
|
|
sTxt3 = _T("法兰");
|
|
|
|
//objXData.GetAt(_T("类型"), sTxt4);
|
|
sTxt4 = _T("法兰");
|
|
|
|
//objXData.GetAt(_T("公称直径"), sTxt5);
|
|
sTxt5.Format(_T("%d"), (int)(dDn + 0.5));
|
|
|
|
//objXData.GetAt(_T("材质"), sTxt6);
|
|
sTxt6 = sMetia;
|
|
|
|
//objXData.GetAt(_T("标准号"), sTxt7);
|
|
sTxt7 = sStd;
|
|
|
|
//objXData.GetAt(_T("端面"), sTxt8);
|
|
sTxt8 = sEndF;
|
|
|
|
objXData.GetAt(_T("压力"), dPre);
|
|
|
|
//objXData.GetAt(_T("描述"), sTxt10);
|
|
sTxt10 = sDescr;
|
|
|
|
//sPipeNo
|
|
//objXData.GetAt(_T("管线名称"), sPipeNo);
|
|
|
|
//objXData.GetAt(_T("外径"), dOD);
|
|
objXData.GetAt(PIPE_OD, dOD);
|
|
|
|
//objXData.GetAt(_T("壁厚"), dt);
|
|
objXData.GetAt(PIPE_THICK, dt);
|
|
|
|
sSQL.Format(_T("insert into AecMTOFlange ([项目名称],[等级名称],[类别],[类型],")
|
|
_T("[公称直径],[材质],[标准号],[端面],[压力],[描述],[管线名称],[图纸号],[外径],[壁厚],[$])")
|
|
_T(" values ('%s','%s','%s','%s', %d,'%s','%s','%s',%g,'%s','%s','%s',%d,%f,[~])"),
|
|
sTxt1, sTxt2, sTxt3, sTxt4,
|
|
_ttoi(sTxt5), sTxt6, sTxt7, sTxt8, dPre, sTxt10,
|
|
sPipeNo, m_sDrawNo, (int)(dOD + 0.5), dt);
|
|
|
|
CString sVal;
|
|
if (mapKey2Len.Lookup(sSQL, sVal))
|
|
{
|
|
nNum += _ttof(sVal);
|
|
sVal.Format(_T("%d"), nNum);
|
|
mapKey2Len.SetAt(sSQL, sVal);
|
|
}
|
|
else
|
|
{
|
|
sVal.Format(_T("%d"), nNum);
|
|
mapKey2Len.SetAt(sSQL, sVal);
|
|
}
|
|
}
|
|
|
|
//ID 项目名称 等级名称 类别 类型
|
|
//公称直径 材质 标准号 端面 压力 法兰类型
|
|
//垫片厚度 描述 数量 图纸号 管线名称
|
|
sKey.Format(_T("%s%d"), PIPE_GASKETINF, i);
|
|
//if (sName.CompareNoCase(_T("垫片")) == 0)
|
|
if (objXData.GetAt(sKey, sGasketInf))
|
|
{
|
|
arVals.RemoveAll();
|
|
CoreTools::SplitStrintToArray(sGasketInf, arVals, _T('#'));
|
|
|
|
if (arVals.GetCount() >= 8)
|
|
{
|
|
nNum = 1;
|
|
|
|
sTxt1 = sProj;
|
|
|
|
//objXData.GetAt(_T("等级名称"), sTxt2);
|
|
sTxt2 = sLevel;
|
|
|
|
//objXData.GetAt(_T("类别"), sTxt3);
|
|
sTxt3 = arVals.GetAt(5);
|
|
|
|
//objXData.GetAt(_T("类型"), sTxt4);
|
|
sTxt4 = arVals.GetAt(6);
|
|
|
|
//objXData.GetAt(_T("公称直径"), sTxt5);
|
|
sTxt5 = arVals.GetAt(0);
|
|
|
|
//objXData.GetAt(_T("材质"), sTxt6);
|
|
sTxt6 = arVals.GetAt(1);
|
|
|
|
//objXData.GetAt(_T("标准号"), sTxt7);
|
|
sTxt7 = arVals.GetAt(7);
|
|
|
|
//objXData.GetAt(_T("端面"), sTxt8);
|
|
sTxt8 = sEndF;
|
|
|
|
//objXData.GetAt(_T("压力"), sTxt9);
|
|
sTxt9.Format(_T("%.1f"), dPre);
|
|
|
|
sTxt11 = arVals.GetAt(4);
|
|
sTxt12 = sGasketInf;
|
|
|
|
sSQL.Format(_T("insert into AecMTOGasket ([项目名称],[等级名称],[类别],[类型],")
|
|
_T("[公称直径],[材质],[标准号],[端面],[压力],[法兰类型],[垫片厚度],[描述],[管线名称],[图纸号],[$])")
|
|
_T(" values ('%s','%s','%s','%s',%d,'%s','%s','%s',%g,'%s',%g,'%s','%s','%s',[~])"),
|
|
sTxt1, sTxt2, sTxt3, sTxt4,
|
|
_ttoi(sTxt5), sTxt6, sTxt7, sTxt8, _ttof(sTxt9), sTxt10, _ttof(sTxt11), sTxt12,
|
|
sPipeNo, m_sDrawNo);
|
|
|
|
CString sVal;
|
|
if (mapKey2Len.Lookup(sSQL, sVal))
|
|
{
|
|
nNum += _ttof(sVal);
|
|
sVal.Format(_T("%d"), nNum);
|
|
mapKey2Len.SetAt(sSQL, sVal);
|
|
}
|
|
else
|
|
{
|
|
sVal.Format(_T("%d"), nNum);
|
|
mapKey2Len.SetAt(sSQL, sVal);
|
|
}
|
|
}
|
|
}
|
|
|
|
//ID 项目名称 管线名称 等级名称 类别 类型
|
|
//公称直径 材质 标准号 端面 压力 描述 数量 图纸号
|
|
//if (sName.CompareNoCase(_T("螺栓")) == 0)
|
|
sKey.Format(_T("%s%d"), PIPE_BOLTINF, i);
|
|
if (objXData.GetAt(sKey, sBoltInfs))
|
|
{
|
|
//[类型],[材质],[标准号],[描述],螺栓规格,螺栓长度,数量
|
|
arVals.RemoveAll();
|
|
CoreTools::SplitStrintToArray(sBoltInfs, arVals, _T('#'));
|
|
if (arVals.GetSize() >= 7)
|
|
{
|
|
sTxt1 = sProj;
|
|
|
|
//objXData.GetAt(_T("等级名称"), sTxt2);
|
|
sTxt2 = sLevel;
|
|
|
|
//objXData.GetAt(_T("类别"), sTxt3);
|
|
sTxt3 = _T("螺栓");
|
|
|
|
//objXData.GetAt(_T("类型"), sTxt4);
|
|
sTxt4 = arVals.GetAt(0);
|
|
|
|
//objXData.GetAt(_T("公称直径"), sTxt5);
|
|
sTxt5.Format(_T("%d"),(int)(dDn+0.5));
|
|
|
|
//objXData.GetAt(_T("材质"), sTxt6);
|
|
sTxt6 = arVals.GetAt(1);
|
|
|
|
//objXData.GetAt(_T("标准号"), sTxt7);
|
|
sTxt7 = arVals.GetAt(2);
|
|
|
|
//objXData.GetAt(_T("端面"), sTxt8);
|
|
sTxt8 = sEndF;
|
|
|
|
//objXData.GetAt(_T("压力"), sTxt9);
|
|
sTxt9.Format(_T("%.1f"), dPre);
|
|
|
|
//objXData.GetAt(_T("描述"), sTxt10);
|
|
sTxt10 = arVals.GetAt(3);
|
|
|
|
//objXData.GetAt(_T("螺栓规格"), sTxt11);
|
|
sTxt11 = arVals.GetAt(4);
|
|
|
|
//objXData.GetAt(_T("厚度"), sTxt12);//利用了垫片厚度关键字,里面存入的是螺栓的套数
|
|
sTxt12 = arVals.GetAt(6);
|
|
|
|
sSQL.Format(_T("insert into AecMTOBolt ([项目名称],[等级名称],[类别],[类型],")
|
|
_T("[公称直径],[材质],[标准号],[端面],[压力],[描述],[螺栓规格],[螺栓套数],[管线名称],[图纸号],[$])")
|
|
_T(" values ('%s','%s','%s','%s',%d,'%s','%s','%s',%g,'%s','%s',%d,'%s','%s',[~])"),
|
|
sTxt1, sTxt2, sTxt3, sTxt4,
|
|
_ttoi(sTxt5), sTxt6, sTxt7, sTxt8, _ttof(sTxt9), sTxt10,
|
|
sTxt11, _ttoi(sTxt12), sPipeNo, m_sDrawNo);
|
|
|
|
if (mapKey2Len.Lookup(sSQL, sVal))
|
|
{
|
|
nNum += _ttof(sVal);
|
|
sVal.Format(_T("%d"), nNum);
|
|
mapKey2Len.SetAt(sSQL, sVal);
|
|
}
|
|
else
|
|
{
|
|
sVal.Format(_T("%d"), nNum);
|
|
mapKey2Len.SetAt(sSQL, sVal);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
return 0;
|
|
}
|
|
|
|
int KTMtoTool::ImpEquMto(AcArray<AecInterface> &arInfs,KTObjXDataMap &objXData, CMapStringToString &mapKey2Len)
|
|
{
|
|
CString sName, sFlag;
|
|
objXData.GetAt(_T("名称"), sName);
|
|
|
|
CString sVal;
|
|
CString sSQL;
|
|
CString sProj, sPipeNo, sLevel, sType, sKind;
|
|
CString sDN, sMotInf, sDescr, sOD;
|
|
m_xDataMap.GetAt(DOC_PROJECT, sProj);
|
|
|
|
double dLen = 1.0;//每一个点代表该种类元件一个
|
|
double dDn = 0.0, dOD = 0.0, dt = 0.0;
|
|
objXData.GetAt(PIPE_DN, dDn); //公称直径
|
|
objXData.GetAt(PIPE_LINENO, sPipeNo); //管线名称
|
|
objXData.GetAt(PIPE_LEVEL, sLevel); //等级名称
|
|
objXData.GetAt(PIPE_DESCR, sDescr);
|
|
objXData.GetAt(PIPE_OD, dOD);
|
|
objXData.GetAt(PIPE_THICK, dt);
|
|
|
|
if (m_lstPipeLineNos.Find(sPipeNo) == NULL)
|
|
{
|
|
m_lstPipeLineNos.AddTail(sPipeNo);
|
|
}
|
|
|
|
/////////////////////////////////////////////////////////////////////////
|
|
// "点类型","材料点","名称","$Tag","管线名称","$Line","等级名称","$Spec",
|
|
// "类别","$Name","类型","$Type","阀长",L,"阀高",H,"手轮直径",D,"公称直径",
|
|
// DN,"标准号","$Codes","材质","$Mat","端面","$Face","压力",Ps,"描述","$Des"
|
|
//,"垫片厚度",GT,"螺栓规格","$Blt"
|
|
|
|
// ID 项目名称 管线名称 等级名称 类别
|
|
// 210 KT-3 P-2000 1.6A1 闸阀
|
|
// 类型 公称直径 端面 压力 描述 数量 图纸号
|
|
// Z41H-16c 65 RF 1 .6 Z41H-16c,RF,1.6 2 A-1
|
|
CString sTxt1, sTxt2, sTxt3, sTxt4, sTxt5, sTxt6, sTxt7, sTxt8, sTxt9, sTxt10, sTxt11, sTxt12;
|
|
if (sName.Find(_T("阀")) != -1)
|
|
{
|
|
//从库中选择??
|
|
|
|
sTxt1 = sProj;
|
|
objXData.GetAt(PIPE_LEVEL, sTxt2);
|
|
|
|
objXData.GetAt(_T("类别"), sTxt3);
|
|
|
|
objXData.GetAt(_T("类型"), sTxt4);
|
|
|
|
//objXData.GetAt(_T("公称直径"), sTxt5);
|
|
|
|
objXData.GetAt(_T("端面"), sTxt6);
|
|
|
|
objXData.GetAt(_T("压力"), sTxt7);
|
|
|
|
objXData.GetAt(_T("描述"), sTxt8);
|
|
|
|
objXData.GetAt(_T("管线名称"), sPipeNo);
|
|
|
|
if (m_lstPipeLineNos.Find(sPipeNo) == NULL)
|
|
{
|
|
m_lstPipeLineNos.AddTail(sPipeNo);
|
|
}
|
|
|
|
sSQL.Format(_T("insert into AecMTOValve ([项目名称],[等级名称],[类别],[类型],[公称直径],")
|
|
_T("[端面],[压力],[描述],[管线名称],[图纸号],[$])")
|
|
_T(" values ('%s','%s','%s','%s',%d,'%s',%g,'%s','%s','%s',[~])"),
|
|
sTxt1, sTxt2, sTxt3, sTxt4,
|
|
_ttoi(sTxt5), sTxt6, _ttof(sTxt7), sTxt8,
|
|
sPipeNo, m_sDrawNo);
|
|
if (mapKey2Len.Lookup(sSQL, sVal))
|
|
{
|
|
dLen += _ttof(sVal);
|
|
sVal.Format(_T("%d"), (int)dLen);
|
|
mapKey2Len.SetAt(sSQL, sVal);
|
|
}
|
|
else
|
|
{
|
|
sVal.Format(_T("%d"), (int)dLen);
|
|
mapKey2Len.SetAt(sSQL, sVal);
|
|
}
|
|
}
|
|
|
|
return 0;
|
|
} |