人员管理接口修改
This commit is contained in:
parent
c7e93f9fd5
commit
160ecc1d8d
|
|
@ -83,6 +83,13 @@ public class PersonMgeController extends BaseController {
|
||||||
return service.delPerson(dto);
|
return service.delPerson(dto);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// @RequiresPermissions("basic:person:push")
|
||||||
|
@PostMapping("pushFace")
|
||||||
|
@SysLog(title = "人员管理", businessType = OperaType.DELETE,logType = 0,module = "基础管理->人员管理",details ="推送人脸库" )
|
||||||
|
public AjaxResult pushFace(@RequestBody BraceletParamsDto dto) {
|
||||||
|
return service.pushFace(dto);
|
||||||
|
}
|
||||||
|
|
||||||
@PostMapping("excelUpload")
|
@PostMapping("excelUpload")
|
||||||
// @RequiresPermissions("basic:person:excelUpload")
|
// @RequiresPermissions("basic:person:excelUpload")
|
||||||
@SysLog(title = "人员管理", businessType = OperaType.IMPORT,logType = 0,module = "基础管理->人员管理",details ="人员导入" )
|
@SysLog(title = "人员管理", businessType = OperaType.IMPORT,logType = 0,module = "基础管理->人员管理",details ="人员导入" )
|
||||||
|
|
|
||||||
|
|
@ -100,4 +100,13 @@ public interface IPersonMgeService {
|
||||||
* @date 2024/8/9 8:51
|
* @date 2024/8/9 8:51
|
||||||
*/
|
*/
|
||||||
List<PersonVo> getExportPersonLists(BraceletParamsDto dto);
|
List<PersonVo> getExportPersonLists(BraceletParamsDto dto);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 推送人脸照片到人脸库
|
||||||
|
* @param dto
|
||||||
|
* @return AjaxResult
|
||||||
|
* @author cwchen
|
||||||
|
* @date 2024/8/12 14:11
|
||||||
|
*/
|
||||||
|
AjaxResult pushFace(BraceletParamsDto dto);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -220,14 +220,13 @@ public class PersonMgeServiceImpl implements IPersonMgeService {
|
||||||
resourceFileMapper.delResourceFile(vo.getFileId());
|
resourceFileMapper.delResourceFile(vo.getFileId());
|
||||||
remoteFileService.delFile(fileId, SecurityConstants.INNER);
|
remoteFileService.delFile(fileId, SecurityConstants.INNER);
|
||||||
}
|
}
|
||||||
|
String personImgBase64 = getPersonImgBase64(vo.getDelFiles());
|
||||||
// 删除人脸库,添加人脸照片至人脸库
|
// 删除人脸库,添加人脸照片至人脸库
|
||||||
Integer isDel = delFaceToLibrary(null, FaceCodeUtil.DEL, "rs-" + vo.getId());
|
delFaceToLibrary(personImgBase64, FaceCodeUtil.DEL, "rs-" + vo.getId());
|
||||||
if(isDel !=null){
|
Integer isPush = addFaceToLibrary(BytesToMultipartFileUtil.multipartFileToBase64(file), FaceCodeUtil.ADD, "rs-" + vo.getId());
|
||||||
Integer isPush = addFaceToLibrary(BytesToMultipartFileUtil.multipartFileToBase64(file), FaceCodeUtil.ADD, "rs-" + vo.getId());
|
if (isPush != null) {
|
||||||
if (isPush != null) {
|
// 更新人脸库推送状态
|
||||||
// 更新人脸库推送状态
|
mapper.updatePeoplePushStatus(vo.getId());
|
||||||
mapper.updatePeoplePushStatus(vo.getId());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
|
@ -253,7 +252,7 @@ public class PersonMgeServiceImpl implements IPersonMgeService {
|
||||||
* @date 2024/8/12 13:20
|
* @date 2024/8/12 13:20
|
||||||
*/
|
*/
|
||||||
public Integer addFaceToLibrary(String base64, String type, String id) {
|
public Integer addFaceToLibrary(String base64, String type, String id) {
|
||||||
if (base64 == null) {
|
if (StringUtils.isEmpty(base64)) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
AjaxResult ajaxResult = faceInterService.addFace(base64, type, id);
|
AjaxResult ajaxResult = faceInterService.addFace(base64, type, id);
|
||||||
|
|
@ -275,6 +274,9 @@ public class PersonMgeServiceImpl implements IPersonMgeService {
|
||||||
* @date 2024/8/12 13:27
|
* @date 2024/8/12 13:27
|
||||||
*/
|
*/
|
||||||
public Integer delFaceToLibrary(String base64, String type, String id) {
|
public Integer delFaceToLibrary(String base64, String type, String id) {
|
||||||
|
if(StringUtils.isEmpty(base64)){
|
||||||
|
return null;
|
||||||
|
}
|
||||||
AjaxResult ajaxResult = faceInterService.addFace(base64, type, id);
|
AjaxResult ajaxResult = faceInterService.addFace(base64, type, id);
|
||||||
Integer code = (Integer) ajaxResult.get("code");
|
Integer code = (Integer) ajaxResult.get("code");
|
||||||
log.info("删除人脸库返回结果:{}", ajaxResult);
|
log.info("删除人脸库返回结果:{}", ajaxResult);
|
||||||
|
|
@ -327,6 +329,52 @@ public class PersonMgeServiceImpl implements IPersonMgeService {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Transactional(rollbackFor = Exception.class)
|
||||||
|
public AjaxResult pushFace(BraceletParamsDto dto) {
|
||||||
|
try {
|
||||||
|
String base64Data = getPersonImgBase64(dto.getFilePath());
|
||||||
|
if(StringUtils.isEmpty(base64Data)){
|
||||||
|
return AjaxResult.error("未上传人脸照片");
|
||||||
|
}
|
||||||
|
// 删除人脸库,添加人脸照片至人脸库
|
||||||
|
delFaceToLibrary(base64Data, FaceCodeUtil.DEL, "rs-" + dto.getId());
|
||||||
|
Integer isPush = addFaceToLibrary(base64Data, FaceCodeUtil.ADD, "rs-" + dto.getId());
|
||||||
|
if (isPush != null) {
|
||||||
|
// 更新人脸库推送状态
|
||||||
|
mapper.updatePeoplePushStatus(dto.getId());
|
||||||
|
}else{
|
||||||
|
return AjaxResult.error("人脸识别接口异常!请检查人脸服务!");
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error(e.toString(), e);
|
||||||
|
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
|
||||||
|
return AjaxResult.error();
|
||||||
|
}
|
||||||
|
return AjaxResult.success();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据文件ID获取图片base64
|
||||||
|
* @param filePath
|
||||||
|
* @return String
|
||||||
|
* @author cwchen
|
||||||
|
* @date 2024/8/12 14:35
|
||||||
|
*/
|
||||||
|
public String getPersonImgBase64(String filePath){
|
||||||
|
R<SysFile> result = remoteFileService.getImgBase64(filePath, SecurityConstants.INNER);
|
||||||
|
if (result != null && result.getCode() == HttpStatus.SUCCESS && result.getData() != null) {
|
||||||
|
String jsonString = JSON.toJSONString(result.getData());
|
||||||
|
JSONObject item = JSON.parseObject(jsonString);
|
||||||
|
String base64 = item.getString("url");
|
||||||
|
if(StringUtils.isNotBlank(base64)){
|
||||||
|
// 去除前缀部分
|
||||||
|
return base64.split(",")[1];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public AjaxResult excelUpload(MultipartFile file, HttpServletRequest request, HttpServletResponse response) {
|
public AjaxResult excelUpload(MultipartFile file, HttpServletRequest request, HttpServletResponse response) {
|
||||||
|
|
@ -335,6 +383,7 @@ public class PersonMgeServiceImpl implements IPersonMgeService {
|
||||||
return AjaxResult.error(result);
|
return AjaxResult.error(result);
|
||||||
}
|
}
|
||||||
List<String> errorFileLists = new ArrayList<>();
|
List<String> errorFileLists = new ArrayList<>();
|
||||||
|
List<String> errorIdLists = new ArrayList<>();
|
||||||
try {
|
try {
|
||||||
List<JSONObject> lstObj = (List<JSONObject>) ImportExcelUtils.readExcel(file, PersonImportVo.class, tempFilePath);
|
List<JSONObject> lstObj = (List<JSONObject>) ImportExcelUtils.readExcel(file, PersonImportVo.class, tempFilePath);
|
||||||
List<PersonVo> list = new ArrayList<>();
|
List<PersonVo> list = new ArrayList<>();
|
||||||
|
|
@ -385,8 +434,14 @@ public class PersonMgeServiceImpl implements IPersonMgeService {
|
||||||
vo.setIdCard(Sm4Utils.encode(vo.getIdCard()));
|
vo.setIdCard(Sm4Utils.encode(vo.getIdCard()));
|
||||||
vo.setPhone(Sm4Utils.encode(vo.getPhone()));
|
vo.setPhone(Sm4Utils.encode(vo.getPhone()));
|
||||||
mapper.addPerson(vo);
|
mapper.addPerson(vo);
|
||||||
|
// 推送人脸照片到人脸库,并更新推送状态
|
||||||
|
Integer isPush = addFaceToLibrary(BytesToMultipartFileUtil.multipartFileToBase64(vo.getFile()), FaceCodeUtil.ADD, "rs-" + vo.getId());
|
||||||
|
if (isPush != null) {
|
||||||
|
mapper.updatePeoplePushStatus(vo.getId());
|
||||||
|
}
|
||||||
String delFileId = uploadFile(vo.getFile(), vo);
|
String delFileId = uploadFile(vo.getFile(), vo);
|
||||||
errorFileLists.add(delFileId);
|
errorFileLists.add(delFileId);
|
||||||
|
errorIdLists.add("rs-"+vo.getId());
|
||||||
}
|
}
|
||||||
} catch (RuntimeException runtimeException) {
|
} catch (RuntimeException runtimeException) {
|
||||||
if (runtimeException.getMessage() == null) {
|
if (runtimeException.getMessage() == null) {
|
||||||
|
|
@ -395,10 +450,11 @@ public class PersonMgeServiceImpl implements IPersonMgeService {
|
||||||
return AjaxResult.error(runtimeException.getMessage());
|
return AjaxResult.error(runtimeException.getMessage());
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.error(e.toString(), e);
|
log.error(e.toString(), e);
|
||||||
// 添加失败-删除文件
|
// 添加失败-删除文件、删除人脸库照片
|
||||||
if (CollectionUtils.isNotEmpty(errorFileLists)) {
|
if (CollectionUtils.isNotEmpty(errorFileLists)) {
|
||||||
for (String delFileId : errorFileLists) {
|
for (int i = 0; i < errorFileLists.size(); i++) {
|
||||||
remoteFileService.delFile(delFileId, SecurityConstants.INNER);
|
remoteFileService.delFile(errorFileLists.get(i), SecurityConstants.INNER);
|
||||||
|
delFaceToLibrary(null, FaceCodeUtil.DEL, errorIdLists.get(i));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
|
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue