|
|
@ -34,6 +34,7 @@ import javax.annotation.Resource; |
|
|
|
import java.util.HashSet; |
|
|
|
import java.util.List; |
|
|
|
import java.util.Set; |
|
|
|
import java.util.stream.Collectors; |
|
|
|
|
|
|
|
/** |
|
|
|
* 暴风眼接收qcp一键通知相关消息 |
|
|
@ -66,22 +67,28 @@ public class QcpButtonReceive { |
|
|
|
private OrganizationMemberDao organizationMemberDao; |
|
|
|
|
|
|
|
@RabbitHandler |
|
|
|
public void process(String messageJson) throws Exception { |
|
|
|
log.info("接收到的消息为:{}",messageJson); |
|
|
|
ButtonDto.CarBasicsMq carBasicsMq = JSONObject.parseObject(messageJson, ButtonDto.CarBasicsMq.class); |
|
|
|
switch (carBasicsMq.getType()){ |
|
|
|
case 0: |
|
|
|
idCardDiscern(carBasicsMq.getIdCardInfoMq()); |
|
|
|
break; |
|
|
|
case 1: |
|
|
|
buttonStart(carBasicsMq.getButtonStartMq()); |
|
|
|
break; |
|
|
|
case 2: |
|
|
|
updateStatus(carBasicsMq.getUpDateStatusMq()); |
|
|
|
break; |
|
|
|
default: |
|
|
|
break; |
|
|
|
public void process(String messageJson){ |
|
|
|
try { |
|
|
|
log.info("接收到的消息为:{}",messageJson); |
|
|
|
ButtonDto.CarBasicsMq carBasicsMq = JSONObject.parseObject(messageJson, ButtonDto.CarBasicsMq.class); |
|
|
|
switch (carBasicsMq.getType()){ |
|
|
|
case 0: |
|
|
|
idCardDiscern(carBasicsMq.getIdCardInfoMq()); |
|
|
|
break; |
|
|
|
case 1: |
|
|
|
buttonStart(carBasicsMq.getButtonStartMq()); |
|
|
|
break; |
|
|
|
case 2: |
|
|
|
updateStatus(carBasicsMq.getUpDateStatusMq()); |
|
|
|
break; |
|
|
|
default: |
|
|
|
break; |
|
|
|
} |
|
|
|
}catch (Exception e) { |
|
|
|
//TODO 待记录异常 程序和人工两方面介入处理
|
|
|
|
log.error("暴风眼接受消息异常",e); |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
@ -107,7 +114,7 @@ public class QcpButtonReceive { |
|
|
|
PatientDto.SavePatient savePatient = new PatientDto.SavePatient(); |
|
|
|
BeanUtil.copyProperties(param,savePatient); |
|
|
|
savePatient.setGender(param.getSex()); |
|
|
|
FirstAid firstAid = firstAidService.getFirstAid(savePatient, param.getUserId(), (byte) 5, organizationId); |
|
|
|
FirstAid firstAid = firstAidService.getFirstAid(savePatient, param.getUserId(), (byte) 5, organizationId, (byte) 1); |
|
|
|
//查询设备信息,并保存状态
|
|
|
|
EquipmentVo.ButtonInfo buttonInfo = qcpDao.queryEquipmentInfoByUserId(param.getUserId()); |
|
|
|
if (ObjectUtil.isNotNull(buttonInfo)) { |
|
|
@ -119,7 +126,7 @@ public class QcpButtonReceive { |
|
|
|
equipmentStatus.setTime(System.currentTimeMillis()); |
|
|
|
equipmentStatusDao.insertSelective(equipmentStatus); |
|
|
|
} |
|
|
|
sendDoctor(firstAid.getId(), firstAid.getName(), firstAid.getHospitalId(), (byte) 1); |
|
|
|
sendDoctor(firstAid.getId(), firstAid.getName(), firstAid.getHospitalId()); |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
@ -134,6 +141,10 @@ public class QcpButtonReceive { |
|
|
|
log.info("暴风眼一键启动接收到的参数{}",param); |
|
|
|
//查询设备信息
|
|
|
|
EquipmentVo.ButtonInfo buttonInfo = qcpDao.queryEquipmentInfoByUserId(param.getUserId()); |
|
|
|
if (!Constant.Equipment.TYPE_TRIAGE_TABLE.equals(buttonInfo.getType())) { |
|
|
|
log.info("不是分诊台设备不可一键启动{}",buttonInfo); |
|
|
|
return; |
|
|
|
} |
|
|
|
if (ObjectUtil.isNotNull(buttonInfo)) { |
|
|
|
Long projectId = qcpDao.queryProjectByUserId(param.getUserId()); |
|
|
|
Long organizationId = organizationProjectDao.queryByProjectId(projectId); |
|
|
@ -142,6 +153,7 @@ public class QcpButtonReceive { |
|
|
|
Long firstAidId = firstAid.getId(); |
|
|
|
EquipmentStatus equipmentStatus = equipmentStatusDao.queryByEidAndFid(buttonInfo.getId(), firstAidId); |
|
|
|
if (ObjectUtil.isNotNull(equipmentStatus)) { |
|
|
|
log.info("一键启动已存在,程序结束{}",equipmentStatus); |
|
|
|
return; |
|
|
|
} |
|
|
|
EquipmentStatus triageStatus = new EquipmentStatus(); |
|
|
@ -150,12 +162,12 @@ public class QcpButtonReceive { |
|
|
|
triageStatus.setEquipmentId(buttonInfo.getId()); |
|
|
|
triageStatus.setEquipmentStatus(Constant.Equipment.RUNNING_STATUS); |
|
|
|
triageStatus.setTime(param.getTime()); |
|
|
|
equipmentStatusDao.insertSelective(equipmentStatus); |
|
|
|
equipmentStatusDao.insertSelective(triageStatus); |
|
|
|
Long hospitalId = buttonInfo.getHospitalId(); |
|
|
|
String name = firstAid.getName(); |
|
|
|
Long time = param.getTime(); |
|
|
|
sendEquipmentStart(firstAidId, hospitalId, name, time); |
|
|
|
sendDoctor(firstAidId, firstAid.getName(), firstAid.getHospitalId(), (byte) 2); |
|
|
|
sendDoctor(firstAidId, firstAid.getName(), firstAid.getHospitalId()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
@ -175,8 +187,13 @@ public class QcpButtonReceive { |
|
|
|
data.setName(name); |
|
|
|
data.setContent(name + equipmentInform.getContent()); |
|
|
|
data.setFirstAidId(firstAidId); |
|
|
|
data.setTotalCountdown(equipmentInform.getTotalCountdown()); |
|
|
|
data.setRealCountdown(System.currentTimeMillis() - time); |
|
|
|
if (equipmentInform.getTotalCountdown() == 0) { |
|
|
|
data.setTotalCountdown(null); |
|
|
|
data.setRealCountdown(null); |
|
|
|
}else { |
|
|
|
data.setTotalCountdown(equipmentInform.getTotalCountdown()); |
|
|
|
data.setRealCountdown(equipmentInform.getTotalCountdown() - (System.currentTimeMillis() - time)); |
|
|
|
} |
|
|
|
data.setTime(time); |
|
|
|
ButtonStartVo buttonStartVo = new ButtonStartVo(); |
|
|
|
buttonStartVo.setData(data); |
|
|
@ -206,8 +223,8 @@ public class QcpButtonReceive { |
|
|
|
log.info("{}未找到急救", param.getFirstAidId()); |
|
|
|
return; |
|
|
|
} |
|
|
|
EquipmentStatus equipmentStatus = equipmentStatusDao.queryByEidAndFidAndStatus(buttonInfo.getId(),param.getFirstAidId(),param.getStatus()); |
|
|
|
if (ObjectUtil.isNotNull(equipmentStatus)) { |
|
|
|
List<EquipmentStatus> equipmentStatus = equipmentStatusDao.queryByEidAndFidAndStatus(buttonInfo.getId(),param.getFirstAidId(),param.getStatus()); |
|
|
|
if (CollectionUtil.isNotEmpty(equipmentStatus)) { |
|
|
|
return; |
|
|
|
} |
|
|
|
if (1 == buttonInfo.getType()) { |
|
|
@ -216,27 +233,34 @@ public class QcpButtonReceive { |
|
|
|
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); |
|
|
|
List<Long> buttonIdList = triageTableList.stream().map(EquipmentVo.ButtonInfo::getId).collect(Collectors.toList()); |
|
|
|
//查询分诊台是否关闭过,如果没有则通知关闭
|
|
|
|
List<EquipmentStatus> equipmentStatusList = equipmentStatusDao.queryTriageTableIsExist(buttonIdList,param.getFirstAidId()); |
|
|
|
log.info("查询分诊台是否关闭过:{}",equipmentStatusList); |
|
|
|
if (CollectionUtil.isEmpty(equipmentStatusList)) { |
|
|
|
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)); |
|
|
|
} |
|
|
|
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)); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
@ -250,14 +274,14 @@ public class QcpButtonReceive { |
|
|
|
saveEquipmentStatus.setFirstAidId(param.getFirstAidId()); |
|
|
|
equipmentStatusDao.insertSelective(saveEquipmentStatus); |
|
|
|
|
|
|
|
sendDoctor(param.getFirstAidId(), firstAid.getName(), firstAid.getHospitalId(), (byte) 3); |
|
|
|
sendDoctor(param.getFirstAidId(), firstAid.getName(), firstAid.getHospitalId()); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 通知医院的所有成员病例进度 |
|
|
|
* @param firstAidId 病例 |
|
|
|
*/ |
|
|
|
private void sendDoctor(Long firstAidId, String firstAidName, Long organizationId,Byte type) throws Exception { |
|
|
|
private void sendDoctor(Long firstAidId, String firstAidName, Long organizationId) throws Exception { |
|
|
|
// 查询医院所有成员
|
|
|
|
List<Long> userIds = organizationMemberDao.queryUserIdsByOrganizationId(organizationId); |
|
|
|
// 查询当前未完成的状态
|
|
|
@ -273,7 +297,7 @@ public class QcpButtonReceive { |
|
|
|
data.setName(firstAidName); |
|
|
|
data.setContent(inform.getEquipmentStatus().equals(Constant.Equipment.ID_CARD_IDENTIFY_STATUS) ? firstAidName : firstAidName + inform.getContent()); |
|
|
|
data.setFirstAidId(firstAidId); |
|
|
|
if (type.equals((byte)1)){ |
|
|
|
if (inform.getTotalCountdown() == 0){ |
|
|
|
data.setTotalCountdown(null); |
|
|
|
data.setRealCountdown(null); |
|
|
|
}else { |
|
|
|