diff --git a/pom.xml b/pom.xml
index 6f83046..35649fa 100644
--- a/pom.xml
+++ b/pom.xml
@@ -29,7 +29,7 @@
1.8
4.12
2.9.0
- 1.1.18
+ 1.2.13
3.1.2
8.0.25
4.0
@@ -38,7 +38,7 @@
1.3.1
2.5
1.10
- 1.2.75
+ 1.2.78
2.9.9
1.18.4
2.7.0
@@ -75,6 +75,10 @@
org.springframework.boot
spring-boot-starter-data-redis
+
+
+
+
org.springframework.boot
spring-boot-configuration-processor
diff --git a/shapelight-admin/pom.xml b/shapelight-admin/pom.xml
index 74dab09..8849cc4 100644
--- a/shapelight-admin/pom.xml
+++ b/shapelight-admin/pom.xml
@@ -11,7 +11,7 @@
2.3.0
- 1.7.0
+ 1.10.0
0.7.0
0.0.9
@@ -32,16 +32,16 @@
spring-boot-starter-data-redis
-
- redis.clients
- jedis
- 2.9.0
-
-
- org.springframework.data
- spring-data-redis
- 2.1.10.RELEASE
-
+
+
+
+
+
+
+
+
+
+
org.apache.commons
@@ -83,6 +83,11 @@
shiro-spring
${shiro.version}
+
+ org.apache.shiro
+ shiro-ehcache
+ ${shiro.version}
+
com.github.axet
kaptcha
diff --git a/shapelight-admin/src/main/java/net/shapelight/common/config/CorsConfig.java b/shapelight-admin/src/main/java/net/shapelight/common/config/CorsConfig.java
index 9c413e1..3316aef 100644
--- a/shapelight-admin/src/main/java/net/shapelight/common/config/CorsConfig.java
+++ b/shapelight-admin/src/main/java/net/shapelight/common/config/CorsConfig.java
@@ -11,6 +11,7 @@ public class CorsConfig implements WebMvcConfigurer {
public void addCorsMappings(CorsRegistry registry) {
registry.addMapping("/**")
.allowedOrigins("*")
+// .allowedOriginPatterns("*")
.allowCredentials(true)
.allowedMethods("GET", "POST", "PUT", "DELETE", "OPTIONS")
.maxAge(3600);
diff --git a/shapelight-admin/src/main/java/net/shapelight/common/config/MinioUtils.java b/shapelight-admin/src/main/java/net/shapelight/common/config/MinioUtils.java
new file mode 100644
index 0000000..5d0dff5
--- /dev/null
+++ b/shapelight-admin/src/main/java/net/shapelight/common/config/MinioUtils.java
@@ -0,0 +1,81 @@
+package net.shapelight.common.config;
+
+import io.minio.MinioClient;
+import io.minio.PutObjectOptions;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Base64;
+
+@Slf4j
+@Component
+public class MinioUtils {
+ @Autowired
+ private MinioConfig minioConfig;
+ @Autowired
+ private MinioClient minioClient;
+
+ public String getFileBase64(String url){
+ String base64Image = "";
+ InputStream inStream = null;
+ ByteArrayOutputStream outStream = null;
+ try {
+ minioClient.statObject(minioConfig.getBucketName(), url);
+ inStream = minioClient.getObject(minioConfig.getBucketName(), url);
+ outStream = new ByteArrayOutputStream();
+ byte[] buffer = new byte[1024];
+ int length;
+ while ((length = inStream.read(buffer)) != -1) {
+ outStream.write(buffer, 0, length);
+ }
+ base64Image = Base64.getEncoder().encodeToString(outStream.toByteArray());
+ } catch (Exception e) {
+ log.error("Minio文件不存在:" + url);
+ e.printStackTrace();
+ } finally {
+ if (inStream != null) {
+ try {
+ inStream.close();
+ } catch (IOException e) {
+ log.error("inputStream close IOException:" + e.getMessage());
+ }
+ }
+ if (outStream != null) {
+ try {
+ outStream.close();
+ } catch (IOException e) {
+ log.error("outStream close IOException:" + e.getMessage());
+ }
+ }
+ }
+ return base64Image;
+ }
+
+ public boolean saveFileByBase64(String fileBase64,String fileName,String contentType){
+ if(fileBase64!=null && !fileBase64.isEmpty()){
+ try {
+ byte[] b = Base64.getDecoder().decode(fileBase64.replace("\n", ""));
+ InputStream inputStream = new ByteArrayInputStream(b);
+ PutObjectOptions putObjectOptions = new PutObjectOptions(b.length, -1);
+// putObjectOptions.setContentType("image/jpeg");
+ putObjectOptions.setContentType(contentType);
+ minioClient.putObject(
+ minioConfig.getBucketName(), fileName, inputStream, putObjectOptions);
+ inputStream.close();
+ return true;
+ } catch (Exception e) {
+ e.printStackTrace();
+ log.error(e.getMessage());
+ return false;
+ }
+ }else{
+ log.debug("Minio文件base64为空,不能写入");
+ return false;
+ }
+ }
+}
diff --git a/shapelight-admin/src/main/java/net/shapelight/common/config/ShiroConfig.java b/shapelight-admin/src/main/java/net/shapelight/common/config/ShiroConfig.java
index ee0d3ea..35357b2 100644
--- a/shapelight-admin/src/main/java/net/shapelight/common/config/ShiroConfig.java
+++ b/shapelight-admin/src/main/java/net/shapelight/common/config/ShiroConfig.java
@@ -4,6 +4,7 @@ package net.shapelight.common.config;
import net.shapelight.modules.sys.oauth2.OAuth2Filter;
import net.shapelight.modules.sys.oauth2.OAuth2Realm;
+import org.apache.shiro.cache.ehcache.EhCacheManager;
import org.apache.shiro.mgt.SecurityManager;
import org.apache.shiro.spring.LifecycleBeanPostProcessor;
import org.apache.shiro.spring.security.interceptor.AuthorizationAttributeSourceAdvisor;
@@ -66,6 +67,7 @@ public class ShiroConfig {
@Bean("securityManager")
public SecurityManager securityManager(OAuth2Realm oAuth2Realm) {
DefaultWebSecurityManager securityManager = new DefaultWebSecurityManager();
+ securityManager.setCacheManager(new EhCacheManager());
securityManager.setRealm(oAuth2Realm);
securityManager.setRememberMeManager(null);
return securityManager;
diff --git a/shapelight-admin/src/main/java/net/shapelight/common/utils/Constant.java b/shapelight-admin/src/main/java/net/shapelight/common/utils/Constant.java
index 1475cc5..9921533 100644
--- a/shapelight-admin/src/main/java/net/shapelight/common/utils/Constant.java
+++ b/shapelight-admin/src/main/java/net/shapelight/common/utils/Constant.java
@@ -55,6 +55,7 @@ public class Constant {
public static final int RESGISTER_TYPE_WEB = 1; //web后台添加
public static final int RESGISTER_TYPE_APP = 2; //App添加
public static final int RESGISTER_TYPE_FILE = 3; //批量导入
+ public static final int RESGISTER_TYPE_Device = 4; //批量导入
public static final int PESON_SUATUS_NOMOR = 0; //正常
public static final int PESON_SUATUS_DISABLE = 1; //禁用
diff --git a/shapelight-admin/src/main/java/net/shapelight/modules/app/controller/AppApiController.java b/shapelight-admin/src/main/java/net/shapelight/modules/app/controller/AppApiController.java
index 256b5b7..a644112 100644
--- a/shapelight-admin/src/main/java/net/shapelight/modules/app/controller/AppApiController.java
+++ b/shapelight-admin/src/main/java/net/shapelight/modules/app/controller/AppApiController.java
@@ -1,6 +1,8 @@
package net.shapelight.modules.app.controller;
+import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONArray;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import io.minio.MinioClient;
import io.minio.PutObjectOptions;
@@ -23,6 +25,8 @@ import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import net.shapelight.modules.ten.entity.*;
import net.shapelight.modules.ten.service.*;
+import net.shapelight.modules.vo.TenCelldeptSelectVo;
+import net.shapelight.modules.vo.TenCelldeptWeVo;
import net.shapelight.modules.vo.TenDeviceVo;
import org.apache.commons.io.FilenameUtils;
import org.springframework.beans.factory.annotation.Autowired;
@@ -74,6 +78,12 @@ public class AppApiController {
private SysDeviceAppService sysDeviceAppService;
@Autowired
private ServerApiService serverApiService;
+ @Autowired
+ private TenCellDeptService tenCellDeptService;
+ @Autowired
+ private TenLabelService tenLabelService;
+ @Autowired
+ private RedisUtils redisUtils;
@Login
@@ -211,6 +221,15 @@ public class AppApiController {
tenPerson.setMobile(person.getMobile());
}
+ if(tenPerson.getPersonType() == 5000 || tenPerson.getPersonType() == 5001 || tenPerson.getPersonType() == 5002){
+ TenLabelEntity labelEntity = tenLabelService.getOne(new QueryWrapper()
+ .eq("type",tenPerson.getPersonType())
+ .eq("tenant_id",user.getTenantId()));
+ if(labelEntity!=null){
+ tenPerson.setLabelId(labelEntity.getLabelId().intValue());
+ }
+ }
+
tenPersonService.saveOtherRoom(tenPerson);
return R.ok();
@@ -358,6 +377,16 @@ public class AppApiController {
TenPersonEntity personEntity = tenPersonService.getById(scope.getPersonId(), scope.getCellId());
scope.setPerson(personEntity);
scope.setCellName(tenCellService.getCellName(scope.getCellId().toString()));
+ if(personEntity!=null){
+ if(personEntity.getDeptId()!=null){
+ TenCellDeptEntity dept = tenCellDeptService.getById(personEntity.getDeptId());
+ if(dept!=null){
+ personEntity.setDeptName(dept.getName());
+ String deptAllName = tenCellDeptService.getAllParentName(dept.getParentId());
+ personEntity.setDeptAllName(deptAllName);
+ }
+ }
+ }
}
@@ -402,6 +431,17 @@ public class AppApiController {
TenPersonEntity personEntity = tenPersonService.getById(scope.getPersonId(), scope.getCellId());
scope.setPerson(personEntity);
scope.setCellName(tenCellService.getCellName(scope.getCellId().toString()));
+
+ if(personEntity!=null){
+ if(personEntity.getDeptId()!=null){
+ TenCellDeptEntity dept = tenCellDeptService.getById(personEntity.getDeptId());
+ if(dept!=null){
+ personEntity.setDeptName(dept.getName());
+ String deptAllName = tenCellDeptService.getAllParentName(dept.getParentId());
+ personEntity.setDeptAllName(deptAllName);
+ }
+ }
+ }
}
return R.ok().put("data", scopes);
}
@@ -448,7 +488,11 @@ public class AppApiController {
// }
int r = serverApiService.openDoor(deviceSn,personId);
if(r == -1){
- return R.error("设备离线");
+ if(redisUtils.get("DeviceLogin-"+deviceSn)!=null){
+ return R.error("不支持远程开门,请刷脸开门");
+ }else{
+ return R.error("设备离线");
+ }
}
return R.ok();
}
@@ -486,6 +530,14 @@ public class AppApiController {
// public static final int PERSON_TYPE_MEMBER = 5001; //家属住户
// public static final int PERSON_TYPE_TENANT = 5002; //租户
// public static final int PERSON_TYPE_GUEST = 5005; //访客
+ if(tenPerson.getPersonType() == 5000 || tenPerson.getPersonType() == 5001 || tenPerson.getPersonType() == 5002){
+ TenLabelEntity labelEntity = tenLabelService.getOne(new QueryWrapper()
+ .eq("type",tenPerson.getPersonType())
+ .eq("tenant_id",user.getTenantId()));
+ if(labelEntity!=null){
+ tenPerson.setLabelId(labelEntity.getLabelId().intValue());
+ }
+ }
if(tenPerson.getPersonType() == 5000){
tenPerson.setAppFlag(Constant.APP_LOGIN_YES);
}else{
@@ -589,19 +641,37 @@ public class AppApiController {
tenPerson.setStatus(Constant.PESON_SUATUS_NOMOR);
- TenPersonEntity tenPersonEntity = tenPersonService.findByName(tenPerson.getName(),
- tenPerson.getRoomId(),tenPerson.getCellId());
- if(tenPersonEntity!=null){
- return R.error("姓名在此房间已存在");
- }
-
- if(tenPerson.getIdCard()!=null){
- TenPersonEntity tenPersonIdcard = tenPersonService.findByIdCard(tenPerson.getIdCard(),
- tenPerson.getRoomId(),tenPerson.getCellId());
- if(tenPersonIdcard!=null){
- return R.error("身份证在此房间已存在");
+ if(tenPerson.getPersonType() == 5000 || tenPerson.getPersonType() == 5001 || tenPerson.getPersonType() == 5002){
+ TenLabelEntity labelEntity = tenLabelService.getOne(new QueryWrapper()
+ .eq("type",tenPerson.getPersonType())
+ .eq("tenant_id",user.getTenantId()));
+ if(labelEntity!=null){
+ tenPerson.setLabelId(labelEntity.getLabelId().intValue());
}
}
+ tenPerson.setDeptId(loginPerson.getDeptId());
+
+ if(tenPerson.getDeptId()!=null){
+ int c = tenPersonService.checkByIdCardDept(tenPerson.getIdCard(),tenPerson.getDeptId());
+ if(c>0){
+ return R.error("身份证在组织已存在");
+ }
+ }
+
+
+// TenPersonEntity tenPersonEntity = tenPersonService.findByName(tenPerson.getName(),
+// tenPerson.getRoomId(),tenPerson.getCellId());
+// if(tenPersonEntity!=null){
+// return R.error("姓名在此房间已存在");
+// }
+//
+// if(tenPerson.getIdCard()!=null){
+// TenPersonEntity tenPersonIdcard = tenPersonService.findByIdCard(tenPerson.getIdCard(),
+// tenPerson.getRoomId(),tenPerson.getCellId());
+// if(tenPersonIdcard!=null){
+// return R.error("身份证在此房间已存在");
+// }
+// }
@@ -636,7 +706,16 @@ public class AppApiController {
// pList = tenPersonService.getByCellId(scope.getCellId(),key);
params.put("cellId",scope.getCellId().toString());
PageUtils page = tenPersonService.getByCellIdQueryPage(params);
-
+ for(TenPersonEntity person: (List)page.getList()){
+ if(person.getDeptId()!=null){
+ TenCellDeptEntity dept = tenCellDeptService.getById(person.getDeptId());
+ if(dept!=null){
+ person.setDeptName(dept.getName());
+ String deptAllName = tenCellDeptService.getAllParentName(dept.getParentId());
+ person.setDeptAllName(deptAllName);
+ }
+ }
+ }
return R.ok().put("data", page);
}
//业主获取家庭成员,业主,租户,家庭成员
@@ -646,8 +725,20 @@ public class AppApiController {
TenPersonEntity personEntity = tenPersonService.getById(scope.getPersonId(),scope.getCellId());
// pList = tenPersonService.getByRoomId(personEntity.getRoomId(),scope.getCellId(),key);
params.put("cellId",scope.getCellId().toString());
- params.put("roomId",personEntity.getRoomId().toString());
- PageUtils page = tenPersonService.selectByRoomIdQueryPage(params);
+// params.put("roomId",personEntity.getRoomId().toString());
+ params.put("deptId",personEntity.getDeptId().toString());
+// PageUtils page = tenPersonService.selectByRoomIdQueryPage(params);
+ PageUtils page = tenPersonService.selectByDeptIdQueryPage(params);
+ for(TenPersonEntity person: (List)page.getList()){
+ if(person.getDeptId()!=null){
+ TenCellDeptEntity dept = tenCellDeptService.getById(person.getDeptId());
+ if(dept!=null){
+ person.setDeptName(dept.getName());
+ String deptAllName = tenCellDeptService.getAllParentName(dept.getParentId());
+ person.setDeptAllName(deptAllName);
+ }
+ }
+ }
return R.ok().put("data", page);
}
@@ -681,8 +772,21 @@ public class AppApiController {
TenPersonEntity personEntity = tenPersonService.getById(scope.getPersonId(),scope.getCellId());
// pList = tenPersonService.getByRoomId(personEntity.getRoomId(),scope.getCellId(),key);
params.put("cellId",scope.getCellId().toString());
- params.put("roomId",personEntity.getRoomId().toString());
- PageUtils page = tenPersonService.selectByRoomIdForGuestQueryPage(params);
+// params.put("roomId",personEntity.getRoomId().toString());
+ params.put("deptId",personEntity.getDeptId().toString());
+// PageUtils page = tenPersonService.selectByRoomIdForGuestQueryPage(params);
+ PageUtils page = tenPersonService.selectByDeptIdForGuestQueryPage(params);
+
+ for(TenPersonEntity person: (List)page.getList()){
+ if(person.getDeptId()!=null){
+ TenCellDeptEntity dept = tenCellDeptService.getById(person.getDeptId());
+ if(dept!=null){
+ person.setDeptName(dept.getName());
+ String deptAllName = tenCellDeptService.getAllParentName(dept.getParentId());
+ person.setDeptAllName(deptAllName);
+ }
+ }
+ }
return R.ok().put("data", page);
}
@@ -812,4 +916,89 @@ public class AppApiController {
}
return R.ok().put("data",version);
}
+
+
+ /**
+ * 选择区域(添加、修改菜单)
+ */
+// @Login
+ @PostMapping("/selectDeptSub")
+ @ApiOperation("添加人员选择框")
+ public R selectDeptSub(@LoginUser AppUserEntity user,@RequestBody Map param){
+// if(user == null){
+// return R.error("用户不存在");
+// }
+ String cellId = (String)param.get("cellId");
+// String tenantId = user.getTenantId().toString();
+// String tenantId = getUser().getTenantId()+"";
+// Map params = new HashMap();
+// params.put("tenantId",tenantId+"");
+// String cellId = (String)params.get("cellId");
+ List areaList = tenCellDeptService.list(new QueryWrapper()
+ .eq("cell_id",cellId));
+ List areaSelectList = new ArrayList<>();
+ //添加一级部门
+// TenCellDeptEntity root = new TenCellDeptEntity();
+// root.setDeptId(cellId);
+// String cellName = tenCellService.getCellName(cellId+"");
+// root.setName(cellName);
+// root.setParentId(-1L);
+// areaList.add(root);
+ for(TenCellDeptEntity area: areaList){
+ TenCelldeptWeVo vo = new TenCelldeptWeVo();
+ vo.setId(area.getDeptId().toString());
+ vo.setLabel(area.getName());
+ vo.setParentId(area.getParentId().toString());
+ vo.setParentName(area.getParentName());
+ areaSelectList.add(vo);
+ }
+ JSONArray areaTree = TreeUtils.listToTree(JSONArray.parseArray(JSON.toJSONString(areaSelectList)),"id","parentId","children");
+// for(Object ob: areaTree){
+//
+// }
+ return R.ok().put("data", areaTree);
+ }
+
+
+
+// /**
+// * 选择区域(添加、修改菜单)
+// */
+// @Login
+// @PostMapping("/selectDept")
+// @ApiOperation("添加人员选择框")
+// public R selectDept(@LoginUser AppUserEntity user,@RequestBody Map param){
+// if(user == null){
+// return R.error("用户不存在");
+// }
+// String parentId = (String)param.get("deptId");
+// String tenantId = user.getTenantId().toString();
+//// String tenantId = getUser().getTenantId()+"";
+//// Map params = new HashMap();
+//// params.put("tenantId",tenantId+"");
+//// String cellId = (String)params.get("cellId");
+// List areaList = tenCellDeptService.list(new QueryWrapper()
+// .eq("parent_id",parentId));
+// List areaSelectList = new ArrayList<>();
+// //添加一级部门
+//// TenCellDeptEntity root = new TenCellDeptEntity();
+//// root.setDeptId(cellId);
+//// String cellName = tenCellService.getCellName(cellId+"");
+//// root.setName(cellName);
+//// root.setParentId(-1L);
+//// areaList.add(root);
+// for(TenCellDeptEntity area: areaList){
+// TenCelldeptSelectVo vo = new TenCelldeptSelectVo();
+// vo.setDeptId(area.getDeptId().toString());
+// vo.setName(area.getName());
+// vo.setParentId(area.getParentId().toString());
+// vo.setParentName(area.getParentName());
+// areaSelectList.add(vo);
+// }
+//// JSONArray areaTree = TreeUtils.listToTree(JSONArray.parseArray(JSON.toJSONString(areaSelectList)),"deptId","parentId","childrenList");
+//// for(Object ob: areaTree){
+////
+//// }
+// return R.ok().put("data", areaSelectList);
+// }
}
diff --git a/shapelight-admin/src/main/java/net/shapelight/modules/app/controller/AppInfoApiController.java b/shapelight-admin/src/main/java/net/shapelight/modules/app/controller/AppInfoApiController.java
index 6697787..4ee6b62 100644
--- a/shapelight-admin/src/main/java/net/shapelight/modules/app/controller/AppInfoApiController.java
+++ b/shapelight-admin/src/main/java/net/shapelight/modules/app/controller/AppInfoApiController.java
@@ -64,6 +64,8 @@ public class AppInfoApiController {
private GlobalValue globalValue;
@Autowired
private TenRecordService tenRecordService;
+ @Autowired
+ private TenCellDeptService tenCellDeptService;
@Login
@@ -312,8 +314,10 @@ public class AppInfoApiController {
TenPersonEntity personEntity = tenPersonService.getById(scope.getPersonId(),scope.getCellId());
// pList = tenPersonService.getByRoomId(personEntity.getRoomId(),scope.getCellId(),key);
params.put("cellId",scope.getCellId().toString());
- params.put("roomId",personEntity.getRoomId().toString());
- PageUtils page = tenRecordService.queryPageRoomRecord(params);
+// params.put("roomId",personEntity.getRoomId().toString());
+ params.put("deptId",personEntity.getDeptId().toString());
+// PageUtils page = tenRecordService.queryPageRoomRecord(params);
+ PageUtils page = tenRecordService.queryPageDeptRecord(params);
return R.ok().put("data", page);
}
}
diff --git a/shapelight-admin/src/main/java/net/shapelight/modules/excel/listener/PersonExcelListener.java b/shapelight-admin/src/main/java/net/shapelight/modules/excel/listener/PersonExcelListener.java
index de89277..8b7f38a 100644
--- a/shapelight-admin/src/main/java/net/shapelight/modules/excel/listener/PersonExcelListener.java
+++ b/shapelight-admin/src/main/java/net/shapelight/modules/excel/listener/PersonExcelListener.java
@@ -184,16 +184,16 @@ public class PersonExcelListener extends AnalysisEventListener {
- String osName = System.getProperty("os.name");//获取指定键(即os.name)的系统属性,如:Windows 7。
- if (!Pattern.matches("Windows.*", osName)) {
- int res = PicSDK.getFace(personModel.getOrgImage(), tempFaceFilePath);
- if (res != 0) {
- personModel.setMessage("图片不合格,未检测到人脸");
- personModel.setStatus(0);
- list.add(personModel);
- return;
- }
- }
+// String osName = System.getProperty("os.name");//获取指定键(即os.name)的系统属性,如:Windows 7。
+// if (!Pattern.matches("Windows.*", osName)) {
+// int res = PicSDK.getFace(personModel.getOrgImage(), tempFaceFilePath);
+// if (res != 0) {
+// personModel.setMessage("图片不合格,未检测到人脸");
+// personModel.setStatus(0);
+// list.add(personModel);
+// return;
+// }
+// }
// int res = PicSDK.getFace(personModel.getOrgImage(), tempFaceFilePath);
diff --git a/shapelight-admin/src/main/java/net/shapelight/modules/httpapi/controler/HttpApiController.java b/shapelight-admin/src/main/java/net/shapelight/modules/httpapi/controler/HttpApiController.java
new file mode 100644
index 0000000..4ea8600
--- /dev/null
+++ b/shapelight-admin/src/main/java/net/shapelight/modules/httpapi/controler/HttpApiController.java
@@ -0,0 +1,1221 @@
+package net.shapelight.modules.httpapi.controler;
+
+
+import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import io.minio.MinioClient;
+import io.minio.PutObjectOptions;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiImplicitParam;
+import io.swagger.annotations.ApiImplicitParams;
+import io.swagger.annotations.ApiOperation;
+import lombok.extern.slf4j.Slf4j;
+import net.shapelight.common.config.GlobalValue;
+import net.shapelight.common.config.MinioConfig;
+import net.shapelight.common.config.MinioUtils;
+import net.shapelight.common.utils.*;
+import net.shapelight.modules.app.entity.AppUserEntity;
+import net.shapelight.modules.app.service.AppUserService;
+import net.shapelight.modules.httpapi.service.AuthService;
+import net.shapelight.modules.nettyapi.config.CmdConstant;
+import net.shapelight.modules.nettyapi.config.MyMessage;
+import net.shapelight.modules.nettyapi.utils.Result;
+import net.shapelight.modules.sys.entity.SysDeviceAppEntity;
+import net.shapelight.modules.sys.entity.SysDeviceEntity;
+import net.shapelight.modules.sys.entity.SysDeviceLogEntity;
+import net.shapelight.modules.sys.entity.SysDeviceTypeEntity;
+import net.shapelight.modules.sys.service.SysDeviceAppService;
+import net.shapelight.modules.sys.service.SysDeviceLogService;
+import net.shapelight.modules.sys.service.SysDeviceService;
+import net.shapelight.modules.sys.service.SysDeviceTypeService;
+import net.shapelight.modules.ten.entity.*;
+import net.shapelight.modules.ten.service.*;
+import net.shapelight.modules.vo.*;
+import org.apache.commons.io.FilenameUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
+import org.springframework.web.multipart.MultipartFile;
+
+import java.io.ByteArrayInputStream;
+import java.io.InputStream;
+import java.util.*;
+
+
+/**
+ * APP测试接口
+ */
+@Slf4j
+@RestController
+@RequestMapping("/api/dev/v2")
+@Api(value="设备HTTP协议接口",tags="设备HTTP协议接口")
+public class HttpApiController {
+
+ @Autowired
+ private TenCellService tenCellService;
+ @Autowired
+ private TenDeviceService tenDeviceService;
+ @Autowired
+ private AuthService authService;
+ @Autowired
+ private RedisUtils redisUtils;
+ @Autowired
+ private SysDeviceService sysDeviceService;
+ @Autowired
+ private TenDeviceAlertService tenDeviceAlertService;
+ @Autowired
+ private TenPersonSyncService tenPersonSyncService;
+ @Autowired
+ private TenPersonService tenPersonService;
+ @Autowired
+ private TenDoorCardService tenDoorCardService;
+ @Autowired
+ private GlobalValue globalValue;
+ @Autowired
+ private SysDeviceTypeService sysDeviceTypeService;
+ @Autowired
+ private TenBuildService tenBuildService;
+ @Autowired
+ private TenRoomService tenRoomService;
+ @Autowired
+ private TenRecordService tenRecordService;
+ @Autowired
+ private SysDeviceAppService sysDeviceAppService;
+ @Autowired
+ private AppUserService appUserService;
+ @Autowired
+ private MinioConfig minioConfig;
+ @Autowired
+ private MinioClient minioClient;
+ @Autowired
+ private SysDeviceLogService sysDeviceLogService;
+ @Autowired
+ private TenDeviceOperateLogService tenDeviceOperateLogService;
+ @Autowired
+ private TenCellDeptService tenCellDeptService;
+ @Autowired
+ private TenLabelService tenLabelService;
+
+ /**
+ *
+ */
+ @PostMapping("/headBeat")
+ @ApiOperation("心跳接口")
+ @ApiImplicitParams({
+ @ApiImplicitParam(name = "dev_id", value = "sn", paramType = "query", dataType = "String", required = true),
+ @ApiImplicitParam(name = "appKey", value = "appkey", paramType = "query", dataType = "String", required = true),
+ @ApiImplicitParam(name = "timestamp", value = "timestamp", paramType = "query", dataType = "String", required = true),
+ @ApiImplicitParam(name = "sign", value = "sign", paramType = "query", dataType = "String", required = true),
+ @ApiImplicitParam(name = "face_count", value = "设备人脸数", paramType = "query", dataType = "String", required = true),
+ })
+ public R headBeat(@RequestBody JSONObject jsonContent) {
+ String sn = jsonContent.getString("dev_id");
+ String appKey = jsonContent.getString("appKey");
+ String timestamp = jsonContent.getString("timestamp");
+ String sign = jsonContent.getString("sign");
+ //鉴权
+ R res = authService.auth(sn,appKey,timestamp,sign);
+ if((Integer) res.get("code") != 0){
+ return res;
+ }
+ log.debug("收到心跳信息:"+sn);
+ //1.判断sn是否存在 设备不存在1002
+ TenDeviceEntity deviceEntity = tenDeviceService.findBySn(sn);
+ SysDeviceEntity sysDeviceEntity = sysDeviceService.getBySn(sn);
+//----------------------------------------以下业务-----------------------------------------------------
+
+ JSONObject dataJson = jsonContent.getJSONObject("data");
+
+ Integer faceCount = dataJson.getIntValue("face_count");
+ Integer rgbCameraStatus = dataJson.getIntValue("rgb_camera_status");
+ Integer irCameraStatus = dataJson.getIntValue("ir_camera_status");
+ Integer relayStatus = dataJson.getIntValue("relay_status");
+
+ Integer restart = dataJson.getInteger("restart");
+ if(restart!=null){
+ if(restart.intValue() == 0){
+ redisUtils.remove("DeviceRestart-"+sn);
+ }
+ }
+
+ //保存人脸个数
+// deviceEntity.setFaceCount(faceCount);
+// deviceEntity.setLastUpdateTime(new Date());
+// tenDeviceService.evictupdateById(deviceEntity);
+
+ //缓存
+ redisUtils.set("HearTBeat-"+sn,faceCount+"="+DateUtils.format(new Date(),DateUtils.DATE_TIME_PATTERN),31536000l);//保存一年
+//心跳在线时间
+ redisUtils.set("DeviceLogin-"+sn,DateUtils.format(new Date(),DateUtils.DATE_TIME_PATTERN),60l);//保存
+
+ TenCellEntity cellEntity = tenCellService.getById(deviceEntity.getCellId());
+
+ Date now = new Date();
+
+ //保存告警信息
+ if(rgbCameraStatus.intValue() == 1){
+ TenDeviceAlertEntity da = new TenDeviceAlertEntity();
+ da.setSn(sn);
+ da.setCellId(cellEntity.getCellId());
+ da.setAlertLevel("严重");
+ da.setAlertType("故障");
+ da.setAlertTime(now);
+ da.setErrorLog("RGB摄像头故障");
+ tenDeviceAlertService.save(da);
+ }
+
+ if(irCameraStatus.intValue() == 1){
+ TenDeviceAlertEntity da = new TenDeviceAlertEntity();
+ da.setSn(sn);
+ da.setCellId(cellEntity.getCellId());
+ da.setAlertLevel("严重");
+ da.setAlertType("故障");
+ da.setAlertTime(now);
+ da.setErrorLog("红外摄像头故障");
+ tenDeviceAlertService.save(da);
+ }
+
+ if(relayStatus.intValue() == 1){
+ TenDeviceAlertEntity da = new TenDeviceAlertEntity();
+ da.setSn(sn);
+ da.setCellId(cellEntity.getCellId());
+ da.setAlertLevel("严重");
+ da.setAlertType("故障");
+ da.setAlertTime(now);
+ da.setErrorLog("继电器故障");
+ tenDeviceAlertService.save(da);
+ }
+//-----------------------------------------------------------返回配置信息-------------------------------------------------
+ Map configMap = new HashMap<>();
+ configMap.put("work_mode",deviceEntity.getHealthCodeFlag());
+ configMap.put("recognize_interval",deviceEntity.getRecSpace());
+ configMap.put("relay_suck_time",5);
+ if(deviceEntity.getLivenessFlag().intValue() == 1){
+ configMap.put("support_liveness",true);
+ }else{
+ configMap.put("support_liveness",false);
+ }
+ configMap.put("liveness_score",deviceEntity.getRgbLiveThd().intValue());
+ configMap.put("recognize_score",deviceEntity.getRecThd().intValue());
+ configMap.put("recognize_distance",1);
+ configMap.put("alert_temp_threshold",deviceEntity.getTemperatureAlert());
+ configMap.put("upload_face_pic",true);
+ configMap.put("upload_pic_mode",deviceEntity.getUploadImageFlag());
+ configMap.put("upload_http_url","");
+ if(deviceEntity.getStrangerFlag().intValue() == 1){
+ configMap.put("support_stranger",true);
+ }else{
+ configMap.put("support_stranger",false);
+ }
+
+ //-----------------------------------------3d数据--------------------------------------
+ // 以下是3d配置
+// SysDeviceTypeEntity deviceTypeEntity = sysDeviceTypeService.getById(sysDeviceEntity.getDeviceTypeId());
+//
+// if (deviceTypeEntity.getOther().equals(Constant.DEVICE_FLAG_3D)) {
+// configMap.put("recognize_score_3d", deviceEntity.getRecognizeScore3d());
+// configMap.put("detection_type", deviceEntity.getDetectionType());
+// }
+ configMap.put("recognize_score_3d", deviceEntity.getRecognizeScore3d());
+ configMap.put("detection_type", deviceEntity.getDetectionType());
+ //------------------------v5http增加内容-------------------------------
+ configMap.put("appLanguage",deviceEntity.getAppLanguage());
+
+ if(redisUtils.get("DeviceRestart-"+sn)!=null){
+ configMap.put("restart",1);
+ }
+ return R.ok().put("data",configMap);
+ }
+
+
+
+ /**
+ *
+ */
+ @PostMapping("/getAllMember")
+ @ApiOperation("获取所有")
+ @ApiImplicitParams({
+ @ApiImplicitParam(name = "dev_id", value = "sn", paramType = "query", dataType = "String", required = true),
+ @ApiImplicitParam(name = "appKey", value = "appkey", paramType = "query", dataType = "String", required = true),
+ @ApiImplicitParam(name = "timestamp", value = "timestamp", paramType = "query", dataType = "String", required = true),
+ @ApiImplicitParam(name = "sign", value = "sign", paramType = "query", dataType = "String", required = true),
+ })
+ public R getAllMember(@RequestBody JSONObject jsonContent) {
+ String sn = jsonContent.getString("dev_id");
+ String appKey = jsonContent.getString("appKey");
+ String timestamp = jsonContent.getString("timestamp");
+ String sign = jsonContent.getString("sign");
+ //鉴权
+ R res = authService.auth(sn,appKey,timestamp,sign);
+ if((Integer) res.get("code") != 0){
+ return res;
+ }
+ log.debug("全量获取:"+sn);
+ TenDeviceEntity deviceEntity = tenDeviceService.findBySn(sn);
+//----------------------------------------以下业务-----------------------------------------------------
+ List all = tenPersonSyncService.getDeviceAllPersonIdUpdateTime(deviceEntity.getDeviceId(),deviceEntity.getTenantId());
+ List resAll = new ArrayList<>();
+ for(TenPersonIdUpdateAllVo vo: all){
+ TenPersonAllVo oVo = new TenPersonAllVo();
+ oVo.setUid(vo.getUid());
+ oVo.setLast_update_stamp(vo.getLast_update_stamp().getTime());
+ resAll.add(oVo);
+ }
+ //删除状态为删除的人员
+ tenPersonSyncService.removeAllDeletePersons(deviceEntity.getDeviceId(),deviceEntity.getTenantId());
+ Map allPersons = new HashMap<>();
+ allPersons.put("allPerson",resAll);
+ return R.ok().put("data",allPersons);
+ }
+
+
+
+
+
+ @PostMapping("/getOneMember")
+ @ApiOperation("获取一个人详细信息")
+ @ApiImplicitParams({
+ @ApiImplicitParam(name = "dev_id", value = "sn", paramType = "query", dataType = "String", required = true),
+ @ApiImplicitParam(name = "appKey", value = "appkey", paramType = "query", dataType = "String", required = true),
+ @ApiImplicitParam(name = "timestamp", value = "timestamp", paramType = "query", dataType = "String", required = true),
+ @ApiImplicitParam(name = "sign", value = "sign", paramType = "query", dataType = "String", required = true),
+ })
+ public R getOneMember(@RequestBody JSONObject jsonContent) {
+ String sn = jsonContent.getString("dev_id");
+ String appKey = jsonContent.getString("appKey");
+ String timestamp = jsonContent.getString("timestamp");
+ String sign = jsonContent.getString("sign");
+ //鉴权
+ R res = authService.auth(sn,appKey,timestamp,sign);
+ if((Integer) res.get("code") != 0){
+ return res;
+ }
+ log.debug("单个获取:"+sn);
+ TenDeviceEntity deviceEntity = tenDeviceService.findBySn(sn);
+// SysDeviceEntity sysDeviceEntity = sysDeviceService.getBySn(sn);
+//----------------------------------------以下业务-----------------------------------------------------
+ JSONObject dataJson = jsonContent.getJSONObject("data");
+ Long uid = dataJson.getLong("uid");
+
+ TenCellEntity cellEntity = tenCellService.getById(deviceEntity.getCellId());
+
+ TenPersonEntity p = tenPersonService.getById(uid,cellEntity.getCellId());
+ if(p == null || p.getDeleteFlag().intValue() == 1){
+ return R.error("人员不存在");
+ }
+ TenUserVo puser = new TenUserVo();
+
+ TenDoorCardEntity doorCardEntity = tenDoorCardService.getOne(
+ new QueryWrapper()
+ .eq("person_id",p.getPersonId())
+ );
+
+ if(doorCardEntity!=null){
+ puser.setCard_id(doorCardEntity.getDoorCard());
+ }else{
+ List doorCardRooms = tenDoorCardService.list(
+ new QueryWrapper()
+ .eq("room_id",p.getRoomId())
+ );
+ TenDoorCardEntity doorCardRoom = null;
+ if(doorCardRooms.size()>0){
+ doorCardRoom = doorCardRooms.get(0);
+ }
+ if(doorCardRoom!=null){
+ puser.setCard_id(doorCardRoom.getDoorCard());
+ }
+
+ }
+
+ puser.setUid(p.getPersonId());
+ puser.setUser_name(p.getName());
+ puser.setUser_type(0);
+ if(p.getLiveStart()!=null){
+ puser.setActive_start_time((int)(p.getLiveStart().getTime()/1000));
+ }
+ if(p.getLiveEnd()!=null){
+ puser.setActive_end_time((int)(p.getLiveEnd().getTime()/1000));
+ }
+
+// puser.setActive_start_time(0);
+// puser.setActive_end_time(0);
+
+ puser.setLast_update_stamp(p.getLastUpdateTime().getTime());
+ puser.setFace_pic_download_url(globalValue.getMinioEndpoint()+"/"
+ + globalValue.getMinioBucketName()+"/"
+ + p.getOrgImage());
+ puser.setFace_pic_base64("");
+
+
+ //--------------------------------------一码通设备添加
+ puser.setIdNumber(p.getIdCard());
+ puser.setPersonClass(p.getPersonType());
+
+
+ //-----------------------------------------3d数据--------------------------------------
+ /*
+ "rgb":"url"
+ "depth":"url"
+ "faceModel": "",
+ "souceFile": "url",
+ "cameraParam": "65464313212",
+ */
+ // 以下是3d配置
+// SysDeviceTypeEntity deviceTypeEntity = sysDeviceTypeService.getById(sysDeviceEntity.getDeviceTypeId());
+//
+// if (deviceTypeEntity.getOther().equals(Constant.DEVICE_FLAG_3D)) {
+// if(p.getSourceFile()!=null){
+// puser.setSourceFile(globalValue.getMinioEndpoint()+"/"
+// + globalValue.getMinioBucketName()+"/"
+// + p.getSourceFile());
+// }
+// if(p.getCameraParam()!=null){
+// puser.setCameraParam(p.getCameraParam());
+// }
+// if(p.getFaceModel()!=null){
+// puser.setFaceModel(p.getFaceModel());
+// }
+// //----------------------------v5http---------------------------
+// if(p.getThdFeature()!=null){
+// puser.setThdFeature(p.getThdFeature());
+// }
+// }
+
+ if(p.getSourceFile()!=null){
+ puser.setSourceFile(globalValue.getMinioEndpoint()+"/"
+ + globalValue.getMinioBucketName()+"/"
+ + p.getSourceFile());
+ }
+ if(p.getCameraParam()!=null){
+ puser.setCameraParam(p.getCameraParam());
+ }
+ if(p.getFaceModel()!=null){
+ puser.setFaceModel(p.getFaceModel());
+ }
+ //----------------------------v5http---------------------------
+ if(p.getThdFeature()!=null){
+ puser.setThdFeature(p.getThdFeature());
+ }
+
+ puser.setBuildUnit(p.getBuildName()+p.getBuildUnit()+"单元");
+ puser.setRoom(p.getRoomName());
+ puser.setDeptId(p.getDeptId());
+
+ if(p.getDeptId()!=null){
+ TenCellDeptEntity deptEntity = tenCellDeptService.getById(p.getDeptId());
+ if(deptEntity!=null){
+ puser.setDeptName(deptEntity.getName());
+ }
+ }
+ puser.setLabelId(p.getLabelId());
+ puser.setLabelName(p.getLabelName());
+
+
+ TenPersonSyncEntity syncEntity = tenPersonSyncService.findByDeviceIdAndPersonId(deviceEntity.getDeviceId(),
+ p.getPersonId(),deviceEntity.getTenantId());
+ syncEntity.setState(Constant.PERSON_SYNC_OK);
+
+ tenPersonSyncService.updateById(syncEntity);
+ return R.ok().put("data",puser);
+ }
+
+
+
+
+ @PostMapping("/getRoomInfo")
+ @ApiOperation("获取楼栋户室信息和人员类型信息")
+ @ApiImplicitParams({
+ @ApiImplicitParam(name = "dev_id", value = "sn", paramType = "query", dataType = "String", required = true),
+ @ApiImplicitParam(name = "appKey", value = "appkey", paramType = "query", dataType = "String", required = true),
+ @ApiImplicitParam(name = "timestamp", value = "timestamp", paramType = "query", dataType = "String", required = true),
+ @ApiImplicitParam(name = "sign", value = "sign", paramType = "query", dataType = "String", required = true),
+ })
+ public R getRoomInfo(@RequestBody JSONObject jsonContent) {
+ String sn = jsonContent.getString("dev_id");
+ String appKey = jsonContent.getString("appKey");
+ String timestamp = jsonContent.getString("timestamp");
+ String sign = jsonContent.getString("sign");
+ //鉴权
+ R res = authService.auth(sn,appKey,timestamp,sign);
+ if((Integer) res.get("code") != 0){
+ return res;
+ }
+ log.debug("获取楼栋户室信息和人员类型信息:"+sn);
+ TenDeviceEntity deviceEntity = tenDeviceService.findBySn(sn);
+//----------------------------------------以下业务-----------------------------------------------------
+ /*
+ public static final int PERSON_TYPE_OWNER = 5000; //业主
+ public static final int PERSON_TYPE_MEMBER = 5001; //家属住户
+ public static final int PERSON_TYPE_TENANT = 5002; //租户
+ public static final int PERSON_TYPE_GUEST = 5005; //访客
+ public static final int PERSON_TYPE_PROPERTY = 5006; //物业人员
+ public static final int PERSON_TYPE_WHITE = 5007; //白名单
+ public static final int PERSON_TYPE_BLACK = 5008; //黑名单
+ {
+ "cell":{
+ "cellId":222222;
+ "name":"西电";
+ "build:[
+ {
+ "buildId":"836267751659012097";
+ "layerCount":4;
+ "nameUnit":"A座2单元";
+ "room":[
+ {
+ roomId:"836279296308805636";
+ roomName:"0101室"
+ }
+ ]
+ },
+ {
+ "buildId":"836267751659012097";
+ "layerCount":4;
+ "nameUnit":"A座2单元"
+ }
+ ]
+ },
+ "personType":[
+ {
+ "personType":5000,
+ "name":"业主"
+ },
+ {
+
+ }
+ ]
+ }
+ */
+ TenCellEntity cell = tenCellService.getById(deviceEntity.getCellId());
+ List buildList = tenBuildService.selectByCellId(cell.getCellId());
+
+ JSONObject cellJson = new JSONObject();
+ cellJson.put("cellId",cell.getCellId());
+ cellJson.put("name",cell.getName());
+
+ List buildVoList = new ArrayList<>();
+ for(TenBuildEntity buildEntity: buildList){
+ AppBuildVo buildVo = new AppBuildVo();
+ buildVo.setBuildId(buildEntity.getBuildId());
+ buildVo.setLayerCount(buildEntity.getLayerCount());
+ buildVo.setNameUnit(buildEntity.getName()+buildEntity.getUnit()+"单元");
+
+ List roomVoList = new ArrayList<>();
+ List roomList = tenRoomService.getBuildRooms(buildEntity.getBuildId());
+ for(TenRoomEntity roomEntity: roomList){
+ AppRoomVo roomVo = new AppRoomVo();
+ roomVo.setRoomId(roomEntity.getRoomId());
+ roomVo.setRoomName(roomEntity.getRoomName());
+ roomVo.setLayer(roomEntity.getLayer());
+
+ roomVoList.add(roomVo);
+ }
+ buildVo.setRoomList(roomVoList);
+
+ buildVoList.add(buildVo);
+ }
+ cellJson.put("buildList",buildVoList);
+
+ //--------------------------------------------------------------
+ List personTypeList = new ArrayList<>();
+ AppPersonType personType5000 = new AppPersonType();
+ personType5000.setPersonType(Constant.PERSON_TYPE_OWNER);
+ personType5000.setTypeName("业主");
+ personTypeList.add(personType5000);
+
+ AppPersonType personType5001 = new AppPersonType();
+ personType5001.setPersonType(Constant.PERSON_TYPE_MEMBER);
+ personType5001.setTypeName("家属住户");
+ personTypeList.add(personType5001);
+
+ AppPersonType personType5002 = new AppPersonType();
+ personType5002.setPersonType(Constant.PERSON_TYPE_TENANT);
+ personType5002.setTypeName("租户");
+ personTypeList.add(personType5002);
+
+ AppPersonType personType5006 = new AppPersonType();
+ personType5006.setPersonType(Constant.PERSON_TYPE_PROPERTY);
+ personType5006.setTypeName("物业");
+ personTypeList.add(personType5006);
+
+ cellJson.put("personType",personTypeList);
+
+ //删除状态为删除的人员
+ return R.ok().put("data",cellJson);
+ }
+
+
+
+ /**
+ *private Integer work_mode; //0表示门禁模式,1表示门禁+测温模式,默认为0 health_code_flag
+ * private Integer recognize_interval; //连续两次人脸识别时间间隔,默认3s rec_space
+ * private Integer relay_suck_time; //继电器吸合开锁持续时间,默认5s
+ * private Boolean support_liveness; //是否支持活体检测,默认true liveness_flag
+ * private Integer liveness_score; //活体检测超过此值则判断为活体,默认60 rgb_live_thd
+ * private Integer recognize_score; //人脸比对分值超过此值则判断为同一个人,默认65 rec_thd
+ * private Integer recognize_distance; //默认1m
+ * private Float alert_temp_threshold; //人脸温度超过此值则报警,默认5s temperature_alert
+ * private Boolean upload_face_pic; //默认true upload_image_flag
+ * private Integer upload_pic_mode; //枚举值0表示人脸图base64编码,和人脸识别记录同时上传, 1表示人脸图通过http协议post上传
+ * private String upload_http_url; //人脸图通过http上传的url地址
+ * private Boolean support_stranger; //是否支持陌生人抓拍 默认false stranger_flag
+ */
+ @PostMapping("/setConfig")
+ @ApiOperation("设备端设置参数发到后台")
+ @ApiImplicitParams({
+ @ApiImplicitParam(name = "dev_id", value = "sn", paramType = "query", dataType = "String", required = true),
+ @ApiImplicitParam(name = "appKey", value = "appkey", paramType = "query", dataType = "String", required = true),
+ @ApiImplicitParam(name = "timestamp", value = "timestamp", paramType = "query", dataType = "String", required = true),
+ @ApiImplicitParam(name = "sign", value = "sign", paramType = "query", dataType = "String", required = true),
+ })
+ public R setConfig(@RequestBody JSONObject jsonContent) {
+ String sn = jsonContent.getString("dev_id");
+ String appKey = jsonContent.getString("appKey");
+ String timestamp = jsonContent.getString("timestamp");
+ String sign = jsonContent.getString("sign");
+ //鉴权
+ R res = authService.auth(sn,appKey,timestamp,sign);
+ if((Integer) res.get("code") != 0){
+ return res;
+ }
+ log.debug("设备端设置参数发到后台:"+sn);
+ TenDeviceEntity deviceEntity = tenDeviceService.findBySn(sn);
+//----------------------------------------以下业务-----------------------------------------------------
+ JSONObject configJson = jsonContent.getJSONObject("data");
+
+ deviceEntity.setHealthCodeFlag(configJson.getInteger("work_mode"));
+ deviceEntity.setRecSpace(configJson.getInteger("recognize_interval"));
+ deviceEntity.setLivenessFlag(configJson.getInteger("support_liveness"));
+ deviceEntity.setRgbLiveThd(configJson.getFloat("liveness_score"));
+ deviceEntity.setRecThd(configJson.getFloat("recognize_score"));
+ deviceEntity.setTemperatureAlert(configJson.getFloat("alert_temp_threshold"));
+ deviceEntity.setUploadImageFlag(configJson.getInteger("upload_pic_mode"));
+ deviceEntity.setStrangerFlag(configJson.getInteger("support_stranger"));
+
+ deviceEntity.setRecognizeScore3d(configJson.getString("recognize_score_3d"));
+ deviceEntity.setDetectionType(configJson.getInteger("detection_type"));
+
+ deviceEntity.setAppLanguage(jsonContent.getInteger("appLanguage"));
+
+ tenDeviceService.evictupdateById(deviceEntity);
+ return R.ok();
+ }
+
+
+
+ @PostMapping("/deletePerson")
+ @ApiOperation("设备端删除人员")
+ @ApiImplicitParams({
+ @ApiImplicitParam(name = "dev_id", value = "sn", paramType = "query", dataType = "String", required = true),
+ @ApiImplicitParam(name = "appKey", value = "appkey", paramType = "query", dataType = "String", required = true),
+ @ApiImplicitParam(name = "timestamp", value = "timestamp", paramType = "query", dataType = "String", required = true),
+ @ApiImplicitParam(name = "sign", value = "sign", paramType = "query", dataType = "String", required = true),
+ })
+ public R deletePerson(@RequestBody JSONObject jsonContent) {
+ String sn = jsonContent.getString("dev_id");
+ String appKey = jsonContent.getString("appKey");
+ String timestamp = jsonContent.getString("timestamp");
+ String sign = jsonContent.getString("sign");
+ //鉴权
+ R res = authService.auth(sn,appKey,timestamp,sign);
+ if((Integer) res.get("code") != 0){
+ return res;
+ }
+ log.debug("设备端删除人员:"+sn);
+ TenDeviceEntity deviceEntity = tenDeviceService.findBySn(sn);
+//----------------------------------------以下业务-----------------------------------------------------
+ JSONObject dataJson = jsonContent.getJSONObject("data");
+ Long uid = dataJson.getLong("uid");
+
+ Map personMap = new HashMap();
+ personMap.put("personId",uid+"");
+ personMap.put("cellId",deviceEntity.getCellId()+"");
+ List