|
@@ -0,0 +1,78 @@
|
|
|
+package com.citu.module.menduner.im.service.statistics;
|
|
|
+
|
|
|
+import com.citu.framework.common.pojo.CommonResult;
|
|
|
+import com.citu.module.menduner.im.controller.app.base.statistics.ImRecentConversationsStatisticsReqVo;
|
|
|
+import com.citu.module.menduner.im.controller.app.base.statistics.imRecentConversationsStatisticsRespVo;
|
|
|
+import com.citu.module.menduner.im.dal.mysql.statistics.ImRecentConversationsStatisticsMapper;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
+
|
|
|
+import java.math.BigDecimal;
|
|
|
+import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
+
|
|
|
+@Service
|
|
|
+public class ImRecentConversationsStatisticsServiceImpl implements ImRecentConversationsStatisticsService{
|
|
|
+
|
|
|
+ ImRecentConversationsStatisticsMapper mapper;
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public CommonResult imRecentConversationsStatistics(ImRecentConversationsStatisticsReqVo reqVo) {
|
|
|
+ imRecentConversationsStatisticsRespVo resp =new imRecentConversationsStatisticsRespVo();
|
|
|
+ BigDecimal bigDecimal =new BigDecimal("100");
|
|
|
+ reqVo.setCommunicateType(0); // 我发起的
|
|
|
+ List<Map<String, Long>> maps = mapper.imRecentConversationsStatistics(reqVo);
|
|
|
+ Long currentCount = 0L; // 本期数量
|
|
|
+ Long parentCount = 0L; // 上期数量
|
|
|
+ for (int i = 0; i < maps.size(); i++) {
|
|
|
+ Long count = maps.get(i).get("count");
|
|
|
+ if(i==0){
|
|
|
+ currentCount=count;
|
|
|
+ }
|
|
|
+ if(i==1){
|
|
|
+ parentCount=count;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ resp.setUsContactCount(currentCount);
|
|
|
+ if(currentCount-parentCount==0 ){
|
|
|
+ resp.setQqUsContactCount(0.0);
|
|
|
+ } else if (parentCount==0 ) {
|
|
|
+ resp.setQqUsContactCount(Double.valueOf(currentCount*100));
|
|
|
+ }else if(currentCount == 0){
|
|
|
+ resp.setQqUsContactCount(-Double.valueOf(currentCount*100));
|
|
|
+ }else {
|
|
|
+ resp.setQqUsContactCount(new BigDecimal(currentCount - parentCount).divide(new BigDecimal(parentCount), 2, BigDecimal.ROUND_HALF_UP).multiply(bigDecimal).doubleValue());
|
|
|
+ }
|
|
|
+ reqVo.setCommunicateType(1); // 我发起的
|
|
|
+ List<Map<String, Long>> maps2 = mapper.imRecentConversationsStatistics(reqVo);
|
|
|
+ currentCount = 0L;
|
|
|
+ parentCount = 0L;
|
|
|
+ for (int i = 0; i < maps.size(); i++) {
|
|
|
+ Long count = maps.get(i).get("count");
|
|
|
+ if(i==0){
|
|
|
+ currentCount=count;
|
|
|
+ }
|
|
|
+ if(i==1){
|
|
|
+ parentCount=count;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ resp.setActiveContactCount(currentCount);
|
|
|
+ if(currentCount-parentCount==0 || parentCount == 0 || currentCount ==0){
|
|
|
+ resp.setQqactiveContactCount(0.0);
|
|
|
+ }else if (parentCount==0 ) {
|
|
|
+ resp.setQqactiveContactCount(Double.valueOf(currentCount*100));
|
|
|
+ }else if(currentCount == 0){
|
|
|
+ resp.setQqactiveContactCount(-Double.valueOf(currentCount*100));
|
|
|
+ }else {
|
|
|
+ resp.setQqactiveContactCount(new BigDecimal(currentCount - parentCount).divide(new BigDecimal(parentCount), 2, BigDecimal.ROUND_HALF_UP).multiply(bigDecimal).doubleValue());
|
|
|
+ }
|
|
|
+ return CommonResult.success(resp);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ public void setMapper(ImRecentConversationsStatisticsMapper mapper) {
|
|
|
+ this.mapper = mapper;
|
|
|
+ }
|
|
|
+}
|