2024-05-12 12:05:01 +08:00
|
|
|
|
using BLL;
|
2024-05-26 08:28:18 +08:00
|
|
|
|
using Model;
|
|
|
|
|
using NPOI.SS.Formula.Functions;
|
2024-05-12 12:05:01 +08:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
2024-05-26 11:28:05 +08:00
|
|
|
|
using System.Data;
|
2024-05-12 12:05:01 +08:00
|
|
|
|
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;
|
2024-05-26 08:28:18 +08:00
|
|
|
|
string installId=string.Empty;
|
2024-05-12 12:05:01 +08:00
|
|
|
|
#region 加载页面
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 加载页面
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="sender"></param>
|
|
|
|
|
/// <param name="e"></param>
|
|
|
|
|
protected void Page_Load(object sender, EventArgs e)
|
|
|
|
|
{
|
2024-05-12 22:53:47 +08:00
|
|
|
|
this.UnitId = Request.Params["unitId"] ?? "";
|
|
|
|
|
this.ProjectId = this.CurrUser.LoginProjectId;
|
|
|
|
|
this.PMIId = Request.Params["PMIId"] ?? "";
|
|
|
|
|
this.weldJointIds = Request.Params["weldJointIds"] ?? "";
|
2024-05-26 08:28:18 +08:00
|
|
|
|
this.installId = Request.Params["installId"];
|
2024-05-12 12:05:01 +08:00
|
|
|
|
if (!IsPostBack)
|
|
|
|
|
{
|
|
|
|
|
this.InitTreeMenu();//加载树
|
|
|
|
|
this.BindGrid();
|
2024-05-26 11:28:05 +08:00
|
|
|
|
this.TotalPMIReport();
|
2024-05-12 12:05:01 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
#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);
|
2024-05-26 11:28:05 +08:00
|
|
|
|
var dictWorkArea = GetWorkAreaDict();
|
2024-05-12 12:05:01 +08:00
|
|
|
|
//排除已经委托过的
|
|
|
|
|
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
|
2024-05-26 08:28:18 +08:00
|
|
|
|
).Distinct().ToList();
|
2024-05-12 12:05:01 +08:00
|
|
|
|
|
|
|
|
|
//查询带有PMI处理的管线数据
|
2024-05-26 11:28:05 +08:00
|
|
|
|
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
|
|
|
|
|
select new {a.PipelineId,a.PipelineCode,a.WorkAreaId,a.WeldJointCode,a.WeldJointId }
|
|
|
|
|
;
|
2024-05-26 08:28:18 +08:00
|
|
|
|
|
2024-05-12 12:05:01 +08:00
|
|
|
|
if (listData.Count > 0)
|
|
|
|
|
{
|
2024-05-26 11:28:05 +08:00
|
|
|
|
iso = iso.Where(a => !listData.Contains(a.WeldJointId));
|
2024-05-12 12:05:01 +08:00
|
|
|
|
}
|
|
|
|
|
if (!string.IsNullOrEmpty(this.txtIsono.Text))
|
|
|
|
|
{
|
2024-05-26 11:28:05 +08:00
|
|
|
|
iso = iso.Where(a => a.PipelineCode.Contains(this.txtIsono.Text.Trim()));
|
2024-05-12 12:05:01 +08:00
|
|
|
|
}
|
2024-05-26 11:28:05 +08:00
|
|
|
|
var isoList = iso.Select(x => new { x.PipelineId,x.PipelineCode,x.WorkAreaId}).OrderBy(x => x.PipelineCode).Distinct().ToList();
|
2024-05-12 12:05:01 +08:00
|
|
|
|
if (isoList.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
foreach (var q in isoList)
|
|
|
|
|
{
|
2024-05-26 11:28:05 +08:00
|
|
|
|
string workAreaCode = string.Empty;
|
|
|
|
|
if (dictWorkArea.ContainsKey(q.WorkAreaId))
|
|
|
|
|
{
|
|
|
|
|
workAreaCode = dictWorkArea[q.WorkAreaId];
|
|
|
|
|
}
|
2024-05-12 12:05:01 +08:00
|
|
|
|
TreeNode newNode = new TreeNode();
|
|
|
|
|
newNode.NodeID = q.PipelineId;
|
2024-05-26 11:28:05 +08:00
|
|
|
|
newNode.Text = q.PipelineCode + "(" + workAreaCode + ")";
|
2024-05-12 12:05:01 +08:00
|
|
|
|
newNode.EnableClickEvent = true;
|
|
|
|
|
rootNode.Nodes.Add(newNode);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2024-05-26 11:28:05 +08:00
|
|
|
|
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;
|
|
|
|
|
}
|
2024-05-12 12:05:01 +08:00
|
|
|
|
#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();
|
2024-05-26 11:28:05 +08:00
|
|
|
|
this.TotalPMIReport();
|
2024-05-12 12:05:01 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#region 点击TreeView
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 点击TreeView
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="sender"></param>
|
|
|
|
|
/// <param name="e"></param>
|
|
|
|
|
protected void tvControlItem_NodeCommand(object sender, TreeCommandEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
this.BindGrid();
|
2024-05-26 11:28:05 +08:00
|
|
|
|
this.TotalPMIReport();
|
2024-05-12 12:05:01 +08:00
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 数据绑定
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 数据绑定
|
|
|
|
|
/// </summary>
|
|
|
|
|
private void BindGrid()
|
|
|
|
|
{
|
2024-05-12 15:28:06 +08:00
|
|
|
|
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();
|
2024-05-12 12:05:01 +08:00
|
|
|
|
|
2024-05-12 22:53:47 +08:00
|
|
|
|
string[] arr = this.weldJointIds.Split('|');
|
2024-05-26 08:28:18 +08:00
|
|
|
|
var query = Funs.DB.View_Pipeline_WeldJoint.Where(t => t.IsPMI == true && t.PipelineId == this.tvControlItem.SelectedNodeID);
|
2024-05-12 22:53:47 +08:00
|
|
|
|
if (arr.Length > 0)
|
|
|
|
|
{
|
|
|
|
|
listData.Add(arr[0]);
|
|
|
|
|
}
|
2024-05-12 15:28:06 +08:00
|
|
|
|
if (listData.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
query = query.Where(t => !listData.Contains(t.WeldJointId));
|
|
|
|
|
}
|
2024-05-12 12:05:01 +08:00
|
|
|
|
if (!string.IsNullOrEmpty(this.txtJointNo.Text))
|
|
|
|
|
{
|
2024-05-12 15:28:06 +08:00
|
|
|
|
query = query.Where(t => t.WeldJointCode == this.txtJointNo.Text);
|
2024-05-12 12:05:01 +08:00
|
|
|
|
}
|
2024-05-26 08:28:18 +08:00
|
|
|
|
|
2024-05-12 22:53:47 +08:00
|
|
|
|
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;
|
2024-05-12 12:05:01 +08:00
|
|
|
|
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
|
2024-05-26 11:28:05 +08:00
|
|
|
|
|
|
|
|
|
#region 统计比例
|
|
|
|
|
private void TotalPMIReport()
|
|
|
|
|
{
|
|
|
|
|
string sql = @"select *from (
|
|
|
|
|
select
|
|
|
|
|
projectId,
|
|
|
|
|
InstallationId,
|
|
|
|
|
WorkAreaId,
|
|
|
|
|
UnitId,
|
|
|
|
|
PipelineId,
|
|
|
|
|
InstallationCode,
|
|
|
|
|
WorkAreaCode,
|
|
|
|
|
PipelineCode,
|
|
|
|
|
PMINum,
|
|
|
|
|
isnull((convert(float,PMIBySNum)/NULLIF(convert(float,PMINum),0)*100),0) as RateBys,
|
|
|
|
|
PMIBySNum,
|
|
|
|
|
isnull( (convert(float,PMIByFNum)/NULLIF(convert(float,PMINum),0)*100),0) as RateByf,
|
|
|
|
|
PMIByFNum
|
|
|
|
|
from (
|
|
|
|
|
select
|
|
|
|
|
a.projectId,
|
|
|
|
|
a.InstallationId,
|
|
|
|
|
a.WorkAreaId,
|
|
|
|
|
a.UnitId,
|
|
|
|
|
a.PipelineId,
|
|
|
|
|
b.InstallationCode,
|
|
|
|
|
c.WorkAreaCode,
|
|
|
|
|
a.PipelineCode,
|
|
|
|
|
(select count(1) from Pipeline_WeldJoint as d where isPMI=1 and d.PipelineId=a.PipelineId) as PMINum,
|
|
|
|
|
(
|
|
|
|
|
select count(1) from PMI_Delegation as pd inner join PMI_DelegationDetails as pdd on pd.Id=pdd.PMIId
|
|
|
|
|
inner join Pipeline_WeldJoint as pwj on pdd.JointId=pwj.WeldJointId
|
|
|
|
|
where pd.InstallationId=a.InstallationId and pd.UnitId=a.UnitId and pdd.WorkAreaId=a.WorkAreaId
|
|
|
|
|
and pwj.PipelineId=a.PipelineId and pwj.JointAttribute='活动S' and pwj.isPMI=1
|
|
|
|
|
) as PMIBySNum,
|
|
|
|
|
(
|
|
|
|
|
select count(1) from PMI_Delegation as pd inner join PMI_DelegationDetails as pdd on pd.Id=pdd.PMIId
|
|
|
|
|
inner join Pipeline_WeldJoint as pwj on pdd.JointId=pwj.WeldJointId
|
|
|
|
|
where pd.InstallationId=a.InstallationId and pd.UnitId=a.UnitId and pdd.WorkAreaId=a.WorkAreaId
|
|
|
|
|
and pwj.PipelineId=a.PipelineId and pwj.JointAttribute='固定F' and pwj.isPMI=1
|
|
|
|
|
) as PMIByFNum
|
|
|
|
|
from Pipeline_Pipeline as a
|
|
|
|
|
left join Project_Installation as b on a.InstallationId=b.InstallationId
|
|
|
|
|
left join Project_WorkArea as c on a.WorkAreaId=c.WorkAreaId
|
|
|
|
|
) as t
|
|
|
|
|
) as H where projectId=@projectId and PipelineId=@PipelineId ";
|
|
|
|
|
List<SqlParameter> listStr = new List<SqlParameter>();
|
|
|
|
|
listStr.Add(new SqlParameter("@projectId", this.CurrUser.LoginProjectId));
|
|
|
|
|
listStr.Add(new SqlParameter("@PipelineId", this.tvControlItem.SelectedNodeID));
|
|
|
|
|
SqlParameter[] parameter = listStr.ToArray();
|
|
|
|
|
DataTable dt = SQLHelper.GetDataTableRunText(sql, parameter);
|
|
|
|
|
if (dt.Rows.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
string PMIByFNum = dt.Rows[0]["PMIByFNum"].ToString();
|
|
|
|
|
string PMIBySNum=dt.Rows[0]["PMIBySNum"].ToString();
|
|
|
|
|
string RateByF=dt.Rows[0]["RateByF"].ToString();
|
|
|
|
|
string RateByS = dt.Rows[0]["RateByS"].ToString();
|
|
|
|
|
lblnumbyf.Text = "预制检测数量:" + PMIByFNum;
|
|
|
|
|
lblnumbys.Text = "安装检测数量:" + PMIBySNum;
|
|
|
|
|
lblratebyf.Text = "预制检测比例:" + Math.Round(decimal.Parse(RateByF), 2)+"%";
|
|
|
|
|
lblratebys.Text = "安装检测比例:" + Math.Round(decimal.Parse(RateByS), 2) + "%";
|
|
|
|
|
|
|
|
|
|
//if(Math.Round(decimal.Parse(RateByF), 2)>0 && Math.Round(decimal.Parse(RateByF), 2) <= 2)
|
|
|
|
|
//{
|
|
|
|
|
// lblratebyf.CssStyle = "{color:red}";
|
|
|
|
|
//}
|
|
|
|
|
//if (Math.Round(decimal.Parse(RateByS), 2) > 0 && Math.Round(decimal.Parse(RateByS), 2) <= 2)
|
|
|
|
|
//{
|
|
|
|
|
// lblratebys.CssStyle = "{color:red}";
|
|
|
|
|
//}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
2024-05-12 12:05:01 +08:00
|
|
|
|
}
|
|
|
|
|
}
|