فهرست منبع

修改撤泵数据下发,增加人员修改时下发人员信息

wangzl 6 ماه پیش
والد
کامیت
84767893ef

+ 16 - 1
pump-web/src/main/java/com/tuoren/web/layer/controller/BusPatientController.java

@@ -1,14 +1,25 @@
 package com.tuoren.web.layer.controller;
 
+import cn.hutool.json.JSONUtil;
+import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONObject;
 import com.tuoren.common.api.CommonResult;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 
+import com.tuoren.common.utils.ConstastUtils;
+import com.tuoren.common.utils.enums.LogType;
+import com.tuoren.web.layer.entity.BusAnalgesicScoreEntity;
+import com.tuoren.web.layer.entity.SysBreathEntity;
 import com.tuoren.web.layer.vo.PatientParam;
+import com.tuoren.web.utils.ConverterUtils;
+import com.tuoren.web.utils.DataUtils;
+import com.tuoren.web.utils.LogUtils;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import lombok.extern.slf4j.Slf4j;
+import org.springframework.amqp.rabbit.connection.CorrelationData;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.dao.DuplicateKeyException;
 import org.springframework.web.bind.annotation.*;
@@ -93,7 +104,11 @@ public class BusPatientController{
         @PutMapping
         public CommonResult update(@RequestBody BusPatientEntity busPatientEntity) {
             try {
-                return CommonResult.success(this.iBusPatientEntityService.updateById(busPatientEntity),"修改成功");
+                boolean flag = this.iBusPatientEntityService.updateById(busPatientEntity);
+                if(flag){
+                    iBusPatientEntityService.sendPatientInfoToPump(busPatientEntity.getPatientId());
+                }
+                return CommonResult.success(flag,"修改成功");
             } catch (Exception e) {
                  log.error("出现错误, {}",e.getMessage());
                  return CommonResult.failed("修改失败");

+ 13 - 0
pump-web/src/main/java/com/tuoren/web/layer/controller/BusPumpController.java

@@ -6,6 +6,7 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 
+import com.tuoren.web.layer.d0.PumpRemoveRequestDTO;
 import com.tuoren.web.layer.vo.PumpParam;
 import com.tuoren.web.layer.entity.BusPatientEntity;
 import com.tuoren.web.layer.entity.SysUserEntity;
@@ -227,4 +228,16 @@ public class BusPumpController{
         iBusPumpEntityService.removePump(ids);
         return CommonResult.success(Boolean.TRUE);
     }
+
+    /**
+     * 撤泵
+     * @param requestDTO 参数
+     * @return
+     */
+    @ApiOperation("撤泵")
+    @PostMapping("/removePumpByIdsNew")
+    public CommonResult<Boolean> removePumpNew(@RequestBody PumpRemoveRequestDTO requestDTO) {
+        iBusPumpEntityService.removePumpNew(requestDTO);
+        return CommonResult.success(Boolean.TRUE);
+    }
 }

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

@@ -0,0 +1,78 @@
+package com.tuoren.web.layer.d0;
+
+import cn.hutool.core.date.DateTime;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+/**
+ * @author wangzl
+ * @description: TODO
+ * @date 2025/6/17 15:01
+ */
+@ApiModel("推送上位机人员信息")
+@Data
+public class PatientDTO {
+
+    @ApiModelProperty("医院编号")
+    private String SysHospital_ID;
+    @ApiModelProperty("产品编号")
+    private String SysProduct_ID;
+    @ApiModelProperty("住院号")
+    private String PatientCode;
+    @ApiModelProperty("泵号")
+    private String PumpCode;
+    @ApiModelProperty("姓名")
+    private String Name;
+    @ApiModelProperty("性别")
+    private String Sex;
+    @ApiModelProperty("身高")
+    private String Height;
+    @ApiModelProperty("体重")
+    private String Weight;
+    @ApiModelProperty("年龄")
+    private Integer Age;
+    @ApiModelProperty("病区")
+    private String Ward;
+    @ApiModelProperty("床号")
+    private String BedNo;
+    @ApiModelProperty("手术名称")
+    private String Operation;
+    @ApiModelProperty("手术医生")
+    private String Surgeon;
+    @ApiModelProperty("ASA")
+    private String ASA;
+    @ApiModelProperty("镇痛方式")
+    private String EaseMode;
+    @ApiModelProperty("麻醉医生")
+    private String Doctor;
+    @ApiModelProperty("麻醉医生2")
+    private String DoctorTwo;
+    @ApiModelProperty("麻醉方式")
+    private String AnesthesiaMode;
+    @ApiModelProperty("配置人员")
+    private String ConfigPerson;
+    @ApiModelProperty("配方")
+    private String Formula;
+    @ApiModelProperty("撤泵人")
+    private String UndoPerson;
+    @ApiModelProperty("销毁人")
+    private String DestroyPerson;
+    @ApiModelProperty("见证人")
+    private String WitnessPerson;
+    @ApiModelProperty("撤泵时间")
+    private String UndoTime;
+    @ApiModelProperty("盐值")
+    private String Salt;
+    @ApiModelProperty("剩余量处置")
+    private String Balance;
+    @ApiModelProperty("备注")
+    private String Remark;
+    @ApiModelProperty("是否删除")
+    private Boolean IsDelete;
+    @ApiModelProperty("创建时间")
+    private String CreateTime;
+    @ApiModelProperty("身高体重BMI")
+    private String BMI;
+
+}

+ 21 - 0
pump-web/src/main/java/com/tuoren/web/layer/d0/PumpRemoveRequestDTO.java

@@ -0,0 +1,21 @@
+package com.tuoren.web.layer.d0;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.util.List;
+
+/**
+ * @author wangzl
+ * @description: TODO
+ * @date 2025/6/13 9:52
+ */
+@Data
+@ApiModel("撤泵请求参数实体")
+public class PumpRemoveRequestDTO {
+    @ApiModelProperty("泵id列表")
+    private List<String> ids;
+    @ApiModelProperty("撤泵人")
+    private String removeUser;
+}

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

@@ -0,0 +1,46 @@
+package com.tuoren.web.layer.d0;
+
+import com.tuoren.web.layer.entity.BusPumpEntity;
+import io.swagger.annotations.ApiModel;
+import lombok.AllArgsConstructor;
+import lombok.Builder;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+/**
+ * @author wangzl
+ * @description: TODO
+ * @date 2025/6/13 11:57
+ */
+@ApiModel("撤泵数据下发到撤泵人")
+@Data
+@NoArgsConstructor
+@AllArgsConstructor
+@Builder
+public class PumpRemoveUserPushRabbitDTO {
+
+    private Integer operation;
+    private String tableName;
+    private String patientCode;
+    private Data data;
+
+    @lombok.Data
+    @AllArgsConstructor(staticName = "of")
+    private static class Data {
+        private String SysHospital_ID;
+        private String PatientCode;
+        private String UndoPerson;
+        private String PumpCode;
+    }
+
+
+    public static PumpRemoveUserPushRabbitDTO parse(BusPumpEntity source) {
+        return PumpRemoveUserPushRabbitDTO.builder()
+                .operation(1)
+                .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

@@ -231,4 +231,7 @@ public class BusPumpEntity implements Serializable {
     @ApiModelProperty("电机状态")
     private String numberStatus;
 
+    @ApiModelProperty("撤泵人")
+    private String removeUser;
+
 }

+ 9 - 0
pump-web/src/main/java/com/tuoren/web/layer/service/IBusPatientService.java

@@ -1,6 +1,7 @@
 package com.tuoren.web.layer.service;
 
 import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.tuoren.web.layer.entity.BusPumpEntity;
 import com.tuoren.web.layer.vo.PatientParam;
 import com.tuoren.web.layer.entity.BusPatientEntity;
 import com.baomidou.mybatisplus.extension.service.IService;
@@ -20,4 +21,12 @@ public interface IBusPatientService extends IService<BusPatientEntity> {
      * @return
      */
     IPage<BusPatientEntity> queryFuzzyPatient(PatientParam patientParam);
+
+    /**
+     * @description: 下发用户信息到上位机
+     * @author wangzl
+     * @date 2025/6/17
+     */
+    void sendPatientInfoToPump(String id) ;
+
 }

+ 3 - 0
pump-web/src/main/java/com/tuoren/web/layer/service/IBusPumpService.java

@@ -1,6 +1,7 @@
 package com.tuoren.web.layer.service;
 
 import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.tuoren.web.layer.d0.PumpRemoveRequestDTO;
 import com.tuoren.web.layer.vo.PumpParam;
 import com.tuoren.web.layer.entity.BusPumpEntity;
 import com.baomidou.mybatisplus.extension.service.IService;
@@ -58,4 +59,6 @@ public interface IBusPumpService extends IService<BusPumpEntity> {
 
 
     void removePump(List<String> ids);
+    void removePumpNew(PumpRemoveRequestDTO requestDTO);
+
 }

+ 94 - 2
pump-web/src/main/java/com/tuoren/web/layer/service/impl/BusPatientServiceImpl.java

@@ -1,26 +1,51 @@
 package com.tuoren.web.layer.service.impl;
 
+import cn.hutool.core.bean.BeanUtil;
+import cn.hutool.core.bean.copier.CopyOptions;
+import cn.hutool.core.date.DateTime;
+import cn.hutool.core.date.DateUtil;
+import cn.hutool.json.JSONUtil;
+import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONObject;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.tuoren.common.utils.ConstastUtils;
+import com.tuoren.common.utils.enums.LogType;
+import com.tuoren.web.layer.d0.PatientDTO;
+import com.tuoren.web.layer.entity.BusAnalgesicScoreEntity;
+import com.tuoren.web.layer.entity.SysBreathEntity;
 import com.tuoren.web.layer.vo.PatientParam;
 import com.tuoren.web.layer.entity.BusPatientEntity;
 import com.tuoren.web.layer.mapper.BusPatientMapper;
 import com.tuoren.web.layer.service.IBusPatientService;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.tuoren.web.utils.ConverterUtils;
+import com.tuoren.web.utils.DataUtils;
+import com.tuoren.web.utils.LogUtils;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.amqp.rabbit.connection.CorrelationData;
+import org.springframework.amqp.rabbit.core.RabbitTemplate;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
-import java.util.List;
+import java.time.ZoneId;
+import java.util.*;
 
 /**
  * <p>
- *  服务实现类
+ * 服务实现类
  * </p>
  *
  * @author fanfan
  * @since 2020-07-03
  */
 @Service
+@Slf4j
 public class BusPatientServiceImpl extends ServiceImpl<BusPatientMapper, BusPatientEntity> implements IBusPatientService {
+    @Autowired
+    private RabbitTemplate rabbitTemplate;
+
     @Override
     public IPage<BusPatientEntity> queryFuzzyPatient(PatientParam patientParam) {
         IPage<BusPatientEntity> iPage = new Page<>(patientParam.getPageNo(), patientParam.getPageSize());
@@ -37,4 +62,71 @@ public class BusPatientServiceImpl extends ServiceImpl<BusPatientMapper, BusPati
         iPage.setRecords(list);
         return iPage;
     }
+
+    /**
+     * @param id
+     * @description: 下发用户信息到上位机
+     * @author wangzl
+     * @date 2025/6/17
+     */
+    @Override
+    public void sendPatientInfoToPump(String id) {
+        BusPatientEntity busPatientEntity = baseMapper.selectById(id);
+        if (busPatientEntity != null) {
+            //TODO: 下发用户信息到上位机
+            // 自定义属性映射规则
+
+            PatientDTO data = new PatientDTO();
+            data.setSysHospital_ID(busPatientEntity.getHospitalCode());
+            data.setPatientCode(busPatientEntity.getPatientCode());
+            data.setPumpCode(busPatientEntity.getPumpCode());
+            data.setName(busPatientEntity.getName());
+            data.setSex(busPatientEntity.getSex());
+            data.setHeight(busPatientEntity.getHeight());
+            data.setWeight(busPatientEntity.getWeight());
+            data.setAge(busPatientEntity.getAge());
+            data.setWard(busPatientEntity.getWardCode());
+            data.setBedNo(busPatientEntity.getBedCode());
+            data.setOperation(busPatientEntity.getOperationName());
+            data.setSurgeon(busPatientEntity.getOperationDoctor());
+            data.setASA(busPatientEntity.getAsa());
+            data.setEaseMode(busPatientEntity.getEasyMode());
+            data.setDoctor(busPatientEntity.getAnesthesiaDoctor1());
+            data.setDoctorTwo(busPatientEntity.getAnesthesiaDoctor2());
+            data.setAnesthesiaMode(busPatientEntity.getAnesthesiaMode());
+            data.setConfigPerson(busPatientEntity.getConfigPerson());
+            data.setFormula(busPatientEntity.getFormula());
+            data.setUndoPerson(busPatientEntity.getUndoPerson());
+            data.setDestroyPerson(busPatientEntity.getDestoryPerson());
+            data.setWitnessPerson(busPatientEntity.getWitnessPerson());
+            if (!Objects.isNull(busPatientEntity.getUndoTime())) {
+                Date undoTime = new Date(busPatientEntity.getUndoTime().atZone(ZoneId.systemDefault()).toInstant().toEpochMilli());
+                data.setUndoTime(DateUtil.format(undoTime, "yyyy-MM-dd HH:mm:ss"));
+            } else {
+                data.setUndoTime(null);
+            }
+            data.setSalt(busPatientEntity.getSalt());
+            data.setBalance(busPatientEntity.getRemain());
+            data.setRemark(busPatientEntity.getRemark());
+            data.setIsDelete(busPatientEntity.getIsDelete());
+            if (!Objects.isNull(busPatientEntity.getGmtCreate())) {
+                Date gmtDate = new Date(busPatientEntity.getGmtCreate().atZone(ZoneId.systemDefault()).toInstant().toEpochMilli());
+                data.setCreateTime(DateUtil.format(gmtDate, "yyyy-MM-dd HH:mm:ss"));
+            } else {
+                data.setCreateTime(null);
+            }
+            data.setBMI(busPatientEntity.getBmi());
+
+            Map<String, Object> pump = new HashMap<>();
+            pump.put("operation", 1);
+            pump.put("tableName", "PatientInfo");
+            pump.put("data", data);
+            log.info("下发用户信息到上位机内容:{}", JSONUtil.toJsonStr(pump));
+            System.out.println(JSONUtil.toJsonStr(pump));
+            //发送到队列
+            rabbitTemplate.convertAndSend(ConstastUtils.ROUTING_KEY+busPatientEntity.getHospitalCode(),JSONUtil.toJsonStr(pump));
+        }
+    }
+
+
 }

+ 46 - 7
pump-web/src/main/java/com/tuoren/web/layer/service/impl/BusPumpServiceImpl.java

@@ -3,30 +3,34 @@ package com.tuoren.web.layer.service.impl;
 import cn.hutool.core.collection.CollectionUtil;
 import cn.hutool.core.util.StrUtil;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.core.toolkit.StringUtils;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
-import com.tuoren.web.layer.entity.BusReceiveRecordCopyEntity;
-import com.tuoren.web.layer.mapper.BusReceiveRecordCopyMapper;
-import com.tuoren.web.layer.vo.PumpParam;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.tuoren.web.layer.d0.PumpRemoveRequestDTO;
+import com.tuoren.web.layer.d0.PumpVo;
 import com.tuoren.web.layer.entity.BusPumpEntity;
+import com.tuoren.web.layer.entity.BusReceiveRecordCopyEntity;
 import com.tuoren.web.layer.entity.BusReceiveRecordEntity;
 import com.tuoren.web.layer.mapper.BusPumpMapper;
+import com.tuoren.web.layer.mapper.BusReceiveRecordCopyMapper;
 import com.tuoren.web.layer.mapper.BusReceiveRecordMapper;
 import com.tuoren.web.layer.service.IBusPumpService;
-import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
-import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
-
+import com.tuoren.web.layer.vo.PumpParam;
 import com.tuoren.web.rabbit.RabbitHandle;
 import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
-import com.tuoren.web.layer.d0.PumpVo;
 import org.springframework.context.annotation.Lazy;
 import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
 
+import java.util.ArrayList;
 import java.util.Collection;
 import java.util.List;
 import java.util.Map;
 import java.util.stream.Collectors;
+import java.util.stream.Stream;
 
 /**
  * <p>
@@ -199,4 +203,39 @@ public class BusPumpServiceImpl extends ServiceImpl<BusPumpMapper, BusPumpEntity
 
         }
     }
+
+
+
+    @Override
+    @Transactional(rollbackFor = Exception.class)
+    public void removePumpNew(PumpRemoveRequestDTO requestDTO) {
+        if(CollectionUtil.isEmpty(requestDTO.getIds())){
+            return;
+        }
+        if(StringUtils.isNotEmpty(requestDTO.getRemoveUser())){
+            return;
+        }
+        Collection<BusPumpEntity> pumps = this.list(new LambdaQueryWrapper<BusPumpEntity>()
+                .in(BusPumpEntity::getId,requestDTO.getIds()));
+        List<BusPumpEntity> collect = pumps.stream()
+                .peek(p -> p.setRemoveUser(requestDTO.getRemoveUser())).collect(Collectors.toList());
+        this.updateBatchById(collect);
+
+        if(CollectionUtil.isEmpty(pumps)){
+            return;
+        }
+        Map<String, List<BusPumpEntity>> pumpMap = collect.stream()
+                .peek(p -> p.setIsRemove(Boolean.FALSE))
+                .collect(Collectors.groupingBy(BusPumpEntity::getHospitalCode));
+
+        this.updateBatchById(pumps);
+        try {
+            //下发
+            rabbitHandle.sendRemovePump(pumpMap);
+            //下发用户
+            rabbitHandle.sendRemovePumpUser(pumpMap);
+        }catch (Exception e){
+
+        }
+    }
 }

+ 14 - 4
pump-web/src/main/java/com/tuoren/web/rabbit/RabbitHandle.java

@@ -16,6 +16,7 @@ import com.rabbitmq.client.AMQP;
 import com.rabbitmq.client.Channel;
 import com.tuoren.common.utils.ConstastUtils;
 import com.tuoren.web.layer.d0.PumpRemovePushRabbitDTO;
+import com.tuoren.web.layer.d0.PumpRemoveUserPushRabbitDTO;
 import com.tuoren.web.layer.entity.*;
 import com.tuoren.web.layer.service.*;
 
@@ -277,11 +278,20 @@ public class RabbitHandle {
 
 	public void sendRemovePump(Map<String, List<BusPumpEntity>> removePumpMap) {
 		removePumpMap
-				.forEach((k,v)->{
+				.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,JSONUtil.toJsonStr(pump)))
+		);
 	}
+		public void sendRemovePumpUser(Map<String, List<BusPumpEntity>> removePumpMap) {
+		removePumpMap
+				.forEach((k,v)->
+					v.stream()
+							.map(PumpRemoveUserPushRabbitDTO::parse)
+							.forEach(pump-> rabbitTemplate.convertAndSend(ConstastUtils.ROUTING_KEY+k,JSONUtil.toJsonStr(pump)))
+		);
+	}
+
+
 }