Selaa lähdekoodia

1、增加“市场节假日查询”接口;
2、错误 #3995 #3997

zhou.xiaoning 3 vuotta sitten
vanhempi
commit
fcfb83a475
6 muutettua tiedostoa jossa 279 lisäystä ja 10 poistoa
  1. 18 0
      controllers/ermcp8/qryErmcp8.go
  2. 78 2
      docs/docs.go
  3. 78 2
      docs/swagger.json
  4. 51 1
      docs/swagger.yaml
  5. 53 5
      models/ermcp8.go
  6. 1 0
      routers/router.go

+ 18 - 0
controllers/ermcp8/qryErmcp8.go

@@ -122,6 +122,7 @@ func QueryInternalUncorrelatedTradeDetail(c *gin.Context) {
 // @Security ApiKeyAuth
 // @Param areauserid query int true "企业ID"
 // @Param goodsid query int true "期货合约ID"
+// @Param tradeuserid query int true "交易用户ID"
 // @Success 200 {array} models.InternalEnableTradeDetail
 // @Failure 500 {object} app.Response
 // @Router /Ermcp8/QueryInternalEnableTradeDetail [get]
@@ -191,6 +192,7 @@ func QueryUnLinkSpotContract(c *gin.Context) {
 // @Security ApiKeyAuth
 // @Param userid query int true "用户ID"
 // @Param spottype query int true "现货类型 - 1:采购计划 2:销售计划 3:采购合同 4:销售合同 5:库存存货"
+// @Param wrstandardid query int false "现货商品ID"
 // @Success 200 {array} models.Ermcp8EnableHedgeditem
 // @Failure 500 {object} app.Response
 // @Router /Ermcp8/QueryErmcp8EnableHedgeditem [get]
@@ -339,3 +341,19 @@ func QueryErmcp2HedgedItemLink(c *gin.Context) {
 	a.DoBindReq(&m)
 	a.DoGetDataI(&m)
 }
+
+// QueryMarketCalendar
+// @Summary 市场节假日查询
+// @Produce json
+// @Security ApiKeyAuth
+// @Param marketid query int false "市场ID"
+// @Success 200 {array} models.Marketcalendar
+// @Failure 500 {object} app.Response
+// @Router /Ermcp8/QueryMarketCalendar [get]
+// @Tags 企业风险管理v8
+func QueryMarketCalendar(c *gin.Context) {
+	a := app.GinUtils{Gin: app.Gin{C: c}}
+	m := models.Marketcalendar{}
+	a.DoBindReq(&m)
+	a.DoGetDataI(&m)
+}

+ 78 - 2
docs/docs.go

@@ -6018,6 +6018,12 @@ var doc = `{
                         "name": "spottype",
                         "in": "query",
                         "required": true
+                    },
+                    {
+                        "type": "integer",
+                        "description": "现货商品ID",
+                        "name": "wrstandardid",
+                        "in": "query"
                     }
                 ],
                 "responses": {
@@ -6188,6 +6194,13 @@ var doc = `{
                         "name": "goodsid",
                         "in": "query",
                         "required": true
+                    },
+                    {
+                        "type": "integer",
+                        "description": "交易用户ID",
+                        "name": "tradeuserid",
+                        "in": "query",
+                        "required": true
                     }
                 ],
                 "responses": {
@@ -6293,6 +6306,47 @@ var doc = `{
                 }
             }
         },
+        "/Ermcp8/QueryMarketCalendar": {
+            "get": {
+                "security": [
+                    {
+                        "ApiKeyAuth": []
+                    }
+                ],
+                "produces": [
+                    "application/json"
+                ],
+                "tags": [
+                    "企业风险管理v8"
+                ],
+                "summary": "市场节假日查询",
+                "parameters": [
+                    {
+                        "type": "integer",
+                        "description": "市场ID",
+                        "name": "marketid",
+                        "in": "query"
+                    }
+                ],
+                "responses": {
+                    "200": {
+                        "description": "OK",
+                        "schema": {
+                            "type": "array",
+                            "items": {
+                                "$ref": "#/definitions/models.Marketcalendar"
+                            }
+                        }
+                    },
+                    "500": {
+                        "description": "Internal Server Error",
+                        "schema": {
+                            "$ref": "#/definitions/app.Response"
+                        }
+                    }
+                }
+            }
+        },
         "/Ermcp8/QueryPatradeLinkDetail": {
             "get": {
                 "security": [
@@ -26318,6 +26372,10 @@ var doc = `{
                 "planstartdate": {
                     "description": "计划开始日期",
                     "type": "string"
+                },
+                "wrstandardid": {
+                    "description": "现货商品ID",
+                    "type": "integer"
                 }
             }
         },
@@ -30649,7 +30707,8 @@ var doc = `{
             "type": "object",
             "required": [
                 "areauserid",
-                "goodsid"
+                "goodsid",
+                "tradeuserid"
             ],
             "properties": {
                 "agreeunit": {
@@ -30692,6 +30751,10 @@ var doc = `{
                     "description": "项目编号",
                     "type": "string"
                 },
+                "tradeuserid": {
+                    "description": "交易用户ID",
+                    "type": "integer"
+                },
                 "unexehedgeqty": {
                     "description": "未执行套期量 = 未执行现货量*折算系数* (1/(1+增值税)) * 套期比例(项目上)",
                     "type": "number"
@@ -30762,7 +30825,7 @@ var doc = `{
                     "type": "integer"
                 },
                 "enableqty": {
-                    "description": "项目可关联手数 = 成交手数 - 关联数量",
+                    "description": "项目可关联数量 = 套保品种数量 - 关联数量",
                     "type": "number"
                 },
                 "enumdicname": {
@@ -31201,6 +31264,19 @@ var doc = `{
                 }
             }
         },
+        "models.Marketcalendar": {
+            "type": "object",
+            "properties": {
+                "holidaydate": {
+                    "description": "节假日期(yyyy-MM-dd)",
+                    "type": "string"
+                },
+                "marketid": {
+                    "description": "市场ID",
+                    "type": "integer"
+                }
+            }
+        },
         "models.Marketrun": {
             "type": "object",
             "required": [

+ 78 - 2
docs/swagger.json

@@ -6002,6 +6002,12 @@
                         "name": "spottype",
                         "in": "query",
                         "required": true
+                    },
+                    {
+                        "type": "integer",
+                        "description": "现货商品ID",
+                        "name": "wrstandardid",
+                        "in": "query"
                     }
                 ],
                 "responses": {
@@ -6172,6 +6178,13 @@
                         "name": "goodsid",
                         "in": "query",
                         "required": true
+                    },
+                    {
+                        "type": "integer",
+                        "description": "交易用户ID",
+                        "name": "tradeuserid",
+                        "in": "query",
+                        "required": true
                     }
                 ],
                 "responses": {
@@ -6277,6 +6290,47 @@
                 }
             }
         },
+        "/Ermcp8/QueryMarketCalendar": {
+            "get": {
+                "security": [
+                    {
+                        "ApiKeyAuth": []
+                    }
+                ],
+                "produces": [
+                    "application/json"
+                ],
+                "tags": [
+                    "企业风险管理v8"
+                ],
+                "summary": "市场节假日查询",
+                "parameters": [
+                    {
+                        "type": "integer",
+                        "description": "市场ID",
+                        "name": "marketid",
+                        "in": "query"
+                    }
+                ],
+                "responses": {
+                    "200": {
+                        "description": "OK",
+                        "schema": {
+                            "type": "array",
+                            "items": {
+                                "$ref": "#/definitions/models.Marketcalendar"
+                            }
+                        }
+                    },
+                    "500": {
+                        "description": "Internal Server Error",
+                        "schema": {
+                            "$ref": "#/definitions/app.Response"
+                        }
+                    }
+                }
+            }
+        },
         "/Ermcp8/QueryPatradeLinkDetail": {
             "get": {
                 "security": [
@@ -26302,6 +26356,10 @@
                 "planstartdate": {
                     "description": "计划开始日期",
                     "type": "string"
+                },
+                "wrstandardid": {
+                    "description": "现货商品ID",
+                    "type": "integer"
                 }
             }
         },
@@ -30633,7 +30691,8 @@
             "type": "object",
             "required": [
                 "areauserid",
-                "goodsid"
+                "goodsid",
+                "tradeuserid"
             ],
             "properties": {
                 "agreeunit": {
@@ -30676,6 +30735,10 @@
                     "description": "项目编号",
                     "type": "string"
                 },
+                "tradeuserid": {
+                    "description": "交易用户ID",
+                    "type": "integer"
+                },
                 "unexehedgeqty": {
                     "description": "未执行套期量 = 未执行现货量*折算系数* (1/(1+增值税)) * 套期比例(项目上)",
                     "type": "number"
@@ -30746,7 +30809,7 @@
                     "type": "integer"
                 },
                 "enableqty": {
-                    "description": "项目可关联手数 = 成交手数 - 关联数量",
+                    "description": "项目可关联数量 = 套保品种数量 - 关联数量",
                     "type": "number"
                 },
                 "enumdicname": {
@@ -31185,6 +31248,19 @@
                 }
             }
         },
+        "models.Marketcalendar": {
+            "type": "object",
+            "properties": {
+                "holidaydate": {
+                    "description": "节假日期(yyyy-MM-dd)",
+                    "type": "string"
+                },
+                "marketid": {
+                    "description": "市场ID",
+                    "type": "integer"
+                }
+            }
+        },
         "models.Marketrun": {
             "type": "object",
             "required": [

+ 51 - 1
docs/swagger.yaml

@@ -7874,6 +7874,9 @@ definitions:
       planstartdate:
         description: 计划开始日期
         type: string
+      wrstandardid:
+        description: 现货商品ID
+        type: integer
     type: object
   models.Ermcp8HedgeditemReport:
     properties:
@@ -11148,6 +11151,9 @@ definitions:
       hedgeditemnum:
         description: 项目编号
         type: string
+      tradeuserid:
+        description: 交易用户ID
+        type: integer
       unexehedgeqty:
         description: 未执行套期量 = 未执行现货量*折算系数* (1/(1+增值税)) * 套期比例(项目上)
         type: number
@@ -11166,6 +11172,7 @@ definitions:
     required:
     - areauserid
     - goodsid
+    - tradeuserid
     type: object
   models.InternalUncorrelatedTradeDetail:
     properties:
@@ -11203,7 +11210,7 @@ definitions:
         description: 创建人来源 - 1:管理端 2:终端 3:交易
         type: integer
       enableqty:
-        description: 项目可关联手数 = 成交手数 - 关联数量
+        description: 项目可关联数量 = 套保品种数量 - 关联数量
         type: number
       enumdicname:
         description: 单位
@@ -11536,6 +11543,15 @@ definitions:
     - trademode
     - tradeproperty
     type: object
+  models.Marketcalendar:
+    properties:
+      holidaydate:
+        description: 节假日期(yyyy-MM-dd)
+        type: string
+      marketid:
+        description: 市场ID
+        type: integer
+    type: object
   models.Marketrun:
     properties:
       afternexttradedate:
@@ -25598,6 +25614,10 @@ paths:
         name: spottype
         required: true
         type: integer
+      - description: 现货商品ID
+        in: query
+        name: wrstandardid
+        type: integer
       produces:
       - application/json
       responses:
@@ -25707,6 +25727,11 @@ paths:
         name: goodsid
         required: true
         type: integer
+      - description: 交易用户ID
+        in: query
+        name: tradeuserid
+        required: true
+        type: integer
       produces:
       - application/json
       responses:
@@ -25779,6 +25804,31 @@ paths:
       summary: 内部未关联成交单查询
       tags:
       - 企业风险管理v8
+  /Ermcp8/QueryMarketCalendar:
+    get:
+      parameters:
+      - description: 市场ID
+        in: query
+        name: marketid
+        type: integer
+      produces:
+      - application/json
+      responses:
+        "200":
+          description: OK
+          schema:
+            items:
+              $ref: '#/definitions/models.Marketcalendar'
+            type: array
+        "500":
+          description: Internal Server Error
+          schema:
+            $ref: '#/definitions/app.Response'
+      security:
+      - ApiKeyAuth: []
+      summary: 市场节假日查询
+      tags:
+      - 企业风险管理v8
   /Ermcp8/QueryPatradeLinkDetail:
     get:
       parameters:

+ 53 - 5
models/ermcp8.go

@@ -905,8 +905,9 @@ type InternalEnableTradeDetail struct {
 	AGREEUNIT         float64 `json:"agreeunit"  xorm:"AGREEUNIT"`                 // 合约乘数
 	CONVERTRATIO      float64 `json:"convertratio"  xorm:"CONVERTRATIO"`           // 品种系数
 
-	AREAUSERID int64 `json:"areauserid"  xorm:"AREAUSERID" form:"areauserid" binding:"required"` // 企业ID
-	GOODSID    int64 `form:"goodsid" binding:"required"`                                         // 期货合约ID
+	AREAUSERID  int64 `json:"areauserid"  xorm:"AREAUSERID" form:"areauserid" binding:"required"` // 企业ID
+	GOODSID     int64 `form:"goodsid" binding:"required"`                                         // 期货合约ID
+	TRADEUSERID int64 `form:"tradeuserid" binding:"required"`                                     // 交易用户ID
 }
 
 func (r *InternalEnableTradeDetail) calc() {
@@ -940,6 +941,7 @@ func (r *InternalEnableTradeDetail) buildSql() string {
 	`
 	sqlId.And("t.AREAUSERID", r.AREAUSERID)
 	sqlId.And("g.GOODSID", r.GOODSID)
+	sqlId.And("hi.TRADEUSERID", r.TRADEUSERID)
 
 	return sqlId.String()
 }
@@ -1324,7 +1326,8 @@ type Ermcp8EnableHedgeditem struct {
 
 	ACCOUNTNAME string `json:"accountname" xorm:"ACCOUNTNAME"` // 套期主体
 
-	USERID int64 `json:"-" form:"userid" binding:"required"` // 用户ID
+	USERID       int64 `json:"-" form:"userid" binding:"required"` // 用户ID
+	WRSTANDARDID int64 `form:"wrstandardid"`                       // 现货商品ID
 }
 
 func (r *Ermcp8EnableHedgeditem) calc() {
@@ -1340,14 +1343,17 @@ func (r *Ermcp8EnableHedgeditem) buildSql() string {
 		t.HEDGEDTYPE,
 		to_char(t.PLANSTARTDATE, 'yyyy-mm-dd') PLANSTARTDATE,
 		to_char(t.PLANENDDATE, 'yyyy-mm-dd') PLANENDDATE,
-		u.ACCOUNTNAME
+		u.ACCOUNTNAME,
+		wr.WRSTANDARDNAME
 	FROM ERMCP2_HedgedItem t
 	LEFT JOIN useraccount u ON u.userid = t.tradeuserid
+	LEFT JOIN WRStandard wr ON wr.wrstandardid = t.wrstandardid
 	WHERE 
 		t.HEDGEDITEMSTATUS = 2
 		AND (t.TRADEUSERID = %v OR t.AREAUSERID = %v)
+		AND (t.WRSTANDARDID IS NULL OR t.WRSTANDARDID = %v)
 	`
-	sqlId.FormatParam(r.USERID, r.USERID)
+	sqlId.FormatParam(r.USERID, r.USERID, r.WRSTANDARDID)
 	switch r.SPOTTYPE {
 	case 1, 2:
 		sqlId.And("t.HEDGEDTYPE", r.SPOTTYPE)
@@ -2091,3 +2097,45 @@ func (r *Ermcp2hedgeditemlink) GetDataEx() (interface{}, error) {
 	}
 	return sData, nil
 }
+
+// Marketcalendar 市场节假日表
+type Marketcalendar struct {
+	MARKETID    int32  `json:"marketid"  xorm:"MARKETID" form:"marketid"` // 市场ID
+	HOLIDAYDATE string `json:"holidaydate"  xorm:"HOLIDAYDATE"`           // 节假日期(yyyy-MM-dd)
+}
+
+// TableName is MARKETCALENDAR
+func (r *Marketcalendar) TableName() string {
+	return "MARKETCALENDAR"
+}
+
+func (r *Marketcalendar) calc() {
+
+}
+
+func (r *Marketcalendar) buildSql() string {
+	var sqlId utils.SQLVal = `
+	SELECT 
+		t.MARKETID,
+		to_char(to_date(t.HOLIDAYDATE,'yyyyMMdd'), 'yyyy-MM-dd') HOLIDAYDATE
+	FROM MarketCalendar t
+	WHERE 1 = 1
+	`
+	sqlId.AndEx("t.MARKETID", r.MARKETID, r.MARKETID > 0)
+
+	return sqlId.String()
+}
+
+// GetDataEx 从数据库中查询数据
+func (r *Marketcalendar) GetDataEx() (interface{}, error) {
+	e := db.GetEngine()
+	s := e.SQL(r.buildSql())
+	sData := make([]Marketcalendar, 0)
+	if err := s.Find(&sData); err != nil {
+		return nil, err
+	}
+	for i := range sData {
+		sData[i].calc()
+	}
+	return sData, nil
+}

+ 1 - 0
routers/router.go

@@ -504,6 +504,7 @@ func InitRouter() *gin.Engine {
 		ermcp8R.GET("/QueryPatradeLinkDetail", ermcp8.QueryPatradeLinkDetail)
 		ermcp8R.GET("/QueryUnLinkErmcpHedgePlan", ermcp8.QueryUnLinkErmcpHedgePlan)
 		ermcp8R.GET("/QueryErmcp2HedgedItemLink", ermcp8.QueryErmcp2HedgedItemLink)
+		ermcp8R.GET("/QueryMarketCalendar", ermcp8.QueryMarketCalendar)
 	}
 
 	// ****************************大连千海金******************************