今日内容
1. <%-- builed by manage.aspx.cmt [ver:2014.19.01] at 2014-12-01 16:19:20 --%> <%@ Page Language="C#" AutoEventWireup="True" CodeBehind="BasLimitConfigManage.aspx.cs" Inherits="HraWeb.BasLimitConfigManage" %> <%@ Register Assembly="Trirand.Web" TagPrefix="asp" Namespace="Trirand.Web.UI.WebControls" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head id="Head1" runat="server"> <title></title> <link href="../assets/css/vendor/BootstrapSelect/bootstrap-select.css" rel="stylesheet" /> <script src="../assets/js/vendor/BootstrapSelect/bootstrap-select.js"></script> <script src="../assets/js/vendor/BootstrapSelect/defaults-zh_CN.js"></script> <link href="../assets/css/vendor/bootstrap/bootstrap.min.css" rel="stylesheet" /> <link href="../assets/css/vendor/jsMind/jsmind.css" rel="stylesheet" /> <style type="text/css"> jmnode.selected { background-color: #428bca; color: #fff; border: solid 0px #CCCCCC; box-shadow: 2px 2px 8px #000; } jmnode { border: solid 1px #CCCCCC; } </style> </head> <body> <div id="jsmind_container" style="height: 800px"></div> <div class="modal fade" id="setModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel"> <div class="modal-dialog" role="document" style="width: 630px"> <div class="modal-content"> <div class="modal-header"> <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button> <h4 class="modal-title" id="myModalLabel">添加限额</h4> </div> <div class="modal-body"> <form class="form-horizontal"> <div class="form-group"> <label for="txt_EffectiveDate_" class="col-md-2 control-label">有效期开始</label> <div class="col-md-4"> <input type="text" class="form-control" id="txt_EffectiveDate_" placeholder="xxxx/xx/xx"> </div> <label for="txt_TerminateDate_" class="col-md-2 control-label">有效期结束</label> <div class="col-md-4"> <input type="text" class="form-control" id="txt_TerminateDate_" placeholder="xxxx/xx/xx"> </div> </div> <div class="form-group"> <label for="txt_LowerLimitValue_" class="col-md-2 control-label">下限值</label> <div class="col-md-4"> <input type="text" class="form-control" id="txt_LowerLimitValue_" placeholder="数值"> </div> <label for="txt_YellowLimitValue_" class="col-md-2 control-label">黄线值</label> <div class="col-md-4"> <input type="text" class="form-control" id="txt_YellowLimitValue_" placeholder="数值"> </div> </div> <div class="form-group"> <label for="txt_RedLimitValue_" class="col-md-2 control-label">红线值</label> <div class="col-md-4"> <input type="text" class="form-control" id="txt_RedLimitValue_" placeholder="数值"> </div> <label for="txt_UpperLimitValue_" class="col-md-2 control-label">黄线值</label> <div class="col-md-4"> <input type="text" class="form-control" id="txt_UpperLimitValue_" placeholder="数值"> </div> </div> <div class="form-group"> <label for="txt_LimitControlFreq_" class="col-md-2 control-label">检查频次</label> <div class="col-md-4"> <input type="text" class="form-control" id="txt_LimitControlFreq_" placeholder="请选择"> </div> <label for="txt_LimitBundleName_" class="col-md-2 control-label">限额名称</label> <div class="col-md-4"> <input type="text" class="form-control" id="txt_LimitBundleName_" placeholder="限额名称"> </div> </div> <div class="form-group"> <label for="txt_EndUser_" class="col-md-2 control-label">使用机构</label> <div class="col-md-4"> <input type="text" class="form-control" id="txt_EndUser_" placeholder="请选择"> </div> <label for="txt_LimitUnit_" class="col-md-2 control-label">单位</label> <div class="col-md-4"> <input type="text" class="form-control" id="txt_LimitUnit_" placeholder="限额名称"> </div> </div> <div class="form-group"> <label for="currency" class="col-md-2 control-label">币种</label> <div class="col-md-4"> <input type="text" class="form-control" id="currency" placeholder="请选择"> </div> </div> </form> </div> <div class="modal-footer"> <button type="button" class="btn btn-primary" data-dismiss="modal">确定</button> </div> </div> </div> </div> <!-- myModal --> <div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel"> <div class="modal-dialog" role="document"> <div class="modal-content"> <div class="modal-header"> <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button> <h4 class="modal-title" id="myModalLabel">限额详情</h4> </div> <div class="modal-body table-responsive"> <table class="table table-hover table-striped"> <tr> <td>限额内容 </td> <td>黄线值 </td> <td>红线值 </td> <td>上限值 </td> <td>额度使用量 </td> </tr> <tr> <td>单笔交易限额 </td> <td>10000 </td> <td>50000 </td> <td>100000 </td> <td>-- </td> </tr> <tr> <td>单笔交易限额 </td> <td>10000 </td> <td>50000 </td> <td>100000 </td> <td>-- </td> </tr> </table> <div class="text-center"> <ul class="pagination"> <li><a href="#">«</a></li> <li><a href="#">1</a></li> <li><a href="#">2</a></li> <li><a href="#">3</a></li> <li><a href="#">4</a></li> <li><a href="#">5</a></li> <li><a href="#">»</a></li> </ul> </div> </div> <div class="modal-footer"> <button type="button" class="btn btn-primary" data-dismiss="modal">确定</button> </div> </div> </div> </div> <!--newModal--> <div class="modal fade " id="newModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel"> <div class="modal-dialog" role="document"> <div class="modal-content" style="width: 400px"> <div class="modal-header"> <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button> <h4 class="modal-title">添加限额</h4> </div> <div class="modal-body " style="min-height: 310px; max-height: 600px; overflow: auto"> <form class="form-inline"> <div class="form-group" style="display: block"> <label for="limitObectType" class="col-md-5 control-label" style="line-height: 34px">限额对象类型</label> <div class=" col-md-7"> <select id="limitObectType" class="selectpicker show-tick form-control"> </select> </div> </div> <div class="form-group col-md-offset-1" style="display: block"> <div id="collapseOne" class="panel-collapse collapse in" role="tabpanel"> <div class="panel-b-body" id="left" style="padding: 0; overflow: auto; width: 100%"> <ul id="tt1" style="" class="easyui-tree"></ul> </div> </div> </div> </form> <div class="panel-b panel-b-archon main-graph"> <div class="col-xs-6 col-sm-4"> <div class="form-group"> </div> </div> </div> </div> <div class="modal-footer"> <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button> <button type="button" id="btn_new" class="btn btn-primary">保存</button> </div> </div> </div> </div> <!--editModal--> <div class="modal fade" id="editModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel"> <div class="modal-dialog" role="document"> <div class="modal-content"> <div class="modal-header"> <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button> <h4 class="modal-title">编辑限额</h4> </div> <div class="modal-body"> <form class="form-inline"> <div class="form-group"> <label for="exampleInputEmail3">限额对象</label> <input type="email" class="form-control" id="d2" placeholder="Email"> </div> </form> </div> <div class="modal-footer"> <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button> <button type="button" id="btn_edit" class="btn btn-primary">保存</button> </div> </div> </div> </div> <!--delModal--> <div class="modal fade bs-example-modal-sm" id="delModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel"> <div class="modal-dialog modal-sm" role="document"> <div class="modal-content"> <div class="modal-header"> <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button> <h4 class="modal-title">删除</h4> </div> <div class="modal-body"> 确定要删除此节点吗? </div> <div class="modal-footer"> <button type="button" class="btn btn-default" data-dismiss="modal">取消</button> <button type="button" id="btn_del" class="btn btn-danger">删除</button> </div> </div> </div> </div> <script src="../assets/js/vendor/jsMind/jsmind.js"></script> <script src="../assets/js/vendor/bootstrapMenu/BootstrapMenu.js"></script> <script src="../assets/js/vendor/bootstrap/bootstrap.min.js"></script> <script type="text/javascript"> function filterDrp(obj, nodeType, nodeId, callback) { var url = '/Bas/BasLimitConfigManage.aspx?_method=entity&type=' + nodeType; $.post(url, function (data) { obj.find("option").remove(); obj.append(data); obj.selectpicker('refresh'); LoadTree1(obj.val(), nodeId, nodeType); }); if (callback) { callback(); } } //树节点的id var nodeId = ''; //树节点的name var nodeName = ''; var selectedNodeId = ''; var selectedNodeType = ''; function LoadTree1(type, nodeId, nodeType) { var nodeId1 = jm.get_selected_node().id; var alertType = $("#limitObectType option:selected").val(); var noalertType = jm.get_selected_node().data.type; //alert("nodeid=" + nodeId1); //alert("nt=" + noalertType); //alert("alertype=" + alertType); var postJson = [noalertType]; //var postJson = ["Limit_Object_BusiStruc", "Limit_Object_BasProductGroup", "Limit_Object_BasCurrency"]; postJson = JSON.stringify(postJson); DataGrid.WaitMessage(); $("#tt1").tree( { url: '/BAS/LimiManagetTree/TraderLimitTreeJson.ashx?_method=GetTradeLimitBusiStrucTree&_id=0&a=' + Math.random() + "&postJson=" + postJson + "&nodeId=" + nodeId1 + "&alertnodeType=" + alertType, method: 'get', animate: true, formatter: function (node) { var s = node.text; if (node.children) { s += " <span style='color:blue'>(" + node.children.length + ")</span>"; } return s; }, onBeforeExpand: function (node, param) { var url = "/BAS/BasLimitBusiStrucManage.aspx?_method=loadChild&child=" + node.id; $('#tt1').tree('options').url = url; }, onClick: function (node) { nodeId = node.id; nodeName = node.text; // $("#jq").jqGrid("setGridParam", { postData: { txt_Name_LK_: $("#txt_Name_LK_").val(), "BaslimitBusinessStruPId": node.id} }).trigger("reloadGrid"); }, onLoadSuccess: function (node, data) { DataGrid.RemoveWaitMessage(); if (data.error!=undefined &&data.error == "-999") { $.messager.alert("操作提示", data.message, "error"); return false; } $('#newModal').modal('show'); } } ); // off_id = $("#tt").selectNode.txt_OfficeId_; } var jm; $(function () { //UTIL.SetDropdownListForBootStrapByParentCode($("#limitObectType"), "Rsk_Limit_Object_Type"); $("#limitObectType").change(function () { var type = $(this).find("option:checked").attr("value"); LoadTree1(type, selectedNodeId, selectedNodeType); }); jm = load_jsmind(); //---------------------------------------------------------------------------------------------------------------- var menu = new BootstrapMenu('jmnode', { actions: [{ name: '添加子节点', onClick: function () { selectedNodeType = jm.get_selected_node().data.type; selectedNodeId = jm.get_selected_node().id; filterDrp($("#limitObectType"), selectedNodeType, selectedNodeId, null); } }, { name: '编辑此节点', onClick: function () { $('#editModal').modal('show'); } }, { name: '删除此节点', onClick: function () { $('#delModal').modal('show'); } }, { name: '添加限额', onClick: function () { $('#setModal').modal('show'); } }, { name: '查看限额设置', onClick: function () { $('#myModal').modal('show'); } }] }); $("#btn_del").click(function () { var nodeSelected = jm.get_selected_node(); $('#delModal').modal('hide'); jm.enable_edit(); jm.remove_node(nodeSelected); jm.disable_edit(); }); $("#btn_edit").click(function () { var nodeSelected = jm.get_selected_node(); $('#editModal').modal('hide'); jm.enable_edit(); jm.begin_edit(nodeSelected); $('.jsmind-editor').val($("#drp1 option:selected").text()); jm.end_edit(); jm.disable_edit(); }); $("#btn_new").click(function () { URL = ''; $('#newModal').modal('hide'); $.post(url, function (data) { if (data == '1') { var nodeSelected = jm.get_selected_node(); alert($("#limitObectType option:selected").val()); jm.enable_edit(); jm.add_node(nodeSelected, nodeId, nodeName, { type: $("#limitObectType").val() }); jm.end_edit(); jm.disable_edit(); } else { } }); }); }); function load_jsmind() { DataGrid.WaitMessage(""); //alert(21); var postJson = ["Limit_Object_BusiStruc", "Limit_Object_BasProductGroup", "Limit_Object_RskFactor", "Limit_Object_BasCurrency", "Limit_Object_BasCounterparty", "Limit_Object_BasPortfolio", "Credit_Rate"]; postJson = JSON.stringify(postJson); var datas = []; var url = '/BAS/LimiManagetTree/TraderLimitTreeJson.ashx?_method=GetTradeLimitBusiStrucTree' + '&postJson=' + postJson + "&isConvert=true"; $.post(url, function (data) { DataGrid.RemoveWaitMessage(); datas = JSON.parse(data); var mind = { "meta": { "name": "demo", "author": "hizzgdev@163.com", "version": "0.2" }, "format": "node_array", "data": datas }; var options = { // options 将在下一章中详细介绍 container: 'jsmind_container', // [必选] 容器的ID editable: false, // [可选] 是否启用编辑 theme: 'default', // [可选] 主题 mode: 'side' }; var jm1 = new jsMind(options); jm1.show(mind); jm = jm1; }); ; } </script> </body> </html> 2.aspx.cs using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using HraWeb.Common; using WebApp.Common; using Contract.Domain; using System.Collections; namespace HraWeb { public partial class BasLimitConfigManage : JQEntityManage<Contract.Domain.BasLimitConfig> { protected override void Page_Load(object sender, EventArgs e) { if (Request["_method"] == "entity") { string type = Request["type"]; Response.Write(Psvc.TypeFilter(type)); Response.End(); } if (Request["_method"] == "addNode") { string nodeType = Request["nodeType"]; string nodeId = Request["nodeId"]; string selectedNodeId = Request["selectedNodeId"]; string selectedNodeType = Request["selectedNodeType"]; IList<RskLimitObject> list = Psvc.AddNode(nodeId, nodeType, selectedNodeId, selectedNodeType); Response.Write(""); Response.End(); } base.Page_Load(sender, e); } /// <summary> /// 设置查询条件或者语句 /// </summary> /// <returns></returns> protected override Framework.QueryInfo SetInfo() { info = base.SetInfo(); return info; } /// <summary> /// 初始化页面控件 /// </summary> protected override void InitPage() { base.InitPage(); // BindDrop(drp_Unit, "SPSW", true); } private Contract.IService.IBasLimitConfigService psvc; /// <summary> /// 初始化 /// </summary> Contract.IService.IBasLimitConfigService Psvc { get { if (psvc == null) { psvc = ctx.GetObject("BasLimitConfigService") as Contract.IService.IBasLimitConfigService; } return psvc; } } } public class jsMindEntity { public string id { get; set; } public bool isroot { get; set; } public string topic { get; set; } public string type { get; set; } public string parentid { get; set; } } } 3.traderlimitjson.ashx.cs using System; using System.Collections; using System.Collections.Generic; using System.Linq; using System.Reflection; using System.Web; using Contract.Domain; using DevExpress.Data.PLinq.Helpers; using Framework; using WebApp.Common; using Contract.Domain.Enum.EnumList; using BASBLL.BasLimitLayer.BasLimitBusiStrucLayer; using HRAModel.Sys.Enum; using Holworth.Utility; using Contract.Domain.Enum.EnumCommon; namespace HraWeb.Common { /// <summary> /// 业务结构选择类型 /// </summary> public enum BusiStrucEnum { BasLimitBusiStruc = -1, BasEnterprice = 0, BasLegalEntity = 1, BasBusinessUnit = 2, BasTradeDesk = 3, BasPortfolio = 4, User = 5 } /// <summary> /// EntityJsonList 的摘要说明 /// </summary> public class TraderLimitTreeJson : BasePage, IHttpHandler, System.Web.SessionState.IRequiresSessionState { /// <summary> /// 根据条件过滤busistruc /// </summary> /// <param name="where"></param> /// <returns></returns> private IList<BasLimitBusiStruc> loadBusiStruc(string where) { QueryInfo info = new QueryInfo(); if (string.IsNullOrEmpty(where)) { if (!string.IsNullOrEmpty(where)) { info.Where.Add("where1", where); } } info.QueryObject = "BasLimitBusiStruc"; var busiList = Dao.FindList<BasLimitBusiStruc>(info); return busiList; } private EasyUiTree loadBusiTree(string nodeId, EasyUiTree node, string where) { var busiList = loadBusiStruc(where); var trees = BusiList2Tree(busiList, null, null); foreach (var item in trees) { node.children.Add(item); } return node; } private IList<EasyUiTree> BusiList2Tree(IList<BasLimitBusiStruc> busiList, BasLimitBusiStruc bb, EasyUiTree ee, bool isfirst = true) { EasyUiTree e1 = null; IList<EasyUiTree> nodes = new List<EasyUiTree>(); IList<BasLimitBusiStruc> tmpList = null; if (bb.Children.Count > 0) { tmpList = bb.Children; } else { tmpList = busiList; } foreach (var b1 in tmpList) { e1 = new EasyUiTree(); e1.id = b1.Id; e1.text = b1.Name; e1.attributes = new { RefTableName = "BasLimitBusiStruc", DataValueField = "Id", TextValueField = "Name", LimitObjectType = (int)Limit_Object.Limit_Object_BusiStruc }; if (b1.Children.Count > 0) { if (e1.children == null) { e1.children = new List<EasyUiTree>(); } BusiList2Tree(busiList, b1, e1, false); } if (isfirst) //node.children.Add(e1); nodes.Add(e1); else { ee.children.Add(e1); } } return nodes; } private void LoadSelNodeTypeEasyuiTree(Limit_Object limitObject, EasyUiTree node, string nodeId, string where) { EasyUiTree e; var currNode = new EasyUiTree(); currNode.children = new List<EasyUiTree>(); switch (limitObject) { case Limit_Object.Limit_Object_BusiStruc: #region 业务结构 BusiStrucEnum strucEnum = 0; var busiInfo = new QueryInfo("BasLimitBusiStruc"); busiInfo.AddParam("Id", nodeId); var busi = Dao.FindOne(busiInfo) as BasLimitBusiStruc; if (busi == null) { throw new Exception("节点不存在,或者节点已经被移除!"); } if (busi.NodeSource == "User") { //Utility.JSUtil.ExecuteScript(string.Format(" $.messager.alert('操作提示', '{0}', '{1}')", "用户级没有子节点", "warning")); //return; var obj = new { error = -999, message = "用户级没有子节点" }; Context.Response.Write(Newtonsoft.Json.JsonConvert.SerializeObject(obj)); Context.Response.End(); } currNode.attributes = new { RefTableName = "BasLimitBusiStruc", DataValueField = "Id", TextValueField = "Name", LimitObjectType = (int)Limit_Object.Limit_Object_BusiStruc }; //currNode.id = nodeId; //currNode.text = busi.Name; if (busi.ProLevel == 1) { strucEnum = BusiStrucEnum.BasLegalEntity; } if (busi.ProLevel == 2) { strucEnum = BusiStrucEnum.BasBusinessUnit; } if (busi.ProLevel == 3) { strucEnum = BusiStrucEnum.BasTradeDesk; } if (busi.ProLevel == 4) { strucEnum = BusiStrucEnum.BasPortfolio; } if (busi.ProLevel == 5) { strucEnum = BusiStrucEnum.User; } switch (strucEnum) { case BusiStrucEnum.BasLimitBusiStruc: loadBusiTree(nodeId, node, where); break; case BusiStrucEnum.BasEnterprice: break; case BusiStrucEnum.BasLegalEntity: currNode.id = ((int)BusiStrucEnum.BasLegalEntity).ToString(); currNode.text = "法人实体"; var entitylist = Dao.FindList<BasLegalEntity>(new QueryInfo("BasLegalEntity")); foreach (var item in entitylist) { e = new EasyUiTree(); e.id = item.Id; e.text = item.LegalEntityName; currNode.children.Add(e); } break; case BusiStrucEnum.BasBusinessUnit: currNode.id = ((int)BusiStrucEnum.BasBusinessUnit).ToString(); currNode.text = "业务单位"; var unitList = Dao.FindList<BasBusinessUnit>(new QueryInfo("BasBusinessUnit")); foreach (var item in unitList) { e = new EasyUiTree(); e.attributes = new { RefTableName = "BasLimitBusiStruc", DataValueField = "Id", TextValueField = "Name", LimitObjectType = (int)Limit_Object.Limit_Object_BusiStruc, Ori = new { RefTableName = "BasBusinessUnit", DataValueField = "Id", TextValueField = "BusinessUnitName", } }; e.id = item.Id; e.text = item.BusinessUnitName; currNode.children.Add(e); } break; case BusiStrucEnum.BasTradeDesk: currNode.id = ((int)BusiStrucEnum.BasTradeDesk).ToString(); currNode.text = "交易前台"; var traderDeskList = Dao.FindList<BasTradeDesk>(new QueryInfo("BasTradeDesk")); foreach (var item in traderDeskList) { e = new EasyUiTree(); e.attributes = new { RefTableName = "BasLimitBusiStruc", DataValueField = "Id", TextValueField = "Name", LimitObjectType = (int)Limit_Object.Limit_Object_BusiStruc, Ori = new { RefTableName = "BasTradeDesk", DataValueField = "Id", TextValueField = "TradeDeskName", } }; e.id = item.Id; e.text = item.TradeDeskName; currNode.children.Add(e); } break; case BusiStrucEnum.BasPortfolio: currNode.id = ((int)BusiStrucEnum.BasPortfolio).ToString(); currNode.text = "投资组合"; var portfolioList = Dao.FindList<BasPortfolio>(new QueryInfo("BasPortfolio")); foreach (var item in portfolioList) { e = new EasyUiTree(); e.attributes = new { RefTableName = "BasLimitBusiStruc", DataValueField = "Id", TextValueField = "Name", LimitObjectType = (int)Limit_Object.Limit_Object_BusiStruc, Ori = new { RefTableName = "BasPortfolio", DataValueField = "Id", TextValueField = "PortfolioName", } }; e.id = item.Id; e.text = item.PortfolioName; currNode.children.Add(e); } break; case BusiStrucEnum.User: currNode.id = ((int)BusiStrucEnum.User).ToString(); currNode.text = "交易员"; var userList = Dao.FindList<User>(new QueryInfo("User")); foreach (var item in userList) { e = new EasyUiTree(); e.attributes = new { RefTableName = "BasLimitBusiStruc", DataValueField = "Id", TextValueField = "Name", LimitObjectType = (int)Limit_Object.Limit_Object_BusiStruc, Ori = new { RefTableName = "User", DataValueField = "Id", TextValueField = "Name", } }; e.id = item.Id; e.text = item.Name; currNode.children.Add(e); } break; default: break; } #endregion break; //case Limit_Object.Limit_Object_BasProductGroup: // #region 产品群 // #endregion // break; case Limit_Object.Limit_Object_RskFactor: #region 风险因子 var rskfactorInfo = new QueryInfo("RskFactor"); rskfactorInfo.AddParam("Id", nodeId); var currfactor = Dao.FindOne(rskfactorInfo) as RskFactor; if (currfactor != null) { var obj = new { error = -999, message = "不能添加子节点,已经属于叶子节点" }; Context.Response.Write(Newtonsoft.Json.JsonConvert.SerializeObject(obj)); Context.Response.End(); } currNode.id = ((int)EnumComon.RskFactor).ToString(); currNode.text = "风险因子"; var factorList = Dao.FindList<RskFactor>(new QueryInfo("RskFactor")); foreach (var item in factorList) { e = new EasyUiTree(); e.attributes = new { RefTableName = "RskFactor", DataValueField = "Id", TextValueField = "RiskFactorName", LimitObjectType = (int)Limit_Object.Limit_Object_RskFactor, }; e.id = item.Id; e.text = item.RiskFactorName; currNode.children.Add(e); } #endregion break; case Limit_Object.Limit_Object_BasCurrency: #region 币种 var currenyInfo = new QueryInfo("BasCurrency"); currenyInfo.AddParam("Id", nodeId); var curreny = Dao.FindOne(currenyInfo) as BasCurrency; if (curreny != null) { var obj = new { error = -999, message = "不能添加子节点,已经属于叶子节点" }; Context.Response.Write(Newtonsoft.Json.JsonConvert.SerializeObject(obj)); Context.Response.End(); } currNode.id = ((int)EnumComon.BasCurrency).ToString(); currNode.text = "币种"; var currencys = Dao.FindList<BasCurrency>(new QueryInfo("BasCurrency")); foreach (var item in currencys) { e = new EasyUiTree(); e.attributes = new { RefTableName = "BasCurrency", DataValueField = "Id", TextValueField = "CurrencyName", LimitObjectType = (int)Limit_Object.Limit_Object_BasCurrency, }; e.id = item.Id; e.text = item.CurrencyName; currNode.children.Add(e); } #endregion break; case Limit_Object.Limit_Object_BasCounterparty: #region 交易对手 var partyInfo = new QueryInfo("BasCounterparty"); partyInfo.AddParam("Id", nodeId); var party = Dao.FindOne(partyInfo) as BasCounterparty; if (party != null) { var obj = new { error = -999, message = "不能添加子节点,已经属于叶子节点" }; Context.Response.Write(Newtonsoft.Json.JsonConvert.SerializeObject(obj)); Context.Response.End(); } currNode.id = ((int)EnumComon.BasCounterparty).ToString(); currNode.text = "交易对手"; var partys = Dao.FindList<BasCounterparty>(new QueryInfo("BasCounterparty")); foreach (var item in partys) { e = new EasyUiTree(); e.attributes = new { RefTableName = "BasCounterparty", DataValueField = "Id", TextValueField = "CounterpartyName", LimitObjectType = (int)Limit_Object.Limit_Object_BasCounterparty, }; e.id = item.Id; e.text = item.CounterpartyName; currNode.children.Add(e); } #endregion break; case Limit_Object.Limit_Object_BasPortfolio: #region 投资组合 var portfolioInfo = new QueryInfo("BasPortfolio"); portfolioInfo.AddParam("Id", nodeId); var portfolio = Dao.FindOne(portfolioInfo) as BasPortfolio; if (portfolio != null) { var obj = new { error = -999, message = "不能添加子节点,已经属于叶子节点" }; Context.Response.Write(Newtonsoft.Json.JsonConvert.SerializeObject(obj)); Context.Response.End(); } currNode.id = ((int)EnumComon.BasPortfolio).ToString(); currNode.text = "投资组合"; var portfolios = Dao.FindList<BasPortfolio>(new QueryInfo("BasPortfolio")); foreach (var item in portfolios) { e = new EasyUiTree(); e.attributes = new { RefTableName = "BasPortfolio", DataValueField = "Id", TextValueField = "PortfolioName", LimitObjectType = (int)Limit_Object.Limit_Object_BasPortfolio, }; e.id = item.Id; e.text = item.PortfolioName; currNode.children.Add(e); } #endregion break; case Limit_Object.Credit_Rate: #region 信用等级 #endregion break; default: break; } node.children.Add(currNode); } private IBasLimitBusiStrucLayerService _basLimitBusiStrucLayerService; public IBasLimitBusiStrucLayerService BasLimitBusiStrucLayerService { get { if (_basLimitBusiStrucLayerService == null) { _basLimitBusiStrucLayerService = ctx["BasLimitBusiStrucLayerService"] as IBasLimitBusiStrucLayerService; } return _basLimitBusiStrucLayerService; } } /// <summary> /// 通过限额对象,检测是否加载该指标类型 /// </summary> /// <param name="limitObject"></param> /// <returns></returns> private bool checkLimitIndexTypeisLoad(Limit_Index_Type limitIndexType, object limitObject) { bool ispass = true; if (limitObject == null || limitObject.ToString() == "") { return true; } switch (int.Parse(limitObject.ToString())) { case (int)Limit_Object.Limit_Object_BusiStruc: ispass = true; break; case (int)Limit_Object.Limit_Object_BasProductGroup: ispass = true; break; case (int)Limit_Object.Limit_Object_RskFactor: ispass = true; break; case (int)Limit_Object.Limit_Object_BasCurrency: switch (limitIndexType) { case Limit_Index_Type.Limit_Index_Type_Trade_Quantity: ispass = true; break; case Limit_Index_Type.Limit_Index_Type_Trade_Amount: ispass = true; break; case Limit_Index_Type.Limit_Index_Type_Cash_Outflow: ispass = true; break; case Limit_Index_Type.Limit_Index_Type_Value_At_Risk: ispass = true; break; case Limit_Index_Type.Limit_Index_Type_Loss: ispass = true; break; case Limit_Index_Type.Limit_Index_Type_Credit_Rating: ispass = true; break; case Limit_Index_Type.Limit_Index_Type_Credit_Line: ispass = false; break; case Limit_Index_Type.Limit_Index_Type_Tenor: ispass = true; break; case Limit_Index_Type.Limit_Index_Type_Sensitivity: ispass = true; break; case Limit_Index_Type.Limit_Index_Type_CutLoss: ispass = true; break; case Limit_Index_Type.Limit_Index_Type_TakeProfit: ispass = true; break; } break; case (int)Limit_Object.Limit_Object_BasCounterparty: ispass = true; break; case (int)Limit_Object.Limit_Object_BasPortfolio: ispass = true; break; case (int)EnumComon.BasLimitProStruc: break; case (int)EnumComon.BasLimitBusiStruc: ispass = true; break; case (int)EnumComon.BasProductGroup: ispass = true; break; case (int)EnumComon.RskFactor: ispass = true; break; case (int)EnumComon.BasCurrency: switch (limitIndexType) { case Limit_Index_Type.Limit_Index_Type_Trade_Quantity: ispass = true; break; case Limit_Index_Type.Limit_Index_Type_Trade_Amount: ispass = true; break; case Limit_Index_Type.Limit_Index_Type_Cash_Outflow: ispass = true; break; case Limit_Index_Type.Limit_Index_Type_Value_At_Risk: ispass = true; break; case Limit_Index_Type.Limit_Index_Type_Loss: ispass = true; break; case Limit_Index_Type.Limit_Index_Type_Credit_Rating: ispass = true; break; case Limit_Index_Type.Limit_Index_Type_Credit_Line: ispass = false; break; case Limit_Index_Type.Limit_Index_Type_Tenor: ispass = true; break; case Limit_Index_Type.Limit_Index_Type_Sensitivity: ispass = true; break; case Limit_Index_Type.Limit_Index_Type_CutLoss: ispass = true; break; case Limit_Index_Type.Limit_Index_Type_TakeProfit: ispass = true; break; default: break; } break; case (int)EnumComon.BasCounterparty: ispass = true; break; case (int)EnumComon.BasPortfolio: ispass = true; break; } return ispass; } public void ProcessRequest(HttpContext context) { var isConvert = context.Request["isConvert"] ?? ""; context.Response.ContentType = "text/plain"; context.Response.Cache.SetCacheability(HttpCacheability.NoCache); var alertType = context.Request["alertnodeType"] ?? ""; var nodeId = context.Request["nodeId"] ?? ""; var csEnumList = EnumUtil.GetEnumDataSource<Inst_Type>(); switch (context.Request["_method"]) { #region 交易限额 限额对象 case "GetTradeLimitBusiStrucTree": List<string> postJson = Newtonsoft.Json.JsonConvert.DeserializeObject<List<string>>(context.Request["postJson"]); #region 业务结构 EasyUiTree node = new EasyUiTree(); node.text = EnumComon.BasLimitBusiStruc.GetEnumDefaultName().ToString(); node.id = ((int)EnumComon.BasLimitBusiStruc).ToString(); node.attributes = new { LimitObjectType = (int)EnumComon.BasLimitBusiStruc }; node.children = new List<EasyUiTree>(); #endregion IList<EasyUiTree> list = new List<EasyUiTree>(); list.Add(node); EasyUiTree rskFactorTree = new EasyUiTree(); EasyUiTree basCurrencyTree = new EasyUiTree(); EasyUiTree basCounterpartyTree = new EasyUiTree(); EasyUiTree basProductGroupTree = new EasyUiTree(); EasyUiTree basPortfolioTree = new EasyUiTree(); IList<EasyUiTree> busiTreeList = TreeJSON.LoadEntityTree("ID", "BAS_LIMIT_BUSI_STRUC", "", "PARENT_ID", "NAME", ""); if (postJson.Contains(Limit_Object.Limit_Object_BusiStruc.ToString()) || postJson.Contains(((int)Limit_Object.Limit_Object_BusiStruc).ToString()) || postJson.Contains(((int)EnumComon.BasLimitBusiStruc).ToString()) ) { #region 业务结构 if (string.IsNullOrEmpty(nodeId)) { foreach (EasyUiTree e1 in busiTreeList) { e1.attributes = new { RefTableName = "BasLimitBusiStruc", DataValueField = "Id", TextValueField = "Name", LimitObjectType = (int)Limit_Object.Limit_Object_BusiStruc }; if (e1.children.Count > 0) { SetEasyUiTreeTag1(e1.children, "BasLimitBusiStruc", "Id", "Name", (int)Limit_Object.Limit_Object_BusiStruc, nodeId); } node.children.Add(e1); } } else { LoadSelNodeTypeEasyuiTree(Limit_Object.Limit_Object_BusiStruc, node, nodeId, ""); } #endregion } if (postJson.Contains(Limit_Object.Limit_Object_RskFactor.ToString()) || postJson.Contains(((int)Limit_Object.Limit_Object_RskFactor).ToString()) || postJson.Contains(((int)EnumComon.RskFactor).ToString())) { if (string.IsNullOrEmpty(nodeId)) { #region 风险因子 rskFactorTree.id = ((int)Limit_Object.Limit_Object_RskFactor).ToString(); rskFactorTree.text = Limit_Object.Limit_Object_RskFactor.GetEnumDefaultName().ToString(); rskFactorTree.attributes = new { LimitObjectType = (int)EnumComon.RskFactor }; rskFactorTree.children = new List<EasyUiTree>(); var factorTreeList = Holworth.Utility.HraUtility.ListToT<RskFactor>(Dao.FindList(new QueryInfo("RskFactor"))).ToList(); if (factorTreeList.Count > 0) { rskFactorTree.state = "closed"; } foreach (RskFactor r in factorTreeList) { EasyUiTree n = new EasyUiTree(); n.id = r.Id; n.text = r.RiskFactorName; n.attributes = new { RefTableName = "RskFactor", DataValueField = "Id", TextValueField = "RiskFactorName", LimitObjectType = (int)Limit_Object.Limit_Object_RskFactor }; rskFactorTree.children.Add(n); } node.children.Add(rskFactorTree); #endregion } else { LoadSelNodeTypeEasyuiTree(Limit_Object.Limit_Object_RskFactor, node, nodeId, ""); } } if (postJson.Contains(Limit_Object.Limit_Object_BasCurrency.ToString()) || postJson.Contains(((int)Limit_Object.Limit_Object_BasCurrency).ToString()) || postJson.Contains(((int)EnumComon.BasCurrency).ToString())) { if (string.IsNullOrEmpty(nodeId)) { #region 币种 basCurrencyTree.id = ((int)Limit_Object.Limit_Object_BasCurrency).ToString(); basCurrencyTree.text = Limit_Object.Limit_Object_BasCurrency.GetEnumDefaultName().ToString(); basCurrencyTree.attributes = new { LimitObjectType = (int)EnumComon.BasCurrency }; basCurrencyTree.children = new List<EasyUiTree>(); var basCurrencyTreeList = Holworth.Utility.HraUtility.ListToT<BasCurrency>(Dao.FindList(new QueryInfo("BasCurrency"))).ToList(); if (basCurrencyTreeList.Count > 0) { basCurrencyTree.state = "closed"; } foreach (BasCurrency r in basCurrencyTreeList) { EasyUiTree n = new EasyUiTree(); n.id = r.Id; n.text = r.CurrencyName; n.attributes = new { RefTableName = "BasCurrency", DataValueField = "Id", TextValueField = "CurrencyName", LimitObjectType = (int)Limit_Object.Limit_Object_BasCurrency }; basCurrencyTree.children.Add(n); } node.children.Add(basCurrencyTree); #endregion } else { LoadSelNodeTypeEasyuiTree(Limit_Object.Limit_Object_BasCurrency, node, nodeId, ""); } } if (postJson.Contains(Limit_Object.Limit_Object_BasCounterparty.ToString()) || postJson.Contains(((int)Limit_Object.Limit_Object_BasCounterparty).ToString()) || postJson.Contains(((int)EnumComon.BasCounterparty).ToString())) { if (string.IsNullOrEmpty(nodeId)) { #region 交易对手 basCounterpartyTree.id = ((int)Limit_Object.Limit_Object_BasCounterparty).ToString(); basCounterpartyTree.text = Limit_Object.Limit_Object_BasCounterparty.GetEnumDefaultName().ToString(); basCounterpartyTree.attributes = new { LimitObjectType = (int)EnumComon.BasCounterparty }; basCounterpartyTree.children = new List<EasyUiTree>(); var basCounterpartyTreeList = Holworth.Utility.HraUtility.ListToT<BasCounterparty>(Dao.FindList(new QueryInfo("BasCounterparty"))).ToList(); if (basCounterpartyTreeList.Count > 0) { basCounterpartyTree.state = "closed"; } foreach (BasCounterparty r in basCounterpartyTreeList) { EasyUiTree n = new EasyUiTree(); n.id = r.Id; n.text = r.CounterpartyName; n.attributes = new { RefTableName = "BasCounterparty", DataValueField = "Id", TextValueField = "CounterpartyName", LimitObjectType = (int)Limit_Object.Limit_Object_BasCounterparty }; basCounterpartyTree.children.Add(n); } node.children.Add(basCounterpartyTree); #endregion } else { LoadSelNodeTypeEasyuiTree(Limit_Object.Limit_Object_BasCounterparty, node, nodeId, ""); } } if (postJson.Contains(Limit_Object.Limit_Object_BasProductGroup.ToString()) || postJson.Contains(((int)Limit_Object.Limit_Object_BasProductGroup).ToString()) || postJson.Contains(((int)EnumComon.BasProductGroup).ToString())) { if (string.IsNullOrEmpty(nodeId)) { #region 金融产品群 basProductGroupTree.id = ((int)Limit_Object.Limit_Object_BasProductGroup).ToString(); basProductGroupTree.text = Limit_Object.Limit_Object_BasProductGroup.GetEnumDefaultName(); basProductGroupTree.attributes = new { LimitObjectType = (int)EnumComon.BasProductGroup }; basProductGroupTree.children = new List<EasyUiTree>(); IList<EasyUiTree> basProductGroupTreeList = TreeJSON.LoadEntityTree("PRODUCT_GROUP_ID", "BAS_PRODUCT_GROUP", "", "PARENT_ID", "PRODUCT_GROUP_NAME", ""); if (basProductGroupTreeList.Count > 0) { basProductGroupTree.state = "closed"; } foreach (EasyUiTree e1 in basProductGroupTreeList) { e1.attributes = new { RefTableName = "BasProductGroup", DataValueField = "Id", TextValueField = "ProductGroupName", LimitObjectType = (int)Limit_Object.Limit_Object_BasProductGroup }; if (e1.children.Count > 0) { SetEasyUiTreeTag1(e1.children, "BasProductGroup", "Id", "ProductGroupName", (int)Limit_Object.Limit_Object_BasProductGroup); } basProductGroupTree.children.Add(e1); } node.children.Add(basProductGroupTree); #endregion } else { LoadSelNodeTypeEasyuiTree(Limit_Object.Limit_Object_BasProductGroup, node, nodeId, ""); } } if (postJson.Contains(Limit_Object.Limit_Object_BasPortfolio.ToString()) || postJson.Contains(((int)Limit_Object.Limit_Object_BasPortfolio).ToString()) || postJson.Contains(((int)EnumComon.BasPortfolio).ToString())) { if (string.IsNullOrEmpty(nodeId)) { #region 投资组合 basPortfolioTree.id = ((int)Limit_Object.Limit_Object_BasPortfolio).ToString(); basPortfolioTree.text = Limit_Object.Limit_Object_BasPortfolio.GetEnumDefaultName().ToString(); basPortfolioTree.attributes = new { LimitObjectType = (int)EnumComon.BasPortfolio }; basPortfolioTree.children = new List<EasyUiTree>(); var basPortfolioTreeTreeList = Holworth.Utility.HraUtility.ListToT<BasPortfolio>(Dao.FindList(new QueryInfo("BasPortfolio"))).ToList(); if (basPortfolioTreeTreeList.Count > 0) { basPortfolioTree.state = "closed"; } foreach (BasPortfolio r in basPortfolioTreeTreeList) { EasyUiTree n = new EasyUiTree(); n.id = r.Id; n.text = r.PortfolioName; n.attributes = new { RefTableName = "BasPortfolio", DataValueField = "Id", TextValueField = "PortfolioName", LimitObjectType = (int)Limit_Object.Limit_Object_BasPortfolio }; basPortfolioTree.children.Add(n); } node.children.Add(basPortfolioTree); #endregion } else { LoadSelNodeTypeEasyuiTree(Limit_Object.Limit_Object_BasPortfolio, node, nodeId, ""); } } //list.Add(node); //list.Add(basProductGroupTree); //list.Add(rskFactorTree); //list.Add(basCurrencyTree); //list.Add(basCounterpartyTree); var json = Newtonsoft.Json.JsonConvert.SerializeObject(list); if (!string.IsNullOrEmpty(isConvert) && isConvert == "true") { IList<jsMindEntity> minds = new List<jsMindEntity>(); json = Convert2MindEntity(list, minds); } context.Response.Write(json); context.Response.End(); break; #endregion #region 交易限额 限额内容 case "GetTradeLimitProStrucTree": string reqlimitObject = context.Request["limitObject"]; Limit_Object selLimitObject = 0; if (!string.IsNullOrEmpty(reqlimitObject)) { selLimitObject = (Limit_Object)int.Parse(reqlimitObject); } int LimitType = int.Parse(context.Request["LimitType"]); QueryInfo basLimitTypeInfo = new QueryInfo(); basLimitTypeInfo.QueryObject = "BasLimitType"; var basLimitTypeList = Holworth.Utility.HraUtility.ListToT<BasLimitType>(Dao.FindList(basLimitTypeInfo)).ToList(); var typeList = basLimitTypeList.Where(x => ((int)x.LimitType) == LimitType).Select(x => x.LimitIndexType).Distinct(new LimitIndexTypeDistinct()).ToList(); IList<EasyUiTree> list1 = new List<EasyUiTree>(); EasyUiTree rootNode = new EasyUiTree(); rootNode.id = ((int)EnumComon.BasLimitProStruc).ToString(); rootNode.text = EnumComon.BasLimitProStruc.GetEnumDefaultName(); rootNode.attributes = new { LimitType = ((int)EnumComon.BasLimitProStruc).ToString() }; //加载指标 if (typeList.Count > 0) { //rootNode.state = "closed"; rootNode.children = new List<EasyUiTree>(); typeList.ForEach(t => { //判断限额指标类型是否属于选中的限额对象 if (checkLimitIndexTypeisLoad(t, reqlimitObject)) { EasyUiTree e2 = new EasyUiTree(); //id存的就是指标类型 e2.id = ((int)t).ToString(); //e2.attributes = "LimitIndexType"; e2.text = csEnumList.First(x => x.IntValue.ToString().Equals(e2.id)).DisplayValue; e2.attributes = new { LimitIndexType = t, LimitType = "" }; rootNode.children.Add(e2); } }); } //加载具体的限额类型 //(这里其实是个自关联) // (指标1 类型1) (指标1 类型2) if (rootNode.children != null && rootNode.children.Count > 0) { foreach (EasyUiTree child in rootNode.children) { foreach (var t in basLimitTypeList) { //按理说我们只要过滤指标类属不属于选定的限额对象就好了 这里正常都要返回true,因为这里的内容就是幸存的指标的具体类型比如 指标1 类型1 if (checkLimitIndexTypeisLoad(t.LimitIndexType, reqlimitObject)) { if (((int)t.LimitIndexType).ToString().Equals(child.id) && t.Id != child.id) { child.state = "closed"; if (child.children == null || child.children.Count <= 0) child.children = new List<EasyUiTree>(); EasyUiTree e3 = new EasyUiTree(); e3.id = t.Id; e3.text = t.LimitIndexName; e3.attributes = new { LimitType = (int)t.LimitType, LimitIndexType = t.LimitIndexType, }; child.children.Add(e3); } } } } } list1.Add(rootNode); var json2 = Newtonsoft.Json.JsonConvert.SerializeObject(list1); if (!string.IsNullOrEmpty(isConvert) && isConvert == "true") { IList<jsMindEntity> minds = new List<jsMindEntity>(); json2 = Convert2MindEntity(list1, minds); } context.Response.Write(json2); context.Response.End(); break; #endregion } } private string Convert2MindEntity(IList<EasyUiTree> list1, IList<jsMindEntity> minds, string parentid = "", bool isfirst = true) { jsMindEntity mind = null; foreach (var item in list1) { mind = new jsMindEntity(); mind.id = item.id; mind.topic = item.text; mind.parentid = parentid; if (isfirst == true) { mind.isroot = true; } else { mind.isroot = false; } mind.type = ((int)((item.attributes as dynamic).LimitObjectType)).ToString(); minds.Add(mind); if (item.children != null && item.children.Count > 0) { Convert2MindEntity(item.children, minds, item.id, false); } } return Newtonsoft.Json.JsonConvert.SerializeObject(minds); } private void SetEasyUiTreeTag1(IList<EasyUiTree> children, string RefTableName, string DataValueField, string DataTextField, int LimitObjectType, string nodeId = "") { var limit_Object_type = (Limit_Object)LimitObjectType; if (children.Count > 0) { if (!string.IsNullOrEmpty(nodeId)) { } foreach (EasyUiTree e in children) { e.attributes = new { RefTableName = RefTableName, DataValueField = DataValueField, TextValueField = DataTextField, LimitObjectType = LimitObjectType }; if (e.children != null && e.children.Count > 0) { SetEasyUiTreeTag1(e.children, RefTableName, DataValueField, DataTextField, LimitObjectType); } } } } public bool IsReusable { get { return false; } } } }