|
@@ -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();
|