using JiepeiWMS.Common;
using JiepeiWMS.Common.Helper;
using JiepeiWMS.Common.HttpContextUser;
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.Http;
using Microsoft.AspNetCore.Mvc;
using SqlSugar;
using System;
using System.Collections.Generic;
using System.Data;
using System.IO;
using System.Linq;
using System.Security.Claims;
using System.Threading.Tasks;
namespace JiepeiWMS.Api.Controllers
{
[Route("api/[controller]/[action]")]
[ApiController]
[Authorize(Permissions.Name)]
public class WMProductListController : ControllerBase
{
///
/// 商品
///
private readonly IWMProductListServices _wMProductListServices;
private readonly IWMProductSpecServices _wMProductSpecServices;
private readonly IWMProductUnitServices _wMProductUnitServices;
private readonly IWMProductClassServices _wMProductClassServices;
private readonly IWMProductInfoServices _wMProductInfoServices;
private readonly IWMPurchaseQuoteDetailServices _wMPurchaseQuoteDetailServices;
private readonly IWMSaleDetailServices _wMSaleDetailServices;
private readonly ISysUserInfoServices _sysUserInfoServices;
private readonly IWMWareHouseServices _wMWareHouseServices;
private readonly ISysOrgServices _BllSysOrg;
private readonly IUser _user;
private readonly IUnitOfWork _unitOfWork;
private readonly IUserRoleServices _userRole;
public WMProductListController(IWMProductListServices WMProductListServices, IWMProductSpecServices WMProductSpecServices, IWMProductUnitServices WMProductUnitServices, IWMProductClassServices WMProductClassServices, IWMProductInfoServices WMProductInfoServices, IWMPurchaseQuoteDetailServices WMPurchaseQuoteDetailServices, IWMSaleDetailServices WMSaleDetailServices, ISysUserInfoServices SysUserInfoServices, IWMWareHouseServices WMWareHouseServices, ISysOrgServices BllSysOrg, IUser user, IUnitOfWork unitOfWork, IUserRoleServices userRole)
{
_wMProductListServices = WMProductListServices;
_wMProductSpecServices = WMProductSpecServices;
_wMProductUnitServices = WMProductUnitServices;
_wMProductClassServices = WMProductClassServices;
_wMProductInfoServices = WMProductInfoServices;
_wMPurchaseQuoteDetailServices = WMPurchaseQuoteDetailServices;
_wMSaleDetailServices = WMSaleDetailServices;
_sysUserInfoServices = SysUserInfoServices;
_wMWareHouseServices = WMWareHouseServices;
_BllSysOrg = BllSysOrg;
_user = user;
_unitOfWork = unitOfWork;
_userRole = userRole;
}
///
/// 查询列表
///
/// 关键字
/// 分类筛选
/// 开始时间筛选
/// 结束时间筛选
/// 仓库Id
/// 页数
/// 条数
///
[HttpGet]
public async Task>> Index(string key = "", string options = "", DateTime? startdate = null, DateTime? enddate = null, int wareHouseId = 0, int page = 1, int intPageSize = 20)
{
if (string.IsNullOrWhiteSpace(key))
key = "";
if (string.IsNullOrWhiteSpace(options))
options = "";
var PageList = await _wMProductListServices.GetWMProductListPage(page, intPageSize, key, options, startdate, enddate, wareHouseId);
return new MessageModel>()
{
msg = "获取成功",
success = PageList.dataCount >= 0,
response = PageList
};
}
///
/// 获取列表
///
///
[AllowAnonymous]
[HttpGet]
public async Task> Get(int id = 0, int wareHouseId = 0)
{
decimal quantity = 0;
var listList = await _wMProductListServices.Query(x => x.IsUse == true);
//listList = listList.Where(x => x.SysOrgId == _user.SysOrgId).ToList();
if (wareHouseId > 0)
{
var ProductInfoModel = await _wMProductInfoServices.GetModel(x => x.ProductListId == id && x.WareHouseId == wareHouseId);
if (ProductInfoModel == null)
quantity = 0;
else
quantity = ProductInfoModel.Quantity ?? 0;
}
return new MessageModel