Преглед на файлове

增加查期货商品组新接口

zou.yingbin преди 4 години
родител
ревизия
190e329098
променени са 6 файла, в които са добавени 514 реда и са изтрити 0 реда
  1. 16 0
      controllers/ermcp3/qryErmcp3.go
  2. 152 0
      docs/docs.go
  3. 152 0
      docs/swagger.json
  4. 107 0
      docs/swagger.yaml
  5. 86 0
      models/ermcp3.go
  6. 1 0
      routers/router.go

+ 16 - 0
controllers/ermcp3/qryErmcp3.go

@@ -493,3 +493,19 @@ func QueryHedgePlan(c *gin.Context) {
 		appG.Response(http.StatusBadRequest, e.ERROR_QUERY_FAIL, nil)
 	}
 }
+
+// QueryGoodsGroup
+// @Summary 查询期货商品组
+// @Produce json
+// @Security ApiKeyAuth
+// @Param areauserid query int true "所属机构id"
+// @Param excludecfg query int false "排除套保品中已关联的商品组 1-排除"
+// @Success 200 {array} models.Ermcp3GoodsGroup
+// @Failure 500 {object} app.Response
+// @Router /Ermcp3/QueryGoodsGroup [get]
+// @Tags 企业风险管理v3(app)
+func QueryGoodsGroup(c *gin.Context) {
+	a := app.GinUtils{Gin: app.Gin{C: c}}
+	m := models.Ermcp3GoodsGroup{}
+	a.DoGetDataI(&m)
+}

+ 152 - 0
docs/docs.go

@@ -5078,6 +5078,54 @@ var doc = `{
                 }
             }
         },
+        "/Ermcp3/QueryGoodsGroup": {
+            "get": {
+                "security": [
+                    {
+                        "ApiKeyAuth": []
+                    }
+                ],
+                "produces": [
+                    "application/json"
+                ],
+                "tags": [
+                    "企业风险管理v3(app)"
+                ],
+                "summary": "查询期货商品组",
+                "parameters": [
+                    {
+                        "type": "integer",
+                        "description": "所属机构id",
+                        "name": "areauserid",
+                        "in": "query",
+                        "required": true
+                    },
+                    {
+                        "type": "integer",
+                        "description": "排除套保品中已关联的商品组 1-排除",
+                        "name": "excludecfg",
+                        "in": "query"
+                    }
+                ],
+                "responses": {
+                    "200": {
+                        "description": "OK",
+                        "schema": {
+                            "type": "array",
+                            "items": {
+                                "$ref": "#/definitions/models.Ermcp3GoodsGroup"
+                            }
+                        }
+                    },
+                    "500": {
+                        "description": "Internal Server Error",
+                        "schema": {
+                            "$ref": "#/definitions/app.Response"
+                        }
+                    }
+                }
+            }
+        },
         "/Ermcp3/QueryGoodsWrstandard": {
             "get": {
                 "security": [
@@ -14018,6 +14066,110 @@ var doc = `{
                 }
             }
         },
+        "models.Ermcp3GoodsGroup": {
+            "type": "object",
+            "required": [
+                "areauserid"
+            ],
+            "properties": {
+                "agreeunit": {
+                    "description": "合约单位",
+                    "type": "number"
+                },
+                "areauserid": {
+                    "description": "所属机构id(套保品是有areauserid的,当要排除已配置商品组时需要areauserid过滤)",
+                    "type": "integer"
+                },
+                "canshort": {
+                    "description": "是否允许做空[通道交易] - 0:不能做空 1:可以做空",
+                    "type": "integer"
+                },
+                "closepricemode": {
+                    "description": "强平价格方式 - 1:市价 2:最新价 3:涨跌停(未实现)",
+                    "type": "integer"
+                },
+                "createtime": {
+                    "description": "创建时间",
+                    "type": "string"
+                },
+                "creatorid": {
+                    "description": "创建人",
+                    "type": "integer"
+                },
+                "currencyid": {
+                    "description": "报价货币ID",
+                    "type": "integer"
+                },
+                "decimalplace": {
+                    "description": "报价小数位",
+                    "type": "integer"
+                },
+                "excludecfg": {
+                    "description": "排除套保品已配置期货分类下的商品组(但显示已配置商品组) 1-排除",
+                    "type": "integer"
+                },
+                "exexchangeid": {
+                    "description": "外部交易所ID[通道交易]",
+                    "type": "integer"
+                },
+                "goodsgroupid": {
+                    "description": "商品组ID(自增ID)",
+                    "type": "integer"
+                },
+                "goodsgroupname": {
+                    "description": "商品组名称",
+                    "type": "string"
+                },
+                "goodsgroupstatus": {
+                    "description": "商品组状态 - 1:正常 2:注销",
+                    "type": "integer"
+                },
+                "goodunitid": {
+                    "description": "报价单位ID",
+                    "type": "integer"
+                },
+                "groupcategroyid": {
+                    "description": "品种分类ID",
+                    "type": "integer"
+                },
+                "innerdealmode": {
+                    "description": "内部成交方式[通道交易] - 1:净头寸 2:开平 3:平今",
+                    "type": "integer"
+                },
+                "marketid": {
+                    "description": "所属市场ID",
+                    "type": "integer"
+                },
+                "modifierid": {
+                    "description": "修改人",
+                    "type": "integer"
+                },
+                "modifytime": {
+                    "description": "修改时间",
+                    "type": "string"
+                },
+                "outerdealmode": {
+                    "description": "外部成交方式[通道交易]- 1:净头寸 2:开平 3:平今",
+                    "type": "integer"
+                },
+                "outergroupcode": {
+                    "description": "外部商品组代码[通道交易]",
+                    "type": "string"
+                },
+                "quoteminunit": {
+                    "description": "行情最小变动单位 [整数,报价小数位一起使用]",
+                    "type": "integer"
+                },
+                "quotesourcegroupid": {
+                    "description": "所属行情源分组ID[参考行情市场用\\通道交易]",
+                    "type": "integer"
+                },
+                "syncgoodsqty": {
+                    "description": "同步合约数[通道交易-投资管理用] - 0表示不限",
+                    "type": "integer"
+                }
+            }
+        },
         "models.Ermcp3HedgePlan": {
             "type": "object",
             "properties": {

+ 152 - 0
docs/swagger.json

@@ -5062,6 +5062,54 @@
                 }
             }
         },
+        "/Ermcp3/QueryGoodsGroup": {
+            "get": {
+                "security": [
+                    {
+                        "ApiKeyAuth": []
+                    }
+                ],
+                "produces": [
+                    "application/json"
+                ],
+                "tags": [
+                    "企业风险管理v3(app)"
+                ],
+                "summary": "查询期货商品组",
+                "parameters": [
+                    {
+                        "type": "integer",
+                        "description": "所属机构id",
+                        "name": "areauserid",
+                        "in": "query",
+                        "required": true
+                    },
+                    {
+                        "type": "integer",
+                        "description": "排除套保品中已关联的商品组 1-排除",
+                        "name": "excludecfg",
+                        "in": "query"
+                    }
+                ],
+                "responses": {
+                    "200": {
+                        "description": "OK",
+                        "schema": {
+                            "type": "array",
+                            "items": {
+                                "$ref": "#/definitions/models.Ermcp3GoodsGroup"
+                            }
+                        }
+                    },
+                    "500": {
+                        "description": "Internal Server Error",
+                        "schema": {
+                            "$ref": "#/definitions/app.Response"
+                        }
+                    }
+                }
+            }
+        },
         "/Ermcp3/QueryGoodsWrstandard": {
             "get": {
                 "security": [
@@ -14002,6 +14050,110 @@
                 }
             }
         },
+        "models.Ermcp3GoodsGroup": {
+            "type": "object",
+            "required": [
+                "areauserid"
+            ],
+            "properties": {
+                "agreeunit": {
+                    "description": "合约单位",
+                    "type": "number"
+                },
+                "areauserid": {
+                    "description": "所属机构id(套保品是有areauserid的,当要排除已配置商品组时需要areauserid过滤)",
+                    "type": "integer"
+                },
+                "canshort": {
+                    "description": "是否允许做空[通道交易] - 0:不能做空 1:可以做空",
+                    "type": "integer"
+                },
+                "closepricemode": {
+                    "description": "强平价格方式 - 1:市价 2:最新价 3:涨跌停(未实现)",
+                    "type": "integer"
+                },
+                "createtime": {
+                    "description": "创建时间",
+                    "type": "string"
+                },
+                "creatorid": {
+                    "description": "创建人",
+                    "type": "integer"
+                },
+                "currencyid": {
+                    "description": "报价货币ID",
+                    "type": "integer"
+                },
+                "decimalplace": {
+                    "description": "报价小数位",
+                    "type": "integer"
+                },
+                "excludecfg": {
+                    "description": "排除套保品已配置期货分类下的商品组(但显示已配置商品组) 1-排除",
+                    "type": "integer"
+                },
+                "exexchangeid": {
+                    "description": "外部交易所ID[通道交易]",
+                    "type": "integer"
+                },
+                "goodsgroupid": {
+                    "description": "商品组ID(自增ID)",
+                    "type": "integer"
+                },
+                "goodsgroupname": {
+                    "description": "商品组名称",
+                    "type": "string"
+                },
+                "goodsgroupstatus": {
+                    "description": "商品组状态 - 1:正常 2:注销",
+                    "type": "integer"
+                },
+                "goodunitid": {
+                    "description": "报价单位ID",
+                    "type": "integer"
+                },
+                "groupcategroyid": {
+                    "description": "品种分类ID",
+                    "type": "integer"
+                },
+                "innerdealmode": {
+                    "description": "内部成交方式[通道交易] - 1:净头寸 2:开平 3:平今",
+                    "type": "integer"
+                },
+                "marketid": {
+                    "description": "所属市场ID",
+                    "type": "integer"
+                },
+                "modifierid": {
+                    "description": "修改人",
+                    "type": "integer"
+                },
+                "modifytime": {
+                    "description": "修改时间",
+                    "type": "string"
+                },
+                "outerdealmode": {
+                    "description": "外部成交方式[通道交易]- 1:净头寸 2:开平 3:平今",
+                    "type": "integer"
+                },
+                "outergroupcode": {
+                    "description": "外部商品组代码[通道交易]",
+                    "type": "string"
+                },
+                "quoteminunit": {
+                    "description": "行情最小变动单位 [整数,报价小数位一起使用]",
+                    "type": "integer"
+                },
+                "quotesourcegroupid": {
+                    "description": "所属行情源分组ID[参考行情市场用\\通道交易]",
+                    "type": "integer"
+                },
+                "syncgoodsqty": {
+                    "description": "同步合约数[通道交易-投资管理用] - 0表示不限",
+                    "type": "integer"
+                }
+            }
+        },
         "models.Ermcp3HedgePlan": {
             "type": "object",
             "properties": {

+ 107 - 0
docs/swagger.yaml

@@ -3668,6 +3668,83 @@ definitions:
         description: 现货合同/套保计划编号
         type: string
     type: object
+  models.Ermcp3GoodsGroup:
+    properties:
+      agreeunit:
+        description: 合约单位
+        type: number
+      areauserid:
+        description: 所属机构id(套保品是有areauserid的,当要排除已配置商品组时需要areauserid过滤)
+        type: integer
+      canshort:
+        description: 是否允许做空[通道交易] - 0:不能做空 1:可以做空
+        type: integer
+      closepricemode:
+        description: 强平价格方式 - 1:市价 2:最新价 3:涨跌停(未实现)
+        type: integer
+      createtime:
+        description: 创建时间
+        type: string
+      creatorid:
+        description: 创建人
+        type: integer
+      currencyid:
+        description: 报价货币ID
+        type: integer
+      decimalplace:
+        description: 报价小数位
+        type: integer
+      excludecfg:
+        description: 排除套保品已配置期货分类下的商品组(但显示已配置商品组) 1-排除
+        type: integer
+      exexchangeid:
+        description: 外部交易所ID[通道交易]
+        type: integer
+      goodsgroupid:
+        description: 商品组ID(自增ID)
+        type: integer
+      goodsgroupname:
+        description: 商品组名称
+        type: string
+      goodsgroupstatus:
+        description: 商品组状态 - 1:正常 2:注销
+        type: integer
+      goodunitid:
+        description: 报价单位ID
+        type: integer
+      groupcategroyid:
+        description: 品种分类ID
+        type: integer
+      innerdealmode:
+        description: 内部成交方式[通道交易] - 1:净头寸 2:开平 3:平今
+        type: integer
+      marketid:
+        description: 所属市场ID
+        type: integer
+      modifierid:
+        description: 修改人
+        type: integer
+      modifytime:
+        description: 修改时间
+        type: string
+      outerdealmode:
+        description: 外部成交方式[通道交易]- 1:净头寸 2:开平 3:平今
+        type: integer
+      outergroupcode:
+        description: 外部商品组代码[通道交易]
+        type: string
+      quoteminunit:
+        description: 行情最小变动单位 [整数,报价小数位一起使用]
+        type: integer
+      quotesourcegroupid:
+        description: 所属行情源分组ID[参考行情市场用\通道交易]
+        type: integer
+      syncgoodsqty:
+        description: 同步合约数[通道交易-投资管理用] - 0表示不限
+        type: integer
+    required:
+    - areauserid
+    type: object
   models.Ermcp3HedgePlan:
     properties:
       areauserid:
@@ -15231,6 +15308,36 @@ paths:
       summary: 查询敞口现货头寸明细(敞口/现货头寸/现货明细)
       tags:
       - 企业风险管理v3(app)
+  /Ermcp3/QueryGoodsGroup:
+    get:
+      parameters:
+      - description: 所属机构id
+        in: query
+        name: areauserid
+        required: true
+        type: integer
+      - description: 排除套保品中已关联的商品组 1-排除
+        in: query
+        name: excludecfg
+        type: integer
+      produces:
+      - application/json
+      responses:
+        "200":
+          description: OK
+          schema:
+            items:
+              $ref: '#/definitions/models.Ermcp3GoodsGroup'
+            type: array
+        "500":
+          description: Internal Server Error
+          schema:
+            $ref: '#/definitions/app.Response'
+      security:
+      - ApiKeyAuth: []
+      summary: 查询期货商品组
+      tags:
+      - 企业风险管理v3(app)
   /Ermcp3/QueryGoodsWrstandard:
     get:
       parameters:

+ 86 - 0
models/ermcp3.go

@@ -1631,3 +1631,89 @@ func (r *Ermcp3HedgePlan) GetData(status string) ([]Ermcp3HedgePlan, error) {
 
 	return sData, nil
 }
+
+// Ermcp3GoodsGroup 商品组
+type Ermcp3GoodsGroup struct {
+	GOODSGROUPID       int32   `json:"goodsgroupid"  xorm:"'GOODSGROUPID'"`             // 商品组ID(自增ID)
+	GOODSGROUPNAME     string  `json:"goodsgroupname"  xorm:"'GOODSGROUPNAME'"`         // 商品组名称
+	GOODSGROUPSTATUS   int32   `json:"goodsgroupstatus"  xorm:"'GOODSGROUPSTATUS'"`     // 商品组状态 - 1:正常 2:注销
+	MARKETID           int32   `json:"marketid"  xorm:"'MARKETID'"`                     // 所属市场ID
+	CREATETIME         string  `json:"createtime"  xorm:"'CREATETIME'"`                 // 创建时间
+	CREATORID          int32   `json:"creatorid"  xorm:"'CREATORID'"`                   // 创建人
+	MODIFYTIME         string  `json:"modifytime"  xorm:"'MODIFYTIME'"`                 // 修改时间
+	MODIFIERID         int32   `json:"modifierid"  xorm:"'MODIFIERID'"`                 // 修改人
+	QUOTESOURCEGROUPID int64   `json:"quotesourcegroupid"  xorm:"'QUOTESOURCEGROUPID'"` // 所属行情源分组ID[参考行情市场用\通道交易]
+	OUTERGROUPCODE     string  `json:"outergroupcode"  xorm:"'OUTERGROUPCODE'"`         // 外部商品组代码[通道交易]
+	CANSHORT           int32   `json:"canshort"  xorm:"'CANSHORT'"`                     // 是否允许做空[通道交易] - 0:不能做空 1:可以做空
+	EXEXCHANGEID       int64   `json:"exexchangeid"  xorm:"'EXEXCHANGEID'"`             // 外部交易所ID[通道交易]
+	CURRENCYID         int32   `json:"currencyid"  xorm:"'CURRENCYID'"`                 // 报价货币ID
+	GOODUNITID         int32   `json:"goodunitid"  xorm:"'GOODUNITID'"`                 // 报价单位ID
+	AGREEUNIT          float32 `json:"agreeunit"  xorm:"'AGREEUNIT'"`                   // 合约单位
+	DECIMALPLACE       int32   `json:"decimalplace"  xorm:"'DECIMALPLACE'"`             // 报价小数位
+	QUOTEMINUNIT       int32   `json:"quoteminunit"  xorm:"'QUOTEMINUNIT'"`             // 行情最小变动单位 [整数,报价小数位一起使用]
+	INNERDEALMODE      int32   `json:"innerdealmode"  xorm:"'INNERDEALMODE'"`           // 内部成交方式[通道交易] - 1:净头寸 2:开平 3:平今
+	OUTERDEALMODE      int32   `json:"outerdealmode"  xorm:"'OUTERDEALMODE'"`           // 外部成交方式[通道交易]- 1:净头寸 2:开平 3:平今
+	SYNCGOODSQTY       int32   `json:"syncgoodsqty"  xorm:"'SYNCGOODSQTY'"`             // 同步合约数[通道交易-投资管理用] - 0表示不限
+	CLOSEPRICEMODE     int32   `json:"closepricemode"  xorm:"'CLOSEPRICEMODE'"`         // 强平价格方式 - 1:市价 2:最新价 3:涨跌停(未实现)
+	GROUPCATEGROYID    int32   `json:"groupcategroyid"  xorm:"'GROUPCATEGROYID'"`       // 品种分类ID
+
+	AreaUserId int64 `json:"areauserid" form:"areauserid" binding:"required"` // 所属机构id(套保品是有areauserid的,当要排除已配置商品组时需要areauserid过滤)
+	ExcludeCfg int32 `json:"excludecfg" form:"excludecfg"`                    // 排除套保品已配置期货分类下的商品组(但显示已配置商品组) 1-排除
+}
+
+func (r *Ermcp3GoodsGroup) calc() {
+}
+
+func (r *Ermcp3GoodsGroup) buildSql() string {
+	var sqlId utils.SQLVal = "SELECT t.GOODSGROUPID," +
+		"       t.GOODSGROUPNAME," +
+		"       t.GOODSGROUPSTATUS," +
+		"       t.MARKETID," +
+		"       to_char(t.CREATETIME, 'yyyy-mm-dd hh24:mi:ss') CREATETIME," +
+		"       t.CREATORID," +
+		"       to_char(t.MODIFYTIME, 'yyyy-mm-dd hh24:mi:ss') MODIFYTIME," +
+		"       t.MODIFIERID," +
+		"       t.QUOTESOURCEGROUPID," +
+		"       t.OUTERGROUPCODE," +
+		"       t.CANSHORT," +
+		"       t.EXEXCHANGEID," +
+		"       t.CURRENCYID," +
+		"       t.GOODUNITID," +
+		"       t.AGREEUNIT," +
+		"       t.DECIMALPLACE," +
+		"       t.QUOTEMINUNIT," +
+		"       t.INNERDEALMODE," +
+		"       t.OUTERDEALMODE," +
+		"       t.SYNCGOODSQTY," +
+		"       t.CLOSEPRICEMODE," +
+		"       t.GROUPCATEGROYID" +
+		"  FROM GOODSGROUP t" +
+		" WHERE 1 = 1"
+	if r.ExcludeCfg == 1 {
+		str := "select t.goodsgroupid" +
+			"  from ERMS_MiddleGoods t" +
+			" where t.areauserid = %v" +
+			"union all" +
+			"select goodsgroupid" +
+			"  from goodsgroup t" +
+			" where t.groupcategroyid not in" +
+			"       (select distinct g.groupcategroyid" +
+			"          from erms_middlegoods t" +
+			"          left join goodsgroup g" +
+			"            on t.goodsgroupid = g.goodsgroupid" +
+			"         where t.areauserid = %v)"
+		str = fmt.Sprintf(str, r.AreaUserId, r.AreaUserId)
+		sqlId.Join(fmt.Sprintf("and t.groupcategroyid not in(%v)", str))
+	}
+	return sqlId.String()
+}
+
+// GetDataEx 商品组信息
+func (r *Ermcp3GoodsGroup) GetDataEx() (interface{}, error) {
+	sData := make([]Ermcp3GoodsGroup, 0)
+	err := db.GetEngine().SQL(r.buildSql()).Find(&sData)
+	for i := range sData {
+		sData[i].calc()
+	}
+	return sData, err
+}

+ 1 - 0
routers/router.go

@@ -431,6 +431,7 @@ func InitRouter() *gin.Engine {
 		ermcp3R.GET("/QuerySpotGoodsPrice", ermcp3.QuerySpotGoodsPrice)
 		ermcp3R.GET("/QuerySpotGoodsPriceLog", ermcp3.QuerySpotGoodsPriceLog)
 		ermcp3R.GET("/QueryHedgePlan", ermcp3.QueryHedgePlan)
+		ermcp3R.GET("/QueryGoodsGroup", ermcp3.QueryGoodsGroup)
 	}
 
 	return r