| | |
| | | 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()) |
| | | .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<Long> getAll(){ |
| | | SysUser user = SecurityUtils.getLoginUser().getUser(); |
| | | Long userId = user.getUserId(); |
| | | |
| | | List<ZfShareData> shareId = zfShareDataService.getShareId(userId); |
| | | List<ZfShareData> zfShareDataList = zfShareDataService.selectList(); |
| | | List<Long> all = new ArrayList<>(); |
| | | all.add(userId); |
| | | if(shareId.size() >0 ) { |
| | | if (shareId.get(0).getMasterAccount() == 0 || shareId.get(0).getMasterAccount() == userId.intValue()) { |
| | | all.add(shareId.get(0).getUserId().longValue()); |
| | | } |
| | | else { |
| | | all.clear(); |
| | | all.add(0L); |
| | | return all; |
| | | } |
| | | } |
| | | if (zfShareDataList.size()>0 && (zfShareDataList.get(0).getMasterAccount() == 0 || zfShareDataList.get(0).getMasterAccount() == userId.intValue())){ |
| | | for (ZfShareData zfShareOther: zfShareDataList) { |
| | | all.add(zfShareOther.getSharedId().longValue()); |
| | | } |
| | | } |
| | | |
| | | return all; |
| | | } |
| | | |
| | | /** |
| | |
| | | */ |
| | | @Override |
| | | public AjaxResult selectDataList(ZSelfNote zSelfNote, Integer pageNum, Integer pageSize) { |
| | | LambdaQueryWrapper<ZSelfNote> lqw = buildCondition(zSelfNote); |
| | | SysUser user = SecurityUtils.getLoginUser().getUser(); |
| | | Long userId = user.getUserId(); |
| | | LambdaQueryWrapper<ZSelfNote> lqw = buildCondition(zSelfNote, userId); |
| | | List<ZfShareData> zfShareOtherList = zfShareDataService.selectList(); |
| | | List<ZfShareData> shareId = zfShareDataService.getShareId(userId); |
| | | if (list(lqw).size()==0) { |
| | | Integer masterAccount = 0; |
| | | if(zfShareOtherList.size()>0 ){ |
| | | masterAccount = zfShareOtherList.get(0).getMasterAccount();} |
| | | if(shareId.size()>0){ |
| | | masterAccount = shareId.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()+"的用户账号下查看"); |
| | | } |
| | | } |
| | | |
| | | 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(); |