feat(hjgl): 支持按焊口匹配和回写管线材料

管线材料导入需要关联到具体焊口,并允许按材料编码匹配库存后回写
材料主编码。新增 HJGL_PipeLineMat 的焊口和材料编码字段,材料匹配、
任务生成和出库关系同步按焊口维度处理,避免仅按组件匹配导致材料
范围不准确。
This commit is contained in:
2026-06-11 10:39:58 +08:00
parent c48972cc60
commit 201443e437
15 changed files with 488 additions and 206 deletions
@@ -138,7 +138,7 @@ namespace FineUIPro.Web.HJGL.WeldingManage
Model.ResponeData responeData = new Model.ResponeData();
List<string> result = new List<string>();
if (count < 6)
if (count < 5)
{
responeData.code = 0;
responeData.message = "导入Excel格式错误!Excel只有" + count.ToString().Trim() + "列";
@@ -182,43 +182,48 @@ namespace FineUIPro.Web.HJGL.WeldingManage
if (pds[i].C != null && !string.IsNullOrEmpty(pds[i].C.ToString()))
{
string materialCode = pds[i].C.ToString().Trim();
string furnaceNo = pds[i].D == null ? string.Empty : pds[i].D.ToString().Trim();
string batchNo = pds[i].E == null ? string.Empty : pds[i].E.ToString().Trim();
if (pds[i].D == null || string.IsNullOrEmpty(pds[i].D.ToString()))
if (!string.IsNullOrEmpty(item.PipelineId))
{
result.Add((i + 2) + "Line, [炉号] 不能为空</br>");
}
if (pds[i].E == null || string.IsNullOrEmpty(pds[i].E.ToString()))
{
result.Add((i + 2) + "Line, [批号] 不能为空</br>");
}
if (!string.IsNullOrEmpty(materialCode) && !string.IsNullOrEmpty(furnaceNo) && !string.IsNullOrEmpty(batchNo))
{
string fullMaterialCode = materialCode + "-" + furnaceNo + "-" + batchNo;
var lib = from x in Funs.DB.HJGL_MaterialCodeLib where x.MaterialCode == fullMaterialCode select x;
if (lib.Count() > 0)
string weldJointCode = pds[i].C.ToString().Trim();
var weldJoint = BLL.WeldJointService.GetWeldJointsByWeldJointCode(item.PipelineId, weldJointCode);
if (weldJoint != null)
{
item.MaterialCode = fullMaterialCode;
item.WeldJointId = weldJoint.WeldJointId;
}
else
{
result.Add("不存在此材料:" + fullMaterialCode);
result.Add("第" + (i + 2).ToString() + "行,当前管线不存在此焊口号-" + weldJointCode + "</br>");
}
}
}
else
{
result.Add((i + 2) + "Line, [焊口号] 不能为空</br>");
}
if (pds[i].D != null && !string.IsNullOrEmpty(pds[i].D.ToString()))
{
string materialCode = pds[i].D.ToString().Trim();
var lib = from x in Funs.DB.HJGL_MaterialCodeLib where x.Code == materialCode select x;
if (lib.Count() > 0)
{
item.MaterialCode2 = materialCode;
}
else
{
result.Add("第" + (i + 2).ToString() + "行,材料编码库不存在此材料编码-" + materialCode + "</br>");
}
}
else
{
result.Add((i + 2) + "Line, [材料编码] 不能为空</br>");
}
if (pds[i].F != null && !string.IsNullOrEmpty(pds[i].F.ToString()))
if (pds[i].E != null && !string.IsNullOrEmpty(pds[i].E.ToString()))
{
try
{
var number = Funs.GetNewDecimal(pds[i].F.ToString());
var number = Funs.GetNewDecimal(pds[i].E.ToString());
item.Number = number;
}
catch (Exception)
@@ -247,7 +252,7 @@ namespace FineUIPro.Web.HJGL.WeldingManage
// result.Add((i + 2) + "Line, [预制组件] 不能为空</br>");
}
}
var model = matList.Where(x => x.PipelineId == item.PipelineId && x.MaterialCode == item.MaterialCode && x.PrefabricatedComponents == item.PrefabricatedComponents);
var model = matList.Where(x => x.PipelineId == item.PipelineId && x.MaterialCode2 == item.MaterialCode2 && x.WeldJointId == item.WeldJointId && x.PrefabricatedComponents == item.PrefabricatedComponents);
if (model.Count() == 0)
{
matList.Add(item);
@@ -478,7 +483,12 @@ namespace FineUIPro.Web.HJGL.WeldingManage
{
foreach (var item in matList)
{
var pipeLineMat = from x in Funs.DB.HJGL_PipeLineMat where x.MaterialCode == item.MaterialCode && x.PipelineId == item.PipelineId && x.PrefabricatedComponents == item.PrefabricatedComponents select x;
var pipeLineMat = from x in Funs.DB.HJGL_PipeLineMat
where x.MaterialCode2 == item.MaterialCode2
&& x.WeldJointId == item.WeldJointId
&& x.PipelineId == item.PipelineId
&& x.PrefabricatedComponents == item.PrefabricatedComponents
select x;
if (pipeLineMat.Count() == 0 || pipeLineMat == null)
{
item.PipeLineMatId = SQLHelper.GetNewID(typeof(Model.HJGL_PipeLineMat));
@@ -486,7 +496,12 @@ namespace FineUIPro.Web.HJGL.WeldingManage
}
else
{
item.PipeLineMatId = pipeLineMat.First().PipeLineMatId;
var oldPipeLineMat = pipeLineMat.First();
item.PipeLineMatId = oldPipeLineMat.PipeLineMatId;
if (string.IsNullOrEmpty(item.MaterialCode))
{
item.MaterialCode = oldPipeLineMat.MaterialCode;
}
BLL.PipelineMatService.UpdatePipeLineMat(item);
}
BLL.HJGL_PipelineComponentService.SyncPipelineComponentByMatId(item.PipeLineMatId);