新增管道颜色标识导入功能及API控制器
更新了多个服务和页面,增加了导入管道颜色标识数据的功能,并实现了包装管理、车次管理、管道组件和焊口信息的API控制器。修正了文件路径错误,优化了分页和排序逻辑,删除了不再使用的API方法。
This commit is contained in:
@@ -6,30 +6,96 @@ using System.Linq;
|
||||
namespace BLL
|
||||
{
|
||||
public class APIPackagingManageService
|
||||
|
||||
{
|
||||
public static List<Model.PackagingManageDetailItem> GetPackagingManageList(string projectId)
|
||||
public static List<Model.PackagingManageDetailItem> GetPackagingManageList(PackagingManageInput filter, int pageIndex, int pageSize, out int totalCount)
|
||||
{
|
||||
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
|
||||
{
|
||||
var q = (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()
|
||||
where x.ProjectId == projectId
|
||||
// base join query to include project and receive person
|
||||
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()
|
||||
select new { x, n, t };
|
||||
|
||||
if (filter != null)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(filter.PackagingManageId))
|
||||
{
|
||||
baseQuery = baseQuery.Where(z => z.x.PackagingManageId == filter.PackagingManageId);
|
||||
}
|
||||
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);
|
||||
}
|
||||
if (!string.IsNullOrEmpty(filter.ProjectName))
|
||||
{
|
||||
baseQuery = baseQuery.Where(z => z.n.ProjectName.Contains(filter.ProjectName));
|
||||
}
|
||||
if (!string.IsNullOrEmpty(filter.ContactName))
|
||||
{
|
||||
baseQuery = baseQuery.Where(z => z.x.ContactName.Contains(filter.ContactName));
|
||||
}
|
||||
if (!string.IsNullOrEmpty(filter.ContactPhone))
|
||||
{
|
||||
baseQuery = baseQuery.Where(z => z.x.ContactPhone.Contains(filter.ContactPhone));
|
||||
}
|
||||
if (!string.IsNullOrEmpty(filter.StackingPosition))
|
||||
{
|
||||
baseQuery = baseQuery.Where(z => z.x.StackingPosition.Contains(filter.StackingPosition));
|
||||
}
|
||||
if (filter.State != null)
|
||||
{
|
||||
baseQuery = baseQuery.Where(z => z.x.State == filter.State);
|
||||
}
|
||||
if (!string.IsNullOrEmpty(filter.ReceiveMan))
|
||||
{
|
||||
baseQuery = baseQuery.Where(z => z.x.ReceiveMan == filter.ReceiveMan || (z.t != null && z.t.PersonName.Contains(filter.ReceiveMan)));
|
||||
}
|
||||
if (!string.IsNullOrEmpty(filter.ReceiveDate))
|
||||
{
|
||||
DateTime dt;
|
||||
if (DateTime.TryParse(filter.ReceiveDate, out dt))
|
||||
{
|
||||
var start = dt.Date;
|
||||
var end = start.AddDays(1);
|
||||
baseQuery = baseQuery.Where(z => z.x.ReceiveDate != null && z.x.ReceiveDate >= start && z.x.ReceiveDate < end);
|
||||
}
|
||||
}
|
||||
if (!string.IsNullOrEmpty(filter.TrainNumberId))
|
||||
{
|
||||
baseQuery = baseQuery.Where(z => z.x.TrainNumber != null && z.x.TrainNumber.Contains(filter.TrainNumberId));
|
||||
}
|
||||
}
|
||||
|
||||
baseQuery = baseQuery.OrderByDescending(z => (z.x.ReceiveDate ?? DateTime.MinValue)).ThenBy(z => z.x.PackagingCode);
|
||||
|
||||
var q = (from z in baseQuery
|
||||
select new PackagingManageDetailItem
|
||||
{
|
||||
PackagingManageId = x.PackagingManageId,
|
||||
PackagingCode = x.PackagingCode,
|
||||
ProjectName = n.ProjectName,
|
||||
ContactName = x.ContactName,
|
||||
ContactPhone = x.ContactPhone,
|
||||
StackingPosition = x.StackingPosition,
|
||||
State = x.State,
|
||||
ReceiveMan = t.PersonName,
|
||||
ReceiveDate = string.Format("{0:g}", x.ReceiveDate),
|
||||
TrainNumber = x.TrainNumber,
|
||||
PackagingManageId = z.x.PackagingManageId,
|
||||
PackagingCode = z.x.PackagingCode,
|
||||
ProjectName = z.n.ProjectName,
|
||||
ContactName = z.x.ContactName,
|
||||
ContactPhone = z.x.ContactPhone,
|
||||
StackingPosition = z.x.StackingPosition,
|
||||
State = z.x.State,
|
||||
ReceiveMan = z.t.PersonName,
|
||||
ReceiveDate = string.Format("{0:g}", z.x.ReceiveDate),
|
||||
TrainNumber = z.x.TrainNumber,
|
||||
}).Distinct();
|
||||
return q.ToList();
|
||||
|
||||
totalCount = q.Count();
|
||||
|
||||
if (pageIndex <=0) pageIndex =1;
|
||||
if (pageSize <=0) pageSize =20;
|
||||
|
||||
return q.Skip((pageIndex -1) * pageSize).Take(pageSize).ToList();
|
||||
|
||||
}
|
||||
}
|
||||
@@ -190,8 +256,6 @@ namespace BLL
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static string GetNewPackagingCode(string projectId)
|
||||
{
|
||||
return HJGLPackagingmanageService.GetNewPackagingCode(projectId);
|
||||
|
||||
Reference in New Issue
Block a user