v8:http协议,组织结构

This commit is contained in:
gaoben 2023-09-20 14:35:52 +08:00
parent 08e5a3e44d
commit 1651e392cc
80 changed files with 4760 additions and 188 deletions

View File

@ -29,7 +29,7 @@
<java.version>1.8</java.version>
<junit.version>4.12</junit.version>
<jedis.version>2.9.0</jedis.version>
<druid.version>1.1.18</druid.version>
<druid.version>1.2.13</druid.version>
<mybatisplus.version>3.1.2</mybatisplus.version>
<mysql.version>8.0.25</mysql.version>
<mssql.version>4.0</mssql.version>
@ -38,7 +38,7 @@
<commons.fileupload.version>1.3.1</commons.fileupload.version>
<commons.io.version>2.5</commons.io.version>
<commons.codec.version>1.10</commons.codec.version>
<fastjson.version>1.2.75</fastjson.version>
<fastjson.version>1.2.78</fastjson.version>
<joda.time.version>2.9.9</joda.time.version>
<lombok.version>1.18.4</lombok.version>
<swagger.version>2.7.0</swagger.version>
@ -75,6 +75,10 @@
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-redis</artifactId>
</dependency>
<!-- <dependency>-->
<!-- <groupId>org.springframework.boot</groupId>-->
<!-- <artifactId>spring-boot-starter-validation</artifactId>-->
<!-- </dependency>-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-configuration-processor</artifactId>

View File

@ -11,7 +11,7 @@
<properties>
<quartz.version>2.3.0</quartz.version>
<shiro.version>1.7.0</shiro.version>
<shiro.version>1.10.0</shiro.version>
<jwt.version>0.7.0</jwt.version>
<kaptcha.version>0.0.9</kaptcha.version>
<!--<qiniu.version>[7.2.0, 7.2.99]</qiniu.version>-->
@ -32,16 +32,16 @@
<artifactId>spring-boot-starter-data-redis</artifactId>
</dependency>
<dependency>
<groupId>redis.clients</groupId>
<artifactId>jedis</artifactId>
<version>2.9.0</version>
</dependency>
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-redis</artifactId>
<version>2.1.10.RELEASE</version>
</dependency>
<!-- <dependency>-->
<!-- <groupId>redis.clients</groupId>-->
<!-- <artifactId>jedis</artifactId>-->
<!-- <version>2.9.0</version>-->
<!-- </dependency>-->
<!-- <dependency>-->
<!-- <groupId>org.springframework.data</groupId>-->
<!-- <artifactId>spring-data-redis</artifactId>-->
<!-- <version>2.1.10.RELEASE</version>-->
<!-- </dependency>-->
<dependency>
<groupId>org.apache.commons</groupId>
@ -83,6 +83,11 @@
<artifactId>shiro-spring</artifactId>
<version>${shiro.version}</version>
</dependency>
<dependency>
<groupId>org.apache.shiro</groupId>
<artifactId>shiro-ehcache</artifactId>
<version>${shiro.version}</version>
</dependency>
<dependency>
<groupId>com.github.axet</groupId>
<artifactId>kaptcha</artifactId>

View File

@ -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);

View File

@ -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;
}
}
}

View File

@ -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;

View File

@ -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; //禁用

View File

@ -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<TenLabelEntity>()
.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,8 +488,12 @@ public class AppApiController {
// }
int r = serverApiService.openDoor(deviceSn,personId);
if(r == -1){
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<TenLabelEntity>()
.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.getPersonType() == 5000 || tenPerson.getPersonType() == 5001 || tenPerson.getPersonType() == 5002){
TenLabelEntity labelEntity = tenLabelService.getOne(new QueryWrapper<TenLabelEntity>()
.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("身份证在组织已存在");
}
}
if(tenPerson.getIdCard()!=null){
TenPersonEntity tenPersonIdcard = tenPersonService.findByIdCard(tenPerson.getIdCard(),
tenPerson.getRoomId(),tenPerson.getCellId());
if(tenPersonIdcard!=null){
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<TenPersonEntity>)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<TenPersonEntity>)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<TenPersonEntity>)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<String, Object> params = new HashMap<String, Object>();
// params.put("tenantId",tenantId+"");
// String cellId = (String)params.get("cellId");
List<TenCellDeptEntity> areaList = tenCellDeptService.list(new QueryWrapper<TenCellDeptEntity>()
.eq("cell_id",cellId));
List<TenCelldeptWeVo> 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<String, Object> params = new HashMap<String, Object>();
//// params.put("tenantId",tenantId+"");
//// String cellId = (String)params.get("cellId");
// List<TenCellDeptEntity> areaList = tenCellDeptService.list(new QueryWrapper<TenCellDeptEntity>()
// .eq("parent_id",parentId));
// List<TenCelldeptSelectVo> 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);
// }
}

View File

@ -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);
}
}

View File

@ -184,16 +184,16 @@ public class PersonExcelListener extends AnalysisEventListener<PersonModel> {
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);

View File

@ -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();
}
}

View File

@ -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);
}
}
}

View File

@ -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 {
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);
}
}else{
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());

View File

@ -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<String, Object> 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();
// }
}

View File

@ -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<SysDeviceLogEntity> {
}

View File

@ -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;
}

View File

@ -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<SysDeviceLogEntity> {
PageUtils queryPage(Map<String, Object> params);
}

View File

@ -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<SysDeviceLogDao, SysDeviceLogEntity> implements SysDeviceLogService {
@Override
public PageUtils queryPage(Map<String, Object> params) {
String sn = (String)params.get("sn");
String recordTimeStart = (String)params.get("recordTimeStart");
String recordTimeEnd = (String)params.get("recordTimeEnd");
IPage<SysDeviceLogEntity> page = this.page(
new Query<SysDeviceLogEntity>().getPage(params),
new QueryWrapper<SysDeviceLogEntity>()
.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);
}
}

View File

@ -40,6 +40,8 @@ public class SysDeviceServiceImpl extends ServiceImpl<SysDeviceDao, SysDeviceEnt
private SysUserService sysUserService;
@Autowired
private DeviceApiService deviceApiService;
@Autowired
private RedisUtils redisUtils;
@Override
public PageUtils queryPage(Map<String, Object> params) {
@ -64,9 +66,14 @@ public class SysDeviceServiceImpl extends ServiceImpl<SysDeviceDao, SysDeviceEnt
boolean onlineFlag = deviceApiService.isOnline(deviceEntity.getSn());
if(onlineFlag){
deviceEntity.setStatus(1);
}else{
if(redisUtils.get("DeviceLogin-"+deviceEntity.getSn())!=null){
deviceEntity.setStatus(1);
}else{
deviceEntity.setStatus(0);
}
// deviceEntity.setStatus(0);
}
SysUserEntity u = sysUserService.getById(tenDeviceEntity.getTenantId());
if(u!=null){
deviceEntity.setTenantName(u.getCompanyName());

View File

@ -41,9 +41,11 @@ import net.shapelight.modules.sys.shiro.ShiroUtils;
//import net.shapelight.modules.ten.service.TenMenuService;
//import net.shapelight.modules.ten.service.TenUserService;
import net.shapelight.modules.ten.entity.TenCellEntity;
import net.shapelight.modules.ten.entity.TenLabelEntity;
import net.shapelight.modules.ten.entity.TenPersonEntity;
import net.shapelight.modules.ten.entity.TenUserScopeEntity;
import net.shapelight.modules.ten.service.TenCellService;
import net.shapelight.modules.ten.service.TenLabelService;
import net.shapelight.modules.ten.service.TenPersonService;
import net.shapelight.modules.ten.service.TenUserScopeService;
import org.apache.commons.beanutils.BeanUtils;
@ -83,6 +85,8 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserDao, SysUserEntity> i
private AppUserScopeService appUserScopeService;
@Autowired
private TenCellService tenCellService;
@Autowired
private TenLabelService tenLabelService;
@Override
public List<String> queryAllPerms(Long userId) {
@ -260,6 +264,25 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserDao, SysUserEntity> 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());
}

View File

@ -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<Long> ids = new ArrayList<>();
//删除运营商下所有设备
List<TenDeviceEntity> devList = tenDeviceService.list(new QueryWrapper<TenDeviceEntity>()
.eq("tenant_id",userIds[0]));
for(TenDeviceEntity entity: devList){
ids.add(entity.getDeviceId());
}
tenDeviceService.evictRemoveByIds(ids);
return R.ok();
}

View File

@ -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<String, Object> params){
String cellId = (String)params.get("cellId");
// PageUtils page = tenCellDeptService.queryPage(params);
List<TenCellDeptEntity> page = tenCellDeptService.list(new QueryWrapper<TenCellDeptEntity>()
.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<Long> 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<String, Object> params = new HashMap<String, Object>();
// params.put("tenantId",tenantId+"");
// String cellId = (String)params.get("cellId");
List<TenCellDeptEntity> areaList = tenCellDeptService.list(new QueryWrapper<TenCellDeptEntity>()
.eq("cell_id",cellId));
List<TenCelldeptSelectVo> 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<String, Object> params = new HashMap<String, Object>();
// params.put("tenantId",tenantId+"");
// String cellId = (String)params.get("cellId");
List<TenCellDeptEntity> areaList = tenCellDeptService.list(new QueryWrapper<TenCellDeptEntity>()
.eq("cell_id",cellId));
List<TenCelldeptSelectVo> 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<String, Object> params){
String cellId = (String)params.get("cellId");
// PageUtils page = tenCellDeptService.queryPage(params);
List<TenCellDeptEntity> page = tenCellDeptService.list(new QueryWrapper<TenCellDeptEntity>()
.eq("parent_id",cellId));
for(TenCellDeptEntity cellDeptEntity: page){
int count = tenCellDeptService.count(new QueryWrapper<TenCellDeptEntity>()
.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<String, Object> params){
String parentId = (String)params.get("deptId");
List<TenCellDeptEntity> page = tenCellDeptService.list(new QueryWrapper<TenCellDeptEntity>()
.eq("parent_id",parentId));
for(TenCellDeptEntity cellDeptEntity: page){
int count = tenCellDeptService.count(new QueryWrapper<TenCellDeptEntity>()
.eq("parent_id",cellDeptEntity.getDeptId()));
if(count > 0){
cellDeptEntity.setHasChildren(true);
}else{
cellDeptEntity.setHasChildren(false);
}
}
return R.ok().put("data", page);
}
}

View File

@ -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();
}

View File

@ -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<String, Object> 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<TenCompanyEntity>()
.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<TenCompanyTypeEntity> page = tenCompanyTypeService.list(new QueryWrapper<TenCompanyTypeEntity>()
.eq("tenant_id",getUser().getTenantId()));
return R.ok().put("data", page);
}
}

View File

@ -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<TenUserScopeEntity>().eq("user_id",user.getUserId()));
params.put("cellId",scope.getCellId().toString());
}
List<TenBuildEntity> bList = tenBuildService.queryAll(params);
List<TenBuildVo> 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<TenBuildEntity> bList = tenBuildService.queryAll(params);
// List<TenBuildVo> 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<TenBuildVo> bVoLIst = new ArrayList<>();
List<TenDeviceEntity> 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<Integer> 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<String,Object> 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<Integer> 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<String,Object> 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<TenLabelEntity> labelList = tenLabelService.list(new QueryWrapper<TenLabelEntity>()
.eq("tenant_id",getUser().getTenantId()));
//其他标签
// Iterator<TenLabelEntity> 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<NameValueClass> 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<maxSize;i++){
data.add(dataYeZhu.get(i));
}
NameValueClass other = new NameValueClass();
int otherCount = 0;
for(int j = maxSize;j<dataYeZhu.size();j++){
otherCount+=dataYeZhu.get(j).getValue();
}
other.setName("其他");
other.setValue(otherCount);
data.add(other);
}
return R.ok().put("data", data).put("allCount",personCount);
}
@ -260,35 +397,51 @@ public class TenDataViewController extends AbstractController {
//获取单位总数
int cCount = tenCompanyService.getAllCount(params);
int yule = Constant.COMPANY_TYPE_YULE;
params.put("type",yule+"");
int yuleCount = tenCompanyService.getAllCount(params);
int jiguan = Constant.COMPANY_TYPE_JIGUAN;
params.put("type",jiguan+"");
int jiguanCount = tenCompanyService.getAllCount(params);
int qita = Constant.COMPANY_TYPE_QITA;
params.put("type",qita+"");
int qitaCount = tenCompanyService.getAllCount(params);
int yonggong = Constant.COMPANY_TYPE_YONGGONG;
params.put("type",yonggong+"");
int yonggongCount = tenCompanyService.getAllCount(params);
int chuzu = Constant.COMPANY_TYPE_CHUZU;
params.put("type",chuzu+"");
int chuzuCount = tenCompanyService.getAllCount(params);
// int yule = Constant.COMPANY_TYPE_YULE;
// params.put("type",yule+"");
// int yuleCount = tenCompanyService.getAllCount(params);
//
// int jiguan = Constant.COMPANY_TYPE_JIGUAN;
// params.put("type",jiguan+"");
// int jiguanCount = tenCompanyService.getAllCount(params);
//
// int qita = Constant.COMPANY_TYPE_QITA;
// params.put("type",qita+"");
// int qitaCount = tenCompanyService.getAllCount(params);
//
// int yonggong = Constant.COMPANY_TYPE_YONGGONG;
// params.put("type",yonggong+"");
// int yonggongCount = tenCompanyService.getAllCount(params);
//
// int chuzu = Constant.COMPANY_TYPE_CHUZU;
// params.put("type",chuzu+"");
// int chuzuCount = tenCompanyService.getAllCount(params);
//
//
// Map<String,Object> 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<String,Object> 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<TenCompanyTypeEntity> typeList = tenCompanyTypeService.list(new QueryWrapper<TenCompanyTypeEntity>()
.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<String, Object> params){
String tenantId = getUser().getTenantId()+"";
params.put("tenantId",tenantId+"");
SysUserEntity user = getUser();
List<Long> roleIdList = sysUserRoleService.queryRoleIdList(user.getUserId());
//小区管理员
if(roleIdList.get(0).longValue() == Constant.ROLE_TEN_CELL){
TenUserScopeEntity scope = tenUserScopeService.getOne(new QueryWrapper<TenUserScopeEntity>().eq("user_id",user.getUserId()));
params.put("cellId",scope.getCellId().toString());
}
//获取范围130以下
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<String,Object> 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<String, Object> params){
String tenantId = getUser().getTenantId()+"";
params.put("tenantId",tenantId+"");
SysUserEntity user = getUser();
List<Long> roleIdList = sysUserRoleService.queryRoleIdList(user.getUserId());
//小区管理员
if(roleIdList.get(0).longValue() == Constant.ROLE_TEN_CELL){
TenUserScopeEntity scope = tenUserScopeService.getOne(new QueryWrapper<TenUserScopeEntity>().eq("user_id",user.getUserId()));
params.put("cellId",scope.getCellId().toString());
}
List<TenPersonMonthCountVo> cList = tenPersonService.getMonthCreate(params);
List<TenPersonMonthCountVo> dList = tenPersonService.getMonthDelete(params);
Map<String,Object> 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;
}
}

View File

@ -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,8 +206,17 @@ public class TenDeviceController extends AbstractController {
//清除数据
int r = serverApiService.restart(sn);
if(r == -1){
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,9 +342,16 @@ public class TenDeviceController extends AbstractController {
}
//配置推送
int r = serverApiService.devConfig(tenDevice.getSn(),config);
// if(r == -1){
// return R.error("设备离线");
// }
if(r == -1){
if(redisUtils.get("DeviceLogin-"+tenDevice.getSn())!=null){
//设置
}else{
return R.error("设备离线");
}
}
tenDeviceService.evictupdateById(tenDevice);
return R.ok();
}

View File

@ -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<String, Object> 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();
}
}

View File

@ -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<TenLabelEntity> list = tenLabelService.list(new QueryWrapper<TenLabelEntity>()
.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<TenLabelEntity> list = tenLabelService.list(new QueryWrapper<TenLabelEntity>()
.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();
}

View File

@ -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<Integer> personTypeList = new ArrayList<>();
List<TenLabelEntity> tenLabel = tenLabelService.list(new QueryWrapper<TenLabelEntity>()
.eq("tenant_id",getUser().getTenantId()));
personTypeList.add(Constant.PERSON_TYPE_OWNER);
personTypeList.add(Constant.PERSON_TYPE_MEMBER);
personTypeList.add(Constant.PERSON_TYPE_TENANT);
@ -278,6 +284,7 @@ public class TenPersonController extends AbstractController {
.eq("user_id",tenantId));
person.setTenantName(sysUserEntity.getCompanyName());
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
@ -286,7 +293,16 @@ public class TenPersonController extends AbstractController {
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);
}

View File

@ -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<TenCellDeptEntity> {
/**
* 查询子区域ID列表
* @param parentId 上级区域ID
*/
List<Long> queryDeptIdList(Long parentId);
String getDeptName(@Param("deptId")Long deptId);
String getAllParentName(@Param("deptId")Long deptId);
}

View File

@ -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<TenCompanyTypeEntity> {
}

View File

@ -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<TenDeviceOperateLogEntity> {
}

View File

@ -12,4 +12,6 @@ import org.apache.ibatis.annotations.Param;
@Mapper
public interface TenLabelDao extends BaseMapper<TenLabelEntity> {
String getLabelName(@Param("labelId")Long labelId);
String getLabelTypeName(@Param("type")Long type, @Param("tenantId")Long tenantId);
}

View File

@ -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<TenPersonEntity> getByHaveMobilePersonByRoomId(@Param("roomId") Long roomId);
int findAgeScopeCount(@Param("cellIds") List<Long> cellIds,@Param("params") Map params);
List<TenPersonMonthCountVo> getMonthCreate(@Param("cellIds") List<Long> cellIds);
List<TenPersonMonthCountVo> getMonthDelete(@Param("cellIds") List<Long> 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<TenPersonEntity> selectByDeptId(Page page,@Param("deptId")Long deptId, @Param("cellId")Long cellId, @Param("key")String key);
IPage<TenPersonEntity> selectByDeptIdForGuest(Page page,@Param("deptId")Long deptId, @Param("cellId")Long cellId, @Param("key")String key);

View File

@ -45,4 +45,5 @@ public interface TenRecordDao {
List<TenRecordEntity> getMonthRecords(@Param("start") String start, @Param("end") String end, @Param("tenantId") String tenantId);
IPage<TenRecordEntity> findPageDeptRecord(Page page, @Param("params") Map params);
}

View File

@ -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<TenRoomEntity> getBuildRooms(@Param("buildId")Long buildId);
@ -52,4 +56,8 @@ public interface TenRoomDao {
List<TenRoomEntity> getPicByCellId(@Param("pId") Long pId,@Param("cellId") Long paramLong);
List<TenRoomDeptVo> getDistinctBuild(@Param("cellId") Long paramLong);
List<TenRoomDeptVo> getDistinctUnit(@Param("cellId") Long paramLong, @Param("buildName")String buildName);
List<TenRoomDeptVo> getDistinctLayer(@Param("cellId") Long paramLong,@Param("buildName")String buildName,@Param("unit")String unit);
List<TenRoomDeptVo> getDistinctRoom(@Param("cellId") Long paramLong,@Param("buildName")String buildName,@Param("unit")String unit,@Param("layer")String layer);
}

View File

@ -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<TenCellDeptEntity> childrenList = new ArrayList<>();
@TableField(exist=false)
private boolean hasChildren = true;
/**
* 上级部门名称
*/
@ApiModelProperty("上级部门名称")
@TableField(exist=false)
private String parentName;
@TableField(exist=false)
private Integer personCount;
}

View File

@ -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;
}

View File

@ -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;
}

View File

@ -255,4 +255,9 @@ public class TenDeviceEntity extends BaseEntity implements Serializable {
private Integer detectionType;
//--------------------v5http协议增加--------------
private Integer appLanguage;
private String lat;
private String lon;
}

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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<TenCellDeptEntity> {
PageUtils queryPage(Map<String, Object> params);
List<Long> getSubDeptIdList(Long areaId);
/**
* 查询子部门ID列表
* @param parentId 上级部门ID
*/
List<Long> queryDeptIdList(Long parentId);
String getAllParentName(Long deptId);
}

View File

@ -15,5 +15,9 @@ public interface TenCompanyService extends IService<TenCompanyEntity> {
PageUtils queryPage(Map<String, Object> params);
int getAllCount(Map<String, Object> params);
int getAllCountTypeId(Map<String, Object> params);
}

View File

@ -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<TenCompanyTypeEntity> {
PageUtils queryPage(Map<String, Object> params);
}

View File

@ -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<TenDeviceOperateLogEntity> {
PageUtils queryPage(Map<String, Object> params);
}

View File

@ -67,6 +67,8 @@ public interface TenDeviceService extends IService<TenDeviceEntity> {
List<TenDeviceEntity> getNotSync(Long cellId);
List<TenDeviceEntity> queryList(Map<String, Object> params);
}

View File

@ -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<String, Object> 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<TenPersonEntity> getByHaveMobilePersonByRoomId(Long roomId);
int findAgeScopeCount(Map<String, Object> params);
List<TenPersonMonthCountVo> getMonthCreate(Map<String, Object> params);
List<TenPersonMonthCountVo> getMonthDelete(Map<String, Object> params);
int checkByIdCardDept(String idCard, Long deptId);
int getDeptPersonCount(Long deptId);
int checkByIdCardCell(String idCard, Long cellId);
int getByLabel(Long labelId);
PageUtils selectByDeptIdQueryPage(Map<String, Object> params);
PageUtils selectByDeptIdForGuestQueryPage(Map<String, Object> params);
}

View File

@ -42,5 +42,7 @@ public interface TenRecordService {
List<TenRecordEntity> getMonthRecords(String start, String end, String tenantId);
PageUtils queryPageDeptRecord(Map<String, Object> params);
}

View File

@ -37,6 +37,8 @@ public interface TenRoomService {
Long buildId,
Long cellId);
List<TenRoomEntity> getBuildRooms(Long buildId);
String getRoomName(Long id, Long cellId);

View File

@ -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<TenCellDeptDao, TenCellDeptEntity> implements TenCellDeptService {
@Override
public PageUtils queryPage(Map<String, Object> params) {
String cellId = (String)params.get("cellID");
IPage<TenCellDeptEntity> page = this.page(
new Query<TenCellDeptEntity>().getPage(params),
new QueryWrapper<TenCellDeptEntity>()
.eq("cell_id",cellId)
);
return new PageUtils(page);
}
@Override
public List<Long> getSubDeptIdList(Long areaId){
//部门及子部门ID列表
List<Long> deptIdList = new ArrayList<>();
//获取子部门ID
List<Long> subIdList = queryDeptIdList(areaId);
getDeptTreeList(subIdList, deptIdList);
return deptIdList;
}
@Override
public List<Long> queryDeptIdList(Long parentId) {
return baseMapper.queryDeptIdList(parentId);
}
/**
* 递归
*/
private void getDeptTreeList(List<Long> subIdList, List<Long> areaIdList){
for(Long deptId : subIdList){
List<Long> list = queryDeptIdList(deptId);
if(list.size() > 0){
getDeptTreeList(list, areaIdList);
}
areaIdList.add(deptId);
}
}
@Override
public String getAllParentName(Long deptId) {
return baseMapper.getAllParentName(deptId);
}
}

View File

@ -106,7 +106,7 @@ public class TenCellServiceImpl extends ServiceImpl<TenCellDao, TenCellEntity> i
// @Cacheable(value="TenCell", key="#name-#tenantId")
@Cacheable(value = "TenCell", key = "#name+'-'+#tenantId")
public TenCellEntity findByCellName(String name, String tenantId) {
return getOne(new QueryWrapper<TenCellEntity>().eq("name", name));
return getOne(new QueryWrapper<TenCellEntity>().eq("name", name).eq("tenant_id",tenantId));
}
@Override

View File

@ -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<TenCompanyDao, TenCompany
@Autowired
private TenCellService tenCellService;
@Autowired
private TenCompanyTypeService tenCompanyTypeService;
@Override
public PageUtils queryPage(Map<String, Object> params) {
String name = (String) params.get("name");
@ -52,6 +56,14 @@ public class TenCompanyServiceImpl extends ServiceImpl<TenCompanyDao, TenCompany
.in("cell_id",cellIds)
.like("name",name)
);
for(TenCompanyEntity entity: page.getRecords()){
if(entity.getTypeId()!=null){
TenCompanyTypeEntity typeEntity = tenCompanyTypeService.getById(entity.getTypeId());
if(typeEntity!=null){
entity.setTypeName(typeEntity.getName());
}
}
}
return new PageUtils(page);
}
@ -84,4 +96,35 @@ public class TenCompanyServiceImpl extends ServiceImpl<TenCompanyDao, TenCompany
}
return list.size();
}
@Override
public int getAllCountTypeId(Map<String, Object> params) {
List<Long> 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<TenCellEntity> cells = tenCellService.queryAll(params);
for (TenCellEntity cell : cells) {
cellIds.add(cell.getCellId());
}
}
if (cellIds.size() == 0) {
return 0;
}
// List<TenCompanyEntity> list = new ArrayList<>();
int count = 0;
if(params.get("typeId")!=null){
count = this.count(new QueryWrapper<TenCompanyEntity>()
.in("cell_id",cellIds)
.eq("type_id",params.get("typeId")));
}else{
count = this.count(new QueryWrapper<TenCompanyEntity>()
.in("cell_id",cellIds));
}
return count;
}
}

View File

@ -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<TenCompanyTypeDao, TenCompanyTypeEntity> implements TenCompanyTypeService {
@Autowired
private TenCompanyService tenCompanyService;
@Override
public PageUtils queryPage(Map<String, Object> params) {
IPage<TenCompanyTypeEntity> page = this.page(
new Query<TenCompanyTypeEntity>().getPage(params),
new QueryWrapper<TenCompanyTypeEntity>()
.eq("tenant_id",params.get("tenantId"))
.like("name",params.get("name"))
);
for(TenCompanyTypeEntity entity: page.getRecords()){
int count = tenCompanyService.count(new QueryWrapper<TenCompanyEntity>()
.eq("type_id",entity.getTypeId()));
entity.setCompanyCount(count);
}
return new PageUtils(page);
}
}

View File

@ -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<TenDeviceOperateLogDao, TenDeviceOperateLogEntity> implements TenDeviceOperateLogService {
@Override
public PageUtils queryPage(Map<String, Object> params) {
String sn = (String)params.get("sn");
String recordTimeStart = (String)params.get("recordTimeStart");
String recordTimeEnd = (String)params.get("recordTimeEnd");
IPage<TenDeviceOperateLogEntity> page = this.page(
new Query<TenDeviceOperateLogEntity>().getPage(params),
new QueryWrapper<TenDeviceOperateLogEntity>()
.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);
}
}

View File

@ -120,9 +120,14 @@ public class TenDeviceServiceImpl extends ServiceImpl<TenDeviceDao, TenDeviceEnt
Boolean flag = deviceApiService.isOnline(dev.getSn());
if (flag) {
dev.setStatus(1);
} else {
//redisUtils.set("DeviceLogin-"+sn,DateUtils.format(new Date(),DateUtils.DATE_TIME_PATTERN),60l);//保存
if(redisUtils.get("DeviceLogin-"+dev.getSn())!=null){
dev.setStatus(1);
}else{
dev.setStatus(0);
}
}
//缓存
// redisUtils.set("HearTBeat-"+sn,faceCount+"="+DateUtils.format(new Date(),DateUtils.DATE_TIME_PATTERN),31536000l);//保存一年
@ -147,6 +152,37 @@ public class TenDeviceServiceImpl extends ServiceImpl<TenDeviceDao, TenDeviceEnt
return new PageUtils(page);
}
@Override
public List<TenDeviceEntity> queryList(Map<String, Object> params) {
List<Long> 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<TenCellEntity> cells = tenCellService.queryAll(params);
for (TenCellEntity cell : cells) {
cellIds.add(cell.getCellId());
}
}
if (cellIds.size() == 0) {
return new ArrayList<>();
}
List<TenDeviceEntity> list = this.list(new QueryWrapper<TenDeviceEntity>()
.eq("tenant_id", params.get("tenantId"))
.in("cell_id", cellIds)
);
return list;
}
@Override
public List<TenDeviceVo> findByCellId(long cellId) {
List<TenDeviceEntity> devList = this.list(new QueryWrapper<TenDeviceEntity>()
@ -165,9 +201,21 @@ public class TenDeviceServiceImpl extends ServiceImpl<TenDeviceDao, TenDeviceEnt
Boolean flag = deviceApiService.isOnline(dev.getSn());
if (flag) {
dev.setStatus(1);
} else {
//redisUtils.set("DeviceLogin-"+sn,DateUtils.format(new Date(),DateUtils.DATE_TIME_PATTERN),60l);//保存
if(redisUtils.get("DeviceLogin-"+dev.getSn())!=null){
dev.setStatus(1);
}else{
dev.setStatus(0);
}
}
// Boolean flag = deviceApiService.isOnline(dev.getSn());
// if (flag) {
// dev.setStatus(1);
// } else {
// dev.setStatus(0);
// }
TenDeviceVo vo = new TenDeviceVo();
try {
BeanUtils.copyProperties(vo, dev);
@ -291,13 +339,14 @@ public class TenDeviceServiceImpl extends ServiceImpl<TenDeviceDao, TenDeviceEnt
@Transactional(rollbackFor = Exception.class)
public boolean evictRemoveByIds(Collection<? extends Serializable> idList) {
//删除同步人员
if(idList.size()>0){
for (Long devId : (List<Long>) 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<TenDeviceDao, TenDeviceEnt
boolean onlineFlag = deviceApiService.isOnline(dev.getSn());
if (onlineFlag) {
onlineCount++;
}else{
if(redisUtils.get("DeviceLogin-"+dev.getSn())!=null){
onlineCount++;
}
}
}
}

View File

@ -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;
@ -28,6 +30,8 @@ public class TenFeedbackServiceImpl extends ServiceImpl<TenFeedbackDao, TenFeedb
private TenCellService tenCellService;
@Autowired
private TenPersonService tenPersonService;
@Autowired
private TenCellDeptService tenCellDeptService;
@Override
public PageUtils queryPage(Map<String, Object> params) {
List<Long> cellIds = new ArrayList<>();
@ -57,6 +61,15 @@ public class TenFeedbackServiceImpl extends ServiceImpl<TenFeedbackDao, TenFeedb
feedbackEntity.setPerson(new TenPersonEntity());
continue;
}
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 new PageUtils(page);
}
@ -74,6 +87,14 @@ public class TenFeedbackServiceImpl extends ServiceImpl<TenFeedbackDao, TenFeedb
for(TenFeedbackEntity entity: page.getRecords()){
TenPersonEntity person = tenPersonService.getById(entity.getPersonId(),entity.getCellId());
if(person !=null){
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);
}
}
entity.setPerson(person);
}else{
continue;
@ -93,6 +114,14 @@ public class TenFeedbackServiceImpl extends ServiceImpl<TenFeedbackDao, TenFeedb
for(TenFeedbackEntity entity: page.getRecords()){
TenPersonEntity person = tenPersonService.getById(entity.getPersonId(),entity.getCellId());
if(person !=null){
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);
}
}
entity.setPerson(person);
}else{
continue;

View File

@ -84,6 +84,8 @@ public class TenPersonServiceImpl implements TenPersonService {
private TenPersonSyncService tenPersonSyncService;
@Autowired
private TenPersonExtractService tenPersonExtractService;
@Autowired
private TenCellDeptService tenCellDeptService;
@Override
@ -133,6 +135,15 @@ public class TenPersonServiceImpl implements TenPersonService {
personEntity.setExtractCount(0);
personEntity.setExtractList(new ArrayList<>());
}
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<TenPersonEntity> 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<TenPersonEntity> 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<TenDeviceVo> 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<TenPersonOperationVo> 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 保存原始头像
// 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<TenPersonEntity> getByHaveMobilePersonByRoomId(Long roomId) {
return this.tenPersonDao.getByHaveMobilePersonByRoomId(roomId);
}
@Override
public int findAgeScopeCount(Map<String, Object> params) {
List<Long> 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<Long> allArea = tenAreaService.getSubAreaIdList(areaId);
//本区域
allArea.add(areaId);
List<TenCellEntity> cellList = tenCellService.list(new QueryWrapper<TenCellEntity>()
.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<TenCellEntity> 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<TenPersonMonthCountVo> getMonthCreate(Map<String, Object> params) {
List<Long> 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<Long> allArea = tenAreaService.getSubAreaIdList(areaId);
//本区域
allArea.add(areaId);
List<TenCellEntity> cellList = tenCellService.list(new QueryWrapper<TenCellEntity>()
.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<TenCellEntity> 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<TenPersonMonthCountVo> getMonthDelete(Map<String, Object> params) {
List<Long> 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<Long> allArea = tenAreaService.getSubAreaIdList(areaId);
//本区域
allArea.add(areaId);
List<TenCellEntity> cellList = tenCellService.list(new QueryWrapper<TenCellEntity>()
.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<TenCellEntity> 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<String, Object> 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<TenPersonEntity> page = tenPersonDao.selectByDeptId(pageParam, deptId, cellId, key);
return new PageUtils(page);
}
@Override
public PageUtils selectByDeptIdForGuestQueryPage(Map<String, Object> 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<TenPersonEntity> page = tenPersonDao.selectByDeptIdForGuest(pageParam, deptId, cellId, key);
return new PageUtils(page);
}
}

View File

@ -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<String, Object> 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<TenRecordEntity> getMonthRecords(String start, String end, String tenantId) {
return this.tenRecordDao.getMonthRecords(start, end, tenantId);
}
@Override
public PageUtils queryPageDeptRecord(Map<String, Object> 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<TenRecordEntity> 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);
}
}

View File

@ -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<TenRepairDao, TenRepairEnt
private TenCellService tenCellService;
@Autowired
private TenPersonService tenPersonService;
@Autowired
private TenCellDeptService tenCellDeptService;
@Override
public PageUtils queryPage(Map<String, Object> params) {
List<Long> cellIds = new ArrayList<>();
@ -55,6 +59,15 @@ public class TenRepairServiceImpl extends ServiceImpl<TenRepairDao, TenRepairEnt
}else{
feedbackEntity.setPerson(new TenPersonEntity());
}
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 new PageUtils(page);
}
@ -70,6 +83,14 @@ public class TenRepairServiceImpl extends ServiceImpl<TenRepairDao, TenRepairEnt
for(TenRepairEntity entity: page.getRecords()){
TenPersonEntity person = tenPersonService.getById(entity.getPersonId(),entity.getCellId());
if(person !=null){
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);
}
}
entity.setPerson(person);
}else{
continue;
@ -89,6 +110,14 @@ public class TenRepairServiceImpl extends ServiceImpl<TenRepairDao, TenRepairEnt
for(TenRepairEntity entity: page.getRecords()){
TenPersonEntity person = tenPersonService.getById(entity.getPersonId(),entity.getCellId());
if(person !=null){
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);
}
}
entity.setPerson(person);
}else{
continue;

View File

@ -167,6 +167,12 @@ public class TenRoomServiceImpl implements TenRoomService {
return tenRoomDao.getLayerRooms(layer, buildId, cellId);
}
@Override
public List<TenRoomEntity> getBuildRooms(Long buildId) {
return tenRoomDao.getBuildRooms(buildId);
}
@Override
public String getRoomName(Long id, Long cellId) {
return tenRoomDao.getRoomName(id,cellId);

View File

@ -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<AppRoomVo> roomList;
}

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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<TenCelldeptSelectVo> childrenList;
}

View File

@ -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<TenCelldeptWeVo> children;
}

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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;
}

View File

@ -3,34 +3,34 @@ 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
enabled: true
filter:
stat:
log-slow-sql: true
slow-sql-millis: 1000
merge-sql: false
merge-sql: true
enabled: true
db-type: mysql
wall:

View File

@ -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

View File

@ -21,6 +21,7 @@
<if test="sql_filter != null">
and ${sql_filter}
</if>
order by t1.order_num
</select>
<select id="querySelectList" resultType="map">

View File

@ -0,0 +1,55 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="net.shapelight.modules.ten.dao.TenCellDeptDao">
<!-- 可根据自己的需求,是否要使用 -->
<resultMap type="net.shapelight.modules.ten.entity.TenCellDeptEntity" id="tenCellDeptMap">
<result property="deptId" column="dept_id"/>
<result property="parentId" column="parent_id"/>
<result property="cellId" column="cell_id"/>
<result property="name" column="name"/>
<result property="lable" column="lable"/>
<result property="lat" column="lat"/>
<result property="lon" column="lon"/>
<result property="other" column="other"/>
<result property="remark" column="remark"/>
<result property="picture" column="picture"/>
<result property="createTime" column="create_time"/>
<result property="createBy" column="create_by"/>
<result property="lastUpdateTime" column="last_update_time"/>
<result property="lastUpdateBy" column="last_update_by"/>
<result property="deleteFlag" column="delete_flag"/>
<result property="tenantId" column="tenant_id"/>
<result property="xaSync" column="xa_sync"/>
<result property="pId" column="p_id"/>
<result property="dzbm" column="dzbm"/>
<result property="isRoom" column="is_room"/>
<result property="roomType" column="room_type"/>
</resultMap>
<select id="queryDeptIdList" resultType="long">
select dept_id from ten_cell_dept where parent_id = #{value} and delete_flag = 0
</select>
<select id="getDeptName" resultType="string">
select name from ten_cell_dept where dept_id = #{deptId}
</select>
<select id="getAllParentName" resultType="string">
select group_concat(name SEPARATOR "/") from(
SELECT T2.dept_id, T2.name
FROM (
SELECT @r AS _id,
(SELECT @r := parent_id FROM ten_cell_dept WHERE dept_id = _id) AS parent_id,
@l := @l + 1 AS lvl
FROM
(SELECT @r := #{deptId}, @l := 0) vars, ten_cell_dept h WHERE @r &lt;> 0) T1
JOIN ten_cell_dept T2
ON T1._id = T2.dept_id
ORDER BY T1.lvl DESC) as f
</select>
</mapper>

View File

@ -52,6 +52,7 @@
<result column="face_model" jdbcType="VARCHAR" property="faceModel" />
<result column="source_file" jdbcType="VARCHAR" property="sourceFile" />
<result column="camera_param" jdbcType="VARCHAR" property="cameraParam" />
<result column="dept_id" jdbcType="BIGINT" property="deptId" />
<association property="cellName" javaType="String"
select="net.shapelight.modules.ten.dao.TenCellDao.getCellName"
@ -236,6 +237,29 @@
<if test="xaSyncImage != null">
xa_sync_image,
</if>
<if test="depth != null">
depth,
</if>
<if test="faceModel != null">
face_model,
</if>
<if test="sourceFile != null">
source_file,
</if>
<if test="cameraParam != null">
camera_param,
</if>
<if test="thdFeature != null">
thd_feature,
</if>
<if test="deptId != null">
dept_id,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="personId != null">
@ -364,6 +388,26 @@
<if test="xaSyncImage != null">
#{xaSyncImage,jdbcType=TINYINT},
</if>
<if test="depth != null">
#{depth,jdbcType=VARCHAR},
</if>
<if test="faceModel != null">
#{faceModel,jdbcType=VARCHAR},
</if>
<if test="sourceFile != null">
#{sourceFile,jdbcType=VARCHAR},
</if>
<if test="cameraParam != null">
#{cameraParam,jdbcType=VARCHAR},
</if>
<if test="thdFeature != null">
#{thdFeature,jdbcType=VARCHAR},
</if>
<if test="deptId != null">
#{deptId,jdbcType=BIGINT},
</if>
</trim>
</insert>
@ -497,12 +541,29 @@
<if test="xaSyncImage != null">
xa_sync_image = #{xaSyncImage,jdbcType=TINYINT},
</if>
<if test="cameraParam != null">
camera_param = #{cameraParam,jdbcType=VARCHAR},
<if test="depth != null">
depth = #{depth,jdbcType=VARCHAR},
</if>
<if test="faceModel != null">
face_model #{faceModel,jdbcType=VARCHAR},
</if>
<if test="sourceFile != null">
source_file = #{sourceFile,jdbcType=VARCHAR},
</if>
<if test="cameraParam != null">
camera_param = #{cameraParam,jdbcType=VARCHAR},
</if>
<if test="thdFeature != null">
thd_feature = #{thdFeature,jdbcType=VARCHAR},
</if>
<if test="deptId != null">
dept_id = #{deptId,jdbcType=BIGINT},
</if>
</set>
where person_id = #{personId,jdbcType=BIGINT}
</update>
@ -671,6 +732,12 @@
#{cellId}
</foreach>
</if>
<if test="params.deptId != null and params.deptId!=''">
and p.dept_id = #{params.deptId}
</if>
<if test="params.labelId != null and params.labelId!=''">
and p.label_id = #{params.labelId}
</if>
order by p.create_time desc
@ -716,6 +783,10 @@
</foreach>
</if>
<if test="params.labelId != null and params.labelId!=''">
and label_id = #{params.labelId}
</if>
</select>
@ -962,6 +1033,189 @@
<select id="findAgeScopeCount" resultType="int">
select count(*) from
(select
if (CHAR_LENGTH(id_card) &lt; 18,(substring(now(),1,4)-(1900+substring(id_card,7,2)))-(substring(id_card,9,4)-date_format(now(),'%m%d')>0),(substring(now(),1,4)-substring(id_card,7,4))-(substring(id_card,11,4)-date_format(now(),'%m%d')>0)) as age
from ten_person where delete_flag = 0
<if test="cellIds != null">
and cell_id in
<foreach item="cellId" collection="cellIds" open="(" separator="," close=")">
#{cellId}
</foreach>
</if>
) as age_t
where 1 = 1
<if test="params.min != null">
and age > #{params.min}
</if>
<if test="params.max != null">
and age &lt;= #{params.max}
</if>
</select>
<select id="getMonthCreate" resultType="net.shapelight.modules.vo.TenPersonMonthCountVo">
select MONTH(NOW()) as m,count(*) as c from ten_person where delete_flag = 0 and MONTH(create_time) = MONTH(NOW())
<if test="cellIds != null">
and cell_id in
<foreach item="cellId" collection="cellIds" open="(" separator="," close=")">
#{cellId}
</foreach>
</if>
UNION
select MONTH(DATE_SUB(NOW(), INTERVAL 1 MONTH)) as m,count(*) as c from ten_person where delete_flag = 0 and MONTH(create_time) = MONTH(DATE_SUB(NOW(), INTERVAL 1 MONTH))
<if test="cellIds != null">
and cell_id in
<foreach item="cellId" collection="cellIds" open="(" separator="," close=")">
#{cellId}
</foreach>
</if>
UNION
select MONTH(DATE_SUB(NOW(), INTERVAL 2 MONTH)) as m,count(*) as c from ten_person where delete_flag = 0 and MONTH(create_time) = MONTH(DATE_SUB(NOW(), INTERVAL 2 MONTH))
<if test="cellIds != null">
and cell_id in
<foreach item="cellId" collection="cellIds" open="(" separator="," close=")">
#{cellId}
</foreach>
</if>
UNION
select MONTH(DATE_SUB(NOW(), INTERVAL 3 MONTH)) as m,count(*) as c from ten_person where delete_flag = 0 and MONTH(create_time) = MONTH(DATE_SUB(NOW(), INTERVAL 3 MONTH))
<if test="cellIds != null">
and cell_id in
<foreach item="cellId" collection="cellIds" open="(" separator="," close=")">
#{cellId}
</foreach>
</if>
UNION
select MONTH(DATE_SUB(NOW(), INTERVAL 4 MONTH)) as m,count(*) as c from ten_person where delete_flag = 0 and MONTH(create_time) = MONTH(DATE_SUB(NOW(), INTERVAL 4 MONTH))
<if test="cellIds != null">
and cell_id in
<foreach item="cellId" collection="cellIds" open="(" separator="," close=")">
#{cellId}
</foreach>
</if>
UNION
select MONTH(DATE_SUB(NOW(), INTERVAL 5 MONTH)) as m,count(*) as c from ten_person where delete_flag = 0 and MONTH(create_time) = MONTH(DATE_SUB(NOW(), INTERVAL 5 MONTH))
<if test="cellIds != null">
and cell_id in
<foreach item="cellId" collection="cellIds" open="(" separator="," close=")">
#{cellId}
</foreach>
</if>
UNION
select MONTH(DATE_SUB(NOW(), INTERVAL 6 MONTH)) as m,count(*) as c from ten_person where delete_flag = 0 and MONTH(create_time) = MONTH(DATE_SUB(NOW(), INTERVAL 6 MONTH))
<if test="cellIds != null">
and cell_id in
<foreach item="cellId" collection="cellIds" open="(" separator="," close=")">
#{cellId}
</foreach>
</if>
</select>
<select id="getMonthDelete" resultType="net.shapelight.modules.vo.TenPersonMonthCountVo">
select MONTH(NOW()) as m,count(*) as c from ten_person where delete_flag = 1 and MONTH(last_update_time) = MONTH(NOW())
<if test="cellIds != null">
and cell_id in
<foreach item="cellId" collection="cellIds" open="(" separator="," close=")">
#{cellId}
</foreach>
</if>
UNION
select MONTH(DATE_SUB(NOW(), INTERVAL 1 MONTH)) as m,count(*) as c from ten_person where delete_flag = 1 and MONTH(last_update_time) = MONTH(DATE_SUB(NOW(), INTERVAL 1 MONTH))
<if test="cellIds != null">
and cell_id in
<foreach item="cellId" collection="cellIds" open="(" separator="," close=")">
#{cellId}
</foreach>
</if>
UNION
select MONTH(DATE_SUB(NOW(), INTERVAL 2 MONTH)) as m,count(*) as c from ten_person where delete_flag = 1 and MONTH(last_update_time) = MONTH(DATE_SUB(NOW(), INTERVAL 2 MONTH))
<if test="cellIds != null">
and cell_id in
<foreach item="cellId" collection="cellIds" open="(" separator="," close=")">
#{cellId}
</foreach>
</if>
UNION
select MONTH(DATE_SUB(NOW(), INTERVAL 3 MONTH)) as m,count(*) as c from ten_person where delete_flag = 1 and MONTH(last_update_time) = MONTH(DATE_SUB(NOW(), INTERVAL 3 MONTH))
<if test="cellIds != null">
and cell_id in
<foreach item="cellId" collection="cellIds" open="(" separator="," close=")">
#{cellId}
</foreach>
</if>
UNION
select MONTH(DATE_SUB(NOW(), INTERVAL 4 MONTH)) as m,count(*) as c from ten_person where delete_flag = 1 and MONTH(last_update_time) = MONTH(DATE_SUB(NOW(), INTERVAL 4 MONTH))
<if test="cellIds != null">
and cell_id in
<foreach item="cellId" collection="cellIds" open="(" separator="," close=")">
#{cellId}
</foreach>
</if>
UNION
select MONTH(DATE_SUB(NOW(), INTERVAL 5 MONTH)) as m,count(*) as c from ten_person where delete_flag = 1 and MONTH(last_update_time) = MONTH(DATE_SUB(NOW(), INTERVAL 5 MONTH))
<if test="cellIds != null">
and cell_id in
<foreach item="cellId" collection="cellIds" open="(" separator="," close=")">
#{cellId}
</foreach>
</if>
UNION
select MONTH(DATE_SUB(NOW(), INTERVAL 6 MONTH)) as m,count(*) as c from ten_person where delete_flag = 1 and MONTH(last_update_time) = MONTH(DATE_SUB(NOW(), INTERVAL 6 MONTH))
<if test="cellIds != null">
and cell_id in
<foreach item="cellId" collection="cellIds" open="(" separator="," close=")">
#{cellId}
</foreach>
</if>
</select>
<select id="checkByIdCardDept" resultType="int">
select count(person_id) from ten_person where delete_flag = 0
and id_card = #{idCard} and dept_id = #{deptId}
</select>
<select id="getDeptPersonCount" resultType="int">
select count(person_id) from ten_person where delete_flag = 0 and dept_id = #{deptId}
</select>
<select id="checkByIdCardCell" resultType="int">
select count(person_id) from ten_person where delete_flag = 0
and id_card = #{idCard} and cell_id = #{cellId}
and (person_type = 5006 or person_type = 5005)
</select>
<select id="getByLabel" resultType="int">
select count(person_id) from ten_person where delete_flag = 0
and label_id = #{labelId}
</select>
<select id="selectByDeptId" resultMap="BaseResultMap">
select p.* from ten_person p where p.dept_id = #{deptId} and p.delete_flag = 0
and p.person_type in(5000,5001,5002)
<if test="key != null and key!=''">
and (p.name like CONCAT('%', '${key}', '%')
or p.mobile like CONCAT('%', '${key}', '%'))
</if>
order by p.person_id desc
</select>
<select id="selectByDeptIdForGuest" resultMap="BaseResultMap">
select p.* from ten_person p where p.dept_id = #{deptId} and p.delete_flag = 0
and p.person_type = 5005
<if test="key != null and key!=''">
and (p.name like CONCAT('%', '${key}', '%')
or p.mobile like CONCAT('%', '${key}', '%'))
</if>
</select>
</mapper>

View File

@ -607,6 +607,37 @@
</select>
<select id="findPageDeptRecord" resultMap="tenRecordMap">
select rec.* from (select r.*,t.name from ten_record_${params.tenantId} r
left join ten_person t on r.person_id = t.person_id
where 1 = 1
<if test="params.cellId != null and params.cellId!=''">
and r.cell_id = #{params.cellId}
</if>
<if test="params.roomId != null and params.roomId!=''">
and t.room_id = #{params.roomId}
</if>
<if test="params.name != null and params.name!=''">
and `name` like CONCAT('%', '${params.name}', '%')
</if>
<if test="params.recordTimeStart != null and params.recordTimeStart!=''">
and `record_time` &gt;= #{params.recordTimeStart}
</if>
<if test="params.recordTimeEnd != null and params.recordTimeStart!=''">
and `record_time` &lt; #{params.recordTimeEnd}
</if>
<if test="params.deptId != null and params.deptId!=''">
and t.dept_id = #{params.deptId}
</if>
order by record_time desc) as rec left join ten_device d on rec.device_sn = d.sn
where d.tenant_id = #{params.tenantId}
and d.delete_flag = 0
</select>
</mapper>

View File

@ -408,6 +408,14 @@
and build_id = #{buildId} and layer = #{layer}
</select>
<select id="getBuildRooms" resultType="net.shapelight.modules.ten.entity.TenRoomEntity">
select * from ten_room where delete_flag = 0
and build_id = #{buildId}
</select>
<select id="getRoomName" resultType="string">
select room_name from ten_room
where room_id = #{roomId,jdbcType=BIGINT}
@ -433,6 +441,31 @@
</select>
<select id="getDistinctBuild" resultType="net.shapelight.modules.vo.TenRoomDeptVo">
select DISTINCT b.name from ten_room r
left join ten_build b
on r.build_id = b.build_id where r.delete_flag = 0 and r.cell_id = #{cellId}
</select>
<select id="getDistinctUnit" resultType="net.shapelight.modules.vo.TenRoomDeptVo">
select DISTINCT b.name,b.unit from ten_room r
left join ten_build b
on r.build_id = b.build_id where r.delete_flag = 0 and r.cell_id = #{cellId} and b.name = #{buildName}
</select>
<select id="getDistinctLayer" resultType="net.shapelight.modules.vo.TenRoomDeptVo">
select DISTINCT b.name,b.unit,r.layer from ten_room r
left join ten_build b
on r.build_id = b.build_id where r.delete_flag = 0 and r.cell_id = #{cellId} and b.name = #{buildName} and unit = #{unit}
</select>
<select id="getDistinctRoom" resultType="net.shapelight.modules.vo.TenRoomDeptVo">
select DISTINCT b.name,b.unit,r.layer,r.room_name,r.room_id from ten_room r
left join ten_build b
on r.build_id = b.build_id where r.delete_flag = 0 and r.cell_id = #{cellId} and b.name = #{buildName} and unit = #{unit} and layer = #{layer}
</select>
</mapper>

View File

@ -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);
}
}

View File

@ -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<SysUserEntity> allSysTenUser = sysUserService.findAllSysTenUser();
//1. 获取所有运营商
List<TenCellEntity> cellList = new ArrayList<>();
for (SysUserEntity sysTenUser : allSysTenUser) {
List<TenCellEntity> 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<TenRoomDeptVo> 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<TenRoomDeptVo> 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<TenRoomDeptVo> 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<TenRoomDeptVo> 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<TenCellDeptEntity> roomDeptList = tenCellDeptService.list(new QueryWrapper<TenCellDeptEntity>()
.eq("cell_id",cellId)
.eq("lable","房间"));
for(TenCellDeptEntity cellDeptEntity: roomDeptList){
List<TenPersonEntity> 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<TenLabelEntity>()
.eq("type",personEntity.getPersonType())
.eq("tenant_id",tenantId));
if(labelEntity!=null){
personEntity.setLabelId(labelEntity.getLabelId().intValue());
}
}
tenPersonService.updateNonal(personEntity);
}
}
}
}

117
version8.txt Normal file
View File

@ -0,0 +1,117 @@
v4.0
1.sys_device_type表 启用other字段0表示2d,1表示3dv4.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检测 13d检测';
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条参数20012002,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;