|
@ -7,12 +7,18 @@ import com.alibaba.fastjson.JSONObject;
|
|
import com.yihu.wlyy.entity.device.PatientDevice;
|
|
import com.yihu.wlyy.entity.device.PatientDevice;
|
|
import com.yihu.wlyy.entity.patient.Patient;
|
|
import com.yihu.wlyy.entity.patient.Patient;
|
|
import com.yihu.wlyy.entity.patient.SignFamily;
|
|
import com.yihu.wlyy.entity.patient.SignFamily;
|
|
|
|
import com.yihu.wlyy.entity.wechat.WechatTemplateConfig;
|
|
import com.yihu.wlyy.repository.dict.SystemDictDao;
|
|
import com.yihu.wlyy.repository.dict.SystemDictDao;
|
|
import com.yihu.wlyy.repository.patient.PatientDao;
|
|
import com.yihu.wlyy.repository.patient.PatientDao;
|
|
import com.yihu.wlyy.repository.patient.PatientDeviceDao;
|
|
import com.yihu.wlyy.repository.patient.PatientDeviceDao;
|
|
import com.yihu.wlyy.repository.patient.SignFamilyDao;
|
|
import com.yihu.wlyy.repository.patient.SignFamilyDao;
|
|
|
|
import com.yihu.wlyy.repository.wechat.WechatTemplateConfigDao;
|
|
import com.yihu.wlyy.service.app.device.PatientDeviceService;
|
|
import com.yihu.wlyy.service.app.device.PatientDeviceService;
|
|
|
|
import com.yihu.wlyy.service.common.account.PatientService;
|
|
|
|
import com.yihu.wlyy.task.PushMsgTask;
|
|
|
|
import com.yihu.wlyy.util.DateUtil;
|
|
import com.yihu.wlyy.util.HttpClientUtil;
|
|
import com.yihu.wlyy.util.HttpClientUtil;
|
|
|
|
import com.yihu.wlyy.wechat.util.WeiXinAccessTokenUtils;
|
|
import org.slf4j.Logger;
|
|
import org.slf4j.Logger;
|
|
import org.slf4j.LoggerFactory;
|
|
import org.slf4j.LoggerFactory;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
@ -49,8 +55,6 @@ public class CreditLogService {
|
|
private StringRedisTemplate redisTemplate;
|
|
private StringRedisTemplate redisTemplate;
|
|
@Autowired
|
|
@Autowired
|
|
private PatientDeviceService patientDeviceService;
|
|
private PatientDeviceService patientDeviceService;
|
|
@Autowired
|
|
|
|
private PatientDao patientDao;
|
|
|
|
|
|
|
|
@Autowired
|
|
@Autowired
|
|
private SystemDictDao systemDictDao;
|
|
private SystemDictDao systemDictDao;
|
|
@ -59,6 +63,17 @@ public class CreditLogService {
|
|
|
|
|
|
@Autowired
|
|
@Autowired
|
|
private SignFamilyDao signFamilyDao;
|
|
private SignFamilyDao signFamilyDao;
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
private PatientService patientService;
|
|
|
|
@Autowired
|
|
|
|
private WechatTemplateConfigDao templateConfigDao;
|
|
|
|
@Autowired
|
|
|
|
private PushMsgTask pushMsgTask;
|
|
|
|
@Autowired
|
|
|
|
private WeiXinAccessTokenUtils weiXinAccessTokenUtils;
|
|
|
|
@Autowired
|
|
|
|
private PatientDao patientDao;
|
|
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
@ -132,6 +147,9 @@ public class CreditLogService {
|
|
* @return
|
|
* @return
|
|
*/
|
|
*/
|
|
public JSONObject insert(JSONObject object) throws Exception {
|
|
public JSONObject insert(JSONObject object) throws Exception {
|
|
|
|
|
|
|
|
JSONObject result = new JSONObject();
|
|
|
|
|
|
String response = null;
|
|
String response = null;
|
|
String patientId = object.getString("patientId");
|
|
String patientId = object.getString("patientId");
|
|
Patient patient = patientDao.findByCode(patientId);
|
|
Patient patient = patientDao.findByCode(patientId);
|
|
@ -151,10 +169,73 @@ public class CreditLogService {
|
|
e.printStackTrace();
|
|
e.printStackTrace();
|
|
logger.error(e.getMessage());
|
|
logger.error(e.getMessage());
|
|
}
|
|
}
|
|
return JSONObject.parseObject(response);
|
|
|
|
|
|
|
|
|
|
result = JSONObject.parseObject(response);
|
|
|
|
String status = result.getString("status");
|
|
|
|
logger.info("健康银行居民新增积分:"+result.toString());
|
|
|
|
if ("200".equals(status)){
|
|
|
|
List<Map<String,Object>> list = (List<Map<String,Object>>)result.get("detailModelList");
|
|
|
|
if (list!=null && list.size()>0){
|
|
|
|
//积分
|
|
|
|
String integrateresult = String.valueOf(list.get(0).get("integrate"));
|
|
|
|
String patientid = String.valueOf(list.get(0).get("patientId"));
|
|
|
|
String total = String.valueOf(list.get(0).get("total"));
|
|
|
|
|
|
|
|
try {
|
|
|
|
//@TODO 获取积分调用发送微信模板接口
|
|
|
|
Patient people = patientDao.findByCode(patientid);
|
|
|
|
String openId = people.getOpenid();
|
|
|
|
String name = people.getName();
|
|
|
|
|
|
|
|
org.json.JSONObject sendJson = new org.json.JSONObject();
|
|
|
|
String first = "";
|
|
|
|
String remark = "";
|
|
|
|
String urlresult = "";
|
|
|
|
|
|
|
|
WechatTemplateConfig templateConfig = templateConfigDao.findByScene("template_healthbank_credit","jfdztz");
|
|
|
|
first = templateConfig.getFirst();
|
|
|
|
remark = templateConfig.getRemark();
|
|
|
|
// String keyword1 = templateConfig.getKeyword1();
|
|
|
|
|
|
|
|
sendJson.put("keyword1", integrateresult);
|
|
|
|
sendJson.put("keyword2", DateUtil.getStringDate());
|
|
|
|
sendJson.put("keyword3", total);
|
|
|
|
sendJson.put("first", first);
|
|
|
|
sendJson.put("remark", remark);
|
|
|
|
urlresult = templateConfig.getUrl();
|
|
|
|
urlresult = urlresult.replace("key1",(integrateresult==null?"":integrateresult));
|
|
|
|
sendJson.put("url", urlresult);//带参数的模板跳转链接
|
|
|
|
System.out.println(sendJson.toString());
|
|
|
|
pushMsgTask.putWxMsg(weiXinAccessTokenUtils.getAccessToken(), 23, 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();
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return result;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
* 按条件查询积分
|
|
* 按条件查询积分
|
|
*
|
|
*
|
|
@ -566,7 +647,7 @@ public class CreditLogService {
|
|
object.put("idCard",patient.getIdcard());
|
|
object.put("idCard",patient.getIdcard());
|
|
object.put("openId",patient.getOpenid());
|
|
object.put("openId",patient.getOpenid());
|
|
object.put("unionId",patient.getUnionid());
|
|
object.put("unionId",patient.getUnionid());
|
|
String url =getBaseUrl() + "addStepIntegrate";
|
|
|
|
|
|
String url =getBaseUrl()+ "addStepIntegrate";
|
|
Map<String,String> params = new HashMap<>();
|
|
Map<String,String> params = new HashMap<>();
|
|
params.put("creditsDetail",object.toJSONString());
|
|
params.put("creditsDetail",object.toJSONString());
|
|
try {
|
|
try {
|