wangxinhui
8 小时以前 526b70eecc5dac5aea91bfffbe0b98118f25827f
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using System.Reflection;
using WIDESEA_Core;
using WIDESEA_DTO.Stock;
using WIDESEA_IStockService;
 
namespace WIDESEA_WMSServer.Controllers.Stock
{
    /// <summary>
    /// 库存视图
    /// </summary>
    [Route("api/ProStockView")]
    [Authorize, ApiController]
    public class ProStockViewController : Controller
    {
        private readonly IProStockViewService _stockViewService;
        public ProStockViewController(IProStockViewService stockViewService)
        {
            _stockViewService = stockViewService;
        }
 
        [HttpPost, Route("GetPageData")]
        public PageGridData<ProStockViewDTO> GetPageData([FromBody] PageDataOptions options)
        {
            return _stockViewService.GetPageData(options);
        }
 
        [HttpPost, Route("GetDetailPage")]
        public object GetDetailPage([FromBody] PageDataOptions pageData)
        {
            return _stockViewService.GetDetailPage(pageData);
        }
 
        /// <summary>
        /// 导出数据
        /// </summary>
        /// <param name="loadData"></param>
        /// <returns></returns>
        [HttpPost, Route("Export")]
        public virtual ActionResult Export([FromBody] PageDataOptions loadData)
        {
            WebResponseContent result = InvokeService("Export", new object[] { loadData }) as WebResponseContent;
            if (result.Status)
                return File(
                       System.IO.File.ReadAllBytes(result.Data.ToString()),
                       System.Net.Mime.MediaTypeNames.Application.Octet,
                       Path.GetFileName(result.Data.ToString())
                   );
            return Json(result);
        }
        /// <summary>
        /// 获取平库库存
        /// </summary>
        [HttpPost, Route("GetProPKSelectStocks"),AllowAnonymous]
        public List<ProStockViewDTO> GetProPKSelectStocks(int orderId)
        {
            return _stockViewService.GetProPKSelectStocks(orderId);
        }
        private object InvokeService(string methodName, object[] parameters)
        {
            Type t = _stockViewService.GetType();
            List<Type> types = new List<Type>();
            foreach (var param in parameters)
            {
                types.Add(param.GetType());
            }
            MethodInfo method = t.GetMethod(methodName, types.ToArray());
            return method.Invoke(_stockViewService, parameters);
        }
    }
}