赛鼎焊接修改

This commit is contained in:
2025-06-04 22:46:21 +08:00
parent d99ff19b09
commit b603b27f0b
40 changed files with 3265 additions and 118 deletions
@@ -229,36 +229,36 @@ namespace FineUIPro.Web.HJGL.PreDesign
private DataTable BindData()
{
string strSql = @"WITH cte as (select pipeline.PipelineCode as PipelineCode,
comonent.PipelineComponentCode as PipelineComponentCode,
'' as matdef,
packdetail.Number as Number,
pack.PackagingCode as PackagingCode,
trainnumber.TrainNumber as TrainNumber,
pipeline.FlowingSection as FlowingSection,
pipeline.UnitWorkId as UnitWorkId
from HJGL_Pipeline pipeline
left join HJGL_PackagingManageDetail packdetail on pipeline.PipelineId = packdetail.PipelineId
left join HJGL_Pipeline_Component comonent
on packdetail.PipelineComponentId = comonent.PipelineComponentId
left join HJGL_PackagingManage pack on packdetail.PackagingManageId = pack.PackagingManageId
left join HJGL_TrainNumberManage trainnumber on pack.TrainNumberId = TrainNumber.Id
where (packdetail.PipelineComponentId is not null or packdetail.PipelineComponentId != '')
union all
select pipeline.PipelineCode as PipelineCode,
packdetail.MaterialCode as PipelineComponentCode,
matlib.MaterialDef as matdef,
packdetail.Number as Number,
pack.PackagingCode as PackagingCode,
trainnumber.TrainNumber as TrainNumber,
pipeline.FlowingSection as FlowingSection,
pipeline.UnitWorkId as UnitWorkId
from HJGL_Pipeline pipeline
left join HJGL_PackagingManageDetail packdetail on pipeline.PipelineId = packdetail.PipelineId
left join HJGL_MaterialCodeLib matlib on packdetail.MaterialCode = matlib.MaterialCode
left join HJGL_PackagingManage pack on packdetail.PackagingManageId = pack.PackagingManageId
left join HJGL_TrainNumberManage trainnumber on pack.TrainNumberId = TrainNumber.Id
where (packdetail.PipelineComponentId is null or packdetail.PipelineComponentId = ''))
SELECT * FROM cte WHERE 1=1 ";
comonent.PipelineComponentCode as PipelineComponentCode,
'' as matdef,
packdetail.Number as Number,
pack.PackagingCode as PackagingCode,
trainnumber.TrainNumber as TrainNumber,
pipeline.FlowingSection as FlowingSection,
pipeline.UnitWorkId as UnitWorkId
from HJGL_Pipeline pipeline
left join HJGL_PackagingManageDetail packdetail on pipeline.PipelineId = packdetail.PipelineId
left join HJGL_Pipeline_Component comonent
on packdetail.PipelineComponentId = comonent.PipelineComponentId
left join HJGL_PackagingManage pack on packdetail.PackagingManageId = pack.PackagingManageId
left join HJGL_TrainNumberManage trainnumber on pack.TrainNumberId = TrainNumber.Id
where (packdetail.PipelineComponentId is not null or packdetail.PipelineComponentId != '')
union all
select pipeline.PipelineCode as PipelineCode,
packdetail.MaterialCode as PipelineComponentCode,
matlib.MaterialDef as matdef,
packdetail.Number as Number,
pack.PackagingCode as PackagingCode,
trainnumber.TrainNumber as TrainNumber,
pipeline.FlowingSection as FlowingSection,
pipeline.UnitWorkId as UnitWorkId
from HJGL_Pipeline pipeline
left join HJGL_PackagingManageDetail packdetail on pipeline.PipelineId = packdetail.PipelineId
left join HJGL_MaterialCodeLib matlib on packdetail.MaterialCode = matlib.MaterialCode
left join HJGL_PackagingManage pack on packdetail.PackagingManageId = pack.PackagingManageId
left join HJGL_TrainNumberManage trainnumber on pack.TrainNumberId = TrainNumber.Id
where (packdetail.PipelineComponentId is null or packdetail.PipelineComponentId = ''))
SELECT * FROM cte WHERE 1=1 ";
List<SqlParameter> listStr = new List<SqlParameter>();
if (tvControlItem.SelectedNode.CommandName.Split('|').Length == 2)
@@ -390,7 +390,7 @@ SELECT * FROM cte WHERE 1=1 ";
线 = x.Field<string>("PipelineCode"),
= x.Field<string>("PipelineComponentCode"),
= !string.IsNullOrWhiteSpace(x.Field<string>("matdef")) ? x.Field<string>("matdef") : "-",
= x.Field<string>("Number"),
= x.Field<decimal?>("Number"),
= x.Field<string>("PackagingCode"),
= x.Field<string>("TrainNumber"),
= x.Field<string>("FlowingSection")
@@ -1,4 +1,5 @@
using BLL;
using Model;
using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
@@ -122,6 +123,27 @@ namespace FineUIPro.Web.HJGL.PreDesign
{
table.PipelineComponentId = string.Join(",", dropPipelineComponentCode.Values);
var newDetailList= new List<Model.HJGL_PackagingManageDetail>();
foreach (var item in dropPipelineComponentCode.Values)
{
var ComponentModel = BLL.HJGL_PipelineComponentService.GetPipelineComponentById(item);
if (ComponentModel != null)
{
var model = new Model.HJGL_PackagingManageDetail()
{
Id = SQLHelper.GetNewID(),
PackagingManageId = this.PackagingManageId,
PipelineId = ComponentModel.PipelineId,
PipelineComponentId = item,
CreateTime = DateTime.Now,
CreateUser = this.CurrUser.PersonId,
};
newDetailList.Add(model);
}
}
HJGLPackagingmanagedetailService.DeleteByPackagingManageId(this.PackagingManageId);
HJGLPackagingmanagedetailService.AddBulk(newDetailList);
}
}
BLL.HJGL_PackagingmanageService.UpdateHJGL_PackagingManage(table);
@@ -0,0 +1,171 @@
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="ProductionSchedulingPlan.aspx.cs" Inherits="FineUIPro.Web.HJGL.PreDesign.ProductionSchedulingPlan" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>排产计划</title>
<link href="../../res/css/common.css" rel="stylesheet" type="text/css" />
</head>
<body>
<form id="form1" runat="server">
<f:PageManager ID="PageManager1" AutoSizePanelID="Panel1" runat="server" />
<f:Panel ID="Panel1" runat="server" ShowBorder="false" ShowHeader="false" Layout="Region">
<Items>
<f:Panel runat="server" ID="panelLeftRegion" RegionPosition="Left" RegionSplit="true"
EnableCollapse="true" Width="300px" Title="WBS目录"
ShowBorder="true" Layout="VBox" ShowHeader="true" AutoScroll="true" BodyPadding="5px"
IconFont="ArrowCircleLeft">
<Toolbars>
<f:Toolbar ID="Toolbar1" Position="Top" runat="server" ToolbarAlign="Left">
<Items>
<f:TextBox ID="txtPipelineCode" runat="server" Label="管线"
EmptyText="输入查询条件" Width="280px" LabelWidth="60px">
</f:TextBox>
<f:HiddenField runat="server" ID="hdUnitWorkId"></f:HiddenField>
</Items>
</f:Toolbar>
<f:Toolbar runat="server" ToolbarAlign="Right">
<Items>
<f:ToolbarFill runat="server"></f:ToolbarFill>
<f:Button ID="btnTreeFind" ToolTip="查询" Icon="SystemSearch"
EnablePostBack="true" OnClick="btnTreeFind_Click" runat="server">
</f:Button>
</Items>
</f:Toolbar>
</Toolbars>
<Items>
<f:Tree ID="tvControlItem" ShowHeader="false" Height="560px" Title="单位工程"
OnNodeCommand="tvControlItem_NodeCommand" runat="server" ShowBorder="false" EnableCollapse="true"
EnableSingleClickExpand="false" AutoLeafIdentification="true" OnNodeExpand="tvControlItem_TreeNodeExpanded"
EnableTextSelection="true">
</f:Tree>
</Items>
</f:Panel>
<f:Panel runat="server" ID="panelCenterRegion" RegionPosition="Center" ShowBorder="true"
Layout="VBox" ShowHeader="false" BodyPadding="5px" IconFont="PlusCircle" Title="排产计划"
TitleToolTip="排产计划" AutoScroll="true">
<Toolbars>
<f:Toolbar ID="Toolbar3" Position="Top" runat="server" ToolbarAlign="Left">
<Items>
<f:ToolbarFill ID="ToolbarFill1" runat="server">
</f:ToolbarFill>
<f:Button ID="btnSave" runat="server" OnClick="btnSave_Click" Text="保存" Icon="SystemSave"></f:Button>
<f:Button ID="btnOut" OnClick="btnOut_Click" runat="server" Text="导出"
Icon="TableGo" EnableAjax="false" EnablePostBack="true" >
</f:Button>
</Items>
</f:Toolbar>
</Toolbars>
<Items>
<f:Grid ID="Grid1" ShowBorder="true" ShowHeader="false" Title="排产计划" ForceFit="false"
EnableCollapse="true" runat="server" BoxFlex="1" DataKeyNames="ProductionSchedulingPlanId" AllowCellEditing="true"
AllowColumnLocking="true" EnableColumnLines="true" ClicksToEdit="1" DataIDField="ProductionSchedulingPlanId"
AllowSorting="true" SortField="FlowNum" SortDirection="ASC" OnSort="Grid1_Sort"
AllowPaging="true" IsDatabasePaging="true" PageSize="15" OnPageIndexChange="Grid1_PageIndexChange"
EnableTextSelection="True">
<Columns>
<f:RowNumberField EnablePagingNumber="true" HeaderText="序号"
Width="60px" HeaderTextAlign="Center" TextAlign="Center" />
<f:RenderField HeaderText="流水段号" ColumnID="FlowNum"
DataField="FlowNum" SortField="FlowNum" FieldType="String" HeaderTextAlign="Center" TextAlign="Left"
Width="120px">
</f:RenderField>
<f:RenderField HeaderText="主项名称" ColumnID="MainItemName"
DataField="MainItemName" SortField="MainItemName" FieldType="String" HeaderTextAlign="Center" TextAlign="Left"
Width="120px">
</f:RenderField>
<f:RenderField HeaderText="材质" ColumnID="Material"
DataField="Material" SortField="Material" FieldType="String" HeaderTextAlign="Center" TextAlign="Left"
Width="100px">
</f:RenderField>
<f:RenderField HeaderText="口径" ColumnID="Caliber"
DataField="Caliber" SortField="Caliber" FieldType="String" HeaderTextAlign="Center" TextAlign="Left"
Width="100px">
</f:RenderField>
<f:RenderField HeaderText="达因数" ColumnID="Dain"
DataField="Dain" SortField="Dain" FieldType="Float" HeaderTextAlign="Center" TextAlign="Left"
Width="90px">
</f:RenderField>
<f:RenderField HeaderText="总达因" ColumnID="TotalDyne"
DataField="TotalDyne" SortField="TotalDyne" FieldType="Float" HeaderTextAlign="Center" TextAlign="Left"
Width="90px">
</f:RenderField>
<f:RenderField HeaderText="总优先级" ColumnID="TotalPriority"
DataField="TotalPriority" SortField="TotalPriority" FieldType="String" HeaderTextAlign="Center" TextAlign="Left"
Width="100px">
<Editor>
<f:TextBox ID="txtTotalPriority" runat="server"></f:TextBox>
</Editor>
</f:RenderField>
<f:RenderField HeaderText="优先级总达因" ColumnID="PriorityTotalDyne"
DataField="PriorityTotalDyne" SortField="PriorityTotalDyne" FieldType="Float" HeaderTextAlign="Center" TextAlign="Left"
Width="120px">
<Editor>
<f:NumberBox ID="txtPriorityTotalDyne" runat="server"></f:NumberBox>
</Editor>
</f:RenderField>
<f:RenderField HeaderText="计划开始时间" ColumnID="PlanStartDate"
DataField="PlanStartDate" SortField="PlanStartDate" FieldType="Date" Renderer="Date" RendererArgument="yyyy-MM-dd" HeaderTextAlign="Center" TextAlign="Left"
Width="120px">
<Editor>
<f:DatePicker ID="txtPlanStartDate" runat="server"></f:DatePicker>
</Editor>
</f:RenderField>
<f:RenderField HeaderText="计划结束时间" ColumnID="PlanEndDate"
DataField="PlanEndDate" SortField="PlanEndDate" FieldType="Date" Renderer="Date" RendererArgument="yyyy-MM-dd" HeaderTextAlign="Center" TextAlign="Left"
Width="120px">
<Editor>
<f:DatePicker ID="txtPlanEndDate" runat="server"></f:DatePicker>
</Editor>
</f:RenderField>
<f:RenderField HeaderText="天数" ColumnID="Days"
DataField="Days" SortField="Days" FieldType="Int" HeaderTextAlign="Center" TextAlign="Left"
Width="90px">
<Editor>
<f:NumberBox ID="txtDays" runat="server" NoDecimal="true" NoNegative="true"></f:NumberBox>
</Editor>
</f:RenderField>
<f:RenderField HeaderText="平均每天工作量" ColumnID="AvgDailyWorkload"
DataField="AvgDailyWorkload" SortField="AvgDailyWorkload" FieldType="Float" HeaderTextAlign="Center" TextAlign="Left"
Width="120px">
<Editor>
<f:NumberBox ID="txtAvgDailyWorkload" runat="server" NoNegative="true"></f:NumberBox>
</Editor>
</f:RenderField>
</Columns>
<Listeners>
<f:Listener Event="dataload" Handler="onGridDataLoad" />
</Listeners>
<PageItems>
<f:ToolbarSeparator ID="ToolbarSeparator1" runat="server">
</f:ToolbarSeparator>
<f:ToolbarText ID="ToolbarText1" runat="server" Text="每页记录数:">
</f:ToolbarText>
<f:DropDownList runat="server" ID="ddlPageSize" Width="80px" AutoPostBack="true"
OnSelectedIndexChanged="ddlPageSize_SelectedIndexChanged">
<f:ListItem Text="10" Value="10" />
<f:ListItem Text="15" Value="15" />
<f:ListItem Text="20" Value="20" />
<f:ListItem Text="25" Value="25" />
<f:ListItem Text="所有行" Value="10000" />
</f:DropDownList>
</PageItems>
</f:Grid>
</Items>
</f:Panel>
</Items>
</f:Panel>
</form>
<script type="text/javascript">
function reloadGrid() {
__doPostBack(null, 'reloadGrid');
}
function onGridDataLoad(event) {
this.mergeColumns(['FlowNum', 'MainItemName', 'Material', 'TotalDyne']);
}
</script>
</body>
</html>
@@ -0,0 +1,526 @@
using BLL;
using MiniExcelLibs;
using Model;
using Newtonsoft.Json.Linq;
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.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" && x.PipelineCode.Contains(txtPipelineCode.Text.Trim()) 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" && x.PipelineCode.Contains(txtPipelineCode.Text.Trim()) 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 && x.PipelineCode.Contains(this.txtPipelineCode.Text.Trim()) 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))
{
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)
{
var plan = BLL.ProductionSchedulingPlanService.GetProductionSchedulingPlan(this.CurrUser.LoginProjectId, item.FlowingSection, item.UnitWorkName, item.Material, item.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 = 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);
}
}
}
}
#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
FROM HJGL_ProductionSchedulingPlan p
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));
}
else if (tvControlItem.SelectedNode.CommandName == "流水段")
{
strSql += " and p.FlowNum = @FlowNum ";
listStr.Add(new SqlParameter("@FlowNum", this.tvControlItem.SelectedNode.Text));
}
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"));
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.FlowNum == this.tvControlItem.SelectedNode.Text);
}
if (lists != null)
{
newUrl = uploadfilepath.Replace("排产计划导出模板", "排产计划(" + 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():"");//平均每天工作量
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
}
}
@@ -0,0 +1,233 @@
//------------------------------------------------------------------------------
// <自动生成>
// 此代码由工具生成。
//
// 对此文件的更改可能导致不正确的行为,如果
// 重新生成代码,则所做更改将丢失。
// </自动生成>
//------------------------------------------------------------------------------
namespace FineUIPro.Web.HJGL.PreDesign
{
public partial class ProductionSchedulingPlan
{
/// <summary>
/// form1 控件。
/// </summary>
/// <remarks>
/// 自动生成的字段。
/// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。
/// </remarks>
protected global::System.Web.UI.HtmlControls.HtmlForm form1;
/// <summary>
/// PageManager1 控件。
/// </summary>
/// <remarks>
/// 自动生成的字段。
/// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。
/// </remarks>
protected global::FineUIPro.PageManager PageManager1;
/// <summary>
/// Panel1 控件。
/// </summary>
/// <remarks>
/// 自动生成的字段。
/// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。
/// </remarks>
protected global::FineUIPro.Panel Panel1;
/// <summary>
/// panelLeftRegion 控件。
/// </summary>
/// <remarks>
/// 自动生成的字段。
/// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。
/// </remarks>
protected global::FineUIPro.Panel panelLeftRegion;
/// <summary>
/// Toolbar1 控件。
/// </summary>
/// <remarks>
/// 自动生成的字段。
/// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。
/// </remarks>
protected global::FineUIPro.Toolbar Toolbar1;
/// <summary>
/// txtPipelineCode 控件。
/// </summary>
/// <remarks>
/// 自动生成的字段。
/// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。
/// </remarks>
protected global::FineUIPro.TextBox txtPipelineCode;
/// <summary>
/// hdUnitWorkId 控件。
/// </summary>
/// <remarks>
/// 自动生成的字段。
/// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。
/// </remarks>
protected global::FineUIPro.HiddenField hdUnitWorkId;
/// <summary>
/// btnTreeFind 控件。
/// </summary>
/// <remarks>
/// 自动生成的字段。
/// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。
/// </remarks>
protected global::FineUIPro.Button btnTreeFind;
/// <summary>
/// tvControlItem 控件。
/// </summary>
/// <remarks>
/// 自动生成的字段。
/// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。
/// </remarks>
protected global::FineUIPro.Tree tvControlItem;
/// <summary>
/// panelCenterRegion 控件。
/// </summary>
/// <remarks>
/// 自动生成的字段。
/// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。
/// </remarks>
protected global::FineUIPro.Panel panelCenterRegion;
/// <summary>
/// Toolbar3 控件。
/// </summary>
/// <remarks>
/// 自动生成的字段。
/// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。
/// </remarks>
protected global::FineUIPro.Toolbar Toolbar3;
/// <summary>
/// ToolbarFill1 控件。
/// </summary>
/// <remarks>
/// 自动生成的字段。
/// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。
/// </remarks>
protected global::FineUIPro.ToolbarFill ToolbarFill1;
/// <summary>
/// btnSave 控件。
/// </summary>
/// <remarks>
/// 自动生成的字段。
/// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。
/// </remarks>
protected global::FineUIPro.Button btnSave;
/// <summary>
/// btnOut 控件。
/// </summary>
/// <remarks>
/// 自动生成的字段。
/// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。
/// </remarks>
protected global::FineUIPro.Button btnOut;
/// <summary>
/// Grid1 控件。
/// </summary>
/// <remarks>
/// 自动生成的字段。
/// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。
/// </remarks>
protected global::FineUIPro.Grid Grid1;
/// <summary>
/// txtTotalPriority 控件。
/// </summary>
/// <remarks>
/// 自动生成的字段。
/// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。
/// </remarks>
protected global::FineUIPro.TextBox txtTotalPriority;
/// <summary>
/// txtPriorityTotalDyne 控件。
/// </summary>
/// <remarks>
/// 自动生成的字段。
/// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。
/// </remarks>
protected global::FineUIPro.NumberBox txtPriorityTotalDyne;
/// <summary>
/// txtPlanStartDate 控件。
/// </summary>
/// <remarks>
/// 自动生成的字段。
/// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。
/// </remarks>
protected global::FineUIPro.DatePicker txtPlanStartDate;
/// <summary>
/// txtPlanEndDate 控件。
/// </summary>
/// <remarks>
/// 自动生成的字段。
/// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。
/// </remarks>
protected global::FineUIPro.DatePicker txtPlanEndDate;
/// <summary>
/// txtDays 控件。
/// </summary>
/// <remarks>
/// 自动生成的字段。
/// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。
/// </remarks>
protected global::FineUIPro.NumberBox txtDays;
/// <summary>
/// txtAvgDailyWorkload 控件。
/// </summary>
/// <remarks>
/// 自动生成的字段。
/// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。
/// </remarks>
protected global::FineUIPro.NumberBox txtAvgDailyWorkload;
/// <summary>
/// ToolbarSeparator1 控件。
/// </summary>
/// <remarks>
/// 自动生成的字段。
/// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。
/// </remarks>
protected global::FineUIPro.ToolbarSeparator ToolbarSeparator1;
/// <summary>
/// ToolbarText1 控件。
/// </summary>
/// <remarks>
/// 自动生成的字段。
/// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。
/// </remarks>
protected global::FineUIPro.ToolbarText ToolbarText1;
/// <summary>
/// ddlPageSize 控件。
/// </summary>
/// <remarks>
/// 自动生成的字段。
/// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。
/// </remarks>
protected global::FineUIPro.DropDownList ddlPageSize;
}
}