|
@ -3,8 +3,11 @@ package com.yihu.wlyy.web.doctor.health;
|
|
|
import java.util.*;
|
|
|
|
|
|
import com.yihu.wlyy.entity.education.*;
|
|
|
import com.yihu.wlyy.entity.patient.Patient;
|
|
|
import com.yihu.wlyy.service.app.health.*;
|
|
|
import com.yihu.wlyy.service.app.label.SignPatientLabelInfoService;
|
|
|
import com.yihu.wlyy.service.common.account.PatientService;
|
|
|
import com.yihu.wlyy.web.WeixinBaseController;
|
|
|
import io.swagger.annotations.Api;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.htmlparser.Parser;
|
|
@ -37,7 +40,7 @@ import com.yihu.wlyy.web.BaseController;
|
|
|
@Controller
|
|
|
@RequestMapping(value = "/doctor/health/edu", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
|
|
|
@Api(description = "健康教育")
|
|
|
public class DoctorHealthEduArticleController extends BaseController {
|
|
|
public class DoctorHealthEduArticleController extends WeixinBaseController {
|
|
|
|
|
|
@Autowired
|
|
|
private HealthEduArticleService healthEduArticleService;
|
|
@ -57,6 +60,9 @@ public class DoctorHealthEduArticleController extends BaseController {
|
|
|
|
|
|
@Autowired
|
|
|
private HealthEduArticleLabelService healthEduArticleLabelService;
|
|
|
|
|
|
@Autowired
|
|
|
private PatientService patientService;
|
|
|
/**
|
|
|
* 查询
|
|
|
* @param pagesize 分页大小
|
|
@ -263,8 +269,11 @@ public class DoctorHealthEduArticleController extends BaseController {
|
|
|
}
|
|
|
// 查询医生信息
|
|
|
Doctor doctor = doctorService.findDoctorByCode(getUID());
|
|
|
String msgHead = doctor.getName()+"医生给您发来了一篇患教文章";
|
|
|
String endMsg = "为了您的健康,"+doctor.getName()+"医生给您发送了一篇患教文章,请仔细查阅,如有问题,可随时咨询医生。";
|
|
|
JSONArray messages = new JSONArray();
|
|
|
for (String p : patientSet) {
|
|
|
Patient patientTemp = patientService.findByCode(p);
|
|
|
for (String a : articles) {
|
|
|
// 查询文章信息
|
|
|
HealthEduArticle temp = maps.get(a);
|
|
@ -294,14 +303,18 @@ public class DoctorHealthEduArticleController extends BaseController {
|
|
|
// 设置为示读
|
|
|
heap.setRead(1);
|
|
|
list.add(heap);
|
|
|
if (StringUtils.isNotEmpty(patientTemp.getOpenid())) {
|
|
|
// 推送消息给微信端
|
|
|
JSONObject json = new JSONObject();
|
|
|
json.put("first",msgHead);
|
|
|
json.put("article",temp.getId()+"");
|
|
|
json.put("title",temp.getTitle());
|
|
|
json.put("doctorName",doctor.getName());
|
|
|
json.put("date", DateUtil.dateToStrLong(DateUtil.getNowDate()));
|
|
|
json.put("remark", endMsg);
|
|
|
PushMsgTask.getInstance().putWxMsg(getAccessToken(), 9, patientTemp.getOpenid(), patientTemp.getName(), json);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
JSONObject message = new JSONObject();
|
|
|
message.put("receiver", p);
|
|
|
message.put("type", MessageType.MESSAGE_TYPE_PATIENT_HEALTH_EDU.P_HE_01.name());
|
|
|
message.put("title", MessageType.MESSAGE_TYPE_PATIENT_HEALTH_EDU.健康教育.name());
|
|
|
message.put("msg", MessageType.MESSAGE_TYPE_PATIENT_HEALTH_EDU.您有新的健康教育.name());
|
|
|
messages.put(message);
|
|
|
}
|
|
|
// 保存到数据库
|
|
|
int row = healthEduArticleService.send(list);
|
|
@ -375,6 +388,7 @@ public class DoctorHealthEduArticleController extends BaseController {
|
|
|
}
|
|
|
|
|
|
private String parsrHtml(String html) {
|
|
|
html =("<span>"+html+"</span>");//拼接一个HTML标签,防止纯文字字符串转换在linux下面出现的异常。
|
|
|
Parser parser = null;
|
|
|
try{
|
|
|
parser = new Parser(html);
|
|
@ -386,4 +400,7 @@ public class DoctorHealthEduArticleController extends BaseController {
|
|
|
}
|
|
|
|
|
|
}
|
|
|
public static void main(String arg[]){
|
|
|
System.out.println(MessageType.MESSAGE_TYPE_PATIENT_HEALTH_EDU.P_HE_01.name());
|
|
|
}
|
|
|
}
|