Просмотр исходного кода

增加“企业敞口查询”接口

zhou.xiaoning 3 лет назад
Родитель
Сommit
c9a09a0757
8 измененных файлов с 840 добавлено и 8 удалено
  1. 26 0
      controllers/ermcp8/qryErmcp8.go
  2. 143 0
      docs/docs.go
  3. 143 0
      docs/swagger.json
  4. 101 0
      docs/swagger.yaml
  5. 92 0
      models/ermcp8.go
  6. 305 8
      pb/mtp2.pb.go
  7. 29 0
      pb/mtp2.proto
  8. 1 0
      routers/router.go

+ 26 - 0
controllers/ermcp8/qryErmcp8.go

@@ -227,3 +227,29 @@ func QueryErmcp8RunningHedgeditem(c *gin.Context) {
 		appG.Response(http.StatusBadRequest, e.ERROR_QUERY_FAIL, nil)
 	}
 }
+
+// QueryErmcp2AreaExposure
+// @Summary 企业敞口查询
+// @Produce json
+// @Security ApiKeyAuth
+// @Param userid query string true "用户ID"
+// @Success 200 {array} models.Ermcp2AreaExposure
+// @Failure 500 {object} app.Response
+// @Router /Ermcp8/QueryErmcp2AreaExposure [get]
+// @Tags 企业风险管理v8
+func QueryErmcp2AreaExposure(c *gin.Context) {
+	appG := app.Gin{C: c}
+	var req models.Ermcp2AreaExposure
+	if err := c.ShouldBind(&req); err != nil {
+		logger.GetLogger().Errorf("parse query req: %v", err)
+		appG.Response(http.StatusBadRequest, e.INVALID_PARAMS, nil)
+		return
+	}
+
+	var m = models.Ermcp2AreaExposure{}
+	if d, err := m.GetDataEx(int(req.USERID)); err == nil {
+		appG.Response(http.StatusOK, e.SUCCESS, d)
+	} else {
+		appG.Response(http.StatusBadRequest, e.ERROR_QUERY_FAIL, nil)
+	}
+}

+ 143 - 0
docs/docs.go

@@ -5753,6 +5753,48 @@ var doc = `{
                 }
             }
         },
+        "/Ermcp8/QueryErmcp2AreaExposure": {
+            "get": {
+                "security": [
+                    {
+                        "ApiKeyAuth": []
+                    }
+                ],
+                "produces": [
+                    "application/json"
+                ],
+                "tags": [
+                    "企业风险管理v8"
+                ],
+                "summary": "企业敞口查询",
+                "parameters": [
+                    {
+                        "type": "string",
+                        "description": "用户ID",
+                        "name": "userid",
+                        "in": "query",
+                        "required": true
+                    }
+                ],
+                "responses": {
+                    "200": {
+                        "description": "OK",
+                        "schema": {
+                            "type": "array",
+                            "items": {
+                                "$ref": "#/definitions/models.Ermcp2AreaExposure"
+                            }
+                        }
+                    },
+                    "500": {
+                        "description": "Internal Server Error",
+                        "schema": {
+                            "$ref": "#/definitions/app.Response"
+                        }
+                    }
+                }
+            }
+        },
         "/Ermcp8/QueryErmcp2HedgedItem": {
             "get": {
                 "security": [
@@ -20717,6 +20759,107 @@ var doc = `{
                 }
             }
         },
+        "models.Ermcp2AreaExposure": {
+            "type": "object",
+            "properties": {
+                "areauserid": {
+                    "description": "所属机构",
+                    "type": "integer"
+                },
+                "enumdicname": {
+                    "description": "单位",
+                    "type": "string"
+                },
+                "futureqty": {
+                    "description": "期货套期量",
+                    "type": "number"
+                },
+                "goodsunitid": {
+                    "description": "单位ID",
+                    "type": "integer"
+                },
+                "hedgedspotexposure": {
+                    "description": "被套期现货敞口量",
+                    "type": "number"
+                },
+                "hedgedspratio": {
+                    "description": "套期期现比例 = 期货套期量/被套期现货敞口量",
+                    "type": "number"
+                },
+                "hedgedtotalexposure": {
+                    "description": "套期敞口量 = 被套期现货敞口量+期货套期量",
+                    "type": "number"
+                },
+                "hedgeplanqty": {
+                    "description": "套期计划量",
+                    "type": "number"
+                },
+                "hedgespotqty": {
+                    "description": "被套期现货量",
+                    "type": "number"
+                },
+                "middlegoodsid": {
+                    "description": "套保品种",
+                    "type": "integer"
+                },
+                "middlegoodsname": {
+                    "description": "套保品种名称",
+                    "type": "string"
+                },
+                "orifutureqty": {
+                    "description": "期初期货套期量",
+                    "type": "number"
+                },
+                "orihedgedspotexposure": {
+                    "description": "期初被套期现货敞口量",
+                    "type": "number"
+                },
+                "orihedgedtotalexposure": {
+                    "description": "期初套期敞口量",
+                    "type": "number"
+                },
+                "orihedgeplanqty": {
+                    "description": "期初套期计划量",
+                    "type": "number"
+                },
+                "orihedgespotqty": {
+                    "description": "期初被套期现货量",
+                    "type": "number"
+                },
+                "orispotexposure": {
+                    "description": "期初现货敞口量",
+                    "type": "number"
+                },
+                "orispotqty": {
+                    "description": "期初现货总量",
+                    "type": "number"
+                },
+                "oritotalexposure": {
+                    "description": "期初总敞口量",
+                    "type": "number"
+                },
+                "spotexposure": {
+                    "description": "现货敞口量",
+                    "type": "number"
+                },
+                "spotqty": {
+                    "description": "现货总量",
+                    "type": "number"
+                },
+                "spratio": {
+                    "description": "总期现比例 = 期货套期量/现货敞口量",
+                    "type": "number"
+                },
+                "totalexposure": {
+                    "description": "总敞口量 = 现货敞口量 + 期货套期量",
+                    "type": "number"
+                },
+                "updatetime": {
+                    "description": "更新时间  --DATE",
+                    "type": "string"
+                }
+            }
+        },
         "models.Ermcp2hedgeditem": {
             "type": "object",
             "properties": {

+ 143 - 0
docs/swagger.json

@@ -5737,6 +5737,48 @@
                 }
             }
         },
+        "/Ermcp8/QueryErmcp2AreaExposure": {
+            "get": {
+                "security": [
+                    {
+                        "ApiKeyAuth": []
+                    }
+                ],
+                "produces": [
+                    "application/json"
+                ],
+                "tags": [
+                    "企业风险管理v8"
+                ],
+                "summary": "企业敞口查询",
+                "parameters": [
+                    {
+                        "type": "string",
+                        "description": "用户ID",
+                        "name": "userid",
+                        "in": "query",
+                        "required": true
+                    }
+                ],
+                "responses": {
+                    "200": {
+                        "description": "OK",
+                        "schema": {
+                            "type": "array",
+                            "items": {
+                                "$ref": "#/definitions/models.Ermcp2AreaExposure"
+                            }
+                        }
+                    },
+                    "500": {
+                        "description": "Internal Server Error",
+                        "schema": {
+                            "$ref": "#/definitions/app.Response"
+                        }
+                    }
+                }
+            }
+        },
         "/Ermcp8/QueryErmcp2HedgedItem": {
             "get": {
                 "security": [
@@ -20701,6 +20743,107 @@
                 }
             }
         },
+        "models.Ermcp2AreaExposure": {
+            "type": "object",
+            "properties": {
+                "areauserid": {
+                    "description": "所属机构",
+                    "type": "integer"
+                },
+                "enumdicname": {
+                    "description": "单位",
+                    "type": "string"
+                },
+                "futureqty": {
+                    "description": "期货套期量",
+                    "type": "number"
+                },
+                "goodsunitid": {
+                    "description": "单位ID",
+                    "type": "integer"
+                },
+                "hedgedspotexposure": {
+                    "description": "被套期现货敞口量",
+                    "type": "number"
+                },
+                "hedgedspratio": {
+                    "description": "套期期现比例 = 期货套期量/被套期现货敞口量",
+                    "type": "number"
+                },
+                "hedgedtotalexposure": {
+                    "description": "套期敞口量 = 被套期现货敞口量+期货套期量",
+                    "type": "number"
+                },
+                "hedgeplanqty": {
+                    "description": "套期计划量",
+                    "type": "number"
+                },
+                "hedgespotqty": {
+                    "description": "被套期现货量",
+                    "type": "number"
+                },
+                "middlegoodsid": {
+                    "description": "套保品种",
+                    "type": "integer"
+                },
+                "middlegoodsname": {
+                    "description": "套保品种名称",
+                    "type": "string"
+                },
+                "orifutureqty": {
+                    "description": "期初期货套期量",
+                    "type": "number"
+                },
+                "orihedgedspotexposure": {
+                    "description": "期初被套期现货敞口量",
+                    "type": "number"
+                },
+                "orihedgedtotalexposure": {
+                    "description": "期初套期敞口量",
+                    "type": "number"
+                },
+                "orihedgeplanqty": {
+                    "description": "期初套期计划量",
+                    "type": "number"
+                },
+                "orihedgespotqty": {
+                    "description": "期初被套期现货量",
+                    "type": "number"
+                },
+                "orispotexposure": {
+                    "description": "期初现货敞口量",
+                    "type": "number"
+                },
+                "orispotqty": {
+                    "description": "期初现货总量",
+                    "type": "number"
+                },
+                "oritotalexposure": {
+                    "description": "期初总敞口量",
+                    "type": "number"
+                },
+                "spotexposure": {
+                    "description": "现货敞口量",
+                    "type": "number"
+                },
+                "spotqty": {
+                    "description": "现货总量",
+                    "type": "number"
+                },
+                "spratio": {
+                    "description": "总期现比例 = 期货套期量/现货敞口量",
+                    "type": "number"
+                },
+                "totalexposure": {
+                    "description": "总敞口量 = 现货敞口量 + 期货套期量",
+                    "type": "number"
+                },
+                "updatetime": {
+                    "description": "更新时间  --DATE",
+                    "type": "string"
+                }
+            }
+        },
         "models.Ermcp2hedgeditem": {
             "type": "object",
             "properties": {

+ 101 - 0
docs/swagger.yaml

@@ -3969,6 +3969,81 @@ definitions:
     - enumdicid
     - enumitemname
     type: object
+  models.Ermcp2AreaExposure:
+    properties:
+      areauserid:
+        description: 所属机构
+        type: integer
+      enumdicname:
+        description: 单位
+        type: string
+      futureqty:
+        description: 期货套期量
+        type: number
+      goodsunitid:
+        description: 单位ID
+        type: integer
+      hedgedspotexposure:
+        description: 被套期现货敞口量
+        type: number
+      hedgedspratio:
+        description: 套期期现比例 = 期货套期量/被套期现货敞口量
+        type: number
+      hedgedtotalexposure:
+        description: 套期敞口量 = 被套期现货敞口量+期货套期量
+        type: number
+      hedgeplanqty:
+        description: 套期计划量
+        type: number
+      hedgespotqty:
+        description: 被套期现货量
+        type: number
+      middlegoodsid:
+        description: 套保品种
+        type: integer
+      middlegoodsname:
+        description: 套保品种名称
+        type: string
+      orifutureqty:
+        description: 期初期货套期量
+        type: number
+      orihedgedspotexposure:
+        description: 期初被套期现货敞口量
+        type: number
+      orihedgedtotalexposure:
+        description: 期初套期敞口量
+        type: number
+      orihedgeplanqty:
+        description: 期初套期计划量
+        type: number
+      orihedgespotqty:
+        description: 期初被套期现货量
+        type: number
+      orispotexposure:
+        description: 期初现货敞口量
+        type: number
+      orispotqty:
+        description: 期初现货总量
+        type: number
+      oritotalexposure:
+        description: 期初总敞口量
+        type: number
+      spotexposure:
+        description: 现货敞口量
+        type: number
+      spotqty:
+        description: 现货总量
+        type: number
+      spratio:
+        description: 总期现比例 = 期货套期量/现货敞口量
+        type: number
+      totalexposure:
+        description: 总敞口量 = 现货敞口量 + 期货套期量
+        type: number
+      updatetime:
+        description: 更新时间  --DATE
+        type: string
+    type: object
   models.Ermcp2hedgeditem:
     properties:
       accountname:
@@ -24857,6 +24932,32 @@ paths:
       summary: 期货成交单明细查询
       tags:
       - 企业风险管理v8
+  /Ermcp8/QueryErmcp2AreaExposure:
+    get:
+      parameters:
+      - description: 用户ID
+        in: query
+        name: userid
+        required: true
+        type: string
+      produces:
+      - application/json
+      responses:
+        "200":
+          description: OK
+          schema:
+            items:
+              $ref: '#/definitions/models.Ermcp2AreaExposure'
+            type: array
+        "500":
+          description: Internal Server Error
+          schema:
+            $ref: '#/definitions/app.Response'
+      security:
+      - ApiKeyAuth: []
+      summary: 企业敞口查询
+      tags:
+      - 企业风险管理v8
   /Ermcp8/QueryErmcp2HedgedItem:
     get:
       description: 已完成项目查询 -> 项目状态 = 3:正常完结 or 5:异常完结

+ 92 - 0
models/ermcp8.go

@@ -1354,6 +1354,7 @@ func (r *Ermcp8EnableHedgeditem) GetDataEx() (interface{}, error) {
 	return sData, nil
 }
 
+// Ermcp8RunningHedgeditem 执行中项目
 type Ermcp8RunningHedgeditem struct {
 	Hedgeditemid        string  `json:"hedgeditemid"  xorm:"HEDGEDITEMID"`               // 被套期项目ID(624+Unix秒时间戳(10位)+xxxxxx)
 	Hedgeditemnum       string  `json:"hedgeditemnum"  xorm:"HEDGEDITEMNUM"`             // 项目编号
@@ -1541,3 +1542,94 @@ func (r *Ermcp8RunningHedgeditem) GetDataEx(userID int) (interface{}, error) {
 
 	return sData, nil
 }
+
+// Ermcp2AreaExposure 企业敞口表_New
+type Ermcp2AreaExposure struct {
+	MiddleGoodsID          int     `json:"middlegoodsid"`          // 套保品种
+	AreaUserID             int     `json:"areauserid"`             // 所属机构
+	SpotQty                float64 `json:"spotqty"`                // 现货总量
+	HedgeSpotQty           float64 `json:"hedgespotqty"`           // 被套期现货量
+	HedgePlanQty           float64 `json:"hedgeplanqty"`           // 套期计划量
+	FutureQty              float64 `json:"futureqty"`              // 期货套期量
+	SpotExposure           float64 `json:"spotexposure"`           // 现货敞口量
+	TotalExposure          float64 `json:"totalexposure"`          // 总敞口量 = 现货敞口量 + 期货套期量
+	SpRatio                float64 `json:"spratio"`                // 总期现比例 = 期货套期量/现货敞口量
+	HedgedSpotExposure     float64 `json:"hedgedspotexposure"`     // 被套期现货敞口量
+	HedgedTotalExposure    float64 `json:"hedgedtotalexposure"`    // 套期敞口量 = 被套期现货敞口量+期货套期量
+	HedgedSpRatio          float64 `json:"hedgedspratio"`          // 套期期现比例 = 期货套期量/被套期现货敞口量
+	OriSpotQty             float64 `json:"orispotqty"`             // 期初现货总量
+	OriHedgeSpotQty        float64 `json:"orihedgespotqty"`        // 期初被套期现货量
+	OriHedgePlanQty        float64 `json:"orihedgeplanqty"`        // 期初套期计划量
+	OriFutureQty           float64 `json:"orifutureqty"`           // 期初期货套期量
+	OriSpotExposure        float64 `json:"orispotexposure"`        // 期初现货敞口量
+	OriTotalExposure       float64 `json:"oritotalexposure"`       // 期初总敞口量
+	OriHedgedSpotExposure  float64 `json:"orihedgedspotexposure"`  // 期初被套期现货敞口量
+	OriHedgedTotalExposure float64 `json:"orihedgedtotalexposure"` // 期初套期敞口量
+	UpdateTime             string  `json:"updatetime"`             // 更新时间  --DATE
+	MiddleGoodsName        string  `json:"middlegoodsname"`        //套保品种名称
+	GoodsUnitID            int     `json:"goodsunitid"`            //单位ID
+
+	EnumdicName string `json:"enumdicname"` // 单位
+
+	USERID int64 `json:"-" form:"userid" binding:"required"` // 用户id, 用于过滤
+}
+
+func (r *Ermcp2AreaExposure) ParseFromProto(p *pb.Ermcp2AreaExposure) {
+	r.MiddleGoodsID = int(p.GetMiddleGoodsID())
+	r.AreaUserID = int(p.GetAreaUserID())
+	r.SpotQty = p.GetSpotQty()
+	r.HedgeSpotQty = p.GetHedgeSpotQty()
+	r.HedgePlanQty = p.GetHedgePlanQty()
+	r.FutureQty = p.GetFutureQty()
+	r.SpotExposure = p.GetSpotExposure()
+	r.TotalExposure = p.GetTotalExposure()
+	r.SpRatio = p.GetSpRatio()
+	r.HedgedSpotExposure = p.GetHedgedSpotExposure()
+	r.HedgedTotalExposure = p.GetHedgedTotalExposure()
+	r.HedgedSpRatio = p.GetHedgedSpRatio()
+	r.OriSpotQty = p.GetOriSpotQty()
+	r.OriHedgeSpotQty = p.GetOriHedgeSpotQty()
+	r.OriHedgePlanQty = p.GetOriHedgePlanQty()
+	r.OriFutureQty = p.GetOriFutureQty()
+	r.OriSpotExposure = p.GetOriSpotExposure()
+	r.OriTotalExposure = p.GetOriTotalExposure()
+	r.OriHedgedSpotExposure = p.GetOriHedgedSpotExposure()
+	r.OriHedgedTotalExposure = p.GetOriHedgedTotalExposure()
+	r.UpdateTime = p.GetUpdateTime().GetDateStr()
+	r.MiddleGoodsName = p.GetMiddleGoodsName()
+	r.GoodsUnitID = int(p.GetGoodsUnitID())
+	if p.GetGoodsUnitID() != 0 {
+		r.EnumdicName = mtpcache.GetEnumDicitemName(int32(p.GetGoodsUnitID()))
+	}
+}
+
+// GetDataEx 从数据库中查询数据
+func (r *Ermcp2AreaExposure) GetDataEx(userID int) (interface{}, error) {
+	redisCli := rediscli.GetRedisClient()
+
+	sData := make([]Ermcp2AreaExposure, 0)
+	key := "Ermcp2AreaExposure:*"
+	if ret, err := redisCli.Do("keys", key).Result(); err == nil {
+		datas := ret.([]interface{})
+		for _, item := range datas {
+			itemKey := item.(string)
+			// 判断是否目标数据
+			s := strings.Split(itemKey, "_")
+			if len(s) == 2 {
+				areaUserID, _ := strconv.Atoi(strings.Replace(s[0], "Ermcp2AreaExposure:", "", -1))
+				if areaUserID == userID {
+					if itemValue, err := redisCli.Get(itemKey).Result(); err == nil {
+						var data pb.Ermcp2AreaExposure
+						if err = proto.Unmarshal([]byte(itemValue), &data); err == nil {
+							m := Ermcp2AreaExposure{}
+							m.ParseFromProto(&data)
+							sData = append(sData, m)
+						}
+					}
+				}
+			}
+		}
+	}
+
+	return sData, nil
+}

+ 305 - 8
pb/mtp2.pb.go

@@ -1831,6 +1831,231 @@ func (x *Ermcp2HedgedItemInfo) GetHimiddlegoodsext() []*Ermcp2HIMiddleGoodsExt {
 	return nil
 }
 
+// ERMCP2_AREAEXPOSURE 企业敞口表_New
+type Ermcp2AreaExposure struct {
+	state         protoimpl.MessageState
+	sizeCache     protoimpl.SizeCache
+	unknownFields protoimpl.UnknownFields
+
+	//mkey: 1 2
+	MiddleGoodsID          *uint64  `protobuf:"varint,1,opt,name=MiddleGoodsID" json:"MiddleGoodsID,omitempty"`                     // 套保品种
+	AreaUserID             *uint64  `protobuf:"varint,2,opt,name=AreaUserID" json:"AreaUserID,omitempty"`                           // 所属机构
+	SpotQty                *float64 `protobuf:"fixed64,3,opt,name=SpotQty" json:"SpotQty,omitempty"`                                // 现货总量
+	HedgeSpotQty           *float64 `protobuf:"fixed64,4,opt,name=HedgeSpotQty" json:"HedgeSpotQty,omitempty"`                      // 被套期现货量
+	HedgePlanQty           *float64 `protobuf:"fixed64,5,opt,name=HedgePlanQty" json:"HedgePlanQty,omitempty"`                      // 套期计划量
+	FutureQty              *float64 `protobuf:"fixed64,6,opt,name=FutureQty" json:"FutureQty,omitempty"`                            // 期货套期量
+	SpotExposure           *float64 `protobuf:"fixed64,7,opt,name=SpotExposure" json:"SpotExposure,omitempty"`                      // 现货敞口量
+	TotalExposure          *float64 `protobuf:"fixed64,8,opt,name=TotalExposure" json:"TotalExposure,omitempty"`                    // 总敞口量 = 现货敞口量 + 期货套期量
+	SpRatio                *float64 `protobuf:"fixed64,9,opt,name=SpRatio" json:"SpRatio,omitempty"`                                // 总期现比例 = 期货套期量/现货敞口量
+	HedgedSpotExposure     *float64 `protobuf:"fixed64,10,opt,name=HedgedSpotExposure" json:"HedgedSpotExposure,omitempty"`         // 被套期现货敞口量
+	HedgedTotalExposure    *float64 `protobuf:"fixed64,11,opt,name=HedgedTotalExposure" json:"HedgedTotalExposure,omitempty"`       // 套期敞口量 = 被套期现货敞口量+期货套期量
+	HedgedSpRatio          *float64 `protobuf:"fixed64,12,opt,name=HedgedSpRatio" json:"HedgedSpRatio,omitempty"`                   // 套期期现比例 = 期货套期量/被套期现货敞口量
+	OriSpotQty             *float64 `protobuf:"fixed64,13,opt,name=OriSpotQty" json:"OriSpotQty,omitempty"`                         // 期初现货总量
+	OriHedgeSpotQty        *float64 `protobuf:"fixed64,14,opt,name=OriHedgeSpotQty" json:"OriHedgeSpotQty,omitempty"`               // 期初被套期现货量
+	OriHedgePlanQty        *float64 `protobuf:"fixed64,15,opt,name=OriHedgePlanQty" json:"OriHedgePlanQty,omitempty"`               // 期初套期计划量
+	OriFutureQty           *float64 `protobuf:"fixed64,16,opt,name=OriFutureQty" json:"OriFutureQty,omitempty"`                     // 期初期货套期量
+	OriSpotExposure        *float64 `protobuf:"fixed64,17,opt,name=OriSpotExposure" json:"OriSpotExposure,omitempty"`               // 期初现货敞口量
+	OriTotalExposure       *float64 `protobuf:"fixed64,18,opt,name=OriTotalExposure" json:"OriTotalExposure,omitempty"`             // 期初总敞口量
+	OriHedgedSpotExposure  *float64 `protobuf:"fixed64,19,opt,name=OriHedgedSpotExposure" json:"OriHedgedSpotExposure,omitempty"`   // 期初被套期现货敞口量
+	OriHedgedTotalExposure *float64 `protobuf:"fixed64,20,opt,name=OriHedgedTotalExposure" json:"OriHedgedTotalExposure,omitempty"` // 期初套期敞口量
+	UpdateTime             *Date    `protobuf:"bytes,21,opt,name=UpdateTime" json:"UpdateTime,omitempty"`                           // 更新时间  --DATE
+	MiddleGoodsName        *string  `protobuf:"bytes,22,opt,name=MiddleGoodsName" json:"MiddleGoodsName,omitempty"`                 //套保品种名称
+	GoodsUnitID            *uint32  `protobuf:"varint,23,opt,name=GoodsUnitID" json:"GoodsUnitID,omitempty"`                        //单位ID
+}
+
+func (x *Ermcp2AreaExposure) Reset() {
+	*x = Ermcp2AreaExposure{}
+	if protoimpl.UnsafeEnabled {
+		mi := &file_mtp2_proto_msgTypes[12]
+		ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
+		ms.StoreMessageInfo(mi)
+	}
+}
+
+func (x *Ermcp2AreaExposure) String() string {
+	return protoimpl.X.MessageStringOf(x)
+}
+
+func (*Ermcp2AreaExposure) ProtoMessage() {}
+
+func (x *Ermcp2AreaExposure) ProtoReflect() protoreflect.Message {
+	mi := &file_mtp2_proto_msgTypes[12]
+	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 Ermcp2AreaExposure.ProtoReflect.Descriptor instead.
+func (*Ermcp2AreaExposure) Descriptor() ([]byte, []int) {
+	return file_mtp2_proto_rawDescGZIP(), []int{12}
+}
+
+func (x *Ermcp2AreaExposure) GetMiddleGoodsID() uint64 {
+	if x != nil && x.MiddleGoodsID != nil {
+		return *x.MiddleGoodsID
+	}
+	return 0
+}
+
+func (x *Ermcp2AreaExposure) GetAreaUserID() uint64 {
+	if x != nil && x.AreaUserID != nil {
+		return *x.AreaUserID
+	}
+	return 0
+}
+
+func (x *Ermcp2AreaExposure) GetSpotQty() float64 {
+	if x != nil && x.SpotQty != nil {
+		return *x.SpotQty
+	}
+	return 0
+}
+
+func (x *Ermcp2AreaExposure) GetHedgeSpotQty() float64 {
+	if x != nil && x.HedgeSpotQty != nil {
+		return *x.HedgeSpotQty
+	}
+	return 0
+}
+
+func (x *Ermcp2AreaExposure) GetHedgePlanQty() float64 {
+	if x != nil && x.HedgePlanQty != nil {
+		return *x.HedgePlanQty
+	}
+	return 0
+}
+
+func (x *Ermcp2AreaExposure) GetFutureQty() float64 {
+	if x != nil && x.FutureQty != nil {
+		return *x.FutureQty
+	}
+	return 0
+}
+
+func (x *Ermcp2AreaExposure) GetSpotExposure() float64 {
+	if x != nil && x.SpotExposure != nil {
+		return *x.SpotExposure
+	}
+	return 0
+}
+
+func (x *Ermcp2AreaExposure) GetTotalExposure() float64 {
+	if x != nil && x.TotalExposure != nil {
+		return *x.TotalExposure
+	}
+	return 0
+}
+
+func (x *Ermcp2AreaExposure) GetSpRatio() float64 {
+	if x != nil && x.SpRatio != nil {
+		return *x.SpRatio
+	}
+	return 0
+}
+
+func (x *Ermcp2AreaExposure) GetHedgedSpotExposure() float64 {
+	if x != nil && x.HedgedSpotExposure != nil {
+		return *x.HedgedSpotExposure
+	}
+	return 0
+}
+
+func (x *Ermcp2AreaExposure) GetHedgedTotalExposure() float64 {
+	if x != nil && x.HedgedTotalExposure != nil {
+		return *x.HedgedTotalExposure
+	}
+	return 0
+}
+
+func (x *Ermcp2AreaExposure) GetHedgedSpRatio() float64 {
+	if x != nil && x.HedgedSpRatio != nil {
+		return *x.HedgedSpRatio
+	}
+	return 0
+}
+
+func (x *Ermcp2AreaExposure) GetOriSpotQty() float64 {
+	if x != nil && x.OriSpotQty != nil {
+		return *x.OriSpotQty
+	}
+	return 0
+}
+
+func (x *Ermcp2AreaExposure) GetOriHedgeSpotQty() float64 {
+	if x != nil && x.OriHedgeSpotQty != nil {
+		return *x.OriHedgeSpotQty
+	}
+	return 0
+}
+
+func (x *Ermcp2AreaExposure) GetOriHedgePlanQty() float64 {
+	if x != nil && x.OriHedgePlanQty != nil {
+		return *x.OriHedgePlanQty
+	}
+	return 0
+}
+
+func (x *Ermcp2AreaExposure) GetOriFutureQty() float64 {
+	if x != nil && x.OriFutureQty != nil {
+		return *x.OriFutureQty
+	}
+	return 0
+}
+
+func (x *Ermcp2AreaExposure) GetOriSpotExposure() float64 {
+	if x != nil && x.OriSpotExposure != nil {
+		return *x.OriSpotExposure
+	}
+	return 0
+}
+
+func (x *Ermcp2AreaExposure) GetOriTotalExposure() float64 {
+	if x != nil && x.OriTotalExposure != nil {
+		return *x.OriTotalExposure
+	}
+	return 0
+}
+
+func (x *Ermcp2AreaExposure) GetOriHedgedSpotExposure() float64 {
+	if x != nil && x.OriHedgedSpotExposure != nil {
+		return *x.OriHedgedSpotExposure
+	}
+	return 0
+}
+
+func (x *Ermcp2AreaExposure) GetOriHedgedTotalExposure() float64 {
+	if x != nil && x.OriHedgedTotalExposure != nil {
+		return *x.OriHedgedTotalExposure
+	}
+	return 0
+}
+
+func (x *Ermcp2AreaExposure) GetUpdateTime() *Date {
+	if x != nil {
+		return x.UpdateTime
+	}
+	return nil
+}
+
+func (x *Ermcp2AreaExposure) GetMiddleGoodsName() string {
+	if x != nil && x.MiddleGoodsName != nil {
+		return *x.MiddleGoodsName
+	}
+	return ""
+}
+
+func (x *Ermcp2AreaExposure) GetGoodsUnitID() uint32 {
+	if x != nil && x.GoodsUnitID != nil {
+		return *x.GoodsUnitID
+	}
+	return 0
+}
+
 var File_mtp2_proto protoreflect.FileDescriptor
 
 var file_mtp2_proto_rawDesc = []byte{
@@ -2223,7 +2448,65 @@ var file_mtp2_proto_rawDesc = []byte{
 	0x65, 0x78, 0x74, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x70, 0x62, 0x2e, 0x45,
 	0x72, 0x6d, 0x63, 0x70, 0x32, 0x48, 0x49, 0x4d, 0x69, 0x64, 0x64, 0x6c, 0x65, 0x47, 0x6f, 0x6f,
 	0x64, 0x73, 0x45, 0x78, 0x74, 0x52, 0x10, 0x68, 0x69, 0x6d, 0x69, 0x64, 0x64, 0x6c, 0x65, 0x67,
-	0x6f, 0x6f, 0x64, 0x73, 0x65, 0x78, 0x74,
+	0x6f, 0x6f, 0x64, 0x73, 0x65, 0x78, 0x74, 0x22, 0x98, 0x07, 0x0a, 0x12, 0x45, 0x72, 0x6d, 0x63,
+	0x70, 0x32, 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, 0x04, 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, 0x04, 0x52, 0x0a, 0x41, 0x72, 0x65, 0x61, 0x55, 0x73,
+	0x65, 0x72, 0x49, 0x44, 0x12, 0x18, 0x0a, 0x07, 0x53, 0x70, 0x6f, 0x74, 0x51, 0x74, 0x79, 0x18,
+	0x03, 0x20, 0x01, 0x28, 0x01, 0x52, 0x07, 0x53, 0x70, 0x6f, 0x74, 0x51, 0x74, 0x79, 0x12, 0x22,
+	0x0a, 0x0c, 0x48, 0x65, 0x64, 0x67, 0x65, 0x53, 0x70, 0x6f, 0x74, 0x51, 0x74, 0x79, 0x18, 0x04,
+	0x20, 0x01, 0x28, 0x01, 0x52, 0x0c, 0x48, 0x65, 0x64, 0x67, 0x65, 0x53, 0x70, 0x6f, 0x74, 0x51,
+	0x74, 0x79, 0x12, 0x22, 0x0a, 0x0c, 0x48, 0x65, 0x64, 0x67, 0x65, 0x50, 0x6c, 0x61, 0x6e, 0x51,
+	0x74, 0x79, 0x18, 0x05, 0x20, 0x01, 0x28, 0x01, 0x52, 0x0c, 0x48, 0x65, 0x64, 0x67, 0x65, 0x50,
+	0x6c, 0x61, 0x6e, 0x51, 0x74, 0x79, 0x12, 0x1c, 0x0a, 0x09, 0x46, 0x75, 0x74, 0x75, 0x72, 0x65,
+	0x51, 0x74, 0x79, 0x18, 0x06, 0x20, 0x01, 0x28, 0x01, 0x52, 0x09, 0x46, 0x75, 0x74, 0x75, 0x72,
+	0x65, 0x51, 0x74, 0x79, 0x12, 0x22, 0x0a, 0x0c, 0x53, 0x70, 0x6f, 0x74, 0x45, 0x78, 0x70, 0x6f,
+	0x73, 0x75, 0x72, 0x65, 0x18, 0x07, 0x20, 0x01, 0x28, 0x01, 0x52, 0x0c, 0x53, 0x70, 0x6f, 0x74,
+	0x45, 0x78, 0x70, 0x6f, 0x73, 0x75, 0x72, 0x65, 0x12, 0x24, 0x0a, 0x0d, 0x54, 0x6f, 0x74, 0x61,
+	0x6c, 0x45, 0x78, 0x70, 0x6f, 0x73, 0x75, 0x72, 0x65, 0x18, 0x08, 0x20, 0x01, 0x28, 0x01, 0x52,
+	0x0d, 0x54, 0x6f, 0x74, 0x61, 0x6c, 0x45, 0x78, 0x70, 0x6f, 0x73, 0x75, 0x72, 0x65, 0x12, 0x18,
+	0x0a, 0x07, 0x53, 0x70, 0x52, 0x61, 0x74, 0x69, 0x6f, 0x18, 0x09, 0x20, 0x01, 0x28, 0x01, 0x52,
+	0x07, 0x53, 0x70, 0x52, 0x61, 0x74, 0x69, 0x6f, 0x12, 0x2e, 0x0a, 0x12, 0x48, 0x65, 0x64, 0x67,
+	0x65, 0x64, 0x53, 0x70, 0x6f, 0x74, 0x45, 0x78, 0x70, 0x6f, 0x73, 0x75, 0x72, 0x65, 0x18, 0x0a,
+	0x20, 0x01, 0x28, 0x01, 0x52, 0x12, 0x48, 0x65, 0x64, 0x67, 0x65, 0x64, 0x53, 0x70, 0x6f, 0x74,
+	0x45, 0x78, 0x70, 0x6f, 0x73, 0x75, 0x72, 0x65, 0x12, 0x30, 0x0a, 0x13, 0x48, 0x65, 0x64, 0x67,
+	0x65, 0x64, 0x54, 0x6f, 0x74, 0x61, 0x6c, 0x45, 0x78, 0x70, 0x6f, 0x73, 0x75, 0x72, 0x65, 0x18,
+	0x0b, 0x20, 0x01, 0x28, 0x01, 0x52, 0x13, 0x48, 0x65, 0x64, 0x67, 0x65, 0x64, 0x54, 0x6f, 0x74,
+	0x61, 0x6c, 0x45, 0x78, 0x70, 0x6f, 0x73, 0x75, 0x72, 0x65, 0x12, 0x24, 0x0a, 0x0d, 0x48, 0x65,
+	0x64, 0x67, 0x65, 0x64, 0x53, 0x70, 0x52, 0x61, 0x74, 0x69, 0x6f, 0x18, 0x0c, 0x20, 0x01, 0x28,
+	0x01, 0x52, 0x0d, 0x48, 0x65, 0x64, 0x67, 0x65, 0x64, 0x53, 0x70, 0x52, 0x61, 0x74, 0x69, 0x6f,
+	0x12, 0x1e, 0x0a, 0x0a, 0x4f, 0x72, 0x69, 0x53, 0x70, 0x6f, 0x74, 0x51, 0x74, 0x79, 0x18, 0x0d,
+	0x20, 0x01, 0x28, 0x01, 0x52, 0x0a, 0x4f, 0x72, 0x69, 0x53, 0x70, 0x6f, 0x74, 0x51, 0x74, 0x79,
+	0x12, 0x28, 0x0a, 0x0f, 0x4f, 0x72, 0x69, 0x48, 0x65, 0x64, 0x67, 0x65, 0x53, 0x70, 0x6f, 0x74,
+	0x51, 0x74, 0x79, 0x18, 0x0e, 0x20, 0x01, 0x28, 0x01, 0x52, 0x0f, 0x4f, 0x72, 0x69, 0x48, 0x65,
+	0x64, 0x67, 0x65, 0x53, 0x70, 0x6f, 0x74, 0x51, 0x74, 0x79, 0x12, 0x28, 0x0a, 0x0f, 0x4f, 0x72,
+	0x69, 0x48, 0x65, 0x64, 0x67, 0x65, 0x50, 0x6c, 0x61, 0x6e, 0x51, 0x74, 0x79, 0x18, 0x0f, 0x20,
+	0x01, 0x28, 0x01, 0x52, 0x0f, 0x4f, 0x72, 0x69, 0x48, 0x65, 0x64, 0x67, 0x65, 0x50, 0x6c, 0x61,
+	0x6e, 0x51, 0x74, 0x79, 0x12, 0x22, 0x0a, 0x0c, 0x4f, 0x72, 0x69, 0x46, 0x75, 0x74, 0x75, 0x72,
+	0x65, 0x51, 0x74, 0x79, 0x18, 0x10, 0x20, 0x01, 0x28, 0x01, 0x52, 0x0c, 0x4f, 0x72, 0x69, 0x46,
+	0x75, 0x74, 0x75, 0x72, 0x65, 0x51, 0x74, 0x79, 0x12, 0x28, 0x0a, 0x0f, 0x4f, 0x72, 0x69, 0x53,
+	0x70, 0x6f, 0x74, 0x45, 0x78, 0x70, 0x6f, 0x73, 0x75, 0x72, 0x65, 0x18, 0x11, 0x20, 0x01, 0x28,
+	0x01, 0x52, 0x0f, 0x4f, 0x72, 0x69, 0x53, 0x70, 0x6f, 0x74, 0x45, 0x78, 0x70, 0x6f, 0x73, 0x75,
+	0x72, 0x65, 0x12, 0x2a, 0x0a, 0x10, 0x4f, 0x72, 0x69, 0x54, 0x6f, 0x74, 0x61, 0x6c, 0x45, 0x78,
+	0x70, 0x6f, 0x73, 0x75, 0x72, 0x65, 0x18, 0x12, 0x20, 0x01, 0x28, 0x01, 0x52, 0x10, 0x4f, 0x72,
+	0x69, 0x54, 0x6f, 0x74, 0x61, 0x6c, 0x45, 0x78, 0x70, 0x6f, 0x73, 0x75, 0x72, 0x65, 0x12, 0x34,
+	0x0a, 0x15, 0x4f, 0x72, 0x69, 0x48, 0x65, 0x64, 0x67, 0x65, 0x64, 0x53, 0x70, 0x6f, 0x74, 0x45,
+	0x78, 0x70, 0x6f, 0x73, 0x75, 0x72, 0x65, 0x18, 0x13, 0x20, 0x01, 0x28, 0x01, 0x52, 0x15, 0x4f,
+	0x72, 0x69, 0x48, 0x65, 0x64, 0x67, 0x65, 0x64, 0x53, 0x70, 0x6f, 0x74, 0x45, 0x78, 0x70, 0x6f,
+	0x73, 0x75, 0x72, 0x65, 0x12, 0x36, 0x0a, 0x16, 0x4f, 0x72, 0x69, 0x48, 0x65, 0x64, 0x67, 0x65,
+	0x64, 0x54, 0x6f, 0x74, 0x61, 0x6c, 0x45, 0x78, 0x70, 0x6f, 0x73, 0x75, 0x72, 0x65, 0x18, 0x14,
+	0x20, 0x01, 0x28, 0x01, 0x52, 0x16, 0x4f, 0x72, 0x69, 0x48, 0x65, 0x64, 0x67, 0x65, 0x64, 0x54,
+	0x6f, 0x74, 0x61, 0x6c, 0x45, 0x78, 0x70, 0x6f, 0x73, 0x75, 0x72, 0x65, 0x12, 0x28, 0x0a, 0x0a,
+	0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x54, 0x69, 0x6d, 0x65, 0x18, 0x15, 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, 0x12, 0x28, 0x0a, 0x0f, 0x4d, 0x69, 0x64, 0x64, 0x6c, 0x65,
+	0x47, 0x6f, 0x6f, 0x64, 0x73, 0x4e, 0x61, 0x6d, 0x65, 0x18, 0x16, 0x20, 0x01, 0x28, 0x09, 0x52,
+	0x0f, 0x4d, 0x69, 0x64, 0x64, 0x6c, 0x65, 0x47, 0x6f, 0x6f, 0x64, 0x73, 0x4e, 0x61, 0x6d, 0x65,
+	0x12, 0x20, 0x0a, 0x0b, 0x47, 0x6f, 0x6f, 0x64, 0x73, 0x55, 0x6e, 0x69, 0x74, 0x49, 0x44, 0x18,
+	0x17, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x0b, 0x47, 0x6f, 0x6f, 0x64, 0x73, 0x55, 0x6e, 0x69, 0x74,
+	0x49, 0x44,
 }
 
 var (
@@ -2238,7 +2521,7 @@ func file_mtp2_proto_rawDescGZIP() []byte {
 	return file_mtp2_proto_rawDescData
 }
 
-var file_mtp2_proto_msgTypes = make([]protoimpl.MessageInfo, 12)
+var file_mtp2_proto_msgTypes = make([]protoimpl.MessageInfo, 13)
 var file_mtp2_proto_goTypes = []interface{}{
 	(*TradeRule)(nil),              // 0: pb.TradeRule
 	(*TradeRuleInfoStruct)(nil),    // 1: pb.TradeRuleInfoStruct
@@ -2252,6 +2535,7 @@ var file_mtp2_proto_goTypes = []interface{}{
 	(*Ermcp2HIMiddleGoods)(nil),    // 9: pb.Ermcp2HIMiddleGoods
 	(*Ermcp2HIMiddleGoodsExt)(nil), // 10: pb.Ermcp2HIMiddleGoodsExt
 	(*Ermcp2HedgedItemInfo)(nil),   // 11: pb.Ermcp2HedgedItemInfo
+	(*Ermcp2AreaExposure)(nil),     // 12: pb.Ermcp2AreaExposure
 }
 var file_mtp2_proto_depIdxs = []int32{
 	0,  // 0: pb.TradeRuleInfoStruct.TradeRules:type_name -> pb.TradeRule
@@ -2268,11 +2552,12 @@ var file_mtp2_proto_depIdxs = []int32{
 	9,  // 11: pb.Ermcp2HIMiddleGoodsExt.middlegoods:type_name -> pb.Ermcp2HIMiddleGoods
 	8,  // 12: pb.Ermcp2HedgedItemInfo.hedgeditemext:type_name -> pb.Ermcp2HedgedItemExt
 	10, // 13: pb.Ermcp2HedgedItemInfo.himiddlegoodsext:type_name -> pb.Ermcp2HIMiddleGoodsExt
-	14, // [14:14] is the sub-list for method output_type
-	14, // [14:14] is the sub-list for method input_type
-	14, // [14:14] is the sub-list for extension type_name
-	14, // [14:14] is the sub-list for extension extendee
-	0,  // [0:14] is the sub-list for field type_name
+	2,  // 14: pb.Ermcp2AreaExposure.UpdateTime:type_name -> pb.Date
+	15, // [15:15] is the sub-list for method output_type
+	15, // [15:15] is the sub-list for method input_type
+	15, // [15:15] is the sub-list for extension type_name
+	15, // [15:15] is the sub-list for extension extendee
+	0,  // [0:15] is the sub-list for field type_name
 }
 
 func init() { file_mtp2_proto_init() }
@@ -2425,6 +2710,18 @@ func file_mtp2_proto_init() {
 				return nil
 			}
 		}
+		file_mtp2_proto_msgTypes[12].Exporter = func(v interface{}, i int) interface{} {
+			switch v := v.(*Ermcp2AreaExposure); 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{
@@ -2432,7 +2729,7 @@ func file_mtp2_proto_init() {
 			GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
 			RawDescriptor: file_mtp2_proto_rawDesc,
 			NumEnums:      0,
-			NumMessages:   12,
+			NumMessages:   13,
 			NumExtensions: 0,
 			NumServices:   0,
 		},

+ 29 - 0
pb/mtp2.proto

@@ -228,4 +228,33 @@ message Ermcp2HedgedItemInfo
 {
   optional Ermcp2HedgedItemExt hedgeditemext = 1; //被套期项目
   repeated Ermcp2HIMiddleGoodsExt himiddlegoodsext = 2;
+}
+
+// ERMCP2_AREAEXPOSURE 企业敞口表_New
+message Ermcp2AreaExposure
+{
+  //mkey: 1 2
+  optional uint64 MiddleGoodsID = 1;    // 套保品种
+  optional uint64 AreaUserID = 2;    // 所属机构
+  optional double SpotQty = 3;    // 现货总量
+  optional double HedgeSpotQty = 4;    // 被套期现货量
+  optional double HedgePlanQty = 5;    // 套期计划量
+  optional double FutureQty = 6;    // 期货套期量
+  optional double SpotExposure = 7;    // 现货敞口量
+  optional double TotalExposure = 8;    // 总敞口量 = 现货敞口量 + 期货套期量
+  optional double SpRatio = 9;    // 总期现比例 = 期货套期量/现货敞口量
+  optional double HedgedSpotExposure = 10;    // 被套期现货敞口量
+  optional double HedgedTotalExposure = 11;    // 套期敞口量 = 被套期现货敞口量+期货套期量
+  optional double HedgedSpRatio = 12;    // 套期期现比例 = 期货套期量/被套期现货敞口量
+  optional double OriSpotQty = 13;    // 期初现货总量
+  optional double OriHedgeSpotQty = 14;    // 期初被套期现货量
+  optional double OriHedgePlanQty = 15;    // 期初套期计划量
+  optional double OriFutureQty = 16;    // 期初期货套期量
+  optional double OriSpotExposure = 17;    // 期初现货敞口量
+  optional double OriTotalExposure = 18;    // 期初总敞口量
+  optional double OriHedgedSpotExposure = 19;    // 期初被套期现货敞口量
+  optional double OriHedgedTotalExposure = 20;    // 期初套期敞口量
+  optional Date   UpdateTime = 21;    // 更新时间  --DATE
+  optional string MiddleGoodsName = 22; //套保品种名称
+  optional uint32 GoodsUnitID = 23;  //单位ID
 }

+ 1 - 0
routers/router.go

@@ -498,6 +498,7 @@ func InitRouter() *gin.Engine {
 		ermcp8R.GET("/QueryUnLinkSpotContract", ermcp8.QueryUnLinkSpotContract)
 		ermcp8R.GET("/QueryErmcp8EnableHedgeditem", ermcp8.QueryErmcp8EnableHedgeditem)
 		ermcp8R.GET("/QueryErmcp8RunningHedgeditem", ermcp8.QueryErmcp8RunningHedgeditem)
+		ermcp8R.GET("/QueryErmcp2AreaExposure", ermcp8.QueryErmcp2AreaExposure)
 	}
 
 	// ****************************大连千海金******************************