ZHJA_HJGL/HJGL_ZH/BLL/API/APIIsoInfoServicecs.cs

173 lines
6.8 KiB
C#

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Model;
namespace BLL
{
public static class APIIsoInfoServicecs
{
/// <summary>
/// 添加管线信息
/// </summary>
/// <param name="addItem"></param>
public static void SaveIsoInfo(IsoInfoItem addItem)
{
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
{
var p= db.Base_Project.FirstOrDefault(z => z.ProjectCode == addItem.ProjectCode.Trim());
if (p != null)
{
var iso = db.HJGL_PW_IsoInfo.FirstOrDefault(z => z.ProjectId == p.ProjectId && z.ISO_IsoNo == addItem.ISO_IsoNo.Trim());
var isoClass = db.HJGL_BS_IsoClass.FirstOrDefault(z => z.ISC_IsoName == addItem.IDName.Trim());
var execStandard=db.HJGL_BS_ExecStandard.FirstOrDefault(z => z.ExecStandardName == addItem.ISO_Executive.Trim());
var ste = db.HJGL_BS_Steel.FirstOrDefault(z => z.STE_Code == addItem.STECode.Trim());
var ser = db.HJGL_BS_Service.FirstOrDefault(z => z.SER_Name == addItem.SERName.Trim());
var pipe_type = DropListService.HJGL_PipeLineClassItem().FirstOrDefault(x => x.Value == addItem.PipeLineClass.Trim());
var steStandard = db.HJGL_BS_MaterialStandard.FirstOrDefault(x => x.MaterialStandardCode == addItem.MaterialStandardCode.Trim());
Model.HJGL_PW_IsoInfo newPipe = new Model.HJGL_PW_IsoInfo();
newPipe.ProjectId = p.ProjectId;
newPipe.BSU_ID = addItem.UnitId;
newPipe.ISO_IsoNo = addItem.ISO_IsoNo.Trim();
if (isoClass != null)
{
newPipe.ISC_ID = isoClass.ISC_ID;
}
else
{
newPipe.ISC_ID = null;
}
if (execStandard != null)
{
newPipe.ISO_Executive = execStandard.ExecStandardId;
}
else
{
newPipe.ISO_Executive = null;
}
if (ste != null)
{
newPipe.STE_ID = ste.STE_ID;
}
else
{
newPipe.STE_ID = null;
}
if (steStandard != null)
{
newPipe.MaterialStandardId = steStandard.MaterialStandardId;
}
else
{
newPipe.MaterialStandardId = null;
}
if (ser != null)
{
newPipe.SER_ID = ser.SER_ID;
}
else
{
newPipe.SER_ID = null;
}
if (pipe_type != null)
{
newPipe.PipeLineClass = pipe_type.Value;
}
else
{
newPipe.PipeLineClass = null;
}
newPipe.ISO_DesignPress = addItem.ISO_DesignPress;
newPipe.ISO_DesignTemperature = addItem.ISO_DesignTemperature;
newPipe.ISO_TestPress = addItem.ISO_TestPress;
newPipe.LeakageTest = addItem.LeakageTest;
newPipe.ISO_Dia = addItem.Dia;
newPipe.ISO_Sch = addItem.Sch;
newPipe.TestCategoryNum = "/";
var weldControl = BLL.HJGL_WeldControlService.GEtWeldControlByISCIDAndExecStandardId(isoClass != null ? isoClass.ISC_ID : "", execStandard != null ? execStandard.ExecStandardId : "");
if (weldControl != null)
{
if (!string.IsNullOrEmpty(weldControl.Joty_Rate))
{
var rate = BLL.HJGL_DetectionService.GetNDTRateByNDTRID(weldControl.Joty_Rate);
if (rate != null)
{
newPipe.TestCategoryNum = rate.NDTR_Code;
}
newPipe.Joty_B_Rate = weldControl.Joty_Rate;
}
if (!string.IsNullOrEmpty(weldControl.Joty_Level))
{
newPipe.Joty_B_Level = weldControl.Joty_Level;
}
if (!string.IsNullOrEmpty(weldControl.Joty_C_Rate))
{
newPipe.Joty_C_Rate = weldControl.Joty_C_Rate;
}
if (!string.IsNullOrEmpty(weldControl.Joty_C_Level))
{
newPipe.Joty_C_Level = weldControl.Joty_C_Level;
}
if (!string.IsNullOrEmpty(weldControl.Joty_D_Rate))
{
newPipe.Joty_D_Rate = weldControl.Joty_D_Rate;
}
if (!string.IsNullOrEmpty(weldControl.Joty_D_Level))
{
newPipe.Joty_D_Level = weldControl.Joty_D_Level;
}
}
if (!string.IsNullOrEmpty(addItem.HotType))
{
newPipe.IsHot = "1";
newPipe.IsHotType = addItem.HotType;
}
else
{
newPipe.IsHot = "0";
newPipe.IsHotType = null;
}
if (iso != null)
{
newPipe.ISO_ID = iso.ISO_ID;
HJGL_PW_IsoInfoService.UpdateIsoInfo(newPipe);
}
else
{
newPipe.ISO_ID = SQLHelper.GetNewID();
db.HJGL_PW_IsoInfo.InsertOnSubmit(newPipe);
db.SubmitChanges();
}
}
}
}
#region 线
/// <summary>
/// 批量保存管线信息
/// </summary>
/// <param name="addItems"></param>
public static void SaveBatchIsoInfo(List<Model.IsoInfoItem> addItems)
{
if (addItems.Count() > 0)
{
foreach (Model.IsoInfoItem addItem in addItems)
{
SaveIsoInfo(addItem);
}
}
}
#endregion
}
}