2023-04-28 天辰质量报验移植

This commit is contained in:
2023-04-28 17:46:41 +08:00
parent dbfd7086e1
commit 03c6364f47
171 changed files with 17248 additions and 2071 deletions
@@ -18,7 +18,7 @@ namespace FineUIPro.Web.CQMS.Comprehensive
/// 上传预设的虚拟路径
/// </summary>
private string initPath = Const.ExcelUrl;
/// <summary>
/// 错误集合
@@ -96,21 +96,22 @@ namespace FineUIPro.Web.CQMS.Comprehensive
/// <param name="filename">Excel文件路径名</param>
private void ImportXlsToData(string fileName)
{
//支持.xls和.xlsx,即包括office2010等版本的 HDR=Yes代表第一行是标题,不是数据;
string cmdText = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source={0};Extended Properties='Excel 12.0; HDR=Yes; IMEX=1'";
//建立连接
OleDbConnection conn = new OleDbConnection(string.Format(cmdText, fileName));
try
{
string oleDBConnString = String.Empty;
oleDBConnString = "Provider=Microsoft.Jet.OLEDB.4.0;";
oleDBConnString += "Data Source=";
oleDBConnString += fileName;
oleDBConnString += ";Extended Properties=Excel 8.0;";
OleDbConnection oleDBConn = null;
//打开连接
if (conn.State == ConnectionState.Broken || conn.State == ConnectionState.Closed)
{
conn.Open();
}
OleDbDataAdapter oleAdMaster = null;
DataTable m_tableName = new DataTable();
DataSet ds = new DataSet();
oleDBConn = new OleDbConnection(oleDBConnString);
oleDBConn.Open();
m_tableName = oleDBConn.GetOleDbSchemaTable(OleDbSchemaGuid.Tables, null);
m_tableName = conn.GetOleDbSchemaTable(OleDbSchemaGuid.Tables, null);
if (m_tableName != null && m_tableName.Rows.Count > 0)
{
@@ -120,13 +121,13 @@ namespace FineUIPro.Web.CQMS.Comprehensive
}
string sqlMaster;
sqlMaster = " SELECT * FROM [" + m_tableName.TableName + "]";
oleAdMaster = new OleDbDataAdapter(sqlMaster, oleDBConn);
oleAdMaster = new OleDbDataAdapter(sqlMaster, conn);
oleAdMaster.Fill(ds, "m_tableName");
oleAdMaster.Dispose();
oleDBConn.Close();
oleDBConn.Dispose();
conn.Close();
conn.Dispose();
AddDatasetToSQL(ds.Tables[0], 13);
AddDatasetToSQL(ds.Tables[0], 10);
hdCheckResult.Text = "1";
}
catch (Exception exc)
@@ -135,6 +136,11 @@ namespace FineUIPro.Web.CQMS.Comprehensive
//return null;
// return dt;
}
finally
{
conn.Close();
conn.Dispose();
}
}
#endregion
@@ -165,106 +171,84 @@ namespace FineUIPro.Web.CQMS.Comprehensive
select x;
var cns = from x in Funs.DB.Base_CNProfessional select x;
var installations = from x in Funs.DB.WBS_UnitWork where x.ProjectId == this.CurrUser.LoginProjectId select x;
var installations = from x in Funs.DB.WBS_UnitWork where x.ProjectId == this.CurrUser.LoginProjectId select x;
for (int i = 0; i < ir; i++)
{
string row0 = pds.Rows[i][0].ToString().Trim();
if (string.IsNullOrEmpty(row0))
if (!string.IsNullOrEmpty(row0))
{
result += (i + 2).ToString() + "," + "文件编号,为必填项!" + "|";
var cn = cns.Where(x => x.ProfessionalName == row0.Trim()).FirstOrDefault();
if (cn == null)
{
result += (i + 2).ToString() + "," + "专业名称" + "," + "[" + row0 + "]不存在!" + "|";
}
}
string row1 = pds.Rows[i][1].ToString().Trim();
if (string.IsNullOrEmpty(row1))
string row1 = pds.Rows[i][1].ToString();
if (!string.IsNullOrEmpty(row1))
{
result += (i + 2).ToString() + "," + "文件名称,为必填项!" + "|";
var ins = installations.Where(x => x.UnitWorkName == row1.Trim()).FirstOrDefault();
if (ins == null)
{
result += (i + 2).ToString() + "," + "装置/单元名称" + "," + "[" + row1 + "]不存在!" + "|";
}
}
string row2 = pds.Rows[i][2].ToString();
if (!string.IsNullOrEmpty(row2))
if (string.IsNullOrEmpty(row2))
{
result += (i + 2).ToString() + "," + "变更单号" + "," + "此项为必填项!" + "|";
}
string row5 = pds.Rows[i][5].ToString();
if (!string.IsNullOrEmpty(row5))
{
try
{
DateTime date = Convert.ToDateTime(row2.Trim());
DateTime date = Convert.ToDateTime(row5.Trim());
}
catch (Exception)
{
result += (i + 2).ToString() + "," + "发日期" + "," + "[" + row2 + "]错误!" + "|";
}
}
else
{
result += (i + 2).ToString() + "," + "发放日期,为必填项!" + "|";
}
string row3 = pds.Rows[i][3].ToString().Trim();
if (!string.IsNullOrEmpty(row3))
{
var cn = cns.Where(x => x.ProfessionalName == row3.Trim()).FirstOrDefault();
if (cn == null)
{
result += (i + 2).ToString() + "," + "专业名称" + "," + "[" + row3 + "]不存在!" + "|";
result += (i + 2).ToString() + "," + "发日期" + "," + "[" + row5 + "]错误!" + "|";
}
}
string row5 = pds.Rows[i][5].ToString().Trim();
if (!string.IsNullOrEmpty(row5))
string row6 = pds.Rows[i][6].ToString();
if (!string.IsNullOrEmpty(row6))
{
string[] reunit = row5.Split(',');
foreach (string unit in reunit)
try
{
var u = units.Where(x => x.UnitName == unit).FirstOrDefault();
if (u == null)
{
result += (i + 2).ToString() + "," + "发件单位" + "," + "[" + unit + "]不存在!" + "|";
}
DateTime date = Convert.ToDateTime(row6.Trim());
}
catch (Exception)
{
result += (i + 2).ToString() + "," + "业主批准时间" + "," + "[" + row6 + "]错误!" + "|";
}
}
string row7 = pds.Rows[i][7].ToString().Trim();
if (!string.IsNullOrEmpty(row7))
{
if (row7 != "纸质" && row7 != "电子")
string[] reunit = row7.Split(',');
foreach (string unit in reunit)
{
result += (i + 2).ToString() + "," + "文件形式" + "," + "[" + row7 + "]错误!" + "|";
var u = units.Where(x => x.UnitName == unit).FirstOrDefault();
if (u == null)
{
result += (i + 2).ToString() + "," + "单位名称" + "," + "[" + unit + "]不存在!" + "|";
}
}
}
string row8 = pds.Rows[i][8].ToString().Trim();
if (!string.IsNullOrEmpty(row8))
{
try
{
int a = Convert.ToInt32(row8.Trim());
}
catch (Exception)
{
result += (i + 2).ToString() + "," + "份数" + "," + "[" + row8 + "]错误!" + "|";
}
}
string row9 = pds.Rows[i][9].ToString().Trim();
if (!string.IsNullOrEmpty(row9))
{
if (row9 != "" && row9 != "")
if (row9 != "未实施" && row9 != "进行中" && row9 != "已完成")
{
result += (i + 2).ToString() + "," + "是否需回复" + "," + "[" + row9 + "]错误!" + "|";
result += (i + 2).ToString() + "," + "处理状态" + "," + "[" + row9 + "]错误!" + "|";
}
}
string row11 = pds.Rows[i][11].ToString();
if (!string.IsNullOrEmpty(row11))
{
try
{
DateTime date = Convert.ToDateTime(row11.Trim());
}
catch (Exception)
{
result += (i + 2).ToString() + "," + "回复日期" + "," + "[" + row11 + "]错误!" + "|";
}
}
}
if (!string.IsNullOrEmpty(result))
{
@@ -319,7 +303,6 @@ namespace FineUIPro.Web.CQMS.Comprehensive
string rootPath = Server.MapPath("~/");
ImportXlsToData2(rootPath + initPath + this.hdFileName.Text);
hdCheckResult.Text = string.Empty;
ShowNotify("导入成功!", MessageBoxIcon.Success);
}
else
{
@@ -339,21 +322,21 @@ namespace FineUIPro.Web.CQMS.Comprehensive
/// <param name="filename">Excel文件路径名</param>
private void ImportXlsToData2(string fileName)
{
//支持.xls和.xlsx,即包括office2010等版本的 HDR=Yes代表第一行是标题,不是数据;
string cmdText = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source={0};Extended Properties='Excel 12.0; HDR=Yes; IMEX=1'";
//建立连接
OleDbConnection conn = new OleDbConnection(string.Format(cmdText, fileName));
try
{
string oleDBConnString = String.Empty;
oleDBConnString = "Provider=Microsoft.Jet.OLEDB.4.0;";
oleDBConnString += "Data Source=";
oleDBConnString += fileName;
oleDBConnString += ";Extended Properties=Excel 8.0;";
OleDbConnection oleDBConn = null;
//打开连接
if (conn.State == ConnectionState.Broken || conn.State == ConnectionState.Closed)
{
conn.Open();
}
OleDbDataAdapter oleAdMaster = null;
DataTable m_tableName = new DataTable();
DataSet ds = new DataSet();
oleDBConn = new OleDbConnection(oleDBConnString);
oleDBConn.Open();
m_tableName = oleDBConn.GetOleDbSchemaTable(OleDbSchemaGuid.Tables, null);
m_tableName = conn.GetOleDbSchemaTable(OleDbSchemaGuid.Tables, null);
if (m_tableName != null && m_tableName.Rows.Count > 0)
{
@@ -363,13 +346,13 @@ namespace FineUIPro.Web.CQMS.Comprehensive
}
string sqlMaster;
sqlMaster = " SELECT * FROM [" + m_tableName.TableName + "]";
oleAdMaster = new OleDbDataAdapter(sqlMaster, oleDBConn);
oleAdMaster = new OleDbDataAdapter(sqlMaster, conn);
oleAdMaster.Fill(ds, "m_tableName");
oleAdMaster.Dispose();
oleDBConn.Close();
oleDBConn.Dispose();
conn.Close();
conn.Dispose();
AddDatasetToSQL2(ds.Tables[0], 13);
AddDatasetToSQL2(ds.Tables[0], 4);
}
catch (Exception ex)
{
@@ -412,50 +395,63 @@ namespace FineUIPro.Web.CQMS.Comprehensive
var oldViewInfo = oldViewInfos.Where(x => x.ChangeOrderCode == pds.Rows[i][2].ToString().Trim()).FirstOrDefault();
if (oldViewInfo == null)
{
Model.Comprehensive_DataDistribution Ins = new Model.Comprehensive_DataDistribution();
Ins.FileCode = pds.Rows[i][0].ToString().Trim();
Ins.FileName = pds.Rows[i][1].ToString().Trim();
Ins.SendDate = Funs.GetNewDateTime(pds.Rows[i][2].ToString().Trim());
Model.Comprehensive_DesignChangeOrder Ins = new Model.Comprehensive_DesignChangeOrder();
Ins.ProjectId = this.CurrUser.LoginProjectId;
if (!string.IsNullOrEmpty(pds.Rows[i][3].ToString().Trim()))
if (!string.IsNullOrEmpty(pds.Rows[i][0].ToString().Trim()))
{
Ins.CNProfessionalId = Funs.DB.Base_CNProfessional.First(e => e.ProfessionalName == pds.Rows[i][3].ToString().Trim()).CNProfessionalId;
Ins.CNProfessionalId = Funs.DB.Base_CNProfessional.First(e => e.ProfessionalName == pds.Rows[i][0].ToString().Trim()).CNProfessionalId;
}
Ins.SendMan = pds.Rows[i][4].ToString().Trim();
if (!string.IsNullOrEmpty(pds.Rows[i][1].ToString().Trim()))
{
Ins.UnitWorkId = Funs.DB.WBS_UnitWork.First(e => e.UnitWorkName == pds.Rows[i][1].ToString().Trim()).UnitWorkId;
}
Ins.ChangeOrderCode = pds.Rows[i][2].ToString().Trim();
Ins.ChangeReason = pds.Rows[i][3].ToString().Trim();
Ins.Contents = pds.Rows[i][4].ToString().Trim();
if (!string.IsNullOrEmpty(pds.Rows[i][5].ToString().Trim()))
{
Ins.ReceivingUnit = BLL.UnitService.GetUnitIds(pds.Rows[i][5].ToString().Trim());
Ins.IssuedDate = Convert.ToDateTime(pds.Rows[i][5].ToString().Trim());
}
Ins.ReceivingMan = pds.Rows[i][6].ToString().Trim();
string row7 = pds.Rows[i][7].ToString().Trim();
if (!string.IsNullOrEmpty(row7))
if (!string.IsNullOrEmpty(pds.Rows[i][6].ToString().Trim()))
{
Ins.FileType = row7 == "纸质" ? "1" : "2";
Ins.ApprovalDate = Convert.ToDateTime(pds.Rows[i][6].ToString().Trim());
}
string row8 = pds.Rows[i][8].ToString().Trim();
if (!string.IsNullOrEmpty(row8))
if (!string.IsNullOrEmpty(pds.Rows[i][7].ToString().Trim()))
{
Ins.CopiesCount = Funs.GetNewInt(row8);
Ins.UnitId = BLL.UnitService.GetUnitIds(pds.Rows[i][7].ToString().Trim());
}
Ins.ImplementationFrontState = pds.Rows[i][8].ToString().Trim();
string row9 = pds.Rows[i][9].ToString().Trim();
if (!string.IsNullOrEmpty(row9))
{
Ins.IsReply = row9 == "是" ? true : false;
if (row9 == "未实施")
{
Ins.HandleState = "1";
}
if (row9 == "进行中")
{
Ins.HandleState = "2";
}
if (row9 == "已完成")
{
Ins.HandleState = "3";
}
}
Ins.ReplyCode = pds.Rows[i][10].ToString().Trim();
if (!string.IsNullOrEmpty(pds.Rows[i][11].ToString().Trim()))
{
Ins.ReplyDate = Convert.ToDateTime(pds.Rows[i][11].ToString().Trim());
}
Ins.Remark = pds.Rows[i][12].ToString().Trim();
Ins.DataDistributionId = SQLHelper.GetNewID(typeof(Model.Comprehensive_DataDistribution));
Ins.DesignChangeOrderId = SQLHelper.GetNewID(typeof(Model.Comprehensive_DesignChangeOrder));
Ins.CompileMan = this.CurrUser.UserId;
Ins.CompileDate = DateTime.Now.Date;
BLL.DataDistributionService.AddDataDistribution(Ins);
BLL.DesignChangeOrderService.AddDesignChangeOrder(Ins);
}
}
}
else
{