|
|
|
@ -19,18 +19,20 @@ package com.epmet.controller; |
|
|
|
|
|
|
|
import com.alibaba.fastjson.JSON; |
|
|
|
import com.epmet.commons.tools.annotation.LoginUser; |
|
|
|
import com.epmet.commons.tools.constant.StrConstant; |
|
|
|
import com.epmet.commons.tools.dto.result.OptionResultDTO; |
|
|
|
import com.epmet.commons.tools.enums.EnvEnum; |
|
|
|
import com.epmet.commons.tools.exception.EpmetErrorCode; |
|
|
|
import com.epmet.commons.tools.exception.EpmetException; |
|
|
|
import com.epmet.commons.tools.page.PageData; |
|
|
|
import com.epmet.commons.tools.security.dto.TokenDto; |
|
|
|
import com.epmet.commons.tools.utils.BarcodeUtils; |
|
|
|
import com.epmet.commons.tools.utils.Result; |
|
|
|
import com.epmet.commons.tools.validator.AssertUtils; |
|
|
|
import com.epmet.commons.tools.validator.ValidatorUtils; |
|
|
|
import com.epmet.commons.tools.validator.group.AddGroup; |
|
|
|
import com.epmet.commons.tools.validator.group.DefaultGroup; |
|
|
|
import com.epmet.commons.tools.validator.group.UpdateGroup; |
|
|
|
import com.epmet.constant.ImportErrorMsgConstants; |
|
|
|
import com.epmet.constants.ImportTaskConstants; |
|
|
|
import com.epmet.dto.IcNeighborHoodDTO; |
|
|
|
import com.epmet.dto.form.ImportInfoFormDTO; |
|
|
|
@ -43,8 +45,12 @@ import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.web.bind.annotation.*; |
|
|
|
import org.springframework.web.multipart.MultipartFile; |
|
|
|
|
|
|
|
import java.io.IOException; |
|
|
|
import java.io.InputStream; |
|
|
|
import javax.imageio.ImageIO; |
|
|
|
import javax.imageio.stream.ImageOutputStream; |
|
|
|
import javax.servlet.http.HttpServletResponse; |
|
|
|
import java.awt.image.BufferedImage; |
|
|
|
import java.io.*; |
|
|
|
import java.net.URLEncoder; |
|
|
|
import java.util.List; |
|
|
|
import java.util.Map; |
|
|
|
|
|
|
|
@ -165,4 +171,50 @@ public class IcNeighborHoodController { |
|
|
|
return new Result(); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* Desc: 根据房屋IDs查询房屋下是否有存在居民的 |
|
|
|
* @param id |
|
|
|
* @author zxc |
|
|
|
* @date 2022/3/2 10:32 上午 |
|
|
|
*/ |
|
|
|
@PostMapping("createQrCode/{id}") |
|
|
|
public void getExistUserByHouseIds(@LoginUser TokenDto tokenDto, @PathVariable("id") String id, HttpServletResponse response){ |
|
|
|
try { |
|
|
|
IcNeighborHoodDTO icNeighborHoodDTO = icNeighborHoodService.get(id); |
|
|
|
if (icNeighborHoodDTO == null){ |
|
|
|
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(),"小区信息不存在"); |
|
|
|
} |
|
|
|
String neighborhoodName = icNeighborHoodDTO.getNeighborHoodName(); |
|
|
|
//String url = "https://demo.tduckapp.com/s/7314b64b3a26455ab793fb8c640856b6?id="+id;
|
|
|
|
String url = EnvEnum.getCurrentEnv().getUrl().replace("api/",StrConstant.EPMETY_STR) |
|
|
|
.concat("epmet-oper-gov/#/") |
|
|
|
.concat(id) |
|
|
|
.concat(StrConstant.AND_MARK).concat("userId=").concat(tokenDto.getUserId()); |
|
|
|
BufferedImage image = BarcodeUtils.drawQRImage(neighborhoodName, url); |
|
|
|
//BufferedImage 转 InputStream
|
|
|
|
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(); |
|
|
|
ImageOutputStream imageOutput = ImageIO.createImageOutputStream(byteArrayOutputStream); |
|
|
|
ImageIO.write(image, "png", imageOutput); |
|
|
|
InputStream inputStream = new ByteArrayInputStream(byteArrayOutputStream.toByteArray()); |
|
|
|
long length = imageOutput.length(); |
|
|
|
String fileName = neighborhoodName+".png"; |
|
|
|
response.setContentType("application/octet-stream"); |
|
|
|
response.setContentLength((int)length); |
|
|
|
response.setHeader("Content-Disposition","attachment;filename="+ URLEncoder.encode(fileName, StrConstant.UTF_8)); |
|
|
|
|
|
|
|
//输出流
|
|
|
|
byte[] bytes = new byte[1024]; |
|
|
|
OutputStream outputStream = response.getOutputStream(); |
|
|
|
long count = 0; |
|
|
|
while(count < length){ |
|
|
|
int len = inputStream.read(bytes, 0, 1024); |
|
|
|
count +=len; |
|
|
|
outputStream.write(bytes, 0, len); |
|
|
|
} |
|
|
|
outputStream.flush(); |
|
|
|
} catch (Exception e) { |
|
|
|
e.printStackTrace(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|