Prechádzať zdrojové kódy

Merge branch 'master' of 192.168.30.132:MTP2.0/MTP20_IF

zhou.xiaoning 4 rokov pred
rodič
commit
45944f5aff

+ 52 - 0
controllers/ermcp/qryExposure.go

@@ -0,0 +1,52 @@
+/**
+* @Author: zou.yingbin
+* @Create  : 2021/1/18 9:26
+* @Modify  : 2021/1/18 9:26
+ */
+
+package ermcp
+
+import (
+	"github.com/gin-gonic/gin"
+	"mtp2_if/global/app"
+	"mtp2_if/global/e"
+	"mtp2_if/logger"
+	"mtp2_if/models"
+	"net/http"
+)
+
+//敞口相关查询
+
+//实时敞口查询请求
+type RealtimeExposureReq struct {
+	AreaUserID uint32 `form:"AreaUserID" binding:"required"` //所属机构ID
+}
+
+//实时敞口查询应答
+type RealtimeExposureRsp models.ErmcpRealExposureModel
+
+// QueryUserInfo 查询实时敞口
+// @Summary 查询实时敞口
+// @Produce json
+// @Security ApiKeyAuth
+// @Param AreaUserID query int true "所属机构ID"
+// @Success 200 {array} RealtimeExposureRsp
+// @Failure 500 {object} app.Response
+// @Router /Ermcp/QueryRealtimeExposure [get]
+// @Tags 企业风险管理(app)
+func QueryRealtimeExposure(c *gin.Context) {
+	appG := app.Gin{C: c}
+	var req RealtimeExposureReq
+	if err := c.ShouldBind(&req); err != nil{
+		logger.GetLogger().Errorf("QueryRealtimeExposure fail, %v", err)
+		appG.Response(http.StatusBadRequest, e.INVALID_PARAMS, nil)
+		return
+	}
+
+	m := models.ErmcpRealExposureModel{AreaUserID: req.AreaUserID}
+	if d, err := m.GetData(); err == nil{
+		appG.Response(http.StatusOK, e.SUCCESS, d)
+	}else{
+		appG.Response(http.StatusBadRequest, e.ERROR_QUERY_FAIL, nil)
+	}
+}

+ 6 - 6
controllers/ermcp/qryOPApply.go

@@ -53,7 +53,7 @@ type KpData struct {
 
 // 查询合同操作请求
 type QryOPApplyReq struct {
-	UserId    int64   `form:"userId" binding:"required"`   //用户ID
+	UserId    int64   `form:"UserId" binding:"required"`   //用户ID
 	RelatedId string `form:"relatedid" binding:"required"` //现货合同ID, 不填则查所有
 }
 
@@ -85,11 +85,11 @@ func QueryBusinessDj(c *gin.Context) {
 			var rsp QryBusinessDjRsp
 			rsp.ErmcpOPApplyModel = v
 			if len(rsp.DETAILJSON) > 0{
-				if err := json.Unmarshal([]byte(rsp.DETAILJSON), &rsp.DjData); err != nil{
+				if err := json.Unmarshal([]byte(rsp.DETAILJSON), &rsp.DjData); err == nil{
 					rsp.DjData.calc(rsp.PRICEMOVE)
 				}
+				sData = append(sData, rsp)
 			}
-			sData = append(sData, rsp)
 		}
 		appG.Response(http.StatusOK, e.SUCCESS, sData)
 	} else {
@@ -117,7 +117,7 @@ func QueryBusinessJs(c *gin.Context) {
 	appG := app.Gin{C: c}
 	var req QryOPApplyReq
 	_=c.ShouldBind(&req)
-	m := models.ErmcpOPApplyModel{RELATEDID: req.RelatedId}
+	m := models.ErmcpOPApplyModel{RELATEDID: req.RelatedId, USERID: req.UserId}
 	if d, err := m.GetData(2); err == nil {
 		//构建应答数据
 		sData := make([]QryBussinessJsRsp, 0)
@@ -155,7 +155,7 @@ func QueryBusinessKx(c *gin.Context) {
 	appG := app.Gin{C: c}
 	var req QryOPApplyReq
 	_=c.ShouldBind(&req)
-	m := models.ErmcpOPApplyModel{RELATEDID: req.RelatedId}
+	m := models.ErmcpOPApplyModel{RELATEDID: req.RelatedId, USERID: req.UserId}
 	if d, err := m.GetData(3); err == nil {
 		//构建应答数据
 		sData := make([]QryBussinessKxRsp, 0)
@@ -193,7 +193,7 @@ func QueryBusinessFp(c *gin.Context) {
 	appG := app.Gin{C: c}
 	var req QryOPApplyReq
 	_=c.ShouldBind(&req)
-	m := models.ErmcpOPApplyModel{RELATEDID: req.RelatedId}
+	m := models.ErmcpOPApplyModel{RELATEDID: req.RelatedId, USERID: req.UserId}
 	if d, err := m.GetData(4); err == nil {
 		//构建应答数据
 		sData := make([]QryBussinessFpRsp, 0)

+ 171 - 0
docs/docs.go

@@ -1055,6 +1055,48 @@ var doc = `{
                 }
             }
         },
+        "/Ermcp/QueryRealtimeExposure": {
+            "get": {
+                "security": [
+                    {
+                        "ApiKeyAuth": []
+                    }
+                ],
+                "produces": [
+                    "application/json"
+                ],
+                "tags": [
+                    "企业风险管理(app)"
+                ],
+                "summary": "查询实时敞口",
+                "parameters": [
+                    {
+                        "type": "integer",
+                        "description": "所属机构ID",
+                        "name": "AreaUserID",
+                        "in": "query",
+                        "required": true
+                    }
+                ],
+                "responses": {
+                    "200": {
+                        "description": "OK",
+                        "schema": {
+                            "type": "array",
+                            "items": {
+                                "$ref": "#/definitions/ermcp.RealtimeExposureRsp"
+                            }
+                        }
+                    },
+                    "500": {
+                        "description": "Internal Server Error",
+                        "schema": {
+                            "$ref": "#/definitions/app.Response"
+                        }
+                    }
+                }
+            }
+        },
         "/Ermcp/QuerySpotContract": {
             "get": {
                 "security": [
@@ -5947,6 +5989,10 @@ var doc = `{
                     "description": "合同状态- 0:未提交 1:待审核 2:执行中 3:正常完结 4:审核拒绝 5:异常完结 6:已撤回",
                     "type": "integer"
                 },
+                "contracttype": {
+                    "description": "合同类型 1-采购, -1-销售",
+                    "type": "number"
+                },
                 "convertfactor": {
                     "description": "标仓系数",
                     "type": "number"
@@ -5999,6 +6045,14 @@ var doc = `{
                     "description": "已收付额(收款或付款)",
                     "type": "number"
                 },
+                "pricedamount": {
+                    "description": "已定价额",
+                    "type": "number"
+                },
+                "pricedavg": {
+                    "description": "已点均价",
+                    "type": "number"
+                },
                 "pricedqty": {
                     "description": "已定价量",
                     "type": "number"
@@ -6019,6 +6073,10 @@ var doc = `{
                     "description": "合同量",
                     "type": "number"
                 },
+                "remark": {
+                    "description": "备注",
+                    "type": "string"
+                },
                 "spotcontractid": {
                     "description": "合同ID",
                     "type": "string"
@@ -6254,6 +6312,10 @@ var doc = `{
                     "description": "数量",
                     "type": "number"
                 },
+                "remark": {
+                    "description": "备注",
+                    "type": "string"
+                },
                 "selluserid": {
                     "description": "销售方ID",
                     "type": "integer"
@@ -6414,6 +6476,115 @@ var doc = `{
                 }
             }
         },
+        "ermcp.RealtimeExposureRsp": {
+            "type": "object",
+            "properties": {
+                "areaUserID": {
+                    "description": "所属机构",
+                    "type": "integer"
+                },
+                "buyFutureQty": {
+                    "description": "买入期货数量",
+                    "type": "number"
+                },
+                "buyPlanQty": {
+                    "description": "采购计划数量",
+                    "type": "number"
+                },
+                "buyPricedQty": {
+                    "description": "采购合同已定价数量",
+                    "type": "number"
+                },
+                "middleGoodsCode": {
+                    "description": "套保品种代码",
+                    "type": "string"
+                },
+                "middleGoodsHedgeRatio": {
+                    "description": "应套保比例",
+                    "type": "number"
+                },
+                "middleGoodsID": {
+                    "description": "套保品种",
+                    "type": "integer"
+                },
+                "middleGoodsName": {
+                    "description": "************以下需计算或非redis数据************//",
+                    "type": "string"
+                },
+                "needHedgeExposoure": {
+                    "description": "应套保敞口",
+                    "type": "number"
+                },
+                "needHedgeRatio": {
+                    "description": "应套保敞口比例",
+                    "type": "number"
+                },
+                "oriBuyFutureQty": {
+                    "description": "期初买入期货数量",
+                    "type": "integer"
+                },
+                "oriBuyPlanQty": {
+                    "description": "期初采购计划数量",
+                    "type": "number"
+                },
+                "oriBuyPricedQty": {
+                    "description": "期初采购合同已定价数量",
+                    "type": "number"
+                },
+                "oriSellFutureQty": {
+                    "description": "期初卖出期货数量",
+                    "type": "integer"
+                },
+                "oriSellPlanQty": {
+                    "description": "期初销售计划数量",
+                    "type": "number"
+                },
+                "oriSellPricedQty": {
+                    "description": "期初销售合同已定价数量",
+                    "type": "number"
+                },
+                "oriTotalFutuQty": {
+                    "description": "期初期货数量=期初买入期货数量-期初卖出期货数量",
+                    "type": "integer"
+                },
+                "oriTotalSpotQty": {
+                    "description": "期初现货数量=(期初销售计划数量-期初销售合同已定价数量)-(期初采购计划数量-期初采购合同已定价数量)",
+                    "type": "number"
+                },
+                "sellFutureQty": {
+                    "description": "卖出期货数量",
+                    "type": "number"
+                },
+                "sellPlanQty": {
+                    "description": "销售计划数量",
+                    "type": "number"
+                },
+                "sellPricedQty": {
+                    "description": "销售合同已定价数量",
+                    "type": "number"
+                },
+                "totalExposure": {
+                    "description": "总敞口",
+                    "type": "number"
+                },
+                "totalFutureQty": {
+                    "description": "期货数量",
+                    "type": "number"
+                },
+                "totalHedgeRatio": {
+                    "description": "敞口比例",
+                    "type": "number"
+                },
+                "totalNeedHedgeQty": {
+                    "description": "期货应套保量",
+                    "type": "number"
+                },
+                "totalSpotQty": {
+                    "description": "现货数量",
+                    "type": "number"
+                }
+            }
+        },
         "erms2.QueryArbitrageStrategyRsp": {
             "type": "object",
             "required": [

+ 171 - 0
docs/swagger.json

@@ -1039,6 +1039,48 @@
                 }
             }
         },
+        "/Ermcp/QueryRealtimeExposure": {
+            "get": {
+                "security": [
+                    {
+                        "ApiKeyAuth": []
+                    }
+                ],
+                "produces": [
+                    "application/json"
+                ],
+                "tags": [
+                    "企业风险管理(app)"
+                ],
+                "summary": "查询实时敞口",
+                "parameters": [
+                    {
+                        "type": "integer",
+                        "description": "所属机构ID",
+                        "name": "AreaUserID",
+                        "in": "query",
+                        "required": true
+                    }
+                ],
+                "responses": {
+                    "200": {
+                        "description": "OK",
+                        "schema": {
+                            "type": "array",
+                            "items": {
+                                "$ref": "#/definitions/ermcp.RealtimeExposureRsp"
+                            }
+                        }
+                    },
+                    "500": {
+                        "description": "Internal Server Error",
+                        "schema": {
+                            "$ref": "#/definitions/app.Response"
+                        }
+                    }
+                }
+            }
+        },
         "/Ermcp/QuerySpotContract": {
             "get": {
                 "security": [
@@ -5931,6 +5973,10 @@
                     "description": "合同状态- 0:未提交 1:待审核 2:执行中 3:正常完结 4:审核拒绝 5:异常完结 6:已撤回",
                     "type": "integer"
                 },
+                "contracttype": {
+                    "description": "合同类型 1-采购, -1-销售",
+                    "type": "number"
+                },
                 "convertfactor": {
                     "description": "标仓系数",
                     "type": "number"
@@ -5983,6 +6029,14 @@
                     "description": "已收付额(收款或付款)",
                     "type": "number"
                 },
+                "pricedamount": {
+                    "description": "已定价额",
+                    "type": "number"
+                },
+                "pricedavg": {
+                    "description": "已点均价",
+                    "type": "number"
+                },
                 "pricedqty": {
                     "description": "已定价量",
                     "type": "number"
@@ -6003,6 +6057,10 @@
                     "description": "合同量",
                     "type": "number"
                 },
+                "remark": {
+                    "description": "备注",
+                    "type": "string"
+                },
                 "spotcontractid": {
                     "description": "合同ID",
                     "type": "string"
@@ -6238,6 +6296,10 @@
                     "description": "数量",
                     "type": "number"
                 },
+                "remark": {
+                    "description": "备注",
+                    "type": "string"
+                },
                 "selluserid": {
                     "description": "销售方ID",
                     "type": "integer"
@@ -6398,6 +6460,115 @@
                 }
             }
         },
+        "ermcp.RealtimeExposureRsp": {
+            "type": "object",
+            "properties": {
+                "areaUserID": {
+                    "description": "所属机构",
+                    "type": "integer"
+                },
+                "buyFutureQty": {
+                    "description": "买入期货数量",
+                    "type": "number"
+                },
+                "buyPlanQty": {
+                    "description": "采购计划数量",
+                    "type": "number"
+                },
+                "buyPricedQty": {
+                    "description": "采购合同已定价数量",
+                    "type": "number"
+                },
+                "middleGoodsCode": {
+                    "description": "套保品种代码",
+                    "type": "string"
+                },
+                "middleGoodsHedgeRatio": {
+                    "description": "应套保比例",
+                    "type": "number"
+                },
+                "middleGoodsID": {
+                    "description": "套保品种",
+                    "type": "integer"
+                },
+                "middleGoodsName": {
+                    "description": "************以下需计算或非redis数据************//",
+                    "type": "string"
+                },
+                "needHedgeExposoure": {
+                    "description": "应套保敞口",
+                    "type": "number"
+                },
+                "needHedgeRatio": {
+                    "description": "应套保敞口比例",
+                    "type": "number"
+                },
+                "oriBuyFutureQty": {
+                    "description": "期初买入期货数量",
+                    "type": "integer"
+                },
+                "oriBuyPlanQty": {
+                    "description": "期初采购计划数量",
+                    "type": "number"
+                },
+                "oriBuyPricedQty": {
+                    "description": "期初采购合同已定价数量",
+                    "type": "number"
+                },
+                "oriSellFutureQty": {
+                    "description": "期初卖出期货数量",
+                    "type": "integer"
+                },
+                "oriSellPlanQty": {
+                    "description": "期初销售计划数量",
+                    "type": "number"
+                },
+                "oriSellPricedQty": {
+                    "description": "期初销售合同已定价数量",
+                    "type": "number"
+                },
+                "oriTotalFutuQty": {
+                    "description": "期初期货数量=期初买入期货数量-期初卖出期货数量",
+                    "type": "integer"
+                },
+                "oriTotalSpotQty": {
+                    "description": "期初现货数量=(期初销售计划数量-期初销售合同已定价数量)-(期初采购计划数量-期初采购合同已定价数量)",
+                    "type": "number"
+                },
+                "sellFutureQty": {
+                    "description": "卖出期货数量",
+                    "type": "number"
+                },
+                "sellPlanQty": {
+                    "description": "销售计划数量",
+                    "type": "number"
+                },
+                "sellPricedQty": {
+                    "description": "销售合同已定价数量",
+                    "type": "number"
+                },
+                "totalExposure": {
+                    "description": "总敞口",
+                    "type": "number"
+                },
+                "totalFutureQty": {
+                    "description": "期货数量",
+                    "type": "number"
+                },
+                "totalHedgeRatio": {
+                    "description": "敞口比例",
+                    "type": "number"
+                },
+                "totalNeedHedgeQty": {
+                    "description": "期货应套保量",
+                    "type": "number"
+                },
+                "totalSpotQty": {
+                    "description": "现货数量",
+                    "type": "number"
+                }
+            }
+        },
         "erms2.QueryArbitrageStrategyRsp": {
             "type": "object",
             "required": [

+ 122 - 0
docs/swagger.yaml

@@ -1127,6 +1127,9 @@ definitions:
       contracctstatus:
         description: 合同状态- 0:未提交 1:待审核 2:执行中 3:正常完结 4:审核拒绝 5:异常完结 6:已撤回
         type: integer
+      contracttype:
+        description: 合同类型 1-采购, -1-销售
+        type: number
       convertfactor:
         description: 标仓系数
         type: number
@@ -1166,6 +1169,12 @@ definitions:
       payamount:
         description: 已收付额(收款或付款)
         type: number
+      pricedamount:
+        description: 已定价额
+        type: number
+      pricedavg:
+        description: 已点均价
+        type: number
       pricedqty:
         description: 已定价量
         type: number
@@ -1181,6 +1190,9 @@ definitions:
       qty:
         description: 合同量
         type: number
+      remark:
+        description: 备注
+        type: string
       spotcontractid:
         description: 合同ID
         type: string
@@ -1355,6 +1367,9 @@ definitions:
       qty:
         description: 数量
         type: number
+      remark:
+        description: 备注
+        type: string
       selluserid:
         description: 销售方ID
         type: integer
@@ -1473,6 +1488,87 @@ definitions:
         description: 现货商品名称
         type: string
     type: object
+  ermcp.RealtimeExposureRsp:
+    properties:
+      areaUserID:
+        description: 所属机构
+        type: integer
+      buyFutureQty:
+        description: 买入期货数量
+        type: number
+      buyPlanQty:
+        description: 采购计划数量
+        type: number
+      buyPricedQty:
+        description: 采购合同已定价数量
+        type: number
+      middleGoodsCode:
+        description: 套保品种代码
+        type: string
+      middleGoodsHedgeRatio:
+        description: 应套保比例
+        type: number
+      middleGoodsID:
+        description: 套保品种
+        type: integer
+      middleGoodsName:
+        description: '************以下需计算或非redis数据************//'
+        type: string
+      needHedgeExposoure:
+        description: 应套保敞口
+        type: number
+      needHedgeRatio:
+        description: 应套保敞口比例
+        type: number
+      oriBuyFutureQty:
+        description: 期初买入期货数量
+        type: integer
+      oriBuyPlanQty:
+        description: 期初采购计划数量
+        type: number
+      oriBuyPricedQty:
+        description: 期初采购合同已定价数量
+        type: number
+      oriSellFutureQty:
+        description: 期初卖出期货数量
+        type: integer
+      oriSellPlanQty:
+        description: 期初销售计划数量
+        type: number
+      oriSellPricedQty:
+        description: 期初销售合同已定价数量
+        type: number
+      oriTotalFutuQty:
+        description: 期初期货数量=期初买入期货数量-期初卖出期货数量
+        type: integer
+      oriTotalSpotQty:
+        description: 期初现货数量=(期初销售计划数量-期初销售合同已定价数量)-(期初采购计划数量-期初采购合同已定价数量)
+        type: number
+      sellFutureQty:
+        description: 卖出期货数量
+        type: number
+      sellPlanQty:
+        description: 销售计划数量
+        type: number
+      sellPricedQty:
+        description: 销售合同已定价数量
+        type: number
+      totalExposure:
+        description: 总敞口
+        type: number
+      totalFutureQty:
+        description: 期货数量
+        type: number
+      totalHedgeRatio:
+        description: 敞口比例
+        type: number
+      totalNeedHedgeQty:
+        description: 期货应套保量
+        type: number
+      totalSpotQty:
+        description: 现货数量
+        type: number
+    type: object
   erms2.QueryArbitrageStrategyRsp:
     properties:
       applybasis:
@@ -6860,6 +6956,32 @@ paths:
       summary: 查询套保计划
       tags:
       - 企业风险管理(app)
+  /Ermcp/QueryRealtimeExposure:
+    get:
+      parameters:
+      - description: 所属机构ID
+        in: query
+        name: AreaUserID
+        required: true
+        type: integer
+      produces:
+      - application/json
+      responses:
+        "200":
+          description: OK
+          schema:
+            items:
+              $ref: '#/definitions/ermcp.RealtimeExposureRsp'
+            type: array
+        "500":
+          description: Internal Server Error
+          schema:
+            $ref: '#/definitions/app.Response'
+      security:
+      - ApiKeyAuth: []
+      summary: 查询实时敞口
+      tags:
+      - 企业风险管理(app)
   /Ermcp/QuerySpotContract:
     get:
       parameters:

+ 19 - 9
models/ermcp.go

@@ -43,6 +43,7 @@ type ErmcpSpotContractModel struct {
 	MARGIN            float64 `json:"margin"  xorm:"'MARGIN'"`                       //当前保证金
 	EnumdicName       string  `json:"enumdicname"  xorm:"'ENUMDICNAME'"`             //单位名称
 	CONTRACCTSTATUS   int32   `json:"contracctstatus"  xorm:"'CONTRACTSTATUS'"`      //合同状态 - 0:未提交 1:待审核 2:执行中 3:正常完结 4:审核拒绝 5:异常完结 6:已撤回
+	Remark            string  `json:"remark"  xorm:"'Remark'"`                       //备注
 }
 
 func (r *ErmcpSpotContractModel) buildSql(nQueryType int32) string {
@@ -60,13 +61,14 @@ func (r *ErmcpSpotContractModel) buildSql(nQueryType int32) string {
 		"       t.QTY," +
 		"       t.PRICE," +
 		"       t.AMOUNT," +
-		"       t.DELIVERYSTARTDATE," +
-		"       t.DELIVERYENDDATE," +
+		"       to_char(t.DELIVERYSTARTDATE, 'yyyy-mm-dd hh:mi:ss') DELIVERYSTARTDATE," +
+		"       to_char(t.DELIVERYENDDATE,'yyyy-mm-dd hh:mi:ss') DELIVERYENDDATE," +
 		"       t.GOODSID," +
 		"       t.PRICEMOVE," +
-		"       t.STARTDATE," +
-		"       t.ENDDATE," +
+		"       to_char(t.STARTDATE, 'yyyy-mm-dd hh:mi:ss') STARTDATE," +
+		"       to_char(t.ENDDATE,'yyyy-mm-dd hh:mi:ss') ENDDATE," +
 		"       t.MARGIN," +
+		"       t.remark," +
 		"       t.contractstatus," +
 		"       u1.accountname      BuyUserName," +
 		"       u2.accountname      SellUserName," +
@@ -145,6 +147,10 @@ type ErmcpModel struct {
 	Contracctstatus   uint    `json:"contracctstatus"  xorm:"'CONTRACTSTATUS'"`      // 合同状态- 0:未提交 1:待审核 2:执行中 3:正常完结 4:审核拒绝 5:异常完结 6:已撤回
 	PriceType         int     `json:"pricetype"  xorm:"'PRICETYPE'"`                 // 定价类型 - 1:一口价 2:点价 3:暂定价
 	ProductType       int     `json:"producttype"  xorm:"'PRODUCTTYPE'"`             // 产品类型 - 1:标准仓单 2:等标 3:非标
+	Contracttype      float64 `json:"contracttype"  xorm:"'CONTRACTTYPE'"`           // 合同类型 1-采购, -1-销售
+	Pricedamount      float64 `json:"pricedamount"  xorm:"'PRICEDAMOUNT'"`           // 已定价额
+	PricedAvg         float64 `json:"pricedavg"  xorm:"'PRICEDAVG'"`                 // 已点均价
+	Remark            string  `json:"remark"  xorm:"'Remark'"`                       //备注
 }
 
 // 组装查询的sql
@@ -170,21 +176,25 @@ func (r *ErmcpModel) buildSql(nContractType, nQueryType int32) string {
 		"       t.invoiceamount," +
 		"       (t.pricedamount + t.RECKONADJUSTAMOUNT + t.RECKONOTHERAMOUNT -" +
 		"       t.invoiceamount) as daikaiAmount," +
-		"       to_char(t.startdate, 'mmdd') startdate," +
-		"       to_char(t.enddate, 'mmdd') enddate," +
-		"       to_char(t.deliverystartdate, 'mmdd') deliverystartdate," +
-		"       to_char(t.deliveryenddate, 'mmdd') deliveryenddate," +
+		"       to_char(t.startdate, 'yyyy-mm-dd hh:mi:ss') startdate," +
+		"       to_char(t.enddate, 'yyyy-mm-dd hh:mi:ss') enddate," +
+		"       to_char(t.deliverystartdate, 'yyyy-mm-dd hh:mi:ss') deliverystartdate," +
+		"       to_char(t.deliveryenddate, 'yyyy-mm-dd hh:mi:ss') deliveryenddate," +
 		"       t.convertfactor," +
 		"       t.contractstatus," +
 		"       t.pricetype," +
 		"       t.producttype," +
 		"       t.contracttype," +
+		"       t.remark," +
 		"       to_char(ta.accountid) accountid," +
 		"       ta.accountname," +
 		"       g.deliverygoodscode," +
 		"       g.deliverygoodsname," +
 		"       g2.goodscode," +
-		"       e.enumdicname" +
+		"       e.enumdicname," +
+		"       t.contracttype," +
+		"       t.pricedamount," +
+		"       case when t.pricedqty > 0 then t.pricedamount/t.pricedqty else 0 end pricedAvg" +
 		"  from ermcp_spotcontract t" +
 		"  left join taaccount ta" +
 		"    on t.%v = ta.userid" +

+ 104 - 0
models/ermcpExposure.go

@@ -0,0 +1,104 @@
+/**
+* @Author: zou.yingbin
+* @Create  : 2021/1/18 9:26
+* @Modify  : 2021/1/18 9:26
+ */
+
+package models
+
+import (
+	"fmt"
+	"github.com/golang/protobuf/proto"
+	"mtp2_if/mtpcache"
+	"mtp2_if/pb"
+	"mtp2_if/rediscli"
+)
+
+//实时敞口
+type ErmcpRealExposureModel struct {
+	MiddleGoodsID      uint32  // 套保品种
+	AreaUserID         uint32  // 所属机构
+	OriBuyPlanQty      float64 // 期初采购计划数量
+	OriBuyPricedQty    float64 // 期初采购合同已定价数量
+	OriSellPlanQty     float64 // 期初销售计划数量
+	OriSellPricedQty   float64 // 期初销售合同已定价数量
+	OriBuyFutureQty    uint64  // 期初买入期货数量
+	OriSellFutureQty   uint64  // 期初卖出期货数量
+	BuyPlanQty         float64 // 采购计划数量
+	BuyPricedQty       float64 // 采购合同已定价数量
+	SellPlanQty        float64 // 销售计划数量
+	SellPricedQty      float64 // 销售合同已定价数量
+	BuyFutureQty       float64 // 买入期货数量
+	SellFutureQty      float64 // 卖出期货数量
+	TotalSpotQty       float64 // 现货数量
+	TotalFutureQty     float64 // 期货数量
+	TotalExposure      float64 // 总敞口
+	TotalHedgeRatio    float64 // 敞口比例
+	TotalNeedHedgeQty  float64 // 期货应套保量
+	NeedHedgeExposoure float64 // 应套保敞口
+	NeedHedgeRatio     float64 // 应套保敞口比例
+	//************以下需计算或非redis数据************//
+	MiddleGoodsName       string  // 套保品种名称
+	MiddleGoodsCode       string  // 套保品种代码
+	MiddleGoodsHedgeRatio float64 // 应套保比例
+	OriTotalSpotQty       float64 // 期初现货数量=(期初销售计划数量-期初销售合同已定价数量)-(期初采购计划数量-期初采购合同已定价数量)
+	OriTotalFutuQty       uint64  // 期初期货数量=期初买入期货数量-期初卖出期货数量
+}
+
+// 计算相关字段
+func (r *ErmcpRealExposureModel) calc() {
+	r.OriTotalSpotQty = (r.OriSellPlanQty - r.OriSellPricedQty) - (r.OriBuyPlanQty - r.OriBuyPricedQty)
+	r.OriTotalFutuQty = r.OriBuyFutureQty - r.OriSellFutureQty
+}
+
+func (r *ErmcpRealExposureModel) ParseFromProto(v *pb.ErmcpAreaExposure) {
+	r.MiddleGoodsID = *v.MiddleGoodsID
+	r.AreaUserID = *v.AreaUserID
+	r.OriBuyPlanQty = *v.OriBuyPlanQty
+	r.OriBuyPricedQty = *v.OriBuyPricedQty
+	r.OriSellPlanQty = *v.OriSellPlanQty
+	r.OriSellPricedQty = *v.OriSellPricedQty
+	r.OriBuyFutureQty = *v.OriBuyFutureQty
+	r.OriSellFutureQty = *v.OriSellFutureQty
+	r.BuyPlanQty = *v.BuyPlanQty
+	r.BuyPricedQty = *v.BuyPricedQty
+	r.SellPlanQty = *v.SellPlanQty
+	r.SellPricedQty = *v.SellPricedQty
+	r.BuyFutureQty = *v.BuyFutureQty
+	r.SellFutureQty = *v.SellFutureQty
+	r.TotalSpotQty = *v.TotalSpotQty
+	r.TotalFutureQty = *v.TotalFutureQty
+	r.TotalExposure = *v.TotalExposure
+	r.TotalHedgeRatio = *v.TotalHedgeRatio
+	r.TotalNeedHedgeQty = *v.TotalNeedHedgeQty
+	r.NeedHedgeExposoure = *v.NeedHedgeExposoure
+	r.NeedHedgeRatio = *v.NeedHedgeRatio
+	// 执行相关计算
+	r.calc()
+}
+
+// 实时敞口数据: Redis数据 + 套保品种信息表
+func (r *ErmcpRealExposureModel) GetData() ([]ErmcpRealExposureModel, error) {
+	// 获取关联的套路商品
+	if sGoods, err := mtpcache.GetMiddleGoodsByUserID(r.AreaUserID); err == nil {
+		sData := make([]ErmcpRealExposureModel, 0)
+		// 从Redis获取数据
+		for i := range sGoods {
+			key := fmt.Sprintf("ErmcpAreaExposure:%d_%d", sGoods[i].AREAUSERID, sGoods[i].MIDDLEGOODSID)
+			if ret, err := rediscli.GetRedisClient().Get(key).Result(); err == nil {
+				if len(ret) > 0 {
+					var data pb.ErmcpAreaExposure
+					if err := proto.Unmarshal([]byte(ret), &data); err == nil {
+						var m ErmcpRealExposureModel
+						m.ParseFromProto(&data)
+						sData = append(sData, m)
+					}
+				}
+			}
+		}
+
+		return sData, nil
+	}
+
+	return nil, nil
+}

+ 15 - 11
models/ermcpOPApply.go

@@ -42,18 +42,20 @@ func (r *ErmcpOPApplyModel) buildSql(opType int32) string {
 		"       to_char(t.RELATEDID) RELATEDID," +
 		"       t.DETAILJSON," +
 		"       to_char(t.APPLYID) APPLYID," +
-		"       to_char(t.APPLYTIME,'yyyy-mm-dd hh:mi:ss') APPLYTIME," +
+		"       to_char(t.APPLYTIME, 'yyyy-mm-dd hh:mi:ss') APPLYTIME," +
 		"       t.APPLYSTATUS," +
-		"       to_char(t.AUDITTIME,'yyyy-mm-dd hh:mi:ss') AUDITTIME," +
+		"       to_char(t.auditid) auditid," +
+		"       to_char(t.AUDITTIME, 'yyyy-mm-dd hh:mi:ss') AUDITTIME," +
 		"       t.CONTRACTTYPE," +
 		"       s.CONTRACTNO," +
 		"       s.PRICETYPE," +
 		"       s.pricemove," +
+		"       s.userid," +
 		"       g.GOODSNAME," +
 		"       g.GOODSCODE," +
 		"       e.EnumdicName," +
-		"       m.username APPLYName," +
-		"       m2.username auditName," +
+		"       u3.accountname APPLYName," +
+		"       u4.accountname auditName," +
 		"       u1.accountname buyuserName," +
 		"       u2.accountname selluserName" +
 		"  from ermcp_contractoperateapply t" +
@@ -61,16 +63,18 @@ func (r *ErmcpOPApplyModel) buildSql(opType int32) string {
 		"    on t.relatedid = s.spotcontractid" +
 		"  left join goods g" +
 		"    on s.goodsid = g.goodsid" +
-		"  left join loginaccount l on t.applyid=l.loginid" +
-		"  left join systemmanager m on m.logincode=l.logincode" +
-		"  left join loginaccount l2 on t.auditid=l2.loginid" +
-		"  left join systemmanager m2 on m2.logincode=l2.logincode" +
-		"  left join useraccount u1 on s.buyuserid=u1.userid" +
-		"  left join useraccount u2 on s.selluserid=u2.userid" +
+		"  left join useraccount u3" +
+		"    on t.applyid = u3.userid" +
+		"  left join useraccount u4" +
+		"    on t.auditid = u4.userid" +
+		"  left join useraccount u1" +
+		"    on s.buyuserid = u1.userid" +
+		"  left join useraccount u2" +
+		"    on s.selluserid = u2.userid" +
 		"  left join enumdicitem e" +
 		"    on e.enumitemname = g.goodunitid" +
 		"   and e.enumdiccode = 'goodsunit'" +
-		"  where t.operateapplytype = %v and s.userid=%v"
+		" where t.operateapplytype = %v and s.userid = %v"
 
 	if len(r.RELATEDID) > 0{
 		sqlId = sqlId + " and t.relatedid=" + r.RELATEDID

+ 123 - 0
mtpcache/middlegoods.go

@@ -0,0 +1,123 @@
+/**
+* @Author: zou.yingbin
+* @Create  : 2021/1/18 15:25
+* @Modify  : 2021/1/18 15:25
+ */
+
+package mtpcache
+
+import (
+	"fmt"
+	"mtp2_if/db"
+	"mtp2_if/logger"
+	"sync"
+	"time"
+)
+
+var vGoodMgr middleGoodsMgr
+
+// 套保商品缓存
+type middleGoodsMgr struct {
+	mtx  sync.RWMutex
+	data map[uint32]MiddleGoods
+	last time.Time
+}
+
+// 套保品种
+type MiddleGoods struct {
+	MIDDLEGOODSID    uint32  `json:"MIDDLEGOODSID"  xorm:"'MIDDLEGOODSID'"`       // 套保品种ID(SEQ_ERMS_MIDDLEGOODS)
+	MIDDLEGOODSNAME  string  `json:"MIDDLEGOODSNAME"  xorm:"'MIDDLEGOODSNAME'"`   // 套保品种名称
+	MIDDLEGOODSCODE  string  `json:"MIDDLEGOODSCODE"  xorm:"'MIDDLEGOODSCODE'"`   // 套保品种代码
+	GOODSUNITID      int32   `json:"GOODSUNITID"  xorm:"'GOODSUNITID'"`           // 单位ID
+	RELATEDGOODSID   int32   `json:"RELATEDGOODSID"  xorm:"'RELATEDGOODSID'"`     // 关联交易商品ID
+	EVALUATERATIO    float64 `json:"EVALUATERATIO"  xorm:"'EVALUATERATIO'"`       // 估价系数
+	QTYDECIMALPLACE  int32   `json:"QTYDECIMALPLACE"  xorm:"'QTYDECIMALPLACE'"`   // 数量小数位
+	RELATEDGOODSTYPE int32   `json:"RELATEDGOODSTYPE"  xorm:"'RELATEDGOODSTYPE'"` // 关联商品类型 - 1:期货合约 2:现货品种
+	NEEDHEDGERATIO   float64 `json:"NEEDHEDGERATIO"  xorm:"'NEEDHEDGERATIO'"`     // 套保比率
+	AREAUSERID       uint32  `json:"AREAUSERID"  xorm:"'AREAUSERID'"`             // 机构用户ID
+	GOODSGROUPID     int32   `json:"GOODSGROUPID"  xorm:"'GOODSGROUPID'"`         // 关联期货品种ID
+}
+
+// 加载数据
+func (r *middleGoodsMgr) load() {
+	now := time.Now()
+	// 间隔3秒以上重新加载
+	if d := now.Sub(r.last); d.Seconds() < 3 {
+		return
+	}
+
+	r.mtx.Lock()
+	defer r.mtx.Unlock()
+	e := db.GetEngine()
+	if e == nil {
+		return
+	}
+
+	sqlId := "select MIDDLEGOODSID," +
+		"       MIDDLEGOODSNAME," +
+		"       MIDDLEGOODSCODE," +
+		"       GOODSUNITID," +
+		"       RELATEDGOODSID," +
+		"       EVALUATERATIO," +
+		"       QTYDECIMALPLACE," +
+		"       RELATEDGOODSTYPE," +
+		"       NEEDHEDGERATIO," +
+		"       AREAUSERID," +
+		"       GOODSGROUPID" +
+		"  from erms_middlegoods t"
+	sData := make([]MiddleGoods, 0)
+	s := e.SQL(sqlId)
+	if err := s.Find(&sData); err == nil {
+		r.data = make(map[uint32]MiddleGoods)
+		for i := range sData {
+			r.data[sData[i].MIDDLEGOODSID] = sData[i]
+		}
+		r.last = time.Now()
+	} else {
+		logger.GetLogger().Errorf("load middlegoods fail, %v", err)
+	}
+}
+
+func (r *middleGoodsMgr) get(middleGoodsId uint32) (MiddleGoods, error) {
+	r.mtx.RLock()
+	defer r.mtx.RUnlock()
+	if r.data == nil {
+		return MiddleGoods{}, fmt.Errorf("not found")
+	}
+
+	if v, ok := r.data[middleGoodsId]; ok {
+		return v, nil
+	}
+
+	return MiddleGoods{}, fmt.Errorf("not found")
+}
+
+func (r *middleGoodsMgr) getByUserID(userId uint32) ([]MiddleGoods, error) {
+	r.mtx.RLock()
+	defer r.mtx.RUnlock()
+	ret := make([]MiddleGoods, 0)
+	for _, v := range r.data {
+		if v.AREAUSERID == userId{
+			ret = append(ret, v)
+		}
+	}
+
+	return ret, nil
+}
+
+// 获取套保商品
+func GetMiddleGoods(middlGoodsId uint32) (MiddleGoods, error) {
+	if v, err := vGoodMgr.get(middlGoodsId); err != nil {
+		vGoodMgr.load()
+	} else {
+		return v, nil
+	}
+
+	return vGoodMgr.get(middlGoodsId)
+}
+
+// 获取指定用户套保商品
+func GetMiddleGoodsByUserID(userId uint32) ([]MiddleGoods, error) {
+	vGoodMgr.load()
+	return vGoodMgr.getByUserID(userId)
+}

+ 2 - 0
pb/generate_go.bat

@@ -0,0 +1,2 @@
+protoc.exe --proto_path=./ -I=./ --go_out=./  *.proto
+pause

+ 475 - 8
pb/mtp2.pb.go

@@ -554,6 +554,361 @@ func (x *Erms2ArbitrageStrategy) GetASName() string {
 	return ""
 }
 
+// ERMCP_AREASPOT 企业现货表
+type ErmcpAreaSpot struct {
+	state         protoimpl.MessageState
+	sizeCache     protoimpl.SizeCache
+	unknownFields protoimpl.UnknownFields
+
+	//mkey: 1 2
+	WrStandardID     *uint32  `protobuf:"varint,1,opt,name=WrStandardID" json:"WrStandardID,omitempty"`          // 现货商品ID
+	AreaUserID       *uint32  `protobuf:"varint,2,opt,name=AreaUserID" json:"AreaUserID,omitempty"`              // 所属机构
+	OriBuyPlanQty    *float64 `protobuf:"fixed64,3,opt,name=OriBuyPlanQty" json:"OriBuyPlanQty,omitempty"`       // 期初采购计划数量
+	OriBuyPricedQty  *float64 `protobuf:"fixed64,4,opt,name=OriBuyPricedQty" json:"OriBuyPricedQty,omitempty"`   // 期初采购合同已定价数量
+	OriSellPlanQty   *float64 `protobuf:"fixed64,5,opt,name=OriSellPlanQty" json:"OriSellPlanQty,omitempty"`     // 期初销售计划数量
+	OriSellPricedQty *float64 `protobuf:"fixed64,6,opt,name=OriSellPricedQty" json:"OriSellPricedQty,omitempty"` // 期初销售合同已定价数量
+	BuyPlanQty       *float64 `protobuf:"fixed64,7,opt,name=BuyPlanQty" json:"BuyPlanQty,omitempty"`             // 采购计划数量
+	BuyPricedQty     *float64 `protobuf:"fixed64,8,opt,name=BuyPricedQty" json:"BuyPricedQty,omitempty"`         // 采购合同已定价数量
+	SellPlanQty      *float64 `protobuf:"fixed64,9,opt,name=SellPlanQty" json:"SellPlanQty,omitempty"`           // 销售计划数量
+	SellPricedQty    *float64 `protobuf:"fixed64,10,opt,name=SellPricedQty" json:"SellPricedQty,omitempty"`      // 销售合同已定价数量
+	TotalSpotQty     *float64 `protobuf:"fixed64,11,opt,name=TotalSpotQty" json:"TotalSpotQty,omitempty"`        // 现货头寸总量 =  (销售计划数量 - 销售已定价数量)  - (采购计划数量 - 采购已定价数量)
+	UpdateTime       *Date    `protobuf:"bytes,12,opt,name=UpdateTime" json:"UpdateTime,omitempty"`              // 更新时间
+}
+
+func (x *ErmcpAreaSpot) Reset() {
+	*x = ErmcpAreaSpot{}
+	if protoimpl.UnsafeEnabled {
+		mi := &file_mtp2_proto_msgTypes[4]
+		ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
+		ms.StoreMessageInfo(mi)
+	}
+}
+
+func (x *ErmcpAreaSpot) String() string {
+	return protoimpl.X.MessageStringOf(x)
+}
+
+func (*ErmcpAreaSpot) ProtoMessage() {}
+
+func (x *ErmcpAreaSpot) ProtoReflect() protoreflect.Message {
+	mi := &file_mtp2_proto_msgTypes[4]
+	if protoimpl.UnsafeEnabled && x != nil {
+		ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
+		if ms.LoadMessageInfo() == nil {
+			ms.StoreMessageInfo(mi)
+		}
+		return ms
+	}
+	return mi.MessageOf(x)
+}
+
+// Deprecated: Use ErmcpAreaSpot.ProtoReflect.Descriptor instead.
+func (*ErmcpAreaSpot) Descriptor() ([]byte, []int) {
+	return file_mtp2_proto_rawDescGZIP(), []int{4}
+}
+
+func (x *ErmcpAreaSpot) GetWrStandardID() uint32 {
+	if x != nil && x.WrStandardID != nil {
+		return *x.WrStandardID
+	}
+	return 0
+}
+
+func (x *ErmcpAreaSpot) GetAreaUserID() uint32 {
+	if x != nil && x.AreaUserID != nil {
+		return *x.AreaUserID
+	}
+	return 0
+}
+
+func (x *ErmcpAreaSpot) GetOriBuyPlanQty() float64 {
+	if x != nil && x.OriBuyPlanQty != nil {
+		return *x.OriBuyPlanQty
+	}
+	return 0
+}
+
+func (x *ErmcpAreaSpot) GetOriBuyPricedQty() float64 {
+	if x != nil && x.OriBuyPricedQty != nil {
+		return *x.OriBuyPricedQty
+	}
+	return 0
+}
+
+func (x *ErmcpAreaSpot) GetOriSellPlanQty() float64 {
+	if x != nil && x.OriSellPlanQty != nil {
+		return *x.OriSellPlanQty
+	}
+	return 0
+}
+
+func (x *ErmcpAreaSpot) GetOriSellPricedQty() float64 {
+	if x != nil && x.OriSellPricedQty != nil {
+		return *x.OriSellPricedQty
+	}
+	return 0
+}
+
+func (x *ErmcpAreaSpot) GetBuyPlanQty() float64 {
+	if x != nil && x.BuyPlanQty != nil {
+		return *x.BuyPlanQty
+	}
+	return 0
+}
+
+func (x *ErmcpAreaSpot) GetBuyPricedQty() float64 {
+	if x != nil && x.BuyPricedQty != nil {
+		return *x.BuyPricedQty
+	}
+	return 0
+}
+
+func (x *ErmcpAreaSpot) GetSellPlanQty() float64 {
+	if x != nil && x.SellPlanQty != nil {
+		return *x.SellPlanQty
+	}
+	return 0
+}
+
+func (x *ErmcpAreaSpot) GetSellPricedQty() float64 {
+	if x != nil && x.SellPricedQty != nil {
+		return *x.SellPricedQty
+	}
+	return 0
+}
+
+func (x *ErmcpAreaSpot) GetTotalSpotQty() float64 {
+	if x != nil && x.TotalSpotQty != nil {
+		return *x.TotalSpotQty
+	}
+	return 0
+}
+
+func (x *ErmcpAreaSpot) GetUpdateTime() *Date {
+	if x != nil {
+		return x.UpdateTime
+	}
+	return nil
+}
+
+// ERMCP_AREAEXPOSURE 企业敞口表
+type ErmcpAreaExposure struct {
+	state         protoimpl.MessageState
+	sizeCache     protoimpl.SizeCache
+	unknownFields protoimpl.UnknownFields
+
+	//mkey: 1 2
+	//nkey: 1
+	MiddleGoodsID      *uint32  `protobuf:"varint,1,opt,name=MiddleGoodsID" json:"MiddleGoodsID,omitempty"`             // 套保品种
+	AreaUserID         *uint32  `protobuf:"varint,2,opt,name=AreaUserID" json:"AreaUserID,omitempty"`                   // 所属机构
+	OriBuyPlanQty      *float64 `protobuf:"fixed64,3,opt,name=OriBuyPlanQty" json:"OriBuyPlanQty,omitempty"`            // 期初采购计划数量
+	OriBuyPricedQty    *float64 `protobuf:"fixed64,4,opt,name=OriBuyPricedQty" json:"OriBuyPricedQty,omitempty"`        // 期初采购合同已定价数量
+	OriSellPlanQty     *float64 `protobuf:"fixed64,5,opt,name=OriSellPlanQty" json:"OriSellPlanQty,omitempty"`          // 期初销售计划数量
+	OriSellPricedQty   *float64 `protobuf:"fixed64,6,opt,name=OriSellPricedQty" json:"OriSellPricedQty,omitempty"`      // 期初销售合同已定价数量
+	OriBuyFutureQty    *uint64  `protobuf:"varint,7,opt,name=OriBuyFutureQty" json:"OriBuyFutureQty,omitempty"`         // 期初买入期货数量
+	OriSellFutureQty   *uint64  `protobuf:"varint,8,opt,name=OriSellFutureQty" json:"OriSellFutureQty,omitempty"`       // 期初卖出期货数量
+	BuyPlanQty         *float64 `protobuf:"fixed64,9,opt,name=BuyPlanQty" json:"BuyPlanQty,omitempty"`                  // 采购计划数量
+	BuyPricedQty       *float64 `protobuf:"fixed64,10,opt,name=BuyPricedQty" json:"BuyPricedQty,omitempty"`             // 采购合同已定价数量
+	SellPlanQty        *float64 `protobuf:"fixed64,11,opt,name=SellPlanQty" json:"SellPlanQty,omitempty"`               // 销售计划数量
+	SellPricedQty      *float64 `protobuf:"fixed64,12,opt,name=SellPricedQty" json:"SellPricedQty,omitempty"`           // 销售合同已定价数量
+	BuyFutureQty       *float64 `protobuf:"fixed64,13,opt,name=BuyFutureQty" json:"BuyFutureQty,omitempty"`             // 买入期货数量
+	SellFutureQty      *float64 `protobuf:"fixed64,14,opt,name=SellFutureQty" json:"SellFutureQty,omitempty"`           // 卖出期货数量
+	TotalSpotQty       *float64 `protobuf:"fixed64,15,opt,name=TotalSpotQty" json:"TotalSpotQty,omitempty"`             // 现货头寸总量
+	TotalFutureQty     *float64 `protobuf:"fixed64,16,opt,name=TotalFutureQty" json:"TotalFutureQty,omitempty"`         // 期货头寸总量
+	TotalExposure      *float64 `protobuf:"fixed64,17,opt,name=TotalExposure" json:"TotalExposure,omitempty"`           // 实时总敞口
+	TotalHedgeRatio    *float64 `protobuf:"fixed64,18,opt,name=TotalHedgeRatio" json:"TotalHedgeRatio,omitempty"`       // 总套保比率
+	TotalNeedHedgeQty  *float64 `protobuf:"fixed64,19,opt,name=TotalNeedHedgeQty" json:"TotalNeedHedgeQty,omitempty"`   // 应套保总量
+	NeedHedgeExposoure *float64 `protobuf:"fixed64,20,opt,name=NeedHedgeExposoure" json:"NeedHedgeExposoure,omitempty"` // 应套保敞口
+	NeedHedgeRatio     *float64 `protobuf:"fixed64,21,opt,name=NeedHedgeRatio" json:"NeedHedgeRatio,omitempty"`         // 应套保比率
+	UpdateTime         *Date    `protobuf:"bytes,22,opt,name=UpdateTime" json:"UpdateTime,omitempty"`                   // 更新时间
+}
+
+func (x *ErmcpAreaExposure) Reset() {
+	*x = ErmcpAreaExposure{}
+	if protoimpl.UnsafeEnabled {
+		mi := &file_mtp2_proto_msgTypes[5]
+		ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
+		ms.StoreMessageInfo(mi)
+	}
+}
+
+func (x *ErmcpAreaExposure) String() string {
+	return protoimpl.X.MessageStringOf(x)
+}
+
+func (*ErmcpAreaExposure) ProtoMessage() {}
+
+func (x *ErmcpAreaExposure) ProtoReflect() protoreflect.Message {
+	mi := &file_mtp2_proto_msgTypes[5]
+	if protoimpl.UnsafeEnabled && x != nil {
+		ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
+		if ms.LoadMessageInfo() == nil {
+			ms.StoreMessageInfo(mi)
+		}
+		return ms
+	}
+	return mi.MessageOf(x)
+}
+
+// Deprecated: Use ErmcpAreaExposure.ProtoReflect.Descriptor instead.
+func (*ErmcpAreaExposure) Descriptor() ([]byte, []int) {
+	return file_mtp2_proto_rawDescGZIP(), []int{5}
+}
+
+func (x *ErmcpAreaExposure) GetMiddleGoodsID() uint32 {
+	if x != nil && x.MiddleGoodsID != nil {
+		return *x.MiddleGoodsID
+	}
+	return 0
+}
+
+func (x *ErmcpAreaExposure) GetAreaUserID() uint32 {
+	if x != nil && x.AreaUserID != nil {
+		return *x.AreaUserID
+	}
+	return 0
+}
+
+func (x *ErmcpAreaExposure) GetOriBuyPlanQty() float64 {
+	if x != nil && x.OriBuyPlanQty != nil {
+		return *x.OriBuyPlanQty
+	}
+	return 0
+}
+
+func (x *ErmcpAreaExposure) GetOriBuyPricedQty() float64 {
+	if x != nil && x.OriBuyPricedQty != nil {
+		return *x.OriBuyPricedQty
+	}
+	return 0
+}
+
+func (x *ErmcpAreaExposure) GetOriSellPlanQty() float64 {
+	if x != nil && x.OriSellPlanQty != nil {
+		return *x.OriSellPlanQty
+	}
+	return 0
+}
+
+func (x *ErmcpAreaExposure) GetOriSellPricedQty() float64 {
+	if x != nil && x.OriSellPricedQty != nil {
+		return *x.OriSellPricedQty
+	}
+	return 0
+}
+
+func (x *ErmcpAreaExposure) GetOriBuyFutureQty() uint64 {
+	if x != nil && x.OriBuyFutureQty != nil {
+		return *x.OriBuyFutureQty
+	}
+	return 0
+}
+
+func (x *ErmcpAreaExposure) GetOriSellFutureQty() uint64 {
+	if x != nil && x.OriSellFutureQty != nil {
+		return *x.OriSellFutureQty
+	}
+	return 0
+}
+
+func (x *ErmcpAreaExposure) GetBuyPlanQty() float64 {
+	if x != nil && x.BuyPlanQty != nil {
+		return *x.BuyPlanQty
+	}
+	return 0
+}
+
+func (x *ErmcpAreaExposure) GetBuyPricedQty() float64 {
+	if x != nil && x.BuyPricedQty != nil {
+		return *x.BuyPricedQty
+	}
+	return 0
+}
+
+func (x *ErmcpAreaExposure) GetSellPlanQty() float64 {
+	if x != nil && x.SellPlanQty != nil {
+		return *x.SellPlanQty
+	}
+	return 0
+}
+
+func (x *ErmcpAreaExposure) GetSellPricedQty() float64 {
+	if x != nil && x.SellPricedQty != nil {
+		return *x.SellPricedQty
+	}
+	return 0
+}
+
+func (x *ErmcpAreaExposure) GetBuyFutureQty() float64 {
+	if x != nil && x.BuyFutureQty != nil {
+		return *x.BuyFutureQty
+	}
+	return 0
+}
+
+func (x *ErmcpAreaExposure) GetSellFutureQty() float64 {
+	if x != nil && x.SellFutureQty != nil {
+		return *x.SellFutureQty
+	}
+	return 0
+}
+
+func (x *ErmcpAreaExposure) GetTotalSpotQty() float64 {
+	if x != nil && x.TotalSpotQty != nil {
+		return *x.TotalSpotQty
+	}
+	return 0
+}
+
+func (x *ErmcpAreaExposure) GetTotalFutureQty() float64 {
+	if x != nil && x.TotalFutureQty != nil {
+		return *x.TotalFutureQty
+	}
+	return 0
+}
+
+func (x *ErmcpAreaExposure) GetTotalExposure() float64 {
+	if x != nil && x.TotalExposure != nil {
+		return *x.TotalExposure
+	}
+	return 0
+}
+
+func (x *ErmcpAreaExposure) GetTotalHedgeRatio() float64 {
+	if x != nil && x.TotalHedgeRatio != nil {
+		return *x.TotalHedgeRatio
+	}
+	return 0
+}
+
+func (x *ErmcpAreaExposure) GetTotalNeedHedgeQty() float64 {
+	if x != nil && x.TotalNeedHedgeQty != nil {
+		return *x.TotalNeedHedgeQty
+	}
+	return 0
+}
+
+func (x *ErmcpAreaExposure) GetNeedHedgeExposoure() float64 {
+	if x != nil && x.NeedHedgeExposoure != nil {
+		return *x.NeedHedgeExposoure
+	}
+	return 0
+}
+
+func (x *ErmcpAreaExposure) GetNeedHedgeRatio() float64 {
+	if x != nil && x.NeedHedgeRatio != nil {
+		return *x.NeedHedgeRatio
+	}
+	return 0
+}
+
+func (x *ErmcpAreaExposure) GetUpdateTime() *Date {
+	if x != nil {
+		return x.UpdateTime
+	}
+	return nil
+}
+
 var File_mtp2_proto protoreflect.FileDescriptor
 
 var file_mtp2_proto_rawDesc = []byte{
@@ -659,7 +1014,91 @@ var file_mtp2_proto_rawDesc = []byte{
 	0x20, 0x01, 0x28, 0x0b, 0x32, 0x08, 0x2e, 0x70, 0x62, 0x2e, 0x44, 0x61, 0x74, 0x65, 0x52, 0x0a,
 	0x55, 0x70, 0x44, 0x61, 0x74, 0x65, 0x74, 0x69, 0x6d, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x41, 0x53,
 	0x4e, 0x61, 0x6d, 0x65, 0x18, 0x28, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x41, 0x53, 0x4e, 0x61,
-	0x6d, 0x65,
+	0x6d, 0x65, 0x22, 0xd1, 0x03, 0x0a, 0x0d, 0x45, 0x72, 0x6d, 0x63, 0x70, 0x41, 0x72, 0x65, 0x61,
+	0x53, 0x70, 0x6f, 0x74, 0x12, 0x22, 0x0a, 0x0c, 0x57, 0x72, 0x53, 0x74, 0x61, 0x6e, 0x64, 0x61,
+	0x72, 0x64, 0x49, 0x44, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x0c, 0x57, 0x72, 0x53, 0x74,
+	0x61, 0x6e, 0x64, 0x61, 0x72, 0x64, 0x49, 0x44, 0x12, 0x1e, 0x0a, 0x0a, 0x41, 0x72, 0x65, 0x61,
+	0x55, 0x73, 0x65, 0x72, 0x49, 0x44, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x0a, 0x41, 0x72,
+	0x65, 0x61, 0x55, 0x73, 0x65, 0x72, 0x49, 0x44, 0x12, 0x24, 0x0a, 0x0d, 0x4f, 0x72, 0x69, 0x42,
+	0x75, 0x79, 0x50, 0x6c, 0x61, 0x6e, 0x51, 0x74, 0x79, 0x18, 0x03, 0x20, 0x01, 0x28, 0x01, 0x52,
+	0x0d, 0x4f, 0x72, 0x69, 0x42, 0x75, 0x79, 0x50, 0x6c, 0x61, 0x6e, 0x51, 0x74, 0x79, 0x12, 0x28,
+	0x0a, 0x0f, 0x4f, 0x72, 0x69, 0x42, 0x75, 0x79, 0x50, 0x72, 0x69, 0x63, 0x65, 0x64, 0x51, 0x74,
+	0x79, 0x18, 0x04, 0x20, 0x01, 0x28, 0x01, 0x52, 0x0f, 0x4f, 0x72, 0x69, 0x42, 0x75, 0x79, 0x50,
+	0x72, 0x69, 0x63, 0x65, 0x64, 0x51, 0x74, 0x79, 0x12, 0x26, 0x0a, 0x0e, 0x4f, 0x72, 0x69, 0x53,
+	0x65, 0x6c, 0x6c, 0x50, 0x6c, 0x61, 0x6e, 0x51, 0x74, 0x79, 0x18, 0x05, 0x20, 0x01, 0x28, 0x01,
+	0x52, 0x0e, 0x4f, 0x72, 0x69, 0x53, 0x65, 0x6c, 0x6c, 0x50, 0x6c, 0x61, 0x6e, 0x51, 0x74, 0x79,
+	0x12, 0x2a, 0x0a, 0x10, 0x4f, 0x72, 0x69, 0x53, 0x65, 0x6c, 0x6c, 0x50, 0x72, 0x69, 0x63, 0x65,
+	0x64, 0x51, 0x74, 0x79, 0x18, 0x06, 0x20, 0x01, 0x28, 0x01, 0x52, 0x10, 0x4f, 0x72, 0x69, 0x53,
+	0x65, 0x6c, 0x6c, 0x50, 0x72, 0x69, 0x63, 0x65, 0x64, 0x51, 0x74, 0x79, 0x12, 0x1e, 0x0a, 0x0a,
+	0x42, 0x75, 0x79, 0x50, 0x6c, 0x61, 0x6e, 0x51, 0x74, 0x79, 0x18, 0x07, 0x20, 0x01, 0x28, 0x01,
+	0x52, 0x0a, 0x42, 0x75, 0x79, 0x50, 0x6c, 0x61, 0x6e, 0x51, 0x74, 0x79, 0x12, 0x22, 0x0a, 0x0c,
+	0x42, 0x75, 0x79, 0x50, 0x72, 0x69, 0x63, 0x65, 0x64, 0x51, 0x74, 0x79, 0x18, 0x08, 0x20, 0x01,
+	0x28, 0x01, 0x52, 0x0c, 0x42, 0x75, 0x79, 0x50, 0x72, 0x69, 0x63, 0x65, 0x64, 0x51, 0x74, 0x79,
+	0x12, 0x20, 0x0a, 0x0b, 0x53, 0x65, 0x6c, 0x6c, 0x50, 0x6c, 0x61, 0x6e, 0x51, 0x74, 0x79, 0x18,
+	0x09, 0x20, 0x01, 0x28, 0x01, 0x52, 0x0b, 0x53, 0x65, 0x6c, 0x6c, 0x50, 0x6c, 0x61, 0x6e, 0x51,
+	0x74, 0x79, 0x12, 0x24, 0x0a, 0x0d, 0x53, 0x65, 0x6c, 0x6c, 0x50, 0x72, 0x69, 0x63, 0x65, 0x64,
+	0x51, 0x74, 0x79, 0x18, 0x0a, 0x20, 0x01, 0x28, 0x01, 0x52, 0x0d, 0x53, 0x65, 0x6c, 0x6c, 0x50,
+	0x72, 0x69, 0x63, 0x65, 0x64, 0x51, 0x74, 0x79, 0x12, 0x22, 0x0a, 0x0c, 0x54, 0x6f, 0x74, 0x61,
+	0x6c, 0x53, 0x70, 0x6f, 0x74, 0x51, 0x74, 0x79, 0x18, 0x0b, 0x20, 0x01, 0x28, 0x01, 0x52, 0x0c,
+	0x54, 0x6f, 0x74, 0x61, 0x6c, 0x53, 0x70, 0x6f, 0x74, 0x51, 0x74, 0x79, 0x12, 0x28, 0x0a, 0x0a,
+	0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x54, 0x69, 0x6d, 0x65, 0x18, 0x0c, 0x20, 0x01, 0x28, 0x0b,
+	0x32, 0x08, 0x2e, 0x70, 0x62, 0x2e, 0x44, 0x61, 0x74, 0x65, 0x52, 0x0a, 0x55, 0x70, 0x64, 0x61,
+	0x74, 0x65, 0x54, 0x69, 0x6d, 0x65, 0x22, 0xf5, 0x06, 0x0a, 0x11, 0x45, 0x72, 0x6d, 0x63, 0x70,
+	0x41, 0x72, 0x65, 0x61, 0x45, 0x78, 0x70, 0x6f, 0x73, 0x75, 0x72, 0x65, 0x12, 0x24, 0x0a, 0x0d,
+	0x4d, 0x69, 0x64, 0x64, 0x6c, 0x65, 0x47, 0x6f, 0x6f, 0x64, 0x73, 0x49, 0x44, 0x18, 0x01, 0x20,
+	0x01, 0x28, 0x0d, 0x52, 0x0d, 0x4d, 0x69, 0x64, 0x64, 0x6c, 0x65, 0x47, 0x6f, 0x6f, 0x64, 0x73,
+	0x49, 0x44, 0x12, 0x1e, 0x0a, 0x0a, 0x41, 0x72, 0x65, 0x61, 0x55, 0x73, 0x65, 0x72, 0x49, 0x44,
+	0x18, 0x02, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x0a, 0x41, 0x72, 0x65, 0x61, 0x55, 0x73, 0x65, 0x72,
+	0x49, 0x44, 0x12, 0x24, 0x0a, 0x0d, 0x4f, 0x72, 0x69, 0x42, 0x75, 0x79, 0x50, 0x6c, 0x61, 0x6e,
+	0x51, 0x74, 0x79, 0x18, 0x03, 0x20, 0x01, 0x28, 0x01, 0x52, 0x0d, 0x4f, 0x72, 0x69, 0x42, 0x75,
+	0x79, 0x50, 0x6c, 0x61, 0x6e, 0x51, 0x74, 0x79, 0x12, 0x28, 0x0a, 0x0f, 0x4f, 0x72, 0x69, 0x42,
+	0x75, 0x79, 0x50, 0x72, 0x69, 0x63, 0x65, 0x64, 0x51, 0x74, 0x79, 0x18, 0x04, 0x20, 0x01, 0x28,
+	0x01, 0x52, 0x0f, 0x4f, 0x72, 0x69, 0x42, 0x75, 0x79, 0x50, 0x72, 0x69, 0x63, 0x65, 0x64, 0x51,
+	0x74, 0x79, 0x12, 0x26, 0x0a, 0x0e, 0x4f, 0x72, 0x69, 0x53, 0x65, 0x6c, 0x6c, 0x50, 0x6c, 0x61,
+	0x6e, 0x51, 0x74, 0x79, 0x18, 0x05, 0x20, 0x01, 0x28, 0x01, 0x52, 0x0e, 0x4f, 0x72, 0x69, 0x53,
+	0x65, 0x6c, 0x6c, 0x50, 0x6c, 0x61, 0x6e, 0x51, 0x74, 0x79, 0x12, 0x2a, 0x0a, 0x10, 0x4f, 0x72,
+	0x69, 0x53, 0x65, 0x6c, 0x6c, 0x50, 0x72, 0x69, 0x63, 0x65, 0x64, 0x51, 0x74, 0x79, 0x18, 0x06,
+	0x20, 0x01, 0x28, 0x01, 0x52, 0x10, 0x4f, 0x72, 0x69, 0x53, 0x65, 0x6c, 0x6c, 0x50, 0x72, 0x69,
+	0x63, 0x65, 0x64, 0x51, 0x74, 0x79, 0x12, 0x28, 0x0a, 0x0f, 0x4f, 0x72, 0x69, 0x42, 0x75, 0x79,
+	0x46, 0x75, 0x74, 0x75, 0x72, 0x65, 0x51, 0x74, 0x79, 0x18, 0x07, 0x20, 0x01, 0x28, 0x04, 0x52,
+	0x0f, 0x4f, 0x72, 0x69, 0x42, 0x75, 0x79, 0x46, 0x75, 0x74, 0x75, 0x72, 0x65, 0x51, 0x74, 0x79,
+	0x12, 0x2a, 0x0a, 0x10, 0x4f, 0x72, 0x69, 0x53, 0x65, 0x6c, 0x6c, 0x46, 0x75, 0x74, 0x75, 0x72,
+	0x65, 0x51, 0x74, 0x79, 0x18, 0x08, 0x20, 0x01, 0x28, 0x04, 0x52, 0x10, 0x4f, 0x72, 0x69, 0x53,
+	0x65, 0x6c, 0x6c, 0x46, 0x75, 0x74, 0x75, 0x72, 0x65, 0x51, 0x74, 0x79, 0x12, 0x1e, 0x0a, 0x0a,
+	0x42, 0x75, 0x79, 0x50, 0x6c, 0x61, 0x6e, 0x51, 0x74, 0x79, 0x18, 0x09, 0x20, 0x01, 0x28, 0x01,
+	0x52, 0x0a, 0x42, 0x75, 0x79, 0x50, 0x6c, 0x61, 0x6e, 0x51, 0x74, 0x79, 0x12, 0x22, 0x0a, 0x0c,
+	0x42, 0x75, 0x79, 0x50, 0x72, 0x69, 0x63, 0x65, 0x64, 0x51, 0x74, 0x79, 0x18, 0x0a, 0x20, 0x01,
+	0x28, 0x01, 0x52, 0x0c, 0x42, 0x75, 0x79, 0x50, 0x72, 0x69, 0x63, 0x65, 0x64, 0x51, 0x74, 0x79,
+	0x12, 0x20, 0x0a, 0x0b, 0x53, 0x65, 0x6c, 0x6c, 0x50, 0x6c, 0x61, 0x6e, 0x51, 0x74, 0x79, 0x18,
+	0x0b, 0x20, 0x01, 0x28, 0x01, 0x52, 0x0b, 0x53, 0x65, 0x6c, 0x6c, 0x50, 0x6c, 0x61, 0x6e, 0x51,
+	0x74, 0x79, 0x12, 0x24, 0x0a, 0x0d, 0x53, 0x65, 0x6c, 0x6c, 0x50, 0x72, 0x69, 0x63, 0x65, 0x64,
+	0x51, 0x74, 0x79, 0x18, 0x0c, 0x20, 0x01, 0x28, 0x01, 0x52, 0x0d, 0x53, 0x65, 0x6c, 0x6c, 0x50,
+	0x72, 0x69, 0x63, 0x65, 0x64, 0x51, 0x74, 0x79, 0x12, 0x22, 0x0a, 0x0c, 0x42, 0x75, 0x79, 0x46,
+	0x75, 0x74, 0x75, 0x72, 0x65, 0x51, 0x74, 0x79, 0x18, 0x0d, 0x20, 0x01, 0x28, 0x01, 0x52, 0x0c,
+	0x42, 0x75, 0x79, 0x46, 0x75, 0x74, 0x75, 0x72, 0x65, 0x51, 0x74, 0x79, 0x12, 0x24, 0x0a, 0x0d,
+	0x53, 0x65, 0x6c, 0x6c, 0x46, 0x75, 0x74, 0x75, 0x72, 0x65, 0x51, 0x74, 0x79, 0x18, 0x0e, 0x20,
+	0x01, 0x28, 0x01, 0x52, 0x0d, 0x53, 0x65, 0x6c, 0x6c, 0x46, 0x75, 0x74, 0x75, 0x72, 0x65, 0x51,
+	0x74, 0x79, 0x12, 0x22, 0x0a, 0x0c, 0x54, 0x6f, 0x74, 0x61, 0x6c, 0x53, 0x70, 0x6f, 0x74, 0x51,
+	0x74, 0x79, 0x18, 0x0f, 0x20, 0x01, 0x28, 0x01, 0x52, 0x0c, 0x54, 0x6f, 0x74, 0x61, 0x6c, 0x53,
+	0x70, 0x6f, 0x74, 0x51, 0x74, 0x79, 0x12, 0x26, 0x0a, 0x0e, 0x54, 0x6f, 0x74, 0x61, 0x6c, 0x46,
+	0x75, 0x74, 0x75, 0x72, 0x65, 0x51, 0x74, 0x79, 0x18, 0x10, 0x20, 0x01, 0x28, 0x01, 0x52, 0x0e,
+	0x54, 0x6f, 0x74, 0x61, 0x6c, 0x46, 0x75, 0x74, 0x75, 0x72, 0x65, 0x51, 0x74, 0x79, 0x12, 0x24,
+	0x0a, 0x0d, 0x54, 0x6f, 0x74, 0x61, 0x6c, 0x45, 0x78, 0x70, 0x6f, 0x73, 0x75, 0x72, 0x65, 0x18,
+	0x11, 0x20, 0x01, 0x28, 0x01, 0x52, 0x0d, 0x54, 0x6f, 0x74, 0x61, 0x6c, 0x45, 0x78, 0x70, 0x6f,
+	0x73, 0x75, 0x72, 0x65, 0x12, 0x28, 0x0a, 0x0f, 0x54, 0x6f, 0x74, 0x61, 0x6c, 0x48, 0x65, 0x64,
+	0x67, 0x65, 0x52, 0x61, 0x74, 0x69, 0x6f, 0x18, 0x12, 0x20, 0x01, 0x28, 0x01, 0x52, 0x0f, 0x54,
+	0x6f, 0x74, 0x61, 0x6c, 0x48, 0x65, 0x64, 0x67, 0x65, 0x52, 0x61, 0x74, 0x69, 0x6f, 0x12, 0x2c,
+	0x0a, 0x11, 0x54, 0x6f, 0x74, 0x61, 0x6c, 0x4e, 0x65, 0x65, 0x64, 0x48, 0x65, 0x64, 0x67, 0x65,
+	0x51, 0x74, 0x79, 0x18, 0x13, 0x20, 0x01, 0x28, 0x01, 0x52, 0x11, 0x54, 0x6f, 0x74, 0x61, 0x6c,
+	0x4e, 0x65, 0x65, 0x64, 0x48, 0x65, 0x64, 0x67, 0x65, 0x51, 0x74, 0x79, 0x12, 0x2e, 0x0a, 0x12,
+	0x4e, 0x65, 0x65, 0x64, 0x48, 0x65, 0x64, 0x67, 0x65, 0x45, 0x78, 0x70, 0x6f, 0x73, 0x6f, 0x75,
+	0x72, 0x65, 0x18, 0x14, 0x20, 0x01, 0x28, 0x01, 0x52, 0x12, 0x4e, 0x65, 0x65, 0x64, 0x48, 0x65,
+	0x64, 0x67, 0x65, 0x45, 0x78, 0x70, 0x6f, 0x73, 0x6f, 0x75, 0x72, 0x65, 0x12, 0x26, 0x0a, 0x0e,
+	0x4e, 0x65, 0x65, 0x64, 0x48, 0x65, 0x64, 0x67, 0x65, 0x52, 0x61, 0x74, 0x69, 0x6f, 0x18, 0x15,
+	0x20, 0x01, 0x28, 0x01, 0x52, 0x0e, 0x4e, 0x65, 0x65, 0x64, 0x48, 0x65, 0x64, 0x67, 0x65, 0x52,
+	0x61, 0x74, 0x69, 0x6f, 0x12, 0x28, 0x0a, 0x0a, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x54, 0x69,
+	0x6d, 0x65, 0x18, 0x16, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x08, 0x2e, 0x70, 0x62, 0x2e, 0x44, 0x61,
+	0x74, 0x65, 0x52, 0x0a, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x54, 0x69, 0x6d, 0x65,
 }
 
 var (
@@ -674,21 +1113,25 @@ func file_mtp2_proto_rawDescGZIP() []byte {
 	return file_mtp2_proto_rawDescData
 }
 
-var file_mtp2_proto_msgTypes = make([]protoimpl.MessageInfo, 4)
+var file_mtp2_proto_msgTypes = make([]protoimpl.MessageInfo, 6)
 var file_mtp2_proto_goTypes = []interface{}{
 	(*TradeRule)(nil),              // 0: pb.TradeRule
 	(*TradeRuleInfoStruct)(nil),    // 1: pb.TradeRuleInfoStruct
 	(*Date)(nil),                   // 2: pb.Date
 	(*Erms2ArbitrageStrategy)(nil), // 3: pb.Erms2ArbitrageStrategy
+	(*ErmcpAreaSpot)(nil),          // 4: pb.ErmcpAreaSpot
+	(*ErmcpAreaExposure)(nil),      // 5: pb.ErmcpAreaExposure
 }
 var file_mtp2_proto_depIdxs = []int32{
 	0, // 0: pb.TradeRuleInfoStruct.TradeRules:type_name -> pb.TradeRule
 	2, // 1: pb.Erms2ArbitrageStrategy.UpDatetime:type_name -> pb.Date
-	2, // [2:2] is the sub-list for method output_type
-	2, // [2:2] is the sub-list for method input_type
-	2, // [2:2] is the sub-list for extension type_name
-	2, // [2:2] is the sub-list for extension extendee
-	0, // [0:2] is the sub-list for field type_name
+	2, // 2: pb.ErmcpAreaSpot.UpdateTime:type_name -> pb.Date
+	2, // 3: pb.ErmcpAreaExposure.UpdateTime:type_name -> pb.Date
+	4, // [4:4] is the sub-list for method output_type
+	4, // [4:4] is the sub-list for method input_type
+	4, // [4:4] is the sub-list for extension type_name
+	4, // [4:4] is the sub-list for extension extendee
+	0, // [0:4] is the sub-list for field type_name
 }
 
 func init() { file_mtp2_proto_init() }
@@ -745,6 +1188,30 @@ func file_mtp2_proto_init() {
 				return nil
 			}
 		}
+		file_mtp2_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} {
+			switch v := v.(*ErmcpAreaSpot); i {
+			case 0:
+				return &v.state
+			case 1:
+				return &v.sizeCache
+			case 2:
+				return &v.unknownFields
+			default:
+				return nil
+			}
+		}
+		file_mtp2_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} {
+			switch v := v.(*ErmcpAreaExposure); i {
+			case 0:
+				return &v.state
+			case 1:
+				return &v.sizeCache
+			case 2:
+				return &v.unknownFields
+			default:
+				return nil
+			}
+		}
 	}
 	type x struct{}
 	out := protoimpl.TypeBuilder{
@@ -752,7 +1219,7 @@ func file_mtp2_proto_init() {
 			GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
 			RawDescriptor: file_mtp2_proto_rawDesc,
 			NumEnums:      0,
-			NumMessages:   4,
+			NumMessages:   6,
 			NumExtensions: 0,
 			NumServices:   0,
 		},

+ 47 - 0
pb/mtp2.proto

@@ -65,3 +65,50 @@ message Erms2ArbitrageStrategy
   optional Date UpDatetime = 39;    // 更新时间
   optional string ASName = 40;    // 策略名称
 }
+
+// ERMCP_AREASPOT 企业现货表
+message ErmcpAreaSpot
+{
+  //mkey: 1 2
+  optional uint32 WrStandardID = 1;    // 现货商品ID
+  optional uint32 AreaUserID = 2;    // 所属机构
+  optional double OriBuyPlanQty = 3;    // 期初采购计划数量
+  optional double OriBuyPricedQty = 4;    // 期初采购合同已定价数量
+  optional double OriSellPlanQty = 5;    // 期初销售计划数量
+  optional double OriSellPricedQty = 6;    // 期初销售合同已定价数量
+  optional double BuyPlanQty = 7;    // 采购计划数量
+  optional double BuyPricedQty = 8;    // 采购合同已定价数量
+  optional double SellPlanQty = 9;    // 销售计划数量
+  optional double SellPricedQty = 10;    // 销售合同已定价数量
+  optional double TotalSpotQty = 11;    // 现货头寸总量 =  (销售计划数量 - 销售已定价数量)  - (采购计划数量 - 采购已定价数量)
+  optional Date UpdateTime = 12;    // 更新时间
+}
+
+// ERMCP_AREAEXPOSURE 企业敞口表
+message ErmcpAreaExposure
+{
+  //mkey: 1 2
+  //nkey: 1
+  optional uint32 MiddleGoodsID = 1;    // 套保品种
+  optional uint32 AreaUserID = 2;    // 所属机构
+  optional double OriBuyPlanQty = 3;    // 期初采购计划数量
+  optional double OriBuyPricedQty = 4;    // 期初采购合同已定价数量
+  optional double OriSellPlanQty = 5;    // 期初销售计划数量
+  optional double OriSellPricedQty = 6;    // 期初销售合同已定价数量
+  optional uint64 OriBuyFutureQty = 7;    // 期初买入期货数量
+  optional uint64 OriSellFutureQty = 8;    // 期初卖出期货数量
+  optional double BuyPlanQty = 9;    // 采购计划数量
+  optional double BuyPricedQty = 10;    // 采购合同已定价数量
+  optional double SellPlanQty = 11;    // 销售计划数量
+  optional double SellPricedQty = 12;    // 销售合同已定价数量
+  optional double BuyFutureQty = 13;    // 买入期货数量
+  optional double SellFutureQty = 14;    // 卖出期货数量
+  optional double TotalSpotQty = 15;    // 现货头寸总量
+  optional double TotalFutureQty = 16;    // 期货头寸总量
+  optional double TotalExposure = 17;    // 实时总敞口
+  optional double TotalHedgeRatio = 18;    // 总套保比率
+  optional double TotalNeedHedgeQty = 19;    // 应套保总量
+  optional double NeedHedgeExposoure = 20;    // 应套保敞口
+  optional double NeedHedgeRatio = 21;    // 应套保比率
+  optional Date UpdateTime = 22;    // 更新时间
+}

BIN
pb/protoc-gen-go.exe


BIN
pb/protoc.exe


+ 1 - 0
routers/router.go

@@ -312,6 +312,7 @@ func InitRouter() *gin.Engine {
 		ermcpR.GET("/QueryBusinessKx", ermcp.QueryBusinessKx)
 		ermcpR.GET("/QueryBusinessFp", ermcp.QueryBusinessFp)
 		ermcpR.GET("/QueryChangeLog", ermcp.QueryChangeLog)
+		ermcpR.GET("/QueryRealtimeExposure", ermcp.QueryRealtimeExposure)
 	}
 
 	return r