Browse Source

增加“QuerySZDZTradePosition 持仓汇总查询(尚志大宗)”接口

Zhou.xiaoning 5 years ago
parent
commit
e417155395
15 changed files with 1603 additions and 340 deletions
  1. 2 2
      config/config.xml
  2. 88 0
      controllers/quote/history.go
  3. 122 0
      controllers/szdz/szdz.go
  4. 425 119
      docs/docs.go
  5. 425 119
      docs/swagger.json
  6. 309 92
      docs/swagger.yaml
  7. 2 0
      global/e/code.go
  8. 2 0
      global/e/msg.go
  9. 5 0
      main.go
  10. 3 3
      models/common.go
  11. 19 1
      models/goods.go
  12. 58 1
      models/market.go
  13. 65 2
      models/quote.go
  14. 76 1
      models/szdz.go
  15. 2 0
      routers/router.go

+ 2 - 2
config/config.xml

@@ -16,12 +16,12 @@
         <DbAddress value="192.168.31.117"/>
         <DbAddress value="192.168.31.117"/>
         <DbName    value="orcl"/>
         <DbName    value="orcl"/>
         <DbPort    value="1521"/>
         <DbPort    value="1521"/>
-        <DbUser    value="mtp2_test16"/>
+        <DbUser    value="mtp2_test181"/>
         <DbPwd     value="muchinfo"/>
         <DbPwd     value="muchinfo"/>
     </DbSetting>
     </DbSetting>
 
 
     <RedisSetting>
     <RedisSetting>
-        <Address   value="192.168.30.213"/>
+        <Address   value="192.168.31.181"/>
         <Port      value="5007"/>
         <Port      value="5007"/>
         <Timeout   value="3"/>
         <Timeout   value="3"/>
         <ConnNum   value="1"/>
         <ConnNum   value="1"/>

+ 88 - 0
controllers/quote/history.go

@@ -0,0 +1,88 @@
+package quote
+
+import (
+	"mtp2_if/global/app"
+	"mtp2_if/global/e"
+	"mtp2_if/logger"
+	"mtp2_if/models"
+	"net/http"
+	"time"
+
+	"github.com/gin-gonic/gin"
+)
+
+// HistoryData 历史数据
+type HistoryData struct {
+	Opened        float32   `json:"Opened"`        // 开盘价
+	Highest       float32   `json:"highest"`       // 收盘价
+	Lowest        float32   `json:"lowest"`        // 最低价
+	Closed        float32   `json:"closed"`        // 收盘价
+	TotleVolume   float32   `json:"totleVolume"`   // 总量
+	TotleTurnover float32   `json:"totleTurnover"` // 总金额
+	HoldVolume    float32   `json:"holdVolume"`    // 持仓量
+	Settle        float32   `json:"settle"`        // 结算价
+	TimeStamp     time.Time `json:"timeStamp"`     // 开盘时间
+}
+
+// QueryTSDataReq 分时图数据查询请求参数
+type QueryTSDataReq struct {
+	GoodsCode string `form:"goodsCode" binding:"required"` // 商品代码
+}
+
+// QueryTSDataRsp 分时图数据查询返回模型
+type QueryTSDataRsp struct {
+	GoodsCode    string        `json:"goodsCode"`    // 商品代码
+	DecimalPlace int           `json:"decimalPlace"` // 小数位
+	TradeDate    string        `json:"tradeDate"`    // 交易日
+	StartTime    string        `json:"startTime"`    // 开始时间
+	EndTime      string        `json:"endTime"`      // 结束时间
+	PreSettle    float32       `json:"preSettle"`    // 昨结
+	HistoryDatas []HistoryData `json:"historyDatas"` // 历史数据
+}
+
+// QueryTSData 分时图数据查询
+// @Summary 分时图数据查询
+// @Produce json
+// @Param GoodsCode query string true "商品代码"
+// @Success 200 {object} QueryTSDataRsp
+// @Failure 500 {object} app.Response
+// @Router /History/QueryTSData [get]
+// @Tags 通用服务
+func QueryTSData(c *gin.Context) {
+	appG := app.Gin{C: c}
+
+	// 获取请求参数
+	var req QueryTSDataReq
+	if err := appG.C.ShouldBindQuery(&req); err != nil {
+		logger.GetLogger().Errorf("QueryTSData failed: %s", err.Error())
+		appG.Response(http.StatusBadRequest, e.INVALID_PARAMS, nil)
+		return
+	}
+
+	var queryTSDataRsp QueryTSDataRsp
+
+	// 获取目标品种交易日
+
+	// FIXME: - 一些不常变化的数据(如市场信息、商品信息等)应缓存到Redis中
+	market, err := models.GetMarketByGoodsCode(req.GoodsCode)
+	if err != nil {
+		logger.GetLogger().Errorf("QueryTSData failed: %s", err.Error())
+		appG.Response(http.StatusBadRequest, e.ERROR_QUERY_FAIL, nil)
+		return
+	}
+	if market == nil {
+		logger.GetLogger().Errorf("QueryTSData failed: %s", err.Error())
+		appG.Response(http.StatusBadRequest, e.ERROR_GET_MARKET_FAILED, nil)
+		return
+	}
+
+	// FIXME: - 由于mtp2.0目前未同步外部交易所品种的当前交易日,
+	//          故通道交易的品种目前只能在交易系统的外部市场中获
+	//          取统一的交易日,后期应要求服务端同步外部数据
+
+	// 获取目标品种的开休市计划
+
+	// 查询成功
+	logger.GetLogger().Debugln("QueryTSData successed: %v", queryTSDataRsp)
+	appG.Response(http.StatusOK, e.SUCCESS, queryTSDataRsp)
+}

+ 122 - 0
controllers/szdz/szdz.go

@@ -1,14 +1,17 @@
 package szdz
 package szdz
 
 
 import (
 import (
+	"encoding/json"
 	"fmt"
 	"fmt"
 	"mtp2_if/db"
 	"mtp2_if/db"
 	"mtp2_if/global/app"
 	"mtp2_if/global/app"
 	"mtp2_if/global/e"
 	"mtp2_if/global/e"
 	"mtp2_if/logger"
 	"mtp2_if/logger"
 	"mtp2_if/models"
 	"mtp2_if/models"
+	"mtp2_if/utils"
 	"net/http"
 	"net/http"
 	"sort"
 	"sort"
+	"strconv"
 
 
 	"github.com/gin-gonic/gin"
 	"github.com/gin-gonic/gin"
 )
 )
@@ -411,3 +414,122 @@ func QueryConvertConfig(c *gin.Context) {
 	logger.GetLogger().Debugln("QueryConvertConfigReq successed: %v", datas)
 	logger.GetLogger().Debugln("QueryConvertConfigReq successed: %v", datas)
 	appG.Response(http.StatusOK, e.SUCCESS, datas)
 	appG.Response(http.StatusOK, e.SUCCESS, datas)
 }
 }
+
+// QuerySZDZTradePositionReq 持仓汇总查询请求参数(尚志大宗)
+type QuerySZDZTradePositionReq struct {
+	AccountID int `form:"accountID" binding:"required"`
+}
+
+// QuerySZDZTradePositionRsp 持仓汇总查询返回模型(尚志大宗)
+type QuerySZDZTradePositionRsp struct {
+	Accountid       int64   `json:"accountid"  xorm:"'ACCOUNTID'"`             // 账号Id
+	Goodsid         int64   `json:"goodsid"  xorm:"'GOODSID'"`                 // 商品Id
+	Positionqty     int64   `json:"positionqty"  xorm:"'POSITIONQTY'"`         // 期初持仓数量
+	Holderamount    float64 `json:"holderamount"  xorm:"'HOLDERAMOUNT'"`       // 期初持仓总金额
+	Curpositionqty  int64   `json:"curpositionqty"  xorm:"'CURPOSITIONQTY'"`   // 当前持仓总数量
+	Curholderamount float64 `json:"curholderamount"  xorm:"'CURHOLDERAMOUNT'"` // 当前持仓总金额
+	Frozenqty       int64   `json:"frozenqty"  xorm:"'FROZENQTY'"`             // 持仓冻结数量
+	Otherfrozenqty  int64   `json:"otherfrozenqty"  xorm:"'OTHERFROZENQTY'"`   // 持仓其他冻结数量(交割冻结)
+	Openreqqty      int64   `json:"openreqqty"  xorm:"'OPENREQQTY'"`           // 开仓申请数量
+	Opentotalqty    int64   `json:"opentotalqty"  xorm:"'OPENTOTALQTY'"`       // 开仓总数量
+	Closetotalqty   int64   `json:"closetotalqty"  xorm:"'CLOSETOTALQTY'"`     // 平仓总数量
+	Tnqty           int64   `json:"tnqty"  xorm:"'TNQTY'"`                     // T+N冻结总量
+	Tnusedqty       int64   `json:"tnusedqty"  xorm:"'TNUSEDQTY'"`             // T+N使用量
+	Usedmargin      float64 `json:"usedmargin"  xorm:"'USEDMARGIN'"`           // 占用保证金
+	Curtdposition   int64   `json:"curtdposition"  xorm:"'CURTDPOSITION'"`     // 期末今日头寸
+	Fretdposition   int64   `json:"fretdposition"  xorm:"'FRETDPOSITION'"`     // 冻结今日头寸
+	Goodscode       string  `json:"goodscode"  xorm:"'GOODSCODE'"`             // 商品代码(内部)
+	Goodsname       string  `json:"goodsname"  xorm:"'GOODSNAME'"`             // 商品名称
+	Currencyid      int64   `json:"currencyid"  xorm:"'CURRENCYID'"`           // 报价货币ID
+	Goodunitid      int64   `json:"goodunitid"  xorm:"'GOODUNITID'"`           // 报价单位ID
+	Goodunit        string  `json:"goodunit" xorm:"'GOODUNIT'"`                // 报价单位
+	Agreeunit       float64 `json:"agreeunit"  xorm:"'AGREEUNIT'"`             // 合约单位
+	Decimalplace    int64   `json:"decimalplace"  xorm:"'DECIMALPLACE'"`       // 报价小数位
+	Marketid        int32   `json:"marketid"  xorm:"'MARKETID'"`               // 市场ID
+	Trademode       int32   `json:"trademode"  xorm:"'TRADEMODE'"`             // 交易模式
+	SZDZ3FreezQTY   int64   `json:"szdz3freezqty" xorm:"'SZDZ3FREEZQTY'"`      // 尚志大宗转换冻结总数量
+
+	BuyOrSell    int64   `json:"buyorsell"  xorm:"'BUYORSELL'" `   // 方向 - 0:买 1:卖
+	EnableQTY    int64   `json:"enableqty"  xorm:"'ENABLEQTY'"`    // 可用量
+	AveragePrice float64 `json:"averageprice" xorm:"AVERAGEPRICE"` // 持仓均价
+}
+
+// QuerySZDZTradePosition 持仓汇总查询(尚志大宗)
+// @Summary 持仓汇总查询(尚志大宗)
+// @Produce json
+// @Security ApiKeyAuth
+// @Param accountID query int true "资金账户"
+// @Success 200 {object} QuerySZDZTradePositionRsp
+// @Failure 500 {object} app.Response
+// @Router /SZDZ/QuerySZDZTradePosition [get]
+// @Tags 定制【尚志大宗】
+func QuerySZDZTradePosition(c *gin.Context) {
+	appG := app.Gin{C: c}
+
+	// 获取请求参数
+	var req QuerySZDZTradePositionReq
+	if err := appG.C.ShouldBindQuery(&req); err != nil {
+		logger.GetLogger().Errorf("QueryTradePosition failed: %s", err.Error())
+		appG.Response(http.StatusBadRequest, e.INVALID_PARAMS, nil)
+		return
+	}
+
+	// 查询数据
+	datas, err := models.GetSZDZBuyTradePosition(req.AccountID)
+	if err != nil {
+		// 查询失败
+		logger.GetLogger().Errorf("QueryConvertConfigReq failed: %s", err.Error())
+		appG.Response(http.StatusBadRequest, e.ERROR_QUERY_FAIL, nil)
+		return
+	}
+	// 构建返回数据
+	rst := make([]QuerySZDZTradePositionRsp, 0)
+	for _, v := range datas {
+		var tradePosition QuerySZDZTradePositionRsp
+		// 反射数据
+		// struct -> json
+		if jsonBytes, err := json.Marshal(v); err == nil {
+			// json -> struct
+			json.Unmarshal(jsonBytes, &tradePosition)
+
+			tradePosition.Accountid = v.Accountid
+			tradePosition.Goodsid = v.Goodsid
+			tradePosition.Positionqty = v.Positionqty
+			tradePosition.Holderamount = v.Holderamount
+			tradePosition.Curholderamount = v.Curholderamount
+			tradePosition.Otherfrozenqty = v.Otherfrozenqty
+			tradePosition.Openreqqty = v.Openreqqty
+			tradePosition.Opentotalqty = v.Opentotalqty
+			tradePosition.Closetotalqty = v.Closetotalqty
+			tradePosition.Tnqty = v.Tnqty
+			tradePosition.Tnusedqty = v.Tnusedqty
+			tradePosition.Usedmargin = v.Usedmargin
+			tradePosition.Curtdposition = v.Curtdposition
+			tradePosition.Fretdposition = v.Fretdposition
+			tradePosition.Goodscode = v.Goodscode
+			tradePosition.Goodsname = v.Goodsname
+			tradePosition.Currencyid = v.Currencyid
+			tradePosition.Goodunitid = v.Goodunitid
+			tradePosition.Goodunit = v.Goodunit
+			tradePosition.Agreeunit = v.Agreeunit
+			tradePosition.Decimalplace = v.Decimalplace
+			tradePosition.Marketid = v.Marketid
+			tradePosition.Trademode = v.Trademode
+			tradePosition.SZDZ3FreezQTY = v.SZDZ3FreezQTY
+
+			// 计算相关
+			tradePosition.Frozenqty = v.Frozenqty + v.SZDZ3FreezQTY // 需要加上
+			tradePosition.Curpositionqty = v.Curpositionqty + v.SZDZ3FreezQTY
+			tradePosition.EnableQTY = v.Curpositionqty - v.Frozenqty - v.Otherfrozenqty
+			averagePrice := tradePosition.Curholderamount / float64(tradePosition.Curpositionqty) / tradePosition.Agreeunit
+			tradePosition.AveragePrice, _ = strconv.ParseFloat(utils.FormatFloat(averagePrice, int(v.Decimalplace)), 64)
+			tradePosition.BuyOrSell = 0
+
+			rst = append(rst, tradePosition)
+		}
+	}
+
+	// 查询成功
+	logger.GetLogger().Debugln("QueryTradePosition successed: %v", rst)
+	appG.Response(http.StatusOK, e.SUCCESS, rst)
+}

+ 425 - 119
docs/docs.go

@@ -457,7 +457,7 @@ var doc = `{
                     },
                     },
                     {
                     {
                         "type": "boolean",
                         "type": "boolean",
-                        "description": "是否未读信息",
+                        "description": "是否只获取未读信息",
                         "name": "onlyUnRead",
                         "name": "onlyUnRead",
                         "in": "query"
                         "in": "query"
                     }
                     }
@@ -499,7 +499,7 @@ var doc = `{
                     "200": {
                     "200": {
                         "description": "OK",
                         "description": "OK",
                         "schema": {
                         "schema": {
-                            "$ref": "#/definitions/models.Tablecolumnconfig"
+                            "$ref": "#/definitions/common.QueryTableDefineRsp"
                         }
                         }
                     },
                     },
                     "500": {
                     "500": {
@@ -724,6 +724,40 @@ var doc = `{
                 }
                 }
             }
             }
         },
         },
+        "/History/QueryTSData": {
+            "get": {
+                "produces": [
+                    "application/json"
+                ],
+                "tags": [
+                    "通用服务"
+                ],
+                "summary": "分时图数据查询",
+                "parameters": [
+                    {
+                        "type": "string",
+                        "description": "商品代码",
+                        "name": "GoodsCode",
+                        "in": "query",
+                        "required": true
+                    }
+                ],
+                "responses": {
+                    "200": {
+                        "description": "OK",
+                        "schema": {
+                            "$ref": "#/definitions/quote.QueryTSDataRsp"
+                        }
+                    },
+                    "500": {
+                        "description": "Internal Server Error",
+                        "schema": {
+                            "$ref": "#/definitions/app.Response"
+                        }
+                    }
+                }
+            }
+        },
         "/Order/QueryHisTradeDetail": {
         "/Order/QueryHisTradeDetail": {
             "get": {
             "get": {
                 "security": [
                 "security": [
@@ -1262,6 +1296,45 @@ var doc = `{
                 }
                 }
             }
             }
         },
         },
+        "/SZDZ/QuerySZDZTradePosition": {
+            "get": {
+                "security": [
+                    {
+                        "ApiKeyAuth": []
+                    }
+                ],
+                "produces": [
+                    "application/json"
+                ],
+                "tags": [
+                    "定制【尚志大宗】"
+                ],
+                "summary": "持仓汇总查询(尚志大宗)",
+                "parameters": [
+                    {
+                        "type": "integer",
+                        "description": "资金账户",
+                        "name": "accountID",
+                        "in": "query",
+                        "required": true
+                    }
+                ],
+                "responses": {
+                    "200": {
+                        "description": "OK",
+                        "schema": {
+                            "$ref": "#/definitions/szdz.QuerySZDZTradePositionRsp"
+                        }
+                    },
+                    "500": {
+                        "description": "Internal Server Error",
+                        "schema": {
+                            "$ref": "#/definitions/app.Response"
+                        }
+                    }
+                }
+            }
+        },
         "/SZDZ/SearchWhite": {
         "/SZDZ/SearchWhite": {
             "get": {
             "get": {
                 "security": [
                 "security": [
@@ -1517,7 +1590,7 @@ var doc = `{
                 "summary": "获取用户信息",
                 "summary": "获取用户信息",
                 "parameters": [
                 "parameters": [
                     {
                     {
-                        "type": "string",
+                        "type": "integer",
                         "description": "用户ID",
                         "description": "用户ID",
                         "name": "userID",
                         "name": "userID",
                         "in": "query",
                         "in": "query",
@@ -1551,7 +1624,7 @@ var doc = `{
                 "summary": "获取用户邀请码",
                 "summary": "获取用户邀请码",
                 "parameters": [
                 "parameters": [
                     {
                     {
-                        "type": "string",
+                        "type": "integer",
                         "description": "用户ID",
                         "description": "用户ID",
                         "name": "userID",
                         "name": "userID",
                         "in": "query",
                         "in": "query",
@@ -1632,59 +1705,6 @@ var doc = `{
                 }
                 }
             }
             }
         },
         },
-        "common.OperationPrimaryMenu": {
-            "type": "object",
-            "properties": {
-                "Children": {
-                    "description": "二级功能菜单",
-                    "type": "array",
-                    "items": {
-                        "$ref": "#/definitions/common.OperationSecondaryMenu"
-                    }
-                },
-                "Key": {
-                    "description": "菜单KEY",
-                    "type": "string"
-                },
-                "Label": {
-                    "description": "菜单标题",
-                    "type": "string"
-                }
-            }
-        },
-        "common.OperationSecondaryMenu": {
-            "type": "object",
-            "properties": {
-                "Key": {
-                    "description": "菜单KEY",
-                    "type": "string"
-                },
-                "Label": {
-                    "description": "菜单标题",
-                    "type": "string"
-                },
-                "TabList": {
-                    "description": "三级功能菜单",
-                    "type": "array",
-                    "items": {
-                        "$ref": "#/definitions/common.OperationTabMenu"
-                    }
-                }
-            }
-        },
-        "common.OperationTabMenu": {
-            "type": "object",
-            "properties": {
-                "Key": {
-                    "description": "菜单KEY",
-                    "type": "string"
-                },
-                "Label": {
-                    "description": "菜单标题",
-                    "type": "string"
-                }
-            }
-        },
         "common.QueryNoticeRsp": {
         "common.QueryNoticeRsp": {
             "type": "object",
             "type": "object",
             "required": [
             "required": [
@@ -1761,90 +1781,57 @@ var doc = `{
                 }
                 }
             }
             }
         },
         },
-        "common.QueryTraderMenuRsp": {
+        "common.QueryTableDefineRsp": {
             "type": "object",
             "type": "object",
+            "required": [
+                "tablekey"
+            ],
             "properties": {
             "properties": {
-                "OperationMenu": {
-                    "description": "功能菜单",
+                "columns": {
+                    "description": "列头信息数组",
                     "type": "array",
                     "type": "array",
                     "items": {
                     "items": {
-                        "$ref": "#/definitions/common.OperationPrimaryMenu"
+                        "$ref": "#/definitions/models.Tablecolumnconfig"
                     }
                     }
                 },
                 },
-                "QuoteMenu": {
-                    "description": "报价牌分类菜单",
-                    "type": "array",
-                    "items": {
-                        "$ref": "#/definitions/common.QuotePrimaryMenu"
-                    }
-                }
-            }
-        },
-        "common.QuotePrimaryMenu": {
-            "type": "object",
-            "properties": {
-                "Index": {
-                    "description": "序号",
-                    "type": "integer"
+                "remark": {
+                    "description": "Remark",
+                    "type": "string"
                 },
                 },
-                "Key": {
-                    "description": "键名",
+                "tabelmenu": {
+                    "description": "列表菜单",
                     "type": "string"
                     "type": "string"
                 },
                 },
-                "Name": {
-                    "description": "菜单名称",
+                "tablekey": {
+                    "description": "列表Key",
                     "type": "string"
                     "type": "string"
                 },
                 },
-                "SubMenus": {
-                    "description": "子菜单",
-                    "type": "array",
-                    "items": {
-                        "$ref": "#/definitions/common.QuoteSecondaryMenu"
-                    }
+                "tablename": {
+                    "description": "列表名称",
+                    "type": "string"
                 },
                 },
-                "SubTitleType": {
-                    "description": "子菜单标题模式:0-市场名称;1-外部交易所名称",
+                "tabletype": {
+                    "description": "列表类型 - 1:管理端 2:终端",
                     "type": "integer"
                     "type": "integer"
-                },
-                "TradeModes": {
-                    "description": "包含市场交易类型",
-                    "type": "string"
                 }
                 }
             }
             }
         },
         },
-        "common.QuoteSecondaryMenu": {
+        "common.QueryTraderMenuRsp": {
             "type": "object",
             "type": "object",
             "properties": {
             "properties": {
-                "ExExchangeCode": {
-                    "description": "外部交易所代码",
-                    "type": "string"
-                },
-                "ExExchangeID": {
-                    "description": "外部交易所ID",
-                    "type": "integer"
-                },
-                "GoodsGroupIDs": {
-                    "description": "商品组ID列表",
+                "OperationMenu": {
+                    "description": "功能菜单",
                     "type": "array",
                     "type": "array",
                     "items": {
                     "items": {
-                        "type": "integer"
+                        "$ref": "#/definitions/models.OperationPrimaryMenu"
                     }
                     }
                 },
                 },
-                "Index": {
-                    "description": "序号",
-                    "type": "integer"
-                },
-                "MarketID": {
-                    "description": "市场ID",
-                    "type": "integer"
-                },
-                "MenuTitle": {
-                    "description": "菜单标题(市场名称或外部交易所名称)",
-                    "type": "string"
-                },
-                "TradeMode": {
-                    "description": "交易模式",
-                    "type": "integer"
+                "QuoteMenu": {
+                    "description": "报价牌分类菜单",
+                    "type": "array",
+                    "items": {
+                        "$ref": "#/definitions/models.QuotePrimaryMenu"
+                    }
                 }
                 }
             }
             }
         },
         },
@@ -3279,6 +3266,127 @@ var doc = `{
                 }
                 }
             }
             }
         },
         },
+        "models.OperationPrimaryMenu": {
+            "type": "object",
+            "properties": {
+                "Children": {
+                    "description": "二级功能菜单",
+                    "type": "array",
+                    "items": {
+                        "$ref": "#/definitions/models.OperationSecondaryMenu"
+                    }
+                },
+                "Key": {
+                    "description": "菜单KEY",
+                    "type": "string"
+                },
+                "Label": {
+                    "description": "菜单标题",
+                    "type": "string"
+                }
+            }
+        },
+        "models.OperationSecondaryMenu": {
+            "type": "object",
+            "properties": {
+                "Key": {
+                    "description": "菜单KEY",
+                    "type": "string"
+                },
+                "Label": {
+                    "description": "菜单标题",
+                    "type": "string"
+                },
+                "TabList": {
+                    "description": "三级功能菜单",
+                    "type": "array",
+                    "items": {
+                        "$ref": "#/definitions/models.OperationTabMenu"
+                    }
+                }
+            }
+        },
+        "models.OperationTabMenu": {
+            "type": "object",
+            "properties": {
+                "Key": {
+                    "description": "菜单KEY",
+                    "type": "string"
+                },
+                "Label": {
+                    "description": "菜单标题",
+                    "type": "string"
+                }
+            }
+        },
+        "models.QuotePrimaryMenu": {
+            "type": "object",
+            "properties": {
+                "Index": {
+                    "description": "序号",
+                    "type": "integer"
+                },
+                "Key": {
+                    "description": "键名",
+                    "type": "string"
+                },
+                "Name": {
+                    "description": "菜单名称",
+                    "type": "string"
+                },
+                "SubMenus": {
+                    "description": "子菜单",
+                    "type": "array",
+                    "items": {
+                        "$ref": "#/definitions/models.QuoteSecondaryMenu"
+                    }
+                },
+                "SubTitleType": {
+                    "description": "子菜单标题模式:0-市场名称;1-外部交易所名称",
+                    "type": "integer"
+                },
+                "TradeModes": {
+                    "description": "包含市场交易类型",
+                    "type": "string"
+                }
+            }
+        },
+        "models.QuoteSecondaryMenu": {
+            "type": "object",
+            "properties": {
+                "ExExchangeCode": {
+                    "description": "外部交易所代码",
+                    "type": "string"
+                },
+                "ExExchangeID": {
+                    "description": "外部交易所ID",
+                    "type": "integer"
+                },
+                "GoodsGroupIDs": {
+                    "description": "商品组ID列表",
+                    "type": "array",
+                    "items": {
+                        "type": "integer"
+                    }
+                },
+                "Index": {
+                    "description": "序号",
+                    "type": "integer"
+                },
+                "MarketID": {
+                    "description": "市场ID",
+                    "type": "integer"
+                },
+                "MenuTitle": {
+                    "description": "菜单标题(市场名称或外部交易所名称)",
+                    "type": "string"
+                },
+                "TradeMode": {
+                    "description": "交易模式",
+                    "type": "integer"
+                }
+            }
+        },
         "models.Szdz3convertconfig": {
         "models.Szdz3convertconfig": {
             "type": "object",
             "type": "object",
             "required": [
             "required": [
@@ -4687,6 +4795,83 @@ var doc = `{
                 }
                 }
             }
             }
         },
         },
+        "quote.HistoryData": {
+            "type": "object",
+            "properties": {
+                "Opened": {
+                    "description": "开盘价",
+                    "type": "number"
+                },
+                "closed": {
+                    "description": "收盘价",
+                    "type": "number"
+                },
+                "highest": {
+                    "description": "收盘价",
+                    "type": "number"
+                },
+                "holdVolume": {
+                    "description": "持仓量",
+                    "type": "number"
+                },
+                "lowest": {
+                    "description": "最低价",
+                    "type": "number"
+                },
+                "settle": {
+                    "description": "结算价",
+                    "type": "number"
+                },
+                "timeStamp": {
+                    "description": "开盘时间",
+                    "type": "string"
+                },
+                "totleTurnover": {
+                    "description": "总金额",
+                    "type": "number"
+                },
+                "totleVolume": {
+                    "description": "总量",
+                    "type": "number"
+                }
+            }
+        },
+        "quote.QueryTSDataRsp": {
+            "type": "object",
+            "properties": {
+                "decimalPlace": {
+                    "description": "小数位",
+                    "type": "integer"
+                },
+                "endTime": {
+                    "description": "结束时间",
+                    "type": "string"
+                },
+                "goodsCode": {
+                    "description": "商品代码",
+                    "type": "string"
+                },
+                "historyDatas": {
+                    "description": "历史数据",
+                    "type": "array",
+                    "items": {
+                        "$ref": "#/definitions/quote.HistoryData"
+                    }
+                },
+                "preSettle": {
+                    "description": "昨结",
+                    "type": "number"
+                },
+                "startTime": {
+                    "description": "开始时间",
+                    "type": "string"
+                },
+                "tradeDate": {
+                    "description": "交易日",
+                    "type": "string"
+                }
+            }
+        },
         "szdz.QueryConvertLogRsp": {
         "szdz.QueryConvertLogRsp": {
             "type": "object",
             "type": "object",
             "required": [
             "required": [
@@ -4944,6 +5129,127 @@ var doc = `{
                 }
                 }
             }
             }
         },
         },
+        "szdz.QuerySZDZTradePositionRsp": {
+            "type": "object",
+            "properties": {
+                "accountid": {
+                    "description": "账号Id",
+                    "type": "integer"
+                },
+                "agreeunit": {
+                    "description": "合约单位",
+                    "type": "number"
+                },
+                "averageprice": {
+                    "description": "持仓均价",
+                    "type": "number"
+                },
+                "buyorsell": {
+                    "description": "方向 - 0:买 1:卖",
+                    "type": "integer"
+                },
+                "closetotalqty": {
+                    "description": "平仓总数量",
+                    "type": "integer"
+                },
+                "curholderamount": {
+                    "description": "当前持仓总金额",
+                    "type": "number"
+                },
+                "curpositionqty": {
+                    "description": "当前持仓总数量",
+                    "type": "integer"
+                },
+                "currencyid": {
+                    "description": "报价货币ID",
+                    "type": "integer"
+                },
+                "curtdposition": {
+                    "description": "期末今日头寸",
+                    "type": "integer"
+                },
+                "decimalplace": {
+                    "description": "报价小数位",
+                    "type": "integer"
+                },
+                "enableqty": {
+                    "description": "可用量",
+                    "type": "integer"
+                },
+                "fretdposition": {
+                    "description": "冻结今日头寸",
+                    "type": "integer"
+                },
+                "frozenqty": {
+                    "description": "持仓冻结数量",
+                    "type": "integer"
+                },
+                "goodscode": {
+                    "description": "商品代码(内部)",
+                    "type": "string"
+                },
+                "goodsid": {
+                    "description": "商品Id",
+                    "type": "integer"
+                },
+                "goodsname": {
+                    "description": "商品名称",
+                    "type": "string"
+                },
+                "goodunit": {
+                    "description": "报价单位",
+                    "type": "string"
+                },
+                "goodunitid": {
+                    "description": "报价单位ID",
+                    "type": "integer"
+                },
+                "holderamount": {
+                    "description": "期初持仓总金额",
+                    "type": "number"
+                },
+                "marketid": {
+                    "description": "市场ID",
+                    "type": "integer"
+                },
+                "openreqqty": {
+                    "description": "开仓申请数量",
+                    "type": "integer"
+                },
+                "opentotalqty": {
+                    "description": "开仓总数量",
+                    "type": "integer"
+                },
+                "otherfrozenqty": {
+                    "description": "持仓其他冻结数量(交割冻结)",
+                    "type": "integer"
+                },
+                "positionqty": {
+                    "description": "期初持仓数量",
+                    "type": "integer"
+                },
+                "szdz3freezqty": {
+                    "description": "尚志大宗转换冻结总数量",
+                    "type": "integer"
+                },
+                "tnqty": {
+                    "description": "T+N冻结总量",
+                    "type": "integer"
+                },
+                "tnusedqty": {
+                    "description": "T+N使用量",
+                    "type": "integer"
+                },
+                "trademode": {
+                    "description": "交易模式",
+                    "type": "integer"
+                },
+                "usedmargin": {
+                    "description": "占用保证金",
+                    "type": "number"
+                }
+            }
+        },
         "taaccount.QueryAmountLogRsp": {
         "taaccount.QueryAmountLogRsp": {
             "type": "object",
             "type": "object",
             "required": [
             "required": [

+ 425 - 119
docs/swagger.json

@@ -441,7 +441,7 @@
                     },
                     },
                     {
                     {
                         "type": "boolean",
                         "type": "boolean",
-                        "description": "是否未读信息",
+                        "description": "是否只获取未读信息",
                         "name": "onlyUnRead",
                         "name": "onlyUnRead",
                         "in": "query"
                         "in": "query"
                     }
                     }
@@ -483,7 +483,7 @@
                     "200": {
                     "200": {
                         "description": "OK",
                         "description": "OK",
                         "schema": {
                         "schema": {
-                            "$ref": "#/definitions/models.Tablecolumnconfig"
+                            "$ref": "#/definitions/common.QueryTableDefineRsp"
                         }
                         }
                     },
                     },
                     "500": {
                     "500": {
@@ -708,6 +708,40 @@
                 }
                 }
             }
             }
         },
         },
+        "/History/QueryTSData": {
+            "get": {
+                "produces": [
+                    "application/json"
+                ],
+                "tags": [
+                    "通用服务"
+                ],
+                "summary": "分时图数据查询",
+                "parameters": [
+                    {
+                        "type": "string",
+                        "description": "商品代码",
+                        "name": "GoodsCode",
+                        "in": "query",
+                        "required": true
+                    }
+                ],
+                "responses": {
+                    "200": {
+                        "description": "OK",
+                        "schema": {
+                            "$ref": "#/definitions/quote.QueryTSDataRsp"
+                        }
+                    },
+                    "500": {
+                        "description": "Internal Server Error",
+                        "schema": {
+                            "$ref": "#/definitions/app.Response"
+                        }
+                    }
+                }
+            }
+        },
         "/Order/QueryHisTradeDetail": {
         "/Order/QueryHisTradeDetail": {
             "get": {
             "get": {
                 "security": [
                 "security": [
@@ -1246,6 +1280,45 @@
                 }
                 }
             }
             }
         },
         },
+        "/SZDZ/QuerySZDZTradePosition": {
+            "get": {
+                "security": [
+                    {
+                        "ApiKeyAuth": []
+                    }
+                ],
+                "produces": [
+                    "application/json"
+                ],
+                "tags": [
+                    "定制【尚志大宗】"
+                ],
+                "summary": "持仓汇总查询(尚志大宗)",
+                "parameters": [
+                    {
+                        "type": "integer",
+                        "description": "资金账户",
+                        "name": "accountID",
+                        "in": "query",
+                        "required": true
+                    }
+                ],
+                "responses": {
+                    "200": {
+                        "description": "OK",
+                        "schema": {
+                            "$ref": "#/definitions/szdz.QuerySZDZTradePositionRsp"
+                        }
+                    },
+                    "500": {
+                        "description": "Internal Server Error",
+                        "schema": {
+                            "$ref": "#/definitions/app.Response"
+                        }
+                    }
+                }
+            }
+        },
         "/SZDZ/SearchWhite": {
         "/SZDZ/SearchWhite": {
             "get": {
             "get": {
                 "security": [
                 "security": [
@@ -1501,7 +1574,7 @@
                 "summary": "获取用户信息",
                 "summary": "获取用户信息",
                 "parameters": [
                 "parameters": [
                     {
                     {
-                        "type": "string",
+                        "type": "integer",
                         "description": "用户ID",
                         "description": "用户ID",
                         "name": "userID",
                         "name": "userID",
                         "in": "query",
                         "in": "query",
@@ -1535,7 +1608,7 @@
                 "summary": "获取用户邀请码",
                 "summary": "获取用户邀请码",
                 "parameters": [
                 "parameters": [
                     {
                     {
-                        "type": "string",
+                        "type": "integer",
                         "description": "用户ID",
                         "description": "用户ID",
                         "name": "userID",
                         "name": "userID",
                         "in": "query",
                         "in": "query",
@@ -1616,59 +1689,6 @@
                 }
                 }
             }
             }
         },
         },
-        "common.OperationPrimaryMenu": {
-            "type": "object",
-            "properties": {
-                "Children": {
-                    "description": "二级功能菜单",
-                    "type": "array",
-                    "items": {
-                        "$ref": "#/definitions/common.OperationSecondaryMenu"
-                    }
-                },
-                "Key": {
-                    "description": "菜单KEY",
-                    "type": "string"
-                },
-                "Label": {
-                    "description": "菜单标题",
-                    "type": "string"
-                }
-            }
-        },
-        "common.OperationSecondaryMenu": {
-            "type": "object",
-            "properties": {
-                "Key": {
-                    "description": "菜单KEY",
-                    "type": "string"
-                },
-                "Label": {
-                    "description": "菜单标题",
-                    "type": "string"
-                },
-                "TabList": {
-                    "description": "三级功能菜单",
-                    "type": "array",
-                    "items": {
-                        "$ref": "#/definitions/common.OperationTabMenu"
-                    }
-                }
-            }
-        },
-        "common.OperationTabMenu": {
-            "type": "object",
-            "properties": {
-                "Key": {
-                    "description": "菜单KEY",
-                    "type": "string"
-                },
-                "Label": {
-                    "description": "菜单标题",
-                    "type": "string"
-                }
-            }
-        },
         "common.QueryNoticeRsp": {
         "common.QueryNoticeRsp": {
             "type": "object",
             "type": "object",
             "required": [
             "required": [
@@ -1745,90 +1765,57 @@
                 }
                 }
             }
             }
         },
         },
-        "common.QueryTraderMenuRsp": {
+        "common.QueryTableDefineRsp": {
             "type": "object",
             "type": "object",
+            "required": [
+                "tablekey"
+            ],
             "properties": {
             "properties": {
-                "OperationMenu": {
-                    "description": "功能菜单",
+                "columns": {
+                    "description": "列头信息数组",
                     "type": "array",
                     "type": "array",
                     "items": {
                     "items": {
-                        "$ref": "#/definitions/common.OperationPrimaryMenu"
+                        "$ref": "#/definitions/models.Tablecolumnconfig"
                     }
                     }
                 },
                 },
-                "QuoteMenu": {
-                    "description": "报价牌分类菜单",
-                    "type": "array",
-                    "items": {
-                        "$ref": "#/definitions/common.QuotePrimaryMenu"
-                    }
-                }
-            }
-        },
-        "common.QuotePrimaryMenu": {
-            "type": "object",
-            "properties": {
-                "Index": {
-                    "description": "序号",
-                    "type": "integer"
+                "remark": {
+                    "description": "Remark",
+                    "type": "string"
                 },
                 },
-                "Key": {
-                    "description": "键名",
+                "tabelmenu": {
+                    "description": "列表菜单",
                     "type": "string"
                     "type": "string"
                 },
                 },
-                "Name": {
-                    "description": "菜单名称",
+                "tablekey": {
+                    "description": "列表Key",
                     "type": "string"
                     "type": "string"
                 },
                 },
-                "SubMenus": {
-                    "description": "子菜单",
-                    "type": "array",
-                    "items": {
-                        "$ref": "#/definitions/common.QuoteSecondaryMenu"
-                    }
+                "tablename": {
+                    "description": "列表名称",
+                    "type": "string"
                 },
                 },
-                "SubTitleType": {
-                    "description": "子菜单标题模式:0-市场名称;1-外部交易所名称",
+                "tabletype": {
+                    "description": "列表类型 - 1:管理端 2:终端",
                     "type": "integer"
                     "type": "integer"
-                },
-                "TradeModes": {
-                    "description": "包含市场交易类型",
-                    "type": "string"
                 }
                 }
             }
             }
         },
         },
-        "common.QuoteSecondaryMenu": {
+        "common.QueryTraderMenuRsp": {
             "type": "object",
             "type": "object",
             "properties": {
             "properties": {
-                "ExExchangeCode": {
-                    "description": "外部交易所代码",
-                    "type": "string"
-                },
-                "ExExchangeID": {
-                    "description": "外部交易所ID",
-                    "type": "integer"
-                },
-                "GoodsGroupIDs": {
-                    "description": "商品组ID列表",
+                "OperationMenu": {
+                    "description": "功能菜单",
                     "type": "array",
                     "type": "array",
                     "items": {
                     "items": {
-                        "type": "integer"
+                        "$ref": "#/definitions/models.OperationPrimaryMenu"
                     }
                     }
                 },
                 },
-                "Index": {
-                    "description": "序号",
-                    "type": "integer"
-                },
-                "MarketID": {
-                    "description": "市场ID",
-                    "type": "integer"
-                },
-                "MenuTitle": {
-                    "description": "菜单标题(市场名称或外部交易所名称)",
-                    "type": "string"
-                },
-                "TradeMode": {
-                    "description": "交易模式",
-                    "type": "integer"
+                "QuoteMenu": {
+                    "description": "报价牌分类菜单",
+                    "type": "array",
+                    "items": {
+                        "$ref": "#/definitions/models.QuotePrimaryMenu"
+                    }
                 }
                 }
             }
             }
         },
         },
@@ -3263,6 +3250,127 @@
                 }
                 }
             }
             }
         },
         },
+        "models.OperationPrimaryMenu": {
+            "type": "object",
+            "properties": {
+                "Children": {
+                    "description": "二级功能菜单",
+                    "type": "array",
+                    "items": {
+                        "$ref": "#/definitions/models.OperationSecondaryMenu"
+                    }
+                },
+                "Key": {
+                    "description": "菜单KEY",
+                    "type": "string"
+                },
+                "Label": {
+                    "description": "菜单标题",
+                    "type": "string"
+                }
+            }
+        },
+        "models.OperationSecondaryMenu": {
+            "type": "object",
+            "properties": {
+                "Key": {
+                    "description": "菜单KEY",
+                    "type": "string"
+                },
+                "Label": {
+                    "description": "菜单标题",
+                    "type": "string"
+                },
+                "TabList": {
+                    "description": "三级功能菜单",
+                    "type": "array",
+                    "items": {
+                        "$ref": "#/definitions/models.OperationTabMenu"
+                    }
+                }
+            }
+        },
+        "models.OperationTabMenu": {
+            "type": "object",
+            "properties": {
+                "Key": {
+                    "description": "菜单KEY",
+                    "type": "string"
+                },
+                "Label": {
+                    "description": "菜单标题",
+                    "type": "string"
+                }
+            }
+        },
+        "models.QuotePrimaryMenu": {
+            "type": "object",
+            "properties": {
+                "Index": {
+                    "description": "序号",
+                    "type": "integer"
+                },
+                "Key": {
+                    "description": "键名",
+                    "type": "string"
+                },
+                "Name": {
+                    "description": "菜单名称",
+                    "type": "string"
+                },
+                "SubMenus": {
+                    "description": "子菜单",
+                    "type": "array",
+                    "items": {
+                        "$ref": "#/definitions/models.QuoteSecondaryMenu"
+                    }
+                },
+                "SubTitleType": {
+                    "description": "子菜单标题模式:0-市场名称;1-外部交易所名称",
+                    "type": "integer"
+                },
+                "TradeModes": {
+                    "description": "包含市场交易类型",
+                    "type": "string"
+                }
+            }
+        },
+        "models.QuoteSecondaryMenu": {
+            "type": "object",
+            "properties": {
+                "ExExchangeCode": {
+                    "description": "外部交易所代码",
+                    "type": "string"
+                },
+                "ExExchangeID": {
+                    "description": "外部交易所ID",
+                    "type": "integer"
+                },
+                "GoodsGroupIDs": {
+                    "description": "商品组ID列表",
+                    "type": "array",
+                    "items": {
+                        "type": "integer"
+                    }
+                },
+                "Index": {
+                    "description": "序号",
+                    "type": "integer"
+                },
+                "MarketID": {
+                    "description": "市场ID",
+                    "type": "integer"
+                },
+                "MenuTitle": {
+                    "description": "菜单标题(市场名称或外部交易所名称)",
+                    "type": "string"
+                },
+                "TradeMode": {
+                    "description": "交易模式",
+                    "type": "integer"
+                }
+            }
+        },
         "models.Szdz3convertconfig": {
         "models.Szdz3convertconfig": {
             "type": "object",
             "type": "object",
             "required": [
             "required": [
@@ -4671,6 +4779,83 @@
                 }
                 }
             }
             }
         },
         },
+        "quote.HistoryData": {
+            "type": "object",
+            "properties": {
+                "Opened": {
+                    "description": "开盘价",
+                    "type": "number"
+                },
+                "closed": {
+                    "description": "收盘价",
+                    "type": "number"
+                },
+                "highest": {
+                    "description": "收盘价",
+                    "type": "number"
+                },
+                "holdVolume": {
+                    "description": "持仓量",
+                    "type": "number"
+                },
+                "lowest": {
+                    "description": "最低价",
+                    "type": "number"
+                },
+                "settle": {
+                    "description": "结算价",
+                    "type": "number"
+                },
+                "timeStamp": {
+                    "description": "开盘时间",
+                    "type": "string"
+                },
+                "totleTurnover": {
+                    "description": "总金额",
+                    "type": "number"
+                },
+                "totleVolume": {
+                    "description": "总量",
+                    "type": "number"
+                }
+            }
+        },
+        "quote.QueryTSDataRsp": {
+            "type": "object",
+            "properties": {
+                "decimalPlace": {
+                    "description": "小数位",
+                    "type": "integer"
+                },
+                "endTime": {
+                    "description": "结束时间",
+                    "type": "string"
+                },
+                "goodsCode": {
+                    "description": "商品代码",
+                    "type": "string"
+                },
+                "historyDatas": {
+                    "description": "历史数据",
+                    "type": "array",
+                    "items": {
+                        "$ref": "#/definitions/quote.HistoryData"
+                    }
+                },
+                "preSettle": {
+                    "description": "昨结",
+                    "type": "number"
+                },
+                "startTime": {
+                    "description": "开始时间",
+                    "type": "string"
+                },
+                "tradeDate": {
+                    "description": "交易日",
+                    "type": "string"
+                }
+            }
+        },
         "szdz.QueryConvertLogRsp": {
         "szdz.QueryConvertLogRsp": {
             "type": "object",
             "type": "object",
             "required": [
             "required": [
@@ -4928,6 +5113,127 @@
                 }
                 }
             }
             }
         },
         },
+        "szdz.QuerySZDZTradePositionRsp": {
+            "type": "object",
+            "properties": {
+                "accountid": {
+                    "description": "账号Id",
+                    "type": "integer"
+                },
+                "agreeunit": {
+                    "description": "合约单位",
+                    "type": "number"
+                },
+                "averageprice": {
+                    "description": "持仓均价",
+                    "type": "number"
+                },
+                "buyorsell": {
+                    "description": "方向 - 0:买 1:卖",
+                    "type": "integer"
+                },
+                "closetotalqty": {
+                    "description": "平仓总数量",
+                    "type": "integer"
+                },
+                "curholderamount": {
+                    "description": "当前持仓总金额",
+                    "type": "number"
+                },
+                "curpositionqty": {
+                    "description": "当前持仓总数量",
+                    "type": "integer"
+                },
+                "currencyid": {
+                    "description": "报价货币ID",
+                    "type": "integer"
+                },
+                "curtdposition": {
+                    "description": "期末今日头寸",
+                    "type": "integer"
+                },
+                "decimalplace": {
+                    "description": "报价小数位",
+                    "type": "integer"
+                },
+                "enableqty": {
+                    "description": "可用量",
+                    "type": "integer"
+                },
+                "fretdposition": {
+                    "description": "冻结今日头寸",
+                    "type": "integer"
+                },
+                "frozenqty": {
+                    "description": "持仓冻结数量",
+                    "type": "integer"
+                },
+                "goodscode": {
+                    "description": "商品代码(内部)",
+                    "type": "string"
+                },
+                "goodsid": {
+                    "description": "商品Id",
+                    "type": "integer"
+                },
+                "goodsname": {
+                    "description": "商品名称",
+                    "type": "string"
+                },
+                "goodunit": {
+                    "description": "报价单位",
+                    "type": "string"
+                },
+                "goodunitid": {
+                    "description": "报价单位ID",
+                    "type": "integer"
+                },
+                "holderamount": {
+                    "description": "期初持仓总金额",
+                    "type": "number"
+                },
+                "marketid": {
+                    "description": "市场ID",
+                    "type": "integer"
+                },
+                "openreqqty": {
+                    "description": "开仓申请数量",
+                    "type": "integer"
+                },
+                "opentotalqty": {
+                    "description": "开仓总数量",
+                    "type": "integer"
+                },
+                "otherfrozenqty": {
+                    "description": "持仓其他冻结数量(交割冻结)",
+                    "type": "integer"
+                },
+                "positionqty": {
+                    "description": "期初持仓数量",
+                    "type": "integer"
+                },
+                "szdz3freezqty": {
+                    "description": "尚志大宗转换冻结总数量",
+                    "type": "integer"
+                },
+                "tnqty": {
+                    "description": "T+N冻结总量",
+                    "type": "integer"
+                },
+                "tnusedqty": {
+                    "description": "T+N使用量",
+                    "type": "integer"
+                },
+                "trademode": {
+                    "description": "交易模式",
+                    "type": "integer"
+                },
+                "usedmargin": {
+                    "description": "占用保证金",
+                    "type": "number"
+                }
+            }
+        },
         "taaccount.QueryAmountLogRsp": {
         "taaccount.QueryAmountLogRsp": {
             "type": "object",
             "type": "object",
             "required": [
             "required": [

+ 309 - 92
docs/swagger.yaml

@@ -18,43 +18,6 @@ definitions:
         description: 总条数
         description: 总条数
         type: integer
         type: integer
     type: object
     type: object
-  common.OperationPrimaryMenu:
-    properties:
-      Children:
-        description: 二级功能菜单
-        items:
-          $ref: '#/definitions/common.OperationSecondaryMenu'
-        type: array
-      Key:
-        description: 菜单KEY
-        type: string
-      Label:
-        description: 菜单标题
-        type: string
-    type: object
-  common.OperationSecondaryMenu:
-    properties:
-      Key:
-        description: 菜单KEY
-        type: string
-      Label:
-        description: 菜单标题
-        type: string
-      TabList:
-        description: 三级功能菜单
-        items:
-          $ref: '#/definitions/common.OperationTabMenu'
-        type: array
-    type: object
-  common.OperationTabMenu:
-    properties:
-      Key:
-        description: 菜单KEY
-        type: string
-      Label:
-        description: 菜单标题
-        type: string
-    type: object
   common.QueryNoticeRsp:
   common.QueryNoticeRsp:
     properties:
     properties:
       auditoruserid:
       auditoruserid:
@@ -111,67 +74,43 @@ definitions:
     required:
     required:
     - autoid
     - autoid
     type: object
     type: object
-  common.QueryTraderMenuRsp:
+  common.QueryTableDefineRsp:
     properties:
     properties:
-      OperationMenu:
-        description: 功能菜单
+      columns:
+        description: 列头信息数组
         items:
         items:
-          $ref: '#/definitions/common.OperationPrimaryMenu'
+          $ref: '#/definitions/models.Tablecolumnconfig'
         type: array
         type: array
-      QuoteMenu:
-        description: 报价牌分类菜单
-        items:
-          $ref: '#/definitions/common.QuotePrimaryMenu'
-        type: array
-    type: object
-  common.QuotePrimaryMenu:
-    properties:
-      Index:
-        description: 序号
-        type: integer
-      Key:
-        description: 键名
+      remark:
+        description: Remark
         type: string
         type: string
-      Name:
-        description: 菜单名称
+      tabelmenu:
+        description: 列表菜单
         type: string
         type: string
-      SubMenus:
-        description: 子菜单
-        items:
-          $ref: '#/definitions/common.QuoteSecondaryMenu'
-        type: array
-      SubTitleType:
-        description: 子菜单标题模式:0-市场名称;1-外部交易所名称
-        type: integer
-      TradeModes:
-        description: 包含市场交易类型
+      tablekey:
+        description: 列表Key
         type: string
         type: string
-    type: object
-  common.QuoteSecondaryMenu:
-    properties:
-      ExExchangeCode:
-        description: 外部交易所代码
+      tablename:
+        description: 列表名称
         type: string
         type: string
-      ExExchangeID:
-        description: 外部交易所ID
+      tabletype:
+        description: 列表类型 - 1:管理端 2:终端
         type: integer
         type: integer
-      GoodsGroupIDs:
-        description: 商品组ID列表
+    required:
+    - tablekey
+    type: object
+  common.QueryTraderMenuRsp:
+    properties:
+      OperationMenu:
+        description: 功能菜单
         items:
         items:
-          type: integer
+          $ref: '#/definitions/models.OperationPrimaryMenu'
+        type: array
+      QuoteMenu:
+        description: 报价牌分类菜单
+        items:
+          $ref: '#/definitions/models.QuotePrimaryMenu'
         type: array
         type: array
-      Index:
-        description: 序号
-        type: integer
-      MarketID:
-        description: 市场ID
-        type: integer
-      MenuTitle:
-        description: 菜单标题(市场名称或外部交易所名称)
-        type: string
-      TradeMode:
-        description: 交易模式
-        type: integer
     type: object
     type: object
   cptrade.Cptradepositioncancel:
   cptrade.Cptradepositioncancel:
     properties:
     properties:
@@ -1244,6 +1183,92 @@ definitions:
     required:
     required:
     - spotcontractid
     - spotcontractid
     type: object
     type: object
+  models.OperationPrimaryMenu:
+    properties:
+      Children:
+        description: 二级功能菜单
+        items:
+          $ref: '#/definitions/models.OperationSecondaryMenu'
+        type: array
+      Key:
+        description: 菜单KEY
+        type: string
+      Label:
+        description: 菜单标题
+        type: string
+    type: object
+  models.OperationSecondaryMenu:
+    properties:
+      Key:
+        description: 菜单KEY
+        type: string
+      Label:
+        description: 菜单标题
+        type: string
+      TabList:
+        description: 三级功能菜单
+        items:
+          $ref: '#/definitions/models.OperationTabMenu'
+        type: array
+    type: object
+  models.OperationTabMenu:
+    properties:
+      Key:
+        description: 菜单KEY
+        type: string
+      Label:
+        description: 菜单标题
+        type: string
+    type: object
+  models.QuotePrimaryMenu:
+    properties:
+      Index:
+        description: 序号
+        type: integer
+      Key:
+        description: 键名
+        type: string
+      Name:
+        description: 菜单名称
+        type: string
+      SubMenus:
+        description: 子菜单
+        items:
+          $ref: '#/definitions/models.QuoteSecondaryMenu'
+        type: array
+      SubTitleType:
+        description: 子菜单标题模式:0-市场名称;1-外部交易所名称
+        type: integer
+      TradeModes:
+        description: 包含市场交易类型
+        type: string
+    type: object
+  models.QuoteSecondaryMenu:
+    properties:
+      ExExchangeCode:
+        description: 外部交易所代码
+        type: string
+      ExExchangeID:
+        description: 外部交易所ID
+        type: integer
+      GoodsGroupIDs:
+        description: 商品组ID列表
+        items:
+          type: integer
+        type: array
+      Index:
+        description: 序号
+        type: integer
+      MarketID:
+        description: 市场ID
+        type: integer
+      MenuTitle:
+        description: 菜单标题(市场名称或外部交易所名称)
+        type: string
+      TradeMode:
+        description: 交易模式
+        type: integer
+    type: object
   models.Szdz3convertconfig:
   models.Szdz3convertconfig:
     properties:
     properties:
       canin:
       canin:
@@ -2303,6 +2328,62 @@ definitions:
     required:
     required:
     - goodsid
     - goodsid
     type: object
     type: object
+  quote.HistoryData:
+    properties:
+      Opened:
+        description: 开盘价
+        type: number
+      closed:
+        description: 收盘价
+        type: number
+      highest:
+        description: 收盘价
+        type: number
+      holdVolume:
+        description: 持仓量
+        type: number
+      lowest:
+        description: 最低价
+        type: number
+      settle:
+        description: 结算价
+        type: number
+      timeStamp:
+        description: 开盘时间
+        type: string
+      totleTurnover:
+        description: 总金额
+        type: number
+      totleVolume:
+        description: 总量
+        type: number
+    type: object
+  quote.QueryTSDataRsp:
+    properties:
+      decimalPlace:
+        description: 小数位
+        type: integer
+      endTime:
+        description: 结束时间
+        type: string
+      goodsCode:
+        description: 商品代码
+        type: string
+      historyDatas:
+        description: 历史数据
+        items:
+          $ref: '#/definitions/quote.HistoryData'
+        type: array
+      preSettle:
+        description: 昨结
+        type: number
+      startTime:
+        description: 开始时间
+        type: string
+      tradeDate:
+        description: 交易日
+        type: string
+    type: object
   szdz.QueryConvertLogRsp:
   szdz.QueryConvertLogRsp:
     properties:
     properties:
       accountid:
       accountid:
@@ -2493,6 +2574,96 @@ definitions:
         description: 交易日(yyyyMMdd)
         description: 交易日(yyyyMMdd)
         type: string
         type: string
     type: object
     type: object
+  szdz.QuerySZDZTradePositionRsp:
+    properties:
+      accountid:
+        description: 账号Id
+        type: integer
+      agreeunit:
+        description: 合约单位
+        type: number
+      averageprice:
+        description: 持仓均价
+        type: number
+      buyorsell:
+        description: 方向 - 0:买 1:卖
+        type: integer
+      closetotalqty:
+        description: 平仓总数量
+        type: integer
+      curholderamount:
+        description: 当前持仓总金额
+        type: number
+      curpositionqty:
+        description: 当前持仓总数量
+        type: integer
+      currencyid:
+        description: 报价货币ID
+        type: integer
+      curtdposition:
+        description: 期末今日头寸
+        type: integer
+      decimalplace:
+        description: 报价小数位
+        type: integer
+      enableqty:
+        description: 可用量
+        type: integer
+      fretdposition:
+        description: 冻结今日头寸
+        type: integer
+      frozenqty:
+        description: 持仓冻结数量
+        type: integer
+      goodscode:
+        description: 商品代码(内部)
+        type: string
+      goodsid:
+        description: 商品Id
+        type: integer
+      goodsname:
+        description: 商品名称
+        type: string
+      goodunit:
+        description: 报价单位
+        type: string
+      goodunitid:
+        description: 报价单位ID
+        type: integer
+      holderamount:
+        description: 期初持仓总金额
+        type: number
+      marketid:
+        description: 市场ID
+        type: integer
+      openreqqty:
+        description: 开仓申请数量
+        type: integer
+      opentotalqty:
+        description: 开仓总数量
+        type: integer
+      otherfrozenqty:
+        description: 持仓其他冻结数量(交割冻结)
+        type: integer
+      positionqty:
+        description: 期初持仓数量
+        type: integer
+      szdz3freezqty:
+        description: 尚志大宗转换冻结总数量
+        type: integer
+      tnqty:
+        description: T+N冻结总量
+        type: integer
+      tnusedqty:
+        description: T+N使用量
+        type: integer
+      trademode:
+        description: 交易模式
+        type: integer
+      usedmargin:
+        description: 占用保证金
+        type: number
+    type: object
   taaccount.QueryAmountLogRsp:
   taaccount.QueryAmountLogRsp:
     properties:
     properties:
       OPERATETYPENAME:
       OPERATETYPENAME:
@@ -2939,7 +3110,7 @@ paths:
         in: query
         in: query
         name: msgType
         name: msgType
         type: integer
         type: integer
-      - description: 是否未读信息
+      - description: 是否只获取未读信息
         in: query
         in: query
         name: onlyUnRead
         name: onlyUnRead
         type: boolean
         type: boolean
@@ -2972,7 +3143,7 @@ paths:
         "200":
         "200":
           description: OK
           description: OK
           schema:
           schema:
-            $ref: '#/definitions/models.Tablecolumnconfig'
+            $ref: '#/definitions/common.QueryTableDefineRsp'
         "500":
         "500":
           description: Internal Server Error
           description: Internal Server Error
           schema:
           schema:
@@ -3113,6 +3284,28 @@ paths:
       summary: 查询现货合同表信息(指定策略ID、未结束的)
       summary: 查询现货合同表信息(指定策略ID、未结束的)
       tags:
       tags:
       - 风险管理
       - 风险管理
+  /History/QueryTSData:
+    get:
+      parameters:
+      - description: 商品代码
+        in: query
+        name: GoodsCode
+        required: true
+        type: string
+      produces:
+      - application/json
+      responses:
+        "200":
+          description: OK
+          schema:
+            $ref: '#/definitions/quote.QueryTSDataRsp'
+        "500":
+          description: Internal Server Error
+          schema:
+            $ref: '#/definitions/app.Response'
+      summary: 分时图数据查询
+      tags:
+      - 通用服务
   /Order/QueryHisTradeDetail:
   /Order/QueryHisTradeDetail:
     get:
     get:
       parameters:
       parameters:
@@ -3454,6 +3647,30 @@ paths:
       summary: 点选挂牌委托单据查询(摘牌大厅)
       summary: 点选挂牌委托单据查询(摘牌大厅)
       tags:
       tags:
       - 定制【尚志大宗】
       - 定制【尚志大宗】
+  /SZDZ/QuerySZDZTradePosition:
+    get:
+      parameters:
+      - description: 资金账户
+        in: query
+        name: accountID
+        required: true
+        type: integer
+      produces:
+      - application/json
+      responses:
+        "200":
+          description: OK
+          schema:
+            $ref: '#/definitions/szdz.QuerySZDZTradePositionRsp'
+        "500":
+          description: Internal Server Error
+          schema:
+            $ref: '#/definitions/app.Response'
+      security:
+      - ApiKeyAuth: []
+      summary: 持仓汇总查询(尚志大宗)
+      tags:
+      - 定制【尚志大宗】
   /SZDZ/SearchWhite:
   /SZDZ/SearchWhite:
     get:
     get:
       parameters:
       parameters:
@@ -3612,7 +3829,7 @@ paths:
         in: query
         in: query
         name: userID
         name: userID
         required: true
         required: true
-        type: string
+        type: integer
       produces:
       produces:
       - application/json
       - application/json
       responses:
       responses:
@@ -3636,7 +3853,7 @@ paths:
         in: query
         in: query
         name: userID
         name: userID
         required: true
         required: true
-        type: string
+        type: integer
       produces:
       produces:
       - application/json
       - application/json
       responses:
       responses:

+ 2 - 0
global/e/code.go

@@ -12,6 +12,8 @@ const (
 	ERROR_QUERY_QUOTEMENU_FAIL     = 30002
 	ERROR_QUERY_QUOTEMENU_FAIL     = 30002
 	ERROR_QUERY_OPERATIONMENU_FAIL = 30003
 	ERROR_QUERY_OPERATIONMENU_FAIL = 30003
 	ERROR_OPERATION_FAILED         = 30010
 	ERROR_OPERATION_FAILED         = 30010
+	ERROR_GET_GOODS_FAILED         = 30011
+	ERROR_GET_MARKET_FAILED        = 30012
 
 
 	ERROR_UPLOAD_SAVE_IMAGE_FAIL    = 40001
 	ERROR_UPLOAD_SAVE_IMAGE_FAIL    = 40001
 	ERROR_UPLOAD_CHECK_IMAGE_FAIL   = 40002
 	ERROR_UPLOAD_CHECK_IMAGE_FAIL   = 40002

+ 2 - 0
global/e/msg.go

@@ -12,6 +12,8 @@ var MsgFlags = map[int]string{
 	ERROR_QUERY_QUOTEMENU_FAIL:     "查询交易端行情报价牌分类菜单失败",
 	ERROR_QUERY_QUOTEMENU_FAIL:     "查询交易端行情报价牌分类菜单失败",
 	ERROR_QUERY_OPERATIONMENU_FAIL: "查询交易端功能菜单失败",
 	ERROR_QUERY_OPERATIONMENU_FAIL: "查询交易端功能菜单失败",
 	ERROR_OPERATION_FAILED:         "执行失败",
 	ERROR_OPERATION_FAILED:         "执行失败",
+	ERROR_GET_GOODS_FAILED:         "获取商品信息失败",
+	ERROR_GET_MARKET_FAILED:        "获取市场信息失败",
 
 
 	ERROR_UPLOAD_SAVE_IMAGE_FAIL:    "保存图片失败",
 	ERROR_UPLOAD_SAVE_IMAGE_FAIL:    "保存图片失败",
 	ERROR_UPLOAD_CHECK_IMAGE_FAIL:   "检查图片失败",
 	ERROR_UPLOAD_CHECK_IMAGE_FAIL:   "检查图片失败",

+ 5 - 0
main.go

@@ -11,6 +11,7 @@ import (
 	"mtp2_if/config"
 	"mtp2_if/config"
 	"mtp2_if/db"
 	"mtp2_if/db"
 	"mtp2_if/logger"
 	"mtp2_if/logger"
+	"mtp2_if/models"
 	"mtp2_if/rediscli"
 	"mtp2_if/rediscli"
 	"mtp2_if/routers"
 	"mtp2_if/routers"
 
 
@@ -59,6 +60,10 @@ func main() {
 		return
 		return
 	}
 	}
 	defer db.CloseMongoDB()
 	defer db.CloseMongoDB()
+	// test
+	startTime, _ := time.ParseInLocation("2006-01-02 15:04:05", "2000-09-06 09:43:00", time.Local)
+	endTime, _ := time.ParseInLocation("2006-01-02 15:04:05", "2020-01-01 00:00:00", time.Local)
+	models.GetHistoryCycleDatas(models.CycleTypeMinutes1, "DXSY01", startTime, endTime, 1440, false)
 
 
 	// 初始化Redis客户端
 	// 初始化Redis客户端
 	err = rediscli.InitRedisCli()
 	err = rediscli.InitRedisCli()

+ 3 - 3
models/common.go

@@ -443,9 +443,9 @@ func GetClientTableColumns(tableKey string) ([]Tablecolumnconfig, error) {
 }
 }
 
 
 // GetNotices 获取指定账户的通知信息(终端)
 // GetNotices 获取指定账户的通知信息(终端)
-// @param loginID int 登录账号
-// @param msgType int 消息类型 - 1:公告通知 2:系统消息
-// @param onlyUnRead bool 是否只获取未读信息
+// 参数 loginID int 登录账号
+// 参数 msgType int 消息类型 - 1:公告通知 2:系统消息
+// 参数 onlyUnRead bool 是否只获取未读信息
 func GetNotices(loginID, msgType int, onlyUnRead bool) ([]Noticemsg, error) {
 func GetNotices(loginID, msgType int, onlyUnRead bool) ([]Noticemsg, error) {
 	engine := db.GetEngine()
 	engine := db.GetEngine()
 
 

+ 19 - 1
models/goods.go

@@ -1,7 +1,10 @@
 // Package models 10.2商品管理
 // Package models 10.2商品管理
 package models
 package models
 
 
-import "time"
+import (
+	"mtp2_if/db"
+	"time"
+)
 
 
 // Goods 商品表
 // Goods 商品表
 type Goods struct {
 type Goods struct {
@@ -55,3 +58,18 @@ type Goods struct {
 func (Goods) TableName() string {
 func (Goods) TableName() string {
 	return "GOODS"
 	return "GOODS"
 }
 }
+
+// GetGoodsByGoodsCode 通过商品代码获取商品信息
+// 参数 goodsCode string 商品代码
+// 返回值 *Goods 商品信息
+// 返回值 error 错误
+func GetGoodsByGoodsCode(goodsCode string) (*Goods, error) {
+	engine := db.GetEngine()
+
+	var goods Goods
+	if _, err := engine.Where("GOODSCODE = ?", goodsCode).Get(&goods); err != nil {
+		return nil, err
+	}
+
+	return &goods, nil
+}

+ 58 - 1
models/market.go

@@ -1,6 +1,9 @@
 package models
 package models
 
 
-import "time"
+import (
+	"mtp2_if/db"
+	"time"
+)
 
 
 // Market 市场表
 // Market 市场表
 type Market struct {
 type Market struct {
@@ -109,3 +112,57 @@ type Externalexchange struct {
 func (Externalexchange) TableName() string {
 func (Externalexchange) TableName() string {
 	return "EXTERNALEXCHANGE"
 	return "EXTERNALEXCHANGE"
 }
 }
+
+// Marketrun 系统/市场运行参数表
+type Marketrun struct {
+	Marketid           int32     `json:"marketid"  xorm:"'MARKETID'" binding:"required"`           // 市场ID
+	Tradedate          string    `json:"tradedate"  xorm:"'TRADEDATE'" binding:"required"`         // 当前交易日(服务) 资金结算完成即变更,供交易服务使用
+	Tradedate2         string    `json:"tradedate2"  xorm:"'TRADEDATE2'" binding:"required"`       // 当前交易日(行情) 在第一个市场待开市时变更为TradeDate,供行情及终端系统使用
+	Nexttradedate      string    `json:"nexttradedate"  xorm:"'NEXTTRADEDATE'" binding:"required"` // 下一交易日
+	Runstatus          int32     `json:"runstatus"  xorm:"'RUNSTATUS'" binding:"required"`         // 运行状态 - 0:初始化 1:待开市 2:开市 3:休市 4:手工休市 5:闭市 6:确认行权开始 7:确认行权结束 10:日终处理开始 11:日终处理成功 12:日终处理失败 13基础服务结算开始 14基础服务结算成功 23.资金结算开始 24.资金结算成功 25.资金结算失败 26.系统结算成功 27.系统结算失败 28.盘中处理开始 29.盘中处理成功 30.盘中处理失败 31.资金结算开始(内) 32.资金结算成功(内) 33.资金结算失败(内) 40.签到开始 41.签到成功 42.签到部份成功 43.签到失败 44.签退开始 45.签退成功 46.签退部份成功 47.签退失败 48.对账开始 49.对账成功 50.对账失败 51.清算开始 52.清算成功 53.清算失败 54.清算部分成功 55. 系统结算开始 62.今日免清算
+	Reckonflag         int32     `json:"reckonflag"  xorm:"'RECKONFLAG'" binding:"required"`       // 结算标识 - 0: 停止结算 1: 正常(管理端控制此字段,交易服务根据此字段判断是否做结算)
+	Manualflag         int32     `json:"manualflag"  xorm:"'MANUALFLAG'"`                          // 手动开市标志- 0:否 1:是  (市场为手动时,是否触发了手动开市标志)
+	Clearquoteflag     int32     `json:"clearquoteflag"  xorm:"'CLEARQUOTEFLAG'"`                  // 行情清盘标志- 1:未发送 2:已发送 3:已回复
+	Updatetime         time.Time `json:"updatetime"  xorm:"'UPDATETIME'"`                          // 更新时间
+	Pretradedate       string    `json:"pretradedate"  xorm:"'PRETRADEDATE'"`                      // 上一交易日
+	Sectionid          int32     `json:"sectionid"  xorm:"'SECTIONID'"`                            // 时间段号[多时段时用]
+	Afternexttradedate string    `json:"afternexttradedate"  xorm:"'AFTERNEXTTRADEDATE'"`          // 下下交易日
+	Machinedate        string    `json:"machinedate"  xorm:"'MACHINEDATE'"`                        // 机器时间
+	Lastreckondate     string    `json:"lastreckondate"  xorm:"'LASTRECKONDATE'"`                  // 最新交易日(结算成功)
+}
+
+// TableName is MARKETRUN
+func (Marketrun) TableName() string {
+	return "MARKETRUN"
+}
+
+// GetMarket 获取市场信息
+// 参数 marketID int 市场ID
+// 返回值 *Market 市场信息
+// 返回值 error 错误
+func GetMarket(marketID int) (*Market, error) {
+	engine := db.GetEngine()
+
+	var market Market
+	if _, err := engine.Where("MARKETID = ?", marketID).Get(&market); err != nil {
+		return nil, err
+	}
+
+	return &market, nil
+}
+
+// GetMarketByGoodsCode 通过商品代码获取市场信息
+// 参数 goodsCode string 商品代码
+// 返回值 *Market 市场信息
+// 返回值 error 错误
+func GetMarketByGoodsCode(goodsCode string) (*Market, error) {
+	engine := db.GetEngine()
+
+	var market Market
+	if _, err := engine.Join("LEFT", "GOODS", "GOODS.MARKETID = MARKET.MARKETID").
+		Where("GOODS.GOODSCODE = ?", goodsCode).Get(&market); err != nil {
+		return nil, err
+	}
+
+	return &market, nil
+}

+ 65 - 2
models/quote.go

@@ -1,6 +1,12 @@
 package models
 package models
 
 
-import "time"
+import (
+	"errors"
+	"mtp2_if/db"
+	"time"
+
+	"gopkg.in/mgo.v2/bson"
+)
 
 
 // CycleType 周期类型
 // CycleType 周期类型
 type CycleType int
 type CycleType int
@@ -26,6 +32,63 @@ const (
 	CycleTypeTik CycleType = 10
 	CycleTypeTik CycleType = 10
 )
 )
 
 
-func GetHistoryCycleDatas(goodsCode, exchangeCode string, startTime, endTime time.Time, count int)  {
+// CycleData MongoDB中历史数据模型
+type CycleData struct {
+	ID    bson.ObjectId `bson:"_id"`   // id
+	GC    string        `bson:"GC"`    // 商品代码
+	ST    int           `bson:"ST"`    // 时间戳
+	SST   string        `bson:"SST"`   // 时间文本
+	Open  int           `bson:"Open"`  // 开盘价
+	High  int           `bson:"High"`  // 最高价
+	Low   int           `bson:"Low"`   // 最低价
+	Close int           `bson:"Close"` // 收盘价
+	TV    int           `bson:"TV"`    // 总量
+	TT    int           `bson:"TT"`    // 总金额
+	HV    int           `bson:"HV"`    // 持仓量
+	SP    int           `bson:"SP"`    // 结算价,日线周期(包括)以上才有
+}
+
+// GetHistoryCycleDatas 获取历史数据
+// 参数 cycleType CycleType 周期类型
+// 参数 goodsCode string 商品代码
+// 参数 startTime time.Time 开始时间(闭区间)
+// 参数 endTime time.Time 结束时间(闭区间)
+// 参数 count int 条数
+// 返回值 []CycleData 历史数据
+// 返回值 error 错误
+func GetHistoryCycleDatas(cycleType CycleType, goodsCode string, startTime, endTime time.Time, count int, isAscForST bool) ([]CycleData, error) {
+	db := db.GetMongoDB()
+
+	// 获取目标Collection
+	collection := "mincycle"
+	switch cycleType {
+	case CycleTypeSecond:
+		collection = "quotetik"
+	case CycleTypeMinutes1:
+		collection = "mincycle"
+	case CycleTypeMinutes5:
+		collection = "min5cycle"
+	case CycleTypeMinutes30:
+		collection = "min30cycle"
+	default:
+		return nil, errors.New("不支持的周期类型")
+	}
+	c := db.C(collection)
+
+	// 按时间排序
+	sort := "-ST"
+	if isAscForST {
+		sort = "ST"
+	}
+
+	// 查询数据
+	var cycleDatas []CycleData
+	if err := c.Find(bson.M{
+		"GC": goodsCode,
+		"ST": bson.M{"$gte": startTime.Unix(), "$lte": endTime.Unix()},
+	}).Limit(count).Sort(sort).All(&cycleDatas); err != nil {
+		return nil, err
+	}
 
 
+	return cycleDatas, nil
 }
 }

+ 76 - 1
models/szdz.go

@@ -1,6 +1,10 @@
 package models
 package models
 
 
-import "time"
+import (
+	"fmt"
+	"mtp2_if/db"
+	"time"
+)
 
 
 // Szdz3goodspickup 商品提货单表
 // Szdz3goodspickup 商品提货单表
 type Szdz3goodspickup struct {
 type Szdz3goodspickup struct {
@@ -102,3 +106,74 @@ type Szdz3convertconfig struct {
 func (Szdz3convertconfig) TableName() string {
 func (Szdz3convertconfig) TableName() string {
 	return "SZDZ3_CONVERTCONFIG"
 	return "SZDZ3_CONVERTCONFIG"
 }
 }
+
+// SZDZTradePosition 尚志大宗查买持仓数据库模型
+type SZDZTradePosition struct {
+	Accountid       int64   `json:"accountid"  xorm:"'ACCOUNTID'"`             // 账号Id
+	Goodsid         int64   `json:"goodsid"  xorm:"'GOODSID'"`                 // 商品Id
+	Positionqty     int64   `json:"positionqty"  xorm:"'POSITIONQTY'"`         // 期初持仓数量
+	Holderamount    float64 `json:"holderamount"  xorm:"'HOLDERAMOUNT'"`       // 期初持仓总金额
+	Curpositionqty  int64   `json:"curpositionqty"  xorm:"'CURPOSITIONQTY'"`   // 当前持仓总数量
+	Curholderamount float64 `json:"curholderamount"  xorm:"'CURHOLDERAMOUNT'"` // 当前持仓总金额
+	Frozenqty       int64   `json:"frozenqty"  xorm:"'FROZENQTY'"`             // 持仓冻结数量
+	Otherfrozenqty  int64   `json:"otherfrozenqty"  xorm:"'OTHERFROZENQTY'"`   // 持仓其他冻结数量(交割冻结)
+	Openreqqty      int64   `json:"openreqqty"  xorm:"'OPENREQQTY'"`           // 开仓申请数量
+	Opentotalqty    int64   `json:"opentotalqty"  xorm:"'OPENTOTALQTY'"`       // 开仓总数量
+	Closetotalqty   int64   `json:"closetotalqty"  xorm:"'CLOSETOTALQTY'"`     // 平仓总数量
+	Tnqty           int64   `json:"tnqty"  xorm:"'TNQTY'"`                     // T+N冻结总量
+	Tnusedqty       int64   `json:"tnusedqty"  xorm:"'TNUSEDQTY'"`             // T+N使用量
+	Usedmargin      float64 `json:"usedmargin"  xorm:"'USEDMARGIN'"`           // 占用保证金
+	Curtdposition   int64   `json:"curtdposition"  xorm:"'CURTDPOSITION'"`     // 期末今日头寸
+	Fretdposition   int64   `json:"fretdposition"  xorm:"'FRETDPOSITION'"`     // 冻结今日头寸
+	Goodscode       string  `json:"goodscode"  xorm:"'GOODSCODE'"`             // 商品代码(内部)
+	Goodsname       string  `json:"goodsname"  xorm:"'GOODSNAME'"`             // 商品名称
+	Currencyid      int64   `json:"currencyid"  xorm:"'CURRENCYID'"`           // 报价货币ID
+	Goodunitid      int64   `json:"goodunitid"  xorm:"'GOODUNITID'"`           // 报价单位ID
+	Goodunit        string  `json:"goodunit" xorm:"'GOODUNIT'"`                // 报价单位
+	Agreeunit       float64 `json:"agreeunit"  xorm:"'AGREEUNIT'"`             // 合约单位
+	Decimalplace    int64   `json:"decimalplace"  xorm:"'DECIMALPLACE'"`       // 报价小数位
+	Marketid        int32   `json:"marketid"  xorm:"'MARKETID'"`               // 市场ID
+	Trademode       int32   `json:"trademode"  xorm:"'TRADEMODE'"`             // 交易模式
+	SZDZ3FreezQTY   int64   `json:"szdz3freezqty" xorm:"'SZDZ3FREEZQTY'"`      // 尚志大宗转换冻结总数量
+}
+
+// GetSZDZBuyTradePosition 获取尚志大宗买持仓数据
+// 参数 accountID int 资金账户
+// 返回值 []SZDZTradePosition 尚志大宗买持仓数据
+// 返回值 error 错误
+func GetSZDZBuyTradePosition(accountID int) ([]SZDZTradePosition, error) {
+	engine := db.GetEngine()
+
+	// 查询数据, 使用Goods作为主表, TRADEPOSITION无记录时使用SZDZ3_FREEZEPOSITION
+	tradePosition := make([]SZDZTradePosition, 0)
+	s := engine.Table("GOODS").
+		Join("LEFT", "TRADEPOSITION", fmt.Sprintf("TRADEPOSITION.GOODSID = GOODS.GOODSID and TRADEPOSITION.ACCOUNTID = %d", accountID)).
+		Join("LEFT", "SZDZ3_FREEZEPOSITION", fmt.Sprintf("SZDZ3_FREEZEPOSITION.GOODSID = GOODS.GOODSID and SZDZ3_FREEZEPOSITION.ACCOUNTID = %d", accountID)).
+		Join("LEFT", "MARKET", "GOODS.MARKETID = MARKET.MARKETID").
+		Join("LEFT", "ENUMDICITEM", "GOODS.GOODUNITID = ENUMDICITEM.ENUMITEMNAME and ENUMDICITEM.ENUMDICCODE = 'goodsunit'").
+		Select(`NVL(TRADEPOSITION.ACCOUNTID, SZDZ3_FREEZEPOSITION.ACCOUNTID) ACCOUNTID,
+				NVL(TRADEPOSITION.GOODSID,SZDZ3_FREEZEPOSITION.GOODSID) GOODSID,
+				NVL(TRADEPOSITION.BUYPOSITIONQTY, 0) POSITIONQTY,
+				NVL(TRADEPOSITION.BUYHOLDERAMOUNT, 0) HOLDERAMOUNT,
+				NVL(TRADEPOSITION.BUYCURPOSITIONQTY, 0) CURPOSITIONQTY,
+				NVL(TRADEPOSITION.BUYCURHOLDERAMOUNT, 0) CURHOLDERAMOUNT,
+				NVL(TRADEPOSITION.BUYFROZENQTY, 0) FROZENQTY,
+				NVL(TRADEPOSITION.BUYOTHERFROZENQTY, 0) OTHERFROZENQTY,
+				NVL(TRADEPOSITION.BUYOPENREQQTY, 0) OPENREQQTY,
+				NVL(TRADEPOSITION.BUYOPENTOTALQTY, 0) OPENTOTALQTY,
+				NVL(TRADEPOSITION.BUYCLOSETOTALQTY, 0) CLOSETOTALQTY,
+				NVL(TRADEPOSITION.BUYTNQTY, 0) TNQTY,
+				NVL(TRADEPOSITION.BUYTNUSEDQTY, 0) TNUSEDQTY,
+				NVL(TRADEPOSITION.USEDMARGIN, 0) USEDMARGIN,
+				NVL(TRADEPOSITION.BUYCURTDPOSITION, 0) CURTDPOSITION,
+				NVL(TRADEPOSITION.BUYFRETDPOSITION, 0) FRETDPOSITION,
+				NVL(SZDZ3_FREEZEPOSITION.QTY, 0) SZDZ3FreezQTY,
+				GOODS.GOODSCODE, GOODS.GOODSNAME, GOODS.CURRENCYID, GOODS.GOODUNITID, ENUMDICITEM.ENUMDICNAME as GOODUNIT, GOODS.AGREEUNIT, GOODS.DECIMALPLACE, MARKET.MARKETID, MARKET.TRADEMODE`).
+		Where(fmt.Sprintf(`TRADEPOSITION.ACCOUNTID = %d and TRADEPOSITION.BUYCURPOSITIONQTY > 0 or SZDZ3_FREEZEPOSITION.QTY > 0`, accountID))
+	if err := s.Find(&tradePosition); err != nil {
+		// 查询失败
+		return tradePosition, err
+	}
+
+	return tradePosition, nil
+}

+ 2 - 0
routers/router.go

@@ -152,6 +152,8 @@ func InitRouter() *gin.Engine {
 		szdzR.GET("/SearchWhite", szdz.SearchWhite)
 		szdzR.GET("/SearchWhite", szdz.SearchWhite)
 		// 查询交易系统转换设置
 		// 查询交易系统转换设置
 		szdzR.GET("/QueryConvertConfig", szdz.QueryConvertConfig)
 		szdzR.GET("/QueryConvertConfig", szdz.QueryConvertConfig)
+		// 持仓汇总查询(尚志大宗)
+		szdzR.GET("/QuerySZDZTradePosition", szdz.QuerySZDZTradePosition)
 	}
 	}
 
 
 	return r
 	return r