Browse Source

情报板接口

develop
lau572 11 months ago
parent
commit
8a7cc0611e
  1. 95
      zc-business/src/main/java/com/zc/business/service/impl/DcBoardServiceImpl.java

95
zc-business/src/main/java/com/zc/business/service/impl/DcBoardServiceImpl.java

@ -1,14 +1,17 @@
package com.zc.business.service.impl; package com.zc.business.service.impl;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.ruoyi.common.constant.HttpStatus;
import com.ruoyi.common.core.domain.AjaxResult; import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.domain.model.LoginUser; import com.ruoyi.common.core.domain.model.LoginUser;
import com.ruoyi.common.utils.SecurityUtils; import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.common.utils.StringUtils; import com.ruoyi.common.utils.StringUtils;
import com.zc.business.controller.DcDeviceController;
import com.zc.business.domain.DcBoardPublish; import com.zc.business.domain.DcBoardPublish;
import com.zc.business.domain.DcBoardReleaseLog; import com.zc.business.domain.DcBoardReleaseLog;
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;
@ -29,6 +32,9 @@ public class DcBoardServiceImpl implements IDcBoardService {
@Autowired @Autowired
private DcBoardReleaseLogMapper dcBoardReleaseLogMapper; private DcBoardReleaseLogMapper dcBoardReleaseLogMapper;
@Autowired
private DcDeviceController deviceController;
/** /**
* @Description 情报板发布 * @Description 情报板发布
* *
@ -48,42 +54,54 @@ public class DcBoardServiceImpl implements IDcBoardService {
String deviceId = dcBoardPublish.getDeviceId(); String deviceId = dcBoardPublish.getDeviceId();
List<Map<String,Object>> contentList = dcBoardPublish.getContent(); List<Map<String,Object>> contentList = dcBoardPublish.getContent();
//TODO 调用控制设备接口 AjaxResult ajaxResult = new AjaxResult();
/* //下发文件名
Map<String,Object> 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);*/
String status = "1"; String status = "1";
//发布记录 try{
LoginUser loginUser = SecurityUtils.getLoginUser(); //下发文件名
Map<String,Object> param = new HashMap<>();
for (Map<String, Object> content : contentList) { param.put("size","65535");
DcBoardReleaseLog releaseLog = new DcBoardReleaseLog(); param.put("fileName","play010.lst");
releaseLog.setDeviceId(deviceId); ajaxResult = deviceController.invokedFunction(deviceId,"11",param);
releaseLog.setReleaseContent(JSON.toJSONString(content)); if (HttpStatus.SUCCESS == Integer.parseInt(String.valueOf(ajaxResult.get("code")))){
releaseLog.setReleaseIp(loginUser.getIpaddr());
releaseLog.setReleaseStatus(status); //功能码13 下发内容
releaseLog.setReleaseUserId(loginUser.getUsername()); param = new HashMap<>();
releaseLog.setReleaseUserName(loginUser.getUser().getNickName()); param.put("parameters",contentList);
releaseLog.setReleaseDeptId(loginUser.getDeptId().toString()); ajaxResult = deviceController.invokedFunction(deviceId,"13",param);
dcBoardReleaseLogMapper.insertDcBoardReleaseLog(releaseLog);
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<String, Object> 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;
return AjaxResult.success();
} }
/** /**
@ -95,10 +113,15 @@ public class DcBoardServiceImpl implements IDcBoardService {
*/ */
public AjaxResult realtimeProperty(String deviceId){ public AjaxResult realtimeProperty(String deviceId){
/*Map<String,Object> param = new HashMap<>(); AjaxResult ajaxResult = new AjaxResult();
param.put("async",false); try {
invokeFunction(deviceId,"3A",param);*/ Map<String,Object> param = new HashMap<>();
param.put("async",false);
ajaxResult = deviceController.invokedFunction(deviceId,"3A",param);
} catch (Exception e){
e.printStackTrace();
}
return AjaxResult.success(); return ajaxResult;
} }
} }

Loading…
Cancel
Save