439 lines
16 KiB
C#
439 lines
16 KiB
C#
using BLL;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Data;
|
|
using System.Linq;
|
|
|
|
namespace FineUIPro.Web.HJGL.PreDesign
|
|
{
|
|
|
|
public partial class PipelingDivide : PageBase
|
|
{
|
|
public static List<Model.HJGL_Pipeline> view_HJGL_Pipelines = new List<Model.HJGL_Pipeline>();
|
|
public decimal PipelineComplete
|
|
{
|
|
get
|
|
{
|
|
return (decimal)ViewState["PipelineComplete"];
|
|
}
|
|
set
|
|
{
|
|
ViewState["PipelineComplete"] = value;
|
|
}
|
|
}
|
|
public decimal PipelineNOComplete
|
|
{
|
|
get
|
|
{
|
|
return (decimal)ViewState["PipelineNOComplete"];
|
|
}
|
|
set
|
|
{
|
|
ViewState["PipelineNOComplete"] = value;
|
|
}
|
|
}
|
|
public string Line_No
|
|
{
|
|
get
|
|
{
|
|
return (string)ViewState["Line_No"];
|
|
}
|
|
set
|
|
{
|
|
ViewState["Line_No"] = value;
|
|
}
|
|
}
|
|
protected void Page_Load(object sender, EventArgs e)
|
|
{
|
|
// ctlAuditFlow.Url = BLL.Project_SysSetService.GetAvevaNetUrl(this.CurrUser.LoginProjectId);
|
|
|
|
if (!IsPostBack)
|
|
{
|
|
// this.ddlPageSize.SelectedValue = this.Grid1.PageSize.ToString();
|
|
this.InitTreeMenu();//加载树
|
|
PipelineComplete = 0;
|
|
PipelineNOComplete = 0;
|
|
}
|
|
}
|
|
|
|
protected void drpProjectId_SelectedIndexChanged(object sender, EventArgs e)
|
|
{
|
|
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 select x).Count();
|
|
var unitNamesUnitIds = BLL.UnitService.getUnitNamesUnitIds(q.UnitId);
|
|
TreeNode tn1 = new TreeNode();
|
|
tn1.NodeID = q.UnitWorkId;
|
|
tn1.Text = q.UnitWorkName + "【" + a.ToString() + "】" + "管线";
|
|
tn1.ToolTip = "施工单位:" + unitNamesUnitIds;
|
|
tn1.EnableClickEvent = true;
|
|
rootNode1.Nodes.Add(tn1);
|
|
}
|
|
}
|
|
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 select x).Count();
|
|
var unitNamesUnitIds = BLL.UnitService.getUnitNamesUnitIds(q.UnitId);
|
|
TreeNode tn2 = new TreeNode();
|
|
tn2.NodeID = q.UnitWorkId;
|
|
tn2.Text = q.UnitWorkName + "【" + a.ToString() + "】" + "管线";
|
|
tn2.ToolTip = "施工单位:" + unitNamesUnitIds;
|
|
tn2.EnableClickEvent = true;
|
|
rootNode2.Nodes.Add(tn2);
|
|
}
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region 点击TreeView
|
|
/// <summary>
|
|
/// 点击TreeView
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void tvControlItem_NodeCommand(object sender, TreeCommandEventArgs e)
|
|
{
|
|
this.BindGrid();
|
|
// var q = view_HJGL_Pipelines.Where(x => x.PipeArea == PipelineService.PipeArea_SHOP);
|
|
// if (q.Any())
|
|
// {
|
|
// List<string> listpipecode = new List<string>();
|
|
// foreach (var item in q)
|
|
// {
|
|
// listpipecode.Add("/" + item.PipelineCode);
|
|
// }
|
|
// Line_No = string.Join(",", listpipecode);
|
|
// }
|
|
// Model.Parameter3D parameter3D = new Model.Parameter3D();
|
|
// Model.ColorModel colorModel = new Model.ColorModel();
|
|
// colorModel = BLL.Project_SysSetService.GetColorModel(this.CurrUser.LoginProjectId);
|
|
// parameter3D.ColorModel = colorModel;
|
|
// parameter3D.TagNum = Line_No;
|
|
// parameter3D.ButtonType = "1";
|
|
// parameter3D.ModelName = HJGL_DataImportService.Getlatest3DModelNameByUnitWorkId(tvControlItem.SelectedNodeID);
|
|
//// parameter3D.Line_No = Line_No;
|
|
// ctlAuditFlow.Url_item = BLL.Project_SysSetService.GetAvevaNetUrl_Item(this.CurrUser.LoginProjectId) + parameter3D.ModelName;
|
|
// ctlAuditFlow.data = parameter3D;
|
|
// ctlAuditFlow.BindData();
|
|
|
|
}
|
|
#endregion
|
|
|
|
#region 数据绑定
|
|
/// <summary>
|
|
/// 数据绑定
|
|
/// </summary>
|
|
private void BindGrid()
|
|
{
|
|
PipelineService.RestPipelineAndJoints(this.CurrUser.LoginProjectId);
|
|
Model.HJGL_Pipeline view_HJGL_Pipeline = new Model.HJGL_Pipeline();
|
|
view_HJGL_Pipeline.ProjectId = this.CurrUser.LoginProjectId;
|
|
view_HJGL_Pipeline.UnitWorkId = this.tvControlItem.SelectedNodeID;
|
|
view_HJGL_Pipeline.PipelineCode = this.txtPipelineCode.Text.Trim();
|
|
view_HJGL_Pipeline.SingleName = this.txtSingleName.Text.Trim();
|
|
// view_HJGL_Pipeline.MaterialCode=this.txtMaterialCode.Text.Trim();
|
|
var list = BLL.PipelineService.GetHJGL_PipelineList(view_HJGL_Pipeline);
|
|
if (!string.IsNullOrEmpty(this.txtMaterialCode.Text.Trim()))
|
|
{
|
|
list = (from x in list
|
|
join y in Funs.DB.HJGL_PipeLineMat on x.PipelineId equals y.PipelineId
|
|
where y.MaterialCode.Contains(txtMaterialCode.Text.Trim())
|
|
select x).Distinct().ToList();
|
|
}
|
|
view_HJGL_Pipelines = list;
|
|
// 2.获取当前分页数据
|
|
Grid1.RecordCount = list.Count();
|
|
|
|
// 2.获取当前分页数据
|
|
|
|
// 3.绑定到Grid
|
|
|
|
|
|
var table = this.GetPagedDataTable(Grid1, list);
|
|
Grid1.DataSource = table;
|
|
Grid1.DataBind();
|
|
//lbSinglePreRate.Text= GetSinglePreRateByUnitWork(this.tvControlItem.SelectedNodeID);
|
|
}
|
|
#endregion
|
|
|
|
#region 分页排序
|
|
#region 页索引改变事件
|
|
/// <summary>
|
|
/// 页索引改变事件
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void Grid1_PageIndexChange(object sender, GridPageEventArgs e)
|
|
{
|
|
Grid1.PageIndex = e.NewPageIndex;
|
|
BindGrid();
|
|
}
|
|
#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
|
|
|
|
#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>
|
|
/// Grid双击事件
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void Grid1_RowDoubleClick(object sender, GridRowClickEventArgs e)
|
|
{
|
|
if (BLL.CommonService.GetAllButtonPowerList(this.CurrUser.LoginProjectId, this.CurrUser.PersonId, BLL.Const.HJGL_PipelineMenuId, BLL.Const.BtnModify))
|
|
{
|
|
PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("PipelingDivideEdit.aspx?PipelineId={0}", Grid1.SelectedRowID, "编辑 - ")));
|
|
}
|
|
else
|
|
{
|
|
ShowNotify("您没有这个权限,请与管理员联系!", MessageBoxIcon.Warning);
|
|
}
|
|
}
|
|
protected void Grid1_RowClick(object sender, GridRowClickEventArgs e)
|
|
{
|
|
var Id = Grid1.SelectedRowIDArray;
|
|
List<string> listpipecode = new List<string>();
|
|
foreach (var item in Id)
|
|
{
|
|
var q = PipelineService.GetPipelineByPipelineId(item);
|
|
listpipecode.Add("/" + q.PipelineCode);
|
|
}
|
|
var pipecode = string.Join(",", listpipecode);
|
|
Model.Parameter3D parameter3D = new Model.Parameter3D();
|
|
Model.ColorModel colorModel = new Model.ColorModel();
|
|
colorModel = BLL.Project_SysSetService.GetColorModel(this.CurrUser.LoginProjectId);
|
|
parameter3D.ColorModel = colorModel;
|
|
parameter3D.TagNum = pipecode;
|
|
parameter3D.ButtonType = "1";
|
|
parameter3D.ModelName = HJGL_DataImportService.Getlatest3DModelNameByUnitWorkId(tvControlItem.SelectedNodeID);
|
|
// parameter3D.Line_No = Line_No;
|
|
|
|
ctlAuditFlow.Url_item = BLL.Project_SysSetService.GetAvevaNetUrl_Item(this.CurrUser.LoginProjectId) + parameter3D.ModelName;
|
|
ctlAuditFlow.data = parameter3D;
|
|
ctlAuditFlow.BindData();
|
|
}
|
|
#endregion
|
|
|
|
#region 关闭弹出窗口及刷新页面
|
|
/// <summary>
|
|
/// 关闭弹出窗口
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void Window1_Close(object sender, WindowCloseEventArgs e)
|
|
{
|
|
this.BindGrid();
|
|
}
|
|
|
|
/// <summary>
|
|
/// 查询
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void btnQuery_Click(object sender, EventArgs e)
|
|
{
|
|
this.BindGrid();
|
|
}
|
|
|
|
/// <summary>
|
|
/// 查询
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void Tree_TextChanged(object sender, EventArgs e)
|
|
{
|
|
this.InitTreeMenu();
|
|
this.BindGrid();
|
|
}
|
|
#endregion
|
|
|
|
#region 按钮事件
|
|
protected void btnGetChart_Click(object sender, EventArgs e)
|
|
{
|
|
var q = view_HJGL_Pipelines.Where(x => x.PipeArea == PipelineService.PipeArea_SHOP);
|
|
var q2 = view_HJGL_Pipelines.Where(x => x.PipeArea == PipelineService.PipeArea_FIELD);
|
|
PipelineComplete = q.Count();
|
|
PipelineNOComplete = q2.Count();
|
|
|
|
PageContext.RegisterStartupScript(Window2.GetShowReference(String.Format("PipelingDivideChart.aspx?PipelineComplete={0}&&PipelineNOComplete={1}", PipelineComplete, PipelineNOComplete, "编辑 - ")));
|
|
|
|
}
|
|
|
|
protected void btnSetShop_Click(object sender, EventArgs e)
|
|
{
|
|
var pipelineidList = Grid1.SelectedRowIDArray;
|
|
foreach (var item in pipelineidList)
|
|
{
|
|
BLL.PipelineService.UpdatePipelineArea(item, PipelineService.PipeArea_SHOP);
|
|
}
|
|
BindGrid();
|
|
|
|
}
|
|
|
|
protected void btnSetFIELD_Click(object sender, EventArgs e)
|
|
{
|
|
var pipelineidList = Grid1.SelectedRowIDArray;
|
|
foreach (var item in pipelineidList)
|
|
{
|
|
BLL.PipelineService.UpdatePipelineArea(item, PipelineService.PipeArea_FIELD);
|
|
|
|
}
|
|
BindGrid();
|
|
}
|
|
|
|
protected void btnRset_Click(object sender, EventArgs e)
|
|
{
|
|
txtPipelineCode.Text = String.Empty;
|
|
txtSingleName.Text = String.Empty;
|
|
txtMaterialCode.Text = String.Empty;
|
|
BindGrid();
|
|
}
|
|
|
|
#endregion
|
|
protected string ConvertPipeArea(object PipeArea)
|
|
{
|
|
string PipeAreaValue = string.Empty;
|
|
if (PipeArea != null)
|
|
{
|
|
var q = PipelineService.GetPipeArea().Where(x => x.Value == PipeArea.ToString());
|
|
if (q != null && q.Count() > 0)
|
|
{
|
|
PipeAreaValue = q.First().Text;
|
|
|
|
}
|
|
}
|
|
|
|
else
|
|
{
|
|
return "";
|
|
}
|
|
return PipeAreaValue;
|
|
}
|
|
/// <summary>
|
|
/// 获取图纸预制率(工厂预制管线的预制达因/工厂预制管线的总达因)
|
|
/// </summary>
|
|
/// <param name="unitworkid"></param>
|
|
/// <returns></returns>
|
|
private string GetSinglePreRateByUnitWork(string unitworkid)
|
|
{
|
|
var db = Funs.DB;
|
|
var pipeline = from x in db.View_HJGL_Pipeline where x.UnitWorkId == unitworkid && x.PipeArea == "1" select x;
|
|
var q = from x in db.View_HJGL_WeldJoint where x.UnitWorkId == unitworkid select x;
|
|
string rate = "";
|
|
|
|
if (q != null && q.Count() > 0 && pipeline.Count() > 0)
|
|
{
|
|
var proSum = (from x in q
|
|
join y in pipeline on x.PipelineId equals y.PipelineId into temp
|
|
from tt in temp.DefaultIfEmpty()
|
|
where x.JointAttribute == "预制口"
|
|
group x by x.UnitWorkId into g
|
|
select new
|
|
{
|
|
SizeSum = g.Sum(x => x.Size)
|
|
}).FirstOrDefault().SizeSum;
|
|
var AllSum = (from x in pipeline
|
|
group x by x.UnitWorkId into g
|
|
select new
|
|
{
|
|
SizeSum = g.Sum(x => x.TotalDin)
|
|
}).FirstOrDefault().SizeSum;
|
|
|
|
proSum = (proSum != null) ? proSum : 0;
|
|
if (AllSum > 0)
|
|
{
|
|
var a = (decimal)100 * proSum / AllSum;
|
|
rate = Math.Round((decimal)a, 1).ToString() + "%";
|
|
}
|
|
|
|
return rate;
|
|
}
|
|
return "0%";
|
|
}
|
|
|
|
}
|
|
}
|