题库对应课程名称可以多选,且同一试题对应不同课程,课程呈现在相同单元格

题库——【课程分类】字段隐藏,另外增加【课程分类】筛选条件
培训需求新增Excel导入
master
xiaochanghai 4 months ago
parent e8c350d618
commit 31cf16415f
  1. 10
      Tiobon.Core.Api/Tiobon.Core.Model.xml
  2. 9
      Tiobon.Core.DataAccess/ReportHelper.cs
  3. 11
      Tiobon.Core.Model/Base/Ghre/Ghre_Question.Dto.Base.cs
  4. 11
      Tiobon.Core.Model/Models/Ghre/Ghre_Question.cs
  5. 2
      Tiobon.Core.Model/View/Ghre/Ghre_Question.Dto.View.cs
  6. 2
      Tiobon.Core.Services/BASE/BaseServices.cs
  7. 233
      Tiobon.Core.Services/Ghre/Ghre_QuestionServices.cs
  8. 188
      Tiobon.Core.Services/Ghre/Ghre_RequestServices.cs
  9. 8
      Tiobon.Core.Services/Ghre/Ghre_StaffGroupServices.cs
  10. 10
      Tiobon.Core/Tiobon.Core.Model.xml

@ -5665,6 +5665,11 @@
预留字段12
</summary>
</member>
<member name="P:Tiobon.Core.Model.Models.Ghre_QuestionBase.CourseIds">
<summary>
课程Ids
</summary>
</member>
<member name="T:Tiobon.Core.Model.Models.Ghre_QuestionAnswerBase">
<summary>
题目答案 (Dto.Base)
@ -20691,6 +20696,11 @@
预留字段12
</summary>
</member>
<member name="P:Tiobon.Core.Model.Models.Ghre_Question.CourseIds">
<summary>
课程Ids
</summary>
</member>
<member name="T:Tiobon.Core.Model.Models.Ghre_QuestionAnswer">
<summary>
题目答案 (Model)

@ -6,6 +6,7 @@ using NPOI.POIFS.NIO;
using NPOI.SS.Formula.Functions;
using NPOI.SS.UserModel;
using NPOI.SS.Util;
using NPOI.Util.Collections;
using NPOI.XSSF.UserModel;
using SqlSugar;
using System;
@ -920,12 +921,18 @@ public static class ReportHelper
dict.Add(x.field, id2);
}
}
else if (x.dataSource == "OrgTreeWithoutPriv")
else if (x.dataSource == "OrgTreeWithPriv")
{
string sql = @$"SELECT DeptID FROM Ghro_Dept WHERE DeptName = '{value}' OR DeptNo = '{value}' OR DeptEname = '{value}'";
var id2 = await Db.Ado.GetLongAsync(sql);
dict.Add(x.field, id2);
}
else if (x.dataSource == "StaffWithoutPriv")
{
string sql = @$"SELECT StaffID FROM Ghra_Staff WHERE StaffName = '{value}' OR StaffNo = '{value}' OR StaffEname = '{value}'";
var id2 = await Db.Ado.GetLongAsync(sql);
dict.Add(x.field, id2);
}
else
dict.Add(x.field, value);
}

@ -6,9 +6,9 @@
*
* Ver
*
*V0.01 2024/4/28 15:54:29 SimonHsiao
*V0.01 2025/2/19 10:56:52 SimonHsiao
*
* Copyright(c) 2024 Tiobon Corporation. All Rights Reserved.
* Copyright(c) 2025 Tiobon Corporation. All Rights Reserved.
*
*  
* SimonHsiao
@ -26,7 +26,6 @@ public class Ghre_QuestionBase
/// <summary>
/// 课程Id
/// </summary>
[Display(Name = "CourseIds"), Description("课程Id")]
public long? CourseId { get; set; }
/// <summary>
@ -139,4 +138,10 @@ public class Ghre_QuestionBase
/// 预留字段12
/// </summary>
public int? ReverseI2 { get; set; }
/// <summary>
/// 课程Ids
/// </summary>
[Display(Name = "CourseIds"), Description("课程Ids"), MaxLength(2000, ErrorMessage = "课程Ids 不能超过 2000 个字符")]
public string CourseIds { get; set; }
}

@ -6,9 +6,9 @@
*
* Ver
*
*V0.01 2024/4/28 15:54:29 SimonHsiao
*V0.01 2025/2/19 10:56:52 SimonHsiao
*
* Copyright(c) 2024 Tiobon Corporation. All Rights Reserved.
* Copyright(c) 2025 Tiobon Corporation. All Rights Reserved.
*
*  
* SimonHsiao
@ -27,7 +27,6 @@ public class Ghre_Question : BasePoco
/// <summary>
/// 课程Id
/// </summary>
[Display(Name = "CourseIds"), Description("课程Id")]
public long? CourseId { get; set; }
/// <summary>
@ -140,4 +139,10 @@ public class Ghre_Question : BasePoco
/// 预留字段12
/// </summary>
public int? ReverseI2 { get; set; }
/// <summary>
/// 课程Ids
/// </summary>
[Display(Name = "CourseIds"), Description("课程Ids"), MaxLength(2000, ErrorMessage = "课程Ids 不能超过 2000 个字符")]
public string CourseIds { get; set; }
}

@ -32,7 +32,7 @@ public class Ghre_QuestionDto : Ghre_Question
//public long CourseTypeId { get; set; }
public string CourseClassId { get; set; }
public string CourseType { get; set; }

@ -950,7 +950,7 @@ public class BaseServices<TEntity, TEntityDto, TInsertDto, TEditDto> : IBaseServ
}
return result;
}
public async virtual Task<ServiceResult<ExcelData>> ImportExcel(IFormFile file, string menuName = null, long? MasterId = null)
public virtual async Task<ServiceResult<ExcelData>> ImportExcel(IFormFile file, string menuName = null, long? MasterId = null)
{
var data = new ExcelData();
var (path, filepath) = await ReportHelper.GetImportFilePath(file, menuName);

@ -1,5 +1,4 @@
using Microsoft.IdentityModel.Tokens;
using NPOI.HSSF.UserModel;
using NPOI.HSSF.UserModel;
using NPOI.SS.UserModel;
using NPOI.SS.Util;
using NPOI.XSSF.UserModel;
@ -188,6 +187,44 @@ public class Ghre_QuestionServices : BaseServices<Ghre_Question, Ghre_QuestionDt
if (name == "page" || name == "pageSize")
continue;
if (name == "CourseType")
{
var jsonParam = JsonHelper.JsonToObj<JsonParam>(value);
if (jsonParam.columnValue != null)
{
switch (jsonParam.operationKey)
{
case "Include":
conditions += @$" AND EXISTS
(SELECT 1
FROM Ghre_Course Course
WHERE IsEnable = 1
AND {jsonParam.columnValue} IN
(SELECT value FROM openjson (CourseClassId))
AND Course.Id IN
(SELECT value FROM openjson (A.CourseIDs)))";
break;
case "NotInclude":
if (jsonParam.columnValue != null)
conditions += @$" AND NOT EXISTS
(SELECT 1
FROM Ghre_Course Course
WHERE IsEnable = 1
AND {jsonParam.columnValue} IN
(SELECT value FROM openjson (CourseClassId))
AND Course.Id IN
(SELECT value FROM openjson (A.CourseIDs)))";
break;
break;
default:
break;
}
}
continue;
}
if (!string.IsNullOrWhiteSpace(value))
conditions = DealConditions(conditions, name, value);
@ -196,25 +233,33 @@ public class Ghre_QuestionServices : BaseServices<Ghre_Question, Ghre_QuestionDt
filter.pageSize = 10000;
sql += conditions;
if (!string.IsNullOrWhiteSpace(condition))
sql += " AND " + condition;
var data = await Db.SqlQueryable<Ghre_QuestionDto>(sql)
.OrderBy(filter.orderBy)
.ToPageListAsync(filter.pageNum, filter.pageSize, totalCount);
var classsIds1 = data.Select(x => x.CourseClassId).Distinct().ToList();
var classsIds = new List<long>();
classsIds1.ForEach(x =>
var courseIds = new List<long>();
data.ForEach(x =>
{
if (!string.IsNullOrWhiteSpace(x))
{
var courseClassIds = JsonConvert.DeserializeObject<List<long>>(x);
classsIds = classsIds.Concat(courseClassIds).ToList();
}
if (x.CourseIds.IsNotEmptyOrNull())
courseIds.AddRange(JsonHelper.JsonToObj<List<long>>(x.CourseIds));
});
classsIds = classsIds.Distinct().ToList();
var classs = await _ghre_CourseClassServices.Query(x => classsIds.Contains(x.Id));
courseIds = courseIds.Distinct().ToList();
//var classsIds1 = data.Select(x => x.CourseClassId).Distinct().ToList();
//var classsIds = new List<long>();
//classsIds1.ForEach(x =>
//{
// if (!string.IsNullOrWhiteSpace(x))
// {
// var courseClassIds = JsonConvert.DeserializeObject<List<long>>(x);
// classsIds = classsIds.Concat(courseClassIds).ToList();
// }
//});
//classsIds = classsIds.Distinct().ToList();
var courses = await _ghre_CourseServices.Query(x => courseIds.Contains(x.Id));
data.ForEach(async x =>
{
@ -222,8 +267,8 @@ public class Ghre_QuestionServices : BaseServices<Ghre_Question, Ghre_QuestionDt
x.QuestionTypeLabel = await GetParaLabel("QuestionType", x.QuestionType);
if (!string.IsNullOrEmpty(x.QuestionContent))
x.QuestionContent = WebUtility.HtmlDecode(x.QuestionContent);
var courseClass = classs.Where(a => x.CourseClassId.Contains(a.Id.ToString())).ToList();
x.CourseType = string.Join(",", courseClass.Select(a => a.ClassName + " (" + a.ClassNo + ")"));
var courseClass = courses.Where(a => x.CourseIds.Contains(a.Id.ToString())).ToList();
x.CourseName = string.Join("", courseClass.Select(a => a.CourseName + " (" + a.CourseNo + ")"));
});
@ -267,7 +312,6 @@ public class Ghre_QuestionServices : BaseServices<Ghre_Question, Ghre_QuestionDt
#region PageData
var answerList = new List<FromGhre_QuestionQuestionAnswerList>
{
new FromGhre_QuestionQuestionAnswerList()
@ -370,7 +414,7 @@ public class Ghre_QuestionServices : BaseServices<Ghre_Question, Ghre_QuestionDt
var question = await base.QueryById(Id);
data.PageData.questionType.ForEach(x => x.isActive = 0);
data.PageData.baseData.questionNo = question.QuestionNo;
data.PageData.baseData.courseID.Add(question.CourseId);
data.PageData.baseData.courseID = JsonHelper.JsonToObj<List<long?>>(question.CourseIds);
data.PageData.baseData.CreateDataInfo = question.CreateDataInfo;
data.PageData.baseData.UpdateDataInfo = question.UpdateDataInfo;
@ -442,47 +486,48 @@ public class Ghre_QuestionServices : BaseServices<Ghre_Question, Ghre_QuestionDt
throw new Exception($"题库中存在相同题目");
}
}
#endregion
for (int j = 0; j < insertModel.baseData.courseID.Count; j++)
{
var courseID = insertModel.baseData.courseID[j];
var insert = new InsertGhre_QuestionInput();
insert.CourseId = courseID;
#endregion
//for (int j = 0; j < insertModel.baseData.courseID.Count; j++)
//{
//var courseID = insertModel.baseData.courseID[j];
var insert = new InsertGhre_QuestionInput();
//insert.CourseId = courseID;
insert.CourseIds = JsonHelper.ObjToJson(insertModel.baseData.courseID);
insert.QuestionType = questionType.type;
insert.DifficultyLevel = questionType.detail.difficulty;
insert.QuestionContent = questionType.detail.content;
insert.QuestionAnalysis = questionType.detail.RemarkSz;
insert.QuestionNo = await GenerateContinuousSequence(insert.QuestionType.Substring(0, 1));
insert.QuestionType = questionType.type;
insert.DifficultyLevel = questionType.detail.difficulty;
insert.QuestionContent = questionType.detail.content;
insert.QuestionAnalysis = questionType.detail.RemarkSz;
insert.QuestionNo = await GenerateContinuousSequence(insert.QuestionType.Substring(0, 1));
var id = await base.Add(insert);
var id = await base.Add(insert);
var insertAnswers = questionType.detail.answerList.Select(x => new InsertGhre_QuestionAnswerInput()
{
QuestionNo = x.No,
AnswerContent = x.label,
ImageUrl = x.imageUrl,
ImageWidthPc = x.imgWidthPc,
ImageWidthApp = x.imgWidthApp,
}).ToList();
int i = 100;
insertAnswers.ForEach(x =>
{
x.TaxisNo = i;
x.QuestionId = id;
if (questionType.detail.answer != null && questionType.detail.answer == x.QuestionNo && (insert.QuestionType == "Single" || insert.QuestionType == "TrueOrFalse"))
x.IsCorrect = true;
if (questionType.detail.answer1 != null && questionType.detail.answer1.Contains(x.QuestionNo) && (insert.QuestionType == "ShortAnswer" || insert.QuestionType == "Multiple" || insert.QuestionType == "Completion"))
x.IsCorrect = true;
i = i + 100;
});
if (insertAnswers.Where(b => string.IsNullOrWhiteSpace(b.AnswerContent) && string.IsNullOrWhiteSpace(b.ImageUrl)).Any())
throw new Exception(insert.QuestionType == "ShortAnswer" ? "关键词存在空值!" : "答案选项存在空值!");
if (!insertAnswers.Where(b => b.IsCorrect == true).Any())
throw new Exception(insert.QuestionType == "ShortAnswer" ? "关键词未填写!" : "正确答案未标记!");
await _ghre_QuestionAnswerServices.Add(insertAnswers);
}
var insertAnswers = questionType.detail.answerList.Select(x => new InsertGhre_QuestionAnswerInput()
{
QuestionNo = x.No,
AnswerContent = x.label,
ImageUrl = x.imageUrl,
ImageWidthPc = x.imgWidthPc,
ImageWidthApp = x.imgWidthApp,
}).ToList();
int i = 100;
insertAnswers.ForEach(x =>
{
x.TaxisNo = i;
x.QuestionId = id;
if (questionType.detail.answer != null && questionType.detail.answer == x.QuestionNo && (insert.QuestionType == "Single" || insert.QuestionType == "TrueOrFalse"))
x.IsCorrect = true;
if (questionType.detail.answer1 != null && questionType.detail.answer1.Contains(x.QuestionNo) && (insert.QuestionType == "ShortAnswer" || insert.QuestionType == "Multiple" || insert.QuestionType == "Completion"))
x.IsCorrect = true;
i = i + 100;
});
if (insertAnswers.Where(b => string.IsNullOrWhiteSpace(b.AnswerContent) && string.IsNullOrWhiteSpace(b.ImageUrl)).Any())
throw new Exception(insert.QuestionType == "ShortAnswer" ? "关键词存在空值!" : "答案选项存在空值!");
if (!insertAnswers.Where(b => b.IsCorrect == true).Any())
throw new Exception(insert.QuestionType == "ShortAnswer" ? "关键词未填写!" : "正确答案未标记!");
await _ghre_QuestionAnswerServices.Add(insertAnswers);
//}
await Db.Ado.CommitTranAsync();
return ServiceResult.OprateSuccess("新增成功!");
}
@ -576,49 +621,49 @@ public class Ghre_QuestionServices : BaseServices<Ghre_Question, Ghre_QuestionDt
await _ghre_QuestionAnswerServices.Add(insertAnswers);
for (int j = 0; j < editModel.baseData.courseID.Count; j++)
{
if (j == 0)
continue;
//for (int j = 0; j < editModel.baseData.courseID.Count; j++)
//{
// if (j == 0)
// continue;
var courseID = editModel.baseData.courseID[j];
var insert = new InsertGhre_QuestionInput();
insert.CourseId = courseID;
//var courseID = editModel.baseData.courseID[j];
var insert = new InsertGhre_QuestionInput();
insert.CourseIds = JsonHelper.ObjToJson(editModel.baseData.courseID);
insert.QuestionType = questionType.type;
insert.DifficultyLevel = questionType.detail.difficulty;
insert.QuestionContent = questionType.detail.content;
insert.QuestionAnalysis = questionType.detail.RemarkSz;
insert.QuestionNo = await GenerateContinuousSequence(insert.QuestionType.Substring(0, 1));
insert.QuestionType = questionType.type;
insert.DifficultyLevel = questionType.detail.difficulty;
insert.QuestionContent = questionType.detail.content;
insert.QuestionAnalysis = questionType.detail.RemarkSz;
insert.QuestionNo = await GenerateContinuousSequence(insert.QuestionType.Substring(0, 1));
var id = await base.Add(insert);
var id = await base.Add(insert);
insertAnswers = questionType.detail.answerList.Select(x => new InsertGhre_QuestionAnswerInput()
{
QuestionNo = x.No,
AnswerContent = x.label,
ImageUrl = x.imageUrl,
ImageWidthPc = x.imgWidthPc,
ImageWidthApp = x.imgWidthApp,
}).ToList();
i = 100;
insertAnswers.ForEach(x =>
{
x.TaxisNo = i;
x.QuestionId = id;
if (questionType.detail.answer != null && questionType.detail.answer == x.QuestionNo && (insert.QuestionType == "Single" || insert.QuestionType == "TrueOrFalse"))
x.IsCorrect = true;
if (questionType.detail.answer1 != null && questionType.detail.answer1.Contains(x.QuestionNo) && (insert.QuestionType == "ShortAnswer" || insert.QuestionType == "Multiple" || insert.QuestionType == "Completion"))
x.IsCorrect = true;
i = i + 100;
});
if (insertAnswers.Where(b => string.IsNullOrWhiteSpace(b.AnswerContent)).Any())
throw new Exception(insert.QuestionType == "ShortAnswer" ? "关键词存在空值!" : "答案选项存在空值!");
if (!insertAnswers.Where(b => b.IsCorrect == true).Any())
throw new Exception(insert.QuestionType == "ShortAnswer" ? "关键词未填写!" : "正确答案未标记!");
await _ghre_QuestionAnswerServices.Add(insertAnswers);
}
insertAnswers = questionType.detail.answerList.Select(x => new InsertGhre_QuestionAnswerInput()
{
QuestionNo = x.No,
AnswerContent = x.label,
ImageUrl = x.imageUrl,
ImageWidthPc = x.imgWidthPc,
ImageWidthApp = x.imgWidthApp,
}).ToList();
i = 100;
insertAnswers.ForEach(x =>
{
x.TaxisNo = i;
x.QuestionId = id;
if (questionType.detail.answer != null && questionType.detail.answer == x.QuestionNo && (insert.QuestionType == "Single" || insert.QuestionType == "TrueOrFalse"))
x.IsCorrect = true;
if (questionType.detail.answer1 != null && questionType.detail.answer1.Contains(x.QuestionNo) && (insert.QuestionType == "ShortAnswer" || insert.QuestionType == "Multiple" || insert.QuestionType == "Completion"))
x.IsCorrect = true;
i = i + 100;
});
if (insertAnswers.Where(b => string.IsNullOrWhiteSpace(b.AnswerContent)).Any())
throw new Exception(insert.QuestionType == "ShortAnswer" ? "关键词存在空值!" : "答案选项存在空值!");
if (!insertAnswers.Where(b => b.IsCorrect == true).Any())
throw new Exception(insert.QuestionType == "ShortAnswer" ? "关键词未填写!" : "正确答案未标记!");
await _ghre_QuestionAnswerServices.Add(insertAnswers);
//}
await Db.Ado.CommitTranAsync();
return ServiceResult.OprateSuccess("更新成功!");

@ -1,4 +1,6 @@
using Serilog;
using Microsoft.EntityFrameworkCore.Metadata.Internal;
using Serilog;
using System.Collections.Generic;
using static Tiobon.Core.Model.Consts;
namespace Tiobon.Core.Services;
@ -323,6 +325,190 @@ FROM Ghre_Request A
}
#region Excel导入
public static async Task<(List<Dictionary<string, object>>, int)> ValidImportExcel(ISqlSugarClient Db, List<QueryExportColumn> columns, DataTable dt)
{
Type entityType = typeof(Ghre_Request);
var properties = entityType.GetGenericProperties();
int ErrorCount = 0;
var dictList = new List<Dictionary<string, object>>();
for (int i = 0; i < dt.Rows.Count; i++)
{
var dict = ReportHelper.GetDefaultDict();
var comments = new List<string>();
for (int j = 0; j < columns.Count; j++)
{
var x = columns[j];
if (!dt.Columns.Contains(x.label))
comments.Add("未查询到【" + x.label + "】列!");
else
{
var value = dt.Rows[i][x.label].ToString();
var courseSource = dt.Rows[i]["课程来源"].ToString();
if (x.label == "需求课程" || x.label == "新增课程")
{
if (x.label == "需求课程" && courseSource == "已有课程" && value.IsNullOrEmpty())
{
comments.Add(x.label + "不能为空!");
dt.Rows[i]["Comments"] = string.Join(";", comments.Select(a => a));
}
else if (x.label == "新增课程" && courseSource == "新增课程" && value.IsNullOrEmpty())
{
comments.Add(x.label + "不能为空!");
dt.Rows[i]["Comments"] = string.Join(";", comments.Select(a => a));
}
}
else
if (x.required == "true" && value.IsNullOrEmpty())
{
comments.Add(x.label + "不能为空!");
dt.Rows[i]["Comments"] = string.Join(";", comments.Select(a => a));
}
if (x.dataSourceType.IsNullOrEmpty() && value.IsNotEmptyOrNull())
{
if (x.dataType == "int" || x.dataType == "decimal")
{
try
{
Convert.ToDecimal(value);
}
catch (Exception)
{
comments.Add(x.label + "无效的数字类型!");
}
}
else if (x.dataType == "date")
{
try
{
Convert.ToDateTime(value);
}
catch (Exception)
{
comments.Add(x.label + "无效的日期类型!");
}
}
}
if (value.IsNotEmptyOrNull())
{
if (x.field == "TrainStaffIds")
{
value = value.Replace(",", ",");
value = value.Replace(";", ",");
value = value.Replace(";", ",");
var value1 = value.Split(',').ToList();
var ids = await Db.Queryable<Ghra_Staff>().Where(o => value1.Contains(o.StaffName) || value1.Contains(o.StaffNo) || value1.Contains(o.StaffEname)).Select(x => x.StaffID).ToListAsync();
dict.Add("TrainStaffId", JsonHelper.ObjToJson(ids));
}
else
{
if (x.elementType == "Switch")
value = value == "是" ? "true" : "false";
if (x.dataSourceId.IsNotEmptyOrNull() && x.dataSourceType.IsNotEmptyOrNull() && !x.dataSource.StartsWith("OrgTreeWith")
&& !x.dataSource.StartsWith("StaffWith"))
{
if (x.dataSourceType == "CommonList")
{
var commonSql = await Db.Queryable<Ghrs_ListCommonSql>().Where(o => o.ListCommonSqlId == x.dataSourceId).FirstAsync();
if (commonSql != null)
{
string sql = @$"SELECT [value]
FROM ({commonSql.SelectSql}) A
WHERE label = '{value}'";
sql = sql.Replace("{@LangID}", "1");
sql = sql.Replace("{@UserID}", App.User.ID.ObjToString());
sql = sql.Replace("{@KeyWords}", null);
var id2 = await Db.Ado.GetLongAsync(sql);
if (properties.Any(o => o.Name == x.field))
dict.Add(x.field, id2);
}
}
else if (x.dataSourceType == "ParaDetailNo")
{
var sql = @$"SELECT ParaDetailNo
FROM Ghrs_ParaDetail
WHERE ParaMasterId IN (SELECT ParaMasterId
FROM Ghrs_ParaMaster
WHERE ParaMasterId = {x.dataSourceId.ObjToInt()})
AND IsEnable = 1
AND ParaDetailName = '{value}'";
var id2 = await Db.Ado.GetStringAsync(sql);
if (properties.Any(o => o.Name == x.field))
dict.Add(x.field, id2);
}
}
else if (x.dataSource == "OrgTreeWithPriv")
{
string sql = @$"SELECT DeptID FROM Ghro_Dept WHERE DeptName = '{value}' OR DeptNo = '{value}' OR DeptEname = '{value}'";
var id2 = await Db.Ado.GetLongAsync(sql);
if (properties.Any(o => o.Name == x.field))
dict.Add(x.field, id2);
}
else if (x.dataSource == "StaffWithoutPriv")
{
string sql = @$"SELECT StaffID FROM Ghra_Staff WHERE StaffName = '{value}' OR StaffNo = '{value}' OR StaffEname = '{value}'";
var id2 = await Db.Ado.GetLongAsync(sql);
if (properties.Any(o => o.Name == x.field))
dict.Add(x.field, id2);
}
else
{
if (properties.Any(o => o.Name == x.field))
dict.Add(x.field, value);
}
}
}
}
}
if (comments.Any())
{
dt.Rows[i]["Comments"] = string.Join(";", comments.Select(a => a));
ErrorCount++;
continue;
}
else
dictList.Add(dict);
}
return (dictList, ErrorCount);
}
public override async Task<ServiceResult<ExcelData>> ImportExcel(IFormFile file, string menuName = null, long? MasterId = null)
{
var data = new ExcelData();
var (path, filepath) = await ReportHelper.GetImportFilePath(file, menuName);
var id1 = SnowFlakeSingle.instance.getID();
string errorFileName = path + SnowFlakeSingle.instance.getID() + FileHelper.GetPostfixStr(filepath);
var dt = ReportHelper.ReadImportExcel(filepath);
var columns = await QueryExportColumn(menuName);
var (dictList, errorCount) = await ValidImportExcel(Db, columns, dt);
Type entityType = typeof(Ghre_Request);
var properties = entityType.GetGenericProperties();
if (errorCount > 0)
{
NPOIHelper.ExportExcel(dt, null, "导入数据", FileHelper.GetPhysicsPath() + errorFileName);
data.filePath = "/Advanced" + errorFileName;
data.ErrorCount = errorCount;
}
else
{
await Db.Insertable(dictList).AS(entityType.GetEntityTableName()).ExecuteCommandAsync();
data.SuccessCount = dictList.Count;
}
return ServiceResult<ExcelData>.OprateSuccess("导入成功!", data);
}
#endregion
#region 牛尾培训需求同步
public async Task Ushio_Sync()

@ -1,10 +1,4 @@
using NPOI.SS.Formula.Functions;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using Tiobon.Core.Model;
namespace Tiobon.Core.Services;
namespace Tiobon.Core.Services;
/// <summary>
/// 员工群组 (服务)

@ -5665,6 +5665,11 @@
预留字段12
</summary>
</member>
<member name="P:Tiobon.Core.Model.Models.Ghre_QuestionBase.CourseIds">
<summary>
课程Ids
</summary>
</member>
<member name="T:Tiobon.Core.Model.Models.Ghre_QuestionAnswerBase">
<summary>
题目答案 (Dto.Base)
@ -20691,6 +20696,11 @@
预留字段12
</summary>
</member>
<member name="P:Tiobon.Core.Model.Models.Ghre_Question.CourseIds">
<summary>
课程Ids
</summary>
</member>
<member name="T:Tiobon.Core.Model.Models.Ghre_QuestionAnswer">
<summary>
题目答案 (Model)

Loading…
Cancel
Save