2024-08-09 08:56:59 +08:00
|
|
|
|
using Microsoft.AspNetCore.Mvc;
|
|
|
|
|
|
using DOAN.Model.MES.group;
|
|
|
|
|
|
using DOAN.Model.MES.group.Dto;
|
|
|
|
|
|
using DOAN.Service.group.IService;
|
|
|
|
|
|
using DOAN.Admin.WebApi.Filters;
|
|
|
|
|
|
using SqlSugar.Extensions;
|
2024-08-09 13:05:46 +08:00
|
|
|
|
using System.Collections.Generic;
|
2024-08-09 08:56:59 +08:00
|
|
|
|
|
|
|
|
|
|
//创建时间:2024-08-08
|
|
|
|
|
|
namespace DOAN.Admin.WebApi.Controllers
|
|
|
|
|
|
{
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 排班
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
[Verify]
|
|
|
|
|
|
[Route("mes/groupManagement/GroupSchedule")]
|
|
|
|
|
|
public class GroupScheduleController : BaseController
|
|
|
|
|
|
{
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 排班接口
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
private readonly IGroupScheduleService _GroupScheduleService;
|
|
|
|
|
|
|
|
|
|
|
|
public GroupScheduleController(IGroupScheduleService GroupScheduleService)
|
|
|
|
|
|
{
|
|
|
|
|
|
_GroupScheduleService = GroupScheduleService;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 查询排班列表
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="parm"></param>
|
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
|
[HttpGet("list")]
|
|
|
|
|
|
// [ActionPermissionFilter(Permission = "business:groupschedule:list")]
|
|
|
|
|
|
public IActionResult QueryGroupSchedule([FromQuery] GroupScheduleQueryDto parm)
|
|
|
|
|
|
{
|
|
|
|
|
|
var response = _GroupScheduleService.GetList(parm);
|
|
|
|
|
|
return SUCCESS(response);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 查询排班详情
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="Id"></param>
|
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
|
[HttpGet("{Id}")]
|
|
|
|
|
|
// [ActionPermissionFilter(Permission = "business:groupschedule:query")]
|
|
|
|
|
|
public IActionResult GetGroupSchedule(string Id)
|
|
|
|
|
|
{
|
|
|
|
|
|
var response = _GroupScheduleService.GetInfo(Id);
|
|
|
|
|
|
|
|
|
|
|
|
var info = response.Adapt<GroupSchedule>();
|
|
|
|
|
|
return SUCCESS(info);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 添加排班
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
|
[HttpPost]
|
|
|
|
|
|
// [ActionPermissionFilter(Permission = "business:groupschedule:add")]
|
|
|
|
|
|
[Log(Title = "排班", BusinessType = BusinessType.INSERT)]
|
|
|
|
|
|
public IActionResult AddGroupSchedule([FromBody] GroupScheduleDto parm)
|
|
|
|
|
|
{
|
|
|
|
|
|
var modal = parm.Adapt<GroupSchedule>().ToCreate(HttpContext);
|
|
|
|
|
|
|
|
|
|
|
|
var response = _GroupScheduleService.AddGroupSchedule(modal);
|
|
|
|
|
|
|
|
|
|
|
|
return SUCCESS(response);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 更新排班
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
|
[HttpPut]
|
|
|
|
|
|
// [ActionPermissionFilter(Permission = "business:groupschedule:edit")]
|
|
|
|
|
|
[Log(Title = "排班", BusinessType = BusinessType.UPDATE)]
|
|
|
|
|
|
public IActionResult UpdateGroupSchedule([FromBody] GroupScheduleDto parm)
|
|
|
|
|
|
{
|
|
|
|
|
|
var modal = parm.Adapt<GroupSchedule>().ToUpdate(HttpContext);
|
|
|
|
|
|
var response = _GroupScheduleService.UpdateGroupSchedule(modal);
|
|
|
|
|
|
|
|
|
|
|
|
return ToResponse(response);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 1 根据日期获取班组
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="date"></param>
|
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
|
[HttpGet("list_by_date")]
|
|
|
|
|
|
public IActionResult ListGroupByDate(GroupScheduleQueryDto2 query)
|
|
|
|
|
|
{
|
|
|
|
|
|
if(query.ScheduleDate == DateTime.MinValue)
|
|
|
|
|
|
{
|
|
|
|
|
|
return SUCCESS(null);
|
|
|
|
|
|
}
|
|
|
|
|
|
var response = _GroupScheduleService.ListGroupByDate(query);
|
|
|
|
|
|
|
|
|
|
|
|
return SUCCESS(response);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// TODO 2 根据日期添加班组
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 添加排班
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
|
[HttpPost("bydate_add")]
|
|
|
|
|
|
[Log(Title = "排班", BusinessType = BusinessType.INSERT)]
|
|
|
|
|
|
public IActionResult AddGroupSchedule2([FromBody] GroupScheduleDto parm)
|
|
|
|
|
|
{
|
|
|
|
|
|
if(parm.ScheduleDate == DateTime.MinValue)
|
|
|
|
|
|
{
|
|
|
|
|
|
return SUCCESS(null);
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
parm.ScheduleDate = parm.ScheduleDate.Date;
|
|
|
|
|
|
var modal = parm.Adapt<GroupSchedule>().ToCreate(HttpContext);
|
|
|
|
|
|
|
|
|
|
|
|
var response = _GroupScheduleService.AddGroupSchedule(modal);
|
|
|
|
|
|
|
|
|
|
|
|
return SUCCESS(response);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2024-08-09 13:05:46 +08:00
|
|
|
|
// TODO
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 3 删除班组
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
|
[HttpDelete("{ids}")]
|
|
|
|
|
|
// [ActionPermissionFilter(Permission = "business:groupschedule:delete")]
|
|
|
|
|
|
[Log(Title = "排班", BusinessType = BusinessType.DELETE)]
|
|
|
|
|
|
public IActionResult DeleteGroupSchedule(string ids)
|
|
|
|
|
|
{
|
|
|
|
|
|
int[] idsArr = Tools.SpitIntArrary(ids);
|
|
|
|
|
|
if (idsArr.Length <= 0) { return ToResponse(ApiResult.Error($"删除失败Id 不能为空")); }
|
|
|
|
|
|
|
|
|
|
|
|
var response = _GroupScheduleService.Delete(idsArr);
|
|
|
|
|
|
|
|
|
|
|
|
return ToResponse(response);
|
|
|
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// //TODO 查询班组绑定的人员
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="group_schedule_id">班组id</param>
|
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
|
[HttpGet("list_person_bind")]
|
|
|
|
|
|
public IActionResult SearchPerson_group_bind(string group_schedule_id)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (string.IsNullOrEmpty(group_schedule_id))
|
|
|
|
|
|
{
|
|
|
|
|
|
return SUCCESS(null);
|
|
|
|
|
|
}
|
|
|
|
|
|
var response = _GroupScheduleService.SearchPerson_group_bind(group_schedule_id);
|
|
|
|
|
|
|
|
|
|
|
|
return SUCCESS(response);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// TODO 查询排班未绑定的人员
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="group_schedule_id">班id</param>
|
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
|
[HttpGet("list_person_bind_no")]
|
|
|
|
|
|
public IActionResult SearchPerson_group_bind_No(string group_schedule_id)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (string.IsNullOrEmpty(group_schedule_id))
|
|
|
|
|
|
{
|
|
|
|
|
|
return SUCCESS(null);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
var response = _GroupScheduleService.SearchPerson_group_bind_No(group_schedule_id);
|
|
|
|
|
|
|
|
|
|
|
|
return SUCCESS(response);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//TODO 班组添加人员
|
|
|
|
|
|
[HttpGet("add_person")]
|
|
|
|
|
|
public IActionResult GroupAddPerson(string group_schedule_id,string person_id)
|
|
|
|
|
|
{
|
|
|
|
|
|
if(string.IsNullOrEmpty(group_schedule_id)) { return SUCCESS(null); }
|
|
|
|
|
|
if(string.IsNullOrEmpty(person_id)) { return SUCCESS(null); }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var response = _GroupScheduleService
|
|
|
|
|
|
.GroupAddPerson(group_schedule_id, person_id, HttpContext.GetName());
|
|
|
|
|
|
|
|
|
|
|
|
return SUCCESS(response);
|
|
|
|
|
|
}
|
|
|
|
|
|
//TODO 班组删除人员
|
|
|
|
|
|
[HttpGet("delete_person")]
|
|
|
|
|
|
public IActionResult GroupRemovePerson(string group_schedule_id, string person_id)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (string.IsNullOrEmpty(group_schedule_id)) { return SUCCESS(null); }
|
|
|
|
|
|
if (string.IsNullOrEmpty(person_id)) { return SUCCESS(null); }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var response = _GroupScheduleService
|
|
|
|
|
|
.GroupRemovePerson(group_schedule_id, person_id);
|
|
|
|
|
|
|
|
|
|
|
|
return SUCCESS(response);
|
|
|
|
|
|
}
|
2024-08-09 08:56:59 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|