Browse Source

联调问题修改,增加字段

zou.yingbin 4 years ago
parent
commit
f2b0509a65
8 changed files with 476 additions and 38 deletions
  1. 34 0
      controllers/ermcp/qryExposure.go
  2. 119 1
      docs/docs.go
  3. 119 1
      docs/swagger.json
  4. 83 1
      docs/swagger.yaml
  5. 55 34
      models/ermcp.go
  6. 64 0
      models/ermcpExposure.go
  7. 1 1
      models/ermcpHedgePlan.go
  8. 1 0
      routers/router.go

+ 34 - 0
controllers/ermcp/qryExposure.go

@@ -86,4 +86,38 @@ func QueryExposureDetail(c *gin.Context) {
 	}else {
 		appG.Response(http.StatusBadRequest, e.ERROR_QUERY_FAIL, nil)
 	}
+}
+
+//////////////////////////////////////////////
+
+// 敞口/现货头寸请求
+type ExposureSpotReq struct {
+	AreaUserID int32 `form:"areaUserId" binding:"required"` //所属机构ID
+}
+
+// 敞口/现货头寸应答
+type ExposureSpotRsp models.AreaSpotModel
+
+// QueryUserInfo 查询敞口现货头寸
+// @Summary 查询敞口现货头寸(敞口/现货头寸)
+// @Produce json
+// @Security ApiKeyAuth
+// @Param areaUserId query int true "所属机构ID"
+// @Success 200 {array} ExposureSpotRsp
+// @Failure 500 {object} app.Response
+// @Router /Ermcp/QueryExposureSpot [get]
+// @Tags 企业风险管理(app)
+func QueryExposureSpot(c *gin.Context)  {
+	appG := app.Gin{C: c}
+	var req ExposureSpotReq
+	if err := c.ShouldBind(&req); err != nil{
+		appG.Response(http.StatusBadRequest, e.INVALID_PARAMS, nil)
+		return
+	}
+	var m = models.AreaSpotModel{AREAUSERID: req.AreaUserID}
+	if d, err := m.GetData(); err == nil{
+		appG.Response(http.StatusOK, e.SUCCESS, d)
+	}else{
+		appG.Response(http.StatusBadRequest, e.ERROR_QUERY_FAIL, nil)
+	}
 }

+ 119 - 1
docs/docs.go

@@ -1056,6 +1056,48 @@ var doc = `{
                 }
             }
         },
+        "/Ermcp/QueryExposureSpot": {
+            "get": {
+                "security": [
+                    {
+                        "ApiKeyAuth": []
+                    }
+                ],
+                "produces": [
+                    "application/json"
+                ],
+                "tags": [
+                    "企业风险管理(app)"
+                ],
+                "summary": "查询敞口现货头寸(敞口/现货头寸)",
+                "parameters": [
+                    {
+                        "type": "integer",
+                        "description": "所属机构ID",
+                        "name": "areaUserId",
+                        "in": "query",
+                        "required": true
+                    }
+                ],
+                "responses": {
+                    "200": {
+                        "description": "OK",
+                        "schema": {
+                            "type": "array",
+                            "items": {
+                                "$ref": "#/definitions/ermcp.ExposureSpotRsp"
+                            }
+                        }
+                    },
+                    "500": {
+                        "description": "Internal Server Error",
+                        "schema": {
+                            "$ref": "#/definitions/app.Response"
+                        }
+                    }
+                }
+            }
+        },
         "/Ermcp/QueryHedgePlan": {
             "get": {
                 "security": [
@@ -5656,6 +5698,9 @@ var doc = `{
         "ermcp.ExposureDetailRsp": {
             "$ref": "#/definitions/models.ErmcpExposureDetailModel"
         },
+        "ermcp.ExposureSpotRsp": {
+            "$ref": "#/definitions/models.AreaSpotModel"
+        },
         "ermcp.QryBusinessDjRsp": {
             "type": "object",
             "properties": {
@@ -7634,6 +7679,47 @@ var doc = `{
                 }
             }
         },
+        "models.AreaSpotModel": {
+            "type": "object",
+            "properties": {
+                "areauserid": {
+                    "description": "所属机构",
+                    "type": "integer"
+                },
+                "decreaseqty": {
+                    "description": "减少数量=-(销售已定价数量+采购计划数量)",
+                    "type": "number"
+                },
+                "increaseqty": {
+                    "description": "增加数量=销售计划数量+采购已定价数量",
+                    "type": "number"
+                },
+                "oritoalspotqty": {
+                    "description": "昨日数量",
+                    "type": "number"
+                },
+                "totalspotqty": {
+                    "description": "当前数量(现货头寸总量) =  (销售计划数量 - 销售已定价数量)  - (采购计划数量 - 采购已定价数量)",
+                    "type": "number"
+                },
+                "updatetime": {
+                    "description": "更新时间",
+                    "type": "string"
+                },
+                "wrstandardcode": {
+                    "description": "现货品种代码",
+                    "type": "string"
+                },
+                "wrstandardid": {
+                    "description": "现货商品ID",
+                    "type": "integer"
+                },
+                "wrstandardname": {
+                    "description": "现货品种",
+                    "type": "string"
+                }
+            }
+        },
         "models.Clientfixedadconfig": {
             "type": "object",
             "required": [
@@ -7900,7 +7986,7 @@ var doc = `{
                     "type": "string"
                 },
                 "hedgeplanno": {
-                    "description": "套保计划编号",
+                    "description": "套保计划编号(名称)",
                     "type": "string"
                 },
                 "hedgeplanstatus": {
@@ -7952,6 +8038,10 @@ var doc = `{
                     "description": "合同状态- 0:未提交 1:待审核 2:执行中 3:正常完结 4:审核拒绝 5:异常完结 6:已撤回",
                     "type": "integer"
                 },
+                "contractno": {
+                    "description": "合同编号",
+                    "type": "string"
+                },
                 "contracttype": {
                     "description": "合同类型 1-采购, -1-销售",
                     "type": "number"
@@ -8004,6 +8094,10 @@ var doc = `{
                     "description": "已开票额",
                     "type": "number"
                 },
+                "loanamount": {
+                    "description": "贷款总额=已定价额+调整金额",
+                    "type": "number"
+                },
                 "margin": {
                     "description": "保证金",
                     "type": "number"
@@ -8012,6 +8106,10 @@ var doc = `{
                     "description": "已收付额(收款或付款)",
                     "type": "number"
                 },
+                "price": {
+                    "description": "价格",
+                    "type": "number"
+                },
                 "pricedamount": {
                     "description": "已定价额",
                     "type": "number"
@@ -8040,6 +8138,22 @@ var doc = `{
                     "description": "合同量",
                     "type": "number"
                 },
+                "reckonadjustamount": {
+                    "description": "调整金额",
+                    "type": "number"
+                },
+                "reckonedamount": {
+                    "description": "已收付额(已确定额)",
+                    "type": "number"
+                },
+                "reckonotheramount": {
+                    "description": "其它费用",
+                    "type": "number"
+                },
+                "reckonrealqty": {
+                    "description": "已确定量",
+                    "type": "number"
+                },
                 "remark": {
                     "description": "备注",
                     "type": "string"
@@ -8056,6 +8170,10 @@ var doc = `{
                     "description": "点价开始日",
                     "type": "string"
                 },
+                "totalamount": {
+                    "description": "合计总额",
+                    "type": "number"
+                },
                 "unpayamount": {
                     "description": "待支收额(支付或收款)",
                     "type": "number"

+ 119 - 1
docs/swagger.json

@@ -1040,6 +1040,48 @@
                 }
             }
         },
+        "/Ermcp/QueryExposureSpot": {
+            "get": {
+                "security": [
+                    {
+                        "ApiKeyAuth": []
+                    }
+                ],
+                "produces": [
+                    "application/json"
+                ],
+                "tags": [
+                    "企业风险管理(app)"
+                ],
+                "summary": "查询敞口现货头寸(敞口/现货头寸)",
+                "parameters": [
+                    {
+                        "type": "integer",
+                        "description": "所属机构ID",
+                        "name": "areaUserId",
+                        "in": "query",
+                        "required": true
+                    }
+                ],
+                "responses": {
+                    "200": {
+                        "description": "OK",
+                        "schema": {
+                            "type": "array",
+                            "items": {
+                                "$ref": "#/definitions/ermcp.ExposureSpotRsp"
+                            }
+                        }
+                    },
+                    "500": {
+                        "description": "Internal Server Error",
+                        "schema": {
+                            "$ref": "#/definitions/app.Response"
+                        }
+                    }
+                }
+            }
+        },
         "/Ermcp/QueryHedgePlan": {
             "get": {
                 "security": [
@@ -5640,6 +5682,9 @@
         "ermcp.ExposureDetailRsp": {
             "$ref": "#/definitions/models.ErmcpExposureDetailModel"
         },
+        "ermcp.ExposureSpotRsp": {
+            "$ref": "#/definitions/models.AreaSpotModel"
+        },
         "ermcp.QryBusinessDjRsp": {
             "type": "object",
             "properties": {
@@ -7618,6 +7663,47 @@
                 }
             }
         },
+        "models.AreaSpotModel": {
+            "type": "object",
+            "properties": {
+                "areauserid": {
+                    "description": "所属机构",
+                    "type": "integer"
+                },
+                "decreaseqty": {
+                    "description": "减少数量=-(销售已定价数量+采购计划数量)",
+                    "type": "number"
+                },
+                "increaseqty": {
+                    "description": "增加数量=销售计划数量+采购已定价数量",
+                    "type": "number"
+                },
+                "oritoalspotqty": {
+                    "description": "昨日数量",
+                    "type": "number"
+                },
+                "totalspotqty": {
+                    "description": "当前数量(现货头寸总量) =  (销售计划数量 - 销售已定价数量)  - (采购计划数量 - 采购已定价数量)",
+                    "type": "number"
+                },
+                "updatetime": {
+                    "description": "更新时间",
+                    "type": "string"
+                },
+                "wrstandardcode": {
+                    "description": "现货品种代码",
+                    "type": "string"
+                },
+                "wrstandardid": {
+                    "description": "现货商品ID",
+                    "type": "integer"
+                },
+                "wrstandardname": {
+                    "description": "现货品种",
+                    "type": "string"
+                }
+            }
+        },
         "models.Clientfixedadconfig": {
             "type": "object",
             "required": [
@@ -7884,7 +7970,7 @@
                     "type": "string"
                 },
                 "hedgeplanno": {
-                    "description": "套保计划编号",
+                    "description": "套保计划编号(名称)",
                     "type": "string"
                 },
                 "hedgeplanstatus": {
@@ -7936,6 +8022,10 @@
                     "description": "合同状态- 0:未提交 1:待审核 2:执行中 3:正常完结 4:审核拒绝 5:异常完结 6:已撤回",
                     "type": "integer"
                 },
+                "contractno": {
+                    "description": "合同编号",
+                    "type": "string"
+                },
                 "contracttype": {
                     "description": "合同类型 1-采购, -1-销售",
                     "type": "number"
@@ -7988,6 +8078,10 @@
                     "description": "已开票额",
                     "type": "number"
                 },
+                "loanamount": {
+                    "description": "贷款总额=已定价额+调整金额",
+                    "type": "number"
+                },
                 "margin": {
                     "description": "保证金",
                     "type": "number"
@@ -7996,6 +8090,10 @@
                     "description": "已收付额(收款或付款)",
                     "type": "number"
                 },
+                "price": {
+                    "description": "价格",
+                    "type": "number"
+                },
                 "pricedamount": {
                     "description": "已定价额",
                     "type": "number"
@@ -8024,6 +8122,22 @@
                     "description": "合同量",
                     "type": "number"
                 },
+                "reckonadjustamount": {
+                    "description": "调整金额",
+                    "type": "number"
+                },
+                "reckonedamount": {
+                    "description": "已收付额(已确定额)",
+                    "type": "number"
+                },
+                "reckonotheramount": {
+                    "description": "其它费用",
+                    "type": "number"
+                },
+                "reckonrealqty": {
+                    "description": "已确定量",
+                    "type": "number"
+                },
                 "remark": {
                     "description": "备注",
                     "type": "string"
@@ -8040,6 +8154,10 @@
                     "description": "点价开始日",
                     "type": "string"
                 },
+                "totalamount": {
+                    "description": "合计总额",
+                    "type": "number"
+                },
                 "unpayamount": {
                     "description": "待支收额(支付或收款)",
                     "type": "number"

+ 83 - 1
docs/swagger.yaml

@@ -843,6 +843,8 @@ definitions:
     type: object
   ermcp.ExposureDetailRsp:
     $ref: '#/definitions/models.ErmcpExposureDetailModel'
+  ermcp.ExposureSpotRsp:
+    $ref: '#/definitions/models.AreaSpotModel'
   ermcp.QryBusinessDjRsp:
     properties:
       amount:
@@ -2308,6 +2310,36 @@ definitions:
         description: 省
         type: object
     type: object
+  models.AreaSpotModel:
+    properties:
+      areauserid:
+        description: 所属机构
+        type: integer
+      decreaseqty:
+        description: 减少数量=-(销售已定价数量+采购计划数量)
+        type: number
+      increaseqty:
+        description: 增加数量=销售计划数量+采购已定价数量
+        type: number
+      oritoalspotqty:
+        description: 昨日数量
+        type: number
+      totalspotqty:
+        description: 当前数量(现货头寸总量) =  (销售计划数量 - 销售已定价数量)  - (采购计划数量 - 采购已定价数量)
+        type: number
+      updatetime:
+        description: 更新时间
+        type: string
+      wrstandardcode:
+        description: 现货品种代码
+        type: string
+      wrstandardid:
+        description: 现货商品ID
+        type: integer
+      wrstandardname:
+        description: 现货品种
+        type: string
+    type: object
   models.Clientfixedadconfig:
     properties:
       adsort:
@@ -2505,7 +2537,7 @@ definitions:
         description: 套保计划ID(601+Unix秒时间戳(10位)+xxxxxx)
         type: string
       hedgeplanno:
-        description: 套保计划编号
+        description: 套保计划编号(名称)
         type: string
       hedgeplanstatus:
         description: 套保计划状态 -  0:未提交 1:待审核 2:执行中 3:正常完结 4:审核拒绝 5:异常完结 6:已撤回
@@ -2543,6 +2575,9 @@ definitions:
       contracctstatus:
         description: 合同状态- 0:未提交 1:待审核 2:执行中 3:正常完结 4:审核拒绝 5:异常完结 6:已撤回
         type: integer
+      contractno:
+        description: 合同编号
+        type: string
       contracttype:
         description: 合同类型 1-采购, -1-销售
         type: number
@@ -2582,12 +2617,18 @@ definitions:
       invoiceamount:
         description: 已开票额
         type: number
+      loanamount:
+        description: 贷款总额=已定价额+调整金额
+        type: number
       margin:
         description: 保证金
         type: number
       payamount:
         description: 已收付额(收款或付款)
         type: number
+      price:
+        description: 价格
+        type: number
       pricedamount:
         description: 已定价额
         type: number
@@ -2609,6 +2650,18 @@ definitions:
       qty:
         description: 合同量
         type: number
+      reckonadjustamount:
+        description: 调整金额
+        type: number
+      reckonedamount:
+        description: 已收付额(已确定额)
+        type: number
+      reckonotheramount:
+        description: 其它费用
+        type: number
+      reckonrealqty:
+        description: 已确定量
+        type: number
       remark:
         description: 备注
         type: string
@@ -2621,6 +2674,9 @@ definitions:
       startdate:
         description: 点价开始日
         type: string
+      totalamount:
+        description: 合计总额
+        type: number
       unpayamount:
         description: 待支收额(支付或收款)
         type: number
@@ -7047,6 +7103,32 @@ paths:
       summary: 查询敞口现货明细
       tags:
       - 企业风险管理(app)
+  /Ermcp/QueryExposureSpot:
+    get:
+      parameters:
+      - description: 所属机构ID
+        in: query
+        name: areaUserId
+        required: true
+        type: integer
+      produces:
+      - application/json
+      responses:
+        "200":
+          description: OK
+          schema:
+            items:
+              $ref: '#/definitions/ermcp.ExposureSpotRsp'
+            type: array
+        "500":
+          description: Internal Server Error
+          schema:
+            $ref: '#/definitions/app.Response'
+      security:
+      - ApiKeyAuth: []
+      summary: 查询敞口现货头寸(敞口/现货头寸)
+      tags:
+      - 企业风险管理(app)
   /Ermcp/QueryHedgePlan:
     get:
       parameters:

+ 55 - 34
models/ermcp.go

@@ -119,39 +119,51 @@ func (r *ErmcpSpotContractModel) GetData(nQueryType int32) ([]ErmcpSpotContractM
 
 // 风险管理合同(对应采购和销售菜单)
 type ErmcpModel struct {
-	UserID            int64   `json:"userid"  xorm:"'UserID'"`                       // 用户ID
-	SpotContractId    string  `json:"spotcontractid"  xorm:"'SPOTCONTRACTID'"`       // 合同ID
-	AccountId         string  `json:"accountid"  xorm:"'ACCOUNTID'"`                 // 账户ID
-	AccountName       string  `json:"accountname"  xorm:"'ACCOUNTNAME'"`             // 账户名称
-	DeliveryGoodsId   int     `json:"deliverygoodsid"  xorm:"'DELIVERYGOODSID'"`     // 现货商品ID
-	DeliveryGoodsCode string  `json:"deliverygoodscode"  xorm:"'DELIVERYGOODSCODE'"` // 现货商品代码
-	DeliveryGoodsName string  `json:"deliverygoodsname"  xorm:"'DELIVERYGOODSNAME'"` // 现货商品名称
-	SpotGoodsdesc     string  `json:"spotgoodsdesc"  xorm:"'SPOTGOODSDESC'"`         // 商品型号(商品规格)
-	GoodsId           int     `json:"goodsid"  xorm:"'GOODSID'"`                     // 点价商品ID
-	Goodscode         string  `json:"goodscode"  xorm:"'GOODSCODE'"`                 // 点价商品代码
-	Pricemove         float64 `json:"pricemove"  xorm:"'PRICEMOVE'"`                 // 升贴水
-	Qty               float64 `json:"qty"  xorm:"'QTY'"`                             // 合同量
-	UnpricedQty       float64 `json:"unpricedqty"  xorm:"'UNPRICEDQTY'"`             // 未定价量
-	PricedQty         float64 `json:"pricedqty"  xorm:"'PRICEDQTY'"`                 // 已定价量
-	UnsureQty         float64 `json:"unsureqty"  xorm:"'UNSUREQTY'"`                 // 未确定量
-	PayAmount         float64 `json:"payamount"  xorm:"'PAYAMOUNT'"`                 // 已收付额(收款或付款)
-	UnpayAmount       float64 `json:"unpayamount"  xorm:"'UNPAYAMOUNT'"`             // 待支收额(支付或收款)
-	InvoiceAmount     float64 `json:"invoiceamount"  xorm:"'INVOICEAMOUNT'"`         // 已开票额
-	DaikaiAmount      float64 `json:"daikaiamount"  xorm:"'DAIKAIAMOUNT'"`           // 待开票额
-	StartDate         string  `json:"startdate"  xorm:"'STARTDATE'"`                 // 点价开始日
-	EndDate           string  `json:"enddate"  xorm:"'ENDDATE'"`                     // 点价结束日
-	DeliveryStartDate string  `json:"deliverystartdate"  xorm:"'DELIVERYSTARTDATE'"` // 交割开始日
-	DeliveryendDate   string  `json:"deliveryenddate"  xorm:"'DELIVERYENDDATE'"`     // 交割结束日
-	Convertfactor     float64 `json:"convertfactor"  xorm:"'CONVERTFACTOR'"`         // 标仓系数
-	EnumdicName       string  `json:"enumdicname"  xorm:"'ENUMDICNAME'"`             // 单位名称
-	Contracctstatus   uint    `json:"contracctstatus"  xorm:"'CONTRACTSTATUS'"`      // 合同状态- 0:未提交 1:待审核 2:执行中 3:正常完结 4:审核拒绝 5:异常完结 6:已撤回
-	PriceType         int     `json:"pricetype"  xorm:"'PRICETYPE'"`                 // 定价类型 - 1:一口价 2:点价 3:暂定价
-	ProductType       int     `json:"producttype"  xorm:"'PRODUCTTYPE'"`             // 产品类型 - 1:标准仓单 2:等标 3:非标
-	Contracttype      float64 `json:"contracttype"  xorm:"'CONTRACTTYPE'"`           // 合同类型 1-采购, -1-销售
-	Pricedamount      float64 `json:"pricedamount"  xorm:"'PRICEDAMOUNT'"`           // 已定价额
-	PricedAvg         float64 `json:"pricedavg"  xorm:"'PRICEDAVG'"`                 // 已点均价
-	Margin            float64 `json:"margin"  xorm:"'MARGIN'"`                       // 保证金
-	Remark            string  `json:"remark"  xorm:"'Remark'"`                       // 备注
+	UserID             int64   `json:"userid"  xorm:"'UserID'"`                         // 用户ID
+	SpotContractId     string  `json:"spotcontractid"  xorm:"'SPOTCONTRACTID'"`         // 合同ID
+	AccountId          string  `json:"accountid"  xorm:"'ACCOUNTID'"`                   // 账户ID
+	AccountName        string  `json:"accountname"  xorm:"'ACCOUNTNAME'"`               // 账户名称
+	DeliveryGoodsId    int     `json:"deliverygoodsid"  xorm:"'DELIVERYGOODSID'"`       // 现货商品ID
+	DeliveryGoodsCode  string  `json:"deliverygoodscode"  xorm:"'DELIVERYGOODSCODE'"`   // 现货商品代码
+	DeliveryGoodsName  string  `json:"deliverygoodsname"  xorm:"'DELIVERYGOODSNAME'"`   // 现货商品名称
+	SpotGoodsdesc      string  `json:"spotgoodsdesc"  xorm:"'SPOTGOODSDESC'"`           // 商品型号(商品规格)
+	GoodsId            int     `json:"goodsid"  xorm:"'GOODSID'"`                       // 点价商品ID
+	Goodscode          string  `json:"goodscode"  xorm:"'GOODSCODE'"`                   // 点价商品代码
+	Pricemove          float64 `json:"pricemove"  xorm:"'PRICEMOVE'"`                   // 升贴水
+	Qty                float64 `json:"qty"  xorm:"'QTY'"`                               // 合同量
+	UnpricedQty        float64 `json:"unpricedqty"  xorm:"'UNPRICEDQTY'"`               // 未定价量
+	PricedQty          float64 `json:"pricedqty"  xorm:"'PRICEDQTY'"`                   // 已定价量
+	UnsureQty          float64 `json:"unsureqty"  xorm:"'UNSUREQTY'"`                   // 未确定量
+	PayAmount          float64 `json:"payamount"  xorm:"'PAYAMOUNT'"`                   // 已收付额(收款或付款)
+	UnpayAmount        float64 `json:"unpayamount"  xorm:"'UNPAYAMOUNT'"`               // 待支收额(支付或收款)
+	InvoiceAmount      float64 `json:"invoiceamount"  xorm:"'INVOICEAMOUNT'"`           // 已开票额
+	DaikaiAmount       float64 `json:"daikaiamount"  xorm:"'DAIKAIAMOUNT'"`             // 待开票额
+	StartDate          string  `json:"startdate"  xorm:"'STARTDATE'"`                   // 点价开始日
+	EndDate            string  `json:"enddate"  xorm:"'ENDDATE'"`                       // 点价结束日
+	DeliveryStartDate  string  `json:"deliverystartdate"  xorm:"'DELIVERYSTARTDATE'"`   // 交割开始日
+	DeliveryendDate    string  `json:"deliveryenddate"  xorm:"'DELIVERYENDDATE'"`       // 交割结束日
+	Convertfactor      float64 `json:"convertfactor"  xorm:"'CONVERTFACTOR'"`           // 标仓系数
+	EnumdicName        string  `json:"enumdicname"  xorm:"'ENUMDICNAME'"`               // 单位名称
+	Contracctstatus    uint    `json:"contracctstatus"  xorm:"'CONTRACTSTATUS'"`        // 合同状态- 0:未提交 1:待审核 2:执行中 3:正常完结 4:审核拒绝 5:异常完结 6:已撤回
+	PriceType          int     `json:"pricetype"  xorm:"'PRICETYPE'"`                   // 定价类型 - 1:一口价 2:点价 3:暂定价
+	ProductType        int     `json:"producttype"  xorm:"'PRODUCTTYPE'"`               // 产品类型 - 1:标准仓单 2:等标 3:非标
+	Contracttype       float64 `json:"contracttype"  xorm:"'CONTRACTTYPE'"`             // 合同类型 1-采购, -1-销售
+	Pricedamount       float64 `json:"pricedamount"  xorm:"'PRICEDAMOUNT'"`             // 已定价额
+	PricedAvg          float64 `json:"pricedavg"  xorm:"'PRICEDAVG'"`                   // 已点均价
+	Margin             float64 `json:"margin"  xorm:"'MARGIN'"`                         // 保证金
+	Remark             string  `json:"remark"  xorm:"'Remark'"`                         // 备注
+	ReckonRealQty      float64 `json:"reckonrealqty"  xorm:"'ReckonRealQty'"`           // 已确定量
+	ReckonOtherAmount  float64 `json:"reckonotheramount"  xorm:"'ReckonOtherAmount'"`   // 其它费用
+	ReckonAdjustAmount float64 `json:"reckonadjustamount"  xorm:"'ReckonAdjustAmount'"` // 调整金额
+	Price              float64 `json:"price"  xorm:"'Price'"`                           // 价格
+	LoanAmount         float64 `json:"loanamount"  xorm:"'LoanAmount'"`                 // 贷款总额=已定价额+调整金额
+	Contractno         string  `json:"contractno"  xorm:"'Contractno'"`                 // 合同编号
+	TotalAmount        float64 `json:"totalamount"  xorm:"'-'"`                         // 合计总额
+	ReckonedAmount     float64 `json:"reckonedamount"  xorm:"'ReckonedAmount'"`         // 已收付额(已确定额)
+}
+
+func (r *ErmcpModel) calc() {
+	r.TotalAmount = r.LoanAmount + r.ReckonOtherAmount - r.ReckonedAmount
 }
 
 // 组装查询的sql
@@ -196,7 +208,13 @@ func (r *ErmcpModel) buildSql(nContractType, nQueryType int32) string {
 		"       e.enumdicname," +
 		"       t.contracttype," +
 		"       t.pricedamount," +
-		"       case when t.pricedqty > 0 then t.pricedamount/t.pricedqty else 0 end pricedAvg" +
+		"       case when t.pricedqty > 0 then t.pricedamount/t.pricedqty else 0 end pricedAvg," +
+		"       t.ReckonRealQty," +
+		"       t.ReckonOtherAmount," +
+		"       t.ReckonAdjustAmount," +
+		"       t.Price," +
+		"       t.ReckonedAmount," +
+		"       t.pricedamount + t.ReckonAdjustAmount as LoanAmount" +
 		"  from ermcp_spotcontract t" +
 		"  left join taaccount ta" +
 		"    on t.%v = ta.userid" +
@@ -251,5 +269,8 @@ func (r *ErmcpModel) GetData(contractType, nQueryType int32) ([]ErmcpModel, erro
 		logger.GetLogger().Errorf("ermcp query fail:%v", err)
 		return sData, err
 	}
+	for i := range sData {
+		sData[i].calc()
+	}
 	return sData, nil
 }

+ 64 - 0
models/ermcpExposure.go

@@ -182,3 +182,67 @@ func (r *ErmcpExposureDetailModel) GetData() ([]ErmcpExposureDetailModel, error)
 	}
 	return sData, nil
 }
+
+/// 现货头寸
+
+// 现货头寸数据
+type AreaSpotModel struct {
+	WRSTANDARDID     int32   `json:"wrstandardid"  xorm:"'WRSTANDARDID'"`     // 现货商品ID
+	WRSTANDARDNAME   string  `json:"wrstandardname"  xorm:"'WRSTANDARDNAME'"` // 现货品种
+	WRSTANDARDCODE   string  `json:"wrstandardcode"  xorm:"'WRSTANDARDCODE'"` // 现货品种代码
+	AREAUSERID       int32   `json:"areauserid"  xorm:"'AREAUSERID'"`         // 所属机构
+	ORIBUYPLANQTY    float64 `json:"-"  xorm:"'ORIBUYPLANQTY'"`               // 期初采购计划数量
+	ORIBUYPRICEDQTY  float64 `json:"-"  xorm:"'ORIBUYPRICEDQTY'"`             // 期初采购合同已定价数量
+	ORISELLPLANQTY   float64 `json:"-"  xorm:"'ORISELLPLANQTY'"`              // 期初销售计划数量
+	ORISELLPRICEDQTY float64 `json:"-"  xorm:"'ORISELLPRICEDQTY'"`            // 期初销售合同已定价数量
+	BUYPLANQTY       float64 `json:"-"  xorm:"'BUYPLANQTY'"`                  // 采购计划数量
+	BUYPRICEDQTY     float64 `json:"-"  xorm:"'BUYPRICEDQTY'"`                // 采购合同已定价数量
+	SELLPLANQTY      float64 `json:"-"  xorm:"'SELLPLANQTY'"`                 // 销售计划数量
+	SELLPRICEDQTY    float64 `json:"-"  xorm:"'SELLPRICEDQTY'"`               // 销售合同已定价数量
+	TOTALSPOTQTY     float64 `json:"totalspotqty"  xorm:"'TOTALSPOTQTY'"`     // 当前数量(现货头寸总量) =  (销售计划数量 - 销售已定价数量)  - (采购计划数量 - 采购已定价数量)
+	OriToalSpotQty   float64 `json:"oritoalspotqty"  xorm:"'OriToalSpotQty'"` // 昨日数量
+	IncreaseQty      float64 `json:"increaseqty"  xorm:"'IncreaseQty'"`       // 增加数量=销售计划数量+采购已定价数量
+	DecreaseQty      float64 `json:"decreaseqty"  xorm:"'DecreaseQty'"`       // 减少数量=-(销售已定价数量+采购计划数量)
+	UPDATETIME       string  `json:"updatetime"  xorm:"'UPDATETIME'"`         // 更新时间
+}
+
+// 进行相关字段的值计算
+func (r *AreaSpotModel) calc() {
+	r.IncreaseQty = r.SELLPLANQTY + r.BUYPRICEDQTY
+	r.DecreaseQty = (r.SELLPRICEDQTY + r.BUYPLANQTY) * -1
+	r.OriToalSpotQty = (r.ORISELLPLANQTY - r.ORISELLPRICEDQTY) - (r.ORIBUYPLANQTY - r.ORIBUYPRICEDQTY)
+}
+
+func (r *AreaSpotModel) buildSql() string {
+	str := "select t.WRSTANDARDID," +
+		"       w.WRSTANDARDNAME," +
+		"       w.WRSTANDARDCODE," +
+		"       t.AREAUSERID," +
+		"       t.ORIBUYPLANQTY," +
+		"       t.ORIBUYPRICEDQTY," +
+		"       t.ORISELLPLANQTY," +
+		"       t.ORISELLPRICEDQTY," +
+		"       t.BUYPLANQTY," +
+		"       t.BUYPRICEDQTY," +
+		"       t.SELLPLANQTY," +
+		"       t.SELLPRICEDQTY," +
+		"       t.TOTALSPOTQTY UPDATETIME" +
+		"  from ermcp_areaspot t" +
+		"  left join wrstandard w" +
+		"    on t.wrstandardid = w.wrstandardid" +
+		"  where t.areauserid=%v"
+	return fmt.Sprintf(str, r.AREAUSERID)
+}
+
+// 从数据库中查询现货头寸
+func (r *AreaSpotModel) GetData() ([]AreaSpotModel, error) {
+	e := db.GetEngine()
+	sData := make([]AreaSpotModel, 0)
+	if err := e.SQL(r.buildSql()).Find(&sData); err != nil{
+		return nil, err
+	}
+	for i := range sData {
+		sData[i].calc()
+	}
+	return sData, nil
+}

+ 1 - 1
models/ermcpHedgePlan.go

@@ -16,7 +16,7 @@ import (
 type ErmcpHedgePlan struct {
 	Areauserid        int64   `json:"areauserid"  xorm:"'Areauserid'"`               //用户ID
 	Hedgeplanid       string  `json:"hedgeplanid"  xorm:"'Hedgeplanid'"`             //套保计划ID(601+Unix秒时间戳(10位)+xxxxxx)
-	Hedgeplanno       string  `json:"hedgeplanno"  xorm:"'Hedgeplanno'"`             //套保计划编号
+	Hedgeplanno       string  `json:"hedgeplanno"  xorm:"'Hedgeplanno'"`             //套保计划编号(名称)
 	Contracttype      int     `json:"contracttype"  xorm:"'Contracttype'"`           //计划类型 - 1:采购 -1:销售
 	Deliverygoodsid   int     `json:"deliverygoodsid"  xorm:"'Deliverygoodsid'"`     //现货品种ID
 	Deliverygoodsname string  `json:"deliverygoodsname"  xorm:"'Deliverygoodsname'"` //现货品种名称

+ 1 - 0
routers/router.go

@@ -314,6 +314,7 @@ func InitRouter() *gin.Engine {
 		ermcpR.GET("/QueryChangeLog", ermcp.QueryChangeLog)
 		ermcpR.GET("/QueryRealtimeExposure", ermcp.QueryRealtimeExposure)
 		ermcpR.GET("/QueryExposureDetail", ermcp.QueryExposureDetail)
+		ermcpR.GET("/QueryExposureSpot", ermcp.QueryExposureSpot)
 	}
 
 	return r