TASK: 数据迁移拆分;
This commit is contained in:
@@ -1418,150 +1418,22 @@ public class MyTaskScheduler {
|
||||
@Transactional
|
||||
public void projectDataCreate() {
|
||||
// UserLikeGroup转project
|
||||
// QueryWrapper<UserLikeGroup> qw = new QueryWrapper<>();
|
||||
// qw.lambda().ne(UserLikeGroup::getAccountId, -1);
|
||||
// List<UserLikeGroup> userLikeGroups = userLikeGroupMapper.selectList(qw);
|
||||
// for (UserLikeGroup userLikeGroup : userLikeGroups) {
|
||||
// Project project = new Project();
|
||||
// project.setAccountId(userLikeGroup.getAccountId());
|
||||
// project.setName(userLikeGroup.getName());
|
||||
// project.setCreateTime(LocalDateTime.ofInstant(userLikeGroup.getCreateDate().toInstant(), ZoneId.systemDefault()));
|
||||
// project.setUpdateTime(LocalDateTime.ofInstant(userLikeGroup.getUpdateDate().toInstant(), ZoneId.systemDefault()));
|
||||
// project.setOriginal(userLikeGroup.getOriginal());
|
||||
// project.setOriginalAccountId(userLikeGroup.getOriginalAccountId());
|
||||
// project.setOriginalPortfolioId(userLikeGroup.getOriginalPortfolioId());
|
||||
//
|
||||
// QueryWrapper<Design> designQueryWrapper = new QueryWrapper<>();
|
||||
// designQueryWrapper.lambda().eq(Design::getCollectionId, userLikeGroup.getCollectionId());
|
||||
// Design design = designMapper.selectOne(designQueryWrapper);
|
||||
// if (Objects.isNull(design)) {
|
||||
// System.out.println(userLikeGroup.getCollectionId());
|
||||
// continue;
|
||||
// }
|
||||
// if (design.getSingleOverall().equals("overall")) {
|
||||
// project.setProcess(DesignProcess.SERIES_DESIGN.name());
|
||||
// }else {
|
||||
// project.setProcess(DesignProcess.SINGLE_DESIGN.name());
|
||||
// }
|
||||
// projectMapper.insert(project);
|
||||
// Long accountId = userLikeGroup.getAccountId();
|
||||
// QueryWrapper<Workspace> workspaceQueryWrapper = new QueryWrapper<>();
|
||||
// workspaceQueryWrapper.lambda().eq(Workspace::getAccountId, accountId);
|
||||
// workspaceQueryWrapper.lambda().eq(Workspace::getIsLastIndex, 1);
|
||||
// Workspace workspace = workspaceMapper.selectOne(workspaceQueryWrapper);
|
||||
// if (Objects.isNull(workspace)) {
|
||||
// System.out.println(accountId);
|
||||
// continue;
|
||||
// }
|
||||
// workspace.setIsLastIndex(0);
|
||||
// workspace.setProjectId(project.getId());
|
||||
// workspace.setSystemDesignerPercentage(design.getSystemScale().multiply(new BigDecimal("100")).setScale(0, RoundingMode.HALF_UP).intValueExact());
|
||||
// if (!design.getSingleOverall().equals("overall")) {
|
||||
// workspace.setPosition(design.getSwitchCategory());
|
||||
// }
|
||||
//
|
||||
// workspace.setId(null);
|
||||
// workspaceMapper.insert(workspace);
|
||||
//
|
||||
// QueryWrapper<CollectionElement> collectionElementQueryWrapper = new QueryWrapper<>();
|
||||
// collectionElementQueryWrapper.lambda().eq(CollectionElement::getCollectionId, userLikeGroup.getCollectionId());
|
||||
// List<CollectionElement> collectionElements = collectionElementMapper.selectList(collectionElementQueryWrapper);
|
||||
// for (CollectionElement collectionElement : collectionElements) {
|
||||
// collectionElement.setProjectId(project.getId());
|
||||
// collectionElementMapper.updateById(collectionElement);
|
||||
// }
|
||||
// Collection collection = collectionMapper.selectById(userLikeGroup.getCollectionId());
|
||||
// if (collection.getMoodTemplateId() != null) {
|
||||
// CollectionElement collectionElement = collectionElementMapper.selectById(collection.getMoodTemplateId());
|
||||
// collectionElement.setProjectId(userLikeGroup.getProjectId());
|
||||
// collectionElement.setIsCompositeImage(1);
|
||||
// collectionElementMapper.updateById(collectionElement);
|
||||
// }
|
||||
//
|
||||
// if (design.getModelType().equals("System")) {
|
||||
// SysFile sysFile = sysFileMapper.selectById(design.getTemplateId());
|
||||
//
|
||||
// CollectionElement collectionElement = new CollectionElement();
|
||||
// collectionElement.setAccountId(design.getAccountId());
|
||||
// collectionElement.setProjectId(project.getId());
|
||||
// collectionElement.setLevel1Type(CollectionLevel1TypeEnum.MODEL.getRealName());
|
||||
//// collectionElement.setLevel2Type(board.getLevel2Type());
|
||||
// collectionElement.setName(sysFile.getName());
|
||||
// collectionElement.setUrl(sysFile.getUrl());
|
||||
//// collectionElement.setHasPin(board.getIsPin());
|
||||
// collectionElement.setMd5(sysFile.getMd5());
|
||||
// collectionElement.setCreateDate(new Date());
|
||||
// collectionElement.setHasPin((byte) 0);
|
||||
// collectionElementMapper.insert(collectionElement);
|
||||
// CollectionElementRelModel collectionElementRelModel = new CollectionElementRelModel();
|
||||
// collectionElementRelModel.setCollectionElementId(collectionElement.getId());
|
||||
// collectionElementRelModel.setRelationId(sysFile.getId());
|
||||
// collectionElementRelModel.setRelationType("System");
|
||||
// collectionElementRelModelMapper.insert(collectionElementRelModel);
|
||||
// }else {
|
||||
// Library library = libraryMapper.selectById(design.getTemplateId());
|
||||
// CollectionElement collectionElement = new CollectionElement();
|
||||
// collectionElement.setAccountId(design.getAccountId());
|
||||
// collectionElement.setProjectId(project.getId());
|
||||
// collectionElement.setLevel1Type(CollectionLevel1TypeEnum.MODEL.getRealName());
|
||||
//// collectionElement.setLevel2Type(board.getLevel2Type());
|
||||
// collectionElement.setName(library.getName());
|
||||
// collectionElement.setUrl(library.getUrl());
|
||||
//// collectionElement.setHasPin(board.getIsPin());
|
||||
// collectionElement.setMd5(library.getMd5());
|
||||
// collectionElement.setCreateDate(new Date());
|
||||
// collectionElement.setHasPin((byte) 0);
|
||||
// collectionElementMapper.insert(collectionElement);
|
||||
// CollectionElementRelModel collectionElementRelModel = new CollectionElementRelModel();
|
||||
// collectionElementRelModel.setCollectionElementId(collectionElement.getId());
|
||||
// collectionElementRelModel.setRelationId(library.getId());
|
||||
// collectionElementRelModel.setRelationType("Library");
|
||||
// collectionElementRelModelMapper.insert(collectionElementRelModel);
|
||||
// }
|
||||
//
|
||||
// userLikeGroup.setProjectId(project.getId());
|
||||
// userLikeGroupMapper.updateById(userLikeGroup);
|
||||
// }
|
||||
// // 必须先完成project数据新增后再执行 toProductImage relight数据关联project
|
||||
// QueryWrapper<Project> projectQueryWrapper = new QueryWrapper<>();
|
||||
// List<Project> projects = projectMapper.selectList(projectQueryWrapper);
|
||||
// for (Project project : projects) {
|
||||
// UserLikeGroup userLikeGroup = userLikeGroupService.getByProjectId(project.getId());
|
||||
// if (Objects.nonNull(userLikeGroup)) {
|
||||
// Long userLikeGroupId = userLikeGroup.getId();
|
||||
// QueryWrapper<ToProductImageRecord> toProductImageRecordQueryWrapper = new QueryWrapper<>();
|
||||
// toProductImageRecordQueryWrapper.lambda().eq(ToProductImageRecord::getUserLikeGroupId, userLikeGroupId);
|
||||
// List<ToProductImageRecord> toProductImageRecords = toProductImageRecordMapper.selectList(toProductImageRecordQueryWrapper);
|
||||
// for (ToProductImageRecord toProductImageRecord : toProductImageRecords) {
|
||||
// toProductImageRecord.setProjectId(project.getId());
|
||||
// toProductImageRecordMapper.updateById(toProductImageRecord);
|
||||
// }
|
||||
//
|
||||
// QueryWrapper<ToProductImageResult> toProductImageResultQueryWrapper = new QueryWrapper<>();
|
||||
// toProductImageResultQueryWrapper.lambda().eq(ToProductImageResult::getUserLikeGroupId, userLikeGroupId);
|
||||
// List<ToProductImageResult> toProductImageResults = toProductImageResultMapper.selectList(toProductImageResultQueryWrapper);
|
||||
// for (ToProductImageResult toProductImageResult : toProductImageResults) {
|
||||
// toProductImageResult.setProjectId(project.getId());
|
||||
// toProductImageResultMapper.updateById(toProductImageResult);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// // 画布数据
|
||||
// QueryWrapper<ExportFile> exportFileQueryWrapper = new QueryWrapper<>();
|
||||
//// exportFileQueryWrapper.lambda().ge(ExportFile::getId, 10);
|
||||
//// exportFileQueryWrapper.lambda().le(ExportFile::getId, 86);
|
||||
// List<ExportFile> exportFiles = exportFileMapper.selectList(exportFileQueryWrapper);
|
||||
// for (ExportFile exportFile : exportFiles) {
|
||||
// Long userLikeGroupId = exportFile.getProjectId();
|
||||
// UserLikeGroup userLikeGroup = userLikeGroupMapper.selectById(userLikeGroupId);
|
||||
// if (Objects.nonNull(userLikeGroup)) {
|
||||
// exportFile.setProjectId(userLikeGroup.getProjectId());
|
||||
// exportFileMapper.updateById(exportFile);
|
||||
// }
|
||||
// }
|
||||
userLikeGroupConvertProject();
|
||||
|
||||
|
||||
// 必须先完成project数据新增后再执行 toProductImage relight数据关联project
|
||||
toProductRelightRelationProject();
|
||||
|
||||
// 画布数据
|
||||
canvasData();
|
||||
|
||||
// 作品关联数据转json数据
|
||||
// 作品关联projectId
|
||||
portfolioData();
|
||||
|
||||
}
|
||||
|
||||
private void portfolioData() {
|
||||
QueryWrapper<Portfolio> updateQueryWrapper = new QueryWrapper<>();
|
||||
updateQueryWrapper.lambda().eq(Portfolio::getOpenSource, 1);
|
||||
List<Portfolio> portfolioListUpdate = portfolioMapper.selectList(updateQueryWrapper);
|
||||
@@ -1692,6 +1564,153 @@ public class MyTaskScheduler {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void canvasData() {
|
||||
QueryWrapper<ExportFile> exportFileQueryWrapper = new QueryWrapper<>();
|
||||
// exportFileQueryWrapper.lambda().ge(ExportFile::getId, 10);
|
||||
// exportFileQueryWrapper.lambda().le(ExportFile::getId, 86);
|
||||
List<ExportFile> exportFiles = exportFileMapper.selectList(exportFileQueryWrapper);
|
||||
for (ExportFile exportFile : exportFiles) {
|
||||
Long userLikeGroupId = exportFile.getProjectId();
|
||||
UserLikeGroup userLikeGroup = userLikeGroupMapper.selectById(userLikeGroupId);
|
||||
if (Objects.nonNull(userLikeGroup)) {
|
||||
exportFile.setProjectId(userLikeGroup.getProjectId());
|
||||
exportFileMapper.updateById(exportFile);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void toProductRelightRelationProject() {
|
||||
QueryWrapper<Project> projectQueryWrapper = new QueryWrapper<>();
|
||||
List<Project> projects = projectMapper.selectList(projectQueryWrapper);
|
||||
for (Project project : projects) {
|
||||
UserLikeGroup userLikeGroup = userLikeGroupService.getByProjectId(project.getId());
|
||||
if (Objects.nonNull(userLikeGroup)) {
|
||||
Long userLikeGroupId = userLikeGroup.getId();
|
||||
QueryWrapper<ToProductImageRecord> toProductImageRecordQueryWrapper = new QueryWrapper<>();
|
||||
toProductImageRecordQueryWrapper.lambda().eq(ToProductImageRecord::getUserLikeGroupId, userLikeGroupId);
|
||||
List<ToProductImageRecord> toProductImageRecords = toProductImageRecordMapper.selectList(toProductImageRecordQueryWrapper);
|
||||
for (ToProductImageRecord toProductImageRecord : toProductImageRecords) {
|
||||
toProductImageRecord.setProjectId(project.getId());
|
||||
toProductImageRecordMapper.updateById(toProductImageRecord);
|
||||
}
|
||||
|
||||
QueryWrapper<ToProductImageResult> toProductImageResultQueryWrapper = new QueryWrapper<>();
|
||||
toProductImageResultQueryWrapper.lambda().eq(ToProductImageResult::getUserLikeGroupId, userLikeGroupId);
|
||||
List<ToProductImageResult> toProductImageResults = toProductImageResultMapper.selectList(toProductImageResultQueryWrapper);
|
||||
for (ToProductImageResult toProductImageResult : toProductImageResults) {
|
||||
toProductImageResult.setProjectId(project.getId());
|
||||
toProductImageResultMapper.updateById(toProductImageResult);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void userLikeGroupConvertProject() {
|
||||
QueryWrapper<UserLikeGroup> qw = new QueryWrapper<>();
|
||||
qw.lambda().ne(UserLikeGroup::getAccountId, -1);
|
||||
List<UserLikeGroup> userLikeGroups = userLikeGroupMapper.selectList(qw);
|
||||
for (UserLikeGroup userLikeGroup : userLikeGroups) {
|
||||
Project project = new Project();
|
||||
project.setAccountId(userLikeGroup.getAccountId());
|
||||
project.setName(userLikeGroup.getName());
|
||||
project.setCreateTime(LocalDateTime.ofInstant(userLikeGroup.getCreateDate().toInstant(), ZoneId.systemDefault()));
|
||||
project.setUpdateTime(LocalDateTime.ofInstant(userLikeGroup.getUpdateDate().toInstant(), ZoneId.systemDefault()));
|
||||
project.setOriginal(userLikeGroup.getOriginal());
|
||||
project.setOriginalAccountId(userLikeGroup.getOriginalAccountId());
|
||||
project.setOriginalPortfolioId(userLikeGroup.getOriginalPortfolioId());
|
||||
|
||||
QueryWrapper<Design> designQueryWrapper = new QueryWrapper<>();
|
||||
designQueryWrapper.lambda().eq(Design::getCollectionId, userLikeGroup.getCollectionId());
|
||||
Design design = designMapper.selectOne(designQueryWrapper);
|
||||
if (Objects.isNull(design)) {
|
||||
System.out.println(userLikeGroup.getCollectionId());
|
||||
continue;
|
||||
}
|
||||
if (design.getSingleOverall().equals("overall")) {
|
||||
project.setProcess(DesignProcess.SERIES_DESIGN.name());
|
||||
}else {
|
||||
project.setProcess(DesignProcess.SINGLE_DESIGN.name());
|
||||
}
|
||||
projectMapper.insert(project);
|
||||
Long accountId = userLikeGroup.getAccountId();
|
||||
QueryWrapper<Workspace> workspaceQueryWrapper = new QueryWrapper<>();
|
||||
workspaceQueryWrapper.lambda().eq(Workspace::getAccountId, accountId);
|
||||
workspaceQueryWrapper.lambda().eq(Workspace::getIsLastIndex, 1);
|
||||
Workspace workspace = workspaceMapper.selectOne(workspaceQueryWrapper);
|
||||
if (Objects.isNull(workspace)) {
|
||||
System.out.println(accountId);
|
||||
continue;
|
||||
}
|
||||
workspace.setIsLastIndex(0);
|
||||
workspace.setProjectId(project.getId());
|
||||
workspace.setSystemDesignerPercentage(design.getSystemScale().multiply(new BigDecimal("100")).setScale(0, RoundingMode.HALF_UP).intValueExact());
|
||||
if (!design.getSingleOverall().equals("overall")) {
|
||||
workspace.setPosition(design.getSwitchCategory());
|
||||
}
|
||||
|
||||
workspace.setId(null);
|
||||
workspaceMapper.insert(workspace);
|
||||
|
||||
QueryWrapper<CollectionElement> collectionElementQueryWrapper = new QueryWrapper<>();
|
||||
collectionElementQueryWrapper.lambda().eq(CollectionElement::getCollectionId, userLikeGroup.getCollectionId());
|
||||
List<CollectionElement> collectionElements = collectionElementMapper.selectList(collectionElementQueryWrapper);
|
||||
for (CollectionElement collectionElement : collectionElements) {
|
||||
collectionElement.setProjectId(project.getId());
|
||||
collectionElementMapper.updateById(collectionElement);
|
||||
}
|
||||
Collection collection = collectionMapper.selectById(userLikeGroup.getCollectionId());
|
||||
if (collection.getMoodTemplateId() != null) {
|
||||
CollectionElement collectionElement = collectionElementMapper.selectById(collection.getMoodTemplateId());
|
||||
collectionElement.setProjectId(userLikeGroup.getProjectId());
|
||||
collectionElement.setIsCompositeImage(1);
|
||||
collectionElementMapper.updateById(collectionElement);
|
||||
}
|
||||
|
||||
if (design.getModelType().equals("System")) {
|
||||
SysFile sysFile = sysFileMapper.selectById(design.getTemplateId());
|
||||
|
||||
CollectionElement collectionElement = new CollectionElement();
|
||||
collectionElement.setAccountId(design.getAccountId());
|
||||
collectionElement.setProjectId(project.getId());
|
||||
collectionElement.setLevel1Type(CollectionLevel1TypeEnum.MODEL.getRealName());
|
||||
// collectionElement.setLevel2Type(board.getLevel2Type());
|
||||
collectionElement.setName(sysFile.getName());
|
||||
collectionElement.setUrl(sysFile.getUrl());
|
||||
// collectionElement.setHasPin(board.getIsPin());
|
||||
collectionElement.setMd5(sysFile.getMd5());
|
||||
collectionElement.setCreateDate(new Date());
|
||||
collectionElement.setHasPin((byte) 0);
|
||||
collectionElementMapper.insert(collectionElement);
|
||||
CollectionElementRelModel collectionElementRelModel = new CollectionElementRelModel();
|
||||
collectionElementRelModel.setCollectionElementId(collectionElement.getId());
|
||||
collectionElementRelModel.setRelationId(sysFile.getId());
|
||||
collectionElementRelModel.setRelationType("System");
|
||||
collectionElementRelModelMapper.insert(collectionElementRelModel);
|
||||
}else {
|
||||
Library library = libraryMapper.selectById(design.getTemplateId());
|
||||
CollectionElement collectionElement = new CollectionElement();
|
||||
collectionElement.setAccountId(design.getAccountId());
|
||||
collectionElement.setProjectId(project.getId());
|
||||
collectionElement.setLevel1Type(CollectionLevel1TypeEnum.MODEL.getRealName());
|
||||
// collectionElement.setLevel2Type(board.getLevel2Type());
|
||||
collectionElement.setName(library.getName());
|
||||
collectionElement.setUrl(library.getUrl());
|
||||
// collectionElement.setHasPin(board.getIsPin());
|
||||
collectionElement.setMd5(library.getMd5());
|
||||
collectionElement.setCreateDate(new Date());
|
||||
collectionElement.setHasPin((byte) 0);
|
||||
collectionElementMapper.insert(collectionElement);
|
||||
CollectionElementRelModel collectionElementRelModel = new CollectionElementRelModel();
|
||||
collectionElementRelModel.setCollectionElementId(collectionElement.getId());
|
||||
collectionElementRelModel.setRelationId(library.getId());
|
||||
collectionElementRelModel.setRelationType("Library");
|
||||
collectionElementRelModelMapper.insert(collectionElementRelModel);
|
||||
}
|
||||
|
||||
userLikeGroup.setProjectId(project.getId());
|
||||
userLikeGroupMapper.updateById(userLikeGroup);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user