|
@ -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 情报板回读 |
|
|
* |
|
|
* |
|
|