ChengDa_English/SGGL/BLL/HJGL/WeldingManage/PipelineService.cs

377 lines
16 KiB
C#
Raw Normal View History

2022-12-20 09:32:32 +08:00
using FineUIPro;
using System;
2022-03-15 17:36:38 +08:00
using System.Collections;
2022-12-20 09:32:32 +08:00
using System.Linq;
2022-03-15 17:36:38 +08:00
namespace BLL
{
public static class PipelineService
{
2022-12-20 09:32:32 +08:00
public static Model.SGGLDB db = Funs.DB;
#region 线
/// <summary>
/// 记录数
/// </summary>
public static int count
{
get;
set;
}
/// <summary>
/// 定义变量
/// </summary>
private static IQueryable<Model.HJGL_View_IsoInfoList> getDataLists = from x in db.HJGL_View_IsoInfoList
select x;
/// <summary>
/// 数据列表
/// </summary>
/// <param name="unitId"></param>
/// <param name="Grid1"></param>
/// <returns></returns>
public static IEnumerable getListData(string projectId,string workAreaId,string unitId,string standard, string isoNo, string testMediumId
,string detectionTypeId,string isoNumber,string materialId,string specification,Grid Grid1)
{
IQueryable<Model.HJGL_View_IsoInfoList> getDataList = getDataLists.Where(x=>x.ProjectId == projectId);
if (!string.IsNullOrEmpty(workAreaId))
{
getDataList = getDataList.Where(x => x.WorkAreaId == workAreaId);
}
if (!string.IsNullOrEmpty(unitId))
{
getDataList = getDataList.Where(x => x.UnitId == unitId);
}
if (!string.IsNullOrEmpty(standard))
{
getDataList = getDataList.Where(x => x.Is_Standard == standard);
}
if (!string.IsNullOrEmpty(isoNo))
{
getDataList = getDataList.Where(x => x.ISO_IsoNo.Contains(isoNo));
}
if (!string.IsNullOrEmpty(testMediumId) && testMediumId != Const._Null)
{
getDataList = getDataList.Where(x => x.TestMediumId == testMediumId);
}
if (!string.IsNullOrEmpty(detectionTypeId) && detectionTypeId != Const._Null)
{
getDataList = getDataList.Where(x => x.DetectionTypeId == detectionTypeId);
}
if (!string.IsNullOrEmpty(isoNumber))
{
getDataList = getDataList.Where(x => x.ISO_IsoNumber.Contains(isoNumber));
}
if (!string.IsNullOrEmpty(materialId) && materialId != Const._Null)
{
getDataList = getDataList.Where(x => x.MaterialId == materialId);
}
if (!string.IsNullOrEmpty(specification))
{
// getDataList = getDataList.Where(x => x.ISO_Specification.Contains(specification));
}
count = getDataList.Count();
if (count == 0)
{
return null;
}
if (Grid1.PageSize > count)
{
Grid1.PageSize = count;
}
getDataList = SortConditionHelper.SortingAndPaging(getDataList, Grid1.SortField, Grid1.SortDirection, Grid1.PageIndex, Grid1.PageSize);
return from x in getDataList
select new
{
x.ISO_ID,
x.ProjectId,
x.ISO_IsoNo,
x.UnitId,
x.UnitName,
x.TestMediumId,
x.MediumName,
x.DetectionRateId,
x.DetectionRateValue,
x.DetectionTypeId,
x.DetectionTypeName,
x.WorkAreaId,
x.WorkAreaCode,
//x.ISO_SysNo,
//x.ISO_SubSysNo,
//x.ISO_CwpNo,
x.ISO_IsoNumber,
//x.ISO_Rev,
//x.ISO_Sheet,
//x.ISO_PipeQty,
//x.ISO_Paint,
//x.ISO_Insulator,
x.MaterialId,
x.MaterialType,
//x.ISO_Executive,
//x.ISO_Modifier,
//x.ISO_ModifyDate,
//x.ISO_Creator,
//x.ISO_CreateDate,
//x.ISO_DesignPress,
//x.ISO_DesignTemperature,
//x.ISO_TestPress,
//x.ISO_TestTemperature,
x.ISO_NDTClass,
x.ISO_PTRate,
x.Is_Standard,
x.PipingClassId,
x.PipingClassName,
// x.ISO_PTClass,
//ISO_IfPickling = (x.ISO_IfPickling == true ? "是" : "否"),
//ISO_IfChasing = (x.ISO_IfChasing == true ? "是" : "否"),
//x.ISO_Remark,
x.TotalDin,
x.JointCount
};
}
#endregion
#region
/// <summary>
/// 批量删除
/// </summary>
/// <returns></returns>
public static Model.ResponeData DelAllPopeline(string projectId, string workAreaId, string unitId, string standard, string isoNo, string testMediumId
, string detectionTypeId, string isoNumber, string materialId, string specification)
{
var responeData = new Model.ResponeData();
try
{
int pcount = 0;
IQueryable<Model.PW_IsoInfo> getDataList = Funs.DB.PW_IsoInfo.Where(x => x.ProjectId == projectId);
if (!string.IsNullOrEmpty(workAreaId))
{
getDataList = getDataList.Where(x => x.WorkAreaId == workAreaId);
}
if (!string.IsNullOrEmpty(unitId))
{
getDataList = getDataList.Where(x => x.UnitId == unitId);
}
if (!string.IsNullOrEmpty(standard))
{
getDataList = getDataList.Where(x => x.Is_Standard == Convert.ToBoolean(standard));
}
if (!string.IsNullOrEmpty(isoNo))
{
getDataList = getDataList.Where(x => x.ISO_IsoNo.Contains(isoNo));
}
if (!string.IsNullOrEmpty(testMediumId) && testMediumId != Const._Null)
{
getDataList = getDataList.Where(x => x.TestMediumId == testMediumId);
}
if (!string.IsNullOrEmpty(detectionTypeId) && testMediumId != Const._Null)
{
getDataList = getDataList.Where(x => x.DetectionTypeId == detectionTypeId);
}
if (!string.IsNullOrEmpty(isoNumber))
{
getDataList = getDataList.Where(x => x.ISO_IsoNumber.Contains(isoNumber));
}
if (!string.IsNullOrEmpty(materialId) && testMediumId != Const._Null)
{
getDataList = getDataList.Where(x => x.MaterialId == materialId);
}
if (!string.IsNullOrEmpty(specification))
{
getDataList = getDataList.Where(x => x.ISO_Specification.Contains(specification));
}
pcount = getDataList.Count();
if (pcount == 0)
{
responeData.code = 0;
responeData.message = "没有符合条件数据!";
}
else
{
var getJots = from x in Funs.DB.PW_JointInfo
join y in getDataList on x.ISO_ID equals y.ISO_ID
select x;
var getDJot = getJots.FirstOrDefault(x => x.DReportID != null);
if (getDJot != null)
{
responeData.code = 0;
responeData.message = "当前管线中,存在已做日报的焊口!";
}
else
{
int jcount = getJots.Count();
Funs.DB.PW_JointInfo.DeleteAllOnSubmit(getJots);
Funs.DB.PW_IsoInfo.DeleteAllOnSubmit(getDataList);
Funs.DB.SubmitChanges();
responeData.code = 1;
responeData.message = "删除管线:"+ pcount.ToString()+"条;焊口:"+ jcount .ToString()+ "个。";
}
}
}
catch (Exception ex)
{
responeData.code = 0;
responeData.message = ex.Message;
}
return responeData;
}
#endregion
2022-03-15 17:36:38 +08:00
/// <summary>
/// 根据管线ID获取管线信息
/// </summary>
/// <param name="pipelineName"></param>
/// <returns></returns>
public static Model.HJGL_Pipeline GetPipelineByPipelineId(string pipelineId)
{
return Funs.DB.HJGL_Pipeline.FirstOrDefault(e => e.PipelineId == pipelineId);
}
/// <summary>
/// 根据管线ID获取管线信息
/// </summary>
/// <param name="pipelineName"></param>
/// <returns></returns>
public static Model.View_HJGL_Pipeline GetViewPipelineByPipelineId(string pipelineId)
{
return Funs.DB.View_HJGL_Pipeline.FirstOrDefault(e => e.PipelineId == pipelineId);
}
/// <summary>
/// 根据管线Code获取管线信息
/// </summary>
/// <param name="isoNo"></param>
/// <returns></returns>
public static bool IsExistPipelineCode(string pipelineCode, string workAreaId, string PipelineId)
{
Model.SGGLDB db = Funs.DB;
Model.HJGL_Pipeline q = null;
if (!string.IsNullOrEmpty(PipelineId))
{
q = Funs.DB.HJGL_Pipeline.FirstOrDefault(x => x.PipelineCode == pipelineCode && x.UnitWorkId == workAreaId && x.PipelineId != PipelineId);
}
else
{
q = Funs.DB.HJGL_Pipeline.FirstOrDefault(x => x.PipelineCode == pipelineCode && x.UnitWorkId == workAreaId);
}
if (q != null)
{
return true;
}
else
{
return false;
}
}
/// <summary>
/// 添加作业管线
/// </summary>
/// <param name="pipeline"></param>
public static void AddPipeline(Model.HJGL_Pipeline pipeline)
{
Model.SGGLDB db = Funs.DB;
Model.HJGL_Pipeline newPipeline = new Model.HJGL_Pipeline();
newPipeline.PipelineId = pipeline.PipelineId;
newPipeline.ProjectId = pipeline.ProjectId;
//newPipeline.InstallationId = pipeline.InstallationId;
newPipeline.UnitId = pipeline.UnitId;
newPipeline.UnitWorkId = pipeline.UnitWorkId;
newPipeline.PipelineCode = pipeline.PipelineCode;
newPipeline.SingleNumber = pipeline.SingleNumber;
newPipeline.PipingClassId = pipeline.PipingClassId;
newPipeline.MediumId = pipeline.MediumId;
newPipeline.DetectionRateId = pipeline.DetectionRateId;
newPipeline.DetectionType = pipeline.DetectionType;
newPipeline.DesignPress = pipeline.DesignPress;
newPipeline.DesignTemperature = pipeline.DesignTemperature;
newPipeline.TestPressure = pipeline.TestPressure;
newPipeline.TestMedium = pipeline.TestMedium;
newPipeline.PipeLenth = pipeline.PipeLenth;
newPipeline.PressurePipingClassId = pipeline.PressurePipingClassId;
newPipeline.Remark = pipeline.Remark;
newPipeline.LeakPressure = pipeline.LeakPressure;
newPipeline.LeakMedium = pipeline.LeakMedium;
newPipeline.VacuumPressure = pipeline.VacuumPressure;
newPipeline.PCMedium = pipeline.PCMedium;
newPipeline.PCtype = pipeline.PCtype;
db.HJGL_Pipeline.InsertOnSubmit(newPipeline);
db.SubmitChanges();
}
/// <summary>
/// 修改作业管线
/// </summary>
/// <param name="pipeline"></param>
public static void UpdatePipeline(Model.HJGL_Pipeline pipeline)
{
Model.SGGLDB db = Funs.DB;
Model.HJGL_Pipeline newPipeline = db.HJGL_Pipeline.FirstOrDefault(e => e.PipelineId == pipeline.PipelineId);
if (newPipeline != null)
{
//newPipeline.InstallationId = pipeline.InstallationId;
newPipeline.UnitId = pipeline.UnitId;
newPipeline.UnitWorkId = pipeline.UnitWorkId;
newPipeline.PipelineCode = pipeline.PipelineCode;
newPipeline.SingleNumber = pipeline.SingleNumber;
newPipeline.PipingClassId = pipeline.PipingClassId;
newPipeline.MediumId = pipeline.MediumId;
newPipeline.DetectionRateId = pipeline.DetectionRateId;
newPipeline.DetectionType = pipeline.DetectionType;
newPipeline.DesignPress = pipeline.DesignPress;
newPipeline.DesignTemperature = pipeline.DesignTemperature;
newPipeline.TestPressure = pipeline.TestPressure;
newPipeline.TestMedium = pipeline.TestMedium;
newPipeline.PipeLenth = pipeline.PipeLenth;
newPipeline.PressurePipingClassId = pipeline.PressurePipingClassId;
newPipeline.LeakPressure = pipeline.LeakPressure;
newPipeline.LeakMedium = pipeline.LeakMedium;
newPipeline.VacuumPressure = pipeline.VacuumPressure;
newPipeline.PCMedium = pipeline.PCMedium;
newPipeline.PCtype = pipeline.PCtype;
newPipeline.Remark = pipeline.Remark;
try
{
db.SubmitChanges(System.Data.Linq.ConflictMode.ContinueOnConflict);
}
catch (System.Data.Linq.ChangeConflictException ex)
{
foreach (System.Data.Linq.ObjectChangeConflict occ in db.ChangeConflicts)
{
// 使用Linq缓存中实体对象的值覆盖当前数据库中的值
occ.Resolve(System.Data.Linq.RefreshMode.KeepCurrentValues);
}
// 这个地方要注意Catch方法中我们前面只是指明了怎样来解决冲突这个地方还需要再次提交更新这样的话值 //才会提交到数据库。
db.SubmitChanges();
}
}
}
/// <summary>
/// 根据作业管线Id删除一个作业管线信息
/// </summary>
/// <param name="pipelineId"></param>
public static void DeletePipeline(string pipelineId)
{
Model.SGGLDB db = Funs.DB;
Model.HJGL_Pipeline pipeline = db.HJGL_Pipeline.FirstOrDefault(e => e.PipelineId == pipelineId);
var jot = db.HJGL_Pipeline.Where(e => e.PipelineId == pipelineId);
if (pipeline != null)
{
db.HJGL_Pipeline.DeleteAllOnSubmit(jot);
db.HJGL_Pipeline.DeleteOnSubmit(pipeline);
db.SubmitChanges();
}
}
}
}