Basf_TCC11/HJGL/BLL/HotProcessHard/HotProess_TrustService.cs

199 lines
9.1 KiB
C#

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace BLL
{
/// <summary>
/// 热处理设备
/// </summary>
public static class HotProess_TrustService
{
/// <summary>
/// 根据主键获取热处理
/// </summary>
/// <param name="hotProessTrustId"></param>
/// <returns></returns>
public static Model.HotProess_Trust GetHotProessTrustById(string hotProessTrustId)
{
return Funs.DB.HotProess_Trust.FirstOrDefault(e => e.HotProessTrustId == hotProessTrustId);
}
/// <summary>
/// 添加热处理
/// </summary>
/// <param name="hotProessTrust"></param>
public static void AddHotProessTrust(Model.HotProess_Trust hotProessTrust)
{
Model.HJGLDB db = Funs.DB;
Model.HotProess_Trust newHotProessTrust = new Model.HotProess_Trust();
newHotProessTrust.HotProessTrustId = hotProessTrust.HotProessTrustId;
newHotProessTrust.HotProessTrustNo = hotProessTrust.HotProessTrustNo;
newHotProessTrust.ProessDate = hotProessTrust.ProessDate;
newHotProessTrust.InstallationId = hotProessTrust.InstallationId;
newHotProessTrust.ProjectId = hotProessTrust.ProjectId;
newHotProessTrust.UnitId = hotProessTrust.UnitId;
newHotProessTrust.Tabler = hotProessTrust.Tabler;
newHotProessTrust.Remark = hotProessTrust.Remark;
newHotProessTrust.ProessMethod = hotProessTrust.ProessMethod;
newHotProessTrust.ProessEquipment = hotProessTrust.ProessEquipment;
db.HotProess_Trust.InsertOnSubmit(newHotProessTrust);
db.SubmitChanges();
}
/// <summary>
/// 修改热处理
/// </summary>
/// <param name="hotProessTrust"></param>
public static void UpdateHotProessTrust(Model.HotProess_Trust hotProessTrust)
{
Model.HJGLDB db = Funs.DB;
Model.HotProess_Trust newHotProessTrust = db.HotProess_Trust.FirstOrDefault(e => e.HotProessTrustId == hotProessTrust.HotProessTrustId);
if (newHotProessTrust != null)
{
newHotProessTrust.HotProessTrustNo = hotProessTrust.HotProessTrustNo;
newHotProessTrust.ProessDate = hotProessTrust.ProessDate;
newHotProessTrust.InstallationId = hotProessTrust.InstallationId;
newHotProessTrust.ProjectId = hotProessTrust.ProjectId;
newHotProessTrust.UnitId = hotProessTrust.UnitId;
newHotProessTrust.Tabler = hotProessTrust.Tabler;
newHotProessTrust.Remark = hotProessTrust.Remark;
newHotProessTrust.ProessMethod = hotProessTrust.ProessMethod;
newHotProessTrust.ProessEquipment = hotProessTrust.ProessEquipment;
db.SubmitChanges();
}
}
/// <summary>
/// 根据主键删除热处理
/// </summary>
/// <param name="hotProessTrustId"></param>
public static void DeleteHotProessTrustById(string hotProessTrustId)
{
Model.HJGLDB db = Funs.DB;
Model.HotProess_Trust hotProessTrust = db.HotProess_Trust.FirstOrDefault(e => e.HotProessTrustId == hotProessTrustId);
if (hotProessTrust != null)
{
db.HotProess_Trust.DeleteOnSubmit(hotProessTrust);
db.SubmitChanges();
}
}
/// <summary>
/// 热处理委托单编号是否存在
/// </summary>
/// <param name="pointNo"></param>
/// <param name="pointId"></param>
/// <returns></returns>
public static bool IsExistTrustCode(string hotProessTrustNo, string hotProessTrustId, string projectId)
{
var q = Funs.DB.HotProess_Trust.FirstOrDefault(x => x.HotProessTrustNo == hotProessTrustNo && x.ProjectId == projectId && x.HotProessTrustId != hotProessTrustId);
if (q != null)
{
return true;
}
else
{
return false;
}
}
/// <summary>
/// 查找后返回集合增加到列表集团中
/// </summary>
/// <param name="hdItemsString"></param>
/// <returns></returns>
public static List<Model.View_HotProess_TrustItem> GetHotProessTrustAddItem(string hdItemsString)
{
var jointInfos = from x in Funs.DB.View_Pipeline_WeldJoint select x;
List<Model.View_HotProess_TrustItem> returnViewMatch = new List<Model.View_HotProess_TrustItem>();
if (!string.IsNullOrEmpty(hdItemsString))
{
List<string> jotIds = Funs.GetStrListByStr(hdItemsString, '|');
foreach (var jotItem in jotIds)
{
string[] strs = jotItem.Split(',');
var jotInfo = jointInfos.FirstOrDefault(x => x.WeldJointId == strs[0]);
Model.View_HotProess_TrustItem newItem = new Model.View_HotProess_TrustItem();
newItem.HotProessTrustItemId = SQLHelper.GetNewID(typeof(Model.View_HotProess_TrustItem));
newItem.WeldJointId = jotInfo.WeldJointId;
newItem.WeldJointCode = jotInfo.WeldJointCode;
newItem.PipelineCode = jotInfo.PipelineCode;
newItem.Specification = jotInfo.Specification;
newItem.MaterialCode = jotInfo.Material1Code;
returnViewMatch.Add(newItem);
}
}
return returnViewMatch;
}
/// <summary>
/// 根据项目状态获取热处理委托明细信息
/// </summary>
/// <param name="ManagerTotalId"></param>
/// <returns></returns>
public static List<Model.View_HotProess_TrustItem> GetHotProessTrustItem(string projectId, string hotProessTrustId)
{
List<Model.View_HotProess_TrustItem> returnViewMatch = (from x in Funs.DB.View_HotProess_TrustItem
where x.ProjectId == projectId && x.HotProessTrustId == hotProessTrustId
select x).ToList();
return returnViewMatch;
}
/// <summary>
/// 查找需要热处理的焊口信息
/// </summary>
/// <param name="projectId"></param>
/// <param name="hotProessTrustId"></param>
/// <param name="iso_id"></param>
/// <returns></returns>
public static List<Model.View_HotProessTrustItemSearch> GetHotProessTrustFind(string projectId, string hotProessTrustId, string pipelineId)
{
Model.HJGLDB db = Funs.DB;
var weldJoints = (from x in db.View_Pipeline_WeldJoint select x).ToList();
List<Model.View_HotProessTrustItemSearch> returnViewMatch = new List<Model.View_HotProessTrustItemSearch>();
var hotProessTrustItems = from x in Funs.DB.HotProess_TrustItem
join z in Funs.DB.Pipeline_WeldJoint
on x.WeldJointId equals z.WeldJointId
where z.ProjectId == projectId && z.PipelineId == pipelineId
select x;
if (weldJoints.Count() > 0)
{
foreach (var item in weldJoints)
{
var jothotProessTrustItems = from x in hotProessTrustItems where x.WeldJointId == item.WeldJointId select x;
bool isShow = false;
if (item.IsHotProess == true)//需要热处理
{
if (jothotProessTrustItems.Count() == 0) //未进行过热处理
{
isShow = true;
}
if (isShow)
{
Model.View_HotProessTrustItemSearch newItem = new Model.View_HotProessTrustItemSearch();
newItem.WeldJointId = item.WeldJointId;
newItem.PipelineId = item.PipelineId;
newItem.PipelineCode = item.PipelineCode;
newItem.WeldJointCode = item.WeldJointCode;
newItem.Specification = item.Specification;
newItem.MaterialCode = item.Material1Code;
newItem.WeldingDailyId = item.WeldingDailyId;
var weldingDaily = BLL.Pipeline_WeldingDailyService.GetPipeline_WeldingDailyByWeldingDailyId(item.WeldingDailyId);
if (weldingDaily != null)
{
newItem.WeldingDate = weldingDaily.WeldingDate;
}
returnViewMatch.Add(newItem);
}
}
}
}
return returnViewMatch;
}
}
}