119 lines
3.7 KiB
C#
119 lines
3.7 KiB
C#
using YLErp.Modules.ScenarioModule;
|
|
|
|
namespace YLErp.Web.Controllers
|
|
{
|
|
/// <summary>
|
|
/// 情景分析
|
|
/// </summary>
|
|
public class ScenarioAnalysisController : BaseController
|
|
{
|
|
#region----情景分析配置----
|
|
|
|
public ActionResult ScenarioList()
|
|
{
|
|
return View();
|
|
}
|
|
|
|
[HttpPost]
|
|
public JsonResult AjaxScenarioQuery(ScenarioReq req)
|
|
{
|
|
//只能看到自己的情景分析配置
|
|
req.UserId = UserId;
|
|
var sList = new ScenarioConfigService(CurUser).SearchList(req);
|
|
return Json(sList);
|
|
}
|
|
|
|
public ActionResult ScenarioView(string enid)
|
|
{
|
|
var intid = DataProtectHelper.DecryptInt(enid);
|
|
var data = new ScenarioConfigService(CurUser).GetData(intid);
|
|
if (data == null)
|
|
{
|
|
return ShowError("找不到数据");
|
|
}
|
|
return View(data);
|
|
}
|
|
|
|
public ActionResult ScenarioEdit(string enid)
|
|
{
|
|
ScenarioConfigV2 data;
|
|
|
|
if (string.IsNullOrEmpty(enid) || enid == "0")
|
|
{
|
|
data = new ScenarioConfigV2
|
|
{
|
|
UserId = UserId,
|
|
UserName = UserName,
|
|
xType = "标的价格",
|
|
yType = "波动率"
|
|
};
|
|
}
|
|
else
|
|
{
|
|
var intid = DataProtectHelper.DecryptInt(enid);
|
|
data = yldb.ScenarioConfig.Find(intid);
|
|
if (data == null)
|
|
{
|
|
return Content("未找到数据,id:" + intid);
|
|
}
|
|
}
|
|
|
|
return View(data);
|
|
}
|
|
|
|
[HttpPost]
|
|
public JsonResult AjaxScenarioEdit(ScenarioConfigV2 req)
|
|
{
|
|
req.UserId = UserId;
|
|
req.UserName = UserName;
|
|
var dbmodel = new ScenarioConfigService(CurUser).SaveData(req);
|
|
return JsonSuccess("更新成功", dbmodel);
|
|
}
|
|
|
|
[HttpPost]
|
|
public JsonResult RemoveScenario(string enid)
|
|
{
|
|
new ScenarioConfigService(CurUser).RemoveData(enid);
|
|
|
|
return JsonSuccess("删除成功");
|
|
}
|
|
|
|
#endregion
|
|
|
|
[MyAuthorize("风险控制-情景分析")]
|
|
public ActionResult TradeScenario()
|
|
{
|
|
return View();
|
|
}
|
|
|
|
public JsonResult TradeScenarioQuery(TradeScenarioSearchModel req)
|
|
{
|
|
req.AssetIds = AssetUnitModel.IntersectAssetUnits(req.AssetGroupIds, req.AssetIds).ToList();
|
|
req.UserAssets = CurUser.GetAssetUnitIds();
|
|
req.UserClients = CurUser.GetClientIdsByCurUser(CurUser.交易管理_查看所有交易);
|
|
req.CurUserTradeIds = CurUser.GetTradeIdsByCurUser();
|
|
var resultList = new TradeScenarioQueryService(CurUser).GetDatas(req, out _);
|
|
return Json(resultList);
|
|
}
|
|
|
|
public ActionResult ScenarioCalc(TradeScenarioSearchModel req)
|
|
{
|
|
var model = new ScenarioModel { SearchModel = req };
|
|
//当前用户情景分析配置
|
|
model.ScenConfigs = yldb.ScenarioConfig.Where(s => s.UserId == CurUser.UserId || s.ConfigName == "对冲风险压力测试").ToArray();
|
|
|
|
return View(model);
|
|
}
|
|
|
|
public JsonResult AjaxScenarioCalc(ScenarioRequest req)
|
|
{
|
|
|
|
req.SearchModel.UserAssets = CurUser.GetAssetUnitIds();
|
|
req.SearchModel.UserClients = CurUser.GetClientIdsByCurUser(CurUser.交易管理_查看所有交易);
|
|
var result = new ScenarioCalcService(CurUser).Calculate(req);
|
|
|
|
return Json(result);
|
|
}
|
|
}
|
|
}
|