| | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.google.zxing.WriterException; |
| | | import lombok.AllArgsConstructor; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.springblade.common.cache.SysCache; |
| | |
| | | import java.io.FileNotFoundException; |
| | | import java.io.FileOutputStream; |
| | | import java.io.IOException; |
| | | import java.io.UnsupportedEncodingException; |
| | | import java.net.URLEncoder; |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.*; |
| | | import java.util.concurrent.atomic.AtomicBoolean; |
| | |
| | | */ |
| | | @Override |
| | | public void importQrCode(List<QrCodeExcel> data, Boolean isCovered, String deptId) { |
| | | // String url = "http://223.82.109.183:2080/securityInfo.html"; |
| | | // data.forEach(qrCodeExcel -> { |
| | | // if (null!=qrCodeExcel.getSecuritynumber()) { |
| | | // String encoded = null; |
| | | // try { |
| | | // //中文字符串编码 |
| | | // encoded = URLEncoder.encode(qrCodeExcel.getSecuritynumber(),"UTF-8"); |
| | | // } catch (UnsupportedEncodingException e) { |
| | | // e.printStackTrace(); |
| | | // } |
| | | // //url 拼接 |
| | | // String content = url + "?securityNumber=" + encoded; |
| | | // byte[] qrCodeImage = new byte[0]; |
| | | // try { |
| | | // //生成二维码字节流 |
| | | // qrCodeImage = QRCodeUtil.getQRCodeImage(content, 350, 350); |
| | | // } catch (WriterException e) { |
| | | // e.printStackTrace(); |
| | | // } catch (IOException e) { |
| | | // e.printStackTrace(); |
| | | // } |
| | | // String path = "D:\\QrCode\\"; |
| | | // FileOutputStream fileOutputStream = null; |
| | | // try { |
| | | // fileOutputStream = new FileOutputStream(path+qrCodeExcel.getSecuritynumber()+".png"); |
| | | // } catch (FileNotFoundException e) { |
| | | // e.printStackTrace(); |
| | | // } |
| | | // try { |
| | | // //图片下载到本地 |
| | | // fileOutputStream.write(qrCodeImage,0,qrCodeImage.length); |
| | | // fileOutputStream.flush(); |
| | | // fileOutputStream.close(); |
| | | // } catch (IOException e) { |
| | | // e.printStackTrace(); |
| | | // } |
| | | // } |
| | | // }); |
| | | String url = "http://223.82.109.183:2080/securityInfo.html"; |
| | | //二维码生成 |
| | | data.forEach(qrCodeExcel -> { |
| | | if (null!=qrCodeExcel.getSecuritynumber()) { |
| | | String encoded = null; |
| | | try { |
| | | //中文字符串编码 |
| | | encoded = URLEncoder.encode(qrCodeExcel.getSecuritynumber(),"UTF-8"); |
| | | } catch (UnsupportedEncodingException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | //url 拼接 |
| | | String content = url + "?securityNumber=" + encoded; |
| | | byte[] qrCodeImage = new byte[0]; |
| | | try { |
| | | //生成二维码字节流 |
| | | qrCodeImage = QRCodeUtil.getQRCodeImage(content, 350, 350); |
| | | } catch (WriterException e) { |
| | | e.printStackTrace(); |
| | | } catch (IOException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | String path = "D:\\QrCode\\"; |
| | | FileOutputStream fileOutputStream = null; |
| | | try { |
| | | fileOutputStream = new FileOutputStream(path+qrCodeExcel.getSecuritynumber()+".png"); |
| | | } catch (FileNotFoundException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | try { |
| | | //图片下载到本地 |
| | | fileOutputStream.write(qrCodeImage,0,qrCodeImage.length); |
| | | fileOutputStream.flush(); |
| | | fileOutputStream.close(); |
| | | } catch (IOException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | }); |
| | | //头像生成 |
| | | data.forEach(qrCodeExcel -> { |
| | | if (null!=qrCodeExcel.getSecuritynumber()) { |
| | | //查询用户头像url |
| | | User user = new User(); |
| | | user.setRealName(qrCodeExcel.getRealName()); |
| | | user.setStatus(1); |
| | | user.setIsDeleted(0); |
| | | user.setSecuritynumber(qrCodeExcel.getSecuritynumber()); |
| | | User user1 = this.getOne(Condition.getQueryWrapper(user)); |
| | | //url 拼接 |