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