| | |
| | | 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.farm.entity.Farm; |
| | | import org.springblade.modules.farmplant.entity.FarmPlant; |
| | | import org.springblade.modules.farmplant.entity.Strain; |
| | | import org.springblade.modules.farmplant.mapper.FarmPlantMapper; |
| | |
| | | public List<Strain> strainTree(FarmPlantVO farm) { |
| | | return baseMapper.strainTree(farm); |
| | | } |
| | | |
| | | /** |
| | | * 农产品种养统计(累计和) |
| | | * @param farm 农产品种植对象 |
| | | * @return |
| | | */ |
| | | @Override |
| | | public FarmPlantVO getFarmPlantStatisticsCount(FarmPlantVO farm) { |
| | | List<FarmPlantVO> farmPlantVOS = baseMapper.getFarmPlantStatisticsCount(farm); |
| | | FarmPlantVO plantVO = new FarmPlantVO(); |
| | | if (farmPlantVOS.size()>0){ |
| | | BigDecimal decimal = new BigDecimal(0.0); |
| | | //遍历 |
| | | for (FarmPlantVO farmPlantVO : farmPlantVOS) { |
| | | if (farmPlantVO.getLandUnit().equals("0")){ |
| | | BigDecimal bg = new BigDecimal(farmPlantVO.getAreas()*1); |
| | | decimal = decimal.add(bg.setScale(2, BigDecimal.ROUND_HALF_UP)); |
| | | } |
| | | if (farmPlantVO.getLandUnit().equals("1")){ |
| | | BigDecimal bg = new BigDecimal(farmPlantVO.getAreas()*0.1); |
| | | decimal = decimal.add(bg.setScale(2, BigDecimal.ROUND_HALF_UP)); |
| | | } |
| | | if (farmPlantVO.getLandUnit().equals("2")){ |
| | | BigDecimal bg = new BigDecimal(farmPlantVO.getAreas()*0.0015); |
| | | decimal = decimal.add(bg.setScale(2, BigDecimal.ROUND_HALF_UP)); |
| | | } |
| | | } |
| | | //求和 |
| | | plantVO.setArea(decimal.toString()); |
| | | }else { |
| | | //求和 |
| | | plantVO.setArea("0"); |
| | | } |
| | | //返回 |
| | | return plantVO; |
| | | } |
| | | } |