912 lines
45 KiB
C#
912 lines
45 KiB
C#
using BLL;
|
||
using BLL.Common;
|
||
using Model;
|
||
using System;
|
||
using System.Collections.Generic;
|
||
using System.Data;
|
||
using System.Data.SqlClient;
|
||
using System.IO;
|
||
using System.Linq;
|
||
using System.Threading;
|
||
|
||
namespace FineUIPro.Web.HJGL.WeldingManage
|
||
{
|
||
public partial class WeldReportDataInNews : PageBase
|
||
{
|
||
#region 定义变量
|
||
/// <summary>
|
||
/// 上传预设的虚拟路径
|
||
/// </summary>
|
||
private string initPath = Const.ExcelUrl;
|
||
|
||
/// <summary>
|
||
/// 错误集合
|
||
/// </summary>
|
||
public static string errorInfos = string.Empty;
|
||
#endregion
|
||
|
||
#region 加载
|
||
/// <summary>
|
||
/// 加载页面
|
||
/// </summary>
|
||
/// <param name="sender"></param>
|
||
/// <param name="e"></param>
|
||
protected void Page_Load(object sender, EventArgs e)
|
||
{
|
||
if (!IsPostBack)
|
||
{
|
||
if (percent == null)
|
||
{
|
||
percent = new Dictionary<string, int>();
|
||
}
|
||
this.id.Text = this.CurrUser.UserId;
|
||
|
||
this.ddlPageSize.SelectedValue = Grid1.PageSize.ToString();
|
||
// 绑定表格
|
||
this.BindGrid();
|
||
}
|
||
else if (GetRequestEventArgument() == "reloadGrid")
|
||
{
|
||
BindGrid();
|
||
}
|
||
}
|
||
#endregion
|
||
|
||
#region 绑定数据
|
||
/// <summary>
|
||
/// 绑定数据
|
||
/// </summary>
|
||
private void BindGrid()
|
||
{
|
||
string strSql = @"SELECT TempId,ProjectId,UserId,Time,RowNo,ToopValue,Value1,Value2,Value3,Value4,Value5,Value6,Value7,Value8,Value9,Value10"
|
||
+ @" ,Value11,Value12,Value13,Value14,Value15,Value16,Value17,Value18,Value19,Value20,Value21,Value22"
|
||
+ @",Value23,Value24,Value25,Value26,Value27,Value28,ToopValue"
|
||
+ @" FROM Sys_WeldReportDataInTemp "
|
||
+ @" WHERE ProjectId=@ProjectId AND UserId=@UserId ";
|
||
List<SqlParameter> listStr = new List<SqlParameter>();
|
||
listStr.Add(new SqlParameter("@ProjectId", this.CurrUser.LoginProjectId));
|
||
listStr.Add(new SqlParameter("@UserId", this.CurrUser.UserId));
|
||
SqlParameter[] parameter = listStr.ToArray();
|
||
DataTable tb = SQLHelper.GetDataTableRunText(strSql, parameter);
|
||
Grid1.RecordCount = tb.Rows.Count;
|
||
var table = this.GetPagedDataTable(Grid1, tb);
|
||
Grid1.DataSource = table;
|
||
Grid1.DataBind();
|
||
|
||
var dataInTempAll = from x in Funs.DB.Sys_WeldReportDataInTemp
|
||
where x.ProjectId == this.CurrUser.LoginProjectId && x.UserId == this.CurrUser.UserId
|
||
select x;
|
||
for (int i = 0; i < Grid1.Rows.Count; i++)
|
||
{
|
||
var dataInTemp = dataInTempAll.FirstOrDefault(x => x.TempId == Grid1.Rows[i].DataKeys[0].ToString());
|
||
if (dataInTemp != null)
|
||
{
|
||
if (!string.IsNullOrEmpty(dataInTemp.ToopValue))
|
||
{
|
||
Grid1.Rows[i].RowCssClass = "red";
|
||
}
|
||
}
|
||
}
|
||
var errData = from x in dataInTempAll where x.ToopValue != null select x;
|
||
this.lbDataCout.Text = errData.Count().ToString();
|
||
}
|
||
#endregion
|
||
|
||
#region 双击事件
|
||
/// <summary>
|
||
/// Grid行双击事件
|
||
/// </summary>
|
||
/// <param name="sender"></param>
|
||
/// <param name="e"></param>
|
||
protected void Grid1_RowDoubleClick(object sender, GridRowClickEventArgs e)
|
||
{
|
||
if (Grid1.SelectedRowIndexArray.Length == 0)
|
||
{
|
||
Alert.ShowInTop("请选择一条记录!", MessageBoxIcon.Warning);
|
||
return;
|
||
}
|
||
if (CommonService.GetAllButtonPowerList(this.CurrUser.LoginProjectId, this.CurrUser.UserId, Const.HJGL_WeldReportMenuId, Const.BtnSave))
|
||
{
|
||
PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("WeldReportDataInNewEdit.aspx?TempId={0}", Grid1.SelectedRowID, "维护 - ")));
|
||
}
|
||
else
|
||
{
|
||
ShowNotify("您没有这个权限,请与管理员联系!", MessageBoxIcon.Warning);
|
||
}
|
||
}
|
||
#endregion
|
||
|
||
#region 导入信息 维护
|
||
/// <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.BtnSave))
|
||
{
|
||
if (Grid1.SelectedRowIndexArray.Length == 0)
|
||
{
|
||
Alert.ShowInTop("请选择一条记录!", MessageBoxIcon.Warning);
|
||
return;
|
||
}
|
||
PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("WeldReportDataInNewEdit.aspx?TempId={0}", Grid1.SelectedRowID, "维护 - ")));
|
||
}
|
||
else
|
||
{
|
||
ShowNotify("您没有这个权限,请与管理员联系!", 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.BtnSave))
|
||
{
|
||
if (Grid1.SelectedRowIndexArray.Length == 0)
|
||
{
|
||
Alert.ShowInTop("请选择一条记录!", MessageBoxIcon.Warning);
|
||
return;
|
||
}
|
||
foreach (int rowIndex in Grid1.SelectedRowIndexArray)
|
||
{
|
||
string rowID = Grid1.DataKeys[rowIndex][0].ToString();
|
||
BLL.WeldReportDataInTempService.DeleteDataInTempByDataInTempID(rowID);
|
||
}
|
||
ShowNotify("删除成功!", MessageBoxIcon.Success);
|
||
this.BindGrid();
|
||
}
|
||
else
|
||
{
|
||
Alert.ShowInTop("您没有这个权限,请与管理员联系!", MessageBoxIcon.Warning);
|
||
return;
|
||
}
|
||
}
|
||
#endregion
|
||
|
||
#region 分页 排序
|
||
/// <summary>
|
||
/// 分页
|
||
/// </summary>
|
||
/// <param name="sender"></param>
|
||
/// <param name="e"></param>
|
||
protected void Grid1_PageIndexChange(object sender, GridPageEventArgs e)
|
||
{
|
||
BindGrid();
|
||
}
|
||
|
||
/// <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();
|
||
}
|
||
|
||
/// <summary>
|
||
/// 排序
|
||
/// </summary>
|
||
/// <param name="sender"></param>
|
||
/// <param name="e"></param>
|
||
protected void Grid1_Sort(object sender, FineUIPro.GridSortEventArgs e)
|
||
{
|
||
BindGrid();
|
||
}
|
||
#endregion
|
||
|
||
#region 文件上传
|
||
/// <summary>
|
||
/// 文件上传
|
||
/// </summary>
|
||
/// <param name="sender"></param>
|
||
/// <param name="e"></param>
|
||
protected void imgbtnImport_Click(object sender, EventArgs e)
|
||
{
|
||
try
|
||
{
|
||
if (this.FileExcel.HasFile == false)
|
||
{
|
||
ShowNotify("请选择Excel文件!", MessageBoxIcon.Warning);
|
||
return;
|
||
}
|
||
string IsXls = Path.GetExtension(this.FileExcel.FileName).ToString().Trim().ToLower();
|
||
if (IsXls != ".xls" && IsXls != ".xlsx")
|
||
{
|
||
ShowNotify("只能选择Excel文件!", MessageBoxIcon.Warning);
|
||
return;
|
||
}
|
||
string rootPath = Server.MapPath("~/");
|
||
string initFullPath = rootPath + initPath;
|
||
if (!Directory.Exists(initFullPath))
|
||
{
|
||
Directory.CreateDirectory(initFullPath);
|
||
}
|
||
//指定上传文件名称
|
||
this.hdfileName.Text = BLL.Funs.GetNewFileName() + IsXls;
|
||
//上传文件路径
|
||
string filePath = initFullPath + this.hdfileName.Text;
|
||
//文件上传服务器
|
||
this.FileExcel.PostedFile.SaveAs(filePath);
|
||
//文件上传服务器后的名称
|
||
string fileName = rootPath + initPath + this.hdfileName.Text;
|
||
//读取Excel
|
||
DataSet ds = NPOIHelper.ExcelToDataSet(fileName, out errorInfos, true);
|
||
//验证Excel读取是否有误
|
||
if (!string.IsNullOrEmpty(errorInfos))
|
||
{
|
||
ShowNotify(errorInfos, MessageBoxIcon.Warning);
|
||
return;
|
||
}
|
||
|
||
if (ds.Tables.Count > 0)
|
||
{
|
||
for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
|
||
{
|
||
Sys_WeldReportDataInTemp newDataInTemp = new Sys_WeldReportDataInTemp();
|
||
newDataInTemp.TempId = SQLHelper.GetNewID(typeof(Model.Sys_WeldReportDataInTemp));
|
||
newDataInTemp.ProjectId = this.CurrUser.LoginProjectId;
|
||
newDataInTemp.UserId = this.CurrUser.UserId;
|
||
newDataInTemp.Time = System.DateTime.Now;
|
||
newDataInTemp.RowNo = i + 2;
|
||
newDataInTemp.Value1 = ds.Tables[0].Rows[i]["单位代号"].ToString();
|
||
newDataInTemp.Value2 = ds.Tables[0].Rows[i]["装置代号"].ToString();
|
||
newDataInTemp.Value3 = ds.Tables[0].Rows[i]["管线代号"].ToString();
|
||
newDataInTemp.Value4 = ds.Tables[0].Rows[i]["焊口代号"].ToString();
|
||
newDataInTemp.Value5 = ds.Tables[0].Rows[i]["材质1代号"].ToString();
|
||
newDataInTemp.Value6 = ds.Tables[0].Rows[i]["材质2代号"].ToString();
|
||
newDataInTemp.Value7 = ds.Tables[0].Rows[i]["焊缝类型代号"].ToString();
|
||
newDataInTemp.Value8 = ds.Tables[0].Rows[i]["焊接区域 (安装/预制)"].ToString();
|
||
newDataInTemp.Value9 = ds.Tables[0].Rows[i]["焊口属性 (固定、活动)"].ToString();
|
||
newDataInTemp.Value10 = ds.Tables[0].Rows[i]["达因数"].ToString();
|
||
newDataInTemp.Value11 = ds.Tables[0].Rows[i]["规格(mm)"].ToString();
|
||
newDataInTemp.Value12 = ds.Tables[0].Rows[i]["壁厚"].ToString();
|
||
newDataInTemp.Value13 = ds.Tables[0].Rows[i]["焊接方法代码"].ToString();
|
||
newDataInTemp.Value14 = ds.Tables[0].Rows[i]["焊材代号"].ToString();
|
||
newDataInTemp.Value15 = ds.Tables[0].Rows[i]["班组代号"].ToString();
|
||
newDataInTemp.Value16 = ds.Tables[0].Rows[i]["盖面焊工代号"].ToString();
|
||
newDataInTemp.Value17 = ds.Tables[0].Rows[i]["打底焊工代号"].ToString();
|
||
newDataInTemp.Value18 = ds.Tables[0].Rows[i]["焊接位置(1G/2G/3G/4G/5G/6G)"].ToString();
|
||
newDataInTemp.Value19 = ds.Tables[0].Rows[i]["焊接日期"].ToString();
|
||
newDataInTemp.Value20 = ds.Tables[0].Rows[i]["电流A"].ToString();
|
||
newDataInTemp.Value21 = ds.Tables[0].Rows[i]["电压V"].ToString();
|
||
newDataInTemp.Value22 = ds.Tables[0].Rows[i]["焊接速度m/min"].ToString();
|
||
newDataInTemp.Value23= ds.Tables[0].Rows[i]["预热温度℃"].ToString();
|
||
newDataInTemp.Value24 = ds.Tables[0].Rows[i]["实际预热温度℃"].ToString();
|
||
newDataInTemp.Value25 = ds.Tables[0].Rows[i]["层间温度℃"].ToString();
|
||
newDataInTemp.Value26 = ds.Tables[0].Rows[i]["后热温度℃"].ToString();
|
||
newDataInTemp.Value27 = ds.Tables[0].Rows[i]["炉批号1"].ToString();
|
||
newDataInTemp.Value28 = ds.Tables[0].Rows[i]["炉批号2"].ToString();
|
||
|
||
BLL.WeldReportDataInTempService.AddDataInTemp(newDataInTemp);
|
||
}
|
||
this.BindGrid();
|
||
ShowNotify("数据已导入临时表!", MessageBoxIcon.Success);
|
||
}
|
||
else
|
||
{
|
||
ShowNotify("无数据!", MessageBoxIcon.Warning);
|
||
return;
|
||
}
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
Alert.ShowInTop("'" + ex.Message + "'", MessageBoxIcon.Warning);
|
||
}
|
||
}
|
||
#endregion
|
||
|
||
#region 导出按钮
|
||
/// 导出按钮
|
||
/// </summary>
|
||
/// <param name="sender"></param>
|
||
/// <param name="e"></param>
|
||
protected void btnOut_Click(object sender, EventArgs e)
|
||
{
|
||
this.Grid1.PageSize = 100000;
|
||
BindGrid();
|
||
Response.ClearContent();
|
||
string filename = Funs.GetNewFileName();
|
||
Response.AddHeader("content-disposition", "attachment; filename=" + System.Web.HttpUtility.UrlEncode("焊接日报" + filename, System.Text.Encoding.UTF8) + ".xls");
|
||
Response.ContentType = "application/excel";
|
||
Response.ContentEncoding = System.Text.Encoding.UTF8;
|
||
Response.Write(GetGridTableHtml(Grid1));
|
||
Response.End();
|
||
}
|
||
#endregion
|
||
|
||
#region 保存审核事件
|
||
/// <summary>
|
||
/// 保存审核事件
|
||
/// </summary>
|
||
/// <param name="sender"></param>
|
||
/// <param name="e"></param>
|
||
protected void btnSave_Click(object sender, EventArgs e)
|
||
{
|
||
Thread t = new Thread(new ThreadStart(() => { btnSaveMethod(this.CurrUser.LoginProjectId, this.CurrUser.UserId); }));
|
||
t.Start();
|
||
if (percent.ContainsKey(this.CurrUser.UserId))
|
||
{
|
||
percent[CurrUser.UserId] = 0;
|
||
}
|
||
else
|
||
{
|
||
percent.Add(CurrUser.UserId, 0);
|
||
|
||
}
|
||
PageContext.RegisterStartupScript("printX()");
|
||
}
|
||
protected void btnRefresh_Click(object sender, EventArgs e)
|
||
{
|
||
this.BindGrid();
|
||
}
|
||
|
||
protected void btnSaveMethod(string LoginProjectId, string UserId)
|
||
{
|
||
var units = from x in Funs.DB.Base_Unit
|
||
join y in Funs.DB.Project_ProjectUnit on x.UnitId equals y.UnitId
|
||
where y.ProjectId == LoginProjectId
|
||
select x;
|
||
var installations = from x in Funs.DB.Project_Installation where x.ProjectId == LoginProjectId select x;
|
||
var workAreas = from x in Funs.DB.ProjectData_WorkArea where x.ProjectId == LoginProjectId select x;
|
||
var steels = from x in Funs.DB.Project_Material
|
||
join y in Funs.DB.Base_Material on x.MaterialId equals y.MaterialId
|
||
where x.ProjectId == LoginProjectId
|
||
select y;
|
||
var types = from x in Funs.DB.Base_WeldType select x;
|
||
var methods = from x in Funs.DB.Base_WeldingMethod select x;
|
||
var weldMethodItem = from x in Funs.DB.BS_WeldMethodItem select x;
|
||
var teamGroups = from x in Funs.DB.ProjectData_TeamGroup where x.ProjectId == LoginProjectId select x;
|
||
var welders = from x in Funs.DB.BS_Welder select x;
|
||
var weldMaterials = from x in Funs.DB.Base_Consumables select x;//焊接耗材
|
||
//var locations = from x in Funs.DB.Base_Location select x;//焊接位置
|
||
|
||
var dataInTemp = from x in Funs.DB.Sys_WeldReportDataInTemp
|
||
where x.ProjectId == LoginProjectId && x.UserId == UserId
|
||
select x;
|
||
int okCount = 0;
|
||
int i = 0;
|
||
int ir = dataInTemp.Count();
|
||
string dateStr = string.Empty;
|
||
string dReportID = string.Empty;
|
||
string erreMessage = "";
|
||
foreach (var tempData in dataInTemp)
|
||
{
|
||
if (tempData != null)
|
||
{
|
||
i++;
|
||
percent[UserId] = (int)(100 * i / ir);
|
||
string errInfo = string.Empty;
|
||
|
||
var isExitValue = Funs.DB.View_JointInfoAndIsoInfo.FirstOrDefault(x => x.ProjectId == this.CurrUser.LoginProjectId && x.UnitCode == tempData.Value1
|
||
&& x.InstallationCode == tempData.Value2 && x.ISO_IsoNo == tempData.Value3 && x.JOT_JointNo == tempData.Value4 && x.JOT_JointStatus != "104");
|
||
|
||
if (isExitValue != null)
|
||
{
|
||
Model.PW_JointInfo joint = BLL.PW_JointInfoService.GetJointInfoByJotID(isExitValue.JOT_ID);
|
||
if (string.IsNullOrEmpty(joint.DReportID))
|
||
{
|
||
Model.BO_WeldReportMain weldReport = new Model.BO_WeldReportMain();
|
||
#region 赋值
|
||
var unit = units.FirstOrDefault(x => x.UnitCode == tempData.Value1);
|
||
if (!string.IsNullOrEmpty(tempData.Value1))
|
||
{
|
||
if (unit == null)
|
||
{
|
||
errInfo += "单位代码[" + tempData.Value1 + "]不存在;";
|
||
}
|
||
else
|
||
{
|
||
weldReport.UnitId = unit.UnitId;
|
||
}
|
||
}
|
||
else
|
||
{
|
||
errInfo += "单位代码为必填项;";
|
||
}
|
||
if (!string.IsNullOrEmpty(tempData.Value2))
|
||
{
|
||
var installation = installations.FirstOrDefault(x => x.InstallationCode == tempData.Value2);
|
||
if (installation == null)
|
||
{
|
||
errInfo += "装置代号[" + tempData.Value2 + "]不存在;";
|
||
}
|
||
else
|
||
{
|
||
weldReport.InstallationId = installation.InstallationId;
|
||
}
|
||
}
|
||
else
|
||
{
|
||
errInfo += "装置代号为必填项;";
|
||
}
|
||
if (string.IsNullOrEmpty(tempData.Value3))
|
||
{
|
||
errInfo += "管线代号为必填项;";
|
||
}
|
||
if (string.IsNullOrEmpty(tempData.Value4))
|
||
{
|
||
errInfo += "焊口代号为必填项;";
|
||
}
|
||
if (!string.IsNullOrEmpty(tempData.Value5))
|
||
{
|
||
var steel = steels.FirstOrDefault(x => x.MaterialCode == tempData.Value5);
|
||
if (steel == null)
|
||
{
|
||
errInfo += "材质1代号[" + tempData.Value5 + "]不存在;";
|
||
}
|
||
else
|
||
{
|
||
joint.MaterialId = steel.MaterialId;
|
||
}
|
||
}
|
||
if (!string.IsNullOrEmpty(tempData.Value6))
|
||
{
|
||
var steel = steels.FirstOrDefault(x => x.MaterialCode == tempData.Value6);
|
||
if (steel == null)
|
||
{
|
||
errInfo += "材质2代号[" + tempData.Value6 + "]不存在;";
|
||
}
|
||
else
|
||
{
|
||
joint.MaterialId2 = steel.MaterialId;
|
||
}
|
||
}
|
||
if (!string.IsNullOrEmpty(tempData.Value7))
|
||
{
|
||
var t = types.FirstOrDefault(x => x.WeldTypeCode == tempData.Value7);
|
||
if (t == null)
|
||
{
|
||
errInfo += "焊缝类型[" + tempData.Value7 + "]不存在;";
|
||
}
|
||
else
|
||
{
|
||
joint.JOTY_ID = t.WeldTypeId;
|
||
}
|
||
}
|
||
if (!string.IsNullOrEmpty(tempData.Value8))
|
||
{
|
||
if (tempData.Value8 != "安装" && tempData.Value8 != "预制")
|
||
{
|
||
errInfo += "焊接区域[" + tempData.Value8 + "]错误;";
|
||
}
|
||
else
|
||
{
|
||
joint.WLO_Code = tempData.Value8.Trim() == "安装" ? "F" : "S";
|
||
}
|
||
}
|
||
else
|
||
{
|
||
errInfo = "焊缝类型为必填项";
|
||
}
|
||
if (!string.IsNullOrEmpty(tempData.Value9))
|
||
{
|
||
if (tempData.Value9 != "固定" && tempData.Value9 != "活动")
|
||
{
|
||
errInfo += "焊口属性[" + tempData.Value9 + "]错误;";
|
||
}
|
||
else
|
||
{
|
||
joint.JOT_JointAttribute = tempData.Value9;
|
||
}
|
||
}
|
||
else
|
||
{
|
||
errInfo = "焊口属性为必填项";
|
||
}
|
||
if (!string.IsNullOrEmpty(tempData.Value10))
|
||
{
|
||
joint.JOT_DoneDin = Funs.GetNewDecimal(tempData.Value10);
|
||
}
|
||
else
|
||
{
|
||
joint.JOT_DoneDin = joint.JOT_Size;
|
||
}
|
||
if (!string.IsNullOrEmpty(tempData.Value11))
|
||
{
|
||
joint.JOT_JointDesc = tempData.Value11;
|
||
}
|
||
if (!string.IsNullOrEmpty(tempData.Value12))
|
||
{
|
||
joint.JOT_Sch = tempData.Value12;
|
||
}
|
||
if (!string.IsNullOrEmpty(tempData.Value13))
|
||
{
|
||
var weldMethod = methods.FirstOrDefault(x => x.WeldingMethodCode == tempData.Value13);
|
||
if (weldMethod == null)
|
||
{
|
||
errInfo += "焊接方法[" + tempData.Value13 + "]不存在;";
|
||
}
|
||
else
|
||
{
|
||
joint.WME_ID = weldMethod.WeldingMethodId;
|
||
}
|
||
}
|
||
if (!string.IsNullOrEmpty(tempData.Value14))
|
||
{
|
||
var weldMaterial = weldMaterials.FirstOrDefault(x => x.ConsumablesCode == tempData.Value14);
|
||
if (weldMaterials == null)
|
||
{
|
||
errInfo += "焊材代号[" + tempData.Value14 + "]不存在;";
|
||
}
|
||
else
|
||
{
|
||
|
||
}
|
||
}
|
||
if (!string.IsNullOrEmpty(tempData.Value15) && tempData.Value1 != null)
|
||
{
|
||
var teamGroup = teamGroups.Where(x => x.UnitId == unit.UnitId && x.TeamGroupCode == tempData.Value15).FirstOrDefault();
|
||
if (teamGroup == null)
|
||
{
|
||
errInfo += "该单位没有此班组代号;";
|
||
}
|
||
else
|
||
{
|
||
|
||
}
|
||
}
|
||
|
||
if (!string.IsNullOrEmpty(tempData.Value16))//盖面焊工
|
||
{
|
||
if (unit != null)
|
||
{
|
||
if (!string.IsNullOrEmpty(tempData.Value15))
|
||
{
|
||
var teamGroup = teamGroups.Where(x => x.UnitId == unit.UnitId && x.TeamGroupCode == tempData.Value15).FirstOrDefault();
|
||
if (teamGroup != null)
|
||
{
|
||
var welder = welders.Where(x => x.WED_Unit == unit.UnitId && x.TeamGroupId == teamGroup.TeamGroupId && x.WED_Code == tempData.Value16).FirstOrDefault();
|
||
if (welder == null)
|
||
{
|
||
errInfo += "该单位没有此焊工代号;";
|
||
}
|
||
else
|
||
{
|
||
var steel = steels.Where(x => x.MaterialCode == tempData.Value5).FirstOrDefault();
|
||
var method = methods.Where(x => x.WeldingMethodCode == tempData.Value13).FirstOrDefault();
|
||
var weldMethodItems = weldMethodItem.Where(x => x.WED_ID == welder.WED_ID).ToList();
|
||
if (steel != null && !string.IsNullOrEmpty(steel.SteelType) && !string.IsNullOrEmpty(welder.Steels) && !welder.Steels.Contains(steel.SteelType))
|
||
{
|
||
errInfo += "盖面焊工没有该材质资质;";
|
||
}
|
||
else if (weldMethodItems.Count != 0)
|
||
{
|
||
var methodItem = weldMethodItem.Where(x => x.WED_ID == welder.WED_ID && x.WME_ID == method.WeldingMethodId).ToList();
|
||
if (methodItem.Count == 0)
|
||
{
|
||
errInfo += "盖面焊工没有焊接方法质资质;";
|
||
}
|
||
}
|
||
else if (!string.IsNullOrEmpty(tempData.Value12) && !string.IsNullOrEmpty(welder.JOT_Sch) && !welder.JOT_Sch.Contains(tempData.Value12))
|
||
{
|
||
errInfo += "盖面焊工没有该壁厚资质;";
|
||
}
|
||
else
|
||
{
|
||
joint.JOT_CellWelder = welder.WED_ID;
|
||
}
|
||
}
|
||
}
|
||
else
|
||
{
|
||
var welder = welders.Where(x => x.WED_Unit == unit.UnitId && x.WED_Code == tempData.Value16).FirstOrDefault();
|
||
|
||
if (welder == null)
|
||
{
|
||
errInfo += "单位没有此焊工代号;";
|
||
}
|
||
}
|
||
}
|
||
else
|
||
{
|
||
var welder = welders.Where(e => e.WED_Unit == unit.UnitId && e.WED_Code == tempData.Value16).FirstOrDefault();
|
||
if (welder != null)
|
||
{
|
||
joint.JOT_CellWelder = welder.WED_ID;
|
||
}
|
||
else
|
||
{
|
||
errInfo += "该单位没有此焊工代号;";
|
||
}
|
||
}
|
||
}
|
||
}
|
||
else
|
||
{
|
||
errInfo += "盖面焊工代号为必填项;";
|
||
}
|
||
|
||
if (!string.IsNullOrEmpty(tempData.Value17))//打底焊工
|
||
{
|
||
if (unit != null)
|
||
{
|
||
if (!string.IsNullOrEmpty(tempData.Value15))
|
||
{
|
||
var teamGroup = teamGroups.Where(x => x.UnitId == unit.UnitId && x.TeamGroupCode == tempData.Value15).FirstOrDefault();
|
||
if (teamGroup != null)
|
||
{
|
||
var welder = welders.Where(x => x.WED_Unit == unit.UnitId && x.TeamGroupId == teamGroup.TeamGroupId && x.WED_Code == tempData.Value17).FirstOrDefault();
|
||
if (welder == null)
|
||
{
|
||
errInfo += "该单位没有此焊工代号;";
|
||
}
|
||
else
|
||
{
|
||
var steel = steels.Where(x => x.MaterialCode == tempData.Value5).FirstOrDefault();
|
||
|
||
var method = methods.Where(x => x.WeldingMethodCode == tempData.Value13).FirstOrDefault();
|
||
var weldMethodItems = weldMethodItem.Where(x => x.WED_ID == welder.WED_ID).ToList();
|
||
|
||
if (steel != null && !string.IsNullOrEmpty(steel.SteelType) && !string.IsNullOrEmpty(welder.Steels) && !welder.Steels.Contains(steel.SteelType))
|
||
{
|
||
errInfo += "打底焊工没有该材质资质;";
|
||
}
|
||
else if (weldMethodItems.Count != 0)
|
||
{
|
||
var methodItem = weldMethodItem.Where(x => x.WED_ID == welder.WED_ID && x.WME_ID == method.WeldingMethodId).ToList();
|
||
if (methodItem.Count == 0)
|
||
{
|
||
errInfo += "打底焊工没有焊接方法质资质;";
|
||
}
|
||
}
|
||
else if (!string.IsNullOrEmpty(tempData.Value12) && !string.IsNullOrEmpty(welder.JOT_Sch) && !welder.JOT_Sch.Contains(tempData.Value12))
|
||
{
|
||
errInfo += "打底焊工没有该壁厚资质;";
|
||
}
|
||
else
|
||
{
|
||
joint.JOT_FloorWelder = welder.WED_ID;
|
||
}
|
||
}
|
||
}
|
||
else
|
||
{
|
||
var welder = welders.Where(x => x.WED_Unit == unit.UnitId && x.WED_Code == tempData.Value17).FirstOrDefault();
|
||
|
||
if (welder == null)
|
||
{
|
||
errInfo += "单位没有此焊工代号;";
|
||
}
|
||
}
|
||
}
|
||
else
|
||
{
|
||
var welder = welders.Where(e => e.WED_Unit == unit.UnitId && e.WED_Code == tempData.Value17).FirstOrDefault();
|
||
if (welder != null)
|
||
{
|
||
joint.JOT_FloorWelder = welder.WED_ID;
|
||
}
|
||
else
|
||
{
|
||
errInfo += "该单位没有此焊工代号;";
|
||
}
|
||
|
||
}
|
||
}
|
||
}
|
||
else
|
||
{
|
||
errInfo += "打底焊工代号为必填项;";
|
||
}
|
||
if (!string.IsNullOrEmpty(tempData.Value18))
|
||
{
|
||
if (tempData.Value18 == "1G" || tempData.Value18 == "2G" || tempData.Value18 == "3G" || tempData.Value18 == "4G" || tempData.Value18 == "5G" || tempData.Value18 == "6G")
|
||
{
|
||
joint.JOT_Location = tempData.Value18;
|
||
}
|
||
else
|
||
{
|
||
errInfo = "焊接位置错误";
|
||
}
|
||
}
|
||
else
|
||
{
|
||
errInfo = "焊接位置为必填项";
|
||
}
|
||
if (!string.IsNullOrEmpty(tempData.Value19))
|
||
{
|
||
try
|
||
{
|
||
weldReport.JOT_WeldDate = Convert.ToDateTime(tempData.Value19);
|
||
}
|
||
catch (Exception)
|
||
{
|
||
errInfo = "焊接日期格式错误";
|
||
}
|
||
}
|
||
else
|
||
{
|
||
errInfo = "焊接日期为必填项";
|
||
}
|
||
joint.JOT_Electricity = tempData.Value20;//电流
|
||
joint.JOT_Voltage = tempData.Value21;//电压
|
||
joint.WeldingSpeed = tempData.Value22;//焊接速度
|
||
if (!string.IsNullOrEmpty(tempData.Value23))
|
||
{
|
||
try
|
||
{
|
||
joint.JOT_PrepareTemp = Funs.GetNewDecimal(tempData.Value23);
|
||
}
|
||
catch (Exception)
|
||
{
|
||
errInfo = "预热温度格式错误";
|
||
}
|
||
}
|
||
if (!string.IsNullOrEmpty(tempData.Value24))
|
||
{
|
||
try
|
||
{
|
||
joint.ActualPrepareTemp = Funs.GetNewDecimal(tempData.Value24);
|
||
}
|
||
catch (Exception)
|
||
{
|
||
errInfo = "实际预热温度格式错误";
|
||
}
|
||
}
|
||
if (!string.IsNullOrEmpty(tempData.Value25))
|
||
{
|
||
try
|
||
{
|
||
joint.JOT_CellTemp = Funs.GetNewDecimal(tempData.Value25);
|
||
}
|
||
catch (Exception)
|
||
{
|
||
errInfo = "层间温度格式错误";
|
||
}
|
||
}
|
||
if (!string.IsNullOrEmpty(tempData.Value26))
|
||
{
|
||
try
|
||
{
|
||
joint.JOT_LastTemp = Funs.GetNewDecimal(tempData.Value26);
|
||
}
|
||
catch (Exception)
|
||
{
|
||
errInfo = "后热温度格式错误";
|
||
}
|
||
}
|
||
joint.JOT_HeartNo1 = tempData.Value27;
|
||
joint.JOT_HeartNo2 = tempData.Value28;
|
||
#endregion
|
||
if (string.IsNullOrEmpty(errInfo)) ////所有信息正确的话 插入日报
|
||
{
|
||
if (dateStr != tempData.Value19)
|
||
{
|
||
weldReport.DReportID = SQLHelper.GetNewID(typeof(Model.BO_WeldReportMain));
|
||
weldReport.ProjectId = this.CurrUser.LoginProjectId;
|
||
weldReport.CHT_Tabler = this.CurrUser.UserId;
|
||
weldReport.CHT_TableDate = DateTime.Now;
|
||
|
||
string bawId = BLL.PW_IsoInfoService.GetIsoInfoByIsoInfoId(joint.ISO_ID).WorkAreaId;
|
||
string bawCode = BLL.WorkAreaService.getWorkAreaByWorkAreaId(bawId).WorkAreaCode;
|
||
string perfix = bawCode + "-" + tempData.Value16 + "-";
|
||
string reportNo = BLL.SQLHelper.RunProcNewId("SpGetNewCode5ByProjectId", "dbo.BO_WeldReportMain", "JOT_DailyReportNo", this.CurrUser.LoginProjectId, perfix);
|
||
weldReport.JOT_DailyReportNo = reportNo;
|
||
BLL.WeldReportService.AddWeldReport(weldReport);
|
||
dReportID = weldReport.DReportID;
|
||
dateStr = tempData.Value19;
|
||
}
|
||
//修改焊口
|
||
//var isExitJotNoValue = Funs.DB.View_JointInfoAndIsoInfo.FirstOrDefault(x => x.ProjectId == this.CurrUser.LoginProjectId && x.UnitCode == tempData.Value1
|
||
//&& x.InstallationCode == tempData.Value2 && x.ISO_IsoNo == tempData.Value3 && x.JOT_JointNo == tempData.Value4 && x.JOT_JointStatus != "104");
|
||
//if (isExitJotNoValue != null)
|
||
//{
|
||
//if (string.IsNullOrEmpty(dReportID))
|
||
//{
|
||
joint.JOT_JointStatus = "100";
|
||
//若是固定口,在焊口号后+G,若是活动口,去掉后面的G
|
||
if (joint.JOT_JointAttribute == "固定")
|
||
{
|
||
joint.JOT_JointNo = joint.JOT_JointNo + "G";
|
||
}
|
||
else
|
||
{
|
||
if (joint.JOT_JointNo.Last() == 'G')
|
||
{
|
||
joint.JOT_JointNo = joint.JOT_JointNo.Substring(0, joint.JOT_JointNo.Length - 1);
|
||
}
|
||
}
|
||
joint.DReportID = dReportID;
|
||
joint.JOT_ID = isExitValue.JOT_ID; //isExitJotNoValue.JOT_ID;
|
||
BLL.PW_JointInfoService.UpdateJointInfo(joint);
|
||
//}
|
||
//}
|
||
BLL.WeldReportDataInTempService.DeleteDataInTempByDataInTempID(tempData.TempId);
|
||
okCount++;
|
||
}
|
||
}
|
||
else
|
||
{
|
||
errInfo = "该焊口日报已存在";
|
||
}
|
||
}
|
||
else
|
||
{
|
||
errInfo = "该焊口不存在";
|
||
}
|
||
if (!string.IsNullOrEmpty(errInfo))
|
||
{
|
||
tempData.ToopValue = errInfo;
|
||
BLL.WeldReportDataInTempService.UpdateDataInTemp(tempData);
|
||
erreMessage += errInfo + ";";
|
||
}
|
||
}
|
||
}
|
||
}
|
||
#endregion
|
||
|
||
#region 删除所有数据事件
|
||
/// <summary>
|
||
/// 删除所有数据事件
|
||
/// </summary>
|
||
/// <param name="sender"></param>
|
||
/// <param name="e"></param>
|
||
protected void btnAllDelete_Click(object sender, EventArgs e)
|
||
{
|
||
if (CommonService.GetAllButtonPowerList(this.CurrUser.LoginProjectId, this.CurrUser.UserId, Const.HJGL_WeldReportMenuId, Const.BtnSave))
|
||
{
|
||
//先删除临时表中 该人员以前导入的数据
|
||
BLL.WeldReportDataInTempService.DeleteDataInTempByProjectIdUserId(this.CurrUser.LoginProjectId, this.CurrUser.UserId);
|
||
this.BindGrid();
|
||
ShowNotify("删除成功!", MessageBoxIcon.Success);
|
||
this.lbDataCout.Text = string.Empty;
|
||
}
|
||
else
|
||
{
|
||
Alert.ShowInTop("您没有这个权限,请与管理员联系!", MessageBoxIcon.Warning);
|
||
return;
|
||
}
|
||
}
|
||
#endregion
|
||
|
||
#region 模版导入说明 下载
|
||
/// <summary>
|
||
/// 下载模版
|
||
/// </summary>
|
||
/// <param name="sender"></param>
|
||
/// <param name="e"></param>
|
||
protected void imgbtnUpload_Click(object sender, EventArgs e)
|
||
{
|
||
this.TemplateUpload(BLL.Const.WeldReportDataInTemplateUrl);
|
||
}
|
||
|
||
/// <summary>
|
||
/// 模板下载方法
|
||
/// </summary>
|
||
/// <param name="initTemplatePath"></param>
|
||
protected void TemplateUpload(string initTemplatePath)
|
||
{
|
||
string rootPath = Server.MapPath("~/");
|
||
string uploadfilepath = rootPath + initTemplatePath;
|
||
string filePath = Const.WeldReportDataInTemplateUrl;
|
||
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
|
||
|
||
public static Dictionary<string, int> percent { get; set; }
|
||
public static Dictionary<string, string> url { get; set; }
|
||
|
||
[System.Web.Services.WebMethod]
|
||
public static int getPercent(string id)
|
||
{
|
||
return percent[id];
|
||
}
|
||
}
|
||
} |