|
|
|
@ -1,7 +1,11 @@
|
|
|
|
|
package com.ruoyi.task;
|
|
|
|
|
|
|
|
|
|
import com.ruoyi.biemo.business.domain.Category;
|
|
|
|
|
import com.ruoyi.biemo.business.domain.DocInfo;
|
|
|
|
|
import com.ruoyi.biemo.business.domain.Report;
|
|
|
|
|
import com.ruoyi.biemo.business.service.CategoryService;
|
|
|
|
|
import com.ruoyi.biemo.business.service.DocInfoService;
|
|
|
|
|
import com.ruoyi.biemo.business.service.ReportService;
|
|
|
|
|
import com.ruoyi.biemo.mongodb.bean.Page;
|
|
|
|
|
import com.ruoyi.biemo.mongodb.utils.CriteriaAndWrapper;
|
|
|
|
|
import com.ruoyi.biemo.mongodb.utils.MongoHelper;
|
|
|
|
@ -15,7 +19,10 @@ public class SyncData {
|
|
|
|
|
MongoHelper mongoHelper;
|
|
|
|
|
@Autowired
|
|
|
|
|
DocInfoService docInfoService;
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
CategoryService categoryService;
|
|
|
|
|
@Autowired
|
|
|
|
|
ReportService reportService;
|
|
|
|
|
public void mongoToEs(){
|
|
|
|
|
Page<DocInfo> page = new Page();
|
|
|
|
|
Page<DocInfo> pageInfo = mongoHelper.findPage(new CriteriaAndWrapper().eq(DocInfo::getIsSync,0),page, DocInfo.class);
|
|
|
|
@ -24,15 +31,40 @@ public class SyncData {
|
|
|
|
|
docInfos.forEach(docInfo -> {
|
|
|
|
|
docInfo.setCreatedBy(1L);
|
|
|
|
|
docInfo.setUpdatedBy(1L);
|
|
|
|
|
docInfoService.insertEs(docInfo);
|
|
|
|
|
docInfo.setCreateTime(System.currentTimeMillis());
|
|
|
|
|
docInfo.setUpdateTime(System.currentTimeMillis());
|
|
|
|
|
docInfo.setIsSync(1);
|
|
|
|
|
docInfoService.insertOrUpdateDocInfo(docInfo);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void mysqlToMongo(){
|
|
|
|
|
public void categoryToEs(){
|
|
|
|
|
Page<Category> page = new Page();
|
|
|
|
|
Page<Category> pageInfo = mongoHelper.findPage(new CriteriaAndWrapper().eq(Category::getIsSync,0),page, Category.class);
|
|
|
|
|
List<Category> categories = pageInfo.getList();
|
|
|
|
|
if(categories!=null&& categories.size()>0){
|
|
|
|
|
categories.forEach(category -> {
|
|
|
|
|
category.setCreatedBy(1L);
|
|
|
|
|
category.setUpdatedBy(1L);
|
|
|
|
|
category.setIsSync(1);
|
|
|
|
|
categoryService.insertOrUpdateCategory(category);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void reportToEs(){
|
|
|
|
|
Page<Report> page = new Page();
|
|
|
|
|
Page<Report> pageInfo = mongoHelper.findPage(new CriteriaAndWrapper().eq(Report::getIsSync,0),page, Report.class);
|
|
|
|
|
List<Report> reports = pageInfo.getList();
|
|
|
|
|
if(reports!=null&& reports.size()>0){
|
|
|
|
|
reports.forEach(report -> {
|
|
|
|
|
report.setCreatedBy(1L);
|
|
|
|
|
report.setUpdatedBy(1L);
|
|
|
|
|
report.setIsSync(1);
|
|
|
|
|
reportService.insertOrUpdateReport(report);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|