更改PMI代码

This commit is contained in:
jackchenyang
2024-05-26 21:28:06 +08:00
parent 5456118b94
commit 25671f28b9
4 changed files with 438 additions and 199 deletions
@@ -36,7 +36,6 @@ namespace FineUIPro.Web.WeldingProcess.PMI
{
this.InitTreeMenu();//加载树
this.BindGrid();
this.TotalPMIReport();
}
}
#endregion
@@ -55,6 +54,14 @@ namespace FineUIPro.Web.WeldingProcess.PMI
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
@@ -62,21 +69,33 @@ namespace FineUIPro.Web.WeldingProcess.PMI
select b.JointId
).Distinct().ToList();
//查询带有PMI处理的管线数据
//查询带有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.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)
{
@@ -140,6 +159,35 @@ namespace FineUIPro.Web.WeldingProcess.PMI
/// </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
@@ -149,10 +197,7 @@ namespace FineUIPro.Web.WeldingProcess.PMI
string[] arr = this.weldJointIds.Split('|');
var query = Funs.DB.View_Pipeline_WeldJoint.Where(t => t.IsPMI == true && t.PipelineId == this.tvControlItem.SelectedNodeID);
if (arr.Length > 0)
{
listData.Add(arr[0]);
}
if (listData.Count > 0)
{
query = query.Where(t => !listData.Contains(t.WeldJointId));
@@ -161,7 +206,14 @@ namespace FineUIPro.Web.WeldingProcess.PMI
{
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))
{
@@ -232,75 +284,39 @@ namespace FineUIPro.Web.WeldingProcess.PMI
#endregion
#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)
var query = Funs.DB.View_PMIDetections.AsQueryable();
if (!string.IsNullOrEmpty(this.CurrUser.LoginProjectId))
{
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) + "%";
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) + "%";
//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