using BLL; using MiniExcelLibs; using Model; using System; using System.Collections.Generic; using System.Data; using System.IO; using System.Linq; namespace FineUIPro.Web.HJGL.InfoQuery { public partial class PipelineQuery : PageBase { public string Line_No { get { return (string)ViewState["Completed_pipeline"]; } set { ViewState["Completed_pipeline"] = value; } } public static List View_HJGL_Pipeline = new List(); //public string Incomplete_pipeline //{ // get // { // return (string)ViewState["Incomplete_pipeline"]; // } // set // { // ViewState["Incomplete_pipeline"] = 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();//加载树 } } #region 加载树装置-单位-工作区 /// /// 加载树 /// 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 unitWork1 = null; List 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 /// /// 点击TreeView /// /// /// protected void tvControlItem_NodeCommand(object sender, TreeCommandEventArgs e) { this.BindGrid(); } #endregion #region 数据绑定 /// /// 数据绑定 /// private void BindGrid() { // string strSql = @"SELECT ProjectId,UnitWorkId,PipelineId,PipelineCode,UnitName,MediumCode,MediumName,PipingClassCode,UnitWorkCode,SingleName, // TestPressure,SingleNumber,DetectionRateCode,DetectionType,Remark,TestMediumCode,TotalDin,FinishSize, // JointCount,PressurePipingClassCode,PipeLenth,DesignPress,DesignTemperature,LeakPressure,VacuumPressure, // LeakMediumName,PCMediumName,MaterialCode,FinishedDate, //(CASE WHEN IsFinished=1 THEN '已完成' ELSE '未完成' END) AS IsFinished // FROM dbo.View_HJGL_Pipeline // WHERE ProjectId= @ProjectId"; // List listStr = new List(); // 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() + "%")); // } // if (drpIsFinish.SelectedValue == "1") // { // strSql += " AND pipe.IsFinished = 1"; // } // if (drpIsFinish.SelectedValue == "0") // { // strSql += " AND (pipe.IsFinished IS NULL OR pipe.IsFinished = 0)"; // } // SqlParameter[] parameter = listStr.ToArray(); // DataTable tb = SQLHelper.GetDataTableRunText(strSql, parameter); Model.View_HJGL_Pipeline view_HJGL_Pipeline = new Model.View_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.IsFinished = null; if (drpIsFinish.SelectedValue == "1") { view_HJGL_Pipeline.IsFinished = true; } if (drpIsFinish.SelectedValue == "0") { view_HJGL_Pipeline.IsFinished = false; } var list = BLL.PipelineService.GetView_HJGL_Pipelines(view_HJGL_Pipeline); View_HJGL_Pipeline = list; get3DParmeter_pipeline(list); // 2.获取当前分页数据 //var table = this.GetPagedDataTable(Grid1, tb1); Grid1.RecordCount = list.Count; //tb = GetFilteredTable(Grid1.FilteredData, tb); var table = this.GetPagedDataTable(Grid1, list); Grid1.DataSource = table; Grid1.DataBind(); } #endregion private void get3DParmeter_pipeline(List view_HJGL_Pipelines) { if (view_HJGL_Pipelines.Any()) { var q = view_HJGL_Pipelines.Where(x => x.IsFinished == true);//获取已完成管线 if (q.Any()) { List Completed_pipelineList = new List(); foreach (var item in q) { Completed_pipelineList.Add("/" + item.PipelineCode); } Line_No = string.Join(",", Completed_pipelineList); } //var q1 = view_HJGL_Pipelines.Where(x => x.IsFinished != true);//获取未完成管线 //if (q1.Any()) //{ // List Incomplete_pipelineList = new List(); // foreach (var item in q1) // { // Incomplete_pipelineList.Add("/" + item.PipelineCode); // } // Incomplete_pipeline = string.Join(",", Incomplete_pipelineList); //} } } #region 分页排序 #region 页索引改变事件 /// /// 页索引改变事件 /// /// /// protected void Grid1_PageIndexChange(object sender, GridPageEventArgs e) { Grid1.PageIndex = e.NewPageIndex; BindGrid(); } #endregion #region 排序 /// /// 排序 /// /// /// protected void Grid1_Sort(object sender, GridSortEventArgs e) { Grid1.SortDirection = e.SortDirection; Grid1.SortField = e.SortField; BindGrid(); } #endregion #region 分页选择下拉改变事件 /// /// 分页选择下拉改变事件 /// /// /// protected void ddlPageSize_SelectedIndexChanged(object sender, EventArgs e) { Grid1.PageSize = Convert.ToInt32(ddlPageSize.SelectedValue); BindGrid(); } #endregion #endregion #region 查询页面 /// /// 查询 /// /// /// protected void btnQuery_Click(object sender, EventArgs e) { this.BindGrid(); } /// /// 查询 /// /// /// protected void Tree_TextChanged(object sender, EventArgs e) { this.InitTreeMenu(); this.BindGrid(); } #endregion #region 导出按钮 /// 导出按钮 /// /// /// protected void btnOut_Click(object sender, EventArgs e) { string path = Funs.RootPath + @"File\Excel\Temp\pipelineQuery.xlsx"; path = path.Replace(".xlsx", string.Format("{0:yyyy-MM-dd-HH-mm}", DateTime.Now) + ".xlsx"); var q = (from x in View_HJGL_Pipeline select new { 管线号 = x.PipelineCode, 是否完成 = x.IsFinished, 完成日期 = x.FinishedDate, 完成达因 = x.FinishSize, 完成焊口 = x.FinishJointCount, 总达因数 = x.TotalDin, 总焊口量 = x.JointCount, 预制口量 = x.ShopJointCount, 管线划分 = x.PipeAreaStr, 无损检测类型 = x.DetectionTypeCode, 探伤比例 = x.DetectionRateCode, 介质名称 = x.MediumName, 管道等级 = x.PipingClassCode, 图纸名称 = x.SingleName, 单线图号 = x.SingleNumber, 设计压力 = x.DesignPress, 设计温度 = x.DesignTemperature, 压力试验介质 = x.TestMediumCode, 压力试验压力 = x.TestPressure, 压力管道级别 = x.PressurePipingClassCode, 管线长度 = x.PipeLenth, 泄露试验介质 = x.LeakMediumName, 泄露试验压力 = x.LeakPressure, 吹洗要求 = x.PCMediumName, 真空试验压力 = x.VacuumPressure, 材质 = x.MaterialCode, 备注 = x.Remark }).ToList(); MiniExcel.SaveAs(path, q); 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); //Response.ClearContent(); //string filename = Funs.GetNewFileName(); //Response.AddHeader("content-disposition", "attachment; filename=" + System.Web.HttpUtility.UrlEncode("管线信息总览" + filename, System.Text.Encoding.UTF8) + ".xls"); //Response.ContentType = "application/excel"; //Response.ContentEncoding = System.Text.Encoding.UTF8; ////this.Grid1.PageSize = this.; //BindGrid(); //Response.Write(GetGridTableHtml(Grid1)); //Response.End(); } //#pragma warning disable CS0108 // “PersonList.GetGridTableHtml(Grid)”隐藏继承的成员“PageBase.GetGridTableHtml(Grid)”。如果是有意隐藏,请使用关键字 new。 // /// // /// 导出方法 // /// // /// // /// // private string GetGridTableHtml(Grid grid) //#pragma warning restore CS0108 // “PersonList.GetGridTableHtml(Grid)”隐藏继承的成员“PageBase.GetGridTableHtml(Grid)”。如果是有意隐藏,请使用关键字 new。 // { // StringBuilder sb = new StringBuilder(); // sb.Append(""); // sb.Append(""); // sb.Append(""); // foreach (GridColumn column in grid.Columns) // { // sb.AppendFormat("", column.HeaderText); // } // sb.Append(""); // foreach (GridRow row in grid.Rows) // { // sb.Append(""); // foreach (GridColumn column in grid.Columns) // { // string html = row.Values[column.ColumnIndex].ToString(); // if (column.ColumnID == "tfNumber") // { // html = (row.FindControl("labNumber") as AspNet.Label).Text; // } // if (column.ColumnID == "tfI") // { // html = (row.FindControl("lbI") as AspNet.Label).Text; // } // //sb.AppendFormat("", html); // sb.AppendFormat("", html); // } // sb.Append(""); // } // sb.Append("
{0}
{0}{0}
"); // return sb.ToString(); // } #endregion protected string ConvertDetectionType(object detectionType) { string detectionName = string.Empty; if (detectionType != null) { string[] types = detectionType.ToString().Split('|'); foreach (string t in types) { var type = BLL.Base_DetectionTypeService.GetDetectionTypeByDetectionTypeId(t); if (type != null) { detectionName += type.DetectionTypeCode + ","; } } } if (detectionName != string.Empty) { return detectionName.Substring(0, detectionName.Length - 1); } else { return ""; } } protected string ConvertIsFinished(object IsFinished) { string IsFinishedValue = "未完成"; if (IsFinished != null) { if (IsFinished.ToString() == "True") { IsFinishedValue = "已完成"; } } return IsFinishedValue; } protected void btnGetChart_Click(object sender, EventArgs e) { decimal PipelineComplete = 0; decimal PipelineNoComplete = 0; if (!string.IsNullOrEmpty(tvControlItem.SelectedNodeID)) { var allline = (from x in Funs.DB.HJGL_Pipeline where x.UnitWorkId == tvControlItem.SelectedNodeID select x).ToList().Count(); var Completeline = (from x in Funs.DB.HJGL_Pipeline where x.UnitWorkId == tvControlItem.SelectedNodeID && x.IsFinished == true select x).ToList().Count(); int NoCompleteline = allline - Completeline; PipelineComplete = Completeline; PipelineNoComplete = NoCompleteline; } PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("PipelineQueryChart.aspx?PipelineComplete={0}&&PipelineNOComplete={1}", PipelineComplete, PipelineNoComplete, "编辑 - "))); } protected void btnSinglePreview_Click(object sender, EventArgs e) { //string httpUrl = @"FileUpload\HJGL_DataImport\095e9691-99c2-4f70-8e67-e70c8fa6be9c\2022-06\管道焊接工作记录.pdf"; //var newurl = Funs.SGGLUrl + httpUrl.Replace(Funs.RootPath, ""); var id = Grid1.SelectedRowID; if (string.IsNullOrEmpty(id)) { ShowNotify("请选择相对应的ISO轴测图", MessageBoxIcon.Warning); return; } var SingleName = (from x in Funs.DB.View_HJGL_Pipeline where x.PipelineId == id select (x.SingleName)).FirstOrDefault(); var filemodel = BLL.HJGL_DataImportService.GetLatestFileByFileName(SingleName, "0", this.CurrUser.LoginProjectId); if (filemodel != null) { string httpUrl = filemodel.FilePath; PageContext.RegisterStartupScript(Window2.GetShowReference(String.Format("~/AttachFile/Look.aspx?fileUrl={0}", httpUrl, "查看 -"))); } else { ShowNotify("请上传相关ISO轴测图", MessageBoxIcon.Warning); return; } } protected void Grid1_RowClick(object sender, GridRowClickEventArgs e) { var q = PipelineService.GetPipelineByPipelineId(Grid1.SelectedRowID); 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 = "2"; parameter3D.ModelName = HJGL_DataImportService.Getlatest3DModelNameByUnitWorkId(tvControlItem.SelectedNodeID); //parameter3D.Line_No = Line_No; parameter3D.Transparency = colorModel.PipelineComplete; parameter3D.Finished_color = colorModel.JointCompleteColor; parameter3D.Incomplete_color = colorModel.JointNOCompleteColor; ctlAuditFlow.Url_item = BLL.Project_SysSetService.GetAvevaNetUrl_Item(this.CurrUser.LoginProjectId) + parameter3D.ModelName; ctlAuditFlow.data = parameter3D; ctlAuditFlow.BindData(); } protected void btnSinglePreview_2_Click(object sender, EventArgs e) { var id = Grid1.SelectedRowID; if (string.IsNullOrEmpty(id)) { ShowNotify("请选择相对应的ISO施工轴测图", MessageBoxIcon.Warning); return; } var SingleName = (from x in Funs.DB.View_HJGL_Pipeline where x.PipelineId == id select (x.SingleName)).FirstOrDefault(); var filemodel = BLL.HJGL_DataImportService.GetLatestFileByFileName(SingleName, "4", this.CurrUser.LoginProjectId); if (filemodel != null) { string httpUrl = filemodel.FilePath; PageContext.RegisterStartupScript(Window2.GetShowReference(String.Format("~/AttachFile/Look.aspx?fileUrl={0}", httpUrl, "查看 -"))); } else { ShowNotify("请上传相关ISO施工轴测图", MessageBoxIcon.Warning); return; } } protected void btnrefresh_Click(object sender, EventArgs e) { 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 = "2"; parameter3D.ModelName = HJGL_DataImportService.Getlatest3DModelNameByUnitWorkId(tvControlItem.SelectedNodeID); // parameter3D.Line_No = Line_No; parameter3D.Transparency = colorModel.PipelineComplete; parameter3D.Finished_color = colorModel.JointCompleteColor; parameter3D.Incomplete_color = colorModel.JointNOCompleteColor; ctlAuditFlow.Url_item = BLL.Project_SysSetService.GetAvevaNetUrl_Item(this.CurrUser.LoginProjectId) + parameter3D.ModelName; ctlAuditFlow.data = parameter3D; ctlAuditFlow.BindData(); } } }