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

943 lines
44 KiB
C#
Raw Normal View History

using Microsoft.Office.Interop.Word;
using MiniExcelLibs;
2022-10-25 22:30:17 +08:00
using Model;
2022-09-05 16:36:31 +08:00
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.IO;
using System.Linq;
using System.Web.UI.DataVisualization.Charting;
2022-09-05 16:36:31 +08:00
using System.Web.UI.WebControls;
2023-02-20 21:59:35 +08:00
using System.Windows.Media.Animation;
using static BLL.PipelineService;
2022-09-05 16:36:31 +08:00
namespace BLL
{
public static class PipelineService
{
/// <summary>
/// 工厂预制
/// </summary>
2023-11-22 17:10:54 +08:00
public const string PipeArea_SHOP = "1";
2022-09-05 16:36:31 +08:00
/// <summary>
2023-12-01 12:56:11 +08:00
/// 现场施工
2022-09-05 16:36:31 +08:00
/// </summary>
2023-11-22 17:10:54 +08:00
public const string PipeArea_FIELD = "2";
2023-02-16 17:19:08 +08:00
public const int pageSize = 20;
public static List<Model.HJGL_Pipeline> hJGL_Pipelines
{
2023-11-22 17:10:54 +08:00
get;
set;
}
/// <summary>
/// 实际日期类型
/// </summary>
2023-11-22 17:10:54 +08:00
public enum ActDateType
{
/// <summary>
/// 实际开始日期(预制)
/// </summary>
ActDateStart_Shop,
/// <summary>
/// 实际完成日期(预制)
/// </summary>
2023-11-22 17:10:54 +08:00
ActDateEnd_Shop,
/// <summary>
/// 实际开始日期(安装)
/// </summary>
2023-11-22 17:10:54 +08:00
ActDateStart_FIELD,
/// <summary>
/// 实际完成日期(安装)
/// </summary>
2023-11-22 17:10:54 +08:00
ActDateEnd_FIELD,
}
2023-02-20 10:49:51 +08:00
/// <summary>
/// 管线划分
/// </summary>
/// <returns></returns>
2022-09-05 16:36:31 +08:00
public static ListItem[] GetPipeArea()
{
ListItem[] list = new ListItem[2];
list[0] = new ListItem("工厂预制", PipeArea_SHOP);
2023-12-01 12:56:11 +08:00
list[1] = new ListItem("现场施工", PipeArea_FIELD);
2022-09-05 16:36:31 +08:00
return list;
}
2023-11-22 17:10:54 +08:00
public static void RestPipelineAndJoints(string projectid)
2022-11-23 15:38:28 +08:00
{
PipelineService.hJGL_Pipelines = PipelineService.GetPipelinesByProjectId(projectid);
WeldJointService.hJGL_WeldJoints = WeldJointService.GetWeldJointByProjectid(projectid);
}
2022-09-05 16:36:31 +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);
}
2023-02-20 10:49:51 +08:00
/// <summary>
/// 根据管线id获取管线状态
/// </summary>
/// <param name="pipelineId"></param>
public static void GetStateByPipelineId(string pipelineId)
2022-11-23 15:38:28 +08:00
{
var mdoel = GetPipelineByPipelineId(pipelineId);
var PlanStartDate = mdoel.PlanStartDate;
var PlanEndDate = mdoel.PlanEndDate;
var ActStartDate = new DateTime?();
var ActEndDate = new DateTime?();
2023-11-22 17:10:54 +08:00
if (!string.IsNullOrEmpty(GetDateByPipelineId(pipelineId, ActDateType.ActDateStart_FIELD)))
{
ActStartDate = Convert.ToDateTime(GetDateByPipelineId(pipelineId, ActDateType.ActDateStart_FIELD));
}
if (!string.IsNullOrEmpty(GetDateByPipelineId(pipelineId, ActDateType.ActDateEnd_FIELD)))
{
ActEndDate = Convert.ToDateTime(GetDateByPipelineId(pipelineId, ActDateType.ActDateEnd_FIELD));
}
2023-11-22 17:10:54 +08:00
if (PlanStartDate == null || PlanEndDate == null)
2023-02-20 10:49:51 +08:00
{
mdoel.State = 0;
UpdatePipeline(mdoel);
return;
}
2023-11-22 17:10:54 +08:00
if (ActStartDate == null && DateTime.Compare(DateTime.Now, PlanStartDate.Value) < 0)
{
mdoel.State = 0;
}
2023-11-22 17:10:54 +08:00
else if (ActStartDate == null && DateTime.Compare(DateTime.Now, PlanStartDate.Value) > 0)
{
mdoel.State = 1;
}
2023-11-22 17:10:54 +08:00
else if (ActStartDate != null && DateTime.Compare(ActStartDate.Value, PlanStartDate.Value) < 0 && ActEndDate == null)
{
mdoel.State = 2;
}
else if (ActStartDate != null && DateTime.Compare(ActStartDate.Value, PlanStartDate.Value) > 0 && ActEndDate == null)
{
mdoel.State = 3;
}
else if (ActEndDate != null)
{
mdoel.State = 4;
}
UpdatePipeline(mdoel);
}
2023-02-20 10:49:51 +08:00
/// <summary>
/// 根据管线id获取实际开始实际完成日期
/// </summary>
/// <param name="pipelineId"></param>
/// <param name="actDateType"></param>
/// <returns></returns>
public static string GetDateByPipelineId(object pipelineId, ActDateType actDateType)
{
2023-11-22 17:10:54 +08:00
string result = "";
string _pipelineId = pipelineId.ToString();
string ActDateStart_Shop = "";
string ActDateEnd_Shop = "";
string ActDateStart_FIELD = "";
string ActDateEnd_FIELD = "";
var pipemodel = GetPipelineByPipelineId(_pipelineId);
var joints = BLL.WeldJointService.GetWeldJointsByPipelineId(_pipelineId);
int joint_Shop_count = joints.Where(x => x.JointAttribute == "预制口").Count();
int joint_Field_count = joints.Where(x => x.JointAttribute == "安装口").Count();
2023-11-22 17:10:54 +08:00
var TaskJoints = (from x in Funs.DB.View_HJGL_WeldingTask
where x.ProjectId == pipemodel.ProjectId && x.PipelineCode == pipemodel.PipelineCode && x.WeldingDailyId != null
select x).ToList();
var TaskJoints_Shop = TaskJoints.Where(x => x.JointAttribute == "预制口").ToList();
2023-11-22 17:10:54 +08:00
var TaskJoints_Field = TaskJoints.Where(x => x.JointAttribute == "安装口").ToList();
if (TaskJoints_Shop.Count > 0)
{
ActDateStart_Shop = TaskJoints_Shop.OrderBy(x => x.TaskDate).First().TaskDate.Value.ToShortDateString();
}
2023-11-22 17:10:54 +08:00
if (joint_Shop_count == TaskJoints_Shop.Count && joint_Shop_count > 0)
{
ActDateEnd_Shop = TaskJoints_Shop.OrderByDescending(x => x.TaskDate).First().TaskDate.Value.Date.ToShortDateString();
}
if (TaskJoints_Field.Count > 0)
{
ActDateStart_FIELD = TaskJoints_Field.OrderBy(x => x.TaskDate).First().TaskDate.Value.Date.ToShortDateString();
}
if (joint_Field_count == TaskJoints_Field.Count && joint_Field_count > 0)
{
ActDateEnd_FIELD = TaskJoints_Field.OrderByDescending(x => x.TaskDate).First().TaskDate.Value.Date.ToShortDateString();
}
switch (actDateType)
{
case ActDateType.ActDateStart_Shop:
result = ActDateStart_Shop;
break;
case ActDateType.ActDateEnd_Shop:
result = ActDateEnd_Shop;
break;
case ActDateType.ActDateStart_FIELD:
result = ActDateStart_FIELD;
break;
case ActDateType.ActDateEnd_FIELD:
result = ActDateEnd_FIELD;
break;
}
return result;
}
2023-02-20 10:49:51 +08:00
/// <summary>
/// 根据焊口更改管线和组件(预制)的实际开始日期和完成日期
/// </summary>
/// <param name="WeldJointId"></param>
public static void UpdataDateByWeldJointId(string WeldJointId)
{
2023-11-22 17:10:54 +08:00
DateTime? ActDateStart_FIELD = new DateTime();
DateTime? ActDateEnd_FIELD = new DateTime();
2023-02-20 10:49:51 +08:00
string JointAttribute = "";
2023-11-22 17:10:54 +08:00
var model_joint = BLL.WeldJointService.GetWeldJointByWeldJointId(WeldJointId);
if (model_joint != null)
2023-02-20 10:49:51 +08:00
{
JointAttribute = model_joint.JointAttribute;
var model_pipeline = GetPipelineByPipelineId(model_joint.PipelineId);
var joints = BLL.WeldJointService.GetWeldJointsByPipelineId(model_joint.PipelineId);
var TaskJoints = (from x in Funs.DB.View_HJGL_WeldingTask
where x.ProjectId == model_pipeline.ProjectId && x.PipelineCode == model_pipeline.PipelineCode && x.WeldingDailyId != null
select x).ToList();
switch (JointAttribute)
{
2023-11-22 17:10:54 +08:00
2023-02-20 10:49:51 +08:00
case "安装口":
int joint_Field_count = joints.Where(x => x.JointAttribute == "安装口").Count();
var TaskJoints_Field = TaskJoints.Where(x => x.JointAttribute == "安装口").ToList();
if (TaskJoints_Field.Count > 0)
{
2023-09-12 16:54:08 +08:00
model_pipeline.ActStartDate = TaskJoints_Field.OrderBy(x => x.TaskDate).First().TaskDate;
2023-02-20 10:49:51 +08:00
}
if (joint_Field_count == TaskJoints_Field.Count && joint_Field_count > 0)
{
2023-02-20 21:59:35 +08:00
model_pipeline.IsFinished = true;
2023-09-12 16:54:08 +08:00
model_pipeline.ActEndDate = TaskJoints_Field.OrderByDescending(x => x.TaskDate).First().TaskDate;
2023-02-20 10:49:51 +08:00
}
2023-09-12 16:54:08 +08:00
//model_pipeline.ActStartDate = ActDateStart_FIELD;
//model_pipeline.ActEndDate = ActDateEnd_FIELD;
2023-02-20 10:49:51 +08:00
UpdatePipeline(model_pipeline);
break;
}
2023-11-22 17:10:54 +08:00
}
2023-02-20 10:49:51 +08:00
}
/// <summary>
/// 根据管线code获取管线信息
/// </summary>
/// <param name="pipelineCode"></param>
/// <returns></returns>
2022-09-05 16:36:31 +08:00
public static Model.HJGL_Pipeline GetPipelineByPipelineCode(string pipelineCode)
{
return Funs.DB.HJGL_Pipeline.FirstOrDefault(e => e.PipelineCode == pipelineCode);
}
2023-02-20 10:49:51 +08:00
/// <summary>
/// 根据管线信息筛选管线
/// </summary>
/// <param name="model"></param>
/// <returns></returns>
2023-02-20 21:59:35 +08:00
public static List<HJGL_Pipeline> GetHJGL_PipelineList(HJGL_Pipeline model)
2022-10-25 22:30:17 +08:00
{
var db = Funs.DB;
2023-11-22 17:10:54 +08:00
var pipelineList = (from x in Funs.DB.HJGL_Pipeline
where
2022-10-25 22:30:17 +08:00
(string.IsNullOrEmpty(model.ProjectId) || x.ProjectId.Contains(model.ProjectId))
&& (string.IsNullOrEmpty(model.UnitWorkId) || x.UnitWorkId.Contains(model.UnitWorkId))
&& (string.IsNullOrEmpty(model.PipelineCode) || x.PipelineCode.Contains(model.PipelineCode))
&& (string.IsNullOrEmpty(model.SingleName) || x.SingleName.Contains(model.SingleName))
&& (string.IsNullOrEmpty(model.DesignPress) || x.DesignPress.Contains(model.DesignPress))
/* && (string.IsNullOrEmpty(model.MaterialCode) || x.MaterialCode.Contains(model.MaterialCode))*/
select x).ToList();
2023-11-22 17:10:54 +08:00
if (model.IsFinished != null)
2022-10-25 22:30:17 +08:00
{
2023-11-22 17:10:54 +08:00
if (model.IsFinished == true)
2022-10-25 22:30:17 +08:00
{
2023-11-22 17:10:54 +08:00
pipelineList = pipelineList.Where(x => x.IsFinished == true).ToList();
2022-10-25 22:30:17 +08:00
}
else
{
2023-11-22 17:10:54 +08:00
pipelineList = pipelineList.Where(x => x.IsFinished == false || x.IsFinished == null).ToList();
2022-10-25 22:30:17 +08:00
}
}
return pipelineList;
}
2023-02-20 21:59:35 +08:00
public static List<View_HJGL_Pipeline> GetView_HJGL_Pipelines(View_HJGL_Pipeline model)
{
var db = Funs.DB;
var pipelineList = (from x in Funs.DB.View_HJGL_Pipeline
where
(string.IsNullOrEmpty(model.ProjectId) || x.ProjectId.Contains(model.ProjectId))
&& (string.IsNullOrEmpty(model.UnitWorkId) || x.UnitWorkId.Contains(model.UnitWorkId))
&& (string.IsNullOrEmpty(model.PipelineCode) || x.PipelineCode.Contains(model.PipelineCode))
&& (string.IsNullOrEmpty(model.SingleName) || x.SingleName.Contains(model.SingleName))
&& (string.IsNullOrEmpty(model.DesignPress) || x.DesignPress.Contains(model.DesignPress))
/* && (string.IsNullOrEmpty(model.MaterialCode) || x.MaterialCode.Contains(model.MaterialCode))*/
select x).ToList();
if (model.IsFinished != null)
{
if (model.IsFinished == true)
{
pipelineList = pipelineList.Where(x => x.IsFinished == true).ToList();
}
else
{
pipelineList = pipelineList.Where(x => x.IsFinished == false || x.IsFinished == null).ToList();
}
}
return pipelineList;
}
2022-09-05 16:36:31 +08:00
/// <summary>
/// 根据unitworkId获取所有管线
/// </summary>
/// <param name="unitworkId"></param>
/// <returns></returns>
public static List<Model.HJGL_Pipeline> GetPipelinesByUnitWordId(string unitworkId)
{
var q = Funs.DB.HJGL_Pipeline.Where(e => e.UnitWorkId == unitworkId).ToList();
return q;
}
/// <summary>
/// 根据项目获取所有管线
/// </summary>
/// <param name="ProjectId"></param>
/// <returns></returns>
public static List<Model.HJGL_Pipeline> GetPipelinesByProjectId(string ProjectId)
{
var q = Funs.DB.HJGL_Pipeline.Where(e => e.ProjectId == ProjectId).ToList();
return q;
}
/// <summary>
2022-09-05 16:36:31 +08:00
/// 根据管线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>
2023-02-20 10:49:51 +08:00
/// 根据主项id获取未完成管线
/// </summary>
/// <param name="unitworkId"></param>
/// <returns></returns>
2023-11-22 17:10:54 +08:00
public static List<string> GetNoComPipelinesByUnitWordId(string unitworkId)
2023-02-20 10:49:51 +08:00
{
var q = (from x in Funs.DB.View_HJGL_WeldJoint
2023-11-22 17:10:54 +08:00
where x.UnitWorkId == unitworkId
select new
{
PipelineId = x.PipelineId,
WeldingDate = x.WeldingDate,
PipelineCode = x.PipelineCode
2023-02-20 10:49:51 +08:00
}).Distinct();
2023-11-22 17:10:54 +08:00
if (q.Count() == 0)
2023-02-20 10:49:51 +08:00
{
return new List<string>();
}
var noCompipeline = from x in q
group x by x.PipelineId into g
select new
{
PipelineId = g.Key,
Count = (from x2 in g where x2.WeldingDate != null && x2.WeldingDate != "" select x2).Count(),
};
var NowComPipelineCode = (from x in q
2023-11-22 17:10:54 +08:00
join y in noCompipeline on x.PipelineId equals y.PipelineId
where y.Count == 0
select x.PipelineCode
).Distinct().ToList();
2023-02-20 10:49:51 +08:00
return NowComPipelineCode;
}
/// <summary>
2022-09-05 16:36:31 +08:00
/// 下载预制口管线导入模板
/// </summary>
/// <param name="projectid"></param>
/// <param name="unitworkid"></param>
2023-11-22 17:10:54 +08:00
public static void DownPipeArea_SHOPFile(string projectid, string unitworkid)
2022-09-05 16:36:31 +08:00
{
string templatePath = Funs.RootPath + @"File\Excel\DataOut\WeldingPlanDataOut_SHOP.xlsx";
string path = Funs.RootPath + @"File\Excel\DataOut\WeldingPlanDataOut_SHOP.xlsx";
path = path.Replace(".xlsx", string.Format("{0:yyyy-MM-dd-HH-mm}", DateTime.Now) + ".xlsx");
string strSql = @"select line.PipelineId+'&'+com.PipelineComponentId as ID
,line.PipelineId
,line.PipelineCode
,line.ProjectId
,line.UnitWorkId
,line.UnitId
,line.SingleNumber
,line.PipingClassId
,line.MediumId
,line.DetectionRateId
,line.DetectionType
,line.TestPressure
,line.TestMedium
,line.Remark
,line.PressurePipingClassId
,line.PipeLenth
,line.DesignPress
,line.DesignTemperature
,line.PCtype
,line.LeakPressure
,line.LeakMedium
,line.VacuumPressure
,line.PCMedium
,line.MaterialId
,line.SingleName
,line.PipeArea
,line.WBSId
,line.PlanStartDate
,line.PlanEndDate
,line.ActStartDate
,line.ActEndDate
,line.IsFinished
,line.FlowingSection
2022-09-05 16:36:31 +08:00
,com.PipelineComponentId
,com.PreUnit
,com.PipelineComponentCode
,com.BoxNumber
,com.AssembleUnit
,com.PipeLineMatId
,com.QRCode
,com.State
,com.PlanStartDate as PlanStartDate_SHOP
,com.PlanEndDate as PlanEndDate_SHOP
,com.ActStartDate as ActStartDate_SHOP
,com.ActEndDate as ActEndDate_SHOP
,unit.UnitWorkName
from HJGL_Pipeline line
left join HJGL_Pipeline_Component com on line.PipelineId=com.PipelineId
left join WBS_UnitWork unit on line.UnitWorkId=unit.UnitWorkId
WHERE line.ProjectId= @ProjectId and line.PipeArea='1' ";
List<SqlParameter> listStr = new List<SqlParameter>();
listStr.Add(new SqlParameter("@ProjectId", projectid));
if (!string.IsNullOrEmpty(unitworkid) && unitworkid != "2")
{
strSql += " AND line.UnitWorkId =@UnitWorkId";
listStr.Add(new SqlParameter("@UnitWorkId", unitworkid));
}
SqlParameter[] parameter = listStr.ToArray();
System.Data.DataTable tb = SQLHelper.GetDataTableRunText(strSql, parameter);
2022-09-05 16:36:31 +08:00
tb.TableName = "Data";
var value = new Dictionary<string, object>()
{
["Data"] = tb,
};
MiniExcel.SaveAsByTemplate(path, templatePath, value);
2023-11-22 17:10:54 +08:00
HJGL_DataImportService.DownFile(path.Replace(Funs.RootPath, ""), "焊接施工计划(预制).xlsx");
2022-09-05 16:36:31 +08:00
File.Delete(path);
}
/// <summary>
/// 下载安装口管线导入模板
/// </summary>
/// <param name="projectid"></param>
/// <param name="unitworkid"></param>
public static void DownPipeArea_FIELDFile(string projectid, string unitworkid)
2023-11-22 17:10:54 +08:00
{
2022-09-05 16:36:31 +08:00
string templatePath = Funs.RootPath + @"File\Excel\DataOut\WeldingPlanDataOut2.xlsx";
string path = Funs.RootPath + @"File\Excel\DataOut\WeldingPlanDataOut2.xlsx";
path = path.Replace(".xlsx", string.Format("{0:yyyy-MM-dd-HH-mm}", DateTime.Now) + ".xlsx");
string strSql = @"select line.PipelineId as ID
,line.PipelineId
2023-12-06 15:22:27 +08:00
,(select ISNULL(SUM(ISNULL(jot.Size,0)),0) FROM dbo.HJGL_WeldJoint jot WHERE jot.PipelineId=line.PipelineId) as TotalSize
,(case when line.PipeArea='1' then (select ISNULL(SUM(ISNULL(jot.Size,0)),0) FROM dbo.HJGL_WeldJoint jot WHERE jot.PipelineId=line.PipelineId and jot.JointAttribute='')
else (select ISNULL(SUM(ISNULL(jot.Size,0)),0) FROM dbo.HJGL_WeldJoint jot WHERE jot.PipelineId=line.PipelineId) end) as TotalYZSize
2022-09-05 16:36:31 +08:00
,line.PipelineCode
,line.ProjectId
2023-12-06 15:22:27 +08:00
,mat.MaterialCode
2022-09-05 16:36:31 +08:00
,line.UnitWorkId
,line.UnitId
,line.SingleNumber
,line.PipingClassId
,line.MediumId
,line.DetectionRateId
,line.DetectionType
,line.TestPressure
,line.TestMedium
,line.Remark
,line.PressurePipingClassId
,line.PipeLenth
,line.DesignPress
,line.DesignTemperature
,line.PCtype
,line.LeakPressure
,line.LeakMedium
,line.VacuumPressure
,line.PCMedium
,line.MaterialId
,line.SingleName
,line.PipeArea
,line.WBSId
,line.PlanStartDate
,line.PlanEndDate
,line.ActStartDate
,line.ActEndDate
,line.IsFinished
,line.FlowingSection
2022-09-05 16:36:31 +08:00
,unit.UnitWorkName
from HJGL_Pipeline line
left join WBS_UnitWork unit on line.UnitWorkId=unit.UnitWorkId
2023-12-06 15:22:27 +08:00
LEFT JOIN dbo.Base_Material AS mat ON mat.MaterialId=line.MaterialId
2022-09-05 16:36:31 +08:00
WHERE line.ProjectId= @ProjectId ";
List<SqlParameter> listStr = new List<SqlParameter>();
listStr.Add(new SqlParameter("@ProjectId", projectid));
if (!string.IsNullOrEmpty(unitworkid) && unitworkid != "2")
{
strSql += " AND line.UnitWorkId =@UnitWorkId";
listStr.Add(new SqlParameter("@UnitWorkId", unitworkid));
}
SqlParameter[] parameter = listStr.ToArray();
System.Data.DataTable tb = SQLHelper.GetDataTableRunText(strSql, parameter);
2022-09-05 16:36:31 +08:00
tb.TableName = "Data";
var value = new Dictionary<string, object>()
{
["Data"] = tb,
};
MiniExcel.SaveAsByTemplate(path, templatePath, value);
HJGL_DataImportService.DownFile(path.Replace(Funs.RootPath, ""), "焊接施工计划(安装).xlsx");
File.Delete(path);
}
/// <summary>
2023-02-20 10:49:51 +08:00
/// 根据管线code查询管线是否存在
2022-09-05 16:36:31 +08:00
/// </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;
}
}
2023-02-20 10:49:51 +08:00
/// <summary>
/// 根据管线code获取管线信息
/// </summary>
/// <param name="pipelineCode">管线号</param>
/// <param name="unitWorkId">主项id</param>
/// <returns></returns>
public static HJGL_Pipeline GetPipelineByCode(string pipelineCode, string unitWorkId)
{
Model.SGGLDB db = Funs.DB;
Model.HJGL_Pipeline q = null;
q = Funs.DB.HJGL_Pipeline.FirstOrDefault(x => x.PipelineCode == pipelineCode && x.UnitWorkId == unitWorkId);
return q;
}
2023-11-22 17:10:54 +08:00
/// <summary>
/// 添加管线信息
/// </summary>
/// <param name="pipeline"></param>
2022-09-05 16:36:31 +08:00
public static void AddPipeline(Model.HJGL_Pipeline pipeline)
{
2024-08-22 10:54:56 +08:00
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
{
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.SingleName = pipeline.SingleName;
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;
newPipeline.MaterialId = pipeline.MaterialId;
newPipeline.State = pipeline.State;
newPipeline.FlowingSection = pipeline.FlowingSection;
db.HJGL_Pipeline.InsertOnSubmit(newPipeline);
db.SubmitChanges();
}
2022-09-05 16:36:31 +08:00
}
/// <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.SingleName = pipeline.SingleName;
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;
newPipeline.MaterialId = pipeline.MaterialId;
newPipeline.IsFinished = pipeline.IsFinished;
newPipeline.PlanStartDate = pipeline.PlanStartDate;
newPipeline.PlanEndDate = pipeline.PlanEndDate;
newPipeline.ActStartDate = pipeline.ActStartDate;
newPipeline.ActEndDate = pipeline.ActEndDate;
newPipeline.WBSId = pipeline.WBSId;
newPipeline.State = pipeline.State;
newPipeline.FlowingSection = pipeline.FlowingSection;
2022-09-05 16:36:31 +08:00
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();
}
}
}
2023-02-20 10:49:51 +08:00
/// <summary>
/// 修改管线划分
/// </summary>
/// <param name="pipelineId"></param>
/// <param name="pipelineArea"></param>
2022-09-05 16:36:31 +08:00
public static void UpdatePipelineArea(string pipelineId, string pipelineArea)
{
Model.SGGLDB db = Funs.DB;
Model.HJGL_Pipeline newPipeline = db.HJGL_Pipeline.FirstOrDefault(e => e.PipelineId == pipelineId);
if (newPipeline != null)
{
newPipeline.PipeArea = pipelineArea;
db.SubmitChanges();
}
}
/// <summary>
/// 更新管线是否完成
/// </summary>
/// <param name="pipelineId"></param>
/// <param name="finishDate"></param>
/// <param name="isFinish"></param>
public static void UpdatePipelinePlan(string pipelineId, string wbsId, DateTime? planStartDate, DateTime? planEndDate, DateTime? actStartDate, DateTime? actEndDate, bool? isFinish)
{
Model.SGGLDB db = Funs.DB;
Model.HJGL_Pipeline newPipeline = db.HJGL_Pipeline.FirstOrDefault(e => e.PipelineId == pipelineId);
if (newPipeline != null)
{
newPipeline.IsFinished = isFinish;
newPipeline.PlanStartDate = planStartDate;
newPipeline.PlanEndDate = planEndDate;
newPipeline.ActStartDate = actStartDate;
newPipeline.ActEndDate = actEndDate;
newPipeline.WBSId = wbsId;
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();
}
}
/// <summary>
/// 根据unitworkId删除一个作业管线信息
/// </summary>
/// <param name="pipelineId"></param>
public static void DeletePipelineByUnitworkId(string unitworkId)
{
Model.SGGLDB db = Funs.DB;
var pipeline = db.HJGL_Pipeline.Where(e => e.UnitWorkId == unitworkId);
if (pipeline != null)
{
//db.HJGL_Pipeline.DeleteAllOnSubmit(jot);
db.HJGL_Pipeline.DeleteAllOnSubmit(pipeline);
db.SubmitChanges();
}
}
/// <summary>
/// 获取管线名称项
/// </summary>
/// <param name="projectId">项目Id</param>
/// <returns></returns>
public static ListItem[] GetPipelineList(string unitWorkId)
{
List<Model.HJGL_Pipeline> q = (from x in Funs.DB.HJGL_Pipeline where x.UnitWorkId == unitWorkId orderby x.PipelineCode select x).ToList();
ListItem[] item = new ListItem[q.Count()];
for (int i = 0; i < q.Count(); i++)
{
item[i] = new ListItem(q[i].PipelineCode, q[i].PipelineId.ToString());
}
return item;
}
/// <summary>
/// 管线下拉框
/// </summary>
/// <param name="dropName">下拉框名字</param>
/// <param name="isShowPlease">是否显示请选择</param>
public static void InitPipelineDownList(FineUIPro.DropDownList dropName, string unitWorkId, bool isShowPlease)
{
dropName.DataValueField = "Value";
dropName.DataTextField = "Text";
dropName.DataSource = GetPipelineList(unitWorkId);
dropName.DataBind();
if (isShowPlease)
{
Funs.FineUIPleaseSelect(dropName);
}
}
2023-02-16 17:19:08 +08:00
2023-11-22 17:10:54 +08:00
public static void BindTreeNodes(FineUIPro.TreeNode node, string pipecode, string ProjectId, int pageSize)
2023-02-16 17:19:08 +08:00
{
var pipeline = (from x in Funs.DB.HJGL_Pipeline
where x.ProjectId == ProjectId && x.UnitWorkId == node.NodeID
&& x.PipelineCode.Contains(pipecode)
orderby x.PipelineCode
select x).ToList();
var hJGL_WeldJoints = (from x in Funs.DB.HJGL_WeldJoint where x.ProjectId == ProjectId select x).ToList();
int pageindex = int.Parse(node.CommandName.Split('|')[0]);
int pageCount = int.Parse(node.CommandName.Split('|')[1]);
if (pageindex <= pageCount)
{
pipeline = pipeline.Skip(pageSize * (pageindex - 1)).Take(pageSize).ToList();
foreach (var item in pipeline)
{
var jotCount = (from x in hJGL_WeldJoints where x.PipelineId == item.PipelineId /*&& x.IsTwoJoint == null*/ select x).Count();
FineUIPro.TreeNode newNode = new FineUIPro.TreeNode();
newNode.Text = item.PipelineCode + "【" + jotCount.ToString() + " " + "焊口" + "】";
newNode.NodeID = item.PipelineId;
newNode.CommandName = "管线";
newNode.EnableClickEvent = true;
node.Nodes.Add(newNode);
}
if (pageindex < pageCount)
{
FineUIPro.TreeNode newNode = new FineUIPro.TreeNode();
newNode.Text = "加载";
newNode.NodeID = SQLHelper.GetNewID();
newNode.CommandName = "加载";
newNode.Icon = FineUIPro.Icon.ArrowDown;
newNode.EnableClickEvent = true;
node.Nodes.Add(newNode);
}
}
}
2023-02-20 21:59:35 +08:00
/// <summary>
/// 根据组件材料编码查询管线
/// </summary>
/// <param name="node"></param>
/// <param name="pipecode"></param>
/// <param name="MaterialCode"></param>
/// <param name="ProjectId"></param>
/// <param name="pageSize"></param>
2023-11-22 17:10:54 +08:00
public static void BindTreeNodes(FineUIPro.TreeNode node, string pipecode, string MaterialCode, string ProjectId, int pageSize)
2023-02-20 21:59:35 +08:00
{
//var pipeline = (from x in Funs.DB.HJGL_Pipeline
// where x.ProjectId == ProjectId && x.UnitWorkId == node.NodeID
// && x.PipelineCode.Contains(pipecode)
// orderby x.PipelineCode
// select x).ToList();
var pipeline = (from x in Funs.DB.HJGL_Pipeline
2023-11-22 17:10:54 +08:00
join y in Funs.DB.HJGL_PipeLineMat.Where(m => m.MaterialCode.Contains(MaterialCode)) on x.PipelineId equals y.PipelineId
where x.ProjectId == ProjectId && x.UnitWorkId == node.NodeID && x.PipelineCode.Contains(pipecode)
2023-02-20 21:59:35 +08:00
select x).Distinct().ToList();
var hJGL_WeldJoints = (from x in Funs.DB.HJGL_WeldJoint where x.ProjectId == ProjectId select x).ToList();
int pageindex = int.Parse(node.CommandName.Split('|')[0]);
int pageCount = int.Parse(node.CommandName.Split('|')[1]);
if (pageindex <= pageCount)
{
pipeline = pipeline.Skip(pageSize * (pageindex - 1)).Take(pageSize).ToList();
foreach (var item in pipeline)
{
var jotCount = (from x in hJGL_WeldJoints where x.PipelineId == item.PipelineId /*&& x.IsTwoJoint == null*/ select x).Count();
FineUIPro.TreeNode newNode = new FineUIPro.TreeNode();
newNode.Text = item.PipelineCode + "【" + jotCount.ToString() + " " + "焊口" + "】";
newNode.NodeID = item.PipelineId;
newNode.CommandName = "管线";
newNode.EnableClickEvent = true;
node.Nodes.Add(newNode);
}
if (pageindex < pageCount)
{
FineUIPro.TreeNode newNode = new FineUIPro.TreeNode();
newNode.Text = "加载";
newNode.NodeID = SQLHelper.GetNewID();
newNode.CommandName = "加载";
newNode.Icon = FineUIPro.Icon.ArrowDown;
newNode.EnableClickEvent = true;
node.Nodes.Add(newNode);
}
}
}
2023-11-22 17:10:54 +08:00
public static void BindTreeNodes(FineUIPro.TreeNode node, bool isExitWPQId, string pipecode, string ProjectId, int pageSize, string pipeArea)
2023-02-20 21:59:35 +08:00
{
2023-11-22 17:10:54 +08:00
string pipeAreasql = string.Empty;
if (pipeArea != BLL.Const._Null)
{
pipeAreasql += " AND PipeArea='" + pipeArea + "'";
}
2023-02-20 21:59:35 +08:00
if (isExitWPQId)
{
2023-11-28 18:53:48 +08:00
string strSql = "SELECT distinct PipelineId, PipelineCode FROM View_HJGL_WeldJoint WHERE IsTwoJoint IS NULL AND UnitWorkId =@UnitWorkId AND WPQId IS NULL" + pipeAreasql;
2023-02-20 21:59:35 +08:00
List<SqlParameter> listStr = new List<SqlParameter>();
listStr.Add(new SqlParameter("@UnitWorkId", node.NodeID));
2023-11-22 17:10:54 +08:00
if (!string.IsNullOrEmpty(pipecode))
2023-02-20 21:59:35 +08:00
{
strSql += " and PipelineCode=@PipelineCode ";
2023-11-22 17:10:54 +08:00
listStr.Add(new SqlParameter("@PipelineCode", "" + pipecode + ""));
2023-02-20 21:59:35 +08:00
}
2023-11-28 18:53:48 +08:00
strSql += " order by PipelineCode";
2023-02-20 21:59:35 +08:00
SqlParameter[] parameter = listStr.ToArray();
System.Data.DataTable dt = SQLHelper.GetDataTableRunText(strSql, parameter);
var pipeline = Funs.TableToEntity<Model.PipeLineIdCodeItem>(dt);
2023-11-22 17:10:54 +08:00
2023-02-20 21:59:35 +08:00
var hJGL_WeldJoints = (from x in Funs.DB.HJGL_WeldJoint where x.ProjectId == ProjectId select x).ToList();
int pageindex = int.Parse(node.CommandName.Split('|')[0]);
int pageCount = int.Parse(node.CommandName.Split('|')[1]);
2023-02-16 17:19:08 +08:00
2023-02-20 21:59:35 +08:00
if (pageindex <= pageCount)
{
pipeline = pipeline.Skip(pageSize * (pageindex - 1)).Take(pageSize).ToList();
foreach (var item in pipeline)
{
var jotCount = (from x in hJGL_WeldJoints where x.PipelineId == item.PipelineId /*&& x.IsTwoJoint == null*/ select x).Count();
FineUIPro.TreeNode newNode = new FineUIPro.TreeNode();
newNode.Text = item.PipelineCode + "【" + jotCount.ToString() + " " + "焊口" + "】";
newNode.NodeID = item.PipelineId;
newNode.CommandName = "管线";
newNode.EnableClickEvent = true;
node.Nodes.Add(newNode);
}
if (pageindex < pageCount)
{
FineUIPro.TreeNode newNode = new FineUIPro.TreeNode();
newNode.Text = "加载";
newNode.NodeID = SQLHelper.GetNewID();
newNode.CommandName = "加载";
newNode.Icon = FineUIPro.Icon.ArrowDown;
newNode.EnableClickEvent = true;
node.Nodes.Add(newNode);
}
}
}
else
{
var pipeline = (from x in Funs.DB.HJGL_Pipeline
where x.ProjectId == ProjectId && x.UnitWorkId == node.NodeID
&& x.PipelineCode.Contains(pipecode)
orderby x.PipelineCode
select x).ToList();
2023-11-22 17:10:54 +08:00
if (pipeArea != BLL.Const._Null)
{
pipeline = pipeline.Where(x => x.PipeArea == pipeArea).ToList();
}
2023-02-20 21:59:35 +08:00
var hJGL_WeldJoints = (from x in Funs.DB.HJGL_WeldJoint where x.ProjectId == ProjectId select x).ToList();
int pageindex = int.Parse(node.CommandName.Split('|')[0]);
int pageCount = int.Parse(node.CommandName.Split('|')[1]);
if (pageindex <= pageCount)
{
pipeline = pipeline.Skip(pageSize * (pageindex - 1)).Take(pageSize).ToList();
foreach (var item in pipeline)
{
var jotCount = (from x in hJGL_WeldJoints where x.PipelineId == item.PipelineId /*&& x.IsTwoJoint == null*/ select x).Count();
FineUIPro.TreeNode newNode = new FineUIPro.TreeNode();
newNode.Text = item.PipelineCode + "【" + jotCount.ToString() + " " + "焊口" + "】";
newNode.NodeID = item.PipelineId;
newNode.CommandName = "管线";
newNode.EnableClickEvent = true;
node.Nodes.Add(newNode);
}
if (pageindex < pageCount)
{
FineUIPro.TreeNode newNode = new FineUIPro.TreeNode();
newNode.Text = "加载";
newNode.NodeID = SQLHelper.GetNewID();
newNode.CommandName = "加载";
newNode.Icon = FineUIPro.Icon.ArrowDown;
newNode.EnableClickEvent = true;
node.Nodes.Add(newNode);
}
}
}
}
2022-09-05 16:36:31 +08:00
}
}