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)
|
||||
|
||||
Reference in New Issue
Block a user