From e36c1e2363e36a69a3cc8ccbc00d28b16f926abd Mon Sep 17 00:00:00 2001
From: eight <641137800@qq.com>
Date: 星期四, 07 十一月 2024 14:38:57 +0800
Subject: [PATCH] 序号表操作

---
 jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/Constants.java                                      |   13 ++++
 jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/controller/admin/config/ECGConfigController.java    |   49 ++++++++++++++++
 jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/service/queue/QueueServiceImpl.java                 |    1 
 jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/service/config/EcgConfigService.java                |    5 +
 jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/service/queuesequence/QueueSequenceServiceImpl.java |   19 ++++-
 jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/service/config/EcgConfigServiceImpl.java            |   21 +++++-
 jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/controller/admin/config/vo/TimeslotVO.java          |   10 +++
 jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/service/queue/QueueServiceTxFunctions.java          |    7 --
 8 files changed, 106 insertions(+), 19 deletions(-)

diff --git a/jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/Constants.java b/jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/Constants.java
index 30bb5a1..e6e9830 100644
--- a/jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/Constants.java
+++ b/jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/Constants.java
@@ -1,6 +1,11 @@
 package cn.lihu.jh.module.ecg;
 
 public interface Constants {
+
+    /**
+     *  閰嶇疆椤�
+    */
+
     static final String ECG_OPENING_TIME_KEY = "ecg.openingtime";
     static final String ECG_ROOM_RESET_TIME_KEY = "ecg.room.reset.time";
     static final String ECG_SCREEN_PANE_WAITING_KEY = "ecg.screen.pane.waiting";
@@ -8,5 +13,11 @@
     static final String DEV_CODE_CHOICE = "dev.code.choice";
 
     static final String BOOK_TIMESLOT_LENGTH = "book.timeslot.length";
-    static final String BOOK_TIMESLOT_LIST = "book.timeslot.list";
+    //static final String BOOK_TIMESLOT_LIST = "book.timeslot.list";
+
+
+    /**
+     *  瀛楀吀椤�
+     */
+    static final String ECG_BOOK_TIMESLOT = "ecg_book_timeslot";
 }
diff --git a/jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/controller/admin/config/ECGConfigController.java b/jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/controller/admin/config/ECGConfigController.java
new file mode 100644
index 0000000..ff33eb5
--- /dev/null
+++ b/jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/controller/admin/config/ECGConfigController.java
@@ -0,0 +1,49 @@
+package cn.lihu.jh.module.ecg.controller.admin.config;
+
+import cn.lihu.jh.framework.common.pojo.CommonResult;
+import cn.lihu.jh.module.ecg.controller.admin.config.vo.TimeslotVO;
+import cn.lihu.jh.module.ecg.controller.admin.queuesequence.vo.QueueSequenceSaveReqVO;
+import cn.lihu.jh.module.ecg.service.config.EcgConfigService;
+import io.swagger.v3.oas.annotations.Operation;
+import io.swagger.v3.oas.annotations.tags.Tag;
+import org.springframework.validation.annotation.Validated;
+import org.springframework.web.bind.annotation.*;
+
+import javax.annotation.Resource;
+import javax.annotation.security.PermitAll;
+import javax.validation.Valid;
+import java.time.LocalTime;
+import java.time.format.DateTimeFormatter;
+import java.util.ArrayList;
+import java.util.List;
+
+import static cn.lihu.jh.framework.common.pojo.CommonResult.success;
+
+@Tag(name = "绠$悊鍚庡彴 - 涓氬姟閰嶇疆")
+@RestController
+@RequestMapping("/ecg/biz-config")
+@Validated
+public class ECGConfigController {
+
+    @Resource
+    private EcgConfigService ecgConfigService;
+
+    @GetMapping("/list-timeslot")
+    @Operation(summary = "棰勭害鏃堕棿娈靛垪琛�")
+    @PermitAll
+    public CommonResult<List<LocalTime>> listTimeslot(@Valid @RequestBody QueueSequenceSaveReqVO createReqVO) {
+
+        List<LocalTime> localTimeList = ecgConfigService.listTimeslot();
+        List<TimeslotVO> timeslotVOList = new ArrayList<>();
+
+        localTimeList.forEach( localTime -> {
+            TimeslotVO timeslotVO = new TimeslotVO();
+            DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("HH:mm");
+            timeslotVO.setLabel( localTime.format(dateTimeFormatter));
+            timeslotVO.setValue( localTime.getHour()*100 + localTime.getMinute() );
+            timeslotVOList.add( timeslotVO );
+        });
+
+        return success(ecgConfigService.listTimeslot());
+    }
+}
diff --git a/jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/controller/admin/config/vo/TimeslotVO.java b/jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/controller/admin/config/vo/TimeslotVO.java
new file mode 100644
index 0000000..ac7d9a7
--- /dev/null
+++ b/jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/controller/admin/config/vo/TimeslotVO.java
@@ -0,0 +1,10 @@
+package cn.lihu.jh.module.ecg.controller.admin.config.vo;
+
+import lombok.Data;
+
+@Data
+public class TimeslotVO {
+    private String label;
+    private Integer value;
+}
+
diff --git a/jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/service/config/EcgConfigService.java b/jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/service/config/EcgConfigService.java
index d5b586d..94e885e 100644
--- a/jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/service/config/EcgConfigService.java
+++ b/jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/service/config/EcgConfigService.java
@@ -1,5 +1,10 @@
 package cn.lihu.jh.module.ecg.service.config;
 
+import java.time.LocalTime;
+import java.util.List;
+
 public interface EcgConfigService {
     void resetScheduler();
+    void readTimeSlotConfig();
+    List<LocalTime> listTimeslot();
 }
diff --git a/jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/service/config/EcgConfigServiceImpl.java b/jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/service/config/EcgConfigServiceImpl.java
index a6d505b..2ed3279 100644
--- a/jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/service/config/EcgConfigServiceImpl.java
+++ b/jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/service/config/EcgConfigServiceImpl.java
@@ -2,6 +2,7 @@
 
 import cn.lihu.jh.module.ecg.Utils;
 import cn.lihu.jh.module.ecg.config.DynamicSchedulingConfig;
+import cn.lihu.jh.module.ecg.dal.dataobject.checktype.CheckTypeDO;
 import cn.lihu.jh.module.ecg.dal.mysql.queuesequence.QueueSequenceMapper;
 import cn.lihu.jh.module.ecg.service.queue.QueueService;
 import cn.lihu.jh.module.ecg.service.queuesequence.QueueSequenceService;
@@ -18,11 +19,7 @@
 import javax.annotation.Resource;
 import java.time.LocalTime;
 import java.util.List;
-import java.util.concurrent.Executors;
-import java.util.concurrent.ScheduledExecutorService;
-
-import static cn.lihu.jh.module.ecg.Constants.ECG_OPENING_TIME_KEY;
-import static cn.lihu.jh.module.ecg.Constants.ECG_ROOM_RESET_TIME_KEY;
+import static cn.lihu.jh.module.ecg.Constants.*;
 
 @Service
 @Validated
@@ -40,6 +37,8 @@
 
     @Resource
     private QueueSequenceService queueSequenceService;
+
+    List<LocalTime> timeslotList = null;
 
     ScheduledTask startBizTask = null;
     ScheduledTask closeBizTask = null;
@@ -83,4 +82,16 @@
         taskRegistrar.afterPropertiesSet();
     }
 
+    @Override
+    public void readTimeSlotConfig() {
+        String strBookTimeslotLength = configApi.getConfigValueByKey(BOOK_TIMESLOT_LENGTH);
+        //String strBookTimeslotList = configApi.getConfigValueByKey(BOOK_TIMESLOT_LIST);
+        //timeslotList = Utils.parseTimeSlotList(strBookTimeslotList, Integer.valueOf(strBookTimeslotLength));
+    }
+
+    @Override
+    public List<LocalTime> listTimeslot() {
+        return  timeslotList;
+    }
+
 }
diff --git a/jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/service/queue/QueueServiceImpl.java b/jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/service/queue/QueueServiceImpl.java
index fb866e2..521e266 100644
--- a/jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/service/queue/QueueServiceImpl.java
+++ b/jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/service/queue/QueueServiceImpl.java
@@ -268,7 +268,6 @@
             queueServiceTxFunctions.resetRoom(needCloseBed);
             queueServiceTxFunctions.bedReload();
             queueServiceTxFunctions.monitorInfo();
-            queueServiceTxFunctions.resetQueueSequenceTable();
         });
     }
 
diff --git a/jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/service/queue/QueueServiceTxFunctions.java b/jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/service/queue/QueueServiceTxFunctions.java
index 1d2cd35..86f8b28 100644
--- a/jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/service/queue/QueueServiceTxFunctions.java
+++ b/jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/service/queue/QueueServiceTxFunctions.java
@@ -459,13 +459,6 @@
         log.info(" opening " + openingFlag.get() + " " + monitorInfoVO.getQueueNum() + " " + monitorInfoVO.getActiveQueueNum() + " " + monitorInfoVO.getCheckTypeBedInfo().toString() );
     }
 
-    public void resetQueueSequenceTable() {
-        String strBookTimeslotLength = configApi.getConfigValueByKey(BOOK_TIMESLOT_LENGTH);
-        String strBookTimeslotList = configApi.getConfigValueByKey(BOOK_TIMESLOT_LIST);
-
-
-    }
-
     private Integer getBedReadyMax(Long roomId, String bedNo) {
         RoomDO roomDO = roomMapper.getRoom(roomId, bedNo);
         Integer[] checkTypes = roomDO.getCheckTypes();
diff --git a/jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/service/queuesequence/QueueSequenceServiceImpl.java b/jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/service/queuesequence/QueueSequenceServiceImpl.java
index 4216715..d99ebbd 100644
--- a/jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/service/queuesequence/QueueSequenceServiceImpl.java
+++ b/jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/service/queuesequence/QueueSequenceServiceImpl.java
@@ -4,6 +4,8 @@
 import cn.lihu.jh.module.ecg.dal.dataobject.checktype.CheckTypeDO;
 import cn.lihu.jh.module.ecg.dal.mysql.checktype.CheckTypeMapper;
 import cn.lihu.jh.module.infra.api.config.ConfigApi;
+import cn.lihu.jh.module.system.api.dict.DictDataApi;
+import cn.lihu.jh.module.system.api.dict.dto.DictDataRespDTO;
 import org.springframework.stereotype.Service;
 import org.springframework.validation.annotation.Validated;
 import org.springframework.transaction.annotation.Transactional;
@@ -35,6 +37,9 @@
 
     @Resource
     private ConfigApi configApi;
+
+    @Resource
+    private DictDataApi dictDataApi;
 
     @Resource
     private QueueSequenceMapper queueSequenceMapper;
@@ -90,17 +95,21 @@
 
         // 璇诲彇鏃舵閰嶇疆
         String strBookTimeslotLength = configApi.getConfigValueByKey(BOOK_TIMESLOT_LENGTH);
-        String strBookTimeslotList = configApi.getConfigValueByKey(BOOK_TIMESLOT_LIST);
+
+        // 鏂规1锛氶厤缃腑鍙�    7:30,8:30,9:30,10:30,11:30,12:30,13:30,14:30,15:30
+        //String strBookTimeslotList = configApi.getConfigValueByKey(BOOK_TIMESLOT_LIST);
+        //List<LocalTime> timeslotList = Utils.parseTimeSlotList(strBookTimeslotList, Integer.valueOf(strBookTimeslotLength));
+
+        List<DictDataRespDTO> dictBookTimeslotList = dictDataApi.getDictDataList(ECG_BOOK_TIMESLOT);
 
         // 璇诲彇鎵�鏈夌殑妫�鏌ョ被鍨�
         List<CheckTypeDO> checkTypeDOList =  checkTypeMapper.simpleCheckTypeList();
         checkTypeDOList.forEach( checkTypeDO -> {
-            List<LocalTime> timeslotList = Utils.parseTimeSlotList(strBookTimeslotList, Integer.valueOf(strBookTimeslotLength));
-            for (int i=0; i < timeslotList.size(); i++) {
-                LocalTime timeslot = timeslotList.get(i);
+
+            for (int i=0; i < dictBookTimeslotList.size(); i++) {
                 QueueSequenceDO queueSequenceDO = new QueueSequenceDO();
                 queueSequenceDO.setCheckType( checkTypeDO.getValue() );
-                queueSequenceDO.setTimeSlot( timeslot.getHour()*100 + timeslot.getMinute() );
+                queueSequenceDO.setTimeSlot( Integer.valueOf(dictBookTimeslotList.get(i).getValue()) );
                 queueSequenceDO.setQueueNo( i * checkTypeDO.getTimeslotBookNum() + checkTypeDO.getTimeslotReservedNum());
                 queueSequenceDO.setQueueVipNo( i * checkTypeDO.getTimeslotBookNum());
                 queueSequenceDO.setQueueFull( i * checkTypeDO.getTimeslotBookNum() + checkTypeDO.getTimeslotBookNum());

--
Gitblit v1.9.3