|
@ -1,20 +1,12 @@
|
|
|
package com.yihu.wlyy.service.synergy;
|
|
|
|
|
|
import com.yihu.wlyy.entity.Patient;
|
|
|
import com.yihu.wlyy.entity.SignFamily;
|
|
|
import com.yihu.wlyy.entity.SignPatientLabelInfo;
|
|
|
import com.yihu.wlyy.entity.User;
|
|
|
import com.yihu.wlyy.entity.*;
|
|
|
import com.yihu.wlyy.entity.synergy.ManageSynergyWorkordeReminderDO;
|
|
|
import com.yihu.wlyy.entity.synergy.ManageSynergyWorkorderDO;
|
|
|
import com.yihu.wlyy.entity.synergy.ManageSynergyWorkorderExecutorDO;
|
|
|
import com.yihu.wlyy.entity.synergy.ManageSynergyWorkorderServicerDO;
|
|
|
import com.yihu.wlyy.repository.PatientDao;
|
|
|
import com.yihu.wlyy.repository.SignFamilyDao;
|
|
|
import com.yihu.wlyy.repository.SignPatientLabelInfoDao;
|
|
|
import com.yihu.wlyy.repository.UserDao;
|
|
|
import com.yihu.wlyy.repository.synergy.ManageSynergyWorkOrderDao;
|
|
|
import com.yihu.wlyy.repository.synergy.ManageSynergyWorkorderCustomerLogDao;
|
|
|
import com.yihu.wlyy.repository.synergy.ManageSynergyWorkorderExecutorDao;
|
|
|
import com.yihu.wlyy.repository.synergy.ManageSynergyWorkorderServicerDao;
|
|
|
import com.yihu.wlyy.repository.*;
|
|
|
import com.yihu.wlyy.repository.synergy.*;
|
|
|
import com.yihu.wlyy.util.DateUtil;
|
|
|
import com.yihu.wlyy.util.HttpClientUtil;
|
|
|
import com.yihu.wlyy.util.IdCardUtil;
|
|
@ -52,13 +44,19 @@ public class SynergyManageService extends BaseJpaService {
|
|
|
@Autowired
|
|
|
private UserDao userDao;
|
|
|
@Autowired
|
|
|
private ManageSynergyWorkorderCustomerLogDao manageSynergyWorkorderCustomerLogDao;
|
|
|
@Autowired
|
|
|
private PatientDao patientDao;
|
|
|
@Autowired
|
|
|
private SignFamilyDao signFamilyDao;
|
|
|
@Autowired
|
|
|
private SignPatientLabelInfoDao signPatientLabelInfoDao;
|
|
|
@Autowired
|
|
|
private ManageSynergyWorkorderCustomerLogDao customerLogDao;
|
|
|
@Autowired
|
|
|
private DoctorDao doctorDao;
|
|
|
@Autowired
|
|
|
private ManageSynergyWorkorderReminderDao manageSynergyWorkorderReminderDao;
|
|
|
@Autowired
|
|
|
private ManageSynergyWorkorderServicerLogDao manageSynergyWorkorderServicerLogDao;
|
|
|
|
|
|
/**
|
|
|
* 根据服务编码获取工单
|
|
@ -392,8 +390,8 @@ public class SynergyManageService extends BaseJpaService {
|
|
|
Map<String,Object> workorderMap = resultWorkorderList.get(0);
|
|
|
//居民信息
|
|
|
resultMap.put("mobile",workorderMap.get("mobile"));//电话号码
|
|
|
resultMap.put("mobile",workorderMap.get("mobile"));//居民姓名
|
|
|
Integer callNum = manageSynergyWorkorderCustomerLogDao.callNumByWorkorder(workorderMap.get("servicerCode")+"");
|
|
|
resultMap.put("patientName",workorderMap.get("service_patient_name"));//居民姓名
|
|
|
Integer callNum = customerLogDao.callNumByWorkorder(workorderMap.get("servicerCode")+"");
|
|
|
resultMap.put("callNum",callNum);//已呼叫次数
|
|
|
Patient patient =patientDao.findByCode(workorderMap.get("service_patient_code")+"");
|
|
|
Integer sex = patient.getSex();
|
|
@ -531,4 +529,190 @@ public class SynergyManageService extends BaseJpaService {
|
|
|
e.printStackTrace();
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 查找该客服该工单是否有异常工单
|
|
|
* @param workorderCode
|
|
|
* @param customerCode
|
|
|
* @return
|
|
|
*/
|
|
|
public Integer findExceptionCount(String workorderCode, String customerCode) {
|
|
|
return customerLogDao.findExceptionCount(workorderCode, customerCode);
|
|
|
}
|
|
|
|
|
|
public Map<String, Object> loadingInfo(String workorderCode, String customerCode) {
|
|
|
Map<String,Object> resultMap = new HashMap<>();
|
|
|
String sql = "SELECT s.service_patient_name, s.service_patient_code, s.`code`, s.s.hospital_name,s.town_name " +
|
|
|
"from (SELECT DISTINCT r.patient,cl.workorder_code from manage_synergy_workorder_customer_log cl " +
|
|
|
"LEFT JOIN manage_call_record r on cl.call_code = r.`code` " +
|
|
|
"where cl.workorder_code = " + workorderCode + " and cl.create_user_code = " + customerCode + " and cl.`status` = 0 ORDER BY cl.create_time LIMIT 0,1) p " +
|
|
|
"LEFT JOIN manage_synergy_workorder_servicer s on p.workorder_code = s.workorder_code and s.service_patient_code = p.patient and s.`status`=1";
|
|
|
|
|
|
Map<String, Object> result = (Map<String, Object>) jdbcTemplate.queryForList(sql);
|
|
|
String patientCode = (String) result.get("service_patient_name");
|
|
|
resultMap.put("patientName", patientCode);
|
|
|
resultMap.put("townName", result.get("town_name"));//所属区县
|
|
|
resultMap.put("hospitalName", result.get("hospital_name"));//所属社区
|
|
|
Integer callNum = customerLogDao.callNumByWorkorder((String) result.get("code"));
|
|
|
resultMap.put("callNum",callNum);//已呼叫次数
|
|
|
Patient patient = patientDao.findByCode(patientCode);
|
|
|
Integer sex = patient.getSex();
|
|
|
String sexName = "";
|
|
|
if(sex==1){
|
|
|
sexName="男";
|
|
|
}else if(sex==2){
|
|
|
sexName="女";
|
|
|
}else{
|
|
|
sexName="未知";
|
|
|
}
|
|
|
resultMap.put("sex",sexName);//性别
|
|
|
Integer age = IdCardUtil.getAgeForIdcard(patient.getIdcard());
|
|
|
resultMap.put("age",age);//年龄
|
|
|
SignFamily signFamily = signFamilyDao.findSignByPatient(patientCode);
|
|
|
resultMap.put("signDoctor", signFamily.getDoctor());//签约医生(即:工单创建医生)
|
|
|
resultMap.put("healthDoctor", signFamily.getDoctorHealthName());//健管师
|
|
|
List<SignPatientLabelInfo> labelDiseaseType = signPatientLabelInfoDao.findByPatientAndLabelTypeAndStatus(patientCode, "3", 1);
|
|
|
String diseaseType="";
|
|
|
for(SignPatientLabelInfo one:labelDiseaseType){
|
|
|
diseaseType+=","+one.getLabelName();
|
|
|
}
|
|
|
resultMap.put("diseaseType", StringUtils.isNotEmpty(diseaseType) ? diseaseType.substring(1) : "");//疾病类型
|
|
|
List<SignPatientLabelInfo> labelHealthType = signPatientLabelInfoDao.findByPatientAndLabelTypeAndStatus(patientCode, "2", 1);
|
|
|
String healthType="";
|
|
|
for(SignPatientLabelInfo one:labelHealthType){
|
|
|
healthType+=","+one.getLabelName();
|
|
|
}
|
|
|
resultMap.put("healthType", StringUtils.isNotEmpty(healthType) ? healthType.substring(1) : "");//健康情况
|
|
|
List<SignPatientLabelInfo> labelServeType = signPatientLabelInfoDao.findByPatientAndLabelTypeAndStatus(patientCode, "2", 1);
|
|
|
String serveType="";
|
|
|
for(SignPatientLabelInfo one:labelServeType){
|
|
|
serveType+=","+one.getLabelName();
|
|
|
}
|
|
|
resultMap.put("serveType", StringUtils.isNotEmpty(serveType)?serveType.substring(1) : "");//服务类型
|
|
|
return resultMap;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 任务进度
|
|
|
* @param workorderCode
|
|
|
* @param userCode
|
|
|
*/
|
|
|
public Map<String,Object> workorderRate(String workorderCode,String userCode){
|
|
|
Map<String,Object> resultMap = new HashMap<>();
|
|
|
//完成情况
|
|
|
//1、有效
|
|
|
Integer validCount = workorderServicerDao.findByWorkorderCodeCount(workorderCode,3);
|
|
|
resultMap.put("validCount",validCount);
|
|
|
//2、无效
|
|
|
resultMap.put("invalidCount",0);
|
|
|
//3、总数
|
|
|
ManageSynergyWorkorderDO manageSynergyWorkorder = workOrderDao.findByCode(workorderCode);
|
|
|
resultMap.put("allCount",manageSynergyWorkorder.getServicerCount());
|
|
|
//我已完成
|
|
|
Integer myFinishedCount = workorderServicerDao.countByWorkorderCodeAndExecutorCodeAndStatus(workorderCode,userCode,3);
|
|
|
resultMap.put("myFinishedCount",myFinishedCount);
|
|
|
//待跟进
|
|
|
Integer followCount = manageSynergyWorkorderServicerLogDao.findByWorkorderCode(workorderCode);
|
|
|
resultMap.put("followCount",followCount);
|
|
|
return resultMap;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 催单
|
|
|
* @param workorderCode
|
|
|
* @param userCode
|
|
|
* @param userType
|
|
|
* @throws Exception
|
|
|
*/
|
|
|
@Transactional
|
|
|
public void reminder(String workorderCode,String userCode,Integer userType) throws Exception{
|
|
|
|
|
|
ManageSynergyWorkorderDO manageSynergyWorkorderDO = workOrderDao.findByCode(workorderCode);
|
|
|
if(manageSynergyWorkorderDO==null){
|
|
|
throw new Exception();
|
|
|
}
|
|
|
ManageSynergyWorkordeReminderDO workordeReminderDO = new ManageSynergyWorkordeReminderDO();
|
|
|
workordeReminderDO.setCode(getCode());
|
|
|
workordeReminderDO.setWorkorderCode(workorderCode);
|
|
|
workordeReminderDO.setCreateUser(userCode);
|
|
|
//创建人类型(1、医生,2、客服,3、客服负责人)
|
|
|
if(userType==1){
|
|
|
Doctor doctor = doctorDao.findByCode(userCode);
|
|
|
workordeReminderDO.setCreateUserName(doctor.getName());
|
|
|
}else if(userType==2||userType==3){
|
|
|
User user = userDao.findByCode(userCode);
|
|
|
workordeReminderDO.setCreateUserName(user.getName());
|
|
|
}
|
|
|
workordeReminderDO.setCreateUserType(userType);
|
|
|
workordeReminderDO.setHospital(manageSynergyWorkorderDO.getHospital());
|
|
|
workordeReminderDO.setHospitalName(manageSynergyWorkorderDO.getHospitalName());
|
|
|
workordeReminderDO.setCreateTime(new Date());
|
|
|
List<ManageSynergyWorkorderExecutorDO> list = workorderExecutorDao.findByWorkorderCode(workorderCode,1);
|
|
|
if(list!=null&&list.size()>0){
|
|
|
workordeReminderDO.setPrincipalCode(list.get(0).getExecutorCode());
|
|
|
workordeReminderDO.setPrincipalName(list.get(0).getExecutorName());
|
|
|
}
|
|
|
workordeReminderDO.setWorkorderType(manageSynergyWorkorderDO.getType());
|
|
|
workordeReminderDO.setRelationCode(manageSynergyWorkorderDO.getRelationCode());
|
|
|
workordeReminderDO.setRelationCodeName(manageSynergyWorkorderDO.getRelationCodeName());
|
|
|
|
|
|
workordeReminderDO.setServiceTime(manageSynergyWorkorderDO!=null?manageSynergyWorkorderDO.getServiceTime():null);
|
|
|
workordeReminderDO.setServicerKey(manageSynergyWorkorderDO!=null?manageSynergyWorkorderDO.getServicerKey():null);
|
|
|
workordeReminderDO.setWorkorderRemark(manageSynergyWorkorderDO!=null?manageSynergyWorkorderDO.getRemark():null);
|
|
|
workordeReminderDO.setDealWith(0);
|
|
|
workordeReminderDO.setPriority(manageSynergyWorkorderDO.getPriority());
|
|
|
manageSynergyWorkorderReminderDao.save(workordeReminderDO);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 催单列表
|
|
|
* @param userCode
|
|
|
* @param receiveType 1、客服,2、客服负责人
|
|
|
* @param sortType 1、升序,2、降序
|
|
|
*/
|
|
|
public List<Map<String,Object>> reminderList(String userCode,Integer receiveType,Integer sortType){
|
|
|
String sql ="";
|
|
|
String sort ="";
|
|
|
if(sortType==1){
|
|
|
sort=" order by r.create_time asc ";
|
|
|
}else if(sortType==2){
|
|
|
sort=" order by r.create_time desc ";
|
|
|
}
|
|
|
if(receiveType==1){
|
|
|
sql =" select DISTINCT r.* from manage_synergy_workorder_reminder r " +
|
|
|
" LEFT JOIN manage_synergy_workorder_executor e on r.workorder_code=e.workorder_code " +
|
|
|
" where e.executor_code='' and e.del=1 and r.deal_with=0 " +sort;
|
|
|
}else if(receiveType==2){
|
|
|
sql =" select r.* from manage_synergy_workorder_reminder r where r.principal_code='"+userCode+"' and r.deal_with=0 "+sort;
|
|
|
}
|
|
|
List<Map<String,Object>> List = jdbcTemplate.queryForList(sql);
|
|
|
List<Map<String,Object>> resultList = new ArrayList<>();
|
|
|
for(Map<String,Object> one:List){
|
|
|
Map<String,Object> resultMap = new HashMap<>();
|
|
|
resultMap.put("workorderCode",one.get("workorder_code"));
|
|
|
resultMap.put("title","来自"+one.get("create_user_name")+"医生("+one.get("hospital_name")+")催单,请尽快处理(服务编号:)"+one.get("workorder_code"));//标题
|
|
|
String workorderTypeName ="";
|
|
|
Integer workorderType = (Integer) one.get("workorder_type");
|
|
|
switch (workorderType){
|
|
|
case 0: workorderTypeName="咨询";break;
|
|
|
case 1: workorderTypeName="健康教育";break;
|
|
|
case 2: workorderTypeName="预约";break;
|
|
|
case 3: workorderTypeName="随访";break;
|
|
|
case 4: workorderTypeName="问卷调查";break;
|
|
|
case 5: workorderTypeName="疾病筛查";break;
|
|
|
}
|
|
|
resultMap.put("workorderTypeName",workorderTypeName);
|
|
|
resultMap.put("workorderType",one.get("workorder_type"));
|
|
|
resultMap.put("priority",one.get("priority"));
|
|
|
resultMap.put("relationCodeName",one.get("relation_code_name"));
|
|
|
resultMap.put("serviceTime",DateUtil.dateToStr((Date)one.get("service_time"),"yyyy-MM-dd HH:mm:ss"));
|
|
|
resultMap.put("reminderTime",DateUtil.dateToStr((Date)one.get("create_time"),"yyyy-MM-dd HH:mm:ss"));
|
|
|
resultMap.put("servicerKey",one.get("servicer_key"));
|
|
|
resultMap.put("workorderRemark",one.get("workorder_remark"));
|
|
|
Integer overTimeFlag = isServiceOverTime((Date)one.get("service_time"));
|
|
|
resultMap.put("overTimeFlag",overTimeFlag);
|
|
|
resultList.add(resultMap);
|
|
|
}
|
|
|
return resultList;
|
|
|
}
|
|
|
}
|