This commit is contained in:
2024-05-08 17:17:11 +08:00
parent 0696f555b2
commit 2f1fca4df2
4528 changed files with 635638 additions and 0 deletions
@@ -0,0 +1,116 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections;
using System.Web.UI.WebControls;
namespace BLL
{
public class HJGL_CH_HotProessResultService
{
/// <summary>
/// 根据热处理Id获取用于热处理结果反馈
/// </summary>
/// <param name="jot_id"></param>
/// <returns></returns>
public static Model.HJGL_CH_HotProessResult GetHotProessResultByID(string HotProessResultId)
{
Model.SGGLDB db = Funs.DB;
var view = db.HJGL_CH_HotProessResult.FirstOrDefault(e => e.HotProessResultId == HotProessResultId);
return view;
}
/// <summary>
/// 根据热处理委托Id和焊口id获取用于热处理结果反馈
/// </summary>
/// <param name="jot_id"></param>
/// <returns></returns>
public static Model.HJGL_CH_HotProessResult GetHotProessResultByHotTrustIDAndJotID(string hotProessTrustId, string jot_id)
{
Model.SGGLDB db = Funs.DB;
var view = db.HJGL_CH_HotProessResult.FirstOrDefault(e => e.HotProessTrustId == hotProessTrustId && e.JOT_ID == jot_id);
return view;
}
/// <summary>
/// 增加热处理结果反馈
/// </summary>
/// <param name="hotProess">热处理实体</param>
public static void AddHotProessResult(Model.HJGL_CH_HotProessResult hotProess)
{
Model.SGGLDB db = Funs.DB;
Model.HJGL_CH_HotProessResult newTestPackage = new Model.HJGL_CH_HotProessResult();
newTestPackage.HotProessResultId = SQLHelper.GetNewID(typeof(Model.HJGL_CH_HotProessResult));
newTestPackage.HotProessTrustId = hotProess.HotProessTrustId;
newTestPackage.ProessTypes = hotProess.ProessTypes;
newTestPackage.JOT_ID = hotProess.JOT_ID;
newTestPackage.HotProessCurveNo = hotProess.HotProessCurveNo;
newTestPackage.IsOK = hotProess.IsOK;
newTestPackage.IsNeedHardTest = hotProess.IsNeedHardTest;
Model.HJGL_CH_HotProessTrustItem hotProessTrustItem = BLL.HJGL_CH_HotProessTrustService.GetCH_HotProessTrustItemByHotProessTrustIdAndJotId(hotProess.HotProessTrustId, hotProess.JOT_ID);
if (hotProessTrustItem != null) //如果热处理委托明细存在,则插入数据
{
db.HJGL_CH_HotProessResult.InsertOnSubmit(newTestPackage);
db.SubmitChanges();
}
}
/// <summary>
/// 修改热处理结果反馈
/// </summary>
/// <param name="weldReport">热处理实体</param>
public static void UpdateHotProessResult(Model.HJGL_CH_HotProessResult hotProess)
{
Model.SGGLDB db = Funs.DB;
Model.HJGL_CH_HotProessResult newTestPackage = db.HJGL_CH_HotProessResult.FirstOrDefault(e => e.HotProessResultId == hotProess.HotProessResultId);
if (newTestPackage != null)
{
newTestPackage.HotProessResultId = hotProess.HotProessResultId;
newTestPackage.HotProessTrustId = hotProess.HotProessTrustId;
newTestPackage.JOT_ID = hotProess.JOT_ID;
newTestPackage.HotProessCurveNo = hotProess.HotProessCurveNo;
newTestPackage.IsOK = hotProess.IsOK;
newTestPackage.ResultDate = hotProess.ResultDate;
newTestPackage.IsNeedHardTest = hotProess.IsNeedHardTest;
newTestPackage.Remark = hotProess.Remark;
db.SubmitChanges();
}
}
/// <summary>
/// 根据主键删除热处理结果反馈
/// </summary>
/// <param name="hotProessID">热处理主键</param>
public static void DeleteHotProessResultByHotProessResultID(string hotProessResultId)
{
Model.SGGLDB db = Funs.DB;
Model.HJGL_CH_HotProessResult hotProess = db.HJGL_CH_HotProessResult.FirstOrDefault(e => e.HotProessResultId == hotProessResultId);
if (hotProess != null)
{
db.HJGL_CH_HotProessResult.DeleteOnSubmit(hotProess);
db.SubmitChanges();
}
}
/// <summary>
/// 根据主键删除热处理结果反馈明细
/// </summary>
/// <param name="hotProessID">热处理主键</param>
public static void DeleteHotProessResultsyHotProessTrustId(string HotProessTrustId)
{
Model.SGGLDB db = Funs.DB;
var items = from x in db.HJGL_CH_HotProessResult where x.HotProessTrustId == HotProessTrustId select x;
if (items != null)
{
foreach (var item in items)
{
//回写热处理合格及反馈时间
BLL.HJGL_PW_JointInfoService.WriteBackHotProessResultOKAndDate(item.JOT_ID, null);
}
db.HJGL_CH_HotProessResult.DeleteAllOnSubmit(items);
db.SubmitChanges();
}
}
}
}
@@ -0,0 +1,637 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections;
using System.Web.UI.WebControls;
namespace BLL
{
public class HJGL_CH_HotProessTrustService
{
/// <summary>
/// 根据项目状态获取热处理委托明细信息
/// </summary>
/// <param name="ManagerTotalId"></param>
/// <returns></returns>
public static List<Model.HJGL_View_CH_HotProessTrustItem> GetHotProessTrustItem(string projectId, string trustId)
{
List<Model.HJGL_View_CH_HotProessTrustItem> returnViewMatch = (from x in Funs.DB.HJGL_View_CH_HotProessTrustItem
where x.ProjectId == projectId && x.HotProessTrustId == trustId
select x).ToList();
return returnViewMatch;
}
/// <summary>
/// 查找后返回集合增加到列表集团中
/// </summary>
/// <param name="hdItemsString"></param>
/// <returns></returns>
public static List<Model.HJGL_View_CH_HotProessTrustItem> GetHotProessTrustAddItem(string hdItemsString)
{
var jointInfos = from x in Funs.DB.HJGL_View_JointInfo select x;
var jointInfoAndIsoInfos = from x in Funs.DB.HJGL_View_JointInfoAndIsoInfo select x;
List<Model.HJGL_View_CH_HotProessTrustItem> returnViewMatch = new List<Model.HJGL_View_CH_HotProessTrustItem>(); //getHotProessTrustItem;
if (!string.IsNullOrEmpty(hdItemsString))
{
List<string> jotIds = Funs.GetStrListByStr(hdItemsString, '|');
foreach (var jotItem in jotIds)
{
string[] strs = jotItem.Split(',');
//if (returnViewMatch.FirstOrDefault(x => x.JOT_ID == jotItem) == null)
//{
var jotInfo = jointInfos.FirstOrDefault(x => x.JOT_ID == strs[0]);
var jotAndIsoInfo = jointInfoAndIsoInfos.FirstOrDefault(x => x.JOT_ID == strs[0]);
if (jotAndIsoInfo != null)
{
Model.HJGL_View_CH_HotProessTrustItem newItem = new Model.HJGL_View_CH_HotProessTrustItem();
newItem.HotProessTrustItemId = SQLHelper.GetNewID(typeof(Model.HJGL_View_CH_HotProessTrustItem));
newItem.JOT_ID = jotAndIsoInfo.JOT_ID;
newItem.ISO_IsoNo = jotAndIsoInfo.ISO_IsoNo;
newItem.JOT_JointNo = jotAndIsoInfo.JOT_JointNo;
newItem.JOT_JointDesc = jotInfo.JOT_JointDesc;
newItem.STE_Code = jotInfo.STE_Name1;
newItem.TrustDate = DateTime.Now;
if (strs.Length > 1)
{
newItem.HardTestResultId = strs[1];
}
if (strs.Length > 2)
{
newItem.HardRepairMark = strs[2];
}
if (!string.IsNullOrEmpty(newItem.HardRepairMark))
{
newItem.JOT_JointNo = jotAndIsoInfo.JOT_JointNo + newItem.HardRepairMark;
}
returnViewMatch.Add(newItem);
}
//}
}
}
return returnViewMatch;
}
/// <summary>
/// 获取未完全热处理焊口信息
/// </summary>
/// <param name="ManagerTotalId"></param>
/// <returns></returns>
public static List<Model.HJGL_View_CH_HotProessTrustItem> GetHotProessTrustFind(string projectId, string trustId, string iso_id)
{
var jointInfos = from x in Funs.DB.HJGL_View_JointInfo select x;
var jointInfoAndIsoInfos = from x in Funs.DB.HJGL_View_JointInfoAndIsoInfo select x;
List<Model.HJGL_View_CH_HotProessTrustItem> returnViewMatch = new List<Model.HJGL_View_CH_HotProessTrustItem>();
var jotLists = from x in Funs.DB.HJGL_PW_JointInfo
where x.ProjectId == projectId && x.ISO_ID == iso_id
select x;
var hotProessTrustItems = from x in Funs.DB.HJGL_CH_HotProessTrustItem
join z in Funs.DB.HJGL_PW_JointInfo
on x.JOT_ID equals z.JOT_ID
where z.ProjectId == projectId && z.ISO_ID == iso_id
select x;
var totalHotProessResult = from x in Funs.DB.HJGL_CH_HotProessResult
join y in Funs.DB.HJGL_PW_JointInfo
on x.JOT_ID equals y.JOT_ID
where y.ISO_ID == iso_id
select x;
if (jotLists.Count() > 0)
{
foreach (var item in jotLists)
{
var jothotProessTrustItems = from x in hotProessTrustItems where x.JOT_ID == item.JOT_ID select x;
bool isShow = false;
if (item.IS_Proess == "1") //需要热处理
{
if (jothotProessTrustItems.Count() == 0) //未进行过热处理
{
isShow = true;
}
else //已进行过热处理
{
string oldProessTypes = item.ProessTypes.Replace("|", "");
string proessTypes = string.Empty;
foreach (var jothotProessTrustItem in jothotProessTrustItems)
{
proessTypes += jothotProessTrustItem.ProessTypes;
}
proessTypes = proessTypes.Replace("|", "");
if (oldProessTypes.Length > proessTypes.Length) //未将所有热处理类型委托完
{
isShow = true;
}
else //已处理完但最终结果反馈未合格的也要显示
{
//该口已存在的结果反馈记录集合
var hotProseeResults = from x in totalHotProessResult where x.JOT_ID == item.JOT_ID select x;
foreach (var hotProseeResult in hotProseeResults)
{
if (hotProseeResult.IsOK == false) //存在结果反馈不合格的记录
{
var oldTrustId = hotProseeResult.HotProessTrustId; //不合格记录的热处理委托Id
var oldItem = hotProessTrustItems.FirstOrDefault(x => x.JOT_ID == item.JOT_ID && x.HotProessTrustId == oldTrustId);
var otherItems = from x in hotProessTrustItems where x.JOT_ID == item.JOT_ID && x.HotProessTrustId != oldTrustId && x.ProessTypes.Contains(oldItem.ProessTypes) select x;
if (otherItems.Count() == 0) //不合格后尚未再次进行热处理委托
{
isShow = true;
}
else
{
List<string> trustIds = (from x in otherItems select x.HotProessTrustId).ToList();
var otherHotProseeResults = from x in totalHotProessResult where trustIds.Contains(x.HotProessTrustId) && x.JOT_ID == item.JOT_ID select x;
if (otherHotProseeResults.Count() > 0 && otherHotProseeResults.Count(x => x.IsOK == false) == otherHotProseeResults.Count()) //所有后续的结果反馈都不合格,则继续显示
{
isShow = true;
}
}
}
}
}
}
if (isShow)
{
var jotInfo = jointInfos.FirstOrDefault(x => x.JOT_ID == item.JOT_ID);
var jotAndIsoInfo = jointInfoAndIsoInfos.FirstOrDefault(x => x.JOT_ID == item.JOT_ID);
if (jotAndIsoInfo != null)
{
var date = BLL.HJGL_WeldReportService.GetWeldReportByDReportID(jotAndIsoInfo.DReportID);
Model.HJGL_View_CH_HotProessTrustItem newItem = new Model.HJGL_View_CH_HotProessTrustItem();
newItem.JOT_ID = jotAndIsoInfo.JOT_ID;
newItem.ISO_ID = jotAndIsoInfo.ISO_ID;
newItem.ISO_IsoNo = jotAndIsoInfo.ISO_IsoNo;
newItem.JOT_JointNo = jotAndIsoInfo.JOT_JointNo;
if (date != null && date.JOT_WeldDate != null)
{
newItem.JOT_WeldDate = date.JOT_WeldDate;
}
newItem.NewJotId = jotAndIsoInfo.JOT_ID;
newItem.JOT_JointDesc = jotInfo.JOT_JointDesc;
newItem.STE_Code = jotInfo.STE_Name1;
newItem.DReportID = jotAndIsoInfo.DReportID;
returnViewMatch.Add(newItem);
}
}
}
}
}
//硬度不合格口记录
var noPassHardLists = (from x in Funs.DB.HJGL_PW_JointInfo
join z in Funs.DB.HJGL_CH_HardTestResult on x.JOT_ID equals z.JOT_ID
join a in Funs.DB.HJGL_CH_HotProessTrustItem on z.JOT_ID equals a.JOT_ID
where x.ProjectId == projectId && x.ISO_ID == iso_id && a.HardTestResultId == null && z.IsOK == false
select new { x.JOT_ID, z.HardTestReportId }).Distinct().ToList();
foreach (var item in noPassHardLists)
{
Model.HJGL_CH_HotProessTrustItem newhotProessTrustItem = (from x in hotProessTrustItems
where x.JOT_ID == item.JOT_ID && x.HardTestResultId == item.HardTestReportId
select x).FirstOrDefault(); //上次硬度不合格口是否生成热处理委托记录
if (newhotProessTrustItem == null)
{
var jotInfo = jointInfos.FirstOrDefault(x => x.JOT_ID == item.JOT_ID);
var jotAndIsoInfo = jointInfoAndIsoInfos.FirstOrDefault(x => x.JOT_ID == item.JOT_ID);
if (jotAndIsoInfo != null)
{
Model.HJGL_View_CH_HotProessTrustItem newItem = new Model.HJGL_View_CH_HotProessTrustItem();
newItem.JOT_ID = jotAndIsoInfo.JOT_ID;
newItem.ISO_ID = jotAndIsoInfo.ISO_ID;
newItem.ISO_IsoNo = jotAndIsoInfo.ISO_IsoNo;
newItem.JOT_JointNo = jotAndIsoInfo.JOT_JointNo;
newItem.JOT_JointDesc = jotInfo.JOT_JointDesc;
newItem.STE_Code = jotInfo.STE_Name1;
newItem.HardTestResultId = item.HardTestReportId;
newItem.DReportID = jotAndIsoInfo.DReportID;
//之前热处理委托主表主键
var oldHotProessTrustId = (from x in Funs.DB.HJGL_CH_HardTestReportItem
join y in Funs.DB.HJGL_CH_HardTestResult
on x.HardTestReportId equals y.HardTestReportId
where x.JOT_ID == item.JOT_ID && y.HardTestReportId == item.HardTestReportId
select x.HotProessTrustId).FirstOrDefault();
//之前热处理委托明细记录
Model.HJGL_CH_HotProessTrustItem oldHotProessTrustItem = (from x in hotProessTrustItems
where x.JOT_ID == item.JOT_ID && x.HotProessTrustId == oldHotProessTrustId && x.ProessTypes.Contains("4")
select x).FirstOrDefault();
if (oldHotProessTrustItem != null)
{
if (string.IsNullOrEmpty(oldHotProessTrustItem.HardRepairMark))
{
newItem.HardRepairMark = "F1";
}
else
{
newItem.HardRepairMark = "F2";
}
}
newItem.NewJotId = jotAndIsoInfo.JOT_ID + ',' + newItem.HardRepairMark;
newItem.JOT_JointNo = jotAndIsoInfo.JOT_JointNo + newItem.HardRepairMark;
returnViewMatch.Add(newItem);
}
}
}
return returnViewMatch;
}
/// <summary>
/// 根据热处理委托Id获取用于热处理委托的热处理委托信息
/// </summary>
/// <param name="jot_id"></param>
/// <returns></returns>
public static Model.HJGL_CH_HotProessTrust GetCH_HotProessTrustByID(string hotProessTrustID)
{
Model.SGGLDB db = Funs.DB;
var view = db.HJGL_CH_HotProessTrust.FirstOrDefault(e => e.HotProessTrustId == hotProessTrustID);
return view;
}
/// <summary>
/// 根据热处理委托Id获取用于热处理委托的焊口视图信息
/// </summary>
/// <param name="jot_id"></param>
/// <returns></returns>
public static List<Model.HJGL_View_CH_HotProessTrustItem> GetView_CH_HotProessTrustItemByCH_HotProessTrustID(string hotProessTrustID)
{
Model.SGGLDB db = Funs.DB;
var view = (from x in db.HJGL_View_CH_HotProessTrustItem where x.HotProessTrustId == hotProessTrustID select x).ToList();
return view;
}
/// <summary>
/// 根据焊口Id获取用于热处理委托的焊口视图信息
/// </summary>
/// <param name="jot_id"></param>
/// <returns></returns>
public static List<Model.HJGL_CH_HotProessTrustItem> GetCH_HotProessTrustItemByJOT_ID(string jot_id)
{
Model.SGGLDB db = Funs.DB;
var view = (from x in db.HJGL_CH_HotProessTrustItem where x.JOT_ID == jot_id select x).ToList();
return view;
}
/// <summary>
/// 根据焊口Id和热处理委托id获取用于热处理委托明细是否存在
/// </summary>
/// <param name="jot_id"></param>
/// <returns></returns>
public static Model.HJGL_CH_HotProessTrustItem GetCH_HotProessTrustItemByHotProessTrustIdAndJotId(string hotProessTrustID, string jot_id)
{
Model.SGGLDB db = Funs.DB;
var view = db.HJGL_CH_HotProessTrustItem.FirstOrDefault(x => x.HotProessTrustId == hotProessTrustID && x.JOT_ID == jot_id);
return view;
}
/// <summary>
/// 根据热处理委托Id获取用于热处理委托的焊口视图信息
/// </summary>
/// <param name="jot_id"></param>
/// <returns></returns>
public static List<Model.HJGL_CH_HotProessTrustItem> GetCH_HotProessTrustItemByHotProessTrustID(string hotProessTrustID)
{
Model.SGGLDB db = Funs.DB;
var view = (from x in db.HJGL_CH_HotProessTrustItem where x.HotProessTrustId == hotProessTrustID select x).ToList();
return view;
}
/// <summary>
/// 根据焊口Id获取用于热处理委托的焊口信息
/// </summary>
/// <param name="jot_id"></param>
/// <returns></returns>
public static Model.HJGL_View_CH_HotProessTrustItem GetView_CH_HotProessTrustItemByJotID(string jot_id, string projectId)
{
var view = Funs.DB.HJGL_View_CH_HotProessTrustItem.FirstOrDefault(e => e.JOT_ID == jot_id && e.ProjectId == projectId);
return view;
}
/// <summary>
/// 增加热处理委托信息
/// </summary>
/// <param name="cH_Trust">热处理委托实体</param>
public static void AddCH_HotProessTrust(Model.HJGL_CH_HotProessTrust cH_Trust)
{
Model.SGGLDB db = Funs.DB;
Model.HJGL_CH_HotProessTrust newCH_HotProessTrust = new Model.HJGL_CH_HotProessTrust();
newCH_HotProessTrust.HotProessTrustId = cH_Trust.HotProessTrustId;
newCH_HotProessTrust.ProjectId = cH_Trust.ProjectId;
newCH_HotProessTrust.HotProessTrustCode = cH_Trust.HotProessTrustCode;
newCH_HotProessTrust.ProjectName = cH_Trust.ProjectName;
newCH_HotProessTrust.ConstructionNo = cH_Trust.ConstructionNo;
newCH_HotProessTrust.TrustUnitId = cH_Trust.TrustUnitId;
newCH_HotProessTrust.TrstManId = cH_Trust.TrstManId;
newCH_HotProessTrust.CreateDate = DateTime.Now;
newCH_HotProessTrust.TrustType = cH_Trust.TrustType;
db.HJGL_CH_HotProessTrust.InsertOnSubmit(newCH_HotProessTrust);
db.SubmitChanges();
}
/// <summary>
/// 修改焊接信息
/// </summary>
/// <param name="weldReport">焊接实体</param>
public static void UpdateCH_HotProessTrust(Model.HJGL_CH_HotProessTrust cH_Trust)
{
Model.SGGLDB db = Funs.DB;
Model.HJGL_CH_HotProessTrust newCH_HotProessTrust = db.HJGL_CH_HotProessTrust.FirstOrDefault(e => e.HotProessTrustId == cH_Trust.HotProessTrustId);
if (newCH_HotProessTrust != null)
{
newCH_HotProessTrust.HotProessTrustCode = cH_Trust.HotProessTrustCode;
newCH_HotProessTrust.ProjectName = cH_Trust.ProjectName;
newCH_HotProessTrust.ConstructionNo = cH_Trust.ConstructionNo;
newCH_HotProessTrust.TrustUnitId = cH_Trust.TrustUnitId;
newCH_HotProessTrust.TrstManId = cH_Trust.TrstManId;
newCH_HotProessTrust.IsPrint = cH_Trust.IsPrint;
db.SubmitChanges();
}
}
/// <summary>
/// 根据主键删除热处理委托信息
/// </summary>
/// <param name="cH_TrustID">热处理委托主键</param>
public static void DeleteCH_HotProessTrustByCH_HotProessTrustID(string hotProessTrustId)
{
Model.SGGLDB db = Funs.DB;
Model.HJGL_CH_HotProessTrust cH_Trust = db.HJGL_CH_HotProessTrust.FirstOrDefault(e => e.HotProessTrustId == hotProessTrustId);
if (cH_Trust != null)
{
db.HJGL_CH_HotProessTrust.DeleteOnSubmit(cH_Trust);
db.SubmitChanges();
}
}
/// <summary>
/// 根据主键删除热处理委托信息明细
/// </summary>
/// <param name="cH_TrustID">热处理委托主键</param>
public static void DeleteCH_HotProessTrustItemByCH_HotProessTrustID(string hotProessTrustId)
{
Model.SGGLDB db = Funs.DB;
var cH_Trust = from x in db.HJGL_CH_HotProessTrustItem where x.HotProessTrustId == hotProessTrustId select x;
if (cH_Trust != null)
{
foreach (var c in cH_Trust)
{
//回写焊口热处理委托时间
BLL.HJGL_PW_JointInfoService.WriteBackHotProessTrustDate(c.JOT_ID, null);
}
db.HJGL_CH_HotProessTrustItem.DeleteAllOnSubmit(cH_Trust);
db.SubmitChanges();
}
}
/// <summary>
/// 增加热处理委托信息明细
/// </summary>
/// <param name="trustItem">热处理委托明细实体</param>
public static void AddCH_HotProessTrustItem(Model.HJGL_CH_HotProessTrustItem trustItem)
{
Model.SGGLDB db = Funs.DB;
Model.HJGL_CH_HotProessTrustItem newTrustItem = new Model.HJGL_CH_HotProessTrustItem();
newTrustItem.HotProessTrustItemId = SQLHelper.GetNewID(typeof(Model.HJGL_CH_HotProessTrustItem));
newTrustItem.HotProessTrustId = trustItem.HotProessTrustId;
newTrustItem.JOT_ID = trustItem.JOT_ID;
newTrustItem.ProessTypes = trustItem.ProessTypes;
newTrustItem.TrustDate = trustItem.TrustDate;
newTrustItem.IsComplete = trustItem.IsComplete;
newTrustItem.Remark = trustItem.Remark;
newTrustItem.TrustItemID = trustItem.TrustItemID;
newTrustItem.HardTestResultId = trustItem.HardTestResultId;
newTrustItem.HardRepairMark = trustItem.HardRepairMark;
var oldTrustItem = Funs.DB.HJGL_CH_HotProessTrustItem.FirstOrDefault(x => x.JOT_ID == newTrustItem.JOT_ID && x.ProessTypes == newTrustItem.ProessTypes && x.HotProessTrustId == newTrustItem.HotProessTrustId);
if (oldTrustItem == null)
{
db.HJGL_CH_HotProessTrustItem.InsertOnSubmit(newTrustItem);
db.SubmitChanges();
}
}
/// <summary>
/// 更新焊口热处理委托情况
/// </summary>
/// <param name="type">type1-录入审核2取消删除</param>
public static void UpdateJOT_TrustFlag(string JOT_ID, string type)
{
var jointInfo = Funs.DB.HJGL_PW_JointInfo.FirstOrDefault(x => x.JOT_ID == JOT_ID);
if (jointInfo != null)
{
if (type == "1")
{
if (String.IsNullOrEmpty(jointInfo.JOT_TrustFlag) || jointInfo.JOT_TrustFlag == "00")
{
jointInfo.JOT_TrustFlag = "01";
}
else if (jointInfo.JOT_TrustFlag == "01")
{
jointInfo.JOT_TrustFlag = "02";
}
else if (jointInfo.JOT_TrustFlag == "02")
{
jointInfo.JOT_TrustFlag = "11";
}
else if (jointInfo.JOT_TrustFlag == "11")
{
jointInfo.JOT_TrustFlag = "12";
}
else if (jointInfo.JOT_TrustFlag == "12")
{
jointInfo.JOT_TrustFlag = "21";
}
else if (jointInfo.JOT_TrustFlag == "21")
{
jointInfo.JOT_TrustFlag = "22";
}
}
else
{
if (jointInfo.JOT_TrustFlag == "22")
{
jointInfo.JOT_TrustFlag = "21";
}
else if (jointInfo.JOT_TrustFlag == "21")
{
jointInfo.JOT_TrustFlag = "12";
}
else if (jointInfo.JOT_TrustFlag == "12")
{
jointInfo.JOT_TrustFlag = "11";
}
else if (jointInfo.JOT_TrustFlag == "11")
{
jointInfo.JOT_TrustFlag = "02";
}
else if (jointInfo.JOT_TrustFlag == "02")
{
jointInfo.JOT_TrustFlag = "01";
}
else
{
jointInfo.JOT_TrustFlag = "00";
}
}
}
Funs.DB.SubmitChanges();
}
/// <summary>
/// 热处理委托单编号是否存在
/// </summary>
/// <param name="pointNo"></param>
/// <param name="pointId"></param>
/// <returns></returns>
public static bool IsExistTrustCode(string trustCode, string trustID, string projectId)
{
var q = Funs.DB.HJGL_CH_HotProessTrust.FirstOrDefault(x => x.HotProessTrustCode == trustCode && x.ProjectId == projectId && x.HotProessTrustId != trustID);
if (q != null)
{
return true;
}
else
{
return false;
}
}
/// <summary>
/// 根据已经处理的项获取剩余需要加载的热处理项
/// </summary>
/// <returns></returns>
public static ListItem[] GetNeedProessTypes(string jointProessTypes, List<string> doProessTypes, string hotProessTrustId, string jotId, string hotProessTrustItemId)
{
if (string.IsNullOrEmpty(hotProessTrustId))
{
if (!string.IsNullOrEmpty(jointProessTypes))
{
List<string> jointProessTypestrs = jointProessTypes.Split('|').ToList();
foreach (var doProessType in doProessTypes)
{
jointProessTypestrs.Remove(doProessType);
}
ListItem[] item = new ListItem[jointProessTypestrs.Count()];
for (int i = 0; i < jointProessTypestrs.Count(); i++)
{
item[i] = new ListItem(GetProessTypesName(jointProessTypestrs[i]), jointProessTypestrs[i].ToString());
}
return item;
}
return null;
}
else
{
Model.HJGL_CH_HotProessTrustItem trustItem = (from x in Funs.DB.HJGL_CH_HotProessTrustItem where x.HotProessTrustItemId == hotProessTrustItemId select x).FirstOrDefault();
if (trustItem != null)
{
List<string> jointProessTypestrs = trustItem.ProessTypes.Split('|').ToList();
ListItem[] item = new ListItem[jointProessTypestrs.Count()];
for (int i = 0; i < jointProessTypestrs.Count(); i++)
{
item[i] = new ListItem(GetProessTypesName(jointProessTypestrs[i]), jointProessTypestrs[i].ToString());
}
return item;
}
else
{
return null;
}
}
}
/// <summary>
/// 根据已经处理的项获取剩余需要加载的热处理项(压力容器)
/// </summary>
/// <returns></returns>
public static ListItem[] GetWeldNeedProessTypes(string jointProessTypes, List<string> doProessTypes, string hotProessTrustId, string jotId, string hotProessTrustItemId)
{
if (string.IsNullOrEmpty(hotProessTrustId))
{
if (!string.IsNullOrEmpty(jointProessTypes))
{
List<string> jointProessTypestrs = jointProessTypes.Split('|').ToList();
foreach (var doProessType in doProessTypes)
{
jointProessTypestrs.Remove(doProessType);
}
ListItem[] item = new ListItem[jointProessTypestrs.Count()];
for (int i = 0; i < jointProessTypestrs.Count(); i++)
{
item[i] = new ListItem(GetProessTypesName(jointProessTypestrs[i]), jointProessTypestrs[i].ToString());
}
return item;
}
return null;
}
else
{
Model.PV_CH_HotProessTrustItem trustItem = (from x in Funs.DB.PV_CH_HotProessTrustItem where x.HotProessTrustItemId == hotProessTrustItemId select x).FirstOrDefault();
if (trustItem != null)
{
List<string> jointProessTypestrs = trustItem.ProessTypes.Split('|').ToList();
ListItem[] item = new ListItem[jointProessTypestrs.Count()];
for (int i = 0; i < jointProessTypestrs.Count(); i++)
{
item[i] = new ListItem(GetProessTypesName(jointProessTypestrs[i]), jointProessTypestrs[i].ToString());
}
return item;
}
else
{
return null;
}
}
}
public static string GetProessTypesName(string proessType)
{
string name = string.Empty;
if (proessType == "1")
{
name = "预热";
}
else if (proessType == "2")
{
name = "消氢";
}
else if (proessType == "3")
{
name = "后热";
}
else if (proessType == "4")
{
name = "消应力热处理";
}
else if (proessType == "5")
{
name = "稳定化处理";
}
return name;
}
public static string GetProessTypesId(string proessTypesName)
{
string id = string.Empty;
if (proessTypesName == "预热")
{
id = "1";
}
else if (proessTypesName == "消氢")
{
id = "2";
}
else if (proessTypesName == "后热")
{
id = "3";
}
else if (proessTypesName == "消应力热处理")
{
id = "4";
}
else if (proessTypesName == "稳定化处理")
{
id = "5";
}
return id;
}
}
}
@@ -0,0 +1,345 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections;
using System.Web.UI.WebControls;
namespace BLL
{
public class HJGL_HotProessManageEditService
{
/// <summary>
/// 根据热处理Id获取用于热处理信息
/// </summary>
/// <param name="jot_id"></param>
/// <returns></returns>
public static Model.HJGL_HotProess GetHotProessByID(string HotProessId)
{
Model.SGGLDB db = Funs.DB;
var view = db.HJGL_HotProess.FirstOrDefault(e => e.HotProessId == HotProessId);
return view;
}
/// <summary>
/// 根据热处理委托Id获取用于热处理信息
/// </summary>
/// <param name="jot_id"></param>
/// <returns></returns>
public static Model.HJGL_HotProess GetHotProessByHotProessTrustId(string HotProessTrustId)
{
Model.SGGLDB db = Funs.DB;
var view = db.HJGL_HotProess.FirstOrDefault(e => e.HotProessTrustId == HotProessTrustId);
return view;
}
/// <summary>
/// 根据热处理委托Id及焊口和热处理类型获取增加记录对应的索引值
/// </summary>
/// <param name="jot_id"></param>
/// <returns></returns>
public static int GetSortIndex(string HotProessTrustId, string jot_id, string proessTypes)
{
int i = 1;
Model.SGGLDB db = Funs.DB;
var view = from x in db.HJGL_HotProessItem where x.HotProessTrustId == HotProessTrustId && x.JOT_ID == jot_id && x.ProessTypes == proessTypes orderby x.SortIndex descending select x;
if (view.Count() > 0)
{
i = Funs.GetNewIntOrZero(view.First().SortIndex.ToString()) + 1;
}
return i;
}
/// <summary>
/// 根据热处理Id获取用于热处理信息明细
/// </summary>
/// <param name="jot_id"></param>
/// <returns></returns>
public static List<Model.View_HotProessItem> GetViewHotProessItemListByID(string hotProessId)
{
var view = (from x in Funs.DB.View_HotProessItem where x.HotProessId == hotProessId select x).ToList();
return view;
}
/// <summary>
/// 根据焊口Id获取用于热处理信息明细
/// </summary>
/// <param name="jot_id"></param>
/// <returns></returns>
public static Model.View_HotProessItem GetViewHotProessItemByJOT_ID(string jot_ID)
{
return Funs.DB.View_HotProessItem.FirstOrDefault(x => x.JOT_ID == jot_ID);
}
/// <summary>
/// 根据主键获取用于热处理信息明细
/// </summary>
/// <param name="jot_id"></param>
/// <returns></returns>
public static Model.HJGL_HotProessItem GetHotProessItemByHotProessItemId(string hotProessItemId)
{
return Funs.DB.HJGL_HotProessItem.FirstOrDefault(x => x.HotProessItemId == hotProessItemId);
}
/// <summary>
/// 增加热处理信息
/// </summary>
/// <param name="hotProess">热处理实体</param>
public static void AddHotProess(Model.HJGL_HotProess hotProess)
{
Model.SGGLDB db = Funs.DB;
Model.HJGL_HotProess newTestPackage = new Model.HJGL_HotProess();
newTestPackage.HotProessId = hotProess.HotProessId;
newTestPackage.HotProessNo = hotProess.HotProessNo;
newTestPackage.ProessDate = hotProess.ProessDate;
newTestPackage.ProjectId = hotProess.ProjectId;
newTestPackage.InstallationId = hotProess.InstallationId;
newTestPackage.UnitId = hotProess.UnitId;
newTestPackage.Tabler = hotProess.Tabler;
newTestPackage.Remark = hotProess.Remark;
newTestPackage.ProessMethod = hotProess.ProessMethod;
newTestPackage.ProessEquipment = hotProess.ProessEquipment;
newTestPackage.NDTMethod = hotProess.NDTMethod;
newTestPackage.NDTRate = hotProess.NDTRate;
newTestPackage.Standards = hotProess.Standards;
newTestPackage.InspectionNum = hotProess.InspectionNum;
newTestPackage.CheckNum = hotProess.CheckNum;
newTestPackage.TestWeldNum = hotProess.TestWeldNum;
newTestPackage.Sendee = hotProess.Sendee;
newTestPackage.CheckUnitId = hotProess.CheckUnitId;
newTestPackage.HotProessTrustId = hotProess.HotProessTrustId;
db.HJGL_HotProess.InsertOnSubmit(newTestPackage);
db.SubmitChanges();
}
/// <summary>
/// 修改热处理信息
/// </summary>
/// <param name="weldReport">热处理实体</param>
public static void UpdateHotProess(Model.HJGL_HotProess hotProess)
{
Model.SGGLDB db = Funs.DB;
Model.HJGL_HotProess newTestPackage = db.HJGL_HotProess.FirstOrDefault(e => e.HotProessId == hotProess.HotProessId);
if (newTestPackage != null)
{
newTestPackage.HotProessId = hotProess.HotProessId;
newTestPackage.HotProessNo = hotProess.HotProessNo;
newTestPackage.ProessDate = hotProess.ProessDate;
newTestPackage.ProjectId = hotProess.ProjectId;
newTestPackage.InstallationId = hotProess.InstallationId;
newTestPackage.UnitId = hotProess.UnitId;
newTestPackage.Tabler = hotProess.Tabler;
newTestPackage.Remark = hotProess.Remark;
newTestPackage.ProessMethod = hotProess.ProessMethod;
newTestPackage.ProessEquipment = hotProess.ProessEquipment;
newTestPackage.NDTMethod = hotProess.NDTMethod;
newTestPackage.NDTRate = hotProess.NDTRate;
newTestPackage.Standards = hotProess.Standards;
newTestPackage.InspectionNum = hotProess.InspectionNum;
newTestPackage.CheckNum = hotProess.CheckNum;
newTestPackage.TestWeldNum = hotProess.TestWeldNum;
newTestPackage.Sendee = hotProess.Sendee;
newTestPackage.CheckUnitId = hotProess.CheckUnitId;
newTestPackage.HotProessTrustId = hotProess.HotProessTrustId;
db.SubmitChanges();
}
}
/// <summary>
/// 根据主键删除热处理信息
/// </summary>
/// <param name="hotProessID">热处理主键</param>
public static void DeleteHotProessByHotProessID(string hotProessID)
{
Model.SGGLDB db = Funs.DB;
Model.HJGL_HotProess hotProess = db.HJGL_HotProess.FirstOrDefault(e => e.HotProessId == hotProessID);
if (hotProess != null)
{
db.HJGL_HotProess.DeleteOnSubmit(hotProess);
db.SubmitChanges();
}
}
/// <summary>
/// 根据主键删除热处理信息明细
/// </summary>
/// <param name="hotProessID">热处理主键</param>
public static void DeleteHotProessItemByHotProessId(string HotProessId)
{
Model.SGGLDB db = Funs.DB;
var items = from x in db.HJGL_HotProessItem where x.HotProessId == HotProessId select x;
if (items != null)
{
foreach (var item in items)
{
Model.HJGL_PW_JointInfo info = new Model.HJGL_PW_JointInfo();
info.JOT_ID = item.JOT_ID;
info.IS_Proess = "0";
UpdateJointInfo(info);
}
db.HJGL_HotProessItem.DeleteAllOnSubmit(items);
db.SubmitChanges();
}
}
/// <summary>
/// 根据委托主键删除热处理信息明细
/// </summary>
/// <param name="hotProessID">热处理委托主键</param>
public static void DeleteHotProessItemByHotProessTrustId(string HotProessTrustId)
{
Model.SGGLDB db = Funs.DB;
var items = from x in db.HJGL_HotProessItem where x.HotProessTrustId == HotProessTrustId select x;
if (items != null)
{
//foreach (var item in items)
//{
// Model.HJGL_PW_JointInfo info = new Model.HJGL_PW_JointInfo();
// info.JOT_ID = item.JOT_ID;
// info.JOT_ProessDate = null;
// info.JOT_HotRpt = null;
// info.IS_Proess = "0";
// UpdateJointInfo(info);
//}
db.HJGL_HotProessItem.DeleteAllOnSubmit(items);
db.SubmitChanges();
}
}
/// <summary>
/// 根据委托主键删除热处理信息明细
/// </summary>
/// <param name="hotProessID">热处理委托主键</param>
public static void DeleteHotProessItemByHotProessItemId(string HotProessItemId)
{
Model.SGGLDB db = Funs.DB;
var items = (from x in db.HJGL_HotProessItem where x.HotProessItemId == HotProessItemId select x).FirstOrDefault();
if (items != null)
{
//foreach (var item in items)
//{
// Model.HJGL_PW_JointInfo info = new Model.HJGL_PW_JointInfo();
// info.JOT_ID = item.JOT_ID;
// info.JOT_ProessDate = null;
// info.JOT_HotRpt = null;
// info.IS_Proess = "0";
// UpdateJointInfo(info);
//}
db.HJGL_HotProessItem.DeleteOnSubmit(items);
db.SubmitChanges();
}
}
/// <summary>
/// 增加热处理信息明细
/// </summary>
/// <param name="HJGL_HotProessItem">热处理明细实体</param>
public static void AddHotProessItem(Model.HJGL_HotProessItem HJGL_HotProessItem, string HotProessNo, string date)
{
Model.SGGLDB db = Funs.DB;
Model.HJGL_HotProessItem newHotProessItem = new Model.HJGL_HotProessItem();
if (!string.IsNullOrEmpty(HJGL_HotProessItem.HotProessItemId))
{
newHotProessItem.HotProessItemId = HJGL_HotProessItem.HotProessItemId;
}
else
{
newHotProessItem.HotProessItemId = SQLHelper.GetNewID(typeof(Model.HJGL_HotProessItem));
}
newHotProessItem.HotProessId = HJGL_HotProessItem.HotProessId;
newHotProessItem.JOT_ID = HJGL_HotProessItem.JOT_ID;
newHotProessItem.PointCount = HJGL_HotProessItem.PointCount;
newHotProessItem.RequiredT = HJGL_HotProessItem.RequiredT;
newHotProessItem.ActualT = HJGL_HotProessItem.ActualT;
newHotProessItem.ProessTypes = HJGL_HotProessItem.ProessTypes;
newHotProessItem.RequestTime = HJGL_HotProessItem.RequestTime;
newHotProessItem.ActualTime = HJGL_HotProessItem.ActualTime;
newHotProessItem.RecordChartNo = HJGL_HotProessItem.RecordChartNo;
newHotProessItem.HardnessReportNo = HJGL_HotProessItem.HardnessReportNo;
newHotProessItem.HotProessTrustId = HJGL_HotProessItem.HotProessTrustId;
newHotProessItem.HotProessDate = HJGL_HotProessItem.HotProessDate;
newHotProessItem.SortIndex = HJGL_HotProessItem.SortIndex;
newHotProessItem.Remark = HJGL_HotProessItem.Remark;
Model.HJGL_CH_HotProessTrustItem hotProessTrustItem = BLL.HJGL_CH_HotProessTrustService.GetCH_HotProessTrustItemByHotProessTrustIdAndJotId(HJGL_HotProessItem.HotProessTrustId, HJGL_HotProessItem.JOT_ID);
if (hotProessTrustItem != null) //如果热处理委托明细存在,则插入并更新数据
{
db.HJGL_HotProessItem.InsertOnSubmit(newHotProessItem);
db.SubmitChanges();
////更新焊口信息
Model.HJGL_PW_JointInfo info = new Model.HJGL_PW_JointInfo();
info.JOT_ID = HJGL_HotProessItem.JOT_ID;
info.IS_Proess = "1";
UpdateJointInfo(info);
}
}
/// <summary>
/// 修改
/// </summary>
/// <param name="jointInfo"></param>
public static void UpdateJointInfo(Model.HJGL_PW_JointInfo jointInfo)
{
Model.SGGLDB db = Funs.DB;
Model.HJGL_PW_JointInfo newJointInfo = db.HJGL_PW_JointInfo.FirstOrDefault(e => e.JOT_ID == jointInfo.JOT_ID);
if (newJointInfo != null)
{
newJointInfo.IS_Proess = jointInfo.IS_Proess;
db.SubmitChanges();
}
}
/// <summary>
/// 根据单位Id获取热处理数
/// </summary>
/// <param name="unitId"></param>
/// <returns></returns>
public static int GetHotProessByUnitId(string unitId)
{
var q = (from x in Funs.DB.HJGL_HotProess where x.UnitId == unitId select x).ToList();
return q.Count();
}
/// <summary>
/// 根据装置Id获取热处理数
/// </summary>
/// <param name="installationId"></param>
/// <returns></returns>
public static int GetHotProessByInstallationId(string installationId)
{
var q = (from x in Funs.DB.HJGL_HotProess where x.InstallationId == installationId select x).ToList();
return q.Count();
}
/// <summary>
/// 根据焊口获取热处理
/// </summary>
/// <param name="jotno"></param>
/// <returns></returns>
public static int GetHotProessByJotId(string jotno)
{
var q = (from x in Funs.DB.HJGL_HotProessItem join y in Funs.DB.HJGL_PW_JointInfo on x.JOT_ID equals y.JOT_ID where y.JOT_JointNo == jotno select x).ToList();
return q.Count();
}
/// <summary>
/// 根据热处理主键获取热处理编号是否存在
/// </summary>
/// <param name="weldReportNo">焊接日报编号</param>
/// <returns>焊接日报信息</returns>
public static bool IsExistHotProessNO(string hotProessNo, string hotProessId, string projectId)
{
var q = Funs.DB.HJGL_HotProess.FirstOrDefault(x => x.HotProessNo == hotProessNo && x.ProjectId == projectId && x.HotProessId != hotProessId);
if (q != null)
{
return true;
}
else
{
return false;
}
}
}
}