Commit 2768cb98 by 王祖波

Merge branch 'feature-recommend2' into 'developer'

加载图片缓存统计

See merge request !2990
parents b4af00b3 3ac1b6a8
...@@ -114,7 +114,7 @@ public class ImageCombined { ...@@ -114,7 +114,7 @@ public class ImageCombined {
} }
public static void main(String[] args) throws Exception{ public static void main(String[] args) throws Exception{
BufferedImage largeImage = loadImageWithCache(LARGE_IMAGE_URL); BufferedImage largeImage = loadImageWithCache(LARGE_IMAGE_URL,"");
BufferedImage qrCodeImage = ImageIO.read(new URL(QR_CODE_URL)); BufferedImage qrCodeImage = ImageIO.read(new URL(QR_CODE_URL));
int showStyle = 0; int showStyle = 0;
...@@ -124,6 +124,7 @@ public class ImageCombined { ...@@ -124,6 +124,7 @@ public class ImageCombined {
} }
public static byte[] getCombinedImage(CombinedQDTO combinedQDTO) throws Exception{ public static byte[] getCombinedImage(CombinedQDTO combinedQDTO) throws Exception{
String enterpriseId = combinedQDTO.getEnterpriseId();
String imageUrl = combinedQDTO.getImageUrl(); String imageUrl = combinedQDTO.getImageUrl();
String qrCodeUrl = combinedQDTO.getQrCodeUrl(); String qrCodeUrl = combinedQDTO.getQrCodeUrl();
Integer showStyle = combinedQDTO.getShowStyle(); Integer showStyle = combinedQDTO.getShowStyle();
...@@ -136,7 +137,7 @@ public class ImageCombined { ...@@ -136,7 +137,7 @@ public class ImageCombined {
//压缩图片的参数 //压缩图片的参数
imageUrl = imageUrl + "?imageView2/2/w/1080/h/10800/format/jpg"; imageUrl = imageUrl + "?imageView2/2/w/1080/h/10800/format/jpg";
logger.info("加载要合成的图片开始1"); logger.info("加载要合成的图片开始1");
BufferedImage largeImage = loadImageWithCache(imageUrl); BufferedImage largeImage = loadImageWithCache(imageUrl,enterpriseId);
logger.info("加载要合成的图片开始2"); logger.info("加载要合成的图片开始2");
BufferedImage qrCodeImage = loadImageWithReader(qrCodeUrl); BufferedImage qrCodeImage = loadImageWithReader(qrCodeUrl);
logger.info("加载要合成的图片结束"); logger.info("加载要合成的图片结束");
...@@ -182,8 +183,8 @@ public class ImageCombined { ...@@ -182,8 +183,8 @@ public class ImageCombined {
/** /**
* 从缓存中加载图像 * 从缓存中加载图像
*/ */
private static BufferedImage loadImageWithCache(String url) { private static BufferedImage loadImageWithCache(String url,String enterpriseId) {
boolean useCache = ApolloUtils.combinedCache(); boolean useCache = ApolloUtils.combinedCache(enterpriseId);
if (!useCache) { if (!useCache) {
logger.info("非缓存加载图片:{}", url); logger.info("非缓存加载图片:{}", url);
return loadImageWithReader(url); return loadImageWithReader(url);
......
...@@ -69,13 +69,17 @@ public class ApolloUtils { ...@@ -69,13 +69,17 @@ public class ApolloUtils {
return Integer.parseInt(combinedFontsType); return Integer.parseInt(combinedFontsType);
} }
public static boolean combinedCache() { public static boolean combinedCache(String enterpriseId) {
Config config = ConfigService.getAppConfig(); Config config = ConfigService.getAppConfig();
String combinedCache = config.getProperty("combinedCache", ""); String combinedCache = config.getProperty("combinedCache", "");
if (StringUtils.isBlank(combinedCache)) { if (StringUtils.isBlank(combinedCache)) {
return false; return false;
} }
return true; String combinedCacheEid = config.getProperty("combinedCacheEid", "");
if (StringUtils.isBlank(combinedCacheEid)) {
return true;
}
return combinedCacheEid.contains(enterpriseId);
} }
/** /**
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment