Browse Source

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

dev
管理员 6 years ago
parent
commit
16f2440a33
  1. 1
      esua-epdc/epdc-gateway/src/main/resources/application.yml
  2. 2
      esua-epdc/epdc-module/epdc-analysis/epdc-analysis-client/pom.xml
  3. 18
      esua-epdc/epdc-module/epdc-custom/epdc-custom-server/src/main/java/com/elink/esua/epdc/modules/epidemic/controller/EpidemicSentryPostController.java
  4. 14
      esua-epdc/epdc-module/epdc-custom/epdc-custom-server/src/main/java/com/elink/esua/epdc/modules/epidemic/service/EpidemicSentryPostService.java
  5. 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/**
- /oss/file/download
- /ws/**
- /custom/epidemicSentryPost/downloadQRCode/**
workLoginUrls:
- /api/work/user/getToken #工作端-获取token
- /api/work/user/login #工作端-登录

2
esua-epdc/epdc-module/epdc-analysis/epdc-analysis-client/pom.xml

@ -24,4 +24,4 @@
<finalName>${project.artifactId}</finalName>
</build>
</project>
</project>

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

File diff suppressed because one or more lines are too long

14
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 org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletResponse;
import java.util.List;
import java.util.Map;
@ -108,7 +109,7 @@ public interface EpidemicSentryPostService extends BaseService<EpidemicSentryPos
/**
* @Description: 哨卡名称查询(未绑定网格id的)
* @Param: []
* @return: com.elink.esua.epdc.commons.tools.utils.Result<java.util.List < java.util.Map < java.lang.String, java.lang.String>>>
* @return: com.elink.esua.epdc.commons.tools.utils.Result<java.util.List < java.util.Map < java.lang.String , java.lang.String>>>
* @Author: zy
* @Date: 2020-02-14
*/
@ -163,4 +164,15 @@ public interface EpidemicSentryPostService extends BaseService<EpidemicSentryPos
* @date 2020/2/16 17:03
*/
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.web.multipart.MultipartFile;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileInputStream;
import javax.servlet.http.HttpServletResponse;
import java.io.*;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLEncoder;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
@ -147,6 +149,39 @@ public class EpidemicSentryPostServiceImpl extends BaseServiceImpl<EpidemicSentr
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
public List<Map<String, String>> listSentryPostName() {
return baseDao.selectListSentryPostName();

Loading…
Cancel
Save