|
@@ -8,6 +8,8 @@ import (
|
|
|
"fwh-toolbox-server/repositories"
|
|
"fwh-toolbox-server/repositories"
|
|
|
"fwh-toolbox-server/taskQueue"
|
|
"fwh-toolbox-server/taskQueue"
|
|
|
"fwh-toolbox-server/utils/global"
|
|
"fwh-toolbox-server/utils/global"
|
|
|
|
|
+ "math"
|
|
|
|
|
+ "regexp"
|
|
|
"strconv"
|
|
"strconv"
|
|
|
"time"
|
|
"time"
|
|
|
|
|
|
|
@@ -15,6 +17,8 @@ import (
|
|
|
"go.uber.org/zap"
|
|
"go.uber.org/zap"
|
|
|
)
|
|
)
|
|
|
|
|
|
|
|
|
|
+var VERSION_REGEX = regexp.MustCompile(`V(\d+)R(\d+)B(\d+)D(\d+)`)
|
|
|
|
|
+
|
|
|
// 获取更新状态
|
|
// 获取更新状态
|
|
|
func GetSiteInfoUpdateStatus() (*domain.SiteInfoUpdateRecord, error) {
|
|
func GetSiteInfoUpdateStatus() (*domain.SiteInfoUpdateRecord, error) {
|
|
|
return repositories.GetSiteInfoUpdateNewRecord()
|
|
return repositories.GetSiteInfoUpdateNewRecord()
|
|
@@ -101,13 +105,25 @@ func ExportSiteInfoDataList(filer *domain.SiteInfoFilter) (*excelize.File, error
|
|
|
f.SetCellValue("Sheet1", "AA1", "Owner/Maintainer")
|
|
f.SetCellValue("Sheet1", "AA1", "Owner/Maintainer")
|
|
|
f.SetCellValue("Sheet1", "AB1", "DataSource")
|
|
f.SetCellValue("Sheet1", "AB1", "DataSource")
|
|
|
f.SetCellValue("Sheet1", "AC1", "LastUpdated")
|
|
f.SetCellValue("Sheet1", "AC1", "LastUpdated")
|
|
|
|
|
+ f.SetCellValue("Sheet1", "AD1", "ConnectType")
|
|
|
|
|
+ f.SetCellValue("Sheet1", "AE1", "WifiSignal")
|
|
|
|
|
+ f.SetCellValue("Sheet1", "AF1", "4GSignal")
|
|
|
|
|
|
|
|
// 写入数据
|
|
// 写入数据
|
|
|
for i, d := range res.Data {
|
|
for i, d := range res.Data {
|
|
|
f.SetCellValue("Sheet1", "A"+strconv.Itoa(i+2), d.Sn)
|
|
f.SetCellValue("Sheet1", "A"+strconv.Itoa(i+2), d.Sn)
|
|
|
f.SetCellValue("Sheet1", "B"+strconv.Itoa(i+2), global.Deref(d.InstallerName, ""))
|
|
f.SetCellValue("Sheet1", "B"+strconv.Itoa(i+2), global.Deref(d.InstallerName, ""))
|
|
|
f.SetCellValue("Sheet1", "C"+strconv.Itoa(i+2), d.ActiveTime)
|
|
f.SetCellValue("Sheet1", "C"+strconv.Itoa(i+2), d.ActiveTime)
|
|
|
- f.SetCellValue("Sheet1", "D"+strconv.Itoa(i+2), d.Status)
|
|
|
|
|
|
|
+ f.SetCellValue("Sheet1", "D"+strconv.Itoa(i+2), func() string {
|
|
|
|
|
+ switch d.Status {
|
|
|
|
|
+ case 0:
|
|
|
|
|
+ return "离线(0)"
|
|
|
|
|
+ case 1:
|
|
|
|
|
+ return "在线(1)"
|
|
|
|
|
+ default:
|
|
|
|
|
+ return fmt.Sprintf("未知(%d)", d.Status)
|
|
|
|
|
+ }
|
|
|
|
|
+ }())
|
|
|
f.SetCellValue("Sheet1", "E"+strconv.Itoa(i+2), global.Deref(d.OnLineTime, ""))
|
|
f.SetCellValue("Sheet1", "E"+strconv.Itoa(i+2), global.Deref(d.OnLineTime, ""))
|
|
|
f.SetCellValue("Sheet1", "F"+strconv.Itoa(i+2), global.Deref(d.OffLineTime, ""))
|
|
f.SetCellValue("Sheet1", "F"+strconv.Itoa(i+2), global.Deref(d.OffLineTime, ""))
|
|
|
f.SetCellValue("Sheet1", "G"+strconv.Itoa(i+2), d.FhpSn)
|
|
f.SetCellValue("Sheet1", "G"+strconv.Itoa(i+2), d.FhpSn)
|
|
@@ -139,6 +155,103 @@ func ExportSiteInfoDataList(filer *domain.SiteInfoFilter) (*excelize.File, error
|
|
|
f.SetCellValue("Sheet1", "AA"+strconv.Itoa(i+2), "Jerry Liang/LMT")
|
|
f.SetCellValue("Sheet1", "AA"+strconv.Itoa(i+2), "Jerry Liang/LMT")
|
|
|
f.SetCellValue("Sheet1", "AB"+strconv.Itoa(i+2), "Fleetview")
|
|
f.SetCellValue("Sheet1", "AB"+strconv.Itoa(i+2), "Fleetview")
|
|
|
f.SetCellValue("Sheet1", "AC"+strconv.Itoa(i+2), record.UpdateTime.Format(time.DateTime))
|
|
f.SetCellValue("Sheet1", "AC"+strconv.Itoa(i+2), record.UpdateTime.Format(time.DateTime))
|
|
|
|
|
+ f.SetCellValue("Sheet1", "AD"+strconv.Itoa(i+2), func() string {
|
|
|
|
|
+ switch d.ConnType {
|
|
|
|
|
+ case 0:
|
|
|
|
|
+ return "未连接(0)"
|
|
|
|
|
+ case 1:
|
|
|
|
|
+ return "eth0(1)"
|
|
|
|
|
+ case 2:
|
|
|
|
|
+ return "eth1(2)"
|
|
|
|
|
+ case 3:
|
|
|
|
|
+ return "WIFI(3)"
|
|
|
|
|
+ case 4:
|
|
|
|
|
+ return "4G(4)"
|
|
|
|
|
+ default:
|
|
|
|
|
+ return fmt.Sprintf("未知(%d)", d.Status)
|
|
|
|
|
+ }
|
|
|
|
|
+ }())
|
|
|
|
|
+ f.SetCellValue("Sheet1", "AE"+strconv.Itoa(i+2), func() string {
|
|
|
|
|
+ s, err := strconv.ParseInt(d.WifiSignal, 10, 64)
|
|
|
|
|
+ if err != nil {
|
|
|
|
|
+ zap.L().Warn("WifiSignal ParseInt failed", zap.String("WifiSignal", d.WifiSignal), zap.String("err", err.Error()))
|
|
|
|
|
+ return fmt.Sprintf("未知信号(%s)", d.WifiSignal)
|
|
|
|
|
+ }
|
|
|
|
|
+ if s < 0 {
|
|
|
|
|
+ return fmt.Sprintf("Disable(%s)", d.WifiSignal)
|
|
|
|
|
+ } else if s < 40 {
|
|
|
|
|
+ return fmt.Sprintf("很弱/不可用(%s) %ddBm", d.WifiSignal, s/2-100)
|
|
|
|
|
+ } else if s < 60 {
|
|
|
|
|
+ return fmt.Sprintf("弱(%s) %ddBm", d.WifiSignal, s/2-100)
|
|
|
|
|
+ } else if s < 80 {
|
|
|
|
|
+ return fmt.Sprintf("中等/一般(%s) %ddBm", d.WifiSignal, s/2-100)
|
|
|
|
|
+ } else {
|
|
|
|
|
+ return fmt.Sprintf("强/良好(%s) > -50dBm", d.WifiSignal)
|
|
|
|
|
+ }
|
|
|
|
|
+ }())
|
|
|
|
|
+ f.SetCellValue("Sheet1", "AF"+strconv.Itoa(i+2), func() string {
|
|
|
|
|
+ if d.Signal == nil {
|
|
|
|
|
+ return "Not Signal"
|
|
|
|
|
+ }
|
|
|
|
|
+ s, err := strconv.ParseInt(*d.Signal, 10, 64)
|
|
|
|
|
+ if err != nil {
|
|
|
|
|
+ zap.L().Warn("Signal ParseInt failed", zap.String("4GSignal", *d.Signal), zap.String("err", err.Error()))
|
|
|
|
|
+ return fmt.Sprintf("未知信号(%s)", *d.Signal)
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 判断软件版本
|
|
|
|
|
+ isNew := false
|
|
|
|
|
+ if d.AppVersion != nil && *d.AppVersion != "" {
|
|
|
|
|
+ match := VERSION_REGEX.FindStringSubmatch(*d.AppVersion)
|
|
|
|
|
+ if match != nil {
|
|
|
|
|
+ v := match[1]
|
|
|
|
|
+ r := match[2]
|
|
|
|
|
+ b := match[3]
|
|
|
|
|
+ d := match[4]
|
|
|
|
|
+ _ = d // 当前逻辑未使用
|
|
|
|
|
+ if v == "10" {
|
|
|
|
|
+ rInt, _ := strconv.Atoi(r)
|
|
|
|
|
+ bInt, _ := strconv.Atoi(b)
|
|
|
|
|
+
|
|
|
|
|
+ if rInt > 5 {
|
|
|
|
|
+ isNew = true
|
|
|
|
|
+ } else if rInt == 4 && bInt >= 14 {
|
|
|
|
|
+ isNew = true
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if isNew {
|
|
|
|
|
+ if s < 0 {
|
|
|
|
|
+ return fmt.Sprintf("Disable(%s)", *d.Signal)
|
|
|
|
|
+ } else if s <= 12 {
|
|
|
|
|
+ return fmt.Sprintf("很差(%s) %ddBm", *d.Signal, int(math.Round(float64(s)/2.5-115)))
|
|
|
|
|
+ } else if s <= 37 {
|
|
|
|
|
+ return fmt.Sprintf("较差(%s) %ddBm", *d.Signal, int(math.Round(float64(s)/2.5-115)))
|
|
|
|
|
+ } else if s <= 62 {
|
|
|
|
|
+ return fmt.Sprintf("一般(%s) %ddBm", *d.Signal, int(math.Round(float64(s)/2.5-115)))
|
|
|
|
|
+ } else if s <= 87 {
|
|
|
|
|
+ return fmt.Sprintf("良好(%s) %ddBm", *d.Signal, int(math.Round(float64(s)/2.5-115)))
|
|
|
|
|
+ } else {
|
|
|
|
|
+ return fmt.Sprintf("极好(%s) %ddBm", *d.Signal, int(math.Round(float64(s)/2.5-115)))
|
|
|
|
|
+ }
|
|
|
|
|
+ } else {
|
|
|
|
|
+ if s < 0 {
|
|
|
|
|
+ return fmt.Sprintf("Disable(%s)", *d.Signal)
|
|
|
|
|
+ } else if s <= 1 {
|
|
|
|
|
+ return fmt.Sprintf("很差(%s) %ddBm", *d.Signal, s*2-113)
|
|
|
|
|
+ } else if s <= 6 {
|
|
|
|
|
+ return fmt.Sprintf("较差(%s) %ddBm", *d.Signal, s*2-113)
|
|
|
|
|
+ } else if s <= 11 {
|
|
|
|
|
+ return fmt.Sprintf("一般(%s) %ddBm", *d.Signal, s*2-113)
|
|
|
|
|
+ } else if s <= 16 {
|
|
|
|
|
+ return fmt.Sprintf("良好(%s) %ddBm", *d.Signal, s*2-113)
|
|
|
|
|
+ } else {
|
|
|
|
|
+ return fmt.Sprintf("极好(%s) %ddBm", *d.Signal, s*2-113)
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }())
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
return f, err
|
|
return f, err
|