怎加参数配置

This commit is contained in:
gaoben 2021-01-29 16:02:50 +08:00
parent 1d52967819
commit 7633545c16
8 changed files with 164 additions and 37 deletions

View File

@ -15,6 +15,7 @@ import net.shapelight.modules.ten.service.TenDeviceService;
import net.shapelight.modules.vo.TenDeviceParamVo; import net.shapelight.modules.vo.TenDeviceParamVo;
import net.shapelight.modules.vo.TenPersonVo; import net.shapelight.modules.vo.TenPersonVo;
import net.shapelight.modules.vo.TenRecordVo; import net.shapelight.modules.vo.TenRecordVo;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
@ -78,6 +79,10 @@ public class CmdProcess {
case addPerson: case addPerson:
log.info("addPerson", cmdEnum.getCmd()); log.info("addPerson", cmdEnum.getCmd());
break; break;
case getParam:
subGetParam(deviceSn,content);
log.info("getParam", cmdEnum.getCmd());
break;
} }
} }
@ -311,6 +316,54 @@ public class CmdProcess {
} }
/**
*
* @param deviceSn
* @param content
* {
* "cmd": "getParam"
* "data": {
* }
* }
*/
private static void subGetParam(String deviceSn,String content){
JSONObject resJson = JSONObject.parseObject(content);
JSONObject data = resJson.getJSONObject("data");
TenDeviceParamVo paramVo = data.toJavaObject(TenDeviceParamVo.class);
paramVo.setSn(deviceSn);
log.debug("收到mqtt设备参数"+content);
TenDeviceEntity dev = cmdProcess.tenDeviceService.findBySn(deviceSn);
BeanUtils.copyProperties(paramVo,dev);
cmdProcess.tenDeviceService.evictupdateById(dev);
}
/**
*
* @param deviceSn
*
* {
* "cmd":" getParam",
* "data":{
* }
* }
*/
public static void publishGetParam(String deviceSn){
String topic = MqttClientUtil.getDevicePublishTopic(deviceSn);
//要发送消息的内容
JSONObject sendContent = new JSONObject();
Map<String,Object> data = new HashMap<>();
sendContent.put("cmd", "getParam");
sendContent.put("data", data);
//发布消息
MqttClientUtil.publish_common(topic, sendContent.toString());
}
/** /**
* *
* @param deviceSn * @param deviceSn

View File

@ -7,7 +7,8 @@ public enum TopicCmdEnum {
faceCount("faceCount"), faceCount("faceCount"),
alert("alert"), alert("alert"),
upRecord("upRecord"), upRecord("upRecord"),
addPerson("addPerson"); addPerson("addPerson"),
getParam("getParam");
private String cmd; private String cmd;

View File

@ -156,6 +156,7 @@ public class PersonExcelListener extends AnalysisEventListener<PersonModel> {
personModel.setOrgImage(image); personModel.setOrgImage(image);
} }
//检测图片人脸 //检测图片人脸
//---------------------------------------------------------------------
String tempPath = ""; String tempPath = "";
if (Pattern.matches("Linux.*", System.getProperty("os.name"))) { if (Pattern.matches("Linux.*", System.getProperty("os.name"))) {
tempPath = image.substring(0,image.lastIndexOf("/")+1); tempPath = image.substring(0,image.lastIndexOf("/")+1);
@ -171,6 +172,7 @@ public class PersonExcelListener extends AnalysisEventListener<PersonModel> {
list.add(personModel); list.add(personModel);
return; return;
} }
//---------------------------------------------------------------------
personModel.setStatus(1); personModel.setStatus(1);
list.add(personModel); list.add(personModel);

View File

@ -24,6 +24,7 @@ import net.shapelight.modules.ten.service.TenCellService;
import net.shapelight.modules.ten.service.TenUserScopeService; import net.shapelight.modules.ten.service.TenUserScopeService;
import net.shapelight.modules.vo.TenDeviceParamVo; import net.shapelight.modules.vo.TenDeviceParamVo;
import org.apache.shiro.authz.annotation.RequiresPermissions; import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.CacheEvict; import org.springframework.cache.annotation.CacheEvict;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
@ -157,12 +158,45 @@ public class TenDeviceController extends AbstractController {
} }
/**
* 获取设备参数
*/
@GetMapping("/getParam/{sn}")
@ApiOperation(value = "获取设备参数")
public R getParam(@PathVariable("sn") String sn){
boolean onlineFlag = emqHttpApi.getClient(sn);
if(onlineFlag){
}else{
return R.error("设备离线,无法更新");
}
CmdProcess.publishGetParam(sn);
try {
Thread.sleep(3000);
TenDeviceEntity dev = tenDeviceService.findBySn(sn);
TenDeviceParamVo paramVo = new TenDeviceParamVo();
BeanUtils.copyProperties(dev,paramVo);
return R.ok().put("data",paramVo);
}catch (Exception e){
return R.error("获取失败,请重试");
}
}
/** /**
* 设置设备参数 * 设置设备参数
*/ */
@PostMapping("/setParam") @PostMapping("/setParam")
@ApiOperation(value = "设置设备参数") @ApiOperation(value = "设置设备参数")
public R setParam(@RequestBody TenDeviceParamVo paramVo){ public R setParam(@RequestBody TenDeviceParamVo paramVo){
String sn = paramVo.getSn();
boolean onlineFlag = emqHttpApi.getClient(sn);
if(onlineFlag){
}else{
return R.error("设备离线,无法更新");
}
CmdProcess.publishSetParam(paramVo.getSn(),paramVo); CmdProcess.publishSetParam(paramVo.getSn(),paramVo);
return R.ok(); return R.ok();
} }

View File

@ -6,6 +6,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.minio.MinioClient; import io.minio.MinioClient;
import io.minio.PutObjectOptions; import io.minio.PutObjectOptions;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import net.coobird.thumbnailator.Thumbnails;
import net.shapelight.common.config.GlobalValue; import net.shapelight.common.config.GlobalValue;
import net.shapelight.common.config.MinioConfig; import net.shapelight.common.config.MinioConfig;
import net.shapelight.common.utils.*; import net.shapelight.common.utils.*;
@ -34,6 +35,7 @@ import org.springframework.cache.annotation.CachePut;
import org.springframework.cache.annotation.Cacheable; import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.awt.image.BufferedImage;
import java.io.*; import java.io.*;
import java.util.*; import java.util.*;
import java.util.regex.Pattern; import java.util.regex.Pattern;
@ -45,6 +47,8 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import net.shapelight.modules.ten.dao.TenPersonDao; import net.shapelight.modules.ten.dao.TenPersonDao;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import javax.imageio.ImageIO;
@Service("tenPersonService") @Service("tenPersonService")
@Slf4j @Slf4j
@ -1736,8 +1740,12 @@ public class TenPersonServiceImpl implements TenPersonService {
tenPerson.setOrgImage(orgImageFileName); tenPerson.setOrgImage(orgImageFileName);
// log.info("原图"+tenPerson.getOrgImage()+"-"+personModel.getOrgImage()); // log.info("原图"+tenPerson.getOrgImage()+"-"+personModel.getOrgImage());
//2. 截取人脸图片 //2. 截取人脸图片
//检测图片人脸 //检测图片人脸
//--------------------------------------------------------------------
String tempPath = ""; String tempPath = "";
if (Pattern.matches("Linux.*", System.getProperty("os.name"))) { if (Pattern.matches("Linux.*", System.getProperty("os.name"))) {
tempPath = personModel.getOrgImage().substring(0, personModel.getOrgImage().lastIndexOf("/") + 1); tempPath = personModel.getOrgImage().substring(0, personModel.getOrgImage().lastIndexOf("/") + 1);
@ -1758,8 +1766,35 @@ public class TenPersonServiceImpl implements TenPersonService {
minioConfig.getBucketName(), faceImageFileName, inputStreamFace, putObjectOptionsFace); minioConfig.getBucketName(), faceImageFileName, inputStreamFace, putObjectOptionsFace);
inputStreamFace.close(); inputStreamFace.close();
tenPerson.setFaceImage(faceImageFileName); tenPerson.setFaceImage(faceImageFileName);
// log.info("人脸图"+tenPerson.getFaceImage());
} }
// tenPerson.setFaceImage(orgImageFileName);
//--------------------------------------------------------------------
//--------------------------------处理图片大小------------------------------------------------------
if (tenPerson.getOrgImage() != null && !tenPerson.getOrgImage().isEmpty()) {
String orgFileStr = "/root/minio/data/cell/"+ tenPerson.getOrgImage();
// String orgFileStr = "/home/server001/minio/data/cell/"+ tenPerson.getOrgImage();
try {
File picture = new File(orgFileStr);
BufferedImage sourceImg = ImageIO.read(new FileInputStream(picture));
int w = sourceImg.getWidth();
int h = sourceImg.getHeight();
if (w > 1080 || h > 1080) {
Thumbnails.of(orgFileStr)
.size(1080, 1080)
.toFile(orgFileStr);
}
}catch (Exception e){
log.error(e.getMessage());
}
}
//--------------------------------处理图片大小------------------------------------------------------
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
tenPerson.setStatus(0); tenPerson.setStatus(0);

View File

@ -14,44 +14,46 @@ import java.io.Serializable;
public class TenDeviceParamVo implements Serializable { public class TenDeviceParamVo implements Serializable {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
@JsonSerialize(using = ToStringSerializer.class) @JsonSerialize(using = ToStringSerializer.class)
@ApiModelProperty("设备ID") // @ApiModelProperty("设备ID")
private Long deviceId; // private Long deviceId;
@ApiModelProperty("设备序列号") @ApiModelProperty("设备序列号")
private String sn; private String sn;
@ApiModelProperty("活体开关") @ApiModelProperty("活体开关")
private Integer livenessFlag; private Integer livenessFlag;
@ApiModelProperty("rgb活体阈值") @ApiModelProperty("rgb活体阈值")
private Float rgbLiveThd; private Float rgbLiveThd;
@ApiModelProperty("nir活体阈值") // @ApiModelProperty("nir活体阈值")
private Float nirLiveThd; // private Float nirLiveThd;
@ApiModelProperty("识别阈值") @ApiModelProperty("识别阈值")
private Float recThd; private Float recThd;
@ApiModelProperty("最小人脸框尺寸") // @ApiModelProperty("最小人脸框尺寸")
private Integer minFaceWidth; // private Integer minFaceWidth;
@ApiModelProperty("心跳周期") // @ApiModelProperty("心跳周期")
private Integer heartbeatCycle; // private Integer heartbeatCycle;
@ApiModelProperty("补光灯亮度") // @ApiModelProperty("补光灯亮度")
private Integer lightScore; // private Integer lightScore;
@ApiModelProperty("声音开关") // @ApiModelProperty("声音开关")
private Integer songFlag; // private Integer songFlag;
@ApiModelProperty("开门声音") // @ApiModelProperty("开门声音")
private String songDoor; // private String songDoor;
@ApiModelProperty("是否上传头像1上传0不上传") // @ApiModelProperty("是否上传头像1上传0不上传")
private Integer uploadImageFlag; // private Integer uploadImageFlag;
@ApiModelProperty("1截取人脸0原图") // @ApiModelProperty("1截取人脸0原图")
private Integer cutFaceFlag; // private Integer cutFaceFlag;
@ApiModelProperty("识别间隔秒") @ApiModelProperty("识别间隔秒")
private Integer recSpace; private Integer recSpace;
@ApiModelProperty("是否抓拍陌生人0否1是") // @ApiModelProperty("是否抓拍陌生人0否1是")
private Integer strangerFlag; // private Integer strangerFlag;
@ApiModelProperty("门常开电平0低1高") // @ApiModelProperty("门常开电平0低1高")
private Integer doorOpenLevel; // private Integer doorOpenLevel;
@ApiModelProperty("锁常开电平0低1高") @ApiModelProperty("锁常开电平0低1高")
private Integer lockOpenLevel; private Integer lockOpenLevel;
@ApiModelProperty("测温补偿") @ApiModelProperty("开锁时间")
private Float temperatureUp; private Integer lockOpenTime;
@ApiModelProperty("告警温度") // @ApiModelProperty("测温补偿")
private Float temperatureAlert; // private Float temperatureUp;
@ApiModelProperty("健康码1支持0不支持") // @ApiModelProperty("告警温度")
private Integer healthCodeFlag; // private Float temperatureAlert;
// @ApiModelProperty("健康码1支持0不支持")
// private Integer healthCodeFlag;
} }

View File

@ -3,7 +3,7 @@ spring:
type: com.alibaba.druid.pool.DruidDataSource type: com.alibaba.druid.pool.DruidDataSource
druid: druid:
driver-class-name: com.mysql.cj.jdbc.Driver driver-class-name: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://192.168.1.111:3306/cell_db?useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai url: jdbc:mysql://192.168.50.232:3306/cell_db?useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai
username: user username: user
password: user@server001 password: user@server001
initial-size: 10 initial-size: 10

View File

@ -26,12 +26,12 @@ spring:
time-zone: GMT+8 time-zone: GMT+8
servlet: servlet:
multipart: multipart:
max-file-size: 100MB max-file-size: 1000MB
max-request-size: 100MB max-request-size: 1000MB
enabled: true enabled: true
redis: redis:
database: 0 database: 0
host: 192.168.1.111 host: 192.168.50.232
port: 6379 port: 6379
password: 123456 # 密码(默认为空) password: 123456 # 密码(默认为空)
timeout: 6000ms # 连接超时时长(毫秒) timeout: 6000ms # 连接超时时长(毫秒)
@ -49,13 +49,13 @@ spring:
mqtt: mqtt:
username: admin username: admin
password: public password: public
url: tcp://192.168.1.111:1883 url: tcp://192.168.50.232:1883
keepAliveInterval: 10 keepAliveInterval: 10
client: client:
id: web-server id: web-server
default: default:
topic: topic topic: topic
api: http://192.168.1.111:8081 api: http://192.168.50.232:8081
mvc: mvc:
@ -83,7 +83,7 @@ global:
db_host: localhost db_host: localhost
db_port: 3306 db_port: 3306
minio: minio:
endpoint: http://192.168.1.111:9000 endpoint: http://192.168.50.232:9000
port: 9000 port: 9000
accessKey: admin accessKey: admin
secretKey: admin@C501 secretKey: admin@C501