فهرست منبع

add
优化定时任务

lifang 1 ماه پیش
والد
کامیت
30ed85607c

+ 1 - 1
nb-admin/src/main/resources/application-dev.yml

@@ -86,7 +86,7 @@ spring:
       org:
         quartz:
           scheduler:
-            instanceName: NbScheduler
+            instanceName: NbDevScheduler
             instanceId: AUTO
           jobStore:
             class: org.quartz.impl.jdbcjobstore.JobStoreTX

+ 3 - 3
nb-admin/src/main/resources/application-prod.yml

@@ -119,9 +119,9 @@ spring:
             myDS:
               provider: hikaricp
               driver: com.mysql.cj.jdbc.Driver
-              URL: jdbc:mysql://47.101.214.91:7001/nbnetpump?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false&serverTimezone=GMT%2B8&autoReconnect=true
-              user: root
-              password: Tuoren123.
+              URL: ${spring.datasource.url}
+              user: ${spring.datasource.username}
+              password: ${spring.datasource.password}
               validationQuery: SELECT 1
   # redis 配置
   redis:

+ 2 - 2
nb-admin/src/main/resources/application.yml

@@ -7,7 +7,7 @@ spring:
   application:
     name: nb
   profiles:
-    active: dev
+    active: prod
   jackson:
     time-zone: GMT+8
 
@@ -17,7 +17,7 @@ server:
     context-path: /api
   undertow:
     accesslog:
-      enabled: true
+      enabled: false
     max-http-post-size: -1
     buffer-size: 1024
     direct-buffers: true

+ 58 - 8
nb-core/src/main/java/com/nb/core/utils/DateCompareUtil.java

@@ -2,6 +2,9 @@ package com.nb.core.utils;
 
 import cn.hutool.core.date.DateUtil;
 
+import java.time.LocalDateTime;
+import java.time.ZoneId;
+import java.time.format.DateTimeFormatter;
 import java.util.Date;
 
 /**
@@ -14,13 +17,13 @@ import java.util.Date;
 public class DateCompareUtil {
 
     /**
-     * 按年月日时分进行比较,忽略毫秒部分
+     * 按年月日时分进行比较,忽略秒和毫秒部分,时区为东八区
      *
      * @param date1 第一个日期
      * @param date2 第二个日期
-     * @return 如果两个日期的年月日时分相同返回true,否则返回false
+     * @return 如果两个日期的年月日时分相同返回true,否则返回false
      */
-    public static boolean isSameDateTimeIgnoreMillis(Date date1, Date date2) {
+    public static boolean isSameDateTimeIgnoreSeconds(Date date1, Date date2) {
         if (date1 == null && date2 == null) {
             return true;
         }
@@ -28,8 +31,13 @@ public class DateCompareUtil {
             return false;
         }
 
-        String format = "yyyy-MM-dd HH:mm:ss";
-        return DateUtil.format(date1, format).equals(DateUtil.format(date2, format));
+        // 转换为东八区 LocalDateTime
+        ZoneId chinaZone = ZoneId.of("Asia/Shanghai");
+        LocalDateTime localDateTime1 = date1.toInstant().atZone(chinaZone).toLocalDateTime();
+        LocalDateTime localDateTime2 = date2.toInstant().atZone(chinaZone).toLocalDateTime();
+        
+        DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm");
+        return localDateTime1.format(formatter).equals(localDateTime2.format(formatter));
     }
 
     /**
@@ -47,11 +55,35 @@ public class DateCompareUtil {
             return false;
         }
 
-        return DateUtil.isSameDay(date1, date2);
+        // 转换为东八区进行比较
+        ZoneId chinaZone = ZoneId.of("Asia/Shanghai");
+        LocalDateTime localDateTime1 = date1.toInstant().atZone(chinaZone).toLocalDateTime();
+        LocalDateTime localDateTime2 = date2.toInstant().atZone(chinaZone).toLocalDateTime();
+
+        return localDateTime1.toLocalDate().equals(localDateTime2.toLocalDate());
     }
 
     /**
-     * 按年月日时分秒毫秒进行精确比较
+     * 按年月日时分秒进行比较,忽略毫秒部分
+     *
+     * @param date1 第一个日期
+     * @param date2 第二个日期
+     * @return 如果两个日期的年月日时分秒相同返回true,否则返回false
+     */
+    public static boolean isSameDateTimeIgnoreMillis(Date date1, Date date2) {
+        if (date1 == null && date2 == null) {
+            return true;
+        }
+        if (date1 == null || date2 == null) {
+            return false;
+        }
+
+        String format = "yyyy-MM-dd HH:mm:ss";
+        return DateUtil.format(date1, format).equals(DateUtil.format(date2, format));
+    }
+
+    /**
+     * 按年月日时分秒毫秒进行精确比较,时区为东八区
      *
      * @param date1 第一个日期
      * @param date2 第二个日期
@@ -65,6 +97,24 @@ public class DateCompareUtil {
             return false;
         }
 
-        return date1.equals(date2);
+        // 转换为东八区进行比较
+        ZoneId chinaZone = ZoneId.of("Asia/Shanghai");
+        LocalDateTime localDateTime1 = date1.toInstant().atZone(chinaZone).toLocalDateTime();
+        LocalDateTime localDateTime2 = date2.toInstant().atZone(chinaZone).toLocalDateTime();
+        
+        return localDateTime1.equals(localDateTime2);
+    }
+    
+    /**
+     * 将Date转换为年月日时分字符串形式,时区为东八区
+     * 
+     * @param date 待转换的日期
+     * @return 格式为"yyyy-MM-dd HH:mm"的字符串
+     */
+    public static Date convertToyyyyMMddHHmm(Date date) {
+        if (date == null) {
+            return null;
+        }
+        return DateUtil.beginOfMinute(date);
     }
 }

+ 12 - 2
nb-service/web-service/src/main/java/com/nb/web/service/bus/listener/HisInfoListener.java

@@ -1,8 +1,10 @@
 package com.nb.web.service.bus.listener;
 
 import cn.hutool.core.collection.CollectionUtil;
+import cn.hutool.core.util.ObjectUtil;
 import cn.hutool.json.JSONUtil;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.nb.core.utils.DateCompareUtil;
 import com.nb.web.api.entity.BusClinicEntity;
 import com.nb.web.service.bus.entity.BusHospitalEntity;
 import com.nb.web.service.bus.entity.BusPatientEntity;
@@ -20,6 +22,7 @@ import org.springframework.transaction.annotation.Transactional;
 import org.springframework.transaction.interceptor.TransactionAspectSupport;
 
 import java.util.List;
+import java.util.stream.Collectors;
 
 /**
  * @author lifang
@@ -50,6 +53,13 @@ public class HisInfoListener {
         if(CollectionUtil.isEmpty(sources)){
             return;
         }
+        final List<BusClinicEntity>  formatSources=sources.stream()
+                .peek(clinic->{
+                    if(ObjectUtil.isNotNull(clinic.getStartTime())){
+                        clinic.setStartTime(DateCompareUtil.convertToyyyyMMddHHmm(clinic.getStartTime()));
+                    }
+                })
+                .collect(Collectors.toList());
         try {
             BusPatientEntity patient = patientService.findByFormatCode(patientCode, hospitalId);
             if(patient==null){
@@ -65,10 +75,10 @@ public class HisInfoListener {
             hisStrategyManager
                     .getHandlers()
                     .stream()
-                    .filter(handler -> handler.apply(sources, target))
+                    .filter(handler -> handler.apply(formatSources, target))
                     //找到第一个匹配的处理器进行处理
                     .findFirst()
-                    .ifPresent(handler-> handler.handle(sources,target));
+                    .ifPresent(handler-> handler.handle(formatSources,target));
         } catch (Exception e){
             log.error("解析his数据时出错,解析后数据:{},错误原因,{}",JSONUtil.toJsonStr(infoEvent),e.getLocalizedMessage());
             TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();

+ 1 - 1
nb-service/web-service/src/main/java/com/nb/web/service/bus/service/dto/ClinicResult.java

@@ -69,7 +69,7 @@ public class ClinicResult  implements Serializable {
     private Integer infusionCount;
 
     @ApiModelProperty("评价信息")
-    private int evalCount;
+    private Integer evalCount;
 
     @ApiModelProperty(value = "废液执行人")
     private String liquidExecutor;

+ 2 - 1
nb-service/web-service/src/main/resources/mapper/bus/BusClinicMapper.xml

@@ -136,6 +136,7 @@
         left join bus_patient
         as p on c.patient_id = p.id
         <where>
+            p.infusion_id is not null
             <if test="query.liquid!=null and query.liquid == true">
                 and c.finished= 1
             </if>
@@ -341,7 +342,7 @@
                 and liquid_checker is not null
             </if>
         </where>
-        order by undo_time desc
+        order by clinic_start_time desc
     </select>