From b02beccf4567068cb47a3f1181a00039456c872d Mon Sep 17 00:00:00 2001
From: zqy <2522236926@qq.com>
Date: 星期三, 06 八月 2025 15:37:20 +0800
Subject: [PATCH] 用户修改姓名和电话同步修改uaid

---
 zhang-content/src/main/java/com/ruoyi/service/impl/ZInfoUserServiceImpl.java |  216 +++++++++++++++++++++++++++++++++++++-----------------
 1 files changed, 148 insertions(+), 68 deletions(-)

diff --git a/zhang-content/src/main/java/com/ruoyi/service/impl/ZInfoUserServiceImpl.java b/zhang-content/src/main/java/com/ruoyi/service/impl/ZInfoUserServiceImpl.java
index 0e3a51b..38f984b 100644
--- a/zhang-content/src/main/java/com/ruoyi/service/impl/ZInfoUserServiceImpl.java
+++ b/zhang-content/src/main/java/com/ruoyi/service/impl/ZInfoUserServiceImpl.java
@@ -3,6 +3,7 @@
 
 
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.ruoyi.common.core.domain.AjaxResult;
@@ -10,13 +11,11 @@
 import com.ruoyi.common.utils.MapUtils;
 import com.ruoyi.common.utils.SecurityUtils;
 import com.ruoyi.common.utils.StringUtils;
+import com.ruoyi.common.utils.uuid.UUID;
 import com.ruoyi.domain.*;
 import com.ruoyi.domain.dto.*;
 import com.ruoyi.mapper.ZInfoUserMapper;
-import com.ruoyi.service.ZInfoUserService;
-import com.ruoyi.service.ZfFamilyService;
-import com.ruoyi.service.ZfRelationService;
-import com.ruoyi.service.ZfRoleService;
+import com.ruoyi.service.*;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -26,7 +25,6 @@
 import javax.annotation.Resource;
 import java.util.*;
 import java.util.stream.Collectors;
-
 /**
  * <p>
  *  鏈嶅姟瀹炵幇绫�
@@ -48,8 +46,36 @@
     @Resource
     private ZfFamilyService zfFamilyService;
 
+
     @Resource
     private ZfRoleService zfRoleService;
+
+    @Resource
+    private ZfClanService zfClanService;
+
+
+
+    /** 浣跨浉鍚岀敤鎴峰悕+鐢佃瘽鍙风爜鐩稿悓鐨勭敤鎴峰搴旂殑uaid鍚屾*/
+    @Override
+    public void setUaidSame(String phone, String username,String uniqueId){
+        UpdateWrapper<ZInfoUser> wrapper = new UpdateWrapper<>();
+        wrapper.eq(phone!=null,"phone_number", phone)
+                .eq(username!=null,"old_name",username)
+                .set("uaid",uniqueId );
+        this.update(null, wrapper); // 鎵ц鏇存柊
+    }
+
+
+
+    @Override
+    public void setSpouseOnly(Long spouse){
+        UpdateWrapper<ZInfoUser> wrapper = new UpdateWrapper<>();
+        System.out.println("{{{{{{{{{{{{{"+spouse);
+        wrapper.eq("spouse_id", spouse)  // 浣跨敤瀛楃涓插瓧娈靛悕
+                .set("spouse_id", null);     // 鐩存帴璁剧疆瀛楁鍊�
+        this.update(null, wrapper); // 鎵ц鏇存柊
+    }
+
 
     @Override
     public AjaxResult selectInfoList(ZInfoUser zInfoUser, Integer pageNum, Integer pageSize) {
@@ -83,11 +109,56 @@
     }
 
     @Override
+    public List<ZInfoUser> findByUaidToFaid(String usid) {
+        if(usid!=null) {
+            ZInfoUser zInfoUser = new ZInfoUser();
+            zInfoUser.setUaid(usid);
+            LambdaQueryWrapper<ZInfoUser> lqw = buildCondition(zInfoUser);
+            List<ZInfoUser> ls =  list(lqw);
+          //  System.out.println(ls.size()+":==========sdfs55dfsdf");
+            return ls;
+        }else {
+            return new ArrayList<>();
+        }
+    }
+
+    @Override
     public List<ZInfoUser> selectByClanId(Integer clanId) {
         ZInfoUser zInfoUser = new ZInfoUser();
         zInfoUser.setClanId(clanId);
         LambdaQueryWrapper<ZInfoUser> lqw = buildCondition(zInfoUser);
         return list(lqw);
+    }
+
+
+//    public List<ZInfoUser> selectByNickName(String nickName){
+//        ZInfoUser zInfoUser = new ZInfoUser();
+//        zInfoUser.setNickName(nickName);
+//        LambdaQueryWrapper<ZInfoUser> lqw = buildCondition(zInfoUser);
+//        return list(lqw);
+//    }
+
+    @Override
+    public AjaxResult findUserNameAClan(List<String> nickNames)
+    {
+        List<ZfShareOther> shareOtherClans = new ArrayList<>();
+        for (String nickName:nickNames) {
+        ZInfoUser zInfoUser = new ZInfoUser();
+        zInfoUser.setNickName(nickName);
+
+        LambdaQueryWrapper<ZInfoUser> lqw = buildCondition(zInfoUser);
+        List<ZInfoUser> zInfoUsers = list(lqw);
+
+
+        for (ZInfoUser zInfoUser1: zInfoUsers) {
+            ZfShareOther shareOtherClan = new ZfShareOther();
+            shareOtherClan.setUserName(zInfoUser1.getNickName());
+            shareOtherClan.setUserId(zInfoUser1.getUserId().intValue());
+            shareOtherClan.setClanId(zInfoUser1.getClanId());
+            shareOtherClan.setClanName(zfClanService.getById(zInfoUser1.getClanId()).getClanName());
+            shareOtherClans.add(shareOtherClan);
+        }}
+        return AjaxResult.success(shareOtherClans);
     }
 
     @Override
@@ -103,9 +174,10 @@
 
 
     @Override
-    public List<ZInfoUser> getDataBySex(Integer sex){
+    public List<ZInfoUser> getDataBySex(Integer sex, Integer clanId){
         LambdaQueryWrapper<ZInfoUser> lqw = new LambdaQueryWrapper<>();
         lqw.eq(ZInfoUser::getSex, sex);
+        lqw.eq(ZInfoUser::getClanId, clanId);
         List<ZInfoUser> list = list(lqw);
         return list;
     }
@@ -140,8 +212,10 @@
         lqw.like(StringUtils.isNotEmpty(zInfoUser.getUnit()), ZInfoUser::getUnit, zInfoUser.getUnit());
         lqw.like(zInfoUser.getSex() != null, ZInfoUser::getSex, zInfoUser.getSex());
         lqw.like(zInfoUser.getMaritalStatus() != null, ZInfoUser::getMaritalStatus, zInfoUser.getMaritalStatus());
-        lqw.like(zInfoUser.getBirth() != null, ZInfoUser::getBirth, zInfoUser.getBirth());
+        lqw.le(zInfoUser.getBirth() != null, ZInfoUser::getBirth, zInfoUser.getBirth());
         lqw.like(zInfoUser.getClanId() != null, ZInfoUser::getClanId, zInfoUser.getClanId());
+
+        lqw.eq(zInfoUser.getUaid() !=null, ZInfoUser::getUaid, zInfoUser.getUaid());
         return lqw;
 
     }
@@ -151,6 +225,7 @@
         LambdaQueryWrapper<ZInfoUser> lambdaQueryWrapper = buildCondition(zInfoUser);
         List<ZInfoUser> list = list(lambdaQueryWrapper);
         log.info("杩斿洖鐨勬暟鎹负:{}", list);
+
         return list;
 
     }
@@ -416,13 +491,13 @@
         ZInfoUser zInfoUser = new ZInfoUser();
         BeanUtils.copyProperties(genealogy, zInfoUser);
         LambdaQueryWrapper<ZInfoUser> lqw = new LambdaQueryWrapper<>();
-        lqw.eq(zInfoUser.getSex() != null, ZInfoUser::getSex, zInfoUser.getSex());
-        lqw.like(StringUtils.isNotEmpty(zInfoUser.getNickName()), ZInfoUser::getNickName, zInfoUser.getNickName());
+//        lqw.eq(zInfoUser.getSex() != null, ZInfoUser::getSex, zInfoUser.getSex());
+//        lqw.like(StringUtils.isNotEmpty(zInfoUser.getNickName()), ZInfoUser::getNickName, zInfoUser.getNickName());
 //        lqw.between(zInfoUser.getBirth() != null, ZInfoUser::getBirth, zInfoUser.getBirth(),zInfoUser.getBirth());
         lqw.eq(zInfoUser.getClanId()!=null, ZInfoUser::getClanId,zInfoUser.getClanId());
         List<ZInfoUser> allPeopleList = list(lqw);
-        System.out.println(allPeopleList);
-        System.out.println("============z=============zzzzzzzzzzzzzzzzzzz");
+       // System.out.println(allPeopleList);
+        //System.out.println("============z=============zzzzzzzzzzzzzzzzzzz");
 
 //        List<ZInfoUser> allPeopleList = list();
         List<ZInfoUser> result = null;
@@ -439,7 +514,7 @@
             throw new RuntimeException("鎮ㄥ湪鍔犲叆鎴愬憳鐨勬椂鍊欐病鏈夋寚瀹氳鎴愬憳鐨勭埗浜叉垨鑰呮瘝浜�");
         }
 
-        System.out.println(result);
+       // System.out.println(result);
 
 //        result.stream().map(
 //                data->{
@@ -485,29 +560,26 @@
         userList.clear();
         List<ZInfoUser> treeList = (List<ZInfoUser>) listWithTreeByCondition(100, genealogy).get("data");
         recursionFindUser(treeList);
-      //  System.out.println(userList);
-        System.out.println("---------------");
-        List<Genealogy> allData = userList.stream().map(
-                zInfoUser -> {
-                    Genealogy newGenealogy = new Genealogy();
-                    BeanUtils.copyProperties(zInfoUser, newGenealogy);
 
-                    if (zInfoUser.getSpouseId() != null) {
-                        ZInfoUser spouse = getById(zInfoUser.getSpouseId());
+                List<Genealogy> allData = userList.stream().map(
+                        zInfoUser -> {
+                            Genealogy newGenealogy = new Genealogy();
+                            BeanUtils.copyProperties(zInfoUser, newGenealogy);
 
-                        Genealogy spouseInfo = new Genealogy();
-                        BeanUtils.copyProperties(spouse,spouseInfo);
-                        newGenealogy.setSpouse(spouseInfo);
-                        spouseInfo.setIdentity(newGenealogy.getIdentity());
-                        spouseInfo.setSpouseName(zInfoUser.getNickName());
-                        newGenealogy.setSpouseName(spouse.getNickName());
-                    }
-                    System.out.println(newGenealogy);
-                    return newGenealogy;
-                }
+                            if (zInfoUser.getSpouseId() != null) {
+                                ZInfoUser spouse = getById(zInfoUser.getSpouseId());
+
+                                Genealogy spouseInfo = new Genealogy();
+                                BeanUtils.copyProperties(spouse,spouseInfo);
+                                newGenealogy.setSpouse(spouseInfo);
+                                spouseInfo.setIdentity(newGenealogy.getIdentity());
+                                spouseInfo.setSpouseName(zInfoUser.getNickName());
+                                newGenealogy.setSpouseName(spouse.getNickName());
+                            }
+                            System.out.println(newGenealogy);
+                            return newGenealogy;
+                        }
         ).collect(Collectors.toList());
-        System.out.println(allData);
-        System.out.println("999999999988888888888++++++++++++++++++++++");
         List<Genealogy> collect = allData.stream()
                 .distinct()
                 .filter((data)-> data.getIsMyFamily() == 1)
@@ -515,18 +587,13 @@
                 .collect(Collectors.toList());
         List<Genealogy> resultData = new ArrayList<>();
 
-        for (int i = (pageNum - 1) * pageSize; i < pageNum * pageSize + pageSize; i++) {
-            if (i >= collect.size()) {
-                break;
-            }
-            resultData.add(collect.get(i));
-        }
-        System.out.println(resultData);
-        System.out.println("999999999988888888888++++++++++++++++++++++");
+
+     //   System.out.println(resultData);
+      //  System.out.println("999999999988888888888++++++++++++++++++++++");
 //
 //
         //瀵箁esult鍋氫竴涓潯浠剁瓫閫�
-        Iterator<Genealogy> it = resultData.iterator();
+        Iterator<Genealogy> it = collect.iterator();
         while(it.hasNext()){
             Genealogy data = it.next();
 
@@ -566,16 +633,18 @@
             }
 
             if(genealogy.getBirth()!=null){
-                if(data.getBirth().compareTo(genealogy.getBirth())!=0){
-                    it.remove();
-                    continue;
+                if(data.getBirth()!=null) {
+                    if (data.getBirth().compareTo(genealogy.getBirth()) != 0) {
+                        it.remove();
+                    }
                 }
+                else it.remove();
             }
         }
 
-       System.out.println(resultData);
+   //    System.out.println(resultData);
 
-        System.out.println("================++++++++++++++66666666666666666999999999");
+      //  System.out.println("================++++++++++++++66666666666666666999999999");
 
 
 //        for (Genealogy data : resultData) {
@@ -605,10 +674,17 @@
 //            }
 //
 //        }
+        for (int i = (pageNum - 1) * pageSize; i < pageNum * pageSize; i++) {
+            if (i >= collect.size()) {
+                break;
+            }
+            System.out.println(i+"//////"+collect.get(i));
+            resultData.add(collect.get(i));
+        }
 
         HashMap<String, Object> resultMap = new HashMap<>();
         resultMap.put("data", resultData);
-        resultMap.put("total", resultData.size());
+        resultMap.put("total", collect.size());
         resultMap.put("pageNum", pageNum);
         resultMap.put("pageSize", pageSize);
 
@@ -675,23 +751,25 @@
     public ZInfoUser getInfoById(Long userId) {
         ZInfoUser user = getInfoBysysId(userId);
 
+        if(user==null) {
+            //鍒╃敤userId鏌ヨ
+            LambdaQueryWrapper<ZInfoUser> lqw = new LambdaQueryWrapper<>();
+            lqw.eq(ZInfoUser::getUserId, userId);
+            List<ZInfoUser> list = list(lqw);
+            if(list.size()>0)
+                user = list.get(0);
+            else
+                return null;
 
-        if(user!=null)
-        {
-            Long familyId = user.getFamilyId();
-          //  System.out.println("dddddddddddddddddddd");
-
-            String roleName = zfRoleService.getById(user.getRoleId()).getName();
-
-            user.setRoleName(roleName);
-//            System.out.println("dddddddddddddddddddd");
-//            System.out.println(familyId);
-//            if(familyId!=null&&familyId!=-1)
-//            {
-//                String familyName = zfFamilyService.getById(familyId).getName();
-//                user.setFamilyName(familyName);
-//            }
         }
+
+        Long familyId = user.getFamilyId();
+        //  System.out.println("dddddddddddddddddddd");
+        if(user.getRoleId()==null)
+            user.setRoleId(3L);
+        String roleName = zfRoleService.getById(user.getRoleId()).getName();
+
+        user.setRoleName(roleName);
         return user;
     }
 
@@ -748,6 +826,8 @@
 
         return null;
     }
+
+
 
 
     private void recursionFindUser(List<ZInfoUser> treeList) {
@@ -839,7 +919,7 @@
         // if(depth==layer)
 
         // layer = layer + 1;
-        System.out.println(depth);
+    //    System.out.println(depth);
 
 //        List<ZInfoUser> myFamilyPeopleList = allPeopleList.stream().filter(
 //                one -> (one.getFatherId() == people.getUserId() || one.getMomId() == people.getUserId()) && (people.getIsMyFamily() == 1)
@@ -850,8 +930,8 @@
                 one -> (((one.getFamilyId()!=null && Objects.equals(one.getFatherId(), people.getUserId())) || (one.getMomId()!=null&& one.getMomId().equals(people.getUserId()))) && (one.getIsMyFamily() == 1))
         ).map(
                 one -> {
-                    System.out.println("++++++++++----0009999");
-                    System.out.println(one);
+               //     System.out.println("++++++++++----0009999");
+              //      System.out.println(one);
                     if (depth == 0) {
                         one.setIdentity(people.getIdentity() + 1);
                         //鏍规嵁閰嶅伓id鏌ヨ閰嶅伓鐨勬暟鎹紝灏佽濂戒竴璧疯繑鍥�
@@ -877,14 +957,14 @@
                         }
                         List<ZInfoUser> zinfo = fillChildren(one, allPeopleList, depth - 1);
                         one.setChildList(zinfo);
-                        System.out.println(one);
+                      //  System.out.println(one);
                         return one;
                     }
 
                     //return one;
                 }
         ).collect(Collectors.toList());
-        System.out.println(collect);
+      //  System.out.println(collect);
         return collect;
 
     }
@@ -902,7 +982,7 @@
         // if(depth==layer)
 
         // layer = layer + 1;
-        System.out.println(depth);
+       // System.out.println(depth);
         List<ZInfoUser> collect = allPeopleList.stream().filter(
                 one ->  Objects.equals(one.getFatherId(), people.getUserId()) ||  Objects.equals(one.getMomId(),people.getUserId())
         ).map(

--
Gitblit v1.9.1