智慧农业后台管理
Administrator
2022-05-23 96624efd2e472c5b5a45a5f38d137bd89c92d7b7
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 org.springblade.modules.farmplant.service.impl;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springblade.modules.farmplant.entity.FarmPlant;
import org.springblade.modules.farmplant.mapper.FarmPlantMapper;
import org.springblade.modules.farmplant.service.FarmPlantService;
import org.springblade.modules.farmplant.vo.FarmPlantVO;
import org.springframework.stereotype.Service;
 
import java.util.List;
 
/**
 * 农场养殖记录表服务实现类
 * @since 2022-05-12
 * @author zhongrj
 */
@Service
public class FarmPlantServiceImpl extends ServiceImpl<FarmPlantMapper, FarmPlant> implements FarmPlantService {
 
    /**
     * 自定义分页
     *
     * @param page
     * @param farm
     * @return
     */
    @Override
    public IPage<FarmPlantVO> selectFarmPlantPage(IPage<FarmPlantVO> page, FarmPlantVO farm) {
        List<FarmPlantVO> farmPlantVOS = baseMapper.selectFarmPlantPage(page, farm);
        //遍历
        farmPlantVOS.forEach(farmPlantVO -> {
            if (farmPlantVO.getLandUnit().equals("1")){
                farmPlantVO.setArea(String.format("%.2f", Double.parseDouble(farmPlantVO.getArea())*0.1));
            }
            if (farmPlantVO.getLandUnit().equals("2")){
                farmPlantVO.setArea(String.format("%.2f",Double.parseDouble(farmPlantVO.getArea())*0.0015));
            }
        });
        return page.setRecords(farmPlantVOS);
    }
}