Browse Source

# 个人中心未读消息统计

zhongwei
haungxing 2 years ago
parent
commit
22a167a076
  1. 34
      hzims-service-api/message-api/src/main/java/com/hnac/hzims/message/vo/UnreadMessageVO.java
  2. 10
      hzims-service/message/src/main/java/com/hnac/hzims/message/controller/MessagePushRecordController.java
  3. 8
      hzims-service/message/src/main/java/com/hnac/hzims/message/service/IMessagePushRecordService.java
  4. 34
      hzims-service/message/src/main/java/com/hnac/hzims/message/service/impl/MessagePushRecordServiceImpl.java
  5. 2
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/controller/StationController.java
  6. 4
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/IStationService.java
  7. 33
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/impl/StationServiceImpl.java

34
hzims-service-api/message-api/src/main/java/com/hnac/hzims/message/vo/UnreadMessageVO.java

@ -0,0 +1,34 @@
package com.hnac.hzims.message.vo;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.NullSerializer;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.io.Serializable;
/**
* @ClassName UnreadMessageVO
* @description: 个人消息中心-待办消息统计返回对象
* @author: hx
* @create: 2023-04-11 19:04
* @Version 4.0
**/
@Data
@ApiModel("个人消息中心-待办消息统计返回对象")
@EqualsAndHashCode
public class UnreadMessageVO implements Serializable {
@ApiModelProperty("业务分类")
private String businessClassify;
@ApiModelProperty("业务分类名称")
private String businessName;
@ApiModelProperty("待办消息数量")
@JsonSerialize(nullsUsing = NullSerializer.class)
private Long todoNum;
}

10
hzims-service/message/src/main/java/com/hnac/hzims/message/controller/MessagePushRecordController.java

@ -7,6 +7,7 @@ import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.hnac.hzims.message.MessageConstants;
import com.hnac.hzims.message.entity.MessagePushRecordEntity;
import com.hnac.hzims.message.service.IMessagePushRecordService;
import com.hnac.hzims.message.vo.UnreadMessageVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
@ -77,4 +78,13 @@ public class MessagePushRecordController extends BladeController {
.eq(MessagePushRecordEntity::getId, id);
return R.status(messagePushRecordService.update(eq));
}
@GetMapping("/getPersonalUnreadMessage")
@ApiOperation("获取当前登录人待办消息")
@ApiOperationSupport(order = 7)
public R<List<UnreadMessageVO>> getPersonalUnreadMessage() {
List<UnreadMessageVO> personalUnreadMessage = messagePushRecordService.getPersonalUnreadMessage();
return R.data(personalUnreadMessage);
}
}

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

@ -2,6 +2,7 @@ package com.hnac.hzims.message.service;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.hnac.hzims.message.entity.MessagePushRecordEntity;
import com.hnac.hzims.message.vo.UnreadMessageVO;
import com.hnac.hzims.message.vo.msgpushrecord.*;
import org.springblade.core.mp.base.BaseService;
import org.springblade.core.mp.support.Query;
@ -69,6 +70,11 @@ public interface IMessagePushRecordService extends BaseService<MessagePushRecord
List<PushStatTypeVo> pushStat(MessagePushRecordEntityVo vo);
/** @Author hx
* @Description 获取当前登录人待办消息
* @Date 2023/4/11 19:27
* @return
**/
List<UnreadMessageVO> getPersonalUnreadMessage();
}

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

@ -1,9 +1,14 @@
package com.hnac.hzims.message.service.impl;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.hnac.hzims.common.utils.CacheUtil;
import com.hnac.hzims.message.MessageConstants;
import com.hnac.hzims.message.config.MessageFactory;
import com.hnac.hzims.message.entity.MessagePushRecordEntity;
@ -11,6 +16,7 @@ import com.hnac.hzims.message.enums.PushStatEnum;
import com.hnac.hzims.message.mapper.MessagePushRecordMapper;
import com.hnac.hzims.message.service.IMessagePushRecordService;
import com.hnac.hzims.message.service.IMessageService;
import com.hnac.hzims.message.vo.UnreadMessageVO;
import com.hnac.hzims.message.vo.msgpushrecord.*;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
@ -18,7 +24,9 @@ import org.springblade.core.log.exception.ServiceException;
import org.springblade.core.mp.base.BaseServiceImpl;
import org.springblade.core.mp.support.Condition;
import org.springblade.core.mp.support.Query;
import org.springblade.core.secure.utils.AuthUtil;
import org.springblade.core.tool.utils.Func;
import org.springblade.system.cache.DictCache;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.Assert;
@ -46,6 +54,12 @@ public class MessagePushRecordServiceImpl extends BaseServiceImpl<MessagePushRec
return this.page(Condition.getPage(query), this.getQueryWrapper(request));
}
/** @Author hx
* @Description 根据ID发送短信
* @Date 2023/4/12 10:22
* @Param [id] 短信记录ID
* @return java.lang.Boolean 推送结果
**/
@Override
public Boolean send(Long id) {
MessagePushRecordEntity record = this.getById(id);
@ -62,6 +76,12 @@ public class MessagePushRecordServiceImpl extends BaseServiceImpl<MessagePushRec
return this.update(luw);
}
/** @Author hx
* @Description 保存并推送消息
* @Date 2023/4/12 10:23
* @Param [request] 消息记录
* @return java.lang.Boolean 推送解雇
**/
@Override
@Transactional(rollbackFor = Exception.class)
public Boolean saveAndSend(MessagePushRecordEntity request) {
@ -183,6 +203,20 @@ public class MessagePushRecordServiceImpl extends BaseServiceImpl<MessagePushRec
return pushStatTypeVos;
}
@Override
public List<UnreadMessageVO> getPersonalUnreadMessage() {
QueryWrapper<MessagePushRecordEntity> query = Wrappers.query();
query.select("business_classify businessClassify,count(0) todoNum");
query.eq("account",AuthUtil.getUserId());
query.groupBy("business_classify");
List<Map<String, Object>> list = this.listMaps(query);
return list.stream().map(map -> {
UnreadMessageVO unreadMessageVO = Func.toBean(map, UnreadMessageVO.class);
unreadMessageVO.setBusinessName(DictCache.getValue("businessClassify",unreadMessageVO.getBusinessClassify()));
return unreadMessageVO;
}).collect(Collectors.toList());
}
/**
* 状态 ===> 状态名称

2
hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/controller/StationController.java

@ -143,7 +143,7 @@ public class StationController extends BladeController {
*/
@PostMapping("/remove")
@ApiOperationSupport(order = 40)
@ApiOperation(value = "逻辑删除", notes = "传入ids")
@ApiOperation(value = "逻辑删除", notes = "传入id")
public R remove(@ApiParam(value = "主键集合", required = true) @RequestParam String ids) {
return R.status(stationService.removeStation(ids));
}

4
hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/IStationService.java

@ -38,10 +38,10 @@ public interface IStationService extends BaseService<StationEntity> {
/**
* 删除站点
* @param ids 站点ID按逗号分隔
* @param id 站点ID按逗号分隔
* @return
*/
boolean removeStation(String ids);
boolean removeStation(String id);
IPage<StationVO> list(StationEntity req, Query query);

33
hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/impl/StationServiceImpl.java

@ -126,24 +126,23 @@ public class StationServiceImpl extends BaseServiceImpl<StationMapper, StationEn
@Override
@Transactional(rollbackFor = Exception.class)
public boolean removeStation(String ids) {
if(this.deleteLogic(Func.toLongList(",",ids))) {
Func.toLongList(",",ids).forEach(id -> {
StationEntity stationEntity = this.getById(id);
// 删除数据平台项目
Result<ProjectVO> existProject = projectClient.getProjectByPid(stationEntity.getCode());
if(existProject.isSuccess() && ObjectUtil.isNotEmpty(existProject.getData())) {
Result dataDelete = projectClient.delete(stationEntity.getCode());
Assert.isTrue(dataDelete.isSuccess(),() -> {
logger.error("hzims-operational:station:removeStation",stationEntity.getCode()+"删除失败,报错信息为:"+dataDelete.getMsg());
throw new ServiceException("数据平台删除项目失败!");
});
}
// 删除智能诊断站点
questionClient.deleteStationInfo(stationEntity.getCode());
});
public boolean removeStation(String id) {
StationEntity stationEntity = this.getById(id);
boolean saveFlag = this.removeById(Long.valueOf(id));
if(saveFlag) {
// 删除数据平台项目
Result<ProjectVO> existProject = projectClient.getProjectByPid(stationEntity.getCode());
if(existProject.isSuccess() && ObjectUtil.isNotEmpty(existProject.getData())) {
Result dataDelete = projectClient.delete(stationEntity.getCode());
Assert.isTrue(dataDelete.isSuccess(),() -> {
logger.error("hzims-operational:station:removeStation",stationEntity.getCode()+"删除失败,报错信息为:"+dataDelete.getMsg());
throw new ServiceException("数据平台删除项目失败!");
});
}
// 删除智能诊断站点
questionClient.deleteStationInfo(stationEntity.getCode());
}
return true;
return saveFlag;
}
@Override

Loading…
Cancel
Save