Blame view

web/WebMvc/Areas/configure/Controllers/SnProgressController.cs 1.96 KB
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 Hh.Mes.POJO.Response;
using Hh.Mes.POJO.ViewModel.Configure;
using Hh.Mes.Service;
using Hh.Mes.Service.SystemAuth;
using Microsoft.AspNetCore.Mvc;
using Newtonsoft.Json;
using System.Collections.Generic;
using System.Linq;
using WebMvc.Aop;
using static Hh.Mes.Service.BulletinBoardService;

namespace WebMvc.Areas.configure.Controllers
{
    /// <summary>
    /// WMS SN信息
    /// </summary>
    [Area("configure")]
    public class SnProgressController : BaseController
    {
        private readonly BulletinBoardService _service;

        public SnProgressController(IAuth authUtil, BulletinBoardService service) : base(authUtil)
        {
            _service = service;
        }

        [Authenticate]
        [ServiceFilter(typeof(OperLogFilter))]
        public IActionResult Index()
        {
            return View(new SnProgressVM());
        }

        [HttpPost]
        [Authenticate]
        [ServiceFilter(typeof(OperLogFilter))]
        public IActionResult Index(string snCode)
        {
            if (string.IsNullOrWhiteSpace(snCode))
            {
                return View(new SnProgressVM());
            }

            var result1 = _service.GetSnInfoBySn(snCode);
            ResponseNew response;
            if (result1 is string)
            {
                response = JsonConvert.DeserializeObject<ResponseNew>(result1);
            }
            else
            {
                response = result1 as ResponseNew;
            }
            var vm = new SnProgressVM
            {
                Status = response.status,
                Message = response.message,
                SNCode = snCode,
            };

            if (response.data is List<DataStatusReport> reports)
            {
                vm.Items = reports.Select(x => new SnProgressItem
                {
                    Status = x.HasData,
                    Title = x.QueryName,
                }).ToList();
            }
            return View(vm);
        }
    }
}