| | |
| | | import com.github.xiaoymin.knife4j.core.util.StrUtil; |
| | | import com.google.zxing.BarcodeFormat; |
| | | import com.google.zxing.EncodeHintType; |
| | | import com.google.zxing.WriterException; |
| | | import com.google.zxing.client.j2se.MatrixToImageWriter; |
| | | import com.google.zxing.common.BitMatrix; |
| | | import com.google.zxing.qrcode.QRCodeWriter; |
| | | import com.google.zxing.qrcode.decoder.ErrorCorrectionLevel; |
| | |
| | | ImageIO.write(image, IMAGE_FORMAT, output); |
| | | } |
| | | |
| | | /** |
| | | *高度——height, |
| | | * 宽度——width, |
| | | * 二维码内容——text(url需要自动跳转前面加上https://) |
| | | */ |
| | | public static byte[] getQRCodeImage(String text, int width, int height) throws WriterException, IOException { |
| | | QRCodeWriter qrCodeWriter = new QRCodeWriter(); |
| | | BitMatrix bitMatrix = qrCodeWriter.encode(text, BarcodeFormat.QR_CODE, width, height); |
| | | |
| | | ByteArrayOutputStream pngOutputStream = new ByteArrayOutputStream(); |
| | | MatrixToImageWriter.writeToStream(bitMatrix, "JPG", pngOutputStream); |
| | | byte[] pngData = pngOutputStream.toByteArray(); |
| | | return pngData; |
| | | } |
| | | |
| | | } |
| | |
| | | SELECT |
| | | sa.id,sa.candidate_no candidateNo, |
| | | ke.exam_type examType,ke.start_time startTime,ke.end_time endTime,ke.exam_name examName, |
| | | bu.real_name realName,bu.cardid idCardNo,ifnull(bu.sex,0) sex,bu.my_picture myPicture, |
| | | bu.real_name realName,bu.cardid idCardNo,ifnull(bu.sex,0) sex,bu.avatar myPicture, |
| | | bd.dept_name deptName,"保安证" applyCard |
| | | FROM |
| | | sys_apply sa |
| | |
| | | select |
| | | sr.candidate_no candidateNo, |
| | | bt.dept_name AS deptName,"保安证" applyCard, |
| | | bu.real_name realName,bu.cardid idCardNo,ifnull(bu.sex,0) sex,bu.my_picture myPicture, |
| | | bu.real_name realName,bu.cardid idCardNo,ifnull(bu.sex,0) sex,bu.avatar myPicture, |
| | | ke.exam_type examType,ke.start_time startTime,ke.end_time endTime,ke.exam_name examName |
| | | FROM |
| | | sys_training_registration sr |
| | |
| | | package org.springblade.modules.qrcode; |
| | | |
| | | import com.google.zxing.WriterException; |
| | | import lombok.AllArgsConstructor; |
| | | import org.springblade.common.utils.QRCodeUtil; |
| | | import org.springblade.core.mp.support.Condition; |
| | | import org.springblade.core.tool.api.R; |
| | | import org.springblade.modules.system.entity.User; |
| | | import org.springblade.modules.system.service.IUserService; |
| | | import org.springblade.modules.system.vo.UserVO; |
| | | import org.springframework.http.HttpHeaders; |
| | | import org.springframework.http.HttpStatus; |
| | | import org.springframework.http.MediaType; |
| | | import org.springframework.http.ResponseEntity; |
| | | import org.springframework.web.bind.annotation.GetMapping; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | |
| | | import java.io.IOException; |
| | | import java.io.UnsupportedEncodingException; |
| | | import java.net.URLEncoder; |
| | | |
| | | /** |
| | | * @author zhongrj |
| | |
| | | */ |
| | | @RestController |
| | | @RequestMapping("/qrCode") |
| | | @AllArgsConstructor |
| | | public class QrCodeController { |
| | | |
| | | private final IUserService userService; |
| | | |
| | | /** |
| | | * 二维码生成 |
| | | * @param securityNumber 保安证编号 |
| | | * @return |
| | | */ |
| | | @GetMapping("/getQrCode") |
| | | public R getQrCode(String content){ |
| | | //获取二维码 |
| | | String qrCode = QRCodeUtil.getBase64QRCode(content); |
| | | return R.data(qrCode); |
| | | public ResponseEntity<byte[]> getQrCode(String securityNumber){ |
| | | String url = "http://s16s652780.51mypc.cn/securityInfo/securityInfo.html"; |
| | | if (null!=securityNumber) { |
| | | String content = url + "?securityNumber=" + securityNumber; |
| | | // "&realName=" + one.getRealName() + |
| | | // "&age=" + one.getAge() + |
| | | // "&sex=" + one.getSex() + |
| | | // "&avatar=" + one.getAvatar() + |
| | | // "&deptName=" + one.getDeptName(); |
| | | |
| | | |
| | | ResponseEntity<byte[]> aEntity = null; |
| | | try { |
| | | byte[] qrCodeImage = QRCodeUtil.getQRCodeImage(content, 350, 350); |
| | | // Set headers |
| | | final HttpHeaders headers = new HttpHeaders(); |
| | | headers.setContentType(MediaType.IMAGE_PNG); |
| | | aEntity = new ResponseEntity<byte[]>(qrCodeImage, headers, HttpStatus.CREATED); |
| | | } catch (WriterException e) { |
| | | e.printStackTrace(); |
| | | } catch (IOException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | return aEntity; |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | /** |
| | | * 根据保安员编码查询保安员信息 |
| | | * @param securityNumber |
| | | * @return |
| | | */ |
| | | @GetMapping("/getUserInfo") |
| | | public UserVO getUserInfo(String securityNumber){ |
| | | //根据保安员编码查询保安员信息 |
| | | return userService.getUserInfoBySecurityNumber(securityNumber); |
| | | } |
| | | |
| | | } |
| | |
| | | UserVO getUserAgeById(@Param("userId") Long userId); |
| | | |
| | | List<Map<String, Object>> selectUser(); |
| | | |
| | | /** |
| | | * 根据保安员编码查询保安信息 |
| | | * @param securityNumber 保安证编码 |
| | | * @return |
| | | */ |
| | | UserVO getUserInfoBySecurityNumber(@Param("securityNumber") String securityNumber); |
| | | } |
| | |
| | | <if test="user.realName!=null and user.realName != ''"> |
| | | and bu.real_name like concat('%', #{user.realName},'%') |
| | | </if> |
| | | <if test="user.dispatch!=null and user.dispatch != ''"> |
| | | and bu.dispatch = #{user.dispatch} |
| | | </if> |
| | | <if test="user.userType!=null and user.userType != ''"> |
| | | and bu.user_type = #{user.userType} |
| | | </if> |
| | |
| | | </select> |
| | | |
| | | |
| | | <!--根据保安员编码查询保安信息--> |
| | | <select id="getUserInfoBySecurityNumber" resultType="org.springblade.modules.system.vo.UserVO"> |
| | | select |
| | | bu.id, |
| | | bu.avatar, |
| | | bu.securitynumber securityNumber, |
| | | ifnull(TIMESTAMPDIFF(YEAR, bu.birthday, CURDATE()),0) age, |
| | | bu.real_name realName, |
| | | bu.sex, |
| | | bd.dept_name deptName |
| | | from |
| | | blade_user bu |
| | | left join |
| | | blade_dept bd |
| | | on |
| | | bu.dept_id = bd.id |
| | | where securitynumber = #{securityNumber} |
| | | </select> |
| | | |
| | | |
| | | <select id="selectUser" resultType="java.util.HashMap"> |
| | | select CAST(id AS CHAR) as groupmember,real_name as rname from blade_user |
| | | </select> |
| | |
| | | * @param isCovered |
| | | */ |
| | | void importSecurity(List<UserExcel> data, Boolean isCovered); |
| | | |
| | | /** |
| | | * 根据保安员编码查询保安信息 |
| | | * @param securityNumber 保安证编码 |
| | | * @return |
| | | */ |
| | | UserVO getUserInfoBySecurityNumber(String securityNumber); |
| | | } |
| | |
| | | this.submit(user); |
| | | }); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 根据保安员编码查询保安信息 |
| | | * @param securityNumber 保安证编码 |
| | | * @return |
| | | */ |
| | | @Override |
| | | public UserVO getUserInfoBySecurityNumber(String securityNumber) { |
| | | return baseMapper.getUserInfoBySecurityNumber(securityNumber); |
| | | } |
| | | } |