|
@@ -5,13 +5,16 @@ import com.alibaba.fastjson.JSONObject;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.sky.ioc.entity.Indeicator;
|
|
|
import com.sky.ioc.entity.Label;
|
|
|
-import com.sky.ioc.entity.domain.space.AccessSpace;
|
|
|
-import com.sky.ioc.entity.domain.space.BuildingSpace;
|
|
|
+import com.sky.ioc.entity.domain.space.*;
|
|
|
import com.sky.ioc.entity.domain.system.Users;
|
|
|
import com.sky.ioc.entity.params.IocParam;
|
|
|
import com.sky.ioc.mapper.AccessSpaceMapper;
|
|
|
import com.sky.ioc.mapper.BuildingSpaceMapper;
|
|
|
import com.sky.ioc.mapper.MeetingMapper;
|
|
|
+import com.sky.ioc.mapper.space.BuildingFloorMapper;
|
|
|
+import com.sky.ioc.mapper.space.BuildingRoomMapper;
|
|
|
+import com.sky.ioc.mapper.space.BuildingStationMapper;
|
|
|
+import com.sky.ioc.service.space.BuildingFloorService;
|
|
|
import com.sky.ioc.service.space.SpaceService;
|
|
|
import com.sky.ioc.tool.DateUtil;
|
|
|
import com.sky.ioc.tool.FalseData;
|
|
@@ -21,11 +24,13 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import java.text.DecimalFormat;
|
|
|
+import java.text.NumberFormat;
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.HashMap;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
import java.util.concurrent.ThreadLocalRandom;
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
|
* TODO 空间
|
|
@@ -46,6 +51,15 @@ public class SpaceServiceImpl implements SpaceService {
|
|
|
@Autowired
|
|
|
MeetingMapper meetingMapper;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ BuildingStationMapper buildingStationMapper;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ BuildingFloorMapper buildingFloorMapper;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ BuildingRoomMapper buildingRoomMapper;
|
|
|
+
|
|
|
/**
|
|
|
* TODO 智能看板 -- 楼宇态势
|
|
|
*
|
|
@@ -69,9 +83,30 @@ public class SpaceServiceImpl implements SpaceService {
|
|
|
Indeicator indeicator = new Indeicator();
|
|
|
List<JSONObject> objects = indeicator.getList();
|
|
|
BuildingSpace buildingSpace = buildingSpaceMapper.getByTier(iocParam);
|
|
|
+ String floorCode = iocParam.getFloorId()+"F";
|
|
|
+ if(iocParam.getFloorId()<0){
|
|
|
+ floorCode = "B"+Math.abs(iocParam.getFloorId());
|
|
|
+ }
|
|
|
+ BuildingFloor floor = buildingFloorMapper.selectOne(new LambdaQueryWrapper<BuildingFloor>().eq(BuildingFloor::getCode,floorCode));
|
|
|
+ Integer result =0;
|
|
|
+ Long totalStation = 0l;
|
|
|
+ if(floor!=null){
|
|
|
+ List<BuildingRoom> rooms = buildingRoomMapper.selectList(new LambdaQueryWrapper<BuildingRoom>().eq(BuildingRoom::getFloorId,floor.getId()));
|
|
|
+ List<Integer> ids = rooms.stream().map(BuildingRoom::getId).collect(Collectors.toList());
|
|
|
+ totalStation = buildingStationMapper.selectCount(new LambdaQueryWrapper<BuildingStation>().in(BuildingStation::getRoomId,ids));
|
|
|
+ Long usedStation = buildingStationMapper.selectCount(new LambdaQueryWrapper<BuildingStation>().in(BuildingStation::getRoomId,ids).eq(BuildingStation::getStatus,2));
|
|
|
+ // 创建一个数值格式化对象
|
|
|
+ NumberFormat numberFormat = NumberFormat.getInstance();
|
|
|
+ // 设置精确到小数点后2位
|
|
|
+ numberFormat.setMaximumFractionDigits(0);
|
|
|
+ if (totalStation>0) {
|
|
|
+ result = Integer.parseInt(numberFormat.format((float) usedStation / (float) totalStation * 100));
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
if (buildingSpace != null) {
|
|
|
- objects.get(0).put("value", buildingSpace.getUsedStation());
|
|
|
- objects.get(1).put("value", buildingSpace.getStationCount());
|
|
|
+ objects.get(0).put("value",result);
|
|
|
+ objects.get(1).put("value", totalStation);
|
|
|
objects.get(2).put("value", buildingSpace.getWorkArea());
|
|
|
objects.get(3).put("value", buildingSpace.getMeetingArea());
|
|
|
objects.add(new JSONObject());
|
|
@@ -79,8 +114,8 @@ public class SpaceServiceImpl implements SpaceService {
|
|
|
objects.get(4).put("value", buildingSpace.getLeadArea());
|
|
|
objects.get(5).put("value", buildingSpace.getOtherArea());
|
|
|
} else {
|
|
|
- objects.get(0).put("value", 0);
|
|
|
- objects.get(1).put("value", 0);
|
|
|
+ objects.get(0).put("value", result);
|
|
|
+ objects.get(1).put("value", totalStation);
|
|
|
objects.get(2).put("value", 0);
|
|
|
objects.get(3).put("value", 0);
|
|
|
objects.add(new JSONObject());
|