weicd
2023-02-09 fa2e08783c7f94e420376b3d9f5f54cf0fdf1d4f
会议室预约
10 files added
870 ■■■■■ changed files
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/conferenceRoom/domain/MeetingRoomReservation.java 77 ●●●●● patch | view | raw | blame | history
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/conferenceRoom/repository/MeetingRoomReservationRepository.java 43 ●●●●● patch | view | raw | blame | history
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/conferenceRoom/rest/MeetingRoomReservationController.java 95 ●●●●● patch | view | raw | blame | history
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/conferenceRoom/service/MeetingRoomReservationService.java 83 ●●●●● patch | view | raw | blame | history
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/conferenceRoom/service/dto/MeetingRoomReservationDto.java 55 ●●●●● patch | view | raw | blame | history
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/conferenceRoom/service/dto/MeetingRoomReservationQueryCriteria.java 43 ●●●●● patch | view | raw | blame | history
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/conferenceRoom/service/impl/MeetingRoomReservationServiceImpl.java 204 ●●●●● patch | view | raw | blame | history
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/conferenceRoom/service/mapstruct/MeetingRoomReservationMapper.java 32 ●●●●● patch | view | raw | blame | history
eladmin-web-master/src/api/conferenceRoom/meetingRoomReservation.js 35 ●●●●● patch | view | raw | blame | history
eladmin-web-master/src/views/conferenceRoom/meetingRoomReservation/index.vue 203 ●●●●● patch | view | raw | blame | history
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/conferenceRoom/domain/MeetingRoomReservation.java
New file
@@ -0,0 +1,77 @@
/*
*  Copyright 2019-2020 Zheng Jie
*
*  Licensed under the Apache License, Version 2.0 (the "License");
*  you may not use this file except in compliance with the License.
*  You may obtain a copy of the License at
*
*  http://www.apache.org/licenses/LICENSE-2.0
*
*  Unless required by applicable law or agreed to in writing, software
*  distributed under the License is distributed on an "AS IS" BASIS,
*  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*  See the License for the specific language governing permissions and
*  limitations under the License.
*/
package me.zhengjie.modules.conferenceRoom.domain;
import lombok.Data;
import cn.hutool.core.bean.BeanUtil;
import io.swagger.annotations.ApiModelProperty;
import cn.hutool.core.bean.copier.CopyOptions;
import me.zhengjie.base.BaseEntity;
import javax.persistence.*;
import javax.validation.constraints.*;
import java.sql.Timestamp;
import java.io.Serializable;
/**
* @website https://eladmin.vip
* @description /
* @author wcd
* @date 2023-02-09
**/
@Entity
@Data
@Table(name="meeting_room_reservation")
public class MeetingRoomReservation extends BaseEntity implements Serializable {
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "`id`")
    @ApiModelProperty(value = "id")
    private Long id;
    @Column(name = "`meeting_id`",nullable = false)
    @NotNull
    @ApiModelProperty(value = "会议室id")
    private Long meetingId;
    @Column(name = "`meeting_theme`",nullable = false)
    @NotBlank
    @ApiModelProperty(value = "会议主题")
    private String meetingTheme;
    @Column(name = "`start_time`",nullable = false)
    @NotNull
    @ApiModelProperty(value = "开始时间")
    private Timestamp startTime;
    @Column(name = "`end_time`",nullable = false)
    @NotNull
    @ApiModelProperty(value = "结束时间")
    private Timestamp endTime;
    @Column(name = "`number_of_participants`")
    @ApiModelProperty(value = "参与人数")
    private Long numberOfParticipants;
    @Column(name = "`remarks`")
    @ApiModelProperty(value = "备注")
    private String remarks;
    public void copy(MeetingRoomReservation source){
        BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true));
    }
}
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/conferenceRoom/repository/MeetingRoomReservationRepository.java
New file
@@ -0,0 +1,43 @@
/*
*  Copyright 2019-2020 Zheng Jie
*
*  Licensed under the Apache License, Version 2.0 (the "License");
*  you may not use this file except in compliance with the License.
*  You may obtain a copy of the License at
*
*  http://www.apache.org/licenses/LICENSE-2.0
*
*  Unless required by applicable law or agreed to in writing, software
*  distributed under the License is distributed on an "AS IS" BASIS,
*  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*  See the License for the specific language governing permissions and
*  limitations under the License.
*/
package me.zhengjie.modules.conferenceRoom.repository;
import me.zhengjie.modules.attendance.domain.AttendanceLeave;
import me.zhengjie.modules.conferenceRoom.domain.MeetingRoomReservation;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import java.util.List;
import java.util.Set;
/**
* @website https://eladmin.vip
* @author wcd
* @date 2023-02-09
**/
public interface MeetingRoomReservationRepository extends JpaRepository<MeetingRoomReservation, Long>, JpaSpecificationExecutor<MeetingRoomReservation> {
    // 会议室预约的时候验证时间是否存在(新增)
    @Query(value = "SELECT * FROM meeting_room_reservation WHERE meeting_id = ?3 AND ((start_time >= ?1 and start_time <= ?2) OR \n" +
            "(start_time <= ?1 and end_time >= ?2) OR (end_time >= ?1 and end_time <= ?2) OR (start_time >= ?1 and end_time <= ?2))", nativeQuery = true)
    List<MeetingRoomReservation> checkReservationTime(String startTime, String endTime, Long userId);
    // 会议室修改预约的时候验证时间是否存在(编辑)
    @Query(value = "SELECT * FROM meeting_room_reservation WHERE meeting_id = ?3 AND id NOT IN ?4 AND ((start_time >= ?1 and start_time <= ?2) OR \n" +
            "(start_time <= ?1 and end_time >= ?2) OR (end_time >= ?1 and end_time <= ?2) OR (start_time >= ?1 and end_time <= ?2))", nativeQuery = true)
    List<MeetingRoomReservation> checkReservationTimeEdit(String startTime, String endTime, Long userId, Set<Long> ids);
}
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/conferenceRoom/rest/MeetingRoomReservationController.java
New file
@@ -0,0 +1,95 @@
/*
*  Copyright 2019-2020 Zheng Jie
*
*  Licensed under the Apache License, Version 2.0 (the "License");
*  you may not use this file except in compliance with the License.
*  You may obtain a copy of the License at
*
*  http://www.apache.org/licenses/LICENSE-2.0
*
*  Unless required by applicable law or agreed to in writing, software
*  distributed under the License is distributed on an "AS IS" BASIS,
*  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*  See the License for the specific language governing permissions and
*  limitations under the License.
*/
package me.zhengjie.modules.conferenceRoom.rest;
import me.zhengjie.annotation.Log;
import me.zhengjie.modules.conferenceRoom.domain.MeetingRoomReservation;
import me.zhengjie.modules.conferenceRoom.service.MeetingRoomReservationService;
import me.zhengjie.modules.conferenceRoom.service.dto.MeetingRoomReservationQueryCriteria;
import org.springframework.data.domain.Pageable;
import lombok.RequiredArgsConstructor;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import io.swagger.annotations.*;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
/**
* @website https://eladmin.vip
* @author wcd
* @date 2023-02-09
**/
@RestController
@RequiredArgsConstructor
@Api(tags = "会议室预约管理")
@RequestMapping("/api/meetingRoomReservation")
public class MeetingRoomReservationController {
    private final MeetingRoomReservationService meetingRoomReservationService;
    @Log("导出数据")
    @ApiOperation("导出数据")
    @GetMapping(value = "/download")
    @PreAuthorize("@el.check('meetingRoomReservation:download')")
    public void exportMeetingRoomReservation(HttpServletResponse response, MeetingRoomReservationQueryCriteria criteria) throws IOException {
        meetingRoomReservationService.download(meetingRoomReservationService.queryAll(criteria), response);
    }
    @GetMapping
    @Log("查询会议室预约")
    @ApiOperation("查询会议室预约")
    @PreAuthorize("@el.check('meetingRoomReservation:list')")
    public ResponseEntity<Object> queryMeetingRoomReservation(MeetingRoomReservationQueryCriteria criteria, Pageable pageable){
        return new ResponseEntity<>(meetingRoomReservationService.queryAll(criteria,pageable),HttpStatus.OK);
    }
    @GetMapping(value = "/all")
    @Log("查询会议室预约")
    @ApiOperation("查询会议室预约")
    @PreAuthorize("@el.check('meetingRoomReservation:list')")
    public ResponseEntity<Object> queryMeetingRoomReservation(MeetingRoomReservationQueryCriteria criteria){
        return new ResponseEntity<>(meetingRoomReservationService.queryAll(criteria),HttpStatus.OK);
    }
    @PostMapping
    @Log("新增会议室预约")
    @ApiOperation("新增会议室预约")
    @PreAuthorize("@el.check('meetingRoomReservation:add')")
    public ResponseEntity<Object> createMeetingRoomReservation(@Validated @RequestBody MeetingRoomReservation resources) throws Exception {
        return new ResponseEntity<>(meetingRoomReservationService.create(resources),HttpStatus.CREATED);
    }
    @PutMapping
    @Log("修改会议室预约")
    @ApiOperation("修改会议室预约")
    @PreAuthorize("@el.check('meetingRoomReservation:edit')")
    public ResponseEntity<Object> updateMeetingRoomReservation(@Validated @RequestBody MeetingRoomReservation resources) throws Exception {
        meetingRoomReservationService.update(resources);
        return new ResponseEntity<>(HttpStatus.NO_CONTENT);
    }
    @DeleteMapping
    @Log("删除会议室预约")
    @ApiOperation("删除会议室预约")
    @PreAuthorize("@el.check('meetingRoomReservation:del')")
    public ResponseEntity<Object> deleteMeetingRoomReservation(@RequestBody Long[] ids) {
        meetingRoomReservationService.deleteAll(ids);
        return new ResponseEntity<>(HttpStatus.OK);
    }
}
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/conferenceRoom/service/MeetingRoomReservationService.java
New file
@@ -0,0 +1,83 @@
/*
*  Copyright 2019-2020 Zheng Jie
*
*  Licensed under the Apache License, Version 2.0 (the "License");
*  you may not use this file except in compliance with the License.
*  You may obtain a copy of the License at
*
*  http://www.apache.org/licenses/LICENSE-2.0
*
*  Unless required by applicable law or agreed to in writing, software
*  distributed under the License is distributed on an "AS IS" BASIS,
*  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*  See the License for the specific language governing permissions and
*  limitations under the License.
*/
package me.zhengjie.modules.conferenceRoom.service;
import me.zhengjie.modules.conferenceRoom.domain.MeetingRoomReservation;
import me.zhengjie.modules.conferenceRoom.service.dto.MeetingRoomReservationDto;
import me.zhengjie.modules.conferenceRoom.service.dto.MeetingRoomReservationQueryCriteria;
import org.springframework.data.domain.Pageable;
import java.util.Map;
import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
/**
* @website https://eladmin.vip
* @description 服务接口
* @author wcd
* @date 2023-02-09
**/
public interface MeetingRoomReservationService {
    /**
    * 查询数据分页
    * @param criteria 条件
    * @param pageable 分页参数
    * @return Map<String,Object>
    */
    Map<String,Object> queryAll(MeetingRoomReservationQueryCriteria criteria, Pageable pageable);
    /**
    * 查询所有数据不分页
    * @param criteria 条件参数
    * @return List<MeetingRoomReservationDto>
    */
    List<MeetingRoomReservationDto> queryAll(MeetingRoomReservationQueryCriteria criteria);
    /**
     * 根据ID查询
     * @param id ID
     * @return MeetingRoomReservationDto
     */
    MeetingRoomReservationDto findById(Long id);
    /**
    * 创建
    * @param resources /
    * @return MeetingRoomReservationDto
    */
    MeetingRoomReservationDto create(MeetingRoomReservation resources) throws Exception;
    /**
    * 编辑
    * @param resources /
    */
    void update(MeetingRoomReservation resources) throws Exception;
    /**
    * 多选删除
    * @param ids /
    */
    void deleteAll(Long[] ids);
    /**
    * 导出数据
    * @param all 待导出的数据
    * @param response /
    * @throws IOException /
    */
    void download(List<MeetingRoomReservationDto> all, HttpServletResponse response) throws IOException;
}
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/conferenceRoom/service/dto/MeetingRoomReservationDto.java
New file
@@ -0,0 +1,55 @@
/*
*  Copyright 2019-2020 Zheng Jie
*
*  Licensed under the Apache License, Version 2.0 (the "License");
*  you may not use this file except in compliance with the License.
*  You may obtain a copy of the License at
*
*  http://www.apache.org/licenses/LICENSE-2.0
*
*  Unless required by applicable law or agreed to in writing, software
*  distributed under the License is distributed on an "AS IS" BASIS,
*  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*  See the License for the specific language governing permissions and
*  limitations under the License.
*/
package me.zhengjie.modules.conferenceRoom.service.dto;
import lombok.Data;
import me.zhengjie.base.BaseDTO;
import java.sql.Timestamp;
import java.io.Serializable;
/**
* @website https://eladmin.vip
* @description /
* @author wcd
* @date 2023-02-09
**/
@Data
public class MeetingRoomReservationDto extends BaseDTO implements Serializable {
    private Long id;
    /** 会议室id */
    private Long meetingId;
    /** 会议主题 */
    private String meetingTheme;
    /** 开始时间 */
    private Timestamp startTime;
    /** 结束时间 */
    private Timestamp endTime;
    /** 参与人数 */
    private Long numberOfParticipants;
    /** 备注 */
    private String remarks;
    /** 会议室名称 */
    private String meetingName;
}
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/conferenceRoom/service/dto/MeetingRoomReservationQueryCriteria.java
New file
@@ -0,0 +1,43 @@
/*
*  Copyright 2019-2020 Zheng Jie
*
*  Licensed under the Apache License, Version 2.0 (the "License");
*  you may not use this file except in compliance with the License.
*  You may obtain a copy of the License at
*
*  http://www.apache.org/licenses/LICENSE-2.0
*
*  Unless required by applicable law or agreed to in writing, software
*  distributed under the License is distributed on an "AS IS" BASIS,
*  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*  See the License for the specific language governing permissions and
*  limitations under the License.
*/
package me.zhengjie.modules.conferenceRoom.service.dto;
import lombok.Data;
import java.sql.Timestamp;
import java.util.List;
import me.zhengjie.annotation.Query;
/**
* @website https://eladmin.vip
* @author wcd
* @date 2023-02-09
**/
@Data
public class MeetingRoomReservationQueryCriteria{
    @Query
    private Long meetingId;
    @Query(type = Query.Type.INNER_LIKE, propName = "meetingTheme")
    private String meetingTheme;
    @Query(type = Query.Type.BETWEEN, propName = "startTime")
    private List<Timestamp> startTime;
    @Query(type = Query.Type.BETWEEN, propName = "endTime")
    private List<Timestamp> endTime;
}
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/conferenceRoom/service/impl/MeetingRoomReservationServiceImpl.java
New file
@@ -0,0 +1,204 @@
/*
*  Copyright 2019-2020 Zheng Jie
*
*  Licensed under the Apache License, Version 2.0 (the "License");
*  you may not use this file except in compliance with the License.
*  You may obtain a copy of the License at
*
*  http://www.apache.org/licenses/LICENSE-2.0
*
*  Unless required by applicable law or agreed to in writing, software
*  distributed under the License is distributed on an "AS IS" BASIS,
*  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*  See the License for the specific language governing permissions and
*  limitations under the License.
*/
package me.zhengjie.modules.conferenceRoom.service.impl;
import me.zhengjie.exception.BadRequestException;
import me.zhengjie.modules.assetManagement.domain.AssetManagement;
import me.zhengjie.modules.assetManagement.domain.AssetUseManagement;
import me.zhengjie.modules.attendance.domain.AttendanceGoOut;
import me.zhengjie.modules.conferenceRoom.domain.MeetingRoom;
import me.zhengjie.modules.conferenceRoom.domain.MeetingRoomReservation;
import me.zhengjie.modules.conferenceRoom.repository.MeetingRoomRepository;
import me.zhengjie.modules.conferenceRoom.service.dto.MeetingRoomDto;
import me.zhengjie.modules.constant.Constant;
import me.zhengjie.modules.quartz.service.OpaiDingTalkService;
import me.zhengjie.modules.system.domain.CustomerResources;
import me.zhengjie.modules.system.domain.Role;
import me.zhengjie.modules.system.domain.User;
import me.zhengjie.modules.system.repository.UserRepository;
import me.zhengjie.utils.ValidationUtil;
import me.zhengjie.utils.FileUtil;
import lombok.RequiredArgsConstructor;
import me.zhengjie.modules.conferenceRoom.repository.MeetingRoomReservationRepository;
import me.zhengjie.modules.conferenceRoom.service.MeetingRoomReservationService;
import me.zhengjie.modules.conferenceRoom.service.dto.MeetingRoomReservationDto;
import me.zhengjie.modules.conferenceRoom.service.dto.MeetingRoomReservationQueryCriteria;
import me.zhengjie.modules.conferenceRoom.service.mapstruct.MeetingRoomReservationMapper;
import org.apache.commons.lang3.ObjectUtils;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import me.zhengjie.utils.PageUtil;
import me.zhengjie.utils.QueryHelp;
import java.text.SimpleDateFormat;
import java.util.*;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import java.util.function.Function;
/**
* @website https://eladmin.vip
* @description 服务实现
* @author wcd
* @date 2023-02-09
**/
@Service
@RequiredArgsConstructor
public class MeetingRoomReservationServiceImpl implements MeetingRoomReservationService {
    private final MeetingRoomReservationRepository meetingRoomReservationRepository;
    private final MeetingRoomReservationMapper meetingRoomReservationMapper;
    private final MeetingRoomRepository meetingRoomRepository;
    private final OpaiDingTalkService opaiDingTalkService;
    private final UserRepository userRepository;
    @Override
    public Map<String,Object> queryAll(MeetingRoomReservationQueryCriteria criteria, Pageable pageable){
        Page<MeetingRoomReservation> page = meetingRoomReservationRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder),pageable);
        //将实体转换为Dto(重写)
        Function<MeetingRoomReservation, MeetingRoomReservationDto> func = new Function<MeetingRoomReservation, MeetingRoomReservationDto>(){
            @Override
            public MeetingRoomReservationDto apply(MeetingRoomReservation meetingRoomReservation) {
                // 将实体类转换成DTO
                MeetingRoomReservationDto meetingRoomReservationDto = meetingRoomReservationMapper.toDto(meetingRoomReservation);
                // 查询会议室
                MeetingRoom meetingRoom = meetingRoomRepository.findById(meetingRoomReservationDto.getMeetingId()).orElseGet(MeetingRoom::new);
                meetingRoomReservationDto.setMeetingName(meetingRoom.getConferenceRoomName());
                return meetingRoomReservationDto;
            }
        };
        return PageUtil.toPage(page.map(func));
    }
    @Override
    public List<MeetingRoomReservationDto> queryAll(MeetingRoomReservationQueryCriteria criteria){
        return meetingRoomReservationMapper.toDto(meetingRoomReservationRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder)));
    }
    @Override
    @Transactional
    public MeetingRoomReservationDto findById(Long id) {
        MeetingRoomReservation meetingRoomReservation = meetingRoomReservationRepository.findById(id).orElseGet(MeetingRoomReservation::new);
        ValidationUtil.isNull(meetingRoomReservation.getId(),"MeetingRoomReservation","id",id);
        return meetingRoomReservationMapper.toDto(meetingRoomReservation);
    }
    @Override
    @Transactional(rollbackFor = Exception.class)
    public MeetingRoomReservationDto create(MeetingRoomReservation resources) throws Exception {
        SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        String startTime = df.format(resources.getStartTime());
        String endTime = df.format(resources.getEndTime());
        //验证约时间是否冲突
        List<MeetingRoomReservation> meetingRoomReservations = meetingRoomReservationRepository.checkReservationTime(startTime,endTime,resources.getMeetingId());
        if(meetingRoomReservations.size() > 0){
            MeetingRoomReservation errorMeetingRoomReservation = meetingRoomReservations.get(0);
            SimpleDateFormat errorFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
            throw new BadRequestException("预约时间冲突," + errorFormat.format(errorMeetingRoomReservation.getStartTime()) + "至" + errorFormat.format(errorMeetingRoomReservation.getEndTime())
                    + "已经存在会议室预约,请调整时间");
        }else{
            //调用钉钉公共方法
            setDingding(resources);
        }
        return meetingRoomReservationMapper.toDto(meetingRoomReservationRepository.save(resources));
    }
    @Override
    @Transactional(rollbackFor = Exception.class)
    public void update(MeetingRoomReservation resources) throws Exception {
        MeetingRoomReservation meetingRoomReservation = meetingRoomReservationRepository.findById(resources.getId()).orElseGet(MeetingRoomReservation::new);
        ValidationUtil.isNull( meetingRoomReservation.getId(),"MeetingRoomReservation","id",resources.getId());
        meetingRoomReservation.copy(resources);
        SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        String startTime = df.format(resources.getStartTime());
        String endTime = df.format(resources.getEndTime());
        // 会议室预约id
        Set<Long> ids = new HashSet<>();
        ids.add(meetingRoomReservation.getId());
        //验证时间是否冲突
        List<MeetingRoomReservation> meetingRoomReservations = meetingRoomReservationRepository.checkReservationTimeEdit(startTime,endTime, resources.getMeetingId(), ids);
        if(meetingRoomReservations.size() > 0){
            MeetingRoomReservation errorMeetingRoomReservation = meetingRoomReservations.get(0);
            SimpleDateFormat errorFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
            throw new BadRequestException("预约时间冲突," + errorFormat.format(errorMeetingRoomReservation.getStartTime()) + "至" + errorFormat.format(errorMeetingRoomReservation.getEndTime())
                    + "已经存在会议室预约,请调整时间");
        }else{
            setDingding(resources);
        }
        meetingRoomReservationRepository.save(meetingRoomReservation);
    }
    /**
     * 发送钉钉公共方法
     * @param resources
     * @return
     * @throws Exception
     */
    public void setDingding(MeetingRoomReservation resources) throws Exception {
        // 获取存储用户钉钉号
        List<String> dingDingList = new ArrayList<>();
        // 查询用户
        List<User> userList = userRepository.findAll();
        for(User user : userList){
            Role role = user.getRoles().iterator().next();
            // 获取项目组长级以上的用户的钉钉id
            if(Long.valueOf(role.getLevel()) <= Constant.ROLE_LEVEL_LEADER){
                if(ObjectUtils.isNotEmpty(user.getDingding())){
                    dingDingList.add(user.getDingding());
                }
            }
        }
        // 查询会议室
        MeetingRoom meetingRoom = meetingRoomRepository.findById(resources.getMeetingId()).orElseGet(MeetingRoom::new);
        // 发送内容至钉钉
        opaiDingTalkService.sendNotice(dingDingList, "会议室预约提示", "### 会议室预约提示  \n  >" +
                "  \n  会议室:"   + meetingRoom.getConferenceRoomName() +
                "  \n  开始时间: " + resources.getStartTime().toString().substring(0,19) +
                "  \n  结束时间: " + resources.getEndTime().toString().substring(0,19) +
                "  \n  会议室预约有变更,请登录PMS系统查看。", "card");
    }
    @Override
    public void deleteAll(Long[] ids) {
        for (Long id : ids) {
            meetingRoomReservationRepository.deleteById(id);
        }
    }
    @Override
    public void download(List<MeetingRoomReservationDto> all, HttpServletResponse response) throws IOException {
        List<Map<String, Object>> list = new ArrayList<>();
        for (MeetingRoomReservationDto meetingRoomReservation : all) {
            // 查询会议室
            MeetingRoom meetingRoom = meetingRoomRepository.findById(meetingRoomReservation.getMeetingId()).orElseGet(MeetingRoom::new);
            Map<String,Object> map = new LinkedHashMap<>();
            map.put("会议室", meetingRoom.getConferenceRoomName());
            map.put("会议主题", meetingRoomReservation.getMeetingTheme());
            map.put("开始时间", meetingRoomReservation.getStartTime());
            map.put("结束时间", meetingRoomReservation.getEndTime());
            map.put("参与人数", meetingRoomReservation.getNumberOfParticipants());
            map.put("备注", meetingRoomReservation.getRemarks());
            map.put("创建者", meetingRoomReservation.getCreateBy());
            map.put("创建时间", meetingRoomReservation.getCreateTime());
            map.put("更新者", meetingRoomReservation.getUpdateBy());
            map.put("更新时间", meetingRoomReservation.getUpdateTime());
            list.add(map);
        }
        FileUtil.downloadExcel(list, response);
    }
}
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/conferenceRoom/service/mapstruct/MeetingRoomReservationMapper.java
New file
@@ -0,0 +1,32 @@
/*
*  Copyright 2019-2020 Zheng Jie
*
*  Licensed under the Apache License, Version 2.0 (the "License");
*  you may not use this file except in compliance with the License.
*  You may obtain a copy of the License at
*
*  http://www.apache.org/licenses/LICENSE-2.0
*
*  Unless required by applicable law or agreed to in writing, software
*  distributed under the License is distributed on an "AS IS" BASIS,
*  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*  See the License for the specific language governing permissions and
*  limitations under the License.
*/
package me.zhengjie.modules.conferenceRoom.service.mapstruct;
import me.zhengjie.base.BaseMapper;
import me.zhengjie.modules.conferenceRoom.domain.MeetingRoomReservation;
import me.zhengjie.modules.conferenceRoom.service.dto.MeetingRoomReservationDto;
import org.mapstruct.Mapper;
import org.mapstruct.ReportingPolicy;
/**
* @website https://eladmin.vip
* @author wcd
* @date 2023-02-09
**/
@Mapper(componentModel = "spring", unmappedTargetPolicy = ReportingPolicy.IGNORE)
public interface MeetingRoomReservationMapper extends BaseMapper<MeetingRoomReservationDto, MeetingRoomReservation> {
}
eladmin-web-master/src/api/conferenceRoom/meetingRoomReservation.js
New file
@@ -0,0 +1,35 @@
import request from '@/utils/request'
export function getAll(params) {
  return request({
    url: 'api/meetingRoomReservation/all',
    method: 'get',
    params
  })
}
export function add(data) {
  return request({
    url: 'api/meetingRoomReservation',
    method: 'post',
    data
  })
}
export function del(ids) {
  return request({
    url: 'api/meetingRoomReservation/',
    method: 'delete',
    data: ids
  })
}
export function edit(data) {
  return request({
    url: 'api/meetingRoomReservation',
    method: 'put',
    data
  })
}
export default { add, edit, del, getAll }
eladmin-web-master/src/views/conferenceRoom/meetingRoomReservation/index.vue
New file
@@ -0,0 +1,203 @@
<template>
  <div class="app-container">
    <!--工具栏-->
    <div class="head-container">
      <div>
        <el-select v-model="query.meetingId" filterable clearable placeholder="所属会议室" style="width: 185px;" class="filter-item" @keyup.enter.native="crud.toQuery">
          <el-option
            v-for="item in meetings"
            :key="item.id"
            :label="item.conferenceRoomName"
            :value="item.id"
          />
        </el-select>
        <el-input
          v-model="query.meetingTheme"
          clearable
          size="small"
          placeholder="会议主题"
          style="width: 185px;"
          class="filter-item"
          @keyup.enter.native="crud.toQuery"
        />
        <el-date-picker
          v-model="query.startTime"
          type="daterange"
          clearable
          class="date-item"
          value-format="yyyy-MM-dd HH:mm:ss"
          placeholder="请选择日期时间"
          range-separator=" : "
          start-placeholder="开始时间"
          end-placeholder="开始时间"
        />
        <el-date-picker
          v-model="query.endTime"
          type="daterange"
          clearable
          class="date-item"
          value-format="yyyy-MM-dd HH:mm:ss"
          placeholder="请选择日期时间"
          range-separator=" : "
          start-placeholder="结束时间"
          end-placeholder="结束时间"
        />
        <rrOperation />
      </div>
      <!--如果想在工具栏加入更多按钮,可以使用插槽方式, slot = 'left' or 'right'-->
      <crudOperation :permission="permission" />
      <!--表单组件-->
      <el-dialog :close-on-click-modal="false" :before-close="crud.cancelCU" :visible.sync="crud.status.cu > 0" :title="crud.status.title" width="500px">
        <el-form ref="form" :model="form" :rules="rules" size="small" label-width="100px">
          <el-form-item label="所属会议室" prop="meetingId">
            <el-select v-model="form.meetingId" filterable clearable placeholder="请选择" style="width: 350px;">
              <el-option
                v-for="item in meetings"
                :key="item.id"
                :label="item.conferenceRoomName"
                :value="item.id"
              />
            </el-select>
          </el-form-item>
          <el-form-item label="会议主题" prop="meetingTheme">
            <el-input v-model="form.meetingTheme" style="width: 350px;" />
          </el-form-item>
          <el-form-item label="开始时间" prop="startTime">
            <el-date-picker
              v-model="form.startTime"
              :type="'datetime'"
              placeholder="选择日期时间"
              style="width: 350px;"
              value-format="yyyy-MM-dd HH:mm:00"
              align="right"
              :picker-options="{
                disabledDate(time) {
                  return form.endTime ? time.getTime() > new Date(form.endTime).getTime() - 8.64e7 : false;
                }
              }"
            />
          </el-form-item>
          <el-form-item label="结束时间" prop="endTime">
            <el-date-picker
              v-model="form.endTime"
              :type="'datetime'"
              placeholder="选择日期时间"
              style="width: 350px;"
              value-format="yyyy-MM-dd HH:mm:00"
              align="right"
              :picker-options="{
                disabledDate(time) {
                  return form.startTime ? time.getTime() < new Date(form.startTime).getTime() - 8.64e7 : false;
                }
              }"
            />
          </el-form-item>
          <el-form-item label="参与人数" prop="numberOfParticipants">
            <el-input v-model="form.numberOfParticipants" style="width: 350px;" />
          </el-form-item>
          <el-form-item label="备注">
            <el-input v-model="form.remarks" type="textarea" rows="3" style="width: 350px;" />
          </el-form-item>
        </el-form>
        <div slot="footer" class="dialog-footer">
          <el-button type="text" @click="crud.cancelCU">取消</el-button>
          <el-button :loading="crud.status.cu === 2" type="primary" @click="crud.submitCU">确认</el-button>
        </div>
      </el-dialog>
      <!--表格渲染-->
      <el-table ref="table" v-loading="crud.loading" :data="crud.data" size="small" style="width: 100%;" @selection-change="crud.selectionChangeHandler">
        <el-table-column type="selection" width="55" />
        <el-table-column prop="meetingId" label="所属会议室" show-overflow-tooltip>
          <template slot-scope="scope">
            <el-tag>{{ scope.row.meetingName }}</el-tag>
          </template>
        </el-table-column>
        <el-table-column prop="meetingTheme" label="会议主题" show-overflow-tooltip />
        <el-table-column prop="startTime" label="开始时间" show-overflow-tooltip />
        <el-table-column prop="endTime" label="结束时间" show-overflow-tooltip />
        <el-table-column prop="numberOfParticipants" label="参与人数" show-overflow-tooltip />
        <el-table-column prop="remarks" label="备注" />
        <el-table-column prop="createTime" label="创建时间" />
        <el-table-column v-if="checkPer(['admin','meetingRoomReservation:edit','meetingRoomReservation:del'])" label="操作" width="150px" align="center">
          <template slot-scope="scope">
            <udOperation
              :data="scope.row"
              :permission="permission"
            />
          </template>
        </el-table-column>
      </el-table>
      <!--分页组件-->
      <pagination />
    </div>
  </div>
</template>
<script>
import crudMeetingRoomReservation from '@/api/conferenceRoom/meetingRoomReservation'
import crudMeetingRoom from '@/api/conferenceRoom/meetingRoom'
import CRUD, { presenter, header, form, crud } from '@crud/crud'
import rrOperation from '@crud/RR.operation'
import crudOperation from '@crud/CRUD.operation'
import udOperation from '@crud/UD.operation'
import pagination from '@crud/Pagination'
const defaultForm = { id: null, meetingId: null, meetingTheme: null, startTime: null, endTime: null, numberOfParticipants: null, remarks: null, createBy: null, createTime: null, updateBy: null, updateTime: null }
export default {
  name: 'MeetingRoomReservation',
  components: { pagination, crudOperation, rrOperation, udOperation },
  mixins: [presenter(), header(), form(defaultForm), crud()],
  cruds() {
    return CRUD({ title: '会议室预约', url: 'api/meetingRoomReservation', idField: 'id', sort: 'id,desc', crudMethod: { ...crudMeetingRoomReservation }})
  },
  data() {
    // 工资(千万内)验证
    var wageValidate = (rule, value, callback) => {
      if (value != null && value !== '' && (isNaN(value) || Number(value) < 0 || Number(value) > 10000000)) {
        callback(new Error('请输入 一千万 以内的正整数或两位小数'))
      } else {
        callback()
      }
    }
    return {
      permission: {
        add: ['admin', 'meetingRoomReservation:add'],
        edit: ['admin', 'meetingRoomReservation:edit'],
        del: ['admin', 'meetingRoomReservation:del'],
        download: ['admin', 'meetingRoomReservation:download']
      },
      rules: {
        meetingId: [
          { required: true, message: '会议室id不能为空', trigger: 'blur' }
        ],
        meetingTheme: [
          { required: true, message: '会议主题不能为空', trigger: 'blur' }
        ],
        startTime: [
          { required: true, message: '开始时间不能为空', trigger: 'blur' }
        ],
        endTime: [
          { required: true, message: '结束时间不能为空', trigger: 'blur' }
        ],
        numberOfParticipants: [
          { validator: wageValidate, trigger: 'blur' }
        ]
      },
      meetings: [] }
  },
  methods: {
    // 钩子:在获取表格数据之前执行,false 则代表不获取数据
    [CRUD.HOOK.beforeRefresh]() {
      // 所属会议室
      crudMeetingRoom.getAll().then(res => {
        this.meetings = res
      })
      return true
    }
  }
}
</script>
<style scoped>
</style>