Blame view

sys/Hh.Mes.Service/ApiService/UpstreamDown/UpstreamService.cs 2.17 KB
1
2
3
4
using Hh.Mes.Common.config;
using Hh.Mes.Common.Json;
using Hh.Mes.POJO.Entity;
using Hh.Mes.POJO.EnumEntitys;
赖素文 authored
5
using Hh.Mes.POJO.Response;
6
using Hh.Mes.Service.Repository;
赖素文 authored
7
using NPOI.POIFS.FileSystem;
8
9
10
11
12
13
14
15
16
using System;
using System.Collections.Generic;
using System.Text;

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

        /// <summary>
22
        /// 新增或更新1
23
        /// </summary>
24
        public int AddOrUpdateFlag = (int)EnumDeleteOrAdd.新增或更新;
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44

        /// <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);
        }
赖素文 authored
45
赖素文 authored
46
47
48
49
50
51
        /// <summary>
        /// type is I or U value
        /// </summary>
        /// <param name="type"></param>
        /// <param name="response"></param>
        /// <returns></returns>
赖素文 authored
52
53
        public ResponseUpstream<string>  typeValidation(string type, ResponseUpstream<string> response)
        {
54
            if ("IU".IndexOf(type)==-1)
赖素文 authored
55
56
57
58
59
60
            {
                response.ResponseError($"【上位系统】【type 只能是I 或者U标识】,请核实确认!");
                return response;
            }
            return response;    
        }
61
62
    }
}