这篇文章主要为大家展示了“spring mybatis汇总统计处理的示例分析”,内容简而易懂,条理清晰,希望能够帮助大家解决疑惑,下面让小编带领大家一起研究并学习一下“spring mybatis汇总统计处理的示例分析”这篇文章吧。publ
这篇文章主要为大家展示了“spring mybatis汇总统计处理的示例分析”,内容简而易懂,条理清晰,希望能够帮助大家解决疑惑,下面让小编带领大家一起研究并学习一下“spring mybatis汇总统计处理的示例分析”这篇文章吧。
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汇总统计处理的示例分析”这篇文章的所有内容,感谢各位的阅读!相信大家都有了一定的了解,希望分享的内容对大家有所帮助,如果还想学习更多知识,欢迎关注编程网精选频道!
--结束END--
本文标题: spring mybatis汇总统计处理的示例分析
本文链接: https://lsjlt.com/news/231733.html(转载时请注明来源链接)
有问题或投稿请发送至: 邮箱/279061341@qq.com QQ/279061341
2024-05-24
2024-05-24
2024-05-24
2024-05-24
2024-05-24
2024-05-24
2024-05-24
2024-05-24
2024-05-24
2024-05-24
回答
回答
回答
回答
回答
回答
回答
回答
回答
回答
0