|
|
@ -1,26 +1,40 @@ |
|
|
|
package com.ccsens.carbasics.mq; |
|
|
|
|
|
|
|
import cn.hutool.core.bean.BeanUtil; |
|
|
|
import cn.hutool.core.collection.CollectionUtil; |
|
|
|
import cn.hutool.core.lang.Snowflake; |
|
|
|
import cn.hutool.core.util.ObjectUtil; |
|
|
|
import cn.hutool.core.util.StrUtil; |
|
|
|
import com.alibaba.fastjson.JSONObject; |
|
|
|
import com.ccsens.carbasics.bean.dto.ButtonDto; |
|
|
|
import com.ccsens.carbasics.bean.dto.PatientDto; |
|
|
|
import com.ccsens.carbasics.bean.po.EquipmentInform; |
|
|
|
import com.ccsens.carbasics.bean.po.EquipmentStatus; |
|
|
|
import com.ccsens.carbasics.bean.po.FirstAid; |
|
|
|
import com.ccsens.carbasics.bean.vo.EquipmentVo; |
|
|
|
import com.ccsens.carbasics.bean.vo.message.ButtonStartVo; |
|
|
|
import com.ccsens.carbasics.bean.vo.message.UpdateStatusVo; |
|
|
|
import com.ccsens.carbasics.persist.dao.*; |
|
|
|
import com.ccsens.carbasics.service.IFirstAidService; |
|
|
|
import com.ccsens.carbasics.util.Constant; |
|
|
|
import com.ccsens.carbasics.util.DefaultCodeError; |
|
|
|
import com.ccsens.util.JacksonUtil; |
|
|
|
import com.ccsens.util.RedisUtil; |
|
|
|
import com.ccsens.util.bean.message.common.InMessage; |
|
|
|
import com.ccsens.util.bean.message.common.MessageConstant; |
|
|
|
import com.ccsens.util.config.RabbitMQConfig; |
|
|
|
import com.ccsens.util.exception.BaseException; |
|
|
|
import com.fasterxml.jackson.core.JsonProcessingException; |
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
import org.springframework.amqp.core.AmqpTemplate; |
|
|
|
import org.springframework.amqp.rabbit.annotation.RabbitHandler; |
|
|
|
import org.springframework.amqp.rabbit.annotation.RabbitListener; |
|
|
|
import org.springframework.stereotype.Component; |
|
|
|
|
|
|
|
import javax.annotation.Resource; |
|
|
|
import java.util.HashSet; |
|
|
|
import java.util.List; |
|
|
|
import java.util.Set; |
|
|
|
|
|
|
|
/** |
|
|
|
* 暴风眼接收qcp一键通知相关消息 |
|
|
@ -47,6 +61,8 @@ public class QcpButtonReceive { |
|
|
|
private EquipmentInformDao equipmentInformDao; |
|
|
|
@Resource |
|
|
|
private FirstAidDao firstAidDao; |
|
|
|
@Resource |
|
|
|
private AmqpTemplate amqpTemplate; |
|
|
|
|
|
|
|
@RabbitHandler |
|
|
|
public void process(String messageJson) throws Exception { |
|
|
@ -78,6 +94,7 @@ public class QcpButtonReceive { |
|
|
|
return; |
|
|
|
} |
|
|
|
redisUtil.set(param.getName()+param.getIdcard(),param.getIdcard(),300); |
|
|
|
|
|
|
|
//根据设备userId查询项目id
|
|
|
|
Long projectId = qcpDao.queryProjectByUserId(param.getUserId()); |
|
|
|
log.info("查询到的项目id:{}",projectId); |
|
|
@ -89,7 +106,17 @@ public class QcpButtonReceive { |
|
|
|
PatientDto.SavePatient savePatient = new PatientDto.SavePatient(); |
|
|
|
BeanUtil.copyProperties(param,savePatient); |
|
|
|
savePatient.setGender(param.getSex()); |
|
|
|
firstAidService.getFirstAid(savePatient,param.getUserId(), (byte) 5,organizationId); |
|
|
|
FirstAid firstAid = firstAidService.getFirstAid(savePatient, param.getUserId(), (byte) 5, organizationId); |
|
|
|
//查询设备信息,并保存状态
|
|
|
|
EquipmentVo.ButtonInfo buttonInfo = qcpDao.queryEquipmentInfoByUserId(param.getUserId()); |
|
|
|
if (ObjectUtil.isNotNull(buttonInfo)) { |
|
|
|
EquipmentStatus equipmentStatus = new EquipmentStatus(); |
|
|
|
equipmentStatus.setId(snowflake.nextId()); |
|
|
|
equipmentStatus.setEquipmentId(buttonInfo.getId()); |
|
|
|
equipmentStatus.setEquipmentStatus((byte) 0); |
|
|
|
equipmentStatus.setFirstAidId(firstAid.getId()); |
|
|
|
equipmentStatus.setTime(System.currentTimeMillis()); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
@ -99,23 +126,111 @@ public class QcpButtonReceive { |
|
|
|
* 一键启动处理 |
|
|
|
* @param param 参数 |
|
|
|
*/ |
|
|
|
public void buttonStart(ButtonDto.ButtonStartMq param) { |
|
|
|
public void buttonStart(ButtonDto.ButtonStartMq param) throws JsonProcessingException { |
|
|
|
log.info("暴风眼一键启动接收到的参数{}",param); |
|
|
|
Long projectId = qcpDao.queryProjectByUserId(param.getUserId()); |
|
|
|
Long organizationId = organizationProjectDao.queryByProjectId(projectId); |
|
|
|
FirstAid firstAid = firstAidDao.queryByOidAndIdcard(organizationId,param.getIdcard()); |
|
|
|
if (ObjectUtil.isNotNull(firstAid)) { |
|
|
|
EquipmentStatus equipmentStatus = new EquipmentStatus(); |
|
|
|
equipmentStatus.setId(snowflake.nextId()); |
|
|
|
//查询设备信息
|
|
|
|
EquipmentVo.ButtonInfo buttonInfo = qcpDao.queryEquipmentInfoByUserId(param.getUserId()); |
|
|
|
if (ObjectUtil.isNotNull(buttonInfo)) { |
|
|
|
Long projectId = qcpDao.queryProjectByUserId(param.getUserId()); |
|
|
|
Long organizationId = organizationProjectDao.queryByProjectId(projectId); |
|
|
|
FirstAid firstAid = firstAidDao.queryByOidAndIdcard(organizationId,param.getIdcard()); |
|
|
|
if (ObjectUtil.isNotNull(firstAid)) { |
|
|
|
EquipmentStatus equipmentStatus = equipmentStatusDao.queryByEidAndFid(buttonInfo.getId(),firstAid.getId()); |
|
|
|
if (ObjectUtil.isNotNull(equipmentStatus)) { |
|
|
|
return; |
|
|
|
} |
|
|
|
EquipmentStatus triageStatus = new EquipmentStatus(); |
|
|
|
triageStatus.setId(snowflake.nextId()); |
|
|
|
triageStatus.setFirstAidId(firstAid.getId()); |
|
|
|
triageStatus.setEquipmentId(buttonInfo.getId()); |
|
|
|
triageStatus.setEquipmentStatus((byte) 1); |
|
|
|
triageStatus.setTime(System.currentTimeMillis()); |
|
|
|
equipmentStatusDao.insertSelective(equipmentStatus); |
|
|
|
//查询医院其他设备
|
|
|
|
List<EquipmentVo.ButtonInfo> buttonInfoList = qcpDao.queryOtherEquipment(buttonInfo.getHospitalId()); |
|
|
|
log.info("查询医院其他设备:{}",buttonInfoList); |
|
|
|
if (CollectionUtil.isNotEmpty(buttonInfoList)) { |
|
|
|
for (EquipmentVo.ButtonInfo info : buttonInfoList) { |
|
|
|
//查询需要发送的消息内容
|
|
|
|
EquipmentInform equipmentInform = equipmentInformDao.queryByType(info.getType()); |
|
|
|
HashSet<String> userSet = new HashSet<>(); |
|
|
|
userSet.add(info.getUserId().toString()); |
|
|
|
ButtonStartVo.Data data = new ButtonStartVo.Data(); |
|
|
|
data.setName(firstAid.getName()); |
|
|
|
data.setContent(equipmentInform.getContent()); |
|
|
|
data.setFirstAidId(firstAid.getId()); |
|
|
|
data.setTotalCountdown(equipmentInform.getTotalCountdown()); |
|
|
|
data.setRealCountdown(System.currentTimeMillis() - param.getTime()); |
|
|
|
data.setTime(equipmentStatus.getTime()); |
|
|
|
ButtonStartVo buttonStartVo = new ButtonStartVo(); |
|
|
|
buttonStartVo.setData(data); |
|
|
|
InMessage inMessage = new InMessage(); |
|
|
|
inMessage.setTos(userSet); |
|
|
|
inMessage.setData(JacksonUtil.beanToJson(buttonStartVo)); |
|
|
|
inMessage.setToDomain(MessageConstant.DomainType.User); |
|
|
|
log.info("一键启动调用消息系统传参{}",inMessage); |
|
|
|
amqpTemplate.convertAndSend(RabbitMQConfig.MESSAGE_QUEUE_NAME,JacksonUtil.beanToJson(inMessage)); |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 修改状态处理 |
|
|
|
* @param param 参数 |
|
|
|
*/ |
|
|
|
public void updateStatus(ButtonDto.UpDateStatusMq param) { |
|
|
|
public void updateStatus(ButtonDto.UpDateStatusMq param) throws JsonProcessingException { |
|
|
|
log.info("暴风眼修改状态接收到的参数{}",param); |
|
|
|
EquipmentVo.ButtonInfo buttonInfo = qcpDao.queryEquipmentInfoByUserId(param.getUserId()); |
|
|
|
if (ObjectUtil.isNull(buttonInfo)) { |
|
|
|
return; |
|
|
|
} |
|
|
|
EquipmentStatus equipmentStatus = equipmentStatusDao.queryByEidAndFidAndStatus(buttonInfo.getId(),param.getFirstAidId(),param.getStatus()); |
|
|
|
if (ObjectUtil.isNotNull(equipmentStatus)) { |
|
|
|
return; |
|
|
|
} |
|
|
|
if (1 == buttonInfo.getType()) { |
|
|
|
if (param.getStatus() ==1 || param.getStatus() == 2) { |
|
|
|
//查询分诊台的设备id
|
|
|
|
List<EquipmentVo.ButtonInfo> triageTableList = qcpDao.queryTriageTable(buttonInfo.getHospitalId()); |
|
|
|
log.info("查询分诊台的设备id列表:{}",triageTableList); |
|
|
|
if (CollectionUtil.isNotEmpty(triageTableList)) { |
|
|
|
HashSet<String> userSet = new HashSet<>(); |
|
|
|
for (EquipmentVo.ButtonInfo triageTable : triageTableList) { |
|
|
|
userSet.add(triageTable.getUserId().toString()); |
|
|
|
//保存分诊台关闭的信息
|
|
|
|
EquipmentStatus triageTableStatus = new EquipmentStatus(); |
|
|
|
triageTableStatus.setId(snowflake.nextId()); |
|
|
|
triageTableStatus.setTime(System.currentTimeMillis()); |
|
|
|
triageTableStatus.setEquipmentStatus((byte) 2); |
|
|
|
triageTableStatus.setEquipmentId(triageTable.getId()); |
|
|
|
triageTableStatus.setFirstAidId(param.getFirstAidId()); |
|
|
|
equipmentStatusDao.insertSelective(triageTableStatus); |
|
|
|
} |
|
|
|
UpdateStatusVo.Data data = new UpdateStatusVo.Data(System.currentTimeMillis(), (byte) 2,param.getFirstAidId()); |
|
|
|
UpdateStatusVo updateStatusVo = new UpdateStatusVo(); |
|
|
|
updateStatusVo.setData(data); |
|
|
|
InMessage inMessage = new InMessage(); |
|
|
|
inMessage.setTos(userSet); |
|
|
|
inMessage.setData(JacksonUtil.beanToJson(updateStatusVo)); |
|
|
|
inMessage.setToDomain(MessageConstant.DomainType.User); |
|
|
|
log.info("更改状态调用消息系统传参{}",inMessage); |
|
|
|
amqpTemplate.convertAndSend(RabbitMQConfig.MESSAGE_QUEUE_NAME,JacksonUtil.beanToJson(inMessage)); |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
//保存设备更改状态的信息
|
|
|
|
EquipmentStatus saveEquipmentStatus = new EquipmentStatus(); |
|
|
|
saveEquipmentStatus.setId(snowflake.nextId()); |
|
|
|
saveEquipmentStatus.setTime(System.currentTimeMillis()); |
|
|
|
saveEquipmentStatus.setEquipmentStatus(param.getStatus()); |
|
|
|
saveEquipmentStatus.setEquipmentId(buttonInfo.getId()); |
|
|
|
saveEquipmentStatus.setFirstAidId(param.getFirstAidId()); |
|
|
|
equipmentStatusDao.insertSelective(saveEquipmentStatus); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|