16 changed files with 309 additions and 14 deletions
@ -0,0 +1,57 @@ |
|||
package com.ccsens.carbasics.bean.dto; |
|||
|
|||
|
|||
import io.swagger.annotations.ApiModel; |
|||
import io.swagger.annotations.ApiModelProperty; |
|||
import lombok.Data; |
|||
|
|||
/** |
|||
* @author AUSU |
|||
*/ |
|||
public class ButtonDto { |
|||
@Data |
|||
@ApiModel("身份证信息-mq入参") |
|||
public static class CarBasicsMq{ |
|||
@ApiModelProperty("消息类型(0-身份证信息,1-一键启动,2-状态更改)") |
|||
private Byte type; |
|||
@ApiModelProperty("0-身份证信息") |
|||
private IdCardInfoMq idCardInfoMq; |
|||
@ApiModelProperty("1-一键启动") |
|||
private ButtonStartMq buttonStartMq; |
|||
@ApiModelProperty("2-状态更改") |
|||
private UpDateStatusMq upDateStatusMq; |
|||
} |
|||
|
|||
@Data |
|||
@ApiModel("身份证信息-mq入参") |
|||
public static class IdCardInfoMq{ |
|||
@ApiModelProperty("姓名") |
|||
private String name; |
|||
@ApiModelProperty("性别(0-女,1-男)") |
|||
private Byte sex; |
|||
@ApiModelProperty("民族") |
|||
private String nation; |
|||
@ApiModelProperty("身份证号") |
|||
private String idcard; |
|||
@ApiModelProperty("设备userId") |
|||
private Long userId; |
|||
} |
|||
@Data |
|||
@ApiModel("一键启动-mq入参") |
|||
public static class ButtonStartMq { |
|||
@ApiModelProperty("身份证号") |
|||
private String idcard; |
|||
@ApiModelProperty("设备userId") |
|||
private Long userId; |
|||
} |
|||
@Data |
|||
@ApiModel("状态更改-mq入参") |
|||
public static class UpDateStatusMq { |
|||
@ApiModelProperty("急救id") |
|||
private Long firstAidId; |
|||
@ApiModelProperty("状态(0身份证识别,1进行中,2结束)") |
|||
private Byte status; |
|||
@ApiModelProperty("设备userId") |
|||
private Long userId; |
|||
} |
|||
} |
@ -0,0 +1,122 @@ |
|||
package com.ccsens.carbasics.mq; |
|||
|
|||
import cn.hutool.core.bean.BeanUtil; |
|||
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.EquipmentStatus; |
|||
import com.ccsens.carbasics.bean.po.FirstAid; |
|||
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.RedisUtil; |
|||
import com.ccsens.util.exception.BaseException; |
|||
import lombok.extern.slf4j.Slf4j; |
|||
import org.springframework.amqp.rabbit.annotation.RabbitHandler; |
|||
import org.springframework.amqp.rabbit.annotation.RabbitListener; |
|||
import org.springframework.stereotype.Component; |
|||
|
|||
import javax.annotation.Resource; |
|||
|
|||
/** |
|||
* 暴风眼接收qcp一键通知相关消息 |
|||
* @author Ausu |
|||
*/ |
|||
@Slf4j |
|||
@Component |
|||
@RabbitListener(queues = Constant.MQ.QCP_BUTTON_START) |
|||
public class QcpButtonReceive { |
|||
|
|||
@Resource |
|||
private Snowflake snowflake; |
|||
@Resource |
|||
private RedisUtil redisUtil; |
|||
@Resource |
|||
private QcpDao qcpDao; |
|||
@Resource |
|||
private IFirstAidService firstAidService; |
|||
@Resource |
|||
private OrganizationProjectDao organizationProjectDao; |
|||
@Resource |
|||
private EquipmentStatusDao equipmentStatusDao; |
|||
@Resource |
|||
private EquipmentInformDao equipmentInformDao; |
|||
@Resource |
|||
private FirstAidDao firstAidDao; |
|||
|
|||
@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; |
|||
} |
|||
} |
|||
|
|||
/** |
|||
* 身份证识别处理 |
|||
* @param param 参数 |
|||
*/ |
|||
public void idCardDiscern(ButtonDto.IdCardInfoMq param) { |
|||
log.info("暴风眼身份证识别接收到的参数{}",param); |
|||
String idCard = (String) redisUtil.get(param.getName() + param.getIdcard()); |
|||
if (StrUtil.isNotBlank(idCard)) { |
|||
return; |
|||
} |
|||
redisUtil.set(param.getName()+param.getIdcard(),param.getIdcard(),300); |
|||
//根据设备userId查询项目id
|
|||
Long projectId = qcpDao.queryProjectByUserId(param.getUserId()); |
|||
log.info("查询到的项目id:{}",projectId); |
|||
if (ObjectUtil.isNotNull(projectId)) { |
|||
Long organizationId = organizationProjectDao.queryByProjectId(projectId); |
|||
log.info("查询到的暴风眼机构id:{}",organizationId); |
|||
if (ObjectUtil.isNotNull(organizationId)) { |
|||
//创建病例
|
|||
PatientDto.SavePatient savePatient = new PatientDto.SavePatient(); |
|||
BeanUtil.copyProperties(param,savePatient); |
|||
savePatient.setGender(param.getSex()); |
|||
firstAidService.getFirstAid(savePatient,param.getUserId(), (byte) 5,organizationId); |
|||
} |
|||
} |
|||
|
|||
} |
|||
|
|||
/** |
|||
* 一键启动处理 |
|||
* @param param 参数 |
|||
*/ |
|||
public void buttonStart(ButtonDto.ButtonStartMq param) { |
|||
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()); |
|||
|
|||
} |
|||
} |
|||
|
|||
/** |
|||
* 修改状态处理 |
|||
* @param param 参数 |
|||
*/ |
|||
public void updateStatus(ButtonDto.UpDateStatusMq param) { |
|||
|
|||
} |
|||
|
|||
} |
@ -0,0 +1,8 @@ |
|||
package com.ccsens.carbasics.persist.dao; |
|||
|
|||
import com.ccsens.carbasics.persist.mapper.EquipmentInformMapper; |
|||
import org.springframework.stereotype.Repository; |
|||
|
|||
@Repository |
|||
public interface EquipmentInformDao extends EquipmentInformMapper { |
|||
} |
@ -0,0 +1,9 @@ |
|||
package com.ccsens.carbasics.persist.dao; |
|||
|
|||
import com.ccsens.carbasics.persist.mapper.EquipmentStatusMapper; |
|||
import org.springframework.stereotype.Repository; |
|||
|
|||
@Repository |
|||
public interface EquipmentStatusDao extends EquipmentStatusMapper { |
|||
|
|||
} |
@ -0,0 +1,18 @@ |
|||
package com.ccsens.carbasics.persist.dao; |
|||
|
|||
import org.apache.ibatis.annotations.Param; |
|||
import org.springframework.stereotype.Repository; |
|||
|
|||
/** |
|||
* 查询qcp中的信息 |
|||
* @author AUSU |
|||
*/ |
|||
@Repository |
|||
public interface QcpDao { |
|||
/** |
|||
* 根据设备userId查询项目id |
|||
* @param userId 设备userId |
|||
* @return 项目id |
|||
*/ |
|||
Long queryProjectByUserId(@Param("userId") Long userId); |
|||
} |
@ -0,0 +1,5 @@ |
|||
<?xml version="1.0" encoding="UTF-8"?> |
|||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
|||
<mapper namespace="com.ccsens.carbasics.persist.dao.EquipmentInformDao"> |
|||
|
|||
</mapper> |
@ -0,0 +1,5 @@ |
|||
<?xml version="1.0" encoding="UTF-8"?> |
|||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
|||
<mapper namespace="com.ccsens.carbasics.persist.dao.EquipmentStatusDao"> |
|||
|
|||
</mapper> |
@ -0,0 +1,16 @@ |
|||
<?xml version="1.0" encoding="UTF-8"?> |
|||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
|||
<mapper namespace="com.ccsens.carbasics.persist.dao.QcpDao"> |
|||
|
|||
<select id="queryProjectByUserId" resultType="java.lang.Long"> |
|||
SELECT |
|||
h.project_id |
|||
FROM |
|||
qcp.t_qcp_hospital_equipment AS he |
|||
LEFT JOIN qcp.t_qcp_hospital AS h ON he.hospital_id = h.id |
|||
WHERE |
|||
he.rec_status = 0 |
|||
AND h.rec_status = 0 |
|||
AND he.user_id = #{userId} |
|||
</select> |
|||
</mapper> |
Loading…
Reference in new issue