2022-09-05 16:36:31 +08:00
using BLL ;
2026-03-05 19:26:42 +08:00
using FineUIPro.Web.DataShow ;
2024-09-27 18:17:21 +08:00
using Model ;
2024-10-09 17:20:12 +08:00
using Newtonsoft.Json ;
2026-06-26 00:40:55 +08:00
using Newtonsoft.Json.Linq ;
2022-09-05 16:36:31 +08:00
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
{
2023-02-20 10:49:51 +08:00
public int pageSize = PipelineService . pageSize ;
2025-10-10 14:33:21 +08:00
public static decimal Rate = 0 ;
2026-03-05 19:26:42 +08:00
public string WarehouseId
2024-12-06 22:17:50 +08:00
{
get
{
2026-03-05 19:26:42 +08:00
return ( string ) ViewState [ "WarehouseId" ] ;
2024-12-06 22:17:50 +08:00
}
set
{
2026-03-05 19:26:42 +08:00
ViewState [ "WarehouseId" ] = value ;
2024-12-06 22:17:50 +08:00
}
}
2022-09-05 16:36:31 +08:00
public string PipeArea
{
get
{
return ( string ) ViewState [ "PipeArea" ] ;
}
set
{
ViewState [ "PipeArea" ] = value ;
}
}
2022-10-28 17:01:51 +08:00
public string Line_No
{
get
{
return ( string ) ViewState [ "Line_No" ] ;
}
set
{
ViewState [ "Line_No" ] = value ;
}
}
2024-09-27 18:17:21 +08:00
public Dictionary < string , string > dicSeclectPipeLine
{
get
{
return ( Dictionary < string , string > ) ViewState [ "dicSeclectPipeLine" ] ;
}
set
{
ViewState [ "dicSeclectPipeLine" ] = value ;
}
}
2024-12-06 22:17:50 +08:00
public List < Model . Tw_PipeMatMatchOutput > tw_PipeMatMatchOutputs
{
get
{
return ( List < Model . Tw_PipeMatMatchOutput > ) ViewState [ "tw_PipeMatMatchOutputs" ] ;
}
set
{
ViewState [ "tw_PipeMatMatchOutputs" ] = value ;
}
}
2026-06-11 10:39:58 +08:00
public Dictionary < string , HashSet < string > > priorityWeldJoints
2026-05-27 12:01:30 +08:00
{
get
{
2026-06-11 10:39:58 +08:00
var value = ViewState [ "priorityWeldJoints" ] as Dictionary < string , HashSet < string > > ;
2026-05-27 12:01:30 +08:00
if ( value = = null )
{
value = new Dictionary < string , HashSet < string > > ( ) ;
2026-06-11 10:39:58 +08:00
ViewState [ "priorityWeldJoints" ] = value ;
2026-05-27 12:01:30 +08:00
}
return value ;
}
set
{
2026-06-11 10:39:58 +08:00
ViewState [ "priorityWeldJoints" ] = value ;
2026-05-27 12:01:30 +08:00
}
}
2026-06-26 00:40:55 +08:00
/// <summary>
/// 页面首次加载时初始化仓库、流水段、匹配状态和左侧WBS管线树。
/// </summary>
/// <param name="sender">事件源。</param>
/// <param name="e">事件参数。</param>
2022-09-05 16:36:31 +08:00
protected void Page_Load ( object sender , EventArgs e )
{
2024-09-18 10:48:34 +08:00
//ctlAuditFlow.Url = BLL.Project_SysSetService.GetAvevaNetUrl(this.CurrUser.LoginProjectId);
2022-09-05 16:36:31 +08:00
if ( ! IsPostBack )
{
2025-10-10 14:33:21 +08:00
tw_PipeMatMatchOutputs = new List < Model . Tw_PipeMatMatchOutput > ( ) ;
2022-09-05 16:36:31 +08:00
PipeArea = Request . Params [ "PipeArea" ] ;
2026-03-05 19:26:42 +08:00
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 > ( ) ;
2022-11-25 14:08:03 +08:00
HJGL_MaterialService . materialStockItems_SHOP = new List < Model . MaterialStockItem > ( ) ;
2025-10-10 14:33:21 +08:00
dicSeclectPipeLine = new Dictionary < string , string > ( ) ;
2026-06-11 10:39:58 +08:00
priorityWeldJoints = new Dictionary < string , HashSet < string > > ( ) ;
2024-12-02 11:33:34 +08:00
var pipeline = ( from x in Funs . DB . HJGL_Pipeline
2025-10-10 14:33:21 +08:00
where x . ProjectId = = this . CurrUser . LoginProjectId
select x . FlowingSection ) . Distinct ( ) . ToList ( ) ;
2024-12-02 11:33:34 +08:00
this . drpFlowingSection . DataTextField = "Value" ;
this . drpFlowingSection . DataValueField = "Value" ;
this . drpFlowingSection . DataSource = pipeline ;
this . drpFlowingSection . DataBind ( ) ;
Funs . FineUIPleaseSelect ( drpFlowingSection ) ;
2022-09-05 16:36:31 +08:00
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 ;
2024-12-06 22:17:50 +08:00
rootNode1 . EnableCheckBox = false ;
2022-09-05 16:36:31 +08:00
this . tvControlItem . Nodes . Add ( rootNode1 ) ;
TreeNode rootNode2 = new TreeNode ( ) ;
rootNode2 . NodeID = "2" ;
rootNode2 . Text = "安装工程" ;
rootNode2 . CommandName = "安装工程" ;
rootNode2 . Expanded = true ;
2024-12-06 22:17:50 +08:00
rootNode2 . EnableCheckBox = false ;
2022-09-05 16:36:31 +08:00
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 ;
2023-08-30 16:19:19 +08:00
//// 当前为施工单位,只能操作本单位的数据
//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
//{
2025-10-10 14:33:21 +08:00
unitWork1 = ( from x in unitWorkList where x . ProjectType = = "1" select x ) . ToList ( ) ;
unitWork2 = ( from x in unitWorkList where x . ProjectType = = "2" select x ) . ToList ( ) ;
2023-08-30 16:19:19 +08:00
//}
2022-09-05 16:36:31 +08:00
if ( unitWork1 . Count ( ) > 0 )
{
foreach ( var q in unitWork1 )
{
2025-10-10 14:33:21 +08:00
2026-05-25 14:41:26 +08:00
int a = GetUnitWorkTestPackagePipelineCount ( q . UnitWorkId ) ;
2023-10-25 19:44:10 +08:00
var unitNamesUnitIds = BLL . UnitService . getUnitNamesUnitIds ( q . UnitId ) ;
2022-09-05 16:36:31 +08:00
TreeNode tn1 = new TreeNode ( ) ;
tn1 . NodeID = q . UnitWorkId ;
tn1 . Text = q . UnitWorkName + "【" + a . ToString ( ) + "】" + "管线" ;
2023-10-25 19:44:10 +08:00
tn1 . ToolTip = "施工单位:" + unitNamesUnitIds ;
2026-05-25 14:41:26 +08:00
tn1 . CommandName = "单位工程" ;
2022-09-05 16:36:31 +08:00
tn1 . EnableExpandEvent = true ;
2026-05-25 14:41:26 +08:00
tn1 . EnableClickEvent = true ;
tn1 . EnableCheckBox = false ;
2022-09-05 16:36:31 +08:00
rootNode1 . Nodes . Add ( tn1 ) ;
if ( a > 0 )
{
2026-05-25 14:41:26 +08:00
BindTestPackageNodes ( tn1 ) ;
2022-09-05 16:36:31 +08:00
}
}
}
if ( unitWork2 . Count ( ) > 0 )
{
foreach ( var q in unitWork2 )
{
2026-05-25 14:41:26 +08:00
int a = GetUnitWorkTestPackagePipelineCount ( q . UnitWorkId ) ;
2025-10-10 14:33:21 +08:00
// var NowComPipelineCode = PipelineService.GetNoComPipelinesByUnitWordId(q.UnitWorkId);
2023-02-20 10:49:51 +08:00
//int a = NowComPipelineCode.Count();
2023-10-25 19:44:10 +08:00
var unitNamesUnitIds = BLL . UnitService . getUnitNamesUnitIds ( q . UnitId ) ;
2022-09-05 16:36:31 +08:00
TreeNode tn2 = new TreeNode ( ) ;
tn2 . NodeID = q . UnitWorkId ;
tn2 . Text = q . UnitWorkName + "【" + a . ToString ( ) + "】" + "管线" ;
if ( q . UnitWorkId = = this . hdUnitWorkId . Text )
{
tn2 . Expanded = true ;
}
2023-10-25 19:44:10 +08:00
tn2 . ToolTip = "施工单位:" + unitNamesUnitIds ;
2026-05-25 14:41:26 +08:00
tn2 . CommandName = "单位工程" ;
2022-09-05 16:36:31 +08:00
tn2 . EnableExpandEvent = true ;
2025-10-10 14:33:21 +08:00
tn2 . EnableClickEvent = true ;
2024-12-06 22:17:50 +08:00
tn2 . EnableCheckBox = false ;
2025-10-10 14:33:21 +08:00
2022-09-05 16:36:31 +08:00
rootNode2 . Nodes . Add ( tn2 ) ;
if ( a > 0 )
{
2026-05-25 14:41:26 +08:00
BindTestPackageNodes ( tn2 ) ;
2022-09-05 16:36:31 +08:00
}
}
}
}
2026-06-26 00:40:55 +08:00
/// <summary>
/// 按分页方式向试压包节点追加管线子节点。
/// </summary>
/// <param name="node">需要加载管线的试压包树节点。</param>
2023-02-20 10:49:51 +08:00
private void BindNodes ( TreeNode node )
2022-09-05 16:36:31 +08:00
{
2024-10-09 17:20:12 +08:00
//var NowComPipelineCode = PipelineService.GetNoComPipelinesByUnitWordId(node.NodeID);
//if (!node.Text.Contains("|"))
//{
// node.Text += "|" + NowComPipelineCode.Count();
//}
2026-05-25 14:41:26 +08:00
var pipeline = GetTestPackagePipelineList ( node . NodeID ) ;
2024-10-09 17:20:12 +08:00
//pipeline= pipeline.Where(x => NowComPipelineCode.Contains(x.PipelineCode)).ToList();
if ( ! node . Text . Contains ( "|" ) )
{
node . Text + = "|" + pipeline . Count ( ) ;
}
2023-02-20 10:49:51 +08:00
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 ( ) ;
2022-09-05 16:36:31 +08:00
foreach ( var item in pipeline )
{
2024-09-27 18:17:21 +08:00
/*if (!NowComPipelineCode.Contains(item.PipelineCode))
2022-09-05 16:36:31 +08:00
{
2023-02-20 10:49:51 +08:00
continue;
2024-09-27 18:17:21 +08:00
}*/
2023-02-20 10:49:51 +08:00
TreeNode newNode = new TreeNode ( ) ;
2025-10-10 14:33:21 +08:00
newNode . Text = item . PipelineCode ;
2022-09-05 16:36:31 +08:00
newNode . NodeID = item . PipelineId ;
2023-02-20 10:49:51 +08:00
newNode . CommandName = "管线" ;
2025-10-10 14:33:21 +08:00
newNode . EnableClickEvent = true ;
2023-02-20 10:49:51 +08:00
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 ) ;
2022-09-05 16:36:31 +08:00
}
}
}
2026-06-26 00:40:55 +08:00
/// <summary>
/// 统计单位工程下各试压包可参与材料匹配的管线数量。
/// </summary>
/// <param name="unitWorkId">单位工程ID。</param>
/// <returns>可参与材料匹配的管线数量。</returns>
2026-05-25 14:41:26 +08:00
private int GetUnitWorkTestPackagePipelineCount ( string unitWorkId )
{
var testPackageIds = ( from x in Funs . DB . PTP_TestPackage
where x . ProjectId = = this . CurrUser . LoginProjectId & & x . UnitWorkId = = unitWorkId
select x . PTP_ID ) . ToList ( ) ;
return testPackageIds . Select ( x = > GetTestPackagePipelineList ( x ) . Count ( ) ) . Sum ( ) ;
}
2026-06-26 00:40:55 +08:00
/// <summary>
/// 为单位工程节点绑定包含管线的试压包节点。
/// </summary>
/// <param name="unitWorkNode">单位工程树节点。</param>
2026-05-25 14:41:26 +08:00
private void BindTestPackageNodes ( TreeNode unitWorkNode )
{
var testPackages = ( from x in Funs . DB . PTP_TestPackage
where x . ProjectId = = this . CurrUser . LoginProjectId
& & x . UnitWorkId = = unitWorkNode . NodeID
orderby x . TestPackageNo
select x ) . ToList ( ) ;
foreach ( var item in testPackages )
{
int pipelineCount = GetTestPackagePipelineList ( item . PTP_ID ) . Count ( ) ;
if ( pipelineCount = = 0 )
{
continue ;
}
TreeNode newNode = new TreeNode ( ) ;
newNode . Text = ( string . IsNullOrEmpty ( item . TestPackageNo ) ? "未知" : item . TestPackageNo ) + "【" + pipelineCount . ToString ( ) + "】管线" ;
newNode . NodeID = item . PTP_ID ;
newNode . CommandName = 1 + "|" + Funs . GetEndPageNumber ( pipelineCount , pageSize ) ;
newNode . EnableClickEvent = true ;
newNode . EnableExpandEvent = true ;
newNode . EnableCheckBox = false ;
unitWorkNode . Nodes . Add ( newNode ) ;
TreeNode loadNode = new TreeNode ( ) ;
loadNode . Text = "加载管线..." ;
loadNode . NodeID = "加载管线..." ;
loadNode . EnableCheckBox = false ;
newNode . Nodes . Add ( loadNode ) ;
}
}
2026-06-26 00:40:55 +08:00
/// <summary>
/// 获取指定试压包下当前仓库、区域和筛选条件内尚未完成出库的管线。
/// </summary>
/// <param name="ptpId">试压包ID。</param>
/// <returns>符合材料匹配入口条件的管线列表。</returns>
2026-05-25 14:41:26 +08:00
private List < Model . HJGL_Pipeline > GetTestPackagePipelineList ( string ptpId )
{
var completeInOutPlanDetailRelationList = from x in Funs . DB . Tw_InOutPlanDetail_Relation
join y in Funs . DB . Tw_InOutPlanMaster on x . InOutPlanMasterId equals y . Id
2026-06-24 23:25:06 +08:00
where y . State = = ( int ) TwConst . State . 已 完 成 & & y . WarehouseId = = drpWarehouse . SelectedValue
2026-05-25 14:41:26 +08:00
select x ;
var pipeline = ( from x in Funs . DB . HJGL_Pipeline
join p in Funs . DB . PTP_PipelineList on x . PipelineId equals p . PipelineId
join y in completeInOutPlanDetailRelationList on x . PipelineId equals y . PipelineId into temp
from y in temp . DefaultIfEmpty ( )
where y = = null
& & p . PTP_ID = = ptpId
& & x . ProjectId = = this . CurrUser . LoginProjectId
& & x . PipeArea = = PipeArea
& & 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 ( ) ;
}
return pipeline . Distinct ( ) . ToList ( ) ;
}
2026-06-26 00:40:55 +08:00
/// <summary>
/// 展开试压包节点时懒加载管线节点。
/// </summary>
/// <param name="sender">事件源。</param>
/// <param name="e">树节点事件参数。</param>
2023-02-20 10:49:51 +08:00
protected void tvControlItem_TreeNodeExpanded ( object sender , TreeNodeEventArgs e )
{
if ( e . Node . Nodes [ 0 ] . NodeID = = "加载管线..." )
{
e . Node . Nodes . Clear ( ) ;
BindNodes ( e . Node ) ;
}
}
2022-09-05 16:36:31 +08:00
#endregion
2026-06-26 00:40:55 +08:00
/// <summary>
/// 按当前筛选条件重新加载左侧WBS管线树。
/// </summary>
/// <param name="sender">事件源。</param>
/// <param name="e">事件参数。</param>
2022-09-05 16:36:31 +08:00
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 )
2023-02-20 10:49:51 +08:00
{
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
{
2025-10-10 14:33:21 +08:00
// this.BindGrid();
2023-02-20 10:49:51 +08:00
}
}
#endregion
#region 数 据 绑 定
2026-06-26 00:40:55 +08:00
/// <summary>
/// 绑定当前选中管线的材料汇总信息。
/// </summary>
2024-09-27 18:17:21 +08:00
private void BindGrid ( )
{
2026-06-11 10:39:58 +08:00
string strSql = @"SELECT ISNULL(pipe.MaterialCode2, lib.Code) AS MaterialCode,
ISNULL(lib.MaterialName, libCode.MaterialName) AS MaterialName,
ISNULL(lib.MaterialUnit, libCode.MaterialUnit) AS MaterialUnit,
ISNULL(lib.MaterialSpec, libCode.MaterialSpec) AS MaterialSpec,
ISNULL(lib.MaterialMade, libCode.MaterialMade) AS MaterialMade,
ISNULL(lib.MaterialDef, libCode.MaterialDef) AS MaterialDef,
sum(pipe.Number)as Number ,
2024-09-27 18:17:21 +08:00
'0' as MatchNum,'否' AS CheckState
FROM dbo.HJGL_PipeLineMat pipe
LEFT JOIN dbo.HJGL_MaterialCodeLib lib ON lib.MaterialCode = pipe.MaterialCode
2026-06-11 10:39:58 +08:00
LEFT JOIN dbo.HJGL_Pipeline line ON line.PipelineId = pipe.PipelineId
OUTER APPLY (SELECT TOP 1 * FROM dbo.HJGL_MaterialCodeLib codeLib WHERE codeLib.ProjectId=line.ProjectId AND codeLib.Code=pipe.MaterialCode2 ORDER BY codeLib.MaterialCode) libCode
2024-09-27 18:17:21 +08:00
WHERE PipelineId=@PipelineId
2026-06-11 10:39:58 +08:00
group by ISNULL(pipe.MaterialCode2, lib.Code),
ISNULL(lib.MaterialName, libCode.MaterialName),
ISNULL(lib.MaterialUnit, libCode.MaterialUnit),
ISNULL(lib.MaterialSpec, libCode.MaterialSpec),
ISNULL(lib.MaterialMade, libCode.MaterialMade),
ISNULL(lib.MaterialDef, libCode.MaterialDef) " ;
2024-09-27 18:17:21 +08:00
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 ( ) ;
2025-10-10 14:33:21 +08:00
}
2026-06-11 17:34:17 +08:00
/// <summary>
/// 绑定管线匹配汇总。重新匹配会刷新 Grid2,需要把用户原来勾选的管线恢复回来。
/// </summary>
/// <param name="keepSelectedPipelineIds">需要保留选中状态的管线ID</param>
2026-06-11 10:39:58 +08:00
void BindGrid2 ( IEnumerable < string > keepSelectedPipelineIds = null )
2024-09-27 18:17:21 +08:00
{
2024-12-06 22:17:50 +08:00
//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 ) ;
2024-09-27 18:17:21 +08:00
Grid2 . DataSource = output ;
Grid2 . DataBind ( ) ;
2024-12-06 22:17:50 +08:00
/*if (output.Any())
2024-10-09 17:20:12 +08:00
{
Rate = Math.Round((decimal)output.Average(item => item.MatchRate) * 100, 2);
lbRate.Text = "匹配率:" + Rate.ToString() + "%";
2024-12-06 22:17:50 +08:00
}*/
2026-06-11 17:34:17 +08:00
// “优先匹配选中焊口”会重新计算匹配结果,重新绑定后要继续保留原管线选中状态。
2026-06-11 10:39:58 +08:00
var keepSelectedList = keepSelectedPipelineIds = = null ? new List < string > ( ) : keepSelectedPipelineIds . Where ( x = > ! string . IsNullOrEmpty ( x ) ) . Distinct ( ) . ToList ( ) ;
2025-10-10 14:33:21 +08:00
var selectList = new List < string > ( ) ;
2024-10-09 17:20:12 +08:00
for ( int i = 0 ; i < Grid2 . Rows . Count ; i + + )
{
2024-12-06 22:17:50 +08:00
var model = Grid2 . Rows [ i ] . DataItem as Tw_PipeMatchOutput ;
2025-10-10 14:33:21 +08:00
if ( model . MatchRate > = 1 )
2024-10-09 17:20:12 +08:00
{
Grid2 . Rows [ i ] . RowCssClass = "green" ;
2024-10-10 10:06:11 +08:00
selectList . Add ( model . PipelineId ) ;
2025-10-10 14:33:21 +08:00
2024-10-09 17:20:12 +08:00
}
else
{
Grid2 . Rows [ i ] . RowCssClass = "red" ;
}
}
2024-10-10 10:06:11 +08:00
if ( cbSelectCom . Checked )
{
2026-06-11 10:39:58 +08:00
selectList . AddRange ( keepSelectedList ) ;
Grid2 . SelectedRowIDArray = selectList . Distinct ( ) . ToArray ( ) ;
}
else if ( keepSelectedList . Any ( ) )
{
Grid2 . SelectedRowIDArray = keepSelectedList . ToArray ( ) ;
2024-10-10 10:06:11 +08:00
}
2024-09-27 18:17:21 +08:00
}
2026-06-26 00:40:55 +08:00
/// <summary>
/// 绑定已加入匹配的管线列表,并标识正在出库中的管线。
/// </summary>
2024-09-27 18:17:21 +08:00
void BindGrid3 ( )
{
Grid3 . DataSource = dicSeclectPipeLine ;
Grid3 . DataBind ( ) ;
2024-10-09 17:20:12 +08:00
for ( int i = 0 ; i < Grid3 . Rows . Count ; i + + )
{
2025-01-23 15:52:33 +08:00
var model = Grid3 . Rows [ i ] . DataItem ;
var model2 = JsonConvert . DeserializeObject < Dictionary < string , string > > ( JsonConvert . SerializeObject ( model ) ) ;
string pipeid = model2 . First ( ) . Value ;
2026-03-05 19:26:42 +08:00
var relationModle = TwInoutplandetailRelationService . GetByPipelineId ( pipeid , drpWarehouse . SelectedValue ) ;
2025-01-23 15:52:33 +08:00
if ( relationModle ! = null )
2024-10-09 17:20:12 +08:00
{
Grid3 . Rows [ i ] . RowCssClass = "yellow" ;
2024-12-06 22:17:50 +08:00
}
2024-10-09 17:20:12 +08:00
}
2024-09-27 18:17:21 +08:00
}
#endregion
#region 表 格 事 件
2026-06-26 00:40:55 +08:00
/// <summary>
/// 材料匹配明细行绑定事件,保留历史行样式扩展入口。
/// </summary>
/// <param name="sender">事件源。</param>
/// <param name="e">Grid行绑定事件参数。</param>
2024-09-27 18:17:21 +08:00
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";
}*/
}
2026-05-27 12:01:30 +08:00
2026-06-26 00:40:55 +08:00
/// <summary>
/// 绑定指定管线的材料匹配明细,设置行颜色、优先焊口选中状态和可生成任务单合计。
/// </summary>
/// <param name="pipelineId">管线ID。</param>
2026-05-27 12:01:30 +08:00
private void BindMaterialDetail ( string pipelineId )
2024-09-27 18:17:21 +08:00
{
2026-06-11 17:34:17 +08:00
// 任务单只允许从未生成任务单的焊口材料中选择,避免重复生成焊接任务。
2026-06-11 10:39:58 +08:00
var tb = GetNoTaskMaterialDetails ( )
. Where ( x = > x . PipelineId = = pipelineId )
2026-06-26 00:40:55 +08:00
// 明细固定按管线号、预制组件号、焊口号、材料编码排序,便于同一焊口材料连续展示。
. OrderBy ( x = > x . PipelineCode )
. ThenBy ( x = > x . PrefabricatedComponents )
. ThenBy ( x = > x . WeldJointCode )
. ThenBy ( x = > x . MaterialCode )
2026-06-11 10:39:58 +08:00
. ToList ( ) ;
2024-09-27 18:17:21 +08:00
Grid1 . DataSource = tb ;
Grid1 . DataBind ( ) ;
2026-05-27 12:01:30 +08:00
var selectList = new List < string > ( ) ;
2026-06-26 00:40:55 +08:00
// 明细行绿色必须以数据库已反写字段判断,不能用本次匹配结果中的 MatchMaterialCode。
var confirmedPipeLineMatIds = GetConfirmedPipeLineMatIds ( tb ) ;
2024-12-06 22:17:50 +08:00
for ( int i = 0 ; i < Grid1 . Rows . Count ; i + + )
{
var model = Grid1 . Rows [ i ] . DataItem as Tw_PipeMatMatchOutput ;
2026-05-27 12:01:30 +08:00
if ( model = = null )
{
continue ;
}
2024-12-06 22:17:50 +08:00
2026-06-26 00:40:55 +08:00
bool isPriority = IsPriorityWeldJoint ( model . PipelineId , model . WeldJointId ) ;
if ( isPriority )
2026-05-27 12:01:30 +08:00
{
selectList . Add ( model . Id ) ;
}
2026-06-26 00:40:55 +08:00
if ( IsMaterialCodeConfirmed ( model , confirmedPipeLineMatIds ) )
{
Grid1 . Rows [ i ] . RowCssClass = "green" ;
}
else if ( isPriority )
{
Grid1 . Rows [ i ] . RowCssClass = "priority" ;
}
2026-05-27 12:01:30 +08:00
else if ( model . MatchRate < 1 | | model . MatchRate = = null )
2024-12-06 22:17:50 +08:00
{
Grid1 . Rows [ i ] . RowCssClass = "red" ;
2025-10-10 14:33:21 +08:00
}
2024-12-06 22:17:50 +08:00
}
2024-09-27 18:17:21 +08:00
2026-05-27 12:01:30 +08:00
Grid1 . SelectedRowIDArray = selectList . ToArray ( ) ;
2026-06-26 00:40:55 +08:00
BindTaskWeldJointSummary ( tb ) ;
}
/// <summary>
/// 在材料明细底部汇总当前明细中真正可生成任务单的焊口数量。
/// </summary>
/// <param name="materialDetails">当前展示的材料匹配明细。</param>
private void BindTaskWeldJointSummary ( List < Tw_PipeMatMatchOutput > materialDetails )
{
// 合计行复用生成任务单的同一套判断,保证页面显示数量和按钮实际生成数量一致。
int taskWeldJointCount = GetTaskWeldJointIdsFromMaterialDetails ( materialDetails ) . Count ;
JObject summary = new JObject ( ) ;
summary . Add ( "PipelineCode" , "合计" ) ;
summary . Add ( "PrefabricatedComponents" , "可生成任务单焊口数:" ) ;
summary . Add ( "WeldJointCode" , taskWeldJointCount . ToString ( ) ) ;
Grid1 . SummaryData = summary ;
2026-05-27 12:01:30 +08:00
}
2026-06-11 17:34:17 +08:00
/// <summary>
/// 获取还没有生成焊接任务单的材料匹配明细。
/// </summary>
2026-06-11 10:39:58 +08:00
private List < Tw_PipeMatMatchOutput > GetNoTaskMaterialDetails ( )
{
var matchOutputs = tw_PipeMatMatchOutputs ? ? new List < Tw_PipeMatMatchOutput > ( ) ;
var weldJointIds = matchOutputs
. Where ( x = > ! string . IsNullOrEmpty ( x . WeldJointId ) )
. Select ( x = > x . WeldJointId )
. Distinct ( )
. ToList ( ) ;
if ( ! weldJointIds . Any ( ) )
{
return matchOutputs ;
}
2026-06-11 17:34:17 +08:00
// HJGL_WeldTask 已存在的焊口不再显示到待生成任务单的材料明细里。
2026-06-11 10:39:58 +08:00
var taskWeldJointIds = Funs . DB . HJGL_WeldTask
. Where ( x = > weldJointIds . Contains ( x . WeldJointId ) )
. Select ( x = > x . WeldJointId )
. Distinct ( )
. ToList ( ) ;
return matchOutputs
. Where ( x = > string . IsNullOrEmpty ( x . WeldJointId ) | | ! taskWeldJointIds . Contains ( x . WeldJointId ) )
. ToList ( ) ;
}
2026-06-26 00:40:55 +08:00
/// <summary>
/// 判断焊口是否被用户设置为当前管线的本次优先匹配焊口。
/// </summary>
/// <param name="pipelineId">管线ID。</param>
/// <param name="weldJointId">焊口ID。</param>
/// <returns>已设置优先匹配返回 true,否则返回 false。</returns>
2026-06-11 10:39:58 +08:00
private bool IsPriorityWeldJoint ( string pipelineId , string weldJointId )
2026-05-27 12:01:30 +08:00
{
return ! string . IsNullOrEmpty ( pipelineId )
2026-06-11 10:39:58 +08:00
& & ! string . IsNullOrEmpty ( weldJointId )
& & priorityWeldJoints . ContainsKey ( pipelineId )
& & priorityWeldJoints [ pipelineId ] . Contains ( weldJointId ) ;
2026-05-27 12:01:30 +08:00
}
2026-06-26 00:40:55 +08:00
/// <summary>
/// 获取材料明细中已持久化反写材料主编码的管线材料ID集合。
/// </summary>
/// <param name="materialDetails">材料匹配明细。</param>
/// <returns>已反写材料主编码的管线材料ID集合。</returns>
private HashSet < string > GetConfirmedPipeLineMatIds ( IEnumerable < Tw_PipeMatMatchOutput > materialDetails )
{
// 已反写材料主编码的唯一可信来源是 HJGL_PipeLineMat.MaterialCode。
var pipeLineMatIds = materialDetails = = null
? new List < string > ( )
: materialDetails
. Where ( x = > x ! = null & & ! string . IsNullOrEmpty ( x . PipeLineMatId ) )
. Select ( x = > x . PipeLineMatId )
. Distinct ( )
. ToList ( ) ;
if ( ! pipeLineMatIds . Any ( ) )
{
return new HashSet < string > ( ) ;
}
var confirmedIds = Funs . DB . HJGL_PipeLineMat
. Where ( x = > pipeLineMatIds . Contains ( x . PipeLineMatId ) & & x . MaterialCode ! = null & & x . MaterialCode ! = "" )
. Select ( x = > x . PipeLineMatId )
. ToList ( ) ;
return new HashSet < string > ( confirmedIds ) ;
}
/// <summary>
/// 判断单条材料明细是否已经反写材料主编码。
/// </summary>
/// <param name="model">材料匹配明细。</param>
/// <param name="confirmedPipeLineMatIds">已反写材料主编码的管线材料ID集合。</param>
/// <returns>已反写返回 true,否则返回 false。</returns>
private bool IsMaterialCodeConfirmed ( Tw_PipeMatMatchOutput model , HashSet < string > confirmedPipeLineMatIds )
{
return model ! = null
& & confirmedPipeLineMatIds ! = null
& & ! string . IsNullOrEmpty ( model . PipeLineMatId )
& & confirmedPipeLineMatIds . Contains ( model . PipeLineMatId ) ;
}
/// <summary>
/// 显示材料匹配颜色和任务单生成规则说明。
/// </summary>
/// <param name="sender">事件源。</param>
/// <param name="e">事件参数。</param>
protected void btnMatchHelp_Click ( object sender , EventArgs e )
{
Alert . ShowInTop ( "1、管线绿色为匹配率100%,明细绿色为已反写材料主编码,红色为匹配率小于100%,蓝色为手动优先焊口。<br/>2、一个焊口可能对应多条材料明细,该焊口全部有效明细已反写材料主编码后才允许一键生成任务单。<br/>3、焊口已进行焊前准备,匹配了焊评才能生成任务单" , "说明" , MessageBoxIcon . Information ) ;
}
/// <summary>
/// 将本次优先匹配焊口状态转换为匹配服务需要的管线-焊口列表结构。
/// </summary>
/// <returns>管线ID到优先焊口ID列表的映射。</returns>
2026-06-11 10:39:58 +08:00
private Dictionary < string , List < string > > GetPriorityWeldJointList ( )
2026-05-27 12:01:30 +08:00
{
2026-06-11 10:39:58 +08:00
return priorityWeldJoints
2026-05-27 12:01:30 +08:00
. Where ( x = > x . Value ! = null & & x . Value . Any ( ) )
. ToDictionary ( x = > x . Key , x = > x . Value . ToList ( ) ) ;
}
2026-06-26 00:40:55 +08:00
/// <summary>
/// 重新计算材料匹配结果,并在刷新管线汇总后恢复原有管线勾选状态。
/// </summary>
2026-05-27 12:01:30 +08:00
private void RefreshMatchResult ( )
{
2026-06-11 17:34:17 +08:00
// 重新匹配库存会刷新管线汇总表,先暂存选择状态,绑定完成后再恢复。
2026-06-11 10:39:58 +08:00
var keepSelectedPipelineIds = Grid2 . SelectedRowIDArray = = null ? new List < string > ( ) : Grid2 . SelectedRowIDArray . ToList ( ) ;
2026-05-27 12:01:30 +08:00
tw_PipeMatMatchOutputs = TwArrivalStatisticsService . GetPipeMatMatch (
this . CurrUser . LoginProjectId ,
dicSeclectPipeLine . Keys . ToList ( ) ,
drpWarehouse . SelectedValue ,
2026-06-11 10:39:58 +08:00
GetPriorityWeldJointList ( ) ) ;
2026-05-27 12:01:30 +08:00
BindGrid3 ( ) ;
2026-06-11 10:39:58 +08:00
BindGrid2 ( keepSelectedPipelineIds ) ;
2026-05-27 12:01:30 +08:00
}
2026-06-26 00:40:55 +08:00
/// <summary>
/// 点击材料匹配管线汇总行时刷新该管线的材料明细。
/// </summary>
/// <param name="sender">事件源。</param>
/// <param name="e">Grid行点击事件参数。</param>
2026-05-27 12:01:30 +08:00
protected void Grid2_RowClick ( object sender , GridRowClickEventArgs e )
{
BindMaterialDetail ( Grid2 . SelectedRowID ) ;
2024-09-27 18:17:21 +08:00
}
2026-06-26 00:40:55 +08:00
/// <summary>
/// 点击材料明细行时联动三维模型定位当前管线或单位工程。
/// </summary>
/// <param name="sender">事件源。</param>
/// <param name="e">Grid行点击事件参数。</param>
2024-09-27 18:17:21 +08:00
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();
}
2026-06-26 00:40:55 +08:00
/// <summary>
/// 记录材料明细排序字段,并按当前选中管线重新绑定明细。
/// </summary>
/// <param name="sender">事件源。</param>
/// <param name="e">Grid排序事件参数。</param>
2024-09-27 18:17:21 +08:00
protected void Grid1_Sort ( object sender , GridSortEventArgs e )
{
Grid1 . SortDirection = e . SortDirection ;
Grid1 . SortField = e . SortField ;
2026-05-27 12:01:30 +08:00
if ( ! string . IsNullOrEmpty ( Grid2 . SelectedRowID ) & & tw_PipeMatMatchOutputs ! = null & & tw_PipeMatMatchOutputs . Any ( ) )
{
BindMaterialDetail ( Grid2 . SelectedRowID ) ;
}
else
{
BindGrid ( ) ;
}
2024-09-27 18:17:21 +08:00
}
#endregion
#region 按 钮 事 件
2026-06-26 00:40:55 +08:00
/// <summary>
/// 刷新三维模型参数,按当前树节点定位单位工程或管线。
/// </summary>
/// <param name="sender">事件源。</param>
/// <param name="e">事件参数。</param>
2023-02-20 10:49:51 +08:00
protected void btnrefresh_Click ( object sender , EventArgs e )
2022-09-05 16:36:31 +08:00
{
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 ;
2022-10-13 18:52:45 +08:00
parameter3D . TagNum = "" ;
2022-11-03 17:39:51 +08:00
parameter3D . ButtonType = "3" ;
2022-10-31 17:03:08 +08:00
2026-05-25 14:41:26 +08:00
if ( this . tvControlItem . SelectedNode . CommandName = = "单位工程" )
2022-10-15 15:40:49 +08:00
{
parameter3D . ModelName = HJGL_DataImportService . Getlatest3DModelNameByUnitWorkId ( tvControlItem . SelectedNodeID ) ;
2022-10-31 17:03:08 +08:00
var pipeline = ( from x in Funs . DB . HJGL_Pipeline
2026-03-05 19:26:42 +08:00
where x . ProjectId = = this . CurrUser . LoginProjectId & & x . UnitWorkId = = tvControlItem . SelectedNodeID & & x . PipeArea = = PipeArea & & x . WarehouseId = = WarehouseId
2022-10-31 17:03:08 +08:00
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 ) ;
}
2022-09-05 16:36:31 +08:00
2022-10-31 17:03:08 +08:00
}
2023-02-20 10:49:51 +08:00
parameter3D . TagNum = string . Join ( "," , pipelineList ) ;
parameter3D . Line_No = string . Join ( "," , pipelineList ) ;
2022-10-15 15:40:49 +08:00
}
else if ( this . tvControlItem . SelectedNode . CommandName = = "管线" )
{
2022-10-31 17:03:08 +08:00
Model . HJGL_Pipeline pipeline = BLL . PipelineService . GetPipelineByPipelineId ( this . tvControlItem . SelectedNodeID ) ;
this . hdUnitWorkId . Text = string . Empty ;
if ( pipeline ! = null )
{
2026-05-25 14:41:26 +08:00
this . hdUnitWorkId . Text = pipeline . UnitWorkId ;
2022-10-31 17:03:08 +08:00
this . BindGrid ( ) ;
}
if ( pipeline ! = null & & ! string . IsNullOrEmpty ( pipeline . UnitWorkId ) )
2022-10-15 15:40:49 +08:00
{
2022-10-28 17:01:51 +08:00
bool istrue = BLL . HJGL_MaterialService . isInStockByPipeline ( tvControlItem . SelectedNodeID , this . CurrUser . LoginProjectId ) ;
if ( istrue )
{
2022-10-31 17:03:08 +08:00
Line_No = "/" + pipeline . PipelineCode ;
2022-10-28 17:01:51 +08:00
}
2022-11-09 16:57:01 +08:00
//parameter3D.Line_No = Line_No;
2022-10-31 17:03:08 +08:00
parameter3D . ModelName = HJGL_DataImportService . Getlatest3DModelNameByUnitWorkId ( pipeline . UnitWorkId ) ;
var pipecode = "/" + pipeline . PipelineCode ;
2022-10-29 10:59:32 +08:00
parameter3D . TagNum = pipecode ;
2022-10-15 15:40:49 +08:00
}
2023-02-20 10:49:51 +08:00
}
2024-09-18 10:48:34 +08:00
//ctlAuditFlow.Url_item = BLL.Project_SysSetService.GetAvevaNetUrl_Item(this.CurrUser.LoginProjectId) + parameter3D.ModelName;
//ctlAuditFlow.data = parameter3D;
//ctlAuditFlow.BindData();
2022-09-05 16:36:31 +08:00
}
2023-02-20 10:49:51 +08:00
}
2022-09-05 16:36:31 +08:00
2026-06-26 00:40:55 +08:00
/// <summary>
/// 打开单位工程材料匹配统计窗口。
/// </summary>
/// <param name="sender">事件源。</param>
/// <param name="e">事件参数。</param>
2024-09-27 18:17:21 +08:00
protected void btnStatisticsMat_Click ( object sender , EventArgs e )
2022-09-05 16:36:31 +08:00
{
2024-09-27 18:17:21 +08:00
Model . WBS_UnitWork unitWork = BLL . UnitWorkService . GetUnitWorkByUnitWorkId ( this . tvControlItem . SelectedNodeID ) ;
if ( unitWork ! = null )
2022-09-05 16:36:31 +08:00
{
2024-09-27 18:17:21 +08:00
PageContext . RegisterStartupScript ( Window2 . GetShowReference ( String . Format ( "WeldMatMatchGet.aspx?UnitWorkId={0}&&PipeArea={1}" , this . tvControlItem . SelectedNodeID , PipeArea , "匹配 - " ) ) ) ;
}
else
{
ShowNotify ( "请先选择单位工程!" , MessageBoxIcon . Warning ) ;
2022-09-05 16:36:31 +08:00
}
}
2026-06-26 00:40:55 +08:00
/// <summary>
/// 将左侧勾选的管线加入本次材料匹配范围并刷新匹配结果。
/// </summary>
/// <param name="sender">事件源。</param>
/// <param name="e">事件参数。</param>
2024-09-27 18:17:21 +08:00
protected void btnAddPipelineMatchMat_Click ( object sender , EventArgs e )
2022-09-05 16:36:31 +08:00
{
2025-10-10 14:33:21 +08:00
var selectNodes = tvControlItem . GetCheckedNodes ( ) ;
2024-12-06 22:17:50 +08:00
foreach ( var node in selectNodes )
2025-10-10 14:33:21 +08:00
{
if ( dicSeclectPipeLine . Where ( x = > x . Key = = node . NodeID ) . Count ( ) = = 0 & & node . CommandName = = "管线" )
2024-09-27 18:17:21 +08:00
{
2024-12-06 22:17:50 +08:00
dicSeclectPipeLine . Add ( node . NodeID , node . Text ) ;
2024-09-27 18:17:21 +08:00
}
}
2026-05-27 12:01:30 +08:00
RefreshMatchResult ( ) ;
2022-09-05 16:36:31 +08:00
}
2026-06-26 00:40:55 +08:00
/// <summary>
/// 从本次材料匹配范围移除选中管线,并清理对应的优先焊口状态。
/// </summary>
/// <param name="sender">事件源。</param>
/// <param name="e">事件参数。</param>
2024-09-27 18:17:21 +08:00
protected void btnDeletePipelineMatchMat_Click ( object sender , EventArgs e )
2022-09-05 16:36:31 +08:00
{
2026-04-19 00:53:26 +08:00
if ( Grid3 . SelectedRowIDArray ! = null & & Grid3 . SelectedRowIDArray . Any ( ) )
2024-09-27 18:17:21 +08:00
{
2026-04-19 00:53:26 +08:00
foreach ( string rowId in Grid3 . SelectedRowIDArray )
2024-12-06 22:17:50 +08:00
{
2026-04-19 00:53:26 +08:00
dicSeclectPipeLine . Remove ( rowId ) ;
2026-06-11 10:39:58 +08:00
priorityWeldJoints . Remove ( rowId ) ;
2026-04-19 00:53:26 +08:00
var node = tvControlItem . FindNode ( rowId ) ;
if ( node ! = null )
{
node . Checked = false ;
}
2024-12-06 22:17:50 +08:00
}
2026-05-27 12:01:30 +08:00
RefreshMatchResult ( ) ;
}
}
2026-06-26 00:40:55 +08:00
/// <summary>
/// 优先匹配选中焊口
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
2026-05-27 12:01:30 +08:00
protected void btnPriorityComponents_Click ( object sender , EventArgs e )
{
string selectedPipelineId = Grid2 . SelectedRowID ;
if ( string . IsNullOrEmpty ( selectedPipelineId ) )
{
ShowNotify ( "请先在材料匹配列表选择管线!" , MessageBoxIcon . Warning ) ;
return ;
}
2026-06-11 17:34:17 +08:00
// 页面上的焊口选择来自 Grid1 材料明细;Grid3 是左侧已加入匹配的管线列表。
2026-06-11 10:39:58 +08:00
var selectedWeldJoints = new HashSet < string > ( ) ;
2026-05-27 12:01:30 +08:00
foreach ( int rowIndex in Grid1 . SelectedRowIndexArray )
{
2026-06-11 10:39:58 +08:00
if ( Grid1 . DataKeys [ rowIndex ] . Length < 4 )
2026-05-27 12:01:30 +08:00
{
continue ;
}
string pipelineId = Grid1 . DataKeys [ rowIndex ] [ 1 ] ? . ToString ( ) ;
2026-06-11 10:39:58 +08:00
string weldJointId = Grid1 . DataKeys [ rowIndex ] [ 3 ] ? . ToString ( ) ;
if ( pipelineId = = selectedPipelineId & & ! string . IsNullOrEmpty ( weldJointId ) )
2026-05-27 12:01:30 +08:00
{
2026-06-11 10:39:58 +08:00
selectedWeldJoints . Add ( weldJointId ) ;
2026-05-27 12:01:30 +08:00
}
}
2026-06-11 10:39:58 +08:00
if ( selectedWeldJoints . Any ( ) )
2026-05-27 12:01:30 +08:00
{
2026-06-11 10:39:58 +08:00
priorityWeldJoints [ selectedPipelineId ] = selectedWeldJoints ;
2026-05-27 12:01:30 +08:00
}
else
{
2026-06-11 10:39:58 +08:00
priorityWeldJoints . Remove ( selectedPipelineId ) ;
2024-09-27 18:17:21 +08:00
}
2026-05-27 12:01:30 +08:00
2026-06-11 17:34:17 +08:00
// 优先焊口会触发重新匹配,当前管线也必须继续保持选中,方便后续生成任务单。
2026-06-11 10:39:58 +08:00
var keepSelectedPipelineIds = Grid2 . SelectedRowIDArray = = null ? new List < string > ( ) : Grid2 . SelectedRowIDArray . ToList ( ) ;
if ( ! keepSelectedPipelineIds . Contains ( selectedPipelineId ) )
{
keepSelectedPipelineIds . Add ( selectedPipelineId ) ;
}
2026-05-27 12:01:30 +08:00
RefreshMatchResult ( ) ;
2026-06-11 10:39:58 +08:00
Grid2 . SelectedRowIDArray = keepSelectedPipelineIds . Distinct ( ) . ToArray ( ) ;
2026-05-27 12:01:30 +08:00
BindMaterialDetail ( selectedPipelineId ) ;
2022-09-05 16:36:31 +08:00
}
2026-05-27 12:01:30 +08:00
2026-06-26 00:40:55 +08:00
/// <summary>
/// 将当前选中管线的匹配结果反写到管线材料主编码。
/// </summary>
/// <param name="sender">事件源。</param>
/// <param name="e">事件参数。</param>
2026-06-11 10:39:58 +08:00
protected void btnConfirmMaterialCode_Click ( object sender , EventArgs e )
{
if ( Grid2 . SelectedRowIDArray = = null | | ! Grid2 . SelectedRowIDArray . Any ( ) )
{
ShowNotify ( "请先选择需要保存匹配结果的管线!" , MessageBoxIcon . Warning ) ;
return ;
}
if ( tw_PipeMatMatchOutputs = = null | | ! tw_PipeMatMatchOutputs . Any ( ) )
{
RefreshMatchResult ( ) ;
}
var selectedPipelineIds = Grid2 . SelectedRowIDArray . ToList ( ) ;
var matchedMaterials = tw_PipeMatMatchOutputs
. Where ( x = > selectedPipelineIds . Contains ( x . PipelineId ) )
. ToList ( ) ;
if ( ! matchedMaterials . Any ( ) )
{
ShowNotify ( "未找到保存的材料匹配明细!" , MessageBoxIcon . Warning ) ;
return ;
}
var invalidMaterials = matchedMaterials
. Where ( x = > string . IsNullOrEmpty ( x . MatchMaterialCode ) | | ( x . MatchRate ? ? 0 ) < 1 )
. ToList ( ) ;
/* if (invalidMaterials.Any())
{
ShowNotify("存在未100%匹配的材料,不能反写材料主编码!", MessageBoxIcon.Warning);
return;
}*/
int count = BLL . PipelineMatService . UpdateMaterialCodeByMatchOutputs ( matchedMaterials ) ;
ShowNotify ( "已保存材料主编码" + count . ToString ( ) + "条!" , MessageBoxIcon . Success ) ;
RefreshMatchResult ( ) ;
if ( Grid2 . SelectedRowIDArray . Any ( ) )
{
BindMaterialDetail ( Grid2 . SelectedRowIDArray . First ( ) ) ;
}
}
2026-06-26 00:40:55 +08:00
/// <summary>
/// 按 Grid2 选中管线下可生成任务单的焊口批量生成焊接任务单。
/// </summary>
/// <param name="sender">事件源。</param>
/// <param name="e">事件参数。</param>
2024-09-27 18:17:21 +08:00
protected void btnGenTask_Click ( object sender , EventArgs e )
2025-10-10 14:33:21 +08:00
{
2026-06-26 00:40:55 +08:00
if ( Grid2 . SelectedRowIDArray = = null | | ! Grid2 . SelectedRowIDArray . Any ( ) )
2024-10-09 17:20:12 +08:00
{
2026-06-26 00:40:55 +08:00
ShowNotify ( "请先在材料匹配列表中选择需要生成任务单的管线!" , MessageBoxIcon . Warning ) ;
return ;
2024-10-09 17:20:12 +08:00
}
2026-06-26 00:40:55 +08:00
// 生成任务单按 Grid2 勾选管线批量取焊口,不再要求用户在 Grid1 明细逐条勾选。
var selectedWeldJointIds = GetTaskWeldJointIdsFromSelectedPipelines ( ) ;
if ( ! selectedWeldJointIds . Any ( ) )
{
ShowNotify ( "选中管线中没有已反写材料主编码的可生成任务单焊口!" , MessageBoxIcon . Warning ) ;
return ;
}
if ( SaveTask ( selectedWeldJointIds ) )
2022-10-15 15:40:49 +08:00
{
2026-06-26 00:40:55 +08:00
ShowNotify ( "生成任务单成功!" , MessageBoxIcon . Warning ) ;
// Alert.Show("生成任务单成功!", MessageBoxIcon.Warning);
Grid1 . DataSource = null ;
Grid1 . DataBind ( ) ;
BindTaskWeldJointSummary ( new List < Tw_PipeMatMatchOutput > ( ) ) ;
Grid2 . DataSource = null ;
Grid2 . DataBind ( ) ;
Grid3 . DataSource = null ;
Grid3 . DataBind ( ) ;
2022-10-15 15:40:49 +08:00
}
2025-10-10 14:33:21 +08:00
2024-09-27 18:17:21 +08:00
}
2026-06-26 00:40:55 +08:00
/// <summary>
/// 根据已通过材料齐套和任务单条件过滤的焊口生成焊接任务单。
/// </summary>
/// <param name="selectedWeldJointIds">待生成任务单的焊口ID集合。</param>
/// <returns>生成成功返回 true;校验失败或无可生成焊口返回 false。</returns>
private bool SaveTask ( HashSet < string > selectedWeldJointIds )
2024-09-27 18:17:21 +08:00
{
2026-06-26 00:40:55 +08:00
if ( selectedWeldJointIds = = null | | ! selectedWeldJointIds . Any ( ) )
2026-06-11 10:39:58 +08:00
{
2026-06-26 00:40:55 +08:00
ShowNotify ( "选中管线中没有已反写材料主编码的可生成任务单焊口!" , MessageBoxIcon . Warning ) ;
2026-06-11 10:39:58 +08:00
return false ;
}
2024-09-27 18:17:21 +08:00
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 ;
2026-06-11 10:39:58 +08:00
var selectedWeldJointIdList = selectedWeldJointIds . ToList ( ) ;
2026-06-26 00:40:55 +08:00
var selectRowId = GetTaskableWeldJointRows ( selectedWeldJointIdList ) ;
2024-12-26 14:42:15 +08:00
Dictionary < string , string > unitworkTaskCode = new Dictionary < string , string > ( ) ;
Dictionary < string , string > unitworkSerialNumber = new Dictionary < string , string > ( ) ;
Dictionary < int , string > matchPipeline = new Dictionary < int , string > ( ) ;
2026-06-11 17:34:17 +08:00
// 生成任务单仍保留管线在匹配结果中的排序,用于任务单列表按管线顺序展示。
2026-06-11 10:39:58 +08:00
for ( int rowIndex = 0 ; rowIndex < Grid2 . Rows . Count ; rowIndex + + )
2024-12-26 14:42:15 +08:00
{
2025-10-10 14:33:21 +08:00
matchPipeline . Add ( rowIndex + 1 , Grid2 . Rows [ rowIndex ] . RowID ) ;
2024-12-26 14:42:15 +08:00
}
2026-05-27 12:01:30 +08:00
if ( ! selectRowId . Any ( ) )
{
ShowNotify ( "未找到可生成任务单的焊口!" , MessageBoxIcon . Warning ) ;
return false ;
}
2024-09-27 18:17:21 +08:00
foreach ( var weldjoint in selectRowId )
2024-12-02 17:51:43 +08:00
{
2024-09-27 18:17:21 +08:00
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 ;
2025-10-10 14:33:21 +08:00
if ( unitworkTaskCode . FirstOrDefault ( x = > x . Key = = NewTask . UnitWorkId ) . Value ! = null )
2024-12-26 14:42:15 +08:00
{
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 ) ;
2025-10-10 14:33:21 +08:00
unitworkTaskCode . Add ( NewTask . UnitWorkId , NewTask . TaskCode ) ;
2024-12-26 14:42:15 +08:00
}
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 ) ;
}
2024-09-27 18:17:21 +08:00
NewTask . WeldTaskId = SQLHelper . GetNewID ( ) ;
2025-10-10 14:33:21 +08:00
NewTask . WeldJointId = weldjoint . WeldJointId ;
2024-09-27 18:17:21 +08:00
var oldWeldTask = BLL . WeldTaskService . GetWeldTaskByWeldJointId ( NewTask . WeldJointId ) ;
if ( oldWeldTask ! = null )
2022-10-15 15:40:49 +08:00
{
2024-09-27 18:17:21 +08:00
ShowNotify ( "所选焊口已存在任务单,无法保存!" , MessageBoxIcon . Warning ) ;
2026-05-27 12:01:30 +08:00
return false ;
2024-09-27 18:17:21 +08:00
}
Model . HJGL_WeldJoint weldJoint = BLL . WeldJointService . GetWeldJointByWeldJointId ( NewTask . WeldJointId ) ;
if ( weldJoint ! = null )
{
2025-10-10 14:33:21 +08:00
NewTask . PipeLineSortIndex = matchPipeline . FirstOrDefault ( x = > x . Value = = weldJoint . PipelineId ) . Key ;
2024-09-27 18:17:21 +08:00
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 )
2022-10-28 17:01:51 +08:00
{
2024-09-27 18:17:21 +08:00
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 ) ;
}
2022-10-28 17:01:51 +08:00
}
2022-10-15 15:40:49 +08:00
}
2024-09-27 18:17:21 +08:00
NewTask . JointAttribute = weldJoint . JointAttribute ;
2022-10-15 15:40:49 +08:00
2024-09-27 18:17:21 +08:00
NewTask . TaskDate = DateTime . Now . Date ;
NewTask . Tabler = this . CurrUser . PersonId ;
NewTask . TableDate = DateTime . Now ;
2023-02-20 10:49:51 +08:00
2024-09-27 18:17:21 +08:00
weldJoint . WeldingMode = "手动" ;
BLL . WeldJointService . UpdateWeldJoint ( weldJoint ) ;
BLL . WeldTaskService . AddWeldTask ( NewTask ) ;
2023-02-20 10:49:51 +08:00
}
2025-10-10 14:33:21 +08:00
2026-05-27 12:01:30 +08:00
return true ;
}
2026-06-11 17:34:17 +08:00
/// <summary>
2026-06-26 00:40:55 +08:00
/// 按任务单实际生成规则过滤可生成任务单的焊口视图数据。
2026-06-11 17:34:17 +08:00
/// </summary>
2026-06-26 00:40:55 +08:00
/// <param name="weldJointIds">候选焊口ID集合。</param>
/// <returns>符合任务单生成条件的焊口视图数据。</returns>
private List < Model . View_HJGL_NoWeldJointFind > GetTaskableWeldJointRows ( IEnumerable < string > weldJointIds )
2026-06-11 10:39:58 +08:00
{
2026-06-26 00:40:55 +08:00
var weldJointIdList = weldJointIds = = null
? new List < string > ( )
: weldJointIds . Where ( x = > ! string . IsNullOrEmpty ( x ) ) . Distinct ( ) . ToList ( ) ;
if ( ! weldJointIdList . Any ( ) )
2026-06-11 10:39:58 +08:00
{
2026-06-26 00:40:55 +08:00
return new List < Model . View_HJGL_NoWeldJointFind > ( ) ;
2026-06-11 10:39:58 +08:00
}
2026-06-26 00:40:55 +08:00
// 合计行和生成按钮必须共用同一套可生成条件:未生成日报、未生成任务单、已维护焊接方法。
var taskableRows = ( from x in Funs . DB . View_HJGL_NoWeldJointFind
where weldJointIdList . Contains ( x . WeldJointId )
& & x . WeldingDailyId = = null
& & x . WeldTaskId = = null
& & x . WeldingMethodCode ! = null
select x ) . ToList ( ) ;
if ( PipeArea = = "1" )
2026-06-11 10:39:58 +08:00
{
2026-06-26 00:40:55 +08:00
// 工厂预制材料匹配只允许预制口生成任务单,现场安装页面不套用该限制。
taskableRows = taskableRows . Where ( x = > x . JointAttribute = = "预制口" ) . ToList ( ) ;
}
2026-06-11 10:39:58 +08:00
2026-06-26 00:40:55 +08:00
return taskableRows ;
}
/// <summary>
/// 从 Grid2 选中的管线中收集可生成任务单的焊口ID。
/// </summary>
/// <returns>可生成任务单的焊口ID集合。</returns>
private HashSet < string > GetTaskWeldJointIdsFromSelectedPipelines ( )
{
// Grid2 的选中管线是任务单生成范围,Grid1 当前展示哪条管线不影响批量生成。
var selectedPipelineIds = Grid2 . SelectedRowIDArray = = null
? new HashSet < string > ( )
: new HashSet < string > ( Grid2 . SelectedRowIDArray . Where ( x = > ! string . IsNullOrEmpty ( x ) ) ) ;
if ( ! selectedPipelineIds . Any ( ) )
{
return new HashSet < string > ( ) ;
2026-06-11 10:39:58 +08:00
}
2026-06-26 00:40:55 +08:00
var materialDetails = GetNoTaskMaterialDetails ( )
// 生成任务单只校验参与匹配的有效材料明细,零用量材料不参与焊口材料齐套判断。
. Where ( x = > selectedPipelineIds . Contains ( x . PipelineId ) & & ! string . IsNullOrEmpty ( x . WeldJointId ) & & ( x . NeedNum ? ? 0 ) > 0 )
. ToList ( ) ;
return GetTaskWeldJointIdsFromMaterialDetails ( materialDetails ) ;
}
/// <summary>
/// 根据材料明细判断焊口是否材料齐套且满足任务单生成条件。
/// </summary>
/// <param name="materialDetails">候选材料匹配明细。</param>
/// <returns>可生成任务单的焊口ID集合。</returns>
private HashSet < string > GetTaskWeldJointIdsFromMaterialDetails ( List < Tw_PipeMatMatchOutput > materialDetails )
{
if ( materialDetails = = null | | ! materialDetails . Any ( ) )
{
return new HashSet < string > ( ) ;
}
materialDetails = materialDetails
. Where ( x = > x ! = null & & ! string . IsNullOrEmpty ( x . WeldJointId ) & & ( x . NeedNum ? ? 0 ) > 0 )
. ToList ( ) ;
// 同一焊口可能有多条有效材料明细,所有明细都反写材料主编码后才算可生成任务单。
var confirmedPipeLineMatIds = GetConfirmedPipeLineMatIds ( materialDetails ) ;
var weldJointIds = materialDetails
. GroupBy ( x = > x . WeldJointId )
. Where ( x = > x . All ( y = > IsMaterialCodeConfirmed ( y , confirmedPipeLineMatIds ) ) )
. Select ( x = > x . Key ) ;
// 材料齐套后还要继续套用任务单视图条件,保证合计数量和点击生成按钮的实际范围一致。
return new HashSet < string > ( GetTaskableWeldJointRows ( weldJointIds ) . Select ( x = > x . WeldJointId ) ) ;
2026-06-11 10:39:58 +08:00
}
2026-06-26 00:40:55 +08:00
/// <summary>
/// 获取指定管线范围内的优先匹配焊口集合。
/// </summary>
/// <param name="selectedPipelineIds">管线ID列表。</param>
/// <returns>管线ID到优先焊口ID集合的映射。</returns>
2026-05-27 12:01:30 +08:00
private Dictionary < string , HashSet < string > > GetPriorityWeldJointIds ( List < string > selectedPipelineIds )
{
var result = new Dictionary < string , HashSet < string > > ( ) ;
2026-06-11 10:39:58 +08:00
var selectedPriority = priorityWeldJoints
2026-05-27 12:01:30 +08:00
. Where ( x = > selectedPipelineIds . Contains ( x . Key ) & & x . Value ! = null & & x . Value . Any ( ) )
. ToList ( ) ;
foreach ( var item in selectedPriority )
{
2026-06-11 10:39:58 +08:00
result [ item . Key ] = new HashSet < string > ( item . Value ) ;
2026-05-27 12:01:30 +08:00
}
return result ;
2024-12-02 17:51:43 +08:00
}
2026-05-27 12:01:30 +08:00
2026-06-26 00:40:55 +08:00
/// <summary>
/// 判断焊材钢号类别是否能覆盖母材类别。
/// </summary>
/// <param name="wpsClass">焊材钢号类别。</param>
/// <param name="matClass">母材类别。</param>
/// <returns>能覆盖返回 true,否则返回 false。</returns>
2024-09-27 18:17:21 +08:00
private bool IsCoverClass ( string wpsClass , string matClass )
{
bool isCover = false ;
int wpsSn = 0 ;
int matSn = 0 ;
if ( wpsClass . Length > 2 & & matClass . Length > 2 )
2023-02-20 10:49:51 +08:00
{
2024-09-27 18:17:21 +08:00
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 ;
}
2023-02-20 10:49:51 +08:00
}
2024-09-27 18:17:21 +08:00
return isCover ;
2023-02-20 10:49:51 +08:00
}
2024-09-27 18:17:21 +08:00
2026-03-05 19:26:42 +08:00
#endregion
2022-09-05 16:36:31 +08:00
2026-06-26 00:40:55 +08:00
/// <summary>
/// 仓库切换后刷新当前仓库ID并重新加载左侧管线树。
/// </summary>
/// <param name="sender">事件源。</param>
/// <param name="e">事件参数。</param>
2026-03-05 19:26:42 +08:00
protected void drpWarehouse_SelectedIndexChanged ( object sender , EventArgs e )
{
2026-06-24 23:25:06 +08:00
WarehouseId = Base_WarehouseService . GetWarehouseList ( this . CurrUser . LoginProjectId )
. Where ( x = > x . WarehouseId = = drpWarehouse . SelectedValue | | x . WarehouseName = = drpWarehouse . SelectedValue )
. Select ( x = > x . WarehouseId )
. FirstOrDefault ( ) ;
2026-03-05 19:26:42 +08:00
this . InitTreeMenu ( ) ; //加载树
}
2022-09-05 16:36:31 +08:00
}
2026-04-19 00:53:26 +08:00
}