174 lines
7.2 KiB
C#
174 lines
7.2 KiB
C#
using Microsoft.AspNetCore.Mvc;
|
|
using Newtonsoft.Json;
|
|
using NPOI.SS.Formula.Functions;
|
|
using SqlSugar;
|
|
using WCS.BLL;
|
|
using WCS.BLL.DbModels;
|
|
using WCS.BLL.HardWare;
|
|
using WCS.BLL.Manager;
|
|
using WCS.BLL.Services.IService;
|
|
using WCS.BLL.Services.Service;
|
|
using WCS.DAL.Db;
|
|
using WCS.DAL.DbModels;
|
|
using WCS.Model;
|
|
using WCS.Model.ApiModel.AGV;
|
|
using WCS.Model.ApiModel.Home;
|
|
using WCS.Model.ApiModel.MatBaseInfo;
|
|
using WCS.Model.ApiModel.MatDetailCurrentInfo;
|
|
using WCS.Model.ApiModel.MatDetailHistoryInfo;
|
|
using WCS.Model.ApiModel.StoreInfo;
|
|
using WCS.WebApi.Helper;
|
|
using Mode = WCS.BLL.HardWare.Mode;
|
|
|
|
namespace WCS.WebApi.Controllers
|
|
{
|
|
/// <summary>
|
|
/// 主页面的接口
|
|
/// </summary>
|
|
[ApiController]
|
|
[Route("[controller]")]
|
|
public class MatDetailHistoryInfoController : ControllerBase
|
|
{
|
|
public MatDetailHistoryInfoController()
|
|
{
|
|
|
|
}
|
|
|
|
[Route("getMatDetailHistoryInfos")]
|
|
[HttpPost(Name = "getMatDetailHistoryInfos")]
|
|
public async Task<PageQueryResponse<MatDetailHistoryInfo>> getMatDetailHistoryInfos(GetMatDetailHistoryInfosRequest request)
|
|
{
|
|
try
|
|
{
|
|
var recordsQueryable = DbHelp.db.Queryable<MatDetailHistoryInfo>()
|
|
.WhereIF(request.RecordType != null, t => t.RecordType == request.RecordType)
|
|
.WhereIF(request.FunctionType != null, t => t.FunctionType == request.FunctionType)
|
|
.WhereIF(!string.IsNullOrEmpty(request.ShelfCode), t => t.ShelfCode.Contains(request.ShelfCode))
|
|
.WhereIF(!string.IsNullOrEmpty(request.MatCode), t => t.MatCode.Contains(request.MatCode))
|
|
.WhereIF(!string.IsNullOrEmpty(request.MatName), t => t.MatName.Contains(request.MatName))
|
|
;
|
|
|
|
var totalCount = await recordsQueryable.CountAsync();
|
|
var records = await recordsQueryable
|
|
.OrderByDescending(t => t.ModifyTime)
|
|
.Skip((request.PageNumber - 1) * request.PageSize).Take(request.PageSize)
|
|
.ToListAsync();
|
|
//生成序号
|
|
for (int i = 0; i < records.Count; i++)
|
|
{
|
|
records[i].RowNumber = (request.PageNumber - 1) * request.PageSize + i + 1;
|
|
}
|
|
return new PageQueryResponse<MatDetailHistoryInfo>()
|
|
{
|
|
Code = 200,
|
|
Message = $"success",
|
|
Data = new PageQueryResponseData<MatDetailHistoryInfo>()
|
|
{
|
|
TotalCount = totalCount,
|
|
MaxPage = request.PageSize == 0 ? 0 : (int)Math.Ceiling((decimal)totalCount / request.PageSize),
|
|
Count = records.Count,
|
|
Lists = records.ToList()
|
|
}
|
|
};
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
return new PageQueryResponse<MatDetailHistoryInfo>()
|
|
{
|
|
Code = 300,
|
|
Message = $"操作失败:{ex.Message}",
|
|
};
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 删除-假删除
|
|
/// </summary>
|
|
/// <param name="request"></param>
|
|
/// <returns></returns>
|
|
[Route("deleteMatDetailHistoryInfo")]
|
|
[HttpPost(Name = "deleteMatDetailHistoryInfo")]
|
|
public async Task<ResponseBase> deleteMatDetailHistoryInfo(DeleteInfosRequest request)
|
|
{
|
|
|
|
try
|
|
{
|
|
//先查询出具体的Id
|
|
var matDetailHistoryInfos = await DbHelp.db.Queryable<MatDetailHistoryInfo>()
|
|
.Where(t => request.needDeleteIds.Contains(t.Id))
|
|
.ToListAsync();
|
|
//执行删除
|
|
var deleteRows = await DbHelp.db.Deleteable(matDetailHistoryInfos).ExecuteCommandAsync();
|
|
return new ResponseCommon<Object>
|
|
{
|
|
Code = 200,
|
|
Message = $"已删除{deleteRows}条数据!",
|
|
Data = null
|
|
};
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
var response = new ResponseCommon<Object>
|
|
{
|
|
Code = 300,
|
|
Message = $"操作失败:{ex.Message}",
|
|
Data = null
|
|
};
|
|
return response;
|
|
}
|
|
|
|
}
|
|
|
|
[Route("exportMatDetailHistoryInfo")]
|
|
[HttpPost(Name = "exportMatDetailHistoryInfo")]
|
|
public async Task<IActionResult> exportMatDetailHistoryInfo(GetMatDetailHistoryInfosRequest request)
|
|
{
|
|
var recordsQueryable = DbHelp.db.Queryable<MatDetailHistoryInfo>()
|
|
.WhereIF(request.RecordType != null, t => t.RecordType == request.RecordType)
|
|
.WhereIF(request.FunctionType != null, t => t.FunctionType == request.FunctionType)
|
|
.WhereIF(!string.IsNullOrEmpty(request.ShelfCode), t => t.ShelfCode.Contains(request.ShelfCode))
|
|
.WhereIF(!string.IsNullOrEmpty(request.MatCode), t => t.MatCode.Contains(request.MatCode))
|
|
.WhereIF(!string.IsNullOrEmpty(request.MatName), t => t.MatName.Contains(request.MatName))
|
|
;
|
|
|
|
var totalCount = await recordsQueryable.CountAsync();
|
|
var result = await recordsQueryable
|
|
.OrderByDescending(t => t.ModifyTime)
|
|
//.Skip((request.PageNumber - 1) * request.PageSize).Take(request.PageSize)
|
|
.ToListAsync();
|
|
//生成序号
|
|
for (int i = 0; i < result.Count; i++)
|
|
{
|
|
result[i].RowNumber = (request.PageNumber - 1) * request.PageSize + i + 1;
|
|
}
|
|
var columns = new[]
|
|
{
|
|
new ExportableColumn("序号","RowNumber"),
|
|
|
|
new ExportableColumn("货架编码","ShelfCode"),
|
|
new ExportableColumn("记录类型","RecordType"),
|
|
new ExportableColumn("操作功能","FunctionType"),
|
|
|
|
new ExportableColumn("货架编码","MatCode"),
|
|
new ExportableColumn("物料名称","MatName"),
|
|
new ExportableColumn("物料批次","MatBatch"),
|
|
new ExportableColumn("物料规格","MatSpec"),
|
|
|
|
new ExportableColumn("更新前数量", "BeforeQty"),
|
|
new ExportableColumn("更新后数量", "AfterQty"),
|
|
|
|
|
|
new ExportableColumn("更新人", "ModifyUser"),
|
|
new ExportableColumn("更新时间", "ModifyTime"),
|
|
};
|
|
if (result == null)
|
|
{
|
|
return NotFound();
|
|
}
|
|
else
|
|
return ExportExcelHelper.Export("导出数据", columns, result);
|
|
}
|
|
|
|
}
|
|
}
|