Compare commits

..

No commits in common. '6be23a4a1e85f8c340947256d0ebc2350c35f9f7' and 'b37e8acb284e3ca828b97c6efa5e07c36143f6a9' have entirely different histories.

@ -125,12 +125,6 @@
<artifactId>javax.servlet-api</artifactId>
</dependency>
<dependency>
<groupId>com.google.zxing</groupId>
<artifactId>core</artifactId>
<version>3.3.3</version>
</dependency>
</dependencies>
</project>

@ -5,16 +5,11 @@ import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.nio.file.Paths;
import java.util.*;
import java.util.Base64;
import java.util.Objects;
import java.util.UUID;
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 org.apache.commons.io.FilenameUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.multipart.MultipartFile;
import com.ruoyi.common.config.RuoYiConfig;
@ -35,7 +30,6 @@ import javax.servlet.http.HttpServletRequest;
*/
public class FileUploadUtils
{
private static final Logger logger = LoggerFactory.getLogger(FileUploadUtils.class);
/**
* 50M
*/
@ -262,7 +256,6 @@ public class FileUploadUtils
b[i] += 256;
}
}
logger.info("file path :{}{}", uploadFilePath, imgClassPath);
// 保存图片
OutputStream out = new FileOutputStream(uploadFilePath.concat(imgClassPath));
out.write(b);
@ -271,31 +264,7 @@ public class FileUploadUtils
// 返回图片的相对路径 = 图片分类路径+图片名+图片后缀
return imgClassPath;
} catch (IOException e) {
logger.error("generateImage error", e);
return null;
}
}
public static String code(String content,String path) {
String picPath = "";
try {
String codeName = UUID.randomUUID().toString();// 二维码的图片名
String imageType = "jpg";// 图片类型
picPath = codeName + "." + imageType;
MultiFormatWriter multiFormatWriter = new MultiFormatWriter();
Map<EncodeHintType, String> hints = new HashMap<EncodeHintType, String>();
hints.put(EncodeHintType.CHARACTER_SET, "UTF-8");
BitMatrix bitMatrix = multiFormatWriter.encode(content, BarcodeFormat.QR_CODE, 400, 400, hints);
File file1 = new File(path, picPath);
MatrixToImageWriter.writeToFile(bitMatrix, imageType, file1);
} catch (WriterException e) {
logger.error("code WriterException:", e);
e.printStackTrace();
} catch (IOException e) {
logger.error("code IOException:", e);
e.printStackTrace();
}
return picPath;
}
}

@ -1,43 +0,0 @@
package com.ruoyi.common.utils.file;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import javax.imageio.ImageIO;
import com.google.zxing.common.BitMatrix;
/**
*
*
* @author 18316
*
*/
public class MatrixToImageWriter {
private static final int BLACK = 0xFF000000;
private static final int WHITE = 0xFFFFFFFF;
private MatrixToImageWriter() {
}
public static BufferedImage toBufferedImage(BitMatrix matrix) {
int width = matrix.getWidth();
int height = matrix.getHeight();
BufferedImage image = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
for (int x = 0; x < width; x++) {
for (int y = 0; y < height; y++) {
image.setRGB(x, y, matrix.get(x, y) ? BLACK : WHITE);
}
}
return image;
}
public static void writeToFile(BitMatrix matrix, String format, File file) throws IOException {
BufferedImage image = toBufferedImage(matrix);
if (!ImageIO.write(image, format, file)) {
throw new IOException("Could not write an image of format " + format + " to " + file);
}
}
}

@ -2,7 +2,6 @@ package com.ruoyi.framework.web.service;
import javax.annotation.Resource;
import com.alibaba.fastjson.JSONObject;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.UserStatus;
import com.ruoyi.common.utils.*;
@ -35,7 +34,6 @@ import com.ruoyi.system.service.ISysConfigService;
import com.ruoyi.system.service.ISysUserService;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
import java.util.Objects;
@ -206,13 +204,6 @@ public class SysLoginService
tDoctor.setUserId(sysUser.getUserId());
tDoctorMapper.insertTDoctor(tDoctor);
tDoctor.setIdentifier("10000000" + tDoctor.getId());
Map map = new HashMap();
map.put("id", tDoctor.getId());
map.put("from", "yinuo");
String content = JSONObject.toJSONString(map);
String qrCode = FileUploadUtils.code(content, uploadFilePath);
tDoctor.setQrCode(qrCode);
log.info("update doctor :{}", tDoctor);
tDoctorMapper.updateTDoctor(tDoctor);
}
LoginUser loginUser = new LoginUser();

@ -32,8 +32,6 @@ import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
import java.util.Objects;
@Service
@ -185,14 +183,6 @@ public class WechatServiceImpl implements IWechatService {
tDoctor.setUserId(sysUser.getUserId());
tDoctorMapper.insertTDoctor(tDoctor);
tDoctor.setIdentifier("10000000" + tDoctor.getId());
Map map = new HashMap();
map.put("id", tDoctor.getId());
map.put("from", "yinuo");
String content = JSONObject.toJSONString(map);
String qrCode = FileUploadUtils.code(content, uploadFilePath);
tDoctor.setQrCode(qrCode);
logger.info("update doctor :{}", tDoctor);
tDoctorMapper.updateTDoctor(tDoctor);
wechatUser.setUserId(tDoctor.getId());

Loading…
Cancel
Save