From 02cb4a13b2f7bba15a5eca9353a2e458efe2c602 Mon Sep 17 00:00:00 2001
From: eight <641137800@qq.com>
Date: 星期四, 07 十一月 2024 11:33:50 +0800
Subject: [PATCH] 排队序号表的初始化

---
 jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/service/queuesequence/QueueSequenceServiceImpl.java |   41 ++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 40 insertions(+), 1 deletions(-)

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 0c6fffb..4216715 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
@@ -1,9 +1,14 @@
 package cn.lihu.jh.module.ecg.service.queuesequence;
 
+import cn.lihu.jh.module.ecg.Utils;
+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 org.springframework.stereotype.Service;
 import org.springframework.validation.annotation.Validated;
 import org.springframework.transaction.annotation.Transactional;
 
+import java.time.LocalTime;
 import java.util.*;
 import cn.lihu.jh.module.ecg.controller.admin.queuesequence.vo.*;
 import cn.lihu.jh.module.ecg.dal.dataobject.queuesequence.QueueSequenceDO;
@@ -16,6 +21,7 @@
 import javax.annotation.Resource;
 
 import static cn.lihu.jh.framework.common.exception.util.ServiceExceptionUtil.exception;
+import static cn.lihu.jh.module.ecg.Constants.*;
 import static cn.lihu.jh.module.ecg.enums.ErrorCodeConstants.*;
 
 /**
@@ -28,7 +34,13 @@
 public class QueueSequenceServiceImpl implements QueueSequenceService {
 
     @Resource
+    private ConfigApi configApi;
+
+    @Resource
     private QueueSequenceMapper queueSequenceMapper;
+
+    @Resource
+    private CheckTypeMapper checkTypeMapper;
 
     @Override
     public Integer createQueueSequence(QueueSequenceSaveReqVO createReqVO) {
@@ -72,4 +84,31 @@
         return queueSequenceMapper.selectPage(pageReqVO);
     }
 
-}
\ No newline at end of file
+    @Override
+    public void resetQueueSequence() {
+        queueSequenceMapper.clearQueueSequenceTable();
+
+        // 璇诲彇鏃舵閰嶇疆
+        String strBookTimeslotLength = configApi.getConfigValueByKey(BOOK_TIMESLOT_LENGTH);
+        String strBookTimeslotList = configApi.getConfigValueByKey(BOOK_TIMESLOT_LIST);
+
+        // 璇诲彇鎵�鏈夌殑妫�鏌ョ被鍨�
+        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);
+                QueueSequenceDO queueSequenceDO = new QueueSequenceDO();
+                queueSequenceDO.setCheckType( checkTypeDO.getValue() );
+                queueSequenceDO.setTimeSlot( timeslot.getHour()*100 + timeslot.getMinute() );
+                queueSequenceDO.setQueueNo( i * checkTypeDO.getTimeslotBookNum() + checkTypeDO.getTimeslotReservedNum());
+                queueSequenceDO.setQueueVipNo( i * checkTypeDO.getTimeslotBookNum());
+                queueSequenceDO.setQueueFull( i * checkTypeDO.getTimeslotBookNum() + checkTypeDO.getTimeslotBookNum());
+                queueSequenceDO.setQueueVipFull( i * checkTypeDO.getTimeslotBookNum() + checkTypeDO.getTimeslotReservedNum());
+                queueSequenceMapper.insert( queueSequenceDO );
+            };
+        });
+    }
+
+}
+

--
Gitblit v1.9.3