feat(clgl): 支持历史出库数据导入
历史出库数据需要批量补录并同步形成出库申请单、出库单和库存扣减。 新增出库申请历史导入入口,按仓库、材料编码、炉号、批号、数量、 出库时间和领用单位校验模板数据,并按材料单位拆分管段/管件单据。
This commit is contained in:
@@ -6,6 +6,7 @@ using Model;
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections;
|
using System.Collections;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Globalization;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
|
||||||
|
|
||||||
@@ -388,6 +389,272 @@ namespace BLL
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 导入历史出库数据,直接生成出库申请单和出库单并扣减库存
|
||||||
|
/// </summary>
|
||||||
|
public static ResponeData ImportOutHistoryData(string oriFileName, string path, string projectId, string createUserId, string unitWorkId)
|
||||||
|
{
|
||||||
|
var responeData = new ResponeData();
|
||||||
|
if (string.IsNullOrEmpty(unitWorkId))
|
||||||
|
{
|
||||||
|
responeData.code = 0;
|
||||||
|
responeData.message = "请选择单位工程!";
|
||||||
|
return responeData;
|
||||||
|
}
|
||||||
|
|
||||||
|
List<Tw_OutHistoryDataIn> importRows;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
importRows = MiniExcel.Query<Tw_OutHistoryDataIn>(path, startCell: "A1").ToList();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
responeData.code = 0;
|
||||||
|
responeData.message = "模板错误:" + ex.Message;
|
||||||
|
return responeData;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (importRows == null || importRows.Count == 0)
|
||||||
|
{
|
||||||
|
responeData.code = 0;
|
||||||
|
responeData.message = "导入数据为空!";
|
||||||
|
return responeData;
|
||||||
|
}
|
||||||
|
|
||||||
|
var warehouseList = Base_WarehouseService.GetWarehouseList(projectId);
|
||||||
|
var allStock = TwMaterialstockService.GetTw_MaterialStockByModle(new Tw_MaterialStockOutput
|
||||||
|
{
|
||||||
|
ProjectId = projectId
|
||||||
|
});
|
||||||
|
var errors = new List<string>();
|
||||||
|
var detailRows = new List<Tw_OutHistoryImportRow>();
|
||||||
|
for (int i = 0; i < importRows.Count; i++)
|
||||||
|
{
|
||||||
|
var row = importRows[i];
|
||||||
|
string rowWarehouseCode = CleanImportText(row.WarehouseCode);
|
||||||
|
string materialCode = CleanImportText(row.MaterialCode);
|
||||||
|
string heatNo = CleanImportText(row.HeatNo);
|
||||||
|
string batchNo = CleanImportText(row.BatchNo);
|
||||||
|
string numText = CleanImportText(row.Num);
|
||||||
|
string outputDateText = CleanImportDateText(row.OutputDate);
|
||||||
|
string reqUnitName = CleanImportText(row.ReqUnitName);
|
||||||
|
int rowIndex = i + 2;
|
||||||
|
|
||||||
|
if (string.IsNullOrEmpty(rowWarehouseCode) && string.IsNullOrEmpty(materialCode) && string.IsNullOrEmpty(heatNo) && string.IsNullOrEmpty(batchNo)
|
||||||
|
&& string.IsNullOrEmpty(numText) && string.IsNullOrEmpty(outputDateText) && string.IsNullOrEmpty(reqUnitName))
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (string.IsNullOrEmpty(rowWarehouseCode))
|
||||||
|
{
|
||||||
|
errors.Add("第" + rowIndex + "行,仓库,此项为必填项!");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (!warehouseList.Any(x => x.WarehouseName == rowWarehouseCode))
|
||||||
|
{
|
||||||
|
errors.Add("第" + rowIndex + "行,仓库[" + rowWarehouseCode + "]不存在!");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (string.IsNullOrEmpty(materialCode))
|
||||||
|
{
|
||||||
|
errors.Add("第" + rowIndex + "行,材料编码,此项为必填项!");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (string.IsNullOrEmpty(heatNo))
|
||||||
|
{
|
||||||
|
errors.Add("第" + rowIndex + "行,炉号,此项为必填项!");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (string.IsNullOrEmpty(batchNo))
|
||||||
|
{
|
||||||
|
errors.Add("第" + rowIndex + "行,批号,此项为必填项!");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
decimal num;
|
||||||
|
if (!decimal.TryParse(numText, out num) || num <= 0)
|
||||||
|
{
|
||||||
|
errors.Add("第" + rowIndex + "行,数量,请输入大于0的数字!");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
DateTime outputDate;
|
||||||
|
if (!TryParseImportDate(outputDateText, out outputDate))
|
||||||
|
{
|
||||||
|
errors.Add("第" + rowIndex + "行,出库时间,格式错误!");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
var reqUnit = UnitService.getUnitByUnitName(reqUnitName);
|
||||||
|
if (reqUnit == null)
|
||||||
|
{
|
||||||
|
errors.Add("第" + rowIndex + "行,领用单位[" + reqUnitName + "]不存在!");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
var stock = allStock.FirstOrDefault(x => x.WarehouseCode == rowWarehouseCode && x.Code == materialCode && x.HeatNo == heatNo && x.BatchNo == batchNo);
|
||||||
|
if (stock == null)
|
||||||
|
{
|
||||||
|
errors.Add("第" + rowIndex + "行,仓库[" + rowWarehouseCode + "]库存中不存在此材料编码/炉号/批号-" + materialCode + "/" + heatNo + "/" + batchNo);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
detailRows.Add(new Tw_OutHistoryImportRow
|
||||||
|
{
|
||||||
|
WarehouseCode = stock.WarehouseCode,
|
||||||
|
MaterialCode = stock.PipeLineMatCode,
|
||||||
|
Code = stock.Code,
|
||||||
|
HeatNo = stock.HeatNo,
|
||||||
|
BatchNo = stock.BatchNo,
|
||||||
|
MaterialUnit = stock.MaterialUnit,
|
||||||
|
Num = num,
|
||||||
|
OutputDate = outputDate,
|
||||||
|
ReqUnitId = reqUnit.UnitId
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
if (errors.Count > 0)
|
||||||
|
{
|
||||||
|
responeData.code = 0;
|
||||||
|
responeData.message = string.Join("|", errors.Distinct());
|
||||||
|
return responeData;
|
||||||
|
}
|
||||||
|
if (detailRows.Count == 0)
|
||||||
|
{
|
||||||
|
responeData.code = 0;
|
||||||
|
responeData.message = "导入数据为空!";
|
||||||
|
return responeData;
|
||||||
|
}
|
||||||
|
|
||||||
|
var stockErrors = detailRows.GroupBy(x => new { x.WarehouseCode, x.MaterialCode })
|
||||||
|
.Select(x => new
|
||||||
|
{
|
||||||
|
x.Key.WarehouseCode,
|
||||||
|
x.Key.MaterialCode,
|
||||||
|
Num = x.Sum(y => y.Num),
|
||||||
|
Stock = allStock.FirstOrDefault(y => y.WarehouseCode == x.Key.WarehouseCode && y.PipeLineMatCode == x.Key.MaterialCode)
|
||||||
|
})
|
||||||
|
.Where(x => x.Stock == null || (x.Stock.StockNum ?? 0) < x.Num)
|
||||||
|
.Select(x => "仓库[" + x.WarehouseCode + "]" + (x.Stock == null ? x.MaterialCode : x.Stock.Code + "/" + x.Stock.HeatNo + "/" + x.Stock.BatchNo)
|
||||||
|
+ "库存不足,库存:" + (x.Stock?.StockNum ?? 0) + ",导入数量:" + x.Num)
|
||||||
|
.ToList();
|
||||||
|
if (stockErrors.Count > 0)
|
||||||
|
{
|
||||||
|
responeData.code = 0;
|
||||||
|
responeData.message = string.Join("|", stockErrors);
|
||||||
|
return responeData;
|
||||||
|
}
|
||||||
|
|
||||||
|
int planCount = 0;
|
||||||
|
foreach (var group in detailRows.GroupBy(x => new
|
||||||
|
{
|
||||||
|
x.WarehouseCode,
|
||||||
|
x.ReqUnitId,
|
||||||
|
OutputDate = x.OutputDate.Date,
|
||||||
|
Category = IsPipeSectionUnit(x.MaterialUnit) ? (int)TwConst.Category.管段 : (int)TwConst.Category.管件
|
||||||
|
}))
|
||||||
|
{
|
||||||
|
var planId = SQLHelper.GetNewID();
|
||||||
|
string cusBillCode = GetDataInCusBillCode(projectId, UnitService.GetUnitCodeByUnitId(group.Key.ReqUnitId), TwConst.TypeInt.其他出库.ToString());
|
||||||
|
var planMaster = new Tw_InOutPlanMaster
|
||||||
|
{
|
||||||
|
Id = planId,
|
||||||
|
ProjectId = projectId,
|
||||||
|
CusBillCode = cusBillCode,
|
||||||
|
WarehouseCode = group.Key.WarehouseCode,
|
||||||
|
WeldTaskId = unitWorkId,
|
||||||
|
Source = 2,
|
||||||
|
InOutType = (int)TwConst.InOutType.出库,
|
||||||
|
TypeInt = (int)TwConst.TypeInt.其他出库,
|
||||||
|
State = (int)TwConst.State.已审核,
|
||||||
|
Category = group.Key.Category,
|
||||||
|
CreateMan = createUserId,
|
||||||
|
CreateDate = group.Key.OutputDate,
|
||||||
|
ReqUnitId = group.Key.ReqUnitId,
|
||||||
|
AuditMan = createUserId,
|
||||||
|
AuditDate = group.Key.OutputDate,
|
||||||
|
AuditMan2 = createUserId,
|
||||||
|
AuditDate2 = group.Key.OutputDate,
|
||||||
|
WarehouseMan = createUserId,
|
||||||
|
WarehouseDate = group.Key.OutputDate,
|
||||||
|
Remark = oriFileName
|
||||||
|
};
|
||||||
|
Add(planMaster);
|
||||||
|
|
||||||
|
var outputDetails = new List<Tw_OutputDetail>();
|
||||||
|
int sortIndex = 1;
|
||||||
|
foreach (var detailGroup in group.GroupBy(x => x.MaterialCode))
|
||||||
|
{
|
||||||
|
decimal num = detailGroup.Sum(x => x.Num);
|
||||||
|
TwInOutplandetailService.Add(new Tw_InOutPlanDetail
|
||||||
|
{
|
||||||
|
Id = SQLHelper.GetNewID(),
|
||||||
|
InOutPlanMasterId = planId,
|
||||||
|
MaterialCode = detailGroup.Key,
|
||||||
|
PlanNum = num,
|
||||||
|
ActNum = num,
|
||||||
|
SortIndex = sortIndex
|
||||||
|
});
|
||||||
|
outputDetails.Add(new Tw_OutputDetail
|
||||||
|
{
|
||||||
|
MaterialCode = detailGroup.Key,
|
||||||
|
PlanNum = num,
|
||||||
|
ActNum = num
|
||||||
|
});
|
||||||
|
sortIndex++;
|
||||||
|
}
|
||||||
|
|
||||||
|
TwOutputmasterService.GenOutMasterByPlanId(planId, outputDetails);
|
||||||
|
planCount++;
|
||||||
|
}
|
||||||
|
|
||||||
|
responeData.code = 1;
|
||||||
|
responeData.message = "导入成功,生成出库申请单/出库单" + planCount + "张。";
|
||||||
|
return responeData;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static bool IsPipeSectionUnit(string materialUnit)
|
||||||
|
{
|
||||||
|
return CleanImportText(materialUnit) == "米";
|
||||||
|
}
|
||||||
|
|
||||||
|
private static string CleanImportText(string value)
|
||||||
|
{
|
||||||
|
return Convert.ToString(value).Replace("\n", "").Replace(" ", "").Replace("\t", "").Replace("\r", "").Trim();
|
||||||
|
}
|
||||||
|
|
||||||
|
private static string CleanImportDateText(string value)
|
||||||
|
{
|
||||||
|
return Convert.ToString(value).Replace("\n", "").Replace("\t", " ").Replace("\r", "").Trim();
|
||||||
|
}
|
||||||
|
|
||||||
|
private static bool TryParseImportDate(string value, out DateTime date)
|
||||||
|
{
|
||||||
|
date = default(DateTime);
|
||||||
|
if (string.IsNullOrEmpty(value))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
double oaDate;
|
||||||
|
if (double.TryParse(value, NumberStyles.Float, CultureInfo.InvariantCulture, out oaDate) && oaDate > 0)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
date = DateTime.FromOADate(oaDate);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return DateTime.TryParse(value, CultureInfo.GetCultureInfo("zh-CN"), DateTimeStyles.None, out date)
|
||||||
|
|| DateTime.TryParse(value, CultureInfo.InvariantCulture, DateTimeStyles.None, out date);
|
||||||
|
}
|
||||||
|
|
||||||
public static Model.Tw_InOutPlanMaster GetById(string Id)
|
public static Model.Tw_InOutPlanMaster GetById(string Id)
|
||||||
{
|
{
|
||||||
return Funs.DB.Tw_InOutPlanMaster.FirstOrDefault(x => x.Id == Id);
|
return Funs.DB.Tw_InOutPlanMaster.FirstOrDefault(x => x.Id == Id);
|
||||||
|
|||||||
@@ -86,6 +86,8 @@
|
|||||||
</f:Button>
|
</f:Button>
|
||||||
<f:Button ID="btnNew" Text="新增" Icon="Add" runat="server" OnClick="btnNew_Click" Hidden="true">
|
<f:Button ID="btnNew" Text="新增" Icon="Add" runat="server" OnClick="btnNew_Click" Hidden="true">
|
||||||
</f:Button>
|
</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 ID="btnPassMaster" Text="专工审核" Icon="ArrowRefresh" runat="server" OnClick="btnPassMaster_OnClick" Hidden="true">
|
||||||
</f:Button>
|
</f:Button>
|
||||||
<f:Button ID="btnPassMaster2" Text="材控审核" Icon="ArrowRefresh" runat="server" OnClick="btnPassMaster2_OnClick" Hidden="true">
|
<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)
|
protected void btnMenuInOutPlanMasterDelete_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
if (CommonService.GetAllButtonPowerList(this.CurrUser.LoginProjectId, this.CurrUser.PersonId, Const.Tw_OutPlanMasterMenuId, Const.BtnDelete))
|
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))
|
if (buttonList.Contains(BLL.Const.BtnAdd))
|
||||||
{
|
{
|
||||||
this.btnNew.Hidden = false;
|
this.btnNew.Hidden = false;
|
||||||
|
this.btnHistoryImport.Hidden = false;
|
||||||
}
|
}
|
||||||
if (buttonList.Contains(BLL.Const.BtnModify))
|
if (buttonList.Contains(BLL.Const.BtnModify))
|
||||||
{
|
{
|
||||||
@@ -703,4 +724,4 @@ namespace FineUIPro.Web.CLGL
|
|||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -185,6 +185,15 @@ namespace FineUIPro.Web.CLGL
|
|||||||
/// </remarks>
|
/// </remarks>
|
||||||
protected global::FineUIPro.Button btnNew;
|
protected global::FineUIPro.Button btnNew;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// btnHistoryImport 控件。
|
||||||
|
/// </summary>
|
||||||
|
/// <remarks>
|
||||||
|
/// 自动生成的字段。
|
||||||
|
/// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。
|
||||||
|
/// </remarks>
|
||||||
|
protected global::FineUIPro.Button btnHistoryImport;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// btnPassMaster 控件。
|
/// btnPassMaster 控件。
|
||||||
/// </summary>
|
/// </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;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -352,6 +352,7 @@
|
|||||||
<Content Include="CLGL\ArrivalStatistics.aspx" />
|
<Content Include="CLGL\ArrivalStatistics.aspx" />
|
||||||
<Content Include="CLGL\OutPlanMaster.aspx" />
|
<Content Include="CLGL\OutPlanMaster.aspx" />
|
||||||
<Content Include="CLGL\OutPlanMasterDetailImport.aspx" />
|
<Content Include="CLGL\OutPlanMasterDetailImport.aspx" />
|
||||||
|
<Content Include="CLGL\OutPlanMasterHistoryImport.aspx" />
|
||||||
<Content Include="CLGL\OutPlanMasterEdit.aspx" />
|
<Content Include="CLGL\OutPlanMasterEdit.aspx" />
|
||||||
<Content Include="CLGL\OutPlanMasterOut.aspx" />
|
<Content Include="CLGL\OutPlanMasterOut.aspx" />
|
||||||
<Content Include="CLGL\InPlanMaster.aspx" />
|
<Content Include="CLGL\InPlanMaster.aspx" />
|
||||||
@@ -8217,6 +8218,13 @@
|
|||||||
<Compile Include="CLGL\OutPlanMasterDetailImport.aspx.designer.cs">
|
<Compile Include="CLGL\OutPlanMasterDetailImport.aspx.designer.cs">
|
||||||
<DependentUpon>OutPlanMasterDetailImport.aspx</DependentUpon>
|
<DependentUpon>OutPlanMasterDetailImport.aspx</DependentUpon>
|
||||||
</Compile>
|
</Compile>
|
||||||
|
<Compile Include="CLGL\OutPlanMasterHistoryImport.aspx.cs">
|
||||||
|
<DependentUpon>OutPlanMasterHistoryImport.aspx</DependentUpon>
|
||||||
|
<SubType>ASPXCodeBehind</SubType>
|
||||||
|
</Compile>
|
||||||
|
<Compile Include="CLGL\OutPlanMasterHistoryImport.aspx.designer.cs">
|
||||||
|
<DependentUpon>OutPlanMasterHistoryImport.aspx</DependentUpon>
|
||||||
|
</Compile>
|
||||||
<Compile Include="CLGL\OutPlanMasterEdit.aspx.cs">
|
<Compile Include="CLGL\OutPlanMasterEdit.aspx.cs">
|
||||||
<DependentUpon>OutPlanMasterEdit.aspx</DependentUpon>
|
<DependentUpon>OutPlanMasterEdit.aspx</DependentUpon>
|
||||||
<SubType>ASPXCodeBehind</SubType>
|
<SubType>ASPXCodeBehind</SubType>
|
||||||
@@ -17174,7 +17182,7 @@
|
|||||||
</COMReference>
|
</COMReference>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
|
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
|
||||||
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v15.0\WebApplications\Microsoft.WebApplication.targets" />
|
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v18.0\WebApplications\Microsoft.WebApplication.targets" />
|
||||||
<ProjectExtensions>
|
<ProjectExtensions>
|
||||||
<VisualStudio>
|
<VisualStudio>
|
||||||
<FlavorProperties GUID="{349c5851-65df-11da-9384-00065b846f21}">
|
<FlavorProperties GUID="{349c5851-65df-11da-9384-00065b846f21}">
|
||||||
|
|||||||
@@ -0,0 +1,42 @@
|
|||||||
|
using MiniExcelLibs.Attributes;
|
||||||
|
|
||||||
|
namespace Model
|
||||||
|
{
|
||||||
|
public class Tw_OutHistoryDataIn
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 仓库
|
||||||
|
/// </summary>
|
||||||
|
[ExcelColumnIndex("A")] public string WarehouseCode { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 材料编码
|
||||||
|
/// </summary>
|
||||||
|
[ExcelColumnIndex("B")] public string MaterialCode { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 炉号
|
||||||
|
/// </summary>
|
||||||
|
[ExcelColumnIndex("C")] public string HeatNo { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 批号
|
||||||
|
/// </summary>
|
||||||
|
[ExcelColumnIndex("D")] public string BatchNo { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 数量
|
||||||
|
/// </summary>
|
||||||
|
[ExcelColumnIndex("E")] public string Num { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 出库时间
|
||||||
|
/// </summary>
|
||||||
|
[ExcelColumnIndex("F")] public string OutputDate { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 领用单位
|
||||||
|
/// </summary>
|
||||||
|
[ExcelColumnIndex("G")] public string ReqUnitName { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,25 @@
|
|||||||
|
using System;
|
||||||
|
|
||||||
|
namespace Model
|
||||||
|
{
|
||||||
|
public class Tw_OutHistoryImportRow
|
||||||
|
{
|
||||||
|
public string WarehouseCode { get; set; }
|
||||||
|
|
||||||
|
public string MaterialCode { get; set; }
|
||||||
|
|
||||||
|
public string Code { get; set; }
|
||||||
|
|
||||||
|
public string HeatNo { get; set; }
|
||||||
|
|
||||||
|
public string BatchNo { get; set; }
|
||||||
|
|
||||||
|
public string MaterialUnit { get; set; }
|
||||||
|
|
||||||
|
public decimal Num { get; set; }
|
||||||
|
|
||||||
|
public DateTime OutputDate { get; set; }
|
||||||
|
|
||||||
|
public string ReqUnitId { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -229,6 +229,8 @@
|
|||||||
<Compile Include="CLGL\Tw_InputDetailBarCodeOutput.cs" />
|
<Compile Include="CLGL\Tw_InputDetailBarCodeOutput.cs" />
|
||||||
<Compile Include="CLGL\Tw_InOutMasterOutput.cs" />
|
<Compile Include="CLGL\Tw_InOutMasterOutput.cs" />
|
||||||
<Compile Include="CLGL\Tw_MaterialStockOutput.cs" />
|
<Compile Include="CLGL\Tw_MaterialStockOutput.cs" />
|
||||||
|
<Compile Include="CLGL\Tw_OutHistoryDataIn.cs" />
|
||||||
|
<Compile Include="CLGL\Tw_OutHistoryImportRow.cs" />
|
||||||
<Compile Include="CLGL\Tw_PipeLineMat.cs" />
|
<Compile Include="CLGL\Tw_PipeLineMat.cs" />
|
||||||
<Compile Include="ConstructionLogCQMS.cs" />
|
<Compile Include="ConstructionLogCQMS.cs" />
|
||||||
<Compile Include="ConstructionLogHSE.cs" />
|
<Compile Include="ConstructionLogHSE.cs" />
|
||||||
|
|||||||
Reference in New Issue
Block a user