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.
450 lines
16 KiB
450 lines
16 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;
|
|
|
|
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;
|
|
public Ghre_ExamServices(ICaching caching,
|
|
IGhre_CourseServices ghre_CourseServices,
|
|
IGhre_CourseSceneServices ghre_CourseSceneServices, IBaseRepository<Ghre_Exam> dal)
|
|
{
|
|
this._dal = dal;
|
|
base.BaseDal = dal;
|
|
base._caching = caching;
|
|
_ghre_CourseServices = ghre_CourseServices;
|
|
_ghre_CourseSceneServices = ghre_CourseSceneServices;
|
|
}
|
|
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<ServicePageResult<Ghre_ExamDto>> QueryList(QueryBody body, string status)
|
|
{
|
|
var data = await QueryFilterPage1(body, status);
|
|
var data1 = Mapper.Map(data.result.DT_TableDataT1).ToANew<List<Ghre_ExamDto>>();
|
|
|
|
//var linkIds = data1.Where(x => x.LinkId != null).Select(x => x.LinkId.Value).Distinct().ToList();
|
|
//var courses = await _ghre_CourseServices.Query(x => linkIds.Contains(x.Id));
|
|
//var courseScenes = await _ghre_CourseSceneServices.Query(x => linkIds.Contains(x.Id));
|
|
|
|
//data1.ForEach(async x =>
|
|
//{
|
|
// try
|
|
// {
|
|
// x.ScoreMethodLabel = await GetParaLabel("ScoreMethod", x.ScoreMethod);
|
|
// x.TotalScore1 = Regex.Replace(x.PassScore.ToString(), @"\.(0+)$", "") + "/" + Regex.Replace(x.TotalScore.ToString(), @"\.(0+)$", "");
|
|
// x.SetMethodLabel = await GetParaLabel("SetMethod", x.SetMethod);
|
|
|
|
// if (x.LinkType == "CourseId")
|
|
// x.CourseName = courses.FirstOrDefault(o => o.Id == x.LinkId)?.CourseName;
|
|
// else if (x.LinkType == "CourseSceneId")
|
|
// x.CourseName = courseScenes.FirstOrDefault(o => o.Id == x.LinkId)?.SceneName;
|
|
// }
|
|
// catch (Exception)
|
|
// {
|
|
|
|
// }
|
|
|
|
//});
|
|
|
|
return new ServicePageResult<Ghre_ExamDto>(body.pageNum, data.result.DT_TablePageInfoT1.TotalCount, body.pageSize, data1);
|
|
}
|
|
|
|
public async Task<ServicePageResult<Ghre_Exam>> QueryFilterPage1(QueryBody filter, string status = null)
|
|
{
|
|
if (string.IsNullOrWhiteSpace(filter.orderBy))
|
|
filter.orderBy = "CreateTime DESC";
|
|
RefAsync<int> totalCount = 0;
|
|
var query = Db.Queryable<Ghre_Exam>();
|
|
if (!string.IsNullOrWhiteSpace(status))
|
|
query = query.Where(x => x.Status == status);
|
|
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;
|
|
query = query.Where(conditions);
|
|
var list = await query
|
|
.OrderByIF(!string.IsNullOrEmpty(filter.orderBy), filter.orderBy)
|
|
.ToPageListAsync(filter.pageNum, filter.pageSize, totalCount);
|
|
|
|
return new ServicePageResult<Ghre_Exam>(filter.pageNum, totalCount, filter.pageSize, list);
|
|
}
|
|
|
|
|
|
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,
|
|
},
|
|
new DefaultGhre_ExamColumn()
|
|
{
|
|
label = "选择试卷",
|
|
field = "ExamPaperId",
|
|
elementType = "ApiSelect",
|
|
required = true,
|
|
multipleSelect = false,
|
|
editable = true,
|
|
},
|
|
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",
|
|
},
|
|
new DefaultGhre_ExamColumn()
|
|
{
|
|
label = "姓名",
|
|
field = "StaffName",
|
|
align = "center",
|
|
}, new DefaultGhre_ExamColumn()
|
|
{
|
|
label = "部门",
|
|
field = "DeptName",
|
|
align = "center",
|
|
}, new DefaultGhre_ExamColumn()
|
|
{
|
|
label = "岗位",
|
|
field = "TitleName",
|
|
align = "center",
|
|
}, new DefaultGhre_ExamColumn()
|
|
{
|
|
label = "入职日期",
|
|
field = "InDate",
|
|
align = "center",
|
|
}, new DefaultGhre_ExamColumn()
|
|
{
|
|
label = "邮箱",
|
|
field = "Mail",
|
|
align = "center",
|
|
width=200
|
|
}, new DefaultGhre_ExamColumn()
|
|
{
|
|
label = "数据来源",
|
|
field = "DataSource",
|
|
align = "center",
|
|
width=200
|
|
}
|
|
};
|
|
#endregion
|
|
|
|
|
|
#region pageData
|
|
if (Id != 0)
|
|
{
|
|
var exam = await base.QueryById(Id);
|
|
input.pageData = Mapper.Map(exam).ToANew<DefaultGhre_ExamPageData>();
|
|
}
|
|
#endregion
|
|
|
|
input.baseColumns = baseColumns;
|
|
input.staffTableColumns = staffTableColumns;
|
|
return ServiceResult<DefaultGhre_ExamInput>.OprateSuccess("查询成功!", input);
|
|
}
|
|
|
|
} |