Procházet zdrojové kódy

查询现货报表接口增加请求参数

zou.yingbin před 3 roky
rodič
revize
47a11e4830
5 změnil soubory, kde provedl 120 přidání a 29 odebrání
  1. 8 1
      controllers/ermcp3/qryErmcp3Report.go
  2. 13 6
      docs/docs.go
  3. 13 6
      docs/swagger.json
  4. 11 6
      docs/swagger.yaml
  5. 75 10
      models/ermcp3Report.go

+ 8 - 1
controllers/ermcp3/qryErmcp3Report.go

@@ -363,6 +363,7 @@ func QryAreaExpourseParamChLogDetail(c *gin.Context) {
 
 // QryAreaSpotplReport
 // @Summary 查询现货报表
+// @Description 目前pcweb的日/周/月报表与手机端的汇总维度不同, 所以增加了可选参数sumflag参数, pcweb请填1
 // @Produce json
 // @Security ApiKeyAuth
 // @Param userid query int true "用户ID"
@@ -371,6 +372,7 @@ func QryAreaExpourseParamChLogDetail(c *gin.Context) {
 // @Param cycletime query string true "周期时间 日(YYYYMMDD) 月(YYYYMM)  季(YYYYQ) 年(YYYY) 周(YYYYMMDD周内任意一天) 全(0)【原值】"
 // @Param deliverygoodsid query int false "现货品种id(明细必填)"
 // @Param currencyid query int false "币种id(明细必填)"
+// @Param sumflag query int false "日/周/月报表汇总维度 1:品种+品类"
 // @Success 200 {array} models.Ermcp3AreaSpotPLReport
 // @Failure 500 {object} app.Response
 // @Router /Ermcp3/QryAreaSpotplReport [get]
@@ -384,7 +386,12 @@ func QryAreaSpotplReport(c *gin.Context) {
 		DELIVERYGOODSID int64 `form:"deliverygoodsid"` // 品种
 		WRSTANDARDID    int64 `form:"wrstandardid"`    // 品类
 		CURRENCYID      int32 `form:"currencyid"`      // 币种
+		SumFlag         int32 `form:"sumflag"`         // 日报表统计维度 1:品种+品类
 	}{}
+	sumFlag := c.Query("sumflag")
+	if sumFlag == "1" {
+		req2.SumFlag = 1
+	}
 	if req.QUERYTYPE == 2 {
 		a.DoBindReq(&req2)
 		a.CheckParamF(func() bool {
@@ -397,7 +404,7 @@ func QryAreaSpotplReport(c *gin.Context) {
 	req.CovertRequest()
 	m := models.Ermcp3AreaSpotPLReport{AREAUSERID: req.USERID, QueryType: req.QUERYTYPE, RECKONDATE: req.TRADEDATE,
 		CYCLETYPE: req.CYCLETYPE, CYCLETIME: req.CYCLETIME, BeginDate: req.BEGINDATE, EndDate: req.ENDDATE,
-		DELIVERYGOODSID: req2.DELIVERYGOODSID, WRSTANDARDID: req2.WRSTANDARDID, CURRENCYID: req2.CURRENCYID}
+		DELIVERYGOODSID: req2.DELIVERYGOODSID, WRSTANDARDID: req2.WRSTANDARDID, CURRENCYID: req2.CURRENCYID, SumFlag: req2.SumFlag}
 	a.DoGetDataI(&m)
 }
 

+ 13 - 6
docs/docs.go

@@ -3369,6 +3369,7 @@ var doc = `{
                         "ApiKeyAuth": []
                     }
                 ],
+                "description": "目前pcweb的日/周/月报表与手机端的汇总维度不同, 所以增加了可选参数sumflag参数, pcweb请填1",
                 "produces": [
                     "application/json"
                 ],
@@ -3416,6 +3417,12 @@ var doc = `{
                         "description": "币种id(明细必填)",
                         "name": "currencyid",
                         "in": "query"
+                    },
+                    {
+                        "type": "integer",
+                        "description": "日/周/月报表汇总维度 1:品种+品类",
+                        "name": "sumflag",
+                        "in": "query"
                     }
                 ],
                 "responses": {
@@ -19819,7 +19826,7 @@ var doc = `{
                     "type": "integer"
                 },
                 "deliverygoodscode": {
-                    "description": "现货品代码",
+                    "description": "现货品代码",
                     "type": "string"
                 },
                 "deliverygoodsid": {
@@ -19827,7 +19834,7 @@ var doc = `{
                     "type": "integer"
                 },
                 "deliverygoodsname": {
-                    "description": "现货品名称",
+                    "description": "现货品名称",
                     "type": "string"
                 },
                 "enddate": {
@@ -19835,7 +19842,7 @@ var doc = `{
                     "type": "string"
                 },
                 "enumdicname": {
-                    "description": "现货品单位名称",
+                    "description": "现货品单位名称(作废)",
                     "type": "string"
                 },
                 "floatpl": {
@@ -19843,7 +19850,7 @@ var doc = `{
                     "type": "number"
                 },
                 "goodsunitid": {
-                    "description": "现货品单位id",
+                    "description": "现货品单位id(作废)",
                     "type": "integer"
                 },
                 "oriamount": {
@@ -19931,7 +19938,7 @@ var doc = `{
                     "type": "integer"
                 },
                 "wrstandardcode": {
-                    "description": "品类代码",
+                    "description": "现货商品(品类)代码",
                     "type": "string"
                 },
                 "wrstandardid": {
@@ -19939,7 +19946,7 @@ var doc = `{
                     "type": "integer"
                 },
                 "wrstandardname": {
-                    "description": "品类名称",
+                    "description": "现货商品(品类)名称",
                     "type": "string"
                 }
             }

+ 13 - 6
docs/swagger.json

@@ -3354,6 +3354,7 @@
                         "ApiKeyAuth": []
                     }
                 ],
+                "description": "目前pcweb的日/周/月报表与手机端的汇总维度不同, 所以增加了可选参数sumflag参数, pcweb请填1",
                 "produces": [
                     "application/json"
                 ],
@@ -3401,6 +3402,12 @@
                         "description": "币种id(明细必填)",
                         "name": "currencyid",
                         "in": "query"
+                    },
+                    {
+                        "type": "integer",
+                        "description": "日/周/月报表汇总维度 1:品种+品类",
+                        "name": "sumflag",
+                        "in": "query"
                     }
                 ],
                 "responses": {
@@ -19804,7 +19811,7 @@
                     "type": "integer"
                 },
                 "deliverygoodscode": {
-                    "description": "现货品代码",
+                    "description": "现货品代码",
                     "type": "string"
                 },
                 "deliverygoodsid": {
@@ -19812,7 +19819,7 @@
                     "type": "integer"
                 },
                 "deliverygoodsname": {
-                    "description": "现货品名称",
+                    "description": "现货品名称",
                     "type": "string"
                 },
                 "enddate": {
@@ -19820,7 +19827,7 @@
                     "type": "string"
                 },
                 "enumdicname": {
-                    "description": "现货品单位名称",
+                    "description": "现货品单位名称(作废)",
                     "type": "string"
                 },
                 "floatpl": {
@@ -19828,7 +19835,7 @@
                     "type": "number"
                 },
                 "goodsunitid": {
-                    "description": "现货品单位id",
+                    "description": "现货品单位id(作废)",
                     "type": "integer"
                 },
                 "oriamount": {
@@ -19916,7 +19923,7 @@
                     "type": "integer"
                 },
                 "wrstandardcode": {
-                    "description": "品类代码",
+                    "description": "现货商品(品类)代码",
                     "type": "string"
                 },
                 "wrstandardid": {
@@ -19924,7 +19931,7 @@
                     "type": "integer"
                 },
                 "wrstandardname": {
-                    "description": "品类名称",
+                    "description": "现货商品(品类)名称",
                     "type": "string"
                 }
             }

+ 11 - 6
docs/swagger.yaml

@@ -4088,25 +4088,25 @@ definitions:
         description: 周期类型 - 1:月 2:季 3:年 4:周 5:全报表【原值】
         type: integer
       deliverygoodscode:
-        description: 现货品代码
+        description: 现货品代码
         type: string
       deliverygoodsid:
         description: 现货品种ID
         type: integer
       deliverygoodsname:
-        description: 现货品名称
+        description: 现货品名称
         type: string
       enddate:
         description: 结束交易日
         type: string
       enumdicname:
-        description: 现货品单位名称
+        description: 现货品单位名称(作废)
         type: string
       floatpl:
         description: 浮动损益
         type: number
       goodsunitid:
-        description: 现货品单位id
+        description: 现货品单位id(作废)
         type: integer
       oriamount:
         description: 期初额
@@ -4172,13 +4172,13 @@ definitions:
         description: 仓单要素类型ID(212+Unix秒时间戳(10位)+xxxxxx)
         type: integer
       wrstandardcode:
-        description: 品类代码
+        description: 现货商品(品类)代码
         type: string
       wrstandardid:
         description: 现货品类ID
         type: integer
       wrstandardname:
-        description: 品类名称
+        description: 现货商品(品类)名称
         type: string
     type: object
   models.Ermcp3AreaStock:
@@ -21588,6 +21588,7 @@ paths:
       - 企业风险管理v3(app)
   /Ermcp3/QryAreaSpotplReport:
     get:
+      description: 目前pcweb的日/周/月报表与手机端的汇总维度不同, 所以增加了可选参数sumflag参数, pcweb请填1
       parameters:
       - description: 用户ID
         in: query
@@ -21618,6 +21619,10 @@ paths:
         in: query
         name: currencyid
         type: integer
+      - description: 日/周/月报表汇总维度 1:品种+品类
+        in: query
+        name: sumflag
+        type: integer
       produces:
       - application/json
       responses:

+ 75 - 10
models/ermcp3Report.go

@@ -911,22 +911,23 @@ type Ermcp3AreaSpotPLReport struct {
 	UPDATETIME            string   `json:"updatetime"  xorm:"UPDATETIME"`                       // 更新时间
 	TODAYINQTY            float64  `json:"todayinqty"  xorm:"TODAYINQTY"`                       // 今日入库量(今入库量)
 	TODAYOUTQTY           float64  `json:"todayoutqty"  xorm:"TODAYOUTQTY"`                     // 今日出库量(今出库量)
-	DELIVERYGOODSCODE     string   `json:"deliverygoodscode"  xorm:"'DELIVERYGOODSCODE'"`       // 现货品代码
-	DELIVERYGOODSNAME     string   `json:"deliverygoodsname"  xorm:"'DELIVERYGOODSNAME'"`       // 现货品名称
-	GOODSUNITID           int32    `json:"goodsunitid"  xorm:"'GOODSUNITID'"`                   // 现货品单位id
-	WRSTANDARDCODE        string   `json:"wrstandardcode"  xorm:"'WRSTANDARDCODE'"`             // 品类代码
-	WRSTANDARDNAME        string   `json:"wrstandardname"  xorm:"'WRSTANDARDNAME'"`             // 品类名称
+	DELIVERYGOODSCODE     string   `json:"deliverygoodscode"  xorm:"'DELIVERYGOODSCODE'"`       // 现货品代码
+	DELIVERYGOODSNAME     string   `json:"deliverygoodsname"  xorm:"'DELIVERYGOODSNAME'"`       // 现货品名称
+	GOODSUNITID           int32    `json:"goodsunitid"  xorm:"'GOODSUNITID'"`                   // 现货品单位id(作废)
+	WRSTANDARDCODE        string   `json:"wrstandardcode"  xorm:"'WRSTANDARDCODE'"`             // 现货商品(品类)代码
+	WRSTANDARDNAME        string   `json:"wrstandardname"  xorm:"'WRSTANDARDNAME'"`             // 现货商品(品类)名称
 	UNITID                int32    `json:"unitid"  xorm:"'UNITID'"`                             // 品类单位id
 	BRANDNAME             string   `json:"brandname"  xorm:"'BRANDNAME'"`                       // 品牌名称
 
-	EnumdicName  string `json:"enumdicname"`  // 现货品单位名称
+	EnumdicName  string `json:"enumdicname"`  // 现货品单位名称(作废)
 	UNITIDNAME   string `json:"unitidname"`   // 品类单位名称
 	ACCOUNTNAME  string `json:"accountname"`  // 机构名称
 	CURRENCYNAME string `json:"currencyname"` // 币种名称
 
-	QueryType int32  `json:"-"`         // 查询类型 1-报表 2-报表明细
-	BeginDate string `json:"begindate"` // 开始交易日
-	EndDate   string `json:"enddate"`   // 结束交易日
+	QueryType int32  `json:"-"`                // 查询类型 1-报表 2-报表明细
+	BeginDate string `json:"begindate"`        // 开始交易日
+	EndDate   string `json:"enddate"`          // 结束交易日
+	SumFlag   int32  `json:"-" form:"sumflag"` // 日报表统计维度 1:品种+品类
 }
 
 func (r *Ermcp3AreaSpotPLReport) calc() {
@@ -958,7 +959,11 @@ func (r *Ermcp3AreaSpotPLReport) calc() {
 func (r *Ermcp3AreaSpotPLReport) buildSql() string {
 	// 日报表
 	if r.QueryType == 1 && r.CYCLETYPE == 0 {
-		return r.buildSqlDay()
+		if r.SumFlag == 1 {
+			return r.buildSqlDay2()
+		} else {
+			return r.buildSqlDay()
+		}
 	}
 	// 日报表明细
 	if r.QueryType == 2 && r.CYCLETYPE == 0 {
@@ -1018,6 +1023,66 @@ func (r *Ermcp3AreaSpotPLReport) buildSqlDay() string {
 	return sqlId.String()
 }
 
+// buildSqlDay2 现货日报表查询语句(汇总维度与buildSqlDay不同, 给pcweb版本用)
+func (r *Ermcp3AreaSpotPLReport) buildSqlDay2() string {
+	var sqlId utils.SQLVal = `
+select a.*,
+       g.deliverygoodscode,
+       g.deliverygoodsname,
+       g.goodsunitid,
+       w.wrstandardcode,
+       w.wrstandardname,
+       w.unitid
+  from (SELECT t.RECKONDATE,
+               t.AREAUSERID,
+               t.CURRENCYID,
+               t.DELIVERYGOODSID,
+               t.WRSTANDARDID,
+               sum(t.ORIBUYQTY) ORIBUYQTY,
+               sum(t.ORIBUYAMOUNT) ORIBUYAMOUNT,
+               sum(t.ORISELLQTY) ORISELLQTY,
+               sum(t.ORISELLAMOUNT) ORISELLAMOUNT,
+               sum(t.ORIQTY) ORIQTY,
+               sum(t.ORIAMOUNT) ORIAMOUNT,
+               sum(t.TODAYBUYQTY) TODAYBUYQTY,
+               sum(t.TODAYBUYAMOUNT) TODAYBUYAMOUNT,
+               sum(t.TODAYSELLQTY) TODAYSELLQTY,
+               sum(t.TODAYSELLAMOUNT) TODAYSELLAMOUNT,
+               sum(t.CURBUYQTY) CURBUYQTY,
+               sum(t.CURBUYAMOUNT) CURBUYAMOUNT,
+               sum(t.CURSELLQTY) CURSELLQTY,
+               sum(t.CURSELLAMOUNT) CURSELLAMOUNT,
+               sum(t.CURQTY) CURQTY,
+               sum(t.CURAMOUNT) CURAMOUNT,
+               max(t.CURSPOTPRICE) CURSPOTPRICE,
+               sum(t.CURMARKETVALUE) CURMARKETVALUE,
+               sum(t.ACTUALPL) ACTUALPL,
+               sum(t.FLOATPL) FLOATPL,
+               sum(t.TODAYINQTY) TODAYINQTY,
+               sum(t.TODAYOUTQTY) TODAYOUTQTY
+          FROM RECKON_ERMCP_AREASPOTPL t
+         WHERE 1 = 1 %v
+         GROUP BY t.RECKONDATE,
+                  t.AREAUSERID,
+                  t.CURRENCYID,
+                  t.DELIVERYGOODSID,
+                  t.WRSTANDARDID) a
+  LEFT JOIN DELIVERYGOODS g
+    on a.deliverygoodsid = g.deliverygoodsid
+  LEFT JOIN WRSTANDARD w
+    on a.wrstandardid = w.wrstandardid
+`
+	var sqlParam utils.SQLVal
+	sqlParam.And("t.AREAUSERID", r.AREAUSERID)
+	if r.QueryType == 1 {
+		sqlParam.And("t.RECKONDATE", r.RECKONDATE)
+	} else if r.QueryType == 2 {
+		sqlParam.Join(fmt.Sprintf(" and t.RECKONDATE >= '%v' and t.RECKONDATE <= '%v' ", r.BeginDate, r.EndDate))
+	}
+	sqlId.FormatParam(sqlParam.String())
+	return sqlId.String()
+}
+
 func (r *Ermcp3AreaSpotPLReport) buildSqlDayDetail() string {
 	var sqlId utils.SQLVal = "select a.*," +
 		"       g.deliverygoodscode," +