7b5b060ffc
同步管线组件、材料和焊口关联数据,优化预制组件打印及焊接相关查询,减少业务台账与实际关联信息不一致。
665 lines
28 KiB
C#
665 lines
28 KiB
C#
using Model;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Data;
|
|
using System.Linq;
|
|
using System.Web.UI.WebControls;
|
|
|
|
namespace BLL
|
|
{
|
|
public class HJGL_PipelineComponentService
|
|
{
|
|
/// <summary>
|
|
/// 待整改
|
|
/// </summary>
|
|
public static int StatePenRec = -2;
|
|
/// <summary>
|
|
/// 已整改
|
|
/// </summary>
|
|
public static int StateRec = -1;
|
|
/// <summary>
|
|
/// 未验收
|
|
/// </summary>
|
|
public static int State0 = 0;
|
|
|
|
/// <summary>
|
|
/// 已验收
|
|
/// </summary>
|
|
public static int State1 = 1;
|
|
|
|
/// <summary>
|
|
/// 已装箱
|
|
/// </summary>
|
|
public static int State2 = 2;
|
|
|
|
|
|
/// <summary>
|
|
/// 获取状态名称
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
public static ListItem[] GetState()
|
|
{
|
|
ListItem[] list = new ListItem[5];
|
|
list[0] = new ListItem("未验收", State0.ToString());
|
|
list[1] = new ListItem("已验收", State1.ToString());
|
|
list[2] = new ListItem("已出库", State2.ToString());
|
|
list[3] = new ListItem("待整改", StatePenRec.ToString());
|
|
list[4] = new ListItem("已整改", StateRec.ToString());
|
|
return list;
|
|
}
|
|
/// <summary>
|
|
/// 生产状态
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
public static ListItem[] GetProductionState()
|
|
{
|
|
ListItem[] list = new ListItem[3];
|
|
list[0] = new ListItem("未开始", "0");
|
|
list[1] = new ListItem("已开始", "1");
|
|
list[2] = new ListItem("已完成", "2");
|
|
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>
|
|
/// 获取预制散件
|
|
/// </summary>
|
|
/// <param name="unitworkId">单位工程Id</param>
|
|
/// <param name="pipelineId">管线Id</param>
|
|
/// <returns></returns>
|
|
public static IEnumerable<PipelinePrefabricatedComponentsItem> GetPipelinePrefabricatedComponent(string unitworkId, string pipelineId)
|
|
{
|
|
var query = from pipe in Funs.DB.HJGL_PipeLineMat
|
|
join lib in Funs.DB.HJGL_MaterialCodeLib on pipe.MaterialCode equals lib.MaterialCode into libJoin
|
|
from libItem in libJoin.DefaultIfEmpty()
|
|
join line in Funs.DB.HJGL_Pipeline on pipe.PipelineId equals line.PipelineId into lineJoin
|
|
from lineItem in lineJoin.DefaultIfEmpty()
|
|
where lineItem != null && lineItem.UnitWorkId == unitworkId && lineItem.PipeArea == "1"
|
|
&& (pipe.PrefabricatedComponents == null || pipe.PrefabricatedComponents == "")
|
|
select new PipelinePrefabricatedComponentsItem
|
|
{
|
|
Id = pipe.PipeLineMatId,
|
|
MaterialCode = libItem.MaterialCode,
|
|
MaterialName = libItem.MaterialName,
|
|
MaterialUnit = libItem.MaterialUnit,
|
|
MaterialSpec = libItem.MaterialSpec,
|
|
MaterialMade = libItem.MaterialMade,
|
|
MaterialDef = libItem.MaterialDef,
|
|
Number = pipe.Number,
|
|
PrefabricatedComponents = pipe.PrefabricatedComponents,
|
|
PipelineId = lineItem.PipelineId,
|
|
};
|
|
|
|
if (!string.IsNullOrEmpty(pipelineId))
|
|
{
|
|
query = query.Where(x => x.PipelineId == pipelineId);
|
|
}
|
|
|
|
query = query.OrderBy(x => x.PrefabricatedComponents);
|
|
|
|
|
|
return query.ToList();
|
|
}
|
|
/// <summary>
|
|
/// 获取预制散件
|
|
/// </summary>
|
|
/// <param name="pipelineId">管线Id</param>
|
|
/// <returns></returns>
|
|
public static IEnumerable<PipelinePrefabricatedComponentsItem> GetPipelinePrefabricatedComponent(string pipelineId)
|
|
{
|
|
var query = from pipe in Funs.DB.HJGL_PipeLineMat
|
|
join lib in Funs.DB.HJGL_MaterialCodeLib on pipe.MaterialCode equals lib.MaterialCode into libJoin
|
|
from libItem in libJoin.DefaultIfEmpty()
|
|
join line in Funs.DB.HJGL_Pipeline on pipe.PipelineId equals line.PipelineId into lineJoin
|
|
from lineItem in lineJoin.DefaultIfEmpty()
|
|
where lineItem != null && lineItem.PipeArea == "1"
|
|
&& (pipe.PrefabricatedComponents == null || pipe.PrefabricatedComponents == "")
|
|
select new PipelinePrefabricatedComponentsItem
|
|
{
|
|
Id = pipe.PipeLineMatId,
|
|
MaterialCode = libItem.MaterialCode,
|
|
MaterialName = libItem.MaterialName,
|
|
MaterialUnit = libItem.MaterialUnit,
|
|
MaterialSpec = libItem.MaterialSpec,
|
|
MaterialMade = libItem.MaterialMade,
|
|
MaterialDef = libItem.MaterialDef,
|
|
Number = pipe.Number,
|
|
PrefabricatedComponents = pipe.PrefabricatedComponents,
|
|
PipelineId = lineItem.PipelineId,
|
|
};
|
|
|
|
if (!string.IsNullOrEmpty(pipelineId))
|
|
{
|
|
query = query.Where(x => x.PipelineId == pipelineId);
|
|
}
|
|
|
|
query = query.OrderBy(x => x.PrefabricatedComponents);
|
|
|
|
var inoutplandetail = (from x in Funs.DB.HJGL_PackagingManageDetail
|
|
where x.PipelineId == pipelineId
|
|
&& (x.PipelineComponentId == null || x.PipelineComponentId == "")
|
|
select x).ToList();
|
|
var queryList = query.ToList();
|
|
// 优化 Linq 过滤条件
|
|
var result = (from x in queryList
|
|
join y in inoutplandetail on x.MaterialCode equals y.MaterialCode into yy
|
|
from y in yy.DefaultIfEmpty()
|
|
where y == null
|
|
select x).ToList();
|
|
return result;
|
|
|
|
}
|
|
|
|
/// <summary>
|
|
/// 获取打印实体
|
|
/// </summary>
|
|
/// <param name="PipelineComponentId"></param>
|
|
/// <param name="PipelineId"></param>
|
|
/// <param name="IsCheckPrint"></param>
|
|
/// <returns></returns>
|
|
public static IEnumerable<PipelineComponentPrintDto> GetPrintModelByPipelineComponentIds(string[] PipelineComponentId, string[] PipelineId, bool IsCheckPrint)
|
|
{
|
|
var db = Funs.DB;
|
|
var query =
|
|
from com in db.HJGL_Pipeline_Component
|
|
join mat in db.HJGL_PipeLineMat on com.PipeLineMatId equals mat.PipeLineMatId into matJoin
|
|
from mat in matJoin.DefaultIfEmpty()
|
|
join pipe in db.HJGL_Pipeline on com.PipelineId equals pipe.PipelineId into pipeJoin
|
|
from pipe in pipeJoin.DefaultIfEmpty()
|
|
join punit in db.Base_Unit on com.PreUnit equals punit.UnitId into punitJoin
|
|
from punit in punitJoin.DefaultIfEmpty()
|
|
join aunit in db.Base_Unit on com.AssembleUnit equals aunit.UnitId into aunitJoin
|
|
from aunit in aunitJoin.DefaultIfEmpty()
|
|
join unitwork in db.WBS_UnitWork on pipe.UnitWorkId equals unitwork.UnitWorkId into unitworkJoin
|
|
from unitwork in unitworkJoin.DefaultIfEmpty()
|
|
orderby com.PipelineComponentCode, com.PipelineId
|
|
select new PipelineComponentPrintDto
|
|
{
|
|
PipelineComponentId = com.PipelineComponentId,
|
|
PipelineComponentCode = com.PipelineComponentCode,
|
|
BoxNumber = com.BoxNumber,
|
|
UnitWorkName = unitwork.UnitWorkName,
|
|
PipelineId = com.PipelineId,
|
|
PreUnit = punit.UnitName,
|
|
AssembleUnit = aunit.UnitName,
|
|
PrefabricatedComponents = mat.PrefabricatedComponents,
|
|
State = com.State,
|
|
PlanStartDate = string.Format("yyyy-MM-dd", pipe.PlanStartDate),
|
|
PipelineCode = pipe.PipelineCode,
|
|
QRCode2 = "PrePipeline$" + com.PipelineComponentId,
|
|
IsPrint = com.IsPrint
|
|
};
|
|
|
|
var result = query.ToList();
|
|
|
|
if (PipelineComponentId != null && PipelineComponentId.Length > 0)
|
|
{
|
|
result = result.Where(x => PipelineComponentId.Contains(x.PipelineComponentId.ToString())).ToList();
|
|
}
|
|
|
|
if (PipelineId != null && PipelineId.Length > 0)
|
|
{
|
|
result = result.Where(x => PipelineId.Contains(x.PipelineId.ToString())).ToList();
|
|
// 按照传入的 PipelineId 顺序排序
|
|
result = result.OrderBy(x => Array.IndexOf(PipelineId, x.PipelineId.ToString())).ToList();
|
|
}
|
|
|
|
// if (IsCheckPrint != null & IsCheckPrint == true)
|
|
// {
|
|
// result = result.Where(x => x.IsPrint == false || x.IsPrint == null).ToList();
|
|
// }
|
|
|
|
return result;
|
|
}
|
|
|
|
/// <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)
|
|
{
|
|
if (string.IsNullOrEmpty(pipeLineMatId))
|
|
{
|
|
return;
|
|
}
|
|
|
|
Model.SGGLDB db = Funs.DB;
|
|
var model_mat = db.HJGL_PipeLineMat.FirstOrDefault(x => x.PipeLineMatId == pipeLineMatId);
|
|
if (model_mat == null || string.IsNullOrEmpty(model_mat.PipelineId))
|
|
{
|
|
return;
|
|
}
|
|
|
|
var PipelineId = model_mat.PipelineId;
|
|
var pipelineModel = db.HJGL_Pipeline.FirstOrDefault(x => x.PipelineId == PipelineId);
|
|
if (pipelineModel == null)
|
|
{
|
|
return;
|
|
}
|
|
|
|
var PipeArea = pipelineModel.PipeArea;
|
|
if (PipeArea == PipelineService.PipeArea_SHOP && !string.IsNullOrEmpty(model_mat.PrefabricatedComponents))
|
|
{
|
|
var model = db.HJGL_Pipeline_Component.FirstOrDefault(x => x.PipelineComponentCode == model_mat.PrefabricatedComponents
|
|
&& x.PipelineId == PipelineId);
|
|
// 组件号可能来自导入数据,未包含分隔符时直接使用原值,避免截取时报错。
|
|
var drawingName = GetDrawingNameByComponentCode(model_mat.PrefabricatedComponents);
|
|
if (model == null)
|
|
{
|
|
model = new Model.HJGL_Pipeline_Component
|
|
{
|
|
PipelineComponentId = SQLHelper.GetNewID(),
|
|
IsPrint = false
|
|
};
|
|
db.HJGL_Pipeline_Component.InsertOnSubmit(model);
|
|
}
|
|
|
|
model.PipelineId = PipelineId;
|
|
model.PipelineComponentCode = model_mat.PrefabricatedComponents;
|
|
model.DrawingName = drawingName;
|
|
model.State = State0;
|
|
model.ProductionState = 0;
|
|
|
|
// 材料导入同步组件时,同时按焊口幂等维护组件关联,避免只生成组件主数据。
|
|
SyncPipelineComponentJoint(db, model, model_mat.WeldJointId);
|
|
db.SubmitChanges();
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 按焊口同步预制组件关联。
|
|
/// </summary>
|
|
private static void SyncPipelineComponentJoint(Model.SGGLDB db, Model.HJGL_Pipeline_Component pipelineComponent, string weldJointId)
|
|
{
|
|
if (pipelineComponent == null || string.IsNullOrEmpty(weldJointId))
|
|
{
|
|
return;
|
|
}
|
|
|
|
var weldJoint = db.HJGL_WeldJoint.FirstOrDefault(x => x.WeldJointId == weldJointId);
|
|
if (weldJoint == null)
|
|
{
|
|
return;
|
|
}
|
|
|
|
var componentJoint = db.HJGL_Pipeline_ComponentJoint.FirstOrDefault(x => x.WeldJointId == weldJointId);
|
|
if (componentJoint == null)
|
|
{
|
|
componentJoint = new Model.HJGL_Pipeline_ComponentJoint
|
|
{
|
|
Id = SQLHelper.GetNewID(),
|
|
WeldJointId = weldJoint.WeldJointId,
|
|
State = State0
|
|
};
|
|
db.HJGL_Pipeline_ComponentJoint.InsertOnSubmit(componentJoint);
|
|
}
|
|
|
|
// 已存在的关联保留生产状态,只刷新组件及焊口标识。
|
|
componentJoint.PipelineComponentId = pipelineComponent.PipelineComponentId;
|
|
componentJoint.PipelineComponentCode = pipelineComponent.PipelineComponentCode;
|
|
componentJoint.WeldJointCode = weldJoint.WeldJointCode;
|
|
}
|
|
|
|
private static string GetDrawingNameByComponentCode(string pipelineComponentCode)
|
|
{
|
|
if (string.IsNullOrEmpty(pipelineComponentCode))
|
|
{
|
|
return string.Empty;
|
|
}
|
|
|
|
int splitIndex = pipelineComponentCode.LastIndexOf('-');
|
|
string drawingName = splitIndex > 0 ? pipelineComponentCode.Substring(0, splitIndex) : pipelineComponentCode;
|
|
return drawingName.Replace("\"", "");
|
|
}
|
|
|
|
/// <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();
|
|
pipeline.IsPrint = false;
|
|
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;
|
|
newPipeline.DrawingName = pipeline.DrawingName;
|
|
newPipeline.ReceiveMan = pipeline.ReceiveMan;
|
|
newPipeline.ReceiveDate = pipeline.ReceiveDate;
|
|
newPipeline.ProductionState = pipeline.ProductionState;
|
|
newPipeline.IsPrint = pipeline.IsPrint;
|
|
newPipeline.Remark = pipeline.Remark;
|
|
db.HJGL_Pipeline_Component.InsertOnSubmit(newPipeline);
|
|
db.SubmitChanges();
|
|
}
|
|
|
|
/// <summary>
|
|
/// 修改管线预制组件基础信息,并同步材料及焊口关联中的组件编号。
|
|
/// </summary>
|
|
public static void UpdatePipelineComponentBasicInfo(Model.HJGL_Pipeline_Component pipeline)
|
|
{
|
|
if (pipeline == null || string.IsNullOrEmpty(pipeline.PipelineComponentId))
|
|
{
|
|
return;
|
|
}
|
|
|
|
Model.SGGLDB db = Funs.DB;
|
|
var current = db.HJGL_Pipeline_Component.FirstOrDefault(e => e.PipelineComponentId == pipeline.PipelineComponentId);
|
|
if (current == null)
|
|
{
|
|
return;
|
|
}
|
|
|
|
string oldPipelineComponentCode = current.PipelineComponentCode;
|
|
current.PipelineId = pipeline.PipelineId;
|
|
current.PreUnit = pipeline.PreUnit;
|
|
current.AssembleUnit = pipeline.AssembleUnit;
|
|
current.PipelineComponentCode = pipeline.PipelineComponentCode;
|
|
current.BoxNumber = pipeline.BoxNumber;
|
|
|
|
if (!string.Equals(oldPipelineComponentCode, pipeline.PipelineComponentCode, StringComparison.Ordinal))
|
|
{
|
|
// 组件编号是材料和组件焊口关联的逻辑键,编辑时必须同步更新。
|
|
if (!string.IsNullOrEmpty(oldPipelineComponentCode))
|
|
{
|
|
var pipelineMaterials = db.HJGL_PipeLineMat.Where(x => x.PipelineId == current.PipelineId
|
|
&& x.PrefabricatedComponents == oldPipelineComponentCode);
|
|
foreach (var pipelineMaterial in pipelineMaterials)
|
|
{
|
|
pipelineMaterial.PrefabricatedComponents = pipeline.PipelineComponentCode;
|
|
}
|
|
}
|
|
|
|
var componentJoints = db.HJGL_Pipeline_ComponentJoint.Where(x => x.PipelineComponentId == current.PipelineComponentId);
|
|
foreach (var componentJoint in componentJoints)
|
|
{
|
|
componentJoint.PipelineComponentCode = pipeline.PipelineComponentCode;
|
|
}
|
|
}
|
|
|
|
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;
|
|
newPipeline.DrawingName = pipeline.DrawingName;
|
|
newPipeline.ReceiveMan = pipeline.ReceiveMan;
|
|
newPipeline.ReceiveDate = pipeline.ReceiveDate;
|
|
newPipeline.ProductionState = pipeline.ProductionState;
|
|
newPipeline.IsPrint = pipeline.IsPrint;
|
|
newPipeline.Remark = pipeline.Remark;
|
|
db.SubmitChanges();
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// 修改组件出库状态
|
|
/// </summary>
|
|
/// <param name="pipelineComponentId"></param>
|
|
/// <param name="BoxNumber"></param>
|
|
public static void UpdateOutState(string pipelineComponentId, string BoxNumber)
|
|
{
|
|
var q = GetPipelineComponentById(pipelineComponentId);
|
|
if (q.State == State1)
|
|
{
|
|
q.State = State2;
|
|
q.BoxNumber = BoxNumber;
|
|
UpdatePipelineComponent(q);
|
|
|
|
}
|
|
|
|
}
|
|
/// <summary>
|
|
/// 修改组件打印状态
|
|
/// </summary>
|
|
/// <param name="PipelineComponentId"></param>
|
|
public static void UpdateIsPrint(string[] PipelineComponentId)
|
|
{
|
|
var componentsToUpdate = Funs.DB.HJGL_Pipeline_Component
|
|
|
|
.Where(c => PipelineComponentId.Contains(c.PipelineComponentId));
|
|
|
|
foreach (var component in componentsToUpdate)
|
|
{
|
|
component.IsPrint = true;
|
|
}
|
|
|
|
Funs.DB.SubmitChanges();
|
|
}
|
|
|
|
/// <summary>
|
|
/// 修改组件生产状态
|
|
/// </summary>
|
|
/// <param name="pipelineComponentId"></param>
|
|
/// <param name="BoxNumber"></param>
|
|
public static void UpdateProductionState(string pipelineComponentId, int state, DateTime TaskDate)
|
|
{
|
|
var q = GetPipelineComponentById(pipelineComponentId);
|
|
if (q != null)
|
|
{
|
|
q.ProductionState = state;
|
|
if (state == 2)
|
|
{
|
|
q.ActEndDate = TaskDate;
|
|
}
|
|
else if (state == 1)
|
|
{
|
|
if (q.ActStartDate == null)
|
|
{
|
|
q.ActStartDate = TaskDate;
|
|
}
|
|
else
|
|
{
|
|
if (DateTime.Compare(TaskDate, q.ActStartDate.Value) < 0)
|
|
{
|
|
q.ActStartDate = TaskDate;
|
|
}
|
|
}
|
|
}
|
|
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 components = db.HJGL_Pipeline_Component.Where(e => e.PipelineId == pipelineId).ToList();
|
|
if (components.Count > 0)
|
|
{
|
|
// 更新导入会重建管线组件,先清理旧组件焊口关联,避免遗留孤儿数据。
|
|
var componentIds = components.Select(x => x.PipelineComponentId).ToArray();
|
|
var componentJoints = db.HJGL_Pipeline_ComponentJoint.Where(x => componentIds.Contains(x.PipelineComponentId));
|
|
db.HJGL_Pipeline_ComponentJoint.DeleteAllOnSubmit(componentJoints);
|
|
db.HJGL_Pipeline_Component.DeleteAllOnSubmit(components);
|
|
db.SubmitChanges();
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 获取已经验收的预制组件
|
|
/// </summary>
|
|
/// <param name="projectId"></param>
|
|
/// <param name="pipelineCode"></param>
|
|
/// <param name="pipelineComponentCode"></param>
|
|
/// <returns></returns>
|
|
public static List<HJGL_Pipeline_Component> GetAcceptedPipelineComponent(string projectId, string pipelineCode,
|
|
string pipelineComponentCode, string flowingSection)
|
|
{
|
|
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
|
|
orderby y.PipelineCode,x.PipelineComponentCode
|
|
where y.ProjectId.Contains(projectId) && x.State.Equals(State1) &&
|
|
(string.IsNullOrEmpty(pipelineCode) || y.PipelineCode.Contains(pipelineCode)) &&
|
|
(string.IsNullOrEmpty(pipelineComponentCode) || x.PipelineComponentCode.Contains(pipelineComponentCode)) &&
|
|
(string.IsNullOrEmpty(flowingSection) || y.FlowingSection.Contains(flowingSection))
|
|
select x).ToList();
|
|
return q;
|
|
|
|
}
|
|
public static List<Model.HJGL_Pipeline_Component> GetComponentByPipelineId(string PipelineId)
|
|
{
|
|
|
|
Model.SGGLDB db = Funs.DB;
|
|
var q = (from x in db.HJGL_Pipeline_Component
|
|
where x.PipelineId == PipelineId
|
|
select x).OrderBy(x => x.PlanStartDate).ToList();
|
|
return q;
|
|
|
|
}
|
|
///// <summary>
|
|
///// 管线下拉框
|
|
///// </summary>
|
|
///// <param name="dropName">下拉框名字</param>
|
|
///// <param name="isShowPlease">是否显示请选择</param>
|
|
//public static void InitPipelineDownList(FineUIPro.DropDownList dropName,string projectid, string pipelineCode,
|
|
// string pipelineComponentCode, bool isShowPlease)
|
|
//{
|
|
// dropName.DataValueField = "PipelineComponentId";
|
|
// dropName.DataTextField = "PipelineComponentCode";
|
|
// dropName.DataSource = GetAcceptedPipelineComponent(projectid, pipelineCode, pipelineComponentCode);
|
|
// dropName.DataBind();
|
|
// if (isShowPlease)
|
|
// {
|
|
// Funs.FineUIPleaseSelect(dropName);
|
|
// }
|
|
//}
|
|
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);
|
|
}
|
|
}
|
|
public static void InitMainItemDownProductionStateList(FineUIPro.DropDownList dropName, bool isShowPlease)
|
|
{
|
|
dropName.DataValueField = "Value";
|
|
dropName.DataTextField = "Text";
|
|
dropName.DataSource = GetProductionState();
|
|
dropName.DataBind();
|
|
if (isShowPlease)
|
|
{
|
|
Funs.FineUIPleaseSelect(dropName);
|
|
}
|
|
}
|
|
}
|
|
|
|
}
|