|
@ -3,14 +3,19 @@ package com.yihu.wlyy.web.common.qrcode;
|
|
import com.yihu.wlyy.entity.doctor.profile.Doctor;
|
|
import com.yihu.wlyy.entity.doctor.profile.Doctor;
|
|
import com.yihu.wlyy.service.common.QrcodeService;
|
|
import com.yihu.wlyy.service.common.QrcodeService;
|
|
import com.yihu.wlyy.service.common.account.DoctorService;
|
|
import com.yihu.wlyy.service.common.account.DoctorService;
|
|
|
|
import com.yihu.wlyy.task.PushMsgTask;
|
|
import com.yihu.wlyy.web.WeixinBaseController;
|
|
import com.yihu.wlyy.web.WeixinBaseController;
|
|
import io.swagger.annotations.Api;
|
|
import io.swagger.annotations.Api;
|
|
|
|
import io.swagger.annotations.ApiParam;
|
|
import org.apache.commons.lang3.StringUtils;
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
|
import org.slf4j.Logger;
|
|
|
|
import org.slf4j.LoggerFactory;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.http.MediaType;
|
|
import org.springframework.http.MediaType;
|
|
import org.springframework.stereotype.Controller;
|
|
import org.springframework.stereotype.Controller;
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
import org.springframework.web.bind.annotation.RequestMethod;
|
|
import org.springframework.web.bind.annotation.RequestMethod;
|
|
|
|
import org.springframework.web.bind.annotation.RequestParam;
|
|
import org.springframework.web.bind.annotation.ResponseBody;
|
|
import org.springframework.web.bind.annotation.ResponseBody;
|
|
|
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
import javax.servlet.http.HttpServletResponse;
|
|
@ -27,6 +32,7 @@ import java.io.OutputStream;
|
|
@Api(description = "二维码")
|
|
@Api(description = "二维码")
|
|
public class QrCodeController extends WeixinBaseController {
|
|
public class QrCodeController extends WeixinBaseController {
|
|
|
|
|
|
|
|
private static Logger logger = LoggerFactory.getLogger(QrCodeController.class);
|
|
@Autowired
|
|
@Autowired
|
|
private QrcodeService qrcodeService;
|
|
private QrcodeService qrcodeService;
|
|
@Autowired
|
|
@Autowired
|
|
@ -291,6 +297,54 @@ public class QrCodeController extends WeixinBaseController {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 下载某个医生的二维码
|
|
|
|
*
|
|
|
|
* @param doctor
|
|
|
|
* @param response
|
|
|
|
*/
|
|
|
|
@RequestMapping(value = "/specialist_img",method = {RequestMethod.GET,RequestMethod.POST})
|
|
|
|
public void downloadSpecialistImage(@ApiParam(name = "doctor", value = "医生id") @RequestParam(value = "doctor", required = true)String doctor,
|
|
|
|
@ApiParam(name = "teamCode", value = "团队id") @RequestParam(value = "teamCode", required = true)Long teamCode,
|
|
|
|
HttpServletResponse response) {
|
|
|
|
try {
|
|
|
|
logger.info("------------------specialist_img:" + doctor);
|
|
|
|
Doctor doc = doctorService.findDoctorByCode(doctor);
|
|
|
|
|
|
|
|
if (doc != null) {
|
|
|
|
if (StringUtils.isEmpty(doc.getQrcode())) {
|
|
|
|
qrcodeService.makeSpecialistQrcode(doc,teamCode, getAccessToken());
|
|
|
|
} else {
|
|
|
|
File file = new File(QrCodeController.class.getResource("/").getPath().replace("/WEB-INF/classes/", "") +
|
|
|
|
File.separator + "qrcode" + File.separator + doc.getQrcode());
|
|
|
|
if (!file.exists()) {
|
|
|
|
qrcodeService.makeSpecialistQrcode(doc,teamCode, getAccessToken());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
String path = request.getSession().getServletContext().getRealPath("/")
|
|
|
|
+ File.separator + "qrcode" + File.separator + doc.getQrcode();
|
|
|
|
InputStream inputStream = new FileInputStream(path);
|
|
|
|
response.setCharacterEncoding("utf-8");
|
|
|
|
response.setContentType("multipart/form-data");
|
|
|
|
response.setHeader("Content-Disposition", "attachment;fileName=" + doc.getQrcode());
|
|
|
|
OutputStream outputStream = response.getOutputStream();
|
|
|
|
byte[] b = new byte[2048];
|
|
|
|
int length = 0;
|
|
|
|
|
|
|
|
while ((length = inputStream.read(b)) > 0) {
|
|
|
|
outputStream.write(b, 0, length);
|
|
|
|
}
|
|
|
|
outputStream.flush();
|
|
|
|
outputStream.close();
|
|
|
|
inputStream.close();
|
|
|
|
} else {
|
|
|
|
throw new Exception("医生信息不存在!");
|
|
|
|
}
|
|
|
|
} catch (Exception e) {
|
|
|
|
response.setStatus(500);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
* 下载所有医生的二维码图片
|
|
* 下载所有医生的二维码图片
|
|
*
|
|
*
|