¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.doumee.cloud.admin; |
| | | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.alibaba.fastjson.JSONArray; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.doumee.api.BaseController; |
| | | import com.doumee.core.annotation.excel.ExcelExporter; |
| | | import com.doumee.core.annotation.pr.PreventRepeat; |
| | | import com.doumee.core.model.ApiResponse; |
| | | import com.doumee.core.model.LoginUserInfo; |
| | | import com.doumee.core.model.PageData; |
| | | import com.doumee.core.model.PageWrap; |
| | | import com.doumee.core.utils.Constants; |
| | | import com.doumee.core.utils.DateUtil; |
| | | import com.doumee.dao.business.model.Bookings; |
| | | import com.doumee.dao.business.vo.RoomStatisticsVo; |
| | | import com.doumee.dao.system.dto.UserStatisticsDTO; |
| | | import com.doumee.dao.system.vo.UserStatisticsVo; |
| | | import com.doumee.dao.web.response.DateTimeResourceDate; |
| | | import com.doumee.dao.web.response.MeetingDetailResponse; |
| | | import com.doumee.service.business.BookingsService; |
| | | import io.swagger.annotations.Api; |
| | | 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.*; |
| | | |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.math.BigDecimal; |
| | | import java.math.RoundingMode; |
| | | import java.time.LocalDate; |
| | | import java.time.LocalDateTime; |
| | | import java.time.LocalTime; |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.Set; |
| | | |
| | | /** |
| | | * @author æ±è¹è¹ |
| | | * @date 2023/05/04 18:18 |
| | | */ |
| | | @Api(tags = "ä¼è®®å®¤é¢å®ä¿¡æ¯è¡¨") |
| | | @RestController |
| | | @RequestMapping(Constants.CLOUD_SERVICE_URL_INDEX+"/business/bookings") |
| | | public class BookingsController extends BaseController { |
| | | |
| | | @Autowired |
| | | private BookingsService bookingsService; |
| | | |
| | | @PreventRepeat |
| | | @ApiOperation("æ°å»º") |
| | | @PostMapping("/create") |
| | | @RequiresPermissions("business:bookings:create") |
| | | public ApiResponse create(@RequestBody Bookings bookings,@RequestHeader(Constants.HEADER_USER_TOKEN) String token) { |
| | | LoginUserInfo user = getLoginUser(token); |
| | | bookings.setCreator(user.getId()); |
| | | return ApiResponse.success(bookingsService.create(bookings)); |
| | | } |
| | | |
| | | @ApiOperation("æ ¹æ®IDå é¤") |
| | | @GetMapping("/delete/{id}") |
| | | @RequiresPermissions("business:bookings:delete") |
| | | public ApiResponse deleteById(@PathVariable Integer id,@RequestHeader(Constants.HEADER_USER_TOKEN) String token) { |
| | | bookingsService.deleteById(id); |
| | | return ApiResponse.success(null); |
| | | } |
| | | |
| | | @ApiOperation("æ¹éå é¤") |
| | | @GetMapping("/delete/batch") |
| | | @RequiresPermissions("business:bookings:delete") |
| | | public ApiResponse deleteByIdInBatch(@RequestParam String ids) { |
| | | String [] idArray = ids.split(","); |
| | | List<Integer> idList = new ArrayList<>(); |
| | | for (String id : idArray) { |
| | | idList.add(Integer.valueOf(id)); |
| | | } |
| | | bookingsService.deleteByIdInBatch(idList); |
| | | return ApiResponse.success(null); |
| | | } |
| | | |
| | | @ApiOperation("æ ¹æ®IDä¿®æ¹") |
| | | @PostMapping("/updateById") |
| | | @RequiresPermissions("business:bookings:update") |
| | | public ApiResponse updateById(@RequestBody Bookings bookings,@RequestHeader(Constants.HEADER_USER_TOKEN) String token) { |
| | | LoginUserInfo user = getLoginUser(token); |
| | | bookings.setCreator(user.getId()); |
| | | bookingsService.updateById(bookings); |
| | | return ApiResponse.success(null); |
| | | } |
| | | |
| | | @ApiOperation("å页æ¥è¯¢") |
| | | @PostMapping("/page") |
| | | @RequiresPermissions("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") |
| | | public void exportExcel (@RequestBody PageWrap<Bookings> pageWrap, HttpServletResponse response) { |
| | | ExcelExporter.build(Bookings.class).export(bookingsService.findPage(pageWrap).getRecords(), "ä¼è®®å®¤é¢å®ä¿¡æ¯è¡¨", response); |
| | | } |
| | | |
| | | @ApiOperation("æ ¹æ®IDæ¥è¯¢") |
| | | @GetMapping("/{id}") |
| | | @RequiresPermissions("business:bookings:query") |
| | | public ApiResponse<MeetingDetailResponse> findById(@PathVariable Integer id) { |
| | | return ApiResponse.success(bookingsService.getMeetingDetail(id)); |
| | | } |
| | | |
| | | |
| | | @ApiOperation("åæ¶") |
| | | @PostMapping("/cancelById") |
| | | @RequiresPermissions("business:bookings:update") |
| | | public ApiResponse cancelById(@RequestBody Bookings bookings) { |
| | | bookingsService.cancelById(bookings); |
| | | return ApiResponse.success(null); |
| | | } |
| | | |
| | | @ApiOperation("ä¼è®®å®¤ä½¿ç¨æ¶é¿ç»è®¡") |
| | | @GetMapping("/getRoomStatistics") |
| | | @RequiresPermissions("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") |
| | | public ApiResponse<PageData<UserStatisticsVo>> getUserStatistics(@RequestBody PageWrap<UserStatisticsDTO> pageWrap ){ |
| | | return ApiResponse.success(bookingsService.getUserStatistics(pageWrap)); |
| | | } |
| | | |
| | | @ApiOperation("人åå伿¶é¿ç»è®¡å¯¼åºExcel") |
| | | @PostMapping("/exportUserStatistics") |
| | | @RequiresPermissions("business:bookings:exportExcel") |
| | | public void exportUserStatistics (@RequestBody PageWrap<UserStatisticsDTO> pageWrap,HttpServletResponse response) { |
| | | |
| | | List<UserStatisticsVo> records = bookingsService.getUserStatistics(pageWrap).getRecords(); |
| | | if (!CollectionUtils.isEmpty(records)){ |
| | | JSONArray o = (JSONArray) JSON.toJSON(records); |
| | | o.forEach(s->{ |
| | | JSONObject jsonObject = (JSONObject) s; |
| | | Set<Map.Entry<String, Object>> entries = jsonObject.entrySet(); |
| | | for (Map.Entry<String, Object> entry:entries){ |
| | | |
| | | if (entry.getValue() instanceof BigDecimal){ |
| | | BigDecimal value = (BigDecimal) entry.getValue(); |
| | | entry.setValue(value.compareTo(value.setScale(0, RoundingMode.DOWN)) > 0 ? value : value.setScale(0, RoundingMode.DOWN)); |
| | | } |
| | | } |
| | | }); |
| | | records = o.toJavaList(UserStatisticsVo.class); |
| | | } |
| | | ExcelExporter.build(UserStatisticsVo.class).export(records, "人åå伿¶é¿ç»è®¡", response); |
| | | } |
| | | |
| | | @ApiOperation("ä¼è®®å®¤ä½¿ç¨æ¶é¿ç»è®¡å¯¼åºExcel") |
| | | @PostMapping("/exportRoomStatistics") |
| | | @RequiresPermissions("business:bookings:exportExcel") |
| | | public void exportRoomStatistics (@RequestBody PageWrap<UserStatisticsDTO> pageWrap,HttpServletResponse response) { |
| | | List<RoomStatisticsVo> roomStatistics = bookingsService.getRoomStatistics(pageWrap.getModel().getYearNum()); |
| | | if (!CollectionUtils.isEmpty(roomStatistics)){ |
| | | JSONArray o = (JSONArray) JSON.toJSON(roomStatistics); |
| | | o.forEach(s->{ |
| | | JSONObject jsonObject = (JSONObject) s; |
| | | Set<Map.Entry<String, Object>> entries = jsonObject.entrySet(); |
| | | for (Map.Entry<String, Object> entry:entries){ |
| | | |
| | | if (entry.getValue() instanceof BigDecimal){ |
| | | BigDecimal value = (BigDecimal) entry.getValue(); |
| | | entry.setValue(value.compareTo(value.setScale(0, RoundingMode.DOWN)) > 0 ? value : value.setScale(0, RoundingMode.DOWN)); |
| | | } |
| | | } |
| | | }); |
| | | roomStatistics = o.toJavaList(RoomStatisticsVo.class); |
| | | } |
| | | ExcelExporter.build(RoomStatisticsVo.class).export(roomStatistics, "ä¼è®®å®¤ä½¿ç¨æ¶é¿ç»è®¡", response); |
| | | } |
| | | |
| | | @ApiOperation("åä¸çé¢çº¦ä¼è®®") |
| | | @GetMapping("/reservationCancel") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(paramType = "query", dataType = "Integer", name = "type", value = "1 ä»å¤© 2 æ¬å¨", required = true), |
| | | }) |
| | | public ApiResponse<List<Bookings>> getMyJoinBookingMeet(@RequestParam Integer type,@RequestHeader(Constants.HEADER_USER_TOKEN) String token){ |
| | | |
| | | LocalDateTime startTime = LocalDateTime.of(LocalDate.now(), LocalTime.of(00,00,00)); |
| | | LocalDateTime endTime = LocalDateTime.of(LocalDate.now(), LocalTime.of(23,59,59)); |
| | | if(Constants.equalsInteger(type,Constants.TWO)){ |
| | | startTime = DateUtil.getMonday(); |
| | | endTime = DateUtil.getSunday(); |
| | | } |
| | | return ApiResponse.success(bookingsService.getMyJoinBookingMeet(getLoginUser(token).getId(), null,startTime,endTime)); |
| | | } |
| | | |
| | | /** |
| | | * è·åç¨æ·å½å½æé¢çº¦ä¼è®®æ
åµ |
| | | * @return |
| | | */ |
| | | @ApiOperation("è·åç¨æ·å½å½æé¢çº¦ä¼è®®æ
åµ") |
| | | @PostMapping("/findMothBookingMeet") |
| | | public ApiResponse<List<DateTimeResourceDate>> findMothBookingMeet( @RequestParam(required = false) Integer roomId,String dateMonth,@RequestHeader(Constants.HEADER_USER_TOKEN) String token){ |
| | | return ApiResponse.success(bookingsService.findMothBookingMeet(getLoginUser(token).getId(),roomId,dateMonth)); |
| | | } |
| | | } |