2024-07-23 14:23:09 +08:00
|
|
|
|
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;
|
2024-08-15 10:59:13 +08:00
|
|
|
|
using DOAN.Service.JobKanban.IService;
|
|
|
|
|
|
using DOAN.Service.MES.group.IService;
|
2024-11-04 13:47:51 +08:00
|
|
|
|
using DOAN.Infrastructure;
|
|
|
|
|
|
using Infrastructure.Converter;
|
2024-07-23 14:23:09 +08:00
|
|
|
|
|
|
|
|
|
|
//创建时间: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;
|
|
|
|
|
|
|
2024-08-15 10:59:13 +08:00
|
|
|
|
|
|
|
|
|
|
private readonly ISkillMatrixService _SkillMatrixService;
|
|
|
|
|
|
|
|
|
|
|
|
public ProReportworkController(IProReportworkService ProReportworkService, ISkillMatrixService SkillMatrixService)
|
2024-07-23 14:23:09 +08:00
|
|
|
|
{
|
|
|
|
|
|
_ProReportworkService = ProReportworkService;
|
2024-08-15 10:59:13 +08:00
|
|
|
|
_SkillMatrixService = SkillMatrixService;
|
|
|
|
|
|
|
2024-07-23 14:23:09 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 查询报工表列表
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="parm"></param>
|
|
|
|
|
|
/// <returns></returns>
|
2024-07-23 15:32:05 +08:00
|
|
|
|
[HttpPost("list")]
|
2024-07-23 14:23:09 +08:00
|
|
|
|
[ActionPermissionFilter(Permission = "productManagement:proreportwork:list")]
|
2024-07-23 15:32:05 +08:00
|
|
|
|
public IActionResult QueryProReportwork([FromBody] ProReportworkQueryDto parm)
|
2024-07-23 14:23:09 +08:00
|
|
|
|
{
|
2024-07-23 15:32:05 +08:00
|
|
|
|
if(parm==null&&string.IsNullOrEmpty(parm.FkWorkorder))
|
|
|
|
|
|
{
|
|
|
|
|
|
SUCCESS(null);
|
|
|
|
|
|
}
|
2024-07-23 14:23:09 +08:00
|
|
|
|
var response = _ProReportworkService.GetList(parm);
|
|
|
|
|
|
return SUCCESS(response);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2024-11-29 10:12:16 +08:00
|
|
|
|
/// <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);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2024-07-23 14:23:09 +08:00
|
|
|
|
|
|
|
|
|
|
/// <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);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2024-08-15 10:59:13 +08:00
|
|
|
|
//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);
|
2024-07-23 14:23:09 +08:00
|
|
|
|
|
2024-08-15 10:59:13 +08:00
|
|
|
|
return SUCCESS(response);
|
|
|
|
|
|
}
|
2024-11-29 10:12:16 +08:00
|
|
|
|
|
2024-11-04 13:47:51 +08:00
|
|
|
|
//TODO 导出excel
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 导出excel
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="user"></param>
|
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
|
[HttpGet("export")]
|
|
|
|
|
|
[Log(Title = "报工导出", BusinessType = BusinessType.EXPORT)]
|
2024-11-04 13:50:00 +08:00
|
|
|
|
[AllowAnonymous]
|
2024-11-04 13:47:51 +08:00
|
|
|
|
public IActionResult UserExport(DateTime handleDate)
|
|
|
|
|
|
{
|
|
|
|
|
|
handleDate=DOANConvertDateTime.ConvertLocalDate(handleDate);
|
|
|
|
|
|
|
|
|
|
|
|
var list =_ProReportworkService.UserExport(handleDate);
|
2025-02-21 17:17:23 +08:00
|
|
|
|
// 创建一个字典来映射属性名和中文标题
|
|
|
|
|
|
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();
|
2024-11-04 13:47:51 +08:00
|
|
|
|
|
2025-02-21 17:17:23 +08:00
|
|
|
|
var result = ExportExcelMini(rows, "report", "报工列表");
|
2024-11-04 13:47:51 +08:00
|
|
|
|
|
|
|
|
|
|
return ExportExcel(result.Item2, result.Item1);
|
|
|
|
|
|
}
|
2024-07-23 14:23:09 +08:00
|
|
|
|
|
2024-11-07 17:25:00 +08:00
|
|
|
|
// TODO 如果没有id 传入工单 手动生成报工记录
|
2024-11-07 17:31:38 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
///
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="workorder"></param>
|
2024-12-10 13:39:23 +08:00
|
|
|
|
/// <returns> 返回报工id </returns>
|
2024-11-07 17:31:38 +08:00
|
|
|
|
/// <exception cref="CustomException"></exception>
|
2024-11-07 17:25:00 +08:00
|
|
|
|
[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);
|
|
|
|
|
|
}
|
2025-03-31 16:07:01 +08:00
|
|
|
|
|
|
|
|
|
|
/// <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);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2024-07-23 14:23:09 +08:00
|
|
|
|
}
|