SGGL_SHJ/SGGL/BLL/CLGL/TwOutputdetailService..cs

168 lines
6.7 KiB
C#
Raw Permalink Normal View History

2024-09-18 10:48:34 +08:00
using FineUIPro;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
namespace BLL
{
public static class TwOutputdetailService
{
#region
/// <summary>
/// 记录数
/// </summary>
public static int Count
{
get;
set;
}
public static IQueryable<Model.Tw_InOutDetailOutput> GetByModle(Model.Tw_InOutDetailOutput table)
{
var q = from x in Funs.DB.Tw_OutputDetail
join y in Funs.DB.HJGL_Pipeline_Component on x.PipelineComponentId equals y.PipelineComponentId into yy
from y in yy.DefaultIfEmpty()
join mat in Funs.DB.HJGL_MaterialCodeLib on x.MaterialCode equals mat.MaterialCode into mm
2024-09-18 10:48:34 +08:00
from mat in mm.DefaultIfEmpty()
2024-09-27 18:17:21 +08:00
join master in Funs.DB.Tw_OutputMaster on x.OutputMasterId equals master.Id into masters
from master in masters.DefaultIfEmpty()
join stock in Funs.DB.Tw_MaterialStock on new { x.MaterialCode, master.WarehouseCode, master.ProjectId } equals new { MaterialCode = stock.PipeLineMatCode, stock.WarehouseCode, stock.ProjectId } into st
2024-09-24 20:38:50 +08:00
from stock in st.DefaultIfEmpty()
2024-09-18 10:48:34 +08:00
where
(string.IsNullOrEmpty(table.Id) || x.Id.Contains(table.Id)) &&
(string.IsNullOrEmpty(table.OutputMasterId) || x.OutputMasterId.Contains(table.OutputMasterId)) &&
(string.IsNullOrEmpty(table.PipelineComponentId) || x.PipelineComponentId.Contains(table.PipelineComponentId)) &&
(string.IsNullOrEmpty(table.MaterialCode) || x.MaterialCode.Contains(table.MaterialCode)) &&
(table.TypeInt == null || master.TypeInt == table.TypeInt)
2024-09-18 10:48:34 +08:00
select new Model.Tw_InOutDetailOutput
{
Id = x.Id,
OutputMasterId = x.OutputMasterId,
CusBillCode = master.CusBillCode,
TypeInt = master.TypeInt,
2024-09-18 10:48:34 +08:00
PipelineComponentId = x.PipelineComponentId,
MaterialCode = x.MaterialCode,
PlanNum = x.PlanNum,
ActNum = x.ActNum,
PipelineComponentCode = y.PipelineComponentCode,
MaterialName = mat.MaterialName,
2024-09-24 20:38:50 +08:00
StockNum = stock.StockNum ?? 0,
DiffNum = (x.ActNum ?? 0) - (x.PlanNum ?? 0),
2024-09-27 18:17:21 +08:00
MaterialDef = mat.MaterialDef
}
2024-09-18 10:48:34 +08:00
;
return q;
}
/// <summary>
/// 获取分页列表
/// </summary>
/// <param name="table"></param>
/// <param name="grid1"></param>
/// <returns></returns>
public static IEnumerable GetListData(Model.Tw_InOutDetailOutput table, Grid grid1)
{
var q = GetByModle(table);
Count = q.Count();
if (Count == 0)
{
return null;
}
q = q.Skip(grid1.PageSize * grid1.PageIndex).Take(grid1.PageSize);
// q = SortConditionHelper.SortingAndPaging(q, Grid1.SortField, Grid1.SortDirection, Grid1.PageIndex, Grid1.PageSize);
return from x in q
select x;
}
#endregion
public static Model.Tw_OutputDetail GetById(string Id)
{
return Funs.DB.Tw_OutputDetail.FirstOrDefault(x => x.Id == Id);
}
/// <summary>
/// 根据明细Id获取对应的出库主表信息
/// </summary>
/// <param name="Id"></param>
/// <returns></returns>
public static Model.Tw_InOutMasterOutput GetInOutMasterById(string Id)
{
var detail = Funs.DB.Tw_OutputDetail.FirstOrDefault(x => x.Id == Id);
if (detail == null) return null;
Model.Tw_InOutMasterOutput fliter = new Model.Tw_InOutMasterOutput
{
Id = detail.OutputMasterId
};
var result= TwOutputmasterService.GetListData(fliter).FirstOrDefault();
2024-09-18 10:48:34 +08:00
return result;
}
2024-09-18 10:48:34 +08:00
public static void Add(Model.Tw_OutputDetail newtable)
{
Model.Tw_OutputDetail table = new Model.Tw_OutputDetail
{
Id = newtable.Id,
OutputMasterId = newtable.OutputMasterId,
PipelineComponentId = newtable.PipelineComponentId,
MaterialCode = newtable.MaterialCode,
PlanNum = newtable.PlanNum,
ActNum = newtable.ActNum,
};
Funs.DB.Tw_OutputDetail.InsertOnSubmit(table);
Funs.DB.SubmitChanges();
}
public static void Update(Model.Tw_OutputDetail newtable)
{
Model.Tw_OutputDetail table = Funs.DB.Tw_OutputDetail.FirstOrDefault(x => x.Id == newtable.Id);
if (table != null)
{
table.Id = newtable.Id;
table.OutputMasterId = newtable.OutputMasterId;
table.PipelineComponentId = newtable.PipelineComponentId;
table.MaterialCode = newtable.MaterialCode;
table.PlanNum = newtable.PlanNum;
table.ActNum = newtable.ActNum;
Funs.DB.SubmitChanges();
}
}
public static void DeleteById(string Id)
{
Model.Tw_OutputDetail table = Funs.DB.Tw_OutputDetail.FirstOrDefault(x => x.Id == Id);
if (table != null)
{
Funs.DB.Tw_OutputDetail.DeleteOnSubmit(table);
Funs.DB.SubmitChanges();
}
}
2024-12-10 15:18:31 +08:00
public static IEnumerable GetPrintListByOutputMasterIds(List<string> outputMasterIds)
{
var q = from x in Funs.DB.Tw_OutputDetail
join y in Funs.DB.HJGL_MaterialCodeLib on x.MaterialCode equals y.MaterialCode
join master in Funs.DB.Tw_OutputMaster on x.OutputMasterId equals master.Id
where outputMasterIds.Contains(x.OutputMasterId)
orderby master.CusBillCode
select new
{
= master.CusBillCode,
= x.MaterialCode,
= y.MaterialName,
= y.MaterialDef,
= x.PlanNum,
= x.ActNum,
};
2024-12-10 15:18:31 +08:00
return q;
}
2024-09-18 10:48:34 +08:00
}
}