429 lines
17 KiB
C#
429 lines
17 KiB
C#
using System;
|
||
using System.Collections.Generic;
|
||
using System.Linq;
|
||
using System.Web;
|
||
using System.Web.UI;
|
||
using System.Web.UI.WebControls;
|
||
using BLL;
|
||
|
||
namespace FineUIPro.Web.HJGL.WeldingManage
|
||
{
|
||
public partial class JointReportUpdate : PageBase
|
||
{
|
||
protected void Page_Load(object sender, EventArgs e)
|
||
{
|
||
if (!IsPostBack)
|
||
{
|
||
string jotId = Request.Params["JOT_ID"];
|
||
|
||
// 焊接位置
|
||
this.drpLocation.DataTextField = "Text";
|
||
this.drpLocation.DataValueField = "Value";
|
||
this.drpLocation.DataSource = BLL.DropListService.HJGL_JOT_LocationItem();
|
||
this.drpLocation.DataBind();
|
||
|
||
if (!string.IsNullOrEmpty(jotId))
|
||
{
|
||
var jot = BLL.HJGL_PW_JointInfoService.GetJointInfoByJotID(jotId);
|
||
var dayly = BLL.HJGL_WeldReportService.GetWeldReportByDReportID(jot.DReportID);
|
||
//盖面焊工
|
||
drpCellWelder.DataTextField = "Text";
|
||
drpCellWelder.DataValueField = "Value";
|
||
drpCellWelder.DataSource = BLL.HJGL_PersonManageService.GetProjectWelderList(jot.ProjectId);
|
||
drpCellWelder.DataBind();
|
||
Funs.FineUIPleaseSelect(this.drpCellWelder);
|
||
|
||
///打底焊工
|
||
drpFloorWelder.DataTextField = "Text";
|
||
drpFloorWelder.DataValueField = "Value";
|
||
drpFloorWelder.DataSource = BLL.HJGL_PersonManageService.GetProjectWelderList(jot.ProjectId);
|
||
drpFloorWelder.DataBind();
|
||
Funs.FineUIPleaseSelect(this.drpFloorWelder);
|
||
|
||
drpFloorWelder.SelectedValue = jot.JOT_FloorWelder;
|
||
drpCellWelder.SelectedValue = jot.JOT_CellWelder;
|
||
if (!string.IsNullOrEmpty(jot.JOT_Location))
|
||
{
|
||
drpLocation.SelectedValue = jot.JOT_Location;
|
||
}
|
||
|
||
if (jot.Jot_WeldingDate.HasValue)
|
||
{
|
||
txtWeldingDate.Text = jot.Jot_WeldingDate.Value.ToString();
|
||
}
|
||
else
|
||
{
|
||
if (dayly != null)
|
||
{
|
||
txtWeldingDate.Text = dayly.JOT_WeldDate.ToString();
|
||
}
|
||
}
|
||
|
||
}
|
||
|
||
}
|
||
}
|
||
|
||
protected void drpFloorWelder_OnSelectedIndexChanged(object sender, EventArgs e)
|
||
{
|
||
if (this.drpFloorWelder.SelectedValue != BLL.Const._Null)
|
||
{
|
||
drpCellWelder.SelectedValue = drpFloorWelder.SelectedValue;
|
||
}
|
||
}
|
||
|
||
protected void btnSave_Click(object sender, EventArgs e)
|
||
{
|
||
string jotId = Request.Params["JOT_ID"];
|
||
Model.HJGL_PW_JointInfo jot = Funs.DB.HJGL_PW_JointInfo.FirstOrDefault(x => x.JOT_ID == jotId);
|
||
if (this.drpFloorWelder.SelectedValue != BLL.Const._Null)
|
||
{
|
||
jot.JOT_FloorWelder = drpFloorWelder.SelectedValue;
|
||
}
|
||
else
|
||
{
|
||
Alert.ShowInTop("请选择打底焊工!", MessageBoxIcon.Warning);
|
||
return;
|
||
}
|
||
|
||
if (this.drpCellWelder.SelectedValue != BLL.Const._Null)
|
||
{
|
||
jot.JOT_CellWelder = drpCellWelder.SelectedValue;
|
||
}
|
||
else
|
||
{
|
||
Alert.ShowInTop("请选择盖面焊工!", MessageBoxIcon.Warning);
|
||
return;
|
||
}
|
||
|
||
if (this.drpLocation.SelectedValue != BLL.Const._Null)
|
||
{
|
||
jot.JOT_Location = drpLocation.SelectedValue;
|
||
}
|
||
else
|
||
{
|
||
Alert.ShowInTop("请选择焊接位置!", MessageBoxIcon.Warning);
|
||
return;
|
||
}
|
||
|
||
|
||
#region 验证焊工资质
|
||
bool isAllD = true; //不合格口是否全为D类口(即焊口号包含D的焊口)
|
||
bool canSave = false;
|
||
var joty = BLL.HJGL_WeldService.GetJointTypeByID(jot.JOTY_ID);
|
||
string weldType = joty.JOTY_Group;
|
||
string floorWelder = drpFloorWelder.SelectedValue;
|
||
string cellWelder = drpCellWelder.SelectedValue;
|
||
decimal? dia = jot.JOT_Dia;
|
||
decimal? sch = Funs.GetNewDecimal(jot.JOT_Sch);
|
||
string wme = jot.WME_ID;
|
||
string wmeCode = string.Empty;
|
||
var wm = BLL.HJGL_WeldingMethodService.GetWeldMethodByWMEID(jot.WME_ID);
|
||
if (wm != null)
|
||
{
|
||
wmeCode = wm.WME_Code;
|
||
}
|
||
|
||
string[] wmeCodes = wmeCode.Split('+');
|
||
string location = jot.JOT_Location;
|
||
string ste = jot.STE_ID;
|
||
|
||
List<Model.HJGL_BS_WelderQualifiedProject> floorWelderQualifys = (from x in Funs.DB.HJGL_BS_WelderQualifiedProject
|
||
where x.WED_ID == floorWelder && (x.IsSteelStru == false || x.IsSteelStru == null)
|
||
&& x.WeldingMethodId != null && x.LimitDate >= DateTime.Now
|
||
&& x.WeldingLocationId != null && x.MaterialType != null
|
||
&& x.WeldType != null && x.ThicknessMax != null && x.SizesMin != null
|
||
select x).ToList();
|
||
|
||
List<Model.HJGL_BS_WelderQualifiedProject> cellWelderQualifys = (from x in Funs.DB.HJGL_BS_WelderQualifiedProject
|
||
where x.WED_ID == cellWelder && (x.IsSteelStru == false || x.IsSteelStru == null)
|
||
&& x.WeldingMethodId != null && x.LimitDate >= DateTime.Now
|
||
&& 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, wmeCode, location, weldType, ste, dia, sch);
|
||
}
|
||
else // 大于一种焊接方法,如氩电联焊
|
||
{
|
||
//bool isok1 = IsOK(floorWelderQualifys, wmeCodes[0], location, ste, dia, sch);
|
||
//bool isok2 = IsOK(floorWelderQualifys, wmeCodes[1], location, ste, dia, sch);
|
||
//if (isok1 && isok2)
|
||
//{
|
||
// canSave = true;
|
||
//}
|
||
canSave = TwoWmeIsOK(floorWelderQualifys, cellWelderQualifys, wmeCodes[0], wmeCodes[1], location, weldType, ste, dia, sch);
|
||
}
|
||
}
|
||
}
|
||
// 打底和盖面焊工不同
|
||
else
|
||
{
|
||
bool isok1 = false;
|
||
bool isok2 = false;
|
||
|
||
if (wmeCodes.Count() <= 1) // 一种焊接方法
|
||
{
|
||
if (floorWelderQualifys != null && floorWelderQualifys.Count() > 0)
|
||
{
|
||
isok1 = IsOK(floorWelderQualifys, wmeCode, location, weldType, ste, dia, sch);
|
||
}
|
||
if (cellWelderQualifys != null && cellWelderQualifys.Count() > 0)
|
||
{
|
||
isok2 = IsOK(cellWelderQualifys, wmeCode, location, weldType, ste, dia, sch);
|
||
}
|
||
if (isok1 && isok2)
|
||
{
|
||
canSave = true;
|
||
}
|
||
}
|
||
else
|
||
{
|
||
//// wmeCodes[0]对应GTAW 对应打底焊工
|
||
//if (floorWelderQualifys != null && floorWelderQualifys.Count() > 0)
|
||
//{
|
||
// isok1 = IsOK(floorWelderQualifys, wmeCodes[0], location, ste, dia, sch);
|
||
//}
|
||
//// wmeCodes[1]对应SMAW 对应盖面焊工
|
||
//if (cellWelderQualifys != null && cellWelderQualifys.Count() > 0)
|
||
//{
|
||
// isok2 = IsOK(cellWelderQualifys, wmeCodes[1], location, ste, dia, sch);
|
||
//}
|
||
//if (isok1 && isok2)
|
||
//{
|
||
// canSave = true;
|
||
//}
|
||
canSave = TwoWmeIsOK(floorWelderQualifys, cellWelderQualifys, wmeCodes[0], wmeCodes[1], location, weldType, ste, dia, sch);
|
||
}
|
||
}
|
||
|
||
if (canSave == false)
|
||
{
|
||
if (!jot.JOT_JointNo.Contains("D"))
|
||
{
|
||
isAllD = false;
|
||
}
|
||
else
|
||
{
|
||
canSave = true;
|
||
}
|
||
}
|
||
#endregion
|
||
if (canSave)
|
||
{
|
||
jot.Jot_WeldingDate = Convert.ToDateTime(txtWeldingDate.Text.Trim());
|
||
Funs.DB.SubmitChanges();
|
||
BLL.Sys_LogService.AddLog(BLL.Const.System_3, this.CurrUser.LoginProjectId, this.CurrUser.UserId, "更新日报信息!");
|
||
|
||
PageContext.RegisterStartupScript(ActiveWindow.GetHidePostBackReference());
|
||
Alert.ShowInTop("日报信息更新成功!", MessageBoxIcon.Success);
|
||
}
|
||
else
|
||
{
|
||
ShowNotify("焊口的焊工资质不符合,无法更新焊工信息!", MessageBoxIcon.Warning);
|
||
return;
|
||
}
|
||
}
|
||
|
||
private bool IsOK(List<Model.HJGL_BS_WelderQualifiedProject> welderQualifys, string wmeCode, string location, string weldType, string ste, decimal? dia, decimal? sch)
|
||
{
|
||
bool isok = false;
|
||
foreach (var welderQualify in welderQualifys)
|
||
{
|
||
int okNum = 0;
|
||
|
||
if (!string.IsNullOrEmpty(wmeCode)) //焊接方法
|
||
{
|
||
if (welderQualify.WeldingMethodId.Contains(wmeCode))
|
||
{
|
||
okNum++;
|
||
}
|
||
}
|
||
else
|
||
{
|
||
okNum++;
|
||
}
|
||
|
||
if (welderQualify.WeldingLocationId == "ALL") //焊接位置
|
||
{
|
||
okNum++;
|
||
}
|
||
else
|
||
{
|
||
if (!string.IsNullOrEmpty(location))
|
||
{
|
||
if (welderQualify.WeldingLocationId.Contains(location))
|
||
{
|
||
okNum++;
|
||
}
|
||
}
|
||
else
|
||
{
|
||
okNum++;
|
||
}
|
||
}
|
||
|
||
if (!string.IsNullOrEmpty(weldType))
|
||
{
|
||
if (welderQualify.WeldType.Contains(weldType))
|
||
{
|
||
okNum++;
|
||
}
|
||
}
|
||
else
|
||
{
|
||
okNum++;
|
||
}
|
||
|
||
var steel = BLL.HJGL_MaterialService.GetSteelBySteID(ste);
|
||
if (steel != null) //钢材类型
|
||
{
|
||
if (welderQualify.MaterialType.Contains(steel.STE_SteelType ?? ""))
|
||
{
|
||
okNum++;
|
||
}
|
||
}
|
||
else
|
||
{
|
||
okNum++;
|
||
}
|
||
|
||
|
||
if (weldType != "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 // 2表示角焊缝,当为角焊缝时,管径和壁厚不限制
|
||
{
|
||
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.HJGL_BS_WelderQualifiedProject> floorWelderQualifys, List<Model.HJGL_BS_WelderQualifiedProject> cellWelderQualifys, string wmeCode1, string wmeCode2, string location, string weldType, string ste, decimal? dia, decimal? sch)
|
||
{
|
||
bool isok = false;
|
||
|
||
decimal? fThicknessMax = 0;
|
||
decimal? cThicknessMax = 0;
|
||
|
||
var steel = BLL.HJGL_MaterialService.GetSteelBySteID(ste);
|
||
var floorQ = from x in floorWelderQualifys
|
||
where x.WeldingMethodId.Contains(wmeCode1)
|
||
&& (x.WeldingLocationId == "ALL" || (location == null || location == "" || x.WeldingLocationId.Contains(location)))
|
||
&& (steel == null || x.MaterialType.Contains(steel.STE_SteelType ?? ""))
|
||
&& x.WeldType.Contains(weldType)
|
||
// && (dia == null || x.SizesMin<=dia)
|
||
select x;
|
||
var cellQ = from x in cellWelderQualifys
|
||
where x.WeldingMethodId.Contains(wmeCode2)
|
||
&& (x.WeldingLocationId == "ALL" || (location == null || location == "" || x.WeldingLocationId.Contains(location)))
|
||
&& (steel == null || x.MaterialType.Contains(steel.STE_SteelType ?? ""))
|
||
&& x.WeldType.Contains(weldType)
|
||
// && (dia == null || x.SizesMin <= dia)
|
||
select x;
|
||
if (floorQ.Count() > 0 && cellQ.Count() > 0)
|
||
{
|
||
if (weldType != "2") // 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;
|
||
}
|
||
|
||
}
|
||
} |