Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
610aa48b50
@ -106,6 +106,88 @@ public class QrCodeUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// // 将码牌编号文字绘制到指定位置
|
||||||
|
// g.drawString(storeNumber, 200, 800);
|
||||||
|
g.dispose();
|
||||||
|
// 输出图片
|
||||||
|
String urlsss = "/temp/qrCode/";
|
||||||
|
if (ObjectUtils.isNotEmpty(urls)){
|
||||||
|
urlsss = urls;
|
||||||
|
}
|
||||||
|
File file1 = new File(urlsss);
|
||||||
|
// 判断目录是否存在
|
||||||
|
if (!file1.exists()) {
|
||||||
|
file1.mkdirs();
|
||||||
|
}
|
||||||
|
|
||||||
|
FileOutputStream outImgStream = new FileOutputStream(outImgPath);
|
||||||
|
ImageIO.write(bufImg, "jpg", outImgStream);
|
||||||
|
outImgStream.flush();
|
||||||
|
outImgStream.close();
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void createLogoCodePictures(InputStream backgroundStream, InputStream logoStream, String url, String outImgPath, Integer staffId, Integer storeId,String urls) {
|
||||||
|
try {
|
||||||
|
// 读取原图片信息
|
||||||
|
//得到文件
|
||||||
|
//// File file = ResourceUtils.getFile(roundImage);
|
||||||
|
// ClassPathResource resource = new ClassPathResource(roundImage);
|
||||||
|
// ClassPathResource logoResource = new ClassPathResource(logoImage);
|
||||||
|
// File file = resource.getFile();
|
||||||
|
|
||||||
|
//文件转化为图片
|
||||||
|
Image srcImg = ImageIO.read(backgroundStream);
|
||||||
|
//获取图片的宽
|
||||||
|
int srcImgWidth = srcImg.getWidth(null);
|
||||||
|
//获取图片的高
|
||||||
|
int srcImgHeight = srcImg.getHeight(null);
|
||||||
|
// 加水印
|
||||||
|
BufferedImage bufImg = new BufferedImage(srcImgWidth, srcImgHeight, BufferedImage.TYPE_INT_RGB);
|
||||||
|
Graphics2D g = bufImg.createGraphics();
|
||||||
|
g.drawImage(srcImg, 0, 0, srcImgWidth, srcImgHeight, null);
|
||||||
|
//使用工具类生成二维码
|
||||||
|
Image image = createQrCode(logoStream, url, 360, 360);
|
||||||
|
//将小图片绘到大图片上,500,300 .表示你的小图片在大图片上的位置。
|
||||||
|
g.drawImage(image, (bufImg.getWidth()-360)/2, 320, null);
|
||||||
|
// 设置字体,样式,字体大小
|
||||||
|
// g.setFont(new Font("TimesRoman", Font.BOLD, 40));
|
||||||
|
g.setFont(chineseFont());
|
||||||
|
//设置颜色。
|
||||||
|
g.setColor(Color.BLACK);
|
||||||
|
|
||||||
|
// 查询当前店铺信息
|
||||||
|
if (ObjectUtils.isNotEmpty(storeId)){
|
||||||
|
LJStore store = storeService.selectStoreByStoreId(storeId);
|
||||||
|
// 查询加油员信息
|
||||||
|
LJStaff staff = null;
|
||||||
|
if (ObjectUtil.isNotEmpty(staffId)){
|
||||||
|
staff = staffService.selectStaffById(staffId);
|
||||||
|
}
|
||||||
|
LJStaff staff1 = staffService.selectStaffByStoreId(storeId);
|
||||||
|
|
||||||
|
// 店铺名称位置文字绘制到指定位置
|
||||||
|
g.drawString(store.getName(), returnX(g,bufImg.getWidth(),store.getName()), 300);
|
||||||
|
// 加油员姓名位置文字绘制到指定位置
|
||||||
|
if (ObjectUtil.isNotEmpty(staff)) {
|
||||||
|
g.drawString("加油员:"+staff.getRealName(), returnX(g, bufImg.getWidth(), "加油员:"+staff.getRealName()), 750);
|
||||||
|
}
|
||||||
|
// 站长名称位置文字绘制到指定位置
|
||||||
|
g.drawString("站长名称:"+staff1.getRealName(), returnX(g, bufImg.getWidth(), "站长名称:"+staff1.getRealName()), 810);
|
||||||
|
// 服务监督电话位置文字绘制到指定位置
|
||||||
|
g.drawString("服务监督电话:"+staff1.getMobile(), returnX(g, bufImg.getWidth(), "服务监督电话:"+staff1.getMobile()), 870);
|
||||||
|
// 店铺地址位置文字绘制到指定位置
|
||||||
|
// g.drawString(store.getAddress(), returnX(g,bufImg.getWidth(),store.getAddress()), 900);
|
||||||
|
drawStringWithMultiLine(g,store.getAddress(), bufImg.getWidth()-20,20,940,10 );
|
||||||
|
}else {
|
||||||
|
drawStringWithMultiLine(g,"欢迎光临", bufImg.getWidth()-20,20,940,10 );
|
||||||
|
g.drawString("欢迎光临:", returnX(g, bufImg.getWidth(), "服务监督电话:"), 870);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// // 将码牌编号文字绘制到指定位置
|
// // 将码牌编号文字绘制到指定位置
|
||||||
// g.drawString(storeNumber, 200, 800);
|
// g.drawString(storeNumber, 200, 800);
|
||||||
g.dispose();
|
g.dispose();
|
||||||
@ -148,7 +230,7 @@ public class QrCodeUtils {
|
|||||||
g.setFont(chineseFont());
|
g.setFont(chineseFont());
|
||||||
//设置颜色。
|
//设置颜色。
|
||||||
g.setColor(Color.BLACK);
|
g.setColor(Color.BLACK);
|
||||||
g.drawString("SN:"+tagCodeSn, returnX(g, bufImg.getWidth(), "SN:"+tagCodeSn), 440);
|
g.drawString("ID:"+tagCodeSn, returnX(g, bufImg.getWidth(), "SN:"+tagCodeSn), 440);
|
||||||
g.dispose();
|
g.dispose();
|
||||||
// 输出图片
|
// 输出图片
|
||||||
String urlsss = "/temp/qrCode/";
|
String urlsss = "/temp/qrCode/";
|
||||||
|
@ -7,7 +7,6 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
import com.fuint.business.indexBanner.entity.IndexBanner;
|
import com.fuint.business.indexBanner.entity.IndexBanner;
|
||||||
import com.fuint.business.indexBanner.service.IndexBannerService;
|
import com.fuint.business.indexBanner.service.IndexBannerService;
|
||||||
import com.fuint.business.member.entity.LJStaff;
|
|
||||||
import com.fuint.business.member.utils.QrCodeUtils;
|
import com.fuint.business.member.utils.QrCodeUtils;
|
||||||
import com.fuint.business.storeInformation.entity.LJStore;
|
import com.fuint.business.storeInformation.entity.LJStore;
|
||||||
import com.fuint.business.storeInformation.entity.QRCode;
|
import com.fuint.business.storeInformation.entity.QRCode;
|
||||||
@ -63,7 +62,7 @@ public class QRCodeServiceImpl extends ServiceImpl<QRCodeMapper, QRCode> impleme
|
|||||||
if (type.equals("0")){
|
if (type.equals("0")){
|
||||||
backgroundImage = "static/qrCodeImg/laigeyouhui_bg.jpg";
|
backgroundImage = "static/qrCodeImg/laigeyouhui_bg.jpg";
|
||||||
}else {
|
}else {
|
||||||
backgroundImage = "static/qrCodeImg/laigeyouhui_bg1.png";
|
backgroundImage = "static/qrCodeImg/laigeyouhui_bg2.png";
|
||||||
}
|
}
|
||||||
|
|
||||||
String logoImage = "static/qrCodeImg/logo.png";
|
String logoImage = "static/qrCodeImg/logo.png";
|
||||||
|
Loading…
Reference in New Issue
Block a user