using System; using System.Collections.Generic; using System.Linq; namespace BLL { public static class WeldJointService { public static List hJGL_WeldJoints { get; set; } /// /// 根据焊口Id获取焊口信息 /// /// /// public static Model.HJGL_WeldJoint GetWeldJointByWeldJointId(string weldJointId) { return Funs.DB.HJGL_WeldJoint.FirstOrDefault(e => e.WeldJointId == weldJointId); } /// /// 判断焊口号是否已存在 /// /// /// public static bool IsExistWeldJointCode(string weldJointCode, string pipelineId, string weldJointId) { Model.SGGLDB db = Funs.DB; Model.HJGL_WeldJoint jot = null; if (!string.IsNullOrEmpty(weldJointId)) { jot = Funs.DB.HJGL_WeldJoint.FirstOrDefault(x => x.WeldJointCode == weldJointCode && x.PipelineId == pipelineId && x.WeldJointId != weldJointId); } else { jot = Funs.DB.HJGL_WeldJoint.FirstOrDefault(x => x.WeldJointCode == weldJointCode && x.PipelineId == pipelineId); } if (jot != null) { return true; } else { return false; } } /// /// 根据焊接日报获取焊口数 /// /// /// public static List GetWeldlinesByWeldingDailyId(string weldingDailyId) { var q = (from x in Funs.DB.HJGL_WeldJoint where x.WeldingDailyId == weldingDailyId orderby x.PipelineId, x.WeldJointCode select x).ToList(); return q; } public static List GetWeldJointsByPipelineId(string PipelineId) { var q = (from x in Funs.DB.HJGL_WeldJoint where x.PipelineId == PipelineId select x).ToList(); return q; } public static Model.HJGL_WeldJoint GetWeldJointsByWeldJointCode(string PipelineId, string WeldJointCode) { var q = (from x in Funs.DB.HJGL_WeldJoint where x.PipelineId == PipelineId && x.WeldJointCode == WeldJointCode select x).FirstOrDefault(); return q; } /// /// 添加 /// /// public static void AddWeldJoint(Model.HJGL_WeldJoint weldJoint) { Model.SGGLDB db = Funs.DB; Model.HJGL_WeldJoint newWeldJoint = new Model.HJGL_WeldJoint { ProjectId = weldJoint.ProjectId, PipelineId = weldJoint.PipelineId, PipelineCode = weldJoint.PipelineCode, WeldJointCode = weldJoint.WeldJointCode, WeldTypeId = weldJoint.WeldTypeId, Material1Id = weldJoint.Material1Id, Material2Id = weldJoint.Material2Id, Thickness = weldJoint.Thickness, Dia = weldJoint.Dia, DNDia = weldJoint.DNDia, Size = weldJoint.Size, DetectionTypeId = weldJoint.DetectionTypeId, JointArea = weldJoint.JointArea, WeldingMethodId = weldJoint.WeldingMethodId, WeldingLocationId = weldJoint.WeldingLocationId, JointAttribute = weldJoint.JointAttribute, IsHotProess = weldJoint.IsHotProess, WeldingWire = weldJoint.WeldingWire, WeldingRod = weldJoint.WeldingRod, DesignIsHotProess = weldJoint.DesignIsHotProess, GrooveTypeId = weldJoint.GrooveTypeId, Specification = weldJoint.Specification, WPQId = weldJoint.WPQId, HeartNo1 = weldJoint.HeartNo1, HeartNo2 = weldJoint.HeartNo2, BaseWeldJointId = weldJoint.BaseWeldJointId, Components1Id = weldJoint.Components1Id, Components2Id = weldJoint.Components2Id, PreTemperature = weldJoint.PreTemperature, Remark = weldJoint.Remark, IsTwoJoint = weldJoint.IsTwoJoint, SubmitMan = weldJoint.SubmitMan, TwoJointType = weldJoint.TwoJointType, CoverWelderTeamGroupId = weldJoint.CoverWelderTeamGroupId, BackingWelderTeamGroupId = weldJoint.BackingWelderTeamGroupId, WeldJointPoint = weldJoint.WeldJointPoint }; if (!string.IsNullOrEmpty(weldJoint.WeldJointId)) { newWeldJoint.WeldJointId = weldJoint.WeldJointId; } else { newWeldJoint.WeldJointId = SQLHelper.GetNewID(typeof(Model.HJGL_WeldJoint)); } db.HJGL_WeldJoint.InsertOnSubmit(newWeldJoint); db.SubmitChanges(); } public static void AddBulkWeldJoint(List weldJoints) { using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString)) { db.HJGL_WeldJoint.InsertAllOnSubmit(weldJoints); db.SubmitChanges(); } } /// /// 修改 /// /// public static void UpdateWeldJoint(Model.HJGL_WeldJoint weldJoint) { Model.SGGLDB db = Funs.DB; Model.HJGL_WeldJoint newWeldJoint = db.HJGL_WeldJoint.FirstOrDefault(e => e.WeldJointId == weldJoint.WeldJointId); if (newWeldJoint != null) { newWeldJoint.WeldJointCode = weldJoint.WeldJointCode; newWeldJoint.ProjectId = weldJoint.ProjectId; newWeldJoint.PipelineCode = weldJoint.PipelineCode; newWeldJoint.WPQId = weldJoint.WPQId; newWeldJoint.WeldTypeId = weldJoint.WeldTypeId; newWeldJoint.Material1Id = weldJoint.Material1Id; newWeldJoint.Material2Id = weldJoint.Material2Id; newWeldJoint.Thickness = weldJoint.Thickness; newWeldJoint.Dia = weldJoint.Dia; newWeldJoint.DNDia = weldJoint.DNDia; newWeldJoint.Size = weldJoint.Size; newWeldJoint.DetectionTypeId = weldJoint.DetectionTypeId; newWeldJoint.JointArea = weldJoint.JointArea; newWeldJoint.WeldingMethodId = weldJoint.WeldingMethodId; newWeldJoint.IsHotProess = weldJoint.IsHotProess; newWeldJoint.WeldingLocationId = weldJoint.WeldingLocationId; newWeldJoint.JointAttribute = weldJoint.JointAttribute; newWeldJoint.DesignIsHotProess = weldJoint.DesignIsHotProess; newWeldJoint.WeldingWire = weldJoint.WeldingWire; newWeldJoint.WeldingRod = weldJoint.WeldingRod; newWeldJoint.GrooveTypeId = weldJoint.GrooveTypeId; newWeldJoint.HeartNo1 = weldJoint.HeartNo1; newWeldJoint.HeartNo2 = weldJoint.HeartNo2; newWeldJoint.Components1Id = weldJoint.Components1Id; newWeldJoint.Components2Id = weldJoint.Components2Id; newWeldJoint.BackingWelderId = weldJoint.BackingWelderId; newWeldJoint.CoverWelderId = weldJoint.CoverWelderId; newWeldJoint.WeldingDailyId = weldJoint.WeldingDailyId; newWeldJoint.WeldingMode = weldJoint.WeldingMode; newWeldJoint.WeldingDailyCode = weldJoint.WeldingDailyCode; newWeldJoint.Specification = weldJoint.Specification; newWeldJoint.PreTemperature = weldJoint.PreTemperature; newWeldJoint.Remark = weldJoint.Remark; newWeldJoint.AttachUrl = weldJoint.AttachUrl; newWeldJoint.SubmitMan = weldJoint.SubmitMan; newWeldJoint.TwoJointType = weldJoint.TwoJointType; newWeldJoint.CoverWelderTeamGroupId = weldJoint.CoverWelderTeamGroupId; newWeldJoint.BackingWelderTeamGroupId = weldJoint.BackingWelderTeamGroupId; newWeldJoint.WeldJointPoint = weldJoint.WeldJointPoint; db.SubmitChanges(); } } /// /// 更新施工焊口信息 /// /// public static void UpdateConWeldJoint(Model.HJGL_WeldJoint weldJoint) { Model.SGGLDB db = Funs.DB; Model.HJGL_WeldJoint newWeldJoint = db.HJGL_WeldJoint.FirstOrDefault(e => e.WeldJointId == weldJoint.WeldJointId); if (newWeldJoint != null) { newWeldJoint.WPQId = weldJoint.WPQId; newWeldJoint.MatchableWPQ = weldJoint.MatchableWPQ; newWeldJoint.WeldingMethodId = weldJoint.WeldingMethodId; newWeldJoint.IsHotProess = weldJoint.IsHotProess; newWeldJoint.WeldingWire = weldJoint.WeldingWire; newWeldJoint.WeldingRod = weldJoint.WeldingRod; newWeldJoint.GrooveTypeId = weldJoint.GrooveTypeId; newWeldJoint.PreTemperature = weldJoint.PreTemperature; newWeldJoint.Remark = weldJoint.Remark; db.SubmitChanges(); } } /// /// 回写焊口信息 /// /// public static void WriteBackWeldJoint(Model.HJGL_WeldJoint weldJoint) { Model.SGGLDB db = Funs.DB; Model.HJGL_WeldJoint newWeldJoint = db.HJGL_WeldJoint.FirstOrDefault(e => e.WeldJointId == weldJoint.WeldJointId); if (newWeldJoint != null) { newWeldJoint.BackingWelderId = weldJoint.BackingWelderId; newWeldJoint.CoverWelderId = weldJoint.CoverWelderId; newWeldJoint.WeldingDailyId = weldJoint.WeldingDailyId; newWeldJoint.WeldingDailyCode = weldJoint.WeldingDailyCode; newWeldJoint.WeldingLocationId = weldJoint.WeldingLocationId; newWeldJoint.JointAttribute = weldJoint.JointAttribute; } } /// /// 二次焊口审核 /// /// /// /// public static void UpdateJointAudit(string jointId, string auditMan, DateTime? auditDate) { Model.SGGLDB db = Funs.DB; Model.HJGL_WeldJoint newWeldJoint = db.HJGL_WeldJoint.FirstOrDefault(e => e.WeldJointId == jointId); if (newWeldJoint != null) { newWeldJoint.AuditMan = auditMan; newWeldJoint.AuditDate = auditDate; db.SubmitChanges(); } } /// /// 二次焊口施工经理审核 /// /// /// /// public static void UpdateJointAudit2(string jointId, string auditMan, DateTime? auditDate) { Model.SGGLDB db = Funs.DB; Model.HJGL_WeldJoint newWeldJoint = db.HJGL_WeldJoint.FirstOrDefault(e => e.WeldJointId == jointId); if (newWeldJoint != null) { newWeldJoint.AuditMan2 = auditMan; newWeldJoint.AuditDate2 = auditDate; db.SubmitChanges(); } } /// /// 根据主键删除焊口信息 /// /// public static void DeleteWeldJointById(string weldJointId) { Model.SGGLDB db = Funs.DB; Model.HJGL_WeldJoint weldline = db.HJGL_WeldJoint.FirstOrDefault(e => e.WeldJointId == weldJointId); if (weldline != null) { db.HJGL_WeldJoint.DeleteOnSubmit(weldline); db.SubmitChanges(); } } /// /// 根据管线删除焊口信息 /// /// public static void DeleteWeldJointByPipelineId(string pipelineId) { Model.SGGLDB db = Funs.DB; var weldline = db.HJGL_WeldJoint.Where(e => e.PipelineId == pipelineId); if (weldline != null) { db.HJGL_WeldJoint.DeleteAllOnSubmit(weldline); db.SubmitChanges(); } } /// /// 根据unitworkid删除焊口 /// /// public static void DeleteWeldJointByUnitWorkId(string unitworkId) { var oldPipeline = BLL.PipelineService.GetPipelinesByUnitWordId(unitworkId); if (oldPipeline != null) { foreach (var pipeline in oldPipeline) { BLL.WeldJointService.DeleteWeldJointByPipelineId(pipeline.PipelineId); //删除原有管线对应焊口 } } } /// /// 更新焊口号 固定焊口号后 +G /// /// 焊口id /// 焊口属性 /// 日报操作(增加、删除) public static void UpdateWeldJointAddG(string weldJointId, string jointAttribute, string operateState) { Model.SGGLDB db = Funs.DB; if (operateState == Const.BtnDelete || jointAttribute != "安装口") { Model.HJGL_WeldJoint deleteWeldJoint = db.HJGL_WeldJoint.FirstOrDefault(e => e.WeldJointId == weldJointId); if (deleteWeldJoint.WeldJointCode.Last() == 'G') { deleteWeldJoint.WeldJointCode = deleteWeldJoint.WeldJointCode.Substring(0, deleteWeldJoint.WeldJointCode.Length - 1); db.SubmitChanges(); } } else { Model.HJGL_WeldJoint addJointInfo = db.HJGL_WeldJoint.FirstOrDefault(e => e.WeldJointId == weldJointId); if (addJointInfo.WeldJointCode.Last() != 'G') { addJointInfo.WeldJointCode += "G"; } db.SubmitChanges(); } } /// /// 根据主键获取焊口信息视图 /// /// /// public static Model.View_HJGL_WeldJoint GetViewWeldJointById(string weldJointId) { Model.SGGLDB db = Funs.DB; return db.View_HJGL_WeldJoint.FirstOrDefault(e => e.WeldJointId == weldJointId); } public static List GetWeldJointByUnitworkId(string UnitWorkId) { Model.SGGLDB db = Funs.DB; var q = (from x in db.HJGL_WeldJoint join y in db.HJGL_Pipeline on x.PipelineId equals y.PipelineId into tt from g in tt.DefaultIfEmpty() where g.UnitWorkId == UnitWorkId select x).ToList(); return q; } public static List GetWeldJointByProjectid(string ProjectId) { Model.SGGLDB db = Funs.DB; var q = (from x in db.HJGL_WeldJoint where x.ProjectId == ProjectId select x).ToList(); return q; } /// /// 根据焊口Id获取插入焊口数 /// /// /// public static List GetBaseWeldJointsByWeldJointId(string weldJointId) { var q = (from x in Funs.DB.HJGL_WeldJoint where x.BaseWeldJointId == weldJointId orderby x.WeldJointCode select x).ToList(); return q; } /// /// 根据焊接日报获取焊口数 /// /// /// public static List GetWeldJointsByWeldingDailyId(string weldingDailyId) { var q = (from x in Funs.DB.HJGL_WeldJoint where x.WeldingDailyId == weldingDailyId orderby x.PipelineId, x.WeldJointCode select x).ToList(); return q; } /// /// 根据焊接日报获取焊口数 /// /// /// public static List GetViewWeldJointsByWeldingDailyId(string weldingDailyId) { var q = (from x in Funs.DB.View_HJGL_WeldJoint where x.WeldingDailyId == weldingDailyId orderby x.PipelineCode, x.WeldJointCode select x).ToList(); return q; } /// /// 获取当前焊工工作量是否超过60寸的焊接人员 /// /// 项目id /// 单位id /// 焊口ID /// 焊接日期 /// public static bool GetWelderLimitDN(string projectId, string welderId, DateTime weldingDate) { using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString)) { var jots = from x in db.HJGL_WeldJoint join y in db.HJGL_WeldingDaily on x.WeldingDailyId equals y.WeldingDailyId where x.ProjectId == projectId && y.WeldingDate == weldingDate && (welderId == x.CoverWelderId || welderId == x.BackingWelderId) select x; decimal? count = jots.Sum(x => x.Size); if (count >= 60) { return true; } else { return false; } } } /// /// 根据管线ID获取焊口信息 /// /// /// public static List GetViewWeldJointsByPipelineId(string pipelineId) { var q = (from x in Funs.DB.View_HJGL_WeldJoint where x.PipelineId == pipelineId orderby x.WeldJointCode select x).ToList(); return q; } public static List GetViewWeldJointsBymodel(Model.View_HJGL_WeldJoint model) { var baseQuery = from x in Funs.DB.View_HJGL_WeldJoint select x; if (!string.IsNullOrEmpty(model.ProjectId)) baseQuery = baseQuery.Where(x => x.ProjectId == model.ProjectId); if (!string.IsNullOrEmpty(model.UnitWorkId)) baseQuery = baseQuery.Where(x => x.UnitWorkId == model.UnitWorkId); if (!string.IsNullOrEmpty(model.PipelineId)) baseQuery = baseQuery.Where(x => x.PipelineId == model.PipelineId); if (!string.IsNullOrEmpty(model.PipelineCode)) baseQuery = baseQuery.Where(x => x.PipelineCode.Contains(model.PipelineCode)); if (!string.IsNullOrEmpty(model.WeldJointCode)) baseQuery = baseQuery.Where(x => x.WeldJointCode.Contains(model.WeldJointCode)); //构建排序 baseQuery = baseQuery.OrderBy(x => x.PipelineId).ThenBy(x => x.WeldJointCode); return baseQuery.ToList(); } public static IEnumerable GetIEnumerableViewWeldJointsBymodel(Model.View_HJGL_WeldJoint model) { var baseQuery = from x in Funs.DB.View_HJGL_WeldJoint select x; if (!string.IsNullOrEmpty(model.ProjectId)) baseQuery = baseQuery.Where(x => x.ProjectId == model.ProjectId); if (!string.IsNullOrEmpty(model.UnitWorkId)) baseQuery = baseQuery.Where(x => x.UnitWorkId == model.UnitWorkId); if (!string.IsNullOrEmpty(model.PipelineId)) baseQuery = baseQuery.Where(x => x.PipelineId == model.PipelineId); if (!string.IsNullOrEmpty(model.PipelineCode)) baseQuery = baseQuery.Where(x => x.PipelineCode.Contains(model.PipelineCode)); if (!string.IsNullOrEmpty(model.WeldJointCode)) baseQuery = baseQuery.Where(x => x.WeldJointCode.Contains(model.WeldJointCode)); return baseQuery.ToList(); } public static (List Data, int Total) GetDataBymodel(Model.View_HJGL_WeldJoint model, int pageIndex = 0, int pageSize = 20) { // 阶段一:构建基础查询 var baseQuery = Funs.DB.View_HJGL_WeldJoint.AsQueryable(); // 阶段二:构建动态查询条件 if (!string.IsNullOrEmpty(model.ProjectId)) baseQuery = baseQuery.Where(x => x.ProjectId == model.ProjectId); if (!string.IsNullOrEmpty(model.UnitWorkId)) baseQuery = baseQuery.Where(x => x.UnitWorkId == model.UnitWorkId); if (!string.IsNullOrEmpty(model.PipelineId)) baseQuery = baseQuery.Where(x => x.PipelineId == model.PipelineId); if (!string.IsNullOrEmpty(model.PipelineCode)) baseQuery = baseQuery.Where(x => x.PipelineCode.Contains(model.PipelineCode)); if (!string.IsNullOrEmpty(model.WeldJointCode)) baseQuery = baseQuery.Where(x => x.WeldJointCode.Contains(model.WeldJointCode)); // 阶段三:排序与分页控制(索引优化关键) var orderedQuery = baseQuery.OrderBy(x => x.PipelineId).ThenBy(x => x.WeldJointCode); // 阶段四:分页执行(数据库层面分页) var pagedData = orderedQuery .Skip((pageIndex) * pageSize) .Take(pageSize) .ToList(); // 获取总记录数(延迟计数优化) var totalCount = baseQuery.Count(); return (pagedData, totalCount); } public static List GetViewWeldJointsBymodel(Model.View_HJGL_WeldJoint model, int pageIndex = 0, int pageSize = 20) { // 阶段一:构建基础查询 var baseQuery = Funs.DB.View_HJGL_WeldJoint.AsQueryable(); // 阶段二:构建动态查询条件 if (!string.IsNullOrEmpty(model.ProjectId)) baseQuery = baseQuery.Where(x => x.ProjectId == model.ProjectId); if (!string.IsNullOrEmpty(model.UnitWorkId)) baseQuery = baseQuery.Where(x => x.UnitWorkId == model.UnitWorkId); if (!string.IsNullOrEmpty(model.PipelineId)) baseQuery = baseQuery.Where(x => x.PipelineId == model.PipelineId); if (!string.IsNullOrEmpty(model.PipelineCode)) baseQuery = baseQuery.Where(x => x.PipelineCode.Contains(model.PipelineCode)); if (!string.IsNullOrEmpty(model.WeldJointCode)) baseQuery = baseQuery.Where(x => x.WeldJointCode.Contains(model.WeldJointCode)); // 阶段三:排序与分页控制(索引优化关键) var orderedQuery = baseQuery.OrderBy(x => x.WeldJointCode); // 阶段四:分页执行(数据库层面分页) var pagedData = orderedQuery .Skip((pageIndex) * pageSize) .Take(pageSize) .ToList(); return pagedData; } /// /// 根据壁厚计算焊口达因 /// /// /// public static double GetSizeByThickness(decimal? size, decimal thickness) { double n = 0; if (thickness <= 8) { n = 1; } else if (thickness > 8 && thickness < 12) { n = 1.2; } else if (thickness >= 12 && thickness < 16) { n = 1.3; } else if (thickness >= 16 && thickness < 19) { n = 1.5; } else if (thickness >= 19 && thickness < 23) { n = 2; } else if (thickness >= 23 && thickness < 27) { n = 3; } else if (thickness >= 27 && thickness < 31) { n = 4; } else if (thickness >= 31 && thickness < 35) { n = 5; } else if (thickness >= 35 && thickness < 39) { n = 6; } else if (thickness >= 39 && thickness < 43) { n = 7; } else if (thickness >= 43 && thickness < 47) { n = 8; } else if (thickness >= 47 && thickness < 51) { n = 9; } else if (thickness >= 51 && thickness < 55) { n = 10; } else if (thickness >= 55 && thickness < 59) { n = 11; } else if (thickness >= 59 && thickness < 63) { n = 12; } return Convert.ToDouble(size) * n; } public static string GetWPQCodeByWeldJointId(object WeldJointId) { string result = ""; if (WeldJointId != null) { var model = GetViewWeldJointById(WeldJointId.ToString()); result = model?.WPQCode; } return result; } /// /// 根据单位工程、流水号、材质、口径获取达因数 /// /// /// 单位工程 /// 流水段 /// 材质 /// 口径 /// 1-达因,2-完成达因 /// public static decimal? GetSizeSum(string projectId, string unitWorkId, string flowingSection, string steelType, string caliber, string type) { Model.SGGLDB db = Funs.DB; decimal? sizeSum = 0; int c = 0; if (!string.IsNullOrEmpty(caliber)) { c = Convert.ToInt32(caliber.Substring(1, caliber.Length - 1)); var weldjoints = (from x in db.HJGL_WeldJoint join y in db.HJGL_Pipeline on x.PipelineId equals y.PipelineId join z in db.Base_Material on y.MaterialId equals z.MaterialId where x.ProjectId == projectId && y.UnitWorkId == unitWorkId && y.FlowingSection == flowingSection && z.SteelType == steelType && y.PipeArea == "1" && x.JointAttribute == "预制口" select x); foreach (var item in weldjoints) { if (!string.IsNullOrEmpty(item.DNDia) && item.DNDia != null) { int s = Convert.ToInt32(item.DNDia.Substring(2, item.DNDia.Length - 2)); if (caliber.Substring(0, 1) == "<" && s < c) { if (type == "1") { sizeSum += item.Size; } else { if (!string.IsNullOrEmpty(item.WeldingDailyId)) { sizeSum += item.Size; } } } else if (caliber.Substring(0, 1) == "≥" && s >= c) { if (type == "1") { sizeSum += item.Size; } else { if (!string.IsNullOrEmpty(item.WeldingDailyId)) { sizeSum += item.Size; } } } } } } return sizeSum; } /// /// 根据单位工程、流水段获取优先级总达因、完成总达因 /// /// 项目id /// 单位工程 /// 流水段 /// 1-总达因,2-完成总达因 /// public static decimal? GetSizeSumByUnitWorkIdAndFlowingSection(string projectId, string unitWorkId, string flowingSection, string type) { Model.SGGLDB db = Funs.DB; decimal? sizeSum = 0; if (type == "1") { sizeSum = (from x in db.HJGL_WeldJoint join y in db.HJGL_Pipeline on x.PipelineId equals y.PipelineId //join z in db.Base_Material on y.MaterialId equals z.MaterialId where x.ProjectId == projectId && y.UnitWorkId == unitWorkId && y.FlowingSection == flowingSection && y.PipeArea == "1" && x.JointAttribute == "预制口" select x.Size).Sum(); } else { sizeSum = (from x in db.HJGL_WeldJoint join y in db.HJGL_Pipeline on x.PipelineId equals y.PipelineId //join z in db.Base_Material on y.MaterialId equals z.MaterialId where x.ProjectId == projectId && y.UnitWorkId == unitWorkId && y.FlowingSection == flowingSection && y.PipeArea == "1" && x.JointAttribute == "预制口" && x.WeldingDailyId != "" && x.WeldingDailyId != null select x.Size).Sum(); } return sizeSum; } /// /// 根据单位工程、流水段、材质获取总达因(按材质) /// /// 项目id /// 单位工程id /// 流水号 /// 材质 /// public static decimal? GetSizeSumByUnitWorkIdAndFlowingSectionAndMaterial(string projectId, string unitWorkId, string flowingSection, string steelType) { Model.SGGLDB db = Funs.DB; decimal? sizeSum = 0; sizeSum = (from x in db.HJGL_WeldJoint join y in db.HJGL_Pipeline on x.PipelineId equals y.PipelineId join z in db.Base_Material on y.MaterialId equals z.MaterialId where x.ProjectId == projectId && y.UnitWorkId == unitWorkId && y.FlowingSection == flowingSection && y.PipeArea == "1" && x.JointAttribute == "预制口" && z.SteelType == steelType select x.Size).Sum(); return sizeSum; } /// /// 获取当日已完成量 /// /// /// /// /// /// /// public static decimal? GetCurrentDaySizeSum(string projectId, string unitWorkId, string flowingSection, string steelType, string caliber) { Model.SGGLDB db = Funs.DB; decimal? sizeSum = 0; int c = 0; if (!string.IsNullOrEmpty(caliber)) { c = Convert.ToInt32(caliber.Substring(1, caliber.Length - 1)); var weldjoints = (from x in db.HJGL_WeldJoint join y in db.HJGL_Pipeline on x.PipelineId equals y.PipelineId join z in db.Base_Material on y.MaterialId equals z.MaterialId where x.ProjectId == projectId && y.UnitWorkId == unitWorkId && y.FlowingSection == flowingSection && z.SteelType == steelType && y.PipeArea == "1" && x.JointAttribute == "预制口" select x); foreach (var item in weldjoints) { if (!string.IsNullOrEmpty(item.DNDia) && item.DNDia != null) { int s = Convert.ToInt32(item.DNDia.Substring(2, item.DNDia.Length - 2)); if (caliber.Substring(0, 1) == "<" && s < c) { if (!string.IsNullOrEmpty(item.WeldingDailyId)) { var weldingDaily = BLL.WeldingDailyService.GetPipeline_WeldingDailyByWeldingDailyId(item.WeldingDailyId); if (weldingDaily != null && weldingDaily.WeldingDate.HasValue && weldingDaily.WeldingDate.Value.ToShortDateString() == DateTime.Now.ToShortDateString()) { sizeSum += item.Size; } } } else if (caliber.Substring(0, 1) == "≥" && s >= c) { if (!string.IsNullOrEmpty(item.WeldingDailyId)) { var weldingDaily = BLL.WeldingDailyService.GetPipeline_WeldingDailyByWeldingDailyId(item.WeldingDailyId); if (weldingDaily != null && weldingDaily.WeldingDate.HasValue && weldingDaily.WeldingDate.Value.ToShortDateString() == DateTime.Now.ToShortDateString()) { sizeSum += item.Size; } } } } } } return sizeSum; } } }