springmybatis汇总统计处理的示例分析
这篇文章主要为大家展示了“spring mybatis汇总统计处理的示例分析”,内容简而易懂,条理清晰,希望能够帮助大家解决疑惑,下面让小编带领大家一起研究并学习一下“spring mybatis汇总统计处理的示例分析”这篇文章吧。
10年积累的网站建设、成都网站制作经验,可以快速应对客户对网站的新想法和需求。提供各种问题对应的解决方案。让选择我们的客户得到更好、更有力的网络服务。我虽然不认识你,你也不认识我。但先网站设计后付款的网站建设流程,更有闽侯免费网站建设让你可以放心的选择与我们合作。
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; }
以上是“spring mybatis汇总统计处理的示例分析”这篇文章的所有内容,感谢各位的阅读!相信大家都有了一定的了解,希望分享的内容对大家有所帮助,如果还想学习更多知识,欢迎关注创新互联行业资讯频道!
名称栏目:springmybatis汇总统计处理的示例分析
地址分享:http://myzitong.com/article/picpes.html