feat(hjgl): 支持组件焊口导入和优先匹配
组件与焊口关系需要参与材料匹配、任务生成和出库明细计算。 新增组件焊口导入入口,并允许在材料匹配时手动指定优先组件, 确保按组件范围生成任务单和领料数据。
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user