162 lines
5.6 KiB
C#
162 lines
5.6 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 DOAN.Model.MES.group.Dto;
|
|
using Aliyun.OSS;
|
|
using Microsoft.AspNetCore.Http.HttpResults;
|
|
|
|
namespace DOAN.Service.Business
|
|
{
|
|
/// <summary>
|
|
/// 排班Service业务层处理
|
|
/// </summary>
|
|
[AppService(ServiceType = typeof(IGroupScheduleService), ServiceLifetime = LifeTime.Transient)]
|
|
public class GroupScheduleService : BaseService<GroupSchedule>, IGroupScheduleService
|
|
{
|
|
/// <summary>
|
|
/// 查询排班列表
|
|
/// </summary>
|
|
/// <param name="parm"></param>
|
|
/// <returns></returns>
|
|
public PagedInfo<GroupScheduleDto> GetList(GroupScheduleQueryDto parm)
|
|
{
|
|
var predicate = Expressionable.Create<GroupSchedule>();
|
|
|
|
var response = Queryable()
|
|
.Where(predicate.ToExpression())
|
|
.ToPage<GroupSchedule, GroupScheduleDto>(parm);
|
|
|
|
return response;
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// 获取详情
|
|
/// </summary>
|
|
/// <param name="Id"></param>
|
|
/// <returns></returns>
|
|
public GroupSchedule GetInfo(string Id)
|
|
{
|
|
var response = Queryable()
|
|
.Where(x => x.Id == Id)
|
|
.First();
|
|
|
|
return response;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 添加排班
|
|
/// </summary>
|
|
/// <param name="model"></param>
|
|
/// <returns></returns>
|
|
public GroupSchedule AddGroupSchedule(GroupSchedule model)
|
|
{
|
|
return Context.Insertable(model).ExecuteReturnEntity();
|
|
}
|
|
|
|
/// <summary>
|
|
/// 修改排班
|
|
/// </summary>
|
|
/// <param name="model"></param>
|
|
/// <returns></returns>
|
|
public int UpdateGroupSchedule(GroupSchedule model)
|
|
{
|
|
//var response = Update(w => w.Id == model.Id, it => new GroupSchedule()
|
|
//{
|
|
// ScheduleDate = model.ScheduleDate,
|
|
// GroupName = model.GroupName,
|
|
// GrouoCode = model.GrouoCode,
|
|
// BelongRoute = model.BelongRoute,
|
|
// 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>
|
|
/// 1 根据日期获取班组
|
|
/// </summary>
|
|
/// <param name="date"></param>
|
|
/// <returns></returns>
|
|
public PagedInfo<GroupScheduleDto> ListGroupByDate(GroupScheduleQueryDto2 query)
|
|
{
|
|
query.ScheduleDate = query.ScheduleDate.Date;
|
|
return Queryable().Where(it => it.ScheduleDate == query.ScheduleDate).ToPage<GroupSchedule, GroupScheduleDto>(query);
|
|
|
|
|
|
}
|
|
/// <summary>
|
|
/// 查询班组绑定的人员
|
|
/// </summary>
|
|
/// <param name="group_schedule_id"></param>
|
|
/// <returns></returns>
|
|
public List<GroupPerson> SearchPerson_group_bind(string group_schedule_id)
|
|
{
|
|
List<GroupPerson> peopleList = Context.Queryable<GroupRelPersonGroup>()
|
|
.LeftJoin<GroupPerson>((rel, p) => rel.FkPersonId == p.Id)
|
|
.Where((rel, p) => rel.FkGroupId == group_schedule_id)
|
|
.Select((rel, p) => p).ToList();
|
|
|
|
return peopleList;
|
|
|
|
|
|
}
|
|
|
|
/// <summary>
|
|
/// 查询班组未绑定的人员
|
|
/// </summary>
|
|
/// <param name="group_schedule_id"></param>
|
|
/// <param name="date"></param>
|
|
/// <returns></returns>
|
|
public List<GroupPerson> SearchPerson_group_bind_No(string group_schedule_id)
|
|
{
|
|
// 查询日期内所有绑定人员
|
|
|
|
//查询指定日期排班
|
|
var ScheduleDate1= SqlFunc.Subqueryable<GroupSchedule>().Where(it => it.Id == group_schedule_id).Select(it => it.ScheduleDate);
|
|
|
|
var ScheduleDate2 = SqlFunc.Subqueryable<GroupSchedule>().Where(it => it.ScheduleDate == ScheduleDate1);
|
|
|
|
//查询排班所有绑定的人员
|
|
var query = SqlFunc.Subqueryable<GroupRelPersonGroup>()
|
|
.LeftJoin<GroupPerson>((rel, p) => rel.FkPersonId == p.Id)
|
|
.Where((rel, p) => ScheduleDate2.Where(it => it.Id == rel.FkGroupId).Any());
|
|
|
|
|
|
// 查询排班内所有未绑定人员
|
|
return Context.Queryable<GroupPerson>().Where(it => query.Where((rel, p) => p.Id == it.Id).NotAny()).ToList();
|
|
|
|
}
|
|
|
|
public int GroupAddPerson(string group_schedule_id, string person_id,string CreatedBy)
|
|
{
|
|
GroupRelPersonGroup relPersonGroup = new GroupRelPersonGroup();
|
|
relPersonGroup.FkGroupId = group_schedule_id;
|
|
relPersonGroup.FkPersonId = person_id;
|
|
relPersonGroup.CreatedTime = DateTime.Now;
|
|
relPersonGroup.CreatedBy = CreatedBy;
|
|
return Context.Insertable(relPersonGroup).ExecuteCommand();
|
|
}
|
|
|
|
public int GroupRemovePerson(string group_schedule_id, string person_id)
|
|
{
|
|
return Context.Deleteable<GroupRelPersonGroup>()
|
|
.Where(it=>it.FkGroupId == group_schedule_id)
|
|
.Where(it=>it.FkPersonId == person_id)
|
|
.ExecuteCommand();
|
|
}
|
|
|
|
}
|
|
} |