|
@ -0,0 +1,113 @@
|
|
|
|
package com.yihu.wlyy.service.third.ylz;
|
|
|
|
|
|
|
|
import com.yihu.wlyy.entity.patient.Patient;
|
|
|
|
import com.yihu.wlyy.repository.patient.PatientDao;
|
|
|
|
import com.yihu.wlyy.service.BaseService;
|
|
|
|
import com.yihu.wlyy.task.PushMsgTask;
|
|
|
|
import com.yihu.wlyy.wechat.util.WeiXinAccessTokenUtils;
|
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
|
import org.json.JSONObject;
|
|
|
|
import org.slf4j.Logger;
|
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Created by Reece on 2017/9/20.
|
|
|
|
* 第三方消息功能
|
|
|
|
*/
|
|
|
|
@Service
|
|
|
|
public class ThirdMessageService extends BaseService {
|
|
|
|
|
|
|
|
private static Logger logger = LoggerFactory.getLogger(ThirdMessageService.class);
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
private WeiXinAccessTokenUtils accessTokenUtils;
|
|
|
|
@Autowired
|
|
|
|
private PushMsgTask pushMsgTask;
|
|
|
|
@Autowired
|
|
|
|
private PatientDao patientDao;
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 公众号消息推送接口
|
|
|
|
*/
|
|
|
|
public JSONObject pushMessage(int type, JSONObject json) throws Exception {
|
|
|
|
JSONObject response = new JSONObject();
|
|
|
|
response.put("ret_code", "0000");
|
|
|
|
response.put("ret_msg", "操作成功");
|
|
|
|
try {
|
|
|
|
String openId = json.has("openId") ? json.getString("openId") : null;
|
|
|
|
JSONObject messageContent = json.has("messageContent") ? json.getJSONObject("messageContent") : null;
|
|
|
|
String name = json.has("name") ? json.getString("name") : null;
|
|
|
|
if (StringUtils.isEmpty(openId)) {
|
|
|
|
response.put("ret_code", "0001");
|
|
|
|
response.put("ret_msg", "openId参数不能为空!");
|
|
|
|
return response;
|
|
|
|
}
|
|
|
|
if (messageContent == null) {
|
|
|
|
response.put("ret_code", "0002");
|
|
|
|
response.put("ret_msg", "messageContent参数不能为空!");
|
|
|
|
return response;
|
|
|
|
}
|
|
|
|
switch (type) {
|
|
|
|
case 0:
|
|
|
|
pushMsgTask.putWxMsg(accessTokenUtils.getAccessToken(), 18, openId, name, messageContent);
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
pushMsgTask.putWxMsg(accessTokenUtils.getAccessToken(), 18, openId, name, messageContent);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
} catch (Exception ex) {
|
|
|
|
ex.printStackTrace();
|
|
|
|
response.put("ret_code", "1000");
|
|
|
|
response.put("ret_msg", ex.getMessage());
|
|
|
|
}
|
|
|
|
return response;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 公众号消息推送接口
|
|
|
|
*/
|
|
|
|
public JSONObject physicalExamination(String idCard, String medicalNo, String medicalOrg, String medicalTime) throws Exception {
|
|
|
|
JSONObject response = new JSONObject();
|
|
|
|
response.put("ret_code", "0000");
|
|
|
|
response.put("ret_msg", "操作成功");
|
|
|
|
try {
|
|
|
|
if (StringUtils.isEmpty(idCard)) {
|
|
|
|
response.put("ret_code", "0001");
|
|
|
|
response.put("ret_msg", "身份证不能为空!");
|
|
|
|
}
|
|
|
|
Patient patient = patientDao.findByIdcard(idCard);
|
|
|
|
String name = patient.getName();
|
|
|
|
String mobile = patient.getMobile();
|
|
|
|
String openId = patient.getOpenid();
|
|
|
|
|
|
|
|
JSONObject model = new JSONObject();
|
|
|
|
String url = "jkda/html/jiankangtijianxiangqing.html?medicalNo=" + medicalNo;
|
|
|
|
model.put("remark", "您可以点击查看报告详情,或通过”健康档案—体检记录“入口查看");
|
|
|
|
model.put("first", "您好,您的体检报告已经生成");
|
|
|
|
model.put("url", url);
|
|
|
|
model.put("keyword1", name);
|
|
|
|
model.put("keyword2", StringUtils.isEmpty(mobile) ? "" : mobile);
|
|
|
|
model.put("keyword3", medicalNo);
|
|
|
|
model.put("keyword4", medicalOrg);
|
|
|
|
model.put("keyword5", medicalTime);
|
|
|
|
|
|
|
|
if (StringUtils.isNotEmpty(openId) && !"undefined".equals(openId)) {
|
|
|
|
pushMsgTask.putAgentWxMsg(patient.getCode(), 18, model);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
} catch (Exception ex) {
|
|
|
|
ex.printStackTrace();
|
|
|
|
response.put("ret_code", "1000");
|
|
|
|
response.put("ret_msg", ex.getMessage());
|
|
|
|
}
|
|
|
|
return response;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|