| 
					
				 | 
			
			
				@@ -1,15 +1,22 @@ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 package com.flyer.foster.service.impl; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import cn.hutool.core.bean.BeanUtil; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import com.flyer.exception.BusinessException; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.flyer.foster.dto.app.FosterRecordAddDTO; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.flyer.foster.entity.FosterRecord; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import com.flyer.foster.entity.Garden; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.flyer.foster.mapper.IFosterRecordMapper; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.flyer.foster.pojo.StpAppUtil; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.flyer.foster.service.IFosterRecordService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import com.flyer.foster.service.IGardenService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import com.flyer.util.RedisUtil; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import org.springframework.beans.factory.annotation.Autowired; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import org.springframework.stereotype.Service; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import org.springframework.transaction.annotation.Transactional; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import java.util.Map; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 /** 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  * <p> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  * 领养记录 服务实现类 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -21,13 +28,30 @@ import org.springframework.transaction.annotation.Transactional; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 @Service 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 public class FosterRecordServiceImpl extends ServiceImpl<IFosterRecordMapper, FosterRecord> implements IFosterRecordService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    @Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    private IGardenService iGardenService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    @Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    private RedisUtil redisUtil; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     @Transactional 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     @Override 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     public boolean addFosterRecord(FosterRecordAddDTO addDTO) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         int tenantId = StpAppUtil.getTokenSession().getInt("tenantId"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        // 根据果园id找到配置的飞鸟看园果园id 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        Garden garden = iGardenService.getById(addDTO.getGardenId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        if (garden == null) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            throw new BusinessException("无效的果园id"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        // 飞鸟看园果园id 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        Integer birdseyeGardenId = garden.getBirdseyeGardenId(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        // 从缓存中取出果园下的树,获取一个未曾分配的树id, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        Map<Object, Object> treeCache = redisUtil.hmget("birdseye:tree"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         FosterRecord fosterRecord = new FosterRecord(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         BeanUtil.copyProperties(addDTO, fosterRecord); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         fosterRecord.setTenantId(tenantId); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        return this.save(fosterRecord); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//        return this.save(fosterRecord); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        return true; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 } 
			 |