迁移 用户-店铺-员工
This commit is contained in:
parent
8ec863238e
commit
ba4573eee0
|
|
@ -11,15 +11,15 @@ import com.zaxxer.hikari.HikariDataSource;
|
|||
* @author GYJoker
|
||||
*/
|
||||
public class CodeGen {
|
||||
private final static String BASE_URL = "rm-bp1kn7h89nz62cno1ro.mysql.rds.aliyuncs.com";
|
||||
private final static String BASE_URL = "rm-bp1b572nblln4jho2po.mysql.rds.aliyuncs.com";
|
||||
private final static String PORT = "3306";
|
||||
private final static String USERNAME = "cashier";
|
||||
private final static String PASSWORD = "Cashier@1@";
|
||||
private final static String DATABASE = "czg_cashier";
|
||||
private final static String OLD_DATABASE = "fycashier_test";
|
||||
private final static String USERNAME = "root";
|
||||
private final static String PASSWORD = "Czg666888";
|
||||
private final static String DATABASE = "czg_cashier_test";
|
||||
private final static String OLD_DATABASE = "fycashier";
|
||||
|
||||
// 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_shop_user_flow", "tb_order_payment");
|
||||
.setGenerateTable("staff_id_relation");
|
||||
|
||||
EntityConfig entityConfig = globalConfig.getEntityConfig();
|
||||
if (isOldVersion) {
|
||||
|
|
|
|||
|
|
@ -0,0 +1,36 @@
|
|||
package com.czg.mergedata.cur.entity;
|
||||
|
||||
import com.mybatisflex.annotation.Id;
|
||||
import com.mybatisflex.annotation.Table;
|
||||
import java.io.Serializable;
|
||||
|
||||
import java.io.Serial;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
* 新老员工 id 对应关系 实体类。
|
||||
*
|
||||
* @author mac
|
||||
* @since 2025-03-12
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Table("staff_id_relation")
|
||||
public class CurStaffIdRelation implements Serializable {
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Id
|
||||
private Long oldStaffId;
|
||||
|
||||
@Id
|
||||
private Long curStaffId;
|
||||
|
||||
}
|
||||
|
|
@ -79,7 +79,7 @@ public class CurSysUser implements Serializable {
|
|||
/**
|
||||
* 状态:1启用、0禁用
|
||||
*/
|
||||
private Integer stauts;
|
||||
private Integer status;
|
||||
|
||||
/**
|
||||
* 创建者
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ package com.czg.mergedata.cur.mapper;
|
|||
import com.mybatisflex.annotation.UseDataSource;
|
||||
import com.mybatisflex.core.BaseMapper;
|
||||
import com.czg.mergedata.cur.entity.CurShopIdRelation;
|
||||
import org.apache.ibatis.annotations.Select;
|
||||
|
||||
/**
|
||||
* 映射层。
|
||||
|
|
@ -12,5 +13,6 @@ import com.czg.mergedata.cur.entity.CurShopIdRelation;
|
|||
*/
|
||||
@UseDataSource("ds1")
|
||||
public interface CurShopIdRelationMapper extends BaseMapper<CurShopIdRelation> {
|
||||
|
||||
@Select("truncate shop_id_relation")
|
||||
void truncateTable();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ package com.czg.mergedata.cur.mapper;
|
|||
import com.mybatisflex.annotation.UseDataSource;
|
||||
import com.mybatisflex.core.BaseMapper;
|
||||
import com.czg.mergedata.cur.entity.CurShopInfo;
|
||||
import org.apache.ibatis.annotations.Select;
|
||||
|
||||
/**
|
||||
* 店铺信息 映射层。
|
||||
|
|
@ -12,5 +13,6 @@ import com.czg.mergedata.cur.entity.CurShopInfo;
|
|||
*/
|
||||
@UseDataSource("ds1")
|
||||
public interface CurShopInfoMapper extends BaseMapper<CurShopInfo> {
|
||||
|
||||
@Select("truncate tb_shop_info")
|
||||
void truncateTable();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ package com.czg.mergedata.cur.mapper;
|
|||
import com.mybatisflex.annotation.UseDataSource;
|
||||
import com.mybatisflex.core.BaseMapper;
|
||||
import com.czg.mergedata.cur.entity.CurShopStaff;
|
||||
import org.apache.ibatis.annotations.Select;
|
||||
|
||||
/**
|
||||
* 店铺员工 映射层。
|
||||
|
|
@ -12,5 +13,6 @@ import com.czg.mergedata.cur.entity.CurShopStaff;
|
|||
*/
|
||||
@UseDataSource("ds1")
|
||||
public interface CurShopStaffMapper extends BaseMapper<CurShopStaff> {
|
||||
|
||||
@Select("truncate tb_shop_staff")
|
||||
void truncateTable();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,17 @@
|
|||
package com.czg.mergedata.cur.mapper;
|
||||
|
||||
import com.mybatisflex.core.BaseMapper;
|
||||
import com.czg.mergedata.cur.entity.CurStaffIdRelation;
|
||||
import org.apache.ibatis.annotations.Select;
|
||||
|
||||
/**
|
||||
* 新老员工 id 对应关系 映射层。
|
||||
*
|
||||
* @author mac
|
||||
* @since 2025-03-12
|
||||
*/
|
||||
public interface CurStaffIdRelationMapper extends BaseMapper<CurStaffIdRelation> {
|
||||
|
||||
@Select("truncate staff_id_relation")
|
||||
void truncateTable();
|
||||
}
|
||||
|
|
@ -14,6 +14,6 @@ import org.apache.ibatis.annotations.Select;
|
|||
@UseDataSource("ds1")
|
||||
public interface CurSysUserMapper extends BaseMapper<CurSysUser> {
|
||||
|
||||
@Select("truncate sys_user ")
|
||||
@Select("truncate sys_user")
|
||||
void truncateTable();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,14 @@
|
|||
package com.czg.mergedata.cur.service;
|
||||
|
||||
import com.mybatisflex.core.service.IService;
|
||||
import com.czg.mergedata.cur.entity.CurStaffIdRelation;
|
||||
|
||||
/**
|
||||
* 新老员工 id 对应关系 服务层。
|
||||
*
|
||||
* @author mac
|
||||
* @since 2025-03-12
|
||||
*/
|
||||
public interface CurStaffIdRelationService extends IService<CurStaffIdRelation> {
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,18 @@
|
|||
package com.czg.mergedata.cur.service.impl;
|
||||
|
||||
import com.mybatisflex.spring.service.impl.ServiceImpl;
|
||||
import com.czg.mergedata.cur.entity.CurStaffIdRelation;
|
||||
import com.czg.mergedata.cur.mapper.CurStaffIdRelationMapper;
|
||||
import com.czg.mergedata.cur.service.CurStaffIdRelationService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* 新老员工 id 对应关系 服务层实现。
|
||||
*
|
||||
* @author mac
|
||||
* @since 2025-03-12
|
||||
*/
|
||||
@Service
|
||||
public class CurStaffIdRelationServiceImpl extends ServiceImpl<CurStaffIdRelationMapper, CurStaffIdRelation> implements CurStaffIdRelationService{
|
||||
|
||||
}
|
||||
|
|
@ -4,11 +4,8 @@ import cn.hutool.core.date.DateUtil;
|
|||
import cn.hutool.crypto.SecureUtil;
|
||||
import com.czg.mergedata.common.resp.CzgResult;
|
||||
import com.czg.mergedata.common.utils.PageUtils;
|
||||
import com.czg.mergedata.cur.entity.CurShopIdRelation;
|
||||
import com.czg.mergedata.cur.entity.CurShopInfo;
|
||||
import com.czg.mergedata.cur.entity.CurShopStaff;
|
||||
import com.czg.mergedata.cur.entity.CurSysUser;
|
||||
import com.czg.mergedata.cur.mapper.CurSysUserMapper;
|
||||
import com.czg.mergedata.cur.entity.*;
|
||||
import com.czg.mergedata.cur.mapper.*;
|
||||
import com.czg.mergedata.cur.service.CurShopIdRelationService;
|
||||
import com.czg.mergedata.cur.service.CurShopInfoService;
|
||||
import com.czg.mergedata.cur.service.CurShopStaffService;
|
||||
|
|
@ -49,6 +46,18 @@ public class CurSysUserServiceImpl extends ServiceImpl<CurSysUserMapper, CurSysU
|
|||
@Resource
|
||||
private CurShopInfoService curShopInfoService;
|
||||
|
||||
@Resource
|
||||
private CurShopInfoMapper curShopInfoMapper;
|
||||
|
||||
@Resource
|
||||
private CurShopStaffMapper curShopStaffMapper;
|
||||
|
||||
@Resource
|
||||
private CurShopIdRelationMapper curShopIdRelationMapper;
|
||||
|
||||
@Resource
|
||||
private CurStaffIdRelationMapper curStaffIdRelationMapper;
|
||||
|
||||
@Resource
|
||||
private OldMerchantAccountService oldMerchantAccountService;
|
||||
|
||||
|
|
@ -64,6 +73,13 @@ public class CurSysUserServiceImpl extends ServiceImpl<CurSysUserMapper, CurSysU
|
|||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public CzgResult<String> mergeShopInfo() {
|
||||
// 清空之前的数据
|
||||
getMapper().truncateTable();
|
||||
curShopInfoMapper.truncateTable();
|
||||
curShopStaffMapper.truncateTable();
|
||||
curShopIdRelationMapper.truncateTable();
|
||||
curStaffIdRelationMapper.truncateTable();
|
||||
|
||||
// 账号和店铺id映射
|
||||
Map<String, Long> orginAccountAndShopIdMap = new HashMap<>();
|
||||
|
||||
|
|
@ -71,137 +87,45 @@ public class CurSysUserServiceImpl extends ServiceImpl<CurSysUserMapper, CurSysU
|
|||
Map<Long, Long> oldAndCurShopIdMap = new HashMap<>();
|
||||
Map<Long, Long> curAndOldShopIdMap = new HashMap<>();
|
||||
|
||||
List<CurSysUser> curSysUsers = execSysUser();
|
||||
curSysUsers.forEach(curSysUser -> {
|
||||
if (!curSysUser.getAccount().contains("@")) {
|
||||
orginAccountAndShopIdMap.put(curSysUser.getAccount(), curSysUser.getId());
|
||||
}
|
||||
});
|
||||
// List<CurSysUser> curSysUsers = execShopSysUser();
|
||||
// curSysUsers.forEach(curSysUser -> {
|
||||
// if (!curSysUser.getAccount().contains("@")) {
|
||||
// orginAccountAndShopIdMap.put(curSysUser.getAccount(), curSysUser.getId());
|
||||
// }
|
||||
// });
|
||||
//
|
||||
// execShopInfo(orginAccountAndShopIdMap, oldAndCurShopIdMap, curAndOldShopIdMap);
|
||||
// execStaffInfo(oldAndCurShopIdMap, curAndOldShopIdMap);
|
||||
|
||||
execShopInfo(orginAccountAndShopIdMap, oldAndCurShopIdMap, curAndOldShopIdMap);
|
||||
execStaffInfo(oldAndCurShopIdMap, curAndOldShopIdMap);
|
||||
execSysUserFromShopInfo();
|
||||
execStaffInfo();
|
||||
updateCurlShopBindInfo();
|
||||
|
||||
return CzgResult.success("处理成功");
|
||||
}
|
||||
|
||||
private List<CurSysUser> execSysUser() {
|
||||
List<CurSysUser> sysUserList = new ArrayList<>();
|
||||
|
||||
QueryWrapper queryWrapper = new QueryWrapper();
|
||||
queryWrapper.gt(OldSysUser::getUserId, 1);
|
||||
|
||||
Page<OldSysUser> page = oldSysUserService.page(PageUtils.buildPage(), queryWrapper);
|
||||
|
||||
long startUserId = 100L;
|
||||
private void execSysUserFromShopInfo() {
|
||||
Page<OldShopInfo> page = oldShopInfoService.page(PageUtils.buildPage());
|
||||
|
||||
while (!page.getRecords().isEmpty()) {
|
||||
List<OldSysUser> oldSysUsers = page.getRecords();
|
||||
List<CurSysUser> curSysUsers = saveOldUser(oldSysUsers, startUserId);
|
||||
sysUserList.addAll(curSysUsers);
|
||||
List<OldShopInfo> records = page.getRecords();
|
||||
saveSysUserFromShopInfo(records);
|
||||
|
||||
page = oldSysUserService.page(PageUtils.buildPage(page.getPageNumber() + 1));
|
||||
startUserId += page.getPageSize();
|
||||
}
|
||||
|
||||
return sysUserList;
|
||||
}
|
||||
|
||||
private List<CurShopInfo> execShopInfo(Map<String, Long> orginAccountAndShopIdMap, Map<Long, Long> oldAndCurShopIdMap,
|
||||
Map<Long, Long> curAndOldShopIdMap) {
|
||||
List<CurShopInfo> curShopInfoList = new ArrayList<>();
|
||||
QueryWrapper queryWrapper = new QueryWrapper();
|
||||
queryWrapper.gt(OldShopInfo::getId, 1);
|
||||
Page<OldShopInfo> page = oldShopInfoService.page(PageUtils.buildPage(), queryWrapper);
|
||||
|
||||
while (!page.getRecords().isEmpty()) {
|
||||
List<OldShopInfo> oldShopInfos = page.getRecords();
|
||||
|
||||
List<CurShopInfo> curShopInfos = saveOldShopInfo(oldShopInfos, orginAccountAndShopIdMap, oldAndCurShopIdMap, curAndOldShopIdMap);
|
||||
curShopInfoList.addAll(curShopInfos);
|
||||
|
||||
page = oldShopInfoService.page(PageUtils.buildPage(page.getPageNumber() + 1), queryWrapper);
|
||||
}
|
||||
|
||||
saveCurAndOldShopId(curAndOldShopIdMap);
|
||||
|
||||
return curShopInfoList;
|
||||
}
|
||||
|
||||
private void execStaffInfo(Map<Long, Long> oldAndCurShopIdMap, Map<Long, Long> curAndOldShopIdMap) {
|
||||
Page<OldPlussShopStaff> page = oldStaffService.page(PageUtils.buildPage());
|
||||
|
||||
while (!page.getRecords().isEmpty()) {
|
||||
List<OldPlussShopStaff> oldShopStaffs = page.getRecords();
|
||||
saveOldStaffInfo(oldShopStaffs, oldAndCurShopIdMap, curAndOldShopIdMap);
|
||||
page = oldStaffService.page(PageUtils.buildPage(page.getPageNumber() + 1));
|
||||
page = oldShopInfoService.page(PageUtils.buildPage(page.getPageNumber() + 1));
|
||||
}
|
||||
}
|
||||
|
||||
private void saveCurAndOldShopId(Map<Long, Long> curAndOldShopIdMap) {
|
||||
List<CurShopIdRelation> curShopIdRelations = new ArrayList<>();
|
||||
|
||||
for (Map.Entry<Long, Long> entry : curAndOldShopIdMap.entrySet()) {
|
||||
CurShopIdRelation curShopIdRelation = new CurShopIdRelation();
|
||||
curShopIdRelation.setCurShopId(entry.getKey());
|
||||
curShopIdRelation.setOldShopId(entry.getValue());
|
||||
curShopIdRelations.add(curShopIdRelation);
|
||||
}
|
||||
|
||||
shopIdRelationService.saveBatch(curShopIdRelations);
|
||||
}
|
||||
|
||||
private List<CurSysUser> saveOldUser(List<OldSysUser> oldSysUsers, long startUserId) {
|
||||
if (oldSysUsers == null || oldSysUsers.isEmpty()) {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
|
||||
List<CurSysUser> curSysUsers = new ArrayList<>();
|
||||
for (int i = 0; i < oldSysUsers.size(); i++) {
|
||||
OldSysUser oldSysUser = oldSysUsers.get(i);
|
||||
|
||||
long userId = startUserId + i;
|
||||
String password = SecureUtil.md5(userId + "czg123456");
|
||||
|
||||
CurSysUser curSysUser = new CurSysUser();
|
||||
curSysUser.setId(userId);
|
||||
curSysUser.setAccount(oldSysUser.getUsername());
|
||||
curSysUser.setNickName(oldSysUser.getNickName());
|
||||
curSysUser.setGender(oldSysUser.getGender());
|
||||
curSysUser.setPhone(oldSysUser.getPhone());
|
||||
curSysUser.setEmail(oldSysUser.getEmail());
|
||||
curSysUser.setAvatar(oldSysUser.getAvatarPath());
|
||||
curSysUser.setPassword(password);
|
||||
curSysUser.setIsAdmin(oldSysUser.getIsAdmin());
|
||||
curSysUser.setStauts(oldSysUser.getEnabled().intValue());
|
||||
curSysUser.setCreateUserId(1L);
|
||||
curSysUser.setUpdateUserId(1L);
|
||||
curSysUser.setCreateTime(oldSysUser.getCreateTime());
|
||||
curSysUser.setUpdateTime(LocalDateTime.now());
|
||||
|
||||
curSysUsers.add(curSysUser);
|
||||
}
|
||||
|
||||
saveBatch(curSysUsers);
|
||||
|
||||
return curSysUsers;
|
||||
}
|
||||
|
||||
private List<CurShopInfo> saveOldShopInfo(List<OldShopInfo> oldShopInfos, Map<String, Long> orginAccountAndShopIdMap,
|
||||
Map<Long, Long> oldAndCurShopIdMap, Map<Long, Long> curAndOldShopIdMap) {
|
||||
if (oldShopInfos == null || oldShopInfos.isEmpty()) {
|
||||
return new ArrayList<>();
|
||||
private void saveSysUserFromShopInfo(List<OldShopInfo> records) {
|
||||
if (records == null || records.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
List<CurShopInfo> curShopInfos = new ArrayList<>();
|
||||
for (OldShopInfo oldShopInfo : oldShopInfos) {
|
||||
// 新的 shopId 即 新系统的 sys_user_id
|
||||
Long shopId = orginAccountAndShopIdMap.get(oldShopInfo.getAccount());
|
||||
|
||||
oldAndCurShopIdMap.put(oldShopInfo.getId(), shopId);
|
||||
curAndOldShopIdMap.put(shopId, oldShopInfo.getId());
|
||||
List<CurSysUser> curSysUsers = new ArrayList<>();
|
||||
|
||||
for (OldShopInfo oldShopInfo : records) {
|
||||
CurShopInfo curShopInfo = new CurShopInfo();
|
||||
curShopInfo.setId(shopId);
|
||||
curShopInfo.setId(oldShopInfo.getId());
|
||||
curShopInfo.setSubTitle(oldShopInfo.getSubTitle());
|
||||
curShopInfo.setShopName(oldShopInfo.getShopName());
|
||||
curShopInfo.setChainName(oldShopInfo.getChainName());
|
||||
|
|
@ -244,19 +168,37 @@ public class CurSysUserServiceImpl extends ServiceImpl<CurSysUserMapper, CurSysU
|
|||
curShopInfo.setBookingSms(oldShopInfo.getBookingSms());
|
||||
|
||||
curShopInfos.add(curShopInfo);
|
||||
|
||||
OldSysUser oldSysUser = oldSysUserService.getOne(new QueryWrapper().eq(OldSysUser::getUsername, oldShopInfo.getAccount()));
|
||||
if (oldSysUser == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
CurSysUser curSysUser = getUserByOldSysUser(oldSysUser, oldShopInfo.getId());
|
||||
|
||||
curSysUsers.add(curSysUser);
|
||||
}
|
||||
|
||||
curShopInfoService.saveBatch(curShopInfos);
|
||||
updateCurlShopBindInfo(curShopInfos, oldAndCurShopIdMap, curAndOldShopIdMap);
|
||||
saveBatch(curSysUsers);
|
||||
}
|
||||
|
||||
return curShopInfos;
|
||||
private void execStaffInfo() {
|
||||
Page<OldPlussShopStaff> page = oldStaffService.page(PageUtils.buildPage());
|
||||
|
||||
while (!page.getRecords().isEmpty()) {
|
||||
List<OldPlussShopStaff> oldShopStaffs = page.getRecords();
|
||||
saveOldStaffInfo(oldShopStaffs);
|
||||
page = oldStaffService.page(PageUtils.buildPage(page.getPageNumber() + 1));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理门店绑定开票信息
|
||||
*/
|
||||
private void updateCurlShopBindInfo(List<CurShopInfo> curShopInfos, Map<Long, Long> oldAndCurShopIdMap,
|
||||
Map<Long, Long> curAndOldShopIdMap) {
|
||||
private void updateCurlShopBindInfo() {
|
||||
List<CurShopInfo> curShopInfos = curShopInfoService.list();
|
||||
|
||||
List<Long> oldShopIds = new ArrayList<>();
|
||||
for (CurShopInfo curShopInfo : curShopInfos) {
|
||||
oldShopIds.add(curShopInfo.getId());
|
||||
|
|
@ -271,9 +213,8 @@ public class CurSysUserServiceImpl extends ServiceImpl<CurSysUserMapper, CurSysU
|
|||
|
||||
// 处理新的 店铺绑定的开票信息
|
||||
for (CurShopInfo curShopInfo : curShopInfos) {
|
||||
Long oldShopId = curAndOldShopIdMap.get(curShopInfo.getId());
|
||||
|
||||
OldMerchantAccount oldMerchantAccount = oldMerchantAccountMap.get(oldShopId);
|
||||
OldMerchantAccount oldMerchantAccount = oldMerchantAccountMap.get(curShopInfo.getId());
|
||||
if (oldMerchantAccount == null) {
|
||||
continue;
|
||||
}
|
||||
|
|
@ -288,37 +229,71 @@ public class CurSysUserServiceImpl extends ServiceImpl<CurSysUserMapper, CurSysU
|
|||
curShopInfoService.updateBatch(curShopInfos);
|
||||
}
|
||||
|
||||
private void saveOldStaffInfo(List<OldPlussShopStaff> oldShopStaffs, Map<Long, Long> oldAndCurShopIdMap,
|
||||
Map<Long, Long> curAndOldShopIdMap) {
|
||||
List<CurShopStaff> curShopStaffs = new ArrayList<>();
|
||||
private void saveOldStaffInfo(List<OldPlussShopStaff> oldShopStaffs) {
|
||||
List<CurSysUser> curSysUsers = new ArrayList<>();
|
||||
|
||||
List<CurStaffIdRelation> staffIdRelations = new ArrayList<>();
|
||||
|
||||
for (OldPlussShopStaff oldShopStaff : oldShopStaffs) {
|
||||
OldSysUser oldSysUser = oldSysUserService.getOne(new QueryWrapper().eq(OldSysUser::getUsername, oldShopStaff.getShopId() + "@" + oldShopStaff.getAccount()));
|
||||
if (oldSysUser == null) {
|
||||
continue;
|
||||
}
|
||||
CurSysUser curSysUser = getUserByOldSysUser(oldSysUser, null);
|
||||
save(curSysUser);
|
||||
curSysUser.setPassword(getPassword(curSysUser.getId()));
|
||||
curSysUsers.add(curSysUser);
|
||||
|
||||
CurShopStaff curShopStaff = new CurShopStaff();
|
||||
curShopStaff.setId(Long.valueOf(oldShopStaff.getId()));
|
||||
Long curShopId = oldAndCurShopIdMap.get(Long.valueOf(oldShopStaff.getShopId()));
|
||||
curShopStaff.setId(curSysUser.getId());
|
||||
curShopStaff.setCode(oldShopStaff.getCode());
|
||||
curShopStaff.setName(oldShopStaff.getName());
|
||||
curShopStaff.setMaxDiscountAmount(oldShopStaff.getMaxDiscountAmount());
|
||||
curShopStaff.setDiscountType(oldShopStaff.getDiscountType());
|
||||
curShopStaff.setStatus(oldShopStaff.getStatus());
|
||||
curShopStaff.setShopId(curShopId);
|
||||
curShopStaff.setShopId(Long.valueOf(oldShopStaff.getShopId()));
|
||||
curShopStaff.setType(oldShopStaff.getType());
|
||||
curShopStaff.setIsManage(oldShopStaff.getIsManage());
|
||||
curShopStaff.setIsPc(oldShopStaff.getIsPc());
|
||||
curShopStaff.setCreateTime(DateUtil.toLocalDateTime(oldShopStaff.getCreatedAt() == null ? new Date() : new Date(oldShopStaff.getCreatedAt())));
|
||||
|
||||
curShopStaffs.add(curShopStaff);
|
||||
|
||||
CurSysUser curSysUser = getOne(new QueryWrapper().eq(CurSysUser::getAccount, oldShopStaff.getShopId() + "@" + oldShopStaff.getAccount()));
|
||||
if (curSysUser != null) {
|
||||
String[] split = curSysUser.getAccount().split("@");
|
||||
curSysUser.setAccount(curShopId + "@" + split[1]);
|
||||
curSysUsers.add(curSysUser);
|
||||
}
|
||||
curStaffService.save(curShopStaff);
|
||||
|
||||
CurStaffIdRelation curStaffIdRelation = new CurStaffIdRelation();
|
||||
curStaffIdRelation.setCurStaffId(curShopStaff.getId());
|
||||
curStaffIdRelation.setOldStaffId(Long.valueOf(oldShopStaff.getId()));
|
||||
staffIdRelations.add(curStaffIdRelation);
|
||||
}
|
||||
|
||||
curStaffService.saveBatch(curShopStaffs);
|
||||
updateBatch(curSysUsers);
|
||||
curStaffIdRelationMapper.insertBatch(staffIdRelations);
|
||||
}
|
||||
|
||||
private CurSysUser getUserByOldSysUser(OldSysUser oldSysUser, Long userId) {
|
||||
CurSysUser curSysUser = new CurSysUser();
|
||||
String password = "";
|
||||
if (userId != null) {
|
||||
password = getPassword(userId);
|
||||
curSysUser.setId(userId);
|
||||
}
|
||||
curSysUser.setAccount(oldSysUser.getUsername());
|
||||
curSysUser.setNickName(oldSysUser.getNickName());
|
||||
curSysUser.setGender(oldSysUser.getGender());
|
||||
curSysUser.setPhone(oldSysUser.getPhone());
|
||||
curSysUser.setEmail(oldSysUser.getEmail());
|
||||
curSysUser.setAvatar(oldSysUser.getAvatarPath());
|
||||
curSysUser.setPassword(password);
|
||||
curSysUser.setIsAdmin(oldSysUser.getIsAdmin());
|
||||
curSysUser.setStatus(oldSysUser.getEnabled().intValue());
|
||||
curSysUser.setCreateUserId(1L);
|
||||
curSysUser.setUpdateUserId(1L);
|
||||
curSysUser.setCreateTime(oldSysUser.getCreateTime());
|
||||
curSysUser.setUpdateTime(LocalDateTime.now());
|
||||
return curSysUser;
|
||||
}
|
||||
|
||||
private String getPassword(Long userId) {
|
||||
return SecureUtil.md5(userId + "czg123456");
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,13 +2,13 @@ mybatis-flex:
|
|||
datasource:
|
||||
ds1:
|
||||
# driver-class-name: com.mysql.cj.jdbc.Driver
|
||||
jdbc-url: jdbc:mysql://rm-bp1kn7h89nz62cno1ro.mysql.rds.aliyuncs.com:3306/czg_cashier?useUnicode=true&characterEncoding=utf-8
|
||||
username: cashier
|
||||
password: Cashier@1@
|
||||
jdbc-url: jdbc:mysql://rm-bp1b572nblln4jho2po.mysql.rds.aliyuncs.com/czg_cashier_test?useUnicode=true&characterEncoding=utf-8
|
||||
username: root
|
||||
password: Czg666888
|
||||
ds2:
|
||||
# driver-class-name: com.mysql.cj.jdbc.Driver
|
||||
jdbc-url: jdbc:mysql://rm-bp1kn7h89nz62cno1ro.mysql.rds.aliyuncs.com:3306/fycashier_test?useUnicode=true&characterEncoding=utf-8
|
||||
username: cashier
|
||||
password: Cashier@1@
|
||||
jdbc-url: jdbc:mysql://rm-bp1b572nblln4jho2po.mysql.rds.aliyuncs.com/fycashier?useUnicode=true&characterEncoding=utf-8
|
||||
username: root
|
||||
password: Czg666888
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -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.CurStaffIdRelationMapper">
|
||||
|
||||
</mapper>
|
||||
|
|
@ -15,3 +15,9 @@
|
|||
|
||||
#### 1.2.1 保存新的 shop_id 和 原来shop_id 对应关系
|
||||
> 表名:shop_id_relation
|
||||
|
||||
|
||||
## 接口执行顺序
|
||||
|
||||
1. 迁移系统用户
|
||||
> /merge/user/mergeShopInfo
|
||||
|
|
|
|||
Loading…
Reference in New Issue