|
|
@@ -10,6 +10,7 @@ import com.studenthotel.model.utils.CommonResult;
|
|
|
import com.studenthotel.services.BuildTotalPeopleService;
|
|
|
import com.studenthotel.services.DormService;
|
|
|
import common.dto.BuildTotalPeopleDto;
|
|
|
+import common.dto.DormitoryBuildingCountedDto;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
|
@@ -63,4 +64,90 @@ public class BuildTotalPeopleController implements BuildTotalPeopleApi {
|
|
|
|
|
|
return CommonResult.ok(buildTotalPeopleDtoList);
|
|
|
}
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public CommonResult dormitoryBuildingCounted() {
|
|
|
+ String[] arr={"1栋","2栋"};
|
|
|
+ String[] arr2={"3栋","4栋"};
|
|
|
+ String[] arr3={"5栋","6栋"};
|
|
|
+ String[] arr4={"7栋","8栋"};
|
|
|
+ String[] arr5={"9栋","10栋"};
|
|
|
+ String[] arr6={"11栋","12栋"};
|
|
|
+ String[] arr7={"13栋","14栋"};
|
|
|
+ String[] arr8={"15栋","16栋"};
|
|
|
+
|
|
|
+ Integer peopleCount = buildTotalPeopleCount(arr);
|
|
|
+ Integer returned = returned(peopleCount);
|
|
|
+
|
|
|
+ Integer peopleCount2 = buildTotalPeopleCount(arr2);
|
|
|
+ Integer returned2 = returned(peopleCount2);
|
|
|
+
|
|
|
+ Integer peopleCount3 = buildTotalPeopleCount(arr3);
|
|
|
+ Integer returned3 = returned(peopleCount3);
|
|
|
+
|
|
|
+ Integer peopleCount4 = buildTotalPeopleCount(arr4);
|
|
|
+ Integer returned4 = returned(peopleCount4);
|
|
|
+
|
|
|
+ Integer peopleCount5 = buildTotalPeopleCount(arr5);
|
|
|
+ Integer returned5 = returned(peopleCount5);
|
|
|
+
|
|
|
+ Integer peopleCount6 = buildTotalPeopleCount(arr6);
|
|
|
+ Integer returned6 = returned(peopleCount6);
|
|
|
+
|
|
|
+ Integer peopleCount7 = buildTotalPeopleCount(arr7);
|
|
|
+ Integer returned7 = returned(peopleCount7);
|
|
|
+
|
|
|
+ Integer peopleCount8 = buildTotalPeopleCount(arr8);
|
|
|
+ int i = new Random().nextInt(peopleCount8 - 400);
|
|
|
+
|
|
|
+ DormitoryBuildingCountedDto dto = new DormitoryBuildingCountedDto(peopleCount, "1-2栋学生公寓", returned, peopleCount - returned);
|
|
|
+ DormitoryBuildingCountedDto dto2 = new DormitoryBuildingCountedDto(peopleCount2, "3-4栋学生公寓", returned2, peopleCount2 - returned2);
|
|
|
+ DormitoryBuildingCountedDto dto3 = new DormitoryBuildingCountedDto(peopleCount3, "5-6栋学生公寓", returned3, peopleCount3 - returned3);
|
|
|
+ DormitoryBuildingCountedDto dto4 = new DormitoryBuildingCountedDto(peopleCount4, "7-8栋学生公寓", returned4, peopleCount4 - returned4);
|
|
|
+ DormitoryBuildingCountedDto dto5 = new DormitoryBuildingCountedDto(peopleCount5, "9-10栋学生公寓", returned5, peopleCount5 - returned5);
|
|
|
+ DormitoryBuildingCountedDto dto6 = new DormitoryBuildingCountedDto(peopleCount6, "11-12栋学生公寓", returned6, peopleCount6 - returned6);
|
|
|
+ DormitoryBuildingCountedDto dto7 = new DormitoryBuildingCountedDto(peopleCount7, "13-14栋学生公寓", returned7, peopleCount7 - returned7);
|
|
|
+ DormitoryBuildingCountedDto dto8 = new DormitoryBuildingCountedDto(peopleCount8, "15-16栋学生公寓", i, peopleCount8 - i);
|
|
|
+
|
|
|
+ ArrayList<DormitoryBuildingCountedDto> dtos = new ArrayList<>();
|
|
|
+ dtos.add(dto);
|
|
|
+ dtos.add(dto2);
|
|
|
+ dtos.add(dto3);
|
|
|
+ dtos.add(dto4);
|
|
|
+ dtos.add(dto5);
|
|
|
+ dtos.add(dto6);
|
|
|
+ dtos.add(dto7);
|
|
|
+ dtos.add(dto8);
|
|
|
+
|
|
|
+ return CommonResult.ok(dtos);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 通过楼栋查询
|
|
|
+ * @param stringBuild
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public Integer buildTotalPeopleCount(String[] stringBuild){
|
|
|
+ Integer total=0;
|
|
|
+ LambdaQueryWrapper<BuildTotalPeople> wrapper=new LambdaQueryWrapper<>();
|
|
|
+ wrapper.in(BuildTotalPeople::getBuild,stringBuild);
|
|
|
+ List<BuildTotalPeople> list = buildTotalPeopleService.list(wrapper);
|
|
|
+ for (BuildTotalPeople buildTotalPeople : list) {
|
|
|
+ Integer headcount = buildTotalPeople.getHeadcount();
|
|
|
+ total=total+headcount;
|
|
|
+ }
|
|
|
+
|
|
|
+ return total;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ public Integer returned(Integer peopleCount){
|
|
|
+ int i = new Random().nextInt(peopleCount - 800);
|
|
|
+ return i+800;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
}
|