package com.qianwen.mdc.service.plant;
|
|
import java.util.List;
|
import java.util.stream.Collectors;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.stereotype.Service;
|
import org.springframework.transaction.annotation.Transactional;
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.qianwen.mdc.domain.plant.Plant;
|
import com.qianwen.mdc.dto.plant.PlantDTO;
|
import com.qianwen.mdc.dto.plant.PlantQueryDTO;
|
import com.qianwen.mdc.mapper.PlantMapper;
|
|
/**
|
* @author y_ys79
|
* 厂房地图查询服务
|
*/
|
@Service
|
public class PlantQueryService {
|
@Autowired
|
private PlantMapper plantMapper;
|
@Autowired
|
private PlantService plantService;
|
/**
|
* 所有厂房列表
|
* @return
|
*/
|
@Transactional(readOnly=true)
|
public List<PlantDTO> list() {
|
|
List<Plant> plist = plantMapper.selectList(null);
|
|
return plist.stream().map(p -> {
|
PlantDTO dto = new PlantDTO();
|
dto.setId(p.getId());
|
dto.setName(p.getName());
|
dto.setGridSetting(p.getGridSetting());
|
return dto;
|
}).collect(Collectors.toList());
|
|
}
|
|
/**
|
* 厂房分页查询
|
* @param dto
|
* @return
|
*/
|
@Transactional(readOnly=true)
|
public Page<PlantDTO> pageQuery(PlantQueryDTO dto) {
|
|
Page<PlantDTO> rowPage = new Page<>(dto.finalPageNo(),dto.finalPageSize());
|
rowPage = plantMapper.queryPage(rowPage, dto);
|
|
List<PlantDTO> list = rowPage.getRecords();
|
//解析机床个数
|
for(PlantDTO p: list) {
|
p.setMachineCount(plantService.parseMachineIdInGrid(p.getGridSetting()).size());
|
}
|
return rowPage;
|
}
|
|
|
}
|