Browse Source

情报板增加批量发布

develop
Mr.Wang 9 months ago
parent
commit
3a0833e9c6
  1. 10
      zc-business/src/main/java/com/zc/business/controller/DcBoardController.java
  2. 20
      zc-business/src/main/java/com/zc/business/domain/DcBoardPublish.java
  3. 10
      zc-business/src/main/java/com/zc/business/service/IDcBoardService.java
  4. 130
      zc-business/src/main/java/com/zc/business/service/impl/DcBoardServiceImpl.java

10
zc-business/src/main/java/com/zc/business/controller/DcBoardController.java

@ -39,6 +39,16 @@ public class DcBoardController {
return dcBoardService.publish(dcBoardPublish); return dcBoardService.publish(dcBoardPublish);
} }
/**
* 情报板批量发布
*/
@ApiOperation("情报板批量发布")
// @PreAuthorize("@ss.hasPermi('business:board:publish')")
@PostMapping("/batch/publish")
public AjaxResult batchPublish(@RequestBody DcBoardPublish dcBoardPublish){
return dcBoardService.batchPublish(dcBoardPublish);
}
/** /**
* 情报板回读 * 情报板回读

20
zc-business/src/main/java/com/zc/business/domain/DcBoardPublish.java

@ -1,21 +1,14 @@
package com.zc.business.domain; 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.ApiModel;
import io.swagger.annotations.ApiModelProperty; 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.List;
import java.util.Map; import java.util.Map;
/** /**
* 情报板发布对象 * 情报板发布对象
* *
* @author ruoyi * @author ruoyi
* @date 2024-01-05 * @date 2024-01-05
*/ */
@ -26,6 +19,9 @@ public class DcBoardPublish
@ApiModelProperty(value = "设备id", required = true) @ApiModelProperty(value = "设备id", required = true)
private String deviceId; private String deviceId;
@ApiModelProperty(value = "设备id列表")
private List<String> deviceIdList;
@ApiModelProperty(value = "内容列表", required = true) @ApiModelProperty(value = "内容列表", required = true)
private List<Map<String,Object>> content; private List<Map<String,Object>> content;
@ -37,6 +33,14 @@ public class DcBoardPublish
this.deviceId = deviceId; this.deviceId = deviceId;
} }
public List<String> getDeviceIdList() {
return deviceIdList;
}
public void setDeviceIdList(List<String> deviceIdList) {
this.deviceIdList = deviceIdList;
}
public List<Map<String, Object>> getContent() { public List<Map<String, Object>> getContent() {
return content; return content;
} }

10
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.ruoyi.common.core.domain.AjaxResult;
import com.zc.business.domain.DcBoardPublish; import com.zc.business.domain.DcBoardPublish;
import java.util.List;
import java.util.Map;
/** /**
* 情报板Service接口 * 情报板Service接口
* *
* @author ruoyi * @author ruoyi
* @date 2024-01-03 * @date 2024-01-03
*/ */
@ -20,6 +17,11 @@ public interface IDcBoardService
*/ */
AjaxResult publish(DcBoardPublish dcBoardPublish); AjaxResult publish(DcBoardPublish dcBoardPublish);
/**
* 情报板批量发布
*/
AjaxResult batchPublish(DcBoardPublish dcBoardPublish);
/** /**
* 情报板回读 * 情报板回读
*/ */

130
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.domain.DcDevice;
import com.zc.business.mapper.DcBoardReleaseLogMapper; import com.zc.business.mapper.DcBoardReleaseLogMapper;
import com.zc.business.service.IDcBoardService; import com.zc.business.service.IDcBoardService;
import org.checkerframework.checker.units.qual.A;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.util.ObjectUtils; import org.springframework.util.ObjectUtils;
import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@ -162,6 +162,134 @@ public class DcBoardServiceImpl implements IDcBoardService {
return ajaxResult; return ajaxResult;
} }
/**
* 情报板批量发布
* @param dcBoardPublish
* @return
*/
@Override
public AjaxResult batchPublish(DcBoardPublish dcBoardPublish) {
// 结果集
List<Map<String,String>> result = new ArrayList<>();
// 设备存在的设备列表
List<DcDevice> dcDeviceList = new ArrayList<>();
if (dcBoardPublish.getDeviceIdList().size() == 0){
return AjaxResult.error("设备id列表为空");
}
if (dcBoardPublish.getContent() == null || dcBoardPublish.getContent().size() == 0){
return AjaxResult.error("下发内容为空");
}
List<String> deviceIdListAll = dcBoardPublish.getDeviceIdList();
deviceIdListAll.forEach(deviceId->{
DcDevice dcDevice = redisCache.getCacheMapValue(RedisKeyConstants.DC_DEVICES, deviceId);
if (dcDevice == null){
Map<String,String> map = new HashMap<>();
map.put("deviceId",deviceId);
map.put("code","0");
map.put("msg","发布失败,设备不存在!");
result.add(map);
}else {
dcDeviceList.add(dcDevice);
}
});
List<Map<String,Object>> contentList = dcBoardPublish.getContent();
for (Map<String, Object> 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<String,String> map = new HashMap<>();
map.put("deviceId",iotDeviceId);
//下发文件名
HashMap<String,Object> 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 情报板回读 * @Description 情报板回读
* *

Loading…
Cancel
Save