示例#1
0
        public static Response Process_Company_TradeIntelliTip(Request request)
        {
            var pre_mb = request.Preprocess2Maybe(true, false);

            if (pre_mb.HasValue)
            {
                return(pre_mb.Value);
            }
            var head = new Response_Head();

            var res_mb = request
                         .GetBody <Req_Intelli_Tip>().ToMaybe()
                         .Where(t => !string.IsNullOrWhiteSpace(t.input) && t.input.Trim().Length > 1)
                         .Do(p => DataAccess.SearchHistoryExt_Insert(new Req_Info_Query()
            {
                u_id = p.u_id, u_name = p.u_name, query_str = p.input
            }.Type_Set(30), p.u_id.ToInt() > 0))
                         .Select <AnalysesResult>(t => CompanyTrade_Proxy.AnalysisAllTrade(t.input, t.pg_size < 1 ? 5 : t.pg_size))
                         .Select <Trade_Intelli_Tip>(ar => ar.AnalysisResult2TradeTip());

            var body = res_mb.HasValue ? res_mb.Value.ToJson() : Trade_Intelli_Tip.Default().ToJson();

            var response = Util.Normal_Resp_Create(head.ToJson(), body, EncryptType.AES | EncryptType.Gzip);

            return(response);
        }
示例#2
0
        public static Trade_Intelli_Tip AnalysisResult2TradeTip(this AnalysesResult ar)
        {
            var tip = new Trade_Intelli_Tip();

            if (ar.exhibitonTagList != null)
            {
                tip.exh_names = ar.exhibitonTagList.Select(pair => pair.Key).ToList();
            }
            if (ar.tradeList != null)
            {
                foreach (var s in ar.tradeList)
                {
                    var segs = s.Key.Split('\t');
                    if (!tip.gb_trades.ContainsKey(segs[0]))
                    {
                        tip.gb_trades[segs[0]] = segs[1];
                    }
                }
            }
            if (ar.productList != null)
            {
                foreach (var s in ar.productList)
                {
                    var segs = s.Key.Split('\t');
                    if (!tip.pro_trades.ContainsKey(segs[0]))
                    {
                        tip.pro_trades[segs[0]] = segs[1];
                    }
                }
            }
            if (ar.forwardTradeList != null)
            {
                tip.fwd_names = ar.forwardTradeList.Select(pair => pair.Key).ToList();
            }

            if (tip.exh_names.Count == 0)
            {
                tip.exh_names.Add("暂无数据");
                tip.exh_names.Add("暂无数据");
            }
            if (tip.pro_trades.Count == 0)
            {
                tip.pro_trades.Add("01", "暂无数据");
                tip.pro_trades.Add("01", "暂无数据");
            }
            if (tip.gb_trades.Count == 0)
            {
                tip.gb_trades.Add("01", "暂无数据");
                tip.gb_trades.Add("01", "暂无数据");
            }
            if (tip.fwd_names.Count == 0)
            {
                tip.fwd_names.Add("暂无数据");
                tip.fwd_names.Add("暂无数据");
            }

            return(tip);
        }