Compare commits
2 Commits
8d074fcb7d
...
5ad7ec4385
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5ad7ec4385 | ||
|
|
2c2ad2fb05 |
137520
APT.Data.Migrations/Migrations/20260113030058_wyw2026011301.Designer.cs
generated
Normal file
137520
APT.Data.Migrations/Migrations/20260113030058_wyw2026011301.Designer.cs
generated
Normal file
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,23 @@
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
namespace APT.Data.Migrations.Migrations
|
||||
{
|
||||
public partial class wyw2026011301 : Migration
|
||||
{
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.AddColumn<int>(
|
||||
name: "EXAMINATION_RESULTS",
|
||||
table: "T_SE_TRAIN_RECORD_PAPER",
|
||||
type: "int",
|
||||
nullable: true);
|
||||
}
|
||||
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropColumn(
|
||||
name: "EXAMINATION_RESULTS",
|
||||
table: "T_SE_TRAIN_RECORD_PAPER");
|
||||
}
|
||||
}
|
||||
}
|
||||
137520
APT.Data.Migrations/Migrations/20260113032016_wyw2026011302.Designer.cs
generated
Normal file
137520
APT.Data.Migrations/Migrations/20260113032016_wyw2026011302.Designer.cs
generated
Normal file
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,33 @@
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
namespace APT.Data.Migrations.Migrations
|
||||
{
|
||||
public partial class wyw2026011302 : Migration
|
||||
{
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropColumn(
|
||||
name: "EXAMINATION_RESULTS",
|
||||
table: "T_SE_TRAIN_RECORD_PAPER");
|
||||
|
||||
migrationBuilder.AddColumn<int>(
|
||||
name: "EXAMINATION_RESULTS",
|
||||
table: "T_SE_TRAIN_RECORD_REPORT",
|
||||
type: "int",
|
||||
nullable: true);
|
||||
}
|
||||
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropColumn(
|
||||
name: "EXAMINATION_RESULTS",
|
||||
table: "T_SE_TRAIN_RECORD_REPORT");
|
||||
|
||||
migrationBuilder.AddColumn<int>(
|
||||
name: "EXAMINATION_RESULTS",
|
||||
table: "T_SE_TRAIN_RECORD_PAPER",
|
||||
type: "int",
|
||||
nullable: true);
|
||||
}
|
||||
}
|
||||
}
|
||||
137526
APT.Data.Migrations/Migrations/20260114085739_wyw20260114.Designer.cs
generated
Normal file
137526
APT.Data.Migrations/Migrations/20260114085739_wyw20260114.Designer.cs
generated
Normal file
File diff suppressed because it is too large
Load Diff
35
APT.Data.Migrations/Migrations/20260114085739_wyw20260114.cs
Normal file
35
APT.Data.Migrations/Migrations/20260114085739_wyw20260114.cs
Normal file
@ -0,0 +1,35 @@
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
namespace APT.Data.Migrations.Migrations
|
||||
{
|
||||
public partial class wyw20260114 : Migration
|
||||
{
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.AddColumn<decimal>(
|
||||
name: "SCOREPER",
|
||||
table: "T_SE_COURSEWEARLIBRARY_DETAIL",
|
||||
type: "decimal(18,2)",
|
||||
nullable: false,
|
||||
defaultValue: 0m);
|
||||
|
||||
migrationBuilder.AddColumn<decimal>(
|
||||
name: "SCOREPASS",
|
||||
table: "T_SE_COURSEWEARLIBRARY",
|
||||
type: "decimal(18,2)",
|
||||
nullable: false,
|
||||
defaultValue: 0m);
|
||||
}
|
||||
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropColumn(
|
||||
name: "SCOREPER",
|
||||
table: "T_SE_COURSEWEARLIBRARY_DETAIL");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "SCOREPASS",
|
||||
table: "T_SE_COURSEWEARLIBRARY");
|
||||
}
|
||||
}
|
||||
}
|
||||
137530
APT.Data.Migrations/Migrations/20260115012758_wyw2026011501.Designer.cs
generated
Normal file
137530
APT.Data.Migrations/Migrations/20260115012758_wyw2026011501.Designer.cs
generated
Normal file
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,24 @@
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
namespace APT.Data.Migrations.Migrations
|
||||
{
|
||||
public partial class wyw2026011501 : Migration
|
||||
{
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.AddColumn<string>(
|
||||
name: "FILENAME",
|
||||
table: "T_SE_COURSEWEARLIBRARY",
|
||||
type: "nvarchar(200)",
|
||||
maxLength: 200,
|
||||
nullable: true);
|
||||
}
|
||||
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropColumn(
|
||||
name: "FILENAME",
|
||||
table: "T_SE_COURSEWEARLIBRARY");
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -71982,6 +71982,10 @@ namespace APT.Data.Migrations.Migrations
|
||||
b.Property<int>("ENTITY_ORG_TPYE")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<string>("FILENAME")
|
||||
.HasMaxLength(200)
|
||||
.HasColumnType("nvarchar(200)");
|
||||
|
||||
b.Property<Guid?>("FILE_DB_ID")
|
||||
.HasColumnType("uniqueidentifier");
|
||||
|
||||
@ -72018,6 +72022,9 @@ namespace APT.Data.Migrations.Migrations
|
||||
.IsRequired()
|
||||
.HasColumnType("uniqueidentifier");
|
||||
|
||||
b.Property<decimal>("SCOREPASS")
|
||||
.HasColumnType("decimal(18,2)");
|
||||
|
||||
b.Property<Guid>("USER_ID")
|
||||
.HasColumnType("uniqueidentifier");
|
||||
|
||||
@ -72080,6 +72087,9 @@ namespace APT.Data.Migrations.Migrations
|
||||
.IsRequired()
|
||||
.HasColumnType("uniqueidentifier");
|
||||
|
||||
b.Property<decimal>("SCOREPER")
|
||||
.HasColumnType("decimal(18,2)");
|
||||
|
||||
b.Property<Guid>("TEST_ID")
|
||||
.HasColumnType("uniqueidentifier");
|
||||
|
||||
@ -75389,6 +75399,9 @@ namespace APT.Data.Migrations.Migrations
|
||||
b.Property<int>("ENTITY_ORG_TPYE")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int?>("EXAMINATION_RESULTS")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<Guid?>("FLOW_ID")
|
||||
.HasColumnType("uniqueidentifier");
|
||||
|
||||
|
||||
@ -10806,6 +10806,7 @@ builder.HasOne(t => t.Nav_Department).WithMany().HasForeignKey(t => t.DEPARTMENT
|
||||
builder.HasOne(t => t.Nav_User).WithMany().HasForeignKey(t => t.USER_ID).OnDelete(DeleteBehavior.Restrict);
|
||||
builder.HasOne(t => t.Nav_FileDB).WithMany().HasForeignKey(t => t.FILE_DB_ID).OnDelete(DeleteBehavior.Restrict);
|
||||
builder.Property(t => t.FILE_PATH).HasMaxLength(200);
|
||||
builder.Property(t => t.FILENAME).HasMaxLength(200);
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
@ -10892,6 +10893,7 @@ builder.Property(t => t.OPTION_B).HasMaxLength(500);
|
||||
builder.Property(t => t.OPTION_C).HasMaxLength(500);
|
||||
builder.Property(t => t.OPTION_D).HasMaxLength(500);
|
||||
builder.Property(t => t.OPTION_E).HasMaxLength(500);
|
||||
builder.Ignore(t => t.ANSWERSHOW);
|
||||
builder.Property(t => t.TRAINNAME).HasMaxLength(500);
|
||||
builder.Property(t => t.MineType).HasMaxLength(500);
|
||||
}
|
||||
|
||||
@ -99,11 +99,25 @@ namespace APT.MS.Domain.Entities.SE
|
||||
[DataFieldLength(200)]
|
||||
public string FILE_PATH { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 文件名称
|
||||
/// </summary>
|
||||
[Description("文件名称")]
|
||||
[DataFieldLength(200)]
|
||||
public string FILENAME { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 题库试题
|
||||
/// </summary>
|
||||
[Description("题库试题")]
|
||||
[FormFieldEdit]
|
||||
public ICollection<T_SE_COURSEWEARLIBRARY_DETAIL> Nav_Detail { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 及格分
|
||||
/// </summary>
|
||||
[Description("及格分")]
|
||||
public decimal SCOREPASS { get; set; } = 80;
|
||||
}
|
||||
}
|
||||
|
||||
@ -39,6 +39,12 @@ namespace APT.MS.Domain.Entities.SE
|
||||
[FormFieldQuery]
|
||||
public int NUM { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 分数
|
||||
/// </summary>
|
||||
[Description("分数")]
|
||||
public decimal SCOREPER { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 试题
|
||||
/// </summary>
|
||||
|
||||
@ -86,6 +86,15 @@ namespace APT.MS.Domain.Entities.SE
|
||||
[FormFieldEdit]
|
||||
public int ANSWER { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 答案
|
||||
/// 是非题 是 1 否 2
|
||||
/// 单选题 A 1, B 2, C 4, D 8
|
||||
/// 多选题 单选位或
|
||||
/// </summary>
|
||||
[Description("答案")]
|
||||
[DataFieldIngore]
|
||||
public string ANSWERSHOW { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 适用表单
|
||||
|
||||
@ -172,5 +172,11 @@ namespace APT.MS.Domain.Entities.SE
|
||||
[Description("搜索结束时间")]
|
||||
[DataFieldIngore]
|
||||
public string START_TIME_E { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 考核结果
|
||||
/// </summary>
|
||||
[Description("考核结果")]
|
||||
public SEExaminationResultsEnum? EXAMINATION_RESULTS { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@ -0,0 +1,746 @@
|
||||
using APT.Infrastructure.Core;
|
||||
using APT.MS.Domain.Entities.SE;
|
||||
using APT.MS.Domain.Enums;
|
||||
using APT.Utility;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using APT.Infrastructure.Core;
|
||||
using APT.BaseData.Domain.ApiModel;
|
||||
using System.Data;
|
||||
using System.IO;
|
||||
using APT.BaseData.Domain.Entities.FM;
|
||||
using APT.BaseData.Domain.Entities;
|
||||
|
||||
namespace APT.SE.WebApi.Controllers.Api
|
||||
{
|
||||
[Route("api/SE/SECoursewearlibrary")]
|
||||
public partial class SECoursewearlibraryController : AuthorizeApiController<T_SE_COURSEWEARLIBRARY>
|
||||
{
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 更新
|
||||
/// </summary>
|
||||
/// <param name="entity"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost, Route("FullUpdate")]
|
||||
public JsonActionResult<bool> FullUpdate([FromBody] T_SE_COURSEWEARLIBRARY entity)
|
||||
{
|
||||
return SafeExecute<bool>(() =>
|
||||
{
|
||||
var Files = entity.Nav_Files;
|
||||
entity.Nav_Files = null;
|
||||
|
||||
var Detail = entity.Nav_Detail;
|
||||
entity.Nav_Detail = null;
|
||||
|
||||
if (Files != null && Files.Count() > 1)
|
||||
{
|
||||
throw new Exception("课件只能单一文件");
|
||||
}
|
||||
if (entity.FILE_DB_ID.HasValue && Files != null && Files.Count > 0)
|
||||
{
|
||||
throw new Exception("视频和附件只能有一个!");//不然到时候 考试 看视频或者附件不好处理
|
||||
}
|
||||
if (entity.SCOREPASS == 0)
|
||||
{
|
||||
throw new Exception("请输入及格分(不能为0)!");
|
||||
}
|
||||
List<T_SE_TEST> listT = new List<T_SE_TEST>();
|
||||
List<T_SE_TEST_LIST_POST> listTPost = new List<T_SE_TEST_LIST_POST>();
|
||||
List<T_SE_TEST_LIST_POINT> listTPoint = new List<T_SE_TEST_LIST_POINT>();
|
||||
if (Detail == null || Detail.Count < 1)
|
||||
{
|
||||
throw new Exception("请添加题目!");
|
||||
}
|
||||
else
|
||||
{
|
||||
decimal ScorePer = 0;
|
||||
decimal sum = Detail.Where(e => !e.IS_DELETED).Sum(e => e.SCOREPER);
|
||||
if (sum != 100)
|
||||
{
|
||||
int dc = Detail.Where(e => !e.IS_DELETED).Count();
|
||||
ScorePer = Math.Round(Convert.ToDecimal(100.0 / dc), 2);
|
||||
if (dc * ScorePer != 100)
|
||||
{
|
||||
throw new Exception("题数" + dc + "不能被100除尽!");
|
||||
}
|
||||
}
|
||||
foreach (var item in Detail)
|
||||
{
|
||||
if (item.IS_DELETED)
|
||||
continue;
|
||||
if (ScorePer != 0)
|
||||
item.SCOREPER = ScorePer;
|
||||
if (item.EDU_CARD_ID == Guid.Empty)
|
||||
item.EDU_CARD_ID = entity.ID;
|
||||
if (item.TEST_ID == Guid.Empty)
|
||||
{
|
||||
throw new Exception("试题ID传参有误,课件试题只能通过导入的方式!");
|
||||
}
|
||||
|
||||
if (item.Nav_Test != null)
|
||||
{
|
||||
if (item.Nav_Test.Nav_Points != null && item.Nav_Test.Nav_Points.Count > 0)
|
||||
listTPost.AddRange(item.Nav_Test.Nav_Posts);
|
||||
// item.Nav_Test.Nav_Posts = null;
|
||||
//}
|
||||
if (item.Nav_Test.Nav_Posts != null && item.Nav_Test.Nav_Posts.Count > 0)
|
||||
listTPoint.AddRange(item.Nav_Test.Nav_Points);
|
||||
// item.Nav_Test.Nav_Points = null;
|
||||
//}
|
||||
listT.Add(item.Nav_Test);
|
||||
item.Nav_Test = null;
|
||||
}
|
||||
//if (item.TEST_ID == Guid.Empty)
|
||||
//{
|
||||
// //手动添加信息
|
||||
//}
|
||||
}
|
||||
}
|
||||
|
||||
if (!entity.FILE_DB_ID.HasValue)
|
||||
{
|
||||
Guid? imgFileID = Files.Find(e => !e.IS_DELETED)?.IMG_FILE_ID;
|
||||
if (imgFileID.HasValue)
|
||||
{
|
||||
//去完善
|
||||
var img = GetEntity<T_PF_IMG_FILE>(imgFileID.Value);
|
||||
if (img != null)
|
||||
{
|
||||
entity.FILE_PATH = img.FILE_PATH;
|
||||
entity.FILENAME = img.FILE_NAME;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (entity.USER_ID == Guid.Empty)
|
||||
{
|
||||
entity.USER_ID = APT.Infrastructure.Api.AppContext.CurrentSession.UserID.Value;
|
||||
entity.DEPARTMENTID = APT.Infrastructure.Api.AppContext.CurrentSession.DepartmentID.Value;
|
||||
}
|
||||
|
||||
UnifiedCommit(() =>
|
||||
{
|
||||
UpdateEntityNoCommit(entity);
|
||||
if (Detail != null && Detail.Any())
|
||||
BantchSaveEntityNoCommit(Detail);
|
||||
if (Files != null && Files.Any())
|
||||
BantchSaveEntityNoCommit(Files);
|
||||
if (listT != null && listT.Any())
|
||||
BantchSaveEntityNoCommit(listT);
|
||||
if (listTPost != null && listTPost.Any())
|
||||
BantchSaveEntityNoCommit(listTPost);
|
||||
if (listTPoint != null && listTPoint.Any())
|
||||
BantchSaveEntityNoCommit(listTPoint);
|
||||
});
|
||||
|
||||
return true;
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 获得单条实体数据
|
||||
/// </summary>
|
||||
/// <param name="filter">过滤实体</param>
|
||||
/// <returns></returns>
|
||||
[HttpPost, Route("GetShow")]
|
||||
public JsonActionResult<T_SE_COURSEWEARLIBRARY> GetShow([FromBody] KeywordFilter filter)
|
||||
{
|
||||
return SafeExecute(() =>
|
||||
{
|
||||
var result = GetEntity<T_SE_COURSEWEARLIBRARY>(null, filter, null);
|
||||
if (result.Nav_Detail != null && result.Nav_Detail.Count() > 0)
|
||||
{
|
||||
string ANSWERSHOW = string.Empty;
|
||||
foreach (var item in result.Nav_Detail)
|
||||
{
|
||||
ANSWERSHOW = string.Empty;
|
||||
GetAnswerShow(item.Nav_Test, ref ANSWERSHOW);
|
||||
item.Nav_Test.ANSWERSHOW = ANSWERSHOW;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
});
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取分数显示
|
||||
/// </summary>
|
||||
/// <param name="Nav_Test"></param>
|
||||
/// <param name="ANSWERSHOW"></param>
|
||||
private void GetAnswerShow(T_SE_TEST Nav_Test, ref string ANSWERSHOW)
|
||||
{
|
||||
|
||||
try
|
||||
{
|
||||
if (Nav_Test != null && Nav_Test.ANSWER != 0 && ((int)Nav_Test.TYPE) != 0)
|
||||
{
|
||||
switch (Nav_Test.ANSWER)
|
||||
{
|
||||
case 0:
|
||||
ANSWERSHOW = "";
|
||||
break;
|
||||
case 1:
|
||||
ANSWERSHOW = "A";
|
||||
break;
|
||||
case 2:
|
||||
ANSWERSHOW = "B";
|
||||
break;
|
||||
case 3:
|
||||
ANSWERSHOW = "AB";
|
||||
break;
|
||||
case 4:
|
||||
ANSWERSHOW = "C";
|
||||
break;
|
||||
case 5:
|
||||
ANSWERSHOW = "AC";
|
||||
break;
|
||||
case 6:
|
||||
ANSWERSHOW = "AB";
|
||||
break;
|
||||
case 7:
|
||||
ANSWERSHOW = "ABC";
|
||||
break;
|
||||
case 8:
|
||||
ANSWERSHOW = "D";
|
||||
break;
|
||||
case 9:
|
||||
ANSWERSHOW = "AD";
|
||||
break;
|
||||
case 10:
|
||||
ANSWERSHOW = "BD";
|
||||
break;
|
||||
case 11:
|
||||
ANSWERSHOW = "ABD";
|
||||
break;
|
||||
case 12:
|
||||
ANSWERSHOW = "CD";
|
||||
break;
|
||||
case 13:
|
||||
ANSWERSHOW = "ACD";
|
||||
break;
|
||||
case 14:
|
||||
ANSWERSHOW = "BCD";
|
||||
break;
|
||||
case 15:
|
||||
ANSWERSHOW = "ABCD";
|
||||
break;
|
||||
case 16:
|
||||
ANSWERSHOW = "E";
|
||||
break;
|
||||
case 17:
|
||||
ANSWERSHOW = "AE";
|
||||
break;
|
||||
case 18:
|
||||
ANSWERSHOW = "BE";
|
||||
break;
|
||||
case 19:
|
||||
ANSWERSHOW = "ABE";
|
||||
break;
|
||||
case 20:
|
||||
ANSWERSHOW = "CE";
|
||||
break;
|
||||
case 21:
|
||||
ANSWERSHOW = "ACE";
|
||||
break;
|
||||
case 22:
|
||||
ANSWERSHOW = "ABE";
|
||||
break;
|
||||
case 23:
|
||||
ANSWERSHOW = "ABCE";
|
||||
break;
|
||||
case 24:
|
||||
ANSWERSHOW = "DE";
|
||||
break;
|
||||
case 25:
|
||||
ANSWERSHOW = "ADE";
|
||||
break;
|
||||
case 26:
|
||||
ANSWERSHOW = "BDE";
|
||||
break;
|
||||
case 27:
|
||||
ANSWERSHOW = "ABDE";
|
||||
break;
|
||||
case 28:
|
||||
ANSWERSHOW = "CDE";
|
||||
break;
|
||||
case 29:
|
||||
ANSWERSHOW = "ACDE";
|
||||
break;
|
||||
case 30:
|
||||
ANSWERSHOW = "BCDE";
|
||||
break;
|
||||
case 31:
|
||||
ANSWERSHOW = "ABCDE";
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
catch { }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取导入数据
|
||||
/// 参考 [Route("api/PF/Import")]
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpPost, Route("GetImportData")]
|
||||
public JsonActionResult<IEnumerable<T_SE_COURSEWEARLIBRARY_DETAIL>> GetImportData()
|
||||
{
|
||||
return SafeExecute<IEnumerable<T_SE_COURSEWEARLIBRARY_DETAIL>>(() =>
|
||||
{
|
||||
List<T_SE_COURSEWEARLIBRARY_DETAIL> listImport = new List<T_SE_COURSEWEARLIBRARY_DETAIL>();
|
||||
var orgId = APT.Infrastructure.Api.AppContext.CurrentSession.OrgId;
|
||||
var httpRequest = this.HttpContext.Request;
|
||||
string orgIdStr = httpRequest.Form["OrgId"];// 获取 组织
|
||||
//ImportDataModel result = new ImportDataModel();
|
||||
var dic = Path.Combine(System.AppContext.BaseDirectory, "tempImportFiles");
|
||||
if (!Directory.Exists(dic))
|
||||
Directory.CreateDirectory(dic);
|
||||
int NUM = 0;
|
||||
Guid TEST_ID = Guid.Empty;
|
||||
Guid EDU_CARD_ID = Guid.Empty;
|
||||
if (httpRequest.Form.ContainsKey("EDU_CARD_ID"))
|
||||
{
|
||||
string strEduID = httpRequest.Form["EDU_CARD_ID"];
|
||||
if (!string.IsNullOrEmpty(strEduID))
|
||||
{
|
||||
try
|
||||
{
|
||||
EDU_CARD_ID = new Guid(strEduID);
|
||||
}
|
||||
catch
|
||||
{
|
||||
EDU_CARD_ID = Guid.Empty;
|
||||
}
|
||||
}
|
||||
}
|
||||
T_SE_TEST test = null;
|
||||
foreach (var key in httpRequest.Form.Files) // 文件键
|
||||
{
|
||||
var postedFile = key; // 获取文件键对应的文件对象
|
||||
string filePath = Path.Combine(dic, DateTime.Now.ToString("yyyy_MM_dd_hh_mm_ss") + "_" + postedFile.FileName);
|
||||
Byte[] fileData = new Byte[postedFile.Length];
|
||||
Stream sr = postedFile.OpenReadStream();//创建数据流对象
|
||||
sr.Read(fileData, 0, (int)postedFile.Length);
|
||||
using (FileStream fs = new FileStream(filePath, FileMode.CreateNew))
|
||||
{
|
||||
fs.Write(fileData, 0, fileData.Length);
|
||||
fs.Flush();
|
||||
fs.Close();
|
||||
}
|
||||
|
||||
//获取数据
|
||||
Dictionary<int, int> startRowIndexs = new Dictionary<int, int>();
|
||||
startRowIndexs.Add(0, 1);//根据Excel格式数据赋值
|
||||
var dataTables = FileUtils.ReadExcelByOledb(filePath, startRowIndexs);
|
||||
string Msg = string.Empty;
|
||||
bool isOK = InsertModel(dataTables.Tables[0], orgId, EDU_CARD_ID, ref Msg, ref listImport);
|
||||
try
|
||||
{
|
||||
System.IO.File.Delete(filePath);
|
||||
}
|
||||
catch { }
|
||||
|
||||
//foreach (var item in dataTables.Tables[0].Rows)
|
||||
//{
|
||||
// //题目
|
||||
// NUM++;
|
||||
// test = new T_SE_TEST()
|
||||
// {
|
||||
// ID = Guid.NewGuid(),
|
||||
// ORG_ID = orgId,
|
||||
// CREATE_TIME = DateTime.Now,
|
||||
// };
|
||||
|
||||
// listImport.Add(new T_SE_COURSEWEARLIBRARY_DETAIL()
|
||||
// {
|
||||
// ID = Guid.NewGuid(),
|
||||
// ORG_ID = orgId,
|
||||
// EDU_CARD_ID = EDU_CARD_ID,
|
||||
// NUM = NUM,
|
||||
// TEST_ID = test.ID,
|
||||
// Nav_Test = test,
|
||||
// CREATE_TIME = test.CREATE_TIME
|
||||
// });
|
||||
//}
|
||||
}
|
||||
return listImport;
|
||||
});
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 数据插入
|
||||
/// </summary>
|
||||
/// <param name="dtSource"></param>
|
||||
/// <param name="orgId"></param>
|
||||
/// <param name="EDU_CARD_ID"></param>
|
||||
/// <param name="Msg"></param>
|
||||
/// <param name="listImport"></param>
|
||||
/// <param name="rowIndex"></param>
|
||||
/// <returns></returns>
|
||||
/// <exception cref="Exception"></exception>
|
||||
public bool InsertModel(DataTable dtSource, Guid? orgId, Guid EDU_CARD_ID, ref string Msg, ref List<T_SE_COURSEWEARLIBRARY_DETAIL> listImport, int rowIndex = 1)
|
||||
{
|
||||
var userId = APT.Infrastructure.Api.AppContext.CurrentSession.UserID;
|
||||
if (dtSource == null || dtSource.Rows.Count < rowIndex)
|
||||
{
|
||||
Msg = "未获取到导入数据";
|
||||
throw new Exception(Msg);
|
||||
}
|
||||
List<int> listNotEmpty = new List<int>() { 0, 1, 7 };//, 8, 10
|
||||
Dictionary<int, List<int>> dicIndexEmpty = new Dictionary<int, List<int>>();
|
||||
int rowAll = dtSource.Rows.Count;
|
||||
int colAll = dtSource.Columns.Count;
|
||||
List<T_SE_TEST> mainTables = new List<T_SE_TEST>();
|
||||
List<T_SE_TEST_LIST_POST> sub1s = new List<T_SE_TEST_LIST_POST>();
|
||||
List<T_SE_TEST_LIST_POINT> sub2s = new List<T_SE_TEST_LIST_POINT>();
|
||||
List<T_SE_TEST_LIST_POST> sub1sPer = null;
|
||||
List<T_SE_TEST_LIST_POINT> sub2sPer = null;
|
||||
|
||||
var posts = GetEntities<T_FM_USER_POST>(t => t.IS_DELETED == false, new BaseFilter(orgId));
|
||||
var points = GetEntities<T_SE_TEST_ENUM_POINT>(t => t.IS_DELETED == false, new BaseFilter(orgId));
|
||||
T_FM_USER_POST modelPost = null;
|
||||
List<string> listPostNameEmpty = new List<string>();
|
||||
|
||||
List<string> listAnswerErrorIndex = new List<string>();
|
||||
List<string> listAnswerError = new List<string>();
|
||||
string strANSWER = string.Empty;
|
||||
T_SE_TEST_ENUM_POINT modelPoint = null;
|
||||
List<string> listPointNameEmpty = new List<string>();
|
||||
DateTime dtNow = DateTime.Now;
|
||||
|
||||
for (int i = 0; i < rowAll; i++)
|
||||
{
|
||||
#region 不能为空
|
||||
|
||||
List<int> listi = null;
|
||||
for (int j = 0; j < colAll; j++)
|
||||
{
|
||||
if (!listNotEmpty.Contains(j))
|
||||
continue;
|
||||
|
||||
if (string.IsNullOrEmpty(dtSource.Rows[i][j].ToString().Trim()))
|
||||
{
|
||||
if (listi == null)
|
||||
{
|
||||
listi = new List<int>();
|
||||
}
|
||||
listi.Add(j);
|
||||
}
|
||||
}
|
||||
if (listi != null)
|
||||
dicIndexEmpty.Add(i + rowIndex, listi);//有空的 直接添加
|
||||
|
||||
#endregion
|
||||
if (dicIndexEmpty.Count < 1)
|
||||
{
|
||||
T_SE_TEST mainTable = new T_SE_TEST();
|
||||
mainTable.ID = Guid.NewGuid();
|
||||
mainTable.ORG_ID = orgId;
|
||||
var testName = dtSource.Rows[i][0].ToString().Trim();
|
||||
if (!string.IsNullOrEmpty(testName))
|
||||
{
|
||||
mainTable.NAME = testName;
|
||||
}
|
||||
else
|
||||
{
|
||||
continue;
|
||||
}
|
||||
var testType = dtSource.Rows[i][1].ToString().Trim();
|
||||
if (!string.IsNullOrEmpty(testType))
|
||||
{
|
||||
if (dtSource.Rows[i][1].ToString().Trim() == "是非题")
|
||||
{
|
||||
mainTable.TYPE = SETestTypeEnum.是非题;
|
||||
}
|
||||
else if (dtSource.Rows[i][1].ToString().Trim() == "单选题")
|
||||
{
|
||||
mainTable.TYPE = SETestTypeEnum.单选题;
|
||||
}
|
||||
else if (dtSource.Rows[i][1].ToString().Trim() == "多选题")
|
||||
{
|
||||
mainTable.TYPE = SETestTypeEnum.多选题;
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new Exception("没有《" + testType + "》类型");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new Exception("题型不能为空!");
|
||||
}
|
||||
if (!string.IsNullOrEmpty(dtSource.Rows[i][2].ToString().Trim()))
|
||||
{
|
||||
mainTable.OPTION_A = (dtSource.Rows[i][2].ToString().Trim());
|
||||
}
|
||||
if (!string.IsNullOrEmpty(dtSource.Rows[i][3].ToString().Trim()))
|
||||
{
|
||||
mainTable.OPTION_B = (dtSource.Rows[i][3].ToString().Trim());
|
||||
}
|
||||
if (!string.IsNullOrEmpty(dtSource.Rows[i][4].ToString().Trim()))
|
||||
{
|
||||
mainTable.OPTION_C = (dtSource.Rows[i][4].ToString().Trim());
|
||||
}
|
||||
if (!string.IsNullOrEmpty(dtSource.Rows[i][5].ToString().Trim()))
|
||||
{
|
||||
mainTable.OPTION_D = (dtSource.Rows[i][5].ToString().Trim());
|
||||
}
|
||||
if (!string.IsNullOrEmpty(dtSource.Rows[i][6].ToString().Trim()))
|
||||
{
|
||||
mainTable.OPTION_E = (dtSource.Rows[i][6].ToString().Trim());
|
||||
}
|
||||
strANSWER = dtSource.Rows[i][7].ToString().Trim();
|
||||
if (!string.IsNullOrEmpty(strANSWER))
|
||||
{
|
||||
mainTable.ANSWERSHOW = strANSWER;
|
||||
if (mainTable.TYPE == SETestTypeEnum.是非题)
|
||||
{
|
||||
if (strANSWER == "是" || strANSWER == "A")
|
||||
{
|
||||
mainTable.ANSWER = 1;
|
||||
}
|
||||
else if (strANSWER == "否" || strANSWER == "B")
|
||||
{
|
||||
mainTable.ANSWER = 2;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (listAnswerError.Contains(strANSWER))
|
||||
{
|
||||
listAnswerError.Add(strANSWER);
|
||||
}
|
||||
listAnswerErrorIndex.Add((i + rowIndex).ToString());
|
||||
}
|
||||
}
|
||||
|
||||
if (mainTable.TYPE == SETestTypeEnum.单选题)
|
||||
{
|
||||
if (strANSWER == "A")
|
||||
{
|
||||
mainTable.ANSWER = 1;
|
||||
}
|
||||
else if (strANSWER == "B")
|
||||
{
|
||||
mainTable.ANSWER = 2;
|
||||
}
|
||||
else if (strANSWER == "C")
|
||||
{
|
||||
mainTable.ANSWER = 4;
|
||||
}
|
||||
else if (strANSWER == "D")
|
||||
{
|
||||
mainTable.ANSWER = 8;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (listAnswerError.Contains(strANSWER))
|
||||
{
|
||||
listAnswerError.Add(strANSWER);
|
||||
}
|
||||
listAnswerErrorIndex.Add((i + rowIndex).ToString());
|
||||
}
|
||||
}
|
||||
if (mainTable.TYPE == SETestTypeEnum.多选题)
|
||||
{
|
||||
int answer = 0;
|
||||
if (strANSWER.Contains("A"))
|
||||
{
|
||||
answer = answer + 1;
|
||||
}
|
||||
if (strANSWER.Contains("B"))
|
||||
{
|
||||
answer = answer + 2;
|
||||
}
|
||||
if (strANSWER.Contains("C"))
|
||||
{
|
||||
answer = answer + 4;
|
||||
}
|
||||
if (strANSWER.Contains("D"))
|
||||
{
|
||||
answer = answer + 8;
|
||||
}
|
||||
if (strANSWER.Contains("E"))
|
||||
{
|
||||
answer = answer + 16;
|
||||
}
|
||||
mainTable.ANSWER = answer;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (listAnswerError.Contains(strANSWER))
|
||||
{
|
||||
listAnswerError.Add(strANSWER);
|
||||
}
|
||||
listAnswerErrorIndex.Add((i + rowIndex).ToString());
|
||||
}
|
||||
if (!string.IsNullOrEmpty(dtSource.Rows[i][8].ToString().Trim()))
|
||||
{
|
||||
int k = 0;
|
||||
if (dtSource.Rows[i][8].ToString().Contains("安全意识调查"))
|
||||
{
|
||||
k = k + 1;
|
||||
}
|
||||
if (dtSource.Rows[i][8].ToString().Contains("培训"))
|
||||
{
|
||||
k = k + 2;
|
||||
}
|
||||
if (dtSource.Rows[i][8].ToString().Contains("事故事件"))
|
||||
{
|
||||
k = k + 4;
|
||||
}
|
||||
mainTable.USAGE = k;
|
||||
}
|
||||
else
|
||||
{
|
||||
mainTable.USAGE = 2;//默认培训
|
||||
}
|
||||
sub1sPer = new List<T_SE_TEST_LIST_POST>();
|
||||
sub2sPer = new List<T_SE_TEST_LIST_POINT>();
|
||||
if (!string.IsNullOrEmpty(dtSource.Rows[i][9].ToString().Trim()))
|
||||
{
|
||||
var testPosts = dtSource.Rows[i][9].ToString().Trim().Split(';');
|
||||
foreach (var postName in testPosts)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(postName))
|
||||
{
|
||||
modelPost = posts.FirstOrDefault(t => t.NAME == postName);
|
||||
if (modelPost == null)
|
||||
{
|
||||
if (!listPostNameEmpty.Contains(postName))
|
||||
listPostNameEmpty.Add(postName);
|
||||
}
|
||||
else
|
||||
{
|
||||
T_SE_TEST_LIST_POST sub1 = new T_SE_TEST_LIST_POST
|
||||
{
|
||||
ID = Guid.NewGuid(),
|
||||
ORG_ID = orgId,
|
||||
TEST_ID = mainTable.ID,
|
||||
POST_ID = posts.FirstOrDefault(t => t.NAME == postName).ID
|
||||
};
|
||||
sub1sPer.Add(sub1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (!string.IsNullOrEmpty(dtSource.Rows[i][10].ToString().Trim()))
|
||||
{
|
||||
var testPoints = dtSource.Rows[i][10].ToString().Trim().Split(';');
|
||||
foreach (var pointName in testPoints)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(pointName))
|
||||
{
|
||||
modelPoint = points.FirstOrDefault(t => t.NAME == pointName);
|
||||
if (modelPoint != null)
|
||||
{
|
||||
T_SE_TEST_LIST_POINT sub2 = new T_SE_TEST_LIST_POINT
|
||||
{
|
||||
ID = Guid.NewGuid(),
|
||||
ORG_ID = orgId,
|
||||
TEST_ID = mainTable.ID,
|
||||
POINT_ID = modelPoint.ID,
|
||||
};
|
||||
sub2sPer.Add(sub2);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!listPointNameEmpty.Contains(pointName))
|
||||
listPointNameEmpty.Add(pointName);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (sub1sPer != null && sub1sPer.Count > 0)
|
||||
sub1s.AddRange(sub1sPer);
|
||||
if (sub2sPer != null && sub2sPer.Count > 0)
|
||||
sub2s.AddRange(sub2sPer);
|
||||
|
||||
if (!string.IsNullOrEmpty(dtSource.Rows[i][11].ToString().Trim()))
|
||||
{
|
||||
mainTable.TRAINNAME = dtSource.Rows[i][11].ToString().Trim();
|
||||
}
|
||||
mainTables.Add((T_SE_TEST)mainTable.Clone());
|
||||
|
||||
if (sub2sPer != null && sub2sPer.Count > 0)
|
||||
mainTable.Nav_Points = sub2sPer;//知识点
|
||||
if (sub1sPer != null && sub1sPer.Count > 0)
|
||||
mainTable.Nav_Posts = sub1sPer;//适用岗位
|
||||
|
||||
listImport.Add(new T_SE_COURSEWEARLIBRARY_DETAIL()
|
||||
{
|
||||
ID = Guid.NewGuid(),
|
||||
ORG_ID = orgId,
|
||||
EDU_CARD_ID = EDU_CARD_ID,
|
||||
NUM = i + 1,
|
||||
TEST_ID = mainTable.ID,
|
||||
Nav_Test = mainTable,
|
||||
CREATE_TIME = mainTable.CREATE_TIME
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
#region 提示
|
||||
|
||||
string strEmptyError = string.Empty;
|
||||
if (listPostNameEmpty.Count > 0 || dicIndexEmpty.Count > 0 || listPointNameEmpty.Count > 0)
|
||||
{
|
||||
if (dicIndexEmpty.Count > 0)
|
||||
{
|
||||
int colIndex = 0;
|
||||
foreach (var item in dicIndexEmpty)
|
||||
{
|
||||
strEmptyError += "行:" + item.Key + ",列:";
|
||||
colIndex = 0;
|
||||
foreach (var itemVal in item.Value)
|
||||
{
|
||||
strEmptyError += (colIndex > 0 ? "、" : "") + itemVal;
|
||||
colIndex++;
|
||||
}
|
||||
strEmptyError += ";";
|
||||
}
|
||||
strEmptyError = strEmptyError.Substring(0, strEmptyError.Length - 1) + "不能为空!";
|
||||
}
|
||||
|
||||
if (listPostNameEmpty.Count > 0)
|
||||
{
|
||||
throw new Exception("岗位未找到:" + string.Join(",", listPostNameEmpty));
|
||||
}
|
||||
if (listPointNameEmpty.Count > 0)
|
||||
{
|
||||
throw new Exception("知识点未找到:" + string.Join(",", listPointNameEmpty));
|
||||
}
|
||||
if (listAnswerErrorIndex.Count > 0)
|
||||
{
|
||||
throw new Exception("答案有误,行:【" + string.Join(",", listAnswerErrorIndex) + "】值:" + string.Join(",", listAnswerError));
|
||||
}
|
||||
}
|
||||
if (strEmptyError != string.Empty)
|
||||
throw new Exception(strEmptyError);
|
||||
|
||||
#endregion
|
||||
|
||||
UnifiedCommit(() =>
|
||||
{
|
||||
if (mainTables != null && mainTables.Any())
|
||||
BantchAddEntityNoCommit(mainTables);
|
||||
if (sub1s != null && sub1s.Any())
|
||||
BantchAddEntityNoCommit(sub1s);
|
||||
if (sub2s != null && sub2s.Any())
|
||||
BantchAddEntityNoCommit(sub2s);
|
||||
});
|
||||
//Msg = "导入成功!";
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -427,11 +427,11 @@ namespace APT.SE.WebApi.Controllers.Api
|
||||
{
|
||||
if (mainTable.TYPE == SETestTypeEnum.是非题)
|
||||
{
|
||||
if (strANSWER == "是")
|
||||
if (strANSWER == "是" || strANSWER == "A")
|
||||
{
|
||||
mainTable.ANSWER = 1;
|
||||
}
|
||||
else if (strANSWER == "否")
|
||||
else if (strANSWER == "否" || strANSWER == "B")
|
||||
{
|
||||
mainTable.ANSWER = 2;
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user