You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
588 lines
22 KiB
588 lines
22 KiB
|
|
using Tiobon.Core.IServices;
|
|
using Tiobon.Core.Model.Models;
|
|
using Tiobon.Core.Services.BASE;
|
|
using Tiobon.Core.IRepository.Base;
|
|
using Tiobon.Core.Common.Caches;
|
|
using System.Dynamic;
|
|
using Tiobon.Core.Model;
|
|
using Tiobon.Core.Common;
|
|
using AgileObjects.AgileMapper;
|
|
using Newtonsoft.Json;
|
|
using Newtonsoft.Json.Linq;
|
|
using SqlSugar;
|
|
using Tiobon.Core.Common.Helper;
|
|
|
|
namespace Tiobon.Core.Services;
|
|
|
|
/// <summary>
|
|
/// 考试 (服务)
|
|
/// </summary>
|
|
public class Ghre_ExamServices : BaseServices<Ghre_Exam, Ghre_ExamDto, InsertGhre_ExamInput, EditGhre_ExamInput>, IGhre_ExamServices
|
|
{
|
|
private readonly IBaseRepository<Ghre_Exam> _dal;
|
|
private readonly IGhre_CourseServices _ghre_CourseServices;
|
|
private readonly IGhre_CourseSceneServices _ghre_CourseSceneServices;
|
|
private readonly IGhra_StaffServices _ghra_StaffSceneServices;
|
|
private readonly IGhre_ExamStaffServices _ghre_ExamStaffServices;
|
|
public Ghre_ExamServices(ICaching caching,
|
|
IGhre_CourseServices ghre_CourseServices,
|
|
IGhre_CourseSceneServices ghre_CourseSceneServices,
|
|
IGhra_StaffServices ghra_StaffSceneServices,
|
|
IGhre_ExamStaffServices ghre_ExamStaffServices,
|
|
IBaseRepository<Ghre_Exam> dal)
|
|
{
|
|
this._dal = dal;
|
|
base.BaseDal = dal;
|
|
base._caching = caching;
|
|
_ghre_CourseServices = ghre_CourseServices;
|
|
_ghre_CourseSceneServices = ghre_CourseSceneServices;
|
|
_ghra_StaffSceneServices = ghra_StaffSceneServices;
|
|
_ghre_ExamStaffServices = ghre_ExamStaffServices;
|
|
}
|
|
public async Task<dynamic> GetModuleInfo(ModuleParam param)
|
|
{
|
|
dynamic result = new ExpandoObject();
|
|
dynamic data = new ExpandoObject();
|
|
|
|
var Toolbar = new List<Toolbar>();
|
|
|
|
Toolbar.Add(new Toolbar()
|
|
{
|
|
fnKey = "NewYN",
|
|
fnKeyValue = null,
|
|
fnTitle = "新增",
|
|
fnType = "table",
|
|
position = "left",
|
|
icon = "ghr-icon-add",
|
|
display = true
|
|
});
|
|
Toolbar.Add(new Toolbar()
|
|
{
|
|
fnKey = "Release",
|
|
fnKeyValue = null,
|
|
fnTitle = "发布",
|
|
fnType = "table",
|
|
position = "left",
|
|
icon = "ghr-publish",
|
|
display = true
|
|
});
|
|
|
|
var DT_Procedure = new DT_Procedure();
|
|
|
|
var sql = "select QueryProcedure, EditProcedure, IUDProcedure from Ghrs_Menu where MenuNo='{0}'";
|
|
sql = string.Format(sql, param.menuName, App.User.ID, param.langId);
|
|
var dt = Db.Ado.GetDataTable(sql);
|
|
if (dt.Rows.Count > 0)
|
|
{
|
|
DT_Procedure.QueryProcedure = dt.Rows[0]["QueryProcedure"].ToString();
|
|
DT_Procedure.EditProcedure = dt.Rows[0]["EditProcedure"].ToString();
|
|
DT_Procedure.IUDProcedure = dt.Rows[0]["IUDProcedure"].ToString();
|
|
}
|
|
sql = $@"SELECT PageSettingQueryId,
|
|
elementType,
|
|
field,
|
|
[dbo].[FLangKeyToValue] (Meky, {param.langId}, label)
|
|
label,
|
|
Meky,
|
|
multipleSelect,
|
|
dataType,
|
|
required,
|
|
palceholder,
|
|
dataSourceType,
|
|
dbo.FS_GetdataSourceBySet
|
|
(dataSource, APIDataSourceType, Ghrs_PageSettingQuery.APIDataSourceID)
|
|
dataSource,
|
|
sortable,
|
|
sortOrder,
|
|
defaultHidden,
|
|
ConfigIsShow,
|
|
filterable,
|
|
CAST(CASE WHEN width = '' THEN '100' ELSE width END AS INT) width,
|
|
align,
|
|
fixed,
|
|
editable,
|
|
searchable,
|
|
searchRequired,
|
|
searchColumnSeq,
|
|
multipleSearchValue,
|
|
maxTagCount,
|
|
selfDefine,
|
|
selectUI,
|
|
isPrimaryKey,
|
|
'false'
|
|
isSorted,
|
|
'false'
|
|
isHidden,
|
|
CASE
|
|
WHEN searchColumnSeq IS NULL OR searchColumnSeq = '' THEN 'false'
|
|
ELSE 'true'
|
|
END
|
|
isSearched,
|
|
SortNo,
|
|
-- searchCanOperator,
|
|
( select ParaDetailNo operator,
|
|
[dbo].[FLangKeyToValue](MKey,1,ParaDetailName) operatorDesc,
|
|
SqlFunction operatorIcon
|
|
from Ghrs_ParaDetail where ParaMasterId=13 and IsEnable=1
|
|
and ParaDetailNo in (select Value from dbo.Fs1_GHR30_SplitString2(searchCanOperator,','))
|
|
order by (select positon from dbo.Fs1_GHR30_SplitString2(searchCanOperator,',')
|
|
where value= ParaDetailNo)
|
|
FOR JSON Path ) searchOperator1,
|
|
''
|
|
searchColumnDefaultValue,
|
|
''
|
|
AppColumnType
|
|
FROM Ghrs_PageSettingQuery
|
|
WHERE PageNo = '{param.menuName}'
|
|
AND elementType NOT IN ('PageGroup')
|
|
AND IsEnable = 1
|
|
ORDER BY SortNo ASC";
|
|
|
|
sql = string.Format(sql, param.menuName, App.User.ID, param.langId);
|
|
var TableColumn = Db.Ado.SqlQuery<TableColumn1>(sql);
|
|
var SearchFormFields = Mapper.Map(TableColumn).ToANew<List<TableColumn>>();
|
|
SearchFormFields.ForEach(x =>
|
|
{
|
|
if (!string.IsNullOrWhiteSpace(x.searchOperator1))
|
|
x.searchOperator = JsonConvert.DeserializeObject<List<searchOperator>>(x.searchOperator1);
|
|
x.searchOperator1 = null;
|
|
});
|
|
|
|
|
|
|
|
#region DT_PageMutiMsg
|
|
var DT_PageMutiMsg = await _caching.GetAsync<List<DT_PageMutiMsg>>("DT_PageMutiMsg");
|
|
if (DT_PageMutiMsg == null || (DT_PageMutiMsg != null && !DT_PageMutiMsg.Any()))
|
|
{
|
|
sql = $@"SELECT Langkey field,
|
|
CASE {param.langId}
|
|
WHEN 1 THEN isnull (Value01, LangValue)
|
|
WHEN 2 THEN isnull (Value02, LangValue)
|
|
WHEN 3 THEN isnull (Value03, LangValue)
|
|
WHEN 4 THEN isnull (Value04, LangValue)
|
|
WHEN 5 THEN isnull (Value05, LangValue)
|
|
WHEN 6 THEN isnull (Value06, LangValue)
|
|
WHEN 7 THEN isnull (Value07, LangValue)
|
|
WHEN 8 THEN isnull (Value08, LangValue)
|
|
WHEN 9 THEN isnull (Value09, LangValue)
|
|
WHEN 10 THEN isnull (Value10, LangValue)
|
|
END label
|
|
FROM Ghrs_LangKey
|
|
WHERE (LangKey LIKE 'GHR_Page%' OR LangKey LIKE 'GHR_Common%')
|
|
AND IsEnable = 1";
|
|
DT_PageMutiMsg = Db.Ado.SqlQuery<DT_PageMutiMsg>(sql);
|
|
if (DT_PageMutiMsg.Any())
|
|
await _caching.SetAsync("DT_PageMutiMsg", DT_PageMutiMsg);
|
|
}
|
|
#endregion
|
|
|
|
data.Toolbar = Toolbar;
|
|
data.DT_Procedure = DT_Procedure;
|
|
data.SearchFormFields = SearchFormFields;
|
|
data.DT_PageMutiMsg = DT_PageMutiMsg;
|
|
|
|
result.Success = true;
|
|
result.Status = 200;
|
|
result.Data = data;
|
|
result.Message = "查询成功";
|
|
return result;
|
|
}
|
|
|
|
public async Task<dynamic> QueryList(QueryBody body, string status)
|
|
{
|
|
var data = await QueryFilterPage1(body, status);
|
|
|
|
dynamic return1 = new ExpandoObject();
|
|
dynamic result = new ExpandoObject();
|
|
dynamic DT_TablePageInfoT1 = new ExpandoObject();
|
|
|
|
result.DT_TableDataT1 = data.result.DT_TableDataT1;
|
|
DT_TablePageInfoT1.PageNum = body.pageNum;
|
|
DT_TablePageInfoT1.PageSize = body.pageSize;
|
|
DT_TablePageInfoT1.TotalCount = data.result.DT_TablePageInfoT1.TotalCount;
|
|
result.DT_TablePageInfoT1 = DT_TablePageInfoT1;
|
|
dynamic CardConfig = new ExpandoObject();
|
|
CardConfig.cardTitle = "ExamName";
|
|
CardConfig.cardImage = "CoverUrl";
|
|
CardConfig.column1 = "AfterHowLongLabel";
|
|
CardConfig.column1Icon = "ghr-form-designer-deteSelect";
|
|
CardConfig.column2 = "CourseName";
|
|
CardConfig.column2Icon = "ghr-exam-paper";
|
|
CardConfig.column3 = "ExamModeLabel";
|
|
CardConfig.column3Icon = "ghr-online-exam";
|
|
CardConfig.column4 = "OpenClassName";
|
|
CardConfig.column4Icon = "ghr-link-openClass";
|
|
CardConfig.column5 = "";
|
|
CardConfig.column5Icon = "";
|
|
CardConfig.column6 = "";
|
|
CardConfig.column6Icon = "";
|
|
result.CardConfig = CardConfig;
|
|
|
|
|
|
return1.result = result;
|
|
return1.message = "查询成功!";
|
|
return1.Success = true;
|
|
return1.code = 0;
|
|
return1.type = "success";
|
|
return return1;
|
|
}
|
|
|
|
public async Task<ServicePageResult<Ghre_ExamDto>> QueryFilterPage1(QueryBody filter, string status = null)
|
|
{
|
|
RefAsync<int> totalCount = 0;
|
|
string sql = @"SELECT *
|
|
FROM (SELECT A.*,
|
|
B.CourseName,
|
|
C.Id CourseTypeId,
|
|
C.ClassName CourseType
|
|
FROM Ghre_Exam A
|
|
LEFT JOIN Ghre_Course B ON A.CourseId = B.Id
|
|
LEFT JOIN Ghre_CourseClass C ON B.CourseClassId = C.Id
|
|
WHERE A.IsEnable = 1) A";
|
|
|
|
if (string.IsNullOrWhiteSpace(filter.orderBy))
|
|
filter.orderBy = "CreateTime DESC";
|
|
|
|
string conditions = "1=1";
|
|
if (filter.jsonParam != null)
|
|
foreach (JProperty jProperty in filter.jsonParam.Properties())
|
|
{
|
|
var name = jProperty.Name;
|
|
var value = jProperty.Value.ToString();
|
|
if (name == "page" || name == "pageSize")
|
|
continue;
|
|
|
|
if (!string.IsNullOrWhiteSpace(value))
|
|
{
|
|
var jsonParam = JsonConvert.DeserializeObject<JsonParam>(value);
|
|
|
|
switch (jsonParam.operationKey)
|
|
{
|
|
case "Include":
|
|
conditions += $" AND {name} LIKE '%{jsonParam.columnValue}%'";
|
|
break;
|
|
case "NotInclude":
|
|
conditions += $" AND {name} NOT LIKE '%{jsonParam.columnValue}%'";
|
|
break;
|
|
case "IsNull":
|
|
conditions += $" AND {name} IS NULL";
|
|
break;
|
|
case "NotNull":
|
|
conditions += $" AND {name} IS NOT NULL";
|
|
break;
|
|
case "Equal":
|
|
conditions += $" AND {name} ='{jsonParam.columnValue}'";
|
|
break;
|
|
case "NotEqual":
|
|
conditions += $" AND {name} !='{jsonParam.columnValue}'";
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
if (filter.pageSize == 0)
|
|
filter.pageSize = 10000;
|
|
var data = await Db.SqlQueryable<Ghre_ExamDto>(sql)
|
|
.OrderBy(filter.orderBy)
|
|
.ToPageListAsync(filter.pageNum, filter.pageSize, totalCount);
|
|
|
|
//data.ForEach(async x =>
|
|
//{
|
|
// x.DifficultyLevelLabel = await GetParaLabel("DifficultyLevel", x.DifficultyLevel);
|
|
// x.QuestionTypeLabel = await GetParaLabel("QuestionType", x.QuestionType);
|
|
//});
|
|
|
|
return new ServicePageResult<Ghre_ExamDto>(filter.pageNum, totalCount, filter.pageSize, data);
|
|
}
|
|
|
|
|
|
public async Task<ServiceResult<DefaultGhre_ExamInput>> QueryDefault(long Id)
|
|
{
|
|
var input = new DefaultGhre_ExamInput();
|
|
|
|
#region baseColumns
|
|
var baseColumns = new List<DefaultGhre_ExamColumn>
|
|
{
|
|
new DefaultGhre_ExamColumn()
|
|
{
|
|
label = "关联课程",
|
|
field = "LinkType",
|
|
elementType = "RadioBox",
|
|
required = true,
|
|
multipleSelect = false,
|
|
editable = false,
|
|
},
|
|
new DefaultGhre_ExamColumn()
|
|
{
|
|
label = "课程名称",
|
|
field = "CourseId",
|
|
elementType = "ApiSelect",
|
|
required = true,
|
|
multipleSelect = false,
|
|
editable = true,
|
|
dataSource = "api/Common/GetSelect/Ghre_Course?FW=DOTNETCORE"
|
|
},
|
|
new DefaultGhre_ExamColumn()
|
|
{
|
|
label = "课程场景",
|
|
field = "CourseSceneId",
|
|
elementType = "ApiSelect",
|
|
required = true,
|
|
multipleSelect = false,
|
|
editable = true,
|
|
dataSource = "api/Common/GetSelect/Ghre_CourseScene?FW=DOTNETCORE"
|
|
},
|
|
new DefaultGhre_ExamColumn()
|
|
{
|
|
label = "选择试卷",
|
|
field = "ExamPaperId",
|
|
elementType = "ApiSelect",
|
|
required = true,
|
|
multipleSelect = false,
|
|
editable = true,
|
|
dataSource = "api/Ghre_ExamPaper/GetSelect?FW=DOTNETCORE&linkId="
|
|
},
|
|
new DefaultGhre_ExamColumn()
|
|
{
|
|
label = "考试编号",
|
|
field = "ExamNo",
|
|
elementType = "Input",
|
|
required =false ,
|
|
multipleSelect = false,
|
|
editable = false
|
|
},
|
|
new DefaultGhre_ExamColumn()
|
|
{
|
|
label = "考试名称",
|
|
field = "ExamName",
|
|
elementType = "Input",
|
|
required = true,
|
|
multipleSelect = false,
|
|
editable = true,
|
|
},
|
|
new DefaultGhre_ExamColumn()
|
|
{
|
|
label = "考试日期",
|
|
field = "DateType",
|
|
elementType = "RadioBox",
|
|
required = true,
|
|
multipleSelect = false,
|
|
editable = true,
|
|
},
|
|
new DefaultGhre_ExamColumn()
|
|
{
|
|
label = "考试区间",
|
|
field = "ExamDate",
|
|
elementType = "GRangePicker",
|
|
required = true,
|
|
multipleSelect = false,
|
|
editable = true,
|
|
},
|
|
new DefaultGhre_ExamColumn()
|
|
{
|
|
label = "学完多久",
|
|
field = "AfterHowLong",
|
|
elementType = "RadioBox",
|
|
required = false,
|
|
multipleSelect = false,
|
|
editable = true,
|
|
},
|
|
new DefaultGhre_ExamColumn()
|
|
{
|
|
label = "考试形式",
|
|
field = "ExamMode",
|
|
elementType = "RadioBox",
|
|
required = false,
|
|
multipleSelect = false,
|
|
editable = true,
|
|
},
|
|
new DefaultGhre_ExamColumn()
|
|
{
|
|
label = "线下考试地点",
|
|
field = "ExamPlace",
|
|
elementType = "Input",
|
|
required = true,
|
|
multipleSelect = false,
|
|
editable = true,
|
|
},
|
|
new DefaultGhre_ExamColumn()
|
|
{
|
|
label = "关联开班",
|
|
field = "IsLinkOpenClass",
|
|
elementType = "RadioBox",
|
|
required = true,
|
|
multipleSelect = false,
|
|
editable = true
|
|
},
|
|
new DefaultGhre_ExamColumn()
|
|
{
|
|
label = "考试说明",
|
|
field = "RemarkSz",
|
|
elementType = "InputTextArea",
|
|
required = true,
|
|
multipleSelect = false,
|
|
editable = true
|
|
}
|
|
};
|
|
#endregion
|
|
|
|
#region staffTableColumns
|
|
|
|
var staffTableColumns = new List<DefaultGhre_ExamColumn>
|
|
{
|
|
new DefaultGhre_ExamColumn()
|
|
{
|
|
label = "工号",
|
|
field = "StaffNo",
|
|
align = "center",
|
|
width=100
|
|
},
|
|
new DefaultGhre_ExamColumn()
|
|
{
|
|
label = "姓名",
|
|
field = "StaffName",
|
|
align = "center",
|
|
width=100
|
|
}, new DefaultGhre_ExamColumn()
|
|
{
|
|
label = "部门",
|
|
field = "DeptName",
|
|
align = "center",
|
|
width=100
|
|
}, new DefaultGhre_ExamColumn()
|
|
{
|
|
label = "岗位",
|
|
field = "TitleName",
|
|
align = "center",
|
|
width=100
|
|
}, new DefaultGhre_ExamColumn()
|
|
{
|
|
label = "入职日期",
|
|
field = "InDate",
|
|
align = "center",
|
|
width=100
|
|
}, new DefaultGhre_ExamColumn()
|
|
{
|
|
label = "邮箱",
|
|
field = "Mail",
|
|
align = "center",
|
|
width=100
|
|
}, new DefaultGhre_ExamColumn()
|
|
{
|
|
label = "数据来源",
|
|
field = "DataSource",
|
|
align = "center",
|
|
width=100
|
|
}
|
|
};
|
|
#endregion
|
|
|
|
|
|
#region pageData
|
|
if (Id != 0)
|
|
{
|
|
var exam = await base.QueryById(Id);
|
|
var pageData = Mapper.Map(exam).ToANew<DefaultGhre_ExamPageData>();
|
|
|
|
if (pageData.AfterHowLong != 7 && pageData.AfterHowLong != 15 && pageData.AfterHowLong != 30)
|
|
{
|
|
pageData.AfterHowLong1 = pageData.AfterHowLong;
|
|
pageData.AfterHowLong = 0;
|
|
}
|
|
if (pageData.DateType == "ExamDate") pageData.ExamDate.Add(pageData.BeginTime.Value.ToString("yyyy/MM/dd"));
|
|
if (pageData.DateType == "ExamDate") pageData.ExamDate.Add(pageData.EndTime.Value.ToString("yyyy/MM/dd"));
|
|
input.pageData = pageData;
|
|
|
|
var staffs = await _ghre_ExamStaffServices.Query(x => x.ExamId == Id);
|
|
|
|
var ids = staffs.Select(x => Convert.ToInt32(x.StaffId)).ToList();
|
|
var staffTableData = await QueryStaff(ids, null);
|
|
pageData.staffTableData = staffTableData.Data;
|
|
}
|
|
#endregion
|
|
|
|
input.baseColumns = baseColumns;
|
|
input.staffTableColumns = staffTableColumns;
|
|
return ServiceResult<DefaultGhre_ExamInput>.OprateSuccess("查询成功!", input);
|
|
}
|
|
|
|
|
|
public async Task<ServiceResult<List<StaffTableData>>> QueryStaff(List<int> Ids, string type)
|
|
{
|
|
string sql = @"SELECT A.StaffID,
|
|
A.StaffName,
|
|
A.StaffNo,
|
|
A.Email Mail,
|
|
B.DeptName,
|
|
C.TitleName,
|
|
FORMAT(A.Indate, 'yyyy/MM/dd') Indate
|
|
FROM Ghra_Staff A
|
|
LEFT JOIN Ghro_Dept B ON A.DeptID = B.DeptID
|
|
LEFT JOIN Ghra_Title C ON A.TitleID = C.TitleID
|
|
WHERE 1=1 AND A.IsEnable=1 ";
|
|
|
|
if (Ids.Any())
|
|
sql += $"AND StaffID IN({string.Join(",", Ids)}) ";
|
|
else sql += "AND 1!=1 ";
|
|
//var list = await _ghra_StaffSceneServices.Query(x => Ids.Contains(x.StaffID));
|
|
|
|
var data = Db.Ado.SqlQuery<StaffTableData>(sql);
|
|
//var data = list.Select(x => new StaffTableData()
|
|
//{
|
|
// StaffID = x.StaffID,
|
|
// StaffNo = x.StaffNo,
|
|
// StaffName = x.StaffName,
|
|
// Mail = x.Email
|
|
//}).ToList();
|
|
return ServiceResult<List<StaffTableData>>.OprateSuccess("查询成功!", data);
|
|
}
|
|
|
|
public async Task<ServiceResult<long>> Insert1(long id, DefaultGhre_ExamPageData pageData)
|
|
{
|
|
if (pageData.DateType == "ExamDate")
|
|
{
|
|
pageData.BeginTime = Convert.ToDateTime(pageData.ExamDate[0]);
|
|
pageData.EndTime = Convert.ToDateTime(pageData.ExamDate[1]);
|
|
}
|
|
if (pageData.AfterHowLong == 0)
|
|
pageData.AfterHowLong = pageData.AfterHowLong1;
|
|
|
|
if (id == 0)
|
|
{
|
|
|
|
pageData.Status = "Draft";
|
|
var insert = Mapper.Map(pageData).ToANew<InsertGhre_ExamInput>();
|
|
id = await base.Add(insert);
|
|
|
|
var insertStaffs = pageData.staffTableData.Select(x => new InsertGhre_ExamStaffInput()
|
|
{
|
|
ExamId = id,
|
|
StaffId = x.StaffID,
|
|
Source = x.DataSource
|
|
}).ToList();
|
|
|
|
await _ghre_ExamStaffServices.Add(insertStaffs);
|
|
|
|
return ServiceResult<long>.OprateSuccess("添加成功!", id);
|
|
}
|
|
else
|
|
{
|
|
var insert = Mapper.Map(pageData).ToANew<EditGhre_ExamInput>();
|
|
await base.Update(id, insert);
|
|
await _ghre_ExamStaffServices.Delete(x => x.ExamId == id);
|
|
var insertStaffs = pageData.staffTableData.Select(x => new InsertGhre_ExamStaffInput()
|
|
{
|
|
ExamId = id,
|
|
StaffId = x.StaffID,
|
|
Source = x.DataSource
|
|
}).ToList();
|
|
|
|
await _ghre_ExamStaffServices.Add(insertStaffs);
|
|
|
|
return ServiceResult<long>.OprateSuccess("修改成功!", id);
|
|
}
|
|
}
|
|
|
|
} |