feat: 完善材料管理与焊接业务功能
This commit is contained in:
@@ -1,10 +1,12 @@
|
||||
using BLL;
|
||||
using FineUIPro.Web.DataShow;
|
||||
using MiniExcelLibs;
|
||||
using Model;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
|
||||
namespace FineUIPro.Web.HJGL.WeldingManage
|
||||
@@ -13,6 +15,19 @@ namespace FineUIPro.Web.HJGL.WeldingManage
|
||||
{
|
||||
public int pageSize = PipelineService.pageSize;
|
||||
|
||||
private const string TreeCommandBuilding = "建筑工程";
|
||||
private const string TreeCommandInstallation = "安装工程";
|
||||
private const string TreeCommandUnitWork = "单位工程";
|
||||
private const string TreeCommandPipeline = "管线";
|
||||
private const string TreeCommandLoad = "加载";
|
||||
private const string PrefabricationJointAttribute = "预制口";
|
||||
private const string InstallationJointAttribute = "安装口";
|
||||
private const string WeldingRodConsumablesType = "2";
|
||||
private const string WeldingWireConsumablesType = "1";
|
||||
private const string ManualWeldingMode = "手动";
|
||||
private const string CoverMaterialClassFe1 = "Fe-1";
|
||||
private const string CoverMaterialClassFe3 = "Fe-3";
|
||||
|
||||
public string WarehouseId
|
||||
{
|
||||
get
|
||||
@@ -89,29 +104,61 @@ namespace FineUIPro.Web.HJGL.WeldingManage
|
||||
//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>();
|
||||
priorityWeldJoints = new Dictionary<string, HashSet<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();//加载树
|
||||
InitializePage();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 初始化页面状态、筛选项和左侧管线树。
|
||||
/// </summary>
|
||||
private void InitializePage()
|
||||
{
|
||||
tw_PipeMatMatchOutputs = new List<Model.Tw_PipeMatMatchOutput>();
|
||||
PipeArea = Request.Params["PipeArea"];
|
||||
BindWarehouseOptions();
|
||||
ResetMaterialStockCache();
|
||||
dicSeclectPipeLine = new Dictionary<string, string>();
|
||||
priorityWeldJoints = new Dictionary<string, HashSet<string>>();
|
||||
BindFlowingSectionOptions();
|
||||
InitTreeMenu();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 绑定当前项目可用仓库,并触发仓库切换后的树刷新。
|
||||
/// </summary>
|
||||
private void BindWarehouseOptions()
|
||||
{
|
||||
drpWarehouse.DataTextField = "Key";
|
||||
drpWarehouse.DataValueField = "Value";
|
||||
drpWarehouse.DataSource = BLL.TwInOutplanmasterService.GetWarehouseCode(this.CurrUser.LoginProjectId);
|
||||
drpWarehouse.DataBind();
|
||||
drpWarehouse_SelectedIndexChanged(null, null);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 清空材料库存缓存,避免首次加载沿用其他入口的区域缓存。
|
||||
/// </summary>
|
||||
private void ResetMaterialStockCache()
|
||||
{
|
||||
HJGL_MaterialService.materialStockItems_FIELD = new List<Model.MaterialStockItem>();
|
||||
HJGL_MaterialService.materialStockItems_SHOP = new List<Model.MaterialStockItem>();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 绑定当前项目的流水段筛选项。
|
||||
/// </summary>
|
||||
private void BindFlowingSectionOptions()
|
||||
{
|
||||
var flowingSections = (from x in Funs.DB.HJGL_Pipeline
|
||||
where x.ProjectId == this.CurrUser.LoginProjectId
|
||||
select x.FlowingSection).Distinct().ToList();
|
||||
drpFlowingSection.DataTextField = "Value";
|
||||
drpFlowingSection.DataValueField = "Value";
|
||||
drpFlowingSection.DataSource = flowingSections;
|
||||
drpFlowingSection.DataBind();
|
||||
Funs.FineUIPleaseSelect(drpFlowingSection);
|
||||
}
|
||||
|
||||
#region 加载树装置-单位-工作区
|
||||
|
||||
/// <summary>
|
||||
@@ -121,20 +168,10 @@ namespace FineUIPro.Web.HJGL.WeldingManage
|
||||
{
|
||||
this.tvControlItem.Nodes.Clear();
|
||||
|
||||
TreeNode rootNode1 = new TreeNode();
|
||||
rootNode1.NodeID = "1";
|
||||
rootNode1.Text = "建筑工程";
|
||||
rootNode1.CommandName = "建筑工程";
|
||||
rootNode1.Selectable = false;
|
||||
rootNode1.EnableCheckBox = false;
|
||||
TreeNode rootNode1 = CreateRootNode("1", TreeCommandBuilding, false, false);
|
||||
this.tvControlItem.Nodes.Add(rootNode1);
|
||||
|
||||
TreeNode rootNode2 = new TreeNode();
|
||||
rootNode2.NodeID = "2";
|
||||
rootNode2.Text = "安装工程";
|
||||
rootNode2.CommandName = "安装工程";
|
||||
rootNode2.Expanded = true;
|
||||
rootNode2.EnableCheckBox = false;
|
||||
TreeNode rootNode2 = CreateRootNode("2", TreeCommandInstallation, true, null);
|
||||
this.tvControlItem.Nodes.Add(rootNode2);
|
||||
|
||||
var unitWorkList = (from x in Funs.DB.WBS_UnitWork
|
||||
@@ -143,57 +180,54 @@ namespace FineUIPro.Web.HJGL.WeldingManage
|
||||
orderby x.UnitWorkCode
|
||||
select x).ToList();
|
||||
|
||||
List<Model.WBS_UnitWork> unitWork1 = null;
|
||||
List<Model.WBS_UnitWork> unitWork2 = null;
|
||||
BindUnitWorkNodes(rootNode1, unitWorkList.Where(x => x.ProjectType == "1"), false);
|
||||
BindUnitWorkNodes(rootNode2, unitWorkList.Where(x => x.ProjectType == "2"), true);
|
||||
}
|
||||
|
||||
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)
|
||||
/// <summary>
|
||||
/// 创建建筑工程或安装工程根节点。
|
||||
/// </summary>
|
||||
private TreeNode CreateRootNode(string nodeId, string text, bool expanded, bool? selectable)
|
||||
{
|
||||
var rootNode = new TreeNode
|
||||
{
|
||||
foreach (var q in unitWork1)
|
||||
{
|
||||
int a = GetUnitWorkTestPackagePipelineCount(q.UnitWorkId);
|
||||
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 = "单位工程";
|
||||
tn1.EnableExpandEvent = true;
|
||||
tn1.EnableClickEvent = true;
|
||||
tn1.EnableCheckBox = false;
|
||||
rootNode1.Nodes.Add(tn1);
|
||||
if (a > 0)
|
||||
{
|
||||
BindTestPackageNodes(tn1);
|
||||
}
|
||||
}
|
||||
NodeID = nodeId,
|
||||
Text = text,
|
||||
CommandName = text,
|
||||
Expanded = expanded,
|
||||
EnableCheckBox = false
|
||||
};
|
||||
if (selectable.HasValue)
|
||||
{
|
||||
rootNode.Selectable = selectable.Value;
|
||||
}
|
||||
if (unitWork2.Count() > 0)
|
||||
{
|
||||
foreach (var q in unitWork2)
|
||||
{
|
||||
int a = GetUnitWorkTestPackagePipelineCount(q.UnitWorkId);
|
||||
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 = "单位工程";
|
||||
tn2.EnableExpandEvent = true;
|
||||
tn2.EnableClickEvent = true;
|
||||
tn2.EnableCheckBox = false;
|
||||
return rootNode;
|
||||
}
|
||||
|
||||
rootNode2.Nodes.Add(tn2);
|
||||
if (a > 0)
|
||||
{
|
||||
BindTestPackageNodes(tn2);
|
||||
}
|
||||
/// <summary>
|
||||
/// 将单位工程节点绑定到指定工程根节点。
|
||||
/// </summary>
|
||||
private void BindUnitWorkNodes(TreeNode parentNode, IEnumerable<Model.WBS_UnitWork> unitWorks, bool expandSelectedNode)
|
||||
{
|
||||
foreach (var unitWork in unitWorks)
|
||||
{
|
||||
int pipelineCount = GetUnitWorkTestPackagePipelineCount(unitWork.UnitWorkId);
|
||||
var unitNamesUnitIds = BLL.UnitService.getUnitNamesUnitIds(unitWork.UnitId);
|
||||
TreeNode unitWorkNode = new TreeNode
|
||||
{
|
||||
NodeID = unitWork.UnitWorkId,
|
||||
Text = unitWork.UnitWorkName + "【" + pipelineCount.ToString() + "】管线",
|
||||
ToolTip = "施工单位:" + unitNamesUnitIds,
|
||||
CommandName = TreeCommandUnitWork,
|
||||
EnableExpandEvent = true,
|
||||
EnableClickEvent = true,
|
||||
EnableCheckBox = false,
|
||||
Expanded = expandSelectedNode && unitWork.UnitWorkId == hdUnitWorkId.Text
|
||||
};
|
||||
parentNode.Nodes.Add(unitWorkNode);
|
||||
if (pipelineCount > 0)
|
||||
{
|
||||
BindTestPackageNodes(unitWorkNode);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -219,16 +253,16 @@ namespace FineUIPro.Web.HJGL.WeldingManage
|
||||
TreeNode newNode = new TreeNode();
|
||||
newNode.Text = item.PipelineCode;
|
||||
newNode.NodeID = item.PipelineId;
|
||||
newNode.CommandName = "管线";
|
||||
newNode.CommandName = TreeCommandPipeline;
|
||||
newNode.EnableClickEvent = true;
|
||||
node.Nodes.Add(newNode);
|
||||
}
|
||||
if (pageindex < pageCount)
|
||||
{
|
||||
TreeNode newNode = new TreeNode();
|
||||
newNode.Text = "加载";
|
||||
newNode.Text = TreeCommandLoad;
|
||||
newNode.NodeID = SQLHelper.GetNewID();
|
||||
newNode.CommandName = "加载";
|
||||
newNode.CommandName = TreeCommandLoad;
|
||||
newNode.Icon = Icon.ArrowDown;
|
||||
newNode.EnableClickEvent = true;
|
||||
node.Nodes.Add(newNode);
|
||||
@@ -288,7 +322,7 @@ namespace FineUIPro.Web.HJGL.WeldingManage
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取指定试压包下当前仓库、区域和筛选条件内尚未完成出库的管线。
|
||||
/// 获取指定试压包下当前仓库和页面筛选条件内尚未完成出库的管线;材料区域由匹配服务按材料明细过滤。
|
||||
/// </summary>
|
||||
/// <param name="ptpId">试压包ID。</param>
|
||||
/// <returns>符合材料匹配入口条件的管线列表。</returns>
|
||||
@@ -306,7 +340,6 @@ namespace FineUIPro.Web.HJGL.WeldingManage
|
||||
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
|
||||
@@ -353,7 +386,7 @@ namespace FineUIPro.Web.HJGL.WeldingManage
|
||||
/// <param name="e"></param>
|
||||
protected void tvControlItem_NodeCommand(object sender, TreeCommandEventArgs e)
|
||||
{
|
||||
if (e.CommandName == "加载")
|
||||
if (e.CommandName == TreeCommandLoad)
|
||||
{
|
||||
string CommandName = e.Node.ParentNode.CommandName;
|
||||
e.Node.ParentNode.CommandName = (int.Parse(CommandName.Split('|')[0]) + 1) + "|" + int.Parse(CommandName.Split('|')[1]);
|
||||
@@ -475,7 +508,12 @@ namespace FineUIPro.Web.HJGL.WeldingManage
|
||||
selectList.Add(model.Id);
|
||||
}
|
||||
|
||||
if (IsMaterialCodeConfirmed(model, confirmedPipeLineMatIds))
|
||||
// 匹配率优先级高于历史确认状态,0% 或未满配材料不能再显示为绿色。
|
||||
if (model.MatchRate == null || model.MatchRate < 1)
|
||||
{
|
||||
Grid1.Rows[i].RowCssClass = "red";
|
||||
}
|
||||
else if (IsMaterialCodeConfirmed(model, confirmedPipeLineMatIds))
|
||||
{
|
||||
Grid1.Rows[i].RowCssClass = "green";
|
||||
}
|
||||
@@ -483,10 +521,6 @@ namespace FineUIPro.Web.HJGL.WeldingManage
|
||||
{
|
||||
Grid1.Rows[i].RowCssClass = "priority";
|
||||
}
|
||||
else if (model.MatchRate < 1 || model.MatchRate == null)
|
||||
{
|
||||
Grid1.Rows[i].RowCssClass = "red";
|
||||
}
|
||||
}
|
||||
|
||||
Grid1.SelectedRowIDArray = selectList.ToArray();
|
||||
@@ -531,10 +565,11 @@ namespace FineUIPro.Web.HJGL.WeldingManage
|
||||
.Distinct()
|
||||
.ToList();
|
||||
var reportWeldJointIds = Funs.DB.HJGL_WeldJoint
|
||||
.Where(x => weldJointIds.Contains(x.WeldJointId)&& x.WeldingDailyId !=null)
|
||||
.Where(x => weldJointIds.Contains(x.WeldJointId) && x.WeldingDailyId != null && x.WeldingDailyId != "")
|
||||
.Select(x => x.WeldJointId).Distinct().ToList();
|
||||
return matchOutputs
|
||||
.Where(x => string.IsNullOrEmpty(x.WeldJointId) || !taskWeldJointIds.Contains(x.WeldJointId) || reportWeldJointIds.Contains(x.WeldJointId))
|
||||
.Where(x => string.IsNullOrEmpty(x.WeldJointId)
|
||||
|| (!taskWeldJointIds.Contains(x.WeldJointId) && !reportWeldJointIds.Contains(x.WeldJointId)))
|
||||
.ToList();
|
||||
}
|
||||
|
||||
@@ -600,7 +635,7 @@ namespace FineUIPro.Web.HJGL.WeldingManage
|
||||
/// <param name="e">事件参数。</param>
|
||||
protected void btnMatchHelp_Click(object sender, EventArgs e)
|
||||
{
|
||||
Alert.ShowInTop("1、管线绿色为匹配率100%,明细绿色为已反写材料主编码,红色为匹配率小于100%,蓝色为手动优先焊口。<br/>2、一个焊口可能对应多条材料明细,该焊口全部有效明细已反写材料主编码后才允许一键生成任务单。<br/>3、焊口已进行焊前准备,匹配了焊评才能生成任务单", "说明", MessageBoxIcon.Information);
|
||||
Alert.ShowInTop("1、管线绿色为匹配率100%,明细绿色为已反写材料主编码,红色为匹配率小于100%,蓝色为手动优先焊口。<br/>2、库存匹配顺序为手动优先焊口、存在已焊口的续作组件、其他未开工组件。<br/>3、一个焊口可能对应多条材料明细,该焊口全部有效明细已反写材料主编码后才允许一键生成任务单。<br/>4、焊口已进行焊前准备,匹配了焊评才能生成任务单", "说明", MessageBoxIcon.Information);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -625,7 +660,8 @@ namespace FineUIPro.Web.HJGL.WeldingManage
|
||||
this.CurrUser.LoginProjectId,
|
||||
dicSeclectPipeLine.Keys.ToList(),
|
||||
drpWarehouse.SelectedValue,
|
||||
GetPriorityWeldJointList());
|
||||
GetPriorityWeldJointList(),
|
||||
PipeArea);
|
||||
BindGrid3();
|
||||
BindGrid2(keepSelectedPipelineIds);
|
||||
}
|
||||
@@ -692,7 +728,74 @@ namespace FineUIPro.Web.HJGL.WeldingManage
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 按树节点获取可加入本次匹配的管线。单位工程节点会展开到其下所有试压包,再套用当前仓库、区域和页面筛选条件。
|
||||
/// 按当前材料区域导出所选单位工程下全部部分已焊接组件。
|
||||
/// </summary>
|
||||
protected void btnExportPartialComponents_Click(object sender, EventArgs e)
|
||||
{
|
||||
Model.WBS_UnitWork unitWork = tvControlItem.SelectedNode == null
|
||||
? null
|
||||
: BLL.UnitWorkService.GetUnitWorkByUnitWorkId(tvControlItem.SelectedNode.NodeID);
|
||||
if (unitWork == null)
|
||||
{
|
||||
ShowNotify("请先选择需要导出的单位工程!", MessageBoxIcon.Warning);
|
||||
return;
|
||||
}
|
||||
|
||||
var components = TwArrivalStatisticsService.GetPartialWeldedComponents(
|
||||
this.CurrUser.LoginProjectId,
|
||||
unitWork.UnitWorkId,
|
||||
PipeArea,
|
||||
drpWarehouse.SelectedValue);
|
||||
if (!components.Any())
|
||||
{
|
||||
ShowNotify("当前单位工程和区域下没有部分已焊接组件!", MessageBoxIcon.Warning);
|
||||
return;
|
||||
}
|
||||
|
||||
var exportData = components.Select(x => new
|
||||
{
|
||||
单位工程 = x.UnitWorkName,
|
||||
区域 = x.PipeAreaText,
|
||||
管线号 = x.PipelineCode,
|
||||
预制组件号 = x.PrefabricatedComponents,
|
||||
总焊口数 = x.TotalWeldJointCount,
|
||||
已焊口数 = x.WeldedWeldJointCount,
|
||||
未焊口数 = x.UnweldedWeldJointCount,
|
||||
组件匹配率 = x.ComponentMatchRateString
|
||||
}).ToList();
|
||||
|
||||
string areaText = PipeArea == PipelineService.PipeArea_SHOP ? "工厂预制" : "现场安装";
|
||||
string fileName = GetSafeFileName(unitWork.UnitWorkName) + "_" + areaText + "_部分已焊组件_" + DateTime.Now.ToString("yyyyMMdd") + ".xlsx";
|
||||
string tempDirectory = Path.Combine(Funs.RootPath, @"File\Excel\Temp");
|
||||
Directory.CreateDirectory(tempDirectory);
|
||||
string filePath = Path.Combine(tempDirectory, Guid.NewGuid().ToString("N") + ".xlsx");
|
||||
|
||||
MiniExcel.SaveAs(filePath, exportData);
|
||||
FileInfo fileInfo = new FileInfo(filePath);
|
||||
System.Web.HttpResponse response = System.Web.HttpContext.Current.Response;
|
||||
response.Clear();
|
||||
response.ContentType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
|
||||
response.AddHeader("Content-Disposition", "attachment;filename=" + System.Web.HttpUtility.UrlEncode(fileName, System.Text.Encoding.UTF8));
|
||||
response.AddHeader("Content-Length", fileInfo.Length.ToString());
|
||||
// 先读取到响应缓冲区再删除临时文件,避免 TransmitFile 异步发送期间文件仍被占用。
|
||||
response.BinaryWrite(File.ReadAllBytes(filePath));
|
||||
File.Delete(filePath);
|
||||
response.Flush();
|
||||
System.Web.HttpContext.Current.ApplicationInstance.CompleteRequest();
|
||||
}
|
||||
|
||||
private static string GetSafeFileName(string fileName)
|
||||
{
|
||||
string safeFileName = string.IsNullOrEmpty(fileName) ? "单位工程" : fileName;
|
||||
foreach (char invalidChar in Path.GetInvalidFileNameChars())
|
||||
{
|
||||
safeFileName = safeFileName.Replace(invalidChar, '_');
|
||||
}
|
||||
return safeFileName;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 按树节点获取可加入本次匹配的管线。单位工程节点会展开到其下所有试压包,再套用当前仓库和页面筛选条件。
|
||||
/// </summary>
|
||||
/// <param name="node">左侧树节点。</param>
|
||||
/// <returns>符合材料匹配入口条件的管线列表。</returns>
|
||||
@@ -703,13 +806,13 @@ namespace FineUIPro.Web.HJGL.WeldingManage
|
||||
return new List<Model.HJGL_Pipeline>();
|
||||
}
|
||||
|
||||
if (node.CommandName == "管线")
|
||||
if (node.CommandName == TreeCommandPipeline)
|
||||
{
|
||||
var pipeline = PipelineService.GetPipelineByPipelineId(node.NodeID);
|
||||
return pipeline == null ? new List<Model.HJGL_Pipeline>() : new List<Model.HJGL_Pipeline> { pipeline };
|
||||
}
|
||||
|
||||
if (node.CommandName == "单位工程")
|
||||
if (node.CommandName == TreeCommandUnitWork)
|
||||
{
|
||||
var testPackageIds = (from x in Funs.DB.PTP_TestPackage
|
||||
where x.ProjectId == this.CurrUser.LoginProjectId
|
||||
@@ -743,7 +846,7 @@ namespace FineUIPro.Web.HJGL.WeldingManage
|
||||
var selectNodes = tvControlItem.GetCheckedNodes();
|
||||
foreach (var node in selectNodes)
|
||||
{
|
||||
if (dicSeclectPipeLine.Where(x => x.Key == node.NodeID).Count() == 0 && node.CommandName == "管线")
|
||||
if (dicSeclectPipeLine.Where(x => x.Key == node.NodeID).Count() == 0 && node.CommandName == TreeCommandPipeline)
|
||||
{
|
||||
dicSeclectPipeLine.Add(node.NodeID, node.Text);
|
||||
addCount++;
|
||||
@@ -978,19 +1081,14 @@ namespace FineUIPro.Web.HJGL.WeldingManage
|
||||
ShowNotify("选中管线中没有已反写材料主编码的可生成任务单焊口!", MessageBoxIcon.Warning);
|
||||
return false;
|
||||
}
|
||||
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 weldingRods = from x in Funs.DB.Base_Consumables where x.ConsumablesType == WeldingRodConsumablesType select x;
|
||||
var weldingWires = from x in Funs.DB.Base_Consumables where x.ConsumablesType == WeldingWireConsumablesType select x;
|
||||
var selectedWeldJointIdList = selectedWeldJointIds.ToList();
|
||||
var selectRowId = GetTaskableWeldJointRows(selectedWeldJointIdList);
|
||||
|
||||
Dictionary<string, string> unitworkTaskCode = new Dictionary<string, string>();
|
||||
Dictionary<string, string> unitworkSerialNumber = new Dictionary<string, string>();
|
||||
Dictionary<int, string> matchPipeline = new Dictionary<int, string>();
|
||||
// 生成任务单仍保留管线在匹配结果中的排序,用于任务单列表按管线顺序展示。
|
||||
for (int rowIndex = 0; rowIndex < Grid2.Rows.Count; rowIndex++)
|
||||
{
|
||||
matchPipeline.Add(rowIndex + 1, Grid2.Rows[rowIndex].RowID);
|
||||
}
|
||||
Dictionary<int, string> matchPipeline = GetMatchPipelineOrder();
|
||||
if (!selectRowId.Any())
|
||||
{
|
||||
ShowNotify("未找到可生成任务单的焊口!", MessageBoxIcon.Warning);
|
||||
@@ -998,8 +1096,6 @@ namespace FineUIPro.Web.HJGL.WeldingManage
|
||||
}
|
||||
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;
|
||||
@@ -1038,59 +1134,7 @@ namespace FineUIPro.Web.HJGL.WeldingManage
|
||||
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);
|
||||
}
|
||||
}
|
||||
PopulateAlternativeConsumables(NewTask, weldJoint, weldingRods, weldingWires);
|
||||
}
|
||||
NewTask.JointAttribute = weldJoint.JointAttribute;
|
||||
|
||||
@@ -1098,7 +1142,7 @@ namespace FineUIPro.Web.HJGL.WeldingManage
|
||||
NewTask.Tabler = this.CurrUser.PersonId;
|
||||
NewTask.TableDate = DateTime.Now;
|
||||
|
||||
weldJoint.WeldingMode = "手动";
|
||||
weldJoint.WeldingMode = ManualWeldingMode;
|
||||
BLL.WeldJointService.UpdateWeldJoint(weldJoint);
|
||||
BLL.WeldTaskService.AddWeldTask(NewTask);
|
||||
}
|
||||
@@ -1106,6 +1150,61 @@ namespace FineUIPro.Web.HJGL.WeldingManage
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取当前管线汇总表中的显示顺序,供任务单保存管线排序使用。
|
||||
/// </summary>
|
||||
private Dictionary<int, string> GetMatchPipelineOrder()
|
||||
{
|
||||
var matchPipeline = new Dictionary<int, string>();
|
||||
for (int rowIndex = 0; rowIndex < Grid2.Rows.Count; rowIndex++)
|
||||
{
|
||||
matchPipeline.Add(rowIndex + 1, Grid2.Rows[rowIndex].RowID);
|
||||
}
|
||||
return matchPipeline;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 根据母材类别计算任务单可替代的焊条和焊丝。
|
||||
/// </summary>
|
||||
private void PopulateAlternativeConsumables(
|
||||
Model.HJGL_WeldTask task,
|
||||
Model.HJGL_WeldJoint weldJoint,
|
||||
IEnumerable<Model.Base_Consumables> weldingRods,
|
||||
IEnumerable<Model.Base_Consumables> weldingWires)
|
||||
{
|
||||
// 获取可替代焊材时沿用原有母材类别和焊材钢号判断规则。
|
||||
var material = BLL.Base_MaterialService.GetMaterialByMaterialId(weldJoint.Material1Id);
|
||||
string materialClass = material.MaterialClass;
|
||||
var selectedRod = weldingRods.FirstOrDefault(x => x.ConsumablesId == weldJoint.WeldingRod);
|
||||
var selectedWire = weldingWires.FirstOrDefault(x => x.ConsumablesId == weldJoint.WeldingWire);
|
||||
|
||||
task.CanWeldingRodName = GetAlternativeConsumableNames(materialClass, selectedRod, weldingRods);
|
||||
task.CanWeldingWireName = GetAlternativeConsumableNames(materialClass, selectedWire, weldingWires);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 返回与当前焊材钢号兼容的候选名称,保持原有逗号分隔格式。
|
||||
/// </summary>
|
||||
private string GetAlternativeConsumableNames(
|
||||
string materialClass,
|
||||
Model.Base_Consumables selectedConsumable,
|
||||
IEnumerable<Model.Base_Consumables> candidateConsumables)
|
||||
{
|
||||
if (selectedConsumable == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
bool useCoverClass = materialClass == CoverMaterialClassFe1 || materialClass == CoverMaterialClassFe3;
|
||||
var names = candidateConsumables
|
||||
.Where(item => useCoverClass
|
||||
? IsCoverClass(selectedConsumable.SteelType, item.SteelType)
|
||||
: selectedConsumable.SteelType == item.SteelType)
|
||||
.Select(item => item.ConsumablesName)
|
||||
.ToList();
|
||||
return names.Any() ? string.Join(",", names) : null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 按任务单实际生成规则过滤可生成任务单的焊口视图数据。
|
||||
/// </summary>
|
||||
@@ -1128,10 +1227,13 @@ namespace FineUIPro.Web.HJGL.WeldingManage
|
||||
&& x.WeldTaskId == null
|
||||
&& x.WeldingMethodCode != null
|
||||
select x).ToList();
|
||||
if (PipeArea == "1")
|
||||
if (PipeArea == PipelineService.PipeArea_SHOP)
|
||||
{
|
||||
// 工厂预制材料匹配只允许预制口生成任务单,现场安装页面不套用该限制。
|
||||
taskableRows = taskableRows.Where(x => x.JointAttribute == "预制口").ToList();
|
||||
taskableRows = taskableRows.Where(x => x.JointAttribute == PrefabricationJointAttribute).ToList();
|
||||
}
|
||||
else if (PipeArea == PipelineService.PipeArea_FIELD)
|
||||
{
|
||||
taskableRows = taskableRows.Where(x => x.JointAttribute == InstallationJointAttribute).ToList();
|
||||
}
|
||||
|
||||
return taskableRows;
|
||||
@@ -1193,26 +1295,16 @@ namespace FineUIPro.Web.HJGL.WeldingManage
|
||||
/// <returns>能覆盖返回 true,否则返回 false。</returns>
|
||||
private bool IsCoverClass(string wpsClass, string matClass)
|
||||
{
|
||||
bool isCover = false;
|
||||
int wpsSn = 0;
|
||||
int matSn = 0;
|
||||
if (wpsClass.Length > 2 && matClass.Length > 2)
|
||||
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 false;
|
||||
}
|
||||
return isCover;
|
||||
|
||||
string wpsPre = wpsClass.Substring(0, wpsClass.Length - 2);
|
||||
string matPre = matClass.Substring(0, matClass.Length - 2);
|
||||
int wpsSn = Funs.GetNewInt(wpsClass.Substring(wpsClass.Length - 1, 1)) ?? 0;
|
||||
int matSn = Funs.GetNewInt(matClass.Substring(matClass.Length - 1, 1)) ?? 0;
|
||||
return wpsPre == matPre && matSn >= wpsSn;
|
||||
}
|
||||
|
||||
#endregion 按钮事件
|
||||
|
||||
Reference in New Issue
Block a user