feige
5 天以前 c8668a4a71987199e610781e7ac8cc02faa4f082
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
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<peopleSea> 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<String, Object> data = new HashMap<>();
            if (thi.equals("事纪")) {
                LambdaQueryWrapper<ZfEvent> 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<ZfEvent> zfEventPage = new Page<>(pageNum, pageSize);
                Page<ZfEvent> pageResult = zfEventService.page(zfEventPage, lqw);
 
                List<ZfEvent> beanRecords = pageResult.getRecords();//得到查询出来的数据
 
                System.out.println(beanRecords);
                System.out.println(beanRecords.size());
                List<zfEventdto> 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<zfEventdto> encapData(List<ZfEvent> lis, String module)
    {
        List<zfEventdto> 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;
    }
}