Files
SGGL_SHJ/SGGL/BLL/CLGL/TwInOutplandetailRelationService.cs
T
lpf 201443e437 feat(hjgl): 支持按焊口匹配和回写管线材料
管线材料导入需要关联到具体焊口,并允许按材料编码匹配库存后回写
材料主编码。新增 HJGL_PipeLineMat 的焊口和材料编码字段,材料匹配、
任务生成和出库关系同步按焊口维度处理,避免仅按组件匹配导致材料
范围不准确。
2026-06-11 10:39:58 +08:00

190 lines
7.6 KiB
C#

using FineUIPro;
using Model;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
namespace BLL
{
public static class TwInoutplandetailRelationService
{
#region
/// <summary>
/// 记录数
/// </summary>
public static int Count
{
get;
set;
}
public static IQueryable<Model.Tw_InOutPlanDetail_Relation> GetTw_InOutPlanDetail_RelationByModle(Model.Tw_InOutPlanDetail_Relation table)
{
var q = from x in Funs.DB.Tw_InOutPlanDetail_Relation
where
(string.IsNullOrEmpty(table.Id) || x.Id.Contains(table.Id)) &&
(string.IsNullOrEmpty(table.PipelineId) || x.PipelineId.Contains(table.PipelineId)) &&
(string.IsNullOrEmpty(table.InOutPlanMasterId) || x.InOutPlanMasterId.Contains(table.InOutPlanMasterId)) &&
(string.IsNullOrEmpty(table.MaterialCode) || x.MaterialCode.Contains(table.MaterialCode)) &&
(string.IsNullOrEmpty(table.PrefabricatedComponents) || x.PrefabricatedComponents.Contains(table.PrefabricatedComponents))
select x
;
return q;
}
/// <summary>
/// 获取分页列表
/// </summary>
/// <param name="table"></param>
/// <param name="grid1"></param>
/// <returns></returns>
public static IEnumerable GetListData(Model.Tw_InOutPlanDetail_Relation table, Grid grid1)
{
var q = GetTw_InOutPlanDetail_RelationByModle(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
join y in Funs.DB.HJGL_Pipeline on x.PipelineId equals y.PipelineId
join mat in Funs.DB.HJGL_MaterialCodeLib on x.MaterialCode equals mat.MaterialCode into mm
from mat in mm.DefaultIfEmpty()
orderby x.PipelineId, x.PrefabricatedComponents
select new
{
x.Id,
x.PipelineId,
y.PipelineCode,
x.InOutPlanMasterId,
x.MaterialCode,
Code = mat.Code,
mat.HeatNo,
mat.BatchNo,
x.PrefabricatedComponents,
x.Number,
mat.MaterialName,
mat.MaterialDef
};
}
#endregion
public static Model.Tw_InOutPlanDetail_Relation GetById(string Id)
{
return Funs.DB.Tw_InOutPlanDetail_Relation.FirstOrDefault(x => x.Id == Id);
}
public static Model.Tw_InOutPlanDetail_Relation GetByPipelineId(string pipelineId, string WarehouseCode)
{
int typeInt = (int)TwConst.TypeInt.;
var q = from x in Funs.DB.Tw_InOutPlanDetail_Relation
join y in Funs.DB.Tw_InOutPlanMaster on x.InOutPlanMasterId equals y.Id
where x.PipelineId == pipelineId && y.WarehouseCode == WarehouseCode && y.TypeInt != typeInt
select x;
return q.FirstOrDefault();
}
public static void Add(Model.Tw_InOutPlanDetail_Relation newtable)
{
Model.Tw_InOutPlanDetail_Relation table = new Model.Tw_InOutPlanDetail_Relation
{
Id = newtable.Id,
PipelineId = newtable.PipelineId,
InOutPlanMasterId = newtable.InOutPlanMasterId,
MaterialCode = newtable.MaterialCode,
PrefabricatedComponents = newtable.PrefabricatedComponents,
Number = newtable.Number,
WeldJointId = newtable.WeldJointId,
};
Funs.DB.Tw_InOutPlanDetail_Relation.InsertOnSubmit(table);
Funs.DB.SubmitChanges();
}
/// <summary>
/// 批量添加计划明细
/// </summary>
/// <param name="list"></param>
/// <param name="inoutPlanMasterId"></param>
public static void AddList(IEnumerable<Model.Tw_InOutPlanDetail_Relation> list, string inoutPlanMasterId)
{
foreach (var item in list)
{
item.Id = SQLHelper.GetNewID();
item.InOutPlanMasterId = inoutPlanMasterId;
Add(item);
}
}
public static void Update(Model.Tw_InOutPlanDetail_Relation newtable)
{
Model.Tw_InOutPlanDetail_Relation table = Funs.DB.Tw_InOutPlanDetail_Relation.FirstOrDefault(x => x.Id == newtable.Id);
if (table != null)
{
table.Id = newtable.Id;
table.PipelineId = newtable.PipelineId;
table.InOutPlanMasterId = newtable.InOutPlanMasterId;
table.MaterialCode = newtable.MaterialCode;
table.PrefabricatedComponents = newtable.PrefabricatedComponents;
table.Number = newtable.Number;
table.WeldJointId = newtable.WeldJointId;
Funs.DB.SubmitChanges();
}
}
public static void DeleteById(string Id)
{
Model.Tw_InOutPlanDetail_Relation table = Funs.DB.Tw_InOutPlanDetail_Relation.FirstOrDefault(x => x.Id == Id);
if (table != null)
{
Funs.DB.Tw_InOutPlanDetail_Relation.DeleteOnSubmit(table);
Funs.DB.SubmitChanges();
}
}
public static void DeleteByInOutPlanMasterId(string inoutPlanMasterId)
{
var list = Funs.DB.Tw_InOutPlanDetail_Relation.Where(x => x.InOutPlanMasterId == inoutPlanMasterId);
if (list != null)
{
Funs.DB.Tw_InOutPlanDetail_Relation.DeleteAllOnSubmit(list);
Funs.DB.SubmitChanges();
}
}
public static IEnumerable GetPrintListByOutputMasterIds(List<string> outputMasterIds)
{
var q = from x in Funs.DB.Tw_InOutPlanDetail_Relation
join y in Funs.DB.HJGL_MaterialCodeLib on x.MaterialCode equals y.MaterialCode
join plan in Funs.DB.Tw_InOutPlanMaster on x.InOutPlanMasterId equals plan.Id
join master in Funs.DB.Tw_OutputMaster on plan.Id equals master.InOutPlanMasterId
join pipe in Funs.DB.HJGL_Pipeline on x.PipelineId equals pipe.PipelineId
where outputMasterIds.Contains(master.Id)
orderby master.CusBillCode
select new
{
= master.CusBillCode,
线 = pipe.PipelineCode,
= x.PrefabricatedComponents,
= x.MaterialCode,
= y.Code,
= y.HeatNo,
= y.BatchNo,
= y.MaterialName,
= y.MaterialDef,
= y.MaterialUnit,
= x.Number,
};
return q;
}
}
}