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

107 lines
4.8 KiB
C#
Raw Normal View History

using Model;
2022-10-11 17:12:13 +08:00
using System;
using System.Collections.Generic;
using System.Linq;
namespace BLL
{
public class APIPipelineComponentService
{
2022-10-11 17:12:13 +08:00
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
2022-10-15 15:40:49 +08:00
from t in tt.DefaultIfEmpty()
from p in pp.DefaultIfEmpty()
2022-10-11 17:12:13 +08:00
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();
2022-10-11 17:12:13 +08:00
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
2022-10-15 15:40:49 +08:00
join m in db.Person_Persons on x.ReceiveMan equals m.PersonId into pp
2022-10-11 17:12:13 +08:00
from t in tt.DefaultIfEmpty()
2022-10-15 15:40:49 +08:00
from p in pp.DefaultIfEmpty()
2024-09-28 16:59:44 +08:00
join unitwork in db.WBS_UnitWork on y.UnitWorkId equals unitwork.UnitWorkId into unitworks
from unitwork in unitworks.DefaultIfEmpty()
where x.PipelineComponentId == PipelineComponentId
2022-10-11 17:12:13 +08:00
select new PipelineComponentItem
{
PipelineComponentId = x.PipelineComponentId,
PipelineComponentCode = x.PipelineComponentCode,
PreUnit = t.UnitName,
DrawingName = x.DrawingName,
BoxNumber = x.BoxNumber,
State = x.State,
2022-10-19 15:49:56 +08:00
PlanStartDate = string.Format("{0:g}", y.PlanStartDate),
2022-10-11 17:12:13 +08:00
QRCode = x.QRCode,
2022-10-15 15:40:49 +08:00
ReceiveMan = p.PersonName,
2024-09-28 16:59:44 +08:00
ReceiveDate = string.Format("{0:g}", x.ReceiveDate),
UnitWorkName = unitwork.UnitWorkName,
2024-11-06 09:59:54 +08:00
Remark = x.Remark
2022-10-11 17:12:13 +08:00
}).FirstOrDefault();
2024-11-06 16:03:58 +08:00
if (q != null)
{
q.StateStr = HJGL_PipelineComponentService.GetState()
.FirstOrDefault(x => x.Value == q.State.ToString())
?.Text.Trim();
}
2022-10-11 17:12:13 +08:00
bool isPower = Person_PersonsService.IsGeneralUnitByPersonId(personId, projectId);
pipelineComponentDetail.pipelineComponentItem = q;
2024-11-06 16:03:58 +08:00
pipelineComponentDetail.isPower = isPower;
2022-10-11 17:12:13 +08:00
return pipelineComponentDetail;
}
}
public static void GetComponentConfirmArrival(string PipelineComponentId, string PersonId, string message)
2022-10-11 17:12:13 +08:00
{
var q = BLL.HJGL_PipelineComponentService.GetPipelineComponentById(PipelineComponentId);
if (q != null)
{
2024-11-06 09:36:10 +08:00
if (!string.IsNullOrEmpty(message))
{
2024-11-06 09:59:54 +08:00
q.State = HJGL_PipelineComponentService.StatePenRec;
q.Remark = message;
2024-11-06 09:36:10 +08:00
}
else
{
2024-11-06 09:59:54 +08:00
q.State = HJGL_PipelineComponentService.State1;
2024-11-06 09:36:10 +08:00
}
2022-10-15 15:40:49 +08:00
q.ReceiveMan = PersonId;
q.ReceiveDate = DateTime.Now;
2024-11-06 09:36:10 +08:00
2022-10-11 17:12:13 +08:00
HJGL_PipelineComponentService.UpdatePipelineComponent(q);
}
}
}
}