feat: 完善焊接质量检查和材料管理
补齐焊前专项审核和焊缝外观检测流程,统一质检查询、附件处理与材料明细导出,提升业务数据追溯和组件匹配使用效率。
This commit is contained in:
@@ -42,6 +42,18 @@ namespace BLL
|
||||
g.Key,
|
||||
RealNum = g.Sum(x => x.ActNum) ?? 0,
|
||||
}).ToList();
|
||||
///实际材料出库数量列表
|
||||
var RealOutMateriaList = (from x in db.Tw_OutputDetail
|
||||
join master in db.Tw_OutputMaster on x.OutputMasterId equals master.Id
|
||||
where master.ProjectId == projectid && master.WarehouseId == WarehouseId
|
||||
group x by x.MaterialCode
|
||||
into g
|
||||
where (string.IsNullOrEmpty(materialCode) || g.Key.Contains(materialCode))
|
||||
select new
|
||||
{
|
||||
g.Key,
|
||||
OutputNum = g.Sum(x => x.ActNum) ?? 0,
|
||||
}).ToList();
|
||||
//库存数量
|
||||
var tw_MaterialStock = (from x in db.Tw_MaterialStock
|
||||
where x.WarehouseId == WarehouseId && x.ProjectId == projectid
|
||||
@@ -50,6 +62,7 @@ namespace BLL
|
||||
var needMateriaList = NeedOutMateriaList.ToList();
|
||||
var materialCodeList = needMateriaList.Select(x => x.Key)
|
||||
.Union(RealInMateriaList.Select(x => x.Key))
|
||||
.Union(RealOutMateriaList.Select(x => x.Key))
|
||||
.Distinct()
|
||||
.ToList();
|
||||
|
||||
@@ -62,6 +75,8 @@ namespace BLL
|
||||
from x in needGroup.DefaultIfEmpty()
|
||||
join y in RealInMateriaList on code equals y.Key into realGroup
|
||||
from y in realGroup.DefaultIfEmpty()
|
||||
join o in RealOutMateriaList on code equals o.Key into outputGroup
|
||||
from o in outputGroup.DefaultIfEmpty()
|
||||
join z in materialInfoList on code equals z.MaterialCode into infoGroup
|
||||
from z in infoGroup.DefaultIfEmpty()
|
||||
join m in tw_MaterialStock on code equals m.PipeLineMatCode into stockGroup
|
||||
@@ -73,6 +88,7 @@ namespace BLL
|
||||
StockNum = m == null ? 0 : (decimal)m.StockNum,
|
||||
NeedNum = x == null ? 0 : x.NeedNum,
|
||||
RealNum = y == null ? 0 : y.RealNum,
|
||||
OutputNum = o == null ? 0 : o.OutputNum,
|
||||
Code = z == null ? null : z.Code,
|
||||
HeatNo = z == null ? null : z.HeatNo,
|
||||
BatchNo = z == null ? null : z.BatchNo,
|
||||
@@ -449,7 +465,8 @@ namespace BLL
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取单位工程下当前区域内同时存在已焊口和未焊口的组件汇总。
|
||||
/// 获取单位工程下当前区域的组件导出汇总。
|
||||
/// 每个组件返回一行;未焊达因量按未焊口统计,材料信息按当前区域组件材料明细统计。
|
||||
/// </summary>
|
||||
public static List<Tw_PartialWeldedComponentOutput> GetPartialWeldedComponents(string projectId, string unitWorkId, string pipeArea, string warehouseCode)
|
||||
{
|
||||
@@ -476,17 +493,53 @@ namespace BLL
|
||||
z.UnitWorkId,
|
||||
m.UnitWorkName,
|
||||
x.PrefabricatedComponents,
|
||||
x.MaterialCode,
|
||||
x.MaterialCode2,
|
||||
x.Number,
|
||||
w.WeldJointId,
|
||||
w.Size,
|
||||
w.WeldingDailyId
|
||||
}).ToList();
|
||||
|
||||
var partialComponents = componentWeldRows
|
||||
var materialCodes = componentWeldRows
|
||||
.Where(x => !string.IsNullOrEmpty(x.MaterialCode))
|
||||
.Select(x => x.MaterialCode)
|
||||
.Distinct()
|
||||
.ToList();
|
||||
var materialCodeLibByMaterialCode = materialCodes.Any()
|
||||
? db.HJGL_MaterialCodeLib
|
||||
.Where(x => materialCodes.Contains(x.MaterialCode))
|
||||
.ToList()
|
||||
.GroupBy(x => x.MaterialCode)
|
||||
.ToDictionary(x => x.Key, x => x.First())
|
||||
: new Dictionary<string, HJGL_MaterialCodeLib>();
|
||||
|
||||
var componentExports = componentWeldRows
|
||||
.GroupBy(x => new { x.PipelineId, x.PipelineCode, x.UnitWorkId, x.UnitWorkName, x.PrefabricatedComponents })
|
||||
.Select(group =>
|
||||
{
|
||||
var weldJoints = group.GroupBy(x => x.WeldJointId).Select(x => x.First()).ToList();
|
||||
int weldedCount = weldJoints.Count(x => !string.IsNullOrEmpty(x.WeldingDailyId));
|
||||
int totalCount = weldJoints.Count;
|
||||
// 材料编码优先采用匹配页面使用的 MaterialCode2,数量按当前区域组件材料明细汇总。
|
||||
var componentMaterialRows = group
|
||||
.Where(x => (x.Number ?? 0) > 0)
|
||||
.ToList();
|
||||
var materialGroups = componentMaterialRows
|
||||
.Select(x => new
|
||||
{
|
||||
MaterialCode = GetExportMaterialCode(x.MaterialCode, x.MaterialCode2, materialCodeLibByMaterialCode),
|
||||
Quantity = x.Number ?? 0
|
||||
})
|
||||
.Where(x => !string.IsNullOrEmpty(x.MaterialCode))
|
||||
.GroupBy(x => x.MaterialCode)
|
||||
.OrderBy(x => x.Key)
|
||||
.Select(x => new
|
||||
{
|
||||
MaterialCode = x.Key,
|
||||
Quantity = x.Sum(y => y.Quantity)
|
||||
})
|
||||
.ToList();
|
||||
return new Tw_PartialWeldedComponentOutput
|
||||
{
|
||||
UnitWorkId = group.Key.UnitWorkId,
|
||||
@@ -498,26 +551,30 @@ namespace BLL
|
||||
PipeAreaText = pipeArea == PipelineService.PipeArea_SHOP ? "工厂预制" : "现场安装",
|
||||
TotalWeldJointCount = totalCount,
|
||||
WeldedWeldJointCount = weldedCount,
|
||||
UnweldedWeldJointCount = totalCount - weldedCount
|
||||
UnweldedWeldJointCount = totalCount - weldedCount,
|
||||
UnweldedDin = weldJoints
|
||||
.Where(x => string.IsNullOrEmpty(x.WeldingDailyId))
|
||||
.Sum(x => x.Size ?? 0),
|
||||
MaterialCode = string.Join("\n", materialGroups.Select(x => x.MaterialCode)),
|
||||
MaterialQuantity = string.Join("\n", materialGroups.Select(x => x.Quantity.ToString()))
|
||||
};
|
||||
})
|
||||
.Where(x => x.WeldedWeldJointCount > 0 && x.UnweldedWeldJointCount > 0)
|
||||
.OrderBy(x => x.PipelineCode)
|
||||
.ThenBy(x => x.PrefabricatedComponents)
|
||||
.ToList();
|
||||
|
||||
if (!partialComponents.Any())
|
||||
if (!componentExports.Any())
|
||||
{
|
||||
return partialComponents;
|
||||
return componentExports;
|
||||
}
|
||||
|
||||
// 导出匹配率复用页面匹配规则,保证区域、未焊口及续作组件优先级完全一致。
|
||||
var pipelineIds = partialComponents.Select(x => x.PipelineId).Distinct().ToList();
|
||||
var pipelineIds = componentExports.Select(x => x.PipelineId).Distinct().ToList();
|
||||
var matchOutputs = GetPipeMatMatch(projectId, pipelineIds, warehouseCode, null, pipeArea);
|
||||
var componentRates = matchOutputs
|
||||
.GroupBy(x => GetComponentKey(x.PipelineId, x.PrefabricatedComponents))
|
||||
.ToDictionary(x => x.Key, x => x.First().ComponentMatchRate ?? 0);
|
||||
foreach (var component in partialComponents)
|
||||
foreach (var component in componentExports)
|
||||
{
|
||||
decimal componentRate;
|
||||
componentRates.TryGetValue(GetComponentKey(component.PipelineId, component.PrefabricatedComponents), out componentRate);
|
||||
@@ -525,10 +582,24 @@ namespace BLL
|
||||
component.ComponentMatchRateString = Math.Round(componentRate * 100, 2).ToString() + "%";
|
||||
}
|
||||
|
||||
return partialComponents;
|
||||
return componentExports;
|
||||
}
|
||||
}
|
||||
|
||||
private static string GetExportMaterialCode(string materialCode, string materialCode2, Dictionary<string, HJGL_MaterialCodeLib> materialCodeLibByMaterialCode)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(materialCode2))
|
||||
{
|
||||
return materialCode2;
|
||||
}
|
||||
|
||||
HJGL_MaterialCodeLib materialLib;
|
||||
return !string.IsNullOrEmpty(materialCode)
|
||||
&& materialCodeLibByMaterialCode.TryGetValue(materialCode, out materialLib)
|
||||
? materialLib.Code
|
||||
: materialCode;
|
||||
}
|
||||
|
||||
private static string GetJointAttributeByPipeArea(string pipeArea)
|
||||
{
|
||||
if (pipeArea == PipelineService.PipeArea_SHOP)
|
||||
|
||||
@@ -133,11 +133,19 @@ namespace BLL
|
||||
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,
|
||||
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,
|
||||
@@ -146,8 +154,26 @@ namespace BLL
|
||||
材料描述 = mat.MaterialDef,
|
||||
计划数量 = x.PlanNum,
|
||||
实际数量 = x.ActNum,
|
||||
y.Remark
|
||||
};
|
||||
return q;
|
||||
// 类型字典无法转换为 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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -151,13 +151,26 @@ namespace BLL
|
||||
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 y in Funs.DB.HJGL_MaterialCodeLib on x.MaterialCode equals y.MaterialCode into materials
|
||||
from y in materials.DefaultIfEmpty()
|
||||
join master in Funs.DB.Tw_OutputMaster on x.OutputMasterId equals master.Id
|
||||
join plan in Funs.DB.Tw_InOutPlanMaster on master.InOutPlanMasterId equals plan.Id into plans
|
||||
from plan in plans.DefaultIfEmpty()
|
||||
join warehouse in Funs.DB.Base_Warehouse on master.WarehouseId equals warehouse.WarehouseId into warehouses
|
||||
from warehouse in warehouses.DefaultIfEmpty()
|
||||
join person in Funs.DB.Person_Persons on master.CreateMan equals person.PersonId into persons
|
||||
from person in persons.DefaultIfEmpty()
|
||||
join unit in Funs.DB.Base_Unit on master.ReqUnitId equals unit.UnitId into units
|
||||
from unit in units.DefaultIfEmpty()
|
||||
where outputMasterIds.Contains(x.OutputMasterId)
|
||||
orderby master.CusBillCode
|
||||
select new
|
||||
{
|
||||
出库单编号 = master.CusBillCode,
|
||||
master.CusBillCode,
|
||||
WarehouseName = warehouse == null ? master.WarehouseCode : warehouse.WarehouseName,
|
||||
master.TypeInt,
|
||||
CreateManName = person == null ? master.CreateMan : person.PersonName,
|
||||
master.CreateDate,
|
||||
材料主编码 = x.MaterialCode,
|
||||
材料编码 = y.Code,
|
||||
炉号 = y.HeatNo,
|
||||
@@ -166,8 +179,30 @@ namespace BLL
|
||||
材料描述 = y.MaterialDef,
|
||||
计划数量 = x.PlanNum,
|
||||
实际数量 = x.ActNum,
|
||||
master.WarehouseDate,
|
||||
ReqUnitName = unit == null ? master.ReqUnitId : unit.UnitName,
|
||||
Remark = plan == null ? null : plan.Remark
|
||||
};
|
||||
return q;
|
||||
// 类型字典无法转换为 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.WarehouseDate,
|
||||
领用单位 = x.ReqUnitName,
|
||||
备注 = x.Remark
|
||||
}).ToList();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user