|
|
|
@ -13,8 +13,10 @@ import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
|
|
import com.google.common.collect.Lists; |
|
|
|
|
import com.hnac.hzims.common.constant.CommonConstant; |
|
|
|
|
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.config.MessageFactory; |
|
|
|
|
import com.hnac.hzims.message.constants.DictKeyConstants; |
|
|
|
|
import com.hnac.hzims.message.dto.BusinessMessageDTO; |
|
|
|
|
import com.hnac.hzims.message.dto.WxMessageDTO; |
|
|
|
|
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.SpringUtil; |
|
|
|
|
import org.springblade.system.cache.DictCache; |
|
|
|
|
import org.springblade.system.entity.Dict; |
|
|
|
|
import org.springblade.system.feign.ISysClient; |
|
|
|
|
import org.springblade.system.user.cache.UserCache; |
|
|
|
|
import org.springblade.system.user.entity.User; |
|
|
|
@ -56,6 +59,7 @@ import java.time.format.DateTimeFormatter;
|
|
|
|
|
import java.util.*; |
|
|
|
|
import java.util.concurrent.FutureTask; |
|
|
|
|
import java.util.stream.Collectors; |
|
|
|
|
import java.util.stream.IntStream; |
|
|
|
|
|
|
|
|
|
@Service |
|
|
|
|
@RequiredArgsConstructor |
|
|
|
@ -156,71 +160,37 @@ public class MessagePushRecordServiceImpl extends BaseServiceImpl<MessagePushRec
|
|
|
|
|
*/ |
|
|
|
|
@Override |
|
|
|
|
public List<MessagePushRecordTypeVo> smsPushStat(MessagePushRecordEntityVo vo) { |
|
|
|
|
List<MessagePushRecordTypeVo> result = Lists.newArrayList(); |
|
|
|
|
//根据type统计数量
|
|
|
|
|
List<MessagePushRecordVo> messagePushRecordVos = baseMapper.smsPushStat(vo); |
|
|
|
|
messagePushRecordVos.forEach(item -> { |
|
|
|
|
YearMonth strMonth = item.getStrMonth(); |
|
|
|
|
// 字符串转localDate 获取月份
|
|
|
|
|
item.setMonth(strMonth.getMonthValue()); |
|
|
|
|
item.setYear(strMonth.getYear()); |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
//按类型分组
|
|
|
|
|
Map<String, List<MessagePushRecordVo>> collect = messagePushRecordVos.stream().collect(Collectors.groupingBy(MessagePushRecordVo::getType)); |
|
|
|
|
|
|
|
|
|
List<MessagePushRecordTypeVo> messagePushRecordTypeVos = new ArrayList<>(); |
|
|
|
|
//封装数据
|
|
|
|
|
collect.forEach((key, value) -> { |
|
|
|
|
MessagePushRecordTypeVo messagePushRecordTypeVo = new MessagePushRecordTypeVo(); |
|
|
|
|
messagePushRecordTypeVo.setType(key); |
|
|
|
|
messagePushRecordTypeVo.setMessagePushRecordList(value); |
|
|
|
|
messagePushRecordTypeVos.add(messagePushRecordTypeVo); |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//封装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); |
|
|
|
|
List<Dict> types = DictCache.getList(DictKeyConstants.MESSAGE_TYPE); |
|
|
|
|
List<YearMonth> lastYearMonths = this.getLastYearMonths(); |
|
|
|
|
types.forEach(dict -> { |
|
|
|
|
MessagePushRecordTypeVo typeVO = new MessagePushRecordTypeVo(); |
|
|
|
|
typeVO.setType(dict.getDictKey()); |
|
|
|
|
typeVO.setTypeName(dict.getDictValue()); |
|
|
|
|
List<MessagePushRecordVo> recordVOList = lastYearMonths.stream().map(yearMonth -> { |
|
|
|
|
MessagePushRecordVo recordVO = new MessagePushRecordVo(); |
|
|
|
|
recordVO.setYear(yearMonth.getYear()); |
|
|
|
|
recordVO.setMonth(yearMonth.getMonthValue()); |
|
|
|
|
recordVO.setStrMonth(yearMonth); |
|
|
|
|
Long power = messagePushRecordVos.stream().filter(group -> group.getType().equals(dict.getDictKey()) && yearMonth.equals(group.getStrMonth())).findFirst().map(MessagePushRecordVo::getPower).orElse(0L); |
|
|
|
|
recordVO.setPower(power); |
|
|
|
|
return recordVO; |
|
|
|
|
}).collect(Collectors.toList()); |
|
|
|
|
typeVO.setMessagePushRecordList(recordVOList); |
|
|
|
|
result.add(typeVO); |
|
|
|
|
}); |
|
|
|
|
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 |
|
|
|
|
public List<BusinessTypeStatVo> businessTypeStat(MessagePushRecordEntityVo vo) { |
|
|
|
|
List<BusinessTypeStatVo> businessTypeStatVos = baseMapper.businessTypeStat(vo); |
|
|
|
|
businessTypeStatVos.forEach(item -> { |
|
|
|
|
String businessClassifyByName = this.getBusinessClassifyByName(item.getBusinessClassify()); |
|
|
|
|
item.setBusinessClassifyName(businessClassifyByName); |
|
|
|
|
}); |
|
|
|
|
return businessTypeStatVos; |
|
|
|
|
List<Dict> classifies = DictCache.getList(DictKeyConstants.BUSINESS_CLASSIFY); |
|
|
|
|
return classifies.stream().map(dict -> { |
|
|
|
|
BusinessTypeStatVo result = new BusinessTypeStatVo(); |
|
|
|
|
result.setBusinessClassify(dict.getDictKey()); |
|
|
|
|
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 |
|
|
|
|
public List<PushStatTypeVo> pushStat(MessagePushRecordEntityVo vo) { |
|
|
|
|
List<PushStatTypeVo> pushStatTypeVos = baseMapper.pushStat(vo); |
|
|
|
|
pushStatTypeVos.forEach(item -> { |
|
|
|
|
//查询出状态信息
|
|
|
|
|
List<Integer> statusList = baseMapper.selectByStatus(); |
|
|
|
|
//业务类型名称
|
|
|
|
|
String businessClassify = item.getBusinessClassify(); |
|
|
|
|
String businessTypeName = this.getBusinessClassifyByName(businessClassify); |
|
|
|
|
item.setBusinessClassifyName(businessTypeName); |
|
|
|
|
List<PushStatVo> pushStatList = item.getPushStatList(); |
|
|
|
|
List<PushStatVo> newPushStatList = new ArrayList<>(); |
|
|
|
|
for (PushStatVo pushStat : pushStatList) { |
|
|
|
|
//业务类型名称
|
|
|
|
|
String businessClassifyPushStat = pushStat.getBusinessClassify(); |
|
|
|
|
String businessTypeNamePushStat = this.getBusinessClassifyByName(businessClassifyPushStat); |
|
|
|
|
pushStat.setBusinessClassifyName(businessTypeNamePushStat); |
|
|
|
|
Integer status = pushStat.getStatus(); |
|
|
|
|
//如果list 包含这条数删除
|
|
|
|
|
statusList.remove(status); |
|
|
|
|
//状态名称
|
|
|
|
|
String name = this.getStatusByName(status); |
|
|
|
|
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; |
|
|
|
|
List<Dict> classifies = DictCache.getList(DictKeyConstants.BUSINESS_CLASSIFY); |
|
|
|
|
return classifies.stream().map(dict -> { |
|
|
|
|
PushStatTypeVo typeVO = new PushStatTypeVo(); |
|
|
|
|
typeVO.setBusinessClassify(dict.getDictKey()); |
|
|
|
|
typeVO.setBusinessClassifyName(dict.getDictValue()); |
|
|
|
|
List<PushStatVo> pushStatVoList = Arrays.stream(MessageConstants.MessagePushResultEnum.class.getEnumConstants()).map(pushResultTypeEnums -> { |
|
|
|
|
PushStatVo statVo = new PushStatVo(); |
|
|
|
|
statVo.setStatus(pushResultTypeEnums.getKey()); |
|
|
|
|
statVo.setStatusName(pushResultTypeEnums.getValue()); |
|
|
|
|
statVo.setBusinessClassify(dict.getDictKey()); |
|
|
|
|
statVo.setBusinessClassifyName(dict.getDictValue()); |
|
|
|
|
Optional<PushStatVo> statVO = pushStatTypeVos.stream().filter(group -> dict.getDictKey().equals(group.getBusinessClassify())) |
|
|
|
|
.flatMap(group -> group.getPushStatList().stream()).filter(stat -> stat.getStatus().equals(pushResultTypeEnums.getKey())).findFirst(); |
|
|
|
|
statVo.setPower(statVO.map(PushStatVo::getPower).orElse(0L)); |
|
|
|
|
return statVo; |
|
|
|
|
}).collect(Collectors.toList()); |
|
|
|
|
typeVO.setPushStatList(pushStatVoList); |
|
|
|
|
return typeVO; |
|
|
|
|
}).collect(Collectors.toList()); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|