Browse Source

1.增加查敞口报表参数调整明细接口
2.查期货商品组增加交易所信息字段

zou.yingbin 4 years ago
parent
commit
e6e5be59b9
7 changed files with 307 additions and 3 deletions
  1. 29 0
      controllers/ermcp3/qryErmcp3Report.go
  2. 75 0
      docs/docs.go
  3. 75 0
      docs/swagger.json
  4. 51 0
      docs/swagger.yaml
  5. 12 3
      models/ermcp3.go
  6. 64 0
      models/ermcp3Report.go
  7. 1 0
      routers/router.go

+ 29 - 0
controllers/ermcp3/qryErmcp3Report.go

@@ -332,6 +332,35 @@ func QryAreaExpourseFutuDetail(c *gin.Context) {
 	a.DoGetDataI(&m)
 }
 
+// QryAreaExpourseParamChLogDetail
+// @Summary 查询敞口参数调整明细(敞口报表/参数调整明细)
+// @Produce json
+// @Security ApiKeyAuth
+// @Param userid query int true "用户ID"
+// @Param middlegoodsid query int true "套保商品id"
+// @Param cycletype query int true "周期类型 - 0:日 1:月 2:季 3:年 4:周 5:全报表【原值】"
+// @Param cycletime query string true "周期时间 日(YYYYMMDD) 月(YYYYMM)  季(YYYYQ) 年(YYYY) 周(YYYYMMDD周内任意一天) 全(0)【原值】"
+// @Success 200 {array} models.Ermcp3ExposureFutuDetail
+// @Failure 500 {object} app.Response
+// @Router /Ermcp3/QryAreaExpourseParamChLogDetail [get]
+// @Tags 企业风险管理v3(app)
+func QryAreaExpourseParamChLogDetail(c *gin.Context) {
+	a := app.GinUtils{Gin: app.Gin{C: c}}
+	tmp := struct {
+		USERID        int64  `form:"userid" binding:"required"`        // 用户id
+		MIDDLEGOODSID int64  `form:"middlegoodsid" binding:"required"` // 套保商品id
+		CYCLETYPE     int32  `form:"cycletype"`
+		CYCLETIME     string `form:"cycletime"`
+	}{}
+	a.DoBindReq(&tmp)
+	req := QryReportReq{USERID: tmp.USERID, QUERYTYPE: 2, CYCLETYPE: tmp.CYCLETYPE, CYCLETIME: tmp.CYCLETIME}
+	a.CheckParam(&req)
+	req.CovertRequest()
+	m := models.Ermcp3ExposureParamChLog{AREAUSERID: mtpcache.GetAreaUserId(req.USERID, 0),
+		MIDDLEGOODSID: tmp.MIDDLEGOODSID, TRADEDATE: req.TRADEDATE, BeginDate: req.BEGINDATE, EndDate: req.ENDDATE}
+	a.DoGetDataI(&m)
+}
+
 // QryAreaSpotplReport
 // @Summary 查询现货报表
 // @Produce json

+ 75 - 0
docs/docs.go

@@ -3118,6 +3118,69 @@ var doc = `{
                 }
             }
         },
+        "/Ermcp3/QryAreaExpourseParamChLogDetail": {
+            "get": {
+                "security": [
+                    {
+                        "ApiKeyAuth": []
+                    }
+                ],
+                "produces": [
+                    "application/json"
+                ],
+                "tags": [
+                    "企业风险管理v3(app)"
+                ],
+                "summary": "查询敞口参数调整明细(敞口报表/参数调整明细)",
+                "parameters": [
+                    {
+                        "type": "integer",
+                        "description": "用户ID",
+                        "name": "userid",
+                        "in": "query",
+                        "required": true
+                    },
+                    {
+                        "type": "integer",
+                        "description": "套保商品id",
+                        "name": "middlegoodsid",
+                        "in": "query",
+                        "required": true
+                    },
+                    {
+                        "type": "integer",
+                        "description": "周期类型 - 0:日 1:月 2:季 3:年 4:周 5:全报表【原值】",
+                        "name": "cycletype",
+                        "in": "query",
+                        "required": true
+                    },
+                    {
+                        "type": "string",
+                        "description": "周期时间 日(YYYYMMDD) 月(YYYYMM)  季(YYYYQ) 年(YYYY) 周(YYYYMMDD周内任意一天) 全(0)【原值】",
+                        "name": "cycletime",
+                        "in": "query",
+                        "required": true
+                    }
+                ],
+                "responses": {
+                    "200": {
+                        "description": "OK",
+                        "schema": {
+                            "type": "array",
+                            "items": {
+                                "$ref": "#/definitions/models.Ermcp3ExposureFutuDetail"
+                            }
+                        }
+                    },
+                    "500": {
+                        "description": "Internal Server Error",
+                        "schema": {
+                            "$ref": "#/definitions/app.Response"
+                        }
+                    }
+                }
+            }
+        },
         "/Ermcp3/QryAreaExpourseReport": {
             "get": {
                 "security": [
@@ -15188,14 +15251,26 @@ var doc = `{
                     "description": "单位名称",
                     "type": "string"
                 },
+                "exchangefullname": {
+                    "description": "交易所全称",
+                    "type": "string"
+                },
                 "excludecfg": {
                     "description": "排除套保品已配置期货分类下的商品组(但显示已配置商品组) 1-排除",
                     "type": "integer"
                 },
+                "exexchangecode": {
+                    "description": "交易所代码",
+                    "type": "string"
+                },
                 "exexchangeid": {
                     "description": "外部交易所ID[通道交易]",
                     "type": "integer"
                 },
+                "exexchangename": {
+                    "description": "交易所名称",
+                    "type": "string"
+                },
                 "goodsgroupid": {
                     "description": "商品组ID(自增ID)",
                     "type": "integer"

+ 75 - 0
docs/swagger.json

@@ -3102,6 +3102,69 @@
                 }
             }
         },
+        "/Ermcp3/QryAreaExpourseParamChLogDetail": {
+            "get": {
+                "security": [
+                    {
+                        "ApiKeyAuth": []
+                    }
+                ],
+                "produces": [
+                    "application/json"
+                ],
+                "tags": [
+                    "企业风险管理v3(app)"
+                ],
+                "summary": "查询敞口参数调整明细(敞口报表/参数调整明细)",
+                "parameters": [
+                    {
+                        "type": "integer",
+                        "description": "用户ID",
+                        "name": "userid",
+                        "in": "query",
+                        "required": true
+                    },
+                    {
+                        "type": "integer",
+                        "description": "套保商品id",
+                        "name": "middlegoodsid",
+                        "in": "query",
+                        "required": true
+                    },
+                    {
+                        "type": "integer",
+                        "description": "周期类型 - 0:日 1:月 2:季 3:年 4:周 5:全报表【原值】",
+                        "name": "cycletype",
+                        "in": "query",
+                        "required": true
+                    },
+                    {
+                        "type": "string",
+                        "description": "周期时间 日(YYYYMMDD) 月(YYYYMM)  季(YYYYQ) 年(YYYY) 周(YYYYMMDD周内任意一天) 全(0)【原值】",
+                        "name": "cycletime",
+                        "in": "query",
+                        "required": true
+                    }
+                ],
+                "responses": {
+                    "200": {
+                        "description": "OK",
+                        "schema": {
+                            "type": "array",
+                            "items": {
+                                "$ref": "#/definitions/models.Ermcp3ExposureFutuDetail"
+                            }
+                        }
+                    },
+                    "500": {
+                        "description": "Internal Server Error",
+                        "schema": {
+                            "$ref": "#/definitions/app.Response"
+                        }
+                    }
+                }
+            }
+        },
         "/Ermcp3/QryAreaExpourseReport": {
             "get": {
                 "security": [
@@ -15172,14 +15235,26 @@
                     "description": "单位名称",
                     "type": "string"
                 },
+                "exchangefullname": {
+                    "description": "交易所全称",
+                    "type": "string"
+                },
                 "excludecfg": {
                     "description": "排除套保品已配置期货分类下的商品组(但显示已配置商品组) 1-排除",
                     "type": "integer"
                 },
+                "exexchangecode": {
+                    "description": "交易所代码",
+                    "type": "string"
+                },
                 "exexchangeid": {
                     "description": "外部交易所ID[通道交易]",
                     "type": "integer"
                 },
+                "exexchangename": {
+                    "description": "交易所名称",
+                    "type": "string"
+                },
                 "goodsgroupid": {
                     "description": "商品组ID(自增ID)",
                     "type": "integer"

+ 51 - 0
docs/swagger.yaml

@@ -4554,12 +4554,21 @@ definitions:
       enumdicname:
         description: 单位名称
         type: string
+      exchangefullname:
+        description: 交易所全称
+        type: string
       excludecfg:
         description: 排除套保品已配置期货分类下的商品组(但显示已配置商品组) 1-排除
         type: integer
+      exexchangecode:
+        description: 交易所代码
+        type: string
       exexchangeid:
         description: 外部交易所ID[通道交易]
         type: integer
+      exexchangename:
+        description: 交易所名称
+        type: string
       goodsgroupid:
         description: 商品组ID(自增ID)
         type: integer
@@ -15190,6 +15199,48 @@ paths:
       summary: 查询敞口套保计划明细(敞口报表/套保计划明细)
       tags:
       - 企业风险管理v3(app)
+  /Ermcp3/QryAreaExpourseParamChLogDetail:
+    get:
+      parameters:
+      - description: 用户ID
+        in: query
+        name: userid
+        required: true
+        type: integer
+      - description: 套保商品id
+        in: query
+        name: middlegoodsid
+        required: true
+        type: integer
+      - description: 周期类型 - 0:日 1:月 2:季 3:年 4:周 5:全报表【原值】
+        in: query
+        name: cycletype
+        required: true
+        type: integer
+      - description: 周期时间 日(YYYYMMDD) 月(YYYYMM)  季(YYYYQ) 年(YYYY) 周(YYYYMMDD周内任意一天)
+          全(0)【原值】
+        in: query
+        name: cycletime
+        required: true
+        type: string
+      produces:
+      - application/json
+      responses:
+        "200":
+          description: OK
+          schema:
+            items:
+              $ref: '#/definitions/models.Ermcp3ExposureFutuDetail'
+            type: array
+        "500":
+          description: Internal Server Error
+          schema:
+            $ref: '#/definitions/app.Response'
+      security:
+      - ApiKeyAuth: []
+      summary: 查询敞口参数调整明细(敞口报表/参数调整明细)
+      tags:
+      - 企业风险管理v3(app)
   /Ermcp3/QryAreaExpourseReport:
     get:
       parameters:

+ 12 - 3
models/ermcp3.go

@@ -1993,6 +1993,9 @@ type Ermcp3GoodsGroup struct {
 	SYNCGOODSQTY       int32   `json:"syncgoodsqty"  xorm:"'SYNCGOODSQTY'"`             // 同步合约数[通道交易-投资管理用] - 0表示不限
 	CLOSEPRICEMODE     int32   `json:"closepricemode"  xorm:"'CLOSEPRICEMODE'"`         // 强平价格方式 - 1:市价 2:最新价 3:涨跌停(未实现)
 	GROUPCATEGROYID    int32   `json:"groupcategroyid"  xorm:"'GROUPCATEGROYID'"`       // 品种分类ID
+	EXEXCHANGECODE     string  `json:"exexchangecode"  xorm:"'EXEXCHANGECODE'"`         // 交易所代码
+	EXEXCHANGENAME     string  `json:"exexchangename"  xorm:"'EXEXCHANGENAME'"`         // 交易所名称
+	EXCHANGEFULLNAME   string  `json:"exchangefullname"  xorm:"'EXCHANGEFULLNAME'"`     // 交易所全称
 
 	ENUMDICNAME string `json:"enumdicname"`                                     // 单位名称
 	AreaUserId  int64  `json:"areauserid" form:"areauserid" binding:"required"` // 所属机构id(套保品是有areauserid的,当要排除已配置商品组时需要areauserid过滤)
@@ -2025,10 +2028,16 @@ func (r *Ermcp3GoodsGroup) buildSql() string {
 		"       t.OUTERDEALMODE," +
 		"       t.SYNCGOODSQTY," +
 		"       t.CLOSEPRICEMODE," +
-		"       t.GROUPCATEGROYID" +
+		"       t.GROUPCATEGROYID," +
+		"       e.exexchangecode," +
+		"       e.exexchangename," +
+		"       e.exchangefullname" +
 		"  FROM GOODSGROUP t" +
-		"  LEFT JOIN market m on t.marketid=m.marketid" +
-		" WHERE 1 = 1 and m.trademode=15"
+		"  LEFT JOIN market m" +
+		"    on t.marketid = m.marketid" +
+		"  LEFT JOIN externalexchange e on t.exexchangeid=e.autoid" +
+		" WHERE 1 = 1" +
+		"   and m.trademode = 15"
 	if r.ExcludeCfg == 1 {
 		str := "select t.goodsgroupid" +
 			"  from ERMS_MiddleGoods t" +

+ 64 - 0
models/ermcp3Report.go

@@ -2693,3 +2693,67 @@ func (r *Ermcp3ExposureFutuDetail) GetDataEx() (interface{}, error) {
 	}
 	return sData, nil
 }
+
+// Ermcp3ExposureParamChLog 敞口报表参数调整明细
+type Ermcp3ExposureParamChLog struct {
+	LOGID            string  `json:"logid"  xorm:"LOGID"`                       // 流水ID(609+Unix秒时间戳(10位)+xxxxxx)
+	MIDDLEGOODSID    int64   `json:"middlegoodsid"  xorm:"MIDDLEGOODSID"`       // 套保品种
+	AREAUSERID       int64   `json:"areauserid"  xorm:"AREAUSERID"`             // 所属机构\交易用户ID
+	ACCOUNTID        int64   `json:"accountid"  xorm:"ACCOUNTID"`               // 期货账户ID (作废, 默认为0)
+	CHANGELOGTYPE    int32   `json:"changelogtype"  xorm:"CHANGELOGTYPE"`       // 变更流水类型 - 1:套保比率变更 2:套利比率变更
+	PARAMBEFOREVALUE float64 `json:"parambeforevalue"  xorm:"PARAMBEFOREVALUE"` // 参数变更前(调整前参数值)
+	PARAMAFTERVALUE  float64 `json:"paramaftervalue"  xorm:"PARAMAFTERVALUE"`   // 参数变更后(调整后参数值)
+	CURVALUE         float64 `json:"curvalue"  xorm:"CURVALUE"`                 // 当前套保\套利量(套保总量|套利总量)
+	BEFOREVALUE      float64 `json:"beforevalue"  xorm:"BEFOREVALUE"`           // 应套保\套利量变更前(调整前应套保总量)
+	AFTERVALUE       float64 `json:"aftervalue"  xorm:"AFTERVALUE"`             // 应套保\套利量变更后(调整后应套保总量)
+	LOGDATETIME      string  `json:"logdatetime"  xorm:"LOGDATETIME"`           // 流水日期
+	TRADEDATE        string  `json:"tradedate"  xorm:"TRADEDATE"`               // 交易日(yyyyMMdd)
+	MIDDLEGOODSCODE  string  `json:"middlegoodscode"`                           // 套保品种代码
+	MIDDLEGOODSNAME  string  `json:"middlegoodsname"`                           // 套保品种名称
+
+	DiffValue float64 `json:"diffvalue"` // 应套保总量变化量
+	BeginDate string  `json:"begindate"` // 开始交易日
+	EndDate   string  `json:"enddate"`   // 结束交易日
+}
+
+func (r *Ermcp3ExposureParamChLog) calc() {
+	r.DiffValue = r.AFTERVALUE - r.BEFOREVALUE
+}
+
+func (r *Ermcp3ExposureParamChLog) buildSql() string {
+	var sqlId utils.SQLVal = "SELECT t.LOGID," +
+		"       t.MIDDLEGOODSID," +
+		"       t.AREAUSERID," +
+		"       t.ACCOUNTID," +
+		"       t.CHANGELOGTYPE," +
+		"       t.PARAMBEFOREVALUE," +
+		"       t.PARAMAFTERVALUE," +
+		"       t.CURVALUE," +
+		"       t.BEFOREVALUE," +
+		"       t.AFTERVALUE," +
+		"       to_char(t.LOGDATETIME, 'yyyy-mm-dd hh24:mi:ss') LOGDATETIME," +
+		"       t.TRADEDATE," +
+		"       g.middlegoodscode," +
+		"       g.middlegoodsname" +
+		"  FROM ERMCP_EXPOSUREPARAMCHGLOG t" +
+		"  LEFT JOIN ERMS_MIDDLEGOODS g on t.middlegoodsid=g.middlegoodsid" +
+		" WHERE 1 = 1"
+	sqlId.And("t.AREAUSERID", r.AREAUSERID)
+	sqlId.AndEx("t.TRADEDATE", r.TRADEDATE, len(r.TRADEDATE) > 0)
+	if len(r.BeginDate) > 0 && len(r.EndDate) > 0 {
+		sqlId.Join(fmt.Sprintf(" and t.TRADEDATE >= '%v' and t.TRADEDATE <= '%v' ", r.BeginDate, r.EndDate))
+	}
+	return sqlId.String()
+}
+
+// GetDataEx 获取敞口报表参数调整明细
+func (r *Ermcp3ExposureParamChLog) GetDataEx() (interface{}, error) {
+	sData := make([]Ermcp3ExposureParamChLog, 0)
+	err := db.GetEngine().SQL(r.buildSql()).Find(&sData)
+	for i := range sData {
+		sData[i].calc()
+		sData[i].BeginDate = r.BeginDate
+		sData[i].EndDate = r.EndDate
+	}
+	return sData, err
+}

+ 1 - 0
routers/router.go

@@ -441,6 +441,7 @@ func InitRouter() *gin.Engine {
 		ermcp3R.GET("/QryAreaExpourseContractDetail", ermcp3.QryAreaExpourseContractDetail)
 		ermcp3R.GET("/QryAreaExpourseHedgeplanDetail", ermcp3.QryAreaExpourseHedgeplanDetail)
 		ermcp3R.GET("/QryAreaExpourseFutuDetail", ermcp3.QryAreaExpourseFutuDetail)
+		ermcp3R.GET("/QryAreaExpourseParamChLogDetail", ermcp3.QryAreaExpourseParamChLogDetail)
 		ermcp3R.GET("/QryAreaStockReport", ermcp3.QryAreaStockReport)
 		ermcp3R.GET("/QryFinanceReport", ermcp3.QryFinanceReport)
 		ermcp3R.GET("/QryAreaSumPL", ermcp3.QryAreaSumPL)