| | |
| | | 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; |
| | | import org.springblade.modules.farmplant.service.FarmPlantService; |
| | | import org.springblade.modules.farmplant.vo.FarmPlantVO; |
| | | import org.springblade.modules.farmplant.vo.StrainVO; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * 农场养殖记录表服务实现类 |
| | | * @since 2022-05-12 |
| | | * |
| | | * @author zhongrj |
| | | * @since 2022-05-12 |
| | | */ |
| | | @Service |
| | | public class FarmPlantServiceImpl extends ServiceImpl<FarmPlantMapper, FarmPlant> implements FarmPlantService { |
| | |
| | | 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)); |
| | | //面积单位(0: 亩 1:分 2:平方米) |
| | | if (farmPlantVO.getLandUnit().equals("0")) { |
| | | farmPlantVO.setArea(String.format("%.2f", Double.parseDouble(farmPlantVO.getArea()) * 1)); |
| | | } |
| | | if (farmPlantVO.getLandUnit().equals("2")){ |
| | | farmPlantVO.setArea(String.format("%.2f",Double.parseDouble(farmPlantVO.getArea())*0.0015)); |
| | | 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); |
| | | } |
| | | |
| | | @Override |
| | | public IPage<FarmPlantVO> selectFarmPlantPageCount(IPage<Object> page, FarmPlantVO farmPlant) { |
| | | return baseMapper.selectFarmPlantPageCount(page, farmPlant); |
| | | } |
| | | |
| | | @Override |
| | | public IPage<FarmPlantVO> selectFarmPlantPageCountYM(IPage<Object> page, FarmPlantVO farmPlant) { |
| | | return baseMapper.selectFarmPlantPageCountYM(page, farmPlant); |
| | | } |
| | | |
| | | @Override |
| | | public IPage<FarmPlantVO> getFarmPlantStatisticsCountz(IPage<FarmPlantVO> page, FarmPlantVO farm) { |
| | | List<FarmPlantVO> farmPlantVOS = baseMapper.getFarmPlantStatisticsCountz(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); |
| | | } |
| | | |
| | | /** |
| | | * 农产品种养统计 |
| | | * |
| | | * @param farm 农产品种植对象 |
| | | * @param page 分页查询对象 |
| | | * @return |
| | |
| | | public IPage<FarmPlantVO> getFarmPlantStatistics(IPage<FarmPlantVO> page, FarmPlantVO farm) { |
| | | List<FarmPlantVO> farmPlantVOS = baseMapper.getFarmPlantStatistics(page, farm); |
| | | //遍历 |
| | | farmPlantVOS.forEach(farmPlantVO -> { |
| | | if (farmPlantVO.getLandUnit().equals("1")){ |
| | | BigDecimal bg = new BigDecimal(farmPlantVO.getAreas()*0.1); |
| | | farmPlantVO.setAreas(bg.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue()); |
| | | } |
| | | if (farmPlantVO.getLandUnit().equals("2")){ |
| | | BigDecimal bg = new BigDecimal(farmPlantVO.getAreas()*0.0015); |
| | | farmPlantVO.setAreas(bg.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue()); |
| | | } |
| | | }); |
| | | // farmPlantVOS.forEach(farmPlantVO -> { |
| | | // if (farmPlantVO.getLandUnit().equals("1")) { |
| | | // BigDecimal bg = new BigDecimal(farmPlantVO.getAreas() * 0.1); |
| | | // farmPlantVO.setAreas(bg.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue()); |
| | | // } |
| | | // if (farmPlantVO.getLandUnit().equals("2")) { |
| | | // BigDecimal bg = new BigDecimal(farmPlantVO.getAreas() * 0.0015); |
| | | // farmPlantVO.setAreas(bg.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue()); |
| | | // } |
| | | // }); |
| | | return page.setRecords(farmPlantVOS); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 农产品列表 |
| | | * |
| | | * @param farm 农产品对象 |
| | | * @return |
| | | */ |
| | | @Override |
| | | 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; |
| | | } |
| | | |
| | | @Override |
| | | public int selectCount(FarmPlantVO farm) { |
| | | return baseMapper.selectCount(farm); |
| | | } |
| | | |
| | | @Override |
| | | public Map selectPlant(String code, String time) { |
| | | return baseMapper.selectPlant(code, time); |
| | | } |
| | | |
| | | @Override |
| | | public Map selectPlantl(String code, String time) { |
| | | return baseMapper.selectPlantl(code, time); |
| | | } |
| | | |
| | | @Override |
| | | public Map selectPlantw(String code, String time) { |
| | | return baseMapper.selectPlantw(code, time); |
| | | } |
| | | |
| | | @Override |
| | | public Map selectPlantp(String code, String time) { |
| | | return baseMapper.selectPlantp(code, time); |
| | | } |
| | | |
| | | @Override |
| | | public Map selectProduct(String code, String time) { |
| | | return baseMapper.selectProduct(code, time); |
| | | } |
| | | |
| | | @Override |
| | | public Map selectProducty(String code, String time) { |
| | | return baseMapper.selectProducty(code, time); |
| | | } |
| | | |
| | | @Override |
| | | public Map selectProductr(String code, String time) { |
| | | return baseMapper.selectProductr(code, time); |
| | | } |
| | | |
| | | @Override |
| | | public Map selectProducts(String code, String time) { |
| | | return baseMapper.selectProducts(code, time); |
| | | } |
| | | |
| | | @Override |
| | | public Map selectProductf(String code, String time) { |
| | | return baseMapper.selectProductf(code, time); |
| | | } |
| | | |
| | | /** |
| | | * 查询种养记录列表(不分页) |
| | | * @param farmPlant |
| | | * @return |
| | | */ |
| | | @Override |
| | | public List<FarmPlantVO> getFarmPlantList(FarmPlantVO farmPlant) { |
| | | return baseMapper.getFarmPlantList(farmPlant); |
| | | } |
| | | } |