feat: 完善材料维护、管线导入与焊接检测报表
为支持材料数量修正和局部管线更新,补充维护与导入入口并隔离窗口审核状态;同步修正焊接日报、外观检测及委托单输出,并简化材料匹配逻辑。
This commit is contained in:
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -613,7 +613,7 @@ namespace FineUIPro.Web.HJGL.DataImport
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 打开材料信息维护窗口,按管线材料ID维护材料主编码和材料编码。
|
||||
/// 打开材料信息维护窗口,按管线材料ID维护材料编码、数量和用途。
|
||||
/// </summary>
|
||||
private void OpenMaterialCodeEdit(Grid grid)
|
||||
{
|
||||
@@ -635,7 +635,7 @@ namespace FineUIPro.Web.HJGL.DataImport
|
||||
return;
|
||||
}
|
||||
|
||||
PageContext.RegisterStartupScript(Window5.GetShowReference(String.Format("MaterialInformationEdit.aspx?PipeLineMatId={0}", grid.SelectedRowID), "维护材料信息", 500, 300));
|
||||
PageContext.RegisterStartupScript(Window5.GetShowReference(String.Format("MaterialInformationEdit.aspx?PipeLineMatId={0}", grid.SelectedRowID), "维护材料信息", 500, 380));
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||
<head runat="server">
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
||||
<title>维护材料编码</title>
|
||||
<title>维护材料信息</title>
|
||||
<base target="_self" />
|
||||
<link href="../../res/css/common.css" rel="stylesheet" type="text/css" />
|
||||
</head>
|
||||
@@ -30,6 +30,14 @@
|
||||
</f:TextBox>
|
||||
</Items>
|
||||
</f:FormRow>
|
||||
<f:FormRow>
|
||||
<Items>
|
||||
<f:NumberBox ID="txtNumber" runat="server" Label="数量" LabelWidth="100px"
|
||||
Required="true" ShowRedStar="true" NoNegative="true" NoDecimal="false"
|
||||
DecimalPrecision="2" MinValue="0" MaxValue="9999999.99">
|
||||
</f:NumberBox>
|
||||
</Items>
|
||||
</f:FormRow>
|
||||
<f:FormRow>
|
||||
<Items>
|
||||
<f:TextBox ID="txtHeatNo" runat="server" Label="炉号"
|
||||
|
||||
@@ -44,6 +44,7 @@ namespace FineUIPro.Web.HJGL.DataImport
|
||||
? Const._Null
|
||||
: pipeLineMat.MaterialCode;
|
||||
this.txtMaterialCode.Text = pipeLineMat.MaterialCode2;
|
||||
this.txtNumber.Text = pipeLineMat.Number.ToString();
|
||||
this.drpPipeArea.SelectedValue = string.IsNullOrEmpty(pipeLineMat.PipeArea)
|
||||
? PipelineService.PipeArea_SHOP
|
||||
: pipeLineMat.PipeArea;
|
||||
@@ -100,16 +101,25 @@ namespace FineUIPro.Web.HJGL.DataImport
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 保存材料主编码和材料编码。
|
||||
/// 保存材料编码、数量和用途。
|
||||
/// </summary>
|
||||
protected void btnSave_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (string.IsNullOrEmpty(this.PipeLineMatId))
|
||||
Model.HJGL_PipeLineMat pipeLineMat = PipelineMatService.GetPipeLineMat(this.PipeLineMatId);
|
||||
if (pipeLineMat == null)
|
||||
{
|
||||
Alert.ShowInTop("未找到材料记录!", MessageBoxIcon.Warning);
|
||||
return;
|
||||
}
|
||||
|
||||
decimal number;
|
||||
if (!decimal.TryParse(this.txtNumber.Text.Trim(), out number)
|
||||
|| number < 0m || number > 9999999.99m || decimal.Round(number, 2) != number)
|
||||
{
|
||||
Alert.ShowInTop("数量请输入0至9999999.99之间的数值,最多保留两位小数!", MessageBoxIcon.Warning);
|
||||
return;
|
||||
}
|
||||
|
||||
string mainMaterialCode = GetMainMaterialCode();
|
||||
if (!string.IsNullOrEmpty(mainMaterialCode) && MaterialCodeLibService.GetMaterialCodeLib(mainMaterialCode) == null)
|
||||
{
|
||||
@@ -117,11 +127,11 @@ namespace FineUIPro.Web.HJGL.DataImport
|
||||
return;
|
||||
}
|
||||
|
||||
PipelineMatService.UpdateMaterialCodes(
|
||||
this.PipeLineMatId,
|
||||
mainMaterialCode,
|
||||
this.txtMaterialCode.Text.Trim());
|
||||
PipelineMatService.UpdatePipeArea(this.PipeLineMatId, this.drpPipeArea.SelectedValue);
|
||||
pipeLineMat.MaterialCode = mainMaterialCode;
|
||||
pipeLineMat.MaterialCode2 = this.txtMaterialCode.Text.Trim();
|
||||
pipeLineMat.Number = number;
|
||||
pipeLineMat.PipeArea = this.drpPipeArea.SelectedValue;
|
||||
PipelineMatService.UpdatePipeLineMat(pipeLineMat);
|
||||
ShowNotify("保存成功!", MessageBoxIcon.Success);
|
||||
PageContext.RegisterStartupScript(ActiveWindow.GetHidePostBackReference());
|
||||
}
|
||||
|
||||
@@ -59,6 +59,11 @@ namespace FineUIPro.Web.HJGL.DataImport
|
||||
/// </remarks>
|
||||
protected global::FineUIPro.TextBox txtMaterialCode;
|
||||
|
||||
/// <summary>
|
||||
/// txtNumber 控件。
|
||||
/// </summary>
|
||||
protected global::FineUIPro.NumberBox txtNumber;
|
||||
|
||||
/// <summary>
|
||||
/// txtHeatNo 控件。
|
||||
/// </summary>
|
||||
|
||||
@@ -768,7 +768,7 @@ namespace FineUIPro.Web.HJGL.PointTrust
|
||||
DataRow detailRow = detailTable.NewRow();
|
||||
detailRow["Sequence"] = sequence++;
|
||||
detailRow["PipelineCode"] = item.PipelineCode ?? string.Empty;
|
||||
detailRow["WeldJointCode"] = item.WeldJointCode ?? string.Empty;
|
||||
detailRow["WeldJointCode"] = "S" + item.WeldJointCode;
|
||||
detailRow["Specification"] = item.Specification ?? string.Empty;
|
||||
detailRow["GrooveType"] = item.GrooveTypeCode ?? string.Empty;
|
||||
detailRow["WeldingMethod"] = item.WeldingMethodCode ?? string.Empty;
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
<f:DropDownList ID="DrpType" runat="server" Label="导入类型">
|
||||
<f:ListItem Text="补充导入" Value="0"/>
|
||||
<f:ListItem Text="更新导入" Value="1"/>
|
||||
<f:ListItem Text="更新导入(管线)" Value="2"/>
|
||||
</f:DropDownList>
|
||||
<f:RadioButtonList ID="rbDiaType" Label="DN公称直径/外径" runat="server">
|
||||
<f:RadioItem Text="DN公称直径" Value="0" Selected="true"/>
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -131,9 +131,6 @@ namespace FineUIPro.Web.HJGL.WeldingManage
|
||||
drpWarehouse_SelectedIndexChanged(null, null);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 清空材料库存缓存,避免首次加载沿用其他入口的区域缓存。
|
||||
/// </summary>
|
||||
/// <summary>
|
||||
/// 绑定当前项目的流水段筛选项。
|
||||
/// </summary>
|
||||
@@ -500,7 +497,8 @@ namespace FineUIPro.Web.HJGL.WeldingManage
|
||||
{
|
||||
Grid1.Rows[i].RowCssClass = "red";
|
||||
}
|
||||
else if (IsMaterialCodeConfirmed(model, confirmedPipeLineMatIds))
|
||||
else if (!string.IsNullOrEmpty(model.PipeLineMatId)
|
||||
&& confirmedPipeLineMatIds.Contains(model.PipeLineMatId))
|
||||
{
|
||||
Grid1.Rows[i].RowCssClass = "green";
|
||||
}
|
||||
@@ -601,20 +599,6 @@ namespace FineUIPro.Web.HJGL.WeldingManage
|
||||
return new HashSet<string>(confirmedIds);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 判断单条材料明细是否已经反写材料主编码。
|
||||
/// </summary>
|
||||
/// <param name="model">材料匹配明细。</param>
|
||||
/// <param name="confirmedPipeLineMatIds">已反写材料主编码的管线材料ID集合。</param>
|
||||
/// <returns>已反写返回 true,否则返回 false。</returns>
|
||||
private bool IsMaterialCodeConfirmed(Tw_PipeMatMatchOutput model, HashSet<string> confirmedPipeLineMatIds)
|
||||
{
|
||||
return model != null
|
||||
&& confirmedPipeLineMatIds != null
|
||||
&& !string.IsNullOrEmpty(model.PipeLineMatId)
|
||||
&& confirmedPipeLineMatIds.Contains(model.PipeLineMatId);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 显示材料匹配颜色和任务单生成规则说明。
|
||||
/// </summary>
|
||||
@@ -642,7 +626,7 @@ namespace FineUIPro.Web.HJGL.WeldingManage
|
||||
private void RefreshMatchResult()
|
||||
{
|
||||
// 重新匹配库存会刷新管线汇总表,先暂存选择状态,绑定完成后再恢复。
|
||||
var keepSelectedPipelineIds = Grid2.SelectedRowIDArray == null ? new List<string>() : Grid2.SelectedRowIDArray.ToList();
|
||||
var keepSelectedPipelineIds = Grid2.SelectedRowIDArray?.ToList() ?? new List<string>();
|
||||
tw_PipeMatMatchOutputs = TwArrivalStatisticsService.GetPipeMatMatch(
|
||||
this.CurrUser.LoginProjectId,
|
||||
dicSeclectPipeLine.Keys.ToList(),
|
||||
@@ -966,7 +950,7 @@ namespace FineUIPro.Web.HJGL.WeldingManage
|
||||
}
|
||||
|
||||
// 优先焊口会触发重新匹配,当前管线也必须继续保持选中,方便后续生成任务单。
|
||||
var keepSelectedPipelineIds = Grid2.SelectedRowIDArray == null ? new List<string>() : Grid2.SelectedRowIDArray.ToList();
|
||||
var keepSelectedPipelineIds = Grid2.SelectedRowIDArray?.ToList() ?? new List<string>();
|
||||
if (!keepSelectedPipelineIds.Contains(selectedPipelineId))
|
||||
{
|
||||
keepSelectedPipelineIds.Add(selectedPipelineId);
|
||||
@@ -976,6 +960,28 @@ namespace FineUIPro.Web.HJGL.WeldingManage
|
||||
BindMaterialDetail();
|
||||
}
|
||||
|
||||
private List<Tw_PipeMatMatchOutput> GetSelectedPipelineMaterials()
|
||||
{
|
||||
if (tw_PipeMatMatchOutputs == null || !tw_PipeMatMatchOutputs.Any())
|
||||
{
|
||||
RefreshMatchResult();
|
||||
}
|
||||
|
||||
var selectedPipelineIds = Grid2.SelectedRowIDArray.ToList();
|
||||
return tw_PipeMatMatchOutputs
|
||||
.Where(x => selectedPipelineIds.Contains(x.PipelineId))
|
||||
.ToList();
|
||||
}
|
||||
|
||||
private void RefreshMatchResultAndDetail()
|
||||
{
|
||||
RefreshMatchResult();
|
||||
if (Grid2.SelectedRowIDArray.Any())
|
||||
{
|
||||
BindMaterialDetail();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 将当前选中管线的匹配结果反写到管线材料主编码。
|
||||
/// </summary>
|
||||
@@ -989,15 +995,7 @@ namespace FineUIPro.Web.HJGL.WeldingManage
|
||||
return;
|
||||
}
|
||||
|
||||
if (tw_PipeMatMatchOutputs == null || !tw_PipeMatMatchOutputs.Any())
|
||||
{
|
||||
RefreshMatchResult();
|
||||
}
|
||||
|
||||
var selectedPipelineIds = Grid2.SelectedRowIDArray.ToList();
|
||||
var matchedMaterials = tw_PipeMatMatchOutputs
|
||||
.Where(x => selectedPipelineIds.Contains(x.PipelineId))
|
||||
.ToList();
|
||||
var matchedMaterials = GetSelectedPipelineMaterials();
|
||||
if (!matchedMaterials.Any())
|
||||
{
|
||||
ShowNotify("未找到保存的材料匹配明细!", MessageBoxIcon.Warning);
|
||||
@@ -1006,11 +1004,7 @@ namespace FineUIPro.Web.HJGL.WeldingManage
|
||||
|
||||
int count = BLL.PipelineMatService.UpdateMaterialCodeByMatchOutputs(matchedMaterials);
|
||||
ShowNotify("已保存材料主编码" + count.ToString() + "条!", MessageBoxIcon.Success);
|
||||
RefreshMatchResult();
|
||||
if (Grid2.SelectedRowIDArray.Any())
|
||||
{
|
||||
BindMaterialDetail();
|
||||
}
|
||||
RefreshMatchResultAndDetail();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -1026,14 +1020,7 @@ namespace FineUIPro.Web.HJGL.WeldingManage
|
||||
return;
|
||||
}
|
||||
|
||||
if (tw_PipeMatMatchOutputs == null || !tw_PipeMatMatchOutputs.Any())
|
||||
{
|
||||
RefreshMatchResult();
|
||||
}
|
||||
|
||||
var selectedPipelineIds = Grid2.SelectedRowIDArray.ToList();
|
||||
var pipeLineMatIds = tw_PipeMatMatchOutputs
|
||||
.Where(x => selectedPipelineIds.Contains(x.PipelineId))
|
||||
var pipeLineMatIds = GetSelectedPipelineMaterials()
|
||||
.Select(x => x.PipeLineMatId)
|
||||
.Distinct()
|
||||
.ToList();
|
||||
@@ -1045,11 +1032,7 @@ namespace FineUIPro.Web.HJGL.WeldingManage
|
||||
|
||||
int count = BLL.PipelineMatService.ClearMaterialCodeByPipeLineMatIds(pipeLineMatIds);
|
||||
ShowNotify("已清除材料主编码" + count.ToString() + "条,已生成任务单的焊口已跳过!", MessageBoxIcon.Success);
|
||||
RefreshMatchResult();
|
||||
if (Grid2.SelectedRowIDArray.Any())
|
||||
{
|
||||
BindMaterialDetail();
|
||||
}
|
||||
RefreshMatchResultAndDetail();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -1094,93 +1077,80 @@ namespace FineUIPro.Web.HJGL.WeldingManage
|
||||
/// <returns>生成成功返回 true;校验失败或无可生成焊口返回 false。</returns>
|
||||
private bool SaveTask(HashSet<string> selectedWeldJointIds)
|
||||
{
|
||||
if (selectedWeldJointIds == null || !selectedWeldJointIds.Any())
|
||||
{
|
||||
ShowNotify("选中管线中没有已反写材料主编码的可生成任务单焊口!", MessageBoxIcon.Warning);
|
||||
return false;
|
||||
}
|
||||
var weldingRods = from x in Funs.DB.Base_Consumables where x.ConsumablesType == WeldingRodConsumablesType select x;
|
||||
var weldingWires = from x in Funs.DB.Base_Consumables where x.ConsumablesType == WeldingWireConsumablesType select x;
|
||||
var selectedWeldJointIdList = selectedWeldJointIds.ToList();
|
||||
var selectRowId = GetTaskableWeldJointRows(selectedWeldJointIdList);
|
||||
var taskableWeldJoints = GetTaskableWeldJointRows(selectedWeldJointIds.ToList());
|
||||
|
||||
Dictionary<string, string> unitworkTaskCode = new Dictionary<string, string>();
|
||||
Dictionary<string, string> unitworkSerialNumber = new Dictionary<string, string>();
|
||||
Dictionary<int, string> matchPipeline = GetMatchPipelineOrder();
|
||||
if (!selectRowId.Any())
|
||||
var taskCodesByUnitWorkId = new Dictionary<string, string>();
|
||||
var serialNumbersByUnitWorkId = new Dictionary<string, string>();
|
||||
var matchPipelineOrder = new Dictionary<int, string>();
|
||||
for (int rowIndex = 0; rowIndex < Grid2.Rows.Count; rowIndex++)
|
||||
{
|
||||
matchPipelineOrder.Add(rowIndex + 1, Grid2.Rows[rowIndex].RowID);
|
||||
}
|
||||
if (!taskableWeldJoints.Any())
|
||||
{
|
||||
ShowNotify("未找到可生成任务单的焊口!", MessageBoxIcon.Warning);
|
||||
return false;
|
||||
}
|
||||
foreach (var weldjoint in selectRowId)
|
||||
foreach (var weldJointRow in taskableWeldJoints)
|
||||
{
|
||||
Model.HJGL_WeldTask NewTask = new Model.HJGL_WeldTask();
|
||||
NewTask.ProjectId = this.CurrUser.LoginProjectId;
|
||||
NewTask.UnitWorkId = PipelineService.GetPipelineByPipelineId(weldjoint.PipelineId)?.UnitWorkId;
|
||||
NewTask.UnitId = this.CurrUser.UnitId;
|
||||
if (unitworkTaskCode.FirstOrDefault(x => x.Key == NewTask.UnitWorkId).Value != null)
|
||||
var newTask = new Model.HJGL_WeldTask();
|
||||
newTask.ProjectId = this.CurrUser.LoginProjectId;
|
||||
newTask.UnitWorkId = PipelineService.GetPipelineByPipelineId(weldJointRow.PipelineId)?.UnitWorkId;
|
||||
newTask.UnitId = this.CurrUser.UnitId;
|
||||
var taskCode = taskCodesByUnitWorkId.FirstOrDefault(x => x.Key == newTask.UnitWorkId).Value;
|
||||
if (taskCode != null)
|
||||
{
|
||||
NewTask.TaskCode = unitworkTaskCode.FirstOrDefault(x => x.Key == NewTask.UnitWorkId).Value;
|
||||
newTask.TaskCode = taskCode;
|
||||
}
|
||||
else
|
||||
{
|
||||
NewTask.TaskCode = BLL.WeldTaskService.GetTaskCodeByDate(this.CurrUser.LoginProjectId, DateTime.Now.Date.ToString("yyyy-MM-dd"), NewTask.UnitWorkId, this.CurrUser.UnitId);
|
||||
unitworkTaskCode.Add(NewTask.UnitWorkId, NewTask.TaskCode);
|
||||
newTask.TaskCode = BLL.WeldTaskService.GetTaskCodeByDate(this.CurrUser.LoginProjectId, DateTime.Now.Date.ToString("yyyy-MM-dd"), newTask.UnitWorkId, this.CurrUser.UnitId);
|
||||
taskCodesByUnitWorkId.Add(newTask.UnitWorkId, newTask.TaskCode);
|
||||
}
|
||||
|
||||
if (unitworkSerialNumber.FirstOrDefault(x => x.Key == NewTask.UnitWorkId).Value != null)
|
||||
var serialNumber = serialNumbersByUnitWorkId.FirstOrDefault(x => x.Key == newTask.UnitWorkId).Value;
|
||||
if (serialNumber != null)
|
||||
{
|
||||
NewTask.SerialNumber = unitworkSerialNumber.FirstOrDefault(x => x.Key == NewTask.UnitWorkId).Value;
|
||||
newTask.SerialNumber = serialNumber;
|
||||
}
|
||||
else
|
||||
{
|
||||
NewTask.SerialNumber = BLL.WeldTaskService.GetSerialNumberByDate(this.CurrUser.LoginProjectId, DateTime.Now.Date.ToString("yyyy-MM-dd"), NewTask.UnitWorkId, this.CurrUser.UnitId);
|
||||
unitworkSerialNumber.Add(NewTask.UnitWorkId, NewTask.SerialNumber);
|
||||
newTask.SerialNumber = BLL.WeldTaskService.GetSerialNumberByDate(this.CurrUser.LoginProjectId, DateTime.Now.Date.ToString("yyyy-MM-dd"), newTask.UnitWorkId, this.CurrUser.UnitId);
|
||||
serialNumbersByUnitWorkId.Add(newTask.UnitWorkId, newTask.SerialNumber);
|
||||
}
|
||||
|
||||
NewTask.WeldTaskId = SQLHelper.GetNewID();
|
||||
NewTask.WeldJointId = weldjoint.WeldJointId;
|
||||
var oldWeldTask = BLL.WeldTaskService.GetWeldTaskByWeldJointId(NewTask.WeldJointId);
|
||||
if (oldWeldTask != null)
|
||||
newTask.WeldTaskId = SQLHelper.GetNewID();
|
||||
newTask.WeldJointId = weldJointRow.WeldJointId;
|
||||
var existingWeldTask = BLL.WeldTaskService.GetWeldTaskByWeldJointId(newTask.WeldJointId);
|
||||
if (existingWeldTask != null)
|
||||
{
|
||||
ShowNotify("所选焊口已存在任务单,无法保存!", MessageBoxIcon.Warning);
|
||||
return false;
|
||||
}
|
||||
Model.HJGL_WeldJoint weldJoint = BLL.WeldJointService.GetWeldJointByWeldJointId(NewTask.WeldJointId);
|
||||
var weldJoint = BLL.WeldJointService.GetWeldJointByWeldJointId(newTask.WeldJointId);
|
||||
if (weldJoint != null)
|
||||
{
|
||||
NewTask.PipeLineSortIndex = matchPipeline.FirstOrDefault(x => x.Value == weldJoint.PipelineId).Key;
|
||||
NewTask.WeldingRod = weldJoint.WeldingRod;
|
||||
NewTask.WeldingWire = weldJoint.WeldingWire;
|
||||
BLL.WeldTaskService.PopulateAlternativeConsumables(NewTask, weldJoint, weldingRods, weldingWires);
|
||||
newTask.PipeLineSortIndex = matchPipelineOrder.FirstOrDefault(x => x.Value == weldJoint.PipelineId).Key;
|
||||
newTask.WeldingRod = weldJoint.WeldingRod;
|
||||
newTask.WeldingWire = weldJoint.WeldingWire;
|
||||
BLL.WeldTaskService.PopulateAlternativeConsumables(newTask, weldJoint, weldingRods, weldingWires);
|
||||
}
|
||||
NewTask.JointAttribute = weldJoint.JointAttribute;
|
||||
newTask.JointAttribute = weldJoint.JointAttribute;
|
||||
|
||||
NewTask.TaskDate = DateTime.Now.Date;
|
||||
NewTask.Tabler = this.CurrUser.PersonId;
|
||||
NewTask.TableDate = DateTime.Now;
|
||||
newTask.TaskDate = DateTime.Now.Date;
|
||||
newTask.Tabler = this.CurrUser.PersonId;
|
||||
newTask.TableDate = DateTime.Now;
|
||||
|
||||
weldJoint.WeldingMode = ManualWeldingMode;
|
||||
BLL.WeldJointService.UpdateWeldJoint(weldJoint);
|
||||
BLL.WeldTaskService.AddWeldTask(NewTask);
|
||||
BLL.WeldTaskService.AddWeldTask(newTask);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取当前管线汇总表中的显示顺序,供任务单保存管线排序使用。
|
||||
/// </summary>
|
||||
private Dictionary<int, string> GetMatchPipelineOrder()
|
||||
{
|
||||
var matchPipeline = new Dictionary<int, string>();
|
||||
for (int rowIndex = 0; rowIndex < Grid2.Rows.Count; rowIndex++)
|
||||
{
|
||||
matchPipeline.Add(rowIndex + 1, Grid2.Rows[rowIndex].RowID);
|
||||
}
|
||||
return matchPipeline;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 按任务单实际生成规则过滤可生成任务单的焊口视图数据。
|
||||
/// </summary>
|
||||
@@ -1257,7 +1227,8 @@ namespace FineUIPro.Web.HJGL.WeldingManage
|
||||
|
||||
var weldJointIds = materialDetails
|
||||
.GroupBy(x => x.WeldJointId)
|
||||
.Where(x => x.All(y => IsMaterialCodeConfirmed(y, confirmedPipeLineMatIds)))
|
||||
.Where(x => x.All(y => !string.IsNullOrEmpty(y.PipeLineMatId)
|
||||
&& confirmedPipeLineMatIds.Contains(y.PipeLineMatId)))
|
||||
.Select(x => x.Key);
|
||||
// 材料齐套后还要继续套用任务单视图条件,保证合计数量和点击生成按钮的实际范围一致。
|
||||
return new HashSet<string>(GetTaskableWeldJointRows(weldJointIds).Select(x => x.WeldJointId));
|
||||
|
||||
Reference in New Issue
Block a user