فهرست منبع

1.查询现货报表增加品类、品牌、期货账户过滤条件
2.查询套保计划增加品类、期货账户字段

zou.yingbin 4 سال پیش
والد
کامیت
a61a131af9
7فایلهای تغییر یافته به همراه1532 افزوده شده و 409 حذف شده
  1. 45 37
      controllers/ermcp3/qryErmcp3Report.go
  2. 433 67
      docs/docs.go
  3. 433 67
      docs/swagger.json
  4. 326 59
      docs/swagger.yaml
  5. 13 1
      models/ermcp3.go
  6. 277 177
      models/ermcp3Report.go
  7. 5 1
      utils/sqlUtils.go

+ 45 - 37
controllers/ermcp3/qryErmcp3Report.go

@@ -44,6 +44,8 @@ func (v QueryDate) IsNumberic(queryType int32) bool {
 // @Param userid query int true "用户ID"
 // @Param deliverygoodsid query int true "现货商品id"
 // @Param tradedate query string true "交易日(格式:yyyyMMdd)"
+// @Param wrstandardid query int false "品类ID"
+// @Param spotgoodsbrandid query int false "现货品牌ID"
 // @Success 200 {array} models.Ermcp3ReportOPLog
 // @Failure 500 {object} app.Response
 // @Router /Ermcp3/QryReportDaySpotDetail [get]
@@ -51,13 +53,16 @@ func (v QueryDate) IsNumberic(queryType int32) bool {
 func QryReportDaySpotDetail(c *gin.Context) {
 	a := app.GinUtils{Gin: app.Gin{C: c}}
 	req := struct {
-		USERID          int64  `form:"userid" binding:"required"`          // 用户id
-		DELIVERYGOODSID int32  `form:"deliverygoodsid" binding:"required"` // 现货商品id
-		TRADEDATE       string `form:"tradedate" binding:"required"`       // 交易日
+		USERID           int64  `form:"userid" binding:"required"`          // 用户id
+		TRADEDATE        string `form:"tradedate" binding:"required"`       // 交易日
+		DELIVERYGOODSID  int32  `form:"deliverygoodsid" binding:"required"` // 现货商品id
+		SPOTGOODSBRANDID int32  `form:"spotgoodsbrandid"`                   // 品牌id
+		WRSTANDARDID     int32  `form:"wrstandardid"`                       // 品类id
 	}{}
 	a.DoBindReq(&req)
 	m := models.Ermcp3ReportOPLog{USERID: req.USERID, DELIVERYGOODSID: req.DELIVERYGOODSID,
-		TRADEDATE: req.TRADEDATE, LogTypeFilter: "2,3"}
+		TRADEDATE: req.TRADEDATE, SPOTGOODSBRANDID: req.SPOTGOODSBRANDID, WRSTANDARDID: req.WRSTANDARDID,
+		LogTypeFilter: "2,3,24,25,26,27"}
 	a.DoGetDataI(&m)
 }
 
@@ -104,20 +109,20 @@ func QryReportDayFinanceFp(c *gin.Context) {
 // @Summary 查询现货日报表(菜单:报表查询/现货报表/现货日报表)
 // @Produce json
 // @Security ApiKeyAuth
-// @Param userid query int true "用户ID"
-// @Param tradedate query string true "交易日(格式:yyyyMMdd)"
-// @Success 200 {array} models.Ermcp3ReportDaySpot
+// @Param areauserid query int true "所属机构id"
+// @Param reckondate query string true "交易日(格式:yyyyMMdd)"
+// @Param accountid query int false "期货账户ID"
+// @Param deliverygoodsid query int false "现货品种ID"
+// @Param wrstandardid query int false "品类ID"
+// @Param spotgoodsbrandid query int false "现货品牌ID"
+// @Success 200 {array} models.Ermcp3ReckonAreaSpotSub
 // @Failure 500 {object} app.Response
 // @Router /Ermcp3/QryReportDaySpot [get]
 // @Tags 企业风险管理v3(app)
 func QryReportDaySpot(c *gin.Context) {
 	a := app.GinUtils{Gin: app.Gin{C: c}}
-	req := struct {
-		USERID    int64  `form:"userid" binding:"required"`    // 用户id
-		TRADEDATE string `form:"tradedate" binding:"required"` // 交易日
-	}{}
-	a.DoBindReq(&req)
-	m := models.Ermcp3ReportDaySpot{AREAUSERID: req.USERID, RECKONDATE: req.TRADEDATE}
+	m := models.Ermcp3ReckonAreaSpotSub{}
+	a.DoBindReq(&m)
 	a.DoGetDataI(&m)
 }
 
@@ -125,50 +130,53 @@ func QryReportDaySpot(c *gin.Context) {
 // @Summary 查询现货月报表(菜单:报表查询/现货报表/现货月报表)
 // @Produce json
 // @Security ApiKeyAuth
-// @Param userid query int true "用户ID"
-// @Param cycletime query string true "周期时间:月(格式:yyyyMM)"
-// @Success 200 {array} models.Ermcp3ReportMonSpot
+// @Param areauserid query int true "所属机构id"
+// @Param cycletype query int true "周期类型 - 1:月 2:季 3:年 4:周 5:全报表【原值】"
+// @Param cycletime query string true "周期时间 月(YYYYMM)  季(YYYYQ) 年(YYYY) 周(YYYYIW) 全(0)【原值】"
+// @Param accountid query int false "期货账户ID"
+// @Param deliverygoodsid query int false "现货品种ID"
+// @Param wrstandardid query int false "品类ID"
+// @Param spotgoodsbrandid query int false "现货品牌ID"
+// @Success 200 {array} models.Ermcp3ReportAreaSpotSub
 // @Failure 500 {object} app.Response
 // @Router /Ermcp3/QryReportMonthSpot [get]
 // @Tags 企业风险管理v3(app)
 func QryReportMonthSpot(c *gin.Context) {
 	a := app.GinUtils{Gin: app.Gin{C: c}}
-	req := struct {
-		UserId    int64  `form:"userid" binding:"required"`    //用户ID
-		CycleTime string `form:"cycletime" binding:"required"` // 周期时间:月(格式:yyyyMM)
-	}{}
-	a.DoBindReq(&req)
-	m := models.Ermcp3ReportMonSpot{AREAUSERID: req.UserId, CYCLETIME: req.CycleTime}
+	m := models.Ermcp3ReportAreaSpotSub{}
+	a.DoBindReq(&m)
 	a.DoGetDataI(&m)
 }
 
 // @Summary 查询现货月报表详情(菜单:报表查询/现货月报表/现货月报表详情)
 // @Produce json
 // @Security ApiKeyAuth
-// @Param userid query int true "用户ID"
-// @Param deliverygoodsid query int true "现货商品id"
-// @Param cycletime query string true "周期时间:月(格式:yyyyMM)"
-// @Success 200 {array} models.Ermcp3ReportDaySpot
+// @Param areauserid query int true "所属机构id"
+// @Param cycletype query int true "周期类型 - 1:月 2:季 3:年 4:周 5:全报表【原值】"
+// @Param cycletime query string true "周期时间 月(YYYYMM)  季(YYYYQ) 年(YYYY) 周(YYYYIW) 全(0)【原值】"
+// @Param accountid query int false "期货账户ID"
+// @Param deliverygoodsid query int false "现货品种ID"
+// @Param wrstandardid query int false "品类ID"
+// @Param spotgoodsbrandid query int false "现货品牌ID"
+// @Success 200 {array} models.Ermcp3ReportAreaSpotSub
 // @Failure 500 {object} app.Response
 // @Router /Ermcp3/QryReportMonthSpotDetail [get]
 // @Tags 企业风险管理v3(app)
 func QryReportMonthSpotDetail(c *gin.Context) {
 	a := app.GinUtils{Gin: app.Gin{C: c}}
-	req := struct {
-		UserId          int64  `form:"userid" binding:"required"`          // 用户ID
-		DELIVERYGOODSID int32  `form:"deliverygoodsid" binding:"required"` // 现货商品id
-		CycleTime       string `form:"cycletime" binding:"required"`       // 周期时间:月(格式:yyyyMM)
-	}{}
+	req := models.Ermcp3ReportAreaSpotSub{}
 	a.DoBindReq(&req)
-	if len(req.CycleTime) != 6 {
-		// 月报表的日期应是6位,如 202101
+	if req.CYCLETYPE != 1 || len(req.CYCLETIME) != 6 {
+		// 目前仅支持月报表明细, 月报表的日期应是6位,如 202101
 		a.Response(http.StatusBadRequest, e.INVALID_PARAMS, nil)
 		return
 	}
-	t1 := req.CycleTime + "01"
-	t2 := req.CycleTime + "31"
-	m := models.Ermcp3ReportDaySpot{AREAUSERID: req.UserId, DELIVERYGOODSID: req.DELIVERYGOODSID,
-		BeginDate: t1, EndDate: t2}
+	t1 := req.CYCLETIME + "01"
+	t2 := req.CYCLETIME + "31"
+	// 月报表明细 = 01~31 日报表
+	m := models.Ermcp3ReckonAreaSpotSub{
+		AREAUSERID: req.AREAUSERID, DELIVERYGOODSID: req.DELIVERYGOODSID, ACCOUNTID: req.ACCOUNTID,
+		WRSTANDARDID: req.WRSTANDARDID, SPOTGOODSBRANDID: req.SPOTGOODSBRANDID, BeginDate: t1, EndDate: t2}
 	a.DoGetDataI(&m)
 }
 

+ 433 - 67
docs/docs.go

@@ -4250,17 +4250,41 @@ var doc = `{
                 "parameters": [
                     {
                         "type": "integer",
-                        "description": "用户ID",
-                        "name": "userid",
+                        "description": "所属机构id",
+                        "name": "areauserid",
                         "in": "query",
                         "required": true
                     },
                     {
                         "type": "string",
                         "description": "交易日(格式:yyyyMMdd)",
-                        "name": "tradedate",
+                        "name": "reckondate",
                         "in": "query",
                         "required": true
+                    },
+                    {
+                        "type": "integer",
+                        "description": "期货账户ID",
+                        "name": "accountid",
+                        "in": "query"
+                    },
+                    {
+                        "type": "integer",
+                        "description": "现货品种ID",
+                        "name": "deliverygoodsid",
+                        "in": "query"
+                    },
+                    {
+                        "type": "integer",
+                        "description": "品类ID",
+                        "name": "wrstandardid",
+                        "in": "query"
+                    },
+                    {
+                        "type": "integer",
+                        "description": "现货品牌ID",
+                        "name": "spotgoodsbrandid",
+                        "in": "query"
                     }
                 ],
                 "responses": {
@@ -4269,7 +4293,7 @@ var doc = `{
                         "schema": {
                             "type": "array",
                             "items": {
-                                "$ref": "#/definitions/models.Ermcp3ReportDaySpot"
+                                "$ref": "#/definitions/models.Ermcp3ReckonAreaSpotSub"
                             }
                         }
                     },
@@ -4317,6 +4341,18 @@ var doc = `{
                         "name": "tradedate",
                         "in": "query",
                         "required": true
+                    },
+                    {
+                        "type": "integer",
+                        "description": "品类ID",
+                        "name": "wrstandardid",
+                        "in": "query"
+                    },
+                    {
+                        "type": "integer",
+                        "description": "现货品牌ID",
+                        "name": "spotgoodsbrandid",
+                        "in": "query"
                     }
                 ],
                 "responses": {
@@ -4355,17 +4391,48 @@ var doc = `{
                 "parameters": [
                     {
                         "type": "integer",
-                        "description": "用户ID",
-                        "name": "userid",
+                        "description": "所属机构id",
+                        "name": "areauserid",
+                        "in": "query",
+                        "required": true
+                    },
+                    {
+                        "type": "integer",
+                        "description": "周期类型 - 1:月 2:季 3:年 4:周 5:全报表【原值】",
+                        "name": "cycletype",
                         "in": "query",
                         "required": true
                     },
                     {
                         "type": "string",
-                        "description": "周期时间:月(格式:yyyyMM)",
+                        "description": "周期时间 月(YYYYMM)  季(YYYYQ) 年(YYYY) 周(YYYYIW) 全(0)【原值】",
                         "name": "cycletime",
                         "in": "query",
                         "required": true
+                    },
+                    {
+                        "type": "integer",
+                        "description": "期货账户ID",
+                        "name": "accountid",
+                        "in": "query"
+                    },
+                    {
+                        "type": "integer",
+                        "description": "现货品种ID",
+                        "name": "deliverygoodsid",
+                        "in": "query"
+                    },
+                    {
+                        "type": "integer",
+                        "description": "品类ID",
+                        "name": "wrstandardid",
+                        "in": "query"
+                    },
+                    {
+                        "type": "integer",
+                        "description": "现货品牌ID",
+                        "name": "spotgoodsbrandid",
+                        "in": "query"
                     }
                 ],
                 "responses": {
@@ -4374,7 +4441,7 @@ var doc = `{
                         "schema": {
                             "type": "array",
                             "items": {
-                                "$ref": "#/definitions/models.Ermcp3ReportMonSpot"
+                                "$ref": "#/definitions/models.Ermcp3ReportAreaSpotSub"
                             }
                         }
                     },
@@ -4404,24 +4471,48 @@ var doc = `{
                 "parameters": [
                     {
                         "type": "integer",
-                        "description": "用户ID",
-                        "name": "userid",
+                        "description": "所属机构id",
+                        "name": "areauserid",
                         "in": "query",
                         "required": true
                     },
                     {
                         "type": "integer",
-                        "description": "现货商品id",
-                        "name": "deliverygoodsid",
+                        "description": "周期类型 - 1:月 2:季 3:年 4:周 5:全报表【原值】",
+                        "name": "cycletype",
                         "in": "query",
                         "required": true
                     },
                     {
                         "type": "string",
-                        "description": "周期时间:月(格式:yyyyMM)",
+                        "description": "周期时间 月(YYYYMM)  季(YYYYQ) 年(YYYY) 周(YYYYIW) 全(0)【原值】",
                         "name": "cycletime",
                         "in": "query",
                         "required": true
+                    },
+                    {
+                        "type": "integer",
+                        "description": "期货账户ID",
+                        "name": "accountid",
+                        "in": "query"
+                    },
+                    {
+                        "type": "integer",
+                        "description": "现货品种ID",
+                        "name": "deliverygoodsid",
+                        "in": "query"
+                    },
+                    {
+                        "type": "integer",
+                        "description": "品类ID",
+                        "name": "wrstandardid",
+                        "in": "query"
+                    },
+                    {
+                        "type": "integer",
+                        "description": "现货品牌ID",
+                        "name": "spotgoodsbrandid",
+                        "in": "query"
                     }
                 ],
                 "responses": {
@@ -4430,7 +4521,7 @@ var doc = `{
                         "schema": {
                             "type": "array",
                             "items": {
-                                "$ref": "#/definitions/models.Ermcp3ReportDaySpot"
+                                "$ref": "#/definitions/models.Ermcp3ReportAreaSpotSub"
                             }
                         }
                     },
@@ -14342,6 +14433,10 @@ var doc = `{
         "models.Ermcp3HedgePlan": {
             "type": "object",
             "properties": {
+                "accountid": {
+                    "description": "资金账号",
+                    "type": "integer"
+                },
                 "areauserid": {
                     "description": "用户ID",
                     "type": "integer"
@@ -14410,6 +14505,10 @@ var doc = `{
                     "description": "商品型号",
                     "type": "string"
                 },
+                "taaccountname": {
+                    "description": "资金账号名称",
+                    "type": "string"
+                },
                 "unitid": {
                     "description": "单位id",
                     "type": "integer"
@@ -14417,6 +14516,18 @@ var doc = `{
                 "updatetime": {
                     "description": "更新时间",
                     "type": "string"
+                },
+                "wrstandardcode": {
+                    "description": "品类代码",
+                    "type": "string"
+                },
+                "wrstandardid": {
+                    "description": "品类id",
+                    "type": "integer"
+                },
+                "wrstandardname": {
+                    "description": "品类名称",
+                    "type": "string"
                 }
             }
         },
@@ -14465,6 +14576,179 @@ var doc = `{
                 }
             }
         },
+        "models.Ermcp3ReckonAreaSpotSub": {
+            "type": "object",
+            "required": [
+                "areauserid",
+                "reckondate"
+            ],
+            "properties": {
+                "accountid": {
+                    "description": "期货账户ID",
+                    "type": "integer"
+                },
+                "accountname": {
+                    "description": "所属机构名称",
+                    "type": "string"
+                },
+                "areauserid": {
+                    "description": "账户所属机构",
+                    "type": "integer"
+                },
+                "brandname": {
+                    "description": "品牌名称",
+                    "type": "string"
+                },
+                "buycontractinqty": {
+                    "description": "采购合同入库量",
+                    "type": "number"
+                },
+                "buypricedamount": {
+                    "description": "采购合同已定价金额",
+                    "type": "number"
+                },
+                "buypricedqty": {
+                    "description": "采购合同已定价数量",
+                    "type": "number"
+                },
+                "buyreckonqty": {
+                    "description": "采购合同交收量",
+                    "type": "number"
+                },
+                "deliverygoodscode": {
+                    "description": "现货商品代码",
+                    "type": "string"
+                },
+                "deliverygoodsid": {
+                    "description": "现货品种ID",
+                    "type": "integer"
+                },
+                "deliverygoodsname": {
+                    "description": "现货商品名称",
+                    "type": "string"
+                },
+                "enumdicname": {
+                    "description": "现货商品单位名称",
+                    "type": "string"
+                },
+                "goodsunitid": {
+                    "description": "现货商品单位id",
+                    "type": "integer"
+                },
+                "oribuycontractinqty": {
+                    "description": "期初采购合同入库量",
+                    "type": "number"
+                },
+                "oribuypricedamount": {
+                    "description": "期初采购合同已定价金额",
+                    "type": "number"
+                },
+                "oribuypricedqty": {
+                    "description": "期初采购合同已定价数量",
+                    "type": "number"
+                },
+                "oribuyreckonqty": {
+                    "description": "期初采购合同交收量",
+                    "type": "number"
+                },
+                "oriproduceinqty": {
+                    "description": "期初生产入库量",
+                    "type": "number"
+                },
+                "oriproduceoutqty": {
+                    "description": "期初生产出库量",
+                    "type": "number"
+                },
+                "orisellcontractoutqty": {
+                    "description": "期初销售合同出库量",
+                    "type": "number"
+                },
+                "orisellpricedamount": {
+                    "description": "期初销售合同已定价金额",
+                    "type": "number"
+                },
+                "orisellpricedqty": {
+                    "description": "期初销售合同已定价数量",
+                    "type": "number"
+                },
+                "orisellreckonqty": {
+                    "description": "期初销售合同交收量",
+                    "type": "number"
+                },
+                "produceinqty": {
+                    "description": "生产入库量",
+                    "type": "number"
+                },
+                "produceoutqty": {
+                    "description": "生产出库量",
+                    "type": "number"
+                },
+                "reckondate": {
+                    "description": "日照时期(yyyyMMdd)",
+                    "type": "string"
+                },
+                "sellcontractoutqty": {
+                    "description": "销售合同出库量",
+                    "type": "number"
+                },
+                "sellpricedamount": {
+                    "description": "销售合同已定价金额",
+                    "type": "number"
+                },
+                "sellpricedqty": {
+                    "description": "销售合同已定价数量",
+                    "type": "number"
+                },
+                "sellreckonqty": {
+                    "description": "销售合同交收量",
+                    "type": "number"
+                },
+                "spotgoodsbrandid": {
+                    "description": "现货品牌ID",
+                    "type": "integer"
+                },
+                "todaybuyreckonqty": {
+                    "description": "今日采购合同已确定数量",
+                    "type": "number"
+                },
+                "todaysellreckonqty": {
+                    "description": "今日销售合同已确定数量",
+                    "type": "number"
+                },
+                "totalbuypricedqty": {
+                    "description": "采购定价量 = 期末 - 期初",
+                    "type": "number"
+                },
+                "totalsellpricedqty": {
+                    "description": "销售定价量 = 期末 - 期初",
+                    "type": "number"
+                },
+                "totalspotqty": {
+                    "description": "现货头寸总量 =  采购合同已定价数量 - 销售合同已定价数量",
+                    "type": "number"
+                },
+                "updatetime": {
+                    "description": "更新时间",
+                    "type": "string"
+                },
+                "wrfactortypeid": {
+                    "description": "仓单要素类型ID(212+Unix秒时间戳(10位)+xxxxxx)",
+                    "type": "integer"
+                },
+                "wrstandardcode": {
+                    "description": "品类代码",
+                    "type": "string"
+                },
+                "wrstandardid": {
+                    "description": "现货品类ID",
+                    "type": "integer"
+                },
+                "wrstandardname": {
+                    "description": "品类名称",
+                    "type": "string"
+                }
+            }
+        },
         "models.Ermcp3ReportAreaSpotPL": {
             "type": "object",
             "properties": {
@@ -14626,68 +14910,42 @@ var doc = `{
                 }
             }
         },
-        "models.Ermcp3ReportDaySpot": {
+        "models.Ermcp3ReportAreaSpotSub": {
             "type": "object",
+            "required": [
+                "areauserid"
+            ],
             "properties": {
-                "areauserid": {
-                    "description": "所属机构T",
+                "accountid": {
+                    "description": "期货账户ID",
                     "type": "integer"
                 },
-                "buyinqty": {
-                    "description": "采购入库量",
-                    "type": "number"
-                },
-                "deliverygoodscode": {
-                    "description": "现货品种代码",
+                "accountname": {
+                    "description": "所属机构名称",
                     "type": "string"
                 },
-                "deliverygoodsid": {
-                    "description": "现货品种id",
+                "areauserid": {
+                    "description": "账户所属机构",
                     "type": "integer"
                 },
-                "deliverygoodsname": {
-                    "description": "现货品种名称",
-                    "type": "string"
-                },
-                "enumdicname": {
-                    "description": "现货商品单位名称",
-                    "type": "string"
-                },
-                "reckondate": {
-                    "description": "日照时期(yyyyMMdd)",
+                "brandname": {
+                    "description": "品牌名称",
                     "type": "string"
                 },
-                "selloutqty": {
-                    "description": "销售出库量",
+                "buycontractinqty": {
+                    "description": "采购合同入库量【期末】",
                     "type": "number"
                 },
-                "todaybuyreckonqty": {
-                    "description": "采购确定量",
+                "buypricedamount": {
+                    "description": "采购合同已定价金额【期末】",
                     "type": "number"
                 },
-                "todaysellreckonqty": {
-                    "description": "销售确定量",
+                "buypricedqty": {
+                    "description": "采购合同已定价数量【期末】",
                     "type": "number"
                 },
-                "totalbuypricedqty": {
-                    "description": "采购定价量 = 期末 - 期初",
-                    "type": "number"
-                },
-                "totalsellpricedqty": {
-                    "description": "销售定价量 = 期末 - 期初",
-                    "type": "number"
-                }
-            }
-        },
-        "models.Ermcp3ReportMonSpot": {
-            "type": "object",
-            "properties": {
-                "areauserid": {
-                    "description": "所属机构id",
-                    "type": "integer"
-                },
-                "buyinqty": {
-                    "description": "采购入库量",
+                "buyreckonqty": {
+                    "description": "采购合同交收量【期末】",
                     "type": "number"
                 },
                 "cycletime": {
@@ -14699,31 +14957,99 @@ var doc = `{
                     "type": "integer"
                 },
                 "deliverygoodscode": {
-                    "description": "现货品代码",
+                    "description": "现货品代码",
                     "type": "string"
                 },
                 "deliverygoodsid": {
-                    "description": "现货品种id",
+                    "description": "现货品种ID",
                     "type": "integer"
                 },
                 "deliverygoodsname": {
-                    "description": "现货品名称",
+                    "description": "现货品名称",
                     "type": "string"
                 },
                 "enumdicname": {
                     "description": "现货商品单位名称",
                     "type": "string"
                 },
-                "selloutqty": {
-                    "description": "销售出库量",
+                "goodsunitid": {
+                    "description": "现货商品单位id",
+                    "type": "integer"
+                },
+                "oribuycontractinqty": {
+                    "description": "期初采购合同入库量【期初】",
+                    "type": "number"
+                },
+                "oribuypricedamount": {
+                    "description": "期初采购合同已定价金额【期初】",
+                    "type": "number"
+                },
+                "oribuypricedqty": {
+                    "description": "期初采购合同已定价数量【期初】",
                     "type": "number"
                 },
+                "oribuyreckonqty": {
+                    "description": "期初采购合同交收量【期初】",
+                    "type": "number"
+                },
+                "oriproduceinqty": {
+                    "description": "期初生产入库量【期初】",
+                    "type": "number"
+                },
+                "oriproduceoutqty": {
+                    "description": "期初生产出库量【期初】",
+                    "type": "number"
+                },
+                "orisellcontractoutqty": {
+                    "description": "期初销售合同出库量【期初】",
+                    "type": "number"
+                },
+                "orisellpricedamount": {
+                    "description": "期初销售合同已定价金额【期初】",
+                    "type": "number"
+                },
+                "orisellpricedqty": {
+                    "description": "期初销售合同已定价数量【期初】",
+                    "type": "number"
+                },
+                "orisellreckonqty": {
+                    "description": "期初销售合同交收量【期初】",
+                    "type": "number"
+                },
+                "produceinqty": {
+                    "description": "生产入库量【期末】",
+                    "type": "number"
+                },
+                "produceoutqty": {
+                    "description": "生产出库量【期末】",
+                    "type": "number"
+                },
+                "sellcontractoutqty": {
+                    "description": "销售合同出库量【期末】",
+                    "type": "number"
+                },
+                "sellpricedamount": {
+                    "description": "销售合同已定价金额【期末】",
+                    "type": "number"
+                },
+                "sellpricedqty": {
+                    "description": "销售合同已定价数量【期末】",
+                    "type": "number"
+                },
+                "sellreckonqty": {
+                    "description": "销售合同交收量【期末】",
+                    "type": "number"
+                },
+                "spotgoodsbrandid": {
+                    "description": "现货品牌ID",
+                    "type": "integer"
+                },
                 "todaybuyreckonqty": {
-                    "description": "采购确定量",
+                    "description": "今日采购合同已确定【汇总】",
                     "type": "number"
                 },
                 "todaysellreckonqty": {
-                    "description": "销售确定量",
+                    "description": "今日销售合同已确定【汇总】",
                     "type": "number"
                 },
                 "totalbuypricedqty": {
@@ -14733,6 +15059,30 @@ var doc = `{
                 "totalsellpricedqty": {
                     "description": "销售定价量 = 期末 - 期初",
                     "type": "number"
+                },
+                "totalspotqty": {
+                    "description": "现货头寸总量 =  采购合同已定价数量 - 销售合同已定价数量【期末】",
+                    "type": "number"
+                },
+                "updatetime": {
+                    "description": "更新时间",
+                    "type": "string"
+                },
+                "wrfactortypeid": {
+                    "description": "仓单要素类型ID(212+Unix秒时间戳(10位)+xxxxxx)",
+                    "type": "integer"
+                },
+                "wrstandardcode": {
+                    "description": "品类代码",
+                    "type": "string"
+                },
+                "wrstandardid": {
+                    "description": "品类ID",
+                    "type": "integer"
+                },
+                "wrstandardname": {
+                    "description": "品类名称",
+                    "type": "string"
                 }
             }
         },
@@ -14807,6 +15157,10 @@ var doc = `{
                     "description": "合同编号",
                     "type": "string"
                 },
+                "spotgoodsbrandid": {
+                    "description": "品牌id",
+                    "type": "integer"
+                },
                 "tradedate": {
                     "description": "交易日(yyyyMMdd)",
                     "type": "string"
@@ -14814,6 +15168,18 @@ var doc = `{
                 "userid": {
                     "description": "机构ID",
                     "type": "integer"
+                },
+                "wrstandardcode": {
+                    "description": "品类代码",
+                    "type": "string"
+                },
+                "wrstandardid": {
+                    "description": "品类id",
+                    "type": "integer"
+                },
+                "wrstandardname": {
+                    "description": "品类名称",
+                    "type": "string"
                 }
             }
         },

+ 433 - 67
docs/swagger.json

@@ -4234,17 +4234,41 @@
                 "parameters": [
                     {
                         "type": "integer",
-                        "description": "用户ID",
-                        "name": "userid",
+                        "description": "所属机构id",
+                        "name": "areauserid",
                         "in": "query",
                         "required": true
                     },
                     {
                         "type": "string",
                         "description": "交易日(格式:yyyyMMdd)",
-                        "name": "tradedate",
+                        "name": "reckondate",
                         "in": "query",
                         "required": true
+                    },
+                    {
+                        "type": "integer",
+                        "description": "期货账户ID",
+                        "name": "accountid",
+                        "in": "query"
+                    },
+                    {
+                        "type": "integer",
+                        "description": "现货品种ID",
+                        "name": "deliverygoodsid",
+                        "in": "query"
+                    },
+                    {
+                        "type": "integer",
+                        "description": "品类ID",
+                        "name": "wrstandardid",
+                        "in": "query"
+                    },
+                    {
+                        "type": "integer",
+                        "description": "现货品牌ID",
+                        "name": "spotgoodsbrandid",
+                        "in": "query"
                     }
                 ],
                 "responses": {
@@ -4253,7 +4277,7 @@
                         "schema": {
                             "type": "array",
                             "items": {
-                                "$ref": "#/definitions/models.Ermcp3ReportDaySpot"
+                                "$ref": "#/definitions/models.Ermcp3ReckonAreaSpotSub"
                             }
                         }
                     },
@@ -4301,6 +4325,18 @@
                         "name": "tradedate",
                         "in": "query",
                         "required": true
+                    },
+                    {
+                        "type": "integer",
+                        "description": "品类ID",
+                        "name": "wrstandardid",
+                        "in": "query"
+                    },
+                    {
+                        "type": "integer",
+                        "description": "现货品牌ID",
+                        "name": "spotgoodsbrandid",
+                        "in": "query"
                     }
                 ],
                 "responses": {
@@ -4339,17 +4375,48 @@
                 "parameters": [
                     {
                         "type": "integer",
-                        "description": "用户ID",
-                        "name": "userid",
+                        "description": "所属机构id",
+                        "name": "areauserid",
+                        "in": "query",
+                        "required": true
+                    },
+                    {
+                        "type": "integer",
+                        "description": "周期类型 - 1:月 2:季 3:年 4:周 5:全报表【原值】",
+                        "name": "cycletype",
                         "in": "query",
                         "required": true
                     },
                     {
                         "type": "string",
-                        "description": "周期时间:月(格式:yyyyMM)",
+                        "description": "周期时间 月(YYYYMM)  季(YYYYQ) 年(YYYY) 周(YYYYIW) 全(0)【原值】",
                         "name": "cycletime",
                         "in": "query",
                         "required": true
+                    },
+                    {
+                        "type": "integer",
+                        "description": "期货账户ID",
+                        "name": "accountid",
+                        "in": "query"
+                    },
+                    {
+                        "type": "integer",
+                        "description": "现货品种ID",
+                        "name": "deliverygoodsid",
+                        "in": "query"
+                    },
+                    {
+                        "type": "integer",
+                        "description": "品类ID",
+                        "name": "wrstandardid",
+                        "in": "query"
+                    },
+                    {
+                        "type": "integer",
+                        "description": "现货品牌ID",
+                        "name": "spotgoodsbrandid",
+                        "in": "query"
                     }
                 ],
                 "responses": {
@@ -4358,7 +4425,7 @@
                         "schema": {
                             "type": "array",
                             "items": {
-                                "$ref": "#/definitions/models.Ermcp3ReportMonSpot"
+                                "$ref": "#/definitions/models.Ermcp3ReportAreaSpotSub"
                             }
                         }
                     },
@@ -4388,24 +4455,48 @@
                 "parameters": [
                     {
                         "type": "integer",
-                        "description": "用户ID",
-                        "name": "userid",
+                        "description": "所属机构id",
+                        "name": "areauserid",
                         "in": "query",
                         "required": true
                     },
                     {
                         "type": "integer",
-                        "description": "现货商品id",
-                        "name": "deliverygoodsid",
+                        "description": "周期类型 - 1:月 2:季 3:年 4:周 5:全报表【原值】",
+                        "name": "cycletype",
                         "in": "query",
                         "required": true
                     },
                     {
                         "type": "string",
-                        "description": "周期时间:月(格式:yyyyMM)",
+                        "description": "周期时间 月(YYYYMM)  季(YYYYQ) 年(YYYY) 周(YYYYIW) 全(0)【原值】",
                         "name": "cycletime",
                         "in": "query",
                         "required": true
+                    },
+                    {
+                        "type": "integer",
+                        "description": "期货账户ID",
+                        "name": "accountid",
+                        "in": "query"
+                    },
+                    {
+                        "type": "integer",
+                        "description": "现货品种ID",
+                        "name": "deliverygoodsid",
+                        "in": "query"
+                    },
+                    {
+                        "type": "integer",
+                        "description": "品类ID",
+                        "name": "wrstandardid",
+                        "in": "query"
+                    },
+                    {
+                        "type": "integer",
+                        "description": "现货品牌ID",
+                        "name": "spotgoodsbrandid",
+                        "in": "query"
                     }
                 ],
                 "responses": {
@@ -4414,7 +4505,7 @@
                         "schema": {
                             "type": "array",
                             "items": {
-                                "$ref": "#/definitions/models.Ermcp3ReportDaySpot"
+                                "$ref": "#/definitions/models.Ermcp3ReportAreaSpotSub"
                             }
                         }
                     },
@@ -14326,6 +14417,10 @@
         "models.Ermcp3HedgePlan": {
             "type": "object",
             "properties": {
+                "accountid": {
+                    "description": "资金账号",
+                    "type": "integer"
+                },
                 "areauserid": {
                     "description": "用户ID",
                     "type": "integer"
@@ -14394,6 +14489,10 @@
                     "description": "商品型号",
                     "type": "string"
                 },
+                "taaccountname": {
+                    "description": "资金账号名称",
+                    "type": "string"
+                },
                 "unitid": {
                     "description": "单位id",
                     "type": "integer"
@@ -14401,6 +14500,18 @@
                 "updatetime": {
                     "description": "更新时间",
                     "type": "string"
+                },
+                "wrstandardcode": {
+                    "description": "品类代码",
+                    "type": "string"
+                },
+                "wrstandardid": {
+                    "description": "品类id",
+                    "type": "integer"
+                },
+                "wrstandardname": {
+                    "description": "品类名称",
+                    "type": "string"
                 }
             }
         },
@@ -14449,6 +14560,179 @@
                 }
             }
         },
+        "models.Ermcp3ReckonAreaSpotSub": {
+            "type": "object",
+            "required": [
+                "areauserid",
+                "reckondate"
+            ],
+            "properties": {
+                "accountid": {
+                    "description": "期货账户ID",
+                    "type": "integer"
+                },
+                "accountname": {
+                    "description": "所属机构名称",
+                    "type": "string"
+                },
+                "areauserid": {
+                    "description": "账户所属机构",
+                    "type": "integer"
+                },
+                "brandname": {
+                    "description": "品牌名称",
+                    "type": "string"
+                },
+                "buycontractinqty": {
+                    "description": "采购合同入库量",
+                    "type": "number"
+                },
+                "buypricedamount": {
+                    "description": "采购合同已定价金额",
+                    "type": "number"
+                },
+                "buypricedqty": {
+                    "description": "采购合同已定价数量",
+                    "type": "number"
+                },
+                "buyreckonqty": {
+                    "description": "采购合同交收量",
+                    "type": "number"
+                },
+                "deliverygoodscode": {
+                    "description": "现货商品代码",
+                    "type": "string"
+                },
+                "deliverygoodsid": {
+                    "description": "现货品种ID",
+                    "type": "integer"
+                },
+                "deliverygoodsname": {
+                    "description": "现货商品名称",
+                    "type": "string"
+                },
+                "enumdicname": {
+                    "description": "现货商品单位名称",
+                    "type": "string"
+                },
+                "goodsunitid": {
+                    "description": "现货商品单位id",
+                    "type": "integer"
+                },
+                "oribuycontractinqty": {
+                    "description": "期初采购合同入库量",
+                    "type": "number"
+                },
+                "oribuypricedamount": {
+                    "description": "期初采购合同已定价金额",
+                    "type": "number"
+                },
+                "oribuypricedqty": {
+                    "description": "期初采购合同已定价数量",
+                    "type": "number"
+                },
+                "oribuyreckonqty": {
+                    "description": "期初采购合同交收量",
+                    "type": "number"
+                },
+                "oriproduceinqty": {
+                    "description": "期初生产入库量",
+                    "type": "number"
+                },
+                "oriproduceoutqty": {
+                    "description": "期初生产出库量",
+                    "type": "number"
+                },
+                "orisellcontractoutqty": {
+                    "description": "期初销售合同出库量",
+                    "type": "number"
+                },
+                "orisellpricedamount": {
+                    "description": "期初销售合同已定价金额",
+                    "type": "number"
+                },
+                "orisellpricedqty": {
+                    "description": "期初销售合同已定价数量",
+                    "type": "number"
+                },
+                "orisellreckonqty": {
+                    "description": "期初销售合同交收量",
+                    "type": "number"
+                },
+                "produceinqty": {
+                    "description": "生产入库量",
+                    "type": "number"
+                },
+                "produceoutqty": {
+                    "description": "生产出库量",
+                    "type": "number"
+                },
+                "reckondate": {
+                    "description": "日照时期(yyyyMMdd)",
+                    "type": "string"
+                },
+                "sellcontractoutqty": {
+                    "description": "销售合同出库量",
+                    "type": "number"
+                },
+                "sellpricedamount": {
+                    "description": "销售合同已定价金额",
+                    "type": "number"
+                },
+                "sellpricedqty": {
+                    "description": "销售合同已定价数量",
+                    "type": "number"
+                },
+                "sellreckonqty": {
+                    "description": "销售合同交收量",
+                    "type": "number"
+                },
+                "spotgoodsbrandid": {
+                    "description": "现货品牌ID",
+                    "type": "integer"
+                },
+                "todaybuyreckonqty": {
+                    "description": "今日采购合同已确定数量",
+                    "type": "number"
+                },
+                "todaysellreckonqty": {
+                    "description": "今日销售合同已确定数量",
+                    "type": "number"
+                },
+                "totalbuypricedqty": {
+                    "description": "采购定价量 = 期末 - 期初",
+                    "type": "number"
+                },
+                "totalsellpricedqty": {
+                    "description": "销售定价量 = 期末 - 期初",
+                    "type": "number"
+                },
+                "totalspotqty": {
+                    "description": "现货头寸总量 =  采购合同已定价数量 - 销售合同已定价数量",
+                    "type": "number"
+                },
+                "updatetime": {
+                    "description": "更新时间",
+                    "type": "string"
+                },
+                "wrfactortypeid": {
+                    "description": "仓单要素类型ID(212+Unix秒时间戳(10位)+xxxxxx)",
+                    "type": "integer"
+                },
+                "wrstandardcode": {
+                    "description": "品类代码",
+                    "type": "string"
+                },
+                "wrstandardid": {
+                    "description": "现货品类ID",
+                    "type": "integer"
+                },
+                "wrstandardname": {
+                    "description": "品类名称",
+                    "type": "string"
+                }
+            }
+        },
         "models.Ermcp3ReportAreaSpotPL": {
             "type": "object",
             "properties": {
@@ -14610,68 +14894,42 @@
                 }
             }
         },
-        "models.Ermcp3ReportDaySpot": {
+        "models.Ermcp3ReportAreaSpotSub": {
             "type": "object",
+            "required": [
+                "areauserid"
+            ],
             "properties": {
-                "areauserid": {
-                    "description": "所属机构T",
+                "accountid": {
+                    "description": "期货账户ID",
                     "type": "integer"
                 },
-                "buyinqty": {
-                    "description": "采购入库量",
-                    "type": "number"
-                },
-                "deliverygoodscode": {
-                    "description": "现货品种代码",
+                "accountname": {
+                    "description": "所属机构名称",
                     "type": "string"
                 },
-                "deliverygoodsid": {
-                    "description": "现货品种id",
+                "areauserid": {
+                    "description": "账户所属机构",
                     "type": "integer"
                 },
-                "deliverygoodsname": {
-                    "description": "现货品种名称",
-                    "type": "string"
-                },
-                "enumdicname": {
-                    "description": "现货商品单位名称",
-                    "type": "string"
-                },
-                "reckondate": {
-                    "description": "日照时期(yyyyMMdd)",
+                "brandname": {
+                    "description": "品牌名称",
                     "type": "string"
                 },
-                "selloutqty": {
-                    "description": "销售出库量",
+                "buycontractinqty": {
+                    "description": "采购合同入库量【期末】",
                     "type": "number"
                 },
-                "todaybuyreckonqty": {
-                    "description": "采购确定量",
+                "buypricedamount": {
+                    "description": "采购合同已定价金额【期末】",
                     "type": "number"
                 },
-                "todaysellreckonqty": {
-                    "description": "销售确定量",
+                "buypricedqty": {
+                    "description": "采购合同已定价数量【期末】",
                     "type": "number"
                 },
-                "totalbuypricedqty": {
-                    "description": "采购定价量 = 期末 - 期初",
-                    "type": "number"
-                },
-                "totalsellpricedqty": {
-                    "description": "销售定价量 = 期末 - 期初",
-                    "type": "number"
-                }
-            }
-        },
-        "models.Ermcp3ReportMonSpot": {
-            "type": "object",
-            "properties": {
-                "areauserid": {
-                    "description": "所属机构id",
-                    "type": "integer"
-                },
-                "buyinqty": {
-                    "description": "采购入库量",
+                "buyreckonqty": {
+                    "description": "采购合同交收量【期末】",
                     "type": "number"
                 },
                 "cycletime": {
@@ -14683,31 +14941,99 @@
                     "type": "integer"
                 },
                 "deliverygoodscode": {
-                    "description": "现货品代码",
+                    "description": "现货品代码",
                     "type": "string"
                 },
                 "deliverygoodsid": {
-                    "description": "现货品种id",
+                    "description": "现货品种ID",
                     "type": "integer"
                 },
                 "deliverygoodsname": {
-                    "description": "现货品名称",
+                    "description": "现货品名称",
                     "type": "string"
                 },
                 "enumdicname": {
                     "description": "现货商品单位名称",
                     "type": "string"
                 },
-                "selloutqty": {
-                    "description": "销售出库量",
+                "goodsunitid": {
+                    "description": "现货商品单位id",
+                    "type": "integer"
+                },
+                "oribuycontractinqty": {
+                    "description": "期初采购合同入库量【期初】",
+                    "type": "number"
+                },
+                "oribuypricedamount": {
+                    "description": "期初采购合同已定价金额【期初】",
+                    "type": "number"
+                },
+                "oribuypricedqty": {
+                    "description": "期初采购合同已定价数量【期初】",
                     "type": "number"
                 },
+                "oribuyreckonqty": {
+                    "description": "期初采购合同交收量【期初】",
+                    "type": "number"
+                },
+                "oriproduceinqty": {
+                    "description": "期初生产入库量【期初】",
+                    "type": "number"
+                },
+                "oriproduceoutqty": {
+                    "description": "期初生产出库量【期初】",
+                    "type": "number"
+                },
+                "orisellcontractoutqty": {
+                    "description": "期初销售合同出库量【期初】",
+                    "type": "number"
+                },
+                "orisellpricedamount": {
+                    "description": "期初销售合同已定价金额【期初】",
+                    "type": "number"
+                },
+                "orisellpricedqty": {
+                    "description": "期初销售合同已定价数量【期初】",
+                    "type": "number"
+                },
+                "orisellreckonqty": {
+                    "description": "期初销售合同交收量【期初】",
+                    "type": "number"
+                },
+                "produceinqty": {
+                    "description": "生产入库量【期末】",
+                    "type": "number"
+                },
+                "produceoutqty": {
+                    "description": "生产出库量【期末】",
+                    "type": "number"
+                },
+                "sellcontractoutqty": {
+                    "description": "销售合同出库量【期末】",
+                    "type": "number"
+                },
+                "sellpricedamount": {
+                    "description": "销售合同已定价金额【期末】",
+                    "type": "number"
+                },
+                "sellpricedqty": {
+                    "description": "销售合同已定价数量【期末】",
+                    "type": "number"
+                },
+                "sellreckonqty": {
+                    "description": "销售合同交收量【期末】",
+                    "type": "number"
+                },
+                "spotgoodsbrandid": {
+                    "description": "现货品牌ID",
+                    "type": "integer"
+                },
                 "todaybuyreckonqty": {
-                    "description": "采购确定量",
+                    "description": "今日采购合同已确定【汇总】",
                     "type": "number"
                 },
                 "todaysellreckonqty": {
-                    "description": "销售确定量",
+                    "description": "今日销售合同已确定【汇总】",
                     "type": "number"
                 },
                 "totalbuypricedqty": {
@@ -14717,6 +15043,30 @@
                 "totalsellpricedqty": {
                     "description": "销售定价量 = 期末 - 期初",
                     "type": "number"
+                },
+                "totalspotqty": {
+                    "description": "现货头寸总量 =  采购合同已定价数量 - 销售合同已定价数量【期末】",
+                    "type": "number"
+                },
+                "updatetime": {
+                    "description": "更新时间",
+                    "type": "string"
+                },
+                "wrfactortypeid": {
+                    "description": "仓单要素类型ID(212+Unix秒时间戳(10位)+xxxxxx)",
+                    "type": "integer"
+                },
+                "wrstandardcode": {
+                    "description": "品类代码",
+                    "type": "string"
+                },
+                "wrstandardid": {
+                    "description": "品类ID",
+                    "type": "integer"
+                },
+                "wrstandardname": {
+                    "description": "品类名称",
+                    "type": "string"
                 }
             }
         },
@@ -14791,6 +15141,10 @@
                     "description": "合同编号",
                     "type": "string"
                 },
+                "spotgoodsbrandid": {
+                    "description": "品牌id",
+                    "type": "integer"
+                },
                 "tradedate": {
                     "description": "交易日(yyyyMMdd)",
                     "type": "string"
@@ -14798,6 +15152,18 @@
                 "userid": {
                     "description": "机构ID",
                     "type": "integer"
+                },
+                "wrstandardcode": {
+                    "description": "品类代码",
+                    "type": "string"
+                },
+                "wrstandardid": {
+                    "description": "品类id",
+                    "type": "integer"
+                },
+                "wrstandardname": {
+                    "description": "品类名称",
+                    "type": "string"
                 }
             }
         },

+ 326 - 59
docs/swagger.yaml

@@ -3806,6 +3806,9 @@ definitions:
     type: object
   models.Ermcp3HedgePlan:
     properties:
+      accountid:
+        description: 资金账号
+        type: integer
       areauserid:
         description: 用户ID
         type: integer
@@ -3857,12 +3860,24 @@ definitions:
       spotgoodsdesc:
         description: 商品型号
         type: string
+      taaccountname:
+        description: 资金账号名称
+        type: string
       unitid:
         description: 单位id
         type: integer
       updatetime:
         description: 更新时间
         type: string
+      wrstandardcode:
+        description: 品类代码
+        type: string
+      wrstandardid:
+        description: 品类id
+        type: integer
+      wrstandardname:
+        description: 品类名称
+        type: string
     type: object
   models.Ermcp3MiddleGoodsDetail2:
     properties:
@@ -3896,6 +3911,135 @@ definitions:
         description: 套保商品信息
         type: object
     type: object
+  models.Ermcp3ReckonAreaSpotSub:
+    properties:
+      accountid:
+        description: 期货账户ID
+        type: integer
+      accountname:
+        description: 所属机构名称
+        type: string
+      areauserid:
+        description: 账户所属机构
+        type: integer
+      brandname:
+        description: 品牌名称
+        type: string
+      buycontractinqty:
+        description: 采购合同入库量
+        type: number
+      buypricedamount:
+        description: 采购合同已定价金额
+        type: number
+      buypricedqty:
+        description: 采购合同已定价数量
+        type: number
+      buyreckonqty:
+        description: 采购合同交收量
+        type: number
+      deliverygoodscode:
+        description: 现货商品代码
+        type: string
+      deliverygoodsid:
+        description: 现货品种ID
+        type: integer
+      deliverygoodsname:
+        description: 现货商品名称
+        type: string
+      enumdicname:
+        description: 现货商品单位名称
+        type: string
+      goodsunitid:
+        description: 现货商品单位id
+        type: integer
+      oribuycontractinqty:
+        description: 期初采购合同入库量
+        type: number
+      oribuypricedamount:
+        description: 期初采购合同已定价金额
+        type: number
+      oribuypricedqty:
+        description: 期初采购合同已定价数量
+        type: number
+      oribuyreckonqty:
+        description: 期初采购合同交收量
+        type: number
+      oriproduceinqty:
+        description: 期初生产入库量
+        type: number
+      oriproduceoutqty:
+        description: 期初生产出库量
+        type: number
+      orisellcontractoutqty:
+        description: 期初销售合同出库量
+        type: number
+      orisellpricedamount:
+        description: 期初销售合同已定价金额
+        type: number
+      orisellpricedqty:
+        description: 期初销售合同已定价数量
+        type: number
+      orisellreckonqty:
+        description: 期初销售合同交收量
+        type: number
+      produceinqty:
+        description: 生产入库量
+        type: number
+      produceoutqty:
+        description: 生产出库量
+        type: number
+      reckondate:
+        description: 日照时期(yyyyMMdd)
+        type: string
+      sellcontractoutqty:
+        description: 销售合同出库量
+        type: number
+      sellpricedamount:
+        description: 销售合同已定价金额
+        type: number
+      sellpricedqty:
+        description: 销售合同已定价数量
+        type: number
+      sellreckonqty:
+        description: 销售合同交收量
+        type: number
+      spotgoodsbrandid:
+        description: 现货品牌ID
+        type: integer
+      todaybuyreckonqty:
+        description: 今日采购合同已确定数量
+        type: number
+      todaysellreckonqty:
+        description: 今日销售合同已确定数量
+        type: number
+      totalbuypricedqty:
+        description: 采购定价量 = 期末 - 期初
+        type: number
+      totalsellpricedqty:
+        description: 销售定价量 = 期末 - 期初
+        type: number
+      totalspotqty:
+        description: 现货头寸总量 =  采购合同已定价数量 - 销售合同已定价数量
+        type: number
+      updatetime:
+        description: 更新时间
+        type: string
+      wrfactortypeid:
+        description: 仓单要素类型ID(212+Unix秒时间戳(10位)+xxxxxx)
+        type: integer
+      wrstandardcode:
+        description: 品类代码
+        type: string
+      wrstandardid:
+        description: 现货品类ID
+        type: integer
+      wrstandardname:
+        description: 品类名称
+        type: string
+    required:
+    - areauserid
+    - reckondate
+    type: object
   models.Ermcp3ReportAreaSpotPL:
     properties:
       actualpl:
@@ -4016,52 +4160,31 @@ definitions:
         description: 品类名称
         type: string
     type: object
-  models.Ermcp3ReportDaySpot:
+  models.Ermcp3ReportAreaSpotSub:
     properties:
-      areauserid:
-        description: 所属机构T
+      accountid:
+        description: 期货账户ID
         type: integer
-      buyinqty:
-        description: 采购入库量
-        type: number
-      deliverygoodscode:
-        description: 现货品种代码
+      accountname:
+        description: 所属机构名称
         type: string
-      deliverygoodsid:
-        description: 现货品种id
+      areauserid:
+        description: 账户所属机构
         type: integer
-      deliverygoodsname:
-        description: 现货品种名称
-        type: string
-      enumdicname:
-        description: 现货商品单位名称
-        type: string
-      reckondate:
-        description: 日照时期(yyyyMMdd)
+      brandname:
+        description: 品牌名称
         type: string
-      selloutqty:
-        description: 销售出库量
+      buycontractinqty:
+        description: 采购合同入库量【期末】
         type: number
-      todaybuyreckonqty:
-        description: 采购确定量
-        type: number
-      todaysellreckonqty:
-        description: 销售确定量
+      buypricedamount:
+        description: 采购合同已定价金额【期末】
         type: number
-      totalbuypricedqty:
-        description: 采购定价量 = 期末 - 期初
-        type: number
-      totalsellpricedqty:
-        description: 销售定价量 = 期末 - 期初
+      buypricedqty:
+        description: 采购合同已定价数量【期末】
         type: number
-    type: object
-  models.Ermcp3ReportMonSpot:
-    properties:
-      areauserid:
-        description: 所属机构id
-        type: integer
-      buyinqty:
-        description: 采购入库量
+      buyreckonqty:
+        description: 采购合同交收量【期末】
         type: number
       cycletime:
         description: 周期时间 月(YYYYMM)  季(YYYYQ) 年(YYYY) 周(YYYYIW) 全(0)【原值】
@@ -4070,25 +4193,76 @@ definitions:
         description: 周期类型 - 1:月 2:季 3:年 4:周 5:全报表【原值】
         type: integer
       deliverygoodscode:
-        description: 现货品代码
+        description: 现货品代码
         type: string
       deliverygoodsid:
-        description: 现货品种id
+        description: 现货品种ID
         type: integer
       deliverygoodsname:
-        description: 现货品名称
+        description: 现货品名称
         type: string
       enumdicname:
         description: 现货商品单位名称
         type: string
-      selloutqty:
-        description: 销售出库量
+      goodsunitid:
+        description: 现货商品单位id
+        type: integer
+      oribuycontractinqty:
+        description: 期初采购合同入库量【期初】
         type: number
+      oribuypricedamount:
+        description: 期初采购合同已定价金额【期初】
+        type: number
+      oribuypricedqty:
+        description: 期初采购合同已定价数量【期初】
+        type: number
+      oribuyreckonqty:
+        description: 期初采购合同交收量【期初】
+        type: number
+      oriproduceinqty:
+        description: 期初生产入库量【期初】
+        type: number
+      oriproduceoutqty:
+        description: 期初生产出库量【期初】
+        type: number
+      orisellcontractoutqty:
+        description: 期初销售合同出库量【期初】
+        type: number
+      orisellpricedamount:
+        description: 期初销售合同已定价金额【期初】
+        type: number
+      orisellpricedqty:
+        description: 期初销售合同已定价数量【期初】
+        type: number
+      orisellreckonqty:
+        description: 期初销售合同交收量【期初】
+        type: number
+      produceinqty:
+        description: 生产入库量【期末】
+        type: number
+      produceoutqty:
+        description: 生产出库量【期末】
+        type: number
+      sellcontractoutqty:
+        description: 销售合同出库量【期末】
+        type: number
+      sellpricedamount:
+        description: 销售合同已定价金额【期末】
+        type: number
+      sellpricedqty:
+        description: 销售合同已定价数量【期末】
+        type: number
+      sellreckonqty:
+        description: 销售合同交收量【期末】
+        type: number
+      spotgoodsbrandid:
+        description: 现货品牌ID
+        type: integer
       todaybuyreckonqty:
-        description: 采购确定量
+        description: 今日采购合同已确定【汇总】
         type: number
       todaysellreckonqty:
-        description: 销售确定量
+        description: 今日销售合同已确定【汇总】
         type: number
       totalbuypricedqty:
         description: 采购定价量 = 期末 - 期初
@@ -4096,6 +4270,26 @@ definitions:
       totalsellpricedqty:
         description: 销售定价量 = 期末 - 期初
         type: number
+      totalspotqty:
+        description: 现货头寸总量 =  采购合同已定价数量 - 销售合同已定价数量【期末】
+        type: number
+      updatetime:
+        description: 更新时间
+        type: string
+      wrfactortypeid:
+        description: 仓单要素类型ID(212+Unix秒时间戳(10位)+xxxxxx)
+        type: integer
+      wrstandardcode:
+        description: 品类代码
+        type: string
+      wrstandardid:
+        description: 品类ID
+        type: integer
+      wrstandardname:
+        description: 品类名称
+        type: string
+    required:
+    - areauserid
     type: object
   models.Ermcp3ReportOPLog:
     properties:
@@ -4150,12 +4344,24 @@ definitions:
       relatedno:
         description: 合同编号
         type: string
+      spotgoodsbrandid:
+        description: 品牌id
+        type: integer
       tradedate:
         description: 交易日(yyyyMMdd)
         type: string
       userid:
         description: 机构ID
         type: integer
+      wrstandardcode:
+        description: 品类代码
+        type: string
+      wrstandardid:
+        description: 品类id
+        type: integer
+      wrstandardname:
+        description: 品类名称
+        type: string
     type: object
   models.Ermcp3SellBuyContract:
     properties:
@@ -14888,16 +15094,32 @@ paths:
   /Ermcp3/QryReportDaySpot:
     get:
       parameters:
-      - description: 用户ID
+      - description: 所属机构id
         in: query
-        name: userid
+        name: areauserid
         required: true
         type: integer
       - description: 交易日(格式:yyyyMMdd)
         in: query
-        name: tradedate
+        name: reckondate
         required: true
         type: string
+      - description: 期货账户ID
+        in: query
+        name: accountid
+        type: integer
+      - description: 现货品种ID
+        in: query
+        name: deliverygoodsid
+        type: integer
+      - description: 品类ID
+        in: query
+        name: wrstandardid
+        type: integer
+      - description: 现货品牌ID
+        in: query
+        name: spotgoodsbrandid
+        type: integer
       produces:
       - application/json
       responses:
@@ -14905,7 +15127,7 @@ paths:
           description: OK
           schema:
             items:
-              $ref: '#/definitions/models.Ermcp3ReportDaySpot'
+              $ref: '#/definitions/models.Ermcp3ReckonAreaSpotSub'
             type: array
         "500":
           description: Internal Server Error
@@ -14934,6 +15156,14 @@ paths:
         name: tradedate
         required: true
         type: string
+      - description: 品类ID
+        in: query
+        name: wrstandardid
+        type: integer
+      - description: 现货品牌ID
+        in: query
+        name: spotgoodsbrandid
+        type: integer
       produces:
       - application/json
       responses:
@@ -14955,16 +15185,37 @@ paths:
   /Ermcp3/QryReportMonthSpot:
     get:
       parameters:
-      - description: 用户ID
+      - description: 所属机构id
         in: query
-        name: userid
+        name: areauserid
         required: true
         type: integer
-      - description: 周期时间:月(格式:yyyyMM)
+      - description: 周期类型 - 1:月 2:季 3:年 4:周 5:全报表【原值】
+        in: query
+        name: cycletype
+        required: true
+        type: integer
+      - description: 周期时间 月(YYYYMM)  季(YYYYQ) 年(YYYY) 周(YYYYIW) 全(0)【原值】
         in: query
         name: cycletime
         required: true
         type: string
+      - description: 期货账户ID
+        in: query
+        name: accountid
+        type: integer
+      - description: 现货品种ID
+        in: query
+        name: deliverygoodsid
+        type: integer
+      - description: 品类ID
+        in: query
+        name: wrstandardid
+        type: integer
+      - description: 现货品牌ID
+        in: query
+        name: spotgoodsbrandid
+        type: integer
       produces:
       - application/json
       responses:
@@ -14972,7 +15223,7 @@ paths:
           description: OK
           schema:
             items:
-              $ref: '#/definitions/models.Ermcp3ReportMonSpot'
+              $ref: '#/definitions/models.Ermcp3ReportAreaSpotSub'
             type: array
         "500":
           description: Internal Server Error
@@ -14986,21 +15237,37 @@ paths:
   /Ermcp3/QryReportMonthSpotDetail:
     get:
       parameters:
-      - description: 用户ID
+      - description: 所属机构id
         in: query
-        name: userid
+        name: areauserid
         required: true
         type: integer
-      - description: 现货商品id
+      - description: 周期类型 - 1:月 2:季 3:年 4:周 5:全报表【原值】
         in: query
-        name: deliverygoodsid
+        name: cycletype
         required: true
         type: integer
-      - description: 周期时间:月(格式:yyyyMM)
+      - description: 周期时间 月(YYYYMM)  季(YYYYQ) 年(YYYY) 周(YYYYIW) 全(0)【原值】
         in: query
         name: cycletime
         required: true
         type: string
+      - description: 期货账户ID
+        in: query
+        name: accountid
+        type: integer
+      - description: 现货品种ID
+        in: query
+        name: deliverygoodsid
+        type: integer
+      - description: 品类ID
+        in: query
+        name: wrstandardid
+        type: integer
+      - description: 现货品牌ID
+        in: query
+        name: spotgoodsbrandid
+        type: integer
       produces:
       - application/json
       responses:
@@ -15008,7 +15275,7 @@ paths:
           description: OK
           schema:
             items:
-              $ref: '#/definitions/models.Ermcp3ReportDaySpot'
+              $ref: '#/definitions/models.Ermcp3ReportAreaSpotSub'
             type: array
         "500":
           description: Internal Server Error

+ 13 - 1
models/ermcp3.go

@@ -1906,6 +1906,11 @@ type Ermcp3HedgePlan struct {
 	AUDITTIME         string  `json:"audittime"  xorm:"'AUDITTIME'"`                 // 审核时间
 	UNITID            int32   `json:"unitid"  xorm:"'UNITID'"`                       // 单位id
 	ENUMDICNAME       string  `json:"enumdicname"`                                   // 单位名称
+	WRSTANDARDID      int32   `json:"wrstandardid"  xorm:"'WRSTANDARDID'"`           // 品类id
+	WRSTANDARDCODE    string  `json:"wrstandardcode"  xorm:"'WRSTANDARDCODE'"`       // 品类代码
+	WRSTANDARDNAME    string  `json:"wrstandardname"  xorm:"'WRSTANDARDNAME'"`       // 品类名称
+	ACCOUNTID         int64   `json:"accountid"  xorm:"'ACCOUNTID'"`                 // 资金账号
+	TAACCOUNTNAME     string  `json:"taaccountname"  xorm:"'TAACCOUNTNAME'"`         // 资金账号名称
 }
 
 func (r *Ermcp3HedgePlan) calc() {
@@ -1929,10 +1934,17 @@ func (r *Ermcp3HedgePlan) buildSql(status string) string {
 		"       to_char(t.updatetime, 'yyyy-mm-dd hh24:mi:ss') updatetime," +
 		"       to_char(t.audittime, 'yyyy-mm-dd hh24:mi:ss') audittime," +
 		"       t.Hedgeplanstatus," +
-		"       t.Remark" +
+		"       t.Remark," +
+		"       t.wrstandardid," +
+		"       w.wrstandardcode," +
+		"       w.wrstandardname," +
+		"       t.accountid," +
+		"       ta.accountname taaccountname" +
 		"  from ermcp_hedgeplan t" +
 		"  left join deliverygoods g" +
 		"    on t.deliverygoodsid = g.deliverygoodsid" +
+		"  left join wrstandard w on t.wrstandardid=w.wrstandardid" +
+		"  left join taaccount ta on t.accountid=ta.accountid" +
 		" where t.hedgeplanstatus in (%v)" +
 		"   and t.areauserid = %v"
 

+ 277 - 177
models/ermcp3Report.go

@@ -35,8 +35,11 @@ type Ermcp3ReportOPLog struct {
 	DELIVERYGOODSID   int32  `json:"deliverygoodsid"  xorm:"'DELIVERYGOODSID'"`     // 现货品种id
 	DELIVERYGOODSCODE string `json:"deliverygoodscode"  xorm:"'DELIVERYGOODSCODE'"` // 现货品种代码
 	DELIVERYGOODSNAME string `json:"deliverygoodsname"  xorm:"'DELIVERYGOODSNAME'"` // 现货品种名称
-
-	LogTypeFilter string `json:"-"` // 查询日志类型, 逗号隔开(如 1,2,4)
+	WRSTANDARDID      int32  `json:"wrstandardid"  xorm:"'wrstandardid'"`           // 品类id
+	WRSTANDARDCODE    string `json:"wrstandardcode"  xorm:"'wrstandardcode'"`       // 品类代码
+	WRSTANDARDNAME    string `json:"wrstandardname"  xorm:"'wrstandardname'"`       // 品类名称
+	SPOTGOODSBRANDID  int32  `json:"spotgoodsbrandid"  xorm:"'SPOTGOODSBRANDID'"`   // 品牌id
+	LogTypeFilter     string `json:"-"`                                             // 查询日志类型, 逗号隔开(如 1,2,4)
 }
 
 // Calc 处理数据
@@ -51,11 +54,13 @@ func (r *Ermcp3ReportOPLog) Calc() {
 	//1:点价价格 2:点价数量 3:结算量 4:其它费用 5:追加保证金 6溢短金额 7:调整金额 8:付款金额 9:收款金额 10:退款金额
 	//11:收票金额 12:开票金额 13:提交审核(合同) 14:审核通过(合同) 15:审核拒绝(合同) 16:合同撤回 17:提交审核(计划)
 	//18:审核通过(计划) 19:审核拒绝(计划) 20:计划撤回 21:正常完结(合同) 22:异常终止(合同) 23:退还保证金
+	//24:采购入库 25:销售出库 26:生产入库 27:生产出库
 	// 数据库注释与返回值映身关系: 结算量->确定量, 收款->收款金额, 退款->退款金额, 付款->付款金额, 收票->收票金额, 开票->开票金额
 	sDes := []string{"点价价格", "点价数量", "确定量", "其它费用", "追加保证金", "溢短金额", "调整金额", "付款", "收款", "退款",
 		"收票", "开票", "提交审核(合同)", "审核通过(合同)", "审核拒绝(合同)", "合同撤回", "提交审核(计划)",
-		"审核通过(计划)", "审核拒绝(计划)", "计划撤回", "正常完结(合同)", "异常终止(合同)", "退还保证金"}
-	if r.OPERATELOGTYPE >= 1 && r.OPERATELOGTYPE <= 23 {
+		"审核通过(计划)", "审核拒绝(计划)", "计划撤回", "正常完结(合同)", "异常终止(合同)", "退还保证金",
+		"采购入库", "销售出库", "生产入库", "生产出库"}
+	if r.OPERATELOGTYPE >= 1 && r.OPERATELOGTYPE <= 27 {
 		r.OPTYPENAME = sDes[r.OPERATELOGTYPE-1]
 	}
 
@@ -113,18 +118,23 @@ func (r *Ermcp3ReportOPLog) buildSql() string {
 		"       t.APPLYID," +
 		"       t.CONTRACTTYPE," +
 		"       t.USERID," +
+		"       t.wrstandardid," +
 		"       s.contractno relatedno," +
 		"       s.spotgoodsbrandid," +
 		"       g.deliverygoodsid," +
 		"       g.deliverygoodscode," +
 		"       g.deliverygoodsname," +
 		"       g.goodsunitid unitid," +
-		"       gb.dgfactoryitemvalue brandname" +
+		"       gb.dgfactoryitemvalue brandname," +
+		"       s.accountid," +
+		"       w.wrstandardcode," +
+		"       w.wrstandardname" +
 		"  FROM ERMCP_CONTRACTOPERATELOG t" +
 		" inner join ermcp_spotcontract s" +
 		"    on t.RELATEDID = s.spotcontractid" +
 		"  left join deliverygoods g" +
 		"    on t.deliverygoodsid = g.deliverygoodsid" +
+		"  left join wrstandard w on t.wrstandardid=w.wrstandardid" +
 		"  left join dgfactoryitem gb" +
 		"    on s.spotgoodsbrandid = gb.dgfactoryitemid" +
 		" WHERE t.biztype = 2"
@@ -132,6 +142,8 @@ func (r *Ermcp3ReportOPLog) buildSql() string {
 	sqlId.And("t.userid", r.USERID)
 	sqlId.And("t.TRADEDATE", r.TRADEDATE)
 	sqlId.AndEx("t.deliverygoodsid", r.DELIVERYGOODSID, r.DELIVERYGOODSID > 0)
+	sqlId.AndEx("t.wrstandardid", r.WRSTANDARDID, r.WRSTANDARDID > 0)
+	sqlId.AndEx("s.spotgoodsbrandid", r.SPOTGOODSBRANDID, r.SPOTGOODSBRANDID > 0)
 	if r.LogTypeFilter != "" {
 		sqlId.Join(fmt.Sprintf(" and t.OPERATELOGTYPE in(%v)", r.LogTypeFilter))
 	}
@@ -148,178 +160,6 @@ func (r *Ermcp3ReportOPLog) GetDataEx() (interface{}, error) {
 	return sData, err
 }
 
-// Ermcp3ReportDaySpot 现货日报表
-type Ermcp3ReportDaySpot struct {
-	BUYPRICEDQTY       float64 `json:"-"  xorm:"'BUYPRICEDQTY'"`                        // 期末采购定价量
-	SELLPRICEDQTY      float64 `json:"-"  xorm:"'SELLPRICEDQTY'"`                       // 期末销售定价量
-	ORIBUYPRICEDQTY    float64 `json:"-"  xorm:"'ORIBUYPRICEDQTY'"`                     // 期初采购定价量
-	ORISELLPRICEDQTY   float64 `json:"-"  xorm:"'ORISELLPRICEDQTY'"`                    // 期初销售定价量
-	TODAYBUYRECKONQTY  float64 `json:"todaybuyreckonqty"  xorm:"'TODAYBUYRECKONQTY'"`   // 采购确定量
-	TODAYSELLRECKONQTY float64 `json:"todaysellreckonqty"  xorm:"'TODAYSELLRECKONQTY'"` // 销售确定量
-	RECKONDATE         string  `json:"reckondate"  xorm:"'RECKONDATE'"`                 // 日照时期(yyyyMMdd)
-	AREAUSERID         int64   `json:"areauserid"  xorm:"'AREAUSERID'"`                 // 所属机构T
-	UNITID             int32   `json:"-"  xorm:"'UNITID'"`                              // 现货商品单位id
-	BUYINQTY           float64 `json:"buyinqty"  xorm:"'BUYINQTY'"`                     // 采购入库量
-	SELLOUTQTY         float64 `json:"selloutqty"  xorm:"'SELLOUTQTY'"`                 // 销售出库量
-	DELIVERYGOODSID    int32   `json:"deliverygoodsid"  xorm:"'DELIVERYGOODSID'"`       // 现货品种id
-	DELIVERYGOODSCODE  string  `json:"deliverygoodscode"  xorm:"'DELIVERYGOODSCODE'"`   // 现货品种代码
-	DELIVERYGOODSNAME  string  `json:"deliverygoodsname"  xorm:"'DELIVERYGOODSNAME'"`   // 现货品种名称
-
-	ENUMDICNAME        string  `json:"enumdicname"`        // 现货商品单位名称
-	TOTALBUYPRICEDQTY  float64 `json:"totalbuypricedqty"`  // 采购定价量 = 期末 - 期初
-	TOTALSELLPRICEDQTY float64 `json:"totalsellpricedqty"` // 销售定价量 = 期末 - 期初
-	BeginDate          string  `json:"-"`                  // 开始日期
-	EndDate            string  `json:"-"`                  // 结束日期
-}
-
-// Calc 数据处理
-func (r *Ermcp3ReportDaySpot) Calc() {
-	r.TOTALBUYPRICEDQTY = r.BUYPRICEDQTY - r.ORIBUYPRICEDQTY
-	r.TOTALSELLPRICEDQTY = r.SELLPRICEDQTY - r.ORISELLPRICEDQTY
-	r.ENUMDICNAME = mtpcache.GetEnumDicitemName(r.UNITID)
-}
-
-func (r *Ermcp3ReportDaySpot) buildSql() string {
-	var sqlId utils.SQLVal = "with tmp as" +
-		" (select t.userid," +
-		"         t.deliverygoodsid," +
-		"         t.reckondate," +
-		"         sum(t.todaybuyinqty) todaybuyinqty," +
-		"         sum(t.todayselloutqty) todayselloutqty" +
-		"    from Reckon_ERMCP_AreaStock t" +
-		"   group by t.userid, t.deliverygoodsid, t.reckondate)" +
-		"select t.reckondate," +
-		"       t.BUYPRICEDQTY," +
-		"       t.SELLPRICEDQTY," +
-		"       t.Oribuypricedqty," +
-		"       t.Orisellpricedqty," +
-		"       t.TODAYBUYRECKONQTY," +
-		"       t.TODAYSELLRECKONQTY," +
-		"       t.RECKONDATE," +
-		"       t.AREAUSERID," +
-		"       g.deliverygoodsid," +
-		"       g.deliverygoodscode," +
-		"       g.deliverygoodsname," +
-		"       g.goodsunitid        unitid," +
-		"       s.todaybuyinqty      buyinqty," +
-		"       s.todayselloutqty    selloutqty" +
-		"  from RECKON_ERMCP_AREASPOT t" +
-		"  left join tmp s" +
-		"    on t.reckondate = s.reckondate" +
-		"   and t.areauserid = s.userid" +
-		"   and t.deliverygoodsid = s.deliverygoodsid" +
-		"  left join deliverygoods g" +
-		"    on t.deliverygoodsid = g.deliverygoodsid" +
-		" where 1 = 1"
-	sqlId.And("t.AREAUSERID", r.AREAUSERID)
-	if r.DELIVERYGOODSID > 0 {
-		sqlId.And("t.DELIVERYGOODSID", r.DELIVERYGOODSID)
-	}
-	if r.RECKONDATE != "" {
-		sqlId.And("t.RECKONDATE", r.RECKONDATE)
-	} else if r.BeginDate != "" && r.BeginDate == r.EndDate {
-		sqlId.And("t.RECKONDATE", r.BeginDate)
-	} else {
-		if r.BeginDate != "" {
-			sqlId.BiggerOrEq("t.RECKONDATE", r.BeginDate)
-		}
-		if r.EndDate != "" {
-			sqlId.LessOrEq("t.RECKONDATE", r.EndDate)
-		}
-	}
-	sqlId.Join(" order by t.RECKONDATE")
-	return sqlId.String()
-}
-
-// GetDataEx 获取现货日报表
-func (r *Ermcp3ReportDaySpot) GetDataEx() (interface{}, error) {
-	sData := make([]Ermcp3ReportDaySpot, 0)
-	err := db.GetEngine().SQL(r.buildSql()).Find(&sData)
-	for i := range sData {
-		sData[i].Calc()
-	}
-	return sData, err
-}
-
-// Ermcp3ReportMonSpot 现货月报表
-type Ermcp3ReportMonSpot struct {
-	CYCLETYPE          int32   `json:"cycletype"  xorm:"'cycletype'"`                   // 周期类型 - 1:月 2:季 3:年 4:周 5:全报表【原值】
-	CYCLETIME          string  `json:"cycletime"  xorm:"'cycletime'"`                   // 周期时间 月(YYYYMM)  季(YYYYQ) 年(YYYY) 周(YYYYIW) 全(0)【原值】
-	BUYPRICEDQTY       float64 `json:"-"  xorm:"'BUYPRICEDQTY'"`                        // 期末采购定价量
-	SELLPRICEDQTY      float64 `json:"-"  xorm:"'SELLPRICEDQTY'"`                       // 期末销售定价量
-	ORIBUYPRICEDQTY    float64 `json:"-"  xorm:"'ORIBUYPRICEDQTY'"`                     // 期初采购定价量
-	ORISELLPRICEDQTY   float64 `json:"-"  xorm:"'ORISELLPRICEDQTY'"`                    // 期初销售定价量
-	TODAYBUYRECKONQTY  float64 `json:"todaybuyreckonqty"  xorm:"'TODAYBUYRECKONQTY'"`   // 采购确定量
-	TODAYSELLRECKONQTY float64 `json:"todaysellreckonqty"  xorm:"'TODAYSELLRECKONQTY'"` // 销售确定量
-	AREAUSERID         int64   `json:"areauserid"  xorm:"'AREAUSERID'"`                 // 所属机构id
-	UNITID             int32   `json:"-"  xorm:"'UNITID'"`                              // 现货商品单位id
-	BUYINQTY           float64 `json:"buyinqty"  xorm:"'BUYINQTY'"`                     // 采购入库量
-	SELLOUTQTY         float64 `json:"selloutqty"  xorm:"'SELLOUTQTY'"`                 // 销售出库量
-	DELIVERYGOODSID    int32   `json:"deliverygoodsid"  xorm:"'DELIVERYGOODSID'"`       // 现货品种id
-	DELIVERYGOODSCODE  string  `json:"deliverygoodscode"  xorm:"'DELIVERYGOODSCODE'"`   // 现货品种代码
-	DELIVERYGOODSNAME  string  `json:"deliverygoodsname"  xorm:"'DELIVERYGOODSNAME'"`   // 现货品种名称
-
-	ENUMDICNAME        string  `json:"enumdicname"`        // 现货商品单位名称
-	TOTALBUYPRICEDQTY  float64 `json:"totalbuypricedqty"`  // 采购定价量 = 期末 - 期初
-	TOTALSELLPRICEDQTY float64 `json:"totalsellpricedqty"` // 销售定价量 = 期末 - 期初
-}
-
-// Calc 数据处理
-func (r *Ermcp3ReportMonSpot) Calc() {
-	r.TOTALBUYPRICEDQTY = r.BUYPRICEDQTY - r.ORIBUYPRICEDQTY
-	r.TOTALSELLPRICEDQTY = r.SELLPRICEDQTY - r.ORISELLPRICEDQTY
-	r.ENUMDICNAME = mtpcache.GetEnumDicitemName(r.UNITID)
-}
-
-func (r *Ermcp3ReportMonSpot) buildSql() string {
-	var sqlId utils.SQLVal = "with tmp as" +
-		" (select t.userid," +
-		"         t.deliverygoodsid," +
-		"         t.cycletime," +
-		"         t.cycletype," +
-		"         sum(t.todaybuyinqty) todaybuyinqty," +
-		"         sum(t.todayselloutqty) todayselloutqty" +
-		"    from Report_ERMCP_AreaStock t" +
-		"   group by t.userid, t.deliverygoodsid, t.cycletime, t.cycletype)" +
-		"select t.BUYPRICEDQTY," +
-		"       t.SELLPRICEDQTY," +
-		"       t.Oribuypricedqty," +
-		"       t.Orisellpricedqty," +
-		"       t.TODAYBUYRECKONQTY," +
-		"       t.TODAYSELLRECKONQTY," +
-		"       t.cycletype," +
-		"       t.cycletime," +
-		"       t.AREAUSERID," +
-		"       g.deliverygoodsid," +
-		"       g.deliverygoodscode," +
-		"       g.deliverygoodsname," +
-		"       g.goodsunitid        unitid," +
-		"       s.todaybuyinqty      buyinqty," +
-		"       s.todayselloutqty    selloutqty" +
-		"  from Report_ERMCP_AreaSpot t" +
-		"  left join tmp s" +
-		"    on t.cycletime = s.cycletime" +
-		"   and t.cycletype = s.cycletype" +
-		"   and t.areauserid = s.userid" +
-		"   and t.deliverygoodsid = s.deliverygoodsid" +
-		"  left join deliverygoods g" +
-		"    on t.deliverygoodsid = g.deliverygoodsid" +
-		" where t.cycletype = 1"
-	sqlId.And("t.AREAUSERID", r.AREAUSERID)
-	sqlId.And("t.cycletime", r.CYCLETIME)
-	return sqlId.String()
-}
-
-// GetDataEx 获取现货月报表
-func (r *Ermcp3ReportMonSpot) GetDataEx() (interface{}, error) {
-	sData := make([]Ermcp3ReportMonSpot, 0)
-	err := db.GetEngine().SQL(r.buildSql()).Find(&sData)
-	for i := range sData {
-		sData[i].Calc()
-	}
-	return sData, err
-}
-
 // Ermcp3ReportAreaSpotPL 现货损益日/月表
 type Ermcp3ReportAreaSpotPL struct {
 	AREAUSERID            int64   `json:"areauserid"  xorm:"'AREAUSERID'"`                       // 所属机构
@@ -449,3 +289,263 @@ func (r *Ermcp3ReportAreaSpotPL) GetDataEx() (interface{}, error) {
 	}
 	return sData, err
 }
+
+// Ermcp3ReckonAreaSpotSub 现货日报表
+type Ermcp3ReckonAreaSpotSub struct {
+	RECKONDATE            string  `json:"reckondate"  xorm:"'RECKONDATE'" form:"reckondate" binding:"required"` // 日照时期(yyyyMMdd)
+	AREAUSERID            int64   `json:"areauserid"  xorm:"'AREAUSERID'" form:"areauserid" binding:"required"` // 账户所属机构
+	ACCOUNTID             int64   `json:"accountid"  xorm:"'ACCOUNTID'" form:"accountid"`                       // 期货账户ID
+	WRFACTORTYPEID        int64   `json:"wrfactortypeid"  xorm:"'WRFACTORTYPEID'"`                              // 仓单要素类型ID(212+Unix秒时间戳(10位)+xxxxxx)
+	DELIVERYGOODSID       int64   `json:"deliverygoodsid"  xorm:"'DELIVERYGOODSID'" form:"deliverygoodsid"`     // 现货品种ID
+	WRSTANDARDID          int64   `json:"wrstandardid"  xorm:"'WRSTANDARDID'" form:"wrstandardid"`              // 现货品类ID
+	SPOTGOODSBRANDID      int32   `json:"spotgoodsbrandid"  xorm:"'SPOTGOODSBRANDID'" form:"spotgoodsbrandid"`  // 现货品牌ID
+	ORIBUYPRICEDQTY       float64 `json:"oribuypricedqty"  xorm:"'ORIBUYPRICEDQTY'"`                            // 期初采购合同已定价数量
+	ORISELLPRICEDQTY      float64 `json:"orisellpricedqty"  xorm:"'ORISELLPRICEDQTY'"`                          // 期初销售合同已定价数量
+	BUYPRICEDQTY          float64 `json:"buypricedqty"  xorm:"'BUYPRICEDQTY'"`                                  // 采购合同已定价数量
+	SELLPRICEDQTY         float64 `json:"sellpricedqty"  xorm:"'SELLPRICEDQTY'"`                                // 销售合同已定价数量
+	TOTALSPOTQTY          float64 `json:"totalspotqty"  xorm:"'TOTALSPOTQTY'"`                                  // 现货头寸总量 =  采购合同已定价数量 - 销售合同已定价数量
+	UPDATETIME            string  `json:"updatetime"  xorm:"'UPDATETIME'"`                                      // 更新时间
+	TODAYBUYRECKONQTY     float64 `json:"todaybuyreckonqty"  xorm:"'TODAYBUYRECKONQTY'"`                        // 今日采购合同已确定数量
+	TODAYSELLRECKONQTY    float64 `json:"todaysellreckonqty"  xorm:"'TODAYSELLRECKONQTY'"`                      // 今日销售合同已确定数量
+	ORIBUYPRICEDAMOUNT    float64 `json:"oribuypricedamount"  xorm:"'ORIBUYPRICEDAMOUNT'"`                      // 期初采购合同已定价金额
+	ORISELLPRICEDAMOUNT   float64 `json:"orisellpricedamount"  xorm:"'ORISELLPRICEDAMOUNT'"`                    // 期初销售合同已定价金额
+	BUYPRICEDAMOUNT       float64 `json:"buypricedamount"  xorm:"'BUYPRICEDAMOUNT'"`                            // 采购合同已定价金额
+	SELLPRICEDAMOUNT      float64 `json:"sellpricedamount"  xorm:"'SELLPRICEDAMOUNT'"`                          // 销售合同已定价金额
+	ORIBUYRECKONQTY       float64 `json:"oribuyreckonqty"  xorm:"'ORIBUYRECKONQTY'"`                            // 期初采购合同交收量
+	ORISELLRECKONQTY      float64 `json:"orisellreckonqty"  xorm:"'ORISELLRECKONQTY'"`                          // 期初销售合同交收量
+	ORIBUYCONTRACTINQTY   float64 `json:"oribuycontractinqty"  xorm:"'ORIBUYCONTRACTINQTY'"`                    // 期初采购合同入库量
+	ORISELLCONTRACTOUTQTY float64 `json:"orisellcontractoutqty"  xorm:"'ORISELLCONTRACTOUTQTY'"`                // 期初销售合同出库量
+	ORIPRODUCEINQTY       float64 `json:"oriproduceinqty"  xorm:"'ORIPRODUCEINQTY'"`                            // 期初生产入库量
+	ORIPRODUCEOUTQTY      float64 `json:"oriproduceoutqty"  xorm:"'ORIPRODUCEOUTQTY'"`                          // 期初生产出库量
+	BUYRECKONQTY          float64 `json:"buyreckonqty"  xorm:"'BUYRECKONQTY'"`                                  // 采购合同交收量
+	SELLRECKONQTY         float64 `json:"sellreckonqty"  xorm:"'SELLRECKONQTY'"`                                // 销售合同交收量
+	BUYCONTRACTINQTY      float64 `json:"buycontractinqty"  xorm:"'BUYCONTRACTINQTY'"`                          // 采购合同入库量
+	SELLCONTRACTOUTQTY    float64 `json:"sellcontractoutqty"  xorm:"'SELLCONTRACTOUTQTY'"`                      // 销售合同出库量
+	PRODUCEINQTY          float64 `json:"produceinqty"  xorm:"'PRODUCEINQTY'"`                                  // 生产入库量
+	PRODUCEOUTQTY         float64 `json:"produceoutqty"  xorm:"'PRODUCEOUTQTY'"`                                // 生产出库量
+	ENUMDICNAME           string  `json:"enumdicname"  xorm:"'ENUMDICNAME'"`                                    // 现货商品单位名称
+	WRSTANDARDNAME        string  `json:"wrstandardname"  xorm:"'wrstandardname'"`                              // 品类名称
+	WRSTANDARDCODE        string  `json:"wrstandardcode"  xorm:"'wrstandardcode'"`                              // 品类代码
+	DELIVERYGOODSCODE     string  `json:"deliverygoodscode"  xorm:"'deliverygoodscode'"`                        // 现货商品代码
+	DELIVERYGOODSNAME     string  `json:"deliverygoodsname"  xorm:"'deliverygoodsname'"`                        // 现货商品名称
+	GOODSUNITID           int32   `json:"goodsunitid"  xorm:"'goodsunitid'"`                                    // 现货商品单位id
+	BRANDNAME             string  `json:"brandname"  xorm:"'brandname'"`                                        // 品牌名称
+	ACCOUNTNAME           string  `json:"accountname"  xorm:"'accountname'"`                                    // 所属机构名称
+
+	TOTALBUYPRICEDQTY  float64 `json:"totalbuypricedqty"`  // 采购定价量 = 期末 - 期初
+	TOTALSELLPRICEDQTY float64 `json:"totalsellpricedqty"` // 销售定价量 = 期末 - 期初
+	BeginDate          string  `json:"-"`                  // 开始日期
+	EndDate            string  `json:"-"`                  // 结束日期
+}
+
+func (r *Ermcp3ReckonAreaSpotSub) calc() {
+	r.TOTALBUYPRICEDQTY = r.BUYPRICEDQTY - r.ORIBUYPRICEDQTY
+	r.TOTALSELLPRICEDQTY = r.SELLPRICEDQTY - r.ORISELLPRICEDQTY
+}
+
+func (r *Ermcp3ReckonAreaSpotSub) buildSql() string {
+	var sqlId utils.SQLVal = "SELECT t.ORIBUYRECKONQTY," +
+		"       t.ORISELLRECKONQTY," +
+		"       t.ORIBUYCONTRACTINQTY," +
+		"       t.ORISELLCONTRACTOUTQTY," +
+		"       t.ORIPRODUCEINQTY," +
+		"       t.ORIPRODUCEOUTQTY," +
+		"       t.BUYRECKONQTY," +
+		"       t.SELLRECKONQTY," +
+		"       t.BUYCONTRACTINQTY," +
+		"       t.SELLCONTRACTOUTQTY," +
+		"       t.PRODUCEINQTY," +
+		"       t.PRODUCEOUTQTY," +
+		"       t.Reckondate," +
+		"       t.AREAUSERID," +
+		"       t.ACCOUNTID," +
+		"       t.WRFACTORTYPEID," +
+		"       t.DELIVERYGOODSID," +
+		"       t.WRSTANDARDID," +
+		"       t.SPOTGOODSBRANDID," +
+		"       t.ORIBUYPRICEDQTY," +
+		"       t.ORISELLPRICEDQTY," +
+		"       t.BUYPRICEDQTY," +
+		"       t.SELLPRICEDQTY," +
+		"       t.TOTALSPOTQTY," +
+		"       to_char(t.UPDATETIME, 'yyyy-mm-dd hh24:mi:ss') UPDATETIME," +
+		"       t.TODAYBUYRECKONQTY," +
+		"       t.TODAYSELLRECKONQTY," +
+		"       t.ORIBUYPRICEDAMOUNT," +
+		"       t.ORISELLPRICEDAMOUNT," +
+		"       t.BUYPRICEDAMOUNT," +
+		"       t.SELLPRICEDAMOUNT," +
+		"       w.wrstandardname," +
+		"       w.wrstandardcode," +
+		"       g.deliverygoodscode," +
+		"       g.deliverygoodsname," +
+		"       g.goodsunitid," +
+		"       d.dgfactoryitemvalue brandname," +
+		"       u.accountname," +
+		"       e.enumdicname" +
+		"  FROM RECKON_ERMCP_AREASPOTSUB t" +
+		"  LEFT JOIN WRSTANDARD w" +
+		"    on t.wrstandardid = w.wrstandardid" +
+		"  LEFT JOIN DELIVERYGOODS g" +
+		"    on t.deliverygoodsid = g.deliverygoodsid" +
+		"  LEFT JOIN DGFACTORYITEM d" +
+		"    on t.spotgoodsbrandid = d.dgfactoryitemid" +
+		"  LEFT JOIN USERACCOUNT u" +
+		"    on t.areauserid = u.userid" +
+		"  LEFT JOIN ENUMDICITEM e" +
+		"    on g.goodsunitid = e.enumitemname" +
+		"   and e.enumdiccode = 'goodsunit'" +
+		"   and e.enumitemstatus = 1" +
+		" WHERE 1 = 1"
+	sqlId.And("t.AREAUSERID", r.AREAUSERID)
+	sqlId.AndEx("t.ACCOUNTID", r.ACCOUNTID, r.ACCOUNTID > 0)
+	sqlId.AndEx("t.deliverygoodsid", r.DELIVERYGOODSID, r.DELIVERYGOODSID > 0)
+	sqlId.AndEx("t.WRSTANDARDID", r.WRSTANDARDID, r.WRSTANDARDID > 0)
+	sqlId.AndEx("t.SPOTGOODSBRANDID", r.SPOTGOODSBRANDID, r.SPOTGOODSBRANDID > 0)
+
+	if r.RECKONDATE != "" {
+		sqlId.And("t.RECKONDATE", r.RECKONDATE)
+	} else if r.BeginDate != "" && r.BeginDate == r.EndDate {
+		sqlId.And("t.RECKONDATE", r.BeginDate)
+	} else {
+		if r.BeginDate != "" {
+			sqlId.BiggerOrEq("t.RECKONDATE", r.BeginDate)
+		}
+		if r.EndDate != "" {
+			sqlId.LessOrEq("t.RECKONDATE", r.EndDate)
+		}
+	}
+	sqlId.Join(" order by t.RECKONDATE")
+
+	return sqlId.String()
+}
+
+// GetDataEx 获取现货日报表
+func (r *Ermcp3ReckonAreaSpotSub) GetDataEx() (interface{}, error) {
+	sData := make([]Ermcp3ReckonAreaSpotSub, 0)
+	err := db.GetEngine().SQL(r.buildSql()).Find(&sData)
+	for i := range sData {
+		sData[i].calc()
+	}
+	return sData, err
+}
+
+// Ermcp3ReportAreaSpotSub 现货分类月报表
+type Ermcp3ReportAreaSpotSub struct {
+	ORIBUYRECKONQTY       float64 `json:"oribuyreckonqty"  xorm:"'ORIBUYRECKONQTY'"`                            // 期初采购合同交收量【期初】
+	ORISELLRECKONQTY      float64 `json:"orisellreckonqty"  xorm:"'ORISELLRECKONQTY'"`                          // 期初销售合同交收量【期初】
+	ORIBUYCONTRACTINQTY   float64 `json:"oribuycontractinqty"  xorm:"'ORIBUYCONTRACTINQTY'"`                    // 期初采购合同入库量【期初】
+	ORISELLCONTRACTOUTQTY float64 `json:"orisellcontractoutqty"  xorm:"'ORISELLCONTRACTOUTQTY'"`                // 期初销售合同出库量【期初】
+	ORIPRODUCEINQTY       float64 `json:"oriproduceinqty"  xorm:"'ORIPRODUCEINQTY'"`                            // 期初生产入库量【期初】
+	ORIPRODUCEOUTQTY      float64 `json:"oriproduceoutqty"  xorm:"'ORIPRODUCEOUTQTY'"`                          // 期初生产出库量【期初】
+	BUYRECKONQTY          float64 `json:"buyreckonqty"  xorm:"'BUYRECKONQTY'"`                                  // 采购合同交收量【期末】
+	SELLRECKONQTY         float64 `json:"sellreckonqty"  xorm:"'SELLRECKONQTY'"`                                // 销售合同交收量【期末】
+	BUYCONTRACTINQTY      float64 `json:"buycontractinqty"  xorm:"'BUYCONTRACTINQTY'"`                          // 采购合同入库量【期末】
+	SELLCONTRACTOUTQTY    float64 `json:"sellcontractoutqty"  xorm:"'SELLCONTRACTOUTQTY'"`                      // 销售合同出库量【期末】
+	PRODUCEINQTY          float64 `json:"produceinqty"  xorm:"'PRODUCEINQTY'"`                                  // 生产入库量【期末】
+	PRODUCEOUTQTY         float64 `json:"produceoutqty"  xorm:"'PRODUCEOUTQTY'"`                                // 生产出库量【期末】
+	CYCLETIME             string  `json:"cycletime"  xorm:"'CYCLETIME'" form:"cycletime"`                       // 周期时间 月(YYYYMM)  季(YYYYQ) 年(YYYY) 周(YYYYIW) 全(0)【原值】
+	CYCLETYPE             int32   `json:"cycletype"  xorm:"'CYCLETYPE'" form:"cycletype"`                       // 周期类型 - 1:月 2:季 3:年 4:周 5:全报表【原值】
+	AREAUSERID            int64   `json:"areauserid"  xorm:"'AREAUSERID'" form:"areauserid" binding:"required"` // 账户所属机构
+	ACCOUNTID             int64   `json:"accountid"  xorm:"'ACCOUNTID'" form:"accountid"`                       // 期货账户ID
+	WRFACTORTYPEID        int64   `json:"wrfactortypeid"  xorm:"'WRFACTORTYPEID'"`                              // 仓单要素类型ID(212+Unix秒时间戳(10位)+xxxxxx)
+	DELIVERYGOODSID       int64   `json:"deliverygoodsid"  xorm:"'DELIVERYGOODSID'" form:"deliverygoodsid"`     // 现货品种ID
+	WRSTANDARDID          int64   `json:"wrstandardid"  xorm:"'WRSTANDARDID'" form:"wrstandardid"`              // 品类ID
+	SPOTGOODSBRANDID      int32   `json:"spotgoodsbrandid"  xorm:"'SPOTGOODSBRANDID'" form:"spotgoodsbrandid"`  // 现货品牌ID
+	ORIBUYPRICEDQTY       float64 `json:"oribuypricedqty"  xorm:"'ORIBUYPRICEDQTY'"`                            // 期初采购合同已定价数量【期初】
+	ORISELLPRICEDQTY      float64 `json:"orisellpricedqty"  xorm:"'ORISELLPRICEDQTY'"`                          // 期初销售合同已定价数量【期初】
+	BUYPRICEDQTY          float64 `json:"buypricedqty"  xorm:"'BUYPRICEDQTY'"`                                  // 采购合同已定价数量【期末】
+	SELLPRICEDQTY         float64 `json:"sellpricedqty"  xorm:"'SELLPRICEDQTY'"`                                // 销售合同已定价数量【期末】
+	TOTALSPOTQTY          float64 `json:"totalspotqty"  xorm:"'TOTALSPOTQTY'"`                                  // 现货头寸总量 =  采购合同已定价数量 - 销售合同已定价数量【期末】
+	UPDATETIME            string  `json:"updatetime"  xorm:"'UPDATETIME'"`                                      // 更新时间
+	TODAYBUYRECKONQTY     float64 `json:"todaybuyreckonqty"  xorm:"'TODAYBUYRECKONQTY'"`                        // 今日采购合同已确定数量【汇总】
+	TODAYSELLRECKONQTY    float64 `json:"todaysellreckonqty"  xorm:"'TODAYSELLRECKONQTY'"`                      // 今日销售合同已确定数量【汇总】
+	ORIBUYPRICEDAMOUNT    float64 `json:"oribuypricedamount"  xorm:"'ORIBUYPRICEDAMOUNT'"`                      // 期初采购合同已定价金额【期初】
+	ORISELLPRICEDAMOUNT   float64 `json:"orisellpricedamount"  xorm:"'ORISELLPRICEDAMOUNT'"`                    // 期初销售合同已定价金额【期初】
+	BUYPRICEDAMOUNT       float64 `json:"buypricedamount"  xorm:"'BUYPRICEDAMOUNT'"`                            // 采购合同已定价金额【期末】
+	SELLPRICEDAMOUNT      float64 `json:"sellpricedamount"  xorm:"'SELLPRICEDAMOUNT'"`                          // 销售合同已定价金额【期末】
+	ENUMDICNAME           string  `json:"enumdicname"  xorm:"'ENUMDICNAME'"`                                    // 现货商品单位名称
+	WRSTANDARDNAME        string  `json:"wrstandardname"  xorm:"'wrstandardname'"`                              // 品类名称
+	WRSTANDARDCODE        string  `json:"wrstandardcode"  xorm:"'wrstandardcode'"`                              // 品类代码
+	DELIVERYGOODSCODE     string  `json:"deliverygoodscode"  xorm:"'deliverygoodscode'"`                        // 现货商品代码
+	DELIVERYGOODSNAME     string  `json:"deliverygoodsname"  xorm:"'deliverygoodsname'"`                        // 现货商品名称
+	GOODSUNITID           int32   `json:"goodsunitid"  xorm:"'goodsunitid'"`                                    // 现货商品单位id
+	BRANDNAME             string  `json:"brandname"  xorm:"'brandname'"`                                        // 品牌名称
+	ACCOUNTNAME           string  `json:"accountname"  xorm:"'accountname'"`                                    // 所属机构名称
+
+	TOTALBUYPRICEDQTY  float64 `json:"totalbuypricedqty"`  // 采购定价量 = 期末 - 期初
+	TOTALSELLPRICEDQTY float64 `json:"totalsellpricedqty"` // 销售定价量 = 期末 - 期初
+}
+
+func (r *Ermcp3ReportAreaSpotSub) calc() {
+	r.TOTALBUYPRICEDQTY = r.BUYPRICEDQTY - r.ORIBUYPRICEDQTY
+	r.TOTALSELLPRICEDQTY = r.SELLPRICEDQTY - r.ORISELLPRICEDQTY
+}
+
+func (r *Ermcp3ReportAreaSpotSub) buildSql() string {
+	var sqlId utils.SQLVal = "SELECT t.ORIBUYRECKONQTY," +
+		"       t.ORISELLRECKONQTY," +
+		"       t.ORIBUYCONTRACTINQTY," +
+		"       t.ORISELLCONTRACTOUTQTY," +
+		"       t.ORIPRODUCEINQTY," +
+		"       t.ORIPRODUCEOUTQTY," +
+		"       t.BUYRECKONQTY," +
+		"       t.SELLRECKONQTY," +
+		"       t.BUYCONTRACTINQTY," +
+		"       t.SELLCONTRACTOUTQTY," +
+		"       t.PRODUCEINQTY," +
+		"       t.PRODUCEOUTQTY," +
+		"       t.CYCLETIME," +
+		"       t.CYCLETYPE," +
+		"       t.AREAUSERID," +
+		"       t.ACCOUNTID," +
+		"       t.WRFACTORTYPEID," +
+		"       t.DELIVERYGOODSID," +
+		"       t.WRSTANDARDID," +
+		"       t.SPOTGOODSBRANDID," +
+		"       t.ORIBUYPRICEDQTY," +
+		"       t.ORISELLPRICEDQTY," +
+		"       t.BUYPRICEDQTY," +
+		"       t.SELLPRICEDQTY," +
+		"       t.TOTALSPOTQTY," +
+		"       to_char(t.UPDATETIME, 'yyyy-mm-dd hh24:mi:ss') UPDATETIME," +
+		"       t.TODAYBUYRECKONQTY," +
+		"       t.TODAYSELLRECKONQTY," +
+		"       t.ORIBUYPRICEDAMOUNT," +
+		"       t.ORISELLPRICEDAMOUNT," +
+		"       t.BUYPRICEDAMOUNT," +
+		"       t.SELLPRICEDAMOUNT," +
+		"       w.wrstandardname," +
+		"       w.wrstandardcode," +
+		"       g.deliverygoodscode," +
+		"       g.deliverygoodsname," +
+		"       g.goodsunitid," +
+		"       d.dgfactoryitemvalue brandname," +
+		"       u.accountname," +
+		"       e.enumdicname" +
+		"  FROM REPORT_ERMCP_AREASPOTSUB t" +
+		"  LEFT JOIN WRSTANDARD w on t.wrstandardid=w.wrstandardid" +
+		"  LEFT JOIN DELIVERYGOODS g on t.deliverygoodsid=g.deliverygoodsid" +
+		"  LEFT JOIN DGFACTORYITEM d on t.spotgoodsbrandid=d.dgfactoryitemid" +
+		"  LEFT JOIN USERACCOUNT u on t.areauserid=u.userid" +
+		"  LEFT JOIN ENUMDICITEM e on g.goodsunitid=e.enumitemname and e.enumdiccode='goodsunit' and e.enumitemstatus=1" +
+		" WHERE 1 = 1"
+	sqlId.And("t.AREAUSERID", r.AREAUSERID)
+	sqlId.And("t.cycletype", r.CYCLETYPE)
+	sqlId.And("t.cycletime", r.CYCLETIME)
+	sqlId.AndEx("t.ACCOUNTID", r.ACCOUNTID, r.ACCOUNTID > 0)
+	sqlId.AndEx("t.deliverygoodsid", r.DELIVERYGOODSID, r.DELIVERYGOODSID > 0)
+	sqlId.AndEx("t.WRSTANDARDID", r.WRSTANDARDID, r.WRSTANDARDID > 0)
+	sqlId.AndEx("t.SPOTGOODSBRANDID", r.SPOTGOODSBRANDID, r.SPOTGOODSBRANDID > 0)
+	return sqlId.String()
+}
+
+// GetDataEx 获取现货分类报表
+func (r *Ermcp3ReportAreaSpotSub) GetDataEx() (interface{}, error) {
+	sData := make([]Ermcp3ReportAreaSpotSub, 0)
+	err := db.GetEngine().SQL(r.buildSql()).Find(&sData)
+	for i := range sData {
+		sData[i].calc()
+	}
+	return sData, err
+}

+ 5 - 1
utils/sqlUtils.go

@@ -24,7 +24,11 @@ func (r *SQLVal) FormatParam(a ...interface{}) {
 
 // And 增加and 条件
 func (r *SQLVal) And(fieldName string, val interface{}) {
-	*r = *r + SQLVal(fmt.Sprintf(" and %v = %v", fieldName, val))
+	if _, ok := val.(string); ok {
+		*r = *r + SQLVal(fmt.Sprintf(" and %v = '%v'", fieldName, val))
+	} else {
+		*r = *r + SQLVal(fmt.Sprintf(" and %v = %v", fieldName, val))
+	}
 }
 
 // And 增加and 条件, bAdd参数省了在外层写if语句