302 lines
11 KiB
C#
302 lines
11 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;
|
|
using Aliyun.OSS;
|
|
using DOAN.Model.MES.base_.Dto;
|
|
using DOAN.Model.MES.base_;
|
|
using Microsoft.IdentityModel.Tokens;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
|
|
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 PagedInfo<GroupPersonSkillDto> GetPersonUnownSkills(GroupPersonSkillQueryDto2 parm)
|
|
{
|
|
var query = Context.Queryable<GroupRelPersonSkill>().Where(it => it.FkPersonId == parm.person_id);
|
|
return Context.Queryable(query).RightJoin<GroupPersonSkill>((rel, s) => rel.FkSkillId == s.Id)
|
|
.Where((rel, s) => rel.FkSkillId == null)
|
|
.WhereIF(!string.IsNullOrEmpty(parm.SkillName), (rel, s) => s.SkillName.Contains(parm.SkillName))
|
|
.Select((rel, s) => s)
|
|
.ToPage<GroupPersonSkill, GroupPersonSkillDto>(parm);
|
|
|
|
|
|
}
|
|
/// <summary>
|
|
/// 取消绑定
|
|
/// </summary>
|
|
/// <param name="person_id"></param>
|
|
/// <param name="skill_id"></param>
|
|
/// <returns></returns>
|
|
|
|
public int CancalPersonSkillBind(string person_id, string skill_id)
|
|
{
|
|
return Context.Deleteable<GroupRelPersonSkill>()
|
|
.Where(it => it.FkPersonId == person_id && it.FkSkillId == skill_id)
|
|
.ExecuteCommand();
|
|
}
|
|
|
|
/// <summary>
|
|
/// 获取工艺路线
|
|
/// </summary>
|
|
/// <param name="query"></param>
|
|
/// <returns></returns>
|
|
public List<BaseWorkRoute> GetWorkRouteList([FromBody] BaseWorkRouteQueryDto query)
|
|
{
|
|
List<BaseWorkRoute> workRouteList = Context.Queryable<BaseWorkRoute>()
|
|
.WhereIF(!string.IsNullOrEmpty(query.Name), it => it.Name.Contains(query.Name))
|
|
.WhereIF(!string.IsNullOrEmpty(query.Code), it => it.Code.Contains(query.Code))
|
|
.WhereIF(query.Status > 0, it => it.Status == query.Status)
|
|
.ToList();
|
|
|
|
return workRouteList;
|
|
|
|
}
|
|
/// <summary>
|
|
/// 根据工艺路线查工位
|
|
/// </summary>
|
|
/// <param name="route_id"></param>
|
|
/// <returns></returns>
|
|
public PagedInfo<BaseWorkStation> GetWorkstationbyRoute(BaseWorkStationQueryDto2 query)
|
|
{
|
|
var query1 = Context.Queryable<BaseRelWorkRouteProcesses>()
|
|
.Where(it => it.FkWorkRoute == query.route_id);
|
|
List<BaseWorkProcesses> workProcesses = Context.Queryable(query1).LeftJoin<BaseWorkProcesses>((q, p) => q.FkWorkProcesses == p.Id)
|
|
.Select((q, p) => p)
|
|
.ToList();
|
|
int?[] filters= workProcesses.Select(it=>it.Id).ToArray();
|
|
|
|
return Context.Queryable<BaseWorkStation>()
|
|
.Where(it => filters.Contains(it.FkWorkProcesses))
|
|
.ToPage<BaseWorkStation, BaseWorkStation>(query);
|
|
}
|
|
/// <summary>
|
|
/// 获取工艺路线与工序父子表
|
|
/// </summary>
|
|
/// <param name="query"></param>
|
|
/// <returns></returns>
|
|
public List<RouteANDprocess> RouteProcessParentSon(BaseWorkRouteQueryDto query)
|
|
{
|
|
List<RouteANDprocess> result = new List<RouteANDprocess>();
|
|
|
|
List<BaseWorkRoute> workRouteList = Context.Queryable<BaseWorkRoute>()
|
|
.WhereIF(!string.IsNullOrEmpty(query.Name), it => it.Name.Contains(query.Name))
|
|
.WhereIF(!string.IsNullOrEmpty(query.Code), it => it.Code.Contains(query.Code))
|
|
.WhereIF(query.Status > 0, it => it.Status == query.Status)
|
|
.ToList();
|
|
// int[] queryints = workRouteList.Select(it => it.Id).ToArray();
|
|
if (workRouteList != null && workRouteList.Count > 0)
|
|
{
|
|
foreach (var workRoute in workRouteList)
|
|
{
|
|
RouteANDprocess parent = new RouteANDprocess();
|
|
parent.Name = workRoute.Name;
|
|
parent.Id = workRoute.Id;
|
|
parent.parentId = 0;
|
|
|
|
result.Add(parent);
|
|
var query1 = Context.Queryable<BaseRelWorkRouteProcesses>()
|
|
.Where(it => it.FkWorkRoute == workRoute.Id);
|
|
List<BaseWorkProcesses> workProcesses = Context.Queryable(query1).LeftJoin<BaseWorkProcesses>((q, p) => q.FkWorkProcesses == p.Id)
|
|
.Select((q, p) => p)
|
|
.ToList();
|
|
|
|
|
|
if (workProcesses != null && workProcesses.Count > 0)
|
|
{
|
|
foreach (var process in workProcesses)
|
|
{
|
|
RouteANDprocess son = new RouteANDprocess();
|
|
son.Name = process.Name;
|
|
son.Id = process.Id.Value;
|
|
son.parentId = parent.Id;
|
|
result.Add(son);
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
return result;
|
|
}
|
|
/// <summary>
|
|
/// 根据工序查工位
|
|
/// </summary>
|
|
/// <param name="workProcess_id"></param>
|
|
/// <returns></returns>
|
|
public List<BaseWorkStation> GetWorkstationList_byProccess(int workProcess_id)
|
|
{
|
|
return Context.Queryable<BaseWorkStation>().Where(it => it.FkWorkProcesses == workProcess_id).ToList();
|
|
|
|
}
|
|
/// <summary>
|
|
/// 获取工位绑定的技能
|
|
/// </summary>
|
|
/// <param name="workstation_id"></param>
|
|
/// <returns></returns>
|
|
public List<GroupPersonSkill> GetWorkstationBindSkillList(int workstation_id)
|
|
{
|
|
|
|
var query = Context.Queryable<GroupRelWorkstationSkill>().Where(it => it.FkWorkstationId == workstation_id);
|
|
|
|
return Context.Queryable(query).LeftJoin<GroupPersonSkill>((rel, s) => rel.FkSkillId == s.Id)
|
|
.Select((rel, s) => s)
|
|
.ToList();
|
|
|
|
}
|
|
|
|
/// <summary>
|
|
/// 获取工位没有绑定的技能 分页
|
|
/// </summary>
|
|
/// <param name="parm"></param>
|
|
/// <returns></returns>
|
|
public PagedInfo<GroupPersonSkillDto> GetWorkstationunBindSkillList(GroupPersonSkillQueryDto3 parm)
|
|
{
|
|
var query = Context.Queryable<GroupRelWorkstationSkill>().Where(it => it.FkWorkstationId == parm.workstation_id);
|
|
return Context.Queryable(query).RightJoin<GroupPersonSkill>((rel, s) => rel.FkSkillId == s.Id)
|
|
.Where((rel, s) => rel.FkSkillId == null)
|
|
.WhereIF(!string.IsNullOrEmpty(parm.SkillName),(rel, s) => s.SkillName.Contains(parm.SkillName))
|
|
.Select((rel, s) => s)
|
|
.ToPage<GroupPersonSkill, GroupPersonSkillDto>(parm);
|
|
|
|
|
|
}
|
|
|
|
public int HandleWorkstationbindSkill(int workstation_id, string skill_id)
|
|
{
|
|
GroupRelWorkstationSkill relWorkstationSkill = new GroupRelWorkstationSkill();
|
|
relWorkstationSkill.FkSkillId = skill_id;
|
|
relWorkstationSkill.FkWorkstationId = workstation_id;
|
|
return Context.Insertable(relWorkstationSkill).ExecuteCommand();
|
|
|
|
|
|
}
|
|
public int LiftedWorkstationbindSkill(int workstation_id, string skill_id)
|
|
{
|
|
return Context.Deleteable<GroupRelWorkstationSkill>()
|
|
.Where(it => it.FkWorkstationId == workstation_id)
|
|
.Where(it => it.FkSkillId == skill_id)
|
|
.ExecuteCommand();
|
|
}
|
|
|
|
|
|
}
|
|
} |