z8018
3 天以前 d8dc91f9c1fece5711e38edd1b1274cb9e579015
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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
using Autofac.Core;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.DependencyModel;
using Newtonsoft.Json;
using System.Reflection;
using WIDESEA_Core.BaseController;
using WIDESEA_Core.Helper;
using WIDESEA_ISystemServices;
using WIDESEA_Model.Models;
using System.IO;
using WIDESEA_DTO.System;
using System.ComponentModel;
using System.Collections.Generic;
using OfficeOpenXml.FormulaParsing.Excel.Functions.DateTime;
using WIDESEA_Core.Caches;
using WIDESEA_Core.Enums;
 
namespace WIDESEA_WCSServer.Controllers.System
{
    [Route("api/Sys_Dictionary")]
    [ApiController]
    public class Sys_DictionaryController : ApiBaseController<ISys_DictionaryService, Sys_Dictionary>
    {
        private readonly IHttpContextAccessor _httpContextAccessor;
        private readonly ICacheService _cacheService;
 
        public Sys_DictionaryController(ISys_DictionaryService service, IHttpContextAccessor httpContextAccessor, ICacheService cacheService) : base(service)
        {
            _httpContextAccessor = httpContextAccessor;
            _cacheService = cacheService;
        }
 
        [HttpPost, Route("GetVueDictionary"), AllowAnonymous]
        public IActionResult GetVueDictionary([FromBody] string[] dicNos)
        {
            List<VueDictionaryDTO> vueDictionaryDTOs = Service.GetVueDictionary(dicNos);
            try
            {
                List<string> cacheDicNos = new List<string>();
                foreach (string n in dicNos)
                {
                    if (vueDictionaryDTOs.Where(x => x.DicNo == n).Count() > 0)
                    {
                        continue;
                    }
                    string str = _cacheService.Get(n);
                    if (!string.IsNullOrEmpty(str))
                    {
                        VueDictionaryDTO? vueDictionary = JsonConvert.DeserializeObject<VueDictionaryDTO>(str);
 
                        if (vueDictionary != null)
                        {
                            vueDictionaryDTOs.Add(vueDictionary);
                            cacheDicNos.Add(n);
                        }
                    }
                }
                List<string> dicList = dicNos.ToList();
                if (dicNos.Where(x => !cacheDicNos.Contains(x)).Count() > 0)
                {
                    string str = AppSettings.Configuration["dics"];
                    if (!string.IsNullOrEmpty(str))
                    {
                        List<string> cusDics = new List<string>();
 
                        List<string> dics = str.Split(",").ToList();
 
                        foreach (var item in dics)
                        {
                            dicList.Remove(item);
                            cusDics.Add(item);
                        }
 
                        foreach (var item in cusDics)
                        {
                            if (vueDictionaryDTOs.Where(x => x.DicNo == item).Count() > 0)
                            {
                                continue;
                            }
                            VueDictionaryDTO vueDictionaryDTO = GetVueDictionary(item.Trim());
                            if (vueDictionaryDTO != null)
                            {
                                vueDictionaryDTOs.Add(vueDictionaryDTO);
                                if (!_cacheService.Exists(item) && vueDictionaryDTO.SaveCache)
                                {
                                    _cacheService.Add(item, vueDictionaryDTO.Serialize());
                                }
                            }
                        }
                    }
                }
            }
            catch
            {
 
            }
            return Json(vueDictionaryDTOs);
        }
 
        private VueDictionaryDTO? GetVueDictionary(string key)
        {
            VueDictionaryDTO? result = null;
            try
            {
                switch (key)
                {
                    
                }
                return result;
            }
            catch (Exception ex)
            {
                return null;
            }
        }
    }
}