| | |
| | | package com.product.administration.service; |
| | | |
| | | import cn.hutool.core.date.DateUnit; |
| | | import cn.hutool.core.date.DateUtil; |
| | | import cn.hutool.core.util.ObjectUtil; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.google.errorprone.annotations.Var; |
| | | import com.google.zxing.BarcodeFormat; |
| | | import com.google.zxing.EncodeHintType; |
| | | import com.google.zxing.MultiFormatWriter; |
| | | import com.google.zxing.WriterException; |
| | | import com.google.zxing.common.BitMatrix; |
| | | import com.google.zxing.qrcode.decoder.ErrorCorrectionLevel; |
| | | import com.product.administration.config.CmnConst; |
| | | import com.product.administration.config.SystemCode; |
| | | import com.product.administration.service.ide.IConferenceManagerService; |
| | |
| | | import com.product.core.dao.BaseDao; |
| | | 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.core.service.support.AbstractBaseService; |
| | | import com.product.core.service.support.QueryFilterService; |
| | | import com.product.core.spring.context.SpringMVCContextHolder; |
| | | import com.product.core.transfer.Transactional; |
| | | import com.product.core.util.QuickResponUtil; |
| | | import com.product.core.websocket.service.WebsocketMesssageServiceThread; |
| | | import com.product.module.sys.entity.SystemUser; |
| | | import com.product.util.BaseUtil; |
| | |
| | | import java.io.IOException; |
| | | import java.text.DecimalFormat; |
| | | import java.text.Format; |
| | | import java.text.ParseException; |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.*; |
| | | |
| | |
| | | param.add(meeting_room); |
| | | param.add(meeting_date); |
| | | StringBuilder sb=new StringBuilder(); |
| | | sb.append(" SELECT b.uuid,b.start_time,b.end_time,b.meeting_topic,b.status, "); |
| | | sb.append(" SELECT b.uuid,b.start_time,b.end_time,b.meeting_topic,b.status,b.record_man as record_man_uuid, "); |
| | | sb.append(" (select user_name from product_sys_users where user_id=b.record_man) as record_man,"); |
| | | sb.append(" (select user_name from product_sys_users where user_id=b.record_master) as record_master,"); |
| | | sb.append(" CONCAT(DATE_FORMAT(b.start_time,\"%H-%i-%S\"),'~',DATE_FORMAT(b.end_time,\"%H-%i-%S\")) as time_quantum,"); |
| | |
| | | String end_time_date = dateFormat.format(end_time); |
| | | MapValues.put("start_time",start_time_date); |
| | | MapValues.put("end_time",end_time_date); |
| | | } |
| | | |
| | | Date date = new Date(); |
| | | //是否能够取消 |
| | | if(date.before(fieldSetEntity.getDate("start_time"))){ |
| | | MapValues.put("isCancel",true); |
| | | } |
| | | //是否执行开启功能 |
| | | if(date.before(fieldSetEntity.getDate("start_time")) && fieldSetEntity.getString("status").equals("已取消")){ |
| | | MapValues.put("isStart",true); |
| | | } |
| | | dataList.add(MapValues); |
| | | } |
| | |
| | | } |
| | | |
| | | @Override |
| | | public String getQrCode(FieldSetEntity fse) throws BaseException, WriterException, IOException { |
| | | String uuid="96f161b4-6360-40ba-8dc1-72bb39d56be4"; |
| | | int BLACK = 0xFF000000; |
| | | int WHITE = 0xFFFFFFFF; |
| | | Date date = new Date(); |
| | | String text = "http://127.0.0.1:9998/lx/api/conference/get_QrCode_Info/v1?uuid=" + uuid+"&date="+date; |
| | | String path = "D:/QRCode"; // 图片生成的位置 |
| | | int width = 400; |
| | | int height = 400; |
| | | // 二维码图片格式 |
| | | String format = "jpg"; |
| | | // 设置编码,防止中文乱码 |
| | | Hashtable<EncodeHintType, Object> ht = new Hashtable<EncodeHintType, Object>(); |
| | | ht.put(EncodeHintType.CHARACTER_SET, "UTF-8"); |
| | | // 设置二维码参数(编码内容,编码类型,图片宽度,图片高度,格式) |
| | | BitMatrix bitMatrix = new MultiFormatWriter().encode(text, BarcodeFormat.QR_CODE, width, height, ht); |
| | | // 生成二维码(定义二维码输出服务器路径) |
| | | File outputFile = new File(path); |
| | | if (!outputFile.exists()) { |
| | | // 创建文件夹 |
| | | outputFile.mkdir(); |
| | | }else { |
| | | outputFile.delete(); |
| | | outputFile.mkdir(); |
| | | public BitMatrix getQrCode(String content) throws BaseException, WriterException, IOException { |
| | | |
| | | //二维码的宽高 |
| | | int width = 200; |
| | | int height = 200; |
| | | |
| | | //其他参数,如字符集编码 |
| | | Map<EncodeHintType, Object> hints = new HashMap<EncodeHintType, Object>(); |
| | | hints.put(EncodeHintType.CHARACTER_SET, "UTF-8"); |
| | | //容错级别为H |
| | | hints.put(EncodeHintType.ERROR_CORRECTION , ErrorCorrectionLevel.H); |
| | | //白边的宽度,可取0~4 |
| | | hints.put(EncodeHintType.MARGIN , 0); |
| | | |
| | | BitMatrix bitMatrix = null; |
| | | try { |
| | | |
| | | bitMatrix = new MultiFormatWriter().encode(content, |
| | | BarcodeFormat.QR_CODE, width, height, hints); |
| | | |
| | | } catch (WriterException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | |
| | | int b_width = bitMatrix.getWidth(); |
| | | int b_height = bitMatrix.getHeight(); |
| | | // 建立图像缓冲器 |
| | | BufferedImage image = new BufferedImage(b_width, b_height, BufferedImage.TYPE_3BYTE_BGR); |
| | | for (int x = 0; x < b_width; x++) { |
| | | for (int y = 0; y < b_height; y++) { |
| | | image.setRGB(x, y, bitMatrix.get(x, y) ? BLACK : WHITE); |
| | | } |
| | | } |
| | | // 生成二维码 |
| | | ImageIO.write(image, format, new File(path + "/code." + format)); |
| | | // 二维码的名称 |
| | | // code.jpg |
| | | |
| | | return path + "/code." + format; |
| | | return bitMatrix; |
| | | } |
| | | |
| | | @Override |
| | | public void CancelAndStart(FieldSetEntity fse) throws BaseException { |
| | | |
| | | String uuid = fse.getString("uuid"); |
| | | String filter=" uuid='"+uuid+"'"; |
| | | DataTableEntity product_oa_conference_apply = baseDao.listTable("product_oa_conference_apply", filter, new Object[]{}); |
| | | if(product_oa_conference_apply.getRows()!=0){ |
| | | FieldSetEntity fieldSetEntity = product_oa_conference_apply.getFieldSetEntity(0); |
| | | if(fieldSetEntity.getString("status").equals("已取消")){ |
| | | fieldSetEntity.setValue("status","已启用"); |
| | | }else { |
| | | fieldSetEntity.setValue("status","已取消"); |
| | | } |
| | | baseDao.update(fieldSetEntity); |
| | | } |
| | | |
| | | } |
| | | |
| | | @Override |
| | | public String ConferenceSign(FieldSetEntity fse) throws BaseException, ParseException { |
| | | |
| | | |
| | | JSONObject jsonObject = new JSONObject(); |
| | | /* if(!StringUtils.isEmpty(fse.getString("uuid"))&&!StringUtils.isEmpty(fse.getString("date"))){*/ |
| | | /*String uuid = fse.getString("uuid"); |
| | | String date = fse.getString("date"); |
| | | SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); |
| | | Date parseDate = dateFormat.parse(date); |
| | | long between = DateUtil.between(parseDate, new Date(), DateUnit.SECOND);*/ |
| | | String uuid="5591f2ea-b7bd-49c4-999a-9a1045edc717"; |
| | | /* if(between>20){ |
| | | jsonObject.put("code","200"); |
| | | jsonObject.put("msg","二维码已失效"); |
| | | jsonObject.put("status","fail"); |
| | | |
| | | }else {*/ |
| | | |
| | | SystemUser currentUser = SpringMVCContextHolder.getCurrentUser(); |
| | | FieldSetEntity fieldSetEntity = new FieldSetEntity(); |
| | | fieldSetEntity.setTableName("product_oa_conference_sign"); |
| | | fieldSetEntity.setValue("sign_user",currentUser.getUser_name()); |
| | | fieldSetEntity.setValue("user_id",currentUser.getUser_id()); |
| | | fieldSetEntity.setValue("org_level_uuid","00000000-0000-0000-0000-000000000000"); |
| | | fieldSetEntity.setValue("organization",currentUser.getDept_uuid()); |
| | | fieldSetEntity.setValue("organization_name",currentUser.getCurrentDept().getString("org_level_name")); |
| | | fieldSetEntity.setValue("sign_date",new Date()); |
| | | fieldSetEntity.setValue("sign_status","已签到"); |
| | | fieldSetEntity.setValue("meeting_uuid",uuid); |
| | | |
| | | // BaseUtil.createCreatorAndCreationTime(SpringMVCContextHolder.getCurrentUser(), fse); |
| | | baseDao.add(fieldSetEntity); |
| | | jsonObject.put("code","200"); |
| | | jsonObject.put("msg","签到成功"); |
| | | jsonObject.put("status","sucess"); |
| | | /* }*/ |
| | | /* }*/ |
| | | |
| | | return jsonObject.toString(); |
| | | } |
| | | |
| | | |
| | | /** |