|
|
@ -13,8 +13,10 @@ import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
|
|
|
import com.google.common.collect.Lists; |
|
|
|
import com.google.common.collect.Lists; |
|
|
|
import com.hnac.hzims.common.constant.CommonConstant; |
|
|
|
import com.hnac.hzims.common.constant.CommonConstant; |
|
|
|
import com.hnac.hzims.common.utils.CacheUtil; |
|
|
|
import com.hnac.hzims.common.utils.CacheUtil; |
|
|
|
|
|
|
|
import com.hnac.hzims.common.utils.DateUtil; |
|
|
|
import com.hnac.hzims.message.MessageConstants; |
|
|
|
import com.hnac.hzims.message.MessageConstants; |
|
|
|
import com.hnac.hzims.message.config.MessageFactory; |
|
|
|
import com.hnac.hzims.message.config.MessageFactory; |
|
|
|
|
|
|
|
import com.hnac.hzims.message.constants.DictKeyConstants; |
|
|
|
import com.hnac.hzims.message.dto.BusinessMessageDTO; |
|
|
|
import com.hnac.hzims.message.dto.BusinessMessageDTO; |
|
|
|
import com.hnac.hzims.message.dto.WxMessageDTO; |
|
|
|
import com.hnac.hzims.message.dto.WxMessageDTO; |
|
|
|
import com.hnac.hzims.message.entity.MessagePushRecordEntity; |
|
|
|
import com.hnac.hzims.message.entity.MessagePushRecordEntity; |
|
|
@ -41,6 +43,7 @@ import org.springblade.core.tool.utils.BeanUtil; |
|
|
|
import org.springblade.core.tool.utils.Func; |
|
|
|
import org.springblade.core.tool.utils.Func; |
|
|
|
import org.springblade.core.tool.utils.SpringUtil; |
|
|
|
import org.springblade.core.tool.utils.SpringUtil; |
|
|
|
import org.springblade.system.cache.DictCache; |
|
|
|
import org.springblade.system.cache.DictCache; |
|
|
|
|
|
|
|
import org.springblade.system.entity.Dict; |
|
|
|
import org.springblade.system.feign.ISysClient; |
|
|
|
import org.springblade.system.feign.ISysClient; |
|
|
|
import org.springblade.system.user.cache.UserCache; |
|
|
|
import org.springblade.system.user.cache.UserCache; |
|
|
|
import org.springblade.system.user.entity.User; |
|
|
|
import org.springblade.system.user.entity.User; |
|
|
@ -56,6 +59,7 @@ import java.time.format.DateTimeFormatter; |
|
|
|
import java.util.*; |
|
|
|
import java.util.*; |
|
|
|
import java.util.concurrent.FutureTask; |
|
|
|
import java.util.concurrent.FutureTask; |
|
|
|
import java.util.stream.Collectors; |
|
|
|
import java.util.stream.Collectors; |
|
|
|
|
|
|
|
import java.util.stream.IntStream; |
|
|
|
|
|
|
|
|
|
|
|
@Service |
|
|
|
@Service |
|
|
|
@RequiredArgsConstructor |
|
|
|
@RequiredArgsConstructor |
|
|
@ -156,71 +160,37 @@ public class MessagePushRecordServiceImpl extends BaseServiceImpl<MessagePushRec |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public List<MessagePushRecordTypeVo> smsPushStat(MessagePushRecordEntityVo vo) { |
|
|
|
public List<MessagePushRecordTypeVo> smsPushStat(MessagePushRecordEntityVo vo) { |
|
|
|
|
|
|
|
List<MessagePushRecordTypeVo> result = Lists.newArrayList(); |
|
|
|
//根据type统计数量
|
|
|
|
//根据type统计数量
|
|
|
|
List<MessagePushRecordVo> messagePushRecordVos = baseMapper.smsPushStat(vo); |
|
|
|
List<MessagePushRecordVo> messagePushRecordVos = baseMapper.smsPushStat(vo); |
|
|
|
messagePushRecordVos.forEach(item -> { |
|
|
|
List<Dict> types = DictCache.getList(DictKeyConstants.MESSAGE_TYPE); |
|
|
|
YearMonth strMonth = item.getStrMonth(); |
|
|
|
List<YearMonth> lastYearMonths = this.getLastYearMonths(); |
|
|
|
// 字符串转localDate 获取月份
|
|
|
|
types.forEach(dict -> { |
|
|
|
item.setMonth(strMonth.getMonthValue()); |
|
|
|
MessagePushRecordTypeVo typeVO = new MessagePushRecordTypeVo(); |
|
|
|
item.setYear(strMonth.getYear()); |
|
|
|
typeVO.setType(dict.getDictKey()); |
|
|
|
}); |
|
|
|
typeVO.setTypeName(dict.getDictValue()); |
|
|
|
|
|
|
|
List<MessagePushRecordVo> recordVOList = lastYearMonths.stream().map(yearMonth -> { |
|
|
|
//按类型分组
|
|
|
|
MessagePushRecordVo recordVO = new MessagePushRecordVo(); |
|
|
|
Map<String, List<MessagePushRecordVo>> collect = messagePushRecordVos.stream().collect(Collectors.groupingBy(MessagePushRecordVo::getType)); |
|
|
|
recordVO.setYear(yearMonth.getYear()); |
|
|
|
|
|
|
|
recordVO.setMonth(yearMonth.getMonthValue()); |
|
|
|
List<MessagePushRecordTypeVo> messagePushRecordTypeVos = new ArrayList<>(); |
|
|
|
recordVO.setStrMonth(yearMonth); |
|
|
|
//封装数据
|
|
|
|
Long power = messagePushRecordVos.stream().filter(group -> group.getType().equals(dict.getDictKey()) && yearMonth.equals(group.getStrMonth())).findFirst().map(MessagePushRecordVo::getPower).orElse(0L); |
|
|
|
collect.forEach((key, value) -> { |
|
|
|
recordVO.setPower(power); |
|
|
|
MessagePushRecordTypeVo messagePushRecordTypeVo = new MessagePushRecordTypeVo(); |
|
|
|
return recordVO; |
|
|
|
messagePushRecordTypeVo.setType(key); |
|
|
|
}).collect(Collectors.toList()); |
|
|
|
messagePushRecordTypeVo.setMessagePushRecordList(value); |
|
|
|
typeVO.setMessagePushRecordList(recordVOList); |
|
|
|
messagePushRecordTypeVos.add(messagePushRecordTypeVo); |
|
|
|
result.add(typeVO); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//封装typeName的数据
|
|
|
|
|
|
|
|
messagePushRecordTypeVos.forEach(item1 -> { |
|
|
|
|
|
|
|
List<MessagePushRecordVo> messagePushRecordList = item1.getMessagePushRecordList(); |
|
|
|
|
|
|
|
//String messageType = DictCache.getValue("messageType", item1.getType());
|
|
|
|
|
|
|
|
//System.out.println("messageType = " + messageType);
|
|
|
|
|
|
|
|
String typeByName = getTypeByName(item1.getType()); |
|
|
|
|
|
|
|
item1.setTypeName(typeByName); |
|
|
|
|
|
|
|
//获取以往12个月的数据
|
|
|
|
|
|
|
|
List<YearMonth> previousMonth = this.getPreviousMonth(); |
|
|
|
|
|
|
|
//创建新的数组 List<MessagePushRecordVo>
|
|
|
|
|
|
|
|
List<MessagePushRecordVo> lists = new ArrayList<>(); |
|
|
|
|
|
|
|
messagePushRecordList.forEach(item2 -> { |
|
|
|
|
|
|
|
YearMonth strMonth = item2.getStrMonth(); |
|
|
|
|
|
|
|
// 字符串转localDate 获取月份
|
|
|
|
|
|
|
|
item2.setMonth(strMonth.getMonthValue()); |
|
|
|
|
|
|
|
item2.setYear(strMonth.getYear()); |
|
|
|
|
|
|
|
previousMonth.remove(strMonth); |
|
|
|
|
|
|
|
//封装typeValue
|
|
|
|
|
|
|
|
item2.setTypeName(typeByName); |
|
|
|
|
|
|
|
lists.add(item2); |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//如果还存在YearMonth,把MessagePushRecordVo添加到新的数组 List<MessagePushRecordVo>
|
|
|
|
|
|
|
|
if (CollectionUtils.isNotEmpty(previousMonth)) { |
|
|
|
|
|
|
|
for (YearMonth yearMonth : previousMonth) { |
|
|
|
|
|
|
|
MessagePushRecordVo messagePushRecordVo = new MessagePushRecordVo(); |
|
|
|
|
|
|
|
messagePushRecordVo.setYear(yearMonth.getYear()); |
|
|
|
|
|
|
|
messagePushRecordVo.setMonth(yearMonth.getMonthValue()); |
|
|
|
|
|
|
|
messagePushRecordVo.setType(item1.getType()); |
|
|
|
|
|
|
|
messagePushRecordVo.setPower(0L); |
|
|
|
|
|
|
|
messagePushRecordVo.setStrMonth(yearMonth); |
|
|
|
|
|
|
|
//封装typeValue
|
|
|
|
|
|
|
|
messagePushRecordVo.setTypeName(typeByName); |
|
|
|
|
|
|
|
lists.add(messagePushRecordVo); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
List<MessagePushRecordVo> newLists = lists.stream().sorted(Comparator.comparing(MessagePushRecordVo::getStrMonth).reversed()).collect(Collectors.toList()); |
|
|
|
|
|
|
|
// 封装到 setMessagePushRecordList
|
|
|
|
|
|
|
|
item1.setMessagePushRecordList(newLists); |
|
|
|
|
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
return result; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
return messagePushRecordTypeVos; |
|
|
|
* 获取从当前月份开始过去一年内的月份 |
|
|
|
|
|
|
|
* @return 过去一年的月份 |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
private List<YearMonth> getLastYearMonths () { |
|
|
|
|
|
|
|
YearMonth now = YearMonth.now(); |
|
|
|
|
|
|
|
return IntStream.iterate(0,index -> index + 1).limit(12).mapToObj(index -> now.minusMonths(index)).collect(Collectors.toList()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
@ -231,11 +201,14 @@ public class MessagePushRecordServiceImpl extends BaseServiceImpl<MessagePushRec |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public List<BusinessTypeStatVo> businessTypeStat(MessagePushRecordEntityVo vo) { |
|
|
|
public List<BusinessTypeStatVo> businessTypeStat(MessagePushRecordEntityVo vo) { |
|
|
|
List<BusinessTypeStatVo> businessTypeStatVos = baseMapper.businessTypeStat(vo); |
|
|
|
List<BusinessTypeStatVo> businessTypeStatVos = baseMapper.businessTypeStat(vo); |
|
|
|
businessTypeStatVos.forEach(item -> { |
|
|
|
List<Dict> classifies = DictCache.getList(DictKeyConstants.BUSINESS_CLASSIFY); |
|
|
|
String businessClassifyByName = this.getBusinessClassifyByName(item.getBusinessClassify()); |
|
|
|
return classifies.stream().map(dict -> { |
|
|
|
item.setBusinessClassifyName(businessClassifyByName); |
|
|
|
BusinessTypeStatVo result = new BusinessTypeStatVo(); |
|
|
|
}); |
|
|
|
result.setBusinessClassify(dict.getDictKey()); |
|
|
|
return businessTypeStatVos; |
|
|
|
result.setBusinessClassifyName(dict.getDictValue()); |
|
|
|
|
|
|
|
result.setPower(businessTypeStatVos.stream().filter(stat -> dict.getDictKey().equals(stat.getBusinessClassify())).map(BusinessTypeStatVo::getPower).findFirst().orElse(0L)); |
|
|
|
|
|
|
|
return result; |
|
|
|
|
|
|
|
}).collect(Collectors.toList()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
@ -459,45 +432,25 @@ public class MessagePushRecordServiceImpl extends BaseServiceImpl<MessagePushRec |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public List<PushStatTypeVo> pushStat(MessagePushRecordEntityVo vo) { |
|
|
|
public List<PushStatTypeVo> pushStat(MessagePushRecordEntityVo vo) { |
|
|
|
List<PushStatTypeVo> pushStatTypeVos = baseMapper.pushStat(vo); |
|
|
|
List<PushStatTypeVo> pushStatTypeVos = baseMapper.pushStat(vo); |
|
|
|
pushStatTypeVos.forEach(item -> { |
|
|
|
List<Dict> classifies = DictCache.getList(DictKeyConstants.BUSINESS_CLASSIFY); |
|
|
|
//查询出状态信息
|
|
|
|
return classifies.stream().map(dict -> { |
|
|
|
List<Integer> statusList = baseMapper.selectByStatus(); |
|
|
|
PushStatTypeVo typeVO = new PushStatTypeVo(); |
|
|
|
//业务类型名称
|
|
|
|
typeVO.setBusinessClassify(dict.getDictKey()); |
|
|
|
String businessClassify = item.getBusinessClassify(); |
|
|
|
typeVO.setBusinessClassifyName(dict.getDictValue()); |
|
|
|
String businessTypeName = this.getBusinessClassifyByName(businessClassify); |
|
|
|
List<PushStatVo> pushStatVoList = Arrays.stream(MessageConstants.MessagePushResultEnum.class.getEnumConstants()).map(pushResultTypeEnums -> { |
|
|
|
item.setBusinessClassifyName(businessTypeName); |
|
|
|
PushStatVo statVo = new PushStatVo(); |
|
|
|
List<PushStatVo> pushStatList = item.getPushStatList(); |
|
|
|
statVo.setStatus(pushResultTypeEnums.getKey()); |
|
|
|
List<PushStatVo> newPushStatList = new ArrayList<>(); |
|
|
|
statVo.setStatusName(pushResultTypeEnums.getValue()); |
|
|
|
for (PushStatVo pushStat : pushStatList) { |
|
|
|
statVo.setBusinessClassify(dict.getDictKey()); |
|
|
|
//业务类型名称
|
|
|
|
statVo.setBusinessClassifyName(dict.getDictValue()); |
|
|
|
String businessClassifyPushStat = pushStat.getBusinessClassify(); |
|
|
|
Optional<PushStatVo> statVO = pushStatTypeVos.stream().filter(group -> dict.getDictKey().equals(group.getBusinessClassify())) |
|
|
|
String businessTypeNamePushStat = this.getBusinessClassifyByName(businessClassifyPushStat); |
|
|
|
.flatMap(group -> group.getPushStatList().stream()).filter(stat -> stat.getStatus().equals(pushResultTypeEnums.getKey())).findFirst(); |
|
|
|
pushStat.setBusinessClassifyName(businessTypeNamePushStat); |
|
|
|
statVo.setPower(statVO.map(PushStatVo::getPower).orElse(0L)); |
|
|
|
Integer status = pushStat.getStatus(); |
|
|
|
return statVo; |
|
|
|
//如果list 包含这条数删除
|
|
|
|
}).collect(Collectors.toList()); |
|
|
|
statusList.remove(status); |
|
|
|
typeVO.setPushStatList(pushStatVoList); |
|
|
|
//状态名称
|
|
|
|
return typeVO; |
|
|
|
String name = this.getStatusByName(status); |
|
|
|
}).collect(Collectors.toList()); |
|
|
|
pushStat.setStatusName(name); |
|
|
|
|
|
|
|
newPushStatList.add(pushStat); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
//如何list不为空补0
|
|
|
|
|
|
|
|
if (CollectionUtils.isNotEmpty(statusList)) { |
|
|
|
|
|
|
|
for (int i = 0; i < statusList.size(); i++) { |
|
|
|
|
|
|
|
PushStatVo pushStat = new PushStatVo(); |
|
|
|
|
|
|
|
int status = statusList.get(i); |
|
|
|
|
|
|
|
pushStat.setStatus(status); |
|
|
|
|
|
|
|
pushStat.setPower(0L); |
|
|
|
|
|
|
|
pushStat.setBusinessClassify(businessClassify); |
|
|
|
|
|
|
|
pushStat.setBusinessClassifyName(businessTypeName); |
|
|
|
|
|
|
|
pushStat.setStatusName(this.getStatusByName(status)); |
|
|
|
|
|
|
|
newPushStatList.add(pushStat); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
item.setPushStatList(newPushStatList); |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
return pushStatTypeVos; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|