18339543638 před 3 roky
rodič
revize
60c59edb04

+ 0 - 2
nb-admin/pom.xml

@@ -15,12 +15,10 @@
         <dependency>
             <groupId>com.tuoren</groupId>
             <artifactId>mq-common</artifactId>
-            <version>1.0</version>
         </dependency>
         <dependency>
             <groupId>com.tuoren</groupId>
             <artifactId>nb-im</artifactId>
-            <version>${nb.version}</version>
         </dependency>
         <dependency>
             <groupId>com.tuoren</groupId>

+ 3 - 0
nb-admin/src/main/java/com/nb/admin/AdminApplication.java

@@ -4,6 +4,7 @@ import com.nb.common.config.properties.DruidProperties;
 import com.nb.common.config.web.RequestCheckProperties;
 import org.mybatis.spring.annotation.MapperScan;
 import org.redisson.spring.starter.RedissonAutoConfiguration;
+import org.springframework.amqp.rabbit.annotation.EnableRabbit;
 import org.springframework.boot.SpringApplication;
 import org.springframework.boot.autoconfigure.SpringBootApplication;
 import org.springframework.boot.autoconfigure.data.redis.RedisAutoConfiguration;
@@ -22,6 +23,7 @@ import org.tio.websocket.starter.EnableTioWebSocketServer;
  */
 @SpringBootApplication(scanBasePackages ={
         "com.nb.aliyun",
+        "com.nb.mq",
         "com.nb.web",
         "com.nb.auth",
         "com.nb.admin",
@@ -34,6 +36,7 @@ exclude = {RedisAutoConfiguration.class,RedissonAutoConfiguration.class})
 @EnableTioWebSocketServer
 @EnableScheduling
 @EnableAsync
+@EnableRabbit
 @MapperScan({"com.nb.**.mapper"})
 @EnableConfigurationProperties({RequestCheckProperties.class, DruidProperties.class})
 @ServletComponentScan(basePackages = "com.nb.common.config")

+ 2 - 2
nb-admin/src/main/resources/application-rabbitmq.yml

@@ -2,8 +2,8 @@ spring:
   rabbitmq:
     host: 192.168.100.32
     port: 5672
-    username: admin
-    password: admin
+    username: guest
+    password: guest
     virtual-host: netpump
     listener:
       simple:

+ 1 - 0
nb-admin/src/main/resources/application.yml

@@ -7,6 +7,7 @@ spring:
     name: nb
   profiles:
     active: dev
+    include: rabbitmq
   jackson:
     time-zone: GMT+8
 

+ 2 - 0
nb-service-api/web-service-api/src/main/java/com/nb/web/api/feign/IClinicClient.java

@@ -53,4 +53,6 @@ public interface IClinicClient {
      * @return void
      */
     void setCurrentClinicByHis(BusClinicEntity source);
+
+    void update(String id, BusClinicEntity clinic);
 }

+ 54 - 66
nb-service/iot-service/src/main/java/com/nb/mq/entity/PcPumpEntity.java

@@ -33,140 +33,128 @@ public class PcPumpEntity implements Serializable {
     private Long id;
 
     @ApiModelProperty(value = "注液泵编码")
-    private String PumpCode;
+    private String pumpCode;
 
     @ApiModelProperty(value = "产品编码")
-    private String SysProduct_ID;
+    private String productCode;
 
     @ApiModelProperty(value = "医院编码")
-    private String SysHospital_ID;
+    private String hospitalCode;
 
     @ApiModelProperty(value = "住院号")
-    private String PatientCode;
+    private String patientCode;
 
     @ApiModelProperty(value = "剩余量")
-    private BigDecimal BalanceQuantity;
+    private BigDecimal remainQuantity;
 
     @ApiModelProperty(value = "持续量(智能泵当前流速)(脉冲泵KVO)")
-    private BigDecimal ContinueQuantity;
+    private BigDecimal continueQuantity;
 
     @ApiModelProperty(value = "自控量")
-    private BigDecimal SelfQuantity;
+    private BigDecimal selfControlQuantity;
 
     @ApiModelProperty(value = "锁定时间,即自控锁时")
-    private BigDecimal LockTime;
+    private BigDecimal lockTime;
 
     @ApiModelProperty(value = "已输入量")
-    private BigDecimal InputQuantity;
+    private BigDecimal inputQuantity;
 
     @ApiModelProperty(value = "有效次数")
-    private Integer TrueNum;
+    private Integer validTime;
 
     @ApiModelProperty(value = "无效次数")
-    private Integer FalseNum;
+    private Integer invalidTime;
 
     @ApiModelProperty(value = "极限量")
-    private BigDecimal MaxQuantity;
+    private BigDecimal maxQuantity;
 
     @ApiModelProperty(value = "首次量")
-    private Integer FirstQuantity;
+    private Integer firstQuantity;
 
     @ApiModelProperty(value = "追加量")
-    private BigDecimal SingleQuantity;
+    private BigDecimal singleQuantity;
 
     @ApiModelProperty(value = "总量")
-    private Integer AllQuantity;
+    private Integer totalQuantity;
 
     @ApiModelProperty(value = "总按次数")
-    private Integer AllCount;
+    private Integer totalCount;
 
     @ApiModelProperty(value = "脉冲量")
-    private BigDecimal PulseQuantity;
+    private BigDecimal pulseQuantity;
 
     @ApiModelProperty(value = "脉冲锁时")
-    private Integer PulseLockTime;
+    private Integer pulseLockTime;
 
     @ApiModelProperty(value = "首次量锁时")
-    private Integer FirstLockTime;
+    private Integer firsLockTime;
 
     @ApiModelProperty(value = "上限")
-    private BigDecimal UpperLimit;
+    private BigDecimal upperLimit;
 
     @ApiModelProperty(value = "下限")
-    private BigDecimal LowerLimit;
+    private BigDecimal lowerLimit;
 
     @ApiModelProperty(value = "自调比例")
-    private Integer CustomScate;
+    private Integer customScate;
 
     @ApiModelProperty(value = "加档有效次数")
-    private Integer AddTrueFrequency;
+    private Integer addValidTime;
 
     @ApiModelProperty(value = "镇痛泵运行状态")
-    private Integer RunState;
+    private Integer runState;
 
     @ApiModelProperty(value = "镇痛泵状态BUF")
-    private Integer BUFState1;
+    private Integer bufState1;
 
     @ApiModelProperty(value = "镇痛泵状态BUF")
-    private Integer BUFState2;
+    private Integer bufState2;
 
     @ApiModelProperty(value = "镇痛泵状态BUF")
-    private Integer BUFState3;
+    private Integer bufState3;
 
     @ApiModelProperty(value = "镇痛泵状态BUF")
-    @JsonSetter(value = "BUFState4")
-    private Integer BUFState4;
+    @JsonSetter(value = "bufState4")
+    private Integer bufState4;
 
     @ApiModelProperty(value = "镇痛泵状态BUF")
-    private Integer BUFState5;
+    private Integer bufState5;
 
     @ApiModelProperty(value = "电量")
-    private Integer BUFState6;
+    private Integer bufState6;
 
     @ApiModelProperty(value = "镇痛泵状态BUF")
-    private Integer BUFState7;
+    private Integer bufState7;
 
     @ApiModelProperty(value = "镇痛泵状态BUF")
-    private Integer BUFState8;
+    private Integer bufState8;
 
     @ApiModelProperty(value = "镇痛泵状态BUF")
-    private Integer BUFState9;
+    private Integer bufState9;
 
     @ApiModelProperty(value = "镇痛评分")
-    private Integer Score;
+    private Integer score;
 
     @ApiModelProperty(value = "加档周期")
-    private BigDecimal FilingCycle;
+    private BigDecimal addCycle;
 
     @ApiModelProperty(value = "减档周期")
-    private BigDecimal ReductionPeriod;
+    private BigDecimal reduceCycle;
 
     @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;
+    private Integer callFlag;
 
     @ApiModelProperty(value = "显示状态")
-    private String ViewState;
+    private String viewState;
 
     @ApiModelProperty(value = "最后上传时间")
-    private LocalDateTime LastUploadTime;
+    private LocalDateTime lastUploadTime;
 
 
     public BusDeviceRunningEntity toDevice(){
         BusDeviceRunningEntity result = new BusDeviceRunningEntity();
         DeviceTypeEnum deviceType=DeviceTypeEnum.other;
-        switch ( this.getSysProduct_ID()){
+        switch ( this.getProductCode()){
             case "1":
                 deviceType=DeviceTypeEnum.continuous;
                 break;
@@ -186,10 +174,10 @@ public class PcPumpEntity implements Serializable {
         result.setDataNumber(1);
 
         result.setPatientCode(this.getPatientCode());
-        result.setTenantId(this.getSysHospital_ID());
-        result.setTotalDose(this.getAllQuantity());
+        result.setTenantId(this.getHospitalCode());
+        result.setTotalDose(this.getTotalQuantity());
         result.setInputDose(this.getInputQuantity());
-        result.setRemainDose(this.getBalanceQuantity());
+        result.setRemainDose(this.getRemainQuantity());
         result.setFirstDose(this.getFirstQuantity());
         result.setMaxDose(this.getMaxQuantity());
         result.setAppendDose(this.getSingleQuantity());
@@ -197,21 +185,21 @@ public class PcPumpEntity implements Serializable {
         result.setContinueDose(this.getContinueQuantity());
         result.setType(deviceType);
 
-        result.setPcaInvalidCount(this.getFalseNum());
-        result.setPcaValidCount(this.getTrueNum());
-        result.setPcaTotalCount(this.getAllCount());
+        result.setPcaInvalidCount(this.getInvalidTime());
+        result.setPcaValidCount(this.getValidTime());
+        result.setPcaTotalCount(this.getTotalCount());
 
 
         parseRunState(result,this.getRunState());
-        parseBufSate1(result,this.getBUFState1());
-        parseBufSate2(result,this.getBUFState2());
-        parseBufSate3(result,this.getBUFState3());
+        parseBufSate1(result,this.getBufState1());
+        parseBufSate2(result,this.getBufState2());
+        parseBufSate3(result,this.getBufState3());
         //镇痛效果由平台自行判断 bufstate4
-        parseBufSate5(result,this.getBUFState5());
-        parseBufSate6(result,this.getBUFState6());
+        parseBufSate5(result,this.getBufState5());
+        parseBufSate6(result,this.getBufState6());
         //电机失控取消 bufstate7
-        parseBufSate8(result,this.getBUFState8());
-        parseBufSate9(result,this.getBUFState9());
+        parseBufSate8(result,this.getBufState8());
+        parseBufSate9(result,this.getBufState9());
         //        result.setRunState();
 //        result.setAlarm();
         return result;

+ 17 - 5
nb-service/iot-service/src/main/java/com/nb/mq/listener/RabbitMqListener.java

@@ -1,5 +1,7 @@
 package com.nb.mq.listener;
 
+import cn.hutool.core.date.DateUtil;
+import cn.hutool.core.util.StrUtil;
 import cn.hutool.json.JSONUtil;
 import com.nb.mq.entity.PcAnalgesicScoreEntity;
 import com.nb.mq.entity.PcPatientEntity;
@@ -19,6 +21,7 @@ import org.springframework.amqp.rabbit.annotation.Queue;
 import org.springframework.amqp.rabbit.annotation.RabbitListener;
 import org.springframework.messaging.handler.annotation.Payload;
 import org.springframework.stereotype.Component;
+import org.springframework.transaction.annotation.Transactional;
 
 import java.util.Date;
 import java.util.Optional;
@@ -47,6 +50,7 @@ public class RabbitMqListener {
      * @return void
      */
     @RabbitListener(queuesToDeclare = @Queue("cloud.patient"))
+    @Transactional(rollbackFor = Exception.class)
     public void patientQueue(@Payload String body) {
         log.info("消息队列中,病人队列{cloud.patient},接受消息:{}",body);
         PcPatientEntity source = JSONUtil.toBean(body, PcPatientEntity.class);
@@ -54,7 +58,6 @@ public class RabbitMqListener {
         BusClinicEntity clinic= source.toClinic(patientId);
         PatientMonitorDetailResult patientDetail = patientClient.lookPatientDetail(patientId);
         BusClinicEntity existClinic = patientDetail.getClinic();
-        clinic.setStartTime(existClinic.getStartTime()==null?new Date():existClinic.getStartTime());
         if(Boolean.TRUE.equals(clinic.getFinished())){
             //进行撤泵处理
             clinicClient.finish(existClinic.getId(),existClinic.getTenantId());
@@ -64,13 +67,21 @@ public class RabbitMqListener {
             }
             return;
         }
-        //当上一个临床状态为已结束时,生成新的临床信息
-        if(Boolean.TRUE.equals(existClinic.getFinished())){
+        //当上一个临床状态为已结束时,对比临床信息是否发生改变,生成新的临床信息
+        boolean sameClinic=false;
+        if(StrUtil.isNotEmpty(existClinic.getId())){
+            sameClinic=(clinic.getSurgeryName()+clinic.getStartTime()).equals(existClinic.getSurgeryName()+existClinic.getStartTime());
+        }
+
+        if(!sameClinic){
+            //为了避免网络延迟,开始时间往前推1个小时
+            clinic.setStartTime(DateUtil.offsetHour(new Date(),-1));
             clinic=clinicClient.insertFromHis(clinic);
+            clinicClient.setCurrentClinicByHis(clinic);
         }else {
-            clinic.setId(existClinic.getId());
+            clinic.setStartTime(existClinic.getStartTime());
+            clinicClient.update(existClinic.getId(),clinic);
         }
-        clinicClient.setCurrentClinicByHis(clinic);
     }
 
     /**
@@ -81,6 +92,7 @@ public class RabbitMqListener {
      * @return void
      */
     @RabbitListener(queuesToDeclare = @Queue("cloud.pump"))
+    @Transactional(rollbackFor = Exception.class)
     public void pumpQueue(@Payload String body) {
         log.info("消息队列中,网络泵队列{cloud.pump},接受消息:{}",body);
         PcPumpEntity source = JSONUtil.toBean(body, PcPumpEntity.class);

+ 1 - 1
nb-service/web-service/src/main/java/com/nb/web/service/bus/registry/device/ClusterDeviceOperator.java

@@ -229,7 +229,7 @@ public class ClusterDeviceOperator implements DeviceOperator {
         if(value==null){
             BusInfusionHistoryEntity lastInfusion = getLastInfusion();
             if(lastInfusion==null){
-                value=Value.simple(null);
+                value=Value.simple(0);
             }else {
                 value=Value.simple(lastInfusion.getDataNumber());
             }

+ 6 - 0
nb-service/web-service/src/main/java/com/nb/web/service/bus/service/LocalBusClinicService.java

@@ -247,6 +247,12 @@ public class LocalBusClinicService extends BaseService<BusClinicMapper, BusClini
         wsPublishUtils.publishPatientMonitor(source.getPatientId(),source.getTenantId());
     }
 
+    @Override
+    public void update(String id, BusClinicEntity clinic) {
+        clinic.setId(id);
+        this.updateById(clinic);
+    }
+
     public ClinicStatsReturnResult stats(ClinicStatsVo statsVo) {
         return ClinicStatsReturnResult.of(this.baseMapper.stats(statsVo));
     }

+ 1 - 1
nb-service/web-service/src/main/java/com/nb/web/service/bus/service/LocalBusDeviceService.java

@@ -161,7 +161,7 @@ public class LocalBusDeviceService extends BaseService<BusDeviceMapper, BusDevic
         }else {
             // 添加设备
             try {
-                entity.setTenantId(Constants.DefaultHospital);
+//                entity.setTenantId(Constants.DefaultHospital);
                 return this.save(entity);
             }catch (Exception e){
                 log.error("新增设备失败,【{}】",ExceptionUtil.getExceptionMsg(e));

+ 8 - 6
nb-service/web-service/src/main/java/com/nb/web/service/bus/service/LocalBusPatientService.java

@@ -480,12 +480,14 @@ public class LocalBusPatientService extends BaseService<BusPatientMapper, BusPat
 
         BusInfusionHistoryEntity infusion =infusionService.getById(infusionId);
 
-        Optional.ofNullable(deviceService.getByDeviceId(infusion.getDeviceId()))
-                .map(device-> {
-                    //填充泵别名
-                    infusion.setAlias(device.getAlias());
-                    return device;
-                });
+        if(infusion!=null){
+            Optional.ofNullable(deviceService.getByDeviceId(infusion.getDeviceId()))
+                    .map(device-> {
+                        //填充泵别名
+                        infusion.setAlias(device.getAlias());
+                        return device;
+                    });
+        }
 
         clinic.setPatientCode(patient.getCode());
 

+ 5 - 0
pom.xml

@@ -71,6 +71,11 @@
     <!-- 依赖管理 -->
     <dependencyManagement>
         <dependencies>
+            <dependency>
+                <groupId>com.tuoren</groupId>
+                <artifactId>mq-common</artifactId>
+                <version>${nb.version}</version>
+            </dependency>
             <dependency>
                 <groupId>com.tuoren</groupId>
                 <artifactId>nb-im</artifactId>