20250609 排产计划

This commit is contained in:
2025-06-09 17:20:34 +08:00
parent a980bb43f3
commit eef442181b
10 changed files with 858 additions and 479 deletions
@@ -1,7 +1,9 @@
using BLL;
using FineUIPro.Web.ProjectData;
using MiniExcelLibs;
using Model;
using Newtonsoft.Json.Linq;
using NPOI.SS.Formula.Functions;
using System;
using System.Collections.Generic;
using System.Data;
@@ -11,6 +13,7 @@ using System.Drawing;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices;
using System.Security.Cryptography;
using System.Web;
using System.Web.WebSockets;
@@ -83,7 +86,7 @@ namespace FineUIPro.Web.HJGL.PreDesign
{
foreach (var q in unitWork1)
{
int a = (from x in Funs.DB.HJGL_Pipeline where x.ProjectId == this.CurrUser.LoginProjectId && x.UnitWorkId == q.UnitWorkId && x.PipeArea == "1" && x.PipelineCode.Contains(txtPipelineCode.Text.Trim()) select x.FlowingSection).Distinct().Count();
int a = (from x in Funs.DB.HJGL_Pipeline where x.ProjectId == this.CurrUser.LoginProjectId && x.UnitWorkId == q.UnitWorkId && x.PipeArea == "1" select x.FlowingSection).Distinct().Count();
var unitNamesUnitIds = BLL.UnitService.getUnitNamesUnitIds(q.UnitId);
TreeNode tn1 = new TreeNode();
tn1.NodeID = q.UnitWorkId;
@@ -112,7 +115,7 @@ namespace FineUIPro.Web.HJGL.PreDesign
{
foreach (var q in unitWork2)
{
int a = (from x in Funs.DB.HJGL_Pipeline where x.ProjectId == this.CurrUser.LoginProjectId && x.UnitWorkId == q.UnitWorkId && x.PipeArea == "1" && x.PipelineCode.Contains(txtPipelineCode.Text.Trim()) select x.FlowingSection).Distinct().Count();
int a = (from x in Funs.DB.HJGL_Pipeline where x.ProjectId == this.CurrUser.LoginProjectId && x.UnitWorkId == q.UnitWorkId && x.PipeArea == "1" select x.FlowingSection).Distinct().Count();
var unitNamesUnitIds = BLL.UnitService.getUnitNamesUnitIds(q.UnitId);
TreeNode tn2 = new TreeNode();
tn2.NodeID = q.UnitWorkId;
@@ -147,7 +150,7 @@ namespace FineUIPro.Web.HJGL.PreDesign
{
List<string> flowingSection = new List<string>();
//List<Model.HJGL_Pipeline> pipeline = new List<Model.HJGL_Pipeline>();
var list = (from x in Funs.DB.HJGL_Pipeline where x.ProjectId == this.CurrUser.LoginProjectId && x.PipeArea == "1" && x.UnitWorkId == node.NodeID && x.PipelineCode.Contains(this.txtPipelineCode.Text.Trim()) select x.FlowingSection).ToList();
var list = (from x in Funs.DB.HJGL_Pipeline where x.ProjectId == this.CurrUser.LoginProjectId && x.PipeArea == "1" && x.UnitWorkId == node.NodeID select x.FlowingSection).ToList();
flowingSection = list.Where(x => !string.IsNullOrWhiteSpace(x) == true).Distinct().OrderBy(x => x).ToList();
//int pageindex = int.Parse(node.CommandName.Split('|')[0]);
//int pageCount = int.Parse(node.CommandName.Split('|')[1]);
@@ -199,16 +202,16 @@ namespace FineUIPro.Web.HJGL.PreDesign
/// <param name="e"></param>
protected void tvControlItem_NodeCommand(object sender, TreeCommandEventArgs e)
{
if (e.CommandName == "流水段")
{
Model.HJGL_Pipeline pipeline = BLL.PipelineService.GetPipelineByFlowingSection(this.tvControlItem.SelectedNode.Text);
this.hdUnitWorkId.Text = string.Empty;
if (pipeline != null)
{
this.hdUnitWorkId.Text = this.tvControlItem.SelectedNode.ParentNode.NodeID;
SaveProductionSchedulingPlan();
}
}
//if (e.CommandName == "流水段")
//{
// Model.HJGL_Pipeline pipeline = BLL.PipelineService.GetPipelineByFlowingSection(this.tvControlItem.SelectedNode.Text);
// this.hdUnitWorkId.Text = string.Empty;
// if (pipeline != null)
// {
// this.hdUnitWorkId.Text = this.tvControlItem.SelectedNode.ParentNode.NodeID;
// SaveProductionSchedulingPlan();
// }
//}
this.BindGrid();
}
@@ -220,23 +223,145 @@ namespace FineUIPro.Web.HJGL.PreDesign
{
if (!string.IsNullOrEmpty(this.tvControlItem.SelectedNodeID))
{
List<Model.View_HJGL_ProductionSchedulingPlanStatistics> lists = (from x in Funs.DB.View_HJGL_ProductionSchedulingPlanStatistics.Where(x => x.ProjectId == this.CurrUser.LoginProjectId && x.FlowingSection == this.tvControlItem.SelectedNode.Text) select x).ToList();
foreach (var item in lists)
if (tvControlItem.SelectedNode.CommandName == "流水段")
{
var plan = BLL.ProductionSchedulingPlanService.GetProductionSchedulingPlan(this.CurrUser.LoginProjectId, item.FlowingSection, item.UnitWorkName, item.Material, item.Caliber);
if (plan == null)
List<SqlParameter> listStr = new List<SqlParameter>();
listStr.Add(new SqlParameter("@projectId", this.CurrUser.LoginProjectId));
if (!string.IsNullOrEmpty(this.tvControlItem.SelectedNode.ParentNode.NodeID))
{
Model.HJGL_ProductionSchedulingPlan newPlan = new HJGL_ProductionSchedulingPlan();
newPlan.ProductionSchedulingPlanId = SQLHelper.GetNewID(typeof(Model.HJGL_ProductionSchedulingPlan));
newPlan.ProjectId = this.CurrUser.LoginProjectId;
//newPlan.PipelineId = this.tvControlItem.SelectedNodeID;
newPlan.FlowNum = item.FlowingSection;
newPlan.MainItemName = item.UnitWorkName;
newPlan.Material = item.Material;
newPlan.Caliber = item.Caliber;
newPlan.Dain = item.Dia;
newPlan.TotalDyne = lists.Sum(x => x.Dia);
BLL.ProductionSchedulingPlanService.AddProductionSchedulingPlan(newPlan);
listStr.Add(new SqlParameter("@unitWorkId", this.tvControlItem.SelectedNode.ParentNode.NodeID));
}
else
{
listStr.Add(new SqlParameter("@unitWorkId", null));
}
if (!string.IsNullOrEmpty(this.tvControlItem.SelectedNode.Text))
{
listStr.Add(new SqlParameter("@flowingSection", this.tvControlItem.SelectedNode.Text));
}
else
{
listStr.Add(new SqlParameter("@flowingSection", null));
}
if (!string.IsNullOrEmpty(this.txtSize.Text.Trim()))
{
listStr.Add(new SqlParameter("@caliber", this.txtSize.Text.Trim()));
}
SqlParameter[] parameter = listStr.ToArray();
DataTable tb = SQLHelper.GetDataTableRunProc("Sp_ProductionSchedulingPlanStatistics", parameter);
for (int i = 0; i < tb.Rows.Count; i++)
{
//decimal totalDia = 0;
//totalDia += Convert.ToDecimal(tb.Rows[i]["Dia"].ToString());//总达因
var plan = BLL.ProductionSchedulingPlanService.GetProductionSchedulingPlan(this.CurrUser.LoginProjectId, tb.Rows[i]["FlowingSection"].ToString(), tb.Rows[i]["UnitWorkId"].ToString(), tb.Rows[i]["Material"].ToString(), tb.Rows[i]["Caliber"].ToString());
if (plan == null)
{
Model.HJGL_ProductionSchedulingPlan newPlan = new HJGL_ProductionSchedulingPlan();
newPlan.ProductionSchedulingPlanId = SQLHelper.GetNewID(typeof(Model.HJGL_ProductionSchedulingPlan));
newPlan.ProjectId = this.CurrUser.LoginProjectId;
newPlan.PipelineId = tb.Rows[i]["UnitWorkId"].ToString();//装置ID
newPlan.FlowNum = tb.Rows[i]["FlowingSection"].ToString();
newPlan.MainItemName = tb.Rows[i]["UnitWorkName"].ToString();
newPlan.Material = tb.Rows[i]["Material"].ToString();
newPlan.Caliber = tb.Rows[i]["Caliber"].ToString();
newPlan.Dain = Funs.GetNewDecimalOrZero(tb.Rows[i]["Dia"].ToString());
newPlan.TotalDyne = Funs.GetNewDecimalOrZero(tb.Rows[i]["TotalDia"].ToString());
newPlan.CompletedCount = Funs.GetNewIntOrZero(tb.Rows[i]["cTotalCount"].ToString());
newPlan.CompletedRate = Funs.GetNewDecimalOrZero(tb.Rows[i]["rate"].ToString());
newPlan.TotalCompletedRate = Funs.GetNewDecimalOrZero(tb.Rows[i]["Srate"].ToString());
BLL.ProductionSchedulingPlanService.AddProductionSchedulingPlan(newPlan);
}
}
}
else if (tvControlItem.SelectedNode.CommandName.Split('|').Length == 2)//单位工程
{
List<SqlParameter> listStr = new List<SqlParameter>();
listStr.Add(new SqlParameter("@projectId", this.CurrUser.LoginProjectId));
if (!string.IsNullOrEmpty(this.tvControlItem.SelectedNode.NodeID))
{
listStr.Add(new SqlParameter("@unitWorkId", this.tvControlItem.SelectedNode.NodeID));
}
else
{
listStr.Add(new SqlParameter("@unitWorkId", null));
}
if (!string.IsNullOrEmpty(this.txtSize.Text.Trim()))
{
listStr.Add(new SqlParameter("@caliber", this.txtSize.Text.Trim()));
}
SqlParameter[] parameter = listStr.ToArray();
DataTable tb = SQLHelper.GetDataTableRunProc("Sp_ProductionSchedulingPlanStatistics", parameter);
for (int i = 0; i < tb.Rows.Count; i++)
{
var plan = BLL.ProductionSchedulingPlanService.GetProductionSchedulingPlan(this.CurrUser.LoginProjectId, tb.Rows[i]["FlowingSection"].ToString(), tb.Rows[i]["UnitWorkId"].ToString(), tb.Rows[i]["Material"].ToString(), tb.Rows[i]["Caliber"].ToString());
if (plan == null)
{
Model.HJGL_ProductionSchedulingPlan newPlan = new HJGL_ProductionSchedulingPlan();
newPlan.ProductionSchedulingPlanId = SQLHelper.GetNewID(typeof(Model.HJGL_ProductionSchedulingPlan));
newPlan.ProjectId = this.CurrUser.LoginProjectId;
newPlan.PipelineId = tb.Rows[i]["UnitWorkId"].ToString();//装置ID
newPlan.FlowNum = tb.Rows[i]["FlowingSection"].ToString();
newPlan.MainItemName = tb.Rows[i]["UnitWorkName"].ToString();
newPlan.Material = tb.Rows[i]["Material"].ToString();
newPlan.Caliber = tb.Rows[i]["Caliber"].ToString();
newPlan.Dain = Funs.GetNewDecimalOrZero(tb.Rows[i]["Dia"].ToString());
newPlan.TotalDyne = Funs.GetNewDecimalOrZero(tb.Rows[i]["TotalDia"].ToString());
newPlan.CompletedCount = Funs.GetNewIntOrZero(tb.Rows[i]["cTotalCount"].ToString());
newPlan.CompletedRate = Funs.GetNewDecimalOrZero(tb.Rows[i]["rate"].ToString());
newPlan.TotalCompletedRate = Funs.GetNewDecimalOrZero(tb.Rows[i]["Srate"].ToString());
BLL.ProductionSchedulingPlanService.AddProductionSchedulingPlan(newPlan);
}
}
}
else if (this.tvControlItem.SelectedNodeID == "1" || this.tvControlItem.SelectedNodeID == "2")
{
List<SqlParameter> listStr = new List<SqlParameter>();
listStr.Add(new SqlParameter("@projectId", this.CurrUser.LoginProjectId));
if (!string.IsNullOrEmpty(this.hdUnitWorkId.Text))
{
listStr.Add(new SqlParameter("@unitWorkId", this.hdUnitWorkId.Text));
}
else
{
listStr.Add(new SqlParameter("@unitWorkId", null));
}
if (!string.IsNullOrEmpty(this.txtSize.Text.Trim()))
{
listStr.Add(new SqlParameter("@caliber", this.txtSize.Text.Trim()));
}
SqlParameter[] parameter = listStr.ToArray();
DataTable tb = SQLHelper.GetDataTableRunProc("Sp_ProductionSchedulingPlanStatistics", parameter);
for (int i = 0; i < tb.Rows.Count; i++)
{
if (!string.IsNullOrEmpty(tb.Rows[i]["FlowingSection"].ToString()))
{
var plan = BLL.ProductionSchedulingPlanService.GetProductionSchedulingPlan(this.CurrUser.LoginProjectId, tb.Rows[i]["FlowingSection"].ToString(), tb.Rows[i]["UnitWorkId"].ToString(), tb.Rows[i]["Material"].ToString(), tb.Rows[i]["Caliber"].ToString());
if (plan == null)
{
Model.HJGL_ProductionSchedulingPlan newPlan = new HJGL_ProductionSchedulingPlan();
newPlan.ProductionSchedulingPlanId = SQLHelper.GetNewID(typeof(Model.HJGL_ProductionSchedulingPlan));
newPlan.ProjectId = this.CurrUser.LoginProjectId;
newPlan.PipelineId = tb.Rows[i]["UnitWorkId"].ToString();//装置ID
newPlan.FlowNum = tb.Rows[i]["FlowingSection"].ToString();
newPlan.MainItemName = tb.Rows[i]["UnitWorkName"].ToString();
newPlan.Material = tb.Rows[i]["Material"].ToString();
newPlan.Caliber = tb.Rows[i]["Caliber"].ToString();
newPlan.Dain = Funs.GetNewDecimalOrZero(tb.Rows[i]["Dia"].ToString());
newPlan.TotalDyne = Funs.GetNewDecimalOrZero(tb.Rows[i]["TotalDia"].ToString());
newPlan.CompletedCount = Funs.GetNewIntOrZero(tb.Rows[i]["cTotalCount"].ToString());
newPlan.CompletedRate = Funs.GetNewDecimalOrZero(tb.Rows[i]["rate"].ToString());
newPlan.TotalCompletedRate = Funs.GetNewDecimalOrZero(tb.Rows[i]["Srate"].ToString());
BLL.ProductionSchedulingPlanService.AddProductionSchedulingPlan(newPlan);
}
}
}
}
}
@@ -264,22 +389,35 @@ namespace FineUIPro.Web.HJGL.PreDesign
p.PlanStartDate,
p.PlanEndDate,
p.Days,
p.AvgDailyWorkload
p.AvgDailyWorkload,
w.ProjectType,
p.CompletedCount,
p.CompletedRate,
p.TotalCompletedRate
FROM HJGL_ProductionSchedulingPlan p
left join WBS_UnitWork w on w.UnitWorkId=p.PipelineId
WHERE 1=1 ";
List<SqlParameter> listStr = new List<SqlParameter>();
if (tvControlItem.SelectedNode.CommandName.Split('|').Length == 2)
{
strSql += " and p.MainItemName =@UnitWorkId";
listStr.Add(new SqlParameter("@UnitWorkId", this.tvControlItem.SelectedNode.Text));
strSql += " and p.PipelineId =@UnitWorkId";
listStr.Add(new SqlParameter("@UnitWorkId", this.tvControlItem.SelectedNode.NodeID));
}
else if (tvControlItem.SelectedNode.CommandName == "流水段")
{
strSql += " and p.FlowNum = @FlowNum ";
strSql += "and p.PipelineId =@UnitWorkId and p.FlowNum = @FlowNum ";
listStr.Add(new SqlParameter("@UnitWorkId", this.tvControlItem.SelectedNode.ParentNode.NodeID));
listStr.Add(new SqlParameter("@FlowNum", this.tvControlItem.SelectedNode.Text));
}
else if (tvControlItem.SelectedNodeID == "1")
{
strSql += "and w.ProjectType ='1' ";
}
else if (tvControlItem.SelectedNodeID == "2")
{
strSql += "and w.ProjectType ='2' ";
}
SqlParameter[] parameter = listStr.ToArray();
DataTable tb = SQLHelper.GetDataTableRunText(strSql, parameter);
@@ -332,10 +470,10 @@ namespace FineUIPro.Web.HJGL.PreDesign
#endregion
#region
protected void btnSearch_Click(object sender, EventArgs e)
{
BindGrid();
}
//protected void btnSearch_Click(object sender, EventArgs e)
//{
// BindGrid();
//}
#endregion
@@ -345,15 +483,15 @@ namespace FineUIPro.Web.HJGL.PreDesign
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void TextBox_TextChanged(object sender, EventArgs e)
{
this.BindGrid();
}
protected void btnTreeFind_Click(object sender, EventArgs e)
{
this.InitTreeMenu();
//protected void TextBox_TextChanged(object sender, EventArgs e)
//{
// this.BindGrid();
//}
//protected void btnTreeFind_Click(object sender, EventArgs e)
//{
// this.InitTreeMenu();
}
//}
#endregion
#region
@@ -470,7 +608,7 @@ namespace FineUIPro.Web.HJGL.PreDesign
cell = row.CreateCell(5);
cell.CellStyle = cellStyle;
cell.SetCellValue(item.TotalDyne.HasValue?item.TotalDyne.ToString():"");//总达因数
cell.SetCellValue(item.TotalDyne.HasValue ? item.TotalDyne.ToString() : "");//总达因数
cell = row.CreateCell(6);
cell.CellStyle = cellStyle;
@@ -490,12 +628,24 @@ namespace FineUIPro.Web.HJGL.PreDesign
cell = row.CreateCell(10);
cell.CellStyle = cellStyle;
cell.SetCellValue(item.Days.HasValue?item.Days.ToString():"");//天数
cell.SetCellValue(item.Days.HasValue ? item.Days.ToString() : "");//天数
cell = row.CreateCell(11);
cell.CellStyle = cellStyle;
cell.SetCellValue(item.AvgDailyWorkload.HasValue ? item.AvgDailyWorkload.ToString():"");//平均每天工作量
cell.SetCellValue(item.AvgDailyWorkload.HasValue ? item.AvgDailyWorkload.ToString() : "");//平均每天工作量
cell = row.CreateCell(12);
cell.CellStyle = cellStyle;
cell.SetCellValue(item.CompletedCount.HasValue ? item.CompletedCount.ToString() : "");//已完成量
cell = row.CreateCell(13);
cell.CellStyle = cellStyle;
cell.SetCellValue(item.CompletedRate.HasValue ? item.CompletedRate.ToString() : "");//已完成百分比
cell = row.CreateCell(14);
cell.CellStyle = cellStyle;
cell.SetCellValue(item.TotalCompletedRate.HasValue ? item.TotalCompletedRate.ToString() : "");//已完成百分比汇总
i++;
}
// 第三步:写入文件流
@@ -522,5 +672,103 @@ namespace FineUIPro.Web.HJGL.PreDesign
}
}
#endregion
#region
/// <summary>
/// 统计
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btnStatics_Click(object sender, EventArgs e)
{
if (!string.IsNullOrEmpty(this.txtSize.Text.Trim()))
{
//单位工程
if (tvControlItem.SelectedNode.CommandName.Split('|').Length == 2)
{
///根据流水段获取管线信息
Model.HJGL_Pipeline pipeline = BLL.PipelineService.GetPipelineByUnitWorkId(this.tvControlItem.SelectedNode.NodeID);
this.hdUnitWorkId.Text = string.Empty;
if (pipeline != null)
{
this.hdUnitWorkId.Text = this.tvControlItem.SelectedNode.NodeID;
SaveProductionSchedulingPlan();
}
}
else if (tvControlItem.SelectedNode.CommandName == "流水段")
{
///根据流水段获取管线信息
Model.HJGL_Pipeline pipeline = BLL.PipelineService.GetPipelineByFlowingSection(this.tvControlItem.SelectedNode.Text);
this.hdUnitWorkId.Text = string.Empty;
if (pipeline != null)
{
this.hdUnitWorkId.Text = this.tvControlItem.SelectedNode.ParentNode.NodeID;
SaveProductionSchedulingPlan();
}
}
else
{
var unitWorkList = (from x in Funs.DB.WBS_UnitWork
where x.ProjectId == this.CurrUser.LoginProjectId
&& x.SuperUnitWork == null && x.UnitId != null && x.ProjectType != null
select x).ToList();
List<Model.WBS_UnitWork> unitWorks = null;
//List<Model.WBS_UnitWork> unitWork2 = null;
//
if (this.tvControlItem.SelectedNodeID == "1")
{
unitWorks = (from x in unitWorkList where x.ProjectType == "1" select x).ToList();
}
else if (this.tvControlItem.SelectedNodeID == "2")
{
unitWorks = (from x in unitWorkList where x.ProjectType == "2" select x).ToList();
}
foreach (var item in unitWorks)
{
Model.HJGL_Pipeline pipeline = BLL.PipelineService.GetPipelineByUnitWorkId(item.UnitWorkId);
this.hdUnitWorkId.Text = string.Empty;
if (pipeline != null)
{
this.hdUnitWorkId.Text = item.UnitWorkId;
SaveProductionSchedulingPlan();
}
}
}
this.BindGrid();
}
else
{
Alert.ShowInTop("请输入口径!", MessageBoxIcon.Warning);
return;
}
}
#endregion
#region
/// <summary>
/// 删除
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btnMenuDelete_Click(object sender, EventArgs e)
{
if (Grid1.SelectedRowIndexArray.Length > 0)
{
foreach (int rowIndex in Grid1.SelectedRowIndexArray)
{
string rowID = Grid1.DataKeys[rowIndex][0].ToString();
var model = BLL.ProductionSchedulingPlanService.GetProductionSchedulingPlanById(rowID);
if (model != null)
{
BLL.ProductionSchedulingPlanService.DeleteProductionSchedulingPlanById(rowID);
}
}
BindGrid();
ShowNotify("删除数据成功!", MessageBoxIcon.Success);
}
}
#endregion
}
}