From 8a7cc0611ec672887ee843c21e69217aadeee31a Mon Sep 17 00:00:00 2001 From: lau572 <1010031226@qq.com> Date: Mon, 8 Jan 2024 17:57:16 +0800 Subject: [PATCH] =?UTF-8?q?=E6=83=85=E6=8A=A5=E6=9D=BF=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/impl/DcBoardServiceImpl.java | 95 ++++++++++++------- 1 file changed, 59 insertions(+), 36 deletions(-) diff --git a/zc-business/src/main/java/com/zc/business/service/impl/DcBoardServiceImpl.java b/zc-business/src/main/java/com/zc/business/service/impl/DcBoardServiceImpl.java index 1cadf762..217f2d7a 100644 --- a/zc-business/src/main/java/com/zc/business/service/impl/DcBoardServiceImpl.java +++ b/zc-business/src/main/java/com/zc/business/service/impl/DcBoardServiceImpl.java @@ -1,14 +1,17 @@ package com.zc.business.service.impl; import com.alibaba.fastjson.JSON; +import com.ruoyi.common.constant.HttpStatus; import com.ruoyi.common.core.domain.AjaxResult; import com.ruoyi.common.core.domain.model.LoginUser; import com.ruoyi.common.utils.SecurityUtils; import com.ruoyi.common.utils.StringUtils; +import com.zc.business.controller.DcDeviceController; import com.zc.business.domain.DcBoardPublish; import com.zc.business.domain.DcBoardReleaseLog; import com.zc.business.mapper.DcBoardReleaseLogMapper; import com.zc.business.service.IDcBoardService; +import org.checkerframework.checker.units.qual.A; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @@ -29,6 +32,9 @@ public class DcBoardServiceImpl implements IDcBoardService { @Autowired private DcBoardReleaseLogMapper dcBoardReleaseLogMapper; + @Autowired + private DcDeviceController deviceController; + /** * @Description 情报板发布 * @@ -48,42 +54,54 @@ public class DcBoardServiceImpl implements IDcBoardService { String deviceId = dcBoardPublish.getDeviceId(); List> contentList = dcBoardPublish.getContent(); - //TODO 调用控制设备接口 - /* //下发文件名 - Map param = new HashMap<>(); - param.put("size","65535"); - param.put("fileName","play010.lst"); - invokeFunction(deviceId,"11",param); - - //功能码13 下发内容 - param = new HashMap<>(); - param.put("parameters",contentList); - invokeFunction(deviceId,"1B",param); - - //功能码1B 播放 - param = new HashMap<>(); - param.put("fileId","10"); - invokeFunction(deviceId,"13",param);*/ - + AjaxResult ajaxResult = new AjaxResult(); String status = "1"; - //发布记录 - LoginUser loginUser = SecurityUtils.getLoginUser(); - - for (Map content : contentList) { - DcBoardReleaseLog releaseLog = new DcBoardReleaseLog(); - releaseLog.setDeviceId(deviceId); - releaseLog.setReleaseContent(JSON.toJSONString(content)); - releaseLog.setReleaseIp(loginUser.getIpaddr()); - releaseLog.setReleaseStatus(status); - releaseLog.setReleaseUserId(loginUser.getUsername()); - releaseLog.setReleaseUserName(loginUser.getUser().getNickName()); - releaseLog.setReleaseDeptId(loginUser.getDeptId().toString()); - dcBoardReleaseLogMapper.insertDcBoardReleaseLog(releaseLog); + try{ + //下发文件名 + Map param = new HashMap<>(); + param.put("size","65535"); + param.put("fileName","play010.lst"); + ajaxResult = deviceController.invokedFunction(deviceId,"11",param); + if (HttpStatus.SUCCESS == Integer.parseInt(String.valueOf(ajaxResult.get("code")))){ + + //功能码13 下发内容 + param = new HashMap<>(); + param.put("parameters",contentList); + ajaxResult = deviceController.invokedFunction(deviceId,"13",param); + + if (HttpStatus.SUCCESS == Integer.parseInt(String.valueOf(ajaxResult.get("code")))) { + + //功能码1B 播放 + param = new HashMap<>(); + param.put("fileId", "10"); + ajaxResult = deviceController.invokedFunction(deviceId, "1B", param); + } + } + + if (HttpStatus.SUCCESS != Integer.parseInt(String.valueOf(ajaxResult.get("code")))) { + status = "0"; + } + + //发布记录 + LoginUser loginUser = SecurityUtils.getLoginUser(); + + for (Map content : contentList) { + DcBoardReleaseLog releaseLog = new DcBoardReleaseLog(); + releaseLog.setDeviceId(deviceId); + releaseLog.setReleaseContent(JSON.toJSONString(content)); + releaseLog.setReleaseIp(loginUser.getIpaddr()); + releaseLog.setReleaseStatus(status); + releaseLog.setReleaseUserId(loginUser.getUsername()); + releaseLog.setReleaseUserName(loginUser.getUser().getNickName()); + releaseLog.setReleaseDeptId(loginUser.getDeptId().toString()); + dcBoardReleaseLogMapper.insertDcBoardReleaseLog(releaseLog); + } + }catch (Exception e){ + e.printStackTrace(); } - - return AjaxResult.success(); + return ajaxResult; } /** @@ -95,10 +113,15 @@ public class DcBoardServiceImpl implements IDcBoardService { */ public AjaxResult realtimeProperty(String deviceId){ - /*Map param = new HashMap<>(); - param.put("async",false); - invokeFunction(deviceId,"3A",param);*/ + AjaxResult ajaxResult = new AjaxResult(); + try { + Map param = new HashMap<>(); + param.put("async",false); + ajaxResult = deviceController.invokedFunction(deviceId,"3A",param); + } catch (Exception e){ + e.printStackTrace(); + } - return AjaxResult.success(); + return ajaxResult; } }