| | |
| | | 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.common.core.domain.entity.SysUser; |
| | | import com.ruoyi.common.utils.MapUtils; |
| | | import com.ruoyi.common.utils.SecurityUtils; |
| | | import com.ruoyi.common.utils.StringUtils; |
| | | import com.ruoyi.common.utils.poi.ExcelUtil; |
| | | import com.ruoyi.domain.ZSelfNote; |
| | | import com.ruoyi.domain.ZSelfNote; |
| | | import com.ruoyi.domain.*; |
| | | import com.ruoyi.mapper.ZSelfNoteMapper; |
| | | import com.ruoyi.service.ZSelfNoteService; |
| | | import com.ruoyi.service.*; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.Arrays; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import javax.annotation.Resource; |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * <p> |
| | |
| | | public class ZSelfNoteServiceImpl extends ServiceImpl<ZSelfNoteMapper, ZSelfNote> implements ZSelfNoteService { |
| | | |
| | | @Autowired |
| | | ZSelfNoteServiceImpl zSelfNoteService; |
| | | ZSelfNoteService zSelfNoteService; |
| | | |
| | | @Resource |
| | | ZfShareDataService zfShareDataService; |
| | | |
| | | @Resource |
| | | private EsService esSer; |
| | | |
| | | @Resource |
| | | private ZInfoUserService zInfoUserService; |
| | | |
| | | @Resource |
| | | private ZfClanService zfClanService; |
| | | |
| | | private LambdaQueryWrapper<ZSelfNote> uniqueCondition(ZSelfNote zSelfNote) { |
| | | LambdaQueryWrapper<ZSelfNote> lqw = new LambdaQueryWrapper<>(); |
| | |
| | | return lqw; |
| | | } |
| | | |
| | | private LambdaQueryWrapper<ZSelfNote> buildCondition(ZSelfNote zSelfNote, Long userId) { |
| | | private LambdaQueryWrapper<ZSelfNote> buildCondition(ZSelfNote zSelfNote) { |
| | | LambdaQueryWrapper<ZSelfNote> lqw = new LambdaQueryWrapper<>(); |
| | | lqw.eq(userId != null, ZSelfNote::getUid, userId) |
| | | lqw.in(ZSelfNote::getUid, getAll()) |
| | | .like(StringUtils.isNotEmpty(zSelfNote.getPeople()), ZSelfNote::getPeople, zSelfNote.getPeople()) |
| | | .like(StringUtils.isNotEmpty(zSelfNote.getTitle()), ZSelfNote::getTitle, zSelfNote.getTitle()) |
| | | .like(StringUtils.isNotEmpty(zSelfNote.getAddress()),ZSelfNote::getAddress,zSelfNote.getAddress()) |
| | |
| | | return lqw; |
| | | } |
| | | |
| | | |
| | | private LambdaQueryWrapper<ZSelfNote> buildConditionSec(ZSelfNote zSelfNote,List<Long> userIds) { |
| | | LambdaQueryWrapper<ZSelfNote> lqw = new LambdaQueryWrapper<>(); |
| | | // lqw.in(ZSelfNote::getUid, getAll()) |
| | | |
| | | lqw.in(ZSelfNote::getUid, userIds) |
| | | .like(StringUtils.isNotEmpty(zSelfNote.getPeople()), ZSelfNote::getPeople, zSelfNote.getPeople()) |
| | | .like(StringUtils.isNotEmpty(zSelfNote.getTitle()), ZSelfNote::getTitle, zSelfNote.getTitle()) |
| | | .like(StringUtils.isNotEmpty(zSelfNote.getAddress()),ZSelfNote::getAddress,zSelfNote.getAddress()) |
| | | .like(StringUtils.isNotEmpty(zSelfNote.getRemark()),ZSelfNote::getRemark,zSelfNote.getRemark()) |
| | | .between(zSelfNote.getHappenStartTime() != null && zSelfNote.getHappenEndTime() != null, ZSelfNote::getHappenTime, zSelfNote.getHappenStartTime(), zSelfNote.getHappenEndTime()) |
| | | .orderByDesc(ZSelfNote::getCreateTime); |
| | | return lqw; |
| | | } |
| | | |
| | | // public List<ZfShareData> getAllByShareId(ZfShareData zfShareData1){ |
| | | // SysUser user = SecurityUtils.getLoginUser().getUser(); |
| | | // Long userId = user.getUserId(); |
| | | // |
| | | // ZfShareData zfShareData = new ZfShareData(); |
| | | // zfShareData.setUserId(userId.intValue()); |
| | | // List<ZfShareData> zfShareDataList = zfShareDataService.selectList(zfShareData); |
| | | // zfShareData.setUserId(zfShareData1.getUserId()); |
| | | // zfShareDataList.addAll(zfShareDataService.selectList(zfShareData)); |
| | | // return zfShareDataList; |
| | | // } |
| | | |
| | | public List<Long> getAll(){ |
| | | SysUser user = SecurityUtils.getLoginUser().getUser(); |
| | | Long userId = user.getUserId(); |
| | | List<Long> allList = new ArrayList<>(); |
| | | Long source = zfShareDataService.getSource(userId); |
| | | allList.add(source); |
| | | allList.addAll(zfShareDataService.getAllPerson(Collections.singletonList(source))); |
| | | |
| | | List<Long> collect = allList.stream().distinct().collect(Collectors.toList()); |
| | | |
| | | List<Long> all = new ArrayList<>(); |
| | | all.add(userId); |
| | | |
| | | if(collect.size() > 1 ) { |
| | | Integer masterAccount = zfShareDataService.getByShareId(collect).get(0).getMasterAccount(); |
| | | if (masterAccount != 0 || masterAccount != userId.intValue()) { |
| | | all.clear(); |
| | | } |
| | | all.addAll(collect); |
| | | } |
| | | return all; |
| | | } |
| | | |
| | | /** |
| | | * 分页查找 |
| | | */ |
| | | @Override |
| | | public AjaxResult selectDataList(ZSelfNote zSelfNote, Integer pageNum, Integer pageSize) { |
| | | |
| | | SysUser user = SecurityUtils.getLoginUser().getUser(); |
| | | Long userId = user.getUserId(); |
| | | LambdaQueryWrapper<ZSelfNote> lqw = buildCondition(zSelfNote, userId); |
| | | |
| | | List<Long> all = getAll(); |
| | | if (all.contains(userId)) { |
| | | List<ZfShareData> byShareId = zfShareDataService.getByShareId(all); |
| | | Integer masterAccount = 0; |
| | | if(byShareId.size()>0){ |
| | | masterAccount = byShareId.get(0).getMasterAccount(); |
| | | } |
| | | ZInfoUser infoBysysId = zInfoUserService.getInfoBysysId(masterAccount.longValue()); |
| | | if (infoBysysId !=null) |
| | | { ZfClan byId = zfClanService.getById(infoBysysId.getClanId()); |
| | | return AjaxResult.success("请前往家族名称为"+byId.getClanName()+",用户名为"+infoBysysId.getNickName()+"的用户账号下查看"); |
| | | } |
| | | } |
| | | // LambdaQueryWrapper<ZSelfNote> lqw = buildCondition(zSelfNote); |
| | | //根据userId查询到infouser的uaid |
| | | ZInfoUser zInfoUser = zInfoUserService.getInfoBysysId(userId); |
| | | //拿到所有的sysid |
| | | List<Long> fms = zInfoUserService.findByUaidToFaid(zInfoUser.getUaid()).stream().map(ZInfoUser::getSysId).collect(Collectors.toList()); |
| | | LambdaQueryWrapper<ZSelfNote> lqw; |
| | | if(!fms.isEmpty()) |
| | | lqw = buildConditionSec(zSelfNote, fms); |
| | | else |
| | | lqw = buildCondition(zSelfNote); |
| | | Page<ZSelfNote> pageBean = new Page<>(pageNum, pageSize); |
| | | Page<ZSelfNote> pageResult = page(pageBean, lqw); |
| | | |
| | | List<ZSelfNote> beanRecords = pageResult.getRecords();//得到查询出来的数据 |
| | | |
| | | |
| | | HashMap<String, Object> data = MapUtils.getResult(pageResult, beanRecords); |
| | | return AjaxResult.success(data); |
| | |
| | | } |
| | | |
| | | @Override |
| | | public List<ZSelfNote> selectByCondition() { |
| | | |
| | | SysUser user = SecurityUtils.getLoginUser().getUser(); |
| | | Long userId = user.getUserId(); |
| | | |
| | | ZSelfNote zSelfNote = new ZSelfNote(); |
| | | LambdaQueryWrapper<ZSelfNote> lqw = buildCondition(zSelfNote); |
| | | return list(lqw); |
| | | } |
| | | |
| | | @Override |
| | | @Transactional |
| | | public AjaxResult importExcel(MultipartFile file) { |
| | | |
| | |
| | | assert dataList != null; |
| | | |
| | | for (ZSelfNote zSelfNote : dataList) { |
| | | zSelfNoteService.mySave(zSelfNote); |
| | | |
| | | if (zSelfNote.getTitle().length() != 0 && zSelfNote.getPeople().length() !=0){ |
| | | mySave(zSelfNote);} |
| | | else { |
| | | throw new RuntimeException("有数据的标题或人物为空"); |
| | | } |
| | | } |
| | | |
| | | return AjaxResult.success(); |