|
|
@ -1,4 +1,7 @@ |
|
|
|
namespace Tiobon.Core.Services; |
|
|
|
using AgileObjects.AgileMapper.Extensions; |
|
|
|
|
|
|
|
using Microsoft.IdentityModel.Tokens; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
namespace Tiobon.Core.Services; |
|
|
|
|
|
|
|
|
|
|
|
/// <summary> |
|
|
|
/// <summary> |
|
|
|
/// 问卷调查 (服务) |
|
|
|
/// 问卷调查 (服务) |
|
|
@ -398,8 +401,6 @@ public class Ghre_SurveyServices : BaseServices<Ghre_Survey, Ghre_SurveyDto, Ins |
|
|
|
return ServiceResult.OprateSuccess("提交成功!"); |
|
|
|
return ServiceResult.OprateSuccess("提交成功!"); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public async Task<ServiceResult> Publish(long id) |
|
|
|
public async Task<ServiceResult> Publish(long id) |
|
|
|
{ |
|
|
|
{ |
|
|
|
var entity = await base.QueryById(id); |
|
|
|
var entity = await base.QueryById(id); |
|
|
@ -457,4 +458,55 @@ public class Ghre_SurveyServices : BaseServices<Ghre_Survey, Ghre_SurveyDto, Ins |
|
|
|
|
|
|
|
|
|
|
|
return ServiceResult.OprateSuccess("发布成功!"); |
|
|
|
return ServiceResult.OprateSuccess("发布成功!"); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
public async Task<ServiceResult<Ghre_SurveyStatistic>> QueryStatistic(long id) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
var data = new Ghre_SurveyStatistic(); |
|
|
|
|
|
|
|
var entity = await base.QueryById(id); |
|
|
|
|
|
|
|
var deptIds = new List<int>(); |
|
|
|
|
|
|
|
var staffIds = new List<int>(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (entity.DeptId.IsNotEmptyOrNull()) |
|
|
|
|
|
|
|
deptIds = JsonHelper.JsonToObj<List<int>>(entity.DeptId); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (entity.StaffId.IsNotEmptyOrNull()) |
|
|
|
|
|
|
|
staffIds = JsonHelper.JsonToObj<List<int>>(entity.StaffId); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var staffIds1 = await Db.Queryable<Ghra_Staff>().Where(x => x.DeptID != null && deptIds.Contains(x.DeptID.Value)).Select(x => x.StaffID).ToListAsync(); |
|
|
|
|
|
|
|
staffIds.AddRange(staffIds1); |
|
|
|
|
|
|
|
staffIds = staffIds.Distinct().ToList(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
data.All = staffIds.Count; |
|
|
|
|
|
|
|
data.Has = await Db.Queryable<Ghre_SurveyRecord>().Where(x => x.SurveyId == id).CountAsync(); |
|
|
|
|
|
|
|
data.New = await Db.Queryable<Ghre_SurveyRecord>().Where(x => x.SurveyId == id && x.SubmitDate.Value.Date == DateTime.Now.Date).CountAsync(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var recordOptions = await Db.Queryable<Ghre_SurveyRecordOption>().Where(x => x.SurveyId == id).ToListAsync(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var questions = await Db.Queryable<Ghre_SurveyQuestion>().OrderBy(x => x.SortNo).Where(x => x.SurveyId == id).ToListAsync(); |
|
|
|
|
|
|
|
var options = await Db.Queryable<Ghre_SurveyOption>().OrderBy(x => x.SortNo).Where(x => x.SurveyId == id).ToListAsync(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
data.Questions = Mapper.Map(questions).ToANew<List<Ghre_SurveyStatisticQuestion>>(); |
|
|
|
|
|
|
|
data.Questions.ForEach(x => |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
x.Table = Mapper.Map(options.Where(o => o.SurveyQuestionId == x.Id)).ToANew<List<Ghre_SurveyStatisticQuestionTable>>(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
decimal total = recordOptions.Where(a => a.SurveyQuestionId == x.Id).Count(); |
|
|
|
|
|
|
|
x.Table.ForEach(o => |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
o.Count = recordOptions.Where(a => a.SurveyQuestionOptionId == o.Id).Count(); |
|
|
|
|
|
|
|
if (o.Count > 0 && total > 0) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
o.Percent1 = o.Count / total; |
|
|
|
|
|
|
|
o.Percent1 = o.Percent1 * 100; |
|
|
|
|
|
|
|
o.Percent = $"{o.Percent1.RemoveZero()}%"; |
|
|
|
|
|
|
|
}else |
|
|
|
|
|
|
|
o.Percent = $"0%"; |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return ServiceResult<Ghre_SurveyStatistic>.OprateSuccess("查询成功!", data); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|