迁移 叫号功能

This commit is contained in:
GYJ 2025-03-13 11:25:04 +08:00
parent 648b08fd2a
commit 6a0fb8000e
2 changed files with 25 additions and 25 deletions

View File

@ -3,11 +3,13 @@ package com.czg.mergedata.cur.service.impl;
import cn.hutool.core.bean.BeanUtil;
import com.czg.mergedata.common.resp.CzgResult;
import com.czg.mergedata.common.utils.PageUtils;
import com.czg.mergedata.cur.entity.CurCallConfig;
import com.czg.mergedata.cur.entity.CurCallQueue;
import com.czg.mergedata.cur.entity.CurCallTable;
import com.czg.mergedata.cur.mapper.CurCallConfigMapper;
import com.czg.mergedata.cur.mapper.CurCallQueueMapper;
import com.czg.mergedata.cur.mapper.CurCallTableMapper;
import com.czg.mergedata.cur.service.CurShopIdRelationService;
import com.czg.mergedata.cur.service.CurCallConfigService;
import com.czg.mergedata.old.entity.OldCallConfig;
import com.czg.mergedata.old.entity.OldCallQueue;
import com.czg.mergedata.old.entity.OldCallTable;
@ -16,16 +18,12 @@ import com.czg.mergedata.old.service.OldCallQueueService;
import com.czg.mergedata.old.service.OldCallTableService;
import com.mybatisflex.core.paginate.Page;
import com.mybatisflex.spring.service.impl.ServiceImpl;
import com.czg.mergedata.cur.entity.CurCallConfig;
import com.czg.mergedata.cur.mapper.CurCallConfigMapper;
import com.czg.mergedata.cur.service.CurCallConfigService;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
/**
* 叫号配置表 服务层实现
@ -36,9 +34,6 @@ import java.util.Map;
@Service
public class CurCallConfigServiceImpl extends ServiceImpl<CurCallConfigMapper, CurCallConfig> implements CurCallConfigService {
@Resource
private CurShopIdRelationService curShopIdRelationService;
@Resource
private CurCallQueueMapper curCallQueueMapper;
@ -61,72 +56,70 @@ public class CurCallConfigServiceImpl extends ServiceImpl<CurCallConfigMapper, C
curCallQueueMapper.truncateTable();
curCallTableMapper.truncateTable();
Map<Long, Long> oldAndCurShopIdMap = curShopIdRelationService.getOldShopIdRelation();
execCallConfig(oldAndCurShopIdMap);
execCallQueue(oldAndCurShopIdMap);
execCallTable(oldAndCurShopIdMap);
execCallConfig();
execCallQueue();
execCallTable();
return CzgResult.success("迁移成功");
}
private void execCallConfig(Map<Long, Long> oldAndCurShopIdMap) {
private void execCallConfig() {
Page<OldCallConfig> page = oldCallConfigService.page(PageUtils.buildPage());
while (!page.getRecords().isEmpty()) {
saveCallConfig(page.getRecords(), oldAndCurShopIdMap);
saveCallConfig(page.getRecords());
page = oldCallConfigService.page(PageUtils.buildPage(page.getPageNumber() + 1));
}
}
private void execCallQueue(Map<Long, Long> oldAndCurShopIdMap) {
private void execCallQueue() {
Page<OldCallQueue> page = oldCallQueueService.page(PageUtils.buildPage());
while (!page.getRecords().isEmpty()) {
saveCallQueue(page.getRecords(), oldAndCurShopIdMap);
saveCallQueue(page.getRecords());
page = oldCallQueueService.page(PageUtils.buildPage(page.getPageNumber() + 1));
}
}
private void execCallTable(Map<Long, Long> oldAndCurShopIdMap) {
private void execCallTable() {
Page<OldCallTable> page = oldCallTableService.page(PageUtils.buildPage());
while (!page.getRecords().isEmpty()) {
saveCallTable(page.getRecords(), oldAndCurShopIdMap);
saveCallTable(page.getRecords());
page = oldCallTableService.page(PageUtils.buildPage(page.getPageNumber() + 1));
}
}
private void saveCallConfig(List<OldCallConfig> oldCallConfigList, Map<Long, Long> oldAndCurShopIdMap) {
private void saveCallConfig(List<OldCallConfig> oldCallConfigList) {
List<CurCallConfig> curCallConfigList = new ArrayList<>();
for (OldCallConfig oldCallConfig : oldCallConfigList) {
CurCallConfig curCallConfig = BeanUtil.toBean(oldCallConfig, CurCallConfig.class);
curCallConfig.setShopId(oldAndCurShopIdMap.get(Long.valueOf(oldCallConfig.getShopId())));
curCallConfig.setShopId(Long.valueOf(oldCallConfig.getShopId()));
curCallConfigList.add(curCallConfig);
}
saveBatch(curCallConfigList);
}
private void saveCallQueue(List<OldCallQueue> oldCallQueueList, Map<Long, Long> oldAndCurShopIdMap) {
private void saveCallQueue(List<OldCallQueue> oldCallQueueList) {
List<CurCallQueue> curCallQueueList = new ArrayList<>();
for (OldCallQueue oldCallQueue : oldCallQueueList) {
CurCallQueue curCallQueue = BeanUtil.toBean(oldCallQueue, CurCallQueue.class);
curCallQueue.setShopId(oldAndCurShopIdMap.get(Long.valueOf(oldCallQueue.getShopId())));
curCallQueue.setShopId(Long.valueOf(oldCallQueue.getShopId()));
curCallQueueList.add(curCallQueue);
}
curCallQueueMapper.insertBatch(curCallQueueList);
}
private void saveCallTable(List<OldCallTable> oldCallTableList, Map<Long, Long> oldAndCurShopIdMap) {
private void saveCallTable(List<OldCallTable> oldCallTableList) {
List<CurCallTable> curCallTableList = new ArrayList<>();
for (OldCallTable oldCallTable : oldCallTableList) {
CurCallTable curCallTable = BeanUtil.toBean(oldCallTable, CurCallTable.class);
curCallTable.setShopId(oldAndCurShopIdMap.get(Long.valueOf(oldCallTable.getShopId())));
curCallTable.setShopId(Long.valueOf(oldCallTable.getShopId()));
curCallTableList.add(curCallTable);
}

View File

@ -73,6 +73,13 @@
#### 执行表
- tb_shop_table_booking 表
### 9. 叫号功能
> /merge/call/mergeData
#### 执行表
- tb_call_config 表
- tb_call_queue 表
- tb_call_table 表