Sfoglia il codice sorgente

增加“期货持仓明细查询”接口

zhou.xiaoning 3 anni fa
parent
commit
c2c78458ea
6 ha cambiato i file con 476 aggiunte e 33 eliminazioni
  1. 16 0
      controllers/ermcp8/qryErmcp8.go
  2. 146 4
      docs/docs.go
  3. 146 4
      docs/swagger.json
  4. 106 6
      docs/swagger.yaml
  5. 61 19
      models/ermcp8.go
  6. 1 0
      routers/router.go

+ 16 - 0
controllers/ermcp8/qryErmcp8.go

@@ -25,3 +25,19 @@ func QueryErmcp2HedgedItem(c *gin.Context) {
 	a.DoBindReq(&m)
 	a.DoGetDataI(&m)
 }
+
+// QueryERMCPJRLinkPos
+// @Summary 期货持仓明细查询
+// @Produce json
+// @Security ApiKeyAuth
+// @Param spotcontractid query int true "套期项目ID"
+// @Success 200 {array} models.Ermcpjrlinkpos
+// @Failure 500 {object} app.Response
+// @Router /Ermcp8/QueryERMCPJRLinkPos [get]
+// @Tags 企业风险管理v8
+func QueryERMCPJRLinkPos(c *gin.Context) {
+	a := app.GinUtils{Gin: app.Gin{C: c}}
+	m := models.Ermcpjrlinkpos{}
+	a.DoBindReq(&m)
+	a.DoGetDataI(&m)
+}

+ 146 - 4
docs/docs.go

@@ -5585,6 +5585,48 @@ var doc = `{
                 }
             }
         },
+        "/Ermcp8/QueryERMCPJRLinkPos": {
+            "get": {
+                "security": [
+                    {
+                        "ApiKeyAuth": []
+                    }
+                ],
+                "produces": [
+                    "application/json"
+                ],
+                "tags": [
+                    "企业风险管理v8"
+                ],
+                "summary": "期货持仓明细查询",
+                "parameters": [
+                    {
+                        "type": "integer",
+                        "description": "套期项目ID",
+                        "name": "spotcontractid",
+                        "in": "query",
+                        "required": true
+                    }
+                ],
+                "responses": {
+                    "200": {
+                        "description": "OK",
+                        "schema": {
+                            "type": "array",
+                            "items": {
+                                "$ref": "#/definitions/models.Ermcpjrlinkpos"
+                            }
+                        }
+                    },
+                    "500": {
+                        "description": "Internal Server Error",
+                        "schema": {
+                            "$ref": "#/definitions/app.Response"
+                        }
+                    }
+                }
+            }
+        },
         "/Ermcp8/QueryErmcp2HedgedItem": {
             "get": {
                 "security": [
@@ -26167,6 +26209,106 @@ var doc = `{
                 }
             }
         },
+        "models.Ermcpjrlinkpos": {
+            "type": "object",
+            "required": [
+                "spotcontractid"
+            ],
+            "properties": {
+                "areauserid": {
+                    "description": "所属企业",
+                    "type": "integer"
+                },
+                "averageprice": {
+                    "description": "持仓均价 (TotalBuyHoldAmount - TotalSellHoldAmount) / NetQty",
+                    "type": "number"
+                },
+                "closepl": {
+                    "description": "总平仓盈亏",
+                    "type": "number"
+                },
+                "executeprice": {
+                    "description": "执行价 - 1:期货单 为 0",
+                    "type": "integer"
+                },
+                "futurehedgeqty": {
+                    "description": "期货套期量",
+                    "type": "number"
+                },
+                "goodsid": {
+                    "description": "期货合约",
+                    "type": "integer"
+                },
+                "middlegoodscode": {
+                    "description": "套保商品代码",
+                    "type": "string"
+                },
+                "middlegoodsname": {
+                    "description": "套保商品名称",
+                    "type": "string"
+                },
+                "netqty": {
+                    "description": "净头寸",
+                    "type": "number"
+                },
+                "optioncode": {
+                    "description": "期权代码",
+                    "type": "string"
+                },
+                "ordertype": {
+                    "description": "单据类型 - 1:期货单 2:看涨期权单 3:看跌期权单",
+                    "type": "integer"
+                },
+                "reckonpl": {
+                    "description": "总盈亏(平仓盈亏 + 结算盈亏 - 手续费)",
+                    "type": "number"
+                },
+                "spotcontractid": {
+                    "description": "现货ID [套期项目ID - 金瑞:合同\\虚拟合同ID",
+                    "type": "string"
+                },
+                "todayfutureclosepl": {
+                    "description": "今日平仓盈亏",
+                    "type": "number"
+                },
+                "totalbuyamount": {
+                    "description": "买金额 [期货]",
+                    "type": "number"
+                },
+                "totalbuyholdamount": {
+                    "description": "买持仓总金额[期货]",
+                    "type": "number"
+                },
+                "totalbuyqty": {
+                    "description": "买数量",
+                    "type": "number"
+                },
+                "totalcharge": {
+                    "description": "手续费",
+                    "type": "number"
+                },
+                "totalpremium": {
+                    "description": "权利金 [期权]",
+                    "type": "number"
+                },
+                "totalsellamount": {
+                    "description": "卖金额 [期货]",
+                    "type": "number"
+                },
+                "totalsellholdamount": {
+                    "description": "卖持仓总金额[期货]",
+                    "type": "number"
+                },
+                "totalsellqty": {
+                    "description": "卖数量",
+                    "type": "number"
+                },
+                "updatetime": {
+                    "description": "更新时间",
+                    "type": "string"
+                }
+            }
+        },
         "models.Externalexchange": {
             "type": "object",
             "required": [
@@ -39251,7 +39393,7 @@ var doc = `{
                     "type": "integer"
                 },
                 "isunopened": {
-                    "description": "是否原封 - 0:否 1:是",
+                    "description": "是否原封 - 1:否 2:是",
                     "type": "integer"
                 },
                 "mpflag": {
@@ -39259,7 +39401,7 @@ var doc = `{
                     "type": "integer"
                 },
                 "openflag": {
-                    "description": "是否非原封 - 0:无 1:皮张大、片张完整,无杂质、虫蛀、霉变、病变、烧皮。 2:片张较大、皮张基本完整,少量断片,少量病变、轻微虫蛀和烧皮。 3:皮张小、片张不完整,断片、碎片较多,有一定量杂质、病斑、虫蛀和烧皮。",
+                    "description": "是否非原封 - 1:无 2:皮张大、片张完整,无杂质、虫蛀、霉变、病变、烧皮。 3:片张较大、皮张基本完整,少量断片,少量病变、轻微虫蛀和烧皮。 4:皮张小、片张不完整,断片、碎片较多,有一定量杂质、病斑、虫蛀和烧皮。",
                     "type": "integer"
                 },
                 "phonenum": {
@@ -39323,7 +39465,7 @@ var doc = `{
                     "type": "integer"
                 },
                 "isunopened": {
-                    "description": "是否原封 - 0:否 1:是",
+                    "description": "是否原封 - 1:否 2:是",
                     "type": "integer"
                 },
                 "mpflag": {
@@ -39331,7 +39473,7 @@ var doc = `{
                     "type": "integer"
                 },
                 "openflag": {
-                    "description": "是否非原封 - 0:无 1:皮张大、片张完整,无杂质、虫蛀、霉变、病变、烧皮。 2:片张较大、皮张基本完整,少量断片,少量病变、轻微虫蛀和烧皮。 3:皮张小、片张不完整,断片、碎片较多,有一定量杂质、病斑、虫蛀和烧皮。",
+                    "description": "是否非原封 - 1:无 2:皮张大、片张完整,无杂质、虫蛀、霉变、病变、烧皮。 3:片张较大、皮张基本完整,少量断片,少量病变、轻微虫蛀和烧皮。 4:皮张小、片张不完整,断片、碎片较多,有一定量杂质、病斑、虫蛀和烧皮。",
                     "type": "integer"
                 },
                 "phonenum": {

+ 146 - 4
docs/swagger.json

@@ -5569,6 +5569,48 @@
                 }
             }
         },
+        "/Ermcp8/QueryERMCPJRLinkPos": {
+            "get": {
+                "security": [
+                    {
+                        "ApiKeyAuth": []
+                    }
+                ],
+                "produces": [
+                    "application/json"
+                ],
+                "tags": [
+                    "企业风险管理v8"
+                ],
+                "summary": "期货持仓明细查询",
+                "parameters": [
+                    {
+                        "type": "integer",
+                        "description": "套期项目ID",
+                        "name": "spotcontractid",
+                        "in": "query",
+                        "required": true
+                    }
+                ],
+                "responses": {
+                    "200": {
+                        "description": "OK",
+                        "schema": {
+                            "type": "array",
+                            "items": {
+                                "$ref": "#/definitions/models.Ermcpjrlinkpos"
+                            }
+                        }
+                    },
+                    "500": {
+                        "description": "Internal Server Error",
+                        "schema": {
+                            "$ref": "#/definitions/app.Response"
+                        }
+                    }
+                }
+            }
+        },
         "/Ermcp8/QueryErmcp2HedgedItem": {
             "get": {
                 "security": [
@@ -26151,6 +26193,106 @@
                 }
             }
         },
+        "models.Ermcpjrlinkpos": {
+            "type": "object",
+            "required": [
+                "spotcontractid"
+            ],
+            "properties": {
+                "areauserid": {
+                    "description": "所属企业",
+                    "type": "integer"
+                },
+                "averageprice": {
+                    "description": "持仓均价 (TotalBuyHoldAmount - TotalSellHoldAmount) / NetQty",
+                    "type": "number"
+                },
+                "closepl": {
+                    "description": "总平仓盈亏",
+                    "type": "number"
+                },
+                "executeprice": {
+                    "description": "执行价 - 1:期货单 为 0",
+                    "type": "integer"
+                },
+                "futurehedgeqty": {
+                    "description": "期货套期量",
+                    "type": "number"
+                },
+                "goodsid": {
+                    "description": "期货合约",
+                    "type": "integer"
+                },
+                "middlegoodscode": {
+                    "description": "套保商品代码",
+                    "type": "string"
+                },
+                "middlegoodsname": {
+                    "description": "套保商品名称",
+                    "type": "string"
+                },
+                "netqty": {
+                    "description": "净头寸",
+                    "type": "number"
+                },
+                "optioncode": {
+                    "description": "期权代码",
+                    "type": "string"
+                },
+                "ordertype": {
+                    "description": "单据类型 - 1:期货单 2:看涨期权单 3:看跌期权单",
+                    "type": "integer"
+                },
+                "reckonpl": {
+                    "description": "总盈亏(平仓盈亏 + 结算盈亏 - 手续费)",
+                    "type": "number"
+                },
+                "spotcontractid": {
+                    "description": "现货ID [套期项目ID - 金瑞:合同\\虚拟合同ID",
+                    "type": "string"
+                },
+                "todayfutureclosepl": {
+                    "description": "今日平仓盈亏",
+                    "type": "number"
+                },
+                "totalbuyamount": {
+                    "description": "买金额 [期货]",
+                    "type": "number"
+                },
+                "totalbuyholdamount": {
+                    "description": "买持仓总金额[期货]",
+                    "type": "number"
+                },
+                "totalbuyqty": {
+                    "description": "买数量",
+                    "type": "number"
+                },
+                "totalcharge": {
+                    "description": "手续费",
+                    "type": "number"
+                },
+                "totalpremium": {
+                    "description": "权利金 [期权]",
+                    "type": "number"
+                },
+                "totalsellamount": {
+                    "description": "卖金额 [期货]",
+                    "type": "number"
+                },
+                "totalsellholdamount": {
+                    "description": "卖持仓总金额[期货]",
+                    "type": "number"
+                },
+                "totalsellqty": {
+                    "description": "卖数量",
+                    "type": "number"
+                },
+                "updatetime": {
+                    "description": "更新时间",
+                    "type": "string"
+                }
+            }
+        },
         "models.Externalexchange": {
             "type": "object",
             "required": [
@@ -39235,7 +39377,7 @@
                     "type": "integer"
                 },
                 "isunopened": {
-                    "description": "是否原封 - 0:否 1:是",
+                    "description": "是否原封 - 1:否 2:是",
                     "type": "integer"
                 },
                 "mpflag": {
@@ -39243,7 +39385,7 @@
                     "type": "integer"
                 },
                 "openflag": {
-                    "description": "是否非原封 - 0:无 1:皮张大、片张完整,无杂质、虫蛀、霉变、病变、烧皮。 2:片张较大、皮张基本完整,少量断片,少量病变、轻微虫蛀和烧皮。 3:皮张小、片张不完整,断片、碎片较多,有一定量杂质、病斑、虫蛀和烧皮。",
+                    "description": "是否非原封 - 1:无 2:皮张大、片张完整,无杂质、虫蛀、霉变、病变、烧皮。 3:片张较大、皮张基本完整,少量断片,少量病变、轻微虫蛀和烧皮。 4:皮张小、片张不完整,断片、碎片较多,有一定量杂质、病斑、虫蛀和烧皮。",
                     "type": "integer"
                 },
                 "phonenum": {
@@ -39307,7 +39449,7 @@
                     "type": "integer"
                 },
                 "isunopened": {
-                    "description": "是否原封 - 0:否 1:是",
+                    "description": "是否原封 - 1:否 2:是",
                     "type": "integer"
                 },
                 "mpflag": {
@@ -39315,7 +39457,7 @@
                     "type": "integer"
                 },
                 "openflag": {
-                    "description": "是否非原封 - 0:无 1:皮张大、片张完整,无杂质、虫蛀、霉变、病变、烧皮。 2:片张较大、皮张基本完整,少量断片,少量病变、轻微虫蛀和烧皮。 3:皮张小、片张不完整,断片、碎片较多,有一定量杂质、病斑、虫蛀和烧皮。",
+                    "description": "是否非原封 - 1:无 2:皮张大、片张完整,无杂质、虫蛀、霉变、病变、烧皮。 3:片张较大、皮张基本完整,少量断片,少量病变、轻微虫蛀和烧皮。 4:皮张小、片张不完整,断片、碎片较多,有一定量杂质、病斑、虫蛀和烧皮。",
                     "type": "integer"
                 },
                 "phonenum": {

+ 106 - 6
docs/swagger.yaml

@@ -8414,6 +8414,80 @@ definitions:
         description: 更新时间
         type: string
     type: object
+  models.Ermcpjrlinkpos:
+    properties:
+      areauserid:
+        description: 所属企业
+        type: integer
+      averageprice:
+        description: 持仓均价 (TotalBuyHoldAmount - TotalSellHoldAmount) / NetQty
+        type: number
+      closepl:
+        description: 总平仓盈亏
+        type: number
+      executeprice:
+        description: 执行价 - 1:期货单 为 0
+        type: integer
+      futurehedgeqty:
+        description: 期货套期量
+        type: number
+      goodsid:
+        description: 期货合约
+        type: integer
+      middlegoodscode:
+        description: 套保商品代码
+        type: string
+      middlegoodsname:
+        description: 套保商品名称
+        type: string
+      netqty:
+        description: 净头寸
+        type: number
+      optioncode:
+        description: 期权代码
+        type: string
+      ordertype:
+        description: 单据类型 - 1:期货单 2:看涨期权单 3:看跌期权单
+        type: integer
+      reckonpl:
+        description: 总盈亏(平仓盈亏 + 结算盈亏 - 手续费)
+        type: number
+      spotcontractid:
+        description: 现货ID [套期项目ID - 金瑞:合同\虚拟合同ID
+        type: string
+      todayfutureclosepl:
+        description: 今日平仓盈亏
+        type: number
+      totalbuyamount:
+        description: 买金额 [期货]
+        type: number
+      totalbuyholdamount:
+        description: 买持仓总金额[期货]
+        type: number
+      totalbuyqty:
+        description: 买数量
+        type: number
+      totalcharge:
+        description: 手续费
+        type: number
+      totalpremium:
+        description: 权利金 [期权]
+        type: number
+      totalsellamount:
+        description: 卖金额 [期货]
+        type: number
+      totalsellholdamount:
+        description: 卖持仓总金额[期货]
+        type: number
+      totalsellqty:
+        description: 卖数量
+        type: number
+      updatetime:
+        description: 更新时间
+        type: string
+    required:
+    - spotcontractid
+    type: object
   models.Externalexchange:
     properties:
       autoid:
@@ -18190,14 +18264,14 @@ definitions:
         description: 是否破洞[原封] - 1:无破洞 2:破洞
         type: integer
       isunopened:
-        description: 是否原封 - 0:否 1:是
+        description: 是否原封 - 1:否 2:是
         type: integer
       mpflag:
         description: 磨皮类型[原封] - 1:无磨皮 2:小磨皮 3:磨皮
         type: integer
       openflag:
-        description: 是否非原封 - 0:无 1:皮张大、片张完整,无杂质、虫蛀、霉变、病变、烧皮。 2:片张较大、皮张基本完整,少量断片,少量病变、轻微虫蛀和烧皮。
-          3:皮张小、片张不完整,断片、碎片较多,有一定量杂质、病斑、虫蛀和烧皮。
+        description: 是否非原封 - 1:无 2:皮张大、片张完整,无杂质、虫蛀、霉变、病变、烧皮。 3:片张较大、皮张基本完整,少量断片,少量病变、轻微虫蛀和烧皮。
+          4:皮张小、片张不完整,断片、碎片较多,有一定量杂质、病斑、虫蛀和烧皮。
         type: integer
       phonenum:
         description: 联系电话
@@ -18244,14 +18318,14 @@ definitions:
         description: 是否破洞[原封] - 1:无破洞 2:破洞
         type: integer
       isunopened:
-        description: 是否原封 - 0:否 1:是
+        description: 是否原封 - 1:否 2:是
         type: integer
       mpflag:
         description: 磨皮类型[原封] - 1:无磨皮 2:小磨皮 3:磨皮
         type: integer
       openflag:
-        description: 是否非原封 - 0:无 1:皮张大、片张完整,无杂质、虫蛀、霉变、病变、烧皮。 2:片张较大、皮张基本完整,少量断片,少量病变、轻微虫蛀和烧皮。
-          3:皮张小、片张不完整,断片、碎片较多,有一定量杂质、病斑、虫蛀和烧皮。
+        description: 是否非原封 - 1:无 2:皮张大、片张完整,无杂质、虫蛀、霉变、病变、烧皮。 3:片张较大、皮张基本完整,少量断片,少量病变、轻微虫蛀和烧皮。
+          4:皮张小、片张不完整,断片、碎片较多,有一定量杂质、病斑、虫蛀和烧皮。
         type: integer
       phonenum:
         description: 联系电话
@@ -23814,6 +23888,32 @@ paths:
       summary: 查询期货子账户
       tags:
       - 企业风险管理v3(app)
+  /Ermcp8/QueryERMCPJRLinkPos:
+    get:
+      parameters:
+      - description: 套期项目ID
+        in: query
+        name: spotcontractid
+        required: true
+        type: integer
+      produces:
+      - application/json
+      responses:
+        "200":
+          description: OK
+          schema:
+            items:
+              $ref: '#/definitions/models.Ermcpjrlinkpos'
+            type: array
+        "500":
+          description: Internal Server Error
+          schema:
+            $ref: '#/definitions/app.Response'
+      security:
+      - ApiKeyAuth: []
+      summary: 期货持仓明细查询
+      tags:
+      - 企业风险管理v8
   /Ermcp8/QueryErmcp2HedgedItem:
     get:
       description: 已完成项目查询 -> 项目状态 = 3:正常完结 or 5:异常完结

+ 61 - 19
models/ermcp8.go

@@ -252,28 +252,70 @@ func (r *Ermcp2himiddlegoods) GetDataEx() (interface{}, error) {
 
 // Ermcpjrlinkpos 项目期货关联头寸
 type Ermcpjrlinkpos struct {
-	SPOTCONTRACTID      string    `json:"spotcontractid"  xorm:"SPOTCONTRACTID"`           // 现货ID [套期项目ID - 金瑞:合同\虚拟合同ID
-	GOODSID             int32     `json:"goodsid"  xorm:"GOODSID"`                         // 期货合约
-	ORDERTYPE           int32     `json:"ordertype"  xorm:"ORDERTYPE"`                     // 单据类型 - 1:期货单 2:看涨期权单 3:看跌期权单
-	EXECUTEPRICE        int64     `json:"executeprice"  xorm:"EXECUTEPRICE"`               // 执行价 - 1:期货单 为 0
-	OPTIONCODE          string    `json:"optioncode"  xorm:"OPTIONCODE"`                   // 期权代码
-	AREAUSERID          int64     `json:"areauserid"  xorm:"AREAUSERID"`                   // 所属企业
-	TOTALBUYAMOUNT      float64   `json:"totalbuyamount"  xorm:"TOTALBUYAMOUNT"`           // 买金额 [期货]
-	TOTALBUYQTY         float64   `json:"totalbuyqty"  xorm:"TOTALBUYQTY"`                 // 买数量
-	TOTALSELLAMOUNT     float64   `json:"totalsellamount"  xorm:"TOTALSELLAMOUNT"`         // 卖金额 [期货]
-	TOTALSELLQTY        float64   `json:"totalsellqty"  xorm:"TOTALSELLQTY"`               // 卖数量
-	NETQTY              float64   `json:"netqty"  xorm:"NETQTY"`                           // 净头寸
-	TOTALCHARGE         float64   `json:"totalcharge"  xorm:"TOTALCHARGE"`                 // 手续费
-	TOTALPREMIUM        float64   `json:"totalpremium"  xorm:"TOTALPREMIUM"`               // 权利金 [期权]
-	CLOSEPL             float64   `json:"closepl"  xorm:"CLOSEPL"`                         // 总平仓盈亏
-	UPDATETIME          time.Time `json:"updatetime"  xorm:"UPDATETIME"`                   // 更新时间
-	TOTALBUYHOLDAMOUNT  float64   `json:"totalbuyholdamount"  xorm:"TOTALBUYHOLDAMOUNT"`   // 买持仓总金额[期货]
-	TOTALSELLHOLDAMOUNT float64   `json:"totalsellholdamount"  xorm:"TOTALSELLHOLDAMOUNT"` // 卖持仓总金额[期货]
-	TODAYFUTURECLOSEPL  float64   `json:"todayfutureclosepl"  xorm:"TODAYFUTURECLOSEPL"`   // 今日平仓盈亏
-	RECKONPL            float64   `json:"reckonpl"  xorm:"RECKONPL"`                       // 总盈亏(平仓盈亏 + 结算盈亏 - 手续费)
+	SPOTCONTRACTID      string    `json:"spotcontractid"  xorm:"SPOTCONTRACTID" form:"spotcontractid" binding:"required"` // 现货ID [套期项目ID - 金瑞:合同\虚拟合同ID
+	GOODSID             int32     `json:"goodsid"  xorm:"GOODSID"`                                                        // 期货合约
+	ORDERTYPE           int32     `json:"ordertype"  xorm:"ORDERTYPE"`                                                    // 单据类型 - 1:期货单 2:看涨期权单 3:看跌期权单
+	EXECUTEPRICE        int64     `json:"executeprice"  xorm:"EXECUTEPRICE"`                                              // 执行价 - 1:期货单 为 0
+	OPTIONCODE          string    `json:"optioncode"  xorm:"OPTIONCODE"`                                                  // 期权代码
+	AREAUSERID          int64     `json:"areauserid"  xorm:"AREAUSERID"`                                                  // 所属企业
+	TOTALBUYAMOUNT      float64   `json:"totalbuyamount"  xorm:"TOTALBUYAMOUNT"`                                          // 买金额 [期货]
+	TOTALBUYQTY         float64   `json:"totalbuyqty"  xorm:"TOTALBUYQTY"`                                                // 买数量
+	TOTALSELLAMOUNT     float64   `json:"totalsellamount"  xorm:"TOTALSELLAMOUNT"`                                        // 卖金额 [期货]
+	TOTALSELLQTY        float64   `json:"totalsellqty"  xorm:"TOTALSELLQTY"`                                              // 卖数量
+	NETQTY              float64   `json:"netqty"  xorm:"NETQTY"`                                                          // 净头寸
+	TOTALCHARGE         float64   `json:"totalcharge"  xorm:"TOTALCHARGE"`                                                // 手续费
+	TOTALPREMIUM        float64   `json:"totalpremium"  xorm:"TOTALPREMIUM"`                                              // 权利金 [期权]
+	CLOSEPL             float64   `json:"closepl"  xorm:"CLOSEPL"`                                                        // 总平仓盈亏
+	UPDATETIME          time.Time `json:"updatetime"  xorm:"UPDATETIME"`                                                  // 更新时间
+	TOTALBUYHOLDAMOUNT  float64   `json:"totalbuyholdamount"  xorm:"TOTALBUYHOLDAMOUNT"`                                  // 买持仓总金额[期货]
+	TOTALSELLHOLDAMOUNT float64   `json:"totalsellholdamount"  xorm:"TOTALSELLHOLDAMOUNT"`                                // 卖持仓总金额[期货]
+	TODAYFUTURECLOSEPL  float64   `json:"todayfutureclosepl"  xorm:"TODAYFUTURECLOSEPL"`                                  // 今日平仓盈亏
+	RECKONPL            float64   `json:"reckonpl"  xorm:"RECKONPL"`                                                      // 总盈亏(平仓盈亏 + 结算盈亏 - 手续费)
+
+	Middlegoodsname string  `json:"middlegoodsname" xorm:"'MIDDLEGOODSNAME'"` // 套保商品名称
+	Middlegoodscode string  `json:"middlegoodscode" xorm:"'MIDDLEGOODSCODE'"` // 套保商品代码
+	FUTUREHEDGEQTY  float64 `json:"futurehedgeqty" xorm:"FUTUREHEDGEQTY"`     // 期货套期量
+
+	AVERAGEPRICE float64 `json:"averageprice" xorm:"AVERAGEPRICE"` // 持仓均价 (TotalBuyHoldAmount - TotalSellHoldAmount) / NetQty
 }
 
 // TableName is ERMCP_JR_LINKPOS
 func (r *Ermcpjrlinkpos) TableName() string {
 	return "ERMCP_JR_LINKPOS"
 }
+
+func (r *Ermcpjrlinkpos) calc() {
+
+}
+
+func (r *Ermcpjrlinkpos) buildSql() string {
+	var sqlId utils.SQLVal = `
+		SELECT 
+			to_char(t.SPOTCONTRACTID) SPOTCONTRACTID,
+			t.ORDERTYPE,
+			t.OPTIONCODE,
+			t.CLOSEPL,
+			t.NETQTY,
+			((t.TotalBuyHoldAmount - t.TotalSellHoldAmount) / NetQty) AVERAGEPRICE
+		FROM ERMCP_JR_LinkPos t 
+		WHERE t.SPOTCONTRACTID = %v
+		ORDER BY t.OPTIONCODE 
+	`
+	sqlId.FormatParam(r.SPOTCONTRACTID)
+
+	return sqlId.String()
+}
+
+// GetDataEx 从数据库中查询数据
+func (r *Ermcpjrlinkpos) GetDataEx() (interface{}, error) {
+	e := db.GetEngine()
+	s := e.SQL(r.buildSql())
+	sData := make([]Ermcpjrlinkpos, 0)
+	if err := s.Find(&sData); err != nil {
+		return nil, err
+	}
+	for i := range sData {
+		sData[i].calc()
+	}
+	return sData, nil
+}

+ 1 - 0
routers/router.go

@@ -488,6 +488,7 @@ func InitRouter() *gin.Engine {
 	ermcp8R.Use(token.Auth())
 	{
 		ermcp8R.GET("/QueryErmcp2HedgedItem", ermcp8.QueryErmcp2HedgedItem)
+		ermcp8R.GET("/QueryERMCPJRLinkPos", ermcp8.QueryERMCPJRLinkPos)
 	}
 
 	// ****************************大连千海金******************************