소스 검색

更新

master
huangjiajun 6 달 전
부모
커밋
df93173238
4개의 변경된 파일135개의 추가작업 그리고 2개의 파일을 삭제
  1. +18
    -0
      app/bigData/hdl/hdl_making_data.go
  2. +113
    -0
      app/bigData/svc/svc_data.go
  3. +1
    -2
      app/e/msg.go
  4. +3
    -0
      app/router/big_data_router.go

+ 18
- 0
app/bigData/hdl/hdl_making_data.go 파일 보기

@@ -39,6 +39,24 @@ func NewSortingCate(c *gin.Context) {
e.OutSuc(c, result, nil)
return
}
func NewSortingGoodsCate(c *gin.Context) {

result := svc.NewSortingGoodsCate()

e.OutSuc(c, result, nil)
return
}
func NewSortingGoodsData(c *gin.Context) {
var arg map[string]string
if err := c.ShouldBindJSON(&arg); err != nil {
e.OutErr(c, e.ERR_INVALID_ARGS, err)
return
}
result := svc.NewSortingGoodsData(arg)

e.OutSuc(c, result, nil)
return
}
func NewSortingData(c *gin.Context) {
result := svc.NewSortingData(c)



+ 113
- 0
app/bigData/svc/svc_data.go 파일 보기

@@ -513,3 +513,116 @@ func NewSortingData(c *gin.Context) []map[string]string {
}
return res
}
func NewSortingGoodsCate() []map[string]string {
res := make([]map[string]string, 0)

engine := db.Db
//1、查找不等于4 5
today := utils.GetTimeRange("today")
if time.Now().Hour() < 2 {
today = utils.GetTimeRange("yesterday")
}
var orders []model.Order
err := engine.Where(" state != 4 and state != 5 and create_at>=? ", time.Unix(today["start"], 0).Format("2006-01-02 15:04:05")).Find(&orders)
if err != nil {
return res
}
var oIds []string
for _, v := range orders {
v1 := order.JudgePackageOrdOrdState(&v)
if v1.State == 4 || v1.State == 5 {
continue
}
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) GROUP BY goods_id,sku_id`
sql = fmt.Sprintf(sql, strings.Join(oIds, ","))
nativeString, err := db.QueryNativeString(engine, sql)
for _, v := range nativeString {
skuData := make([]md2.Sku, 0)
json.Unmarshal([]byte(v["sku"]), &skuData)
skuStr := ""
for _, v1 := range skuData {
if skuStr != "" {
skuStr += ";"
}
skuStr += v1.Value
}
tmp := map[string]string{
"goods_id": v["goods_id"],
"sku_id": v["sku_id"],
"goods_name": v["goods_title"],
"sku": skuStr,
"num": v["num"],
"success_num": v["success_num"],
"state": "1",
"state_str": "待分拣",
}
if utils.StrToInt(v["num"]) <= utils.StrToInt(v["success_num"]) {
tmp["state"] = "4"
tmp["stare_str"] = "分拣完成"
}
res = append(res, tmp)
}
return res
}
func NewSortingGoodsData(arg map[string]string) []map[string]string {

engine := db.Db
res := make([]map[string]string, 0)
var enterprise []model.Enterprise
err := engine.Where("1=1").Find(&enterprise)
if err != nil {
return res
}
var enterpriseMap = map[int]model.Enterprise{}
for _, v := range enterprise {
enterpriseMap[v.Id] = v
}
//1、查找不等于4 5
today := utils.GetTimeRange("today")
if time.Now().Hour() < 2 {
today = utils.GetTimeRange("yesterday")
}
var orders []model.Order
err = engine.Where(" state != 4 and state != 5 and create_at>=? ", time.Unix(today["start"], 0).Format("2006-01-02 15:04:05")).Find(&orders)
if err != nil {
return res
}
var oIds []string
for _, v := range orders {
v1 := order.JudgePackageOrdOrdState(&v)
if v1.State == 4 || v1.State == 5 {
continue
}
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 sku_id=%s GROUP BY enterprise_id`
sql = fmt.Sprintf(sql, strings.Join(oIds, ","), arg["goods_id"], arg["sku_id"])
nativeString, err := db.QueryNativeString(engine, sql)
for _, v := range nativeString {
skuData := make([]md2.Sku, 0)
json.Unmarshal([]byte(v["sku"]), &skuData)
skuStr := ""
for _, v1 := range skuData {
if skuStr != "" {
skuStr += ";"
}
skuStr += v1.Value
}
tmp := map[string]string{
"enterprise_name": enterpriseMap[utils.StrToInt(v["enterprise_id"])].Name,
"num": v["num"],
"success_num": v["success_num"],
"state": "1",
"state_str": "待分拣",
}
if utils.StrToInt(v["num"]) <= utils.StrToInt(v["success_num"]) {
tmp["state"] = "4"
tmp["stare_str"] = "分拣完成"
}
res = append(res, tmp)
}
return res

}

+ 1
- 2
app/e/msg.go 파일 보기

@@ -3,9 +3,8 @@ package e
import (
"applet/app/utils"
"encoding/json"
"net/http"

"github.com/gin-gonic/gin"
"net/http"

"applet/app/utils/logx"
)


+ 3
- 0
app/router/big_data_router.go 파일 보기

@@ -28,4 +28,7 @@ func rData(r *gin.RouterGroup) {
r.GET("/new_sorting_cate", hdl.NewSortingCate) //分拣区学校分类
r.POST("/new_sorting_data", hdl.NewSortingData) //分拣区数据

r.GET("/new_sorting_goods_cate", hdl.NewSortingGoodsCate) //分拣区 按商品
r.POST("/new_sorting_goods_data", hdl.NewSortingGoodsData) //分拣区 按商品 数据

}

불러오는 중...
취소
저장