Compare commits
2 Commits
154ab7386b
...
20e85cd3e9
| Author | SHA1 | Date |
|---|---|---|
|
|
20e85cd3e9 | |
|
|
6986069333 |
|
|
@ -14,6 +14,7 @@ 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;
|
||||||
|
|
||||||
|
|
@ -162,6 +163,9 @@ 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,7 +232,6 @@ public class SocialDirectoryService extends BaseService {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* 搜索接口
|
* 搜索接口
|
||||||
* @param keyword 关键字
|
* @param keyword 关键字
|
||||||
|
|
@ -553,4 +552,49 @@ 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