201443e437
管线材料导入需要关联到具体焊口,并允许按材料编码匹配库存后回写 材料主编码。新增 HJGL_PipeLineMat 的焊口和材料编码字段,材料匹配、 任务生成和出库关系同步按焊口维度处理,避免仅按组件匹配导致材料 范围不准确。
142 lines
5.3 KiB
C#
142 lines
5.3 KiB
C#
using Model;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
namespace BLL
|
|
{
|
|
|
|
public static class PipelineMatService
|
|
{
|
|
/// <summary>
|
|
///获取管线材料信息
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
public static Model.HJGL_PipeLineMat GetPipeLineMat(string pipelineMatId)
|
|
{
|
|
return Funs.DB.HJGL_PipeLineMat.FirstOrDefault(e => e.PipeLineMatId == pipelineMatId);
|
|
}
|
|
|
|
public static List<Model.HJGL_PipeLineMat> GetPipeLineMatsByPipelineId(string pipelineId)
|
|
{
|
|
return Funs.DB.HJGL_PipeLineMat.Where(e => e.PipelineId == pipelineId).ToList();
|
|
}
|
|
|
|
/// <summary>
|
|
/// 增加管线材料
|
|
/// </summary>
|
|
/// <param name="PipingClass"></param>
|
|
public static void AddPipeLineMat(Model.HJGL_PipeLineMat pipelineMat)
|
|
{
|
|
Model.SGGLDB db = Funs.DB;
|
|
Model.HJGL_PipeLineMat newPipelineMat = new HJGL_PipeLineMat
|
|
{
|
|
PipeLineMatId = pipelineMat.PipeLineMatId,
|
|
MaterialCode = pipelineMat.MaterialCode,
|
|
MaterialCode2 = pipelineMat.MaterialCode2,
|
|
WeldJointId = pipelineMat.WeldJointId,
|
|
PipelineId = pipelineMat.PipelineId,
|
|
Number = pipelineMat.Number,
|
|
PrefabricatedComponents = pipelineMat.PrefabricatedComponents,
|
|
};
|
|
db.HJGL_PipeLineMat.InsertOnSubmit(newPipelineMat);
|
|
db.SubmitChanges();
|
|
}
|
|
|
|
/// <summary>
|
|
/// 修改管线材料
|
|
/// </summary>
|
|
/// <param name="pipingClass"></param>
|
|
public static void UpdatePipeLineMat(Model.HJGL_PipeLineMat pipelineMat)
|
|
{
|
|
Model.SGGLDB db = Funs.DB;
|
|
Model.HJGL_PipeLineMat newPipelineMat = db.HJGL_PipeLineMat.FirstOrDefault(e => e.PipeLineMatId == pipelineMat.PipeLineMatId);
|
|
if (newPipelineMat != null)
|
|
{
|
|
newPipelineMat.MaterialCode = pipelineMat.MaterialCode;
|
|
newPipelineMat.MaterialCode2 = pipelineMat.MaterialCode2;
|
|
newPipelineMat.WeldJointId = pipelineMat.WeldJointId;
|
|
newPipelineMat.PipelineId = pipelineMat.PipelineId;
|
|
newPipelineMat.Number = pipelineMat.Number;
|
|
newPipelineMat.PrefabricatedComponents = pipelineMat.PrefabricatedComponents;
|
|
db.SubmitChanges();
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 根据材料匹配结果反写材料主编码
|
|
/// </summary>
|
|
/// <param name="matchedMaterials">匹配成功的管线材料</param>
|
|
/// <returns>反写数量</returns>
|
|
public static int UpdateMaterialCodeByMatchOutputs(IEnumerable<Model.Tw_PipeMatMatchOutput> matchedMaterials)
|
|
{
|
|
Model.SGGLDB db = Funs.DB;
|
|
int count = 0;
|
|
foreach (var item in matchedMaterials)
|
|
{
|
|
if (item == null || string.IsNullOrEmpty(item.PipeLineMatId) || string.IsNullOrEmpty(item.MatchMaterialCode))
|
|
{
|
|
continue;
|
|
}
|
|
|
|
var pipeLineMat = db.HJGL_PipeLineMat.FirstOrDefault(e => e.PipeLineMatId == item.PipeLineMatId);
|
|
if (pipeLineMat == null)
|
|
{
|
|
continue;
|
|
}
|
|
|
|
pipeLineMat.MaterialCode = item.MatchMaterialCode;
|
|
count++;
|
|
}
|
|
|
|
if (count > 0)
|
|
{
|
|
db.SubmitChanges();
|
|
}
|
|
|
|
return count;
|
|
}
|
|
/// <summary>
|
|
/// 根据unitworkid删除焊口
|
|
/// </summary>
|
|
/// <param name="unitworkId"></param>
|
|
public static void DeletePipeLineMatByUnitWorkId(string unitworkId)
|
|
{
|
|
var oldPipeline = BLL.PipelineService.GetPipelinesByUnitWordId(unitworkId);
|
|
if (oldPipeline != null)
|
|
{
|
|
foreach (var pipeline in oldPipeline)
|
|
{
|
|
HJGL_PipelineComponentService.DeletePipelineComponentBypipelineId(pipeline.PipelineId);//删除原有管线对应组件
|
|
DeletePipeLineMatBypipelineId(pipeline.PipelineId); //删除原有管线对应材料
|
|
}
|
|
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// 根据主键删除管线材料
|
|
/// </summary>
|
|
/// <param name="pipingClassId"></param>
|
|
public static void DeletePipeLineMat(string pipelineMatId)
|
|
{
|
|
Model.SGGLDB db = Funs.DB;
|
|
Model.HJGL_PipeLineMat delPipelineMat = db.HJGL_PipeLineMat.FirstOrDefault(e => e.PipeLineMatId == pipelineMatId);
|
|
HJGL_PipelineComponentService.DeletePipelineComponentByMatId(pipelineMatId);
|
|
if (delPipelineMat != null)
|
|
{
|
|
db.HJGL_PipeLineMat.DeleteOnSubmit(delPipelineMat);
|
|
db.SubmitChanges();
|
|
}
|
|
}
|
|
|
|
public static void DeletePipeLineMatBypipelineId(string pipelineId)
|
|
{
|
|
Model.SGGLDB db = Funs.DB;
|
|
var delPipelineMat = db.HJGL_PipeLineMat.Where(e => e.PipelineId == pipelineId);
|
|
if (delPipelineMat != null)
|
|
{
|
|
db.HJGL_PipeLineMat.DeleteAllOnSubmit(delPipelineMat);
|
|
db.SubmitChanges();
|
|
}
|
|
}
|
|
}
|
|
}
|