using Model; using System; using System.Collections.Generic; using System.Linq; namespace BLL { public class APIPipelineComponentService { public static List GetPackagingManageList(string projectid) { using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString)) { var q = (from x in db.HJGL_Pipeline_Component join y in db.HJGL_Pipeline on x.PipelineId equals y.PipelineId join z in db.Base_Unit on x.PreUnit equals z.UnitId into tt join m in db.Person_Persons on x.ReceiveMan equals m.PersonId into pp from t in tt.DefaultIfEmpty() from p in pp.DefaultIfEmpty() where y.ProjectId == projectid select new PipelineComponentItem { PipelineComponentId = x.PipelineComponentId, PipelineComponentCode = x.PipelineComponentCode, PreUnit = t.UnitName, DrawingName = x.DrawingName, BoxNumber = x.BoxNumber, State = x.State, PlanStartDate = string.Format("{0:g}", y.PlanStartDate), QRCode = x.QRCode, ReceiveMan = p.PersonName, ReceiveDate = string.Format("{0:g}", x.ReceiveDate) }).Distinct(); return q.ToList(); } } public static PipelineComponentDetail GetPipelineComponentById(string projectId, string personId, string PipelineComponentId) { using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString)) { PipelineComponentDetail pipelineComponentDetail = new PipelineComponentDetail(); var q = (from x in db.HJGL_Pipeline_Component join y in db.HJGL_Pipeline on x.PipelineId equals y.PipelineId join z in db.Base_Unit on x.PreUnit equals z.UnitId into tt join m in db.Person_Persons on x.ReceiveMan equals m.PersonId into pp from t in tt.DefaultIfEmpty() from p in pp.DefaultIfEmpty() join unitwork in db.WBS_UnitWork on y.UnitWorkId equals unitwork.UnitWorkId into unitworks from unitwork in unitworks.DefaultIfEmpty() where x.PipelineComponentId == PipelineComponentId select new PipelineComponentItem { PipelineComponentId = x.PipelineComponentId, PipelineComponentCode = x.PipelineComponentCode, PreUnit = t.UnitName, DrawingName = x.DrawingName, BoxNumber = x.BoxNumber, State = x.State, PlanStartDate = string.Format("{0:g}", y.PlanStartDate), QRCode = x.QRCode, ReceiveMan = p.PersonName, ReceiveDate = string.Format("{0:g}", x.ReceiveDate), UnitWorkName = unitwork.UnitWorkName, Remark = x.Remark }).FirstOrDefault(); if (q != null) { q.StateStr = HJGL_PipelineComponentService.GetState() .FirstOrDefault(x => x.Value == q.State.ToString()) ?.Text.Trim(); } bool isPower = Person_PersonsService.IsGeneralUnitByPersonId(personId, projectId); pipelineComponentDetail.pipelineComponentItem = q; pipelineComponentDetail.isPower = isPower; return pipelineComponentDetail; } } public static void GetComponentConfirmArrival(string PipelineComponentId, string PersonId, string message) { var q = BLL.HJGL_PipelineComponentService.GetPipelineComponentById(PipelineComponentId); if (q != null) { if (!string.IsNullOrEmpty(message)) { q.State = HJGL_PipelineComponentService.StatePenRec; q.Remark = message; } else { q.State = HJGL_PipelineComponentService.State1; } q.ReceiveMan = PersonId; q.ReceiveDate = DateTime.Now; HJGL_PipelineComponentService.UpdatePipelineComponent(q); } } } }