2de696fad2
补齐焊前专项审核和焊缝外观检测流程,统一质检查询、附件处理与材料明细导出,提升业务数据追溯和组件匹配使用效率。
180 lines
7.1 KiB
C#
180 lines
7.1 KiB
C#
using FineUIPro;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
|
|
|
|
namespace BLL
|
|
{
|
|
|
|
public static class TwInputdetailService
|
|
{
|
|
|
|
|
|
|
|
#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_InputDetail
|
|
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
|
|
from mat in mm.DefaultIfEmpty()
|
|
where
|
|
(string.IsNullOrEmpty(table.Id) || x.Id.Contains(table.Id)) &&
|
|
(string.IsNullOrEmpty(table.InputMasterId) || x.InputMasterId.Contains(table.InputMasterId)) &&
|
|
(string.IsNullOrEmpty(table.PipelineComponentId) || x.PipelineComponentId.Contains(table.PipelineComponentId)) &&
|
|
(string.IsNullOrEmpty(table.MaterialCode) || x.MaterialCode.Contains(table.MaterialCode))
|
|
orderby x.SortIndex
|
|
select new Model.Tw_InOutDetailOutput
|
|
{
|
|
Id = x.Id,
|
|
InputMasterId = x.InputMasterId,
|
|
PipelineComponentId = x.PipelineComponentId,
|
|
MaterialCode = x.MaterialCode,
|
|
Code = mat.Code,
|
|
HeatNo = mat.HeatNo,
|
|
BatchNo = mat.BatchNo,
|
|
PlanNum = x.PlanNum,
|
|
ActNum = x.ActNum,
|
|
PipelineComponentCode = y.PipelineComponentCode,
|
|
MaterialName = mat.MaterialName,
|
|
MaterialDef = mat.MaterialDef,
|
|
SortIndex = x.SortIndex
|
|
}
|
|
;
|
|
|
|
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_InputDetail GetById(string Id)
|
|
{
|
|
return Funs.DB.Tw_InputDetail.FirstOrDefault(x => x.Id == Id);
|
|
}
|
|
public static void Add(Model.Tw_InputDetail newtable)
|
|
{
|
|
|
|
Model.Tw_InputDetail table = new Model.Tw_InputDetail
|
|
{
|
|
Id = newtable.Id,
|
|
InputMasterId = newtable.InputMasterId,
|
|
PipelineComponentId = newtable.PipelineComponentId,
|
|
MaterialCode = newtable.MaterialCode,
|
|
PlanNum = newtable.PlanNum,
|
|
ActNum = newtable.ActNum,
|
|
SortIndex = newtable.SortIndex
|
|
};
|
|
Funs.DB.Tw_InputDetail.InsertOnSubmit(table);
|
|
Funs.DB.SubmitChanges();
|
|
}
|
|
|
|
public static void Update(Model.Tw_InputDetail newtable)
|
|
{
|
|
|
|
Model.Tw_InputDetail table = Funs.DB.Tw_InputDetail.FirstOrDefault(x => x.Id == newtable.Id);
|
|
if (table != null)
|
|
{
|
|
table.Id = newtable.Id;
|
|
table.InputMasterId = newtable.InputMasterId;
|
|
table.PipelineComponentId = newtable.PipelineComponentId;
|
|
table.MaterialCode = newtable.MaterialCode;
|
|
table.PlanNum = newtable.PlanNum;
|
|
table.ActNum = newtable.ActNum;
|
|
table.SortIndex = newtable.SortIndex;
|
|
Funs.DB.SubmitChanges();
|
|
}
|
|
|
|
}
|
|
public static void DeleteById(string Id)
|
|
{
|
|
|
|
Model.Tw_InputDetail table = Funs.DB.Tw_InputDetail.FirstOrDefault(x => x.Id == Id);
|
|
if (table != null)
|
|
{
|
|
TwInputdetailBarCodeService.DeleteByInputDetailId(Id);
|
|
Funs.DB.Tw_InputDetail.DeleteOnSubmit(table);
|
|
Funs.DB.SubmitChanges();
|
|
}
|
|
|
|
}
|
|
|
|
public static IEnumerable GePrintListByInputMasterIds(List<string> inputMasterIds)
|
|
{
|
|
var q = from x in Funs.DB.Tw_InputDetail
|
|
join mat in Funs.DB.HJGL_MaterialCodeLib on x.MaterialCode equals mat.MaterialCode into mm
|
|
from mat in mm.DefaultIfEmpty()
|
|
join y in Funs.DB.Tw_InputMaster on x.InputMasterId equals y.Id
|
|
join warehouse in Funs.DB.Base_Warehouse on y.WarehouseId equals warehouse.WarehouseId into warehouses
|
|
from warehouse in warehouses.DefaultIfEmpty()
|
|
join person in Funs.DB.Person_Persons on y.CreateMan equals person.PersonId into persons
|
|
from person in persons.DefaultIfEmpty()
|
|
where inputMasterIds.Contains(x.InputMasterId)
|
|
orderby y.CusBillCode, x.SortIndex
|
|
select new
|
|
{
|
|
y.CusBillCode,
|
|
WarehouseName = warehouse == null ? y.WarehouseCode : warehouse.WarehouseName,
|
|
y.TypeInt,
|
|
CreateManName = person == null ? y.CreateMan : person.PersonName,
|
|
y.CreateDate,
|
|
材料主编码 = x.MaterialCode,
|
|
材料编码 = mat.Code,
|
|
炉号 = mat.HeatNo,
|
|
批号 = mat.BatchNo,
|
|
材料名称 = mat.MaterialName,
|
|
材料描述 = mat.MaterialDef,
|
|
计划数量 = x.PlanNum,
|
|
实际数量 = x.ActNum,
|
|
y.Remark
|
|
};
|
|
// 类型字典无法转换为 SQL,先完成数据库查询,再生成固定顺序的 Excel 列。
|
|
return q.ToList().Select(x => new
|
|
{
|
|
编号 = x.CusBillCode,
|
|
仓库 = x.WarehouseName,
|
|
类型 = TwConst.TypeIntMap.FirstOrDefault(y => y.Value == x.TypeInt).Key,
|
|
发起人 = x.CreateManName,
|
|
发起时间 = x.CreateDate,
|
|
x.材料主编码,
|
|
x.材料编码,
|
|
x.炉号,
|
|
x.批号,
|
|
x.材料名称,
|
|
x.材料描述,
|
|
x.计划数量,
|
|
x.实际数量,
|
|
备注 = x.Remark
|
|
}).ToList();
|
|
}
|
|
}
|
|
}
|