From c0fe8c8ed645070fc4acd5ec1403f4cf0b0e4086 Mon Sep 17 00:00:00 2001 From: lau572 <1010031226@qq.com> Date: Mon, 26 Feb 2024 10:13:35 +0800 Subject: [PATCH] =?UTF-8?q?=E6=83=85=E6=8A=A5=E6=9D=BF=E5=8F=91=E5=B8=83?= =?UTF-8?q?=E6=97=A5=E5=BF=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/impl/DcBoardServiceImpl.java | 20 +++++++++++++++++-- 1 file changed, 18 insertions(+), 2 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 75228554..c83e7b0d 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 @@ -4,11 +4,14 @@ 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.core.redis.RedisCache; import com.ruoyi.common.utils.SecurityUtils; import com.ruoyi.common.utils.StringUtils; +import com.zc.business.constant.RedisKeyConstants; import com.zc.business.controller.DcDeviceController; import com.zc.business.domain.DcBoardPublish; import com.zc.business.domain.DcBoardReleaseLog; +import com.zc.business.domain.DcDevice; import com.zc.business.mapper.DcBoardReleaseLogMapper; import com.zc.business.service.IDcBoardService; import org.checkerframework.checker.units.qual.A; @@ -35,6 +38,9 @@ public class DcBoardServiceImpl implements IDcBoardService { @Autowired private DcDeviceController deviceController; + @Autowired + private RedisCache redisCache; + /** * @Description 情报板发布 * @@ -52,6 +58,12 @@ public class DcBoardServiceImpl implements IDcBoardService { } String deviceId = dcBoardPublish.getDeviceId(); + + DcDevice dcDevice = redisCache.getCacheMapValue(RedisKeyConstants.DC_DEVICES, deviceId); + if (dcDevice == null){ + return AjaxResult.error("发布失败,设备不存在!"); + } + List> contentList = dcBoardPublish.getContent(); AjaxResult ajaxResult = new AjaxResult(); @@ -83,12 +95,18 @@ public class DcBoardServiceImpl implements IDcBoardService { status = "0"; } + + } catch (Exception e){ + e.printStackTrace(); + status = "0"; + } finally { //发布记录 LoginUser loginUser = SecurityUtils.getLoginUser(); for (Map content : contentList) { DcBoardReleaseLog releaseLog = new DcBoardReleaseLog(); releaseLog.setDeviceId(deviceId); + releaseLog.setDeviceName(dcDevice.getDeviceName()); releaseLog.setReleaseContent(JSON.toJSONString(content)); releaseLog.setReleaseIp(loginUser.getIpaddr()); releaseLog.setReleaseStatus(status); @@ -98,8 +116,6 @@ public class DcBoardServiceImpl implements IDcBoardService { releaseLog.setPlatform(loginUser.getUser().getUserType()); dcBoardReleaseLogMapper.insertDcBoardReleaseLog(releaseLog); } - }catch (Exception e){ - e.printStackTrace(); } return ajaxResult;