feat:添加安防小板设备相关接口
This commit is contained in:
parent
e0389a15da
commit
6822b5f354
@ -27,8 +27,7 @@ import com.fastbee.framework.security.handle.LogoutSuccessHandlerImpl;
|
|||||||
*/
|
*/
|
||||||
//@EnableWebSecurity
|
//@EnableWebSecurity
|
||||||
@EnableGlobalMethodSecurity(prePostEnabled = true, securedEnabled = true)
|
@EnableGlobalMethodSecurity(prePostEnabled = true, securedEnabled = true)
|
||||||
public class SecurityConfig extends WebSecurityConfigurerAdapter
|
public class SecurityConfig extends WebSecurityConfigurerAdapter {
|
||||||
{
|
|
||||||
/**
|
/**
|
||||||
* 自定义用户认证逻辑
|
* 自定义用户认证逻辑
|
||||||
*/
|
*/
|
||||||
@ -73,8 +72,7 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter
|
|||||||
*/
|
*/
|
||||||
@Bean
|
@Bean
|
||||||
@Override
|
@Override
|
||||||
public AuthenticationManager authenticationManagerBean() throws Exception
|
public AuthenticationManager authenticationManagerBean() throws Exception {
|
||||||
{
|
|
||||||
return super.authenticationManagerBean();
|
return super.authenticationManagerBean();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -94,8 +92,7 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter
|
|||||||
* authenticated | 用户登录后可访问
|
* authenticated | 用户登录后可访问
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
protected void configure(HttpSecurity httpSecurity) throws Exception
|
protected void configure(HttpSecurity httpSecurity) throws Exception {
|
||||||
{
|
|
||||||
// 注解标记允许匿名访问的url
|
// 注解标记允许匿名访问的url
|
||||||
ExpressionUrlAuthorizationConfigurer<HttpSecurity>.ExpressionInterceptUrlRegistry registry = httpSecurity.authorizeRequests();
|
ExpressionUrlAuthorizationConfigurer<HttpSecurity>.ExpressionInterceptUrlRegistry registry = httpSecurity.authorizeRequests();
|
||||||
permitAllUrl.getUrls().forEach(url -> registry.antMatchers(url).permitAll());
|
permitAllUrl.getUrls().forEach(url -> registry.antMatchers(url).permitAll());
|
||||||
@ -112,14 +109,14 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter
|
|||||||
// 过滤请求
|
// 过滤请求
|
||||||
.authorizeRequests()
|
.authorizeRequests()
|
||||||
// 对于登录login 注册register 验证码captchaImage 允许匿名访问
|
// 对于登录login 注册register 验证码captchaImage 允许匿名访问
|
||||||
.antMatchers("/login", "/register", "/captchaImage","/iot/tool/register","/iot/tool/ntp","/iot/tool/download",
|
.antMatchers("/login", "/register", "/captchaImage", "/iot/tool/register", "/iot/tool/ntp", "/iot/tool/download",
|
||||||
"/iot/tool/mqtt/auth","/iot/tool/mqtt/authv5","/iot/tool/mqtt/webhook","/iot/tool/mqtt/webhookv5","/auth/**/**",
|
"/iot/tool/mqtt/auth", "/iot/tool/mqtt/authv5", "/iot/tool/mqtt/webhook", "/iot/tool/mqtt/webhookv5", "/auth/**/**",
|
||||||
"/wechat/mobileLogin", "/wechat/miniLogin", "/wechat/wxBind/callback").permitAll()
|
"/wechat/mobileLogin", "/wechat/miniLogin", "/wechat/wxBind/callback").permitAll()
|
||||||
.antMatchers("/zlmhook/**").permitAll()
|
.antMatchers("/zlmhook/**").permitAll()
|
||||||
.antMatchers("/ruleengine/rulemanager/**").permitAll()
|
.antMatchers("/ruleengine/rulemanager/**").permitAll()
|
||||||
.antMatchers("/goview/sys/login","/goview/project/getData").permitAll()
|
.antMatchers("/goview/sys/login", "/goview/project/getData").permitAll()
|
||||||
.antMatchers("/notify/smsLoginCaptcha","/auth/sms/login", "/notify/weComVerifyUrl"
|
.antMatchers("/notify/smsLoginCaptcha", "/auth/sms/login", "/notify/weComVerifyUrl"
|
||||||
,"/wechat/publicAccount/callback","/notify/smsRegisterCaptcha").permitAll()
|
, "/wechat/publicAccount/callback", "/notify/smsRegisterCaptcha").permitAll()
|
||||||
.antMatchers("/app/language/list").permitAll()
|
.antMatchers("/app/language/list").permitAll()
|
||||||
// 静态资源,可匿名访问
|
// 静态资源,可匿名访问
|
||||||
.antMatchers(HttpMethod.GET, "/", "/*.html", "/**/*.html", "/**/*.css", "/**/*.js", "/profile/**").permitAll()
|
.antMatchers(HttpMethod.GET, "/", "/*.html", "/**/*.html", "/**/*.css", "/**/*.js", "/profile/**").permitAll()
|
||||||
@ -130,6 +127,8 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter
|
|||||||
// .antMatchers("/oauth/css/**","/oauth/fonts/**","/oauth/js/**").permitAll()
|
// .antMatchers("/oauth/css/**","/oauth/fonts/**","/oauth/js/**").permitAll()
|
||||||
// dueros
|
// dueros
|
||||||
.antMatchers("/dueros").permitAll()
|
.antMatchers("/dueros").permitAll()
|
||||||
|
//安防小板
|
||||||
|
.antMatchers("/iot/photos").permitAll()
|
||||||
|
|
||||||
// 除上面外的所有请求全部需要鉴权认证
|
// 除上面外的所有请求全部需要鉴权认证
|
||||||
.anyRequest().authenticated()
|
.anyRequest().authenticated()
|
||||||
@ -158,8 +157,7 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter
|
|||||||
* 强散列哈希加密实现
|
* 强散列哈希加密实现
|
||||||
*/
|
*/
|
||||||
@Bean
|
@Bean
|
||||||
public BCryptPasswordEncoder bCryptPasswordEncoder()
|
public BCryptPasswordEncoder bCryptPasswordEncoder() {
|
||||||
{
|
|
||||||
return new BCryptPasswordEncoder();
|
return new BCryptPasswordEncoder();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -167,8 +165,7 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter
|
|||||||
* 身份认证接口
|
* 身份认证接口
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
protected void configure(AuthenticationManagerBuilder auth) throws Exception
|
protected void configure(AuthenticationManagerBuilder auth) throws Exception {
|
||||||
{
|
|
||||||
auth.userDetailsService(userDetailsService).passwordEncoder(bCryptPasswordEncoder());
|
auth.userDetailsService(userDetailsService).passwordEncoder(bCryptPasswordEncoder());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,155 @@
|
|||||||
|
package com.fastbee.iot.anfang.controller;
|
||||||
|
|
||||||
|
import com.fastbee.common.annotation.Log;
|
||||||
|
import com.fastbee.common.config.RuoYiConfig;
|
||||||
|
import com.fastbee.common.core.controller.BaseController;
|
||||||
|
import com.fastbee.common.core.domain.AjaxResult;
|
||||||
|
import com.fastbee.common.core.page.TableDataInfo;
|
||||||
|
import com.fastbee.common.enums.BusinessType;
|
||||||
|
import com.fastbee.common.exception.ServiceException;
|
||||||
|
import com.fastbee.common.utils.file.FileUploadUtils;
|
||||||
|
import com.fastbee.common.utils.poi.ExcelUtil;
|
||||||
|
import com.fastbee.iot.anfang.service.IUploadedPhotosService;
|
||||||
|
import com.fastbee.iot.model.anfang.UploadedPhotos;
|
||||||
|
import io.swagger.annotations.Api;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.security.access.prepost.PreAuthorize;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.math.RoundingMode;
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import static com.fastbee.common.utils.StringUtils.isEmpty;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设备告警上传Controller
|
||||||
|
*
|
||||||
|
* @author Dunxi Zang
|
||||||
|
* @date 2024-06-19
|
||||||
|
*/
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/iot/photos")
|
||||||
|
@Api(tags = "安防小板")
|
||||||
|
public class UploadedPhotosController extends BaseController
|
||||||
|
{
|
||||||
|
@Autowired
|
||||||
|
private IUploadedPhotosService uploadedPhotosService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询设备告警上传列表
|
||||||
|
*/
|
||||||
|
@PreAuthorize("@ss.hasPermi('iot:photos:list')")
|
||||||
|
@GetMapping("/list")
|
||||||
|
public TableDataInfo list(UploadedPhotos uploadedPhotos)
|
||||||
|
{
|
||||||
|
startPage();
|
||||||
|
List<UploadedPhotos> list = uploadedPhotosService.selectUploadedPhotosList(uploadedPhotos);
|
||||||
|
return getDataTable(list);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 导出设备告警上传列表
|
||||||
|
*/
|
||||||
|
@PreAuthorize("@ss.hasPermi('iot:photos:export')")
|
||||||
|
@Log(title = "设备告警上传", businessType = BusinessType.EXPORT)
|
||||||
|
@PostMapping("/export")
|
||||||
|
public void export(HttpServletResponse response, UploadedPhotos uploadedPhotos)
|
||||||
|
{
|
||||||
|
List<UploadedPhotos> list = uploadedPhotosService.selectUploadedPhotosList(uploadedPhotos);
|
||||||
|
ExcelUtil<UploadedPhotos> util = new ExcelUtil<UploadedPhotos>(UploadedPhotos.class);
|
||||||
|
util.exportExcel(response, list, "设备告警上传数据");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取设备告警上传详细信息
|
||||||
|
*/
|
||||||
|
@PreAuthorize("@ss.hasPermi('iot:photos:query')")
|
||||||
|
@GetMapping(value = "/{id}")
|
||||||
|
public AjaxResult getInfo(@PathVariable("id") Long id)
|
||||||
|
{
|
||||||
|
return success(uploadedPhotosService.selectUploadedPhotosById(id));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新增设备告警上传
|
||||||
|
*/
|
||||||
|
@PostMapping
|
||||||
|
public AjaxResult uploadPhoto(
|
||||||
|
@RequestParam("fileToUpload") MultipartFile photo,
|
||||||
|
@RequestParam("imei") String imei,
|
||||||
|
@RequestParam("sn") String sn,
|
||||||
|
@RequestParam("lat") String lat,
|
||||||
|
@RequestParam("lng") String lng,
|
||||||
|
@RequestParam("temp") String temp,
|
||||||
|
@RequestParam("doorState") String doorState,
|
||||||
|
@RequestParam("shakeState") String shakeState,
|
||||||
|
@RequestParam("time") String time) {
|
||||||
|
|
||||||
|
if (photo.isEmpty()) {
|
||||||
|
throw new ServiceException("照片为空,上传失败");
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
// 上传文件路径
|
||||||
|
String filePath = RuoYiConfig.getUploadPath();
|
||||||
|
// 上传并返回新文件名称
|
||||||
|
String fileName = FileUploadUtils.upload(filePath, photo);
|
||||||
|
|
||||||
|
// 处理可能为空的字段
|
||||||
|
Double latitude = isEmpty(lat) ? 0.0 : Double.valueOf(lat);
|
||||||
|
Double longitude = isEmpty(lng) ? 0.0 : Double.valueOf(lng);
|
||||||
|
Double temperature = isEmpty(temp) ? 0.0 : convertAndRoundTemperature(temp);
|
||||||
|
if(doorState.equals("0")){
|
||||||
|
shakeState = "1";
|
||||||
|
}
|
||||||
|
// 处理时间戳
|
||||||
|
long timestamp = Long.parseLong(time + "000");
|
||||||
|
Date date = new Date(timestamp);
|
||||||
|
|
||||||
|
UploadedPhotos uploadedPhotos = new UploadedPhotos(
|
||||||
|
null, fileName, imei, sn, latitude, longitude, temperature, doorState, shakeState, date
|
||||||
|
);
|
||||||
|
return toAjax(uploadedPhotosService.insertUploadedPhotos(uploadedPhotos));
|
||||||
|
} catch (IOException e) {
|
||||||
|
throw new ServiceException("设备告警信息上传失败");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改设备告警上传
|
||||||
|
*/
|
||||||
|
@PreAuthorize("@ss.hasPermi('iot:photos:edit')")
|
||||||
|
@Log(title = "设备告警上传", businessType = BusinessType.UPDATE)
|
||||||
|
@PutMapping
|
||||||
|
public AjaxResult edit(@RequestBody UploadedPhotos uploadedPhotos)
|
||||||
|
{
|
||||||
|
return toAjax(uploadedPhotosService.updateUploadedPhotos(uploadedPhotos));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除设备告警上传
|
||||||
|
*/
|
||||||
|
@PreAuthorize("@ss.hasPermi('iot:photos:remove')")
|
||||||
|
@Log(title = "设备告警上传", businessType = BusinessType.DELETE)
|
||||||
|
@DeleteMapping("/{ids}")
|
||||||
|
public AjaxResult remove(@PathVariable Long[] ids)
|
||||||
|
{
|
||||||
|
return toAjax(uploadedPhotosService.deleteUploadedPhotosByIds(ids));
|
||||||
|
}
|
||||||
|
public static Double convertAndRoundTemperature(String tempStr) {
|
||||||
|
// 将字符串转换为double
|
||||||
|
double temp = Double.parseDouble(tempStr);
|
||||||
|
|
||||||
|
// 使用BigDecimal进行四舍五入,保留两位小数
|
||||||
|
BigDecimal bd = BigDecimal.valueOf(temp);
|
||||||
|
bd = bd.setScale(2, RoundingMode.HALF_UP);
|
||||||
|
|
||||||
|
// 返回转换后的double值
|
||||||
|
return bd.doubleValue();
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,62 @@
|
|||||||
|
package com.fastbee.iot.anfang.service;
|
||||||
|
|
||||||
|
import com.fastbee.iot.model.anfang.UploadedPhotos;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 存储上传的照片信息Service接口
|
||||||
|
*
|
||||||
|
* @author kerwincui
|
||||||
|
* @date 2024-06-20
|
||||||
|
*/
|
||||||
|
public interface IUploadedPhotosService
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* 查询存储上传的照片信息
|
||||||
|
*
|
||||||
|
* @param id 存储上传的照片信息主键
|
||||||
|
* @return 存储上传的照片信息
|
||||||
|
*/
|
||||||
|
public UploadedPhotos selectUploadedPhotosById(Long id);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询存储上传的照片信息列表
|
||||||
|
*
|
||||||
|
* @param uploadedPhotos 存储上传的照片信息
|
||||||
|
* @return 存储上传的照片信息集合
|
||||||
|
*/
|
||||||
|
public List<UploadedPhotos> selectUploadedPhotosList(UploadedPhotos uploadedPhotos);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新增存储上传的照片信息
|
||||||
|
*
|
||||||
|
* @param uploadedPhotos 存储上传的照片信息
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
public int insertUploadedPhotos(UploadedPhotos uploadedPhotos);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改存储上传的照片信息
|
||||||
|
*
|
||||||
|
* @param uploadedPhotos 存储上传的照片信息
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
public int updateUploadedPhotos(UploadedPhotos uploadedPhotos);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 批量删除存储上传的照片信息
|
||||||
|
*
|
||||||
|
* @param ids 需要删除的存储上传的照片信息主键集合
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
public int deleteUploadedPhotosByIds(Long[] ids);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除存储上传的照片信息信息
|
||||||
|
*
|
||||||
|
* @param id 存储上传的照片信息主键
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
public int deleteUploadedPhotosById(Long id);
|
||||||
|
}
|
@ -0,0 +1,95 @@
|
|||||||
|
package com.fastbee.iot.anfang.service.impl;
|
||||||
|
|
||||||
|
import com.fastbee.iot.anfang.service.IUploadedPhotosService;
|
||||||
|
import com.fastbee.iot.mapper.UploadedPhotosMapper;
|
||||||
|
import com.fastbee.iot.model.anfang.UploadedPhotos;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 存储上传的照片信息Service业务层处理
|
||||||
|
*
|
||||||
|
* @author kerwincui
|
||||||
|
* @date 2024-06-20
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
public class UploadedPhotosServiceImpl implements IUploadedPhotosService
|
||||||
|
{
|
||||||
|
@Resource
|
||||||
|
private UploadedPhotosMapper uploadedPhotosMapper;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询存储上传的照片信息
|
||||||
|
*
|
||||||
|
* @param id 存储上传的照片信息主键
|
||||||
|
* @return 存储上传的照片信息
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public UploadedPhotos selectUploadedPhotosById(Long id)
|
||||||
|
{
|
||||||
|
return uploadedPhotosMapper.selectUploadedPhotosById(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询存储上传的照片信息列表
|
||||||
|
*
|
||||||
|
* @param uploadedPhotos 存储上传的照片信息
|
||||||
|
* @return 存储上传的照片信息
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public List<UploadedPhotos> selectUploadedPhotosList(UploadedPhotos uploadedPhotos)
|
||||||
|
{
|
||||||
|
return uploadedPhotosMapper.selectUploadedPhotosList(uploadedPhotos);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新增存储上传的照片信息
|
||||||
|
*
|
||||||
|
* @param uploadedPhotos 存储上传的照片信息
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public int insertUploadedPhotos(UploadedPhotos uploadedPhotos)
|
||||||
|
{
|
||||||
|
return uploadedPhotosMapper.insertUploadedPhotos(uploadedPhotos);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改存储上传的照片信息
|
||||||
|
*
|
||||||
|
* @param uploadedPhotos 存储上传的照片信息
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public int updateUploadedPhotos(UploadedPhotos uploadedPhotos)
|
||||||
|
{
|
||||||
|
return uploadedPhotosMapper.updateUploadedPhotos(uploadedPhotos);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 批量删除存储上传的照片信息
|
||||||
|
*
|
||||||
|
* @param ids 需要删除的存储上传的照片信息主键
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public int deleteUploadedPhotosByIds(Long[] ids)
|
||||||
|
{
|
||||||
|
return uploadedPhotosMapper.deleteUploadedPhotosByIds(ids);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除存储上传的照片信息信息
|
||||||
|
*
|
||||||
|
* @param id 存储上传的照片信息主键
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public int deleteUploadedPhotosById(Long id)
|
||||||
|
{
|
||||||
|
return uploadedPhotosMapper.deleteUploadedPhotosById(id);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,63 @@
|
|||||||
|
package com.fastbee.iot.mapper;
|
||||||
|
|
||||||
|
|
||||||
|
import com.fastbee.iot.model.anfang.UploadedPhotos;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 存储上传的照片信息Mapper接口
|
||||||
|
*
|
||||||
|
* @author kerwincui
|
||||||
|
* @date 2024-06-20
|
||||||
|
*/
|
||||||
|
public interface UploadedPhotosMapper
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* 查询存储上传的照片信息
|
||||||
|
*
|
||||||
|
* @param id 存储上传的照片信息主键
|
||||||
|
* @return 存储上传的照片信息
|
||||||
|
*/
|
||||||
|
public UploadedPhotos selectUploadedPhotosById(Long id);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询存储上传的照片信息列表
|
||||||
|
*
|
||||||
|
* @param uploadedPhotos 存储上传的照片信息
|
||||||
|
* @return 存储上传的照片信息集合
|
||||||
|
*/
|
||||||
|
public List<UploadedPhotos> selectUploadedPhotosList(UploadedPhotos uploadedPhotos);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新增存储上传的照片信息
|
||||||
|
*
|
||||||
|
* @param uploadedPhotos 存储上传的照片信息
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
public int insertUploadedPhotos(UploadedPhotos uploadedPhotos);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改存储上传的照片信息
|
||||||
|
*
|
||||||
|
* @param uploadedPhotos 存储上传的照片信息
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
public int updateUploadedPhotos(UploadedPhotos uploadedPhotos);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除存储上传的照片信息
|
||||||
|
*
|
||||||
|
* @param id 存储上传的照片信息主键
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
public int deleteUploadedPhotosById(Long id);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 批量删除存储上传的照片信息
|
||||||
|
*
|
||||||
|
* @param ids 需要删除的数据主键集合
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
public int deleteUploadedPhotosByIds(Long[] ids);
|
||||||
|
}
|
@ -0,0 +1,65 @@
|
|||||||
|
package com.fastbee.iot.model.anfang;
|
||||||
|
|
||||||
|
import com.fastbee.common.annotation.Excel;
|
||||||
|
import com.fastbee.common.core.domain.BaseEntity;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设备告警上传对象 uploaded_photos
|
||||||
|
*
|
||||||
|
* @author Dunxi Zang
|
||||||
|
* @date 2024-06-19
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@AllArgsConstructor
|
||||||
|
@NoArgsConstructor
|
||||||
|
public class UploadedPhotos extends BaseEntity
|
||||||
|
{
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
/** 主键 */
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
/** 照片存储路径 */
|
||||||
|
@Excel(name = "照片存储路径")
|
||||||
|
private String photoPath;
|
||||||
|
|
||||||
|
/** 设备IMEI号 */
|
||||||
|
@Excel(name = "设备IMEI号")
|
||||||
|
private String imei;
|
||||||
|
|
||||||
|
/** 设备序列号 */
|
||||||
|
@Excel(name = "设备序列号")
|
||||||
|
private String sn;
|
||||||
|
|
||||||
|
/** 纬度信息 */
|
||||||
|
@Excel(name = "纬度信息")
|
||||||
|
private Double lat;
|
||||||
|
|
||||||
|
/** 经度信息 */
|
||||||
|
@Excel(name = "经度信息")
|
||||||
|
private Double lng;
|
||||||
|
|
||||||
|
/** 温度信息 */
|
||||||
|
@Excel(name = "温度信息")
|
||||||
|
private Double temp;
|
||||||
|
|
||||||
|
/** 门状态信息 */
|
||||||
|
@Excel(name = "门状态信息")
|
||||||
|
private String doorState;
|
||||||
|
|
||||||
|
/** 震动状态信息 */
|
||||||
|
@Excel(name = "震动状态信息")
|
||||||
|
private String shakeState;
|
||||||
|
|
||||||
|
/** 上传时间 */
|
||||||
|
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||||
|
@Excel(name = "上传时间", width = 30, dateFormat = "yyyy-MM-dd")
|
||||||
|
private Date uploadTime;
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,97 @@
|
|||||||
|
<?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="com.fastbee.iot.mapper.UploadedPhotosMapper">
|
||||||
|
|
||||||
|
<resultMap type="com.fastbee.iot.model.anfang.UploadedPhotos" id="UploadedPhotosResult">
|
||||||
|
<result property="id" column="id" />
|
||||||
|
<result property="photoPath" column="photo_path" />
|
||||||
|
<result property="imei" column="imei" />
|
||||||
|
<result property="sn" column="sn" />
|
||||||
|
<result property="lat" column="lat" />
|
||||||
|
<result property="lng" column="lng" />
|
||||||
|
<result property="temp" column="temp" />
|
||||||
|
<result property="doorState" column="door_state" />
|
||||||
|
<result property="shakeState" column="shake_state" />
|
||||||
|
<result property="uploadTime" column="upload_time" />
|
||||||
|
</resultMap>
|
||||||
|
|
||||||
|
<sql id="selectUploadedPhotosVo">
|
||||||
|
select id, photo_path, imei, sn, lat, lng, temp, door_state, shake_state, upload_time from uploaded_photos
|
||||||
|
</sql>
|
||||||
|
|
||||||
|
<select id="selectUploadedPhotosList" parameterType="com.fastbee.iot.model.anfang.UploadedPhotos" resultMap="UploadedPhotosResult">
|
||||||
|
<include refid="selectUploadedPhotosVo"/>
|
||||||
|
<where>
|
||||||
|
<if test="photoPath != null and photoPath != ''"> and photo_path = #{photoPath}</if>
|
||||||
|
<if test="imei != null and imei != ''"> and imei = #{imei}</if>
|
||||||
|
<if test="sn != null and sn != ''"> and sn like concat('%', #{sn}, '%')</if>
|
||||||
|
<if test="lat != null "> and lat = #{lat}</if>
|
||||||
|
<if test="lng != null "> and lng = #{lng}</if>
|
||||||
|
<if test="params.beginTemp != null and params.beginTemp != '' and params.endTemp != null and params.endTemp != ''"> and temp between #{params.beginTemp} and #{params.endTemp}</if>
|
||||||
|
<if test="doorState != null and doorState != ''"> and door_state = #{doorState}</if>
|
||||||
|
<if test="shakeState != null and shakeState != ''"> and shake_state = #{shakeState}</if>
|
||||||
|
<if test="params.beginUploadTime != null and params.beginUploadTime != '' and params.endUploadTime != null and params.endUploadTime != ''"> and upload_time between #{params.beginUploadTime} and #{params.endUploadTime}</if>
|
||||||
|
</where>
|
||||||
|
order by id desc
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<select id="selectUploadedPhotosById" parameterType="Long" resultMap="UploadedPhotosResult">
|
||||||
|
<include refid="selectUploadedPhotosVo"/>
|
||||||
|
where id = #{id}
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<insert id="insertUploadedPhotos" parameterType="com.fastbee.iot.model.anfang.UploadedPhotos" useGeneratedKeys="true" keyProperty="id">
|
||||||
|
insert into uploaded_photos
|
||||||
|
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||||
|
<if test="photoPath != null and photoPath != ''">photo_path,</if>
|
||||||
|
<if test="imei != null and imei != ''">imei,</if>
|
||||||
|
<if test="sn != null">sn,</if>
|
||||||
|
<if test="lat != null">lat,</if>
|
||||||
|
<if test="lng != null">lng,</if>
|
||||||
|
<if test="temp != null">temp,</if>
|
||||||
|
<if test="doorState != null">door_state,</if>
|
||||||
|
<if test="shakeState != null">shake_state,</if>
|
||||||
|
<if test="uploadTime != null">upload_time,</if>
|
||||||
|
</trim>
|
||||||
|
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||||
|
<if test="photoPath != null and photoPath != ''">#{photoPath},</if>
|
||||||
|
<if test="imei != null and imei != ''">#{imei},</if>
|
||||||
|
<if test="sn != null">#{sn},</if>
|
||||||
|
<if test="lat != null">#{lat},</if>
|
||||||
|
<if test="lng != null">#{lng},</if>
|
||||||
|
<if test="temp != null">#{temp},</if>
|
||||||
|
<if test="doorState != null">#{doorState},</if>
|
||||||
|
<if test="shakeState != null">#{shakeState},</if>
|
||||||
|
<if test="uploadTime != null">#{uploadTime},</if>
|
||||||
|
</trim>
|
||||||
|
</insert>
|
||||||
|
|
||||||
|
<update id="updateUploadedPhotos" parameterType="com.fastbee.iot.model.anfang.UploadedPhotos">
|
||||||
|
update uploaded_photos
|
||||||
|
<trim prefix="SET" suffixOverrides=",">
|
||||||
|
<if test="photoPath != null and photoPath != ''">photo_path = #{photoPath},</if>
|
||||||
|
<if test="imei != null and imei != ''">imei = #{imei},</if>
|
||||||
|
<if test="sn != null">sn = #{sn},</if>
|
||||||
|
<if test="lat != null">lat = #{lat},</if>
|
||||||
|
<if test="lng != null">lng = #{lng},</if>
|
||||||
|
<if test="temp != null">temp = #{temp},</if>
|
||||||
|
<if test="doorState != null">door_state = #{doorState},</if>
|
||||||
|
<if test="shakeState != null">shake_state = #{shakeState},</if>
|
||||||
|
<if test="uploadTime != null">upload_time = #{uploadTime},</if>
|
||||||
|
</trim>
|
||||||
|
where id = #{id}
|
||||||
|
</update>
|
||||||
|
|
||||||
|
<delete id="deleteUploadedPhotosById" parameterType="Long">
|
||||||
|
delete from uploaded_photos where id = #{id}
|
||||||
|
</delete>
|
||||||
|
|
||||||
|
<delete id="deleteUploadedPhotosByIds" parameterType="String">
|
||||||
|
delete from uploaded_photos where id in
|
||||||
|
<foreach item="id" collection="array" open="(" separator="," close=")">
|
||||||
|
#{id}
|
||||||
|
</foreach>
|
||||||
|
</delete>
|
||||||
|
</mapper>
|
Loading…
x
Reference in New Issue
Block a user