增加设备端接口全量获取和单一获取人员信息,修改下发设备增加原图base64
This commit is contained in:
parent
0e8d979236
commit
b00f593c61
6
pom.xml
6
pom.xml
|
@ -248,6 +248,12 @@
|
|||
<artifactId>gson</artifactId>
|
||||
<version>${gson.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>net.coobird</groupId>
|
||||
<artifactId>thumbnailator</artifactId>
|
||||
<version>0.4.13</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<!-- 阿里云maven仓库 -->
|
||||
|
|
|
@ -260,6 +260,8 @@ public class AppApiController {
|
|||
int res = tenPersonService.save(tenPerson);
|
||||
if (res==2) {
|
||||
return R.error("照片未检测到人脸");
|
||||
}else if(res == 10){
|
||||
return R.error("文件不存在");
|
||||
}
|
||||
return R.ok();
|
||||
}
|
||||
|
|
|
@ -0,0 +1,46 @@
|
|||
package net.shapelight.modules.car.controller;
|
||||
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiImplicitParam;
|
||||
import io.swagger.annotations.ApiImplicitParams;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import net.shapelight.common.utils.R;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 停车接口
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/api/car/v1")
|
||||
@Api("停车接口")
|
||||
@Slf4j
|
||||
public class CarOpenApi {
|
||||
|
||||
@PostMapping("/getMsg/{cellId}")
|
||||
@ApiOperation(value = "获取Msg")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name="sn",value = "设备SN",paramType = "query",dataType = "String",required = true),
|
||||
})
|
||||
public R getMsg(@PathVariable("cellId") Long cellId,@RequestParam Map<String, Object> params){
|
||||
|
||||
JSONObject msgJson = JSONObject.parseObject((String)params.get("Msg"));
|
||||
switch ((Integer) msgJson.get("command")){
|
||||
case 1://1-主动上传进出记录,
|
||||
break;
|
||||
case 13://13-主动上传车辆信息
|
||||
break;
|
||||
case 19://19-主动上传本地修改车辆信息
|
||||
break;
|
||||
case 20://20-主动上传本地注销车辆信息
|
||||
|
||||
}
|
||||
|
||||
return R.ok();
|
||||
}
|
||||
}
|
|
@ -9,6 +9,7 @@ import io.swagger.annotations.ApiImplicitParam;
|
|||
import io.swagger.annotations.ApiImplicitParams;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import net.coobird.thumbnailator.Thumbnails;
|
||||
import net.shapelight.common.config.GlobalValue;
|
||||
import net.shapelight.common.config.MinioConfig;
|
||||
import net.shapelight.common.utils.*;
|
||||
|
@ -22,6 +23,7 @@ import net.shapelight.modules.ten.entity.TenPersonEntity;
|
|||
import net.shapelight.modules.ten.entity.TenRecordEntity;
|
||||
import net.shapelight.modules.ten.service.*;
|
||||
import net.shapelight.modules.vo.TenDoorCardVo;
|
||||
import net.shapelight.modules.vo.TenPersonIdUpdateVo;
|
||||
import net.shapelight.modules.vo.TenPersonVo;
|
||||
import org.apache.commons.beanutils.BeanUtils;
|
||||
import org.apache.commons.io.FilenameUtils;
|
||||
|
@ -37,7 +39,9 @@ import org.springframework.web.client.RestTemplate;
|
|||
import org.springframework.web.multipart.MultipartFile;
|
||||
import org.springframework.web.util.UriComponentsBuilder;
|
||||
|
||||
import javax.imageio.ImageIO;
|
||||
import javax.swing.text.html.parser.Entity;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.*;
|
||||
import java.net.URI;
|
||||
import java.util.*;
|
||||
|
@ -107,6 +111,170 @@ public class DeviceController {
|
|||
}
|
||||
|
||||
|
||||
@PostMapping("/getAllPerson")
|
||||
@ApiOperation(value = "获取全部人员id和lastupdatetime",response = TenPersonVo.class)
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name="sn",value = "设备SN",paramType = "query",dataType = "String",required = true),
|
||||
})
|
||||
public R getAllPerson(@RequestBody Map<String, Object> params){
|
||||
// AppSecret sec = new AppSecret();
|
||||
// BeanUtils.copyProperties(params, sec);
|
||||
// int checkIn = sec.check();
|
||||
// if(checkIn!=0){
|
||||
// return R.error("Authentication failure:"+checkIn);
|
||||
// }
|
||||
String lastUpdateTime = (String)params.get("lastUpdateTime");
|
||||
String sn = (String)params.get("sn");
|
||||
TenDeviceEntity dev = tenDeviceService.findBySn(sn);
|
||||
if (dev==null) {
|
||||
return R.error("设备未绑定");
|
||||
}
|
||||
|
||||
List<TenPersonIdUpdateVo> list = tenDeviceService.findAllPersonIdUpdate(dev.getCellId(),
|
||||
dev.getBuildId(),
|
||||
dev.getRoomId());
|
||||
log.info("获取人员信息:sn:"+sn+"-"+lastUpdateTime+" count:"+list.size());
|
||||
return R.ok().put("data",list);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@PostMapping("/getOnePerson")
|
||||
@ApiOperation(value = "获取一个人的信息",response = TenPersonVo.class)
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name="sn",value = "设备SN",paramType = "query",dataType = "String",required = true),
|
||||
@ApiImplicitParam(name="memberId",value = "人员id",paramType = "query",dataType = "String",required = true),
|
||||
})
|
||||
public R getOnePerson(@RequestBody Map<String, Object> params){
|
||||
// AppSecret sec = new AppSecret();
|
||||
// BeanUtils.copyProperties(params, sec);
|
||||
// int checkIn = sec.check();
|
||||
// if(checkIn!=0){
|
||||
// return R.error("Authentication failure:"+checkIn);
|
||||
// }
|
||||
String sn = (String)params.get("sn");
|
||||
TenDeviceEntity dev = tenDeviceService.findBySn(sn);
|
||||
if (dev==null) {
|
||||
return R.error("设备未绑定");
|
||||
}
|
||||
|
||||
Integer memberId = (Integer)params.get("memberId");
|
||||
TenPersonEntity p = tenPersonService.getByMemberId(memberId,dev.getCellId());
|
||||
TenPersonVo vo = new TenPersonVo();
|
||||
if (p!=null) {
|
||||
try {
|
||||
|
||||
BeanUtils.copyProperties(vo,p);
|
||||
|
||||
if (vo.getFaceImage() != null && !vo.getFaceImage().isEmpty()) {
|
||||
String encode = "";
|
||||
InputStream inStream = null;
|
||||
ByteArrayOutputStream outStream = null;
|
||||
try {
|
||||
minioClient.statObject(minioConfig.getBucketName(), vo.getFaceImage());
|
||||
|
||||
inStream = minioClient.getObject(minioConfig.getBucketName(), vo.getFaceImage());
|
||||
outStream = new ByteArrayOutputStream();
|
||||
byte[] buffer = new byte[1024];
|
||||
int length;
|
||||
while ((length = inStream.read(buffer)) != -1) {
|
||||
outStream.write(buffer, 0, length);
|
||||
}
|
||||
encode = Base64.getEncoder().encodeToString(outStream.toByteArray());
|
||||
vo.setFaceImageStr(encode);
|
||||
} catch (Exception e) {
|
||||
log.error("底库不存在:" + vo.getFaceImage());
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
if (inStream != null) {
|
||||
try {
|
||||
inStream.close();
|
||||
} catch (IOException e) {
|
||||
log.debug("inputStream close IOException:" + e.getMessage());
|
||||
}
|
||||
}
|
||||
if (outStream != null) {
|
||||
try {
|
||||
outStream.close();
|
||||
} catch (IOException e) {
|
||||
log.debug("outStream close IOException:" + e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
try {
|
||||
minioClient.statObject(minioConfig.getBucketName(), vo.getOrgImage());
|
||||
|
||||
inStream = minioClient.getObject(minioConfig.getBucketName(), vo.getOrgImage());
|
||||
outStream = new ByteArrayOutputStream();
|
||||
byte[] buffer = new byte[1024];
|
||||
int length;
|
||||
while ((length = inStream.read(buffer)) != -1) {
|
||||
outStream.write(buffer, 0, length);
|
||||
}
|
||||
encode = Base64.getEncoder().encodeToString(outStream.toByteArray());
|
||||
vo.setOrgImageStr(encode);
|
||||
} catch (Exception e) {
|
||||
log.error("原始照片不存在:" + vo.getOrgImage());
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
if (inStream != null) {
|
||||
try {
|
||||
inStream.close();
|
||||
} catch (IOException e) {
|
||||
log.debug("inputStream close IOException:" + e.getMessage());
|
||||
}
|
||||
}
|
||||
if (outStream != null) {
|
||||
try {
|
||||
outStream.close();
|
||||
} catch (IOException e) {
|
||||
log.debug("outStream close IOException:" + e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}catch (Exception e){
|
||||
return R.error("拷贝失败");
|
||||
}
|
||||
}
|
||||
return R.ok().put("data",vo);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// @PostMapping("/getAllPerson")
|
||||
// @ApiOperation(value = "获取更新的人员",response = TenPersonVo.class)
|
||||
//// @ApiImplicitParams({
|
||||
//// @ApiImplicitParam(name="sn",value = "设备SN",paramType = "query",dataType = "String",required = true),
|
||||
//// @ApiImplicitParam(name="lastUpdateTime",value = "时间",paramType = "query",dataType = "String",required = true),
|
||||
//// })
|
||||
// public R getAllPerson(@RequestBody Map<String, Object> params){
|
||||
//// AppSecret sec = new AppSecret();
|
||||
//// BeanUtils.copyProperties(params, sec);
|
||||
//// int checkIn = sec.check();
|
||||
//// if(checkIn!=0){
|
||||
//// return R.error("Authentication failure:"+checkIn);
|
||||
//// }
|
||||
// String lastUpdateTime = (String)params.get("lastUpdateTime");
|
||||
// String sn = (String)params.get("sn");
|
||||
// TenDeviceEntity dev = tenDeviceService.findBySn(sn);
|
||||
// if (dev==null) {
|
||||
// return R.error("设备未绑定");
|
||||
// }
|
||||
//
|
||||
// List<TenPersonVo> list = tenDeviceService.findAllPerson(dev.getCellId(),
|
||||
// dev.getBuildId(),
|
||||
// dev.getRoomId(),
|
||||
// lastUpdateTime);
|
||||
// log.info("获取人员信息:sn:"+sn+"-"+lastUpdateTime+" count:"+list.size());
|
||||
// return R.ok().put("data",list);
|
||||
// }
|
||||
|
||||
|
||||
|
||||
@PostMapping("/getUpdateDoorCard")
|
||||
@ApiOperation(value = "获取更新的卡号",response = TenDoorCardVo.class)
|
||||
|
@ -280,7 +448,9 @@ public class DeviceController {
|
|||
}
|
||||
// encode = Base64.getEncoder().encodeToString(outStream.toByteArray());
|
||||
// return R.ok().put("visitorCode",encode);
|
||||
return R.ok().put("data",codeFileUrl);
|
||||
Map<String,String> codeUrl = new HashMap<>();
|
||||
codeUrl.put("url",codeFileUrl);
|
||||
return R.ok().put("data",codeUrl);
|
||||
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
|
@ -342,7 +512,9 @@ public class DeviceController {
|
|||
}
|
||||
encode = Base64.getEncoder().encodeToString(outStream.toByteArray());
|
||||
// return R.ok().put("visitorCode",encode);
|
||||
return R.ok().put("data",codeFileUrl);
|
||||
Map<String,String> codeUrl = new HashMap<>();
|
||||
codeUrl.put("url",codeFileUrl);
|
||||
return R.ok().put("data",codeUrl);
|
||||
} catch (Exception ee) {
|
||||
return R.error(ee.getMessage());
|
||||
}
|
||||
|
@ -375,6 +547,48 @@ public class DeviceController {
|
|||
return R.ok().put("data", now);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@PostMapping("/bachOrgImage")
|
||||
@ApiOperation(value = "批处理",response = TenPersonVo.class)
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name="cellId",value = "小区id",paramType = "query",dataType = "String",required = true),
|
||||
})
|
||||
public R bachOrgImage(@RequestBody Map<String, Object> params){
|
||||
Long cellId = Long.parseLong((String)params.get("cellId"));
|
||||
List<TenPersonVo> list = tenPersonService.findAllByCellId(cellId);
|
||||
|
||||
for (int i = 0;i<list.size();i++) {
|
||||
TenPersonVo vo = list.get(i);
|
||||
if (vo.getOrgImage() != null && !vo.getOrgImage().isEmpty()) {
|
||||
String orgFileStr = "/root/minio/data/cell/"+ vo.getOrgImage();
|
||||
|
||||
try {
|
||||
File picture = new File(orgFileStr);
|
||||
BufferedImage sourceImg = ImageIO.read(new FileInputStream(picture));
|
||||
int w = sourceImg.getWidth();
|
||||
int h = sourceImg.getHeight();
|
||||
// long fileSize = picture.length();
|
||||
// if(fileSize<200000l){
|
||||
// continue;
|
||||
// }
|
||||
if (w > 1080 || h > 1080) {
|
||||
Thumbnails.of(orgFileStr)
|
||||
.size(1080, 1080)
|
||||
.toFile(orgFileStr);
|
||||
}
|
||||
|
||||
vo.setOrgImageStr("w:"+w+"h:"+h+orgFileStr);
|
||||
}catch (Exception e){
|
||||
log.error("批处理图片大小失败");
|
||||
log.error(e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return R.ok().put("data",list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取一个用户所有小区id
|
||||
*/
|
||||
|
|
|
@ -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.TenPersonEntity;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import net.shapelight.modules.vo.TenPersonIdUpdateVo;
|
||||
import net.shapelight.modules.vo.TenPersonVo;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
@ -46,12 +47,19 @@ public interface TenPersonDao {
|
|||
@Param("lastUpdateTime")String lastUpdateTime
|
||||
);
|
||||
|
||||
List<TenPersonIdUpdateVo> findAllPersonIdUpdate(@Param("cellId")Long cellId,
|
||||
@Param("buildId")Long buildId,
|
||||
@Param("roomId")Long roomId
|
||||
);
|
||||
|
||||
List<TenPersonVo> findByLastUpdatePerson(@Param("cellId")Long cellId,
|
||||
@Param("buildId")Long buildId,
|
||||
@Param("roomId")Long roomId,
|
||||
@Param("lastUpdateTime")String lastUpdateTime
|
||||
);
|
||||
|
||||
List<TenPersonVo> findAllByCellId(@Param("cellId")Long cellId);
|
||||
|
||||
int findRoomCount(@Param("cellId")Long cellId,@Param("roomId")Long roomId);
|
||||
int findBuildCount(@Param("cellId")Long cellId,@Param("buildId")Long buildId);
|
||||
int findCellCount(@Param("cellId")Long cellId);
|
||||
|
|
|
@ -8,6 +8,7 @@ import net.shapelight.modules.ten.entity.TenDeviceEntity;
|
|||
import net.shapelight.modules.ten.entity.TenPersonEntity;
|
||||
import net.shapelight.modules.ten.entity.TenRecordEntity;
|
||||
import net.shapelight.modules.vo.TenDeviceVo;
|
||||
import net.shapelight.modules.vo.TenPersonIdUpdateVo;
|
||||
import net.shapelight.modules.vo.TenPersonVo;
|
||||
import org.springframework.cache.annotation.CacheEvict;
|
||||
|
||||
|
@ -32,6 +33,16 @@ public interface TenDeviceService extends IService<TenDeviceEntity> {
|
|||
Long roomId,
|
||||
String lastUpdateTime
|
||||
);
|
||||
List<TenPersonVo> findAllPerson(Long cellId,
|
||||
Long buildId,
|
||||
Long roomId,
|
||||
String lastUpdateTime
|
||||
);
|
||||
|
||||
List<TenPersonIdUpdateVo> findAllPersonIdUpdate(Long cellId,
|
||||
Long buildId,
|
||||
Long roomId
|
||||
);
|
||||
|
||||
boolean upRecord(TenRecordEntity entity);
|
||||
void updateFaceCount(String sn, Integer faceCount);
|
||||
|
|
|
@ -7,6 +7,7 @@ import net.shapelight.modules.ten.entity.TenBuildEntity;
|
|||
import net.shapelight.modules.ten.entity.TenCellEntity;
|
||||
import net.shapelight.modules.ten.entity.TenPersonEntity;
|
||||
import net.shapelight.modules.ten.entity.TenRoomEntity;
|
||||
import net.shapelight.modules.vo.TenPersonIdUpdateVo;
|
||||
import net.shapelight.modules.vo.TenPersonVo;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
|
@ -58,6 +59,20 @@ public interface TenPersonService {
|
|||
);
|
||||
|
||||
|
||||
List<TenPersonVo> findAllPerson(Long cellId,
|
||||
Long buildId,
|
||||
Long roomId,
|
||||
String lastUpdateTime
|
||||
);
|
||||
|
||||
List<TenPersonIdUpdateVo> findAllPersonIdUpdate(Long cellId,
|
||||
Long buildId,
|
||||
Long roomId
|
||||
);
|
||||
|
||||
List<TenPersonVo> findAllByCellId(Long cellId);
|
||||
|
||||
|
||||
|
||||
|
||||
int findRoomCount(Long cellId,Long roomId);
|
||||
|
|
|
@ -8,6 +8,7 @@ import net.shapelight.modules.dev.mqtt.EmqHttpApi;
|
|||
import net.shapelight.modules.ten.entity.*;
|
||||
import net.shapelight.modules.ten.service.*;
|
||||
import net.shapelight.modules.vo.TenDeviceVo;
|
||||
import net.shapelight.modules.vo.TenPersonIdUpdateVo;
|
||||
import net.shapelight.modules.vo.TenPersonVo;
|
||||
import org.apache.commons.beanutils.BeanUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
@ -173,6 +174,16 @@ public class TenDeviceServiceImpl extends ServiceImpl<TenDeviceDao, TenDeviceEnt
|
|||
return tenPersonService.findUpdatePerson(cellId, buildId, roomId, lastUpdateTime);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<TenPersonVo> findAllPerson(Long cellId, Long buildId, Long roomId, String lastUpdateTime) {
|
||||
return tenPersonService.findAllPerson(cellId, buildId, roomId, lastUpdateTime);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<TenPersonIdUpdateVo> findAllPersonIdUpdate(Long cellId, Long buildId, Long roomId) {
|
||||
return tenPersonService.findAllPersonIdUpdate(cellId, buildId, roomId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean upRecord(TenRecordEntity entity) {
|
||||
return tenRecordService.saveForFace(entity);
|
||||
|
|
|
@ -20,6 +20,7 @@ import net.shapelight.modules.excel.model.PersonModel;
|
|||
import net.shapelight.modules.ten.entity.*;
|
||||
import net.shapelight.modules.ten.service.*;
|
||||
import net.shapelight.modules.vo.TenDeviceVo;
|
||||
import net.shapelight.modules.vo.TenPersonIdUpdateVo;
|
||||
import net.shapelight.modules.vo.TenPersonVo;
|
||||
import org.apache.commons.codec.digest.DigestUtils;
|
||||
import org.apache.commons.io.FileUtils;
|
||||
|
@ -252,6 +253,7 @@ public class TenPersonServiceImpl implements TenPersonService {
|
|||
entity.setOrgImage("");
|
||||
entity.setFaceImage("");
|
||||
e.printStackTrace();
|
||||
return 10;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -271,7 +273,7 @@ public class TenPersonServiceImpl implements TenPersonService {
|
|||
null,
|
||||
null);
|
||||
//删除临时文件
|
||||
minioClient.removeObject(minioConfig.getBucketName(), tempIdFrontImage);
|
||||
//minioClient.removeObject(minioConfig.getBucketName(), tempIdFrontImage);
|
||||
entity.setIdFrontImage(idFrontImageFileName);
|
||||
|
||||
} catch (Exception e) {
|
||||
|
@ -296,7 +298,7 @@ public class TenPersonServiceImpl implements TenPersonService {
|
|||
null,
|
||||
null);
|
||||
//删除临时文件
|
||||
minioClient.removeObject(minioConfig.getBucketName(), tempIdBackImage);
|
||||
//minioClient.removeObject(minioConfig.getBucketName(), tempIdBackImage);
|
||||
entity.setIdBackImage(idBackImageFileName);
|
||||
} catch (Exception e) {
|
||||
entity.setIdBackImage("");
|
||||
|
@ -1360,6 +1362,42 @@ public class TenPersonServiceImpl implements TenPersonService {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
try {
|
||||
minioClient.statObject(minioConfig.getBucketName(), vo.getOrgImage());
|
||||
|
||||
inStream = minioClient.getObject(minioConfig.getBucketName(), vo.getOrgImage());
|
||||
outStream = new ByteArrayOutputStream();
|
||||
byte[] buffer = new byte[1024];
|
||||
int length;
|
||||
while ((length = inStream.read(buffer)) != -1) {
|
||||
outStream.write(buffer, 0, length);
|
||||
}
|
||||
encode = Base64.getEncoder().encodeToString(outStream.toByteArray());
|
||||
vo.setOrgImageStr(encode);
|
||||
} catch (Exception e) {
|
||||
log.error("原始照片不存在:" + vo.getOrgImage());
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
if (inStream != null) {
|
||||
try {
|
||||
inStream.close();
|
||||
} catch (IOException e) {
|
||||
log.debug("inputStream close IOException:" + e.getMessage());
|
||||
}
|
||||
}
|
||||
if (outStream != null) {
|
||||
try {
|
||||
outStream.close();
|
||||
} catch (IOException e) {
|
||||
log.debug("outStream close IOException:" + e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
//删除最后时间重复的项
|
||||
|
@ -1427,6 +1465,117 @@ public class TenPersonServiceImpl implements TenPersonService {
|
|||
return list;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public List<TenPersonVo> findAllPerson(Long cellId, Long buildId, Long roomId, String lastUpdateTime) {
|
||||
//升序排列
|
||||
List<TenPersonVo> list = tenPersonDao.findUpdatePerson(cellId, buildId, roomId, lastUpdateTime);
|
||||
if(list.size()>0){
|
||||
TenPersonVo lastPerson = list.get(list.size()-1);
|
||||
String last = DateUtils.format(lastPerson.getLastUpdateTime(),DateUtils.DATE_TIME_PATTERN);
|
||||
List<TenPersonVo> listAfter = tenPersonDao.findByLastUpdatePerson(cellId, buildId, roomId, last);
|
||||
for(TenPersonVo vo:listAfter){
|
||||
if(vo.getPersonId().longValue() != lastPerson.getPersonId().longValue()
|
||||
&& vo.getLastUpdateTime().getTime() == lastPerson.getLastUpdateTime().getTime()){
|
||||
list.add(vo);
|
||||
}
|
||||
}
|
||||
}
|
||||
for (int i = 0;i<list.size();i++) {
|
||||
TenPersonVo vo = list.get(i);
|
||||
if (vo.getFaceImage() != null && !vo.getFaceImage().isEmpty()) {
|
||||
String encode = "";
|
||||
InputStream inStream = null;
|
||||
ByteArrayOutputStream outStream = null;
|
||||
try {
|
||||
minioClient.statObject(minioConfig.getBucketName(), vo.getFaceImage());
|
||||
|
||||
inStream = minioClient.getObject(minioConfig.getBucketName(), vo.getFaceImage());
|
||||
outStream = new ByteArrayOutputStream();
|
||||
byte[] buffer = new byte[1024];
|
||||
int length;
|
||||
while ((length = inStream.read(buffer)) != -1) {
|
||||
outStream.write(buffer, 0, length);
|
||||
}
|
||||
// encode = Base64.getEncoder().encodeToString(outStream.toByteArray());
|
||||
vo.setFaceImageStr(outStream.size()/1000+"");
|
||||
} catch (Exception e) {
|
||||
log.error("底库不存在:" + vo.getFaceImage());
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
if (inStream != null) {
|
||||
try {
|
||||
inStream.close();
|
||||
} catch (IOException e) {
|
||||
log.debug("inputStream close IOException:" + e.getMessage());
|
||||
}
|
||||
}
|
||||
if (outStream != null) {
|
||||
try {
|
||||
outStream.close();
|
||||
} catch (IOException e) {
|
||||
log.debug("outStream close IOException:" + e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
try {
|
||||
minioClient.statObject(minioConfig.getBucketName(), vo.getOrgImage());
|
||||
|
||||
inStream = minioClient.getObject(minioConfig.getBucketName(), vo.getOrgImage());
|
||||
outStream = new ByteArrayOutputStream();
|
||||
byte[] buffer = new byte[1024];
|
||||
int length;
|
||||
while ((length = inStream.read(buffer)) != -1) {
|
||||
outStream.write(buffer, 0, length);
|
||||
}
|
||||
// encode = Base64.getEncoder().encodeToString(outStream.toByteArray());
|
||||
vo.setOrgImageStr(outStream.size()/1000+"");
|
||||
} catch (Exception e) {
|
||||
log.error("原始照片不存在:" + vo.getOrgImage());
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
if (inStream != null) {
|
||||
try {
|
||||
inStream.close();
|
||||
} catch (IOException e) {
|
||||
log.debug("inputStream close IOException:" + e.getMessage());
|
||||
}
|
||||
}
|
||||
if (outStream != null) {
|
||||
try {
|
||||
outStream.close();
|
||||
} catch (IOException e) {
|
||||
log.debug("outStream close IOException:" + e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public List<TenPersonIdUpdateVo> findAllPersonIdUpdate(Long cellId, Long buildId, Long roomId) {
|
||||
//升序排列
|
||||
List<TenPersonIdUpdateVo> list = tenPersonDao.findAllPersonIdUpdate(cellId, buildId, roomId);
|
||||
return list;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public List<TenPersonVo> findAllByCellId(Long cellId) {
|
||||
return tenPersonDao.findAllByCellId(cellId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int findRoomCount(Long cellId, Long roomId) {
|
||||
return tenPersonDao.findRoomCount(cellId, roomId);
|
||||
|
|
|
@ -81,8 +81,13 @@ public class TenRecordServiceImpl implements TenRecordService {
|
|||
|
||||
for (TenRecordEntity rec : page.getRecords()) {
|
||||
TenDeviceEntity dev = tenDeviceService.findBySn(rec.getDeviceSn());
|
||||
rec.setDeviceName(dev.getName());
|
||||
rec.setGateFlag(dev.getGateFlag());
|
||||
if(dev == null){
|
||||
rec.setDeviceName(rec.getDeviceSn());
|
||||
rec.setGateFlag(0);
|
||||
}else{
|
||||
rec.setDeviceName(dev.getName());
|
||||
rec.setGateFlag(dev.getGateFlag());
|
||||
}
|
||||
TenPersonEntity person = tenPersonService.getById(rec.getPersonId(), rec.getCellId());
|
||||
if (person == null) {
|
||||
person = new TenPersonEntity();
|
||||
|
|
|
@ -0,0 +1,26 @@
|
|||
package net.shapelight.modules.vo;
|
||||
|
||||
import com.alibaba.fastjson.annotation.JSONField;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
|
||||
@Data
|
||||
public class TenPersonIdUpdateVo implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@ApiModelProperty("人员ID")
|
||||
private Integer memberId;
|
||||
|
||||
/**
|
||||
* 更新时间
|
||||
*/
|
||||
@ApiModelProperty("更新时间")
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
||||
@JSONField(format="yyyy-MM-dd HH:mm:ss")
|
||||
private Date lastUpdateTime;
|
||||
}
|
|
@ -138,4 +138,11 @@ public class TenPersonVo implements Serializable {
|
|||
private String faceImageStr;
|
||||
|
||||
|
||||
/**
|
||||
*人脸原始照片base64
|
||||
*/
|
||||
@ApiModelProperty("人脸原始照片base64")
|
||||
private String orgImageStr;
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -644,8 +644,26 @@
|
|||
and last_update_time > #{lastUpdateTime}
|
||||
</if>
|
||||
order by last_update_time asc
|
||||
limit 100
|
||||
limit 50
|
||||
</select>
|
||||
|
||||
|
||||
|
||||
<select id="findAllPersonIdUpdate" resultType="net.shapelight.modules.vo.TenPersonIdUpdateVo">
|
||||
select member_id,last_update_time from ten_person_${cellId}
|
||||
where 1=1
|
||||
<if test="cellId != null and cellId!=''">
|
||||
and cell_id = #{cellId}
|
||||
</if>
|
||||
<if test="buildId != null and buildId!=''">
|
||||
and build_id = #{buildId}
|
||||
</if>
|
||||
<if test="roomId != null and roomId!=''">
|
||||
and room_id = #{roomId}
|
||||
</if>
|
||||
</select>
|
||||
|
||||
|
||||
<select id="findByLastUpdatePerson" resultMap="updateMap">
|
||||
select * from ten_person_${cellId}
|
||||
where 1=1
|
||||
|
@ -663,6 +681,10 @@
|
|||
</if>
|
||||
</select>
|
||||
|
||||
<select id="findAllByCellId" resultMap="updateMap">
|
||||
select * from ten_person_${cellId}
|
||||
</select>
|
||||
|
||||
<select id="findRoomCount" resultType="int">
|
||||
select count(*) from ten_person_${cellId}
|
||||
where delete_flag = 0
|
||||
|
|
|
@ -309,6 +309,9 @@
|
|||
<if test="params.roomName != null and params.roomName!=''">
|
||||
and room_name like CONCAT('%', '${params.roomName}', '%')
|
||||
</if>
|
||||
<if test="params.roomNumber != null and params.roomNumber!=''">
|
||||
and room_number = #{params.roomNumber}
|
||||
</if>
|
||||
</select>
|
||||
|
||||
<select id="getAllCount" resultType="int" >
|
||||
|
|
Loading…
Reference in New Issue