SGGL_SHJ/SGGL/FineUIPro.Web/HJGL/WeldingManage/WeldMatMatch.aspx.cs

380 lines
16 KiB
C#
Raw Normal View History

2022-09-05 16:36:31 +08:00
using BLL;
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
namespace FineUIPro.Web.HJGL.WeldingManage
{
public partial class WeldMatMatch : PageBase
{
public string PipeArea
{
get
{
return (string)ViewState["PipeArea"];
}
set
{
ViewState["PipeArea"] = value;
}
}
protected void Page_Load(object sender, EventArgs e)
{
ctlAuditFlow.Url = BLL.Project_SysSetService.GetAvevaNetUrl(this.CurrUser.LoginProjectId);
if (!IsPostBack)
{
PipeArea = Request.Params["PipeArea"];
this.InitTreeMenu();//加载树
}
}
#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.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();
}
if (unitWork1.Count() > 0)
{
foreach (var q in unitWork1)
{
int a = (from x in Funs.DB.HJGL_Pipeline where x.ProjectId == this.CurrUser.LoginProjectId && x.UnitWorkId == q.UnitWorkId && x.PipeArea == PipeArea select x).Count();
var u = BLL.UnitService.GetUnitByUnitId(q.UnitId);
TreeNode tn1 = new TreeNode();
tn1.NodeID = q.UnitWorkId;
tn1.Text = q.UnitWorkName + "【" + a.ToString() + "】" + "管线";
tn1.ToolTip = "施工单位:" + u.UnitName;
tn1.CommandName = "单位工程";
tn1.EnableExpandEvent = true;
rootNode1.Nodes.Add(tn1);
if (a > 0)
{
// BindNodes(tn1);
TreeNode newNode = new TreeNode();
newNode.Text = "加载管线...";
newNode.NodeID = "加载管线...";
tn1.Nodes.Add(newNode);
}
}
}
if (unitWork2.Count() > 0)
{
foreach (var q in unitWork2)
{
int a = (from x in Funs.DB.HJGL_Pipeline where x.ProjectId == this.CurrUser.LoginProjectId && x.UnitWorkId == q.UnitWorkId && x.PipeArea == PipeArea select x).Count();
var u = BLL.UnitService.GetUnitByUnitId(q.UnitId);
TreeNode tn2 = new TreeNode();
tn2.NodeID = q.UnitWorkId;
tn2.Text = q.UnitWorkName + "【" + a.ToString() + "】" + "管线";
if (q.UnitWorkId == this.hdUnitWorkId.Text)
{
tn2.Expanded = true;
}
tn2.ToolTip = "施工单位:" + u.UnitName;
tn2.CommandName = "单位工程";
tn2.EnableExpandEvent = true;
rootNode2.Nodes.Add(tn2);
if (a > 0)
{
// BindNodes(tn2);
TreeNode newNode = new TreeNode();
newNode.Text = "加载管线...";
newNode.NodeID = "加载管线...";
tn2.Nodes.Add(newNode);
}
}
}
}
protected void tvControlItem_TreeNodeExpanded(object sender, TreeNodeEventArgs e)
{
e.Node.Nodes.Clear();
if (e.Node.CommandName == "单位工程")
{
2022-09-05 16:36:31 +08:00
var pipeline = (from x in Funs.DB.HJGL_Pipeline
where x.ProjectId == this.CurrUser.LoginProjectId && x.UnitWorkId == e.Node.NodeID && x.PipeArea == PipeArea
orderby x.PipelineCode
select x).ToList();
if (!string .IsNullOrEmpty (txtPipelineCode.Text.Trim()))
{
pipeline= pipeline.Where(x => x.PipelineCode.Contains(txtPipelineCode.Text.Trim())).ToList();
}
2022-09-05 16:36:31 +08:00
foreach (var item in pipeline)
{
//var jotCount = (from x in Funs.DB.HJGL_WeldJoint where x.PipelineId == item.PipelineId && x.IsTwoJoint == null select x).Count();
//var weldJotCount = (from x in Funs.DB.HJGL_WeldJoint where x.PipelineId == item.PipelineId && x.IsTwoJoint == null && x.WeldingDailyId != null select x).Count();
//if (jotCount > weldJotCount)
//{
// newNode.Text = "<font color='#EE0000'>" + item.PipelineCode + "【" + jotCount.ToString() + " " + "焊口" + "】" + "</font>";
//}
//else
//{
// newNode.Text = item.PipelineCode + "【" + jotCount.ToString() + " " + "焊口" + "】";
//}
TreeNode newNode = new TreeNode();
string suf = " (0%)";
bool istrue = BLL.HJGL_MaterialService.isInStockByPipeline(item.PipelineId, this.CurrUser.LoginProjectId);
if (istrue)
{
suf = " (100%)";
newNode.CssClass = "tn-color-green";
}
newNode.Text = item.PipelineCode+suf; //+ "【" + jotCount.ToString() + " " + "焊口" + "】";
2022-10-15 15:40:49 +08:00
newNode.CommandName = "管线";
2022-09-05 16:36:31 +08:00
newNode.NodeID = item.PipelineId;
newNode.EnableClickEvent = true;
e.Node.Nodes.Add(newNode);
}
}
}
#endregion
protected void btnTreeFind_Click(object sender, EventArgs e)
{
this.InitTreeMenu();
}
#region TreeView
/// <summary>
/// 点击TreeView
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void tvControlItem_NodeCommand(object sender, TreeCommandEventArgs e)
{
if (!string.IsNullOrEmpty(this.tvControlItem.SelectedNodeID))
{
2022-10-19 15:49:56 +08:00
2022-09-05 16:36:31 +08:00
Model.HJGL_Pipeline pipeline = BLL.PipelineService.GetPipelineByPipelineId(this.tvControlItem.SelectedNodeID);
this.hdUnitWorkId.Text = string.Empty;
if (pipeline != null)
{
this.hdUnitWorkId.Text = this.tvControlItem.SelectedNode.ParentNode.NodeID;
this.BindGrid();
}
2022-10-19 15:49:56 +08:00
if (PipeArea == PipelineService.PipeArea_SHOP)
{
var list= BLL.HJGL_PipelineComponentService.GetComponentByPipelineId(pipeline.PipelineId);
if (list!=null&&list.Count()>0)
{
lbPlanStartDate.Text = list.First().PlanStartDate.ToString () ;
}
}
else if (PipeArea == PipelineService.PipeArea_FIELD)
{
lbPlanStartDate.Text = pipeline.PlanStartDate.HasValue ? pipeline.PlanStartDate.Value.ToShortDateString() : "";
}
2022-09-05 16:36:31 +08:00
//if (pipeline.PlanStartDate.HasValue && pipeline.ActStartDate.HasValue)
//{
// if (pipeline.ActStartDate < pipeline.PlanStartDate)
// {
// lbIsFinished.Text = "超前";
// }
// else if (pipeline.ActStartDate > pipeline.PlanStartDate)
// {
// lbIsFinished.Text = "延误";
// }
// else
// {
// lbIsFinished.Text = "正常";
// }
//}
//if (pipeline.PlanStartDate.HasValue && !pipeline.ActStartDate.HasValue)
//{
// if (pipeline.PlanStartDate >= DateTime.Now)
// {
// lbIsFinished.Text = "正常";
// }
// else
// {
// lbIsFinished.Text = "延误";
// }
//}
Model.Parameter3D parameter3D = new Model.Parameter3D();
Model.ColorModel colorModel = new Model.ColorModel();
colorModel = BLL.Project_SysSetService.GetColorModel(this.CurrUser.LoginProjectId);
parameter3D.ColorModel = colorModel;
2022-10-13 18:52:45 +08:00
parameter3D.TagNum = "";
2022-09-05 16:36:31 +08:00
parameter3D.ButtonType = "0,3";
2022-10-15 15:40:49 +08:00
if (this.tvControlItem.SelectedNode.CommandName == "单位工程")
{
parameter3D.ModelName = HJGL_DataImportService.Getlatest3DModelNameByUnitWorkId(tvControlItem.SelectedNodeID);
2022-09-05 16:36:31 +08:00
2022-10-15 15:40:49 +08:00
}
else if (this.tvControlItem.SelectedNode.CommandName == "管线")
{
var model = PipelineService.GetPipelineByPipelineId(tvControlItem.SelectedNodeID);
if (model != null && !string.IsNullOrEmpty(model.UnitWorkId))
{
parameter3D.ModelName = HJGL_DataImportService.Getlatest3DModelNameByUnitWorkId(model.UnitWorkId);
}
}
ctlAuditFlow.Url_item = BLL.Project_SysSetService.GetAvevaNetUrl(this.CurrUser.LoginProjectId) + "item/IPE%7CVPD%7C" + parameter3D.ModelName;
2022-09-05 16:36:31 +08:00
ctlAuditFlow.data = parameter3D;
ctlAuditFlow.BindData();
}
}
#endregion
#region
private void BindGrid()
{
string strSql = @"SELECT lib.MaterialCode,lib.MaterialName,lib.MaterialUnit,
lib.MaterialSpec,lib.MaterialMade,lib.MaterialDef,sum(pipe.Number)as Number ,
'0' as MatchNum,'否' AS CheckState
FROM dbo.HJGL_PipeLineMat pipe
LEFT JOIN dbo.HJGL_MaterialCodeLib lib ON lib.MaterialCode = pipe.MaterialCode
WHERE PipelineId=@PipelineId
group by lib.MaterialCode,lib.MaterialName,lib.MaterialUnit,
lib.MaterialSpec,lib.MaterialMade,lib.MaterialDef ";
List<SqlParameter> listStr = new List<SqlParameter>();
listStr.Add(new SqlParameter("@PipelineId", this.tvControlItem.SelectedNodeID));
SqlParameter[] parameter = listStr.ToArray();
DataTable dt = SQLHelper.GetDataTableRunText(strSql, parameter);
// 2.获取当前分页数据
Grid1.DataSource = dt;
Grid1.DataBind();
}
protected void Grid1_RowDataBound(object sender, GridRowEventArgs e)
{
// DataRowView row = e.DataItem as DataRowView;
string code = Grid1.DataKeys[e.RowIndex][0].ToString();
var num= decimal.Parse(Grid1.DataKeys[e.RowIndex][1].ToString()) ;
bool istrue = HJGL_MaterialService.isInStockByMaterialCode(code,num,PipeArea, this.CurrUser.LoginProjectId);
if (istrue)
{
e.RowCssClass = "color1";
}
}
protected string ConvertGetStockNum(object MaterialCode)
{
return BLL.HJGL_MaterialService.GetStockNumByCode(MaterialCode.ToString(), this.CurrUser.LoginProjectId, PipeArea).ToString();
}
#endregion
#region
/// <summary>
/// 排序
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void Grid1_Sort(object sender, GridSortEventArgs e)
{
Grid1.SortDirection = e.SortDirection;
Grid1.SortField = e.SortField;
BindGrid();
}
#endregion
/// <summary>
/// 匹配
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btnNew_Click(object sender, EventArgs e)
{
}
2022-10-13 18:52:45 +08:00
protected void Grid1_RowClick(object sender, GridRowClickEventArgs e)
{
Model.Parameter3D parameter3D = new Model.Parameter3D();
Model.ColorModel colorModel = new Model.ColorModel();
colorModel = BLL.Project_SysSetService.GetColorModel(this.CurrUser.LoginProjectId);
parameter3D.ColorModel = colorModel;
2022-10-15 15:40:49 +08:00
parameter3D.ButtonType = "0,3";
if (this.tvControlItem.SelectedNode.CommandName == "单位工程")
{
parameter3D.ModelName = HJGL_DataImportService.Getlatest3DModelNameByUnitWorkId(tvControlItem.SelectedNodeID);
}
else if (this.tvControlItem.SelectedNode.CommandName == "管线")
{
var modelpipe = PipelineService.GetPipelineByPipelineId(tvControlItem.SelectedNodeID);
if (modelpipe != null && !string.IsNullOrEmpty(modelpipe.UnitWorkId))
{
parameter3D.ModelName = HJGL_DataImportService.Getlatest3DModelNameByUnitWorkId(modelpipe.UnitWorkId);
var pipecode = "/" + modelpipe.PipelineCode;
parameter3D.TagNum = pipecode;
}
}
ctlAuditFlow.Url_item = BLL.Project_SysSetService.GetAvevaNetUrl(this.CurrUser.LoginProjectId) + "item/IPE%7CVPD%7C" + parameter3D.ModelName;
2022-10-13 18:52:45 +08:00
ctlAuditFlow.data = parameter3D;
ctlAuditFlow.BindData();
}
2022-09-05 16:36:31 +08:00
/// <summary>
/// 查询
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
//protected void btnQuery_Click(object sender, EventArgs e)
//{
// this.BindGrid();
//}
}
}