326 lines
12 KiB
C#
326 lines
12 KiB
C#
using BLL;
|
|
using Model;
|
|
using NPOI.SS.Formula.Functions;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Data;
|
|
using System.Data.SqlClient;
|
|
using System.Linq;
|
|
using System.Web;
|
|
using System.Web.UI;
|
|
using System.Web.UI.WebControls;
|
|
|
|
namespace FineUIPro.Web.WeldingProcess.PMI
|
|
{
|
|
public partial class PMISelectList : PageBase
|
|
{
|
|
string UnitId = string.Empty;
|
|
string ProjectId = string.Empty;
|
|
string PMIId = string.Empty;
|
|
string weldJointIds=string.Empty;
|
|
string installId=string.Empty;
|
|
#region 加载页面
|
|
/// <summary>
|
|
/// 加载页面
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void Page_Load(object sender, EventArgs e)
|
|
{
|
|
this.UnitId = Request.Params["unitId"] ?? "";
|
|
this.ProjectId = this.CurrUser.LoginProjectId;
|
|
this.PMIId = Request.Params["PMIId"] ?? "";
|
|
this.weldJointIds = Request.Params["weldJointIds"] ?? "";
|
|
this.installId = Request.Params["installId"];
|
|
if (!IsPostBack)
|
|
{
|
|
this.InitTreeMenu();//加载树
|
|
this.BindGrid();
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region 加载管线信息
|
|
/// <summary>
|
|
/// 加载树
|
|
/// </summary>
|
|
private void InitTreeMenu()
|
|
{
|
|
this.tvControlItem.Nodes.Clear();
|
|
TreeNode rootNode = new TreeNode();
|
|
rootNode.Text = Resources.Lan.PipelineCode;
|
|
rootNode.NodeID = "0";
|
|
rootNode.ToolTip = Resources.Lan.SeachTip;
|
|
rootNode.Expanded = true;
|
|
this.tvControlItem.Nodes.Add(rootNode);
|
|
var dictWorkArea = GetWorkAreaDict();
|
|
//查询出来未达到PMI检测比例的数据
|
|
var pmiNocheckList = Funs.DB.View_PMIDetections
|
|
.Where(t => t.ProjectId == this.ProjectId
|
|
&& t.InstallationId == this.installId
|
|
&& t.UnitId == this.UnitId
|
|
&& (t.RateBys <= 2 && t.PMIBySNum <= 2) || (t.RateByf <= 2 && t.PMIByFNum <= 2))
|
|
.AsQueryable();
|
|
|
|
//排除已经委托过的
|
|
var listData= (from a in Funs.DB.PMI_Delegation.AsQueryable() join
|
|
b in Funs.DB.PMI_DelegationDetails.AsQueryable() on
|
|
a.Id equals b.PMIId
|
|
select b.JointId
|
|
).Distinct().ToList();
|
|
|
|
//查询带有PMI处理且已经焊接过的管线数据
|
|
var iso = from a in Funs.DB.View_Pipeline_WeldJoint
|
|
where a.IsPMI==true && a.ProjectId==this.ProjectId && a.UnitId==this.UnitId
|
|
&& a.InstallationId==this.installId && (a.WeldingDailyId != "" && a.WeldingDailyId!=null)
|
|
select new {a.PipelineId,a.PipelineCode,a.WorkAreaId,a.WeldJointCode,a.WeldJointId }
|
|
;
|
|
|
|
iso = from a in iso join b in pmiNocheckList on a.PipelineId equals b.PipelineId
|
|
select new {
|
|
a.PipelineId,
|
|
a.PipelineCode,
|
|
a.WorkAreaId,
|
|
a.WeldJointCode,
|
|
a.WeldJointId
|
|
};
|
|
|
|
if (listData.Count > 0)
|
|
{
|
|
iso = iso.Where(a => !listData.Contains(a.WeldJointId));
|
|
}
|
|
|
|
if (!string.IsNullOrEmpty(this.txtIsono.Text))
|
|
{
|
|
iso = iso.Where(a => a.PipelineCode.Contains(this.txtIsono.Text.Trim()));
|
|
}
|
|
|
|
|
|
var isoList = iso.Select(x => new { x.PipelineId,x.PipelineCode,x.WorkAreaId}).OrderBy(x => x.PipelineCode).Distinct().ToList();
|
|
if (isoList.Count > 0)
|
|
{
|
|
foreach (var q in isoList)
|
|
{
|
|
string workAreaCode = string.Empty;
|
|
if (dictWorkArea.ContainsKey(q.WorkAreaId))
|
|
{
|
|
workAreaCode = dictWorkArea[q.WorkAreaId];
|
|
}
|
|
TreeNode newNode = new TreeNode();
|
|
newNode.NodeID = q.PipelineId;
|
|
newNode.Text = q.PipelineCode + "(" + workAreaCode + ")";
|
|
newNode.EnableClickEvent = true;
|
|
rootNode.Nodes.Add(newNode);
|
|
}
|
|
}
|
|
}
|
|
private Dictionary<string, string> GetWorkAreaDict()
|
|
{
|
|
var dict = Funs.DB.Project_WorkArea.Where(t=>t.ProjectId==this.ProjectId&& t.UnitId==this.UnitId).ToDictionary(t => t.WorkAreaId, t => t.WorkAreaCode);
|
|
return dict;
|
|
}
|
|
#endregion
|
|
|
|
#region 管线查询
|
|
/// <summary>
|
|
/// 查询
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void Tree_TextChanged(object sender, EventArgs e)
|
|
{
|
|
this.InitTreeMenu();
|
|
}
|
|
protected void Tree2_TextChanged(object sender, EventArgs e)
|
|
{
|
|
this.BindGrid();
|
|
this.TotalPMIReport();
|
|
}
|
|
|
|
#endregion
|
|
|
|
|
|
#region 点击TreeView
|
|
/// <summary>
|
|
/// 点击TreeView
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void tvControlItem_NodeCommand(object sender, TreeCommandEventArgs e)
|
|
{
|
|
this.BindGrid();
|
|
this.TotalPMIReport();
|
|
}
|
|
#endregion
|
|
|
|
#region 数据绑定
|
|
/// <summary>
|
|
/// 数据绑定
|
|
/// </summary>
|
|
private void BindGrid()
|
|
{
|
|
//未达标的活动S口
|
|
var pmiViewJointBy_S = (from a in Funs.DB.View_PMIDetections
|
|
join b in Funs.DB.Pipeline_WeldJoint
|
|
on a.PipelineId equals b.PipelineId
|
|
where a.ProjectId == this.ProjectId
|
|
&& a.InstallationId == this.installId
|
|
&& a.UnitId == this.UnitId
|
|
&& b.JointAttribute == "活动S"
|
|
&& a.PipelineId == this.tvControlItem.SelectedNodeID
|
|
|
|
&& (b.WeldingDailyId != null && b.WeldingDailyId != "")
|
|
&& (a.RateBys > 2 || a.PMIBySNum > 2)
|
|
select b.WeldJointId)
|
|
.ToList();
|
|
//未达标的固定F口
|
|
var pmiViewJointBy_F = (from a in Funs.DB.View_PMIDetections
|
|
join b in Funs.DB.Pipeline_WeldJoint
|
|
on a.PipelineId equals b.PipelineId
|
|
where a.ProjectId == this.ProjectId
|
|
&& a.InstallationId == this.installId
|
|
&& a.UnitId == this.UnitId
|
|
&& b.JointAttribute == "固定F"
|
|
&& a.PipelineId == this.tvControlItem.SelectedNodeID
|
|
&& (b.WeldingDailyId != null && b.WeldingDailyId != "")
|
|
&& (a.RateByf >2 && a.PMIByFNum > 2)
|
|
select b.WeldJointId)
|
|
.ToList();
|
|
|
|
//排除已经选择过的焊口
|
|
var listData = (from a in Funs.DB.PMI_Delegation.AsQueryable()
|
|
join
|
|
b in Funs.DB.PMI_DelegationDetails.AsQueryable() on
|
|
a.Id equals b.PMIId
|
|
select b.JointId
|
|
).Distinct().ToList();
|
|
|
|
string[] arr = this.weldJointIds.Split('|');
|
|
var query = Funs.DB.View_Pipeline_WeldJoint.Where(t => t.IsPMI == true
|
|
&& (t.WeldingDailyId != null && t.WeldingDailyId!="")
|
|
&& t.PipelineId == this.tvControlItem.SelectedNodeID);
|
|
|
|
if (listData.Count > 0)
|
|
{
|
|
query = query.Where(t => !listData.Contains(t.WeldJointId));
|
|
}
|
|
if (!string.IsNullOrEmpty(this.txtJointNo.Text))
|
|
{
|
|
query = query.Where(t => t.WeldJointCode == this.txtJointNo.Text);
|
|
}
|
|
if (pmiViewJointBy_S.Count > 0)
|
|
{
|
|
query = query.Where(t => t.JointAttribute != "活动S");
|
|
}
|
|
if (pmiViewJointBy_F.Count > 0)
|
|
{
|
|
query = query.Where(t => t.JointAttribute != "固定F");
|
|
}
|
|
var data= query.ToList() ;
|
|
if (!string.IsNullOrEmpty(weldJointIds))
|
|
{
|
|
string[] jots = weldJointIds.Split('|');
|
|
data = data.Where(t => !jots.Contains(t.WeldJointId)).ToList();
|
|
}
|
|
data = data.OrderBy(t => t.WeldJointCode).ToList();
|
|
Grid1.DataSource = data;
|
|
Grid1.DataBind();
|
|
}
|
|
#endregion
|
|
|
|
#region 排序
|
|
/// <summary>
|
|
/// 排序
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void Grid1_Sort(object sender, GridSortEventArgs e)
|
|
{
|
|
this.BindGrid();
|
|
}
|
|
#endregion
|
|
|
|
#region 提交按钮
|
|
/// <summary>
|
|
/// 提交按钮
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void btnAccept_Click(object sender, EventArgs e)
|
|
{
|
|
string itemsString = "";
|
|
string[] selectRowId = Grid1.SelectedRowIDArray;
|
|
int n = 0;
|
|
int j = 0;
|
|
int[] selections = new int[selectRowId.Count()];
|
|
foreach (GridRow row in Grid1.Rows)
|
|
{
|
|
if (selectRowId.Contains(row.DataKeys[0]))
|
|
{
|
|
selections[n] = j;
|
|
n++;
|
|
}
|
|
j++;
|
|
}
|
|
var select = selections.Distinct();
|
|
string jotIds = Request.Params["jotIds"];
|
|
if (!string.IsNullOrEmpty(jotIds))
|
|
{
|
|
string[] jots = jotIds.Split('|');
|
|
foreach (string jotId in jots)
|
|
{
|
|
itemsString += jotId + "|";
|
|
}
|
|
}
|
|
foreach (int i in select)
|
|
{
|
|
string rowID = Grid1.DataKeys[i][0].ToString();
|
|
if (!itemsString.Contains(rowID))
|
|
{
|
|
itemsString += rowID + "|";
|
|
}
|
|
}
|
|
PageContext.RegisterStartupScript(ActiveWindow.GetWriteBackValueReference(itemsString)
|
|
+ ActiveWindow.GetHidePostBackReference());
|
|
}
|
|
#endregion
|
|
|
|
#region 统计比例
|
|
|
|
private void TotalPMIReport()
|
|
{
|
|
var query = Funs.DB.View_PMIDetections.AsQueryable();
|
|
if (!string.IsNullOrEmpty(this.CurrUser.LoginProjectId))
|
|
{
|
|
query=query.Where(t=>t.ProjectId == this.CurrUser.LoginProjectId);
|
|
}
|
|
if (!string.IsNullOrEmpty(this.installId))
|
|
{
|
|
query=query.Where(t=>t.InstallationId==this.installId);
|
|
}
|
|
if (!string.IsNullOrEmpty(this.UnitId))
|
|
{
|
|
query=query.Where(t=>t.UnitId==this.UnitId);
|
|
}
|
|
if (!string.IsNullOrEmpty(txtIsono.Text))
|
|
{
|
|
query = query.Where(t => t.PipelineCode.Contains(txtIsono.Text.Trim()));
|
|
}
|
|
if (!string.IsNullOrEmpty(this.tvControlItem.SelectedNodeID))
|
|
{
|
|
query=query.Where(t=>t.PipelineId==this.tvControlItem.SelectedNodeID);
|
|
}
|
|
query = query.Where(t => (t.RateBys <= 2 && t.PMIBySNum <= 2) || (t.RateByf <= 2 && t.PMIByFNum <= 2));
|
|
var pmiInfo = query.FirstOrDefault();
|
|
if (pmiInfo!=null)
|
|
{
|
|
lblnumbyf.Text = "安装检测数量:" + pmiInfo.PMIByFNum;
|
|
lblnumbys.Text = "预制检测数量:" + pmiInfo.PMIBySNum;
|
|
lblratebyf.Text = "安装检测比例:" + Math.Round(pmiInfo.RateByf, 2)+"%";
|
|
lblratebys.Text = "预制检测比例:" + Math.Round(pmiInfo.RateBys, 2) + "%";
|
|
|
|
}
|
|
}
|
|
#endregion
|
|
}
|
|
} |