@@ -10,7 +10,7 @@ import org.springframework.web.bind.annotation.RequestMapping; | |||
import org.springframework.web.bind.annotation.RestController; | |||
/** | |||
* @desc: 摄像头 | |||
* @desc: 摄像头 前端控制器 | |||
* @team: tuoheng | |||
* @author: wanjing | |||
* @date: 2023-02-06 |
@@ -9,7 +9,7 @@ import org.springframework.web.bind.annotation.RequestMapping; | |||
import org.springframework.web.bind.annotation.RestController; | |||
/** | |||
* @desc: 物资 | |||
* @desc: 仓库物资 前端控制器 | |||
* @team: tuoheng | |||
* @author: wanjing | |||
* @date: 2023-02-06 |
@@ -10,7 +10,7 @@ import org.springframework.web.bind.annotation.RequestMapping; | |||
import org.springframework.web.bind.annotation.RestController; | |||
/** | |||
* @desc: 仓库 | |||
* @desc: 仓库 前端控制器 | |||
* @team: tuoheng | |||
* @author: wanjing | |||
* @date: 2023-02-06 |
@@ -1,5 +1,6 @@ | |||
package com.tuoheng.admin.controller; | |||
import com.tuoheng.admin.entity.query.WarningQuery; | |||
import com.tuoheng.admin.entity.request.warning.QueryWarningListRequest; | |||
import com.tuoheng.admin.service.warning.IWarningService; | |||
import com.tuoheng.common.utils.JsonResult; | |||
@@ -10,7 +11,7 @@ import org.springframework.web.bind.annotation.RequestMapping; | |||
import org.springframework.web.bind.annotation.RestController; | |||
/** | |||
* @desc: 预警 | |||
* @desc: 预警 前端控制器 | |||
* @team: tuoheng | |||
* @author: wanjing | |||
* @date: 2023-02-06 | |||
@@ -22,6 +23,16 @@ public class WarningController { | |||
@Autowired | |||
private IWarningService warningService; | |||
/** | |||
* 告警列表查询 分页 | |||
* @param query | |||
* @return | |||
*/ | |||
@GetMapping("/index") | |||
public JsonResult index(WarningQuery query){ | |||
return warningService.index(query); | |||
} | |||
/** | |||
* 查询预警列表 | |||
*/ |
@@ -9,7 +9,7 @@ import org.springframework.web.bind.annotation.RequestMapping; | |||
import org.springframework.web.bind.annotation.RestController; | |||
/** | |||
* @desc: 预警记录 | |||
* @desc: 预警记录 前端控制器 | |||
* @team: tuoheng | |||
* @author: wanjing | |||
* @date: 2023-02-06 |
@@ -0,0 +1,55 @@ | |||
package com.tuoheng.admin.entity.query; | |||
import com.fasterxml.jackson.annotation.JsonFormat; | |||
import com.tuoheng.common.common.BaseQuery; | |||
import lombok.Data; | |||
import org.springframework.format.annotation.DateTimeFormat; | |||
import java.util.Date; | |||
/** | |||
* @Author ChengWang | |||
* @Date 2023/2/7 | |||
*/ | |||
@Data | |||
public class WarningQuery extends BaseQuery { | |||
/** | |||
* 租户id | |||
*/ | |||
private Integer tenantId; | |||
/** | |||
* 发现方式 | |||
*/ | |||
private Integer discoveryWay; | |||
/** | |||
* 预警状态 1待确认 2确认 3忽略 | |||
*/ | |||
private Integer status; | |||
/** | |||
* 创建时间-->预警时间 | |||
*/ | |||
private String waringTime; | |||
/** | |||
* 起始日期 | |||
*/ | |||
@DateTimeFormat(pattern = "yyyy.MM.dd hh:mm:ss") | |||
@JsonFormat(pattern = "yyyy.MM.dd hh:mm:ss", timezone = "GMT+8") | |||
private Date waringStartTime; | |||
/** | |||
* 结束日期 | |||
*/ | |||
@DateTimeFormat(pattern = "yyyy.MM.dd hh:mm:ss") | |||
@JsonFormat(pattern = "yyyy.MM.dd hh:mm:ss", timezone = "GMT+8") | |||
private Date waringEndTime; | |||
} |
@@ -0,0 +1,49 @@ | |||
package com.tuoheng.admin.entity.vo; | |||
import com.fasterxml.jackson.annotation.JsonFormat; | |||
import lombok.Data; | |||
import org.springframework.format.annotation.DateTimeFormat; | |||
import java.util.Date; | |||
/** | |||
* @Author ChengWang | |||
* @Date 2023/2/7 | |||
*/ | |||
@Data | |||
public class WarningVO { | |||
/** | |||
* 预警时间 | |||
*/ | |||
@DateTimeFormat(pattern = "yyyy.MM.dd hh:mm:ss") | |||
@JsonFormat(pattern = "yyyy.MM.dd hh:mm:ss", timezone = "GMT+8") | |||
private Date waringTime; | |||
/** | |||
* 预警来源 | |||
*/ | |||
private Integer discoveryWay; | |||
/** | |||
* 预警来源名称 | |||
*/ | |||
private String discoverWayName; | |||
/** | |||
* 火灾位置 | |||
*/ | |||
private String location; | |||
/** | |||
* 火灾核实 | |||
*/ | |||
private Integer status; | |||
/** | |||
* 火灾核实名称 | |||
*/ | |||
private String statusName; | |||
} |
@@ -0,0 +1,27 @@ | |||
package com.tuoheng.admin.enums; | |||
import lombok.Getter; | |||
/** | |||
* @Author ChengWang | |||
* @Date 2023/2/7 | |||
*/ | |||
public enum DiscoveryWayEnum { | |||
SURVEILLANCE_CAMERA(1,"监控摄像"), | |||
UAV_PATROL(2,"无人机巡检"), | |||
MANUAL_INSPECTION(3,"人工巡检"); | |||
DiscoveryWayEnum(int code, String description){ | |||
this.code = code; | |||
this.description = description; | |||
} | |||
@Getter | |||
private int code; | |||
@Getter | |||
private String description; | |||
} |
@@ -0,0 +1,43 @@ | |||
package com.tuoheng.admin.enums; | |||
/** | |||
* @Author ChengWang | |||
* @Date 2023/2/7 | |||
*/ | |||
public enum WarningEnum { | |||
DATA_IS_NULL(1210101, "数据为空"), | |||
USER_IS_NOT_EXIST(1210102, "用户为空"), | |||
TENANT_ID_IS_NULL(1210103,"租户id为空"); | |||
/** | |||
* 错误码 | |||
*/ | |||
private int code; | |||
/** | |||
* 错误信息 | |||
*/ | |||
private String msg; | |||
WarningEnum(int code, String msg){ | |||
this.code = code; | |||
this.msg = msg; | |||
} | |||
public int getCode() { | |||
return code; | |||
} | |||
public void setCode(int code) { | |||
this.code = code; | |||
} | |||
public String getMsg() { | |||
return msg; | |||
} | |||
public void setMsg(String msg) { | |||
this.msg = msg; | |||
} | |||
} |
@@ -1,5 +1,6 @@ | |||
package com.tuoheng.admin.mapper; | |||
import com.baomidou.mybatisplus.core.mapper.BaseMapper; | |||
import com.tuoheng.admin.entity.domain.Warning; | |||
import com.tuoheng.admin.entity.request.warning.QueryWarningListRequest; | |||
@@ -12,7 +13,7 @@ import java.util.List; | |||
* @author wanjing | |||
* @date 2023-02-06 | |||
*/ | |||
public interface WarningMapper { | |||
public interface WarningMapper extends BaseMapper<Warning> { | |||
/** | |||
* 查询预警列表 |
@@ -1,31 +1,41 @@ | |||
package com.tuoheng.admin.service.warning; | |||
import com.tuoheng.admin.entity.request.warning.QueryWarningListRequest; | |||
import com.tuoheng.common.utils.JsonResult; | |||
/** | |||
* 预警Service接口 | |||
* | |||
* @author wanjing | |||
* @team tuoheng | |||
* @date 2023-02-06 | |||
*/ | |||
public interface IWarningService { | |||
/** | |||
* 查询预警列表 | |||
* | |||
* @param request 预警 | |||
* @return 预警集合 | |||
*/ | |||
JsonResult getList(QueryWarningListRequest request); | |||
/** | |||
* 查询预警 | |||
* | |||
* @param id 预警主键 | |||
* @return 预警 | |||
*/ | |||
JsonResult getOneById(Integer id); | |||
} | |||
package com.tuoheng.admin.service.warning; | |||
import com.tuoheng.admin.entity.domain.Warning; | |||
import com.tuoheng.admin.entity.query.WarningQuery; | |||
import com.tuoheng.admin.entity.request.warning.QueryWarningListRequest; | |||
import com.tuoheng.common.common.IBaseService; | |||
import com.tuoheng.common.utils.JsonResult; | |||
/** | |||
* 预警Service接口 | |||
* | |||
* @author wanjing | |||
* @team tuoheng | |||
* @date 2023-02-06 | |||
*/ | |||
public interface IWarningService extends IBaseService<Warning> { | |||
/** | |||
* 查询预警列表 | |||
* | |||
* @param request 预警 | |||
* @return 预警集合 | |||
*/ | |||
JsonResult getList(QueryWarningListRequest request); | |||
/** | |||
* 查询预警 | |||
* | |||
* @param id 预警主键 | |||
* @return 预警 | |||
*/ | |||
JsonResult getOneById(Integer id); | |||
/** | |||
* 告警列表 分页 | |||
* @param query | |||
* @return | |||
*/ | |||
JsonResult index(WarningQuery query); | |||
} |
@@ -1,44 +1,60 @@ | |||
package com.tuoheng.admin.service.warning; | |||
import com.tuoheng.admin.entity.request.warning.QueryWarningListRequest; | |||
import com.tuoheng.admin.service.warning.query.QueryWarningListService; | |||
import com.tuoheng.common.utils.JsonResult; | |||
import org.springframework.beans.factory.annotation.Autowired; | |||
import org.springframework.stereotype.Service; | |||
/** | |||
* 预警Service业务层处理 | |||
* | |||
* @author wanjing | |||
* @team tuoheng | |||
* @date 2023-02-06 | |||
*/ | |||
@Service | |||
public class WarningServiceImpl implements IWarningService { | |||
@Autowired | |||
private QueryWarningListService queryWarningListService; | |||
/** | |||
* 查询预警列表 | |||
* | |||
* @param request 预警 | |||
* @return 预警 | |||
*/ | |||
@Override | |||
public JsonResult getList(QueryWarningListRequest request) { | |||
return queryWarningListService.getList(request); | |||
} | |||
/** | |||
* 查询预警 | |||
* | |||
* @param id 预警主键 | |||
* @return 预警 | |||
*/ | |||
@Override | |||
public JsonResult getOneById(Integer id) { | |||
return null; | |||
} | |||
} | |||
package com.tuoheng.admin.service.warning; | |||
import com.tuoheng.admin.entity.domain.Warning; | |||
import com.tuoheng.admin.entity.query.WarningQuery; | |||
import com.tuoheng.admin.entity.request.warning.QueryWarningListRequest; | |||
import com.tuoheng.admin.mapper.WarningMapper; | |||
import com.tuoheng.admin.service.warning.query.QueryWarningListService; | |||
import com.tuoheng.common.common.BaseServiceImpl; | |||
import com.tuoheng.common.utils.JsonResult; | |||
import lombok.extern.slf4j.Slf4j; | |||
import org.springframework.beans.factory.annotation.Autowired; | |||
import org.springframework.stereotype.Service; | |||
/** | |||
* 预警Service业务层处理 | |||
* | |||
* @author wanjing | |||
* @team tuoheng | |||
* @date 2023-02-06 | |||
*/ | |||
@Service | |||
@Slf4j | |||
public class WarningServiceImpl extends BaseServiceImpl<WarningMapper, Warning> implements IWarningService { | |||
@Autowired | |||
private QueryWarningListService queryWarningListService; | |||
/** | |||
* 查询预警列表 | |||
* | |||
* @param request 预警 | |||
* @return 预警 | |||
*/ | |||
@Override | |||
public JsonResult getList(QueryWarningListRequest request) { | |||
return queryWarningListService.getList(request); | |||
} | |||
/** | |||
* 查询预警 | |||
* | |||
* @param id 预警主键 | |||
* @return 预警 | |||
*/ | |||
@Override | |||
public JsonResult getOneById(Integer id) { | |||
return null; | |||
} | |||
/** | |||
* 告警列表查询 分页 | |||
* @param query | |||
* @return | |||
*/ | |||
@Override | |||
public JsonResult index(WarningQuery query) { | |||
return queryWarningListService.index(query); | |||
} | |||
} |
@@ -1,20 +1,38 @@ | |||
package com.tuoheng.admin.service.warning.query; | |||
import cn.hutool.core.collection.CollectionUtil; | |||
import cn.hutool.core.date.DateUtil; | |||
import com.baomidou.mybatisplus.core.metadata.IPage; | |||
import com.baomidou.mybatisplus.core.toolkit.ObjectUtils; | |||
import com.baomidou.mybatisplus.core.toolkit.Wrappers; | |||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; | |||
import com.tuoheng.admin.common.ServiceExceptionEnum; | |||
import com.tuoheng.admin.entity.domain.Goods; | |||
import com.tuoheng.admin.entity.domain.Warning; | |||
import com.tuoheng.admin.entity.query.WarningQuery; | |||
import com.tuoheng.admin.entity.request.goods.QueryGoodsListRequest; | |||
import com.tuoheng.admin.entity.request.warning.QueryWarningListRequest; | |||
import com.tuoheng.admin.entity.vo.WarningVO; | |||
import com.tuoheng.admin.enums.DiscoveryWayEnum; | |||
import com.tuoheng.admin.enums.MarkTypeEnum; | |||
import com.tuoheng.admin.enums.WarningEnum; | |||
import com.tuoheng.admin.mapper.GoodsMapper; | |||
import com.tuoheng.admin.mapper.WarningMapper; | |||
import com.tuoheng.common.exception.ServiceException; | |||
import com.tuoheng.common.utils.DateUtils; | |||
import com.tuoheng.common.utils.JsonResult; | |||
import com.tuoheng.common.utils.StringUtils; | |||
import com.tuoheng.system.entity.User; | |||
import com.tuoheng.system.utils.ShiroUtils; | |||
import lombok.Data; | |||
import lombok.extern.slf4j.Slf4j; | |||
import org.springframework.beans.BeanUtils; | |||
import org.springframework.beans.factory.annotation.Autowired; | |||
import org.springframework.stereotype.Service; | |||
import java.util.Date; | |||
import java.util.List; | |||
import java.util.stream.Collectors; | |||
/** | |||
* 查询预警业务层处理 | |||
@@ -60,4 +78,59 @@ public class QueryWarningListService { | |||
return JsonResult.success(); | |||
} | |||
/** | |||
* 告警列表查询 分页 | |||
* | |||
* @param query | |||
* @return | |||
*/ | |||
public JsonResult index(WarningQuery query) { | |||
//校验 | |||
if(query.getLimit() == null && query.getPage() == null){ | |||
throw new ServiceException(ServiceExceptionEnum.PARAMETER_IS_NULL); | |||
} | |||
User user = ShiroUtils.getUserInfo(); | |||
if(ObjectUtils.isEmpty(user)) { | |||
return JsonResult.error(WarningEnum.USER_IS_NOT_EXIST.getCode(),WarningEnum.USER_IS_NOT_EXIST.getMsg()); | |||
}; | |||
Integer tenantId = user.getTenantId(); | |||
if(null == tenantId) { | |||
return JsonResult.error(WarningEnum.TENANT_ID_IS_NULL.getCode(),WarningEnum.TENANT_ID_IS_NULL.getMsg()); | |||
} | |||
query.setTenantId(tenantId); | |||
IPage<Warning> page = new Page<>(query.getPage(),query.getLimit()); | |||
IPage<WarningVO> pageData = new Page<>(query.getPage(),query.getLimit()); | |||
//时间 | |||
Date startTime = null; | |||
Date endTime = null; | |||
if(StringUtils.isNotEmpty(query.getWaringTime())){ | |||
startTime = DateUtils.dateTime(DateUtils.YYYY_MM_DD_HH_MM_SS,query.getWaringTime()+" 00:00:00"); | |||
endTime = DateUtils.dateTime(DateUtils.YYYY_MM_DD_HH_MM_SS,query.getWaringTime()+" 23:59:59"); | |||
} | |||
query.setWaringStartTime(startTime); | |||
query.setWaringEndTime(endTime); | |||
//获取分页数据 | |||
IPage<Warning> warningPageData = warningMapper.selectPage(page, Wrappers.<Warning>lambdaQuery() | |||
.eq(null != query.getDiscoveryWay(), Warning::getDiscoveryWay, query.getDiscoveryWay()) | |||
.eq(null != query.getStatus(), Warning::getStatus, query.getStatus()) | |||
.between(null != query.getWaringStartTime() && null != query.getWaringEndTime(), Warning::getCheckTime, query.getWaringStartTime(), query.getWaringEndTime()) | |||
.eq(Warning::getMark, MarkTypeEnum.VALID.getCode())); | |||
if(null == warningPageData){ | |||
return null; | |||
} | |||
//属性赋值 | |||
List<WarningVO> collect = warningPageData.getRecords().stream().map(x -> { | |||
WarningVO vo = new WarningVO(); | |||
BeanUtils.copyProperties(x, vo); | |||
//预警来源 | |||
//if(x.getDiscoveryWay() == DiscoveryWayEnum.SURVEILLANCE_CAMERA.getCode()) | |||
return vo; | |||
}).collect(Collectors.toList()); | |||
pageData.setRecords(collect); | |||
return JsonResult.success(pageData); | |||
} | |||
} |