This commit is contained in:
jackchenyang
2024-05-25 16:25:27 +08:00
parent 9831d335da
commit 1bd3a4ed2c
7 changed files with 652 additions and 149 deletions
@@ -88,15 +88,19 @@ namespace FineUIPro.Web.WeldingProcess.TrustManage
if (ds.Tables.Count > 0)
{
string result = string.Empty;
List<Model.Batch_BatchTrust> trustList= new List<Model.Batch_BatchTrust>();
List<Model.Batch_BatchTrust> trustList = new List<Model.Batch_BatchTrust>();
var units = from x in Funs.DB.Base_Unit select x;
var area = from x in Funs.DB.Project_WorkArea where x.ProjectId == this.CurrUser.LoginProjectId select x;
var installation = from x in Funs.DB.Project_Installation where x.ProjectId == this.CurrUser.LoginProjectId select x;
var trustIn = from x in Funs.DB.View_TrustBathcIn where x.ProjectId == this.CurrUser.LoginProjectId select x;
var pipeList = from x in Funs.DB.Pipeline_Pipeline where x.ProjectId == this.CurrUser.LoginProjectId select x;
List<Model.TrustBatchImportErrorLog> logListData = new List<Model.TrustBatchImportErrorLog>();
string BatchNo = DateTime.Now.ToString("yyyyMMddHHmmss");
for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
{
string result = string.Empty;
var log = new Model.TrustBatchImportErrorLog();
string col0 = ds.Tables[0].Rows[i][0].ToString().Trim();
string col1 = ds.Tables[0].Rows[i][1].ToString().Trim();
string col2 = ds.Tables[0].Rows[i][2].ToString().Trim();
@@ -107,18 +111,33 @@ namespace FineUIPro.Web.WeldingProcess.TrustManage
string col7 = ds.Tables[0].Rows[i][7].ToString().Trim();
string col8 = ds.Tables[0].Rows[i][8].ToString().Trim();
string col9 = ds.Tables[0].Rows[i][9].ToString().Trim();
log.Id = SQLHelper.GetNewID(typeof(TrustBatchImportErrorLog));
log.RowID = (i + 2);
log.BatchNo = BatchNo;
log.TrustBatchCode = col0;
log.InstallCode = col1;
log.AreaCode = col2;
log.PipelineCode = col3;
log.WeldJointCode = col4;
log.DetectionType = col5;
log.TrustDate = col6;
log.UnitCode = col7;
log.SurfaceState = col8;
log.Opportunity = col9;
log.CreatedTime = DateTime.Now;
Model.Batch_BatchTrust t = new Model.Batch_BatchTrust();
if (string.IsNullOrEmpty(col0))
{
result += "第" + (i + 2).ToString() + "行," + "委托单号" + "," + "此项为必填项!" + "|";
result += "委托单号此项为必填项!" + "|";
}
else
{
var oldTrust = Funs.DB.Batch_BatchTrust.FirstOrDefault(x => x.TrustBatchCode == col0);
if (oldTrust != null)
{
result += "第" + (i + 2).ToString() + "行," + "委托单号" + "," + "[" + col0 + "]已存在!" + "|";
result += "委托单号 [" + col0 + "]已存在!" + "|";
}
else
{
@@ -132,7 +151,7 @@ namespace FineUIPro.Web.WeldingProcess.TrustManage
Model.Project_Installation ins = installation.FirstOrDefault(x => x.InstallationCode == col1);
if (ins == null)
{
result += "第" + (i + 2).ToString() + "行," + "装置编号" + "," + "[" + col1 + "]不存在!" + "|";
result += "装置编号 [" + col1 + "]不存在!" + "|";
}
else
{
@@ -142,7 +161,7 @@ namespace FineUIPro.Web.WeldingProcess.TrustManage
}
else
{
result += "第" + (i + 2).ToString() + "行," + "装置编号" + "," + "此项为必填项!" + "|";
result += "装置编号此项为必填项!" + "|";
}
string workAreaId = string.Empty;
@@ -151,7 +170,7 @@ namespace FineUIPro.Web.WeldingProcess.TrustManage
Model.Project_WorkArea workArea = area.FirstOrDefault(x => x.WorkAreaCode == col2 && x.InstallationId == installationId);
if (workArea == null)
{
result += "第" + (i + 2).ToString() + "行," + "区域编号" + "," + "[" + col2 + "]不存在!" + "|";
result += "区域编号 [" + col2 + "]不存在!" + "|";
}
else
{
@@ -161,7 +180,7 @@ namespace FineUIPro.Web.WeldingProcess.TrustManage
}
else
{
result += "第" + (i + 2).ToString() + "行," + "区域编号" + "," + "此项为必填项!" + "|";
result += "区域编号此项为必填项!" + "|";
}
string pipelineId = string.Empty;
@@ -170,7 +189,7 @@ namespace FineUIPro.Web.WeldingProcess.TrustManage
var pipe = pipeList.FirstOrDefault(x => x.PipelineCode == col3 && x.WorkAreaId == workAreaId);
if (pipe == null)
{
result += "第" + (i + 2).ToString() + "行," + "该区域管线号" + "," + "[" + col3 + "]不存在!" + "|";
result += "该区域管线号 [" + col3 + "]不存在!" + "|";
}
else
{
@@ -180,7 +199,7 @@ namespace FineUIPro.Web.WeldingProcess.TrustManage
}
else
{
result += "第" + (i + 2).ToString() + "行," + "管线号" + "," + "此项为必填项!" + "|";
result += "管线号此项为必填项!" + "|";
}
string weldJointId = string.Empty;
@@ -189,23 +208,23 @@ namespace FineUIPro.Web.WeldingProcess.TrustManage
var weldJoint = from x in Funs.DB.Pipeline_WeldJoint where x.PipelineId == pipelineId && x.WeldJointCode == col4 select x;
if (weldJoint.Count() == 0)
{
result += "第" + (i + 2).ToString() + "行," + "焊口号" + "," + "[" + col4 + "]不存在!" + "|";
result += "焊口号 [" + col4 + "]不存在!" + "|";
}
else if (weldJoint.Count() == 1)
{
weldJointId = weldJoint.First().WeldJointId;
t.WeldingMethodId=weldJoint.First().WeldingMethodId;
t.WeldingMethodId = weldJoint.First().WeldingMethodId;
t.GrooveTypeId = weldJoint.First().GrooveTypeId;
}
else
{
result += "第" + (i + 2).ToString() + "行," + "焊口号" + "," + "[" + col4 + "]重复!" + "|";
result += "焊口号 [" + col4 + "]重复!" + "|";
}
}
else
{
result += "第" + (i + 2).ToString() + "行," + "焊口号" + "," + "此项为必填项!" + "|";
result += "焊口号此项为必填项!" + "|";
}
string ndeId = string.Empty;
@@ -214,7 +233,7 @@ namespace FineUIPro.Web.WeldingProcess.TrustManage
var nde = Funs.DB.Base_DetectionType.FirstOrDefault(x => x.DetectionTypeCode == col5);
if (nde == null)
{
result += "第" + (i + 2).ToString() + "行," + "探伤类型" + "," + "[" + col5 + "]错误!" + "|";
result += "探伤类型[" + col5 + "]错误!" + "|";
}
else
@@ -225,19 +244,19 @@ namespace FineUIPro.Web.WeldingProcess.TrustManage
}
else
{
result += "第" + (i + 2).ToString() + "行," + "探伤类型" + "," + "此项为必填项!" + "|";
result += "探伤类型此项为必填项!" + "|";
}
var pointBatchItem = trustIn.FirstOrDefault(x => x.InstallationId == installationId && x.WorkAreaId == workAreaId && x.PipelineId == pipelineId && x.WeldJointId == weldJointId && x.DetectionTypeId == ndeId);
if (pointBatchItem == null)
{
result += "第" + (i + 2).ToString() + "行," + "检验批中不存在对应焊口信息" + "|";
result += "检验批中不存在对应焊口信息" + "|";
}
else
{
if (pointBatchItem.TrustBatchItemId != null)
{
result += "第" + (i + 2).ToString() + "行," + "焊口已委托" + "|";
result += "焊口已委托" + "|";
}
else
{
@@ -254,12 +273,12 @@ namespace FineUIPro.Web.WeldingProcess.TrustManage
}
catch (Exception)
{
result += "第" + (i + 2).ToString() + "行," + "委托日期" + "," + "[" + col6 + "]错误!" + "|";
result += "委托日期 [" + col6 + "]错误!" + "|";
}
}
else
{
result += "第" + (i + 2).ToString() + "行," + "委托日期" + "," + "此项为必填项!" + "|";
result += "委托日期此项为必填项!" + "|";
}
if (!string.IsNullOrEmpty(col7))
@@ -267,7 +286,7 @@ namespace FineUIPro.Web.WeldingProcess.TrustManage
Model.Base_Unit unit = Funs.DB.Base_Unit.FirstOrDefault(x => x.UnitCode == col7);
if (unit == null)
{
result += "第" + (i + 2).ToString() + "行," + "检测单位编号" + "," + "[" + col7 + "]错误!" + "|";
result += "检测单位编号[" + col7 + "]错误!" + "|";
}
else
{
@@ -276,31 +295,35 @@ namespace FineUIPro.Web.WeldingProcess.TrustManage
}
else
{
result += "第" + (i + 2).ToString() + "行," + "检测单位" + "," + "此项为必填项!" + "|";
result += "检测单位此项为必填项!" + "|";
}
if (!string.IsNullOrEmpty(col8))
{
if (col8!= "打磨" && col8 != "机加工" && col8 != "喷砂" && col8 != "漆面")
if (col8 != "打磨" && col8 != "机加工" && col8 != "喷砂" && col8 != "漆面")
{
result += "第" + (i + 2).ToString() + "行," + "表面检测需录入:打磨、机加工、喷砂、漆面" + "|";
result += "表面检测需录入:打磨、机加工、喷砂、漆面" + "|";
}
}
if (!string.IsNullOrEmpty(col9))
{
if (col9 != "焊后" && col9 != "打磨后" && col9 != "热处理后" && col9 != "坡口准备" && col9 != "清根后" && col9 != "压力试验后" && col9 != "其他")
{
result += "第" + (i + 2).ToString() + "行," + "检测时机需录入:焊后、打磨后、热处理后、坡口准备、清根后、压力试验后、其他" + "|";
result += "检测时机需录入:焊后、打磨后、热处理后、坡口准备、清根后、压力试验后、其他" + "|";
}
}
log.Remark = result;
logListData.Add(log);
trustList.Add(t);
}
var trustCodeList=trustList.Select(p=>p.TrustBatchCode).Distinct();
var trustCodeList = trustList.Select(p => p.TrustBatchCode).Distinct();
foreach (var trustCode in trustCodeList)
{
string result = string.Empty;
var t = from x in trustList where x.TrustBatchCode == trustCode select x;
var logInfo = logListData.FirstOrDefault(x => x.TrustBatchCode == trustCode);
if (t.Select(x => x.InstallationId).Distinct().Count() > 1)
{
result += "委托单" + trustCode + "装置不一至" + "|";
@@ -329,17 +352,18 @@ namespace FineUIPro.Web.WeldingProcess.TrustManage
{
result += "委托单" + trustCode + "委托日期不一至" + "|";
}
if (logInfo != null)
{
logInfo.Remark += result;
}
}
if (!string.IsNullOrEmpty(result))
if (logListData.Where(t => t.Remark != "").Any())
{
if (result.Contains("|"))
{
result = result.Substring(0, result.LastIndexOf("|"));
}
errorInfos = result;
lbResult.Text = result;
Funs.DB.TrustBatchImportErrorLog.InsertAllOnSubmit(logListData);
Funs.DB.SubmitChanges();
this.Grid1.Hidden = false;
this.BindGrid1(BatchNo);
}
else
{
@@ -350,6 +374,12 @@ namespace FineUIPro.Web.WeldingProcess.TrustManage
}
void BindGrid1(string batchNo)
{
var result = Funs.DB.TrustBatchImportErrorLog.Where(t => t.BatchNo == batchNo).OrderBy(t => t.RowID).ToList();
this.Grid1.DataSource = result;
this.Grid1.DataBind();
}
#endregion