20250704 试压包导入

This commit is contained in:
2025-07-04 13:50:37 +08:00
parent b004037b4d
commit 2fe06c242f
7 changed files with 367 additions and 347 deletions
@@ -111,7 +111,7 @@
</f:Window>
<f:Menu ID="Menu1" runat="server">
<Items>
<f:MenuButton ID="btnMenuImport" EnablePostBack="true" runat="server" Text="导入" Icon="PageExcel" OnClick="btnMenuImport_Click" Hidden="true">
<f:MenuButton ID="btnMenuImport" EnablePostBack="true" runat="server" Text="导入" Icon="PageExcel" OnClick="btnMenuImport_Click" >
</f:MenuButton>
<f:MenuButton ID="btnMenuNew" EnablePostBack="true" runat="server" Text="新增" Icon="Add" OnClick="btnMenuNew_Click">
</f:MenuButton>
@@ -48,40 +48,35 @@
</f:Toolbar>
</Toolbars>
<Rows>
<f:FormRow>
<Items>
</Items>
</f:FormRow>
<f:FormRow>
<Items>
<f:Grid ID="Grid1" ShowBorder="true" ShowHeader="false" Title="试压包信息" Height="350px"
EnableCollapse="true" runat="server" BoxFlex="1" DataKeyNames="PipelineCode" AllowCellEditing="true"
AllowColumnLocking="true" EnableColumnLines="true" ClicksToEdit="2" DataIDField="PipelineCode" EnableBigData="true"
EnableColumnLines="true" ClicksToEdit="2" DataIDField="PipelineCode"
AllowSorting="true" SortField="PipelineCode" SortDirection="ASC"
AllowPaging="true" IsDatabasePaging="false" PageSize="300" EnableBigDataRowTip="false"
AllowPaging="true" IsDatabasePaging="false" PageSize="300"
EnableTextSelection="True" >
<Columns>
<f:RowNumberField EnablePagingNumber="true" HeaderText="序号"
Width="60px" HeaderTextAlign="Center" TextAlign="Center" />
<f:RenderField Width="100px" ColumnID="" DataField="" SortField=""
<f:RenderField Width="300px" ColumnID="TestPackageNo" DataField="TestPackageNo" SortField="TestPackageNo"
FieldType="String" HeaderText="试压包号" HeaderTextAlign="Center"
TextAlign="Left">
</f:RenderField>
<f:RenderField Width="100px" ColumnID="" DataField="" SortField=""
<f:RenderField Width="200px" ColumnID="TestPackageName" DataField="TestPackageName" SortField="TestPackageName"
FieldType="String" HeaderText="系统名称" HeaderTextAlign="Center"
TextAlign="Left">
</f:RenderField>
<f:RenderField Width="130px" ColumnID="PipelineCode" DataField="PipelineCode" SortField="PipelineCode"
<f:RenderField Width="330px" ColumnID="PipelineCode" DataField="PipelineCode" SortField="PipelineCode"
FieldType="String" HeaderText="管线号" HeaderTextAlign="Center"
TextAlign="Left">
</f:RenderField>
<f:RenderField Width="100px" ColumnID="" DataField="" SortField=""
<f:RenderField Width="100px" ColumnID="TestPressure" DataField="TestPressure" SortField="TestPressure"
FieldType="String" HeaderText="调整试验压力" HeaderTextAlign="Center"
TextAlign="Left">
</f:RenderField>
<f:RenderField HeaderText="备注" ColumnID=""
DataField="" SortField="" FieldType="String" HeaderTextAlign="Center"
<f:RenderField HeaderText="备注" ColumnID="Remark"
DataField="Remark" SortField="Remark" FieldType="String" HeaderTextAlign="Center"
TextAlign="Left" Width="100px">
</f:RenderField>
</Columns>
@@ -63,6 +63,7 @@ namespace FineUIPro.Web.HJGL.TestPackage
}
}
#endregion
//void BindGrid2()
//{
// string strSql = @" select Import.DesignBasisDataImportId
@@ -154,6 +155,7 @@ namespace FineUIPro.Web.HJGL.TestPackage
alert.Show();
}
}
#region Excel提取数据
/// <summary>
/// 从Excel提取数据--》Dataset
@@ -192,8 +194,6 @@ namespace FineUIPro.Web.HJGL.TestPackage
}
#endregion
#region Dataset的数据导入数据库
/// <summary>
/// 将Dataset的数据导入数据库
@@ -216,8 +216,11 @@ namespace FineUIPro.Web.HJGL.TestPackage
if (pds.Count > 0 && pds != null)
{
Model.SGGLDB db = Funs.DB;
var getPipeline = from x in db.View_HJGL_WeldJoint where x.ProjectId == this.CurrUser.LoginProjectId select x;
//var getPipeline = from x in db.View_HJGL_WeldJoint where x.ProjectId == this.CurrUser.LoginProjectId select x;
var getPipeline = from x in db.HJGL_Pipeline where x.ProjectId == this.CurrUser.LoginProjectId
&& x.UnitWorkId==Request.Params["UnitWorkId"]
select x;
Model.WBS_UnitWork unitWork = BLL.UnitWorkService.GetUnitWorkByUnitWorkId(Request.Params["UnitWorkId"]);
for (int i = 1; i < pds.Count; i++)
{
@@ -229,46 +232,67 @@ namespace FineUIPro.Web.HJGL.TestPackage
pipeline.UnitId = unitWork.UnitId;
}
string col0 = pds[i].A;
if (string.IsNullOrEmpty(col0))
if (pds[i].A != null)
{
string col0 = pds[i].A.ToString();
if (string.IsNullOrEmpty(col0))
{
result.Add("第" + (i + 1).ToString() + "行," + "试压包编号" + "," + "此项为必填项!" + "|");
}
else
{
pipeline.TestPackageNo = col0;
}
}
else
{
result.Add("第" + (i + 1).ToString() + "行," + "试压包编号" + "," + "此项为必填项!" + "|");
}
else
if (pds[i].B != null)
{
pipeline.TestPackageNo = col0;
pipeline.TestPackageName = pds[i].B.ToString();//系统名称
}
pipeline.TestPackageName = pds[i].B;//系统名称
string col2 = pds[i].C;
if (string.IsNullOrEmpty(col2))
if (pds[i].C != null)
{
string col2 = pds[i].C.ToString();
if (string.IsNullOrEmpty(col2))
{
result.Add("第" + (i + 1).ToString() + "行," + "管线号" + "," + "此项为必填项!" + "|");
}
else
{
var line = getPipeline.FirstOrDefault(u => u.PipelineCode == col2);
if (line != null)
{
var ptpLineList = from x in db.PTP_PipelineList where x.PipelineId == line.PipelineId select x;
if (ptpLineList != null && DrpType.SelectedValue == "0")
{
result.Add("第" + (i + 1).ToString() + "行," + "管线号[" + col2 + "]已试压!" + "|");
}
else
{
pipeline.PipelineId = line.PipelineId;
pipeline.PipelineCode = col2;
}
}
else
{
result.Add("第" + (i + 1).ToString() + "行," + "管线号[" + col2 + "]不存在!" + "|");
}
}
}
else
{
result.Add("第" + (i + 1).ToString() + "行," + "管线号" + "," + "此项为必填项!" + "|");
}
else
if (pds[i].D != null)
{
var line = getPipeline.FirstOrDefault(u => u.PipelineCode == col2);
if (line!=null)
{
pipeline.PipelineId = line.PipelineId;
pipeline.PipelineCode = col2;
}
pipeline.AdjustTestPressure = pds[i].D.ToString();
}
string col3 = pds[i].D;
if (!string.IsNullOrEmpty(col3))
if (pds[i].E != null)
{
try
{
decimal testPressure = Convert.ToDecimal(col3);
pipeline.TestPressure = testPressure;
}
catch (Exception)
{
result.Add("第" + (i + 1).ToString() + "行," + "调整试验压力格式输入有误" + "|");
}
}
pipeline.Remark = pds[i].E;
pipeline.Remark = pds[i].E.ToString();
}
pipeline.Tabler = this.CurrUser.PersonId;
pipeline.TableDate = DateTime.Now;
@@ -289,7 +313,6 @@ namespace FineUIPro.Web.HJGL.TestPackage
{
errorInfos = string.Empty;
}
}
else
{
@@ -339,6 +362,7 @@ namespace FineUIPro.Web.HJGL.TestPackage
}
#endregion
#region
/// <summary>
/// 提交
@@ -371,9 +395,9 @@ namespace FineUIPro.Web.HJGL.TestPackage
if (DrpType.SelectedValue == "1")//更新导入
{
//BLL.PipelineMatService.DeletePipeLineMatByUnitWorkId(unitworkId);//删除原有管线对应材料
BLL.WeldJointService.DeleteWeldJointByUnitWorkId(unitworkId);////删除原有管线对应焊口
BLL.PipelineService.DeletePipelineByUnitworkId(unitworkId);//删除原有管线
AddView_HJGL_WeldJoint(PipelineList);//导入数据
//BLL.WeldJointService.DeleteWeldJointByUnitWorkId(unitworkId);////删除原有管线对应焊口
//BLL.PipelineService.DeletePipelineByUnitworkId(unitworkId);//删除原有管线
AddView_TestPackage_PipelineList(PipelineList);//导入数据
//Model.HJGL_DesignBasisDataImport hJGL_DesignBasisDataImport = new Model.HJGL_DesignBasisDataImport();
//hJGL_DesignBasisDataImport.DesignBasisDataImportId = SQLHelper.GetNewID();
@@ -396,7 +420,7 @@ namespace FineUIPro.Web.HJGL.TestPackage
}
else //补充导入
{
AddView_HJGL_WeldJoint(PipelineList);
AddView_TestPackage_PipelineList(PipelineList);
//Model.HJGL_DesignBasisDataImport hJGL_DesignBasisDataImport = new Model.HJGL_DesignBasisDataImport();
//hJGL_DesignBasisDataImport.DesignBasisDataImportId = SQLHelper.GetNewID();
@@ -427,12 +451,12 @@ namespace FineUIPro.Web.HJGL.TestPackage
ShowNotify("请先将错误数据修正,再重新导入提交!", MessageBoxIcon.Warning);
}
}
public void AddView_HJGL_WeldJoint(List<Model.View_TestPackage_PipelineList> PipelineList)
public void AddView_TestPackage_PipelineList(List<Model.View_TestPackage_PipelineList> PipelineList)
{
string unitworkId = Request.Params["UnitWorkId"];
addTestPackage(PipelineList, unitworkId);
addHJGL_WeldJoints(PipelineList, unitworkId);
addPTP_PipelineList(PipelineList, unitworkId);
}
void addTestPackage(List<Model.View_TestPackage_PipelineList> PipelineList, string UnitWorkId)
@@ -448,7 +472,8 @@ namespace FineUIPro.Web.HJGL.TestPackage
TestPackageName=x.TestPackageName,
Tabler =x.Tabler,
TableDate=x.TableDate,
Remark = x.Remark
Remark = x.Remark,
AdjustTestPressure=x.AdjustTestPressure
}).DistinctBy(temp => new
{
temp.PTP_ID,
@@ -457,7 +482,8 @@ namespace FineUIPro.Web.HJGL.TestPackage
temp.UnitWorkId,
temp.TestPackageNo,
temp.TestPackageName,
temp.Remark
temp.Remark,
temp.AdjustTestPressure
}).ToList();
for (int i = 0; i < pipelines.Count(); i++)
{
@@ -471,6 +497,7 @@ namespace FineUIPro.Web.HJGL.TestPackage
pipeline.Tabler = pipelines[i].Tabler;
pipeline.TableDate = pipelines[i].TableDate;
pipeline.Remark = pipelines[i].Remark;
pipeline.AdjustTestPressure = pipelines[i].AdjustTestPressure;
var isExistTestPackageNo = TestPackageEditService.GetTestPackageByNo(pipeline.TestPackageNo, pipeline.UnitWorkId);
if (isExistTestPackageNo != null) // 更新试压包
@@ -485,40 +512,41 @@ namespace FineUIPro.Web.HJGL.TestPackage
}
}
}
void addHJGL_WeldJoints(List<Model.View_TestPackage_PipelineList> PipelineList, string UnitWorkId)
void addPTP_PipelineList(List<Model.View_TestPackage_PipelineList> PipelineList, string UnitWorkId)
{
Model.SGGLDB db = Funs.DB;
var getpipelines = from y in db.PTP_TestPackage where y.UnitWorkId == UnitWorkId select y;
var allWeldJoints = from x in db.PTP_PipelineList
var getTestPackage = from y in db.PTP_TestPackage where y.UnitWorkId == UnitWorkId select y;
var allPipelineLists = from x in db.PTP_PipelineList
join y in db.PTP_TestPackage on x.PTP_ID equals y.PTP_ID
where y.UnitWorkId == UnitWorkId
select x;
List<Model.PTP_PipelineList> weldJoints_add = new List<Model.PTP_PipelineList>();
List<Model.PTP_PipelineList> pipelineList_add = new List<Model.PTP_PipelineList>();
var weldJoints = (from x in PipelineList
select new Model.PTP_PipelineList
{
{
PTP_ID = x.PTP_ID,
TestPackageNo=x.TestPackageNo,
PipelineId = x.PipelineId,
TestPressure = x.TestPressure,
//TestPressure = x.TestPressure,
}).DistinctBy(temp => new
{
temp.PTP_ID,
temp.TestPackageNo,
temp.PipelineId,
temp.TestPressure
//temp.TestPressure
}).ToList();
var pipelineCodes = weldJoints.Select(x => x.PTP_ID).Distinct().ToList();
for (int i = 0; i < weldJoints.Count(); i++)
{
Model.PTP_PipelineList weldJoint = new Model.PTP_PipelineList();
//weldJoint.PipelineId = getpipelines.Where(x => x.TestPackageNo == weldJoints[i].PipelineCode).FirstOrDefault().PipelineId;
//weldJoint.WeldJointCode = weldJoints[i].WeldJointCode;
//weldJoint.PipelineCode = weldJoints[i].PipelineCode;
weldJoint.PTP_ID = getTestPackage.Where(x => x.TestPackageNo == weldJoints[i].TestPackageNo).FirstOrDefault().PTP_ID;
weldJoint.PipelineId = weldJoints[i].PipelineId;
//weldJoint.TestPressure = weldJoints[i].TestPressure;
var isExistJot = allWeldJoints.FirstOrDefault(x => x.PTP_ID == weldJoint.PTP_ID && x.PipelineId == weldJoint.PipelineId);
if (isExistJot != null) // 更新焊口
var isExistJot = allPipelineLists.FirstOrDefault(x => x.PTP_ID == weldJoint.PTP_ID && x.PipelineId == weldJoint.PipelineId);
if (isExistJot != null) // 更新试压管线
{
weldJoint.PT_PipeId = isExistJot.PT_PipeId;
BLL.TestPackageEditService.UpdatePipelineList(weldJoint);
@@ -526,130 +554,43 @@ namespace FineUIPro.Web.HJGL.TestPackage
else // 增加试压管线
{
weldJoint.PT_PipeId = SQLHelper.GetNewID();
weldJoints_add.Add(weldJoint);
pipelineList_add.Add(weldJoint);
}
}
if (weldJoints_add.Count > 0)
if (pipelineList_add.Count > 0)
{
//BLL.TestPackageEditService.AddPipelineList(weldJoints_add);
}
Model.SGGLDB db2 = Funs.DB;
List<Model.PTP_PipelineList> delJoints = new List<Model.PTP_PipelineList>();
var allWeldJoints2 = from x in db2.PTP_PipelineList
join y in db2.PTP_TestPackage on x.PTP_ID equals y.PTP_ID
where y.UnitWorkId == Request.Params["UnitWorkId"]
select x;
foreach (var pipelineCode in pipelineCodes)
{
var pipelineWeldJointCodes = weldJoints.Where(x => x.PTP_ID == pipelineCode).Select(x => x.PipelineId).ToList();
var q = allWeldJoints2.Where(x => x.PTP_ID == pipelineCode && !pipelineWeldJointCodes.Contains(x.PipelineId)).ToList();
delJoints.AddRange(q);
}
if (delJoints.Count() > 0)
{
try
{
db2.PTP_PipelineList.DeleteAllOnSubmit(delJoints);
db2.SubmitChanges();
}
catch (Exception)
{
string weldJointCodes = string.Empty;
foreach (var item in delJoints)
{
weldJointCodes += item.PipelineId + ",";
}
Alert.ShowInParent(weldJointCodes, MessageBoxIcon.Warning);
}
BLL.TestPackageEditService.AddPipelineLists(pipelineList_add);
}
//Model.SGGLDB db2 = Funs.DB;
//List<Model.PTP_PipelineList> delJoints = new List<Model.PTP_PipelineList>();
//var allWeldJoints2 = from x in db2.PTP_PipelineList
// join y in db2.PTP_TestPackage on x.PTP_ID equals y.PTP_ID
// where y.UnitWorkId == Request.Params["UnitWorkId"]
// select x;
//foreach (var pipelineCode in pipelineCodes)
//{
// var pipelineWeldJointCodes = weldJoints.Where(x => x.PTP_ID == pipelineCode).Select(x => x.PipelineId).ToList();
// var q = allWeldJoints2.Where(x => x.PTP_ID == pipelineCode && !pipelineWeldJointCodes.Contains(x.PipelineId)).ToList();
// delJoints.AddRange(q);
//}
//if (delJoints.Count() > 0)
//{
// try
// {
// db2.PTP_PipelineList.DeleteAllOnSubmit(delJoints);
// db2.SubmitChanges();
// }
// catch (Exception)
// {
// string weldJointCodes = string.Empty;
// foreach (var item in delJoints)
// {
// weldJointCodes += item.PipelineId + ",";
// }
// Alert.ShowInParent(weldJointCodes, MessageBoxIcon.Warning);
// }
//}
}
//public void AddView_HJGL_WeldJoint(List<Model.View_HJGL_WeldJoint> PipelineList)
//{
// string unitworkId = Request.Params["UnitWorkId"];
// var getPipeline = from x in Funs.DB.View_HJGL_WeldJoint where x.UnitWorkId== unitworkId select x;
// List<Model.HJGL_WeldJoint> weldJoints_add = new List<Model.HJGL_WeldJoint>();
// for (int i = 0; i < PipelineList.Count(); i++)
// {
// var pipeLineId = string.Empty;
// var WeldJointId = string.Empty;
// Model.HJGL_Pipeline pipeline = new Model.HJGL_Pipeline();
// pipeline.PipelineId = PipelineList[i].PipelineId;
// pipeline.ProjectId = this.CurrUser.LoginProjectId;
// pipeline.UnitId = PipelineList[i].UnitId;
// pipeline.UnitWorkId = PipelineList[i].UnitWorkId;
// pipeline.PipelineCode = PipelineList[i].PipelineCode;
// pipeline.SingleName = PipelineList[i].SingleName;
// pipeline.SingleNumber = PipelineList[i].SingleNumber;
// pipeline.MediumId = PipelineList[i].MediumId;
// pipeline.PipingClassId = PipelineList[i].PipingClassId;
// pipeline.DetectionRateId = PipelineList[i].DetectionRateId;
// pipeline.DetectionType = PipelineList[i].DetectionType;
// pipeline.DesignPress = PipelineList[i].DesignPress;
// pipeline.DesignTemperature = PipelineList[i].DesignTemperature;
// pipeline.TestMedium = PipelineList[i].TestMedium;
// pipeline.TestPressure = PipelineList[i].TestPressure;
// pipeline.PressurePipingClassId = PipelineList[i].PressurePipingClassId;
// pipeline.PipeLenth = PipelineList[i].PipeLenth;
// pipeline.LeakMedium = PipelineList[i].LeakMedium;
// pipeline.LeakPressure = PipelineList[i].LeakPressure;
// pipeline.VacuumPressure = PipelineList[i].VacuumPressure;
// pipeline.PCMedium = PipelineList[i].PCMedium;
// pipeline.MaterialId = PipelineList[i].MaterialId;
// pipeline.Remark = PipelineList[i].Remark;
// var isExistPipelineCode = getPipeline.FirstOrDefault(x => x.PipelineCode == pipeline.PipelineCode && x.UnitWorkId == Request.Params["UnitWorkId"]);
// if (isExistPipelineCode != null) // 更新管线
// {
// pipeLineId = isExistPipelineCode.PipelineId;
// pipeline.PipelineId = isExistPipelineCode.PipelineId;
// BLL.PipelineService.UpdatePipeline(pipeline);
// }
// else // 增加管线
// {
// pipeLineId = SQLHelper.GetNewID();
// pipeline.PipelineId = pipeLineId;
// BLL.PipelineService.AddPipeline(pipeline);
// }
// Model.HJGL_WeldJoint weldJoint = new Model.HJGL_WeldJoint();
// weldJoint.PipelineId = pipeLineId;
// weldJoint.WeldJointCode = PipelineList[i].WeldJointCode;
// weldJoint.PipelineCode = PipelineList[i].PipelineCode;
// weldJoint.Material1Id = PipelineList[i].Material1Id;
// weldJoint.Material2Id = PipelineList[i].Material2Id;
// weldJoint.Dia = PipelineList[i].Dia;
// weldJoint.Size = PipelineList[i].Size;
// weldJoint.Thickness = PipelineList[i].Thickness;
// weldJoint.Specification = PipelineList[i].Specification;
// weldJoint.WeldTypeId = PipelineList[i].WeldTypeId;
// weldJoint.DetectionTypeId = PipelineList[i].DetectionTypeId;
// weldJoint.JointAttribute = PipelineList[i].JointAttribute;
// weldJoint.ProjectId= PipelineList[i].ProjectId;
// var isExistJot = getPipeline.FirstOrDefault(x => x.PipelineId == pipeLineId && x.WeldJointCode == PipelineList[i].WeldJointCode);
// if (isExistJot != null) // 更新焊口
// {
// weldJoint.WeldJointId = isExistJot.WeldJointId;
// BLL.WeldJointService.UpdateWeldJoint(weldJoint);
// }
// else // 增加焊口
// {
// weldJoint.WeldJointId=SQLHelper.GetNewID();
// weldJoints_add.Add(weldJoint);
// //BLL.WeldJointService.AddWeldJoint(weldJoint);
// }
// }
// if (weldJoints_add.Count>0)
// {
// BLL.WeldJointService.AddBulkWeldJoint(weldJoints_add);
// }
//}
#endregion
/// <summary>