|
@ -15,14 +15,18 @@ import com.yihu.wlyy.service.app.health.PatientHealthIndexService;
|
|
|
import com.yihu.wlyy.service.common.account.PatientService;
|
|
|
import com.yihu.wlyy.service.third.health.bank.CreditLogService;
|
|
|
import com.yihu.wlyy.task.PushMsgTask;
|
|
|
import com.yihu.wlyy.util.DateUtil;
|
|
|
import com.yihu.wlyy.util.HttpClientUtil;
|
|
|
import com.yihu.wlyy.web.BaseController;
|
|
|
import com.yihu.wlyy.web.doctor.device.DoctorDeviceController;
|
|
|
import com.yihu.wlyy.wechat.util.WeiXinAccessTokenUtils;
|
|
|
import io.swagger.annotations.Api;
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
import io.swagger.annotations.ApiParam;
|
|
|
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.beans.factory.annotation.Value;
|
|
|
import org.springframework.data.domain.Page;
|
|
@ -46,6 +50,7 @@ import java.util.Map;
|
|
|
@RequestMapping(value = "patient/device")
|
|
|
@Api(value = "患者设备管理", description = "患者设备管理")
|
|
|
public class PatientDeviceController extends BaseController {
|
|
|
private static Logger logger = LoggerFactory.getLogger(PatientDeviceController.class);
|
|
|
|
|
|
@Autowired
|
|
|
private PatientDeviceService patientDeviceService;
|
|
@ -222,8 +227,8 @@ public class PatientDeviceController extends BaseController {
|
|
|
if (deviceDetail!=null){
|
|
|
//修改设备表中{"1":"0", "2":"0"}的绑定次数 和其他绑定信息,
|
|
|
wlyyDeviceDetailService.updateAfterBinding(device.getDeviceSn(),device.getUserIdcard(),device.getUserType(),new Date(),flag);
|
|
|
Patient patient = patientService.findByCode(device.getUser());
|
|
|
if (flag){
|
|
|
Patient patient = patientService.findByCode(device.getUser());
|
|
|
String creditDetail = "{\"tradeType\":\"HEALTH_TASK\",\"flag\":\"BIND\",\"tradeDirection\":1,\"status\":1,\"patientId\":\""+device.getUser()+"\",\"hospital\":\""+patient.getTown()+"\"}";
|
|
|
com.alibaba.fastjson.JSONObject jsonObject = com.alibaba.fastjson.JSONObject.parseObject(creditDetail);
|
|
|
com.alibaba.fastjson.JSONObject response = creditLogService.insert(jsonObject);
|
|
@ -236,44 +241,51 @@ public class PatientDeviceController extends BaseController {
|
|
|
String flagType = String.valueOf(list.get(0).get("flag"));
|
|
|
//@TODO 调用发送微信模板接口
|
|
|
//Patient people = patientDao.findByCode(device.getUser());
|
|
|
String openId = patient.getOpenid();
|
|
|
String name = patient.getName();
|
|
|
|
|
|
org.json.JSONObject sendJson = new org.json.JSONObject();
|
|
|
String first = "";
|
|
|
String remark = "";
|
|
|
String deviceName = device.getDeviceName();
|
|
|
WechatTemplateConfig templateConfig = templateConfigDao.findByScene("template_patient_bind_device","bdsb");
|
|
|
first = templateConfig.getFirst();
|
|
|
first = first.replace("key1",(deviceName==null?"":deviceName));
|
|
|
remark = templateConfig.getRemark();
|
|
|
String keyword1 = templateConfig.getKeyword1();
|
|
|
|
|
|
sendJson.put("keyword1", keyword1);
|
|
|
sendJson.put("keyword2", device.getCzrq());
|
|
|
sendJson.put("first", first);
|
|
|
sendJson.put("remark", remark);
|
|
|
sendJson.put("url", templateConfig.getUrl());//带参数的模板跳转链接
|
|
|
pushMsgTask.putWxMsg(weiXinAccessTokenUtils.getAccessToken(), 22, openId, name, sendJson);
|
|
|
// //发送代理人
|
|
|
// jsonArray = weiXinOpenIdUtils.getAgentOpenId(patient, openId);
|
|
|
// if (jsonArray != null && jsonArray.length() > 0) {
|
|
|
// for (int i = 0; i < jsonArray.length(); i++) {
|
|
|
// org.json.JSONObject j = jsonArray.getJSONObject(i);
|
|
|
// Patient member = (Patient) j.get("member");
|
|
|
// int start = url.indexOf("&toUser=");
|
|
|
// int end = url.indexOf("&", start + 1);
|
|
|
// String touser = url.substring(start, end);
|
|
|
// url = url.replace(touser, "&toUser=" + member.getCode());
|
|
|
// //name患者姓名
|
|
|
// sendJson.put("first", weiXinOpenIdUtils.getTitleMes(people, (int) j.get("relation"), name) + first);
|
|
|
// sendJson.put("url", url);
|
|
|
// pushMsgTask.putWxMsg(weiXinAccessTokenUtils.getAccessToken(), 19, member.getOpenid(), name, sendJson);
|
|
|
// }
|
|
|
// }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
try {
|
|
|
String openId = patient.getOpenid();
|
|
|
String name = patient.getName();
|
|
|
|
|
|
org.json.JSONObject sendJson = new org.json.JSONObject();
|
|
|
String first = "";
|
|
|
String remark = "";
|
|
|
String deviceName = device.getDeviceName();
|
|
|
WechatTemplateConfig templateConfig = templateConfigDao.findByScene("template_patient_bind_device","bdsb");
|
|
|
first = templateConfig.getFirst();
|
|
|
first = first.replace("key1",(deviceName==null?"":deviceName));
|
|
|
remark = templateConfig.getRemark();
|
|
|
|
|
|
sendJson.put("keyword1", deviceName);
|
|
|
sendJson.put("keyword2", DateUtil.dateToStrLong(device.getCzrq()));
|
|
|
sendJson.put("keyword3", templateConfig.getKeyword3());
|
|
|
sendJson.put("first", first);
|
|
|
sendJson.put("remark", remark);
|
|
|
sendJson.put("url", templateConfig.getUrl());//带参数的模板跳转链接
|
|
|
System.out.println(sendJson.toString());
|
|
|
pushMsgTask.putWxMsg(weiXinAccessTokenUtils.getAccessToken(), 22, openId, name, sendJson);
|
|
|
// //发送代理人
|
|
|
// jsonArray = weiXinOpenIdUtils.getAgentOpenId(patient, openId);
|
|
|
// if (jsonArray != null && jsonArray.length() > 0) {
|
|
|
// for (int i = 0; i < jsonArray.length(); i++) {
|
|
|
// org.json.JSONObject j = jsonArray.getJSONObject(i);
|
|
|
// Patient member = (Patient) j.get("member");
|
|
|
// int start = url.indexOf("&toUser=");
|
|
|
// int end = url.indexOf("&", start + 1);
|
|
|
// String touser = url.substring(start, end);
|
|
|
// url = url.replace(touser, "&toUser=" + member.getCode());
|
|
|
// //name患者姓名
|
|
|
// sendJson.put("first", weiXinOpenIdUtils.getTitleMes(people, (int) j.get("relation"), name) + first);
|
|
|
// sendJson.put("url", url);
|
|
|
// pushMsgTask.putWxMsg(weiXinAccessTokenUtils.getAccessToken(), 19, member.getOpenid(), name, sendJson);
|
|
|
// }
|
|
|
// }
|
|
|
}catch (Exception e){
|
|
|
logger.info("设备绑定微信模板消息发送失败:"+e.getMessage());
|
|
|
// e.printStackTrace();
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|