From 7fcd6ab1d7f08dd83853b42fde52f64a225ca8ea Mon Sep 17 00:00:00 2001 From: feige <791364011@qq.com> Date: 星期三, 20 十一月 2024 10:57:07 +0800 Subject: [PATCH] 修改了bug --- zhang-content/src/main/java/com/ruoyi/service/impl/ZfAncestorServiceImpl.java | 211 ++++++++++++++++++++++++++++++++++++---------------- 1 files changed, 146 insertions(+), 65 deletions(-) diff --git a/zhang-content/src/main/java/com/ruoyi/service/impl/ZfAncestorServiceImpl.java b/zhang-content/src/main/java/com/ruoyi/service/impl/ZfAncestorServiceImpl.java index 39214c0..8a9342e 100644 --- a/zhang-content/src/main/java/com/ruoyi/service/impl/ZfAncestorServiceImpl.java +++ b/zhang-content/src/main/java/com/ruoyi/service/impl/ZfAncestorServiceImpl.java @@ -1,19 +1,29 @@ package com.ruoyi.service.impl; +import com.baomidou.mybatisplus.core.conditions.Wrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; + import com.ruoyi.common.core.domain.AjaxResult; import com.ruoyi.common.core.domain.entity.EsModel; -import com.ruoyi.domain.ZInfoUser; -import com.ruoyi.domain.ZfAncestor; -import com.ruoyi.domain.ZfClan; +import com.ruoyi.common.utils.MapUtils; +import com.ruoyi.common.utils.StringUtils; +import com.ruoyi.domain.*; +import com.ruoyi.domain.dto.AncestorClan; import com.ruoyi.mapper.ZfAncestorMapper; import com.ruoyi.service.*; +import org.elasticsearch.action.delete.DeleteRequest; +import org.elasticsearch.client.RequestOptions; import org.elasticsearch.client.RestHighLevelClient; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import javax.annotation.Resource; +import java.io.IOException; import java.util.*; @Service @@ -22,6 +32,8 @@ @Resource private EsService esSer; + @Resource + private ZfAncestorMapper zfAncestorMapper; @Resource ZInfoUserService zInfoUserService; @@ -38,7 +50,7 @@ private LambdaQueryWrapper<ZfAncestor> buildCondition(ZfAncestor zfAncestor) { LambdaQueryWrapper<ZfAncestor> lqw = new LambdaQueryWrapper<>(); lqw.orderByDesc(ZfAncestor::getId); - lqw.eq(zfAncestor.getClanId() !=null , ZfAncestor::getClanId, zfAncestor.getClanId()); + lqw.eq(zfAncestor.getName()!=null, ZfAncestor::getName,zfAncestor.getName()); return lqw; } @@ -103,26 +115,85 @@ return AjaxResult.success(members); } + @Override + public AjaxResult selectDataList(ZfAncestor zfAncestor, Integer pageNo, Integer pageSize) { + QueryWrapper<Object> queryWrapper = new QueryWrapper<>(); + queryWrapper.eq(zfAncestor.getClanId() !=null , " zf_ancestor.clan_id", zfAncestor.getClanId()); + queryWrapper.eq(zfAncestor.getSysId() !=null , " zf_ancestor.sys_id ", zfAncestor.getSysId()); + queryWrapper.like(StringUtils.isNotEmpty(zfAncestor.getName()),"zf_ancestor.name",zfAncestor.getName()); + + Page<AncestorClan> info = zfAncestorMapper.selectInfo(new Page<>(pageNo, pageSize),queryWrapper); + //page(pa, wrapper); + // List<AncestorClan> orders = page(pa, wrapper); + List<AncestorClan> list =info.getRecords(); + HashMap<String, Object> data = MapUtils.getResult(info, list); + return AjaxResult.success(data); + } + + @Override + public List<AncestorClan> selectByCondition(ZfAncestor zfAncestor) { + QueryWrapper<Object> lqw = new QueryWrapper<>(); + lqw.eq(zfAncestor.getClanId() !=null , " zf_ancestor.clan_id", zfAncestor.getClanId()); + + lqw.like(StringUtils.isNotEmpty(zfAncestor.getName()),"zf_ancestor.name",zfAncestor.getName()); + + List<AncestorClan> lis = zfAncestorMapper.selectAllInfo(lqw); + + return lis; + } + + @Override + public List<AncestorClan> selectByIds(Long[] ids) { + List<AncestorClan> list = new ArrayList<>(); + QueryWrapper<Object> lqw = new QueryWrapper<>(); + // lqw.like(StringUtils.isNotEmpty(zfAncestor.getName()),"zf_ancestor.name",zfAncestor.getName()); + + // if(ids.length!=0) + // list = listByIds(Arrays.asList(ids)); + //else + list = zfAncestorMapper.selectAllInfo(lqw); +// System.out.println(list.size()); +// System.out.println("---------+++++++++---------"); + + List tmp = new ArrayList<>(Arrays.asList(ids)); + List res = new ArrayList(); + if(ids.length!=0) + { + for(AncestorClan ast : list) + { + if(tmp.contains(ast.getId().longValue())) + { + res.add(ast); + } + } + return res; + } + else + + return list; + } @Override public Long addData(ZfAncestor zfAncestor) { - LambdaQueryWrapper<ZfAncestor> lqw = buildCondition(zfAncestor); - List<ZfAncestor> list = list(lqw); - Long sysID = 0L; - if(list.size()>2){ - throw new RuntimeException("璇峰嬁閲嶅娣诲姞绁栧厛"); - } - else if (list.size() == 1){ - if (list.get(0).getSex().equals(zfAncestor.getSex())){ - throw new RuntimeException("涓や綅绁栧厛涓嶈兘涓哄悓鎬�"); - } +// LambdaQueryWrapper<ZfAncestor> lqw = buildCondition(zfAncestor); +// List<ZfAncestor> list = list(lqw); +// Long sysID = 0L; +// System.out.println("15dniwru/"+list); +// if(list.size()>0){ +// throw new RuntimeException("璇峰嬁閲嶅娣诲姞绁栧厛"); +// } + +// else if (list.size() == 1){ +// if (list.get(0).getSex().equals(zfAncestor.getSex())){ +// throw new RuntimeException("涓や綅绁栧厛涓嶈兘涓哄悓鎬�"); +// } - sysID = zInfoUserService.getInfoBysysId(list.get(0).getSysId()).getUserId(); - } - + // sysID = zInfoUserService.getInfoBysysId(list.get(0).getSysId()).getUserId(); +// } +// // if (!Long.valueOf(zfClanService.getById(zfClanManage.getClanId()).getAdminId()).equals(getUserId())) { // throw new RuntimeException("鎮ㄤ笉鏄鐞嗗憳,娌℃湁鏉冨姏娣诲姞鎴愬憳"); @@ -138,20 +209,20 @@ // zInfoUserService.saveOrUpdate(zInfoUser); save(zfAncestor); - EsModel esModel = new EsModel(); - Integer inte = zfAncestor.getClanId(); - String uuid = UUID.randomUUID().toString().replace("-",""); - esModel.setId(uuid); - esModel.setCtId(Long.valueOf(inte)); - esModel.setCtTableName("瀹舵棌绠$悊"); - esModel.setBy1(zfAncestor.getName()); - - esModel.setBy5("/zfClanManage"); -// esModel.setFid(familyId); - esSer.insertTable(esModel); +// EsModel esModel = new EsModel(); +// Integer inte = zfAncestor.getClanId(); +// String uuid = UUID.randomUUID().toString().replace("-",""); +// esModel.setId(uuid); +// esModel.setCtId(Long.valueOf(inte)); +// esModel.setCtTableName("瀹舵棌绠$悊"); +// esModel.setBy1(zfAncestor.getName()); +// +// esModel.setBy5("/zfClanManage"); +//// esModel.setFid(familyId); +// esSer.insertTable(esModel); // System.out.println(esModel); - return sysID; + return 1L; } @@ -234,53 +305,63 @@ return zfAncestor2; } + @Override + public ZfAncestor selectZfAncestor(ZfAncestor zfAncestor) { + LambdaQueryWrapper<ZfAncestor> queryWraper = new LambdaQueryWrapper<>(); + + queryWraper.eq(zfAncestor.getSysId() !=null , ZfAncestor::getSysId, zfAncestor.getSysId()); + List lis = this.list(queryWraper); + if(lis.size()>0) + return (ZfAncestor) lis.get(0); + else + return null; + } + /** * *閫氳繃瀹舵棌id鍒犻櫎 */ @Override public void deleteMember(Long ids) { -// LambdaQueryWrapper<ZfAncestor> lqw = new LambdaQueryWrapper<>(); -// lqw.eq(ZfAncestor::getClanId,ids); -// List<ZfAncestor> zfAncestors =list(lqw) ; -//// for (ZfClanManage zfClanManage : zfClanManages) { -//// if (!zfClanManages.getAdminId().equals(getUserId())) { -//// throw new RuntimeException("鎮ㄤ笉鏄鐞嗗憳,娌℃湁鏉冨姏鍒犻櫎璇ュ鏃�"); -//// } -//// } -// -//// if (!Long.valueOf(zfClanService.getById(zfClanManages.get(0).getClanId()).getAdminId()).equals(getUserId())) { -//// throw new RuntimeException("鎮ㄤ笉鏄鐞嗗憳,娌℃湁鏉冨姏鍒犻櫎鎴愬憳"); -//// } -// List<Integer> id = new ArrayList<>() ; -// for (ZfAncestor zfAncestor : zfAncestors) { -// ZInfoUser zInfoUser = zInfoUserService.getById(Long.valueOf(zfAncestor.getMemberId())); -// zInfoUser.setClanId(0); -// System.out.println(zInfoUser); -// zInfoUserService.saveOrUpdate(zInfoUser); -// id.add(zfAncestor.getId()); + LambdaQueryWrapper<ZfAncestor> lqw = new LambdaQueryWrapper<>(); + lqw.eq(ZfAncestor::getClanId,ids); + List<ZfAncestor> zfAncestors =list(lqw) ; +// for (ZfClanManage zfClanManage : zfClanManages) { +// if (!zfClanManages.getAdminId().equals(getUserId())) { +// throw new RuntimeException("鎮ㄤ笉鏄鐞嗗憳,娌℃湁鏉冨姏鍒犻櫎璇ュ鏃�"); +// } +// } - } +// if (!Long.valueOf(zfClanService.getById(zfClanManages.get(0).getClanId()).getAdminId()).equals(getUserId())) { +// throw new RuntimeException("鎮ㄤ笉鏄鐞嗗憳,娌℃湁鏉冨姏鍒犻櫎鎴愬憳"); +// } + List<Integer> id = new ArrayList<>() ; + for (ZfAncestor zfAncestor : zfAncestors) { + ZInfoUser zInfoUser = zInfoUserService.getInfoBysysId(zfAncestor.getSysId()); + zInfoUser.setClanId(0); + zInfoUserService.saveOrUpdate(zInfoUser); + id.add(zfAncestor.getId()); +// +// } /** * 鍦ㄧ敤鎴蜂俊鎭〃鍒犻櫎瀹舵棌鍙� */ + if (zfAncestorService.removeByIds(id)) { + //鍒犻櫎es涓殑鏁版嵁 + zfAncestors.stream().forEach(zfAncestor1 -> { + EsModel esModel = esSer.findByCtId((zfAncestor1.getId().intValue()), "瀹舵棌绠$悊"); + if (esModel != null) { + DeleteRequest deleteRequest = new DeleteRequest("allsearchdata", esModel.getId()); + try { + restHighLevelClient.delete(deleteRequest, RequestOptions.DEFAULT); + } catch (IOException e) { + throw new RuntimeException(e); + } + } + }); -// if (zfAncestorService.removeByIds(id)) { -// //鍒犻櫎es涓殑鏁版嵁 -// zfAncestors.stream().forEach(zfAncestor -> { -// EsModel esModel = esSer.findByCtId((zfAncestor.getId().intValue()), "瀹舵棌绠$悊"); -// if (esModel != null) { -// DeleteRequest deleteRequest = new DeleteRequest("allsearchdata", esModel.getId()); -// try { -// restHighLevelClient.delete(deleteRequest, RequestOptions.DEFAULT); -// } catch (IOException e) { -// throw new RuntimeException(e); -// } -// } -// }); -// -// -// }} + + }}} } -- Gitblit v1.9.1