From 13595459a52a8e7ecd042e8290dce75e7e2bf057 Mon Sep 17 00:00:00 2001 From: Fibonacci998 <30697927+tuansu2021998@users.noreply.github.com> Date: Fri, 24 Apr 2020 16:31:36 +0700 Subject: [PATCH] done update coordinate --- .../bean/ContributeNewRealEstateBean.java | 32 +++++---- ...nageCrawlRealEstateSetRoadSegmentBean.java | 24 +++++-- .../common/entity/District.java | 4 -- .../common/entity/Province.java | 2 - .../common/entity/SegmentOfStreet.java | 3 - .../common/entity/Street.java | 5 -- src/main/webapp/admin/listuser.xhtml | 68 +++++++++++-------- .../webapp/admin/managecrawlrealestate.xhtml | 28 ++++++-- src/main/webapp/resources/css/color.css | 12 ++++ .../resources/css/contributenewrealestate.css | 16 +++-- .../webapp/resources/css/viewmyprofile.css | 41 ++++++----- .../resources/js/contributenewrealestate.js | 8 +-- .../webapp/user/contributenewrealestate.xhtml | 15 ++-- .../user/updatecontributerealestate.xhtml | 8 +-- 14 files changed, 153 insertions(+), 113 deletions(-) create mode 100644 src/main/webapp/resources/css/color.css diff --git a/src/main/java/capstone/lip/landinformationportal/business/bean/ContributeNewRealEstateBean.java b/src/main/java/capstone/lip/landinformationportal/business/bean/ContributeNewRealEstateBean.java index ededa5c2..5c243d76 100644 --- a/src/main/java/capstone/lip/landinformationportal/business/bean/ContributeNewRealEstateBean.java +++ b/src/main/java/capstone/lip/landinformationportal/business/bean/ContributeNewRealEstateBean.java @@ -20,6 +20,8 @@ import org.springframework.security.core.Authentication; import org.springframework.security.core.context.SecurityContextHolder; +import com.google.gson.Gson; + import capstone.lip.landinformationportal.business.service.Interface.IHouseService; import capstone.lip.landinformationportal.business.service.Interface.IHousesDetailService; import capstone.lip.landinformationportal.business.service.Interface.IHousesFeatureService; @@ -37,6 +39,7 @@ import capstone.lip.landinformationportal.common.dto.HouseFeatureValue; import capstone.lip.landinformationportal.common.dto.LandFeatureValue; import capstone.lip.landinformationportal.common.entity.District; +import capstone.lip.landinformationportal.common.entity.FormedCoordinate; import capstone.lip.landinformationportal.common.entity.House; import capstone.lip.landinformationportal.common.entity.HousesDetail; import capstone.lip.landinformationportal.common.entity.HousesFeature; @@ -112,7 +115,6 @@ public class ContributeNewRealEstateBean implements Serializable { private String lngSingleCoordinate; private String latSingleCoordinate; private List listCoordinate; - private String jsonMultipleCoordinate; private String landFeatureIdSelected = ""; private String houseFeatureIdSelected = ""; @@ -617,7 +619,7 @@ public void provinceChange() { segmentStreetIdSelected = ""; nameInput = selectedProvince.getProvinceName(); - PrimeFaces.current().executeScript("focusMap(" + selectedProvince.getProvinceLat() + ", " + selectedProvince.getProvinceLng() + ");"); + PrimeFaces.current().executeScript("focusMap(" + selectedProvince.getProvinceLat() + ", " + selectedProvince.getProvinceLng() + ", 15);"); } else { listDistrict = new ArrayList<>(); listStreet = new ArrayList<>(); @@ -635,7 +637,7 @@ public void districtChange() { segmentStreetIdSelected = ""; selectedDistrict = listDistrict.stream().filter(x -> x.getDistrictId().equals(Long.parseLong(districtIdSelected))).collect(Collectors.toList()).get(0); - PrimeFaces.current().executeScript("focusMap(" + selectedDistrict.getDistrictLat() + ", " + selectedDistrict.getDistrictLng() + ");"); + PrimeFaces.current().executeScript("focusMap(" + selectedDistrict.getDistrictLat() + ", " + selectedDistrict.getDistrictLng() + ", 17);"); PrimeFaces.current().executeScript("changeInfo(\"" + selectedDistrict.getDistrictName() + "\", " + selectedDistrict.getDistrictLng() + ", " + selectedDistrict.getDistrictLat() + ")"); listSegmentOfStreet = selectedDistrict.getListSegmentOfStreet(); @@ -657,7 +659,7 @@ public void streetChange() { segmentStreetIdSelected = ""; selectedStreet = listStreet.stream().filter(x -> x.getStreetId().equals((Long.parseLong(streetIdSelected)))).collect(Collectors.toList()).get(0); - PrimeFaces.current().executeScript("focusMap(" + selectedStreet.getStreetLat() + ", " + selectedStreet.getStreetLng() + ");"); + PrimeFaces.current().executeScript("focusMap(" + selectedStreet.getStreetLat() + ", " + selectedStreet.getStreetLng() + ", 19);"); PrimeFaces.current().executeScript("changeInfo(\"" + selectedStreet.getStreetName() + "\", " + selectedStreet.getStreetLat() + ", " + selectedStreet.getStreetLng() + ")"); @@ -675,11 +677,23 @@ public void segmentStreetChange() { if (segmentStreetIdSelected != null && !segmentStreetIdSelected.equals("")) { processType = "4"; segmentOfStreet = listSegmentOfStreet.stream().filter(x -> x.getSegmentId().equals(Long.parseLong(segmentStreetIdSelected))).collect(Collectors.toList()).get(0); - PrimeFaces.current().executeScript("focusMap(" + segmentOfStreet.getSegmentLat() + ", " + segmentOfStreet.getSegmentLng() + ");"); + PrimeFaces.current().executeScript("clearDataMap()"); + PrimeFaces.current().executeScript("focusMap(" + segmentOfStreet.getSegmentLat() + ", " + segmentOfStreet.getSegmentLng() + ", 19);"); PrimeFaces.current().executeScript("changeInfo(\"" + segmentOfStreet.getSegmentName() + "\", " + segmentOfStreet.getSegmentLat() + ", " + segmentOfStreet.getSegmentLng() + ")"); PrimeFaces.current().executeScript("updateDeleteOld()"); + List listFormedCoordinate = segmentOfStreet.getListFormedCoordinate(); + List listCoordinate = listFormedCoordinate.stream() + .map(x->{ + Coordinate coor = new Coordinate(x.getFormedLng(), x.getFormedLat()); + return coor; + }).collect(Collectors.toList()); + Gson gson = new Gson(); + String jsonMultipleCoordinate = gson.toJson(listCoordinate); + + PrimeFaces.current().executeScript("drawPath('"+jsonMultipleCoordinate+"')"); + } else { segmentStreetIdSelected = ""; segmentOfStreet = null; @@ -872,14 +886,6 @@ public void setListCoordinate(List listCoordinate) { this.listCoordinate = listCoordinate; } - public String getJsonMultipleCoordinate() { - return jsonMultipleCoordinate; - } - - public void setJsonMultipleCoordinate(String jsonMultipleCoordinate) { - this.jsonMultipleCoordinate = jsonMultipleCoordinate; - } - public Province getSelectedProvince() { return selectedProvince; } diff --git a/src/main/java/capstone/lip/landinformationportal/business/bean/ManageCrawlRealEstateSetRoadSegmentBean.java b/src/main/java/capstone/lip/landinformationportal/business/bean/ManageCrawlRealEstateSetRoadSegmentBean.java index a91551cb..8bb30a74 100644 --- a/src/main/java/capstone/lip/landinformationportal/business/bean/ManageCrawlRealEstateSetRoadSegmentBean.java +++ b/src/main/java/capstone/lip/landinformationportal/business/bean/ManageCrawlRealEstateSetRoadSegmentBean.java @@ -69,15 +69,15 @@ public void showPopup(Long realEstateId) { listDistrict = null; listStreet = null; listSegment = null; - listAdjacentSegment = null; + listAdjacentSegment = realEstate.getListRealEstateAdjacentSegment(); provinceIdSelected = ""; districtIdSelected = ""; streetIdSelected = ""; roadSegmentIdSelected = ""; - singleLat = realEstate.getRealEstateLat().toString(); - singleLng = realEstate.getRealEstateLng().toString(); + singleLat = ""; + singleLng = ""; - if (realEstate.getListRealEstateAdjacentSegment() != null) { + if (realEstate.getListRealEstateAdjacentSegment() != null && !realEstate.getListRealEstateAdjacentSegment().isEmpty()) { segmentConfuse = false; }else { segmentConfuse = true; @@ -140,8 +140,14 @@ public void segmentStreetChange() { PrimeFaces.current().executeScript("drawPath('"+json+"')"); } public void saveSegmentToReo() { - - List listRealEstateByCoordinate = realEstateService.findByRealEstateLatAndRealEstateLng(realEstate.getRealEstateLat(), realEstate.getRealEstateLng()); + try { + Double.parseDouble(singleLat); + Double.parseDouble(singleLng); + }catch (Exception e) { + setMessage(FacesMessage.SEVERITY_ERROR, "Tọa độ không hợp lệ"); + return; + } + List listRealEstateByCoordinate = realEstateService.findByRealEstateLatAndRealEstateLng(Double.parseDouble(singleLat), Double.parseDouble(singleLng)); if (listRealEstateByCoordinate == null || (listRealEstateByCoordinate!=null && listRealEstateByCoordinate.isEmpty())) { coordinateConfuse = false; }else { @@ -155,15 +161,21 @@ public void saveSegmentToReo() { } + if (listAdjacentSegment == null || listAdjacentSegment.isEmpty()) { setMessage(FacesMessage.SEVERITY_ERROR, "Chưa chọn đoạn đường"); return; } realEstateAdjacentSegmentService.save(listAdjacentSegment); + + realEstate = realEstateService.findById(realEstate.getRealEstateId()); + realEstate.setRealEstateLng(Double.parseDouble(singleLng)); + realEstate.setRealEstateLat(Double.parseDouble(singleLat)); realEstate.setRealEstateStatus(String.valueOf(StatusRealEstateConstant.VERIFIED)); realEstateService.save(realEstate); setMessage(FacesMessage.SEVERITY_INFO, "Chỉnh sửa thành công"); + PrimeFaces.current().executeScript("PF('alert').renderMessage({\"summary\":\"Thành công\",\"detail\":\"Chỉnh sửa thành công\",\"severity\":\"info\"})"); showPopup = false; } diff --git a/src/main/java/capstone/lip/landinformationportal/common/entity/District.java b/src/main/java/capstone/lip/landinformationportal/common/entity/District.java index 7f012d6b..1709e09e 100644 --- a/src/main/java/capstone/lip/landinformationportal/common/entity/District.java +++ b/src/main/java/capstone/lip/landinformationportal/common/entity/District.java @@ -13,14 +13,10 @@ import javax.persistence.ManyToOne; import javax.persistence.OneToMany; import javax.persistence.Table; - import org.hibernate.annotations.LazyToOne; import org.hibernate.annotations.LazyToOneOption; import org.hibernate.annotations.NotFound; import org.hibernate.annotations.NotFoundAction; -import org.hibernate.annotations.OnDelete; -import org.hibernate.annotations.OnDeleteAction; - import capstone.lip.landinformationportal.common.entity.audit.AuditAbstract; @Entity diff --git a/src/main/java/capstone/lip/landinformationportal/common/entity/Province.java b/src/main/java/capstone/lip/landinformationportal/common/entity/Province.java index 038afb69..95eaa707 100644 --- a/src/main/java/capstone/lip/landinformationportal/common/entity/Province.java +++ b/src/main/java/capstone/lip/landinformationportal/common/entity/Province.java @@ -14,8 +14,6 @@ import org.hibernate.annotations.LazyToOneOption; import org.hibernate.annotations.NotFound; import org.hibernate.annotations.NotFoundAction; -import org.hibernate.annotations.OnDelete; -import org.hibernate.annotations.OnDeleteAction; import capstone.lip.landinformationportal.common.entity.audit.AuditAbstract; diff --git a/src/main/java/capstone/lip/landinformationportal/common/entity/SegmentOfStreet.java b/src/main/java/capstone/lip/landinformationportal/common/entity/SegmentOfStreet.java index 75bcb0ac..82d22981 100644 --- a/src/main/java/capstone/lip/landinformationportal/common/entity/SegmentOfStreet.java +++ b/src/main/java/capstone/lip/landinformationportal/common/entity/SegmentOfStreet.java @@ -2,7 +2,6 @@ import java.io.Serializable; import java.util.List; -import javax.persistence.CascadeType; import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.FetchType; @@ -17,8 +16,6 @@ import org.hibernate.annotations.LazyToOneOption; import org.hibernate.annotations.NotFound; import org.hibernate.annotations.NotFoundAction; -import org.hibernate.annotations.OnDelete; -import org.hibernate.annotations.OnDeleteAction; import capstone.lip.landinformationportal.common.entity.audit.AuditAbstract; diff --git a/src/main/java/capstone/lip/landinformationportal/common/entity/Street.java b/src/main/java/capstone/lip/landinformationportal/common/entity/Street.java index 5457bd12..d4bb047a 100644 --- a/src/main/java/capstone/lip/landinformationportal/common/entity/Street.java +++ b/src/main/java/capstone/lip/landinformationportal/common/entity/Street.java @@ -2,8 +2,6 @@ import java.io.Serializable; import java.util.List; - -import javax.persistence.CascadeType; import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.FetchType; @@ -12,13 +10,10 @@ import javax.persistence.Id; import javax.persistence.OneToMany; import javax.persistence.Table; - import org.hibernate.annotations.LazyToOne; import org.hibernate.annotations.LazyToOneOption; import org.hibernate.annotations.NotFound; import org.hibernate.annotations.NotFoundAction; -import org.hibernate.annotations.OnDelete; -import org.hibernate.annotations.OnDeleteAction; import capstone.lip.landinformationportal.common.entity.audit.AuditAbstract; @Entity diff --git a/src/main/webapp/admin/listuser.xhtml b/src/main/webapp/admin/listuser.xhtml index d740149d..f621de08 100644 --- a/src/main/webapp/admin/listuser.xhtml +++ b/src/main/webapp/admin/listuser.xhtml @@ -10,39 +10,47 @@ - - - + + + + - - - - - - - - - - - - - - - - - +
+
+ + + +
+
+ + + +
+
+ + + +
+
+ + + +
+
+ + + +
+
- +