Compare commits
No commits in common. "20e85cd3e9df534ae244a79641c15ef39508e25c" and "154ab7386bc41f9445294ecc8aee398f90f94cf1" have entirely different histories.
20e85cd3e9
...
154ab7386b
|
|
@ -14,7 +14,6 @@ import org.springframework.web.bind.annotation.PostMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
|
@ -163,9 +162,6 @@ public class SocialDirectoryController extends BaseController {
|
||||||
return success(socialItemService.pageList(pageNum,pageSize,keyword));
|
return success(socialItemService.pageList(pageNum,pageSize,keyword));
|
||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping("syncToMongo")
|
|
||||||
public Result<Object> syncToMongo() {
|
|
||||||
return success(socialDirectoryService.syncSocialDirectoryCache(parmsUtil.getInteger("page","请输入page")));
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -232,6 +232,7 @@ public class SocialDirectoryService extends BaseService {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* 搜索接口
|
* 搜索接口
|
||||||
* @param keyword 关键字
|
* @param keyword 关键字
|
||||||
|
|
@ -552,49 +553,4 @@ public class SocialDirectoryService extends BaseService {
|
||||||
return socialDirectoryMapper.selectMaps(codeqw);
|
return socialDirectoryMapper.selectMaps(codeqw);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public HashMap<String, Object> syncSocialDirectoryCache(int page) {
|
|
||||||
HashMap<String, Object> map = new HashMap<>();
|
|
||||||
|
|
||||||
int syncCount = 50000;
|
|
||||||
|
|
||||||
map.put("page",page);
|
|
||||||
|
|
||||||
String outString = "syncSocialDirectoryCache:"+"page:"+page+":";
|
|
||||||
|
|
||||||
DebugUtil.out(outString+"start");
|
|
||||||
|
|
||||||
initMongoDb();
|
|
||||||
|
|
||||||
if (page == 1)
|
|
||||||
{
|
|
||||||
mongoTemplate.dropCollection("social_directory");
|
|
||||||
|
|
||||||
long count = socialDirectoryMapper.selectCount(null);
|
|
||||||
|
|
||||||
DebugUtil.out(outString+"database_count:"+count);
|
|
||||||
|
|
||||||
map.put("total_count",(int)count);
|
|
||||||
|
|
||||||
int total_page = (int) Math.ceil((double) count / syncCount);
|
|
||||||
|
|
||||||
map.put("total_page",total_page);
|
|
||||||
|
|
||||||
DebugUtil.out(outString+"database_page:"+total_page);
|
|
||||||
}
|
|
||||||
|
|
||||||
QueryWrapper<SocialDirectory> queryWrapper = new QueryWrapper<>();
|
|
||||||
|
|
||||||
queryWrapper.last("limit "+syncCount+" offset " + (page - 1) * syncCount);
|
|
||||||
|
|
||||||
List<SocialDirectory> socialDirectoryList = socialDirectoryMapper.selectList(queryWrapper);
|
|
||||||
|
|
||||||
DebugUtil.out(outString+"database_select_success:"+socialDirectoryList.size());
|
|
||||||
|
|
||||||
saveListToMongoDb(socialDirectoryList);
|
|
||||||
|
|
||||||
DebugUtil.out(outString+"mongo_insert_success");
|
|
||||||
|
|
||||||
return map;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue