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; 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.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 接口 * 消息流水表 Mapper 接口
...@@ -10,5 +13,5 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper; ...@@ -10,5 +13,5 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
* @date 2022-04-20 * @date 2022-04-20
*/ */
public interface MsgLogMapper extends BaseMapper<MsgLog> { public interface MsgLogMapper extends BaseMapper<MsgLog> {
List<KV> getMsgType();
} }
...@@ -2,4 +2,10 @@ ...@@ -2,4 +2,10 @@
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> <!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"> <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> </mapper>
package com.yeejoin.amos.boot.module.tzs.biz.controller; package com.yeejoin.amos.boot.module.tzs.biz.controller;
import org.springframework.web.bind.annotation.RequestMapping; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.Api;
import org.springframework.web.bind.annotation.RestController;
import com.yeejoin.amos.boot.biz.common.controller.BaseController; import com.yeejoin.amos.boot.biz.common.controller.BaseController;
import com.yeejoin.amos.boot.module.tzs.api.dto.KV;
import java.util.List; import com.yeejoin.amos.boot.module.tzs.api.dto.MsgLogDto;
import com.yeejoin.amos.boot.module.tzs.biz.service.impl.MsgLogServiceImpl; 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.ResponseHelper;
import org.typroject.tyboot.core.restful.utils.ResponseModel; import org.typroject.tyboot.core.restful.utils.ResponseModel;
import org.springframework.beans.factory.annotation.Autowired;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import java.util.List;
import org.springframework.web.bind.annotation.*; import java.util.Map;
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;
/** /**
* 消息流水表 * 消息流水表
...@@ -92,14 +89,13 @@ public class MsgLogController extends BaseController { ...@@ -92,14 +89,13 @@ public class MsgLogController extends BaseController {
* 列表分页查询 * 列表分页查询
* *
* @param current 当前页 * @param current 当前页
* @param current 每页大小 * @param size 每页大小
* @return * @return
*/ */
@TycloudOperation(ApiLevel = UserType.AGENCY) @TycloudOperation(ApiLevel = UserType.AGENCY)
@GetMapping(value = "/page") @GetMapping(value = "/page")
@ApiOperation(httpMethod = "GET", value = "消息流水表分页查询", notes = "消息流水表分页查询") @ApiOperation(httpMethod = "GET", value = "消息流水表分页查询", notes = "消息流水表分页查询")
public ResponseModel<Page<MsgLogDto>> queryForPage(@RequestParam(value = "current") int current, @RequestParam public ResponseModel<Page<MsgLogDto>> queryForPage(@RequestParam(value = "current") int current, @RequestParam(value = "size") int size) {
(value = "size") int size) {
Page<MsgLogDto> page = new Page<MsgLogDto>(); Page<MsgLogDto> page = new Page<MsgLogDto>();
page.setCurrent(current); page.setCurrent(current);
page.setSize(size); page.setSize(size);
...@@ -126,8 +122,7 @@ public class MsgLogController extends BaseController { ...@@ -126,8 +122,7 @@ public class MsgLogController extends BaseController {
@TycloudOperation(ApiLevel = UserType.AGENCY) @TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(httpMethod = "GET", value = "告警数量统计", notes = "告警数量统计") @ApiOperation(httpMethod = "GET", value = "告警数量统计", notes = "告警数量统计")
@GetMapping(value = "/count") @GetMapping(value = "/count")
public ResponseModel<Integer> countByTerminalType( public ResponseModel<Integer> countByTerminalType(@RequestParam(value = "terminalType", required = false) String terminalType) {
@RequestParam(value = "terminalType", required = false) String terminalType) {
return ResponseHelper.buildResponse(msgLogServiceImpl.countByTerminalType(terminalType)); return ResponseHelper.buildResponse(msgLogServiceImpl.countByTerminalType(terminalType));
} }
...@@ -135,21 +130,56 @@ public class MsgLogController extends BaseController { ...@@ -135,21 +130,56 @@ public class MsgLogController extends BaseController {
* 列表分页查询 * 列表分页查询
* *
* @param current 当前页 * @param current 当前页
* @param current 每页大小 * @param size 每页大小
* @param terminalType 终端类型 * @param terminalType 终端类型
* @param isRead 是否未读 * @param isRead 是否未读
* @return
*/ */
@TycloudOperation(ApiLevel = UserType.AGENCY) @TycloudOperation(ApiLevel = UserType.AGENCY)
@GetMapping(value = "/page/terminalType") @GetMapping(value = "/page/terminalType")
@ApiOperation(httpMethod = "GET", value = "消息流水表分页查询", notes = "消息流水表分页查询") @ApiOperation(httpMethod = "GET", value = "消息流水表分页查询", notes = "消息流水表分页查询")
public ResponseModel<Page<MsgLogDto>> queryForPage(@RequestParam(value = "current") int current, public ResponseModel<Page<MsgLogDto>> queryForPage(
@RequestParam(value = "size") int size, @RequestParam(value = "current") int current,
@RequestParam(value = "terminalType") String terminalType, @RequestParam(value = "size") int size,
@RequestParam(value = "isRead") Boolean isRead) { @RequestParam(required = false) String terminalType,
Page<MsgLogDto> page = new Page<MsgLogDto>(); @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.setCurrent(current);
page.setSize(size); 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; package com.yeejoin.amos.boot.module.tzs.biz.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; 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.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.google.common.collect.Lists; 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.AlertMsgDto;
import com.yeejoin.amos.boot.module.tzs.api.dto.AlertPaperInfoDto; 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.dto.MsgLogDto;
import com.yeejoin.amos.boot.module.tzs.api.entity.MsgLog; 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.mapper.MsgLogMapper;
import com.yeejoin.amos.boot.module.tzs.api.service.IMsgLogService; import com.yeejoin.amos.boot.module.tzs.api.service.IMsgLogService;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.BeanUtils;
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.util.StringUtils;
import org.typroject.tyboot.core.foundation.utils.ValidationUtil; import org.typroject.tyboot.core.foundation.utils.ValidationUtil;
import org.typroject.tyboot.core.rdbms.service.BaseService; import org.typroject.tyboot.core.rdbms.service.BaseService;
import java.util.LinkedList;
import java.util.List; import java.util.List;
/** /**
...@@ -26,7 +31,7 @@ import java.util.List; ...@@ -26,7 +31,7 @@ import java.util.List;
* @date 2022-04-20 * @date 2022-04-20
*/ */
@Service @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); Logger logger = LoggerFactory.getLogger(MsgLogServiceImpl.class);
...@@ -36,26 +41,25 @@ public class MsgLogServiceImpl extends BaseService<MsgLogDto,MsgLog,MsgLogMapper ...@@ -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); return this.queryForPage(page, null, false);
} }
/** /**
* 列表查询 示例 * 列表查询 示例
*/ */
public List<MsgLogDto> queryForMsgLogList() { public List<MsgLogDto> queryForMsgLogList() {
return this.queryForList("" , false); return this.queryForList("", false);
} }
public List<MsgLogDto> queryForWebMsgLogList(String terminalType) { public List<MsgLogDto> queryForWebMsgLogList(String terminalType) {
return this.queryForList("" , false, terminalType); return this.queryForList("", false, terminalType);
} }
public List<AlertMsgDto> queryForAlertMsg(List<String> regionCodes) { public List<AlertMsgDto> queryForAlertMsg(List<String> regionCodes) {
List<AlertMsgDto> alertMsgDtoList = Lists.newArrayList(); List<AlertMsgDto> alertMsgDtoList = Lists.newArrayList();
// 查询电梯警情预报消息 // 查询电梯警情预报消息
List<AlertPaperInfoDto> alertPaperInfoDtoList = List<AlertPaperInfoDto> alertPaperInfoDtoList = alertCalledService.getAlertPaperInfoList(alertCalledService.authRegionCodeList(regionCodes), false);
alertCalledService.getAlertPaperInfoList(alertCalledService.authRegionCodeList(regionCodes), false);
if (!ValidationUtil.isEmpty(alertPaperInfoDtoList)) { if (!ValidationUtil.isEmpty(alertPaperInfoDtoList)) {
alertPaperInfoDtoList.forEach(msg -> { alertPaperInfoDtoList.forEach(msg -> {
AlertMsgDto alertMsgDto = new AlertMsgDto(); AlertMsgDto alertMsgDto = new AlertMsgDto();
...@@ -82,15 +86,51 @@ public class MsgLogServiceImpl extends BaseService<MsgLogDto,MsgLog,MsgLogMapper ...@@ -82,15 +86,51 @@ public class MsgLogServiceImpl extends BaseService<MsgLogDto,MsgLog,MsgLogMapper
alertMsgDtoList.add(alertMsgDto); alertMsgDtoList.add(alertMsgDto);
}); });
} }
return alertMsgDtoList; return alertMsgDtoList;
} }
public Integer countByTerminalType(String terminalType) { 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) { public List<KV> getType() {
return this.queryForPage(page, "rec_date", false, terminalType, isRead); 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