package com.ruoyi.service.impl; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.ruoyi.common.core.domain.AjaxResult; import com.ruoyi.common.utils.MapUtils; import com.ruoyi.domain.ZfEvent; import com.ruoyi.domain.dto.zfEventdto; import com.ruoyi.domain.peopleSea; import com.ruoyi.service.PeopleSearchService; import com.ruoyi.service.ZfEventService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import java.util.ArrayList; import java.util.HashMap; import java.util.List; @Service public class PeopleSearchServiceImpl implements PeopleSearchService { @Autowired private ZfEventService zfEventService; private LambdaQueryWrapper buildCondition(peopleSea peops) { return null; // if(peops.getModule().equals("事纪")) { // LambdaQueryWrapper<> lqw = new LambdaQueryWrapper<>(); // lqw.orderByDesc(ZfEquipment::getHappenTime); // lqw.like(StringUtils.isNotEmpty(zfEquipment.getName()), ZfEquipment::getName, zfEquipment.getName()); // lqw.like(StringUtils.isNotEmpty(zfEquipment.getBuyer()), ZfEquipment::getBuyer, zfEquipment.getBuyer()); // lqw.like(StringUtils.isNotEmpty(zfEquipment.getContent()), ZfEquipment::getContent, zfEquipment.getContent()); // lqw.like(StringUtils.isNotEmpty(zfEquipment.getLocation()), ZfEquipment::getLocation, zfEquipment.getLocation()); // lqw.like(StringUtils.isNotEmpty(zfEquipment.getRemark()), ZfEquipment::getRemark, zfEquipment.getRemark()); // lqw.eq(zfEquipment.getHappenTime() != null, ZfEquipment::getHappenTime, zfEquipment.getHappenTime()); // // lqw.between(peops.getStartTime() != null && peops.getEndTime() != null, peopleSea::getStartTime, zfEquipment.getHappenStartTime(), zfEquipment.getHappenEndTime()); // // } return lqw; } @Override public AjaxResult selectDataList(peopleSea peopleS, Integer pageNum, Integer pageSize) { System.out.println(peopleS.getModules().toString()); for(String thi: peopleS.getModules()) { System.out.println("dsf4444"); HashMap data = new HashMap<>(); if (thi.equals("事纪")) { LambdaQueryWrapper lqw = new LambdaQueryWrapper<>(); ; //按照,分割名称 String[] pes = peopleS.getPeoples().split(","); // 后续条件用and连接 for (String pe : pes) { lqw.like(ZfEvent::getPeople, pe); } lqw.between(peopleS.getStartTime() != null && peopleS.getEndTime() != null, ZfEvent::getHappenTime, peopleS.getStartTime(), peopleS.getEndTime()); Page zfEventPage = new Page<>(pageNum, pageSize); Page pageResult = zfEventService.page(zfEventPage, lqw); List beanRecords = pageResult.getRecords();//得到查询出来的数据 System.out.println(beanRecords); System.out.println(beanRecords.size()); List dtoResult = encapData(beanRecords, "事纪"); System.out.println(dtoResult); data = MapUtils.getResult(pageResult, dtoResult); System.out.println(data); } //合并多个data return AjaxResult.success(data); } return null; } public List encapData(List lis, String module) { List daoRes = new ArrayList<>() ; for(ZfEvent obj : lis) { zfEventdto atd = new zfEventdto(); atd.setId(obj.getId()); atd.setModule(module); atd.setName(obj.getPeople()); atd.setCreateTime(obj.getHappenTime()); daoRes.add(atd); } return daoRes; } }