Browse Source

修改人员发送统计消息统计

zhongwei
段飞宇 1 year ago
parent
commit
91a0502ac1
  1. 33
      hzims-service-api/message-api/src/main/java/com/hnac/hzims/message/vo/msgpushrecord/PushStatResponseVo.java
  2. 33
      hzims-service-api/message-api/src/main/java/com/hnac/hzims/message/vo/msgpushrecord/UserPushStatResponseVo.java
  3. 28
      hzims-service-api/message-api/src/main/java/com/hnac/hzims/message/vo/msgpushrecord/UserPushStatTypeResponseVo.java
  4. 4
      hzims-service-api/message-api/src/main/java/com/hnac/hzims/message/vo/msgpushrecord/UserPushStatTypeVo.java
  5. 14
      hzims-service/message/src/main/java/com/hnac/hzims/message/controller/web/MessageStatisticsController.java
  6. 8
      hzims-service/message/src/main/java/com/hnac/hzims/message/mapper/MessagePushRecordMapper.java
  7. 34
      hzims-service/message/src/main/java/com/hnac/hzims/message/mapper/MessagePushRecordMapper.xml
  8. 8
      hzims-service/message/src/main/java/com/hnac/hzims/message/service/IMessagePushRecordService.java
  9. 56
      hzims-service/message/src/main/java/com/hnac/hzims/message/service/impl/MessagePushRecordServiceImpl.java

33
hzims-service-api/message-api/src/main/java/com/hnac/hzims/message/vo/msgpushrecord/PushStatResponseVo.java

@ -0,0 +1,33 @@
package com.hnac.hzims.message.vo.msgpushrecord;
import lombok.Data;
import java.util.List;
/**
* @Author WL
* @Version v1.0
* @Serial 1.0
* @Date 2023/6/29 14:18
*/
@Data
public class PushStatResponseVo {
/**
* 推送人名称
*/
private String pusherName;
/**
* 业务分类
*/
private String businessClassify;
/**
* 业务分类名称
*/
private String businessClassifyName;
/**
* 统计数量
*/
private Integer count;
}

33
hzims-service-api/message-api/src/main/java/com/hnac/hzims/message/vo/msgpushrecord/UserPushStatResponseVo.java

@ -0,0 +1,33 @@
package com.hnac.hzims.message.vo.msgpushrecord;
import lombok.Data;
import javax.sound.sampled.Port;
import java.util.List;
import java.util.Map;
import java.util.Set;
/**
* @Author WL
* @Version v1.0
* @Serial 1.0
* @Date 2023/6/29 13:58
*/
@Data
public class UserPushStatResponseVo {
/**
* 业务分类
*/
private String businessClassify;
/**
* 业务分类名称
*/
private String businessClassifyName;
/**
* 封装map
*/
private Map<String,Integer> params;
}

28
hzims-service-api/message-api/src/main/java/com/hnac/hzims/message/vo/msgpushrecord/UserPushStatTypeResponseVo.java

@ -0,0 +1,28 @@
package com.hnac.hzims.message.vo.msgpushrecord;
import lombok.Data;
import java.util.List;
import java.util.Set;
/**
* @Author WL
* @Version v1.0
* @Serial 1.0
* @Date 2023/6/29 13:46
*/
@Data
public class UserPushStatTypeResponseVo {
/**
* 封装人员信息
*/
private List<String> userNames;
/**
* 封装业务分类对象
*/
private List<UserPushStatResponseVo> userPushStatResponseVos;
}

4
hzims-service-api/message-api/src/main/java/com/hnac/hzims/message/vo/msgpushrecord/UserPushStatTypeVo.java

@ -22,4 +22,8 @@ public class UserPushStatTypeVo {
* 推送业务分类数组 * 推送业务分类数组
*/ */
private List<UserPushStatVo> pushStatList; private List<UserPushStatVo> pushStatList;
} }

14
hzims-service/message/src/main/java/com/hnac/hzims/message/controller/web/MessageStatisticsController.java

@ -56,10 +56,22 @@ public class MessageStatisticsController {
/** /**
* 人员发送统计 * 人员发送统计
*/ */
@GetMapping("/userPushStatWithMessgae")
public R userPushStatWithMessgae(MessagePushRecordEntityVo vo) {
log.info("人员发送统计");
List<UserPushStatTypeVo> messagePushRecordVos = messagePushRecordService.userPushStat(vo);
log.info("人员发送统计 返回的数据: {}",messagePushRecordVos);
return R.data(messagePushRecordVos);
}
/**
* 新人员发送统计
*/
@GetMapping("/userPushStat") @GetMapping("/userPushStat")
public R userPushStat(MessagePushRecordEntityVo vo) { public R userPushStat(MessagePushRecordEntityVo vo) {
log.info("人员发送统计"); log.info("人员发送统计");
List<UserPushStatTypeVo> messagePushRecordVos = messagePushRecordService.userPushStat(vo); UserPushStatTypeResponseVo messagePushRecordVos = messagePushRecordService.newUserPushStat(vo);
log.info("人员发送统计 返回的数据: {}",messagePushRecordVos); log.info("人员发送统计 返回的数据: {}",messagePushRecordVos);
return R.data(messagePushRecordVos); return R.data(messagePushRecordVos);
} }

8
hzims-service/message/src/main/java/com/hnac/hzims/message/mapper/MessagePushRecordMapper.java

@ -6,6 +6,7 @@ import org.apache.ibatis.annotations.Param;
import org.springblade.core.datascope.mapper.UserDataScopeBaseMapper; import org.springblade.core.datascope.mapper.UserDataScopeBaseMapper;
import java.util.List; import java.util.List;
import java.util.Set;
public interface MessagePushRecordMapper extends UserDataScopeBaseMapper<MessagePushRecordEntity> { public interface MessagePushRecordMapper extends UserDataScopeBaseMapper<MessagePushRecordEntity> {
@ -43,4 +44,11 @@ public interface MessagePushRecordMapper extends UserDataScopeBaseMapper<Message
*/ */
List<Integer> selectByStatus(); List<Integer> selectByStatus();
/**
* 新人员发送统计
* @param vo
* @return
*/
List<PushStatResponseVo> selectUserPushStat(@Param("vo") MessagePushRecordEntityVo vo);
} }

34
hzims-service/message/src/main/java/com/hnac/hzims/message/mapper/MessagePushRecordMapper.xml

@ -14,6 +14,7 @@
</resultMap> </resultMap>
<!-- 根据type统计数量--> <!-- 根据type统计数量-->
<select id="smsPushStat" resultType="com.hnac.hzims.message.vo.msgpushrecord.MessagePushRecordVo"> <select id="smsPushStat" resultType="com.hnac.hzims.message.vo.msgpushrecord.MessagePushRecordVo">
select count(1) power, select count(1) power,
@ -27,6 +28,7 @@
and and
DEPT_ID = #{vo.stationCode} DEPT_ID = #{vo.stationCode}
</if> </if>
and (BUSINESS_CLASSIFY != '' and BUSINESS_CLASSIFY is not null)
</where> </where>
group by strMonth, TYPE group by strMonth, TYPE
</select> </select>
@ -50,6 +52,7 @@
and and
type = #{vo.type} type = #{vo.type}
</if> </if>
and (BUSINESS_CLASSIFY != '' and BUSINESS_CLASSIFY is not null)
</where> </where>
group by businessClassify group by businessClassify
</select> </select>
@ -74,6 +77,7 @@
and and
type = #{vo.type} type = #{vo.type}
</if> </if>
and (BUSINESS_CLASSIFY != '' and BUSINESS_CLASSIFY is not null)
</where> </where>
group by businessClassify, pusherName group by businessClassify, pusherName
</select> </select>
@ -107,6 +111,7 @@
and and
type = #{vo.type} type = #{vo.type}
</if> </if>
and (BUSINESS_CLASSIFY != '' and BUSINESS_CLASSIFY is not null)
</where> </where>
group by businessClassify,status group by businessClassify,status
</select> </select>
@ -116,4 +121,33 @@
from hzims_message_push_record from hzims_message_push_record
group by STATUS group by STATUS
</select> </select>
<select id="selectUserPushStat" resultType="com.hnac.hzims.message.vo.msgpushrecord.PushStatResponseVo">
select PUSHER_NAME pusherName,
BUSINESS_CLASSIFY businessClassify,
count(1) count
from hzims_message_push_record
<where>
IS_DELETED = 0
<if test="vo.stationCode != null and vo.stationCode != ''">
and
DEPT_ID = #{vo.stationCode}
</if>
<if test="vo.yearMonth != null">
and
date_format(PLAN_TIME, '%Y-%m') = #{vo.yearMonth}
</if>
<if test="vo.type != null and vo.type != ''">
and
type = #{vo.type}
</if>
and (BUSINESS_CLASSIFY != '' and BUSINESS_CLASSIFY is not null)
</where>
group by businessClassify,pusherName
</select>
</mapper> </mapper>

8
hzims-service/message/src/main/java/com/hnac/hzims/message/service/IMessagePushRecordService.java

@ -90,4 +90,12 @@ public interface IMessagePushRecordService extends BaseService<MessagePushRecord
Boolean sendAppMsgByUsers(BusinessMessageDTO request,List<MessagePushRecordEntity> records); Boolean sendAppMsgByUsers(BusinessMessageDTO request,List<MessagePushRecordEntity> records);
Boolean sendWsMsgByUsers(List<MessagePushRecordEntity> request); Boolean sendWsMsgByUsers(List<MessagePushRecordEntity> request);
/**
* 新人员发送统计
* @param vo
* @return
*/
UserPushStatTypeResponseVo newUserPushStat(MessagePushRecordEntityVo vo);
} }

56
hzims-service/message/src/main/java/com/hnac/hzims/message/service/impl/MessagePushRecordServiceImpl.java

@ -23,6 +23,7 @@ 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;
@ -233,11 +234,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,11 +366,11 @@ public class MessagePushRecordServiceImpl extends BaseServiceImpl<MessagePushRec
} }
@Override @Override
public Boolean sendAppMsgByUsers(BusinessMessageDTO request,List<MessagePushRecordEntity> records) { public Boolean sendAppMsgByUsers(BusinessMessageDTO request, List<MessagePushRecordEntity> records) {
PushMessageServiceImpl service = SpringUtil.getBean(PushMessageServiceImpl.class); PushMessageServiceImpl service = SpringUtil.getBean(PushMessageServiceImpl.class);
try { try {
boolean sendFlag = service.sendByUsers(request.getSubject(), request.getContent(), Arrays.asList(request.getUserIds().split(",")), request.getTenantId()); boolean sendFlag = service.sendByUsers(request.getSubject(), request.getContent(), Arrays.asList(request.getUserIds().split(",")), request.getTenantId());
if(sendFlag) { if (sendFlag) {
return this.update(Wrappers.<MessagePushRecordEntity>lambdaUpdate() return this.update(Wrappers.<MessagePushRecordEntity>lambdaUpdate()
.set(MessagePushRecordEntity::getPushTime, LocalDateTime.now()) .set(MessagePushRecordEntity::getPushTime, LocalDateTime.now())
.set(MessagePushRecordEntity::getStatus, MessageConstants.PUSH_SUCCESS) .set(MessagePushRecordEntity::getStatus, MessageConstants.PUSH_SUCCESS)
@ -333,8 +378,7 @@ public class MessagePushRecordServiceImpl extends BaseServiceImpl<MessagePushRec
); );
} }
return false; return false;
} } catch (Exception e) {
catch(Exception e) {
throw new ServiceException(e.getMessage()); throw new ServiceException(e.getMessage());
} }
} }
@ -344,7 +388,7 @@ public class MessagePushRecordServiceImpl extends BaseServiceImpl<MessagePushRec
WebsocketServiceImpl service = SpringUtil.getBean(WebsocketServiceImpl.class); WebsocketServiceImpl service = SpringUtil.getBean(WebsocketServiceImpl.class);
request.forEach(record -> { request.forEach(record -> {
boolean sendFlag = service.send(record); boolean sendFlag = service.send(record);
if(sendFlag) { if (sendFlag) {
this.update(Wrappers.<MessagePushRecordEntity>lambdaUpdate() this.update(Wrappers.<MessagePushRecordEntity>lambdaUpdate()
.set(MessagePushRecordEntity::getPushTime, LocalDateTime.now()) .set(MessagePushRecordEntity::getPushTime, LocalDateTime.now())
.set(MessagePushRecordEntity::getStatus, MessageConstants.PUSH_SUCCESS) .set(MessagePushRecordEntity::getStatus, MessageConstants.PUSH_SUCCESS)

Loading…
Cancel
Save