AJNB 1 month ago
parent
commit
4edb597662
13 changed files with 176 additions and 25 deletions
  1. 8 0
      ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/enterprise/base/mapper/TEAreaInstanceMapper.java
  2. 8 0
      ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/enterprise/base/mapper/TEAreaModelMapper.java
  3. 8 0
      ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/enterprise/base/mapper/TEWorkroadMapper.java
  4. 1 1
      ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/enterprise/farm/controller/TwoFarmMesMapController.java
  5. 21 7
      ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/enterprise/farm/controller/VillageManageController.java
  6. 27 0
      ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/enterprise/farm/domain/VillageMesVO.java
  7. 3 1
      ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/enterprise/farm/mapper/VillageManageMapper.java
  8. 6 1
      ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/enterprise/farm/service/VillageManageService.java
  9. 33 6
      ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/enterprise/farm/service/impl/TwoFarmMesMapServiceImpl.java
  10. 48 9
      ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/enterprise/farm/service/impl/VillageManageServiceImpl.java
  11. 4 0
      ruoyi-modules/ruoyi-system/src/main/resources/mapper/system/base/TEAreaInstanceMapper.xml
  12. 4 0
      ruoyi-modules/ruoyi-system/src/main/resources/mapper/system/base/TEAreaModelMapper.xml
  13. 5 0
      ruoyi-modules/ruoyi-system/src/main/resources/mapper/system/base/TEWorkroadMapper.xml

+ 8 - 0
ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/enterprise/base/mapper/TEAreaInstanceMapper.java

@@ -58,4 +58,12 @@ public interface TEAreaInstanceMapper
      * @return 结果
      */
     public int deleteTEAreaInstanceByIds(String[] ids);
+
+    /**
+     * 删除小区信息实例
+     *
+     * @param areaModelId 小区信息实例主键
+     * @return 结果
+     */
+    public int deleteTEAreaInstanceByAreaModelIdId(String areaModelId);
 }

+ 8 - 0
ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/enterprise/base/mapper/TEAreaModelMapper.java

@@ -58,4 +58,12 @@ public interface TEAreaModelMapper
      * @return 结果
      */
     public int deleteTEAreaModelByIds(String[] ids);
+
+    /**
+     * 删除小区信息
+     *
+     * @param farmId 小区信息主键
+     * @return 结果
+     */
+    public int deleteTEAreaModelByFarmId(String farmId);
 }

+ 8 - 0
ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/enterprise/base/mapper/TEWorkroadMapper.java

@@ -58,4 +58,12 @@ public interface TEWorkroadMapper
      * @return 结果
      */
     public int deleteTEWorkroadByIds(String[] ids);
+
+    /**
+     * 删除作业路
+     *
+     * @param farmId 作业路主键
+     * @return 结果
+     */
+    public int deleteTEWorkroadByFarmId(String farmId);
 }

+ 1 - 1
ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/enterprise/farm/controller/TwoFarmMesMapController.java

@@ -33,7 +33,7 @@ public class TwoFarmMesMapController {
     }
 
     /**
-     * 删除对应农场的信息和地图经纬度
+     * 删除对应农场的信息和地图经纬度,和对应小区和作业路
      */
     @RequestMapping("/deleteFarmMesMap")
     public AjaxResult deleteFarmMesMap(@RequestBody TEFarm vo){

+ 21 - 7
ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/enterprise/farm/controller/VillageManageController.java

@@ -17,25 +17,39 @@ public class VillageManageController {
     @Resource
     VillageManageService villageManageService;
 
-//    增加小区
+    //    增加小区
     @RequestMapping("/add")
     public AjaxResult addVillage(@RequestBody VillageMesVO villageMesVo) {
-        try{
+        try {
 //            System.out.println(villageMesVo);
             return villageManageService.addVillage(villageMesVo);
-        }catch (Exception e){
+        } catch (Exception e) {
             e.printStackTrace();
             return AjaxResult.error(e.getMessage());
         }
     }
 
-    @PostMapping("/selectAll")
+    @PostMapping("/selectAllByFarmId")
     public AjaxResult selectAll(@RequestBody VillageMesVO villageMesVo) {
         try {
+//            System.out.println("VillageMesVO"+ villageMesVo);
             return villageManageService.selectVillageByFarmId(villageMesVo);
-        }catch (Exception e){
-            e.printStackTrace();
+        } catch (NullPointerException e) {
+            return AjaxResult.error("查询的farmid为空");
+        } catch (Exception e) {
+            return AjaxResult.error(String.valueOf(e));
+        }
+    }
+
+    @PostMapping("/selectAllByEnterPriseId")
+    public AjaxResult selectAll(String EnterPriseId) {
+        try {
+//            System.out.println("VillageMesVO"+ villageMesVo);
+            return villageManageService.selectVillageByEnterPriseId(EnterPriseId);
+        } catch (NullPointerException e) {
+            return AjaxResult.error("查询的farmid为空");
+        } catch (Exception e) {
+            return AjaxResult.error(String.valueOf(e));
         }
-        return null;
     }
 }

+ 27 - 0
ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/enterprise/farm/domain/VillageMesVO.java

@@ -70,5 +70,32 @@ public class VillageMesVO {
 
     //    返回数据时用的坐标点
     private List<TEAreaInstance> neighborhood_path_back;
+
+    @Override
+    public String toString() {
+        return "VillageMesVO{" +
+                "id='" + id + '\'' +
+                ", farm_id='" + farm_id + '\'' +
+                ", ridge_num=" + ridge_num +
+                ", ridge_length=" + ridge_length +
+                ", rowdir_space=" + rowdir_space +
+                ", rowdir_num=" + rowdir_num +
+                ", rowspace_space=" + rowspace_space +
+                ", rowspace_num=" + rowspace_num +
+                ", islock_ridge=" + islock_ridge +
+                ", direction=" + direction +
+                ", ridge_id='" + ridge_id + '\'' +
+                ", lng1='" + lng1 + '\'' +
+                ", lat1='" + lat1 + '\'' +
+                ", lng2='" + lng2 + '\'' +
+                ", lat2='" + lat2 + '\'' +
+                ", lng3='" + lng3 + '\'' +
+                ", lat3='" + lat3 + '\'' +
+                ", lng4='" + lng4 + '\'' +
+                ", lat4='" + lat4 + '\'' +
+                ", neighborhood_path=" + neighborhood_path +
+                ", neighborhood_path_back=" + neighborhood_path_back +
+                '}';
+    }
 }
 

+ 3 - 1
ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/enterprise/farm/mapper/VillageManageMapper.java

@@ -4,7 +4,9 @@ import com.ruoyi.system.enterprise.base.domain.TEAreaModel;
 import com.ruoyi.system.enterprise.base.mapper.TEAreaModelMapper;
 import com.ruoyi.system.enterprise.farm.domain.VillageInstanceVO;
 
+import java.util.List;
+
 public interface VillageManageMapper {
 
-    public TEAreaModel selectTEAreaModelByFarmId(String id);
+    public List<TEAreaModel> selectTEAreaModelByFarmId(String id);
 }

+ 6 - 1
ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/enterprise/farm/service/VillageManageService.java

@@ -8,6 +8,11 @@ public interface VillageManageService {
    // 新增小区
     public AjaxResult addVillage(VillageMesVO villageMesVo);
 
-    //查询小区
+    //根据农场id查询对应所有小区
     public AjaxResult selectVillageByFarmId(VillageMesVO villageMesVo);
+
+    //根据企业查询所有农场下的所有小区
+    public AjaxResult selectVillageByEnterPriseId(String EnterPriseId);
+
+
 }

+ 33 - 6
ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/enterprise/farm/service/impl/TwoFarmMesMapServiceImpl.java

@@ -1,13 +1,16 @@
 package com.ruoyi.system.enterprise.farm.service.impl;
 
 import com.ruoyi.common.core.web.domain.AjaxResult;
+import com.ruoyi.system.enterprise.base.domain.TEAreaInstance;
+import com.ruoyi.system.enterprise.base.domain.TEAreaModel;
 import com.ruoyi.system.enterprise.base.domain.TEFarm;
 import com.ruoyi.system.enterprise.base.domain.TEFarmMap;
-import com.ruoyi.system.enterprise.base.mapper.TEFarmMapMapper;
-import com.ruoyi.system.enterprise.base.mapper.TEFarmMapper;
+import com.ruoyi.system.enterprise.base.mapper.*;
 import com.ruoyi.system.enterprise.farm.domain.EnterpriseFarmVO;
 import com.ruoyi.system.enterprise.farm.domain.TwoFarmMesMapVO;
+import com.ruoyi.system.enterprise.farm.domain.VillageMesVO;
 import com.ruoyi.system.enterprise.farm.mapper.TwoFarmMesMapMapper;
+import com.ruoyi.system.enterprise.farm.mapper.VillageManageMapper;
 import com.ruoyi.system.enterprise.farm.service.TwoFarmMesMapService;
 import org.springframework.stereotype.Service;
 
@@ -32,6 +35,19 @@ public class TwoFarmMesMapServiceImpl implements TwoFarmMesMapService {
     @Resource
     TwoFarmMesMapMapper twoFarmMesMapMapper;
 
+    @Resource
+    VillageManageMapper villageManageMapper;
+
+    @Resource
+    TEAreaModelMapper teAreaModelMapper;
+
+    @Resource
+    TEAreaInstanceMapper teAreaInstanceMapper;
+
+    @Resource
+    TEWorkroadMapper teWorkroadMapper;
+
+
     @Override
     public AjaxResult addFarmMesMap(TwoFarmMesMapVO vo) {
         //处理数据
@@ -53,13 +69,24 @@ public class TwoFarmMesMapServiceImpl implements TwoFarmMesMapService {
 
     @Override
     public AjaxResult deleteFarmMesMap(TEFarm vo) {
-        //依据农村ID删除两个表的信息
+        //依据农村ID删除两个表的信息,和小区,作业路
         //farm表
         int isDeleteTeFarm = teFarmMapper.deleteTEFarmById(vo.getId());
         //farmMap表
         int isDeleteTeFarmMap = twoFarmMesMapMapper.deleteTEFarmMapByFarmId(vo.getId());
+        //area表,areaInstance表
+        //先根据农场id获取该农场所有的小区id
+        List<TEAreaModel> areas = villageManageMapper.selectTEAreaModelByFarmId(vo.getId());
+        int isDeleteAreaInstance = 0;
+        for (TEAreaModel teAreaModel : areas) {
+            isDeleteAreaInstance += teAreaInstanceMapper.deleteTEAreaInstanceByAreaModelIdId(teAreaModel.getId());
+        }
+        int isDeleteArea = teAreaModelMapper.deleteTEAreaModelByFarmId(vo.getId());
+
+        //workRoad表
+        int isDeleteWorkRoad = teWorkroadMapper.deleteTEWorkroadByFarmId(vo.getId());
         if (isDeleteTeFarm == 1 && isDeleteTeFarmMap >= 1) {
-            return AjaxResult.success("成功删除农场信息,包括" + isDeleteTeFarmMap + "条map信息");
+            return AjaxResult.success("成功删除农场信息,包括" + isDeleteTeFarmMap + "条map信息, "+isDeleteArea+"条小区信息, "+isDeleteAreaInstance+"条小区坐标, "+isDeleteWorkRoad+"条作业路");
         }
         return AjaxResult.success("操作失败");
     }
@@ -78,7 +105,7 @@ public class TwoFarmMesMapServiceImpl implements TwoFarmMesMapService {
             teFarmMap.setFarmId(teFarmTemp.getId());
             List<TEFarmMap> teFarmMapList = twoFarmMesMapMapper.selectTEFarmMapListOrderSeq(teFarmMap);
             //将得到的teFarmTemp和得到的对应teFarmMapList加入到arrList
-            arrList.add(changeTEFarmToTwoFarmMesMapVO(teFarmTemp,teFarmMapList));
+            arrList.add(changeTEFarmToTwoFarmMesMapVO(teFarmTemp, teFarmMapList));
         });
         return AjaxResult.success(arrList);
     }
@@ -117,7 +144,7 @@ public class TwoFarmMesMapServiceImpl implements TwoFarmMesMapService {
     }
 
     //处理数据,将TEFarm转变为到TwoFarmMesMapVO
-    public  TwoFarmMesMapVO changeTEFarmToTwoFarmMesMapVO(TEFarm vo,List<TEFarmMap> list) {
+    public TwoFarmMesMapVO changeTEFarmToTwoFarmMesMapVO(TEFarm vo, List<TEFarmMap> list) {
         TwoFarmMesMapVO twoFarmMesMapVO = new TwoFarmMesMapVO();
         twoFarmMesMapVO.setId(vo.getId());
         twoFarmMesMapVO.setFarm_name(vo.getFarmName());

+ 48 - 9
ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/enterprise/farm/service/impl/VillageManageServiceImpl.java

@@ -4,9 +4,11 @@ import com.ruoyi.common.core.utils.uuid.UUID;
 import com.ruoyi.common.core.web.domain.AjaxResult;
 import com.ruoyi.system.enterprise.base.domain.TEAreaInstance;
 import com.ruoyi.system.enterprise.base.domain.TEAreaModel;
+import com.ruoyi.system.enterprise.base.domain.TEFarm;
 import com.ruoyi.system.enterprise.base.domain.TEFarmMap;
 import com.ruoyi.system.enterprise.base.mapper.TEAreaInstanceMapper;
 import com.ruoyi.system.enterprise.base.mapper.TEAreaModelMapper;
+import com.ruoyi.system.enterprise.base.mapper.TEFarmMapper;
 import com.ruoyi.system.enterprise.farm.domain.VillageInstanceVO;
 import com.ruoyi.system.enterprise.farm.domain.VillageMesVO;
 import com.ruoyi.system.enterprise.farm.mapper.VillageManageMapper;
@@ -31,13 +33,16 @@ public class VillageManageServiceImpl implements VillageManageService {
     @Resource
     VillageManageMapper villageManageMapper;
 
+    @Resource
+    TEFarmMapper teFarmMapper;
+
     //新增小区
     @Override
     public AjaxResult addVillage(VillageMesVO villageMesVo) {
         String villageUuid = UUID.randomUUID().toString();
         HashMap<String, String> villageIdAndInstanceId = new HashMap<>();
         //插入小区模板
-        TEAreaModel teAreaModel = changeVillage(villageMesVo,villageUuid);
+        TEAreaModel teAreaModel = changeVillage(villageMesVo, villageUuid);
         villageIdAndInstanceId.put("id", villageUuid);
         teAreaModelMapper.insertTEAreaModel(teAreaModel);
         //插入小区实例
@@ -53,17 +58,49 @@ public class VillageManageServiceImpl implements VillageManageService {
     }
 
 
-    //根据所有农场id查询小区
+    //根据农场id查询对应所有小区
     @Override
     public AjaxResult selectVillageByFarmId(VillageMesVO villageMesVo) {
-        TEAreaModel vo = villageManageMapper.selectTEAreaModelByFarmId(villageMesVo.getFarm_id());
-        VillageMesVO new_vo = changeTEAreaModelToVillageMesVO(vo);
-        TEAreaInstance tEAreaInstance = new TEAreaInstance();
-        List<TEAreaInstance> new_instance = teAreaInstanceMapper.selectTEAreaInstanceList(tEAreaInstance);
-        new_vo.setNeighborhood_path_back(new_instance);
-        return AjaxResult.success(new_vo);
+//        System.out.println("villageMesVo.getFarm_id()"+ villageMesVo.getFarm_id());
+        List<TEAreaModel> vo = villageManageMapper.selectTEAreaModelByFarmId(villageMesVo.getFarm_id());
+//        System.out.println("vo.size()"+vo.size());
+        List<VillageMesVO> villageMesVO = new ArrayList<>();
+        for (TEAreaModel teAreaModel : vo) {
+            VillageMesVO new_vo = changeTEAreaModelToVillageMesVO(teAreaModel);
+            TEAreaInstance tEAreaInstance = new TEAreaInstance();
+            tEAreaInstance.setAreaModelId(teAreaModel.getId());
+            List<TEAreaInstance> new_instance = teAreaInstanceMapper.selectTEAreaInstanceList(tEAreaInstance);
+            new_vo.setNeighborhood_path_back(new_instance);
+            villageMesVO.add(new_vo);
+        }
+        return AjaxResult.success(villageMesVO);
     }
 
+    //根据企业id查询对应所有小区
+    @Override
+    public AjaxResult selectVillageByEnterPriseId(String EnterPriseId) {
+        TEFarm teFarm = new TEFarm();
+        teFarm.setEnterpirseId(EnterPriseId);
+        List<TEFarm> farms = teFarmMapper.selectTEFarmList(teFarm);
+        List<List<VillageMesVO>> villageMesVOs = new ArrayList<>();
+        for (TEFarm farm : farms) {
+            List<TEAreaModel> vo = villageManageMapper.selectTEAreaModelByFarmId(farm.getId());
+            List<VillageMesVO> villageMesVO = new ArrayList<>();
+            for (TEAreaModel teAreaModel : vo) {
+                VillageMesVO new_vo = changeTEAreaModelToVillageMesVO(teAreaModel);
+                TEAreaInstance tEAreaInstance = new TEAreaInstance();
+                tEAreaInstance.setAreaModelId(teAreaModel.getId());
+                List<TEAreaInstance> new_instance = teAreaInstanceMapper.selectTEAreaInstanceList(tEAreaInstance);
+                new_vo.setNeighborhood_path_back(new_instance);
+                villageMesVO.add(new_vo);
+            }
+            villageMesVOs.add(villageMesVO);
+        }
+        return AjaxResult.success(villageMesVOs);
+    }
+
+
+
     //处理数据,将VillageMesVO转换为TEAreaModel
     public TEAreaModel changeVillage(VillageMesVO villageMesVo, String villageUuid) {
         TEAreaModel teAreaModel = new TEAreaModel();
@@ -88,8 +125,9 @@ public class VillageManageServiceImpl implements VillageManageService {
         teAreaModel.setLat4(" ");
         return teAreaModel;
     }
+
     //处理数据,将teAreaInstanceVO转换为TEAreaInstance
-    public TEAreaInstance changeVillageInstanceToTEAreaInstance(List<List<Double>> paths , String villageUuid) {
+    public TEAreaInstance changeVillageInstanceToTEAreaInstance(List<List<Double>> paths, String villageUuid) {
         TEAreaInstance teAreaInstance = new TEAreaInstance();
         teAreaInstance.setId(UUID.randomUUID().toString());
         teAreaInstance.setAreaModelId(villageUuid);
@@ -104,6 +142,7 @@ public class VillageManageServiceImpl implements VillageManageService {
         teAreaInstance.setLat4(String.valueOf(paths.get(3).get(1)));
         return teAreaInstance;
     }
+
     //将TEAreaModel转换为VillageMesVO
     public VillageMesVO changeTEAreaModelToVillageMesVO(TEAreaModel teAreaModel) {
         VillageMesVO vo = new VillageMesVO();

+ 4 - 0
ruoyi-modules/ruoyi-system/src/main/resources/mapper/system/base/TEAreaInstanceMapper.xml

@@ -100,4 +100,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             #{id}
         </foreach>
     </delete>
+
+    <delete id="deleteTEAreaInstanceByAreaModelIdId" parameterType="String">
+        delete from t_e_area_instance where area_model_id = #{areaModelId}
+    </delete>
 </mapper>

+ 4 - 0
ruoyi-modules/ruoyi-system/src/main/resources/mapper/system/base/TEAreaModelMapper.xml

@@ -140,4 +140,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             #{id}
         </foreach>
     </delete>
+
+    <delete id="deleteTEAreaModelByFarmId" parameterType="String">
+        delete from t_e_area_model where farm_id = #{farmId}
+    </delete>
 </mapper>

+ 5 - 0
ruoyi-modules/ruoyi-system/src/main/resources/mapper/system/base/TEWorkroadMapper.xml

@@ -80,4 +80,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             #{id}
         </foreach>
     </delete>
+
+    <delete id="deleteTEWorkroadByFarmId" parameterType="String">
+        delete from t_e_workroad where farm_id = #{farmId}
+    </delete>
+
 </mapper>