831 lines
40 KiB
C#
831 lines
40 KiB
C#
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;
|
|
using System.Data.SqlClient;
|
|
using System.Data.SqlTypes;
|
|
using System.Drawing;
|
|
using System.IO;
|
|
using System.Linq;
|
|
using System.Runtime.InteropServices;
|
|
using System.Security.Cryptography;
|
|
using System.Web;
|
|
using System.Web.WebSockets;
|
|
|
|
namespace FineUIPro.Web.HJGL.PreDesign
|
|
{
|
|
public partial class ProductionSchedulingPlan : PageBase
|
|
{
|
|
public int pageSize = 20;
|
|
public static DataTable GridDataTable = new DataTable();
|
|
protected void Page_Load(object sender, EventArgs e)
|
|
{
|
|
if (!IsPostBack)
|
|
{
|
|
this.ddlPageSize.SelectedValue = this.Grid1.PageSize.ToString();
|
|
this.InitTreeMenu();//加载树
|
|
}
|
|
}
|
|
|
|
#region 加载树装置-单位-工作区
|
|
/// <summary>
|
|
/// 加载树
|
|
/// </summary>
|
|
private void InitTreeMenu()
|
|
{
|
|
this.tvControlItem.Nodes.Clear();
|
|
|
|
TreeNode rootNode1 = new TreeNode();
|
|
rootNode1.NodeID = "1";
|
|
rootNode1.Text = "建筑工程";
|
|
rootNode1.CommandName = "建筑工程";
|
|
rootNode1.Selectable = false;
|
|
this.tvControlItem.Nodes.Add(rootNode1);
|
|
|
|
TreeNode rootNode2 = new TreeNode();
|
|
rootNode2.NodeID = "2";
|
|
rootNode2.Text = "安装工程";
|
|
rootNode2.CommandName = "安装工程";
|
|
rootNode2.Expanded = true;
|
|
this.tvControlItem.Nodes.Add(rootNode2);
|
|
|
|
var pUnits = (from x in Funs.DB.Project_ProjectUnit where x.ProjectId == this.CurrUser.LoginProjectId select x).ToList();
|
|
// 获取当前用户所在单位
|
|
var currUnit = pUnits.FirstOrDefault(x => x.UnitId == this.CurrUser.UnitId);
|
|
|
|
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> unitWork1 = null;
|
|
List<Model.WBS_UnitWork> unitWork2 = null;
|
|
|
|
//// 当前为施工单位,只能操作本单位的数据
|
|
//if (currUnit != null && currUnit.UnitType == Const.ProjectUnitType_2)
|
|
//{
|
|
// unitWork1 = (from x in unitWorkList
|
|
// where x.UnitId == this.CurrUser.UnitId && x.ProjectType == "1"
|
|
// select x).ToList();
|
|
// unitWork2 = (from x in unitWorkList
|
|
// where x.UnitId == this.CurrUser.UnitId && x.ProjectType == "2"
|
|
// select x).ToList();
|
|
//}
|
|
//else
|
|
//{
|
|
unitWork1 = (from x in unitWorkList where x.ProjectType == "1" select x).ToList();
|
|
unitWork2 = (from x in unitWorkList where x.ProjectType == "2" select x).ToList();
|
|
//}
|
|
|
|
if (unitWork1.Count() > 0)
|
|
{
|
|
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" select x.FlowingSection).Distinct().Count();
|
|
var unitNamesUnitIds = BLL.UnitService.getUnitNamesUnitIds(q.UnitId);
|
|
TreeNode tn1 = new TreeNode();
|
|
tn1.NodeID = q.UnitWorkId;
|
|
//tn1.Text = q.UnitWorkName + "【" + a.ToString() + "】" + "管线";
|
|
tn1.Text = q.UnitWorkName;
|
|
tn1.ToolTip = "施工单位:" + unitNamesUnitIds;
|
|
tn1.CommandName = 1 + "|" + Funs.GetEndPageNumber(a, pageSize);
|
|
tn1.EnableClickEvent = true;
|
|
tn1.EnableExpandEvent = true;
|
|
rootNode1.Nodes.Add(tn1);
|
|
if (a > 0)
|
|
{
|
|
// BindNodes(tn1);
|
|
TreeNode newNode = new TreeNode();
|
|
newNode.Text = "加载流水段...";
|
|
newNode.NodeID = "加载流水段...";
|
|
tn1.Nodes.Add(newNode);
|
|
}
|
|
//if (a > 0)
|
|
//{
|
|
// BindNodes(tn1);
|
|
//}
|
|
}
|
|
}
|
|
if (unitWork2.Count() > 0)
|
|
{
|
|
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" select x.FlowingSection).Distinct().Count();
|
|
var unitNamesUnitIds = BLL.UnitService.getUnitNamesUnitIds(q.UnitId);
|
|
TreeNode tn2 = new TreeNode();
|
|
tn2.NodeID = q.UnitWorkId;
|
|
//tn2.Text = q.UnitWorkName + "【" + a.ToString() + "】" + "管线";
|
|
tn2.Text = q.UnitWorkName;
|
|
if (q.UnitWorkId == this.hdUnitWorkId.Text)
|
|
{
|
|
tn2.Expanded = true;
|
|
}
|
|
tn2.ToolTip = "施工单位:" + unitNamesUnitIds;
|
|
tn2.CommandName = 1 + "|" + Funs.GetEndPageNumber(a, pageSize);
|
|
tn2.EnableClickEvent = true;
|
|
tn2.EnableExpandEvent = true;
|
|
rootNode2.Nodes.Add(tn2);
|
|
if (a > 0)
|
|
{
|
|
// BindNodes(tn1);
|
|
TreeNode newNode = new TreeNode();
|
|
newNode.Text = "加载流水段...";
|
|
newNode.NodeID = "加载流水段...";
|
|
tn2.Nodes.Add(newNode);
|
|
}
|
|
//if (a > 0)
|
|
//{
|
|
// BindNodes(tn2);
|
|
//}
|
|
}
|
|
}
|
|
}
|
|
|
|
private void BindNodes(TreeNode node)
|
|
{
|
|
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 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]);
|
|
//if (pageindex <= pageCount)
|
|
//{
|
|
// flowingSection = flowingSection.Skip(pageSize * (pageindex - 1)).Take(pageSize).ToList();
|
|
foreach (var item in flowingSection)
|
|
{
|
|
//var comCount = (from x in Funs.DB.HJGL_Pipeline_Component where x.PipelineId == item.PipelineId select x).Count();
|
|
TreeNode newNode = new TreeNode();
|
|
//newNode.Text = item.PipelineCode + "【" + comCount.ToString() + " " + "组件" + "】";
|
|
|
|
newNode.Text = item;
|
|
newNode.ToolTip = "流水段";
|
|
newNode.CommandName = "流水段";
|
|
newNode.NodeID = SQLHelper.GetNewID();
|
|
newNode.EnableClickEvent = true;
|
|
node.Nodes.Add(newNode);
|
|
}
|
|
// if (pageindex < pageCount)
|
|
// {
|
|
// TreeNode newNode = new TreeNode();
|
|
// newNode.Text = "加载";
|
|
// newNode.NodeID = "加载";
|
|
// //newNode.NodeID = SQLHelper.GetNewID();
|
|
// newNode.CommandName = "加载";
|
|
// newNode.Icon = Icon.ArrowDown;
|
|
// newNode.EnableClickEvent = true;
|
|
// node.Nodes.Add(newNode);
|
|
// }
|
|
//}
|
|
}
|
|
|
|
#endregion
|
|
protected void tvControlItem_TreeNodeExpanded(object sender, TreeNodeEventArgs e)
|
|
{
|
|
if (e.Node.Nodes[0].NodeID == "加载流水段...")
|
|
{
|
|
e.Node.Nodes.Clear();
|
|
BindNodes(e.Node);
|
|
}
|
|
|
|
}
|
|
#region 点击TreeView
|
|
/// <summary>
|
|
/// 点击TreeView
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <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();
|
|
// }
|
|
//}
|
|
this.BindGrid();
|
|
}
|
|
|
|
/// <summary>
|
|
/// 保存数据
|
|
/// </summary>
|
|
/// <exception cref="NotImplementedException"></exception>
|
|
private void SaveProductionSchedulingPlan()
|
|
{
|
|
if (!string.IsNullOrEmpty(this.tvControlItem.SelectedNodeID))
|
|
{
|
|
if (tvControlItem.SelectedNode.CommandName == "流水段")
|
|
{
|
|
List<SqlParameter> listStr = new List<SqlParameter>();
|
|
listStr.Add(new SqlParameter("@projectId", this.CurrUser.LoginProjectId));
|
|
if (!string.IsNullOrEmpty(this.tvControlItem.SelectedNode.ParentNode.NodeID))
|
|
{
|
|
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);
|
|
|
|
//删除原有数据
|
|
BLL.ProductionSchedulingPlanService.DeleteProductionSchedulingPlanByUnitWorkIdAndFlowNum(this.CurrUser.LoginProjectId,this.tvControlItem.SelectedNode.ParentNode.Text, this.tvControlItem.SelectedNode.Text);
|
|
for (int i = 0; i < tb.Rows.Count; i++)
|
|
{
|
|
string unitWorkId = tb.Rows[i]["UnitWorkId"].ToString();//单位工程
|
|
string flowingSection = tb.Rows[i]["FlowingSection"].ToString();//流水号
|
|
string steelType = tb.Rows[i]["SteelType"].ToString();//材质Value
|
|
string material = tb.Rows[i]["Material"].ToString();//材质Text
|
|
string caliber = tb.Rows[i]["Caliber"].ToString();//寸径
|
|
|
|
var plan = BLL.ProductionSchedulingPlanService.GetProductionSchedulingPlan(this.CurrUser.LoginProjectId, flowingSection, unitWorkId, material, caliber);
|
|
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 = unitWorkId;
|
|
newPlan.FlowNum = flowingSection;
|
|
newPlan.MainItemName = tb.Rows[i]["UnitWorkName"].ToString();
|
|
newPlan.Material = material;
|
|
newPlan.Caliber = caliber;
|
|
newPlan.Dain = BLL.WeldJointService.GetSizeSum(this.CurrUser.LoginProjectId, unitWorkId, flowingSection, steelType, caliber,"1");
|
|
newPlan.TotalDyne = BLL.WeldJointService.GetSizeSumByUnitWorkIdAndFlowingSection(this.CurrUser.LoginProjectId, unitWorkId, flowingSection,"1");
|
|
newPlan.CompletedCount = BLL.WeldJointService.GetSizeSum(this.CurrUser.LoginProjectId, unitWorkId, flowingSection, steelType, caliber, "2");
|
|
if (newPlan.Dain > 0)
|
|
{
|
|
newPlan.CompletedRate = (newPlan.CompletedCount / newPlan.Dain) * 100;
|
|
}
|
|
else
|
|
{
|
|
newPlan.CompletedRate = 0;
|
|
}
|
|
if (newPlan.TotalDyne > 0)
|
|
{
|
|
decimal? completeDinSum = BLL.WeldJointService.GetSizeSumByUnitWorkIdAndFlowingSection(this.CurrUser.LoginProjectId, unitWorkId, flowingSection, "2");
|
|
newPlan.TotalCompletedRate = (completeDinSum / newPlan.TotalDyne) * 100;
|
|
}
|
|
else
|
|
{
|
|
newPlan.TotalCompletedRate = 0;
|
|
}
|
|
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);
|
|
|
|
//删除原有数据
|
|
BLL.ProductionSchedulingPlanService.DeleteProductionSchedulingPlanByUnitWork(this.CurrUser.LoginProjectId, this.tvControlItem.SelectedNode.Text);
|
|
for (int i = 0; i < tb.Rows.Count; i++)
|
|
{
|
|
string unitWorkId = tb.Rows[i]["UnitWorkId"].ToString();//单位工程
|
|
string flowingSection = tb.Rows[i]["FlowingSection"].ToString();//流水号
|
|
string steelType = tb.Rows[i]["SteelType"].ToString();//材质Value
|
|
string material = tb.Rows[i]["Material"].ToString();//材质Text
|
|
string caliber = tb.Rows[i]["Caliber"].ToString();//寸径
|
|
var plan = BLL.ProductionSchedulingPlanService.GetProductionSchedulingPlan(this.CurrUser.LoginProjectId, flowingSection, unitWorkId, material, caliber);
|
|
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 = unitWorkId;
|
|
newPlan.FlowNum = flowingSection;
|
|
newPlan.MainItemName = tb.Rows[i]["UnitWorkName"].ToString();
|
|
newPlan.Material = material;
|
|
newPlan.Caliber = caliber;
|
|
newPlan.Dain = BLL.WeldJointService.GetSizeSum(this.CurrUser.LoginProjectId, unitWorkId, flowingSection, steelType, caliber, "1");
|
|
newPlan.TotalDyne = BLL.WeldJointService.GetSizeSumByUnitWorkIdAndFlowingSection(this.CurrUser.LoginProjectId, unitWorkId, flowingSection, "1");
|
|
newPlan.CompletedCount = BLL.WeldJointService.GetSizeSum(this.CurrUser.LoginProjectId, unitWorkId, flowingSection, steelType, caliber, "2");
|
|
if (newPlan.Dain > 0)
|
|
{
|
|
newPlan.CompletedRate = (newPlan.CompletedCount / newPlan.Dain) * 100;
|
|
}
|
|
else
|
|
{
|
|
newPlan.CompletedRate = 0;
|
|
}
|
|
if (newPlan.TotalDyne > 0)
|
|
{
|
|
decimal? completeDinSum = BLL.WeldJointService.GetSizeSumByUnitWorkIdAndFlowingSection(this.CurrUser.LoginProjectId, unitWorkId, flowingSection, "2");
|
|
newPlan.TotalCompletedRate = (completeDinSum / newPlan.TotalDyne) * 100;
|
|
}
|
|
else
|
|
{
|
|
newPlan.TotalCompletedRate = 0;
|
|
}
|
|
|
|
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);
|
|
// }
|
|
// }
|
|
// }
|
|
//}
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region 数据绑定
|
|
/// <summary>
|
|
/// 数据绑定
|
|
/// </summary>
|
|
private void BindGrid()
|
|
{
|
|
if (tvControlItem.SelectedNode == null) return;
|
|
string strSql = @"SELECT p.ProductionSchedulingPlanId,
|
|
p.ProjectId,
|
|
p.PipelineId,
|
|
p.FlowNum,
|
|
p.MainItemName,
|
|
p.Material,
|
|
p.Caliber,
|
|
p.Dain,
|
|
p.TotalDyne,
|
|
p.TotalPriority,
|
|
p.PriorityTotalDyne,
|
|
p.PlanStartDate,
|
|
p.PlanEndDate,
|
|
p.Days,
|
|
p.AvgDailyWorkload,
|
|
w.ProjectType,
|
|
p.CompletedCount,
|
|
p.CompletedRate,
|
|
p.TotalCompletedRate,
|
|
p.OnDayCompleteDyne,
|
|
p.NextDayCompleteDyne
|
|
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.PipelineId =@UnitWorkId";
|
|
listStr.Add(new SqlParameter("@UnitWorkId", this.tvControlItem.SelectedNode.NodeID));
|
|
|
|
}
|
|
else if (tvControlItem.SelectedNode.CommandName == "流水段")
|
|
{
|
|
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);
|
|
GridDataTable = tb;
|
|
// 2.获取当前分页数据
|
|
Grid1.RecordCount = tb.Rows.Count;
|
|
var table = this.GetPagedDataTable(Grid1, tb);
|
|
Grid1.DataSource = table;
|
|
Grid1.DataBind();
|
|
}
|
|
#endregion
|
|
|
|
#region 分页排序
|
|
#region 页索引改变事件
|
|
/// <summary>
|
|
/// 页索引改变事件
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void Grid1_PageIndexChange(object sender, GridPageEventArgs e)
|
|
{
|
|
BindGrid();
|
|
}
|
|
#endregion
|
|
|
|
#region 排序
|
|
/// <summary>
|
|
/// 排序
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void Grid1_Sort(object sender, GridSortEventArgs e)
|
|
{
|
|
BindGrid();
|
|
}
|
|
#endregion
|
|
|
|
#region 分页选择下拉改变事件
|
|
/// <summary>
|
|
/// 分页选择下拉改变事件
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void ddlPageSize_SelectedIndexChanged(object sender, EventArgs e)
|
|
{
|
|
Grid1.PageSize = Convert.ToInt32(ddlPageSize.SelectedValue);
|
|
BindGrid();
|
|
}
|
|
#endregion
|
|
#endregion
|
|
|
|
#region 维护事件
|
|
//protected void btnSearch_Click(object sender, EventArgs e)
|
|
//{
|
|
// BindGrid();
|
|
//}
|
|
|
|
#endregion
|
|
|
|
#region 关闭弹出窗口及刷新页面
|
|
/// <summary>
|
|
/// 查询
|
|
/// </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();
|
|
|
|
//}
|
|
#endregion
|
|
|
|
#region 保存
|
|
/// <summary>
|
|
/// 保存
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void btnSave_Click(object sender, EventArgs e)
|
|
{
|
|
if (this.Grid1.Rows.Count > 0)
|
|
{
|
|
foreach (JObject mergedRow in Grid1.GetMergedData())
|
|
{
|
|
JObject values = mergedRow.Value<JObject>("values");
|
|
int i = mergedRow.Value<int>("index");
|
|
string rowId = Grid1.Rows[i].RowID;
|
|
var newPlan = BLL.ProductionSchedulingPlanService.GetProductionSchedulingPlanById(rowId);
|
|
if (newPlan != null)
|
|
{
|
|
newPlan.TotalPriority = values.Value<string>("TotalPriority");
|
|
newPlan.PriorityTotalDyne = Funs.GetNewDecimal(values.Value<string>("PriorityTotalDyne"));
|
|
newPlan.PlanStartDate = Funs.GetNewDateTime(values.Value<string>("PlanStartDate"));
|
|
newPlan.PlanEndDate = Funs.GetNewDateTime(values.Value<string>("PlanEndDate"));
|
|
newPlan.Days = Funs.GetNewInt(values.Value<string>("Days"));
|
|
newPlan.AvgDailyWorkload = Funs.GetNewDecimal(values.Value<string>("AvgDailyWorkload"));
|
|
newPlan.OnDayCompleteDyne = Funs.GetNewDecimal(values.Value<string>("OnDayCompleteDyne"));
|
|
newPlan.NextDayCompleteDyne = Funs.GetNewDecimal(values.Value<string>("NextDayCompleteDyne"));
|
|
newPlan.CompletedCount = Funs.GetNewInt(values.Value<string>("CompletedCount"));
|
|
newPlan.CompletedRate = Funs.GetNewDecimal(values.Value<string>("CompletedRate"));
|
|
newPlan.TotalCompletedRate = Funs.GetNewDecimal(values.Value<string>("TotalCompletedRate"));
|
|
BLL.ProductionSchedulingPlanService.UpdateProductionSchedulingPlan(newPlan);
|
|
}
|
|
}
|
|
ShowNotify("保存成功!", MessageBoxIcon.Success);
|
|
BindGrid();
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region 导出
|
|
protected void btnOut_Click(object sender, EventArgs e)
|
|
{
|
|
string rootPath = Server.MapPath("~/");
|
|
string initTemplatePath = Const.HJGL_ProductionSchedulingPlanPath;
|
|
string uploadfilepath = string.Empty;
|
|
string newUrl = string.Empty;
|
|
uploadfilepath = rootPath + initTemplatePath;
|
|
|
|
var lists = (from x in Funs.DB.HJGL_ProductionSchedulingPlan
|
|
where x.ProjectId == this.CurrUser.LoginProjectId
|
|
select x);
|
|
|
|
if (tvControlItem.SelectedNode.CommandName.Split('|').Length == 2)
|
|
{
|
|
lists = lists.Where(x => x.MainItemName == this.tvControlItem.SelectedNode.Text);
|
|
}
|
|
else if (tvControlItem.SelectedNode.CommandName == "流水段")
|
|
{
|
|
lists = lists.Where(x => x.MainItemName == this.tvControlItem.SelectedNode.ParentNode.Text && x.FlowNum == this.tvControlItem.SelectedNode.Text);
|
|
}
|
|
lists = lists.OrderBy(x => x.Caliber).OrderBy(x => x.Material).OrderBy(x => x.FlowNum).OrderBy(x => x.MainItemName);
|
|
if (lists != null)
|
|
{
|
|
newUrl = uploadfilepath.Replace("排产计划导出模板", "排产计划-" + this.tvControlItem.SelectedNode.Text + "-" + DateTime.Now.ToString("yyyyMMdd"));
|
|
if (File.Exists(newUrl))
|
|
{
|
|
File.Delete(newUrl);
|
|
}
|
|
File.Copy(uploadfilepath, newUrl);
|
|
// 第一步:读取文件流
|
|
NPOI.SS.UserModel.IWorkbook workbook;
|
|
using (FileStream stream = new FileStream(newUrl, FileMode.Open, FileAccess.Read))
|
|
{
|
|
workbook = new NPOI.XSSF.UserModel.XSSFWorkbook(stream);
|
|
//workbook = new NPOI.HSSF.UserModel.HSSFWorkbook(stream);
|
|
}
|
|
// 创建单元格样式
|
|
NPOI.SS.UserModel.ICellStyle cellStyle = workbook.CreateCellStyle();
|
|
cellStyle.BorderTop = NPOI.SS.UserModel.BorderStyle.Thin;
|
|
cellStyle.BorderRight = NPOI.SS.UserModel.BorderStyle.Thin;
|
|
cellStyle.BorderBottom = NPOI.SS.UserModel.BorderStyle.Thin;
|
|
cellStyle.BorderLeft = NPOI.SS.UserModel.BorderStyle.Thin;
|
|
cellStyle.Alignment = NPOI.SS.UserModel.HorizontalAlignment.Center;
|
|
cellStyle.VerticalAlignment = NPOI.SS.UserModel.VerticalAlignment.Center;
|
|
cellStyle.WrapText = true;//自动换行
|
|
var font = workbook.CreateFont();
|
|
font.FontHeightInPoints = 11;
|
|
cellStyle.SetFont(font);
|
|
// 第二步:创建新数据行
|
|
NPOI.SS.UserModel.ISheet sheet = workbook.GetSheetAt(0);
|
|
NPOI.SS.UserModel.IRow row = sheet.GetRow(0);
|
|
NPOI.SS.UserModel.ICell cell;
|
|
int i = 1;
|
|
foreach (var item in lists)
|
|
{
|
|
// 第二步:创建新数据行
|
|
row = sheet.CreateRow(i);
|
|
// 添加数据
|
|
cell = row.CreateCell(0);
|
|
cell.CellStyle = cellStyle;
|
|
cell.SetCellValue(item.FlowNum);//流水段号
|
|
|
|
cell = row.CreateCell(1);
|
|
cell.CellStyle = cellStyle;
|
|
cell.SetCellValue(item.MainItemName);//主项名称
|
|
|
|
cell = row.CreateCell(2);
|
|
cell.CellStyle = cellStyle;
|
|
cell.SetCellValue(item.Material);//材质
|
|
|
|
cell = row.CreateCell(3);
|
|
cell.CellStyle = cellStyle;
|
|
cell.SetCellValue(item.Caliber);//口径
|
|
|
|
cell = row.CreateCell(4);
|
|
cell.CellStyle = cellStyle;
|
|
cell.SetCellValue(item.Dain.HasValue ? item.Dain.ToString() : "");//达因数
|
|
|
|
cell = row.CreateCell(5);
|
|
cell.CellStyle = cellStyle;
|
|
cell.SetCellValue(item.TotalDyne.HasValue ? item.TotalDyne.ToString() : "");//总达因数
|
|
|
|
cell = row.CreateCell(6);
|
|
cell.CellStyle = cellStyle;
|
|
cell.SetCellValue(item.TotalPriority);//总优先级
|
|
|
|
cell = row.CreateCell(7);
|
|
cell.CellStyle = cellStyle;
|
|
cell.SetCellValue(item.PriorityTotalDyne.HasValue ? item.PriorityTotalDyne.ToString() : "");//优先级总达因
|
|
|
|
cell = row.CreateCell(8);
|
|
cell.CellStyle = cellStyle;
|
|
cell.SetCellValue(item.PlanStartDate.HasValue ? string.Format("{0:yyyy-MM-dd}", item.PlanStartDate) : "");//计划开始时间
|
|
|
|
cell = row.CreateCell(9);
|
|
cell.CellStyle = cellStyle;
|
|
cell.SetCellValue(item.PlanEndDate.HasValue ? string.Format("{0:yyyy-MM-dd}", item.PlanEndDate) : "");//计划结束时间
|
|
|
|
cell = row.CreateCell(10);
|
|
cell.CellStyle = cellStyle;
|
|
cell.SetCellValue(item.Days.HasValue ? item.Days.ToString() : "");//天数
|
|
|
|
cell = row.CreateCell(11);
|
|
cell.CellStyle = cellStyle;
|
|
cell.SetCellValue(item.AvgDailyWorkload.HasValue ? item.AvgDailyWorkload.ToString() : "");//平均每天工作量
|
|
|
|
cell = row.CreateCell(12);
|
|
cell.CellStyle = cellStyle;
|
|
cell.SetCellValue(item.OnDayCompleteDyne.HasValue ? item.OnDayCompleteDyne.ToString() : "");//当日已完成量
|
|
|
|
cell = row.CreateCell(13);
|
|
cell.CellStyle = cellStyle;
|
|
cell.SetCellValue(item.NextDayCompleteDyne.HasValue ? item.NextDayCompleteDyne.ToString() : "");//次日应完成量
|
|
|
|
cell = row.CreateCell(14);
|
|
cell.CellStyle = cellStyle;
|
|
cell.SetCellValue(item.CompletedCount.HasValue ? item.CompletedCount.ToString() : "");//累计已完成量
|
|
|
|
cell = row.CreateCell(15);
|
|
cell.CellStyle = cellStyle;
|
|
cell.SetCellValue(item.CompletedRate.HasValue ? item.CompletedRate.ToString() : "");//已完成百分比
|
|
|
|
cell = row.CreateCell(16);
|
|
cell.CellStyle = cellStyle;
|
|
cell.SetCellValue(item.TotalCompletedRate.HasValue ? item.TotalCompletedRate.ToString() : "");//已完成百分比汇总
|
|
|
|
i++;
|
|
}
|
|
// 第三步:写入文件流
|
|
using (FileStream stream = new FileStream(newUrl, FileMode.Create, FileAccess.Write))
|
|
{
|
|
workbook.Write(stream);
|
|
workbook.Close();
|
|
}
|
|
string fileName = Path.GetFileName(newUrl);
|
|
FileInfo info = new FileInfo(newUrl);
|
|
long fileSize = info.Length;
|
|
Response.Clear();
|
|
Response.ContentType = "application/x-zip-compressed";
|
|
Response.AddHeader("Content-Disposition", "attachment;filename=" + System.Web.HttpUtility.UrlEncode(fileName, System.Text.Encoding.UTF8));
|
|
Response.AddHeader("Content-Length", fileSize.ToString());
|
|
Response.TransmitFile(newUrl, 0, fileSize);
|
|
Response.Flush();
|
|
Response.Close();
|
|
File.Delete(newUrl);
|
|
}
|
|
else
|
|
{
|
|
Alert.ShowInTop("当前无记录,无法导出!", MessageBoxIcon.Warning);
|
|
}
|
|
}
|
|
#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
|
|
}
|
|
} |