Administrator před 2 roky
rodič
revize
8623fdfa56

+ 2 - 2
src/main/java/com/sysu/admin/api/crop/ApiLandController.java

@@ -32,12 +32,12 @@ public class ApiLandController extends BaseComponent {
 
     @RequestMapping("/land_area_stat")
     public BaseResult getLandAreaStat(@RequestBody CommonVo commonVo){
-        return R.succ(landService.getLandAreaStat(commonVo.getDate(), commonVo.getDistrict(), commonVo.getCity()));
+        return R.succ(landService.getLandAreaStat(commonVo.getMonth(), commonVo.getDistrict(), commonVo.getCity()));
     }
 
     @RequestMapping("/crop_area_stat")
     public BaseResult getCropAreaStat(@RequestBody CommonVo commonVo){
-        return R.succ(landService.getCropAreaStat(commonVo.getDate(),commonVo.getDistrict(), commonVo.getCity()));
+        return R.succ(landService.getCropAreaStat(commonVo.getMonth(),commonVo.getDistrict(), commonVo.getCity()));
     }
 
     @RequestMapping("/soil_stat")

+ 8 - 10
src/main/java/com/sysu/admin/controller/aland/LandService.java

@@ -35,13 +35,12 @@ public class LandService extends BaseService<Land,Long> {
 
     /**
      * 农业地块统计
-     * @param date
      * @param districtCode
      * @param city
      * @return
      */
-    public List<TownStatLand> getLandAreaStat(Date date, String districtCode, String city){
-        Double percent = getPercent(date);
+    public List<TownStatLand> getLandAreaStat(Integer month, String districtCode, String city){
+        Double percent = getPercent(month);
         List<Object[]> res = null;
         Map<Integer,String> namesMap = null;
         if(districtCode != null){
@@ -106,15 +105,14 @@ public class LandService extends BaseService<Land,Long> {
 
     /**
      * 根据月份得到一个1到 1.5的系数
-     * @param date
+     * @param month
      * @return
      */
-    public Double getPercent(Date date){
-        if(date == null){
+    public Double getPercent(Integer month){
+        if(month == null){
             return 1.0;
         }
-        String mm = TextUtil.leftSubstring("-",TextUtil.rightSubstring("-", MySimpleDateFormat.formatDate(date)));
-        Double percent = Double.parseDouble("1." + Integer.parseInt(mm) % 5);
+        Double percent = Double.parseDouble("1." + month % 5);
         return percent;
     }
 
@@ -122,8 +120,8 @@ public class LandService extends BaseService<Land,Long> {
      * 种植类型统计
      * @return
      */
-    public List<TownStatCrop> getCropAreaStat(Date date, String districtCode, String city){
-        Double percent = getPercent(date);
+    public List<TownStatCrop> getCropAreaStat(Integer month, String districtCode, String city){
+        Double percent = getPercent(month);
         List<Object[]> res = null;
         Map<Integer,String> namesMap = null;
         if(districtCode != null){

+ 1 - 0
src/main/java/com/sysu/admin/site/CommonVo.java

@@ -19,6 +19,7 @@ public class CommonVo {
     private String district;
     private Integer town;
     private Date date;
+    private Integer month;
     private String crop_type;
     private Double[] point;
     public Integer page = 1;

+ 2 - 1
src/test/java/com/sysu/admin/utils/shape/postgis/Main.java

@@ -7,7 +7,7 @@ import java.util.concurrent.atomic.AtomicInteger;
 
 public class Main {
     public static void main(String[] args) {
-//        PostGisUtilTest postGisUtilTest = new PostGisUtilTest();
+        PostGisUtilTest postGisUtilTest = new PostGisUtilTest();
 //        postGisUtilTest.testInsertShp();
 //        try {
 //            postGisUtilTest.createTable();
@@ -21,6 +21,7 @@ public class Main {
 //        postGisUtilTest.ST_Extent();
 //        postGisUtilTest.createIndex();
 //        postGisUtilTest.createCOLUMN();
+        postGisUtilTest.removeTables();
 
     }
 }

+ 6 - 0
src/test/java/com/sysu/admin/utils/shape/postgis/PostGisUtilTest.java

@@ -204,6 +204,12 @@ public class PostGisUtilTest {
         }
     }
 
+    public void removeTables(){
+        for(String tableName : getTableNames()){
+            System.out.println("delete from "+ tableName + " ;");
+        }
+    }
+
     public void insertLandRangeIndex(){
         for(String tableName : getTableNames()){
             System.out.println("insert into p_land_range_index(\"start\",\"end\",\"table_name\") ");