|
|
|
@ -14,6 +14,8 @@ using SqlSugar; |
|
|
|
|
using MathNet.Numerics.Distributions; |
|
|
|
|
using MongoDB.Driver.Linq; |
|
|
|
|
using OfficeOpenXml.FormulaParsing.Excel.Functions.DateTime; |
|
|
|
|
using System.Data; |
|
|
|
|
using System.Collections.Generic; |
|
|
|
|
|
|
|
|
|
namespace Tiobon.Core.Services; |
|
|
|
|
|
|
|
|
@ -49,9 +51,9 @@ public class Ghre_StudyRuleServices : BaseServices<Ghre_StudyRule, Ghre_StudyRul |
|
|
|
|
if (filter.pageSize == 0) |
|
|
|
|
filter.pageSize = 10000; |
|
|
|
|
|
|
|
|
|
var countSql = @$" SELECT COUNT(1) FROM Ghre_StudyRule"; |
|
|
|
|
var countSql = @$" SELECT COUNT(1) FROM Ghre_StudyRule_v"; |
|
|
|
|
var sql = @$" SELECT *
|
|
|
|
|
FROM Ghre_StudyRule A";
|
|
|
|
|
FROM Ghre_StudyRule_v A";
|
|
|
|
|
|
|
|
|
|
string conditions = " WHERE 1=1 "; |
|
|
|
|
|
|
|
|
@ -113,11 +115,43 @@ public class Ghre_StudyRuleServices : BaseServices<Ghre_StudyRule, Ghre_StudyRul |
|
|
|
|
var ids = entitys.Select(x => x.Id).ToList(); |
|
|
|
|
var staffs = await _ghre_StudyRuleStaffServices.Query(x => x.StudyRuleId != null && ids.Contains(x.StudyRuleId.Value)); |
|
|
|
|
|
|
|
|
|
entitys.ForEach(x => |
|
|
|
|
var zoneIds = new List<int>(); |
|
|
|
|
var deptIds = new List<int>(); |
|
|
|
|
var titleIds = new List<int>(); |
|
|
|
|
var gradeIds = new List<int>(); |
|
|
|
|
var jobIds = new List<int>(); |
|
|
|
|
entitys.ForEach(rule => |
|
|
|
|
{ |
|
|
|
|
x.StaffNames = string.Join(",", staffs.Where(o => o.StudyRuleId == x.Id).Select(o => o.StaffName)); |
|
|
|
|
rule.StaffNames = string.Join(",", staffs.Where(o => o.StudyRuleId == rule.Id).Select(o => o.StaffName)); |
|
|
|
|
|
|
|
|
|
if (!rule.ZoneId.IsNull()) |
|
|
|
|
rule.ZoneIds = JsonHelper.JsonToObj<List<int>>(rule.ZoneId); |
|
|
|
|
if (!rule.DeptId.IsNull()) |
|
|
|
|
rule.DeptIds = JsonHelper.JsonToObj<List<int>>(rule.DeptId); |
|
|
|
|
if (!rule.TitleId.IsNull()) |
|
|
|
|
rule.TitleIds = JsonHelper.JsonToObj<List<int>>(rule.TitleId); |
|
|
|
|
if (!rule.GradeId.IsNull()) |
|
|
|
|
rule.GradeIds = JsonHelper.JsonToObj<List<int>>(rule.GradeId); |
|
|
|
|
if (!rule.JobId.IsNull()) |
|
|
|
|
rule.JobIds = JsonHelper.JsonToObj<List<int>>(rule.JobId); |
|
|
|
|
|
|
|
|
|
if (rule.ZoneIds.Any()) |
|
|
|
|
zoneIds.AddRange(rule.ZoneIds); |
|
|
|
|
|
|
|
|
|
if (rule.DeptIds.Any()) |
|
|
|
|
deptIds.AddRange(rule.DeptIds); |
|
|
|
|
|
|
|
|
|
if (rule.TitleIds.Any()) |
|
|
|
|
titleIds.AddRange(rule.TitleIds); |
|
|
|
|
|
|
|
|
|
if (rule.GradeIds.Any()) |
|
|
|
|
gradeIds.AddRange(rule.GradeIds); |
|
|
|
|
|
|
|
|
|
if (rule.JobIds.Any()) |
|
|
|
|
jobIds.AddRange(rule.JobIds); |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return new ServicePageResult<Ghre_StudyRuleDto>(filter.pageNum, total, filter.pageSize, entitys); |
|
|
|
|
|
|
|
|
|
} |
|
|
|
@ -125,6 +159,18 @@ public class Ghre_StudyRuleServices : BaseServices<Ghre_StudyRule, Ghre_StudyRul |
|
|
|
|
|
|
|
|
|
public override async Task<long> Add(InsertGhre_StudyRuleInput entity) |
|
|
|
|
{ |
|
|
|
|
|
|
|
|
|
if (!entity.ZoneIds.IsNull() && entity.ZoneIds.Any()) |
|
|
|
|
entity.ZoneId = JsonHelper.ObjToJson(entity.ZoneIds); |
|
|
|
|
if (!entity.DeptIds.IsNull() && entity.DeptIds.Any()) |
|
|
|
|
entity.DeptId = JsonHelper.ObjToJson(entity.DeptIds); |
|
|
|
|
if (!entity.TitleIds.IsNull() && entity.TitleIds.Any()) |
|
|
|
|
entity.TitleId = JsonHelper.ObjToJson(entity.TitleIds); |
|
|
|
|
if (!entity.GradeIds.IsNull() && entity.GradeIds.Any()) |
|
|
|
|
entity.GradeId = JsonHelper.ObjToJson(entity.GradeIds); |
|
|
|
|
if (!entity.JobIds.IsNull() && entity.JobIds.Any()) |
|
|
|
|
entity.JobId = JsonHelper.ObjToJson(entity.JobIds); |
|
|
|
|
|
|
|
|
|
var result = await base.Add(entity); |
|
|
|
|
|
|
|
|
|
if (entity.Staffs != null && entity.Staffs.Any()) |
|
|
|
@ -147,15 +193,27 @@ public class Ghre_StudyRuleServices : BaseServices<Ghre_StudyRule, Ghre_StudyRul |
|
|
|
|
return result; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public override async Task<bool> Update(long Id, EditGhre_StudyRuleInput editModel) |
|
|
|
|
public override async Task<bool> Update(long Id, EditGhre_StudyRuleInput entity) |
|
|
|
|
{ |
|
|
|
|
var result = await base.Update(Id, editModel); |
|
|
|
|
|
|
|
|
|
if (!entity.ZoneIds.IsNull() && entity.ZoneIds.Any()) |
|
|
|
|
entity.ZoneId = JsonHelper.ObjToJson(entity.ZoneIds); |
|
|
|
|
if (!entity.DeptIds.IsNull() && entity.DeptIds.Any()) |
|
|
|
|
entity.DeptId = JsonHelper.ObjToJson(entity.DeptIds); |
|
|
|
|
if (!entity.TitleIds.IsNull() && entity.TitleIds.Any()) |
|
|
|
|
entity.TitleId = JsonHelper.ObjToJson(entity.TitleIds); |
|
|
|
|
if (!entity.GradeIds.IsNull() && entity.GradeIds.Any()) |
|
|
|
|
entity.GradeId = JsonHelper.ObjToJson(entity.GradeIds); |
|
|
|
|
if (!entity.JobIds.IsNull() && entity.JobIds.Any()) |
|
|
|
|
entity.JobId = JsonHelper.ObjToJson(entity.JobIds); |
|
|
|
|
|
|
|
|
|
var result = await base.Update(Id, entity); |
|
|
|
|
await _ghre_StudyRuleStaffServices.Delete(x => x.StudyRuleId == Id); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (editModel.Staffs != null && editModel.Staffs.Any()) |
|
|
|
|
if (!entity.IsNull() && entity.Staffs.Any()) |
|
|
|
|
{ |
|
|
|
|
var insertStaffs = editModel.Staffs.Select(x => new InsertGhre_StudyRuleStaffInput |
|
|
|
|
var insertStaffs = entity.Staffs.Select(x => new InsertGhre_StudyRuleStaffInput |
|
|
|
|
{ |
|
|
|
|
StaffId = x, |
|
|
|
|
StudyRuleId = Id |
|
|
|
@ -183,9 +241,19 @@ public class Ghre_StudyRuleServices : BaseServices<Ghre_StudyRule, Ghre_StudyRul |
|
|
|
|
var staffs = await _ghre_StudyRuleStaffServices.Query(x => x.StudyRuleId != null && x.StudyRuleId == result.result.DT_TableDataT1[0].Id); |
|
|
|
|
|
|
|
|
|
var DT_TableDataT1 = result.result.DT_TableDataT1; |
|
|
|
|
DT_TableDataT1.ForEach(t => |
|
|
|
|
DT_TableDataT1.ForEach(rule => |
|
|
|
|
{ |
|
|
|
|
t.Staffs = staffs.Where(x => x.StaffId != null).Select(x => x.StaffId.Value).ToList(); |
|
|
|
|
rule.Staffs = staffs.Where(x => x.StaffId != null).Select(x => x.StaffId.Value).ToList(); |
|
|
|
|
if (!rule.ZoneId.IsNull()) |
|
|
|
|
rule.ZoneIds = JsonHelper.JsonToObj<List<int>>(rule.ZoneId); |
|
|
|
|
if (!rule.DeptId.IsNull()) |
|
|
|
|
rule.DeptIds = JsonHelper.JsonToObj<List<int>>(rule.DeptId); |
|
|
|
|
if (!rule.TitleId.IsNull()) |
|
|
|
|
rule.TitleIds = JsonHelper.JsonToObj<List<int>>(rule.TitleId); |
|
|
|
|
if (!rule.GradeId.IsNull()) |
|
|
|
|
rule.GradeIds = JsonHelper.JsonToObj<List<int>>(rule.GradeId); |
|
|
|
|
if (!rule.JobId.IsNull()) |
|
|
|
|
rule.JobIds = JsonHelper.JsonToObj<List<int>>(rule.JobId); |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
result.result.DT_TableDataT1 = DT_TableDataT1; |
|
|
|
@ -201,6 +269,22 @@ public class Ghre_StudyRuleServices : BaseServices<Ghre_StudyRule, Ghre_StudyRul |
|
|
|
|
|
|
|
|
|
var rule = await Db.Queryable<Ghre_StudyRule>().FirstAsync(x => x.Id == ruleId); |
|
|
|
|
|
|
|
|
|
var ZoneIds = new List<int?>(); |
|
|
|
|
var DeptIds = new List<int?>(); |
|
|
|
|
var TitleIds = new List<int?>(); |
|
|
|
|
var GradeIds = new List<int?>(); |
|
|
|
|
var JobIds = new List<int?>(); |
|
|
|
|
if (!rule.ZoneId.IsNull()) |
|
|
|
|
ZoneIds = JsonHelper.JsonToObj<List<int?>>(rule.ZoneId); |
|
|
|
|
if (!rule.DeptId.IsNull()) |
|
|
|
|
DeptIds = JsonHelper.JsonToObj<List<int?>>(rule.DeptId); |
|
|
|
|
if (!rule.TitleId.IsNull()) |
|
|
|
|
TitleIds = JsonHelper.JsonToObj<List<int?>>(rule.TitleId); |
|
|
|
|
if (!rule.GradeId.IsNull()) |
|
|
|
|
GradeIds = JsonHelper.JsonToObj<List<int?>>(rule.GradeId); |
|
|
|
|
if (!rule.JobId.IsNull()) |
|
|
|
|
JobIds = JsonHelper.JsonToObj<List<int?>>(rule.JobId); |
|
|
|
|
|
|
|
|
|
var ruleStaffs = await Db.Queryable<Ghre_StudyRuleStaff>().Where(x => x.StudyRuleId == ruleId).ToListAsync(); |
|
|
|
|
|
|
|
|
|
await Db.Updateable<Ghre_StudyRuleResult>().Where(x => x.StudyRuleId == ruleId && x.IsEnable == 1) |
|
|
|
@ -211,13 +295,12 @@ public class Ghre_StudyRuleServices : BaseServices<Ghre_StudyRule, Ghre_StudyRul |
|
|
|
|
|
|
|
|
|
var staffs = await Db.Queryable<Ghra_Staff>() |
|
|
|
|
.Where(x => x.OutDate == null || (x.OutDate != null && x.Indate != null && x.Indate.Value.Date <= DateTime.Now.Date && x.Indate.Value.Date >= DateTime.Now.Date)) |
|
|
|
|
.WhereIF(!rule.ZoneId.IsNull(), x => x.ZoneID == rule.ZoneId) |
|
|
|
|
.WhereIF(!rule.DeptId.IsNull(), x => x.DeptID == rule.DeptId) |
|
|
|
|
.WhereIF(!rule.TitleId.IsNull(), x => x.TitleID == rule.TitleId) |
|
|
|
|
.WhereIF(!rule.GradeId.IsNull(), x => x.GradeID == rule.GradeId) |
|
|
|
|
.WhereIF(!rule.JobId.IsNull(), x => x.JobID == rule.JobId) |
|
|
|
|
.WhereIF(ZoneIds.Any(), x => ZoneIds.Contains(x.ZoneID)) |
|
|
|
|
.WhereIF(DeptIds.Any(), x => DeptIds.Contains(x.DeptID)) |
|
|
|
|
.WhereIF(TitleIds.Any(), x => TitleIds.Contains(x.TitleID)) |
|
|
|
|
.WhereIF(GradeIds.Any(), x => GradeIds.Contains(x.GradeID)) |
|
|
|
|
.WhereIF(JobIds.Any(), x => JobIds.Contains(x.JobID)) |
|
|
|
|
.WhereIF(!ruleStaffIds.IsNull() && ruleStaffIds.Any(), x => ruleStaffIds.Contains(x.StaffID)) |
|
|
|
|
.WhereIF(!rule.GradeId.IsNull(), x => x.GradeID == rule.GradeId) |
|
|
|
|
.ToListAsync(); |
|
|
|
|
|
|
|
|
|
if (!staffs.IsNull()) |
|
|
|
|