|
|
@ -442,15 +442,15 @@ public class HouseController implements ResultDataResolver { |
|
|
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "未查到房屋信息", "未查到房屋信息"); |
|
|
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "未查到房屋信息", "未查到房屋信息"); |
|
|
} |
|
|
} |
|
|
//url组成:小程序地址?房屋编码
|
|
|
//url组成:小程序地址?房屋编码
|
|
|
String url = HouseQrcodeEnum.PREFIX.getCode() + "?houseCode=" + house.getHouseCode(); |
|
|
String url = HouseQrcodeEnum.PREFIX.getCode() + house.getHouseCode(); |
|
|
BufferedImage image = BarcodeUtils.drawQRImage(house.getNeighborHoodName() + house.getBuildingName() + house.getUnitNum() + house.getDoorName(), url); |
|
|
BufferedImage image = BarcodeUtils.drawQRImage(house.getBuildingName() + house.getUnitNum() + house.getDoorName(), url); |
|
|
//BufferedImage 转 InputStream
|
|
|
//BufferedImage 转 InputStream
|
|
|
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(); |
|
|
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(); |
|
|
ImageOutputStream imageOutput = ImageIO.createImageOutputStream(byteArrayOutputStream); |
|
|
ImageOutputStream imageOutput = ImageIO.createImageOutputStream(byteArrayOutputStream); |
|
|
ImageIO.write(image, "png", imageOutput); |
|
|
ImageIO.write(image, "png", imageOutput); |
|
|
InputStream inputStream = new ByteArrayInputStream(byteArrayOutputStream.toByteArray()); |
|
|
InputStream inputStream = new ByteArrayInputStream(byteArrayOutputStream.toByteArray()); |
|
|
long length = imageOutput.length(); |
|
|
long length = imageOutput.length(); |
|
|
String fileName = house.getNeighborHoodName() + house.getBuildingName() + house.getUnitNum() + house.getDoorName() + ".png"; |
|
|
String fileName = house.getBuildingName() + house.getUnitNum() + house.getDoorName() + ".png"; |
|
|
response.setContentType("application/octet-stream"); |
|
|
response.setContentType("application/octet-stream"); |
|
|
response.setContentLength((int) length); |
|
|
response.setContentLength((int) length); |
|
|
response.setHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode(fileName, StrConstant.UTF_8)); |
|
|
response.setHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode(fileName, StrConstant.UTF_8)); |
|
|
|