zhuangpei-mesbackend/DOAN.Service/MES/group/GroupPersonSkillMatrixService.cs
2024-08-12 16:13:24 +08:00

130 lines
4.2 KiB
C#

using System;
using SqlSugar;
using Infrastructure.Attribute;
using Infrastructure.Extensions;
using DOAN.Model;
using DOAN.Model.Dto;
using DOAN.Model.MES.group;
using DOAN.Model.MES.group.Dto;
using DOAN.Repository;
using DOAN.Service.group.IService;
using System.Linq;
using NPOI.SS.Formula.Functions;
using NPOI.XSSF.UserModel;
namespace DOAN.Service.group
{
/// <summary>
/// 人员技能矩阵图Service业务层处理
/// </summary>
[AppService(ServiceType = typeof(IGroupPersonSkillService), ServiceLifetime = LifeTime.Transient)]
public class GroupPersonSkillService : BaseService<GroupPersonSkill>, IGroupPersonSkillService
{
/// <summary>
/// 查询人员技能矩阵图列表
/// </summary>
/// <param name="parm"></param>
/// <returns></returns>
public PagedInfo<GroupPersonSkillDto> GetList(GroupPersonSkillQueryDto parm)
{
var predicate = Expressionable.Create<GroupPersonSkill>()
.AndIF(!string.IsNullOrEmpty(parm.SkillName),it=>it.SkillName.Contains(parm.SkillName))
.AndIF(parm.Status>0,it=>it.Status==parm.Status)
;
var response = Queryable()
.Where(predicate.ToExpression())
.ToPage<GroupPersonSkill, GroupPersonSkillDto>(parm);
return response;
}
/// <summary>
/// 获取详情
/// </summary>
/// <param name="Id"></param>
/// <returns></returns>
public GroupPersonSkill GetInfo(string Id)
{
var response = Queryable()
.Where(x => x.Id == Id)
.First();
return response;
}
/// <summary>
/// 添加人员技能矩阵图
/// </summary>
/// <param name="model"></param>
/// <returns></returns>
public GroupPersonSkill AddGroupPersonSkill(GroupPersonSkill model)
{
if(string.IsNullOrEmpty(model.Id))
{
model.Id = XueHua;
}
return Context.Insertable(model).ExecuteReturnEntity();
}
/// <summary>
/// 修改人员技能矩阵图
/// </summary>
/// <param name="model"></param>
/// <returns></returns>
public int UpdateGroupPersonSkill(GroupPersonSkill model)
{
//var response = Update(w => w.Id == model.Id, it => new GroupPersonSkill()
//{
// SkillName = model.SkillName,
// Image = model.Image,
// Vedio = model.Vedio,
// Remark = model.Remark,
// Status = model.Status,
// CreatedBy = model.CreatedBy,
// CreatedTime = model.CreatedTime,
// UpdatedBy = model.UpdatedBy,
// UpdatedTime = model.UpdatedTime,
//});
//return response;
return Update(model, true);
}
/// <summary>
/// 人员技能评估
/// </summary>
/// <param name="relPersonSkill"></param>
/// <returns></returns>
public int PersonskillAssessment(GroupRelPersonSkill relPersonSkill)
{
return Context.Storageable(relPersonSkill).ExecuteCommand();
}
//获取人员已经拥有的技能
public List<GroupPersonSkillDto2> GetPersonSkills(string person_id)
{
var query = Context.Queryable<GroupRelPersonSkill>().Where(it => it.FkPersonId == person_id);
return Context.Queryable(query).LeftJoin<GroupPersonSkill>((rel,s)=>rel.FkSkillId==s.Id)
.Select((rel,s)=>new GroupPersonSkillDto2() { score=rel.Score.Value},true)
.ToList();
}
//获取人员没有拥有的技能
public List<GroupPersonSkill> GetPersonUnownSkills(string person_id)
{
var query = Context.Queryable<GroupRelPersonSkill>().Where(it => it.FkPersonId == person_id);
return Context.Queryable(query).LeftJoin<GroupPersonSkill>((rel, s) => rel.FkSkillId != s.Id)
.Select((rel, s) => s)
.Distinct()
.ToList();
}
}
}