| | |
| | | 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.service.MyAsyncService; |
| | | import org.springblade.modules.system.vo.UserVO; |
| | | import org.springframework.http.HttpHeaders; |
| | | import org.springframework.http.HttpStatus; |
| | |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | import sun.misc.BASE64Encoder; |
| | | |
| | | import java.io.FileOutputStream; |
| | | import java.io.IOException; |
| | | import java.io.UnsupportedEncodingException; |
| | | import java.net.URLEncoder; |
| | |
| | | |
| | | private final IUserService userService; |
| | | |
| | | private final MyAsyncService myAsyncService; |
| | | |
| | | /** |
| | | * 二维码生成-字节流 |
| | | * @param securityNumber 保安证编号 |
| | | * @return |
| | | */ |
| | | @GetMapping("/getQrCode") |
| | | public ResponseEntity<byte[]> getQrCode(String securityNumber){ |
| | | public ResponseEntity<byte[]> getQrCode(String securityNumber) throws UnsupportedEncodingException { |
| | | // String url = "http://s16s652780.51mypc.cn/securityInfo/securityInfo.html"; |
| | | String url = "http://223.82.109.183:2080/securityInfo.html"; |
| | | String url = "http://61.131.136.25:2080/securityInfo.html"; |
| | | if (null!=securityNumber) { |
| | | String content = url + "?securityNumber=" + securityNumber; |
| | | String encoded = URLEncoder.encode(securityNumber,"UTF-8"); |
| | | String content = url + "?securityNumber=" + encoded; |
| | | // "&realName=" + one.getRealName() + |
| | | // "&age=" + one.getAge() + |
| | | // "&sex=" + one.getSex() + |
| | |
| | | ResponseEntity<byte[]> aEntity = null; |
| | | try { |
| | | URLEncoder.encode(content,"utf-8"); |
| | | System.out.println("content = " + content); |
| | | byte[] qrCodeImage = QRCodeUtil.getQRCodeImage(content, 350, 350); |
| | | |
| | | // Set headers |
| | | final HttpHeaders headers = new HttpHeaders(); |
| | | headers.setContentType(MediaType.IMAGE_PNG); |
| | |
| | | @GetMapping("/getQrCodeBase64") |
| | | public String getQrCodeBase64(String securityNumber) throws Exception{ |
| | | // String url = "http://s16s652780.51mypc.cn/securityInfo/securityInfo.html"; |
| | | String url = "http://223.82.109.183:2080/securityInfo.html"; |
| | | String url = "http://61.131.136.25:2080/securityInfo.html"; |
| | | if (null!=securityNumber) { |
| | | String content = url + "?securityNumber=" + securityNumber; |
| | | String encoded = URLEncoder.encode(securityNumber,"UTF-8"); |
| | | String content = url + "?securityNumber=" + encoded; |
| | | byte[] qrCodeImage = QRCodeUtil.getQRCodeImage(content, 350, 350); |
| | | String encode = new BASE64Encoder().encode(qrCodeImage); |
| | | return "data:image/png;base64,"+encode; |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 二维码生成base64 |
| | | * @param securityNumber 保安证编号 |
| | | * @return |
| | | */ |
| | | @GetMapping("/getQrCodeDown") |
| | | public String getQrCodeDown(String securityNumber) throws Exception{ |
| | | // String url = "http://s16s652780.51mypc.cn/securityInfo/securityInfo.html"; |
| | | String url = "http://61.131.136.25:2080/securityInfo.html"; |
| | | if (null!=securityNumber) { |
| | | String encoded = URLEncoder.encode(securityNumber,"UTF-8"); |
| | | String content = url + "?securityNumber=" + encoded; |
| | | byte[] qrCodeImage = QRCodeUtil.getQRCodeImage(content, 350, 350); |
| | | String path = "D:\\QrCode\\"; |
| | | FileOutputStream fileOutputStream = new FileOutputStream(path+securityNumber+".png"); |
| | | fileOutputStream.write(qrCodeImage,0,qrCodeImage.length); |
| | | fileOutputStream.flush(); |
| | | fileOutputStream.close(); |
| | | return securityNumber; |
| | | } |
| | | return null; |
| | | } |
| | |
| | | * @return |
| | | */ |
| | | @GetMapping("/getUserInfo") |
| | | public UserVO getUserInfo(String securityNumber){ |
| | | public UserVO getUserInfo(String securityNumber,String cardid){ |
| | | //根据保安员编码查询保安员信息 |
| | | return userService.getUserInfoBySecurityNumber(securityNumber); |
| | | return userService.getUserInfoBySecurityNumber(securityNumber,cardid); |
| | | } |
| | | |
| | | /** |
| | | * test |
| | | * 异步调用测试 |
| | | */ |
| | | @GetMapping("/test") |
| | | public void test(){ |
| | | //根据保安员编码查询保安员信息 |
| | | for (int i = 0; i < 500; i++) { |
| | | User user = new User(); |
| | | user.setCardid("cardid"+i); |
| | | myAsyncService.test(user); |
| | | } |
| | | } |
| | | |
| | | } |