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.
119 lines
4.7 KiB
119 lines
4.7 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 Newtonsoft.Json.Linq;
|
|
using Tiobon.Core.Common.DB.Dapper.Extensions;
|
|
using Tiobon.Core.Common;
|
|
using Tiobon.Core.Model;
|
|
using Newtonsoft.Json;
|
|
|
|
namespace Tiobon.Core.Services;
|
|
|
|
/// <summary>
|
|
/// 必选修查询 (服务)
|
|
/// </summary>
|
|
public class Ghre_RequiredCourseServices : BaseServices<Ghre_RequiredCourse, Ghre_RequiredCourseDto, InsertGhre_RequiredCourseInput, EditGhre_RequiredCourseInput>, IGhre_RequiredCourseServices
|
|
{
|
|
private readonly IBaseRepository<Ghre_RequiredCourse> _dal;
|
|
public Ghre_RequiredCourseServices(ICaching caching, IBaseRepository<Ghre_RequiredCourse> dal)
|
|
{
|
|
this._dal = dal;
|
|
base.BaseDal = dal;
|
|
base._caching = caching;
|
|
}
|
|
|
|
public override async Task<ServicePageResult<Ghre_RequiredCourseDto>> QueryFilterPage(QueryBody filter)
|
|
{
|
|
if (string.IsNullOrWhiteSpace(filter.orderBy))
|
|
filter.orderBy = "UpdateTime DESC,CreateTime DESC";
|
|
|
|
if (filter.pageSize == 0)
|
|
filter.pageSize = 10000;
|
|
|
|
var countSql = @$" SELECT COUNT(1) FROM Ghre_RequiredCourse_V";
|
|
var sql = @$" SELECT *
|
|
FROM Ghre_RequiredCourse_V";
|
|
|
|
string conditions = " WHERE IsEnable = 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 (name == "DueDate")
|
|
{
|
|
var jsonParam = JsonConvert.DeserializeObject<JsonParam>(value);
|
|
conditions += $" AND FORMAT(DueDate, 'yyyy-MM-dd') = '{jsonParam.columnValue}'";
|
|
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;
|
|
}
|
|
}
|
|
}
|
|
|
|
sql += conditions;
|
|
countSql += conditions;
|
|
int total = await Db.Ado.GetIntAsync(countSql);
|
|
|
|
sql = "SELECT * FROM (SELECT *, ROW_NUMBER() OVER (ORDER BY " + filter.orderBy + ") NUM FROM (SELECT * FROM (" + sql + " ";
|
|
sql += ") A ) B ) C";
|
|
|
|
sql += " WHERE NUM <= " + filter.pageNum * filter.pageSize + " AND NUM >" + (filter.pageNum - 1) * filter.pageSize;
|
|
|
|
var entitys = await Db.Ado.SqlQueryAsync<Ghre_RequiredCourseDto>(sql);
|
|
|
|
entitys.ForEach(async x =>
|
|
{
|
|
x.RequiredClassLabel = await GetParaLabel("TrainingRequiredClass", x.RequiredClass);
|
|
x.CourseStatusLabel = await GetParaLabel("TrainingCourseStatus", x.CourseStatus);
|
|
x.StudyStatusLabel = await GetParaLabel("TrainingStudyStatus", x.StudyStatus);
|
|
x.IsPassLabel = x.IsPass == true ? "是" : "否";
|
|
|
|
x.InStatusLabel = x.InStatus == "1" ? "在职" : null;
|
|
x.InStatusLabel = x.InStatus == "2" ? "离职" : null;
|
|
x.InStatusLabel = x.InStatus == "0" ? "未入职" : null;
|
|
if (x.Indate != null)
|
|
x.Indate1 = x.Indate.Value.ToString("yyyy-MM-dd");
|
|
if (x.DueDate != null)
|
|
x.DueDate1 = x.DueDate.Value.ToString("yyyy-MM-dd");
|
|
if (x.ExamDate != null)
|
|
x.ExamDate1 = x.ExamDate.Value.ToString("yyyy-MM-dd");
|
|
|
|
});
|
|
|
|
return new ServicePageResult<Ghre_RequiredCourseDto>(filter.pageNum, total, filter.pageSize, entitys);
|
|
|
|
}
|
|
} |