1810 lines
85 KiB
C#
1810 lines
85 KiB
C#
using System;
|
||
using System.Collections.Generic;
|
||
using System.Data;
|
||
using System.Data.OleDb;
|
||
using System.IO;
|
||
using System.Linq;
|
||
using System.Text;
|
||
using System.Web.UI;
|
||
using BLL;
|
||
using AspNet = System.Web.UI.WebControls;
|
||
using Model;
|
||
using NPOI.HSSF.Util;
|
||
using NPOI.SS.UserModel;
|
||
using NPOI.XSSF.UserModel;
|
||
|
||
namespace FineUIPro.Web.WeldingProcess.WeldingManage
|
||
{
|
||
public partial class WeldReportIn : PageBase
|
||
{
|
||
/// <summary>
|
||
/// 上传预设的虚拟路径
|
||
/// </summary>
|
||
private string initPath = Const.ExcelUrl;
|
||
|
||
public static List<WeldReportInItem> weldReportInItems = new List<WeldReportInItem>();
|
||
|
||
public static List<Model.SpWeldingDaily> dayList = new List<Model.SpWeldingDaily>();
|
||
|
||
/// <summary>
|
||
/// 错误集合
|
||
/// </summary>
|
||
public static string errorInfos = string.Empty;
|
||
/// <summary>
|
||
/// 错误集合
|
||
/// </summary>
|
||
public static string coodeNumError = string.Empty;
|
||
/// <summary>
|
||
/// 错误集合
|
||
/// </summary>
|
||
public static string eventArg = string.Empty;
|
||
|
||
|
||
protected void Page_Load(object sender, EventArgs e)
|
||
{
|
||
if (!IsPostBack)
|
||
{
|
||
this.hdFileName.Text = string.Empty;
|
||
this.hdCheckResult.Text = string.Empty;
|
||
errorInfos = string.Empty;
|
||
coodeNumError = string.Empty;
|
||
eventArg = string.Empty;
|
||
weldReportInItems.Clear();
|
||
dayList.Clear();
|
||
}
|
||
}
|
||
|
||
#region 审核
|
||
/// <summary>
|
||
/// 审核
|
||
/// </summary>
|
||
/// <param name="sender"></param>
|
||
/// <param name="e"></param>
|
||
protected void btnAudit_Click(object sender, EventArgs e)
|
||
{
|
||
errorInfos = string.Empty;
|
||
coodeNumError = string.Empty;
|
||
eventArg = string.Empty;
|
||
weldReportInItems.Clear();
|
||
dayList.Clear();
|
||
if (this.fuAttachUrl.HasFile == false)
|
||
{
|
||
ShowNotify("请选择Excel文件!", MessageBoxIcon.Warning);
|
||
return;
|
||
}
|
||
string IsXls = Path.GetExtension(this.fuAttachUrl.FileName).ToString().Trim().ToLower();
|
||
if (IsXls != ".xls" && IsXls != ".xlsx")
|
||
{
|
||
ShowNotify("只能选择Excel文件!", MessageBoxIcon.Warning);
|
||
return;
|
||
}
|
||
|
||
string rootPath = Server.MapPath("~/");
|
||
string initFullPath = rootPath + initPath;
|
||
if (!Directory.Exists(initFullPath))
|
||
{
|
||
Directory.CreateDirectory(initFullPath);
|
||
}
|
||
//指定上传文件名称
|
||
this.hdFileName.Text = BLL.Funs.GetNewFileName() + IsXls;
|
||
//上传文件路径
|
||
string filePath = initFullPath + this.hdFileName.Text;
|
||
//文件上传服务器
|
||
this.fuAttachUrl.PostedFile.SaveAs(filePath);
|
||
//文件上传服务器后的名称
|
||
string fileName = rootPath + initPath + this.hdFileName.Text;
|
||
//读取Excel
|
||
DataSet ds = NPOIHelper.ExcelToDataSet(fileName, out errorInfos, true);
|
||
//验证Excel读取是否有误
|
||
if (!string.IsNullOrEmpty(errorInfos))
|
||
{
|
||
ShowNotify(errorInfos, MessageBoxIcon.Warning);
|
||
return;
|
||
}
|
||
|
||
var project = BLL.Base_ProjectService.GetProjectByProjectId(this.CurrUser.LoginProjectId);
|
||
eventArg = string.Empty;
|
||
string installationId = string.Empty;
|
||
string workAreaId = string.Empty;
|
||
string unitId = string.Empty;
|
||
|
||
int totalNum = ds.Tables.Count;
|
||
if (totalNum > 0)
|
||
{
|
||
var DNCompareList = BLL.Base_DNCompareService.GetDNCompareList();
|
||
var materials = from x in Funs.DB.Base_Material select x; //材质
|
||
var weldingLocation = from x in Funs.DB.Base_WeldingLocation select x; //焊接位置
|
||
var weldTypes = from x in Funs.DB.Base_WeldType select x; //焊缝类型
|
||
var weldingMethods = from x in Funs.DB.Base_WeldingMethod select x;//焊接方法
|
||
var componentss = from x in Funs.DB.Base_Components select x;//安装组件
|
||
var consumabless = from x in Funs.DB.Base_Consumables select x;//焊接耗材(焊丝、焊条)
|
||
var wpsList = from x in Funs.DB.WPQ_WPQList select x;
|
||
var coodeList = from x in Funs.DB.Base_MaterialCoode where x.ProjectId == this.CurrUser.LoginProjectId select x; //coode
|
||
|
||
for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
|
||
{
|
||
|
||
Model.SpWeldingDaily d = new Model.SpWeldingDaily();
|
||
WeldReportInItem oneWebReportInItem = new WeldReportInItem();
|
||
oneWebReportInItem.RowID = (i + 1).ToString();
|
||
oneWebReportInItem.Remark = string.Empty;
|
||
#region 数据验证
|
||
|
||
string insId = string.Empty;
|
||
if (ds.Tables[0].Rows[i]["装置编号"] != null && !string.IsNullOrEmpty(ds.Tables[0].Rows[i]["装置编号"].ToString()))
|
||
{
|
||
oneWebReportInItem.InstallationCode = ds.Tables[0].Rows[i]["装置编号"].ToString();
|
||
var ins = from x in Funs.DB.Project_Installation
|
||
where x.ProjectId == this.CurrUser.LoginProjectId
|
||
&& x.InstallationCode == ds.Tables[0].Rows[i]["装置编号"].ToString()
|
||
select x;
|
||
|
||
if (ins.Count() > 0)
|
||
{
|
||
insId = ins.First().InstallationId;
|
||
d.InstallationId = insId;
|
||
}
|
||
else
|
||
{
|
||
errorInfos += (i + 2) + "行, 该项目装置编号不存在!</br>";
|
||
oneWebReportInItem.Remark += "该项目装置编号不存在" + "|";
|
||
}
|
||
}
|
||
else
|
||
{
|
||
errorInfos += (i + 2) + "行, 装置编号不能为空!</br>";
|
||
oneWebReportInItem.Remark += "装置编号不能为空" + "|";
|
||
}
|
||
|
||
string areaId = string.Empty;
|
||
if (ds.Tables[0].Rows[i]["区域编号"] != null && !string.IsNullOrEmpty(ds.Tables[0].Rows[i]["区域编号"].ToString()))
|
||
{
|
||
oneWebReportInItem.WorkAreaCode = ds.Tables[0].Rows[i]["区域编号"].ToString();
|
||
var area = from x in Funs.DB.Project_WorkArea
|
||
where x.ProjectId == this.CurrUser.LoginProjectId
|
||
&& x.WorkAreaCode == ds.Tables[0].Rows[i]["区域编号"].ToString()
|
||
select x;
|
||
|
||
if (area.Count() > 0)
|
||
{
|
||
areaId = area.First().WorkAreaId;
|
||
d.WorkAreaId = areaId;
|
||
}
|
||
else
|
||
{
|
||
errorInfos += (i + 2) + "行, 该项目区域编号不存在!</br>";
|
||
oneWebReportInItem.Remark += "该项目区域编号不存在" + "|";
|
||
}
|
||
}
|
||
else
|
||
{
|
||
errorInfos += (i + 2) + "行, 区域编号不能为空!</br>";
|
||
oneWebReportInItem.Remark += "区域编号不能为空" + "|";
|
||
}
|
||
|
||
|
||
if (ds.Tables[0].Rows[i]["单位代码"] != null && !string.IsNullOrEmpty(ds.Tables[0].Rows[i]["单位代码"].ToString()))
|
||
{
|
||
oneWebReportInItem.UnitCode = ds.Tables[0].Rows[i]["单位代码"].ToString();
|
||
var unit = from x in Funs.DB.Project_Unit
|
||
join y in Funs.DB.Base_Unit on x.UnitId equals y.UnitId
|
||
where x.ProjectId == this.CurrUser.LoginProjectId && x.UnitType.Contains(Const.UnitType_5)
|
||
&& y.UnitCode == ds.Tables[0].Rows[i]["单位代码"].ToString()
|
||
select x;
|
||
|
||
if (unit.Count() > 0)
|
||
{
|
||
d.UnitId = unit.First().UnitId;
|
||
}
|
||
else
|
||
{
|
||
errorInfos += (i + 2) + "行, 该项目单位代码不存在!</br>";
|
||
oneWebReportInItem.Remark += "该项目单位代码不存在" + "|";
|
||
}
|
||
}
|
||
else
|
||
{
|
||
errorInfos += (i + 2) + "行, 单位代码不能为空!</br>";
|
||
oneWebReportInItem.Remark += "单位代码不能为空" + "|";
|
||
}
|
||
|
||
string pipelineId = string.Empty;
|
||
if (ds.Tables[0].Rows[i]["管线号"] != null && !string.IsNullOrEmpty(ds.Tables[0].Rows[i]["管线号"].ToString()))
|
||
{
|
||
oneWebReportInItem.PipelineCode = ds.Tables[0].Rows[i]["管线号"].ToString();
|
||
var pipeline = from x in Funs.DB.Pipeline_Pipeline
|
||
where x.ProjectId == this.CurrUser.LoginProjectId && x.WorkAreaId == areaId
|
||
&& x.InstallationId == insId && x.WorkAreaId == areaId && x.PipelineCode == ds.Tables[0].Rows[i]["管线号"].ToString()
|
||
select x;
|
||
|
||
if (pipeline.Count() > 0)
|
||
{
|
||
|
||
pipelineId = pipeline.First().PipelineId;
|
||
d.PipelineId = pipelineId;
|
||
//pipelineIdList.Add(pipelineId);
|
||
}
|
||
else
|
||
{
|
||
errorInfos += (i + 2) + "行, 该项目管线编号不存在!</br>";
|
||
oneWebReportInItem.Remark += "该项目管线编号不存在" + "|";
|
||
}
|
||
}
|
||
else
|
||
{
|
||
errorInfos += (i + 2) + "行,管线号不能为空!</br>";
|
||
oneWebReportInItem.Remark += "管线号不能为空" + "|";
|
||
}
|
||
|
||
string jotId = string.Empty;
|
||
string ansi = string.Empty;
|
||
decimal? size = null;
|
||
decimal? dia = null;
|
||
decimal? sch = null;
|
||
|
||
if (ds.Tables[0].Rows[i]["焊口号"] != null && !string.IsNullOrEmpty(ds.Tables[0].Rows[i]["焊口号"].ToString()))
|
||
{
|
||
oneWebReportInItem.WeldJointCode = ds.Tables[0].Rows[i]["焊口号"].ToString();
|
||
var jot = from x in Funs.DB.Pipeline_WeldJoint
|
||
where x.ProjectId == this.CurrUser.LoginProjectId
|
||
&& x.PipelineId == pipelineId && x.WeldJointCode == ds.Tables[0].Rows[i]["焊口号"].ToString()
|
||
&& (x.WeldingDailyId == null || x.WeldingDailyId == "")
|
||
select x;
|
||
|
||
if (jot.Count() > 0)
|
||
{
|
||
jotId = jot.First().WeldJointId;
|
||
d.WeldJointId = jot.First().WeldJointId;
|
||
d.Size = jot.First().Size;
|
||
d.Dia = jot.First().Dia;
|
||
d.ANSISCH = jot.First().ANSISCH;
|
||
d.Thickness = jot.First().Thickness;
|
||
d.Specification = jot.First().Specification;
|
||
d.JointAttribute = jot.First().JointAttribute;
|
||
d.JointArea = jot.First().JointArea;
|
||
d.WeldTypeId = jot.First().WeldTypeId;
|
||
d.WeldingLocationId = jot.First().WeldingLocationId;
|
||
d.Material1Id = jot.First().Material1Id;
|
||
d.Material2Id = jot.First().Material2Id;
|
||
d.PipeAssembly1Id = jot.First().PipeAssembly1Id;
|
||
d.PipeAssembly2Id = jot.First().PipeAssembly2Id;
|
||
d.Coode1 = jot.First().Coode1;
|
||
d.Coode2 = jot.First().Coode2;
|
||
d.HeartNo1 = jot.First().HeartNo1;
|
||
d.HeartNo2 = jot.First().HeartNo2;
|
||
d.WeldSilkId = jot.First().WeldSilkId;
|
||
d.WeldMatId = jot.First().WeldMatId;
|
||
d.PipeSegment = jot.First().PipeSegment;
|
||
d.WPQId = jot.First().WPQId;
|
||
d.WeldingMethodId = jot.First().WeldingMethodId;
|
||
|
||
ansi = jot.First().ANSISCH;
|
||
size = jot.First().Size;
|
||
dia = jot.First().Dia;
|
||
sch = jot.First().Thickness;
|
||
}
|
||
else
|
||
{
|
||
errorInfos += (i + 2) + "行, 该项目管线的焊口号不存在或已焊接!</br>";
|
||
oneWebReportInItem.Remark += "该项目管线的焊口号不存在或已焊接" + "|";
|
||
}
|
||
}
|
||
else
|
||
{
|
||
errorInfos += (i + 2) + "行,焊口号不能为空!</br>";
|
||
oneWebReportInItem.Remark += "焊口号不能为空" + "|";
|
||
}
|
||
|
||
if (ds.Tables[0].Rows[i]["焊接日期"] != null && !string.IsNullOrEmpty(ds.Tables[0].Rows[i]["焊接日期"].ToString()))
|
||
{
|
||
oneWebReportInItem.WeldingDate = ds.Tables[0].Rows[i]["焊接日期"].ToString();
|
||
try
|
||
{
|
||
DateTime dd = Convert.ToDateTime(ds.Tables[0].Rows[i]["焊接日期"].ToString());
|
||
d.WeldingDate = dd.Date;
|
||
}
|
||
catch
|
||
{
|
||
errorInfos += (i + 2) + "行,焊接日期格式不正确!</br>";
|
||
oneWebReportInItem.Remark += "焊接日期格式不正确" + "|";
|
||
}
|
||
|
||
}
|
||
else
|
||
{
|
||
errorInfos += (i + 2) + "行,焊接日期不能为空!</br>";
|
||
oneWebReportInItem.Remark += "焊接日期不能为空" + "|";
|
||
}
|
||
|
||
bool isExistFloor = false;
|
||
string floorWelderId = string.Empty;
|
||
if (ds.Tables[0].Rows[i]["打底焊工号"] != null && !string.IsNullOrEmpty(ds.Tables[0].Rows[i]["打底焊工号"].ToString()))
|
||
{
|
||
oneWebReportInItem.B_WelderCode = ds.Tables[0].Rows[i]["打底焊工号"].ToString();
|
||
var floorWelder = from x in Funs.DB.Welder_ProjectWelder
|
||
join y in Funs.DB.Welder_Welder on x.WelderId equals y.WelderId
|
||
where x.ProjectId == this.CurrUser.LoginProjectId
|
||
&& y.WelderCode == ds.Tables[0].Rows[i]["打底焊工号"].ToString()
|
||
select x;
|
||
if (floorWelder.Count() > 0)
|
||
{
|
||
isExistFloor = true;
|
||
floorWelderId = floorWelder.First().WelderId;
|
||
d.BackingWelderId = floorWelder.First().WelderId;
|
||
}
|
||
else
|
||
{
|
||
errorInfos += (i + 2) + "行,该项目打底焊工号不存在!</br>";
|
||
oneWebReportInItem.Remark += "该项目打底焊工号不存在" + "|";
|
||
}
|
||
}
|
||
else
|
||
{
|
||
errorInfos += (i + 2) + "行,打底焊工号不能为空!</br>";
|
||
oneWebReportInItem.Remark += "打底焊工号不能为空" + "|";
|
||
}
|
||
|
||
bool isExistCell = false;
|
||
string cellWelderId = string.Empty;
|
||
bool? welderQueIsUse = false;
|
||
if (ds.Tables[0].Rows[i]["盖面焊工号"] != null && !string.IsNullOrEmpty(ds.Tables[0].Rows[i]["盖面焊工号"].ToString()))
|
||
{
|
||
oneWebReportInItem.T_WelderCode = ds.Tables[0].Rows[i]["盖面焊工号"].ToString();
|
||
var cellWelder = from x in Funs.DB.Welder_ProjectWelder
|
||
join y in Funs.DB.Welder_Welder on x.WelderId equals y.WelderId
|
||
where x.ProjectId == this.CurrUser.LoginProjectId
|
||
&& y.WelderCode == ds.Tables[0].Rows[i]["盖面焊工号"].ToString()
|
||
select x;
|
||
if (cellWelder.Count() > 0)
|
||
{
|
||
isExistCell = true;
|
||
cellWelderId = cellWelder.First().WelderId;
|
||
d.CoverWelderId = cellWelder.First().WelderId;
|
||
var projectUnit = BLL.Project_UnitService.GetProject_UnitByProjectIdUnitId(this.CurrUser.LoginProjectId, cellWelder.First().UnitId);
|
||
if (projectUnit != null)
|
||
{
|
||
welderQueIsUse = projectUnit.WelderQueIsUse;
|
||
}
|
||
}
|
||
else
|
||
{
|
||
errorInfos += (i + 2) + "行,该项目盖面焊工号不存在!</br>";
|
||
oneWebReportInItem.Remark += "该项目盖面焊工号不存在" + "|";
|
||
}
|
||
}
|
||
else
|
||
{
|
||
errorInfos += (i + 2) + "行,盖面焊工号不能为空!</br>";
|
||
oneWebReportInItem.Remark += "盖面焊工号不能为空" + "|";
|
||
}
|
||
|
||
|
||
if (ds.Tables[0].Rows[i]["焊缝类型"] != null && !string.IsNullOrEmpty(ds.Tables[0].Rows[i]["焊缝类型"].ToString()))
|
||
{
|
||
oneWebReportInItem.WeldTypeCode = ds.Tables[0].Rows[i]["焊缝类型"].ToString();
|
||
var weldType = weldTypes.FirstOrDefault(x => x.WeldTypeCode == ds.Tables[0].Rows[i]["焊缝类型"].ToString());
|
||
if (weldType == null)
|
||
{
|
||
errorInfos += "焊缝类型[" + ds.Tables[0].Rows[i]["焊缝类型"].ToString() + "]不存在;";
|
||
oneWebReportInItem.Remark += "焊缝类型[" + ds.Tables[0].Rows[i]["焊缝类型"].ToString() + "]不存在" + "|";
|
||
}
|
||
else
|
||
{
|
||
d.WeldTypeId = weldType.WeldTypeId;
|
||
}
|
||
}
|
||
|
||
if (ds.Tables[0].Rows[i]["焊口属性(活动S、固定G)"] != null && !string.IsNullOrEmpty(ds.Tables[0].Rows[i]["焊口属性(活动S、固定G)"].ToString()))
|
||
{
|
||
string att = ds.Tables[0].Rows[i]["焊口属性(活动S、固定G)"].ToString();
|
||
oneWebReportInItem.JointAttribute = att;
|
||
if (att != "S" && att != "G")
|
||
{
|
||
errorInfos += (i + 2) + "行,焊口属性(S或G)不正确!</br>";
|
||
oneWebReportInItem.Remark += "焊口属性(S或G)不正确" + "|";
|
||
}
|
||
else
|
||
{
|
||
d.JointAttribute = att;
|
||
if (att == "S")
|
||
{
|
||
d.JointArea = "S";
|
||
}
|
||
else
|
||
{
|
||
d.JointArea = "F";
|
||
}
|
||
}
|
||
}
|
||
|
||
if (ds.Tables[0].Rows[i]["焊接位置"] != null && !string.IsNullOrEmpty(ds.Tables[0].Rows[i]["焊接位置"].ToString()))
|
||
{
|
||
oneWebReportInItem.WeldingLocationCode = ds.Tables[0].Rows[i]["焊接位置"].ToString();
|
||
var loc = weldingLocation.FirstOrDefault(x => x.WeldingLocationCode == ds.Tables[0].Rows[i]["焊接位置"].ToString());
|
||
if (loc == null)
|
||
{
|
||
errorInfos += "焊接位置[" + ds.Tables[0].Rows[i]["焊接位置"].ToString() + "]不存在;";
|
||
oneWebReportInItem.Remark += "焊接位置[" + ds.Tables[0].Rows[i]["焊接位置"].ToString() + "]不存在" + "|";
|
||
}
|
||
else
|
||
{
|
||
d.WeldingLocationId = loc.WeldingLocationId;
|
||
}
|
||
}
|
||
|
||
if (ds.Tables[0].Rows[i]["管径"] != null && !string.IsNullOrEmpty(ds.Tables[0].Rows[i]["管径"].ToString()))
|
||
{
|
||
oneWebReportInItem.Size = ds.Tables[0].Rows[i]["管径"].ToString();
|
||
decimal? dd = Funs.GetNewDecimal(ds.Tables[0].Rows[i]["管径"].ToString());
|
||
if (dd != null)
|
||
{
|
||
d.Size = Funs.GetNewDecimal(ds.Tables[0].Rows[i]["管径"].ToString());
|
||
size = dd;
|
||
}
|
||
else
|
||
{
|
||
errorInfos += (i + 2) + "行,管径格式不正确!</br>";
|
||
oneWebReportInItem.Remark += "管径格式不正确" + "|";
|
||
}
|
||
|
||
}
|
||
|
||
|
||
if (ds.Tables[0].Rows[i]["美标壁厚"] != null && !string.IsNullOrEmpty(ds.Tables[0].Rows[i]["美标壁厚"].ToString()))
|
||
{
|
||
oneWebReportInItem.ANSISCH = ds.Tables[0].Rows[i]["美标壁厚"].ToString();
|
||
var q = from x in DNCompareList where x.Value == ds.Tables[0].Rows[i]["美标壁厚"].ToString() select x;
|
||
if (q.Count() > 0)
|
||
{
|
||
d.ANSISCH = ds.Tables[0].Rows[i]["美标壁厚"].ToString();
|
||
ansi = ds.Tables[0].Rows[i]["美标壁厚"].ToString();
|
||
|
||
var dn = from x in Funs.DB.Base_DNCompare where x.PipeSize == size select x;
|
||
|
||
if (dn.Count() > 0)
|
||
{
|
||
if (dn.First().OutSizeDia != null)
|
||
{
|
||
dia = dn.First().OutSizeDia;
|
||
d.Dia = dia;
|
||
}
|
||
|
||
if (ansi == "5")
|
||
{
|
||
if (dn.First().SCH5 != null)
|
||
{
|
||
sch = dn.First().SCH5;
|
||
}
|
||
}
|
||
if (ansi == "5S")
|
||
{
|
||
if (dn.First().SCH5S != null)
|
||
{
|
||
sch = dn.First().SCH5S;
|
||
}
|
||
}
|
||
if (ansi == "10")
|
||
{
|
||
if (dn.First().SCH10 != null)
|
||
{
|
||
sch = dn.First().SCH10;
|
||
}
|
||
}
|
||
if (ansi == "10S")
|
||
{
|
||
if (dn.First().SCH10S != null)
|
||
{
|
||
sch = dn.First().SCH10S;
|
||
}
|
||
}
|
||
if (ansi == "20")
|
||
{
|
||
if (dn.First().SCH20 != null)
|
||
{
|
||
sch = dn.First().SCH20;
|
||
}
|
||
}
|
||
if (ansi == "30")
|
||
{
|
||
if (dn.First().SCH30 != null)
|
||
{
|
||
sch = dn.First().SCH30;
|
||
}
|
||
}
|
||
if (ansi == "40")
|
||
{
|
||
if (dn.First().SCH40 != null)
|
||
{
|
||
sch = dn.First().SCH40;
|
||
}
|
||
}
|
||
if (ansi == "40S")
|
||
{
|
||
if (dn.First().SCH40S != null)
|
||
{
|
||
sch = dn.First().SCH40S;
|
||
}
|
||
}
|
||
if (ansi == "STD")
|
||
{
|
||
if (dn.First().STD != null)
|
||
{
|
||
sch = dn.First().STD;
|
||
}
|
||
}
|
||
if (ansi == "60")
|
||
{
|
||
if (dn.First().SCH60 != null)
|
||
{
|
||
sch = dn.First().SCH60;
|
||
}
|
||
}
|
||
if (ansi == "80")
|
||
{
|
||
if (dn.First().SCH80 != null)
|
||
{
|
||
sch = dn.First().SCH80;
|
||
}
|
||
}
|
||
if (ansi == "80S")
|
||
{
|
||
if (dn.First().SCH80S != null)
|
||
{
|
||
sch = dn.First().SCH80S;
|
||
}
|
||
}
|
||
if (ansi == "XS")
|
||
{
|
||
if (dn.First().XS != null)
|
||
{
|
||
sch = dn.First().XS;
|
||
}
|
||
}
|
||
if (ansi == "100")
|
||
{
|
||
if (dn.First().SCH100 != null)
|
||
{
|
||
sch = dn.First().SCH100;
|
||
}
|
||
}
|
||
if (ansi == "120")
|
||
{
|
||
if (dn.First().SCH120 != null)
|
||
{
|
||
sch = dn.First().SCH120;
|
||
}
|
||
}
|
||
if (ansi == "140")
|
||
{
|
||
if (dn.First().SCH140 != null)
|
||
{
|
||
sch = dn.First().SCH140;
|
||
}
|
||
}
|
||
if (ansi == "160")
|
||
{
|
||
if (dn.First().SCH160 != null)
|
||
{
|
||
sch = dn.First().SCH160;
|
||
}
|
||
}
|
||
if (ansi == "XXS")
|
||
{
|
||
if (dn.First().XXS != null)
|
||
{
|
||
sch = dn.First().XXS;
|
||
}
|
||
}
|
||
|
||
d.Thickness = sch;
|
||
}
|
||
}
|
||
else
|
||
{
|
||
errorInfos += "美标壁厚[" + ds.Tables[0].Rows[i]["美标壁厚"].ToString() + "]错误;";
|
||
oneWebReportInItem.Remark += "美标壁厚[" + ds.Tables[0].Rows[i]["美标壁厚"].ToString() + "]错误" + "|";
|
||
}
|
||
}
|
||
|
||
if (dia != null && sch != null)
|
||
{
|
||
d.Specification = "Φ" + Funs.GetClearZero(dia.Value) + "×" + Funs.GetClearZero(sch.Value);
|
||
}
|
||
|
||
if (ds.Tables[0].Rows[i]["焊接方法"] != null && !string.IsNullOrEmpty(ds.Tables[0].Rows[i]["焊接方法"].ToString()))
|
||
{
|
||
oneWebReportInItem.WeldingMethodCode = ds.Tables[0].Rows[i]["焊接方法"].ToString();
|
||
var weldMethod = weldingMethods.FirstOrDefault(x => x.WeldingMethodCode == ds.Tables[0].Rows[i]["焊接方法"].ToString());
|
||
if (weldMethod == null)
|
||
{
|
||
errorInfos += "焊接方法[" + ds.Tables[0].Rows[i]["焊接方法"].ToString() + "]不存在;";
|
||
oneWebReportInItem.Remark += "焊接方法[" + ds.Tables[0].Rows[i]["焊接方法"].ToString() + "]不存在" + "|";
|
||
}
|
||
else
|
||
{
|
||
d.WeldingMethodId = weldMethod.WeldingMethodId;
|
||
}
|
||
}
|
||
|
||
if (ds.Tables[0].Rows[i]["材质1"] != null && !string.IsNullOrEmpty(ds.Tables[0].Rows[i]["材质1"].ToString()))
|
||
{
|
||
oneWebReportInItem.MaterialCode1 = ds.Tables[0].Rows[i]["材质1"].ToString();
|
||
var steel = materials.FirstOrDefault(x => x.MaterialCode == ds.Tables[0].Rows[i]["材质1"].ToString());
|
||
if (steel == null)
|
||
{
|
||
errorInfos += "材质1[" + ds.Tables[0].Rows[i]["材质1"].ToString() + "]不存在;";
|
||
oneWebReportInItem.Remark += "材质1[" + ds.Tables[0].Rows[i]["材质1"].ToString() + "]不存在" + "|";
|
||
}
|
||
else
|
||
{
|
||
d.Material1Id = steel.MaterialId;
|
||
}
|
||
}
|
||
|
||
if (ds.Tables[0].Rows[i]["材质2"] != null && !string.IsNullOrEmpty(ds.Tables[0].Rows[i]["材质2"].ToString()))
|
||
{
|
||
oneWebReportInItem.MaterialCode2 = ds.Tables[0].Rows[i]["材质2"].ToString();
|
||
var steel = materials.FirstOrDefault(x => x.MaterialCode == ds.Tables[0].Rows[i]["材质2"].ToString());
|
||
if (steel == null)
|
||
{
|
||
errorInfos += "材质2[" + ds.Tables[0].Rows[i]["材质2"].ToString() + "]不存在;";
|
||
oneWebReportInItem.Remark += "材质2[" + ds.Tables[0].Rows[i]["材质2"].ToString() + "]不存在" + "|";
|
||
}
|
||
else
|
||
{
|
||
d.Material2Id = steel.MaterialId;
|
||
}
|
||
}
|
||
|
||
if (ds.Tables[0].Rows[i]["组件1"] != null && !string.IsNullOrEmpty(ds.Tables[0].Rows[i]["组件1"].ToString()))
|
||
{
|
||
oneWebReportInItem.ComponentsCode1 = ds.Tables[0].Rows[i]["组件1"].ToString();
|
||
var com = componentss.FirstOrDefault(x => x.ComponentsCode == ds.Tables[0].Rows[i]["组件1"].ToString());
|
||
if (com == null)
|
||
{
|
||
errorInfos += "组件1号[" + ds.Tables[0].Rows[i]["组件1"].ToString() + "]不存在;";
|
||
oneWebReportInItem.Remark += "组件1号[" + ds.Tables[0].Rows[i]["组件1"].ToString() + "]不存在" + "|";
|
||
}
|
||
else
|
||
{
|
||
d.PipeAssembly1Id = com.ComponentsId;
|
||
}
|
||
}
|
||
if (ds.Tables[0].Rows[i]["组件2"] != null && !string.IsNullOrEmpty(ds.Tables[0].Rows[i]["组件2"].ToString()))
|
||
{
|
||
oneWebReportInItem.ComponentsCode2 = ds.Tables[0].Rows[i]["组件2"].ToString();
|
||
var com = componentss.FirstOrDefault(x => x.ComponentsCode == ds.Tables[0].Rows[i]["组件2"].ToString());
|
||
if (com == null)
|
||
{
|
||
errorInfos += "组件2号[" + ds.Tables[0].Rows[i]["组件2"].ToString() + "]不存在;";
|
||
oneWebReportInItem.Remark += "组件2号[" + ds.Tables[0].Rows[i]["组件2"].ToString() + "]不存在" + "|";
|
||
}
|
||
else
|
||
{
|
||
d.PipeAssembly2Id = com.ComponentsId;
|
||
}
|
||
}
|
||
if (ds.Tables[0].Rows[i]["Coode1"] != null && !string.IsNullOrEmpty(ds.Tables[0].Rows[i]["Coode1"].ToString()))
|
||
{
|
||
oneWebReportInItem.Coode1 = ds.Tables[0].Rows[i]["Coode1"].ToString();
|
||
d.Coode1 = ds.Tables[0].Rows[i]["Coode1"].ToString();
|
||
}
|
||
|
||
|
||
if (ds.Tables[0].Rows[i]["Coode2"] != null && !string.IsNullOrEmpty(ds.Tables[0].Rows[i]["Coode2"].ToString()))
|
||
{
|
||
oneWebReportInItem.Coode2 = ds.Tables[0].Rows[i]["Coode2"].ToString();
|
||
d.Coode2 = ds.Tables[0].Rows[i]["Coode2"].ToString();
|
||
}
|
||
|
||
if (ds.Tables[0].Rows[i]["炉批号1"] != null && !string.IsNullOrEmpty(ds.Tables[0].Rows[i]["炉批号1"].ToString()))
|
||
{
|
||
oneWebReportInItem.cood1 = ds.Tables[0].Rows[i]["炉批号1"].ToString();
|
||
var cood = coodeList.FirstOrDefault(x => x.IsUse == true && x.Coode == d.Coode1 && x.HeartNo == ds.Tables[0].Rows[i]["炉批号1"].ToString());
|
||
if (cood == null)
|
||
{
|
||
errorInfos += "炉批号1:[" + ds.Tables[0].Rows[i]["炉批号1"].ToString() + "]或对应的Coode1:" + d.Coode1 + "不存在;";
|
||
oneWebReportInItem.Remark += "炉批号1:[" + ds.Tables[0].Rows[i]["炉批号1"].ToString() + "]或对应的Coode1:" + d.Coode1 + "不存在" + "|";
|
||
}
|
||
else
|
||
{
|
||
d.HeartNo1 = ds.Tables[0].Rows[i]["炉批号1"].ToString();
|
||
}
|
||
}
|
||
|
||
if (ds.Tables[0].Rows[i]["炉批号2"] != null && !string.IsNullOrEmpty(ds.Tables[0].Rows[i]["炉批号2"].ToString()))
|
||
{
|
||
oneWebReportInItem.cood2 = ds.Tables[0].Rows[i]["炉批号2"].ToString();
|
||
var cood = coodeList.FirstOrDefault(x => x.IsUse == true && x.Coode == d.Coode2 && x.HeartNo == ds.Tables[0].Rows[i]["炉批号2"].ToString());
|
||
if (cood == null)
|
||
{
|
||
errorInfos += "炉批号2:[" + ds.Tables[0].Rows[i]["炉批号2"].ToString() + "]或对应的Coode2:" + d.Coode2 + "不存在;";
|
||
oneWebReportInItem.Remark += "炉批号2:[" + ds.Tables[0].Rows[i]["炉批号2"].ToString() + "]或对应的Coode2:" + d.Coode2 + "不存在" + "|";
|
||
}
|
||
else
|
||
{
|
||
d.HeartNo2 = ds.Tables[0].Rows[i]["炉批号2"].ToString();
|
||
}
|
||
}
|
||
|
||
if (ds.Tables[0].Rows[i]["焊丝"] != null && !string.IsNullOrEmpty(ds.Tables[0].Rows[i]["焊丝"].ToString()))
|
||
{
|
||
oneWebReportInItem.S_ConsumablesCode = ds.Tables[0].Rows[i]["焊丝"].ToString();
|
||
// 焊丝如多个用“,”隔开
|
||
string[] silkList = ds.Tables[0].Rows[i]["焊丝"].ToString().Trim().Split(',');
|
||
string silkIds = string.Empty;
|
||
if (silkList.Count() > 0)
|
||
{
|
||
foreach (string silk in silkList)
|
||
{
|
||
if (!string.IsNullOrEmpty(silk))
|
||
{
|
||
var weldSilk = consumabless.FirstOrDefault(x => x.ConsumablesCode == silk && x.ConsumablesType == "1");
|
||
if (weldSilk == null)
|
||
{
|
||
errorInfos += "焊丝[" + silk + "]不存在;";
|
||
oneWebReportInItem.Remark += "焊丝[" + silk + "]不存在" + "|";
|
||
}
|
||
else
|
||
{
|
||
silkIds = silkIds + weldSilk.ConsumablesId + ",";
|
||
}
|
||
}
|
||
}
|
||
if (silkIds != string.Empty)
|
||
{
|
||
d.WeldSilkId = silkIds.Substring(0, silkIds.Length - 1);
|
||
}
|
||
}
|
||
else
|
||
{
|
||
errorInfos += "焊丝[" + ds.Tables[0].Rows[i]["焊丝"].ToString() + "]不正确,多个焊丝用,隔开;";
|
||
oneWebReportInItem.Remark += "焊丝[" + ds.Tables[0].Rows[i]["焊丝"].ToString() + "]不正确,多个焊丝用,隔开" + "|";
|
||
}
|
||
}
|
||
if (ds.Tables[0].Rows[i]["焊条"] != null && !string.IsNullOrEmpty(ds.Tables[0].Rows[i]["焊条"].ToString()))
|
||
{
|
||
oneWebReportInItem.T_ConsumablesCode = ds.Tables[0].Rows[i]["焊条"].ToString();
|
||
var weldMat = consumabless.FirstOrDefault(x => x.ConsumablesCode == ds.Tables[0].Rows[i]["焊条"].ToString() && x.ConsumablesType == "2");
|
||
if (weldMat == null)
|
||
{
|
||
errorInfos += "焊条[" + ds.Tables[0].Rows[i]["焊条"].ToString() + "]不存在;";
|
||
oneWebReportInItem.Remark += "焊条[" + ds.Tables[0].Rows[i]["焊条"].ToString() + "]不存在" + "|";
|
||
}
|
||
else
|
||
{
|
||
d.WeldMatId = weldMat.ConsumablesId;
|
||
}
|
||
}
|
||
|
||
if (ds.Tables[0].Rows[i]["所属管段"] != null && !string.IsNullOrEmpty(ds.Tables[0].Rows[i]["所属管段"].ToString()))
|
||
{
|
||
oneWebReportInItem.PipeSegment = ds.Tables[0].Rows[i]["所属管段"].ToString();
|
||
d.PipeSegment = ds.Tables[0].Rows[i]["所属管段"].ToString();
|
||
}
|
||
|
||
if (ds.Tables[0].Rows[i]["WPS编号"] != null && !string.IsNullOrEmpty(ds.Tables[0].Rows[i]["WPS编号"].ToString()))
|
||
{
|
||
oneWebReportInItem.WPSCode = ds.Tables[0].Rows[i]["WPS编号"].ToString();
|
||
var wps = wpsList.FirstOrDefault(x => x.WPQCode == ds.Tables[0].Rows[i]["WPS编号"].ToString());
|
||
if (wps == null)
|
||
{
|
||
errorInfos += "WPS编号[" + ds.Tables[0].Rows[i]["WPS编号"].ToString() + "]不存在;";
|
||
oneWebReportInItem.Remark += "WPS编号[" + ds.Tables[0].Rows[i]["WPS编号"].ToString() + "]不存在" + "|";
|
||
}
|
||
else
|
||
{
|
||
d.WPQId = wps.WPQId;
|
||
//d.WeldingMethodId = wps.WeldingMethodId;
|
||
}
|
||
}
|
||
|
||
#endregion
|
||
|
||
|
||
|
||
#region 判断WPS资质 暂不用
|
||
//if (!string.IsNullOrEmpty(errorInfos))
|
||
//{
|
||
// ShowNotify(errorInfos, MessageBoxIcon.Warning, 10000);
|
||
// return;
|
||
//}
|
||
//else
|
||
//{
|
||
// // 判断WPS资质 暂不用
|
||
// if (welderQueIsUse == true)
|
||
// {
|
||
// if (isExistFloor && isExistCell)
|
||
// {
|
||
// //bool canSave = false;
|
||
// var jot = BLL.Pipeline_WeldJointService.GetWeldJointByWeldJointId(jotId);
|
||
// var wps = BLL.WPQListServiceService.GetWPQById(jot.WPQId);
|
||
// if (wps != null)
|
||
// {
|
||
// if (wps.WelderIds.Contains(cellWelderId) && wps.WelderIds.Contains(floorWelderId))
|
||
// {
|
||
|
||
// }
|
||
// else
|
||
// {
|
||
// eventArg = eventArg + jot.WeldJointCode + ",";
|
||
// }
|
||
// }
|
||
// }
|
||
// }
|
||
//}
|
||
#endregion
|
||
|
||
#region 焊工合格项目资质判断
|
||
// 判断资质
|
||
if (welderQueIsUse == true)
|
||
{
|
||
if (!string.IsNullOrEmpty(jotId) && isExistFloor && isExistCell)
|
||
{
|
||
bool canSave = false;
|
||
var jot = BLL.Pipeline_WeldJointService.GetWeldJointByWeldJointId(jotId);
|
||
var joty = BLL.Base_WeldTypeService.GetWeldTypeByWeldTypeId(jot.WeldTypeId);
|
||
string weldTypeGroup = joty.Flag;
|
||
string weldTypeCode = joty.WeldTypeCode;
|
||
string floorWelder = floorWelderId;
|
||
string cellWelder = cellWelderId;
|
||
//decimal? dia = jot.Dia;
|
||
//decimal? sch = jot.Thickness;
|
||
|
||
string weldingMethodCode = string.Empty;
|
||
var wm = BLL.Base_WeldingMethodService.GetWeldingMethodByWeldingMethodId(d.WeldingMethodId);
|
||
if (wm != null)
|
||
{
|
||
weldingMethodCode = wm.WeldingMethodCode;
|
||
}
|
||
string[] wmeCodes = weldingMethodCode.Split('+');
|
||
|
||
string location = string.Empty;
|
||
var loc = BLL.Base_WeldingLocationServie.GetWeldingLocationById(d.WeldingLocationId);
|
||
if (loc != null)
|
||
{
|
||
location = loc.WeldingLocationCode;
|
||
}
|
||
|
||
string ste = jot.Material1Id;
|
||
|
||
List<Model.Welder_WelderQualify> floorWelderQualifys = (from x in Funs.DB.Welder_WelderQualify
|
||
where x.WelderId == floorWelder && x.WeldingMethodId != null
|
||
&& x.WeldingLocationId != null && x.MaterialType != null
|
||
&& x.WeldType != null
|
||
&& x.ThicknessMax != null && x.SizesMin != null
|
||
select x).ToList();
|
||
|
||
List<Model.Welder_WelderQualify> cellWelderQualifys = (from x in Funs.DB.Welder_WelderQualify
|
||
where x.WelderId == cellWelder && x.WeldingMethodId != null
|
||
&& x.WeldingLocationId != null && x.MaterialType != null
|
||
&& x.WeldType != null
|
||
&& x.ThicknessMax != null && x.SizesMin != null
|
||
select x).ToList();
|
||
|
||
// 打底和盖面同一焊工
|
||
if (floorWelder == cellWelder)
|
||
{
|
||
if (floorWelderQualifys != null && floorWelderQualifys.Count() > 0)
|
||
{
|
||
if (wmeCodes.Count() <= 1) // 一种焊接方法
|
||
{
|
||
canSave = IsOK(floorWelderQualifys, wmeCodes[0], location, weldTypeGroup, ste, dia, sch);
|
||
}
|
||
else // 大于一种焊接方法,如氩电联焊
|
||
{
|
||
canSave = TwoWmeIsOK(floorWelderQualifys, cellWelderQualifys, wmeCodes[0], wmeCodes[1], location, weldTypeGroup, ste, dia, sch);
|
||
}
|
||
}
|
||
}
|
||
// 打底和盖面焊工不同
|
||
else
|
||
{
|
||
bool isok1 = false;
|
||
bool isok2 = false;
|
||
|
||
if (wmeCodes.Count() <= 1) // 一种焊接方法
|
||
{
|
||
if (floorWelderQualifys != null && floorWelderQualifys.Count() > 0)
|
||
{
|
||
isok1 = IsOK(floorWelderQualifys, wmeCodes[0], location, weldTypeGroup, ste, dia, sch);
|
||
}
|
||
if (cellWelderQualifys != null && cellWelderQualifys.Count() > 0)
|
||
{
|
||
isok2 = IsOK(cellWelderQualifys, wmeCodes[0], location, weldTypeGroup, ste, dia, sch);
|
||
}
|
||
if (isok1 && isok2)
|
||
{
|
||
canSave = true;
|
||
}
|
||
}
|
||
else
|
||
{
|
||
canSave = TwoWmeIsOK(floorWelderQualifys, cellWelderQualifys, wmeCodes[0], wmeCodes[1], location, weldTypeGroup, ste, dia, sch);
|
||
}
|
||
}
|
||
|
||
if (canSave == false)
|
||
{
|
||
eventArg = eventArg + jot.WeldJointCode + ",";
|
||
oneWebReportInItem.Remark += Resources.Lan.NoQualification + "【" + jot.WeldJointCode + "】" + Resources.Lan.WeldingConditions + "|";
|
||
}
|
||
}
|
||
}
|
||
#endregion
|
||
dayList.Add(d);
|
||
oneWebReportInItem.CreatedTime = DateTime.Now.ToString("yyyy年MM月dd日 HH时mm分ss秒");
|
||
weldReportInItems.Add(oneWebReportInItem);
|
||
}
|
||
|
||
if (weldReportInItems.Count <= 0)
|
||
{
|
||
ShowAlert("没有数据!", MessageBoxIcon.Warning);
|
||
return;
|
||
}
|
||
|
||
// 判断Coode数量
|
||
coodeNumError = string.Empty;
|
||
var coode1Group = dayList.GroupBy(x => new { x.Coode1, x.HeartNo1 }).Select(g => new { Coode = g.Key.Coode1, HeartNo = g.Key.HeartNo1 });
|
||
var coode2Group = dayList.GroupBy(x => new { x.Coode2, x.HeartNo2 }).Select(g => new { Coode = g.Key.Coode2, HeartNo = g.Key.HeartNo2 });
|
||
var coodeListGroup = coode1Group.Union(coode2Group).Distinct();
|
||
string[] jotList = dayList.Select(x => x.WeldJointId).ToArray();
|
||
foreach (var c in coodeListGroup)
|
||
{
|
||
var coodeNum = from x in Funs.DB.Base_MaterialCoode
|
||
where x.ProjectId == this.CurrUser.LoginProjectId
|
||
&& x.Coode == c.Coode && x.HeartNo == c.HeartNo
|
||
select x;
|
||
int daily1 = (from x in dayList where x.Coode1 == c.Coode && x.HeartNo1 == c.HeartNo select x).Count();
|
||
int daily2 = (from x in dayList where x.Coode2 == c.Coode && x.HeartNo2 == c.HeartNo select x).Count();
|
||
int jotCoode1 = (from x in Funs.DB.Pipeline_WeldJoint
|
||
where x.ProjectId == this.CurrUser.LoginProjectId
|
||
&& x.Coode1 == c.Coode && x.HeartNo1 == c.HeartNo
|
||
&& !jotList.Contains(x.WeldJointId)
|
||
select x).Count();
|
||
int jotCoode2 = (from x in Funs.DB.Pipeline_WeldJoint
|
||
where x.ProjectId == this.CurrUser.LoginProjectId
|
||
&& x.Coode2 == c.Coode && x.HeartNo2 == c.HeartNo
|
||
&& !jotList.Contains(x.WeldJointId)
|
||
select x).Count();
|
||
if (coodeNum.Count() > 0 && coodeNum.First().Amount != null)
|
||
{
|
||
if (daily1 + daily2 + jotCoode1 + jotCoode2 > coodeNum.First().Amount.Value)
|
||
{
|
||
coodeNumError += "Coode:" + c.Coode + "对应的炉批号:" + c.HeartNo + "的数量已超出,";
|
||
|
||
string merrRemark = "Coode:" + c.Coode + "对应的炉批号:" + c.HeartNo + "的数量已超出" + "|";
|
||
var errweldReportInItems = weldReportInItems.FindAll(p => (p.Coode1 == c.Coode || p.Coode2 == c.Coode) && !p.Remark.Contains(merrRemark));
|
||
errweldReportInItems.ForEach(p => p.Remark += merrRemark);
|
||
}
|
||
}
|
||
}
|
||
BindGrid();
|
||
}
|
||
else
|
||
{
|
||
ShowAlert("没有数据!", MessageBoxIcon.Warning);
|
||
return;
|
||
}
|
||
|
||
|
||
}
|
||
private void BindGrid()
|
||
{
|
||
this.Grid1.Hidden = false;
|
||
this.Grid1.DataSource = weldReportInItems;
|
||
this.Grid1.DataBind();
|
||
}
|
||
|
||
#endregion
|
||
|
||
#region 导入
|
||
/// <summary>
|
||
/// 导入
|
||
/// </summary>
|
||
/// <param name="sender"></param>
|
||
/// <param name="e"></param>
|
||
protected void btnImport_Click(object sender, EventArgs e)
|
||
{
|
||
if (string.IsNullOrEmpty(this.hdFileName.Text))
|
||
{
|
||
ShowNotify("请先审核要导入的文件!", MessageBoxIcon.Warning);
|
||
return;
|
||
}
|
||
// 数据验证错误,返回
|
||
if (!string.IsNullOrEmpty(errorInfos) || !string.IsNullOrEmpty(coodeNumError) || !string.IsNullOrEmpty(eventArg))
|
||
{
|
||
ShowNotify("请修正错误数据后再导入!", MessageBoxIcon.Warning);
|
||
return;
|
||
}
|
||
if (dayList.Count <= 0)
|
||
{
|
||
ShowNotify("无记录!", MessageBoxIcon.Warning);
|
||
return;
|
||
}
|
||
var groupList = dayList.GroupBy(x => new { x.InstallationId, x.WorkAreaId, x.UnitId, x.WeldingDate })
|
||
.Select(g => new { InstallationId = g.Key.InstallationId, WorkAreaId = g.Key.WorkAreaId, UnitId = g.Key.UnitId, WeldingDate = g.Key.WeldingDate });
|
||
foreach (var group in groupList)
|
||
{
|
||
// 主表
|
||
Model.Pipeline_WeldingDaily newWeldingDaily = new Model.Pipeline_WeldingDaily();
|
||
string perfix = string.Format("{0:yyyyMMdd}", group.WeldingDate) + "-";
|
||
string weldingDailyCode = BLL.SQLHelper.RunProcNewId("SpGetThreeNumber", "dbo.Pipeline_WeldingDaily", "WeldingDailyCode", this.CurrUser.LoginProjectId, perfix);
|
||
newWeldingDaily.WeldingDailyCode = weldingDailyCode;
|
||
newWeldingDaily.ProjectId = this.CurrUser.LoginProjectId;
|
||
newWeldingDaily.InstallationId = group.InstallationId;
|
||
newWeldingDaily.UnitId = group.UnitId;
|
||
newWeldingDaily.WeldingDate = Convert.ToDateTime(group.WeldingDate).Date;
|
||
|
||
newWeldingDaily.Tabler = this.CurrUser.UserId;
|
||
newWeldingDaily.TableDate = DateTime.Now;
|
||
|
||
newWeldingDaily.WeldingDailyId = SQLHelper.GetNewID(typeof(Model.Pipeline_WeldingDaily));
|
||
BLL.Pipeline_WeldingDailyService.AddPipeline_WeldingDaily(newWeldingDaily);
|
||
|
||
var dailyReportGroup = dayList.Where(x => x.InstallationId == group.InstallationId && x.WorkAreaId == group.WorkAreaId && x.UnitId == group.UnitId && x.WeldingDate == Convert.ToDateTime(group.WeldingDate).Date);
|
||
foreach (var item in dailyReportGroup)
|
||
{
|
||
var newWeldJoint = BLL.Pipeline_WeldJointService.GetWeldJointByWeldJointId(item.WeldJointId);
|
||
//var pipeline = BLL.Pipeline_PipelineService.GetPipelineByPipelineId(newWeldJoint.PipelineId);
|
||
|
||
newWeldJoint.WeldingDailyId = newWeldingDaily.WeldingDailyId;
|
||
newWeldJoint.WeldingDailyCode = weldingDailyCode;
|
||
newWeldJoint.CoverWelderId = item.CoverWelderId;
|
||
newWeldJoint.BackingWelderId = item.BackingWelderId;
|
||
newWeldJoint.WeldingDate = newWeldingDaily.WeldingDate;
|
||
newWeldJoint.WeldTypeId = item.WeldTypeId;
|
||
newWeldJoint.JointAttribute = item.JointAttribute;
|
||
newWeldJoint.WeldingLocationId = item.WeldingLocationId;
|
||
|
||
newWeldJoint.Size = item.Size;
|
||
newWeldJoint.ANSISCH = item.ANSISCH;
|
||
newWeldJoint.Dia = item.Dia;
|
||
newWeldJoint.Thickness = item.Thickness;
|
||
newWeldJoint.DoneDin = item.Size;
|
||
newWeldJoint.Specification = item.Specification;
|
||
newWeldJoint.WeldingMethodId = item.WeldingMethodId;
|
||
newWeldJoint.Material1Id = item.Material1Id;
|
||
newWeldJoint.Material2Id = item.Material2Id;
|
||
newWeldJoint.PipeAssembly1Id = item.PipeAssembly1Id;
|
||
newWeldJoint.PipeAssembly2Id = item.PipeAssembly2Id;
|
||
newWeldJoint.HeartNo1 = item.HeartNo1;
|
||
newWeldJoint.HeartNo2 = item.HeartNo2;
|
||
newWeldJoint.WeldSilkId = item.WeldSilkId;
|
||
newWeldJoint.WeldMatId = item.WeldMatId;
|
||
newWeldJoint.PipeSegment = item.PipeSegment;
|
||
newWeldJoint.WPQId = item.WPQId;
|
||
|
||
BLL.Pipeline_WeldJointService.UpdateWeldJoint(newWeldJoint);
|
||
|
||
//更新焊口号 修改固定焊口号后 +G
|
||
//BLL.Pipeline_WeldJointService.UpdateWeldJointAddG(newWeldJoint.WeldJointId, newWeldJoint.JointAttribute, Const.BtnAdd);
|
||
BLL.Batch_PointBatchItemService.InsertPointBatch(this.CurrUser.LoginProjectId, item.UnitId, item.InstallationId, item.BackingWelderId, item.CoverWelderId, item.WeldJointId, newWeldingDaily.WeldingDate);
|
||
}
|
||
|
||
BLL.Sys_LogService.AddLog(BLL.Const.System_3, this.CurrUser.LoginProjectId, this.CurrUser.UserId, Const.HJGL_WeldReportMenuId, Const.BtnAdd, newWeldingDaily.WeldingDailyId);
|
||
}
|
||
|
||
errorInfos = string.Empty;
|
||
coodeNumError = string.Empty;
|
||
eventArg = string.Empty;
|
||
weldReportInItems.Clear();
|
||
dayList.Clear();
|
||
ShowNotify("日报导入成功!", MessageBoxIcon.Success);
|
||
}
|
||
|
||
#endregion
|
||
|
||
#region 导出错误提示
|
||
/// <summary>
|
||
/// 导出错误提示
|
||
/// </summary>
|
||
/// <param name="sender"></param>
|
||
/// <param name="e"></param>
|
||
|
||
protected void btnOut_Click(object sender, EventArgs e)
|
||
{
|
||
if (weldReportInItems.Count <= 0)
|
||
{
|
||
ShowAlert("没有数据!", MessageBoxIcon.Warning);
|
||
return;
|
||
}
|
||
string rootPath = Server.MapPath("~/") + Const.ExcelUrl;
|
||
//模板文件
|
||
string TempletFileName = rootPath + "DailyReportErrorOut.xlsx";
|
||
//导出文件
|
||
string filePath = rootPath + "DailyReportErrorOut" + DateTime.Now.ToString("yyyyMMddhhmmss") + "\\";
|
||
if (!Directory.Exists(filePath))
|
||
{
|
||
Directory.CreateDirectory(filePath);
|
||
}
|
||
string ReportFileName = filePath + ".xlsx";
|
||
|
||
FileStream file = new FileStream(TempletFileName, FileMode.Open, FileAccess.Read);
|
||
XSSFWorkbook hssfworkbook = new XSSFWorkbook(file);
|
||
|
||
#region JointComprehensive
|
||
XSSFSheet reportModel = (XSSFSheet)hssfworkbook.GetSheet("Sheet1");
|
||
|
||
XSSFFont cs_content_Font1 = (XSSFFont)hssfworkbook.CreateFont(); //创建字体
|
||
cs_content_Font1.FontName = "sans-serif";//字体
|
||
cs_content_Font1.FontHeightInPoints = 9; //字体大小
|
||
|
||
ICellStyle style = hssfworkbook.CreateCellStyle();
|
||
style.SetFont(cs_content_Font1);
|
||
|
||
XSSFFont cs_content_Font = (XSSFFont)hssfworkbook.CreateFont(); //创建字体
|
||
cs_content_Font.FontName = "sans-serif";//字体
|
||
cs_content_Font.FontHeightInPoints = 10; //字体大小
|
||
cs_content_Font.Color = HSSFColor.Red.Index;
|
||
|
||
IDataFormat dataformat = hssfworkbook.CreateDataFormat();
|
||
ICellStyle styleDate = hssfworkbook.CreateCellStyle();
|
||
styleDate.SetFont(cs_content_Font1);
|
||
styleDate.DataFormat = dataformat.GetFormat("yyyy-mm-dd");
|
||
|
||
if (weldReportInItems.Count > 0)
|
||
{
|
||
var rowIndex = 1;
|
||
foreach (var itemOver in weldReportInItems)
|
||
{
|
||
if (reportModel.GetRow(rowIndex) == null) reportModel.CreateRow(rowIndex);
|
||
|
||
#region 列赋值
|
||
//行号
|
||
if (reportModel.GetRow(rowIndex).GetCell(0) == null) reportModel.GetRow(rowIndex).CreateCell(0);
|
||
reportModel.GetRow(rowIndex).GetCell(0).SetCellValue(itemOver.RowID.ToString());
|
||
reportModel.GetRow(rowIndex).GetCell(0).CellStyle = style; //将字体绑定到样式
|
||
|
||
//装置编号
|
||
if (reportModel.GetRow(rowIndex).GetCell(1) == null) reportModel.GetRow(rowIndex).CreateCell(1);
|
||
reportModel.GetRow(rowIndex).GetCell(1).SetCellValue(itemOver.InstallationCode);
|
||
reportModel.GetRow(rowIndex).GetCell(1).CellStyle = style;
|
||
//区域编号
|
||
if (reportModel.GetRow(rowIndex).GetCell(2) == null) reportModel.GetRow(rowIndex).CreateCell(2);
|
||
reportModel.GetRow(rowIndex).GetCell(2).SetCellValue(itemOver.WorkAreaCode);
|
||
reportModel.GetRow(rowIndex).GetCell(2).CellStyle = style;
|
||
//单位代码
|
||
if (reportModel.GetRow(rowIndex).GetCell(3) == null) reportModel.GetRow(rowIndex).CreateCell(3);
|
||
reportModel.GetRow(rowIndex).GetCell(3).SetCellValue(itemOver.UnitCode);
|
||
reportModel.GetRow(rowIndex).GetCell(3).CellStyle = style;
|
||
//管线号
|
||
if (reportModel.GetRow(rowIndex).GetCell(4) == null) reportModel.GetRow(rowIndex).CreateCell(4);
|
||
reportModel.GetRow(rowIndex).GetCell(4).SetCellValue(itemOver.PipelineCode);
|
||
reportModel.GetRow(rowIndex).GetCell(4).CellStyle = style;
|
||
//焊口号
|
||
if (reportModel.GetRow(rowIndex).GetCell(5) == null) reportModel.GetRow(rowIndex).CreateCell(5);
|
||
reportModel.GetRow(rowIndex).GetCell(5).SetCellValue(itemOver.WeldJointCode);
|
||
reportModel.GetRow(rowIndex).GetCell(5).CellStyle = style;
|
||
//焊接日期
|
||
if (reportModel.GetRow(rowIndex).GetCell(6) == null) reportModel.GetRow(rowIndex).CreateCell(6);
|
||
reportModel.GetRow(rowIndex).GetCell(6).SetCellValue(itemOver.WeldingDate);
|
||
reportModel.GetRow(rowIndex).GetCell(6).CellStyle = style;
|
||
//打底焊工号
|
||
if (reportModel.GetRow(rowIndex).GetCell(7) == null) reportModel.GetRow(rowIndex).CreateCell(7);
|
||
reportModel.GetRow(rowIndex).GetCell(7).SetCellValue(itemOver.B_WelderCode);
|
||
reportModel.GetRow(rowIndex).GetCell(7).CellStyle = style;
|
||
//盖面焊工号
|
||
if (reportModel.GetRow(rowIndex).GetCell(8) == null) reportModel.GetRow(rowIndex).CreateCell(8);
|
||
reportModel.GetRow(rowIndex).GetCell(8).SetCellValue(itemOver.T_WelderCode);
|
||
reportModel.GetRow(rowIndex).GetCell(8).CellStyle = style;
|
||
//焊缝类型
|
||
if (reportModel.GetRow(rowIndex).GetCell(9) == null) reportModel.GetRow(rowIndex).CreateCell(9);
|
||
reportModel.GetRow(rowIndex).GetCell(9).SetCellValue(itemOver.WeldTypeCode);
|
||
reportModel.GetRow(rowIndex).GetCell(9).CellStyle = style;
|
||
//焊口属性(活动S、固定G)
|
||
if (reportModel.GetRow(rowIndex).GetCell(10) == null) reportModel.GetRow(rowIndex).CreateCell(10);
|
||
reportModel.GetRow(rowIndex).GetCell(10).SetCellValue(itemOver.JointAttribute);
|
||
reportModel.GetRow(rowIndex).GetCell(10).CellStyle = style;
|
||
//焊接位置
|
||
if (reportModel.GetRow(rowIndex).GetCell(11) == null) reportModel.GetRow(rowIndex).CreateCell(11);
|
||
reportModel.GetRow(rowIndex).GetCell(11).SetCellValue(itemOver.WeldingLocationCode);
|
||
reportModel.GetRow(rowIndex).GetCell(11).CellStyle = style;
|
||
//管径
|
||
if (reportModel.GetRow(rowIndex).GetCell(12) == null) reportModel.GetRow(rowIndex).CreateCell(12);
|
||
reportModel.GetRow(rowIndex).GetCell(12).SetCellValue(itemOver.Size);
|
||
reportModel.GetRow(rowIndex).GetCell(12).CellStyle = style;
|
||
//美标壁厚
|
||
if (reportModel.GetRow(rowIndex).GetCell(13) == null) reportModel.GetRow(rowIndex).CreateCell(13);
|
||
reportModel.GetRow(rowIndex).GetCell(13).SetCellValue(itemOver.ANSISCH);
|
||
reportModel.GetRow(rowIndex).GetCell(13).CellStyle = style;
|
||
//焊接方法
|
||
if (reportModel.GetRow(rowIndex).GetCell(14) == null) reportModel.GetRow(rowIndex).CreateCell(14);
|
||
reportModel.GetRow(rowIndex).GetCell(14).SetCellValue(itemOver.WeldingMethodCode);
|
||
reportModel.GetRow(rowIndex).GetCell(14).CellStyle = style;
|
||
//材质1
|
||
if (reportModel.GetRow(rowIndex).GetCell(15) == null) reportModel.GetRow(rowIndex).CreateCell(15);
|
||
reportModel.GetRow(rowIndex).GetCell(15).SetCellValue(itemOver.MaterialCode1);
|
||
reportModel.GetRow(rowIndex).GetCell(15).CellStyle = style;
|
||
//材质2
|
||
if (reportModel.GetRow(rowIndex).GetCell(16) == null) reportModel.GetRow(rowIndex).CreateCell(16);
|
||
reportModel.GetRow(rowIndex).GetCell(16).SetCellValue(itemOver.MaterialCode2);
|
||
reportModel.GetRow(rowIndex).GetCell(16).CellStyle = style;
|
||
//组件1
|
||
if (reportModel.GetRow(rowIndex).GetCell(17) == null) reportModel.GetRow(rowIndex).CreateCell(17);
|
||
reportModel.GetRow(rowIndex).GetCell(17).SetCellValue(itemOver.ComponentsCode1);
|
||
reportModel.GetRow(rowIndex).GetCell(17).CellStyle = style;
|
||
//组件2
|
||
if (reportModel.GetRow(rowIndex).GetCell(18) == null) reportModel.GetRow(rowIndex).CreateCell(18);
|
||
reportModel.GetRow(rowIndex).GetCell(18).SetCellValue(itemOver.ComponentsCode2);
|
||
reportModel.GetRow(rowIndex).GetCell(18).CellStyle = style;
|
||
//Coode1
|
||
if (reportModel.GetRow(rowIndex).GetCell(19) == null) reportModel.GetRow(rowIndex).CreateCell(19);
|
||
reportModel.GetRow(rowIndex).GetCell(19).SetCellValue(itemOver.Coode1);
|
||
reportModel.GetRow(rowIndex).GetCell(19).CellStyle = style;
|
||
//炉批号1
|
||
if (reportModel.GetRow(rowIndex).GetCell(20) == null) reportModel.GetRow(rowIndex).CreateCell(20);
|
||
reportModel.GetRow(rowIndex).GetCell(20).SetCellValue(itemOver.cood1);
|
||
reportModel.GetRow(rowIndex).GetCell(20).CellStyle = style;
|
||
//Coode2
|
||
if (reportModel.GetRow(rowIndex).GetCell(21) == null) reportModel.GetRow(rowIndex).CreateCell(21);
|
||
reportModel.GetRow(rowIndex).GetCell(21).SetCellValue(itemOver.Coode2);
|
||
reportModel.GetRow(rowIndex).GetCell(21).CellStyle = style;
|
||
//炉批号2
|
||
if (reportModel.GetRow(rowIndex).GetCell(22) == null) reportModel.GetRow(rowIndex).CreateCell(22);
|
||
reportModel.GetRow(rowIndex).GetCell(22).SetCellValue(itemOver.cood2);
|
||
reportModel.GetRow(rowIndex).GetCell(22).CellStyle = style;
|
||
//焊丝
|
||
if (reportModel.GetRow(rowIndex).GetCell(23) == null) reportModel.GetRow(rowIndex).CreateCell(23);
|
||
reportModel.GetRow(rowIndex).GetCell(23).SetCellValue(itemOver.S_ConsumablesCode);
|
||
reportModel.GetRow(rowIndex).GetCell(23).CellStyle = style;
|
||
//焊条
|
||
if (reportModel.GetRow(rowIndex).GetCell(24) == null) reportModel.GetRow(rowIndex).CreateCell(24);
|
||
reportModel.GetRow(rowIndex).GetCell(24).SetCellValue(itemOver.T_ConsumablesCode);
|
||
reportModel.GetRow(rowIndex).GetCell(24).CellStyle = style;
|
||
//所属管段
|
||
if (reportModel.GetRow(rowIndex).GetCell(25) == null) reportModel.GetRow(rowIndex).CreateCell(25);
|
||
reportModel.GetRow(rowIndex).GetCell(25).SetCellValue(itemOver.PipeSegment);
|
||
reportModel.GetRow(rowIndex).GetCell(25).CellStyle = style;
|
||
//WPS编号
|
||
if (reportModel.GetRow(rowIndex).GetCell(26) == null) reportModel.GetRow(rowIndex).CreateCell(26);
|
||
reportModel.GetRow(rowIndex).GetCell(26).SetCellValue(itemOver.WPSCode);
|
||
reportModel.GetRow(rowIndex).GetCell(26).CellStyle = style;
|
||
//错误
|
||
if (reportModel.GetRow(rowIndex).GetCell(27) == null) reportModel.GetRow(rowIndex).CreateCell(27);
|
||
reportModel.GetRow(rowIndex).GetCell(27).SetCellValue(itemOver.Remark.Replace("|", ";"));
|
||
reportModel.GetRow(rowIndex).GetCell(27).CellStyle = style;
|
||
|
||
#endregion
|
||
|
||
rowIndex++;
|
||
}
|
||
}
|
||
#endregion
|
||
reportModel.ForceFormulaRecalculation = true;
|
||
|
||
using (FileStream filess = System.IO.File.OpenWrite(ReportFileName))
|
||
{
|
||
hssfworkbook.Write(filess);
|
||
}
|
||
FileInfo filet = new FileInfo(ReportFileName);
|
||
Response.Clear();
|
||
Response.Charset = "GB2312";
|
||
Response.ContentEncoding = System.Text.Encoding.UTF8;
|
||
// 添加头信息,为"文件下载/另存为"对话框指定默认文件名
|
||
Response.AddHeader("Content-Disposition", "attachment; filename=焊接日报错误日志_" + Server.UrlEncode(DateTime.Now.ToString("yyyyMMddhhmmss") + ".xlsx"));
|
||
// 添加头信息,指定文件大小,让浏览器能够显示下载进度
|
||
Response.AddHeader("Content-Length", filet.Length.ToString());
|
||
// 指定返回的是一个不能被客户端读取的流,必须被下载
|
||
Response.ContentType = "application/ms-excel";
|
||
// 把文件流发送到客户端
|
||
Response.WriteFile(filet.FullName);
|
||
// 停止页面的执行
|
||
Response.End();
|
||
}
|
||
|
||
/// <summary>
|
||
/// 导出方法
|
||
/// </summary>
|
||
/// <param name="grid"></param>
|
||
/// <returns></returns>
|
||
private string GetGridTableHtml(Grid grid)
|
||
{
|
||
StringBuilder sb = new StringBuilder();
|
||
grid.PageSize = 10000;
|
||
sb.Append("<meta http-equiv=\"content-type\" content=\"application/excel; charset=UTF-8\"/>");
|
||
sb.Append("<table cellspacing=\"0\" rules=\"all\" border=\"1\" style=\"border-collapse:collapse;\">");
|
||
sb.Append("<tr>");
|
||
foreach (GridColumn column in grid.Columns)
|
||
{
|
||
sb.AppendFormat("<td>{0}</td>", column.HeaderText);
|
||
}
|
||
sb.Append("</tr>");
|
||
foreach (GridRow row in grid.Rows)
|
||
{
|
||
sb.Append("<tr>");
|
||
foreach (GridColumn column in grid.Columns)
|
||
{
|
||
string html = row.Values[column.ColumnIndex].ToString();
|
||
if (column.ColumnID == "Remark")
|
||
{
|
||
html = (row.FindControl("lablRemark") as AspNet.Label).Text;
|
||
}
|
||
sb.AppendFormat("<td>{0}</td>", html);
|
||
}
|
||
|
||
sb.Append("</tr>");
|
||
}
|
||
|
||
sb.Append("</table>");
|
||
|
||
return sb.ToString();
|
||
}
|
||
#endregion
|
||
|
||
#region 下载模板
|
||
/// <summary>
|
||
/// 下载模板按钮
|
||
/// </summary>
|
||
/// <param name="sender"></param>
|
||
/// <param name="e"></param>
|
||
protected void btnDownLoad_Click(object sender, EventArgs e)
|
||
{
|
||
PageContext.RegisterStartupScript(Confirm.GetShowReference("确定下载导入模板吗?", String.Empty, MessageBoxIcon.Question, PageManager1.GetCustomEventReference(false, "Confirm_OK"), PageManager1.GetCustomEventReference("Confirm_Cancel")));
|
||
}
|
||
|
||
/// <summary>
|
||
/// 下载导入模板
|
||
/// </summary>
|
||
/// <param name="sender"></param>
|
||
/// <param name="e"></param>
|
||
protected void PageManager1_CustomEvent(object sender, CustomEventArgs e)
|
||
{
|
||
if (e.EventArgument == "Confirm_OK")
|
||
{
|
||
string rootPath = Server.MapPath("~/");
|
||
string uploadfilepath = rootPath + Const.DailyReportTemplateUrl;
|
||
string filePath = Const.DailyReportTemplateUrl;
|
||
string fileName = Path.GetFileName(filePath);
|
||
FileInfo info = new FileInfo(uploadfilepath);
|
||
long fileSize = info.Length;
|
||
Response.ClearContent();
|
||
Response.AddHeader("Content-Disposition", "attachment;filename=" + System.Web.HttpUtility.UrlEncode(fileName, System.Text.Encoding.UTF8));
|
||
Response.ContentType = "excel/plain";
|
||
Response.ContentEncoding = System.Text.Encoding.UTF8;
|
||
Response.AddHeader("Content-Length", fileSize.ToString().Trim());
|
||
Response.TransmitFile(uploadfilepath, 0, fileSize);
|
||
Response.End();
|
||
}
|
||
}
|
||
#endregion
|
||
|
||
#region 资质分析
|
||
private bool IsOK(List<Model.Welder_WelderQualify> welderQualifys, string wmeCode, string location, string weldTypeGroup, string ste, decimal? dia, decimal? sch)
|
||
{
|
||
bool isok = false;
|
||
foreach (var welderQualify in welderQualifys)
|
||
{
|
||
int okNum = 0;
|
||
|
||
if (!string.IsNullOrEmpty(wmeCode)) //焊接方法
|
||
{
|
||
if (wmeCode.Contains(welderQualify.WeldingMethodId))
|
||
{
|
||
okNum++;
|
||
}
|
||
}
|
||
else
|
||
{
|
||
okNum++;
|
||
}
|
||
|
||
if (welderQualify.WeldingLocationId == "ALL") //焊接位置
|
||
{
|
||
okNum++;
|
||
}
|
||
else
|
||
{
|
||
if (!string.IsNullOrEmpty(location))
|
||
{
|
||
if (welderQualify.WeldingLocationId.Contains(location))
|
||
{
|
||
okNum++;
|
||
}
|
||
}
|
||
else
|
||
{
|
||
okNum++;
|
||
}
|
||
}
|
||
|
||
if (!string.IsNullOrEmpty(weldTypeGroup))
|
||
{
|
||
if (welderQualify.WeldType.Contains(weldTypeGroup))
|
||
{
|
||
okNum++;
|
||
}
|
||
}
|
||
else
|
||
{
|
||
okNum++;
|
||
}
|
||
|
||
var steel = BLL.Base_MaterialService.GetMaterialByMaterialId(ste);
|
||
if (steel != null) //钢材类型
|
||
{
|
||
if (welderQualify.MaterialType.Contains(steel.MaterialType ?? ""))
|
||
{
|
||
okNum++;
|
||
}
|
||
}
|
||
else
|
||
{
|
||
okNum++;
|
||
}
|
||
|
||
if (weldTypeGroup != "2") // 承插焊
|
||
{
|
||
if (welderQualify.SizesMin == 0) // 0表示不限
|
||
{
|
||
okNum++;
|
||
}
|
||
else //最小寸径
|
||
{
|
||
if (dia != null)
|
||
{
|
||
if (dia >= welderQualify.SizesMin)
|
||
{
|
||
okNum++;
|
||
}
|
||
}
|
||
else
|
||
{
|
||
okNum++;
|
||
}
|
||
}
|
||
|
||
if (welderQualify.ThicknessMax == 0) // 0表示不限
|
||
{
|
||
okNum++;
|
||
}
|
||
else
|
||
{
|
||
if (sch != null) //最大壁厚
|
||
{
|
||
if (sch <= welderQualify.ThicknessMax)
|
||
{
|
||
okNum++;
|
||
}
|
||
}
|
||
else
|
||
{
|
||
okNum++;
|
||
}
|
||
}
|
||
}
|
||
else // 当为角焊缝时,管径和壁厚不限制
|
||
{
|
||
okNum++;
|
||
okNum++;
|
||
}
|
||
|
||
|
||
if (okNum == 6) //全部条件符合
|
||
{
|
||
isok = true;
|
||
break;
|
||
}
|
||
}
|
||
|
||
return isok;
|
||
}
|
||
|
||
/// <summary>
|
||
/// 两种焊接方法的资质判断
|
||
/// </summary>
|
||
/// <param name="floorWelderQualifys"></param>
|
||
/// <param name="cellWelderQualifys"></param>
|
||
/// <param name="wmeCode1"></param>
|
||
/// <param name="wmeCode2"></param>
|
||
/// <param name="location"></param>
|
||
/// <param name="ste"></param>
|
||
/// <param name="dia"></param>
|
||
/// <param name="sch"></param>
|
||
/// <returns></returns>
|
||
private bool TwoWmeIsOK(List<Model.Welder_WelderQualify> floorWelderQualifys, List<Model.Welder_WelderQualify> cellWelderQualifys, string wmeCode1, string wmeCode2, string location, string weldTypeGroup, string ste, decimal? dia, decimal? sch)
|
||
{
|
||
bool isok = false;
|
||
|
||
decimal? fThicknessMax = 0;
|
||
decimal? cThicknessMax = 0;
|
||
|
||
var steel = BLL.Base_MaterialService.GetMaterialByMaterialId(ste);
|
||
var floorQ = from x in floorWelderQualifys
|
||
where wmeCode1.Contains(x.WeldingMethodId)
|
||
&& (x.WeldingLocationId == "ALL" || (location == null || location == "" || x.WeldingLocationId.Contains(location)))
|
||
&& (steel == null || x.MaterialType.Contains(steel.MaterialType ?? ""))
|
||
&& (weldTypeGroup == null || x.WeldType.Contains(weldTypeGroup))
|
||
// && (dia == null || x.SizesMin<=dia)
|
||
select x;
|
||
var cellQ = from x in cellWelderQualifys
|
||
where wmeCode2.Contains(x.WeldingMethodId)
|
||
&& (x.WeldingLocationId == "ALL" || (location == null || location == "" || x.WeldingLocationId.Contains(location)))
|
||
&& (steel == null || x.MaterialType.Contains(steel.MaterialType ?? ""))
|
||
&& (weldTypeGroup == null || x.WeldType.Contains(weldTypeGroup))
|
||
// && (dia == null || x.SizesMin <= dia)
|
||
select x;
|
||
if (floorQ.Count() > 0 && cellQ.Count() > 0)
|
||
{
|
||
if (weldTypeGroup != "2") // 当为角焊缝时,管径和壁厚不限制
|
||
{
|
||
var floorDiaQ = floorQ.Where(x => x.SizesMin <= dia);
|
||
var cellDiaQ = cellQ.Where(x => x.SizesMin <= dia);
|
||
|
||
if (floorDiaQ.Count() > 0 && cellDiaQ.Count() > 0)
|
||
{
|
||
var fThick = floorDiaQ.Where(x => x.ThicknessMax == 0);
|
||
var cThick = cellDiaQ.Where(x => x.ThicknessMax == 0);
|
||
|
||
// 只要有一个不限(为0)就通过
|
||
if (fThick.Count() > 0 || cThick.Count() > 0)
|
||
{
|
||
isok = true;
|
||
}
|
||
|
||
else
|
||
{
|
||
fThicknessMax = floorQ.Max(x => x.ThicknessMax);
|
||
cThicknessMax = cellQ.Max(x => x.ThicknessMax);
|
||
|
||
if ((fThicknessMax + cThicknessMax) >= sch)
|
||
{
|
||
isok = true;
|
||
}
|
||
}
|
||
}
|
||
}
|
||
else
|
||
{
|
||
isok = true;
|
||
}
|
||
}
|
||
|
||
return isok;
|
||
}
|
||
#endregion
|
||
}
|
||
|
||
#region grid数据模型
|
||
/// <summary>
|
||
/// 列表数据模型
|
||
/// </summary>
|
||
public class WeldReportInItem
|
||
{
|
||
/// <summary>
|
||
/// RowID
|
||
/// </summary>
|
||
public string RowID
|
||
{
|
||
get;
|
||
set;
|
||
}
|
||
/// <summary>
|
||
/// 装置编号
|
||
/// </summary>
|
||
public string InstallationCode
|
||
{
|
||
get;
|
||
set;
|
||
}
|
||
/// <summary>
|
||
/// 区域编号
|
||
/// </summary>
|
||
public string WorkAreaCode
|
||
{
|
||
get;
|
||
set;
|
||
}
|
||
/// <summary>
|
||
/// 单位代码
|
||
/// </summary>
|
||
public string UnitCode
|
||
{
|
||
get;
|
||
set;
|
||
}
|
||
/// <summary>
|
||
/// 管线号
|
||
/// </summary>
|
||
public string PipelineCode
|
||
{
|
||
get;
|
||
set;
|
||
}
|
||
/// <summary>
|
||
/// 焊口号
|
||
/// </summary>
|
||
public string WeldJointCode
|
||
{
|
||
get;
|
||
set;
|
||
}
|
||
/// <summary>
|
||
/// 焊接日期
|
||
/// </summary>
|
||
public string WeldingDate
|
||
{
|
||
get;
|
||
set;
|
||
}
|
||
/// <summary>
|
||
/// 打底焊工号
|
||
/// </summary>
|
||
public string B_WelderCode
|
||
{
|
||
get;
|
||
set;
|
||
}
|
||
/// <summary>
|
||
/// 盖面焊工号
|
||
/// </summary>
|
||
public string T_WelderCode
|
||
{
|
||
get;
|
||
set;
|
||
}
|
||
/// <summary>
|
||
/// 焊缝类型
|
||
/// </summary>
|
||
public string WeldTypeCode
|
||
{
|
||
get;
|
||
set;
|
||
}
|
||
/// <summary>
|
||
/// 焊口属性(活动S、固定G)
|
||
/// </summary>
|
||
public string JointAttribute
|
||
{
|
||
get;
|
||
set;
|
||
}
|
||
/// <summary>
|
||
/// 焊接位置
|
||
/// </summary>
|
||
public string WeldingLocationCode
|
||
{
|
||
get;
|
||
set;
|
||
}
|
||
/// <summary>
|
||
/// 管径
|
||
/// </summary>
|
||
public string Size
|
||
{
|
||
get;
|
||
set;
|
||
}
|
||
/// <summary>
|
||
/// 美标壁厚
|
||
/// </summary>
|
||
public string ANSISCH
|
||
{
|
||
get;
|
||
set;
|
||
}
|
||
/// <summary>
|
||
/// 焊接方法
|
||
/// </summary>
|
||
public string WeldingMethodCode
|
||
{
|
||
get;
|
||
set;
|
||
}
|
||
/// <summary>
|
||
/// 材质1
|
||
/// </summary>
|
||
public string MaterialCode1
|
||
{
|
||
get;
|
||
set;
|
||
}
|
||
/// <summary>
|
||
/// 材质2
|
||
/// </summary>
|
||
public string MaterialCode2
|
||
{
|
||
get;
|
||
set;
|
||
}
|
||
/// <summary>
|
||
/// 组件1
|
||
/// </summary>
|
||
public string ComponentsCode1
|
||
{
|
||
get;
|
||
set;
|
||
}
|
||
/// <summary>
|
||
/// 组件2
|
||
/// </summary>
|
||
public string ComponentsCode2
|
||
{
|
||
get;
|
||
set;
|
||
}
|
||
/// <summary>
|
||
/// Coode1
|
||
/// </summary>
|
||
public string Coode1
|
||
{
|
||
get;
|
||
set;
|
||
}
|
||
/// <summary>
|
||
/// 炉批号1
|
||
/// </summary>
|
||
public string cood1
|
||
{
|
||
get;
|
||
set;
|
||
}
|
||
/// <summary>
|
||
/// Coode2
|
||
/// </summary>
|
||
public string Coode2
|
||
{
|
||
get;
|
||
set;
|
||
}
|
||
/// <summary>
|
||
/// 炉批号2
|
||
/// </summary>
|
||
public string cood2
|
||
{
|
||
get;
|
||
set;
|
||
}
|
||
/// <summary>
|
||
/// 焊丝
|
||
/// </summary>
|
||
public string S_ConsumablesCode
|
||
{
|
||
get;
|
||
set;
|
||
}
|
||
/// <summary>
|
||
/// 焊条
|
||
/// </summary>
|
||
public string T_ConsumablesCode
|
||
{
|
||
get;
|
||
set;
|
||
}
|
||
/// <summary>
|
||
/// 所属管段
|
||
/// </summary>
|
||
public string PipeSegment
|
||
{
|
||
get;
|
||
set;
|
||
}
|
||
/// <summary>
|
||
/// WPS编号
|
||
/// </summary>
|
||
public string WPSCode
|
||
{
|
||
get;
|
||
set;
|
||
}
|
||
/// <summary>
|
||
/// 错误信息
|
||
/// </summary>
|
||
public string Remark
|
||
{
|
||
get;
|
||
set;
|
||
}
|
||
|
||
/// <summary>
|
||
/// 导入时间
|
||
/// </summary>
|
||
public string CreatedTime
|
||
{
|
||
get;
|
||
set;
|
||
}
|
||
}
|
||
#endregion
|
||
|
||
} |