Browse Source

add 添加验签逻辑

18339543638 3 years ago
parent
commit
6bbc04153a
20 changed files with 611 additions and 21 deletions
  1. 1 0
      coffee-admin/src/main/java/com/coffee/admin/AdminApplication.java
  2. 62 0
      coffee-common/src/main/java/com/coffee/common/config/CacheHttpServletRequestWrapper.java
  3. 38 0
      coffee-common/src/main/java/com/coffee/common/config/CachingContentFilter.java
  4. 1 1
      coffee-common/src/main/java/com/coffee/common/crud/controller/BaseSaveController.java
  5. 7 2
      coffee-framework/src/main/java/com/coffee/framework/config/WebAppMvcConfig.java
  6. 1 1
      coffee-framework/src/main/java/com/coffee/framework/config/mybatisplus/MybatisPlusConfig.java
  7. 7 2
      coffee-framework/src/main/java/com/coffee/framework/config/mybatisplus/handler/CreateAndUpdateMetaObjectHandler.java
  8. 9 7
      coffee-system/src/main/java/com/coffee/bus/controller/BusDrugController.java
  9. 1 1
      coffee-system/src/main/java/com/coffee/bus/controller/BusFormulaController.java
  10. 10 1
      coffee-system/src/main/java/com/coffee/bus/controller/BusPatientController.java
  11. 7 4
      coffee-system/src/main/java/com/coffee/bus/entity/BusFormulaEntity.java
  12. 26 0
      coffee-system/src/main/java/com/coffee/bus/entity/FormulaDrugDomain.java
  13. 158 0
      coffee-system/src/main/java/com/coffee/bus/entity/PatientMonitorDomain.java
  14. 63 0
      coffee-system/src/main/java/com/coffee/bus/handler/CheckSignHandler.java
  15. 9 0
      coffee-system/src/main/java/com/coffee/bus/mapper/BusPatientMapper.java
  16. 11 0
      coffee-system/src/main/java/com/coffee/bus/service/LocalBusPatientService.java
  17. 43 0
      coffee-system/src/main/java/com/coffee/bus/service/dto/PatientMonitorQuery.java
  18. 2 2
      coffee-system/src/main/java/com/coffee/bus/websocket/listener/DeviceInfoListener.java
  19. 11 0
      coffee-system/src/main/java/com/coffee/system/controller/SysConfigController.java
  20. 144 0
      coffee-system/src/main/resources/mapper/bus/BusPatientMapper.xml

+ 1 - 0
coffee-admin/src/main/java/com/coffee/admin/AdminApplication.java

@@ -21,6 +21,7 @@ import org.tio.websocket.starter.EnableTioWebSocketServer;
 @EnableTioWebSocketServer
 @EnableScheduling
 @EnableAsync
+@ServletComponentScan(basePackages = "com.coffee.common.config")
 @EnableTransactionManagement
 public class AdminApplication {
 

+ 62 - 0
coffee-common/src/main/java/com/coffee/common/config/CacheHttpServletRequestWrapper.java

@@ -0,0 +1,62 @@
+package com.coffee.common.config;
+
+import org.springframework.util.StreamUtils;
+
+import javax.servlet.ReadListener;
+import javax.servlet.ServletInputStream;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletRequestWrapper;
+import java.io.*;
+import java.nio.charset.Charset;
+
+public class CacheHttpServletRequestWrapper extends HttpServletRequestWrapper {
+
+    private static final String CHARSET_UTF8 = "UTF-8";
+
+    private final byte[] body;
+    private String bodyString;
+
+    public CacheHttpServletRequestWrapper(HttpServletRequest request) throws IOException {
+        super(request);
+        this.bodyString = StreamUtils.copyToString(request.getInputStream(), Charset.forName(CHARSET_UTF8));
+        body = bodyString.getBytes(CHARSET_UTF8);
+    }
+
+    public String getBodyString() {
+        return this.bodyString;
+    }
+
+    @Override
+    public BufferedReader getReader() throws IOException {
+        return new BufferedReader(new InputStreamReader(getInputStream()));
+    }
+
+    @Override
+    public ServletInputStream getInputStream() throws IOException {
+
+        final ByteArrayInputStream innerBAIS = new ByteArrayInputStream(body);
+
+        return new ServletInputStream() {
+
+            @Override
+            public boolean isFinished() {
+                return false;
+            }
+
+            @Override
+            public boolean isReady() {
+                return false;
+            }
+
+            @Override
+            public void setReadListener(ReadListener readListener) {
+
+            }
+
+            @Override
+            public int read() throws IOException {
+                return innerBAIS.read();
+            }
+        };
+    }
+}

+ 38 - 0
coffee-common/src/main/java/com/coffee/common/config/CachingContentFilter.java

@@ -0,0 +1,38 @@
+package com.coffee.common.config;
+
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.web.util.ContentCachingRequestWrapper;
+
+import javax.servlet.*;
+import javax.servlet.annotation.WebFilter;
+import javax.servlet.http.HttpServletRequest;
+import java.io.IOException;
+
+/**
+ * @author lifang
+ * @version 1.0.0
+ * @ClassName DefaultFilter.java
+ * @Description TODO
+ * @createTime 2022年04月22日 14:59:00
+ */
+@Slf4j
+@WebFilter(urlPatterns = "/*")
+public class CachingContentFilter implements Filter {
+
+    @Override
+    public void init(FilterConfig filterConfig) {
+    }
+
+    @Override
+    public void doFilter(ServletRequest request, ServletResponse response,
+                         FilterChain chain) throws IOException, ServletException {
+
+        HttpServletRequest requestWrapper = new CacheHttpServletRequestWrapper((HttpServletRequest) request);
+        chain.doFilter(requestWrapper, response);
+
+    }
+
+    @Override
+    public void destroy() {
+    }
+}

+ 1 - 1
coffee-common/src/main/java/com/coffee/common/crud/controller/BaseSaveController.java

@@ -43,6 +43,6 @@ public interface BaseSaveController<E,K extends Serializable> extends
     @ApiOperation(value = "根据ID修改数据")
     default R update(@RequestBody E payload) {
         editAuth();
-        return getService().updateById(payload)?R.success():R.fail("更新失败");
+        return getService().updateById(payload)?R.success(payload):R.fail("更新失败");
     }
 }

+ 7 - 2
coffee-framework/src/main/java/com/coffee/framework/config/WebAppMvcConfig.java

@@ -1,5 +1,6 @@
 package com.coffee.framework.config;
 
+import cn.hutool.core.collection.CollectionUtil;
 import com.coffee.common.config.BooleanToIntegerSerializer;
 import com.fasterxml.jackson.databind.DeserializationFeature;
 import com.fasterxml.jackson.databind.ObjectMapper;
@@ -28,7 +29,7 @@ import java.util.*;
 //@Profile("dev")
 public class WebAppMvcConfig implements WebMvcConfigurer {
     @Autowired
-    private HandlerInterceptor interceptors;
+    private List<HandlerInterceptor> interceptors;
     @Override
     public void extendMessageConverters(List<HttpMessageConverter<?>> converters) {
         MappingJackson2HttpMessageConverter converter = new MappingJackson2HttpMessageConverter();
@@ -73,8 +74,12 @@ public class WebAppMvcConfig implements WebMvcConfigurer {
 
     @Override
     public void addInterceptors(InterceptorRegistry registry) {
-        registry.addInterceptor(interceptors);
+        if(CollectionUtil.isNotEmpty(interceptors)){
+            interceptors.forEach(registry::addInterceptor);
+        }
     }
 
 
+
+
 }

+ 1 - 1
coffee-framework/src/main/java/com/coffee/framework/config/mybatisplus/MybatisPlusConfig.java

@@ -165,7 +165,7 @@ public class MybatisPlusConfig {
 
             @Override
             public boolean ignoreInsert(List<Column> columns, String tenantIdColumn) {
-                return false;
+                return columns.stream().anyMatch(column -> column.getColumnName().equals(tenantIdColumn));
             }
         });
         return tenantInterceptor;

+ 7 - 2
coffee-framework/src/main/java/com/coffee/framework/config/mybatisplus/handler/CreateAndUpdateMetaObjectHandler.java

@@ -6,10 +6,14 @@ import com.coffee.common.exception.CustomException;
 import com.coffee.common.result.ResultCode;
 import com.coffee.common.util.SecurityUtil;
 import org.apache.ibatis.reflection.MetaObject;
+import org.springframework.web.context.request.RequestContextHolder;
+import org.springframework.web.context.request.ServletRequestAttributes;
 
 import java.util.Date;
 import java.util.Objects;
 
+import static org.springframework.web.context.request.RequestAttributes.SCOPE_REQUEST;
+
 /**
  * MP注入处理器
  *
@@ -48,8 +52,9 @@ public class CreateAndUpdateMetaObjectHandler implements MetaObjectHandler {
                 this.strictUpdateFill(metaObject, UPDATE_BY, String.class, Objects.isNull(loginUser) ? null : loginUser.getSysUser().getId().toString());
             }
             if (metaObject.hasGetter(TENANT_ID) && metaObject.getValue(TENANT_ID) == null) {
-                LoginUser loginUser = SecurityUtil.getLoginUser();
-                this.strictUpdateFill(metaObject, TENANT_ID, String.class, Objects.isNull(loginUser) ? null : loginUser.getSysUser().getTenantId());
+                ServletRequestAttributes request = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
+                String tenantId = String.valueOf(request.getAttribute("tenantId", SCOPE_REQUEST));
+                this.strictInsertFill(metaObject, TENANT_ID, String.class, tenantId);
             }
         } catch (Exception e) {
             throw new CustomException(ResultCode.INTERNAL_SERVER_ERROR.getMessage());

+ 9 - 7
coffee-system/src/main/java/com/coffee/bus/controller/BusDrugController.java

@@ -28,18 +28,20 @@ import java.util.List;
 @RequestMapping("/bus/drug")
 @Api(tags = "药品管理",description = "统一权限前缀(bus:drug),例如新增bus:drug:add")
 public class BusDrugController extends BaseCrudController<BusDrugEntity,String> {
-    private final LocalBusDrugService scoreService;
-
-
-    @GetMapping
-    @ApiOperation("改接口无意义,当该模块下存在接口时,将该接口删除")
-    public void show(){
+    private final LocalBusDrugService drugService;
 
+    /**
+     * 权限控制前缀
+     * @return
+     */
+    @Override
+    public String getPermissionPrefix() {
+        return "bus:drug";
     }
 
     @Override
     public BaseService<? extends Mapper<BusDrugEntity>, BusDrugEntity, String> getService() {
-        return scoreService;
+        return drugService;
     }
 
 }

+ 1 - 1
coffee-system/src/main/java/com/coffee/bus/controller/BusFormulaController.java

@@ -22,7 +22,7 @@ import org.springframework.web.bind.annotation.RestController;
 @RestController
 @AllArgsConstructor
 @RequestMapping("/bus/formula")
-@Api(tags = "配方管理",description = "统一权限前缀(bus:formula),bus:formula:add")
+@Api(tags = "药品配方管理",description = "统一权限前缀(bus:formula),bus:formula:add")
 
 public class BusFormulaController  extends BaseCrudController<BusFormulaEntity, String> {
     private final LocalBusFormulaService scoreService;

+ 10 - 1
coffee-system/src/main/java/com/coffee/bus/controller/BusPatientController.java

@@ -7,6 +7,7 @@ import com.baomidou.mybatisplus.core.mapper.Mapper;
 import com.coffee.bus.controller.vo.MonitorFinished;
 import com.coffee.bus.entity.BusDeviceRunningEntity;
 import com.coffee.bus.entity.BusPatientEntity;
+import com.coffee.bus.entity.PatientMonitorDomain;
 import com.coffee.bus.enums.DeviceStatusEnum;
 import com.coffee.bus.service.LocalBusClinicService;
 import com.coffee.bus.service.LocalBusDeviceRunningService;
@@ -14,9 +15,9 @@ import com.coffee.bus.service.LocalBusPatientService;
 import com.coffee.bus.service.dto.ManualUndoConfig;
 import com.coffee.bus.service.dto.PatientDeviceNoneResult;
 import com.coffee.bus.service.dto.PatientDeviceRepeatResult;
+import com.coffee.bus.service.dto.PatientMonitorQuery;
 import com.coffee.common.crud.BaseService;
 import com.coffee.common.crud.controller.BaseCrudController;
-import com.coffee.common.entity.QueryParamEntity;
 import com.coffee.common.exception.CustomException;
 import com.coffee.common.result.R;
 import io.swagger.annotations.*;
@@ -44,6 +45,14 @@ public class BusPatientController extends BaseCrudController<BusPatientEntity, S
     private final LocalBusDeviceRunningService deviceRunningService;
 
     private final LocalBusClinicService clinicService;
+
+    @PostMapping("/no_page")
+    @SaCheckPermission("bus:patient:query")
+    @ApiOperation(value = "病人监控管理列表",notes = "病人监控管理列表,权限【bus:patient:query】")
+    public R<List<PatientMonitorDomain>> selectPage(@RequestBody PatientMonitorQuery query){
+        return R.success(patientService.selectAll(query));
+    }
+
     @GetMapping("/repeat/device")
     @ApiOperation(value = "获取当前医院绑定设备重复的所有病患信息",notes = "当出现病患同一时间绑定了多个泵时,调用该接口查询出所有设备重复报警数据,权限【无】")
     public R<List<PatientDeviceRepeatResult>> repeatDevice(){

+ 7 - 4
coffee-system/src/main/java/com/coffee/bus/entity/BusFormulaEntity.java

@@ -1,6 +1,8 @@
 package com.coffee.bus.entity;
 
+import com.baomidou.mybatisplus.annotation.TableField;
 import com.baomidou.mybatisplus.annotation.TableName;
+import com.baomidou.mybatisplus.extension.handlers.FastjsonTypeHandler;
 import com.coffee.common.entity.TenantGenericEntity;
 import io.swagger.annotations.ApiModel;
 import io.swagger.annotations.ApiModelProperty;
@@ -8,7 +10,7 @@ import lombok.Data;
 import lombok.EqualsAndHashCode;
 import lombok.ToString;
 import org.hibernate.validator.constraints.Length;
-
+import java.util.*;
 /**
  * @author zsl
  * @version 1.0.0
@@ -28,8 +30,9 @@ public class BusFormulaEntity extends TenantGenericEntity<String,String> {
     @Length(max = 255,message = "配方名称长度不得超过255个字节")
     private String name;
 
-    @ApiModelProperty(value = "配方类型")
-    @Length(max = 2048,message = "配方类型不得超过2048个字符")
-    private String content;
+    @ApiModelProperty(value = "配方内容")
+    @Length(max = 2048,message = "配方内容不得超过2048个字符")
+    @TableField(typeHandler = FastjsonTypeHandler.class,javaType = true)
+    private List<FormulaDrugDomain> content;
 
 }

+ 26 - 0
coffee-system/src/main/java/com/coffee/bus/entity/FormulaDrugDomain.java

@@ -0,0 +1,26 @@
+package com.coffee.bus.entity;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import org.hibernate.validator.constraints.Length;
+
+/**
+ * @author lifang
+ * @version 1.0.0
+ * @ClassName DrugDomain.java
+ * @Description TODO
+ * @createTime 2022年04月21日 14:27:00
+ */
+@ApiModel("配方药品详情")
+@Data
+public class FormulaDrugDomain {
+    @ApiModelProperty(value = "药品名称")
+    private String name;
+
+    @ApiModelProperty(value = "药品用量")
+    private String dose;
+
+    @ApiModelProperty(value = "药品单位")
+    private String unit;
+}

+ 158 - 0
coffee-system/src/main/java/com/coffee/bus/entity/PatientMonitorDomain.java

@@ -0,0 +1,158 @@
+package com.coffee.bus.entity;
+
+import com.coffee.bus.enums.DeviceAlarmEnum;
+import com.coffee.bus.enums.DeviceEnum;
+import com.coffee.bus.enums.DeviceStatusEnum;
+import com.coffee.bus.enums.PatientAlarmEnum;
+import com.coffee.common.enums.SexEnum;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import org.hibernate.validator.constraints.Length;
+
+import java.math.BigDecimal;
+import java.util.Date;
+
+/**
+ * @author lifang
+ * @version 1.0.0
+ * @ClassName PatientMonitorDomain.java
+ * @Description TODO
+ * @createTime 2022年04月21日 15:57:00
+ */
+@ApiModel("病人监控实体")
+@Data
+public class PatientMonitorDomain {
+    @ApiModelProperty(value = "病号")
+    private String patientCode;
+
+    @ApiModelProperty(value = "病人名称")
+    private String patientName;
+
+    @ApiModelProperty(value = "性别")
+    private SexEnum gender;
+
+    @ApiModelProperty(value = "病人报警信息",example = "泵重复,无泵")
+    private PatientAlarmEnum patientAlarm;
+
+    @ApiModelProperty(value = "设备id")
+    private String deviceId;
+
+
+    @ApiModelProperty(value = "临床号")
+    private String clinicId;
+
+    @ApiModelProperty(value = "病区")
+    private String ward;
+
+    @ApiModelProperty(value = "床号")
+    private String bedNo;
+
+
+    @ApiModelProperty(value = "总量")
+    private Integer totalDose;
+
+    @ApiModelProperty(value = "公共参数-首次量")
+    private Integer firstDose;
+
+
+    @ApiModelProperty(value = "公共参数-剩余量")
+    private BigDecimal remainDose;
+
+    @ApiModelProperty(value = "公共参数-已输入量")
+    private BigDecimal inputDose;
+
+    @ApiModelProperty(value = "公共参数-追加量")
+    private BigDecimal appendDose;
+
+    @ApiModelProperty(value = "公共参数-追加锁时")
+    private BigDecimal appendLockTime;
+
+    @ApiModelProperty(value = "公共参数-极限量")
+    private BigDecimal maxDose;
+
+    @ApiModelProperty(value = "公共参数-自控锁时")
+    private BigDecimal selfControlLockTime;
+
+    @ApiModelProperty(value = "公共参数-自控次数")
+    private BigDecimal selfControlCount;
+
+    @ApiModelProperty(value = "公共参数-pca有效次数")
+    private Integer pcaValidCount;
+
+    @ApiModelProperty(value = "公共参数-pca无效次数")
+    private Integer pcaInvalidCount;
+
+    @ApiModelProperty(value = "公共参数-pca总按次数")
+    private Integer pcaTotalCount;
+
+    @ApiModelProperty(value = "持续泵参数-持续量")
+    private BigDecimal continueDose;
+
+    @ApiModelProperty(value = "脉冲泵参数-脉冲量")
+    private Integer pulseDose;
+
+    @ApiModelProperty(value = "脉冲泵参数-脉冲锁时")
+    private Integer pulseLockTime;
+
+    @ApiModelProperty(value = "脉冲泵参数-脉冲首次锁时")
+    private Integer pulseFirstLockTime;
+
+    @ApiModelProperty(value = "智能泵参数-加档周期")
+    private BigDecimal flowUpCycle;
+
+    @ApiModelProperty(value = "智能泵参数-减档周期")
+    private BigDecimal flowDownCycle;
+
+    @ApiModelProperty(value = "智能泵参数-计次")
+    private BigDecimal flowCount;
+
+    @ApiModelProperty(value = "智能泵参数-上限")
+    private BigDecimal flowUpLimit;
+
+    @ApiModelProperty(value = "智能泵参数-下限")
+    private BigDecimal flowDownLimit;
+
+    @ApiModelProperty(value = "智能泵参数-自调比例")
+    private BigDecimal flowAdjustRate;
+
+
+    @ApiModelProperty(value = "泵运行状态")
+    private DeviceStatusEnum deviceRunState;
+
+    @ApiModelProperty(value = "报警信息")
+    private DeviceAlarmEnum deviceAlarm;
+
+    @ApiModelProperty(value = "输注即将结束提醒")
+    private Boolean warnWillFinished;
+
+    @ApiModelProperty(value = "镇痛不足提醒")
+    private Boolean warnAnalgesicPoor;
+
+    @ApiModelProperty(value = "电量偏低提醒")
+    private Boolean warnLowBattery;
+
+    @ApiModelProperty(value = "输注开始时间,即本次运行开机时间")
+    private Date infusionStartTime;
+
+    @ApiModelProperty(value = "备注")
+    private String remark;
+
+    @ApiModelProperty(value = "泵类型")
+    private DeviceEnum deviceType;
+
+    @ApiModelProperty(value = "麻醉医生")
+    private String anaDoctor;
+
+    @ApiModelProperty(value = "麻醉方式")
+    private String anaType;
+
+    @ApiModelProperty(value = "镇痛方式")
+    private String analType;
+
+    @ApiModelProperty(value = "手术医生")
+    private String surgeryDoctor;
+
+    @ApiModelProperty(value = "手术名称")
+    private String surgeryName;
+}

+ 63 - 0
coffee-system/src/main/java/com/coffee/bus/handler/CheckSignHandler.java

@@ -0,0 +1,63 @@
+package com.coffee.bus.handler;
+
+import cn.hutool.core.io.FastByteArrayOutputStream;
+import cn.hutool.core.io.IoUtil;
+import cn.hutool.core.util.StrUtil;
+import cn.hutool.crypto.SignUtil;
+import cn.hutool.crypto.asymmetric.SignAlgorithm;
+import cn.hutool.crypto.digest.DigestUtil;
+import cn.hutool.json.JSONObject;
+import cn.hutool.json.JSONUtil;
+import com.coffee.common.result.R;
+import com.coffee.common.result.ResultCode;
+import jodd.net.HttpMethod;
+import org.apache.commons.codec.digest.DigestUtils;
+import org.apache.commons.codec.digest.Md5Crypt;
+import org.bouncycastle.crypto.digests.MD5Digest;
+import org.springframework.stereotype.Component;
+import org.springframework.web.servlet.HandlerInterceptor;
+import sun.security.provider.MD5;
+
+import javax.servlet.ServletInputStream;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+import java.nio.charset.Charset;
+import java.util.TreeMap;
+
+/**
+ * @author lifang
+ * @version 1.0.0
+ * @ClassName CheckSignHandler.java
+ * @Description TODO
+ * @createTime 2022年04月22日 10:47:00
+ */
+@Component
+public class CheckSignHandler implements HandlerInterceptor {
+    @Override
+    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws IOException {
+        String method = request.getMethod();
+        if (method.equals("POST")) {
+            //post 请求验证参数
+            String sign = request.getHeader("Sign");
+            String timestamp = request.getHeader("Timestamp");
+            String authorization = request.getHeader("Authorization");
+            String body = IoUtil.read(request.getInputStream(), Charset.defaultCharset());
+            if(StrUtil.isEmpty(sign)||StrUtil.isEmpty(timestamp)||StrUtil.isEmpty(authorization)){
+                response.getOutputStream().write(JSONUtil.parse(R.result(ResultCode.PARAM_MISS,"请检查是否携带Timestamp、Sign、Authorization")).toString().getBytes());
+                return false;
+            }
+            JSONObject jsonObject = new JSONObject(true);
+            jsonObject.putOpt("body",String.valueOf(body));
+            jsonObject.putOpt("timestamp",timestamp);
+            jsonObject.putOpt("token",authorization);
+            String encodeSign = DigestUtil.md5Hex(jsonObject.toString());
+            if (!encodeSign.equals(sign)) {
+                response.getOutputStream().write(JSONUtil.parse(R.result(ResultCode.REQ_REJECT,"签名错误")).toString().getBytes());
+                return false;
+            }
+        }
+        //get请求
+        return true;
+    }
+}

+ 9 - 0
coffee-system/src/main/java/com/coffee/bus/mapper/BusPatientMapper.java

@@ -1,9 +1,12 @@
 package com.coffee.bus.mapper;
 
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.coffee.bus.entity.BusPatientEntity;
 import com.coffee.bus.entity.PatientDeviceRepeatDomain;
+import com.coffee.bus.entity.PatientMonitorDomain;
 import com.coffee.bus.service.dto.PatientDeviceNoneResult;
+import com.coffee.bus.service.dto.PatientMonitorQuery;
 import org.apache.ibatis.annotations.Mapper;
 import org.apache.ibatis.annotations.Param;
 
@@ -31,4 +34,10 @@ public interface BusPatientMapper extends BaseMapper<BusPatientEntity> {
      */
     List<PatientDeviceNoneResult> selectNoneDevice();
 
+    /**
+     * 查询监控病患列表, 不分页
+     * @param query
+     * @return
+     */
+    IPage<PatientMonitorDomain> selectMonitor(IPage<PatientMonitorDomain> page,@Param("query") PatientMonitorQuery query);
 }

+ 11 - 0
coffee-system/src/main/java/com/coffee/bus/service/LocalBusPatientService.java

@@ -1,13 +1,18 @@
 package com.coffee.bus.service;
 
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.coffee.bus.entity.BusPatientEntity;
 import com.coffee.bus.entity.PatientDeviceRepeatDomain;
+import com.coffee.bus.entity.PatientMonitorDomain;
 import com.coffee.bus.mapper.BusPatientMapper;
 import com.coffee.bus.service.dto.PatientDeviceNoneResult;
 import com.coffee.bus.service.dto.PatientDeviceRepeatResult;
+import com.coffee.bus.service.dto.PatientMonitorQuery;
 import com.coffee.common.crud.BaseService;
 import lombok.AllArgsConstructor;
 import lombok.extern.slf4j.Slf4j;
+import org.springframework.data.domain.PageRequest;
 import org.springframework.scheduling.annotation.Async;
 import org.springframework.stereotype.Service;
 
@@ -92,4 +97,10 @@ public class LocalBusPatientService extends BaseService<BusPatientMapper, BusPat
     public List<PatientDeviceNoneResult> noneDevice() {
         return this.baseMapper.selectNoneDevice();
     }
+
+    public List<PatientMonitorDomain> selectAll(PatientMonitorQuery query) {
+        Page<PatientMonitorDomain> page = new Page<>(0, 500, false);
+        IPage<PatientMonitorDomain> result = this.baseMapper.selectMonitor(page,query);
+        return result.getRecords();
+    }
 }

+ 43 - 0
coffee-system/src/main/java/com/coffee/bus/service/dto/PatientMonitorQuery.java

@@ -0,0 +1,43 @@
+package com.coffee.bus.service.dto;
+
+import com.coffee.bus.enums.DeviceAlarmEnum;
+import com.coffee.bus.enums.DeviceEnum;
+import com.coffee.bus.enums.DeviceStatusEnum;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import java.util.*;
+/**
+ * @author lifang
+ * @version 1.0.0
+ * @ClassName PatientMonitorQuery.java
+ * @Description TODO
+ * @createTime 2022年04月22日 08:50:00
+ */
+@Data
+@ApiModel("病人监控查询参数")
+public class PatientMonitorQuery {
+    @ApiModelProperty("模糊查询,病区、床号、姓名、住院号")
+    private String blurry;
+
+    @ApiModelProperty("病区查询集合")
+    private List<String> wards;
+
+    @ApiModelProperty("设备类型查询,网络泵、脉冲泵、智能泵")
+    private List<DeviceEnum> types;
+
+    @ApiModelProperty("设备输注最后运行状态查询")
+    private List<DeviceStatusEnum> deviceStatus;
+
+    @ApiModelProperty("设备输注最后报警状态")
+    private List<DeviceAlarmEnum> deviceAlarms;
+
+    @ApiModelProperty("设备输注最后即将结束警告")
+    private boolean warnWillFinished;
+
+    @ApiModelProperty("设备输注最后镇痛不足警告")
+    private boolean warnAnalgesicPoor;
+
+    @ApiModelProperty("设备输注最后低电量警告")
+    private boolean warnLowBattery;
+}

+ 2 - 2
coffee-system/src/main/java/com/coffee/bus/websocket/listener/DeviceInfoListener.java

@@ -515,7 +515,7 @@ public class DeviceInfoListener {
         SpringUtil.publishEvent(new DeviceInfoEvent(this,pump3,pump3.getDeviceId()));
 //        });
         Thread.sleep(5000);
-        String now = DateUtil.now();
+        String now = DateUtil.yesterday().toString();
         BusClinicEntity clinic = new BusClinicEntity();
         clinic.setPatientCode("456");
         clinic.setName("临床:"+ now);
@@ -525,7 +525,7 @@ public class DeviceInfoListener {
         clinic.setWard("病区:"+now);
         clinic.setBedNo("床号:"+now);
         clinic.setTenantId("1505808170691784706");
-        clinic.setStartTime(new Date());
+        clinic.setStartTime(DateUtil.yesterday());
         SpringUtil.publishEvent(new HisEvent(this,Arrays.asList(clinic),clinic.getTenantId()));
 
     }

+ 11 - 0
coffee-system/src/main/java/com/coffee/system/controller/SysConfigController.java

@@ -10,6 +10,7 @@ import com.coffee.system.common.dto.SysConfigEditDTO;
 import com.coffee.system.common.dto.SysConfigQueryDTO;
 import com.coffee.system.entity.SysConfig;
 import com.coffee.system.service.ISysConfigService;
+import io.swagger.annotations.ApiOperation;
 import org.springframework.validation.annotation.Validated;
 import org.springframework.web.bind.annotation.*;
 
@@ -113,5 +114,15 @@ public class SysConfigController {
         return R.success();
     }
 
+
+    /**
+     *
+     * 根据键值,获取value
+     */
+    @ApiOperation("获取系统时间(毫秒级)")
+    @GetMapping("/getTime")
+    public R getTime() {
+        return R.success(System.currentTimeMillis());
+    }
 }
 

+ 144 - 0
coffee-system/src/main/resources/mapper/bus/BusPatientMapper.xml

@@ -19,6 +19,52 @@
         <result column="master" property="master"/>
     </resultMap>
 
+    <resultMap id="monitorResult" type="com.coffee.bus.entity.PatientMonitorDomain">
+        <result column="patient_name" property="patientName"/>
+        <result column="patient_code" property="patientCode"/>
+        <result column="gender" property="gender"/>
+        <result column="patient_alarm" property="patientAlarm"/>
+        <result column="device_id" property="deviceId"/>
+        <result column="clinic_id" property="clinicId"/>
+        <result column="ward" property="ward"/>
+        <result column="bed_no" property="bedNo"/>
+        <result column="total_dose" property="totalDose"/>
+        <result column="first_dose" property="firstDose"/>
+        <result column="remain_dose" property="remainDose"/>
+        <result column="input_dose" property="inputDose"/>
+        <result column="append_dose" property="appendDose"/>
+        <result column="append_lock_time" property="appendLockTime"/>
+        <result column="max_dose" property="maxDose"/>
+        <result column="self_control_count" property="selfControlCount"/>
+        <result column="self_control_lock_time" property="selfControlLockTime"/>
+        <result column="pca_valid_count" property="pcaValidCount"/>
+        <result column="pca_invalid_count" property="pcaInvalidCount"/>
+        <result column="pca_total_count" property="pcaTotalCount"/>
+        <result column="continue_dose" property="continueDose"/>
+        <result column="pulse_dose" property="pulseDose"/>
+        <result column="pulse_first_lock_time" property="pulseFirstLockTime"/>
+        <result column="pulse_lock_time" property="pulseLockTime"/>
+        <result column="flow_up_cycle" property="flowUpCycle"/>
+        <result column="flow_down_cycle" property="flowDownCycle"/>
+        <result column="flow_count" property="flowCount"/>
+        <result column="flow_up_limit" property="flowUpLimit"/>
+        <result column="flow_down_limit" property="flowDownLimit"/>
+        <result column="flow_adjust_rate" property="flowAdjustRate"/>
+        <result column="run_state" property="deviceRunState"/>
+        <result column="warn_analgesic_poor" property="warnAnalgesicPoor"/>
+        <result column="warn_low_battery" property="warnLowBattery"/>
+        <result column="warn_will_finished" property="warnWillFinished"/>
+        <result column="device_alarm" property="deviceAlarm"/>
+        <result column="infusion_start_time" property="infusionStartTime"/>
+        <result column="remark" property="remark"/>
+        <result column="device_type" property="deviceType"/>
+        <result column="anal_type" property="analType"/>
+        <result column="ana_doctor" property="anaDoctor"/>
+        <result column="ana_type" property="anaType"/>
+        <result column="surgery_doctor" property="surgeryDoctor"/>
+        <result column="surgery_name" property="surgeryName"/>
+    </resultMap>
+
     <select id="selectRepeatDevice" resultMap="repeatDeviceResult">
          SELECT
  p.name,
@@ -51,4 +97,102 @@ SELECT
 FROM (SELECT `name`,gender,CODE,tenant_id FROM bus_patient WHERE bus_patient.`alarm`=2 ) AS p
 left join  (SELECT * FROM bus_clinic WHERE finished=0 ) AS c ON  c.`patient_code`=p.code;
     </select>
+
+    <select id="selectMonitor" resultMap="monitorResult" parameterType="com.coffee.bus.service.dto.PatientMonitorQuery">
+        select
+        p.`name` as patient_name,
+        p.`code` as patient_code,
+        p.gender as gender,
+        p.alarm as patient_alarm,
+        i.device_id as device_id,
+        i.clinic_id as clinic_id,
+        i.ward as ward,
+        i.bed_no as bed_no,
+        i.total_dose as total_dose,
+        i.first_dose as first_dose,
+        i.remain_dose as remain_dose,
+        i.input_dose as input_dose,
+        i.append_dose as append_dose,
+        i.append_lock_time as append_lock_time,
+        i.max_dose as max_dose,
+        i.self_control_count as self_control_count,
+        i.self_control_lock_time as self_control_lock_time,
+        i.pca_valid_count as pca_valid_count,
+        i.pca_invalid_count as pca_invalid_count,
+        i.pca_total_count as pca_total_count,
+        i.continue_dose as continue_dose,
+        i.pulse_dose as pulse_dose,
+        i.pulse_lock_time as pulse_lock_time,
+        i.pulse_first_lock_time as pulse_first_lock_time,
+        i.flow_up_cycle as flow_up_cycle,
+        i.flow_down_cycle as flow_down_cycle,
+        i.flow_count as flow_count,
+        i.flow_up_limit as flow_up_limit,
+        i.flow_down_limit as flow_down_limit,
+        i.flow_adjust_rate as flow_adjust_rate,
+        i.run_state as run_state,
+        i.warn_will_finished as warn_will_finished,
+        i.warn_analgesic_poor as warn_analgesic_poor,
+        i.warn_low_battery as warn_low_battery,
+        i.alarm as device_alarm,
+        i.start_time as infusion_start_time,
+        i.remark as remark,
+        i.type as device_type,
+        c.ana_doctor as ana_doctor,
+        c.ana_type as ana_type,
+        c.anal_type as anal_type,
+        c.surgery_doctor as surgery_doctor,
+        c.surgery_name as surgery_name
+        from
+        (select * from bus_patient)
+        as p
+        join
+        (select * from bus_infusion_history
+        <where>
+            <if test="query.wards != null and query.wards.size > 0">
+                and ward in
+                <foreach item="ward" index="index" collection="query.wards" open="(" separator="," close=")">
+                    #{ward, jdbcType=VARCHAR}
+                </foreach>
+            </if>
+            <if test="query.types != null and query.types.size > 0">
+                and type in
+                <foreach item="type" index="index" collection="query.types" open="(" separator="," close=")">
+                    #{type, jdbcType=VARCHAR}
+                </foreach>
+            </if>
+            <if test="query.deviceStatus != null and query.deviceStatus.size > 0">
+                and run_state in
+                <foreach item="status" index="index" collection="query.deviceStatus" open="(" separator="," close=")">
+                    #{status, jdbcType=VARCHAR}
+                </foreach>
+            </if>
+            <if test="query.deviceAlarms != null and query.deviceAlarms.size > 0">
+                or alarm in
+                <foreach item="alarm" index="index" collection="query.deviceAlarms" open="(" separator="," close=")">
+                    #{alarm, jdbcType=VARCHAR}
+                </foreach>
+            </if>
+            <if test="query.warnWillFinished != false or query.warnAnalgesicPoor != false or  query.warnLowBattery != false">
+                and (
+                <choose>
+                    <when test="query.warnWillFinished != false">warn_will_finished=1</when>
+                    <otherwise>warn_will_finished!=1</otherwise>
+                </choose>
+                <if test="query.warnAnalgesicPoor != false">or warn_analgesic_poor=1 </if>
+                <if test="query.warnLowBattery != false"> or warn_low_battery=1 </if>
+
+              )
+            </if>
+
+        </where>
+        ) as i on p.infusion_id=i.id
+        left join bus_clinic c on i.clinic_id=c.id
+        <where>
+            <if test="query.blurry != null">
+                p.`name` like concat('%', #{query.blurry}, '%') or p.`code` like concat('%', #{query.blurry}, '%') or i.ward LIKE concat('%', #{query.blurry}, '%') OR i.bed_no LIKE concat('%', #{query.blurry}, '%')
+              </if>
+        </where>
+
+    </select>
 </mapper>