Explorar o código

处理下发上位机问题处理

wangzl hai 5 meses
pai
achega
14aac5843b

+ 56 - 0
pump-admin/src/main/test/com/tuoren/web/Test1.java

@@ -1,6 +1,11 @@
 package com.tuoren.web;
 
 import com.tuoren.TuorenApplication;
+import com.tuoren.web.layer.controller.BusPatientController;
+import com.tuoren.web.layer.d0.PumpRemoveRequestDTO;
+import com.tuoren.web.layer.entity.BusPatientEntity;
+import com.tuoren.web.layer.service.IBusPatientService;
+import com.tuoren.web.layer.service.impl.BusPumpServiceImpl;
 import lombok.extern.slf4j.Slf4j;
 import org.junit.Test;
 import org.junit.runner.RunWith;
@@ -8,7 +13,9 @@ import org.springframework.amqp.rabbit.core.RabbitTemplate;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.boot.test.context.SpringBootTest;
 import org.springframework.test.context.junit4.SpringRunner;
+import org.springframework.web.bind.annotation.RequestBody;
 
+import javax.annotation.Resource;
 import java.util.Arrays;
 
 /**
@@ -24,8 +31,57 @@ public class Test1 {
 
     @Autowired
     private RabbitTemplate rabbitTemplate;
+    @Resource
+    private BusPumpServiceImpl busPumpService;
+
+    @Resource
+    private BusPatientController busPatientController;
+    @Resource
+    private IBusPatientService iBusPatientEntityService;
     @Test
     public void test() throws Exception {
         rabbitTemplate.convertAndSend("removePump","123412412", Arrays.asList("12","23","3455"));
     }
+    @Test
+    public void test2() throws Exception {
+        PumpRemoveRequestDTO pumpRemoveRequestDTO = new PumpRemoveRequestDTO();
+        pumpRemoveRequestDTO.setIds(Arrays.asList("382"));
+        pumpRemoveRequestDTO.setRemoveUser("admin");
+        busPumpService.removePumpNew(pumpRemoveRequestDTO);
+    }
+
+    @Test
+    public void test3() throws Exception {
+        BusPatientEntity busPatientEntity = new BusPatientEntity();
+        busPatientEntity.setPatientId("007a44e8-8c33-449f-bb96-78144352cfbc");
+        /**
+         * @return void
+         * @author wangzl
+         * @date 2025/6/18
+         * @description
+         *
+         * "anesthesiaMode":"这是我的麻醉方式",
+         * "bedCode":"这是我的床号",
+         * "patientId":"ad649e03-7b5c-4f94-9a37-b994012b0120",
+         * "sex":"男","name":"这是我的姓名",
+         * "operationName":"这是我的手术名称",
+         * "wardCode":"这是我的病区",
+         * "operationDoctor":"这是我的手术医生",
+         * "easyMode":"这是我的镇痛方式",
+         * "patientCode":"5210800000000"
+         */
+        busPatientEntity.setAnesthesiaMode("这是我的麻醉方式");
+        busPatientEntity.setBedCode("这是我的床号");
+        busPatientEntity.setName("这是我的姓名");
+        busPatientEntity.setOperationName("这是我的手术名称");
+        busPatientEntity.setWardCode("这是我的病区");
+        busPatientEntity.setOperationDoctor("这是我的手术医生");
+        busPatientEntity.setEasyMode("这是我的镇痛方式");
+        busPatientEntity.setPatientCode("5210800000000");
+        boolean flag = this.iBusPatientEntityService.updateById(busPatientEntity);
+        System.out.println(flag);
+        if(flag){
+            iBusPatientEntityService.sendPatientInfoToPump(busPatientEntity.getPatientId());
+        }
+    }
 }

+ 6 - 0
pump-web/pom.xml

@@ -21,6 +21,12 @@
             <version>0.0.1-SNAPSHOT</version>
         </dependency>
 
+        <dependency>
+            <groupId>com.google.code.gson</groupId>
+            <artifactId>gson</artifactId>
+            <version>2.8.5</version>
+        </dependency>
+
     </dependencies>
 
 </project>

+ 30 - 30
pump-web/src/main/java/com/tuoren/web/layer/d0/PatientDTO.java

@@ -15,64 +15,64 @@ import lombok.Data;
 public class PatientDTO {
 
     @ApiModelProperty("医院编号")
-    private String SysHospital_ID;
+    private String SysHospital_ID ="";
     @ApiModelProperty("产品编号")
-    private String SysProduct_ID;
+    private String SysProduct_ID ="";
     @ApiModelProperty("住院号")
-    private String PatientCode;
+    private String PatientCode ="";
     @ApiModelProperty("泵号")
-    private String PumpCode;
+    private String PumpCode ="";
     @ApiModelProperty("姓名")
-    private String Name;
+    private String Name ="";
     @ApiModelProperty("性别")
-    private String Sex;
+    private String Sex ="";
     @ApiModelProperty("身高")
-    private String Height;
+    private String Height ="";
     @ApiModelProperty("体重")
-    private String Weight;
+    private String Weight ="";
     @ApiModelProperty("年龄")
-    private Integer Age;
+    private Integer Age =0;
     @ApiModelProperty("病区")
-    private String Ward;
+    private String Ward ="";
     @ApiModelProperty("床号")
-    private String BedNo;
+    private String BedNo ="";
     @ApiModelProperty("手术名称")
-    private String Operation;
+    private String Operation ="";
     @ApiModelProperty("手术医生")
-    private String Surgeon;
+    private String Surgeon = "";
     @ApiModelProperty("ASA")
-    private String ASA;
+    private String ASA = "";
     @ApiModelProperty("镇痛方式")
-    private String EaseMode;
+    private String EaseMode = "";
     @ApiModelProperty("麻醉医生")
-    private String Doctor;
+    private String Doctor = "";
     @ApiModelProperty("麻醉医生2")
-    private String DoctorTwo;
+    private String DoctorTwo = "";
     @ApiModelProperty("麻醉方式")
-    private String AnesthesiaMode;
+    private String AnesthesiaMode = "";
     @ApiModelProperty("配置人员")
-    private String ConfigPerson;
+    private String ConfigPerson = "";
     @ApiModelProperty("配方")
-    private String Formula;
+    private String Formula = "";
     @ApiModelProperty("撤泵人")
-    private String UndoPerson;
+    private String UndoPerson = "";
     @ApiModelProperty("销毁人")
-    private String DestroyPerson;
+    private String DestroyPerson = "";
     @ApiModelProperty("见证人")
-    private String WitnessPerson;
+    private String WitnessPerson = "";
     @ApiModelProperty("撤泵时间")
-    private String UndoTime;
+    private String UndoTime = "";
     @ApiModelProperty("盐值")
-    private String Salt;
+    private String Salt = "";
     @ApiModelProperty("剩余量处置")
-    private String Balance;
+    private String Balance = "";
     @ApiModelProperty("备注")
-    private String Remark;
+    private String Remark = "";
     @ApiModelProperty("是否删除")
-    private Boolean IsDelete;
+    private Boolean IsDelete = false;
     @ApiModelProperty("创建时间")
-    private String CreateTime;
+    private String CreateTime ="";
     @ApiModelProperty("身高体重BMI")
-    private String BMI;
+    private String BMI = "";
 
 }

+ 1 - 1
pump-web/src/main/java/com/tuoren/web/layer/d0/PumpRemovePushRabbitDTO.java

@@ -40,7 +40,7 @@ public class PumpRemovePushRabbitDTO implements Serializable {
 
     public static PumpRemovePushRabbitDTO parse(BusPumpEntity source){
         return PumpRemovePushRabbitDTO.builder()
-                .operation(1)
+                .operation(0)
                 .tableName("Pump")
                 .data(Data.of(source.getHospitalCode(),source.getPumpCode(),Boolean.FALSE,new Date()))
                 .build();

+ 1 - 1
pump-web/src/main/java/com/tuoren/web/layer/d0/PumpRemoveUserPushRabbitDTO.java

@@ -36,7 +36,7 @@ public class PumpRemoveUserPushRabbitDTO {
 
     public static PumpRemoveUserPushRabbitDTO parse(BusPumpEntity source) {
         return PumpRemoveUserPushRabbitDTO.builder()
-                .operation(1)
+                .operation(0)
                 .tableName("PatientInfo")
                 .data(Data.of(source.getHospitalCode(), source.getPatientCode(), source.getRemoveUser(), source.getPumpCode()))
                 .build();

+ 3 - 0
pump-web/src/main/java/com/tuoren/web/layer/entity/BusPumpEntity.java

@@ -234,4 +234,7 @@ public class BusPumpEntity implements Serializable {
     @ApiModelProperty("撤泵人")
     private String removeUser;
 
+    @ApiModelProperty("配方")
+    private String formula;
+
 }

+ 6 - 5
pump-web/src/main/java/com/tuoren/web/layer/service/impl/BusPatientServiceImpl.java

@@ -5,6 +5,7 @@ import cn.hutool.json.JSONUtil;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.google.gson.Gson;
 import com.tuoren.common.utils.ConstastUtils;
 import com.tuoren.web.layer.d0.PatientDTO;
 import com.tuoren.web.layer.entity.BusPatientEntity;
@@ -62,9 +63,9 @@ public class BusPatientServiceImpl extends ServiceImpl<BusPatientMapper, BusPati
         if (busPatientEntity != null) {
             //TODO: 下发用户信息到上位机
             // 自定义属性映射规则
-
             PatientDTO data = new PatientDTO();
             data.setSysHospital_ID(busPatientEntity.getHospitalCode());
+            data.setSysProduct_ID(busPatientEntity.getProductCode());
             data.setPatientCode(busPatientEntity.getPatientCode());
             data.setPumpCode(busPatientEntity.getPumpCode());
             data.setName(busPatientEntity.getName());
@@ -105,13 +106,13 @@ public class BusPatientServiceImpl extends ServiceImpl<BusPatientMapper, BusPati
             data.setBMI(busPatientEntity.getBmi());
 
             Map<String, Object> pump = new HashMap<>();
-            pump.put("operation", 1);
+            pump.put("operation", 0);
             pump.put("tableName", "PatientInfo");
             pump.put("data", data);
-            log.info("下发用户信息到上位机内容:{}", JSONUtil.toJsonStr(pump));
-            log.info(JSONUtil.toJsonStr(pump));
+            Gson gson = new Gson();
+            log.info("下发用户信息到上位机内容:{}",gson.toJson(pump) );
             //发送到队列
-            rabbitTemplate.convertAndSend(ConstastUtils.ROUTING_KEY+busPatientEntity.getHospitalCode(),JSONUtil.toJsonStr(pump));
+            rabbitTemplate.convertAndSend(ConstastUtils.ROUTING_KEY+busPatientEntity.getHospitalCode(),gson.toJson(pump));
         }
     }
 

+ 5 - 2
pump-web/src/main/java/com/tuoren/web/rabbit/RabbitHandle.java

@@ -12,6 +12,7 @@ import cn.hutool.core.util.NumberUtil;
 import cn.hutool.core.util.ObjectUtil;
 import cn.hutool.json.JSONUtil;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.google.gson.Gson;
 import com.rabbitmq.client.AMQP;
 import com.rabbitmq.client.Channel;
 import com.tuoren.common.utils.ConstastUtils;
@@ -277,19 +278,21 @@ public class RabbitHandle {
 	}
 
 	public void sendRemovePump(Map<String, List<BusPumpEntity>> removePumpMap) {
+		Gson gson = new Gson();
 		removePumpMap
 				.forEach((k,v)->
 					v.stream()
 							.map(PumpRemovePushRabbitDTO::parse)
-							.forEach(pump-> rabbitTemplate.convertAndSend(ConstastUtils.ROUTING_KEY+k,JSONUtil.toJsonStr(pump)))
+							.forEach(pump-> rabbitTemplate.convertAndSend(ConstastUtils.ROUTING_KEY+k,gson.toJson(pump)))
 		);
 	}
 		public void sendRemovePumpUser(Map<String, List<BusPumpEntity>> removePumpMap) {
+		Gson gson = new Gson();
 		removePumpMap
 				.forEach((k,v)->
 					v.stream()
 							.map(PumpRemoveUserPushRabbitDTO::parse)
-							.forEach(pump-> rabbitTemplate.convertAndSend(ConstastUtils.ROUTING_KEY+k,JSONUtil.toJsonStr(pump)))
+							.forEach(pump-> rabbitTemplate.convertAndSend(ConstastUtils.ROUTING_KEY+k,gson.toJson(pump)))
 		);
 	}