feat(hjgl): 支持组件焊口导入和优先匹配
组件与焊口关系需要参与材料匹配、任务生成和出库明细计算。 新增组件焊口导入入口,并允许在材料匹配时手动指定优先组件, 确保按组件范围生成任务单和领料数据。
This commit is contained in:
@@ -34,6 +34,11 @@
|
||||
background-color: green;
|
||||
}
|
||||
|
||||
.f-grid-row.priority {
|
||||
background-color: #1e88e5;
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
.f-grid-row {
|
||||
font-size: smaller;
|
||||
}
|
||||
@@ -138,7 +143,9 @@
|
||||
<f:Toolbar ID="Toolbar3" Position="Top" runat="server" ToolbarAlign="Left">
|
||||
<Items>
|
||||
<f:Label ID="lbRate" runat="server" LabelWidth="100px" Hidden="true"></f:Label>
|
||||
<f:Label ID="lbNote" runat="server" LabelWidth="100px" Text="绿色为匹配率100%,红色为匹配率小于100%"></f:Label>
|
||||
<f:Label ID="lbNote" runat="server" LabelWidth="100px" Text="绿色为匹配率100%,红色为匹配率小于100%,蓝色为手动优先组件"></f:Label>
|
||||
<f:Button ID="btnPriorityComponents" Text="优先匹配选中组件" Icon="TabGo" runat="server" OnClick="btnPriorityComponents_Click">
|
||||
</f:Button>
|
||||
<f:Button ID="btnGenTask" ToolTip="生成任务单" Icon="ApplicationViewIcons" runat="server" OnClick="btnGenTask_Click" ConfirmText="确定生成任务单吗?">
|
||||
</f:Button>
|
||||
<f:CheckBox ID="cbSelectCom" ShowLabel="false" runat="server" Text="默认勾选匹配100%" Checked="true">
|
||||
@@ -174,9 +181,9 @@
|
||||
|
||||
<Items>
|
||||
<f:Grid ID="Grid1" ShowBorder="true" ShowHeader="false" Title="材料匹配明细" EnableRowClickEvent="true"
|
||||
EnableCollapse="true" runat="server" BoxFlex="1" DataKeyNames="Id" ForceFit="true"
|
||||
EnableCollapse="true" runat="server" BoxFlex="1" DataKeyNames="Id,PipelineId,PrefabricatedComponents" ForceFit="true"
|
||||
EnableColumnLines="true" DataIDField="Id" AllowSorting="true" OnRowDataBound="Grid1_RowDataBound"
|
||||
SortField="Id" SortDirection="ASC" OnSort="Grid1_Sort">
|
||||
SortField="Id" SortDirection="ASC" OnSort="Grid1_Sort" EnableCheckBoxSelect="true">
|
||||
<Columns>
|
||||
<f:RenderField Width="200px" ColumnID="PipelineCode" DataField="PipelineCode" SortField="PipelineCode"
|
||||
FieldType="String" HeaderText="管线号" HeaderTextAlign="Center"
|
||||
|
||||
@@ -70,6 +70,24 @@ namespace FineUIPro.Web.HJGL.WeldingManage
|
||||
}
|
||||
}
|
||||
|
||||
public Dictionary<string, HashSet<string>> priorityComponents
|
||||
{
|
||||
get
|
||||
{
|
||||
var value = ViewState["priorityComponents"] as Dictionary<string, HashSet<string>>;
|
||||
if (value == null)
|
||||
{
|
||||
value = new Dictionary<string, HashSet<string>>();
|
||||
ViewState["priorityComponents"] = value;
|
||||
}
|
||||
return value;
|
||||
}
|
||||
set
|
||||
{
|
||||
ViewState["priorityComponents"] = value;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
protected void Page_Load(object sender, EventArgs e)
|
||||
{
|
||||
@@ -86,6 +104,7 @@ namespace FineUIPro.Web.HJGL.WeldingManage
|
||||
; HJGL_MaterialService.materialStockItems_FIELD = new List<Model.MaterialStockItem>();
|
||||
HJGL_MaterialService.materialStockItems_SHOP = new List<Model.MaterialStockItem>();
|
||||
dicSeclectPipeLine = new Dictionary<string, string>();
|
||||
priorityComponents = 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();
|
||||
@@ -464,23 +483,66 @@ namespace FineUIPro.Web.HJGL.WeldingManage
|
||||
}*/
|
||||
|
||||
}
|
||||
protected void Grid2_RowClick(object sender, GridRowClickEventArgs e)
|
||||
|
||||
private void BindMaterialDetail(string pipelineId)
|
||||
{
|
||||
var tb = tw_PipeMatMatchOutputs.Where(x => x.PipelineId == Grid2.SelectedRowID).ToList();
|
||||
var tb = tw_PipeMatMatchOutputs.Where(x => x.PipelineId == pipelineId).ToList();
|
||||
Grid1.DataSource = tb;
|
||||
Grid1.DataBind();
|
||||
|
||||
var selectList = new List<string>();
|
||||
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)
|
||||
if (model == null)
|
||||
{
|
||||
Grid1.Rows[i].RowCssClass = "red";
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
if (IsPriorityComponent(model.PipelineId, model.PrefabricatedComponents))
|
||||
{
|
||||
Grid1.Rows[i].RowCssClass = "priority";
|
||||
selectList.Add(model.Id);
|
||||
}
|
||||
else if (model.MatchRate < 1 || model.MatchRate == null)
|
||||
{
|
||||
Grid1.Rows[i].RowCssClass = "red";
|
||||
}
|
||||
}
|
||||
|
||||
Grid1.SelectedRowIDArray = selectList.ToArray();
|
||||
}
|
||||
|
||||
private bool IsPriorityComponent(string pipelineId, string prefabricatedComponents)
|
||||
{
|
||||
return !string.IsNullOrEmpty(pipelineId)
|
||||
&& !string.IsNullOrEmpty(prefabricatedComponents)
|
||||
&& priorityComponents.ContainsKey(pipelineId)
|
||||
&& priorityComponents[pipelineId].Contains(prefabricatedComponents);
|
||||
}
|
||||
|
||||
private Dictionary<string, List<string>> GetPriorityComponentList()
|
||||
{
|
||||
return priorityComponents
|
||||
.Where(x => x.Value != null && x.Value.Any())
|
||||
.ToDictionary(x => x.Key, x => x.Value.ToList());
|
||||
}
|
||||
|
||||
private void RefreshMatchResult()
|
||||
{
|
||||
tw_PipeMatMatchOutputs = TwArrivalStatisticsService.GetPipeMatMatch(
|
||||
this.CurrUser.LoginProjectId,
|
||||
dicSeclectPipeLine.Keys.ToList(),
|
||||
drpWarehouse.SelectedValue,
|
||||
GetPriorityComponentList());
|
||||
BindGrid3();
|
||||
BindGrid2();
|
||||
}
|
||||
|
||||
protected void Grid2_RowClick(object sender, GridRowClickEventArgs e)
|
||||
{
|
||||
BindMaterialDetail(Grid2.SelectedRowID);
|
||||
|
||||
}
|
||||
protected void Grid1_RowClick(object sender, GridRowClickEventArgs e)
|
||||
{
|
||||
@@ -520,7 +582,14 @@ namespace FineUIPro.Web.HJGL.WeldingManage
|
||||
{
|
||||
Grid1.SortDirection = e.SortDirection;
|
||||
Grid1.SortField = e.SortField;
|
||||
BindGrid();
|
||||
if (!string.IsNullOrEmpty(Grid2.SelectedRowID) && tw_PipeMatMatchOutputs != null && tw_PipeMatMatchOutputs.Any())
|
||||
{
|
||||
BindMaterialDetail(Grid2.SelectedRowID);
|
||||
}
|
||||
else
|
||||
{
|
||||
BindGrid();
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
@@ -613,10 +682,7 @@ namespace FineUIPro.Web.HJGL.WeldingManage
|
||||
dicSeclectPipeLine.Add(node.NodeID, node.Text);
|
||||
}
|
||||
}
|
||||
tw_PipeMatMatchOutputs = TwArrivalStatisticsService.GetPipeMatMatch(this.CurrUser.LoginProjectId, dicSeclectPipeLine.Keys.ToList(), drpWarehouse.SelectedValue);
|
||||
|
||||
BindGrid3();
|
||||
BindGrid2();
|
||||
RefreshMatchResult();
|
||||
}
|
||||
|
||||
protected void btnDeletePipelineMatchMat_Click(object sender, EventArgs e)
|
||||
@@ -626,6 +692,7 @@ namespace FineUIPro.Web.HJGL.WeldingManage
|
||||
foreach (string rowId in Grid3.SelectedRowIDArray)
|
||||
{
|
||||
dicSeclectPipeLine.Remove(rowId);
|
||||
priorityComponents.Remove(rowId);
|
||||
var node = tvControlItem.FindNode(rowId);
|
||||
if (node != null)
|
||||
{
|
||||
@@ -633,25 +700,63 @@ namespace FineUIPro.Web.HJGL.WeldingManage
|
||||
}
|
||||
}
|
||||
|
||||
tw_PipeMatMatchOutputs = TwArrivalStatisticsService.GetPipeMatMatch(this.CurrUser.LoginProjectId, dicSeclectPipeLine.Keys.ToList(), drpWarehouse.SelectedValue);
|
||||
|
||||
BindGrid3();
|
||||
BindGrid2();
|
||||
RefreshMatchResult();
|
||||
}
|
||||
}
|
||||
|
||||
protected void btnPriorityComponents_Click(object sender, EventArgs e)
|
||||
{
|
||||
string selectedPipelineId = Grid2.SelectedRowID;
|
||||
if (string.IsNullOrEmpty(selectedPipelineId))
|
||||
{
|
||||
ShowNotify("请先在材料匹配列表选择管线!", MessageBoxIcon.Warning);
|
||||
return;
|
||||
}
|
||||
|
||||
var selectedComponents = new HashSet<string>();
|
||||
foreach (int rowIndex in Grid1.SelectedRowIndexArray)
|
||||
{
|
||||
if (Grid1.DataKeys[rowIndex].Length < 3)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
string pipelineId = Grid1.DataKeys[rowIndex][1]?.ToString();
|
||||
string componentCode = Grid1.DataKeys[rowIndex][2]?.ToString();
|
||||
if (pipelineId == selectedPipelineId && !string.IsNullOrEmpty(componentCode))
|
||||
{
|
||||
selectedComponents.Add(componentCode);
|
||||
}
|
||||
}
|
||||
|
||||
if (selectedComponents.Any())
|
||||
{
|
||||
priorityComponents[selectedPipelineId] = selectedComponents;
|
||||
}
|
||||
else
|
||||
{
|
||||
priorityComponents.Remove(selectedPipelineId);
|
||||
}
|
||||
|
||||
RefreshMatchResult();
|
||||
BindMaterialDetail(selectedPipelineId);
|
||||
}
|
||||
|
||||
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();
|
||||
if (SaveTask())
|
||||
{
|
||||
ShowNotify("生成任务单成功!", MessageBoxIcon.Warning);
|
||||
// Alert.Show("生成任务单成功!", MessageBoxIcon.Warning);
|
||||
Grid1.DataSource = null;
|
||||
Grid1.DataBind();
|
||||
Grid2.DataSource = null;
|
||||
Grid2.DataBind();
|
||||
Grid3.DataSource = null;
|
||||
Grid3.DataBind();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -659,7 +764,7 @@ namespace FineUIPro.Web.HJGL.WeldingManage
|
||||
}
|
||||
|
||||
}
|
||||
private void SaveTask()
|
||||
private bool 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;
|
||||
@@ -679,6 +784,21 @@ namespace FineUIPro.Web.HJGL.WeldingManage
|
||||
{
|
||||
selectRowId = selectRowId.Where(x => x.JointAttribute == "预制口").ToList();
|
||||
}
|
||||
var priorityWeldJointIds = GetPriorityWeldJointIds(Grid2.SelectedRowIDArray.ToList());
|
||||
if (priorityWeldJointIds.Any())
|
||||
{
|
||||
if (priorityWeldJointIds.Any(x => !x.Value.Any()))
|
||||
{
|
||||
ShowNotify("选中组件未找到关联焊口,无法按组件生成任务单!", MessageBoxIcon.Warning);
|
||||
return false;
|
||||
}
|
||||
selectRowId = selectRowId.Where(x => !priorityWeldJointIds.ContainsKey(x.PipelineId) || priorityWeldJointIds[x.PipelineId].Contains(x.WeldJointId)).ToList();
|
||||
}
|
||||
if (!selectRowId.Any())
|
||||
{
|
||||
ShowNotify("未找到可生成任务单的焊口!", MessageBoxIcon.Warning);
|
||||
return false;
|
||||
}
|
||||
foreach (var weldjoint in selectRowId)
|
||||
{
|
||||
string canWeldingRodName = string.Empty;
|
||||
@@ -713,7 +833,7 @@ namespace FineUIPro.Web.HJGL.WeldingManage
|
||||
if (oldWeldTask != null)
|
||||
{
|
||||
ShowNotify("所选焊口已存在任务单,无法保存!", MessageBoxIcon.Warning);
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
Model.HJGL_WeldJoint weldJoint = BLL.WeldJointService.GetWeldJointByWeldJointId(NewTask.WeldJointId);
|
||||
if (weldJoint != null)
|
||||
@@ -786,7 +906,36 @@ namespace FineUIPro.Web.HJGL.WeldingManage
|
||||
BLL.WeldTaskService.AddWeldTask(NewTask);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private Dictionary<string, HashSet<string>> GetPriorityWeldJointIds(List<string> selectedPipelineIds)
|
||||
{
|
||||
var result = new Dictionary<string, HashSet<string>>();
|
||||
var selectedPriority = priorityComponents
|
||||
.Where(x => selectedPipelineIds.Contains(x.Key) && x.Value != null && x.Value.Any())
|
||||
.ToList();
|
||||
|
||||
foreach (var item in selectedPriority)
|
||||
{
|
||||
string pipelineId = item.Key;
|
||||
var componentCodes = item.Value.ToList();
|
||||
var weldJointIds = (from joint in Funs.DB.HJGL_Pipeline_ComponentJoint
|
||||
join weldJoint in Funs.DB.HJGL_WeldJoint on joint.WeldJointId equals weldJoint.WeldJointId
|
||||
join component in Funs.DB.HJGL_Pipeline_Component on joint.PipelineComponentId equals component.PipelineComponentId into componentJoin
|
||||
from componentItem in componentJoin.DefaultIfEmpty()
|
||||
where joint.WeldJointId != null
|
||||
&& weldJoint.PipelineId == pipelineId
|
||||
&& ((componentItem != null && componentCodes.Contains(componentItem.PipelineComponentCode))
|
||||
|| componentCodes.Contains(joint.PipelineComponentCode))
|
||||
select joint.WeldJointId).Distinct().ToList();
|
||||
|
||||
result[pipelineId] = new HashSet<string>(weldJointIds);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
private bool IsCoverClass(string wpsClass, string matClass)
|
||||
{
|
||||
bool isCover = false;
|
||||
|
||||
@@ -257,6 +257,15 @@ namespace FineUIPro.Web.HJGL.WeldingManage
|
||||
/// </remarks>
|
||||
protected global::FineUIPro.Label lbNote;
|
||||
|
||||
/// <summary>
|
||||
/// btnPriorityComponents 控件。
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// 自动生成的字段。
|
||||
/// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。
|
||||
/// </remarks>
|
||||
protected global::FineUIPro.Button btnPriorityComponents;
|
||||
|
||||
/// <summary>
|
||||
/// btnGenTask 控件。
|
||||
/// </summary>
|
||||
|
||||
Reference in New Issue
Block a user