成交簿记搬迁山证fr007

This commit is contained in:
吴方海
2025-04-22 10:40:46 +08:00
parent 3ecd0a2357
commit 08682b28c4
4 changed files with 351 additions and 24 deletions
@@ -28,6 +28,101 @@ namespace YLErp.Modules.SwapModule
{
}
/// <summary>
/// 查询今天是否有FR007的数据
/// </summary>
/// <returns></returns>
public eod_commodity_future_price SearchTodayFRData(DateTime dateTime)
{
var data = DbContext.eod_commodity_future_price.Where(a => a.ValueDate == dateTime).FirstOrDefault();
if (data == null)
{
data = new eod_commodity_future_price();
}
return data;
}
/// <summary>
/// 查询选择的时间是否拥有FR007的数据
/// </summary>
/// <returns></returns>
public List<eod_commodity_future_price> SearchdateFRData(List<DateTime> date)
{
var datafr007 = DbContext.eod_commodity_future_price.Where(a => date.Contains(a.ValueDate)).ToList();
return datafr007;
}
/// <summary>
/// 删除的RF007数据
/// </summary>
/// <param name="id">要删除的RF007数据Id</param>
/// <exception cref="ServiceException"></exception>
public bool DeleteFRData(int id)
{
var frdata = DbContext.eod_commodity_future_price.Find(id);
if (frdata == null)
{
throw new ServiceException("未找到FR007流水");
}
DbContext.eod_commodity_future_price.Remove(frdata);
DbContext.SaveChanges();
return true;
}
/// <summary>
/// 新增或者修改FR007数据
/// </summary>
/// <param name="price">FR007价格</param>
/// <param name="dateTime">新增或者修改时间</param>
/// <exception cref="ServiceException"></exception>
public bool AddOrUpdateFRdata(Double price, DateTime dateTime)
{
string beforedate = "";
var frdata = DbContext.eod_commodity_future_price.Where(a => a.ValueDate == dateTime).FirstOrDefault();
if (frdata == null)
{
frdata = new eod_commodity_future_price();
}
//修改
if (frdata != null && frdata?.UnderlyingCode != null)
{
frdata.ValueDate = dateTime;
frdata.HighPrice = 0;
frdata.LowPrice = 0;
beforedate = JsonHelper.Serialize(frdata);
}
else
{
//新增
var newestdata = DbContext.eod_commodity_future_price.OrderByDescending(a => a.ValueDate).FirstOrDefault();
if (newestdata == null)
{
var underlyingCode = DbContext.underlying_manager.Where(a => a.UnderlyingCode == "FR007").FirstOrDefault();
if (underlyingCode == null)
{
throw new ServiceException("找不到FR007的标的");
}
newestdata = new eod_commodity_future_price();
newestdata.UnderlyingId = underlyingCode.id;
}
frdata.ValueDate = dateTime;
frdata.UnderlyingCode = "FR007";
frdata.UnderlyingId = newestdata.UnderlyingId;
frdata.DataSource = "人工";
DbContext.Add(frdata);
}
frdata.ClosePrice = Math.Round(price, 4);
frdata.SettlePrice = Math.Round(price, 4);
frdata.ReferencePrice = Math.Round(price, 4);
frdata.OptId = UserInfo.UserId;
frdata.OptName = UserInfo.UserName;
frdata.OptDate = DateTime.Now;
DbContext.SaveChanges();
return true;
}
/// <summary>
/// 查询互换流水导入
/// </summary>
@@ -2,6 +2,7 @@
using BaseOUDAL;
using CsvHelper;
using DocumentFormat.OpenXml.Spreadsheet;
using Microsoft.AspNetCore.Authorization;
using System.Collections.Concurrent;
using System.Linq;
using System.Web.Mvc;
@@ -712,6 +713,44 @@ namespace YLErp.Web.Controllers
}
#endregion
#endregion
#region fr007
/// <summary>
/// 查询最新一条FR007数据
/// </summary>
/// <returns></returns>
public JsonResult SearchTodayWhetherFRData(DateTime dateTime)
{
var service = new SwapFlowService(CurUser);
var data = service.SearchTodayFRData(dateTime);
return Json(data);
}
/// <summary>
/// 删除FR007数据
/// </summary>
/// <param name="id">要删除的RF007数据Id</param>
/// <returns></returns>
public JsonResult DeleteFRData(int id)
{
var service = new SwapFlowService(CurUser);
bool flag = service.DeleteFRData(id);
return Json(flag);
}
/// <summary>
/// 新增或者修改FR007数据
/// </summary>
/// <param name="id">新增为空 修改时是要修改的FR007数据</param>
/// <param name="price">FR007价格</param>
/// <param name="dateTime">新增或者修改时间</param>
[AllowAnonymous]
public JsonResult AddOrUpdateFRData(double price, DateTime dateTime)
{
var service = new SwapFlowService(CurUser);
bool flag = service.AddOrUpdateFRdata(price, dateTime);
return Json(flag);
}
#endregion
#endregion
#region
#region -
@@ -1039,5 +1078,7 @@ namespace YLErp.Web.Controllers
var result = service.SendConfirmEamil(tradeId);
return JsonSuccess(result);
}
}
}
+115 -23
View File
@@ -15,6 +15,7 @@
@section CSS{
<link rel="stylesheet" href="~/Style/Css/step.css?v=@(HtmlUtil.JsVersion)" />
<style>
.layui-progress {
position: relative;
height: 6px;
@@ -52,6 +53,44 @@
.bootstrap-select{
width:140px !important;
}
.clickable-icon {
cursor: pointer;
padding: 5px;
font-size: 16px;
}
.clickable-icon:hover {
opacity: 0.8;
}
.input-fr007 {
text-align: right;
padding-right: 25px !important;
}
.icon-box {
font-size: 20px;
}
.confirm-icon {
color: #4282ff;
}
.warning-icon {
color: #ffb84a;
}
.tips-icon {
display: contents;
}
.input-box {
position: relative;
}
.input-unit {
position: absolute;
right: 17px;
top: 0;
}
</style>
}
@section JS{
@@ -72,34 +111,87 @@
<div id="steps"></div>
</div>
<div class="searchdiv">
<div style="display:flex;height:40px;">
<a v-on:click="refreshTradeFlow(false)" href="#" style="margin-left:30px;"><span class="glyphicon glyphicon-refresh" v-show="step==1">刷新交易端流水</span></a>
@if (CurUser.结算管理_成交簿记流水新增)
{
<button class="btn btn-primary" v-on:click="addNew" style="margin-left:30px;" v-show="step==1">添加流水</button>
<button class="btn btn-primary" v-on:click="showImportSwapflow" style="margin-left:30px;" v-show="step==1">导入流水</button>
}
<button class="btn btn-primary" v-on:click="getList"><span class="glyphicon glyphicon-search"></span>查询</button>
@*<button class="btn btn-primary" v-on:click="summaryStep" style="margin-left:30px;" v-show="step==1">汇总</button>*@
<div style="position:absolute;right:17px;">
@Html.MyAceDropdownInput("SearchClientId", "客户名称", ClientDataModel.GetAllOpenClient(),multiple:false,appendEmptyAll:false)
<label>标的代码</label>
<select class="" data-placeholder="请选择 标的代码" id="UnderlyingCode" name="UnderlyingCode" data-actions-box="true" data-live-search="true" style="width:180px;"></select>
<label style="margin-left:10px;">清算日期</label>
<vue-datepicker :holiday="1" v-model="tradeDate" id="tradeDate" ></vue-datepicker>
@if (CurUser.结算管理_成交簿记流水重置)
<div style="display: flex; height: auto; flex-wrap: wrap; align-items: center; gap: 8px; padding: 8px 0;">
<!-- 左侧操作按钮组 -->
<div style="display: flex; flex-wrap: wrap; gap: 8px;">
<a v-on:click="refreshTradeFlow(false)" href="#" style="text-decoration: none;">
<span class="glyphicon glyphicon-refresh" v-show="step==1">刷新交易端流水</span>
</a>
@if (CurUser.结算管理_成交簿记流水新增)
{
<button class="btn btn-primary" id="resetBtn" style="margin-left:16px;">重置</button>
}
@if (CurUser.结算管理_成交簿记流水簿记)
{
<button class="btn btn-primary" id="combookingBtn" style="margin-left:16px;">确定簿记</button>
<button class="btn btn-primary" v-on:click="addNew" v-show="step==1">添加流水</button>
<button class="btn btn-primary" v-on:click="showImportSwapflow" v-show="step==1">导入流水</button>
}
<button class="btn btn-primary" v-on:click="getList">
<span class="glyphicon glyphicon-search"></span> 查询
</button>
</div>
<!-- 右侧输入控件组 -->
<div style="display: flex; flex-wrap: wrap; gap: 8px; margin-left: auto;">
<!-- FR007 输入组 -->
<div style="display: flex; align-items: center; gap: 8px;">
<span>FR007</span>
<div style="position: relative;">
<input type="text" v-model="FRData.value" class="form-control input-fr007"
style="width: 90px; padding-right: 25px;"
v-bind:disabled="!isFromArtifical"
v-on:focus="editFRData">
<span class="input-unit" style="position: absolute; right: 8px; top: 50%; transform: translateY(-50%);">%</span>
</div>
<i v-if="isShowWarning" class="fa fa-exclamation-triangle warning-icon" v-bind:title="frTips" aria-hidden="true"></i>
<template v-if="!isShowWarning && isFromArtifical">
<i class="fa fa-pencil-square-o clickable-icon"
v-show="!isAddOrEditFRData"
v-on:click="editFRData"></i>
<div v-show="isAddOrEditFRData" style="display: flex; gap: 4px;">
<i class="fa fa-check-circle clickable-icon text-success"
v-on:click="commitFRData"></i>
<i class="fa fa-times-circle clickable-icon text-danger"
v-on:click="deleteFRData"></i>
</div>
</template>
</div>
<!-- 日期选择组 -->
<div style="display: flex; align-items: center; gap: 8px;">
<span>日期</span>
<vue-datepicker :holiday="1" v-model="FRData.date" id="FRDataDate"
style="width: 140px;"
v-on:input="getFRData"></vue-datepicker>
<span>客户名称</span>
<input type="text" class="text-box" id="SearchClientId" />
</div>
<!-- 标的代码和清算日期 -->
<div style="display: flex; align-items: center; gap: 8px;">
<div class="form-group" style="margin: 0;">
<label>标的代码</label>
<select class="form-control selectpicker" data-placeholder="请选择 标的代码" id="UnderlyingCode" name="UnderlyingCode" data-actions-box="true" data-live-search="true" style="width: 180px; max-width: 100%;"></select>
</div>
<div class="form-group" style="margin: 0;">
<label>清算日期</label>
<vue-datepicker :holiday="1" v-model="tradeDate" id="tradeDate"
style="width: 140px;"></vue-datepicker>
</div>
</div>
<!-- 右侧操作按钮 -->
<div style="display: flex; gap: 8px;">
@if (CurUser.结算管理_成交簿记流水重置)
{
<button class="btn btn-primary" id="resetBtn">重置</button>
}
@if (CurUser.结算管理_成交簿记流水簿记)
{
<button class="btn btn-primary" id="combookingBtn">确定簿记</button>
}
</div>
</div>
@* <button class="btn btn-primary" v-on:click="unwindStep" style="margin-left:30px;" v-show="step==2">执行开平仓事件</button>
<button class="btn btn-primary" v-on:click="composeUnwindStep" style="margin-left:30px;" v-show="step==3">合成持仓</button>*@
</div>
</div>
<div id="tableContent" class="yc-panel my-0 p-0">
@Html.Raw(JqGridSimple.OutTable())
</div>
@@ -2,6 +2,7 @@
const inputFormatTradePrice = Object.freeze({ precision: otcformat.trading.tradeSinglePrice.precision, negative: true, append: '' });
const inputFormatTradeAmount = Object.freeze({ precision: otcformat.trading.notional.precision, append: '' });
const inputFormatMarginRate = Object.freeze({ precision: otcformat.trading.marginRateP.precision, append: '%' });
var clients = ylotc.clients;
const consUnderlyingFlag = (function () {
let unSelFlag = tradeHelper.UnderlyingSelectFlag;
return unSelFlag.UseForTrading | unSelFlag.IncludeMatured | unSelFlag.UsePinYinFilter | unSelFlag.IncludeBasket | unSelFlag.IncludeSynthetic | unSelFlag.CheckLaunch;
@@ -186,6 +187,9 @@ $(function () {
document.onkeydown = keyEnter;
let underlyingCtrl = new tradeHelper.UnderlyingSelectCtrl('#UnderlyingCode', { UseCodeAsId: true }).setFlag(tradeHelper.UnderlyingSelectFlag.OtcTrade);
let autoClientNumber_0 = FastVue.autocomplete(document.getElementById('SearchClientId'), {
nameField: 'Name', valueField: 'id', searchField: ['Number', 'Name'], lookup: clients
});
CombookingHub();
ResetHub();
});
@@ -868,7 +872,16 @@ var vue = new Vue({
step: 1,
tradeDate: "",
UnderlyingCode: "",
ClientId:null
ClientId: null,
isAddOrEditFRData: false,
isShowWarning: true,
isFromArtifical: false,
FRData: {
oldValue: null,
value: "",
id: "",
date: ""
},
},
mounted: function () {
autoClient = FastVue.autocomplete(document.getElementById('ClientId'), {
@@ -881,12 +894,17 @@ var vue = new Vue({
this.initStep(this.step);
//intiGrid(this.step)
this.refreshTradeFlow(false);
this.FRData.date = this.getToday()
this.getFRData();
},
computed: {
maxTradeDate() {
var now = this.getCurrentDate();
return now;
},
frTips() {
return `${this.FRData.date}无FR007,请补充。`;
}
},
methods: {
initStep(index) {
@@ -903,6 +921,87 @@ var vue = new Vue({
intiGrid(thisObj.step)
});
},
getToday() {
const today = new Date();
const year = today.getFullYear();
const month = today.getMonth() + 1; // getMonth() 返回的月份是从 0 开始的
const day = today.getDate();
// 如果需要格式化为 YYYY-MM-DD 字符串
const formattedToday = `${year}-${month.toString().padStart(2, '0')}-${day.toString().padStart(2, '0')}`;
return formattedToday
},
getFRData() {
const thisObj = this;
main.post(`/swapTrade2/SearchTodayWhetherFRData?dateTime=${this.FRData.date}`).done(function (resp) {
if (resp.UnderlyingCode) { // 如果这天有fr007获取值和id,隐藏警告
thisObj.FRData.value = (resp.ReferencePrice * 100).toFixed(4);
thisObj.FRData.oldValue = (resp.ReferencePrice * 100).toFixed(4);
thisObj.FRData.id = resp.id;
thisObj.isShowWarning = false
thisObj.isFromArtifical = resp.DataSource === "人工"
} else {
thisObj.FRData.value = "";
thisObj.FRData.id = "";
thisObj.isShowWarning = true;
thisObj.isFromArtifical = true;// 如果没有fr007,fr007来源默认设置为人工,用于新增
}
});
},
editFRData() {
this.isAddOrEditFRData = true
this.isShowWarning = false
},
cancelEditFRData() {
this.FRData.value = "";
this.isAddOrEditFRData = false
const today = this.getToday();
if (this.FRData.date !== today) {
this.isShowWarning = true;
} else {
this.isShowWarning = false
}
},
commitFRData() {
if (this.FRData.value) {
const value = Number(this.FRData.value)
if (!Number.isNaN(value)) {
// 用字符串四舍五入
const price = main.toNumber(value / 100, 6);
// 新增时不传id
const url = this.FRData.date ? `/swapTrade2/AddOrUpdateFRData?dateTime=${this.FRData.date}&price=${price}` : `/swapTrade2/AddOrUpdateFRData?price=${price}`
const thisObj = this;
main.post(url).done(function (resp) {
if (resp) {
thisObj.isAddOrEditFRData = false
thisObj.getFRData()
}
});
}
} else if (this.isShowWarning) { // 当日无fr007不做改动
this.isAddOrEditFRData = false
this.getFRData()
} else if (this.FRData.id) { // 当日有fr007删除fr007
const thisObj = this;
main.post(`/swapTrade2/DeleteFRData?id=${thisObj.FRData.id}`).done(function (resp) {
if (resp) {
thisObj.isAddOrEditFRData = false
thisObj.getFRData()
}
});
} else {
this.isAddOrEditFRData = false
this.isShowWarning = true;
}
},
deleteFRData() {
if (this.FRData.id) {
this.FRData.value = this.FRData.oldValue
this.isAddOrEditFRData = false
} else {
this.cancelEditFRData()
}
},
setStep(st) {
this.step = st;
},