|
|
|
using DS.Module.Core;
|
|
|
|
using DS.Module.Core.Data;
|
|
|
|
using DS.WMS.Core.Check.Dtos;
|
|
|
|
using DS.WMS.Core.Check.Interface;
|
|
|
|
using DS.WMS.Core.Check.View;
|
|
|
|
using DS.WMS.Core.Op.Dtos;
|
|
|
|
using DS.WMS.Core.Sys.Interface;
|
|
|
|
using Microsoft.AspNetCore.Mvc;
|
|
|
|
using MiniExcelLibs;
|
|
|
|
|
|
|
|
namespace DS.WMS.CheckApi.Controllers;
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// 自动对账服务
|
|
|
|
/// </summary>
|
|
|
|
public class CheckBillAutoController : ApiController
|
|
|
|
{
|
|
|
|
private readonly ICheckBillAutoService _invokeService;
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// 构造函数
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="invokeService"></param>
|
|
|
|
public CheckBillAutoController(ICheckBillAutoService invokeService)
|
|
|
|
{
|
|
|
|
_invokeService = invokeService;
|
|
|
|
}
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// 自动对账列表
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="request"></param>
|
|
|
|
/// <returns></returns>
|
|
|
|
[HttpPost]
|
|
|
|
[Route("GetCheckBillAutoList")]
|
|
|
|
public DataResult<List<CheckBillAutoRes>> GetCheckBillAutoList([FromBody] PageRequest request)
|
|
|
|
{
|
|
|
|
var res = _invokeService.GetCheckBillAutoList(request);
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// 自动对账明细列表
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="request"></param>
|
|
|
|
/// <returns></returns>
|
|
|
|
[HttpPost]
|
|
|
|
[Route("GetCheckBillAutoDetailList")]
|
|
|
|
public DataResult<List<CheckBillAutoDetailRes>> GetCheckBillAutoDetailList([FromBody] PageRequest request)
|
|
|
|
{
|
|
|
|
var res = _invokeService.GetCheckBillAutoDetailList(request);
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// 编辑
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="req"></param>
|
|
|
|
/// <returns></returns>
|
|
|
|
[HttpPost]
|
|
|
|
[Route("EditCheckBillAutoInfo")]
|
|
|
|
public DataResult EditCheckBillAutoInfo([FromBody] CheckBillAutoReq req)
|
|
|
|
{
|
|
|
|
var res = _invokeService.EditCheckBillAutoInfo(req);
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
/// <summary>
|
|
|
|
/// 详情
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="id"></param>
|
|
|
|
/// <returns></returns>
|
|
|
|
[HttpGet]
|
|
|
|
[Route("GetCheckBillAutoInfo")]
|
|
|
|
public DataResult<CheckBillAutoRes> GetCheckBillAutoInfo([FromQuery] string id)
|
|
|
|
{
|
|
|
|
var res = _invokeService.GetCheckBillAutoInfo(id);
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// 导入对账excel
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="file">excel文件</param>
|
|
|
|
/// <param name="id">对账主表id</param>
|
|
|
|
/// <returns></returns>
|
|
|
|
[HttpPost]
|
|
|
|
[Route("ImportExcel")]
|
|
|
|
public async Task<DataResult> ImportExcel(IFormFile file, [FromForm] string id)
|
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
|
|
|
var formFile = file;
|
|
|
|
//DataResult<string> api_Result = new Api_Result<string>();
|
|
|
|
//获取文件名
|
|
|
|
var fileName = formFile.FileName;
|
|
|
|
// 获取文件后缀
|
|
|
|
var fileExtension = Path.GetExtension(fileName);
|
|
|
|
// 判断后缀是否是xlsx或者xls
|
|
|
|
if (fileExtension != ".xlsx" && fileExtension != ".xls")
|
|
|
|
{
|
|
|
|
return DataResult.Failed("文件格式错误");
|
|
|
|
}
|
|
|
|
var length = formFile.Length;
|
|
|
|
if (length > 1024 * 1024 * 10)
|
|
|
|
{
|
|
|
|
return DataResult.Failed("文件大小不能超过10M");
|
|
|
|
}
|
|
|
|
// MemoryStream 内存流 在内存当中创建一个流(开辟空间)
|
|
|
|
using (var stream = new MemoryStream())
|
|
|
|
{
|
|
|
|
//将文件写入内存流
|
|
|
|
formFile.CopyTo(stream);
|
|
|
|
//将流的位置归零
|
|
|
|
stream.Position = 0;
|
|
|
|
//将内存流转成List集合
|
|
|
|
var list = await stream.QueryAsync<CheckBillAutoExcelReq>();
|
|
|
|
|
|
|
|
var res = await _invokeService.CreateCheckBillAutoByExcel(id,list.ToList());
|
|
|
|
|
|
|
|
return await Task.FromResult(res);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
catch (Exception ex)
|
|
|
|
{
|
|
|
|
throw new Exception(ex.ToString());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|