You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
193 lines
5.5 KiB
C#
193 lines
5.5 KiB
C#
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());
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// 对账明细批量删除
|
|
/// </summary>
|
|
/// <param name="req">主表Id及明细业务Ids</param>
|
|
/// <returns></returns>
|
|
[HttpPost]
|
|
[Route("BatchDelCheckBillAutoDetail")]
|
|
public DataResult BatchDelCheckBillAutoDetail([FromBody] IdModel req)
|
|
{
|
|
var res = _invokeService.BatchDelCheckBillAutoDetail(req);
|
|
return res;
|
|
}
|
|
/// <summary>
|
|
/// 自动对账批量删除
|
|
/// </summary>
|
|
/// <param name="req">主表Ids</param>
|
|
/// <returns></returns>
|
|
[HttpPost]
|
|
[Route("BatchDelCheckBillAuto")]
|
|
public DataResult BatchDelCheckBillAuto([FromBody] IdModel req)
|
|
{
|
|
var res = _invokeService.BatchDelCheckBillAuto(req);
|
|
return res;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 自动对账重新匹配
|
|
/// </summary>
|
|
/// <param name="req">主表Id</param>
|
|
/// <returns></returns>
|
|
[HttpPost]
|
|
[Route("RecountCheckBillAuto")]
|
|
public DataResult RecountCheckBillAuto([FromBody] IdModel req)
|
|
{
|
|
var res = _invokeService.RecountCheckBillAuto(req);
|
|
return res;
|
|
}
|
|
/// <summary>
|
|
/// 生成对账单
|
|
/// </summary>
|
|
/// <param name="req">主表Id</param>
|
|
/// <returns></returns>
|
|
[HttpPost]
|
|
[Route("CreateCheckBill")]
|
|
public async Task<DataResult> CreateCheckBill([FromBody] IdModel req)
|
|
{
|
|
var res = await _invokeService.CreateCheckBill(req);
|
|
return res;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 取消生成的对账单
|
|
/// </summary>
|
|
/// <param name="req">主表Id</param>
|
|
/// <returns></returns>
|
|
[HttpPost]
|
|
[Route("CancelCheckBill")]
|
|
public async Task<DataResult> CancelCheckBill([FromBody] IdModel req)
|
|
{
|
|
var res = await _invokeService.CancelCheckBill(req);
|
|
return res;
|
|
}
|
|
} |