|  | @@ -4,6 +4,7 @@ import com.sysu.admin.controller.city.CityRepository;
 | 
	
		
			
				|  |  |  import com.sysu.admin.controller.city.DistrictRepository;
 | 
	
		
			
				|  |  |  import com.sysu.admin.controller.city.DistrictService;
 | 
	
		
			
				|  |  |  import com.sysu.admin.controller.city.TownService;
 | 
	
		
			
				|  |  | +import com.sysu.admin.site.CommonVo;
 | 
	
		
			
				|  |  |  import com.sysu.admin.support.base.BaseService;
 | 
	
		
			
				|  |  |  import com.sysu.admin.support.cfg.CacheCfg;
 | 
	
		
			
				|  |  |  import com.sysu.admin.utils.MySimpleDateFormat;
 | 
	
	
		
			
				|  | @@ -296,12 +297,12 @@ public class LandService extends BaseService<Land,Long> {
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -    public PaginationResult list(Double[] sure,String district, Integer townId, PaginationVo page, String cropType, Integer parcelType){
 | 
	
		
			
				|  |  | +    public PaginationResult list(CommonVo commonVo,PaginationVo page){
 | 
	
		
			
				|  |  |          String wkt = null;
 | 
	
		
			
				|  |  | -        if(townId != null) {
 | 
	
		
			
				|  |  | -             wkt = townService.findWktById(townId);
 | 
	
		
			
				|  |  | -        }else if(StringUtils.isNotBlank(district)) {
 | 
	
		
			
				|  |  | -             wkt = districtRepository.findWktByCode(district);
 | 
	
		
			
				|  |  | +        if(commonVo.getTown() != null) {
 | 
	
		
			
				|  |  | +             wkt = townService.findWktById(commonVo.getTown());
 | 
	
		
			
				|  |  | +        }else if(StringUtils.isNotBlank(commonVo.getDistrict())) {
 | 
	
		
			
				|  |  | +             wkt = districtRepository.findWktByCode(commonVo.getDistrict());
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |          List<Land> data = null;
 | 
	
		
			
				|  |  |          int count;
 | 
	
	
		
			
				|  | @@ -310,36 +311,49 @@ public class LandService extends BaseService<Land,Long> {
 | 
	
		
			
				|  |  |          StringBuffer sql = new StringBuffer(100);
 | 
	
		
			
				|  |  |          countSql.append("select count(1) from  leizhou_land where 1=1");
 | 
	
		
			
				|  |  |          sql.append("select * from  leizhou_land where 1=1");
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        StringBuffer append = appendWhere(commonVo, wkt);
 | 
	
		
			
				|  |  | +        sql.append(append);
 | 
	
		
			
				|  |  | +        countSql.append(append);
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        sql.append(" limit ").append(page.getLimit()).append(" OFFSET ").append(start);
 | 
	
		
			
				|  |  | +        count = Integer.valueOf(mEntityManager.createNativeQuery(countSql.toString()).getSingleResult().toString());
 | 
	
		
			
				|  |  | +        data = mEntityManager.createNativeQuery(sql.toString(), Land.class).getResultList();
 | 
	
		
			
				|  |  | +        return PaginationHelper.create(data, count, page.page);
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    public StringBuffer appendWhere(CommonVo commonVo, String wkt){
 | 
	
		
			
				|  |  | +        StringBuffer sql = new StringBuffer(100);
 | 
	
		
			
				|  |  |          if(wkt != null){
 | 
	
		
			
				|  |  | -            countSql.append(" and St_within(geom,st_geomfromtext('");
 | 
	
		
			
				|  |  | -            countSql.append(wkt).append("',4326))");
 | 
	
		
			
				|  |  |              sql.append(" and St_within(geom,st_geomfromtext('");
 | 
	
		
			
				|  |  |              sql.append(wkt).append("',4326))");
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -        if(StringUtils.isNotBlank(cropType)) {
 | 
	
		
			
				|  |  | -            countSql.append(" and crop_type = '").append(cropType).append("'");
 | 
	
		
			
				|  |  | -            sql.append(" and crop_type = '").append(cropType).append("'");
 | 
	
		
			
				|  |  | +        if(StringUtils.isNotBlank(commonVo.getCrop_type())) {
 | 
	
		
			
				|  |  | +            sql.append(" and crop_type = '").append(commonVo.getCrop_type()).append("'");
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -        if(parcelType != null) {
 | 
	
		
			
				|  |  | -            countSql.append(" and parcel_type = ").append(parcelType);
 | 
	
		
			
				|  |  | -            sql.append(" and parcel_type = ").append(parcelType);
 | 
	
		
			
				|  |  | +        if(commonVo.getParcel_type()!= null) {
 | 
	
		
			
				|  |  | +            sql.append(" and parcel_type = ").append(commonVo.getParcel_type());
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | +        sql.append(intervalWhere("crop_sure", commonVo.getSure()));
 | 
	
		
			
				|  |  | +        sql.append(intervalWhere("dan_chan", commonVo.getDanchan()));
 | 
	
		
			
				|  |  | +        sql.append(intervalWhere("ph", commonVo.getPh()));
 | 
	
		
			
				|  |  | +        sql.append(intervalWhere("c", commonVo.getC()));
 | 
	
		
			
				|  |  | +        sql.append(intervalWhere("_2n", commonVo.get_2n()));
 | 
	
		
			
				|  |  | +        sql.append(intervalWhere("p", commonVo.getP()));
 | 
	
		
			
				|  |  | +        sql.append(intervalWhere("k", commonVo.getK()));
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -        if(ArrayUtils.isNotEmpty(sure)){
 | 
	
		
			
				|  |  | -            countSql.append(" and crop_sure >= ").append(sure[0]);
 | 
	
		
			
				|  |  | -            countSql.append(" and crop_sure <= ").append(sure[1]);
 | 
	
		
			
				|  |  | -            sql.append(" and crop_sure >= ").append(sure[0]);
 | 
	
		
			
				|  |  | -            sql.append(" and crop_sure <= ").append(sure[1]);
 | 
	
		
			
				|  |  | -        }
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -        sql.append(" limit ").append(page.getLimit()).append(" OFFSET ").append(start);
 | 
	
		
			
				|  |  | -        count = Integer.valueOf(mEntityManager.createNativeQuery(countSql.toString()).getSingleResult().toString());
 | 
	
		
			
				|  |  | -        data = mEntityManager.createNativeQuery(sql.toString(), Land.class).getResultList();
 | 
	
		
			
				|  |  | -        return PaginationHelper.create(data, count, page.page);
 | 
	
		
			
				|  |  | +        return sql;
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | +    private StringBuffer intervalWhere(String col, Double[] values){
 | 
	
		
			
				|  |  | +        StringBuffer res = new StringBuffer(40);
 | 
	
		
			
				|  |  | +        if(ArrayUtils.isNotEmpty(values)){
 | 
	
		
			
				|  |  | +            res.append(" and "+col+" >= ").append(values[0]);
 | 
	
		
			
				|  |  | +            if(values.length > 1)
 | 
	
		
			
				|  |  | +                res.append(" and "+col+" <= ").append(values[1]);
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        return res;
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      public Land findByPoint(Double[] point){
 | 
	
	
		
			
				|  | @@ -351,3 +365,21 @@ public class LandService extends BaseService<Land,Long> {
 | 
	
		
			
				|  |  |          return landRepository;
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |  }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +
 |