12 changed files with 548 additions and 15 deletions
@ -0,0 +1,107 @@ |
|||
package cn.iocoder.yudao.module.hand.controller.admin; |
|||
|
|||
import cn.iocoder.yudao.module.hand.dal.AlarmMessageDO; |
|||
import cn.iocoder.yudao.module.hand.service.AlarmMessageService; |
|||
import cn.iocoder.yudao.module.hand.vo.AlarmMessagePageReqVO; |
|||
import cn.iocoder.yudao.module.hand.vo.AlarmMessageRespVO; |
|||
import cn.iocoder.yudao.module.hand.vo.AlarmMessageSaveReqVO; |
|||
import org.springframework.web.bind.annotation.*; |
|||
import jakarta.annotation.Resource; |
|||
import org.springframework.validation.annotation.Validated; |
|||
import org.springframework.security.access.prepost.PreAuthorize; |
|||
import io.swagger.v3.oas.annotations.tags.Tag; |
|||
import io.swagger.v3.oas.annotations.Parameter; |
|||
import io.swagger.v3.oas.annotations.Operation; |
|||
|
|||
import jakarta.validation.constraints.*; |
|||
import jakarta.validation.*; |
|||
import jakarta.servlet.http.*; |
|||
import java.util.*; |
|||
import java.io.IOException; |
|||
|
|||
import cn.iocoder.yudao.framework.common.pojo.PageParam; |
|||
import cn.iocoder.yudao.framework.common.pojo.PageResult; |
|||
import cn.iocoder.yudao.framework.common.pojo.CommonResult; |
|||
import cn.iocoder.yudao.framework.common.util.object.BeanUtils; |
|||
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; |
|||
|
|||
import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; |
|||
|
|||
import cn.iocoder.yudao.framework.apilog.core.annotation.ApiAccessLog; |
|||
import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.*; |
|||
|
|||
|
|||
|
|||
@Tag(name = "管理后台 - GAS手持探测器推送") |
|||
@RestController |
|||
@RequestMapping("/gas/alarm-message") |
|||
@Validated |
|||
public class AlarmMessageController { |
|||
|
|||
@Resource |
|||
private AlarmMessageService alarmMessageService; |
|||
|
|||
@PostMapping("/create") |
|||
@Operation(summary = "创建GAS手持探测器推送") |
|||
@PreAuthorize("@ss.hasPermission('gas:alarm-message:create')") |
|||
public CommonResult<Long> createAlarmMessage(@Valid @RequestBody AlarmMessageSaveReqVO createReqVO) { |
|||
return success(alarmMessageService.createAlarmMessage(createReqVO)); |
|||
} |
|||
|
|||
@PutMapping("/update") |
|||
@Operation(summary = "更新GAS手持探测器推送") |
|||
@PreAuthorize("@ss.hasPermission('gas:alarm-message:update')") |
|||
public CommonResult<Boolean> updateAlarmMessage(@Valid @RequestBody AlarmMessageSaveReqVO updateReqVO) { |
|||
alarmMessageService.updateAlarmMessage(updateReqVO); |
|||
return success(true); |
|||
} |
|||
|
|||
@DeleteMapping("/delete") |
|||
@Operation(summary = "删除GAS手持探测器推送") |
|||
@Parameter(name = "id", description = "编号", required = true) |
|||
@PreAuthorize("@ss.hasPermission('gas:alarm-message:delete')") |
|||
public CommonResult<Boolean> deleteAlarmMessage(@RequestParam("id") Long id) { |
|||
alarmMessageService.deleteAlarmMessage(id); |
|||
return success(true); |
|||
} |
|||
|
|||
@DeleteMapping("/delete-list") |
|||
@Parameter(name = "ids", description = "编号", required = true) |
|||
@Operation(summary = "批量删除GAS手持探测器推送") |
|||
@PreAuthorize("@ss.hasPermission('gas:alarm-message:delete')") |
|||
public CommonResult<Boolean> deleteAlarmMessageList(@RequestParam("ids") List<Long> ids) { |
|||
alarmMessageService.deleteAlarmMessageListByIds(ids); |
|||
return success(true); |
|||
} |
|||
|
|||
@GetMapping("/get") |
|||
@Operation(summary = "获得GAS手持探测器推送") |
|||
@Parameter(name = "id", description = "编号", required = true, example = "1024") |
|||
@PreAuthorize("@ss.hasPermission('gas:alarm-message:query')") |
|||
public CommonResult<AlarmMessageRespVO> getAlarmMessage(@RequestParam("id") Long id) { |
|||
AlarmMessageDO alarmMessage = alarmMessageService.getAlarmMessage(id); |
|||
return success(BeanUtils.toBean(alarmMessage, AlarmMessageRespVO.class)); |
|||
} |
|||
|
|||
@GetMapping("/page") |
|||
@Operation(summary = "获得GAS手持探测器推送分页") |
|||
@PreAuthorize("@ss.hasPermission('gas:alarm-message:query')") |
|||
public CommonResult<PageResult<AlarmMessageRespVO>> getAlarmMessagePage(@Valid AlarmMessagePageReqVO pageReqVO) { |
|||
PageResult<AlarmMessageDO> pageResult = alarmMessageService.getAlarmMessagePage(pageReqVO); |
|||
return success(BeanUtils.toBean(pageResult, AlarmMessageRespVO.class)); |
|||
} |
|||
|
|||
@GetMapping("/export-excel") |
|||
@Operation(summary = "导出GAS手持探测器推送 Excel") |
|||
@PreAuthorize("@ss.hasPermission('gas:alarm-message:export')") |
|||
@ApiAccessLog(operateType = EXPORT) |
|||
public void exportAlarmMessageExcel(@Valid AlarmMessagePageReqVO pageReqVO, |
|||
HttpServletResponse response) throws IOException { |
|||
pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE); |
|||
List<AlarmMessageDO> list = alarmMessageService.getAlarmMessagePage(pageReqVO).getList(); |
|||
// 导出 Excel
|
|||
ExcelUtils.write(response, "GAS手持探测器推送.xls", "数据", AlarmMessageRespVO.class, |
|||
BeanUtils.toBean(list, AlarmMessageRespVO.class)); |
|||
} |
|||
|
|||
} |
|||
@ -0,0 +1,63 @@ |
|||
package cn.iocoder.yudao.module.hand.dal; |
|||
|
|||
import lombok.*; |
|||
import java.util.*; |
|||
import java.time.LocalDateTime; |
|||
import java.time.LocalDateTime; |
|||
import com.baomidou.mybatisplus.annotation.*; |
|||
import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; |
|||
|
|||
/** |
|||
* GAS手持探测器推送 DO |
|||
* |
|||
* @author 超级管理员 |
|||
*/ |
|||
@TableName("gas_alarm_message") |
|||
@KeySequence("gas_alarm_message_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。
|
|||
@Data |
|||
@EqualsAndHashCode(callSuper = true) |
|||
@ToString(callSuper = true) |
|||
@Builder |
|||
@NoArgsConstructor |
|||
@AllArgsConstructor |
|||
public class AlarmMessageDO extends BaseDO { |
|||
|
|||
/** |
|||
* 主键ID |
|||
*/ |
|||
@TableId |
|||
private Long id; |
|||
/** |
|||
* 手持表id |
|||
*/ |
|||
private Long detectorId; |
|||
/** |
|||
* 持有人名称 |
|||
*/ |
|||
private String name; |
|||
/** |
|||
* 设备编号 |
|||
*/ |
|||
private String sn; |
|||
/** |
|||
* 消息 |
|||
*/ |
|||
private String message; |
|||
/** |
|||
* 推送设备sn,逗号分割 |
|||
*/ |
|||
private String pushSnList; |
|||
/** |
|||
* 备注 |
|||
*/ |
|||
private String remark; |
|||
/** |
|||
* 部门id |
|||
*/ |
|||
private Long deptId; |
|||
/** |
|||
* 租户id |
|||
*/ |
|||
private Long tenantId; |
|||
|
|||
} |
|||
@ -0,0 +1,33 @@ |
|||
package cn.iocoder.yudao.module.hand.mapper; |
|||
|
|||
import java.util.*; |
|||
|
|||
import cn.iocoder.yudao.framework.common.pojo.PageResult; |
|||
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; |
|||
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; |
|||
import cn.iocoder.yudao.module.hand.dal.AlarmMessageDO; |
|||
import cn.iocoder.yudao.module.hand.vo.AlarmMessagePageReqVO; |
|||
import org.apache.ibatis.annotations.Mapper; |
|||
|
|||
/** |
|||
* GAS手持探测器推送 Mapper |
|||
* |
|||
* @author 超级管理员 |
|||
*/ |
|||
@Mapper |
|||
public interface AlarmMessageMapper extends BaseMapperX<AlarmMessageDO> { |
|||
|
|||
default PageResult<AlarmMessageDO> selectPage(AlarmMessagePageReqVO reqVO) { |
|||
return selectPage(reqVO, new LambdaQueryWrapperX<AlarmMessageDO>() |
|||
.eqIfPresent(AlarmMessageDO::getDetectorId, reqVO.getDetectorId()) |
|||
.likeIfPresent(AlarmMessageDO::getName, reqVO.getName()) |
|||
.eqIfPresent(AlarmMessageDO::getSn, reqVO.getSn()) |
|||
.eqIfPresent(AlarmMessageDO::getMessage, reqVO.getMessage()) |
|||
.eqIfPresent(AlarmMessageDO::getPushSnList, reqVO.getPushSnList()) |
|||
.eqIfPresent(AlarmMessageDO::getRemark, reqVO.getRemark()) |
|||
.eqIfPresent(AlarmMessageDO::getDeptId, reqVO.getDeptId()) |
|||
.betweenIfPresent(AlarmMessageDO::getCreateTime, reqVO.getCreateTime()) |
|||
.orderByDesc(AlarmMessageDO::getId)); |
|||
} |
|||
|
|||
} |
|||
@ -0,0 +1,67 @@ |
|||
package cn.iocoder.yudao.module.hand.service; |
|||
|
|||
import java.util.*; |
|||
|
|||
import cn.iocoder.yudao.module.hand.dal.AlarmMessageDO; |
|||
import cn.iocoder.yudao.module.hand.dal.HandDetectorDO; |
|||
import cn.iocoder.yudao.module.hand.vo.AlarmMessagePageReqVO; |
|||
import cn.iocoder.yudao.module.hand.vo.AlarmMessageSaveReqVO; |
|||
import cn.iocoder.yudao.module.hand.vo.HandDataVo; |
|||
import jakarta.validation.*; |
|||
import cn.iocoder.yudao.framework.common.pojo.PageResult; |
|||
import cn.iocoder.yudao.framework.common.pojo.PageParam; |
|||
|
|||
/** |
|||
* GAS手持探测器推送 Service 接口 |
|||
* |
|||
* @author 超级管理员 |
|||
*/ |
|||
public interface AlarmMessageService { |
|||
|
|||
/** |
|||
* 创建GAS手持探测器推送 |
|||
* |
|||
* @param createReqVO 创建信息 |
|||
* @return 编号 |
|||
*/ |
|||
Long createAlarmMessage(@Valid AlarmMessageSaveReqVO createReqVO); |
|||
|
|||
/** |
|||
* 更新GAS手持探测器推送 |
|||
* |
|||
* @param updateReqVO 更新信息 |
|||
*/ |
|||
void updateAlarmMessage(@Valid AlarmMessageSaveReqVO updateReqVO); |
|||
|
|||
/** |
|||
* 删除GAS手持探测器推送 |
|||
* |
|||
* @param id 编号 |
|||
*/ |
|||
void deleteAlarmMessage(Long id); |
|||
|
|||
/** |
|||
* 批量删除GAS手持探测器推送 |
|||
* |
|||
* @param ids 编号 |
|||
*/ |
|||
void deleteAlarmMessageListByIds(List<Long> ids); |
|||
|
|||
/** |
|||
* 获得GAS手持探测器推送 |
|||
* |
|||
* @param id 编号 |
|||
* @return GAS手持探测器推送 |
|||
*/ |
|||
AlarmMessageDO getAlarmMessage(Long id); |
|||
|
|||
/** |
|||
* 获得GAS手持探测器推送分页 |
|||
* |
|||
* @param pageReqVO 分页查询 |
|||
* @return GAS手持探测器推送分页 |
|||
*/ |
|||
PageResult<AlarmMessageDO> getAlarmMessagePage(AlarmMessagePageReqVO pageReqVO); |
|||
|
|||
void createAlarmRecord(HandDataVo redisData, List<HandDetectorDO> listAll, String msgContent); |
|||
} |
|||
@ -0,0 +1,117 @@ |
|||
package cn.iocoder.yudao.module.hand.service.impl; |
|||
|
|||
import cn.hutool.core.collection.CollUtil; |
|||
import cn.hutool.core.util.StrUtil; |
|||
import cn.iocoder.yudao.module.hand.dal.AlarmMessageDO; |
|||
import cn.iocoder.yudao.module.hand.dal.HandDetectorDO; |
|||
import cn.iocoder.yudao.module.hand.mapper.AlarmMessageMapper; |
|||
import cn.iocoder.yudao.module.hand.service.AlarmMessageService; |
|||
import cn.iocoder.yudao.module.hand.vo.AlarmMessagePageReqVO; |
|||
import cn.iocoder.yudao.module.hand.vo.AlarmMessageSaveReqVO; |
|||
import cn.iocoder.yudao.module.hand.vo.HandDataVo; |
|||
import org.springframework.stereotype.Service; |
|||
import jakarta.annotation.Resource; |
|||
import org.springframework.validation.annotation.Validated; |
|||
import org.springframework.transaction.annotation.Transactional; |
|||
|
|||
import java.util.*; |
|||
import java.util.stream.Collectors; |
|||
|
|||
import cn.iocoder.yudao.framework.common.pojo.PageResult; |
|||
import cn.iocoder.yudao.framework.common.pojo.PageParam; |
|||
import cn.iocoder.yudao.framework.common.util.object.BeanUtils; |
|||
|
|||
|
|||
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; |
|||
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertList; |
|||
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.diffList; |
|||
import static cn.iocoder.yudao.module.hand.enums.ErrorCodeConstants.ALARM_MESSAGE_NOT_EXISTS; |
|||
|
|||
/** |
|||
* GAS手持探测器推送 Service 实现类 |
|||
* |
|||
* @author 超级管理员 |
|||
*/ |
|||
@Service |
|||
@Validated |
|||
public class AlarmMessageServiceImpl implements AlarmMessageService { |
|||
|
|||
@Resource |
|||
private AlarmMessageMapper alarmMessageMapper; |
|||
|
|||
@Override |
|||
public Long createAlarmMessage(AlarmMessageSaveReqVO createReqVO) { |
|||
// 插入
|
|||
AlarmMessageDO alarmMessage = BeanUtils.toBean(createReqVO, AlarmMessageDO.class); |
|||
alarmMessageMapper.insert(alarmMessage); |
|||
|
|||
// 返回
|
|||
return alarmMessage.getId(); |
|||
} |
|||
|
|||
@Override |
|||
public void updateAlarmMessage(AlarmMessageSaveReqVO updateReqVO) { |
|||
// 校验存在
|
|||
validateAlarmMessageExists(updateReqVO.getId()); |
|||
// 更新
|
|||
AlarmMessageDO updateObj = BeanUtils.toBean(updateReqVO, AlarmMessageDO.class); |
|||
alarmMessageMapper.updateById(updateObj); |
|||
} |
|||
|
|||
@Override |
|||
public void deleteAlarmMessage(Long id) { |
|||
// 校验存在
|
|||
validateAlarmMessageExists(id); |
|||
// 删除
|
|||
alarmMessageMapper.deleteById(id); |
|||
} |
|||
|
|||
@Override |
|||
public void deleteAlarmMessageListByIds(List<Long> ids) { |
|||
// 删除
|
|||
alarmMessageMapper.deleteByIds(ids); |
|||
} |
|||
|
|||
|
|||
private void validateAlarmMessageExists(Long id) { |
|||
if (alarmMessageMapper.selectById(id) == null) { |
|||
throw exception(ALARM_MESSAGE_NOT_EXISTS); |
|||
} |
|||
} |
|||
|
|||
@Override |
|||
public AlarmMessageDO getAlarmMessage(Long id) { |
|||
return alarmMessageMapper.selectById(id); |
|||
} |
|||
|
|||
@Override |
|||
public PageResult<AlarmMessageDO> getAlarmMessagePage(AlarmMessagePageReqVO pageReqVO) { |
|||
return alarmMessageMapper.selectPage(pageReqVO); |
|||
} |
|||
|
|||
@Override |
|||
@Transactional(rollbackFor = Exception.class) |
|||
public void createAlarmRecord(HandDataVo redisData, List<HandDetectorDO> listAll, String msgContent) { |
|||
String pushSnListStr = ""; |
|||
if (CollUtil.isNotEmpty(listAll)) { |
|||
pushSnListStr = listAll.stream() |
|||
.map(HandDetectorDO::getSn) |
|||
.filter(StrUtil::isNotBlank) |
|||
.collect(Collectors.joining(",")); |
|||
} |
|||
// 2. 构建实体对象
|
|||
AlarmMessageDO alarmDO = new AlarmMessageDO(); |
|||
alarmDO.setDetectorId(redisData.getId()); |
|||
alarmDO.setName(redisData.getName()); |
|||
alarmDO.setSn(redisData.getSn()); |
|||
alarmDO.setTenantId(redisData.getTenantId()); |
|||
alarmDO.setDeptId(redisData.getDeptId()); |
|||
alarmDO.setMessage(msgContent); |
|||
alarmDO.setPushSnList(pushSnListStr); |
|||
alarmDO.setRemark("系统自动触发报警推送"); |
|||
|
|||
// 3. 落库
|
|||
alarmMessageMapper.insert(alarmDO); |
|||
} |
|||
|
|||
} |
|||
@ -0,0 +1,41 @@ |
|||
package cn.iocoder.yudao.module.hand.vo; |
|||
|
|||
import lombok.*; |
|||
import java.util.*; |
|||
import io.swagger.v3.oas.annotations.media.Schema; |
|||
import cn.iocoder.yudao.framework.common.pojo.PageParam; |
|||
import org.springframework.format.annotation.DateTimeFormat; |
|||
import java.time.LocalDateTime; |
|||
|
|||
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; |
|||
|
|||
@Schema(description = "管理后台 - GAS手持探测器推送分页 Request VO") |
|||
@Data |
|||
public class AlarmMessagePageReqVO extends PageParam { |
|||
|
|||
@Schema(description = "手持表id", example = "10665") |
|||
private Long detectorId; |
|||
|
|||
@Schema(description = "持有人名称", example = "王五") |
|||
private String name; |
|||
|
|||
@Schema(description = "设备编号") |
|||
private String sn; |
|||
|
|||
@Schema(description = "消息") |
|||
private String message; |
|||
|
|||
@Schema(description = "推送设备sn,逗号分割") |
|||
private String pushSnList; |
|||
|
|||
@Schema(description = "备注", example = "随便") |
|||
private String remark; |
|||
|
|||
@Schema(description = "部门id", example = "12286") |
|||
private Long deptId; |
|||
|
|||
@Schema(description = "创建时间") |
|||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) |
|||
private LocalDateTime[] createTime; |
|||
|
|||
} |
|||
@ -0,0 +1,51 @@ |
|||
package cn.iocoder.yudao.module.hand.vo; |
|||
|
|||
import io.swagger.v3.oas.annotations.media.Schema; |
|||
import lombok.*; |
|||
import java.util.*; |
|||
import org.springframework.format.annotation.DateTimeFormat; |
|||
import java.time.LocalDateTime; |
|||
import com.alibaba.excel.annotation.*; |
|||
|
|||
@Schema(description = "管理后台 - GAS手持探测器推送 Response VO") |
|||
@Data |
|||
@ExcelIgnoreUnannotated |
|||
public class AlarmMessageRespVO { |
|||
|
|||
@Schema(description = "主键ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "13733") |
|||
@ExcelProperty("主键ID") |
|||
private Long id; |
|||
|
|||
@Schema(description = "手持表id", example = "10665") |
|||
@ExcelProperty("手持表id") |
|||
private Long detectorId; |
|||
|
|||
@Schema(description = "持有人名称", example = "王五") |
|||
@ExcelProperty("持有人名称") |
|||
private String name; |
|||
|
|||
@Schema(description = "设备编号") |
|||
@ExcelProperty("设备编号") |
|||
private String sn; |
|||
|
|||
@Schema(description = "消息") |
|||
@ExcelProperty("消息") |
|||
private String message; |
|||
|
|||
@Schema(description = "推送设备sn,逗号分割") |
|||
@ExcelProperty("推送设备sn,逗号分割") |
|||
private String pushSnList; |
|||
|
|||
@Schema(description = "备注", example = "随便") |
|||
@ExcelProperty("备注") |
|||
private String remark; |
|||
|
|||
@Schema(description = "部门id", example = "12286") |
|||
@ExcelProperty("部门id") |
|||
private Long deptId; |
|||
|
|||
@Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) |
|||
@ExcelProperty("创建时间") |
|||
private LocalDateTime createTime; |
|||
|
|||
} |
|||
@ -0,0 +1,36 @@ |
|||
package cn.iocoder.yudao.module.hand.vo; |
|||
|
|||
import io.swagger.v3.oas.annotations.media.Schema; |
|||
import lombok.*; |
|||
import java.util.*; |
|||
import jakarta.validation.constraints.*; |
|||
|
|||
@Schema(description = "管理后台 - GAS手持探测器推送新增/修改 Request VO") |
|||
@Data |
|||
public class AlarmMessageSaveReqVO { |
|||
|
|||
@Schema(description = "主键ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "13733") |
|||
private Long id; |
|||
|
|||
@Schema(description = "手持表id", example = "10665") |
|||
private Long detectorId; |
|||
|
|||
@Schema(description = "持有人名称", example = "王五") |
|||
private String name; |
|||
|
|||
@Schema(description = "设备编号") |
|||
private String sn; |
|||
|
|||
@Schema(description = "消息") |
|||
private String message; |
|||
|
|||
@Schema(description = "推送设备sn,逗号分割") |
|||
private String pushSnList; |
|||
|
|||
@Schema(description = "备注", example = "随便") |
|||
private String remark; |
|||
|
|||
@Schema(description = "部门id", example = "12286") |
|||
private Long deptId; |
|||
|
|||
} |
|||
@ -0,0 +1,12 @@ |
|||
<?xml version="1.0" encoding="UTF-8"?> |
|||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
|||
<mapper namespace="cn.iocoder.yudao.module.hand.mapper.AlarmMessageMapper"> |
|||
|
|||
<!-- |
|||
一般情况下,尽可能使用 Mapper 进行 CRUD 增删改查即可。 |
|||
无法满足的场景,例如说多表关联查询,才使用 XML 编写 SQL。 |
|||
代码生成器暂时只生成 Mapper XML 文件本身,更多推荐 MybatisX 快速开发插件来生成查询。 |
|||
文档可见:https://www.iocoder.cn/MyBatis/x-plugins/ |
|||
--> |
|||
|
|||
</mapper> |
|||
Loading…
Reference in new issue