Explorar o código

增加“内部成交单可关联项目查询”接口

zhou.xiaoning %!s(int64=3) %!d(string=hai) anos
pai
achega
97556efb62
Modificáronse 6 ficheiros con 451 adicións e 24 borrados
  1. 17 0
      controllers/ermcp8/qryErmcp8.go
  2. 106 0
      docs/docs.go
  3. 106 0
      docs/swagger.json
  4. 73 0
      docs/swagger.yaml
  5. 148 24
      models/ermcp8.go
  6. 1 0
      routers/router.go

+ 17 - 0
controllers/ermcp8/qryErmcp8.go

@@ -112,3 +112,20 @@ func QueryInternalUncorrelatedTradeDetail(c *gin.Context) {
 	a.DoBindReq(&m)
 	a.DoGetDataI(&m)
 }
+
+// QueryInternalEnableTradeDetail
+// @Summary 内部成交单可关联项目查询
+// @Produce json
+// @Security ApiKeyAuth
+// @Param areauserid query int true "企业ID"
+// @Param goodsid query int true "期货合约ID"
+// @Success 200 {array} models.InternalEnableTradeDetail
+// @Failure 500 {object} app.Response
+// @Router /Ermcp8/QueryInternalEnableTradeDetail [get]
+// @Tags 企业风险管理v8
+func QueryInternalEnableTradeDetail(c *gin.Context) {
+	a := app.GinUtils{Gin: app.Gin{C: c}}
+	m := models.InternalEnableTradeDetail{}
+	a.DoBindReq(&m)
+	a.DoGetDataI(&m)
+}

+ 106 - 0
docs/docs.go

@@ -5808,6 +5808,55 @@ var doc = `{
                 }
             }
         },
+        "/Ermcp8/QueryInternalEnableTradeDetail": {
+            "get": {
+                "security": [
+                    {
+                        "ApiKeyAuth": []
+                    }
+                ],
+                "produces": [
+                    "application/json"
+                ],
+                "tags": [
+                    "企业风险管理v8"
+                ],
+                "summary": "内部成交单可关联项目查询",
+                "parameters": [
+                    {
+                        "type": "integer",
+                        "description": "企业ID",
+                        "name": "areauserid",
+                        "in": "query",
+                        "required": true
+                    },
+                    {
+                        "type": "integer",
+                        "description": "期货合约ID",
+                        "name": "goodsid",
+                        "in": "query",
+                        "required": true
+                    }
+                ],
+                "responses": {
+                    "200": {
+                        "description": "OK",
+                        "schema": {
+                            "type": "array",
+                            "items": {
+                                "$ref": "#/definitions/models.InternalEnableTradeDetail"
+                            }
+                        }
+                    },
+                    "500": {
+                        "description": "Internal Server Error",
+                        "schema": {
+                            "$ref": "#/definitions/app.Response"
+                        }
+                    }
+                }
+            }
+        },
         "/Ermcp8/QueryInternalUncorrelatedTradeDetail": {
             "get": {
                 "security": [
@@ -28945,6 +28994,63 @@ var doc = `{
                 }
             }
         },
+        "models.InternalEnableTradeDetail": {
+            "type": "object",
+            "required": [
+                "areauserid",
+                "goodsid"
+            ],
+            "properties": {
+                "areauserid": {
+                    "description": "企业ID",
+                    "type": "integer"
+                },
+                "deliverygoodscode": {
+                    "description": "现货品种代码",
+                    "type": "string"
+                },
+                "deliverygoodsid": {
+                    "description": "现货品种ID(SEQ_DELIVERYGOODS)",
+                    "type": "integer"
+                },
+                "deliverygoodsname": {
+                    "description": "现货品种名称",
+                    "type": "string"
+                },
+                "futurehedgeqty": {
+                    "description": "[已关联数量]期货持仓套期量",
+                    "type": "number"
+                },
+                "goodsid": {
+                    "description": "期货合约ID",
+                    "type": "integer"
+                },
+                "hedgeditemnum": {
+                    "description": "项目编号",
+                    "type": "string"
+                },
+                "unexehedgeqty": {
+                    "description": "未执行套期量 = 未执行现货量*折算系数* (1/(1+增值税)) * 套期比例(项目上)",
+                    "type": "number"
+                },
+                "unexespotqty": {
+                    "description": "未执行现货量",
+                    "type": "number"
+                },
+                "wrstandardcode": {
+                    "description": "现货品类代码",
+                    "type": "string"
+                },
+                "wrstandardid": {
+                    "description": "现货品类ID(SEQ_WRSTANDARD)",
+                    "type": "integer"
+                },
+                "wrstandardname": {
+                    "description": "现货品类名称",
+                    "type": "string"
+                }
+            }
+        },
         "models.InternalUncorrelatedTradeDetail": {
             "type": "object",
             "properties": {

+ 106 - 0
docs/swagger.json

@@ -5792,6 +5792,55 @@
                 }
             }
         },
+        "/Ermcp8/QueryInternalEnableTradeDetail": {
+            "get": {
+                "security": [
+                    {
+                        "ApiKeyAuth": []
+                    }
+                ],
+                "produces": [
+                    "application/json"
+                ],
+                "tags": [
+                    "企业风险管理v8"
+                ],
+                "summary": "内部成交单可关联项目查询",
+                "parameters": [
+                    {
+                        "type": "integer",
+                        "description": "企业ID",
+                        "name": "areauserid",
+                        "in": "query",
+                        "required": true
+                    },
+                    {
+                        "type": "integer",
+                        "description": "期货合约ID",
+                        "name": "goodsid",
+                        "in": "query",
+                        "required": true
+                    }
+                ],
+                "responses": {
+                    "200": {
+                        "description": "OK",
+                        "schema": {
+                            "type": "array",
+                            "items": {
+                                "$ref": "#/definitions/models.InternalEnableTradeDetail"
+                            }
+                        }
+                    },
+                    "500": {
+                        "description": "Internal Server Error",
+                        "schema": {
+                            "$ref": "#/definitions/app.Response"
+                        }
+                    }
+                }
+            }
+        },
         "/Ermcp8/QueryInternalUncorrelatedTradeDetail": {
             "get": {
                 "security": [
@@ -28929,6 +28978,63 @@
                 }
             }
         },
+        "models.InternalEnableTradeDetail": {
+            "type": "object",
+            "required": [
+                "areauserid",
+                "goodsid"
+            ],
+            "properties": {
+                "areauserid": {
+                    "description": "企业ID",
+                    "type": "integer"
+                },
+                "deliverygoodscode": {
+                    "description": "现货品种代码",
+                    "type": "string"
+                },
+                "deliverygoodsid": {
+                    "description": "现货品种ID(SEQ_DELIVERYGOODS)",
+                    "type": "integer"
+                },
+                "deliverygoodsname": {
+                    "description": "现货品种名称",
+                    "type": "string"
+                },
+                "futurehedgeqty": {
+                    "description": "[已关联数量]期货持仓套期量",
+                    "type": "number"
+                },
+                "goodsid": {
+                    "description": "期货合约ID",
+                    "type": "integer"
+                },
+                "hedgeditemnum": {
+                    "description": "项目编号",
+                    "type": "string"
+                },
+                "unexehedgeqty": {
+                    "description": "未执行套期量 = 未执行现货量*折算系数* (1/(1+增值税)) * 套期比例(项目上)",
+                    "type": "number"
+                },
+                "unexespotqty": {
+                    "description": "未执行现货量",
+                    "type": "number"
+                },
+                "wrstandardcode": {
+                    "description": "现货品类代码",
+                    "type": "string"
+                },
+                "wrstandardid": {
+                    "description": "现货品类ID(SEQ_WRSTANDARD)",
+                    "type": "integer"
+                },
+                "wrstandardname": {
+                    "description": "现货品类名称",
+                    "type": "string"
+                }
+            }
+        },
         "models.InternalUncorrelatedTradeDetail": {
             "type": "object",
             "properties": {

+ 73 - 0
docs/swagger.yaml

@@ -10325,6 +10325,48 @@ definitions:
     - ordertime
     - trademode
     type: object
+  models.InternalEnableTradeDetail:
+    properties:
+      areauserid:
+        description: 企业ID
+        type: integer
+      deliverygoodscode:
+        description: 现货品种代码
+        type: string
+      deliverygoodsid:
+        description: 现货品种ID(SEQ_DELIVERYGOODS)
+        type: integer
+      deliverygoodsname:
+        description: 现货品种名称
+        type: string
+      futurehedgeqty:
+        description: '[已关联数量]期货持仓套期量'
+        type: number
+      goodsid:
+        description: 期货合约ID
+        type: integer
+      hedgeditemnum:
+        description: 项目编号
+        type: string
+      unexehedgeqty:
+        description: 未执行套期量 = 未执行现货量*折算系数* (1/(1+增值税)) * 套期比例(项目上)
+        type: number
+      unexespotqty:
+        description: 未执行现货量
+        type: number
+      wrstandardcode:
+        description: 现货品类代码
+        type: string
+      wrstandardid:
+        description: 现货品类ID(SEQ_WRSTANDARD)
+        type: integer
+      wrstandardname:
+        description: 现货品类名称
+        type: string
+    required:
+    - areauserid
+    - goodsid
+    type: object
   models.InternalUncorrelatedTradeDetail:
     properties:
       accountid:
@@ -24371,6 +24413,37 @@ paths:
       summary: 查询被套期项目信息
       tags:
       - 企业风险管理v8
+  /Ermcp8/QueryInternalEnableTradeDetail:
+    get:
+      parameters:
+      - description: 企业ID
+        in: query
+        name: areauserid
+        required: true
+        type: integer
+      - description: 期货合约ID
+        in: query
+        name: goodsid
+        required: true
+        type: integer
+      produces:
+      - application/json
+      responses:
+        "200":
+          description: OK
+          schema:
+            items:
+              $ref: '#/definitions/models.InternalEnableTradeDetail'
+            type: array
+        "500":
+          description: Internal Server Error
+          schema:
+            $ref: '#/definitions/app.Response'
+      security:
+      - ApiKeyAuth: []
+      summary: 内部成交单可关联项目查询
+      tags:
+      - 企业风险管理v8
   /Ermcp8/QueryInternalUncorrelatedTradeDetail:
     get:
       parameters:

+ 148 - 24
models/ermcp8.go

@@ -6,6 +6,91 @@ import (
 	"time"
 )
 
+// Ermcp2himiddlegoodsOrc 项目套保品种明细
+type Ermcp2himiddlegoodsOrc struct {
+	HEDGEDITEMID     int64     `json:"hedgeditemid"  xorm:"HEDGEDITEMID"`         // 被套期项目ID(624+Unix秒时间戳(10位)+xxxxxx)
+	MIDDLEGOODSID    int64     `json:"middlegoodsid"  xorm:"MIDDLEGOODSID"`       // 套保品种ID
+	DELIVERYGOODSID  int64     `json:"deliverygoodsid"  xorm:"DELIVERYGOODSID"`   // 现货品种ID
+	WRSTANDARDID     int64     `json:"wrstandardid"  xorm:"WRSTANDARDID"`         // 现货商品ID
+	VATRATE          float64   `json:"vatrate"  xorm:"VATRATE"`                   // 增值税
+	SPOTCONVERTRATIO float64   `json:"spotconvertratio"  xorm:"SPOTCONVERTRATIO"` // 折算系数 [现货]
+	UNEXESPOTQTY     float64   `json:"unexespotqty"  xorm:"UNEXESPOTQTY"`         // 未执行现货量
+	UNEXEHEDGEQTY    float64   `json:"unexehedgeqty"  xorm:"UNEXEHEDGEQTY"`       // 未执行套期量 = 未执行现货量*折算系数* (1/(1+增值税)) * 套期比例(项目上)
+	FUTUREHEDGEQTY   float64   `json:"futurehedgeqty"  xorm:"FUTUREHEDGEQTY"`     // 期货持仓套期量
+	HIEXPSOURE       float64   `json:"hiexpsoure"  xorm:"HIEXPSOURE"`             // 期现敞口量 = 未执行套期量 + 期货持仓套期量
+	TRADEUSERID      int64     `json:"tradeuserid"  xorm:"TRADEUSERID"`           // 交易用户ID
+	AREAUSERID       int64     `json:"areauserid"  xorm:"AREAUSERID"`             // 企业ID
+	CREATETIME       time.Time `json:"createtime"  xorm:"CREATETIME"`             // 创建时间
+	UPDATETIME       time.Time `json:"updatetime"  xorm:"UPDATETIME"`             // 更新时间
+}
+
+// TableName is ERMCP2_HIMIDDLEGOODS
+func (r *Ermcp2himiddlegoodsOrc) TableName() string {
+	return "ERMCP2_HIMIDDLEGOODS"
+}
+
+// Ermcp2hedgeditem 被套期项目表
+type Ermcp2hedgeditemOrc struct {
+	HEDGEDITEMID        int64     `json:"hedgeditemid"  xorm:"HEDGEDITEMID"`               // 被套期项目ID(624+Unix秒时间戳(10位)+xxxxxx)
+	HEDGEDITEMNUM       string    `json:"hedgeditemnum"  xorm:"HEDGEDITEMNUM"`             // 项目编号
+	HEDGEDITEMNAME      string    `json:"hedgeditemname"  xorm:"HEDGEDITEMNAME"`           // 项目名称
+	HEDGEDTYPE          int32     `json:"hedgedtype"  xorm:"HEDGEDTYPE"`                   // 套期类型 - 1:采购计划项目 2:销售计划项目 3:现货贸易项目 4:库存存货项目 5:定价采购合同项目
+	PLANSTARTDATE       time.Time `json:"planstartdate"  xorm:"PLANSTARTDATE"`             // 计划开始日期
+	PLANENDDATE         time.Time `json:"planenddate"  xorm:"PLANENDDATE"`                 // 计划结束日期
+	HEDGERATE           float64   `json:"hedgerate"  xorm:"HEDGERATE"`                     // 套期比率
+	TRADEUSERID         int64     `json:"tradeuserid"  xorm:"TRADEUSERID"`                 // 交易用户ID
+	AREAUSERID          int64     `json:"areauserid"  xorm:"AREAUSERID"`                   // 企业ID
+	HEDGEDITEMSTATUS    int32     `json:"hedgeditemstatus"  xorm:"HEDGEDITEMSTATUS"`       // 项目状态 - 0:未提交 1:待审核 2:执行中 3:正常完结 4:审核拒绝 5:异常完结 6:已撤回
+	APPLYSRC            int32     `json:"applysrc"  xorm:"APPLYSRC"`                       // 申请来源 - 1:管理端 2:终端
+	APPLYID             int64     `json:"applyid"  xorm:"APPLYID"`                         // 申请人
+	REMARK              string    `json:"remark"  xorm:"REMARK"`                           // 备注
+	CREATETIME          time.Time `json:"createtime"  xorm:"CREATETIME"`                   // 申请时间
+	AUDITTRADEDATE      string    `json:"audittradedate"  xorm:"AUDITTRADEDATE"`           // 审核交易日(yyyyMMdd)
+	AUDITID             int64     `json:"auditid"  xorm:"AUDITID"`                         // 审核人
+	AUDITSRC            int32     `json:"auditsrc"  xorm:"AUDITSRC"`                       // 审核来源 - 1:管理端 2:终端
+	AUDITTIME           time.Time `json:"audittime"  xorm:"AUDITTIME"`                     // 审核时间
+	AUDITREMARK         string    `json:"auditremark"  xorm:"AUDITREMARK"`                 // 审核备注
+	DELIVERYGOODSID     int64     `json:"deliverygoodsid"  xorm:"DELIVERYGOODSID"`         // 现货品种ID
+	WRSTANDARDID        int64     `json:"wrstandardid"  xorm:"WRSTANDARDID"`               // 现货商品ID
+	VATRATE             float64   `json:"vatrate"  xorm:"VATRATE"`                         // 增值税
+	HEDGEQTY            float64   `json:"hedgeqty"  xorm:"HEDGEQTY"`                       // 套期现货量
+	HEDGEAMOUNT         float64   `json:"hedgeamount"  xorm:"HEDGEAMOUNT"`                 // 套期市价总额
+	HEDGERESTAMOUNT     float64   `json:"hedgerestamount"  xorm:"HEDGERESTAMOUNT"`         // 套期剩余市价总额【现货贸易】
+	HEDGECONTRACTAMOUNT float64   `json:"hedgecontractamount"  xorm:"HEDGECONTRACTAMOUNT"` // 套期定价总额 【定价采购合同】【现货贸易】
+	ORIAVGPRICE         float64   `json:"oriavgprice"  xorm:"ORIAVGPRICE"`                 // 期初市场均价 = 套期市价总额 / 套期现货量
+	EXEQTY              float64   `json:"exeqty"  xorm:"EXEQTY"`                           // 执行现货量
+	EXEAMOUNT           float64   `json:"exeamount"  xorm:"EXEAMOUNT"`                     // 执行市价总额
+	EXERESTAMOUNT       float64   `json:"exerestamount"  xorm:"EXERESTAMOUNT"`             // 执行剩余市价总额【现货贸易】
+	EXEAVGPRICE         float64   `json:"exeavgprice"  xorm:"EXEAVGPRICE"`                 // 执行市场均价= 执行市价总额 / 执行现货量
+	EXECONTRACTAMOUNT   float64   `json:"execontractamount"  xorm:"EXECONTRACTAMOUNT"`     // 执行定价总额
+	CURPRICE            float64   `json:"curprice"  xorm:"CURPRICE"`                       // 当前市场价
+	UNEXEQTY            float64   `json:"unexeqty"  xorm:"UNEXEQTY"`                       // 未执行现货量 = 套期现货量 - 执行现货量
+	SPOTHEDGEPL         float64   `json:"spothedgepl"  xorm:"SPOTHEDGEPL"`                 // 现货套期损益 =(执行市场均价-期初市场均价)*执行现货量 * 方向(销售计划 为 -1, 其它为1)
+	SPOTPL              float64   `json:"spotpl"  xorm:"SPOTPL"`                           // 现货套期损益 = 现货实际损益 + 现货浮动损益
+	FUTUREHEDGEPL       float64   `json:"futurehedgepl"  xorm:"FUTUREHEDGEPL"`             // 期货实际损益
+	FUTUREPL            float64   `json:"futurepl"  xorm:"FUTUREPL"`                       // 期货套期损益
+	HEDGESUMPL          float64   `json:"hedgesumpl"  xorm:"HEDGESUMPL"`                   // 套期汇总损益 = 期货汇总损益 + 现货汇总损益
+	SPOTTRADEPL         float64   `json:"spottradepl"  xorm:"SPOTTRADEPL"`                 // 现货贸易损益【现货贸易】= 执行合同定价总额 - 套期合同定价总额
+	VATPL               float64   `json:"vatpl"  xorm:"VATPL"`                             // 增值税损益【现货贸易】= 现货贸易损益 * (增值税率 /(1+增值税率))
+	SUMOBSPL            float64   `json:"sumobspl"  xorm:"SUMOBSPL"`                       // 汇总绝对损益【现货贸易】=现货贸易损益+增值税损益+期货套期损益
+	SPOTBOOKAMOUNT      float64   `json:"spotbookamount"  xorm:"SPOTBOOKAMOUNT"`           // 现货账面总额
+	CURSTOCK            float64   `json:"curstock"  xorm:"CURSTOCK"`                       // 期末库存量 = 采购总量 - 销售总量
+	ENDDATE             time.Time `json:"enddate"  xorm:"ENDDATE"`                         // 完成日期
+	ENDTRADEDATE        string    `json:"endtradedate"  xorm:"ENDTRADEDATE"`               // 完成交易日
+	UPDATETIME          time.Time `json:"updatetime"  xorm:"UPDATETIME"`                   // 更新时间
+	ORISPOTHEDGEPL      float64   `json:"orispothedgepl"  xorm:"ORISPOTHEDGEPL"`           // 期初现货实际损益
+	ORIFUTUREHEDGEPL    float64   `json:"orifuturehedgepl"  xorm:"ORIFUTUREHEDGEPL"`       // 期初期货实际损益
+	ORISPOTPL           float64   `json:"orispotpl"  xorm:"ORISPOTPL"`                     // 期初现货套期损益
+	ORIFUTUREPL         float64   `json:"orifuturepl"  xorm:"ORIFUTUREPL"`                 // 期初期货套期损益
+	SPOTFLOATPL         float64   `json:"spotfloatpl"  xorm:"SPOTFLOATPL"`                 // 现货浮动损益 =(当前市场价 - 期初市场价)*未执行现货量 * 方向(销售计划 为 -1, 其它为1)
+	FUTUREFLOATPL       float64   `json:"futurefloatpl"  xorm:"FUTUREFLOATPL"`             // 期货浮动损益
+}
+
+// TableName is ERMCP2_HEDGEDITEM
+func (r *Ermcp2hedgeditemOrc) TableName() string {
+	return "ERMCP2_HEDGEDITEM"
+}
+
 // Ermcp2hedgeditem 被套期项目表
 type Ermcp2hedgeditem struct {
 	Hedgeditemid        string    `json:"hedgeditemid"  xorm:"HEDGEDITEMID"`                                 // 被套期项目ID(624+Unix秒时间戳(10位)+xxxxxx)
@@ -621,7 +706,7 @@ func (r *InternalUncorrelatedTradeDetail) buildSql() string {
 	FROM ERMCP_PA_TRADELINK ept
 	LEFT JOIN goods g ON ept.goodsid = g.goodsid
 	LEFT JOIN taaccount ta ON ta.accountid = ept.accountid
-	LEFT JOIN useraccount ua ON ta.userid = ua.userid
+	LEFT JOIN useraccount ua ON ta.RELATEDUSERID = ua.userid
 	LEFT JOIN enumdicitem e ON e.enumitemname = g.goodunitid AND e.enumdiccode = 'goodsunit'
 	WHERE ept.tradelot > ept.relatedlot
 	and ept.areauserid in
@@ -662,26 +747,65 @@ func (r *InternalUncorrelatedTradeDetail) GetDataEx() (interface{}, error) {
 	return sData, nil
 }
 
-// Ermcp2himiddlegoods 项目套保品种明细
-// Ermcp2himiddlegoods 项目套保品种明细
-// type Ermcp2himiddlegoods struct {
-// 	HEDGEDITEMID    int64    `json:"hedgeditemid"  xorm:"HEDGEDITEMID"`    // 被套期项目ID(624+Unix秒时间戳(10位)+xxxxxx)
-// 	MIDDLEGOODSID    int64    `json:"middlegoodsid"  xorm:"MIDDLEGOODSID"`    // 套保品种ID
-// 	DELIVERYGOODSID    int64    `json:"deliverygoodsid"  xorm:"DELIVERYGOODSID"`    // 现货品种ID
-// 	WRSTANDARDID    int64    `json:"wrstandardid"  xorm:"WRSTANDARDID"`    // 现货商品ID
-// 	VATRATE    float64    `json:"vatrate"  xorm:"VATRATE"`    // 增值税
-// 	SPOTCONVERTRATIO    float64    `json:"spotconvertratio"  xorm:"SPOTCONVERTRATIO"`    // 折算系数 [现货]
-// 	UNEXESPOTQTY    float64    `json:"unexespotqty"  xorm:"UNEXESPOTQTY"`    // 未执行现货量
-// 	UNEXEHEDGEQTY    float64    `json:"unexehedgeqty"  xorm:"UNEXEHEDGEQTY"`    // 未执行套期量 = 未执行现货量*折算系数* (1/(1+增值税)) * 套期比例(项目上)
-// 	FUTUREHEDGEQTY    float64    `json:"futurehedgeqty"  xorm:"FUTUREHEDGEQTY"`    // 期货持仓套期量
-// 	HIEXPSOURE    float64    `json:"hiexpsoure"  xorm:"HIEXPSOURE"`    // 期现敞口量 = 未执行套期量 + 期货持仓套期量
-// 	TRADEUSERID    int64    `json:"tradeuserid"  xorm:"TRADEUSERID"`    // 交易用户ID
-// 	AREAUSERID    int64    `json:"areauserid"  xorm:"AREAUSERID"`    // 企业ID
-// 	CREATETIME    time.Time    `json:"createtime"  xorm:"CREATETIME"`    // 创建时间
-// 	UPDATETIME    time.Time    `json:"updatetime"  xorm:"UPDATETIME"`    // 更新时间
-//   }
-
-//   // TableName is ERMCP2_HIMIDDLEGOODS
-//   func (r *Ermcp2himiddlegoods) TableName() string {
-// 	return "ERMCP2_HIMIDDLEGOODS"
-//   }
+// InternalEnableTradeDetail 内部成交单可关联项目
+type InternalEnableTradeDetail struct {
+	HEDGEDITEMNUM     string  `json:"hedgeditemnum"  xorm:"HEDGEDITEMNUM"`                                // 项目编号
+	Deliverygoodsid   int32   `json:"deliverygoodsid"  xorm:"'DELIVERYGOODSID'"`                          // 现货品种ID(SEQ_DELIVERYGOODS)
+	Deliverygoodscode string  `json:"deliverygoodscode"  xorm:"'DELIVERYGOODSCODE'"`                      // 现货品种代码
+	Deliverygoodsname string  `json:"deliverygoodsname"  xorm:"'DELIVERYGOODSNAME'"`                      // 现货品种名称
+	Wrstandardid      int64   `json:"wrstandardid"  xorm:"'WRSTANDARDID'"`                                // 现货品类ID(SEQ_WRSTANDARD)
+	Wrstandardcode    string  `json:"wrstandardcode"  xorm:"'WRSTANDARDCODE'"`                            // 现货品类代码
+	Wrstandardname    string  `json:"wrstandardname"  xorm:"'WRSTANDARDNAME'"`                            // 现货品类名称
+	UNEXESPOTQTY      float64 `json:"unexespotqty"  xorm:"UNEXESPOTQTY"`                                  // 未执行现货量
+	UNEXEHEDGEQTY     float64 `json:"unexehedgeqty"  xorm:"UNEXEHEDGEQTY"`                                // 未执行套期量 = 未执行现货量*折算系数* (1/(1+增值税)) * 套期比例(项目上)
+	FUTUREHEDGEQTY    float64 `json:"futurehedgeqty"  xorm:"FUTUREHEDGEQTY"`                              // [已关联数量]期货持仓套期量
+	AREAUSERID        int64   `json:"areauserid"  xorm:"AREAUSERID" form:"areauserid" binding:"required"` // 企业ID
+
+	GOODSID int64 `form:"goodsid" binding:"required"` // 期货合约ID
+}
+
+func (r *InternalEnableTradeDetail) calc() {
+
+}
+
+func (r *InternalEnableTradeDetail) buildSql() string {
+	var sqlId utils.SQLVal = `
+	SELECT 
+		hi.HEDGEDITEMNUM,
+		dg.DELIVERYGOODSID,
+		dg.DELIVERYGOODSCODE,
+		dg.DELIVERYGOODSNAME,
+		wr.WRSTANDARDID,
+		wr.WRSTANDARDCODE,
+		wr.WRSTANDARDNAME,
+		t.UNEXESPOTQTY,
+		t.UNEXEHEDGEQTY,
+		t.FUTUREHEDGEQTY
+	FROM ERMCP2_HIMiddleGoods t
+	LEFT JOIN ERMCP2_HedgedItem hi ON hi.HEDGEDITEMID = t.HEDGEDITEMID
+	LEFT JOIN DeliveryGoods dg ON dg.DELIVERYGOODSID = t.DELIVERYGOODSID
+	LEFT JOIN WRStandard wr ON wr.WRStandardID = t.WRStandardID
+	LEFT JOIN ERMS_MiddleGoods ON mg.MIDDLEGOODSID = t.MIDDLEGOODSID
+	LEFT JOIN ERMCP_GGConvertConfig gc ON gc.destgoodsgroupid = mg.goodsgroupid
+	LEFT JOIN Goods g ON g.GOODSGROUPID = gc.SRCGOODSGROUPID
+	WHERE 1 = 1
+	`
+	sqlId.And("t.AREAUSERID", r.AREAUSERID)
+	sqlId.And("g.GOODSID", r.GOODSID)
+
+	return sqlId.String()
+}
+
+// GetDataEx 从数据库中查询数据
+func (r *InternalEnableTradeDetail) GetDataEx() (interface{}, error) {
+	e := db.GetEngine()
+	s := e.SQL(r.buildSql())
+	sData := make([]InternalEnableTradeDetail, 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

@@ -493,6 +493,7 @@ func InitRouter() *gin.Engine {
 		ermcp8R.GET("/QueryERMCP2HedgedItemSpotDetail", ermcp8.QueryERMCP2HedgedItemSpotDetail)
 		ermcp8R.GET("/QueryERMCPPatradeLinkDetail", ermcp8.QueryERMCPPatradeLinkDetail)
 		ermcp8R.GET("/QueryInternalUncorrelatedTradeDetail", ermcp8.QueryInternalUncorrelatedTradeDetail)
+		ermcp8R.GET("/QueryInternalEnableTradeDetail", ermcp8.QueryInternalEnableTradeDetail)
 	}
 
 	// ****************************大连千海金******************************