feat(clgl): 支持历史出库数据导入
历史出库数据需要批量补录并同步形成出库申请单、出库单和库存扣减。 新增出库申请历史导入入口,按仓库、材料编码、炉号、批号、数量、 出库时间和领用单位校验模板数据,并按材料单位拆分管段/管件单据。
This commit is contained in:
@@ -86,6 +86,8 @@
|
||||
</f:Button>
|
||||
<f:Button ID="btnNew" Text="新增" Icon="Add" runat="server" OnClick="btnNew_Click" Hidden="true">
|
||||
</f:Button>
|
||||
<f:Button ID="btnHistoryImport" Text="历史导入" Icon="ApplicationGet" runat="server" OnClick="btnHistoryImport_Click" Hidden="true">
|
||||
</f:Button>
|
||||
<f:Button ID="btnPassMaster" Text="专工审核" Icon="ArrowRefresh" runat="server" OnClick="btnPassMaster_OnClick" Hidden="true">
|
||||
</f:Button>
|
||||
<f:Button ID="btnPassMaster2" Text="材控审核" Icon="ArrowRefresh" runat="server" OnClick="btnPassMaster2_OnClick" Hidden="true">
|
||||
|
||||
@@ -413,6 +413,26 @@ namespace FineUIPro.Web.CLGL
|
||||
}
|
||||
}
|
||||
|
||||
protected void btnHistoryImport_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (CommonService.GetAllButtonPowerList(this.CurrUser.LoginProjectId, this.CurrUser.PersonId, Const.Tw_OutPlanMasterMenuId, Const.BtnAdd))
|
||||
{
|
||||
if (string.IsNullOrEmpty(tvControlItem.SelectedNodeID))
|
||||
{
|
||||
Alert.ShowInTop("请选择单位工程!", MessageBoxIcon.Warning);
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
PageContext.RegisterStartupScript(Window2.GetShowReference(String.Format("OutPlanMasterHistoryImport.aspx?UnitWorkId={0}", tvControlItem.SelectedNodeID)));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ShowNotify("您没有这个权限,请与管理员联系!", MessageBoxIcon.Warning);
|
||||
}
|
||||
}
|
||||
|
||||
protected void btnMenuInOutPlanMasterDelete_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (CommonService.GetAllButtonPowerList(this.CurrUser.LoginProjectId, this.CurrUser.PersonId, Const.Tw_OutPlanMasterMenuId, Const.BtnDelete))
|
||||
@@ -680,6 +700,7 @@ namespace FineUIPro.Web.CLGL
|
||||
if (buttonList.Contains(BLL.Const.BtnAdd))
|
||||
{
|
||||
this.btnNew.Hidden = false;
|
||||
this.btnHistoryImport.Hidden = false;
|
||||
}
|
||||
if (buttonList.Contains(BLL.Const.BtnModify))
|
||||
{
|
||||
@@ -703,4 +724,4 @@ namespace FineUIPro.Web.CLGL
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -185,6 +185,15 @@ namespace FineUIPro.Web.CLGL
|
||||
/// </remarks>
|
||||
protected global::FineUIPro.Button btnNew;
|
||||
|
||||
/// <summary>
|
||||
/// btnHistoryImport 控件。
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// 自动生成的字段。
|
||||
/// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。
|
||||
/// </remarks>
|
||||
protected global::FineUIPro.Button btnHistoryImport;
|
||||
|
||||
/// <summary>
|
||||
/// btnPassMaster 控件。
|
||||
/// </summary>
|
||||
|
||||
@@ -0,0 +1,49 @@
|
||||
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="OutPlanMasterHistoryImport.aspx.cs" Inherits="FineUIPro.Web.CLGL.OutPlanMasterHistoryImport" %>
|
||||
|
||||
<!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>
|
||||
</head>
|
||||
<body>
|
||||
<form id="form1" runat="server">
|
||||
<f:PageManager ID="PageManager1" AutoSizePanelID="SimpleForm1" runat="server" />
|
||||
<f:Form ID="SimpleForm1" ShowBorder="false" ShowHeader="false" BodyPadding="10px"
|
||||
runat="server" RedStarPosition="BeforeText" LabelAlign="Right">
|
||||
<Toolbars>
|
||||
<f:Toolbar ID="Toolbar1" Position="Top" ToolbarAlign="Right" runat="server">
|
||||
<Items>
|
||||
<f:HiddenField ID="hdFileName" runat="server">
|
||||
</f:HiddenField>
|
||||
<f:Button ID="btnDownLoad" runat="server" Icon="ApplicationGo" ToolTip="下载模板"
|
||||
Text="下载模板" OnClick="btnDownLoad_Click" EnablePostBack="true" EnableAjax="false">
|
||||
</f:Button>
|
||||
<f:ToolbarFill runat="server">
|
||||
</f:ToolbarFill>
|
||||
<f:Button ID="btnImport" Icon="ApplicationGet" runat="server" ToolTip="导入"
|
||||
Text="导入" ValidateForms="SimpleForm1" OnClick="btnImport_Click">
|
||||
</f:Button>
|
||||
</Items>
|
||||
</f:Toolbar>
|
||||
</Toolbars>
|
||||
<Rows>
|
||||
<f:FormRow>
|
||||
<Items>
|
||||
<f:FileUpload runat="server" ID="fuAttachUrl" EmptyText="选择要导入的文件"
|
||||
Label="选择要导入的文件" LabelWidth="150px">
|
||||
</f:FileUpload>
|
||||
</Items>
|
||||
</f:FormRow>
|
||||
<f:FormRow>
|
||||
<Items>
|
||||
<f:Label runat="server" ID="lblTip" EncodeText="false"
|
||||
Text="模板列:仓库、材料编码、炉号、批号、数量、出库时间、领用单位。导入后会按材料单位自动拆分管段/管件单据,并直接生成出库单扣减对应仓库的库存。">
|
||||
</f:Label>
|
||||
</Items>
|
||||
</f:FormRow>
|
||||
</Rows>
|
||||
</f:Form>
|
||||
</form>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,137 @@
|
||||
using BLL;
|
||||
using MiniExcelLibs;
|
||||
using Model;
|
||||
using System;
|
||||
using System.Data;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using System.Web;
|
||||
|
||||
namespace FineUIPro.Web.CLGL
|
||||
{
|
||||
public partial class OutPlanMasterHistoryImport : PageBase
|
||||
{
|
||||
private readonly string initPath = Const.ExcelUrl;
|
||||
|
||||
/// <summary>
|
||||
/// 单位工程主键
|
||||
/// </summary>
|
||||
public string UnitWorkId
|
||||
{
|
||||
get
|
||||
{
|
||||
return (string)ViewState["UnitWorkId"];
|
||||
}
|
||||
set
|
||||
{
|
||||
ViewState["UnitWorkId"] = value;
|
||||
}
|
||||
}
|
||||
|
||||
protected void Page_Load(object sender, EventArgs e)
|
||||
{
|
||||
if (!IsPostBack)
|
||||
{
|
||||
UnitWorkId = Request.Params["UnitWorkId"];
|
||||
hdFileName.Text = string.Empty;
|
||||
}
|
||||
}
|
||||
|
||||
protected void btnImport_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (string.IsNullOrEmpty(UnitWorkId))
|
||||
{
|
||||
ShowNotify("请选择单位工程!", MessageBoxIcon.Warning);
|
||||
return;
|
||||
}
|
||||
|
||||
if (fuAttachUrl.HasFile == false)
|
||||
{
|
||||
ShowNotify("请选择Excel文件!", MessageBoxIcon.Warning);
|
||||
return;
|
||||
}
|
||||
|
||||
string isXls = Path.GetExtension(fuAttachUrl.FileName).Trim().ToLower();
|
||||
if (isXls != ".xlsx")
|
||||
{
|
||||
ShowNotify("只能选择xlsx格式Excel文件!", MessageBoxIcon.Warning);
|
||||
return;
|
||||
}
|
||||
|
||||
string rootPath = Server.MapPath("~/");
|
||||
string initFullPath = rootPath + initPath;
|
||||
if (!Directory.Exists(initFullPath))
|
||||
{
|
||||
Directory.CreateDirectory(initFullPath);
|
||||
}
|
||||
|
||||
hdFileName.Text = Funs.GetNewFileName() + isXls;
|
||||
string filePath = initFullPath + hdFileName.Text;
|
||||
fuAttachUrl.PostedFile.SaveAs(filePath);
|
||||
|
||||
ResponeData responeData = TwInOutplanmasterService.ImportOutHistoryData(
|
||||
fuAttachUrl.FileName,
|
||||
filePath,
|
||||
this.CurrUser.LoginProjectId,
|
||||
this.CurrUser.PersonId,
|
||||
UnitWorkId);
|
||||
|
||||
if (responeData.code == 1)
|
||||
{
|
||||
DeleteTempFile(filePath);
|
||||
ShowNotify(responeData.message, MessageBoxIcon.Success);
|
||||
PageContext.RegisterStartupScript(ActiveWindow.GetHideRefreshReference());
|
||||
}
|
||||
else
|
||||
{
|
||||
Alert alert = new Alert
|
||||
{
|
||||
Message = responeData.message,
|
||||
MessageBoxIcon = MessageBoxIcon.Error
|
||||
};
|
||||
alert.Show();
|
||||
}
|
||||
}
|
||||
|
||||
protected void btnDownLoad_Click(object sender, EventArgs e)
|
||||
{
|
||||
string rootPath = Server.MapPath("~/");
|
||||
string tempDirectory = rootPath + @"File\Excel\Temp\";
|
||||
if (!Directory.Exists(tempDirectory))
|
||||
{
|
||||
Directory.CreateDirectory(tempDirectory);
|
||||
}
|
||||
|
||||
string tempPath = tempDirectory + "历史出库数据导入模板" + string.Format("{0:yyyyMMddHHmmss}", DateTime.Now) + ".xlsx";
|
||||
DataTable template = new DataTable();
|
||||
template.Columns.Add("仓库");
|
||||
template.Columns.Add("材料编码");
|
||||
template.Columns.Add("炉号");
|
||||
template.Columns.Add("批号");
|
||||
template.Columns.Add("数量");
|
||||
template.Columns.Add("出库时间");
|
||||
template.Columns.Add("领用单位");
|
||||
MiniExcel.SaveAs(tempPath, template);
|
||||
|
||||
FileInfo info = new FileInfo(tempPath);
|
||||
long fileSize = info.Length;
|
||||
Response.ClearContent();
|
||||
Response.AddHeader("Content-Disposition", "attachment;filename=" + HttpUtility.UrlEncode("历史出库数据导入模板.xlsx", Encoding.UTF8));
|
||||
Response.ContentType = "excel/plain";
|
||||
Response.ContentEncoding = Encoding.UTF8;
|
||||
Response.AddHeader("Content-Length", fileSize.ToString().Trim());
|
||||
Response.TransmitFile(tempPath, 0, fileSize);
|
||||
Response.Flush();
|
||||
Response.Close();
|
||||
DeleteTempFile(tempPath);
|
||||
}
|
||||
|
||||
private void DeleteTempFile(string filePath)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(filePath) && File.Exists(filePath))
|
||||
{
|
||||
File.Delete(filePath);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,98 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <自动生成>
|
||||
// 此代码由工具生成。
|
||||
//
|
||||
// 对此文件的更改可能导致不正确的行为,如果
|
||||
// 重新生成代码,则所做更改将丢失。
|
||||
// </自动生成>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace FineUIPro.Web.CLGL
|
||||
{
|
||||
|
||||
|
||||
public partial class OutPlanMasterHistoryImport
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// form1 控件。
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// 自动生成的字段。
|
||||
/// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。
|
||||
/// </remarks>
|
||||
protected global::System.Web.UI.HtmlControls.HtmlForm form1;
|
||||
|
||||
/// <summary>
|
||||
/// PageManager1 控件。
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// 自动生成的字段。
|
||||
/// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。
|
||||
/// </remarks>
|
||||
protected global::FineUIPro.PageManager PageManager1;
|
||||
|
||||
/// <summary>
|
||||
/// SimpleForm1 控件。
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// 自动生成的字段。
|
||||
/// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。
|
||||
/// </remarks>
|
||||
protected global::FineUIPro.Form SimpleForm1;
|
||||
|
||||
/// <summary>
|
||||
/// Toolbar1 控件。
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// 自动生成的字段。
|
||||
/// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。
|
||||
/// </remarks>
|
||||
protected global::FineUIPro.Toolbar Toolbar1;
|
||||
|
||||
/// <summary>
|
||||
/// hdFileName 控件。
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// 自动生成的字段。
|
||||
/// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。
|
||||
/// </remarks>
|
||||
protected global::FineUIPro.HiddenField hdFileName;
|
||||
|
||||
/// <summary>
|
||||
/// btnDownLoad 控件。
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// 自动生成的字段。
|
||||
/// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。
|
||||
/// </remarks>
|
||||
protected global::FineUIPro.Button btnDownLoad;
|
||||
|
||||
/// <summary>
|
||||
/// btnImport 控件。
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// 自动生成的字段。
|
||||
/// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。
|
||||
/// </remarks>
|
||||
protected global::FineUIPro.Button btnImport;
|
||||
|
||||
/// <summary>
|
||||
/// fuAttachUrl 控件。
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// 自动生成的字段。
|
||||
/// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。
|
||||
/// </remarks>
|
||||
protected global::FineUIPro.FileUpload fuAttachUrl;
|
||||
|
||||
/// <summary>
|
||||
/// lblTip 控件。
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// 自动生成的字段。
|
||||
/// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。
|
||||
/// </remarks>
|
||||
protected global::FineUIPro.Label lblTip;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user