浏览代码

add
苹果手机报警推送

18339543638 1 年之前
父节点
当前提交
ef36cd0f95

+ 13 - 5
nb-service/app-assistant/src/main/java/com/nb/app/assistant/utils/ApnsUtils.java

@@ -3,8 +3,10 @@ package com.nb.app.assistant.utils;
 import cn.hutool.core.io.FileUtil;
 import cn.hutool.core.io.resource.ClassPathResource;
 import cn.hutool.core.io.resource.ResourceUtil;
+import cn.hutool.core.map.MapUtil;
 import cn.hutool.json.JSONUtil;
 import com.nb.app.assistant.api.bean.DeviceAlarmBean;
+import com.nb.web.api.enums.DeviceAlarmEnum;
 import com.turo.pushy.apns.*;
 import com.turo.pushy.apns.auth.ApnsSigningKey;
 import com.turo.pushy.apns.util.SimpleApnsPushNotification;
@@ -18,6 +20,7 @@ import java.io.File;
 import java.io.InputStream;
 import java.net.URL;
 import java.util.Date;
+import java.util.Map;
 import java.util.UUID;
 import static com.turo.pushy.apns.PushType.ALERT;
 
@@ -41,7 +44,7 @@ public class ApnsUtils {
         String topic = "tuoren.PumpIOS";
 
         ApsEntity aps = ApsEntity.createDefault(ApsEntity.AlertEntity.of("驼人镇痛泵报警", String.format("设备号:%s,住院号:%s", source.getDeviceId(), source.getPatientCode()), source.getAlarmState().getText()));
-        String payload = JSONUtil.toJsonStr(aps);
+        String payload = JSONUtil.toJsonStr( MapUtil.of("aps",aps));
         //有效时间
         Date invalidationTime= new Date(System.currentTimeMillis() + 60 * 60 * 1000L );
         //发送策略 apns-priority 10为立即 5为省电
@@ -62,18 +65,23 @@ public class ApnsUtils {
         //如果失败不必惊慌,rejectionReason字段中会有失败的原因。对应官网找到原因即可
         //https://developer.apple.com/documentation/usernotifications/setting_up_a_remote_notification_server/handling_notification_responses_from_apns?language=objc
 
-        log.info("IOS云响应------------->"+JSONUtil.toJsonStr(response));
+        log.info("IOS云响应------------->"+response.isAccepted()+":"+JSONUtil.toJsonStr(response));
+    }
 
 
+    public static void main(String[] args) throws Exception {
+        DeviceAlarmBean deviceAlarmBean = new DeviceAlarmBean();
+        deviceAlarmBean.setAlarmState(DeviceAlarmEnum.Bubble);
+        deviceAlarmBean.setDeviceId("123");
+        deviceAlarmBean.setPatientCode("34556");
+        deviceAlarmBean.setUploadTime(new Date());
+        sendMsg("d515d98839e2e630c58feae45ab1b6e60d54c288d6f46640e6b68e0466424ea7",deviceAlarmBean);
     }
 
     public static ApnsClient getAPNSConnect() {
-
         if (apnsClient == null) {
             try {
                 //四个线程
-                URL url = ResourceUtil.getResource("AuthKey_X4S8H58U59.p8");
-
                 ClassPathResource classPathResource = new ClassPathResource("AuthKey_X4S8H58U59.p8");
                 InputStream inputStream = classPathResource.getStream();
                 EventLoopGroup eventLoopGroup = new NioEventLoopGroup(4);

+ 62 - 3
nb-service/web-service/src/main/java/com/nb/web/service/bus/controller/vo/BusClinicExcelVO.java

@@ -2,12 +2,14 @@ package com.nb.web.service.bus.controller.vo;
 
 import cn.hutool.core.collection.CollectionUtil;
 import cn.hutool.core.date.DatePattern;
+import cn.hutool.core.util.EnumUtil;
 import cn.hutool.core.util.ObjectUtil;
 import com.alibaba.excel.annotation.ExcelProperty;
 import com.nb.core.enums.SexEnum;
 import com.nb.web.api.bean.FormulaDrugDetailDomain;
 import com.nb.web.api.bean.FormulaDrugDomain;
 import com.nb.web.api.entity.BusEvaluationEntity;
+import com.nb.web.api.entity.BusInfusionHistoryEntity;
 import lombok.Data;
 
 import java.math.BigDecimal;
@@ -85,6 +87,44 @@ public class BusClinicExcelVO {
     private String entrust;
 
 
+    /*************输注部分*********************/
+    private String infusionId;
+    @ExcelProperty(value = "输注开始时间",format = DatePattern.NORM_DATETIME_PATTERN)
+    private Date infusionStartTime;
+
+    @ExcelProperty(value = "总量")
+    private Integer totalDose;
+
+    @ExcelProperty(value = "首次量")
+    private Integer firstDose;
+
+    @ExcelProperty(value = "剩余量")
+    private BigDecimal remainDose;
+
+    @ExcelProperty(value = "已输入量")
+    private BigDecimal inputDose;
+
+    @ExcelProperty(value = "持续量")
+    private BigDecimal continueDose;
+
+    @ExcelProperty(value = "追加量")
+    private BigDecimal appendDose;
+
+    @ExcelProperty(value = "极限量")
+    private BigDecimal maxDose;
+
+    @ExcelProperty(value = "自控锁时")
+    private BigDecimal selfControlLockTime;
+
+    @ExcelProperty(value = "pca有效次数")
+    private Integer pcaValidCount;
+
+    @ExcelProperty(value = "pca无效次数")
+    private Integer pcaInvalidCount;
+
+    @ExcelProperty(value = "pca总按次数")
+    private Integer pcaTotalCount;
+
     /*************评价部分********************/
 
     @ExcelProperty(value = "疼痛静止评分")
@@ -167,9 +207,9 @@ public class BusClinicExcelVO {
 
     public void setPatientGender(String patientGender) {
         if(ObjectUtil.isNotNull(patientGender)){
-            SexEnum sexEnum = SexEnum.valueOf(patientGender);
+            SexEnum sexEnum = EnumUtil.likeValueOf(SexEnum.class,patientGender);
             if(ObjectUtil.isNull(sexEnum)){
-                this.patientGender = SexEnum.UNKNOW.getText();
+                this.patientGender = patientGender;
             }else {
                 this.patientGender = sexEnum.getText();
             }
@@ -193,8 +233,27 @@ public class BusClinicExcelVO {
         return content;
     }
 
+    public void fillInfusion(BusInfusionHistoryEntity infusion){
+        if(ObjectUtil.isNull(infusion)){
+            return;
+        }
+        this.infusionId=infusion.getId();
+        this.infusionStartTime=infusion.getStartTime();
+        this.totalDose=infusion.getTotalDose();
+        this.firstDose=infusion.getFirstDose();
+        this.remainDose=infusion.getRemainDose();
+        this.inputDose=infusion.getInputDose();
+        this.continueDose=infusion.getContinueDose();
+        this.appendDose=infusion.getAppendDose();
+        this.maxDose=infusion.getMaxDose();
+        this.selfControlLockTime=infusion.getSelfControlLockTime();
+        this.pcaValidCount=infusion.getPcaValidCount();
+        this.pcaInvalidCount=infusion.getPcaInvalidCount();
+        this.pcaTotalCount=infusion.getPcaTotalCount();
+    }
+
 
-    public void parseEval(BusEvaluationEntity eval){
+    public void fillEval(BusEvaluationEntity eval){
         if(ObjectUtil.isNull(eval)){
             return;
         }

+ 29 - 11
nb-service/web-service/src/main/java/com/nb/web/service/bus/service/LocalBusClinicService.java

@@ -330,35 +330,53 @@ public class LocalBusClinicService extends BaseService<BusClinicMapper, BusClini
      * @return
      */
     public String  exportExcelSourceListBase64(Collection<String> clinicIds) throws IOException {
+        List<BusClinicExcelVO> result =new ArrayList<>();
         if(CollectionUtil.isEmpty(clinicIds)){
-            return ExportExcelUtils.exportClinicExcelBase64(new ArrayList<>());
+            return ExportExcelUtils.exportClinicExcelBase64(result);
         }
         List<BusClinicEntity> clinicList = this.baseMapper.selectList(new LambdaQueryWrapper<BusClinicEntity>()
                 .in(BusClinicEntity::getId, clinicIds));
         if(CollectionUtil.isEmpty(clinicList)){
-            return ExportExcelUtils.exportClinicExcelBase64(new ArrayList<>());
+            return ExportExcelUtils.exportClinicExcelBase64(result);
         }
-        List<BusClinicExcelVO> result =new ArrayList<>();
+
+        //输注历史
+        List<BusInfusionHistoryEntity> infusionHistories = this.infusionHistoryMapper.selectList(new LambdaQueryWrapper<BusInfusionHistoryEntity>()
+                .in(BusInfusionHistoryEntity::getClinicId, clinicIds)
+                .orderByDesc(BusInfusionHistoryEntity::getStartTime));
+        Map<String, List<BusInfusionHistoryEntity>> infusionMap = infusionHistories.stream()
+                .collect(Collectors.groupingBy(BusInfusionHistoryEntity::getClinicId));
+
         List<BusEvaluationEntity> evals = evaluationMapper.selectList(new LambdaQueryWrapper<BusEvaluationEntity>()
                 .in(BusEvaluationEntity::getClinicId, clinicIds)
                 .orderByDesc(BusEvaluationEntity::getEvaluateTime));
+
         Map<String, List<BusEvaluationEntity>> clinicMap = evals.stream()
-                .collect(Collectors.groupingBy(BusEvaluationEntity::getClinicId));
+                .collect(Collectors.groupingBy(BusEvaluationEntity::getInfusionId));
 
         for (BusClinicEntity clinicEntity : clinicList) {
-            List<BusEvaluationEntity> excelEvals = clinicMap.get(clinicEntity.getId());
-            if (CollectionUtil.isNotEmpty(excelEvals)) {
-                for (BusEvaluationEntity excelEval : excelEvals) {
+            List<BusInfusionHistoryEntity> infusions = infusionMap.get(clinicEntity.getId());
+            if (CollectionUtil.isNotEmpty(infusions)) {
+                for (BusInfusionHistoryEntity infusion : infusions) {
                     BusClinicExcelVO clinicExcel = BeanUtil.copyProperties(clinicEntity, BusClinicExcelVO.class);
-                    clinicExcel.parseEval(excelEval);
-                    result.add(clinicExcel);
+                    clinicExcel.fillInfusion(infusion);
+
+                    List<BusEvaluationEntity> excelEvals = clinicMap.get(infusion.getId());
+                    if (CollectionUtil.isNotEmpty(excelEvals)) {
+                        for (BusEvaluationEntity excelEval : excelEvals) {
+                            BusClinicExcelVO excelExec = BeanUtil.copyProperties(clinicExcel, BusClinicExcelVO.class);
+                            excelExec.fillEval(excelEval);
+                            result.add(excelExec);
+                        }
+                    }else {
+                        result.add(clinicExcel);
+                    }
                 }
             }else {
                 BusClinicExcelVO clinicExcel = BeanUtil.copyProperties(clinicEntity, BusClinicExcelVO.class);
                 result.add(clinicExcel);
             }
         }
-
-      return ExportExcelUtils.exportClinicExcelBase64(result);
+        return ExportExcelUtils.exportClinicExcelBase64(result);
     }
 }

+ 41 - 3
nb-service/web-service/src/main/java/com/nb/web/service/bus/utils/ClinicExcelMergeWriteHandler.java

@@ -15,12 +15,13 @@ import java.util.List;
  * @Description :
  * @Author : LF
  * @Date: 2024年10月11日
+ *
+ * 0-18列病人的基础信息
+ * 19-32列输注信息
  */
 
 public class ClinicExcelMergeWriteHandler implements RowWriteHandler {
     private int minRowIndex=4;
-    //最大的合并列数
-    private int maxColumnIndex=18;
 
     private List<BusClinicExcelVO> source;
 
@@ -30,6 +31,42 @@ public class ClinicExcelMergeWriteHandler implements RowWriteHandler {
 
     @Override
     public void afterRowDispose(RowWriteHandlerContext context) {
+       mergeClinicInfo(context);
+       mergeInfusionInfo(context);
+    }
+
+    /**
+     * 合并输注基本信息
+     * @param context
+     */
+    private void mergeInfusionInfo(RowWriteHandlerContext context){
+        Integer rowIndex = context.getRowIndex();
+        if(rowIndex!=CollectionUtil.size(source)+3){
+            return;
+        }
+        Integer lastRowIndex =rowIndex;
+        int lastMergeIndex=lastRowIndex;
+        int currentIndex=lastRowIndex;
+        while (currentIndex>=4){
+            int preIndex=currentIndex-1;
+            preIndex=preIndex>4?preIndex:4;
+            BusClinicExcelVO curSource = CollectionUtil.get(source, currentIndex-4);
+            BusClinicExcelVO preSource = CollectionUtil.get(source, preIndex-4);
+            if(!StrUtil.equals(curSource.getInfusionId(),preSource.getInfusionId())||currentIndex==4){
+                for (int i = 19; i <= 30; i++) {
+                    mergeCell(context.getWriteSheetHolder().getSheet(),currentIndex,lastMergeIndex,i,i);
+                }
+                lastMergeIndex=preIndex;
+            }
+            currentIndex--;
+        }
+    }
+
+    /**
+     * 合并手术基本信息
+     * @param context
+     */
+    private void mergeClinicInfo(RowWriteHandlerContext context){
         Integer rowIndex = context.getRowIndex();
         if(rowIndex!=CollectionUtil.size(source)+3){
             return;
@@ -43,7 +80,7 @@ public class ClinicExcelMergeWriteHandler implements RowWriteHandler {
             BusClinicExcelVO curSource = CollectionUtil.get(source, currentIndex-4);
             BusClinicExcelVO preSource = CollectionUtil.get(source, preIndex-4);
             if(!StrUtil.equals(curSource.getId(),preSource.getId())||currentIndex==4){
-                for (int i = 0; i <= maxColumnIndex; i++) {
+                for (int i = 0; i <= 18; i++) {
                     mergeCell(context.getWriteSheetHolder().getSheet(),currentIndex,lastMergeIndex,i,i);
                 }
                 lastMergeIndex=preIndex;
@@ -52,6 +89,7 @@ public class ClinicExcelMergeWriteHandler implements RowWriteHandler {
         }
     }
 
+
     private void mergeCell(Sheet sheet,int startRowIndex, int endRowIndex, int startColumnIndex, int endColumnIndex){
         //开始和结束行数一样
         if(startRowIndex==endRowIndex){

二进制
nb-service/web-service/src/main/resources/export/clinicExcel.xlsx