迁移 台桌信息
This commit is contained in:
parent
b1fa1cc8bc
commit
648b08fd2a
|
|
@ -1,11 +1,13 @@
|
|||
package com.czg.mergedata.cur.entity;
|
||||
|
||||
import com.mybatisflex.annotation.Column;
|
||||
import com.mybatisflex.annotation.Id;
|
||||
import com.mybatisflex.annotation.KeyType;
|
||||
import com.mybatisflex.annotation.Table;
|
||||
import java.io.Serializable;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
|
|
@ -49,8 +51,10 @@ public class CurShopTableArea implements Serializable {
|
|||
*/
|
||||
private String name;
|
||||
|
||||
private Long createdAt;
|
||||
@Column(onInsertValue = "now()")
|
||||
private LocalDateTime createdTime;
|
||||
|
||||
private Long updatedAt;
|
||||
@Column(onInsertValue = "now()", onUpdateValue = "now()")
|
||||
private LocalDateTime updatedTime;
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -28,9 +28,6 @@ import java.util.Map;
|
|||
@Service
|
||||
public class CurShopTableBookingServiceImpl extends ServiceImpl<CurShopTableBookingMapper, CurShopTableBooking> implements CurShopTableBookingService {
|
||||
|
||||
@Resource
|
||||
private CurShopIdRelationService curShopIdRelationService;
|
||||
|
||||
@Resource
|
||||
private OldShopTableBookingService oldShopTableBookingService;
|
||||
|
||||
|
|
@ -39,29 +36,27 @@ public class CurShopTableBookingServiceImpl extends ServiceImpl<CurShopTableBook
|
|||
public CzgResult<String> mergeData() {
|
||||
getMapper().truncateTable();
|
||||
|
||||
Map<Long, Long> oldAndCurShopIdMap = curShopIdRelationService.getOldShopIdRelation();
|
||||
|
||||
execTableBooking(oldAndCurShopIdMap);
|
||||
execTableBooking();
|
||||
|
||||
return CzgResult.success("迁移成功");
|
||||
}
|
||||
|
||||
private void execTableBooking(Map<Long, Long> oldAndCurShopIdMap) {
|
||||
private void execTableBooking() {
|
||||
Page<OldShopTableBooking> page = oldShopTableBookingService.page(PageUtils.buildPage());
|
||||
|
||||
while (!page.getRecords().isEmpty()) {
|
||||
saveTableBooking(page.getRecords(), oldAndCurShopIdMap);
|
||||
saveTableBooking(page.getRecords());
|
||||
page = oldShopTableBookingService.page(PageUtils.buildPage(page.getPageNumber() + 1));
|
||||
}
|
||||
}
|
||||
|
||||
private void saveTableBooking(List<OldShopTableBooking> oldShopTableBookingList, Map<Long, Long> oldAndCurShopIdMap) {
|
||||
private void saveTableBooking(List<OldShopTableBooking> oldShopTableBookingList) {
|
||||
List<CurShopTableBooking> curShopTableBookingList = new ArrayList<>();
|
||||
|
||||
for (OldShopTableBooking oldShopTableBooking : oldShopTableBookingList) {
|
||||
CurShopTableBooking curShopTableBooking = BeanUtil.toBean(oldShopTableBooking, CurShopTableBooking.class);
|
||||
|
||||
curShopTableBooking.setShopId(oldAndCurShopIdMap.get(Long.valueOf(oldShopTableBooking.getShopId())));
|
||||
curShopTableBooking.setShopId(Long.valueOf(oldShopTableBooking.getShopId()));
|
||||
curShopTableBooking.setIsDel(oldShopTableBooking.getDelFlag());
|
||||
|
||||
curShopTableBookingList.add(curShopTableBooking);
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
package com.czg.mergedata.cur.service.impl;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import com.czg.mergedata.common.resp.CzgResult;
|
||||
import com.czg.mergedata.common.utils.PageUtils;
|
||||
import com.czg.mergedata.cur.entity.CurShopTableArea;
|
||||
|
|
@ -20,6 +21,7 @@ import org.springframework.stereotype.Service;
|
|||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
|
|
@ -32,9 +34,6 @@ import java.util.Map;
|
|||
@Service
|
||||
public class CurShopTableServiceImpl extends ServiceImpl<CurShopTableMapper, CurShopTable> implements CurShopTableService {
|
||||
|
||||
@Resource
|
||||
private CurShopIdRelationService curShopIdRelationService;
|
||||
|
||||
@Resource
|
||||
private CurShopTableAreaMapper curShopTableAreaMapper;
|
||||
|
||||
|
|
@ -50,43 +49,44 @@ public class CurShopTableServiceImpl extends ServiceImpl<CurShopTableMapper, Cur
|
|||
curShopTableAreaMapper.truncateTable();
|
||||
getMapper().truncateTable();
|
||||
|
||||
Map<Long, Long> oldAndCurShopIdMap = curShopIdRelationService.getOldShopIdRelation();
|
||||
|
||||
execTableArea(oldAndCurShopIdMap);
|
||||
execTable(oldAndCurShopIdMap);
|
||||
execTableArea();
|
||||
execTable();
|
||||
|
||||
return CzgResult.success("迁移成功");
|
||||
}
|
||||
|
||||
private void execTableArea(Map<Long, Long> oldAndCurShopIdMap) {
|
||||
private void execTableArea() {
|
||||
Page<OldShopArea> page = oldShopAreaService.page(PageUtils.buildPage());
|
||||
|
||||
while (!page.getRecords().isEmpty()) {
|
||||
List<OldShopArea> oldShopAreaList = page.getRecords();
|
||||
saveTableArea(oldShopAreaList, oldAndCurShopIdMap);
|
||||
saveTableArea(oldShopAreaList);
|
||||
|
||||
page = oldShopAreaService.page(PageUtils.buildPage(page.getPageNumber() + 1));
|
||||
}
|
||||
}
|
||||
|
||||
private void execTable(Map<Long, Long> oldAndCurShopIdMap) {
|
||||
private void execTable() {
|
||||
Page<OldShopTable> page = oldShopTableService.page(PageUtils.buildPage());
|
||||
|
||||
while (!page.getRecords().isEmpty()) {
|
||||
List<OldShopTable> oldShopTableList = page.getRecords();
|
||||
saveTable(oldShopTableList, oldAndCurShopIdMap);
|
||||
saveTable(oldShopTableList);
|
||||
page = oldShopTableService.page(PageUtils.buildPage(page.getPageNumber() + 1));
|
||||
}
|
||||
}
|
||||
|
||||
private void saveTableArea(List<OldShopArea> oldShopAreaList, Map<Long, Long> oldAndCurShopIdMap) {
|
||||
private void saveTableArea(List<OldShopArea> oldShopAreaList) {
|
||||
List<CurShopTableArea> curShopTableAreas = new ArrayList<>();
|
||||
|
||||
for (OldShopArea oldShopArea : oldShopAreaList) {
|
||||
CurShopTableArea curShopTableArea = BeanUtil.toBean(oldShopArea, CurShopTableArea.class);
|
||||
|
||||
Long curShopId = oldAndCurShopIdMap.get(Long.valueOf(oldShopArea.getShopId()));
|
||||
curShopTableArea.setShopId(curShopId == null ? 1L : curShopId);
|
||||
curShopTableArea.setId(Long.valueOf(oldShopArea.getId()));
|
||||
curShopTableArea.setShopId(Long.valueOf(oldShopArea.getShopId()));
|
||||
curShopTableArea.setSort(oldShopArea.getSort());
|
||||
curShopTableArea.setName(oldShopArea.getName());
|
||||
curShopTableArea.setCreatedTime(DateUtil.toLocalDateTime(oldShopArea.getCreatedAt() == null? new Date() : new Date(oldShopArea.getCreatedAt())));
|
||||
curShopTableArea.setUpdatedTime(DateUtil.toLocalDateTime(oldShopArea.getUpdatedAt() == null ? new Date() : new Date(oldShopArea.getUpdatedAt())));
|
||||
|
||||
curShopTableAreas.add(curShopTableArea);
|
||||
}
|
||||
|
|
@ -94,15 +94,16 @@ public class CurShopTableServiceImpl extends ServiceImpl<CurShopTableMapper, Cur
|
|||
curShopTableAreaMapper.insertBatch(curShopTableAreas);
|
||||
}
|
||||
|
||||
private void saveTable(List<OldShopTable> oldShopTableList, Map<Long, Long> oldAndCurShopIdMap) {
|
||||
private void saveTable(List<OldShopTable> oldShopTableList) {
|
||||
List<CurShopTable> curShopTables = new ArrayList<>();
|
||||
|
||||
for (OldShopTable oldShopTable : oldShopTableList) {
|
||||
CurShopTable curShopTable = BeanUtil.toBean(oldShopTable, CurShopTable.class);
|
||||
|
||||
Long curShopId = oldAndCurShopIdMap.get(Long.valueOf(oldShopTable.getShopId()));
|
||||
curShopTable.setShopId(curShopId == null ? 1L : curShopId);
|
||||
curShopTable.setShopId(Long.valueOf(oldShopTable.getShopId()));
|
||||
curShopTable.setTableCode(oldShopTable.getQrcode());
|
||||
curShopTable.setCreateTime(DateUtil.toLocalDateTime(oldShopTable.getCreatedAt() == null ? new Date() : new Date(oldShopTable.getCreatedAt())));
|
||||
curShopTable.setUpdateTime(DateUtil.toLocalDateTime(oldShopTable.getUpdatedAt() == null ? new Date() : new Date(oldShopTable.getUpdatedAt())));
|
||||
|
||||
curShopTables.add(curShopTable);
|
||||
}
|
||||
|
|
|
|||
12
收银机数据迁移关系.md
12
收银机数据迁移关系.md
|
|
@ -62,5 +62,17 @@
|
|||
- tb_coupon_category 表
|
||||
- tb_group_order_coupon 表
|
||||
|
||||
### 7. 台桌管理
|
||||
> /merge/table/mergeData
|
||||
#### 执行表
|
||||
- tb_shop_table_area 表
|
||||
- tb_shop_table 表
|
||||
|
||||
### 8. 台桌预定
|
||||
> /merge/table/booking
|
||||
#### 执行表
|
||||
- tb_shop_table_booking 表
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue