Procházet zdrojové kódy

增加查询仓单持有记录接口

zou.yingbin před 4 roky
rodič
revize
608defe560
6 změnil soubory, kde provedl 498 přidání a 1 odebrání
  1. 16 0
      controllers/wrTrade2/qryWrTrade.go
  2. 147 0
      docs/docs.go
  3. 147 0
      docs/swagger.json
  4. 104 0
      docs/swagger.yaml
  5. 83 1
      models/wrTrade2.go
  6. 1 0
      routers/router.go

+ 16 - 0
controllers/wrTrade2/qryWrTrade.go

@@ -172,3 +172,19 @@ func QueryPerformancePlan(c *gin.Context) {
 	a.DoBindReq(&m)
 	a.DoGetDataI(&m)
 }
+
+// QueryHoldLB
+// @Summary 查询仓单持有记录
+// @Produce json
+// @Security ApiKeyAuth
+// @Param accountid query int true "资金账号"
+// @Success 200 {array} models.WrHoldLB
+// @Failure 500 {object} app.Response
+// @Router /WrTrade2/QueryHoldLB [get]
+// @Tags 仓单贸易v2
+func QueryHoldLB(c *gin.Context) {
+	a := app.GinUtils{Gin: app.Gin{C: c}}
+	m := models.WrHoldLB{}
+	a.DoBindReq(&m)
+	a.DoGetDataI(&m)
+}

+ 147 - 0
docs/docs.go

@@ -10921,6 +10921,48 @@ var doc = `{
                 }
             }
         },
+        "/WrTrade2/QueryHoldLB": {
+            "get": {
+                "security": [
+                    {
+                        "ApiKeyAuth": []
+                    }
+                ],
+                "produces": [
+                    "application/json"
+                ],
+                "tags": [
+                    "仓单贸易v2"
+                ],
+                "summary": "查询仓单持有记录",
+                "parameters": [
+                    {
+                        "type": "integer",
+                        "description": "资金账号",
+                        "name": "accountid",
+                        "in": "query",
+                        "required": true
+                    }
+                ],
+                "responses": {
+                    "200": {
+                        "description": "OK",
+                        "schema": {
+                            "type": "array",
+                            "items": {
+                                "$ref": "#/definitions/models.WrHoldLB"
+                            }
+                        }
+                    },
+                    "500": {
+                        "description": "Internal Server Error",
+                        "schema": {
+                            "$ref": "#/definitions/app.Response"
+                        }
+                    }
+                }
+            }
+        },
         "/WrTrade2/QueryOrderQuote": {
             "get": {
                 "security": [
@@ -29345,6 +29387,111 @@ var doc = `{
                 }
             }
         },
+        "models.WrHoldLB": {
+            "type": "object",
+            "properties": {
+                "accountid": {
+                    "description": "持有人帐户ID",
+                    "type": "integer"
+                },
+                "createtime": {
+                    "description": "创建时间(过户时间)",
+                    "type": "string"
+                },
+                "deliverygoodscode": {
+                    "description": "品种代码",
+                    "type": "string"
+                },
+                "deliverygoodsid": {
+                    "description": "品种ID",
+                    "type": "integer"
+                },
+                "deliverygoodsname": {
+                    "description": "品种名称",
+                    "type": "string"
+                },
+                "enableqty": {
+                    "description": "可用数量",
+                    "type": "number"
+                },
+                "enumdicname": {
+                    "description": "单位名称",
+                    "type": "string"
+                },
+                "freezerqty": {
+                    "description": "冻结数量",
+                    "type": "number"
+                },
+                "ladingbillid": {
+                    "description": "提单ID(208+Unix秒时间戳(10位)+xxxxxx)",
+                    "type": "integer"
+                },
+                "optioncompare": {
+                    "description": "选择项比较串【{选择项ID}+{冒号}+选择项值 } ,逗号分隔,头尾加逗号】-- 所有选择项拼接,用于比较",
+                    "type": "string"
+                },
+                "parentsubnum": {
+                    "description": "拆分父子单号",
+                    "type": "integer"
+                },
+                "qty": {
+                    "description": "数量",
+                    "type": "number"
+                },
+                "subnum": {
+                    "description": "提单子单号",
+                    "type": "integer"
+                },
+                "tradedate": {
+                    "description": "交易日(yyyyMMdd)",
+                    "type": "string"
+                },
+                "userid": {
+                    "description": "持有人ID",
+                    "type": "integer"
+                },
+                "warehouseid": {
+                    "description": "仓库ID",
+                    "type": "integer"
+                },
+                "warehousename": {
+                    "description": "仓库名称",
+                    "type": "string"
+                },
+                "wrfactortypeid": {
+                    "description": "仓单要素类型ID(212+Unix秒时间戳(10位)+xxxxxx)",
+                    "type": "integer"
+                },
+                "wrfactortypename": {
+                    "description": "仓单要素类型名称(选择项要素的名称合并显示,逗号分隔)",
+                    "type": "string"
+                },
+                "wrholdeno": {
+                    "description": "仓单编号",
+                    "type": "string"
+                },
+                "wrid": {
+                    "description": "仓单变更ID",
+                    "type": "integer"
+                },
+                "wrstandardcode": {
+                    "description": "现货商品代码",
+                    "type": "string"
+                },
+                "wrstandardid": {
+                    "description": "现货商品ID",
+                    "type": "integer"
+                },
+                "wrstandardname": {
+                    "description": "商品名称",
+                    "type": "string"
+                },
+                "wrtypename": {
+                    "description": "商品",
+                    "type": "string"
+                }
+            }
+        },
         "models.WrOrderDetail": {
             "type": "object",
             "properties": {

+ 147 - 0
docs/swagger.json

@@ -10905,6 +10905,48 @@
                 }
             }
         },
+        "/WrTrade2/QueryHoldLB": {
+            "get": {
+                "security": [
+                    {
+                        "ApiKeyAuth": []
+                    }
+                ],
+                "produces": [
+                    "application/json"
+                ],
+                "tags": [
+                    "仓单贸易v2"
+                ],
+                "summary": "查询仓单持有记录",
+                "parameters": [
+                    {
+                        "type": "integer",
+                        "description": "资金账号",
+                        "name": "accountid",
+                        "in": "query",
+                        "required": true
+                    }
+                ],
+                "responses": {
+                    "200": {
+                        "description": "OK",
+                        "schema": {
+                            "type": "array",
+                            "items": {
+                                "$ref": "#/definitions/models.WrHoldLB"
+                            }
+                        }
+                    },
+                    "500": {
+                        "description": "Internal Server Error",
+                        "schema": {
+                            "$ref": "#/definitions/app.Response"
+                        }
+                    }
+                }
+            }
+        },
         "/WrTrade2/QueryOrderQuote": {
             "get": {
                 "security": [
@@ -29329,6 +29371,111 @@
                 }
             }
         },
+        "models.WrHoldLB": {
+            "type": "object",
+            "properties": {
+                "accountid": {
+                    "description": "持有人帐户ID",
+                    "type": "integer"
+                },
+                "createtime": {
+                    "description": "创建时间(过户时间)",
+                    "type": "string"
+                },
+                "deliverygoodscode": {
+                    "description": "品种代码",
+                    "type": "string"
+                },
+                "deliverygoodsid": {
+                    "description": "品种ID",
+                    "type": "integer"
+                },
+                "deliverygoodsname": {
+                    "description": "品种名称",
+                    "type": "string"
+                },
+                "enableqty": {
+                    "description": "可用数量",
+                    "type": "number"
+                },
+                "enumdicname": {
+                    "description": "单位名称",
+                    "type": "string"
+                },
+                "freezerqty": {
+                    "description": "冻结数量",
+                    "type": "number"
+                },
+                "ladingbillid": {
+                    "description": "提单ID(208+Unix秒时间戳(10位)+xxxxxx)",
+                    "type": "integer"
+                },
+                "optioncompare": {
+                    "description": "选择项比较串【{选择项ID}+{冒号}+选择项值 } ,逗号分隔,头尾加逗号】-- 所有选择项拼接,用于比较",
+                    "type": "string"
+                },
+                "parentsubnum": {
+                    "description": "拆分父子单号",
+                    "type": "integer"
+                },
+                "qty": {
+                    "description": "数量",
+                    "type": "number"
+                },
+                "subnum": {
+                    "description": "提单子单号",
+                    "type": "integer"
+                },
+                "tradedate": {
+                    "description": "交易日(yyyyMMdd)",
+                    "type": "string"
+                },
+                "userid": {
+                    "description": "持有人ID",
+                    "type": "integer"
+                },
+                "warehouseid": {
+                    "description": "仓库ID",
+                    "type": "integer"
+                },
+                "warehousename": {
+                    "description": "仓库名称",
+                    "type": "string"
+                },
+                "wrfactortypeid": {
+                    "description": "仓单要素类型ID(212+Unix秒时间戳(10位)+xxxxxx)",
+                    "type": "integer"
+                },
+                "wrfactortypename": {
+                    "description": "仓单要素类型名称(选择项要素的名称合并显示,逗号分隔)",
+                    "type": "string"
+                },
+                "wrholdeno": {
+                    "description": "仓单编号",
+                    "type": "string"
+                },
+                "wrid": {
+                    "description": "仓单变更ID",
+                    "type": "integer"
+                },
+                "wrstandardcode": {
+                    "description": "现货商品代码",
+                    "type": "string"
+                },
+                "wrstandardid": {
+                    "description": "现货商品ID",
+                    "type": "integer"
+                },
+                "wrstandardname": {
+                    "description": "商品名称",
+                    "type": "string"
+                },
+                "wrtypename": {
+                    "description": "商品",
+                    "type": "string"
+                }
+            }
+        },
         "models.WrOrderDetail": {
             "type": "object",
             "properties": {

+ 104 - 0
docs/swagger.yaml

@@ -13336,6 +13336,84 @@ definitions:
         description: 履约计划模板ID
         type: integer
     type: object
+  models.WrHoldLB:
+    properties:
+      accountid:
+        description: 持有人帐户ID
+        type: integer
+      createtime:
+        description: 创建时间(过户时间)
+        type: string
+      deliverygoodscode:
+        description: 品种代码
+        type: string
+      deliverygoodsid:
+        description: 品种ID
+        type: integer
+      deliverygoodsname:
+        description: 品种名称
+        type: string
+      enableqty:
+        description: 可用数量
+        type: number
+      enumdicname:
+        description: 单位名称
+        type: string
+      freezerqty:
+        description: 冻结数量
+        type: number
+      ladingbillid:
+        description: 提单ID(208+Unix秒时间戳(10位)+xxxxxx)
+        type: integer
+      optioncompare:
+        description: 选择项比较串【{选择项ID}+{冒号}+选择项值 } ,逗号分隔,头尾加逗号】-- 所有选择项拼接,用于比较
+        type: string
+      parentsubnum:
+        description: 拆分父子单号
+        type: integer
+      qty:
+        description: 数量
+        type: number
+      subnum:
+        description: 提单子单号
+        type: integer
+      tradedate:
+        description: 交易日(yyyyMMdd)
+        type: string
+      userid:
+        description: 持有人ID
+        type: integer
+      warehouseid:
+        description: 仓库ID
+        type: integer
+      warehousename:
+        description: 仓库名称
+        type: string
+      wrfactortypeid:
+        description: 仓单要素类型ID(212+Unix秒时间戳(10位)+xxxxxx)
+        type: integer
+      wrfactortypename:
+        description: 仓单要素类型名称(选择项要素的名称合并显示,逗号分隔)
+        type: string
+      wrholdeno:
+        description: 仓单编号
+        type: string
+      wrid:
+        description: 仓单变更ID
+        type: integer
+      wrstandardcode:
+        description: 现货商品代码
+        type: string
+      wrstandardid:
+        description: 现货商品ID
+        type: integer
+      wrstandardname:
+        description: 商品名称
+        type: string
+      wrtypename:
+        description: 商品
+        type: string
+    type: object
   models.WrOrderDetail:
     properties:
       buyorsell:
@@ -22832,6 +22910,32 @@ paths:
       tags:
       - 仓单贸易
       - 仓单贸易
+  /WrTrade2/QueryHoldLB:
+    get:
+      parameters:
+      - description: 资金账号
+        in: query
+        name: accountid
+        required: true
+        type: integer
+      produces:
+      - application/json
+      responses:
+        "200":
+          description: OK
+          schema:
+            items:
+              $ref: '#/definitions/models.WrHoldLB'
+            type: array
+        "500":
+          description: Internal Server Error
+          schema:
+            $ref: '#/definitions/app.Response'
+      security:
+      - ApiKeyAuth: []
+      summary: 查询仓单持有记录
+      tags:
+      - 仓单贸易v2
   /WrTrade2/QueryOrderQuote:
     get:
       parameters:

+ 83 - 1
models/wrTrade2.go

@@ -10,6 +10,7 @@ import (
 	"fmt"
 	"mtp2_if/db"
 	"mtp2_if/utils"
+	"strings"
 )
 
 // WrOrderQuote 买卖大厅行情
@@ -44,7 +45,7 @@ type WrOrderQuote struct {
 }
 
 func (r *WrOrderQuote) calc() {
-
+	r.WRGOODSNAME = strings.ReplaceAll(r.WRGOODSNAME, ",", "-")
 }
 
 // buildSqlFixedPrice 一口价
@@ -341,6 +342,7 @@ type Wr2FactorType struct {
 
 func (r *Wr2FactorType) Calc() {
 	r.WRTYPENAME = r.WRSTANDARDNAME + "-" + r.WRFACTORTYPENAME
+	r.WRTYPENAME = strings.ReplaceAll(r.WRTYPENAME, ",", "-")
 }
 
 // WrPosition 仓单贸易持仓汇总
@@ -1102,3 +1104,83 @@ func (r *WrPerformancePlan) GetDataEx() (interface{}, error) {
 	}
 	return sData, err
 }
+
+// WrHoldLB 仓单持有记录
+type WrHoldLB struct {
+	LADINGBILLID    int64   `json:"ladingbillid"  xorm:"LADINGBILLID" form:"ladingbillid"`          // 提单ID(208+Unix秒时间戳(10位)+xxxxxx)
+	SUBNUM          int32   `json:"subnum"  xorm:"SUBNUM" form:"subnum"`                            // 提单子单号
+	WRFACTORTYPEID  int64   `json:"wrfactortypeid"  xorm:"WRFACTORTYPEID" form:"wrfactortypeid"`    // 仓单要素类型ID
+	DELIVERYGOODSID int32   `json:"deliverygoodsid"  xorm:"DELIVERYGOODSID" form:"deliverygoodsid"` // 品种ID
+	QTY             float64 `json:"qty"  xorm:"QTY" form:"qty"`                                     // 数量
+	FREEZERQTY      float64 `json:"freezerqty"  xorm:"FREEZERQTY" form:"freezerqty"`                // 冻结数量
+	USERID          int64   `json:"userid"  xorm:"USERID" form:"userid"`                            // 持有人ID
+	ACCOUNTID       int64   `json:"accountid"  xorm:"ACCOUNTID" form:"accountid"`                   // 持有人帐户ID
+	CREATETIME      string  `json:"createtime"  xorm:"CREATETIME" form:"createtime"`                // 创建时间(过户时间)
+	TRADEDATE       string  `json:"tradedate"  xorm:"TRADEDATE" form:"tradedate"`                   // 交易日(yyyyMMdd)
+	WRID            int64   `json:"wrid"  xorm:"WRID" form:"wrid"`                                  // 仓单变更ID
+	PARENTSUBNUM    int32   `json:"parentsubnum"  xorm:"PARENTSUBNUM" form:"parentsubnum"`          // 拆分父子单号
+	Wr2FactorType   `xorm:"extends"`
+
+	WRHOLDENO string  `json:"wrholdeno"` // 仓单编号
+	ENABLEQTY float64 `json:"enableqty"` // 可用数量
+}
+
+func (r *WrHoldLB) calc() {
+	r.WRHOLDENO = fmt.Sprintf("%v_%v", r.LADINGBILLID, r.SUBNUM)
+	r.ENABLEQTY = r.QTY - r.FREEZERQTY
+}
+
+func (r *WrHoldLB) buildSql() string {
+	var sqlId utils.SQLVal = "with tmp as" +
+		" (select t.wrfactortypeid," +
+		"         t.wrfactortypename," +
+		"         t.wrstandardid," +
+		"         t.deliverygoodsid," +
+		"         g.deliverygoodscode," +
+		"         g.deliverygoodsname," +
+		"         w.wrstandardcode," +
+		"         w.wrstandardname," +
+		"         h.warehousecode," +
+		"         h.warehousename," +
+		"         e.enumdicname," +
+		"         w.wrstandardname || '-' || t.wrfactortypename as wrtypename" +
+		"    from wrfactortype t" +
+		"    left join deliverygoods g" +
+		"      on t.deliverygoodsid = g.deliverygoodsid" +
+		"    left join wrstandard w" +
+		"      on t.wrstandardid = w.wrstandardid" +
+		"    left join warehouseinfo h" +
+		"      on t.warehouseid = h.autoid" +
+		"    left join enumdicitem e" +
+		"      on w.unitid = e.enumitemname" +
+		"     and e.enumdiccode = 'goodsunit'" +
+		")" +
+		"SELECT t.LADINGBILLID," +
+		"       t.SUBNUM," +
+		"       t.WRFACTORTYPEID," +
+		"       t.DELIVERYGOODSID," +
+		"       t.QTY," +
+		"       t.FREEZERQTY," +
+		"       t.USERID," +
+		"       t.ACCOUNTID," +
+		"       to_char(t.CREATETIME, 'yyyy-mm-dd hh24:mi:ss') CREATETIME," +
+		"       t.TRADEDATE," +
+		"       t.WRID," +
+		"       t.PARENTSUBNUM," +
+		"       tmp.*" +
+		"  FROM WRHOLDLB t" +
+		" LEFT JOIN tmp on t.wrfactortypeid= tmp.wrfactortypeid" +
+		" WHERE 1 = 1"
+	sqlId.And("t.ACCOUNTID", r.ACCOUNTID)
+	return sqlId.String()
+}
+
+// GetDataEx 获取仓单持有记录
+func (r *WrHoldLB) GetDataEx() (interface{}, error) {
+	sData := make([]WrHoldLB, 0)
+	err := db.GetEngine().SQL(r.buildSql()).Find(&sData)
+	for i := range sData {
+		sData[i].calc()
+	}
+	return sData, err
+}

+ 1 - 0
routers/router.go

@@ -525,6 +525,7 @@ func InitRouter() *gin.Engine {
 		wrTrade2R.GET("QueryWrSpecialMatchOrder", wrTrade2.QueryWrSpecialMatchOrder)
 		wrTrade2R.GET("QueryWrGoodsInfo", wrTrade2.QueryWrGoodsInfo)
 		wrTrade2R.GET("QueryPerformancePlan", wrTrade2.QueryPerformancePlan)
+		wrTrade2R.GET("QueryHoldLB", wrTrade2.QueryHoldLB)
 	}
 
 	return r