You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
56 lines
1.6 KiB
Go
56 lines
1.6 KiB
Go
package service
|
|
|
|
import (
|
|
"cu-helper/high-opt-loss/model"
|
|
"github.com/go-resty/resty/v2"
|
|
"github.com/mizuki1412/go-core-kit/class/exception"
|
|
"github.com/tidwall/gjson"
|
|
"time"
|
|
)
|
|
|
|
//获取光衰数据列表
|
|
|
|
type HighOptLoss struct {
|
|
Count int
|
|
CountFlag int //1绿色,2黄色,3红色
|
|
DurationOverSeven int
|
|
DurationOverSevenFlag int //1绿色,2黄色,3红色
|
|
DurationOverFifteen int
|
|
DurationOverFifteenFlag int //1绿色,2黄色,3红色
|
|
Book int
|
|
BookFlag int //1绿色,2黄色,3红色
|
|
}
|
|
|
|
func ReqGetHighOptLossList(receiveFlag string) map[string]*HighOptLoss {
|
|
h := model.NewHeader()
|
|
header := h.GenReqParam()
|
|
f := model.NewGetHighOptLossList(receiveFlag)
|
|
form := f.GenReqParam()
|
|
client := resty.New().SetRetryCount(5).SetRetryWaitTime(10 * time.Second)
|
|
resp, err := client.R().
|
|
SetHeaders(header).SetFormData(form).Post("http://132.151.160.87:10010/wms-zj/gShuaiReply/gshuaiOrderReplyListAjax.do")
|
|
if err != nil {
|
|
panic(exception.New(err.Error()))
|
|
}
|
|
//handle光衰数据
|
|
data := gjson.Get(resp.String(), "list").Array()
|
|
m := make(map[string]*HighOptLoss)
|
|
for _, v := range data {
|
|
if m[v.Get("DEAL_MAN").String()] == nil {
|
|
m[v.Get("DEAL_MAN").String()] = &HighOptLoss{}
|
|
}
|
|
m[v.Get("DEAL_MAN").String()].Count++
|
|
duration := v.Get("TIMELONGS").Int()
|
|
if duration >= 604800 {
|
|
m[v.Get("DEAL_MAN").String()].DurationOverSeven++
|
|
}
|
|
if duration >= 1296000 {
|
|
m[v.Get("DEAL_MAN").String()].DurationOverFifteen++
|
|
}
|
|
if v.Get("BOOK_TIME").String() != "" {
|
|
m[v.Get("DEAL_MAN").String()].Book++
|
|
}
|
|
}
|
|
return m
|
|
}
|