From 693c9148698a5e05cfa41afda08e35254b7d59d3 Mon Sep 17 00:00:00 2001 From: fei550 <1420031550@qq.com> Date: Wed, 6 Nov 2024 16:03:58 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E7=84=8A=E6=8E=A5=E4=BB=BB?= =?UTF-8?q?=E5=8A=A1=E5=8D=95=E6=89=93=E5=8D=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../API/HJGL/APIPipelineComponentService.cs | 16 +- SGGL/BLL/CLGL/TwArrivalStatisticsService.cs | 65 ++++++ SGGL/BLL/CLGL/TwInOutplanmasterService.cs | 2 +- .../File/Fastreport/材料入库单.frx | 4 +- .../File/Fastreport/材料出库计划单.frx | 4 +- .../File/Fastreport/管道焊接任务单.frx | 188 ++++++++++++++++++ .../HJGL/WeldingManage/WeldTask.aspx | 1 + .../HJGL/WeldingManage/WeldTask.aspx.cs | 80 ++++++++ .../WeldingManage/WeldTask.aspx.designer.cs | 9 + 9 files changed, 359 insertions(+), 10 deletions(-) create mode 100644 SGGL/FineUIPro.Web/File/Fastreport/管道焊接任务单.frx diff --git a/SGGL/BLL/API/HJGL/APIPipelineComponentService.cs b/SGGL/BLL/API/HJGL/APIPipelineComponentService.cs index e50ffbb2..69132cea 100644 --- a/SGGL/BLL/API/HJGL/APIPipelineComponentService.cs +++ b/SGGL/BLL/API/HJGL/APIPipelineComponentService.cs @@ -52,8 +52,7 @@ namespace BLL from t in tt.DefaultIfEmpty() from p in pp.DefaultIfEmpty() join unitwork in db.WBS_UnitWork on y.UnitWorkId equals unitwork.UnitWorkId into unitworks - from unitwork in unitworks.DefaultIfEmpty() - + from unitwork in unitworks.DefaultIfEmpty() where x.PipelineComponentId== PipelineComponentId select new PipelineComponentItem { @@ -62,8 +61,7 @@ namespace BLL PreUnit = t.UnitName, DrawingName = x.DrawingName, BoxNumber = x.BoxNumber, - State = x.State, - StateStr = HJGL_PipelineComponentService.GetState().FirstOrDefault(q=>q.Value==x.State.ToString()).Text.Trim(), + State = x.State, PlanStartDate = string.Format("{0:g}", y.PlanStartDate), QRCode = x.QRCode, ReceiveMan = p.PersonName, @@ -71,9 +69,17 @@ namespace BLL UnitWorkName=unitwork.UnitWorkName, Remark = x.Remark }).FirstOrDefault(); + if (q != null) + { + q.StateStr = HJGL_PipelineComponentService.GetState() + .FirstOrDefault(x => x.Value == q.State.ToString()) + ?.Text.Trim(); + + } bool isPower = Person_PersonsService.IsGeneralUnitByPersonId(personId, projectId); pipelineComponentDetail.pipelineComponentItem = q; - pipelineComponentDetail.isPower=isPower; + pipelineComponentDetail.isPower = isPower; + return pipelineComponentDetail; } diff --git a/SGGL/BLL/CLGL/TwArrivalStatisticsService.cs b/SGGL/BLL/CLGL/TwArrivalStatisticsService.cs index 52585cf1..4f3e753f 100644 --- a/SGGL/BLL/CLGL/TwArrivalStatisticsService.cs +++ b/SGGL/BLL/CLGL/TwArrivalStatisticsService.cs @@ -7,6 +7,7 @@ using System.Linq; using System.Text; using System.Text.RegularExpressions; using System.Threading.Tasks; +using System.Windows.Media.Animation; namespace BLL { @@ -132,6 +133,70 @@ namespace BLL } } + public static decimal? GetPipeMatch(string pipelineId) + { + using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString)) + { + var twPipeMatMatchOutputs = new List(); + var pipelineModel = PipelineService.GetPipelineByPipelineId(pipelineId); + string warehouseCode = PipelineService + .GetPipeArea().FirstOrDefault(x => x.Value == pipelineModel.PipeArea.ToString()) + ?.Text; + // 获取所需材料列表 + var requiredMaterials = (from x in db.HJGL_PipeLineMat + join y in db.HJGL_MaterialCodeLib on x.MaterialCode equals y.MaterialCode + join z in db.HJGL_Pipeline on x.PipelineId equals z.PipelineId + join m in db.WBS_UnitWork on z.UnitWorkId equals m.UnitWorkId + where z.PipelineId== pipelineId && x.PrefabricatedComponents != "" //x.PrefabricatedComponents!="" 用于筛选非散件材料 + select new Tw_PipeMatMatchOutput + { + Id = Guid.NewGuid().ToString(), + PipelineId = x.PipelineId, + PipelineCode = z.PipelineCode, + UnitWorkId = z.UnitWorkId, + UnitWorkName = m.UnitWorkName, + PrefabricatedComponents = x.PrefabricatedComponents, + MaterialCode = x.MaterialCode, + MaterialName = y.MaterialName, + MaterialSpec = y.MaterialSpec, + MaterialUnit = y.MaterialUnit, + MaterialDef = y.MaterialDef, + NeedNum = x.Number, + } + ).ToList(); + Tw_MaterialStockOutput tw_MaterialStockOutput = new Tw_MaterialStockOutput(); + tw_MaterialStockOutput.WarehouseCode = warehouseCode; + var stockList = TwMaterialstockService.GetTw_MaterialStockByModle(tw_MaterialStockOutput).ToList();//获取库存列表 + + // 模拟库存管理 + foreach (var material in requiredMaterials) + { + var thisMaterialStockNum = stockList.FirstOrDefault(x => x.PipeLineMatCode == material.MaterialCode)?.StockNum ?? 0; + if (thisMaterialStockNum >= material.NeedNum) + { + material.MatchNum = material.NeedNum; + material.MatchRate = 1; + material.MatchRateString = "100%"; + } + else + { + material.MatchNum = thisMaterialStockNum < 0 ? 0 : thisMaterialStockNum; + material.MatchRate = (material.NeedNum == 0 ? 0 : material.MatchNum ?? 0 / material.NeedNum); + material.MatchRateString = Math.Round((decimal)material.MatchRate * 100, 2).ToString() + "%"; + + } + //修改stockList对应的库存数量 + var stock = stockList.FirstOrDefault(x => x.PipeLineMatCode == material.MaterialCode); + if (stock != null) + { + stock.StockNum -= material.MatchNum; + } + } + twPipeMatMatchOutputs = requiredMaterials; + var result = twPipeMatMatchOutputs.Count==0?0: twPipeMatMatchOutputs.Sum(x=>x.MatchRate)/ twPipeMatMatchOutputs.Count; + return result; + } + } public static List GetMatMatchByOutPlanMasterId(string outPlanMasterId) { diff --git a/SGGL/BLL/CLGL/TwInOutplanmasterService.cs b/SGGL/BLL/CLGL/TwInOutplanmasterService.cs index 993dbf03..34db1b20 100644 --- a/SGGL/BLL/CLGL/TwInOutplanmasterService.cs +++ b/SGGL/BLL/CLGL/TwInOutplanmasterService.cs @@ -547,7 +547,7 @@ namespace BLL { return; } - string WeldTaskId= unitworkid+"|"+unitid+ "|" + string.Format("{0:yyyyMMMMdd}", date); + string WeldTaskId= unitworkid+"|"+unitid+ "|" + string.Format("{0:yyyyMMdd}", date); //判断是否已经生成过出库计划单 var queryIsExitInMaster = new Tw_InOutMasterOutput(); queryIsExitInMaster.WeldTaskId = WeldTaskId; diff --git a/SGGL/FineUIPro.Web/File/Fastreport/材料入库单.frx b/SGGL/FineUIPro.Web/File/Fastreport/材料入库单.frx index c682a67c..e0b7e869 100644 --- a/SGGL/FineUIPro.Web/File/Fastreport/材料入库单.frx +++ b/SGGL/FineUIPro.Web/File/Fastreport/材料入库单.frx @@ -1,5 +1,5 @@  - + using System; using System.Collections; using System.Collections.Generic; @@ -84,7 +84,7 @@ namespace FastReport } - + diff --git a/SGGL/FineUIPro.Web/File/Fastreport/材料出库计划单.frx b/SGGL/FineUIPro.Web/File/Fastreport/材料出库计划单.frx index fbc6ab3d..9768ed7f 100644 --- a/SGGL/FineUIPro.Web/File/Fastreport/材料出库计划单.frx +++ b/SGGL/FineUIPro.Web/File/Fastreport/材料出库计划单.frx @@ -1,5 +1,5 @@  - + using System; using System.Collections; using System.Collections.Generic; @@ -84,7 +84,7 @@ namespace FastReport } - + diff --git a/SGGL/FineUIPro.Web/File/Fastreport/管道焊接任务单.frx b/SGGL/FineUIPro.Web/File/Fastreport/管道焊接任务单.frx new file mode 100644 index 00000000..15f229ee --- /dev/null +++ b/SGGL/FineUIPro.Web/File/Fastreport/管道焊接任务单.frx @@ -0,0 +1,188 @@ + + + using System; +using System.Collections; +using System.Collections.Generic; +using System.ComponentModel; +using System.Windows.Forms; +using System.Drawing; +using System.Data; +using FastReport; +using FastReport.Data; +using FastReport.Dialog; +using FastReport.Barcode; +using FastReport.Table; +using FastReport.Utils; + +namespace FastReport +{ + public class ReportScript + {   + private int x; + private void Tabel_Data_ManualBuild(object sender, EventArgs e) + { + DataSourceBase rowData = Report.GetDataSource("Data"); + // init the data source + rowData.Init(); + + // print the first table row - it is a header + Tabel_Data.PrintRow(0); + // each PrintRow call must be followed by either PrintColumn or PrintColumns call + // to print cells on the row + Tabel_Data.PrintColumns(); + x=0; + // now enumerate the data source and print the table body + while (rowData.HasMoreRows) + { + x++; + // print the table body + Tabel_Data.PrintRow(1); + Tabel_Data.PrintColumns(); + + // go next data source row + rowData.Next(); + }   + } + } +} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/SGGL/FineUIPro.Web/HJGL/WeldingManage/WeldTask.aspx b/SGGL/FineUIPro.Web/HJGL/WeldingManage/WeldTask.aspx index c6bc54bd..24e47ec2 100644 --- a/SGGL/FineUIPro.Web/HJGL/WeldingManage/WeldTask.aspx +++ b/SGGL/FineUIPro.Web/HJGL/WeldingManage/WeldTask.aspx @@ -86,6 +86,7 @@ + diff --git a/SGGL/FineUIPro.Web/HJGL/WeldingManage/WeldTask.aspx.cs b/SGGL/FineUIPro.Web/HJGL/WeldingManage/WeldTask.aspx.cs index 3b06ecb5..f11a2a25 100644 --- a/SGGL/FineUIPro.Web/HJGL/WeldingManage/WeldTask.aspx.cs +++ b/SGGL/FineUIPro.Web/HJGL/WeldingManage/WeldTask.aspx.cs @@ -1,4 +1,5 @@ using BLL; +using FineUIPro.Web.HJGL.HotProcessHard; using Newtonsoft.Json.Linq; using System; using System.Collections.Generic; @@ -1332,5 +1333,84 @@ namespace FineUIPro.Web.HJGL.WeldingManage ShowNotify("请选择焊口", MessageBoxIcon.Question); } } + + protected void btnPrintTask_Click(object sender, EventArgs e) + { + DateTime? taskTime = Funs.GetNewDateTime(tvControlItem.SelectedNodeID.Split('|')[2]); + if (taskTime != null) + { + var weldTaskList = BLL.WeldTaskService.GetWeldingTaskList(this.CurrUser.LoginProjectId, tvControlItem.SelectedNodeID.Split('|')[0], tvControlItem.SelectedNodeID.Split('|')[1], Convert.ToDateTime(taskTime), this.rbIsAudit.SelectedValue); + var pipelines = weldTaskList.Select(x => x.PipelineId).Distinct().ToList(); + + if (pipelines.Any()) + { + BLL.FastReportService.ResetData(); + + //var result = HJGL_PipelineComponentService.GetPrintModelByPipelineComponentIds(null, pipelines.ToArray(), true); + //var PipelineComponentIds = result.Select(x => x.PipelineComponentId).ToArray(); + //var tb = LINQToDataTable(result); + //if (tb != null && tb.Rows.Count > 0) + //{ + // tb.TableName = "Table1"; + //} + //else + //{ + // ShowNotify("该管线已打印完成", MessageBoxIcon.Question); + // return; + //} + Dictionary keyValuePairs = new Dictionary(); + keyValuePairs.Add("Code", UnitWorkService.getUnitWorkByUnitWorkId(tvControlItem.SelectedNodeID.Split('|')[0]).UnitWorkCode+ string.Format("{0:yyyyMMdd}", taskTime.Value)); + keyValuePairs.Add("TaskDate", string.Format("{0:yyyy-MM-dd}", taskTime.Value)); + keyValuePairs.Add("UnitName", UnitService.GetUnitNameByUnitId(tvControlItem.SelectedNodeID.Split('|')[1])); + keyValuePairs.Add("UnitWorkName]", UnitWorkService.getUnitWorkByUnitWorkId(tvControlItem.SelectedNodeID.Split('|')[0]).UnitWorkName); + // 创建一个新的DataTable + DataTable dataTable = new DataTable(); + dataTable.TableName = "Data"; + // 添加列 + dataTable.Columns.Add("PipelineCode", typeof(string)); + dataTable.Columns.Add("FlowingSection", typeof(string)); + dataTable.Columns.Add("MaterialCode", typeof(string)); + dataTable.Columns.Add("MaterialSpec", typeof(string)); + dataTable.Columns.Add("MatchRate", typeof(string)); + + foreach (string pipeline in pipelines) + { + DataRow dr = dataTable.NewRow(); + var pipelineModel = PipelineService.GetPipelineByPipelineId(pipeline); + List list=new List { pipeline }; + + dr["PipelineCode"] = pipelineModel.PipelineCode; + dr["FlowingSection"] = pipelineModel.FlowingSection; + dr["MaterialCode"] = Base_MaterialService.GetMaterialByMaterialId(pipelineModel.MaterialId).MaterialCode ; + dr["MaterialSpec"] = string.Join(",", weldTaskList.Select(x => x.Specification).Distinct().ToList()) ; + dr["MatchRate"] = Math.Round((decimal)TwArrivalStatisticsService.GetPipeMatch(pipeline) * 100, 2).ToString() + "%" ; + dataTable.Rows.Add(dr); + } + BLL.FastReportService.AddFastreportTable(dataTable); + BLL.FastReportService.AddFastreportParameter(keyValuePairs); + string initTemplatePath = ""; + string rootPath = Server.MapPath("~/"); + initTemplatePath = "File\\Fastreport\\管道焊接任务单.frx"; + + if (File.Exists(rootPath + initTemplatePath)) + { + PageContext.RegisterStartupScript(Window2.GetShowReference(String.Format("~/Controls/Fastreport.aspx?ReportPath={0}", rootPath + initTemplatePath))); + + } + + } + else + { + ShowNotify("无关联管线", MessageBoxIcon.Question); + + } + + + } + else + { + ShowNotify("请选择任务单", MessageBoxIcon.Question); + } + } } } \ No newline at end of file diff --git a/SGGL/FineUIPro.Web/HJGL/WeldingManage/WeldTask.aspx.designer.cs b/SGGL/FineUIPro.Web/HJGL/WeldingManage/WeldTask.aspx.designer.cs index 1eb7c146..1766260e 100644 --- a/SGGL/FineUIPro.Web/HJGL/WeldingManage/WeldTask.aspx.designer.cs +++ b/SGGL/FineUIPro.Web/HJGL/WeldingManage/WeldTask.aspx.designer.cs @@ -221,6 +221,15 @@ namespace FineUIPro.Web.HJGL.WeldingManage /// protected global::FineUIPro.Button btnPrint; + /// + /// btnPrintTask 控件。 + /// + /// + /// 自动生成的字段。 + /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 + /// + protected global::FineUIPro.Button btnPrintTask; + /// /// txtTaskDate 控件。 ///