This commit is contained in:
何美荣 2026-03-26 14:58:04 +08:00
commit fac79612d9

View File

@ -522,6 +522,14 @@ namespace APT.SE.WebApi.Controllers.Api
List<string> listPointNameEmpty = new List<string>();
DateTime dtNow = DateTime.Now;
//数据库现有题目 去重判断
List<T_SE_TEST> listDataAllCheck = GetEntities<T_SE_TEST>(e => !e.IS_DELETED, null, null).ToList();
T_SE_TEST check = null;
List<string> listRepeatDataIndex = new List<string>();
List<string> listNameTypeError = new List<string>();
List<string> listRepeatExcelIndex = new List<string>();
List<string> listNameTypeEError = new List<string>();
for (int i = 0; i < rowAll; i++)
{
#region
@ -562,15 +570,15 @@ namespace APT.SE.WebApi.Controllers.Api
var testType = dtSource.Rows[i][1].ToString().Trim();
if (!string.IsNullOrEmpty(testType))
{
if (dtSource.Rows[i][1].ToString().Trim() == "是非题")
if (testType == "是非题")
{
mainTable.TYPE = SETestTypeEnum.;
}
else if (dtSource.Rows[i][1].ToString().Trim() == "单选题")
else if (testType == "单选题")
{
mainTable.TYPE = SETestTypeEnum.;
}
else if (dtSource.Rows[i][1].ToString().Trim() == "多选题")
else if (testType == "多选题")
{
mainTable.TYPE = SETestTypeEnum.;
}
@ -583,6 +591,20 @@ namespace APT.SE.WebApi.Controllers.Api
{
throw new Exception("题型不能为空!");
}
check = listDataAllCheck.FirstOrDefault(e => e.NAME == mainTable.NAME && e.TYPE == mainTable.TYPE);
if (check != null)
{
listRepeatDataIndex.Add((i + rowIndex).ToString());
listNameTypeError.Add(mainTable.NAME + "" + testType);
}
check = mainTables.FirstOrDefault(e => e.NAME == mainTable.NAME && e.TYPE == mainTable.TYPE);
if (check != null)
{
listRepeatExcelIndex.Add((i + rowIndex).ToString());
listNameTypeEError.Add(mainTable.NAME + "" + testType);
}
if (!string.IsNullOrEmpty(dtSource.Rows[i][2].ToString().Trim()))
{
mainTable.OPTION_A = (dtSource.Rows[i][2].ToString().Trim());
@ -609,11 +631,11 @@ namespace APT.SE.WebApi.Controllers.Api
mainTable.ANSWERSHOW = strANSWER;
if (mainTable.TYPE == SETestTypeEnum.)
{
if (strANSWER == "" || strANSWER == "A")
if (strANSWER == "A" || strANSWER == "是" || strANSWER == "a")
{
mainTable.ANSWER = 1;
}
else if (strANSWER == "否" || strANSWER == "B")
else if (strANSWER == "B" || strANSWER == "否" || strANSWER == "b")
{
mainTable.ANSWER = 2;
}
@ -626,8 +648,7 @@ namespace APT.SE.WebApi.Controllers.Api
listAnswerErrorIndex.Add((i + rowIndex).ToString());
}
}
if (mainTable.TYPE == SETestTypeEnum.)
else if (mainTable.TYPE == SETestTypeEnum.)
{
if (strANSWER == "A")
{
@ -654,7 +675,7 @@ namespace APT.SE.WebApi.Controllers.Api
listAnswerErrorIndex.Add((i + rowIndex).ToString());
}
}
if (mainTable.TYPE == SETestTypeEnum.)
else if (mainTable.TYPE == SETestTypeEnum.)
{
int answer = 0;
if (strANSWER.Contains("A"))
@ -809,7 +830,7 @@ namespace APT.SE.WebApi.Controllers.Api
#region
string strEmptyError = string.Empty;
if (listPostNameEmpty.Count > 0 || dicIndexEmpty.Count > 0 || listPointNameEmpty.Count > 0)
if (listPostNameEmpty.Count > 0 || dicIndexEmpty.Count > 0 || listPointNameEmpty.Count > 0 || listRepeatDataIndex.Count > 0 || listRepeatExcelIndex.Count > 0)
{
if (dicIndexEmpty.Count > 0)
{
@ -840,6 +861,14 @@ namespace APT.SE.WebApi.Controllers.Api
{
throw new Exception("答案有误,行:【" + string.Join(",", listAnswerErrorIndex) + "】值:" + string.Join(",", listAnswerError));
}
if (listRepeatDataIndex.Count > 0)
{
throw new Exception("与现有题库重复,行:【" + string.Join(",", listRepeatDataIndex) + "】值:" + string.Join(",", listNameTypeError));
}
if (listRepeatExcelIndex.Count > 0)
{
throw new Exception("Excel中题目重复【" + string.Join(",", listRepeatExcelIndex) + "】值:" + string.Join(",", listNameTypeEError));
}
}
if (strEmptyError != string.Empty)
throw new Exception(strEmptyError);