bb6615ebb0
焊前检查需要同时覆盖下料、组对和防腐检查,并支持移动端查询与保存。 扩展焊前检查模型、服务和页面字段,补充检查结果、不合格原因、整改要求、 附件和防腐检查记录,便于按焊口和材料追溯检查过程。
192 lines
7.1 KiB
C#
192 lines
7.1 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="pipelineMatId">管线材料ID</param>
|
|
/// <param name="materialCode">材料编码</param>
|
|
public static void UpdateMaterialCode2(string pipelineMatId, string materialCode)
|
|
{
|
|
Model.SGGLDB db = Funs.DB;
|
|
Model.HJGL_PipeLineMat pipeLineMat = db.HJGL_PipeLineMat.FirstOrDefault(e => e.PipeLineMatId == pipelineMatId);
|
|
if (pipeLineMat != null)
|
|
{
|
|
pipeLineMat.MaterialCode2 = materialCode;
|
|
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>
|
|
/// 按管线材料ID清除已反写的材料主编码,保留导入材料编码。
|
|
/// </summary>
|
|
/// <param name="pipeLineMatIds">管线材料ID列表。</param>
|
|
/// <returns>清除数量。</returns>
|
|
public static int ClearMaterialCodeByPipeLineMatIds(IEnumerable<string> pipeLineMatIds)
|
|
{
|
|
var idList = pipeLineMatIds == null
|
|
? new List<string>()
|
|
: pipeLineMatIds.Where(x => !string.IsNullOrEmpty(x)).Distinct().ToList();
|
|
if (!idList.Any())
|
|
{
|
|
return 0;
|
|
}
|
|
|
|
Model.SGGLDB db = Funs.DB;
|
|
int count = 0;
|
|
var pipeLineMats = db.HJGL_PipeLineMat
|
|
.Where(e => idList.Contains(e.PipeLineMatId) && e.MaterialCode != null && e.MaterialCode != "")
|
|
.ToList();
|
|
foreach (var item in pipeLineMats)
|
|
{
|
|
item.MaterialCode = null;
|
|
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();
|
|
}
|
|
}
|
|
}
|
|
}
|