xinjiang/SGGL/BLL/HJGL/CheckManage/CheckItemManageService.cs

238 lines
9.2 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace BLL
{
/// <summary>
/// 检测明细
/// </summary>
public class CheckItemManageService
{
/// <summary>
/// 根据焊口ID获取委托明细信息
/// </summary>
/// <param name="jotId"></param>
/// <returns></returns>
public static Model.View_CH_CheckItem GetTrustItemByCheckItem(string checkItemID)
{
return Funs.DB.View_CH_CheckItem.FirstOrDefault(e => e.CHT_CheckItemID == checkItemID);
}
/// <summary>
/// 根据焊口ID获取委托明细信息
/// </summary>
/// <param name="jotId"></param>
/// <returns></returns>
public static Model.View_CH_CheckItem GetViewCheckItemByJOTID(string jotId)
{
return Funs.DB.View_CH_CheckItem.FirstOrDefault(e => e.JOT_ID == jotId);
}
public static Model.View_CH_CheckItem GetNoCheckViewCheckItemByJOTID(string jotId)
{
return Funs.DB.View_CH_CheckItem.FirstOrDefault(e => e.JOT_ID == jotId&&e.CHT_CheckID ==null);
}
public static Model.View_CH_CheckItem GetNoCheckViewCheckItemByJOTID(string jotId,string CH_TrustID)
{
return Funs.DB.View_CH_CheckItem.FirstOrDefault(e => e.JOT_ID == jotId && e.CH_TrustID == CH_TrustID);
}
/// <summary>
/// 根据焊口ID获取检测明细信息
/// </summary>
/// <param name="jotId"></param>
/// <returns></returns>
public static List<Model.CH_CheckItem> GetTrustItemByCheck(string checkId)
{
return Funs.DB.CH_CheckItem.Where(e => e.CHT_CheckID == checkId).ToList();
}
/// <summary>
/// 根据焊口ID和检测id获取检测明细信息
/// </summary>
/// <param name="jotId"></param>
/// <returns></returns>
public static Model.CH_CheckItem GetTrustItemByCheckAndJotId(string checkId, string jotId)
{
return Funs.DB.CH_CheckItem.FirstOrDefault(e => e.CHT_CheckID == checkId && e.JOT_ID == jotId);
}
/// <summary>
/// 添加
/// </summary>
/// <param name="checkItem"></param>
public static void AddCheckItem(Model.CH_CheckItem checkItem)
{
Model.CH_CheckItem newCheckItem = new Model.CH_CheckItem();
string newKeyID = SQLHelper.GetNewID(typeof(Model.CH_CheckItem));
newCheckItem.CHT_CheckItemID = newKeyID;
newCheckItem.CHT_CheckID = checkItem.CHT_CheckID;
newCheckItem.JOT_ID = checkItem.JOT_ID;
newCheckItem.CH_TrustItemID = checkItem.CH_TrustItemID;
newCheckItem.CHT_CheckMethod = checkItem.CHT_CheckMethod;
newCheckItem.CHT_RequestDate = checkItem.CHT_RequestDate;
newCheckItem.CHT_RepairLocation = checkItem.CHT_RepairLocation;
newCheckItem.CHT_TotalFilm = checkItem.CHT_TotalFilm;
newCheckItem.CHT_PassFilm = checkItem.CHT_PassFilm;
newCheckItem.CHT_CheckResult = checkItem.CHT_CheckResult;
newCheckItem.CHT_CheckNo = checkItem.CHT_CheckNo;
newCheckItem.CHT_FilmDate = checkItem.CHT_FilmDate;
newCheckItem.CHT_ReportDate = checkItem.CHT_ReportDate;
newCheckItem.CHT_Remark = checkItem.CHT_Remark;
newCheckItem.CHT_FloorWelder1 = checkItem.CHT_FloorWelder1;
newCheckItem.CHT_FloorWelder2 = checkItem.CHT_FloorWelder2;
newCheckItem.FilmSpecifications = checkItem.FilmSpecifications;
newCheckItem.DefectLength = checkItem.DefectLength;
newCheckItem.DefectDepth = checkItem.DefectDepth;
newCheckItem.DefectHeight = checkItem.DefectHeight;
newCheckItem.ExtendingRice = checkItem.ExtendingRice;
newCheckItem.Defects_Definition = checkItem.Defects_Definition;
Funs.DB.CH_CheckItem.InsertOnSubmit(newCheckItem);
Funs.DB.SubmitChanges();
}
/// <summary>
/// 根据检测单号获取相关的所有明细
/// </summary>
/// <param name="cht_checkId"></param>
/// <returns></returns>
public static List<Model.CH_CheckItem> GetCheckItemByCheck(string cht_checkId)
{
return (from x in Funs.DB.CH_CheckItem where x.CHT_CheckID == cht_checkId select x).ToList();
}
/// <summary>
/// 修改检测明细审核日期
/// </summary>
/// <param name="cht_CheckID">主表ID</param>
/// <param name="flag">1表示更新为当前时间2表示为取消审核日期</param>
public static void UpdateCheckItemAudioTime(string cht_CheckID, string flag)
{
var q = GetCheckItemByCheck(cht_CheckID);
foreach (var item in q)
{
Model.CH_CheckItem newCheck = item;
if (flag == "1")
{
newCheck.CHT_AuditTime = DateTime.Now;
}
else
{
newCheck.CHT_AuditTime = null;
}
Funs.DB.SubmitChanges();
}
}
/// <summary>
/// 根据主表Id删除所有明细信息
/// </summary>
/// <param name="checkId"></param>
public static void DeleteCheckItemByCheckId(string checkId)
{
var checkItem = from x in Funs.DB.CH_CheckItem where x.CHT_CheckID == checkId select x;
if (checkItem != null)
{
Funs.DB.CH_CheckItem.DeleteAllOnSubmit(checkItem);
Funs.DB.SubmitChanges();
}
}
/// <summary>
/// 更改焊口检测情况
/// </summary>
/// <param name="jot_id"></param>
/// <param name="type"></param>
public static void UpdateJointCheckFlag(string jot_id, string type)
{
var jointinfo = Funs.DB.PW_JointInfo.FirstOrDefault(x => x.JOT_ID == jot_id);
if (jointinfo != null)
{
if (type == "1")
{
if (string.IsNullOrEmpty(jointinfo.JOT_CheckFlag) || jointinfo.JOT_CheckFlag == "00")
{
jointinfo.JOT_CheckFlag = "01";
}
else if (jointinfo.JOT_CheckFlag == "01")//一次检测,未审核
{
jointinfo.JOT_CheckFlag = "02";
}
else if (jointinfo.JOT_CheckFlag == "02")//一次检测,已审核
{
jointinfo.JOT_CheckFlag = "11";
}
else if (jointinfo.JOT_CheckFlag == "11")//二次检测,未审核
{
jointinfo.JOT_CheckFlag = "12";
}
else if (jointinfo.JOT_CheckFlag == "12")//二次检测,已审核
{
jointinfo.JOT_CheckFlag = "21";
}
else if (jointinfo.JOT_CheckFlag == "21")//三次检测,未审核
{
jointinfo.JOT_CheckFlag = "22";//三次检测,已审核
}
}
else
{
if (jointinfo.JOT_CheckFlag == "22")
{
jointinfo.JOT_CheckFlag = "21";
}
else if (jointinfo.JOT_CheckFlag == "21")
{
jointinfo.JOT_CheckFlag = "12";
}
else if (jointinfo.JOT_CheckFlag == "12")
{
jointinfo.JOT_CheckFlag = "11";
}
else if (jointinfo.JOT_CheckFlag == "11")
{
jointinfo.JOT_CheckFlag = "02";
}
else if (jointinfo.JOT_CheckFlag == "02")
{
jointinfo.JOT_CheckFlag = "01";
}
else
{
jointinfo.JOT_CheckFlag = "00";
}
}
}
Funs.DB.SubmitChanges();
}
/// <summary>
/// 根据焊口信息获取检测记录
/// </summary>
/// <param name="jotId"></param>
/// <returns></returns>
public static Model.CH_CheckItem GetCheckItemByJotId(string jotId)
{
return Funs.DB.CH_CheckItem.FirstOrDefault(e => e.JOT_ID == jotId);
}
public static Model.CH_CheckItem GetCheckItemByJotId(string jotId,string checkId)
{
return Funs.DB.CH_CheckItem.FirstOrDefault(e => e.JOT_ID == jotId && e.CHT_CheckID== checkId);
}
/// <summary>
/// 根据检测id获取明细视图
/// </summary>
/// <param name="checkId"></param>
/// <returns></returns>
public static List<Model.View_CH_CheckItem> GetViewCheckItemByCheckId(string checkId)
{
return (from x in Funs.DB.View_CH_CheckItem where x.CHT_CheckID == checkId select x).ToList();
}
}
}