|
|
@ -14,6 +14,7 @@ import com.google.common.collect.Lists; |
|
|
|
import com.hnac.hzims.common.utils.CacheUtil; |
|
|
|
import com.hnac.hzims.common.utils.CacheUtil; |
|
|
|
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.dto.BusinessMessageDTO; |
|
|
|
import com.hnac.hzims.message.entity.MessagePushRecordEntity; |
|
|
|
import com.hnac.hzims.message.entity.MessagePushRecordEntity; |
|
|
|
import com.hnac.hzims.message.enums.PushStatEnum; |
|
|
|
import com.hnac.hzims.message.enums.PushStatEnum; |
|
|
|
import com.hnac.hzims.message.mapper.MessagePushRecordMapper; |
|
|
|
import com.hnac.hzims.message.mapper.MessagePushRecordMapper; |
|
|
@ -22,29 +23,25 @@ import com.hnac.hzims.message.service.IMessagePushRecordService; |
|
|
|
import com.hnac.hzims.message.service.IMessageService; |
|
|
|
import com.hnac.hzims.message.service.IMessageService; |
|
|
|
import com.hnac.hzims.message.vo.UnreadMessageVO; |
|
|
|
import com.hnac.hzims.message.vo.UnreadMessageVO; |
|
|
|
import com.hnac.hzims.message.vo.msgpushrecord.*; |
|
|
|
import com.hnac.hzims.message.vo.msgpushrecord.*; |
|
|
|
|
|
|
|
import io.minio.messages.Item; |
|
|
|
import lombok.AllArgsConstructor; |
|
|
|
import lombok.AllArgsConstructor; |
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
import org.springblade.core.log.exception.ServiceException; |
|
|
|
import org.springblade.core.log.exception.ServiceException; |
|
|
|
import org.springblade.core.mp.base.BaseServiceImpl; |
|
|
|
import org.springblade.core.mp.base.BaseServiceImpl; |
|
|
|
import org.springblade.core.mp.support.Condition; |
|
|
|
import com.hnac.hzims.common.utils.Condition; |
|
|
|
import org.springblade.core.mp.support.Query; |
|
|
|
import org.springblade.core.mp.support.Query; |
|
|
|
import org.springblade.core.secure.utils.AuthUtil; |
|
|
|
import org.springblade.core.secure.utils.AuthUtil; |
|
|
|
import org.springblade.core.tool.utils.Func; |
|
|
|
import org.springblade.core.tool.utils.Func; |
|
|
|
|
|
|
|
import org.springblade.core.tool.utils.SpringUtil; |
|
|
|
import org.springblade.system.cache.DictCache; |
|
|
|
import org.springblade.system.cache.DictCache; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
|
import org.springframework.util.Assert; |
|
|
|
import org.springframework.util.Assert; |
|
|
|
|
|
|
|
|
|
|
|
import javax.validation.Valid; |
|
|
|
import javax.validation.Valid; |
|
|
|
import java.time.LocalDate; |
|
|
|
import java.time.*; |
|
|
|
import java.time.LocalDateTime; |
|
|
|
|
|
|
|
import java.time.Year; |
|
|
|
|
|
|
|
import java.time.YearMonth; |
|
|
|
|
|
|
|
import java.time.format.DateTimeFormatter; |
|
|
|
import java.time.format.DateTimeFormatter; |
|
|
|
import java.util.ArrayList; |
|
|
|
import java.util.*; |
|
|
|
import java.util.Comparator; |
|
|
|
|
|
|
|
import java.util.List; |
|
|
|
|
|
|
|
import java.util.Map; |
|
|
|
|
|
|
|
import java.util.stream.Collectors; |
|
|
|
import java.util.stream.Collectors; |
|
|
|
|
|
|
|
|
|
|
|
@Service |
|
|
|
@Service |
|
|
@ -118,13 +115,14 @@ public class MessagePushRecordServiceImpl extends BaseServiceImpl<MessagePushRec |
|
|
|
* @return QueryWrapper |
|
|
|
* @return QueryWrapper |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
private LambdaQueryWrapper<MessagePushRecordEntity> getQueryWrapper(MessagePushRecordEntity request) { |
|
|
|
private LambdaQueryWrapper<MessagePushRecordEntity> getQueryWrapper(MessagePushRecordEntity request) { |
|
|
|
LambdaQueryWrapper<MessagePushRecordEntity> lambda = Condition.getQueryWrapper(request).lambda(); |
|
|
|
LambdaQueryWrapper<MessagePushRecordEntity> lambda = Condition.getQueryWrapper(MessagePushRecordEntity.class,request); |
|
|
|
if(Func.isNotEmpty(request.getStartTime())) { |
|
|
|
if(Func.isNotEmpty(request.getStartTime())) { |
|
|
|
lambda.ge(MessagePushRecordEntity::getPushTime, request.getStartTime()); |
|
|
|
lambda.ge(MessagePushRecordEntity::getPushTime, LocalDateTime.of(request.getStartTime(), LocalTime.MIN)); |
|
|
|
} |
|
|
|
} |
|
|
|
if(Func.isNotEmpty(request.getEndTime())) { |
|
|
|
if(Func.isNotEmpty(request.getEndTime())) { |
|
|
|
lambda.le(MessagePushRecordEntity::getPushTime, request.getEndTime()); |
|
|
|
lambda.le(MessagePushRecordEntity::getPushTime, LocalDateTime.of(request.getEndTime(), LocalTime.MAX)); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
lambda.eq(Func.isNotEmpty(request.getStatus()),MessagePushRecordEntity::getStatus,request.getStatus()); |
|
|
|
lambda.orderByDesc(MessagePushRecordEntity::getPushTime); |
|
|
|
lambda.orderByDesc(MessagePushRecordEntity::getPushTime); |
|
|
|
return lambda; |
|
|
|
return lambda; |
|
|
|
} |
|
|
|
} |
|
|
@ -234,11 +232,55 @@ public class MessagePushRecordServiceImpl extends BaseServiceImpl<MessagePushRec |
|
|
|
String businessTypeName = this.getBusinessClassifyByName(businessClassify); |
|
|
|
String businessTypeName = this.getBusinessClassifyByName(businessClassify); |
|
|
|
pushStat.setBusinessClassifyName(businessTypeName); |
|
|
|
pushStat.setBusinessClassifyName(businessTypeName); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
}); |
|
|
|
}); |
|
|
|
return userPushStatTypeVos; |
|
|
|
return userPushStatTypeVos; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* 新人员发送统计 |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
* @param vo |
|
|
|
|
|
|
|
* @return |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
|
|
public UserPushStatTypeResponseVo newUserPushStat(MessagePushRecordEntityVo vo) { |
|
|
|
|
|
|
|
UserPushStatTypeResponseVo pushStatList = new UserPushStatTypeResponseVo(); |
|
|
|
|
|
|
|
List<UserPushStatResponseVo> results = new ArrayList<>(); |
|
|
|
|
|
|
|
List<PushStatResponseVo> pushStat = baseMapper.selectUserPushStat(vo); |
|
|
|
|
|
|
|
List<String> list = pushStat.stream().map(item -> item.getPusherName()).distinct().collect(Collectors.toList()); |
|
|
|
|
|
|
|
pushStatList.setUserNames(list); |
|
|
|
|
|
|
|
//封装业务分类对象
|
|
|
|
|
|
|
|
Map<String, List<PushStatResponseVo>> collect = pushStat.stream().collect(Collectors.groupingBy(PushStatResponseVo::getBusinessClassify)); |
|
|
|
|
|
|
|
//
|
|
|
|
|
|
|
|
for (Map.Entry<String, List<PushStatResponseVo>> entry : collect.entrySet()) { |
|
|
|
|
|
|
|
List<String> arrayList = Lists.newArrayList(list); |
|
|
|
|
|
|
|
UserPushStatResponseVo userPushStatTypeResponseVo = new UserPushStatResponseVo(); |
|
|
|
|
|
|
|
//存储key
|
|
|
|
|
|
|
|
userPushStatTypeResponseVo.setBusinessClassify(entry.getKey()); |
|
|
|
|
|
|
|
userPushStatTypeResponseVo.setBusinessClassifyName(this.getBusinessClassifyByName(entry.getKey())); |
|
|
|
|
|
|
|
TreeMap<String, Integer> treeMap = new TreeMap<>(); |
|
|
|
|
|
|
|
//存储业务分类
|
|
|
|
|
|
|
|
List<PushStatResponseVo> pushStatResponseVos = entry.getValue(); |
|
|
|
|
|
|
|
for (PushStatResponseVo pushStatResponseVo : pushStatResponseVos) { |
|
|
|
|
|
|
|
if (arrayList.contains(pushStatResponseVo.getPusherName())){ |
|
|
|
|
|
|
|
arrayList.remove(pushStatResponseVo.getPusherName()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
treeMap.put(pushStatResponseVo.getPusherName(),pushStatResponseVo.getCount()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
//如果不存在设为0
|
|
|
|
|
|
|
|
for (String name : arrayList) { |
|
|
|
|
|
|
|
treeMap.put(name,0); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
userPushStatTypeResponseVo.setParams(treeMap); |
|
|
|
|
|
|
|
results.add(userPushStatTypeResponseVo); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
pushStatList.setUserPushStatResponseVos(results); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return pushStatList; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* 推送成功失败统计 |
|
|
|
* 推送成功失败统计 |
|
|
|
* |
|
|
|
* |
|
|
@ -321,6 +363,40 @@ public class MessagePushRecordServiceImpl extends BaseServiceImpl<MessagePushRec |
|
|
|
}).collect(Collectors.toList()); |
|
|
|
}).collect(Collectors.toList()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
|
|
public Boolean sendAppMsgByUsers(BusinessMessageDTO request, List<MessagePushRecordEntity> records) { |
|
|
|
|
|
|
|
PushMessageServiceImpl service = SpringUtil.getBean(PushMessageServiceImpl.class); |
|
|
|
|
|
|
|
try { |
|
|
|
|
|
|
|
boolean sendFlag = service.sendByUsers(request.getSubject(), request.getContent(), Arrays.asList(request.getUserIds().split(",")), request.getTenantId()); |
|
|
|
|
|
|
|
if (sendFlag) { |
|
|
|
|
|
|
|
return this.update(Wrappers.<MessagePushRecordEntity>lambdaUpdate() |
|
|
|
|
|
|
|
.set(MessagePushRecordEntity::getPushTime, LocalDateTime.now()) |
|
|
|
|
|
|
|
.set(MessagePushRecordEntity::getStatus, MessageConstants.PUSH_SUCCESS) |
|
|
|
|
|
|
|
.in(MessagePushRecordEntity::getId, records.stream().map(MessagePushRecordEntity::getId).collect(Collectors.toList())) |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return false; |
|
|
|
|
|
|
|
} catch (Exception e) { |
|
|
|
|
|
|
|
throw new ServiceException(e.getMessage()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
|
|
public Boolean sendWsMsgByUsers(List<MessagePushRecordEntity> request) { |
|
|
|
|
|
|
|
WebsocketServiceImpl service = SpringUtil.getBean(WebsocketServiceImpl.class); |
|
|
|
|
|
|
|
request.forEach(record -> { |
|
|
|
|
|
|
|
boolean sendFlag = service.send(record); |
|
|
|
|
|
|
|
if (sendFlag) { |
|
|
|
|
|
|
|
this.update(Wrappers.<MessagePushRecordEntity>lambdaUpdate() |
|
|
|
|
|
|
|
.set(MessagePushRecordEntity::getPushTime, LocalDateTime.now()) |
|
|
|
|
|
|
|
.set(MessagePushRecordEntity::getStatus, MessageConstants.PUSH_SUCCESS) |
|
|
|
|
|
|
|
.in(MessagePushRecordEntity::getId, record.getId()) |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
return true; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* 状态 ===> 状态名称 |
|
|
|
* 状态 ===> 状态名称 |
|
|
|