This commit is contained in:
高飞 2026-04-16 09:42:32 +08:00
commit 570abdc2e8
10 changed files with 206 additions and 33 deletions

View File

@ -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

View File

@ -1,4 +1,4 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
namespace BLL namespace BLL
@ -53,6 +53,11 @@ namespace BLL
{ {
throw new Exception("当前包装状态不可修改车次号"); throw new Exception("当前包装状态不可修改车次号");
} }
// 检查包装是否已关联其他车次
if (!string.IsNullOrEmpty(packModel.TrainNumberId) && packModel.TrainNumberId != trainNumberId)
{
throw new Exception("该包装已在其他车次中存在,不能重复添加");
}
packModel.TrainNumberId = trainNumberId; packModel.TrainNumberId = trainNumberId;
HJGLPackagingmanageService.UpdateHJGL_PackagingManage(packModel); HJGLPackagingmanageService.UpdateHJGL_PackagingManage(packModel);
} }

View File

@ -1,4 +1,4 @@
using FastReport.DevComponents.DotNetBar; using FastReport.DevComponents.DotNetBar;
using FineUIPro; using FineUIPro;
using Model; using Model;
using System; using System;
@ -15,7 +15,9 @@ namespace BLL
public static class HJGLPackagingmanageService public static class HJGLPackagingmanageService
{ {
#region Fields #region Fields
/// <summary>
/// 包装分类映射字典
/// </summary>
public static Dictionary<string, int> CategoryIntMap = new Dictionary<string, int> public static Dictionary<string, int> CategoryIntMap = new Dictionary<string, int>
{ {
{ "打捆" ,(int)CategoryInt.}, { "打捆" ,(int)CategoryInt.},
@ -528,6 +530,20 @@ namespace BLL
{ {
baseQuery = baseQuery.Where(z => z.train.Id != null && z.train.Id.Contains(filter.TrainNumberId)); baseQuery = baseQuery.Where(z => z.train.Id != null && z.train.Id.Contains(filter.TrainNumberId));
} }
// 是否关联车次筛选
if (filter.HasTrainNumber.HasValue)
{
if (filter.HasTrainNumber.Value)
{
// 已关联车次TrainNumberId 不为空
baseQuery = baseQuery.Where(z => z.x.TrainNumberId != null && z.x.TrainNumberId != "");
}
else
{
// 未关联车次TrainNumberId 为空
baseQuery = baseQuery.Where(z => z.x.TrainNumberId == null || z.x.TrainNumberId == "");
}
}
} }
baseQuery = baseQuery.OrderByDescending(z => (z.x.ReceiveDate ?? DateTime.MinValue)).ThenBy(z => z.x.PackagingCode); baseQuery = baseQuery.OrderByDescending(z => (z.x.ReceiveDate ?? DateTime.MinValue)).ThenBy(z => z.x.PackagingCode);
@ -545,6 +561,9 @@ namespace BLL
ReceiveMan = z.train.ContactName, ReceiveMan = z.train.ContactName,
ReceiveDate = string.Format("{0:g}", z.x.ReceiveDate), ReceiveDate = string.Format("{0:g}", z.x.ReceiveDate),
TrainNumber = z.train.TrainNumber, TrainNumber = z.train.TrainNumber,
ComponentCount = db.HJGL_PackagingManageDetail.Count(d => d.PackagingManageId == z.x.PackagingManageId),
CategoryInt = z.x.CategoryInt,
CategoryString = z.x.CategoryInt == 10 ? "打捆" : (z.x.CategoryInt == 20 ? "装箱" : (z.x.CategoryInt == 30 ? "散装" : ""))
}).Distinct(); }).Distinct();
totalCount = q.Count(); totalCount = q.Count();

View File

@ -474,18 +474,29 @@ namespace FineUIPro.Web.CLGL
return; return;
} }
string planId = Grid1.SelectedRowID; string planId = Grid1.SelectedRowID;
string message = TwOutputmasterService.RevokeGenOutMasterByPlanId(planId); var planMaster = BLL.TwInOutplanmasterService.GetById(planId);
if (string.IsNullOrEmpty(message)) switch (planMaster.State)
{ {
ShowNotify("撤销出库成功!", MessageBoxIcon.Success); case (int)TwConst.State.:
BindGrid(); planMaster.State = (int)TwConst.State.;
} planMaster.AuditMan = null;
else planMaster.AuditDate = null;
{ TwInOutplanmasterService.Update(planMaster);
Alert.ShowInTop(message, MessageBoxIcon.Warning); BindGrid();
return; ShowNotify("撤销审核成功!", MessageBoxIcon.Success);
} break;
case (int)TwConst.State.:
TwOutputmasterService.RevokeGenOutMasterByPlanId(planId);
BindGrid();
ShowNotify("撤销出库单成功!", MessageBoxIcon.Success);
break;
default:
Alert.ShowInTop("请选择有效的计划!", MessageBoxIcon.Warning);
break;
}
} }

View File

@ -17033,7 +17033,7 @@
</COMReference> </COMReference>
</ItemGroup> </ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" /> <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> <ProjectExtensions>
<VisualStudio> <VisualStudio>
<FlavorProperties GUID="{349c5851-65df-11da-9384-00065b846f21}"> <FlavorProperties GUID="{349c5851-65df-11da-9384-00065b846f21}">

View File

@ -1,4 +1,4 @@
using BLL; using BLL;
using MiniExcelLibs; using MiniExcelLibs;
using Model; using Model;
using System; using System;
@ -213,29 +213,24 @@ namespace FineUIPro.Web.HJGL.PreDesign
private void BindGrid() private void BindGrid()
{ {
if (tvControlItem.SelectedNode == null) return; 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.获取当前分页数据 // 2.获取当前分页数据
Grid1.RecordCount = totalCount; Grid1.RecordCount = totalCount;
var table = view_HJGL_InstallDatas; var table = view_HJGL_InstallDatas;
Grid1.DataSource = table; Grid1.DataSource = table;
Grid1.DataBind(); Grid1.DataBind();
// 更新汇总信息 // 更新汇总信息(使用已统计的数据)
UpdateSummary(); UpdateSummary(componentCount, partCount);
} }
/// <summary> /// <summary>
/// 更新汇总信息 /// 更新汇总信息
/// </summary> /// </summary>
private void UpdateSummary() private void UpdateSummary(int componentCount, int partCount)
{ {
try try
{ {
var baseQuery = GetIQueryableInstallDatas();
// 计算汇总数据
var componentCount = baseQuery.Count(x => x.TypeStr == "预制组件");
var partCount = baseQuery.Count(x => x.TypeStr == "预制散件");
// 更新汇总标签 // 更新汇总标签
lblSummary1.Text = $"预制组件数量:{componentCount}"; lblSummary1.Text = $"预制组件数量:{componentCount}";
lblSummary2.Text = $"预制散件数量:{partCount}"; lblSummary2.Text = $"预制散件数量:{partCount}";
@ -252,14 +247,27 @@ namespace FineUIPro.Web.HJGL.PreDesign
/// 查询数据 /// 查询数据
/// </summary> /// </summary>
/// <returns></returns> /// <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(); 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 (pageIndex <= 0) pageIndex = 1;
if (pageSize <= 0) pageSize = 10; if (pageSize <= 0) pageSize = 10;
var query = baseQuery.Skip((pageIndex - 1) * pageSize).Take(pageSize).ToList(); var query = baseQuery.Skip((pageIndex - 1) * pageSize).Take(pageSize).ToList();
// 预制组件数量显示为1预制散件保持原始数量 // 预制组件数量显示为1预制散件保持原始数量
foreach (var item in query) 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.PipelineCode.Contains(txtPipelineCode.Text.Trim()));
} }
// 过滤组件编号/材料编码值为"裕-量"的记录
baseQuery = baseQuery.Where(x => x.Code != "裕-量");
baseQuery = baseQuery.OrderBy(x => x.PipelineCode).ThenBy(x => x.Code); baseQuery = baseQuery.OrderBy(x => x.PipelineCode).ThenBy(x => x.Code);
return baseQuery; return baseQuery;

View File

@ -1,4 +1,4 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
@ -20,6 +20,18 @@ namespace Model
public string ReceiveMan { get; set; } public string ReceiveMan { get; set; }
public string ReceiveDate { get; set; } public string ReceiveDate { get; set; }
public string TrainNumber { get; set; } public string TrainNumber { get; set; }
/// <summary>
/// 包装内数量(预制组件或散件数量)
/// </summary>
public int ComponentCount { get; set; }
/// <summary>
/// 包装分类代码
/// </summary>
public int? CategoryInt { get; set; }
/// <summary>
/// 包装分类名称
/// </summary>
public string CategoryString { get; set; }
} }

View File

@ -1,4 +1,4 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
@ -55,5 +55,9 @@ namespace Model
/// 车次id /// 车次id
/// </summary> /// </summary>
public string TrainNumberId { get; set; } public string TrainNumberId { get; set; }
/// <summary>
/// 是否关联车次true:已关联, false:未关联, null:不筛选)
/// </summary>
public bool? HasTrainNumber { get; set; }
} }
} }

View File

@ -1,4 +1,4 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
@ -31,6 +31,10 @@ namespace Model
public string TypeString { get; set; } public string TypeString { get; set; }
public int? CategoryInt { get; set; } public int? CategoryInt { get; set; }
public string CategoryString { get; set; } public string CategoryString { get; set; }
/// <summary>
/// 包装内数量(预制组件或散件数量)
/// </summary>
public int ComponentCount { get; set; }
#endregion Properties #endregion Properties

View File

@ -1,4 +1,4 @@
using BLL; using BLL;
using Model; using Model;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
@ -229,6 +229,26 @@ namespace WebAPI.Controllers
return responeData; return responeData;
} }
/// <summary>
/// 获取包装分类列表
/// </summary>
/// <returns>包装分类字典</returns>
[HttpGet]
public Model.ResponeData GetPackagingCategories()
{
var responeData = new Model.ResponeData();
try
{
responeData.data = HJGLPackagingmanageService.CategoryIntMap;
}
catch (Exception ex)
{
responeData.code = 0;
responeData.message = ex.Message;
}
return responeData;
}
#endregion Methods #endregion Methods
} }
} }