Merge remote-tracking branch 'origin/main'
This commit is contained in:
		
						commit
						61f343f258
					
				| @ -33,5 +33,5 @@ public interface FaceLibraryMapper extends BaseMapper<FaceLibrary> { | ||||
|      */ | ||||
|      Integer getLibraryCount(@Param("idFactory") Long idFactory); | ||||
| 
 | ||||
|     FaceLibrary getLibrary(@Param("factoryName") String factoryName); | ||||
|     FaceLibrary getLibraryByFactoryName(@Param("factoryName") String factoryName); | ||||
| } | ||||
|  | ||||
| @ -67,7 +67,7 @@ public class FaceLibraryServiceImpl extends ServiceImpl<FaceLibraryMapper, FaceL | ||||
|     @Transactional(rollbackFor = Exception.class) | ||||
|     public FaceLibrary addLibrary(FaceLibrary faceLibrary) { | ||||
|         try { | ||||
|             if (faceLibraryMapper.getLibrary(faceLibrary.getFactoryName()) != null) { | ||||
|             if (faceLibraryMapper.getLibraryByFactoryName(faceLibrary.getFactoryName()) != null) { | ||||
|                 throw new DkException("库名称已存在"); | ||||
|             } | ||||
|             FaceLibraryVO faceLibraryVO = new FaceLibraryVO(); | ||||
| @ -93,35 +93,37 @@ public class FaceLibraryServiceImpl extends ServiceImpl<FaceLibraryMapper, FaceL | ||||
|         faceLibrary.setIsValid(YNEnums.NO.code); | ||||
|         faceLibrary.setIdFactory(libraryId); | ||||
|         try { | ||||
| 
 | ||||
|         ApiVO faceLibrary1 = (ApiVO) httpUtil.delete(link+ ApiUrlEnum.FACELIB_POSTURL.getUrl()+"/"+String.valueOf(libraryId), ApiVO.class); | ||||
|             ApiVO faceLibrary1 = (ApiVO) httpUtil.delete(link + ApiUrlEnum.FACELIB_POSTURL.getUrl() + "/" + libraryId, ApiVO.class); | ||||
|             if (! faceLibrary1.getCode().equals(200)) { | ||||
|                 throw new DkException("删除库失败, " + faceLibrary1.getMessage()); | ||||
|             } | ||||
|         }catch (Exception e){ | ||||
|             throw new DkException("删除库失败"); | ||||
|             throw new DkException(e.getMessage()); | ||||
|         } | ||||
|             /**调用API*/ | ||||
|             Integer integer = controlLibraryMidMapper.selectByLibID(String.valueOf(libraryId), YNEnums.YES.code); | ||||
|             if(integer<=0) { | ||||
|                 int count = faceLibraryMapper.deleteById(faceLibrary); | ||||
|                 /**删除对应的人像*/ | ||||
|                 List<Portrait> portraits = portraitMapper.queryPortraitByFactory(libraryId); | ||||
|                 portraitMapper.deletePortrait(libraryId); | ||||
|                 if(UtilValidate.isNotEmpty(portraits)){ | ||||
|                     for (Portrait p:portraits) { | ||||
|                         /**删除文件服务器*/ | ||||
|                         try { | ||||
|                             minioUtil.removeObject(bucketName,p.getUrl()); | ||||
|                         } catch (Exception e) { | ||||
|                             log.error(e.getMessage()); | ||||
|                             //throw new DkException("文件服务器图片删除失败"); | ||||
|                         } | ||||
|         /**调用API*/ | ||||
|         Integer integer = controlLibraryMidMapper.selectByLibID(String.valueOf(libraryId), YNEnums.YES.code); | ||||
|         if(integer<=0) { | ||||
|             int count = faceLibraryMapper.deleteById(faceLibrary); | ||||
|             /**删除对应的人像*/ | ||||
|             List<Portrait> portraits = portraitMapper.queryPortraitByFactory(libraryId); | ||||
|             portraitMapper.deletePortrait(libraryId); | ||||
|             if(UtilValidate.isNotEmpty(portraits)){ | ||||
|                 for (Portrait p:portraits) { | ||||
|                     /**删除文件服务器*/ | ||||
|                     try { | ||||
|                         minioUtil.removeObject(bucketName,p.getUrl()); | ||||
|                     } catch (Exception e) { | ||||
|                         log.error(e.getMessage()); | ||||
|                         //throw new DkException("文件服务器图片删除失败"); | ||||
|                     } | ||||
|                 } | ||||
|                 if (count < 0) { | ||||
|                     throw new DkException("删除库失败"); | ||||
|                 } | ||||
|             }else{ | ||||
|                 throw new DkException(SystemCode.DELETELIB_ERROR.code,"该库有关联的布控信息,不能删除!"); | ||||
|             } | ||||
|             if (count < 0) { | ||||
|                 throw new DkException("删除库失败"); | ||||
|             } | ||||
|         }else{ | ||||
|             throw new DkException(SystemCode.DELETELIB_ERROR.code,"该库有关联的布控信息,不能删除!"); | ||||
|         } | ||||
| 
 | ||||
|         return faceLibrary; | ||||
|     } | ||||
|  | ||||
| @ -72,22 +72,18 @@ public class PortraitServiceImpl extends ServiceImpl<PortraitMapper, Portrait> i | ||||
|     public Portrait addPortrait(String libraryId, MultipartFile multipartFile) { | ||||
|         /**保存数据*/ | ||||
|         Portrait portrait; | ||||
|         String[] identityMessage = new String[2]; | ||||
|         String filename; | ||||
|         String multipartFileName = multipartFile.getOriginalFilename(); | ||||
|         if (UtilValidate.isNotEmpty(multipartFileName)) { | ||||
|             boolean status = multipartFileName.contains("_"); | ||||
|             if (status) { | ||||
|                 String filename = multipartFileName.substring(0, multipartFileName.lastIndexOf(".")); | ||||
|                 identityMessage = filename.split("_"); | ||||
|             } else { | ||||
|                 throw new DkException(SystemCode.FILE_ERROR.code, multipartFileName + "文件名格式不正确"); | ||||
|             } | ||||
|             filename = multipartFileName.substring(0, multipartFileName.lastIndexOf(".")); | ||||
|         } else { | ||||
|             throw new DkException(SystemCode.FILE_ERROR.code, multipartFileName + "文件名格式不正确"); | ||||
|         } | ||||
|         ImagesVO imageVO = new ImagesVO(); | ||||
|         setimageVO(imageVO, identityMessage); | ||||
|         setimageVO(imageVO, filename); | ||||
|         try { | ||||
|             String card = imageVO.getIdCard(); | ||||
|             int hash = card.hashCode(); | ||||
|             String name = imageVO.getName(); | ||||
|             int hash = name.hashCode(); | ||||
|             if (hash < 0) { | ||||
|                 hash = 0 - hash; | ||||
|             } | ||||
| @ -103,12 +99,8 @@ public class PortraitServiceImpl extends ServiceImpl<PortraitMapper, Portrait> i | ||||
|         /**调用微云新增人像*/ | ||||
|         ApiVO face = (ApiVO) httpUtil.post(link + ApiUrlEnum.FACE_POSTURL.getUrl(), imageVO, ApiVO.class); | ||||
|         String json = gson.toJson(face.getData()); | ||||
|         ImageReturnVO imageReturnVO = null; | ||||
|         if (UtilValidate.isNotEmpty(json)) { | ||||
|             imageReturnVO = gson.fromJson(json, ImageReturnVO.class); | ||||
|         } | ||||
|         if (UtilValidate.isNotEmpty(imageReturnVO)) { | ||||
|             portrait = save(imageReturnVO, imageVO); | ||||
|         if (UtilValidate.isNotEmpty(face) && face.getCode().equals(200)) { | ||||
|             portrait = save(null, imageVO); | ||||
|         } else { | ||||
|             throw new DkException(SystemCode.FACESRH_ERROR.code, face.getMessage()); | ||||
|         } | ||||
| @ -225,7 +217,7 @@ public class PortraitServiceImpl extends ServiceImpl<PortraitMapper, Portrait> i | ||||
|                     } | ||||
|                     /**文件名:身份证_姓名*/ | ||||
|                     ImagesVO imageVO = new ImagesVO(); | ||||
|                     setimageVO(imageVO, message); | ||||
| //                    setimageVO(imageVO, message); | ||||
|                     imageVO.setUrl(map.get("url").toString()); | ||||
|                     List<ImageVO> faces = new ArrayList<>(); | ||||
|                     //faces.add(imageVO); | ||||
| @ -381,45 +373,45 @@ public class PortraitServiceImpl extends ServiceImpl<PortraitMapper, Portrait> i | ||||
|      */ | ||||
|     public Portrait save(ImageReturnVO imageReturnVO, ImagesVO imageVO) { | ||||
|         Portrait portrait = new Portrait(); | ||||
|         /**id*/ | ||||
|         if (UtilValidate.isNotEmpty(imageReturnVO.getFaceId())) { | ||||
|             portrait.setIdPortrait(Long.parseLong(imageReturnVO.getFaceId())); | ||||
|         } | ||||
|         //人脸ID | ||||
|         if (UtilValidate.isNotEmpty(imageReturnVO.getIdFaceid())) { | ||||
|             portrait.setFeatId(imageReturnVO.getIdFaceid()); | ||||
|         } | ||||
|         if (UtilValidate.isNotEmpty(imageReturnVO.getFace())) { | ||||
|             /**背景地址*/ | ||||
|             if (UtilValidate.isNotEmpty(imageReturnVO.getFace().getUrl())) { | ||||
|                 portrait.setBackgroundUrl(imageReturnVO.getFace().getUrl()); | ||||
|             } | ||||
|             /**人脸地址*/ | ||||
|             if (UtilValidate.isNotEmpty(imageReturnVO.getFace().getFaceUrl())) { | ||||
|                 portrait.setUrl(imageReturnVO.getFace().getFaceUrl()); | ||||
|             } | ||||
|         } | ||||
|         portrait.setIdPortrait(Long.parseLong(imageVO.getFaceId())); | ||||
|         portrait.setFeatId(imageVO.getFaceId()); | ||||
|         portrait.setFaceIds(imageVO.getFaceId()); | ||||
|         portrait.setName(imageVO.getName()); | ||||
|         portrait.setIdFactory(Long.parseLong(imageVO.getLibraryId())); | ||||
|         portrait.setUrl(imageVO.getUrl()); | ||||
|         portrait.setBackgroundUrl(imageVO.getUrl()); | ||||
| 
 | ||||
|         if (UtilValidate.isNotEmpty(imageReturnVO.getLibraryId())) { | ||||
|             portrait.setIdFactory(Long.parseLong(imageReturnVO.getLibraryId())); | ||||
|         } | ||||
| //        if (UtilValidate.isNotEmpty(imageReturnVO.getFace())) { | ||||
| //            /**背景地址*/ | ||||
| //            if (UtilValidate.isNotEmpty(imageReturnVO.getFace().getUrl())) { | ||||
| //                portrait.setBackgroundUrl(imageReturnVO.getFace().getUrl()); | ||||
| //            } | ||||
| //            /**人脸地址*/ | ||||
| //            if (UtilValidate.isNotEmpty(imageReturnVO.getFace().getFaceUrl())) { | ||||
| //                portrait.setUrl(imageReturnVO.getFace().getFaceUrl()); | ||||
| //            } | ||||
| //        } | ||||
| 
 | ||||
| //        if (UtilValidate.isNotEmpty(imageReturnVO.getLibraryId())) { | ||||
| //            portrait.setIdFactory(Long.parseLong(imageVO.getLibraryId())); | ||||
| //        } | ||||
|         /**出生年月*/ | ||||
|         if (UtilValidate.isNotEmpty(imageVO.getIdCard())) { | ||||
|             portrait.setBirthDate(getBirthDate(imageVO.getIdCard())); | ||||
|         } | ||||
|         /**身份证信息*/ | ||||
|         if (UtilValidate.isNotEmpty(imageReturnVO.getFace().getIdCard())) { | ||||
|             portrait.setIdCard(imageReturnVO.getFace().getIdCard()); | ||||
|         } | ||||
|         if (UtilValidate.isNotEmpty(imageVO.getName())) { | ||||
|             portrait.setName(imageVO.getName()); | ||||
|         } | ||||
|         if (UtilValidate.isNotEmpty(imageReturnVO.getFaceId())) { | ||||
|             portrait.setFaceIds(imageReturnVO.getFaceId()); | ||||
|         } | ||||
|         if (UtilValidate.isNotEmpty(imageVO.getGender())) { | ||||
|             portrait.setSex(imageVO.getGender()); | ||||
|         } | ||||
| //        if (UtilValidate.isNotEmpty(imageVO.getIdCard())) { | ||||
| //            portrait.setBirthDate(getBirthDate(imageVO.getIdCard())); | ||||
| //        } | ||||
| //        /**身份证信息*/ | ||||
| //        if (UtilValidate.isNotEmpty(imageReturnVO.getFace().getIdCard())) { | ||||
| //            portrait.setIdCard(imageReturnVO.getFace().getIdCard()); | ||||
| //        } | ||||
| //        if (UtilValidate.isNotEmpty(imageVO.getName())) { | ||||
| // | ||||
| //        } | ||||
| //        if (UtilValidate.isNotEmpty(imageReturnVO.getFaceId())) { | ||||
| //            portrait.setFaceIds(imageReturnVO.getFaceId()); | ||||
| //        } | ||||
| //        if (UtilValidate.isNotEmpty(imageVO.getGender())) { | ||||
| //            portrait.setSex(imageVO.getGender()); | ||||
| //        } | ||||
|         portrait.setIsValid(YNEnums.YES.code); | ||||
|         portrait.setCreateTime(new Date()); | ||||
|         portrait.setUpdateTime(new Date()); | ||||
| @ -461,22 +453,27 @@ public class PortraitServiceImpl extends ServiceImpl<PortraitMapper, Portrait> i | ||||
|         } | ||||
|     } | ||||
| 
 | ||||
|     public void setimageVO(ImagesVO imageVO, String[] identityMessage) { | ||||
|         if (identityMessage.length > 0) { | ||||
|             /**文件名:身份证_姓名_性别*/ | ||||
|             if (!IdCardUtil.isValidatedAllIdcard(identityMessage[0])) { | ||||
|                 throw new DkException(SystemCode.IDCARD_ERROR.code, "身份证号码输入不正确"); | ||||
|             } | ||||
|             if (UtilValidate.isNotEmpty(identityMessage[0])) { | ||||
|                 setSex(imageVO, identityMessage[0]); | ||||
|                 imageVO.setIdCard(identityMessage[0]); | ||||
|             } | ||||
|             if (UtilValidate.isNotEmpty(identityMessage[1])) { | ||||
|                 imageVO.setName(identityMessage[1]); | ||||
|             } | ||||
|         } | ||||
|     private void setimageVO(ImagesVO imageVO, String filename) { | ||||
|         imageVO.setFaceId(String.valueOf(System.currentTimeMillis())); | ||||
|         imageVO.setName(filename); | ||||
|     } | ||||
| 
 | ||||
| //    public void setimageVO(ImagesVO imageVO, String[] identityMessage) { | ||||
| //        if (identityMessage.length > 0) { | ||||
| //            /**文件名:身份证_姓名_性别*/ | ||||
| //            if (!IdCardUtil.isValidatedAllIdcard(identityMessage[0])) { | ||||
| //                throw new DkException(SystemCode.IDCARD_ERROR.code, "身份证号码输入不正确"); | ||||
| //            } | ||||
| //            if (UtilValidate.isNotEmpty(identityMessage[0])) { | ||||
| //                setSex(imageVO, identityMessage[0]); | ||||
| //                imageVO.setIdCard(identityMessage[0]); | ||||
| //            } | ||||
| //            if (UtilValidate.isNotEmpty(identityMessage[1])) { | ||||
| //                imageVO.setName(identityMessage[1]); | ||||
| //            } | ||||
| //        } | ||||
| //    } | ||||
| 
 | ||||
|     @Override | ||||
|     public SearchResultVo libSearchPage(SearchRequestVo searchRequestVo) { | ||||
|         //用户传输图片过来进行检索,调用人脸API | ||||
|  | ||||
| @ -23,7 +23,7 @@ | ||||
|     <select id="getLibraryCount" resultType="java.lang.Integer"> | ||||
|         select COUNT(*)  from portrait p where p.is_valid='Y'and p.id_factory= #{idFactory} | ||||
|     </select> | ||||
|     <select id="getLibrary" resultType="com.dkha.server.modules.entities.FaceLibrary"> | ||||
|     <select id="getLibraryByFactoryName" resultType="com.dkha.server.modules.entities.FaceLibrary"> | ||||
|         SELECT | ||||
|             f.id_factory as idFactory, | ||||
|             f.factory_name as factoryName, | ||||
| @ -33,6 +33,6 @@ | ||||
|         FROM | ||||
|             face_library f | ||||
|         WHERE | ||||
|             f.id_factory = #{factoryName} | ||||
|             f.factory_name = #{factoryName} | ||||
|     </select> | ||||
| </mapper> | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user