焊接管理导入修改
This commit is contained in:
@@ -287,8 +287,8 @@ namespace BLL
|
||||
{
|
||||
// 从子表HJGL_PackagingManageDetail中获取关联的组件ID
|
||||
var PipelineComponentIdList = (from x in Funs.DB.HJGL_PackagingManageDetail
|
||||
where x.PackagingManageId == PackagingManageId
|
||||
select x.PipelineComponentId).ToList();
|
||||
where x.PackagingManageId == PackagingManageId
|
||||
select x.PipelineComponentId).ToList();
|
||||
if (PipelineComponentIdList == null || PipelineComponentIdList.Count == 0)
|
||||
return new List<Model.PackagingManagePrintOutput>();
|
||||
|
||||
@@ -322,7 +322,7 @@ namespace BLL
|
||||
PipelineComponentCode = x.MaterialCode,
|
||||
num = x.Number.ToString(),
|
||||
CU = x.MaterialUnit,
|
||||
UnitWorkName = UnitWorkService.GetNameById( TwOutputdetailService.GetInOutMasterById(x.TwOutputDetailId)?.UnitWorkId ),
|
||||
UnitWorkName = UnitWorkService.GetNameById(TwOutputdetailService.GetInOutMasterById(x.TwOutputDetailId)?.UnitWorkId),
|
||||
FlowingSection = model.StackingPosition,
|
||||
};
|
||||
result = detailList.ToList();
|
||||
@@ -421,54 +421,85 @@ namespace BLL
|
||||
return q;
|
||||
}
|
||||
|
||||
public static (List<PackagingManageOutput> Data, int Total) GetPackagingManageList(string projectId, string PackagingCode, int pageIndex = 0, int pageSize = 20)
|
||||
public static (List<PackagingManageOutput> Data, int Total) GetPackagingManageList(string projectId, string PackagingCode, int pageIndex = 0, int pageSize = 20)
|
||||
{
|
||||
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
|
||||
{
|
||||
var baseQuery = (from x in db.HJGL_PackagingManage
|
||||
join n in db.Base_Project on x.ProjectId equals n.ProjectId
|
||||
join m in db.Person_Persons on x.ReceiveMan equals m.PersonId into tt
|
||||
from t in tt.DefaultIfEmpty()
|
||||
join train in db.HJGL_TrainNumberManage on x.TrainNumberId equals train.Id into trains
|
||||
var filteredQuery = from x in db.HJGL_PackagingManage
|
||||
join p in db.Person_Persons
|
||||
on x.CompileMan equals p.PersonId into personGroup
|
||||
from p in personGroup.DefaultIfEmpty()
|
||||
join u in db.Base_Unit
|
||||
on p.UnitId equals u.UnitId into unitGroup
|
||||
from u in unitGroup.DefaultIfEmpty()
|
||||
where x.ProjectId == projectId
|
||||
&& (string.IsNullOrEmpty(PackagingCode) || x.PackagingCode.Contains(PackagingCode))
|
||||
select new { x, u };
|
||||
|
||||
// 获取总记录数(延迟计数优化)
|
||||
var totalCount = filteredQuery.Count();
|
||||
var pagedData = (from z in filteredQuery
|
||||
join n in db.Base_Project on z.x.ProjectId equals n.ProjectId
|
||||
join train in db.HJGL_TrainNumberManage on z.x.TrainNumberId equals train.Id into trains
|
||||
from train in trains.DefaultIfEmpty()
|
||||
where x.ProjectId == projectId
|
||||
&& (string.IsNullOrEmpty(PackagingCode) || x.PackagingCode.Contains(PackagingCode))
|
||||
orderby z.x.PackagingCode descending
|
||||
select new PackagingManageOutput
|
||||
{
|
||||
PackagingManageId = x.PackagingManageId,
|
||||
PackagingCode = x.PackagingCode,
|
||||
PackagingManageId = z.x.PackagingManageId,
|
||||
PackagingCode = z.x.PackagingCode,
|
||||
ProjectName = n.ProjectName,
|
||||
ContactName = train.ContactName,
|
||||
ContactPhone = train.ContactPhone,
|
||||
DriverName = train.DriverName,
|
||||
DriverPhone = train.DriverPhone,
|
||||
LicensePlateNumber = train.LicensePlateNumber,
|
||||
StackingPosition = x.StackingPosition,
|
||||
State = x.State,
|
||||
TypeInt = x.TypeInt,
|
||||
CategoryInt = x.CategoryInt,
|
||||
TypeString = GetTypeString(x.TypeInt),
|
||||
CategoryString = GetCategoryString(x.CategoryInt),
|
||||
ReceiveMan = train.ContactName,//t.PersonName,
|
||||
ReceiveDate = x.ReceiveDate.HasValue ? string.Format("{0:g}", x.ReceiveDate) : "",
|
||||
PlanStartDate = GetMinPlanStartDate(x.PackagingManageId),
|
||||
TrainNumberOld = x.TrainNumber,
|
||||
StackingPosition = z.x.StackingPosition,
|
||||
State = z.x.State,
|
||||
TypeInt = z.x.TypeInt,
|
||||
CategoryInt = z.x.CategoryInt,
|
||||
TypeString = GetTypeString(z.x.TypeInt),
|
||||
CategoryString = GetCategoryString(z.x.CategoryInt),
|
||||
ReceiveMan = train.ContactName,
|
||||
ReceiveDate = z.x.ReceiveDate.HasValue ? string.Format("{0:g}", z.x.ReceiveDate) : "",
|
||||
TrainNumberOld = z.x.TrainNumber,
|
||||
TrainNumber = train.TrainNumber,
|
||||
Code = x.PackagingCode.Substring(0, x.PackagingCode.LastIndexOf("-")).Substring(x.PackagingCode.Substring(0, x.PackagingCode.LastIndexOf("-")).LastIndexOf("-") + 1),
|
||||
}).Distinct();
|
||||
})
|
||||
.Skip(pageIndex * pageSize)
|
||||
.Take(pageSize)
|
||||
.ToList();
|
||||
|
||||
var pagedData = baseQuery
|
||||
.OrderByDescending(x => x.Code)
|
||||
.Skip((pageIndex) * pageSize)
|
||||
.Take(pageSize)
|
||||
.ToList();
|
||||
foreach (var item in pagedData)
|
||||
{
|
||||
item.Code = GetPackagingCodeSortPart(item.PackagingCode);
|
||||
}
|
||||
|
||||
// 获取总记录数(延迟计数优化)
|
||||
var totalCount = baseQuery.Count();
|
||||
return (pagedData, totalCount);
|
||||
}
|
||||
}
|
||||
|
||||
private static string GetPackagingCodeSortPart(string packagingCode)
|
||||
{
|
||||
if (string.IsNullOrEmpty(packagingCode))
|
||||
{
|
||||
return string.Empty;
|
||||
}
|
||||
|
||||
var lastIndex = packagingCode.LastIndexOf("-");
|
||||
if (lastIndex <= 0)
|
||||
{
|
||||
return packagingCode;
|
||||
}
|
||||
|
||||
var beforeLast = packagingCode.Substring(0, lastIndex);
|
||||
var secondLastIndex = beforeLast.LastIndexOf("-");
|
||||
if (secondLastIndex < 0 || secondLastIndex >= beforeLast.Length - 1)
|
||||
{
|
||||
return beforeLast;
|
||||
}
|
||||
|
||||
return beforeLast.Substring(secondLastIndex + 1);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取包装管理列表(带过滤条件)
|
||||
/// </summary>
|
||||
@@ -486,9 +517,15 @@ namespace BLL
|
||||
join n in db.Base_Project on x.ProjectId equals n.ProjectId
|
||||
join m in db.Person_Persons on x.ReceiveMan equals m.PersonId into tt
|
||||
from t in tt.DefaultIfEmpty()
|
||||
join train in db.HJGL_TrainNumberManage on x.TrainNumberId equals train.Id into trains
|
||||
from train in trains.DefaultIfEmpty()
|
||||
select new { x, n, t , train };
|
||||
join p in db.Person_Persons
|
||||
on x.CompileMan equals p.PersonId into personGroup
|
||||
from p in personGroup.DefaultIfEmpty() // 实现 Left Join
|
||||
join u in db.Base_Unit
|
||||
on p.UnitId equals u.UnitId into unitGroup
|
||||
from u in unitGroup.DefaultIfEmpty() // 实现 Left Join
|
||||
join train in db.HJGL_TrainNumberManage on x.TrainNumberId equals train.Id into trains
|
||||
from train in trains.DefaultIfEmpty()
|
||||
select new { x, n, t, u.UnitId, u.UnitName, train };
|
||||
|
||||
if (filter != null)
|
||||
{
|
||||
@@ -499,7 +536,7 @@ namespace BLL
|
||||
if (!string.IsNullOrEmpty(filter.PackagingCode))
|
||||
{
|
||||
baseQuery = baseQuery.Where(z => z.x.PackagingCode.Contains(filter.PackagingCode));
|
||||
}
|
||||
}
|
||||
if (!string.IsNullOrEmpty(filter.ProjectId))
|
||||
{
|
||||
baseQuery = baseQuery.Where(z => z.x.ProjectId == filter.ProjectId);
|
||||
@@ -574,7 +611,7 @@ namespace BLL
|
||||
ReceiveDate = string.Format("{0:g}", z.x.ReceiveDate),
|
||||
TrainNumber = z.train.TrainNumber,
|
||||
ComponentCount = db.HJGL_PackagingManageDetail.Count(d => d.PackagingManageId == z.x.PackagingManageId),
|
||||
CategoryInt = z.x.CategoryInt,
|
||||
CategoryInt = z.x.CategoryInt,
|
||||
CategoryString = z.x.CategoryInt == 10 ? "打捆" : (z.x.CategoryInt == 20 ? "装箱" : (z.x.CategoryInt == 30 ? "散装" : ""))
|
||||
}).Distinct();
|
||||
|
||||
@@ -626,8 +663,8 @@ namespace BLL
|
||||
{
|
||||
// 获取现有的组件ID列表
|
||||
var existingComponentIds = (from x in db.HJGL_PackagingManageDetail
|
||||
where x.PackagingManageId == packagingManageId
|
||||
select x.PipelineComponentId).ToList();
|
||||
where x.PackagingManageId == packagingManageId
|
||||
select x.PipelineComponentId).ToList();
|
||||
|
||||
// 合并新旧组件ID(去重)
|
||||
HashSet<string> allComponentIds = new HashSet<string>(existingComponentIds);
|
||||
@@ -696,7 +733,7 @@ namespace BLL
|
||||
}
|
||||
|
||||
var existDetail = (from detail in Funs.DB.HJGL_PackagingManageDetail
|
||||
join pack in Funs.DB.HJGL_PackagingManage on detail.PackagingManageId equals pack.PackagingManageId
|
||||
join pack in Funs.DB.HJGL_PackagingManage on detail.PackagingManageId equals pack.PackagingManageId
|
||||
where detail.PipelineComponentId == pipelineComponentId
|
||||
select new
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user