package com.product.administration.controller; import com.alibaba.druid.util.StringUtils; import com.alibaba.fastjson.JSONObject; import com.google.zxing.WriterException; import com.google.zxing.client.j2se.MatrixToImageWriter; import com.google.zxing.common.BitMatrix; import com.product.administration.config.CmnConst; import com.product.administration.config.SystemCode; import com.product.administration.service.ConferenceManagerService; import com.product.administration.service.ide.IConferenceManagerService; import com.product.core.config.CoreConst; import com.product.core.controller.support.AbstractBaseController; import com.product.core.entity.DataTableEntity; import com.product.core.entity.FieldSetEntity; import com.product.core.entity.RequestParameterEntity; import com.product.core.exception.BaseException; import com.product.core.permission.PermissionService; import com.product.module.sys.config.SystemErrorCode; import com.product.module.sys.version.ApiVersion; import com.product.util.BaseUtil; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import java.io.IOException; import java.io.OutputStream; import java.util.Date; import java.util.HashMap; import java.util.List; /** * @Author cheng * @Description 会议室管理 * @Date 2021/4/20 14:27 * @Version 1.0 */ @RestController @RequestMapping("/api/conference") public class ConferenceManagerController extends AbstractBaseController { @Autowired PermissionService permissionService; @Autowired ConferenceManagerService conferenceManagerService; /** * 会议室配置列表 * * @param request * @return */ @PostMapping("/list-conference-room/{version}") @ApiVersion(1) public String listConferenceRoom(HttpServletRequest request) { try { //获取参数 FieldSetEntity fse = null; Object bean = request.getAttribute(CoreConst.API_POST_REQUEST_DATA); if (bean != null) { RequestParameterEntity reqp = (RequestParameterEntity) bean; fse = reqp.getFormData(); } //判断参数是否为空 if (bean == null || fse == null) { return this.error(com.product.admin.config.SystemCode.SYSTEM_FORM_NODATA.getValue(), com.product.admin.config.SystemCode.SYSTEM_FORM_NODATA.getText()); } // 判断表名是否正常 if (fse.getTableName() == null || !CmnConst.PRODUCT_OA_CONFERENCE_ROOM_CONFIG.equals(fse.getTableName())) { return this.error(SystemCode.SYSTEM_TABLE_NODATA.getValue(), SystemCode.SYSTEM_TABLE_NODATA.getText()); } // 判断分页参数是否正常 if (StringUtils.isEmpty(fse.getString(CmnConst.PAGESIZE)) || StringUtils.isEmpty(fse.getString(CmnConst.CPAGE))) { return this.error(SystemCode.SYSTEM_FORM_COUNT.getValue(), SystemCode.SYSTEM_FORM_COUNT.getText()); } //数据操作的权限验证 if (!permissionService.validDataPermission(fse, CoreConst.DATA_PERMISSION_VALID_TYPE_ORG)) { return this.error(SystemErrorCode.SYSTEM_NOT_OPER_PERMISSION.getValue(), SystemErrorCode.SYSTEM_NOT_OPER_PERMISSION.getText()); } return OK_List(conferenceManagerService.getListConferenceRoom(fse)); } catch (BaseException e) { e.printStackTrace(); return this.error(e.getCode(), e.getMessage()); } catch (Exception e) { e.printStackTrace(); return this.error(SystemCode.CONFERENCE_ROOM_LIST_FIAL.getValue(), SystemCode.CONFERENCE_ROOM_LIST_FIAL.getText() + e.getMessage()); } } /** * 会议室配置详情 * * @param request * @return */ @PostMapping("/find-conference-room/{version}") @ApiVersion(1) public String findCconferenceRoom(HttpServletRequest request) { try { //获取参数 FieldSetEntity fse = null; Object bean = request.getAttribute(CoreConst.API_POST_REQUEST_DATA); if (bean != null) { RequestParameterEntity reqp = (RequestParameterEntity) bean; fse = reqp.getFormData(); } //判断参数是否为空 if (bean == null || fse == null) { return this.error(com.product.admin.config.SystemCode.SYSTEM_FORM_NODATA.getValue(), com.product.admin.config.SystemCode.SYSTEM_FORM_NODATA.getText()); } // 判断表名是否正常 if (fse.getTableName() == null || !CmnConst.PRODUCT_OA_CONFERENCE_ROOM_CONFIG.equals(fse.getTableName())) { return this.error(SystemCode.SYSTEM_TABLE_NODATA.getValue(), SystemCode.SYSTEM_TABLE_NODATA.getText()); } // 判断uuid是否正常 if (StringUtils.isEmpty(fse.getUUID())) { return this.error(SystemCode.SYSTEM_FORM_COUNT.getValue(), SystemCode.SYSTEM_FORM_COUNT.getText()); } //数据操作的权限验证 if (!permissionService.validDataPermission(fse, CoreConst.DATA_PERMISSION_VALID_TYPE_ORG)) { return this.error(SystemErrorCode.SYSTEM_NOT_OPER_PERMISSION.getValue(), SystemErrorCode.SYSTEM_NOT_OPER_PERMISSION.getText()); } return OK_List(conferenceManagerService.findConferenceRoom(fse)); } catch (BaseException e) { e.printStackTrace(); return this.error(e.getCode(), e.getMessage()); } catch (Exception e) { e.printStackTrace(); return this.error(SystemCode.CONFERENCE_ROOM_FIND_FIAL.getValue(), SystemCode.CONFERENCE_ROOM_FIND_FIAL.getText() + e.getMessage()); } } /** * 会议室保存 * * @param request * @return */ @PostMapping("/save-conference-room/{version}") @ApiVersion(1) public String saveCconferenceRoom(HttpServletRequest request) { try { //获取参数 FieldSetEntity fse = null; Object bean = request.getAttribute(CoreConst.API_POST_REQUEST_DATA); if (bean != null) { RequestParameterEntity reqp = (RequestParameterEntity) bean; fse = reqp.getFormData(); } //判断参数是否为空 if (bean == null || fse == null) { return this.error(com.product.admin.config.SystemCode.SYSTEM_FORM_NODATA.getValue(), com.product.admin.config.SystemCode.SYSTEM_FORM_NODATA.getText()); } // 判断表名是否正常 if (fse.getTableName() == null || !CmnConst.PRODUCT_OA_CONFERENCE_ROOM_CONFIG.equals(fse.getTableName())) { return this.error(SystemCode.SYSTEM_TABLE_NODATA.getValue(), SystemCode.SYSTEM_TABLE_NODATA.getText()); } //数据操作的权限验证 if (!permissionService.validDataPermission(fse, CoreConst.DATA_PERMISSION_VALID_TYPE_ORG)) { return this.error(SystemErrorCode.SYSTEM_NOT_OPER_PERMISSION.getValue(), SystemErrorCode.SYSTEM_NOT_OPER_PERMISSION.getText()); } IConferenceManagerService service=(IConferenceManagerService) getProxyInstance(conferenceManagerService); return service.saveConferenceRoom(fse)?OK():error(SystemCode.CONFERENCE_ROOM_SAVE_FIAL.getValue(),SystemCode.CONFERENCE_ROOM_FIND_FIAL.getText()); } catch (BaseException e) { e.printStackTrace(); return this.error(e.getCode(), e.getMessage()); } catch (Exception e) { e.printStackTrace(); return this.error(SystemCode.CONFERENCE_ROOM_SAVE_FIAL.getValue(), SystemCode.CONFERENCE_ROOM_FIND_FIAL.getText() + e.getMessage()); } } /** * 会议室删除 * * @param request * @return */ @PostMapping("/del-conference-room/{version}") @ApiVersion(1) public String deleteCconferenceRoom(HttpServletRequest request) { try { //获取参数 FieldSetEntity fse = null; Object bean = request.getAttribute(CoreConst.API_POST_REQUEST_DATA); if (bean != null) { RequestParameterEntity reqp = (RequestParameterEntity) bean; fse = reqp.getFormData(); } //判断参数是否为空 if (bean == null || fse == null) { return this.error(com.product.admin.config.SystemCode.SYSTEM_FORM_NODATA.getValue(), com.product.admin.config.SystemCode.SYSTEM_FORM_NODATA.getText()); } // 判断表名是否正常 if (fse.getTableName() == null || !CmnConst.PRODUCT_OA_CONFERENCE_ROOM_CONFIG.equals(fse.getTableName())) { return this.error(SystemCode.SYSTEM_TABLE_NODATA.getValue(), SystemCode.SYSTEM_TABLE_NODATA.getText()); } // 判断uuid是否正常 if (StringUtils.isEmpty(fse.getUUID())) { return this.error(SystemCode.SYSTEM_FORM_COUNT.getValue(), SystemCode.SYSTEM_FORM_COUNT.getText()); } //数据操作的权限验证 if (!permissionService.validDataPermission(fse, CoreConst.DATA_PERMISSION_VALID_TYPE_ORG)) { return this.error(SystemErrorCode.SYSTEM_NOT_OPER_PERMISSION.getValue(), SystemErrorCode.SYSTEM_NOT_OPER_PERMISSION.getText()); } IConferenceManagerService service=(IConferenceManagerService) getProxyInstance(conferenceManagerService); return service.delConferenceRoom(fse)?OK():error(SystemCode.CONFERENCE_ROOM_DEL_FIAL.getValue(),SystemCode.CONFERENCE_ROOM_DEL_FIAL.getText()); } catch (BaseException e) { e.printStackTrace(); return this.error(e.getCode(), e.getMessage()); } catch (Exception e) { e.printStackTrace(); return this.error(SystemCode.CONFERENCE_ROOM_DEL_FIAL.getValue(), SystemCode.CONFERENCE_ROOM_DEL_FIAL.getText() + e.getMessage()); } } /** * 会议申请 * * @param request * @return */ @PostMapping("/list-conference-apply/{version}") @ApiVersion(1) public String listConferenceApply(HttpServletRequest request) { try { //获取参数 FieldSetEntity fse = null; Object bean = request.getAttribute(CoreConst.API_POST_REQUEST_DATA); if (bean != null) { RequestParameterEntity reqp = (RequestParameterEntity) bean; fse = reqp.getFormData(); } //判断参数是否为空 if (bean == null || fse == null) { return this.error(com.product.admin.config.SystemCode.SYSTEM_FORM_NODATA.getValue(), com.product.admin.config.SystemCode.SYSTEM_FORM_NODATA.getText()); } // 判断表名是否正常 if (fse.getTableName() == null || !CmnConst.PRODUCT_OA_CONFERENCE_APPLY.equals(fse.getTableName())) { return this.error(SystemCode.SYSTEM_TABLE_NODATA.getValue(), SystemCode.SYSTEM_TABLE_NODATA.getText()); } // 判断分页参数是否正常 if (StringUtils.isEmpty(fse.getString(CmnConst.PAGESIZE)) || StringUtils.isEmpty(fse.getString(CmnConst.CPAGE))) { return this.error(SystemCode.SYSTEM_FORM_COUNT.getValue(), SystemCode.SYSTEM_FORM_COUNT.getText()); } //数据操作的权限验证 if (!permissionService.validDataPermission(fse, CoreConst.DATA_PERMISSION_VALID_TYPE_ORG)) { return this.error(SystemErrorCode.SYSTEM_NOT_OPER_PERMISSION.getValue(), SystemErrorCode.SYSTEM_NOT_OPER_PERMISSION.getText()); } return OK_List(conferenceManagerService.getListConferenceApply(fse)); } catch (BaseException e) { e.printStackTrace(); return this.error(e.getCode(), e.getMessage()); } catch (Exception e) { e.printStackTrace(); return this.error(SystemCode.CONFERENCE_APPLY_LIST_FIAL.getValue(), SystemCode.CONFERENCE_APPLY_LIST_FIAL.getText() + e.getMessage()); } } /** * 会议室配置详情 * * @param request * @return */ @PostMapping("/find-conference-apply/{version}") @ApiVersion(1) public String findCconferenceApply(HttpServletRequest request) { try { //获取参数 FieldSetEntity fse = null; Object bean = request.getAttribute(CoreConst.API_POST_REQUEST_DATA); if (bean != null) { RequestParameterEntity reqp = (RequestParameterEntity) bean; fse = reqp.getFormData(); } //判断参数是否为空 if (bean == null || fse == null) { return this.error(com.product.admin.config.SystemCode.SYSTEM_FORM_NODATA.getValue(), com.product.admin.config.SystemCode.SYSTEM_FORM_NODATA.getText()); } // 判断表名是否正常 if (fse.getTableName() == null || !CmnConst.PRODUCT_OA_CONFERENCE_APPLY.equals(fse.getTableName())) { return this.error(SystemCode.SYSTEM_TABLE_NODATA.getValue(), SystemCode.SYSTEM_TABLE_NODATA.getText()); } // 判断uuid是否正常 if (StringUtils.isEmpty(fse.getUUID())) { return this.error(SystemCode.SYSTEM_FORM_COUNT.getValue(), SystemCode.SYSTEM_FORM_COUNT.getText()); } //数据操作的权限验证 if (!permissionService.validDataPermission(fse, CoreConst.DATA_PERMISSION_VALID_TYPE_ORG)) { return this.error(SystemErrorCode.SYSTEM_NOT_OPER_PERMISSION.getValue(), SystemErrorCode.SYSTEM_NOT_OPER_PERMISSION.getText()); } JSONObject jsonObject = BaseUtil.fieldSetEntityToJson(conferenceManagerService.findConferenceApply(fse)); return BaseUtil.success(jsonObject,null); } catch (BaseException e) { e.printStackTrace(); return this.error(e.getCode(), e.getMessage()); } catch (Exception e) { e.printStackTrace(); return this.error(SystemCode.CONFERENCE_APPLY_FIND_FIAL.getValue(), SystemCode.CONFERENCE_APPLY_FIND_FIAL.getText() + e.getMessage()); } } /** * 会议室保存 * * @param request * @return */ @PostMapping("/save-conference-apply/{version}") @ApiVersion(1) public String saveCconferenceApply(HttpServletRequest request) { try { //获取参数 FieldSetEntity fse = null; Object bean = request.getAttribute(CoreConst.API_POST_REQUEST_DATA); if (bean != null) { RequestParameterEntity reqp = (RequestParameterEntity) bean; fse = reqp.getFormData(); } //判断参数是否为空 if (bean == null || fse == null) { return this.error(com.product.admin.config.SystemCode.SYSTEM_FORM_NODATA.getValue(), com.product.admin.config.SystemCode.SYSTEM_FORM_NODATA.getText()); } // 判断表名是否正常 if (fse.getTableName() == null || !CmnConst.PRODUCT_OA_CONFERENCE_APPLY.equals(fse.getTableName())) { return this.error(SystemCode.SYSTEM_TABLE_NODATA.getValue(), SystemCode.SYSTEM_TABLE_NODATA.getText()); } //数据操作的权限验证 if (!permissionService.validDataPermission(fse, CoreConst.DATA_PERMISSION_VALID_TYPE_ORG)) { return this.error(SystemErrorCode.SYSTEM_NOT_OPER_PERMISSION.getValue(), SystemErrorCode.SYSTEM_NOT_OPER_PERMISSION.getText()); } IConferenceManagerService service=(IConferenceManagerService) getProxyInstance(conferenceManagerService); return OK_Add(service.saveConferenceApply(fse)); } catch (BaseException e) { e.printStackTrace(); return this.error(e.getCode(), e.getMessage()); } catch (Exception e) { e.printStackTrace(); return this.error(SystemCode.CONFERENCE_APPLY_SAVE_FIAL.getValue(), SystemCode.CONFERENCE_APPLY_FIND_FIAL.getText() + e.getMessage()); } } /** * 会议室删除 * * @param request * @return */ @PostMapping("/del-conference-apply/{version}") @ApiVersion(1) public String deleteCconferenceApply(HttpServletRequest request) { try { //获取参数 FieldSetEntity fse = null; Object bean = request.getAttribute(CoreConst.API_POST_REQUEST_DATA); if (bean != null) { RequestParameterEntity reqp = (RequestParameterEntity) bean; fse = reqp.getFormData(); } //判断参数是否为空 if (bean == null || fse == null) { return this.error(com.product.admin.config.SystemCode.SYSTEM_FORM_NODATA.getValue(), com.product.admin.config.SystemCode.SYSTEM_FORM_NODATA.getText()); } // 判断表名是否正常 if (fse.getTableName() == null || !CmnConst.PRODUCT_OA_CONFERENCE_APPLY.equals(fse.getTableName())) { return this.error(SystemCode.SYSTEM_TABLE_NODATA.getValue(), SystemCode.SYSTEM_TABLE_NODATA.getText()); } // 判断uuid是否正常 if (StringUtils.isEmpty(fse.getUUID())) { return this.error(SystemCode.SYSTEM_FORM_COUNT.getValue(), SystemCode.SYSTEM_FORM_COUNT.getText()); } //数据操作的权限验证 if (!permissionService.validDataPermission(fse, CoreConst.DATA_PERMISSION_VALID_TYPE_ORG)) { return this.error(SystemErrorCode.SYSTEM_NOT_OPER_PERMISSION.getValue(), SystemErrorCode.SYSTEM_NOT_OPER_PERMISSION.getText()); } IConferenceManagerService service=(IConferenceManagerService) getProxyInstance(conferenceManagerService); return service.delConferenceApply(fse)?OK():error(SystemCode.CONFERENCE_APPLY_DEL_FIAL.getValue(),SystemCode.CONFERENCE_APPLY_DEL_FIAL.getText()); } catch (BaseException e) { e.printStackTrace(); return this.error(e.getCode(), e.getMessage()); } catch (Exception e) { e.printStackTrace(); return this.error(SystemCode.CONFERENCE_APPLY_DEL_FIAL.getValue(), SystemCode.CONFERENCE_APPLY_DEL_FIAL.getText() + e.getMessage()); } } /** * 会议室使用情况 * * @param request * @return */ @PostMapping("/conference-room-usage/{version}") @ApiVersion(1) public String conferenceRoomUsage(HttpServletRequest request) { try { //获取参数 FieldSetEntity fse = null; Object bean = request.getAttribute(CoreConst.API_POST_REQUEST_DATA); if (bean != null) { RequestParameterEntity reqp = (RequestParameterEntity) bean; fse = reqp.getFormData(); } //判断参数是否为空 if (bean == null || fse == null) { return this.error(com.product.admin.config.SystemCode.SYSTEM_FORM_NODATA.getValue(), com.product.admin.config.SystemCode.SYSTEM_FORM_NODATA.getText()); } // 判断表名是否正常 if (fse.getTableName() == null || !CmnConst.PRODUCT_OA_CONFERENCE_APPLY.equals(fse.getTableName())) { return this.error(SystemCode.SYSTEM_TABLE_NODATA.getValue(), SystemCode.SYSTEM_TABLE_NODATA.getText()); } return conferenceManagerService.getConferenceRoomUsage(fse); } catch (BaseException e) { e.printStackTrace(); return this.error(e.getCode(), e.getMessage()); } catch (Exception e) { e.printStackTrace(); return this.error(SystemCode.CONFERENCE_ROOM_GET_FIAL.getValue(), SystemCode.CONFERENCE_ROOM_GET_FIAL.getText() + e.getMessage()); } } @PostMapping("/get_kb_Data/{version}") @ApiVersion(1) public String getkbData(HttpServletRequest request){ //获取参数 FieldSetEntity fse = null; Object bean = request.getAttribute(CoreConst.API_POST_REQUEST_DATA); if (bean != null) { RequestParameterEntity reqp = (RequestParameterEntity) bean; fse = reqp.getFormData(); } //判断参数是否为空 if (bean == null || fse == null) { return this.error(com.product.admin.config.SystemCode.SYSTEM_FORM_NODATA.getValue(), com.product.admin.config.SystemCode.SYSTEM_FORM_NODATA.getText()); } List kbData = conferenceManagerService.getKbData(fse); return OK(kbData); } @PostMapping("/get_Meeting_Details/{version}") @ApiVersion(1) public String getMeetingDetails(HttpServletRequest request){ //获取参数 FieldSetEntity fse = null; Object bean = request.getAttribute(CoreConst.API_POST_REQUEST_DATA); if (bean != null) { RequestParameterEntity reqp = (RequestParameterEntity) bean; fse = reqp.getFormData(); } //判断参数是否为空 if (bean == null || fse == null) { return this.error(com.product.admin.config.SystemCode.SYSTEM_FORM_NODATA.getValue(), com.product.admin.config.SystemCode.SYSTEM_FORM_NODATA.getText()); } List meetingDetails = conferenceManagerService.getMeetingDetails(fse); return OK(meetingDetails); } @PostMapping("/save_or_update_meeting_info/{version}") @ApiVersion(1) public String saveOrUpdateMeetingInfo(HttpServletRequest request){ //获取参数 FieldSetEntity fse = null; Object bean = request.getAttribute(CoreConst.API_POST_REQUEST_DATA); if (bean != null) { RequestParameterEntity reqp = (RequestParameterEntity) bean; fse = reqp.getFormData(); } //判断参数是否为空 if (bean == null || fse == null) { return this.error(com.product.admin.config.SystemCode.SYSTEM_FORM_NODATA.getValue(), com.product.admin.config.SystemCode.SYSTEM_FORM_NODATA.getText()); } HashMap hashMap = conferenceManagerService.saveOrUpdateMeetingInfo(fse); return OK(hashMap); } /** * 会议管理签到二维码 * @param request * @param response * @throws IOException * @throws WriterException */ @PostMapping("/get_QrCode/{version}") @ApiVersion(1) public void getQrCode(HttpServletRequest request, HttpServletResponse response) throws IOException, WriterException { //获取参数 FieldSetEntity fse = null; Object bean = request.getAttribute(CoreConst.API_POST_REQUEST_DATA); if (bean != null) { RequestParameterEntity reqp = (RequestParameterEntity) bean; fse = reqp.getFormData(); if(fse!=null && !StringUtils.isEmpty(fse.getString("uuid"))){ String uuid = fse.getString("uuid"); // 设置响应流信息 response.setContentType("image/jpg"); response.setHeader("Pragma", "no-cache"); response.setHeader("Cache-Control", "no-cache"); response.setDateHeader("Expires", 0); OutputStream stream = response.getOutputStream(); //后端跳转地址 // String content = ("http://www.baidu.com"); JSONObject jsonData = new JSONObject(); jsonData.put("uuid",uuid); jsonData.put("date",new Date()); //jsonData.put("url",content); //获取一个二维码图片 BitMatrix bitMatrix = conferenceManagerService.getQrCode(jsonData.toString()); //以流的形式输出到前端 MatrixToImageWriter.writeToStream(bitMatrix , "jpg" , stream); } } } @PostMapping("/cancel_and_start/{version}") @ApiVersion(1) public String CancelAndStart(HttpServletRequest request){ //获取参数 FieldSetEntity fse = null; Object bean = request.getAttribute(CoreConst.API_POST_REQUEST_DATA); if (bean != null) { RequestParameterEntity reqp = (RequestParameterEntity) bean; fse = reqp.getFormData(); } //判断参数是否为空 if (bean == null || fse == null) { return this.error(com.product.admin.config.SystemCode.SYSTEM_FORM_NODATA.getValue(), com.product.admin.config.SystemCode.SYSTEM_FORM_NODATA.getText()); } conferenceManagerService.CancelAndStart(fse); return OK(); } }