浏览代码

25寸屏添加演示模式

wangwx 2 年之前
父节点
当前提交
a34706f50e

+ 10 - 0
ruoyi-system25/src/main/java/com/ruoyi/advertiser25/controller/ScreenMaterialController.java

@@ -79,4 +79,14 @@ public class ScreenMaterialController extends BaseController {
         return materialService.passMaterial(Material25);
     }
 
+    @GetMapping("/demo/{id}")
+    public AjaxResult demo(@PathVariable Long id){
+        return materialService.demo(id);
+    }
+
+    @GetMapping("/getDemoPic")
+    public AjaxResult getDemoPic(){
+        return materialService.getDemoPic();
+    }
+
 }

+ 0 - 79
ruoyi-system25/src/main/java/com/ruoyi/advertiser25/domain/AdFirmwareUpgrade25.java

@@ -1,79 +0,0 @@
-package com.ruoyi.advertiser25.domain;
-
-import com.fasterxml.jackson.annotation.JsonFormat;
-import com.ruoyi.common.annotation.Excel;
-import com.ruoyi.common.core.domain.BaseEntity;
-import lombok.AllArgsConstructor;
-import lombok.Data;
-import lombok.NoArgsConstructor;
-import lombok.experimental.Accessors;
-
-import java.util.Date;
-
-/**
- * 固件升级 对象 ad_firmware_upgrade
- * 
- * @author caiweigan
- * @date 2022-02-07
- */
-@Data
-@AllArgsConstructor
-@NoArgsConstructor
-@Accessors(chain = true)
-public class AdFirmwareUpgrade25 extends BaseEntity {
-    private static final long serialVersionUID = 1L;
-
-    /**
-     * 升级id
-     */
-    private Long upgradeId;
-
-    /**
-     * 主版本号
-     */
-    @Excel(name = "主版本号")
-    private Integer majorVersion;
-
-    /**
-     * 子版本号
-     */
-    @Excel(name = "子版本号")
-    private Integer subVersion;
-
-    /**
-     * 硬件版本
-     */
-    @Excel(name = "硬件版本")
-    private Integer hardwareVersion;
-
-    /**
-     * 屏幕类型 1元太屏 2日本屏幕
-     */
-    private String screenType;
-
-    /**
-     * 附件
-     */
-    @Excel(name = "附件")
-    private String attachment;
-
-    /**
-     * 发布状态(0未发布 1已发布)
-     */
-    @Excel(name = "发布状态")
-    private String publishStatus;
-
-    /**
-     * 发布类型(0自动发布 1手动发布)
-     */
-    @Excel(name = "发布类型")
-    private String publishType;
-
-    /**
-     * 发布时间
-     */
-    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
-    @Excel(name = "发布时间", width = 30)
-    private Date publishTime;
-
-}

+ 12 - 0
ruoyi-system25/src/main/java/com/ruoyi/advertiser25/mapper/ScreenMaterialMapper.java

@@ -5,6 +5,7 @@ import com.ruoyi.advertiser25.domain.dto.MaterialUrlDto25;
 import org.apache.ibatis.annotations.Param;
 
 import java.util.List;
+import java.util.Map;
 
 /**
  * 广告素材 Mapper接口
@@ -67,4 +68,15 @@ public interface ScreenMaterialMapper {
      * @return
      */
     List<MaterialUrlDto25> selectMaterialListForPublic();
+
+    /**
+     * 说明:添加演示图片
+     * @param pic 素材信息
+     * @return
+     */
+    int insertDemoPic(Material25 pic);
+
+    int updateDemoPic();
+
+    Map selectDemoPic();
 }

+ 3 - 0
ruoyi-system25/src/main/java/com/ruoyi/advertiser25/service/IScreenMaterialService.java

@@ -60,4 +60,7 @@ public interface IScreenMaterialService {
      */
     AjaxResult passMaterial(Material25 material25);
 
+    AjaxResult demo(Long id);
+    AjaxResult getDemoPic();
+
 }

+ 23 - 1
ruoyi-system25/src/main/java/com/ruoyi/advertiser25/service/impl/ScreenMaterialServiceImpl.java

@@ -57,7 +57,14 @@ public class ScreenMaterialServiceImpl implements IScreenMaterialService {
         material25.setStatus(MaterialStatusEnum25.WAIT_SUBMIT.getCode());
         material25.setCreateBy(SecurityUtils.getUsername());
         material25.setCreateTime(DateUtils.getNowDate());
-        return screenMaterialMapper.insertMaterial(material25);
+        int result = screenMaterialMapper.insertMaterial(material25);
+        // 65525是演示模式的图片,需要跳过
+        if (material25.getId() == 65525L){
+            material25.setId(null);
+            screenMaterialMapper.insertMaterial(material25);
+            screenMaterialMapper.deleteMaterialByIds(new Long[]{65525L});
+        }
+        return result;
     }
 
     @Override
@@ -147,4 +154,19 @@ public class ScreenMaterialServiceImpl implements IScreenMaterialService {
         screenMaterialMapper.updateMaterial(updatedMaterial25);
         return AjaxResult.success("签名成功!");
     }
+
+    @Override
+    public AjaxResult demo(Long id){
+        screenMaterialMapper.updateDemoPic();
+        Material25 pic = screenMaterialMapper.selectMaterialById(id);
+        pic.setCreateBy(SecurityUtils.getUsername());
+        pic.setCreateTime(DateUtils.getNowDate());
+        screenMaterialMapper.insertDemoPic(pic);
+        return AjaxResult.success();
+    }
+
+    @Override
+    public AjaxResult getDemoPic(){
+        return AjaxResult.success(screenMaterialMapper.selectDemoPic());
+    }
 }

+ 4 - 2
ruoyi-system25/src/main/java/com/ruoyi/mcu25/constant/McuOtherConstant25.java

@@ -11,7 +11,9 @@ public interface McuOtherConstant25 {
     byte BEAT_PACKAGE_REPLY_LABEL_NUM = 0x0A;
     /** 心跳回复包 软件版本+硬件版本+心跳周期设置+刷图周期+crc16+包尾 长度 */
     byte BEAT_PACKAGE_REPLY_ELSE_LENGTH = 0x09;
-    /** SE业务回复包 标签数量 */
-    byte SE_PACKAGE_REPLY_LABEL_NUM = 0x07;
 
+    /** 演示模式 心跳包回复包 标签数量 */
+    byte BEAT_PACKAGE_REPLY_LABEL_NUM_1 = 0x06;
+    /** 演示模式 心跳回复包 软件版本+硬件版本+crc16+包尾 长度 */
+    byte BEAT_PACKAGE_REPLY_ELSE_LENGTH_1 = 0x05;
 }

+ 8 - 2
ruoyi-system25/src/main/java/com/ruoyi/mcu25/server/DealChannel25.java

@@ -149,8 +149,14 @@ public class DealChannel25 {
 
         // 上行心跳包 0x01
         if (beatPack.getPackageType() == McuBeatPackTypeConstant25.UP_BEAT_PACKAGE_TYPE) {
-            // 处理心跳包
-            responseBytes = dealServer25.upBeatReply(beatPack);
+            // 处理心跳包-工作状态 0:默认模式 1:投屏模式
+            int workType = beatPack.getDeviceInfo().getDevWorkStatus();
+            if (workType == 0){
+                responseBytes = dealServer25.upBeatReply(beatPack);
+            }
+            if (workType == 1){
+                responseBytes = dealServer25.upBeatReply1(beatPack);
+            }
         }
 
         // 图片文件传输包 0x05----25寸使用http请求

+ 196 - 15
ruoyi-system25/src/main/java/com/ruoyi/mcu25/server/DealServer25.java

@@ -4,19 +4,18 @@ import cn.hutool.core.convert.Convert;
 import cn.hutool.core.io.file.FileReader;
 import cn.hutool.core.util.CharsetUtil;
 import cn.hutool.core.util.IdUtil;
-import com.ruoyi.advertiser25.domain.AdFirmwareUpgrade25;
 import com.ruoyi.advertiser25.domain.AdHandle25;
 import com.ruoyi.advertiser25.domain.AdHeartbeatData25;
+import com.ruoyi.advertiser25.domain.Upgrade25;
 import com.ruoyi.advertiser25.domain.dto.CarouselPlanRedisDto25;
 import com.ruoyi.advertiser25.domain.dto.ImageBindDto;
-import com.ruoyi.advertiser25.service.IScreenDeviceService;
-import com.ruoyi.advertiser25.service.IDeviceHeartbeatService;
-import com.ruoyi.advertiser25.service.IRotationPlanService;
-import com.ruoyi.advertiser25.service.ISysParamService;
+import com.ruoyi.advertiser25.mapper.ScreenMaterialMapper;
+import com.ruoyi.advertiser25.service.*;
 import com.ruoyi.common.config.RuoYiConfig;
 import com.ruoyi.common.utils.DateUtils;
 import com.ruoyi.common.utils.StringUtils;
 import com.ruoyi.mcu25.config.McuSm4KeyConfig25;
+import com.ruoyi.mcu25.config.McuSocketConfig25;
 import com.ruoyi.mcu25.constant.*;
 import com.ruoyi.mcu25.domain.AdHeartBeatPackage25;
 import com.ruoyi.mcu25.domain.AdMessageBody25;
@@ -57,6 +56,15 @@ public class DealServer25 {
     @Resource(name= "deviceHeartbeatServiceImpl")
     private IDeviceHeartbeatService adHeartbeatDataService;
 
+    @Resource
+    private IUpgradeService upgradeService;
+
+    @Resource
+    private McuSocketConfig25 mcuSocketConfig25;
+
+    @Resource
+    private ScreenMaterialMapper screenMaterialMapper;
+
     /**
      * 处理心跳包
      * @param beatPack
@@ -153,18 +161,21 @@ public class DealServer25 {
         info[i++] = (byte) ((msgLen >> 8) & 0xff);
         info[i++] = (byte) ((msgLen) & 0xff);
         // 根据屏幕类型、硬件版本查询最新的固件包
-        AdFirmwareUpgrade25 adFirmwareUpgrade25 = null;
+        String screenType = Convert.toHex(equipmentType);
+        Integer hardwareVersion = Integer.parseInt(Integer.toHexString(beatPack.getDeviceInfo().getHw())) ;
+        Upgrade25 param = new Upgrade25().setScreenType(screenType).setHardwareVersion(hardwareVersion).setPublishStatus("1");
+        Upgrade25 upgrade25 = upgradeService.selectLatestFirmware(param);
         // 硬件版本
         info[i++] = McuBeatPackTagConstant25.TAG_DEV_HW_REV;
         info[i++] = 0x00;
         info[i++] = 0x01;
-        info[i++] = 0x10;
+        info[i++] = upgrade25 != null ? Convert.hexToBytes(upgrade25.getHardwareVersion().toString())[0] : 0x10;
         // 软件版本:如果没有固件包,就不传
-        if (adFirmwareUpgrade25 != null) {
+        if (upgrade25 != null) {
             info[i++] = McuBeatPackTagConstant25.TAG_DEV_SW_REV;
             info[i++] = 0x00;
             info[i++] = 0x01;
-            String softwareVersion = adFirmwareUpgrade25.getMajorVersion().toString() + adFirmwareUpgrade25.getSubVersion().toString();
+            String softwareVersion = upgrade25.getMajorVersion().toString() + upgrade25.getSubVersion().toString();
             info[i++] = Convert.hexToBytes(softwareVersion)[0];
         }
         // 心跳周期
@@ -282,6 +293,176 @@ public class DealServer25 {
         return crc16Data;
     }
 
+    /**
+     * 演示模式的上行心跳
+     * @param beatPack
+     * @return
+     */
+    public byte[] upBeatReply1(AdHeartBeatPackage25 beatPack) {
+        String imei=beatPack.getImeiStr();
+
+        //如果数据库没有拉手数据,则不回复心跳。忽略该条心跳数据
+        AdHandle25 adHandle25Local = adHandleService.selectAdHandleByImei(imei);
+        if(adHandle25Local ==null){
+            log.info("数据库没有此拉手数据:" + imei);
+            return null;
+        }
+        AdHandle25 adHandle25 =null;
+        try {
+            // 存储心跳数据
+            AdHeartbeatData25 adHeartbeatData25 = decodingAdHeartbeatData(beatPack.getDeviceInfo());
+            // 不需要保存首位的0
+            adHeartbeatData25.setImei(imei);
+            //存入数据库
+            adHeartbeatDataService.insertAdHeartbeatData(adHeartbeatData25);
+            // 根据心跳修改拉手信息
+            adHandle25 = new AdHandle25();
+            // 15位的imei
+            adHandle25.setImei(adHeartbeatData25.getImei());
+            adHandle25.setIccid(adHeartbeatData25.getIccid());
+            adHandle25.setOnlineStatus("1");
+            adHandle25.setSoftwareVersion(adHeartbeatData25.getSw());
+            adHandle25.setHardwareVersion(adHeartbeatData25.getHw());
+            adHandle25.setUpdateTime(new Date());
+            try {
+                adHandleService.updateHandleByHeartbeat(adHandle25);
+            }catch(Exception e2){
+                log.error("更新拉手信息发生错误:adHandle:{}", adHandle25);
+            }
+        } catch (Exception e) {
+            log.error("数据转换异常:", e);
+        }
+
+        log.info("已接收到MCU发来的普通心跳包,开始解析并回复心跳包。。。<br/>");
+
+        //获取演示模式图片
+        Map imageSeq = screenMaterialMapper.selectDemoPic();
+
+        // 获取音频--@TODO
+        Map audioSeq = imageSeq;
+
+        // 服务器地址
+        byte[] downHttpSeq = Convert.hexToBytes(Convert.toHex(mcuSocketConfig25.getHttpServer(), CharsetUtil.CHARSET_UTF_8));
+
+        int imgLen = 1 * 4 * 2; // 图片序号4字节+创建时间2字节
+        int audLen = 1 * 4 * 2; // 音频长度
+        int len = imgLen + audLen + downHttpSeq.length + 1;
+
+        byte[] info = new byte[len + 3000];
+        int i = 0; // info数组下标
+        // 包头
+        info[i++] = McuBeatPackHeadAndTailConstant25.PACKAGE_HEAD;
+        // IMEI
+        byte[] imeiByte = DataTransitionUtil25.intsToBytes(beatPack.getIMEI());
+        System.arraycopy(imeiByte, 0, info, i, imeiByte.length);
+        i += imeiByte.length;
+        // 协议版本
+        info[i++] = 0x10;
+        // 设备类型
+        byte[] equipmentType = DataTransitionUtil25.intsToBytes(beatPack.getEquipmentType());
+        System.arraycopy(equipmentType, 0, info, i, equipmentType.length);
+        i += equipmentType.length;
+        // 包序号
+        info[i++] = (byte) ((beatPack.getPackageSeq() >> 8) & 0xff);
+        info[i++] = (byte) (beatPack.getPackageSeq() & 0xff);
+        // 标识
+        info[i++] = McuBeatIdentificationConstant25.BEAT_IDENTIFICATION_0X00;
+        // 包类型
+        info[i++] = McuBeatPackTypeConstant25.DOWN_BEAT_PACKAGE_TYPE;
+        // 心跳包回复标签数量
+        info[i++] = McuOtherConstant25.BEAT_PACKAGE_REPLY_LABEL_NUM_1;
+        // 消息体长度
+        int msgLen = len + McuOtherConstant25.BEAT_PACKAGE_REPLY_ELSE_LENGTH_1;
+        int msgLenIndex = i; //消息体长度下标
+        info[i++] = (byte) ((msgLen >> 8) & 0xff);
+        info[i++] = (byte) ((msgLen) & 0xff);
+        // 根据屏幕类型、硬件版本查询最新的固件包
+        String screenType = Convert.toHex(equipmentType);
+        Integer hardwareVersion = Integer.parseInt(Integer.toHexString(beatPack.getDeviceInfo().getHw())) ;
+        Upgrade25 param = new Upgrade25().setScreenType(screenType).setHardwareVersion(hardwareVersion).setPublishStatus("1");
+        Upgrade25 upgrade25 = upgradeService.selectLatestFirmware(param);
+        // 硬件版本
+        info[i++] = McuBeatPackTagConstant25.TAG_DEV_HW_REV;
+        info[i++] = 0x00;
+        info[i++] = 0x01;
+        info[i++] = upgrade25 != null ? Convert.hexToBytes(upgrade25.getHardwareVersion().toString())[0] : 0x10;
+        // 软件版本:如果没有固件包,就不传
+        if (upgrade25 != null) {
+            info[i++] = McuBeatPackTagConstant25.TAG_DEV_SW_REV;
+            info[i++] = 0x00;
+            info[i++] = 0x01;
+            String softwareVersion = upgrade25.getMajorVersion().toString() + upgrade25.getSubVersion().toString();
+            info[i++] = Convert.hexToBytes(softwareVersion)[0];
+        }
+
+        // 服务器端设备绑定图片列表-25寸
+        info[i++] = McuBeatPackTagConstant25.TAG_DEV_SERVER_IMAGE_INFO_25;
+        int bindiImageNum = 1; // 图片数量
+        int lenTag0E = bindiImageNum * 4 * 2 + 2;
+        info[i++] = (byte) ((lenTag0E >> 8) & 0xff);
+        info[i++] = (byte) ((lenTag0E) & 0xff);
+
+        info[i++] = (byte) ((bindiImageNum >> 8) & 0xff);
+        info[i++] = (byte) ((bindiImageNum) & 0xff);
+
+        int picId = Integer.valueOf(imageSeq.get("regId").toString());
+        info[i++] = (byte) ((picId >> 24) & 0xff);
+        info[i++] = (byte) ((picId >> 16) & 0xff);
+        info[i++] = (byte) ((picId >> 8) & 0xff);
+        info[i++] = (byte) ((picId) & 0xff);
+        byte[] picTime = Convert.hexToBytes(imageSeq.get("signTime").toString());
+        info[i++] = picTime[0];
+        info[i++] = picTime[1];
+        info[i++] = picTime[2];
+        info[i++] = picTime[3];
+
+        // 绑定音频列表
+        info[i++] = McuBeatPackTagConstant25.TAG_DEV_SERVER_AUDIO_INFO;
+        int bindAudioNum = 1; // 图片数量
+        int lenTag13 = bindAudioNum * 4 * 2 + 2;
+        info[i++] = (byte) ((lenTag13 >> 8) & 0xff);
+        info[i++] = (byte) ((lenTag13) & 0xff);
+
+        info[i++] = (byte) ((bindAudioNum >> 8) & 0xff);
+        info[i++] = (byte) ((bindAudioNum) & 0xff);
+
+        int audId = Integer.valueOf(imageSeq.get("regId").toString());
+        info[i++] = (byte) ((audId >> 24) & 0xff);
+        info[i++] = (byte) ((audId >> 16) & 0xff);
+        info[i++] = (byte) ((audId >> 8) & 0xff);
+        info[i++] = (byte) ((audId) & 0xff);
+        byte[] audTime = Convert.hexToBytes(imageSeq.get("signTime").toString());
+        info[i++] = audTime[0];
+        info[i++] = audTime[1];
+        info[i++] = audTime[2];
+        info[i++] = audTime[3];
+
+        // 绑定 HTTP 服务器地址
+        info[i++] = McuBeatPackTagConstant25.TAG_DEV_SERVER_DOWN_HTTP;
+        int downHttpNum = downHttpSeq.length; // 图片数量
+        int lenTag25 = downHttpNum + 2;
+        info[i++] = (byte) ((lenTag25 >> 8) & 0xff);
+        info[i++] = (byte) ((lenTag25) & 0xff);
+
+        info[i++] = (byte) ((downHttpNum >> 8) & 0xff);
+        info[i++] = (byte) ((downHttpNum) & 0xff);
+        System.arraycopy(downHttpSeq, 0, info, i, downHttpSeq.length);
+        i += downHttpSeq.length;
+        // 工作模式设置
+        info[i++] = McuBeatPackTagConstant25.TAG_DEV_WORK_STATUS;
+        info[i++] = (byte) (0x00);
+        info[i++] = (byte) (0x03);
+        info[i++] = (byte) (0x00);
+
+        // end
+
+        info[msgLenIndex++] = (byte) (((i - 19) >> 8) & 0xff);
+        info[msgLenIndex++] = (byte) (((i - 19)) & 0xff);
+
+        byte[] crc16Data = getCrc16Data(i, info, beatPack, msgLenIndex);
+        return crc16Data;
+    }
+
     private AdHeartbeatData25 decodingAdHeartbeatData(AdMessageBody25 messageBody) {
         AdHeartbeatData25 obj = new AdHeartbeatData25();
         obj.setCsq(messageBody.getCsq());
@@ -620,19 +801,19 @@ public class DealServer25 {
             return  BaseTag25.reply(beatPack, McuBeatIdentificationConstant25.BEAT_IDENTIFICATION_0X80,
                     McuBeatPackTypeConstant25.UPGRADE_PACKAGE_TYPE, tagList);
         }
-        // 固件包下载
 
+        // 固件包下载
         log.info("imei:{},下载升级包数据,当前包序号为:{}。。。<br/>", imei, beatPack.getPackageSeq());
         // 根据屏幕类型、硬件版本查询最新的固件包
         AdMessageBody25 deviceInfo = beatPack.getDeviceInfo();
         String screenType = Convert.toHex(DataTransitionUtil25.intsToBytes(beatPack.getEquipmentType()));
         Integer hardwareVersion = Integer.parseInt(Integer.toHexString(beatPack.getDeviceInfo().getHw())) ;
-        AdFirmwareUpgrade25 param = new AdFirmwareUpgrade25().setScreenType(screenType).setHardwareVersion(hardwareVersion).setPublishStatus("1");
-        AdFirmwareUpgrade25 adFirmwareUpgrade25 = null;
-        if (adFirmwareUpgrade25 == null) {
+        Upgrade25 param = new Upgrade25().setScreenType(screenType).setHardwareVersion(hardwareVersion).setPublishStatus("1");
+        Upgrade25 upgrade25 = upgradeService.selectLatestFirmware(param);
+        if (upgrade25 == null) {
             return null;
         }
-        String filePath = RuoYiConfig.getProfile() + adFirmwareUpgrade25.getAttachment().replace("/profile", "");
+        String filePath = RuoYiConfig.getProfile() + upgrade25.getAttachment().replace("/profile", "");
         FileReader fileReader = new FileReader(filePath);
         byte[] fileDatas = fileReader.readBytes();
 
@@ -674,7 +855,7 @@ public class DealServer25 {
         resDatas[index++] = McuBeatPackTagConstant25.TAG_DEV_HW_REV;
         resDatas[index++] = 0x00;
         resDatas[index++] = 0x01;
-        resDatas[index++] = Convert.hexToBytes(adFirmwareUpgrade25.getHardwareVersion().toString())[0];
+        resDatas[index++] = Convert.hexToBytes(upgrade25.getHardwareVersion().toString())[0];
         // tlv t:下载升级文件传输
         resDatas[index++] = McuBeatPackTagConstant25.TAG_DEV_UPGRADE_TRANSFER;
         // tlv l:t(0x18)的长度 固件包数据长度 + 6个字节的长度

+ 16 - 4
ruoyi-system25/src/main/java/com/ruoyi/mcu25/server/HttpServer25.java

@@ -3,6 +3,7 @@ package com.ruoyi.mcu25.server;
 import cn.hutool.core.convert.Convert;
 import cn.hutool.core.date.DateUtil;
 import com.ruoyi.advertiser25.domain.Material25;
+import com.ruoyi.advertiser25.mapper.ScreenMaterialMapper;
 import com.ruoyi.advertiser25.service.IScreenMaterialService;
 import com.ruoyi.common.config.RuoYiConfig;
 import com.ruoyi.common.constant.Constants;
@@ -32,6 +33,7 @@ import java.nio.charset.StandardCharsets;
 import java.nio.file.FileSystemException;
 import java.util.Base64;
 import java.util.Locale;
+import java.util.Map;
 import java.util.concurrent.CountDownLatch;
 
 /**
@@ -52,12 +54,13 @@ public class HttpServer25 {
     @Resource
     private IScreenMaterialService materialService;
 
-
+    @Resource
+    private ScreenMaterialMapper screenMaterialMapper;
 
     @GetMapping("/{fileName}")
     public void fileDownload(@PathVariable("fileName") String fileName, HttpServletResponse response, HttpServletRequest request) {
         String ip = IpUtils.getIpAddr(request);
-        log.info("开始--接收到设备心跳!设备ip:{} ----------------------------------------------------------", ip);
+        log.info("开始--设备请求下载!设备ip:{} ----------------------------------------------------------", ip);
         log.info("接收时间:{},接收参数:{},range:{}", DateUtil.now(), fileName, request.getHeader("Range"));
         try {
             // 禁止目录上跳级别
@@ -65,9 +68,15 @@ public class HttpServer25 {
                 throw new Exception(StringUtils.format("文件名称({})非法,不允许下载。 ", fileName));
             }
             String[] file = fileName.split("\\.");
-            Material25 material25 = materialService.selectMaterialById(Long.valueOf(file[0]));
+            String id = file[0];
+            // 演示模式固定下载 65535.GSC
+            if ("65535".equals(id)){
+                Map demoPic = screenMaterialMapper.selectDemoPic();
+                id = demoPic.get("oriId").toString();
+            }
+            Material25 material25 = materialService.selectMaterialById(Long.valueOf(id));
             if (material25 == null || StringUtils.isEmpty(material25.getConvertedFileUrl())){
-                throw new Exception(StringUtils.format("系统未查询到文件:({}),不能下载。 ", fileName));
+                throw new Exception(StringUtils.format("系统未查询到文件:({}),下载失败。 ", fileName));
             }
             // 本地资源路径
             String localPath = RuoYiConfig.getProfile();
@@ -152,6 +161,9 @@ public class HttpServer25 {
     }
 
 
+    /**
+     * 说明:已经不用
+     */
     @PostMapping("/download")
     public String download(@RequestBody HttpServerBean25 data, HttpServletRequest req){
         String ip = IpUtils.getIpAddr(req);

+ 12 - 0
ruoyi-system25/src/main/resources/mapper/advertiser25/ScreenMaterialMapper.xml

@@ -124,4 +124,16 @@
         where id <![CDATA[<=]]> 10 and pic_show = 1 and status = 2 order by pic_sort
     </select>
 
+    <insert id="insertDemoPic" parameterType="com.ruoyi.advertiser25.domain.Material25">
+        insert into n25_material_demo(ori_id, reg_id, file_url, file_type, create_by, create_time, sign_time)
+        values (#{id}, '65535', #{convertedFileUrl}, '1', #{createBy}, #{createTime}, #{signTime});
+    </insert>
+
+    <update id="updateDemoPic">
+        update n25_material_demo set is_delete = 1 where file_type = 1 and is_delete = 0;
+    </update>
+
+    <select id="selectDemoPic" resultType="hashmap">
+        select ori_id as oriId, reg_id as regId, sign_time as signTime from n25_material_demo where file_type = 1 and is_delete = 0;
+    </select>
 </mapper>

+ 15 - 0
ruoyi-ui/src/api/advertising25/material.js

@@ -51,3 +51,18 @@ export function passMaterial(data) {
     data: data
   })
 }
+
+// 设备为演示模式素材
+export function setDemoMaterial(id) {
+  return request({
+    url: '/advertising25/material/demo/'+ id,
+    method: 'get',
+  })
+}
+
+export function getDemoMaterial(){
+  return request({
+    url: '/advertising25/material/getDemoPic',
+    method: 'get'
+  })
+}

+ 7 - 2
ruoyi-ui/src/components/FileUpload/index.vue

@@ -13,9 +13,10 @@
       :headers="headers"
       class="upload-file-uploader"
       ref="fileUpload"
+      :disabled="isDisabled"
     >
       <!-- 上传按钮 -->
-      <el-button size="mini" type="primary">选取文件</el-button>
+      <el-button :disabled="isDisabled" size="mini" type="primary">选取文件</el-button>
       <!-- 上传提示 -->
       <div class="el-upload__tip" slot="tip" v-if="showTip">
         请上传
@@ -31,7 +32,7 @@
         <el-link :href="`${baseUrl}${file.url}`" :underline="false" target="_blank">
           <span class="el-icon-document"> {{ getFileName(file.name) }} </span>
         </el-link>
-        <div class="ele-upload-list__item-content-action">
+        <div v-if="!isDisabled" class="ele-upload-list__item-content-action">
           <el-link :underline="false" @click="handleDelete(index)" type="danger">删除</el-link>
         </div>
       </li>
@@ -62,6 +63,10 @@ export default {
       type: Array,
       default: () => ["doc", "xls", "ppt", "txt", "pdf"],
     },
+    isDisabled:{
+      type:Boolean,
+      default:false
+    },
     // 是否显示提示
     isShowTip: {
       type: Boolean,

+ 5 - 0
ruoyi-ui/src/components/ImageUpload/index.vue

@@ -16,6 +16,7 @@
       :file-list="fileList"
       :on-preview="handlePictureCardPreview"
       :class="{hide: this.fileList.length >= this.limit}"
+      :disabled="isDisabled"
     >
       <i class="el-icon-plus"></i>
     </el-upload>
@@ -63,6 +64,10 @@ export default {
       type: Array,
       default: () => ["png", "jpg", "jpeg"],
     },
+    isDisabled:{
+      type:Boolean,
+      default:false
+    },
     // 是否显示提示
     isShowTip: {
       type: Boolean,

+ 38 - 6
ruoyi-ui/src/views/advertising25/material/index.vue

@@ -33,13 +33,19 @@
       <el-col :span="1.5">
         <el-button type="info" plain icon="el-icon-search" size="mini" @click="handlePreview">预览</el-button>
       </el-col>
+      <el-col :span="1.5">
+        <el-button type="warning" plain icon="el-icon-video-play" size="mini" @click="handleDemo">设为演示图片</el-button>
+      </el-col>
       <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
     </el-row>
 
     <el-row :gutter="10">
       <el-col :span="8" v-for="material in materialList" :key="material.id">
-        <el-card :class="{'active': materialSelected[material.id]}" :body-style="{ width: '100%', height: '366px' }">
+        <el-card :class="{'active': materialSelected[material.id]}" :body-style="{ width: '100%', height: '366px', position: 'relative', 'z-index': '100' }">
           <el-image fit="fit" :src="material.originalPicUrl" @click="handleClick(material.id)" style="width:100%;height: 90%;"></el-image>
+          <div v-if="demoPic == material.id" style="position: absolute; top: 35px; transform:rotate(45deg); right: -10px; background-color: white;">
+            <span>已设为演示图片</span>
+          </div>
           <div>
             <div class="bottom">
               <el-button type="text" class="button" style="color: #f56c6c" @click="handleDeleteOne(material.id)">删除</el-button>
@@ -68,12 +74,12 @@
         <el-row :gutter="24">
           <el-col :span="12">
             <el-form-item label="图片" prop="originalPicUrl">
-              <imageUpload v-model="form.originalPicUrl" :limit="1" :file-size="10" :file-type="['png', 'jpg']" />
+              <imageUpload :isDisabled="form.status == 2" :isShowTip="form.status != 2" v-model="form.originalPicUrl" :limit="1" :file-size="10" :file-type="['png', 'jpg']" />
             </el-form-item>
           </el-col>
           <el-col :span="12">
             <el-form-item label="转换后图片(BMP)" prop="convertedPicUrl">
-              <imageUpload v-model="form.convertedPicUrl" :limit="1" :file-size="10" :file-type="['BMP']" />
+              <imageUpload :isDisabled="form.status == 2" :isShowTip="form.status != 2" v-model="form.convertedPicUrl" :limit="1" :file-size="10" :file-type="['BMP']" />
             </el-form-item>
           </el-col>
         </el-row>
@@ -83,7 +89,7 @@
           </el-col>
           <el-col :span="20">
             <el-form-item label="转换后文件(GSC)" prop="convertedFileUrl">
-              <fileUpload v-model="form.convertedFileUrl" :limit="1" :file-size="10" :file-type="['GSC']"/>
+              <fileUpload :isDisabled="form.status == 2" :isShowTip="form.status != 2"  v-model="form.convertedFileUrl" :limit="1" :file-size="10" :file-type="['GSC']"/>
             </el-form-item>
           </el-col>
         </el-row>
@@ -126,7 +132,16 @@
 </template>
 
 <script>
-import {listMaterial, getMaterial, delMaterial, addMaterial, updateMaterial, passMaterial} from "@/api/advertising25/material";
+import {
+  listMaterial,
+  getMaterial,
+  delMaterial,
+  addMaterial,
+  updateMaterial,
+  passMaterial,
+  setDemoMaterial,
+  getDemoMaterial
+} from "@/api/advertising25/material";
 import ImageUpload from '@/components/ImageUpload';
 import FileUpload from '@/components/FileUpload';
 
@@ -198,15 +213,25 @@ export default {
       // 用于限制快速点击按钮多次提交问题
       isDisabled: false,
       //预览窗体宽度
-      width: ''
+      width: '',
+      demoPic: '',
     };
   },
   created() {
     this.getList();
   },
   methods: {
+    reloadDemoPic(){
+      this.demoPic = ''
+      getDemoMaterial().then(response => {
+        if (response.data){
+          this.demoPic = response.data.oriId;
+        }
+      })
+    },
     /** 查询广告素材 列表 */
     getList() {
+      this.reloadDemoPic();
       this.loading = true;
       this.materialSelected = {};
       this.materialListData = {};
@@ -293,6 +318,13 @@ export default {
       this.convertedPicUrl = convertedPicUrl;
       this.previewOpen = true;
     },
+    handleDemo(){
+      const id = this.ids[0];
+      setDemoMaterial(id).then(response => {
+        this.msgSuccess('设置成功')
+        this.getList()
+      });
+    },
     handlePass(){
       const body = {
         id: this.ids[0]