Browse Source

添加根据哨卡ID获取哨卡小程序码的图片流的接口

dev
管理员 6 years ago
parent
commit
16f2440a33
  1. 1
      esua-epdc/epdc-gateway/src/main/resources/application.yml
  2. 16
      esua-epdc/epdc-module/epdc-custom/epdc-custom-server/src/main/java/com/elink/esua/epdc/modules/epidemic/controller/EpidemicSentryPostController.java
  3. 12
      esua-epdc/epdc-module/epdc-custom/epdc-custom-server/src/main/java/com/elink/esua/epdc/modules/epidemic/service/EpidemicSentryPostService.java
  4. 41
      esua-epdc/epdc-module/epdc-custom/epdc-custom-server/src/main/java/com/elink/esua/epdc/modules/epidemic/service/impl/EpidemicSentryPostServiceImpl.java

1
esua-epdc/epdc-gateway/src/main/resources/application.yml

@ -225,6 +225,7 @@ renren:
- /heart/** - /heart/**
- /oss/file/download - /oss/file/download
- /ws/** - /ws/**
- /custom/epidemicSentryPost/downloadQRCode/**
workLoginUrls: workLoginUrls:
- /api/work/user/getToken #工作端-获取token - /api/work/user/getToken #工作端-获取token
- /api/work/user/login #工作端-登录 - /api/work/user/login #工作端-登录

16
esua-epdc/epdc-module/epdc-custom/epdc-custom-server/src/main/java/com/elink/esua/epdc/modules/epidemic/controller/EpidemicSentryPostController.java

@ -164,7 +164,7 @@ public class EpidemicSentryPostController {
/** /**
* 生成哨卡单个小程序码 * 生成哨卡单个小程序码
* *
* @param [formDto] * @param formDto
* @return com.elink.esua.epdc.commons.tools.utils.Result * @return com.elink.esua.epdc.commons.tools.utils.Result
* @author wangtong * @author wangtong
* @date 2020/2/14 17:46 * @date 2020/2/14 17:46
@ -177,7 +177,7 @@ public class EpidemicSentryPostController {
/** /**
* 生成哨卡多个小程序码 * 生成哨卡多个小程序码
* *
* @param [formDto] * @param formDto
* @return com.elink.esua.epdc.commons.tools.utils.Result * @return com.elink.esua.epdc.commons.tools.utils.Result
* @author wangtong * @author wangtong
* @date 2020/2/14 17:46 * @date 2020/2/14 17:46
@ -187,4 +187,16 @@ public class EpidemicSentryPostController {
return this.epidemicSentryPostService.createPostsCodes(formDto); return this.epidemicSentryPostService.createPostsCodes(formDto);
} }
/**
* 下载小程序码
*
* @return com.elink.esua.epdc.commons.tools.utils.Result
* @author rongchao
* @date 2020/2/14 17:46
*/
@GetMapping("downloadQRCode/{postId}")
public void downloadQRCode(@PathVariable("postId") String postId, HttpServletResponse response) {
epidemicSentryPostService.downloadQRCode(postId, response);
}
} }

12
esua-epdc/epdc-module/epdc-custom/epdc-custom-server/src/main/java/com/elink/esua/epdc/modules/epidemic/service/EpidemicSentryPostService.java

@ -25,6 +25,7 @@ import com.elink.esua.epdc.dto.form.CreateCodeFormDTO;
import com.elink.esua.epdc.modules.epidemic.entity.EpidemicSentryPostEntity; import com.elink.esua.epdc.modules.epidemic.entity.EpidemicSentryPostEntity;
import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletResponse;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@ -163,4 +164,15 @@ public interface EpidemicSentryPostService extends BaseService<EpidemicSentryPos
* @date 2020/2/16 17:03 * @date 2020/2/16 17:03
*/ */
EpidemicSentryPostDTO selectOneByThirdSentryPostid(String thirdSentryPostid); EpidemicSentryPostDTO selectOneByThirdSentryPostid(String thirdSentryPostid);
/**
* 下载图片
*
* @param postId
* @param response
* @return com.elink.esua.epdc.dto.EpidemicSentryPostDTO
* @author rongchao
* @date 2020/2/16 17:03
*/
void downloadQRCode(String postId, HttpServletResponse response);
} }

41
esua-epdc/epdc-module/epdc-custom/epdc-custom-server/src/main/java/com/elink/esua/epdc/modules/epidemic/service/impl/EpidemicSentryPostServiceImpl.java

@ -47,9 +47,11 @@ import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartFile;
import java.io.ByteArrayOutputStream; import javax.servlet.http.HttpServletResponse;
import java.io.File; import java.io.*;
import java.io.FileInputStream; import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLEncoder;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.List; import java.util.List;
@ -147,6 +149,39 @@ public class EpidemicSentryPostServiceImpl extends BaseServiceImpl<EpidemicSentr
return ConvertUtils.sourceToTarget(baseDao.selectOne(wrapper), EpidemicSentryPostDTO.class); return ConvertUtils.sourceToTarget(baseDao.selectOne(wrapper), EpidemicSentryPostDTO.class);
} }
@Override
public void downloadQRCode(String postId, HttpServletResponse response) {
EpidemicSentryPostDTO dto = selectOneByThirdSentryPostid(postId);
URL url;
try {
String fileUrl = dto.getMaCodeUrl();
url = new URL(fileUrl);
DataInputStream dataInputStream = new DataInputStream(url.openStream());
if (null != dataInputStream) {
response.setHeader("Cache-Control", "No-Cache");
response.setContentType("image/jpeg");
byte[] buf = new byte[1024];
int L;
OutputStream toClient = new BufferedOutputStream(response.getOutputStream());
while ((L = dataInputStream.read(buf)) != NumConstant.ONE_NEG) {
toClient.write(buf, NumConstant.ZERO, L);
}
dataInputStream.close();
toClient.flush();
toClient.close();
}
} catch (MalformedURLException e) {
e.printStackTrace();
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
@Override @Override
public List<Map<String, String>> listSentryPostName() { public List<Map<String, String>> listSentryPostName() {
return baseDao.selectListSentryPostName(); return baseDao.selectListSentryPostName();

Loading…
Cancel
Save