using System; using System.Collections.Generic; using System.Linq; namespace BLL { /// /// 焊前抽检台账服务 /// public static class PreWeldInspectionService { /// /// 获取下料抽检台账 /// public static Tuple, int> GetCuttingCheckList(string projectId, string pipelineCode, string weldJointCode, int pageIndex, int pageSize) { using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString)) { var query = from c in db.HJGL_PreWeldCuttingCheck join w in db.HJGL_WeldJoint on c.WeldJointId equals w.WeldJointId join p in db.Person_Persons on c.CheckPerson equals p.PersonId into persons from p in persons.DefaultIfEmpty() where string.IsNullOrEmpty(projectId) || c.ProjectId == projectId || w.ProjectId == projectId select new { c, w, CheckPersonName = p == null ? string.Empty : p.PersonName }; if (!string.IsNullOrEmpty(pipelineCode)) { query = query.Where(x => x.w.PipelineCode.Contains(pipelineCode)); } if (!string.IsNullOrEmpty(weldJointCode)) { query = query.Where(x => x.w.WeldJointCode.Contains(weldJointCode)); } int total = query.Count(); var data = query.OrderByDescending(x => x.c.CheckTime) .Skip(pageIndex * pageSize) .Take(pageSize) .Select(x => new Model.PreWeldCuttingCheckItem { CuttingCheckId = x.c.CuttingCheckId, ProjectId = x.c.ProjectId, WeldJointId = x.c.WeldJointId, PipelineCode = x.w.PipelineCode, WeldJointCode = x.w.WeldJointCode, IsMaterialCodeBatchNoAccurate = x.c.IsMaterialCodeBatchNoAccurate, IsMaterialQuantityAccurate = x.c.IsMaterialQuantityAccurate, IsQualified = x.c.IsQualified, CheckPerson = x.c.CheckPerson, CheckPersonName = x.CheckPersonName, CheckTime = x.c.CheckTime, CreateUser = x.c.CreateUser, CreateTime = x.c.CreateTime, Remark = x.c.Remark }) .ToList(); return Tuple.Create(data, total); } } /// /// 获取组对抽检台账 /// public static Tuple, int> GetFitupCheckList(string projectId, string pipelineCode, string weldJointCode, int pageIndex, int pageSize) { using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString)) { var query = from f in db.HJGL_PreWeldFitupCheck join w in db.HJGL_WeldJoint on f.WeldJointId equals w.WeldJointId join g in db.Base_GrooveType on f.GrooveTypeId equals g.GrooveTypeId into grooveTypes from g in grooveTypes.DefaultIfEmpty() join p in db.Person_Persons on f.CheckPerson equals p.PersonId into persons from p in persons.DefaultIfEmpty() where string.IsNullOrEmpty(projectId) || f.ProjectId == projectId || w.ProjectId == projectId select new { f, w, g, CheckPersonName = p == null ? string.Empty : p.PersonName }; if (!string.IsNullOrEmpty(pipelineCode)) { query = query.Where(x => x.w.PipelineCode.Contains(pipelineCode)); } if (!string.IsNullOrEmpty(weldJointCode)) { query = query.Where(x => x.w.WeldJointCode.Contains(weldJointCode)); } int total = query.Count(); var data = query.OrderBy(x => x.w.PipelineCode).ThenBy(x => x.w.WeldJointCode) .Skip(pageIndex * pageSize) .Take(pageSize) .Select(x => new Model.PreWeldFitupCheckItem { FitupCheckId = x.f.FitupCheckId, ProjectId = x.f.ProjectId, WeldJointId = x.w.WeldJointId, PipelineCode = x.w.PipelineCode, WeldJointCode = x.w.WeldJointCode, GrooveTypeId = x.f.GrooveTypeId, GrooveTypeCode = x.g == null ? string.Empty : x.g.GrooveTypeCode, GrooveTypeName = x.g == null ? string.Empty : x.g.GrooveTypeName, GrooveProcessType = x.f.GrooveProcessType, GrooveAngle = x.f.GrooveAngle, FitupGap = x.f.FitupGap, Misalignment = x.f.Misalignment, CheckPerson = x.f.CheckPerson, CheckPersonName = x.CheckPersonName, CheckTime = x.f.CheckTime, CreateUser = x.f.CreateUser, CreateTime = x.f.CreateTime, Remark = x.f.Remark }) .ToList(); return Tuple.Create(data, total); } } /// /// 获取下料抽检实体 /// public static Model.HJGL_PreWeldCuttingCheck GetCuttingCheckById(string cuttingCheckId) { using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString)) { return db.HJGL_PreWeldCuttingCheck.FirstOrDefault(x => x.CuttingCheckId == cuttingCheckId); } } /// /// 获取组对抽检实体 /// public static Model.HJGL_PreWeldFitupCheck GetFitupCheckByWeldJointId(string weldJointId) { using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString)) { return db.HJGL_PreWeldFitupCheck.FirstOrDefault(x => x.WeldJointId == weldJointId); } } } }