ComplianceServer/oldcode/Core.Web/Controllers/StockReportController.cs

606 lines
21 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

using Core.Web.App_Start;
using Core.Web.WebHelper;
using CRM.Core.BLL;
using CRM.Core.Common.Layui;
using CRM.Core.Common.WebHelper;
using CRM.Core.DTO;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Linq;
using System.Net.Sockets;
using System.Runtime.InteropServices;
using System.Security.Cryptography;
using System.Text;
using System.Web.Helpers;
using System.Web.Mvc;
using System.Web.Script.Serialization;
using System.Web.Services.Description;
using WX.CRM.Common;
using WX.CRM.Common.StockHelper;
namespace Core.Web.Controllers
{
public class StockReportController : BaseController
{
private StockPools_BL _stockBL = new StockPools_BL();
private WX.CRM.Common.ValidationErrors errors = new WX.CRM.Common.ValidationErrors();
public StockReportController()
{
}
[AuthorizeRedirect(RightsConfig.CONST_股票报备, ToolBarConfig.CONST_NotButton, true)]
[HttpGet]
public ActionResult Index()
{
ViewBag.rightCode = RightsConfig.CONST_股票报备;
var select = BuildInduNameList();
ViewBag.InduList = select.InduInfo;
return View();
}
[HttpPost]
[AuthorizeRedirect(RightsConfig.CONST_股票报备, ToolBarConfig.CONST_NotButton, false)]
public JsonResult Index(Laypage pager, SearchStockPoolPageDto dto)
{
try
{
var list = _stockBL.GetList(ref pager, dto);
foreach (var item in list)
{
item.StatusName = item.Status == null ? "禁用" : item.Status == 0 ? "正常" : "禁用";
item.UpdateTime = !string.IsNullOrWhiteSpace(item.UpdateTime) ? Convert.ToDateTime(item.UpdateTime).ToString("yyyy-MM-dd HH:mm:ss") : item.UpdateTime;
}
var data = new LayuiData<ZxdStockPoolDto>()
{
msg = "数据加载成功!",
count = pager.count,
code = 0,
data = list
};
return Json(data, JsonRequestBehavior.AllowGet);
}
catch (Exception ex)
{
LogHelper.Error(ex.ToString());
return Json(new { }, JsonRequestBehavior.AllowGet);
}
}
public JsonResult Page(Laypage pager, SearchStockPoolNewPageDto dto)
{
var url = ConfigurationManager.AppSettings["StockPoolUrlNew"];
var authorization = ConfigurationManager.AppSettings["StockPoolAuthorization"];
dto.PageNum = pager.page;
dto.PageSize = pager.limit;
var json = JsonConvert.SerializeObject(dto, Formatting.Indented, new JsonSerializerSettings
{
NullValueHandling = NullValueHandling.Ignore,
ContractResolver = new Newtonsoft.Json.Serialization.CamelCasePropertyNamesContractResolver()
});
var result = Utility.PostAjaxData($"{url}/stockpool/api/stock/report/page", json, authorization, true);
var data = JsonHelper.FromJson<StockPoolResult<StockPoolResultRow>>(result);
pager.count = data.Total;
return Json(data, JsonRequestBehavior.AllowGet);
}
public JsonResult LogPage(Laypage pager, int id)
{
var url = ConfigurationManager.AppSettings["StockPoolUrlNew"];
var authorization = ConfigurationManager.AppSettings["StockPoolAuthorization"];
var request = $"pageNum={pager.page}&pageSize={pager.limit}&stockReportId={id}&businessType=0";
var result = Utility.GetData($"{url}/stockpool/api/stock/report/listOperateLog", request, authorization, true);
var data = JsonHelper.FromJson<StockPoolResult<StockPoolLog>>(result);
pager.count = data.Total;
return Json(data, JsonRequestBehavior.AllowGet);
}
[AuthorizeRedirect(RightsConfig.CONST_股票报备, ToolBarConfig.CONST_NotButton, true)]
[HttpGet]
public ActionResult ReportList()
{
ViewBag.rightCode = RightsConfig.CONST_股票报备;
var select = BuildInduNameList();
ViewBag.InduList = select.InduInfo;
ViewBag.ProductLineName = select.ProductLineName;
ViewBag.OperatorName = select.OperatorName;
ViewBag.ColumnName = select.ColumnName;
return View();
}
[HttpPost]
[AuthorizeRedirect(RightsConfig.CONST_股票报备, ToolBarConfig.CONST_NotButton, false)]
public JsonResult ReportList(Laypage pager, SearchStockAuditPageDto dto)
{
try
{
var list = _stockBL.GetReportList(ref pager, dto);
var data = new LayuiData<ZxdStockAuditDto>()
{
msg = "数据加载成功!",
count = pager.count,
code = 0,
data = list
};
return Json(data, JsonRequestBehavior.AllowGet);
}
catch (Exception ex)
{
LogHelper.Error(ex.ToString());
return Json(new { }, JsonRequestBehavior.AllowGet);
}
}
[HttpGet]
[AuthorizeRedirect(RightsConfig.CONST_股票报备, ToolBarConfig.CONST_NotButton, true)]
public ActionResult Log(int id)
{
ViewBag.Id = id;
return View();
}
[HttpGet]
[AuthorizeRedirect(RightsConfig.CONST_股票报备, ToolBarConfig.CONST_NotButton, true)]
public ActionResult Check(int id, int check)
{
var model = new StockAuditOrRejectDto
{
Id = id,
Check = check
};
return View(model);
}
[HttpPost]
public ActionResult Check(int id, string remark, int check)
{
var ret = new retMsg { result = true, retcode = 200 };
var secret = ConfigurationManager.AppSettings["StockPoolSecret"];
var url = ConfigurationManager.AppSettings["StockPoolUrlNew"];
var authorization = ConfigurationManager.AppSettings["StockPoolAuthorization"];
try
{
StockAuditOrRejectDto dto = new StockAuditOrRejectDto
{
Id = id,
Reason = remark,
Check = check,
CheckUserName = UserName,
};
BuildPostBody(dto, secret);
var json = JsonConvert.SerializeObject(dto, Formatting.Indented, new JsonSerializerSettings
{
NullValueHandling = NullValueHandling.Ignore,
ContractResolver = new Newtonsoft.Json.Serialization.CamelCasePropertyNamesContractResolver()
});
var result = Utility.PostAjaxData($"{url}/stockpool/api/stock/report/audit", json, authorization, true);
var data = JsonHelper.FromJson<StockPoolResult<StockPoolResultRow>>(result);
//_stockBL.CheckStockPools(model);
}
catch (Exception ex)
{
ret = new retMsg { result = false, retcode = 200, retmsg = ex.Message };
}
return Json(ret, JsonRequestBehavior.AllowGet);
}
/// <summary>
/// 行业下拉框
/// </summary>
/// <returns></returns>
public DropSelectList BuildInduNameList()
{
try
{
var appId = ConfigurationManager.AppSettings["StockPoolAppId"];
var secret = ConfigurationManager.AppSettings["StockPoolSecret"];
ApiSignHelper apiSignHelper = new ApiSignHelper(appId, secret);
var url = ConfigurationManager.AppSettings["StockPoolUrl"] + "/api/Stock/GetDropSelectList";
Dictionary<string, object> param = new Dictionary<string, object>();
var ret = apiSignHelper.GetApi<string>(url, param);
DropSelectList dropSelectList = JsonConvert.DeserializeObject<DropSelectList>(ret.Data);
return dropSelectList;
}
catch (Exception ex)
{
LogHelper.Error($"获取下拉框失败{ex.Message}");
return new DropSelectList();
}
}
private void BuildPostBody(StockAuditOrRejectDto dto, string key)
{
var nowTime = DateTime.Now;
var timestamp = GetTimeStampByTime(nowTime);
dto.Timestamp = timestamp;
dto.CheckTime = nowTime.ToString("yyyy-MM-dd HH:mm:ss");
StringBuilder beforeSignStr = new StringBuilder();
beforeSignStr.Append(dto.Id)
.Append(dto.Check)
.Append(dto.CheckUserName)
.Append(dto.CheckTime)
.Append(dto.Timestamp);
dto.Sign = HmacMD5(beforeSignStr.ToString(), key);
}
public long GetTimeStampByTime(DateTime nowTime)
{
TimeSpan ts = nowTime - new DateTime(1970, 1, 1, 8, 0, 0, 0);
return long.Parse(Convert.ToInt64(ts.TotalSeconds).ToString());
}
public string HmacMD5(string ciphertext, string accessKey)
{
Encoding utf = new UTF8Encoding();
HMACMD5 hmac = new HMACMD5(utf.GetBytes(accessKey));
byte[] hashValue = hmac.ComputeHash(utf.GetBytes(ciphertext));
return Convert.ToBase64String(hashValue);
}
public class SearchStockPoolNewPageDto
{
public string BeginTime { get; set; }
/// <summary>
/// 审核状态10专业审核中20合规审核中99审核通过-1审核驳回
/// </summary>
public int? Checked { get; set; }
public string CreateBy { get; set; }
public string CreateTime { get; set; }
public string EndTime { get; set; }
/// <summary>
/// 在池状态0-在池1-出池
/// </summary>
public int? InPoolStatus { get; set; }
/// <summary>
/// 所属行业
/// </summary>
public string InduName { get; set; }
/// <summary>
/// 分页,页数
/// </summary>
public int PageNum { get; set; }
/// <summary>
/// 分页,每页条数
/// </summary>
public int PageSize { get; set; }
/// <summary>
/// 产品线 1001:东方股票1002六合1004懂牛
/// </summary>
public string PlatformId { get; set; }
/// <summary>
/// 产品线 1001:东方股票1002六合1004懂牛
/// </summary>
public List<string> PlatformIds
{
get
{
return !string.IsNullOrEmpty(PlatformId) ? PlatformId.Split(',').ToList() : null;
}
}
public string Remark { get; set; }
/// <summary>
/// 1人工 2自动
/// </summary>
public int? ReportType { get; set; }
/// <summary>
/// 股票池 股票代码
/// </summary>
public string StockCode { get; set; }
/// <summary>
/// 股票名称
/// </summary>
public string StockName { get; set; }
/// <summary>
/// 栏目名
/// </summary>
public string SubjectName { get; set; }
}
public class StockPoolResult<T>
{
public int Total { get; set; }
public List<T> Rows { get; set; }
public int Code { get; set; }
public string Msg { get; set; }
}
public class StockPoolResultRow
{
/// <summary>
/// 助理Id
/// </summary>
public string AssistantId { get; set; }
/// <summary>
/// 审核时间
/// </summary>
public string CheckTime { get; set; }
/// <summary>
/// 审核人
/// </summary>
public string CheckUserId { get; set; }
/// <summary>
/// 审核人
/// </summary>
public string CheckUserName { get; set; }
/// <summary>
/// 审核流程状态10专业审核中20合规审核中99审核通过-1审核驳回
/// </summary>
public int Checked { get; set; }
/// <summary>
/// 审核流程状态
/// </summary>
public string CheckedStr
{
get
{
return Checked == 10 ? "专业审核中" :
Checked == 20 ? "合规审核中" :
Checked == 99 ? "审核通过" :
Checked == -1 ? "审核驳回" : "--";
}
}
/// <summary>
/// 内容Id
/// </summary>
public int? ContentId { get; set; }
/// <summary>
/// 内容类型0默认1图文2观点3视频
/// </summary>
public int ContentType { get; set; }
/// <summary>
/// 内容类型
/// </summary>
public string ContentTypeStr
{
get
{
return ContentType == 0 ? "默认" :
ContentType == 1 ? "图文" :
ContentType == 2 ? "观点" :
ContentType == 3 ? "视频" : "--";
}
}
/// <summary>
/// 报备时间
/// </summary>
public string CreateTime { get; set; }
/// <summary>
/// 关注价格上限
/// </summary>
public decimal? FocusPriceCeiling { get; set; }
/// <summary>
/// 关注价格下限
/// </summary>
public decimal? FocusPriceFloor { get; set; }
/// <summary>
///
/// </summary>
public int Id { get; set; }
/// <summary>
/// 在池状态0-在池1-出池
/// </summary>
public int? InPoolStatus { get; set; }
/// <summary>
/// 在池状态
/// </summary>
public string InPoolStatusStr
{
get
{
return InPoolStatus == null ? "--"
: InPoolStatus == 0 ? "在池"
: InPoolStatus == 1 ? "出池" : "--";
}
}
/// <summary>
/// 所属行业
/// </summary>
public string InduName { get; set; }
/// <summary>
/// 产品线 1001:东方股票1002六合1004懂牛
/// </summary>
public int? PlatformId { get; set; }
/// <summary>
/// 产品线
/// </summary>
public string Platform => PlatformId == 1001 ? "东方股票" :
PlatformId == 1002 ? "六合" :
PlatformId == 1004 ? "懂牛" :
PlatformId == 1005 ? "聚牛" :
PlatformId == 2001 ? "短线王" : "--";
/// <summary>
/// 执业证书编号
/// </summary>
public string PracticeNo { get; set; }
/// <summary>
/// 推荐原因
/// </summary>
public string RecommendReason { get; set; }
/// <summary>
/// 推荐仓位下限
/// </summary>
public decimal? RecommendStockFloor { get; set; }
/// <summary>
/// 推荐仓位
/// </summary>
public decimal? RecommendStockPosition { get; set; }
/// <summary>
/// 股票报备价格
/// </summary>
public decimal? ReportStockPrice { get; set; }
/// <summary>
/// 1人工 2自动
/// </summary>
public int ReportType { get; set; }
/// <summary>
/// 入池方式
/// </summary>
public string ReportTypeStr
{
get
{
return ReportType == 1 ? "人工报备" :
ReportType == 2 ? "自动报备" : "--";
}
}
/// <summary>
/// 报备人
/// </summary>
public string ReportUserId { get; set; }
/// <summary>
/// 报备人
/// </summary>
public string ReportUserName { get; set; }
/// <summary>
/// 股票池 股票代码
/// </summary>
public string StockCode { get; set; }
/// <summary>
/// 股票名称
/// </summary>
public string StockName { get; set; }
/// <summary>
/// 栏目Id
/// </summary>
public int? SubjectId { get; set; }
/// <summary>
/// 栏目名
/// </summary>
public string SubjectName { get; set; }
/// <summary>
/// 上传图片
/// </summary>
public string UploadImage { get; set; }
/// <summary>
/// 预警价格上限
/// </summary>
public decimal? WarningPriceCeiling { get; set; }
/// <summary>
/// 预警价格下限
/// </summary>
public decimal? WarningPriceFloor { get; set; }
}
public class StockPoolLog
{
public int Id { get; set; }
/// <summary>
/// 操作事项类型
/// </summary>
public int OperateType { get; set; }
/// <summary>
/// 操作事项类型
/// </summary>
public string OperateTypeStr
{
get
{
return OperateType == 0 ? "提交申请" :
OperateType == 1 ? "专业审核" :
OperateType == 2 ? "合规审核" :
OperateType == 3 ? "入池" :
OperateType == 4 ? "出池" : "--";
}
}
/// <summary>
/// 股票报备id
/// </summary>
public int StockReportId { get; set; }
/// <summary>
/// 触发类型0-人工1-自动
/// </summary>
public int TriggerType { get; set; }
/// <summary>
/// 触发类型
/// </summary>
public string TriggerTypeStr
{
get
{
return TriggerType == 0 ? "人工" :
TriggerType == 1 ? "自动" : "--";
}
}
/// <summary>
/// 操作结果
/// </summary>
public string OperateResult { get; set; }
/// <summary>
/// 操作说明
/// </summary>
public string OperateRemark { get; set; }
/// <summary>
/// 操作人姓名
/// </summary>
public string CreateName { get; set; }
/// <summary>
/// 操作人id
/// </summary>
public int? CreateBy { get; set; }
/// <summary>
/// 操作时间
/// </summary>
public string CreateTime { get; set; }
}
public class StockAuditOrRejectDto
{
/// <summary>
/// 报备id
/// </summary>
public int? Id { get; set; }
/// <summary>
/// 审核状态 -1审核拒绝99审核通过
/// </summary>
public int Check { get; set; }
/// <summary>
/// 审核人
/// </summary>
public string CheckUserName { get; set; }
/// <summary>
/// 审核理由
/// </summary>
public string Reason { get; set; }
/// <summary>
/// 审核时间
/// </summary>
public string CheckTime { get; set; }
/// <summary>
/// HmacMD5签名
/// </summary>
public string Sign { get; set; }
/// <summary>
/// 毫秒时间戳
/// </summary>
public long Timestamp { get; set; }
}
}
}