From e0e6a1c8470d620086b340c8d4b620462ee77af6 Mon Sep 17 00:00:00 2001 From: huangjiajun <582604932@qq.com> Date: Thu, 4 Jul 2024 18:55:58 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/bigData/hdl/hdl_making_data.go | 6 ++-- app/bigData/svc/svc_data.go | 52 +++++++++++++++++++++++------- app/router/big_data_router.go | 4 +-- 3 files changed, 45 insertions(+), 17 deletions(-) diff --git a/app/bigData/hdl/hdl_making_data.go b/app/bigData/hdl/hdl_making_data.go index 241089c..0fee2f1 100644 --- a/app/bigData/hdl/hdl_making_data.go +++ b/app/bigData/hdl/hdl_making_data.go @@ -34,14 +34,14 @@ func SortingData(c *gin.Context) { return } func NewSortingCate(c *gin.Context) { - result := svc.NewSortingCate() + result := svc.NewSortingCate(c) e.OutSuc(c, result, nil) return } func NewSortingGoodsCate(c *gin.Context) { - result := svc.NewSortingGoodsCate() + result := svc.NewSortingGoodsCate(c) e.OutSuc(c, result, nil) return @@ -52,7 +52,7 @@ func NewSortingGoodsData(c *gin.Context) { e.OutErr(c, e.ERR_INVALID_ARGS, err) return } - result := svc.NewSortingGoodsData(arg) + result := svc.NewSortingGoodsData(c, arg) e.OutSuc(c, result, nil) return diff --git a/app/bigData/svc/svc_data.go b/app/bigData/svc/svc_data.go index 5d85f41..995505c 100644 --- a/app/bigData/svc/svc_data.go +++ b/app/bigData/svc/svc_data.go @@ -408,23 +408,35 @@ func RightDataForSorting(req md.RightDataForMakeReq) (resp []md.RightDataForMake return } -func NewSortingCate() []map[string]string { +func NewSortingCate(c *gin.Context) []map[string]string { engine := db.Db res := make([]map[string]string, 0) + var args = make(map[string]string) + c.ShouldBindJSON(&args) var enterprise []model.Enterprise - err := engine.Where("1=1").Find(&enterprise) + sess := engine.Where("1=1") + if args["name"] != "" { + sess.And("name like ? or inside_name like ?", "%"+args["name"]+"%", "%"+args["name"]+"%") + } + err := sess.Find(&enterprise) if err != nil { return res } var enterpriseMap = map[int]model.Enterprise{} + enterpriseId := []int{-1} for _, v := range enterprise { enterpriseMap[v.Id] = v + enterpriseId = append(enterpriseId, v.Id) } //1、查找不等于4 5 now := CommDate() var orders []model.Order - err = engine.Where(" state != 4 and state != 5 and make_date=?", now).Find(&orders) + sess1 := engine.Where(" state != 4 and state != 5 and make_date=?", now) + if args["name"] != "" { + sess1.In("enterprise_id", enterpriseId) + } + err = sess1.Find(&orders) if err != nil { return res } @@ -477,8 +489,12 @@ func NewSortingData(c *gin.Context) []map[string]string { } oIds = append(oIds, utils.Int64ToStr(v.Oid)) } - sql := `SELECT SUM(num) as num,SUM(success_num) as success_num,goods_title,sku FROM order_goods WHERE oid in (%s) and make_date=%s and goods_type=0 GROUP BY enterprise_id,goods_id,sku_id` - sql = fmt.Sprintf(sql, strings.Join(oIds, ","), now) + sql := `SELECT SUM(num) as num,SUM(success_num) as success_num,goods_title,sku FROM order_goods WHERE %s oid in (%s) and make_date=%s and goods_type=0 GROUP BY enterprise_id,goods_id,sku_id` + str := "" + if args["name"] != "" { + str = " goods_title like %" + args["name"] + "% and " + } + sql = fmt.Sprintf(sql, str, strings.Join(oIds, ","), now) nativeString, err := db.QueryNativeString(engine, sql) for _, v := range nativeString { skuData := make([]md2.Sku, 0) @@ -506,13 +522,16 @@ func NewSortingData(c *gin.Context) []map[string]string { } return res } -func NewSortingGoodsCate() []map[string]string { +func NewSortingGoodsCate(c *gin.Context) []map[string]string { res := make([]map[string]string, 0) engine := db.Db //1、查找不等于4 5 now := CommDate() var orders []model.Order + var args = make(map[string]string) + c.ShouldBindJSON(&args) + err := engine.Where(" state != 4 and state != 5 and make_date=? ", now).Find(&orders) if err != nil { return res @@ -525,8 +544,12 @@ func NewSortingGoodsCate() []map[string]string { } oIds = append(oIds, utils.Int64ToStr(v.Oid)) } - sql := `SELECT SUM(num) as num,SUM(success_num) as success_num,goods_title,sku,goods_id,sku_id FROM order_goods WHERE oid in (%s) and goods_type=0 and make_date=%s GROUP BY goods_id,sku_id` - sql = fmt.Sprintf(sql, strings.Join(oIds, ","), now) + sql := `SELECT SUM(num) as num,SUM(success_num) as success_num,goods_title,sku,goods_id,sku_id FROM order_goods WHERE %s oid in (%s) and goods_type=0 and make_date=%s GROUP BY goods_id,sku_id` + str := "" + if args["name"] != "" { + str = " goods_title like %" + args["name"] + "% and " + } + sql = fmt.Sprintf(sql, str, strings.Join(oIds, ","), now) nativeString, err := db.QueryNativeString(engine, sql) for _, v := range nativeString { skuData := make([]md2.Sku, 0) @@ -556,7 +579,7 @@ func NewSortingGoodsCate() []map[string]string { } return res } -func NewSortingGoodsData(arg map[string]string) []map[string]string { +func NewSortingGoodsData(c *gin.Context, arg map[string]string) []map[string]string { engine := db.Db res := make([]map[string]string, 0) @@ -571,7 +594,8 @@ func NewSortingGoodsData(arg map[string]string) []map[string]string { } //1、查找不等于4 5 now := CommDate() - + var args = make(map[string]string) + c.ShouldBindJSON(&args) var orders []model.Order err = engine.Where(" state != 4 and state != 5 and make_date=? ", now).Find(&orders) if err != nil { @@ -585,8 +609,12 @@ func NewSortingGoodsData(arg map[string]string) []map[string]string { } oIds = append(oIds, utils.Int64ToStr(v.Oid)) } - sql := `SELECT SUM(num) as num,SUM(success_num) as success_num,goods_title,sku,goods_id,sku_id,enterprise_id FROM order_goods WHERE oid in (%s) and goods_id=%s and goods_type=0 and sku_id=%s and make_date=%s GROUP BY enterprise_id ORDER BY id asc` - sql = fmt.Sprintf(sql, strings.Join(oIds, ","), arg["goods_id"], arg["sku_id"], now) + sql := `SELECT SUM(num) as num,SUM(success_num) as success_num,goods_title,sku,goods_id,sku_id,enterprise_id FROM order_goods WHERE %s oid in (%s) and goods_id=%s and goods_type=0 and sku_id=%s and make_date=%s GROUP BY enterprise_id ORDER BY id asc` + str := "" + if args["name"] != "" { + str = " goods_title like %" + args["name"] + "% and " + } + sql = fmt.Sprintf(sql, str, strings.Join(oIds, ","), arg["goods_id"], arg["sku_id"], now) nativeString, err := db.QueryNativeString(engine, sql) for _, v := range nativeString { skuData := make([]md2.Sku, 0) diff --git a/app/router/big_data_router.go b/app/router/big_data_router.go index 1f11d54..73f5ea5 100644 --- a/app/router/big_data_router.go +++ b/app/router/big_data_router.go @@ -25,10 +25,10 @@ func rData(r *gin.RouterGroup) { r.GET("/new_order_notice", hdl.NewOrderNotice) //新订单提醒 r.GET("/new_order_info_notice", hdl.NewOrderInfoNotice) //新订单提醒 - r.GET("/new_sorting_cate", hdl.NewSortingCate) //分拣区学校分类 + r.Any("/new_sorting_cate", hdl.NewSortingCate) //分拣区学校分类 r.POST("/new_sorting_data", hdl.NewSortingData) //分拣区数据 - r.GET("/new_sorting_goods_cate", hdl.NewSortingGoodsCate) //分拣区 按商品 + r.Any("/new_sorting_goods_cate", hdl.NewSortingGoodsCate) //分拣区 按商品 r.POST("/new_sorting_goods_data", hdl.NewSortingGoodsData) //分拣区 按商品 数据 r.GET("/notice", hdl.Notice) }