484 lines
22 KiB
C#
484 lines
22 KiB
C#
using BLL;
|
|
using MiniExcelLibs;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Data;
|
|
using System.Data.SqlClient;
|
|
using System.IO;
|
|
using System.Linq;
|
|
using System.Web.UI.WebControls;
|
|
|
|
namespace FineUIPro.Web.HJGL.WeldingManage
|
|
{
|
|
public partial class WeldingPlan : PageBase
|
|
{
|
|
|
|
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();//加载树
|
|
}
|
|
}
|
|
|
|
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 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.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 u = BLL.UnitService.GetUnitByUnitId(q.UnitId);
|
|
TreeNode tn2 = new TreeNode();
|
|
tn2.NodeID = q.UnitWorkId;
|
|
tn2.Text = q.UnitWorkName + "【" + a.ToString() + "】" + "管线";
|
|
tn2.ToolTip = "施工单位:" + u.UnitName;
|
|
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();
|
|
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 = "";
|
|
parameter3D.ButtonType = "0";
|
|
parameter3D.ModelName = HJGL_DataImportService.Getlatest3DModelNameByUnitWorkId(tvControlItem.SelectedNodeID);
|
|
// PipelineService.GetPipelinesByUnitWordId(tvControlItem.SelectedNodeID);
|
|
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()
|
|
{
|
|
string strSql = @"select (line.PipelineId+'&'+ISNULL(com.PipelineComponentId,'') ) as ID
|
|
,line.PipelineId
|
|
,line.PipelineCode
|
|
,line.ProjectId
|
|
,line.UnitWorkId
|
|
,line.UnitId
|
|
,line.SingleNumber
|
|
,line.PipingClassId
|
|
,line.MediumId
|
|
,line.DetectionRateId
|
|
,line.DetectionType
|
|
,line.TestPressure
|
|
,line.TestMedium
|
|
,line.Remark
|
|
,line.PressurePipingClassId
|
|
,line.PipeLenth
|
|
,line.DesignPress
|
|
,line.DesignTemperature
|
|
,line.PCtype
|
|
,line.LeakPressure
|
|
,line.LeakMedium
|
|
,line.VacuumPressure
|
|
,line.PCMedium
|
|
,line.MaterialId
|
|
,line.SingleName
|
|
,line.PipeArea
|
|
,line.WBSId
|
|
,line.PlanStartDate
|
|
,line.PlanEndDate
|
|
,line.ActStartDate
|
|
,line.ActEndDate
|
|
,line.IsFinished
|
|
,line.FlowingSection
|
|
,(case line.State
|
|
when 0 then '未开始'
|
|
when 1 then '未开始且延误'
|
|
when 2 then '开始'
|
|
when 3 then '已开始且延误'
|
|
when 4 then '完成' else '' end ) as State
|
|
,com.PipelineComponentId
|
|
,com.PreUnit
|
|
,com.PipelineComponentCode
|
|
,com.BoxNumber
|
|
,com.AssembleUnit
|
|
,com.PipeLineMatId
|
|
,com.QRCode
|
|
,com.PlanStartDate as PlanStartDate_SHOP
|
|
,com.PlanEndDate as PlanEndDate_SHOP
|
|
,com.ActStartDate as ActStartDate_SHOP
|
|
,com.ActEndDate as ActEndDate_SHOP
|
|
from HJGL_Pipeline line
|
|
left join HJGL_Pipeline_Component com on line.PipelineId=com.PipelineId
|
|
LEFT JOIN dbo.Base_Material AS mat ON mat.MaterialId=line.MaterialId
|
|
WHERE line.ProjectId= @ProjectId";
|
|
List<SqlParameter> listStr = new List<SqlParameter>();
|
|
listStr.Add(new SqlParameter("@ProjectId", this.CurrUser.LoginProjectId));
|
|
|
|
strSql += " AND line.UnitWorkId =@UnitWorkId";
|
|
listStr.Add(new SqlParameter("@UnitWorkId", this.tvControlItem.SelectedNodeID));
|
|
if (!string.IsNullOrEmpty(this.txtPipelineCode.Text.Trim()))
|
|
{
|
|
strSql += " AND line.PipelineCode LIKE @PipelineCode";
|
|
listStr.Add(new SqlParameter("@PipelineCode", "%" + this.txtPipelineCode.Text.Trim() + "%"));
|
|
}
|
|
if (!string.IsNullOrEmpty(this.txtSingleName.Text.Trim()))
|
|
{
|
|
strSql += " AND line.SingleName LIKE @SingleName";
|
|
listStr.Add(new SqlParameter("@SingleName", "%" + this.txtSingleName.Text.Trim() + "%"));
|
|
}
|
|
if (!string.IsNullOrEmpty(this.txtDesignPress.Text.Trim()))
|
|
{
|
|
strSql += " AND line.DesignPress LIKE @DesignPress";
|
|
listStr.Add(new SqlParameter("@DesignPress", "%" + this.txtDesignPress.Text.Trim() + "%"));
|
|
}
|
|
if (!string.IsNullOrEmpty(this.txtMaterialCode.Text.Trim()))
|
|
{
|
|
strSql += " AND mat.MaterialCode LIKE @MaterialCode";
|
|
listStr.Add(new SqlParameter("@MaterialCode", "%" + this.txtMaterialCode.Text.Trim() + "%"));
|
|
}
|
|
if (!string.IsNullOrEmpty(this.txtFlowingSection.Text.Trim()))
|
|
{
|
|
strSql += " AND line.FlowingSection LIKE @FlowingSection";
|
|
listStr.Add(new SqlParameter("@FlowingSection", "%" + this.txtFlowingSection.Text.Trim() + "%"));
|
|
}
|
|
|
|
|
|
SqlParameter[] parameter = listStr.ToArray();
|
|
DataTable tb = SQLHelper.GetDataTableRunText(strSql, parameter);
|
|
|
|
// 2.获取当前分页数据
|
|
//var table = this.GetPagedDataTable(Grid1, tb1);
|
|
Grid1.RecordCount = tb.Rows.Count;
|
|
tb = GetFilteredTable(Grid1.FilteredData, tb);
|
|
var table = this.GetPagedDataTable(Grid1, tb);
|
|
Grid1.DataSource = table;
|
|
Grid1.DataBind();
|
|
}
|
|
#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("PipelineFinish.aspx?PipelineId={0}", Grid1.SelectedRowID, "编辑 - ")));
|
|
}
|
|
else
|
|
{
|
|
ShowNotify("您没有这个权限,请与管理员联系!", MessageBoxIcon.Warning);
|
|
}
|
|
}
|
|
protected void Grid1_RowClick(object sender, GridRowClickEventArgs e)
|
|
{
|
|
var q = PipelineService.GetPipelineByPipelineId(Grid1.SelectedRowID.Split('&')[0]);
|
|
var pipecode = "/" + q.PipelineCode;
|
|
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 = "0";
|
|
parameter3D.ModelName = HJGL_DataImportService.Getlatest3DModelNameByUnitWorkId(tvControlItem.SelectedNodeID);
|
|
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 导出按钮
|
|
/// 导出按钮
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void btnOut_Click(object sender, EventArgs e)
|
|
{
|
|
string templatePath = Funs.RootPath + @"File\Excel\DataOut\WeldingPlanDataOut2.xlsx";
|
|
string path = Funs.RootPath + @"File\Excel\DataOut\WeldingPlanDataOut2.xlsx";
|
|
path = path.Replace(".xlsx", string.Format("{0:yyyy-MM-dd-HH-mm}", DateTime.Now) + ".xlsx");
|
|
|
|
string strSql = @"SELECT PL.ProjectId,PL.UnitWorkId,unit.UnitWorkName,PipelineCode,PlanStartDate,PlanEndDate,ActStartDate,ActEndDate,
|
|
WBSId,(CASE WHEN IsFinished='1' THEN '已完成' ELSE '未完成' END) AS IsFinished
|
|
FROM dbo.HJGL_Pipeline as PL
|
|
left join WBS_UnitWork unit on PL.UnitWorkId=unit.UnitWorkId
|
|
WHERE PL.ProjectId= @ProjectId";
|
|
List<SqlParameter> listStr = new List<SqlParameter>();
|
|
listStr.Add(new SqlParameter("@ProjectId", this.CurrUser.LoginProjectId));
|
|
if (!string.IsNullOrEmpty(this.tvControlItem.SelectedNodeID) && tvControlItem.SelectedNodeID != "2")
|
|
{
|
|
strSql += " AND PL.UnitWorkId =@UnitWorkId";
|
|
listStr.Add(new SqlParameter("@UnitWorkId", this.tvControlItem.SelectedNodeID));
|
|
}
|
|
|
|
SqlParameter[] parameter = listStr.ToArray();
|
|
DataTable tb = SQLHelper.GetDataTableRunText(strSql, parameter);
|
|
tb.TableName = "Data";
|
|
var value = new Dictionary<string, object>()
|
|
{
|
|
["Data"] = tb,
|
|
};
|
|
MiniExcel.SaveAsByTemplate(path, templatePath, value);
|
|
string fileName = "施工实施计划.xlsx";
|
|
FileInfo info = new FileInfo(path);
|
|
long fileSize = info.Length;
|
|
System.Web.HttpContext.Current.Response.Clear();
|
|
System.Web.HttpContext.Current.Response.ContentType = "application/x-zip-compressed";
|
|
System.Web.HttpContext.Current.Response.AddHeader("Content-Disposition", "attachment;filename=" + System.Web.HttpUtility.UrlEncode(fileName, System.Text.Encoding.UTF8));
|
|
System.Web.HttpContext.Current.Response.AddHeader("Content-Length", fileSize.ToString());
|
|
System.Web.HttpContext.Current.Response.TransmitFile(path, 0, fileSize);
|
|
System.Web.HttpContext.Current.Response.Flush();
|
|
System.Web.HttpContext.Current.Response.Close();
|
|
File.Delete(path);
|
|
|
|
|
|
}
|
|
protected void btnSync_Click(object sender, EventArgs e)
|
|
{
|
|
string templatePath = Funs.RootPath + @"File\Excel\DataOut\WeldingPlanDataOut.xlsx";
|
|
string path = Funs.RootPath + @"File\Excel\DataOut\WeldingPlanDataOut.xlsx";
|
|
path = path.Replace(".xlsx", string.Format("{0:yyyy-MM-dd-HH-mm}", DateTime.Now) + ".xlsx");
|
|
|
|
string strSql = @"SELECT ProjectId,UnitWorkId,PipelineId,PipelineCode,PlanStartDate,PlanEndDate,ActStartDate,ActEndDate,
|
|
WBSId,(CASE WHEN IsFinished='1' THEN '已完成' ELSE '未完成' END) AS IsFinished
|
|
FROM dbo.HJGL_Pipeline
|
|
WHERE ProjectId= @ProjectId";
|
|
List<SqlParameter> listStr = new List<SqlParameter>();
|
|
listStr.Add(new SqlParameter("@ProjectId", this.CurrUser.LoginProjectId));
|
|
|
|
strSql += " AND UnitWorkId =@UnitWorkId";
|
|
listStr.Add(new SqlParameter("@UnitWorkId", this.tvControlItem.SelectedNodeID));
|
|
if (!string.IsNullOrEmpty(this.txtPipelineCode.Text.Trim()))
|
|
{
|
|
strSql += " AND PipelineCode LIKE @PipelineCode";
|
|
listStr.Add(new SqlParameter("@PipelineCode", "%" + this.txtPipelineCode.Text.Trim() + "%"));
|
|
}
|
|
|
|
SqlParameter[] parameter = listStr.ToArray();
|
|
DataTable tb = SQLHelper.GetDataTableRunText(strSql, parameter);
|
|
tb.TableName = "Data";
|
|
var value = new Dictionary<string, object>()
|
|
{
|
|
["Data"] = tb,
|
|
};
|
|
MiniExcel.SaveAsByTemplate(path, templatePath, value);
|
|
string fileName = "施工实施计划.xlsx";
|
|
FileInfo info = new FileInfo(path);
|
|
long fileSize = info.Length;
|
|
System.Web.HttpContext.Current.Response.Clear();
|
|
System.Web.HttpContext.Current.Response.ContentType = "application/x-zip-compressed";
|
|
System.Web.HttpContext.Current.Response.AddHeader("Content-Disposition", "attachment;filename=" + System.Web.HttpUtility.UrlEncode(fileName, System.Text.Encoding.UTF8));
|
|
System.Web.HttpContext.Current.Response.AddHeader("Content-Length", fileSize.ToString());
|
|
System.Web.HttpContext.Current.Response.TransmitFile(path, 0, fileSize);
|
|
System.Web.HttpContext.Current.Response.Flush();
|
|
System.Web.HttpContext.Current.Response.Close();
|
|
File.Delete(path);
|
|
|
|
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region 导入
|
|
protected void btnImportFIELD_Click(object sender, EventArgs e)
|
|
{
|
|
Model.WBS_UnitWork unitWork = BLL.UnitWorkService.GetUnitWorkByUnitWorkId(this.tvControlItem.SelectedNodeID);
|
|
if (unitWork != null)
|
|
{
|
|
PageContext.RegisterStartupScript(Window2.GetShowReference(String.Format("WeldingPlanIn.aspx?UnitWorkId={0}&Type={1}", this.tvControlItem.SelectedNodeID, PipelineService.PipeArea_FIELD, "导入 - ")));
|
|
}
|
|
else
|
|
{
|
|
ShowNotify("请先选择单位工程!", MessageBoxIcon.Warning);
|
|
}
|
|
}
|
|
protected void btnImportSHOP_Click(object sender, EventArgs e)
|
|
{
|
|
Model.WBS_UnitWork unitWork = BLL.UnitWorkService.GetUnitWorkByUnitWorkId(this.tvControlItem.SelectedNodeID);
|
|
if (unitWork != null)
|
|
{
|
|
PageContext.RegisterStartupScript(Window2.GetShowReference(String.Format("WeldingPlanIn.aspx?UnitWorkId={0}&Type={1}", this.tvControlItem.SelectedNodeID, PipelineService.PipeArea_SHOP, "导入 - ")));
|
|
}
|
|
else
|
|
{
|
|
ShowNotify("请先选择单位工程!", MessageBoxIcon.Warning);
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
protected void btnUpDateState_Click(object sender, EventArgs e)
|
|
{
|
|
string unitworkid = this.tvControlItem.SelectedNodeID;
|
|
var pipeline=PipelineService.GetPipelinesByUnitWordId(unitworkid);
|
|
foreach (var item in pipeline)
|
|
{
|
|
BLL.PipelineService.GetStateByPipelineId(item.PipelineId);
|
|
|
|
}
|
|
BindGrid();
|
|
}
|
|
|
|
}
|
|
}
|