|
@ -1,19 +1,27 @@
|
|
|
package com.yihu.wlyy.service.synergy;
|
|
|
|
|
|
import com.yihu.wlyy.entity.*;
|
|
|
import com.yihu.wlyy.entity.call.CallRecord;
|
|
|
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.entity.synergy.*;
|
|
|
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;
|
|
|
import com.yihu.wlyy.util.fastdfs.FastDFSUtil;
|
|
|
import com.yihu.wlyy.util.query.BaseJpaService;
|
|
|
import jxl.Workbook;
|
|
|
import jxl.write.*;
|
|
|
import org.apache.commons.collections.map.HashedMap;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.json.JSONObject;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.jdbc.core.BeanPropertyRowMapper;
|
|
|
import org.springframework.jdbc.core.JdbcTemplate;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
@ -60,6 +68,10 @@ public class SynergyManageService extends BaseJpaService {
|
|
|
private ManageSynergyWorkorderServicerLogDao manageSynergyWorkorderServicerLogDao;
|
|
|
@Autowired
|
|
|
private TownDao townDao;
|
|
|
@Autowired
|
|
|
private FastDFSUtil fastDFSUtil;
|
|
|
@Autowired
|
|
|
private ManageCustomerOnlineRecordDao manageCustomerOnlineRecordDao;
|
|
|
|
|
|
/**
|
|
|
* 根据服务编码获取工单
|
|
@ -114,13 +126,14 @@ public class SynergyManageService extends BaseJpaService {
|
|
|
whereSql +=" and w.create_user_type=2 ";//创建人为客服
|
|
|
whereSql += " and w.create_user ='"+code+"' ";
|
|
|
}
|
|
|
}else if(userType==3){//医生
|
|
|
}else if(userType==1){//医生
|
|
|
if(isAcceptTask==1){//我接收
|
|
|
whereSql +=" and w.create_user_type=2 ";//创建人为客服
|
|
|
|
|
|
whereSql += " and e.executor_code ='"+code+"' ";
|
|
|
}else if(isAcceptTask==2){//我派发
|
|
|
whereSql +=" and w.create_user_type=2 ";//创建人为医生
|
|
|
whereSql += " and e.create_user ='"+code+"' ";
|
|
|
whereSql +=" and w.create_user_type=1 ";//创建人为医生
|
|
|
whereSql += " and w.create_user ='"+code+"' ";
|
|
|
}
|
|
|
}
|
|
|
|
|
@ -201,6 +214,9 @@ public class SynergyManageService extends BaseJpaService {
|
|
|
String finalSql = sql+" LIMIT "+(page-1)*pageSize+","+pageSize;
|
|
|
List<Map<String,Object>> resultWorkorderList = jdbcTemplate.queryForList(finalSql);
|
|
|
List<Map<String,Object>> resultList = new ArrayList<>();
|
|
|
ManageSynergyWorkorderServicerDO servicerDO = null;
|
|
|
Patient patient =null;
|
|
|
List<ManageSynergyWorkorderServicerDO> servicerList = null;
|
|
|
for(Map<String,Object> one : resultWorkorderList){
|
|
|
Map<String,Object> map = new HashMap<>();
|
|
|
map.put("workorderCode",one.get("code"));//服务编码
|
|
@ -242,6 +258,19 @@ public class SynergyManageService extends BaseJpaService {
|
|
|
map.put("finishedServicerCount",finishedServicerCount);//服务完成人数
|
|
|
map.put("userName",one.get("create_user_name"));
|
|
|
map.put("hospitalName",one.get("hospital_name"));
|
|
|
map.put("servicerKey",one.get("servicer_key"));
|
|
|
map.put("remark",one.get("remark"));
|
|
|
if(workorderTypeR==0||workorderTypeR==2||workorderTypeR==3){
|
|
|
servicerList = workorderServicerDao.findByWorkorderCode(one.get("code")+"");
|
|
|
if(servicerList.size()>0){
|
|
|
servicerDO = servicerList.get(0);
|
|
|
patient = patientDao.findByCode(servicerDO.getServicePatientCode());
|
|
|
}
|
|
|
Integer age = IdCardUtil.getAgeForIdcard(patient.getIdcard());
|
|
|
String sex = IdCardUtil.getSexForIdcard_new(patient.getIdcard());
|
|
|
map.put("age",age);
|
|
|
map.put("sex","1".equals(sex)?"男":("2".equals(sex)?"女":"未知"));
|
|
|
}
|
|
|
resultList.add(map);
|
|
|
}
|
|
|
Map<String,Object> resultMap = new HashMap<>();
|
|
@ -455,14 +484,17 @@ public class SynergyManageService extends BaseJpaService {
|
|
|
resultMap.put("townName",workorderMap.get("town_name"));//所属区县
|
|
|
resultMap.put("hospitalName",workorderMap.get("hospital_name"));//所属社区
|
|
|
SignFamily signFamily = signFamilyDao.findSignByPatient(workorderMap.get("service_patient_code")+"");
|
|
|
resultMap.put("signDoctor",signFamily.getDoctor());//签约医生(即:工单创建医生)
|
|
|
resultMap.put("signDoctor",signFamily.getDoctorName());//签约医生(即:工单创建医生)
|
|
|
resultMap.put("healthDoctor",signFamily.getDoctorHealthName());//健管师
|
|
|
List<SignPatientLabelInfo> labelDiseaseType = signPatientLabelInfoDao.findByPatientAndLabelTypeAndStatus(workorderMap.get("service_patient_code")+"", "3", 1);
|
|
|
String diseaseType="";
|
|
|
List<String> diseaseTypeList= new ArrayList<>();
|
|
|
for(SignPatientLabelInfo one:labelDiseaseType){
|
|
|
diseaseType+=","+one.getLabelName();
|
|
|
diseaseTypeList.add(one.getLabel());
|
|
|
}
|
|
|
resultMap.put("diseaseType",StringUtils.isNotEmpty(diseaseType)?diseaseType.substring(1):"");//疾病类型
|
|
|
resultMap.put("diseaseTypeCode",diseaseTypeList);//疾病类型code
|
|
|
List<SignPatientLabelInfo> labelHealthType = signPatientLabelInfoDao.findByPatientAndLabelTypeAndStatus(workorderMap.get("service_patient_code")+"", "2", 1);
|
|
|
String healthType="";
|
|
|
for(SignPatientLabelInfo one:labelHealthType){
|
|
@ -475,20 +507,22 @@ public class SynergyManageService extends BaseJpaService {
|
|
|
serveType+=","+one.getLabelName();
|
|
|
}
|
|
|
resultMap.put("serveType",StringUtils.isNotEmpty(serveType)?serveType.substring(1):"");//服务类型
|
|
|
|
|
|
resultMap.put("workorder",workorderMap.get("code"));//工单编号
|
|
|
resultMap.put("patientCode",workorderMap.get("service_patient_code"));//居民code
|
|
|
resultMap.put("doctorCode",workorderMap.get("create_user"));//创建人(医生)code
|
|
|
//获取提交记录
|
|
|
String servicerCode = workorderMap.get("servicerCode")+"";
|
|
|
List<ManageSynergyWorkorderServicerLogDO> list = manageSynergyWorkorderServicerLogDao.findByWorkorderServiceCode(servicerCode);
|
|
|
if(list.size()>0){
|
|
|
ManageSynergyWorkorderServicerLogDO log = list.get(0);
|
|
|
Map<String,Object> m = new HashMap<>();
|
|
|
m.put("personal",log.getPersonal());
|
|
|
m.put("callCode",log.getCallCode());
|
|
|
m.put("callStatus",log.getCallStatus());
|
|
|
m.put("emphasis",log.getEmphasis());
|
|
|
m.put("followUp",log.getFollowUp());
|
|
|
m.put("remark",log.getRemark());
|
|
|
m.put("returnVisit",log.getReturnVisit());
|
|
|
m.put("personal",log.getPersonal());//是否为本人
|
|
|
m.put("callCode",log.getCallCode());//通话记录code
|
|
|
m.put("callStatus",log.getCallStatus());//通话状态(1、正常通话,2、无人接听,3、拒接,4、占线,5、关机,6、停机,7、无法接通,8、空号错号)
|
|
|
m.put("emphasis",log.getEmphasis());//是否重点患者(1、重点患者,2、非重点患者)
|
|
|
m.put("followUp",log.getFollowUp());//是否跟进(1、无需跟进,2、待跟进)
|
|
|
m.put("remark",log.getRemark());//备注
|
|
|
m.put("returnVisit",log.getReturnVisit());//回访(1、有效回访,2、无效回访)
|
|
|
resultMap.put("servicerLog",m);
|
|
|
}
|
|
|
return resultMap;
|
|
@ -846,6 +880,9 @@ public class SynergyManageService extends BaseJpaService {
|
|
|
*/
|
|
|
public void createWorkorder(ManageSynergyWorkorderDO manageSynergyWorkorderDO,List<ManageSynergyWorkorderServicerDO> manageSynergyWorkorderServicerDOS){
|
|
|
manageSynergyWorkorderDO.setCode(getWorkorderNo());
|
|
|
manageSynergyWorkorderDO.setDel(1);
|
|
|
manageSynergyWorkorderDO.setCreateTime(new Date());
|
|
|
manageSynergyWorkorderDO.setStatus(1);
|
|
|
ManageSynergyWorkorderDO manageSynergyWorkorderDO1 = workOrderDao.save(manageSynergyWorkorderDO);
|
|
|
for (ManageSynergyWorkorderServicerDO servicerDO:manageSynergyWorkorderServicerDOS){
|
|
|
servicerDO.setWorkorderType(manageSynergyWorkorderDO1.getType());
|
|
@ -868,9 +905,8 @@ public class SynergyManageService extends BaseJpaService {
|
|
|
* @param followupClass
|
|
|
* @param followupManagerStatus
|
|
|
* @param plandate
|
|
|
* @param prescriptioncode
|
|
|
*/
|
|
|
public String addFollowup(String doctor,String patient, String date, String followupType,String followupClass,String followupManagerStatus,String plandate,String prescriptioncode){
|
|
|
public String addFollowup(String doctor,String patient, String date, String followupType,String followupClass,String followupManagerStatus,String plandate){
|
|
|
String response = null;
|
|
|
String url = wlyyUrl + "followup/addFollowup";
|
|
|
Map<String, Object> params = new HashMap<>();
|
|
@ -881,7 +917,6 @@ public class SynergyManageService extends BaseJpaService {
|
|
|
params.put("followupClass",followupClass);
|
|
|
params.put("followupManagerStatus",followupManagerStatus);
|
|
|
params.put("plandate",plandate);
|
|
|
params.put("prescriptioncode",prescriptioncode);
|
|
|
try {
|
|
|
response = httpClientUtil.post(url, params);
|
|
|
} catch (Exception e) {
|
|
@ -1125,11 +1160,11 @@ public class SynergyManageService extends BaseJpaService {
|
|
|
i++;
|
|
|
}
|
|
|
wwb.write();
|
|
|
wwb.close();
|
|
|
}catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
if (wwb != null) wwb.close();
|
|
|
throw e;
|
|
|
}finally {
|
|
|
if (wwb != null) wwb.close();
|
|
|
}
|
|
|
}
|
|
|
|
|
@ -1177,16 +1212,183 @@ public class SynergyManageService extends BaseJpaService {
|
|
|
return list;
|
|
|
}
|
|
|
|
|
|
public int saveCallLabel(String callLabels,String callCode){
|
|
|
String sql ="UPDATE manage_call_record SET call_label='"+callLabels+"' WHERE `code`='"+callCode+"'";
|
|
|
return jdbcTemplate.update(sql);
|
|
|
}
|
|
|
|
|
|
public int saveCallInfo(String serviceType,String serviceContent,String callCode){
|
|
|
String sql ="UPDATE manage_call_record SET service_type='"+serviceType+"',service_content='"+serviceContent+"' WHERE `code`='"+callCode+"'";
|
|
|
return jdbcTemplate.update(sql);
|
|
|
}
|
|
|
|
|
|
public Map<String,Object> customerIndex(String userCode){
|
|
|
Map<String,Object> map = new HashMap<>();
|
|
|
String today = DateUtil.dateToStrShort(new Date());
|
|
|
String callSql ="SELECT * FROM manage_call_record WHERE user_code='"+userCode+"' and create_time>='"+today+" 00:00:00' and create_time<='"+today+" 23:59:59'";
|
|
|
//--------------今日外呼量-----------------//
|
|
|
List<CallRecord> waihudList = jdbcTemplate.query(callSql+" and type=2",new BeanPropertyRowMapper<>(CallRecord.class));
|
|
|
int customerNoCount = 0;
|
|
|
for(CallRecord callRecord : waihudList){
|
|
|
//获取客户未接通数量
|
|
|
if(callRecord.getAnswerStatus()==3){
|
|
|
customerNoCount++;
|
|
|
}
|
|
|
}
|
|
|
//求总时长
|
|
|
int seconds = totalTaklTime(waihudList);
|
|
|
//求平均时长
|
|
|
map.put("waihuAvgTalkTime",getAvgTime(seconds,waihudList.size()));
|
|
|
map.put("waihuCount",waihudList.size());
|
|
|
map.put("waihuCustomerNoCount",customerNoCount);
|
|
|
|
|
|
//--------------今日在线时长-----------------//
|
|
|
String startTime=today+" 00:00:00";
|
|
|
String endTime = today+" 23:59:59";
|
|
|
List<ManageCustomerOnlineRecordDO> manageCustomerOnlineRecordDOList = manageCustomerOnlineRecordDao.findByCustomerCodeToday(userCode,startTime,endTime);
|
|
|
String onLineTime = manageCustomerOnlineRecordDOList.get(0).getTotalOnlineTime();
|
|
|
for (ManageCustomerOnlineRecordDO customerOnlineRecordDO : manageCustomerOnlineRecordDOList){
|
|
|
|
|
|
}
|
|
|
|
|
|
//--------------今日接入量-----------------//
|
|
|
List<CallRecord> jieruList = jdbcTemplate.query(callSql+" and type=1",new BeanPropertyRowMapper<>(CallRecord.class));
|
|
|
//求总时长
|
|
|
int jieruTotalSecond = totalTaklTime(jieruList);
|
|
|
//求平均时长
|
|
|
map.put("jieruAvgTalkTime",getAvgTime(jieruTotalSecond,jieruList.size()));
|
|
|
map.put("jieruCount",jieruList.size());
|
|
|
|
|
|
//--------------今日协同任务外呼数-----------------//
|
|
|
|
|
|
return map;
|
|
|
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
*
|
|
|
* 返回总的秒数
|
|
|
* @param list
|
|
|
* @return
|
|
|
*/
|
|
|
public int totalTaklTime(List<CallRecord> list){
|
|
|
int hours = 0;
|
|
|
int minutes = 0;
|
|
|
int seconds = 0;
|
|
|
for(CallRecord callRecord : list){
|
|
|
if (callRecord.getAnswerStatus()==1){
|
|
|
String talkTime = callRecord.getTalkTime();
|
|
|
String[] talkTimeStr = talkTime.split(":");
|
|
|
for (int i=0;i<talkTimeStr.length;i++){
|
|
|
if (i==0){
|
|
|
hours += Integer.valueOf(talkTimeStr[i]);
|
|
|
}
|
|
|
if (i==1){
|
|
|
minutes += Integer.valueOf(talkTimeStr[i]);
|
|
|
}
|
|
|
if (i==2){
|
|
|
seconds += Integer.valueOf(talkTimeStr[i]);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
seconds = hours*3600+minutes*60+seconds;
|
|
|
return seconds;
|
|
|
}
|
|
|
|
|
|
public String getAvgTime(int totalSeconds,int count){
|
|
|
int avgSeconds = totalSeconds/count;
|
|
|
String avgTalkTime = "";
|
|
|
avgTalkTime =avgSeconds/3600+"时";
|
|
|
if (avgSeconds%3600==0){
|
|
|
avgTalkTime +="0分0秒";
|
|
|
}else {
|
|
|
if (avgSeconds%3600%60==0){
|
|
|
avgTalkTime +=avgSeconds%3600/60+"分0秒";
|
|
|
}else {
|
|
|
avgTalkTime +=avgSeconds%3600/60+"分"+avgSeconds%3600%60+"秒";
|
|
|
}
|
|
|
}
|
|
|
return avgTalkTime;
|
|
|
}
|
|
|
/**
|
|
|
* 添加客户操作记录
|
|
|
* @param workorderCode
|
|
|
* @param workorderServiceCode
|
|
|
* @param userCode
|
|
|
* @param userName
|
|
|
* @param callCode
|
|
|
* @param status
|
|
|
*/
|
|
|
public void addWorkorderCustomerLog(String workorderCode,String workorderServiceCode,String userCode,String userName,String callCode,String status){
|
|
|
@Transactional
|
|
|
public void addWorkorderCustomerLog(String workorderCode,String workorderServiceCode,String userCode,String callCode,Integer status) throws Exception{
|
|
|
|
|
|
ManageSynergyWorkorderCustomerLogDO workorderCustomerLogDO = new ManageSynergyWorkorderCustomerLogDO();
|
|
|
workorderCustomerLogDO.setCode(getCode());
|
|
|
workorderCustomerLogDO.setCallCode(callCode);
|
|
|
workorderCustomerLogDO.setCreateTime(new Date());
|
|
|
workorderCustomerLogDO.setCreateUserCode(userCode);
|
|
|
User user = userDao.findByCode(userCode);
|
|
|
workorderCustomerLogDO.setCreateUserName(user.getName());
|
|
|
workorderCustomerLogDO.setStatus(status);
|
|
|
workorderCustomerLogDO.setWorkorderCode(workorderCode);
|
|
|
workorderCustomerLogDO.setWorkorderServiceCode(workorderServiceCode);
|
|
|
customerLogDao.save(workorderCustomerLogDO);
|
|
|
}
|
|
|
|
|
|
// public static void main(String[] args) {
|
|
|
// String a ="group1/M00/0E/FB/rBFuWlubh7SACz32AAAde0sVAJk899.png";
|
|
|
// int aa = a.lastIndexOf("/");
|
|
|
// System.out.println(aa);
|
|
|
// System.out.println(a.substring(0,aa));
|
|
|
// }
|
|
|
public void wordToPDF(String path) throws Exception{
|
|
|
String groupName = path.substring(0,path.lastIndexOf("/"));
|
|
|
String remoteFileName =path.substring(path.lastIndexOf("/"),path.length()-1);
|
|
|
byte[] bb =FastDFSUtil.download(groupName,remoteFileName);
|
|
|
|
|
|
}
|
|
|
|
|
|
public Map<String,Object> adminIndex(String userCode){
|
|
|
List<User> userList = userDao.findByType(4);
|
|
|
|
|
|
Map<String,Object> map = new HashMap<>();
|
|
|
String today = DateUtil.dateToStrShort(new Date());
|
|
|
String callSql ="SELECT" +
|
|
|
" r.*" +
|
|
|
" FROM" +
|
|
|
" manage_call_record r" +
|
|
|
" LEFT JOIN wlyy_user u ON r.user_code = u.`code`" +
|
|
|
" WHERE" +
|
|
|
" u.type = 4" +
|
|
|
" AND r.create_time >= '"+today+" 00:00:00'" +
|
|
|
" AND r.create_time <= '"+today+" 23:59:59'";
|
|
|
//--------------今日外呼量-----------------//
|
|
|
List<CallRecord> waihudList = jdbcTemplate.query(callSql+" and r.type=2",new BeanPropertyRowMapper<>(CallRecord.class));
|
|
|
//求总时长
|
|
|
int seconds = totalTaklTime(waihudList);
|
|
|
//求平均时长
|
|
|
map.put("waihuAvgTalkTime",getAvgTime(seconds,waihudList.size()));
|
|
|
map.put("waihuCount",waihudList.size());
|
|
|
|
|
|
//--------------今日在线时长-----------------//
|
|
|
String startTime=today+" 00:00:00";
|
|
|
String endTime = today+" 23:59:59";
|
|
|
List<ManageCustomerOnlineRecordDO> manageCustomerOnlineRecordDOList = manageCustomerOnlineRecordDao.findByCustomerCodeToday(userCode,startTime,endTime);
|
|
|
String onLineTime = manageCustomerOnlineRecordDOList.get(0).getTotalOnlineTime();
|
|
|
for (ManageCustomerOnlineRecordDO customerOnlineRecordDO : manageCustomerOnlineRecordDOList){
|
|
|
|
|
|
}
|
|
|
|
|
|
//--------------今日接入量-----------------//
|
|
|
List<CallRecord> jieruList = jdbcTemplate.query(callSql+" and r.type=1",new BeanPropertyRowMapper<>(CallRecord.class));
|
|
|
//求总时长
|
|
|
int jieruTotalSecond = totalTaklTime(jieruList);
|
|
|
//求平均时长
|
|
|
map.put("jieruAvgTalkTime",getAvgTime(jieruTotalSecond,jieruList.size()));
|
|
|
map.put("jieruCount",jieruList.size());
|
|
|
|
|
|
//--------------今日协同任务外呼数-----------------//
|
|
|
|
|
|
return map;
|
|
|
|
|
|
}
|
|
|
}
|