using JiepeiWMS.Common;
using JiepeiWMS.Common.Config;
using JiepeiWMS.Common.Enums;
using JiepeiWMS.Common.Helper;
using JiepeiWMS.Common.HttpContextUser;
using JiepeiWMS.Extends;
using JiepeiWMS.IRepository.UnitOfWork;
using JiepeiWMS.IServices;
using JiepeiWMS.Model;
using JiepeiWMS.Model.Models;
using JiepeiWMS.Model.ViewModels;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Logging;
using SqlSugar;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Threading.Tasks;
namespace JiepeiWMS.Api.Controllers
{
[Route("api/[controller]/[action]")]
[ApiController]
[Authorize(Permissions.Name)]
public class WMSaleInfoController : ControllerBase
{
///
/// 领料申请
///
private readonly IWMSaleInfoServices _wMSaleInfoServices;
private readonly IWMSaleDetailServices _wMSaleDetailServices;
private readonly IWMProductListServices _wMProductListServices;
private readonly IWMWareHouseServices _wMWareHouseServices;
private readonly IWMProductInfoServices _wMProductInfoServices;
private readonly IWMStockLogServices _wMStockLogServices;
private readonly IWMCheckInfoServices _wMCheckInfoServices;
private readonly IWMSaleInfoLogServices _wMSaleInfoLogServices;
private readonly IDepartmentServices _departmentServices;
private readonly ISysUserInfoServices _sysUserInfoServices;
private readonly IUser _user;
private readonly ILogger _logger;
private readonly IUnitOfWork _unitOfWork;
private readonly IRoleServices _roleServices;
private readonly IUserRoleServices _userRoleServices;
public WMSaleInfoController(
IWMSaleInfoServices WMSaleInfoServices,
IWMSaleDetailServices WMSaleDetailServices,
IWMProductListServices WMProductListServices,
IWMWareHouseServices WMWareHouseServices,
IWMProductInfoServices WMProductInfoServices,
IWMStockLogServices WMStockLogServices,
IWMCheckInfoServices WMCheckInfoServices,
IWMSaleInfoLogServices WMSaleInfoLogServices,
IDepartmentServices DepartmentServices,
ISysUserInfoServices SysUserInfoServices,
IUser user,
ILogger logger,
IUnitOfWork unitOfWork,
IRoleServices RoleServices,
IUserRoleServices UserRoleServices)
{
_wMSaleInfoServices = WMSaleInfoServices;
_wMSaleDetailServices = WMSaleDetailServices;
_wMProductListServices = WMProductListServices;
_wMWareHouseServices = WMWareHouseServices;
_wMProductInfoServices = WMProductInfoServices;
_wMStockLogServices = WMStockLogServices;
_wMCheckInfoServices = WMCheckInfoServices;
_wMSaleInfoLogServices = WMSaleInfoLogServices;
_departmentServices = DepartmentServices;
_sysUserInfoServices = SysUserInfoServices;
_user = user;
_logger = logger;
_unitOfWork = unitOfWork;
_roleServices = RoleServices;
_userRoleServices = UserRoleServices;
}
///
/// 查询列表
///
/// 关键字
/// 仓库筛选
/// 类型筛选
/// 开始时间筛选
/// 结束时间筛选
/// 审核状态筛选
/// 页数
/// 条数
///
[HttpGet]
public async Task>> Get(string key = "", string options = "", string typeoptions = "", DateTime? startdate = null, DateTime? enddate = null, string statusoptions = "", int page = 1, int intPageSize = 20)
{
if (string.IsNullOrWhiteSpace(key))
key = "";
if (string.IsNullOrWhiteSpace(options))
options = "";
if (string.IsNullOrWhiteSpace(typeoptions))
typeoptions = "";
if (string.IsNullOrWhiteSpace(statusoptions))
statusoptions = "";
var PageList = await _wMSaleInfoServices.GetWMSaleInfoPage(page, intPageSize, key, options, typeoptions, startdate, enddate, statusoptions);
//测试接口
//var dsdfss = await _wMSaleInfoServices.QueryById(1073);
//var sdd = await _wMSaleDetailServices.Query(x => x.SaleId == dsdfss.Id);
//foreach (var item in sdd)
//{
// item.GiveNum = 2;
//}
//var s = await _wMSaleInfoServices.BeginMaterialOutInNC(dsdfss, sdd);
return new MessageModel>()
{
msg = "获取成功",
success = PageList.dataCount >= 0,
response = PageList
};
}
///
/// 获取参数
///
///
[HttpGet]
[AllowAnonymous]
public async Task> GetParams()
{
var dicStatus = typeof(EnumWMSaleStatus)._GetValueDescriptionDicFromEnumType().Select(t => new { Key = t.Key.GetHashCode(), t.Value });
return new MessageModel