Prechádzať zdrojové kódy

Merge branch 'dev' into nb-pc-rabbitmq

# Conflicts:
#	nb-service/web-service/src/main/java/com/nb/web/service/bus/hospital/HospitalManager.java
18339543638 3 rokov pred
rodič
commit
d90ed8fc5d
37 zmenil súbory, kde vykonal 796 pridanie a 55 odobranie
  1. 6 4
      nb-common/log-common/src/main/java/com/nb/common/log/aop/LogAspect.java
  2. 44 0
      nb-core/src/main/java/com/nb/core/annotation/Phone.java
  3. 17 0
      nb-im/src/main/java/com/nb/im/controller/ImRoomController.java
  4. 12 0
      nb-im/src/main/java/com/nb/im/controller/ImRoomMsgController.java
  5. 16 0
      nb-im/src/main/java/com/nb/im/controller/vo/MsgExtendVo.java
  6. 2 0
      nb-im/src/main/java/com/nb/im/entity/ImMsgEntity.java
  7. 3 0
      nb-im/src/main/java/com/nb/im/entity/ImRoomUserEntity.java
  8. 1 0
      nb-im/src/main/java/com/nb/im/listener/ConsultMsgListener.java
  9. 13 3
      nb-im/src/main/java/com/nb/im/service/LocalImRoomService.java
  10. 3 2
      nb-im/src/main/java/com/nb/im/service/LocalImRoomUserService.java
  11. 83 0
      nb-im/src/main/java/com/nb/im/service/dto/ImRoomDetailDto.java
  12. 3 0
      nb-im/src/main/java/com/nb/im/service/dto/ImRoomDto.java
  13. 3 3
      nb-im/src/main/java/com/nb/im/service/dto/ImRoomQuery.java
  14. 6 1
      nb-im/src/main/java/com/nb/im/service/dto/ImRoomResult.java
  15. 1 1
      nb-im/src/main/java/com/nb/im/ws/filter/MsgFormatFilter.java
  16. 17 1
      nb-im/src/main/resources/mapper/im/ImRoomMapper.xml
  17. 4 4
      nb-service-api/app-assistant-api/src/main/java/com/nb/app/assistant/api/entity/AssistantEvalEntity.java
  18. 3 6
      nb-service-api/app-assistant-api/src/main/java/com/nb/app/assistant/api/entity/AssistantUserBindEntity.java
  19. 2 2
      nb-service-api/app-assistant-api/src/main/java/com/nb/app/assistant/api/enums/ApplyEnum.java
  20. 11 1
      nb-service-api/app-assistant-api/src/main/java/com/nb/app/assistant/api/feign/IAssistantUserBindClient.java
  21. 2 0
      nb-service-api/app-doctor-api/src/main/java/com/nb/app/doctor/api/entity/AppDoctorUserEntity.java
  22. 3 0
      nb-service-api/app-msg-api/src/main/java/com/nb/app/msg/bean/MsgBean.java
  23. 25 0
      nb-service-api/web-service-api/src/main/java/com/nb/web/api/feign/IPatientClient.java
  24. 6 0
      nb-service/app-assistant/src/main/java/com/nb/app/assistant/auth/AssistantPhoneGranter.java
  25. 12 1
      nb-service/app-assistant/src/main/java/com/nb/app/assistant/controller/PatientOperationController.java
  26. 3 0
      nb-service/app-assistant/src/main/java/com/nb/app/assistant/controller/vo/CaptureVo.java
  27. 22 3
      nb-service/app-assistant/src/main/java/com/nb/app/assistant/service/LocalAssistantUserBindService.java
  28. 1 1
      nb-service/app-assistant/src/main/java/com/nb/app/assistant/utils/CaptchaUtil.java
  29. 7 1
      nb-service/app-doctor/src/main/java/com/nb/app/doctor/controller/PatientMonitorController.java
  30. 1 1
      nb-service/app-msg/src/main/java/com/nb/app/msg/entity/AppConsultEntity.java
  31. 134 0
      nb-service/iot-service/src/main/java/com/nb/mq/entity/PcAnalgesicScoreEntity.java
  32. 107 0
      nb-service/iot-service/src/main/java/com/nb/mq/entity/PcPatientEntity.java
  33. 173 0
      nb-service/iot-service/src/main/java/com/nb/mq/entity/PcPumpEntity.java
  34. 11 0
      nb-service/iot-service/src/main/java/com/nb/mq/listener/RabbitMqListener.java
  35. 18 19
      nb-service/web-service/src/main/java/com/nb/web/service/bus/hospital/HospitalManager.java
  36. 20 0
      nb-service/web-service/src/main/java/com/nb/web/service/bus/service/LocalBusPatientService.java
  37. 1 1
      nb-service/web-service/src/main/resources/mapper/bus/BusPatientMapper.xml

+ 6 - 4
nb-common/log-common/src/main/java/com/nb/common/log/aop/LogAspect.java

@@ -53,19 +53,21 @@ public class LogAspect {
         Long startTime = System.currentTimeMillis();
         Object obj = null;
         Exception exception = null;
+        List<Object> param = new ArrayList<>();
         try {
+            param = Arrays.stream(point.getArgs()).filter(item -> Objects.nonNull(item) && !isFilterObject(item)).collect(Collectors.toList());
             obj = point.proceed();
         } catch (Exception e) {
             exception = e;
             throw e;
         } finally {
             Long endTime = System.currentTimeMillis();
-            handleLog(point, exception, obj, endTime - startTime);
+            handleLog(point,param, exception, obj, endTime - startTime);
         }
         return obj;
     }
 
-    protected void handleLog(final JoinPoint joinPoint, final Exception e, Object retValue, long time) {
+    protected void handleLog(final JoinPoint joinPoint, List<Object> param, final Exception e, Object retValue, long time) {
         try {
             // 获得注解
             Signature signature = joinPoint.getSignature();
@@ -86,8 +88,8 @@ public class LogAspect {
             String methodName = joinPoint.getSignature().getName();
             sysLog.setRequsetMethod(className + "." + methodName + "()");
 
-            List<Object> objectList = Arrays.stream(joinPoint.getArgs()).filter(item -> Objects.nonNull(item) && !isFilterObject(item)).collect(Collectors.toList());
-            sysLog.setRequsetParams(JSONUtil.toJsonStr(objectList));
+
+            sysLog.setRequsetParams(JSONUtil.toJsonStr(param));
             sysLog.setResponseResult(JSONUtil.toJsonStr(retValue));
             sysLog.setRequsetTime(String.valueOf(time));
 

+ 44 - 0
nb-core/src/main/java/com/nb/core/annotation/Phone.java

@@ -0,0 +1,44 @@
+package com.nb.core.annotation;
+
+import static java.lang.annotation.ElementType.CONSTRUCTOR;
+import static java.lang.annotation.ElementType.FIELD;
+import static java.lang.annotation.ElementType.METHOD;
+import static java.lang.annotation.ElementType.PARAMETER;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+import javax.validation.Constraint;
+import javax.validation.Payload;
+import javax.validation.ReportAsSingleViolation;
+import javax.validation.constraints.Null;
+import javax.validation.constraints.Pattern;
+
+import org.hibernate.validator.constraints.CompositionType;
+import org.hibernate.validator.constraints.ConstraintComposition;
+import org.hibernate.validator.constraints.Length;
+
+/**
+ * 验证手机号,空和正确的手机号都能验证通过<br/>
+ * 正确的手机号由11位数字组成,第一位为1
+ * 第二位为 3、4、5、7、8
+ * 
+ */
+@ConstraintComposition(CompositionType.OR)
+@Pattern(regexp = "1[3|4|5|7|8][0-9]\\d{8}")
+@Null
+@Length(min = 0, max = 0)
+@Documented
+@Constraint(validatedBy = {})
+@Target({ METHOD, FIELD, CONSTRUCTOR, PARAMETER })
+@Retention(RUNTIME)
+@ReportAsSingleViolation
+public @interface Phone {
+    String message() default "手机号校验错误";
+
+    Class<?>[] groups() default {};
+
+    Class<? extends Payload>[] payload() default {};
+}

+ 17 - 0
nb-im/src/main/java/com/nb/im/controller/ImRoomController.java

@@ -1,6 +1,7 @@
 package com.nb.im.controller;
 
 import cn.dev33.satoken.stp.StpLogic;
+import cn.hutool.core.bean.BeanUtil;
 import cn.hutool.core.collection.CollectionUtil;
 import cn.hutool.core.util.StrUtil;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
@@ -20,6 +21,7 @@ import com.nb.im.entity.ImRoomEntity;
 import com.nb.im.room.ImRoomOperator;
 import com.nb.im.room.ImRoomOperatorManager;
 import com.nb.im.service.LocalImMsgService;
+import com.nb.im.service.dto.ImRoomDetailDto;
 import com.nb.im.service.dto.ImRoomDto;
 import com.nb.im.enums.ImStatusEnum;
 import com.nb.im.enums.SponsorEnum;
@@ -29,6 +31,7 @@ import com.nb.im.service.dto.ImRoomResult;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import lombok.AllArgsConstructor;
+import org.springframework.context.annotation.Bean;
 import org.springframework.validation.annotation.Validated;
 import org.springframework.web.bind.annotation.*;
 
@@ -56,6 +59,9 @@ public class ImRoomController implements BaseSaveController<ImRoomEntity,String>
     @ApiOperation(value = "查询并自动创建与病人看护人的聊天室",notes = "若存在,则返回聊天室信息,若不存在,则返回空")
     @PostMapping("/look")
     public R getChatRoom(@RequestBody@Validated ImRoomDto source){
+        if(source.isAutoCreate()&&StrUtil.isEmpty(source.getDoctorNickname())){
+            throw new CustomException("医生昵称不可为空");
+        }
         ImRoomEntity chatRoom = imRoomService.getOne(new QueryWrapper<ImRoomEntity>()
                 .lambda()
                 .eq(ImRoomEntity::getAssistId, source.getAssistId())
@@ -97,6 +103,17 @@ public class ImRoomController implements BaseSaveController<ImRoomEntity,String>
         return R.success(result);
     }
 
+    @GetMapping("/view/{id}")
+    @ApiOperation(value = "根据id查询聊天室")
+    public R<ImRoomDetailDto> getById(@PathVariable("id") String id){
+        ImRoomDetailDto result= BeanUtil.toBean(imRoomService.getById(id),ImRoomDetailDto.class);
+        if(result!=null){
+            result.setUnreadCount( roomOperatorManager.getRoomOperator(result.getId())
+                    .unReadCount( String.valueOf(SecurityUtil.getId())));
+        }
+        return R.success(result);
+    }
+
 
     @PostMapping("/no_page/unread/{roomId}")
     @ApiOperation(value = "获取所有未读消息(需手动调用接口设置为已读)")

+ 12 - 0
nb-im/src/main/java/com/nb/im/controller/ImRoomMsgController.java

@@ -1,7 +1,10 @@
 package com.nb.im.controller;
 
+import cn.hutool.json.JSONUtil;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
 import com.nb.core.result.R;
+import com.nb.im.controller.vo.MsgExtendVo;
 import com.nb.im.entity.ImMsgEntity;
 import com.nb.im.service.LocalImMsgService;
 import com.nb.im.service.dto.ImRoomMsgQuery;
@@ -35,4 +38,13 @@ public class ImRoomMsgController  {
                 .lambda()
                 .eq(ImMsgEntity::getRoomId,query.getRoomId())));
     }
+
+    @PostMapping("/edit")
+    @ApiOperation("修改消息扩展字段")
+    public R<Boolean> edit(@RequestBody@Validated MsgExtendVo vo){
+        return R.success(chatRoomMsgService.update(new UpdateWrapper<ImMsgEntity>()
+                .lambda()
+                .eq(ImMsgEntity::getId,vo.getId())
+                .set(ImMsgEntity::getExtend, JSONUtil.toJsonStr(vo.getExtend()))));
+    }
 }

+ 16 - 0
nb-im/src/main/java/com/nb/im/controller/vo/MsgExtendVo.java

@@ -0,0 +1,16 @@
+package com.nb.im.controller.vo;
+
+import lombok.Data;
+
+/**
+ * @author lifang
+ * @version 1.0.0
+ * @ClassName MsgExtentVo.java
+ * @Description TODO
+ * @createTime 2022年09月06日 08:14:00
+ */
+@Data
+public class MsgExtendVo {
+    private String id;
+    private Object extend;
+}

+ 2 - 0
nb-im/src/main/java/com/nb/im/entity/ImMsgEntity.java

@@ -3,6 +3,7 @@ package com.nb.im.entity;
 import com.baomidou.mybatisplus.annotation.TableField;
 import com.baomidou.mybatisplus.annotation.TableName;
 import com.baomidou.mybatisplus.core.toolkit.IdWorker;
+import com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler;
 import com.nb.app.msg.bean.MsgBean;
 import com.nb.app.msg.enums.MsgEnum;
 import com.nb.core.entity.GenericEntity;
@@ -65,6 +66,7 @@ public class ImMsgEntity extends GenericEntity<String> {
     private boolean sys;
 
     @ApiModelProperty("扩展字段,例:当消息类型为一键呼叫时,存放 boolean类型标识是否已处理;当消息类型为问题咨询详情时,存放 咨询问题id")
+    @TableField(typeHandler = JacksonTypeHandler.class)
     private Object extend;
 
 

+ 3 - 0
nb-im/src/main/java/com/nb/im/entity/ImRoomUserEntity.java

@@ -36,6 +36,9 @@ public class ImRoomUserEntity extends GenericEntity<String> {
     @ApiModelProperty(value = "参与人id",required = true)
     private String userId;
 
+    @ApiModelProperty(value = "参与人昵称")
+    private String nickname;
+
     @ApiModelProperty("已读消息数量")
     private int readCount;
 

+ 1 - 0
nb-im/src/main/java/com/nb/im/listener/ConsultMsgListener.java

@@ -101,6 +101,7 @@ public class ConsultMsgListener {
         result.setImRoomId(source.getId());
         result.setTop(false);
         result.setUserId(msg.getReceiverId());
+        result.setNickname(msg.getReceiverName());
         roomUserService.save(result);
         return result;
     }

+ 13 - 3
nb-im/src/main/java/com/nb/im/service/LocalImRoomService.java

@@ -1,5 +1,6 @@
 package com.nb.im.service;
 
+import cn.hutool.core.util.StrUtil;
 import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
 import com.baomidou.mybatisplus.core.toolkit.IdWorker;
 import com.nb.app.msg.enums.MsgEnum;
@@ -16,11 +17,13 @@ import com.nb.im.room.ImRoomOperatorManager;
 import com.nb.im.service.dto.ImRoomDto;
 import com.nb.im.utils.ImUtils;
 import com.nb.im.ws.PubMsgInfo;
+import com.nb.web.api.feign.IPatientClient;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.context.annotation.Lazy;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
+import java.util.Date;
 import java.util.HashMap;
 import java.util.Map;
 
@@ -37,6 +40,10 @@ public class LocalImRoomService extends BaseService<ImRoomMapper, ImRoomEntity,S
     @Lazy
     private LocalImRoomUserService chatRoomUserService;
 
+    @Autowired
+    @Lazy
+    private IPatientClient patientClient;
+
     @Autowired
     @Lazy
     private ImUtils imUtils;
@@ -47,7 +54,9 @@ public class LocalImRoomService extends BaseService<ImRoomMapper, ImRoomEntity,S
 
     @Override
     public void validateBeforeSave(ImRoomEntity entity) {
-
+        if(entity.getManageType()==null&& StrUtil.isNotEmpty(entity.getPatientId())){
+            entity.setManageType(patientClient.getManageType(entity.getPatientId()));
+        }
     }
 
     @Override
@@ -83,8 +92,8 @@ public class LocalImRoomService extends BaseService<ImRoomMapper, ImRoomEntity,S
         //等待医生确认
         result.setStatus(source.getStatus());
         this.save(result);
-        chatRoomUserService.createRoomUser(result.getId(),source.getAssistId(),SponsorEnum.assist);
-        chatRoomUserService.createRoomUser(result.getId(),source.getDoctorId(),SponsorEnum.doctor);
+        chatRoomUserService.createRoomUser(result.getId(),source.getAssistId(),source.getDoctorNickname(),SponsorEnum.assist);
+        chatRoomUserService.createRoomUser(result.getId(),source.getDoctorId(),source.getDoctorNickname(),SponsorEnum.doctor);
         return result;
     }
 
@@ -102,6 +111,7 @@ public class LocalImRoomService extends BaseService<ImRoomMapper, ImRoomEntity,S
         this.update(new UpdateWrapper<ImRoomEntity>()
                 .lambda()
                 .eq(ImRoomEntity::getId,chatRoomId)
+                .set(ImRoomEntity::getSuccessTime,new Date())
                 .set(ImRoomEntity::getStatus,ImStatusEnum.SUCCESS)
         );
     }

+ 3 - 2
nb-im/src/main/java/com/nb/im/service/LocalImRoomUserService.java

@@ -16,6 +16,7 @@ import org.springframework.transaction.annotation.Transactional;
  */
 @Service
 public class LocalImRoomUserService extends BaseService<ImRoomUserMapper, ImRoomUserEntity,String> {
+
     @Override
     public void validateBeforeSave(ImRoomUserEntity entity) {
         entity.setTop(false);
@@ -34,12 +35,12 @@ public class LocalImRoomUserService extends BaseService<ImRoomUserMapper, ImRoom
 
 
     @Transactional(rollbackFor = Exception.class)
-    public ImRoomUserEntity createRoomUser(String roomId, String partId, SponsorEnum partType){
+    public ImRoomUserEntity createRoomUser(String roomId, String partId, String partNickname, SponsorEnum partType){
         ImRoomUserEntity result = new ImRoomUserEntity();
         result.setImRoomId(roomId);
         result.setTop(false);
         result.setUserId(partId);
-//        result.setLastSendTime(new Date());
+        result.setNickname(partNickname);
         this.save(result);
         return result;
     }

+ 83 - 0
nb-im/src/main/java/com/nb/im/service/dto/ImRoomDetailDto.java

@@ -0,0 +1,83 @@
+package com.nb.im.service.dto;
+
+import com.nb.core.entity.GenericEntity;
+import com.nb.core.enums.SexEnum;
+import com.nb.im.enums.ImStatusEnum;
+import com.nb.im.enums.SponsorEnum;
+import com.nb.web.api.enums.ClinicManageEnum;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import javax.validation.constraints.NotNull;
+import java.util.Date;
+
+/**
+ * @author lifang
+ * @version 1.0.0
+ * @ClassName ImRoomDetailDto.java
+ * @Description TODO
+ * @createTime 2022年09月06日 10:11:00
+ */
+@Data
+public class ImRoomDetailDto {
+
+    private String id;
+
+    @ApiModelProperty(value = "病人id",readOnly = true)
+    private String patientId;
+
+    @ApiModelProperty(value = "住院号",readOnly = true)
+    private String patientCode;
+
+    @ApiModelProperty(value = "病人名称",readOnly = true)
+    private String patientName;
+
+    @ApiModelProperty(value = "病人年龄",readOnly = true)
+    private Integer patientAge;
+
+    @ApiModelProperty(value = "病人性别",readOnly = true)
+    private SexEnum patientSex;
+
+    @ApiModelProperty(value = "看护位置 0(院内管理) 1(居家管理)",required = true)
+    private ClinicManageEnum manageType;
+
+    @ApiModelProperty(value = "看护人id",readOnly = true)
+    @NotNull(message = "看护人id不能为空",groups = GenericEntity.Insert.class)
+    private String assistId;
+
+    @ApiModelProperty(value = "医生id",readOnly = true)
+    @NotNull(message = "医生id不能为空",groups = GenericEntity.Insert.class)
+    private String doctorId;
+
+    @ApiModelProperty(value = "发起人类型",readOnly = true,allowableValues = "0(看护人发起) 1(医生发起)")
+    @NotNull(message = "发起类型不能为空",groups = GenericEntity.Insert.class)
+    private SponsorEnum sponsorType;
+
+    @ApiModelProperty(value = "聊天室总消息数",readOnly = true)
+    private Integer totalCount;
+
+    @ApiModelProperty(value = "成功建立聊天室时间",readOnly = true)
+    private Date successTime;
+
+    @ApiModelProperty(value = "聊天室状态",readOnly = true)
+    private ImStatusEnum status;
+
+    @ApiModelProperty(value = "聊天室最后一条消息id",readOnly = true)
+    private String lastMsgId;
+
+    @ApiModelProperty(value = "聊天室最后一条消息时间",readOnly = true)
+    private Date lastMsgTime;
+
+    @ApiModelProperty(value = "聊天室最后一条消息发送人",readOnly = true)
+    private String lastSenderId;
+
+    @ApiModelProperty(value = "监控是否结束",readOnly = true)
+    private Boolean monitorFinished;
+
+    @ApiModelProperty(value = "监控结束时间",readOnly = true)
+    private Date monitorFinishedTime;
+
+
+    @ApiModelProperty(value = "消息未读数量",readOnly = true)
+    private Integer unreadCount;
+}

+ 3 - 0
nb-im/src/main/java/com/nb/im/service/dto/ImRoomDto.java

@@ -26,6 +26,9 @@ public class ImRoomDto {
     @NotNull(message = "医生id不能为空")
     private String doctorId;
 
+    @ApiModelProperty(value = "医生昵称,当autoCreate为true时,不为空")
+    private String doctorNickname;
+
     @ApiModelProperty(value = "看护人员id",required = true)
     @NotNull(message = "看护人员id不能为空")
     private String assistId;

+ 3 - 3
nb-im/src/main/java/com/nb/im/service/dto/ImRoomQuery.java

@@ -17,14 +17,14 @@ import javax.validation.constraints.NotNull;
 @Data
 @ApiModel("聊天室查询参数")
 public class ImRoomQuery {
-    @ApiModelProperty(value = "医生id",required = true)
-    @NotNull(message = "医生id不能为空")
+    @ApiModelProperty(value = "医生id")
+//    @NotNull(message = "医生id不能为空")
     private String doctorId;
 
     @ApiModelProperty(value = "病人id")
     private String patientId;
 
-    @ApiModelProperty(value = "看护人id")
+    @ApiModelProperty(value = "看护人id,当看护人id不为空时,会返回该聊天室所属的医生信息")
     private String assistId;
 
     @ApiModelProperty(value = "管理位置",allowableValues = "0(院内管理) 1(居家管理)")

+ 6 - 1
nb-im/src/main/java/com/nb/im/service/dto/ImRoomResult.java

@@ -1,6 +1,5 @@
 package com.nb.im.service.dto;
 
-import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
 import com.nb.app.msg.enums.MsgEnum;
 import com.nb.core.enums.SexEnum;
 import com.nb.im.enums.ImMsgType;
@@ -67,4 +66,10 @@ public class ImRoomResult implements Serializable {
 
     @ApiModelProperty("消息未读数量")
     private Integer unreadCount;
+
+    @ApiModelProperty(value = "医生昵称")
+    private String doctorNickname;
+
+    @ApiModelProperty(value = "医生id")
+    private String doctorId;
 }

+ 1 - 1
nb-im/src/main/java/com/nb/im/ws/filter/MsgFormatFilter.java

@@ -49,7 +49,7 @@ public class MsgFormatFilter implements PubMsgFilter {
                 pubMsgInfo = objectMapper.readerFor(PubMsgInfo.class).readValue(String.valueOf(source.getPayload()));
                 pubMsgInfo.validate();
             }catch (Exception e){
-                Tio.send(channelContext,WsResponse.fromText(JSONUtil.toJsonStr(PubResponse.fail(pubMsgInfo!=null?pubMsgInfo.getKey():"",e.getMessage())),WsPacket.CHARSET_NAME));
+//                Tio.send(channelContext,WsResponse.fromText(JSONUtil.toJsonStr(PubResponse.fail(pubMsgInfo!=null?pubMsgInfo.getKey():"",e.getMessage())),WsPacket.CHARSET_NAME));
                 for (String param : source.getParams()) {
                     Tio.send(channelContext, WsResponse.fromText(JSONUtil.toJsonStr(
                             MessageResponse.of("im","im-result",

+ 17 - 1
nb-im/src/main/resources/mapper/im/ImRoomMapper.xml

@@ -16,6 +16,8 @@
         <result column="payload" property="payload"/>
         <result column="operation_type" property="operationType"/>
         <result column="msg_type" property="msgType"/>
+        <result column="doctorNickname" property="doctorNickname"/>
+        <result column="doctorId" property="doctorId"/>
     </resultMap>
 
 
@@ -31,13 +33,20 @@
         r.last_msg_time as last_msg_time,
         r.sponsor_type as sponsor_type,
         r.total_count as total_count,
+        <if test="query.assistId != null">
+            ru.nickname as doctorNickname,
+            ru.user_id as doctorId,
+        </if>
         rm.payload as payload,
         rm.msg_type as msg_type,
         rm.operation_type as operation_type
+
         from
         (select * from im_room
         <where>
-            doctor_id=#{query.doctorId}
+            <if test="query.doctorId != null">
+                and  doctor_id=#{query.doctorId}
+            </if>
             <if test="query.patientInfo != null">
                 and (patient_code like concat('%',#{query.patientInfo},'%') or patient_name like concat('%',#{query.patientInfo},'%') )
             </if>
@@ -54,6 +63,13 @@
         ) as r
         left join (select * from im_msg) as rm
         on rm.id=r.last_msg_id
+        <if test="query.assistId != null">
+            left join (select * from im_room_user where
+            user_id != #{query.assistId}
+            ) as ru
+            on ru.im_room_id=r.id
+        </if>
+
         order by last_msg_time desc
     </select>
 

+ 4 - 4
nb-service-api/app-assistant-api/src/main/java/com/nb/app/assistant/api/entity/AssistantEvalEntity.java

@@ -50,12 +50,12 @@ public class AssistantEvalEntity extends GenericEntity<String> {
     private String evaluatorName;
 
     @ApiModelProperty("疼痛部位-正面 具体传值内容即key:value值由传参人决定,传入值即为获取值")
-    @TableField(typeHandler = JacksonTypeHandler.class)
-    private Map<String,Object> painFront;
+    @TableField(typeHandler =  StringListTypeHandler.class)
+    private List<String> painFront;
 
     @ApiModelProperty("疼痛部位-反面 具体传值内容即key:value值由传参人决定,传入值即为获取值")
-    @TableField(typeHandler = JacksonTypeHandler.class)
-    private Map<String,Object> painBack;
+    @TableField(typeHandler =  StringListTypeHandler.class)
+    private List<String> painBack;
 
     @ApiModelProperty("疼痛性质")
     @TableField(typeHandler =  StringListTypeHandler.class)

+ 3 - 6
nb-service-api/app-assistant-api/src/main/java/com/nb/app/assistant/api/entity/AssistantUserBindEntity.java

@@ -1,6 +1,5 @@
 package com.nb.app.assistant.api.entity;
 
-import com.baomidou.mybatisplus.annotation.TableField;
 import com.baomidou.mybatisplus.annotation.TableName;
 import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
 import com.nb.app.assistant.api.enums.ApplyEnum;
@@ -15,8 +14,6 @@ import lombok.EqualsAndHashCode;
 import lombok.NoArgsConstructor;
 import lombok.ToString;
 
-import java.util.Date;
-
 /**
  * @author lifang
  * @version 1.0.0
@@ -37,7 +34,7 @@ public class AssistantUserBindEntity extends GenericEntity<String> {
     @ApiModelProperty(value = "用户昵称",required = true)
     private String assistNickname;
 
-    @ApiModelProperty(value = "病人id",required = true)
+    @ApiModelProperty(value = "病人id,当手动填写数据时,为空;当邀请码填充时,不为空")
     private String patientId;
 
     @ApiModelProperty(value = "住院号",required = true)
@@ -71,10 +68,10 @@ public class AssistantUserBindEntity extends GenericEntity<String> {
     @ApiModelProperty(value = "是否为默认看护")
     private Boolean default_;
 
-    @ApiModelProperty(value = "申请类型",required = true,allowableValues = "0(手动申请) 1(邀请码申请)")
+    @ApiModelProperty(value = "申请类型",required = true,example = " 0(手动申请) 1(邀请码申请)")
     private ApplyEnum applyType;
 
-    @ApiModelProperty(value = "绑定状态",required = true,allowableValues = "0(等待医生进行绑定操作) 1(绑定成功) 2(拒绝) 3(自动断开) 4(手动断开)")
+    @ApiModelProperty(value = "绑定状态",required = true,example = "0(等待医生进行绑定操作) 1(绑定成功) 2(拒绝) 3(自动断开) 4(手动断开)")
     private BindEnum status;
 
     @ApiModelProperty(value = "解除绑定人,当与userId相同时,即本人解除绑定关系,当不同时,即由医生解除绑定关系")

+ 2 - 2
nb-service-api/app-assistant-api/src/main/java/com/nb/app/assistant/api/enums/ApplyEnum.java

@@ -21,9 +21,9 @@ public enum  ApplyEnum   implements IEnum<Integer> {
     INVITE_CODE(1,"邀请码申请")
     ;
     @Getter
-    @ApiModelProperty("报警编码")
+    @ApiModelProperty("编码")
     private Integer value;
     @Getter
-    @ApiModelProperty("报警内容")
+    @ApiModelProperty("内容")
     private String text;
 }

+ 11 - 1
nb-service-api/app-assistant-api/src/main/java/com/nb/app/assistant/api/feign/IAssistantUserBindClient.java

@@ -53,5 +53,15 @@ public interface IAssistantUserBindClient {
      * @param tenantId
      * @return boolean
      */
-    boolean haveBind(String patientCode, String tenantId);
+    boolean haveBindByPatientCode(String patientCode, String tenantId);
+
+    /**
+     * 描述: 判断该医院的住院号是否已被看护
+     * @author lifang
+     * @date 2022/8/20 14:52
+     * @param patientId
+     * @param tenantId
+     * @return boolean
+     */
+    boolean haveBindByPatientId(String patientId, String tenantId);
 }

+ 2 - 0
nb-service-api/app-doctor-api/src/main/java/com/nb/app/doctor/api/entity/AppDoctorUserEntity.java

@@ -3,6 +3,7 @@ package com.nb.app.doctor.api.entity;
 import com.baomidou.mybatisplus.annotation.*;
 import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
 import com.nb.common.config.mybatisplus.handler.TenantNameHandler;
+import com.nb.core.annotation.Phone;
 import com.nb.core.entity.TenantGenericEntity;
 import com.nb.core.enums.SexEnum;
 import com.nb.core.enums.StatusEnum;
@@ -28,6 +29,7 @@ public class AppDoctorUserEntity extends TenantGenericEntity<String,String> {
     @ApiModelProperty(value = "用户名,用户名不得超过32个字节")
     @Length(max = 32,message = "用户名不得超过32个字节",groups = {Insert.class,Update.class})
     @TableField(updateStrategy = FieldStrategy.NEVER)
+    @Phone(groups = Insert.class)
     private String username;
 
     @ApiModelProperty(value = "密码,密码不得超过32位")

+ 3 - 0
nb-service-api/app-msg-api/src/main/java/com/nb/app/msg/bean/MsgBean.java

@@ -18,6 +18,9 @@ import java.io.Serializable;
 @Builder
 @Getter
 public class MsgBean implements Serializable {
+
+    private String id;
+
     @ApiModelProperty("消息类型")
     private MsgEnum msgType;
 

+ 25 - 0
nb-service-api/web-service-api/src/main/java/com/nb/web/api/feign/IPatientClient.java

@@ -42,8 +42,23 @@ public interface IPatientClient {
      */
     String getClinicId(String patientId);
 
+    /**
+     * 描述: 设置看护位置
+     * @author lifang
+     * @date 2022/9/6 11:32
+     * @param clinicId
+     * @param manageEnum
+     * @return boolean
+     */
     boolean setManageType(String clinicId, ClinicManageEnum manageEnum);
 
+    /**
+     * 描述: 获取看护位置
+     * @author lifang
+     * @date 2022/9/6 11:32
+     * @return boolean
+     */
+    ClinicManageEnum getManageType(String patientId);
     /**
      * 描述: 生成邀请码
      * @author lifang
@@ -72,4 +87,14 @@ public interface IPatientClient {
      * @return void
      */
     void delInviteCode(String inviteCode);
+
+    /**
+     * 描述: 根据住院号获取病人id
+     * @author lifang
+     * @date 2022/9/7 9:00
+     * @param tenantId
+     * @param patientCode
+     * @return String
+     */
+    String lookPatientId(String tenantId, String patientCode);
 }

+ 6 - 0
nb-service/app-assistant/src/main/java/com/nb/app/assistant/auth/AssistantPhoneGranter.java

@@ -1,7 +1,9 @@
 package com.nb.app.assistant.auth;
 
+import cn.hutool.core.util.PhoneUtil;
 import cn.hutool.core.util.StrUtil;
 import cn.hutool.extra.spring.SpringUtil;
+import com.baomidou.mybatisplus.core.toolkit.IdWorker;
 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import com.nb.app.assistant.entity.AssistantUserEntity;
 import com.nb.app.assistant.enums.CaptchaEnum;
@@ -44,6 +46,9 @@ public class AssistantPhoneGranter implements IAuthGranter {
 
     @Override
     public LoginUser grant(TokenParameter source) {
+        if (!PhoneUtil.isPhone(source.getUsername())) {
+            throw new CustomException("手机号校验失败");
+        }
         if (StrUtil.isBlank(source.getUsername())) {
             throw new CustomException("手机号不能为空");
         }
@@ -59,6 +64,7 @@ public class AssistantPhoneGranter implements IAuthGranter {
        //自动注册
         if(user==null){
             user=new AssistantUserEntity();
+            user.setId(IdWorker.getIdStr());
             user.setPhone(source.getUsername());
             user.setNickname(source.getUsername());
             user.setPassword(SecurityUtil.encryptPassword("123456"));

+ 12 - 1
nb-service/app-assistant/src/main/java/com/nb/app/assistant/controller/PatientOperationController.java

@@ -88,6 +88,15 @@ public class PatientOperationController {
         if(ApplyEnum.INVITE_CODE.equals(vo.getApplyType())&& StrUtil.isEmpty(vo.getInviteCode())){
             throw new CustomException("邀请码不能为空");
         }
+        if(ApplyEnum.INVITE_CODE.equals(vo.getApplyType())&& StrUtil.isEmpty(vo.getPatientId())){
+            throw new CustomException("病人id不能为空");
+        }
+        if(StrUtil.isEmpty(vo.getPatientId())){
+            vo.setPatientId(patientClient.lookPatientId(vo.getTenantId(),vo.getPatientCode()));
+        }
+        if(vo.getManageType()==null){
+            vo.setManageType(patientClient.getManageType(vo.getPatientId()));
+        }
         judgePatient(vo.getPatientId());
         judgeUser();
         AssistantUserBindEntity resource = BeanUtil.copyProperties(vo, AssistantUserBindEntity.class);
@@ -103,7 +112,9 @@ public class PatientOperationController {
         }
         judgePatient(inviteCodeResult.getResult().getPatientId());
         judgeUser();
-        return R.success(BeanUtil.copyProperties(inviteCodeResult.getResult(), InviteCodePatientVo.class));
+        InviteCodePatientVo result = BeanUtil.copyProperties(inviteCodeResult.getResult(), InviteCodePatientVo.class);
+        result.setTenantId(inviteCodeResult.getTenantId());
+        return R.success(result);
     }
 
     @PostMapping("/call/{bindId}")

+ 3 - 0
nb-service/app-assistant/src/main/java/com/nb/app/assistant/controller/vo/CaptureVo.java

@@ -1,6 +1,7 @@
 package com.nb.app.assistant.controller.vo;
 
 import com.nb.app.assistant.enums.CaptchaEnum;
+import com.nb.core.annotation.Phone;
 import io.swagger.annotations.ApiModel;
 import io.swagger.annotations.ApiModelProperty;
 import lombok.Data;
@@ -20,6 +21,8 @@ public class CaptureVo {
     @ApiModelProperty(value = "验证码用途",example = "0",allowableValues = "0、短信验证码",required = true)
     @NotNull(message = "验证码用途不能为空")
     private CaptchaEnum type;
+
     @ApiModelProperty(value = "手机号",required = true)
+    @Phone
     private String phone;
 }

+ 22 - 3
nb-service/app-assistant/src/main/java/com/nb/app/assistant/service/LocalAssistantUserBindService.java

@@ -3,8 +3,10 @@ package com.nb.app.assistant.service;
 import cn.hutool.core.bean.BeanUtil;
 import cn.hutool.core.util.StrUtil;
 import cn.hutool.extra.spring.SpringUtil;
+import cn.hutool.json.JSONUtil;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
+import com.baomidou.mybatisplus.core.toolkit.IdWorker;
 import com.nb.app.assistant.api.bean.HandleBindResult;
 import com.nb.app.assistant.api.entity.AssistantUserBindEntity;
 import com.nb.app.assistant.api.feign.IAssistantUserBindClient;
@@ -64,6 +66,12 @@ public class LocalAssistantUserBindService extends BaseService<AssistantUserBind
     @Override
     public boolean save(AssistantUserBindEntity entity) {
         String id = String.valueOf(SecurityUtil.getId());
+        if(StrUtil.isEmpty(entity.getPatientId())){
+            entity.setPatientId(patientClient.lookPatientId(entity.getTenantId(),entity.getPatientCode()));
+        }
+        if(entity.getManageType()==null){
+            entity.setManageType(patientClient.getManageType(entity.getPatientId()));
+        }
         AssistantUserResult currentUser = userService.getById(id);
         entity.setStatus(BindEnum.WAITING);
         entity.setAssistId(currentUser.getId());
@@ -104,14 +112,15 @@ public class LocalAssistantUserBindService extends BaseService<AssistantUserBind
     }
     @Transactional
     public void painCall(String bindId) {
-        //todo
         AssistantUserBindEntity userBind = this.getById(bindId);
         AssistantUserResult user = userService.getById(userBind.getAssistId());
+        String id= IdWorker.getIdStr();
         SpringUtil.publishEvent(new SaveMsgEvent(
                 this,
                 MsgBean.builder()
+                        .id(id)
                         .msgType(MsgEnum.PAIN_CALL)
-                        .payload(userBind.getPatientId())
+                        .payload(id)
                         .senderId(userBind.getAssistId())
                         .senderNickname(user.getNickname())
                         .senderAvatar(user.getAvatar())
@@ -225,7 +234,7 @@ public class LocalAssistantUserBindService extends BaseService<AssistantUserBind
     }
 
     @Override
-    public boolean haveBind(String patientCode, String tenantId) {
+    public boolean haveBindByPatientCode(String patientCode, String tenantId) {
         return this.getOne(new QueryWrapper<AssistantUserBindEntity>()
                 .lambda()
                 .eq(AssistantUserBindEntity::getTenantId,tenantId)
@@ -234,6 +243,16 @@ public class LocalAssistantUserBindService extends BaseService<AssistantUserBind
                 .last("limit 1"))!=null;
     }
 
+    @Override
+    public boolean haveBindByPatientId(String patientId, String tenantId) {
+        return this.getOne(new QueryWrapper<AssistantUserBindEntity>()
+                .lambda()
+                .eq(AssistantUserBindEntity::getTenantId,tenantId)
+                .eq(AssistantUserBindEntity::getPatientId,patientId)
+                .eq(AssistantUserBindEntity::getStatus,BindEnum.SUCCESS)
+                .last("limit 1"))!=null;
+    }
+
     /**
      * 描述:查询当前用户所看护的所有病人信息
      * @author lifang

+ 1 - 1
nb-service/app-assistant/src/main/java/com/nb/app/assistant/utils/CaptchaUtil.java

@@ -29,7 +29,7 @@ public class CaptchaUtil {
 
         String result = codeCache.getWithTTLOnly(key);
         if (StrUtil.isNullOrUndefined(result)) {
-            result= RandomUtil.randomNumbers(4);
+            result= RandomUtil.randomNumbers(6);
             codeCache.put(key,result,5, TimeUnit.MINUTES);
         }
         return result;

+ 7 - 1
nb-service/app-doctor/src/main/java/com/nb/app/doctor/controller/PatientMonitorController.java

@@ -83,6 +83,12 @@ public class PatientMonitorController {
         return R.success(lifeCycleManage.isOnline(assistId));
     }
 
+    @ApiOperation("判断当前病人是否有看护人")
+    @PostMapping("/bind/{patientId}")
+    public R<Boolean> isBind(@RequestAttribute("tenantId")@ApiParam(hidden = true) String tenantId,@PathVariable("patientId")String patientId){
+        return R.success(userBindClient.haveBindByPatientId(patientId,tenantId));
+    }
+
     @PostMapping("/monitor/{patientId}")
     @ApiOperation(value = "查看病人当前监控详情")
     public R<PatientMonitorDetailResult> monitorPatient(@PathVariable("patientId") String patientId) {
@@ -92,7 +98,7 @@ public class PatientMonitorController {
     @PostMapping("/invite/code")
     @ApiOperation(value = "患者看护邀请码,默认失效失效(7天)")
     public R<InviteCodeResult> inviteCode(@RequestAttribute("tenantId")@ApiParam(hidden = true) String tenantId, @RequestBody@Validated InviteCodeVo resource) {
-        if(userBindClient.haveBind(resource.getPatientCode(),tenantId)){
+        if(userBindClient.haveBindByPatientCode(resource.getPatientCode(),tenantId)){
             throw new CustomException("该病人已被看护");
         }
         return R.success(patientClient.generateInviteCode(tenantId,resource.getPatientCode(),resource.getManage()));

+ 1 - 1
nb-service/app-msg/src/main/java/com/nb/app/msg/entity/AppConsultEntity.java

@@ -57,7 +57,7 @@ public class AppConsultEntity  extends GenericEntity<String> {
     @NotNull(message = "内容描述不能为空",groups = Insert.class)
     private String content;
 
-    @ApiModelProperty(value = "看护人id")
+    @ApiModelProperty(value = "看护人id",required = true)
     @NotNull(message = "看护人id不能为空",groups = Insert.class)
     private String assistId;
 

+ 134 - 0
nb-service/iot-service/src/main/java/com/nb/mq/entity/PcAnalgesicScoreEntity.java

@@ -0,0 +1,134 @@
+package com.nb.mq.entity;
+
+
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableName;
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableId;
+import java.time.LocalDateTime;
+import java.io.Serializable;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.experimental.Accessors;
+
+/**
+ *
+ * 
+ * </p>
+ *
+ * @author fanfan
+ * @since 2020-07-03
+ */
+@Data
+@EqualsAndHashCode(callSuper = false)
+@Accessors(chain = true)
+@TableName("bus_analgesic_score")
+@ApiModel(value="BusAnalgesicScoreEntity对象", description="")
+public class PcAnalgesicScoreEntity implements Serializable {
+
+    private static final long serialVersionUID = 1L;
+
+    @ApiModelProperty(value = "主键",hidden = true)
+    @TableId(value = "id", type = IdType.AUTO)
+    private Long id;
+
+    @ApiModelProperty(value = "病人ID")
+    public String patientId;
+
+    @ApiModelProperty(value = "泵号")
+    private String pumpCode;
+
+    @ApiModelProperty(value = "医院编码")
+    private String hospitalCode;
+
+    @ApiModelProperty(value = "住院号")
+    private String patientCode;
+
+    @ApiModelProperty(value = "疼痛评分静止")
+    private Integer statics;
+
+    @ApiModelProperty(value = "疼痛评分活动")
+    private Integer activity;
+
+    @ApiModelProperty(value = "镇静评分")
+    private Integer calm;
+
+    @ApiModelProperty(value = "左上肢")
+    private Integer leftArm;
+
+    @ApiModelProperty(value = "左下肢")
+    private Integer leftLeg;
+
+    @ApiModelProperty(value = "右上肢")
+    private Integer rightArm;
+
+    @ApiModelProperty(value = "右下肢")
+    private Integer rightLeg;
+
+    @ApiModelProperty(value = "恶心呕吐")
+    private Integer nauseaVomit;
+
+    @ApiModelProperty(value = "瘙痒")
+    private Integer itch;
+
+    @ApiModelProperty(value = "眩晕")
+    private Integer vertigo;
+
+    @ApiModelProperty(value = "咽喉疼痛")
+    private Integer soreThroat;
+
+    @ApiModelProperty(value = "尿潴留")
+    private Integer uroschesis;
+
+    @ApiModelProperty(value = "呼吸抑制")
+    private Integer breathDepression;
+
+    @ApiModelProperty(value = "声音嘶哑")
+    private Integer hoarseness;
+
+    @ApiModelProperty(value = "认知障碍")
+    private Integer cognitionObstacle;
+
+    @ApiModelProperty(value = "其他")
+    private String other;
+
+    @ApiModelProperty(value = "满意度")
+    private Integer satisfaction;
+
+    @ApiModelProperty(value = "创建时间",hidden = true)
+    private LocalDateTime gmtCreate;
+
+    @ApiModelProperty(value = "更新时间",hidden = true)
+    private LocalDateTime gmtModified;
+
+    @ApiModelProperty(value = "评价时间",hidden = true)
+    private LocalDateTime followDate;
+
+    @ApiModelProperty(value = "评价人")
+    private String creator;
+
+    @ApiModelProperty(value = "产品编码")
+    private String productCode;
+
+    @ApiModelProperty(value = "评价传输ID",hidden = true)
+    @TableField(exist = false)
+    private String analgesicScoreId;
+
+    @ApiModelProperty(value = "收缩压")
+    private String  SBP;
+
+
+    @ApiModelProperty(value = "舒张压")
+    private String  DBP;
+
+    @ApiModelProperty(value = "心率")
+    private String HR;
+
+    @ApiModelProperty(value = "呼吸频率")
+    private String RR;
+
+    @ApiModelProperty(value = "血氧饱和度")
+    private String SpO2;
+}

+ 107 - 0
nb-service/iot-service/src/main/java/com/nb/mq/entity/PcPatientEntity.java

@@ -0,0 +1,107 @@
+package com.nb.mq.entity;
+import java.time.LocalDateTime;
+import java.io.Serializable;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+/**
+ * <p>
+ * 
+ * </p>
+ *
+ * @author fanfan
+ * @since 2020-07-03
+ */
+@Data
+public class PcPatientEntity implements Serializable {
+
+    private static final long serialVersionUID = 1L;
+
+    @ApiModelProperty(value = "主键/病人id")
+    private String patientId;
+
+    @ApiModelProperty(value = "医院Id")
+    private String hospitalCode;
+
+    @ApiModelProperty(value = "产品编号")
+    private String productCode;
+
+    @ApiModelProperty(value = "住院号")
+    private String patientCode;
+
+    @ApiModelProperty(value = "泵号")
+    private String pumpCode;
+
+    @ApiModelProperty(value = "姓名")
+    private String name;
+
+    @ApiModelProperty(value = "性别")
+    private String sex;
+
+    @ApiModelProperty(value = "体重")
+    private String weight;
+
+    @ApiModelProperty(value = "身高")
+    private String height;
+
+    @ApiModelProperty(value = "年龄")
+    private Integer age;
+
+    @ApiModelProperty(value = "病区")
+    private String wardCode;
+
+    @ApiModelProperty(value = "床号")
+    private String bedCode;
+
+    @ApiModelProperty(value = "手术名称")
+    private String operationName;
+
+    @ApiModelProperty(value = "手术医生")
+    private String operationDoctor;
+
+    @ApiModelProperty(value = "ASA")
+    private String asa;
+
+    @ApiModelProperty(value = "镇痛方式")
+    private String easyMode;
+
+    @ApiModelProperty(value = "麻醉医生")
+    private String anesthesiaDoctor1;
+
+    @ApiModelProperty(value = "麻醉医生2")
+    private String anesthesiaDoctor2;
+
+    @ApiModelProperty(value = "麻醉方式")
+    private String anesthesiaMode;
+
+    @ApiModelProperty(value = "配置人员")
+    private String configPerson;
+
+    @ApiModelProperty(value = "配方")
+    private String formula;
+
+    @ApiModelProperty(value = "撤泵人")
+    private String undoPerson;
+
+    @ApiModelProperty(value = "销毁人")
+    private String destoryPerson;
+
+    @ApiModelProperty(value = "见证人")
+    private String witnessPerson;
+
+    @ApiModelProperty(value = "撤泵时间")
+    private LocalDateTime undoTime;
+
+    @ApiModelProperty(value = "盐值")
+    private String salt;
+
+    @ApiModelProperty(value = "剩余量处置")
+    private String remain;
+
+    @ApiModelProperty(value = "备注")
+    private String remark;
+
+    @ApiModelProperty(value = "是否删除")
+    private Boolean isDelete;
+
+    private String bmi;
+}

+ 173 - 0
nb-service/iot-service/src/main/java/com/nb/mq/entity/PcPumpEntity.java

@@ -0,0 +1,173 @@
+package com.nb.mq.entity;
+import java.math.BigDecimal;
+
+import java.time.LocalDateTime;
+import java.io.Serializable;
+import java.util.Date;
+import com.fasterxml.jackson.annotation.JsonSetter;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.experimental.Accessors;
+/**
+ * <p>
+ * 
+ * </p>
+ *
+ * @author fanfan
+ * @since 2020-07-03
+ */
+@Data
+@EqualsAndHashCode(callSuper = false)
+@Accessors(chain = true)
+public class PcPumpEntity implements Serializable {
+
+    private static final long serialVersionUID = 1L;
+
+    @ApiModelProperty(value = "主键")
+    private Long id;
+
+    @ApiModelProperty(value = "注液泵编码")
+    private String PumpCode;
+
+    @ApiModelProperty(value = "产品编码")
+    private String SysProduct_ID;
+
+    @ApiModelProperty(value = "医院编码")
+    private String SysHospital_ID;
+
+    @ApiModelProperty(value = "住院号")
+    private String PatientCode;
+
+    @ApiModelProperty(value = "剩余量")
+    private BigDecimal BalanceQuantity;
+
+    @ApiModelProperty(value = "持续量(智能泵当前流速)(脉冲泵KVO)")
+    private BigDecimal ContinueQuantity;
+
+    @ApiModelProperty(value = "自控量")
+    private BigDecimal SelfQuantity;
+
+    @ApiModelProperty(value = "锁定时间")
+    private Integer LockTime;
+
+    @ApiModelProperty(value = "已输入量")
+    private BigDecimal InputQuantity;
+
+    @ApiModelProperty(value = "有效次数")
+    private Integer TrueNum;
+
+    @ApiModelProperty(value = "无效次数")
+    private Integer FalseNum;
+
+    @ApiModelProperty(value = "极限量")
+    private BigDecimal MaxQuantity;
+
+    @ApiModelProperty(value = "首次量")
+    private Integer FirstQuantity;
+
+    @ApiModelProperty(value = "追加量")
+    private BigDecimal SingleQuantity;
+
+    @ApiModelProperty(value = "总量")
+    private Integer AllQuantity;
+
+    @ApiModelProperty(value = "总按次数")
+    private Integer AllCount;
+
+    @ApiModelProperty(value = "脉冲量")
+    private BigDecimal PulseQuantity;
+
+    @ApiModelProperty(value = "脉冲锁时")
+    private Integer PulseLockTime;
+
+    @ApiModelProperty(value = "首次量锁时")
+    private Integer FirstLockTime;
+
+    @ApiModelProperty(value = "上限")
+    private BigDecimal UpperLimit;
+
+    @ApiModelProperty(value = "下限")
+    private BigDecimal LowerLimit;
+
+    @ApiModelProperty(value = "自调比例")
+    private Integer CustomScate;
+
+    @ApiModelProperty(value = "加档有效次数")
+    private Integer AddTrueFrequency;
+
+    @ApiModelProperty(value = "镇痛泵运行状态")
+    private Integer RunState;
+
+    @ApiModelProperty(value = "镇痛泵状态BUF")
+    private Integer BUFState1;
+
+    @ApiModelProperty(value = "镇痛泵状态BUF")
+    private Integer BUFState2;
+
+    @ApiModelProperty(value = "镇痛泵状态BUF")
+    private Integer BUFState3;
+
+    @ApiModelProperty(value = "镇痛泵状态BUF")
+    @JsonSetter(value = "BUFState4")
+    private Integer BUFState4;
+
+    @ApiModelProperty(value = "镇痛泵状态BUF")
+    private Integer BUFState5;
+
+    @ApiModelProperty(value = "镇痛泵状态BUF")
+    private Integer BUFState6;
+
+    @ApiModelProperty(value = "镇痛泵状态BUF")
+    private Integer BUFState7;
+
+    @ApiModelProperty(value = "镇痛泵状态BUF")
+    private Integer BUFState8;
+
+    @ApiModelProperty(value = "镇痛泵状态BUF")
+    private Integer BUFState9;
+
+    @ApiModelProperty(value = "镇痛评分")
+    private Integer Score;
+
+    @ApiModelProperty(value = "加档周期")
+    private BigDecimal FilingCycle;
+
+    @ApiModelProperty(value = "减档周期")
+    private BigDecimal ReductionPeriod;
+
+    @ApiModelProperty(value = "呼叫标记")
+    private Integer CallFlag;
+
+    @ApiModelProperty(value = "开始时间")
+    private Date StartTime;
+
+    @ApiModelProperty(value = "是否可见")
+    private Boolean Visible;
+
+    @ApiModelProperty(value = "状态标记")
+    private Integer StateFlag;
+
+    @ApiModelProperty(value = "是否在服务区")
+    private Integer NoSignal;
+
+    @ApiModelProperty(value = "显示状态")
+    private String ViewState;
+
+    @ApiModelProperty(value = "备注")
+    private String Remark;
+
+    @ApiModelProperty(value = "最后上传时间")
+    private LocalDateTime LastUploadTime;
+
+    @ApiModelProperty(value = "创建时间",hidden = true)
+    private LocalDateTime gmtCreate;
+
+    @ApiModelProperty(value = "更新时间",hidden = true)
+    private LocalDateTime gmtModified;
+
+    @ApiModelProperty(value = "是否是家用")
+    private Boolean isFamily;
+
+
+}

+ 11 - 0
nb-service/iot-service/src/main/java/com/nb/mq/listener/RabbitMqListener.java

@@ -0,0 +1,11 @@
+package com.nb.mq.listener;
+
+/**
+ * @author lifang
+ * @version 1.0.0
+ * @ClassName RabbitMqListener.java
+ * @Description TODO
+ * @createTime 2022年09月07日 13:40:00
+ */
+public class RabbitMqListener {
+}

+ 18 - 19
nb-service/web-service/src/main/java/com/nb/web/service/bus/hospital/HospitalManager.java

@@ -98,25 +98,24 @@ public class HospitalManager {
         init(configStorageManager);
 
         singleOffsetsDeviceExecutor.scheduleWithFixedDelay(()->{
-                    List<BusInfusionHistoryEntity> infusions = infusionHistoryService.list(new QueryWrapper<BusInfusionHistoryEntity>()
-                            .lambda()
-                            .eq(BusInfusionHistoryEntity::getFinished, false)
-                            .eq(BusInfusionHistoryEntity::getIsUndo, false)
-                            .eq(BusInfusionHistoryEntity::getTenantId,this.hospitalId));
-                    infusions
-                            .parallelStream()
-                            .forEach(infusionInfo->{
-                                BusDeviceRunningEntity source = BeanUtil.toBean(infusionInfo, BusDeviceRunningEntity.class);
-                                source.setInfusionId(infusionInfo.getId());
-                                source.setUploadTime(infusionInfo.getLastUploadTime());
-                                extraConfigHandler.handler(source);
-                                autoUndoConfigHandler.handler(source);
-                                finishMonitorConfigHandler.handler(source);
-                            });
-
-
-                },
-                0,  Math.addExact(30,RandomUtil.randomInt(0,60)),TimeUnit.MINUTES);
+            List<BusInfusionHistoryEntity> infusions = infusionHistoryService.list(new QueryWrapper<BusInfusionHistoryEntity>()
+                    .lambda()
+                    .eq(BusInfusionHistoryEntity::getFinished, false)
+                    .eq(BusInfusionHistoryEntity::getIsUndo, false));
+            infusions
+                    .parallelStream()
+                    .forEach(infusionInfo->{
+                        BusDeviceRunningEntity source = BeanUtil.toBean(infusionInfo, BusDeviceRunningEntity.class);
+                        source.setInfusionId(infusionInfo.getId());
+                        source.setUploadTime(infusionInfo.getLastUploadTime());
+                        extraConfigHandler.handler(source);
+                        autoUndoConfigHandler.handler(source);
+                        finishMonitorConfigHandler.handler(source);
+                    });
+
+
+        },
+        0,  Math.addExact(30,RandomUtil.randomInt(0,60)),TimeUnit.MINUTES);
     }
 
     private void init(ConfigStorageManager configStorageManager){

+ 20 - 0
nb-service/web-service/src/main/java/com/nb/web/service/bus/service/LocalBusPatientService.java

@@ -232,6 +232,7 @@ public class LocalBusPatientService extends BaseService<BusPatientMapper, BusPat
      * @param patientCode
      * @return
      */
+    @Transactional(rollbackFor = Exception.class)
     public BusPatientEntity getOneByHospitalAndPatientCode(String tenantId, String patientCode) {
         BusPatientEntity patient = this.getOne(new QueryWrapper<BusPatientEntity>().lambda()
                 .eq(BusPatientEntity::getTenantId, tenantId)
@@ -516,6 +517,19 @@ public class LocalBusPatientService extends BaseService<BusPatientMapper, BusPat
         return result;
     }
 
+    @Override
+    public ClinicManageEnum getManageType(String patientId) {
+        String clinicId = getClinicId(patientId);
+        if(StrUtil.isBlank(clinicId)){
+            return null;
+        }
+        BusClinicEntity clinic = clinicService.getById(clinicId);
+        if(clinic==null){
+            return null;
+        }
+        return clinic.getManageType();
+    }
+
     @Override
     @Transactional(rollbackFor = Exception.class)
     public InviteCodeResult generateInviteCode(String tenantId,String patientCode, ClinicManageEnum manageType) {
@@ -564,4 +578,10 @@ public class LocalBusPatientService extends BaseService<BusPatientMapper, BusPat
     public void delInviteCode(String inviteCode) {
         inviteCodeUtil.delCode(inviteCode);
     }
+
+    @Override
+    public String lookPatientId(String tenantId, String patientCode) {
+        BusPatientEntity patient = this.getOneByHospitalAndPatientCode(tenantId, patientCode);
+        return patient.getId();
+    }
 }

+ 1 - 1
nb-service/web-service/src/main/resources/mapper/bus/BusPatientMapper.xml

@@ -440,7 +440,7 @@
         </where>
         )
         as p
-        join
+        left join
         bus_infusion_history as i on p.infusion_id=i.id
         left join (select device_id,alias from bus_device) as d on d.device_id=i.device_id
         left join (select * from bus_clinic where monitor_type=1) c on p.clinic_id=c.id