InspectServiceImpl.java
1.69 KB
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
package vion.service.impl;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import io.github.linpeilie.Converter;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
import vion.dto.InspectDTO;
import vion.mapper.InspectMapper;
import vion.model.Account;
import vion.model.Inspect;
import vion.model.Store;
import vion.service.IAccountService;
import vion.service.IInspectService;
import vion.service.IStoreService;
import java.util.List;
@Service
@RequiredArgsConstructor
public class InspectServiceImpl extends ServiceImpl<InspectMapper, Inspect> implements IInspectService {
private final IStoreService storeService;
private final IAccountService accountService;
private final Converter converter;
@Override
public Page<Inspect> getInspectList(InspectDTO data) {
Page<Inspect> inspectList = this.lambdaQuery(converter.convert(data, new Inspect()))
.between(data.getStartdate() != null && data.getEnddate() != null, Inspect::getInspectTime, data.getStartdate(), data.getEnddate())
.page(Page.of(data.getPageNum(), data.getPageSize()));
List<Store> storeList = storeService.list();
List<Account> accountList = accountService.list();
inspectList.getRecords().forEach(item -> {
item.setAccountName(accountList.stream().filter(v -> v.getId().equals(item.getAccountId())).map(Account::getName).findFirst().orElse("--"));
item.setStoreName(storeList.stream().filter(v -> v.getId().equals(item.getStoreId())).map(Store::getName).findFirst().orElse("--"));
});
return inspectList;
}
}