迁移 台桌预定
This commit is contained in:
parent
f402792bef
commit
aaf2dc361d
|
|
@ -18,8 +18,8 @@ public class CodeGen {
|
|||
private final static String DATABASE = "czg_cashier";
|
||||
private final static String OLD_DATABASE = "fycashier_test";
|
||||
|
||||
private final static boolean isOldVersion = false;
|
||||
// private final static boolean isOldVersion = true;
|
||||
// private final static boolean isOldVersion = false;
|
||||
private final static boolean isOldVersion = true;
|
||||
|
||||
public static void main(String[] args) {
|
||||
//配置数据源
|
||||
|
|
@ -81,7 +81,7 @@ public class CodeGen {
|
|||
//设置表前缀和只生成哪些表,setGenerateTable 未配置时,生成所有表
|
||||
globalConfig.getStrategyConfig()
|
||||
.setTablePrefix("tb_")
|
||||
.setGenerateTable("tb_member_points_log");
|
||||
.setGenerateTable("tb_shop_table_booking");
|
||||
|
||||
EntityConfig entityConfig = globalConfig.getEntityConfig();
|
||||
if (isOldVersion) {
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
package com.czg.mergedata.controller;
|
||||
|
||||
import com.czg.mergedata.common.resp.CzgResult;
|
||||
import com.czg.mergedata.cur.service.CurShopTableBookingService;
|
||||
import com.czg.mergedata.cur.service.CurShopTableService;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
|
|
@ -16,8 +17,16 @@ public class TableController {
|
|||
@Resource
|
||||
private CurShopTableService curShopTableService;
|
||||
|
||||
@Resource
|
||||
private CurShopTableBookingService curShopTableBookingService;
|
||||
|
||||
@GetMapping("/mergeData")
|
||||
public CzgResult<String> mergeData() {
|
||||
return curShopTableService.mergeData();
|
||||
}
|
||||
|
||||
@GetMapping("/booking")
|
||||
public CzgResult<String> booking() {
|
||||
return curShopTableBookingService.mergeData();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,164 @@
|
|||
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.math.BigDecimal;
|
||||
import java.sql.Date;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
import java.io.Serial;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
* 店铺台桌预订 实体类。
|
||||
*
|
||||
* @author mac
|
||||
* @since 2025-02-19
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Table("tb_shop_table_booking")
|
||||
public class CurShopTableBooking implements Serializable {
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* id
|
||||
*/
|
||||
@Id(keyType = KeyType.Auto)
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 店铺桌台id
|
||||
*/
|
||||
private Long shopTableId;
|
||||
|
||||
/**
|
||||
* 店铺id
|
||||
*/
|
||||
private Long shopId;
|
||||
|
||||
/**
|
||||
* 订单编号
|
||||
*/
|
||||
private String orderNo;
|
||||
|
||||
/**
|
||||
* 预约日期
|
||||
*/
|
||||
private Date bookingDate;
|
||||
|
||||
/**
|
||||
* 预约类型 lunch-午餐 dinner-晚餐
|
||||
*/
|
||||
private String bookingType;
|
||||
|
||||
/**
|
||||
* 用餐人数
|
||||
*/
|
||||
private Integer dinerNum;
|
||||
|
||||
/**
|
||||
* 电话号码
|
||||
*/
|
||||
private String phoneNumber;
|
||||
|
||||
/**
|
||||
* 订餐人
|
||||
*/
|
||||
private String bookingPerson;
|
||||
|
||||
/**
|
||||
* 性别/称呼 1-先生 2-女士
|
||||
*/
|
||||
private Integer gender;
|
||||
|
||||
/**
|
||||
* 预约时间
|
||||
*/
|
||||
private LocalDateTime bookingTime;
|
||||
|
||||
/**
|
||||
* 用餐类型 普通用餐/宴会套餐/自助餐/...,由前端定义或者输入文本
|
||||
*/
|
||||
private String diningType;
|
||||
|
||||
/**
|
||||
* 重点关注 1-是 0-否
|
||||
*/
|
||||
private Integer focus;
|
||||
|
||||
/**
|
||||
* 接收营销短信 1-是 0-否
|
||||
*/
|
||||
private Integer receiveMarketingSms;
|
||||
|
||||
/**
|
||||
* 摆台桌数
|
||||
*/
|
||||
private Integer bookingTableNum;
|
||||
|
||||
/**
|
||||
* 餐标(单价)
|
||||
*/
|
||||
private BigDecimal diningStandardPrice;
|
||||
|
||||
/**
|
||||
* 餐标(单位) table-元/桌 person-元/人
|
||||
*/
|
||||
private String diningStandardUnit;
|
||||
|
||||
/**
|
||||
* 预订状态 -1-已取消 10-已到店 20-待到店 999-已超时
|
||||
注:此处定义为数字是为了方便按状态排序
|
||||
*/
|
||||
private String status;
|
||||
|
||||
/**
|
||||
* 留座时间
|
||||
*/
|
||||
private Integer timeoutMinute;
|
||||
|
||||
/**
|
||||
* 操作时间
|
||||
*/
|
||||
@Column(onInsertValue = "now()")
|
||||
private LocalDateTime createTime;
|
||||
|
||||
/**
|
||||
* 操作人
|
||||
*/
|
||||
private String createUserName;
|
||||
|
||||
/**
|
||||
* 到店时间
|
||||
*/
|
||||
private LocalDateTime arrivedTime;
|
||||
|
||||
/**
|
||||
* 更新时间
|
||||
*/
|
||||
@Column(onInsertValue = "now()", onUpdateValue = "now()")
|
||||
private LocalDateTime updateTime;
|
||||
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
private String remark;
|
||||
|
||||
/**
|
||||
* 删除标志 1-是 0-否
|
||||
*/
|
||||
private Integer isDel;
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,18 @@
|
|||
package com.czg.mergedata.cur.mapper;
|
||||
|
||||
import com.mybatisflex.annotation.UseDataSource;
|
||||
import com.mybatisflex.core.BaseMapper;
|
||||
import com.czg.mergedata.cur.entity.CurShopTableBooking;
|
||||
import org.apache.ibatis.annotations.Select;
|
||||
|
||||
/**
|
||||
* 店铺台桌预订 映射层。
|
||||
*
|
||||
* @author mac
|
||||
* @since 2025-02-19
|
||||
*/
|
||||
@UseDataSource("ds1")
|
||||
public interface CurShopTableBookingMapper extends BaseMapper<CurShopTableBooking> {
|
||||
@Select("truncate tb_shop_table_booking")
|
||||
void truncateTable();
|
||||
}
|
||||
|
|
@ -0,0 +1,17 @@
|
|||
package com.czg.mergedata.cur.service;
|
||||
|
||||
import com.czg.mergedata.common.resp.CzgResult;
|
||||
import com.mybatisflex.core.service.IService;
|
||||
import com.czg.mergedata.cur.entity.CurShopTableBooking;
|
||||
|
||||
/**
|
||||
* 店铺台桌预订 服务层。
|
||||
*
|
||||
* @author mac
|
||||
* @since 2025-02-19
|
||||
*/
|
||||
public interface CurShopTableBookingService extends IService<CurShopTableBooking> {
|
||||
|
||||
CzgResult<String> mergeData();
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,72 @@
|
|||
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.service.CurShopIdRelationService;
|
||||
import com.czg.mergedata.old.entity.OldShopTableBooking;
|
||||
import com.czg.mergedata.old.service.OldShopTableBookingService;
|
||||
import com.mybatisflex.core.paginate.Page;
|
||||
import com.mybatisflex.spring.service.impl.ServiceImpl;
|
||||
import com.czg.mergedata.cur.entity.CurShopTableBooking;
|
||||
import com.czg.mergedata.cur.mapper.CurShopTableBookingMapper;
|
||||
import com.czg.mergedata.cur.service.CurShopTableBookingService;
|
||||
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;
|
||||
|
||||
/**
|
||||
* 店铺台桌预订 服务层实现。
|
||||
*
|
||||
* @author mac
|
||||
* @since 2025-02-19
|
||||
*/
|
||||
@Service
|
||||
public class CurShopTableBookingServiceImpl extends ServiceImpl<CurShopTableBookingMapper, CurShopTableBooking> implements CurShopTableBookingService {
|
||||
|
||||
@Resource
|
||||
private CurShopIdRelationService curShopIdRelationService;
|
||||
|
||||
@Resource
|
||||
private OldShopTableBookingService oldShopTableBookingService;
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public CzgResult<String> mergeData() {
|
||||
getMapper().truncateTable();
|
||||
|
||||
Map<Long, Long> oldAndCurShopIdMap = curShopIdRelationService.getOldShopIdRelation();
|
||||
|
||||
execTableBooking(oldAndCurShopIdMap);
|
||||
|
||||
return CzgResult.success("迁移成功");
|
||||
}
|
||||
|
||||
private void execTableBooking(Map<Long, Long> oldAndCurShopIdMap) {
|
||||
Page<OldShopTableBooking> page = oldShopTableBookingService.page(PageUtils.buildPage());
|
||||
|
||||
while (!page.getRecords().isEmpty()) {
|
||||
saveTableBooking(page.getRecords(), oldAndCurShopIdMap);
|
||||
page = oldShopTableBookingService.page(PageUtils.buildPage(page.getPageNumber() + 1));
|
||||
}
|
||||
}
|
||||
|
||||
private void saveTableBooking(List<OldShopTableBooking> oldShopTableBookingList, Map<Long, Long> oldAndCurShopIdMap) {
|
||||
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.setIsDel(oldShopTableBooking.getDelFlag());
|
||||
|
||||
curShopTableBookingList.add(curShopTableBooking);
|
||||
}
|
||||
|
||||
saveBatch(curShopTableBookingList);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,164 @@
|
|||
package com.czg.mergedata.old.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.math.BigDecimal;
|
||||
import java.sql.Date;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
import java.io.Serial;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
* 店铺台桌预订 实体类。
|
||||
*
|
||||
* @author mac
|
||||
* @since 2025-02-19
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Table("tb_shop_table_booking")
|
||||
public class OldShopTableBooking implements Serializable {
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* id
|
||||
*/
|
||||
@Id(keyType = KeyType.Auto)
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 店铺桌台id
|
||||
*/
|
||||
private Integer shopTableId;
|
||||
|
||||
/**
|
||||
* 店铺id
|
||||
*/
|
||||
private Integer shopId;
|
||||
|
||||
/**
|
||||
* 订单编号
|
||||
*/
|
||||
private String orderNo;
|
||||
|
||||
/**
|
||||
* 预约日期
|
||||
*/
|
||||
private Date bookingDate;
|
||||
|
||||
/**
|
||||
* 预约类型 lunch-午餐 dinner-晚餐
|
||||
*/
|
||||
private String bookingType;
|
||||
|
||||
/**
|
||||
* 用餐人数
|
||||
*/
|
||||
private Integer dinerNum;
|
||||
|
||||
/**
|
||||
* 电话号码
|
||||
*/
|
||||
private String phoneNumber;
|
||||
|
||||
/**
|
||||
* 订餐人
|
||||
*/
|
||||
private String bookingPerson;
|
||||
|
||||
/**
|
||||
* 性别/称呼 1-先生 2-女士
|
||||
*/
|
||||
private Integer gender;
|
||||
|
||||
/**
|
||||
* 预约时间
|
||||
*/
|
||||
private LocalDateTime bookingTime;
|
||||
|
||||
/**
|
||||
* 用餐类型 普通用餐/宴会套餐/自助餐/...,由前端定义或者输入文本
|
||||
*/
|
||||
private String diningType;
|
||||
|
||||
/**
|
||||
* 重点关注 1-是 0-否
|
||||
*/
|
||||
private Integer focus;
|
||||
|
||||
/**
|
||||
* 接收营销短信 1-是 0-否
|
||||
*/
|
||||
private Integer receiveMarketingSms;
|
||||
|
||||
/**
|
||||
* 摆台桌数
|
||||
*/
|
||||
private Integer bookingTableNum;
|
||||
|
||||
/**
|
||||
* 餐标(单价)
|
||||
*/
|
||||
private BigDecimal diningStandardPrice;
|
||||
|
||||
/**
|
||||
* 餐标(单位) table-元/桌 person-元/人
|
||||
*/
|
||||
private String diningStandardUnit;
|
||||
|
||||
/**
|
||||
* 预订状态 -1-已取消 10-已到店 20-待到店 999-已超时
|
||||
注:此处定义为数字是为了方便按状态排序
|
||||
*/
|
||||
private String status;
|
||||
|
||||
/**
|
||||
* 留座时间
|
||||
*/
|
||||
private Integer timeoutMinute;
|
||||
|
||||
/**
|
||||
* 操作时间
|
||||
*/
|
||||
@Column(onInsertValue = "now()")
|
||||
private LocalDateTime createTime;
|
||||
|
||||
/**
|
||||
* 操作人
|
||||
*/
|
||||
private String createUserName;
|
||||
|
||||
/**
|
||||
* 到店时间
|
||||
*/
|
||||
private LocalDateTime arrivedTime;
|
||||
|
||||
/**
|
||||
* 更新时间
|
||||
*/
|
||||
@Column(onInsertValue = "now()", onUpdateValue = "now()")
|
||||
private LocalDateTime updateTime;
|
||||
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
private String remark;
|
||||
|
||||
/**
|
||||
* 删除标志 1-是 0-否
|
||||
*/
|
||||
private Integer delFlag;
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,16 @@
|
|||
package com.czg.mergedata.old.mapper;
|
||||
|
||||
import com.mybatisflex.annotation.UseDataSource;
|
||||
import com.mybatisflex.core.BaseMapper;
|
||||
import com.czg.mergedata.old.entity.OldShopTableBooking;
|
||||
|
||||
/**
|
||||
* 店铺台桌预订 映射层。
|
||||
*
|
||||
* @author mac
|
||||
* @since 2025-02-19
|
||||
*/
|
||||
@UseDataSource("ds2")
|
||||
public interface OldShopTableBookingMapper extends BaseMapper<OldShopTableBooking> {
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,14 @@
|
|||
package com.czg.mergedata.old.service;
|
||||
|
||||
import com.mybatisflex.core.service.IService;
|
||||
import com.czg.mergedata.old.entity.OldShopTableBooking;
|
||||
|
||||
/**
|
||||
* 店铺台桌预订 服务层。
|
||||
*
|
||||
* @author mac
|
||||
* @since 2025-02-19
|
||||
*/
|
||||
public interface OldShopTableBookingService extends IService<OldShopTableBooking> {
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,18 @@
|
|||
package com.czg.mergedata.old.service.impl;
|
||||
|
||||
import com.mybatisflex.spring.service.impl.ServiceImpl;
|
||||
import com.czg.mergedata.old.entity.OldShopTableBooking;
|
||||
import com.czg.mergedata.old.mapper.OldShopTableBookingMapper;
|
||||
import com.czg.mergedata.old.service.OldShopTableBookingService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* 店铺台桌预订 服务层实现。
|
||||
*
|
||||
* @author mac
|
||||
* @since 2025-02-19
|
||||
*/
|
||||
@Service
|
||||
public class OldShopTableBookingServiceImpl extends ServiceImpl<OldShopTableBookingMapper, OldShopTableBooking> implements OldShopTableBookingService{
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper
|
||||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.czg.mergedata.cur.mapper.CurShopTableBookingMapper">
|
||||
|
||||
</mapper>
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper
|
||||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.czg.mergedata.old.mapper.OldShopTableBookingMapper">
|
||||
|
||||
</mapper>
|
||||
Loading…
Reference in New Issue