| 
					
				 | 
			
			
				@@ -4,7 +4,6 @@ import com.sysu.admin.controller.city.CityRepository; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.sysu.admin.controller.city.DistrictRepository; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 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; 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -13,7 +12,6 @@ import org.springframework.beans.factory.annotation.Autowired; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import org.springframework.stereotype.Service; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import java.util.ArrayList; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-import java.util.Arrays; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import java.util.Date; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import java.util.List; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 @Service("LandService2") 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -28,21 +26,33 @@ public class LandService extends BaseService<Land,Long> { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     CityRepository cityRepository; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    public List<LandAreaStat> getLandAreaStat(){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    public List<LandAreaStat> getLandAreaStat(String district, Integer townId, Date date){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        Double percent = getPercent(date); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         List<LandAreaStat> list = new ArrayList<>(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        list.add(toLandAreaStat("crop_acre")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        list.add(toLandAreaStat("water_acre")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        list.add(toLandAreaStat("field_acre")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        return  list; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        List<Object[]> res = null; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        if(townId != null) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            String wkt = townRepository.findWktById(townId); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            res = landRepository.statMajority(wkt); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        }else if(StringUtils.isNotBlank(district)) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            String wkt = districtRepository.findWktByCode(district); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            res = landRepository.statMajority(wkt); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        }else{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            res =landRepository.statMajorityAll(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        res.stream().forEach(o -> { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            Double area = (Double)o[1]; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            LandAreaStat bean = new LandAreaStat(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            bean.setId(Integer.valueOf(o[0].toString())); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            bean.setColor(LandAreaStat.castColor(bean.getId())); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            bean.setName(LandAreaStat.castName(bean.getId())); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            bean.setArea((area + area / 2) / 1000); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            bean.setArea(bean.getArea() * percent); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            list.add(bean); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        return list; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    public LandAreaStat toLandAreaStat(String key){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        LandAreaStat cropAreaStat = new LandAreaStat(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        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){ 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -60,12 +70,12 @@ public class LandService extends BaseService<Land,Long> { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         List<Object[]> res = null; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         if(townId != null) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             String wkt = townRepository.findWktById(townId); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            res = landRepository.stat(wkt); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            res = landRepository.statCropType(wkt); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         }else if(StringUtils.isNotBlank(district)) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             String wkt = districtRepository.findWktByCode(district); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            res = landRepository.stat(wkt); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            res = landRepository.statCropType(wkt); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         }else{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            res =landRepository.statAll(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            res =landRepository.statCropTypeAll(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         res.stream().forEach(o -> { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             Double area = (Double)o[1]; 
			 |