|
@ -9,17 +9,21 @@ import com.yihu.jw.entity.base.im.ConsultTeamDo;
|
|
|
import com.yihu.jw.entity.base.im.ConsultTeamLogDo;
|
|
|
import com.yihu.jw.entity.base.patient.BasePatientDO;
|
|
|
import com.yihu.jw.entity.hospital.message.MessageNoticeSetting;
|
|
|
import com.yihu.jw.entity.util.SystemConfEntity;
|
|
|
import com.yihu.jw.hospital.module.consult.service.ConsultTeamService;
|
|
|
import com.yihu.jw.hospital.prescription.dao.PrescriptionDao;
|
|
|
import com.yihu.jw.hospital.task.PushMsgTask;
|
|
|
import com.yihu.jw.hospital.utils.CommonUtil;
|
|
|
import com.yihu.jw.hospital.utils.HttpUtil;
|
|
|
import com.yihu.jw.hospital.utils.WeiXinAccessTokenUtils;
|
|
|
import com.yihu.jw.im.dao.ConsultDao;
|
|
|
import com.yihu.jw.im.dao.ConsultTeamDao;
|
|
|
import com.yihu.jw.im.util.ImUtil;
|
|
|
import com.yihu.jw.im.util.ImageCompress;
|
|
|
import com.yihu.jw.message.service.MessageService;
|
|
|
import com.yihu.jw.patient.dao.BasePatientDao;
|
|
|
import com.yihu.jw.restmodel.web.endpoint.EnvelopRestEndpoint;
|
|
|
import com.yihu.jw.util.date.DateUtil;
|
|
|
import com.yihu.jw.util.http.HttpClientUtil;
|
|
|
import io.swagger.annotations.Api;
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
@ -38,9 +42,14 @@ import org.springframework.web.bind.annotation.RequestMethod;
|
|
|
import org.springframework.web.bind.annotation.RequestParam;
|
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
import java.io.File;
|
|
|
import java.io.FileOutputStream;
|
|
|
import java.io.IOException;
|
|
|
import java.io.InputStream;
|
|
|
import java.net.HttpURLConnection;
|
|
|
import java.net.URL;
|
|
|
import java.util.*;
|
|
|
|
|
|
/**
|
|
|
* 患者端:三师咨询控制类
|
|
@ -52,12 +61,13 @@ import java.util.Map;
|
|
|
@Api(description = "患者端-患者咨询")
|
|
|
public class ConsultController extends EnvelopRestEndpoint {
|
|
|
|
|
|
@Autowired
|
|
|
protected HttpServletRequest request;
|
|
|
|
|
|
@Autowired
|
|
|
private ConsultTeamService consultTeamService;
|
|
|
// @Autowired
|
|
|
// private DoctorCommentService doctorCommentService;
|
|
|
// @Autowired
|
|
|
// private DoctorStatisticsService doctorStatisticsService;
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
private BaseDoctorInfoService doctorService;
|
|
|
|
|
@ -69,29 +79,35 @@ public class ConsultController extends EnvelopRestEndpoint {
|
|
|
|
|
|
@Autowired
|
|
|
private CommonUtil CommonUtil;
|
|
|
|
|
|
@Autowired
|
|
|
private ImUtil imUtill;
|
|
|
|
|
|
@Autowired
|
|
|
private HttpUtil httpUtil;
|
|
|
private ConsultTeamDao consultTeamDao;
|
|
|
|
|
|
@Autowired
|
|
|
private PushMsgTask pushMsgTask;
|
|
|
private HttpClientUtil httpClientUtil;
|
|
|
|
|
|
@Autowired
|
|
|
private ConsultTeamDao consultTeamDao;
|
|
|
private MessageService messageService;
|
|
|
|
|
|
@Autowired
|
|
|
private PrescriptionDao prescriptionDao;
|
|
|
private JdbcTemplate jdbcTemplate;
|
|
|
|
|
|
@Autowired
|
|
|
private ConsultDao consultDao;
|
|
|
|
|
|
@Autowired
|
|
|
WeiXinAccessTokenUtils weiXinAccessTokenUtils;
|
|
|
|
|
|
@Value("${doctorAssistant.api}")
|
|
|
private String doctorAssistant;
|
|
|
|
|
|
@Value("${doctorAssistant.target_url}")
|
|
|
private String targetUrl;
|
|
|
@Autowired
|
|
|
private HttpClientUtil httpClientUtil;
|
|
|
@Autowired
|
|
|
private MessageService messageService;
|
|
|
@Autowired
|
|
|
private JdbcTemplate jdbcTemplate;
|
|
|
|
|
|
|
|
|
@Value("${im.data_base_name}")
|
|
|
private String im;
|
|
|
|
|
@ -100,8 +116,16 @@ public class ConsultController extends EnvelopRestEndpoint {
|
|
|
|
|
|
@Autowired
|
|
|
private RedisTemplate redisTemplate;
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
private HttpUtil httpUtil;
|
|
|
@Autowired
|
|
|
private PushMsgTask pushMsgTask;
|
|
|
@Autowired
|
|
|
private PrescriptionDao prescriptionDao;
|
|
|
// @Autowired
|
|
|
// private DoctorCommentService doctorCommentService;
|
|
|
// @Autowired
|
|
|
// private DoctorStatisticsService doctorStatisticsService;
|
|
|
// @Autowired
|
|
|
// private DoctorWorkTimeService doctorWorkTimeService;
|
|
|
// @Autowired
|
|
@ -113,6 +137,7 @@ public class ConsultController extends EnvelopRestEndpoint {
|
|
|
// @Autowired
|
|
|
// private WlyyDynamicMessagesDao dynamicMessagesDao;
|
|
|
|
|
|
|
|
|
// @ApiOperation("testRedis")
|
|
|
// @RequestMapping(value = "testRedis",method = RequestMethod.POST)
|
|
|
// public String testRedis(){
|
|
@ -1849,4 +1874,129 @@ public class ConsultController extends EnvelopRestEndpoint {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
/**
|
|
|
* 获取微信服务器图片
|
|
|
*
|
|
|
* @return
|
|
|
*/
|
|
|
public String fetchWxImages() {
|
|
|
String photos = "";
|
|
|
try {
|
|
|
String images = request.getParameter("mediaIds");
|
|
|
if (StringUtils.isEmpty(images)) {
|
|
|
return photos;
|
|
|
}
|
|
|
String[] mediaIds = images.split(",");
|
|
|
for (String mediaId : mediaIds) {
|
|
|
if (StringUtils.isEmpty(mediaId)) {
|
|
|
continue;
|
|
|
}
|
|
|
String temp = saveImageToDisk(mediaId);
|
|
|
if (StringUtils.isNotEmpty(temp)) {
|
|
|
if (photos.length() == 0) {
|
|
|
photos = temp;
|
|
|
} else {
|
|
|
photos += "," + temp;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
} catch (Exception e) {
|
|
|
error(e);
|
|
|
}
|
|
|
return photos;
|
|
|
}
|
|
|
|
|
|
|
|
|
/**
|
|
|
* 获取下载图片信息(jpg)
|
|
|
*
|
|
|
* @param mediaId 文件的id
|
|
|
* @throws Exception
|
|
|
*/
|
|
|
public String saveImageToDisk(String mediaId) throws Exception {
|
|
|
// 文件保存的临时路径
|
|
|
String tempPath = SystemConfEntity.getInstance().getTempPath() + File.separator;
|
|
|
// 拼接年月日路径
|
|
|
String datePath = DateUtil.getStringDate("yyyy") + File.separator + DateUtil.getStringDate("MM") + File.separator + DateUtil.getStringDate("dd") + File.separator;
|
|
|
// 重命名文件
|
|
|
String newFileName = DateUtil.dateToStr(new Date(), DateUtil.YYYYMMDDHHMMSS) + "_" + new Random().nextInt(1000) + ".png";
|
|
|
// 保存路径
|
|
|
File uploadFile = new File(tempPath + datePath + newFileName);
|
|
|
|
|
|
InputStream inputStream = null;
|
|
|
FileOutputStream fileOutputStream = null;
|
|
|
try {
|
|
|
if (!uploadFile.getParentFile().exists()) {
|
|
|
uploadFile.getParentFile().mkdirs();
|
|
|
}
|
|
|
inputStream = getInputStream(mediaId);
|
|
|
byte[] data = new byte[1024];
|
|
|
int len = 0;
|
|
|
fileOutputStream = new FileOutputStream(uploadFile);
|
|
|
while ((len = inputStream.read(data)) != -1) {
|
|
|
fileOutputStream.write(data, 0, len);
|
|
|
}
|
|
|
// 生成缩略图
|
|
|
ImageCompress.compress(uploadFile.getAbsolutePath(), uploadFile.getAbsolutePath() + "_small", 300, 300);
|
|
|
// 返回保存路径
|
|
|
return datePath + newFileName;
|
|
|
} catch (IOException e) {
|
|
|
e.printStackTrace();
|
|
|
} finally {
|
|
|
if (inputStream != null) {
|
|
|
try {
|
|
|
inputStream.close();
|
|
|
} catch (IOException e) {
|
|
|
e.printStackTrace();
|
|
|
}
|
|
|
}
|
|
|
if (fileOutputStream != null) {
|
|
|
try {
|
|
|
fileOutputStream.close();
|
|
|
} catch (IOException e) {
|
|
|
e.printStackTrace();
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
return null;
|
|
|
}
|
|
|
|
|
|
|
|
|
/**
|
|
|
* 下载多媒体文件(请注意,视频文件不支持下载,调用该接口需http协议)
|
|
|
*
|
|
|
* @return
|
|
|
*/
|
|
|
public InputStream getInputStream(String mediaId) {
|
|
|
String accessToken = getAccessToken();
|
|
|
InputStream is = null;
|
|
|
String url = "https://api.weixin.qq.com/cgi-bin/media/get?access_token=" + accessToken + "&media_id=" + mediaId;
|
|
|
try {
|
|
|
URL urlGet = new URL(url);
|
|
|
HttpURLConnection http = (HttpURLConnection) urlGet.openConnection();
|
|
|
http.setRequestMethod("GET"); // 必须是get方式请求
|
|
|
http.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
|
|
|
http.setDoOutput(true);
|
|
|
http.setDoInput(true);
|
|
|
System.setProperty("sun.net.client.defaultConnectTimeout", "30000");// 连接超时30秒
|
|
|
System.setProperty("sun.net.client.defaultReadTimeout", "30000"); // 读取超时30秒
|
|
|
http.connect();
|
|
|
// 获取文件转化为byte流
|
|
|
is = http.getInputStream();
|
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
}
|
|
|
return is;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 获取微信的access_token
|
|
|
*
|
|
|
* @return
|
|
|
*/
|
|
|
public String getAccessToken() {
|
|
|
return weiXinAccessTokenUtils.getAccessToken();
|
|
|
}
|
|
|
|
|
|
}
|