public PageInfo getCenterInvestAnswerSum(GetCenterInvestSumReq askReq)
throws BusinessException {
PageInfo pageResult = new PageInfo();
final String METHOD = "getCenterAskInvestSum";
try {
PageHelper.startPage(askReq.getPageNum(), askReq.getPageSize());
LogUtil.logInput(LOG_TYPE.BIZ.val, this, METHOD, askReq);
// 1.如果存在投顾,es查询投顾信息
List adviserIdList = null;
Map adviserMap = null;
if (StringUtils.hasLength(askReq.getInvestAdviserName())) {
AdviserEsReq adviserEsReq = new AdviserEsReq();
adviserEsReq.setInvestAdviserName(askReq.getInvestAdviserName());
adviserEsReq.setPageSize(1000);
PageInfo pageInfo = AdviserEsUtils.findByParams(adviserEsReq);
if (CollectionUtils.isEmpty(pageInfo.getList())) {
return pageResult;
}
adviserIdList = new ArrayList();
adviserMap = new HashMap();
for (VdInvestAdviser adviser : pageInfo.getList()) {
adviserIdList.add(adviser.getId());
adviserMap.put(adviser.getId(), adviser);
}
}
// 2.查询需要统计的问股数据
AskStockStatisticsReq statisticsReq = new AskStockStatisticsReq();
statisticsReq.setBeginDate(DateUtils.toDate(askReq.getStartDate(), DateFormat.YEAR_MONTH_DAY));
statisticsReq.setEndDate(
DateUtils.nextDays(DateUtils.toDate(askReq.getEndDate(), DateFormat.YEAR_MONTH_DAY), 1));
statisticsReq.setAdviserIdList(adviserIdList);
List askList = this.apAskExtMapper.findByCreateTime(statisticsReq);
if (CollectionUtils.isEmpty(askList)) {
return pageResult;
}
// 3.判断是否需要查询投顾信息,用户未根据投顾姓名搜索则需要重新查询投顾信息
if (CollectionUtils.isEmpty(adviserIdList)) {
adviserIdList = new ArrayList();// 最后循环组数据要用
Set adviserIdSet = new HashSet();// 去重用
adviserMap = new HashMap();
askList.forEach(ask -> {
adviserIdSet.add(ask.getAdviserId());
});
adviserIdList.addAll(adviserIdSet);
List adviserList = AdviserEsUtils.findByIds(adviserIdList);
for (VdInvestAdviser adviser : adviserList) {
adviserMap.put(adviser.getId(), adviser);
}
}
// 4.统计数据
Map askCountMap = new HashMap();// 提问数map
Map answerCountMap = new HashMap();// 解答数map
Map reportCountMap = new HashMap();// 举报数map
Map qualifiedCountMap = new HashMap();// 合格数map
Map complianceCountMap = new HashMap();// 合规数map
askList.forEach(ask -> {
Long key = ask.getAdviserId();
setDataMap(askCountMap, key, 1);
if (ask.getAnswerFlag() != null && ask.getAnswerFlag()) {
setDataMap(answerCountMap, key, 1);
}
if (ask.getReportFlag() != null && ask.getReportFlag()) {
setDataMap(reportCountMap, key, 1);
}
if (ask.getQualifiedFlag() != null && ask.getQualifiedFlag()) {
setDataMap(qualifiedCountMap, key, 1);
}
if (ask.getComplianceFlag() != null && ask.getComplianceFlag()) {
setDataMap(complianceCountMap, key, 1);
}
});
// 5.组返回页面数据
List resultList = new ArrayList();
for (Long adviserId : adviserIdList) {
VdInvestAdviser adviser = adviserMap.get(adviserId);
GetCenterInvestSumRes res = new GetCenterInvestSumRes();
res.setAdviserId(adviserId);
res.setInvestAdviserName(adviser.getInvestAdviserName());
res.setInvestAdviserDept(adviser.getInvestAdviserDept());
res.setSatisfied(adviser.getAverageSatisfied());
res.setYybCode(adviser.getYybCode());
res.setAskAdviserCount(answerCountMap.containsKey(adviserId) ? answerCountMap.get(adviserId) : 0);
res.setAskCount(askCountMap.containsKey(adviserId) ? askCountMap.get(adviserId) : 0);
res.setQualifiedCount(qualifiedCountMap.containsKey(adviserId) ? qualifiedCountMap.get(adviserId) : 0);
res.setComplianceCount(
complianceCountMap.containsKey(adviserId) ? complianceCountMap.get(adviserId) : 0);
res.setReportFlagCount(reportCountMap.containsKey(adviserId) ? reportCountMap.get(adviserId) : 0);
resultList.add(res);
}
pageResult.setList(resultList);
} catch (Exception e) {
LogUtil.logError(LOG_TYPE.BIZ.val, this, METHOD, e);
throw ExceptionUtil.generateException("统计解答问股的投股信息", e);
}
return pageResult;
}
throws BusinessException {
PageInfo pageResult = new PageInfo();
final String METHOD = "getCenterAskInvestSum";
try {
PageHelper.startPage(askReq.getPageNum(), askReq.getPageSize());
LogUtil.logInput(LOG_TYPE.BIZ.val, this, METHOD, askReq);
// 1.如果存在投顾,es查询投顾信息
List adviserIdList = null;
Map adviserMap = null;
if (StringUtils.hasLength(askReq.getInvestAdviserName())) {
AdviserEsReq adviserEsReq = new AdviserEsReq();
adviserEsReq.setInvestAdviserName(askReq.getInvestAdviserName());
adviserEsReq.setPageSize(1000);
PageInfo pageInfo = AdviserEsUtils.findByParams(adviserEsReq);
if (CollectionUtils.isEmpty(pageInfo.getList())) {
return pageResult;
}
adviserIdList = new ArrayList();
adviserMap = new HashMap();
for (VdInvestAdviser adviser : pageInfo.getList()) {
adviserIdList.add(adviser.getId());
adviserMap.put(adviser.getId(), adviser);
}
}
// 2.查询需要统计的问股数据
AskStockStatisticsReq statisticsReq = new AskStockStatisticsReq();
statisticsReq.setBeginDate(DateUtils.toDate(askReq.getStartDate(), DateFormat.YEAR_MONTH_DAY));
statisticsReq.setEndDate(
DateUtils.nextDays(DateUtils.toDate(askReq.getEndDate(), DateFormat.YEAR_MONTH_DAY), 1));
statisticsReq.setAdviserIdList(adviserIdList);
List askList = this.apAskExtMapper.findByCreateTime(statisticsReq);
if (CollectionUtils.isEmpty(askList)) {
return pageResult;
}
// 3.判断是否需要查询投顾信息,用户未根据投顾姓名搜索则需要重新查询投顾信息
if (CollectionUtils.isEmpty(adviserIdList)) {
adviserIdList = new ArrayList();// 最后循环组数据要用
Set adviserIdSet = new HashSet();// 去重用
adviserMap = new HashMap();
askList.forEach(ask -> {
adviserIdSet.add(ask.getAdviserId());
});
adviserIdList.addAll(adviserIdSet);
List adviserList = AdviserEsUtils.findByIds(adviserIdList);
for (VdInvestAdviser adviser : adviserList) {
adviserMap.put(adviser.getId(), adviser);
}
}
// 4.统计数据
Map askCountMap = new HashMap();// 提问数map
Map answerCountMap = new HashMap();// 解答数map
Map reportCountMap = new HashMap();// 举报数map
Map qualifiedCountMap = new HashMap();// 合格数map
Map complianceCountMap = new HashMap();// 合规数map
askList.forEach(ask -> {
Long key = ask.getAdviserId();
setDataMap(askCountMap, key, 1);
if (ask.getAnswerFlag() != null && ask.getAnswerFlag()) {
setDataMap(answerCountMap, key, 1);
}
if (ask.getReportFlag() != null && ask.getReportFlag()) {
setDataMap(reportCountMap, key, 1);
}
if (ask.getQualifiedFlag() != null && ask.getQualifiedFlag()) {
setDataMap(qualifiedCountMap, key, 1);
}
if (ask.getComplianceFlag() != null && ask.getComplianceFlag()) {
setDataMap(complianceCountMap, key, 1);
}
});
// 5.组返回页面数据
List resultList = new ArrayList();
for (Long adviserId : adviserIdList) {
VdInvestAdviser adviser = adviserMap.get(adviserId);
GetCenterInvestSumRes res = new GetCenterInvestSumRes();
res.setAdviserId(adviserId);
res.setInvestAdviserName(adviser.getInvestAdviserName());
res.setInvestAdviserDept(adviser.getInvestAdviserDept());
res.setSatisfied(adviser.getAverageSatisfied());
res.setYybCode(adviser.getYybCode());
res.setAskAdviserCount(answerCountMap.containsKey(adviserId) ? answerCountMap.get(adviserId) : 0);
res.setAskCount(askCountMap.containsKey(adviserId) ? askCountMap.get(adviserId) : 0);
res.setQualifiedCount(qualifiedCountMap.containsKey(adviserId) ? qualifiedCountMap.get(adviserId) : 0);
res.setComplianceCount(
complianceCountMap.containsKey(adviserId) ? complianceCountMap.get(adviserId) : 0);
res.setReportFlagCount(reportCountMap.containsKey(adviserId) ? reportCountMap.get(adviserId) : 0);
resultList.add(res);
}
pageResult.setList(resultList);
} catch (Exception e) {
LogUtil.logError(LOG_TYPE.BIZ.val, this, METHOD, e);
throw ExceptionUtil.generateException("统计解答问股的投股信息", e);
}
return pageResult;
}
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/30180323/viewspace-2149227/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/30180323/viewspace-2149227/