Browse Source

预警状态通知接口

tags/v1.2.0^2
chengwang 1 year ago
parent
commit
f12726d6ff
5 changed files with 134 additions and 0 deletions
  1. +19
    -0
      tuoheng-admin/src/main/java/com/tuoheng/admin/controller/WarningController.java
  2. +13
    -0
      tuoheng-admin/src/main/java/com/tuoheng/admin/service/warning/IWarningService.java
  3. +18
    -0
      tuoheng-admin/src/main/java/com/tuoheng/admin/service/warning/WarningServiceImpl.java
  4. +36
    -0
      tuoheng-admin/src/main/java/com/tuoheng/admin/service/warning/edit/WarningStatusService.java
  5. +48
    -0
      tuoheng-admin/src/main/java/com/tuoheng/admin/service/warning/notice/WarningNoticeService.java

+ 19
- 0
tuoheng-admin/src/main/java/com/tuoheng/admin/controller/WarningController.java View File

@@ -74,4 +74,23 @@ public class WarningController {
public JsonResult details(@PathVariable("id") Integer id){
return warningService.details(id);
}

/**
* 火灾通知下发
* @return
*/
@GetMapping("/notice")
public JsonResult notice(){
return warningService.notice();
}

/**
* 通知预警与处理
* @param id
* @return
*/
@PutMapping("/status/{id}/{status}")
public JsonResult editStatusById(@PathVariable("id") Integer id,@PathVariable("status") Integer status){
return warningService.editStatusById(id,status);
}
}

+ 13
- 0
tuoheng-admin/src/main/java/com/tuoheng/admin/service/warning/IWarningService.java View File

@@ -63,4 +63,17 @@ public interface IWarningService extends IBaseService<Warning> {
* @return
*/
JsonResult details(Integer id);

/**
* 预警通知下发
* @return
*/
JsonResult notice();

/**
* 通知预警与处理
* @param id
* @return
*/
JsonResult editStatusById(Integer id,Integer status);
}

+ 18
- 0
tuoheng-admin/src/main/java/com/tuoheng/admin/service/warning/WarningServiceImpl.java View File

@@ -7,7 +7,9 @@ import com.tuoheng.admin.entity.request.warning.WarningConfirmRequest;
import com.tuoheng.admin.mapper.WarningMapper;
import com.tuoheng.admin.service.warning.confirm.WarningConfirmService;
import com.tuoheng.admin.service.warning.details.WarningDetailsService;
import com.tuoheng.admin.service.warning.edit.WarningStatusService;
import com.tuoheng.admin.service.warning.ignore.WarningIgnoreService;
import com.tuoheng.admin.service.warning.notice.WarningNoticeService;
import com.tuoheng.admin.service.warning.query.QueryWarningByIdService;
import com.tuoheng.admin.service.warning.query.QueryWarningListService;
import com.tuoheng.admin.service.warning.query.QueryWarningPageListService;
@@ -46,6 +48,12 @@ public class WarningServiceImpl extends BaseServiceImpl<WarningMapper, Warning>
@Autowired
private WarningDetailsService warningDetailsService;

@Autowired
private WarningNoticeService warningNoticeService;

@Autowired
private WarningStatusService warningStatusService;



/**
@@ -90,5 +98,15 @@ public class WarningServiceImpl extends BaseServiceImpl<WarningMapper, Warning>
return warningDetailsService.details(id);
}

@Override
public JsonResult notice() {
return warningNoticeService.notice();
}

@Override
public JsonResult editStatusById(Integer id,Integer status) {
return warningStatusService.editStatusById(id,status);
}


}

+ 36
- 0
tuoheng-admin/src/main/java/com/tuoheng/admin/service/warning/edit/WarningStatusService.java View File

@@ -0,0 +1,36 @@
package com.tuoheng.admin.service.warning.edit;

import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.tuoheng.admin.entity.domain.Warning;
import com.tuoheng.admin.enums.MarkTypeEnum;
import com.tuoheng.admin.mapper.WarningMapper;
import com.tuoheng.common.utils.JsonResult;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
* @Author ChengWang
* @Date 2023/2/9
*/
@Service
@Slf4j
public class WarningStatusService {

@Autowired
private WarningMapper warningMapper;


public JsonResult editStatusById(Integer id,Integer status) {
//根据id查询并更新预警状态
Warning warning = warningMapper.selectById(id);
if(ObjectUtils.isNotEmpty(warning)){
warning.setStatus(status);
warningMapper.updateById(warning);
}

return JsonResult.success();
}
}

+ 48
- 0
tuoheng-admin/src/main/java/com/tuoheng/admin/service/warning/notice/WarningNoticeService.java View File

@@ -0,0 +1,48 @@
package com.tuoheng.admin.service.warning.notice;

import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.tuoheng.admin.entity.domain.Warning;
import com.tuoheng.admin.enums.MarkTypeEnum;
import com.tuoheng.admin.enums.WarningStatusEnum;
import com.tuoheng.admin.mapper.WarningMapper;
import com.tuoheng.common.utils.JsonResult;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;


/**
* 火灾预警通知下发业务处理层
* @Author ChengWang
* @Date 2023/2/9
*/
@Service
@Slf4j
public class WarningNoticeService {

@Autowired
private WarningMapper warningMapper;

/**
* 火灾通知下发弹窗
* @return
*/
public JsonResult notice() {
//当前登录用户
// User user = ShiroUtils.getUserInfo();
// Integer tenantId = ShiroUtils.getTenantId();
Integer tenantId = 1;
//查询预警表是否有预警数据
List<Warning> warningList = warningMapper.selectList(Wrappers.<Warning>lambdaQuery()
.eq(Warning::getTenantId, tenantId)
.eq(Warning::getStatus, WarningStatusEnum.WAIT_CONFIRM.getCode())
.eq(Warning::getMark, MarkTypeEnum.VALID.getCode()));
if(CollectionUtils.isEmpty(warningList) || warningList.size() == 0){
return JsonResult.success();
}
return JsonResult.success(warningList);
}
}

Loading…
Cancel
Save