|
|
@@ -6,6 +6,7 @@ import (
|
|
|
"server/model/common/request"
|
|
|
"server/model/common/response"
|
|
|
"server/utils/data"
|
|
|
+ "server/utils/logger"
|
|
|
"server/utils/protocol"
|
|
|
"strconv"
|
|
|
"time"
|
|
|
@@ -33,8 +34,8 @@ func (ds *DeviceService) GenerateDeviceFile(id int) (data response.DeviceFileDat
|
|
|
for _, d := range devices {
|
|
|
if d.DeviceGenre.Type == "环境设备" {
|
|
|
envDev := response.EnvDev{
|
|
|
- Sn: d.Sn,
|
|
|
Name: d.Name,
|
|
|
+ Sn: d.Sn,
|
|
|
Address: d.Address,
|
|
|
TaskTime: d.TaskTime,
|
|
|
WaitTime: d.WaitTime,
|
|
|
@@ -73,8 +74,8 @@ func (ds *DeviceService) DeviceSwitch(info request.SwitchTunnel) error {
|
|
|
} else {
|
|
|
i = 0
|
|
|
}
|
|
|
- data := strconv.Itoa(info.RadarId) + strconv.Itoa(info.RelayId) + strconv.Itoa(i)
|
|
|
- err = MqttService.Publish(MqttService.GetTopic(info.TunnelSn, protocol.TopicSwitchControl), []byte(data))
|
|
|
+ data1 := strconv.Itoa(info.RadarId) + strconv.Itoa(info.RelayId) + strconv.Itoa(i)
|
|
|
+ err = MqttService.Publish(MqttService.GetTopic(info.TunnelSn, protocol.TopicSwitchControl), []byte(data1))
|
|
|
if err != nil {
|
|
|
return fmt.Errorf("error updating: %v", err)
|
|
|
}
|
|
|
@@ -133,9 +134,19 @@ func InductanceStatistics() error {
|
|
|
}
|
|
|
|
|
|
consumption := data.CalculateDailyEnergyConsumption(preprocessData)
|
|
|
- fmt.Println(time.Now())
|
|
|
- fmt.Println(consumption)
|
|
|
+
|
|
|
+ err = dao.PowerStatistics{
|
|
|
+ TunnelSn: tunnel.TunnelSn,
|
|
|
+ TotalActivePower: consumption,
|
|
|
+ UploadTime: time.Now().Add(-1).Local().Format("2006-01-02"),
|
|
|
+ }.CreatePowerStatistics()
|
|
|
+
|
|
|
+ logger.Get().Errorf("电感数据统计 隧道:%v 错误%v", tunnel.TunnelSn, err)
|
|
|
}
|
|
|
|
|
|
return nil
|
|
|
}
|
|
|
+
|
|
|
+func (ds *DeviceService) QueryPowerStatisticsBySn(sn string) (powerStatistics []dao.PowerStatistics, err error) {
|
|
|
+ return dao.QueryPowerStatisticsBySn(sn)
|
|
|
+}
|