fix:修改安装清单查询速度。
This commit is contained in:
parent
5809a5fb48
commit
7ea2473a55
|
|
@ -0,0 +1,92 @@
|
|||
USE [SGGLDB]
|
||||
GO
|
||||
|
||||
/****** Object: View [dbo].[View_HJGL_InstallData] Script Date: 2026/4/16 0:12:44 ******/
|
||||
SET ANSI_NULLS ON
|
||||
GO
|
||||
|
||||
SET QUOTED_IDENTIFIER ON
|
||||
GO
|
||||
|
||||
ALTER VIEW [dbo].[View_HJGL_InstallData]
|
||||
AS
|
||||
WITH TwOutPutData as (select distinct twRelation.PipelineId,
|
||||
outdetail.Id as TwOutputDetailId,
|
||||
twRelation.MaterialCode,
|
||||
master.Id as OutputMasterId
|
||||
from Tw_OutputMaster master
|
||||
join Tw_OutputDetail outdetail on outdetail.OutputMasterId = master.Id
|
||||
join Tw_InOutPlanMaster planmaster on planmaster.Id = master.InOutPlanMasterId
|
||||
join Tw_InOutPlanDetail_Relation twRelation
|
||||
on twRelation.InOutPlanMasterId = planmaster.Id and
|
||||
outdetail.MaterialCode = twRelation.MaterialCode
|
||||
where master.TypeInt=70),
|
||||
PrefabricatedData AS (SELECT pipe.PipeLineMatId as Id,
|
||||
line.PipelineCode,
|
||||
pipe.PrefabricatedComponents as Code,
|
||||
'预制组件' as TypeStr,
|
||||
'' as Matdef,
|
||||
CAST(NULL AS DECIMAL(18, 2)) as Number, -- 明确指定数据类型
|
||||
pack.PackagingCode,
|
||||
trainnumber.TrainNumber,
|
||||
line.FlowingSection,
|
||||
line.UnitWorkId,
|
||||
line.ProjectId,
|
||||
pack.StackingPosition
|
||||
FROM dbo.HJGL_PipeLineMat pipe
|
||||
INNER JOIN dbo.HJGL_Pipeline line -- 改为INNER JOIN,如果管道必须存在
|
||||
ON pipe.PipelineId = line.PipelineId
|
||||
LEFT JOIN dbo.HJGL_MaterialCodeLib lib
|
||||
ON lib.MaterialCode = pipe.MaterialCode
|
||||
LEFT JOIN HJGL_Pipeline_Component comonent
|
||||
ON comonent.PipelineComponentCode = pipe.PrefabricatedComponents
|
||||
LEFT JOIN HJGL_PackagingManageDetail packdetail
|
||||
ON packdetail.PipelineComponentId = comonent.PipelineComponentId
|
||||
LEFT JOIN HJGL_PackagingManage pack
|
||||
ON packdetail.PackagingManageId = pack.PackagingManageId
|
||||
AND pack.ProjectId = line.ProjectId -- 添加项目关联条件
|
||||
LEFT JOIN HJGL_TrainNumberManage trainnumber
|
||||
ON pack.TrainNumberId = trainnumber.Id
|
||||
WHERE line.PipeArea = '1'
|
||||
and (pipe.PrefabricatedComponents != ''
|
||||
AND pipe.PrefabricatedComponents IS NOT NULL and pipe.PrefabricatedComponents not in('裕-量'))),
|
||||
LooseComponentsData AS (SELECT distinct pipe.PipeLineMatId as Id,
|
||||
line.PipelineCode,
|
||||
pipe.MaterialCode as Code,
|
||||
'预制散件' as TypeStr,
|
||||
lib.MaterialDef as Matdef,
|
||||
cast( packdetail.Number as DECIMAL(18, 2)) as Number,
|
||||
pack.PackagingCode,
|
||||
trainnumber.TrainNumber,
|
||||
line.FlowingSection,
|
||||
line.UnitWorkId,
|
||||
line.ProjectId,
|
||||
pack.StackingPosition
|
||||
FROM dbo.HJGL_PipeLineMat pipe
|
||||
INNER JOIN HJGL_Pipeline line -- 改为INNER JOIN
|
||||
ON pipe.PipelineId = line.PipelineId
|
||||
LEFT JOIN dbo.HJGL_MaterialCodeLib lib
|
||||
ON lib.MaterialCode = pipe.MaterialCode
|
||||
LEFT JOIN HJGL_PackagingManageDetail packdetail
|
||||
ON packdetail.MaterialCode = pipe.MaterialCode
|
||||
LEFT JOIN TwOutPutData twOutPutData
|
||||
ON twOutPutData.PipelineId = pipe.PipelineId and
|
||||
twOutPutData.MaterialCode = packdetail.MaterialCode
|
||||
LEFT JOIN HJGL_PackagingManage pack
|
||||
ON packdetail.PackagingManageId = pack.PackagingManageId
|
||||
AND pack.ProjectId = line.ProjectId -- 添加项目关联条件
|
||||
LEFT JOIN HJGL_TrainNumberManage trainnumber
|
||||
ON pack.TrainNumberId = trainnumber.Id
|
||||
where line.PipeArea = '1'
|
||||
and (pipe.PrefabricatedComponents is null or pipe.PrefabricatedComponents = '') )
|
||||
|
||||
-- 合并结果
|
||||
SELECT *
|
||||
FROM PrefabricatedData
|
||||
UNION ALL
|
||||
SELECT *
|
||||
FROM LooseComponentsData
|
||||
|
||||
GO
|
||||
|
||||
|
||||
|
|
@ -474,18 +474,29 @@ namespace FineUIPro.Web.CLGL
|
|||
return;
|
||||
}
|
||||
string planId = Grid1.SelectedRowID;
|
||||
string message = TwOutputmasterService.RevokeGenOutMasterByPlanId(planId);
|
||||
if (string.IsNullOrEmpty(message))
|
||||
var planMaster = BLL.TwInOutplanmasterService.GetById(planId);
|
||||
switch (planMaster.State)
|
||||
{
|
||||
ShowNotify("撤销出库成功!", MessageBoxIcon.Success);
|
||||
BindGrid();
|
||||
}
|
||||
else
|
||||
{
|
||||
Alert.ShowInTop(message, MessageBoxIcon.Warning);
|
||||
return;
|
||||
case (int)TwConst.State.已审核:
|
||||
planMaster.State = (int)TwConst.State.待审核;
|
||||
planMaster.AuditMan = null;
|
||||
planMaster.AuditDate = null;
|
||||
TwInOutplanmasterService.Update(planMaster);
|
||||
BindGrid();
|
||||
ShowNotify("撤销审核成功!", MessageBoxIcon.Success);
|
||||
|
||||
}
|
||||
break;
|
||||
case (int)TwConst.State.已完成:
|
||||
TwOutputmasterService.RevokeGenOutMasterByPlanId(planId);
|
||||
BindGrid();
|
||||
ShowNotify("撤销出库单成功!", MessageBoxIcon.Success);
|
||||
break;
|
||||
|
||||
|
||||
default:
|
||||
Alert.ShowInTop("请选择有效的计划!", MessageBoxIcon.Warning);
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -17033,7 +17033,7 @@
|
|||
</COMReference>
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
|
||||
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v15.0\WebApplications\Microsoft.WebApplication.targets" />
|
||||
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v18.0\WebApplications\Microsoft.WebApplication.targets" />
|
||||
<ProjectExtensions>
|
||||
<VisualStudio>
|
||||
<FlavorProperties GUID="{349c5851-65df-11da-9384-00065b846f21}">
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
using BLL;
|
||||
using BLL;
|
||||
using MiniExcelLibs;
|
||||
using Model;
|
||||
using System;
|
||||
|
|
@ -213,29 +213,24 @@ namespace FineUIPro.Web.HJGL.PreDesign
|
|||
private void BindGrid()
|
||||
{
|
||||
if (tvControlItem.SelectedNode == null) return;
|
||||
var view_HJGL_InstallDatas = BindData(Grid1.PageIndex+1, Grid1.PageSize,out int totalCount);
|
||||
var view_HJGL_InstallDatas = BindData(Grid1.PageIndex+1, Grid1.PageSize,out int totalCount, out int componentCount, out int partCount);
|
||||
// 2.获取当前分页数据
|
||||
Grid1.RecordCount = totalCount;
|
||||
var table = view_HJGL_InstallDatas;
|
||||
Grid1.DataSource = table;
|
||||
Grid1.DataBind();
|
||||
|
||||
// 更新汇总信息
|
||||
UpdateSummary();
|
||||
// 更新汇总信息(使用已统计的数据)
|
||||
UpdateSummary(componentCount, partCount);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 更新汇总信息
|
||||
/// </summary>
|
||||
private void UpdateSummary()
|
||||
private void UpdateSummary(int componentCount, int partCount)
|
||||
{
|
||||
try
|
||||
{
|
||||
var baseQuery = GetIQueryableInstallDatas();
|
||||
// 计算汇总数据
|
||||
var componentCount = baseQuery.Count(x => x.TypeStr == "预制组件");
|
||||
var partCount = baseQuery.Count(x => x.TypeStr == "预制散件");
|
||||
|
||||
// 更新汇总标签
|
||||
lblSummary1.Text = $"预制组件数量:{componentCount}";
|
||||
lblSummary2.Text = $"预制散件数量:{partCount}";
|
||||
|
|
@ -252,14 +247,27 @@ namespace FineUIPro.Web.HJGL.PreDesign
|
|||
/// 查询数据
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
private List<View_HJGL_InstallData> BindData(int pageIndex, int pageSize, out int totalCount)
|
||||
private List<View_HJGL_InstallData> BindData(int pageIndex, int pageSize, out int totalCount, out int componentCount, out int partCount)
|
||||
{
|
||||
var baseQuery = GetIQueryableInstallDatas();
|
||||
totalCount = baseQuery.Count();
|
||||
|
||||
// 一次性统计所有需要的数据(使用 GroupBy 优化)
|
||||
var stats = baseQuery
|
||||
.GroupBy(x => x.TypeStr)
|
||||
.Select(g => new { TypeStr = g.Key, Count = g.Count() })
|
||||
.ToList();
|
||||
|
||||
// 从统计结果中提取数据
|
||||
totalCount = stats.Sum(s => s.Count);
|
||||
componentCount = stats.FirstOrDefault(s => s.TypeStr == "预制组件")?.Count ?? 0;
|
||||
partCount = stats.FirstOrDefault(s => s.TypeStr == "预制散件")?.Count ?? 0;
|
||||
|
||||
// 分页保护
|
||||
if (pageIndex <= 0) pageIndex = 1;
|
||||
if (pageSize <= 0) pageSize = 10;
|
||||
|
||||
var query = baseQuery.Skip((pageIndex - 1) * pageSize).Take(pageSize).ToList();
|
||||
|
||||
// 预制组件数量显示为1,预制散件保持原始数量
|
||||
foreach (var item in query)
|
||||
{
|
||||
|
|
@ -307,9 +315,7 @@ namespace FineUIPro.Web.HJGL.PreDesign
|
|||
{
|
||||
baseQuery = baseQuery.Where(x => x.PipelineCode.Contains(txtPipelineCode.Text.Trim()));
|
||||
|
||||
}
|
||||
// 过滤组件编号/材料编码值为"裕-量"的记录
|
||||
baseQuery = baseQuery.Where(x => x.Code != "裕-量");
|
||||
}
|
||||
baseQuery = baseQuery.OrderBy(x => x.PipelineCode).ThenBy(x => x.Code);
|
||||
|
||||
return baseQuery;
|
||||
|
|
|
|||
Loading…
Reference in New Issue