|
@ -0,0 +1,156 @@
|
|
|
package com.yihu.wlyy.service.specialist;/**
|
|
|
* Created by nature of king on 2018/8/28.
|
|
|
*/
|
|
|
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.yihu.wlyy.entity.doctor.profile.Doctor;
|
|
|
import com.yihu.wlyy.entity.message.Message;
|
|
|
import com.yihu.wlyy.entity.organization.Hospital;
|
|
|
import com.yihu.wlyy.entity.patient.Patient;
|
|
|
import com.yihu.wlyy.repository.doctor.DoctorDao;
|
|
|
import com.yihu.wlyy.repository.message.MessageDao;
|
|
|
import com.yihu.wlyy.repository.organization.HospitalDao;
|
|
|
import com.yihu.wlyy.repository.patient.PatientDao;
|
|
|
import com.yihu.wlyy.service.BaseService;
|
|
|
import com.yihu.wlyy.util.HttpClientUtil;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
import java.util.Date;
|
|
|
import java.util.HashMap;
|
|
|
import java.util.Map;
|
|
|
|
|
|
/**
|
|
|
* @author wangzhinan
|
|
|
* @create 2018-08-28 9:09
|
|
|
* @desc 服务项目评论
|
|
|
**/
|
|
|
@Service
|
|
|
@Transactional
|
|
|
public class SpecialistEvaluateSevice extends BaseService {
|
|
|
private static org.slf4j.Logger logger = LoggerFactory.getLogger(SpecialistEvaluateSevice.class);
|
|
|
@Autowired
|
|
|
private MessageDao messageDao;
|
|
|
|
|
|
@Value("${specialist.url}")
|
|
|
private String specialistUrl;
|
|
|
@Autowired
|
|
|
private HttpClientUtil httpClientUtil;
|
|
|
@Autowired
|
|
|
private PatientDao patientDao;
|
|
|
@Autowired
|
|
|
private HospitalDao hospitalDao;
|
|
|
@Autowired
|
|
|
private DoctorDao doctorDao;
|
|
|
|
|
|
/**
|
|
|
* 添加评论
|
|
|
*
|
|
|
* @param object
|
|
|
* @return
|
|
|
*/
|
|
|
public JSONObject insert(JSONObject object){
|
|
|
String response = null;
|
|
|
String url =specialistUrl + "svr-specialist/createEvaluate";
|
|
|
Map<String,String> params = new HashMap<>();
|
|
|
params.put("evaluate",object.toJSONString());
|
|
|
try {
|
|
|
response = httpClientUtil.httpPost(url,params);
|
|
|
}catch (Exception e){
|
|
|
e.printStackTrace();
|
|
|
logger.error(e.getMessage());
|
|
|
}
|
|
|
return JSONObject.parseObject(response);
|
|
|
}
|
|
|
|
|
|
|
|
|
/**
|
|
|
* 更新评论
|
|
|
*
|
|
|
* @param object
|
|
|
* @return
|
|
|
*/
|
|
|
public JSONObject update(JSONObject object){
|
|
|
String response = null;
|
|
|
String url =specialistUrl + "svr-specialist/updateEvaluate";
|
|
|
Map<String,String> params = new HashMap<>();
|
|
|
params.put("evaluate",object.toJSONString());
|
|
|
try {
|
|
|
response = httpClientUtil.httpPost(url,params);
|
|
|
}catch (Exception e){
|
|
|
e.printStackTrace();
|
|
|
logger.error(e.getMessage());
|
|
|
}
|
|
|
return JSONObject.parseObject(response);
|
|
|
}
|
|
|
|
|
|
|
|
|
/**
|
|
|
* 获取评论
|
|
|
*
|
|
|
* @param object
|
|
|
* @return
|
|
|
*/
|
|
|
public JSONObject select(JSONObject object){
|
|
|
String response = null;
|
|
|
String url =specialistUrl + "svr-specialist/getEvaluate";
|
|
|
Map<String,String> params = new HashMap<>();
|
|
|
params.put("evaluate",object.toJSONString());
|
|
|
try {
|
|
|
response = httpClientUtil.httpPost(url,params);
|
|
|
}catch (Exception e){
|
|
|
e.printStackTrace();
|
|
|
logger.error(e.getMessage());
|
|
|
}
|
|
|
return JSONObject.parseObject(response);
|
|
|
}
|
|
|
|
|
|
|
|
|
/**
|
|
|
* 发送消息 type:19 受理提醒,20 待办工作提醒 21 服务进展提醒-已完成 22 服务进展提醒-未完成
|
|
|
*/
|
|
|
public JSONObject sendMessage(Message message,String hospital,String patient){
|
|
|
JSONObject object = new JSONObject();
|
|
|
try {
|
|
|
Patient patient1 = patientDao.findByCode(patient);
|
|
|
Hospital hospital1 = hospitalDao.findByCode(hospital);
|
|
|
Doctor doctor = doctorDao.findByCode(message.getSender());
|
|
|
if (message.getType() == 19 && StringUtils.isNoneBlank(hospital)){
|
|
|
message.setType(19);
|
|
|
message.setTitle("康复计划-受理提醒");
|
|
|
message.setContent("您的"+patient1.getName()+"签约居民,刚刚出院,"+hospital1.getName()+"已完成康复计划的制定,请查看");
|
|
|
}else if (message.getType() == 20){
|
|
|
message.setType(20);
|
|
|
message.setTitle("康复计划-待办工作提醒");
|
|
|
message.setContent("您的"+patient1.getName()+"签约居民10天后计划到"+hospital1.getName()+"复诊,请查看");
|
|
|
}else if (message.getType() == 21){
|
|
|
message.setType(21);
|
|
|
message.setTitle("康复计划-服务进展提醒");
|
|
|
message.setContent("您的"+patient1.getName()+"签约居民已完成康复计划今日项目,请查看");
|
|
|
}else if (message.getType() == 22){
|
|
|
message.setType(22);
|
|
|
message.setTitle("康复计划-服务进展提醒");
|
|
|
message.setContent("您的"+patient1.getName()+"签约居民未完成康复计划今天项目,请尽快处理");
|
|
|
}
|
|
|
message.setSenderName(doctor.getName());
|
|
|
message.setCode(getCode());
|
|
|
message.setSenderPhoto(doctor.getPhoto());
|
|
|
message.setReadonly(1);//是否只读消息
|
|
|
message.setSex(doctor.getSex());
|
|
|
message.setOver("1");//未处理
|
|
|
message.setDel("1");
|
|
|
message.setState(1);
|
|
|
message.setCzrq(new Date());
|
|
|
messageDao.save(message);
|
|
|
}catch (Exception e){
|
|
|
e.printStackTrace();
|
|
|
logger.error(e.getMessage());
|
|
|
}
|
|
|
return object;
|
|
|
}
|
|
|
|
|
|
}
|