Browse Source

导入带图像

suntianwu 3 years ago
parent
commit
a1d82089d5
1 changed files with 19 additions and 8 deletions
  1. 19 8
      src/main/java/com/iden/bms/service/PersonService.java

+ 19 - 8
src/main/java/com/iden/bms/service/PersonService.java

@@ -538,6 +538,20 @@ public class PersonService {
      * @return
      * @return
      */
      */
     public boolean deleteById(Long id){
     public boolean deleteById(Long id){
+        IdenPerson idenPerson = this.idenPersonService.getById(id);
+
+        QueryWrapper<IdenPersonCrowdRef> queryWrapper = new QueryWrapper<>();
+        queryWrapper.lambda().eq(IdenPersonCrowdRef::getPersonId,idenPerson.getId());
+        idenPersonCrowdRefService.remove(queryWrapper);
+
+        String image = idenPerson.getImage();
+        IdenCommunity idenCommunity = this.idenCommunityService.getById(idenPerson.getCommunityId());
+        if (StringUtils.isNotEmpty(image) && idenCommunity != null) {
+            File imageFile = new File(idenRoot + "data/final/person/image/" + idenCommunity.getCode() + "/" + image.substring(image.lastIndexOf("/")));
+            if(imageFile.exists()){
+                imageFile.delete();
+            }
+        }
         return this.idenPersonService.removeById(id);
         return this.idenPersonService.removeById(id);
     }
     }
 
 
@@ -665,16 +679,13 @@ public class PersonService {
      */
      */
     @Transactional(rollbackFor = Exception.class)
     @Transactional(rollbackFor = Exception.class)
     public void updatePerson(PersonVO vo) throws BDException {
     public void updatePerson(PersonVO vo) throws BDException {
-        Long communityId = vo.getCommunityId();
-        if(communityId == null ){
-            throw new BDException("必须选择小区");
-        }
+        vo.setCommunityId(null);//不能修改小区
+
+        IdenPerson idenPerson = this.idenPersonService.getById(vo.getId());
+        Long communityId = idenPerson.getCommunityId();
         IdenCommunity idenCommunity = this.idenCommunityService.getById(communityId);
         IdenCommunity idenCommunity = this.idenCommunityService.getById(communityId);
-        if(idenCommunity == null ){
-            throw new BDException("小区不能为空");
-        }
+
         //保存人员
         //保存人员
-        IdenPerson idenPerson = new IdenPerson();
         String oldImage = idenPerson.getImage();
         String oldImage = idenPerson.getImage();
         BeanUtil.copyProperties(vo,idenPerson);
         BeanUtil.copyProperties(vo,idenPerson);
         String newImage = vo.getImage();
         String newImage = vo.getImage();