Commit 887a671b authored by helinlin's avatar helinlin

开发特种设备 消息中心 接口

parent e224210a
package com.yeejoin.amos.boot.module.tzs.api.dto;
import lombok.Data;
@Data
public class KV {
private String name;
private Object value;
}
package com.yeejoin.amos.boot.module.tzs.api.mapper;
import com.yeejoin.amos.boot.module.tzs.api.entity.MsgLog;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.yeejoin.amos.boot.module.tzs.api.dto.KV;
import com.yeejoin.amos.boot.module.tzs.api.entity.MsgLog;
import java.util.List;
/**
* 消息流水表 Mapper 接口
......@@ -10,5 +13,5 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
* @date 2022-04-20
*/
public interface MsgLogMapper extends BaseMapper<MsgLog> {
List<KV> getMsgType();
}
......@@ -2,4 +2,10 @@
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.yeejoin.amos.boot.module.tzs.api.mapper.MsgLogMapper">
<select id="getMsgType" resultType="com.yeejoin.amos.boot.module.tzs.api.dto.KV">
SELECT msg_type AS value, msg_type_name AS name
FROM tz_msg_log
GROUP BY msg_type
</select>
</mapper>
package com.yeejoin.amos.boot.module.tzs.biz.controller;
import org.springframework.web.bind.annotation.RequestMapping;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.Api;
import org.springframework.web.bind.annotation.RestController;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yeejoin.amos.boot.biz.common.controller.BaseController;
import java.util.List;
import com.yeejoin.amos.boot.module.tzs.api.dto.KV;
import com.yeejoin.amos.boot.module.tzs.api.dto.MsgLogDto;
import com.yeejoin.amos.boot.module.tzs.biz.service.impl.MsgLogServiceImpl;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.typroject.tyboot.core.foundation.enumeration.UserType;
import org.typroject.tyboot.core.restful.doc.TycloudOperation;
import org.typroject.tyboot.core.restful.utils.ResponseHelper;
import org.typroject.tyboot.core.restful.utils.ResponseModel;
import org.springframework.beans.factory.annotation.Autowired;
import javax.servlet.http.HttpServletRequest;
import org.springframework.web.bind.annotation.*;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yeejoin.amos.boot.module.tzs.api.dto.MsgLogDto;
import org.typroject.tyboot.core.restful.doc.TycloudOperation;
import org.typroject.tyboot.core.foundation.enumeration.UserType;
import java.util.List;
import java.util.Map;
/**
* 消息流水表
......@@ -92,14 +89,13 @@ public class MsgLogController extends BaseController {
* 列表分页查询
*
* @param current 当前页
* @param current 每页大小
* @param size 每页大小
* @return
*/
@TycloudOperation(ApiLevel = UserType.AGENCY)
@GetMapping(value = "/page")
@ApiOperation(httpMethod = "GET", value = "消息流水表分页查询", notes = "消息流水表分页查询")
public ResponseModel<Page<MsgLogDto>> queryForPage(@RequestParam(value = "current") int current, @RequestParam
(value = "size") int size) {
public ResponseModel<Page<MsgLogDto>> queryForPage(@RequestParam(value = "current") int current, @RequestParam(value = "size") int size) {
Page<MsgLogDto> page = new Page<MsgLogDto>();
page.setCurrent(current);
page.setSize(size);
......@@ -126,8 +122,7 @@ public class MsgLogController extends BaseController {
@TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(httpMethod = "GET", value = "告警数量统计", notes = "告警数量统计")
@GetMapping(value = "/count")
public ResponseModel<Integer> countByTerminalType(
@RequestParam(value = "terminalType", required = false) String terminalType) {
public ResponseModel<Integer> countByTerminalType(@RequestParam(value = "terminalType", required = false) String terminalType) {
return ResponseHelper.buildResponse(msgLogServiceImpl.countByTerminalType(terminalType));
}
......@@ -135,21 +130,56 @@ public class MsgLogController extends BaseController {
* 列表分页查询
*
* @param current 当前页
* @param current 每页大小
* @param size 每页大小
* @param terminalType 终端类型
* @param isRead 是否未读
* @return
*/
@TycloudOperation(ApiLevel = UserType.AGENCY)
@GetMapping(value = "/page/terminalType")
@ApiOperation(httpMethod = "GET", value = "消息流水表分页查询", notes = "消息流水表分页查询")
public ResponseModel<Page<MsgLogDto>> queryForPage(@RequestParam(value = "current") int current,
@RequestParam(value = "size") int size,
@RequestParam(value = "terminalType") String terminalType,
@RequestParam(value = "isRead") Boolean isRead) {
Page<MsgLogDto> page = new Page<MsgLogDto>();
public ResponseModel<Page<MsgLogDto>> queryForPage(
@RequestParam(value = "current") int current,
@RequestParam(value = "size") int size,
@RequestParam(required = false) String terminalType,
@RequestParam(required = false) Boolean isRead,
@RequestParam(required = false) String sendTimeStart,
@RequestParam(required = false) String sendTimeEnd,
@RequestParam(required = false) String msgType,
@RequestParam(required = false) String body
) {
Page<MsgLogDto> page = new Page<>();
page.setCurrent(current);
page.setSize(size);
return ResponseHelper.buildResponse(msgLogServiceImpl.queryForMsgLogByTerminalTypePage(page, terminalType, isRead));
return ResponseHelper.buildResponse(msgLogServiceImpl.queryForMsgLogByTerminalTypePage(page, terminalType, isRead, sendTimeStart, sendTimeEnd, msgType, body));
}
/**
* 获取消息类型
*/
@TycloudOperation(ApiLevel = UserType.AGENCY)
@GetMapping(value = "/msgType")
@ApiOperation(httpMethod = "GET", value = "获取消息类型")
public ResponseModel<List<KV>> queryForPage() {
return ResponseHelper.buildResponse(msgLogServiceImpl.getType());
}
/**
* 全部已读
*/
@TycloudOperation(ApiLevel = UserType.AGENCY)
@GetMapping(value = "/allRead")
@ApiOperation(httpMethod = "GET", value = "全部已读")
public ResponseModel<Boolean> allRead() {
return ResponseHelper.buildResponse(msgLogServiceImpl.allRead());
}
/**
* 批量删除
*/
@TycloudOperation(ApiLevel = UserType.AGENCY)
@PostMapping(value = "/deleteByIds")
@ApiOperation(httpMethod = "POST", value = "批量删除")
public ResponseModel<Boolean> deleteByIds(@RequestBody Map<String, List<Long>> body) {
return ResponseHelper.buildResponse(msgLogServiceImpl.deleteByIds(body.get("ids")));
}
}
\ No newline at end of file
}
package com.yeejoin.amos.boot.module.tzs.biz.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.google.common.collect.Lists;
import com.yeejoin.amos.boot.module.tzs.api.dto.AlertMsgDto;
import com.yeejoin.amos.boot.module.tzs.api.dto.AlertPaperInfoDto;
import com.yeejoin.amos.boot.module.tzs.api.dto.KV;
import com.yeejoin.amos.boot.module.tzs.api.dto.MsgLogDto;
import com.yeejoin.amos.boot.module.tzs.api.entity.MsgLog;
import com.yeejoin.amos.boot.module.tzs.api.enums.TerminalTypeEnum;
import com.yeejoin.amos.boot.module.tzs.api.mapper.MsgLogMapper;
import com.yeejoin.amos.boot.module.tzs.api.service.IMsgLogService;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;
import org.typroject.tyboot.core.foundation.utils.ValidationUtil;
import org.typroject.tyboot.core.rdbms.service.BaseService;
import java.util.LinkedList;
import java.util.List;
/**
......@@ -26,7 +31,7 @@ import java.util.List;
* @date 2022-04-20
*/
@Service
public class MsgLogServiceImpl extends BaseService<MsgLogDto,MsgLog,MsgLogMapper> implements IMsgLogService {
public class MsgLogServiceImpl extends BaseService<MsgLogDto, MsgLog, MsgLogMapper> implements IMsgLogService {
Logger logger = LoggerFactory.getLogger(MsgLogServiceImpl.class);
......@@ -36,26 +41,25 @@ public class MsgLogServiceImpl extends BaseService<MsgLogDto,MsgLog,MsgLogMapper
/**
* 分页查询
*/
public Page<MsgLogDto> queryForMsgLogPage(Page<MsgLogDto> page) {
public Page<MsgLogDto> queryForMsgLogPage(Page<MsgLogDto> page) {
return this.queryForPage(page, null, false);
}
/**
* 列表查询 示例
*/
public List<MsgLogDto> queryForMsgLogList() {
return this.queryForList("" , false);
public List<MsgLogDto> queryForMsgLogList() {
return this.queryForList("", false);
}
public List<MsgLogDto> queryForWebMsgLogList(String terminalType) {
return this.queryForList("" , false, terminalType);
public List<MsgLogDto> queryForWebMsgLogList(String terminalType) {
return this.queryForList("", false, terminalType);
}
public List<AlertMsgDto> queryForAlertMsg(List<String> regionCodes) {
List<AlertMsgDto> alertMsgDtoList = Lists.newArrayList();
// 查询电梯警情预报消息
List<AlertPaperInfoDto> alertPaperInfoDtoList =
alertCalledService.getAlertPaperInfoList(alertCalledService.authRegionCodeList(regionCodes), false);
List<AlertPaperInfoDto> alertPaperInfoDtoList = alertCalledService.getAlertPaperInfoList(alertCalledService.authRegionCodeList(regionCodes), false);
if (!ValidationUtil.isEmpty(alertPaperInfoDtoList)) {
alertPaperInfoDtoList.forEach(msg -> {
AlertMsgDto alertMsgDto = new AlertMsgDto();
......@@ -82,15 +86,51 @@ public class MsgLogServiceImpl extends BaseService<MsgLogDto,MsgLog,MsgLogMapper
alertMsgDtoList.add(alertMsgDto);
});
}
return alertMsgDtoList;
}
public Integer countByTerminalType(String terminalType) {
return this.list(new LambdaQueryWrapper<MsgLog>().eq(StringUtils.isNotEmpty(terminalType), MsgLog::getTerminalType, terminalType)).size();
return this.list(new LambdaQueryWrapper<MsgLog>().eq(StringUtils.hasText(terminalType), MsgLog::getTerminalType, terminalType)).size();
}
public Page<MsgLogDto> queryForMsgLogByTerminalTypePage(Page<MsgLogDto> page, String terminalType, Boolean isRead, String sendTimeStart, String sendTimeEnd, String msgType, String body) {
Page<MsgLog> msgLogPage = new Page<>(page.getCurrent(), page.getSize());
LambdaQueryWrapper<MsgLog> wrapper = new LambdaQueryWrapper<>();
if (!StringUtils.hasText(terminalType)) {
terminalType = TerminalTypeEnum.TERMINAL_TYPE_WEB.getCode();
}
wrapper.eq(MsgLog::getTerminalType, terminalType);
wrapper.eq(isRead != null, MsgLog::getIsRead, isRead);
wrapper.ge(StringUtils.hasText(sendTimeStart), MsgLog::getSendTime, sendTimeStart);
wrapper.le(StringUtils.hasText(sendTimeEnd), MsgLog::getSendTime, sendTimeEnd);
wrapper.eq(StringUtils.hasText(msgType), MsgLog::getMsgType, msgType);
wrapper.eq(MsgLog::getIsDelete, 0);
wrapper.like(StringUtils.hasText(body), MsgLog::getBody, body);
page(msgLogPage, wrapper);
LinkedList<MsgLogDto> msgLogDtos = new LinkedList<>();
for (MsgLog record : msgLogPage.getRecords()) {
MsgLogDto msgLogDto = new MsgLogDto();
BeanUtils.copyProperties(record, msgLogDto);
msgLogDtos.add(msgLogDto);
}
page.setRecords(msgLogDtos);
return page;
}
public Page<MsgLogDto> queryForMsgLogByTerminalTypePage(Page<MsgLogDto> page, String terminalType, Boolean isRead) {
return this.queryForPage(page, "rec_date", false, terminalType, isRead);
public List<KV> getType() {
return getBaseMapper().getMsgType();
}
}
\ No newline at end of file
public boolean allRead() {
LambdaUpdateWrapper<MsgLog> wrapper = new LambdaUpdateWrapper<>();
wrapper.eq(MsgLog::getIsRead, 0).set(MsgLog::getIsRead, 1);
return update(wrapper);
}
public boolean deleteByIds(List<Long> longs) {
LambdaUpdateWrapper<MsgLog> wrapper = new LambdaUpdateWrapper<>();
wrapper.in(MsgLog::getSequenceNbr, longs).set(MsgLog::getIsDelete, 1);
return update(wrapper);
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment