Bladeren bron

新增“查询被套期项目信息”接口

zhou.xiaoning 3 jaren geleden
bovenliggende
commit
57665d0f80
6 gewijzigde bestanden met toevoegingen van 1224 en 0 verwijderingen
  1. 27 0
      controllers/ermcp8/qryErmcp8.go
  2. 344 0
      docs/docs.go
  3. 344 0
      docs/swagger.json
  4. 250 0
      docs/swagger.yaml
  5. 251 0
      models/ermcp8.go
  6. 8 0
      routers/router.go

+ 27 - 0
controllers/ermcp8/qryErmcp8.go

@@ -0,0 +1,27 @@
+package ermcp8
+
+import (
+	"mtp2_if/global/app"
+	"mtp2_if/models"
+
+	"github.com/gin-gonic/gin"
+)
+
+// QueryErmcp2HedgedItem
+// @Summary 查询被套期项目信息
+// @description 已完成项目查询: 项目状态 = 3:正常完结 or 5:异常完结
+// @Produce json
+// @Security ApiKeyAuth
+// @Param userid query string true "用户ID"
+// @Param HedgedType query int false "套期类型 1:采购计划项目 2:销售计划项目 3:现货贸易项目 4:库存存货项目 5:定价采购合同项目"
+// @Param HedgedItemStatus query int false "项目状态 0:未提交 1:待审核 2:执行中 3:正常完结 4:审核拒绝 5:异常完结 6:已撤回"
+// @Success 200 {array} models.Ermcp2hedgeditem
+// @Failure 500 {object} app.Response
+// @Router /Ermcp8/QueryErmcp2HedgedItem [get]
+// @Tags 企业风险管理v8
+func QueryErmcp2HedgedItem(c *gin.Context) {
+	a := app.GinUtils{Gin: app.Gin{C: c}}
+	m := models.Ermcp2hedgeditem{}
+	a.DoBindReq(&m)
+	a.DoGetDataI(&m)
+}

+ 344 - 0
docs/docs.go

@@ -5585,6 +5585,61 @@ var doc = `{
                 }
             }
         },
+        "/Ermcp8/QueryErmcp2HedgedItem": {
+            "get": {
+                "security": [
+                    {
+                        "ApiKeyAuth": []
+                    }
+                ],
+                "description": "已完成项目查询: 项目状态 = 3:正常完结 or 5:异常完结",
+                "produces": [
+                    "application/json"
+                ],
+                "tags": [
+                    "企业风险管理v8"
+                ],
+                "summary": "查询被套期项目信息",
+                "parameters": [
+                    {
+                        "type": "string",
+                        "description": "用户ID",
+                        "name": "userid",
+                        "in": "query",
+                        "required": true
+                    },
+                    {
+                        "type": "integer",
+                        "description": "套期类型 1:采购计划项目 2:销售计划项目 3:现货贸易项目 4:库存存货项目 5:定价采购合同项目",
+                        "name": "HedgedType",
+                        "in": "query"
+                    },
+                    {
+                        "type": "integer",
+                        "description": "项目状态 0:未提交 1:待审核 2:执行中 3:正常完结 4:审核拒绝 5:异常完结 6:已撤回",
+                        "name": "HedgedItemStatus",
+                        "in": "query"
+                    }
+                ],
+                "responses": {
+                    "200": {
+                        "description": "OK",
+                        "schema": {
+                            "type": "array",
+                            "items": {
+                                "$ref": "#/definitions/models.Ermcp2hedgeditem"
+                            }
+                        }
+                    },
+                    "500": {
+                        "description": "Internal Server Error",
+                        "schema": {
+                            "$ref": "#/definitions/app.Response"
+                        }
+                    }
+                }
+            }
+        },
         "/Erms2/QueryArbitrageStrategy": {
             "get": {
                 "security": [
@@ -20036,6 +20091,295 @@ var doc = `{
                 }
             }
         },
+        "models.Ermcp2hedgeditem": {
+            "type": "object",
+            "properties": {
+                "accountName": {
+                    "description": "套期主体",
+                    "type": "string"
+                },
+                "applyid": {
+                    "description": "申请人",
+                    "type": "integer"
+                },
+                "applysrc": {
+                    "description": "申请来源 - 1:管理端 2:终端",
+                    "type": "integer"
+                },
+                "areauserid": {
+                    "description": "企业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"
+                },
+                "createtime": {
+                    "description": "申请时间",
+                    "type": "string"
+                },
+                "curprice": {
+                    "description": "当前市场价",
+                    "type": "number"
+                },
+                "curstock": {
+                    "description": "期末库存量 = 采购总量 - 销售总量",
+                    "type": "number"
+                },
+                "deliverygoodsid": {
+                    "description": "现货品种ID",
+                    "type": "integer"
+                },
+                "enddate": {
+                    "description": "完成日期",
+                    "type": "string"
+                },
+                "endtradedate": {
+                    "description": "完成交易日",
+                    "type": "string"
+                },
+                "enumdicname": {
+                    "description": "单位",
+                    "type": "string"
+                },
+                "exeamount": {
+                    "description": "执行市价总额",
+                    "type": "number"
+                },
+                "exeavgprice": {
+                    "description": "执行市场均价= 执行市价总额 / 执行现货量",
+                    "type": "number"
+                },
+                "execontractamount": {
+                    "description": "执行定价总额",
+                    "type": "number"
+                },
+                "exeqty": {
+                    "description": "执行现货量",
+                    "type": "number"
+                },
+                "exerestamount": {
+                    "description": "执行剩余市价总额【现货贸易】",
+                    "type": "number"
+                },
+                "futurefloatpl": {
+                    "description": "期货浮动损益",
+                    "type": "number"
+                },
+                "futurehedgepl": {
+                    "description": "期货实际损益",
+                    "type": "number"
+                },
+                "futurehedgeplchange": {
+                    "description": "期货实际损益变动",
+                    "type": "number"
+                },
+                "futurepl": {
+                    "description": "期货套期损益",
+                    "type": "number"
+                },
+                "futureplchange": {
+                    "description": "期货套期损益变动",
+                    "type": "number"
+                },
+                "hedgeamount": {
+                    "description": "套期市价总额",
+                    "type": "number"
+                },
+                "hedgecontractamount": {
+                    "description": "套期定价总额 【定价采购合同】【现货贸易】",
+                    "type": "number"
+                },
+                "hedgeditemid": {
+                    "description": "被套期项目ID(624+Unix秒时间戳(10位)+xxxxxx)",
+                    "type": "string"
+                },
+                "hedgeditemname": {
+                    "description": "项目名称",
+                    "type": "string"
+                },
+                "hedgeditemnum": {
+                    "description": "项目编号",
+                    "type": "string"
+                },
+                "hedgeditemstatus": {
+                    "description": "项目状态 - 0:未提交 1:待审核 2:执行中 3:正常完结 4:审核拒绝 5:异常完结 6:已撤回",
+                    "type": "integer"
+                },
+                "hedgedtype": {
+                    "description": "套期类型 - 1:采购计划项目 2:销售计划项目 3:现货贸易项目 4:库存存货项目 5:定价采购合同项目",
+                    "type": "integer"
+                },
+                "hedgeqty": {
+                    "description": "套期现货量",
+                    "type": "number"
+                },
+                "hedgerate": {
+                    "description": "套保比率",
+                    "type": "number"
+                },
+                "hedgerestamount": {
+                    "description": "套期剩余市价总额【现货贸易】",
+                    "type": "number"
+                },
+                "hedgesumpl": {
+                    "description": "套期汇总损益 = 期货汇总损益 + 现货汇总损益",
+                    "type": "number"
+                },
+                "middlegoodslist": {
+                    "description": "套期商品列表",
+                    "type": "array",
+                    "items": {
+                        "$ref": "#/definitions/models.Ermcp2himiddlegoods"
+                    }
+                },
+                "oriavgprice": {
+                    "description": "期初市场均价 = 套期市价总额 / 套期现货量",
+                    "type": "number"
+                },
+                "orifuturehedgepl": {
+                    "description": "期初期货实际损益",
+                    "type": "number"
+                },
+                "orifuturepl": {
+                    "description": "期初期货套期损益",
+                    "type": "number"
+                },
+                "orispothedgepl": {
+                    "description": "期初现货实际损益",
+                    "type": "number"
+                },
+                "orispotpl": {
+                    "description": "期初现货套期损益",
+                    "type": "number"
+                },
+                "planenddate": {
+                    "description": "计划结束日期",
+                    "type": "string"
+                },
+                "planstartdate": {
+                    "description": "计划开始日期",
+                    "type": "string"
+                },
+                "remark": {
+                    "description": "备注",
+                    "type": "string"
+                },
+                "spotbookamount": {
+                    "description": "现货账面总额",
+                    "type": "number"
+                },
+                "spotfloatpl": {
+                    "description": "现货浮动损益 =(当前市场价 - 期初市场价)*未执行现货量 * 方向(销售计划 为 -1, 其它为1)",
+                    "type": "number"
+                },
+                "spothedgepl": {
+                    "description": "现货套期损益 =(执行市场均价-期初市场均价)*执行现货量 * 方向(销售计划 为 -1, 其它为1)",
+                    "type": "number"
+                },
+                "spothedgeplchange": {
+                    "description": "现货实际损益变动",
+                    "type": "number"
+                },
+                "spotpl": {
+                    "description": "现货套期损益 = 现货实际损益 + 现货浮动损益",
+                    "type": "number"
+                },
+                "spotplchange": {
+                    "description": "现货套期损益变动",
+                    "type": "number"
+                },
+                "spottradepl": {
+                    "description": "现货贸易损益【现货贸易】= 执行合同定价总额 - 套期合同定价总额",
+                    "type": "number"
+                },
+                "sumobspl": {
+                    "description": "汇总绝对损益【现货贸易】=现货贸易损益+增值税损益+期货套期损益",
+                    "type": "number"
+                },
+                "tradeuserid": {
+                    "description": "交易用户ID",
+                    "type": "integer"
+                },
+                "unexeqty": {
+                    "description": "未执行现货量 = 套期现货量 - 执行现货量",
+                    "type": "number"
+                },
+                "updatetime": {
+                    "description": "更新时间",
+                    "type": "string"
+                },
+                "vatpl": {
+                    "description": "增值税损益【现货贸易】= 现货贸易损益 * (增值税率 /(1+增值税率))",
+                    "type": "number"
+                },
+                "vatrate": {
+                    "description": "增值税",
+                    "type": "number"
+                },
+                "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.Ermcp3AreaSpot": {
             "type": "object",
             "properties": {

+ 344 - 0
docs/swagger.json

@@ -5569,6 +5569,61 @@
                 }
             }
         },
+        "/Ermcp8/QueryErmcp2HedgedItem": {
+            "get": {
+                "security": [
+                    {
+                        "ApiKeyAuth": []
+                    }
+                ],
+                "description": "已完成项目查询: 项目状态 = 3:正常完结 or 5:异常完结",
+                "produces": [
+                    "application/json"
+                ],
+                "tags": [
+                    "企业风险管理v8"
+                ],
+                "summary": "查询被套期项目信息",
+                "parameters": [
+                    {
+                        "type": "string",
+                        "description": "用户ID",
+                        "name": "userid",
+                        "in": "query",
+                        "required": true
+                    },
+                    {
+                        "type": "integer",
+                        "description": "套期类型 1:采购计划项目 2:销售计划项目 3:现货贸易项目 4:库存存货项目 5:定价采购合同项目",
+                        "name": "HedgedType",
+                        "in": "query"
+                    },
+                    {
+                        "type": "integer",
+                        "description": "项目状态 0:未提交 1:待审核 2:执行中 3:正常完结 4:审核拒绝 5:异常完结 6:已撤回",
+                        "name": "HedgedItemStatus",
+                        "in": "query"
+                    }
+                ],
+                "responses": {
+                    "200": {
+                        "description": "OK",
+                        "schema": {
+                            "type": "array",
+                            "items": {
+                                "$ref": "#/definitions/models.Ermcp2hedgeditem"
+                            }
+                        }
+                    },
+                    "500": {
+                        "description": "Internal Server Error",
+                        "schema": {
+                            "$ref": "#/definitions/app.Response"
+                        }
+                    }
+                }
+            }
+        },
         "/Erms2/QueryArbitrageStrategy": {
             "get": {
                 "security": [
@@ -20020,6 +20075,295 @@
                 }
             }
         },
+        "models.Ermcp2hedgeditem": {
+            "type": "object",
+            "properties": {
+                "accountName": {
+                    "description": "套期主体",
+                    "type": "string"
+                },
+                "applyid": {
+                    "description": "申请人",
+                    "type": "integer"
+                },
+                "applysrc": {
+                    "description": "申请来源 - 1:管理端 2:终端",
+                    "type": "integer"
+                },
+                "areauserid": {
+                    "description": "企业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"
+                },
+                "createtime": {
+                    "description": "申请时间",
+                    "type": "string"
+                },
+                "curprice": {
+                    "description": "当前市场价",
+                    "type": "number"
+                },
+                "curstock": {
+                    "description": "期末库存量 = 采购总量 - 销售总量",
+                    "type": "number"
+                },
+                "deliverygoodsid": {
+                    "description": "现货品种ID",
+                    "type": "integer"
+                },
+                "enddate": {
+                    "description": "完成日期",
+                    "type": "string"
+                },
+                "endtradedate": {
+                    "description": "完成交易日",
+                    "type": "string"
+                },
+                "enumdicname": {
+                    "description": "单位",
+                    "type": "string"
+                },
+                "exeamount": {
+                    "description": "执行市价总额",
+                    "type": "number"
+                },
+                "exeavgprice": {
+                    "description": "执行市场均价= 执行市价总额 / 执行现货量",
+                    "type": "number"
+                },
+                "execontractamount": {
+                    "description": "执行定价总额",
+                    "type": "number"
+                },
+                "exeqty": {
+                    "description": "执行现货量",
+                    "type": "number"
+                },
+                "exerestamount": {
+                    "description": "执行剩余市价总额【现货贸易】",
+                    "type": "number"
+                },
+                "futurefloatpl": {
+                    "description": "期货浮动损益",
+                    "type": "number"
+                },
+                "futurehedgepl": {
+                    "description": "期货实际损益",
+                    "type": "number"
+                },
+                "futurehedgeplchange": {
+                    "description": "期货实际损益变动",
+                    "type": "number"
+                },
+                "futurepl": {
+                    "description": "期货套期损益",
+                    "type": "number"
+                },
+                "futureplchange": {
+                    "description": "期货套期损益变动",
+                    "type": "number"
+                },
+                "hedgeamount": {
+                    "description": "套期市价总额",
+                    "type": "number"
+                },
+                "hedgecontractamount": {
+                    "description": "套期定价总额 【定价采购合同】【现货贸易】",
+                    "type": "number"
+                },
+                "hedgeditemid": {
+                    "description": "被套期项目ID(624+Unix秒时间戳(10位)+xxxxxx)",
+                    "type": "string"
+                },
+                "hedgeditemname": {
+                    "description": "项目名称",
+                    "type": "string"
+                },
+                "hedgeditemnum": {
+                    "description": "项目编号",
+                    "type": "string"
+                },
+                "hedgeditemstatus": {
+                    "description": "项目状态 - 0:未提交 1:待审核 2:执行中 3:正常完结 4:审核拒绝 5:异常完结 6:已撤回",
+                    "type": "integer"
+                },
+                "hedgedtype": {
+                    "description": "套期类型 - 1:采购计划项目 2:销售计划项目 3:现货贸易项目 4:库存存货项目 5:定价采购合同项目",
+                    "type": "integer"
+                },
+                "hedgeqty": {
+                    "description": "套期现货量",
+                    "type": "number"
+                },
+                "hedgerate": {
+                    "description": "套保比率",
+                    "type": "number"
+                },
+                "hedgerestamount": {
+                    "description": "套期剩余市价总额【现货贸易】",
+                    "type": "number"
+                },
+                "hedgesumpl": {
+                    "description": "套期汇总损益 = 期货汇总损益 + 现货汇总损益",
+                    "type": "number"
+                },
+                "middlegoodslist": {
+                    "description": "套期商品列表",
+                    "type": "array",
+                    "items": {
+                        "$ref": "#/definitions/models.Ermcp2himiddlegoods"
+                    }
+                },
+                "oriavgprice": {
+                    "description": "期初市场均价 = 套期市价总额 / 套期现货量",
+                    "type": "number"
+                },
+                "orifuturehedgepl": {
+                    "description": "期初期货实际损益",
+                    "type": "number"
+                },
+                "orifuturepl": {
+                    "description": "期初期货套期损益",
+                    "type": "number"
+                },
+                "orispothedgepl": {
+                    "description": "期初现货实际损益",
+                    "type": "number"
+                },
+                "orispotpl": {
+                    "description": "期初现货套期损益",
+                    "type": "number"
+                },
+                "planenddate": {
+                    "description": "计划结束日期",
+                    "type": "string"
+                },
+                "planstartdate": {
+                    "description": "计划开始日期",
+                    "type": "string"
+                },
+                "remark": {
+                    "description": "备注",
+                    "type": "string"
+                },
+                "spotbookamount": {
+                    "description": "现货账面总额",
+                    "type": "number"
+                },
+                "spotfloatpl": {
+                    "description": "现货浮动损益 =(当前市场价 - 期初市场价)*未执行现货量 * 方向(销售计划 为 -1, 其它为1)",
+                    "type": "number"
+                },
+                "spothedgepl": {
+                    "description": "现货套期损益 =(执行市场均价-期初市场均价)*执行现货量 * 方向(销售计划 为 -1, 其它为1)",
+                    "type": "number"
+                },
+                "spothedgeplchange": {
+                    "description": "现货实际损益变动",
+                    "type": "number"
+                },
+                "spotpl": {
+                    "description": "现货套期损益 = 现货实际损益 + 现货浮动损益",
+                    "type": "number"
+                },
+                "spotplchange": {
+                    "description": "现货套期损益变动",
+                    "type": "number"
+                },
+                "spottradepl": {
+                    "description": "现货贸易损益【现货贸易】= 执行合同定价总额 - 套期合同定价总额",
+                    "type": "number"
+                },
+                "sumobspl": {
+                    "description": "汇总绝对损益【现货贸易】=现货贸易损益+增值税损益+期货套期损益",
+                    "type": "number"
+                },
+                "tradeuserid": {
+                    "description": "交易用户ID",
+                    "type": "integer"
+                },
+                "unexeqty": {
+                    "description": "未执行现货量 = 套期现货量 - 执行现货量",
+                    "type": "number"
+                },
+                "updatetime": {
+                    "description": "更新时间",
+                    "type": "string"
+                },
+                "vatpl": {
+                    "description": "增值税损益【现货贸易】= 现货贸易损益 * (增值税率 /(1+增值税率))",
+                    "type": "number"
+                },
+                "vatrate": {
+                    "description": "增值税",
+                    "type": "number"
+                },
+                "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.Ermcp3AreaSpot": {
             "type": "object",
             "properties": {

+ 250 - 0
docs/swagger.yaml

@@ -3969,6 +3969,221 @@ definitions:
     - enumdicid
     - enumitemname
     type: object
+  models.Ermcp2hedgeditem:
+    properties:
+      accountName:
+        description: 套期主体
+        type: string
+      applyid:
+        description: 申请人
+        type: integer
+      applysrc:
+        description: 申请来源 - 1:管理端 2:终端
+        type: integer
+      areauserid:
+        description: 企业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
+      createtime:
+        description: 申请时间
+        type: string
+      curprice:
+        description: 当前市场价
+        type: number
+      curstock:
+        description: 期末库存量 = 采购总量 - 销售总量
+        type: number
+      deliverygoodsid:
+        description: 现货品种ID
+        type: integer
+      enddate:
+        description: 完成日期
+        type: string
+      endtradedate:
+        description: 完成交易日
+        type: string
+      enumdicname:
+        description: 单位
+        type: string
+      exeamount:
+        description: 执行市价总额
+        type: number
+      exeavgprice:
+        description: 执行市场均价= 执行市价总额 / 执行现货量
+        type: number
+      execontractamount:
+        description: 执行定价总额
+        type: number
+      exeqty:
+        description: 执行现货量
+        type: number
+      exerestamount:
+        description: 执行剩余市价总额【现货贸易】
+        type: number
+      futurefloatpl:
+        description: 期货浮动损益
+        type: number
+      futurehedgepl:
+        description: 期货实际损益
+        type: number
+      futurehedgeplchange:
+        description: 期货实际损益变动
+        type: number
+      futurepl:
+        description: 期货套期损益
+        type: number
+      futureplchange:
+        description: 期货套期损益变动
+        type: number
+      hedgeamount:
+        description: 套期市价总额
+        type: number
+      hedgecontractamount:
+        description: 套期定价总额 【定价采购合同】【现货贸易】
+        type: number
+      hedgeditemid:
+        description: 被套期项目ID(624+Unix秒时间戳(10位)+xxxxxx)
+        type: string
+      hedgeditemname:
+        description: 项目名称
+        type: string
+      hedgeditemnum:
+        description: 项目编号
+        type: string
+      hedgeditemstatus:
+        description: 项目状态 - 0:未提交 1:待审核 2:执行中 3:正常完结 4:审核拒绝 5:异常完结 6:已撤回
+        type: integer
+      hedgedtype:
+        description: 套期类型 - 1:采购计划项目 2:销售计划项目 3:现货贸易项目 4:库存存货项目 5:定价采购合同项目
+        type: integer
+      hedgeqty:
+        description: 套期现货量
+        type: number
+      hedgerate:
+        description: 套保比率
+        type: number
+      hedgerestamount:
+        description: 套期剩余市价总额【现货贸易】
+        type: number
+      hedgesumpl:
+        description: 套期汇总损益 = 期货汇总损益 + 现货汇总损益
+        type: number
+      middlegoodslist:
+        description: 套期商品列表
+        items:
+          $ref: '#/definitions/models.Ermcp2himiddlegoods'
+        type: array
+      oriavgprice:
+        description: 期初市场均价 = 套期市价总额 / 套期现货量
+        type: number
+      orifuturehedgepl:
+        description: 期初期货实际损益
+        type: number
+      orifuturepl:
+        description: 期初期货套期损益
+        type: number
+      orispothedgepl:
+        description: 期初现货实际损益
+        type: number
+      orispotpl:
+        description: 期初现货套期损益
+        type: number
+      planenddate:
+        description: 计划结束日期
+        type: string
+      planstartdate:
+        description: 计划开始日期
+        type: string
+      remark:
+        description: 备注
+        type: string
+      spotbookamount:
+        description: 现货账面总额
+        type: number
+      spotfloatpl:
+        description: 现货浮动损益 =(当前市场价 - 期初市场价)*未执行现货量 * 方向(销售计划 为 -1, 其它为1)
+        type: number
+      spothedgepl:
+        description: 现货套期损益 =(执行市场均价-期初市场均价)*执行现货量 * 方向(销售计划 为 -1, 其它为1)
+        type: number
+      spothedgeplchange:
+        description: 现货实际损益变动
+        type: number
+      spotpl:
+        description: 现货套期损益 = 现货实际损益 + 现货浮动损益
+        type: number
+      spotplchange:
+        description: 现货套期损益变动
+        type: number
+      spottradepl:
+        description: 现货贸易损益【现货贸易】= 执行合同定价总额 - 套期合同定价总额
+        type: number
+      sumobspl:
+        description: 汇总绝对损益【现货贸易】=现货贸易损益+增值税损益+期货套期损益
+        type: number
+      tradeuserid:
+        description: 交易用户ID
+        type: integer
+      unexeqty:
+        description: 未执行现货量 = 套期现货量 - 执行现货量
+        type: number
+      updatetime:
+        description: 更新时间
+        type: string
+      vatpl:
+        description: 增值税损益【现货贸易】= 现货贸易损益 * (增值税率 /(1+增值税率))
+        type: number
+      vatrate:
+        description: 增值税
+        type: number
+      wrstandardid:
+        description: 现货商品ID
+        type: integer
+      wrstandardname:
+        description: 商品名称
+        type: string
+    type: object
+  models.Ermcp2himiddlegoods:
+    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
+    required:
+    - hedgeditemid
+    - middlegoodsid
+    type: object
   models.Ermcp3AreaSpot:
     properties:
       areauserid:
@@ -23503,6 +23718,41 @@ paths:
       summary: 查询期货子账户
       tags:
       - 企业风险管理v3(app)
+  /Ermcp8/QueryErmcp2HedgedItem:
+    get:
+      description: '已完成项目查询: 项目状态 = 3:正常完结 or 5:异常完结'
+      parameters:
+      - description: 用户ID
+        in: query
+        name: userid
+        required: true
+        type: string
+      - description: 套期类型 1:采购计划项目 2:销售计划项目 3:现货贸易项目 4:库存存货项目 5:定价采购合同项目
+        in: query
+        name: HedgedType
+        type: integer
+      - description: 项目状态 0:未提交 1:待审核 2:执行中 3:正常完结 4:审核拒绝 5:异常完结 6:已撤回
+        in: query
+        name: HedgedItemStatus
+        type: integer
+      produces:
+      - application/json
+      responses:
+        "200":
+          description: OK
+          schema:
+            items:
+              $ref: '#/definitions/models.Ermcp2hedgeditem'
+            type: array
+        "500":
+          description: Internal Server Error
+          schema:
+            $ref: '#/definitions/app.Response'
+      security:
+      - ApiKeyAuth: []
+      summary: 查询被套期项目信息
+      tags:
+      - 企业风险管理v8
   /Erms2/QueryArbitrageStrategy:
     get:
       parameters:

+ 251 - 0
models/ermcp8.go

@@ -0,0 +1,251 @@
+package models
+
+import (
+	"mtp2_if/db"
+	"mtp2_if/utils"
+	"time"
+)
+
+// Ermcp2hedgeditem 被套期项目表
+type Ermcp2hedgeditem struct {
+	Hedgeditemid        string    `json:"hedgeditemid"  xorm:"HEDGEDITEMID"`                                 // 被套期项目ID(624+Unix秒时间戳(10位)+xxxxxx)
+	Hedgeditemnum       string    `json:"hedgeditemnum"  xorm:"HEDGEDITEMNUM"`                               // 项目编号
+	Hedgeditemname      string    `json:"hedgeditemname"  xorm:"HEDGEDITEMNAME"`                             // 项目名称
+	Hedgedtype          int32     `json:"hedgedtype"  xorm:"HEDGEDTYPE" form:"hedgedtype"`                   // 套期类型 - 1:采购计划项目 2:销售计划项目 3:现货贸易项目 4:库存存货项目 5:定价采购合同项目
+	Planstartdate       time.Time `json:"planstartdate"  xorm:"PLANSTARTDATE"`                               // 计划开始日期
+	Planenddate         time.Time `json:"planenddate"  xorm:"PLANENDDATE"`                                   // 计划结束日期
+	Hedgerate           float64   `json:"hedgerate"  xorm:"HEDGERATE"`                                       // 套保比率
+	Tradeuserid         int64     `json:"tradeuserid"  xorm:"TRADEUSERID"`                                   // 交易用户ID
+	Areauserid          int64     `json:"areauserid"  xorm:"AREAUSERID"`                                     // 企业ID
+	Hedgeditemstatus    int32     `json:"hedgeditemstatus"  xorm:"HEDGEDITEMSTATUS" form:"hedgeditemstatus"` // 项目状态 - 0:未提交 1:待审核 2:执行中 3:正常完结 4:审核拒绝 5:异常完结 6:已撤回
+	Applysrc            int32     `json:"applysrc"  xorm:"APPLYSRC"`                                         // 申请来源 - 1:管理端 2:终端
+	Applyid             int64     `json:"applyid"  xorm:"APPLYID"`                                           // 申请人
+	Remark              string    `json:"remark"  xorm:"REMARK"`                                             // 备注
+	Createtime          time.Time `json:"createtime"  xorm:"CREATETIME"`                                     // 申请时间
+	Audittradedate      string    `json:"audittradedate"  xorm:"AUDITTRADEDATE"`                             // 审核交易日(yyyyMMdd)
+	Auditid             int64     `json:"auditid"  xorm:"AUDITID"`                                           // 审核人
+	Auditsrc            int32     `json:"auditsrc"  xorm:"AUDITSRC"`                                         // 审核来源 - 1:管理端 2:终端
+	Audittime           time.Time `json:"audittime"  xorm:"AUDITTIME"`                                       // 审核时间
+	Auditremark         string    `json:"auditremark"  xorm:"AUDITREMARK"`                                   // 审核备注
+	Deliverygoodsid     int64     `json:"deliverygoodsid"  xorm:"DELIVERYGOODSID"`                           // 现货品种ID
+	Wrstandardid        int64     `json:"wrstandardid"  xorm:"WRSTANDARDID"`                                 // 现货商品ID
+	Vatrate             float64   `json:"vatrate"  xorm:"VATRATE"`                                           // 增值税
+	Hedgeqty            float64   `json:"hedgeqty"  xorm:"HEDGEQTY"`                                         // 套期现货量
+	Hedgeamount         float64   `json:"hedgeamount"  xorm:"HEDGEAMOUNT"`                                   // 套期市价总额
+	Hedgerestamount     float64   `json:"hedgerestamount"  xorm:"HEDGERESTAMOUNT"`                           // 套期剩余市价总额【现货贸易】
+	Hedgecontractamount float64   `json:"hedgecontractamount"  xorm:"HEDGECONTRACTAMOUNT"`                   // 套期定价总额 【定价采购合同】【现货贸易】
+	Oriavgprice         float64   `json:"oriavgprice"  xorm:"ORIAVGPRICE"`                                   // 期初市场均价 = 套期市价总额 / 套期现货量
+	Exeqty              float64   `json:"exeqty"  xorm:"EXEQTY"`                                             // 执行现货量
+	Exeamount           float64   `json:"exeamount"  xorm:"EXEAMOUNT"`                                       // 执行市价总额
+	Exerestamount       float64   `json:"exerestamount"  xorm:"EXERESTAMOUNT"`                               // 执行剩余市价总额【现货贸易】
+	Exeavgprice         float64   `json:"exeavgprice"  xorm:"EXEAVGPRICE"`                                   // 执行市场均价= 执行市价总额 / 执行现货量
+	Execontractamount   float64   `json:"execontractamount"  xorm:"EXECONTRACTAMOUNT"`                       // 执行定价总额
+	Curprice            float64   `json:"curprice"  xorm:"CURPRICE"`                                         // 当前市场价
+	Unexeqty            float64   `json:"unexeqty"  xorm:"UNEXEQTY"`                                         // 未执行现货量 = 套期现货量 - 执行现货量
+	Spothedgepl         float64   `json:"spothedgepl"  xorm:"SPOTHEDGEPL"`                                   // 现货套期损益 =(执行市场均价-期初市场均价)*执行现货量 * 方向(销售计划 为 -1, 其它为1)
+	Spotpl              float64   `json:"spotpl"  xorm:"SPOTPL"`                                             // 现货套期损益 = 现货实际损益 + 现货浮动损益
+	Futurehedgepl       float64   `json:"futurehedgepl"  xorm:"FUTUREHEDGEPL"`                               // 期货实际损益
+	Futurepl            float64   `json:"futurepl"  xorm:"FUTUREPL"`                                         // 期货套期损益
+	Hedgesumpl          float64   `json:"hedgesumpl"  xorm:"HEDGESUMPL"`                                     // 套期汇总损益 = 期货汇总损益 + 现货汇总损益
+	Spottradepl         float64   `json:"spottradepl"  xorm:"SPOTTRADEPL"`                                   // 现货贸易损益【现货贸易】= 执行合同定价总额 - 套期合同定价总额
+	Vatpl               float64   `json:"vatpl"  xorm:"VATPL"`                                               // 增值税损益【现货贸易】= 现货贸易损益 * (增值税率 /(1+增值税率))
+	Sumobspl            float64   `json:"sumobspl"  xorm:"SUMOBSPL"`                                         // 汇总绝对损益【现货贸易】=现货贸易损益+增值税损益+期货套期损益
+	Spotbookamount      float64   `json:"spotbookamount"  xorm:"SPOTBOOKAMOUNT"`                             // 现货账面总额
+	Curstock            float64   `json:"curstock"  xorm:"CURSTOCK"`                                         // 期末库存量 = 采购总量 - 销售总量
+	Enddate             time.Time `json:"enddate"  xorm:"ENDDATE"`                                           // 完成日期
+	Endtradedate        string    `json:"endtradedate"  xorm:"ENDTRADEDATE"`                                 // 完成交易日
+	Updatetime          time.Time `json:"updatetime"  xorm:"UPDATETIME"`                                     // 更新时间
+	Orispothedgepl      float64   `json:"orispothedgepl"  xorm:"ORISPOTHEDGEPL"`                             // 期初现货实际损益
+	Orifuturehedgepl    float64   `json:"orifuturehedgepl"  xorm:"ORIFUTUREHEDGEPL"`                         // 期初期货实际损益
+	Orispotpl           float64   `json:"orispotpl"  xorm:"ORISPOTPL"`                                       // 期初现货套期损益
+	Orifuturepl         float64   `json:"orifuturepl"  xorm:"ORIFUTUREPL"`                                   // 期初期货套期损益
+	Spotfloatpl         float64   `json:"spotfloatpl"  xorm:"SPOTFLOATPL"`                                   // 现货浮动损益 =(当前市场价 - 期初市场价)*未执行现货量 * 方向(销售计划 为 -1, 其它为1)
+	Futurefloatpl       float64   `json:"futurefloatpl"  xorm:"FUTUREFLOATPL"`                               // 期货浮动损益
+
+	SpotHedgePLChange   float64 `json:"spothedgeplchange" xorm:"SPOTHEDGEPLCHANGE"`     // 现货实际损益变动
+	SpotPLChange        float64 `json:"spotplchange" xorm:"SPOTPLCHANGE"`               // 现货套期损益变动
+	FutureHedgePLChange float64 `json:"futurehedgeplchange" xorm:"FUTUREHEDGEPLCHANGE"` // 期货实际损益变动
+	FuturePLChange      float64 `json:"futureplchange" xorm:"FUTUREPLCHANGE"`           // 期货套期损益变动
+
+	Wrstandardname string `json:"wrstandardname" xorm:"'WRSTANDARDNAME'"` // 商品名称
+	EnumdicName    string `json:"enumdicname"  xorm:"'ENUMDICNAME'"`      // 单位
+	AccountName    string `json:"accountName" xorm:"ACCOUNTNAME"`         // 套期主体
+
+	MiddleGoodsList []Ermcp2himiddlegoods `json:"middlegoodslist"` // 套期商品列表
+
+	USERID int64 `json:"-" form:"userid" binding:"required"` // 用户id, 用于过滤
+}
+
+// TableName is ERMCP2_HEDGEDITEM
+func (r *Ermcp2hedgeditem) TableName() string {
+	return "ERMCP2_HEDGEDITEM"
+}
+
+func (r *Ermcp2hedgeditem) calc() {
+
+}
+
+func (r *Ermcp2hedgeditem) buildSql() string {
+	var sqlId utils.SQLVal = `
+		SELECT 
+			to_char(t.HEDGEDITEMID) HEDGEDITEMID,
+			t.HEDGEDITEMNUM      ,
+			t.HEDGEDITEMNAME     ,
+			t.HEDGEDTYPE         ,
+			t.PLANSTARTDATE      ,
+			t.PLANENDDATE        ,
+			t.HEDGERATE          ,
+			t.TRADEUSERID        ,
+			t.AREAUSERID         ,
+			t.HEDGEDITEMSTATUS   ,
+			t.APPLYSRC           ,
+			t.APPLYID            ,
+			t.REMARK             ,
+			t.CREATETIME         ,
+			t.AUDITTRADEDATE     ,
+			t.AUDITID            ,
+			t.AUDITSRC           ,
+			t.AUDITTIME          ,
+			t.AUDITREMARK        ,
+			t.DELIVERYGOODSID    ,
+			t.WRSTANDARDID       ,
+			t.VATRATE            ,
+			t.HEDGEQTY           ,
+			t.HEDGEAMOUNT        ,
+			t.HEDGERESTAMOUNT    ,
+			t.HEDGECONTRACTAMOUNT,
+			t.ORIAVGPRICE        ,
+			t.EXEQTY             ,
+			t.EXEAMOUNT          ,
+			t.EXERESTAMOUNT      ,
+			t.EXEAVGPRICE        ,
+			t.EXECONTRACTAMOUNT  ,
+			t.CURPRICE           ,
+			t.UNEXEQTY           ,
+			t.SPOTHEDGEPL        ,
+			t.SPOTPL             ,
+			t.FUTUREHEDGEPL      ,
+			t.FUTUREPL           ,
+			t.HEDGESUMPL         ,
+			t.SPOTTRADEPL        ,
+			t.VATPL              ,
+			t.SUMOBSPL           ,
+			t.SPOTBOOKAMOUNT     ,
+			t.CURSTOCK           ,
+			t.ENDDATE            ,
+			t.ENDTRADEDATE       ,
+			t.UPDATETIME         ,
+			t.ORISPOTHEDGEPL     ,
+			t.ORIFUTUREHEDGEPL   ,
+			t.ORISPOTPL          ,
+			t.ORIFUTUREPL        ,
+			t.SPOTFLOATPL        ,
+			t.FUTUREFLOATPL      ,
+			(t.SpotHedgePL - t.OriSpotHedgePL) SPOTHEDGEPLCHANGE,
+			(t.SpotPL - t.OriSpotPL) SPOTPLCHANGE,
+			(t.FutureHedgePL - t.OriFutureHedgePL) FUTUREHEDGEPLCHANGE,
+			(t.FuturePL - t.OriFuturePL) FUTUREPLCHANGE,
+			wr.WRSTANDARDNAME,
+			e.ENUMDICNAME,
+			u.ACCOUNTNAME
+		FROM ERMCP2_HedgedItem 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 useraccount u ON u.userid = t.tradeuserid
+		WHERE 1 = 1
+   			AND %v in (t.AreaUserID, t.TradeUserID)
+	`
+	sqlId.FormatParam(r.USERID)
+	sqlId.AndEx("t.Hedgedtype", r.Hedgedtype, r.Hedgedtype > 0)
+	sqlId.AndEx("t.hedgeditemstatus", r.Hedgeditemstatus, r.Hedgeditemstatus > 0)
+
+	return sqlId.String()
+}
+
+// GetDataEx 从数据库中查询数据
+func (r *Ermcp2hedgeditem) GetDataEx() (interface{}, error) {
+	e := db.GetEngine()
+	s := e.SQL(r.buildSql())
+	sData := make([]Ermcp2hedgeditem, 0)
+	if err := s.Find(&sData); err != nil {
+		return nil, err
+	}
+	for i := range sData {
+		sData[i].calc()
+	}
+
+	if len(sData) > 0 {
+		// 获取关联期货品种
+		m1 := Ermcp2himiddlegoods{}
+		if d1, err := m1.GetDataEx(); err == nil {
+			gpLst := d1.([]Ermcp2himiddlegoods)
+			for i := range sData {
+				sData[i].MiddleGoodsList = append(sData[i].MiddleGoodsList, gpLst...)
+			}
+		}
+	}
+
+	return sData, nil
+}
+
+// Ermcp2himiddlegoods 项目套保品种明细
+type Ermcp2himiddlegoods struct {
+	HEDGEDITEMID     int64     `json:"hedgeditemid"  xorm:"HEDGEDITEMID" binding:"required"`   // 被套期项目ID(624+Unix秒时间戳(10位)+xxxxxx)
+	MIDDLEGOODSID    int64     `json:"middlegoodsid"  xorm:"MIDDLEGOODSID" binding:"required"` // 套保品种ID
+	DELIVERYGOODSID  int64     `json:"-"  xorm:"DELIVERYGOODSID"`                              // 现货品种ID
+	WRSTANDARDID     int64     `json:"-"  xorm:"WRSTANDARDID"`                                 // 现货商品ID
+	VATRATE          float64   `json:"-"  xorm:"VATRATE"`                                      // 增值税
+	SPOTCONVERTRATIO float64   `json:"-"  xorm:"SPOTCONVERTRATIO"`                             // 折算系数 [现货]
+	UNEXESPOTQTY     float64   `json:"-"  xorm:"UNEXESPOTQTY"`                                 // 未执行现货量
+	UNEXEHEDGEQTY    float64   `json:"unexehedgeqty"  xorm:"UNEXEHEDGEQTY"`                    // 未执行套期量 = 未执行现货量*折算系数* (1/(1+增值税)) * 套期比例(项目上)
+	FUTUREHEDGEQTY   float64   `json:"futurehedgeqty"  xorm:"FUTUREHEDGEQTY"`                  // 期货持仓套期量
+	HIEXPSOURE       float64   `json:"hiexpsoure"  xorm:"HIEXPSOURE"`                          // 期现敞口量 = 未执行套期量 + 期货持仓套期量
+	TRADEUSERID      int64     `json:"-"  xorm:"TRADEUSERID"`                                  // 交易用户ID
+	AREAUSERID       int64     `json:"-"  xorm:"AREAUSERID"`                                   // 企业ID
+	CREATETIME       time.Time `json:"-"  xorm:"CREATETIME"`                                   // 创建时间
+	UPDATETIME       time.Time `json:"-"  xorm:"UPDATETIME"`                                   // 更新时间
+
+	Middlegoodsname string `json:"middlegoodsname"  xorm:"'MIDDLEGOODSNAME'"` // 套保商品名称
+	Middlegoodscode string `json:"middlegoodscode"  xorm:"'MIDDLEGOODSCODE'"` // 套保商品代码
+}
+
+// TableName is ERMCP2_HIMIDDLEGOODS
+func (r *Ermcp2himiddlegoods) TableName() string {
+	return "ERMCP2_HIMIDDLEGOODS"
+}
+
+func (r *Ermcp2himiddlegoods) calc() {
+
+}
+
+func (r *Ermcp2himiddlegoods) buildSql() string {
+	var sqlId utils.SQLVal = `
+		SELECT 
+			t.MIDDLEGOODSID,
+			t.UNEXEHEDGEQTY,
+			t.FUTUREHEDGEQTY,
+			t.HIEXPSOURE,
+			m.MIDDLEGOODSNAME,
+			m.MIDDLEGOODSCODE
+		FROM ERMCP2_HIMIDDLEGOODS t 
+		LEFT JOIN erms_middlegoods m ON m.middlegoodsid = t.middlegoodsid
+		WHERE t.HEDGEDITEMID = %v
+	`
+	sqlId.FormatParam(r.HEDGEDITEMID)
+
+	return sqlId.String()
+}
+
+// GetDataEx 从数据库中查询数据
+func (r *Ermcp2himiddlegoods) GetDataEx() (interface{}, error) {
+	e := db.GetEngine()
+	s := e.SQL(r.buildSql())
+	sData := make([]Ermcp2himiddlegoods, 0)
+	if err := s.Find(&sData); err != nil {
+		return nil, err
+	}
+	for i := range sData {
+		sData[i].calc()
+	}
+	return sData, nil
+}

+ 8 - 0
routers/router.go

@@ -8,6 +8,7 @@ import (
 	"mtp2_if/controllers/delivery"
 	"mtp2_if/controllers/ermcp"
 	"mtp2_if/controllers/ermcp3"
+	"mtp2_if/controllers/ermcp8"
 	"mtp2_if/controllers/erms2"
 	"mtp2_if/controllers/erms3"
 	"mtp2_if/controllers/hsby"
@@ -482,6 +483,13 @@ func InitRouter() *gin.Engine {
 		ermcp3R.GET("/QrySCMiddleGoodsReport", ermcp3.QrySCMiddleGoodsReport)
 	}
 
+	// ***************************** 企业风险管理v8 ***************************
+	ermcp8R := apiR.Group("Ermcp8")
+	ermcp8R.Use(token.Auth())
+	{
+		ermcp8R.GET("/QueryErmcp2HedgedItem", ermcp8.QueryErmcp2HedgedItem)
+	}
+
 	// ****************************大连千海金******************************
 	qhjR := apiR.Group("Qhj")
 	qhjR.Use(token.Auth())