فهرست منبع

增加“套期计划明细查询”接口

zhou.xiaoning 3 سال پیش
والد
کامیت
7db7e51e63
6فایلهای تغییر یافته به همراه498 افزوده شده و 32 حذف شده
  1. 17 1
      controllers/ermcp8/qryErmcp8.go
  2. 141 3
      docs/docs.go
  3. 141 3
      docs/swagger.json
  4. 100 3
      docs/swagger.yaml
  5. 98 22
      models/ermcp8.go
  6. 1 0
      routers/router.go

+ 17 - 1
controllers/ermcp8/qryErmcp8.go

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

+ 141 - 3
docs/docs.go

@@ -5585,6 +5585,48 @@ var doc = `{
                 }
             }
         },
+        "/Ermcp8/QueryERMCP2HedgedItemspot": {
+            "get": {
+                "security": [
+                    {
+                        "ApiKeyAuth": []
+                    }
+                ],
+                "produces": [
+                    "application/json"
+                ],
+                "tags": [
+                    "企业风险管理v8"
+                ],
+                "summary": "套期计划明细查询",
+                "parameters": [
+                    {
+                        "type": "integer",
+                        "description": "套期项目ID",
+                        "name": "hedgeditemid",
+                        "in": "query",
+                        "required": true
+                    }
+                ],
+                "responses": {
+                    "200": {
+                        "description": "OK",
+                        "schema": {
+                            "type": "array",
+                            "items": {
+                                "$ref": "#/definitions/models.Ermcp2hedgeditemspot"
+                            }
+                        }
+                    },
+                    "500": {
+                        "description": "Internal Server Error",
+                        "schema": {
+                            "$ref": "#/definitions/app.Response"
+                        }
+                    }
+                }
+            }
+        },
         "/Ermcp8/QueryERMCPJRLinkPos": {
             "get": {
                 "security": [
@@ -5603,7 +5645,7 @@ var doc = `{
                     {
                         "type": "integer",
                         "description": "套期项目ID",
-                        "name": "spotcontractid",
+                        "name": "hedgeditemid",
                         "in": "query",
                         "required": true
                     }
@@ -20474,6 +20516,102 @@ var doc = `{
                 }
             }
         },
+        "models.Ermcp2hedgeditemspot": {
+            "type": "object",
+            "required": [
+                "hedgeditemid"
+            ],
+            "properties": {
+                "areauserid": {
+                    "description": "企业ID",
+                    "type": "integer"
+                },
+                "createtime": {
+                    "description": "创建时间",
+                    "type": "string"
+                },
+                "customeruserid": {
+                    "description": "对手方 【3:采购合同 4:销售合同】",
+                    "type": "integer"
+                },
+                "deliverygoodsid": {
+                    "description": "现货品种ID",
+                    "type": "integer"
+                },
+                "enumdicname": {
+                    "description": "单位",
+                    "type": "string"
+                },
+                "hedgeditemid": {
+                    "description": "被套期项目ID",
+                    "type": "string"
+                },
+                "hedgeditemspotid": {
+                    "description": "现货明细ID(625+Unix秒时间戳(10位)+xxxxxx)",
+                    "type": "string"
+                },
+                "hedgedtype": {
+                    "description": "套期类型[计划类型] - 1:采购计划项目 2:销售计划项目 3:现货贸易项目 4:库存存货项目 5:定价采购合同项目",
+                    "type": "integer"
+                },
+                "hedgeplanno": {
+                    "description": "计划编号",
+                    "type": "string"
+                },
+                "oriavgprice": {
+                    "description": "期初市场价[当初市场价]",
+                    "type": "number"
+                },
+                "relatedamount": {
+                    "description": "市价总额 = 关联数量 * 期初市场价",
+                    "type": "number"
+                },
+                "relatedhedgeplanid": {
+                    "description": "关联计划ID 【1:采购计划 2:销售计划】",
+                    "type": "integer"
+                },
+                "relatedqty": {
+                    "description": "关联数量[数量]",
+                    "type": "number"
+                },
+                "relatedspotcontractid": {
+                    "description": "关联合同ID 【3:采购合同 4:销售合同】",
+                    "type": "integer"
+                },
+                "relatedtype": {
+                    "description": "关联类型 - 1:套期关联 2:执行关联",
+                    "type": "integer"
+                },
+                "spotgoodsbrandid": {
+                    "description": "现货品牌ID -  存“DGFactoryItem”表\"DGFactoryItemID\" = 2",
+                    "type": "integer"
+                },
+                "spotpricedamount": {
+                    "description": "定价总额",
+                    "type": "number"
+                },
+                "spotpricedavgprice": {
+                    "description": "现货均价 = 定价总额 / 关联数量",
+                    "type": "number"
+                },
+                "spottype": {
+                    "description": "现货类型 - 1:采购计划 2:销售计划 3:采购合同 4:销售合同 5:库存存货",
+                    "type": "integer"
+                },
+                "tradeuserid": {
+                    "description": "交易用户ID",
+                    "type": "integer"
+                },
+                "wrstandardid": {
+                    "description": "现货商品ID",
+                    "type": "integer"
+                },
+                "wrstandardname": {
+                    "description": "现货商品",
+                    "type": "string"
+                }
+            }
+        },
         "models.Ermcp2himiddlegoods": {
             "type": "object",
             "required": [
@@ -26224,7 +26362,7 @@ var doc = `{
                     "type": "number"
                 },
                 "closepl": {
-                    "description": "总平仓盈亏",
+                    "description": "总平仓盈亏 [期货损益]",
                     "type": "number"
                 },
                 "executeprice": {
@@ -26256,7 +26394,7 @@ var doc = `{
                     "type": "string"
                 },
                 "ordertype": {
-                    "description": "单据类型 - 1:期货单 2:看涨期权单 3:看跌期权单",
+                    "description": "单据类型[套期工具] - 1:期货单 2:看涨期权单 3:看跌期权单",
                     "type": "integer"
                 },
                 "reckonpl": {

+ 141 - 3
docs/swagger.json

@@ -5569,6 +5569,48 @@
                 }
             }
         },
+        "/Ermcp8/QueryERMCP2HedgedItemspot": {
+            "get": {
+                "security": [
+                    {
+                        "ApiKeyAuth": []
+                    }
+                ],
+                "produces": [
+                    "application/json"
+                ],
+                "tags": [
+                    "企业风险管理v8"
+                ],
+                "summary": "套期计划明细查询",
+                "parameters": [
+                    {
+                        "type": "integer",
+                        "description": "套期项目ID",
+                        "name": "hedgeditemid",
+                        "in": "query",
+                        "required": true
+                    }
+                ],
+                "responses": {
+                    "200": {
+                        "description": "OK",
+                        "schema": {
+                            "type": "array",
+                            "items": {
+                                "$ref": "#/definitions/models.Ermcp2hedgeditemspot"
+                            }
+                        }
+                    },
+                    "500": {
+                        "description": "Internal Server Error",
+                        "schema": {
+                            "$ref": "#/definitions/app.Response"
+                        }
+                    }
+                }
+            }
+        },
         "/Ermcp8/QueryERMCPJRLinkPos": {
             "get": {
                 "security": [
@@ -5587,7 +5629,7 @@
                     {
                         "type": "integer",
                         "description": "套期项目ID",
-                        "name": "spotcontractid",
+                        "name": "hedgeditemid",
                         "in": "query",
                         "required": true
                     }
@@ -20458,6 +20500,102 @@
                 }
             }
         },
+        "models.Ermcp2hedgeditemspot": {
+            "type": "object",
+            "required": [
+                "hedgeditemid"
+            ],
+            "properties": {
+                "areauserid": {
+                    "description": "企业ID",
+                    "type": "integer"
+                },
+                "createtime": {
+                    "description": "创建时间",
+                    "type": "string"
+                },
+                "customeruserid": {
+                    "description": "对手方 【3:采购合同 4:销售合同】",
+                    "type": "integer"
+                },
+                "deliverygoodsid": {
+                    "description": "现货品种ID",
+                    "type": "integer"
+                },
+                "enumdicname": {
+                    "description": "单位",
+                    "type": "string"
+                },
+                "hedgeditemid": {
+                    "description": "被套期项目ID",
+                    "type": "string"
+                },
+                "hedgeditemspotid": {
+                    "description": "现货明细ID(625+Unix秒时间戳(10位)+xxxxxx)",
+                    "type": "string"
+                },
+                "hedgedtype": {
+                    "description": "套期类型[计划类型] - 1:采购计划项目 2:销售计划项目 3:现货贸易项目 4:库存存货项目 5:定价采购合同项目",
+                    "type": "integer"
+                },
+                "hedgeplanno": {
+                    "description": "计划编号",
+                    "type": "string"
+                },
+                "oriavgprice": {
+                    "description": "期初市场价[当初市场价]",
+                    "type": "number"
+                },
+                "relatedamount": {
+                    "description": "市价总额 = 关联数量 * 期初市场价",
+                    "type": "number"
+                },
+                "relatedhedgeplanid": {
+                    "description": "关联计划ID 【1:采购计划 2:销售计划】",
+                    "type": "integer"
+                },
+                "relatedqty": {
+                    "description": "关联数量[数量]",
+                    "type": "number"
+                },
+                "relatedspotcontractid": {
+                    "description": "关联合同ID 【3:采购合同 4:销售合同】",
+                    "type": "integer"
+                },
+                "relatedtype": {
+                    "description": "关联类型 - 1:套期关联 2:执行关联",
+                    "type": "integer"
+                },
+                "spotgoodsbrandid": {
+                    "description": "现货品牌ID -  存“DGFactoryItem”表\"DGFactoryItemID\" = 2",
+                    "type": "integer"
+                },
+                "spotpricedamount": {
+                    "description": "定价总额",
+                    "type": "number"
+                },
+                "spotpricedavgprice": {
+                    "description": "现货均价 = 定价总额 / 关联数量",
+                    "type": "number"
+                },
+                "spottype": {
+                    "description": "现货类型 - 1:采购计划 2:销售计划 3:采购合同 4:销售合同 5:库存存货",
+                    "type": "integer"
+                },
+                "tradeuserid": {
+                    "description": "交易用户ID",
+                    "type": "integer"
+                },
+                "wrstandardid": {
+                    "description": "现货商品ID",
+                    "type": "integer"
+                },
+                "wrstandardname": {
+                    "description": "现货商品",
+                    "type": "string"
+                }
+            }
+        },
         "models.Ermcp2himiddlegoods": {
             "type": "object",
             "required": [
@@ -26208,7 +26346,7 @@
                     "type": "number"
                 },
                 "closepl": {
-                    "description": "总平仓盈亏",
+                    "description": "总平仓盈亏 [期货损益]",
                     "type": "number"
                 },
                 "executeprice": {
@@ -26240,7 +26378,7 @@
                     "type": "string"
                 },
                 "ordertype": {
-                    "description": "单据类型 - 1:期货单 2:看涨期权单 3:看跌期权单",
+                    "description": "单据类型[套期工具] - 1:期货单 2:看涨期权单 3:看跌期权单",
                     "type": "integer"
                 },
                 "reckonpl": {

+ 100 - 3
docs/swagger.yaml

@@ -4157,6 +4157,77 @@ definitions:
         description: 商品名称
         type: string
     type: object
+  models.Ermcp2hedgeditemspot:
+    properties:
+      areauserid:
+        description: 企业ID
+        type: integer
+      createtime:
+        description: 创建时间
+        type: string
+      customeruserid:
+        description: 对手方 【3:采购合同 4:销售合同】
+        type: integer
+      deliverygoodsid:
+        description: 现货品种ID
+        type: integer
+      enumdicname:
+        description: 单位
+        type: string
+      hedgeditemid:
+        description: 被套期项目ID
+        type: string
+      hedgeditemspotid:
+        description: 现货明细ID(625+Unix秒时间戳(10位)+xxxxxx)
+        type: string
+      hedgedtype:
+        description: 套期类型[计划类型] - 1:采购计划项目 2:销售计划项目 3:现货贸易项目 4:库存存货项目 5:定价采购合同项目
+        type: integer
+      hedgeplanno:
+        description: 计划编号
+        type: string
+      oriavgprice:
+        description: 期初市场价[当初市场价]
+        type: number
+      relatedamount:
+        description: 市价总额 = 关联数量 * 期初市场价
+        type: number
+      relatedhedgeplanid:
+        description: 关联计划ID 【1:采购计划 2:销售计划】
+        type: integer
+      relatedqty:
+        description: 关联数量[数量]
+        type: number
+      relatedspotcontractid:
+        description: 关联合同ID 【3:采购合同 4:销售合同】
+        type: integer
+      relatedtype:
+        description: 关联类型 - 1:套期关联 2:执行关联
+        type: integer
+      spotgoodsbrandid:
+        description: 现货品牌ID -  存“DGFactoryItem”表"DGFactoryItemID" = 2
+        type: integer
+      spotpricedamount:
+        description: 定价总额
+        type: number
+      spotpricedavgprice:
+        description: 现货均价 = 定价总额 / 关联数量
+        type: number
+      spottype:
+        description: 现货类型 - 1:采购计划 2:销售计划 3:采购合同 4:销售合同 5:库存存货
+        type: integer
+      tradeuserid:
+        description: 交易用户ID
+        type: integer
+      wrstandardid:
+        description: 现货商品ID
+        type: integer
+      wrstandardname:
+        description: 现货商品
+        type: string
+    required:
+    - hedgeditemid
+    type: object
   models.Ermcp2himiddlegoods:
     properties:
       futurehedgeqty:
@@ -8423,7 +8494,7 @@ definitions:
         description: 持仓均价 (TotalBuyHoldAmount - TotalSellHoldAmount) / NetQty
         type: number
       closepl:
-        description: 总平仓盈亏
+        description: 总平仓盈亏 [期货损益]
         type: number
       executeprice:
         description: 执行价 - 1:期货单 为 0
@@ -8447,7 +8518,7 @@ definitions:
         description: 期权代码
         type: string
       ordertype:
-        description: 单据类型 - 1:期货单 2:看涨期权单 3:看跌期权单
+        description: 单据类型[套期工具] - 1:期货单 2:看涨期权单 3:看跌期权单
         type: integer
       reckonpl:
         description: 总盈亏(平仓盈亏 + 结算盈亏 - 手续费)
@@ -23888,12 +23959,38 @@ paths:
       summary: 查询期货子账户
       tags:
       - 企业风险管理v3(app)
+  /Ermcp8/QueryERMCP2HedgedItemspot:
+    get:
+      parameters:
+      - description: 套期项目ID
+        in: query
+        name: hedgeditemid
+        required: true
+        type: integer
+      produces:
+      - application/json
+      responses:
+        "200":
+          description: OK
+          schema:
+            items:
+              $ref: '#/definitions/models.Ermcp2hedgeditemspot'
+            type: array
+        "500":
+          description: Internal Server Error
+          schema:
+            $ref: '#/definitions/app.Response'
+      security:
+      - ApiKeyAuth: []
+      summary: 套期计划明细查询
+      tags:
+      - 企业风险管理v8
   /Ermcp8/QueryERMCPJRLinkPos:
     get:
       parameters:
       - description: 套期项目ID
         in: query
-        name: spotcontractid
+        name: hedgeditemid
         required: true
         type: integer
       produces:

+ 98 - 22
models/ermcp8.go

@@ -252,25 +252,25 @@ func (r *Ermcp2himiddlegoods) GetDataEx() (interface{}, error) {
 
 // Ermcpjrlinkpos 项目期货关联头寸
 type Ermcpjrlinkpos struct {
-	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"`                                                      // 总盈亏(平仓盈亏 + 结算盈亏 - 手续费)
+	SPOTCONTRACTID      string    `json:"spotcontractid"  xorm:"SPOTCONTRACTID" form:"hedgeditemid" 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'"` // 套保商品代码
@@ -296,11 +296,17 @@ func (r *Ermcpjrlinkpos) buildSql() string {
 			t.OPTIONCODE,
 			t.CLOSEPL,
 			t.NETQTY,
-			((t.TotalBuyHoldAmount - t.TotalSellHoldAmount) / NetQty) AVERAGEPRICE
-		FROM ERMCP_JR_LinkPos t 
-		WHERE t.SPOTCONTRACTID = %v
+			((t.TotalBuyHoldAmount - t.TotalSellHoldAmount) / NetQty) AVERAGEPRICE,
+			mg.middlegoodsname,
+			mg.middlegoodscode
+		FROM ERMCP_JR_LinkPos t
+		LEFT JOIN Goods g ON g.goodsid = t.goodsid
+		LEFT JOIN ERMCP_GGConvertConfig gc on gc.srcgoodsgroupid = g.goodsgroupid
+		LEFT JOIN ERMS_MiddleGoods mg ON mg.goodsgroupid = gc.destgoodsgroupid
+		WHERE mg.areauserid = t.areauserid AND t.SPOTCONTRACTID = %v
 		ORDER BY t.OPTIONCODE 
 	`
+	// 只有期货合约ID(GoodsID)的情况下获取套保商品名称,需要以上的关联
 	sqlId.FormatParam(r.SPOTCONTRACTID)
 
 	return sqlId.String()
@@ -319,3 +325,73 @@ func (r *Ermcpjrlinkpos) GetDataEx() (interface{}, error) {
 	}
 	return sData, nil
 }
+
+// Ermcp2hedgeditemspot 项目现货明细
+type Ermcp2hedgeditemspot struct {
+	HEDGEDITEMSPOTID      string    `json:"hedgeditemspotid"  xorm:"HEDGEDITEMSPOTID"`                                // 现货明细ID(625+Unix秒时间戳(10位)+xxxxxx)
+	HEDGEDITEMID          string    `json:"hedgeditemid"  xorm:"HEDGEDITEMID" form:"hedgeditemid" binding:"required"` // 被套期项目ID
+	HEDGEDTYPE            int32     `json:"hedgedtype"  xorm:"HEDGEDTYPE"`                                            // 套期类型[计划类型] - 1:采购计划项目 2:销售计划项目 3:现货贸易项目 4:库存存货项目 5:定价采购合同项目
+	SPOTTYPE              int32     `json:"spottype"  xorm:"SPOTTYPE"`                                                // 现货类型 - 1:采购计划 2:销售计划 3:采购合同 4:销售合同 5:库存存货
+	RELATEDTYPE           int32     `json:"relatedtype"  xorm:"RELATEDTYPE"`                                          // 关联类型 - 1:套期关联 2:执行关联
+	RELATEDHEDGEPLANID    int64     `json:"relatedhedgeplanid"  xorm:"RELATEDHEDGEPLANID"`                            // 关联计划ID 【1:采购计划 2:销售计划】
+	RELATEDSPOTCONTRACTID int64     `json:"relatedspotcontractid"  xorm:"RELATEDSPOTCONTRACTID"`                      // 关联合同ID 【3:采购合同 4:销售合同】
+	CUSTOMERUSERID        int64     `json:"customeruserid"  xorm:"CUSTOMERUSERID"`                                    // 对手方 【3:采购合同 4:销售合同】
+	DELIVERYGOODSID       int64     `json:"deliverygoodsid"  xorm:"DELIVERYGOODSID"`                                  // 现货品种ID
+	WRSTANDARDID          int64     `json:"wrstandardid"  xorm:"WRSTANDARDID"`                                        // 现货商品ID
+	SPOTGOODSBRANDID      int32     `json:"spotgoodsbrandid"  xorm:"SPOTGOODSBRANDID"`                                // 现货品牌ID -  存“DGFactoryItem”表"DGFactoryItemID" = 2
+	RELATEDQTY            float64   `json:"relatedqty"  xorm:"RELATEDQTY"`                                            // 关联数量[数量]
+	ORIAVGPRICE           float64   `json:"oriavgprice"  xorm:"ORIAVGPRICE"`                                          // 期初市场价[当初市场价]
+	RELATEDAMOUNT         float64   `json:"relatedamount"  xorm:"RELATEDAMOUNT"`                                      // 市价总额 = 关联数量 * 期初市场价
+	SPOTPRICEDAMOUNT      float64   `json:"spotpricedamount"  xorm:"SPOTPRICEDAMOUNT"`                                // 定价总额
+	SPOTPRICEDAVGPRICE    float64   `json:"spotpricedavgprice"  xorm:"SPOTPRICEDAVGPRICE"`                            // 现货均价 = 定价总额 / 关联数量
+	CREATETIME            time.Time `json:"createtime"  xorm:"CREATETIME"`                                            // 创建时间
+	TRADEUSERID           int64     `json:"tradeuserid"  xorm:"TRADEUSERID"`                                          // 交易用户ID
+	AREAUSERID            int64     `json:"areauserid"  xorm:"AREAUSERID"`                                            // 企业ID
+
+	Wrstandardname string `json:"wrstandardname" xorm:"'WRSTANDARDNAME'"` // 现货商品
+	EnumdicName    string `json:"enumdicname"  xorm:"'ENUMDICNAME'"`      // 单位
+	Hedgeplanno    string `json:"hedgeplanno"  xorm:"'HEDGEPLANNO'"`      // 计划编号
+}
+
+// TableName is ERMCP2_HEDGEDITEMSPOT
+func (r *Ermcp2hedgeditemspot) TableName() string {
+	return "ERMCP2_HEDGEDITEMSPOT"
+}
+
+func (r *Ermcp2hedgeditemspot) calc() {
+
+}
+
+func (r *Ermcp2hedgeditemspot) buildSql() string {
+	var sqlId utils.SQLVal = `
+		SELECT 
+			to_char(t.hedgeditemspotid) HEDGEDITEMSPOTID,
+			to_char(t.hedgeditemid) HEDGEDITEMID,
+			t.HEDGEDTYPE,
+			wr.WRSTANDARDNAME,
+			e.ENUMDICNAME,
+			t.RELATEDQTY,
+			t.ORIAVGPRICE
+		FROM ERMCP2_HEDGEDITEMSPOT t
+		LEFT JOIN WRStandard wr ON wr.wrstandardid = t.wrstandardid
+		LEFT JOIN enumdicitem e on wr.unitid=e.enumitemname and e.enumdiccode='goodsunit'
+		LEFT JOIN ermcp_hedgeplan s ON s.HedgePlanID = t.RELATEDHEDGEPLANID
+	`
+	sqlId.FormatParam(r.HEDGEDITEMID)
+
+	return sqlId.String()
+}
+
+// GetDataEx 从数据库中查询数据
+func (r *Ermcp2hedgeditemspot) GetDataEx() (interface{}, error) {
+	e := db.GetEngine()
+	s := e.SQL(r.buildSql())
+	sData := make([]Ermcp2hedgeditemspot, 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

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