From 1651e392ccff2e3118dd1713918d48b3b3f6c2ec Mon Sep 17 00:00:00 2001 From: gaoben Date: Wed, 20 Sep 2023 14:35:52 +0800 Subject: [PATCH] =?UTF-8?q?v8:http=E5=8D=8F=E8=AE=AE=EF=BC=8C=E7=BB=84?= =?UTF-8?q?=E7=BB=87=E7=BB=93=E6=9E=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pom.xml | 8 +- shapelight-admin/pom.xml | 27 +- .../shapelight/common/config/CorsConfig.java | 1 + .../shapelight/common/config/MinioUtils.java | 81 ++ .../shapelight/common/config/ShiroConfig.java | 2 + .../net/shapelight/common/utils/Constant.java | 1 + .../app/controller/AppApiController.java | 223 ++- .../app/controller/AppInfoApiController.java | 8 +- .../excel/listener/PersonExcelListener.java | 20 +- .../httpapi/controler/HttpApiController.java | 1221 +++++++++++++++++ .../modules/httpapi/service/AuthService.java | 72 + .../modules/job/utils/ScheduleJob.java | 4 +- .../sys/controller/SysDeviceController.java | 27 +- .../controller/SysDeviceLogController.java | 87 ++ .../modules/sys/dao/SysDeviceLogDao.java | 14 + .../sys/entity/SysDeviceLogEntity.java | 40 + .../sys/service/SysDeviceLogService.java | 17 + .../service/impl/SysDeviceLogServiceImpl.java | 35 + .../service/impl/SysDeviceServiceImpl.java | 9 +- .../sys/service/impl/SysUserServiceImpl.java | 23 + .../controller/SysTenUserController.java | 12 + .../ten/controller/TenCellDeptController.java | 272 ++++ .../ten/controller/TenCompanyController.java | 1 + .../controller/TenCompanyTypeController.java | 113 ++ .../ten/controller/TenDataViewController.java | 360 ++++- .../ten/controller/TenDeviceController.java | 27 +- .../TenDeviceOperateLogController.java | 87 ++ .../ten/controller/TenLabelController.java | 26 +- .../ten/controller/TenPersonController.java | 30 +- .../modules/ten/dao/TenCellDeptDao.java | 30 + .../modules/ten/dao/TenCompanyTypeDao.java | 14 + .../ten/dao/TenDeviceOperateLogDao.java | 14 + .../modules/ten/dao/TenLabelDao.java | 2 + .../modules/ten/dao/TenPersonDao.java | 18 + .../modules/ten/dao/TenRecordDao.java | 1 + .../modules/ten/dao/TenRoomDao.java | 8 + .../modules/ten/entity/TenCellDeptEntity.java | 118 ++ .../modules/ten/entity/TenCompanyEntity.java | 6 + .../ten/entity/TenCompanyTypeEntity.java | 61 + .../modules/ten/entity/TenDeviceEntity.java | 5 + .../ten/entity/TenDeviceOperateLogEntity.java | 41 + .../modules/ten/entity/TenPersonEntity.java | 14 + .../ten/service/TenCellDeptService.java | 29 + .../ten/service/TenCompanyService.java | 4 + .../ten/service/TenCompanyTypeService.java | 17 + .../service/TenDeviceOperateLogService.java | 17 + .../modules/ten/service/TenDeviceService.java | 2 + .../modules/ten/service/TenPersonService.java | 17 + .../modules/ten/service/TenRecordService.java | 2 + .../modules/ten/service/TenRoomService.java | 2 + .../service/impl/TenCellDeptServiceImpl.java | 70 + .../ten/service/impl/TenCellServiceImpl.java | 2 +- .../service/impl/TenCompanyServiceImpl.java | 43 + .../impl/TenCompanyTypeServiceImpl.java | 43 + .../impl/TenDeviceOperateLogServiceImpl.java | 42 + .../service/impl/TenDeviceServiceImpl.java | 69 +- .../service/impl/TenFeedbackServiceImpl.java | 29 + .../service/impl/TenPersonServiceImpl.java | 265 +++- .../service/impl/TenRecordServiceImpl.java | 50 + .../service/impl/TenRepairServiceImpl.java | 29 + .../ten/service/impl/TenRoomServiceImpl.java | 6 + .../net/shapelight/modules/vo/AppBuildVo.java | 31 + .../shapelight/modules/vo/AppPersonType.java | 13 + .../net/shapelight/modules/vo/AppRoomVo.java | 26 + .../modules/vo/TenCelldeptSelectVo.java | 44 + .../modules/vo/TenCelldeptWeVo.java | 44 + .../shapelight/modules/vo/TenPersonAllVo.java | 24 + .../modules/vo/TenPersonMonthCountVo.java | 11 + .../shapelight/modules/vo/TenRoomDeptVo.java | 16 + .../net/shapelight/modules/vo/TenUserVo.java | 10 + .../src/main/resources/application-dev.yml | 44 +- .../src/main/resources/application.yml | 4 +- .../main/resources/mapper/ten/TenAreaDao.xml | 1 + .../resources/mapper/ten/TenCellDeptDao.xml | 55 + .../resources/mapper/ten/TenPersonDao.xml | 258 +++- .../resources/mapper/ten/TenRecordDao.xml | 31 + .../main/resources/mapper/ten/TenRoomDao.xml | 33 + .../src/test/java/gb/BinTest.java | 61 + .../src/test/java/gb/PersonBatchAdd.java | 207 +++ version8.txt | 117 ++ 80 files changed, 4760 insertions(+), 188 deletions(-) create mode 100644 shapelight-admin/src/main/java/net/shapelight/common/config/MinioUtils.java create mode 100644 shapelight-admin/src/main/java/net/shapelight/modules/httpapi/controler/HttpApiController.java create mode 100644 shapelight-admin/src/main/java/net/shapelight/modules/httpapi/service/AuthService.java create mode 100644 shapelight-admin/src/main/java/net/shapelight/modules/sys/controller/SysDeviceLogController.java create mode 100644 shapelight-admin/src/main/java/net/shapelight/modules/sys/dao/SysDeviceLogDao.java create mode 100644 shapelight-admin/src/main/java/net/shapelight/modules/sys/entity/SysDeviceLogEntity.java create mode 100644 shapelight-admin/src/main/java/net/shapelight/modules/sys/service/SysDeviceLogService.java create mode 100644 shapelight-admin/src/main/java/net/shapelight/modules/sys/service/impl/SysDeviceLogServiceImpl.java create mode 100644 shapelight-admin/src/main/java/net/shapelight/modules/ten/controller/TenCellDeptController.java create mode 100644 shapelight-admin/src/main/java/net/shapelight/modules/ten/controller/TenCompanyTypeController.java create mode 100644 shapelight-admin/src/main/java/net/shapelight/modules/ten/controller/TenDeviceOperateLogController.java create mode 100644 shapelight-admin/src/main/java/net/shapelight/modules/ten/dao/TenCellDeptDao.java create mode 100644 shapelight-admin/src/main/java/net/shapelight/modules/ten/dao/TenCompanyTypeDao.java create mode 100644 shapelight-admin/src/main/java/net/shapelight/modules/ten/dao/TenDeviceOperateLogDao.java create mode 100644 shapelight-admin/src/main/java/net/shapelight/modules/ten/entity/TenCellDeptEntity.java create mode 100644 shapelight-admin/src/main/java/net/shapelight/modules/ten/entity/TenCompanyTypeEntity.java create mode 100644 shapelight-admin/src/main/java/net/shapelight/modules/ten/entity/TenDeviceOperateLogEntity.java create mode 100644 shapelight-admin/src/main/java/net/shapelight/modules/ten/service/TenCellDeptService.java create mode 100644 shapelight-admin/src/main/java/net/shapelight/modules/ten/service/TenCompanyTypeService.java create mode 100644 shapelight-admin/src/main/java/net/shapelight/modules/ten/service/TenDeviceOperateLogService.java create mode 100644 shapelight-admin/src/main/java/net/shapelight/modules/ten/service/impl/TenCellDeptServiceImpl.java create mode 100644 shapelight-admin/src/main/java/net/shapelight/modules/ten/service/impl/TenCompanyTypeServiceImpl.java create mode 100644 shapelight-admin/src/main/java/net/shapelight/modules/ten/service/impl/TenDeviceOperateLogServiceImpl.java create mode 100644 shapelight-admin/src/main/java/net/shapelight/modules/vo/AppBuildVo.java create mode 100644 shapelight-admin/src/main/java/net/shapelight/modules/vo/AppPersonType.java create mode 100644 shapelight-admin/src/main/java/net/shapelight/modules/vo/AppRoomVo.java create mode 100644 shapelight-admin/src/main/java/net/shapelight/modules/vo/TenCelldeptSelectVo.java create mode 100644 shapelight-admin/src/main/java/net/shapelight/modules/vo/TenCelldeptWeVo.java create mode 100644 shapelight-admin/src/main/java/net/shapelight/modules/vo/TenPersonAllVo.java create mode 100644 shapelight-admin/src/main/java/net/shapelight/modules/vo/TenPersonMonthCountVo.java create mode 100644 shapelight-admin/src/main/java/net/shapelight/modules/vo/TenRoomDeptVo.java create mode 100644 shapelight-admin/src/main/resources/mapper/ten/TenCellDeptDao.xml create mode 100644 shapelight-admin/src/test/java/gb/BinTest.java create mode 100644 shapelight-admin/src/test/java/gb/PersonBatchAdd.java create mode 100644 version8.txt 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> params = new ArrayList<>(); + params.add(personMap); + tenPersonService.removeByIdList(params); + return R.ok(); + } + + + + @PostMapping("/upRecord") + @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 upRecord(@RequestParam("jsonString") String jsonString, @RequestParam(value="recordImage",required = false) MultipartFile recordImage, @RequestParam(value = "sourceFile", required = false) MultipartFile sourceFile) { +// public R upRecord(@RequestBody JSONObject jsonContent) { + JSONObject jsonContent = JSONObject.parseObject(jsonString); + + 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 personId = dataJson.getLongValue("uid"); + Integer unlockMode = dataJson.getIntValue("unlock_mode"); + Long unlockTime = dataJson.getLongValue("unlock_time"); + unlockTime = unlockTime*1000; +// String captureFacePic = dataJson.getString("capture_face_pic"); + + TenRecordEntity record = new TenRecordEntity(); + record.setDeviceSn(sn); + record.setDeviceName(deviceEntity.getName()); + record.setCellId(deviceEntity.getCellId()); + record.setPersonId(personId); + record.setOpenType(unlockMode); + record.setRecordTime(new Date(unlockTime)); +// record.setRecordFaceStr(captureFacePic); + record.setTenantId(deviceEntity.getTenantId()); + + //------------------------------------3d------------------------------------ + String score3d = dataJson.getString("score"); +// String sourceFileStr = dataJson.getString("sourceFile"); + Integer duration = dataJson.getInteger("duration"); + String threshold = dataJson.getString("threshold"); + Float distance = dataJson.getFloat("distance"); + Float temperature = dataJson.getFloat("temperature"); + String cameraParam = dataJson.getString("cameraParam"); + + record.setScore3d(score3d); +// record.setSourceFileStr(sourceFileStr); + record.setDuration(duration); + record.setThreshold(threshold); + record.setDistance(distance); + record.setTemperature(temperature); + record.setCameraParam(cameraParam); + + try { + //保存图片 + if (recordImage !=null && !recordImage.isEmpty() && recordImage.getSize() > 0) { + String userFileUrl = globalValue.getImagesDir() + "/" + + record.getCellId().toString() + "/" + + record.getPersonId().toString() + "/"; + String fileName = userFileUrl + UUIDUtil.uuid() + ".jpg"; + InputStream inputStream = recordImage.getInputStream(); + PutObjectOptions putObjectOptions = new PutObjectOptions(inputStream.available(), -1); + putObjectOptions.setContentType(recordImage.getContentType()); + minioClient.putObject( + minioConfig.getBucketName(), fileName, inputStream, putObjectOptions); + inputStream.close(); + record.setRecordFace(fileName); + } + } catch (Exception e) { +// return R.error(e.getMessage()); + e.printStackTrace(); + log.error("保存2d照片失败。。。。。。。。。。。。。。。。。。。。。"); + } + + + try { + //保存sourceFiile + //保存图片 + if (sourceFile != null && !sourceFile.isEmpty() && sourceFile.getSize() > 0) { + String userFileUrl = globalValue.getImagesDir() + "/" + + record.getCellId().toString() + "/" + + record.getPersonId().toString() + "/"; + String fileName = userFileUrl + UUIDUtil.uuid() + ".zip"; + InputStream inputStream = sourceFile.getInputStream(); + PutObjectOptions putObjectOptions = new PutObjectOptions(inputStream.available(), -1); + putObjectOptions.setContentType(sourceFile.getContentType()); + minioClient.putObject( + minioConfig.getBucketName(), fileName, inputStream, putObjectOptions); + inputStream.close(); + record.setSourceFile(fileName); + } + + } catch (Exception e) { +// return R.error(e.getMessage()); + e.printStackTrace(); + log.error("保存3d文件失败。。。。。。。。。。。。。。。。。。。。。"); + } + +// log.info("保存记录:----------------------"+record.getRecordTime()+"-"+record.getMemberId().intValue()); + tenRecordService.saveForFace(record); + return R.ok(); + } + + + @PostMapping("/getVersion") + @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 getVersion(@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); + List appEntityList = sysDeviceAppService.list(new QueryWrapper() + .eq("device_type_id",sysDeviceEntity.getDeviceTypeId()) + .orderByDesc("version")); + JSONObject versionJson = new JSONObject(); + + int max = 0; + int index = 0; + if(appEntityList.size()>0){ + + for(int i = 0;imax){ + max = v; + index = i; + } + } + } + + SysDeviceAppEntity app = appEntityList.get(index); + versionJson.put("version",app.getVersion()); + versionJson.put("url",app.getUrl()); + } + return R.ok().put("data",versionJson); + } + + + @PostMapping("/addPerson") + @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 addPerson(@RequestParam("jsonString") String jsonString, @RequestParam("orgImage") MultipartFile orgImage, @RequestParam("sourceFile") MultipartFile sourceFile,@RequestParam("thdFeature") String thdFeature) { + JSONObject jsonContent = JSONObject.parseObject(jsonString); + 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 personJson = jsonContent.getJSONObject("data"); +// tenPerson.setCellId(personJson.getLong("cellId")); +// tenPerson.setRoomId(personJson.getLong("roomId")); +// tenPerson.setPersonType(personJson.getInteger("personType")); +// tenPerson.setName(personJson.getString("name")); +// tenPerson.setMobile(personJson.getString("mobile")); +// tenPerson.setIdCard(personJson.getString("idCard")); +// tenPerson.setGender(personJson.getInteger("gender")); + + TenPersonEntity tenPerson = JSONObject.toJavaObject(personJson,TenPersonEntity.class); + + tenPerson.setThdFeature(thdFeature); + + if(tenPerson.getIdCard()!=null){ + if(tenPerson.getIdCard().length() == 15){ + String id18 = Convert.toEighteen(tenPerson.getIdCard()); + tenPerson.setIdCard(id18); + } + } + +// 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.getDeptId()!=null){ + int c = tenPersonService.checkByIdCardDept(tenPerson.getIdCard(),tenPerson.getDeptId()); + if(c>0){ + return R.error("身份证在组织已存在"); + } + }else{ + int p = tenPersonService.checkByIdCardCell(tenPerson.getIdCard(),deviceEntity.getCellId()); + if(p>0){ + return R.error("身份证在小区已存在"); + } + } + +// if(tenPerson.getPersonType()!=Constant.PERSON_TYPE_PROPERTY){ +// int c = tenPersonService.checkByIdCardDept(tenPerson.getIdCard(),tenPerson.getDeptId()); +// if(c>0){ +// return R.error("身份证在组织已存在"); +// } +// }else{ +// int p = tenPersonService.checkByIdCardCell(tenPerson.getIdCard(),deviceEntity.getCellId()); +// if(p>0){ +// return R.error("身份证在小区已存在"); +// } +// } + + if (tenPerson.getRoomId()!=null) { + TenRoomEntity roomEntity = tenRoomService.getById(tenPerson.getRoomId(),tenPerson.getCellId()); + if(roomEntity!=null){ + tenPerson.setBuildId(roomEntity.getBuildId()); + } + } + + Date now = new Date(); + long id = new SnowflakeIdWorker().nextId(); + tenPerson.setPersonId(id); + tenPerson.setUuid(UUIDUtil.uuid()); + tenPerson.setTenantId(deviceEntity.getTenantId()); + tenPerson.setCreateBy(sn); + tenPerson.setRegisterType(Constant.RESGISTER_TYPE_Device); + tenPerson.setStatus(Constant.PESON_SUATUS_NOMOR); + tenPerson.setCreateTime(now); + tenPerson.setLastUpdateTime(now); + + tenPerson.setCellId(deviceEntity.getCellId()); + + if (orgImage.isEmpty() || orgImage.getSize() == 0 || sourceFile.isEmpty() || sourceFile.getSize() == 0) { + return R.error("文件不能为空"); + } + try { + //保存原始图片 + String userFileUrl = globalValue.getImagesDir() + "/" + + tenPerson.getCellId().toString() + "/" + + tenPerson.getPersonId().toString() + "/"; + String orgImageFileName = userFileUrl + "o_" + UUIDUtil.uuid() + ".jpg"; + + InputStream inputStream = orgImage.getInputStream(); + PutObjectOptions putObjectOptions = new PutObjectOptions(inputStream.available(), -1); + putObjectOptions.setContentType(orgImage.getContentType()); + minioClient.putObject( + minioConfig.getBucketName(), orgImageFileName, inputStream, putObjectOptions); + inputStream.close(); + + tenPerson.setOrgImage(orgImageFileName); + tenPerson.setFaceImage(orgImageFileName); + + } catch (Exception e) { + return R.error(e.getMessage()); + } + + + try { + //保存sourceFiile + String userFileUrl = globalValue.getImagesDir() + "/" + + tenPerson.getCellId().toString() + "/" + + tenPerson.getPersonId().toString() + "/"; + String sourceFileName = userFileUrl + "p_" + UUIDUtil.uuid() + ".zip"; + + InputStream inputStream = sourceFile.getInputStream(); + PutObjectOptions putObjectOptions = new PutObjectOptions(inputStream.available(), -1); + putObjectOptions.setContentType(sourceFile.getContentType()); + minioClient.putObject( + minioConfig.getBucketName(), sourceFileName, inputStream, putObjectOptions); + inputStream.close(); + + tenPerson.setSourceFile(sourceFileName); + + } catch (Exception e) { + return R.error(e.getMessage()); + } + //处理类型: + //1. 不是固定类型,给一个默认的家属类型 + if(tenPerson.getPersonType()>10000){ + tenPerson.setLabelId(tenPerson.getPersonType()); + tenPerson.setPersonType(Constant.PERSON_TYPE_MEMBER);// + } else if (tenPerson.getPersonType() == Constant.PERSON_TYPE_OWNER + || tenPerson.getPersonType() == Constant.PERSON_TYPE_TENANT + || tenPerson.getPersonType() == Constant.PERSON_TYPE_MEMBER) { + TenLabelEntity labelEntity = tenLabelService.getOne(new QueryWrapper() + .eq("type",tenPerson.getPersonType()) + .eq("tenant_id",deviceEntity.getTenantId())); + if(labelEntity!=null){ + tenPerson.setLabelId(labelEntity.getLabelId().intValue()); + } + } + int resSave = tenPersonService.save3d(tenPerson); + if (resSave==1) { + return R.error("添加失败"); + } + JSONObject personRes = new JSONObject(); + personRes.put("uid",tenPerson.getPersonId()); + personRes.put("last_update_stamp",DateUtils.format(tenPerson.getLastUpdateTime(),DateUtils.DATE_TIME_PATTERN)); + return R.ok().put("data",personRes); + + } + + + + @PostMapping("/upAppLog") + @ApiOperation("设备上传applog") + @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 upAppLog(@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("设备发送系统log:"+sn); + TenDeviceEntity deviceEntity = tenDeviceService.findBySn(sn); +//----------------------------------------以下业务----------------------------------------------------- + SysDeviceEntity sysDeviceEntity = sysDeviceService.getBySn(sn); + + JSONObject data = jsonContent.getJSONObject("data"); + + SysDeviceLogEntity logEntity = new SysDeviceLogEntity(); + logEntity.setCreateTime(data.getDate("createTime")); + logEntity.setLog(data.getString("log")); + logEntity.setSn(sn); + + sysDeviceLogService.save(logEntity); + + return R.ok(); + } + + + @PostMapping("/upOperateLog") + @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 upOperateLog(@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("设备发送系统log:"+sn); + TenDeviceEntity deviceEntity = tenDeviceService.findBySn(sn); +//----------------------------------------以下业务----------------------------------------------------- + SysDeviceEntity sysDeviceEntity = sysDeviceService.getBySn(sn); + + JSONObject data = jsonContent.getJSONObject("data"); + + TenDeviceOperateLogEntity logEntity = new TenDeviceOperateLogEntity(); + logEntity.setCreateTime(data.getDate("createTime")); + logEntity.setOperation(data.getString("operation")); + logEntity.setSn(sn); + logEntity.setTenantId(deviceEntity.getTenantId()); + + tenDeviceOperateLogService.save(logEntity); + + return R.ok(); + } + + + + + @PostMapping("/getDeptInfo") + @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 getDeptInfo(@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()); + + JSONObject cellJson = new JSONObject(); + cellJson.put("cellId",cell.getCellId()); + cellJson.put("name",cell.getName()); + + List areaList = tenCellDeptService.list(new QueryWrapper() + .eq("cell_id",deviceEntity.getCellId())); + + List areaSelectList = new ArrayList<>(); + 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"); + cellJson.put("deptTree",areaTree); + + //-------------------------------------------------------------- + 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 personType5005 = new AppPersonType(); +// personType5005.setPersonType(Constant.PERSON_TYPE_GUEST); +// personType5005.setTypeName("访客"); +// personTypeList.add(personType5005); +// +// AppPersonType personType5006 = new AppPersonType(); +// personType5006.setPersonType(Constant.PERSON_TYPE_PROPERTY); +// personType5006.setTypeName("物业"); +// personTypeList.add(personType5006); + + List tenLabel = tenLabelService.list(new QueryWrapper() + .eq("tenant_id",deviceEntity.getTenantId())); + + Iterator it = tenLabel.iterator(); + while(it.hasNext()){ + TenLabelEntity label = it.next(); + if(label.getType() == Constant.PERSON_TYPE_OWNER + || label.getType() == Constant.PERSON_TYPE_MEMBER + || label.getType() == Constant.PERSON_TYPE_TENANT + || label.getType() == Constant.PERSON_TYPE_GUEST + || label.getType() == Constant.PERSON_TYPE_PROPERTY){ + it.remove(); + } + } + + for(TenLabelEntity labelEntity: tenLabel){ + AppPersonType lable = new AppPersonType(); + lable.setLabelId(labelEntity.getLabelId()); + lable.setPersonType(labelEntity.getType()); + lable.setTypeName(labelEntity.getName()); + personTypeList.add(lable); + } + + cellJson.put("personType",personTypeList); + + //删除状态为删除的人员 + return R.ok().put("data",cellJson); + } + + + + @PostMapping("/upGps") + @ApiOperation("设备上传GPS") + @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 upGps(@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("设备发送GPS:"+sn); + TenDeviceEntity deviceEntity = tenDeviceService.findBySn(sn); +//----------------------------------------以下业务----------------------------------------------------- + + JSONObject data = jsonContent.getJSONObject("data"); + deviceEntity.setLat(data.getString("lat")); + deviceEntity.setLon(data.getString("lon")); + + tenDeviceService.evictupdateById(deviceEntity); + + return R.ok(); + } +} diff --git a/shapelight-admin/src/main/java/net/shapelight/modules/httpapi/service/AuthService.java b/shapelight-admin/src/main/java/net/shapelight/modules/httpapi/service/AuthService.java new file mode 100644 index 0000000..b84b294 --- /dev/null +++ b/shapelight-admin/src/main/java/net/shapelight/modules/httpapi/service/AuthService.java @@ -0,0 +1,72 @@ +package net.shapelight.modules.httpapi.service; + +import com.alibaba.fastjson.JSONObject; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import lombok.extern.slf4j.Slf4j; +import net.shapelight.common.config.GlobalValue; +import net.shapelight.common.utils.MD5Utils; +import net.shapelight.common.utils.R; +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.SysDeviceEntity; +import net.shapelight.modules.sys.service.SysDeviceService; +import net.shapelight.modules.ten.entity.TenDeviceEntity; +import net.shapelight.modules.ten.service.TenDeviceService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +@Slf4j +@Service("authService") +public class AuthService { + @Autowired + private SysDeviceService sysDeviceService; + @Autowired + private TenDeviceService tenDeviceService; + @Autowired + private GlobalValue globalValue; + + + + + public R auth(String sn, String appKey, String timestamp, String sign){ + + String gAppKey = globalValue.getDevAppId(); + String gAppSecret = globalValue.getDevAppSecret(); + + //设备sn不能为空 + if (sn == null || sn.isEmpty()) { + R res = R.error(201, "Device Is Not Bind"); + return res; + } + + if(appKey==null || appKey.length()==0 + || !gAppKey.equals(appKey)){ + R res = R.error(203, "App key Error"); + return res; + } + + String mySign = MD5Utils.getMD5Str(sn+appKey+gAppSecret+timestamp); + if(!mySign.equalsIgnoreCase(sign)){ + R res = R.error(201, "Sign error"); + return res; + } + + SysDeviceEntity sysDeviceEntity = sysDeviceService.getBySn(sn); + if(sysDeviceEntity == null){ + return R.error(201, "Device Is Not Bind"); + } + if(sysDeviceEntity.getState() == 0){ + return R.error(202, "Device Is Stop"); + } + + //1.判断sn是否存在 设备不存在1002 + TenDeviceEntity deviceEntity = tenDeviceService.findBySn(sn); + if(deviceEntity == null){ + return R.error(201, "Device Is Not Bind"); + } + + + return R.ok(); + } +} diff --git a/shapelight-admin/src/main/java/net/shapelight/modules/job/utils/ScheduleJob.java b/shapelight-admin/src/main/java/net/shapelight/modules/job/utils/ScheduleJob.java index fc85c04..eda87da 100644 --- a/shapelight-admin/src/main/java/net/shapelight/modules/job/utils/ScheduleJob.java +++ b/shapelight-admin/src/main/java/net/shapelight/modules/job/utils/ScheduleJob.java @@ -68,8 +68,10 @@ public class ScheduleJob extends QuartzJobBean { //任务状态 0:成功 1:失败 log.setStatus(1); log.setError(StringUtils.substring(e.toString(), 0, 2000)); - }finally { + scheduleJobLogService.save(log); + }finally { +// scheduleJobLogService.save(log); } } } diff --git a/shapelight-admin/src/main/java/net/shapelight/modules/sys/controller/SysDeviceController.java b/shapelight-admin/src/main/java/net/shapelight/modules/sys/controller/SysDeviceController.java index 2d5e679..e6475f0 100644 --- a/shapelight-admin/src/main/java/net/shapelight/modules/sys/controller/SysDeviceController.java +++ b/shapelight-admin/src/main/java/net/shapelight/modules/sys/controller/SysDeviceController.java @@ -9,6 +9,7 @@ import io.swagger.annotations.Api; import io.swagger.annotations.ApiImplicitParam; import io.swagger.annotations.ApiImplicitParams; import io.swagger.annotations.ApiOperation; +import net.shapelight.common.utils.RedisUtils; import net.shapelight.common.utils.StringUtils; import net.shapelight.modules.nettyapi.service.ServerApiService; import net.shapelight.modules.sys.entity.SysDeviceEntity; @@ -40,6 +41,8 @@ public class SysDeviceController { @Autowired private TenDeviceService tenDeviceService; + @Autowired + private RedisUtils redisUtils; /** @@ -102,6 +105,7 @@ public class SysDeviceController { @RequiresPermissions("sys:device") @ApiOperation(value = "修改") public R update(@RequestBody SysDeviceEntity sysDevice){ + redisUtils.removePattern("SysDevice:*"); sysDevice.setSn(sysDevice.getSn().trim()); sysDeviceService.updateById(sysDevice); return R.ok(); @@ -114,16 +118,18 @@ public class SysDeviceController { @RequiresPermissions("sys:device") @ApiOperation(value = "修改") public R stop(@RequestBody SysDeviceEntity sysDevice){ - if(sysDevice.getState().intValue() == 0){ - int flag = serverApiService.stopDevice(sysDevice.getSn()); - if(flag == -1){ - return R.error("设备不在线"); - }else { - sysDeviceService.updateById(sysDevice); - } - }else{ - sysDeviceService.updateById(sysDevice); - } + redisUtils.removePattern("SysDevice:*"); +// if(sysDevice.getState().intValue() == 0){ +// int flag = serverApiService.stopDevice(sysDevice.getSn()); +// if(flag == -1){ +// return R.error("设备不在线"); +// }else { +// sysDeviceService.updateById(sysDevice); +// } +// }else{ +// sysDeviceService.updateById(sysDevice); +// } + sysDeviceService.updateById(sysDevice); return R.ok(); } @@ -137,6 +143,7 @@ public class SysDeviceController { @RequiresPermissions("sys:device") @ApiOperation(value = "删除") public R delete(@RequestBody Long[] deviceIds){ + redisUtils.removePattern("SysDevice:*"); for(Long devId: deviceIds) { SysDeviceEntity sysDeviceEntity = sysDeviceService.getById(devId); TenDeviceEntity tenDeviceEntity = tenDeviceService.findBySn(sysDeviceEntity.getSn()); diff --git a/shapelight-admin/src/main/java/net/shapelight/modules/sys/controller/SysDeviceLogController.java b/shapelight-admin/src/main/java/net/shapelight/modules/sys/controller/SysDeviceLogController.java new file mode 100644 index 0000000..66ea65a --- /dev/null +++ b/shapelight-admin/src/main/java/net/shapelight/modules/sys/controller/SysDeviceLogController.java @@ -0,0 +1,87 @@ +package net.shapelight.modules.sys.controller; + +import java.util.Arrays; +import java.util.Map; + +import net.shapelight.modules.sys.entity.SysDeviceLogEntity; +import net.shapelight.modules.sys.service.SysDeviceLogService; +import org.apache.shiro.authz.annotation.RequiresPermissions; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; + +import net.shapelight.common.utils.PageUtils; +import net.shapelight.common.utils.R; + + + +/** + * + * + */ +@RestController +@RequestMapping("sys/devicelog") +public class SysDeviceLogController { + @Autowired + private SysDeviceLogService sysDeviceLogService; + + /** + * 列表 + */ + @RequestMapping("/list") + @RequiresPermissions("sys:devicelog") + public R list(@RequestParam Map params){ + PageUtils page = sysDeviceLogService.queryPage(params); + + return R.ok().put("data", page); + } + + + /** + * 信息 + */ + @RequestMapping("/info/{logId}") + @RequiresPermissions("sys:devicelog") + public R info(@PathVariable("logId") Long logId){ + SysDeviceLogEntity sysDeviceLog = sysDeviceLogService.getById(logId); + + return R.ok().put("data", sysDeviceLog); + } +// +// /** +// * 保存 +// */ +// @RequestMapping("/save") +// @RequiresPermissions("sys:devicelog:save") +// public R save(@RequestBody SysDeviceLogEntity sysDeviceLog){ +// sysDeviceLogService.save(sysDeviceLog); +// +// return R.ok(); +// } +// +// /** +// * 修改 +// */ +// @RequestMapping("/update") +// @RequiresPermissions("sys:devicelog:update") +// public R update(@RequestBody SysDeviceLogEntity sysDeviceLog){ +// sysDeviceLogService.updateById(sysDeviceLog); +// +// return R.ok(); +// } +// +// /** +// * 删除 +// */ +// @RequestMapping("/delete") +// @RequiresPermissions("sys:devicelog:delete") +// public R delete(@RequestBody Long[] logIds){ +// sysDeviceLogService.removeByIds(Arrays.asList(logIds)); +// +// return R.ok(); +// } + +} diff --git a/shapelight-admin/src/main/java/net/shapelight/modules/sys/dao/SysDeviceLogDao.java b/shapelight-admin/src/main/java/net/shapelight/modules/sys/dao/SysDeviceLogDao.java new file mode 100644 index 0000000..725981e --- /dev/null +++ b/shapelight-admin/src/main/java/net/shapelight/modules/sys/dao/SysDeviceLogDao.java @@ -0,0 +1,14 @@ +package net.shapelight.modules.sys.dao; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import net.shapelight.modules.sys.entity.SysDeviceLogEntity; +import org.apache.ibatis.annotations.Mapper; + +/** + * + * + */ +@Mapper +public interface SysDeviceLogDao extends BaseMapper { + +} diff --git a/shapelight-admin/src/main/java/net/shapelight/modules/sys/entity/SysDeviceLogEntity.java b/shapelight-admin/src/main/java/net/shapelight/modules/sys/entity/SysDeviceLogEntity.java new file mode 100644 index 0000000..58a4482 --- /dev/null +++ b/shapelight-admin/src/main/java/net/shapelight/modules/sys/entity/SysDeviceLogEntity.java @@ -0,0 +1,40 @@ +package net.shapelight.modules.sys.entity; + +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; + +import java.io.Serializable; +import java.util.Date; + +import com.fasterxml.jackson.annotation.JsonFormat; +import lombok.Data; + +/** + * + * + */ +@Data +@TableName("sys_device_log") +public class SysDeviceLogEntity implements Serializable { + private static final long serialVersionUID = 1L; + + /** + * id + */ + @TableId + private Long logId; + /** + * + */ + private String sn; + /** + * + */ + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") + private Date createTime; + /** + * + */ + private String log; + +} diff --git a/shapelight-admin/src/main/java/net/shapelight/modules/sys/service/SysDeviceLogService.java b/shapelight-admin/src/main/java/net/shapelight/modules/sys/service/SysDeviceLogService.java new file mode 100644 index 0000000..4e4265e --- /dev/null +++ b/shapelight-admin/src/main/java/net/shapelight/modules/sys/service/SysDeviceLogService.java @@ -0,0 +1,17 @@ +package net.shapelight.modules.sys.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import net.shapelight.common.utils.PageUtils; +import net.shapelight.modules.sys.entity.SysDeviceLogEntity; + +import java.util.Map; + +/** + * + * + */ +public interface SysDeviceLogService extends IService { + + PageUtils queryPage(Map params); +} + diff --git a/shapelight-admin/src/main/java/net/shapelight/modules/sys/service/impl/SysDeviceLogServiceImpl.java b/shapelight-admin/src/main/java/net/shapelight/modules/sys/service/impl/SysDeviceLogServiceImpl.java new file mode 100644 index 0000000..dd737c5 --- /dev/null +++ b/shapelight-admin/src/main/java/net/shapelight/modules/sys/service/impl/SysDeviceLogServiceImpl.java @@ -0,0 +1,35 @@ +package net.shapelight.modules.sys.service.impl; + +import net.shapelight.common.utils.StringUtils; +import net.shapelight.modules.sys.dao.SysDeviceLogDao; +import net.shapelight.modules.sys.entity.SysDeviceLogEntity; +import net.shapelight.modules.sys.service.SysDeviceLogService; +import org.springframework.stereotype.Service; +import java.util.Map; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import net.shapelight.common.utils.PageUtils; +import net.shapelight.common.utils.Query; + +@Service("sysDeviceLogService") +public class SysDeviceLogServiceImpl extends ServiceImpl implements SysDeviceLogService { + + @Override + public PageUtils queryPage(Map params) { + String sn = (String)params.get("sn"); + String recordTimeStart = (String)params.get("recordTimeStart"); + String recordTimeEnd = (String)params.get("recordTimeEnd"); + IPage page = this.page( + new Query().getPage(params), + new QueryWrapper() + .like(!StringUtils.isNullOrEmpty(params.get("sn")),"sn",params.get("sn")) + .ge(!StringUtils.isNullOrEmpty(params.get("recordTimeStart")),"create_time",recordTimeStart) + .le(!StringUtils.isNullOrEmpty(params.get("recordTimeEnd")),"create_time",recordTimeEnd) + .orderByDesc("create_time") + ); + + return new PageUtils(page); + } + +} \ No newline at end of file diff --git a/shapelight-admin/src/main/java/net/shapelight/modules/sys/service/impl/SysDeviceServiceImpl.java b/shapelight-admin/src/main/java/net/shapelight/modules/sys/service/impl/SysDeviceServiceImpl.java index 3392cee..de60a1b 100644 --- a/shapelight-admin/src/main/java/net/shapelight/modules/sys/service/impl/SysDeviceServiceImpl.java +++ b/shapelight-admin/src/main/java/net/shapelight/modules/sys/service/impl/SysDeviceServiceImpl.java @@ -40,6 +40,8 @@ public class SysDeviceServiceImpl extends ServiceImpl params) { @@ -65,7 +67,12 @@ public class SysDeviceServiceImpl extends ServiceImpl i private AppUserScopeService appUserScopeService; @Autowired private TenCellService tenCellService; + @Autowired + private TenLabelService tenLabelService; @Override public List queryAllPerms(Long userId) { @@ -260,6 +264,25 @@ public class SysUserServiceImpl extends ServiceImpl i String tempDir = globalValue.getStaticLocations() + "/temp"; FileUtils.forceMkdir(new File(userDir)); FileUtils.forceMkdir(new File(tempDir)); + //保存标签 + TenLabelEntity labelEntity = new TenLabelEntity(); + labelEntity.setTenantId(user.getTenantId()); + labelEntity.setType(5000); + labelEntity.setName("业主"); + tenLabelService.save(labelEntity); + + TenLabelEntity lable2 = new TenLabelEntity(); + lable2.setTenantId(user.getTenantId()); + lable2.setType(5001); + lable2.setName("家属"); + tenLabelService.save(lable2); + + TenLabelEntity lable3 = new TenLabelEntity(); + lable3.setTenantId(user.getTenantId()); + lable3.setType(5002); + lable3.setName("租户"); + tenLabelService.save(lable3); + } catch (Exception e) { throw new RRException(e.getMessage()); } diff --git a/shapelight-admin/src/main/java/net/shapelight/modules/systen/controller/SysTenUserController.java b/shapelight-admin/src/main/java/net/shapelight/modules/systen/controller/SysTenUserController.java index 135beaa..45f66ad 100644 --- a/shapelight-admin/src/main/java/net/shapelight/modules/systen/controller/SysTenUserController.java +++ b/shapelight-admin/src/main/java/net/shapelight/modules/systen/controller/SysTenUserController.java @@ -26,6 +26,8 @@ import net.shapelight.modules.sys.service.SysRoleService; import net.shapelight.modules.sys.service.SysUserRoleService; import net.shapelight.modules.sys.service.SysUserService; //import net.shapelight.modules.systen.service.SysTenUserRoleService; +import net.shapelight.modules.ten.entity.TenDeviceEntity; +import net.shapelight.modules.ten.service.TenDeviceService; import org.apache.commons.lang.ArrayUtils; import org.apache.shiro.authz.annotation.RequiresPermissions; import org.apache.shiro.crypto.hash.Sha256Hash; @@ -51,6 +53,8 @@ public class SysTenUserController extends AbstractController { @Autowired private SysRoleService sysRoleService; + @Autowired + private TenDeviceService tenDeviceService; /** * 所有企业用户列表 @@ -149,6 +153,14 @@ public class SysTenUserController extends AbstractController { } sysUserService.removeByIds(Arrays.asList(userIds)); + List ids = new ArrayList<>(); + //删除运营商下所有设备 + List devList = tenDeviceService.list(new QueryWrapper() + .eq("tenant_id",userIds[0])); + for(TenDeviceEntity entity: devList){ + ids.add(entity.getDeviceId()); + } + tenDeviceService.evictRemoveByIds(ids); return R.ok(); } diff --git a/shapelight-admin/src/main/java/net/shapelight/modules/ten/controller/TenCellDeptController.java b/shapelight-admin/src/main/java/net/shapelight/modules/ten/controller/TenCellDeptController.java new file mode 100644 index 0000000..8197d86 --- /dev/null +++ b/shapelight-admin/src/main/java/net/shapelight/modules/ten/controller/TenCellDeptController.java @@ -0,0 +1,272 @@ +package net.shapelight.modules.ten.controller; + +import java.util.*; + +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONArray; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import io.swagger.annotations.ApiOperation; +import net.shapelight.common.utils.Constant; +import net.shapelight.common.utils.TreeUtils; +import net.shapelight.modules.sys.controller.AbstractController; +import net.shapelight.modules.ten.entity.TenCellEntity; +import net.shapelight.modules.ten.service.TenCellService; +import net.shapelight.modules.ten.service.TenPersonService; +import net.shapelight.modules.vo.TenAreaSelectVo; +import net.shapelight.modules.vo.TenCelldeptSelectVo; +import org.apache.shiro.authz.annotation.RequiresPermissions; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +import net.shapelight.modules.ten.entity.TenCellDeptEntity; +import net.shapelight.modules.ten.service.TenCellDeptService; +import net.shapelight.common.utils.PageUtils; +import net.shapelight.common.utils.R; + + + +/** + * + * + */ +@RestController +@RequestMapping("ten/celldept") +public class TenCellDeptController extends AbstractController { + @Autowired + private TenCellDeptService tenCellDeptService; + @Autowired + private TenCellService tenCellService; + @Autowired + private TenPersonService tenPersonService; + + /** + * 列表 + */ + @GetMapping("/list") + @RequiresPermissions("ten:celldept") + public R list(@RequestParam Map params){ + String cellId = (String)params.get("cellId"); +// PageUtils page = tenCellDeptService.queryPage(params); + List page = tenCellDeptService.list(new QueryWrapper() + .eq("cell_id",cellId)); + for(TenCellDeptEntity cellDeptEntity: page){ + if(cellDeptEntity.getChildrenList().size() == 0){ + cellDeptEntity.setHasChildren(false); + } + } +// for(TenCellDeptEntity entity: page){ +// if(entity.getDeptId()!=null){ +// int count = tenPersonService.getDeptPersonCount(entity.getDeptId()); +// entity.setPersonCount(count); +// } +// } + + JSONArray dataTree = TreeUtils.listToTree(JSONArray.parseArray(JSON.toJSONString(page)),"deptId","parentId","childrenList"); + +// return R.ok().put("data", menuTree).put("menuList",menuList); + + return R.ok().put("data", dataTree); + } + + + /** + * 信息 + */ + @GetMapping("/info/{deptId}") + @RequiresPermissions("ten:celldept") + public R info(@PathVariable("deptId") Long deptId){ + TenCellDeptEntity tenCellDept = tenCellDeptService.getById(deptId); + TenCellDeptEntity parent = tenCellDeptService.getById(tenCellDept.getParentId()); + if(tenCellDept.getParentId().longValue() == tenCellDept.getCellId().longValue()){ + String cellName = tenCellService.getCellName(tenCellDept.getCellId()+""); + tenCellDept.setParentName(cellName); + }else if(parent!=null){ + tenCellDept.setParentName(parent.getName()); + } + + return R.ok().put("data", tenCellDept); + } + + /** + * 保存 + */ + @PostMapping("/save") + @RequiresPermissions("ten:celldept") + public R save(@RequestBody TenCellDeptEntity tenCellDept){ + String deptAllName = tenCellDeptService.getAllParentName(tenCellDept.getParentId()); + if(deptAllName!=null){ + String dArray[] = deptAllName.split("/"); + if(dArray.length>5){ + return R.error("组织结构最多6层"); + } + } + tenCellDept.setCreateBy(getUser().getUsername()); + tenCellDept.setTenantId(getUser().getTenantId()); + tenCellDeptService.save(tenCellDept); + + return R.ok(); + } + + /** + * 修改 + */ + @PostMapping("/update") + @RequiresPermissions("ten:celldept") + public R update(@RequestBody TenCellDeptEntity tenCellDept){ + tenCellDept.setLastUpdateBy(getUser().getUsername()); + tenCellDept.setLastUpdateTime(new Date()); + if(tenCellDept.getDeptId().longValue() == tenCellDept.getParentId().longValue()){ + return R.error("上级不能为自己!"); + } + tenCellDeptService.updateById(tenCellDept); + + return R.ok(); + } + + /** + * 删除 + */ + @PostMapping("/delete") + @RequiresPermissions("ten:celldept") + public R delete(@RequestBody Long[] deptIds){ + //判断是否有子部门 + List areaList = tenCellDeptService.getSubDeptIdList(deptIds[0]); + if(areaList.size() > 0){ + return R.error("请先删除子部门"); + }else{ + //判断是否有已经过添加小区 + + } + tenCellDeptService.removeByIds(Arrays.asList(deptIds)); + + return R.ok(); + } + + + + /** + * 选择区域(添加、修改菜单) + */ + @GetMapping("/selectParent/{cellId}") + @ApiOperation("选择区域,只在添加区域时调用,作为父级区域") + public R selectParent(@PathVariable("cellId") String cellId){ + if(cellId.equals("null")){ + return R.ok().put("data", null); + } + Long cellIdLong = Long.parseLong(cellId); + 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(cellIdLong); + 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", areaTree); + } + + + + + /** + * 选择区域(添加、修改菜单) + */ + @GetMapping("/selectSub/{cellId}") + @ApiOperation("添加人员选择框") + public R selectSub(@PathVariable("cellId") Long cellId){ + 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){ + 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", areaTree); + } + + + + /** + * 列表 + */ + @GetMapping("/listRoot") + @RequiresPermissions("ten:celldept") + public R listRoot(@RequestParam Map params){ + String cellId = (String)params.get("cellId"); +// PageUtils page = tenCellDeptService.queryPage(params); + List page = tenCellDeptService.list(new QueryWrapper() + .eq("parent_id",cellId)); + for(TenCellDeptEntity cellDeptEntity: page){ + int count = tenCellDeptService.count(new QueryWrapper() + .eq("parent_id",cellDeptEntity.getDeptId())); + if(count > 0){ + cellDeptEntity.setHasChildren(true); + }else{ + cellDeptEntity.setHasChildren(false); + } + } + + return R.ok().put("data", page); + } + + + /** + * 列表 + */ + @GetMapping("/listSub") + @RequiresPermissions("ten:celldept") + public R listSub(@RequestParam Map params){ + String parentId = (String)params.get("deptId"); + List page = tenCellDeptService.list(new QueryWrapper() + .eq("parent_id",parentId)); + for(TenCellDeptEntity cellDeptEntity: page){ + int count = tenCellDeptService.count(new QueryWrapper() + .eq("parent_id",cellDeptEntity.getDeptId())); + if(count > 0){ + cellDeptEntity.setHasChildren(true); + }else{ + cellDeptEntity.setHasChildren(false); + } + } + + return R.ok().put("data", page); + } + +} diff --git a/shapelight-admin/src/main/java/net/shapelight/modules/ten/controller/TenCompanyController.java b/shapelight-admin/src/main/java/net/shapelight/modules/ten/controller/TenCompanyController.java index 3bd99ed..ab77a82 100644 --- a/shapelight-admin/src/main/java/net/shapelight/modules/ten/controller/TenCompanyController.java +++ b/shapelight-admin/src/main/java/net/shapelight/modules/ten/controller/TenCompanyController.java @@ -85,6 +85,7 @@ public class TenCompanyController extends AbstractController { @RequiresPermissions("ten:company") @ApiOperation(value = "保存信息") public R save(@RequestBody TenCompanyEntity tenCompany){ + tenCompany.setTenantId(getUser().getTenantId()); tenCompanyService.save(tenCompany); return R.ok(); } diff --git a/shapelight-admin/src/main/java/net/shapelight/modules/ten/controller/TenCompanyTypeController.java b/shapelight-admin/src/main/java/net/shapelight/modules/ten/controller/TenCompanyTypeController.java new file mode 100644 index 0000000..704f872 --- /dev/null +++ b/shapelight-admin/src/main/java/net/shapelight/modules/ten/controller/TenCompanyTypeController.java @@ -0,0 +1,113 @@ +package net.shapelight.modules.ten.controller; + +import java.util.Arrays; +import java.util.Date; +import java.util.List; +import java.util.Map; + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import net.shapelight.modules.sys.controller.AbstractController; +import net.shapelight.modules.ten.entity.TenCompanyEntity; +import net.shapelight.modules.ten.service.TenCompanyService; +import org.apache.shiro.authz.annotation.RequiresPermissions; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +import net.shapelight.modules.ten.entity.TenCompanyTypeEntity; +import net.shapelight.modules.ten.service.TenCompanyTypeService; +import net.shapelight.common.utils.PageUtils; +import net.shapelight.common.utils.R; + +import javax.xml.crypto.Data; + + +/** + * 标签 + * + */ +@RestController +@RequestMapping("ten/companytype") +public class TenCompanyTypeController extends AbstractController { + @Autowired + private TenCompanyTypeService tenCompanyTypeService; + @Autowired + private TenCompanyService tenCompanyService; + + /** + * 列表 + */ + @GetMapping("/list") + @RequiresPermissions("ten:companytype") + public R list(@RequestParam Map params){ + String tenantId = getUser().getTenantId()+""; + params.put("tenantId",tenantId+""); + PageUtils page = tenCompanyTypeService.queryPage(params); + + return R.ok().put("data", page); + } + + + /** + * 信息 + */ + @GetMapping("/info/{typeId}") + @RequiresPermissions("ten:companytype") + public R info(@PathVariable("typeId") Long typeId){ + TenCompanyTypeEntity tenCompanyType = tenCompanyTypeService.getById(typeId); + + return R.ok().put("data", tenCompanyType); + } + + /** + * 保存 + */ + @PostMapping("/save") + @RequiresPermissions("ten:companytype") + public R save(@RequestBody TenCompanyTypeEntity tenCompanyType){ + tenCompanyType.setTenantId(getUser().getTenantId()); + tenCompanyType.setCreateBy(getUser().getUsername()); + tenCompanyType.setCreateTime(new Date()); + tenCompanyTypeService.save(tenCompanyType); + + return R.ok(); + } + + /** + * 修改 + */ + @PostMapping("/update") + @RequiresPermissions("ten:companytype") + public R update(@RequestBody TenCompanyTypeEntity tenCompanyType){ + tenCompanyType.setLastUpdateBy(getUser().getUsername()); + tenCompanyType.setLastUpdateTime(new Date()); + tenCompanyTypeService.updateById(tenCompanyType); + + return R.ok(); + } + + /** + * 删除 + */ + @PostMapping("/delete") + @RequiresPermissions("ten:companytype") + public R delete(@RequestBody Long[] typeIds){ + Long typeId = typeIds[0]; + int c = tenCompanyService.count(new QueryWrapper() + .eq("tenant_id",getUser().getTenantId()) + .eq("type_id",typeId)); + if(c>0){ + return R.error("当前类别已使用"); + } + tenCompanyTypeService.removeByIds(Arrays.asList(typeIds)); + + return R.ok(); + } + + @GetMapping("/select") + public R select(){ + List page = tenCompanyTypeService.list(new QueryWrapper() + .eq("tenant_id",getUser().getTenantId())); + return R.ok().put("data", page); + } + +} diff --git a/shapelight-admin/src/main/java/net/shapelight/modules/ten/controller/TenDataViewController.java b/shapelight-admin/src/main/java/net/shapelight/modules/ten/controller/TenDataViewController.java index 1ad8205..8a07594 100644 --- a/shapelight-admin/src/main/java/net/shapelight/modules/ten/controller/TenDataViewController.java +++ b/shapelight-admin/src/main/java/net/shapelight/modules/ten/controller/TenDataViewController.java @@ -5,16 +5,15 @@ import io.swagger.annotations.Api; import io.swagger.annotations.ApiImplicitParam; import io.swagger.annotations.ApiImplicitParams; import io.swagger.annotations.ApiOperation; +import lombok.Data; import net.shapelight.common.utils.*; import net.shapelight.modules.sys.controller.AbstractController; import net.shapelight.modules.sys.entity.SysUserEntity; import net.shapelight.modules.sys.service.SysUserRoleService; -import net.shapelight.modules.ten.entity.TenBuildEntity; -import net.shapelight.modules.ten.entity.TenPersonEntity; -import net.shapelight.modules.ten.entity.TenRecordEntity; -import net.shapelight.modules.ten.entity.TenUserScopeEntity; +import net.shapelight.modules.ten.entity.*; import net.shapelight.modules.ten.service.*; import net.shapelight.modules.vo.TenBuildVo; +import net.shapelight.modules.vo.TenPersonMonthCountVo; import net.shapelight.modules.vo.TenRecordVo; import org.apache.shiro.authz.annotation.RequiresPermissions; import org.springframework.beans.BeanUtils; @@ -50,6 +49,10 @@ public class TenDataViewController extends AbstractController { private TenRoomService tenRoomService; @Autowired private TenCompanyService tenCompanyService; + @Autowired + private TenLabelService tenLabelService; + @Autowired + private TenCompanyTypeService tenCompanyTypeService; /** * 列表 @@ -74,16 +77,42 @@ public class TenDataViewController extends AbstractController { TenUserScopeEntity scope = tenUserScopeService.getOne(new QueryWrapper().eq("user_id",user.getUserId())); params.put("cellId",scope.getCellId().toString()); } - List bList = tenBuildService.queryAll(params); - List bVoLIst = new ArrayList<>(); - for(TenBuildEntity build: bList){ - TenBuildVo vo = new TenBuildVo(); - BeanUtils.copyProperties(build,vo); - vo.setRoomCount(build.getRoomEach().intValue() * build.getLayerCount().intValue()); - vo.setPersonCount(tenPersonService.findBuildCount(build.getCellId(),build.getBuildId())); -// vo.setInRoomCount(); - bVoLIst.add(vo); +// List bList = tenBuildService.queryAll(params); +// List bVoLIst = new ArrayList<>(); +// for(TenBuildEntity build: bList){ +// TenBuildVo vo = new TenBuildVo(); +// BeanUtils.copyProperties(build,vo); +// vo.setRoomCount(build.getRoomEach().intValue() * build.getLayerCount().intValue()); +// vo.setPersonCount(tenPersonService.findBuildCount(build.getCellId(),build.getBuildId())); +//// vo.setInRoomCount(); +// bVoLIst.add(vo); +// +// } + List bVoLIst = new ArrayList<>(); + List devList = tenDeviceService.queryList(params); + for(TenDeviceEntity deviceEntity: devList){ + TenBuildVo vo = new TenBuildVo(); + TenCellEntity cellEntity = tenCellService.getById(deviceEntity.getCellId()); + vo.setCellName(cellEntity.getName()); + vo.setName(deviceEntity.getName()); +// if(deviceEntity.getLat()!=null && deviceEntity.getLat().length()>0){ +// vo.setLat(deviceEntity.getLat()); +// }else{ +// vo.setLat("38"); +// } +// if(deviceEntity.getLon()!=null && deviceEntity.getLon().length()>0){ +// vo.setLon(deviceEntity.getLon()); +// }else{ +// vo.setLon("108"); +// } + + if(deviceEntity.getLat()!=null && deviceEntity.getLat().length()>0){ + vo.setLat(deviceEntity.getLat()); + vo.setLon(deviceEntity.getLon()); + bVoLIst.add(vo); + } +// bVoLIst.add(vo); } return R.ok().put("data", bVoLIst); } @@ -148,46 +177,154 @@ public class TenDataViewController extends AbstractController { params.put("cellId",scope.getCellId().toString()); } +// //获取住户总数 +// List personTypeList = new ArrayList<>(); +// personTypeList.add(Constant.PERSON_TYPE_OWNER); +// personTypeList.add(Constant.PERSON_TYPE_MEMBER); +// personTypeList.add(Constant.PERSON_TYPE_TENANT); +// params.put("personTypeList",personTypeList); +// int personCount = tenPersonService.getAllCount(params); +// +// //获取业主总数包括业主和家庭成员 +// personTypeList.clear(); +// personTypeList.add(Constant.PERSON_TYPE_OWNER); +// personTypeList.add(Constant.PERSON_TYPE_MEMBER); +// params.put("personTypeList",personTypeList); +// int personOwnerCount = tenPersonService.getAllCount(params); +// +// //获取租户 +// personTypeList.clear(); +// personTypeList.add(Constant.PERSON_TYPE_TENANT); +// params.put("personTypeList",personTypeList); +// int personTenantCount = tenPersonService.getAllCount(params); +// +// //获取访客 +// personTypeList.clear(); +// personTypeList.add(Constant.PERSON_TYPE_GUEST); +// params.put("personTypeList",personTypeList); +// int personGuestCount = tenPersonService.getAllCount(params); +// +// //获取物业人员 +// personTypeList.clear(); +// personTypeList.add(Constant.PERSON_TYPE_PROPERTY); +// params.put("personTypeList",personTypeList); +// int personPropertyCount = tenPersonService.getAllCount(params); +// +// Map data = new HashMap(); +// data.put("personCount",personCount); +// data.put("personOwnerCount",personOwnerCount); +// data.put("personTenantCount",personTenantCount); +// data.put("personGuestCount",personGuestCount); +// data.put("personPropertyCount",personPropertyCount); + + + + + List data = new ArrayList(); //获取住户总数 List personTypeList = new ArrayList<>(); - personTypeList.add(Constant.PERSON_TYPE_OWNER); - personTypeList.add(Constant.PERSON_TYPE_MEMBER); - personTypeList.add(Constant.PERSON_TYPE_TENANT); - params.put("personTypeList",personTypeList); +// personTypeList.add(Constant.PERSON_TYPE_OWNER); +// personTypeList.add(Constant.PERSON_TYPE_MEMBER); +// personTypeList.add(Constant.PERSON_TYPE_TENANT); +// params.put("personTypeList",personTypeList); int personCount = tenPersonService.getAllCount(params); - - //获取业主总数包括业主和家庭成员 - personTypeList.clear(); - personTypeList.add(Constant.PERSON_TYPE_OWNER); - personTypeList.add(Constant.PERSON_TYPE_MEMBER); - params.put("personTypeList",personTypeList); - int personOwnerCount = tenPersonService.getAllCount(params); - - //获取租户 - personTypeList.clear(); - personTypeList.add(Constant.PERSON_TYPE_TENANT); - params.put("personTypeList",personTypeList); - int personTenantCount = tenPersonService.getAllCount(params); - +// +// //获取业主总数包括业主和家庭成员 +// personTypeList.clear(); +// personTypeList.add(Constant.PERSON_TYPE_OWNER); +// personTypeList.add(Constant.PERSON_TYPE_MEMBER); +// params.put("personTypeList",personTypeList); +// int personOwnerCount = tenPersonService.getAllCount(params); +// +// //获取租户 +// personTypeList.clear(); +// personTypeList.add(Constant.PERSON_TYPE_TENANT); +// params.put("personTypeList",personTypeList); +// int personTenantCount = tenPersonService.getAllCount(params); +// //获取访客 personTypeList.clear(); personTypeList.add(Constant.PERSON_TYPE_GUEST); params.put("personTypeList",personTypeList); int personGuestCount = tenPersonService.getAllCount(params); - +// //获取物业人员 personTypeList.clear(); personTypeList.add(Constant.PERSON_TYPE_PROPERTY); params.put("personTypeList",personTypeList); int personPropertyCount = tenPersonService.getAllCount(params); +// +// data.put("personCount",personCount); +// data.put("personOwnerCount",personOwnerCount); +// data.put("personTenantCount",personTenantCount); +// data.put("personGuestCount",personGuestCount); +// data.put("personPropertyCount",personPropertyCount); - Map data = new HashMap(); - data.put("personCount",personCount); - data.put("personOwnerCount",personOwnerCount); - data.put("personTenantCount",personTenantCount); - data.put("personGuestCount",personGuestCount); - data.put("personPropertyCount",personPropertyCount); - return R.ok().put("data", data); + NameValueClass c1 = new NameValueClass(); + c1.setName("访客"); + c1.setValue(personGuestCount); + data.add(c1); + + NameValueClass c2 = new NameValueClass(); + c2.setName("物业"); + c2.setValue(personGuestCount); + data.add(c2); + + //标签 + List labelList = tenLabelService.list(new QueryWrapper() + .eq("tenant_id",getUser().getTenantId())); + //其他标签 +// Iterator it = labelList.iterator(); +// while(it.hasNext()){ +// TenLabelEntity label = it.next(); +// if(label.getType() == Constant.PERSON_TYPE_OWNER +// || label.getType() == Constant.PERSON_TYPE_MEMBER +// || label.getType() == Constant.PERSON_TYPE_TENANT +// || label.getType() == Constant.PERSON_TYPE_GUEST +// || label.getType() == Constant.PERSON_TYPE_PROPERTY){ +// it.remove(); +// } +// } + int maxSize = 5; + List dataYeZhu = new ArrayList(); + for(TenLabelEntity labelEntity: labelList){ + params.remove("personTypeList"); + params.put("labelId",labelEntity.getLabelId()); + int labelCount = tenPersonService.getAllCount(params); + NameValueClass c = new NameValueClass(); + c.setName(labelEntity.getName()); + c.setValue(labelCount); + dataYeZhu.add(c); + } + + //顾虑多余的 + //1.排序 + dataYeZhu.sort(((o1,o2) -> { + //从大到小 + return o2.value - o1.value;//此处定义比较规则,o2.age-o1.age即为从大到小 + })); + +// data.addAll(dataYeZhu); + if(dataYeZhu.size()<=maxSize){ + data.addAll(dataYeZhu); + }else{ + for(int i = 0;i data = new HashMap(); +// data.put("cCount",cCount); +// data.put("yuleCount",yuleCount); +// data.put("jiguanCount",jiguanCount); +// data.put("qitaCount",qitaCount); +// data.put("yonggongCount",yonggongCount); +// data.put("chuzuCount",chuzuCount); - Map data = new HashMap(); - data.put("cCount",cCount); - data.put("yuleCount",yuleCount); - data.put("jiguanCount",jiguanCount); - data.put("qitaCount",qitaCount); - data.put("yonggongCount",yonggongCount); - data.put("chuzuCount",chuzuCount); - return R.ok().put("data", data); + //类型 + List dataRes = new ArrayList(); + List typeList = tenCompanyTypeService.list(new QueryWrapper() + .eq("tenant_id",getUser().getTenantId())); + for(TenCompanyTypeEntity labelEntity: typeList){ + params.put("typeId",labelEntity.getTypeId()); + int labelCount = tenCompanyService.getAllCountTypeId(params); + NameValueClass c = new NameValueClass(); + c.setName(labelEntity.getName()); + c.setValue(labelCount); + dataRes.add(c); + } + + + return R.ok().put("data", dataRes).put("allCount",cCount); } @@ -322,7 +475,8 @@ public class TenDataViewController extends AbstractController { // vo.setTemplate(entity.getTemplate()); if(p!=null){ vo.setPersonName(p.getName()); - vo.setAddress(p.getCellName()+p.getBuildName()+p.getRoomName()); +// vo.setAddress(p.getCellName()+p.getBuildName()+p.getRoomName()); + vo.setAddress(p.getCellName()); } list.add(vo); @@ -378,4 +532,76 @@ public class TenDataViewController extends AbstractController { return R.ok().put("data", list); } + + + @GetMapping("/getAgeScope") + @ApiOperation(value = "年龄分布",response = Map.class) + public R getAgeScope(@RequestParam Map params){ + String tenantId = getUser().getTenantId()+""; + params.put("tenantId",tenantId+""); + SysUserEntity user = getUser(); + List roleIdList = sysUserRoleService.queryRoleIdList(user.getUserId()); + //小区管理员 + if(roleIdList.get(0).longValue() == Constant.ROLE_TEN_CELL){ + TenUserScopeEntity scope = tenUserScopeService.getOne(new QueryWrapper().eq("user_id",user.getUserId())); + params.put("cellId",scope.getCellId().toString()); + } + + //获取范围1:30以下 + params.put("max",30); + int c1 = tenPersonService.findAgeScopeCount(params); + + params.put("min",30); + params.put("max",40); + int c2 = tenPersonService.findAgeScopeCount(params); + + params.put("min",40); + params.put("max",50); + int c3 = tenPersonService.findAgeScopeCount(params); + + params.put("min",50); + params.put("max",60); + int c4 = tenPersonService.findAgeScopeCount(params); + + params.remove("max"); + params.put("min",60); + int c5= tenPersonService.findAgeScopeCount(params); + + + Map data = new HashMap(); + data.put("c1",c1); + data.put("c2",c2); + data.put("c3",c3); + data.put("c4",c4); + data.put("c5",c5); + return R.ok().put("data", data); + } + + + @GetMapping("/getTurnover") + @ApiOperation(value = "人员流动",response = Map.class) + public R getTurnover(@RequestParam Map params){ + String tenantId = getUser().getTenantId()+""; + params.put("tenantId",tenantId+""); + SysUserEntity user = getUser(); + List roleIdList = sysUserRoleService.queryRoleIdList(user.getUserId()); + //小区管理员 + if(roleIdList.get(0).longValue() == Constant.ROLE_TEN_CELL){ + TenUserScopeEntity scope = tenUserScopeService.getOne(new QueryWrapper().eq("user_id",user.getUserId())); + params.put("cellId",scope.getCellId().toString()); + } + + List cList = tenPersonService.getMonthCreate(params); + List dList = tenPersonService.getMonthDelete(params); + + Map data = new HashMap(); + data.put("create",cList); + data.put("delete",dList); + return R.ok().put("data", data); + } + @Data + class NameValueClass{ + private String name; + private Integer value; + } } diff --git a/shapelight-admin/src/main/java/net/shapelight/modules/ten/controller/TenDeviceController.java b/shapelight-admin/src/main/java/net/shapelight/modules/ten/controller/TenDeviceController.java index e9cd186..ea19882 100644 --- a/shapelight-admin/src/main/java/net/shapelight/modules/ten/controller/TenDeviceController.java +++ b/shapelight-admin/src/main/java/net/shapelight/modules/ten/controller/TenDeviceController.java @@ -7,7 +7,7 @@ import io.swagger.annotations.Api; import io.swagger.annotations.ApiImplicitParam; import io.swagger.annotations.ApiImplicitParams; import io.swagger.annotations.ApiOperation; -import net.shapelight.common.utils.Constant; +import net.shapelight.common.utils.*; //import net.shapelight.modules.dev.mqtt.CmdProcess; //import net.shapelight.modules.dev.mqtt.EmqHttpApi; import net.shapelight.modules.nettyapi.service.ServerApiService; @@ -35,9 +35,6 @@ import org.springframework.web.bind.annotation.*; import net.shapelight.modules.ten.entity.TenDeviceEntity; import net.shapelight.modules.ten.service.TenDeviceService; -import net.shapelight.common.utils.PageUtils; -import net.shapelight.common.utils.R; - /** @@ -64,6 +61,8 @@ public class TenDeviceController extends AbstractController { // private EmqHttpApi emqHttpApi; @Autowired private ServerApiService serverApiService; + @Autowired + private RedisUtils redisUtils; /** * 列表 @@ -207,7 +206,16 @@ public class TenDeviceController extends AbstractController { //清除数据 int r = serverApiService.restart(sn); if(r == -1){ - return R.error("设备离线"); + if(redisUtils.get("DeviceLogin-"+sn)!=null){ + if(redisUtils.get("DeviceRestart-"+sn)==null){ + redisUtils.set("DeviceRestart-"+sn, 1,60l);//保存 + }else{ + return R.error("正在等待重启"); + } + }else{ + return R.error("设备离线"); + } +// return R.error("设备离线"); } return R.ok(); } @@ -334,8 +342,15 @@ public class TenDeviceController extends AbstractController { } //配置推送 int r = serverApiService.devConfig(tenDevice.getSn(),config); +// if(r == -1){ +// return R.error("设备离线"); +// } if(r == -1){ - return R.error("设备离线"); + if(redisUtils.get("DeviceLogin-"+tenDevice.getSn())!=null){ + //设置 + }else{ + return R.error("设备离线"); + } } tenDeviceService.evictupdateById(tenDevice); return R.ok(); diff --git a/shapelight-admin/src/main/java/net/shapelight/modules/ten/controller/TenDeviceOperateLogController.java b/shapelight-admin/src/main/java/net/shapelight/modules/ten/controller/TenDeviceOperateLogController.java new file mode 100644 index 0000000..5252094 --- /dev/null +++ b/shapelight-admin/src/main/java/net/shapelight/modules/ten/controller/TenDeviceOperateLogController.java @@ -0,0 +1,87 @@ +package net.shapelight.modules.ten.controller; + +import java.util.Arrays; +import java.util.Map; + +import org.apache.shiro.authz.annotation.RequiresPermissions; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; + +import net.shapelight.modules.ten.entity.TenDeviceOperateLogEntity; +import net.shapelight.modules.ten.service.TenDeviceOperateLogService; +import net.shapelight.common.utils.PageUtils; +import net.shapelight.common.utils.R; + + + +/** + * + * + */ +@RestController +@RequestMapping("ten/deviceoperatelog") +public class TenDeviceOperateLogController { + @Autowired + private TenDeviceOperateLogService tenDeviceOperateLogService; + + /** + * 列表 + */ + @RequestMapping("/list") + @RequiresPermissions("ten:deviceoperatelog") + public R list(@RequestParam Map params){ + PageUtils page = tenDeviceOperateLogService.queryPage(params); + + return R.ok().put("data", page); + } + + + /** + * 信息 + */ + @RequestMapping("/info/{logId}") + @RequiresPermissions("ten:deviceoperatelog") + public R info(@PathVariable("logId") Long logId){ + TenDeviceOperateLogEntity tenDeviceOperateLog = tenDeviceOperateLogService.getById(logId); + + return R.ok().put("data", tenDeviceOperateLog); + } + + /** + * 保存 + */ + @RequestMapping("/save") + @RequiresPermissions("ten:deviceoperatelog") + public R save(@RequestBody TenDeviceOperateLogEntity tenDeviceOperateLog){ + tenDeviceOperateLogService.save(tenDeviceOperateLog); + + return R.ok(); + } + + /** + * 修改 + */ + @RequestMapping("/update") + @RequiresPermissions("ten:deviceoperatelog") + public R update(@RequestBody TenDeviceOperateLogEntity tenDeviceOperateLog){ + tenDeviceOperateLogService.updateById(tenDeviceOperateLog); + + return R.ok(); + } + + /** + * 删除 + */ + @RequestMapping("/delete") + @RequiresPermissions("ten:deviceoperatelog:delete") + public R delete(@RequestBody Long[] logIds){ + tenDeviceOperateLogService.removeByIds(Arrays.asList(logIds)); + + return R.ok(); + } + +} diff --git a/shapelight-admin/src/main/java/net/shapelight/modules/ten/controller/TenLabelController.java b/shapelight-admin/src/main/java/net/shapelight/modules/ten/controller/TenLabelController.java index 908f0bd..6285d77 100644 --- a/shapelight-admin/src/main/java/net/shapelight/modules/ten/controller/TenLabelController.java +++ b/shapelight-admin/src/main/java/net/shapelight/modules/ten/controller/TenLabelController.java @@ -12,6 +12,7 @@ import io.swagger.annotations.ApiImplicitParam; import io.swagger.annotations.ApiImplicitParams; import io.swagger.annotations.ApiOperation; import net.shapelight.modules.sys.controller.AbstractController; +import net.shapelight.modules.ten.service.TenPersonService; import org.apache.shiro.authz.annotation.RequiresPermissions; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; @@ -33,6 +34,8 @@ import net.shapelight.common.utils.R; public class TenLabelController extends AbstractController { @Autowired private TenLabelService tenLabelService; + @Autowired + private TenPersonService tenPersonService; /** * 列表 @@ -82,11 +85,18 @@ public class TenLabelController extends AbstractController { @RequiresPermissions("ten:label") @ApiOperation(value = "保存标签") public R save(@RequestBody TenLabelEntity tenLabel){ + List list = tenLabelService.list(new QueryWrapper() + .eq("tenant_id",getUser().getTenantId()) + .eq("name",tenLabel.getName())); + if(list.size()>0){ + return R.error("名称已存在"); + } tenLabel.setCreateBy(getUser().getUsername()); tenLabel.setCreateTime(new Date()); tenLabel.setTenantId(getUser().getTenantId()); tenLabelService.save(tenLabel); - + tenLabel.setType(tenLabel.getLabelId().intValue()); + tenLabelService.updateById(tenLabel); return R.ok(); } @@ -97,6 +107,15 @@ public class TenLabelController extends AbstractController { @RequiresPermissions("ten:label") @ApiOperation(value = "修改标签") public R update(@RequestBody TenLabelEntity tenLabel){ + TenLabelEntity old = tenLabelService.getById(tenLabel.getLabelId()); + if(!old.getName().equals(tenLabel.getName())){ + List list = tenLabelService.list(new QueryWrapper() + .eq("tenant_id",getUser().getTenantId()) + .eq("name",tenLabel.getName())); + if(list.size()>0){ + return R.error("名称已存在"); + } + } tenLabel.setTenantId(getUser().getTenantId()); tenLabel.setLastUpdateBy(getUser().getUsername()); tenLabel.setLastUpdateTime(new Date()); @@ -113,6 +132,11 @@ public class TenLabelController extends AbstractController { @RequiresPermissions("ten:label") @ApiOperation(value = "删除标签") public R delete(@RequestBody Long[] labelIds){ + Long id = labelIds[0]; + int pCount = tenPersonService.getByLabel(id); + if(pCount>0){ + return R.error("此标签已使用"); + } tenLabelService.removeByIds(Arrays.asList(labelIds)); return R.ok(); } diff --git a/shapelight-admin/src/main/java/net/shapelight/modules/ten/controller/TenPersonController.java b/shapelight-admin/src/main/java/net/shapelight/modules/ten/controller/TenPersonController.java index 42a4fdd..451b682 100644 --- a/shapelight-admin/src/main/java/net/shapelight/modules/ten/controller/TenPersonController.java +++ b/shapelight-admin/src/main/java/net/shapelight/modules/ten/controller/TenPersonController.java @@ -76,6 +76,10 @@ public class TenPersonController extends AbstractController { private TenPersonSyncService tenPersonSyncService; @Autowired private ServerApiService serverApiService; + @Autowired + private TenCellDeptService tenCellDeptService; + @Autowired + private TenLabelService tenLabelService; /** @@ -111,6 +115,8 @@ public class TenPersonController extends AbstractController { params.put("cellId", scope.getCellId().toString()); } List personTypeList = new ArrayList<>(); + List tenLabel = tenLabelService.list(new QueryWrapper() + .eq("tenant_id",getUser().getTenantId())); personTypeList.add(Constant.PERSON_TYPE_OWNER); personTypeList.add(Constant.PERSON_TYPE_MEMBER); personTypeList.add(Constant.PERSON_TYPE_TENANT); @@ -278,15 +284,25 @@ public class TenPersonController extends AbstractController { .eq("user_id",tenantId)); person.setTenantName(sysUserEntity.getCompanyName()); - if(person.getPersonType().intValue() == Constant.PERSON_TYPE_MEMBER - || person.getPersonType().intValue() == Constant.PERSON_TYPE_OWNER - || person.getPersonType().intValue() == Constant.PERSON_TYPE_TENANT - || person.getPersonType().intValue() == Constant.PERSON_TYPE_GUEST){ - String n = String.format("%02d%s",Integer.parseInt(person.getBuildUnit()),person.getRoomName()); - n = n.replace("室",""); - person.setDoorNumber(n); + if(person.getRoomId()!=null){ + if(person.getPersonType().intValue() == Constant.PERSON_TYPE_MEMBER + || person.getPersonType().intValue() == Constant.PERSON_TYPE_OWNER + || person.getPersonType().intValue() == Constant.PERSON_TYPE_TENANT + || person.getPersonType().intValue() == Constant.PERSON_TYPE_GUEST){ + String n = String.format("%02d%s",Integer.parseInt(person.getBuildUnit()),person.getRoomName()); + n = n.replace("室",""); + person.setDoorNumber(n); + } } + 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", person); } diff --git a/shapelight-admin/src/main/java/net/shapelight/modules/ten/dao/TenCellDeptDao.java b/shapelight-admin/src/main/java/net/shapelight/modules/ten/dao/TenCellDeptDao.java new file mode 100644 index 0000000..40edc30 --- /dev/null +++ b/shapelight-admin/src/main/java/net/shapelight/modules/ten/dao/TenCellDeptDao.java @@ -0,0 +1,30 @@ +package net.shapelight.modules.ten.dao; + +import net.shapelight.modules.ten.entity.TenCellDeptEntity; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; + +import java.util.List; +import java.util.Map; + +/** + * + * + */ +@Mapper +public interface TenCellDeptDao extends BaseMapper { + + + /** + * 查询子区域ID列表 + * @param parentId 上级区域ID + */ + List queryDeptIdList(Long parentId); + + String getDeptName(@Param("deptId")Long deptId); + + String getAllParentName(@Param("deptId")Long deptId); + + +} diff --git a/shapelight-admin/src/main/java/net/shapelight/modules/ten/dao/TenCompanyTypeDao.java b/shapelight-admin/src/main/java/net/shapelight/modules/ten/dao/TenCompanyTypeDao.java new file mode 100644 index 0000000..6d13f07 --- /dev/null +++ b/shapelight-admin/src/main/java/net/shapelight/modules/ten/dao/TenCompanyTypeDao.java @@ -0,0 +1,14 @@ +package net.shapelight.modules.ten.dao; + +import net.shapelight.modules.ten.entity.TenCompanyTypeEntity; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import org.apache.ibatis.annotations.Mapper; + +/** + * 标签 + * + */ +@Mapper +public interface TenCompanyTypeDao extends BaseMapper { + +} diff --git a/shapelight-admin/src/main/java/net/shapelight/modules/ten/dao/TenDeviceOperateLogDao.java b/shapelight-admin/src/main/java/net/shapelight/modules/ten/dao/TenDeviceOperateLogDao.java new file mode 100644 index 0000000..54c0d0c --- /dev/null +++ b/shapelight-admin/src/main/java/net/shapelight/modules/ten/dao/TenDeviceOperateLogDao.java @@ -0,0 +1,14 @@ +package net.shapelight.modules.ten.dao; + +import net.shapelight.modules.ten.entity.TenDeviceOperateLogEntity; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import org.apache.ibatis.annotations.Mapper; + +/** + * + * + */ +@Mapper +public interface TenDeviceOperateLogDao extends BaseMapper { + +} diff --git a/shapelight-admin/src/main/java/net/shapelight/modules/ten/dao/TenLabelDao.java b/shapelight-admin/src/main/java/net/shapelight/modules/ten/dao/TenLabelDao.java index f00ff8d..a0edc66 100644 --- a/shapelight-admin/src/main/java/net/shapelight/modules/ten/dao/TenLabelDao.java +++ b/shapelight-admin/src/main/java/net/shapelight/modules/ten/dao/TenLabelDao.java @@ -12,4 +12,6 @@ import org.apache.ibatis.annotations.Param; @Mapper public interface TenLabelDao extends BaseMapper { String getLabelName(@Param("labelId")Long labelId); + String getLabelTypeName(@Param("type")Long type, @Param("tenantId")Long tenantId); + } diff --git a/shapelight-admin/src/main/java/net/shapelight/modules/ten/dao/TenPersonDao.java b/shapelight-admin/src/main/java/net/shapelight/modules/ten/dao/TenPersonDao.java index f4393c6..75b5960 100644 --- a/shapelight-admin/src/main/java/net/shapelight/modules/ten/dao/TenPersonDao.java +++ b/shapelight-admin/src/main/java/net/shapelight/modules/ten/dao/TenPersonDao.java @@ -6,6 +6,7 @@ import net.shapelight.modules.ten.entity.TenPersonEntity; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import net.shapelight.modules.vo.TenPersonIdUpdateAllVo; import net.shapelight.modules.vo.TenPersonIdUpdateVo; +import net.shapelight.modules.vo.TenPersonMonthCountVo; import net.shapelight.modules.vo.TenPersonVo; import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Param; @@ -94,6 +95,23 @@ public interface TenPersonDao { List getByHaveMobilePersonByRoomId(@Param("roomId") Long roomId); + int findAgeScopeCount(@Param("cellIds") List cellIds,@Param("params") Map params); + + List getMonthCreate(@Param("cellIds") List cellIds); + List getMonthDelete(@Param("cellIds") List cellIds); + + + int checkByIdCardDept(@Param("idCard")String idCard, @Param("deptId")Long deptId); + + int getDeptPersonCount(@Param("deptId")Long deptId); + + int checkByIdCardCell(@Param("idCard")String idCard, @Param("cellId")Long cellId); + + int getByLabel(@Param("labelId")Long labelId); + + IPage selectByDeptId(Page page,@Param("deptId")Long deptId, @Param("cellId")Long cellId, @Param("key")String key); + IPage selectByDeptIdForGuest(Page page,@Param("deptId")Long deptId, @Param("cellId")Long cellId, @Param("key")String key); + diff --git a/shapelight-admin/src/main/java/net/shapelight/modules/ten/dao/TenRecordDao.java b/shapelight-admin/src/main/java/net/shapelight/modules/ten/dao/TenRecordDao.java index 74f96bd..e97de99 100644 --- a/shapelight-admin/src/main/java/net/shapelight/modules/ten/dao/TenRecordDao.java +++ b/shapelight-admin/src/main/java/net/shapelight/modules/ten/dao/TenRecordDao.java @@ -45,4 +45,5 @@ public interface TenRecordDao { List getMonthRecords(@Param("start") String start, @Param("end") String end, @Param("tenantId") String tenantId); + IPage findPageDeptRecord(Page page, @Param("params") Map params); } diff --git a/shapelight-admin/src/main/java/net/shapelight/modules/ten/dao/TenRoomDao.java b/shapelight-admin/src/main/java/net/shapelight/modules/ten/dao/TenRoomDao.java index 2dc83d8..6e8867b 100644 --- a/shapelight-admin/src/main/java/net/shapelight/modules/ten/dao/TenRoomDao.java +++ b/shapelight-admin/src/main/java/net/shapelight/modules/ten/dao/TenRoomDao.java @@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import net.shapelight.modules.ten.entity.TenRoomEntity; import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import net.shapelight.modules.vo.TenRoomDeptVo; import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Param; @@ -36,6 +37,9 @@ public interface TenRoomDao { @Param("buildId")Long buildId, @Param("cellId")Long cellId); + List getBuildRooms(@Param("buildId")Long buildId); + + @@ -52,4 +56,8 @@ public interface TenRoomDao { List getPicByCellId(@Param("pId") Long pId,@Param("cellId") Long paramLong); + List getDistinctBuild(@Param("cellId") Long paramLong); + List getDistinctUnit(@Param("cellId") Long paramLong, @Param("buildName")String buildName); + List getDistinctLayer(@Param("cellId") Long paramLong,@Param("buildName")String buildName,@Param("unit")String unit); + List getDistinctRoom(@Param("cellId") Long paramLong,@Param("buildName")String buildName,@Param("unit")String unit,@Param("layer")String layer); } diff --git a/shapelight-admin/src/main/java/net/shapelight/modules/ten/entity/TenCellDeptEntity.java b/shapelight-admin/src/main/java/net/shapelight/modules/ten/entity/TenCellDeptEntity.java new file mode 100644 index 0000000..c8aa02c --- /dev/null +++ b/shapelight-admin/src/main/java/net/shapelight/modules/ten/entity/TenCellDeptEntity.java @@ -0,0 +1,118 @@ +package net.shapelight.modules.ten.entity; + +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; + +import java.io.Serializable; +import java.util.ArrayList; +import java.util.Date; +import java.util.List; + +import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import com.fasterxml.jackson.databind.ser.std.ToStringSerializer; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import net.shapelight.common.base.BaseEntity; + +/** + * + * + */ +@Data +@TableName("ten_cell_dept") +public class TenCellDeptEntity extends BaseEntity implements Serializable { + private static final long serialVersionUID = 1L; + + /** + * 部门/楼栋 + */ + @TableId + @JsonSerialize(using = ToStringSerializer.class) + private Long deptId; + /** + * 父级目录 + */ + @JsonSerialize(using = ToStringSerializer.class) + private Long parentId; + /** + * 小区ID + */ + @JsonSerialize(using = ToStringSerializer.class) + private Long cellId; + /** + * 名称 + */ + private String name; + /** + * 标签 + */ + private String lable; + /** + * 纬度 + */ + private String lat; + /** + * 经度 + */ + private String lon; + /** + * 其他 + */ + private String other; + /** + * 备注 + */ + private String remark; + /** + * 照片 + */ + private String picture; + /** + * 0未删除1删除 + */ + private Integer deleteFlag; + /** + * 运营商ID + */ + @JsonSerialize(using = ToStringSerializer.class) + private Long tenantId; + /** + * 第三方是否同步1是0否默认0 + */ + private Integer xaSync; + /** + * 地址序号 + */ + private Integer pId; + /** + * 地址编码 + */ + private String dzbm; + /** + * 是否是户室0否1是 + */ + private Integer isRoom; + /** + * 类型:自住,出租 + */ + private Integer roomType; + + @TableField(exist=false) + @ApiModelProperty("子菜单") + private List childrenList = new ArrayList<>(); + + @TableField(exist=false) + private boolean hasChildren = true; + + /** + * 上级部门名称 + */ + @ApiModelProperty("上级部门名称") + @TableField(exist=false) + private String parentName; + + @TableField(exist=false) + private Integer personCount; + +} diff --git a/shapelight-admin/src/main/java/net/shapelight/modules/ten/entity/TenCompanyEntity.java b/shapelight-admin/src/main/java/net/shapelight/modules/ten/entity/TenCompanyEntity.java index 7d80bda..bc82ba6 100644 --- a/shapelight-admin/src/main/java/net/shapelight/modules/ten/entity/TenCompanyEntity.java +++ b/shapelight-admin/src/main/java/net/shapelight/modules/ten/entity/TenCompanyEntity.java @@ -1,5 +1,6 @@ package net.shapelight.modules.ten.entity; +import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableLogic; import com.baomidou.mybatisplus.annotation.TableName; @@ -119,4 +120,9 @@ public class TenCompanyEntity implements Serializable { @TableLogic private Integer deleteFlag; + private Long typeId; + + @TableField(exist=false) + private String typeName; + } diff --git a/shapelight-admin/src/main/java/net/shapelight/modules/ten/entity/TenCompanyTypeEntity.java b/shapelight-admin/src/main/java/net/shapelight/modules/ten/entity/TenCompanyTypeEntity.java new file mode 100644 index 0000000..174e16d --- /dev/null +++ b/shapelight-admin/src/main/java/net/shapelight/modules/ten/entity/TenCompanyTypeEntity.java @@ -0,0 +1,61 @@ +package net.shapelight.modules.ten.entity; + +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; + +import java.io.Serializable; +import java.util.Date; + +import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import com.fasterxml.jackson.databind.ser.std.ToStringSerializer; +import lombok.Data; + +/** + * 标签 + * + */ +@Data +@TableName("ten_company_type") +public class TenCompanyTypeEntity implements Serializable { + private static final long serialVersionUID = 1L; + + /** + * ID + */ + @TableId + private Long typeId; + /** + * 标签名称 + */ + private String name; + /** + * 创建时间 + */ + private Date createTime; + /** + * 创建人 + */ + private String createBy; + /** + * 更新时间 + */ + private Date lastUpdateTime; + /** + * 更新人 + */ + private String lastUpdateBy; + /** + * 0未删除1删除 + */ + private Integer deleteFlag; + /** + * 运营商ID + */ + @JsonSerialize(using = ToStringSerializer.class) + private Long tenantId; + + @TableField(exist=false) + private Integer companyCount; + +} diff --git a/shapelight-admin/src/main/java/net/shapelight/modules/ten/entity/TenDeviceEntity.java b/shapelight-admin/src/main/java/net/shapelight/modules/ten/entity/TenDeviceEntity.java index 813434e..af7f33f 100644 --- a/shapelight-admin/src/main/java/net/shapelight/modules/ten/entity/TenDeviceEntity.java +++ b/shapelight-admin/src/main/java/net/shapelight/modules/ten/entity/TenDeviceEntity.java @@ -255,4 +255,9 @@ public class TenDeviceEntity extends BaseEntity implements Serializable { private Integer detectionType; + //--------------------v5http协议增加-------------- + private Integer appLanguage; + private String lat; + private String lon; + } diff --git a/shapelight-admin/src/main/java/net/shapelight/modules/ten/entity/TenDeviceOperateLogEntity.java b/shapelight-admin/src/main/java/net/shapelight/modules/ten/entity/TenDeviceOperateLogEntity.java new file mode 100644 index 0000000..78380dc --- /dev/null +++ b/shapelight-admin/src/main/java/net/shapelight/modules/ten/entity/TenDeviceOperateLogEntity.java @@ -0,0 +1,41 @@ +package net.shapelight.modules.ten.entity; + +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; + +import java.io.Serializable; +import java.util.Date; +import lombok.Data; + +/** + * + * + */ +@Data +@TableName("ten_device_operate_log") +public class TenDeviceOperateLogEntity implements Serializable { + private static final long serialVersionUID = 1L; + + /** + * + */ + @TableId + private Long logId; + /** + * + */ + private String sn; + /** + * 创建时间 + */ + private Date createTime; + /** + * 用户操作 + */ + private String operation; + /** + * 运营商Id + */ + private Long tenantId; + +} diff --git a/shapelight-admin/src/main/java/net/shapelight/modules/ten/entity/TenPersonEntity.java b/shapelight-admin/src/main/java/net/shapelight/modules/ten/entity/TenPersonEntity.java index 6b096b3..6515d4d 100644 --- a/shapelight-admin/src/main/java/net/shapelight/modules/ten/entity/TenPersonEntity.java +++ b/shapelight-admin/src/main/java/net/shapelight/modules/ten/entity/TenPersonEntity.java @@ -345,5 +345,19 @@ public class TenPersonEntity extends BaseEntity implements Serializable { private String sourceFile; private String cameraParam; + //-----------------v5http----- + private String thdFeature; + + @JsonSerialize(using = ToStringSerializer.class) + @ApiModelProperty("部门ID") + private Long deptId; + + @ApiModelProperty("部门名称") + @TableField(exist = false) + private String deptName; + + @ApiModelProperty("部门长名称") + @TableField(exist = false) + private String deptAllName; } diff --git a/shapelight-admin/src/main/java/net/shapelight/modules/ten/service/TenCellDeptService.java b/shapelight-admin/src/main/java/net/shapelight/modules/ten/service/TenCellDeptService.java new file mode 100644 index 0000000..00b805a --- /dev/null +++ b/shapelight-admin/src/main/java/net/shapelight/modules/ten/service/TenCellDeptService.java @@ -0,0 +1,29 @@ +package net.shapelight.modules.ten.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import net.shapelight.common.utils.PageUtils; +import net.shapelight.modules.ten.entity.TenCellDeptEntity; +import org.apache.ibatis.annotations.Param; + +import java.util.List; +import java.util.Map; + +/** + * + * + */ +public interface TenCellDeptService extends IService { + + PageUtils queryPage(Map params); + + List getSubDeptIdList(Long areaId); + /** + * 查询子部门ID列表 + * @param parentId 上级部门ID + */ + List queryDeptIdList(Long parentId); + + String getAllParentName(Long deptId); + +} + diff --git a/shapelight-admin/src/main/java/net/shapelight/modules/ten/service/TenCompanyService.java b/shapelight-admin/src/main/java/net/shapelight/modules/ten/service/TenCompanyService.java index fb712bf..bc2ab9b 100644 --- a/shapelight-admin/src/main/java/net/shapelight/modules/ten/service/TenCompanyService.java +++ b/shapelight-admin/src/main/java/net/shapelight/modules/ten/service/TenCompanyService.java @@ -15,5 +15,9 @@ public interface TenCompanyService extends IService { PageUtils queryPage(Map params); int getAllCount(Map params); + + int getAllCountTypeId(Map params); + + } diff --git a/shapelight-admin/src/main/java/net/shapelight/modules/ten/service/TenCompanyTypeService.java b/shapelight-admin/src/main/java/net/shapelight/modules/ten/service/TenCompanyTypeService.java new file mode 100644 index 0000000..a8db7a0 --- /dev/null +++ b/shapelight-admin/src/main/java/net/shapelight/modules/ten/service/TenCompanyTypeService.java @@ -0,0 +1,17 @@ +package net.shapelight.modules.ten.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import net.shapelight.common.utils.PageUtils; +import net.shapelight.modules.ten.entity.TenCompanyTypeEntity; + +import java.util.Map; + +/** + * 标签 + * + */ +public interface TenCompanyTypeService extends IService { + + PageUtils queryPage(Map params); +} + diff --git a/shapelight-admin/src/main/java/net/shapelight/modules/ten/service/TenDeviceOperateLogService.java b/shapelight-admin/src/main/java/net/shapelight/modules/ten/service/TenDeviceOperateLogService.java new file mode 100644 index 0000000..d3048bc --- /dev/null +++ b/shapelight-admin/src/main/java/net/shapelight/modules/ten/service/TenDeviceOperateLogService.java @@ -0,0 +1,17 @@ +package net.shapelight.modules.ten.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import net.shapelight.common.utils.PageUtils; +import net.shapelight.modules.ten.entity.TenDeviceOperateLogEntity; + +import java.util.Map; + +/** + * + * + */ +public interface TenDeviceOperateLogService extends IService { + + PageUtils queryPage(Map params); +} + diff --git a/shapelight-admin/src/main/java/net/shapelight/modules/ten/service/TenDeviceService.java b/shapelight-admin/src/main/java/net/shapelight/modules/ten/service/TenDeviceService.java index f7587ae..f7dc8d0 100644 --- a/shapelight-admin/src/main/java/net/shapelight/modules/ten/service/TenDeviceService.java +++ b/shapelight-admin/src/main/java/net/shapelight/modules/ten/service/TenDeviceService.java @@ -67,6 +67,8 @@ public interface TenDeviceService extends IService { List getNotSync(Long cellId); + List queryList(Map params); + } diff --git a/shapelight-admin/src/main/java/net/shapelight/modules/ten/service/TenPersonService.java b/shapelight-admin/src/main/java/net/shapelight/modules/ten/service/TenPersonService.java index 6dd6d83..f8fad57 100644 --- a/shapelight-admin/src/main/java/net/shapelight/modules/ten/service/TenPersonService.java +++ b/shapelight-admin/src/main/java/net/shapelight/modules/ten/service/TenPersonService.java @@ -9,6 +9,7 @@ import net.shapelight.modules.ten.entity.TenPersonEntity; import net.shapelight.modules.ten.entity.TenRoomEntity; import net.shapelight.modules.vo.TenPersonIdUpdateAllVo; import net.shapelight.modules.vo.TenPersonIdUpdateVo; +import net.shapelight.modules.vo.TenPersonMonthCountVo; import net.shapelight.modules.vo.TenPersonVo; import org.apache.ibatis.annotations.Param; @@ -27,6 +28,7 @@ public interface TenPersonService { PageUtils queryVerify(Map params); int save(TenPersonEntity entity); + int save3d(TenPersonEntity entity); boolean saveOtherRoom(TenPersonEntity entity); // boolean removeById(Long roomId,Long cellId); @@ -122,6 +124,21 @@ public interface TenPersonService { List getByHaveMobilePersonByRoomId(Long roomId); + int findAgeScopeCount(Map params); + + List getMonthCreate(Map params); + List getMonthDelete(Map params); + + int checkByIdCardDept(String idCard, Long deptId); + + int getDeptPersonCount(Long deptId); + + int checkByIdCardCell(String idCard, Long cellId); + + int getByLabel(Long labelId); + + PageUtils selectByDeptIdQueryPage(Map params); + PageUtils selectByDeptIdForGuestQueryPage(Map params); } diff --git a/shapelight-admin/src/main/java/net/shapelight/modules/ten/service/TenRecordService.java b/shapelight-admin/src/main/java/net/shapelight/modules/ten/service/TenRecordService.java index 2dace6b..8b4dda2 100644 --- a/shapelight-admin/src/main/java/net/shapelight/modules/ten/service/TenRecordService.java +++ b/shapelight-admin/src/main/java/net/shapelight/modules/ten/service/TenRecordService.java @@ -42,5 +42,7 @@ public interface TenRecordService { List getMonthRecords(String start, String end, String tenantId); + PageUtils queryPageDeptRecord(Map params); + } diff --git a/shapelight-admin/src/main/java/net/shapelight/modules/ten/service/TenRoomService.java b/shapelight-admin/src/main/java/net/shapelight/modules/ten/service/TenRoomService.java index 06a73ed..66e5e24 100644 --- a/shapelight-admin/src/main/java/net/shapelight/modules/ten/service/TenRoomService.java +++ b/shapelight-admin/src/main/java/net/shapelight/modules/ten/service/TenRoomService.java @@ -37,6 +37,8 @@ public interface TenRoomService { Long buildId, Long cellId); + List getBuildRooms(Long buildId); + String getRoomName(Long id, Long cellId); diff --git a/shapelight-admin/src/main/java/net/shapelight/modules/ten/service/impl/TenCellDeptServiceImpl.java b/shapelight-admin/src/main/java/net/shapelight/modules/ten/service/impl/TenCellDeptServiceImpl.java new file mode 100644 index 0000000..b989da1 --- /dev/null +++ b/shapelight-admin/src/main/java/net/shapelight/modules/ten/service/impl/TenCellDeptServiceImpl.java @@ -0,0 +1,70 @@ +package net.shapelight.modules.ten.service.impl; + +import org.springframework.stereotype.Service; + +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import net.shapelight.common.utils.PageUtils; +import net.shapelight.common.utils.Query; + +import net.shapelight.modules.ten.dao.TenCellDeptDao; +import net.shapelight.modules.ten.entity.TenCellDeptEntity; +import net.shapelight.modules.ten.service.TenCellDeptService; + + +@Service("tenCellDeptService") +public class TenCellDeptServiceImpl extends ServiceImpl implements TenCellDeptService { + + @Override + public PageUtils queryPage(Map params) { + String cellId = (String)params.get("cellID"); + IPage page = this.page( + new Query().getPage(params), + new QueryWrapper() + .eq("cell_id",cellId) + ); + + return new PageUtils(page); + } + + @Override + public List getSubDeptIdList(Long areaId){ + //部门及子部门ID列表 + List deptIdList = new ArrayList<>(); + //获取子部门ID + List subIdList = queryDeptIdList(areaId); + getDeptTreeList(subIdList, deptIdList); + return deptIdList; + } + + @Override + public List queryDeptIdList(Long parentId) { + return baseMapper.queryDeptIdList(parentId); + } + + + /** + * 递归 + */ + private void getDeptTreeList(List subIdList, List areaIdList){ + for(Long deptId : subIdList){ + List list = queryDeptIdList(deptId); + if(list.size() > 0){ + getDeptTreeList(list, areaIdList); + } + areaIdList.add(deptId); + } + } + + + @Override + public String getAllParentName(Long deptId) { + return baseMapper.getAllParentName(deptId); + } + + +} \ No newline at end of file diff --git a/shapelight-admin/src/main/java/net/shapelight/modules/ten/service/impl/TenCellServiceImpl.java b/shapelight-admin/src/main/java/net/shapelight/modules/ten/service/impl/TenCellServiceImpl.java index fa7326b..b8e2f85 100644 --- a/shapelight-admin/src/main/java/net/shapelight/modules/ten/service/impl/TenCellServiceImpl.java +++ b/shapelight-admin/src/main/java/net/shapelight/modules/ten/service/impl/TenCellServiceImpl.java @@ -106,7 +106,7 @@ public class TenCellServiceImpl extends ServiceImpl i // @Cacheable(value="TenCell", key="#name-#tenantId") @Cacheable(value = "TenCell", key = "#name+'-'+#tenantId") public TenCellEntity findByCellName(String name, String tenantId) { - return getOne(new QueryWrapper().eq("name", name)); + return getOne(new QueryWrapper().eq("name", name).eq("tenant_id",tenantId)); } @Override diff --git a/shapelight-admin/src/main/java/net/shapelight/modules/ten/service/impl/TenCompanyServiceImpl.java b/shapelight-admin/src/main/java/net/shapelight/modules/ten/service/impl/TenCompanyServiceImpl.java index d7e7cf3..8d5f344 100644 --- a/shapelight-admin/src/main/java/net/shapelight/modules/ten/service/impl/TenCompanyServiceImpl.java +++ b/shapelight-admin/src/main/java/net/shapelight/modules/ten/service/impl/TenCompanyServiceImpl.java @@ -2,7 +2,9 @@ package net.shapelight.modules.ten.service.impl; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import net.shapelight.modules.ten.entity.TenCellEntity; +import net.shapelight.modules.ten.entity.TenCompanyTypeEntity; import net.shapelight.modules.ten.service.TenCellService; +import net.shapelight.modules.ten.service.TenCompanyTypeService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @@ -25,6 +27,8 @@ public class TenCompanyServiceImpl extends ServiceImpl params) { String name = (String) params.get("name"); @@ -52,6 +56,14 @@ public class TenCompanyServiceImpl extends ServiceImpl params) { + List cellIds = new ArrayList<>(); +// cellIds.add(709832651506188289L); + String cellId = (String)params.get("cellId"); + if (cellId!=null && !cellId.isEmpty()){ + Long cellLong = Long.parseLong(cellId); + cellIds.add(cellLong); + }else { + List cells = tenCellService.queryAll(params); + for (TenCellEntity cell : cells) { + cellIds.add(cell.getCellId()); + } + } + if (cellIds.size() == 0) { + return 0; + } +// List list = new ArrayList<>(); + int count = 0; + if(params.get("typeId")!=null){ + count = this.count(new QueryWrapper() + .in("cell_id",cellIds) + .eq("type_id",params.get("typeId"))); + }else{ + count = this.count(new QueryWrapper() + .in("cell_id",cellIds)); + } + return count; + } } diff --git a/shapelight-admin/src/main/java/net/shapelight/modules/ten/service/impl/TenCompanyTypeServiceImpl.java b/shapelight-admin/src/main/java/net/shapelight/modules/ten/service/impl/TenCompanyTypeServiceImpl.java new file mode 100644 index 0000000..6531165 --- /dev/null +++ b/shapelight-admin/src/main/java/net/shapelight/modules/ten/service/impl/TenCompanyTypeServiceImpl.java @@ -0,0 +1,43 @@ +package net.shapelight.modules.ten.service.impl; + +import net.shapelight.modules.ten.entity.TenCompanyEntity; +import net.shapelight.modules.ten.service.TenCompanyService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import java.util.Map; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import net.shapelight.common.utils.PageUtils; +import net.shapelight.common.utils.Query; + +import net.shapelight.modules.ten.dao.TenCompanyTypeDao; +import net.shapelight.modules.ten.entity.TenCompanyTypeEntity; +import net.shapelight.modules.ten.service.TenCompanyTypeService; + + +@Service("tenCompanyTypeService") +public class TenCompanyTypeServiceImpl extends ServiceImpl implements TenCompanyTypeService { + + @Autowired + private TenCompanyService tenCompanyService; + + @Override + public PageUtils queryPage(Map params) { + IPage page = this.page( + new Query().getPage(params), + new QueryWrapper() + .eq("tenant_id",params.get("tenantId")) + .like("name",params.get("name")) + ); + + for(TenCompanyTypeEntity entity: page.getRecords()){ + int count = tenCompanyService.count(new QueryWrapper() + .eq("type_id",entity.getTypeId())); + entity.setCompanyCount(count); + } + + return new PageUtils(page); + } + +} \ No newline at end of file diff --git a/shapelight-admin/src/main/java/net/shapelight/modules/ten/service/impl/TenDeviceOperateLogServiceImpl.java b/shapelight-admin/src/main/java/net/shapelight/modules/ten/service/impl/TenDeviceOperateLogServiceImpl.java new file mode 100644 index 0000000..b75f5c0 --- /dev/null +++ b/shapelight-admin/src/main/java/net/shapelight/modules/ten/service/impl/TenDeviceOperateLogServiceImpl.java @@ -0,0 +1,42 @@ +package net.shapelight.modules.ten.service.impl; + +import net.shapelight.common.utils.StringUtils; +import net.shapelight.modules.ten.entity.TenRecordEntity; +import org.springframework.stereotype.Service; + +import java.util.List; +import java.util.Map; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import net.shapelight.common.utils.PageUtils; +import net.shapelight.common.utils.Query; + +import net.shapelight.modules.ten.dao.TenDeviceOperateLogDao; +import net.shapelight.modules.ten.entity.TenDeviceOperateLogEntity; +import net.shapelight.modules.ten.service.TenDeviceOperateLogService; + + +@Service("tenDeviceOperateLogService") +public class TenDeviceOperateLogServiceImpl extends ServiceImpl implements TenDeviceOperateLogService { + + @Override + public PageUtils queryPage(Map params) { + + String sn = (String)params.get("sn"); + String recordTimeStart = (String)params.get("recordTimeStart"); + String recordTimeEnd = (String)params.get("recordTimeEnd"); + + IPage page = this.page( + new Query().getPage(params), + new QueryWrapper() + .like(!StringUtils.isNullOrEmpty(params.get("sn")),"sn",params.get("sn")) + .ge(!StringUtils.isNullOrEmpty(params.get("recordTimeStart")),"create_time",recordTimeStart) + .le(!StringUtils.isNullOrEmpty(params.get("recordTimeEnd")),"create_time",recordTimeEnd) + .orderByDesc("create_time") + ); + + return new PageUtils(page); + } + +} \ No newline at end of file diff --git a/shapelight-admin/src/main/java/net/shapelight/modules/ten/service/impl/TenDeviceServiceImpl.java b/shapelight-admin/src/main/java/net/shapelight/modules/ten/service/impl/TenDeviceServiceImpl.java index f7367c0..68f9e21 100644 --- a/shapelight-admin/src/main/java/net/shapelight/modules/ten/service/impl/TenDeviceServiceImpl.java +++ b/shapelight-admin/src/main/java/net/shapelight/modules/ten/service/impl/TenDeviceServiceImpl.java @@ -121,7 +121,12 @@ public class TenDeviceServiceImpl extends ServiceImpl queryList(Map params) { + List cellIds = new ArrayList<>(); +// cellIds.add(709832651506188289L); + String cellId = (String) params.get("cellId"); + String key = (String) params.get("key"); +// if(key == null){ +// key = ""; +// } + if (cellId != null && !cellId.isEmpty()) { + Long cellLong = Long.parseLong(cellId); + cellIds.add(cellLong); + } else { + List cells = tenCellService.queryAll(params); + for (TenCellEntity cell : cells) { + cellIds.add(cell.getCellId()); + } + } + if (cellIds.size() == 0) { + return new ArrayList<>(); + } + + List list = this.list(new QueryWrapper() + .eq("tenant_id", params.get("tenantId")) + .in("cell_id", cellIds) + ); + + return list; + } + @Override public List findByCellId(long cellId) { List devList = this.list(new QueryWrapper() @@ -166,8 +202,20 @@ public class TenDeviceServiceImpl extends ServiceImpl idList) { //删除同步人员 - for (Long devId : (List) idList) { - TenDeviceEntity deviceEntity = this.getById(devId); - tenPersonSyncService.removeByDeviceId(devId, deviceEntity.getTenantId()); - //清除通知: - serverApiService.cleanData(deviceEntity.getSn()); + if(idList.size()>0){ + for (Long devId : (List) idList) { + TenDeviceEntity deviceEntity = this.getById(devId); + tenPersonSyncService.removeByDeviceId(devId, deviceEntity.getTenantId()); + //清除通知: + serverApiService.cleanData(deviceEntity.getSn()); + } } - return removeByIds(idList); } @@ -343,6 +392,10 @@ public class TenDeviceServiceImpl extends ServiceImpl params) { List cellIds = new ArrayList<>(); @@ -57,6 +61,15 @@ public class TenFeedbackServiceImpl extends ServiceImpl()); } + 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 new PageUtils(page); } @@ -159,6 +170,17 @@ public class TenPersonServiceImpl implements TenPersonService { pageParam.setCurrent(Long.parseLong((String) params.get("page"))); pageParam.setSize(Long.parseLong((String) params.get("limit"))); IPage page = tenPersonDao.findVerifyPageAll(pageParam, cellIds, params); + for (TenPersonEntity personEntity : page.getRecords()) { + 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 new PageUtils(page); } @@ -178,6 +200,17 @@ public class TenPersonServiceImpl implements TenPersonService { pageParam.setSize(Long.parseLong((String) params.get("limit"))); IPage page = tenPersonDao.globalSearchPageAll(pageParam, cellIds, params); + for (TenPersonEntity personEntity : page.getRecords()) { + 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); + } + } + } + // for(TenPersonEntity p : page.getRecords()){ //// String cellName = tenCellService.getCellName(p.getCellId().toString()); // String buildName = tenBuildService.getBuildName(p.getBuildId(),p.getCellId()); @@ -232,6 +265,7 @@ public class TenPersonServiceImpl implements TenPersonService { String osName = System.getProperty("os.name");//获取指定键(即os.name)的系统属性,如:Windows 7。 if (!Pattern.matches("Windows.*", osName)) { +// if (Pattern.matches("Windows.*", osName)) { int res = PicSDK.getFace(tempOrgFilePath, tempFaceFilePath); if (res != 0) { log.error("图片不合格,未检测到人脸"); @@ -443,6 +477,57 @@ public class TenPersonServiceImpl implements TenPersonService { } + + + @Override + @Transactional(rollbackFor = Exception.class) + @CacheEvict(value = "TenPerson", allEntries = true) + public int save3d(TenPersonEntity entity) { +// String userFileUrl = globalValue.getImagesDir() + "/" + +// entity.getCellId().toString() + "/" + +// entity.getPersonId().toString() + "/"; +// //保存原始图片 +// String orgImageFileName = userFileUrl + "o_" + UUIDUtil.uuid() + ".jpg"; +// String faceImageFileName = userFileUrl + "s_" + UUIDUtil.uuid() + ".jpg"; + + int flag = tenPersonDao.insert(entity); + + if (flag == 1) { + //发送设备通知 + List devList = tenDeviceService.findByCellId(entity.getCellId()); + //状态是0正常,发送推送 + if (entity.getStatus().intValue() == Constant.PESON_SUATUS_NOMOR) { + for (TenDeviceVo dev : devList) { + //添加到同步表,下发设备通知 + TenPersonSyncEntity syncEntity = new TenPersonSyncEntity(); + syncEntity.setPersonId(entity.getPersonId()); + syncEntity.setTenantId(entity.getTenantId()); + syncEntity.setDeviceSn(dev.getSn()); + syncEntity.setDeviceId(dev.getDeviceId()); + syncEntity.setState(1); + syncEntity.setLastUpdateTime(entity.getLastUpdateTime()); + tenPersonSyncService.insert(syncEntity); + + //下发通知 + List list = new ArrayList<>(); + TenPersonOperationVo vo = new TenPersonOperationVo(); + vo.setUid(syncEntity.getPersonId()); + vo.setOperation(1); + vo.setLast_update_stamp(syncEntity.getLastUpdateTime()); + list.add(vo); + serverApiService.personOperation(dev.getSn(), list); + } + } + return 0; + } + return 1; + } + + + + + + //添加多个房产 @Override @Transactional(rollbackFor = Exception.class) @@ -486,6 +571,7 @@ public class TenPersonServiceImpl implements TenPersonService { String tempFaceFilePath = tempPath + tempFaceFileName; String osName = System.getProperty("os.name");//获取指定键(即os.name)的系统属性,如:Windows 7。 +// if (Pattern.matches("Windows.*", osName)) { if (!Pattern.matches("Windows.*", osName)) { int res = PicSDK.getFace(tempOrgFilePath, tempFaceFilePath); if (res != 0) { @@ -1857,24 +1943,26 @@ public class TenPersonServiceImpl implements TenPersonService { 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) { - return; - } else { - //1. 保存人脸图片 - InputStream inputStreamFace = new FileInputStream(tempFaceFilePath); - PutObjectOptions putObjectOptionsFace = new PutObjectOptions(inputStreamFace.available(), -1); - putObjectOptions.setContentType("image/jpg"); - minioClient.putObject( - minioConfig.getBucketName(), faceImageFileName, inputStreamFace, putObjectOptionsFace); - inputStreamFace.close(); - tenPerson.setFaceImage(faceImageFileName); - } - } else { - //windows 保存原始头像 - tenPerson.setFaceImage(orgImageFileName); - } +// if (!Pattern.matches("Windows.*", osName)) { +// int res = PicSDK.getFace(personModel.getOrgImage(), tempFaceFilePath); +// if (res != 0) { +// return; +// } else { +// //1. 保存人脸图片 +// InputStream inputStreamFace = new FileInputStream(tempFaceFilePath); +// PutObjectOptions putObjectOptionsFace = new PutObjectOptions(inputStreamFace.available(), -1); +// putObjectOptions.setContentType("image/jpg"); +// minioClient.putObject( +// minioConfig.getBucketName(), faceImageFileName, inputStreamFace, putObjectOptionsFace); +// inputStreamFace.close(); +// tenPerson.setFaceImage(faceImageFileName); +// } +// } else { +// //windows 保存原始头像 +// tenPerson.setFaceImage(orgImageFileName); +// } + + tenPerson.setFaceImage(orgImageFileName); // int res = PicSDK.getFace(personModel.getOrgImage(), tempFaceFilePath); @@ -2075,4 +2163,145 @@ public class TenPersonServiceImpl implements TenPersonService { public List getByHaveMobilePersonByRoomId(Long roomId) { return this.tenPersonDao.getByHaveMobilePersonByRoomId(roomId); } + + @Override + public int findAgeScopeCount(Map params) { + List cellIds = new ArrayList<>(); + String areaIdStr = (String) params.get("areaId"); + String cellIdStr = (String) params.get("cellId"); + + if (areaIdStr != null && !areaIdStr.isEmpty() && (cellIdStr == null || cellIdStr.isEmpty())) { + Long areaId = Long.parseLong(areaIdStr); + //子区域 + List allArea = tenAreaService.getSubAreaIdList(areaId); + //本区域 + allArea.add(areaId); + List cellList = tenCellService.list(new QueryWrapper() + .in("area_id", allArea)); + for (TenCellEntity cell : cellList) { + cellIds.add(cell.getCellId()); + } + } else if (cellIdStr != null && !cellIdStr.isEmpty()) { + Long cellLong = Long.parseLong(cellIdStr); + cellIds.add(cellLong); + } else { + List cells = tenCellService.queryAll(params); + for (TenCellEntity cell : cells) { + cellIds.add(cell.getCellId()); + } + } + if (cellIds.size() == 0) { + return 0; + } + return this.tenPersonDao.findAgeScopeCount(cellIds,params); + } + + @Override + public List getMonthCreate(Map params) { + List cellIds = new ArrayList<>(); + String areaIdStr = (String) params.get("areaId"); + String cellIdStr = (String) params.get("cellId"); + + if (areaIdStr != null && !areaIdStr.isEmpty() && (cellIdStr == null || cellIdStr.isEmpty())) { + Long areaId = Long.parseLong(areaIdStr); + //子区域 + List allArea = tenAreaService.getSubAreaIdList(areaId); + //本区域 + allArea.add(areaId); + List cellList = tenCellService.list(new QueryWrapper() + .in("area_id", allArea)); + for (TenCellEntity cell : cellList) { + cellIds.add(cell.getCellId()); + } + } else if (cellIdStr != null && !cellIdStr.isEmpty()) { + Long cellLong = Long.parseLong(cellIdStr); + cellIds.add(cellLong); + } else { + List cells = tenCellService.queryAll(params); + for (TenCellEntity cell : cells) { + cellIds.add(cell.getCellId()); + } + } + if (cellIds.size() == 0) { + return new ArrayList<>(); + } + return tenPersonDao.getMonthCreate(cellIds); + } + + @Override + public List getMonthDelete(Map params) { + List cellIds = new ArrayList<>(); + String areaIdStr = (String) params.get("areaId"); + String cellIdStr = (String) params.get("cellId"); + + if (areaIdStr != null && !areaIdStr.isEmpty() && (cellIdStr == null || cellIdStr.isEmpty())) { + Long areaId = Long.parseLong(areaIdStr); + //子区域 + List allArea = tenAreaService.getSubAreaIdList(areaId); + //本区域 + allArea.add(areaId); + List cellList = tenCellService.list(new QueryWrapper() + .in("area_id", allArea)); + for (TenCellEntity cell : cellList) { + cellIds.add(cell.getCellId()); + } + } else if (cellIdStr != null && !cellIdStr.isEmpty()) { + Long cellLong = Long.parseLong(cellIdStr); + cellIds.add(cellLong); + } else { + List cells = tenCellService.queryAll(params); + for (TenCellEntity cell : cells) { + cellIds.add(cell.getCellId()); + } + } + if (cellIds.size() == 0) { + return new ArrayList<>(); + } + return tenPersonDao.getMonthDelete(cellIds); + } + + @Override + public int checkByIdCardDept(String idCard, Long deptId) { + return tenPersonDao.checkByIdCardDept(idCard, deptId); + } + + @Override + public int getDeptPersonCount(Long deptId) { + return tenPersonDao.getDeptPersonCount(deptId); + } + @Override + public int checkByIdCardCell(String idCard, Long deptId) { + return tenPersonDao.checkByIdCardCell(idCard, deptId); + } + + @Override + public int getByLabel(Long labelId) { + return tenPersonDao.getByLabel(labelId); + } + + @Override + public PageUtils selectByDeptIdQueryPage(Map params) { + Long deptId = Long.parseLong((String) params.get("deptId")); + Long cellId = Long.parseLong((String) params.get("cellId")); + String key = (String) params.get("key"); + + Page pageParam = new Page(); + pageParam.setCurrent(Long.parseLong((String) params.get("page"))); + pageParam.setSize(Long.parseLong((String) params.get("limit"))); + IPage page = tenPersonDao.selectByDeptId(pageParam, deptId, cellId, key); + return new PageUtils(page); + } + + @Override + public PageUtils selectByDeptIdForGuestQueryPage(Map params) { + Long deptId = Long.parseLong((String) params.get("deptId")); + Long cellId = Long.parseLong((String) params.get("cellId")); + String key = (String) params.get("key"); + + Page pageParam = new Page(); + pageParam.setCurrent(Long.parseLong((String) params.get("page"))); + pageParam.setSize(Long.parseLong((String) params.get("limit"))); + IPage page = tenPersonDao.selectByDeptIdForGuest(pageParam, deptId, cellId, key); + return new PageUtils(page); + } } diff --git a/shapelight-admin/src/main/java/net/shapelight/modules/ten/service/impl/TenRecordServiceImpl.java b/shapelight-admin/src/main/java/net/shapelight/modules/ten/service/impl/TenRecordServiceImpl.java index 7db8240..b288225 100644 --- a/shapelight-admin/src/main/java/net/shapelight/modules/ten/service/impl/TenRecordServiceImpl.java +++ b/shapelight-admin/src/main/java/net/shapelight/modules/ten/service/impl/TenRecordServiceImpl.java @@ -58,6 +58,8 @@ public class TenRecordServiceImpl implements TenRecordService { // private EmqHttpApi emqHttpApi; @Autowired private RedisUtils redisUtils; + @Autowired + private TenCellDeptService tenCellDeptService; @Override public PageUtils queryPage(Map params) { @@ -104,6 +106,15 @@ public class TenRecordServiceImpl implements TenRecordService { TenCellEntity cell = tenCellService.getById(rec.getCellId()); person.setCellName(cell.getName()); + }else{ + if(person.getDeptId()!=null){ + TenCellDeptEntity dept = tenCellDeptService.getById(person.getDeptId()); + if(dept!=null){ + person.setDeptName(dept.getName()); + String deptAllName = tenCellDeptService.getAllParentName(dept.getDeptId()); + person.setDeptAllName(deptAllName); + } + } } rec.setPerson(person); } @@ -425,4 +436,43 @@ public class TenRecordServiceImpl implements TenRecordService { public List getMonthRecords(String start, String end, String tenantId) { return this.tenRecordDao.getMonthRecords(start, end, tenantId); } + + @Override + public PageUtils queryPageDeptRecord(Map params) { + + Long tenantId = (Long)params.get("tenantId"); + + Page pageParam = new Page(); + pageParam.setCurrent(Long.parseLong((String) params.get("page"))); + pageParam.setSize(Long.parseLong((String) params.get("limit"))); + IPage page = tenRecordDao.findPageDeptRecord(pageParam, params); + + for (TenRecordEntity rec : page.getRecords()) { + TenDeviceEntity dev = tenDeviceService.findBySn(rec.getDeviceSn()); + rec.setDeviceName(dev.getName()); + rec.setGateFlag(dev.getGateFlag()); + TenPersonEntity person = tenPersonService.getById(rec.getPersonId(), dev.getCellId()); + if (person == null) { + person = new TenPersonEntity(); +// TenRoomEntity room = tenRoomService.getById(rec.getRoomId(), rec.getCellId()); +// person.setRoomName(room.getRoomName()); + TenCellEntity cell = tenCellService.getById(rec.getCellId()); + person.setCellName(cell.getName()); +// TenBuildEntity build = tenBuildService.getById(room.getBuildId(), room.getCellId()); +// person.setBuildName(build.getName()); +// person.setBuildUnit(build.getUnit()); + }else{ + 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); + } + } + } + rec.setPerson(person); + } + return new PageUtils(page); + } } diff --git a/shapelight-admin/src/main/java/net/shapelight/modules/ten/service/impl/TenRepairServiceImpl.java b/shapelight-admin/src/main/java/net/shapelight/modules/ten/service/impl/TenRepairServiceImpl.java index dc813a3..181224e 100644 --- a/shapelight-admin/src/main/java/net/shapelight/modules/ten/service/impl/TenRepairServiceImpl.java +++ b/shapelight-admin/src/main/java/net/shapelight/modules/ten/service/impl/TenRepairServiceImpl.java @@ -1,7 +1,9 @@ package net.shapelight.modules.ten.service.impl; +import net.shapelight.modules.ten.entity.TenCellDeptEntity; import net.shapelight.modules.ten.entity.TenCellEntity; import net.shapelight.modules.ten.entity.TenPersonEntity; +import net.shapelight.modules.ten.service.TenCellDeptService; import net.shapelight.modules.ten.service.TenCellService; import net.shapelight.modules.ten.service.TenPersonService; import org.springframework.beans.factory.annotation.Autowired; @@ -27,6 +29,8 @@ public class TenRepairServiceImpl extends ServiceImpl params) { List cellIds = new ArrayList<>(); @@ -55,6 +59,15 @@ public class TenRepairServiceImpl extends ServiceImpl getBuildRooms(Long buildId) { + return tenRoomDao.getBuildRooms(buildId); + } + + @Override public String getRoomName(Long id, Long cellId) { return tenRoomDao.getRoomName(id,cellId); diff --git a/shapelight-admin/src/main/java/net/shapelight/modules/vo/AppBuildVo.java b/shapelight-admin/src/main/java/net/shapelight/modules/vo/AppBuildVo.java new file mode 100644 index 0000000..69decef --- /dev/null +++ b/shapelight-admin/src/main/java/net/shapelight/modules/vo/AppBuildVo.java @@ -0,0 +1,31 @@ +package net.shapelight.modules.vo; + +import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import com.fasterxml.jackson.databind.ser.std.ToStringSerializer; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.io.Serializable; +import java.util.List; + +@Data +public class AppBuildVo implements Serializable { + + @ApiModelProperty("楼栋ID") + @JsonSerialize(using = ToStringSerializer.class) + private Long buildId; + + /** + * 总层数 + */ + @ApiModelProperty("总层数") + private Integer layerCount; + + /** + * 总层数 + */ + @ApiModelProperty("单元") + private String nameUnit; + + private List roomList; +} diff --git a/shapelight-admin/src/main/java/net/shapelight/modules/vo/AppPersonType.java b/shapelight-admin/src/main/java/net/shapelight/modules/vo/AppPersonType.java new file mode 100644 index 0000000..fdda830 --- /dev/null +++ b/shapelight-admin/src/main/java/net/shapelight/modules/vo/AppPersonType.java @@ -0,0 +1,13 @@ +package net.shapelight.modules.vo; + +import io.swagger.models.auth.In; +import lombok.Data; + +import java.io.Serializable; + +@Data +public class AppPersonType implements Serializable { + private Long labelId; + private Integer personType; + private String typeName; +} diff --git a/shapelight-admin/src/main/java/net/shapelight/modules/vo/AppRoomVo.java b/shapelight-admin/src/main/java/net/shapelight/modules/vo/AppRoomVo.java new file mode 100644 index 0000000..2ddec77 --- /dev/null +++ b/shapelight-admin/src/main/java/net/shapelight/modules/vo/AppRoomVo.java @@ -0,0 +1,26 @@ +package net.shapelight.modules.vo; + +import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import com.fasterxml.jackson.databind.ser.std.ToStringSerializer; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.io.Serializable; + +@Data +public class AppRoomVo implements Serializable { + + @ApiModelProperty("户室ID") + @JsonSerialize(using = ToStringSerializer.class) + private Long roomId; + /** + * 房间名称 + */ + @ApiModelProperty("房间名称") + private String roomName; + /** + * 所在楼层 + */ + @ApiModelProperty("楼层") + private Integer layer; +} diff --git a/shapelight-admin/src/main/java/net/shapelight/modules/vo/TenCelldeptSelectVo.java b/shapelight-admin/src/main/java/net/shapelight/modules/vo/TenCelldeptSelectVo.java new file mode 100644 index 0000000..1d164da --- /dev/null +++ b/shapelight-admin/src/main/java/net/shapelight/modules/vo/TenCelldeptSelectVo.java @@ -0,0 +1,44 @@ +package net.shapelight.modules.vo; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.io.Serializable; +import java.util.List; + +/** + * 区域管理 + * + */ +@Data +public class TenCelldeptSelectVo implements Serializable { + private static final long serialVersionUID = 1L; + + /** + * 区域id + */ + @ApiModelProperty("部门id") + private String deptId; + /** + * 上级区域ID,一级区域为0 + */ + @ApiModelProperty("上级ID") + private String parentId; + /** + * 区域名称 + */ + @ApiModelProperty("名称") + private String name; + /** + * 上级部门名称 + */ + @ApiModelProperty("上级名称") + private String parentName; + /** + * 子区域 + * + */ + @ApiModelProperty("子部门") + private List childrenList; + +} diff --git a/shapelight-admin/src/main/java/net/shapelight/modules/vo/TenCelldeptWeVo.java b/shapelight-admin/src/main/java/net/shapelight/modules/vo/TenCelldeptWeVo.java new file mode 100644 index 0000000..1b09830 --- /dev/null +++ b/shapelight-admin/src/main/java/net/shapelight/modules/vo/TenCelldeptWeVo.java @@ -0,0 +1,44 @@ +package net.shapelight.modules.vo; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.io.Serializable; +import java.util.List; + +/** + * 区域管理 + * + */ +@Data +public class TenCelldeptWeVo implements Serializable { + private static final long serialVersionUID = 1L; + + /** + * 区域id + */ + @ApiModelProperty("部门id") + private String id; + /** + * 上级区域ID,一级区域为0 + */ + @ApiModelProperty("上级ID") + private String parentId; + /** + * 区域名称 + */ + @ApiModelProperty("名称") + private String label; + /** + * 上级部门名称 + */ + @ApiModelProperty("上级名称") + private String parentName; + /** + * 子区域 + * + */ + @ApiModelProperty("子部门") + private List children; + +} diff --git a/shapelight-admin/src/main/java/net/shapelight/modules/vo/TenPersonAllVo.java b/shapelight-admin/src/main/java/net/shapelight/modules/vo/TenPersonAllVo.java new file mode 100644 index 0000000..8f2b862 --- /dev/null +++ b/shapelight-admin/src/main/java/net/shapelight/modules/vo/TenPersonAllVo.java @@ -0,0 +1,24 @@ +package net.shapelight.modules.vo; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.io.Serializable; +import java.util.Date; + + +@Data +public class TenPersonAllVo implements Serializable { + private static final long serialVersionUID = 1L; + + @ApiModelProperty("人员ID") + private Long uid; + + /** + * 更新时间 + */ + @ApiModelProperty("更新时间") +// @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") +// @JSONField(format="yyyy-MM-dd HH:mm:ss") + private Long last_update_stamp; +} diff --git a/shapelight-admin/src/main/java/net/shapelight/modules/vo/TenPersonMonthCountVo.java b/shapelight-admin/src/main/java/net/shapelight/modules/vo/TenPersonMonthCountVo.java new file mode 100644 index 0000000..64a2193 --- /dev/null +++ b/shapelight-admin/src/main/java/net/shapelight/modules/vo/TenPersonMonthCountVo.java @@ -0,0 +1,11 @@ +package net.shapelight.modules.vo; + +import lombok.Data; + +import java.io.Serializable; + +@Data +public class TenPersonMonthCountVo implements Serializable { + private String m; + private Integer c; +} diff --git a/shapelight-admin/src/main/java/net/shapelight/modules/vo/TenRoomDeptVo.java b/shapelight-admin/src/main/java/net/shapelight/modules/vo/TenRoomDeptVo.java new file mode 100644 index 0000000..63fac91 --- /dev/null +++ b/shapelight-admin/src/main/java/net/shapelight/modules/vo/TenRoomDeptVo.java @@ -0,0 +1,16 @@ +package net.shapelight.modules.vo; + +import lombok.Data; + +import java.io.Serializable; + +@Data +public class TenRoomDeptVo implements Serializable { + private static final long serialVersionUID = 1L; + + private String name; + private String unit; + private String layer; + private String roomName; + private String roomId; +} diff --git a/shapelight-admin/src/main/java/net/shapelight/modules/vo/TenUserVo.java b/shapelight-admin/src/main/java/net/shapelight/modules/vo/TenUserVo.java index 610acaa..fbca49c 100644 --- a/shapelight-admin/src/main/java/net/shapelight/modules/vo/TenUserVo.java +++ b/shapelight-admin/src/main/java/net/shapelight/modules/vo/TenUserVo.java @@ -34,5 +34,15 @@ public class TenUserVo { private String idNumber; private Integer personClass; + private String thdFeature; + + //-------------------v5http--------------- + private String buildUnit; + private String room; + private Long deptId; + private String deptName; + private Integer labelId; + private String labelName; + } diff --git a/shapelight-admin/src/main/resources/application-dev.yml b/shapelight-admin/src/main/resources/application-dev.yml index b56a808..c51696c 100644 --- a/shapelight-admin/src/main/resources/application-dev.yml +++ b/shapelight-admin/src/main/resources/application-dev.yml @@ -3,39 +3,39 @@ spring: type: com.alibaba.druid.pool.DruidDataSource druid: driver-class-name: com.mysql.cj.jdbc.Driver - url: jdbc:mysql://192.168.10.20:3306/cell_db_v4.0_fengdong?useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai&useSSL=false&rewriteBatchedStatements=true + url: jdbc:mysql://192.168.10.20:3306/cell_db_v8_http_test?useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai&useSSL=false&rewriteBatchedStatements=true username: user password: user@server001 - initial-size: 10 - max-active: 100 - min-idle: 10 - max-wait: 60000 + initial-size: 50 + max-active: 110 + min-idle: 31 + max-wait: 110000 pool-prepared-statements: true - max-pool-prepared-statement-per-connection-size: 20 - time-between-eviction-runs-millis: 60000 - min-evictable-idle-time-millis: 300000 + max-pool-prepared-statement-per-connection-size: 22 + time-between-eviction-runs-millis: 70000 + min-evictable-idle-time-millis: 310000 #validation-query: SELECT 1 FROM DUAL test-while-idle: true - test-on-borrow: false + test-on-borrow: true test-on-return: false stat-view-servlet: - enabled: false + enabled: true url-pattern: /druid/* login-username: admin login-password: admin@A1 allow: - web-stat-filter: - enabled: false - filter: - stat: - log-slow-sql: true - slow-sql-millis: 1000 - merge-sql: false - enabled: true - db-type: mysql - wall: - config: - multi-statement-allow: true + web-stat-filter: + enabled: true + filter: + stat: + log-slow-sql: true + slow-sql-millis: 1000 + merge-sql: true + enabled: true + db-type: mysql + wall: + config: + multi-statement-allow: true #sharding.jdbc: diff --git a/shapelight-admin/src/main/resources/application.yml b/shapelight-admin/src/main/resources/application.yml index 80285ea..b670f7b 100644 --- a/shapelight-admin/src/main/resources/application.yml +++ b/shapelight-admin/src/main/resources/application.yml @@ -64,14 +64,14 @@ spring: async: request-timeout: 60000 #60秒 resources: - static-locations: file:D:/project/cell #根目录 + static-locations: file:/home/huangyifang/project/cell #根目录 #file: #文件上传目录(注意Linux和Windows上的目录结构不同) #uploadPath: D:/project/cell/temp global: http_flag: http file_path: - static-locations: D:/project/cell #根目录,必须是在static-locations下 + static-locations: /home/huangyifang/project/cell #根目录,必须是在static-locations下 temp_dir: temp images_dir: images apk_dir: apk diff --git a/shapelight-admin/src/main/resources/mapper/ten/TenAreaDao.xml b/shapelight-admin/src/main/resources/mapper/ten/TenAreaDao.xml index 80ee2b6..4849634 100644 --- a/shapelight-admin/src/main/resources/mapper/ten/TenAreaDao.xml +++ b/shapelight-admin/src/main/resources/mapper/ten/TenAreaDao.xml @@ -21,6 +21,7 @@ and ${sql_filter} + order by t1.order_num + select dept_id from ten_cell_dept where parent_id = #{value} and delete_flag = 0 + + + + + + + + \ No newline at end of file diff --git a/shapelight-admin/src/main/resources/mapper/ten/TenPersonDao.xml b/shapelight-admin/src/main/resources/mapper/ten/TenPersonDao.xml index a9f57e1..0a31ca2 100644 --- a/shapelight-admin/src/main/resources/mapper/ten/TenPersonDao.xml +++ b/shapelight-admin/src/main/resources/mapper/ten/TenPersonDao.xml @@ -52,6 +52,7 @@ + xa_sync_image, + + + + depth, + + + face_model, + + + source_file, + + + camera_param, + + + thd_feature, + + + + dept_id, + + + @@ -364,6 +388,26 @@ #{xaSyncImage,jdbcType=TINYINT}, + + + #{depth,jdbcType=VARCHAR}, + + + #{faceModel,jdbcType=VARCHAR}, + + + #{sourceFile,jdbcType=VARCHAR}, + + + #{cameraParam,jdbcType=VARCHAR}, + + + #{thdFeature,jdbcType=VARCHAR}, + + + + #{deptId,jdbcType=BIGINT}, + @@ -497,12 +541,29 @@ xa_sync_image = #{xaSyncImage,jdbcType=TINYINT}, - - camera_param = #{cameraParam,jdbcType=VARCHAR}, + + + + depth = #{depth,jdbcType=VARCHAR}, + + + face_model #{faceModel,jdbcType=VARCHAR}, source_file = #{sourceFile,jdbcType=VARCHAR}, + + camera_param = #{cameraParam,jdbcType=VARCHAR}, + + + thd_feature = #{thdFeature,jdbcType=VARCHAR}, + + + + dept_id = #{deptId,jdbcType=BIGINT}, + + + where person_id = #{personId,jdbcType=BIGINT} @@ -671,6 +732,12 @@ #{cellId} + + and p.dept_id = #{params.deptId} + + + and p.label_id = #{params.labelId} + order by p.create_time desc @@ -716,6 +783,10 @@ + + and label_id = #{params.labelId} + + @@ -962,6 +1033,189 @@ + + + + + + + + + + + + + + + + + + + + + + diff --git a/shapelight-admin/src/main/resources/mapper/ten/TenRecordDao.xml b/shapelight-admin/src/main/resources/mapper/ten/TenRecordDao.xml index 450456b..66e78ac 100644 --- a/shapelight-admin/src/main/resources/mapper/ten/TenRecordDao.xml +++ b/shapelight-admin/src/main/resources/mapper/ten/TenRecordDao.xml @@ -607,6 +607,37 @@ + + + diff --git a/shapelight-admin/src/main/resources/mapper/ten/TenRoomDao.xml b/shapelight-admin/src/main/resources/mapper/ten/TenRoomDao.xml index bd354f7..a995aef 100644 --- a/shapelight-admin/src/main/resources/mapper/ten/TenRoomDao.xml +++ b/shapelight-admin/src/main/resources/mapper/ten/TenRoomDao.xml @@ -408,6 +408,14 @@ and build_id = #{buildId} and layer = #{layer} + + + + + + + + + + + + + + diff --git a/shapelight-admin/src/test/java/gb/BinTest.java b/shapelight-admin/src/test/java/gb/BinTest.java new file mode 100644 index 0000000..9387224 --- /dev/null +++ b/shapelight-admin/src/test/java/gb/BinTest.java @@ -0,0 +1,61 @@ +package gb; + +import net.shapelight.modules.sys.service.SysDeviceLogService; + +import java.io.ByteArrayOutputStream; +import java.io.FileInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.util.Base64; + +public class BinTest { + + private static final char[] HEX_CHAR = {'0', '1', '2', '3', '4', '5', + '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'}; + + public static byte[] getImageByte(String imgPath){ + String imgFile = imgPath;// 待处理的图片 + InputStream in = null; + byte[] data = null; + String encode = null; // 返回Base64编码过的字节数组字符串 + // 对字节数组Base64编码 + try { + // 读取图片字节数组 + in = new FileInputStream(imgFile); + data = new byte[in.available()]; + in.read(data); + } catch (IOException e) { + e.printStackTrace(); + } finally { + try { + in.close(); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + return data; + } + + public static String bytesToHex2(byte[] bytes) { + char[] buf = new char[bytes.length * 2]; + int index = 0; + for(byte b : bytes) { // 利用位运算进行转换,可以看作方法一的变种 + buf[index++] = HEX_CHAR[b >>> 4 & 0xf]; + buf[index++] = HEX_CHAR[b & 0xf]; + } + + return new String(buf); + } + public static void main(String args[]){ + String url = "/home/huangyifang/tempFiles/33.jpg"; + byte[] bin = getImageByte(url); + + String binStr = bytesToHex2(bin); + System.out.println(binStr); + + + } + + +} diff --git a/shapelight-admin/src/test/java/gb/PersonBatchAdd.java b/shapelight-admin/src/test/java/gb/PersonBatchAdd.java new file mode 100644 index 0000000..f43f971 --- /dev/null +++ b/shapelight-admin/src/test/java/gb/PersonBatchAdd.java @@ -0,0 +1,207 @@ +package gb; + +import com.alibaba.fastjson.JSONObject; +import com.baomidou.mybatisplus.core.conditions.Wrapper; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import lombok.extern.slf4j.Slf4j; +import net.shapelight.AdminApplication; +import net.shapelight.common.utils.Constant; +import net.shapelight.common.utils.SnowflakeIdWorker; +import net.shapelight.common.utils.UUIDUtil; +import net.shapelight.modules.sys.entity.SysUserEntity; +import net.shapelight.modules.sys.service.SysUserService; +import net.shapelight.modules.ten.dao.TenPersonDao; +import net.shapelight.modules.ten.dao.TenRoomDao; +import net.shapelight.modules.ten.entity.*; +import net.shapelight.modules.ten.service.*; +import net.shapelight.modules.vo.TenRoomDeptVo; +import net.shapelight.modules.xian.service.XaApi; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.test.context.junit4.SpringRunner; + +import java.util.ArrayList; +import java.util.Date; +import java.util.List; + +@Slf4j +@RunWith(SpringRunner.class) +@SpringBootTest(classes = AdminApplication.class) +public class PersonBatchAdd { + + @Autowired + private TenPersonDao personDao; + @Autowired + private TenPersonService tenPersonService; + @Autowired + private TenPersonSyncService tenPersonSyncService; + @Autowired + private TenRoomService tenRoomService; + @Autowired + private TenRoomDao tenRoomDao; + @Autowired + private TenCellDeptService tenCellDeptService; + @Autowired + private SysUserService sysUserService; + @Autowired + private TenCellService tenCellService; + @Autowired + private TenLabelService tenLabelService; + + @Test + public void test1() { + + //1145677664724451334 + TenPersonEntity tenPerson = tenPersonService.getById(1146037854288216067l,1146037238358867968l); + + for(int i = 1;i<=10000;i++){ +// TenPersonEntity tenPerson = new TenPersonEntity(); + tenPerson.setMemberId(null); + long id = new SnowflakeIdWorker().nextId(); + tenPerson.setPersonId(id); + tenPerson.setUuid(UUIDUtil.uuid()); + tenPerson.setName("Wy-"+i); + tenPerson.setIdCard("61013"+(new Date()).getTime()); + personDao.insert(tenPerson); + + } + } + + @Test + public void runAllData() { + List allSysTenUser = sysUserService.findAllSysTenUser(); + //1. 获取所有运营商 + List cellList = new ArrayList<>(); + for (SysUserEntity sysTenUser : allSysTenUser) { + List allCells = this.tenCellService.list((Wrapper) (new QueryWrapper()) + .eq("tenant_id", sysTenUser.getTenantId())); + //2.在运营商下加入标签 + //保存标签 + TenLabelEntity labelEntity = new TenLabelEntity(); + labelEntity.setTenantId(sysTenUser.getTenantId()); + labelEntity.setType(5000); + labelEntity.setName("业主"); + tenLabelService.save(labelEntity); + + TenLabelEntity lable2 = new TenLabelEntity(); + lable2.setTenantId(sysTenUser.getTenantId()); + lable2.setType(5001); + lable2.setName("家属"); + tenLabelService.save(lable2); + + TenLabelEntity lable3 = new TenLabelEntity(); + lable3.setTenantId(sysTenUser.getTenantId()); + lable3.setType(5002); + lable3.setName("租户"); + tenLabelService.save(lable3); + + + //3.迁移部门数据 + for (TenCellEntity cellEntity : allCells) { + cellList.add(cellEntity); + roomToDept(cellEntity.getCellId(),sysTenUser.getTenantId()); + + //4.人员表填充dept字段 + personDept(cellEntity.getCellId(),sysTenUser.getTenantId()); + System.out.println(cellEntity.getName()+":小区数据转换完成。。。。。。。。。。。。。。。。。。。。。。。。。。"); + } + System.out.println(sysTenUser.getUsername()+":运营商转换完成。。。。。。。。。。。。。。。。。。。。。。。。。。"); + } + System.out.println("所有数据转换完成。。。。。。。。。。。。小区数量:"+cellList.size()); + for(TenCellEntity cellEntity: cellList){ + System.out.println(cellEntity.getCellId()+":"+cellEntity.getName()); + } + } + + @Test + public void runCellData() { + Long cellId = 1131959113794715655l; + Long tenantId = 1131959113794715655l; + roomToDept(cellId,tenantId); + personDept(cellId,tenantId); + } + + + + // @Test + public void roomToDept(Long cellId, Long tenantId) { +// long cellId = 842043084869992448l; +// long cellId = 854357229950730242l; + + List buildNameList = tenRoomDao.getDistinctBuild(cellId); + //插入楼栋信息 + for(TenRoomDeptVo buildName: buildNameList){ + TenCellDeptEntity build = new TenCellDeptEntity(); + build.setCellId(cellId); + build.setParentId(cellId); + build.setName(buildName.getName()); + build.setLable("楼栋"); + build.setTenantId(tenantId); + tenCellDeptService.save(build); + + //单元信息 + List unitList = tenRoomDao.getDistinctUnit(cellId,buildName.getName()); + for(TenRoomDeptVo unitName: unitList){ + TenCellDeptEntity unit = new TenCellDeptEntity(); + unit.setCellId(cellId); + unit.setParentId(build.getDeptId()); + unit.setName(unitName.getUnit()+"单元"); + unit.setLable("单元"); + unit.setTenantId(tenantId); + tenCellDeptService.save(unit); + + //楼层 + List layerList = tenRoomDao.getDistinctLayer(cellId,buildName.getName(),unitName.getUnit()); + for(TenRoomDeptVo layerName: layerList){ + TenCellDeptEntity layer = new TenCellDeptEntity(); + layer.setCellId(cellId); + layer.setParentId(unit.getDeptId()); + layer.setName(layerName.getLayer()+"层"); + layer.setLable("楼层"); + layer.setTenantId(tenantId); + tenCellDeptService.save(layer); + + //房间 + List roomList = tenRoomDao.getDistinctRoom(cellId,buildName.getName(),unitName.getUnit(),layerName.getLayer()); + for(TenRoomDeptVo roomName: roomList){ + TenCellDeptEntity room = new TenCellDeptEntity(); + room.setCellId(cellId); + room.setParentId(layer.getDeptId()); + room.setName(roomName.getRoomName()); + room.setLable("房间"); + room.setOther(roomName.getRoomId()); + room.setTenantId(tenantId); + tenCellDeptService.save(room); + } + } + } + } + } + + + // @Test + public void personDept(Long cellId,Long tenantId) { +// long cellId = 842043084869992448l; +// long cellId = 854357229950730242l; + List roomDeptList = tenCellDeptService.list(new QueryWrapper() + .eq("cell_id",cellId) + .eq("lable","房间")); + for(TenCellDeptEntity cellDeptEntity: roomDeptList){ + List personList = tenPersonService.getByRoomId(Long.parseLong(cellDeptEntity.getOther()),cellId,null); + for(TenPersonEntity personEntity: personList){ + personEntity.setDeptId(cellDeptEntity.getDeptId()); + if(personEntity.getPersonType() == 5000 || personEntity.getPersonType() == 5001 || personEntity.getPersonType() == 5002){ + TenLabelEntity labelEntity = tenLabelService.getOne(new QueryWrapper() + .eq("type",personEntity.getPersonType()) + .eq("tenant_id",tenantId)); + if(labelEntity!=null){ + personEntity.setLabelId(labelEntity.getLabelId().intValue()); + } + } + tenPersonService.updateNonal(personEntity); + } + } + } +} diff --git a/version8.txt b/version8.txt new file mode 100644 index 0000000..e069d57 --- /dev/null +++ b/version8.txt @@ -0,0 +1,117 @@ +v4.0 +1.sys_device_type表 启用other字段,0表示2d,1表示3d,v4.0加入,空表示2d +2.ten_device表增加两个字段,识别阈值:recognize_score_3d,检测方式:detection_type +3.ten_person表增加5个字段:depth,face_model,source_file,camera_param +4.ten_record表增加8个字段:depth,source_file,duration,threshold,distance,score3d,temperature,camera_param + + +v4.0 数据库修改内容 +alter table ten_device_copy1 +ADD COLUMN recognize_score3d varchar(30) DEFAULT '62,65' COMMENT '3d识别阈值', +ADD COLUMN detection_type tinyint(1) DEFAULT 0 COMMENT '0:默认2d检测, 1:3d检测'; + + +alter table ten_person_copy1 +ADD COLUMN depth varchar(200) COMMENT '深度图片', +ADD COLUMN face_model varchar(200) COMMENT '脸模', +ADD COLUMN source_file varchar(200) COMMENT '源文件', +ADD COLUMN camera_param varchar(200) COMMENT '相机参数'; + +alter table ten_record_9999999999999 +ADD COLUMN depth varchar(200) COMMENT '深度图片', +ADD COLUMN source_file varchar(200) COMMENT '源文件', +ADD COLUMN camera_param varchar(200) COMMENT '相机参数', +ADD COLUMN duration int(11) COMMENT '耗时', +ADD COLUMN threshold varchar(50) COMMENT '阈值', +ADD COLUMN distance float COMMENT '距离', +ADD COLUMN score3d varchar(50) COMMENT '分数', +ADD COLUMN temperature float COMMENT '体温'; + + + + + +------------------------v8.0 http协议版本,数据库更新说明:先执行以下sql语句,在跑批处理程序----------------- +1.ten_device表增加字段:app_language,lat,lon +2.ten_person表增加字段:thd_feature,dept_id +3.ten_person表person_type字段默认5000 +4.sys_menu表增加4条参数2001,2002,2003,2004 +5.ten_company表增加type_id字段关联 +6.ten_label表type字段类型修改为int +7.增加表 ten_cell_dept +8.增加表 ten_device_operate_log +9.增加表 ten_company_type +10.页面修改角色 + + + +alter table ten_device ADD COLUMN app_language tinyint(1) DEFAULT 0 COMMENT 'app版本'; +alter table ten_device ADD COLUMN lat varchar(50) DEFAULT '' COMMENT '纬度'; +alter table ten_device ADD COLUMN lon varchar(50) DEFAULT '' COMMENT '经度'; + +alter table ten_person ADD COLUMN thd_feature varchar(1024) COMMENT '3d特征'; +alter table ten_person ADD COLUMN dept_id bigint(20) COMMENT '部门id'; +alter table ten_person ALTER COLUMN person_type SET DEFAULT 5000; + +INSERT INTO `sys_menu` VALUES (2001, 3, '设备Log', 'sys/deviceLog', 'sys:devicelog', 1, 'shebei', 6, 'system_devicelog'); +INSERT INTO `sys_menu` VALUES (2002, 1210, '操作记录', 'ten/deviceoperatelog', 'ten:deviceoperatelog', 1, 'shebei', 6, 'tenant_deviceoperatelog'); +INSERT INTO `sys_menu` VALUES (2003, 1234, '组织管理', 'ten/celldept', 'ten:celldept', 1, 'shebei', 6, 'tenant_celldept'); +INSERT INTO `sys_menu` VALUES (2004, 1220, '单位类别', 'ten/companytype', 'ten:companytype', 1, 'shebei', 6, 'tenant_companytype'); + +alter table ten_company ADD COLUMN type_id bigint(20) COMMENT '类别id'; + +ALTER TABLE ten_label MODIFY COLUMN type INT(11); + +CREATE TABLE `ten_cell_dept` ( + `dept_id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '部门/楼栋', + `parent_id` bigint(20) DEFAULT NULL COMMENT '父级目录', + `cell_id` bigint(20) NOT NULL COMMENT '小区ID', + `name` varchar(200) DEFAULT NULL COMMENT '名称', + `lable` varchar(100) DEFAULT NULL COMMENT '标签', + `lat` varchar(50) DEFAULT '' COMMENT '纬度', + `lon` varchar(50) DEFAULT '' COMMENT '经度', + `other` varchar(200) DEFAULT '' COMMENT '其他', + `remark` varchar(100) DEFAULT '' COMMENT '备注', + `picture` varchar(1024) DEFAULT '' COMMENT '照片', + `create_time` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', + `create_by` varchar(100) DEFAULT '' COMMENT '创建人', + `last_update_time` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '更新时间', + `last_update_by` varchar(100) DEFAULT '' COMMENT '更新人', + `delete_flag` tinyint(1) DEFAULT '0' COMMENT '0未删除1删除', + `tenant_id` bigint(20) unsigned zerofill DEFAULT '00000000000000000000' COMMENT '运营商ID', + `xa_sync` tinyint(1) DEFAULT '0' COMMENT '第三方是否同步1是0否默认0', + `p_id` int(18) DEFAULT NULL COMMENT '地址序号', + `dzbm` varchar(100) DEFAULT NULL COMMENT '地址编码', + `is_room` tinyint(1) DEFAULT '0' COMMENT '是否是户室0否1是', + `room_type` tinyint(1) DEFAULT '0' COMMENT '类型:自住,出租', + PRIMARY KEY (`dept_id`) +) ENGINE=InnoDB AUTO_INCREMENT=37291 DEFAULT CHARSET=utf8mb4; + +CREATE TABLE `ten_company_type` ( + `type_id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT 'ID', + `name` varchar(100) DEFAULT '' COMMENT '标签名称', + `create_time` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', + `create_by` varchar(100) DEFAULT '' COMMENT '创建人', + `last_update_time` datetime DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间', + `last_update_by` varchar(100) DEFAULT '' COMMENT '更新人', + `delete_flag` tinyint(1) DEFAULT '0' COMMENT '0未删除1删除', + `tenant_id` bigint(20) NOT NULL COMMENT '运营商ID', + PRIMARY KEY (`type_id`) USING BTREE +) ENGINE=InnoDB AUTO_INCREMENT=10033 DEFAULT CHARSET=utf8mb4 ROW_FORMAT=DYNAMIC COMMENT='标签'; + +CREATE TABLE `ten_device_operate_log` ( + `log_id` bigint(20) NOT NULL AUTO_INCREMENT, + `sn` varchar(100) DEFAULT NULL, + `create_time` datetime DEFAULT NULL COMMENT '创建时间', + `operation` varchar(200) DEFAULT NULL COMMENT '用户操作', + `tenant_id` bigint(20) DEFAULT NULL COMMENT '运营商Id', + PRIMARY KEY (`log_id`) +) ENGINE=InnoDB AUTO_INCREMENT=667 DEFAULT CHARSET=utf8mb4; + +CREATE TABLE `sys_device_log` ( + `log_id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT 'id', + `sn` varchar(50) DEFAULT NULL, + `create_time` datetime DEFAULT NULL, + `log` varchar(16000) DEFAULT NULL, + PRIMARY KEY (`log_id`) USING BTREE +) ENGINE=InnoDB AUTO_INCREMENT=418 DEFAULT CHARSET=utf8mb4; \ No newline at end of file