zhou.xiaoning 3 tahun lalu
induk
melakukan
43ac7394ba
6 mengubah file dengan 2300 tambahan dan 82 penghapusan
  1. 70 0
      controllers/ermcp8/qryErmcp8.go
  2. 707 41
      docs/docs.go
  3. 707 41
      docs/swagger.json
  4. 474 0
      docs/swagger.yaml
  5. 339 0
      models/ermcp8.go
  6. 3 0
      routers/router.go

+ 70 - 0
controllers/ermcp8/qryErmcp8.go

@@ -253,3 +253,73 @@ func QueryErmcp2AreaExposure(c *gin.Context) {
 		appG.Response(http.StatusBadRequest, e.ERROR_QUERY_FAIL, nil)
 	}
 }
+
+// QueryErmcp2StockSpotChangeLog
+// @Summary 敞口明细 - 现货变动明细查询
+// @Produce json
+// @Security ApiKeyAuth
+// @Param userid query int true "用户ID"
+// @Param middlegoodsid query int true "套保品种ID"
+// @Success 200 {array} models.Ermcp2stockspotchangelog
+// @Failure 500 {object} app.Response
+// @Router /Ermcp8/QueryErmcp2StockSpotChangeLog [get]
+// @Tags 企业风险管理v8
+func QueryErmcp2StockSpotChangeLog(c *gin.Context) {
+	a := app.GinUtils{Gin: app.Gin{C: c}}
+	m := models.Ermcp2stockspotchangelog{}
+	a.DoBindReq(&m)
+	a.DoGetDataI(&m)
+}
+
+// QueryErmcp2HedgedItemsDetail
+// @Summary 敞口明细 - 计划变动明细
+// @Produce json
+// @Security ApiKeyAuth
+// @Param userid query int true "用户ID"
+// @Param middlegoodsid query int true "套保品种ID"
+// @Success 200 {array} models.Ermcp2hedgeditemsDetail
+// @Failure 500 {object} app.Response
+// @Router /Ermcp8/QueryErmcp2HedgedItemsDetail [get]
+// @Tags 企业风险管理v8
+func QueryErmcp2HedgedItemsDetail(c *gin.Context) {
+	a := app.GinUtils{Gin: app.Gin{C: c}}
+	m := models.Ermcp2hedgeditemsDetail{}
+	a.DoBindReq(&m)
+	a.DoGetDataI(&m)
+}
+
+// QueryPatradeLinkDetail
+// @Summary 敞口明细 - 期货变动明细
+// @Produce json
+// @Security ApiKeyAuth
+// @Param userid query int true "用户ID"
+// @Param middlegoodsid query int true "套保品种ID"
+// @Success 200 {array} models.Patradelinkdetail
+// @Failure 500 {object} app.Response
+// @Router /Ermcp8/QueryPatradeLinkDetail [get]
+// @Tags 企业风险管理v8
+func QueryPatradeLinkDetail(c *gin.Context) {
+	a := app.GinUtils{Gin: app.Gin{C: c}}
+	m := models.Patradelinkdetail{}
+	a.DoBindReq(&m)
+	a.DoGetDataI(&m)
+}
+
+// QueryUnLinkErmcpHedgePlan
+// @Summary 未关联购销计划
+// @Produce json
+// @Security ApiKeyAuth
+// @Param areauserid query int true "企业ID"
+// @Param contracttype query int false "计划类型 - 1:采购 -1:销售"
+// @Param hedgeplanno query string false "计划编号,模糊查询"
+// @Param wrstandardname query string false "现货商品,模糊查询"
+// @Success 200 {array} models.Unlinkermcphedgeplan
+// @Failure 500 {object} app.Response
+// @Router /Ermcp8/QueryUnLinkErmcpHedgePlan [get]
+// @Tags 企业风险管理v8
+func QueryUnLinkErmcpHedgePlan(c *gin.Context) {
+	a := app.GinUtils{Gin: app.Gin{C: c}}
+	m := models.Unlinkermcphedgeplan{}
+	a.DoBindReq(&m)
+	a.DoGetDataI(&m)
+}

+ 707 - 41
docs/docs.go

@@ -5850,6 +5850,104 @@ var doc = `{
                 }
             }
         },
+        "/Ermcp8/QueryErmcp2HedgedItemsDetail": {
+            "get": {
+                "security": [
+                    {
+                        "ApiKeyAuth": []
+                    }
+                ],
+                "produces": [
+                    "application/json"
+                ],
+                "tags": [
+                    "企业风险管理v8"
+                ],
+                "summary": "敞口明细 - 计划变动明细",
+                "parameters": [
+                    {
+                        "type": "integer",
+                        "description": "用户ID",
+                        "name": "userid",
+                        "in": "query",
+                        "required": true
+                    },
+                    {
+                        "type": "integer",
+                        "description": "套保品种ID",
+                        "name": "middlegoodsid",
+                        "in": "query",
+                        "required": true
+                    }
+                ],
+                "responses": {
+                    "200": {
+                        "description": "OK",
+                        "schema": {
+                            "type": "array",
+                            "items": {
+                                "$ref": "#/definitions/models.Ermcp2hedgeditemsDetail"
+                            }
+                        }
+                    },
+                    "500": {
+                        "description": "Internal Server Error",
+                        "schema": {
+                            "$ref": "#/definitions/app.Response"
+                        }
+                    }
+                }
+            }
+        },
+        "/Ermcp8/QueryErmcp2StockSpotChangeLog": {
+            "get": {
+                "security": [
+                    {
+                        "ApiKeyAuth": []
+                    }
+                ],
+                "produces": [
+                    "application/json"
+                ],
+                "tags": [
+                    "企业风险管理v8"
+                ],
+                "summary": "敞口明细 - 现货变动明细查询",
+                "parameters": [
+                    {
+                        "type": "integer",
+                        "description": "用户ID",
+                        "name": "userid",
+                        "in": "query",
+                        "required": true
+                    },
+                    {
+                        "type": "integer",
+                        "description": "套保品种ID",
+                        "name": "middlegoodsid",
+                        "in": "query",
+                        "required": true
+                    }
+                ],
+                "responses": {
+                    "200": {
+                        "description": "OK",
+                        "schema": {
+                            "type": "array",
+                            "items": {
+                                "$ref": "#/definitions/models.Ermcp2stockspotchangelog"
+                            }
+                        }
+                    },
+                    "500": {
+                        "description": "Internal Server Error",
+                        "schema": {
+                            "$ref": "#/definitions/app.Response"
+                        }
+                    }
+                }
+            }
+        },
         "/Ermcp8/QueryErmcp8EnableHedgeditem": {
             "get": {
                 "security": [
@@ -6153,6 +6251,115 @@ var doc = `{
                 }
             }
         },
+        "/Ermcp8/QueryPatradeLinkDetail": {
+            "get": {
+                "security": [
+                    {
+                        "ApiKeyAuth": []
+                    }
+                ],
+                "produces": [
+                    "application/json"
+                ],
+                "tags": [
+                    "企业风险管理v8"
+                ],
+                "summary": "敞口明细 - 期货变动明细",
+                "parameters": [
+                    {
+                        "type": "integer",
+                        "description": "用户ID",
+                        "name": "userid",
+                        "in": "query",
+                        "required": true
+                    },
+                    {
+                        "type": "integer",
+                        "description": "套保品种ID",
+                        "name": "middlegoodsid",
+                        "in": "query",
+                        "required": true
+                    }
+                ],
+                "responses": {
+                    "200": {
+                        "description": "OK",
+                        "schema": {
+                            "type": "array",
+                            "items": {
+                                "$ref": "#/definitions/models.Patradelinkdetail"
+                            }
+                        }
+                    },
+                    "500": {
+                        "description": "Internal Server Error",
+                        "schema": {
+                            "$ref": "#/definitions/app.Response"
+                        }
+                    }
+                }
+            }
+        },
+        "/Ermcp8/QueryUnLinkErmcpHedgePlan": {
+            "get": {
+                "security": [
+                    {
+                        "ApiKeyAuth": []
+                    }
+                ],
+                "produces": [
+                    "application/json"
+                ],
+                "tags": [
+                    "企业风险管理v8"
+                ],
+                "summary": "未关联购销计划",
+                "parameters": [
+                    {
+                        "type": "integer",
+                        "description": "企业ID",
+                        "name": "areauserid",
+                        "in": "query",
+                        "required": true
+                    },
+                    {
+                        "type": "integer",
+                        "description": "计划类型 - 1:采购 -1:销售",
+                        "name": "contracttype",
+                        "in": "query"
+                    },
+                    {
+                        "type": "string",
+                        "description": "计划编号,模糊查询",
+                        "name": "hedgeplanno",
+                        "in": "query"
+                    },
+                    {
+                        "type": "string",
+                        "description": "现货商品,模糊查询",
+                        "name": "wrstandardname",
+                        "in": "query"
+                    }
+                ],
+                "responses": {
+                    "200": {
+                        "description": "OK",
+                        "schema": {
+                            "type": "array",
+                            "items": {
+                                "$ref": "#/definitions/models.Unlinkermcphedgeplan"
+                            }
+                        }
+                    },
+                    "500": {
+                        "description": "Internal Server Error",
+                        "schema": {
+                            "$ref": "#/definitions/app.Response"
+                        }
+                    }
+                }
+            }
+        },
         "/Ermcp8/QueryUnLinkSpotContract": {
             "get": {
                 "security": [
@@ -21112,12 +21319,13 @@ var doc = `{
                 }
             }
         },
-        "models.Ermcp2hedgeditemspot": {
+        "models.Ermcp2hedgeditemsDetail": {
             "type": "object",
-            "required": [
-                "hedgeditemid"
-            ],
             "properties": {
+                "accountname": {
+                    "description": "套期主体",
+                    "type": "string"
+                },
                 "areauserid": {
                     "description": "企业ID",
                     "type": "integer"
@@ -21167,7 +21375,7 @@ var doc = `{
                     "type": "integer"
                 },
                 "relatedqty": {
-                    "description": "关联数量[数量]",
+                    "description": "[期间变化量]关联数量",
                     "type": "number"
                 },
                 "relatedspotcontractid": {
@@ -21198,6 +21406,10 @@ var doc = `{
                     "description": "交易用户ID",
                     "type": "integer"
                 },
+                "unexeqty": {
+                    "description": "未执行现货量 = 套期现货量 - 执行现货量",
+                    "type": "number"
+                },
                 "wrstandardid": {
                     "description": "现货商品ID",
                     "type": "integer"
@@ -21208,28 +21420,16 @@ var doc = `{
                 }
             }
         },
-        "models.Ermcp2hedgeditemspotDetail": {
+        "models.Ermcp2hedgeditemspot": {
             "type": "object",
             "required": [
                 "hedgeditemid"
             ],
             "properties": {
-                "accountname": {
-                    "description": "对手方",
-                    "type": "string"
-                },
                 "areauserid": {
                     "description": "企业ID",
                     "type": "integer"
                 },
-                "brandname": {
-                    "description": "品牌",
-                    "type": "string"
-                },
-                "contractno": {
-                    "description": "合同编号",
-                    "type": "string"
-                },
                 "createtime": {
                     "description": "创建时间",
                     "type": "string"
@@ -21258,6 +21458,10 @@ var doc = `{
                     "description": "套期类型[计划类型] - 1:采购计划项目 2:销售计划项目 3:现货贸易项目 4:库存存货项目 5:定价采购合同项目",
                     "type": "integer"
                 },
+                "hedgeplanno": {
+                    "description": "计划编号",
+                    "type": "string"
+                },
                 "oriavgprice": {
                     "description": "期初市场价[当初市场价]",
                     "type": "number"
@@ -21287,7 +21491,7 @@ var doc = `{
                     "type": "integer"
                 },
                 "spotpricedamount": {
-                    "description": "定价总额[金额]",
+                    "description": "定价总额",
                     "type": "number"
                 },
                 "spotpricedavgprice": {
@@ -21295,7 +21499,7 @@ var doc = `{
                     "type": "number"
                 },
                 "spottype": {
-                    "description": "现货类型[合同类型] - 1:采购计划 2:销售计划 3:采购合同 4:销售合同 5:库存存货",
+                    "description": "现货类型 - 1:采购计划 2:销售计划 3:采购合同 4:销售合同 5:库存存货",
                     "type": "integer"
                 },
                 "tradeuserid": {
@@ -21312,43 +21516,232 @@ var doc = `{
                 }
             }
         },
-        "models.Ermcp2himiddlegoods": {
+        "models.Ermcp2hedgeditemspotDetail": {
             "type": "object",
             "required": [
-                "hedgeditemid",
-                "middlegoodsid"
+                "hedgeditemid"
             ],
             "properties": {
-                "futurehedgeqty": {
-                    "description": "期货持仓套期量",
-                    "type": "number"
+                "accountname": {
+                    "description": "对手方",
+                    "type": "string"
                 },
-                "hedgeditemid": {
-                    "description": "被套期项目ID(624+Unix秒时间戳(10位)+xxxxxx)",
+                "areauserid": {
+                    "description": "企业ID",
                     "type": "integer"
                 },
-                "hiexpsoure": {
-                    "description": "期现敞口量 = 未执行套期量 + 期货持仓套期量",
-                    "type": "number"
-                },
-                "middlegoodscode": {
-                    "description": "套保商品代码",
+                "brandname": {
+                    "description": "品牌",
                     "type": "string"
                 },
-                "middlegoodsid": {
-                    "description": "套保品种ID",
-                    "type": "integer"
-                },
-                "middlegoodsname": {
-                    "description": "套保商品名称",
+                "contractno": {
+                    "description": "合同编号",
                     "type": "string"
                 },
-                "unexehedgeqty": {
+                "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"
+                },
+                "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": [
+                "hedgeditemid",
+                "middlegoodsid"
+            ],
+            "properties": {
+                "futurehedgeqty": {
+                    "description": "期货持仓套期量",
+                    "type": "number"
+                },
+                "hedgeditemid": {
+                    "description": "被套期项目ID(624+Unix秒时间戳(10位)+xxxxxx)",
+                    "type": "integer"
+                },
+                "hiexpsoure": {
+                    "description": "期现敞口量 = 未执行套期量 + 期货持仓套期量",
+                    "type": "number"
+                },
+                "middlegoodscode": {
+                    "description": "套保商品代码",
+                    "type": "string"
+                },
+                "middlegoodsid": {
+                    "description": "套保品种ID",
+                    "type": "integer"
+                },
+                "middlegoodsname": {
+                    "description": "套保商品名称",
+                    "type": "string"
+                },
+                "unexehedgeqty": {
                     "description": "未执行套期量 = 未执行现货量*折算系数* (1/(1+增值税)) * 套期比例(项目上)",
                     "type": "number"
                 }
             }
         },
+        "models.Ermcp2stockspotchangelog": {
+            "type": "object",
+            "properties": {
+                "accountname": {
+                    "description": "套期主体",
+                    "type": "string"
+                },
+                "aftervalue": {
+                    "description": "现货量",
+                    "type": "number"
+                },
+                "beforevalue": {
+                    "description": "变更前现货量",
+                    "type": "number"
+                },
+                "contracttype": {
+                    "description": "现货合同类型 - 1:采购 -1:销售",
+                    "type": "integer"
+                },
+                "createtime": {
+                    "description": "创建时间",
+                    "type": "string"
+                },
+                "customerusername": {
+                    "description": "对手方",
+                    "type": "string"
+                },
+                "deliverygoodsid": {
+                    "description": "现货品种ID",
+                    "type": "integer"
+                },
+                "exetype": {
+                    "description": "执行类型 - 1:采购合同 2:销售合同 3:生产入库 4:生产出库",
+                    "type": "integer"
+                },
+                "logid": {
+                    "description": "流水ID(604+Unix秒时间戳(10位)+xxxxxx)",
+                    "type": "integer"
+                },
+                "logvalue": {
+                    "description": "现货量变更值",
+                    "type": "number"
+                },
+                "middlegoodschange": {
+                    "description": "套期商品变化量 = LogValue * 折算系数* (1/(1+增值税))",
+                    "type": "number"
+                },
+                "operatelogtype": {
+                    "description": "操作流水类型 -  2:点价数量 21:正常完结(合同) 22:异常终止(合同)  24:采购入库 25:销售出库 26:生产入库 27:生产出库",
+                    "type": "integer"
+                },
+                "relatedid": {
+                    "description": "现货合同ID",
+                    "type": "integer"
+                },
+                "spotgoodsbrandid": {
+                    "description": "现货品牌ID",
+                    "type": "integer"
+                },
+                "tradedate": {
+                    "description": "交易日(yyyyMMdd)",
+                    "type": "string"
+                },
+                "userid": {
+                    "description": "机构ID",
+                    "type": "integer"
+                },
+                "warehouseinfoid": {
+                    "description": "仓库ID",
+                    "type": "integer"
+                },
+                "wrfactortypeid": {
+                    "description": "仓单要素类型ID(212+Unix秒时间戳(10位)+xxxxxx)",
+                    "type": "integer"
+                },
+                "wrstandardid": {
+                    "description": "现货商品ID",
+                    "type": "integer"
+                },
+                "wrstandardname": {
+                    "description": "商品名称 LogValue * 折算系数* (1/(1+增值税))",
+                    "type": "string"
+                }
+            }
+        },
         "models.Ermcp3AreaSpot": {
             "type": "object",
             "properties": {
@@ -30944,6 +31337,143 @@ var doc = `{
                 }
             }
         },
+        "models.Patradelinkdetail": {
+            "type": "object",
+            "properties": {
+                "accountname": {
+                    "description": "套期主体",
+                    "type": "string"
+                },
+                "agreeunit": {
+                    "description": "合约乘数",
+                    "type": "number"
+                },
+                "amount": {
+                    "description": "金额 = RelatedLot * TradePrice * AgreeUnit",
+                    "type": "number"
+                },
+                "areauserid": {
+                    "description": "所属机构",
+                    "type": "integer"
+                },
+                "bizsubjectid": {
+                    "description": "归属业务部门ID - SubjectID",
+                    "type": "integer"
+                },
+                "buyorsell": {
+                    "description": "方向 - 0:买 1:卖",
+                    "type": "integer"
+                },
+                "convertratio": {
+                    "description": "品种系数",
+                    "type": "number"
+                },
+                "convertratiochange": {
+                    "description": "套期商品变化量 = RelatedLot * AgreeUnit * ConvertRatio",
+                    "type": "number"
+                },
+                "createtime": {
+                    "description": "创建时间",
+                    "type": "string"
+                },
+                "creatorid": {
+                    "description": "创建人ID",
+                    "type": "integer"
+                },
+                "creatorsrc": {
+                    "description": "创建人来源 - 1:管理端 2:终端 3:交易",
+                    "type": "integer"
+                },
+                "goodscode": {
+                    "description": "商品代码(内部)",
+                    "type": "string"
+                },
+                "goodsgroupid": {
+                    "description": "对冲品种ID[期货合约商品组ID]",
+                    "type": "integer"
+                },
+                "goodsid": {
+                    "description": "商品ID",
+                    "type": "integer"
+                },
+                "hedgeditemid": {
+                    "description": "现货ID[套期项目ID] [13 - 被套期项目ID] [4,10,11 - 现货合同ID]  [9 - 套保计划ID]",
+                    "type": "integer"
+                },
+                "hedgeflag": {
+                    "description": "投机套保标志 - 0:无 1:投机 2:套保 3:套利 4:套期保值(平安\\合同) 5:单边(平安) 6:移仓(平安) 7:错单处理(平安) 8:跨期套利(平安) 9:套期保值(计划) 10:套利(合同)  11:换月(合同)  12:交割(金瑞) 13:被套期项目",
+                    "type": "integer"
+                },
+                "linkdetailid": {
+                    "description": "期货明细ID(614+Unix秒时间戳(10位)+xxxxxx)",
+                    "type": "string"
+                },
+                "linkstatus": {
+                    "description": "关联状态 - 1:成功 2:失败 3:解绑",
+                    "type": "integer"
+                },
+                "middlegoodsid": {
+                    "description": "套保品种ID",
+                    "type": "integer"
+                },
+                "name": {
+                    "description": "账户名/子账户",
+                    "type": "string"
+                },
+                "optioncode": {
+                    "description": "[期货合约]期权代码 [期权]",
+                    "type": "string"
+                },
+                "ordertype": {
+                    "description": "单据类型[套期工具] - 1:期货单 2:看涨期权单 3:看跌期权单",
+                    "type": "integer"
+                },
+                "relatedlot": {
+                    "description": "[数量]关联手数",
+                    "type": "number"
+                },
+                "relatedmode": {
+                    "description": "关联方式 - 1:自动关联 2:手动关联 3:解绑关联",
+                    "type": "integer"
+                },
+                "relatedqty": {
+                    "description": "关联数量 = RelatedLot * AgreeUnit * ConvertRatio",
+                    "type": "number"
+                },
+                "retcode": {
+                    "description": "返回码",
+                    "type": "integer"
+                },
+                "saleuserid": {
+                    "description": "业务员ID",
+                    "type": "integer"
+                },
+                "tradedate": {
+                    "description": "关联交易日(yyyyMMdd)",
+                    "type": "string"
+                },
+                "tradeid": {
+                    "description": "[成交单号]内部成交单ID",
+                    "type": "string"
+                },
+                "tradelot": {
+                    "description": "成交手数",
+                    "type": "integer"
+                },
+                "tradeprice": {
+                    "description": "[价格]成交价格",
+                    "type": "number"
+                },
+                "tradetime": {
+                    "description": "日期时间",
+                    "type": "string"
+                },
+                "tradetradedate": {
+                    "description": "成交交易日(yyyyMMdd)",
+                    "type": "string"
+                }
+            }
+        },
         "models.QhjAccountOutInApply": {
             "type": "object",
             "properties": {
@@ -36343,6 +36873,142 @@ var doc = `{
                 }
             }
         },
+        "models.Unlinkermcphedgeplan": {
+            "type": "object",
+            "required": [
+                "areauserid"
+            ],
+            "properties": {
+                "accountid": {
+                    "description": "期货账户ID - 作废",
+                    "type": "integer"
+                },
+                "accountname": {
+                    "description": "交易用户",
+                    "type": "string"
+                },
+                "applyid": {
+                    "description": "申请人",
+                    "type": "integer"
+                },
+                "applysrc": {
+                    "description": "申请来源 - 1:管理端 2:终端",
+                    "type": "integer"
+                },
+                "applytime": {
+                    "description": "申请时间",
+                    "type": "string"
+                },
+                "areauserid": {
+                    "description": "[企业ID]机构ID",
+                    "type": "integer"
+                },
+                "auditid": {
+                    "description": "审核人",
+                    "type": "integer"
+                },
+                "auditremark": {
+                    "description": "审核备注",
+                    "type": "string"
+                },
+                "auditsrc": {
+                    "description": "审核来源 - 1:管理端 2:终端",
+                    "type": "integer"
+                },
+                "audittime": {
+                    "description": "审核时间",
+                    "type": "string"
+                },
+                "audittradedate": {
+                    "description": "审核交易日(yyyyMMdd)",
+                    "type": "string"
+                },
+                "biztype": {
+                    "description": "业务类型 - 1:套保",
+                    "type": "integer"
+                },
+                "contracttype": {
+                    "description": "计划类型 - 1:采购 -1:销售",
+                    "type": "integer"
+                },
+                "convertfactor": {
+                    "description": "标仓系数 - 作废",
+                    "type": "number"
+                },
+                "createtime": {
+                    "description": "创建时间",
+                    "type": "string"
+                },
+                "currencyid": {
+                    "description": "结算币种ID - 作废",
+                    "type": "integer"
+                },
+                "deliverygoodsid": {
+                    "description": "现货品种ID",
+                    "type": "integer"
+                },
+                "enumdicname": {
+                    "description": "结算币种",
+                    "type": "string"
+                },
+                "hedgeplanid": {
+                    "description": "套保计划ID(601+Unix秒时间戳(10位)+xxxxxx)",
+                    "type": "integer"
+                },
+                "hedgeplanno": {
+                    "description": "[计划编号]套保计划编号,模糊查询",
+                    "type": "string"
+                },
+                "hedgeplanstatus": {
+                    "description": "[状态]套保计划状态 -  0:未提交 1:待审核 2:执行中 3:正常完结 4:审核拒绝 5:异常完结 6:已撤回",
+                    "type": "integer"
+                },
+                "isrelated": {
+                    "description": "是否已关联计划项目 - 0:否 1:是",
+                    "type": "integer"
+                },
+                "planqty": {
+                    "description": "[计划量]计划数量",
+                    "type": "number"
+                },
+                "plantime": {
+                    "description": "计划时间",
+                    "type": "string"
+                },
+                "producttype": {
+                    "description": "产品类型 - 1:标准仓单 2:等标 3:非标",
+                    "type": "integer"
+                },
+                "remark": {
+                    "description": "备注",
+                    "type": "string"
+                },
+                "spotgoodsdesc": {
+                    "description": "商品型号",
+                    "type": "string"
+                },
+                "tradedate": {
+                    "description": "交易日(yyyyMMdd)",
+                    "type": "string"
+                },
+                "tradeuserid": {
+                    "description": "交易用户ID",
+                    "type": "integer"
+                },
+                "updatetime": {
+                    "description": "更新时间",
+                    "type": "string"
+                },
+                "wrstandardid": {
+                    "description": "现货商品ID",
+                    "type": "integer"
+                },
+                "wrstandardname": {
+                    "description": "现货商品,模糊查询",
+                    "type": "string"
+                }
+            }
+        },
         "models.UserCollectConfig": {
             "type": "object",
             "properties": {

+ 707 - 41
docs/swagger.json

@@ -5834,6 +5834,104 @@
                 }
             }
         },
+        "/Ermcp8/QueryErmcp2HedgedItemsDetail": {
+            "get": {
+                "security": [
+                    {
+                        "ApiKeyAuth": []
+                    }
+                ],
+                "produces": [
+                    "application/json"
+                ],
+                "tags": [
+                    "企业风险管理v8"
+                ],
+                "summary": "敞口明细 - 计划变动明细",
+                "parameters": [
+                    {
+                        "type": "integer",
+                        "description": "用户ID",
+                        "name": "userid",
+                        "in": "query",
+                        "required": true
+                    },
+                    {
+                        "type": "integer",
+                        "description": "套保品种ID",
+                        "name": "middlegoodsid",
+                        "in": "query",
+                        "required": true
+                    }
+                ],
+                "responses": {
+                    "200": {
+                        "description": "OK",
+                        "schema": {
+                            "type": "array",
+                            "items": {
+                                "$ref": "#/definitions/models.Ermcp2hedgeditemsDetail"
+                            }
+                        }
+                    },
+                    "500": {
+                        "description": "Internal Server Error",
+                        "schema": {
+                            "$ref": "#/definitions/app.Response"
+                        }
+                    }
+                }
+            }
+        },
+        "/Ermcp8/QueryErmcp2StockSpotChangeLog": {
+            "get": {
+                "security": [
+                    {
+                        "ApiKeyAuth": []
+                    }
+                ],
+                "produces": [
+                    "application/json"
+                ],
+                "tags": [
+                    "企业风险管理v8"
+                ],
+                "summary": "敞口明细 - 现货变动明细查询",
+                "parameters": [
+                    {
+                        "type": "integer",
+                        "description": "用户ID",
+                        "name": "userid",
+                        "in": "query",
+                        "required": true
+                    },
+                    {
+                        "type": "integer",
+                        "description": "套保品种ID",
+                        "name": "middlegoodsid",
+                        "in": "query",
+                        "required": true
+                    }
+                ],
+                "responses": {
+                    "200": {
+                        "description": "OK",
+                        "schema": {
+                            "type": "array",
+                            "items": {
+                                "$ref": "#/definitions/models.Ermcp2stockspotchangelog"
+                            }
+                        }
+                    },
+                    "500": {
+                        "description": "Internal Server Error",
+                        "schema": {
+                            "$ref": "#/definitions/app.Response"
+                        }
+                    }
+                }
+            }
+        },
         "/Ermcp8/QueryErmcp8EnableHedgeditem": {
             "get": {
                 "security": [
@@ -6137,6 +6235,115 @@
                 }
             }
         },
+        "/Ermcp8/QueryPatradeLinkDetail": {
+            "get": {
+                "security": [
+                    {
+                        "ApiKeyAuth": []
+                    }
+                ],
+                "produces": [
+                    "application/json"
+                ],
+                "tags": [
+                    "企业风险管理v8"
+                ],
+                "summary": "敞口明细 - 期货变动明细",
+                "parameters": [
+                    {
+                        "type": "integer",
+                        "description": "用户ID",
+                        "name": "userid",
+                        "in": "query",
+                        "required": true
+                    },
+                    {
+                        "type": "integer",
+                        "description": "套保品种ID",
+                        "name": "middlegoodsid",
+                        "in": "query",
+                        "required": true
+                    }
+                ],
+                "responses": {
+                    "200": {
+                        "description": "OK",
+                        "schema": {
+                            "type": "array",
+                            "items": {
+                                "$ref": "#/definitions/models.Patradelinkdetail"
+                            }
+                        }
+                    },
+                    "500": {
+                        "description": "Internal Server Error",
+                        "schema": {
+                            "$ref": "#/definitions/app.Response"
+                        }
+                    }
+                }
+            }
+        },
+        "/Ermcp8/QueryUnLinkErmcpHedgePlan": {
+            "get": {
+                "security": [
+                    {
+                        "ApiKeyAuth": []
+                    }
+                ],
+                "produces": [
+                    "application/json"
+                ],
+                "tags": [
+                    "企业风险管理v8"
+                ],
+                "summary": "未关联购销计划",
+                "parameters": [
+                    {
+                        "type": "integer",
+                        "description": "企业ID",
+                        "name": "areauserid",
+                        "in": "query",
+                        "required": true
+                    },
+                    {
+                        "type": "integer",
+                        "description": "计划类型 - 1:采购 -1:销售",
+                        "name": "contracttype",
+                        "in": "query"
+                    },
+                    {
+                        "type": "string",
+                        "description": "计划编号,模糊查询",
+                        "name": "hedgeplanno",
+                        "in": "query"
+                    },
+                    {
+                        "type": "string",
+                        "description": "现货商品,模糊查询",
+                        "name": "wrstandardname",
+                        "in": "query"
+                    }
+                ],
+                "responses": {
+                    "200": {
+                        "description": "OK",
+                        "schema": {
+                            "type": "array",
+                            "items": {
+                                "$ref": "#/definitions/models.Unlinkermcphedgeplan"
+                            }
+                        }
+                    },
+                    "500": {
+                        "description": "Internal Server Error",
+                        "schema": {
+                            "$ref": "#/definitions/app.Response"
+                        }
+                    }
+                }
+            }
+        },
         "/Ermcp8/QueryUnLinkSpotContract": {
             "get": {
                 "security": [
@@ -21096,12 +21303,13 @@
                 }
             }
         },
-        "models.Ermcp2hedgeditemspot": {
+        "models.Ermcp2hedgeditemsDetail": {
             "type": "object",
-            "required": [
-                "hedgeditemid"
-            ],
             "properties": {
+                "accountname": {
+                    "description": "套期主体",
+                    "type": "string"
+                },
                 "areauserid": {
                     "description": "企业ID",
                     "type": "integer"
@@ -21151,7 +21359,7 @@
                     "type": "integer"
                 },
                 "relatedqty": {
-                    "description": "关联数量[数量]",
+                    "description": "[期间变化量]关联数量",
                     "type": "number"
                 },
                 "relatedspotcontractid": {
@@ -21182,6 +21390,10 @@
                     "description": "交易用户ID",
                     "type": "integer"
                 },
+                "unexeqty": {
+                    "description": "未执行现货量 = 套期现货量 - 执行现货量",
+                    "type": "number"
+                },
                 "wrstandardid": {
                     "description": "现货商品ID",
                     "type": "integer"
@@ -21192,28 +21404,16 @@
                 }
             }
         },
-        "models.Ermcp2hedgeditemspotDetail": {
+        "models.Ermcp2hedgeditemspot": {
             "type": "object",
             "required": [
                 "hedgeditemid"
             ],
             "properties": {
-                "accountname": {
-                    "description": "对手方",
-                    "type": "string"
-                },
                 "areauserid": {
                     "description": "企业ID",
                     "type": "integer"
                 },
-                "brandname": {
-                    "description": "品牌",
-                    "type": "string"
-                },
-                "contractno": {
-                    "description": "合同编号",
-                    "type": "string"
-                },
                 "createtime": {
                     "description": "创建时间",
                     "type": "string"
@@ -21242,6 +21442,10 @@
                     "description": "套期类型[计划类型] - 1:采购计划项目 2:销售计划项目 3:现货贸易项目 4:库存存货项目 5:定价采购合同项目",
                     "type": "integer"
                 },
+                "hedgeplanno": {
+                    "description": "计划编号",
+                    "type": "string"
+                },
                 "oriavgprice": {
                     "description": "期初市场价[当初市场价]",
                     "type": "number"
@@ -21271,7 +21475,7 @@
                     "type": "integer"
                 },
                 "spotpricedamount": {
-                    "description": "定价总额[金额]",
+                    "description": "定价总额",
                     "type": "number"
                 },
                 "spotpricedavgprice": {
@@ -21279,7 +21483,7 @@
                     "type": "number"
                 },
                 "spottype": {
-                    "description": "现货类型[合同类型] - 1:采购计划 2:销售计划 3:采购合同 4:销售合同 5:库存存货",
+                    "description": "现货类型 - 1:采购计划 2:销售计划 3:采购合同 4:销售合同 5:库存存货",
                     "type": "integer"
                 },
                 "tradeuserid": {
@@ -21296,43 +21500,232 @@
                 }
             }
         },
-        "models.Ermcp2himiddlegoods": {
+        "models.Ermcp2hedgeditemspotDetail": {
             "type": "object",
             "required": [
-                "hedgeditemid",
-                "middlegoodsid"
+                "hedgeditemid"
             ],
             "properties": {
-                "futurehedgeqty": {
-                    "description": "期货持仓套期量",
-                    "type": "number"
+                "accountname": {
+                    "description": "对手方",
+                    "type": "string"
                 },
-                "hedgeditemid": {
-                    "description": "被套期项目ID(624+Unix秒时间戳(10位)+xxxxxx)",
+                "areauserid": {
+                    "description": "企业ID",
                     "type": "integer"
                 },
-                "hiexpsoure": {
-                    "description": "期现敞口量 = 未执行套期量 + 期货持仓套期量",
-                    "type": "number"
-                },
-                "middlegoodscode": {
-                    "description": "套保商品代码",
+                "brandname": {
+                    "description": "品牌",
                     "type": "string"
                 },
-                "middlegoodsid": {
-                    "description": "套保品种ID",
-                    "type": "integer"
-                },
-                "middlegoodsname": {
-                    "description": "套保商品名称",
+                "contractno": {
+                    "description": "合同编号",
                     "type": "string"
                 },
-                "unexehedgeqty": {
+                "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"
+                },
+                "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": [
+                "hedgeditemid",
+                "middlegoodsid"
+            ],
+            "properties": {
+                "futurehedgeqty": {
+                    "description": "期货持仓套期量",
+                    "type": "number"
+                },
+                "hedgeditemid": {
+                    "description": "被套期项目ID(624+Unix秒时间戳(10位)+xxxxxx)",
+                    "type": "integer"
+                },
+                "hiexpsoure": {
+                    "description": "期现敞口量 = 未执行套期量 + 期货持仓套期量",
+                    "type": "number"
+                },
+                "middlegoodscode": {
+                    "description": "套保商品代码",
+                    "type": "string"
+                },
+                "middlegoodsid": {
+                    "description": "套保品种ID",
+                    "type": "integer"
+                },
+                "middlegoodsname": {
+                    "description": "套保商品名称",
+                    "type": "string"
+                },
+                "unexehedgeqty": {
                     "description": "未执行套期量 = 未执行现货量*折算系数* (1/(1+增值税)) * 套期比例(项目上)",
                     "type": "number"
                 }
             }
         },
+        "models.Ermcp2stockspotchangelog": {
+            "type": "object",
+            "properties": {
+                "accountname": {
+                    "description": "套期主体",
+                    "type": "string"
+                },
+                "aftervalue": {
+                    "description": "现货量",
+                    "type": "number"
+                },
+                "beforevalue": {
+                    "description": "变更前现货量",
+                    "type": "number"
+                },
+                "contracttype": {
+                    "description": "现货合同类型 - 1:采购 -1:销售",
+                    "type": "integer"
+                },
+                "createtime": {
+                    "description": "创建时间",
+                    "type": "string"
+                },
+                "customerusername": {
+                    "description": "对手方",
+                    "type": "string"
+                },
+                "deliverygoodsid": {
+                    "description": "现货品种ID",
+                    "type": "integer"
+                },
+                "exetype": {
+                    "description": "执行类型 - 1:采购合同 2:销售合同 3:生产入库 4:生产出库",
+                    "type": "integer"
+                },
+                "logid": {
+                    "description": "流水ID(604+Unix秒时间戳(10位)+xxxxxx)",
+                    "type": "integer"
+                },
+                "logvalue": {
+                    "description": "现货量变更值",
+                    "type": "number"
+                },
+                "middlegoodschange": {
+                    "description": "套期商品变化量 = LogValue * 折算系数* (1/(1+增值税))",
+                    "type": "number"
+                },
+                "operatelogtype": {
+                    "description": "操作流水类型 -  2:点价数量 21:正常完结(合同) 22:异常终止(合同)  24:采购入库 25:销售出库 26:生产入库 27:生产出库",
+                    "type": "integer"
+                },
+                "relatedid": {
+                    "description": "现货合同ID",
+                    "type": "integer"
+                },
+                "spotgoodsbrandid": {
+                    "description": "现货品牌ID",
+                    "type": "integer"
+                },
+                "tradedate": {
+                    "description": "交易日(yyyyMMdd)",
+                    "type": "string"
+                },
+                "userid": {
+                    "description": "机构ID",
+                    "type": "integer"
+                },
+                "warehouseinfoid": {
+                    "description": "仓库ID",
+                    "type": "integer"
+                },
+                "wrfactortypeid": {
+                    "description": "仓单要素类型ID(212+Unix秒时间戳(10位)+xxxxxx)",
+                    "type": "integer"
+                },
+                "wrstandardid": {
+                    "description": "现货商品ID",
+                    "type": "integer"
+                },
+                "wrstandardname": {
+                    "description": "商品名称 LogValue * 折算系数* (1/(1+增值税))",
+                    "type": "string"
+                }
+            }
+        },
         "models.Ermcp3AreaSpot": {
             "type": "object",
             "properties": {
@@ -30928,6 +31321,143 @@
                 }
             }
         },
+        "models.Patradelinkdetail": {
+            "type": "object",
+            "properties": {
+                "accountname": {
+                    "description": "套期主体",
+                    "type": "string"
+                },
+                "agreeunit": {
+                    "description": "合约乘数",
+                    "type": "number"
+                },
+                "amount": {
+                    "description": "金额 = RelatedLot * TradePrice * AgreeUnit",
+                    "type": "number"
+                },
+                "areauserid": {
+                    "description": "所属机构",
+                    "type": "integer"
+                },
+                "bizsubjectid": {
+                    "description": "归属业务部门ID - SubjectID",
+                    "type": "integer"
+                },
+                "buyorsell": {
+                    "description": "方向 - 0:买 1:卖",
+                    "type": "integer"
+                },
+                "convertratio": {
+                    "description": "品种系数",
+                    "type": "number"
+                },
+                "convertratiochange": {
+                    "description": "套期商品变化量 = RelatedLot * AgreeUnit * ConvertRatio",
+                    "type": "number"
+                },
+                "createtime": {
+                    "description": "创建时间",
+                    "type": "string"
+                },
+                "creatorid": {
+                    "description": "创建人ID",
+                    "type": "integer"
+                },
+                "creatorsrc": {
+                    "description": "创建人来源 - 1:管理端 2:终端 3:交易",
+                    "type": "integer"
+                },
+                "goodscode": {
+                    "description": "商品代码(内部)",
+                    "type": "string"
+                },
+                "goodsgroupid": {
+                    "description": "对冲品种ID[期货合约商品组ID]",
+                    "type": "integer"
+                },
+                "goodsid": {
+                    "description": "商品ID",
+                    "type": "integer"
+                },
+                "hedgeditemid": {
+                    "description": "现货ID[套期项目ID] [13 - 被套期项目ID] [4,10,11 - 现货合同ID]  [9 - 套保计划ID]",
+                    "type": "integer"
+                },
+                "hedgeflag": {
+                    "description": "投机套保标志 - 0:无 1:投机 2:套保 3:套利 4:套期保值(平安\\合同) 5:单边(平安) 6:移仓(平安) 7:错单处理(平安) 8:跨期套利(平安) 9:套期保值(计划) 10:套利(合同)  11:换月(合同)  12:交割(金瑞) 13:被套期项目",
+                    "type": "integer"
+                },
+                "linkdetailid": {
+                    "description": "期货明细ID(614+Unix秒时间戳(10位)+xxxxxx)",
+                    "type": "string"
+                },
+                "linkstatus": {
+                    "description": "关联状态 - 1:成功 2:失败 3:解绑",
+                    "type": "integer"
+                },
+                "middlegoodsid": {
+                    "description": "套保品种ID",
+                    "type": "integer"
+                },
+                "name": {
+                    "description": "账户名/子账户",
+                    "type": "string"
+                },
+                "optioncode": {
+                    "description": "[期货合约]期权代码 [期权]",
+                    "type": "string"
+                },
+                "ordertype": {
+                    "description": "单据类型[套期工具] - 1:期货单 2:看涨期权单 3:看跌期权单",
+                    "type": "integer"
+                },
+                "relatedlot": {
+                    "description": "[数量]关联手数",
+                    "type": "number"
+                },
+                "relatedmode": {
+                    "description": "关联方式 - 1:自动关联 2:手动关联 3:解绑关联",
+                    "type": "integer"
+                },
+                "relatedqty": {
+                    "description": "关联数量 = RelatedLot * AgreeUnit * ConvertRatio",
+                    "type": "number"
+                },
+                "retcode": {
+                    "description": "返回码",
+                    "type": "integer"
+                },
+                "saleuserid": {
+                    "description": "业务员ID",
+                    "type": "integer"
+                },
+                "tradedate": {
+                    "description": "关联交易日(yyyyMMdd)",
+                    "type": "string"
+                },
+                "tradeid": {
+                    "description": "[成交单号]内部成交单ID",
+                    "type": "string"
+                },
+                "tradelot": {
+                    "description": "成交手数",
+                    "type": "integer"
+                },
+                "tradeprice": {
+                    "description": "[价格]成交价格",
+                    "type": "number"
+                },
+                "tradetime": {
+                    "description": "日期时间",
+                    "type": "string"
+                },
+                "tradetradedate": {
+                    "description": "成交交易日(yyyyMMdd)",
+                    "type": "string"
+                }
+            }
+        },
         "models.QhjAccountOutInApply": {
             "type": "object",
             "properties": {
@@ -36327,6 +36857,142 @@
                 }
             }
         },
+        "models.Unlinkermcphedgeplan": {
+            "type": "object",
+            "required": [
+                "areauserid"
+            ],
+            "properties": {
+                "accountid": {
+                    "description": "期货账户ID - 作废",
+                    "type": "integer"
+                },
+                "accountname": {
+                    "description": "交易用户",
+                    "type": "string"
+                },
+                "applyid": {
+                    "description": "申请人",
+                    "type": "integer"
+                },
+                "applysrc": {
+                    "description": "申请来源 - 1:管理端 2:终端",
+                    "type": "integer"
+                },
+                "applytime": {
+                    "description": "申请时间",
+                    "type": "string"
+                },
+                "areauserid": {
+                    "description": "[企业ID]机构ID",
+                    "type": "integer"
+                },
+                "auditid": {
+                    "description": "审核人",
+                    "type": "integer"
+                },
+                "auditremark": {
+                    "description": "审核备注",
+                    "type": "string"
+                },
+                "auditsrc": {
+                    "description": "审核来源 - 1:管理端 2:终端",
+                    "type": "integer"
+                },
+                "audittime": {
+                    "description": "审核时间",
+                    "type": "string"
+                },
+                "audittradedate": {
+                    "description": "审核交易日(yyyyMMdd)",
+                    "type": "string"
+                },
+                "biztype": {
+                    "description": "业务类型 - 1:套保",
+                    "type": "integer"
+                },
+                "contracttype": {
+                    "description": "计划类型 - 1:采购 -1:销售",
+                    "type": "integer"
+                },
+                "convertfactor": {
+                    "description": "标仓系数 - 作废",
+                    "type": "number"
+                },
+                "createtime": {
+                    "description": "创建时间",
+                    "type": "string"
+                },
+                "currencyid": {
+                    "description": "结算币种ID - 作废",
+                    "type": "integer"
+                },
+                "deliverygoodsid": {
+                    "description": "现货品种ID",
+                    "type": "integer"
+                },
+                "enumdicname": {
+                    "description": "结算币种",
+                    "type": "string"
+                },
+                "hedgeplanid": {
+                    "description": "套保计划ID(601+Unix秒时间戳(10位)+xxxxxx)",
+                    "type": "integer"
+                },
+                "hedgeplanno": {
+                    "description": "[计划编号]套保计划编号,模糊查询",
+                    "type": "string"
+                },
+                "hedgeplanstatus": {
+                    "description": "[状态]套保计划状态 -  0:未提交 1:待审核 2:执行中 3:正常完结 4:审核拒绝 5:异常完结 6:已撤回",
+                    "type": "integer"
+                },
+                "isrelated": {
+                    "description": "是否已关联计划项目 - 0:否 1:是",
+                    "type": "integer"
+                },
+                "planqty": {
+                    "description": "[计划量]计划数量",
+                    "type": "number"
+                },
+                "plantime": {
+                    "description": "计划时间",
+                    "type": "string"
+                },
+                "producttype": {
+                    "description": "产品类型 - 1:标准仓单 2:等标 3:非标",
+                    "type": "integer"
+                },
+                "remark": {
+                    "description": "备注",
+                    "type": "string"
+                },
+                "spotgoodsdesc": {
+                    "description": "商品型号",
+                    "type": "string"
+                },
+                "tradedate": {
+                    "description": "交易日(yyyyMMdd)",
+                    "type": "string"
+                },
+                "tradeuserid": {
+                    "description": "交易用户ID",
+                    "type": "integer"
+                },
+                "updatetime": {
+                    "description": "更新时间",
+                    "type": "string"
+                },
+                "wrstandardid": {
+                    "description": "现货商品ID",
+                    "type": "integer"
+                },
+                "wrstandardname": {
+                    "description": "现货商品,模糊查询",
+                    "type": "string"
+                }
+            }
+        },
         "models.UserCollectConfig": {
             "type": "object",
             "properties": {

+ 474 - 0
docs/swagger.yaml

@@ -4232,6 +4232,81 @@ definitions:
         description: 商品名称
         type: string
     type: object
+  models.Ermcp2hedgeditemsDetail:
+    properties:
+      accountname:
+        description: 套期主体
+        type: string
+      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
+      unexeqty:
+        description: 未执行现货量 = 套期现货量 - 执行现货量
+        type: number
+      wrstandardid:
+        description: 现货商品ID
+        type: integer
+      wrstandardname:
+        description: 现货商品
+        type: string
+    type: object
   models.Ermcp2hedgeditemspot:
     properties:
       areauserid:
@@ -4407,6 +4482,70 @@ definitions:
     - hedgeditemid
     - middlegoodsid
     type: object
+  models.Ermcp2stockspotchangelog:
+    properties:
+      accountname:
+        description: 套期主体
+        type: string
+      aftervalue:
+        description: 现货量
+        type: number
+      beforevalue:
+        description: 变更前现货量
+        type: number
+      contracttype:
+        description: 现货合同类型 - 1:采购 -1:销售
+        type: integer
+      createtime:
+        description: 创建时间
+        type: string
+      customerusername:
+        description: 对手方
+        type: string
+      deliverygoodsid:
+        description: 现货品种ID
+        type: integer
+      exetype:
+        description: 执行类型 - 1:采购合同 2:销售合同 3:生产入库 4:生产出库
+        type: integer
+      logid:
+        description: 流水ID(604+Unix秒时间戳(10位)+xxxxxx)
+        type: integer
+      logvalue:
+        description: 现货量变更值
+        type: number
+      middlegoodschange:
+        description: 套期商品变化量 = LogValue * 折算系数* (1/(1+增值税))
+        type: number
+      operatelogtype:
+        description: 操作流水类型 -  2:点价数量 21:正常完结(合同) 22:异常终止(合同)  24:采购入库 25:销售出库 26:生产入库
+          27:生产出库
+        type: integer
+      relatedid:
+        description: 现货合同ID
+        type: integer
+      spotgoodsbrandid:
+        description: 现货品牌ID
+        type: integer
+      tradedate:
+        description: 交易日(yyyyMMdd)
+        type: string
+      userid:
+        description: 机构ID
+        type: integer
+      warehouseinfoid:
+        description: 仓库ID
+        type: integer
+      wrfactortypeid:
+        description: 仓单要素类型ID(212+Unix秒时间戳(10位)+xxxxxx)
+        type: integer
+      wrstandardid:
+        description: 现货商品ID
+        type: integer
+      wrstandardname:
+        description: 商品名称 LogValue * 折算系数* (1/(1+增值税))
+        type: string
+    type: object
   models.Ermcp3AreaSpot:
     properties:
       areauserid:
@@ -11577,6 +11716,109 @@ definitions:
         description: 菜单标题
         type: string
     type: object
+  models.Patradelinkdetail:
+    properties:
+      accountname:
+        description: 套期主体
+        type: string
+      agreeunit:
+        description: 合约乘数
+        type: number
+      amount:
+        description: 金额 = RelatedLot * TradePrice * AgreeUnit
+        type: number
+      areauserid:
+        description: 所属机构
+        type: integer
+      bizsubjectid:
+        description: 归属业务部门ID - SubjectID
+        type: integer
+      buyorsell:
+        description: 方向 - 0:买 1:卖
+        type: integer
+      convertratio:
+        description: 品种系数
+        type: number
+      convertratiochange:
+        description: 套期商品变化量 = RelatedLot * AgreeUnit * ConvertRatio
+        type: number
+      createtime:
+        description: 创建时间
+        type: string
+      creatorid:
+        description: 创建人ID
+        type: integer
+      creatorsrc:
+        description: 创建人来源 - 1:管理端 2:终端 3:交易
+        type: integer
+      goodscode:
+        description: 商品代码(内部)
+        type: string
+      goodsgroupid:
+        description: 对冲品种ID[期货合约商品组ID]
+        type: integer
+      goodsid:
+        description: 商品ID
+        type: integer
+      hedgeditemid:
+        description: 现货ID[套期项目ID] [13 - 被套期项目ID] [4,10,11 - 现货合同ID]  [9 - 套保计划ID]
+        type: integer
+      hedgeflag:
+        description: 投机套保标志 - 0:无 1:投机 2:套保 3:套利 4:套期保值(平安\合同) 5:单边(平安) 6:移仓(平安) 7:错单处理(平安)
+          8:跨期套利(平安) 9:套期保值(计划) 10:套利(合同)  11:换月(合同)  12:交割(金瑞) 13:被套期项目
+        type: integer
+      linkdetailid:
+        description: 期货明细ID(614+Unix秒时间戳(10位)+xxxxxx)
+        type: string
+      linkstatus:
+        description: 关联状态 - 1:成功 2:失败 3:解绑
+        type: integer
+      middlegoodsid:
+        description: 套保品种ID
+        type: integer
+      name:
+        description: 账户名/子账户
+        type: string
+      optioncode:
+        description: '[期货合约]期权代码 [期权]'
+        type: string
+      ordertype:
+        description: 单据类型[套期工具] - 1:期货单 2:看涨期权单 3:看跌期权单
+        type: integer
+      relatedlot:
+        description: '[数量]关联手数'
+        type: number
+      relatedmode:
+        description: 关联方式 - 1:自动关联 2:手动关联 3:解绑关联
+        type: integer
+      relatedqty:
+        description: 关联数量 = RelatedLot * AgreeUnit * ConvertRatio
+        type: number
+      retcode:
+        description: 返回码
+        type: integer
+      saleuserid:
+        description: 业务员ID
+        type: integer
+      tradedate:
+        description: 关联交易日(yyyyMMdd)
+        type: string
+      tradeid:
+        description: '[成交单号]内部成交单ID'
+        type: string
+      tradelot:
+        description: 成交手数
+        type: integer
+      tradeprice:
+        description: '[价格]成交价格'
+        type: number
+      tradetime:
+        description: 日期时间
+        type: string
+      tradetradedate:
+        description: 成交交易日(yyyyMMdd)
+        type: string
+    type: object
   models.QhjAccountOutInApply:
     properties:
       accountcode:
@@ -15598,6 +15840,107 @@ definitions:
         description: 用户名称
         type: string
     type: object
+  models.Unlinkermcphedgeplan:
+    properties:
+      accountid:
+        description: 期货账户ID - 作废
+        type: integer
+      accountname:
+        description: 交易用户
+        type: string
+      applyid:
+        description: 申请人
+        type: integer
+      applysrc:
+        description: 申请来源 - 1:管理端 2:终端
+        type: integer
+      applytime:
+        description: 申请时间
+        type: string
+      areauserid:
+        description: '[企业ID]机构ID'
+        type: integer
+      auditid:
+        description: 审核人
+        type: integer
+      auditremark:
+        description: 审核备注
+        type: string
+      auditsrc:
+        description: 审核来源 - 1:管理端 2:终端
+        type: integer
+      audittime:
+        description: 审核时间
+        type: string
+      audittradedate:
+        description: 审核交易日(yyyyMMdd)
+        type: string
+      biztype:
+        description: 业务类型 - 1:套保
+        type: integer
+      contracttype:
+        description: 计划类型 - 1:采购 -1:销售
+        type: integer
+      convertfactor:
+        description: 标仓系数 - 作废
+        type: number
+      createtime:
+        description: 创建时间
+        type: string
+      currencyid:
+        description: 结算币种ID - 作废
+        type: integer
+      deliverygoodsid:
+        description: 现货品种ID
+        type: integer
+      enumdicname:
+        description: 结算币种
+        type: string
+      hedgeplanid:
+        description: 套保计划ID(601+Unix秒时间戳(10位)+xxxxxx)
+        type: integer
+      hedgeplanno:
+        description: '[计划编号]套保计划编号,模糊查询'
+        type: string
+      hedgeplanstatus:
+        description: '[状态]套保计划状态 -  0:未提交 1:待审核 2:执行中 3:正常完结 4:审核拒绝 5:异常完结 6:已撤回'
+        type: integer
+      isrelated:
+        description: 是否已关联计划项目 - 0:否 1:是
+        type: integer
+      planqty:
+        description: '[计划量]计划数量'
+        type: number
+      plantime:
+        description: 计划时间
+        type: string
+      producttype:
+        description: 产品类型 - 1:标准仓单 2:等标 3:非标
+        type: integer
+      remark:
+        description: 备注
+        type: string
+      spotgoodsdesc:
+        description: 商品型号
+        type: string
+      tradedate:
+        description: 交易日(yyyyMMdd)
+        type: string
+      tradeuserid:
+        description: 交易用户ID
+        type: integer
+      updatetime:
+        description: 更新时间
+        type: string
+      wrstandardid:
+        description: 现货商品ID
+        type: integer
+      wrstandardname:
+        description: 现货商品,模糊查询
+        type: string
+    required:
+    - areauserid
+    type: object
   models.UserCollectConfig:
     properties:
       accountstatus:
@@ -24993,6 +25336,68 @@ paths:
       summary: 查询被套期项目信息
       tags:
       - 企业风险管理v8
+  /Ermcp8/QueryErmcp2HedgedItemsDetail:
+    get:
+      parameters:
+      - description: 用户ID
+        in: query
+        name: userid
+        required: true
+        type: integer
+      - description: 套保品种ID
+        in: query
+        name: middlegoodsid
+        required: true
+        type: integer
+      produces:
+      - application/json
+      responses:
+        "200":
+          description: OK
+          schema:
+            items:
+              $ref: '#/definitions/models.Ermcp2hedgeditemsDetail'
+            type: array
+        "500":
+          description: Internal Server Error
+          schema:
+            $ref: '#/definitions/app.Response'
+      security:
+      - ApiKeyAuth: []
+      summary: 敞口明细 - 计划变动明细
+      tags:
+      - 企业风险管理v8
+  /Ermcp8/QueryErmcp2StockSpotChangeLog:
+    get:
+      parameters:
+      - description: 用户ID
+        in: query
+        name: userid
+        required: true
+        type: integer
+      - description: 套保品种ID
+        in: query
+        name: middlegoodsid
+        required: true
+        type: integer
+      produces:
+      - application/json
+      responses:
+        "200":
+          description: OK
+          schema:
+            items:
+              $ref: '#/definitions/models.Ermcp2stockspotchangelog'
+            type: array
+        "500":
+          description: Internal Server Error
+          schema:
+            $ref: '#/definitions/app.Response'
+      security:
+      - ApiKeyAuth: []
+      summary: 敞口明细 - 现货变动明细查询
+      tags:
+      - 企业风险管理v8
   /Ermcp8/QueryErmcp8EnableHedgeditem:
     get:
       parameters:
@@ -25187,6 +25592,75 @@ paths:
       summary: 内部未关联成交单查询
       tags:
       - 企业风险管理v8
+  /Ermcp8/QueryPatradeLinkDetail:
+    get:
+      parameters:
+      - description: 用户ID
+        in: query
+        name: userid
+        required: true
+        type: integer
+      - description: 套保品种ID
+        in: query
+        name: middlegoodsid
+        required: true
+        type: integer
+      produces:
+      - application/json
+      responses:
+        "200":
+          description: OK
+          schema:
+            items:
+              $ref: '#/definitions/models.Patradelinkdetail'
+            type: array
+        "500":
+          description: Internal Server Error
+          schema:
+            $ref: '#/definitions/app.Response'
+      security:
+      - ApiKeyAuth: []
+      summary: 敞口明细 - 期货变动明细
+      tags:
+      - 企业风险管理v8
+  /Ermcp8/QueryUnLinkErmcpHedgePlan:
+    get:
+      parameters:
+      - description: 企业ID
+        in: query
+        name: areauserid
+        required: true
+        type: integer
+      - description: 计划类型 - 1:采购 -1:销售
+        in: query
+        name: contracttype
+        type: integer
+      - description: 计划编号,模糊查询
+        in: query
+        name: hedgeplanno
+        type: string
+      - description: 现货商品,模糊查询
+        in: query
+        name: wrstandardname
+        type: string
+      produces:
+      - application/json
+      responses:
+        "200":
+          description: OK
+          schema:
+            items:
+              $ref: '#/definitions/models.Unlinkermcphedgeplan'
+            type: array
+        "500":
+          description: Internal Server Error
+          schema:
+            $ref: '#/definitions/app.Response'
+      security:
+      - ApiKeyAuth: []
+      summary: 未关联购销计划
+      tags:
+      - 企业风险管理v8
   /Ermcp8/QueryUnLinkSpotContract:
     get:
       parameters:

+ 339 - 0
models/ermcp8.go

@@ -1633,3 +1633,342 @@ func (r *Ermcp2AreaExposure) GetDataEx(userID int) (interface{}, error) {
 
 	return sData, nil
 }
+
+// Ermcp2stockspotchangelog 现货操作流水表
+type Ermcp2stockspotchangelog struct {
+	LOGID            int64   `json:"logid"  xorm:"LOGID"`                       // 流水ID(604+Unix秒时间戳(10位)+xxxxxx)
+	OPERATELOGTYPE   int32   `json:"operatelogtype"  xorm:"OPERATELOGTYPE"`     // 操作流水类型 -  2:点价数量 21:正常完结(合同) 22:异常终止(合同)  24:采购入库 25:销售出库 26:生产入库 27:生产出库
+	DELIVERYGOODSID  int64   `json:"deliverygoodsid"  xorm:"DELIVERYGOODSID"`   // 现货品种ID
+	WRSTANDARDID     int64   `json:"wrstandardid"  xorm:"WRSTANDARDID"`         // 现货商品ID
+	SPOTGOODSBRANDID int32   `json:"spotgoodsbrandid"  xorm:"SPOTGOODSBRANDID"` // 现货品牌ID
+	WRFACTORTYPEID   int64   `json:"wrfactortypeid"  xorm:"WRFACTORTYPEID"`     // 仓单要素类型ID(212+Unix秒时间戳(10位)+xxxxxx)
+	WAREHOUSEINFOID  int64   `json:"warehouseinfoid"  xorm:"WAREHOUSEINFOID"`   // 仓库ID
+	RELATEDID        int64   `json:"relatedid"  xorm:"RELATEDID"`               // 现货合同ID
+	CONTRACTTYPE     int32   `json:"contracttype"  xorm:"CONTRACTTYPE"`         // 现货合同类型 - 1:采购 -1:销售
+	EXETYPE          int32   `json:"exetype"  xorm:"EXETYPE"`                   // 执行类型 - 1:采购合同 2:销售合同 3:生产入库 4:生产出库
+	LOGVALUE         float64 `json:"logvalue"  xorm:"LOGVALUE"`                 // 现货量变更值
+	BEFOREVALUE      float64 `json:"beforevalue"  xorm:"BEFOREVALUE"`           // 变更前现货量
+	AFTERVALUE       float64 `json:"aftervalue"  xorm:"AFTERVALUE"`             // 现货量
+	TRADEDATE        string  `json:"tradedate"  xorm:"TRADEDATE"`               // 交易日(yyyyMMdd)
+	CREATETIME       string  `json:"createtime"  xorm:"CREATETIME"`             // 创建时间
+	USERID           int64   `json:"userid"  xorm:"USERID" form:"userid"`       // 机构ID
+
+	CustomerUserName string `json:"customerusername" xorm:"CUSTOMERUSERNAME"` // 对手方
+	Wrstandardname   string `json:"wrstandardname" xorm:"WRSTANDARDNAME"`     // 商品名称 LogValue * 折算系数* (1/(1+增值税))
+	AccountName      string `json:"accountname" xorm:"ACCOUNTNAME"`           // 套期主体
+
+	MiddleGoodsChange float64 `json:"middlegoodschange" xorm:"MIDDLEGOODSCHANGE"` // 套期商品变化量 = LogValue * 折算系数* (1/(1+增值税))
+
+	MIDDLEGOODSID int64 `json:"-"  form:"middlegoodsid"` // 套保品种ID
+}
+
+// TableName is ERMCP2_STOCKSPOTCHANGELOG
+func (r *Ermcp2stockspotchangelog) TableName() string {
+	return "ERMCP2_STOCKSPOTCHANGELOG"
+}
+
+func (r *Ermcp2stockspotchangelog) calc() {
+
+}
+
+func (r *Ermcp2stockspotchangelog) buildSql() string {
+	// var sqlId utils.SQLVal = `
+	// 	WITH tmp AS
+	// 	(
+	// 		SELECT
+	// 			c.WRStandardID,
+	// 			ws.WRStandardCode,
+	// 			ws.WRStandardName,
+	// 			c.ConvertRatio,
+	// 			mg.MiddleGoodsID
+	// 		FROM ERMS2_WRSConvertDetail c
+	// 		LEFT JOIN ERMS_MiddleGoods mg ON mg.MiddleGoodsID = c.MiddleGoodsID
+	// 		LEFT JOIN WRStandard ws ON ws.WRStandardID = c.WRStandardID
+	// 	)
+	// 	SELECT
+	// 		to_char(t.CREATETIME, 'yyyy-mm-dd hh24:mi:ss') CREATETIME,
+	// 		t.EXETYPE,
+	// 		u.ACCOUNTNAME CUSTOMERUSERNAME,
+	// 		tmp.WRSTANDARDNAME,
+	// 		t.LOGVALUE,
+	// 		s.CONTRACTNO,
+	// 		u1.ACCOUNTNAME
+	// 	FROM ERMCP2_StockSpotChangeLog t
+	// 	LEFT JOIN ERMCP_SPOTCONTRACT s ON s.SPOTCONTRACTID = t.RELATEDID
+	// 	LEFT JOIN useraccount u ON u.userid = s.CUSTOMERUSERID
+	// 	LEFT JOIN useraccount u1 ON u.userid = s.RELATEDUSERID
+	// 	LEFT JOIN tmp ON t.WRSTANDARDID = tmp.WRStandardID
+	// 	WHERE t.userid = %v and tmp.MiddleGoodsID = %v
+	// `
+	var sqlId utils.SQLVal = `
+		SELECT
+			to_char(t.CREATETIME, 'yyyy-mm-dd hh24:mi:ss') CREATETIME,
+			t.EXETYPE,
+			u.ACCOUNTNAME CUSTOMERUSERNAME,
+			ws.WRSTANDARDNAME,
+			t.LOGVALUE,
+			s.CONTRACTNO,
+			u1.ACCOUNTNAME
+		FROM ERMCP2_StockSpotChangeLog t
+		LEFT JOIN ERMS2_WRSConvertDetail c ON c.WRStandardID = t.WRStandardID
+		LEFT JOIN ERMS_MiddleGoods mg ON mg.MiddleGoodsID = c.MiddleGoodsID
+		LEFT JOIN WRStandard ws ON ws.WRStandardID = t.WRStandardID
+		LEFT JOIN ERMCP_SPOTCONTRACT s ON s.SPOTCONTRACTID = t.RELATEDID
+		LEFT JOIN useraccount u ON u.userid = s.CUSTOMERUSERID
+		LEFT JOIN useraccount u1 ON u.userid = s.RELATEDUSERID
+		WHERE t.userid = %v AND mg.MiddleGoodsID = %v
+	`
+	sqlId.FormatParam(r.USERID, r.MIDDLEGOODSID)
+
+	return sqlId.String()
+}
+
+// GetDataEx 从数据库中查询数据
+func (r *Ermcp2stockspotchangelog) GetDataEx() (interface{}, error) {
+	e := db.GetEngine()
+	s := e.SQL(r.buildSql())
+	sData := make([]Ermcp2stockspotchangelog, 0)
+	if err := s.Find(&sData); err != nil {
+		return nil, err
+	}
+	for i := range sData {
+		sData[i].calc()
+	}
+	return sData, nil
+}
+
+// Ermcp2hedgeditemspot 计划变动明细
+type Ermcp2hedgeditemsDetail struct {
+	HEDGEDITEMSPOTID      string  `json:"hedgeditemspotid"  xorm:"HEDGEDITEMSPOTID"`           // 现货明细ID(625+Unix秒时间戳(10位)+xxxxxx)
+	HEDGEDITEMID          string  `json:"hedgeditemid"  xorm:"HEDGEDITEMID"`                   // 被套期项目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            string  `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"`      // 计划编号
+	UNEXEQTY       float64 `json:"unexeqty"  xorm:"UNEXEQTY"`            // 未执行现货量 = 套期现货量 - 执行现货量
+	AccountName    string  `json:"accountname" xorm:"ACCOUNTNAME"`       // 套期主体
+
+	USERID        int64 `json:"-" form:"userid"`         // 用户ID
+	MIDDLEGOODSID int64 `json:"-"  form:"middlegoodsid"` // 套保品种ID
+}
+
+func (r *Ermcp2hedgeditemsDetail) calc() {
+
+}
+
+func (r *Ermcp2hedgeditemsDetail) buildSql() string {
+	var sqlId utils.SQLVal = `
+		SELECT 
+			to_char(t.CREATETIME, 'yyyy-mm-dd hh24:mi:ss') CREATETIME,
+			t.SPOTTYPE,
+			wr.WRSTANDARDNAME,
+			e.ENUMDICNAME,
+			h.UNEXEQTY,
+			t.RELATEDQTY,
+			s.HEDGEPLANNO,
+			u.ACCOUNTNAME
+		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
+		LEFT JOIN ERMCP2_HedgedItem h on h.HedgedItemID = t.HEDGEDITEMID
+		LEFT JOIN useraccount u ON u.userid = t.TRADEUSERID
+		WHERE t.SpotType IN (1,2) 
+			AND t.areauserid = %v AND mg.MiddleGoodsID = %v
+	`
+	sqlId.FormatParam(r.USERID, r.MIDDLEGOODSID)
+
+	return sqlId.String()
+}
+
+// GetDataEx 从数据库中查询数据
+func (r *Ermcp2hedgeditemsDetail) GetDataEx() (interface{}, error) {
+	e := db.GetEngine()
+	s := e.SQL(r.buildSql())
+	sData := make([]Ermcp2hedgeditemsDetail, 0)
+	if err := s.Find(&sData); err != nil {
+		return nil, err
+	}
+	for i := range sData {
+		sData[i].calc()
+	}
+	return sData, nil
+}
+
+// Patradelinkdetail 期货变动明细
+type Patradelinkdetail struct {
+	LINKDETAILID   string  `json:"linkdetailid"  xorm:"LINKDETAILID"`                        // 期货明细ID(614+Unix秒时间戳(10位)+xxxxxx)
+	TRADEID        string  `json:"tradeid"  xorm:"TRADEID"`                                  // [成交单号]内部成交单ID
+	BUYORSELL      int32   `json:"buyorsell"  xorm:"BUYORSELL"`                              // 方向 - 0:买 1:卖
+	HEDGEFLAG      int32   `json:"hedgeflag"  xorm:"HEDGEFLAG"`                              // 投机套保标志 - 0:无 1:投机 2:套保 3:套利 4:套期保值(平安\合同) 5:单边(平安) 6:移仓(平安) 7:错单处理(平安) 8:跨期套利(平安) 9:套期保值(计划) 10:套利(合同)  11:换月(合同)  12:交割(金瑞) 13:被套期项目
+	SPOTCONTRACTID int64   `json:"hedgeditemid"  xorm:"SPOTCONTRACTID"`                      // 现货ID[套期项目ID] [13 - 被套期项目ID] [4,10,11 - 现货合同ID]  [9 - 套保计划ID]
+	RELATEDLOT     float64 `json:"relatedlot"  xorm:"RELATEDLOT"`                            // [数量]关联手数
+	GOODSID        int32   `json:"goodsid"  xorm:"GOODSID"`                                  // 商品ID
+	GOODSGROUPID   int32   `json:"goodsgroupid"  xorm:"GOODSGROUPID"`                        // 对冲品种ID[期货合约商品组ID]
+	MIDDLEGOODSID  int64   `json:"middlegoodsid"  xorm:"MIDDLEGOODSID" form:"middlegoodsid"` // 套保品种ID
+	RELATEDQTY     float64 `json:"relatedqty"  xorm:"RELATEDQTY"`                            // 关联数量 = RelatedLot * AgreeUnit * ConvertRatio
+	TRADEDATE      string  `json:"tradedate"  xorm:"TRADEDATE"`                              // 关联交易日(yyyyMMdd)
+	RELATEDMODE    int32   `json:"relatedmode"  xorm:"RELATEDMODE"`                          // 关联方式 - 1:自动关联 2:手动关联 3:解绑关联
+	TRADETRADEDATE string  `json:"tradetradedate"  xorm:"TRADETRADEDATE"`                    // 成交交易日(yyyyMMdd)
+	TRADEPRICE     float64 `json:"tradeprice"  xorm:"TRADEPRICE"`                            // [价格]成交价格
+	TRADELOT       int64   `json:"tradelot"  xorm:"TRADELOT"`                                // 成交手数
+	SALEUSERID     int64   `json:"saleuserid"  xorm:"SALEUSERID"`                            // 业务员ID
+	BIZSUBJECTID   int64   `json:"bizsubjectid"  xorm:"BIZSUBJECTID"`                        // 归属业务部门ID - SubjectID
+	AGREEUNIT      float64 `json:"agreeunit"  xorm:"AGREEUNIT"`                              // 合约乘数
+	CONVERTRATIO   float64 `json:"convertratio"  xorm:"CONVERTRATIO"`                        // 品种系数
+	AREAUSERID     int64   `json:"areauserid"  xorm:"AREAUSERID"`                            // 所属机构
+	CREATORSRC     int32   `json:"creatorsrc"  xorm:"CREATORSRC"`                            // 创建人来源 - 1:管理端 2:终端 3:交易
+	CREATORID      int64   `json:"creatorid"  xorm:"CREATORID"`                              // 创建人ID
+	CREATETIME     string  `json:"createtime"  xorm:"CREATETIME"`                            // 创建时间
+	LINKSTATUS     int32   `json:"linkstatus"  xorm:"LINKSTATUS"`                            // 关联状态 - 1:成功 2:失败 3:解绑
+	RETCODE        int32   `json:"retcode"  xorm:"RETCODE"`                                  // 返回码
+
+	TRADETIME          time.Time `json:"tradetime"  xorm:"TRADETIME"`                  // 日期时间
+	ORDERTYPE          int32     `json:"ordertype"  xorm:"ORDERTYPE"`                  // 单据类型[套期工具] - 1:期货单 2:看涨期权单 3:看跌期权单
+	OPTIONCODE         string    `json:"optioncode"  xorm:"OPTIONCODE"`                // [期货合约]期权代码 [期权]
+	AMOUNT             float64   `json:"amount"  xorm:"AMOUNT"`                        // 金额 = RelatedLot * TradePrice * AgreeUnit
+	NAME               string    `json:"name" xorm:"NAME"`                             // 账户名/子账户
+	GOODSCODE          string    `json:"goodscode"  xorm:"GOODSCODE"`                  // 商品代码(内部)
+	CONVERTRATIOCHANGE float64   `json:"convertratiochange" xorm:"CONVERTRATIOCHANGE"` // 套期商品变化量 = RelatedLot * AgreeUnit * ConvertRatio
+	AccountName        string    `json:"accountname" xorm:"ACCOUNTNAME"`               // 套期主体
+
+	USERID int64 `json:"-" form:"userid"` // 用户ID
+}
+
+func (r *Patradelinkdetail) calc() {
+
+}
+
+func (r *Patradelinkdetail) buildSql() string {
+	var sqlId utils.SQLVal = `
+	SELECT
+		to_char(t.CREATETIME, 'yyyy-mm-dd hh24:mi:ss') CREATETIME,
+		p.ORDERTYPE,
+		g.GOODSCODE,
+		t.BUYORSELL,
+		t.TRADEPRICE,
+		t.RELATEDLOT,
+		(t.RelatedLot * t.TradePrice * t.AgreeUnit) AMOUNT,
+		(t.RelatedLot * t.AgreeUnit * t.ConvertRatio) CONVERTRATIOCHANGE,
+		to_char(t.TRADEID) TRADEID,
+		u.ACCOUNTNAME
+	FROM ERMCP_PA_TradeLinkDetail t
+	LEFT JOIN ERMCP_PA_TradeLink p ON p.TradeID = t.TradeID AND p.BuyorSell = t.BuyorSell
+	LEFT JOIN USERACCOUNT u on u.userid = p.ACCOUNTID
+	LEFT JOIN GOODS g ON g.goodsid = t.goodsid
+	WHERE t.areauserid = %v AND t.middlegoodsid = %v
+	`
+	sqlId.FormatParam(r.USERID, r.MIDDLEGOODSID)
+
+	return sqlId.String()
+}
+
+// GetDataEx 从数据库中查询数据
+func (r *Patradelinkdetail) GetDataEx() (interface{}, error) {
+	e := db.GetEngine()
+	s := e.SQL(r.buildSql())
+	sData := make([]Patradelinkdetail, 0)
+	if err := s.Find(&sData); err != nil {
+		return nil, err
+	}
+	for i := range sData {
+		sData[i].calc()
+	}
+	return sData, nil
+}
+
+// Unlinkermcphedgeplan 未关联购销计划
+type Unlinkermcphedgeplan struct {
+	HEDGEPLANID     int64     `json:"hedgeplanid"  xorm:"HEDGEPLANID"`                                    // 套保计划ID(601+Unix秒时间戳(10位)+xxxxxx)
+	HEDGEPLANNO     string    `json:"hedgeplanno"  xorm:"HEDGEPLANNO" form:"hedgeplanno"`                 // [计划编号]套保计划编号,模糊查询
+	CONTRACTTYPE    int32     `json:"contracttype"  xorm:"CONTRACTTYPE" form:"contracttype"`              // 计划类型 - 1:采购 -1:销售
+	AREAUSERID      int64     `json:"areauserid"  xorm:"AREAUSERID" form:"areauserid" binding:"required"` // [企业ID]机构ID
+	DELIVERYGOODSID int64     `json:"deliverygoodsid"  xorm:"DELIVERYGOODSID"`                            // 现货品种ID
+	PRODUCTTYPE     int32     `json:"producttype"  xorm:"PRODUCTTYPE"`                                    // 产品类型 - 1:标准仓单 2:等标 3:非标
+	SPOTGOODSDESC   string    `json:"spotgoodsdesc"  xorm:"SPOTGOODSDESC"`                                // 商品型号
+	PLANQTY         float64   `json:"planqty"  xorm:"PLANQTY"`                                            // [计划量]计划数量
+	CONVERTFACTOR   float64   `json:"convertfactor"  xorm:"CONVERTFACTOR"`                                // 标仓系数 - 作废
+	PLANTIME        time.Time `json:"plantime"  xorm:"PLANTIME"`                                          // 计划时间
+	TRADEDATE       string    `json:"tradedate"  xorm:"TRADEDATE"`                                        // 交易日(yyyyMMdd)
+	HEDGEPLANSTATUS int32     `json:"hedgeplanstatus"  xorm:"HEDGEPLANSTATUS"`                            // [状态]套保计划状态 -  0:未提交 1:待审核 2:执行中 3:正常完结 4:审核拒绝 5:异常完结 6:已撤回
+	CREATETIME      time.Time `json:"createtime"  xorm:"CREATETIME"`                                      // 创建时间
+	UPDATETIME      time.Time `json:"updatetime"  xorm:"UPDATETIME"`                                      // 更新时间
+	APPLYSRC        int32     `json:"applysrc"  xorm:"APPLYSRC"`                                          // 申请来源 - 1:管理端 2:终端
+	APPLYID         int64     `json:"applyid"  xorm:"APPLYID"`                                            // 申请人
+	REMARK          string    `json:"remark"  xorm:"REMARK"`                                              // 备注
+	APPLYTIME       time.Time `json:"applytime"  xorm:"APPLYTIME"`                                        // 申请时间
+	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"`                                    // 审核备注
+	WRSTANDARDID    int64     `json:"wrstandardid"  xorm:"WRSTANDARDID"`                                  // 现货商品ID
+	ACCOUNTID       int64     `json:"accountid"  xorm:"ACCOUNTID"`                                        // 期货账户ID - 作废
+	TRADEUSERID     int64     `json:"tradeuserid"  xorm:"TRADEUSERID"`                                    // 交易用户ID
+	CURRENCYID      int64     `json:"currencyid"  xorm:"CURRENCYID"`                                      // 结算币种ID - 作废
+	BIZTYPE         int32     `json:"biztype"  xorm:"BIZTYPE"`                                            // 业务类型 - 1:套保
+	ISRELATED       int32     `json:"isrelated"  xorm:"ISRELATED"`                                        // 是否已关联计划项目 - 0:否 1:是
+
+	AccountName    string `json:"accountname" xorm:"ACCOUNTNAME"`                             // 交易用户
+	EnumdicName    string `json:"enumdicname"  xorm:"ENUMDICNAME"`                            // 结算币种
+	Wrstandardname string `json:"wrstandardname" xorm:"WRSTANDARDNAME" form:"wrstandardname"` // 现货商品,模糊查询
+}
+
+func (r *Unlinkermcphedgeplan) calc() {
+
+}
+
+func (r *Unlinkermcphedgeplan) buildSql() string {
+	var sqlId utils.SQLVal = `
+	SELECT
+		t.HEDGEPLANNO,
+		u.ACCOUNTNAME,
+		t.CONTRACTTYPE,
+		wr.WRSTANDARDNAME,
+		t.PLANQTY,
+		e.ENUMDICNAME,
+		t.HEDGEPLANSTATUS
+	FROM ERMCP_HedgePlan t
+	LEFT JOIN USERACCOUNT u on u.userid = t.tradeuserid
+	LEFT JOIN WRStandard wr ON wr.wrstandardid = t.wrstandardid
+	LEFT JOIN ENUMDICITEM e ON e.ENUMITEMNAME = t.CURRENCYID and e.ENUMDICCODE = 'currency'
+	WHERE t.areauserid = %v
+	`
+	sqlId.FormatParam(r.AREAUSERID)
+	sqlId.AndEx("t.contracttype", r.CONTRACTTYPE, r.CONTRACTTYPE > 0)
+	sqlId.AndLike("t.hedgeplanno", r.HEDGEPLANNO)
+	sqlId.AndLike("wr.WRSTANDARDNAME", r.HEDGEPLANNO)
+
+	return sqlId.String()
+}
+
+// GetDataEx 从数据库中查询数据
+func (r *Unlinkermcphedgeplan) GetDataEx() (interface{}, error) {
+	e := db.GetEngine()
+	s := e.SQL(r.buildSql())
+	sData := make([]Unlinkermcphedgeplan, 0)
+	if err := s.Find(&sData); err != nil {
+		return nil, err
+	}
+	for i := range sData {
+		sData[i].calc()
+	}
+	return sData, nil
+}

+ 3 - 0
routers/router.go

@@ -499,6 +499,9 @@ func InitRouter() *gin.Engine {
 		ermcp8R.GET("/QueryErmcp8EnableHedgeditem", ermcp8.QueryErmcp8EnableHedgeditem)
 		ermcp8R.GET("/QueryErmcp8RunningHedgeditem", ermcp8.QueryErmcp8RunningHedgeditem)
 		ermcp8R.GET("/QueryErmcp2AreaExposure", ermcp8.QueryErmcp2AreaExposure)
+		ermcp8R.GET("/QueryErmcp2StockSpotChangeLog", ermcp8.QueryErmcp2StockSpotChangeLog)
+		ermcp8R.GET("/QueryErmcp2HedgedItemsDetail", ermcp8.QueryErmcp2HedgedItemsDetail)
+		ermcp8R.GET("/QueryPatradeLinkDetail", ermcp8.QueryPatradeLinkDetail)
 	}
 
 	// ****************************大连千海金******************************