fix(hjgl): 完善材料编码与管线材料导入
调整材料库批量导入和管线材料导入处理,支持维护已有材料信息。
This commit is contained in:
@@ -17,10 +17,6 @@ namespace FineUIPro.Web.HJGL.BaseInfo
|
||||
/// </summary>
|
||||
private string initPath = Const.ExcelUrl;//"File\\Excel\\DataIn\\";
|
||||
|
||||
/// <summary>
|
||||
/// 错误集合
|
||||
/// </summary>
|
||||
public static string errorInfos = string.Empty;
|
||||
#endregion
|
||||
|
||||
#region 加载
|
||||
@@ -84,10 +80,8 @@ namespace FineUIPro.Web.HJGL.BaseInfo
|
||||
protected void btnImport_Click(object sender, EventArgs e)
|
||||
{
|
||||
string message = string.Empty;
|
||||
errorInfos = string.Empty;
|
||||
string errorInfos = string.Empty;
|
||||
List<HJGL_MaterialCodeLib> codeLib = new List<HJGL_MaterialCodeLib>();
|
||||
List<HJGL_MaterialCodeLib> codeLib_update = new List<HJGL_MaterialCodeLib>();
|
||||
var materialcodelist = MaterialCodeLibService.GetMaterialCodeLibList();
|
||||
if (this.fuAttachUrl.HasFile == false)
|
||||
{
|
||||
ShowNotify("请选择Excel文件!", MessageBoxIcon.Warning);
|
||||
@@ -99,14 +93,6 @@ namespace FineUIPro.Web.HJGL.BaseInfo
|
||||
ShowNotify("只能选择Excel文件!", MessageBoxIcon.Warning);
|
||||
return;
|
||||
}
|
||||
if (codeLib != null)
|
||||
{
|
||||
codeLib.Clear();
|
||||
}
|
||||
if (!string.IsNullOrEmpty(errorInfos))
|
||||
{
|
||||
errorInfos = string.Empty;
|
||||
}
|
||||
string rootPath = Server.MapPath("~/");
|
||||
string initFullPath = rootPath + initPath;
|
||||
if (!Directory.Exists(initFullPath))
|
||||
@@ -140,9 +126,10 @@ namespace FineUIPro.Web.HJGL.BaseInfo
|
||||
{
|
||||
HJGL_MaterialCodeLib item = new HJGL_MaterialCodeLib();
|
||||
#region 数据验证和赋值
|
||||
if (rows[i].MaterialCode != null && !string.IsNullOrEmpty(rows[i].MaterialCode))
|
||||
if (!string.IsNullOrWhiteSpace(rows[i].MaterialCode))
|
||||
{
|
||||
item.MaterialCode = rows[i].MaterialCode;
|
||||
item.MaterialCode = rows[i].MaterialCode.Trim();
|
||||
item.Code = item.MaterialCode;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -159,20 +146,7 @@ namespace FineUIPro.Web.HJGL.BaseInfo
|
||||
//item.PipeGrade = dv[i]["管道等级"].ToString();
|
||||
//item.ProjectId = CurrUser.LoginProjectId;
|
||||
//= SQLHelper.GetNewID(typeof(Model.Editor_CostReport));
|
||||
if (!codeLib.Select(x => x.MaterialCode).Contains(item.MaterialCode))
|
||||
{
|
||||
|
||||
if (materialcodelist.Select(x => x.MaterialCode).Contains(item.MaterialCode))
|
||||
{
|
||||
codeLib_update.Add(item);
|
||||
}
|
||||
else
|
||||
{
|
||||
codeLib.Add(item);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
codeLib.Add(item);
|
||||
|
||||
#endregion
|
||||
}
|
||||
@@ -231,60 +205,6 @@ namespace FineUIPro.Web.HJGL.BaseInfo
|
||||
Alert.ShowInTop(BLL.UiText.Message(errorInfos), MessageBoxIcon.Warning);
|
||||
return;
|
||||
}
|
||||
codeLib = (from x in codeLib
|
||||
select new HJGL_MaterialCodeLib
|
||||
{
|
||||
MaterialCode = x.MaterialCode,
|
||||
Code = x.MaterialCode,
|
||||
MaterialDef = x.MaterialDef,
|
||||
MaterialSpec = x.MaterialSpec,
|
||||
MaterialUnit = x.MaterialUnit,
|
||||
MaterialName = x.MaterialName,
|
||||
DesignInstitute = x.DesignInstitute,
|
||||
|
||||
}).DistinctBy(temp => new
|
||||
{
|
||||
temp.MaterialCode,
|
||||
temp.Code,
|
||||
temp.MaterialDef,
|
||||
temp.MaterialSpec,
|
||||
temp.MaterialUnit,
|
||||
temp.MaterialName,
|
||||
temp.DesignInstitute
|
||||
}).ToList();
|
||||
codeLib_update = (from x in codeLib_update
|
||||
select new HJGL_MaterialCodeLib
|
||||
{
|
||||
MaterialCode = x.MaterialCode,
|
||||
Code = x.MaterialCode,
|
||||
MaterialDef = x.MaterialDef,
|
||||
MaterialSpec = x.MaterialSpec,
|
||||
MaterialUnit = x.MaterialUnit,
|
||||
MaterialName = x.MaterialName,
|
||||
DesignInstitute = x.DesignInstitute,
|
||||
|
||||
}).DistinctBy(temp => new
|
||||
{
|
||||
temp.MaterialCode,
|
||||
temp.Code,
|
||||
temp.MaterialDef,
|
||||
temp.MaterialSpec,
|
||||
temp.MaterialUnit,
|
||||
temp.MaterialName,
|
||||
temp.DesignInstitute
|
||||
}).ToList();
|
||||
foreach (var item in codeLib_update)
|
||||
{
|
||||
var mewCostReport = BLL.MaterialCodeLibService.GetMaterialCodeLib(item.MaterialCode);
|
||||
if (mewCostReport == null)
|
||||
{
|
||||
BLL.MaterialCodeLibService.AddMaterialCodeLib(item);
|
||||
}
|
||||
else
|
||||
{
|
||||
BLL.MaterialCodeLibService.UpdateMaterialCodeLib(item);
|
||||
}
|
||||
}
|
||||
MaterialCodeLibService.AddBulkMaterialCodeLib(codeLib);
|
||||
ShowNotify("数据导入成功!", MessageBoxIcon.Success);
|
||||
PageContext.RegisterStartupScript(ActiveWindow.GetHidePostBackReference());
|
||||
|
||||
Reference in New Issue
Block a user