199 lines
6.8 KiB
C#
199 lines
6.8 KiB
C#
using Aliyun.OSS;
|
||
using Microsoft.AspNetCore.Mvc;
|
||
using RIZO.Model;
|
||
using RIZO.Model.Mes;
|
||
using RIZO.Model.Content.Dto;
|
||
using RIZO.Model.Mes.Dto;
|
||
using RIZO.Model.Mes.Dto.Process;
|
||
using RIZO.Service.Mes;
|
||
using RIZO.Service.Mes.IMesService.Process;
|
||
using RIZO.Model.Mes.Process;
|
||
|
||
|
||
//创建时间:2025-11-04
|
||
namespace RIZO.Admin.WebApi.Controllers.Mes.Process
|
||
{
|
||
/// <summary>
|
||
/// 工艺表
|
||
/// </summary>
|
||
[Route("mes/ProcessInfo")]
|
||
[AllowAnonymous]
|
||
public class ProcessInfoController : BaseController
|
||
{
|
||
/// <summary>
|
||
/// 工艺表接口
|
||
/// </summary>
|
||
private readonly IProcessInfoService _ProcessInfoService;
|
||
|
||
public ProcessInfoController(IProcessInfoService ProcessInfoService)
|
||
{
|
||
_ProcessInfoService = ProcessInfoService;
|
||
}
|
||
|
||
/// <summary>
|
||
/// 查询工艺表列表
|
||
/// </summary>
|
||
/// <param name="parm"></param>
|
||
/// <returns></returns>
|
||
[HttpGet("list")]
|
||
[ActionPermissionFilter(Permission = "processinfo:list")]
|
||
public IActionResult QueryProcessInfo([FromQuery] ProcessInfoQueryDto parm)
|
||
{
|
||
var response = _ProcessInfoService.GetList(parm);
|
||
return SUCCESS(response);
|
||
}
|
||
|
||
|
||
/// <summary>
|
||
/// 查询工艺表详情
|
||
/// </summary>
|
||
/// <param name="Id"></param>
|
||
/// <returns></returns>
|
||
[HttpGet("{Id}")]
|
||
[ActionPermissionFilter(Permission = "processinfo:query")]
|
||
public IActionResult GetProcessInfo(long Id)
|
||
{
|
||
var response = _ProcessInfoService.GetInfo(Id);
|
||
|
||
var info = response.Adapt<ProcessInfoDto>();
|
||
return SUCCESS(info);
|
||
}
|
||
|
||
/// <summary>
|
||
/// 添加工艺表
|
||
/// </summary>
|
||
/// <returns></returns>
|
||
[HttpPost]
|
||
[ActionPermissionFilter(Permission = "processinfo:add")]
|
||
[Log(Title = "工艺表", BusinessType = BusinessType.INSERT)]
|
||
public IActionResult AddProcessInfo([FromBody] ProcessInfoDto parm)
|
||
{
|
||
var modal = parm.Adapt<ProcessInfo>().ToCreate(HttpContext);
|
||
|
||
var response = _ProcessInfoService.AddProcessInfo(modal);
|
||
|
||
return SUCCESS(response);
|
||
}
|
||
|
||
/// <summary>
|
||
/// 更新工艺表
|
||
/// </summary>
|
||
/// <returns></returns>
|
||
[HttpPut]
|
||
[ActionPermissionFilter(Permission = "processinfo:edit")]
|
||
[Log(Title = "工艺表", BusinessType = BusinessType.UPDATE)]
|
||
public IActionResult UpdateProcessInfo([FromBody] ProcessInfoDto parm)
|
||
{
|
||
var modal = parm.Adapt<ProcessInfo>().ToUpdate(HttpContext);
|
||
var response = _ProcessInfoService.UpdateProcessInfo(modal);
|
||
|
||
return ToResponse(response);
|
||
}
|
||
|
||
/// <summary>
|
||
/// 删除工艺表
|
||
/// </summary>
|
||
/// <returns></returns>
|
||
[HttpPost("delete/{ids}")]
|
||
[ActionPermissionFilter(Permission = "processinfo:delete")]
|
||
[Log(Title = "工艺表", BusinessType = BusinessType.DELETE)]
|
||
public IActionResult DeleteProcessInfo([FromRoute]string ids)
|
||
{
|
||
var idArr = Tools.SplitAndConvert<long>(ids);
|
||
|
||
return ToResponse(_ProcessInfoService.Delete(idArr));
|
||
}
|
||
|
||
/// <summary>
|
||
/// 导入工艺表
|
||
/// </summary>
|
||
/// <returns></returns>
|
||
[HttpPost("ImportProcessInfo")]
|
||
//[ActionPermissionFilter(Permission = "processinfo:import")]
|
||
[Log(Title = "导入保存工艺路线", BusinessType = BusinessType.IMPORT)]
|
||
public IActionResult ImportProcessInfo([FromQuery] string userId, [FromQuery] string userName, [FromForm] IFormFile file)
|
||
{
|
||
var stream = file.OpenReadStream();
|
||
var fileName = file.FileName;
|
||
var response = _ProcessInfoService.ImportProcessInfo(stream, userId,userName);
|
||
return SUCCESS(response);
|
||
}
|
||
|
||
/// <summary>
|
||
/// 通过工艺路线Code批量删除工艺表
|
||
/// </summary>
|
||
/// <returns></returns>
|
||
[HttpPost("deleteByProcessCode")]
|
||
[ActionPermissionFilter(Permission = "processinfo:delete")]
|
||
[Log(Title = "工艺表", BusinessType = BusinessType.DELETE)]
|
||
public IActionResult DeleteByProcessCode([FromBody] string[] processCodeArr)
|
||
{
|
||
return ToResponse(_ProcessInfoService.DeleteByProcessCode(processCodeArr));
|
||
}
|
||
|
||
/// <summary>
|
||
/// 模糊条件查询
|
||
/// </summary>
|
||
[HttpPost("GetProcessInfoCondition")]
|
||
//[ActionPermissionFilter(Permission = "processinfo:query")]
|
||
public IActionResult GetProcessInfoCondition([FromBody] ProcessInfoQueryDto parm)
|
||
{
|
||
|
||
// 校验参数
|
||
if (parm == null)
|
||
{
|
||
return SUCCESS(new PagedInfo<ProcessInfoDto>()); // 非法参数返回空分页
|
||
}
|
||
// 调用服务层分页查询(需同步修改服务层方法)
|
||
var pagedResult = _ProcessInfoService.GetProcessInfoCondition(parm);
|
||
|
||
return SUCCESS(pagedResult);
|
||
}
|
||
|
||
/// <summary>
|
||
/// 导出工艺路线详情
|
||
/// </summary>
|
||
/// <returns></returns>
|
||
[HttpGet("export")]
|
||
//[ActionPermissionFilter(Permission = "processinfo:export")]
|
||
[Log(Title = "工艺路线详情", BusinessType = BusinessType.EXPORT)]
|
||
public IActionResult Export()
|
||
{
|
||
ProcessInfoQueryDto parm = new ProcessInfoQueryDto
|
||
{
|
||
PageNum = 1,
|
||
PageSize = 100000
|
||
};
|
||
var list = _ProcessInfoService.GetList(parm).Result;
|
||
if (list == null || list.Count <= 0)
|
||
{
|
||
return ToResponse(ResultCode.FAIL, "没有要导出的数据");
|
||
}
|
||
var (sFileName, sFilePath) = ExportExcelMini(list, "工艺路线详情", "工艺路线详情");
|
||
if (string.IsNullOrWhiteSpace(sFilePath))
|
||
{
|
||
return ToResponse(ResultCode.FAIL, "Excel生成失败");
|
||
}
|
||
return PhysicalFile(
|
||
sFilePath,
|
||
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
|
||
sFileName,
|
||
true
|
||
);
|
||
}
|
||
|
||
/// <summary>
|
||
/// 工艺信息导入模板下载
|
||
/// </summary>
|
||
/// <returns></returns>
|
||
[HttpGet("importTemplate")]
|
||
[Log(Title = "工艺路线导入模板", BusinessType = BusinessType.EXPORT, IsSaveRequestData = true, IsSaveResponseData = false)]
|
||
[AllowAnonymous]
|
||
public IActionResult ImportTemplateExcel()
|
||
{
|
||
(string, string) result = DownloadImportTemplate("工艺路线导入模板");
|
||
return ExportExcel(result.Item2, result.Item1);
|
||
}
|
||
|
||
}
|
||
} |