|
@ -9,6 +9,7 @@ import com.yihu.wlyy.util.CommonUtil;
|
|
|
import com.yihu.wlyy.util.DateUtil;
|
|
|
import com.yihu.wlyy.web.WeixinBaseController;
|
|
|
import io.swagger.annotations.Api;
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.json.JSONArray;
|
|
|
import org.json.JSONObject;
|
|
@ -25,271 +26,274 @@ import java.util.Date;
|
|
|
|
|
|
/**
|
|
|
* 患者端:图文咨询/公共咨询/病友圈控制类
|
|
|
*
|
|
|
* @author George
|
|
|
*
|
|
|
* @author George
|
|
|
*/
|
|
|
@Controller
|
|
|
@RequestMapping(value = "/patient/consult/public", produces = MediaType.APPLICATION_JSON_UTF8_VALUE,method = {RequestMethod.GET,RequestMethod.POST})
|
|
|
@RequestMapping(value = "/patient/consult/public", produces = MediaType.APPLICATION_JSON_UTF8_VALUE, method = {RequestMethod.GET, RequestMethod.POST})
|
|
|
@Api(description = "图文咨询,公共咨询,病友圈")
|
|
|
public class ConsultPublicController extends WeixinBaseController {
|
|
|
|
|
|
@Autowired
|
|
|
private ConsultPublicService consultPublicService;
|
|
|
@Autowired
|
|
|
private ConsultPublicService consultPublicService;
|
|
|
|
|
|
@Autowired
|
|
|
private PatientInfoService patientInfoService;
|
|
|
@Autowired
|
|
|
private CommonUtil CommonUtil;
|
|
|
@Autowired
|
|
|
private PatientInfoService patientInfoService;
|
|
|
@Autowired
|
|
|
private CommonUtil CommonUtil;
|
|
|
|
|
|
/**
|
|
|
* 添加公共咨询
|
|
|
*
|
|
|
* @param question 问题
|
|
|
* @param content 问题描述
|
|
|
* @param when 发病时间(如:1小时前)
|
|
|
* @param images 图片标识,多图以逗号分隔
|
|
|
* @param images 图片URL,多图以逗号分隔
|
|
|
* @param disease 疾病类型标识
|
|
|
* @param diseaseName 疾病类型名称
|
|
|
* @return
|
|
|
*/
|
|
|
@RequestMapping(value = "add")
|
|
|
@ResponseBody
|
|
|
public String add(
|
|
|
String question,
|
|
|
String content,
|
|
|
String when,
|
|
|
@RequestParam(required = false) String images,
|
|
|
@RequestParam(required = false) String disease,
|
|
|
@RequestParam(required = false) String diseaseName) {
|
|
|
try {
|
|
|
ConsultPublic cp = new ConsultPublic();
|
|
|
// 回复数默认为0
|
|
|
cp.setAmount(0);
|
|
|
// 设置问题描述
|
|
|
cp.setContent(content);
|
|
|
// 设置图片URL
|
|
|
if (StringUtils.isEmpty(images)) {
|
|
|
images = fetchWxImages();
|
|
|
}
|
|
|
if (StringUtils.isNotEmpty(images)) {
|
|
|
images = CommonUtil.copyTempImage(images);
|
|
|
}
|
|
|
cp.setImages(images);
|
|
|
// 设置患者标识
|
|
|
cp.setPatient(getRepUID());
|
|
|
/**
|
|
|
* 添加公共咨询
|
|
|
*
|
|
|
* @param question 问题
|
|
|
* @param content 问题描述
|
|
|
* @param when 发病时间(如:1小时前)
|
|
|
* @param images 图片标识,多图以逗号分隔
|
|
|
* @param images 图片URL,多图以逗号分隔
|
|
|
* @param disease 疾病类型标识
|
|
|
* @param diseaseName 疾病类型名称
|
|
|
* @return
|
|
|
*/
|
|
|
@RequestMapping(value = "add")
|
|
|
@ResponseBody
|
|
|
@ApiOperation("添加公共咨询")
|
|
|
public String add(
|
|
|
String question,
|
|
|
String content,
|
|
|
String when,
|
|
|
@RequestParam(required = false) String images,
|
|
|
@RequestParam(required = false) String disease,
|
|
|
@RequestParam(required = false) String diseaseName) {
|
|
|
try {
|
|
|
ConsultPublic cp = new ConsultPublic();
|
|
|
// 回复数默认为0
|
|
|
cp.setAmount(0);
|
|
|
// 设置问题描述
|
|
|
cp.setContent(content);
|
|
|
// 设置图片URL
|
|
|
if (StringUtils.isEmpty(images)) {
|
|
|
images = fetchWxImages();
|
|
|
}
|
|
|
if (StringUtils.isNotEmpty(images)) {
|
|
|
images = CommonUtil.copyTempImage(images);
|
|
|
}
|
|
|
cp.setImages(images);
|
|
|
// 设置患者标识
|
|
|
cp.setPatient(getRepUID());
|
|
|
// cp.setPatient(getUID());
|
|
|
// Patient patient=patientInfoService.findByCode(getUID());
|
|
|
Patient patient=patientInfoService.findByCode(getRepUID());
|
|
|
cp.setSex(patient.getSex());
|
|
|
// 设置问题标题
|
|
|
cp.setTitle(question);
|
|
|
// 未读数量默认为0
|
|
|
cp.setUnread(0);
|
|
|
// 设置发病时间
|
|
|
cp.setWhen(when);
|
|
|
// 设置疾病类型
|
|
|
cp.setDisease(disease);
|
|
|
// 设置疾病类型名称
|
|
|
cp.setDiseaseName(diseaseName);
|
|
|
// 保存到数据库
|
|
|
ConsultPublic temp = consultPublicService.addConsult(cp);
|
|
|
if (temp == null) {
|
|
|
return error(-1, "保存失败!");
|
|
|
}
|
|
|
return success("保存成功!");
|
|
|
} catch (Exception e) {
|
|
|
error(e);
|
|
|
return error(-1, "保存失败!");
|
|
|
}
|
|
|
}
|
|
|
Patient patient = patientInfoService.findByCode(getRepUID());
|
|
|
cp.setSex(patient.getSex());
|
|
|
// 设置问题标题
|
|
|
cp.setTitle(question);
|
|
|
// 未读数量默认为0
|
|
|
cp.setUnread(0);
|
|
|
// 设置发病时间
|
|
|
cp.setWhen(when);
|
|
|
// 设置疾病类型
|
|
|
cp.setDisease(disease);
|
|
|
// 设置疾病类型名称
|
|
|
cp.setDiseaseName(diseaseName);
|
|
|
// 保存到数据库
|
|
|
ConsultPublic temp = consultPublicService.addConsult(cp);
|
|
|
if (temp == null) {
|
|
|
return error(-1, "保存失败!");
|
|
|
}
|
|
|
return success("保存成功!");
|
|
|
} catch (Exception e) {
|
|
|
error(e);
|
|
|
return error(-1, "保存失败!");
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 查询患者公共咨询记录
|
|
|
*
|
|
|
* @param pagesize 分页大小
|
|
|
* @return
|
|
|
*/
|
|
|
@RequestMapping(value = "list")
|
|
|
@ResponseBody
|
|
|
public String list(long id, int pagesize, @RequestParam(required = false) String disease) {
|
|
|
try {
|
|
|
JSONArray list = new JSONArray();
|
|
|
Page<ConsultPublic> datas = consultPublicService.findPublicQuestionByPatient(getRepUID(), disease, id, pagesize);
|
|
|
/**
|
|
|
* 查询患者公共咨询记录
|
|
|
*
|
|
|
* @param pagesize 分页大小
|
|
|
* @return
|
|
|
*/
|
|
|
@RequestMapping(value = "list")
|
|
|
@ResponseBody
|
|
|
@ApiOperation("查询患者公共咨询记录")
|
|
|
public String list(long id, int pagesize, @RequestParam(required = false) String disease) {
|
|
|
try {
|
|
|
JSONArray list = new JSONArray();
|
|
|
Page<ConsultPublic> datas = consultPublicService.findPublicQuestionByPatient(getRepUID(), disease, id, pagesize);
|
|
|
// Page<ConsultPublic> datas = consultPublicService.findPublicQuestionByPatient(getUID(), disease, id, pagesize);
|
|
|
if (datas != null) {
|
|
|
for (ConsultPublic cp : datas) {
|
|
|
if (cp == null) {
|
|
|
continue;
|
|
|
}
|
|
|
JSONObject json = new JSONObject();
|
|
|
json.put("id", cp.getId());
|
|
|
// 设置问题标识
|
|
|
json.put("consult", cp.getConsult());
|
|
|
// 设置患者姓名
|
|
|
json.put("name", cp.getName());
|
|
|
// 设置患者头像
|
|
|
json.put("photo", cp.getPhoto());
|
|
|
// 设置问题标题
|
|
|
json.put("title", cp.getTitle());
|
|
|
// 设置问题描述
|
|
|
json.put("content", cp.getContent());
|
|
|
// 设置发病时间
|
|
|
json.put("when", cp.getWhen());
|
|
|
// 设置疾病标识
|
|
|
json.put("disease", cp.getDisease());
|
|
|
// 设置性别
|
|
|
json.put("sex", cp.getSex());
|
|
|
// 设置疾病名称
|
|
|
json.put("diseaseName", cp.getDiseaseName());
|
|
|
// 设置是否包含图片
|
|
|
json.put("hasImg", StringUtils.isNoneEmpty(cp.getImages()));
|
|
|
// 设置回复总数
|
|
|
json.put("amount", cp.getAmount());
|
|
|
// 咨询时间
|
|
|
json.put("czrq",cp.getCzrq());
|
|
|
if (datas != null) {
|
|
|
for (ConsultPublic cp : datas) {
|
|
|
if (cp == null) {
|
|
|
continue;
|
|
|
}
|
|
|
JSONObject json = new JSONObject();
|
|
|
json.put("id", cp.getId());
|
|
|
// 设置问题标识
|
|
|
json.put("consult", cp.getConsult());
|
|
|
// 设置患者姓名
|
|
|
json.put("name", cp.getName());
|
|
|
// 设置患者头像
|
|
|
json.put("photo", cp.getPhoto());
|
|
|
// 设置问题标题
|
|
|
json.put("title", cp.getTitle());
|
|
|
// 设置问题描述
|
|
|
json.put("content", cp.getContent());
|
|
|
// 设置发病时间
|
|
|
json.put("when", cp.getWhen());
|
|
|
// 设置疾病标识
|
|
|
json.put("disease", cp.getDisease());
|
|
|
// 设置性别
|
|
|
json.put("sex", cp.getSex());
|
|
|
// 设置疾病名称
|
|
|
json.put("diseaseName", cp.getDiseaseName());
|
|
|
// 设置是否包含图片
|
|
|
json.put("hasImg", StringUtils.isNoneEmpty(cp.getImages()));
|
|
|
// 设置回复总数
|
|
|
json.put("amount", cp.getAmount());
|
|
|
// 咨询时间
|
|
|
json.put("czrq", cp.getCzrq());
|
|
|
|
|
|
list.put(json);
|
|
|
}
|
|
|
}
|
|
|
return write(200, "查询成功!", "list", datas, list);
|
|
|
} catch (Exception e) {
|
|
|
error(e);
|
|
|
return error(-1, "查询失败!");
|
|
|
}
|
|
|
}
|
|
|
list.put(json);
|
|
|
}
|
|
|
}
|
|
|
return write(200, "查询成功!", "list", datas, list);
|
|
|
} catch (Exception e) {
|
|
|
error(e);
|
|
|
return error(-1, "查询失败!");
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 回复公共咨询
|
|
|
* @param consult 咨询标识
|
|
|
* @param content 回复内容
|
|
|
* @param images 回复图片,多图以逗号分隔
|
|
|
* @return
|
|
|
*/
|
|
|
@RequestMapping(value = "reply")
|
|
|
@ResponseBody
|
|
|
public String reply(String consult, String content, @RequestParam(required = false) String images) {
|
|
|
try {
|
|
|
ConsultPublicReply reply = new ConsultPublicReply();
|
|
|
reply.setConsult(consult);
|
|
|
reply.setContent(content);
|
|
|
reply.setCzrq(new Date());
|
|
|
reply.setDel("1");
|
|
|
// 设置图片URL
|
|
|
if (StringUtils.isEmpty(images)) {
|
|
|
images = fetchWxImages();
|
|
|
}
|
|
|
if (StringUtils.isNotEmpty(images)) {
|
|
|
images = CommonUtil.copyTempImage(images);
|
|
|
}
|
|
|
reply.setImages(images);
|
|
|
/**
|
|
|
* 回复公共咨询
|
|
|
*
|
|
|
* @param consult 咨询标识
|
|
|
* @param content 回复内容
|
|
|
* @param images 回复图片,多图以逗号分隔
|
|
|
* @return
|
|
|
*/
|
|
|
@RequestMapping(value = "reply")
|
|
|
@ResponseBody
|
|
|
@ApiOperation("回复公共咨询")
|
|
|
public String reply(String consult, String content, @RequestParam(required = false) String images) {
|
|
|
try {
|
|
|
ConsultPublicReply reply = new ConsultPublicReply();
|
|
|
reply.setConsult(consult);
|
|
|
reply.setContent(content);
|
|
|
reply.setCzrq(new Date());
|
|
|
reply.setDel("1");
|
|
|
// 设置图片URL
|
|
|
if (StringUtils.isEmpty(images)) {
|
|
|
images = fetchWxImages();
|
|
|
}
|
|
|
if (StringUtils.isNotEmpty(images)) {
|
|
|
images = CommonUtil.copyTempImage(images);
|
|
|
}
|
|
|
reply.setImages(images);
|
|
|
// reply.setPatient(getUID());
|
|
|
// Patient patient=patientInfoService.findByCode(getUID());
|
|
|
reply.setPatient(getRepUID());
|
|
|
Patient patient=patientInfoService.findByCode(getRepUID());
|
|
|
reply.setSex(patient.getSex());
|
|
|
ConsultPublicReply temp = consultPublicService.addPatientReply(reply);
|
|
|
if (temp == null) {
|
|
|
return error(-1, "回复失败!");
|
|
|
}
|
|
|
return success("回复成功!");
|
|
|
} catch (Exception e) {
|
|
|
error(e);
|
|
|
return error(-1, "回复失败!");
|
|
|
}
|
|
|
}
|
|
|
reply.setPatient(getRepUID());
|
|
|
Patient patient = patientInfoService.findByCode(getRepUID());
|
|
|
reply.setSex(patient.getSex());
|
|
|
ConsultPublicReply temp = consultPublicService.addPatientReply(reply);
|
|
|
if (temp == null) {
|
|
|
return error(-1, "回复失败!");
|
|
|
}
|
|
|
return success("回复成功!");
|
|
|
} catch (Exception e) {
|
|
|
error(e);
|
|
|
return error(-1, "回复失败!");
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 查询公共咨询的回复列表
|
|
|
*
|
|
|
* @param consult
|
|
|
* 咨询标识
|
|
|
* @param pagesize
|
|
|
* 分页大小
|
|
|
* @return
|
|
|
*/
|
|
|
@RequestMapping(value = "reply_list")
|
|
|
@ResponseBody
|
|
|
public String replyList(String consult, long id, int pagesize) {
|
|
|
try {
|
|
|
JSONArray list = new JSONArray();
|
|
|
Page<ConsultPublicReply> datas = consultPublicService.findReplyListByConsult(consult, id, pagesize);
|
|
|
if (datas != null) {
|
|
|
for (ConsultPublicReply cpr : datas) {
|
|
|
if (cpr == null) {
|
|
|
continue;
|
|
|
}
|
|
|
JSONObject json = new JSONObject();
|
|
|
// 设置回复标识
|
|
|
json.put("id", cpr.getId());
|
|
|
// 设置回复者姓名
|
|
|
json.put("name", cpr.getName());
|
|
|
// 设置回复者头像
|
|
|
json.put("photo", cpr.getPhoto());
|
|
|
// 设置回复内容
|
|
|
json.put("content", cpr.getContent());
|
|
|
// 设置回复图片
|
|
|
json.put("images", cpr.getImages());
|
|
|
// 设置回复时间
|
|
|
json.put("czrq", DateUtil.dateToStrLong(cpr.getCzrq()));
|
|
|
list.put(json);
|
|
|
}
|
|
|
}
|
|
|
if (id <= 0) {
|
|
|
ConsultPublic temp = consultPublicService.findByConsult(consult);
|
|
|
/**
|
|
|
* 查询公共咨询的回复列表
|
|
|
*
|
|
|
* @param consult 咨询标识
|
|
|
* @param pagesize 分页大小
|
|
|
* @return
|
|
|
*/
|
|
|
@RequestMapping(value = "reply_list")
|
|
|
@ResponseBody
|
|
|
@ApiOperation("查询公共咨询的回复列表")
|
|
|
public String replyList(String consult, long id, int pagesize) {
|
|
|
try {
|
|
|
JSONArray list = new JSONArray();
|
|
|
Page<ConsultPublicReply> datas = consultPublicService.findReplyListByConsult(consult, id, pagesize);
|
|
|
if (datas != null) {
|
|
|
for (ConsultPublicReply cpr : datas) {
|
|
|
if (cpr == null) {
|
|
|
continue;
|
|
|
}
|
|
|
JSONObject json = new JSONObject();
|
|
|
// 设置回复标识
|
|
|
json.put("id", cpr.getId());
|
|
|
// 设置回复者姓名
|
|
|
json.put("name", cpr.getName());
|
|
|
// 设置回复者头像
|
|
|
json.put("photo", cpr.getPhoto());
|
|
|
// 设置回复内容
|
|
|
json.put("content", cpr.getContent());
|
|
|
// 设置回复图片
|
|
|
json.put("images", cpr.getImages());
|
|
|
// 设置回复时间
|
|
|
json.put("czrq", DateUtil.dateToStrLong(cpr.getCzrq()));
|
|
|
list.put(json);
|
|
|
}
|
|
|
}
|
|
|
if (id <= 0) {
|
|
|
ConsultPublic temp = consultPublicService.findByConsult(consult);
|
|
|
// if (temp != null && StringUtils.equals(temp.getPatient(), getUID())) {
|
|
|
if (temp != null && StringUtils.equals(temp.getPatient(), getRepUID())) {
|
|
|
// 自己的帖子,清空未读数量
|
|
|
consultPublicService.clearUnread(consult);
|
|
|
}
|
|
|
}
|
|
|
return write(200, "查询成功!", "list", datas, list);
|
|
|
} catch (Exception e) {
|
|
|
error(e);
|
|
|
return error(-1, "查询失败!");
|
|
|
}
|
|
|
}
|
|
|
if (temp != null && StringUtils.equals(temp.getPatient(), getRepUID())) {
|
|
|
// 自己的帖子,清空未读数量
|
|
|
consultPublicService.clearUnread(consult);
|
|
|
}
|
|
|
}
|
|
|
return write(200, "查询成功!", "list", datas, list);
|
|
|
} catch (Exception e) {
|
|
|
error(e);
|
|
|
return error(-1, "查询失败!");
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 查询公共咨询详细信息
|
|
|
*
|
|
|
* @param consult
|
|
|
* @return
|
|
|
*/
|
|
|
@RequestMapping(value = "info")
|
|
|
@ResponseBody
|
|
|
public String info(String consult) {
|
|
|
try {
|
|
|
JSONObject json = new JSONObject();
|
|
|
ConsultPublic cp = consultPublicService.findByConsult(consult);
|
|
|
if (cp != null) {
|
|
|
// 设置咨询标识
|
|
|
json.put("consult", cp.getConsult());
|
|
|
// 设置姓名
|
|
|
json.put("name", cp.getName());
|
|
|
// 设置头像
|
|
|
json.put("photo", cp.getPhoto());
|
|
|
// 设置问题
|
|
|
json.put("question", cp.getTitle());
|
|
|
// 设置问题描述
|
|
|
json.put("content", cp.getContent());
|
|
|
// 设置发病时间
|
|
|
json.put("when", cp.getWhen());
|
|
|
// 设置回复图片
|
|
|
json.put("images", cp.getImages());
|
|
|
// 设置疾病标识
|
|
|
json.put("disease", cp.getDisease());
|
|
|
// 设置疾病名称
|
|
|
json.put("diseaseName", cp.getDiseaseName());
|
|
|
// 设置回复时间
|
|
|
json.put("czrq", DateUtil.dateToStrLong(cp.getCzrq()));
|
|
|
}
|
|
|
return write(200, "查询成功!", "data", json);
|
|
|
} catch (Exception e) {
|
|
|
error(e);
|
|
|
return error(-1, "查询失败!");
|
|
|
}
|
|
|
}
|
|
|
/**
|
|
|
* 查询公共咨询详细信息
|
|
|
*
|
|
|
* @param consult
|
|
|
* @return
|
|
|
*/
|
|
|
@RequestMapping(value = "info")
|
|
|
@ResponseBody
|
|
|
@ApiOperation("查询公共咨询详细信息")
|
|
|
public String info(String consult) {
|
|
|
try {
|
|
|
JSONObject json = new JSONObject();
|
|
|
ConsultPublic cp = consultPublicService.findByConsult(consult);
|
|
|
if (cp != null) {
|
|
|
// 设置咨询标识
|
|
|
json.put("consult", cp.getConsult());
|
|
|
// 设置姓名
|
|
|
json.put("name", cp.getName());
|
|
|
// 设置头像
|
|
|
json.put("photo", cp.getPhoto());
|
|
|
// 设置问题
|
|
|
json.put("question", cp.getTitle());
|
|
|
// 设置问题描述
|
|
|
json.put("content", cp.getContent());
|
|
|
// 设置发病时间
|
|
|
json.put("when", cp.getWhen());
|
|
|
// 设置回复图片
|
|
|
json.put("images", cp.getImages());
|
|
|
// 设置疾病标识
|
|
|
json.put("disease", cp.getDisease());
|
|
|
// 设置疾病名称
|
|
|
json.put("diseaseName", cp.getDiseaseName());
|
|
|
// 设置回复时间
|
|
|
json.put("czrq", DateUtil.dateToStrLong(cp.getCzrq()));
|
|
|
}
|
|
|
return write(200, "查询成功!", "data", json);
|
|
|
} catch (Exception e) {
|
|
|
error(e);
|
|
|
return error(-1, "查询失败!");
|
|
|
}
|
|
|
}
|
|
|
|
|
|
}
|