Files
gjm 164968b62e chore
把非utf8-bom编码的cpp/h文件改为 utf8 bom 编码, msvc识别utf8编码时,如果不是bom格式的,会使用当前cp_oem来解码.
2026-10-04 00:04:20 +08:00

617 lines
14 KiB
C++

#include "stdafx.h"
#include "DJGXDlg.h"
#include "uiiado.h"
#include "PipelineTools.h"
#include "KTInsulateMainDlg.h"
#include "AecPipeSupport.h"
#include "CoreTools.h"
const LPCTSTR g_pszAecSpecPipe[] = {_T("公称直径"),_T("外径"),_T("壁厚"),_T("类型"),_T("端面"),_T("材质"),_T("表号"),_T("标准号"),_T("外径系列"),_T("描述"),_T("制造类型"),_T("元件代码"),NULL};
const int g_nColWidths[] = { 120, 120, 120, 160, 100, 180, 180, 180, 100, 180, 120, 140, 0};
const LPCTSTR g_pszAecPipeSpecIndex[] = {_T("介质"),_T("介质代号"),_T("最大口径"),_T("设计温度"),_T("设计压力"),_T("法兰等级"),_T("材质"),_T("腐蚀裕度"),NULL};
const int g_nColWidths2[] = { 200, 100, 120, 120, 100, 120, 140, 120, 0};
IMPLEMENT_DYNAMIC(CDJGXDlg, CDialog)
CDJGXDlg::CDJGXDlg(CWnd* pParent /*=NULL*/)
: CDialog(CDJGXDlg::IDD, pParent)
, m_nElSel(0)
, m_dEl(1000)
, m_nDDir(0)
, m_sSerNo(_T(""))
, m_sZoneNo(_T(""))
, m_sPipeNo(_T(""))
, m_dFPLen(0)
, m_sParamSetting(_T(""))
{
m_nConnectType = 0;
m_pDb = NULL;
m_sCurrSys = _T("");
m_bFilled = false;
memset(&m_pipeParam,0,sizeof(WPipe::PipeParam));
}
CDJGXDlg::~CDJGXDlg()
{
}
void CDJGXDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
DDX_Control(pDX, IDC_COMBO2, m_wndProCombo);
DDX_Control(pDX, IDC_COMBO1, m_wndSpecCombo);
DDX_Control(pDX, IDC_COMBO4, m_wndRadioCombo);
DDX_Control(pDX, IDC_LIST2, m_wndPipeSpecList);
DDX_Control(pDX, IDC_LIST1, m_wndPipeSpecIdxList);
DDX_Radio(pDX, IDC_RADIO3, m_nElSel);
DDX_Text(pDX, IDC_EDIT5, m_dEl);
DDX_Radio(pDX, IDC_RADIO1, m_nDDir);
DDX_Text(pDX, IDC_EDIT1, m_sSerNo);
DDX_Text(pDX, IDC_EDIT2, m_sZoneNo);
DDX_Text(pDX, IDC_EDIT3, m_sPipeNo);
DDX_Text(pDX, IDC_EDIT4, m_dFPLen);
DDX_Control(pDX, IDC_COMBO3, m_wndComboSys);
DDX_Text(pDX, IDC_EDIT6, m_sParamSetting);
}
BEGIN_MESSAGE_MAP(CDJGXDlg, CDialog)
ON_BN_CLICKED(IDOK, &CDJGXDlg::OnBnClickedOk)
ON_CBN_SELCHANGE(IDC_COMBO2, &CDJGXDlg::OnCbnSelchangeCombo2)
ON_CBN_SELCHANGE(IDC_COMBO1, &CDJGXDlg::OnCbnSelchangeCombo1)
ON_BN_CLICKED(IDC_BUTTON2, &CDJGXDlg::OnBnClickedButton2)
ON_BN_CLICKED(IDC_BUTTON3, &CDJGXDlg::OnBnClickedButton3)
END_MESSAGE_MAP()
BOOL CDJGXDlg::OnInitDialog()
{
CDialog::OnInitDialog();
InitListCtrlStyle();
ShowProSpec();
ShowRadio();
return TRUE;
}
BOOL CDJGXDlg::InitListCtrlStyle()
{
CBitmap bmp;
if (!bmp.LoadBitmap(IDB_BMPSPEC))
{
AfxMessageBox(_T("Can't load bitmap: %x\n"), IDB_BMPSPEC);
ASSERT(FALSE);
return FALSE;
}
BITMAP bmpObj;
bmp.GetBitmap(&bmpObj);
UINT nFlags = ILC_COLOR24 | ILC_MASK;
m_imageList.Create(16, bmpObj.bmHeight, nFlags, 0, 0);
m_imageList.Add(&bmp, RGB(255, 0, 0));
m_wndPipeSpecList.SetExtendedStyle(LVS_EX_GRIDLINES | LVS_EX_FULLROWSELECT | LVS_EX_SINGLEROW);
m_wndPipeSpecList.SetImageList(&m_imageList, LVSIL_SMALL);
m_wndPipeSpecIdxList.SetExtendedStyle(LVS_EX_GRIDLINES | LVS_EX_FULLROWSELECT | LVS_EX_SINGLEROW);
m_wndPipeSpecIdxList.SetImageList(&m_imageList, LVSIL_SMALL);
int n = 0;
while(g_nColWidths[n] > 0)
{
m_wndPipeSpecList.InsertColumn(n,g_pszAecSpecPipe[n],LVCFMT_LEFT,g_nColWidths[n]);
n++;
}
n = 0;
while(g_nColWidths2[n] > 0)
{
m_wndPipeSpecIdxList.InsertColumn(n,g_pszAecPipeSpecIndex[n],LVCFMT_LEFT,g_nColWidths2[n]);
n++;
}
return TRUE;
}
bool CDJGXDlg::ShowProSpec()
{
CString sSQL;
sSQL.Format(_T("select distinct [项目名称] from [AecSpecname]"));
CStringArray arVals;
m_pDb->GetSelData(sSQL,arVals);
for(int i = 0;i < arVals.GetSize();i++)
{
m_wndProCombo.AddString(arVals.GetAt(i));
}
m_wndProCombo.SetCurSel(0);
CString sPro = arVals.GetAt(0);
arVals.RemoveAll();
sSQL.Format(_T("select distinct [等级名称] from [AecSpecname] where [项目名称]='%s'"),sPro);
m_pDb->GetSelData(sSQL,arVals);
for(int n = 0;n < arVals.GetSize();n++)
{
m_wndSpecCombo.AddString(arVals.GetAt(n));
}
m_wndSpecCombo.SetCurSel(0);
CString sSpec = arVals.GetAt(0);
ShowPipeSpecList(sPro,sSpec);
return true;
}
void CDJGXDlg::OnCbnSelchangeCombo2()
{
int nCur = m_wndProCombo.GetCurSel();
if (nCur != -1)
{
CString sPro;
m_wndProCombo.GetLBText(nCur,sPro);
m_wndSpecCombo.ResetContent();
CStringArray arVals;
CString sSQL;
sSQL.Format(_T("select distinct [等级名称] from [AecSpecname] where [项目名称]='%s'"),sPro);
m_pDb->GetSelData(sSQL,arVals);
for(int n = 0;n < arVals.GetSize();n++)
{
m_wndSpecCombo.AddString(arVals.GetAt(n));
}
m_wndSpecCombo.SetCurSel(0);
CString sSpec = arVals.GetAt(0);
ShowPipeSpecList(sPro,sSpec);
}
}
void CDJGXDlg::OnCbnSelchangeCombo1()
{
int nCur = m_wndProCombo.GetCurSel();
if (nCur != -1)
{
CString sPro;
m_wndProCombo.GetLBText(nCur,sPro);
nCur = m_wndSpecCombo.GetCurSel();
if (nCur != -1)
{
CString sSpec;
m_wndSpecCombo.GetLBText(nCur,sSpec);
ShowPipeSpecList(sPro,sSpec);
}
}
}
bool CDJGXDlg::ShowPipeSpecList(CString& sPro,CString& sSpec)
{
m_wndPipeSpecList.DeleteAllItems();
m_wndPipeSpecIdxList.DeleteAllItems();
CString sFields = _T("");
int n = 0;
while(g_nColWidths[n] > 0)
{
sFields += _T("[");
sFields += g_pszAecSpecPipe[n];
sFields += _T("],");
n++;
}
sFields.TrimRight(_T(','));
CString sSQL;
sSQL.Format(_T("select %s from [AecSpecPipe] where [项目名称]='%s' and [等级名称]='%s' and [短代码]='PIP' order by [公称直径]"),sFields,sPro,sSpec);
CUIIValueTable valueTable;
m_pDb->GetSelData(sSQL,valueTable);
CStringArray arVals;
for(int i = 0;i < valueTable.GetTableLogicSize();i++)
{
arVals.RemoveAll();
valueTable.GetValueRecord(i,arVals);
m_wndPipeSpecList.InsertItem(i,arVals.GetAt(0),0);
for(int n = 1;n < arVals.GetSize();n++)
{
m_wndPipeSpecList.SetItemText(i,n,arVals.GetAt(n));
}
}
m_wndPipeSpecList.SetItemState(0,LVIS_SELECTED,LVIS_SELECTED);
n = 0;
sFields = _T("");
while(g_nColWidths[n] > 0)
{
sFields += _T("[");
sFields += g_pszAecPipeSpecIndex[n];
sFields += _T("],");
n++;
}
sFields.TrimRight(_T(','));
sSQL.Format(_T("select %s from [AecPipeSpecIndex] where [等级号]='%s'"),sFields,sSpec);
valueTable.RemoveAll(TRUE);
m_pDb->GetSelData(sSQL,valueTable);
for(int i = 0;i < valueTable.GetTableLogicSize();i++)
{
arVals.RemoveAll();
valueTable.GetValueRecord(i,arVals);
m_wndPipeSpecIdxList.InsertItem(i,arVals.GetAt(0),0);
for(int n = 1;n < arVals.GetSize();n++)
{
m_wndPipeSpecIdxList.SetItemText(i,n,arVals.GetAt(n));
}
}
m_wndPipeSpecIdxList.SetItemState(0,LVIS_SELECTED,LVIS_SELECTED);
return true;
}
bool CDJGXDlg::ShowRadio()
{
CString sSQL;
sSQL.Format(_T("select [曲率半径] from [AecElbowradius] order by [曲率半径]"));
CStringArray arVals;
m_pDb->GetSelData(sSQL,arVals);
for(int i = 0;i < arVals.GetSize();i++)
{
m_wndRadioCombo.AddString(arVals.GetAt(i));
}
m_wndRadioCombo.SetCurSel(2);
return true;
}
static void TextToApp(WPipe::PipeParam& pparam,CString& sText)
{
//BE 坡口焊
//BW 对焊
//MNPT
//MGE
//SW 承插
//PE 平端
//SCRD 螺纹
//SAWH 螺旋埋弧焊
//TE 螺纹端
//ISNS 内螺纹,暗杆
//ISRS 内螺纹, 明杆
//FLGD 法兰型
pparam.m_app = WPipe::eButtweld;
pparam.m_nConnectType = 0;
if (sText.CompareNoCase(_T("SW") ) == 0)
{
pparam.m_app = WPipe::eSanitary;
pparam.m_nConnectType = 1;
}
else if(sText.CompareNoCase(_T("SCRD") ) == 0 ||
sText.CompareNoCase(_T("SAWH")) == 0 ||
sText.CompareNoCase(_T("TE")) == 0 ||
sText.CompareNoCase(_T("ISNS")) == 0 ||
sText.CompareNoCase(_T("ISRS")) == 0)
{
pparam.m_app = WPipe::eVictaulic;
pparam.m_nConnectType = 2;
}
else if(sText.CompareNoCase(_T("FLGD") ) == 0 )
{
pparam.m_app = WPipe::eFlange;
pparam.m_nConnectType = 3;
}
}
void CDJGXDlg::QueryFlangOnPipe()
{
if (m_pipeParam.m_nConnectType == 3 || m_pipeParam.m_nConnectType == 5)
{
double dWD = 0, dWh = 0, dThk = 0, dN = 0;
if (TDbPipeSupport::QueryFlangData(m_pDb
, m_pipeParam.m_dDN
, m_pipeParam.m_dPress
, dWD
, dWh
, dThk
, dN
, CoreTools::GetCurrentProject()
, m_pipeParam.szLevel))
{
m_pipeParam.m_dInterfaceL = dWh;
m_pipeParam.m_dInterfaceD = dWD;
}
}
}
void CDJGXDlg::OnBnClickedOk()
{
UpdateData();
m_bFilled = false;
FillPipeParam();
CDialog::OnOK();
}
void CDJGXDlg::FillPipeParam()
{
memset(&m_pipeParam,0,sizeof(WPipe::PipeParam));
CStringArray arVals;
int nItem = -1;
POSITION ps = m_wndPipeSpecList.GetFirstSelectedItemPosition();
if (ps != NULL)
{
nItem = m_wndPipeSpecList.GetNextSelectedItem(ps);
if (nItem == -1)
{
AfxMessageBox(_T("请选择公称直径行!"));
return;
}
}
//SQL查询条件
//[公称直径]=%d and [等级名称]='%s' and [项目]='%s'
CString sWhere,sPro;
int nSel = m_wndProCombo.GetCurSel();
if (nSel != -1)
{
m_wndProCombo.GetLBText(nSel, sPro);
}
//等级
CString sSpec;
int nCur = m_wndSpecCombo.GetCurSel();
if (nCur != -1)
{
m_wndSpecCombo.GetLBText(nCur,sSpec);
_tcscpy(m_pipeParam.szLevel,sSpec);
}
//公称
CString sText,sSQL;
sText = m_wndPipeSpecList.GetItemText(nItem,0);
m_pipeParam.m_dDN = _ttof(sText);
sWhere.Format(_T("[公称直径]=%d and [等级名称]='%s' and [项目]='%s'"),(int)(m_pipeParam.m_dDN+0.5),m_pipeParam.szLevel,sPro);
//外径
sText = m_wndPipeSpecList.GetItemText(nItem,1);
m_pipeParam.m_dOD = _ttof(sText);
//壁厚
sText = m_wndPipeSpecList.GetItemText(nItem,2);
m_pipeParam.m_dThick = _ttof(sText);
//标高
switch(m_nElSel)
{
case 0://中心线
{
break;
}
case 1: //顶参考基准
{
m_dEl -= m_pipeParam.m_dOD / 2.0;
break;
}
case 2://底参考基准
{
m_dEl += m_pipeParam.m_dOD / 2.0;
break;
}
}
m_pipeParam.m_dEl = m_dEl;
//曲率半径
m_pipeParam.m_dRRatio = 3.0;//默认
nSel = m_wndRadioCombo.GetCurSel();
if (nSel != -1)
{
m_wndRadioCombo.GetLBText(nSel, sText);
m_pipeParam.m_dRRatio = _ttof(sText);
}
//管道类型
//根据端面确定 焊接 承插 螺纹 法兰 卡箍
m_pipeParam.m_app = WPipe::eButtweld;
TextToApp(m_pipeParam,m_wndPipeSpecList.GetItemText(nItem,4));
//法兰端面
_tcscpy(m_pipeParam.m_szEndF,_T("PE"));
sSQL.Format(_T("select distinct [端面] from [AecSpecFlange] where %s"),sWhere);
arVals.RemoveAll();
m_pDb->GetSelData(sSQL,arVals);
if (arVals.GetSize() > 0)
{
_tcscpy(m_pipeParam.m_szEndF,arVals.GetAt(0));
}
//垫片信息 --> //[材质],[压力],[垫片厚度],[描述]
sSQL.Format(_T("select [材质],[压力],[垫片厚度],[描述] from [AecSpecGasket] where %s"),sWhere);
arVals.RemoveAll();
m_pDb->GetSelData(sSQL,arVals);
if (arVals.GetSize() >= 4)
{
CString sGaskets;
for (int ii = 0;ii < arVals.GetSize();ii++)
{
sGaskets += arVals.GetAt(ii);
if (ii < arVals.GetSize() - 1)
sGaskets += _T('/');
}
_tcscpy(m_pipeParam.m_szGastInf,sGaskets);
}
//法兰管分段长度
m_pipeParam.m_dInterfaceL3 = m_dFPLen;
//查询变径 由使用过程查询
//管号
_tcscpy(m_pipeParam.szPipeno,m_sPipeNo);
//管道材质
sText = m_wndPipeSpecList.GetItemText(nItem,5);
_tcscpy(m_pipeParam.szMertial,(LPCTSTR)sText);
//管件材质
sSQL.Format(_T("select distinct [材质] from [AecSpecFit] where [公称直径]=%d and [类别]='管件' and [等级名称]='%s'"),(int)(m_pipeParam.m_dDN+0.5),m_pipeParam.szLevel);
arVals.RemoveAll();
m_pDb->GetSelData(sSQL,arVals);
if (arVals.GetSize() > 0)
{
_tcscpy(m_pipeParam.szMertialFit,arVals.GetAt(0));
}
//区号
_tcscpy(m_pipeParam.szZoneNo,m_sZoneNo);
//表号
sText = m_wndPipeSpecList.GetItemText(nItem,6);
//描述
sText = m_wndPipeSpecList.GetItemText(nItem,9);
_tcscpy(m_pipeParam.szDescr,sText);
//介质
sText = m_wndPipeSpecIdxList.GetItemText(nItem,0);
_tcscpy(m_pipeParam.szMedia,sText);
//压力
sText = m_wndPipeSpecIdxList.GetItemText(nItem,4);
m_pipeParam.m_dPress = _ttof(sText);
//系统
_tcscpy(m_pipeParam.szSys,m_sCurrSys);
//保温伴热
//查询接口 信息
QueryFlangOnPipe();
m_bFilled = true;
}
//保温伴热
void CDJGXDlg::OnBnClickedButton2()
{
UpdateData();
KTInsulateMainDlg dlg;
dlg.SetADOServer(m_pDb);
WPipe::PipeParam param;
memset(&param,0,sizeof(WPipe::PipeParam));
FillPipeParam();
GetPipeParam(&param);
dlg.SetPipeParam(&param);
if (IDOK == dlg.DoModal())
{
_tcscpy(m_pipeParam.szInsMtr,param.szInsMtr);
m_pipeParam.m_dInsThk = param.m_dInsThk;
m_pipeParam.m_nInsAndHead = param.m_nInsAndHead;
_tcscpy(m_pipeParam.szInsSpec,param.szInsSpec);
_tcscpy(m_pipeParam.szInsMateral,param.szInsMateral);
_tcscpy(m_pipeParam.szInsTag,param.szInsTag);
_tcscpy(m_pipeParam.szInsDim,param.szInsDim);
FormatParamSettingAndSpec();
UpdateData(FALSE);
}
}
void CDJGXDlg::FormatParamSettingAndSpec()
{
//介质压力
CString sZone, sDN, sPP, sNo, sGrade;
CString sText;
sText.Format(_T("%s"), m_pipeParam.szMedia);
sPP = sText;
m_sParamSetting = sText + _T("-");
sText.Format(_T("%s"), m_pipeParam.szLevel);
sGrade = sText;
m_sParamSetting += sText + _T("-");
sText.Format(_T("%d"), (int)m_pipeParam.m_dDN);
sDN = sText;
m_sParamSetting += sText + _T("-");
sText.Format(_T("%.1f"), m_pipeParam.m_dRRatio);
m_sParamSetting += sText + _T("-");
sText.Format(_T("%s"), m_pipeParam.szInsMtr);
sText.TrimRight(_T('-'));
if (!sText.IsEmpty())
{
m_sParamSetting += sText + _T("-");
}
sText.Format(_T("%.1f"), m_pipeParam.m_dInsThk);
m_sParamSetting += sText;
//管线号
m_sPipeNo = m_sZoneNo + _T("-") + sDN + _T("-") + sPP + _T("-") + m_sSerNo + _T("-") + sGrade;
}
//分系统设置
void CDJGXDlg::OnBnClickedButton3()
{
CStringArray arSyses;
if (!PipelineTools::setLayerSys(m_pDb, arSyses))
{
return;
}
m_wndComboSys.ResetContent();
for (int i = 0; i < arSyses.GetSize(); i++)
{
m_wndComboSys.AddString(arSyses.GetAt(i));
}
if (arSyses.GetSize() > 0)
{
m_wndComboSys.SetCurSel(0);
m_wndComboSys.GetLBText(0, m_sCurrSys);
}
}
void CDJGXDlg::SetShowParam(WPipe::PipeParam* pParam)
{
if (pParam != NULL)
{
memcpy(&m_pipeParam,pParam,sizeof(WPipe::PipeParam));
m_bFilled = true;
}
}
bool CDJGXDlg::GetPipeParam(WPipe::PipeParam* pParam) const
{
if (pParam != NULL)
{
memcpy(pParam,&m_pipeParam,sizeof(WPipe::PipeParam));
}
return m_bFilled;
}