2023-07-28 11:14:32 +08:00
|
|
|
|
using BLL;
|
|
|
|
|
using Model;
|
|
|
|
|
using Newtonsoft.Json.Linq;
|
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Web;
|
|
|
|
|
using System.Web.UI;
|
|
|
|
|
using System.Web.UI.WebControls;
|
|
|
|
|
|
|
|
|
|
namespace FineUIPro.Web.TestRun.BeforeTestRun
|
|
|
|
|
{
|
|
|
|
|
public partial class SubWorkInspect : PageBase
|
|
|
|
|
{
|
|
|
|
|
protected void Page_Load(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (!IsPostBack)
|
|
|
|
|
{
|
|
|
|
|
this.InitTreeMenu();//加载树
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#region 树绑定
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 加载树
|
|
|
|
|
/// </summary>
|
|
|
|
|
private void InitTreeMenu()
|
|
|
|
|
{
|
|
|
|
|
this.tvControlItem.Nodes.Clear();
|
|
|
|
|
TreeNode rootNode = new TreeNode();
|
|
|
|
|
rootNode.Text = "检查表";
|
|
|
|
|
rootNode.NodeID = "0";
|
|
|
|
|
rootNode.Expanded = true;
|
|
|
|
|
rootNode.ToolTip = "";
|
|
|
|
|
rootNode.EnableClickEvent = true;
|
|
|
|
|
this.tvControlItem.Nodes.Add(rootNode);
|
|
|
|
|
var userSubInspects = Funs.DB.PreRun_SubInspectTermItem.Where(x => x.InspectedUser == this.CurrUser.UserId).ToList();
|
|
|
|
|
if (userSubInspects.Count == 0) return;
|
|
|
|
|
var subSystemIds = userSubInspects.ConvertAll(x => x.SubSystemId);
|
|
|
|
|
var workPackIds = userSubInspects.ConvertAll(x => x.WorkPackId);
|
|
|
|
|
|
|
|
|
|
var list = from a in Funs.DB.PreRun_SysDevice
|
|
|
|
|
join b in Funs.DB.PreRun_SubSysWorkPackage on a.PreRunId equals b.SubSystemId
|
|
|
|
|
join c in Funs.DB.PreRun_WorkPackage on b.WorkPackId equals c.WorkPackId
|
|
|
|
|
where a.ProjectId == this.CurrUser.LoginProjectId && subSystemIds.Contains(a.PreRunId) && workPackIds.Contains(c.WorkPackId)
|
2023-08-04 11:19:37 +08:00
|
|
|
|
select new { a.PreRunId, a.PreRunCode, a.PreRunName, a.ProjectId, c.WorkPackId, c.WorkPackName };
|
2023-07-28 11:14:32 +08:00
|
|
|
|
if (list.Count() > 0)
|
|
|
|
|
{
|
2023-09-19 16:12:26 +08:00
|
|
|
|
var selectlist = new List<SelectPropertyTechnology>();
|
|
|
|
|
var sysPipingData = from proper in Funs.DB.PreRun_PropertySysPiping
|
|
|
|
|
join selectproper in Funs.DB.PreRun_SubPropertySelect on proper.PropertyId equals selectproper.PropertyId
|
|
|
|
|
join inspectterm in Funs.DB.PreRun_SubInspectTerm on selectproper.PropertyId equals inspectterm.PropertyTechnologyId
|
|
|
|
|
where subSystemIds.Contains(selectproper.SubSystemId)
|
|
|
|
|
select new SelectPropertyTechnology()
|
|
|
|
|
{
|
|
|
|
|
Id = proper.PropertyId,
|
|
|
|
|
Code = $"管道:({proper.PipingCode})",
|
|
|
|
|
WorkPackId = inspectterm.WorkPackId,
|
|
|
|
|
SubSystemId = selectproper.SubSystemId
|
|
|
|
|
};
|
|
|
|
|
if (sysPipingData.Count() > 0)
|
|
|
|
|
{
|
|
|
|
|
selectlist.AddRange(sysPipingData);
|
|
|
|
|
}
|
|
|
|
|
var technologylist = from technology in Funs.DB.PreRun_TechnologySysPiping
|
|
|
|
|
join selecttechnology in Funs.DB.PreRun_SubTechnologySelect on technology.TechnologyId equals selecttechnology.TechnologyId
|
|
|
|
|
join inspectterm in Funs.DB.PreRun_SubInspectTerm on selecttechnology.TechnologyId equals inspectterm.PropertyTechnologyId
|
|
|
|
|
where subSystemIds.Contains(selecttechnology.SubSystemId)
|
|
|
|
|
select new SelectPropertyTechnology()
|
|
|
|
|
{
|
|
|
|
|
Id = technology.TechnologyId,
|
|
|
|
|
Code = $"设备:({technology.TagNumber})",
|
|
|
|
|
WorkPackId = inspectterm.WorkPackId,
|
|
|
|
|
SubSystemId = selecttechnology.SubSystemId
|
|
|
|
|
};
|
|
|
|
|
if (technologylist.Count() > 0)
|
|
|
|
|
{
|
|
|
|
|
selectlist.AddRange(technologylist);
|
|
|
|
|
}
|
2023-07-28 11:14:32 +08:00
|
|
|
|
var subList = list.GroupBy(x => new { x.PreRunId, x.PreRunCode, x.PreRunName });
|
|
|
|
|
foreach (var item in subList)
|
|
|
|
|
{
|
|
|
|
|
TreeNode rootUnitNode = new TreeNode();//定义根节点
|
|
|
|
|
rootUnitNode.NodeID = item.Key.PreRunId;
|
|
|
|
|
rootUnitNode.Text = item.Key.PreRunName;
|
|
|
|
|
rootUnitNode.ToolTip = item.Key.PreRunName;
|
|
|
|
|
rootUnitNode.CommandName = "";
|
2023-09-19 16:12:26 +08:00
|
|
|
|
rootUnitNode.EnableClickEvent = false;
|
|
|
|
|
rootUnitNode.EnableExpandEvent = false;
|
2023-07-28 11:14:32 +08:00
|
|
|
|
rootNode.Nodes.Add(rootUnitNode);
|
|
|
|
|
rootUnitNode.Expanded = true;
|
2023-08-04 11:19:37 +08:00
|
|
|
|
var worklist = list.Where(a => a.PreRunId == item.Key.PreRunId).GroupBy(x => new { x.WorkPackId, x.WorkPackName }).ToList();
|
2023-07-28 11:14:32 +08:00
|
|
|
|
if (worklist.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
foreach (var itemWork in worklist)
|
|
|
|
|
{
|
|
|
|
|
TreeNode newNode = new TreeNode();
|
|
|
|
|
newNode.Text = itemWork.Key.WorkPackName;
|
|
|
|
|
newNode.NodeID = itemWork.Key.WorkPackId + "|" + item.Key.PreRunId;
|
|
|
|
|
newNode.ToolTip = itemWork.Key.WorkPackName;
|
|
|
|
|
newNode.CommandName = "";
|
2023-09-19 16:12:26 +08:00
|
|
|
|
newNode.EnableClickEvent = false;
|
|
|
|
|
newNode.EnableExpandEvent = false;
|
2023-07-28 11:14:32 +08:00
|
|
|
|
rootUnitNode.Nodes.Add(newNode);
|
2023-09-19 16:12:26 +08:00
|
|
|
|
newNode.Expanded = true;
|
|
|
|
|
if (selectlist.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
var workselects = selectlist.Where(x => x.SubSystemId == item.Key.PreRunId && x.WorkPackId == itemWork.Key.WorkPackId);
|
|
|
|
|
foreach (var itemSelect in workselects)
|
|
|
|
|
{
|
|
|
|
|
TreeNode newNodeSelect = new TreeNode();
|
|
|
|
|
newNodeSelect.Text = itemSelect.Code;
|
|
|
|
|
newNodeSelect.NodeID = itemWork.Key.WorkPackId + "|" + item.Key.PreRunId + "|" + itemSelect.Id;
|
|
|
|
|
newNodeSelect.ToolTip = itemSelect.Code;
|
|
|
|
|
newNodeSelect.CommandName = "";
|
|
|
|
|
newNodeSelect.EnableClickEvent = true;
|
|
|
|
|
newNodeSelect.EnableExpandEvent = true;
|
|
|
|
|
newNode.Nodes.Add(newNodeSelect);
|
|
|
|
|
newNodeSelect.Expanded = true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2023-07-28 11:14:32 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 点击TreeView
|
|
|
|
|
/// </summary>
|
|
|
|
|
protected void tvControlItem_NodeCommand(object sender, TreeCommandEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
this.BindGrid();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 数据绑定
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 绑定数据
|
|
|
|
|
/// </summary>
|
|
|
|
|
public void BindGrid()
|
|
|
|
|
{
|
|
|
|
|
var workPackId = this.tvControlItem.SelectedNodeID.Split('|').First();
|
2023-09-19 16:12:26 +08:00
|
|
|
|
var subSystemId = this.tvControlItem.SelectedNodeID.Split('|')[1];
|
|
|
|
|
var propertytechnologyid = this.tvControlItem.SelectedNodeID.Split('|').Last();
|
2023-07-28 11:14:32 +08:00
|
|
|
|
//获取子系统
|
|
|
|
|
var subSysModel = Funs.DB.PreRun_SysDevice.FirstOrDefault(x => x.PreRunId == subSystemId);
|
2023-09-19 16:12:26 +08:00
|
|
|
|
var list = Funs.DB.PreRun_SubInspectTermItem.Where(x => x.WorkPackId == workPackId && x.SubSystemId == subSystemId && x.PropertyTechnologyId == propertytechnologyid && x.InspectedUser == this.CurrUser.UserId).OrderBy(x => x.Sort).ToList();
|
2023-07-28 11:14:32 +08:00
|
|
|
|
Grid1.DataSource = list;
|
|
|
|
|
Grid1.DataBind();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 排序
|
|
|
|
|
/// </summary>
|
|
|
|
|
protected void Grid1_Sort(object sender, GridSortEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
Grid1.SortDirection = e.SortDirection;
|
|
|
|
|
Grid1.SortField = e.SortField;
|
|
|
|
|
BindGrid();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
2023-09-19 16:12:26 +08:00
|
|
|
|
#region 保存
|
|
|
|
|
|
2023-07-28 11:14:32 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// 保存
|
|
|
|
|
/// </summary>
|
|
|
|
|
protected void btnSave_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
JArray mergedData = Grid1.GetMergedData();
|
|
|
|
|
foreach (JObject mergedRow in mergedData)
|
|
|
|
|
{
|
|
|
|
|
string status = mergedRow.Value<string>("status");
|
|
|
|
|
JObject values = mergedRow.Value<JObject>("values");
|
|
|
|
|
int i = mergedRow.Value<int>("index");
|
|
|
|
|
var subItemId = this.Grid1.Rows[i].DataKeys[0].ToString();
|
|
|
|
|
//获取子系统信息
|
2023-09-19 16:12:26 +08:00
|
|
|
|
var model = Funs.DB.PreRun_SubInspectTermItem.FirstOrDefault(x => x.TermItemId == subItemId);
|
2023-07-28 11:14:32 +08:00
|
|
|
|
if (model != null)
|
|
|
|
|
{
|
|
|
|
|
model.InspectionIllustrate = !string.IsNullOrWhiteSpace(values.Value<string>("InspectionIllustrate")) ? values.Value<string>("InspectionIllustrate") : string.Empty;
|
2023-09-19 16:12:26 +08:00
|
|
|
|
if (!string.IsNullOrWhiteSpace(values.Value<string>("InspectionResults")))
|
|
|
|
|
{
|
|
|
|
|
model.InspectionResults = int.Parse(values.Value<string>("InspectionResults"));
|
|
|
|
|
}
|
2023-07-28 11:14:32 +08:00
|
|
|
|
Funs.DB.SubmitChanges();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
BindGrid();
|
|
|
|
|
ShowNotify("保存成功!");
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
ShowNotify(ex.Message, MessageBoxIcon.Error);
|
|
|
|
|
}
|
|
|
|
|
}
|
2023-09-19 16:12:26 +08:00
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 子系统选择的管道/设备
|
|
|
|
|
/// </summary>
|
|
|
|
|
public class SelectPropertyTechnology
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 主键
|
|
|
|
|
/// </summary>
|
|
|
|
|
public string Id { get; set; }
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 编码
|
|
|
|
|
/// </summary>
|
|
|
|
|
public string Code { get; set; }
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 工作包主键
|
|
|
|
|
/// </summary>
|
|
|
|
|
public string WorkPackId { get; set; }
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 子系统主键
|
|
|
|
|
/// </summary>
|
|
|
|
|
public string SubSystemId { get; set; }
|
|
|
|
|
}
|
|
|
|
|
|
2023-07-28 11:14:32 +08:00
|
|
|
|
}
|
|
|
|
|
}
|