2025-12-26 14:39:45 +08:00
|
|
|
|
using DOAN.Admin.WebApi.Filters;
|
2026-01-06 17:26:47 +08:00
|
|
|
|
using DOAN.Model;
|
2025-12-25 12:02:03 +08:00
|
|
|
|
using DOAN.Model.BZFM;
|
2025-12-26 14:39:45 +08:00
|
|
|
|
using DOAN.Model.BZFM.Dto;
|
2026-01-07 18:06:16 +08:00
|
|
|
|
using DOAN.Model.MES.product;
|
2026-01-06 12:06:05 +08:00
|
|
|
|
using DOAN.Model.System;
|
2026-01-06 17:26:47 +08:00
|
|
|
|
using DOAN.Model.System.Dto;
|
2025-12-26 14:39:45 +08:00
|
|
|
|
using DOAN.Service.BZFM;
|
2025-12-25 12:02:03 +08:00
|
|
|
|
using DOAN.Service.BZFM.IBZFMService;
|
2025-12-26 14:39:45 +08:00
|
|
|
|
using Microsoft.AspNetCore.Mvc;
|
2026-01-06 12:06:05 +08:00
|
|
|
|
using MiniExcelLibs;
|
2026-01-07 18:06:16 +08:00
|
|
|
|
using NPOI.SS.Formula.Functions;
|
|
|
|
|
|
using NPOI.SS.UserModel;
|
|
|
|
|
|
using NPOI.XSSF.UserModel;
|
2026-01-06 17:26:47 +08:00
|
|
|
|
using System.Collections.Generic;
|
2026-01-07 18:06:16 +08:00
|
|
|
|
using System.Globalization;
|
2026-01-08 10:50:03 +08:00
|
|
|
|
using System.IO;
|
2026-01-07 18:06:16 +08:00
|
|
|
|
using System.Linq;
|
2025-12-25 12:02:03 +08:00
|
|
|
|
|
|
|
|
|
|
//创建时间:2025-12-25
|
|
|
|
|
|
namespace DOAN.Admin.WebApi.Controllers.BZFM
|
|
|
|
|
|
{
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 物料表
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
[Verify]
|
2025-12-25 14:27:40 +08:00
|
|
|
|
[Route("mes/productionMaterial/MmMaterial")]
|
2025-12-25 12:02:03 +08:00
|
|
|
|
public class MmMaterialController : BaseController
|
|
|
|
|
|
{
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 物料表接口
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
private readonly IMmMaterialService _MmMaterialService;
|
|
|
|
|
|
|
|
|
|
|
|
public MmMaterialController(IMmMaterialService MmMaterialService)
|
|
|
|
|
|
{
|
|
|
|
|
|
_MmMaterialService = MmMaterialService;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 查询物料表列表
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="parm"></param>
|
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
|
[HttpGet("list")]
|
|
|
|
|
|
[ActionPermissionFilter(Permission = "mmmaterial:list")]
|
|
|
|
|
|
public IActionResult QueryMmMaterial([FromQuery] MmMaterialQueryDto parm)
|
|
|
|
|
|
{
|
|
|
|
|
|
var response = _MmMaterialService.GetList(parm);
|
|
|
|
|
|
return SUCCESS(response);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 查询物料表详情
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="Id"></param>
|
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
|
[HttpGet("{Id}")]
|
|
|
|
|
|
[ActionPermissionFilter(Permission = "mmmaterial:query")]
|
|
|
|
|
|
public IActionResult GetMmMaterial(int Id)
|
|
|
|
|
|
{
|
|
|
|
|
|
var response = _MmMaterialService.GetInfo(Id);
|
|
|
|
|
|
|
|
|
|
|
|
var info = response.Adapt<MmMaterialDto>();
|
|
|
|
|
|
return SUCCESS(info);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 添加物料表
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
|
[HttpPost]
|
|
|
|
|
|
[ActionPermissionFilter(Permission = "mmmaterial:add")]
|
|
|
|
|
|
[Log(Title = "物料表", BusinessType = BusinessType.INSERT)]
|
|
|
|
|
|
public IActionResult AddMmMaterial([FromBody] MmMaterialDto parm)
|
|
|
|
|
|
{
|
|
|
|
|
|
var modal = parm.Adapt<MmMaterial>().ToCreate(HttpContext);
|
|
|
|
|
|
|
|
|
|
|
|
var response = _MmMaterialService.AddMmMaterial(modal);
|
|
|
|
|
|
|
|
|
|
|
|
return SUCCESS(response);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 更新物料表
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
|
[HttpPut]
|
|
|
|
|
|
[ActionPermissionFilter(Permission = "mmmaterial:edit")]
|
|
|
|
|
|
[Log(Title = "物料表", BusinessType = BusinessType.UPDATE)]
|
|
|
|
|
|
public IActionResult UpdateMmMaterial([FromBody] MmMaterialDto parm)
|
|
|
|
|
|
{
|
|
|
|
|
|
var modal = parm.Adapt<MmMaterial>().ToUpdate(HttpContext);
|
|
|
|
|
|
var response = _MmMaterialService.UpdateMmMaterial(modal);
|
|
|
|
|
|
|
|
|
|
|
|
return ToResponse(response);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 删除物料表
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
|
[HttpPost("delete/{ids}")]
|
|
|
|
|
|
[ActionPermissionFilter(Permission = "mmmaterial:delete")]
|
|
|
|
|
|
[Log(Title = "物料表", BusinessType = BusinessType.DELETE)]
|
|
|
|
|
|
public IActionResult DeleteMmMaterial([FromRoute]string ids)
|
|
|
|
|
|
{
|
|
|
|
|
|
var idArr = Tools.SplitAndConvert<int>(ids);
|
|
|
|
|
|
|
|
|
|
|
|
return ToResponse(_MmMaterialService.Delete(idArr));
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-12-26 14:53:50 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 获取物料表类别下拉框
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
|
[HttpPost("GetMmMaterialCategoryOptions")]
|
|
|
|
|
|
[AllowAnonymous]
|
|
|
|
|
|
public IActionResult GetMmMaterialCategoryOptions([FromBody] MmMaterialCategoryDto parm)
|
2025-12-26 14:39:45 +08:00
|
|
|
|
{
|
2025-12-26 14:53:50 +08:00
|
|
|
|
var response = _MmMaterialService.GetMmMaterialCategoryOptions(parm);
|
|
|
|
|
|
return SUCCESS(response);
|
2025-12-26 14:39:45 +08:00
|
|
|
|
}
|
2025-12-26 14:53:50 +08:00
|
|
|
|
|
2026-01-06 12:06:05 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 导入
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="formFile">使用IFromFile必须使用name属性否则获取不到文件</param>
|
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
|
[HttpPost("importData")]
|
|
|
|
|
|
[Log(Title = "物料清单导入", BusinessType = BusinessType.IMPORT, IsSaveRequestData = false, IsSaveResponseData = true)]
|
|
|
|
|
|
[ActionPermissionFilter(Permission = "mmmaterial:import")]
|
|
|
|
|
|
public IActionResult ImportData([FromForm(Name = "file")] IFormFile formFile)
|
|
|
|
|
|
{
|
2026-01-08 11:06:25 +08:00
|
|
|
|
//return SUCCESS(_MmMaterialService.Importmaterial(material));
|
|
|
|
|
|
if (formFile == null)
|
|
|
|
|
|
{
|
|
|
|
|
|
return SUCCESS(null);
|
|
|
|
|
|
}
|
2026-01-08 11:45:06 +08:00
|
|
|
|
ImportResultDto response = _MmMaterialService.Importmaterial(formFile, HttpContext.GetName());
|
2026-01-08 11:06:25 +08:00
|
|
|
|
|
|
|
|
|
|
return SUCCESS(response);
|
2026-01-06 12:06:05 +08:00
|
|
|
|
}
|
2026-01-06 17:26:47 +08:00
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 下载物料导入模板
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
|
[HttpGet("importTemplate")]
|
|
|
|
|
|
[Log(Title = "物料模板", BusinessType = BusinessType.EXPORT)]
|
|
|
|
|
|
[AllowAnonymous]
|
|
|
|
|
|
public IActionResult ImportTemplateExcel()
|
|
|
|
|
|
{
|
|
|
|
|
|
// create an empty sample list of export DTO to generate header row
|
2026-01-07 15:25:58 +08:00
|
|
|
|
var sample = new List<MmMaterialExcelDto>();
|
2026-01-06 17:26:47 +08:00
|
|
|
|
var result = DownloadImportTemplate(sample, "material");
|
|
|
|
|
|
return ExportExcel(result.Item2, result.Item1);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
2026-01-07 14:58:50 +08:00
|
|
|
|
/// 物料清单导出
|
2026-01-06 17:26:47 +08:00
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="material"></param>
|
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
|
[HttpGet("export")]
|
|
|
|
|
|
[Log(Title = "物料清单导出", BusinessType = BusinessType.EXPORT)]
|
|
|
|
|
|
[ActionPermissionFilter(Permission = "mmmaterial:export")]
|
|
|
|
|
|
public IActionResult MaterialExport([FromQuery] MmMaterialQueryDto material)
|
|
|
|
|
|
{
|
|
|
|
|
|
var list = _MmMaterialService.SelectMaterialList(material, new PagerInfo(1, 10000));
|
|
|
|
|
|
|
2026-01-07 15:45:45 +08:00
|
|
|
|
var data = (list?.Result ?? new List<MmMaterialExcelDto>());
|
2026-01-06 17:26:47 +08:00
|
|
|
|
|
2026-01-07 15:45:45 +08:00
|
|
|
|
var result = ExportExcelMini(data, "material", "物料清单");
|
2026-01-06 17:26:47 +08:00
|
|
|
|
return ExportExcel(result.Item2, result.Item1);
|
|
|
|
|
|
}
|
2025-12-25 12:02:03 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|