Kaynağa Gözat

增加查询定价报表接口

zou.yingbin 4 yıl önce
ebeveyn
işleme
523fdf2441

+ 33 - 4
controllers/ermcp3/qryErmcp3Report.go

@@ -48,10 +48,10 @@ func (v QueryDate) IsNumberic(queryType int32) bool {
 // @Param cycletype query int true "周期类型 - 0:日 1:月 2:季 3:年 4:周 5:全报表【原值】"
 // @Param cycletime query string true "周期时间 日(YYYYMMDD) 月(YYYYMM) 季(YYYYQ) 年(YYYY) 周(YYYYMMDD周内任意一天) 全(0)【原值】"
 type QryReportReq struct {
-	USERID    int64  `form:"userid" binding:"required"`                // 用户id
-	QUERYTYPE int32  `form:"querytype" binding:"required,min=1,max=2"` // 查询类型
-	CYCLETYPE int32  `form:"cycletype"`                                // 周期类型
-	CYCLETIME string `form:"cycletime" binding:"required"`             // 周期时间
+	USERID    int64  `form:"userid" binding:"required"`    // 用户id
+	QUERYTYPE int32  `form:"querytype"`                    // 查询类型
+	CYCLETYPE int32  `form:"cycletype"`                    // 周期类型
+	CYCLETIME string `form:"cycletime" binding:"required"` // 周期时间
 
 	TRADEDATE string // 交易日
 	BEGINDATE string // 开始交易日
@@ -614,3 +614,32 @@ func QryTaFutureDataReport(c *gin.Context) {
 		CURRENCYID: req2.CURRENCYID, GOODSGROUPID: req2.GOODSGROUPID, GOODSID: req2.GOODSID, BUYORSELL: req2.BUYORSELL}
 	a.DoGetDataI(&m)
 }
+
+// QrySCMiddleGoodsReport
+// @Summary 查询定价报表
+// @Produce json
+// @Security ApiKeyAuth
+// @Param userid query int true "用户ID"
+// @Param cycletype query int true "周期类型 - 0:日 1:月 2:季 3:年 4:周 5:全报表【原值】"
+// @Param cycletime query string true "周期时间 日(YYYYMMDD) 月(YYYYMM)  季(YYYYQ) 年(YYYY) 周(YYYYMMDD周内任意一天) 全(0)【原值】"
+// @Param spotcontractid query int fasle "现货合同id"
+// @Param middlegoodsid query int fasle "套保品种id"
+// @Param deliverygoodsid query int fasle "现货品种id"
+// @Param wrstandardid query int fasle "现货商品id"
+// @Success 200 {array} models.Ermcp3SCMiddleGoodsReport
+// @Failure 500 {object} app.Response
+// @Router /Ermcp3/QrySCMiddleGoodsReport [get]
+// @Tags 企业风险管理v3(app)
+func QrySCMiddleGoodsReport(c *gin.Context) {
+	a := app.GinUtils{Gin: app.Gin{C: c}}
+	m := models.Ermcp3SCMiddleGoodsReport{}
+	req := QryReportReq{}
+	a.DoBindReq(&req)
+	req.QUERYTYPE = 1 // 查询报表
+	a.CheckParam(&req)
+	req.CovertRequest()
+	a.DoBindReq(&m)
+	m.RECKONDATE, m.CYCLETYPE, m.CYCLETIME = req.TRADEDATE, req.CYCLETYPE, req.CYCLETIME
+	m.BeginDate, m.EndDate, m.QueryType = req.BEGINDATE, req.ENDDATE, req.QUERYTYPE
+	a.DoGetDataI(&m)
+}

+ 253 - 0
docs/docs.go

@@ -3621,6 +3621,86 @@ var doc = `{
                 }
             }
         },
+        "/Ermcp3/QrySCMiddleGoodsReport": {
+            "get": {
+                "security": [
+                    {
+                        "ApiKeyAuth": []
+                    }
+                ],
+                "produces": [
+                    "application/json"
+                ],
+                "tags": [
+                    "企业风险管理v3(app)"
+                ],
+                "summary": "查询定价报表",
+                "parameters": [
+                    {
+                        "type": "integer",
+                        "description": "用户ID",
+                        "name": "userid",
+                        "in": "query",
+                        "required": true
+                    },
+                    {
+                        "type": "integer",
+                        "description": "周期类型 - 0:日 1:月 2:季 3:年 4:周 5:全报表【原值】",
+                        "name": "cycletype",
+                        "in": "query",
+                        "required": true
+                    },
+                    {
+                        "type": "string",
+                        "description": "周期时间 日(YYYYMMDD) 月(YYYYMM)  季(YYYYQ) 年(YYYY) 周(YYYYMMDD周内任意一天) 全(0)【原值】",
+                        "name": "cycletime",
+                        "in": "query",
+                        "required": true
+                    },
+                    {
+                        "type": "integer",
+                        "description": "现货合同id",
+                        "name": "spotcontractid",
+                        "in": "query"
+                    },
+                    {
+                        "type": "integer",
+                        "description": "套保品种id",
+                        "name": "middlegoodsid",
+                        "in": "query"
+                    },
+                    {
+                        "type": "integer",
+                        "description": "现货品种id",
+                        "name": "deliverygoodsid",
+                        "in": "query"
+                    },
+                    {
+                        "type": "integer",
+                        "description": "现货商品id",
+                        "name": "wrstandardid",
+                        "in": "query"
+                    }
+                ],
+                "responses": {
+                    "200": {
+                        "description": "OK",
+                        "schema": {
+                            "type": "array",
+                            "items": {
+                                "$ref": "#/definitions/models.Ermcp3SCMiddleGoodsReport"
+                            }
+                        }
+                    },
+                    "500": {
+                        "description": "Internal Server Error",
+                        "schema": {
+                            "$ref": "#/definitions/app.Response"
+                        }
+                    }
+                }
+            }
+        },
         "/Ermcp3/QryTaFutureDataReport": {
             "get": {
                 "security": [
@@ -20944,6 +21024,179 @@ var doc = `{
                 }
             }
         },
+        "models.Ermcp3SCMiddleGoodsReport": {
+            "type": "object",
+            "properties": {
+                "begindate": {
+                    "description": "开始交易日",
+                    "type": "string"
+                },
+                "contractno": {
+                    "description": "合同编号",
+                    "type": "string"
+                },
+                "contracttype": {
+                    "description": "合同类型 1:采购 -1:销售",
+                    "type": "integer"
+                },
+                "convertratio": {
+                    "description": "折算系数",
+                    "type": "number"
+                },
+                "cycletime": {
+                    "description": "周期时间 月(YYYYMM)  季(YYYYQ) 年(YYYY) 周(YYYYIW) 全(0)【原值】",
+                    "type": "string"
+                },
+                "cycletype": {
+                    "description": "周期类型 - 1:月 2:季 3:年 4:周 5:全报表【原值】",
+                    "type": "integer"
+                },
+                "deliverygoodscode": {
+                    "description": "品种代码",
+                    "type": "string"
+                },
+                "deliverygoodsid": {
+                    "description": "现货品种ID",
+                    "type": "integer"
+                },
+                "deliverygoodsname": {
+                    "description": "品种名称",
+                    "type": "string"
+                },
+                "diffprice": {
+                    "description": "现期价格差 = 今日点价登记均价(基价) - 今日期货成交均价",
+                    "type": "number"
+                },
+                "diffqty": {
+                    "description": "期现数量差 = 套保计划量 - 今日期货关联成交量",
+                    "type": "number"
+                },
+                "enddate": {
+                    "description": "结束交易日",
+                    "type": "string"
+                },
+                "hedgeplanqty": {
+                    "description": "套保计划量 = TodayPricedQty * 折算系数 * (1/(1+增值税率)) * 套保比例",
+                    "type": "number"
+                },
+                "mathname": {
+                    "description": "交易对手方",
+                    "type": "string"
+                },
+                "middlegoodscode": {
+                    "description": "套保品种代码",
+                    "type": "string"
+                },
+                "middlegoodsid": {
+                    "description": "套保品种ID",
+                    "type": "integer"
+                },
+                "middlegoodsname": {
+                    "description": "套保品种名称",
+                    "type": "string"
+                },
+                "middlegoodspricedqty": {
+                    "description": "已定价量(套保品种 - 税前) = PricedQty * 折算系数",
+                    "type": "number"
+                },
+                "middlegoodspricedqty2": {
+                    "description": "已定价量(套保品种- 税后) = MiddleGoodsPricedQty * (1/(1+增值税率))",
+                    "type": "number"
+                },
+                "middlegoodspricedqty3": {
+                    "description": "已定价量(套保品种应套保量) = MiddleGoodsPricedQty2 *  套保比率",
+                    "type": "number"
+                },
+                "needhedgeratio": {
+                    "description": "套保系数",
+                    "type": "number"
+                },
+                "pricedamount": {
+                    "description": "已定价额(现货)",
+                    "type": "number"
+                },
+                "pricedamount2": {
+                    "description": "已定价额(现货-基价额)",
+                    "type": "number"
+                },
+                "pricedqty": {
+                    "description": "已定价量(现货)",
+                    "type": "number"
+                },
+                "reckondate": {
+                    "description": "日照时期(yyyyMMdd)",
+                    "type": "string"
+                },
+                "relatedmiddlegoodsamount": {
+                    "description": "已关联额(期货)",
+                    "type": "number"
+                },
+                "relatedmiddlegoodsqty": {
+                    "description": "已关联量(套保品种)(期货)",
+                    "type": "number"
+                },
+                "spotcontractid": {
+                    "description": "现货合同ID(602+Unix秒时间戳(10位)+xxxxxx)",
+                    "type": "string"
+                },
+                "todayavgfutuprice": {
+                    "description": "今日期货成交均价 = TodayRelatedMiddleGoodsAmount /TodayRelatedMiddleGoodsQty",
+                    "type": "number"
+                },
+                "todayavgprice": {
+                    "description": "今日定价均价 = TodayPricedAmount / TodayPricedQty",
+                    "type": "number"
+                },
+                "todayavgprice2": {
+                    "description": "今日点价登记均价(基价) = TodayPricedAmount2 / TodayPricedQty",
+                    "type": "number"
+                },
+                "todaypricedamount": {
+                    "description": "今日定价额(现货)",
+                    "type": "number"
+                },
+                "todaypricedamount2": {
+                    "description": "今日定价额(现货-基价额)",
+                    "type": "number"
+                },
+                "todaypricedqty": {
+                    "description": "今日定价量(现货)",
+                    "type": "number"
+                },
+                "todayrelatedmiddlegoodsamount": {
+                    "description": "今日关联额(期货)",
+                    "type": "number"
+                },
+                "todayrelatedmiddlegoodsqty": {
+                    "description": "今日关联量(期货)",
+                    "type": "number"
+                },
+                "updatetime": {
+                    "description": "更新时间",
+                    "type": "string"
+                },
+                "userid": {
+                    "description": "合同所属用户id",
+                    "type": "integer"
+                },
+                "vatrate": {
+                    "description": "增值税率",
+                    "type": "number"
+                },
+                "wrstandardcode": {
+                    "description": "商品(品类) 代码",
+                    "type": "string"
+                },
+                "wrstandardid": {
+                    "description": "现货商品ID",
+                    "type": "integer"
+                },
+                "wrstandardname": {
+                    "description": "商品(品类) 名称",
+                    "type": "string"
+                }
+            }
+        },
         "models.Ermcp3SellBuyContract": {
             "type": "object",
             "properties": {

+ 253 - 0
docs/swagger.json

@@ -3605,6 +3605,86 @@
                 }
             }
         },
+        "/Ermcp3/QrySCMiddleGoodsReport": {
+            "get": {
+                "security": [
+                    {
+                        "ApiKeyAuth": []
+                    }
+                ],
+                "produces": [
+                    "application/json"
+                ],
+                "tags": [
+                    "企业风险管理v3(app)"
+                ],
+                "summary": "查询定价报表",
+                "parameters": [
+                    {
+                        "type": "integer",
+                        "description": "用户ID",
+                        "name": "userid",
+                        "in": "query",
+                        "required": true
+                    },
+                    {
+                        "type": "integer",
+                        "description": "周期类型 - 0:日 1:月 2:季 3:年 4:周 5:全报表【原值】",
+                        "name": "cycletype",
+                        "in": "query",
+                        "required": true
+                    },
+                    {
+                        "type": "string",
+                        "description": "周期时间 日(YYYYMMDD) 月(YYYYMM)  季(YYYYQ) 年(YYYY) 周(YYYYMMDD周内任意一天) 全(0)【原值】",
+                        "name": "cycletime",
+                        "in": "query",
+                        "required": true
+                    },
+                    {
+                        "type": "integer",
+                        "description": "现货合同id",
+                        "name": "spotcontractid",
+                        "in": "query"
+                    },
+                    {
+                        "type": "integer",
+                        "description": "套保品种id",
+                        "name": "middlegoodsid",
+                        "in": "query"
+                    },
+                    {
+                        "type": "integer",
+                        "description": "现货品种id",
+                        "name": "deliverygoodsid",
+                        "in": "query"
+                    },
+                    {
+                        "type": "integer",
+                        "description": "现货商品id",
+                        "name": "wrstandardid",
+                        "in": "query"
+                    }
+                ],
+                "responses": {
+                    "200": {
+                        "description": "OK",
+                        "schema": {
+                            "type": "array",
+                            "items": {
+                                "$ref": "#/definitions/models.Ermcp3SCMiddleGoodsReport"
+                            }
+                        }
+                    },
+                    "500": {
+                        "description": "Internal Server Error",
+                        "schema": {
+                            "$ref": "#/definitions/app.Response"
+                        }
+                    }
+                }
+            }
+        },
         "/Ermcp3/QryTaFutureDataReport": {
             "get": {
                 "security": [
@@ -20928,6 +21008,179 @@
                 }
             }
         },
+        "models.Ermcp3SCMiddleGoodsReport": {
+            "type": "object",
+            "properties": {
+                "begindate": {
+                    "description": "开始交易日",
+                    "type": "string"
+                },
+                "contractno": {
+                    "description": "合同编号",
+                    "type": "string"
+                },
+                "contracttype": {
+                    "description": "合同类型 1:采购 -1:销售",
+                    "type": "integer"
+                },
+                "convertratio": {
+                    "description": "折算系数",
+                    "type": "number"
+                },
+                "cycletime": {
+                    "description": "周期时间 月(YYYYMM)  季(YYYYQ) 年(YYYY) 周(YYYYIW) 全(0)【原值】",
+                    "type": "string"
+                },
+                "cycletype": {
+                    "description": "周期类型 - 1:月 2:季 3:年 4:周 5:全报表【原值】",
+                    "type": "integer"
+                },
+                "deliverygoodscode": {
+                    "description": "品种代码",
+                    "type": "string"
+                },
+                "deliverygoodsid": {
+                    "description": "现货品种ID",
+                    "type": "integer"
+                },
+                "deliverygoodsname": {
+                    "description": "品种名称",
+                    "type": "string"
+                },
+                "diffprice": {
+                    "description": "现期价格差 = 今日点价登记均价(基价) - 今日期货成交均价",
+                    "type": "number"
+                },
+                "diffqty": {
+                    "description": "期现数量差 = 套保计划量 - 今日期货关联成交量",
+                    "type": "number"
+                },
+                "enddate": {
+                    "description": "结束交易日",
+                    "type": "string"
+                },
+                "hedgeplanqty": {
+                    "description": "套保计划量 = TodayPricedQty * 折算系数 * (1/(1+增值税率)) * 套保比例",
+                    "type": "number"
+                },
+                "mathname": {
+                    "description": "交易对手方",
+                    "type": "string"
+                },
+                "middlegoodscode": {
+                    "description": "套保品种代码",
+                    "type": "string"
+                },
+                "middlegoodsid": {
+                    "description": "套保品种ID",
+                    "type": "integer"
+                },
+                "middlegoodsname": {
+                    "description": "套保品种名称",
+                    "type": "string"
+                },
+                "middlegoodspricedqty": {
+                    "description": "已定价量(套保品种 - 税前) = PricedQty * 折算系数",
+                    "type": "number"
+                },
+                "middlegoodspricedqty2": {
+                    "description": "已定价量(套保品种- 税后) = MiddleGoodsPricedQty * (1/(1+增值税率))",
+                    "type": "number"
+                },
+                "middlegoodspricedqty3": {
+                    "description": "已定价量(套保品种应套保量) = MiddleGoodsPricedQty2 *  套保比率",
+                    "type": "number"
+                },
+                "needhedgeratio": {
+                    "description": "套保系数",
+                    "type": "number"
+                },
+                "pricedamount": {
+                    "description": "已定价额(现货)",
+                    "type": "number"
+                },
+                "pricedamount2": {
+                    "description": "已定价额(现货-基价额)",
+                    "type": "number"
+                },
+                "pricedqty": {
+                    "description": "已定价量(现货)",
+                    "type": "number"
+                },
+                "reckondate": {
+                    "description": "日照时期(yyyyMMdd)",
+                    "type": "string"
+                },
+                "relatedmiddlegoodsamount": {
+                    "description": "已关联额(期货)",
+                    "type": "number"
+                },
+                "relatedmiddlegoodsqty": {
+                    "description": "已关联量(套保品种)(期货)",
+                    "type": "number"
+                },
+                "spotcontractid": {
+                    "description": "现货合同ID(602+Unix秒时间戳(10位)+xxxxxx)",
+                    "type": "string"
+                },
+                "todayavgfutuprice": {
+                    "description": "今日期货成交均价 = TodayRelatedMiddleGoodsAmount /TodayRelatedMiddleGoodsQty",
+                    "type": "number"
+                },
+                "todayavgprice": {
+                    "description": "今日定价均价 = TodayPricedAmount / TodayPricedQty",
+                    "type": "number"
+                },
+                "todayavgprice2": {
+                    "description": "今日点价登记均价(基价) = TodayPricedAmount2 / TodayPricedQty",
+                    "type": "number"
+                },
+                "todaypricedamount": {
+                    "description": "今日定价额(现货)",
+                    "type": "number"
+                },
+                "todaypricedamount2": {
+                    "description": "今日定价额(现货-基价额)",
+                    "type": "number"
+                },
+                "todaypricedqty": {
+                    "description": "今日定价量(现货)",
+                    "type": "number"
+                },
+                "todayrelatedmiddlegoodsamount": {
+                    "description": "今日关联额(期货)",
+                    "type": "number"
+                },
+                "todayrelatedmiddlegoodsqty": {
+                    "description": "今日关联量(期货)",
+                    "type": "number"
+                },
+                "updatetime": {
+                    "description": "更新时间",
+                    "type": "string"
+                },
+                "userid": {
+                    "description": "合同所属用户id",
+                    "type": "integer"
+                },
+                "vatrate": {
+                    "description": "增值税率",
+                    "type": "number"
+                },
+                "wrstandardcode": {
+                    "description": "商品(品类) 代码",
+                    "type": "string"
+                },
+                "wrstandardid": {
+                    "description": "现货商品ID",
+                    "type": "integer"
+                },
+                "wrstandardname": {
+                    "description": "商品(品类) 名称",
+                    "type": "string"
+                }
+            }
+        },
         "models.Ermcp3SellBuyContract": {
             "type": "object",
             "properties": {

+ 181 - 0
docs/swagger.yaml

@@ -5721,6 +5721,135 @@ definitions:
         description: 账户类型 -  1:交易所 2:机构 3:会员子机构 4:经纪人 5:投资者 6:客户 7:企业成员(云平台)
         type: integer
     type: object
+  models.Ermcp3SCMiddleGoodsReport:
+    properties:
+      begindate:
+        description: 开始交易日
+        type: string
+      contractno:
+        description: 合同编号
+        type: string
+      contracttype:
+        description: 合同类型 1:采购 -1:销售
+        type: integer
+      convertratio:
+        description: 折算系数
+        type: number
+      cycletime:
+        description: 周期时间 月(YYYYMM)  季(YYYYQ) 年(YYYY) 周(YYYYIW) 全(0)【原值】
+        type: string
+      cycletype:
+        description: 周期类型 - 1:月 2:季 3:年 4:周 5:全报表【原值】
+        type: integer
+      deliverygoodscode:
+        description: 品种代码
+        type: string
+      deliverygoodsid:
+        description: 现货品种ID
+        type: integer
+      deliverygoodsname:
+        description: 品种名称
+        type: string
+      diffprice:
+        description: 现期价格差 = 今日点价登记均价(基价) - 今日期货成交均价
+        type: number
+      diffqty:
+        description: 期现数量差 = 套保计划量 - 今日期货关联成交量
+        type: number
+      enddate:
+        description: 结束交易日
+        type: string
+      hedgeplanqty:
+        description: 套保计划量 = TodayPricedQty * 折算系数 * (1/(1+增值税率)) * 套保比例
+        type: number
+      mathname:
+        description: 交易对手方
+        type: string
+      middlegoodscode:
+        description: 套保品种代码
+        type: string
+      middlegoodsid:
+        description: 套保品种ID
+        type: integer
+      middlegoodsname:
+        description: 套保品种名称
+        type: string
+      middlegoodspricedqty:
+        description: 已定价量(套保品种 - 税前) = PricedQty * 折算系数
+        type: number
+      middlegoodspricedqty2:
+        description: 已定价量(套保品种- 税后) = MiddleGoodsPricedQty * (1/(1+增值税率))
+        type: number
+      middlegoodspricedqty3:
+        description: 已定价量(套保品种应套保量) = MiddleGoodsPricedQty2 *  套保比率
+        type: number
+      needhedgeratio:
+        description: 套保系数
+        type: number
+      pricedamount:
+        description: 已定价额(现货)
+        type: number
+      pricedamount2:
+        description: 已定价额(现货-基价额)
+        type: number
+      pricedqty:
+        description: 已定价量(现货)
+        type: number
+      reckondate:
+        description: 日照时期(yyyyMMdd)
+        type: string
+      relatedmiddlegoodsamount:
+        description: 已关联额(期货)
+        type: number
+      relatedmiddlegoodsqty:
+        description: 已关联量(套保品种)(期货)
+        type: number
+      spotcontractid:
+        description: 现货合同ID(602+Unix秒时间戳(10位)+xxxxxx)
+        type: string
+      todayavgfutuprice:
+        description: 今日期货成交均价 = TodayRelatedMiddleGoodsAmount /TodayRelatedMiddleGoodsQty
+        type: number
+      todayavgprice:
+        description: 今日定价均价 = TodayPricedAmount / TodayPricedQty
+        type: number
+      todayavgprice2:
+        description: 今日点价登记均价(基价) = TodayPricedAmount2 / TodayPricedQty
+        type: number
+      todaypricedamount:
+        description: 今日定价额(现货)
+        type: number
+      todaypricedamount2:
+        description: 今日定价额(现货-基价额)
+        type: number
+      todaypricedqty:
+        description: 今日定价量(现货)
+        type: number
+      todayrelatedmiddlegoodsamount:
+        description: 今日关联额(期货)
+        type: number
+      todayrelatedmiddlegoodsqty:
+        description: 今日关联量(期货)
+        type: number
+      updatetime:
+        description: 更新时间
+        type: string
+      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.Ermcp3SellBuyContract:
     properties:
       accountid:
@@ -20294,6 +20423,58 @@ paths:
       summary: 查询财务报表
       tags:
       - 企业风险管理v3(app)
+  /Ermcp3/QrySCMiddleGoodsReport:
+    get:
+      parameters:
+      - description: 用户ID
+        in: query
+        name: userid
+        required: true
+        type: integer
+      - description: 周期类型 - 0:日 1:月 2:季 3:年 4:周 5:全报表【原值】
+        in: query
+        name: cycletype
+        required: true
+        type: integer
+      - description: 周期时间 日(YYYYMMDD) 月(YYYYMM)  季(YYYYQ) 年(YYYY) 周(YYYYMMDD周内任意一天) 全(0)【原值】
+        in: query
+        name: cycletime
+        required: true
+        type: string
+      - description: 现货合同id
+        in: query
+        name: spotcontractid
+        type: integer
+      - description: 套保品种id
+        in: query
+        name: middlegoodsid
+        type: integer
+      - description: 现货品种id
+        in: query
+        name: deliverygoodsid
+        type: integer
+      - description: 现货商品id
+        in: query
+        name: wrstandardid
+        type: integer
+      produces:
+      - application/json
+      responses:
+        "200":
+          description: OK
+          schema:
+            items:
+              $ref: '#/definitions/models.Ermcp3SCMiddleGoodsReport'
+            type: array
+        "500":
+          description: Internal Server Error
+          schema:
+            $ref: '#/definitions/app.Response'
+      security:
+      - ApiKeyAuth: []
+      summary: 查询定价报表
+      tags:
+      - 企业风险管理v3(app)
   /Ermcp3/QryTaFutureDataReport:
     get:
       parameters:

+ 211 - 0
models/ermcp3Report.go

@@ -2819,3 +2819,214 @@ func (r *Ermcp3ExposureParamChLog) GetDataEx() (interface{}, error) {
 	}
 	return sData, err
 }
+
+// Ermcp3SCMiddleGoodsReport 定价报表
+type Ermcp3SCMiddleGoodsReport struct {
+	RECKONDATE                    string   `json:"reckondate"  xorm:"RECKONDATE" form:"reckondate"`                     // 日照时期(yyyyMMdd)
+	CYCLETYPE                     int32    `json:"cycletype"  xorm:"CYCLETYPE" form:"cycletype"`                        // 周期类型 - 1:月 2:季 3:年 4:周 5:全报表【原值】
+	CYCLETIME                     string   `json:"cycletime"  xorm:"CYCLETIME" form:"cycletime"`                        // 周期时间 月(YYYYMM)  季(YYYYQ) 年(YYYY) 周(YYYYIW) 全(0)【原值】
+	SPOTCONTRACTID                string   `json:"spotcontractid"  xorm:"SPOTCONTRACTID" form:"spotcontractid"`         // 现货合同ID(602+Unix秒时间戳(10位)+xxxxxx)
+	MIDDLEGOODSID                 int64    `json:"middlegoodsid"  xorm:"MIDDLEGOODSID" form:"middlegoodsid"`            // 套保品种ID
+	DELIVERYGOODSID               int64    `json:"deliverygoodsid"  xorm:"DELIVERYGOODSID" form:"deliverygoodsid"`      // 现货品种ID
+	WRSTANDARDID                  int64    `json:"wrstandardid"  xorm:"WRSTANDARDID" form:"wrstandardid"`               // 现货商品ID
+	PRICEDQTY                     SFLOAT64 `json:"pricedqty"  xorm:"PRICEDQTY"`                                         // 已定价量(现货)
+	MIDDLEGOODSPRICEDQTY          SFLOAT64 `json:"middlegoodspricedqty"  xorm:"MIDDLEGOODSPRICEDQTY"`                   // 已定价量(套保品种 - 税前) = PricedQty * 折算系数
+	MIDDLEGOODSPRICEDQTY2         SFLOAT64 `json:"middlegoodspricedqty2"  xorm:"MIDDLEGOODSPRICEDQTY2"`                 // 已定价量(套保品种- 税后) = MiddleGoodsPricedQty * (1/(1+增值税率))
+	MIDDLEGOODSPRICEDQTY3         SFLOAT64 `json:"middlegoodspricedqty3"  xorm:"MIDDLEGOODSPRICEDQTY3"`                 // 已定价量(套保品种应套保量) = MiddleGoodsPricedQty2 *  套保比率
+	RELATEDMIDDLEGOODSQTY         SFLOAT64 `json:"relatedmiddlegoodsqty"  xorm:"RELATEDMIDDLEGOODSQTY"`                 // 已关联量(套保品种)(期货)
+	UPDATETIME                    string   `json:"updatetime"  xorm:"UPDATETIME"`                                       // 更新时间
+	TODAYRELATEDMIDDLEGOODSQTY    SFLOAT64 `json:"todayrelatedmiddlegoodsqty"  xorm:"TODAYRELATEDMIDDLEGOODSQTY"`       // 今日关联量(期货)
+	TODAYRELATEDMIDDLEGOODSAMOUNT SFLOAT64 `json:"todayrelatedmiddlegoodsamount"  xorm:"TODAYRELATEDMIDDLEGOODSAMOUNT"` // 今日关联额(期货)
+	RELATEDMIDDLEGOODSAMOUNT      SFLOAT64 `json:"relatedmiddlegoodsamount"  xorm:"RELATEDMIDDLEGOODSAMOUNT"`           // 已关联额(期货)
+	TODAYPRICEDQTY                SFLOAT64 `json:"todaypricedqty"  xorm:"TODAYPRICEDQTY"`                               // 今日定价量(现货)
+	TODAYPRICEDAMOUNT             SFLOAT64 `json:"todaypricedamount"  xorm:"TODAYPRICEDAMOUNT"`                         // 今日定价额(现货)
+	PRICEDAMOUNT                  SFLOAT64 `json:"pricedamount"  xorm:"PRICEDAMOUNT"`                                   // 已定价额(现货)
+	TODAYPRICEDAMOUNT2            SFLOAT64 `json:"todaypricedamount2"  xorm:"TODAYPRICEDAMOUNT2"`                       // 今日定价额(现货-基价额)
+	PRICEDAMOUNT2                 SFLOAT64 `json:"pricedamount2"  xorm:"PRICEDAMOUNT2"`                                 // 已定价额(现货-基价额)
+
+	USERID            int64    `json:"userid"  xorm:"'USERID'" form:"userid"`         // 合同所属用户id
+	CONTRACTNO        string   `json:"contractno"  xorm:"'CONTRACTNO'"`               // 合同编号
+	CONTRACTTYPE      int32    `json:"contracttype"  xorm:"'CONTRACTTYPE'"`           // 合同类型 1:采购 -1:销售
+	MATHNAME          string   `json:"mathname"  xorm:"'MATHNAME'"`                   // 交易对手方
+	DELIVERYGOODSCODE string   `json:"deliverygoodscode"  xorm:"'DELIVERYGOODSCODE'"` // 品种代码
+	DELIVERYGOODSNAME string   `json:"deliverygoodsname"  xorm:"'DELIVERYGOODSNAME'"` // 品种名称
+	WRSTANDARDCODE    string   `json:"wrstandardcode"  xorm:"'WRSTANDARDCODE'"`       // 商品(品类) 代码
+	WRSTANDARDNAME    string   `json:"wrstandardname"  xorm:"'WRSTANDARDNAME'"`       // 商品(品类) 名称
+	VATRATE           SFLOAT64 `json:"vatrate"  xorm:"'VATRATE'"`                     // 增值税率
+	MIDDLEGOODSCODE   string   `json:"middlegoodscode"  xorm:"'MIDDLEGOODSCODE'"`     // 套保品种代码
+	MIDDLEGOODSNAME   string   `json:"middlegoodsname"  xorm:"'MIDDLEGOODSNAME'"`     // 套保品种名称
+	NEEDHEDGERATIO    SFLOAT64 `json:"needhedgeratio"  xorm:"'NEEDHEDGERATIO'"`       // 套保系数
+	CONVERTRATIO      SFLOAT64 `json:"convertratio"  xorm:"'CONVERTRATIO'"`           // 折算系数
+
+	TODAYAVGPRICE     SFLOAT64 `json:"todayavgprice"  xorm:"'TODAYAVGPRICE'"`         // 今日定价均价 = TodayPricedAmount / TodayPricedQty
+	TODAYAVGPRICE2    SFLOAT64 `json:"todayavgprice2"  xorm:"'TODAYAVGPRICE2'"`       // 今日点价登记均价(基价) = TodayPricedAmount2 / TodayPricedQty
+	HEDGEPLANQTY      SFLOAT64 `json:"hedgeplanqty"  xorm:"'HEDGEPLANQTY'"`           // 套保计划量 = TodayPricedQty * 折算系数 * (1/(1+增值税率)) * 套保比例
+	TODAYAVGFUTUPRICE SFLOAT64 `json:"todayavgfutuprice"  xorm:"'TODAYAVGFUTUPRICE'"` // 今日期货成交均价 = TodayRelatedMiddleGoodsAmount /TodayRelatedMiddleGoodsQty
+	DIFFPRICE         SFLOAT64 `json:"diffprice"  xorm:"'DIFFPRICE'"`                 // 现期价格差 = 今日点价登记均价(基价) - 今日期货成交均价
+	DIFFQTY           SFLOAT64 `json:"diffqty"  xorm:"'DIFFQTY'"`                     // 期现数量差 = 套保计划量 - 今日期货关联成交量
+
+	QueryType int32  `json:"-"`         // 查询类型 1-报表 2-报表明细
+	BeginDate string `json:"begindate"` // 开始交易日
+	EndDate   string `json:"enddate"`   // 结束交易日
+}
+
+func (r *Ermcp3SCMiddleGoodsReport) calc() {
+
+	if r.TODAYPRICEDQTY > 0 {
+		r.TODAYAVGPRICE = r.TODAYPRICEDAMOUNT / r.TODAYPRICEDQTY
+		r.TODAYAVGPRICE.Round(2)
+
+		r.TODAYAVGPRICE2 = r.TODAYPRICEDAMOUNT2 / r.TODAYPRICEDQTY
+		r.TODAYAVGPRICE2.Round(2)
+	}
+
+	r.HEDGEPLANQTY = r.TODAYPRICEDQTY * r.CONVERTRATIO * (1 / (1 + r.VATRATE)) * r.NEEDHEDGERATIO
+	if r.TODAYRELATEDMIDDLEGOODSQTY > 0 {
+		r.TODAYAVGFUTUPRICE = r.TODAYRELATEDMIDDLEGOODSAMOUNT / r.TODAYRELATEDMIDDLEGOODSQTY
+		r.TODAYAVGFUTUPRICE.Round(2)
+
+		r.DIFFPRICE = r.TODAYAVGPRICE2 - r.TODAYAVGFUTUPRICE
+		r.DIFFPRICE.Round(2)
+
+		r.DIFFQTY = r.HEDGEPLANQTY - r.TODAYRELATEDMIDDLEGOODSQTY
+		r.DIFFQTY.Round(8)
+	}
+}
+
+func (r *Ermcp3SCMiddleGoodsReport) buildSql() string {
+	if r.CYCLETYPE == 0 {
+		return r.buildSqlDay()
+	} else {
+		return r.buildSqlCycle()
+	}
+}
+
+func (r *Ermcp3SCMiddleGoodsReport) buildSqlDay() string {
+	var sqlId utils.SQLVal = `
+select t.reckondate,
+       to_char(t.spotcontractid) spotcontractid,
+       t.middlegoodsid,
+       t.deliverygoodsid,
+       t.wrstandardid,
+       t.pricedqty,
+       t.middlegoodspricedqty,
+       t.middlegoodspricedqty2,
+       t.middlegoodspricedqty3,
+       t.relatedmiddlegoodsqty,
+       t.todayrelatedmiddlegoodsqty,
+       t.todayrelatedmiddlegoodsamount,
+       t.relatedmiddlegoodsamount,
+       t.todaypricedqty,
+       t.todaypricedamount,
+       t.pricedamount,
+       t.todaypricedamount2,
+       t.pricedamount2,
+       s.userid,
+       s.contractno,
+       s.contracttype,
+       u.accountname mathname,
+       g.deliverygoodscode,
+       g.deliverygoodsname,
+       w.wrstandardcode,
+       w.wrstandardname,
+       w.vatrate,
+       m.middlegoodscode,
+       m.middlegoodsname,
+       m.needhedgeratio,
+       c.convertratio
+  from Reckon_ERMCP_SCMiddleGoods t
+ inner join ermcp_spotcontract s
+    on t.spotcontractid = s.spotcontractid
+  left join useraccount u
+    on u.userid = (decode(s.contracttype, 1, s.selluserid, s.buyuserid))
+  left join deliverygoods g
+    on t.deliverygoodsid = g.deliverygoodsid
+  left join wrstandard w
+    on t.wrstandardid = w.wrstandardid
+  left join erms_middlegoods m
+    on t.middlegoodsid = m.middlegoodsid
+  left join erms2_wrsconvertdetail c
+    on t.middlegoodsid = c.middlegoodsid
+   and t.wrstandardid = c.wrstandardid
+ where 1 = 1
+`
+	sqlId.JoinFormat(" and %v in (s.userid, s.tradeuserid, s.saleuserid, s.tradeuserid)", r.USERID)
+	sqlId.And("t.RECKONDATE", r.RECKONDATE)
+	sqlId.AndEx("t.middlegoodsid", r.MIDDLEGOODSID, r.MIDDLEGOODSID > 0)
+	sqlId.AndEx("t.deliverygoodsid", r.DELIVERYGOODSID, r.DELIVERYGOODSID > 0)
+	sqlId.AndEx("t.wrstandardid", r.WRSTANDARDID, r.WRSTANDARDID > 0)
+	sqlId.AndInterEx("t.spotcontractid", r.SPOTCONTRACTID, r.SPOTCONTRACTID != "")
+
+	return sqlId.String()
+}
+
+func (r *Ermcp3SCMiddleGoodsReport) buildSqlCycle() string {
+	var sqlId utils.SQLVal = `
+select t.cycletype,
+       t.cycletime,
+       to_char(t.spotcontractid) spotcontractid,
+       t.middlegoodsid,
+       t.deliverygoodsid,
+       t.wrstandardid,
+       t.pricedqty,
+       t.middlegoodspricedqty,
+       t.middlegoodspricedqty2,
+       t.middlegoodspricedqty3,
+       t.relatedmiddlegoodsqty,
+       t.todayrelatedmiddlegoodsqty,
+       t.todayrelatedmiddlegoodsamount,
+       t.relatedmiddlegoodsamount,
+       t.todaypricedqty,
+       t.todaypricedamount,
+       t.pricedamount,
+       t.todaypricedamount2,
+       t.pricedamount2,
+       s.userid,
+       s.contractno,
+       s.contracttype,
+       u.accountname mathname,
+       g.deliverygoodscode,
+       g.deliverygoodsname,
+       w.wrstandardcode,
+       w.wrstandardname,
+       w.vatrate,
+       m.middlegoodscode,
+       m.middlegoodsname,
+       m.needhedgeratio,
+       c.convertratio
+  from Report_ERMCP_SCMiddleGoods t
+ inner join ermcp_spotcontract s
+    on t.spotcontractid = s.spotcontractid
+  left join useraccount u
+    on u.userid = (decode(s.contracttype, 1, s.selluserid, s.buyuserid))
+  left join deliverygoods g
+    on t.deliverygoodsid = g.deliverygoodsid
+  left join wrstandard w
+    on t.wrstandardid = w.wrstandardid
+  left join erms_middlegoods m
+    on t.middlegoodsid = m.middlegoodsid
+  left join erms2_wrsconvertdetail c
+    on t.middlegoodsid = c.middlegoodsid
+   and t.wrstandardid = c.wrstandardid
+ where 1 = 1
+`
+	sqlId.JoinFormat(" and %v in (s.userid, s.tradeuserid, s.saleuserid, s.tradeuserid)", r.USERID)
+	sqlId.And("t.CYCLETYPE", r.CYCLETYPE)
+	sqlId.And("t.CYCLETIME", r.CYCLETIME)
+	sqlId.AndEx("t.middlegoodsid", r.MIDDLEGOODSID, r.MIDDLEGOODSID > 0)
+	sqlId.AndEx("t.deliverygoodsid", r.DELIVERYGOODSID, r.DELIVERYGOODSID > 0)
+	sqlId.AndEx("t.wrstandardid", r.WRSTANDARDID, r.WRSTANDARDID > 0)
+	sqlId.AndInterEx("t.spotcontractid", r.SPOTCONTRACTID, r.SPOTCONTRACTID != "")
+
+	return sqlId.String()
+}
+
+// GetDataEx 获取定价报表
+func (r *Ermcp3SCMiddleGoodsReport) GetDataEx() (interface{}, error) {
+	sData := make([]Ermcp3SCMiddleGoodsReport, 0)
+	err := db.GetEngine().SQL(r.buildSql()).Find(&sData)
+	for i := range sData {
+		sData[i].calc()
+	}
+	return sData, err
+}

+ 1 - 0
routers/router.go

@@ -459,6 +459,7 @@ func InitRouter() *gin.Engine {
 		ermcp3R.GET("/QryFinanceReport", ermcp3.QryFinanceReport)
 		ermcp3R.GET("/QryAreaSumPL", ermcp3.QryAreaSumPL)
 		ermcp3R.GET("/QryTaFutureDataReport", ermcp3.QryTaFutureDataReport)
+		ermcp3R.GET("/QrySCMiddleGoodsReport", ermcp3.QrySCMiddleGoodsReport)
 	}
 
 	// ****************************大连千海金******************************