更新无损委托单导入错误日志
This commit is contained in:
@@ -4,10 +4,13 @@ using System.Data;
|
||||
using System.Data.OleDb;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Web.Configuration;
|
||||
using System.Web.UI;
|
||||
using System.Web.UI.WebControls;
|
||||
using BLL;
|
||||
using FineUIPro.Web.common.ProjectSet;
|
||||
using FineUIPro.Web.Common.ProjectSet;
|
||||
using Model;
|
||||
|
||||
namespace FineUIPro.Web.WeldingProcess.TrustManage
|
||||
{
|
||||
@@ -88,15 +91,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>();
|
||||
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 +114,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 +154,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 +164,7 @@ namespace FineUIPro.Web.WeldingProcess.TrustManage
|
||||
}
|
||||
else
|
||||
{
|
||||
result += "第" + (i + 2).ToString() + "行," + "装置编号" + "," + "此项为必填项!" + "|";
|
||||
result += "装置编号此项为必填项!" + "|";
|
||||
}
|
||||
|
||||
string workAreaId = string.Empty;
|
||||
@@ -151,7 +173,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 +183,7 @@ namespace FineUIPro.Web.WeldingProcess.TrustManage
|
||||
}
|
||||
else
|
||||
{
|
||||
result += "第" + (i + 2).ToString() + "行," + "区域编号" + "," + "此项为必填项!" + "|";
|
||||
result += "区域编号此项为必填项!" + "|";
|
||||
}
|
||||
|
||||
string pipelineId = string.Empty;
|
||||
@@ -170,7 +192,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 +202,7 @@ namespace FineUIPro.Web.WeldingProcess.TrustManage
|
||||
}
|
||||
else
|
||||
{
|
||||
result += "第" + (i + 2).ToString() + "行," + "管线号" + "," + "此项为必填项!" + "|";
|
||||
result += "管线号此项为必填项!" + "|";
|
||||
}
|
||||
|
||||
string weldJointId = string.Empty;
|
||||
@@ -189,7 +211,7 @@ 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)
|
||||
@@ -200,12 +222,12 @@ namespace FineUIPro.Web.WeldingProcess.TrustManage
|
||||
}
|
||||
else
|
||||
{
|
||||
result += "第" + (i + 2).ToString() + "行," + "焊口号" + "," + "[" + col4 + "]重复!" + "|";
|
||||
result += "焊口号 [" + col4 + "]重复!" + "|";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
result += "第" + (i + 2).ToString() + "行," + "焊口号" + "," + "此项为必填项!" + "|";
|
||||
result += "焊口号此项为必填项!" + "|";
|
||||
}
|
||||
|
||||
string ndeId = string.Empty;
|
||||
@@ -214,7 +236,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 +247,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 +276,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 +289,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 +298,35 @@ namespace FineUIPro.Web.WeldingProcess.TrustManage
|
||||
}
|
||||
else
|
||||
{
|
||||
result += "第" + (i + 2).ToString() + "行," + "检测单位" + "," + "此项为必填项!" + "|";
|
||||
result += "检测单位此项为必填项!" + "|";
|
||||
}
|
||||
|
||||
if (!string.IsNullOrEmpty(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();
|
||||
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 +355,18 @@ namespace FineUIPro.Web.WeldingProcess.TrustManage
|
||||
{
|
||||
result += "委托单" + trustCode + "委托日期不一至" + "|";
|
||||
}
|
||||
}
|
||||
|
||||
if (!string.IsNullOrEmpty(result))
|
||||
{
|
||||
if (result.Contains("|"))
|
||||
if (logInfo != null)
|
||||
{
|
||||
result = result.Substring(0, result.LastIndexOf("|"));
|
||||
logInfo.Remark += result;
|
||||
}
|
||||
errorInfos = result;
|
||||
|
||||
lbResult.Text = result;
|
||||
}
|
||||
|
||||
if (logListData.Where(t=>t.Remark!="").Any())
|
||||
{
|
||||
Funs.DB.TrustBatchImportErrorLog.InsertAllOnSubmit(logListData);
|
||||
Funs.DB.SubmitChanges();
|
||||
this.Grid1.Hidden = false;
|
||||
this.BindGrid1(BatchNo);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -351,7 +378,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
|
||||
|
||||
#region 导入
|
||||
|
||||
Reference in New Issue
Block a user