|
@@ -19,17 +19,19 @@ var InfoBoardService = new(infoBoardService)
|
|
|
|
|
|
|
|
type infoBoardService struct{}
|
|
type infoBoardService struct{}
|
|
|
|
|
|
|
|
-func (s *infoBoardService) Get(id int) (*model.InfoBoardDetail, *common.Errors) {
|
|
|
|
|
|
|
+func (s *infoBoardService) Get(id int) (model.InfoBoardDetail, *common.Errors) {
|
|
|
// 创建查询实例
|
|
// 创建查询实例
|
|
|
device := &dao.InfoBoard{
|
|
device := &dao.InfoBoard{
|
|
|
ID: id,
|
|
ID: id,
|
|
|
}
|
|
}
|
|
|
getDevice, err := device.GetDevice()
|
|
getDevice, err := device.GetDevice()
|
|
|
if err != nil {
|
|
if err != nil {
|
|
|
- return nil, common.FailResponse(err.Error(), nil)
|
|
|
|
|
|
|
+ return model.InfoBoardDetail{}, common.FailResponse(err.Error(), nil)
|
|
|
}
|
|
}
|
|
|
detail := s.rewriteBoardDetail(getDevice)
|
|
detail := s.rewriteBoardDetail(getDevice)
|
|
|
- return &detail, nil
|
|
|
|
|
|
|
+ fmt.Printf("detail = %v \n", detail.BootStartTime)
|
|
|
|
|
+ fmt.Printf("detail = %v \n", detail.Condition)
|
|
|
|
|
+ return detail, nil
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
func (s *infoBoardService) CreateOrUpdate(userId int64, tenantId string, req dao.InfoBoard) *common.Errors {
|
|
func (s *infoBoardService) CreateOrUpdate(userId int64, tenantId string, req dao.InfoBoard) *common.Errors {
|
|
@@ -91,6 +93,7 @@ func (s *infoBoardService) List(searchValue string, current, size int) ([]model.
|
|
|
// 从缓存中读取真实状态
|
|
// 从缓存中读取真实状态
|
|
|
func (s *infoBoardService) rewriteBoardDetail(d dao.InfoBoard) model.InfoBoardDetail {
|
|
func (s *infoBoardService) rewriteBoardDetail(d dao.InfoBoard) model.InfoBoardDetail {
|
|
|
endTime, state := cache.GetDeviceState(d.Sn)
|
|
endTime, state := cache.GetDeviceState(d.Sn)
|
|
|
|
|
+
|
|
|
detail := model.InfoBoardDetail{
|
|
detail := model.InfoBoardDetail{
|
|
|
InfoBoard: d,
|
|
InfoBoard: d,
|
|
|
RunState: state,
|
|
RunState: state,
|
|
@@ -98,12 +101,14 @@ func (s *infoBoardService) rewriteBoardDetail(d dao.InfoBoard) model.InfoBoardDe
|
|
|
EndLineTime: endTime,
|
|
EndLineTime: endTime,
|
|
|
}
|
|
}
|
|
|
cacheMap := cache.GetDeviceLedData(d.Sn)
|
|
cacheMap := cache.GetDeviceLedData(d.Sn)
|
|
|
|
|
+
|
|
|
if cacheMap != nil {
|
|
if cacheMap != nil {
|
|
|
marshal, err := json.Marshal(cacheMap)
|
|
marshal, err := json.Marshal(cacheMap)
|
|
|
if err != nil {
|
|
if err != nil {
|
|
|
logger.Logger.Errorf("rewriteBoardDetail err1 = %v \n", err)
|
|
logger.Logger.Errorf("rewriteBoardDetail err1 = %v \n", err)
|
|
|
return detail
|
|
return detail
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
var cltData model.CltledData
|
|
var cltData model.CltledData
|
|
|
err = json.Unmarshal(marshal, &cltData)
|
|
err = json.Unmarshal(marshal, &cltData)
|
|
|
if err != nil {
|
|
if err != nil {
|
|
@@ -111,6 +116,7 @@ func (s *infoBoardService) rewriteBoardDetail(d dao.InfoBoard) model.InfoBoardDe
|
|
|
return detail
|
|
return detail
|
|
|
}
|
|
}
|
|
|
detail.Power = "边缘程序未升级"
|
|
detail.Power = "边缘程序未升级"
|
|
|
|
|
+
|
|
|
if cltData.RealWidth != "" {
|
|
if cltData.RealWidth != "" {
|
|
|
detail.ResolutionName = fmt.Sprintf("%v * %v", cltData.RealWidth, cltData.RealHeight)
|
|
detail.ResolutionName = fmt.Sprintf("%v * %v", cltData.RealWidth, cltData.RealHeight)
|
|
|
detail.OnTheAir = cltData.Playing
|
|
detail.OnTheAir = cltData.Playing
|
|
@@ -139,11 +145,13 @@ func (s *infoBoardService) rewriteBoardDetail(d dao.InfoBoard) model.InfoBoardDe
|
|
|
}
|
|
}
|
|
|
if cltData.WakeupTime != "" {
|
|
if cltData.WakeupTime != "" {
|
|
|
detail.NeverCloseDown = 2
|
|
detail.NeverCloseDown = 2
|
|
|
- detail.BootStartTime = cltData.WakeupTime
|
|
|
|
|
- detail.BootEndTime = cltData.SleepTime
|
|
|
|
|
|
|
+ //detail.BootStartTime = cltData.WakeupTime
|
|
|
|
|
+ //detail.BootEndTime = cltData.SleepTime
|
|
|
|
|
+ detail.RealStartAndEndTime = fmt.Sprintf("%v-%v", cltData.WakeupTime, cltData.SleepTime)
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
return detail
|
|
return detail
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -209,22 +217,22 @@ func (s *infoBoardService) EdgeCmd(tenant, sn string, cmdNum, id int) {
|
|
|
case 3: //重启
|
|
case 3: //重启
|
|
|
param["command"] = "reboot"
|
|
param["command"] = "reboot"
|
|
|
s.reqEdge(tenant, edgePost, param, action)
|
|
s.reqEdge(tenant, edgePost, param, action)
|
|
|
- case 4: //重新节目
|
|
|
|
|
|
|
+ //case 4: //重新节目,不在此处,处理了
|
|
|
case 6: //更新排程
|
|
case 6: //更新排程
|
|
|
device := &dao.InfoBoard{
|
|
device := &dao.InfoBoard{
|
|
|
ID: id,
|
|
ID: id,
|
|
|
}
|
|
}
|
|
|
dev, _ := device.GetDevice()
|
|
dev, _ := device.GetDevice()
|
|
|
action = "ssched"
|
|
action = "ssched"
|
|
|
- sleep := dev.BootEndTime + ":00"
|
|
|
|
|
- param["sleep"] = sleep[0:8]
|
|
|
|
|
- wakeup := dev.BootStartTime + ":00"
|
|
|
|
|
- param["wakeup"] = wakeup[0:8]
|
|
|
|
|
if dev.NeverCloseDown == 1 {
|
|
if dev.NeverCloseDown == 1 {
|
|
|
param["sleep"] = ""
|
|
param["sleep"] = ""
|
|
|
param["wakeup"] = ""
|
|
param["wakeup"] = ""
|
|
|
|
|
+ } else {
|
|
|
|
|
+ sleep, wakeup := ledTimeFormat(dev.BootEndTime, dev.BootStartTime)
|
|
|
|
|
+ param["sleep"] = sleep
|
|
|
|
|
+ param["wakeup"] = wakeup
|
|
|
}
|
|
}
|
|
|
- param["reboot"] = "12:30:10" //每日重启时间
|
|
|
|
|
|
|
+ param["reboot"] = "12:30:1" //每日重启时间
|
|
|
s.reqEdge(tenant, edgePost, param, action)
|
|
s.reqEdge(tenant, edgePost, param, action)
|
|
|
case 101: //更新亮度 音量, 这里需要做成定时任务去跑
|
|
case 101: //更新亮度 音量, 这里需要做成定时任务去跑
|
|
|
device := &dao.InfoBoard{
|
|
device := &dao.InfoBoard{
|
|
@@ -290,3 +298,17 @@ func isEight() bool {
|
|
|
return false
|
|
return false
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+// ledTimeFormat led开始 结束时间格式化
|
|
|
|
|
+func ledTimeFormat(stime string, etime string) (string, string) {
|
|
|
|
|
+ startTime := fmt.Sprintf("%v %v:01", time.Now().Format("2006-01-02"), stime)
|
|
|
|
|
+ endTime := fmt.Sprintf("%v %v:01", time.Now().Format("2006-01-02"), etime)
|
|
|
|
|
+
|
|
|
|
|
+ ktime, _ := time.Parse("2006-01-02 15:04:05", startTime)
|
|
|
|
|
+ jtime, _ := time.Parse("2006-01-02 15:04:05", endTime)
|
|
|
|
|
+
|
|
|
|
|
+ atoi1, _ := strconv.Atoi(ktime.Format("15"))
|
|
|
|
|
+ atoi2, _ := strconv.Atoi(jtime.Format("15"))
|
|
|
|
|
+
|
|
|
|
|
+ return fmt.Sprintf("%v:%v:1", atoi1, ktime.Format("4")), fmt.Sprintf("%v:%v:1", atoi2, jtime.Format("4"))
|
|
|
|
|
+}
|