508 lines
20 KiB
C#
508 lines
20 KiB
C#
using BLL;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Data;
|
|
using System.Data.SqlClient;
|
|
using System.Linq;
|
|
using System.Web;
|
|
|
|
namespace FineUIPro.Web.HJGL.TestPackage
|
|
{
|
|
public partial class TestPackageComplete : PageBase
|
|
{
|
|
#region 定义项
|
|
|
|
/// <summary>
|
|
/// 试压包主键
|
|
/// </summary>
|
|
public string PTP_ID
|
|
{
|
|
get
|
|
{
|
|
return (string)ViewState["PTP_ID"];
|
|
}
|
|
set
|
|
{
|
|
ViewState["PTP_ID"] = value;
|
|
}
|
|
}
|
|
#endregion 定义项
|
|
|
|
#region 加载页面
|
|
|
|
/// <summary>
|
|
/// 加载页面
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void Page_Load(object sender, EventArgs e)
|
|
{
|
|
if (!IsPostBack)
|
|
{
|
|
this.ddlPageSize.SelectedValue = this.Grid1.PageSize.ToString();
|
|
|
|
drpStateStr.DataTextField = "Value";
|
|
drpStateStr.DataValueField = "Value";
|
|
drpStateStr.DataSource= BLL.TestPackageEditService.StateMap;
|
|
drpStateStr.DataBind();
|
|
this.PTP_ID = string.Empty;
|
|
Model.Project_Sys_Set pressUnit = BLL.Project_SysSetService.GetSysSetBySetId("8", this.CurrUser.LoginProjectId);
|
|
if (pressUnit != null && pressUnit.SetValue == "2")
|
|
{
|
|
this.Grid1.Columns[1].HeaderText = "设计压力kpa(g)";
|
|
this.Grid1.Columns[4].HeaderText = "压力试验压力kpa(g)";
|
|
}
|
|
this.InitTreeMenu();//加载树
|
|
BindGrid2();
|
|
}
|
|
}
|
|
|
|
#endregion 加载页面
|
|
|
|
#region 加载树装置-单位-工作区
|
|
|
|
/// <summary>
|
|
/// 加载树
|
|
/// </summary>
|
|
private void InitTreeMenu()
|
|
{
|
|
this.tvControlItem.Nodes.Clear();
|
|
|
|
TreeNode rootNode1 = new TreeNode();
|
|
rootNode1.NodeID = "1";
|
|
rootNode1.Text = "建筑工程";
|
|
rootNode1.CommandName = "建筑工程";
|
|
rootNode1.Selectable = false;
|
|
this.tvControlItem.Nodes.Add(rootNode1);
|
|
|
|
TreeNode rootNode2 = new TreeNode();
|
|
rootNode2.NodeID = "2";
|
|
rootNode2.Text = "安装工程";
|
|
rootNode2.CommandName = "安装工程";
|
|
rootNode2.Expanded = true;
|
|
this.tvControlItem.Nodes.Add(rootNode2);
|
|
var pUnits = (from x in Funs.DB.Project_ProjectUnit where x.ProjectId == this.CurrUser.LoginProjectId select x).ToList();
|
|
// 获取当前用户所在单位
|
|
var currUnit = pUnits.FirstOrDefault(x => x.UnitId == this.CurrUser.UnitId);
|
|
|
|
var unitWorkList = (from x in Funs.DB.WBS_UnitWork
|
|
where x.ProjectId == this.CurrUser.LoginProjectId
|
|
&& x.SuperUnitWork == null && x.UnitId != null && x.ProjectType != null
|
|
select x).ToList();
|
|
List<Model.PTP_TestPackage> testPackageLists = new List<Model.PTP_TestPackage>();
|
|
if (!string.IsNullOrEmpty(this.txtCode.Text.Trim()))
|
|
{
|
|
testPackageLists = (from x in Funs.DB.PTP_TestPackage
|
|
where x.ProjectId == this.CurrUser.LoginProjectId
|
|
&& x.TestPackageNo.Contains(this.txtCode.Text.Trim())
|
|
select x).ToList();
|
|
}
|
|
else
|
|
{
|
|
testPackageLists = (from x in Funs.DB.PTP_TestPackage
|
|
where x.ProjectId == this.CurrUser.LoginProjectId
|
|
select x).ToList();
|
|
}
|
|
List<Model.WBS_UnitWork> unitWork1 = null;
|
|
List<Model.WBS_UnitWork> unitWork2 = null;
|
|
|
|
//// 当前为施工单位,只能操作本单位的数据
|
|
//if (currUnit != null && currUnit.UnitType == Const.ProjectUnitType_2)
|
|
//{
|
|
// unitWork1 = (from x in unitWorkList
|
|
// where x.UnitId == this.CurrUser.UnitId && x.ProjectType == "1"
|
|
// select x).ToList();
|
|
// unitWork2 = (from x in unitWorkList
|
|
// where x.UnitId == this.CurrUser.UnitId && x.ProjectType == "2"
|
|
// select x).ToList();
|
|
//}
|
|
//else
|
|
//{
|
|
unitWork1 = (from x in unitWorkList where x.ProjectType == "1" select x).ToList();
|
|
unitWork2 = (from x in unitWorkList where x.ProjectType == "2" select x).ToList();
|
|
//}
|
|
|
|
var dicUnitWorkTestPackagePassPercent = BLL.TestPackageEditService.GetTestPackagePassPercentByProjectId(this.CurrUser.LoginProjectId);
|
|
if (unitWork1.Count() > 0)
|
|
{
|
|
foreach (var q in unitWork1)
|
|
{
|
|
var unitNamesUnitIds = BLL.UnitService.getUnitNamesUnitIds(q.UnitId);
|
|
var unitWorkTestPackagePassPercent = dicUnitWorkTestPackagePassPercent.TryGetValue(q.UnitWorkId, out var value) ? value : 0;
|
|
TreeNode tn1 = new TreeNode();
|
|
tn1.NodeID = q.UnitWorkId;
|
|
tn1.Text = q.UnitWorkName + "(已完成" + unitWorkTestPackagePassPercent + "%)";
|
|
tn1.ToolTip = "施工单位:" + unitNamesUnitIds;
|
|
tn1.CommandName = "单位工程";
|
|
if (unitWorkTestPackagePassPercent==100)
|
|
{
|
|
tn1.CssClass = "Green";
|
|
}
|
|
rootNode1.Nodes.Add(tn1);
|
|
var testPackageUnitList = testPackageLists.Where(x => x.UnitWorkId == q.UnitWorkId).ToList();
|
|
BindNodes(tn1, testPackageUnitList);
|
|
}
|
|
}
|
|
if (unitWork2.Count() > 0)
|
|
{
|
|
foreach (var q in unitWork2)
|
|
{
|
|
var unitNamesUnitIds = BLL.UnitService.getUnitNamesUnitIds(q.UnitId);
|
|
var unitWorkTestPackagePassPercent = dicUnitWorkTestPackagePassPercent.TryGetValue(q.UnitWorkId, out var value) ? value : 0;
|
|
|
|
TreeNode tn2 = new TreeNode();
|
|
tn2.NodeID = q.UnitWorkId;
|
|
tn2.Text = q.UnitWorkName + "(已完成" + unitWorkTestPackagePassPercent + "%)";
|
|
tn2.ToolTip = "施工单位:" + unitNamesUnitIds;
|
|
tn2.CommandName = "单位工程";
|
|
if (unitWorkTestPackagePassPercent == 100)
|
|
{
|
|
tn2.CssClass = "Green";
|
|
}
|
|
rootNode2.Nodes.Add(tn2);
|
|
var testPackageUnitList = testPackageLists.Where(x => x.UnitWorkId == q.UnitWorkId).ToList();
|
|
BindNodes(tn2, testPackageUnitList);
|
|
}
|
|
}
|
|
}
|
|
|
|
#endregion 加载树装置-单位-工作区
|
|
|
|
#region 绑定树节点
|
|
|
|
/// <summary>
|
|
/// 绑定树节点
|
|
/// </summary>
|
|
/// <param name="node"></param>
|
|
private void BindNodes(TreeNode node, List<Model.PTP_TestPackage> testPackageUnitList)
|
|
{
|
|
if (node.CommandName == "单位工程")
|
|
{
|
|
var dReports = from x in testPackageUnitList
|
|
where x.AduditDate.HasValue
|
|
orderby x.TestPackageNo descending
|
|
select x;
|
|
var totalList = from x in Funs.DB.PTP_ItemEndCheckList select x;
|
|
foreach (var item in dReports)
|
|
{
|
|
var list = from x in totalList where x.PTP_ID == item.PTP_ID select x;
|
|
var notCompleteAlist = from x in totalList
|
|
where x.PTP_ID == item.PTP_ID && x.AOKState == null
|
|
select x;
|
|
|
|
if (list.Count() > 0 && notCompleteAlist.Count() == 0) //不存在A类尾项未整改完成记录
|
|
{
|
|
TreeNode newNode = new TreeNode();
|
|
if (!string.IsNullOrEmpty(item.TestPackageNo))
|
|
{
|
|
newNode.Text = item.TestPackageNo;
|
|
}
|
|
else
|
|
{
|
|
newNode.Text = "未知";
|
|
}
|
|
//if (!item.AduditDate.HasValue || string.IsNullOrEmpty(item.Auditer))
|
|
//{
|
|
// newNode.Text = "<font color='#FF7575'>" + newNode.Text + "</font>";
|
|
// node.Text = "<font color='#FF7575'>" + node.Text + "</font>";
|
|
//}
|
|
newNode.NodeID = item.PTP_ID;
|
|
newNode.EnableClickEvent = true;
|
|
newNode.CommandName = "TestPackage";
|
|
node.Nodes.Add(newNode);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
#endregion 绑定树节点
|
|
|
|
#region 点击TreeView
|
|
|
|
/// <summary>
|
|
/// 点击TreeView
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void tvControlItem_NodeCommand(object sender, TreeCommandEventArgs e)
|
|
{
|
|
this.PTP_ID = tvControlItem.SelectedNodeID;
|
|
this.BindGrid();
|
|
}
|
|
|
|
#endregion 点击TreeView
|
|
|
|
#region 数据绑定
|
|
/// <summary>
|
|
/// 数据绑定
|
|
/// </summary>
|
|
private void BindGrid()
|
|
{
|
|
this.SetTextTemp();
|
|
this.PageInfoLoad(); ///页面输入保存信息
|
|
string strSql = @" SELECT ptpPipe.PT_PipeId, ptpPipe.PTP_ID, ptpPipe.PipelineId, ptpPipe.DesignPress,
|
|
ptpPipe.DesignTemperature, ptpPipe.AmbientTemperature, ptpPipe.TestMedium,
|
|
ptpPipe.TestMediumTemperature, ptpPipe.TestPressure, ptpPipe.HoldingTime,IsoInfo.PipelineCode,testMedium.MediumName
|
|
FROM dbo.PTP_PipelineList AS ptpPipe
|
|
LEFT JOIN dbo.HJGL_Pipeline AS IsoInfo ON ptpPipe.PipelineId = IsoInfo.PipelineId
|
|
LEFT JOIN dbo.Base_TestMedium AS testMedium ON testMedium.TestMediumId = IsoInfo.TestMedium
|
|
WHERE ptpPipe.PTP_ID=@PTP_ID";
|
|
List<SqlParameter> listStr = new List<SqlParameter>();
|
|
listStr.Add(new SqlParameter("@ProjectId", this.CurrUser.LoginProjectId));
|
|
listStr.Add(new SqlParameter("@PTP_ID", this.PTP_ID));
|
|
SqlParameter[] parameter = listStr.ToArray();
|
|
DataTable tb = SQLHelper.GetDataTableRunText(strSql, parameter);
|
|
// 2.获取当前分页数据
|
|
//var table = this.GetPagedDataTable(Grid1, tb1);
|
|
Grid1.RecordCount = tb.Rows.Count;
|
|
var table = this.GetPagedDataTable(Grid1, tb);
|
|
Grid1.DataSource = table;
|
|
Grid1.DataBind();
|
|
}
|
|
|
|
/// <summary>
|
|
/// 获取当前项目下所有试压包分析
|
|
/// </summary>
|
|
private void BindGrid2()
|
|
{
|
|
// 获取当前项目下所有试压包
|
|
var projectTestPackages = BLL.TestPackageEditService.GetTestPackageByProjectId(this.CurrUser.LoginProjectId);
|
|
if (projectTestPackages == null || projectTestPackages.Count == 0)
|
|
{
|
|
Grid2.DataSource = null;
|
|
Grid2.DataBind();
|
|
return;
|
|
}
|
|
if (!string.IsNullOrEmpty(this.txtGrid2code.Text.Trim()))
|
|
{
|
|
projectTestPackages = projectTestPackages.Where(x => x.TestPackageNo.Contains(this.txtGrid2code.Text.Trim())).ToList();
|
|
}
|
|
|
|
// 分析每个试压包
|
|
var analyzeList = new List<Model.TestPackageAnalyzeOutput>();
|
|
foreach (var pkg in projectTestPackages)
|
|
{
|
|
var analyze = BLL.TestPackageEditService.getTestPackageAnalyze(pkg.PTP_ID, pkg.ProjectId);
|
|
analyzeList.Add(analyze);
|
|
}
|
|
analyzeList = analyzeList.OrderBy(x => x.UnitWorkName).ThenBy(x => x.TestPackageNo).ToList();
|
|
|
|
if (drpCanPressureTest.SelectedValueArray.Length>0)
|
|
{
|
|
analyzeList = analyzeList.Where(x => drpCanPressureTest.SelectedValueArray.ToList().Contains(x.CanPressureTest)).ToList();
|
|
}
|
|
if (drpStateStr.SelectedValueArray.Length > 0)
|
|
{
|
|
analyzeList = analyzeList.Where(x => drpStateStr.SelectedValueArray.ToList().Contains(x.StateStr)).ToList();
|
|
}
|
|
// 绑定到Grid1
|
|
Grid2.RecordCount = analyzeList.Count;
|
|
Grid2.DataSource = analyzeList;
|
|
Grid2.DataBind();
|
|
|
|
// 设置行样式(保留原逻辑)
|
|
for (int i = 0; i < Grid2.Rows.Count; i++)
|
|
{
|
|
string ptpId = Grid2.Rows[i].DataKeys[0].ToString();
|
|
var ptpModel = analyzeList.FirstOrDefault(x=>x.PTP_ID== ptpId);
|
|
if (ptpModel != null)
|
|
{
|
|
|
|
if (ptpModel.CanPressureTest== "未具备")
|
|
{
|
|
Grid2.Rows[i].RowCssClass = "Red";
|
|
|
|
}
|
|
else if (ptpModel.CanPressureTest == "易具备")
|
|
{
|
|
Grid2.Rows[i].RowCssClass = "Yellow";
|
|
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
#region 加载页面输入保存信息
|
|
|
|
/// <summary>
|
|
/// 加载页面输入保存信息
|
|
/// </summary>
|
|
private void PageInfoLoad()
|
|
{
|
|
var testPackageManage = BLL.TestPackageEditService.GetTestPackageByID(this.PTP_ID);
|
|
if (testPackageManage != null)
|
|
{
|
|
this.txtTestPackageNo.Text = testPackageManage.TestPackageNo;
|
|
this.txtTestPackageName.Text = testPackageManage.TestPackageName;
|
|
this.txtadjustTestPressure.Text = testPackageManage.AdjustTestPressure;
|
|
this.txtAmbientTemperature.Text = testPackageManage.AmbientTemperature.ToString();
|
|
this.txtFinishDef.Text = testPackageManage.FinishDef;
|
|
this.txtHoldingTime.Text = testPackageManage.HoldingTime.ToString();
|
|
this.txtTestDate.Text = testPackageManage.TestDate?.ToString("yyyy-MM-dd");
|
|
this.txtTestMediumTemperature.Text = testPackageManage.TestMediumTemperature.ToString();
|
|
}
|
|
}
|
|
|
|
#endregion 加载页面输入保存信息
|
|
|
|
#region 清空页面输入信息
|
|
|
|
/// <summary>
|
|
/// 清空页面输入信息
|
|
/// </summary>
|
|
private void SetTextTemp()
|
|
{
|
|
this.txtadjustTestPressure.Text = string.Empty;
|
|
this.txtAmbientTemperature.Text = string.Empty;
|
|
this.txtFinishDef.Text = string.Empty;
|
|
this.txtHoldingTime.Text = string.Empty;
|
|
this.txtTestDate.Text = string.Empty;
|
|
this.txtTestMediumTemperature.Text = string.Empty;
|
|
}
|
|
|
|
#endregion 清空页面输入信息
|
|
|
|
#endregion 数据绑定
|
|
|
|
#region 分页排序
|
|
|
|
#region 页索引改变事件
|
|
|
|
/// <summary>
|
|
/// 页索引改变事件
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void Grid1_PageIndexChange(object sender, GridPageEventArgs e)
|
|
{
|
|
BindGrid();
|
|
}
|
|
|
|
#endregion 页索引改变事件
|
|
|
|
#region 排序
|
|
|
|
/// <summary>
|
|
/// 排序
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void Grid1_Sort(object sender, GridSortEventArgs e)
|
|
{
|
|
BindGrid();
|
|
}
|
|
|
|
#endregion 排序
|
|
|
|
#region 分页选择下拉改变事件
|
|
|
|
/// <summary>
|
|
/// 分页选择下拉改变事件
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void ddlPageSize_SelectedIndexChanged(object sender, EventArgs e)
|
|
{
|
|
Grid1.PageSize = Convert.ToInt32(ddlPageSize.SelectedValue);
|
|
BindGrid();
|
|
}
|
|
|
|
#endregion 分页选择下拉改变事件
|
|
|
|
#endregion 分页排序
|
|
|
|
#region 关闭弹出窗口及刷新页面
|
|
|
|
/// <summary>
|
|
/// 关闭弹出窗口
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void Window1_Close(object sender, WindowCloseEventArgs e)
|
|
{
|
|
this.PTP_ID = this.hdPTP_ID.Text;
|
|
this.BindGrid();
|
|
this.InitTreeMenu();
|
|
this.hdPTP_ID.Text = string.Empty;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 查询
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void Tree_TextChanged(object sender, EventArgs e)
|
|
{
|
|
this.InitTreeMenu();
|
|
this.BindGrid();
|
|
}
|
|
|
|
#endregion 关闭弹出窗口及刷新页面
|
|
|
|
protected void btnMenuModify_Click(object sender, EventArgs e)
|
|
{
|
|
PageContext.RegisterStartupScript(Window1.GetSaveStateReference(this.hdPTP_ID.ClientID) + Window1.GetShowReference(String.Format("TestPackageCompleteEdit.aspx?PTP_ID={0}", this.tvControlItem.SelectedNodeID, "操作 - ")));
|
|
}
|
|
|
|
protected void btnPrinter_Click(object sender, EventArgs e)
|
|
{
|
|
string PTP_ID = this.tvControlItem.SelectedNodeID;
|
|
var p = BLL.TestPackageEditService.GetTestPackageByID(PTP_ID);
|
|
if (p != null)
|
|
{
|
|
string varValue = string.Empty;
|
|
var project = BLL.ProjectService.GetProjectByProjectId(this.CurrUser.LoginProjectId);
|
|
if (project != null)
|
|
{
|
|
varValue = project.ProjectName;
|
|
var unitWork = BLL.UnitWorkService.GetUnitWorkByUnitWorkId(p.UnitWorkId);
|
|
if (unitWork != null)
|
|
{
|
|
varValue = varValue + "|" + unitWork.UnitWorkName;
|
|
}
|
|
if (!string.IsNullOrEmpty(p.TestPackageName))
|
|
{
|
|
varValue = varValue + "|" + p.TestPackageName;
|
|
}
|
|
if (!string.IsNullOrEmpty(p.TestPackageNo))
|
|
{
|
|
varValue = varValue + "|" + p.TestPackageNo;
|
|
}
|
|
if (!string.IsNullOrEmpty(p.FinishDef))
|
|
{
|
|
varValue = varValue + "|" + p.FinishDef;
|
|
}
|
|
}
|
|
if (!string.IsNullOrEmpty(varValue))
|
|
{
|
|
varValue = HttpUtility.UrlEncodeUnicode(varValue);
|
|
}
|
|
PageContext.RegisterStartupScript(Window2.GetShowReference(String.Format("../../ReportPrint/ExReportPrint.aspx?ispop=1&reportId={0}&replaceParameter={1}&varValue={2}&projectId={3}", BLL.Const.HJGL_TestPackageRecordReportId, PTP_ID, varValue, this.CurrUser.LoginProjectId)));
|
|
}
|
|
else
|
|
{
|
|
ShowNotify("请选择试压包!", MessageBoxIcon.Warning);
|
|
return;
|
|
}
|
|
}
|
|
|
|
#region 查询
|
|
|
|
/// <summary>
|
|
/// 查询
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void txtCode_TextChanged(object sender, EventArgs e)
|
|
{
|
|
InitTreeMenu();
|
|
}
|
|
protected void btnSearch_Click(object sender, EventArgs e)
|
|
{
|
|
BindGrid2();
|
|
}
|
|
|
|
#endregion 查询
|
|
|
|
}
|
|
} |