773 lines
34 KiB
C#
773 lines
34 KiB
C#
using BLL;
|
|
using FineUIPro.Web.DataShow;
|
|
using Model;
|
|
using Newtonsoft.Json;
|
|
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 int pageSize = PipelineService.pageSize;
|
|
public static decimal Rate = 0;
|
|
public string WarehouseId
|
|
{
|
|
get
|
|
{
|
|
return (string)ViewState["WarehouseId"];
|
|
}
|
|
set
|
|
{
|
|
ViewState["WarehouseId"] = value;
|
|
}
|
|
}
|
|
public string PipeArea
|
|
{
|
|
get
|
|
{
|
|
return (string)ViewState["PipeArea"];
|
|
}
|
|
set
|
|
{
|
|
ViewState["PipeArea"] = value;
|
|
}
|
|
}
|
|
public string Line_No
|
|
{
|
|
get
|
|
{
|
|
return (string)ViewState["Line_No"];
|
|
}
|
|
set
|
|
{
|
|
ViewState["Line_No"] = value;
|
|
}
|
|
}
|
|
public Dictionary<string, string> dicSeclectPipeLine
|
|
{
|
|
get
|
|
{
|
|
return (Dictionary<string, string>)ViewState["dicSeclectPipeLine"];
|
|
}
|
|
set
|
|
{
|
|
ViewState["dicSeclectPipeLine"] = value;
|
|
}
|
|
}
|
|
public List<Model.Tw_PipeMatMatchOutput> tw_PipeMatMatchOutputs
|
|
{
|
|
get
|
|
{
|
|
return (List<Model.Tw_PipeMatMatchOutput>)ViewState["tw_PipeMatMatchOutputs"];
|
|
}
|
|
set
|
|
{
|
|
ViewState["tw_PipeMatMatchOutputs"] = value;
|
|
}
|
|
}
|
|
|
|
|
|
protected void Page_Load(object sender, EventArgs e)
|
|
{
|
|
//ctlAuditFlow.Url = BLL.Project_SysSetService.GetAvevaNetUrl(this.CurrUser.LoginProjectId);
|
|
if (!IsPostBack)
|
|
{
|
|
tw_PipeMatMatchOutputs = new List<Model.Tw_PipeMatMatchOutput>();
|
|
PipeArea = Request.Params["PipeArea"];
|
|
drpWarehouse.DataTextField = "Key";
|
|
drpWarehouse.DataValueField = "Value";
|
|
drpWarehouse.DataSource = BLL.TwInOutplanmasterService.GetWarehouseCode(this.CurrUser.LoginProjectId);
|
|
drpWarehouse.DataBind();
|
|
drpWarehouse_SelectedIndexChanged(null, null);
|
|
; HJGL_MaterialService.materialStockItems_FIELD = new List<Model.MaterialStockItem>();
|
|
HJGL_MaterialService.materialStockItems_SHOP = new List<Model.MaterialStockItem>();
|
|
dicSeclectPipeLine = new Dictionary<string, string>();
|
|
var pipeline = (from x in Funs.DB.HJGL_Pipeline
|
|
where x.ProjectId == this.CurrUser.LoginProjectId
|
|
select x.FlowingSection).Distinct().ToList();
|
|
this.drpFlowingSection.DataTextField = "Value";
|
|
this.drpFlowingSection.DataValueField = "Value";
|
|
this.drpFlowingSection.DataSource = pipeline;
|
|
this.drpFlowingSection.DataBind();
|
|
Funs.FineUIPleaseSelect(drpFlowingSection);
|
|
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;
|
|
rootNode1.EnableCheckBox = false;
|
|
this.tvControlItem.Nodes.Add(rootNode1);
|
|
|
|
TreeNode rootNode2 = new TreeNode();
|
|
rootNode2.NodeID = "2";
|
|
rootNode2.Text = "安装工程";
|
|
rootNode2.CommandName = "安装工程";
|
|
rootNode2.Expanded = true;
|
|
rootNode2.EnableCheckBox = false;
|
|
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 && x.WarehouseId == WarehouseId 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.CommandName = 1 + "|" + Funs.GetEndPageNumber(a, pageSize);
|
|
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 && x.WarehouseId == WarehouseId select x).Count();
|
|
// var NowComPipelineCode = PipelineService.GetNoComPipelinesByUnitWordId(q.UnitWorkId);
|
|
//int a = NowComPipelineCode.Count();
|
|
var unitNamesUnitIds = BLL.UnitService.getUnitNamesUnitIds(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 = "施工单位:" + unitNamesUnitIds;
|
|
tn2.CommandName = 1 + "|" + Funs.GetEndPageNumber(a, pageSize);
|
|
tn2.EnableExpandEvent = true;
|
|
tn2.EnableClickEvent = true;
|
|
tn2.EnableCheckBox = false;
|
|
|
|
rootNode2.Nodes.Add(tn2);
|
|
if (a > 0)
|
|
{
|
|
// BindNodes(tn2);
|
|
TreeNode newNode = new TreeNode();
|
|
newNode.Text = "加载管线...";
|
|
newNode.NodeID = "加载管线...";
|
|
tn2.Nodes.Add(newNode);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
private void BindNodes(TreeNode node)
|
|
{
|
|
//var NowComPipelineCode = PipelineService.GetNoComPipelinesByUnitWordId(node.NodeID);
|
|
//if (!node.Text.Contains("|"))
|
|
//{
|
|
// node.Text += "|" + NowComPipelineCode.Count();
|
|
|
|
//}
|
|
var CompleteInOutPlanDetail_RelationList = from x in Funs.DB.Tw_InOutPlanDetail_Relation
|
|
join y in Funs.DB.Tw_InOutPlanMaster on x.InOutPlanMasterId equals y.Id
|
|
where y.State == (int)TwConst.State.已完成 && y.WarehouseCode == drpWarehouse.SelectedValue
|
|
select x;
|
|
|
|
var pipeline = (from x in Funs.DB.HJGL_Pipeline
|
|
join y in CompleteInOutPlanDetail_RelationList on x.PipelineId equals y.PipelineId into temp
|
|
from y in temp.DefaultIfEmpty()
|
|
where y == null && x.ProjectId == this.CurrUser.LoginProjectId && x.UnitWorkId == node.NodeID
|
|
&& x.PipelineCode.Contains(this.txtPipelineCode.Text.Trim()) && x.WarehouseId==WarehouseId
|
|
orderby x.PipelineCode
|
|
select x).ToList();
|
|
if (!string.IsNullOrEmpty(drpFlowingSection.SelectedValue) && drpFlowingSection.SelectedValue != Const._Null)
|
|
{
|
|
pipeline = pipeline.Where(x => x.FlowingSection == drpFlowingSection.SelectedValue).ToList();
|
|
}
|
|
//pipeline= pipeline.Where(x => NowComPipelineCode.Contains(x.PipelineCode)).ToList();
|
|
if (!node.Text.Contains("|"))
|
|
{
|
|
node.Text += "|" + pipeline.Count();
|
|
|
|
}
|
|
int pageindex = int.Parse(node.CommandName.Split('|')[0]);
|
|
int pageCount = int.Parse(node.CommandName.Split('|')[1]);
|
|
if (pageindex <= pageCount)
|
|
{
|
|
pipeline = pipeline.Skip(pageSize * (pageindex - 1)).Take(pageSize).ToList();
|
|
foreach (var item in pipeline)
|
|
{
|
|
/*if (!NowComPipelineCode.Contains(item.PipelineCode))
|
|
{
|
|
continue;
|
|
}*/
|
|
TreeNode newNode = new TreeNode();
|
|
newNode.Text = item.PipelineCode;
|
|
newNode.NodeID = item.PipelineId;
|
|
newNode.CommandName = "管线";
|
|
newNode.EnableClickEvent = true;
|
|
node.Nodes.Add(newNode);
|
|
}
|
|
if (pageindex < pageCount)
|
|
{
|
|
TreeNode newNode = new TreeNode();
|
|
newNode.Text = "加载";
|
|
newNode.NodeID = SQLHelper.GetNewID();
|
|
newNode.CommandName = "加载";
|
|
newNode.Icon = Icon.ArrowDown;
|
|
newNode.EnableClickEvent = true;
|
|
node.Nodes.Add(newNode);
|
|
}
|
|
}
|
|
}
|
|
|
|
protected void tvControlItem_TreeNodeExpanded(object sender, TreeNodeEventArgs e)
|
|
{
|
|
if (e.Node.Nodes[0].NodeID == "加载管线...")
|
|
{
|
|
e.Node.Nodes.Clear();
|
|
BindNodes(e.Node);
|
|
}
|
|
}
|
|
|
|
#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 (e.CommandName == "加载")
|
|
{
|
|
string CommandName = e.Node.ParentNode.CommandName;
|
|
e.Node.ParentNode.CommandName = (int.Parse(CommandName.Split('|')[0]) + 1) + "|" + int.Parse(CommandName.Split('|')[1]);
|
|
TreeNode treeNode = e.Node.ParentNode;
|
|
treeNode.Nodes.Remove(e.Node);
|
|
BindNodes(e.Node.ParentNode);
|
|
}
|
|
else
|
|
{
|
|
// this.BindGrid();
|
|
|
|
}
|
|
}
|
|
#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();
|
|
}
|
|
void BindGrid2()
|
|
{
|
|
//var result = tw_PipeMatMatchOutputs
|
|
// .GroupBy(item => new { item.PipelineId, item.PipelineCode,item.UnitWorkName }) // 按 PipelineId 和 PipelineCode 分组
|
|
// .Select(group => new
|
|
// {
|
|
// PipelineId = group.Key.PipelineId, // 当前组的 PipelineId
|
|
// PipelineCode = group.Key.PipelineCode, // 当前组的 PipelineCode
|
|
// UnitWorkName = group.Key.UnitWorkName, // 当前组的 UnitWorkName
|
|
// AverageMatchRate = group.Average(item => item.MatchRate) // 计算平均 MatchRate
|
|
// })
|
|
// .ToList(); // 转换为 List
|
|
|
|
//// 如果需要将结果转换为自定义类型,可以这样做
|
|
//List<Tw_PipeMatMatchOutput> output = result.Select(r => new Tw_PipeMatMatchOutput
|
|
//{
|
|
// PipelineId = r.PipelineId,
|
|
// PipelineCode = r.PipelineCode,
|
|
// UnitWorkName = r.UnitWorkName,
|
|
// MatchRate = r.AverageMatchRate,
|
|
// MatchRateString = Math.Round((decimal)r.AverageMatchRate * 100, 2).ToString() + "%"
|
|
//}).ToList();
|
|
var output = TwArrivalStatisticsService.GetPipeMatch(tw_PipeMatMatchOutputs);
|
|
Grid2.DataSource = output;
|
|
Grid2.DataBind();
|
|
/*if (output.Any())
|
|
{
|
|
Rate = Math.Round((decimal)output.Average(item => item.MatchRate) * 100, 2);
|
|
lbRate.Text = "匹配率:" + Rate.ToString() + "%";
|
|
}*/
|
|
var selectList = new List<string>();
|
|
for (int i = 0; i < Grid2.Rows.Count; i++)
|
|
{
|
|
var model = Grid2.Rows[i].DataItem as Tw_PipeMatchOutput;
|
|
|
|
if (model.MatchRate >= 1)
|
|
{
|
|
Grid2.Rows[i].RowCssClass = "green";
|
|
selectList.Add(model.PipelineId);
|
|
|
|
}
|
|
else
|
|
{
|
|
Grid2.Rows[i].RowCssClass = "red";
|
|
}
|
|
|
|
}
|
|
if (cbSelectCom.Checked)
|
|
{
|
|
Grid2.SelectedRowIDArray = selectList.ToArray();
|
|
}
|
|
}
|
|
|
|
void BindGrid3()
|
|
{
|
|
|
|
Grid3.DataSource = dicSeclectPipeLine;
|
|
Grid3.DataBind();
|
|
for (int i = 0; i < Grid3.Rows.Count; i++)
|
|
{
|
|
var model = Grid3.Rows[i].DataItem;
|
|
var model2 = JsonConvert.DeserializeObject<Dictionary<string, string>>(JsonConvert.SerializeObject(model));
|
|
string pipeid = model2.First().Value;
|
|
|
|
var relationModle = TwInoutplandetailRelationService.GetByPipelineId(pipeid, drpWarehouse.SelectedValue);
|
|
if (relationModle != null)
|
|
{
|
|
Grid3.Rows[i].RowCssClass = "yellow";
|
|
}
|
|
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region 表格事件
|
|
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 void Grid2_RowClick(object sender, GridRowClickEventArgs e)
|
|
{
|
|
var tb = tw_PipeMatMatchOutputs.Where(x => x.PipelineId == Grid2.SelectedRowID).ToList();
|
|
Grid1.DataSource = tb;
|
|
Grid1.DataBind();
|
|
for (int i = 0; i < Grid1.Rows.Count; i++)
|
|
{
|
|
var model = Grid1.Rows[i].DataItem as Tw_PipeMatMatchOutput;
|
|
|
|
if (model?.MatchRate < 1 || model?.MatchRate == null)
|
|
{
|
|
Grid1.Rows[i].RowCssClass = "red";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
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;
|
|
parameter3D.ButtonType = "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))
|
|
{
|
|
bool istrue = BLL.HJGL_MaterialService.isInStockByPipeline(tvControlItem.SelectedNodeID, this.CurrUser.LoginProjectId);
|
|
if (istrue)
|
|
{
|
|
Line_No = "/" + modelpipe.PipelineCode;
|
|
}
|
|
// parameter3D.Line_No = Line_No;
|
|
parameter3D.ModelName = HJGL_DataImportService.Getlatest3DModelNameByUnitWorkId(modelpipe.UnitWorkId);
|
|
var pipecode = "/" + modelpipe.PipelineCode;
|
|
parameter3D.TagNum = pipecode;
|
|
}
|
|
|
|
}
|
|
//ctlAuditFlow.Url_item = BLL.Project_SysSetService.GetAvevaNetUrl_Item(this.CurrUser.LoginProjectId) + parameter3D.ModelName;
|
|
//ctlAuditFlow.data = parameter3D;
|
|
//ctlAuditFlow.BindData();
|
|
}
|
|
protected void Grid1_Sort(object sender, GridSortEventArgs e)
|
|
{
|
|
Grid1.SortDirection = e.SortDirection;
|
|
Grid1.SortField = e.SortField;
|
|
BindGrid();
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region 按钮事件
|
|
|
|
protected void btnrefresh_Click(object sender, EventArgs e)
|
|
{
|
|
if (!string.IsNullOrEmpty(this.tvControlItem.SelectedNodeID))
|
|
{
|
|
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 = "3";
|
|
|
|
if (this.tvControlItem.SelectedNode.CommandName.Split('|').Count() == 2)
|
|
{
|
|
parameter3D.ModelName = HJGL_DataImportService.Getlatest3DModelNameByUnitWorkId(tvControlItem.SelectedNodeID);
|
|
var pipeline = (from x in Funs.DB.HJGL_Pipeline
|
|
where x.ProjectId == this.CurrUser.LoginProjectId && x.UnitWorkId == tvControlItem.SelectedNodeID && x.PipeArea == PipeArea && x.WarehouseId == WarehouseId
|
|
orderby x.PipelineCode
|
|
select x).ToList();
|
|
List<string> pipelineList = new List<string>();
|
|
foreach (var item in pipeline)
|
|
{
|
|
bool istrue = BLL.HJGL_MaterialService.isInStockByPipeline(item.PipelineId, this.CurrUser.LoginProjectId);
|
|
if (istrue)
|
|
{
|
|
pipelineList.Add("/" + item.PipelineCode);
|
|
}
|
|
|
|
}
|
|
parameter3D.TagNum = string.Join(",", pipelineList);
|
|
parameter3D.Line_No = string.Join(",", pipelineList);
|
|
}
|
|
else if (this.tvControlItem.SelectedNode.CommandName == "管线")
|
|
{
|
|
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();
|
|
}
|
|
|
|
if (pipeline != null && !string.IsNullOrEmpty(pipeline.UnitWorkId))
|
|
{
|
|
bool istrue = BLL.HJGL_MaterialService.isInStockByPipeline(tvControlItem.SelectedNodeID, this.CurrUser.LoginProjectId);
|
|
if (istrue)
|
|
{
|
|
Line_No = "/" + pipeline.PipelineCode;
|
|
}
|
|
//parameter3D.Line_No = Line_No;
|
|
parameter3D.ModelName = HJGL_DataImportService.Getlatest3DModelNameByUnitWorkId(pipeline.UnitWorkId);
|
|
var pipecode = "/" + pipeline.PipelineCode;
|
|
parameter3D.TagNum = pipecode;
|
|
|
|
}
|
|
}
|
|
|
|
//ctlAuditFlow.Url_item = BLL.Project_SysSetService.GetAvevaNetUrl_Item(this.CurrUser.LoginProjectId) + parameter3D.ModelName;
|
|
//ctlAuditFlow.data = parameter3D;
|
|
//ctlAuditFlow.BindData();
|
|
}
|
|
|
|
}
|
|
|
|
protected void btnStatisticsMat_Click(object sender, EventArgs e)
|
|
{
|
|
Model.WBS_UnitWork unitWork = BLL.UnitWorkService.GetUnitWorkByUnitWorkId(this.tvControlItem.SelectedNodeID);
|
|
if (unitWork != null)
|
|
{
|
|
PageContext.RegisterStartupScript(Window2.GetShowReference(String.Format("WeldMatMatchGet.aspx?UnitWorkId={0}&&PipeArea={1}", this.tvControlItem.SelectedNodeID, PipeArea, "匹配 - ")));
|
|
}
|
|
else
|
|
{
|
|
ShowNotify("请先选择单位工程!", MessageBoxIcon.Warning);
|
|
}
|
|
}
|
|
|
|
protected void btnAddPipelineMatchMat_Click(object sender, EventArgs e)
|
|
{
|
|
var selectNodes = tvControlItem.GetCheckedNodes();
|
|
foreach (var node in selectNodes)
|
|
{
|
|
if (dicSeclectPipeLine.Where(x => x.Key == node.NodeID).Count() == 0 && node.CommandName == "管线")
|
|
{
|
|
dicSeclectPipeLine.Add(node.NodeID, node.Text);
|
|
}
|
|
}
|
|
tw_PipeMatMatchOutputs = TwArrivalStatisticsService.GetPipeMatMatch(this.CurrUser.LoginProjectId, dicSeclectPipeLine.Keys.ToList(), drpWarehouse.SelectedValue);
|
|
|
|
BindGrid3();
|
|
BindGrid2();
|
|
}
|
|
|
|
protected void btnDeletePipelineMatchMat_Click(object sender, EventArgs e)
|
|
{
|
|
if (Grid3.SelectedRowID != "")
|
|
{
|
|
dicSeclectPipeLine.Remove(Grid3.SelectedRowID);
|
|
var node = tvControlItem.FindNode(Grid3.SelectedRowID);
|
|
if (node != null)
|
|
{
|
|
node.Checked = false;
|
|
}
|
|
|
|
tw_PipeMatMatchOutputs = TwArrivalStatisticsService.GetPipeMatMatch(this.CurrUser.LoginProjectId, dicSeclectPipeLine.Keys.ToList(), drpWarehouse.SelectedValue);
|
|
|
|
BindGrid3();
|
|
BindGrid2();
|
|
}
|
|
}
|
|
protected void btnGenTask_Click(object sender, EventArgs e)
|
|
{
|
|
if (Grid2.SelectedRowIDArray.Count() > 0)
|
|
{
|
|
SaveTask();
|
|
ShowNotify("生成任务单成功!", MessageBoxIcon.Warning);
|
|
// Alert.Show("生成任务单成功!", MessageBoxIcon.Warning);
|
|
Grid1.DataSource = null;
|
|
Grid1.DataBind();
|
|
Grid2.DataSource = null;
|
|
Grid2.DataBind();
|
|
Grid3.DataSource = null;
|
|
Grid3.DataBind();
|
|
}
|
|
else
|
|
{
|
|
ShowNotify("请先选择需要发起任单的管线!", MessageBoxIcon.Warning);
|
|
}
|
|
|
|
}
|
|
private void SaveTask()
|
|
{
|
|
var weldingRods = from x in Funs.DB.Base_Consumables where x.ConsumablesType == "2" select x;
|
|
var weldingWires = from x in Funs.DB.Base_Consumables where x.ConsumablesType == "1" select x;
|
|
var selectRowId = (from x in Funs.DB.View_HJGL_NoWeldJointFind
|
|
where Grid2.SelectedRowIDArray.ToList().Contains(x.PipelineId) && x.WeldingDailyId == null &&
|
|
x.WeldTaskId == null && x.WeldingMethodCode != null
|
|
select x).ToList();
|
|
|
|
Dictionary<string, string> unitworkTaskCode = new Dictionary<string, string>();
|
|
Dictionary<string, string> unitworkSerialNumber = new Dictionary<string, string>();
|
|
Dictionary<int, string> matchPipeline = new Dictionary<int, string>();
|
|
foreach (var rowIndex in Grid2.SelectedRowIndexArray)
|
|
{
|
|
matchPipeline.Add(rowIndex + 1, Grid2.Rows[rowIndex].RowID);
|
|
}
|
|
if (PipeArea == "1") //工厂预制的管线,则只选择预制口
|
|
{
|
|
selectRowId = selectRowId.Where(x => x.JointAttribute == "预制口").ToList();
|
|
}
|
|
foreach (var weldjoint in selectRowId)
|
|
{
|
|
string canWeldingRodName = string.Empty;
|
|
string canWeldingWireName = string.Empty;
|
|
Model.HJGL_WeldTask NewTask = new Model.HJGL_WeldTask();
|
|
NewTask.ProjectId = this.CurrUser.LoginProjectId;
|
|
NewTask.UnitWorkId = PipelineService.GetPipelineByPipelineId(weldjoint.PipelineId)?.UnitWorkId;
|
|
NewTask.UnitId = this.CurrUser.UnitId;
|
|
if (unitworkTaskCode.FirstOrDefault(x => x.Key == NewTask.UnitWorkId).Value != null)
|
|
{
|
|
NewTask.TaskCode = unitworkTaskCode.FirstOrDefault(x => x.Key == NewTask.UnitWorkId).Value;
|
|
}
|
|
else
|
|
{
|
|
NewTask.TaskCode = BLL.WeldTaskService.GetTaskCodeByDate(this.CurrUser.LoginProjectId, DateTime.Now.Date.ToString("yyyy-MM-dd"), NewTask.UnitWorkId, this.CurrUser.UnitId);
|
|
unitworkTaskCode.Add(NewTask.UnitWorkId, NewTask.TaskCode);
|
|
}
|
|
|
|
if (unitworkSerialNumber.FirstOrDefault(x => x.Key == NewTask.UnitWorkId).Value != null)
|
|
{
|
|
NewTask.SerialNumber = unitworkSerialNumber.FirstOrDefault(x => x.Key == NewTask.UnitWorkId).Value;
|
|
}
|
|
else
|
|
{
|
|
NewTask.SerialNumber = BLL.WeldTaskService.GetSerialNumberByDate(this.CurrUser.LoginProjectId, DateTime.Now.Date.ToString("yyyy-MM-dd"), NewTask.UnitWorkId, this.CurrUser.UnitId);
|
|
unitworkSerialNumber.Add(NewTask.UnitWorkId, NewTask.SerialNumber);
|
|
}
|
|
|
|
NewTask.WeldTaskId = SQLHelper.GetNewID();
|
|
NewTask.WeldJointId = weldjoint.WeldJointId;
|
|
var oldWeldTask = BLL.WeldTaskService.GetWeldTaskByWeldJointId(NewTask.WeldJointId);
|
|
if (oldWeldTask != null)
|
|
{
|
|
ShowNotify("所选焊口已存在任务单,无法保存!", MessageBoxIcon.Warning);
|
|
return;
|
|
}
|
|
Model.HJGL_WeldJoint weldJoint = BLL.WeldJointService.GetWeldJointByWeldJointId(NewTask.WeldJointId);
|
|
if (weldJoint != null)
|
|
{
|
|
NewTask.PipeLineSortIndex = matchPipeline.FirstOrDefault(x => x.Value == weldJoint.PipelineId).Key;
|
|
NewTask.WeldingRod = weldJoint.WeldingRod;
|
|
NewTask.WeldingWire = weldJoint.WeldingWire;
|
|
//获取可替代焊丝焊条
|
|
var mat = BLL.Base_MaterialService.GetMaterialByMaterialId(weldJoint.Material1Id);
|
|
string matClass = mat.MaterialClass;
|
|
var matRod = weldingRods.FirstOrDefault(x => x.ConsumablesId == weldJoint.WeldingRod);
|
|
if (matRod != null)
|
|
{
|
|
foreach (var item in weldingRods)
|
|
{
|
|
if (matClass == "Fe-1" || matClass == "Fe-3")
|
|
{
|
|
if (IsCoverClass(matRod.SteelType, item.SteelType))
|
|
{
|
|
canWeldingRodName = canWeldingRodName + item.ConsumablesName + ",";
|
|
}
|
|
}
|
|
else
|
|
{
|
|
if (matRod.SteelType == item.SteelType)
|
|
{
|
|
canWeldingRodName = canWeldingRodName + item.ConsumablesName + ",";
|
|
}
|
|
}
|
|
}
|
|
if (!string.IsNullOrEmpty(canWeldingRodName))
|
|
{
|
|
NewTask.CanWeldingRodName = canWeldingRodName.Substring(0, canWeldingRodName.Length - 1);
|
|
}
|
|
}
|
|
var matWire = weldingWires.FirstOrDefault(x => x.ConsumablesId == weldJoint.WeldingWire);
|
|
if (matWire != null)
|
|
{
|
|
foreach (var item in weldingWires)
|
|
{
|
|
if (matClass == "Fe-1" || matClass == "Fe-3")
|
|
{
|
|
if (IsCoverClass(matWire.SteelType, item.SteelType))
|
|
{
|
|
canWeldingWireName = canWeldingWireName + item.ConsumablesName + ",";
|
|
}
|
|
}
|
|
else
|
|
{
|
|
if (matWire.SteelType == item.SteelType)
|
|
{
|
|
canWeldingWireName = canWeldingWireName + item.ConsumablesName + ",";
|
|
}
|
|
}
|
|
}
|
|
if (!string.IsNullOrEmpty(canWeldingWireName))
|
|
{
|
|
NewTask.CanWeldingWireName = canWeldingWireName.Substring(0, canWeldingWireName.Length - 1);
|
|
}
|
|
}
|
|
}
|
|
NewTask.JointAttribute = weldJoint.JointAttribute;
|
|
|
|
NewTask.TaskDate = DateTime.Now.Date;
|
|
NewTask.Tabler = this.CurrUser.PersonId;
|
|
NewTask.TableDate = DateTime.Now;
|
|
|
|
weldJoint.WeldingMode = "手动";
|
|
BLL.WeldJointService.UpdateWeldJoint(weldJoint);
|
|
BLL.WeldTaskService.AddWeldTask(NewTask);
|
|
}
|
|
|
|
}
|
|
private bool IsCoverClass(string wpsClass, string matClass)
|
|
{
|
|
bool isCover = false;
|
|
int wpsSn = 0;
|
|
int matSn = 0;
|
|
if (wpsClass.Length > 2 && matClass.Length > 2)
|
|
{
|
|
string wpsPre = wpsClass.Substring(0, wpsClass.Length - 2);
|
|
string matPre = matClass.Substring(0, matClass.Length - 2);
|
|
|
|
string wps = wpsClass.Substring(wpsClass.Length - 1, 1);
|
|
wpsSn = Funs.GetNewInt(wps).HasValue ? Funs.GetNewInt(wps).Value : 0;
|
|
|
|
string mat = matClass.Substring(matClass.Length - 1, 1);
|
|
matSn = Funs.GetNewInt(mat).HasValue ? Funs.GetNewInt(mat).Value : 0;
|
|
|
|
if (wpsPre == matPre && matSn >= wpsSn)
|
|
{
|
|
return true;
|
|
}
|
|
}
|
|
return isCover;
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
|
protected void drpWarehouse_SelectedIndexChanged(object sender, EventArgs e)
|
|
{
|
|
WarehouseId = Base_WarehouseService.GetWarehouseList(this.CurrUser.LoginProjectId).Where(x => x.WarehouseName == drpWarehouse.SelectedValue).Select(x => x.WarehouseId).FirstOrDefault();
|
|
this.InitTreeMenu();//加载树
|
|
}
|
|
}
|
|
} |