18339543638 пре 3 година
родитељ
комит
7278394c6d

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

@@ -32,7 +32,6 @@ public interface BaseQueryController<E, K extends Serializable> extends
     default R<IPage<E>> queryPager(@RequestBody QueryParamEntity<E> query) {
         queryAuth();
         return R.success(this.getService().list(query));
-
     }
 
     @PostMapping("/_count")

+ 68 - 11
coffee-system/src/main/java/com/coffee/bus/controller/BusConstantController.java

@@ -1,11 +1,18 @@
 package com.coffee.bus.controller;
 
-import io.swagger.annotations.Api;
-import io.swagger.annotations.ApiOperation;
-import lombok.AllArgsConstructor;
-import org.springframework.web.bind.annotation.GetMapping;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RestController;
+import cn.hutool.core.util.StrUtil;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.coffee.bus.enums.ConstantEnum;
+import com.coffee.bus.service.constant.AbstractConstantService;
+import com.coffee.common.entity.QueryParamEntity;
+import com.coffee.common.result.R;
+import io.swagger.annotations.*;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
+
+import java.io.Serializable;
+import java.util.*;
+import java.util.stream.Collectors;
 
 /**
  * @author lifang
@@ -15,13 +22,63 @@ import org.springframework.web.bind.annotation.RestController;
  * @createTime 2022年04月08日 10:19:00
  */
 @RestController
-@AllArgsConstructor
 @RequestMapping("/bus/constant")
-@Api(tags = "常量管理",description = "统一权限前缀(bus:constant),例如新增bus:constant:add")
+@Api(tags = "常量管理",value = "统一权限前缀(bus:constant),例如新增bus:constant:add")
 public class BusConstantController {
-    @GetMapping
-    @ApiOperation("改接口无意义,当该模块下存在接口时,将该接口删除")
-    public void show(){
 
+    private HashMap<ConstantEnum, AbstractConstantService> constantHashMap=new HashMap<>();
+
+
+    @Autowired
+    public BusConstantController(List<AbstractConstantService> constantList) {
+        constantList.stream().collect(Collectors.groupingBy(AbstractConstantService::getName)).forEach((k, vs)->{
+            constantHashMap.merge(k,vs.get(0),(o1,o2)->{
+                throw new RuntimeException("常量服务类名称不可重复[{"+o1.getName()+"}]");
+            });
+        });
+    }
+
+    @PostMapping("/{type}/page")
+    @ApiImplicitParams({
+            @ApiImplicitParam(name = "type",value = "常量类型",required = true,allowableValues = "ward,doctor,surgery,asa,anaesthesia,anal,alarmCause,drugCate,entrust",allowMultiple = true,dataTypeClass = ConstantEnum.class),
+            @ApiImplicitParam(name = "query",value = "查询参数",required = true)
+    })
+    @ApiOperation(value = "使用POST方式分页动态查询")
+    public R<IPage<?>> queryPager(@PathVariable("type") ConstantEnum type,@RequestBody QueryParamEntity<?> query) {
+        AbstractConstantService constantService = constantHashMap.get(type);
+        if(constantService==null){
+            return R.fail("常量类型{"+type+"}不存在");
+        }
+        return R.success(constantService.list(query));
+    }
+
+    @PostMapping("/{type}/remove")
+    @ApiImplicitParams({
+            @ApiImplicitParam(name = "id",value = "主键id",required = true),
+            @ApiImplicitParam(name = "type",value = "常量类型",required = true,example ="****type请从一下的key值中选取,否则即查询失败****\n" +
+                    "{\n" +
+                    "    \"ward\":\"病区\",\n" +
+                    "    \"doctor\":\"人员\",\n" +
+                    "    \"surgery\":\"手术名称\",\n" +
+                    "    \"asa\":\"asa\",\n" +
+                    "    \"anaesthesia\":\"麻醉方式\",\n" +
+                    "    \"anal\":\"镇痛方式\",\n" +
+                    "    \"alarmCause\":\"报警原因\",\n" +
+                    "    \"drugCate\":\"药品分类\",\n" +
+                    "    \"entrust\":\"医嘱\"\n" +
+                    "}")
+    })
+    @ApiOperation(value = "根据ID删除")
+    public R delete(@PathVariable("type") ConstantEnum type,@RequestParam("id") Serializable id) {
+        if(StrUtil.isNullOrUndefined(String.valueOf(id))){
+            return R.success();
+        }
+        AbstractConstantService constantService = constantHashMap.get(type);
+        if(constantService==null){
+            return R.success("常量类型{"+type+"}不存在");
+        }
+        String key=String.valueOf(id);
+        return constantService
+                .removeById(key)? R.success():R.fail("删除失败");
     }
 }

+ 37 - 0
coffee-system/src/main/java/com/coffee/bus/enums/ConstantEnum.java

@@ -0,0 +1,37 @@
+package com.coffee.bus.enums;
+
+import com.fasterxml.jackson.annotation.JsonFormat;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.AllArgsConstructor;
+
+/**
+ * @author lifang
+ * @version 1.0.0
+ * @ClassName ConstantEnum.java
+ * @Description TODO
+ * @createTime 2022年04月09日 10:42:00
+ */
+@JsonFormat(shape = JsonFormat.Shape.OBJECT)
+@ApiModel("常量类型")
+@AllArgsConstructor
+public enum  ConstantEnum {
+    @ApiModelProperty("病区")
+    ward,
+    @ApiModelProperty("医护人员")
+    doctor,
+    @ApiModelProperty("手术名称")
+    surgery,
+    @ApiModelProperty("asa")
+    asa,
+    @ApiModelProperty("麻醉手术")
+    anaesthesia,
+    @ApiModelProperty("镇痛手术")
+    anal,
+    @ApiModelProperty("报警原因")
+    alarmCause,
+    @ApiModelProperty("药品分类")
+    drugCate,
+    @ApiModelProperty("医嘱")
+    entrust;
+}

+ 8 - 3
coffee-system/src/main/java/com/coffee/bus/listener/event/bean/DeviceAlarmEvent.java

@@ -2,6 +2,7 @@ package com.coffee.bus.listener.event.bean;
 
 import com.coffee.bus.entity.BusDeviceUsingEntity;
 import lombok.Data;
+import lombok.Getter;
 import org.springframework.context.ApplicationEvent;
 
 import java.time.Clock;
@@ -13,17 +14,21 @@ import java.time.Clock;
  * @Description TODO
  * @createTime 2022年03月21日 16:44:00
  */
-@Data
+
+@Getter
 public class DeviceAlarmEvent extends ApplicationEvent {
 
     private final BusDeviceUsingEntity content;
-    public DeviceAlarmEvent(Object source, BusDeviceUsingEntity content) {
+    private final String historyId;
+    public DeviceAlarmEvent(Object source, BusDeviceUsingEntity content,String historyId) {
         super(source);
         this.content=content;
+        this.historyId=historyId;
     }
 
-    public DeviceAlarmEvent(Object source, BusDeviceUsingEntity content, Clock clock) {
+    public DeviceAlarmEvent(Object source, BusDeviceUsingEntity content ,String historyId,Clock clock) {
         super(source, clock);
         this.content=content;
+        this.historyId=historyId;
     }
 }

+ 22 - 0
coffee-system/src/main/java/com/coffee/bus/service/constant/AbstractConstantService.java

@@ -0,0 +1,22 @@
+package com.coffee.bus.service.constant;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.coffee.bus.enums.ConstantEnum;
+import com.coffee.common.crud.BaseService;
+
+import java.io.Serializable;
+
+/**
+ * @author lifang
+ * @version 1.0.0
+ * @ClassName IConstant.java
+ * @Description 常量继承类
+ * @createTime 2022年04月09日 10:19:00
+ */
+public abstract class AbstractConstantService<M extends BaseMapper<E>, E,PK extends Serializable>  extends BaseService {
+    /**
+     * 获取常量名称
+     * @return
+     */
+    public abstract ConstantEnum getName();
+}