feat: 完善材料维护、管线导入与焊接检测报表
为支持材料数量修正和局部管线更新,补充维护与导入入口并隔离窗口审核状态;同步修正焊接日报、外观检测及委托单输出,并简化材料匹配逻辑。
This commit is contained in:
@@ -18,23 +18,30 @@ namespace FineUIPro.Web.HJGL.WeldingManage
|
||||
private string initPath = Const.ExcelUrl;
|
||||
|
||||
/// <summary>
|
||||
/// 安装组件集合
|
||||
/// 每个导入窗口独立保存审核数据,避免同一用户多窗口或不同用户串用模板。
|
||||
/// </summary>
|
||||
public static List<Model.View_HJGL_WeldJoint> PipelineList = new List<Model.View_HJGL_WeldJoint>();
|
||||
private sealed class ImportContext
|
||||
{
|
||||
public string ProjectId;
|
||||
public string PersonId;
|
||||
public string UnitWorkId;
|
||||
public string FileName;
|
||||
public string OriginalFileName;
|
||||
public List<Model.View_HJGL_WeldJoint> Rows = new List<Model.View_HJGL_WeldJoint>();
|
||||
public int State;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 错误集合
|
||||
/// </summary>
|
||||
public static string errorInfos = string.Empty;
|
||||
private ImportContext importContext;
|
||||
private string ImportSessionKey { get { return "PipelineListPDMSIn:" + (string)ViewState["ImportToken"]; } }
|
||||
private List<Model.View_HJGL_WeldJoint> PipelineList { get { return importContext.Rows; } }
|
||||
private int State { get { return importContext.State; } set { importContext.State = value; } }
|
||||
|
||||
/// <summary>
|
||||
/// 导入数据分类(管线)
|
||||
/// </summary>
|
||||
public static string DataClassification = "Pipeline";
|
||||
private const string DataClassification = "Pipeline";
|
||||
public enum ButtonState { Check = 0, Import = 1, Save = 2 }
|
||||
|
||||
public static int State;
|
||||
|
||||
#endregion
|
||||
|
||||
#region 加载
|
||||
@@ -45,19 +52,40 @@ namespace FineUIPro.Web.HJGL.WeldingManage
|
||||
/// <param name="e"></param>
|
||||
protected void Page_Load(object sender, EventArgs e)
|
||||
{
|
||||
if (this.CurrUser == null)
|
||||
{
|
||||
throw new InvalidOperationException("登录已失效,请重新登录后打开导入窗口。");
|
||||
}
|
||||
var unitWorkId = Request.QueryString["UnitWorkId"];
|
||||
var unitWork = BLL.UnitWorkService.GetUnitWorkByUnitWorkId(unitWorkId);
|
||||
if (unitWork == null || unitWork.ProjectId != this.CurrUser.LoginProjectId)
|
||||
{
|
||||
throw new InvalidOperationException("单位工程不属于当前项目,不能导入或恢复数据。");
|
||||
}
|
||||
if (!IsPostBack)
|
||||
{
|
||||
this.hdFileName.Text = string.Empty;
|
||||
State = (int)ButtonState.Check;
|
||||
|
||||
if (PipelineList != null)
|
||||
ViewState["ImportToken"] = Guid.NewGuid().ToString("N");
|
||||
importContext = new ImportContext
|
||||
{
|
||||
PipelineList.Clear();
|
||||
}
|
||||
errorInfos = string.Empty;
|
||||
lbVersion.Text = BLL.HJGL_DesignBasisDataImportService.GetNowVersionByUnitWorkId(Request.Params["UnitWorkId"], DataClassification).ToString();
|
||||
ProjectId = this.CurrUser.LoginProjectId,
|
||||
PersonId = this.CurrUser.PersonId,
|
||||
UnitWorkId = unitWorkId
|
||||
};
|
||||
Session[ImportSessionKey] = importContext;
|
||||
this.hdFileName.Text = string.Empty;
|
||||
lbVersion.Text = BLL.HJGL_DesignBasisDataImportService.GetNowVersionByUnitWorkId(unitWorkId, DataClassification).ToString();
|
||||
BindGrid2();
|
||||
}
|
||||
else
|
||||
{
|
||||
importContext = Session[ImportSessionKey] as ImportContext;
|
||||
if (importContext == null || importContext.ProjectId != this.CurrUser.LoginProjectId
|
||||
|| importContext.PersonId != this.CurrUser.PersonId || importContext.UnitWorkId != unitWorkId
|
||||
|| importContext.FileName != (string)ViewState["ImportFileName"])
|
||||
{
|
||||
throw new InvalidOperationException("导入窗口已失效或数据已变更,请重新打开窗口审核文件。");
|
||||
}
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
void BindGrid2()
|
||||
@@ -66,7 +94,8 @@ namespace FineUIPro.Web.HJGL.WeldingManage
|
||||
,Import.ProjectId
|
||||
,Import.UnitWorkId
|
||||
,(Case Import.ImportType when '0' then '补充导入'
|
||||
when '1' then '更新导入' end) as ImportType
|
||||
when '1' then '更新导入'
|
||||
when '2' then '更新导入(管线)' end) as ImportType
|
||||
,Import.FileName
|
||||
,Import.FilePath
|
||||
,Import.DataClassification
|
||||
@@ -84,7 +113,7 @@ namespace FineUIPro.Web.HJGL.WeldingManage
|
||||
order by Import.CreateDate";
|
||||
List<SqlParameter> listStr = new List<SqlParameter>();
|
||||
listStr.Add(new SqlParameter("@ProjectId", this.CurrUser.LoginProjectId));
|
||||
listStr.Add(new SqlParameter("@UnitWorkId", Request.Params["UnitWorkId"]));
|
||||
listStr.Add(new SqlParameter("@UnitWorkId", importContext.UnitWorkId));
|
||||
listStr.Add(new SqlParameter("@DataClassification", DataClassification));
|
||||
SqlParameter[] parameter = listStr.ToArray();
|
||||
DataTable tb = SQLHelper.GetDataTableRunText(strSql, parameter);
|
||||
@@ -96,7 +125,7 @@ namespace FineUIPro.Web.HJGL.WeldingManage
|
||||
var table = this.GetPagedDataTable(Grid2, tb);
|
||||
Grid2.DataSource = table;
|
||||
Grid2.DataBind();
|
||||
drpVersion.DataSource = BLL.HJGL_DesignBasisDataImportService.GetListVersionByUnitWorkId(Request.Params["UnitWorkId"], DataClassification);
|
||||
drpVersion.DataSource = BLL.HJGL_DesignBasisDataImportService.GetListVersionByUnitWorkId(importContext.UnitWorkId, DataClassification);
|
||||
drpVersion.DataBind();
|
||||
|
||||
}
|
||||
@@ -110,6 +139,12 @@ namespace FineUIPro.Web.HJGL.WeldingManage
|
||||
{
|
||||
try
|
||||
{
|
||||
State = (int)ButtonState.Check;
|
||||
PipelineList.Clear();
|
||||
importContext.FileName = null;
|
||||
importContext.OriginalFileName = null;
|
||||
ViewState["ImportFileName"] = null;
|
||||
hdFileName.Text = string.Empty;
|
||||
if (this.fuAttachUrl.HasFile == false)
|
||||
{
|
||||
ShowNotify("请您选择Excel文件!", MessageBoxIcon.Warning);
|
||||
@@ -121,14 +156,6 @@ namespace FineUIPro.Web.HJGL.WeldingManage
|
||||
ShowNotify("只可以选择Excel文件!", MessageBoxIcon.Warning);
|
||||
return;
|
||||
}
|
||||
if (PipelineList != null)
|
||||
{
|
||||
PipelineList.Clear();
|
||||
}
|
||||
if (!string.IsNullOrEmpty(errorInfos))
|
||||
{
|
||||
errorInfos = string.Empty;
|
||||
}
|
||||
string rootPath = Server.MapPath("~/");
|
||||
string initFullPath = rootPath + initPath;
|
||||
if (!Directory.Exists(initFullPath))
|
||||
@@ -136,10 +163,17 @@ namespace FineUIPro.Web.HJGL.WeldingManage
|
||||
Directory.CreateDirectory(initFullPath);
|
||||
}
|
||||
|
||||
this.hdFileName.Text = BLL.Funs.GetNewFileName() + IsXls;
|
||||
string filePath = initFullPath + this.hdFileName.Text;
|
||||
string uploadedFileName = Guid.NewGuid().ToString("N") + IsXls;
|
||||
string filePath = initFullPath + uploadedFileName;
|
||||
this.fuAttachUrl.PostedFile.SaveAs(filePath);
|
||||
ImportXlsToData(rootPath + initPath + this.hdFileName.Text);
|
||||
var rows = ReadImportFile(filePath);
|
||||
importContext.Rows = rows;
|
||||
importContext.FileName = uploadedFileName;
|
||||
importContext.OriginalFileName = this.fuAttachUrl.FileName;
|
||||
ViewState["ImportFileName"] = uploadedFileName;
|
||||
hdFileName.Text = uploadedFileName;
|
||||
State = (int)ButtonState.Import;
|
||||
ShowNotify("审核完成请点击导入");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@@ -156,36 +190,18 @@ namespace FineUIPro.Web.HJGL.WeldingManage
|
||||
/// 从Excel提取数据--》Dataset
|
||||
/// </summary>
|
||||
/// <param name="filename">Excel文件路径名</param>
|
||||
private void ImportXlsToData(string fileName)
|
||||
private List<Model.View_HJGL_WeldJoint> ReadImportFile(string fileName)
|
||||
{
|
||||
try
|
||||
var rows = new List<Model.View_HJGL_WeldJoint>();
|
||||
var ds = MiniExcel.Query(fileName).ToList();
|
||||
var columns = MiniExcel.GetColumns(fileName);
|
||||
var result = AddDatasetToSQL(ds, columns.Count, rows);
|
||||
if (result.code != 1)
|
||||
{
|
||||
var ds = MiniExcel.Query(fileName).ToList();
|
||||
var columns = MiniExcel.GetColumns(fileName);
|
||||
var cnt = columns.Count;
|
||||
var reposedata = AddDatasetToSQL(ds, cnt);
|
||||
if (reposedata.code == 1)
|
||||
{
|
||||
State = (int)ButtonState.Import;
|
||||
ShowNotify("审核完成请点击导入");
|
||||
}
|
||||
else
|
||||
{
|
||||
Alert alert = new Alert
|
||||
{
|
||||
Message = reposedata.message,
|
||||
Target = Target.Self
|
||||
};
|
||||
alert.Show();
|
||||
//ShowNotify(reposedata.message);
|
||||
}
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
|
||||
ErrLogInfo.WriteLog("焊接基础数据上传失败!", exc);
|
||||
|
||||
throw new InvalidOperationException(result.message);
|
||||
}
|
||||
ValidatePipelineScope(rows, importContext.UnitWorkId);
|
||||
return rows;
|
||||
}
|
||||
#endregion
|
||||
|
||||
@@ -198,7 +214,7 @@ namespace FineUIPro.Web.HJGL.WeldingManage
|
||||
/// <param name="pds">数据集</param>
|
||||
/// <param name="Cols">数据集行数</param>
|
||||
/// <returns></returns>
|
||||
private Model.ResponeData AddDatasetToSQL(List<dynamic> pds, int count)
|
||||
private Model.ResponeData AddDatasetToSQL(List<dynamic> pds, int count, List<Model.View_HJGL_WeldJoint> rows)
|
||||
{
|
||||
Model.ResponeData responeData = new Model.ResponeData();
|
||||
// string result = string.Empty;
|
||||
@@ -227,7 +243,7 @@ namespace FineUIPro.Web.HJGL.WeldingManage
|
||||
var getPaintCodeDict = from x in db.Tw_PaintCodeDict where x.IsUsed select x;
|
||||
//var getComponents = from x in Funs.DB.Base_Components where x.ProjeceId == this.CurrUser.LoginProjectId select x;
|
||||
|
||||
Model.WBS_UnitWork unitWork = BLL.UnitWorkService.GetUnitWorkByUnitWorkId(Request.Params["UnitWorkId"]);
|
||||
Model.WBS_UnitWork unitWork = BLL.UnitWorkService.GetUnitWorkByUnitWorkId(importContext.UnitWorkId);
|
||||
for (int i = 1; i < pds.Count; i++)
|
||||
{
|
||||
Model.View_HJGL_WeldJoint pipeline = new Model.View_HJGL_WeldJoint();
|
||||
@@ -235,7 +251,7 @@ namespace FineUIPro.Web.HJGL.WeldingManage
|
||||
|
||||
if (unitWork != null)
|
||||
{
|
||||
pipeline.UnitWorkId = Request.Params["UnitWorkId"];
|
||||
pipeline.UnitWorkId = importContext.UnitWorkId;
|
||||
pipeline.UnitId = unitWork.UnitId;
|
||||
}
|
||||
|
||||
@@ -818,28 +834,21 @@ namespace FineUIPro.Web.HJGL.WeldingManage
|
||||
if (!string.IsNullOrEmpty(pipeline.PipelineCode) && !string.IsNullOrEmpty(pipeline.WeldJointCode))
|
||||
{
|
||||
pipeline.ProjectId = this.CurrUser.LoginProjectId;
|
||||
PipelineList.Add(pipeline);
|
||||
rows.Add(pipeline);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
if (result.Count > 0)
|
||||
{
|
||||
PipelineList.Clear();
|
||||
rows.Clear();
|
||||
// result = result.Substring(0, result.LastIndexOf("|"));
|
||||
errorInfos = string.Join("|", result.Distinct());
|
||||
//Alert alert = new Alert();
|
||||
//alert.Message = result;
|
||||
//alert.Target = Target.Self;
|
||||
//alert.Show();
|
||||
responeData.code = 0;
|
||||
responeData.message = errorInfos;
|
||||
}
|
||||
else
|
||||
{
|
||||
errorInfos = string.Empty;
|
||||
|
||||
|
||||
responeData.message = string.Join("|", result.Distinct());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -870,28 +879,20 @@ namespace FineUIPro.Web.HJGL.WeldingManage
|
||||
return;
|
||||
|
||||
}
|
||||
if (string.IsNullOrEmpty(errorInfos))
|
||||
if (!string.IsNullOrEmpty(importContext.FileName))
|
||||
{
|
||||
if (!string.IsNullOrEmpty(this.hdFileName.Text))
|
||||
if (PipelineList.Count > 0)
|
||||
{
|
||||
if (PipelineList.Count > 0)
|
||||
{
|
||||
this.Grid1.Hidden = false;
|
||||
this.Grid1.DataSource = PipelineList;
|
||||
this.Grid1.DataBind();
|
||||
Grid1.RecordCount = PipelineList.Count;
|
||||
State = (int)ButtonState.Save;
|
||||
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ShowNotify("请先审核要导入的文件!", MessageBoxIcon.Warning);
|
||||
this.Grid1.Hidden = false;
|
||||
this.Grid1.DataSource = PipelineList;
|
||||
this.Grid1.DataBind();
|
||||
Grid1.RecordCount = PipelineList.Count;
|
||||
State = (int)ButtonState.Save;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ShowNotify("请先将错误数据修正,再重新导入提交!", MessageBoxIcon.Warning);
|
||||
ShowNotify("请先审核要导入的文件!", MessageBoxIcon.Warning);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -910,88 +911,119 @@ namespace FineUIPro.Web.HJGL.WeldingManage
|
||||
return;
|
||||
|
||||
}
|
||||
if (string.IsNullOrEmpty(errorInfos))
|
||||
string unitworkId = importContext.UnitWorkId;
|
||||
ValidatePipelineScope(PipelineList, unitworkId);
|
||||
if (DrpType.SelectedValue != "0" && DrpType.SelectedValue != "1" && DrpType.SelectedValue != "2")
|
||||
{
|
||||
throw new InvalidOperationException("导入类型无效。");
|
||||
}
|
||||
string rootPath = Server.MapPath("~/");
|
||||
string oldefilePath = rootPath + initPath + importContext.FileName;
|
||||
string filePath = rootPath + Const.DesignBasisDataImportPath + importContext.FileName;
|
||||
if (!Directory.Exists(rootPath + Const.DesignBasisDataImportPath))
|
||||
{
|
||||
Directory.CreateDirectory(rootPath + Const.DesignBasisDataImportPath);
|
||||
}
|
||||
File.Move(oldefilePath, filePath);
|
||||
// 消费服务端提交状态,旧页面回放不能重复执行清理。
|
||||
State = (int)ButtonState.Check;
|
||||
string FileName = importContext.OriginalFileName;
|
||||
|
||||
|
||||
if (DrpType.SelectedValue == "1" || DrpType.SelectedValue == "2")//更新导入
|
||||
{
|
||||
|
||||
string rootPath = Server.MapPath("~/");
|
||||
string oldefilePath = rootPath + initPath + this.hdFileName.Text;
|
||||
string unitworkId = Request.Params["UnitWorkId"];
|
||||
string filePath = rootPath + Const.DesignBasisDataImportPath + this.hdFileName.Text;
|
||||
if (oldefilePath != string.Empty && System.IO.File.Exists(oldefilePath))
|
||||
if (DrpType.SelectedValue == "2")
|
||||
{
|
||||
if (!Directory.Exists(rootPath + Const.DesignBasisDataImportPath))
|
||||
{
|
||||
Directory.CreateDirectory(rootPath + Const.DesignBasisDataImportPath);
|
||||
}
|
||||
File.Move(oldefilePath, filePath);
|
||||
//System.IO.File.Delete(oldefilePath);//删除上传的XLS文件
|
||||
DeleteImportedPipelines(unitworkId, PipelineList);
|
||||
}
|
||||
string FileName = this.fuAttachUrl.FileName;
|
||||
|
||||
|
||||
if (DrpType.SelectedValue == "1")//更新导入
|
||||
else
|
||||
{
|
||||
|
||||
BLL.PipelineMatService.DeletePipeLineMatByUnitWorkId(unitworkId);//删除原有管线对应材料
|
||||
BLL.WeldJointService.DeleteWeldJointByUnitWorkId(unitworkId);////删除原有管线对应焊口
|
||||
BLL.PipelineService.DeletePipelineByUnitworkId(unitworkId);//删除原有管线
|
||||
AddView_HJGL_WeldJoint(PipelineList);//导入数据
|
||||
|
||||
Model.HJGL_DesignBasisDataImport hJGL_DesignBasisDataImport = new Model.HJGL_DesignBasisDataImport();
|
||||
hJGL_DesignBasisDataImport.DesignBasisDataImportId = SQLHelper.GetNewID();
|
||||
hJGL_DesignBasisDataImport.ProjectId = this.CurrUser.LoginProjectId;
|
||||
hJGL_DesignBasisDataImport.UnitWorkId = unitworkId;
|
||||
hJGL_DesignBasisDataImport.ImportType = "1";
|
||||
hJGL_DesignBasisDataImport.DataClassification = DataClassification;
|
||||
hJGL_DesignBasisDataImport.FileName = FileName;
|
||||
hJGL_DesignBasisDataImport.FilePath = filePath.Replace(rootPath, "");
|
||||
hJGL_DesignBasisDataImport.FileType = BLL.HJGL_DesignBasisDataImportService.GetFileType(FileName);
|
||||
hJGL_DesignBasisDataImport.Version = BLL.HJGL_DesignBasisDataImportService.GetNewVersionByUnitWorkId(unitworkId, DataClassification);
|
||||
hJGL_DesignBasisDataImport.Remark = txtRemark.Text;
|
||||
hJGL_DesignBasisDataImport.CreateMan = this.CurrUser.PersonId;
|
||||
hJGL_DesignBasisDataImport.CreateDate = DateTime.Now.ToString("yyyy-MM-dd HH-mm-ss");
|
||||
BLL.HJGL_DesignBasisDataImportService.AddHJGL_DesignBasisDataImport(hJGL_DesignBasisDataImport);
|
||||
|
||||
BLL.HJGL_DesignBasisDataImportVerSionLogService.UpdateVersion(this.CurrUser.LoginProjectId, unitworkId, (decimal)hJGL_DesignBasisDataImport.Version, DataClassification);
|
||||
|
||||
|
||||
}
|
||||
else //补充导入
|
||||
{
|
||||
AddView_HJGL_WeldJoint(PipelineList);
|
||||
AddView_HJGL_WeldJoint(PipelineList);//导入数据
|
||||
|
||||
Model.HJGL_DesignBasisDataImport hJGL_DesignBasisDataImport = new Model.HJGL_DesignBasisDataImport();
|
||||
hJGL_DesignBasisDataImport.DesignBasisDataImportId = SQLHelper.GetNewID();
|
||||
hJGL_DesignBasisDataImport.ProjectId = this.CurrUser.LoginProjectId;
|
||||
hJGL_DesignBasisDataImport.UnitWorkId = unitworkId;
|
||||
hJGL_DesignBasisDataImport.ImportType = "0";
|
||||
hJGL_DesignBasisDataImport.DataClassification = DataClassification;
|
||||
hJGL_DesignBasisDataImport.FileName = FileName;
|
||||
hJGL_DesignBasisDataImport.FilePath = filePath.Replace(rootPath, ""); ;
|
||||
hJGL_DesignBasisDataImport.FileType = BLL.HJGL_DesignBasisDataImportService.GetFileType(FileName);
|
||||
hJGL_DesignBasisDataImport.Version = BLL.HJGL_DesignBasisDataImportService.GetNowVersionByUnitWorkId(unitworkId, DataClassification);
|
||||
hJGL_DesignBasisDataImport.Remark = txtRemark.Text;
|
||||
hJGL_DesignBasisDataImport.CreateMan = this.CurrUser.PersonId;
|
||||
hJGL_DesignBasisDataImport.CreateDate = DateTime.Now.ToString("yyyy-MM-dd HH-mm-ss");
|
||||
BLL.HJGL_DesignBasisDataImportService.AddHJGL_DesignBasisDataImport(hJGL_DesignBasisDataImport);
|
||||
Model.HJGL_DesignBasisDataImport hJGL_DesignBasisDataImport = new Model.HJGL_DesignBasisDataImport();
|
||||
hJGL_DesignBasisDataImport.DesignBasisDataImportId = SQLHelper.GetNewID();
|
||||
hJGL_DesignBasisDataImport.ProjectId = this.CurrUser.LoginProjectId;
|
||||
hJGL_DesignBasisDataImport.UnitWorkId = unitworkId;
|
||||
hJGL_DesignBasisDataImport.ImportType = DrpType.SelectedValue;
|
||||
hJGL_DesignBasisDataImport.DataClassification = DataClassification;
|
||||
hJGL_DesignBasisDataImport.FileName = FileName;
|
||||
hJGL_DesignBasisDataImport.FilePath = filePath.Replace(rootPath, "");
|
||||
hJGL_DesignBasisDataImport.FileType = BLL.HJGL_DesignBasisDataImportService.GetFileType(FileName);
|
||||
hJGL_DesignBasisDataImport.Version = BLL.HJGL_DesignBasisDataImportService.GetNewVersionByUnitWorkId(unitworkId, DataClassification);
|
||||
hJGL_DesignBasisDataImport.Remark = txtRemark.Text;
|
||||
hJGL_DesignBasisDataImport.CreateMan = this.CurrUser.PersonId;
|
||||
hJGL_DesignBasisDataImport.CreateDate = DateTime.Now.ToString("yyyy-MM-dd HH-mm-ss");
|
||||
BLL.HJGL_DesignBasisDataImportService.AddHJGL_DesignBasisDataImport(hJGL_DesignBasisDataImport);
|
||||
|
||||
BLL.HJGL_DesignBasisDataImportVerSionLogService.UpdateVersion(this.CurrUser.LoginProjectId, unitworkId, (decimal)hJGL_DesignBasisDataImport.Version, DataClassification);
|
||||
BLL.HJGL_DesignBasisDataImportVerSionLogService.UpdateVersion(this.CurrUser.LoginProjectId, unitworkId, (decimal)hJGL_DesignBasisDataImport.Version, DataClassification);
|
||||
|
||||
}
|
||||
|
||||
ShowNotify("导入成功!", MessageBoxIcon.Success);
|
||||
PipelineService.RestPipelineAndJoints(this.CurrUser.LoginProjectId);
|
||||
|
||||
PageContext.RegisterStartupScript(ActiveWindow.GetHidePostBackReference());
|
||||
}
|
||||
else
|
||||
else //补充导入
|
||||
{
|
||||
ShowNotify("请先将错误数据修正,再重新导入提交!", MessageBoxIcon.Warning);
|
||||
AddView_HJGL_WeldJoint(PipelineList);
|
||||
|
||||
Model.HJGL_DesignBasisDataImport hJGL_DesignBasisDataImport = new Model.HJGL_DesignBasisDataImport();
|
||||
hJGL_DesignBasisDataImport.DesignBasisDataImportId = SQLHelper.GetNewID();
|
||||
hJGL_DesignBasisDataImport.ProjectId = this.CurrUser.LoginProjectId;
|
||||
hJGL_DesignBasisDataImport.UnitWorkId = unitworkId;
|
||||
hJGL_DesignBasisDataImport.ImportType = "0";
|
||||
hJGL_DesignBasisDataImport.DataClassification = DataClassification;
|
||||
hJGL_DesignBasisDataImport.FileName = FileName;
|
||||
hJGL_DesignBasisDataImport.FilePath = filePath.Replace(rootPath, ""); ;
|
||||
hJGL_DesignBasisDataImport.FileType = BLL.HJGL_DesignBasisDataImportService.GetFileType(FileName);
|
||||
hJGL_DesignBasisDataImport.Version = BLL.HJGL_DesignBasisDataImportService.GetNowVersionByUnitWorkId(unitworkId, DataClassification);
|
||||
hJGL_DesignBasisDataImport.Remark = txtRemark.Text;
|
||||
hJGL_DesignBasisDataImport.CreateMan = this.CurrUser.PersonId;
|
||||
hJGL_DesignBasisDataImport.CreateDate = DateTime.Now.ToString("yyyy-MM-dd HH-mm-ss");
|
||||
BLL.HJGL_DesignBasisDataImportService.AddHJGL_DesignBasisDataImport(hJGL_DesignBasisDataImport);
|
||||
|
||||
BLL.HJGL_DesignBasisDataImportVerSionLogService.UpdateVersion(this.CurrUser.LoginProjectId, unitworkId, (decimal)hJGL_DesignBasisDataImport.Version, DataClassification);
|
||||
|
||||
}
|
||||
|
||||
ShowNotify("导入成功!", MessageBoxIcon.Success);
|
||||
PipelineService.RestPipelineAndJoints(this.CurrUser.LoginProjectId);
|
||||
Session.Remove(ImportSessionKey);
|
||||
PageContext.RegisterStartupScript(ActiveWindow.GetHidePostBackReference());
|
||||
}
|
||||
/// <summary>
|
||||
/// 在模板进入写入流程前校验所属范围,拒绝失效或混入其他工程的数据。
|
||||
/// </summary>
|
||||
private void ValidatePipelineScope(List<Model.View_HJGL_WeldJoint> rows, string unitworkId)
|
||||
{
|
||||
if (unitworkId != importContext.UnitWorkId || rows.Count == 0
|
||||
|| rows.Any(x => x.ProjectId != importContext.ProjectId || x.UnitWorkId != unitworkId
|
||||
|| string.IsNullOrWhiteSpace(x.PipelineCode) || string.IsNullOrWhiteSpace(x.WeldJointCode)))
|
||||
{
|
||||
throw new InvalidOperationException("模板为空或数据不属于当前项目、单位工程,请重新审核。");
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 只清理当前单位工程中本次模板涉及的管线及其组件、材料和焊口。
|
||||
/// </summary>
|
||||
private void DeleteImportedPipelines(string unitworkId, List<Model.View_HJGL_WeldJoint> rows)
|
||||
{
|
||||
var pipelineCodes = rows.Select(x => x.PipelineCode).Distinct().ToList();
|
||||
var pipelines = BLL.PipelineService.GetPipelinesByUnitWordId(unitworkId)
|
||||
.Where(x => x.ProjectId == importContext.ProjectId && pipelineCodes.Contains(x.PipelineCode)).ToList();
|
||||
foreach (var pipeline in pipelines)
|
||||
{
|
||||
BLL.HJGL_PipelineComponentService.DeletePipelineComponentBypipelineId(pipeline.PipelineId);
|
||||
BLL.PipelineMatService.DeletePipeLineMatBypipelineId(pipeline.PipelineId);
|
||||
BLL.WeldJointService.DeleteWeldJointByPipelineId(pipeline.PipelineId);
|
||||
BLL.PipelineService.DeletePipeline(pipeline.PipelineId);
|
||||
}
|
||||
}
|
||||
|
||||
public void AddView_HJGL_WeldJoint(List<Model.View_HJGL_WeldJoint> PipelineList)
|
||||
{
|
||||
string unitworkId = Request.Params["UnitWorkId"];
|
||||
string unitworkId = importContext.UnitWorkId;
|
||||
|
||||
addPipelines(PipelineList, unitworkId);
|
||||
addHJGL_WeldJoints(PipelineList, unitworkId);
|
||||
@@ -1298,22 +1330,35 @@ namespace FineUIPro.Web.HJGL.WeldingManage
|
||||
/// <param name="version"></param>
|
||||
private void RestoreVersion(string unitworkId, decimal version)
|
||||
{
|
||||
if (unitworkId != importContext.UnitWorkId)
|
||||
{
|
||||
throw new InvalidOperationException("恢复目标与当前导入窗口的单位工程不一致。");
|
||||
}
|
||||
var model = BLL.HJGL_DesignBasisDataImportService.GetDataByUnitWorkIdAndVersion(unitworkId, version, DataClassification);
|
||||
if (model != null && model.Count > 0)
|
||||
{
|
||||
// 所有历史文件先校验成功,再进入清理流程;恢复不复用当前上传模板。
|
||||
var batches = new List<KeyValuePair<string, List<Model.View_HJGL_WeldJoint>>>();
|
||||
foreach (var item in model)
|
||||
{
|
||||
|
||||
string rootPath = Server.MapPath("~/");
|
||||
// initFullPath = rootPath + initPath;
|
||||
string filePath = rootPath + item.FilePath;
|
||||
ImportXlsToData(filePath);
|
||||
BLL.PipelineMatService.DeletePipeLineMatByUnitWorkId(unitworkId);//删除原有管线对应材料
|
||||
BLL.WeldJointService.DeleteWeldJointByUnitWorkId(unitworkId);////删除原有管线对应焊口
|
||||
BLL.PipelineService.DeletePipelineByUnitworkId(unitworkId);//删除原有管线
|
||||
AddView_HJGL_WeldJoint(PipelineList);//导入数据
|
||||
PipelineList.Clear();
|
||||
|
||||
if (item.ProjectId != importContext.ProjectId || item.UnitWorkId != unitworkId
|
||||
|| item.DataClassification != DataClassification
|
||||
|| (item.ImportType != "0" && item.ImportType != "1" && item.ImportType != "2"))
|
||||
{
|
||||
throw new InvalidOperationException("历史导入记录不属于当前项目、单位工程或导入类型无效,不能恢复。");
|
||||
}
|
||||
var rows = ReadImportFile(Server.MapPath("~/") + item.FilePath);
|
||||
batches.Add(new KeyValuePair<string, List<Model.View_HJGL_WeldJoint>>(item.ImportType, rows));
|
||||
}
|
||||
// 仅重建本版本模板合集涉及的管线,保留模板外管线。
|
||||
DeleteImportedPipelines(unitworkId, batches.SelectMany(x => x.Value).ToList());
|
||||
foreach (var batch in batches)
|
||||
{
|
||||
if (batch.Key == "1" || batch.Key == "2")
|
||||
{
|
||||
DeleteImportedPipelines(unitworkId, batch.Value);
|
||||
}
|
||||
AddView_HJGL_WeldJoint(batch.Value);
|
||||
}
|
||||
BLL.HJGL_DesignBasisDataImportVerSionLogService.UpdateVersion(this.CurrUser.LoginProjectId, unitworkId, version, DataClassification);
|
||||
PipelineService.RestPipelineAndJoints(this.CurrUser.LoginProjectId);
|
||||
@@ -1333,7 +1378,7 @@ namespace FineUIPro.Web.HJGL.WeldingManage
|
||||
}
|
||||
else
|
||||
{
|
||||
PageContext.RegisterStartupScript(Confirm.GetShowReference("确定恢复至该版本吗?", String.Empty, MessageBoxIcon.Question, PageManager1.GetCustomEventReference(false, "Confirm_Restore"), PageManager1.GetCustomEventReference("Confirm_Cancel")));
|
||||
PageContext.RegisterStartupScript(Confirm.GetShowReference("确定恢复该版本模板涉及的管线吗?模板外管线将保留。", String.Empty, MessageBoxIcon.Question, PageManager1.GetCustomEventReference(false, "Confirm_Restore"), PageManager1.GetCustomEventReference("Confirm_Cancel")));
|
||||
|
||||
}
|
||||
|
||||
@@ -1374,7 +1419,7 @@ namespace FineUIPro.Web.HJGL.WeldingManage
|
||||
}
|
||||
else if (e.EventArgument == "Confirm_Restore")
|
||||
{
|
||||
var unitworkid = Request.Params["UnitWorkId"];
|
||||
var unitworkid = importContext.UnitWorkId;
|
||||
decimal version = decimal.Parse(drpVersion.SelectedValue);
|
||||
RestoreVersion(unitworkid, version);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user