|
@@ -0,0 +1,144 @@
|
|
|
|
|
+package platform.modules.api.service;
|
|
|
|
|
+
|
|
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
|
|
+import platform.modules.api.dto.SkyImageCount;
|
|
|
|
|
+import platform.modules.carrier.dto.CarrierLibraryResult;
|
|
|
|
|
+import platform.modules.carrier.dto.SearchCondition;
|
|
|
|
|
+import platform.modules.carrier.entity.Building;
|
|
|
|
|
+import platform.modules.carrier.entity.ContractFloor;
|
|
|
|
|
+import platform.modules.carrier.entity.Park;
|
|
|
|
|
+import platform.modules.carrier.service.BuildingService;
|
|
|
|
|
+import platform.modules.carrier.service.CarrierStatisticService;
|
|
|
|
|
+import platform.modules.carrier.service.ContractFloorService;
|
|
|
|
|
+import platform.modules.carrier.service.ParkService;
|
|
|
|
|
+import platform.modules.government.entity.Street;
|
|
|
|
|
+import platform.modules.government.service.StreetService;
|
|
|
|
|
+
|
|
|
|
|
+import java.util.ArrayList;
|
|
|
|
|
+import java.util.HashMap;
|
|
|
|
|
+import java.util.List;
|
|
|
|
|
+import java.util.concurrent.*;
|
|
|
|
|
+
|
|
|
|
|
+/**
|
|
|
|
|
+ * @author kevin
|
|
|
|
|
+ * @since 2019/11/13 4:27 PM
|
|
|
|
|
+ */
|
|
|
|
|
+@Service
|
|
|
|
|
+public class SkyImageCountApiService {
|
|
|
|
|
+
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private BuildingService buildingService;
|
|
|
|
|
+
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private ParkService parkService;
|
|
|
|
|
+
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private StreetService streetService;
|
|
|
|
|
+
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private CarrierStatisticService carrierStatisticService;
|
|
|
|
|
+
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private ContractFloorService contractFloorService;
|
|
|
|
|
+
|
|
|
|
|
+ private ExecutorService threadPool = new ThreadPoolExecutor(
|
|
|
|
|
+ 10,
|
|
|
|
|
+ 20,
|
|
|
|
|
+ 1L,
|
|
|
|
|
+ TimeUnit.SECONDS,
|
|
|
|
|
+ new LinkedBlockingDeque<>(100),
|
|
|
|
|
+ Executors.defaultThreadFactory(),
|
|
|
|
|
+ new ThreadPoolExecutor.CallerRunsPolicy());
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 获取厂房统计
|
|
|
|
|
+ */
|
|
|
|
|
+ public List<SkyImageCount> factoryBuilding() {
|
|
|
|
|
+ List<Building> list = buildingService.findList();
|
|
|
|
|
+ CopyOnWriteArrayList<SkyImageCount> counts = new CopyOnWriteArrayList<>();
|
|
|
|
|
+ for (Building building : list) {
|
|
|
|
|
+ SkyImageCount count = new SkyImageCount();
|
|
|
|
|
+ count.setNo(building.getNo());
|
|
|
|
|
+ if (building.getArea() != null){
|
|
|
|
|
+ count.setBuildingArea(building.getArea());
|
|
|
|
|
+ }
|
|
|
|
|
+ else {
|
|
|
|
|
+ //楼栋没有建筑面积获取楼层建筑面积
|
|
|
|
|
+ count.setBuildingArea(buildingService.findBuildingTotalArea(building.getId()));
|
|
|
|
|
+ }
|
|
|
|
|
+ count.setRentArea(buildingService.getBuildRentAreaStatistic(building.getId()));
|
|
|
|
|
+ counts.add(count);
|
|
|
|
|
+ }
|
|
|
|
|
+ return counts;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 园区统计
|
|
|
|
|
+ *
|
|
|
|
|
+ * @return
|
|
|
|
|
+ */
|
|
|
|
|
+ public List<SkyImageCount> getParkStatistic() {
|
|
|
|
|
+ List<Park> parks = parkService.findParkOnUseList();
|
|
|
|
|
+ List<SkyImageCount> counts = new ArrayList<>();
|
|
|
|
|
+ for (Park park : parks) {
|
|
|
|
|
+ SkyImageCount count = new SkyImageCount();
|
|
|
|
|
+ count.setNo(park.getNo());
|
|
|
|
|
+ double sumBuildingArea = carrierStatisticService.getSumParkBuildingArea(park.getId());
|
|
|
|
|
+ count.setBuildingArea(sumBuildingArea);
|
|
|
|
|
+ Double sumRentArea = parkService.getParkRentAreaStatistic(park.getId());
|
|
|
|
|
+ count.setRentArea(sumRentArea);
|
|
|
|
|
+ counts.add(count);
|
|
|
|
|
+ }
|
|
|
|
|
+ return counts;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 街道统计
|
|
|
|
|
+ *
|
|
|
|
|
+ * @return
|
|
|
|
|
+ */
|
|
|
|
|
+ public List getStreetStatistic() {
|
|
|
|
|
+ List<Street> streets = streetService.findList();
|
|
|
|
|
+ List<SkyImageCount> counts = new ArrayList<>();
|
|
|
|
|
+ for (Street street : streets) {
|
|
|
|
|
+ SkyImageCount count = new SkyImageCount();
|
|
|
|
|
+ count.setNo(street.getNo());
|
|
|
|
|
+ Double sumRentArea = streetService.getStreetRentAreaStatistic(street.getId());
|
|
|
|
|
+ count.setRentArea(sumRentArea);
|
|
|
|
|
+ //楼栋建筑面积为空,按楼层建筑面积和算,楼层建筑面积为空按,楼层已租、代租只和算
|
|
|
|
|
+ Double sumBuildArea = carrierStatisticService.getSumStreetBuildingArea(street.getId());
|
|
|
|
|
+ count.setBuildingArea(sumBuildArea);
|
|
|
|
|
+ counts.add(count);
|
|
|
|
|
+ }
|
|
|
|
|
+ return counts;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 租赁接口
|
|
|
|
|
+ * @param startTime
|
|
|
|
|
+ * @param endTime
|
|
|
|
|
+ * @return
|
|
|
|
|
+ */
|
|
|
|
|
+ public Object leaseBuilding(String startTime, String endTime) {
|
|
|
|
|
+ HashMap<String, List<SkyImageCount>> hashMap = new HashMap<>();
|
|
|
|
|
+ List<Building> list = buildingService.findList();
|
|
|
|
|
+ List<SkyImageCount> canRents = new CopyOnWriteArrayList<>();
|
|
|
|
|
+ List<SkyImageCount> endRents = buildingService.findEndContractByTime(startTime, endTime);
|
|
|
|
|
+ for (Building building : list) {
|
|
|
|
|
+ SkyImageCount count = new SkyImageCount();
|
|
|
|
|
+ count.setNo(building.getNo());
|
|
|
|
|
+ CarrierLibraryResult areaStatistic = buildingService.getBuildAreaStatistic(building.getId());
|
|
|
|
|
+ //相应时间内合同到期面积
|
|
|
|
|
+ List<ContractFloor> contractList =
|
|
|
|
|
+ contractFloorService.findEndContractByTime(startTime, endTime, building.getId());
|
|
|
|
|
+ if ((areaStatistic != null && areaStatistic.getSumRestArea() > 0) ||
|
|
|
|
|
+ (contractList != null && contractList.size() > 0)){
|
|
|
|
|
+ canRents.add(count);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ hashMap.put("canRents", canRents);
|
|
|
|
|
+ hashMap.put("endRents", endRents);
|
|
|
|
|
+ return hashMap;
|
|
|
|
|
+ }
|
|
|
|
|
+}
|