Selaa lähdekoodia

feat:“设备获取广告时增加播放时机器状态字段“

soobin 1 vuosi sitten
vanhempi
commit
0ab180a56f

+ 60 - 54
src/main/java/com/szwl/controller/ADIndexController.java

@@ -44,31 +44,33 @@ public class ADIndexController {
 
     @Autowired
     private RedisTemplate redisTemplate;
+
     /**
      * 根据广告id获取广告
      */
     @GetMapping(value = "/getAdById.htm", produces = "text/html;charset=utf-8")
     @ResponseBody
     public String getAdById(String id) {
-        if(StringUtils.isEmpty(id)){
+        if (StringUtils.isEmpty(id)) {
 //            return JsonMessage.error("id为null");
             return "id为null";
         }
         TAd ad = aDService.getById(id);
         ArrayList<AdVo> list = new ArrayList<>();
-                AdVo adVo = new AdVo();
-                adVo.setAdType(String.valueOf(ad.getAdType()));
-                adVo.setLocationType(String.valueOf(ad.getLocationType()));
-                adVo.setName(ad.getName());
-                adVo.setOrder(ad.getOrders());
-                adVo.setUrl(ad.getUrl());
-                adVo.setEquipmentType(ad.getEquipmentType());
-                adVo.setCreateDate(ad.getCreateDate());
-                adVo.setId(ad.getId());
-                adVo.setMediaPreview(ad.getMediaPreview());
-                adVo.setDuration(ad.getDuration());
-                adVo.setScreenType(ad.getScreenType());
-                list.add(adVo);
+        AdVo adVo = new AdVo();
+        adVo.setAdType(String.valueOf(ad.getAdType()));
+        adVo.setLocationType(String.valueOf(ad.getLocationType()));
+        adVo.setName(ad.getName());
+        adVo.setOrder(ad.getOrders());
+        adVo.setUrl(ad.getUrl());
+        adVo.setEquipmentType(ad.getEquipmentType());
+        adVo.setCreateDate(ad.getCreateDate());
+        adVo.setId(ad.getId());
+        adVo.setMediaPreview(ad.getMediaPreview());
+        adVo.setDuration(ad.getDuration());
+        adVo.setScreenType(ad.getScreenType());
+        adVo.setPlayTimeStatus(ad.getPlayTimeStatus());
+        list.add(adVo);
 
         JSONObject jsonObject = new JSONObject();
         jsonObject.put("code", 0);
@@ -82,20 +84,20 @@ public class ADIndexController {
      */
     @GetMapping(value = "/getAd.htm", produces = "text/html;charset=utf-8")
     @ResponseBody
-    public String getAdNew(String clientId,String equimentType) {
+    public String getAdNew(String clientId, String equimentType) {
         LambdaQueryWrapper<TEquipment> query = Wrappers.lambdaQuery();
-        query.eq(TEquipment::getClientId,clientId);
+        query.eq(TEquipment::getClientId, clientId);
         List<TEquipment> equipmentList = equipmentService.list(query);
         TEquipment equipment = equipmentList.get(0);
         String adminId = String.valueOf(equipment.getAdminId());
         //1,获取
         LambdaQueryWrapper<TAd> query1 = Wrappers.lambdaQuery();
-        query1.eq(TAd::getType,"0");
-        query1.eq(TAd::getEquipmentType,equimentType);
+        query1.eq(TAd::getType, "0");
+        query1.eq(TAd::getEquipmentType, equimentType);
         List<TAd> ads = aDService.list(query1);
         ArrayList<AdVo> list = new ArrayList<>();
         for (TAd ad : ads) {
-            if(adminId.equals(ad.getAdminId())||ad.getAdminId()==null){
+            if (adminId.equals(ad.getAdminId()) || ad.getAdminId() == null) {
                 AdVo adVo = new AdVo();
                 adVo.setAdType(String.valueOf(ad.getAdType()));
                 adVo.setLocationType(String.valueOf(ad.getLocationType()));
@@ -107,6 +109,7 @@ public class ADIndexController {
                 adVo.setMediaPreview(ad.getMediaPreview());
                 adVo.setDuration(ad.getDuration());
                 adVo.setScreenType(ad.getScreenType());
+                adVo.setPlayTimeStatus(ad.getPlayTimeStatus());
                 list.add(adVo);
             }
 
@@ -117,38 +120,40 @@ public class ADIndexController {
         jsonObject.put("errmsg", "");
         return jsonObject.toJSONString();
     }
+
     /**
      * 设备获取广告
      */
     @GetMapping(value = "/getAdByEquipment.htm", produces = "text/html;charset=utf-8")
     @ResponseBody
-    public String getAdByEquipment(String clientId,String equimentType) {
+    public String getAdByEquipment(String clientId, String equimentType) {
         LambdaQueryWrapper<TEquipment> query = Wrappers.lambdaQuery();
-        query.eq(TEquipment::getClientId,clientId);
+        query.eq(TEquipment::getClientId, clientId);
         List<TEquipment> equipmentList = equipmentService.list(query);
         TEquipment equipment = equipmentList.get(0);
         String adminId = String.valueOf(equipment.getAdminId());
         //1,获取
         LambdaQueryWrapper<TAd> query1 = Wrappers.lambdaQuery();
-        query1.eq(TAd::getType,"0");
-        query1.eq(TAd::getEquipmentType,equimentType);
-        query1.eq(TAd::getAdminId,adminId);
+        query1.eq(TAd::getType, "0");
+        query1.eq(TAd::getEquipmentType, equimentType);
+        query1.eq(TAd::getAdminId, adminId);
         List<TAd> ads = aDService.list(query1);
         ArrayList<AdVo> list = new ArrayList<>();
         for (TAd ad : ads) {
-            if(adminId.equals(ad.getAdminId())||ad.getAdminId()==null){
-                    AdVo adVo = new AdVo();
-                    adVo.setAdType(String.valueOf(ad.getAdType()));
-                    adVo.setLocationType(String.valueOf(ad.getLocationType()));
-                    adVo.setName(ad.getName());
-                    adVo.setOrder(ad.getOrders());
-                    adVo.setUrl(ad.getUrl());
-                    adVo.setCreateDate(ad.getCreateDate());
-                    adVo.setId(ad.getId());
-                    adVo.setMediaPreview(ad.getMediaPreview());
-                    adVo.setDuration(ad.getDuration());
-                    adVo.setScreenType(ad.getScreenType());
-                    list.add(adVo);
+            if (adminId.equals(ad.getAdminId()) || ad.getAdminId() == null) {
+                AdVo adVo = new AdVo();
+                adVo.setAdType(String.valueOf(ad.getAdType()));
+                adVo.setLocationType(String.valueOf(ad.getLocationType()));
+                adVo.setName(ad.getName());
+                adVo.setOrder(ad.getOrders());
+                adVo.setUrl(ad.getUrl());
+                adVo.setCreateDate(ad.getCreateDate());
+                adVo.setId(ad.getId());
+                adVo.setMediaPreview(ad.getMediaPreview());
+                adVo.setDuration(ad.getDuration());
+                adVo.setScreenType(ad.getScreenType());
+                adVo.setPlayTimeStatus(ad.getPlayTimeStatus());
+                list.add(adVo);
             }
 
         }
@@ -158,6 +163,7 @@ public class ADIndexController {
         jsonObject.put("errmsg", "");
         return jsonObject.toJSONString();
     }
+
     /**
      * 获取时间规则
      *
@@ -172,22 +178,23 @@ public class ADIndexController {
 //            return JsonMessage.error("该规则不存在");
             return "该规则不存在";
         }
-        if(StringUtils.isEmpty(timeRule.getType())||timeRule.getType().equals("0")){
+        if (StringUtils.isEmpty(timeRule.getType()) || timeRule.getType().equals("0")) {
             //旧规则
             String rule = null;
             List<TimeRuleVo> timeRuleVos = JSON.parseArray(timeRule.getRule(), TimeRuleVo.class);
-            for(TimeRuleVo timeRuleVo:timeRuleVos){
+            for (TimeRuleVo timeRuleVo : timeRuleVos) {
                 List<String> ads = timeRuleVo.getAd();
                 rule = ads.toString();
                 break;
             }
             return rule;
-        }else {
+        } else {
             //新规则
             String rule = timeRule.getRule();
             return rule;
         }
     }
+
     /**
      * 获取时间规则 ByClientId
      *
@@ -197,40 +204,41 @@ public class ADIndexController {
     @GetMapping(value = "/getTimeRuleByClientId.htm", produces = "text/html;charset=utf-8")
     @ResponseBody
     public String getTimeRuleByClientId(String clientId) {
-        if(StringUtils.isEmpty(clientId)){
+        if (StringUtils.isEmpty(clientId)) {
             return "编号为空";
         }
         LambdaQueryWrapper<TEquipment> query = Wrappers.lambdaQuery();
-        query.eq(TEquipment::getClientId,clientId);
+        query.eq(TEquipment::getClientId, clientId);
         List<TEquipment> equipmentList = equipmentService.list(query);
-        if(equipmentList.size()>0){
+        if (equipmentList.size() > 0) {
             TEquipment equipment = equipmentList.get(0);
-            if(equipment.getTimeRuleId()!=null){
+            if (equipment.getTimeRuleId() != null) {
                 TTimeRule timeRule = timeRuleService.getById(equipment.getTimeRuleId());
                 if (timeRule == null) {
 //            return JsonMessage.error("该规则不存在");
                     return "该规则不存在";
                 }
-                if(StringUtils.isEmpty(timeRule.getType())||timeRule.getType().equals("0")){
+                if (StringUtils.isEmpty(timeRule.getType()) || timeRule.getType().equals("0")) {
                     //旧规则
                     String rule = null;
                     List<TimeRuleVo> timeRuleVos = JSON.parseArray(timeRule.getRule(), TimeRuleVo.class);
-                    for(TimeRuleVo timeRuleVo:timeRuleVos){
+                    for (TimeRuleVo timeRuleVo : timeRuleVos) {
                         List<String> ads = timeRuleVo.getAd();
                         rule = ads.toString();
                         break;
                     }
                     return rule;
-                }else {
+                } else {
                     //新规则
                     String rule = timeRule.getRule();
                     return rule;
                 }
             }
-            }
+        }
         return "该规则不存在";
 
     }
+
     /**
      * 设备下载广告失败则更新设备的推送广告时间
      *
@@ -240,7 +248,7 @@ public class ADIndexController {
     @ResponseBody
     public String updatePushTimeUpdate(String clientId, String pushUpdateTime) {
         LambdaQueryWrapper<TEquipment> query = Wrappers.lambdaQuery();
-        query.eq(TEquipment::getClientId,clientId);
+        query.eq(TEquipment::getClientId, clientId);
         List<TEquipment> equipmentList = equipmentService.list(query);
         TEquipment equipment = equipmentList.get(0);
         if (equipment == null) {
@@ -261,9 +269,8 @@ public class ADIndexController {
 //        return JsonMessage.success("修改成功");
         return "修改成功";
     }
+
     /**
-     *
-     *
      * @param
      * @return
      */
@@ -273,15 +280,14 @@ public class ADIndexController {
         Boolean hasKey = redisTemplate.hasKey(str);
         return JsonMessage.success(hasKey);
     }
+
     /**
-     *
-     *
      * @param
      * @return
      */
     @GetMapping(value = "/checkRedis2.htm", produces = "application/json;charset=UTF-8")
     @ResponseBody
-    public JsonMessage checkRedis2(String key,String hashkey) {
+    public JsonMessage checkRedis2(String key, String hashkey) {
         Object o = redisTemplate.boundHashOps(key).get(hashkey);
         return JsonMessage.success(o);
     }

+ 4 - 98
src/main/java/com/szwl/model/dto/AdVo.java

@@ -1,11 +1,13 @@
 package com.szwl.model.dto;
 
 import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
 import org.springframework.format.annotation.DateTimeFormat;
 
 import java.io.Serializable;
 import java.util.Date;
 
+@Data
 public class AdVo implements Serializable {
 
     private Long id;
@@ -56,103 +58,7 @@ public class AdVo implements Serializable {
     @ApiModelProperty(value = "适用机器类型")
     private String equipmentType;
 
-    public String getEquipmentType() {
-        return equipmentType;
-    }
-
-    public void setEquipmentType(String equipmentType) {
-        this.equipmentType = equipmentType;
-    }
-
-    public Integer getScreenType() {
-        return screenType;
-    }
-
-    public void setScreenType(Integer screenType) {
-        this.screenType = screenType;
-    }
-
-    public Long getDuration() {
-        return duration;
-    }
-
-    public void setDuration(Long duration) {
-        this.duration = duration;
-    }
-
-    public String getName() {
-        return name;
-    }
-
-    public void setName(String name) {
-        this.name = name;
-    }
-
-
-    public String getUrl() {
-        return url;
-    }
-
-    public void setUrl(String url) {
-        this.url = url;
-    }
-
-    public String getAdminId() {
-        return adminId;
-    }
-
-    public void setAdminId(String adminId) {
-        this.adminId = adminId;
-    }
-
-    public String getAdType() {
-        return adType;
-    }
-
-    public void setAdType(String adType) {
-        this.adType = adType;
-    }
-
-    public String getLocationType() {
-        return locationType;
-    }
-
-    public void setLocationType(String locationType) {
-        this.locationType = locationType;
-    }
-
-    public Integer getOrder() {
-        return order;
-    }
-
-    public void setOrder(Integer order) {
-        this.order = order;
-    }
-
-    public Date getCreateDate() {
-        return createDate;
-    }
-
-    public void setCreateDate(Date createDate) {
-
-        this.createDate = createDate;
-    }
-
-    public Long getId() {
-        return id;
-    }
-
-    public void setId(Long id) {
-        this.id = id;
-    }
-
-    public String getMediaPreview() {
-        return mediaPreview;
-    }
-
-    public void setMediaPreview(String mediaPreview) {
-        this.mediaPreview = mediaPreview;
-    }
-
+    @ApiModelProperty(value = "播放时机器状态,0:默认,1:待机状态,2:工作状态")
+    private String playTimeStatus;
 
 }