Browse Source

客服系統

trick9191 7 years ago
parent
commit
c085c72412

+ 16 - 3
patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/service/manager/account/CustomerService.java

@ -3,6 +3,7 @@ package com.yihu.wlyy.service.manager.account;
import com.yihu.wlyy.entity.*;
import com.yihu.wlyy.entity.*;
import com.yihu.wlyy.entity.call.CallRecord;
import com.yihu.wlyy.entity.call.CallRecord;
import com.yihu.wlyy.entity.call.CallService;
import com.yihu.wlyy.entity.call.CallService;
import com.yihu.wlyy.repository.DoctorDao;
import com.yihu.wlyy.repository.MessageDao;
import com.yihu.wlyy.repository.MessageDao;
import com.yihu.wlyy.repository.PatientDao;
import com.yihu.wlyy.repository.PatientDao;
import com.yihu.wlyy.repository.UserDao;
import com.yihu.wlyy.repository.UserDao;
@ -56,6 +57,8 @@ public class CustomerService extends BaseService{
	private JdbcTemplate jdbcTemplate;
	private JdbcTemplate jdbcTemplate;
	@Autowired
	@Autowired
	private MessageDao messageDao;
	private MessageDao messageDao;
	@Autowired
	private DoctorDao doctorDao;
	@Value(("${doctorAssistant.api}")+"/wlyygc/doctor/message")
	@Value(("${doctorAssistant.api}")+"/wlyygc/doctor/message")
	private String messageApi;
	private String messageApi;
@ -408,6 +411,10 @@ public class CustomerService extends BaseService{
		callService.setUser(user);
		callService.setUser(user);
		User u = userDao.findByCode(user);
		User u = userDao.findByCode(user);
		callService.setUserName(u.getName());
		callService.setUserName(u.getName());
		//存储医生
		SignFamily sf = familyService.findByPatientCode(callService.getPatient());
		callService.setAdminTeamCode(sf.getAdminTeamId());
		callService.setCreateTime(new Date());
		callServiceDao.save(callService);
		callServiceDao.save(callService);
		//待处理发送消息给医生
		//待处理发送消息给医生
@ -429,7 +436,7 @@ public class CustomerService extends BaseService{
			message.setReadonly(1);//是否只读消息
			message.setReadonly(1);//是否只读消息
			message.setSex(p.getSex());
			message.setSex(p.getSex());
			message.setOver("1");//未处理
			message.setOver("1");//未处理
			message.setDel("1");
			messageDao.save(message);
			messageDao.save(message);
		}
		}
@ -451,7 +458,12 @@ public class CustomerService extends BaseService{
			Message message = new Message();
			Message message = new Message();
			message.setCzrq(new Date());
			message.setCzrq(new Date());
			message.setCreateTime(new Date());
			message.setCreateTime(new Date());
			message.setContent("您有一条新的协同服务消息!");
			if("1".equals(callService.getType())){
				message.setContent(u.getName()+"需要预约挂号");
			}else{
				message.setContent(u.getName()+"发起咨询");
			}
			message.setRead(1);//设置未读
			message.setRead(1);//设置未读
			message.setReceiver(callService.getDoctor());//设置接受医生的code
			message.setReceiver(callService.getDoctor());//设置接受医生的code
			message.setSender(callService.getPatient());//设置发送的用户
			message.setSender(callService.getPatient());//设置发送的用户
@ -463,6 +475,7 @@ public class CustomerService extends BaseService{
			message.setReadonly(1);//是否只读消息
			message.setReadonly(1);//是否只读消息
			message.setSex(p.getSex());
			message.setSex(p.getSex());
			message.setOver("1");//未处理
			message.setOver("1");//未处理
			message.setDel("1");
			messageDao.save(message);
			messageDao.save(message);
		}
		}
@ -527,7 +540,7 @@ public class CustomerService extends BaseService{
			sql +=" AND (s.patient_name = '"+keyword+"' OR s.ssc ='"+keyword+"' OR s.Idcard ='"+keyword+"')";
			sql +=" AND (s.patient_name = '"+keyword+"' OR s.ssc ='"+keyword+"' OR s.Idcard ='"+keyword+"')";
		}
		}
		if(serverType!=null){
		if(serverType!=null){
			sql += " AND s.server_type ='"+serverType+"' " ;
			sql += " AND s.type ='"+serverType+"' " ;
		}
		}
		if(state != null){
		if(state != null){
			sql +=" AND s.state ='"+state+"'";
			sql +=" AND s.state ='"+state+"'";

+ 5 - 2
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/message/MessageDao.java

@ -62,7 +62,7 @@ public interface MessageDao extends PagingAndSortingRepository<Message, Long>, J
    @Query("select a from Message a where a.receiver = ?1 and a.prescriptionStatus=?2 and a.type in (6,7) order by a.createTime desc")
    @Query("select a from Message a where a.receiver = ?1 and a.prescriptionStatus=?2 and a.type in (6,7) order by a.createTime desc")
    List<Message> getSysTemMessageByPrescription(String doctor, String prescriptionStatus);
    List<Message> getSysTemMessageByPrescription(String doctor, String prescriptionStatus);
    @Query("select a from Message a where a.receiver = ?1 and a.type not in (1,2,6,7)")
    @Query("select a from Message a where a.receiver = ?1 and a.type not in (1,2,6,7,12)")
    List<Message> getSystemMessage(String doctor, Pageable pageRequest);
    List<Message> getSystemMessage(String doctor, Pageable pageRequest);
    @Query("select a from Message a where a.receiver = ?1 and a.type=?2 and a.prescriptionStatus='0' ")
    @Query("select a from Message a where a.receiver = ?1 and a.type=?2 and a.prescriptionStatus='0' ")
@ -98,9 +98,12 @@ public interface MessageDao extends PagingAndSortingRepository<Message, Long>, J
    @Query("from Message a where a.type = 8 and a.state=0 and a.del='1' and a.over='0' and relationCode = ?1  ")
    @Query("from Message a where a.type = 8 and a.state=0 and a.del='1' and a.over='0' and relationCode = ?1  ")
    Message findByRelationCode(String relationCode);
    Message findByRelationCode(String relationCode);
    @Query("from Message a where a.type = 12 and a.state=0 and a.del='1' and a.over='0' and receiver = ?1  ")
    @Query("from Message a where a.type = 12 and a.del='1' and a.over='1' and receiver = ?1  ")
    List<Message> findByReceiverCallService(String doctor);
    List<Message> findByReceiverCallService(String doctor);
    @Query("select a from Message a where a.receiver = ?1 and a.type=?2 ")
    @Query("select a from Message a where a.receiver = ?1 and a.type=?2 ")
    List<Message> getMessageByType(String doctor, Integer type, Pageable pageRequest);
    List<Message> getMessageByType(String doctor, Integer type, Pageable pageRequest);
    @Query("from Message a where a.type = 12 and a.del='1' and a.over='1' and relationCode = ?1  ")
    List<Message> findByCallServiceRelationCode(String relationCode);
}
}

+ 25 - 15
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/prescription/PrescriptionExpressageService.java

@ -10,8 +10,11 @@ import com.yihu.wlyy.repository.patient.PatientDao;
import com.yihu.wlyy.repository.prescription.*;
import com.yihu.wlyy.repository.prescription.*;
import com.yihu.wlyy.service.BaseService;
import com.yihu.wlyy.service.BaseService;
import com.yihu.wlyy.util.DateUtil;
import com.yihu.wlyy.util.DateUtil;
import com.yihu.wlyy.util.ElasticsearchUtil;
import org.apache.commons.collections.map.HashedMap;
import org.apache.commons.collections.map.HashedMap;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.core.JdbcTemplate;
@ -27,6 +30,8 @@ import java.util.*;
@Service
@Service
@Transactional
@Transactional
public class PrescriptionExpressageService extends BaseService {
public class PrescriptionExpressageService extends BaseService {
    private Logger logger = LoggerFactory.getLogger(ElasticsearchUtil.class);
    @Autowired
    @Autowired
    private PrescriptionExpressageDao prescriptionExpressageDao;
    private PrescriptionExpressageDao prescriptionExpressageDao;
    @Autowired
    @Autowired
@ -559,23 +564,28 @@ public class PrescriptionExpressageService extends BaseService {
            prescriptionLog.setStatus(PrescriptionLog.PrescriptionLogStatus.finish.getValue());
            prescriptionLog.setStatus(PrescriptionLog.PrescriptionLogStatus.finish.getValue());
            prescriptionLogDao.save(prescriptionLog);
            prescriptionLogDao.save(prescriptionLog);
            //更新二维码(isUse)
            PrescriptionDispensaryCode prescriptionDispensaryCode = prescriptionDispensaryCodeDao.finByCode(prescriptionCode);
            if(prescriptionDispensaryCode!=null){
                //修改取药码code为已经使用
                prescriptionDispensaryCode.setIsUse(1);
                prescriptionDispensaryCodeDao.save(prescriptionDispensaryCode);
            try {
                //更新二维码(isUse)
                PrescriptionDispensaryCode prescriptionDispensaryCode = prescriptionDispensaryCodeDao.finByCode(prescriptionCode);
                if(prescriptionDispensaryCode!=null){
                    //修改取药码code为已经使用
                    prescriptionDispensaryCode.setIsUse(1);
                    prescriptionDispensaryCodeDao.save(prescriptionDispensaryCode);
                    //更新配送信息
                    PrescriptionExpressage prescriptionExpressage = prescriptionExpressageDao.findByPrescriptionCode(prescriptionDispensaryCode.getPrescriptionCode());
                    if(prescriptionExpressage!=null){
                        prescriptionExpressage.setHospitalDoctor(doctor);
                        prescriptionExpressage.setHospitalDoctorCode(d.getCode());
                        prescriptionExpressage.setFetchingMedicineTime(new Date());
                        prescriptionExpressageDao.save(prescriptionExpressage);
                    }
                }
            }catch (Exception e){
                logger.info("更新二维码(isUse),更新配送信息 异常:"+e.getMessage());
            }
            }
            //更新配送信息
            PrescriptionExpressage prescriptionExpressage = prescriptionExpressageDao.findByPrescriptionCode(prescriptionDispensaryCode.getPrescriptionCode());
            if(prescriptionExpressage!=null){
                prescriptionExpressage.setHospitalDoctor(doctor);
                prescriptionExpressage.setHospitalDoctorCode(d.getCode());
                prescriptionExpressage.setFetchingMedicineTime(new Date());
                prescriptionExpressageDao.save(prescriptionExpressage);
            }
            return "1";
            return "1";
        }
        }
        return "0";
        return "0";

+ 25 - 2
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/call/CustomerService.java

@ -46,13 +46,12 @@ public class CustomerService extends BaseService{
				" s.create_time AS createTime, " +
				" s.create_time AS createTime, " +
				" s.user, " +
				" s.user, " +
				" s.user_name AS userName ," +
				" s.user_name AS userName ," +
				" s.create_Time AS createTime ," +
				" p.sex," +
				" p.sex," +
				" p.photo," +
				" p.photo," +
				" TIMESTAMPDIFF(YEAR,p.birthday,SYSDATE()) age" +
				" TIMESTAMPDIFF(YEAR,p.birthday,SYSDATE()) age" +
				" FROM " +
				" FROM " +
				" manage_call_service s " +
				" manage_call_service s " +
				" LEFT JOIN wlyy_patient p ON s.code = s.patient" +
				" LEFT JOIN wlyy_patient p ON p.code = s.patient" +
				" WHERE " +
				" WHERE " +
				" s.state >0 ";
				" s.state >0 ";
		if(StringUtils.isNotBlank(keyword)){
		if(StringUtils.isNotBlank(keyword)){
@ -116,6 +115,12 @@ public class CustomerService extends BaseService{
		CallService callService = callServiceDao.findByCode(code);
		CallService callService = callServiceDao.findByCode(code);
		CallRecord callRecord = callRecordDao.findByCode(callService.getCallCode());
		CallRecord callRecord = callRecordDao.findByCode(callService.getCallCode());
		Map<String,Object> rs = new HashedMap();
		Map<String,Object> rs = new HashedMap();
		String id = callService.getIdcard();
		String idCard = id.substring(0,id.length()-10)+"*******"+id.substring(id.length()-2,id.length());
		callRecord.setIdcard(idCard);
		callService.setIdcard(idCard);
		rs.put("callService",callService);
		rs.put("callService",callService);
		rs.put("callRecord",callRecord);
		rs.put("callRecord",callRecord);
		return rs;
		return rs;
@ -129,6 +134,15 @@ public class CustomerService extends BaseService{
		 callService.setDealTime(new Date());
		 callService.setDealTime(new Date());
		 callService.setState(2);
		 callService.setState(2);
		 callServiceDao.save(callService);
		 callServiceDao.save(callService);
		List<Message> mes = messageDao.findByCallServiceRelationCode(code);
		if(mes!=null&&mes.size()>0){
			for(Message m :mes){
				m.setOver("0");
				m.setRead(0);
				messageDao.save(m);
			}
		}
		return "1";
		return "1";
	}
	}
@ -168,6 +182,15 @@ public class CustomerService extends BaseService{
			cs.setDealContent(dealContent);
			cs.setDealContent(dealContent);
		}
		}
		callServiceDao.save(cs);
		callServiceDao.save(cs);
		List<Message> mes = messageDao.findByCallServiceRelationCode(code);
		if(mes!=null&&mes.size()>0){
			for(Message m :mes){
				m.setOver("0");
				m.setRead(0);
				messageDao.save(m);
			}
		}
		return "1";
		return "1";
	}
	}
}
}