2023-06-19
This commit is contained in:
Binary file not shown.
@@ -1,4 +1,5 @@
|
|||||||
using BLL;
|
using BLL;
|
||||||
|
using MiniExcelLibs;
|
||||||
using Model;
|
using Model;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
@@ -325,6 +326,123 @@ namespace FineUIPro.Web.HJGL.WeldingManage
|
|||||||
responeData.message = errorInfos;
|
responeData.message = errorInfos;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return responeData;
|
||||||
|
}
|
||||||
|
private Model.ResponeData AddDatasetToSQL(List<dynamic> pds, int count)
|
||||||
|
{
|
||||||
|
Model.ResponeData responeData = new Model.ResponeData();
|
||||||
|
List<string> result = new List<string>();
|
||||||
|
|
||||||
|
if (count < 4)
|
||||||
|
{
|
||||||
|
responeData.code = 0;
|
||||||
|
responeData.message = "导入Excel格式错误!Excel只有" + count.ToString().Trim() + "列";
|
||||||
|
return responeData;
|
||||||
|
}
|
||||||
|
if (pds.Count > 0 && pds != null)
|
||||||
|
{
|
||||||
|
|
||||||
|
for (int i = 0; i < pds.Count; i++)
|
||||||
|
{
|
||||||
|
HJGL_PipeLineMat item = new HJGL_PipeLineMat();
|
||||||
|
|
||||||
|
#region 数据验证和赋值
|
||||||
|
|
||||||
|
|
||||||
|
string unitworkId = string.Empty;
|
||||||
|
unitworkId = Request.Params["UnitWorkId"];
|
||||||
|
string PipeArea = string.Empty;//管线划分 1工厂预制 2现场施工
|
||||||
|
|
||||||
|
if (pds[i].A != null && !string.IsNullOrEmpty(pds[i].A.ToString()))
|
||||||
|
{
|
||||||
|
string pipelineCode = pds[i].A.ToString();
|
||||||
|
var pipeline = from x in Funs.DB.HJGL_Pipeline where x.ProjectId == this.CurrUser.LoginProjectId && x.UnitWorkId == unitworkId && x.PipelineCode == pipelineCode select x;
|
||||||
|
if (pipeline.Count() > 0)
|
||||||
|
{
|
||||||
|
item.PipelineId = pipeline.First().PipelineId;
|
||||||
|
PipeArea = pipeline.First().PipeArea;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
result.Add("不存在此管线号-" + pds[i].A.ToString());
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
result.Add((i + 2) + "Line, [管线号] 不能为空</br>");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if (pds[i].C != null && !string.IsNullOrEmpty(pds[i].C.ToString()))
|
||||||
|
{
|
||||||
|
string materialCode = pds[i].C.ToString();
|
||||||
|
var lib = from x in Funs.DB.HJGL_MaterialCodeLib where x.MaterialCode == materialCode select x;
|
||||||
|
if (lib.Count() > 0)
|
||||||
|
{
|
||||||
|
item.MaterialCode = pds[i].C.ToString();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
result.Add("不存在此材料编码-" + pds[i].C.ToString());
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
result.Add((i + 2) + "Line, [材料编码] 不能为空</br>");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pds[i].D != null && !string.IsNullOrEmpty(pds[i].D.ToString()))
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var number = Funs.GetNewDecimal(pds[i].D.ToString());
|
||||||
|
item.Number = number;
|
||||||
|
}
|
||||||
|
catch (Exception)
|
||||||
|
{
|
||||||
|
result.Add("第" + (i + 2).ToString() + "行," + "数量格式输入有误</br>");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
result.Add((i + 2) + "Line, [数量] 不能为空</br>");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (PipeArea == "1")
|
||||||
|
{
|
||||||
|
if (pds[i].B != null && !string.IsNullOrEmpty(pds[i].B.ToString()))
|
||||||
|
{
|
||||||
|
item.PrefabricatedComponents = pds[i].B.ToString();
|
||||||
|
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
result.Add((i + 2) + "Line, [预制组件] 不能为空</br>");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
var model = matList.Where(x => x.PipelineId == item.PipelineId && x.MaterialCode == item.MaterialCode && x.PrefabricatedComponents == item.PrefabricatedComponents);
|
||||||
|
if (model.Count() == 0)
|
||||||
|
{
|
||||||
|
matList.Add(item);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
responeData.code = 0;
|
||||||
|
responeData.message = "导入数据为空!";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
return responeData;
|
return responeData;
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
@@ -344,7 +462,7 @@ namespace FineUIPro.Web.HJGL.WeldingManage
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
string IsXls = Path.GetExtension(this.fuAttachUrl.FileName).ToString().Trim().ToLower();
|
string IsXls = Path.GetExtension(this.fuAttachUrl.FileName).ToString().Trim().ToLower();
|
||||||
if (IsXls != ".xls" && IsXls != ".xlsx")
|
if (IsXls != ".xlsx")
|
||||||
{
|
{
|
||||||
ShowNotify("只能选择Excel文件!", MessageBoxIcon.Warning);
|
ShowNotify("只能选择Excel文件!", MessageBoxIcon.Warning);
|
||||||
return;
|
return;
|
||||||
@@ -365,26 +483,14 @@ namespace FineUIPro.Web.HJGL.WeldingManage
|
|||||||
//文件上传服务器后的名称
|
//文件上传服务器后的名称
|
||||||
string fileName = rootPath + initPath + this.hdFileName.Text;
|
string fileName = rootPath + initPath + this.hdFileName.Text;
|
||||||
//读取Excel
|
//读取Excel
|
||||||
DataSet ds = NPOIHelper.ExcelToDataSet(fileName, out errorInfos, true);
|
var ds = MiniExcel.Query(fileName).ToList();
|
||||||
|
var columns = MiniExcel.GetColumns(fileName);
|
||||||
//验证Excel读取是否有误
|
var cnt = columns.Count;
|
||||||
if (!string.IsNullOrEmpty(errorInfos))
|
var reposedata = AddDatasetToSQL(ds, cnt);
|
||||||
{
|
|
||||||
Alert alert = new Alert
|
|
||||||
{
|
|
||||||
Message = errorInfos,
|
|
||||||
Target = Target.Self
|
|
||||||
};
|
|
||||||
alert.Show();
|
|
||||||
//ShowNotify(errorInfos, MessageBoxIcon.Warning);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
var reposedata= AddDatasetToSQL(ds.Tables[0], 4);
|
|
||||||
if (reposedata.code == 1)
|
if (reposedata.code == 1)
|
||||||
{
|
{
|
||||||
State = (int)ButtonState.Import;
|
State = (int)ButtonState.Import;
|
||||||
ShowNotify("审核完成请点击导入");
|
ShowNotify("审核完成请点击导入");
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -394,7 +500,7 @@ namespace FineUIPro.Web.HJGL.WeldingManage
|
|||||||
Target = Target.Self
|
Target = Target.Self
|
||||||
};
|
};
|
||||||
alert.Show();
|
alert.Show();
|
||||||
//ShowNotify(reposedata.message);
|
//ShowNotify(reposedata.message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#region 导入
|
#region 导入
|
||||||
|
|||||||
Reference in New Issue
Block a user