171 lines
5.5 KiB
C#
171 lines
5.5 KiB
C#
using Microsoft.AspNetCore.Mvc;
|
||
using DOAN.Model.MES.product;
|
||
using DOAN.Model.MES.product.Dto;
|
||
|
||
|
||
using DOAN.Service.MES.product.IService;
|
||
using DOAN.Service.MES.product;
|
||
using DOAN.Admin.WebApi.Filters;
|
||
using Org.BouncyCastle.Crypto;
|
||
using DOAN.Model.System;
|
||
using MiniExcelLibs;
|
||
using DOAN.Model.System.Dto;
|
||
using DOAN.Model;
|
||
using DOAN.Service.JobKanban.IService;
|
||
using DOAN.Service.MES.group.IService;
|
||
using DOAN.Infrastructure;
|
||
using Infrastructure.Converter;
|
||
|
||
//创建时间:2024-07-23
|
||
namespace DOAN.Admin.WebApi.Controllers
|
||
{
|
||
/// <summary>
|
||
/// 报工表
|
||
/// </summary>
|
||
[Verify]
|
||
[Route("mes/productManagement/ProReportwork")]
|
||
public class ProReportworkController : BaseController
|
||
{
|
||
/// <summary>
|
||
/// 报工表接口
|
||
/// </summary>
|
||
private readonly IProReportworkService _ProReportworkService;
|
||
|
||
|
||
private readonly ISkillMatrixService _SkillMatrixService;
|
||
|
||
public ProReportworkController(IProReportworkService ProReportworkService, ISkillMatrixService SkillMatrixService)
|
||
{
|
||
_ProReportworkService = ProReportworkService;
|
||
_SkillMatrixService = SkillMatrixService;
|
||
|
||
}
|
||
|
||
/// <summary>
|
||
/// 查询报工表列表
|
||
/// </summary>
|
||
/// <param name="parm"></param>
|
||
/// <returns></returns>
|
||
[HttpPost("list")]
|
||
[ActionPermissionFilter(Permission = "productManagement:proreportwork:list")]
|
||
public IActionResult QueryProReportwork([FromBody] ProReportworkQueryDto parm)
|
||
{
|
||
if(parm==null&&string.IsNullOrEmpty(parm.FkWorkorder))
|
||
{
|
||
SUCCESS(null);
|
||
}
|
||
var response = _ProReportworkService.GetList(parm);
|
||
return SUCCESS(response);
|
||
}
|
||
|
||
|
||
/// <summary>
|
||
/// 查询报工表详情
|
||
/// </summary>
|
||
/// <param name="Id"></param>
|
||
/// <returns></returns>
|
||
[HttpGet("{Id}")]
|
||
[ActionPermissionFilter(Permission = "productManagement:proreportwork:query")]
|
||
public IActionResult GetProReportwork(string Id)
|
||
{
|
||
var response = _ProReportworkService.GetInfo(Id);
|
||
|
||
var info = response.Adapt<ProReportwork>();
|
||
return SUCCESS(info);
|
||
}
|
||
|
||
/// <summary>
|
||
/// 添加报工表
|
||
/// </summary>
|
||
/// <returns></returns>
|
||
[HttpPost]
|
||
[ActionPermissionFilter(Permission = "productManagement:proreportwork:add")]
|
||
[Log(Title = "报工表", BusinessType = BusinessType.INSERT)]
|
||
public IActionResult AddProReportwork([FromBody] ProReportworkDto parm)
|
||
{
|
||
var modal = parm.Adapt<ProReportwork>().ToCreate(HttpContext);
|
||
|
||
var response = _ProReportworkService.AddProReportwork(modal);
|
||
|
||
return SUCCESS(response);
|
||
}
|
||
|
||
/// <summary>
|
||
/// 更新报工表
|
||
/// </summary>
|
||
/// <returns></returns>
|
||
[HttpPut]
|
||
[ActionPermissionFilter(Permission = "productManagement:proreportwork:edit")]
|
||
[Log(Title = "报工表", BusinessType = BusinessType.UPDATE)]
|
||
public IActionResult UpdateProReportwork([FromBody] ProReportworkDto parm)
|
||
{
|
||
var modal = parm.Adapt<ProReportwork>().ToUpdate(HttpContext);
|
||
var response = _ProReportworkService.UpdateProReportwork(modal);
|
||
|
||
return ToResponse(response);
|
||
}
|
||
|
||
/// <summary>
|
||
/// 删除报工表
|
||
/// </summary>
|
||
/// <returns></returns>
|
||
[HttpDelete("{ids}")]
|
||
[ActionPermissionFilter(Permission = "productManagement:proreportwork:delete")]
|
||
[Log(Title = "报工表", BusinessType = BusinessType.DELETE)]
|
||
public IActionResult DeleteProReportwork(string ids)
|
||
{
|
||
string[] idsArr = Tools.SpitStrArrary(ids);
|
||
if (idsArr.Length <= 0) { return ToResponse(ApiResult.Error($"删除失败Id 不能为空")); }
|
||
|
||
var response = _ProReportworkService.Delete(idsArr);
|
||
|
||
return ToResponse(response);
|
||
}
|
||
|
||
//TODO 3 根据班组获取人员
|
||
[HttpGet("get_persons")]
|
||
public IActionResult GetPersonsList(string group_schedule_id)
|
||
{
|
||
|
||
if (string.IsNullOrWhiteSpace(group_schedule_id)) { return SUCCESS(null); }
|
||
|
||
var response = _SkillMatrixService.GetPersonsList(group_schedule_id);
|
||
|
||
return SUCCESS(response);
|
||
}
|
||
|
||
//TODO 导出excel
|
||
/// <summary>
|
||
/// 导出excel
|
||
/// </summary>
|
||
/// <param name="user"></param>
|
||
/// <returns></returns>
|
||
[HttpGet("export")]
|
||
[Log(Title = "报工导出", BusinessType = BusinessType.EXPORT)]
|
||
[AllowAnonymous]
|
||
public IActionResult UserExport(DateTime handleDate)
|
||
{
|
||
handleDate=DOANConvertDateTime.ConvertLocalDate(handleDate);
|
||
|
||
var list =_ProReportworkService.UserExport(handleDate);
|
||
|
||
var result = ExportExcelMini(list, "report", "报工列表");
|
||
|
||
return ExportExcel(result.Item2, result.Item1);
|
||
}
|
||
|
||
// TODO 如果没有id 传入工单 手动生成报工记录
|
||
[HttpGet("manual_generation_reportwork")]
|
||
public IActionResult ManualGenerationOfReportWork(string workorder)
|
||
{
|
||
if (string.IsNullOrEmpty(workorder))
|
||
{
|
||
throw new CustomException("workorder is null");
|
||
}
|
||
|
||
var response = _ProReportworkService.ManualGenerationOfReportWork(workorder, HttpContext.GetName());
|
||
return SUCCESS(response);
|
||
}
|
||
|
||
}
|
||
} |