|
|
@@ -9,13 +9,17 @@ import com.zd.common.core.redis.RedisService;
|
|
|
import com.zd.common.core.utils.DateUtils;
|
|
|
import com.zd.common.core.utils.SaveUtil;
|
|
|
import com.zd.common.core.utils.SecurityUtils;
|
|
|
-import com.zd.common.core.utils.SpringUtils;
|
|
|
import com.zd.laboratory.domain.LabAudioSynthesis;
|
|
|
import com.zd.laboratory.domain.LabExitLight;
|
|
|
import com.zd.laboratory.domain.LabExitLine;
|
|
|
import com.zd.laboratory.domain.LabExitLineJoin;
|
|
|
-import com.zd.laboratory.domain.vo.*;
|
|
|
-import com.zd.laboratory.mapper.*;
|
|
|
+import com.zd.laboratory.domain.vo.LabExitLightVO;
|
|
|
+import com.zd.laboratory.domain.vo.LabExitLineJoinVO;
|
|
|
+import com.zd.laboratory.domain.vo.LabExitLineVO;
|
|
|
+import com.zd.laboratory.mapper.LabAudioSynthesisMapper;
|
|
|
+import com.zd.laboratory.mapper.LabExitLightMapper;
|
|
|
+import com.zd.laboratory.mapper.LabExitLineJoinMapper;
|
|
|
+import com.zd.laboratory.mapper.LabExitLineMapper;
|
|
|
import com.zd.laboratory.mqtt.service.impl.SubMessageSendManager;
|
|
|
import com.zd.laboratory.service.ILabExitLineService;
|
|
|
import com.zd.laboratory.service.ILabSparseHardwareService;
|
|
|
@@ -32,7 +36,6 @@ import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
import java.util.*;
|
|
|
-import java.util.concurrent.TimeUnit;
|
|
|
|
|
|
/**
|
|
|
* 逃生线路主Service业务层处理
|
|
|
@@ -60,8 +63,6 @@ public class LabExitLineServiceImpl implements ILabExitLineService
|
|
|
@Autowired
|
|
|
private SubMessageSendManager messageSendService;
|
|
|
@Autowired
|
|
|
- private LabSubjectMapper labSubjectMapper;
|
|
|
- @Autowired
|
|
|
private LabAudioSynthesisMapper labAudioSynthesisMapper;
|
|
|
@Autowired
|
|
|
private RemoteSpeakService remoteSpeakService;
|
|
|
@@ -195,13 +196,6 @@ public class LabExitLineServiceImpl implements ILabExitLineService
|
|
|
LabExitLineJoin labExitLineJoin = new LabExitLineJoin();
|
|
|
labExitLineJoin.setLightDirection(labExitLineVO.getLightDirection());
|
|
|
labExitLineJoin.setLineId(labExitLineList.get(0).getId());
|
|
|
-// List<LabExitLineJoin> labExitLineJoinList = labExitLineJoinMapper.selectLabExitLineJoinList(labExitLineJoin);
|
|
|
-// Long[] lightIds = new Long[labExitLineJoinList.size()];
|
|
|
-// for(int i=0;i<labExitLineJoinList.size();i++){
|
|
|
-// lightIds[i] = labExitLineJoinList.get(i).getLightId();
|
|
|
-// }
|
|
|
- //删除指引灯继电器数据
|
|
|
-// labExitLightMapper.deleteLabExitLightByIds(lightIds);
|
|
|
//删除线路和指引灯关联关系
|
|
|
labExitLineJoinMapper.deleteLabExitLineJoinByLineId(labExitLineJoin);
|
|
|
//删除线路数据
|
|
|
@@ -232,11 +226,8 @@ public class LabExitLineServiceImpl implements ILabExitLineService
|
|
|
checkMap.put(labExitLightVO.getRelayCode()+""+labExitLightVO.getRelayBit(),labExitLights.get(0));
|
|
|
}else{
|
|
|
LabExitLight labExitLight = new LabExitLight();
|
|
|
-// labExitLight.setSubjectId(labExitLightVO.getSubjectId());
|
|
|
-// labExitLight.setBuildId(labExitLineVO.getBuildId());
|
|
|
labExitLight.setRelayCode(labExitLightVO.getRelayCode());
|
|
|
labExitLight.setRelayBit(labExitLightVO.getRelayBit());
|
|
|
-// labExitLight.setLightDirection(labExitLineVO.getLightDirection());
|
|
|
labExitLight.setLightStatus(1);
|
|
|
labExitLight.setConfigName(labExitLightVO.getConfigName());
|
|
|
labExitLight.setConfigStatus(labExitLightVO.getConfigStatus());
|
|
|
@@ -352,8 +343,8 @@ public class LabExitLineServiceImpl implements ILabExitLineService
|
|
|
try {
|
|
|
Thread.sleep(500);
|
|
|
} catch (InterruptedException e) {
|
|
|
- Thread.currentThread().interrupt();
|
|
|
logger.error("异常信息:", e);
|
|
|
+ Thread.currentThread().interrupt();
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
@@ -404,138 +395,7 @@ public class LabExitLineServiceImpl implements ILabExitLineService
|
|
|
@Override
|
|
|
public List<LabExitLineJoinVO> doChange(Long subId, Integer type) {
|
|
|
|
|
|
- if(redisService.hasKey(CacheConstants.EVACUATION + subId)){
|
|
|
- EvacuationLine evacuationLine = redisService.getCacheObject(CacheConstants.EVACUATION + subId);
|
|
|
- if(type.equals(evacuationLine.getType())){
|
|
|
- //如果相等 取redis的值,不相等就要后续取查
|
|
|
- return evacuationLine.getLineJoins();
|
|
|
- // -1 直接取redis的值
|
|
|
- }else if(type==-1){
|
|
|
- return evacuationLine.getLineJoins();
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- //手动变更疏散线路的时候,如果向左,左侧灯全部亮,向右,右侧灯全部亮,如果两侧,需要查询起始等是否具备两侧疏散
|
|
|
- List<LabExitLineJoinVO> lineJoins;
|
|
|
- if(type==0){
|
|
|
- lineJoins = selectLabExitLineIntelligentGuidance(subId, type);
|
|
|
- if(lineJoins.size() == 0){
|
|
|
- throw new ServiceException("执行疏散未查询到线路!");
|
|
|
- }
|
|
|
- }else{
|
|
|
- LabExitLineJoin labExitLineJoin = new LabExitLineJoin();
|
|
|
- labExitLineJoin.setLightDirection(type);
|
|
|
- labExitLineJoin.setSubjectId(subId);
|
|
|
- lineJoins = labExitLineJoinMapper.selectLabExitFloorAllLine(labExitLineJoin);
|
|
|
- if(lineJoins.size() == 0){
|
|
|
- throw new ServiceException("执行疏散未查询到线路!");
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- // 根据楼层查询指示灯
|
|
|
- List<LabExitLight> allLines = labExitLightMapper.selectLabExitLightList(new LabExitLight());
|
|
|
-
|
|
|
-
|
|
|
- for (int i = 0; i < allLines.size(); i++) {
|
|
|
- for (LabExitLineJoinVO lineJoin : lineJoins) {
|
|
|
- if(lineJoin.getLightId().equals(allLines.get(i).getId())){
|
|
|
- allLines.remove(i);
|
|
|
- i--;
|
|
|
- break;
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- // 先关闭不是疏散的指示灯
|
|
|
- for (LabExitLight allLine : allLines) {
|
|
|
- if(StringUtils.isNotBlank(allLine.getRelayCode()) && allLine.getRelayBit() != null){
|
|
|
-
|
|
|
- if(StringUtils.isBlank(allLine.getConfigName())){
|
|
|
- logger.error("疏散指示灯调用老继电器");
|
|
|
- socketService.sendCommand(Symbol.order.control, allLine.getRelayCode(), Symbol.command.close, allLine.getRelayBit());
|
|
|
- }else {
|
|
|
- logger.error("疏散指示灯调用新继电器");
|
|
|
- socketService.sendMqttCommand(allLine.getRelayCode(), Symbol.command.close, allLine.getRelayBit()+"");
|
|
|
- }
|
|
|
- logger.info("关闭非疏散指示灯:{},{},{}", allLine.getRelayCode(), allLine.getRelayBit(), "发送成功");
|
|
|
-
|
|
|
- try {
|
|
|
- Thread.sleep(500);
|
|
|
- } catch (InterruptedException e) {
|
|
|
- Thread.currentThread().interrupt();
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- // 再打开疏散指示灯
|
|
|
- for (LabExitLineJoinVO lineJoin : lineJoins) {
|
|
|
- if(StringUtils.isNotBlank(lineJoin.getRelayCode()) && StringUtils.isNotBlank(lineJoin.getRelayBit())){
|
|
|
-
|
|
|
- if(StringUtils.isBlank(lineJoin.getConfigName())){
|
|
|
- logger.error("疏散指示灯调用老继电器");
|
|
|
- socketService.sendCommand(Symbol.order.control, lineJoin.getRelayCode(), Symbol.command.open, Integer.parseInt(lineJoin.getRelayBit()));
|
|
|
- }else {
|
|
|
- logger.error("疏散指示灯调用新继电器");
|
|
|
- socketService.sendMqttCommand(lineJoin.getRelayCode(), Symbol.command.open, lineJoin.getRelayBit());
|
|
|
- }
|
|
|
-
|
|
|
- logger.info("打开疏散指示灯:{},{},{}", lineJoin.getRelayCode(), lineJoin.getRelayBit(), "发送成功");
|
|
|
- try {
|
|
|
- Thread.sleep(500);
|
|
|
- } catch (Exception e) {
|
|
|
- logger.error("打开疏散指示灯异常", e);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- EvacuationLine evacuationLine = new EvacuationLine();
|
|
|
- evacuationLine.setType(type);
|
|
|
- evacuationLine.setLineJoins(lineJoins);
|
|
|
-
|
|
|
- redisService.setCacheObject(CacheConstants.EVACUATION + subId, evacuationLine,1L, TimeUnit.DAYS);
|
|
|
- //mqtt推送消息
|
|
|
- Map exitLineMap = new HashMap();
|
|
|
- exitLineMap.put("EXIT_LINE_MESSAGE",true);
|
|
|
- messageSendService.SendExitLineUpdate(exitLineMap);
|
|
|
-
|
|
|
- // 这里先写死一个喇叭播报,如果后期需要改动,在重新调整。
|
|
|
- //这里查询预案下的合成音乐
|
|
|
- if(redisService.getCacheObject("subjectByExit"+subId)==null){
|
|
|
- try{
|
|
|
- LabAudioSynthesis audioSyn = new LabAudioSynthesis();
|
|
|
- audioSyn.setSceneType(2);
|
|
|
- List<LabAudioSynthesis> audioSynList = labAudioSynthesisMapper.selectLabAudioSynthesisList(audioSyn);
|
|
|
- if(audioSynList.size()>0){
|
|
|
- LabAudioSynthesis audioSyntheses = audioSynList.get(0);
|
|
|
- //获取喇叭列表
|
|
|
- Integer count = labSparseHardwareService.selectSpeakerCount();
|
|
|
- logger.info("查询喇叭总数:{}",count);
|
|
|
- R deviceList = remoteSpeakService.getDeviceList(1,count + 10, 5L);
|
|
|
- if(deviceList.getCode()==200){
|
|
|
- List<Map<String,Object>> mapList = (List <Map <String, Object>>) deviceList.getData();
|
|
|
-
|
|
|
- for(Map<String,Object> map:mapList){
|
|
|
- logger.info("喇叭日志============================="+map);
|
|
|
- if(com.zd.common.core.utils.StringUtils.isNotNull(map.get("deviceSn")) && com.zd.common.core.utils.StringUtils.isNotNull(map.get("port"))){
|
|
|
- List<PlayVo> playVoList = new ArrayList<>();
|
|
|
- PlayVo playVo = new PlayVo();
|
|
|
- playVo.setSn(map.get("deviceSn")+"");
|
|
|
- playVo.setDeviceIp(map.get("deviceIp")+"");
|
|
|
- playVo.setPort(Integer.parseInt(map.get("port")+""));
|
|
|
- ParamVo paramVo=new ParamVo();
|
|
|
- paramVo.setVol(Integer.parseInt(map.get("deviceVol").toString()));
|
|
|
- playVo.setParams(paramVo);
|
|
|
- playVoList.add(playVo);
|
|
|
- remoteSpeakService.textParseUrlAppIps(audioSyntheses.getNewMusicUrl(),playVoList);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
- }
|
|
|
- }catch (Exception e){
|
|
|
- logger.error("开启喇叭异常!{}",e);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
+ List<LabExitLineJoinVO> lineJoins = new ArrayList <>();
|
|
|
return lineJoins;
|
|
|
}
|
|
|
|