From 99a1c6dd6aba878892c904a1577f9e2d8ad48d8b Mon Sep 17 00:00:00 2001 From: liyh Date: Thu, 4 Jul 2024 15:25:21 +0800 Subject: [PATCH] 22 --- HJGL/BLL/Common/Const.cs | 5 + HJGL/FineUIPro.Web/FineUIPro.Web.csproj | 8 + .../WeldingManage/WeldReport.aspx | 2 +- .../WeldingManage/WeldReportAdd.aspx | 319 ++++ .../WeldingManage/WeldReportAdd.aspx.cs | 1404 +++++++++++++++++ .../WeldReportAdd.aspx.designer.cs | 386 +++++ 6 files changed, 2123 insertions(+), 1 deletion(-) create mode 100644 HJGL/FineUIPro.Web/WeldingProcess/WeldingManage/WeldReportAdd.aspx create mode 100644 HJGL/FineUIPro.Web/WeldingProcess/WeldingManage/WeldReportAdd.aspx.cs create mode 100644 HJGL/FineUIPro.Web/WeldingProcess/WeldingManage/WeldReportAdd.aspx.designer.cs diff --git a/HJGL/BLL/Common/Const.cs b/HJGL/BLL/Common/Const.cs index 539ddf2..5c302ce 100644 --- a/HJGL/BLL/Common/Const.cs +++ b/HJGL/BLL/Common/Const.cs @@ -539,6 +539,11 @@ namespace BLL /// public const string HJGL_PreWeldReportMenuId = "8D92CA4E-F267-4175-9152-56F095668FC9"; + /// + /// 焊接日报录入 + /// + public const string HJGL_WeldReportAddMenuId = "B745D9CA-627D-41D4-AA4B-8A8593DF82C6"; + #endregion #region 热处理/硬度委托 diff --git a/HJGL/FineUIPro.Web/FineUIPro.Web.csproj b/HJGL/FineUIPro.Web/FineUIPro.Web.csproj index d6f8377..1d93411 100644 --- a/HJGL/FineUIPro.Web/FineUIPro.Web.csproj +++ b/HJGL/FineUIPro.Web/FineUIPro.Web.csproj @@ -1257,6 +1257,7 @@ + @@ -5571,6 +5572,13 @@ WeldReport.aspx + + WeldReportAdd.aspx + ASPXCodeBehind + + + WeldReportAdd.aspx + WeldReportEdit.aspx ASPXCodeBehind diff --git a/HJGL/FineUIPro.Web/WeldingProcess/WeldingManage/WeldReport.aspx b/HJGL/FineUIPro.Web/WeldingProcess/WeldingManage/WeldReport.aspx index 25de56b..0d6b419 100644 --- a/HJGL/FineUIPro.Web/WeldingProcess/WeldingManage/WeldReport.aspx +++ b/HJGL/FineUIPro.Web/WeldingProcess/WeldingManage/WeldReport.aspx @@ -53,7 +53,7 @@ OnClick="btnNewImport_Click"> + runat="server" OnClick="btnNew_Click" Hidden="true"> diff --git a/HJGL/FineUIPro.Web/WeldingProcess/WeldingManage/WeldReportAdd.aspx b/HJGL/FineUIPro.Web/WeldingProcess/WeldingManage/WeldReportAdd.aspx new file mode 100644 index 0000000..de9ffcd --- /dev/null +++ b/HJGL/FineUIPro.Web/WeldingProcess/WeldingManage/WeldReportAdd.aspx @@ -0,0 +1,319 @@ +<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WeldReportAdd.aspx.cs" Inherits="FineUIPro.Web.WeldingProcess.WeldingManage.WeldReportAdd" %> + + + + + + + 焊接日报录入 + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + <%----%> + + + + + + + + + + + + + + + + + + + + + + + + + <%-- + --%> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + <%-- + + + + + + + + + + + --%> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/HJGL/FineUIPro.Web/WeldingProcess/WeldingManage/WeldReportAdd.aspx.cs b/HJGL/FineUIPro.Web/WeldingProcess/WeldingManage/WeldReportAdd.aspx.cs new file mode 100644 index 0000000..4300883 --- /dev/null +++ b/HJGL/FineUIPro.Web/WeldingProcess/WeldingManage/WeldReportAdd.aspx.cs @@ -0,0 +1,1404 @@ +using System; +using System.Collections.Generic; +using System.Data; +using System.Data.SqlClient; +using System.Linq; +using System.Web.UI.WebControls; +using BLL; +using Newtonsoft.Json.Linq; +using static System.Windows.Forms.VisualStyles.VisualStyleElement; + +namespace FineUIPro.Web.WeldingProcess.WeldingManage +{ + public partial class WeldReportAdd : PageBase + { + #region 定义项 + + /// + /// 项目主键 + /// + public string ProjectId + { + get + { + return (string)ViewState["ProjectId"]; + } + set + { + ViewState["ProjectId"] = value; + } + } + #endregion + + #region 加载页面 + /// + /// 加载页面 + /// + /// + /// + protected void Page_Load(object sender, EventArgs e) + { + if (!IsPostBack) + { + this.ProjectId = this.CurrUser.LoginProjectId; + + ///焊缝类型 + Base_WeldTypeService.InitWeldTypeDropDownList(this.drpWeldType, Resources.Lan.PleaseSelect, false); + this.drpWeldType.DataTextField = "WeldTypeCode"; + this.drpWeldType.DataValueField = "WeldTypeCode"; + this.drpWeldType.DataSource = from x in Funs.DB.Base_WeldType orderby x.WeldTypeCode select x; + this.drpWeldType.DataBind(); + + ///焊接位置 + this.drpWeldingLocationId.DataTextField = "WeldingLocationCode"; + this.drpWeldingLocationId.DataValueField = "WeldingLocationCode"; + this.drpWeldingLocationId.DataSource = from x in Funs.DB.Base_WeldingLocation orderby x.WeldingLocationCode select x; + this.drpWeldingLocationId.DataBind(); + this.drpWeldingLocationId.SelectedIndex = 0; + + // 焊接方法 + this.drpWeldingMethod.DataTextField = "WeldingMethodCode"; + this.drpWeldingMethod.DataValueField = "WeldingMethodCode"; + this.drpWeldingMethod.DataSource = from x in Funs.DB.Base_WeldingMethod orderby x.WeldingMethodCode select x; + this.drpWeldingMethod.DataBind(); + this.drpWeldingMethod.SelectedIndex = 0; + + ///材质1 + Base_MaterialService.InitMaterialDropDownList(this.drpMaterial1); + ///材质2 + Base_MaterialService.InitMaterialDropDownList(this.drpMaterial2); + + // 组件1 + this.drpComponents1.DataTextField = "ComponentsCode"; + this.drpComponents1.DataValueField = "ComponentsCode"; + this.drpComponents1.DataSource = from x in Funs.DB.Base_Components orderby x.ComponentsCode select x; + this.drpComponents1.DataBind(); + this.drpComponents1.SelectedIndex = 0; + + // 组件2 + this.drpComponents2.DataTextField = "ComponentsCode"; + this.drpComponents2.DataValueField = "ComponentsCode"; + this.drpComponents2.DataSource = from x in Funs.DB.Base_Components orderby x.ComponentsCode select x; + this.drpComponents2.DataBind(); + this.drpComponents2.SelectedIndex = 0; + + // 焊丝 + this.drpWeldSilkCode.DataTextField = "ConsumablesCode"; + this.drpWeldSilkCode.DataValueField = "ConsumablesCode"; + this.drpWeldSilkCode.DataSource = from x in Funs.DB.Base_Consumables where x.ConsumablesType == "1" orderby x.ConsumablesCode select x; + this.drpWeldSilkCode.DataBind(); + Funs.FineUIPleaseSelect(drpWeldSilkCode); + //this.drpWeldSilkCode.SelectedIndex = 0; + + // 焊条 + this.drpWeldMatCode.DataTextField = "ConsumablesCode"; + this.drpWeldMatCode.DataValueField = "ConsumablesCode"; + this.drpWeldMatCode.DataSource = from x in Funs.DB.Base_Consumables where x.ConsumablesType == "2" orderby x.ConsumablesCode select x; + this.drpWeldMatCode.DataBind(); + Funs.FineUIPleaseSelect(drpWeldMatCode); + this.drpWeldMatCode.SelectedIndex = 0; + + ///焊接属性 + this.drpJointAttribute.DataTextField = "Text"; + this.drpJointAttribute.DataValueField = "Value"; + this.drpJointAttribute.DataSource = BLL.DropListService.HJGL_JointAttributeItem(); + this.drpJointAttribute.DataBind(); + + var wpsList = from x in Funs.DB.WPQ_WPQList where x.ProjectId == CurrUser.LoginProjectId select x; + drpWPS.DataValueField = "WPQCode"; + drpWPS.DataTextField = "WPQCode"; + drpWPS.DataSource = wpsList.ToList().OrderBy(x => x.WPQCode); + drpWPS.DataBind(); + Funs.FineUIPleaseSelect(drpWPS); + + // 物料码 + BLL.MaterialCoodeService.InitMaterialCoodeDropDownList(this.drpCoode1, this.CurrUser.LoginProjectId, true, Resources.Lan.PleaseSelect);//Coode1 + BLL.MaterialCoodeService.InitMaterialCoodeDropDownList(this.drpCoode2, this.CurrUser.LoginProjectId, true, Resources.Lan.PleaseSelect);//Coode2 + + + List GetWeldingDailyItem = new List(); + this.BindGrid(GetWeldingDailyItem); // 初始化页面 + this.PageInfoLoad(); // 加载页面 + //this.CalculationAmount(); + } + } + #endregion + + #region 超量焊工提示 + /// + /// 超量焊工提示 + /// + //private void CalculationAmount() + //{ + // this.lbAmount.Hidden = true; + // this.lbAmount.Text = string.Empty; + // DateTime? date = Funs.GetNewDateTime(this.txtWeldingDate.Text); + // string txtValue = string.Empty; + // if (date.HasValue) + // { + // var weldJoints = BLL.Pipeline_WeldJointService.GetWeldlinesByWeldingDailyId(this.WeldingDailyId); + // foreach (var item in weldJoints) + // { + // bool cWelder = BLL.Pipeline_WeldJointService.GetWelderLimitDN(this.ProjectId, item.CoverWelderId, date.Value); + // bool bWelder = cWelder; + // if (item.BackingWelderId != item.CoverWelderId) + // { + // bWelder = BLL.Pipeline_WeldJointService.GetWelderLimitDN(this.ProjectId, item.BackingWelderId, date.Value); + // } + // if (cWelder || bWelder) + // { + // if (cWelder) + // { + // var coverWelder = BLL.WelderService.GetWelderById(item.CoverWelderId); + // if (coverWelder != null) + // { + // string txt = coverWelder.WelderCode + ";"; + // if (!txtValue.Contains(txt)) + // { + // txtValue += txt; + // } + // } + // } + // if (bWelder) + // { + // var floorWelder = BLL.WelderService.GetWelderById(item.BackingWelderId); + // if (floorWelder != null) + // { + // string txt = floorWelder.WelderCode + ";"; + // if (!txtValue.Contains(txt)) + // { + // txtValue += txt; + // } + // } + // } + // } + // } + // } + // if (!string.IsNullOrEmpty(txtValue)) + // { + // this.lbAmount.Text = txtValue; + // this.lbAmount.Hidden = false; + // } + //} + #endregion + + #region 加载页面输入提交信息 + /// + /// 加载页面输入提交信息 + /// + private void PageInfoLoad() + { + BLL.Base_UnitService.InitProjectUnitDropDownList(this.drpUnit, true, this.ProjectId, BLL.Const.UnitType_5, Resources.Lan.PleaseSelect); + this.drpUnit.SelectedIndex = 1; + var u = BLL.Project_UnitService.GetProject_UnitByProjectIdUnitId(CurrUser.LoginProjectId, CurrUser.UnitId); + if (u != null && u.UnitType == BLL.Const.UnitType_5) + { + BLL.Project_InstallationService.InitInstallationDropDownList(this.drpInstallation, true, CurrUser.LoginProjectId, CurrUser.UnitId, Resources.Lan.PleaseSelect); + drpUnit.SelectedValue = CurrUser.UnitId; + drpUnit.Enabled = false; + } + else + { + BLL.Project_InstallationService.InitInstallationDropDownList(this.drpInstallation, true, this.ProjectId, Resources.Lan.PleaseSelect); + } + + this.SimpleForm1.Reset(); ///重置所有字段 + this.txtTabler.Text = this.CurrUser.UserName; + this.hdTablerId.Text = this.CurrUser.UserId; + this.txtWeldingDate.Text = string.Format("{0:yyyy-MM-dd}", System.DateTime.Now); + this.txtTableDate.Text = string.Format("{0:yyyy-MM-dd}", System.DateTime.Now); + string perfix = string.Format("{0:yyyyMMdd}", System.DateTime.Now) + "-"; + this.txtWeldingDailyCode.Text = BLL.SQLHelper.RunProcNewId("SpGetThreeNumber", "dbo.Pipeline_WeldingDaily", "WeldingDailyCode", this.CurrUser.LoginProjectId, perfix); + + } + #endregion + + #region 单位下拉框变化加载对应的焊工信息 + /// + /// 单位下拉框变化加载对应的焊工信息 + /// + /// + /// + protected void drpUnit_SelectedIndexChanged(object sender, EventArgs e) + { + this.drpCoverWelderId.Items.Clear(); + this.drpBackingWelderId.Items.Clear(); + if (this.drpUnit.SelectedValue != BLL.Const._Null) + { + BLL.Project_InstallationService.InitInstallationDropDownList(this.drpInstallation, true, CurrUser.LoginProjectId, drpUnit.SelectedValue, Resources.Lan.PleaseSelect); + BLL.WelderService.InitProjectWelderCodeDropDownList(this.drpCoverWelderId, false, this.ProjectId, this.drpUnit.SelectedValue, Resources.Lan.PleaseSelect); + BLL.WelderService.InitProjectWelderCodeDropDownList(this.drpBackingWelderId, false, this.ProjectId, this.drpUnit.SelectedValue, Resources.Lan.PleaseSelect); + } + } + #endregion + + #region 数据绑定 + /// + /// 数据绑定 + /// + private void BindGrid(List GetWeldingDailyItem) + { + DataTable tb = this.LINQToDataTable(GetWeldingDailyItem); + // 2.获取当前分页数据 + //var table = this.GetPagedDataTable(GridNewDynamic, tb1); + Grid1.RecordCount = tb.Rows.Count; + tb = GetFilteredTable(Grid1.FilteredData, tb); + var table = this.GetPagedDataTable(Grid1, tb); + + Grid1.DataSource = table; + Grid1.DataBind(); + } + #endregion + + #region 排序 + /// + /// 排序 + /// + /// + /// + protected void Grid1_Sort(object sender, GridSortEventArgs e) + { + List GetWeldingDailyItem = this.CollectGridJointInfo(); + this.BindGrid(GetWeldingDailyItem); + } + #endregion + + private static bool canSave; //是否可以保存 + + #region 焊接日报 提交事件 + /// + /// 编辑焊接日报 + /// + /// + /// + protected void btnSave_Click(object sender, EventArgs e) + { + if (CommonService.GetAllButtonPowerList(this.ProjectId, this.CurrUser.UserId, Const.HJGL_WeldReportAddMenuId, Const.BtnAdd)) + { + if (BLL.Pipeline_WeldingDailyService.IsExistWeldingDailyCode(this.txtWeldingDailyCode.Text, "", this.ProjectId)) + { + ShowNotify(Resources.Lan.WeldingReportExists, MessageBoxIcon.Warning); + return; + } + if (string.IsNullOrEmpty(this.txtWeldingDate.Text) || string.IsNullOrEmpty(this.txtWeldingDailyCode.Text.Trim())) + { + ShowNotify(Resources.Lan.WeldingNumDateIsNotNull, MessageBoxIcon.Warning); + return; + } + + string eventArg = string.Empty; + List GetWeldingDailyItem = this.CollectGridJointInfo(); + //过滤一次 如果 + GetWeldingDailyItem = GetWeldingDailyItem.FindAll(p => !string.IsNullOrWhiteSpace(p.CoverWelderCode) && !string.IsNullOrWhiteSpace(p.BackingWelderCode)); + if (GetWeldingDailyItem.Count <= 0) { + ShowNotify("请录入管线信息!!!", MessageBoxIcon.Warning); + return; + } + + + // 判断Coode数量 + string coodeNumError = string.Empty; + var coode1Group = GetWeldingDailyItem.GroupBy(x => x.CoodeHeartNo1).Select(g => g.Key); + var coode2Group = GetWeldingDailyItem.GroupBy(x => x.CoodeHeartNo2).Select(g => g.Key); + var coodeListGroup = coode1Group.Union(coode2Group).Distinct(); + string[] jotList = GetWeldingDailyItem.Select(x => x.WeldJointId).ToArray(); + foreach (var c in coodeListGroup) + { + if (c.Contains(":")) + { + string coode = c.Split(':')[0]; + string heartNo = c.Split(':')[1]; + var coodeNum = from x in Funs.DB.Base_MaterialCoode + where x.ProjectId == this.CurrUser.LoginProjectId + && x.Coode == coode && x.HeartNo == heartNo + select x; + int daily1 = (from x in GetWeldingDailyItem where x.CoodeHeartNo1 == c select x).Count(); + int daily2 = (from x in GetWeldingDailyItem where x.CoodeHeartNo2 == c select x).Count(); + int jotCoode1 = (from x in Funs.DB.Pipeline_WeldJoint + where x.ProjectId == this.CurrUser.LoginProjectId + && x.Coode1 == coode && x.HeartNo1 == 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 == coode && x.HeartNo2 == 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:" + coode + "对应的炉批号:" + heartNo + "的数量已超出,"; + } + } + } + + } + if (!string.IsNullOrEmpty(coodeNumError)) + { + coodeNumError = coodeNumError + "请检查后再录入"; + } + + #region 焊工合格项目资质判断 + foreach (var item in GetWeldingDailyItem) + { + bool canSave = false; + var jot = BLL.Pipeline_WeldJointService.GetWeldJointByWeldJointId(item.WeldJointId); + var joty = BLL.Base_WeldTypeService.GetWeldTypeByWeldTypeId(jot.WeldTypeId); + string weldTypeGroup = joty.Flag; + string weldTypeCode = joty.WeldTypeCode; + string floorWelder = item.BackingWelderId; + string cellWelder = item.CoverWelderId; + decimal? dia = item.Dia; + decimal? sch = item.Thickness; + //string wme = item.WeldingMethodCode; + //string wmeCode = string.Empty; + //var wm = BLL.HJGL_WeldingMethodService.GetWeldMethodByWMEID(item.WME_ID); + //if (wm != null) + //{ + // wmeCode = wm.WME_Code; + //} + + string[] wmeCodes = item.WeldingMethodCode.Split('+'); + string location = item.WeldingLocationCode; + string ste = jot.Material1Id; + var projectWelder = BLL.Welder_ProjectWelderService.GetProjectWelderByProjectIdAndWelderId(this.ProjectId, item.BackingWelderId); + var projectUnit = BLL.Project_UnitService.GetProject_UnitByProjectIdUnitId(this.ProjectId, projectWelder.UnitId); + if (projectUnit != null && projectUnit.WelderQueIsUse == true) + { + List 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 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); + } + } + } + else + { + canSave = true; + } + + if (canSave == false) + { + eventArg = eventArg + jot.WeldJointCode + ","; + } + } + #endregion + + #region 生成管线的随机数 不用了 + //var pro = BLL.Base_ProjectService.GetProjectByProjectId(this.ProjectId); + //// 生成管线的随机数 + //var romPipe = (from x in GetWeldingDailyItem + // join y in Funs.DB.Pipeline_WeldJoint on x.WeldJointId equals y.WeldJointId + // select y.PipelineId).Distinct(); + //if (romPipe.Count() > 0) + //{ + // foreach (string pipeId in romPipe) + // { + // var iso = BLL.Pipeline_PipelineService.GetPipelineByPipelineId(pipeId); + // var pipe = Funs.DB.View_Pipeline_Random.FirstOrDefault(x => x.PipelineId == pipeId); + // int rate = Convert.ToInt32(pipe.DetectionRateValue); + // if (rate != 0) + // { + // // RT 随机数 + // int rtTotalJotNum = Convert.ToInt32(pipe.RTTotalJointCount); + // // 已焊焊口数 + // int rtWeldingJotNum = Convert.ToInt32(pipe.RTWeldingCount); + // // 已点口数 + // int rtPointNum = Convert.ToInt32(pipe.RtPointCount); + // int rtMinValue = rtWeldingJotNum + 1; + // int rtMaxValue = rtTotalJotNum; + + // if (pro.ProjectArea == "2") + // { + // // RT 活动口按管线比例 + // int rtPointTotalNum = Convert.ToInt32(Math.Ceiling((double)(rtTotalJotNum * rate) / (double)100)); + // int rtnum = rtPointTotalNum - rtPointNum; + + // if (rtnum > 0) + // { + // int[] r = Funs.GetRandomNum(rtnum, rtMinValue, rtMaxValue); + // var q = from x in r orderby x select x; + // string random = string.Empty; + // foreach (int i in q) + // { + // if (i <= rtMaxValue) + // { + // random = random + i.ToString() + ","; + // } + // } + // if (random.Length > 0) + // { + // string randomNum = random.Substring(0, random.Length - 1); + // Pipeline_PipelineService.UpdatePipelineRTRandom(pipeId, randomNum); + // } + // } + // } + // else //福建: RT检测先按比例分段点口 + // { + // int oldRandomNum = 0; + // if (iso != null && !string.IsNullOrEmpty(iso.RandomNum)) + // { + // oldRandomNum = iso.RandomNum.Split(',').Count(); + // } + + // int totalJotNum = Convert.ToInt32(pipe.TotalJointCount); + // // 分段num1为向上取整 + // int num1 = Convert.ToInt32(Math.Ceiling((double)(totalJotNum * rate) / (double)100)); + // // num2为向下取整 + // int num2 = Convert.ToInt32(Math.Floor((double)(totalJotNum * rate) / (double)100)); + + // // 如相等说明随机数已产生,并符合数量,否则重新计算 + // if (oldRandomNum != num1) + // { + // int min = 1; + // int max = Convert.ToInt32(Math.Ceiling((double)(100) / (double)(rate))); + // string random = string.Empty; + // for (int i = 1; i <= num2; i++) + // { + // int[] r = Funs.GetRandomNum(1, min, max); + // random = random + r[0] + ","; + // } + // if (num1 > num2) + // { + // int y = totalJotNum - (num2 * max); + // int[] r = Funs.GetRandomNum(1, min, y); + // random = random + r[0] + ","; + // } + + // if (random.Length > 0) + // { + // string randomNum = random.Substring(0, random.Length - 1); + // Pipeline_PipelineService.UpdatePipelineRTRandom(pipeId, randomNum); + // } + // } + + // #region 暂不用:固定口(大于管线检测比例的40%,这里按50%计算) 随机数 + // // 先优先点固定口(大于管线检测比例的40%,这里按50%计算) 随机数 + // //int gdTotalJotNum = Convert.ToInt32(pipe.GDTotalJointCount); + // //int gdWeldingJotNum = Convert.ToInt32(pipe.GDWeldingCount); + // //int gdPointNum = Convert.ToInt32(pipe.GDPointCount); + // //int gdMinValue = gdWeldingJotNum + 1; + // //int gdMaxValue = gdTotalJotNum; + + // //int gdPointTotalNum = Convert.ToInt32(Math.Ceiling((double)(totalJotNum * rate * 0.5) / (double)100)); + // //int gdnum = gdPointTotalNum - gdPointNum; + + // //int gdRandomCount = 0; + // //if (gdnum > 0) + // //{ + // // string random = string.Empty; + // // if (gdnum > gdMaxValue) // 说明固定口数量不够,所以所有固定口都点 + // // { + // // for (int i = gdMinValue; i <= gdMaxValue; i++) + // // { + // // random = random + i.ToString() + ","; + // // } + // // gdRandomCount = gdMaxValue - gdMinValue + 1; + // // } + // // else + // // { + // // int[] r = Funs.GetRandomNum(gdnum, gdMinValue, gdMaxValue); + // // var q = from x in r orderby x select x; + // // foreach (int i in q) + // // { + // // if (i <= gdMaxValue) + // // { + // // random = random + i.ToString() + ","; + // // } + // // } + // // gdRandomCount = q.Count(); + // // } + // // if (random.Length > 0) + // // { + // // string randomNum = random.Substring(0, random.Length - 1); + // // Pipeline_PipelineService.UpdatePipelineGDRandom(pipeId, randomNum); + // // } + + // //} + + // //// 活动口 + // //// RT 活动口按管线比例 + // //int pointTotalNum = Convert.ToInt32(Math.Ceiling((double)(totalJotNum * rate) / (double)100)); + // //int rtnum = pointTotalNum - rtPointNum - gdPointNum - gdRandomCount; + + // //if (rtnum > 0) + // //{ + // // string random = string.Empty; + // // if (rtnum > rtMaxValue) // 说明活动口数量不够,所以所有活动口都点 + // // { + // // for (int i = rtMinValue; i <= rtMaxValue; i++) + // // { + // // random = random + i.ToString() + ","; + // // } + // // } + // // else + // // { + // // int[] r = Funs.GetRandomNum(rtnum, rtMinValue, rtMaxValue); + // // var q = from x in r orderby x select x; + // // foreach (int i in q) + // // { + // // if (i <= rtMaxValue) + // // { + // // random = random + i.ToString() + ","; + // // } + // // } + // // } + // // if (random.Length > 0) + // // { + // // string randomNum = random.Substring(0, random.Length - 1); + // // Pipeline_PipelineService.UpdatePipelineRTRandom(pipeId, randomNum); + // // } + // //} + // #endregion + // } + + // // PT 随机数 + // int ptTotalJotNum = Convert.ToInt32(pipe.PTTotalJointCount); + // int ptWeldingJotNum = Convert.ToInt32(pipe.PTWeldingCount); + // int ptPointNum = Convert.ToInt32(pipe.PtPointCount); + // int ptMinValue = ptWeldingJotNum + 1; + // int ptMaxValue = ptTotalJotNum; + + // int ptPointTotalNum = Convert.ToInt32(Math.Ceiling((double)(ptTotalJotNum * rate) / (double)100)); + // int ptnum = ptPointTotalNum - ptPointNum; + + // if (ptnum > 0) + // { + // int[] r = Funs.GetRandomNum(ptnum, ptMinValue, ptMaxValue); + // var q = from x in r orderby x select x; + // string random = string.Empty; + // foreach (int i in q) + // { + // if (i <= ptMaxValue) + // { + // random = random + i.ToString() + ","; + // } + // } + // if (random.Length > 0) + // { + // string randomNum = random.Substring(0, random.Length - 1); + // Pipeline_PipelineService.UpdatePipelinePTRandom(pipeId, randomNum); + // } + // } + // } + // } + //} + #endregion + + if (!string.IsNullOrEmpty(coodeNumError)) + { + ShowNotify(coodeNumError, MessageBoxIcon.Warning, 10000); + return; + } + // 焊工资质都符合条件 + else if (eventArg == string.Empty) + { + Model.Pipeline_WeldingDaily newWeldingDaily = new Model.Pipeline_WeldingDaily(); + newWeldingDaily.WeldingDailyCode = this.txtWeldingDailyCode.Text.Trim(); + newWeldingDaily.ProjectId = this.ProjectId; + if (this.drpInstallation.SelectedValue != BLL.Const._Null) + { + newWeldingDaily.InstallationId = this.drpInstallation.SelectedValue; + } + newWeldingDaily.UnitId = this.drpUnit.SelectedValue; + DateTime? weldDate = Funs.GetNewDateTime(this.txtWeldingDate.Text); + if (weldDate.HasValue) + { + newWeldingDaily.WeldingDate = weldDate.Value; + } + else + { + newWeldingDaily.WeldingDate = System.DateTime.Now; + } + newWeldingDaily.Tabler = this.hdTablerId.Text; + newWeldingDaily.TableDate = Funs.GetNewDateTime(this.txtTableDate.Text); + newWeldingDaily.Remark = this.txtRemark.Text.Trim(); + + newWeldingDaily.WeldingDailyId = SQLHelper.GetNewID(typeof(Model.Pipeline_WeldingDaily)); + BLL.Pipeline_WeldingDailyService.AddPipeline_WeldingDaily(newWeldingDaily); + BLL.Sys_LogService.AddLog(BLL.Const.System_3, this.CurrUser.LoginProjectId, this.CurrUser.UserId, Const.HJGL_WeldReportMenuId, Const.BtnAdd, newWeldingDaily.WeldingDailyId); + + foreach (var item in GetWeldingDailyItem) + { + var newWeldJoint = BLL.Pipeline_WeldJointService.GetWeldJointByWeldJointId(item.WeldJointId); + //var pipeline = BLL.Pipeline_PipelineService.GetPipelineByPipelineId(newWeldJoint.PipelineId); + //var joty = BLL.Base_WeldTypeService.GetWeldTypeByWeldTypeId(item.WeldTypeId); + //string weldTypeCode = joty.WeldTypeCode; + + newWeldJoint.WeldingDailyId = newWeldingDaily.WeldingDailyId; + newWeldJoint.WeldingDailyCode = this.txtWeldingDailyCode.Text.Trim(); + newWeldJoint.CoverWelderId = item.CoverWelderId; + newWeldJoint.BackingWelderId = item.BackingWelderId; + newWeldJoint.Size = item.Size; + newWeldJoint.DoneDin = item.Size; + newWeldJoint.Dia = item.Dia; + newWeldJoint.Thickness = item.Thickness; + if (item.Dia != null && item.Thickness != null) + { + newWeldJoint.Specification = "Φ" + Funs.GetClearZero(item.Dia.Value) + "×" + Funs.GetClearZero(item.Thickness.Value); + } + newWeldJoint.JointAttribute = item.JointAttribute; + newWeldJoint.JointArea = item.JointArea; + newWeldJoint.WeldingLocationId = item.WeldingLocationId; + newWeldJoint.Material1Id = item.MaterialId1; + newWeldJoint.Material2Id = item.MaterialId2; + if (item.CoodeHeartNo1.Contains(":")) + { + newWeldJoint.Coode1 = item.CoodeHeartNo1.Split(':')[0]; + newWeldJoint.HeartNo1 = item.CoodeHeartNo1.Split(':')[1]; + } + if (item.CoodeHeartNo2.Contains(":")) + { + newWeldJoint.Coode2 = item.CoodeHeartNo2.Split(':')[0]; + newWeldJoint.HeartNo2 = item.CoodeHeartNo2.Split(':')[1]; + } + newWeldJoint.PipeAssembly1Id = item.Components1Id; + newWeldJoint.PipeAssembly2Id = item.Components2Id; + newWeldJoint.WeldingMethodId = item.WeldingMethodId; + newWeldJoint.WeldMatId = item.WeldMatId; + newWeldJoint.WeldSilkId = item.WeldSilkId; + newWeldJoint.WeldingDate = newWeldingDaily.WeldingDate; + 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.ProjectId, this.drpUnit.SelectedValue, this.drpInstallation.SelectedValue, item.BackingWelderId, item.CoverWelderId, item.WeldJointId, newWeldingDaily.WeldingDate); + + } + + #region 新建日报及焊工每天超过60达因的提示(暂不用) + //// 新建日报 + //if (weldlines.Count() == 0) + //{ + // foreach (var item in GetWeldingDailyItem) + // { + // errlog += InsertWeldingDailyItem(item, newWeldingDaily.WeldingDate, true,newWeldingDaily.WeldingDailyId); + // } + //} + + //// 日报已存在的情况 + //else + //{ + // var weldJoints = from x in weldlines select x.WeldJointId; + // foreach (var item in GetWeldingDailyItem) + // { + // // 如日报明细存在则只更新焊口信息,如进批条件改变,则只有删除后再重新增加 + // if (weldJoints.Contains(item.WeldJointId)) + // { + // var newWeldJoint = BLL.Pipeline_WeldJointService.GetWeldJointByWeldJointId(item.WeldJointId); + // newWeldJoint.WeldingDailyId = this.WeldingDailyId; + // newWeldJoint.WeldingDailyCode = this.txtWeldingDailyCode.Text.Trim(); + // //newWeldJoint.CoverWelderId = item.CoverWelderId; + // //newWeldJoint.BackingWelderId = item.BackingWelderId; + // newWeldJoint.WeldTypeId = item.WeldTypeId; + // //newWeldJoint.JointArea = item.JointArea; + // newWeldJoint.DoneDin = item.DoneDin; + // if (!string.IsNullOrEmpty(item.JointAttribute)) + // { + // newWeldJoint.JointAttribute = item.JointAttribute; + // if (item.JointAttribute == "活动S") + // { + // newWeldJoint.JointArea = "S"; + // } + // else + // { + // newWeldJoint.JointArea = "F"; + // } + // } + + + // newWeldJoint.WeldingLocationId = item.WeldingLocationId; + // BLL.Pipeline_WeldJointService.UpdateWeldJoint(newWeldJoint); + // //更新焊口号 修改固定焊口号后 +G + // //BLL.Pipeline_WeldJointService.UpdateWeldJointAddG(newWeldJoint.WeldJointId, newWeldJoint.JointAttribute, Const.BtnAdd); + + // } + // else + // { + // errlog += InsertWeldingDailyItem(item, newWeldingDaily.WeldingDate, true,newWeldingDaily.WeldingDailyId); + // } + // } + //} + + + + // 焊工每天超过60达因的提示(暂不用) + //foreach (var item in GetWeldingDailyItem) + //{ + // if (!string.IsNullOrEmpty(item.CoverWelderId) && !string.IsNullOrEmpty(item.BackingWelderId)) + // { + // bool cWelder = BLL.Pipeline_WeldJointService.GetWelderLimitDN(this.ProjectId, item.CoverWelderId, newWeldingDaily.WeldingDate.Value); + // bool bWelder = cWelder; + // if (item.CoverWelderId != item.BackingWelderId) + // { + // bWelder = BLL.Pipeline_WeldJointService.GetWelderLimitDN(this.ProjectId, item.BackingWelderId, newWeldingDaily.WeldingDate.Value); + // } + + // if (cWelder || bWelder) + // { + // if (cWelder) + // { + // var coverWelder = BLL.WelderService.GetWelderById(item.CoverWelderId); + // if (coverWelder != null) + // { + // string txt = Resources.Lan.WelderCode + coverWelder.WelderCode + Resources.Lan.WeldingDiameter; + // if (!errlog.Contains(txt)) + // { + // errlog += txt; + // } + // } + // } + + // if (bWelder) + // { + // var backingWelder = BLL.WelderService.GetWelderById(item.BackingWelderId); + // if (backingWelder != null) + // { + // string txt = Resources.Lan.WelderCode + backingWelder.WelderCode + Resources.Lan.WeldingDiameter; + // if (!errlog.Contains(txt)) + // { + // errlog += txt; + // } + // } + // } + // } + // } + //} + + #endregion + + Alert.Show(Resources.Lan.SaveSuccessfully, MessageBoxIcon.Success); + + //重新刷新页面,恢复初始化状态 + PageContext.RegisterStartupScript("location.reload(); "); + + } + else + { + Alert.ShowInTop(Resources.Lan.NoQualification + "【" + eventArg + "】" + Resources.Lan.WeldingConditions, Resources.Lan.SubmitResults, MessageBoxIcon.Warning); + } + } + else + { + ShowNotify(Resources.Lan.NoPrivilegePrompt, MessageBoxIcon.Warning); + return; + } + } + #endregion + + #region 日报明细插入(更新焊口信息),组批等 (暂不用) + /// + /// 日报明细插入(更新焊口信息),组批等 + /// + /// + /// + /// + private string InsertWeldingDailyItem(Model.SpWeldingDailyItem item, DateTime? weldingDate, bool isSave,string WeldingDailyId) + { + string errlog = string.Empty; + var newWeldJoint = BLL.Pipeline_WeldJointService.GetWeldJointByWeldJointId(item.WeldJointId); + var pipeline = BLL.Pipeline_PipelineService.GetPipelineByPipelineId(newWeldJoint.PipelineId); + + if (newWeldJoint != null && string.IsNullOrEmpty(newWeldJoint.WeldingDailyId)) + { + if (!string.IsNullOrEmpty(item.CoverWelderId) && !string.IsNullOrEmpty(item.BackingWelderId)) + { + + canSave = true; + + if (canSave == true) //全部条件符合 + { + if (isSave) + { + newWeldJoint.WeldingDailyId = WeldingDailyId; + newWeldJoint.WeldingDailyCode = this.txtWeldingDailyCode.Text.Trim(); + newWeldJoint.CoverWelderId = item.CoverWelderId; + newWeldJoint.BackingWelderId = item.BackingWelderId; + newWeldJoint.WeldTypeId = item.WeldTypeId; + newWeldJoint.JointArea = item.JointArea; + newWeldJoint.DoneDin = item.DoneDin; + newWeldJoint.JointAttribute = item.JointAttribute; + newWeldJoint.WeldingLocationId = item.WeldingLocationId; + BLL.Pipeline_WeldJointService.UpdateWeldJoint(newWeldJoint); + //更新焊口号 修改固定焊口号后 +G + //BLL.Pipeline_WeldJointService.UpdateWeldJointAddG(newWeldJoint.WeldJointId, newWeldJoint.JointAttribute, Const.BtnAdd); + + // 进批 + //BLL.Batch_PointBatchItemService.InsertPointBatch(this.ProjectId, this.drpUnit.SelectedValue, this.drpInstallation.SelectedValue, item.CoverWelderId, item.WeldJointId, weldingDate); + } + } + else + { + errlog = Resources.Lan.NoQualification + "【" + newWeldJoint.WeldJointCode + "】" + Resources.Lan.WeldingConditions; + } + + + } + else + { + errlog = Resources.Lan.WeldingJoint + "【" + newWeldJoint.WeldJointCode + "】" + Resources.Lan.NoWelderSelected; + } + } + + return errlog; + } + #endregion + + #region 收集Grid页面信息 + /// + /// 收集Grid页面信息 + /// + /// + private List CollectGridJointInfo() + { + List GetWeldingDailyItem = null; + List getNewWeldReportItem = new List(); + if (!string.IsNullOrEmpty(this.hdItemsString.Text)) + { + GetWeldingDailyItem = BLL.Pipeline_WeldingDailyService.GetWeldReportAddItem(this.hdItemsString.Text); + } + + JArray mergedData = Grid1.GetMergedData(); + foreach (JObject mergedRow in mergedData) + { + string status = mergedRow.Value("status"); + JObject values = mergedRow.Value("values"); + + string rowID = values.Value("WeldJointId").ToString(); + var item = GetWeldingDailyItem.FirstOrDefault(x => x.WeldJointId == rowID); + if (item != null) + { + var coverWelderCode = (from x in Funs.DB.Welder_Welder + join y in Funs.DB.Welder_ProjectWelder + on x.WelderId equals y.WelderId + where y.ProjectId == this.ProjectId && x.WelderCode == values.Value("CoverWelderId") + select x).FirstOrDefault(); + if (coverWelderCode != null) + { + item.CoverWelderCode = coverWelderCode.WelderCode; + item.CoverWelderId = coverWelderCode.WelderId; + } + var backingWelderCode = (from x in Funs.DB.Welder_Welder + join y in Funs.DB.Welder_ProjectWelder + on x.WelderId equals y.WelderId + where y.ProjectId == this.ProjectId && x.WelderCode == values.Value("BackingWelderId") + select x).FirstOrDefault(); + if (backingWelderCode != null) + { + item.BackingWelderCode = backingWelderCode.WelderCode; + item.BackingWelderId = backingWelderCode.WelderId; + } + var weldType = (from x in Funs.DB.Base_WeldType + where x.WeldTypeCode == values.Value("WeldTypeId") + select x).FirstOrDefault(); + if (weldType != null) + { + item.WeldTypeId = weldType.WeldTypeId; + } + //item.JointArea = values.Value("JointArea").ToString(); + if (!string.IsNullOrEmpty(values.Value("JointAttribute"))) + { + item.JointAttribute = values.Value("JointAttribute").ToString(); + if (item.JointAttribute == "S") + { + item.JointArea = "S"; + } + else + { + item.JointArea = "F"; + } + } + + var weldingLocation = (from x in Funs.DB.Base_WeldingLocation + where x.WeldingLocationCode == values.Value("WeldingLocationId") + select x).FirstOrDefault(); + if (weldingLocation != null) + { + item.WeldingLocationId = weldingLocation.WeldingLocationId; + } + item.Size = Funs.GetNewDecimalOrZero(values.Value("DoneDin").ToString()); + item.DoneDin = Funs.GetNewDecimalOrZero(values.Value("DoneDin").ToString()); + + item.CoodeHeartNo1 = values.Value("CoodeHeartNo1").ToString(); + item.CoodeHeartNo2 = values.Value("CoodeHeartNo2").ToString(); + + var wmt = (from x in Funs.DB.Base_WeldingMethod + where x.WeldingMethodCode == values.Value("WeldingMethodCode") + select x).FirstOrDefault(); + if (wmt != null) + { + item.WeldingMethodId = wmt.WeldingMethodId; + } + + var mat1 = (from x in Funs.DB.Base_Material + where x.MaterialCode == values.Value("Material1Code") + select x).FirstOrDefault(); + if (mat1 != null) + { + item.MaterialId1 = mat1.MaterialId; + } + + var mat2 = (from x in Funs.DB.Base_Material + where x.MaterialCode == values.Value("Material2Code") + select x).FirstOrDefault(); + if (mat2 != null) + { + item.MaterialId2 = mat2.MaterialId; + } + + + var com1 = (from x in Funs.DB.Base_Components + where x.ComponentsCode == values.Value("Components1Code") + select x).FirstOrDefault(); + if (com1 != null) + { + item.Components1Id = com1.ComponentsId; + } + var com2 = (from x in Funs.DB.Base_Components + where x.ComponentsCode == values.Value("Components2Code") + select x).FirstOrDefault(); + if (com2 != null) + { + item.Components2Id = com2.ComponentsId; + } + + //var weldSilk = (from x in Funs.DB.Base_Consumables + // where x.ConsumablesCode == values.Value("WeldSilkCode") + // select x).FirstOrDefault(); + string WeldSilkCodes = values.Value("WeldSilkCode"); + if (!string.IsNullOrEmpty(WeldSilkCodes)) + { + string weldSilkIds = string.Empty; + string[] weldSilkCodes = WeldSilkCodes.Split(','); + if (weldSilkCodes.Count() > 0) + { + foreach (string s in weldSilkCodes) + { + var silk = Funs.DB.Base_Consumables.FirstOrDefault(e => e.ConsumablesCode == s); + if (silk != null) + { + weldSilkIds = weldSilkIds + silk.ConsumablesId + ','; + } + + } + if (weldSilkIds.Length > 0) + { + weldSilkIds = weldSilkIds.Substring(0, weldSilkIds.Length - 1); + } + } + item.WeldSilkId = weldSilkIds; + } + //if (weldSilk != null) + //{ + // item.WeldSilkId = weldSilk.ConsumablesId; + //} + + var weldMat = (from x in Funs.DB.Base_Consumables + where x.ConsumablesCode == values.Value("WeldMatCode") + select x).FirstOrDefault(); + if (weldMat != null) + { + item.WeldMatId = weldMat.ConsumablesId; + } + + item.PipeSegment = values.Value("PipeSegment").ToString(); + + var wps = (from x in Funs.DB.WPQ_WPQList + where x.WPQCode == values.Value("WPQCode") && x.ProjectId == CurrUser.LoginProjectId + select x).FirstOrDefault(); + if (wps != null) + { + item.WPQId = wps.WPQId; + } + + getNewWeldReportItem.Add(item); + } + + } + return getNewWeldReportItem; + } + #endregion + + #region Grid 关闭弹出窗口事件 + /// + /// 关闭弹出窗口 + /// + /// + /// + protected void Window1_Close(object sender, WindowCloseEventArgs e) + { + List GetWeldingDailyItem = BLL.Pipeline_WeldingDailyService.GetWeldReportAddItem(this.hdItemsString.Text); + this.BindGrid(GetWeldingDailyItem); + //SetDrpByDrpUnitChange(); + //this.hdItemsString.Text = string.Empty; + } + #endregion + + #region 右键删除事件 + /// + /// 右键删除事件 + /// + /// + /// + protected void btnMenuDelete_Click(object sender, EventArgs e) + { + if (Grid1.SelectedRowIndexArray.Length > 0) + { + List GetWeldingDailyItem = this.CollectGridJointInfo(); + foreach (int rowIndex in Grid1.SelectedRowIndexArray) + { + string rowID = Grid1.DataKeys[rowIndex][0].ToString(); + var item = GetWeldingDailyItem.FirstOrDefault(x => x.WeldJointId == rowID); + if (item != null && !BLL.Batch_NDEItemService.IsCheckedByWeldJoint(rowID)) + { + GetWeldingDailyItem.Remove(item); + // 删除焊口所在批和委托检测里信息 + BLL.Batch_NDEItemService.DeleteAllNDEInfoToWeldJoint(item.WeldJointId); + + // 更新焊口信息 + var updateWeldJoint = BLL.Pipeline_WeldJointService.GetWeldJointByWeldJointId(item.WeldJointId); + if (updateWeldJoint != null) + { + updateWeldJoint.WeldingDailyId = null; + updateWeldJoint.WeldingDailyCode = null; + updateWeldJoint.CoverWelderId = null; + updateWeldJoint.BackingWelderId = null; + BLL.Pipeline_WeldJointService.UpdateWeldJoint(updateWeldJoint); + } + } + else + { + Alert.ShowInTop("不能删除,已检测并审核!", MessageBoxIcon.Warning); + } + } + + BindGrid(GetWeldingDailyItem); + ShowNotify(Resources.Lan.DeletedSuccessfully, MessageBoxIcon.Success); + } + } + #endregion + + #region 资质分析 + private bool IsOK(List 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; + } + + /// + /// 两种焊接方法的资质判断 + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + private bool TwoWmeIsOK(List floorWelderQualifys, List 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 查找 + /// + /// 查找未焊接焊口 + /// + /// + /// + protected void ckSelect_Click(object sender, EventArgs e) + { + if (string.IsNullOrEmpty(this.drpUnit.SelectedValue) || this.drpUnit.SelectedValue == BLL.Const._Null || string.IsNullOrEmpty(this.drpInstallation.SelectedValue) || this.drpInstallation.SelectedValue == BLL.Const._Null) { + Alert.ShowInTop(Resources.Lan.PleaseUnitAndInstallation, MessageBoxIcon.Warning); + return; + } + List GetWeldingDailyItem=new List (); + string PipelineCode = this.txtPipelineCode.Text.Trim(); + if (string.IsNullOrWhiteSpace(PipelineCode)) { + Alert.ShowInTop("请输入要查询管线号!", MessageBoxIcon.Warning); + return; + } + string pipelineId=string.Empty; + var onePipeline_Pipeline=Funs.DB.Pipeline_Pipeline.FirstOrDefault(p=>p.PipelineCode == PipelineCode); + if (onePipeline_Pipeline == null) { + Alert.ShowInTop($"没有查询到管线号为【{PipelineCode}】的管线信息!", MessageBoxIcon.Warning); + BindGrid(GetWeldingDailyItem); + return; + } + + pipelineId = onePipeline_Pipeline.PipelineId; + string strSql = @"SELECT jot.WeldJointId,jot.WeldJointCode,jot.Dia,jot.Thickness, + method.WeldingMethodCode + FROM dbo.Pipeline_WeldJoint jot + LEFT JOIN dbo.Pipeline_Pipeline iso ON iso.PipelineId = jot.PipelineId + LEFT JOIN dbo.Pipeline_PreWeldingDaily preJot ON preJot.WeldJointId = jot.WeldJointId + LEFT JOIN dbo.Base_WeldingMethod method ON method.WeldingMethodId = jot.WeldingMethodId + WHERE iso.InstallationId IS NOT NULL AND jot.WeldTypeId IS NOT NULL + AND iso.DetectionRateId IS NOT NULL + AND preJot.PreWeldingDailyId IS NULL + AND jot.WeldingDailyId IS NULL + AND jot.ProjectId=@ProjectId AND jot.PipelineId=@PipelineId"; + + List listStr = new List(); + listStr.Add(new SqlParameter("@ProjectId", this.CurrUser.LoginProjectId)); + listStr.Add(new SqlParameter("@PipelineId", pipelineId)); + strSql += " ORDER BY CONVERT(INT,dbo.Fun_GetParseInt(jot.WeldJointCode))"; + SqlParameter[] parameter = listStr.ToArray(); + DataTable dt = SQLHelper.GetDataTableRunText(strSql, parameter); + + + if (dt.Rows.Count <= 0) { + Alert.ShowInTop($"没有查询到数据,请检查管线号为【{PipelineCode}】是否有新增数据!", MessageBoxIcon.Warning); + } + + string itemsString = string.Empty; + itemsString = "|#"; + foreach (DataRow row in dt.Rows) + { + string item = row["WeldJointId"].ToString(); + if (!itemsString.Contains(item)) + { + itemsString += item + "|"; + } + } + this.hdItemsString.Text=itemsString; + GetWeldingDailyItem = BLL.Pipeline_WeldingDailyService.GetWeldReportAddItem(this.hdItemsString.Text); + BindGrid(GetWeldingDailyItem); + + this.drpCoverWelderId.Items.Clear(); + this.drpBackingWelderId.Items.Clear(); + if (this.drpUnit.SelectedValue != BLL.Const._Null) + { + BLL.WelderService.InitProjectWelderCodeDropDownList(this.drpCoverWelderId, false, this.ProjectId, this.drpUnit.SelectedValue, Resources.Lan.PleaseSelect); + BLL.WelderService.InitProjectWelderCodeDropDownList(this.drpBackingWelderId, false, this.ProjectId, this.drpUnit.SelectedValue, Resources.Lan.PleaseSelect); + } + } + #endregion + } +} \ No newline at end of file diff --git a/HJGL/FineUIPro.Web/WeldingProcess/WeldingManage/WeldReportAdd.aspx.designer.cs b/HJGL/FineUIPro.Web/WeldingProcess/WeldingManage/WeldReportAdd.aspx.designer.cs new file mode 100644 index 0000000..ac738b9 --- /dev/null +++ b/HJGL/FineUIPro.Web/WeldingProcess/WeldingManage/WeldReportAdd.aspx.designer.cs @@ -0,0 +1,386 @@ +//------------------------------------------------------------------------------ +// <自动生成> +// 此代码由工具生成。 +// +// 对此文件的更改可能导致不正确的行为,如果 +// 重新生成代码,则所做更改将丢失。 +// +//------------------------------------------------------------------------------ + +namespace FineUIPro.Web.WeldingProcess.WeldingManage +{ + + + public partial class WeldReportAdd + { + + /// + /// form1 控件。 + /// + /// + /// 自动生成的字段。 + /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 + /// + protected global::System.Web.UI.HtmlControls.HtmlForm form1; + + /// + /// PageManager1 控件。 + /// + /// + /// 自动生成的字段。 + /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 + /// + protected global::FineUIPro.PageManager PageManager1; + + /// + /// Panel1 控件。 + /// + /// + /// 自动生成的字段。 + /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 + /// + protected global::FineUIPro.Panel Panel1; + + /// + /// panelCenterRegion 控件。 + /// + /// + /// 自动生成的字段。 + /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 + /// + protected global::FineUIPro.Panel panelCenterRegion; + + /// + /// Toolbar2 控件。 + /// + /// + /// 自动生成的字段。 + /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 + /// + protected global::FineUIPro.Toolbar Toolbar2; + + /// + /// hdItemsString 控件。 + /// + /// + /// 自动生成的字段。 + /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 + /// + protected global::FineUIPro.HiddenField hdItemsString; + + /// + /// hdTablerId 控件。 + /// + /// + /// 自动生成的字段。 + /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 + /// + protected global::FineUIPro.HiddenField hdTablerId; + + /// + /// ToolbarFill1 控件。 + /// + /// + /// 自动生成的字段。 + /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 + /// + protected global::FineUIPro.ToolbarFill ToolbarFill1; + + /// + /// btnSave 控件。 + /// + /// + /// 自动生成的字段。 + /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 + /// + protected global::FineUIPro.Button btnSave; + + /// + /// SimpleForm1 控件。 + /// + /// + /// 自动生成的字段。 + /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 + /// + protected global::FineUIPro.Form SimpleForm1; + + /// + /// txtWeldingDailyCode 控件。 + /// + /// + /// 自动生成的字段。 + /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 + /// + protected global::FineUIPro.TextBox txtWeldingDailyCode; + + /// + /// drpUnit 控件。 + /// + /// + /// 自动生成的字段。 + /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 + /// + protected global::FineUIPro.DropDownList drpUnit; + + /// + /// drpInstallation 控件。 + /// + /// + /// 自动生成的字段。 + /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 + /// + protected global::FineUIPro.DropDownList drpInstallation; + + /// + /// txtWeldingDate 控件。 + /// + /// + /// 自动生成的字段。 + /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 + /// + protected global::FineUIPro.DatePicker txtWeldingDate; + + /// + /// txtTabler 控件。 + /// + /// + /// 自动生成的字段。 + /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 + /// + protected global::FineUIPro.TextBox txtTabler; + + /// + /// txtTableDate 控件。 + /// + /// + /// 自动生成的字段。 + /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 + /// + protected global::FineUIPro.DatePicker txtTableDate; + + /// + /// txtRemark 控件。 + /// + /// + /// 自动生成的字段。 + /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 + /// + protected global::FineUIPro.TextBox txtRemark; + + /// + /// Grid1 控件。 + /// + /// + /// 自动生成的字段。 + /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 + /// + protected global::FineUIPro.Grid Grid1; + + /// + /// Toolbar1 控件。 + /// + /// + /// 自动生成的字段。 + /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 + /// + protected global::FineUIPro.Toolbar Toolbar1; + + /// + /// txtPipelineCode 控件。 + /// + /// + /// 自动生成的字段。 + /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 + /// + protected global::FineUIPro.TextBox txtPipelineCode; + + /// + /// ckSelect 控件。 + /// + /// + /// 自动生成的字段。 + /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 + /// + protected global::FineUIPro.Button ckSelect; + + /// + /// drpCoverWelderId 控件。 + /// + /// + /// 自动生成的字段。 + /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 + /// + protected global::FineUIPro.DropDownList drpCoverWelderId; + + /// + /// drpBackingWelderId 控件。 + /// + /// + /// 自动生成的字段。 + /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 + /// + protected global::FineUIPro.DropDownList drpBackingWelderId; + + /// + /// drpWeldType 控件。 + /// + /// + /// 自动生成的字段。 + /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 + /// + protected global::FineUIPro.DropDownList drpWeldType; + + /// + /// drpJointAttribute 控件。 + /// + /// + /// 自动生成的字段。 + /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 + /// + protected global::FineUIPro.DropDownList drpJointAttribute; + + /// + /// drpWeldingLocationId 控件。 + /// + /// + /// 自动生成的字段。 + /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 + /// + protected global::FineUIPro.DropDownList drpWeldingLocationId; + + /// + /// txtDoneDin 控件。 + /// + /// + /// 自动生成的字段。 + /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 + /// + protected global::FineUIPro.NumberBox txtDoneDin; + + /// + /// drpWeldingMethod 控件。 + /// + /// + /// 自动生成的字段。 + /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 + /// + protected global::FineUIPro.DropDownList drpWeldingMethod; + + /// + /// drpMaterial1 控件。 + /// + /// + /// 自动生成的字段。 + /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 + /// + protected global::FineUIPro.DropDownList drpMaterial1; + + /// + /// drpMaterial2 控件。 + /// + /// + /// 自动生成的字段。 + /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 + /// + protected global::FineUIPro.DropDownList drpMaterial2; + + /// + /// drpComponents1 控件。 + /// + /// + /// 自动生成的字段。 + /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 + /// + protected global::FineUIPro.DropDownList drpComponents1; + + /// + /// drpComponents2 控件。 + /// + /// + /// 自动生成的字段。 + /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 + /// + protected global::FineUIPro.DropDownList drpComponents2; + + /// + /// drpCoode1 控件。 + /// + /// + /// 自动生成的字段。 + /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 + /// + protected global::FineUIPro.DropDownList drpCoode1; + + /// + /// drpCoode2 控件。 + /// + /// + /// 自动生成的字段。 + /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 + /// + protected global::FineUIPro.DropDownList drpCoode2; + + /// + /// drpWeldSilkCode 控件。 + /// + /// + /// 自动生成的字段。 + /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 + /// + protected global::FineUIPro.DropDownList drpWeldSilkCode; + + /// + /// drpWeldMatCode 控件。 + /// + /// + /// 自动生成的字段。 + /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 + /// + protected global::FineUIPro.DropDownList drpWeldMatCode; + + /// + /// txtPipeSegment 控件。 + /// + /// + /// 自动生成的字段。 + /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 + /// + protected global::FineUIPro.TextBox txtPipeSegment; + + /// + /// drpWPS 控件。 + /// + /// + /// 自动生成的字段。 + /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 + /// + protected global::FineUIPro.DropDownList drpWPS; + + /// + /// Window1 控件。 + /// + /// + /// 自动生成的字段。 + /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 + /// + protected global::FineUIPro.Window Window1; + + /// + /// Menu1 控件。 + /// + /// + /// 自动生成的字段。 + /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 + /// + protected global::FineUIPro.Menu Menu1; + + /// + /// btnMenuDelete 控件。 + /// + /// + /// 自动生成的字段。 + /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 + /// + protected global::FineUIPro.MenuButton btnMenuDelete; + } +}