Blame view

sys/Hh.Mes.Service/ApiService/UpstreamDown/UpstreamService.cs 2.31 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
using Hh.Mes.Common.config;
using Hh.Mes.Common.Json;
using Hh.Mes.POJO.Entity;
using Hh.Mes.POJO.EnumEntitys;
using Hh.Mes.POJO.Response;
using Hh.Mes.Service.Repository;
using NPOI.POIFS.FileSystem;
using System;
using System.Collections.Generic;
using System.Text;

namespace Hh.Mes.Service.ApiService
{
    public partial class UpstreamService : RepositorySqlSugar<sys_user>
    {
        /// <summary>
        /// 删除=0
        /// </summary>
        public int DeleteFlag = (int)EnumDeleteOrAdd.删除;

        /// <summary>
        /// 新增或更新1
        /// </summary>
        public int AddOrUpdateFlag = (int)EnumDeleteOrAdd.新增或更新;

        /// <summary>
        /// 获取token true 请求成功 T2是对应的token值,false失败
        /// </summary>
        /// <returns></returns>
        public Tuple<bool, string> GetMomToken()
        {
            var url = GetDictionaryDictValue("UrlMomToken", "GetUrl");
            var jsonData = new
            {
                username = ConfigRead.GetInstance.GetAppsetConnection().AppCustomExtend2, //"esb@P_SYS_COMPANY_393bb2f058ac4a8ba59510a1a228d383",
                password = ConfigRead.GetInstance.GetAppsetConnection().AppCustomExtend3,//"efb03b68f7a0c2a331fc61a491c4b2d7",
                verify = "0"
            };

            var httpResult = HttpMan(url, jsonData, EnumLog.Mom获取Token.ToString());
            if (!httpResult.Status) return new Tuple<bool, string>(false, httpResult.Message);
            var json = DynamicJson.Parse(httpResult.Result);
            return new Tuple<bool, string>(true, json.data.access_token);
        }

        /// <summary>
        /// type is I or U value
        /// </summary>
        /// <param name="type"></param>
        /// <param name="response"></param>
        /// <returns></returns>
        public ResponseUpstream<string>  typeValidation(string type, ResponseUpstream<string> response)
        {
54
55
56
57
58
            if (string.IsNullOrEmpty(type))
            {
                type = "I";
                return response;
            }
59
60
61
62
63
64
65
66
67
            if ("IUD".IndexOf(type)==-1)
            {
                response.ResponseError($"【上位系统】【type 只能是I或者U或者D标识】,请核实确认!");
                return response;
            }
            return response;    
        }
    }
}