二维码接口修改(中文不识别),保安员查询新增帅选条件
| | |
| | | */ |
| | | 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); |
| | | |
| | | HashMap<EncodeHintType, Object> hints = new HashMap<>(); |
| | | hints.put(EncodeHintType.CHARACTER_SET, "utf-8"); |
| | | |
| | | BitMatrix bitMatrix =qrCodeWriter.encode(text,BarcodeFormat.QR_CODE, width, height,hints); |
| | | //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; |
| | | //返回 |
| | | return pngOutputStream.toByteArray(); |
| | | } |
| | | |
| | | } |
| | |
| | | import org.springframework.web.bind.annotation.GetMapping; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | import sun.misc.BASE64Encoder; |
| | | |
| | | import java.io.IOException; |
| | | import java.io.UnsupportedEncodingException; |
| | | import java.net.URLEncoder; |
| | | import java.util.Base64; |
| | | |
| | | /** |
| | | * @author zhongrj |
| | |
| | | |
| | | ResponseEntity<byte[]> aEntity = null; |
| | | try { |
| | | URLEncoder.encode(content,"utf-8"); |
| | | byte[] qrCodeImage = QRCodeUtil.getQRCodeImage(content, 350, 350); |
| | | // Set headers |
| | | final HttpHeaders headers = new HttpHeaders(); |
| | |
| | | return null; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 二维码生成 |
| | | * @param securityNumber 保安证编号 |
| | | * @return |
| | | */ |
| | | @GetMapping("/getQrCodeBase64") |
| | | public String getQrCodeBase64(String securityNumber) throws Exception{ |
| | | String url = "http://s16s652780.51mypc.cn/securityInfo/securityInfo.html"; |
| | | if (null!=securityNumber) { |
| | | String content = url + "?securityNumber=" + securityNumber; |
| | | byte[] qrCodeImage = QRCodeUtil.getQRCodeImage(content, 350, 350); |
| | | String encode = new BASE64Encoder().encode(qrCodeImage); |
| | | return "data:image/png;base64,"+encode; |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | /** |
| | | * 根据保安员编码查询保安员信息 |
| | | * @param securityNumber |
| | |
| | | and bu.user_type = #{user.userType} |
| | | </if> |
| | | <if test="user.securitynumber!=null and user.securitynumber != ''"> |
| | | and bu.securitynumber = #{user.securitynumber} |
| | | and bu.securitynumber like concat('%', #{user.securitynumber},'%') |
| | | </if> |
| | | <if test="user.cardid!=null and user.cardid != ''"> |
| | | and bu.cardid like concat('%', #{user.cardid},'%') |
| | | </if> |
| | | <if test="user.examinationType!=null and user.examinationType != ''"> |
| | | and bu.examination_type = #{user.examinationType} |