788 lines
34 KiB
C#
788 lines
34 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;
|
||
using System.Web;
|
||
using System.Web.UI;
|
||
using System.Web.UI.WebControls;
|
||
|
||
namespace FineUIPro.Web.HJGL.CheckManage
|
||
{
|
||
public partial class QualityRatingDataIn : PageBase
|
||
{
|
||
#region 定义项
|
||
/// <summary>
|
||
/// 项目id
|
||
/// </summary>
|
||
public string ProjectId
|
||
{
|
||
get
|
||
{
|
||
return (string)ViewState["ProjectId"];
|
||
}
|
||
set
|
||
{
|
||
ViewState["ProjectId"] = value;
|
||
}
|
||
}
|
||
|
||
/// <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.ProjectId = Request.Params["projectId"];
|
||
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"
|
||
+ @",ToopValue,Type"
|
||
+ @" FROM Sys_DataInTemp "
|
||
+ @" WHERE ProjectId=@ProjectId AND UserId=@UserId AND Type=@Type";
|
||
List<SqlParameter> listStr = new List<SqlParameter>();
|
||
listStr.Add(new SqlParameter("@ProjectId", this.ProjectId));
|
||
listStr.Add(new SqlParameter("@UserId", this.CurrUser.UserId));
|
||
listStr.Add(new SqlParameter("@Type", "RTQualityRating"));
|
||
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_DataInTemp
|
||
where x.ProjectId ==this.ProjectId && x.UserId == this.CurrUser.UserId && x.Type == "RTQualityRating"
|
||
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;
|
||
}
|
||
PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("QualityRatingDataInEdit.aspx?TempId={0}&&projectId={1}", Grid1.SelectedRowID,this.ProjectId, "维护 - ")));
|
||
}
|
||
#endregion
|
||
|
||
#region 导入信息 维护
|
||
/// <summary>
|
||
/// 导入信息编辑
|
||
/// </summary>
|
||
/// <param name="sender"></param>
|
||
/// <param name="e"></param>
|
||
protected void btnMenuEdit_Click(object sender, EventArgs e)
|
||
{
|
||
if (Grid1.SelectedRowIndexArray.Length == 0)
|
||
{
|
||
Alert.ShowInTop("请选择一条记录!", MessageBoxIcon.Warning);
|
||
return;
|
||
}
|
||
PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("QualityRatingDataInEdit.aspx?TempId={0}&&projectId={1}", Grid1.SelectedRowID,this.ProjectId, "维护 - ")));
|
||
}
|
||
|
||
/// <summary>
|
||
/// 删除按钮
|
||
/// </summary>
|
||
/// <param name="sender"></param>
|
||
/// <param name="e"></param>
|
||
protected void btnMenuDelete_Click(object sender, EventArgs e)
|
||
{
|
||
if (Grid1.SelectedRowIndexArray.Length == 0)
|
||
{
|
||
Alert.ShowInTop("请选择一条记录!", MessageBoxIcon.Warning);
|
||
return;
|
||
}
|
||
|
||
foreach (int rowIndex in Grid1.SelectedRowIndexArray)
|
||
{
|
||
string rowID = Grid1.DataKeys[rowIndex][0].ToString();
|
||
BLL.Sys_DataInTempService.DeleteDataInTempByDataInTempID(rowID);
|
||
}
|
||
|
||
ShowNotify("删除成功!", MessageBoxIcon.Success);
|
||
this.BindGrid();
|
||
}
|
||
#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 + Const.ExcelUrl;
|
||
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 + Const.ExcelUrl + 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[0].Rows.Count > 0)
|
||
{
|
||
for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
|
||
{
|
||
Sys_DataInTemp newDataInTemp = new Sys_DataInTemp();
|
||
newDataInTemp.TempId = SQLHelper.GetNewID(typeof(Model.Sys_DataInTemp));
|
||
newDataInTemp.ProjectId = this.ProjectId;
|
||
newDataInTemp.UserId = this.CurrUser.UserId;
|
||
newDataInTemp.Time = DateTime.Now;
|
||
newDataInTemp.Type = "RTQualityRating";
|
||
newDataInTemp.RowNo = i + 1;
|
||
newDataInTemp.Value1 = ds.Tables[0].Rows[i][0].ToString();
|
||
newDataInTemp.Value2 = ds.Tables[0].Rows[i][1].ToString();
|
||
newDataInTemp.Value3 = ds.Tables[0].Rows[i][2].ToString();
|
||
newDataInTemp.Value4 = ds.Tables[0].Rows[i][3].ToString();
|
||
newDataInTemp.Value5 = ds.Tables[0].Rows[i][4].ToString();
|
||
newDataInTemp.Value6 = ds.Tables[0].Rows[i][5].ToString();
|
||
newDataInTemp.Value7 = ds.Tables[0].Rows[i][6].ToString();
|
||
newDataInTemp.Value8 = ds.Tables[0].Rows[i][7].ToString();
|
||
newDataInTemp.Value9 = ds.Tables[0].Rows[i][8].ToString();
|
||
newDataInTemp.Value10 = ds.Tables[0].Rows[i][9].ToString();
|
||
newDataInTemp.Value11 = ds.Tables[0].Rows[i][10].ToString();
|
||
newDataInTemp.Value12 = ds.Tables[0].Rows[i][11].ToString();
|
||
newDataInTemp.Value13 = ds.Tables[0].Rows[i][12].ToString();
|
||
newDataInTemp.Value14 = ds.Tables[0].Rows[i][13].ToString();
|
||
newDataInTemp.Value15 = ds.Tables[0].Rows[i][14].ToString();
|
||
newDataInTemp.Value16 = ds.Tables[0].Rows[i][15].ToString();
|
||
newDataInTemp.Value17 = ds.Tables[0].Rows[i][16].ToString();
|
||
newDataInTemp.Value18 = ds.Tables[0].Rows[i][17].ToString();
|
||
newDataInTemp.Value19 = ds.Tables[0].Rows[i][18].ToString();
|
||
newDataInTemp.Value20 = ds.Tables[0].Rows[i][19].ToString();
|
||
newDataInTemp.Value21 = ds.Tables[0].Rows[i][20].ToString();
|
||
newDataInTemp.Value22 = ds.Tables[0].Rows[i][21].ToString();
|
||
|
||
BLL.Sys_DataInTempService.AddDataInTemp(newDataInTemp);
|
||
}
|
||
this.BindGrid();
|
||
ShowNotify("数据已导入临时表!", MessageBoxIcon.Success);
|
||
File.Delete(fileName);//删除上传的临时文件
|
||
}
|
||
else
|
||
{
|
||
Alert.ShowInTop("导入数据为空!", MessageBoxIcon.Success);
|
||
return;
|
||
}
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
Alert.ShowInTop("'" + ex.Message + "'", MessageBoxIcon.Warning);
|
||
}
|
||
}
|
||
#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.ProjectId, this.CurrUser.UserId, "RTQualityRating"); }));
|
||
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, string type)
|
||
{
|
||
Model.SGGLDB db = Funs.DB;
|
||
var units = from x in db.Base_Unit select x;//施工单位
|
||
var batchs = from x in db.HJGL_BO_Batch where x.ProjectId == LoginProjectId select x;//批次
|
||
var isoInfos = from x in db.HJGL_PW_IsoInfo where x.ProjectId == LoginProjectId select x;//管线
|
||
var jointInfos = from x in db.HJGL_PW_JointInfo where x.ProjectId == LoginProjectId select x;//焊口
|
||
var hardTestReportItemSetView = from x in db.HJGL_View_RTQualityRating where x.ProjectId == LoginProjectId && x.CH_NDTMethod == "20d2cbca-8b3d-434b-b1c1-181796986fa5" select x;
|
||
|
||
var dataInTemp = from x in Funs.DB.Sys_DataInTemp
|
||
where x.ProjectId == LoginProjectId && x.UserId == UserId && x.Type == type
|
||
orderby x.RowNo
|
||
select x;
|
||
int okCount = 0;
|
||
int i = 0;
|
||
int ir = dataInTemp.Count();
|
||
string erreMessage = "";
|
||
|
||
// 按 JOT_ID 分组汇总数据,支持任意多个焊口
|
||
Dictionary<string, JointWriteBackData> jointDataDict = new Dictionary<string, JointWriteBackData>();
|
||
|
||
foreach (var tempData in dataInTemp)
|
||
{
|
||
if (tempData != null)
|
||
{
|
||
i++;
|
||
percent[UserId] = (int)(100 * i / ir);
|
||
string errInfo = string.Empty;
|
||
string unitId = string.Empty;
|
||
string batchId = string.Empty;
|
||
string isoId = string.Empty;
|
||
string jotId = string.Empty;
|
||
int filmNum = 0;
|
||
int rMatNum = 0;
|
||
bool bRT = true;
|
||
bool needRemake = false;
|
||
Model.HJGL_CH_TrustItem trustItem = null;
|
||
|
||
Model.HJGL_BO_QualityRating newQualityRating = new Model.HJGL_BO_QualityRating();
|
||
var isExitValue = hardTestReportItemSetView.FirstOrDefault(x => x.UnitName == tempData.Value1.Trim() && x.BatchCode == tempData.Value2.Trim() && x.ISO_IsoNo == tempData.Value3.Trim());
|
||
if (isExitValue != null)
|
||
{
|
||
if (!string.IsNullOrEmpty(tempData.Value1.Trim()))
|
||
{
|
||
var getUnit = units.FirstOrDefault(x => x.UnitName == tempData.Value1.Trim());
|
||
if (getUnit == null)
|
||
{
|
||
errInfo += "施工单位[" + tempData.Value1.Trim() + "]不存在;";
|
||
}
|
||
else
|
||
{
|
||
unitId = getUnit.UnitId;
|
||
}
|
||
}
|
||
else
|
||
{
|
||
errInfo += "施工单位为必填项;";
|
||
}
|
||
if (!string.IsNullOrEmpty(tempData.Value2.Trim()))
|
||
{
|
||
var getBatch = batchs.FirstOrDefault(x => x.BatchCode == tempData.Value2.Trim());
|
||
if (getBatch == null)
|
||
{
|
||
errInfo += "批次号[" + tempData.Value2.Trim() + "]不存在;";
|
||
}
|
||
else
|
||
{
|
||
batchId = getBatch.BatchId;
|
||
}
|
||
}
|
||
else
|
||
{
|
||
errInfo += "批次号为必填项;";
|
||
}
|
||
if (!string.IsNullOrEmpty(tempData.Value3.Trim()))
|
||
{
|
||
var getIso = isoInfos.FirstOrDefault(x => x.BSU_ID == unitId && x.ISO_IsoNo == tempData.Value3.Trim());
|
||
if (getIso == null)
|
||
{
|
||
errInfo += "管线号[" + tempData.Value3.Trim() + "]该单位下不存在;";
|
||
}
|
||
else
|
||
{
|
||
isoId = getIso.ISO_ID;
|
||
newQualityRating.ISO_ID = isoId;
|
||
}
|
||
}
|
||
else
|
||
{
|
||
errInfo += "管线号为必填项;";
|
||
}
|
||
if (!string.IsNullOrEmpty(tempData.Value4.Trim()))
|
||
{
|
||
var getJoint = jointInfos.FirstOrDefault(x => x.ISO_ID == isoId && x.JOT_JointNo == tempData.Value4.Trim());
|
||
if (getJoint == null)
|
||
{
|
||
errInfo += "焊口号[" + tempData.Value4.Trim() + "]该管线下不存在;";
|
||
}
|
||
else
|
||
{
|
||
jotId = getJoint.JOT_ID;
|
||
newQualityRating.JOT_ID = jotId;
|
||
}
|
||
}
|
||
else
|
||
{
|
||
errInfo += "焊口号为必填项;";
|
||
}
|
||
if (!string.IsNullOrEmpty(tempData.Value5.Trim()))
|
||
{
|
||
var isExfileNum = from x in db.HJGL_BO_QualityRating where x.JOT_ID == jotId && x.FilmNum == tempData.Value5.Trim() select x;
|
||
if (isExfileNum.Count() > 0)
|
||
{
|
||
errInfo += "焊口号[" + tempData.Value4.Trim() + "]拍片记录已存在;";
|
||
}
|
||
else
|
||
{
|
||
newQualityRating.FilmNum = tempData.Value5.Trim();
|
||
}
|
||
}
|
||
else
|
||
{
|
||
errInfo += "底片编号为必填项;";
|
||
}
|
||
if (!string.IsNullOrEmpty(tempData.Value6.Trim()))
|
||
{
|
||
newQualityRating.RepairTag = tempData.Value6.Trim();//返修标记
|
||
}
|
||
if (!string.IsNullOrEmpty(tempData.Value7.Trim()))
|
||
{
|
||
if (tempData.Value7.Trim() != "√")
|
||
{
|
||
errInfo += "R母材格式错误;";
|
||
}
|
||
else
|
||
{
|
||
newQualityRating.RMaterial = true;
|
||
rMatNum++;
|
||
}
|
||
}
|
||
if (!string.IsNullOrEmpty(tempData.Value8.Trim()))
|
||
{
|
||
if (tempData.Value8.Trim() != "√")
|
||
{
|
||
errInfo += "重拍格式错误;";
|
||
}
|
||
else
|
||
{
|
||
if (string.IsNullOrEmpty(tempData.Value9.Trim()))
|
||
{
|
||
errInfo += "重拍原因为必填项;";
|
||
}
|
||
else
|
||
{
|
||
newQualityRating.Remake = true;
|
||
newQualityRating.RemakeResult = tempData.Value9.Trim();
|
||
needRemake = true;
|
||
}
|
||
}
|
||
}
|
||
if (!string.IsNullOrEmpty(tempData.Value10.Trim()))
|
||
{
|
||
if (tempData.Value10.Trim() != "√")
|
||
{
|
||
errInfo += "裂纹格式错误;";
|
||
}
|
||
else
|
||
{
|
||
newQualityRating.Cack = true;
|
||
}
|
||
}
|
||
if (!string.IsNullOrEmpty(tempData.Value11.Trim()))
|
||
{
|
||
if (tempData.Value11.Trim() != "√")
|
||
{
|
||
errInfo += "未融合格式错误;";
|
||
}
|
||
else
|
||
{
|
||
newQualityRating.NotFusion = true;
|
||
}
|
||
}
|
||
if (!string.IsNullOrEmpty(tempData.Value12.Trim()))
|
||
{
|
||
if (tempData.Value12.Trim() != "√")
|
||
{
|
||
errInfo += "未焊透格式错误;";
|
||
}
|
||
else
|
||
{
|
||
newQualityRating.NotPenetration = true;
|
||
}
|
||
}
|
||
if (!string.IsNullOrEmpty(tempData.Value13.Trim()))
|
||
{
|
||
if (tempData.Value13.Trim() != "√")
|
||
{
|
||
errInfo += "条状缺陷格式错误;";
|
||
}
|
||
else
|
||
{
|
||
newQualityRating.StripDefects = true;
|
||
}
|
||
}
|
||
if (!string.IsNullOrEmpty(tempData.Value14.Trim()))
|
||
{
|
||
if (tempData.Value14.Trim() != "√")
|
||
{
|
||
errInfo += "圆形缺陷格式错误;";
|
||
}
|
||
else
|
||
{
|
||
newQualityRating.CircularDefects = true;
|
||
}
|
||
}
|
||
if (!string.IsNullOrEmpty(tempData.Value15.Trim()))
|
||
{
|
||
if (tempData.Value15.Trim() != "√")
|
||
{
|
||
errInfo += "深孔缺陷格式错误;";
|
||
}
|
||
else
|
||
{
|
||
newQualityRating.DeepHoleDefects = true;
|
||
}
|
||
}
|
||
if (!string.IsNullOrEmpty(tempData.Value16.Trim()))
|
||
{
|
||
if (tempData.Value16.Trim() != "√")
|
||
{
|
||
errInfo += "根部内凹格式错误;";
|
||
}
|
||
else
|
||
{
|
||
newQualityRating.RootsConcave = true;
|
||
}
|
||
}
|
||
if (!string.IsNullOrEmpty(tempData.Value17.Trim()))
|
||
{
|
||
if (tempData.Value17.Trim() != "√")
|
||
{
|
||
errInfo += "根部咬边格式错误;";
|
||
}
|
||
else
|
||
{
|
||
newQualityRating.RootsBiteEdge = true;
|
||
}
|
||
}
|
||
if (!string.IsNullOrEmpty(tempData.Value20.Trim()))
|
||
{
|
||
if (tempData.Value20.Trim() != "Ⅰ" && tempData.Value20.Trim() != "Ⅱ" && tempData.Value20.Trim() != "Ⅲ" && tempData.Value20.Trim() != "Ⅳ" && tempData.Value20.Trim() != "Ⅴ" && tempData.Value20.Trim() != "VI")
|
||
{
|
||
errInfo += "评定结果格式错误;";
|
||
}
|
||
else
|
||
{
|
||
newQualityRating.DefectResult = tempData.Value20.Trim();
|
||
}
|
||
}
|
||
if (!string.IsNullOrEmpty(tempData.Value21.Trim()))
|
||
{
|
||
if (tempData.Value21.Trim() != "合格" && tempData.Value21.Trim() != "不合格")
|
||
{
|
||
errInfo += "是否合格格式错误;";
|
||
}
|
||
else
|
||
{
|
||
newQualityRating.IsPass = tempData.Value21.Trim();
|
||
if (tempData.Value21.Trim() == "不合格")
|
||
{
|
||
if (string.IsNullOrEmpty(tempData.Value20.Trim()))
|
||
{
|
||
errInfo += "不合格记录评定结果不能为空;";
|
||
}
|
||
else
|
||
{
|
||
bRT = false;
|
||
}
|
||
}
|
||
filmNum++;
|
||
}
|
||
}
|
||
else
|
||
{
|
||
errInfo += "是否合格为必填项;";
|
||
}
|
||
trustItem = (from x in db.HJGL_CH_TrustItem
|
||
join y in db.HJGL_CH_Trust on x.CH_TrustID equals y.CH_TrustID
|
||
where y.BatchId == batchId && x.JOT_ID == jotId && x.States == "1"
|
||
&& y.CH_NDTMethod == "20d2cbca-8b3d-434b-b1c1-181796986fa5"
|
||
select x).FirstOrDefault();
|
||
if (trustItem != null)
|
||
{
|
||
newQualityRating.CH_TrustItemID = trustItem.CH_TrustItemID;
|
||
}
|
||
else
|
||
{
|
||
var qu = from x in db.HJGL_BO_QualityRating where x.JOT_ID == jotId && x.FilmNum != tempData.Value5.Trim() select x;
|
||
if (qu != null)
|
||
{
|
||
newQualityRating.CH_TrustItemID = qu.FirstOrDefault().CH_TrustItemID;
|
||
}
|
||
else
|
||
{
|
||
errInfo += "委托记录不存在或拍片记录已存在,请核对;";
|
||
}
|
||
}
|
||
}
|
||
else
|
||
{
|
||
errInfo += "该记录未下委托,请核对;";
|
||
}
|
||
if (string.IsNullOrEmpty(errInfo)) ////所有信息正确的话 插入数据
|
||
{
|
||
|
||
newQualityRating.SignMan = this.CurrUser.UserId;
|
||
newQualityRating.SignDate = DateTime.Now;
|
||
newQualityRating.QualityRatingId = SQLHelper.GetNewID(typeof(Model.HJGL_BO_QualityRating));
|
||
BLL.HJGL_BO_QualityRatingService.AddQualityRating(newQualityRating);
|
||
|
||
if (!jointDataDict.ContainsKey(jotId))
|
||
{
|
||
jointDataDict[jotId] = new JointWriteBackData
|
||
{
|
||
//TotalFilmNum = 0,
|
||
//TotalRMatNum = 0,
|
||
TrustItem = BLL.HJGL_CH_TrustItemService.GetTrustItemByID(newQualityRating.CH_TrustItemID)
|
||
};
|
||
}
|
||
|
||
//jointDataDict[jotId].TotalFilmNum += filmNum;
|
||
//jointDataDict[jotId].TotalRMatNum += rMatNum;
|
||
//// 状态计算
|
||
//string finalState = bRT ? (needRemake ? "3" : "2") : "4";
|
||
//jointDataDict[jotId].FinalState = finalState;
|
||
|
||
|
||
BLL.Sys_DataInTempService.DeleteDataInTempByDataInTempID(tempData.TempId);
|
||
okCount++;
|
||
}
|
||
if (!string.IsNullOrEmpty(errInfo))
|
||
{
|
||
tempData.ToopValue = errInfo;
|
||
BLL.Sys_DataInTempService.UpdateDataInTemp(tempData);
|
||
erreMessage += errInfo + ";";
|
||
}
|
||
}
|
||
}
|
||
|
||
// ===================== 循环结束:统一回写(所有焊口各执行一次) =====================
|
||
foreach (var kv in jointDataDict)
|
||
{
|
||
string jotId = kv.Key;
|
||
var data = kv.Value;
|
||
var trustItem = data.TrustItem;
|
||
|
||
if (trustItem == null) continue;
|
||
|
||
// 更新委托状态
|
||
//trustItem.States = data.FinalState;
|
||
trustItem.FeedbackMan = this.CurrUser.UserName;
|
||
trustItem.FeedbackDate = DateTime.Now;
|
||
|
||
// 每个 JOT_ID 只调用一次!
|
||
int totalRMatNum = 0;
|
||
int isPassNum = 0;
|
||
int remakeNum = 0;
|
||
var qualityRating = (from x in db.HJGL_BO_QualityRating where x.JOT_ID == jotId select x);
|
||
foreach (var item in qualityRating)
|
||
{
|
||
if (item.RMaterial != null)
|
||
{
|
||
totalRMatNum++;
|
||
}
|
||
if (item.IsPass == "合格")
|
||
{
|
||
if (item.Remake == true)
|
||
{
|
||
remakeNum++;//待重检
|
||
}
|
||
else
|
||
{
|
||
isPassNum++;//检测合格
|
||
}
|
||
}
|
||
}
|
||
if (isPassNum == qualityRating.Count())
|
||
{
|
||
if (remakeNum > 0)
|
||
{
|
||
trustItem.States = "3";
|
||
}
|
||
else
|
||
{
|
||
trustItem.States = "2";
|
||
}
|
||
}
|
||
else
|
||
{
|
||
trustItem.States = "4";
|
||
}
|
||
BLL.HJGL_PW_JointInfoService.JointFileNumWriteBack(jotId, qualityRating.Count());
|
||
BLL.HJGL_PW_JointInfoService.JointRMaterialWriteBack(jotId, totalRMatNum);
|
||
BLL.HJGL_PW_JointInfoService.JointCheckStateWriteBack(jotId, "20d2cbca-8b3d-434b-b1c1-181796986fa5", trustItem.States);
|
||
BLL.HJGL_CH_TrustItemService.UpdateTrustItem(trustItem);
|
||
}
|
||
}
|
||
#endregion
|
||
|
||
#region 删除所有数据事件
|
||
/// <summary>
|
||
/// 删除所有数据事件
|
||
/// </summary>
|
||
/// <param name="sender"></param>
|
||
/// <param name="e"></param>
|
||
protected void btnAllDelete_Click(object sender, EventArgs e)
|
||
{
|
||
//先删除临时表中 该人员以前导入的数据
|
||
BLL.Sys_DataInTempService.DeleteDataInTempByProjectIdUserId(this.ProjectId, this.CurrUser.UserId, "RTQualityRating");
|
||
this.BindGrid();
|
||
ShowNotify("删除成功!", MessageBoxIcon.Success);
|
||
this.lbDataCout.Text = string.Empty;
|
||
}
|
||
#endregion
|
||
|
||
#region 下载模版
|
||
/// <summary>
|
||
/// 下载模版
|
||
/// </summary>
|
||
/// <param name="sender"></param>
|
||
/// <param name="e"></param>
|
||
protected void imgbtnUpload_Click(object sender, EventArgs e)
|
||
{
|
||
string rootPath = Server.MapPath("~/");
|
||
string uploadfilepath = rootPath + Const.RTQualityRatingTemplateUrl;
|
||
string filePath = Const.RTQualityRatingTemplateUrl;
|
||
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];
|
||
}
|
||
|
||
// 汇总数据实体
|
||
public class JointWriteBackData
|
||
{
|
||
public int TotalFilmNum { get; set; }
|
||
public int TotalRMatNum { get; set; }
|
||
public string FinalState { get; set; }
|
||
public Model.HJGL_CH_TrustItem TrustItem { get; set; }
|
||
}
|
||
}
|
||
} |