|  |  |  | 
|---|
|  |  |  | import com.alibaba.fastjson.JSONArray; | 
|---|
|  |  |  | import com.alibaba.fastjson.JSONObject; | 
|---|
|  |  |  | import com.doumee.api.BaseController; | 
|---|
|  |  |  | import com.doumee.config.annotation.CloudRequiredPermission; | 
|---|
|  |  |  | import com.doumee.core.annotation.excel.ExcelExporter; | 
|---|
|  |  |  | import com.doumee.core.annotation.pr.PreventRepeat; | 
|---|
|  |  |  | import com.doumee.core.model.ApiResponse; | 
|---|
|  |  |  | 
|---|
|  |  |  | import io.swagger.annotations.ApiImplicitParam; | 
|---|
|  |  |  | import io.swagger.annotations.ApiImplicitParams; | 
|---|
|  |  |  | import io.swagger.annotations.ApiOperation; | 
|---|
|  |  |  | import org.apache.shiro.authz.annotation.RequiresPermissions; | 
|---|
|  |  |  | import org.springframework.beans.factory.annotation.Autowired; | 
|---|
|  |  |  | import org.springframework.util.CollectionUtils; | 
|---|
|  |  |  | import org.springframework.web.bind.annotation.*; | 
|---|
|  |  |  | 
|---|
|  |  |  | @PreventRepeat | 
|---|
|  |  |  | @ApiOperation("新建") | 
|---|
|  |  |  | @PostMapping("/create") | 
|---|
|  |  |  | @RequiresPermissions("business:bookings:create") | 
|---|
|  |  |  | @CloudRequiredPermission("business:bookings:create") | 
|---|
|  |  |  | public ApiResponse create(@RequestBody Bookings bookings,@RequestHeader(Constants.HEADER_USER_TOKEN) String token){ | 
|---|
|  |  |  | LoginUserInfo user = getLoginUser(token); | 
|---|
|  |  |  | bookings.setLoginUserInfo(user); | 
|---|
|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @ApiOperation("根据ID删除") | 
|---|
|  |  |  | @GetMapping("/delete/{id}") | 
|---|
|  |  |  | @RequiresPermissions("business:bookings:delete") | 
|---|
|  |  |  | @CloudRequiredPermission("business:bookings:delete") | 
|---|
|  |  |  | public ApiResponse deleteById(@PathVariable Integer id,@RequestHeader(Constants.HEADER_USER_TOKEN) String token){ | 
|---|
|  |  |  | bookingsService.deleteById(id,this.getLoginUser(token)); | 
|---|
|  |  |  | return ApiResponse.success(null); | 
|---|
|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @ApiOperation("批量删除") | 
|---|
|  |  |  | @GetMapping("/delete/batch") | 
|---|
|  |  |  | @RequiresPermissions("business:bookings:delete") | 
|---|
|  |  |  | @CloudRequiredPermission("business:bookings:delete") | 
|---|
|  |  |  | public ApiResponse deleteByIdInBatch(@RequestParam String ids,@RequestHeader(Constants.HEADER_USER_TOKEN) String token){ | 
|---|
|  |  |  | String [] idArray = ids.split(","); | 
|---|
|  |  |  | List<Integer> idList = new ArrayList<>(); | 
|---|
|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @ApiOperation("根据ID修改") | 
|---|
|  |  |  | @PostMapping("/updateById") | 
|---|
|  |  |  | @RequiresPermissions("business:bookings:update") | 
|---|
|  |  |  | @CloudRequiredPermission("business:bookings:update") | 
|---|
|  |  |  | public ApiResponse updateById(@RequestBody Bookings bookings,@RequestHeader(Constants.HEADER_USER_TOKEN) String token){ | 
|---|
|  |  |  | LoginUserInfo user = getLoginUser(token); | 
|---|
|  |  |  | bookings.setLoginUserInfo(user); | 
|---|
|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @ApiOperation("分页查询") | 
|---|
|  |  |  | @PostMapping("/page") | 
|---|
|  |  |  | @RequiresPermissions("business:bookings:query") | 
|---|
|  |  |  | @CloudRequiredPermission("business:bookings:query") | 
|---|
|  |  |  | public ApiResponse<PageData<Bookings>> findPage (@RequestBody PageWrap<Bookings> pageWrap,@RequestHeader(Constants.HEADER_USER_TOKEN) String token){ | 
|---|
|  |  |  | return ApiResponse.success(bookingsService.findPage(pageWrap)); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @ApiOperation("导出Excel") | 
|---|
|  |  |  | @PostMapping("/exportExcel") | 
|---|
|  |  |  | @RequiresPermissions("business:bookings:exportExcel") | 
|---|
|  |  |  | @CloudRequiredPermission("business:bookings:exportExcel") | 
|---|
|  |  |  | public void exportExcel (@RequestBody PageWrap<Bookings> pageWrap, HttpServletResponse response,@RequestHeader(Constants.HEADER_USER_TOKEN) String token){ | 
|---|
|  |  |  | ExcelExporter.build(Bookings.class).export(bookingsService.findPage(pageWrap).getRecords(), "会议室预定信息表", response); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @ApiOperation("根据ID查询") | 
|---|
|  |  |  | @GetMapping("/{id}") | 
|---|
|  |  |  | @RequiresPermissions("business:bookings:query") | 
|---|
|  |  |  | @CloudRequiredPermission("business:bookings:query") | 
|---|
|  |  |  | public ApiResponse<MeetingDetailResponse> findById(@PathVariable Integer id,@RequestHeader(Constants.HEADER_USER_TOKEN) String token){ | 
|---|
|  |  |  | return ApiResponse.success(bookingsService.getMeetingDetail(id)); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @ApiOperation("取消") | 
|---|
|  |  |  | @PostMapping("/cancelById") | 
|---|
|  |  |  | @RequiresPermissions("business:bookings:update") | 
|---|
|  |  |  | @CloudRequiredPermission("business:bookings:update") | 
|---|
|  |  |  | public ApiResponse cancelById(@RequestBody Bookings bookings,@RequestHeader(Constants.HEADER_USER_TOKEN) String token){ | 
|---|
|  |  |  | bookings.setLoginUserInfo(this.getLoginUser(token)); | 
|---|
|  |  |  | bookingsService.cancelById(bookings); | 
|---|
|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @ApiOperation("会议室使用时长统计") | 
|---|
|  |  |  | @GetMapping("/getRoomStatistics") | 
|---|
|  |  |  | @RequiresPermissions("business:bookings:update") | 
|---|
|  |  |  | @CloudRequiredPermission("business:bookings:update") | 
|---|
|  |  |  | public ApiResponse<List<RoomStatisticsVo>> getRoomStatistics(@RequestParam Integer yearNum, @RequestParam Integer roomId){ | 
|---|
|  |  |  | return ApiResponse.success(bookingsService.getRoomStatistics(yearNum)); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @ApiOperation("人员参加会议时常") | 
|---|
|  |  |  | @PostMapping("/getUserStatistics") | 
|---|
|  |  |  | @RequiresPermissions("business:bookings:update") | 
|---|
|  |  |  | @CloudRequiredPermission("business:bookings:update") | 
|---|
|  |  |  | public ApiResponse<PageData<UserStatisticsVo>> getUserStatistics(@RequestBody PageWrap<UserStatisticsDTO> pageWrap ){ | 
|---|
|  |  |  | return ApiResponse.success(bookingsService.getUserStatistics(pageWrap)); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @ApiOperation("人员参会时长统计导出Excel") | 
|---|
|  |  |  | @PostMapping("/exportUserStatistics") | 
|---|
|  |  |  | @RequiresPermissions("business:bookings:exportExcel") | 
|---|
|  |  |  | @CloudRequiredPermission("business:bookings:exportExcel") | 
|---|
|  |  |  | public void exportUserStatistics (@RequestBody PageWrap<UserStatisticsDTO> pageWrap,HttpServletResponse response,@RequestHeader(Constants.HEADER_USER_TOKEN) String token){ | 
|---|
|  |  |  |  | 
|---|
|  |  |  | List<UserStatisticsVo> records = bookingsService.getUserStatistics(pageWrap).getRecords(); | 
|---|
|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @ApiOperation("会议室使用时长统计导出Excel") | 
|---|
|  |  |  | @PostMapping("/exportRoomStatistics") | 
|---|
|  |  |  | @RequiresPermissions("business:bookings:exportExcel") | 
|---|
|  |  |  | @CloudRequiredPermission("business:bookings:exportExcel") | 
|---|
|  |  |  | public void exportRoomStatistics (@RequestBody PageWrap<UserStatisticsDTO> pageWrap,HttpServletResponse response,@RequestHeader(Constants.HEADER_USER_TOKEN) String token){ | 
|---|
|  |  |  | List<RoomStatisticsVo> roomStatistics = bookingsService.getRoomStatistics(pageWrap.getModel().getYearNum()); | 
|---|
|  |  |  | if (!CollectionUtils.isEmpty(roomStatistics)){ | 
|---|