| 
					
				 | 
			
			
				@@ -2,10 +2,11 @@ package com.sysu.admin.controller.aland; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.sysu.admin.controller.city.CityRepository; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.sysu.admin.controller.city.DistrictRepository; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-import com.sysu.admin.controller.city.Town; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.sysu.admin.controller.city.TownRepository; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.sysu.admin.support.base.BaseService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.sysu.admin.support.system.config.SConfig; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import com.sysu.admin.utils.MySimpleDateFormat; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import com.sysu.admin.utils.TextUtil; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.xiesx.fastboot.core.jpa.JpaPlusRepository; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import org.apache.commons.lang3.StringUtils; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import org.springframework.beans.factory.annotation.Autowired; 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -13,6 +14,7 @@ import org.springframework.stereotype.Service; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import java.util.ArrayList; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import java.util.Arrays; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import java.util.Date; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import java.util.List; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 @Service("LandService2") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 public class LandService extends BaseService<Land,Long> { 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -42,15 +44,18 @@ public class LandService extends BaseService<Land,Long> { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         return cropAreaStat; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    public CropAreaStat toCropAreaStat(String key){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        CropAreaStat cropAreaStat = new CropAreaStat(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        SConfig field_acre =serviceContext.mSConfigService.get(key); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        cropAreaStat.setArea(Double.parseDouble(field_acre.getV())); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        cropAreaStat.setName(field_acre.getTitle()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        return cropAreaStat; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    public Double getPercent(Date date){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        if(date == null){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            return 1.0; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        String mm = TextUtil.leftSubstring("-",TextUtil.rightSubstring("-", MySimpleDateFormat.formatDate(date))); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        Double percent = Double.parseDouble("1." + Integer.parseInt(mm) % 5); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        return percent; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    public List<CropAreaStat> getCropAreaStat(String district, Integer townId) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    public List<CropAreaStat> getCropAreaStat(String district, Integer townId, Date date) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        Double percent = getPercent(date); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         List<CropAreaStat> list = new ArrayList<>(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         List<Object[]> res = null; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         if(townId != null) { 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -65,8 +70,10 @@ public class LandService extends BaseService<Land,Long> { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         res.stream().forEach(o -> { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             Double area = (Double)o[1]; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             CropAreaStat cropAreaStat = new CropAreaStat(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            cropAreaStat.setName(CropAreaStat.cast(o[0].toString())); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            cropAreaStat.setName(CropAreaStat.castName(o[0].toString())); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            cropAreaStat.setColor(CropAreaStat.castColor(o[0].toString())); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             cropAreaStat.setArea((area + area / 2) / 1000); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            cropAreaStat.setArea(cropAreaStat.getArea() * percent); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             list.add(cropAreaStat); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         return list; 
			 |