Переглянути джерело

过滤掉已经过时的号源

lighter 2 роки тому
батько
коміт
7a62ed0cb5

+ 5 - 1
src/main/java/thyyxxk/wxservice_server/entity/appointment/GetDoctorSourcesParam.java

@@ -11,8 +11,12 @@ public class GetDoctorSourcesParam {
     private String deptCode;
     private String doctorCode;
     private Boolean nightClinic;
-
+    private Boolean needExcludePassedTime;
     public Boolean getNightClinic() {
         return null != nightClinic && nightClinic;
     }
+
+    public Boolean getNeedExcludePassedTime() {
+        return null != needExcludePassedTime && needExcludePassedTime;
+    }
 }

+ 20 - 0
src/main/java/thyyxxk/wxservice_server/service/AppointmentService.java

@@ -41,6 +41,9 @@ public class AppointmentService {
     @Value("${hrgApiUrl}")
     private String hrgApiUrl;
 
+    private static final int[] ampmValue = new int[]{830, 900, 930, 1000, 1030, 1100, 1130, 1200, 1430, 1500, 1530, 1600, 1630, 1700};
+    private static final String[] ampmLabel = new String[]{"a1","a2","a3","a4","a5","a6","a7","a8","p1","p2","p3","p4","p5","p6"};
+
     @Autowired
     public AppointmentService(AppointmentDao dao, RedisLikeService redis, ElectronicHealthCardService healthCardService, WxRefundService wxRefundService) {
         this.dao = dao;
@@ -219,6 +222,23 @@ public class AppointmentService {
             return ResultVoUtil.fail(ExceptionEnum.SLIGHTLY_ERROR, data.getResultMessage());
         }
         data.getData().removeIf(map -> (int) map.get("leftNum") == 0);
+        String today = DateUtil.formatDatetime(new Date(), "yyyy-MM-dd");
+        if (param.getNeedExcludePassedTime() && param.getDate().equals(today)) {
+            int currentHourMinute = DateUtil.parseHourMinuteToInteger();
+            int validAmpmIndex = 0;
+            for (int i = 0; i < ampmValue.length; i++) {
+                if (currentHourMinute < ampmValue[i]) {
+                    validAmpmIndex = i;
+                    break;
+                }
+            }
+            for (Map<String, Object> map : data.getData()) {
+                for (int i = 0; i < validAmpmIndex; i++) {
+                    map.remove(ampmLabel[i]);
+                }
+            }
+        }
+
         if (data.getData().size() == 0) {
             return ResultVoUtil.fail(ExceptionEnum.SLIGHTLY_ERROR);
         }

+ 5 - 0
src/main/java/thyyxxk/wxservice_server/utils/DateUtil.java

@@ -30,6 +30,11 @@ public class DateUtil {
         }
     }
 
+    public static int parseHourMinuteToInteger() {
+        SimpleDateFormat sdf = new SimpleDateFormat("HHmm");
+        return Integer.parseInt(sdf.format(new Date()));
+    }
+
     public static String parseTimestamp(Long timestamp) {
         Date date = new Date(timestamp);
         SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");

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

@@ -32,9 +32,9 @@ mybatis:
   configuration:
     map-underscore-to-camel-case: true
 
-hrgApiUrl: http://172.16.30.33:8089/thmz/api/v1
+#hrgApiUrl: http://172.16.30.33:8089/thmz/api/v1
 #hrgApiUrl: http://172.16.30.33:8889/thmz/api/v1
-#hrgApiUrl: http://172.16.32.160:81/thmz/api/v1
+hrgApiUrl: http://172.16.32.160:81/thmz/api/v1
 
 inspectionUrl: http://172.16.32.178:622/pushservice.asmx?wsdl
 physicalCheck: http://172.16.32.183:8888/bdp/dataservice/api/