feat(hjgl): 支持组件焊口导入和优先匹配

组件与焊口关系需要参与材料匹配、任务生成和出库明细计算。
新增组件焊口导入入口,并允许在材料匹配时手动指定优先组件,
确保按组件范围生成任务单和领料数据。
This commit is contained in:
2026-05-27 12:01:30 +08:00
parent 883493e02e
commit 49d59df7df
13 changed files with 841 additions and 47 deletions
+37 -14
View File
@@ -720,18 +720,41 @@ namespace BLL
return;
}
var pipelineList = db.View_HJGL_WeldingTask.Where(e => e.UnitWorkId == unitworkid && e.UnitId == unitid && e.TaskDate.Value.Date == date.Date && e.SerialNumber == serialNumber).OrderBy(x => x.PipeLineSortIndex).Select(x => x.PipelineId).Distinct().ToList();
var taskWeldJointIds = db.View_HJGL_WeldingTask
.Where(e => e.UnitWorkId == unitworkid && e.UnitId == unitid && e.TaskDate.Value.Date == date.Date && e.SerialNumber == serialNumber && e.WeldJointId != null)
.Select(e => e.WeldJointId)
.Distinct()
.ToList();
var taskComponents = (from relation in db.HJGL_Pipeline_ComponentJoint
join component in db.HJGL_Pipeline_Component on relation.PipelineComponentId equals component.PipelineComponentId into componentJoin
from componentItem in componentJoin.DefaultIfEmpty()
join weldJointItem in db.HJGL_WeldJoint on relation.WeldJointId equals weldJointItem.WeldJointId
where taskWeldJointIds.Contains(relation.WeldJointId)
&& weldJointItem.PipelineId != null
&& (relation.PipelineComponentCode != null || (componentItem != null && componentItem.PipelineComponentCode != null))
select new
{
PipelineId = weldJointItem.PipelineId,
PipelineComponentCode = componentItem != null && componentItem.PipelineComponentCode != null ? componentItem.PipelineComponentCode : relation.PipelineComponentCode
}).Distinct().ToList();
//领料出库需要排除散件材料
var MaterDatial = from x in db.HJGL_PipeLineMat
join y in db.HJGL_MaterialCodeLib on x.MaterialCode equals y.MaterialCode
where pipelineList.Contains(x.PipelineId) && x.PrefabricatedComponents != null
select new
{
x.PipelineId,
x.PrefabricatedComponents,
x.MaterialCode,
x.Number,
y.MaterialUnit,
};
var allMaterDatial = (from x in db.HJGL_PipeLineMat
join y in db.HJGL_MaterialCodeLib on x.MaterialCode equals y.MaterialCode
where pipelineList.Contains(x.PipelineId) && x.PrefabricatedComponents != null
select new
{
x.PipelineId,
x.PrefabricatedComponents,
x.MaterialCode,
x.Number,
y.MaterialUnit,
}).ToList();
var componentPipelineIds = taskComponents.Select(x => x.PipelineId).Distinct().ToList();
var MaterDatial = taskComponents.Any()
? allMaterDatial.Where(mat => !componentPipelineIds.Contains(mat.PipelineId)
|| taskComponents.Any(component => component.PipelineId == mat.PipelineId
&& component.PipelineComponentCode == mat.PrefabricatedComponents)).ToList()
: allMaterDatial;
//var outMateriaList = from x in db.HJGL_PipeLineMat
// join y in db.HJGL_MaterialCodeLib on x.MaterialCode equals y.MaterialCode
// where pipelineList.Contains(x.PipelineId)
@@ -787,7 +810,7 @@ namespace BLL
};
TwInOutplandetailService.Add(detail);
}
var twinoutplandetailRelationList = MaterDatial.ToList().Select(x => new Tw_InOutPlanDetail_Relation
var twinoutplandetailRelationList = MaterDatial.Select(x => new Tw_InOutPlanDetail_Relation
{
PipelineId = x.PipelineId,
MaterialCode = x.MaterialCode,
@@ -826,7 +849,7 @@ namespace BLL
};
TwInOutplandetailService.Add(detail);
}
var twinoutplandetailRelationList = MaterDatial.ToList().Select(x => new Tw_InOutPlanDetail_Relation
var twinoutplandetailRelationList = MaterDatial.Select(x => new Tw_InOutPlanDetail_Relation
{
PipelineId = x.PipelineId,
MaterialCode = x.MaterialCode,
@@ -841,4 +864,4 @@ namespace BLL
}
}
}