update: high_opt_loss

main
Leo 9 months ago
parent cdf58c7b6b
commit 6ca8673921

@ -18,12 +18,10 @@ var highOpticalLossCmd = &cobra.Command{
Short: "Generate a High Optical Loss Report",
Run: func(cmd *cobra.Command, args []string) {
initkit.BindFlags(cmd)
m1 := service.ReqGetHighOptLossList("2")
logkit.Info("拿到大光衰数据,开始生成...")
m2 := service.ReqGetHighOptLossSmallList("2")
logkit.Info("拿到小光衰数据,开始生成...")
common.GenExcelFile(m1)
common.GenExcelFileSmall(m2)
m1 := service.ReqGetHighOptLossUnderList()
m2 := service.ReqGetHighOptLossHistoryList()
logkit.Info("拿到光衰数据,开始生成...")
common.GenExcelFile(m1, m2)
},
}

@ -3,19 +3,125 @@ package common
import (
"cu-helper/high-opt-loss/service"
"fmt"
"github.com/mizuki1412/go-core-kit/library/mathkit"
"github.com/mizuki1412/go-core-kit/service/logkit"
"github.com/spf13/cast"
"github.com/xuri/excelize/v2"
"strconv"
"time"
)
func GenExcelFile(m map[string]*service.HighOptLoss) {
func GenExcelFile(m1 map[string]*service.HighOptLossUnder, m2 map[string]*service.HighOptLossHistory) {
// Open the Excel file
f, err := excelize.OpenFile("/Users/leo/Documents/光衰通报/大光衰/2025/大光衰通报(3月3日).xlsx")
f, err := excelize.OpenFile("/Users/leo/Documents/光衰通报/光衰/2025/光衰通报(3月14日).xlsx")
if err != nil {
fmt.Println(err)
return
}
styleRed, err := f.NewStyle(&excelize.Style{
Alignment: &excelize.Alignment{
Horizontal: "center",
Vertical: "center",
},
Border: []excelize.Border{
{Type: "top", Style: 1, Color: "000000"},
{Type: "bottom", Style: 1, Color: "000000"},
{Type: "left", Style: 1, Color: "000000"},
{Type: "right", Style: 1, Color: "000000"},
},
Fill: excelize.Fill{
Type: "pattern",
Color: []string{"C00000"}, // RGB(192,0,0)
Pattern: 1,
},
Font: &excelize.Font{
Color: "FFFFFF", // 白色
Bold: true,
},
})
styleRedFMT, err := f.NewStyle(&excelize.Style{
Alignment: &excelize.Alignment{
Horizontal: "center",
Vertical: "center",
},
Border: []excelize.Border{
{Type: "top", Style: 1, Color: "000000"},
{Type: "bottom", Style: 1, Color: "000000"},
{Type: "left", Style: 1, Color: "000000"},
{Type: "right", Style: 1, Color: "000000"},
},
Fill: excelize.Fill{
Type: "pattern",
Color: []string{"C00000"}, // RGB(192,0,0)
Pattern: 1,
},
Font: &excelize.Font{
Color: "FFFFFF", // 白色
Bold: true,
},
NumFmt: 10, // 或使用自定义格式代码:"0.00%"
})
styleYellow, err := f.NewStyle(&excelize.Style{
Alignment: &excelize.Alignment{
Horizontal: "center",
Vertical: "center",
},
Border: []excelize.Border{
{Type: "top", Style: 1, Color: "000000"},
{Type: "bottom", Style: 1, Color: "000000"},
{Type: "left", Style: 1, Color: "000000"},
{Type: "right", Style: 1, Color: "000000"},
},
Fill: excelize.Fill{
Type: "pattern",
Color: []string{"FFC000"}, // RGB(255,192,0)
Pattern: 1,
},
Font: &excelize.Font{
Bold: true,
},
})
styleGreen, err := f.NewStyle(&excelize.Style{
Alignment: &excelize.Alignment{
Horizontal: "center",
Vertical: "center",
},
Border: []excelize.Border{
{Type: "top", Style: 1, Color: "000000"},
{Type: "bottom", Style: 1, Color: "000000"},
{Type: "left", Style: 1, Color: "000000"},
{Type: "right", Style: 1, Color: "000000"},
},
Fill: excelize.Fill{
Type: "pattern",
Color: []string{"92D050"}, // RGB(146,208,80)
Pattern: 1,
},
Font: &excelize.Font{
Bold: true,
},
})
styleGreenFMT, err := f.NewStyle(&excelize.Style{
Alignment: &excelize.Alignment{
Horizontal: "center",
Vertical: "center",
},
Border: []excelize.Border{
{Type: "top", Style: 1, Color: "000000"},
{Type: "bottom", Style: 1, Color: "000000"},
{Type: "left", Style: 1, Color: "000000"},
{Type: "right", Style: 1, Color: "000000"},
},
Fill: excelize.Fill{
Type: "pattern",
Color: []string{"92D050"}, // RGB(146,208,80)
Pattern: 1,
},
Font: &excelize.Font{
Bold: true,
},
NumFmt: 10, // 或使用自定义格式代码:"0.00%"
})
// Cut and paste data from E4:E22 to C4:C22
for i := 4; i <= 22; i++ {
@ -26,90 +132,101 @@ func GenExcelFile(m map[string]*service.HighOptLoss) {
f.SetCellValue("汇总", eCell, "")
}
// Populate E4:H22 with data from the map
// Populate E4:L22 with data from the map
for i := 4; i <= 22; i++ {
bCell := "B" + strconv.Itoa(i)
key, _ := f.GetCellValue("汇总", bCell)
if data, ok := m[key]; ok {
f.SetCellValue("汇总", "E"+strconv.Itoa(i), data.Count)
if data, ok := m1[key]; ok {
f.SetCellValue("汇总", "E"+strconv.Itoa(i), data.UnderCount)
if data.UnderCount == 0 {
f.SetCellStyle("汇总", "E"+strconv.Itoa(i), "E"+strconv.Itoa(i), styleGreen)
}
if data.UnderCount > 0 && data.UnderCount <= 5 {
f.SetCellStyle("汇总", "E"+strconv.Itoa(i), "E"+strconv.Itoa(i), styleYellow)
}
if data.UnderCount > 5 {
f.SetCellStyle("汇总", "E"+strconv.Itoa(i), "E"+strconv.Itoa(i), styleRed)
}
f.SetCellValue("汇总", "F"+strconv.Itoa(i), data.DurationOverSeven)
if data.DurationOverSeven == 0 {
f.SetCellStyle("汇总", "F"+strconv.Itoa(i), "F"+strconv.Itoa(i), styleGreen)
}
if data.DurationOverSeven > 0 && data.DurationOverSeven <= 5 {
f.SetCellStyle("汇总", "F"+strconv.Itoa(i), "F"+strconv.Itoa(i), styleYellow)
}
if data.DurationOverSeven > 5 {
f.SetCellStyle("汇总", "F"+strconv.Itoa(i), "F"+strconv.Itoa(i), styleRed)
}
f.SetCellValue("汇总", "G"+strconv.Itoa(i), data.DurationOverFifteen)
if data.DurationOverFifteen == 0 {
f.SetCellStyle("汇总", "G"+strconv.Itoa(i), "G"+strconv.Itoa(i), styleGreen)
}
if data.DurationOverFifteen > 0 && data.DurationOverFifteen <= 5 {
f.SetCellStyle("汇总", "G"+strconv.Itoa(i), "G"+strconv.Itoa(i), styleYellow)
}
if data.DurationOverFifteen > 5 {
f.SetCellStyle("汇总", "G"+strconv.Itoa(i), "G"+strconv.Itoa(i), styleRed)
}
f.SetCellValue("汇总", "H"+strconv.Itoa(i), data.Book)
if data.Book == 0 {
f.SetCellStyle("汇总", "H"+strconv.Itoa(i), "H"+strconv.Itoa(i), styleRed)
}
if data.Book > 0 {
f.SetCellStyle("汇总", "H"+strconv.Itoa(i), "H"+strconv.Itoa(i), styleGreen)
}
if data.Book == 0 && data.UnderCount == 0 {
f.SetCellStyle("汇总", "H"+strconv.Itoa(i), "H"+strconv.Itoa(i), styleGreen)
}
f.SetCellValue("汇总", "I"+strconv.Itoa(i), data.ApplyCount)
} else {
f.SetCellValue("汇总", "E"+strconv.Itoa(i), 0)
f.SetCellStyle("汇总", "E"+strconv.Itoa(i), "E"+strconv.Itoa(i), styleGreen)
f.SetCellValue("汇总", "F"+strconv.Itoa(i), 0)
f.SetCellStyle("汇总", "F"+strconv.Itoa(i), "F"+strconv.Itoa(i), styleGreen)
f.SetCellValue("汇总", "G"+strconv.Itoa(i), 0)
f.SetCellStyle("汇总", "G"+strconv.Itoa(i), "G"+strconv.Itoa(i), styleGreen)
f.SetCellValue("汇总", "H"+strconv.Itoa(i), 0)
f.SetCellStyle("汇总", "H"+strconv.Itoa(i), "H"+strconv.Itoa(i), styleGreen)
f.SetCellValue("汇总", "I"+strconv.Itoa(i), 0)
}
}
// Calculate D4:D22 as C-E
for i := 4; i <= 22; i++ {
cCell := "C" + strconv.Itoa(i)
eCell := "E" + strconv.Itoa(i)
dCell := "D" + strconv.Itoa(i)
cValue, _ := f.GetCellValue("汇总", cCell)
eValue, _ := f.GetCellValue("汇总", eCell)
cInt, _ := strconv.Atoi(cValue)
eInt, _ := strconv.Atoi(eValue)
f.SetCellValue("汇总", dCell, cInt-eInt)
}
// Sum columns C:H and place the results in row 23
for col := 'C'; col <= 'H'; col++ {
sumCell := string(col) + "23"
sumFormula := fmt.Sprintf("SUM(%s4:%s22)", string(col), string(col))
f.SetCellFormula("汇总", sumCell, sumFormula)
}
// Recalculate the sum for each cell to ensure it appears without manual intervention
for col := 'C'; col <= 'H'; col++ {
sumCell := string(col) + "23"
value, err := f.CalcCellValue("汇总", sumCell)
if err != nil {
fmt.Println(err)
} else {
f.SetCellValue("汇总", sumCell, cast.ToInt(value))
}
}
// Save the file
if err := f.SaveAs("/Users/leo/Documents/光衰通报/大光衰/2025/大光衰通报(3月14日).xlsx"); err != nil {
fmt.Println(err)
}
logkit.Info("生成结束...")
}
func GenExcelFileSmall(m map[string]*service.HighOptLoss) {
// Open the Excel file
f, err := excelize.OpenFile("/Users/leo/Documents/光衰通报/小光衰/2025/光衰质差通报(3月3日).xlsx")
if err != nil {
fmt.Println(err)
return
}
// Cut and paste data from E4:E22 to C4:C22
for i := 4; i <= 22; i++ {
eCell := "E" + strconv.Itoa(i)
cCell := "C" + strconv.Itoa(i)
value, _ := f.GetCellValue("汇总", eCell)
f.SetCellValue("汇总", cCell, cast.ToInt(value))
f.SetCellValue("汇总", eCell, "")
}
// Populate E4:H22 with data from the map
for i := 4; i <= 22; i++ {
bCell := "B" + strconv.Itoa(i)
key, _ := f.GetCellValue("汇总", bCell)
if data, ok := m[key]; ok {
f.SetCellValue("汇总", "E"+strconv.Itoa(i), data.Count)
f.SetCellValue("汇总", "F"+strconv.Itoa(i), data.DurationOverSeven)
f.SetCellValue("汇总", "G"+strconv.Itoa(i), data.DurationOverFifteen)
f.SetCellValue("汇总", "H"+strconv.Itoa(i), data.Book)
if data, ok := m2[key]; ok {
f.SetCellValue("汇总", "J"+strconv.Itoa(i), data.Count)
if data1, ok1 := m1[key]; ok1 {
//有归档+有在途
f.SetCellValue("汇总", "K"+strconv.Itoa(i), data.Count+data1.Count)
v := mathkit.FloatRound(float64(data.Count)/(float64(data.Count)+float64(data1.Count)), 4)
f.SetCellValue("汇总", "L"+strconv.Itoa(i), v)
if v < 0.8 {
f.SetCellStyle("汇总", "L"+strconv.Itoa(i), "L"+strconv.Itoa(i), styleRedFMT)
}
if v >= 0.8 {
f.SetCellStyle("汇总", "L"+strconv.Itoa(i), "L"+strconv.Itoa(i), styleGreenFMT)
}
} else {
//有归档+无在途
f.SetCellValue("汇总", "K"+strconv.Itoa(i), data.Count)
v := mathkit.FloatRound(float64(data.Count)/(float64(data.Count)), 4)
f.SetCellValue("汇总", "L"+strconv.Itoa(i), v)
if v < 0.8 {
f.SetCellStyle("汇总", "L"+strconv.Itoa(i), "L"+strconv.Itoa(i), styleRedFMT)
}
if v >= 0.8 {
f.SetCellStyle("汇总", "L"+strconv.Itoa(i), "L"+strconv.Itoa(i), styleGreenFMT)
}
}
} else {
f.SetCellValue("汇总", "E"+strconv.Itoa(i), 0)
f.SetCellValue("汇总", "F"+strconv.Itoa(i), 0)
f.SetCellValue("汇总", "G"+strconv.Itoa(i), 0)
f.SetCellValue("汇总", "H"+strconv.Itoa(i), 0)
f.SetCellValue("汇总", "J"+strconv.Itoa(i), 0)
if data1, ok1 := m1[key]; ok1 {
//无归档+有在途
f.SetCellValue("汇总", "K"+strconv.Itoa(i), data1.Count)
f.SetCellValue("汇总", "L"+strconv.Itoa(i), 0)
f.SetCellStyle("汇总", "L"+strconv.Itoa(i), "L"+strconv.Itoa(i), styleRedFMT)
} else {
//无归档+无在途
f.SetCellValue("汇总", "K"+strconv.Itoa(i), 0)
f.SetCellValue("汇总", "L"+strconv.Itoa(i), 1)
f.SetCellStyle("汇总", "L"+strconv.Itoa(i), "L"+strconv.Itoa(i), styleGreenFMT)
}
}
}
@ -123,16 +240,31 @@ func GenExcelFileSmall(m map[string]*service.HighOptLoss) {
cInt, _ := strconv.Atoi(cValue)
eInt, _ := strconv.Atoi(eValue)
f.SetCellValue("汇总", dCell, cInt-eInt)
if cInt-eInt == 0 {
//本周压降为0但是当前遗留量为0
if eInt == 0 {
f.SetCellStyle("汇总", dCell, dCell, styleGreen)
} else {
//当前有遗留但是没压降量
f.SetCellStyle("汇总", dCell, dCell, styleYellow)
}
}
if cInt-eInt < 0 {
f.SetCellStyle("汇总", dCell, dCell, styleRed)
}
if cInt-eInt > 0 {
f.SetCellStyle("汇总", dCell, dCell, styleGreen)
}
}
// Sum columns C:H and place the results in row 23
for col := 'C'; col <= 'H'; col++ {
for col := 'C'; col <= 'K'; col++ {
sumCell := string(col) + "23"
sumFormula := fmt.Sprintf("SUM(%s4:%s22)", string(col), string(col))
f.SetCellFormula("汇总", sumCell, sumFormula)
}
// Recalculate the sum for each cell to ensure it appears without manual intervention
for col := 'C'; col <= 'H'; col++ {
for col := 'C'; col <= 'K'; col++ {
sumCell := string(col) + "23"
value, err := f.CalcCellValue("汇总", sumCell)
if err != nil {
@ -141,9 +273,16 @@ func GenExcelFileSmall(m map[string]*service.HighOptLoss) {
f.SetCellValue("汇总", sumCell, cast.ToInt(value))
}
}
done, _ := f.GetCellValue("汇总", "J23")
total, _ := f.GetCellValue("汇总", "K23")
f.SetCellValue("汇总", "L23", mathkit.FloatRound(cast.ToFloat64(done)/cast.ToFloat64(total), 4))
//设置表头
content := fmt.Sprintf("西湖智家光衰通报:%s", time.Now().Format("1月2日"))
f.SetCellValue("汇总", "A1", content)
// Save the file
if err := f.SaveAs("/Users/leo/Documents/光衰通报/小光衰/2025/光衰质差通报(3月14日).xlsx"); err != nil {
if err := f.SaveAs("/Users/leo/Documents/光衰通报/光衰/2025/光衰通报(" + time.Now().Format("1月2日") + ").xlsx"); err != nil {
fmt.Println(err)
}
logkit.Info("生成结束...")

@ -0,0 +1,61 @@
package model
import (
"reflect"
"time"
)
/*
http://132.151.160.87:10010/wms-zj/gshuaiOrderQueryW/getOrderInfo.do
*/
/*
*/
type GetHighOptLossHistoryList struct {
Page string `map:"page"`
Rows string `map:"rows"`
OrgId string `map:"orgId"`
BusiType string `map:"busiType"`
QueryFlag string `map:"queryFlag"`
StartTime string `map:"startTime"`
EndTime string `map:"endTime"`
QueryType string `map:"queryType"`
WorkAction string `map:"workAction"`
}
func NewGetHighOptLossHistoryList() *GetHighOptLossHistoryList {
getHighOptLossHistoryList := new(GetHighOptLossHistoryList)
getHighOptLossHistoryList.Page = "1"
getHighOptLossHistoryList.Rows = "10000"
getHighOptLossHistoryList.OrgId = "330106"
getHighOptLossHistoryList.BusiType = "11"
getHighOptLossHistoryList.QueryFlag = "2"
getHighOptLossHistoryList.StartTime = "2024-12-28 15:40:49" //TODO 以后每年要修改这个
getHighOptLossHistoryList.EndTime = time.Now().Format("2006-01-02 15:04:05")
getHighOptLossHistoryList.QueryType = "-1"
getHighOptLossHistoryList.WorkAction = "0"
return getHighOptLossHistoryList
}
func (th *GetHighOptLossHistoryList) GenReqParam() map[string]string {
return th.structToMap()
}
func (th *GetHighOptLossHistoryList) structToMap() map[string]string {
result := make(map[string]string)
t := reflect.TypeOf(*th)
v := reflect.ValueOf(*th)
for i := 0; i < t.NumField(); i++ {
field := t.Field(i)
value := v.Field(i)
// Use the tag value as the key in the map, if it exists; otherwise, use the field name.
tag := field.Tag.Get("map")
if tag == "" {
tag = field.Name
}
result[tag] = value.String()
}
return result
}

@ -1,57 +0,0 @@
package model
import "reflect"
/*
http://132.151.160.87:10010/wms-zj/gShuaiReply/gshuaiOrderReplyListAjax.do
*/
/*
*/
type GetHighOptLossList struct {
OrgId string `map:"orgId"`
BookFlag string `map:"bookFlag"`
OrderPram string `map:"orderpram"`
OrderDesc string `map:"orderDesc"`
ReceiveFlag string `map:"receiveFlag"`
Rows string `map:"rows"`
Page string `map:"page"`
QueryType string `map:"queryType"`
}
// NewGetHighOptLossList receiveFlag=0,全部 receiveFlag=1,综合派单 receiveFlag=2,施工处理 receiveFlag=5,人工回访
func NewGetHighOptLossList(receiveFlag string) *GetHighOptLossList {
getHighOptLossList := new(GetHighOptLossList)
getHighOptLossList.OrgId = "330106"
getHighOptLossList.BookFlag = "-1"
getHighOptLossList.OrderPram = "ACCEPT_TIME"
getHighOptLossList.OrderDesc = "DESC"
getHighOptLossList.ReceiveFlag = receiveFlag
getHighOptLossList.Rows = "1000"
getHighOptLossList.Page = "1"
getHighOptLossList.QueryType = "-1"
return getHighOptLossList
}
func (th *GetHighOptLossList) GenReqParam() map[string]string {
return th.structToMap()
}
func (th *GetHighOptLossList) structToMap() map[string]string {
result := make(map[string]string)
t := reflect.TypeOf(*th)
v := reflect.ValueOf(*th)
for i := 0; i < t.NumField(); i++ {
field := t.Field(i)
value := v.Field(i)
// Use the tag value as the key in the map, if it exists; otherwise, use the field name.
tag := field.Tag.Get("map")
if tag == "" {
tag = field.Name
}
result[tag] = value.String()
}
return result
}

@ -0,0 +1,63 @@
package model
import (
"reflect"
"time"
)
/*
http://132.151.160.87:10010/wms-zj/gshuaiOrderQueryW/getOrderInfo.do
*/
/*
访
*/
type GetHighOptLossUnderList struct {
Page string `map:"page"`
Rows string `map:"rows"`
OrgId string `map:"orgId"`
BusiType string `map:"busiType"`
QueryFlag string `map:"queryFlag"`
StartTime string `map:"startTime"`
EndTime string `map:"endTime"`
OrdStatus string `map:"ordStatus"`
QueryType string `map:"queryType"`
WorkAction string `map:"workAction"`
}
func NewGetHighOptLossUnderList() *GetHighOptLossUnderList {
getHighOptLossUnderList := new(GetHighOptLossUnderList)
getHighOptLossUnderList.Page = "1"
getHighOptLossUnderList.Rows = "10000"
getHighOptLossUnderList.OrgId = "330106"
getHighOptLossUnderList.BusiType = "11"
getHighOptLossUnderList.QueryFlag = "1"
getHighOptLossUnderList.StartTime = "2024-12-28 15:40:49" //TODO 以后每年要修改这个
getHighOptLossUnderList.EndTime = time.Now().Format("2006-01-02 15:04:05")
getHighOptLossUnderList.OrdStatus = "0"
getHighOptLossUnderList.QueryType = "-1"
getHighOptLossUnderList.WorkAction = "0"
return getHighOptLossUnderList
}
func (th *GetHighOptLossUnderList) GenReqParam() map[string]string {
return th.structToMap()
}
func (th *GetHighOptLossUnderList) structToMap() map[string]string {
result := make(map[string]string)
t := reflect.TypeOf(*th)
v := reflect.ValueOf(*th)
for i := 0; i < t.NumField(); i++ {
field := t.Field(i)
value := v.Field(i)
// Use the tag value as the key in the map, if it exists; otherwise, use the field name.
tag := field.Tag.Get("map")
if tag == "" {
tag = field.Name
}
result[tag] = value.String()
}
return result
}

@ -10,87 +10,78 @@ import (
//获取光衰数据列表
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红色
// HighOptLossUnder 在途光衰单
type HighOptLossUnder struct {
Count int //所有在途单
UnderCount int //施工中在途单
ApplyCount int //人工回访在途单
DurationOverSeven int
DurationOverFifteen int
Book int
}
func ReqGetHighOptLossList(receiveFlag string) map[string]*HighOptLoss {
type HighOptLossHistory struct {
Count int
}
// ReqGetHighOptLossUnderList 查询在途光衰单(包含施工中、人工回访、综合调度等全部未归档状态)
func ReqGetHighOptLossUnderList() map[string]*HighOptLossUnder {
h := model.NewHeader()
header := h.GenReqParam()
f := model.NewGetHighOptLossList(receiveFlag)
f := model.NewGetHighOptLossUnderList()
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")
SetHeaders(header).SetFormData(form).Post("http://132.151.160.87:10010/wms-zj/gshuaiOrderQueryW/getOrderInfo.do")
if err != nil {
panic(exception.New(err.Error()))
}
//handle光衰数据
data := gjson.Get(resp.String(), "list").Array()
m := make(map[string]*HighOptLoss)
m := make(map[string]*HighOptLossUnder)
for _, v := range data {
if v.Get("onuGreatLightDecline").String() == "否" {
//小光衰不处理
continue
}
if m[v.Get("DEAL_MAN").String()] == nil {
m[v.Get("DEAL_MAN").String()] = &HighOptLoss{}
m[v.Get("DEAL_MAN").String()] = &HighOptLossUnder{}
}
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("STATUS").String() == "施工处理" {
m[v.Get("DEAL_MAN").String()].UnderCount++
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++
}
}
if v.Get("BOOK_TIME").String() != "" {
m[v.Get("DEAL_MAN").String()].Book++
if v.Get("STATUS").String() == "人工回访" {
m[v.Get("DEAL_MAN").String()].ApplyCount++
}
}
return m
}
func ReqGetHighOptLossSmallList(receiveFlag string) map[string]*HighOptLoss {
// ReqGetHighOptLossHistoryList 查询历史光衰单
func ReqGetHighOptLossHistoryList() map[string]*HighOptLossHistory {
h := model.NewHeader()
header := h.GenReqParam()
f := model.NewGetHighOptLossList(receiveFlag)
f := model.NewGetHighOptLossHistoryList()
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")
SetHeaders(header).SetFormData(form).Post("http://132.151.160.87:10010/wms-zj/gshuaiOrderQueryW/getOrderInfo.do")
if err != nil {
panic(exception.New(err.Error()))
}
//handle光衰数据
data := gjson.Get(resp.String(), "list").Array()
m := make(map[string]*HighOptLoss)
m := make(map[string]*HighOptLossHistory)
for _, v := range data {
if v.Get("onuGreatLightDecline").String() == "是" {
//大光衰不处理
continue
}
if m[v.Get("DEAL_MAN").String()] == nil {
m[v.Get("DEAL_MAN").String()] = &HighOptLoss{}
m[v.Get("DEAL_MAN").String()] = &HighOptLossHistory{}
}
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
}

Loading…
Cancel
Save