人员管理问题修改
This commit is contained in:
parent
4a944e3379
commit
405f974af1
|
|
@ -10,9 +10,11 @@ import com.bonus.app.entity.BraceletEntity;
|
|||
import com.bonus.app.entity.BraceletInfoEntity;
|
||||
import com.bonus.app.entity.LsUserEntity;
|
||||
import com.bonus.app.mapper.BraceletMapper;
|
||||
import com.bonus.common.core.constant.BusinessConstants;
|
||||
import com.bonus.common.core.constant.HttpStatus;
|
||||
import com.bonus.common.core.constant.SecurityConstants;
|
||||
import com.bonus.common.core.domain.R;
|
||||
import com.bonus.common.core.exception.ServiceException;
|
||||
import com.bonus.common.core.utils.*;
|
||||
import com.bonus.common.core.utils.encryption.Sm4Utils;
|
||||
import com.bonus.common.core.utils.uuid.IdUtils;
|
||||
|
|
@ -30,12 +32,11 @@ import lombok.extern.slf4j.Slf4j;
|
|||
import org.apache.commons.lang3.ObjectUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.transaction.interceptor.TransactionAspectSupport;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
|
|
@ -236,6 +237,7 @@ public class BraceletServiceImpl implements BraceletService{
|
|||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public AjaxResult addLsUser(MultipartFile file, String params) {
|
||||
try {
|
||||
if(ObjectUtils.isEmpty(file)){
|
||||
|
|
@ -293,14 +295,24 @@ public class BraceletServiceImpl implements BraceletService{
|
|||
R<Boolean> r= sourceService.addFileSource(fileVo, SecurityConstants.INNER);
|
||||
if(r.getData()){
|
||||
AjaxResult ajaxResult = addFaceToLibrary(BytesToMultipartFileUtil.multipartFileToBase64(file), FaceCodeUtil.ADD, "rs-" + user.getId());
|
||||
return ajaxResult;
|
||||
JSONObject data = JSONObject.parseObject(JSONObject.toJSONString(ajaxResult.get("data")));
|
||||
Integer code = data.getInteger("code");
|
||||
String msg = data.getString("msg");
|
||||
if (Objects.equals(code, BusinessConstants.SUCCESS_CODE)) {
|
||||
return AjaxResult.success("添加成功");
|
||||
}else{
|
||||
throw new ServiceException(msg);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
return AjaxResult.error("添加失败");
|
||||
}catch (ServiceException e){
|
||||
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
|
||||
return AjaxResult.error(e.getMessage());
|
||||
}catch (Exception e){
|
||||
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
|
||||
log.error(e.toString(),e);
|
||||
}
|
||||
return AjaxResult.error("系统异常");
|
||||
|
|
|
|||
|
|
@ -227,7 +227,7 @@ public interface PersonMgeMapper {
|
|||
* @author cwchen
|
||||
* @date 2024/8/12 13:12
|
||||
*/
|
||||
void updatePeoplePushStatus(Long id);
|
||||
void updatePeoplePushStatus(@Param("id") Long id,@Param("isPush")Integer isPush);
|
||||
|
||||
/**
|
||||
* 判断人员是否绑定了设备
|
||||
|
|
|
|||
|
|
@ -0,0 +1,181 @@
|
|||
package com.bonus.bracelet.service.impl;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.alibaba.nacos.shaded.com.google.common.collect.Maps;
|
||||
import com.bonus.common.core.utils.FaceCodeUtil;
|
||||
import com.bonus.common.core.utils.StringUtils;
|
||||
import com.bonus.common.core.utils.http.HttpUtils;
|
||||
import com.bonus.common.core.web.domain.AjaxResult;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
@Service
|
||||
@Slf4j
|
||||
public class FaceInterUtilService {
|
||||
|
||||
/**
|
||||
* 新增人脸库
|
||||
*/
|
||||
public final static String addFace="updatedb";
|
||||
|
||||
@Value("${face.path}")
|
||||
public String faceUrl;
|
||||
|
||||
/**
|
||||
* 刷新人脸库
|
||||
*/
|
||||
public final static String refresh="refreshdb";
|
||||
/**
|
||||
* 识别人脸库
|
||||
*/
|
||||
public final static String sbface="facerecognition";
|
||||
|
||||
|
||||
public static void main(String[] args) {
|
||||
|
||||
}
|
||||
public AjaxResult addFace2(String image, String type, String id) {
|
||||
Map<String,Object> result= Maps.newHashMap();
|
||||
try{
|
||||
Map<String,Object> map= Maps.newHashMap();
|
||||
map.put("img",image);
|
||||
map.put("optMode",type);
|
||||
map.put("uniqueKey",id);
|
||||
String msg= HttpUtils.sendRequest(faceUrl+addFace,JSON.toJSONString(map),true);
|
||||
if(StringUtils.isNotEmpty(msg)){
|
||||
JSONObject json=JSON.parseObject(msg);
|
||||
String code=json.getString("code");
|
||||
String eMsg=json.getString("msg");
|
||||
if("30002".equals(code)){
|
||||
result.put("code",200);
|
||||
}else {
|
||||
result.put("code",201);
|
||||
}
|
||||
String msgCN= FaceCodeUtil.getCodeString(code);
|
||||
result.put("msg",msgCN);
|
||||
result.put("eMsg",eMsg);
|
||||
}else{
|
||||
result.put("code",201);
|
||||
result.put("msg","人脸识别接口异常!请检查人脸服务!");
|
||||
}
|
||||
AjaxResult.success(result);
|
||||
}catch (Exception e){
|
||||
log.error(e.toString(),e);
|
||||
}
|
||||
return AjaxResult.error("人脸识别接口异常!请检查人脸服务!");
|
||||
|
||||
}
|
||||
/**
|
||||
* 人脸信进行修改
|
||||
* @param image
|
||||
* @param type
|
||||
* @param id ls-
|
||||
* bz-
|
||||
* @return
|
||||
*/
|
||||
public AjaxResult addFace(String image, String type, String id) {
|
||||
Map<String,Object> result= Maps.newHashMap();
|
||||
try{
|
||||
Map<String,Object> map= Maps.newHashMap();
|
||||
map.put("img",image);
|
||||
map.put("optMode",type);
|
||||
map.put("uniqueKey",id);
|
||||
String msg= HttpUtils.sendRequest(faceUrl+addFace,JSON.toJSONString(map),true);
|
||||
if(StringUtils.isNotEmpty(msg)){
|
||||
JSONObject json=JSON.parseObject(msg);
|
||||
String code=json.getString("code");
|
||||
String eMsg=json.getString("msg");
|
||||
if("30002".equals(code)){
|
||||
result.put("code",200);
|
||||
}else {
|
||||
result.put("code",201);
|
||||
}
|
||||
String msgCN= FaceCodeUtil.getCodeString(code);
|
||||
result.put("msg",msgCN);
|
||||
result.put("eMsg",eMsg);
|
||||
}else{
|
||||
result.put("code",201);
|
||||
result.put("msg","人脸识别接口异常!请检查人脸服务!");
|
||||
}
|
||||
return AjaxResult.success(result);
|
||||
}catch (Exception e){
|
||||
log.error(e.toString(),e);
|
||||
}
|
||||
return AjaxResult.error("人脸识别接口异常!请检查人脸服务!");
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 刷新图像库
|
||||
* @return
|
||||
*/
|
||||
public AjaxResult refreshFace() {
|
||||
Map<String,Object> result= Maps.newHashMap();
|
||||
try{
|
||||
Map<String,Object> map= Maps.newHashMap();
|
||||
String msg= HttpUtils.sendRequest(faceUrl+refresh,JSON.toJSONString(map),true);
|
||||
if(StringUtils.isNotEmpty(msg)){
|
||||
JSONObject json=JSON.parseObject(msg);
|
||||
String code=json.getString("code");
|
||||
String eMsg=json.getString("msg");
|
||||
if("30002".equals(code)){
|
||||
result.put("code",200);
|
||||
result.put("msg","操作成功");
|
||||
}else {
|
||||
String msgCN= FaceCodeUtil.getCodeString(code);
|
||||
result.put("msg",msgCN);
|
||||
result.put("code",201);
|
||||
}
|
||||
result.put("eMsg",eMsg);
|
||||
}else{
|
||||
result.put("code",201);
|
||||
result.put("msg","人脸识别接口异常!请检查人脸服务!");
|
||||
}
|
||||
AjaxResult.success(result);
|
||||
}catch (Exception e){
|
||||
log.error(e.toString(),e);
|
||||
}
|
||||
return AjaxResult.error("人脸识别接口异常!请检查人脸服务!");
|
||||
}
|
||||
|
||||
public AjaxResult verifyFace(String image) {
|
||||
Map<String,Object> result= Maps.newHashMap();
|
||||
try{
|
||||
Map<String,Object> map= Maps.newHashMap();
|
||||
map.put("img",image);
|
||||
String msg= HttpUtils.sendRequest(faceUrl+sbface,JSON.toJSONString(map),true);
|
||||
if(StringUtils.isNotEmpty(msg)){
|
||||
JSONObject json=JSON.parseObject(msg);
|
||||
String code=json.getString("code");
|
||||
String eMsg=json.getString("msg");
|
||||
//识别成功返回的数据
|
||||
if("30000".equals(code)){
|
||||
JSONArray jsonArray=json.getJSONArray("data");
|
||||
Object key= jsonArray.get(0);
|
||||
result.put("code",201);
|
||||
result.put("userId",key);
|
||||
result.put("msg","人脸识别成功");
|
||||
}else{
|
||||
result.put("code",201);
|
||||
String msgCN= FaceCodeUtil.getCodeString(code);
|
||||
result.put("msg",msgCN);
|
||||
result.put("eMsg",eMsg);
|
||||
result.put("userId","-9999");
|
||||
}
|
||||
}else{
|
||||
result.put("code",201);
|
||||
result.put("msg","人脸识别接口异常!请检查人脸服务!");
|
||||
}
|
||||
AjaxResult.success(result);
|
||||
}catch (Exception e){
|
||||
log.error(e.toString(),e);
|
||||
}
|
||||
return AjaxResult.error("人脸识别接口异常!请检查人脸服务!");
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -81,7 +81,7 @@ public class PersonMgeServiceImpl implements IPersonMgeService {
|
|||
private RemoteFileService remoteFileService;
|
||||
|
||||
@Autowired
|
||||
private FaceInterService faceInterService;
|
||||
private FaceInterUtilService faceInterService;
|
||||
|
||||
@Value("${file.temp_file_path}")
|
||||
private String tempFilePath;
|
||||
|
|
@ -182,10 +182,15 @@ public class PersonMgeServiceImpl implements IPersonMgeService {
|
|||
mapper.addPerson(vo);
|
||||
delFileId = uploadFile(file, vo);
|
||||
// 添加人脸照片至人脸库
|
||||
AjaxResult ajaxResult = addFaceToLibrary(BytesToMultipartFileUtil.multipartFileToBase64(file), FaceCodeUtil.ADD, "rs-" + vo.getId());
|
||||
if (ajaxResult != null && Objects.equals((Integer) ajaxResult.get("code"), BusinessConstants.SUCCESS_CODE)) {
|
||||
AjaxResult ajaxResult = addFaceToLibrary(BytesToMultipartFileUtil.multipartFileToBase64(file), FaceCodeUtil.ADD, "bz-" + vo.getId());
|
||||
JSONObject data = JSONObject.parseObject(JSONObject.toJSONString(ajaxResult.get("data")));
|
||||
Integer code = data.getInteger("code");
|
||||
String msg = data.getString("msg");
|
||||
if (Objects.equals(code, BusinessConstants.SUCCESS_CODE)) {
|
||||
// 更新人脸库推送状态
|
||||
mapper.updatePeoplePushStatus(vo.getId());
|
||||
mapper.updatePeoplePushStatus(vo.getId(),1);
|
||||
}else{
|
||||
mapper.updatePeoplePushStatus(vo.getId(),0);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error("新增人员", e);
|
||||
|
|
@ -249,19 +254,24 @@ public class PersonMgeServiceImpl implements IPersonMgeService {
|
|||
mapper.editPerson(vo);
|
||||
delFileId = uploadFile(file, vo);
|
||||
if (StringUtils.isNotEmpty(vo.getDelFiles())) {
|
||||
String personImgBase64 = getPersonImgBase64(vo.getDelFiles());
|
||||
// 删除人脸库,添加人脸照片至人脸库
|
||||
AjaxResult delAjax = delFaceToLibrary(personImgBase64, FaceCodeUtil.DEL, "bz-" + vo.getId());
|
||||
AjaxResult ajaxResult = addFaceToLibrary(BytesToMultipartFileUtil.multipartFileToBase64(file), FaceCodeUtil.ADD, "bz-" + vo.getId());
|
||||
JSONObject data = JSONObject.parseObject(JSONObject.toJSONString(ajaxResult.get("data")));
|
||||
Integer code = data.getInteger("code");
|
||||
String msg = data.getString("msg");
|
||||
if (Objects.equals(code, BusinessConstants.SUCCESS_CODE)) {
|
||||
// 更新人脸库推送状态
|
||||
mapper.updatePeoplePushStatus(vo.getId(),1);
|
||||
}else{
|
||||
mapper.updatePeoplePushStatus(vo.getId(),0);
|
||||
}
|
||||
String[] delFiles = vo.getDelFiles().split(",");
|
||||
for (String fileId : delFiles) {
|
||||
resourceFileMapper.delResourceFile(vo.getFileId());
|
||||
remoteFileService.delFile(fileId, SecurityConstants.INNER);
|
||||
}
|
||||
String personImgBase64 = getPersonImgBase64(vo.getDelFiles());
|
||||
// 删除人脸库,添加人脸照片至人脸库
|
||||
delFaceToLibrary(personImgBase64, FaceCodeUtil.DEL, "rs-" + vo.getId());
|
||||
AjaxResult ajaxResult = addFaceToLibrary(BytesToMultipartFileUtil.multipartFileToBase64(file), FaceCodeUtil.ADD, "rs-" + vo.getId());
|
||||
if (ajaxResult != null && Objects.equals((Integer) ajaxResult.get("code"), BusinessConstants.SUCCESS_CODE)) {
|
||||
// 更新人脸库推送状态
|
||||
mapper.updatePeoplePushStatus(vo.getId());
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error("修改人员", e);
|
||||
|
|
@ -353,11 +363,11 @@ public class PersonMgeServiceImpl implements IPersonMgeService {
|
|||
}
|
||||
}
|
||||
mapper.delCertificate(dto);
|
||||
resourceFileMapper.delResourceFile(dto.getFileId());
|
||||
remoteFileService.delFile(dto.getFilePath(), SecurityConstants.INNER);
|
||||
// 删除人脸库
|
||||
String base64Data = getPersonImgBase64(dto.getFilePath());
|
||||
delFaceToLibrary(base64Data, FaceCodeUtil.DEL, "rs-" + dto.getId());
|
||||
AjaxResult delAjax = delFaceToLibrary(base64Data, FaceCodeUtil.DEL, "bz-" + dto.getId());
|
||||
resourceFileMapper.delResourceFile(dto.getFileId());
|
||||
remoteFileService.delFile(dto.getFilePath(), SecurityConstants.INNER);
|
||||
return AjaxResult.success();
|
||||
} catch (Exception e) {
|
||||
log.error("删除人员", e);
|
||||
|
|
@ -375,13 +385,16 @@ public class PersonMgeServiceImpl implements IPersonMgeService {
|
|||
return AjaxResult.error("未上传人脸照片");
|
||||
}
|
||||
// 删除人脸库,添加人脸照片至人脸库
|
||||
delFaceToLibrary(base64Data, FaceCodeUtil.DEL, "rs-" + dto.getId());
|
||||
AjaxResult ajaxResult = addFaceToLibrary(base64Data, FaceCodeUtil.ADD, "rs-" + dto.getId());
|
||||
if (ajaxResult != null && Objects.equals((Integer) ajaxResult.get("code"), BusinessConstants.SUCCESS_CODE)) {
|
||||
delFaceToLibrary(base64Data, FaceCodeUtil.DEL, "bz-" + dto.getId());
|
||||
AjaxResult ajaxResult = addFaceToLibrary(base64Data, FaceCodeUtil.ADD, "bz-" + dto.getId());
|
||||
JSONObject data = JSONObject.parseObject(JSONObject.toJSONString(ajaxResult.get("data")));
|
||||
Integer code = data.getInteger("code");
|
||||
String msg = data.getString("msg");
|
||||
if (Objects.equals(code, BusinessConstants.SUCCESS_CODE)) {
|
||||
// 更新人脸库推送状态
|
||||
mapper.updatePeoplePushStatus(dto.getId());
|
||||
} else {
|
||||
return AjaxResult.error((String) ajaxResult.get("msg"));
|
||||
mapper.updatePeoplePushStatus(dto.getId(),1);
|
||||
}else{
|
||||
return AjaxResult.error(msg);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error(e.toString(), e);
|
||||
|
|
@ -488,13 +501,19 @@ public class PersonMgeServiceImpl implements IPersonMgeService {
|
|||
vo.setPhone(Sm4Utils.encode(vo.getPhone()));
|
||||
mapper.addPerson(vo);
|
||||
// 推送人脸照片到人脸库,并更新推送状态
|
||||
AjaxResult ajaxResult = addFaceToLibrary(BytesToMultipartFileUtil.multipartFileToBase64(vo.getFile()), FaceCodeUtil.ADD, "rs-" + vo.getId());
|
||||
if (ajaxResult != null && Objects.equals((Integer) ajaxResult.get("code"), BusinessConstants.SUCCESS_CODE)) {
|
||||
mapper.updatePeoplePushStatus(vo.getId());
|
||||
AjaxResult ajaxResult = addFaceToLibrary(BytesToMultipartFileUtil.multipartFileToBase64(vo.getFile()), FaceCodeUtil.ADD, "bz-" + vo.getId());
|
||||
JSONObject data = JSONObject.parseObject(JSONObject.toJSONString(ajaxResult.get("data")));
|
||||
Integer code = data.getInteger("code");
|
||||
String msg = data.getString("msg");
|
||||
if (Objects.equals(code, BusinessConstants.SUCCESS_CODE)) {
|
||||
// 更新人脸库推送状态
|
||||
mapper.updatePeoplePushStatus(vo.getId(),1);
|
||||
}else{
|
||||
mapper.updatePeoplePushStatus(vo.getId(),0);
|
||||
}
|
||||
String delFileId = uploadFile(vo.getFile(), vo);
|
||||
errorFileLists.add(delFileId);
|
||||
errorIdLists.add("rs-" + vo.getId());
|
||||
errorIdLists.add("bz-" + vo.getId());
|
||||
}
|
||||
} catch (RuntimeException runtimeException) {
|
||||
if (runtimeException.getMessage() == null) {
|
||||
|
|
@ -519,10 +538,10 @@ public class PersonMgeServiceImpl implements IPersonMgeService {
|
|||
@Override
|
||||
public AjaxResult getPersonFace(BraceletParamsDto dto) {
|
||||
if (StringUtils.isBlank(dto.getFilePath())) {
|
||||
return AjaxResult.success("查询成功",null);
|
||||
return AjaxResult.success("查询成功", null);
|
||||
}
|
||||
String imgBase64 = getPersonImgBase64(dto.getFilePath());
|
||||
return AjaxResult.success("查询成功",imgBase64);
|
||||
return AjaxResult.success("查询成功", imgBase64);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -284,6 +284,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
</update>
|
||||
<!--更新人脸库推送状态-->
|
||||
<update id="updatePeoplePushStatus">
|
||||
UPDATE tb_people SET is_push = 1 WHERE id = #{id}
|
||||
UPDATE tb_people SET is_push = #{isPush} WHERE id = #{id}
|
||||
</update>
|
||||
</mapper>
|
||||
Loading…
Reference in New Issue