Basf_TCC11/HJGL/FineUIPro.Web/WeldingProcess/WeldingManage/WeldReport.aspx.cs

1745 lines
81 KiB
C#
Raw Normal View History

2024-05-08 16:27:28 +08:00
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.IO;
using NPOI.HSSF.Util;
using NPOI.SS.UserModel;
using NPOI.SS.Util;
using NPOI.XSSF.UserModel;
using System.Linq;
using System.Threading;
using BLL;
2024-06-05 08:24:19 +08:00
using Org.BouncyCastle.Ocsp;
using NPOI.SS.Formula.Functions;
2024-05-08 16:27:28 +08:00
namespace FineUIPro.Web.WeldingProcess.WeldingManage
{
public partial class WeldReport : PageBase
{
//定义变量
/// <summary>
/// 上传预设的虚拟路径
/// </summary>
private string initPath = Const.ExcelUrl;
/// <summary>
/// 错误集合
/// </summary>
public static string errorInfos = string.Empty;
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
this.txtMonth.Text = string.Format("{0:yyyy-MM}",DateTime.Now);
this.ddlPageSize.SelectedValue = this.Grid1.PageSize.ToString();
this.InitTreeMenu();//加载树
}
}
#region -
/// <summary>
/// 加载树
/// </summary>
private void InitTreeMenu()
{
if (!string.IsNullOrEmpty(this.txtMonth.Text.Trim()))
{
DateTime startTime = Convert.ToDateTime(this.txtMonth.Text.Trim() + "-01");
DateTime endTime = startTime.AddMonths(1);
this.tvControlItem.Nodes.Clear();
var weldReports = (from x in Funs.DB.Pipeline_WeldingDaily
where x.ProjectId == this.CurrUser.LoginProjectId
select x).ToList();
this.BindNodes(null, weldReports, startTime, endTime);
}
else
{
Alert.ShowInTop("请选择月份!", MessageBoxIcon.Warning);
}
}
#endregion
#region
#region
/// <summary>
/// 绑定树节点
/// </summary>
/// <param name="node"></param>
private void BindNodes(TreeNode node, List<Model.Pipeline_WeldingDaily> projectWeldReports, DateTime startTime, DateTime endTime)
{
var pUnitDepth = Funs.DB.Project_Unit.FirstOrDefault(x => x.UnitId == this.CurrUser.UnitId && x.ProjectId == this.CurrUser.LoginProjectId);
if (node == null)
{
if (pUnitDepth!=null && pUnitDepth.UnitType == Const.UnitType_5)
{
var installations = (from x in projectWeldReports
join y in Funs.DB.Project_Installation
on x.InstallationId equals y.InstallationId
where x.UnitId==this.CurrUser.UnitId && x.WeldingDate >= startTime && x.WeldingDate < endTime
select y).Distinct().ToList();
foreach (var q in installations)
{
TreeNode newNode = new TreeNode();
newNode.NodeID = q.InstallationId;
newNode.Text = q.InstallationName;
newNode.ToolTip = Resources.Lan.InstallationName;
newNode.Expanded = true;
this.tvControlItem.Nodes.Add(newNode);
this.BindNodes(newNode, projectWeldReports, startTime, endTime);
}
}
else
{
var installations = (from x in projectWeldReports
join y in Funs.DB.Project_Installation
on x.InstallationId equals y.InstallationId
where x.WeldingDate >= startTime && x.WeldingDate < endTime
select y).Distinct().ToList();
foreach (var q in installations)
{
TreeNode newNode = new TreeNode();
newNode.NodeID = q.InstallationId;
newNode.Text = q.InstallationName;
newNode.ToolTip = Resources.Lan.InstallationName;
newNode.Expanded = true;
this.tvControlItem.Nodes.Add(newNode);
this.BindNodes(newNode, projectWeldReports, startTime, endTime);
}
}
}
else if (node.ToolTip == Resources.Lan.InstallationName)
{
List<Model.Base_Unit> units = null;
if (pUnitDepth != null && pUnitDepth.UnitType == Const.UnitType_5)
{
units = (from x in Funs.DB.Base_Unit
where x.UnitId == this.CurrUser.UnitId
select x).ToList();
}
else
{
units = (from x in projectWeldReports
join y in Funs.DB.Project_Installation
on x.InstallationId equals y.InstallationId
join z in Funs.DB.Base_Unit
on x.UnitId equals z.UnitId
where x.InstallationId == node.NodeID && x.WeldingDate >= startTime && x.WeldingDate < endTime
select z).Distinct().ToList();
}
units = units.OrderBy(x => x.InTime).Distinct().ToList();
foreach (var q in units)
{
TreeNode newNode = new TreeNode();
newNode.Text = q.UnitName;
newNode.NodeID = q.UnitId + "|" + node.NodeID;
newNode.ToolTip = Resources.Lan.UnitName;
newNode.EnableClickEvent = true;
node.Nodes.Add(newNode);
}
}
}
#endregion
#endregion
#region TreeView
/// <summary>
/// 点击TreeView
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void tvControlItem_NodeCommand(object sender, TreeCommandEventArgs e)
{
this.BindGrid();
}
#endregion
#region
/// <summary>
/// 查询
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btnQuery_Click(object sender, EventArgs e)
{
this.BindGrid();
}
#endregion
#region
/// <summary>
/// 数据绑定
/// </summary>
private void BindGrid()
{
if (this.tvControlItem.SelectedNode != null && this.tvControlItem.SelectedNode.ToolTip == Resources.Lan.UnitName)
{
string[] strs = this.tvControlItem.SelectedNodeID.Split('|');
DateTime startDate = Convert.ToDateTime(this.txtMonth.Text.Trim() + "-1");
DateTime endDate = startDate.AddMonths(1);
string startDateStr = string.Format("{0:yyyy-MM-dd}", startDate);
string endDateStr = string.Format("{0:yyyy-MM-dd}", endDate);
string strSql = @"SELECT distinct d.WeldingDailyId,d.WeldingDailyCode,d.ProjectId,
d.InstallationId,d.UnitId,d.WeldingDate,d.Tabler,d.TableDate,d.Remark
FROM dbo.Pipeline_WeldingDaily d
left join dbo.View_Pipeline_WeldJoint w on w.WeldingDailyId=d.WeldingDailyId
WHERE 1=1 ";
List<SqlParameter> listStr = new List<SqlParameter>
{
};
strSql += " AND d.ProjectId =@ProjectId";
listStr.Add(new SqlParameter("@ProjectId", this.CurrUser.LoginProjectId));
strSql += " AND d.InstallationId =@InstallationId";
listStr.Add(new SqlParameter("@InstallationId", strs[1]));
strSql += " AND d.UnitId =@UnitId";
listStr.Add(new SqlParameter("@UnitId", strs[0]));
strSql += " AND d.WeldingDate >=@startDateStr";
listStr.Add(new SqlParameter("@startDateStr", startDateStr));
strSql += " AND d.WeldingDate <@endDateStr";
listStr.Add(new SqlParameter("@endDateStr", endDateStr));
if (!string.IsNullOrEmpty(this.txtWeldingDate.Text.Trim()))
{
strSql += " AND d.WeldingDate = @WeldingDate";
listStr.Add(new SqlParameter("@WeldingDate", this.txtWeldingDate.Text.Trim()));
}
if (!string.IsNullOrEmpty(this.txtPipelineCode.Text.Trim()))
{
strSql += " AND w.PipelineCode LIKE @PipelineCode";
listStr.Add(new SqlParameter("@PipelineCode", "%" + this.txtPipelineCode.Text.Trim() + "%"));
}
if (!string.IsNullOrEmpty(this.txtWeldJointCode.Text.Trim()))
{
strSql += " AND w.WeldJointCode LIKE @WeldJointCode";
listStr.Add(new SqlParameter("@WeldJointCode", "%" + this.txtWeldJointCode.Text.Trim() + "%"));
}
SqlParameter[] parameter = listStr.ToArray();
DataTable tb = SQLHelper.GetDataTableRunText(strSql, parameter);
// 2.获取当前分页数据
//var table = this.GetPagedDataTable(Grid1, tb1);
Grid1.RecordCount = tb.Rows.Count;
tb = GetFilteredTable(Grid1.FilteredData, tb);
var table = this.GetPagedDataTable(Grid1, tb);
Grid1.DataSource = table;
Grid1.DataBind();
}
}
#endregion
#region
#region
/// <summary>
/// 页索引改变事件
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void Grid1_PageIndexChange(object sender, GridPageEventArgs e)
{
BindGrid();
}
#endregion
#region
/// <summary>
/// 排序
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void Grid1_Sort(object sender, GridSortEventArgs e)
{
BindGrid();
}
#endregion
#region
/// <summary>
/// 分页选择下拉改变事件
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void ddlPageSize_SelectedIndexChanged(object sender, EventArgs e)
{
Grid1.PageSize = Convert.ToInt32(ddlPageSize.SelectedValue);
BindGrid();
}
#endregion
#endregion
#region
/// <summary>
/// Grid双击事件
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void Grid1_RowDoubleClick(object sender, GridRowClickEventArgs e)
{
if (BLL.CommonService.GetAllButtonPowerList(this.CurrUser.LoginProjectId, this.CurrUser.UserId, BLL.Const.HJGL_WeldReportMenuId, BLL.Const.BtnModify))
{
PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("WeldReportEdit.aspx?WeldingDailyId={0}", Grid1.SelectedRowID, "编辑 - ")));
}
else
{
ShowNotify(Resources.Lan.NoPrivilegePrompt, MessageBoxIcon.Warning);
}
}
/// <summary>
/// 增加焊接日报
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btnNew_Click(object sender, EventArgs e)
{
if (CommonService.GetAllButtonPowerList(this.CurrUser.LoginProjectId, this.CurrUser.UserId, Const.HJGL_WeldReportMenuId, Const.BtnAdd))
{
PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("WeldReportEdit.aspx?ProjectId={0}", this.CurrUser.LoginProjectId, "新增 - ")));
}
else
{
ShowNotify(Resources.Lan.NoPrivilegePrompt, MessageBoxIcon.Warning);
}
}
/// <summary>
/// 焊接日报编辑
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btnMenuEdit_Click(object sender, EventArgs e)
{
if (BLL.CommonService.GetAllButtonPowerList(this.CurrUser.LoginProjectId, this.CurrUser.UserId, BLL.Const.HJGL_WeldReportMenuId, BLL.Const.BtnModify))
{
if (Grid1.SelectedRowIndexArray.Length == 0)
{
Alert.ShowInTop(Resources.Lan.SelectLeastOneRecord, MessageBoxIcon.Warning);
return;
}
PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("WeldReportEdit.aspx?WeldingDailyId={0}", Grid1.SelectedRowID, "维护 - ")));
}
else
{
ShowNotify(Resources.Lan.NoPrivilegePrompt, MessageBoxIcon.Warning);
}
}
/// <summary>
/// 删除按钮
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btnMenuDelete_Click(object sender, EventArgs e)
{
if (CommonService.GetAllButtonPowerList(this.CurrUser.LoginProjectId, this.CurrUser.UserId, Const.HJGL_WeldReportMenuId, Const.BtnDelete))
{
if (Grid1.SelectedRowIndexArray.Length == 0)
{
Alert.ShowInTop(Resources.Lan.SelectLeastOneRecord, MessageBoxIcon.Warning);
return;
}
else
{
string weldingDailyId = Grid1.SelectedRowID;
if (!BLL.Batch_NDEItemService.IsCheckedByWeldingDaily(weldingDailyId))
{
var weldJoints = BLL.Pipeline_WeldJointService.GetWeldlinesByWeldingDailyId(weldingDailyId);
if (weldJoints.Count() > 0)
{
foreach (var item in weldJoints)
{
var updateWeldJoint = BLL.Pipeline_WeldJointService.GetWeldJointByWeldJointId(item.WeldJointId);
if (updateWeldJoint != null)
{
updateWeldJoint.WeldingDailyId = null;
updateWeldJoint.WeldingDailyCode = null;
updateWeldJoint.CoverWelderId = null;
updateWeldJoint.BackingWelderId = null;
updateWeldJoint.WeldingDate = null;
BLL.Pipeline_WeldJointService.UpdateWeldJoint(updateWeldJoint);
// 删除焊口所在批和委托检测里信息
BLL.Batch_NDEItemService.DeleteAllNDEInfoToWeldJoint(item.WeldJointId);
}
}
}
BLL.Pipeline_WeldingDailyService.DeleteWeldingDailyByWeldingDailyId(weldingDailyId);
BLL.Sys_LogService.AddLog(BLL.Const.System_3, this.CurrUser.LoginProjectId, this.CurrUser.UserId, Const.HJGL_WeldReportMenuId, Const.BtnDelete, weldingDailyId);
ShowNotify(Resources.Lan.DeletedSuccessfully, MessageBoxIcon.Success);
this.BindGrid();
}
else
{
Alert.ShowInTop("该日报下已有焊口检测了,不能删除!", MessageBoxIcon.Warning);
}
}
}
else
{
Alert.ShowInTop(Resources.Lan.NoPrivilegePrompt, MessageBoxIcon.Warning);
}
}
#endregion
#region
/// <summary>
/// 模板下载
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btnDownLoad_Click(object sender, EventArgs e)
{
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();
//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
/// <summary>
/// 导入
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btnImport_Click(object sender, EventArgs e)
{
if (this.dailyReportUrl.HasFile == false)
{
ShowNotify("请选择Excel文件!", MessageBoxIcon.Warning);
return;
}
string IsXls = Path.GetExtension(this.dailyReportUrl.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.hidFileName.Text = BLL.Funs.GetNewFileName() + IsXls;
//上传文件路径
string filePath = initFullPath + this.hidFileName.Text;
//文件上传服务器
this.dailyReportUrl.PostedFile.SaveAs(filePath);
//文件上传服务器后的名称
string fileName = rootPath + initPath + this.hidFileName.Text;
//读取Excel
DataSet ds = NPOIHelper.ExcelToDataSet(fileName, out errorInfos, true);
errorInfos = string.Empty;
//验证Excel读取是否有误
if (!string.IsNullOrEmpty(errorInfos))
{
ShowNotify(errorInfos, MessageBoxIcon.Warning);
return;
}
string message = string.Empty;
var project = BLL.Base_ProjectService.GetProjectByProjectId(this.CurrUser.LoginProjectId);
// 管线ID的集合
//List<string> pipelineIdList = new List<string>();
// 焊工资质不符合条件信息
string eventArg = string.Empty;
string installationId = string.Empty;
string workAreaId = string.Empty;
string unitId = string.Empty;
//string txtWeldDate = 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;
2024-06-05 08:24:19 +08:00
var coodeList = from x in Funs.DB.Base_MaterialCoode where x.ProjectId == this.CurrUser.LoginProjectId select x; //coode
2024-05-08 16:27:28 +08:00
List<Model.SpWeldingDaily> dayList = new List<Model.SpWeldingDaily>();
for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
{
Model.SpWeldingDaily d = new Model.SpWeldingDaily();
#region
string insId = string.Empty;
if (ds.Tables[0].Rows[i]["装置编号"] != null && !string.IsNullOrEmpty(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>";
}
}
else
{
errorInfos += (i + 2) + "行, 装置编号不能为空!</br>";
}
string areaId = string.Empty;
if (ds.Tables[0].Rows[i]["区域编号"] != null && !string.IsNullOrEmpty(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>";
}
}
else
{
errorInfos += (i + 2) + "行, 区域编号不能为空!</br>";
}
if (ds.Tables[0].Rows[i]["单位代码"] != null && !string.IsNullOrEmpty(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>";
}
}
else
{
errorInfos += (i + 2) + "行, 单位代码不能为空!</br>";
}
string pipelineId = string.Empty;
if (ds.Tables[0].Rows[i]["管线号"] != null && !string.IsNullOrEmpty(ds.Tables[0].Rows[i]["管线号"].ToString()))
{
var pipeline = from x in Funs.DB.Pipeline_Pipeline
where x.ProjectId == this.CurrUser.LoginProjectId && x.WorkAreaId == areaId
2024-06-05 08:24:19 +08:00
&& x.InstallationId == insId && x.WorkAreaId==areaId && x.PipelineCode == ds.Tables[0].Rows[i]["管线号"].ToString()
2024-05-08 16:27:28 +08:00
select x;
if (pipeline.Count() > 0)
{
pipelineId = pipeline.First().PipelineId;
d.PipelineId = pipelineId;
//pipelineIdList.Add(pipelineId);
}
else
{
errorInfos += (i + 2) + "行, 该项目管线编号不存在!</br>";
}
}
else
{
errorInfos += (i + 2) + "行,管线号不能为空!</br>";
}
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()))
{
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;
2024-06-05 08:24:19 +08:00
d.Coode1 = jot.First().Coode1;
d.Coode2 = jot.First().Coode2;
2024-05-08 16:27:28 +08:00
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>";
}
}
else
{
errorInfos += (i + 2) + "行,焊口号不能为空!</br>";
}
if (ds.Tables[0].Rows[i]["焊接日期"] != null && !string.IsNullOrEmpty(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>";
}
}
else
{
errorInfos += (i + 2) + "行,焊接日期不能为空!</br>";
}
bool isExistFloor = false;
string floorWelderId = string.Empty;
if (ds.Tables[0].Rows[i]["打底焊工号"] != null && !string.IsNullOrEmpty(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>";
}
}
else
{
errorInfos += (i + 2) + "行,打底焊工号不能为空!</br>";
}
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()))
{
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>";
}
}
else
{
errorInfos += (i + 2) + "行,盖面焊工号不能为空!</br>";
}
if (ds.Tables[0].Rows[i]["焊缝类型"] != null && !string.IsNullOrEmpty(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() + "]不存在;";
}
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();
if (att != "S" && att != "G")
{
errorInfos += (i + 2) + "行,焊口属性(S或G)不正确!</br>";
}
else
{
2024-06-05 08:24:19 +08:00
d.JointAttribute = att;
2024-05-08 16:27:28 +08:00
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()))
{
var loc = weldingLocation.FirstOrDefault(x => x.WeldingLocationCode == ds.Tables[0].Rows[i]["焊接位置"].ToString());
if (loc == null)
{
errorInfos += "焊接位置[" + 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()))
{
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>";
}
}
if (ds.Tables[0].Rows[i]["美标壁厚"] != null && !string.IsNullOrEmpty(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() + "]错误;";
}
}
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()))
{
var weldMethod = weldingMethods.FirstOrDefault(x => x.WeldingMethodCode == ds.Tables[0].Rows[i]["焊接方法"].ToString());
if (weldMethod == null)
{
errorInfos += "焊接方法[" + 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()))
{
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() + "]不存在;";
}
else
{
d.Material1Id = steel.MaterialId;
}
}
if (ds.Tables[0].Rows[i]["材质2"] != null && !string.IsNullOrEmpty(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() + "]不存在;";
}
else
{
d.Material2Id = steel.MaterialId;
}
}
if (ds.Tables[0].Rows[i]["组件1"] != null && !string.IsNullOrEmpty(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() + "]不存在;";
}
else
{
d.PipeAssembly1Id = com.ComponentsId;
}
}
if (ds.Tables[0].Rows[i]["组件2"] != null && !string.IsNullOrEmpty(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() + "]不存在;";
}
else
{
d.PipeAssembly2Id = com.ComponentsId;
}
}
2024-06-05 08:24:19 +08:00
if (ds.Tables[0].Rows[i]["Coode1"] != null && !string.IsNullOrEmpty(ds.Tables[0].Rows[i]["Coode1"].ToString()))
{
2024-07-01 09:29:35 +08:00
d.Coode1 = ds.Tables[0].Rows[i]["Coode1"].ToString();
2024-06-05 08:24:19 +08:00
}
2024-07-01 09:29:35 +08:00
//else
//{
// errorInfos += (i + 2) + "行,Coode1不能为空!</br>";
//}
2024-06-05 08:24:19 +08:00
if (ds.Tables[0].Rows[i]["Coode2"] != null && !string.IsNullOrEmpty(ds.Tables[0].Rows[i]["Coode2"].ToString()))
{
2024-07-03 17:32:33 +08:00
d.Coode2 = ds.Tables[0].Rows[i]["Coode2"].ToString();
2024-06-05 08:24:19 +08:00
}
2024-07-01 09:29:35 +08:00
//else
//{
// errorInfos += (i + 2) + "行,Coode2不能为空!</br>";
//}
2024-05-08 16:27:28 +08:00
if (ds.Tables[0].Rows[i]["炉批号1"] != null && !string.IsNullOrEmpty(ds.Tables[0].Rows[i]["炉批号1"].ToString()))
{
2024-07-01 09:29:35 +08:00
var cood = coodeList.FirstOrDefault(x =>x.IsUse==true && x.Coode == d.Coode1 && x.HeartNo == ds.Tables[0].Rows[i]["炉批号1"].ToString());
2024-06-05 08:24:19 +08:00
if (cood == null)
{
2024-07-03 17:12:32 +08:00
errorInfos += "炉批号1:[" + ds.Tables[0].Rows[i]["炉批号1"].ToString() + "]或对应的Coode1:"+d.Coode1+"不存在;";
2024-06-05 08:24:19 +08:00
}
else
{
d.HeartNo1 = ds.Tables[0].Rows[i]["炉批号1"].ToString();
}
}
2024-07-01 09:29:35 +08:00
//else
//{
// errorInfos += (i + 2) + "行,炉批号1不能为空!</br>";
//}
2024-06-05 08:24:19 +08:00
2024-05-08 16:27:28 +08:00
if (ds.Tables[0].Rows[i]["炉批号2"] != null && !string.IsNullOrEmpty(ds.Tables[0].Rows[i]["炉批号2"].ToString()))
{
2024-07-01 09:29:35 +08:00
var cood = coodeList.FirstOrDefault(x => x.IsUse == true && x.Coode == d.Coode2 && x.HeartNo == ds.Tables[0].Rows[i]["炉批号2"].ToString());
2024-06-05 08:24:19 +08:00
if (cood == null)
{
2024-07-03 17:12:32 +08:00
errorInfos += "炉批号2:[" + ds.Tables[0].Rows[i]["炉批号2"].ToString() + "]或对应的Coode2:"+ d.Coode2 + "不存在;";
2024-06-05 08:24:19 +08:00
}
else
{
d.HeartNo2 = ds.Tables[0].Rows[i]["炉批号2"].ToString();
}
}
2024-07-01 09:29:35 +08:00
//else
//{
// errorInfos += (i + 2) + "行,炉批号2不能为空!</br>";
//}
2024-05-08 16:27:28 +08:00
//if (ds.Tables[0].Rows[i]["焊丝"] != null && !string.IsNullOrEmpty(ds.Tables[0].Rows[i]["焊丝"].ToString()))
//{
// var weldSilk = consumabless.FirstOrDefault(x => x.ConsumablesCode == ds.Tables[0].Rows[i]["焊丝"].ToString() && x.ConsumablesType == "1");
// if (weldSilk == null)
// {
// errorInfos += "焊丝[" + ds.Tables[0].Rows[i]["焊丝"].ToString() + "]不存在;";
// }
// else
// {
// d.WeldSilkId = weldSilk.ConsumablesId;
// }
//}
if (ds.Tables[0].Rows[i]["焊丝"] != null && !string.IsNullOrEmpty(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 + "]不存在;";
}
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() + "]不正确,多个焊丝用,隔开;";
}
}
if (ds.Tables[0].Rows[i]["焊条"] != null && !string.IsNullOrEmpty(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() + "]不存在;";
}
else
{
d.WeldMatId = weldMat.ConsumablesId;
}
}
if (ds.Tables[0].Rows[i]["所属管段"] != null && !string.IsNullOrEmpty(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()))
{
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() + "]不存在;";
}
else
{
d.WPQId = wps.WPQId;
//d.WeldingMethodId = wps.WeldingMethodId;
}
}
#endregion
dayList.Add(d);
2024-07-01 09:29:35 +08:00
#region WPS资质
2024-05-08 16:27:28 +08:00
//if (!string.IsNullOrEmpty(errorInfos))
//{
// ShowNotify(errorInfos, MessageBoxIcon.Warning, 10000);
// return;
//}
2024-07-01 09:29:35 +08:00
//else
2024-05-08 16:27:28 +08:00
//{
2024-07-01 09:29:35 +08:00
// // 判断WPS资质 暂不用
2024-05-08 16:27:28 +08:00
// if (welderQueIsUse == true)
// {
// if (isExistFloor && isExistCell)
// {
2024-07-01 09:29:35 +08:00
// //bool canSave = false;
2024-05-08 16:27:28 +08:00
// var jot = BLL.Pipeline_WeldJointService.GetWeldJointByWeldJointId(jotId);
2024-07-01 09:29:35 +08:00
// var wps = BLL.WPQListServiceService.GetWPQById(jot.WPQId);
// if (wps != null)
2024-05-08 16:27:28 +08:00
// {
2024-07-01 09:29:35 +08:00
// if (wps.WelderIds.Contains(cellWelderId) && wps.WelderIds.Contains(floorWelderId))
2024-05-08 16:27:28 +08:00
// {
// }
// else
// {
2024-07-01 09:29:35 +08:00
// eventArg = eventArg + jot.WeldJointCode + ",";
2024-05-08 16:27:28 +08:00
// }
// }
// }
// }
//}
#endregion
2024-07-01 09:29:35 +08:00
#region
if (!string.IsNullOrEmpty(errorInfos))
{
ShowNotify(errorInfos, MessageBoxIcon.Warning, 10000);
return;
}
else
{
// 判断资质
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 + ",";
}
}
}
}
#endregion
2024-05-08 16:27:28 +08:00
}
2024-06-05 08:24:19 +08:00
// 判断Coode数量
string 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 + "的数量已超出,";
}
}
}
if (!string.IsNullOrEmpty(coodeNumError))
{
coodeNumError = coodeNumError + "请检查后再导入";
}
2024-05-08 16:27:28 +08:00
// 数据验证错误,返回
if (!string.IsNullOrEmpty(errorInfos))
{
ShowNotify(errorInfos, MessageBoxIcon.Warning, 10000);
return;
}
2024-06-05 08:24:19 +08:00
else if (!string.IsNullOrEmpty(coodeNumError))
{
ShowNotify(coodeNumError, MessageBoxIcon.Warning, 10000);
return;
}
2024-05-08 16:27:28 +08:00
else
{
// 焊工资质符全条件
if (eventArg == string.Empty)
{
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;
2024-06-05 08:24:19 +08:00
2024-05-08 16:27:28 +08:00
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);
}
ShowNotify("日报导入成功!", MessageBoxIcon.Success);
this.BindGrid();
//PageContext.RegisterStartupScript(ActiveWindow.GetHidePostBackReference());
}
else
{
Alert.ShowInTop(Resources.Lan.NoQualification + "【" + eventArg + "】" + Resources.Lan.WeldingConditions, Resources.Lan.SubmitResults, MessageBoxIcon.Warning);
}
}
}
else
{
ShowAlert("没有数据!", MessageBoxIcon.Warning);
return;
}
}
2024-07-03 17:45:57 +08:00
/// <summary>
/// 导入(新版)
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btnNewImport_Click(object sender, EventArgs e)
{
PageContext.RegisterStartupScript(Window2.GetShowReference(String.Format("WeldReportIn.aspx", "导入 - ")));
}
/// <summary>
/// 关闭导入弹出窗口
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void Window2_Close(object sender, WindowCloseEventArgs e)
{
InitTreeMenu();
}
2024-05-08 16:27:28 +08:00
private void SaveMethod(string LoginProjectId, string UserId, DataSet ds)
{
}
#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
/// <summary>
/// 关闭弹出窗口
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void Window1_Close(object sender, WindowCloseEventArgs e)
{
this.InitTreeMenu();//加载树
this.BindGrid();
}
/// <summary>
/// 查询
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void TextBox_TextChanged(object sender, EventArgs e)
{
this.BindGrid();
}
/// <summary>
/// 查询
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void Tree_TextChanged(object sender, EventArgs e)
{
this.InitTreeMenu();
this.BindGrid();
}
#endregion
#region
/// <summary>
/// 获取单位名称
/// </summary>
/// <param name="bigType"></param>
/// <returns></returns>
protected string ConvertUnitName(object UnitId)
{
string name = string.Empty;
if (UnitId != null)
{
var unit = BLL.Base_UnitService.GetUnit(UnitId.ToString());
if (unit != null)
{
name = unit.UnitName;
}
}
return name;
}
/// <summary>
/// 获取装置名称
/// </summary>
/// <param name="bigType"></param>
/// <returns></returns>
protected string ConvertInstallationCode(object InstallationId)
{
string name = string.Empty;
if (InstallationId != null)
{
var installation = BLL.Project_InstallationService.GetProject_InstallationByInstallationId(InstallationId.ToString());
if (installation != null)
{
name = installation.InstallationCode;
}
}
return name;
}
/// <summary>
/// 获取填报人
/// </summary>
/// <param name="bigType"></param>
/// <returns></returns>
protected string ConvertTabler(object Tabler)
{
string name = string.Empty;
if (Tabler != null)
{
var user = BLL.Sys_UserService.GetUsersByUserId(Tabler.ToString());
if (user != null)
{
name = user.UserName;
}
}
return name;
}
#endregion
}
}