SGGL_SHJ/SGGL/BLL/HJGL/WeldingManage/PipelineComponentService.cs

270 lines
11 KiB
C#
Raw Normal View History

2022-09-05 16:36:31 +08:00
using System.Collections.Generic;
using System.Linq;
using System.Web.UI.WebControls;
namespace BLL
{
public class HJGL_PipelineComponentService
{
/// <summary>
/// 未验收
/// </summary>
public static int state_0 = 0;
/// <summary>
/// 已验收
/// </summary>
public static int state_1 = 1;
/// <summary>
/// 已装箱
/// </summary>
public static int state_2 = 2;
public static ListItem[] GetState()
{
ListItem[] list = new ListItem[3];
list[0] = new ListItem("未验收", state_0.ToString());
list[1] = new ListItem("已验收", state_1.ToString());
list[2] = new ListItem("已出库", state_2.ToString());
return list;
}
/// <summary>
/// 根据ID获取组件信息
/// </summary>
/// <param name="pipelineName"></param>
/// <returns></returns>
public static Model.HJGL_Pipeline_Component GetPipelineComponentById(string pipelineComponentId)
{
return Funs.DB.HJGL_Pipeline_Component.FirstOrDefault(e => e.PipelineComponentId == pipelineComponentId);
}
public static Model.HJGL_Pipeline_Component GetPipelineComponentByCodeandpipelineId(string pipelineComponentCode, string pipelineId)
{
var q = Funs.DB.HJGL_Pipeline_Component.FirstOrDefault(x => x.PipelineComponentCode == pipelineComponentCode && x.PipelineId == pipelineId);
return q;
}
/// <summary>
/// 根据材料信息id获取组件信息
/// </summary>
/// <param name="pipeLineMatId"></param>
/// <returns></returns>
public static Model.HJGL_Pipeline_Component GetPipelineComponentByMatId(string pipeLineMatId)
{
return Funs.DB.HJGL_Pipeline_Component.FirstOrDefault(e => e.PipeLineMatId == pipeLineMatId);
}
/// <summary>
/// 判断管线组件Code是否存在
/// </summary>
/// <param name="pipelineComponentCode"></param>
/// <param name="pipelineComponentId"></param>
/// <returns></returns>
public static bool IsExistPipelineComponentCode(string pipelineComponentCode, string pipelineId, string pipelineComponentId)
{
Model.SGGLDB db = Funs.DB;
Model.HJGL_Pipeline_Component q = null;
if (!string.IsNullOrEmpty(pipelineComponentId))
{
q = Funs.DB.HJGL_Pipeline_Component.FirstOrDefault(x => x.PipelineComponentCode == pipelineComponentCode && x.PipelineId == pipelineId && x.PipelineComponentId != pipelineComponentId);
}
else
{
q = Funs.DB.HJGL_Pipeline_Component.FirstOrDefault(x => x.PipelineComponentCode == pipelineComponentCode && x.PipelineId == pipelineId);
}
if (q != null)
{
return true;
}
else
{
return false;
}
}
/// <summary>
/// 根据管线材料id同步组件
/// </summary>
public static void SyncPipelineComponentByMatId(string pipeLineMatId)
{
var model_mat = BLL.PipelineMatService.GetPipeLineMat(pipeLineMatId);
var PipelineId = model_mat.PipelineId;
var PipeArea = BLL.PipelineService.GetPipelineByPipelineId(PipelineId).PipeArea;
if (PipeArea=="1")
{
// var model = GetPipelineComponentByMatId(pipeLineMatId);
var model = GetPipelineComponentByCodeandpipelineId(model_mat.PrefabricatedComponents,PipelineId);
if (model!=null)
{
model.PipelineId = PipelineId;
model.PipelineComponentCode = model_mat.PrefabricatedComponents;
2022-10-11 17:12:13 +08:00
model.DrawingName = model_mat.PrefabricatedComponents.Substring(0, model_mat.PrefabricatedComponents.LastIndexOf('-'));
2022-09-05 16:36:31 +08:00
model.State = state_0;
UpdatePipelineComponent(model);
}
else
{
model=new Model.HJGL_Pipeline_Component();
model.PipelineComponentId = SQLHelper.GetNewID();
model.PipelineId = PipelineId;
model.PipelineComponentCode = model_mat.PrefabricatedComponents;
2022-10-11 17:12:13 +08:00
model.DrawingName = model_mat.PrefabricatedComponents.Substring(0, model_mat.PrefabricatedComponents.LastIndexOf('-'));
2022-09-05 16:36:31 +08:00
model.State = state_0;
AddPipelineComponent(model);
}
}
}
/// <summary>
/// 添加作业管线
/// </summary>
/// <param name="pipeline"></param>
public static void AddPipelineComponent(Model.HJGL_Pipeline_Component pipeline)
{
Model.SGGLDB db = Funs.DB;
Model.HJGL_Pipeline_Component newPipeline = new Model.HJGL_Pipeline_Component();
newPipeline.PipelineComponentId = pipeline.PipelineComponentId;
newPipeline.PipelineId = pipeline.PipelineId;
newPipeline.PreUnit = pipeline.PreUnit;
newPipeline.PipelineComponentCode = pipeline.PipelineComponentCode;
newPipeline.BoxNumber = pipeline.BoxNumber;
newPipeline.AssembleUnit = pipeline.AssembleUnit;
newPipeline.PipeLineMatId = pipeline.PipeLineMatId;
newPipeline.State= pipeline.State;
newPipeline.QRCode= pipeline.QRCode;
newPipeline.PlanStartDate = pipeline.PlanStartDate;
newPipeline.PlanEndDate = pipeline.PlanEndDate;
newPipeline.ActStartDate = pipeline.ActStartDate;
newPipeline.ActEndDate = pipeline.ActEndDate;
2022-09-23 22:29:48 +08:00
newPipeline.DrawingName = pipeline.DrawingName;
2022-10-15 15:40:49 +08:00
newPipeline.ReceiveMan= pipeline.ReceiveMan;
newPipeline.ReceiveDate= pipeline.ReceiveDate;
2022-09-05 16:36:31 +08:00
db.HJGL_Pipeline_Component.InsertOnSubmit(newPipeline);
db.SubmitChanges();
}
/// <summary>
/// 修改作业管线
/// </summary>
/// <param name="pipeline"></param>
public static void UpdatePipelineComponent(Model.HJGL_Pipeline_Component pipeline)
{
Model.SGGLDB db = Funs.DB;
Model.HJGL_Pipeline_Component newPipeline = db.HJGL_Pipeline_Component.FirstOrDefault(e => e.PipelineComponentId == pipeline.PipelineComponentId);
if (newPipeline != null)
{
newPipeline.PipelineId = pipeline.PipelineId;
newPipeline.PreUnit = pipeline.PreUnit;
newPipeline.PipelineComponentCode = pipeline.PipelineComponentCode;
newPipeline.BoxNumber = pipeline.BoxNumber;
newPipeline.AssembleUnit = pipeline.AssembleUnit;
newPipeline.PipeLineMatId = pipeline.PipeLineMatId;
newPipeline.State = pipeline.State;
newPipeline.QRCode = pipeline.QRCode;
newPipeline.PlanStartDate = pipeline.PlanStartDate;
newPipeline.PlanEndDate = pipeline.PlanEndDate;
newPipeline.ActStartDate = pipeline.ActStartDate;
newPipeline.ActEndDate = pipeline.ActEndDate;
2022-09-23 22:29:48 +08:00
newPipeline.DrawingName = pipeline.DrawingName;
2022-10-15 15:40:49 +08:00
newPipeline.ReceiveMan = pipeline.ReceiveMan;
newPipeline.ReceiveDate = pipeline.ReceiveDate;
2022-09-05 16:36:31 +08:00
db.SubmitChanges();
}
}
2022-10-15 15:40:49 +08:00
public static void UpdateOutState(string pipelineComponentId,string BoxNumber)
2022-09-05 16:36:31 +08:00
{
var q=GetPipelineComponentById(pipelineComponentId);
if (q.State==state_1)
{
q.State = state_2;
2022-10-15 15:40:49 +08:00
q.BoxNumber=BoxNumber;
2022-09-05 16:36:31 +08:00
UpdatePipelineComponent(q);
}
}
/// <summary>
/// 根据作业管线Id删除一个作业管线信息
/// </summary>
/// <param name="pipelineId"></param>
public static void DeletePipelineComponent(string pipelineComponentId)
{
Model.SGGLDB db = Funs.DB;
Model.HJGL_Pipeline_Component pipeline = db.HJGL_Pipeline_Component.FirstOrDefault(e => e.PipelineComponentId == pipelineComponentId);
if (pipeline != null)
{
db.HJGL_Pipeline_Component.DeleteOnSubmit(pipeline);
db.SubmitChanges();
}
}
/// <summary>
/// 根据管线材料id删除对应组件
/// </summary>
/// <param name="pipeLineMatId"></param>
public static void DeletePipelineComponentByMatId(string pipeLineMatId)
{
Model.SGGLDB db = Funs.DB;
var mdoel = db.HJGL_Pipeline_Component.Where(e => e.PipeLineMatId == pipeLineMatId);
if (mdoel != null)
{
db.HJGL_Pipeline_Component.DeleteAllOnSubmit(mdoel);
db.SubmitChanges();
}
}
/// <summary>
/// 根据管线id删除组件
/// </summary>
/// <param name="pipelineId"></param>
public static void DeletePipelineComponentBypipelineId(string pipelineId)
{
Model.SGGLDB db = Funs.DB;
var mdoel = db.HJGL_Pipeline_Component.Where(e => e.PipelineId == pipelineId);
if (mdoel != null)
{
db.HJGL_Pipeline_Component.DeleteAllOnSubmit(mdoel);
db.SubmitChanges();
}
}
/// <summary>
/// 获取已经验收的预制组件
/// </summary>
/// <param name="projectid"></param>
/// <returns></returns>
public static List<Model.HJGL_Pipeline_Component> GetAcceptedPipelineComponent(string projectid)
{
Model.SGGLDB db = Funs.DB;
var q = (from x in db.HJGL_Pipeline_Component
join y in db.HJGL_Pipeline on x.PipelineId equals y.PipelineId
where y.ProjectId.Contains(projectid) && x.State.Equals(state_1)
select x).ToList();
return q;
}
/// <summary>
/// 管线下拉框
/// </summary>
/// <param name="dropName">下拉框名字</param>
/// <param name="isShowPlease">是否显示请选择</param>
public static void InitPipelineDownList(FineUIPro.DropDownList dropName,string projectid, bool isShowPlease)
{
dropName.DataValueField = "PipelineComponentId";
dropName.DataTextField = "PipelineComponentCode";
dropName.DataSource = GetAcceptedPipelineComponent(projectid);
dropName.DataBind();
if (isShowPlease)
{
Funs.FineUIPleaseSelect(dropName);
}
}
2022-09-23 22:29:48 +08:00
public static void InitMainItemDownList(FineUIPro.DropDownList dropName, bool isShowPlease)
{
dropName.DataValueField = "Value";
dropName.DataTextField = "Text";
dropName.DataSource = GetState();
dropName.DataBind();
if (isShowPlease)
{
Funs.FineUIPleaseSelect(dropName);
}
}
2022-09-05 16:36:31 +08:00
}
}