Procházet zdrojové kódy

增加铁合金获取现货行情接口

zhou.xiaoning před 3 roky
rodič
revize
3988a8a7c1
6 změnil soubory, kde provedl 405 přidání a 0 odebrání
  1. 27 0
      controllers/ferroalloy/quote.go
  2. 110 0
      docs/docs.go
  3. 110 0
      docs/swagger.json
  4. 73 0
      docs/swagger.yaml
  5. 77 0
      models/ferroalloy.go
  6. 8 0
      routers/router.go

+ 27 - 0
controllers/ferroalloy/quote.go

@@ -0,0 +1,27 @@
+package ferroalloy
+
+import (
+	"mtp2_if/global/app"
+	"mtp2_if/models"
+
+	"github.com/gin-gonic/gin"
+)
+
+// GetSpotGoodsPrice
+// @Summary  获取现货行情
+// @Produce  json
+// @Security ApiKeyAuth
+// @Security LoginID
+// @Security Group
+// @Param    page     query    int false "页码"
+// @Param    pagesize query    int false "每页条数"
+// @Success  200      {array}  models.GErmcpspotgoodsprice
+// @Failure  500      {object} app.Response
+// @Router   /Ferroalloy/GetSpotGoodsPrice [get]
+// @Tags     铁合金
+func GetSpotGoodsPrice(c *gin.Context) {
+	a := app.GinUtils{Gin: app.Gin{C: c}}
+	m := models.GErmcpspotgoodsprice{}
+	a.DoBindReq(&m)
+	a.DoGetDataByPage(&m)
+}

+ 110 - 0
docs/docs.go

@@ -7549,6 +7549,59 @@ const docTemplate = `{
                 }
             }
         },
+        "/Ferroalloy/GetSpotGoodsPrice": {
+            "get": {
+                "security": [
+                    {
+                        "ApiKeyAuth": []
+                    },
+                    {
+                        "LoginID": []
+                    },
+                    {
+                        "Group": []
+                    }
+                ],
+                "produces": [
+                    "application/json"
+                ],
+                "tags": [
+                    "铁合金"
+                ],
+                "summary": "获取现货行情",
+                "parameters": [
+                    {
+                        "type": "integer",
+                        "description": "页码",
+                        "name": "page",
+                        "in": "query"
+                    },
+                    {
+                        "type": "integer",
+                        "description": "每页条数",
+                        "name": "pagesize",
+                        "in": "query"
+                    }
+                ],
+                "responses": {
+                    "200": {
+                        "description": "OK",
+                        "schema": {
+                            "type": "array",
+                            "items": {
+                                "$ref": "#/definitions/models.GErmcpspotgoodsprice"
+                            }
+                        }
+                    },
+                    "500": {
+                        "description": "Internal Server Error",
+                        "schema": {
+                            "$ref": "#/definitions/app.Response"
+                        }
+                    }
+                }
+            }
+        },
         "/Guangzuan/GZBSFWOrderOperate": {
             "get": {
                 "security": [
@@ -29758,6 +29811,63 @@ const docTemplate = `{
                 }
             }
         },
+        "models.GErmcpspotgoodsprice": {
+            "type": "object",
+            "properties": {
+                "currencyid": {
+                    "description": "报价货币ID",
+                    "type": "integer"
+                },
+                "deliverygoodsid": {
+                    "description": "现货品种ID",
+                    "type": "integer"
+                },
+                "spotgoodsbrandid": {
+                    "description": "现货品牌ID(通用则为0, 不为0则须先有商品ID)",
+                    "type": "integer"
+                },
+                "spotgoodsprice": {
+                    "description": "【最新价】当前价格",
+                    "type": "number"
+                },
+                "srcmarketname": {
+                    "description": "来源市场名称",
+                    "type": "string"
+                },
+                "todaypricedtotalamount": {
+                    "description": "今日定价金额",
+                    "type": "number"
+                },
+                "todaypricedtotalqty": {
+                    "description": "今日定价总量",
+                    "type": "number"
+                },
+                "todayspotgoodsprice": {
+                    "description": "今日指定价",
+                    "type": "number"
+                },
+                "tradedate": {
+                    "description": "【日期】交易日",
+                    "type": "string"
+                },
+                "wrstandardcode": {
+                    "description": "现货商品代码",
+                    "type": "string"
+                },
+                "wrstandardid": {
+                    "description": "现货商品ID(通用则为0)",
+                    "type": "integer"
+                },
+                "wrstandardname": {
+                    "description": "【名称】现货商品名称",
+                    "type": "string"
+                },
+                "ystspotgoodsprice": {
+                    "description": "昨价",
+                    "type": "number"
+                }
+            }
+        },
         "models.GZGoods": {
             "type": "object",
             "required": [

+ 110 - 0
docs/swagger.json

@@ -7540,6 +7540,59 @@
                 }
             }
         },
+        "/Ferroalloy/GetSpotGoodsPrice": {
+            "get": {
+                "security": [
+                    {
+                        "ApiKeyAuth": []
+                    },
+                    {
+                        "LoginID": []
+                    },
+                    {
+                        "Group": []
+                    }
+                ],
+                "produces": [
+                    "application/json"
+                ],
+                "tags": [
+                    "铁合金"
+                ],
+                "summary": "获取现货行情",
+                "parameters": [
+                    {
+                        "type": "integer",
+                        "description": "页码",
+                        "name": "page",
+                        "in": "query"
+                    },
+                    {
+                        "type": "integer",
+                        "description": "每页条数",
+                        "name": "pagesize",
+                        "in": "query"
+                    }
+                ],
+                "responses": {
+                    "200": {
+                        "description": "OK",
+                        "schema": {
+                            "type": "array",
+                            "items": {
+                                "$ref": "#/definitions/models.GErmcpspotgoodsprice"
+                            }
+                        }
+                    },
+                    "500": {
+                        "description": "Internal Server Error",
+                        "schema": {
+                            "$ref": "#/definitions/app.Response"
+                        }
+                    }
+                }
+            }
+        },
         "/Guangzuan/GZBSFWOrderOperate": {
             "get": {
                 "security": [
@@ -29749,6 +29802,63 @@
                 }
             }
         },
+        "models.GErmcpspotgoodsprice": {
+            "type": "object",
+            "properties": {
+                "currencyid": {
+                    "description": "报价货币ID",
+                    "type": "integer"
+                },
+                "deliverygoodsid": {
+                    "description": "现货品种ID",
+                    "type": "integer"
+                },
+                "spotgoodsbrandid": {
+                    "description": "现货品牌ID(通用则为0, 不为0则须先有商品ID)",
+                    "type": "integer"
+                },
+                "spotgoodsprice": {
+                    "description": "【最新价】当前价格",
+                    "type": "number"
+                },
+                "srcmarketname": {
+                    "description": "来源市场名称",
+                    "type": "string"
+                },
+                "todaypricedtotalamount": {
+                    "description": "今日定价金额",
+                    "type": "number"
+                },
+                "todaypricedtotalqty": {
+                    "description": "今日定价总量",
+                    "type": "number"
+                },
+                "todayspotgoodsprice": {
+                    "description": "今日指定价",
+                    "type": "number"
+                },
+                "tradedate": {
+                    "description": "【日期】交易日",
+                    "type": "string"
+                },
+                "wrstandardcode": {
+                    "description": "现货商品代码",
+                    "type": "string"
+                },
+                "wrstandardid": {
+                    "description": "现货商品ID(通用则为0)",
+                    "type": "integer"
+                },
+                "wrstandardname": {
+                    "description": "【名称】现货商品名称",
+                    "type": "string"
+                },
+                "ystspotgoodsprice": {
+                    "description": "昨价",
+                    "type": "number"
+                }
+            }
+        },
         "models.GZGoods": {
             "type": "object",
             "required": [

+ 73 - 0
docs/swagger.yaml

@@ -9643,6 +9643,48 @@ definitions:
     required:
     - resourcecode
     type: object
+  models.GErmcpspotgoodsprice:
+    properties:
+      currencyid:
+        description: 报价货币ID
+        type: integer
+      deliverygoodsid:
+        description: 现货品种ID
+        type: integer
+      spotgoodsbrandid:
+        description: 现货品牌ID(通用则为0, 不为0则须先有商品ID)
+        type: integer
+      spotgoodsprice:
+        description: 【最新价】当前价格
+        type: number
+      srcmarketname:
+        description: 来源市场名称
+        type: string
+      todaypricedtotalamount:
+        description: 今日定价金额
+        type: number
+      todaypricedtotalqty:
+        description: 今日定价总量
+        type: number
+      todayspotgoodsprice:
+        description: 今日指定价
+        type: number
+      tradedate:
+        description: 【日期】交易日
+        type: string
+      wrstandardcode:
+        description: 现货商品代码
+        type: string
+      wrstandardid:
+        description: 现货商品ID(通用则为0)
+        type: integer
+      wrstandardname:
+        description: 【名称】现货商品名称
+        type: string
+      ystspotgoodsprice:
+        description: 昨价
+        type: number
+    type: object
   models.GZGoods:
     properties:
       address:
@@ -28133,6 +28175,37 @@ paths:
       summary: 客户信息查询
       tags:
       - 风险管理v3
+  /Ferroalloy/GetSpotGoodsPrice:
+    get:
+      parameters:
+      - description: 页码
+        in: query
+        name: page
+        type: integer
+      - description: 每页条数
+        in: query
+        name: pagesize
+        type: integer
+      produces:
+      - application/json
+      responses:
+        "200":
+          description: OK
+          schema:
+            items:
+              $ref: '#/definitions/models.GErmcpspotgoodsprice'
+            type: array
+        "500":
+          description: Internal Server Error
+          schema:
+            $ref: '#/definitions/app.Response'
+      security:
+      - ApiKeyAuth: []
+      - LoginID: []
+      - Group: []
+      summary: 获取现货行情
+      tags:
+      - 铁合金
   /Guangzuan/GZBSFWOrderOperate:
     get:
       parameters:

+ 77 - 0
models/ferroalloy.go

@@ -0,0 +1,77 @@
+package models
+
+import (
+	"fmt"
+	"mtp2_if/db"
+	"mtp2_if/utils"
+	"time"
+)
+
+// 上海铁合金项目
+
+// GErmcpspotgoodsprice 现货市价表
+type GErmcpspotgoodsprice struct {
+	DELIVERYGOODSID        int32     `json:"deliverygoodsid" xorm:"DELIVERYGOODSID"`               // 现货品种ID
+	WRSTANDARDID           int64     `json:"wrstandardid" xorm:"WRSTANDARDID"`                     // 现货商品ID(通用则为0)
+	SPOTGOODSBRANDID       int32     `json:"spotgoodsbrandid" xorm:"SPOTGOODSBRANDID"`             // 现货品牌ID(通用则为0, 不为0则须先有商品ID)
+	CURRENCYID             int64     `json:"currencyid" xorm:"CURRENCYID"`                         // 报价货币ID
+	SPOTGOODSPRICE         float64   `json:"spotgoodsprice" xorm:"SPOTGOODSPRICE"`                 // 【最新价】当前价格
+	TRADEDATE              string    `json:"tradedate" xorm:"TRADEDATE"`                           // 【日期】交易日
+	OPERATESRC             int32     `json:"-" xorm:"OPERATESRC"`                                  // 最后操作来源 - 1:管理端 2:终端
+	OPERATEID              int64     `json:"-" xorm:"OPERATEID"`                                   // 最后操作人
+	OPERATETIME            time.Time `json:"-" xorm:"OPERATETIME"`                                 // 最后操作时间
+	ISVALID                int32     `json:"-" xorm:"ISVALID"`                                     // 是否有效 - 0:无效 1:有效
+	YSTSPOTGOODSPRICE      float64   `json:"ystspotgoodsprice" xorm:"YSTSPOTGOODSPRICE"`           // 昨价
+	TODAYSPOTGOODSPRICE    float64   `json:"todayspotgoodsprice" xorm:"TODAYSPOTGOODSPRICE"`       // 今日指定价
+	TODAYPRICEDTOTALQTY    float64   `json:"todaypricedtotalqty" xorm:"TODAYPRICEDTOTALQTY"`       // 今日定价总量
+	TODAYPRICEDTOTALAMOUNT float64   `json:"todaypricedtotalamount" xorm:"TODAYPRICEDTOTALAMOUNT"` // 今日定价金额
+	SRCMARKETNAME          string    `json:"srcmarketname" xorm:"SRCMARKETNAME"`                   // 来源市场名称
+
+	WRSTANDARDCODE string `json:"wrstandardcode" xorm:"WRSTANDARDCODE"` // 现货商品代码
+	WRSTANDARDNAME string `json:"wrstandardname" xorm:"WRSTANDARDNAME"` // 【名称】现货商品名称
+
+	PageEx `xorm:"extends"` // 页码信息
+}
+
+func (r *GErmcpspotgoodsprice) calc() {
+	if len(r.TRADEDATE) == 8 {
+		r.TRADEDATE = fmt.Sprintf("%v-%v-%v\n", r.TRADEDATE[0:4], r.TRADEDATE[4:6], r.TRADEDATE[6:8])
+	}
+}
+
+func (r *GErmcpspotgoodsprice) buildSql() string {
+	var sqlId utils.SQLVal = `
+	SELECT 
+		t.DELIVERYGOODSID       ,
+		t.WRSTANDARDID          ,
+		t.SPOTGOODSBRANDID      ,
+		t.CURRENCYID            ,
+		t.SPOTGOODSPRICE        ,
+		t.TRADEDATE             ,
+		t.YSTSPOTGOODSPRICE     ,
+		t.TODAYSPOTGOODSPRICE   ,
+		t.TODAYPRICEDTOTALQTY   ,
+		t.TODAYPRICEDTOTALAMOUNT,
+		t.SRCMARKETNAME,
+		w.WRSTANDARDCODE,
+		w.WRSTANDARDNAME         
+	FROM ERMCP_SPOTGOODSPRICE t
+	LEFT JOIN WRStandard w ON t.WRSTANDARDID = w.WRSTANDARDID
+	WHERE t.SPOTGOODSBRANDID = 0 AND t.CURRENCYID = 1 AND t.ISVALID = 1
+	`
+	sqlId.OrderByDesc("w.WRSTANDARDNAME")
+
+	sqlId.Page(r.Page, r.PageSize)
+	return sqlId.String()
+}
+
+func (r *GErmcpspotgoodsprice) GetDataByPage() (interface{}, error, int, int, int) {
+	sData := make([]GErmcpspotgoodsprice, 0)
+	err := db.GetEngine().SQL(r.buildSql()).Find(&sData)
+	total := 0
+	for i := range sData {
+		sData[i].calc()
+		total = sData[i].Total
+	}
+	return sData, err, r.Page, r.PageSize, total
+}

+ 8 - 0
routers/router.go

@@ -11,6 +11,7 @@ import (
 	"mtp2_if/controllers/ermcp8"
 	"mtp2_if/controllers/erms2"
 	"mtp2_if/controllers/erms3"
+	"mtp2_if/controllers/ferroalloy"
 	"mtp2_if/controllers/guangzuan"
 	"mtp2_if/controllers/hsby"
 	"mtp2_if/controllers/market"
@@ -684,6 +685,13 @@ func InitRouter() *gin.Engine {
 		guangzuanR.GET("QueryTradeReport", guangzuan.QueryTradeReport)
 	}
 
+	// **************************上海铁合金*************************
+	ferroalloyR := apiR.Group("Ferroalloy")
+	ferroalloyR.Use(token.Auth())
+	{
+		ferroalloyR.GET("GetSpotGoodsPrice", ferroalloy.GetSpotGoodsPrice)
+	}
+
 	return r
 }