SGGL_SHJ/SGGL/BLL/API/HJGL/APIPipelineComponentService.cs

88 lines
4.0 KiB
C#

using NPOI.OpenXmlFormats.Shared;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Model;
namespace BLL
{
public class APIPipelineComponentService
{
public static List<PipelineComponentItem> 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()
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)
}).FirstOrDefault();
bool isPower = Person_PersonsService.IsGeneralUnitByPersonId(personId, projectId);
pipelineComponentDetail.pipelineComponentItem = q;
pipelineComponentDetail.isPower=isPower;
return pipelineComponentDetail;
}
}
public static void GetComponentConfirmArrival(string PipelineComponentId,string PersonId)
{
var q = BLL.HJGL_PipelineComponentService.GetPipelineComponentById(PipelineComponentId);
if (q != null)
{
q.State = HJGL_PipelineComponentService.state_1;
q.ReceiveMan = PersonId;
q.ReceiveDate = DateTime.Now;
HJGL_PipelineComponentService.UpdatePipelineComponent(q);
}
}
}
}