From 3a0833e9c6e6be66fa7939485ca618706c1cbff6 Mon Sep 17 00:00:00 2001 From: "Mr.Wang" Date: Thu, 7 Mar 2024 15:04:59 +0800 Subject: [PATCH] =?UTF-8?q?=E6=83=85=E6=8A=A5=E6=9D=BF=E5=A2=9E=E5=8A=A0?= =?UTF-8?q?=E6=89=B9=E9=87=8F=E5=8F=91=E5=B8=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/DcBoardController.java | 10 ++ .../zc/business/domain/DcBoardPublish.java | 20 +-- .../zc/business/service/IDcBoardService.java | 10 +- .../service/impl/DcBoardServiceImpl.java | 130 +++++++++++++++++- 4 files changed, 157 insertions(+), 13 deletions(-) diff --git a/zc-business/src/main/java/com/zc/business/controller/DcBoardController.java b/zc-business/src/main/java/com/zc/business/controller/DcBoardController.java index 2916248e..33916c96 100644 --- a/zc-business/src/main/java/com/zc/business/controller/DcBoardController.java +++ b/zc-business/src/main/java/com/zc/business/controller/DcBoardController.java @@ -39,6 +39,16 @@ public class DcBoardController { return dcBoardService.publish(dcBoardPublish); } + /** + * 情报板批量发布 + */ + @ApiOperation("情报板批量发布") +// @PreAuthorize("@ss.hasPermi('business:board:publish')") + @PostMapping("/batch/publish") + public AjaxResult batchPublish(@RequestBody DcBoardPublish dcBoardPublish){ + return dcBoardService.batchPublish(dcBoardPublish); + } + /** * 情报板回读 diff --git a/zc-business/src/main/java/com/zc/business/domain/DcBoardPublish.java b/zc-business/src/main/java/com/zc/business/domain/DcBoardPublish.java index b9aa0ac8..62163cff 100644 --- a/zc-business/src/main/java/com/zc/business/domain/DcBoardPublish.java +++ b/zc-business/src/main/java/com/zc/business/domain/DcBoardPublish.java @@ -1,21 +1,14 @@ package com.zc.business.domain; -import com.fasterxml.jackson.annotation.JsonFormat; -import com.ruoyi.common.annotation.Excel; -import com.ruoyi.common.core.domain.BaseEntity; -import io.swagger.annotations.ApiImplicitParam; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; -import org.apache.commons.lang3.builder.ToStringBuilder; -import org.apache.commons.lang3.builder.ToStringStyle; -import java.util.Date; import java.util.List; import java.util.Map; /** * 情报板发布对象 - * + * * @author ruoyi * @date 2024-01-05 */ @@ -26,6 +19,9 @@ public class DcBoardPublish @ApiModelProperty(value = "设备id", required = true) private String deviceId; + @ApiModelProperty(value = "设备id列表") + private List deviceIdList; + @ApiModelProperty(value = "内容列表", required = true) private List> content; @@ -37,6 +33,14 @@ public class DcBoardPublish this.deviceId = deviceId; } + public List getDeviceIdList() { + return deviceIdList; + } + + public void setDeviceIdList(List deviceIdList) { + this.deviceIdList = deviceIdList; + } + public List> getContent() { return content; } diff --git a/zc-business/src/main/java/com/zc/business/service/IDcBoardService.java b/zc-business/src/main/java/com/zc/business/service/IDcBoardService.java index 44e70026..d1c451ed 100644 --- a/zc-business/src/main/java/com/zc/business/service/IDcBoardService.java +++ b/zc-business/src/main/java/com/zc/business/service/IDcBoardService.java @@ -3,12 +3,9 @@ package com.zc.business.service; import com.ruoyi.common.core.domain.AjaxResult; import com.zc.business.domain.DcBoardPublish; -import java.util.List; -import java.util.Map; - /** * 情报板Service接口 - * + * * @author ruoyi * @date 2024-01-03 */ @@ -20,6 +17,11 @@ public interface IDcBoardService */ AjaxResult publish(DcBoardPublish dcBoardPublish); + /** + * 情报板批量发布 + */ + AjaxResult batchPublish(DcBoardPublish dcBoardPublish); + /** * 情报板回读 */ 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 f1785dba..8a2c0a1f 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 @@ -14,11 +14,11 @@ 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; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.util.ObjectUtils; +import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -162,6 +162,134 @@ public class DcBoardServiceImpl implements IDcBoardService { return ajaxResult; } + /** + * 情报板批量发布 + * @param dcBoardPublish + * @return + */ + @Override + public AjaxResult batchPublish(DcBoardPublish dcBoardPublish) { + // 结果集 + List> result = new ArrayList<>(); + // 设备存在的设备列表 + List dcDeviceList = new ArrayList<>(); + if (dcBoardPublish.getDeviceIdList().size() == 0){ + return AjaxResult.error("设备id列表为空"); + } + if (dcBoardPublish.getContent() == null || dcBoardPublish.getContent().size() == 0){ + return AjaxResult.error("下发内容为空"); + } + + List deviceIdListAll = dcBoardPublish.getDeviceIdList(); + deviceIdListAll.forEach(deviceId->{ + DcDevice dcDevice = redisCache.getCacheMapValue(RedisKeyConstants.DC_DEVICES, deviceId); + if (dcDevice == null){ + Map map = new HashMap<>(); + map.put("deviceId",deviceId); + map.put("code","0"); + map.put("msg","发布失败,设备不存在!"); + result.add(map); + }else { + dcDeviceList.add(dcDevice); + } + }); + + + List> contentList = dcBoardPublish.getContent(); + for (Map content : contentList) { + if (!content.containsKey("ACTION") || ObjectUtils.isEmpty(content.get("ACTION"))){ + return AjaxResult.error("请选择入屏方式!"); + } + if (!content.containsKey("STAY") || ObjectUtils.isEmpty(content.get("STAY"))){ + return AjaxResult.error("请输入停留时长!"); + } + if (!content.containsKey("COLOR") || ObjectUtils.isEmpty(content.get("COLOR"))){ + return AjaxResult.error("请选择字体颜色!"); + } + if (!content.containsKey("CONTENT") || ObjectUtils.isEmpty(content.get("CONTENT"))){ + return AjaxResult.error("请输入内容!"); + } + if (!content.containsKey("FONT") || ObjectUtils.isEmpty(content.get("FONT"))){ + return AjaxResult.error("请选择字体类型!"); + } + if (!content.containsKey("FONT_SIZE") || ObjectUtils.isEmpty(content.get("FONT_SIZE"))){ + return AjaxResult.error("请选择字体大小!"); + } + if (!content.containsKey("formatStyle") || ObjectUtils.isEmpty(content.get("formatStyle"))){ + return AjaxResult.error("请选择对齐方式!"); + } + if (!content.containsKey("height") || ObjectUtils.isEmpty(content.get("height"))){ + return AjaxResult.error("请选择屏幕尺寸!"); + } + if (!content.containsKey("width") || ObjectUtils.isEmpty(content.get("width"))){ + return AjaxResult.error("请选择屏幕尺寸!"); + } + } + + + dcDeviceList.forEach(dcDevice -> { + String iotDeviceId = dcDevice.getIotDeviceId(); + String status = "1"; + try{ + Map map = new HashMap<>(); + map.put("deviceId",iotDeviceId); + //下发文件名 + HashMap param = new HashMap<>(); + param.put("size","65535"); + param.put("fileName","play009.lst"); + AjaxResult ajaxResult11 = deviceController.invokedFunction(iotDeviceId,"11",param); + if (HttpStatus.SUCCESS == Integer.parseInt(String.valueOf(ajaxResult11.get("code")))){ + + //功能码13 下发内容 + param = new HashMap<>(); + param.put("parameters",contentList); + AjaxResult ajaxResult13 = deviceController.invokedFunction(iotDeviceId,"13",param); + + if (HttpStatus.SUCCESS == Integer.parseInt(String.valueOf(ajaxResult13.get("code")))) { + + //功能码1B 播放 + param = new HashMap<>(); + param.put("fileId", "9"); + AjaxResult ajaxResult1B = deviceController.invokedFunction(iotDeviceId, "1B", param); + + if (HttpStatus.SUCCESS != Integer.parseInt(String.valueOf(ajaxResult1B.get("code")))) { + status = "0"; + } + map.put("code",status); + map.put("msg",ajaxResult1B.get("msg").toString()); + result.add(map); + }else { + status = "0"; + map.put("code",status); + map.put("msg",ajaxResult13.get("msg").toString()); + result.add(map); + } + } + + } catch (Exception e){ + e.printStackTrace(); + status = "0"; + } finally { + //发布记录 + LoginUser loginUser = SecurityUtils.getLoginUser(); + DcBoardReleaseLog releaseLog = new DcBoardReleaseLog(); + releaseLog.setDeviceId(iotDeviceId); + releaseLog.setDeviceName(dcDevice.getDeviceName()); + releaseLog.setReleaseContent(JSON.toJSONString(contentList)); + releaseLog.setReleaseIp(loginUser.getIpaddr()); + releaseLog.setReleaseStatus(status); + releaseLog.setReleaseUserId(loginUser.getUsername()); + releaseLog.setReleaseUserName(loginUser.getUser().getNickName()); + releaseLog.setReleaseDeptId(loginUser.getDeptId().toString()); + releaseLog.setPlatform(loginUser.getUser().getUserType()); + dcBoardReleaseLogMapper.insertDcBoardReleaseLog(releaseLog); + } + }); + + + return AjaxResult.success(result); + } + /** * @Description 情报板回读 *