消息中心相关接口
parent
8a392a0737
commit
521255ff8d
|
|
@ -0,0 +1,48 @@
|
||||||
|
package com.gunshi.project.xyt.controller;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
|
import com.gunshi.core.result.R;
|
||||||
|
import com.gunshi.project.xyt.entity.so.MessageCenterPageSo;
|
||||||
|
import com.gunshi.project.xyt.model.MessageCenter;
|
||||||
|
import com.gunshi.project.xyt.service.MessageCenterService;
|
||||||
|
import io.swagger.v3.oas.annotations.Operation;
|
||||||
|
import io.swagger.v3.oas.annotations.Parameter;
|
||||||
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 描述: 消息中心
|
||||||
|
* author: xusan
|
||||||
|
* date: 2024-09-19 10:39:29
|
||||||
|
*/
|
||||||
|
@Tag(name = "消息中心")
|
||||||
|
@RestController
|
||||||
|
@RequestMapping(value="/messageCenter")
|
||||||
|
public class MessageCenterController {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private MessageCenterService service;
|
||||||
|
|
||||||
|
@Operation(summary = "分页查询")
|
||||||
|
@PostMapping("/list/page")
|
||||||
|
public R<Page<MessageCenter>> listPage(@Validated @RequestBody MessageCenterPageSo page) {
|
||||||
|
return R.ok(service.listPage(page));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Operation(summary = "已读")
|
||||||
|
@PostMapping("/update")
|
||||||
|
public R<MessageCenter> update(@Validated @RequestBody MessageCenter dto) {
|
||||||
|
boolean result = service.updateById(dto);
|
||||||
|
return R.ok(result ? dto : null);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Operation(summary = "全部标注已读")
|
||||||
|
@GetMapping("/all/read")
|
||||||
|
public R<Boolean> allRead(@RequestParam("receiveUserId") @Parameter(description = "接收人id") Long receiveUserId) {
|
||||||
|
return R.ok(service.allRead(receiveUserId));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,36 @@
|
||||||
|
package com.gunshi.project.xyt.entity.so;
|
||||||
|
|
||||||
|
import com.gunshi.db.dto.PageSo;
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import jakarta.validation.constraints.NotNull;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Description:
|
||||||
|
* Created by wanyan on 2024/3/19
|
||||||
|
*
|
||||||
|
* @author wanyan
|
||||||
|
* @version 1.0
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@Schema(description = "消息中心分页查询对象")
|
||||||
|
public class MessageCenterPageSo {
|
||||||
|
|
||||||
|
@NotNull(message = "分页参数不能为空")
|
||||||
|
@Schema(description = "分页参数")
|
||||||
|
private PageSo pageSo;
|
||||||
|
|
||||||
|
@Schema(description="主题")
|
||||||
|
private String title;
|
||||||
|
|
||||||
|
@Schema(description="发布人名字")
|
||||||
|
private String publishUserName;
|
||||||
|
|
||||||
|
@Schema(description="接收人id")
|
||||||
|
@NotNull(message = "接收人id不可为空")
|
||||||
|
private Long receiveUserId;
|
||||||
|
|
||||||
|
@Schema(description="是否已读(0否 1是)")
|
||||||
|
@NotNull(message = "是否已读不可为空")
|
||||||
|
private Integer status;
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,15 @@
|
||||||
|
package com.gunshi.project.xyt.mapper;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
import com.gunshi.project.xyt.model.MessageCenter;
|
||||||
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 描述: 消息中心
|
||||||
|
* author: xusan
|
||||||
|
* date: 2024-09-19 10:39:29
|
||||||
|
*/
|
||||||
|
@Mapper
|
||||||
|
public interface MessageCenterMapper extends BaseMapper<MessageCenter> {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,96 @@
|
||||||
|
package com.gunshi.project.xyt.model;
|
||||||
|
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.IdType;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableField;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||||
|
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
||||||
|
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
|
||||||
|
import com.gunshi.core.dateformat.DateFormatString;
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import jakarta.validation.constraints.Size;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 描述: 消息中心
|
||||||
|
* author: xusan
|
||||||
|
* date: 2024-09-19 10:39:29
|
||||||
|
*/
|
||||||
|
@Schema(description="消息中心")
|
||||||
|
@Data
|
||||||
|
@TableName("public.message_center")
|
||||||
|
public class MessageCenter implements Serializable {
|
||||||
|
|
||||||
|
public final static String thisTableName = "MessageCenter";
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 主键
|
||||||
|
*/
|
||||||
|
@TableId(value="id", type= IdType.AUTO)
|
||||||
|
@Schema(description="主键")
|
||||||
|
@JsonSerialize(using = ToStringSerializer.class)
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 主题
|
||||||
|
*/
|
||||||
|
@TableField(value="title")
|
||||||
|
@Schema(description="主题")
|
||||||
|
@Size(max = 100,message = "主题最大长度要小于 100")
|
||||||
|
private String title;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 发布人id
|
||||||
|
*/
|
||||||
|
@TableField(value="publish_user_id")
|
||||||
|
@Schema(description="发布人id")
|
||||||
|
@JsonSerialize(using = ToStringSerializer.class)
|
||||||
|
private Long publishUserId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 发布人名字
|
||||||
|
*/
|
||||||
|
@TableField(value="publish_user_name")
|
||||||
|
@Schema(description="发布人名字")
|
||||||
|
@Size(max = 100,message = "发布人名字最大长度要小于 100")
|
||||||
|
private String publishUserName;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 发布时间
|
||||||
|
*/
|
||||||
|
@TableField(value="publish_time")
|
||||||
|
@Schema(description="发布时间")
|
||||||
|
@JsonFormat(pattern = DateFormatString.YYYY_MM_DD_HH_MM_SS, timezone = "GMT+8")
|
||||||
|
private Date publishTime;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 内容
|
||||||
|
*/
|
||||||
|
@TableField(value="content")
|
||||||
|
@Schema(description="内容")
|
||||||
|
@Size(max = 500,message = "内容最大长度要小于 500")
|
||||||
|
private String content;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 接收人id
|
||||||
|
*/
|
||||||
|
@TableField(value="receive_user_id")
|
||||||
|
@Schema(description="接收人id")
|
||||||
|
@JsonSerialize(using = ToStringSerializer.class)
|
||||||
|
private Long receiveUserId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 是否已读(0否 1是)
|
||||||
|
*/
|
||||||
|
@TableField(value="status")
|
||||||
|
@Schema(description="是否已读(0否 1是)")
|
||||||
|
private Integer status;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -48,6 +48,9 @@ public class AssessTaskService extends ServiceImpl<AssessTaskMapper, AssessTask>
|
||||||
@Autowired
|
@Autowired
|
||||||
private AssessTeamRatingService teamRatingService;
|
private AssessTeamRatingService teamRatingService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private MessageCenterService messageCenterService;
|
||||||
|
|
||||||
public AssessTask saveData(AssessTask dto) {
|
public AssessTask saveData(AssessTask dto) {
|
||||||
dto.setId(IdWorker.getId());
|
dto.setId(IdWorker.getId());
|
||||||
dto.setStatus(0);
|
dto.setStatus(0);
|
||||||
|
|
@ -121,6 +124,7 @@ public class AssessTaskService extends ServiceImpl<AssessTaskMapper, AssessTask>
|
||||||
assessObjectService.updateTeams(teams);
|
assessObjectService.updateTeams(teams);
|
||||||
//考核指标
|
//考核指标
|
||||||
List<AssessTeamRating> ratings = new ArrayList<>();
|
List<AssessTeamRating> ratings = new ArrayList<>();
|
||||||
|
List<MessageCenter> messages = new ArrayList<>();
|
||||||
List<AssessIndicator> indicatorIds = this.baseMapper.queryIndicators(task.getTemplateId());
|
List<AssessIndicator> indicatorIds = this.baseMapper.queryIndicators(task.getTemplateId());
|
||||||
for(AssessTeam team : teams){
|
for(AssessTeam team : teams){
|
||||||
for(AssessIndicator indicator : indicatorIds){
|
for(AssessIndicator indicator : indicatorIds){
|
||||||
|
|
@ -131,9 +135,16 @@ public class AssessTaskService extends ServiceImpl<AssessTaskMapper, AssessTask>
|
||||||
rating.setStandardScore(indicator.getStandardScore());
|
rating.setStandardScore(indicator.getStandardScore());
|
||||||
ratings.add(rating);
|
ratings.add(rating);
|
||||||
}
|
}
|
||||||
|
MessageCenter center = new MessageCenter();
|
||||||
|
center.setPublishUserId(task.getCreateUserId());
|
||||||
|
center.setPublishUserName(task.getCreateUserName());
|
||||||
|
center.setReceiveUserId(team.getTeamUserId());
|
||||||
|
center.setTitle("评分任务");
|
||||||
|
center.setContent("您收到一条考核评分任务的提醒:"+task.getTaskName()+",请及时处理。");
|
||||||
|
messages.add(center);
|
||||||
}
|
}
|
||||||
teamRatingService.saveBatch(ratings);
|
teamRatingService.saveBatch(ratings);
|
||||||
|
messageCenterService.insertMessage(messages);
|
||||||
List<AssessObjectRating> list = new ArrayList<>();
|
List<AssessObjectRating> list = new ArrayList<>();
|
||||||
for(AssessObject object : objects){
|
for(AssessObject object : objects){
|
||||||
for(AssessIndicator indicator : indicatorIds){
|
for(AssessIndicator indicator : indicatorIds){
|
||||||
|
|
|
||||||
|
|
@ -11,14 +11,17 @@ import com.gunshi.project.xyt.entity.vo.InspectTaskDetailVo;
|
||||||
import com.gunshi.project.xyt.entity.vo.InspectTaskVo;
|
import com.gunshi.project.xyt.entity.vo.InspectTaskVo;
|
||||||
import com.gunshi.project.xyt.mapper.InspectTaskMapper;
|
import com.gunshi.project.xyt.mapper.InspectTaskMapper;
|
||||||
import com.gunshi.project.xyt.model.InspectTask;
|
import com.gunshi.project.xyt.model.InspectTask;
|
||||||
|
import com.gunshi.project.xyt.model.MessageCenter;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 描述: 巡检任务
|
* 描述: 巡检任务
|
||||||
|
|
@ -34,12 +37,23 @@ public class InspectTaskService extends ServiceImpl<InspectTaskMapper, InspectTa
|
||||||
@Autowired
|
@Autowired
|
||||||
private InspectTaskDetailService inspectTaskDetailService;
|
private InspectTaskDetailService inspectTaskDetailService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private MessageCenterService messageCenterService;
|
||||||
|
|
||||||
public InspectTask saveData(InspectTask dto) {
|
public InspectTask saveData(InspectTask dto) {
|
||||||
dto.setId(IdWorker.getId());
|
dto.setId(IdWorker.getId());
|
||||||
dto.setStatus(0);
|
dto.setStatus(0);
|
||||||
dto.setCreateTime(new Date());
|
dto.setCreateTime(new Date());
|
||||||
this.save(dto);
|
this.save(dto);
|
||||||
inspectTaskDetailService.saveDetail(dto.getItems(),dto.getId());
|
inspectTaskDetailService.saveDetail(dto.getItems(),dto.getId());
|
||||||
|
|
||||||
|
MessageCenter center = new MessageCenter();
|
||||||
|
center.setPublishUserId(dto.getCreateUserId());
|
||||||
|
center.setPublishUserName(dto.getCreateUserName());
|
||||||
|
center.setReceiveUserId(dto.getInspectUserId());
|
||||||
|
center.setTitle("巡查任务");
|
||||||
|
center.setContent("您收到一条巡查任务的提醒:" + dto.getTaskTitle() +",请及时处理。");
|
||||||
|
messageCenterService.insertMessage(Arrays.asList(center));
|
||||||
return dto;
|
return dto;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -77,10 +91,21 @@ public class InspectTaskService extends ServiceImpl<InspectTaskMapper, InspectTa
|
||||||
|
|
||||||
public Boolean finish(InspectTaskVo vo) {
|
public Boolean finish(InspectTaskVo vo) {
|
||||||
List<InspectTaskDetailVo> list = vo.getList();
|
List<InspectTaskDetailVo> list = vo.getList();
|
||||||
inspectTaskDetailService.finish(list);
|
|
||||||
InspectTask task = this.getById(list.get(0).getTaskId());
|
InspectTask task = this.getById(list.get(0).getTaskId());
|
||||||
|
inspectTaskDetailService.finish(list);
|
||||||
task.setFinishTime(vo.getStatus() == 2 ? new Date() : null);
|
task.setFinishTime(vo.getStatus() == 2 ? new Date() : null);
|
||||||
task.setStatus(vo.getStatus());
|
task.setStatus(vo.getStatus());
|
||||||
|
|
||||||
|
List<MessageCenter> messageCenters = list.stream().filter(o -> o.getIsHandle() == 1).map(t->{
|
||||||
|
MessageCenter center = new MessageCenter();
|
||||||
|
center.setPublishUserId(task.getInspectUserId());
|
||||||
|
center.setPublishUserName(task.getInspectUserName());
|
||||||
|
center.setReceiveUserId(t.getHandleUserId());
|
||||||
|
center.setTitle("巡查问题");
|
||||||
|
center.setContent("您收到一条巡查任务未处理问题的提醒:"+task.getTaskTitle()+",请及时处理。");
|
||||||
|
return center;
|
||||||
|
}).collect(Collectors.toList());
|
||||||
|
messageCenterService.insertMessage(messageCenters);
|
||||||
return this.updateById(task);
|
return this.updateById(task);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,60 @@
|
||||||
|
package com.gunshi.project.xyt.service;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
|
import com.baomidou.mybatisplus.core.toolkit.IdWorker;
|
||||||
|
import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
|
||||||
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||||
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
import com.gunshi.project.xyt.entity.so.MessageCenterPageSo;
|
||||||
|
import com.gunshi.project.xyt.mapper.MessageCenterMapper;
|
||||||
|
import com.gunshi.project.xyt.model.MessageCenter;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 描述: 消息中心
|
||||||
|
* author: xusan
|
||||||
|
* date: 2024-09-19 10:39:29
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
@Slf4j
|
||||||
|
@Transactional(rollbackFor = Exception.class)
|
||||||
|
public class MessageCenterService extends ServiceImpl<MessageCenterMapper, MessageCenter>
|
||||||
|
{
|
||||||
|
|
||||||
|
public void insertMessage(List<MessageCenter> messageCenters){
|
||||||
|
for(MessageCenter messageCenter : messageCenters){
|
||||||
|
messageCenter.setId(IdWorker.getId());
|
||||||
|
messageCenter.setPublishTime(new Date());
|
||||||
|
messageCenter.setStatus(0);
|
||||||
|
}
|
||||||
|
this.saveBatch(messageCenters);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Page<MessageCenter> listPage(MessageCenterPageSo page) {
|
||||||
|
LambdaQueryWrapper<MessageCenter> queryWrapper = Wrappers.lambdaQuery();
|
||||||
|
queryWrapper.eq(MessageCenter::getReceiveUserId,page.getReceiveUserId())
|
||||||
|
.eq(MessageCenter::getStatus,page.getStatus());
|
||||||
|
if (ObjectUtils.isNotNull(page.getTitle())) {
|
||||||
|
queryWrapper.like(MessageCenter::getTitle, page.getTitle());
|
||||||
|
}
|
||||||
|
if (ObjectUtils.isNotNull(page.getPublishUserName())) {
|
||||||
|
queryWrapper.like(MessageCenter::getPublishUserName, page.getPublishUserName());
|
||||||
|
}
|
||||||
|
return this.page(page.getPageSo().toPage(),queryWrapper);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Boolean allRead(Long receiveUserId) {
|
||||||
|
return this.lambdaUpdate()
|
||||||
|
.set(MessageCenter::getStatus, 1)
|
||||||
|
.eq(MessageCenter::getReceiveUserId, receiveUserId)
|
||||||
|
.update();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
Loading…
Reference in New Issue