update: high_opt_loss

main
Leo 8 months ago
parent 6ca8673921
commit 6e4ddf0094

@ -1,8 +1,8 @@
package cmd
import (
"cu-helper/high-opt-loss/common"
"cu-helper/high-opt-loss/service"
"cu-helper/wms/common"
"cu-helper/wms/service"
"github.com/mizuki1412/go-core-kit/init/initkit"
"github.com/mizuki1412/go-core-kit/service/logkit"
"github.com/spf13/cobra"

@ -1,7 +1,7 @@
package common
import (
"cu-helper/high-opt-loss/service"
"cu-helper/wms/service"
"fmt"
"github.com/mizuki1412/go-core-kit/library/mathkit"
"github.com/mizuki1412/go-core-kit/service/logkit"
@ -13,7 +13,7 @@ import (
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月14日).xlsx")
f, err := excelize.OpenFile("/Users/leo/Documents/光衰通报/光衰/2025/光衰通报(3月28日).xlsx")
if err != nil {
fmt.Println(err)
return
@ -177,7 +177,8 @@ func GenExcelFile(m1 map[string]*service.HighOptLossUnder, m2 map[string]*servic
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)
f.SetCellValue("汇总", "I"+strconv.Itoa(i), data.CantCount)
f.SetCellValue("汇总", "J"+strconv.Itoa(i), data.ApplyCount)
} else {
f.SetCellValue("汇总", "E"+strconv.Itoa(i), 0)
f.SetCellStyle("汇总", "E"+strconv.Itoa(i), "E"+strconv.Itoa(i), styleGreen)
@ -188,44 +189,45 @@ func GenExcelFile(m1 map[string]*service.HighOptLossUnder, m2 map[string]*servic
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)
f.SetCellValue("汇总", "J"+strconv.Itoa(i), 0)
}
if data, ok := m2[key]; ok {
f.SetCellValue("汇总", "J"+strconv.Itoa(i), data.Count)
f.SetCellValue("汇总", "K"+strconv.Itoa(i), data.Count)
if data1, ok1 := m1[key]; ok1 {
//有归档+有在途
f.SetCellValue("汇总", "K"+strconv.Itoa(i), data.Count+data1.Count)
f.SetCellValue("汇总", "L"+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)
f.SetCellValue("汇总", "M"+strconv.Itoa(i), v)
if v < 0.8 {
f.SetCellStyle("汇总", "L"+strconv.Itoa(i), "L"+strconv.Itoa(i), styleRedFMT)
f.SetCellStyle("汇总", "M"+strconv.Itoa(i), "M"+strconv.Itoa(i), styleRedFMT)
}
if v >= 0.8 {
f.SetCellStyle("汇总", "L"+strconv.Itoa(i), "L"+strconv.Itoa(i), styleGreenFMT)
f.SetCellStyle("汇总", "M"+strconv.Itoa(i), "M"+strconv.Itoa(i), styleGreenFMT)
}
} else {
//有归档+无在途
f.SetCellValue("汇总", "K"+strconv.Itoa(i), data.Count)
f.SetCellValue("汇总", "L"+strconv.Itoa(i), data.Count)
v := mathkit.FloatRound(float64(data.Count)/(float64(data.Count)), 4)
f.SetCellValue("汇总", "L"+strconv.Itoa(i), v)
f.SetCellValue("汇总", "M"+strconv.Itoa(i), v)
if v < 0.8 {
f.SetCellStyle("汇总", "L"+strconv.Itoa(i), "L"+strconv.Itoa(i), styleRedFMT)
f.SetCellStyle("汇总", "M"+strconv.Itoa(i), "M"+strconv.Itoa(i), styleRedFMT)
}
if v >= 0.8 {
f.SetCellStyle("汇总", "L"+strconv.Itoa(i), "L"+strconv.Itoa(i), styleGreenFMT)
f.SetCellStyle("汇总", "M"+strconv.Itoa(i), "M"+strconv.Itoa(i), styleGreenFMT)
}
}
} else {
f.SetCellValue("汇总", "J"+strconv.Itoa(i), 0)
f.SetCellValue("汇总", "K"+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)
f.SetCellValue("汇总", "L"+strconv.Itoa(i), data1.Count)
f.SetCellValue("汇总", "M"+strconv.Itoa(i), 0)
f.SetCellStyle("汇总", "M"+strconv.Itoa(i), "M"+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)
f.SetCellValue("汇总", "L"+strconv.Itoa(i), 0)
f.SetCellValue("汇总", "M"+strconv.Itoa(i), 1)
f.SetCellStyle("汇总", "M"+strconv.Itoa(i), "M"+strconv.Itoa(i), styleGreenFMT)
}
}
}
@ -257,14 +259,14 @@ func GenExcelFile(m1 map[string]*service.HighOptLossUnder, m2 map[string]*servic
}
}
// Sum columns C:H and place the results in row 23
for col := 'C'; col <= 'K'; col++ {
for col := 'C'; col <= 'L'; 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 <= 'K'; col++ {
for col := 'C'; col <= 'L'; col++ {
sumCell := string(col) + "23"
value, err := f.CalcCellValue("汇总", sumCell)
if err != nil {
@ -273,9 +275,9 @@ func GenExcelFile(m1 map[string]*service.HighOptLossUnder, m2 map[string]*servic
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))
done, _ := f.GetCellValue("汇总", "K23")
total, _ := f.GetCellValue("汇总", "L23")
f.SetCellValue("汇总", "M23", mathkit.FloatRound(cast.ToFloat64(done)/cast.ToFloat64(total), 4))
//设置表头
content := fmt.Sprintf("西湖智家光衰通报:%s", time.Now().Format("1月2日"))

@ -1,7 +1,7 @@
package service
import (
"cu-helper/high-opt-loss/model"
"cu-helper/wms/model"
"github.com/go-resty/resty/v2"
"github.com/mizuki1412/go-core-kit/class/exception"
"github.com/tidwall/gjson"
@ -13,8 +13,9 @@ import (
// HighOptLossUnder 在途光衰单
type HighOptLossUnder struct {
Count int //所有在途单
UnderCount int //施工中在途单
UnderCount int //施工中在途单,包含不可处理
ApplyCount int //人工回访在途单
CantCount int //回单不可处理
DurationOverSeven int
DurationOverFifteen int
Book int
@ -45,6 +46,9 @@ func ReqGetHighOptLossUnderList() map[string]*HighOptLossUnder {
m[v.Get("DEAL_MAN").String()].Count++
if v.Get("STATUS").String() == "施工处理" {
m[v.Get("DEAL_MAN").String()].UnderCount++
if v.Get("REPLY_TYPE").String() == "不可处理" {
m[v.Get("DEAL_MAN").String()].CantCount++
}
duration := v.Get("TIMELONGS").Int()
if duration >= 604800 {
m[v.Get("DEAL_MAN").String()].DurationOverSeven++
Loading…
Cancel
Save