迁移用户数据 完成
This commit is contained in:
parent
74c9d05134
commit
7fe48c1ae7
|
|
@ -1,5 +1,6 @@
|
|||
package com.czg.mergedata;
|
||||
|
||||
import org.mybatis.spring.annotation.MapperScan;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.transaction.annotation.EnableTransactionManagement;
|
||||
|
|
@ -9,6 +10,7 @@ import org.springframework.transaction.annotation.EnableTransactionManagement;
|
|||
*/
|
||||
@SpringBootApplication
|
||||
@EnableTransactionManagement
|
||||
@MapperScan("com.czg.mergedata.*.mapper")
|
||||
public class MergeDataApplication {
|
||||
|
||||
public static void main(String[] args) {
|
||||
|
|
|
|||
|
|
@ -1,38 +0,0 @@
|
|||
package com.czg.mergedata.common.config;
|
||||
|
||||
import com.zaxxer.hikari.HikariDataSource;
|
||||
import org.apache.ibatis.session.SqlSessionFactory;
|
||||
import org.mybatis.spring.SqlSessionFactoryBean;
|
||||
import org.mybatis.spring.annotation.MapperScan;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import org.springframework.boot.jdbc.DataSourceBuilder;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.context.annotation.Primary;
|
||||
import org.springframework.core.io.support.PathMatchingResourcePatternResolver;
|
||||
|
||||
import javax.sql.DataSource;
|
||||
|
||||
/**
|
||||
* @author GYJoker
|
||||
*/
|
||||
@Configuration
|
||||
@MapperScan(basePackages = "com.czg.mergedata.cur.mapper", sqlSessionFactoryRef = "curEntityManagerFactory")
|
||||
public class CurDataSourceConfig {
|
||||
@Primary
|
||||
@Bean(name = "curDataSource")
|
||||
@ConfigurationProperties(prefix = "spring.datasource.cur")
|
||||
public DataSource primaryDataSource() {
|
||||
return DataSourceBuilder.create().type(HikariDataSource.class).build();
|
||||
}
|
||||
|
||||
@Primary
|
||||
@Bean(name = "curEntityManagerFactory")
|
||||
public SqlSessionFactory curSqlSessionFactory(@Qualifier("curDataSource") DataSource dataSource) throws Exception {
|
||||
SqlSessionFactoryBean sessionFactory = new SqlSessionFactoryBean();
|
||||
sessionFactory.setDataSource(dataSource);
|
||||
sessionFactory.setMapperLocations(new PathMatchingResourcePatternResolver().getResources("classpath:mapper/cur/*.xml"));
|
||||
return sessionFactory.getObject();
|
||||
}
|
||||
}
|
||||
|
|
@ -1,38 +0,0 @@
|
|||
package com.czg.mergedata.common.config;
|
||||
|
||||
import com.zaxxer.hikari.HikariDataSource;
|
||||
import org.apache.ibatis.session.SqlSessionFactory;
|
||||
import org.mybatis.spring.SqlSessionFactoryBean;
|
||||
import org.mybatis.spring.annotation.MapperScan;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import org.springframework.boot.jdbc.DataSourceBuilder;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.context.annotation.Primary;
|
||||
import org.springframework.core.io.support.PathMatchingResourcePatternResolver;
|
||||
|
||||
import javax.sql.DataSource;
|
||||
|
||||
/**
|
||||
* @author GYJoker
|
||||
*/
|
||||
@Configuration
|
||||
@MapperScan(basePackages = "com.czg.mergedata.old.mapper", sqlSessionFactoryRef = "oldEntityManagerFactory")
|
||||
public class OldDataSourceConfig {
|
||||
@Primary
|
||||
@Bean(name = "oldDataSource")
|
||||
@ConfigurationProperties(prefix = "spring.datasource.old")
|
||||
public DataSource oldDataSource() {
|
||||
return DataSourceBuilder.create().type(HikariDataSource.class).build();
|
||||
}
|
||||
|
||||
@Primary
|
||||
@Bean(name = "oldEntityManagerFactory")
|
||||
public SqlSessionFactory oldSqlSessionFactory(@Qualifier("oldDataSource") DataSource dataSource) throws Exception {
|
||||
SqlSessionFactoryBean sessionFactory = new SqlSessionFactoryBean();
|
||||
sessionFactory.setDataSource(dataSource);
|
||||
sessionFactory.setMapperLocations(new PathMatchingResourcePatternResolver().getResources("classpath:mapper/old/*.xml"));
|
||||
return sessionFactory.getObject();
|
||||
}
|
||||
}
|
||||
|
|
@ -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_merchant_account");
|
||||
.setGenerateTable("tb_shop_id_relation");
|
||||
|
||||
EntityConfig entityConfig = globalConfig.getEntityConfig();
|
||||
if (isOldVersion) {
|
||||
|
|
|
|||
|
|
@ -0,0 +1,27 @@
|
|||
package com.czg.mergedata.controller;
|
||||
|
||||
import com.czg.mergedata.old.entity.OldMerchantAccount;
|
||||
import com.czg.mergedata.old.service.OldMerchantAccountService;
|
||||
import com.mybatisflex.core.query.QueryWrapper;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
/**
|
||||
* @author GYJoker
|
||||
*/
|
||||
@RequestMapping("/test")
|
||||
@RestController
|
||||
public class TestServiceController {
|
||||
@Resource
|
||||
private OldMerchantAccountService oldMerchantAccountService;
|
||||
|
||||
@RequestMapping("/oldMerchantAccount")
|
||||
public Object getOldMerchantAccount() {
|
||||
QueryWrapper queryWrapper = new QueryWrapper();
|
||||
queryWrapper.in(OldMerchantAccount::getShopId, Arrays.asList(1, 2, 3, 4, 5));
|
||||
return oldMerchantAccountService.list(queryWrapper);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,5 +1,6 @@
|
|||
package com.czg.mergedata.cur.mapper;
|
||||
|
||||
import com.mybatisflex.annotation.UseDataSource;
|
||||
import com.mybatisflex.core.BaseMapper;
|
||||
import com.czg.mergedata.cur.entity.CurShopIdRelation;
|
||||
|
||||
|
|
@ -9,6 +10,7 @@ import com.czg.mergedata.cur.entity.CurShopIdRelation;
|
|||
* @author mac
|
||||
* @since 2025-02-15
|
||||
*/
|
||||
@UseDataSource("ds1")
|
||||
public interface CurShopIdRelationMapper extends BaseMapper<CurShopIdRelation> {
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
package com.czg.mergedata.cur.mapper;
|
||||
|
||||
import com.mybatisflex.annotation.UseDataSource;
|
||||
import com.mybatisflex.core.BaseMapper;
|
||||
import com.czg.mergedata.cur.entity.CurShopInfo;
|
||||
|
||||
|
|
@ -9,6 +10,7 @@ import com.czg.mergedata.cur.entity.CurShopInfo;
|
|||
* @author mac
|
||||
* @since 2025-02-15
|
||||
*/
|
||||
@UseDataSource("ds1")
|
||||
public interface CurShopInfoMapper extends BaseMapper<CurShopInfo> {
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
package com.czg.mergedata.cur.mapper;
|
||||
|
||||
import com.mybatisflex.annotation.UseDataSource;
|
||||
import com.mybatisflex.core.BaseMapper;
|
||||
import com.czg.mergedata.cur.entity.CurShopStaff;
|
||||
|
||||
|
|
@ -9,6 +10,7 @@ import com.czg.mergedata.cur.entity.CurShopStaff;
|
|||
* @author mac
|
||||
* @since 2025-02-15
|
||||
*/
|
||||
@UseDataSource("ds1")
|
||||
public interface CurShopStaffMapper extends BaseMapper<CurShopStaff> {
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
package com.czg.mergedata.cur.mapper;
|
||||
|
||||
import com.mybatisflex.annotation.UseDataSource;
|
||||
import com.mybatisflex.core.BaseMapper;
|
||||
import com.czg.mergedata.cur.entity.CurSysUser;
|
||||
|
||||
|
|
@ -9,6 +10,7 @@ import com.czg.mergedata.cur.entity.CurSysUser;
|
|||
* @author mac
|
||||
* @since 2025-02-15
|
||||
*/
|
||||
@UseDataSource("ds1")
|
||||
public interface CurSysUserMapper extends BaseMapper<CurSysUser> {
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
package com.czg.mergedata.cur.service;
|
||||
|
||||
import com.mybatisflex.annotation.UseDataSource;
|
||||
import com.mybatisflex.core.service.IService;
|
||||
import com.czg.mergedata.cur.entity.CurShopIdRelation;
|
||||
|
||||
|
|
@ -9,6 +10,7 @@ import com.czg.mergedata.cur.entity.CurShopIdRelation;
|
|||
* @author mac
|
||||
* @since 2025-02-15
|
||||
*/
|
||||
@UseDataSource("ds1")
|
||||
public interface CurShopIdRelationService extends IService<CurShopIdRelation> {
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
package com.czg.mergedata.cur.service;
|
||||
|
||||
import com.mybatisflex.annotation.UseDataSource;
|
||||
import com.mybatisflex.core.service.IService;
|
||||
import com.czg.mergedata.cur.entity.CurShopInfo;
|
||||
|
||||
|
|
@ -9,6 +10,7 @@ import com.czg.mergedata.cur.entity.CurShopInfo;
|
|||
* @author mac
|
||||
* @since 2025-02-15
|
||||
*/
|
||||
@UseDataSource("ds1")
|
||||
public interface CurShopInfoService extends IService<CurShopInfo> {
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
package com.czg.mergedata.cur.service;
|
||||
|
||||
import com.mybatisflex.annotation.UseDataSource;
|
||||
import com.mybatisflex.core.service.IService;
|
||||
import com.czg.mergedata.cur.entity.CurShopStaff;
|
||||
|
||||
|
|
@ -9,6 +10,7 @@ import com.czg.mergedata.cur.entity.CurShopStaff;
|
|||
* @author mac
|
||||
* @since 2025-02-15
|
||||
*/
|
||||
@UseDataSource("ds1")
|
||||
public interface CurShopStaffService extends IService<CurShopStaff> {
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
package com.czg.mergedata.cur.service;
|
||||
|
||||
import com.czg.mergedata.common.resp.CzgResult;
|
||||
import com.mybatisflex.annotation.UseDataSource;
|
||||
import com.mybatisflex.core.service.IService;
|
||||
import com.czg.mergedata.cur.entity.CurSysUser;
|
||||
|
||||
|
|
@ -10,6 +11,7 @@ import com.czg.mergedata.cur.entity.CurSysUser;
|
|||
* @author mac
|
||||
* @since 2025-02-15
|
||||
*/
|
||||
@UseDataSource("ds1")
|
||||
public interface CurSysUserService extends IService<CurSysUser> {
|
||||
|
||||
CzgResult<String> mergeShopInfo();
|
||||
|
|
|
|||
|
|
@ -1,9 +1,9 @@
|
|||
package com.czg.mergedata.cur.service.impl;
|
||||
|
||||
import com.mybatisflex.spring.service.impl.ServiceImpl;
|
||||
import com.czg.mergedata.cur.entity.CurShopIdRelation;
|
||||
import com.czg.mergedata.cur.mapper.CurShopIdRelationMapper;
|
||||
import com.czg.mergedata.cur.service.CurShopIdRelationService;
|
||||
import com.mybatisflex.spring.service.impl.ServiceImpl;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -1,9 +1,9 @@
|
|||
package com.czg.mergedata.cur.service.impl;
|
||||
|
||||
import com.mybatisflex.spring.service.impl.ServiceImpl;
|
||||
import com.czg.mergedata.cur.entity.CurShopInfo;
|
||||
import com.czg.mergedata.cur.mapper.CurShopInfoMapper;
|
||||
import com.czg.mergedata.cur.service.CurShopInfoService;
|
||||
import com.mybatisflex.spring.service.impl.ServiceImpl;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -1,9 +1,9 @@
|
|||
package com.czg.mergedata.cur.service.impl;
|
||||
|
||||
import com.mybatisflex.spring.service.impl.ServiceImpl;
|
||||
import com.czg.mergedata.cur.entity.CurShopStaff;
|
||||
import com.czg.mergedata.cur.mapper.CurShopStaffMapper;
|
||||
import com.czg.mergedata.cur.service.CurShopStaffService;
|
||||
import com.mybatisflex.spring.service.impl.ServiceImpl;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -4,10 +4,12 @@ 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.service.CurShopIdRelationService;
|
||||
import com.czg.mergedata.cur.service.CurShopInfoService;
|
||||
import com.czg.mergedata.cur.service.CurShopStaffService;
|
||||
import com.czg.mergedata.cur.service.CurSysUserService;
|
||||
|
|
@ -20,7 +22,6 @@ import com.czg.mergedata.old.service.OldPlussShopStaffService;
|
|||
import com.czg.mergedata.old.service.OldShopInfoService;
|
||||
import com.czg.mergedata.old.service.OldSysUserService;
|
||||
import com.mybatisflex.core.paginate.Page;
|
||||
import com.mybatisflex.core.query.QueryChain;
|
||||
import com.mybatisflex.core.query.QueryWrapper;
|
||||
import com.mybatisflex.spring.service.impl.ServiceImpl;
|
||||
import jakarta.annotation.Resource;
|
||||
|
|
@ -57,6 +58,9 @@ public class CurSysUserServiceImpl extends ServiceImpl<CurSysUserMapper, CurSysU
|
|||
@Resource
|
||||
private CurShopStaffService curStaffService;
|
||||
|
||||
@Resource
|
||||
private CurShopIdRelationService shopIdRelationService;
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public CzgResult<String> mergeShopInfo() {
|
||||
|
|
@ -68,41 +72,36 @@ public class CurSysUserServiceImpl extends ServiceImpl<CurSysUserMapper, CurSysU
|
|||
Map<Long, Long> curAndOldShopIdMap = new HashMap<>();
|
||||
|
||||
List<CurSysUser> curSysUsers = execSysUser();
|
||||
// curSysUsers.forEach(curSysUser -> {
|
||||
// if (!curSysUser.getAccount().contains("@")) {
|
||||
// orginAccountAndShopIdMap.put(curSysUser.getAccount(), curSysUser.getId());
|
||||
// }
|
||||
// });
|
||||
//
|
||||
// List<CurShopInfo> curShopInfos = execShopInfo(orginAccountAndShopIdMap, oldAndCurShopIdMap, curAndOldShopIdMap);
|
||||
// execStaffInfo(oldAndCurShopIdMap, curAndOldShopIdMap);
|
||||
curSysUsers.forEach(curSysUser -> {
|
||||
if (!curSysUser.getAccount().contains("@")) {
|
||||
orginAccountAndShopIdMap.put(curSysUser.getAccount(), curSysUser.getId());
|
||||
}
|
||||
});
|
||||
|
||||
execShopInfo(orginAccountAndShopIdMap, oldAndCurShopIdMap, curAndOldShopIdMap);
|
||||
execStaffInfo(oldAndCurShopIdMap, curAndOldShopIdMap);
|
||||
|
||||
return CzgResult.success("处理成功");
|
||||
}
|
||||
|
||||
private List<CurSysUser> execSysUser() {
|
||||
List<CurSysUser> sysUserList = new ArrayList<>();
|
||||
|
||||
// QueryWrapper queryWrapper = new QueryWrapper();
|
||||
// queryWrapper.gt(OldSysUser::getUserId, 1);
|
||||
QueryWrapper queryWrapper = new QueryWrapper();
|
||||
queryWrapper.gt(OldSysUser::getUserId, 1);
|
||||
|
||||
OldSysUser byId = oldSysUserService.getById(1);
|
||||
// Page<OldSysUser> page = oldSysUserService.page(PageUtils.buildPage());
|
||||
// List<OldSysUser> list = oldSysUserService.list(new QueryWrapper().ge(OldSysUser::getUserId, 1));
|
||||
// Page<OldSysUser> page = oldSysUserService.page(PageUtils.buildPage(), queryWrapper);
|
||||
// Page<OldSysUser> page = oldSysUserService.page(PageUtils.buildPage());
|
||||
//
|
||||
// long startUserId = 100L;
|
||||
//
|
||||
// while (page.hasNext() || page.getPageNumber() == 1) {
|
||||
// List<OldSysUser> oldSysUsers = page.getRecords();
|
||||
// List<CurSysUser> curSysUsers = saveOldUser(oldSysUsers, startUserId);
|
||||
// sysUserList.addAll(curSysUsers);
|
||||
//
|
||||
// page = oldSysUserService.page(PageUtils.buildPage(page.getPageNumber() + 1));
|
||||
// startUserId += page.getPageSize();
|
||||
// }
|
||||
Page<OldSysUser> page = oldSysUserService.page(PageUtils.buildPage(), queryWrapper);
|
||||
|
||||
long startUserId = 100L;
|
||||
|
||||
while (page.hasNext() || page.getPageNumber() == 1) {
|
||||
List<OldSysUser> oldSysUsers = page.getRecords();
|
||||
List<CurSysUser> curSysUsers = saveOldUser(oldSysUsers, startUserId);
|
||||
sysUserList.addAll(curSysUsers);
|
||||
|
||||
page = oldSysUserService.page(PageUtils.buildPage(page.getPageNumber() + 1));
|
||||
startUserId += page.getPageSize();
|
||||
}
|
||||
|
||||
return sysUserList;
|
||||
}
|
||||
|
|
@ -110,7 +109,9 @@ public class CurSysUserServiceImpl extends ServiceImpl<CurSysUserMapper, CurSysU
|
|||
private List<CurShopInfo> execShopInfo(Map<String, Long> orginAccountAndShopIdMap, Map<Long, Long> oldAndCurShopIdMap,
|
||||
Map<Long, Long> curAndOldShopIdMap) {
|
||||
List<CurShopInfo> curShopInfoList = new ArrayList<>();
|
||||
Page<OldShopInfo> page = oldShopInfoService.page(PageUtils.buildPage());
|
||||
QueryWrapper queryWrapper = new QueryWrapper();
|
||||
queryWrapper.gt(OldShopInfo::getId, 1);
|
||||
Page<OldShopInfo> page = oldShopInfoService.page(PageUtils.buildPage(), queryWrapper);
|
||||
|
||||
while (page.hasNext() || page.getPageNumber() == 1) {
|
||||
List<OldShopInfo> oldShopInfos = page.getRecords();
|
||||
|
|
@ -118,9 +119,11 @@ public class CurSysUserServiceImpl extends ServiceImpl<CurSysUserMapper, CurSysU
|
|||
List<CurShopInfo> curShopInfos = saveOldShopInfo(oldShopInfos, orginAccountAndShopIdMap, oldAndCurShopIdMap, curAndOldShopIdMap);
|
||||
curShopInfoList.addAll(curShopInfos);
|
||||
|
||||
page = oldShopInfoService.page(PageUtils.buildPage());
|
||||
page = oldShopInfoService.page(PageUtils.buildPage(page.getPageNumber() + 1), queryWrapper);
|
||||
}
|
||||
|
||||
saveCurAndOldShopId(curAndOldShopIdMap);
|
||||
|
||||
return curShopInfoList;
|
||||
}
|
||||
|
||||
|
|
@ -130,10 +133,23 @@ public class CurSysUserServiceImpl extends ServiceImpl<CurSysUserMapper, CurSysU
|
|||
while (page.hasNext() || page.getPageNumber() == 1) {
|
||||
List<OldPlussShopStaff> oldShopStaffs = page.getRecords();
|
||||
saveOldStaffInfo(oldShopStaffs, oldAndCurShopIdMap, curAndOldShopIdMap);
|
||||
page = oldStaffService.page(PageUtils.buildPage());
|
||||
page = oldStaffService.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<>();
|
||||
|
|
@ -205,8 +221,8 @@ public class CurSysUserServiceImpl extends ServiceImpl<CurSysUserMapper, CurSysU
|
|||
curShopInfo.setProfiles(oldShopInfo.getProfiles());
|
||||
curShopInfo.setOnSale(oldShopInfo.getOnSale());
|
||||
curShopInfo.setStatus(oldShopInfo.getStatus());
|
||||
curShopInfo.setExpireTime(DateUtil.toLocalDateTime(new Date(oldShopInfo.getExpireAt())));
|
||||
curShopInfo.setCreateTime(DateUtil.toLocalDateTime(new Date(oldShopInfo.getCreatedAt())));
|
||||
curShopInfo.setExpireTime(DateUtil.toLocalDateTime(oldShopInfo.getExpireAt() == null ? new Date() : new Date(oldShopInfo.getExpireAt())));
|
||||
curShopInfo.setCreateTime(DateUtil.toLocalDateTime(oldShopInfo.getCreatedAt() == null ? new Date() : new Date(oldShopInfo.getCreatedAt())));
|
||||
curShopInfo.setShopQrcode(oldShopInfo.getShopQrcode());
|
||||
curShopInfo.setTag(oldShopInfo.getTag());
|
||||
curShopInfo.setLat(oldShopInfo.getLat());
|
||||
|
|
@ -226,6 +242,8 @@ public class CurSysUserServiceImpl extends ServiceImpl<CurSysUserMapper, CurSysU
|
|||
curShopInfo.setSmallQrcode(oldShopInfo.getSmallQrcode());
|
||||
curShopInfo.setPaymentQrcode(oldShopInfo.getPaymentQrcode());
|
||||
curShopInfo.setBookingSms(oldShopInfo.getBookingSms());
|
||||
|
||||
curShopInfos.add(curShopInfo);
|
||||
}
|
||||
|
||||
curShopInfoService.saveBatch(curShopInfos);
|
||||
|
|
@ -245,9 +263,7 @@ public class CurSysUserServiceImpl extends ServiceImpl<CurSysUserMapper, CurSysU
|
|||
}
|
||||
|
||||
// 查询旧的 店铺绑定的开票信息
|
||||
QueryWrapper queryWrapper = new QueryWrapper();
|
||||
queryWrapper.in(OldMerchantAccount::getShopId, oldShopIds);
|
||||
List<OldMerchantAccount> merchantAccounts = oldMerchantAccountService.list(queryWrapper);
|
||||
List<OldMerchantAccount> merchantAccounts = oldMerchantAccountService.getMerchantAccountByIds(oldShopIds);
|
||||
Map<Long, OldMerchantAccount> oldMerchantAccountMap = new HashMap<>();
|
||||
for (OldMerchantAccount oldMerchantAccount : merchantAccounts) {
|
||||
oldMerchantAccountMap.put(Long.valueOf(oldMerchantAccount.getShopId()), oldMerchantAccount);
|
||||
|
|
@ -290,13 +306,14 @@ public class CurSysUserServiceImpl extends ServiceImpl<CurSysUserMapper, CurSysU
|
|||
curShopStaff.setType(oldShopStaff.getType());
|
||||
curShopStaff.setIsManage(oldShopStaff.getIsManage());
|
||||
curShopStaff.setIsPc(oldShopStaff.getIsPc());
|
||||
curShopStaff.setCreateTime(DateUtil.toLocalDateTime(new Date(oldShopStaff.getCreatedAt())));
|
||||
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) {
|
||||
curSysUser.setAccount(curShopId + "@" + curSysUser.getAccount());
|
||||
String[] split = curSysUser.getAccount().split("@");
|
||||
curSysUser.setAccount(curShopId + "@" + split[1]);
|
||||
curSysUsers.add(curSysUser);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
package com.czg.mergedata.old.mapper;
|
||||
|
||||
import com.mybatisflex.annotation.UseDataSource;
|
||||
import com.mybatisflex.core.BaseMapper;
|
||||
import com.czg.mergedata.old.entity.OldMerchantAccount;
|
||||
|
||||
|
|
@ -9,6 +10,7 @@ import com.czg.mergedata.old.entity.OldMerchantAccount;
|
|||
* @author mac
|
||||
* @since 2025-02-15
|
||||
*/
|
||||
@UseDataSource("ds2")
|
||||
public interface OldMerchantAccountMapper extends BaseMapper<OldMerchantAccount> {
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
package com.czg.mergedata.old.mapper;
|
||||
|
||||
import com.mybatisflex.annotation.UseDataSource;
|
||||
import com.mybatisflex.core.BaseMapper;
|
||||
import com.czg.mergedata.old.entity.OldPlussShopStaff;
|
||||
|
||||
|
|
@ -9,6 +10,7 @@ import com.czg.mergedata.old.entity.OldPlussShopStaff;
|
|||
* @author mac
|
||||
* @since 2025-02-15
|
||||
*/
|
||||
@UseDataSource("ds2")
|
||||
public interface OldPlussShopStaffMapper extends BaseMapper<OldPlussShopStaff> {
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
package com.czg.mergedata.old.mapper;
|
||||
|
||||
import com.mybatisflex.annotation.UseDataSource;
|
||||
import com.mybatisflex.core.BaseMapper;
|
||||
import com.czg.mergedata.old.entity.OldShopInfo;
|
||||
|
||||
|
|
@ -9,6 +10,7 @@ import com.czg.mergedata.old.entity.OldShopInfo;
|
|||
* @author mac
|
||||
* @since 2025-02-15
|
||||
*/
|
||||
@UseDataSource("ds2")
|
||||
public interface OldShopInfoMapper extends BaseMapper<OldShopInfo> {
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
package com.czg.mergedata.old.mapper;
|
||||
|
||||
import com.mybatisflex.annotation.UseDataSource;
|
||||
import com.mybatisflex.core.BaseMapper;
|
||||
import com.czg.mergedata.old.entity.OldSysUser;
|
||||
|
||||
|
|
@ -9,6 +10,7 @@ import com.czg.mergedata.old.entity.OldSysUser;
|
|||
* @author mac
|
||||
* @since 2025-02-15
|
||||
*/
|
||||
@UseDataSource("ds2")
|
||||
public interface OldSysUserMapper extends BaseMapper<OldSysUser> {
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,14 +1,18 @@
|
|||
package com.czg.mergedata.old.service;
|
||||
|
||||
import com.mybatisflex.annotation.UseDataSource;
|
||||
import com.mybatisflex.core.service.IService;
|
||||
import com.czg.mergedata.old.entity.OldMerchantAccount;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 商家登陆帐号 服务层。
|
||||
*
|
||||
* @author mac
|
||||
* @since 2025-02-15
|
||||
*/
|
||||
@UseDataSource("ds2")
|
||||
public interface OldMerchantAccountService extends IService<OldMerchantAccount> {
|
||||
|
||||
List<OldMerchantAccount> getMerchantAccountByIds(List<Long> ids);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
package com.czg.mergedata.old.service;
|
||||
|
||||
import com.mybatisflex.annotation.UseDataSource;
|
||||
import com.mybatisflex.core.service.IService;
|
||||
import com.czg.mergedata.old.entity.OldPlussShopStaff;
|
||||
|
||||
|
|
@ -9,6 +10,7 @@ import com.czg.mergedata.old.entity.OldPlussShopStaff;
|
|||
* @author mac
|
||||
* @since 2025-02-15
|
||||
*/
|
||||
@UseDataSource("ds2")
|
||||
public interface OldPlussShopStaffService extends IService<OldPlussShopStaff> {
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
package com.czg.mergedata.old.service;
|
||||
|
||||
import com.mybatisflex.annotation.UseDataSource;
|
||||
import com.mybatisflex.core.service.IService;
|
||||
import com.czg.mergedata.old.entity.OldShopInfo;
|
||||
|
||||
|
|
@ -9,6 +10,7 @@ import com.czg.mergedata.old.entity.OldShopInfo;
|
|||
* @author mac
|
||||
* @since 2025-02-15
|
||||
*/
|
||||
@UseDataSource("ds2")
|
||||
public interface OldShopInfoService extends IService<OldShopInfo> {
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
package com.czg.mergedata.old.service;
|
||||
|
||||
import com.mybatisflex.annotation.UseDataSource;
|
||||
import com.mybatisflex.core.service.IService;
|
||||
import com.czg.mergedata.old.entity.OldSysUser;
|
||||
|
||||
|
|
@ -9,6 +10,7 @@ import com.czg.mergedata.old.entity.OldSysUser;
|
|||
* @author mac
|
||||
* @since 2025-02-15
|
||||
*/
|
||||
@UseDataSource("ds2")
|
||||
public interface OldSysUserService extends IService<OldSysUser> {
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,11 +1,14 @@
|
|||
package com.czg.mergedata.old.service.impl;
|
||||
|
||||
import com.mybatisflex.spring.service.impl.ServiceImpl;
|
||||
import com.czg.mergedata.old.entity.OldMerchantAccount;
|
||||
import com.czg.mergedata.old.mapper.OldMerchantAccountMapper;
|
||||
import com.czg.mergedata.old.service.OldMerchantAccountService;
|
||||
import com.mybatisflex.annotation.UseDataSource;
|
||||
import com.mybatisflex.spring.service.impl.ServiceImpl;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 商家登陆帐号 服务层实现。
|
||||
*
|
||||
|
|
@ -13,6 +16,11 @@ import org.springframework.stereotype.Service;
|
|||
* @since 2025-02-15
|
||||
*/
|
||||
@Service
|
||||
@UseDataSource("ds2")
|
||||
public class OldMerchantAccountServiceImpl extends ServiceImpl<OldMerchantAccountMapper, OldMerchantAccount> implements OldMerchantAccountService{
|
||||
|
||||
@Override
|
||||
public List<OldMerchantAccount> getMerchantAccountByIds(List<Long> ids) {
|
||||
return getMapper().selectListByIds(ids);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
package com.czg.mergedata.old.service.impl;
|
||||
|
||||
import com.mybatisflex.annotation.UseDataSource;
|
||||
import com.mybatisflex.spring.service.impl.ServiceImpl;
|
||||
import com.czg.mergedata.old.entity.OldPlussShopStaff;
|
||||
import com.czg.mergedata.old.mapper.OldPlussShopStaffMapper;
|
||||
|
|
@ -13,6 +14,7 @@ import org.springframework.stereotype.Service;
|
|||
* @since 2025-02-15
|
||||
*/
|
||||
@Service
|
||||
@UseDataSource("ds2")
|
||||
public class OldPlussShopStaffServiceImpl extends ServiceImpl<OldPlussShopStaffMapper, OldPlussShopStaff> implements OldPlussShopStaffService{
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
package com.czg.mergedata.old.service.impl;
|
||||
|
||||
import com.mybatisflex.annotation.UseDataSource;
|
||||
import com.mybatisflex.spring.service.impl.ServiceImpl;
|
||||
import com.czg.mergedata.old.entity.OldShopInfo;
|
||||
import com.czg.mergedata.old.mapper.OldShopInfoMapper;
|
||||
|
|
@ -13,6 +14,7 @@ import org.springframework.stereotype.Service;
|
|||
* @since 2025-02-15
|
||||
*/
|
||||
@Service
|
||||
@UseDataSource("ds2")
|
||||
public class OldShopInfoServiceImpl extends ServiceImpl<OldShopInfoMapper, OldShopInfo> implements OldShopInfoService{
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
package com.czg.mergedata.old.service.impl;
|
||||
|
||||
import com.mybatisflex.annotation.UseDataSource;
|
||||
import com.mybatisflex.spring.service.impl.ServiceImpl;
|
||||
import com.czg.mergedata.old.entity.OldSysUser;
|
||||
import com.czg.mergedata.old.mapper.OldSysUserMapper;
|
||||
|
|
@ -13,6 +14,7 @@ import org.springframework.stereotype.Service;
|
|||
* @since 2025-02-15
|
||||
*/
|
||||
@Service
|
||||
@UseDataSource("ds2")
|
||||
public class OldSysUserServiceImpl extends ServiceImpl<OldSysUserMapper, OldSysUser> implements OldSysUserService{
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,12 +1,12 @@
|
|||
spring:
|
||||
mybatis-flex:
|
||||
datasource:
|
||||
cur:
|
||||
driver-class-name: com.mysql.cj.jdbc.Driver
|
||||
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@
|
||||
old:
|
||||
driver-class-name: com.mysql.cj.jdbc.Driver
|
||||
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@
|
||||
|
|
|
|||
|
|
@ -16,3 +16,7 @@ logging:
|
|||
mybatis:
|
||||
configuration:
|
||||
log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
|
||||
|
||||
|
||||
mybatis-flex:
|
||||
mapper-locations: classpath*:mapper/**/*.xml
|
||||
|
|
|
|||
Loading…
Reference in New Issue