|
@@ -80,6 +80,7 @@ func (s *lightStrategyService) CreateOrUpdate(userId int64, tenantId int, req *m
|
|
|
if req.ID == 0 {
|
|
|
strategy.CreateTime = time.Now()
|
|
|
strategy.CreateUser = userId
|
|
|
+ strategy.Status = 1
|
|
|
if strategy.IsExistedBySN() {
|
|
|
logger.Logger.Errorf("Create GetstrategyID err \n")
|
|
|
return common.ParamsInvalidResponse("编码不能重复,请重新填写!", nil)
|
|
@@ -169,8 +170,8 @@ func (s *lightStrategyService) CreateOrUpdate(userId int64, tenantId int, req *m
|
|
|
}
|
|
|
|
|
|
//存策略条件
|
|
|
- _ = TimeConditionService.Save(timeList)
|
|
|
- _ = LightConditionService.Save(strategy.LightConditionList)
|
|
|
+ _ = TimeConditionService.Save(timeList, strategy.ID)
|
|
|
+ _ = LightConditionService.Save(strategy.LightConditionList, strategy.ID)
|
|
|
|
|
|
//todo 调用设备云端的新增或修改
|
|
|
|
|
@@ -215,9 +216,20 @@ func (s *lightStrategyService) List(searchValue string, current, size int) ([]mo
|
|
|
timeCondition.StartTime = "日落"
|
|
|
timeCondition.EndTime = "日出"
|
|
|
}
|
|
|
- detail.CombinationStr = fmt.Sprintf("开灯时段:%s ~ %s , 灯光亮度:%d%%", timeCondition.StartTime,
|
|
|
- timeCondition.EndTime, timeCondition.Luminance)
|
|
|
+ str := []string{}
|
|
|
+ str = append(str, fmt.Sprintf("开灯时段:%s ~ %s , 灯光亮度:%d%%", timeCondition.StartTime,
|
|
|
+ timeCondition.EndTime, timeCondition.Luminance))
|
|
|
+ detail.CombinationStr = str
|
|
|
}
|
|
|
+ lightStrategy := &model.LightStrategyDetail{
|
|
|
+ LightStrategy: strategy,
|
|
|
+ }
|
|
|
+ lightStrategy.TimeConditionList = TimeConditionService.GetByLightId(strategy.ID)
|
|
|
+ if len(lightStrategy.TimeConditionList) > 0 {
|
|
|
+ lightStrategy.LightType = "时间"
|
|
|
+ }
|
|
|
+ detail.LightType = lightStrategy.LightType + "策略"
|
|
|
+
|
|
|
details = append(details, detail)
|
|
|
}
|
|
|
return details, nil
|