256 lines
9.3 KiB
C#
256 lines
9.3 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="parm"></param>
|
||
/// <returns></returns>
|
||
[HttpPost("list_print")]
|
||
[ActionPermissionFilter(Permission = "productManagement:proreportwork:list")]
|
||
public IActionResult QueryProReportworkPrint([FromBody] ProReportworkQueryDto parm)
|
||
{
|
||
if(parm==null&&string.IsNullOrEmpty(parm.FkWorkorder))
|
||
{
|
||
SUCCESS(null);
|
||
}
|
||
var response = _ProReportworkService.GetList_Print(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 columnMapping = new Dictionary<string, string>
|
||
{
|
||
{ nameof(ProReportworkDto.Id), "ID" },
|
||
{ nameof(ProReportworkDto.FkWorkorder), "工单号" },
|
||
{ nameof(ProReportworkDto.DispatchNum), "计划数量" },
|
||
{ nameof(ProReportworkDto.FinishedNum), "完成数量" },
|
||
{ nameof(ProReportworkDto.ProductionCode), "产品代码" },
|
||
{ nameof(ProReportworkDto.ProductionName), "产品名称" },
|
||
{ nameof(ProReportworkDto.UnfinishedReanson), "未完成原因" },
|
||
{ nameof(ProReportworkDto.Specification), "规格" },
|
||
{ nameof(ProReportworkDto.GroupCode), "组别" },
|
||
{ nameof(ProReportworkDto.LineCode), "线别" },
|
||
{ nameof(ProReportworkDto.Difference), "报告数和仓库确认数是否差异" },
|
||
{ nameof(ProReportworkDto.UnqualifiedNumber), "未完成数量" },
|
||
{ nameof(ProReportworkDto.ReworkNumber), "返工数" },
|
||
{ nameof(ProReportworkDto.ScrapNumber), "报废数" },
|
||
{ nameof(ProReportworkDto.WorkorderRamark), "工单备注" },
|
||
{ nameof(ProReportworkDto.Remark), "报工备注" },
|
||
{ nameof(ProReportworkDto.CreatedBy), "创建者" },
|
||
{ nameof(ProReportworkDto.CreatedTime), "创建时间" },
|
||
{ nameof(ProReportworkDto.UpdatedBy), "更改者" },
|
||
{ nameof(ProReportworkDto.UpdatedTime), "更改时间" },
|
||
{ nameof(ProReportworkDto.Priority), "优先级" },
|
||
{ nameof(ProReportworkDto.Status), "状态" },
|
||
{ nameof(ProReportworkDto.Beat), "节拍" },
|
||
|
||
};
|
||
|
||
// 将数据转换为字典列表,以便 MiniExcel 可以识别列名
|
||
var rows = list.Select(dto => columnMapping.ToDictionary(
|
||
mapping => mapping.Value, // 使用中文标题作为列名
|
||
mapping => dto.GetType().GetProperty(mapping.Key).GetValue(dto, null)
|
||
)).ToList();
|
||
|
||
var result = ExportExcelMini(rows, "report", "报工列表");
|
||
|
||
return ExportExcel(result.Item2, result.Item1);
|
||
}
|
||
|
||
// TODO 如果没有id 传入工单 手动生成报工记录
|
||
/// <summary>
|
||
///
|
||
/// </summary>
|
||
/// <param name="workorder"></param>
|
||
/// <returns> 返回报工id </returns>
|
||
/// <exception cref="CustomException"></exception>
|
||
[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);
|
||
}
|
||
|
||
/// <summary>
|
||
/// 批量成品入库
|
||
/// </summary>
|
||
/// <param name="startTime"></param>
|
||
/// <param name="endTime"></param>
|
||
/// <returns></returns>
|
||
[HttpGet("batchPutInFinProduct")]
|
||
[AllowAnonymous]
|
||
public IActionResult batchPutInFinProduct([FromQuery] DateTime startTime,DateTime endTime)
|
||
{
|
||
var response = _ProReportworkService.batchPutInFinProduct(startTime,endTime);
|
||
return SUCCESS(response);
|
||
}
|
||
|
||
|
||
/// <summary>
|
||
/// 单条成品入库或驳回
|
||
/// </summary>
|
||
/// <param name="Id"></param>
|
||
/// <param name="type"></param>
|
||
/// <returns></returns>
|
||
[HttpGet("putInAndReject")]
|
||
[AllowAnonymous]
|
||
public IActionResult putInAndReject([FromQuery] string Id,int type)
|
||
{
|
||
var response = _ProReportworkService.putInAndReject(Id, type);
|
||
return SUCCESS(response);
|
||
}
|
||
}
|
||
} |