|
@ -1,5 +1,6 @@
|
|
|
package com.yihu.jw.hospital.message.service;
|
|
|
|
|
|
import com.alibaba.fastjson.JSONArray;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
|
|
import com.yihu.jw.doctor.dao.BaseDoctorDao;
|
|
@ -12,14 +13,12 @@ import com.yihu.jw.hospital.message.dao.SystemMessageDao;
|
|
|
import com.yihu.jw.hospital.prescription.dao.OutpatientDao;
|
|
|
import com.yihu.jw.message.dao.MessageNoticeSettingDao;
|
|
|
import com.yihu.jw.message.dao.SpecialistDynamicMessagesDao;
|
|
|
import com.yihu.jw.restmodel.web.Envelop;
|
|
|
import com.yihu.jw.restmodel.web.MixEnvelop;
|
|
|
import com.yihu.jw.util.date.DateUtil;
|
|
|
import com.yihu.jw.utils.StringUtil;
|
|
|
import com.yihu.jw.utils.YkyySMSService;
|
|
|
import com.yihu.jw.utils.hibernate.HibenateUtils;
|
|
|
import com.yihu.mysql.query.BaseJpaService;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.checkerframework.checker.units.qual.A;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.data.redis.core.StringRedisTemplate;
|
|
@ -37,7 +36,7 @@ import java.util.Map;
|
|
|
*/
|
|
|
@Service
|
|
|
@Transactional
|
|
|
public class SystemMessageService extends BaseJpaService<SystemMessageDO,SystemMessageDao> {
|
|
|
public class SystemMessageService extends BaseJpaService<SystemMessageDO, SystemMessageDao> {
|
|
|
|
|
|
@Autowired
|
|
|
private SystemMessageDao systemMessageDao;
|
|
@ -66,11 +65,12 @@ public class SystemMessageService extends BaseJpaService<SystemMessageDO,SystemM
|
|
|
|
|
|
/**
|
|
|
* 新增线上就诊消息
|
|
|
*
|
|
|
* @param systemMessageDO
|
|
|
* @return
|
|
|
* @throws Exception
|
|
|
*/
|
|
|
public SystemMessageDO addMessage(SystemMessageDO systemMessageDO) throws Exception{
|
|
|
public SystemMessageDO addMessage(SystemMessageDO systemMessageDO) throws Exception {
|
|
|
systemMessageDO.setIsRead("0");
|
|
|
systemMessageDO.setDel("1");
|
|
|
systemMessageDO.setCreateTime((new Date()));
|
|
@ -81,22 +81,23 @@ public class SystemMessageService extends BaseJpaService<SystemMessageDO,SystemM
|
|
|
|
|
|
/**
|
|
|
* 更新线上就诊消息
|
|
|
*
|
|
|
* @param id
|
|
|
* @param read
|
|
|
* @param del
|
|
|
* @return
|
|
|
* @throws Exception
|
|
|
*/
|
|
|
public SystemMessageDO updateMessage(String id,String read,String del) throws Exception{
|
|
|
public SystemMessageDO updateMessage(String id, String read, String del) throws Exception {
|
|
|
SystemMessageDO systemMessageDO = systemMessageDao.findOne(id);
|
|
|
if (null == systemMessageDO){
|
|
|
if (null == systemMessageDO) {
|
|
|
return null;
|
|
|
}
|
|
|
if (!StringUtil.isEmpty(read)){
|
|
|
if (!StringUtil.isEmpty(read)) {
|
|
|
systemMessageDO.setIsRead(read);
|
|
|
systemMessageDO.setReadTime(new Date());
|
|
|
}
|
|
|
if (!StringUtil.isEmpty(del)){
|
|
|
if (!StringUtil.isEmpty(del)) {
|
|
|
systemMessageDO.setDel(del);
|
|
|
}
|
|
|
systemMessageDao.save(systemMessageDO);
|
|
@ -106,10 +107,11 @@ public class SystemMessageService extends BaseJpaService<SystemMessageDO,SystemM
|
|
|
|
|
|
/**
|
|
|
* 保存线上就诊消息(外部调用)
|
|
|
*
|
|
|
* @param systemMessageDO
|
|
|
* @throws Exception
|
|
|
*/
|
|
|
public void saveMessage(SystemMessageDO systemMessageDO) throws Exception{
|
|
|
public void saveMessage(SystemMessageDO systemMessageDO) throws Exception {
|
|
|
systemMessageDO.setIsRead("0");
|
|
|
systemMessageDO.setDel("1");
|
|
|
systemMessageDO.setCreateTime(new Date());
|
|
@ -119,11 +121,12 @@ public class SystemMessageService extends BaseJpaService<SystemMessageDO,SystemM
|
|
|
|
|
|
/**
|
|
|
* 根据id查询消息详情
|
|
|
*
|
|
|
* @param id
|
|
|
* @return
|
|
|
* @throws Exception
|
|
|
*/
|
|
|
public SystemMessageDO queryById(String id) throws Exception{
|
|
|
public SystemMessageDO queryById(String id) throws Exception {
|
|
|
SystemMessageDO systemMessageDO = systemMessageDao.queryById(id);
|
|
|
return systemMessageDO;
|
|
|
}
|
|
@ -131,12 +134,12 @@ public class SystemMessageService extends BaseJpaService<SystemMessageDO,SystemM
|
|
|
/**
|
|
|
* 发送系统消息通用接口
|
|
|
*/
|
|
|
public SystemMessageDO commenSystemMessage(String jsonParam,String jsonContent) throws Exception{
|
|
|
if (StringUtils.isNoneBlank(jsonParam)){
|
|
|
SystemMessageDO systemMessageDO = objectMapper.readValue(jsonParam,SystemMessageDO.class);
|
|
|
public SystemMessageDO commenSystemMessage(String jsonParam, String jsonContent) throws Exception {
|
|
|
if (StringUtils.isNoneBlank(jsonParam)) {
|
|
|
SystemMessageDO systemMessageDO = objectMapper.readValue(jsonParam, SystemMessageDO.class);
|
|
|
systemMessageDO.setDel("1");
|
|
|
systemMessageDO.setIsRead("0");
|
|
|
if (StringUtils.isNoneBlank(jsonContent)){
|
|
|
if (StringUtils.isNoneBlank(jsonContent)) {
|
|
|
JSONObject jsonObject = JSONObject.parseObject(jsonContent);
|
|
|
systemMessageDO.setData(jsonObject.toJSONString());
|
|
|
}
|
|
@ -145,24 +148,25 @@ public class SystemMessageService extends BaseJpaService<SystemMessageDO,SystemM
|
|
|
}
|
|
|
return null;
|
|
|
}
|
|
|
public String sendDoctorRemindSms(ConsultDo consultDo){
|
|
|
|
|
|
public String sendDoctorRemindSms(ConsultDo consultDo) {
|
|
|
String msg = "";
|
|
|
if ("xm_ykyy_wx".equalsIgnoreCase(wechatId)){
|
|
|
if (consultDo!=null){
|
|
|
if ("xm_ykyy_wx".equalsIgnoreCase(wechatId)) {
|
|
|
if (consultDo != null) {
|
|
|
WlyyOutpatientDO wlyyOutpatientDO = outpatientDao.findById(consultDo.getRelationCode());
|
|
|
if (wlyyOutpatientDO!=null){
|
|
|
if (wlyyOutpatientDO != null) {
|
|
|
BaseDoctorDO baseDoctorDO = baseDoctorDao.findById(wlyyOutpatientDO.getDoctor());
|
|
|
if (baseDoctorDO!=null){
|
|
|
ykyySMSService.sendSmsByTempcode("message_remind_paitent",wlyyOutpatientDO,null,baseDoctorDO.getMobile());
|
|
|
msg="发送成功";
|
|
|
}else{
|
|
|
msg="发送失败,医生不存在";
|
|
|
if (baseDoctorDO != null) {
|
|
|
ykyySMSService.sendSmsByTempcode("message_remind_paitent", wlyyOutpatientDO, null, baseDoctorDO.getMobile());
|
|
|
msg = "发送成功";
|
|
|
} else {
|
|
|
msg = "发送失败,医生不存在";
|
|
|
}
|
|
|
}else {
|
|
|
msg="发送失败,门诊不存在";
|
|
|
} else {
|
|
|
msg = "发送失败,门诊不存在";
|
|
|
}
|
|
|
}else {
|
|
|
msg="发送失败,consult不存在";
|
|
|
} else {
|
|
|
msg = "发送失败,consult不存在";
|
|
|
}
|
|
|
}
|
|
|
|
|
@ -304,4 +308,66 @@ public class SystemMessageService extends BaseJpaService<SystemMessageDO,SystemM
|
|
|
return re;
|
|
|
}
|
|
|
|
|
|
|
|
|
/**
|
|
|
* 获取待接单的接口
|
|
|
*
|
|
|
* @param message {"read":1,"over":0}
|
|
|
* @param page 页码
|
|
|
* @param size 分页大小
|
|
|
* @return
|
|
|
* @throws Exception
|
|
|
*/
|
|
|
public org.json.JSONObject getWaitingMessages(SystemMessageDO message, String types, Integer page, Integer size) throws Exception {
|
|
|
String sqlList = " SELECT a.* ";
|
|
|
String sqlCount = " select count(*) as total ";
|
|
|
String sql = " FROM base_system_message a ";
|
|
|
// " LEFT JOIN wlyy_door_service_application b ON a.relation_code = b.code ";//云招呼没有资质审核这块
|
|
|
sql += " where 1=1 AND a.state = 1 AND a.over = 1 ";
|
|
|
if (!StringUtils.isEmpty(message.getReceiver())) {
|
|
|
sql += " AND a.receiver = '" + message.getReceiver() + "'";
|
|
|
}
|
|
|
if (!StringUtils.isEmpty(types)) {
|
|
|
sql += " AND a.type IN (" + types + ")";
|
|
|
}
|
|
|
//分页
|
|
|
String pageSql = " ORDER BY a.create_time DESC LIMIT " + (page - 1) * size + "," + size;
|
|
|
|
|
|
sqlCount += sql;
|
|
|
sqlList += sql + pageSql;
|
|
|
List<Map<String, Object>> rstotal = jdbcTemplate.queryForList(sqlCount);
|
|
|
List<Map<String, Object>> mapList = jdbcTemplate.queryForList(sqlList);
|
|
|
Long count = 0L;
|
|
|
if (rstotal != null && rstotal.size() > 0) {
|
|
|
count = (Long) rstotal.get(0).get("total");
|
|
|
}
|
|
|
JSONArray jsonArray = new JSONArray();
|
|
|
for (Map<String, Object> one : mapList) {
|
|
|
org.json.JSONObject object = new org.json.JSONObject();
|
|
|
object.put("over", one.get("over"));
|
|
|
object.put("code", one.get("code"));
|
|
|
object.put("receiver", one.get("receiver"));
|
|
|
object.put("del", one.get("del"));
|
|
|
object.put("title", one.get("title"));
|
|
|
object.put("type", one.get("type"));
|
|
|
object.put("content", one.get("content"));
|
|
|
object.put("sender", one.get("sender"));
|
|
|
object.put("id", one.get("id"));
|
|
|
object.put("state", one.get("state"));
|
|
|
object.put("relation_code", one.get("relation_code"));
|
|
|
object.put("has_read", one.get("has_read"));
|
|
|
object.put("appliStatus", one.get("appliStatus"));
|
|
|
Date date = (Date) one.get("create_time");
|
|
|
object.put("create_time", DateUtil.dateToStr(date, "yyyy-MM-dd HH:mm:ss"));
|
|
|
Date date1 = (Date) one.get("czrq");
|
|
|
object.put("czrq", DateUtil.dateToStr(date1, "yyyy-MM-dd HH:mm:ss"));
|
|
|
jsonArray.add(object);
|
|
|
}
|
|
|
org.json.JSONObject object = new org.json.JSONObject();
|
|
|
object.put("total", count);
|
|
|
object.put("waitingMessages", jsonArray);
|
|
|
object.put("currPage", page);
|
|
|
object.put("pageSize", size);
|
|
|
return object;
|
|
|
}
|
|
|
}
|