first commit
This commit is contained in:
3
comm/Item/WebContent/META-INF/MANIFEST.MF
Executable file
3
comm/Item/WebContent/META-INF/MANIFEST.MF
Executable file
@@ -0,0 +1,3 @@
|
||||
Manifest-Version: 1.0
|
||||
Class-Path:
|
||||
|
||||
110
comm/Item/WebContent/item_leverage_add.jsp
Executable file
110
comm/Item/WebContent/item_leverage_add.jsp
Executable file
@@ -0,0 +1,110 @@
|
||||
<%@ page language="java" pageEncoding="utf-8"%>
|
||||
<%@ include file="include/pagetop.jsp"%>
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<%@ include file="include/head.jsp"%>
|
||||
</head>
|
||||
<body>
|
||||
<%@ include file="include/loading.jsp"%>
|
||||
<%@ include file="include/top.jsp"%>
|
||||
<%@ include file="include/menu_left.jsp"%>
|
||||
|
||||
<!-- //////////////////////////////////////////////////////////////////////////// -->
|
||||
<!-- START CONTENT -->
|
||||
<div class="content">
|
||||
|
||||
|
||||
|
||||
<!-- //////////////////////////////////////////////////////////////////////////// -->
|
||||
<!-- START CONTAINER -->
|
||||
<div class="container-default">
|
||||
<h3>交易杠杆</h3>
|
||||
<%@ include file="include/alert.jsp"%>
|
||||
<!-- //////////////////////////////////////////////////////////////////////////// -->
|
||||
<!-- START queryForm -->
|
||||
<form action="<%=basePath%>normal/adminItemLeverageAction!list.action" method="post" id="queryForm">
|
||||
<s:hidden name="pageNo" id="pageNo"></s:hidden>
|
||||
<s:hidden name="itemid" id="itemid"></s:hidden>
|
||||
</form>
|
||||
<!-- END queryForm -->
|
||||
<!-- //////////////////////////////////////////////////////////////////////////// -->
|
||||
<div class="row">
|
||||
<div class="col-md-12 col-lg-12">
|
||||
<div class="panel panel-default">
|
||||
|
||||
<div class="panel-title">
|
||||
新增杠杆
|
||||
<ul class="panel-tools">
|
||||
<li><a class="icon minimise-tool"><i
|
||||
class="fa fa-minus"></i></a></li>
|
||||
<li><a class="icon expand-tool"><i class="fa fa-expand"></i></a></li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<div class="panel-body">
|
||||
<form class="form-horizontal" action="<%=basePath%>normal/adminItemLeverageAction!add.action" method="post" name="mainForm" id="mainForm">
|
||||
<s:hidden name="itemid" id="itemid"></s:hidden>
|
||||
|
||||
<div class="form-group">
|
||||
<label class="col-sm-2 control-label form-label">杠杆倍数</label>
|
||||
<div class="col-sm-3">
|
||||
<div class="input-group">
|
||||
<s:textfield id="leverage" name="leverage" cssClass="form-control " />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="form-group">
|
||||
<div class="col-sm-offset-2 col-sm-10">
|
||||
<a href="javascript:goUrl(<s:property value="pageNo" />)" class="btn">取消</a> <a
|
||||
href="javascript:submit()" class="btn btn-default">保存</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</form>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
<!-- END CONTAINER -->
|
||||
<!-- //////////////////////////////////////////////////////////////////////////// -->
|
||||
|
||||
|
||||
<%@ include file="include/footer.jsp"%>
|
||||
|
||||
|
||||
</div>
|
||||
<!-- End Content -->
|
||||
<!-- //////////////////////////////////////////////////////////////////////////// -->
|
||||
|
||||
|
||||
<%@ include file="include/js.jsp"%>
|
||||
|
||||
|
||||
<script type="text/javascript">
|
||||
function submit(){
|
||||
swal({
|
||||
title : "是否保存?",
|
||||
text : "",
|
||||
type : "warning",
|
||||
showCancelButton : true,
|
||||
confirmButtonColor : "#DD6B55",
|
||||
confirmButtonText : "确认",
|
||||
closeOnConfirm : false
|
||||
}, function() {
|
||||
document.getElementById("mainForm").submit();
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
116
comm/Item/WebContent/item_leverage_list.jsp
Executable file
116
comm/Item/WebContent/item_leverage_list.jsp
Executable file
@@ -0,0 +1,116 @@
|
||||
<%@ page language="java" pageEncoding="utf-8"%>
|
||||
<%@ include file="include/pagetop.jsp"%>
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<%@ include file="include/head.jsp"%>
|
||||
</head>
|
||||
<body>
|
||||
<%@ include file="include/loading.jsp"%>
|
||||
<%@ include file="include/top.jsp"%>
|
||||
<%@ include file="include/menu_left.jsp"%>
|
||||
|
||||
<!-- //////////////////////////////////////////////////////////////////////////// -->
|
||||
<!-- START CONTENT -->
|
||||
<div class="content">
|
||||
<!-- //////////////////////////////////////////////////////////////////////////// -->
|
||||
<!-- START CONTAINER -->
|
||||
<div class="container-default">
|
||||
<h3>交易杠杆</h3>
|
||||
<%@ include file="include/alert.jsp"%>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
<!-- Start Panel -->
|
||||
<div class="panel panel-default">
|
||||
|
||||
<div class="panel-title">查询结果</div>
|
||||
<a href="<%=basePath%>normal/adminItemLeverageAction!toAdd.action?itemid=<s:property value="itemid" />" class="btn btn-light" style="margin-bottom: 10px" >新增杠杆参数</a>
|
||||
<div class="panel-body">
|
||||
<table class="table table-bordered table-striped">
|
||||
<thead>
|
||||
<tr>
|
||||
<td>杠杆(倍)</td>
|
||||
<td width="130px"></td>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<s:iterator value="page.elements" status="stat">
|
||||
<tr>
|
||||
<td><fmt:formatNumber value="${leverage}"
|
||||
pattern="#0.00" /></td>
|
||||
|
||||
<td>
|
||||
<div class="btn-group">
|
||||
<button type="button" class="btn btn-light">操作</button>
|
||||
<button type="button" class="btn btn-light dropdown-toggle"
|
||||
data-toggle="dropdown" aria-expanded="false">
|
||||
<span class="caret"></span> <span class="sr-only">Toggle
|
||||
Dropdown</span>
|
||||
</button>
|
||||
<ul class="dropdown-menu" role="menu">
|
||||
|
||||
<li><a
|
||||
href="javascript:ondelete('<s:property value="id" />')">删除</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
</td>
|
||||
|
||||
</tr>
|
||||
</s:iterator>
|
||||
|
||||
</tbody>
|
||||
</table>
|
||||
<%@ include file="include/page_simple.jsp"%>
|
||||
<nav>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<!-- End Panel -->
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<!-- END CONTAINER -->
|
||||
<!-- //////////////////////////////////////////////////////////////////////////// -->
|
||||
|
||||
|
||||
<%@ include file="include/footer.jsp"%>
|
||||
|
||||
|
||||
</div>
|
||||
<!-- End Content -->
|
||||
<!-- //////////////////////////////////////////////////////////////////////////// -->
|
||||
|
||||
|
||||
|
||||
<%@ include file="include/js.jsp"%>
|
||||
|
||||
<form action="normal/adminItemLeverageAction!delete.action"
|
||||
method="post" id="ondelete">
|
||||
<input type="hidden" name="pageNo" id="pageNo"
|
||||
value="${param.pageNo}">
|
||||
<s:hidden name="id" id="id"></s:hidden>
|
||||
<s:hidden name="itemid" id="itemid"></s:hidden>
|
||||
</form>
|
||||
<script type="text/javascript">
|
||||
function ondelete(id) {
|
||||
$("#id").val(id);
|
||||
swal({
|
||||
title : "是否确认删除?",
|
||||
text : "",
|
||||
type : "warning",
|
||||
showCancelButton : true,
|
||||
confirmButtonColor : "#DD6B55",
|
||||
confirmButtonText : "确认",
|
||||
closeOnConfirm : false
|
||||
}, function() {
|
||||
document.getElementById("ondelete").submit();
|
||||
});
|
||||
|
||||
}
|
||||
</script>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
142
comm/Item/WebContent/item_list.jsp
Executable file
142
comm/Item/WebContent/item_list.jsp
Executable file
@@ -0,0 +1,142 @@
|
||||
<%@ page language="java" pageEncoding="utf-8"%>
|
||||
<%@ include file="include/pagetop.jsp"%>
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<%@ include file="include/head.jsp"%>
|
||||
</head>
|
||||
<body>
|
||||
<%@ include file="include/loading.jsp"%>
|
||||
<%@ include file="include/top.jsp"%>
|
||||
<%@ include file="include/menu_left.jsp"%>
|
||||
|
||||
<!-- //////////////////////////////////////////////////////////////////////////// -->
|
||||
<!-- START CONTENT -->
|
||||
<div class="content">
|
||||
|
||||
|
||||
|
||||
<!-- //////////////////////////////////////////////////////////////////////////// -->
|
||||
<!-- START CONTAINER -->
|
||||
<div class="container-default">
|
||||
<h3>交易品种</h3>
|
||||
<%@ include file="include/alert.jsp"%>
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
<div class="panel panel-default">
|
||||
|
||||
<div class="panel-title">操作</div>
|
||||
<div class="panel-body">
|
||||
|
||||
<form class="form-horizontal"
|
||||
action="<%=basePath%>normal/adminItemAction!order_open.action"
|
||||
method="post" id="queryForm">
|
||||
<s:hidden name="pageNo" id="pageNo"></s:hidden>
|
||||
<div class="col-md-12 col-lg-4">
|
||||
<fieldset>
|
||||
<div class="control-group">
|
||||
<div class="controls">
|
||||
<s:select id="order_open" cssClass="form-control "
|
||||
name="order_open" list="#{'true':'交易开启','false':'交易关闭(关闭后,所有品种不可开仓和平仓)'}"
|
||||
listKey="key" listValue="value"
|
||||
value="order_open" />
|
||||
</div>
|
||||
</div>
|
||||
</fieldset>
|
||||
</div>
|
||||
|
||||
<div class="col-md-12 col-lg-2">
|
||||
<button type="submit" class="btn btn-block btn-default">确定</button>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
<!-- Start Panel -->
|
||||
<div class="panel panel-default">
|
||||
|
||||
<div class="panel-title">查询结果</div>
|
||||
<div class="panel-body">
|
||||
<table class="table table-bordered table-striped">
|
||||
<thead>
|
||||
<tr>
|
||||
<td>名称</td>
|
||||
<td>代码</td>
|
||||
<td>交易对</td>
|
||||
<td>每张金额</td>
|
||||
<td>每张手续费</td>
|
||||
<td>最小变动单位</td>
|
||||
<td>最小变动单位的盈亏金额</td>
|
||||
<!--
|
||||
<td>市场</td> -->
|
||||
<td width="130px"></td>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<s:iterator value="page.elements" status="stat">
|
||||
<tr>
|
||||
<td><s:property value="name" /></td>
|
||||
<td><s:property value="symbol" /></td>
|
||||
<td><s:property value="symbol_data" /></td>
|
||||
<td><s:property value="unit_amount" /></td>
|
||||
<td><s:property value="unit_fee" /></td>
|
||||
<td><s:property value="pips" /></td>
|
||||
<td><s:property value="pips_amount" /></td>
|
||||
<!--
|
||||
<td><s:if test='market=="1"'>币币交易</s:if><s:if test='market=="2"'>合约交易</s:if></td>
|
||||
-->
|
||||
<td>
|
||||
<div class="btn-group">
|
||||
<button type="button" class="btn btn-light">操作</button>
|
||||
<button type="button" class="btn btn-light dropdown-toggle"
|
||||
data-toggle="dropdown" aria-expanded="false">
|
||||
<span class="caret"></span> <span class="sr-only">Toggle
|
||||
Dropdown</span>
|
||||
</button>
|
||||
<ul class="dropdown-menu" role="menu">
|
||||
<li><a
|
||||
href="<%=basePath%>normal/adminItemAction!toUpdate.action?id=<s:property value="id" />">修改</a></li>
|
||||
<li><a
|
||||
href="<%=basePath%>normal/adminItemLeverageAction!list.action?itemid=<s:property value="id" />">交易杠杆</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
</td>
|
||||
|
||||
</tr>
|
||||
</s:iterator>
|
||||
|
||||
</tbody>
|
||||
</table>
|
||||
<%@ include file="include/page_simple.jsp"%>
|
||||
<nav>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<!-- End Panel -->
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<!-- END CONTAINER -->
|
||||
<!-- //////////////////////////////////////////////////////////////////////////// -->
|
||||
|
||||
|
||||
<%@ include file="include/footer.jsp"%>
|
||||
|
||||
|
||||
</div>
|
||||
<!-- End Content -->
|
||||
<!-- //////////////////////////////////////////////////////////////////////////// -->
|
||||
|
||||
|
||||
|
||||
<%@ include file="include/js.jsp"%>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
153
comm/Item/WebContent/item_update.jsp
Executable file
153
comm/Item/WebContent/item_update.jsp
Executable file
@@ -0,0 +1,153 @@
|
||||
<%@ page language="java" pageEncoding="utf-8"%>
|
||||
<%@ include file="include/pagetop.jsp"%>
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<%@ include file="include/head.jsp"%>
|
||||
</head>
|
||||
<body>
|
||||
<%@ include file="include/loading.jsp"%>
|
||||
<%@ include file="include/top.jsp"%>
|
||||
<%@ include file="include/menu_left.jsp"%>
|
||||
|
||||
<!-- //////////////////////////////////////////////////////////////////////////// -->
|
||||
<!-- START CONTENT -->
|
||||
<div class="content">
|
||||
|
||||
|
||||
|
||||
<!-- //////////////////////////////////////////////////////////////////////////// -->
|
||||
<!-- START CONTAINER -->
|
||||
<div class="container-default">
|
||||
<h3>交易品种</h3>
|
||||
<%@ include file="include/alert.jsp"%>
|
||||
<!-- //////////////////////////////////////////////////////////////////////////// -->
|
||||
<!-- START queryForm -->
|
||||
<form action="<%=basePath%>normal/adminItemAction!list.action" method="post" id="queryForm">
|
||||
<s:hidden name="pageNo" id="pageNo"></s:hidden>
|
||||
</form>
|
||||
<!-- END queryForm -->
|
||||
<!-- //////////////////////////////////////////////////////////////////////////// -->
|
||||
<div class="row">
|
||||
<div class="col-md-12 col-lg-12">
|
||||
<div class="panel panel-default">
|
||||
|
||||
<div class="panel-title">
|
||||
修改交易品种
|
||||
<ul class="panel-tools">
|
||||
<li><a class="icon minimise-tool"><i
|
||||
class="fa fa-minus"></i></a></li>
|
||||
<li><a class="icon expand-tool"><i class="fa fa-expand"></i></a></li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<div class="panel-body">
|
||||
<form class="form-horizontal" action="<%=basePath%>normal/adminItemAction!update.action" method="post" name="mainForm" id="mainForm">
|
||||
<s:hidden name="id" id="id"></s:hidden>
|
||||
<h5>基础信息</h5>
|
||||
|
||||
<div class="form-group">
|
||||
<label class="col-sm-2 control-label form-label">名称</label>
|
||||
<div class="col-sm-5">
|
||||
<s:textfield id="name" name="name" cssClass="form-control " />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label class="col-sm-2 control-label form-label">代码</label>
|
||||
<div class="col-sm-5">
|
||||
<s:textfield id="symbol" name="symbol" cssClass="form-control " readonly="true"/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label class="col-sm-2 control-label form-label">交易对</label>
|
||||
<div class="col-sm-5">
|
||||
<s:textfield id="symbol_data" name="symbol_data" cssClass="form-control " readonly="true"/>
|
||||
</div>
|
||||
</div>
|
||||
<h5>交易信息</h5>
|
||||
<p class="ballon color1">盈亏公式:(合约总金额 /每张金额)*(涨跌点数/最小变动单位*最小变动单位的盈亏金额)。</p>
|
||||
<div class="form-group">
|
||||
<label class="col-sm-2 control-label form-label">金额/张</label>
|
||||
<div class="col-sm-3">
|
||||
<s:textfield id="unit_amount" name="unit_amount" cssClass="form-control " placeholder="合约每张金额"/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label class="col-sm-2 control-label form-label">手续费/张</label>
|
||||
<div class="col-sm-3">
|
||||
|
||||
<s:textfield id="unit_fee" name="unit_fee" cssClass="form-control " placeholder="合约每张金额"/>
|
||||
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label class="col-sm-2 control-label form-label">最小变动单位</label>
|
||||
<div class="col-sm-3">
|
||||
<s:textfield id="pips" name="pips" cssClass="form-control " placeholder="报价变动的最小幅度"/>
|
||||
<p>报价变动的最小幅度,行情低于设置单位不会计价盈亏"</p>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="col-sm-2 control-label form-label">最小变动单位的盈亏金额</label>
|
||||
<div class="col-sm-3">
|
||||
<s:textfield id="pips_amount" name="pips_amount" cssClass="form-control " placeholder="最小变动单位的盈亏金额"/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<div class="col-sm-offset-2 col-sm-10">
|
||||
<a href="javascript:goUrl(<s:property value="pageNo" />)" class="btn">取消</a> <a
|
||||
href="javascript:submit()" class="btn btn-default">保存</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</form>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
<!-- END CONTAINER -->
|
||||
<!-- //////////////////////////////////////////////////////////////////////////// -->
|
||||
|
||||
|
||||
<%@ include file="include/footer.jsp"%>
|
||||
|
||||
|
||||
</div>
|
||||
<!-- End Content -->
|
||||
<!-- //////////////////////////////////////////////////////////////////////////// -->
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<%@ include file="include/js.jsp"%>
|
||||
<script type="text/javascript">
|
||||
function submit(){
|
||||
swal({
|
||||
title : "是否保存?",
|
||||
text : "",
|
||||
type : "warning",
|
||||
showCancelButton : true,
|
||||
confirmButtonColor : "#DD6B55",
|
||||
confirmButtonText : "确认",
|
||||
closeOnConfirm : false
|
||||
}, function() {
|
||||
document.getElementById("mainForm").submit();
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
38
comm/Item/build/classes/project/item/Item.hbm.xml
Executable file
38
comm/Item/build/classes/project/item/Item.hbm.xml
Executable file
@@ -0,0 +1,38 @@
|
||||
<?xml version="1.0"?>
|
||||
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
|
||||
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
|
||||
<hibernate-mapping>
|
||||
<class name="project.item.Item" table="T_ITEM">
|
||||
<id name="id" type="java.lang.String">
|
||||
<column name="UUID" />
|
||||
<generator class="uuid.hex" />
|
||||
</id>
|
||||
<property name="name" type="java.lang.String">
|
||||
<column name="NAME" />
|
||||
</property>
|
||||
<property name="symbol" type="java.lang.String">
|
||||
<column name="SYMBOL" />
|
||||
</property>
|
||||
<property name="symbol_data" type="java.lang.String">
|
||||
<column name="SYMBOL_DATA" />
|
||||
</property>
|
||||
<property name="pips" type="double">
|
||||
<column name="PIPS" />
|
||||
</property>
|
||||
<property name="pips_amount" type="double">
|
||||
<column name="PIPS_AMOUNT" />
|
||||
</property>
|
||||
<property name="adjustment_value" type="double">
|
||||
<column name="ADJUSTMENT_VALUE" />
|
||||
</property>
|
||||
<property name="unit_amount" type="double">
|
||||
<column name="UNIT_AMOUNT" />
|
||||
</property>
|
||||
<property name="unit_fee" type="double">
|
||||
<column name="UNIT_FEE" />
|
||||
</property>
|
||||
<property name="market" type="java.lang.String">
|
||||
<column name="MARKET" />
|
||||
</property>
|
||||
</class>
|
||||
</hibernate-mapping>
|
||||
17
comm/Item/build/classes/project/item/ItemLever.hbm.xml
Executable file
17
comm/Item/build/classes/project/item/ItemLever.hbm.xml
Executable file
@@ -0,0 +1,17 @@
|
||||
<?xml version="1.0"?>
|
||||
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
|
||||
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
|
||||
<hibernate-mapping>
|
||||
<class name="project.item.ItemLever" table="T_ITEM_LEVERAGE">
|
||||
<id name="id" type="java.lang.String">
|
||||
<column name="UUID" />
|
||||
<generator class="uuid.hex" />
|
||||
</id>
|
||||
<property name="item_id" type="java.lang.String">
|
||||
<column name="ITEM_ID" />
|
||||
</property>
|
||||
<property name="lever_rate" type="double">
|
||||
<column name="LEVER_RATE" />
|
||||
</property>
|
||||
</class>
|
||||
</hibernate-mapping>
|
||||
11
comm/Item/config/applicationContext-hibernate.xml
Executable file
11
comm/Item/config/applicationContext-hibernate.xml
Executable file
@@ -0,0 +1,11 @@
|
||||
|
||||
admin
|
||||
|
||||
<!-- item -->
|
||||
<value>itemService</value>
|
||||
<value>adminItemService</value>
|
||||
<value>adminItemLeverageService</value>
|
||||
|
||||
api
|
||||
<!-- item -->
|
||||
<value>itemService</value>
|
||||
17
comm/Item/config/applicationContext-item.xml
Executable file
17
comm/Item/config/applicationContext-item.xml
Executable file
@@ -0,0 +1,17 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<beans xmlns="http://www.springframework.org/schema/beans"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns:dubbo="http://code.alibabatech.com/schema/dubbo"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/beans
|
||||
http://www.springframework.org/schema/beans/spring-beans.xsd
|
||||
http://code.alibabatech.com/schema/dubbo
|
||||
http://code.alibabatech.com/schema/dubbo/dubbo.xsd ">
|
||||
|
||||
<!-- init-method="init" -->
|
||||
|
||||
<bean id="itemService"
|
||||
class="project.item.internal.ItemServiceImpl">
|
||||
<property name="hibernateTemplate" ref="hibernateTemplate" />
|
||||
</bean>
|
||||
|
||||
</beans>
|
||||
29
comm/Item/config/applicationContext-item_admin.xml
Executable file
29
comm/Item/config/applicationContext-item_admin.xml
Executable file
@@ -0,0 +1,29 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<beans xmlns="http://www.springframework.org/schema/beans"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns:dubbo="http://code.alibabatech.com/schema/dubbo"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/beans
|
||||
http://www.springframework.org/schema/beans/spring-beans.xsd
|
||||
http://code.alibabatech.com/schema/dubbo
|
||||
http://code.alibabatech.com/schema/dubbo/dubbo.xsd ">
|
||||
|
||||
<bean id="adminItemService"
|
||||
class="project.item.internal.AdminItemServiceImpl">
|
||||
<property name="hibernateTemplate" ref="hibernateTemplate" />
|
||||
<property name="pagedQueryDao" ref="pagedDao" />
|
||||
<property name="itemService" ref="itemService" />
|
||||
<property name="klineService" ref="klineService" />
|
||||
</bean>
|
||||
|
||||
<bean id="adminItemLeverageService"
|
||||
class="project.item.internal.AdminItemLeverageServiceImpl">
|
||||
<property name="hibernateTemplate" ref="hibernateTemplate" />
|
||||
<property name="pagedQueryDao" ref="pagedDao" />
|
||||
</bean>
|
||||
|
||||
<bean id="itemService"
|
||||
class="project.item.internal.ItemServiceImpl">
|
||||
<property name="hibernateTemplate" ref="hibernateTemplate" />
|
||||
</bean>
|
||||
|
||||
</beans>
|
||||
17
comm/Item/config/applicationContext-item_data.xml
Executable file
17
comm/Item/config/applicationContext-item_data.xml
Executable file
@@ -0,0 +1,17 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<beans xmlns="http://www.springframework.org/schema/beans"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns:dubbo="http://code.alibabatech.com/schema/dubbo"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/beans
|
||||
http://www.springframework.org/schema/beans/spring-beans.xsd
|
||||
http://code.alibabatech.com/schema/dubbo
|
||||
http://code.alibabatech.com/schema/dubbo/dubbo.xsd ">
|
||||
|
||||
<!-- init-method="init" -->
|
||||
|
||||
<bean id="itemService"
|
||||
class="project.item.internal.ItemServiceImpl">
|
||||
<property name="hibernateTemplate" ref="hibernateTemplate" />
|
||||
</bean>
|
||||
|
||||
</beans>
|
||||
21
comm/Item/config/normal.xml
Executable file
21
comm/Item/config/normal.xml
Executable file
@@ -0,0 +1,21 @@
|
||||
|
||||
admin
|
||||
<action name="adminItemAction"
|
||||
class="project.item.web.AdminItemAction">
|
||||
<result name="list">/item_list.jsp</result>
|
||||
<result name="update">/item_update.jsp</result>
|
||||
<result name="add">/item_add.jsp</result>
|
||||
</action>
|
||||
|
||||
<action name="adminItemLeverageAction"
|
||||
class="project.item.web.AdminItemLeverageAction">
|
||||
<result name="list">/item_leverage_list.jsp</result>
|
||||
<result name="add">/item_leverage_add.jsp</result>
|
||||
</action>
|
||||
|
||||
|
||||
api
|
||||
|
||||
<action name="withdraw"
|
||||
class="project.withdraw.web.WithdrawAction">
|
||||
</action>
|
||||
33
comm/Item/dbscript/1.1/ITEM-DDL-MYSQL.SQL
Executable file
33
comm/Item/dbscript/1.1/ITEM-DDL-MYSQL.SQL
Executable file
@@ -0,0 +1,33 @@
|
||||
DROP TABLE IF EXISTS `T_ITEM`;
|
||||
CREATE TABLE `T_ITEM` (
|
||||
`UUID` varchar(32) NOT NULL COMMENT 'Ö÷¼ü',
|
||||
`NAME` varchar(64) ,
|
||||
`SYMBOL` varchar(32) ,
|
||||
`SYMBOL_DATA` varchar(32) ,
|
||||
`PIPS` double ,
|
||||
`PIPS_AMOUNT` double ,
|
||||
`ADJUSTMENT_VALUE` double ,
|
||||
`UNIT_AMOUNT` double ,
|
||||
`UNIT_FEE` double ,
|
||||
`MARKET` varchar(32) ,
|
||||
PRIMARY KEY (`UUID`),
|
||||
KEY `INDEX_ITEM_SYMBOL` (`SYMBOL`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
alter table T_ITEM add DECIMALS int;
|
||||
|
||||
DROP TABLE IF EXISTS `T_ITEM_LEVERAGE`;
|
||||
CREATE TABLE `T_ITEM_LEVERAGE` (
|
||||
`UUID` varchar(32) NOT NULL COMMENT 'Ö÷¼ü',
|
||||
`ITEM_ID` varchar(32) ,
|
||||
`LEVER_RATE` double ,
|
||||
PRIMARY KEY (`UUID`),
|
||||
KEY `INDEX_ITEM_LEVERAGE_ITEM_ID` (`ITEM_ID`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
ALTER TABLE `T_ITEM` ADD COLUMN `MULTIPLE` double NULL DEFAULT 0;
|
||||
54
comm/Item/dbscript/1.1/ITEM-DML-MYSQL.SQL
Executable file
54
comm/Item/dbscript/1.1/ITEM-DML-MYSQL.SQL
Executable file
@@ -0,0 +1,54 @@
|
||||
|
||||
INSERT INTO `SCT_RESOURCE` (`UUID`, `RES_STRING`, `RES_TYPE`)
|
||||
VALUES
|
||||
('URL_ADMIN_ITEM_ADD', '/normal/adminItemAction!add.action*', 'URL');
|
||||
INSERT INTO `SCT_ROLE_RESOURCE` (`ROLE_UUID`,`RESOURCE_UUID`)
|
||||
VALUES
|
||||
('SECURITY_ROLE_ROOT', 'URL_ADMIN_ITEM_ADD');
|
||||
INSERT INTO `SCT_ROLE_RESOURCE` (`ROLE_UUID`,`RESOURCE_UUID`)
|
||||
VALUES
|
||||
('SECURITY_ROLE_ADMIN', 'URL_ADMIN_ITEM_ADD');
|
||||
|
||||
|
||||
INSERT INTO `SCT_RESOURCE` (`UUID`, `RES_STRING`, `RES_TYPE`)
|
||||
VALUES
|
||||
('URL_ADMIN_ITEM_UPDATE', '/normal/adminItemAction!update.action*', 'URL');
|
||||
INSERT INTO `SCT_ROLE_RESOURCE` (`ROLE_UUID`,`RESOURCE_UUID`)
|
||||
VALUES
|
||||
('SECURITY_ROLE_ROOT', 'URL_ADMIN_ITEM_UPDATE');
|
||||
INSERT INTO `SCT_ROLE_RESOURCE` (`ROLE_UUID`,`RESOURCE_UUID`)
|
||||
VALUES
|
||||
('SECURITY_ROLE_ADMIN', 'URL_ADMIN_ITEM_UPDATE');
|
||||
|
||||
|
||||
INSERT INTO `SCT_RESOURCE` (`UUID`, `RES_STRING`, `RES_TYPE`)
|
||||
VALUES
|
||||
('URL_ADMIN_ITEM_ORDER_OPEN', '/normal/adminItemAction!order_open.action*', 'URL');
|
||||
INSERT INTO `SCT_ROLE_RESOURCE` (`ROLE_UUID`,`RESOURCE_UUID`)
|
||||
VALUES
|
||||
('SECURITY_ROLE_ROOT', 'URL_ADMIN_ITEM_ORDER_OPEN');
|
||||
INSERT INTO `SCT_ROLE_RESOURCE` (`ROLE_UUID`,`RESOURCE_UUID`)
|
||||
VALUES
|
||||
('SECURITY_ROLE_ADMIN', 'URL_ADMIN_ITEM_ORDER_OPEN');
|
||||
|
||||
|
||||
INSERT INTO `SCT_RESOURCE` (`UUID`, `RES_STRING`, `RES_TYPE`)
|
||||
VALUES
|
||||
('URL_ADMIN_ITEMLEVERAGE_ADD', '/normal/adminItemLeverageAction!add.action*', 'URL');
|
||||
INSERT INTO `SCT_ROLE_RESOURCE` (`ROLE_UUID`,`RESOURCE_UUID`)
|
||||
VALUES
|
||||
('SECURITY_ROLE_ROOT', 'URL_ADMIN_ITEMLEVERAGE_ADD');
|
||||
INSERT INTO `SCT_ROLE_RESOURCE` (`ROLE_UUID`,`RESOURCE_UUID`)
|
||||
VALUES
|
||||
('SECURITY_ROLE_ADMIN', 'URL_ADMIN_ITEMLEVERAGE_ADD');
|
||||
|
||||
|
||||
INSERT INTO `SCT_RESOURCE` (`UUID`, `RES_STRING`, `RES_TYPE`)
|
||||
VALUES
|
||||
('URL_ADMIN_ITEMLEVERAGE_DELETE', '/normal/adminItemLeverageAction!delete.action*', 'URL');
|
||||
INSERT INTO `SCT_ROLE_RESOURCE` (`ROLE_UUID`,`RESOURCE_UUID`)
|
||||
VALUES
|
||||
('SECURITY_ROLE_ROOT', 'URL_ADMIN_ITEMLEVERAGE_DELETE');
|
||||
INSERT INTO `SCT_ROLE_RESOURCE` (`ROLE_UUID`,`RESOURCE_UUID`)
|
||||
VALUES
|
||||
('SECURITY_ROLE_ADMIN', 'URL_ADMIN_ITEMLEVERAGE_DELETE');
|
||||
99
comm/Item/src/project/data/loadcache/ItemLoadCacheService.java
Executable file
99
comm/Item/src/project/data/loadcache/ItemLoadCacheService.java
Executable file
@@ -0,0 +1,99 @@
|
||||
package project.data.loadcache;
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.springframework.orm.hibernate5.support.HibernateDaoSupport;
|
||||
|
||||
import project.item.ItemRedisKeys;
|
||||
import project.item.model.Item;
|
||||
import project.item.model.ItemLever;
|
||||
import project.item.model.ItemUserOptional;
|
||||
import project.redis.RedisHandler;
|
||||
|
||||
public class ItemLoadCacheService extends HibernateDaoSupport {
|
||||
|
||||
private Logger logger = LogManager.getLogger(this.getClass().getName());
|
||||
|
||||
private RedisHandler redisHandler;
|
||||
|
||||
public void loadcache() {
|
||||
loadItem();
|
||||
loadItemLever();
|
||||
loadItemUserOptional();
|
||||
logger.info("完成Item数据加载redis");
|
||||
}
|
||||
|
||||
private void loadItem() {
|
||||
List<Item> list = (List<Item>) this.getHibernateTemplate().find(" FROM Item ");
|
||||
Map<String, Item> cache = new ConcurrentHashMap<String, Item>();
|
||||
|
||||
for (int i = 0; i < list.size(); i++) {
|
||||
Item item = list.get(i);
|
||||
redisHandler.setSync(ItemRedisKeys.ITEM_SYMBOL + item.getSymbol(), item);
|
||||
cache.put(list.get(i).getSymbol(), item);
|
||||
}
|
||||
redisHandler.setSync(ItemRedisKeys.ITEM_MAP, cache);
|
||||
|
||||
}
|
||||
|
||||
private void loadItemLever() {
|
||||
// StringBuffer queryString = new StringBuffer(" FROM ItemLever ");
|
||||
// List<ItemLever> list = this.getHibernateTemplate().find(queryString.toString());
|
||||
List<ItemLever> list = (List<ItemLever>) this.getHibernateTemplate().find(" FROM ItemLever ");
|
||||
Map<String, Map<String, ItemLever>> lever_map = new ConcurrentHashMap<String, Map<String, ItemLever>>();
|
||||
for (int i = 0; i < list.size(); i++) {
|
||||
ItemLever itemLever = list.get(i);
|
||||
Map<String, ItemLever> lever_list = lever_map.get(itemLever.getItem_id());
|
||||
if (lever_list == null) {
|
||||
lever_list = new ConcurrentHashMap<String, ItemLever>();
|
||||
}
|
||||
lever_list.put(itemLever.getId().toString(), itemLever);
|
||||
lever_map.put(itemLever.getItem_id(), lever_list);
|
||||
|
||||
}
|
||||
|
||||
Map<String, Object> params = new ConcurrentHashMap<String, Object>();
|
||||
Iterator<Entry<String, Map<String, ItemLever>>> it = lever_map.entrySet().iterator();
|
||||
while (it.hasNext()) {
|
||||
Entry<String, Map<String, ItemLever>> entry = it.next();
|
||||
params.put(ItemRedisKeys.ITEM_LEVER_ID + entry.getKey(), entry.getValue());
|
||||
}
|
||||
redisHandler.setBatchSync(params);
|
||||
|
||||
}
|
||||
|
||||
public void loadItemUserOptional() {
|
||||
StringBuffer queryString = new StringBuffer(" FROM ItemUserOptional ");
|
||||
List<ItemUserOptional> list = (List<ItemUserOptional>) this.getHibernateTemplate().find(queryString.toString());
|
||||
// List<ItemUserOptional> list = currentSession().createQuery(" FROM ItemUserOptional ").getResultList();
|
||||
|
||||
Map<String, Map<String, ItemUserOptional>> cacheMap = new ConcurrentHashMap<String, Map<String, ItemUserOptional>>();
|
||||
|
||||
for (ItemUserOptional entity : list) {
|
||||
if (cacheMap.containsKey(entity.getPartyId())) {
|
||||
Map<String, ItemUserOptional> map = cacheMap.get(entity.getPartyId().toString());
|
||||
map.put(entity.getSymbol(), entity);
|
||||
cacheMap.put(entity.getPartyId().toString(), map);
|
||||
} else {
|
||||
Map<String, ItemUserOptional> map = new ConcurrentHashMap<String, ItemUserOptional>();
|
||||
map.put(entity.getSymbol(), entity);
|
||||
cacheMap.put(entity.getPartyId().toString(), map);
|
||||
}
|
||||
}
|
||||
|
||||
for (Entry<String, Map<String, ItemUserOptional>> entry : cacheMap.entrySet()) {
|
||||
redisHandler.setSync(ItemRedisKeys.ITEM_USER_OPTIONAL_MAP_PARTY_ID + entry.getKey(), entry.getValue());
|
||||
}
|
||||
}
|
||||
|
||||
public void setRedisHandler(RedisHandler redisHandler) {
|
||||
this.redisHandler = redisHandler;
|
||||
}
|
||||
|
||||
}
|
||||
13
comm/Item/src/project/item/AdminItemLeverageService.java
Executable file
13
comm/Item/src/project/item/AdminItemLeverageService.java
Executable file
@@ -0,0 +1,13 @@
|
||||
package project.item;
|
||||
|
||||
import kernel.web.Page;
|
||||
import project.item.model.ItemLever;
|
||||
|
||||
public interface AdminItemLeverageService {
|
||||
|
||||
public Page pagedQuery(int pageNo, int pageSize, String itemId);
|
||||
|
||||
public void save(ItemLever entity);
|
||||
|
||||
public void delete(String id);
|
||||
}
|
||||
61
comm/Item/src/project/item/AdminItemService.java
Executable file
61
comm/Item/src/project/item/AdminItemService.java
Executable file
@@ -0,0 +1,61 @@
|
||||
package project.item;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import kernel.web.Page;
|
||||
import project.item.model.Item;
|
||||
|
||||
public interface AdminItemService {
|
||||
public Page pagedQuery(int pageNo, int pageSize, String market, String symbol);
|
||||
|
||||
public Item get(String id);
|
||||
|
||||
public void update(Item entity);
|
||||
|
||||
public void save(Item entity);
|
||||
|
||||
|
||||
/**
|
||||
* 根据合约类型获取代码
|
||||
*
|
||||
* @param market
|
||||
* @return
|
||||
*/
|
||||
public List<String> getSymbolsByMarket(String market);
|
||||
|
||||
/**
|
||||
* 翻页获取代码
|
||||
*
|
||||
* @param pageNo
|
||||
* @param pageSize
|
||||
* @param market
|
||||
* @return
|
||||
*/
|
||||
public Page pagedQuerySymbolsByMarket(int pageNo, int pageSize, String market);
|
||||
|
||||
/**
|
||||
* 检测代码是否存在
|
||||
*
|
||||
* @param symbol
|
||||
* @return
|
||||
*/
|
||||
public boolean checkSymbolExit(String symbol);
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 获取item
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public List<Item> getItems();
|
||||
|
||||
/**
|
||||
* 获取代码
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public List<String> getSymbols();
|
||||
|
||||
|
||||
}
|
||||
22
comm/Item/src/project/item/ItemLock.java
Executable file
22
comm/Item/src/project/item/ItemLock.java
Executable file
@@ -0,0 +1,22 @@
|
||||
package project.item;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
public class ItemLock {
|
||||
private static final Set<String> filter = new HashSet<String>();
|
||||
|
||||
public static boolean add(String order_no) {
|
||||
if (!filter.add(order_no)) {
|
||||
return false;
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public static void remove(String order_no) {
|
||||
filter.remove(order_no);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
13
comm/Item/src/project/item/ItemRedisKeys.java
Executable file
13
comm/Item/src/project/item/ItemRedisKeys.java
Executable file
@@ -0,0 +1,13 @@
|
||||
package project.item;
|
||||
|
||||
public class ItemRedisKeys {
|
||||
public final static String ITEM_LEVER_ID = "ITEM_LEVER_ID_";
|
||||
public final static String ITEM_MAP = "ITEM_MAP_";
|
||||
public final static String ITEM_SYMBOL = "ITEM_SYMBOL_";
|
||||
public final static String ITEM_SYMBOLDATA = "ITEM_SYMBOLDATA_";
|
||||
|
||||
/**
|
||||
* 自选列表
|
||||
*/
|
||||
public final static String ITEM_USER_OPTIONAL_MAP_PARTY_ID = "ITEM_USER_OPTIONAL_MAP_PARTY_ID_";
|
||||
}
|
||||
54
comm/Item/src/project/item/ItemService.java
Executable file
54
comm/Item/src/project/item/ItemService.java
Executable file
@@ -0,0 +1,54 @@
|
||||
package project.item;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import project.item.model.Item;
|
||||
import project.item.model.ItemLever;
|
||||
import project.redis.RedisHandler;
|
||||
|
||||
/**
|
||||
* Item
|
||||
*/
|
||||
public interface ItemService {
|
||||
|
||||
/*
|
||||
* Item 可能返回null
|
||||
*/
|
||||
public Item cacheBySymbol(String symbol, boolean localcache);
|
||||
|
||||
public List<Item> cacheGetAll();
|
||||
|
||||
/**
|
||||
* 数据源的symbol查询系统的symbol值
|
||||
*
|
||||
* @param symbol_data 数据源的symbol值
|
||||
* @return symbol
|
||||
*/
|
||||
public Item cacheBySymbolData(String symbol_data);
|
||||
|
||||
public void update(Item entity);
|
||||
|
||||
public void add(Item entity);
|
||||
|
||||
/**
|
||||
* Item杠杆配置
|
||||
*
|
||||
*/
|
||||
public List<ItemLever> findLever(String item_id);
|
||||
|
||||
/**
|
||||
* 根据market获取
|
||||
*
|
||||
* @param market
|
||||
* @return
|
||||
*/
|
||||
public List<Item> cacheGetByMarket(String market);
|
||||
|
||||
/**
|
||||
* 获取所有币种名称
|
||||
*/
|
||||
public List<String> cacheGetAllSymbol();
|
||||
|
||||
RedisHandler getRedisHandler();
|
||||
|
||||
}
|
||||
24
comm/Item/src/project/item/ItemUserOptionalService.java
Executable file
24
comm/Item/src/project/item/ItemUserOptionalService.java
Executable file
@@ -0,0 +1,24 @@
|
||||
package project.item;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import project.item.model.ItemUserOptional;
|
||||
|
||||
public interface ItemUserOptionalService {
|
||||
|
||||
List<ItemUserOptional> cacheListByPartyId(String partyId);
|
||||
|
||||
void update(ItemUserOptional entity);
|
||||
|
||||
void save(ItemUserOptional entity);
|
||||
|
||||
public void delete(String partyId, String symbol);
|
||||
|
||||
public void delete(ItemUserOptional entity);
|
||||
|
||||
/**
|
||||
* 返回自选币种的行情
|
||||
*/
|
||||
public List<Map<String, Object>> cacheListDataByPartyId(String partyId, String symbol);
|
||||
}
|
||||
73
comm/Item/src/project/item/internal/AdminItemLeverageServiceImpl.java
Executable file
73
comm/Item/src/project/item/internal/AdminItemLeverageServiceImpl.java
Executable file
@@ -0,0 +1,73 @@
|
||||
package project.item.internal;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import org.springframework.orm.hibernate5.support.HibernateDaoSupport;
|
||||
|
||||
import kernel.util.StringUtils;
|
||||
import kernel.web.Page;
|
||||
import kernel.web.PagedQueryDao;
|
||||
import project.item.AdminItemLeverageService;
|
||||
import project.item.ItemRedisKeys;
|
||||
import project.item.model.ItemLever;
|
||||
import project.redis.RedisHandler;
|
||||
|
||||
public class AdminItemLeverageServiceImpl extends HibernateDaoSupport implements AdminItemLeverageService {
|
||||
private PagedQueryDao pagedQueryDao;
|
||||
private RedisHandler redisHandler;
|
||||
|
||||
@Override
|
||||
public Page pagedQuery(int pageNo, int pageSize, String item_id) {
|
||||
StringBuffer queryString = new StringBuffer(" FROM ItemLever WHERE 1 = 1 ");
|
||||
|
||||
Map<String, Object> parameters = new HashMap<String, Object>();
|
||||
if (!StringUtils.isNullOrEmpty(item_id)) {
|
||||
queryString.append(" and item_id = :item_id ");
|
||||
parameters.put("item_id", item_id);
|
||||
}
|
||||
|
||||
Page page = this.pagedQueryDao.pagedQueryHql(pageNo, pageSize, queryString.toString(), parameters);
|
||||
|
||||
return page;
|
||||
}
|
||||
|
||||
public ItemLever get(String id) {
|
||||
return getHibernateTemplate().get(ItemLever.class, id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void save(ItemLever entity) {
|
||||
this.getHibernateTemplate().save(entity);
|
||||
Map<String, ItemLever> map = (Map<String, ItemLever>) redisHandler.get(ItemRedisKeys.ITEM_LEVER_ID + entity.getItem_id());
|
||||
if (map == null) {
|
||||
map = new ConcurrentHashMap<String, ItemLever>();
|
||||
}
|
||||
map.put(entity.getId().toString(), entity);
|
||||
redisHandler.setSync(ItemRedisKeys.ITEM_LEVER_ID + entity.getItem_id(), map);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void delete(String id) {
|
||||
ItemLever entity = get(id);
|
||||
if (entity != null) {
|
||||
this.getHibernateTemplate().delete(entity);
|
||||
Map<String, ItemLever> map = (Map<String, ItemLever>) redisHandler.get(ItemRedisKeys.ITEM_LEVER_ID + entity.getItem_id());
|
||||
if (map != null) {
|
||||
map.remove(id);
|
||||
}
|
||||
redisHandler.setSync(ItemRedisKeys.ITEM_LEVER_ID + entity.getItem_id(), map);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void setPagedQueryDao(PagedQueryDao pagedQueryDao) {
|
||||
this.pagedQueryDao = pagedQueryDao;
|
||||
}
|
||||
|
||||
public void setRedisHandler(RedisHandler redisHandler) {
|
||||
this.redisHandler = redisHandler;
|
||||
}
|
||||
|
||||
}
|
||||
125
comm/Item/src/project/item/internal/AdminItemServiceImpl.java
Executable file
125
comm/Item/src/project/item/internal/AdminItemServiceImpl.java
Executable file
@@ -0,0 +1,125 @@
|
||||
package project.item.internal;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.commons.collections.CollectionUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.orm.hibernate5.support.HibernateDaoSupport;
|
||||
|
||||
import kernel.exception.BusinessException;
|
||||
import kernel.web.Page;
|
||||
import kernel.web.PagedQueryDao;
|
||||
import project.item.AdminItemService;
|
||||
import project.item.ItemService;
|
||||
import project.item.model.Item;
|
||||
import project.onlinechat.MessageUser;
|
||||
import project.party.model.Party;
|
||||
|
||||
public class AdminItemServiceImpl extends HibernateDaoSupport implements AdminItemService {
|
||||
private PagedQueryDao pagedQueryDao;
|
||||
private ItemService itemService;
|
||||
|
||||
public Page pagedQuery(int pageNo, int pageSize, String market, String symbol) {
|
||||
StringBuffer queryString = new StringBuffer();
|
||||
queryString.append(" FROM Item where 1 = 1 ");
|
||||
|
||||
Map<String, Object> parameters = new HashMap();
|
||||
if (StringUtils.isNotEmpty(symbol)) {
|
||||
queryString.append("AND symbol like:symbol ");
|
||||
parameters.put("symbol", "%" + symbol + "%");
|
||||
}
|
||||
Page page = this.pagedQueryDao.pagedQueryHql(pageNo, pageSize, queryString.toString(), parameters);
|
||||
|
||||
return page;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Item get(String id) {
|
||||
return getHibernateTemplate().get(Item.class, id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(Item entity) {
|
||||
itemService.update(entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void save(Item entity) {
|
||||
Item item = itemService.cacheBySymbolData(entity.getSymbol_data());
|
||||
|
||||
if (item != null) {
|
||||
throw new BusinessException("交易品种已存在");
|
||||
}
|
||||
itemService.add(entity);
|
||||
|
||||
}
|
||||
|
||||
public List<String> getSymbolsByMarket(String market) {
|
||||
StringBuffer queryString = new StringBuffer();
|
||||
queryString.append("SELECT obj.symbol FROM Item obj WHERE 1 = 1 ");
|
||||
queryString.append("AND market=?0 ");
|
||||
List<String> list = (List<String>) this.getHibernateTemplate().find(queryString.toString(), market);
|
||||
|
||||
// List<String> list = currentSession().createQuery("SELECT obj.symbol FROM Item obj WHERE 1 = 1 ")
|
||||
// .setParameter(0, market).getResultList();
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
public Page pagedQuerySymbolsByMarket(int pageNo, int pageSize, String market) {
|
||||
StringBuffer queryString = new StringBuffer();
|
||||
queryString.append("SELECT obj.symbol FROM Item obj WHERE 1 = 1 ");
|
||||
Map<String, Object> parameters = new HashMap();
|
||||
|
||||
if (StringUtils.isNotEmpty(market)) {
|
||||
queryString.append("AND market=:market ");
|
||||
parameters.put("market", market);
|
||||
}
|
||||
Page page = this.pagedQueryDao.pagedQueryHql(pageNo, pageSize, queryString.toString(), parameters);
|
||||
// List<String> list = this.getHibernateTemplate().find(queryString.toString(),market);
|
||||
return page;
|
||||
}
|
||||
|
||||
public boolean checkSymbolExit(String symbol) {
|
||||
List<Item> find = (List<Item>) this.getHibernateTemplate().find("FROM Item WHERE symbol=?0", symbol);
|
||||
|
||||
// List<Item> find = currentSession().createQuery("FROM Item WHERE symbol=?")
|
||||
// .setParameter(0, symbol).getResultList();
|
||||
|
||||
return !CollectionUtils.isEmpty(find) && null != find.get(0);
|
||||
}
|
||||
|
||||
public void setPagedQueryDao(PagedQueryDao pagedQueryDao) {
|
||||
this.pagedQueryDao = pagedQueryDao;
|
||||
}
|
||||
|
||||
public void setItemService(ItemService itemService) {
|
||||
this.itemService = itemService;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Item> getItems() {
|
||||
StringBuffer queryString = new StringBuffer();
|
||||
queryString.append(" FROM Item WHERE 1 = 1 ");
|
||||
List<Item> items = (List<Item>) this.getHibernateTemplate().find(queryString.toString());
|
||||
|
||||
// List<Item> items = currentSession().createQuery(" FROM Item WHERE 1 = 1 ").getResultList();
|
||||
|
||||
return items;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getSymbols() {
|
||||
StringBuffer queryString = new StringBuffer();
|
||||
queryString.append("SELECT obj.symbol FROM Item obj WHERE 1 = 1 ");
|
||||
// queryString.append("AND market=? ");
|
||||
List<String> list = (List<String>) this.getHibernateTemplate().find(queryString.toString());
|
||||
|
||||
// List<String> list = currentSession().createQuery("SELECT obj.symbol FROM Item obj WHERE 1 = 1 ").getResultList();
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
}
|
||||
143
comm/Item/src/project/item/internal/ItemServiceImpl.java
Executable file
143
comm/Item/src/project/item/internal/ItemServiceImpl.java
Executable file
@@ -0,0 +1,143 @@
|
||||
package project.item.internal;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import org.springframework.orm.hibernate5.support.HibernateDaoSupport;
|
||||
|
||||
import com.jcraft.jsch.Logger;
|
||||
|
||||
import kernel.cache.RedisLocalCache;
|
||||
import kernel.util.StringUtils;
|
||||
import project.item.ItemRedisKeys;
|
||||
import project.item.ItemService;
|
||||
import project.item.model.Item;
|
||||
import project.item.model.ItemLever;
|
||||
import project.redis.RedisHandler;
|
||||
|
||||
public class ItemServiceImpl extends HibernateDaoSupport implements ItemService {
|
||||
|
||||
private RedisHandler redisHandler;
|
||||
private RedisLocalCache redisLocalCache;
|
||||
|
||||
@Override
|
||||
public Item cacheBySymbol(String symbol, boolean localcache) {
|
||||
Item item = null;
|
||||
if (localcache) {
|
||||
item = (Item) redisLocalCache.get(ItemRedisKeys.ITEM_SYMBOL + symbol);
|
||||
} else {
|
||||
item = (Item) redisHandler.get(ItemRedisKeys.ITEM_SYMBOL + symbol);
|
||||
}
|
||||
|
||||
return item;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Item> cacheGetAll() {
|
||||
List<Item> list = new ArrayList<Item>();
|
||||
Map<String, Item> cache = (ConcurrentHashMap<String, Item>) redisHandler.get(ItemRedisKeys.ITEM_MAP);
|
||||
if (null == cache || cache.values().size() <= 0) {
|
||||
return list;
|
||||
}
|
||||
for (Item item : cache.values()) {
|
||||
list.add(item);
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
public List<Item> cacheGetByMarket(String symbol) {
|
||||
List<Item> cacheGetAll = cacheGetAll();
|
||||
if (StringUtils.isNullOrEmpty(symbol)) {
|
||||
return cacheGetAll;
|
||||
}
|
||||
List<Item> result = new ArrayList<Item>();
|
||||
for (Item item : cacheGetAll) {
|
||||
if (symbol.equals(item.getSymbol()))
|
||||
result.add(item);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(Item entity) {
|
||||
this.getHibernateTemplate().update(entity);
|
||||
redisHandler.setSync(ItemRedisKeys.ITEM_SYMBOL + entity.getSymbol(), entity);
|
||||
redisLocalCache.put(ItemRedisKeys.ITEM_SYMBOLDATA + entity.getSymbol_data(), entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Item cacheBySymbolData(String symbol_data) {
|
||||
Item item = (Item) redisLocalCache.get(ItemRedisKeys.ITEM_SYMBOLDATA + symbol_data);
|
||||
if (item == null) {
|
||||
Map<String, Item> cache = (ConcurrentHashMap<String, Item>) redisHandler.get(ItemRedisKeys.ITEM_MAP);
|
||||
for (String key : cache.keySet()) {
|
||||
Item item_cache = cache.get(key);
|
||||
if (item_cache.getSymbol_data().equals(symbol_data)) {
|
||||
redisLocalCache.put(ItemRedisKeys.ITEM_SYMBOLDATA + symbol_data, item_cache);
|
||||
return item_cache;
|
||||
}
|
||||
}
|
||||
}
|
||||
return item;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void add(Item entity) {
|
||||
this.getHibernateTemplate().save(entity);
|
||||
redisHandler.setSync(ItemRedisKeys.ITEM_SYMBOL + entity.getSymbol(), entity);
|
||||
|
||||
//同时添加到map
|
||||
Map<String, Item> cache = (ConcurrentHashMap<String, Item>) redisHandler.get(ItemRedisKeys.ITEM_MAP);
|
||||
if(null == cache) {
|
||||
cache = new ConcurrentHashMap<String, Item>();
|
||||
}
|
||||
cache.put(entity.getSymbol(), entity);
|
||||
redisHandler.setSync(ItemRedisKeys.ITEM_MAP, cache);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ItemLever> findLever(String item_id) {
|
||||
Map<String, ItemLever> map = (Map<String, ItemLever>)redisHandler.get(ItemRedisKeys.ITEM_LEVER_ID + item_id);
|
||||
if (map != null) {
|
||||
List<ItemLever> list = new ArrayList<ItemLever>(map.values());
|
||||
Collections.sort(list, new Comparator<ItemLever>() {//按倍率排序
|
||||
@Override
|
||||
public int compare(ItemLever arg0, ItemLever arg1) {
|
||||
// TODO Auto-generated method stub
|
||||
return new Double(arg0.getLever_rate()).compareTo(arg1.getLever_rate());
|
||||
}
|
||||
});
|
||||
return list;
|
||||
}
|
||||
return new ArrayList<ItemLever>();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取所有币种名称
|
||||
*/
|
||||
@Override
|
||||
public List<String> cacheGetAllSymbol() {
|
||||
List<Item> cacheGetAll = cacheGetAll();
|
||||
List<String> data = new ArrayList<String>();
|
||||
for (Item item : cacheGetAll) {
|
||||
data.add(item.getSymbol());
|
||||
}
|
||||
return data;
|
||||
}
|
||||
|
||||
public void setRedisHandler(RedisHandler redisHandler) {
|
||||
this.redisHandler = redisHandler;
|
||||
}
|
||||
|
||||
public void setRedisLocalCache(RedisLocalCache redisLocalCache) {
|
||||
this.redisLocalCache = redisLocalCache;
|
||||
}
|
||||
public RedisHandler getRedisHandler() {
|
||||
return redisHandler;
|
||||
}
|
||||
|
||||
}
|
||||
167
comm/Item/src/project/item/internal/ItemUserOptionalServiceImpl.java
Executable file
167
comm/Item/src/project/item/internal/ItemUserOptionalServiceImpl.java
Executable file
@@ -0,0 +1,167 @@
|
||||
package project.item.internal;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import org.apache.commons.collections.CollectionUtils;
|
||||
import org.springframework.orm.hibernate5.support.HibernateDaoSupport;
|
||||
|
||||
import com.mysql.cj.util.StringUtils;
|
||||
|
||||
import project.data.DataService;
|
||||
import project.data.model.Realtime;
|
||||
import project.item.ItemRedisKeys;
|
||||
import project.item.ItemUserOptionalService;
|
||||
import project.item.model.ItemUserOptional;
|
||||
import project.redis.RedisHandler;
|
||||
|
||||
public class ItemUserOptionalServiceImpl extends HibernateDaoSupport implements ItemUserOptionalService {
|
||||
|
||||
private RedisHandler redisHandler;
|
||||
private DataService dataService;
|
||||
|
||||
@Override
|
||||
public List<ItemUserOptional> cacheListByPartyId(String partyId) {
|
||||
Map<String, ItemUserOptional> map = (Map<String, ItemUserOptional>) redisHandler
|
||||
.get(ItemRedisKeys.ITEM_USER_OPTIONAL_MAP_PARTY_ID + partyId);
|
||||
return map == null ? null : new ArrayList<ItemUserOptional>(map.values());
|
||||
}
|
||||
|
||||
public List<Map<String, Object>> cacheListDataByPartyId(String partyId, String symbol) {
|
||||
List<Map<String, Object>> result = new ArrayList<Map<String, Object>>();
|
||||
List<ItemUserOptional> list = new ArrayList<>();
|
||||
List<ItemUserOptional> lists = cacheListByPartyId(partyId);
|
||||
if (!StringUtils.isNullOrEmpty(symbol)) {
|
||||
for (ItemUserOptional op : lists) {
|
||||
if (op.getSymbol().equals(symbol)) {
|
||||
list.add(op);
|
||||
}
|
||||
}
|
||||
}else {
|
||||
list = lists;
|
||||
}
|
||||
if (CollectionUtils.isEmpty(list))
|
||||
return result;
|
||||
|
||||
List<String> symbols = new ArrayList<String>();
|
||||
for (ItemUserOptional itemUserOptional : list) {
|
||||
symbols.add(itemUserOptional.getSymbol());
|
||||
}
|
||||
if (CollectionUtils.isEmpty(symbols))
|
||||
return new ArrayList<Map<String, Object>>();
|
||||
|
||||
List<Realtime> realtimes = dataService.realtime(String.join(",", symbols));
|
||||
for (Realtime realtime : realtimes) {
|
||||
Map<String, Object> bind = bind(realtime);
|
||||
result.add(bind);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
// public List<Map<String, Object>> cacheListDataByPartyId(String partyId, String module) {
|
||||
// if (!StringUtils.isEmpty(module) && !Constants.OPTIONAL_MODULE.contains(module)) {
|
||||
// throw new BusinessException("参数错误");
|
||||
// }
|
||||
// List<Map<String, Object>> result = new ArrayList<Map<String, Object>>();
|
||||
// List<ItemUserOptional> list = cacheListByPartyId(partyId);
|
||||
// if (CollectionUtils.isEmpty(list))
|
||||
// return result;
|
||||
//
|
||||
// List<String> symbols = new ArrayList<String>();
|
||||
// for (ItemUserOptional itemUserOptional : list) {
|
||||
// // 空的模块,或者存在的模块
|
||||
// if (StringUtils.isEmpty(module) || module.equals(itemUserOptional.getModule())) {
|
||||
// symbols.add(itemUserOptional.getSymbol());
|
||||
// }
|
||||
// }
|
||||
// if (CollectionUtils.isEmpty(symbols))
|
||||
// return new ArrayList<Map<String, Object>>();
|
||||
//
|
||||
// List<Realtime> realtimes = dataService.realtime(String.join(",", symbols));
|
||||
// for (Realtime realtime : realtimes) {
|
||||
// Map<String, Object> bind = bind(realtime);
|
||||
// bind.put("module", module);// 未处理
|
||||
// }
|
||||
// return result;
|
||||
// }
|
||||
|
||||
public Map<String, Object> bind(Realtime realtime) {
|
||||
Map<String, Object> map = new HashMap<String, Object>();
|
||||
map.put("amount", String.valueOf(realtime.getAmount()));
|
||||
map.put("change_ratio", realtime.getChange_ratio());
|
||||
map.put("close", String.valueOf(realtime.getClose()));
|
||||
map.put("current_time", realtime.getCurrent_time());
|
||||
map.put("high", String.valueOf(realtime.getHigh()));
|
||||
map.put("low", String.valueOf(realtime.getLow()));
|
||||
map.put("name", realtime.getName());
|
||||
map.put("open", String.valueOf(realtime.getOpen()));
|
||||
map.put("symbol", String.valueOf(realtime.getSymbol()));
|
||||
map.put("ts", realtime.getTs());
|
||||
map.put("volume", String.valueOf(realtime.getVolume()));
|
||||
return map;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(ItemUserOptional entity) {
|
||||
this.getHibernateTemplate().update(entity);
|
||||
Map<String, ItemUserOptional> map = (Map<String, ItemUserOptional>) redisHandler
|
||||
.get(ItemRedisKeys.ITEM_USER_OPTIONAL_MAP_PARTY_ID + entity.getPartyId().toString());
|
||||
|
||||
if (map == null) {
|
||||
map = new ConcurrentHashMap<String, ItemUserOptional>();
|
||||
}
|
||||
map.put(entity.getSymbol(), entity);
|
||||
redisHandler.setSync(ItemRedisKeys.ITEM_USER_OPTIONAL_MAP_PARTY_ID + entity.getPartyId().toString(), map);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void save(ItemUserOptional entity) {
|
||||
Map<String, ItemUserOptional> map = (Map<String, ItemUserOptional>) redisHandler
|
||||
.get(ItemRedisKeys.ITEM_USER_OPTIONAL_MAP_PARTY_ID + entity.getPartyId().toString());
|
||||
if (map == null) {
|
||||
map = new ConcurrentHashMap<String, ItemUserOptional>();
|
||||
} else if (map.containsKey(entity.getSymbol())) {
|
||||
// 已经添加的则直接返回
|
||||
return;
|
||||
}
|
||||
this.getHibernateTemplate().save(entity);
|
||||
map.put(entity.getSymbol(), entity);
|
||||
redisHandler.setSync(ItemRedisKeys.ITEM_USER_OPTIONAL_MAP_PARTY_ID + entity.getPartyId().toString(), map);
|
||||
}
|
||||
|
||||
public void delete(String partyId, String symbol) {
|
||||
Map<String, ItemUserOptional> map = (Map<String, ItemUserOptional>) redisHandler
|
||||
.get(ItemRedisKeys.ITEM_USER_OPTIONAL_MAP_PARTY_ID + partyId);
|
||||
|
||||
if (map != null && !map.isEmpty()) {
|
||||
ItemUserOptional itemUserOptional = map.remove(symbol);
|
||||
if (itemUserOptional == null)
|
||||
return;
|
||||
this.getHibernateTemplate().delete(itemUserOptional);
|
||||
redisHandler.setSync(ItemRedisKeys.ITEM_USER_OPTIONAL_MAP_PARTY_ID + partyId, map);
|
||||
}
|
||||
}
|
||||
|
||||
public void delete(ItemUserOptional entity) {
|
||||
this.getHibernateTemplate().delete(entity);
|
||||
Map<String, ItemUserOptional> map = (Map<String, ItemUserOptional>) redisHandler
|
||||
.get(ItemRedisKeys.ITEM_USER_OPTIONAL_MAP_PARTY_ID + entity.getPartyId().toString());
|
||||
|
||||
if (map != null && !map.isEmpty()) {
|
||||
map.remove(entity.getSymbol());
|
||||
redisHandler.setSync(ItemRedisKeys.ITEM_USER_OPTIONAL_MAP_PARTY_ID + entity.getPartyId().toString(), map);
|
||||
}
|
||||
}
|
||||
|
||||
public void setRedisHandler(RedisHandler redisHandler) {
|
||||
this.redisHandler = redisHandler;
|
||||
}
|
||||
|
||||
public void setDataService(DataService dataService) {
|
||||
this.dataService = dataService;
|
||||
}
|
||||
|
||||
}
|
||||
51
comm/Item/src/project/item/model/Item.hbm.xml
Executable file
51
comm/Item/src/project/item/model/Item.hbm.xml
Executable file
@@ -0,0 +1,51 @@
|
||||
<?xml version="1.0"?>
|
||||
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
|
||||
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
|
||||
<hibernate-mapping>
|
||||
<class name="project.item.model.Item" table="T_ITEM">
|
||||
<id name="id" type="java.lang.String">
|
||||
<column name="UUID" />
|
||||
<generator class="uuid.hex" />
|
||||
</id>
|
||||
<property name="name" type="java.lang.String">
|
||||
<column name="NAME" />
|
||||
</property>
|
||||
<property name="symbol" type="java.lang.String" update="false">
|
||||
<column name="SYMBOL" />
|
||||
</property>
|
||||
<property name="symbol_data" type="java.lang.String" update="false">
|
||||
<column name="SYMBOL_DATA" />
|
||||
</property>
|
||||
<property name="pips" type="double">
|
||||
<column name="PIPS" />
|
||||
</property>
|
||||
<property name="pips_amount" type="double">
|
||||
<column name="PIPS_AMOUNT" />
|
||||
</property>
|
||||
<property name="adjustment_value" type="double">
|
||||
<column name="ADJUSTMENT_VALUE" />
|
||||
</property>
|
||||
<property name="unit_amount" type="double">
|
||||
<column name="UNIT_AMOUNT" />
|
||||
</property>
|
||||
<property name="unit_fee" type="double">
|
||||
<column name="UNIT_FEE" />
|
||||
</property>
|
||||
<property name="market" type="java.lang.String" update="false">
|
||||
<column name="MARKET" />
|
||||
</property>
|
||||
<property name="decimals" type="java.lang.Integer">
|
||||
<column name="DECIMALS" />
|
||||
</property>
|
||||
<property name="multiple" type="double">
|
||||
<column name="MULTIPLE" />
|
||||
</property>
|
||||
<property name="borrowing_rate" type="double">
|
||||
<column name="BORROWING_RATE" />
|
||||
</property>
|
||||
<property name="symbolFullName" type="java.lang.String">
|
||||
<column name="SYMBOL_FULL_NAME" />
|
||||
</property>
|
||||
|
||||
</class>
|
||||
</hibernate-mapping>
|
||||
204
comm/Item/src/project/item/model/Item.java
Executable file
204
comm/Item/src/project/item/model/Item.java
Executable file
@@ -0,0 +1,204 @@
|
||||
package project.item.model;
|
||||
|
||||
import kernel.bo.EntityObject;
|
||||
|
||||
/**
|
||||
* 产品
|
||||
*
|
||||
*/
|
||||
public class Item extends EntityObject {
|
||||
|
||||
private static final long serialVersionUID = 4857935723215615892L;
|
||||
/**
|
||||
* 交割合约
|
||||
*/
|
||||
public static final String DELIVERY_CONTRACT = "DELIVERY";
|
||||
/**
|
||||
* 永续合约
|
||||
*/
|
||||
public static final String FOREVER_CONTRACT = "FOREVER";
|
||||
|
||||
/**
|
||||
* 名称
|
||||
*/
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 代码
|
||||
*/
|
||||
private String symbol;
|
||||
|
||||
/**
|
||||
* 数据源编码
|
||||
*/
|
||||
private String symbol_data;
|
||||
|
||||
/**
|
||||
* 最小浮动
|
||||
*/
|
||||
private double pips;
|
||||
|
||||
private String pips_str;
|
||||
|
||||
/**
|
||||
* 最小浮动金额(以交易金额计算)
|
||||
*/
|
||||
private double pips_amount;
|
||||
|
||||
private String pips_amount_str;
|
||||
|
||||
private Double adjustment_value = new Double(0);
|
||||
|
||||
/**
|
||||
* 每手金额
|
||||
*/
|
||||
private double unit_amount;
|
||||
|
||||
/**
|
||||
* 每手的手续费
|
||||
*/
|
||||
private double unit_fee;
|
||||
|
||||
/**
|
||||
* 市场
|
||||
*/
|
||||
private String market;
|
||||
/**
|
||||
* 小数位精度
|
||||
*/
|
||||
private Integer decimals;
|
||||
/**
|
||||
* 交易量放大倍数,如果为0或者空不进行操作,否则乘以倍数
|
||||
*/
|
||||
private double multiple = new Double(0);
|
||||
/**
|
||||
* 借贷利率
|
||||
*/
|
||||
private double borrowing_rate;
|
||||
|
||||
/**
|
||||
* 币种全称
|
||||
*/
|
||||
private String symbolFullName;
|
||||
|
||||
public String getSymbolFullName() {
|
||||
return symbolFullName;
|
||||
}
|
||||
|
||||
public void setSymbolFullName(String symbolFullName) {
|
||||
this.symbolFullName = symbolFullName;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getSymbol() {
|
||||
return symbol;
|
||||
}
|
||||
|
||||
public void setSymbol(String symbol) {
|
||||
this.symbol = symbol;
|
||||
}
|
||||
|
||||
public double getPips() {
|
||||
return pips;
|
||||
}
|
||||
|
||||
public void setPips(double pips) {
|
||||
this.pips = pips;
|
||||
}
|
||||
|
||||
public double getPips_amount() {
|
||||
return pips_amount;
|
||||
}
|
||||
|
||||
public void setPips_amount(double pips_amount) {
|
||||
this.pips_amount = pips_amount;
|
||||
}
|
||||
|
||||
public Double getAdjustment_value() {
|
||||
return adjustment_value;
|
||||
}
|
||||
|
||||
public void setAdjustment_value(Double adjustment_value) {
|
||||
this.adjustment_value = adjustment_value;
|
||||
}
|
||||
|
||||
public String getMarket() {
|
||||
return market;
|
||||
}
|
||||
|
||||
public void setMarket(String market) {
|
||||
this.market = market;
|
||||
}
|
||||
|
||||
public String getSymbol_data() {
|
||||
return symbol_data;
|
||||
}
|
||||
|
||||
public void setSymbol_data(String symbol_data) {
|
||||
this.symbol_data = symbol_data;
|
||||
}
|
||||
|
||||
public double getUnit_amount() {
|
||||
return unit_amount;
|
||||
}
|
||||
|
||||
public void setUnit_amount(double unit_amount) {
|
||||
this.unit_amount = unit_amount;
|
||||
}
|
||||
|
||||
public double getUnit_fee() {
|
||||
return unit_fee;
|
||||
}
|
||||
|
||||
public void setUnit_fee(double unit_fee) {
|
||||
this.unit_fee = unit_fee;
|
||||
}
|
||||
|
||||
public Integer getDecimals() {
|
||||
return decimals;
|
||||
}
|
||||
|
||||
public void setDecimals(Integer decimals) {
|
||||
this.decimals = decimals;
|
||||
}
|
||||
|
||||
public String getPips_str() {
|
||||
return pips_str;
|
||||
}
|
||||
|
||||
public void setPips_str(String pips_str) {
|
||||
this.pips_str = pips_str;
|
||||
}
|
||||
|
||||
public double getMultiple() {
|
||||
return multiple;
|
||||
}
|
||||
|
||||
public void setMultiple(double multiple) {
|
||||
this.multiple = multiple;
|
||||
}
|
||||
|
||||
public double getBorrowing_rate() {
|
||||
return borrowing_rate;
|
||||
}
|
||||
|
||||
public void setBorrowing_rate(double borrowing_rate) {
|
||||
this.borrowing_rate = borrowing_rate;
|
||||
}
|
||||
|
||||
public String getPips_amount_str() {
|
||||
return pips_amount_str;
|
||||
}
|
||||
|
||||
public void setPips_amount_str(String pips_amount_str) {
|
||||
this.pips_amount_str = pips_amount_str;
|
||||
}
|
||||
|
||||
}
|
||||
17
comm/Item/src/project/item/model/ItemLever.hbm.xml
Executable file
17
comm/Item/src/project/item/model/ItemLever.hbm.xml
Executable file
@@ -0,0 +1,17 @@
|
||||
<?xml version="1.0"?>
|
||||
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
|
||||
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
|
||||
<hibernate-mapping>
|
||||
<class name="project.item.model.ItemLever" table="T_ITEM_LEVERAGE">
|
||||
<id name="id" type="java.lang.String">
|
||||
<column name="UUID" />
|
||||
<generator class="uuid.hex" />
|
||||
</id>
|
||||
<property name="item_id" type="java.lang.String">
|
||||
<column name="ITEM_ID" />
|
||||
</property>
|
||||
<property name="lever_rate" type="double">
|
||||
<column name="LEVER_RATE" />
|
||||
</property>
|
||||
</class>
|
||||
</hibernate-mapping>
|
||||
33
comm/Item/src/project/item/model/ItemLever.java
Executable file
33
comm/Item/src/project/item/model/ItemLever.java
Executable file
@@ -0,0 +1,33 @@
|
||||
package project.item.model;
|
||||
|
||||
import kernel.bo.EntityObject;
|
||||
|
||||
/**
|
||||
*
|
||||
* 杠杆定义
|
||||
*/
|
||||
public class ItemLever extends EntityObject {
|
||||
private static final long serialVersionUID = -6464213099743653537L;
|
||||
private String item_id;
|
||||
/**
|
||||
* 杠杆倍数
|
||||
*/
|
||||
private double lever_rate;
|
||||
|
||||
public String getItem_id() {
|
||||
return item_id;
|
||||
}
|
||||
|
||||
public void setItem_id(String item_id) {
|
||||
this.item_id = item_id;
|
||||
}
|
||||
|
||||
public double getLever_rate() {
|
||||
return lever_rate;
|
||||
}
|
||||
|
||||
public void setLever_rate(double lever_rate) {
|
||||
this.lever_rate = lever_rate;
|
||||
}
|
||||
|
||||
}
|
||||
18
comm/Item/src/project/item/model/ItemUserOptional.hbm.xml
Executable file
18
comm/Item/src/project/item/model/ItemUserOptional.hbm.xml
Executable file
@@ -0,0 +1,18 @@
|
||||
<?xml version="1.0"?>
|
||||
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
|
||||
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
|
||||
<hibernate-mapping>
|
||||
<class name="project.item.model.ItemUserOptional" table="T_ITEM_USER_OPTIONAL">
|
||||
<id name="id" type="java.lang.String">
|
||||
<column name="UUID" />
|
||||
<generator class="uuid.hex" />
|
||||
</id>
|
||||
<property name="partyId" type="java.lang.String">
|
||||
<column name="PARTY_ID" />
|
||||
</property>
|
||||
<property name="symbol" type="java.lang.String" >
|
||||
<column name="SYMBOL" />
|
||||
</property>
|
||||
|
||||
</class>
|
||||
</hibernate-mapping>
|
||||
36
comm/Item/src/project/item/model/ItemUserOptional.java
Executable file
36
comm/Item/src/project/item/model/ItemUserOptional.java
Executable file
@@ -0,0 +1,36 @@
|
||||
package project.item.model;
|
||||
|
||||
import kernel.bo.EntityObject;
|
||||
|
||||
/**
|
||||
* 产品
|
||||
*
|
||||
*/
|
||||
public class ItemUserOptional extends EntityObject {
|
||||
|
||||
private static final long serialVersionUID = 4857935723215615892L;
|
||||
|
||||
private String partyId;
|
||||
|
||||
/**
|
||||
* 代码
|
||||
*/
|
||||
private String symbol;
|
||||
|
||||
public String getPartyId() {
|
||||
return partyId;
|
||||
}
|
||||
|
||||
public String getSymbol() {
|
||||
return symbol;
|
||||
}
|
||||
|
||||
public void setPartyId(String partyId) {
|
||||
this.partyId = partyId;
|
||||
}
|
||||
|
||||
public void setSymbol(String symbol) {
|
||||
this.symbol = symbol;
|
||||
}
|
||||
|
||||
}
|
||||
901
comm/Item/src/project/web/admin/AdminItemController.java
Executable file
901
comm/Item/src/project/web/admin/AdminItemController.java
Executable file
@@ -0,0 +1,901 @@
|
||||
package project.web.admin;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.List;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.security.providers.encoding.PasswordEncoder;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.servlet.ModelAndView;
|
||||
|
||||
import kernel.exception.BusinessException;
|
||||
import kernel.util.Arith;
|
||||
import kernel.util.PropertiesUtil;
|
||||
import kernel.util.StringUtils;
|
||||
import kernel.web.PageActionSupport;
|
||||
import project.Constants;
|
||||
import project.data.internal.KlineInitService;
|
||||
import project.item.AdminItemService;
|
||||
import project.item.ItemService;
|
||||
import project.item.model.Item;
|
||||
import project.log.Log;
|
||||
import project.log.LogService;
|
||||
import project.syspara.Syspara;
|
||||
import project.syspara.SysparaService;
|
||||
import security.SecUser;
|
||||
import security.internal.SecUserService;
|
||||
|
||||
/**
|
||||
* 永续合约管理
|
||||
*/
|
||||
@RestController
|
||||
public class AdminItemController extends PageActionSupport {
|
||||
|
||||
private Logger logger = LogManager.getLogger(AdminItemController.class);
|
||||
|
||||
@Autowired
|
||||
private AdminItemService adminItemService;
|
||||
@Autowired
|
||||
private ItemService itemService;
|
||||
@Autowired
|
||||
private KlineInitService klineInitService;
|
||||
@Autowired
|
||||
private SysparaService sysparaService;
|
||||
@Autowired
|
||||
protected LogService logService;
|
||||
@Autowired
|
||||
protected SecUserService secUserService;
|
||||
@Autowired
|
||||
protected PasswordEncoder passwordEncoder;
|
||||
|
||||
private final String action = "normal/adminItemAction!";
|
||||
|
||||
/**
|
||||
* 获取 列表
|
||||
*/
|
||||
@RequestMapping(value = action + "list.action")
|
||||
public ModelAndView list(HttpServletRequest request) {
|
||||
String pageNo = request.getParameter("pageNo");
|
||||
String message = request.getParameter("message");
|
||||
String error = request.getParameter("error");
|
||||
String para_symbol = request.getParameter("para_symbol");
|
||||
|
||||
ModelAndView modelAndView = new ModelAndView();
|
||||
modelAndView.setViewName("item_list");
|
||||
|
||||
try {
|
||||
|
||||
this.checkAndSetPageNo(pageNo);
|
||||
|
||||
this.pageSize = 20;
|
||||
|
||||
this.page = this.adminItemService.pagedQuery(this.pageNo, this.pageSize, Item.FOREVER_CONTRACT,
|
||||
para_symbol);
|
||||
for (Item item : (List<Item>) this.page.getElements()) {
|
||||
item.setPips_str(new BigDecimal(String.valueOf(item.getPips())).toPlainString());
|
||||
item.setPips_amount_str(new BigDecimal(String.valueOf(item.getPips_amount())).toPlainString());
|
||||
}
|
||||
|
||||
} catch (BusinessException e) {
|
||||
modelAndView.addObject("error", e.getMessage());
|
||||
return modelAndView;
|
||||
} catch (Throwable t) {
|
||||
logger.error(" error ", t);
|
||||
modelAndView.addObject("error", "[ERROR] " + t.getMessage());
|
||||
return modelAndView;
|
||||
}
|
||||
|
||||
modelAndView.addObject("pageNo", this.pageNo);
|
||||
modelAndView.addObject("pageSize", this.pageSize);
|
||||
modelAndView.addObject("page", this.page);
|
||||
modelAndView.addObject("message", message);
|
||||
modelAndView.addObject("error", error);
|
||||
modelAndView.addObject("para_symbol", para_symbol);
|
||||
return modelAndView;
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增 页面
|
||||
*/
|
||||
@RequestMapping(value = action + "toAdd.action")
|
||||
public ModelAndView toAdd(HttpServletRequest request) {
|
||||
|
||||
String basePath = PropertiesUtil.getProperty("admin_url");
|
||||
basePath = this.getPath(request);
|
||||
|
||||
ModelAndView modelAndView = new ModelAndView();
|
||||
modelAndView.addObject(basePath);
|
||||
modelAndView.setViewName("item_add");
|
||||
return modelAndView;
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增
|
||||
* name 名称
|
||||
* symbol 代码
|
||||
* symbol_data 数据源编码
|
||||
* pips 最小浮动
|
||||
* pips_amount 最小浮动金额(以交易金额计算)
|
||||
* unit_amount 每手金额
|
||||
* decimals 精度
|
||||
* unit_fee 每手的手续费
|
||||
*/
|
||||
@RequestMapping(value = action + "add.action")
|
||||
public ModelAndView add(HttpServletRequest request) {
|
||||
String name = request.getParameter("name");
|
||||
String symbol = request.getParameter("symbol");
|
||||
String symbol_data = request.getParameter("symbol_data");
|
||||
String pips = request.getParameter("pips");
|
||||
String pips_amount = request.getParameter("pips_amount");
|
||||
String unit_amount = request.getParameter("unit_amount");
|
||||
String decimals = request.getParameter("decimals");
|
||||
String unit_fee = request.getParameter("unit_fee");
|
||||
|
||||
ModelAndView modelAndView = new ModelAndView();
|
||||
|
||||
try {
|
||||
|
||||
String error = this.validateAdd(name, symbol, symbol_data, pips, pips_amount, unit_amount, decimals, unit_fee);
|
||||
if (!StringUtils.isNullOrEmpty(error)) {
|
||||
throw new BusinessException(error);
|
||||
}
|
||||
|
||||
Item item = new Item();
|
||||
item.setName(name);
|
||||
item.setSymbol(symbol);
|
||||
item.setSymbol_data(symbol_data);
|
||||
item.setPips(Double.valueOf(pips));
|
||||
item.setPips_amount(Double.valueOf(pips_amount));
|
||||
item.setUnit_amount(Double.valueOf(unit_amount));
|
||||
item.setDecimals(Integer.valueOf(decimals));
|
||||
item.setUnit_fee(Double.valueOf(unit_fee));
|
||||
|
||||
} catch (BusinessException e) {
|
||||
modelAndView.addObject("error", e.getMessage());
|
||||
modelAndView.addObject("name", name);
|
||||
modelAndView.addObject("symbol", symbol);
|
||||
modelAndView.addObject("symbol_data", symbol_data);
|
||||
modelAndView.addObject("pips", pips);
|
||||
modelAndView.addObject("pips_amount", pips_amount);
|
||||
modelAndView.addObject("unit_amount", unit_amount);
|
||||
modelAndView.addObject("decimals", decimals);
|
||||
modelAndView.addObject("unit_fee", unit_fee);
|
||||
modelAndView.setViewName("item_add");
|
||||
return modelAndView;
|
||||
} catch (Throwable t) {
|
||||
logger.error(" error ", t);
|
||||
modelAndView.addObject("error", "[ERROR] " + t.getMessage());
|
||||
modelAndView.addObject("name", name);
|
||||
modelAndView.addObject("symbol", symbol);
|
||||
modelAndView.addObject("symbol_data", symbol_data);
|
||||
modelAndView.addObject("pips", pips);
|
||||
modelAndView.addObject("pips_amount", pips_amount);
|
||||
modelAndView.addObject("unit_amount", unit_amount);
|
||||
modelAndView.addObject("decimals", decimals);
|
||||
modelAndView.addObject("unit_fee", unit_fee);
|
||||
modelAndView.setViewName("item_add");
|
||||
return modelAndView;
|
||||
}
|
||||
|
||||
modelAndView.addObject("message", "操作成功");
|
||||
modelAndView.setViewName("redirect:/" + action + "list.action");
|
||||
return modelAndView;
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新 页面
|
||||
*/
|
||||
@RequestMapping(value = action + "toUpdate.action")
|
||||
public ModelAndView toUpdate(HttpServletRequest request) {
|
||||
String id = request.getParameter("id");
|
||||
|
||||
ModelAndView modelAndView = new ModelAndView();
|
||||
|
||||
try {
|
||||
|
||||
Item item = this.adminItemService.get(id);
|
||||
|
||||
modelAndView.addObject("id", id);
|
||||
modelAndView.addObject("name", item.getName());
|
||||
modelAndView.addObject("symbol", item.getSymbol());
|
||||
modelAndView.addObject("symbol_data", item.getSymbol_data());
|
||||
modelAndView.addObject("pips", item.getPips());
|
||||
modelAndView.addObject("pips_str", new BigDecimal(String.valueOf(item.getPips())).toPlainString());
|
||||
modelAndView.addObject("pips_amount", item.getPips_amount());
|
||||
modelAndView.addObject("unit_amount", item.getUnit_amount());
|
||||
modelAndView.addObject("unit_fee", item.getUnit_fee());
|
||||
modelAndView.addObject("decimals", null == item.getDecimals() ? 0 : item.getDecimals());
|
||||
|
||||
} catch (BusinessException e) {
|
||||
modelAndView.addObject("error", e.getMessage());
|
||||
modelAndView.setViewName("redirect:/" + action + "list.action");
|
||||
return modelAndView;
|
||||
} catch (Throwable t) {
|
||||
logger.error(" error ", t);
|
||||
modelAndView.addObject("error", "[ERROR] " + t.getMessage());
|
||||
modelAndView.setViewName("redirect:/" + action + "list.action");
|
||||
return modelAndView;
|
||||
}
|
||||
|
||||
modelAndView.setViewName("item_update");
|
||||
return modelAndView;
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新
|
||||
* name 名称
|
||||
* symbol 代码
|
||||
* symbol_data 数据源编码
|
||||
* pips 最小浮动
|
||||
* pips_amount 最小浮动金额(以交易金额计算)
|
||||
* unit_amount 每手金额
|
||||
* decimals 精度
|
||||
* unit_fee 每手的手续费
|
||||
* multiple 交易量放大倍数,如果为0或者空不进行操作,否则乘以倍数
|
||||
* login_safeword 登录人资金密码
|
||||
*/
|
||||
@RequestMapping(value = action + "update.action")
|
||||
public ModelAndView update(HttpServletRequest request) {
|
||||
String id = request.getParameter("id");
|
||||
String name = request.getParameter("name");
|
||||
String symbol = request.getParameter("symbol");
|
||||
String symbol_data = request.getParameter("symbol_data");
|
||||
String pips = request.getParameter("pips");
|
||||
String pips_str = request.getParameter("pips_str");
|
||||
String pips_amount = request.getParameter("pips_amount");
|
||||
String unit_amount = request.getParameter("unit_amount");
|
||||
String unit_fee = request.getParameter("unit_fee");
|
||||
String decimals = request.getParameter("decimals");
|
||||
String multiple = request.getParameter("multiple");
|
||||
String login_safeword = request.getParameter("login_safeword");
|
||||
|
||||
ModelAndView modelAndView = new ModelAndView();
|
||||
|
||||
try {
|
||||
|
||||
if (StringUtils.isEmptyString(multiple)) {
|
||||
multiple = "0";
|
||||
}
|
||||
|
||||
String error = this.validate(unit_fee, unit_amount, pips, pips_amount, multiple, decimals);
|
||||
if (!StringUtils.isNullOrEmpty(error)) {
|
||||
throw new BusinessException(error);
|
||||
}
|
||||
|
||||
double unit_fee_double = Double.valueOf(unit_fee).doubleValue();
|
||||
double unit_amount_double = Double.valueOf(unit_amount).doubleValue();
|
||||
double pips_double = Double.valueOf(pips).doubleValue();
|
||||
double pips_amount_double = Double.valueOf(pips_amount).doubleValue();
|
||||
double multiple_double = Double.valueOf(multiple).doubleValue();
|
||||
int decimals_int = Integer.valueOf(decimals).intValue();
|
||||
|
||||
Item item = this.adminItemService.get(id);
|
||||
String old_item_name = item.getName();
|
||||
String old_item_symbol = item.getSymbol();
|
||||
double old_multiple = item.getMultiple();
|
||||
double old_unit_amount = item.getUnit_amount();
|
||||
double old_unit_fee = item.getUnit_fee();
|
||||
// pips 最小变动单位
|
||||
double old_pips = item.getPips();
|
||||
// pips_amount最小变动单位的盈亏金额
|
||||
double old_pips_amount = item.getPips_amount();
|
||||
|
||||
String username_login = this.getUsername_login();
|
||||
|
||||
SecUser sec = this.secUserService.findUserByLoginName(this.getUsername_login());
|
||||
this.checkLoginSafeword(sec, username_login, login_safeword);
|
||||
|
||||
item.setName(name);
|
||||
item.setUnit_fee(unit_fee_double);
|
||||
item.setUnit_amount(unit_amount_double);
|
||||
item.setPips(pips_double);
|
||||
item.setDecimals(decimals_int);
|
||||
item.setPips_amount(pips_amount_double);
|
||||
this.adminItemService.update(item);
|
||||
|
||||
Log log = new Log();
|
||||
log.setCategory(Constants.LOG_CATEGORY_OPERATION);
|
||||
log.setUsername(username_login);
|
||||
log.setOperator(username_login);
|
||||
log.setLog("管理员手动修改永续合约配置," + "原名称[" + old_item_name + "],原代码[" + old_item_symbol + "]," + "原交易量倍数["
|
||||
+ old_multiple + "],原每手价格[" + old_unit_amount + "]," + "原手续费[" + old_unit_fee + "],原最小变动单位["
|
||||
+ old_pips + "]," + "原最小变动单位的盈亏金额[" + old_pips_amount + "]," + "修改后名称[" + name + "],修改后代码[" + symbol
|
||||
+ "]," + "修改后交易量倍数[" + multiple_double + "],原每手价格[" + unit_amount + "]," + "修改后手续费[" + unit_fee
|
||||
+ "],修改后最小变动单位[" + pips + "]," + "修改后最小变动单位的盈亏金额[" + pips_amount + "]," + "ip:["
|
||||
+ this.getIp(getRequest()) + "]");
|
||||
logService.saveSync(log);
|
||||
|
||||
} catch (BusinessException e) {
|
||||
modelAndView.addObject("error", e.getMessage());
|
||||
modelAndView.addObject("id", id);
|
||||
modelAndView.addObject("name", name);
|
||||
modelAndView.addObject("symbol", symbol);
|
||||
modelAndView.addObject("symbol_data", symbol_data);
|
||||
modelAndView.addObject("pips", pips);
|
||||
modelAndView.addObject("pips_str", pips_str);
|
||||
modelAndView.addObject("pips_amount", pips_amount);
|
||||
modelAndView.addObject("unit_amount", unit_amount);
|
||||
modelAndView.addObject("unit_fee", unit_fee);
|
||||
modelAndView.addObject("decimals", decimals);
|
||||
modelAndView.addObject("multiple", multiple);
|
||||
modelAndView.setViewName("item_update");
|
||||
return modelAndView;
|
||||
} catch (Throwable t) {
|
||||
logger.error(" error ", t);
|
||||
modelAndView.addObject("error", "[ERROR] " + t.getMessage());
|
||||
modelAndView.addObject("id", id);
|
||||
modelAndView.addObject("name", name);
|
||||
modelAndView.addObject("symbol", symbol);
|
||||
modelAndView.addObject("symbol_data", symbol_data);
|
||||
modelAndView.addObject("pips", pips);
|
||||
modelAndView.addObject("pips_str", pips_str);
|
||||
modelAndView.addObject("pips_amount", pips_amount);
|
||||
modelAndView.addObject("unit_amount", unit_amount);
|
||||
modelAndView.addObject("unit_fee", unit_fee);
|
||||
modelAndView.addObject("decimals", decimals);
|
||||
modelAndView.addObject("multiple", multiple);
|
||||
modelAndView.setViewName("item_update");
|
||||
return modelAndView;
|
||||
}
|
||||
|
||||
modelAndView.addObject("message", "操作成功");
|
||||
modelAndView.setViewName("redirect:/" + action + "list.action");
|
||||
return modelAndView;
|
||||
}
|
||||
|
||||
/**
|
||||
* 配置 列表
|
||||
*/
|
||||
@RequestMapping(value = action + "listConfig.action")
|
||||
public ModelAndView listConfig(HttpServletRequest request) {
|
||||
String pageNo = request.getParameter("pageNo");
|
||||
String message = request.getParameter("message");
|
||||
String error = request.getParameter("error");
|
||||
String para_symbol = request.getParameter("para_symbol");
|
||||
|
||||
ModelAndView modelAndView = new ModelAndView();
|
||||
modelAndView.setViewName("item_config_list");
|
||||
|
||||
try {
|
||||
|
||||
this.checkAndSetPageNo(pageNo);
|
||||
|
||||
this.pageSize = 20;
|
||||
|
||||
this.page = this.adminItemService.pagedQuery(this.pageNo, this.pageSize, Item.FOREVER_CONTRACT, para_symbol);
|
||||
|
||||
for (Item item : (List<Item>) this.page.getElements()) {
|
||||
item.setPips_str(new BigDecimal(String.valueOf(item.getPips())).toPlainString());
|
||||
}
|
||||
|
||||
} catch (BusinessException e) {
|
||||
modelAndView.addObject("error", e.getMessage());
|
||||
return modelAndView;
|
||||
} catch (Throwable t) {
|
||||
logger.error(" error ", t);
|
||||
modelAndView.addObject("error", "[ERROR] " + t.getMessage());
|
||||
return modelAndView;
|
||||
}
|
||||
|
||||
modelAndView.addObject("pageNo", this.pageNo);
|
||||
modelAndView.addObject("pageSize", this.pageSize);
|
||||
modelAndView.addObject("page", this.page);
|
||||
modelAndView.addObject("message", message);
|
||||
modelAndView.addObject("error", error);
|
||||
modelAndView.addObject("para_symbol", para_symbol);
|
||||
return modelAndView;
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增 配置 页面
|
||||
*/
|
||||
@RequestMapping(value = action + "toAddConfig.action")
|
||||
public ModelAndView toAddConfig(HttpServletRequest request) {
|
||||
|
||||
String basePath = PropertiesUtil.getProperty("admin_url");
|
||||
basePath = this.getPath(request);
|
||||
|
||||
ModelAndView model = new ModelAndView();
|
||||
model.addObject(basePath);
|
||||
model.setViewName("item_config_add");
|
||||
return model;
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增 配置
|
||||
* name 名称
|
||||
* symbol 代码
|
||||
* symbol_data 数据源编码
|
||||
* decimals 精度
|
||||
* multiple 交易量放大倍数,如果为0或者空不进行操作,否则乘以倍数
|
||||
* login_safeword 登录人资金密码
|
||||
* borrowing_rate 借贷利率
|
||||
*/
|
||||
@RequestMapping(value = action + "addConfig.action")
|
||||
public ModelAndView addConfig(HttpServletRequest request) {
|
||||
String name = request.getParameter("name");
|
||||
String symbol = request.getParameter("symbol");
|
||||
String symbol_data = request.getParameter("symbol_data");
|
||||
String decimals = request.getParameter("decimals");
|
||||
String multiple = request.getParameter("multiple");
|
||||
String borrowing_rate = request.getParameter("borrowing_rate");
|
||||
String login_safeword = request.getParameter("login_safeword");
|
||||
|
||||
ModelAndView modelAndView = new ModelAndView();
|
||||
|
||||
try {
|
||||
|
||||
if (StringUtils.isEmptyString(multiple)) {
|
||||
multiple = "0";
|
||||
}
|
||||
|
||||
String error = this.validateAddConfig(name, symbol, symbol_data, decimals, multiple, borrowing_rate);
|
||||
if (!StringUtils.isNullOrEmpty(error)) {
|
||||
throw new BusinessException(error);
|
||||
}
|
||||
|
||||
int decimals_int = Integer.valueOf(decimals).intValue();
|
||||
double multiple_double = Double.valueOf(multiple).doubleValue();
|
||||
double borrowing_rate_double = Double.valueOf(borrowing_rate).doubleValue();
|
||||
|
||||
String username_login = this.getUsername_login();
|
||||
|
||||
SecUser sec = this.secUserService.findUserByLoginName(this.getUsername_login());
|
||||
this.checkLoginSafeword(sec, username_login, login_safeword);
|
||||
|
||||
Item item = new Item();
|
||||
item.setName(name);
|
||||
item.setSymbol(symbol);
|
||||
item.setSymbol_data(symbol_data);
|
||||
item.setDecimals(decimals_int);
|
||||
item.setMultiple(multiple_double);
|
||||
item.setBorrowing_rate(Arith.div(borrowing_rate_double, 100));
|
||||
this.adminItemService.save(item);
|
||||
|
||||
project.log.Log log = new project.log.Log();
|
||||
log.setCategory(Constants.LOG_CATEGORY_OPERATION);
|
||||
log.setUsername(username_login);
|
||||
log.setOperator(username_login);
|
||||
log.setLog("管理员手动添加行情品种,品种名称[" + name + "],品种代码[" + symbol + "],ip:[" + this.getIp(getRequest()) + "]");
|
||||
logService.saveSync(log);
|
||||
|
||||
} catch (BusinessException e) {
|
||||
modelAndView.addObject("error", e.getMessage());
|
||||
modelAndView.addObject("name", name);
|
||||
modelAndView.addObject("symbol", symbol);
|
||||
modelAndView.addObject("symbol_data", symbol_data);
|
||||
modelAndView.addObject("decimals", decimals);
|
||||
modelAndView.addObject("multiple", multiple);
|
||||
modelAndView.addObject("borrowing_rate", borrowing_rate);
|
||||
modelAndView.setViewName("item_config_add");
|
||||
return modelAndView;
|
||||
} catch (Throwable t) {
|
||||
logger.error(" error ", t);
|
||||
modelAndView.addObject("error", "[ERROR] " + t.getMessage());
|
||||
modelAndView.addObject("name", name);
|
||||
modelAndView.addObject("symbol", symbol);
|
||||
modelAndView.addObject("symbol_data", symbol_data);
|
||||
modelAndView.addObject("decimals", decimals);
|
||||
modelAndView.addObject("multiple", multiple);
|
||||
modelAndView.addObject("borrowing_rate", borrowing_rate);
|
||||
modelAndView.setViewName("item_config_add");
|
||||
return modelAndView;
|
||||
}
|
||||
|
||||
modelAndView.addObject("message", "操作成功");
|
||||
modelAndView.setViewName("redirect:/" + action + "listConfig.action");
|
||||
return modelAndView;
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新 配置 页面
|
||||
*/
|
||||
@RequestMapping(value = action + "toUpdateConfig.action")
|
||||
public ModelAndView toUpdateConfig(HttpServletRequest request) {
|
||||
String id = request.getParameter("id");
|
||||
|
||||
Item item = this.adminItemService.get(id);
|
||||
|
||||
ModelAndView modelAndView = new ModelAndView();
|
||||
modelAndView.addObject("id", id);
|
||||
modelAndView.addObject("name", item.getName());
|
||||
modelAndView.addObject("symbol", item.getSymbol());
|
||||
modelAndView.addObject("symbol_data", item.getSymbol_data());
|
||||
modelAndView.addObject("decimals", null == item.getDecimals() ? 0 : item.getDecimals());
|
||||
modelAndView.addObject("multiple", item.getMultiple());
|
||||
modelAndView.addObject("borrowing_rate", Arith.mul(item.getBorrowing_rate(), 100));
|
||||
modelAndView.setViewName("item_config_update");
|
||||
return modelAndView;
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新 配置
|
||||
* name 名称
|
||||
* symbol 代码
|
||||
* decimals 精度
|
||||
* multiple 交易量放大倍数,如果为0或者空不进行操作,否则乘以倍数
|
||||
* login_safeword 登录人资金密码
|
||||
* borrowing_rate 借贷利率
|
||||
*/
|
||||
@RequestMapping(value = action + "updateConfig.action")
|
||||
public ModelAndView updateConfig(HttpServletRequest request) {
|
||||
String id = request.getParameter("id");
|
||||
String name = request.getParameter("name");
|
||||
String symbol = request.getParameter("symbol");
|
||||
String decimals = request.getParameter("decimals");
|
||||
String multiple = request.getParameter("multiple");
|
||||
String borrowing_rate = request.getParameter("borrowing_rate");
|
||||
String login_safeword = request.getParameter("login_safeword");
|
||||
|
||||
ModelAndView modelAndView = new ModelAndView();
|
||||
|
||||
try {
|
||||
|
||||
Item item = this.adminItemService.get(id);
|
||||
String old_item_name = item.getName();
|
||||
String old_item_symbol = item.getSymbol();
|
||||
double old_multiple = item.getMultiple();
|
||||
double old_borrowing_rate = item.getBorrowing_rate();
|
||||
|
||||
String error = this.validateUpdateConfig(name, symbol, "null", decimals, multiple, borrowing_rate);
|
||||
if (!StringUtils.isNullOrEmpty(error)) {
|
||||
throw new BusinessException(error);
|
||||
}
|
||||
|
||||
int decimals_int = Integer.valueOf(decimals).intValue();
|
||||
double multiple_double = Double.valueOf(multiple).doubleValue();
|
||||
double borrowing_rate_double = Double.valueOf(borrowing_rate).doubleValue();
|
||||
|
||||
String username_login = this.getUsername_login();
|
||||
|
||||
SecUser sec = this.secUserService.findUserByLoginName(username_login);
|
||||
this.checkLoginSafeword(sec, username_login, login_safeword);
|
||||
|
||||
item.setName(name);
|
||||
item.setDecimals(decimals_int);
|
||||
item.setMultiple(multiple_double);
|
||||
item.setBorrowing_rate(Arith.div(borrowing_rate_double, 100));
|
||||
|
||||
this.adminItemService.update(item);
|
||||
|
||||
Log log = new Log();
|
||||
log.setCategory(Constants.LOG_CATEGORY_OPERATION);
|
||||
log.setUsername(username_login);
|
||||
log.setOperator(username_login);
|
||||
log.setLog("管理员手动修改行情品种," + "原品种名称[" + old_item_name + "],原品种代码[" + old_item_symbol + "],原品种交易量倍数["
|
||||
+ old_multiple + "]," + "原借贷利率[" + old_borrowing_rate + "]," + "修改后品种名称[" + name + "],修改后品种代码["
|
||||
+ symbol + "],修改后品种交易量倍数[" + multiple + "]," + "修改后借贷利率[" + item.getBorrowing_rate() + "]," + "ip:["
|
||||
+ this.getIp(getRequest()) + "]");
|
||||
this.logService.saveSync(log);
|
||||
|
||||
} catch (BusinessException e) {
|
||||
modelAndView.addObject("error", e.getMessage());
|
||||
modelAndView.addObject("id", id);
|
||||
modelAndView.addObject("name", name);
|
||||
modelAndView.addObject("symbol", symbol);
|
||||
modelAndView.addObject("decimals", decimals);
|
||||
modelAndView.addObject("multiple", multiple);
|
||||
modelAndView.addObject("borrowing_rate", borrowing_rate);
|
||||
modelAndView.setViewName("item_config_update");
|
||||
return modelAndView;
|
||||
} catch (Throwable t) {
|
||||
logger.error(" error ", t);
|
||||
modelAndView.addObject("error", "[ERROR] " + t.getMessage());
|
||||
modelAndView.addObject("id", id);
|
||||
modelAndView.addObject("name", name);
|
||||
modelAndView.addObject("symbol", symbol);
|
||||
modelAndView.addObject("decimals", decimals);
|
||||
modelAndView.addObject("multiple", multiple);
|
||||
modelAndView.addObject("borrowing_rate", borrowing_rate);
|
||||
modelAndView.setViewName("item_config_update");
|
||||
return modelAndView;
|
||||
}
|
||||
|
||||
modelAndView.addObject("message", "操作成功");
|
||||
modelAndView.setViewName("redirect:/" + action + "listConfig.action");
|
||||
return modelAndView;
|
||||
}
|
||||
|
||||
/**
|
||||
* order_open
|
||||
*/
|
||||
@RequestMapping(value = action + "order_open.action")
|
||||
public ModelAndView order_open(HttpServletRequest request) {
|
||||
String order_open = request.getParameter("order_open");
|
||||
|
||||
ModelAndView modelAndView = new ModelAndView();
|
||||
modelAndView.setViewName("redirect:/" + action + "list.action");
|
||||
|
||||
try {
|
||||
|
||||
Syspara syspara = this.sysparaService.find("order_open");
|
||||
syspara.setValue(order_open);
|
||||
this.sysparaService.update(syspara);
|
||||
|
||||
} catch (BusinessException e) {
|
||||
modelAndView.addObject("error", e.getMessage());
|
||||
return modelAndView;
|
||||
} catch (Throwable t) {
|
||||
logger.error(" error ", t);
|
||||
modelAndView.addObject("error", "[ERROR] " + t.getMessage());
|
||||
return modelAndView;
|
||||
}
|
||||
|
||||
modelAndView.addObject("message", "操作成功");
|
||||
return modelAndView;
|
||||
}
|
||||
|
||||
/**
|
||||
* kline初始化
|
||||
*/
|
||||
@RequestMapping(value = action + "klineInit.action")
|
||||
public ModelAndView klineInit(HttpServletRequest request) {
|
||||
String para_init_symbol = request.getParameter("para_init_symbol");
|
||||
|
||||
ModelAndView modelAndView = new ModelAndView();
|
||||
modelAndView.setViewName("redirect:/" + action + "listConfig.action");
|
||||
|
||||
try {
|
||||
|
||||
String symbols = para_init_symbol;
|
||||
if (StringUtils.isEmptyString(symbols)) {
|
||||
|
||||
List<Item> items = this.itemService.cacheGetAll();
|
||||
for (int i = 0; i < items.size(); i++) {
|
||||
|
||||
String symbol = items.get(i).getSymbol();
|
||||
if (items.size() - i == 1) {
|
||||
symbols += symbol;
|
||||
} else {
|
||||
symbols += symbol + ",";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
this.klineInitService.klineInit(symbols);
|
||||
|
||||
} catch (BusinessException e) {
|
||||
modelAndView.addObject("error", e.getMessage());
|
||||
return modelAndView;
|
||||
} catch (Throwable t) {
|
||||
logger.error(" error ", t);
|
||||
modelAndView.addObject("error", "[ERROR] " + t.getMessage());
|
||||
return modelAndView;
|
||||
}
|
||||
|
||||
modelAndView.addObject("message", "K线图初始化完成");
|
||||
return modelAndView;
|
||||
}
|
||||
|
||||
/**
|
||||
* kline初始化配置
|
||||
*/
|
||||
@RequestMapping(value = action + "klineInitConfig.action")
|
||||
public ModelAndView klineInitConfig(HttpServletRequest request) {
|
||||
String para_init_symbol = request.getParameter("para_init_symbol");
|
||||
|
||||
ModelAndView modelAndView = new ModelAndView();
|
||||
modelAndView.setViewName("redirect:/" + action + "listConfig.action");
|
||||
|
||||
try {
|
||||
|
||||
String symbols = para_init_symbol;
|
||||
if (StringUtils.isEmptyString(symbols)) {
|
||||
|
||||
List<Item> items = this.itemService.cacheGetByMarket("");
|
||||
for (int i = 0; i < items.size(); i++) {
|
||||
|
||||
String symbol = items.get(i).getSymbol();
|
||||
if (items.size() - i == 1) {
|
||||
symbols += symbol;
|
||||
} else {
|
||||
symbols += symbol + ",";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
this.klineInitService.klineInit(symbols);
|
||||
|
||||
} catch (BusinessException e) {
|
||||
modelAndView.addObject("error", e.getMessage());
|
||||
return modelAndView;
|
||||
} catch (Throwable t) {
|
||||
logger.error(" error ", t);
|
||||
modelAndView.addObject("error", "[ERROR] " + t.getMessage());
|
||||
return modelAndView;
|
||||
}
|
||||
|
||||
modelAndView.addObject("message", "K线图初始化完成");
|
||||
return modelAndView;
|
||||
}
|
||||
|
||||
/**
|
||||
* 验证登录人资金密码
|
||||
*/
|
||||
private void checkLoginSafeword(SecUser secUser, String operatorUsername, String loginSafeword) {
|
||||
String sysSafeword = secUser.getSafeword();
|
||||
String safeword_md5 = passwordEncoder.encodePassword(loginSafeword, operatorUsername);
|
||||
if (!safeword_md5.equals(sysSafeword)) {
|
||||
throw new BusinessException("登录人资金密码错误");
|
||||
}
|
||||
}
|
||||
|
||||
private String getPath(HttpServletRequest request) {
|
||||
return String.format("%s://%s:%s%s", request.getScheme(), request.getServerName(), request.getServerPort(),
|
||||
request.getContextPath());
|
||||
}
|
||||
|
||||
public String validateAdd(String name, String symbol, String symbol_data, String pips, String pips_amount,
|
||||
String unit_amount, String decimals, String unit_fee) {
|
||||
|
||||
if (StringUtils.isNullOrEmpty(name)) {
|
||||
return "名称不能为空";
|
||||
}
|
||||
if (StringUtils.isNullOrEmpty(symbol)) {
|
||||
return "代码不能为空";
|
||||
}
|
||||
if (this.adminItemService.checkSymbolExit(symbol)) {
|
||||
return "代码已经存在";
|
||||
}
|
||||
|
||||
return this.validate(unit_fee, unit_amount, pips, pips_amount, decimals, "0");
|
||||
}
|
||||
|
||||
public String validate(String unit_fee, String unit_amount, String pips, String pips_amount, String multiple, String decimals) {
|
||||
|
||||
if (StringUtils.isNullOrEmpty(unit_fee)) {
|
||||
return "每手的手续费必填";
|
||||
}
|
||||
if (!StringUtils.isDouble(unit_fee)) {
|
||||
return "每手的手续费不是浮点数";
|
||||
}
|
||||
if (Double.valueOf(unit_fee).doubleValue() < 0) {
|
||||
return "每手的手续费不能小于0";
|
||||
}
|
||||
|
||||
if (StringUtils.isNullOrEmpty(unit_amount)) {
|
||||
return "每手金额必填";
|
||||
}
|
||||
if (!StringUtils.isDouble(unit_amount)) {
|
||||
return "每手金额不是浮点数";
|
||||
}
|
||||
if (Double.valueOf(unit_amount).doubleValue() < 0) {
|
||||
return "每手金额不能小于0";
|
||||
}
|
||||
|
||||
if (StringUtils.isNullOrEmpty(pips)) {
|
||||
return "最小浮动必填";
|
||||
}
|
||||
if (!StringUtils.isDouble(pips)) {
|
||||
return "最小浮动不是浮点数";
|
||||
}
|
||||
if (Double.valueOf(pips).doubleValue() <= 0) {
|
||||
return "最小浮动不能小于等于0";
|
||||
}
|
||||
|
||||
if (StringUtils.isNullOrEmpty(pips_amount)) {
|
||||
return "最小浮动金额必填";
|
||||
}
|
||||
if (!StringUtils.isDouble(pips_amount)) {
|
||||
return "最小浮动金额不是浮点数";
|
||||
}
|
||||
if (Double.valueOf(pips_amount).doubleValue() < 0) {
|
||||
return "最小浮动金额不能小于0";
|
||||
}
|
||||
|
||||
if (StringUtils.isNullOrEmpty(multiple)) {
|
||||
return "交易量放大倍数必填";
|
||||
}
|
||||
if (!StringUtils.isDouble(multiple)) {
|
||||
return "交易量放大倍数不是浮点数";
|
||||
}
|
||||
if (Double.valueOf(multiple).doubleValue() < 0) {
|
||||
return "交易量放大倍数不能小于0";
|
||||
}
|
||||
|
||||
if (StringUtils.isNullOrEmpty(decimals)) {
|
||||
return "精度必填";
|
||||
}
|
||||
if (!StringUtils.isInteger(decimals)) {
|
||||
return "精度不是整数";
|
||||
}
|
||||
if (Integer.valueOf(decimals).intValue() < 0) {
|
||||
return "精度不能小于0";
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public String validateAddConfig(String name, String symbol, String symbol_data, String decimals, String multiple, String borrowing_rate) {
|
||||
|
||||
if (StringUtils.isNullOrEmpty(name)) {
|
||||
return "名称不能为空";
|
||||
}
|
||||
if (StringUtils.isNullOrEmpty(symbol)) {
|
||||
return "代码不能为空";
|
||||
}
|
||||
if (this.adminItemService.checkSymbolExit(symbol)) {
|
||||
return "代码已经存在";
|
||||
}
|
||||
|
||||
if (StringUtils.isNullOrEmpty(decimals)) {
|
||||
return "精度必填";
|
||||
}
|
||||
if (!StringUtils.isInteger(decimals)) {
|
||||
return "精度不是整数";
|
||||
}
|
||||
if (Integer.valueOf(decimals).intValue() < 0) {
|
||||
return "精度不能小于0";
|
||||
}
|
||||
|
||||
if (StringUtils.isNullOrEmpty(multiple)) {
|
||||
return "交易量放大倍数必填";
|
||||
}
|
||||
if (!StringUtils.isDouble(multiple)) {
|
||||
return "交易量放大倍数不是浮点数";
|
||||
}
|
||||
if (Double.valueOf(multiple).doubleValue() < 0) {
|
||||
return "交易量放大倍数不能小于0";
|
||||
}
|
||||
|
||||
if (StringUtils.isNullOrEmpty(borrowing_rate)) {
|
||||
return "借贷利率必填";
|
||||
}
|
||||
if (!StringUtils.isDouble(borrowing_rate)) {
|
||||
return "借贷利率不是浮点数";
|
||||
}
|
||||
if (Double.valueOf(borrowing_rate).doubleValue() < 0) {
|
||||
return "借贷利率不能小于0";
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public String validateUpdateConfig(String name, String symbol, String symbol_data, String decimals, String multiple, String borrowing_rate) {
|
||||
|
||||
if (StringUtils.isNullOrEmpty(name)) {
|
||||
return "名称不能为空";
|
||||
}
|
||||
if (StringUtils.isNullOrEmpty(symbol)) {
|
||||
return "代码不能为空";
|
||||
}
|
||||
|
||||
if (StringUtils.isNullOrEmpty(decimals)) {
|
||||
return "精度必填";
|
||||
}
|
||||
if (!StringUtils.isInteger(decimals)) {
|
||||
return "精度不是整数";
|
||||
}
|
||||
if (Integer.valueOf(decimals).intValue() < 0) {
|
||||
return "精度不能小于0";
|
||||
}
|
||||
|
||||
if (StringUtils.isNullOrEmpty(multiple)) {
|
||||
return "交易量放大倍数必填";
|
||||
}
|
||||
if (!StringUtils.isDouble(multiple)) {
|
||||
return "交易量放大倍数不是浮点数";
|
||||
}
|
||||
if (Double.valueOf(multiple).doubleValue() < 0) {
|
||||
return "交易量放大倍数不能小于0";
|
||||
}
|
||||
|
||||
if (StringUtils.isNullOrEmpty(borrowing_rate)) {
|
||||
return "借贷利率必填";
|
||||
}
|
||||
if (!StringUtils.isDouble(borrowing_rate)) {
|
||||
return "借贷利率不是浮点数";
|
||||
}
|
||||
if (Double.valueOf(borrowing_rate).doubleValue() < 0) {
|
||||
return "借贷利率不能小于0";
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
133
comm/Item/src/project/web/admin/AdminItemLeverageController.java
Executable file
133
comm/Item/src/project/web/admin/AdminItemLeverageController.java
Executable file
@@ -0,0 +1,133 @@
|
||||
package project.web.admin;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.servlet.ModelAndView;
|
||||
|
||||
import kernel.exception.BusinessException;
|
||||
import kernel.util.StringUtils;
|
||||
import kernel.web.PageActionSupport;
|
||||
import project.item.AdminItemLeverageService;
|
||||
import project.item.ItemService;
|
||||
import project.item.model.ItemLever;
|
||||
|
||||
/**
|
||||
* 交易杠杆
|
||||
*
|
||||
*/
|
||||
@RestController
|
||||
public class AdminItemLeverageController extends PageActionSupport {
|
||||
|
||||
private static final Log logger = LogFactory.getLog(AdminItemLeverageController.class);
|
||||
@Autowired
|
||||
private AdminItemLeverageService adminItemLeverageService;
|
||||
|
||||
private final String action = "normal/adminItemLeverageAction!";
|
||||
|
||||
/**
|
||||
* 交易杠杆-列表
|
||||
*/
|
||||
@RequestMapping(value = action + "list.action")
|
||||
public ModelAndView list(HttpServletRequest request) {
|
||||
String itemid = request.getParameter("itemid");
|
||||
String message = request.getParameter("message");
|
||||
String error = request.getParameter("error");
|
||||
|
||||
this.checkAndSetPageNo(request.getParameter("pageNo"));
|
||||
this.pageSize = 10;
|
||||
this.page = this.adminItemLeverageService.pagedQuery(this.pageNo, this.pageSize, itemid);
|
||||
ModelAndView model = new ModelAndView();
|
||||
model.addObject("pageNo", this.pageNo);
|
||||
model.addObject("pageSize", this.pageSize);
|
||||
model.addObject("page", this.page);
|
||||
model.addObject("itemid", itemid);
|
||||
model.addObject("message", message);
|
||||
model.addObject("error", error);
|
||||
model.setViewName("item_leverage_list");
|
||||
return model;
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增杠杆参数
|
||||
*/
|
||||
@RequestMapping(value = action + "toAdd.action")
|
||||
public ModelAndView toAdd(HttpServletRequest request) {
|
||||
|
||||
String message = request.getParameter("message");
|
||||
String error = request.getParameter("error");
|
||||
String itemid = request.getParameter("itemid");
|
||||
String leverage = request.getParameter("leverage");
|
||||
|
||||
ModelAndView model = new ModelAndView();
|
||||
model.addObject("message", message);
|
||||
model.addObject("error", error);
|
||||
model.addObject("itemid", itemid);
|
||||
model.addObject("leverage", leverage);
|
||||
model.setViewName("item_leverage_add");
|
||||
return model;
|
||||
}
|
||||
|
||||
@RequestMapping(value = action + "add.action")
|
||||
public ModelAndView add(HttpServletRequest request) {
|
||||
|
||||
String itemid = request.getParameter("itemid");
|
||||
String leverage = request.getParameter("leverage");
|
||||
|
||||
ModelAndView model = new ModelAndView();
|
||||
String error = "";
|
||||
|
||||
if (StringUtils.isNullOrEmpty(leverage)
|
||||
|| !StringUtils.isDouble(leverage)
|
||||
|| Double.valueOf(leverage) < 1) {
|
||||
throw new BusinessException("杠杆倍数不能小于1");
|
||||
}
|
||||
|
||||
ItemLever entity = new ItemLever();
|
||||
try {
|
||||
entity.setItem_id(itemid);
|
||||
entity.setLever_rate(Double.valueOf(leverage));
|
||||
|
||||
this.adminItemLeverageService.save(entity);
|
||||
model.addObject("message", "操作成功");
|
||||
model.setViewName("redirect:/" + action + "list.action");
|
||||
return model;
|
||||
} catch (BusinessException e) {
|
||||
error = e.getMessage();
|
||||
} catch (Throwable t) {
|
||||
logger.error("add error ", t);
|
||||
error = "程序错误";
|
||||
}
|
||||
model.addObject("error", error);
|
||||
model.setViewName("item_leverage_add");
|
||||
return model;
|
||||
}
|
||||
|
||||
/**
|
||||
* 交易杠杆-删除
|
||||
*/
|
||||
@RequestMapping(action + "toDelete.action")
|
||||
public ModelAndView toDelete(HttpServletRequest request) {
|
||||
|
||||
String id = request.getParameter("id");
|
||||
ModelAndView model = new ModelAndView();
|
||||
String error = "";
|
||||
try {
|
||||
|
||||
this.adminItemLeverageService.delete(id);
|
||||
model.addObject("message", "操作成功");
|
||||
} catch (BusinessException e) {
|
||||
error = e.getMessage();
|
||||
} catch (Throwable t) {
|
||||
logger.error("add error ", t);
|
||||
error = "程序错误";
|
||||
}
|
||||
model.addObject("error", error);
|
||||
model.setViewName("redirect:/" + action + "list.action");
|
||||
return model;
|
||||
}
|
||||
}
|
||||
189
comm/Item/src/project/web/api/ItemUserOptionalController.java
Executable file
189
comm/Item/src/project/web/api/ItemUserOptionalController.java
Executable file
@@ -0,0 +1,189 @@
|
||||
package project.web.api;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.CrossOrigin;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import kernel.exception.BusinessException;
|
||||
import kernel.util.StringUtils;
|
||||
import kernel.util.ThreadUtils;
|
||||
import kernel.web.BaseAction;
|
||||
import kernel.web.ResultObject;
|
||||
import project.item.ItemLock;
|
||||
import project.item.ItemUserOptionalService;
|
||||
import project.item.model.ItemUserOptional;
|
||||
|
||||
/**
|
||||
* 自选币种行情
|
||||
*
|
||||
*/
|
||||
@RestController
|
||||
@CrossOrigin
|
||||
public class ItemUserOptionalController extends BaseAction {
|
||||
|
||||
private Logger logger = LogManager.getLogger(ItemUserOptionalController.class);
|
||||
|
||||
@Autowired
|
||||
private ItemUserOptionalService itemUserOptionalService;
|
||||
|
||||
private final String action = "/api/itemUserOptional!";
|
||||
|
||||
/**
|
||||
* 返回自选币种的行情
|
||||
*/
|
||||
@RequestMapping(action + "list.action")
|
||||
public Object list(HttpServletRequest request) {
|
||||
ResultObject resultObject = new ResultObject();
|
||||
resultObject = readSecurityContextFromSession(resultObject);
|
||||
if (!"0".equals(resultObject.getCode())) {
|
||||
return resultObject;
|
||||
}
|
||||
try {
|
||||
String symbol = request.getParameter("symbol");
|
||||
List<Map<String, Object>> list = itemUserOptionalService.cacheListDataByPartyId(this.getLoginPartyId(), symbol);
|
||||
resultObject.setData(list);
|
||||
resultObject.setCode("0");
|
||||
} catch (BusinessException e) {
|
||||
resultObject.setCode("1");
|
||||
resultObject.setMsg(e.getMessage());
|
||||
} catch (Exception e) {
|
||||
resultObject.setCode("1");
|
||||
resultObject.setMsg("程序错误");
|
||||
logger.error("error:", e);
|
||||
}
|
||||
|
||||
return resultObject;
|
||||
}
|
||||
|
||||
/**
|
||||
* 加入自选
|
||||
*/
|
||||
@RequestMapping(action + "add.action")
|
||||
public Object add(HttpServletRequest request) {
|
||||
ResultObject resultObject = new ResultObject();
|
||||
resultObject = readSecurityContextFromSession(resultObject);
|
||||
if (!"0".equals(resultObject.getCode())) {
|
||||
return resultObject;
|
||||
}
|
||||
boolean lock = false;
|
||||
String loginPartyId = this.getLoginPartyId();
|
||||
try {
|
||||
|
||||
if (ItemLock.add(loginPartyId)) {
|
||||
String symbol = request.getParameter("symbol");
|
||||
lock = true;
|
||||
if (StringUtils.isNullOrEmpty(symbol)) {
|
||||
throw new BusinessException("参数错误");
|
||||
}
|
||||
ItemUserOptional entity = new ItemUserOptional();
|
||||
entity.setPartyId(this.getLoginPartyId());
|
||||
entity.setSymbol(symbol);
|
||||
itemUserOptionalService.save(entity);
|
||||
resultObject.setCode("0");
|
||||
}else {
|
||||
throw new BusinessException("请稍后再试");
|
||||
}
|
||||
} catch (BusinessException e) {
|
||||
resultObject.setCode("1");
|
||||
resultObject.setMsg(e.getMessage());
|
||||
} catch (Exception e) {
|
||||
resultObject.setCode("1");
|
||||
resultObject.setMsg("程序错误");
|
||||
logger.error("error:", e);
|
||||
} finally {
|
||||
if (lock) {
|
||||
ThreadUtils.sleep(50);
|
||||
ItemLock.remove(loginPartyId);
|
||||
}
|
||||
}
|
||||
return resultObject;
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除自选币种
|
||||
*/
|
||||
@RequestMapping(action + "delete.action")
|
||||
public Object delete(HttpServletRequest request) {
|
||||
ResultObject resultObject = new ResultObject();
|
||||
resultObject = readSecurityContextFromSession(resultObject);
|
||||
if (!"0".equals(resultObject.getCode())) {
|
||||
return resultObject;
|
||||
}
|
||||
boolean lock = false;
|
||||
String loginPartyId = this.getLoginPartyId();
|
||||
try {
|
||||
if (ItemLock.add(loginPartyId)) {
|
||||
String symbol = request.getParameter("symbol");
|
||||
lock = true;
|
||||
if (StringUtils.isNullOrEmpty(symbol)) {
|
||||
throw new BusinessException("参数错误");
|
||||
}
|
||||
itemUserOptionalService.delete(this.getLoginPartyId(), symbol);
|
||||
resultObject.setCode("0");
|
||||
}else {
|
||||
throw new BusinessException("请稍后再试");
|
||||
}
|
||||
} catch (BusinessException e) {
|
||||
resultObject.setCode("1");
|
||||
resultObject.setMsg(e.getMessage());
|
||||
} catch (Exception e) {
|
||||
resultObject.setCode("1");
|
||||
resultObject.setMsg("程序错误");
|
||||
logger.error("error:", e);
|
||||
} finally {
|
||||
if (lock) {
|
||||
ThreadUtils.sleep(50);
|
||||
ItemLock.remove(loginPartyId);
|
||||
}
|
||||
}
|
||||
return resultObject;
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询是否已加入自选
|
||||
*/
|
||||
@RequestMapping(action + "getItemOptionalStatus.action")
|
||||
public Object getItemOptionalStatus(HttpServletRequest request) {
|
||||
ResultObject resultObject = new ResultObject();
|
||||
resultObject = readSecurityContextFromSession(resultObject);
|
||||
if (!"0".equals(resultObject.getCode())) {
|
||||
return resultObject;
|
||||
}
|
||||
try {
|
||||
String symbol = request.getParameter("symbol");
|
||||
List<ItemUserOptional> list = itemUserOptionalService.cacheListByPartyId(this.getLoginPartyId());
|
||||
Map<String, Object> data = new HashMap<String, Object>();
|
||||
if (null == list) {
|
||||
data.put("status", "0");
|
||||
} else {
|
||||
for (ItemUserOptional item : list) {
|
||||
if (symbol.equals(item.getSymbol())) {
|
||||
data.put("status", "1");
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
resultObject.setData(data);
|
||||
resultObject.setCode("0");
|
||||
} catch (BusinessException e) {
|
||||
resultObject.setCode("1");
|
||||
resultObject.setMsg(e.getMessage());
|
||||
} catch (Exception e) {
|
||||
resultObject.setCode("1");
|
||||
resultObject.setMsg("程序错误");
|
||||
logger.error("error:", e);
|
||||
}
|
||||
return resultObject;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user