Преглед изворни кода

增加查询可关联套保计划接口

zou.yingbin пре 3 година
родитељ
комит
4e7ed2f7e2
6 измењених фајлова са 516 додато и 0 уклоњено
  1. 20 0
      controllers/ermcp3/qryErmcp3.go
  2. 149 0
      docs/docs.go
  3. 149 0
      docs/swagger.json
  4. 104 0
      docs/swagger.yaml
  5. 93 0
      models/ermcp3.go
  6. 1 0
      routers/router.go

+ 20 - 0
controllers/ermcp3/qryErmcp3.go

@@ -599,6 +599,26 @@ func QuerySCMiddleGoods(c *gin.Context) {
 	a.DoGetDataI(&m)
 }
 
+// QueryHPMiddleGoods
+// @Summary 查询可关联套保计划
+// @Produce json
+// @Security ApiKeyAuth
+// @Param userid query int true "用户ID(填登录用户的userid)"
+// @Param buyorsell query int true "买卖方向 0-买 1-卖"
+// @Param goodsgroupid query int true "商品组id"
+// @Param hedgeplanno query string false "套保计划编号(模糊匹配)"
+// @Param wrstandardname query string false "现货商品名称(模糊匹配)"
+// @Success 200 {array} models.Ermcp3HPMiddleGoods
+// @Failure 500 {object} app.Response
+// @Router /Ermcp3/QueryHPMiddleGoods [get]
+// @Tags 企业风险管理v3(app)
+func QueryHPMiddleGoods(c *gin.Context) {
+	a := app.GinUtils{Gin: app.Gin{C: c}}
+	m := models.Ermcp3HPMiddleGoods{}
+	a.DoBindReq(&m)
+	a.DoGetDataI(&m)
+}
+
 // QueryPaTradeLinkDetail
 // @Summary 查询期现关联记录
 // @Description 页面 app 现货->期现关联->关联记录

+ 149 - 0
docs/docs.go

@@ -4569,6 +4569,74 @@ var doc = `{
                 }
             }
         },
+        "/Ermcp3/QueryHPMiddleGoods": {
+            "get": {
+                "security": [
+                    {
+                        "ApiKeyAuth": []
+                    }
+                ],
+                "produces": [
+                    "application/json"
+                ],
+                "tags": [
+                    "企业风险管理v3(app)"
+                ],
+                "summary": "查询可关联套保计划",
+                "parameters": [
+                    {
+                        "type": "integer",
+                        "description": "用户ID(填登录用户的userid)",
+                        "name": "userid",
+                        "in": "query",
+                        "required": true
+                    },
+                    {
+                        "type": "integer",
+                        "description": "买卖方向 0-买 1-卖",
+                        "name": "buyorsell",
+                        "in": "query",
+                        "required": true
+                    },
+                    {
+                        "type": "integer",
+                        "description": "商品组id",
+                        "name": "goodsgroupid",
+                        "in": "query",
+                        "required": true
+                    },
+                    {
+                        "type": "string",
+                        "description": "套保计划编号(模糊匹配)",
+                        "name": "hedgeplanno",
+                        "in": "query"
+                    },
+                    {
+                        "type": "string",
+                        "description": "现货商品名称(模糊匹配)",
+                        "name": "wrstandardname",
+                        "in": "query"
+                    }
+                ],
+                "responses": {
+                    "200": {
+                        "description": "OK",
+                        "schema": {
+                            "type": "array",
+                            "items": {
+                                "$ref": "#/definitions/models.Ermcp3HPMiddleGoods"
+                            }
+                        }
+                    },
+                    "500": {
+                        "description": "Internal Server Error",
+                        "schema": {
+                            "$ref": "#/definitions/app.Response"
+                        }
+                    }
+                }
+            }
+        },
         "/Ermcp3/QueryHedgePlan": {
             "get": {
                 "security": [
@@ -22111,6 +22179,87 @@ var doc = `{
                 }
             }
         },
+        "models.Ermcp3HPMiddleGoods": {
+            "type": "object",
+            "properties": {
+                "biztype": {
+                    "description": "业务类型 1:套保 2:套利",
+                    "type": "integer"
+                },
+                "contracttype": {
+                    "description": "合同类型 1:采购 -1:销售",
+                    "type": "integer"
+                },
+                "convertratio": {
+                    "description": "折算系数",
+                    "type": "number"
+                },
+                "customername": {
+                    "description": "对手手名称",
+                    "type": "string"
+                },
+                "customeruserid": {
+                    "description": "对手id",
+                    "type": "integer"
+                },
+                "enumdicname": {
+                    "description": "现货单位名称",
+                    "type": "string"
+                },
+                "hedgeplanid": {
+                    "description": "计划id",
+                    "type": "string"
+                },
+                "hedgeplanno": {
+                    "description": "计划编号",
+                    "type": "string"
+                },
+                "middlegoodsid": {
+                    "description": "套保品种ID",
+                    "type": "integer"
+                },
+                "middlegoodsplanqty3": {
+                    "description": "应套保计划量",
+                    "type": "number"
+                },
+                "needhedgeratio": {
+                    "description": "套保比例",
+                    "type": "number"
+                },
+                "pricedqty": {
+                    "description": "已定价量",
+                    "type": "number"
+                },
+                "relatedmiddlegoodsqty": {
+                    "description": "已关联量(套保品种)(期货)",
+                    "type": "number"
+                },
+                "unitid": {
+                    "description": "现货单位id",
+                    "type": "integer"
+                },
+                "userid": {
+                    "description": "用户id",
+                    "type": "integer"
+                },
+                "vatrate": {
+                    "description": "增值税率",
+                    "type": "number"
+                },
+                "wrstandardcode": {
+                    "description": "现货商品代码",
+                    "type": "string"
+                },
+                "wrstandardid": {
+                    "description": "现货商品id",
+                    "type": "integer"
+                },
+                "wrstandardname": {
+                    "description": "现货商品名称",
+                    "type": "string"
+                }
+            }
+        },
         "models.Ermcp3HedgePlan": {
             "type": "object",
             "properties": {

+ 149 - 0
docs/swagger.json

@@ -4554,6 +4554,74 @@
                 }
             }
         },
+        "/Ermcp3/QueryHPMiddleGoods": {
+            "get": {
+                "security": [
+                    {
+                        "ApiKeyAuth": []
+                    }
+                ],
+                "produces": [
+                    "application/json"
+                ],
+                "tags": [
+                    "企业风险管理v3(app)"
+                ],
+                "summary": "查询可关联套保计划",
+                "parameters": [
+                    {
+                        "type": "integer",
+                        "description": "用户ID(填登录用户的userid)",
+                        "name": "userid",
+                        "in": "query",
+                        "required": true
+                    },
+                    {
+                        "type": "integer",
+                        "description": "买卖方向 0-买 1-卖",
+                        "name": "buyorsell",
+                        "in": "query",
+                        "required": true
+                    },
+                    {
+                        "type": "integer",
+                        "description": "商品组id",
+                        "name": "goodsgroupid",
+                        "in": "query",
+                        "required": true
+                    },
+                    {
+                        "type": "string",
+                        "description": "套保计划编号(模糊匹配)",
+                        "name": "hedgeplanno",
+                        "in": "query"
+                    },
+                    {
+                        "type": "string",
+                        "description": "现货商品名称(模糊匹配)",
+                        "name": "wrstandardname",
+                        "in": "query"
+                    }
+                ],
+                "responses": {
+                    "200": {
+                        "description": "OK",
+                        "schema": {
+                            "type": "array",
+                            "items": {
+                                "$ref": "#/definitions/models.Ermcp3HPMiddleGoods"
+                            }
+                        }
+                    },
+                    "500": {
+                        "description": "Internal Server Error",
+                        "schema": {
+                            "$ref": "#/definitions/app.Response"
+                        }
+                    }
+                }
+            }
+        },
         "/Ermcp3/QueryHedgePlan": {
             "get": {
                 "security": [
@@ -22096,6 +22164,87 @@
                 }
             }
         },
+        "models.Ermcp3HPMiddleGoods": {
+            "type": "object",
+            "properties": {
+                "biztype": {
+                    "description": "业务类型 1:套保 2:套利",
+                    "type": "integer"
+                },
+                "contracttype": {
+                    "description": "合同类型 1:采购 -1:销售",
+                    "type": "integer"
+                },
+                "convertratio": {
+                    "description": "折算系数",
+                    "type": "number"
+                },
+                "customername": {
+                    "description": "对手手名称",
+                    "type": "string"
+                },
+                "customeruserid": {
+                    "description": "对手id",
+                    "type": "integer"
+                },
+                "enumdicname": {
+                    "description": "现货单位名称",
+                    "type": "string"
+                },
+                "hedgeplanid": {
+                    "description": "计划id",
+                    "type": "string"
+                },
+                "hedgeplanno": {
+                    "description": "计划编号",
+                    "type": "string"
+                },
+                "middlegoodsid": {
+                    "description": "套保品种ID",
+                    "type": "integer"
+                },
+                "middlegoodsplanqty3": {
+                    "description": "应套保计划量",
+                    "type": "number"
+                },
+                "needhedgeratio": {
+                    "description": "套保比例",
+                    "type": "number"
+                },
+                "pricedqty": {
+                    "description": "已定价量",
+                    "type": "number"
+                },
+                "relatedmiddlegoodsqty": {
+                    "description": "已关联量(套保品种)(期货)",
+                    "type": "number"
+                },
+                "unitid": {
+                    "description": "现货单位id",
+                    "type": "integer"
+                },
+                "userid": {
+                    "description": "用户id",
+                    "type": "integer"
+                },
+                "vatrate": {
+                    "description": "增值税率",
+                    "type": "number"
+                },
+                "wrstandardcode": {
+                    "description": "现货商品代码",
+                    "type": "string"
+                },
+                "wrstandardid": {
+                    "description": "现货商品id",
+                    "type": "integer"
+                },
+                "wrstandardname": {
+                    "description": "现货商品名称",
+                    "type": "string"
+                }
+            }
+        },
         "models.Ermcp3HedgePlan": {
             "type": "object",
             "properties": {

+ 104 - 0
docs/swagger.yaml

@@ -5595,6 +5595,66 @@ definitions:
     required:
     - areauserid
     type: object
+  models.Ermcp3HPMiddleGoods:
+    properties:
+      biztype:
+        description: 业务类型 1:套保 2:套利
+        type: integer
+      contracttype:
+        description: 合同类型 1:采购 -1:销售
+        type: integer
+      convertratio:
+        description: 折算系数
+        type: number
+      customername:
+        description: 对手手名称
+        type: string
+      customeruserid:
+        description: 对手id
+        type: integer
+      enumdicname:
+        description: 现货单位名称
+        type: string
+      hedgeplanid:
+        description: 计划id
+        type: string
+      hedgeplanno:
+        description: 计划编号
+        type: string
+      middlegoodsid:
+        description: 套保品种ID
+        type: integer
+      middlegoodsplanqty3:
+        description: 应套保计划量
+        type: number
+      needhedgeratio:
+        description: 套保比例
+        type: number
+      pricedqty:
+        description: 已定价量
+        type: number
+      relatedmiddlegoodsqty:
+        description: 已关联量(套保品种)(期货)
+        type: number
+      unitid:
+        description: 现货单位id
+        type: integer
+      userid:
+        description: 用户id
+        type: integer
+      vatrate:
+        description: 增值税率
+        type: number
+      wrstandardcode:
+        description: 现货商品代码
+        type: string
+      wrstandardid:
+        description: 现货商品id
+        type: integer
+      wrstandardname:
+        description: 现货商品名称
+        type: string
+    type: object
   models.Ermcp3HedgePlan:
     properties:
       accountid:
@@ -22755,6 +22815,50 @@ paths:
       summary: 查询商品品牌
       tags:
       - 企业风险管理v3(app)
+  /Ermcp3/QueryHPMiddleGoods:
+    get:
+      parameters:
+      - description: 用户ID(填登录用户的userid)
+        in: query
+        name: userid
+        required: true
+        type: integer
+      - description: 买卖方向 0-买 1-卖
+        in: query
+        name: buyorsell
+        required: true
+        type: integer
+      - description: 商品组id
+        in: query
+        name: goodsgroupid
+        required: true
+        type: integer
+      - description: 套保计划编号(模糊匹配)
+        in: query
+        name: hedgeplanno
+        type: string
+      - description: 现货商品名称(模糊匹配)
+        in: query
+        name: wrstandardname
+        type: string
+      produces:
+      - application/json
+      responses:
+        "200":
+          description: OK
+          schema:
+            items:
+              $ref: '#/definitions/models.Ermcp3HPMiddleGoods'
+            type: array
+        "500":
+          description: Internal Server Error
+          schema:
+            $ref: '#/definitions/app.Response'
+      security:
+      - ApiKeyAuth: []
+      summary: 查询可关联套保计划
+      tags:
+      - 企业风险管理v3(app)
   /Ermcp3/QueryHedgePlan:
     get:
       parameters:

+ 93 - 0
models/ermcp3.go

@@ -3273,6 +3273,99 @@ func (r *Ermcp3SCMiddleGoods) GetDataEx() (interface{}, error) {
 	return sData, err
 }
 
+// Ermcp3HPMiddleGoods 业务关联套保计划
+type Ermcp3HPMiddleGoods struct {
+	USERID                int64   `json:"userid"  xorm:"'USERID'" form:"userid"`                         // 用户id
+	CUSTOMERUSERID        int64   `json:"customeruserid"  xorm:"'CUSTOMERUSERID'"`                       // 对手id
+	CUSTOMERNAME          string  `json:"customername"  xorm:"'CUSTOMERNAME'" form:"customername"`       // 对手手名称
+	HEDGEPLANNO           string  `json:"hedgeplanno"  xorm:"'HEDGEPLANNO'" form:"hedgeplanno"`          // 计划编号
+	HEDGEPLANID           string  `json:"hedgeplanid"  xorm:"'HEDGEPLANID'"`                             // 计划id
+	WRSTANDARDID          int64   `json:"wrstandardid"  xorm:"'WRSTANDARDID'"`                           // 现货商品id
+	WRSTANDARDCODE        string  `json:"wrstandardcode"  xorm:"'WRSTANDARDCODE'"`                       // 现货商品代码
+	WRSTANDARDNAME        string  `json:"wrstandardname"  xorm:"'WRSTANDARDNAME'" form:"wrstandardname"` // 现货商品名称
+	UNITID                int32   `json:"unitid"  xorm:"'UNITID'"`                                       // 现货单位id
+	VATRATE               float64 `json:"vatrate"  xorm:"'VATRATE'"`                                     // 增值税率
+	MIDDLEGOODSPLANQTY3   float64 `json:"middlegoodsplanqty3"  xorm:"'middlegoodsplanqty3'"`             // 应套保计划量
+	RELATEDMIDDLEGOODSQTY float64 `json:"relatedmiddlegoodsqty"  xorm:"'RELATEDMIDDLEGOODSQTY'"`         // 已关联量(套保品种)(期货)
+	PRICEDQTY             float64 `json:"pricedqty"  xorm:"'PRICEDQTY'"`                                 // 已定价量
+	MIDDLEGOODSID         int64   `json:"middlegoodsid"  xorm:"'MIDDLEGOODSID'"`                         // 套保品种ID
+	NEEDHEDGERATIO        float64 `json:"needhedgeratio"  xorm:"'NEEDHEDGERATIO'"`                       // 套保比例
+	CONTRACTTYPE          int     `json:"contracttype"  xorm:"'CONTRACTTYPE'"`                           // 合同类型 1:采购 -1:销售
+	ENUMDICNAME           string  `json:"enumdicname"  xorm:"'ENUMDICNAME'"`                             // 现货单位名称
+	BIZTYPE               int     `json:"biztype"  xorm:"'BIZTYPE'" form:"biztype"`                      // 业务类型 1:套保 2:套利
+	CONVERTRATIO          float64 `json:"convertratio"  xorm:"'CONVERTRATIO'"`                           // 折算系数
+
+	BUYORSELL    int32 `json:"-" form:"buyorsell"`    // 买卖方向, 用作筛选
+	GOODSGROUPID int32 `json:"-" form:"goodsgroupid"` // 期货商品组id, 用作筛选
+}
+
+func (r *Ermcp3HPMiddleGoods) calc() {
+
+}
+
+func (r *Ermcp3HPMiddleGoods) buildSql() string {
+	var sqlId utils.SQLVal = `
+with tmp as
+ (select k.configid,
+         k.srcgoodsgroupid,
+         k.destgoodsgroupid,
+         k.convertratio,
+         m.middlegoodsid
+    from ermcp_ggconvertconfig k
+   inner join erms_middlegoods m
+      on k.destgoodsgroupid = m.goodsgroupid)
+select s.areauserid userid,
+       s.hedgeplanno,
+       s.contracttype,
+       s.biztype,
+       to_char(s.hedgeplanid) hedgeplanid,
+       w.wrstandardid,
+       w.wrstandardcode,
+       w.wrstandardname,
+       w.unitid,
+       w.vatrate,
+       t.middlegoodsplanqty3,
+       t.relatedmiddlegoodsqty,
+       t.planqty,
+       t.middlegoodsid,
+       mg.needhedgeratio,
+       e.enumdicname,
+       tmp.convertratio
+  from ermcp_hpmiddlegoods t
+ inner join ermcp_hedgeplan s
+    on t.hedgeplanid = s.hedgeplanid
+  left join wrstandard w
+    on t.wrstandardid = w.wrstandardid
+  left join erms_middlegoods mg
+    on t.middlegoodsid = mg.middlegoodsid
+  left join enumdicitem e on w.unitid=e.enumitemname and e.enumdiccode='goodsunit'
+  inner join tmp on t.middlegoodsid=tmp.middlegoodsid and tmp.srcgoodsgroupid = %v
+ where 1 = 1 and t.middlegoodsplanqty3 > t.relatedmiddlegoodsqty and s.hedgeplanstatus = 2
+`
+	sqlId.FormatParam(r.GOODSGROUPID)
+	if r.BUYORSELL == 0 {
+		r.CONTRACTTYPE = -1
+	} else {
+		r.CONTRACTTYPE = 1
+	}
+	sqlId.And("s.CONTRACTTYPE", r.CONTRACTTYPE)
+	sqlId.JoinFormat(" and %v in(s.areauserid, s.tradeuserid)", r.USERID)
+	sqlId.AndLike("s.HEDGEPLANNO", r.HEDGEPLANNO)
+	sqlId.AndLike("w.wrstandardname", r.WRSTANDARDNAME)
+
+	return sqlId.String()
+}
+
+// GetDataEx 获取业务关联套保计划
+func (r *Ermcp3HPMiddleGoods) GetDataEx() (interface{}, error) {
+	sData := make([]Ermcp3HPMiddleGoods, 0)
+	err := db.GetEngine().SQL(r.buildSql()).Find(&sData)
+	for i := range sData {
+		sData[i].calc()
+	}
+	return sData, err
+}
+
 // Ermcp3TradeLinkDetail 期现关联记录
 type Ermcp3TradeLinkDetail struct {
 	LINKDETAILID   string  `json:"linkdetailid"  xorm:"LINKDETAILID" form:"linkdetailid"`       // 关联ID(614+Unix秒时间戳(10位)+xxxxxx)

+ 1 - 0
routers/router.go

@@ -452,6 +452,7 @@ func InitRouter() *gin.Engine {
 		ermcp3R.GET("/QueryPaAreaAuditCfg", ermcp3.QueryPaAreaAuditCfg)
 		ermcp3R.GET("/QueryPaTradeLink", ermcp3.QueryPaTradeLink)
 		ermcp3R.GET("/QuerySCMiddleGoods", ermcp3.QuerySCMiddleGoods)
+		ermcp3R.GET("/QueryHPMiddleGoods", ermcp3.QueryHPMiddleGoods)
 		ermcp3R.GET("/QueryPaTradeLinkDetail", ermcp3.QueryPaTradeLinkDetail)
 		ermcp3R.GET("/QueryOutTradeLink", ermcp3.QueryOutTradeLink)
 		ermcp3R.GET("/QuerySubTaaccount", ermcp3.QuerySubTaaccount)