|
@ -1,13 +1,7 @@
|
|
|
package com.yihu.wlyy.service.synergy;
|
|
|
|
|
|
import com.sun.jersey.api.client.Client;
|
|
|
import com.sun.jersey.api.client.WebResource;
|
|
|
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.*;
|
|
@ -19,7 +13,6 @@ import com.yihu.wlyy.util.http.HttpUtils;
|
|
|
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.apache.http.HttpEntity;
|
|
|
import org.apache.http.HttpResponse;
|
|
@ -89,6 +82,8 @@ public class SynergyManageService extends BaseJpaService {
|
|
|
@Autowired
|
|
|
private FastDFSUtil fastDFSUtil;
|
|
|
@Autowired
|
|
|
private ManageCustomerOnlineRecordDao manageCustomerOnlineRecordDao;
|
|
|
@Autowired
|
|
|
private ManageSynergyAccessoryDao manageSynergyAccessoryDao;
|
|
|
|
|
|
/**
|
|
@ -419,6 +414,8 @@ public class SynergyManageService extends BaseJpaService {
|
|
|
//获取处理结果
|
|
|
map.put("resultRemark", workorderDO.getDealResultRemark());
|
|
|
map.put("accessory", workorderDO.getDealResultAccessory());
|
|
|
if(workorderDO.getType() == 4)
|
|
|
map.put("relationCode", workorderDO.getRelationCode());
|
|
|
}else if(status == 4){
|
|
|
//获取退回原因
|
|
|
map.put("returnedRemark", workorderDO.getReturnedRemark());
|
|
@ -656,14 +653,17 @@ public class SynergyManageService extends BaseJpaService {
|
|
|
* @param customerCode
|
|
|
* @return
|
|
|
*/
|
|
|
public String isNotException(String workorderCode, String customerCode) {
|
|
|
public Object isNotException(String workorderCode, String customerCode) {
|
|
|
String sql = "SELECT cl.workorder_service_code from manage_synergy_workorder_customer_log cl " +
|
|
|
"where cl.workorder_service_code not in (SELECT l.workorder_service_code from manage_synergy_workorder_customer_log l where l.`status` = 2) " +
|
|
|
"where cl.workorder_service_code not in (SELECT l.workorder_service_code from manage_synergy_workorder_customer_log l where l.`status` = 1) " +
|
|
|
"and cl.workorder_code = '" + workorderCode + "' and cl.create_user_code= '" + customerCode + "' " +
|
|
|
"GROUP BY cl.workorder_code, cl.create_user_code " +
|
|
|
"ORDER BY cl.create_time LIMIT 0, 1";
|
|
|
String workorderServiceCode = jdbcTemplate.queryForObject(sql, String.class);
|
|
|
return workorderServiceCode;
|
|
|
List<Map<String, Object>> list = jdbcTemplate.queryForList(sql);
|
|
|
if(list.size() > 0){
|
|
|
return list.get(0).get("workorder_service_code");
|
|
|
}
|
|
|
return null;
|
|
|
}
|
|
|
|
|
|
public Map<String, Object> loadingInfo(String workorderServiceCode) {
|
|
@ -678,8 +678,8 @@ public class SynergyManageService extends BaseJpaService {
|
|
|
Map<String, Object> result = (Map<String, Object>) jdbcTemplate.queryForList(sql);
|
|
|
String patientCode = (String) result.get("service_patient_name");
|
|
|
*/
|
|
|
String patientCode = workorderServicerDO.getServicePatientName();
|
|
|
resultMap.put("patientName", patientCode);
|
|
|
String patientCode = workorderServicerDO.getServicePatientCode();
|
|
|
resultMap.put("patientName", workorderServicerDO.getServicePatientName());
|
|
|
resultMap.put("townName", workorderServicerDO.getTownName());//所属区县
|
|
|
resultMap.put("hospitalName", workorderServicerDO.getHospitalName());//所属社区
|
|
|
Integer callNum = customerLogDao.callNumByWorkorder(workorderServiceCode);
|
|
@ -704,7 +704,7 @@ public class SynergyManageService extends BaseJpaService {
|
|
|
Integer age = IdCardUtil.getAgeForIdcard(patient.getIdcard());
|
|
|
resultMap.put("age",age);//年龄
|
|
|
SignFamily signFamily = signFamilyDao.findSignByPatient(patientCode);
|
|
|
resultMap.put("signDoctor", signFamily.getDoctor());//签约医生(即:工单创建医生)
|
|
|
resultMap.put("signDoctor", signFamily.getDoctorName());//签约医生(即:工单创建医生)
|
|
|
resultMap.put("healthDoctor", signFamily.getDoctorHealthName());//健管师
|
|
|
List<SignPatientLabelInfo> labelDiseaseType = signPatientLabelInfoDao.findByPatientAndLabelTypeAndStatus(patientCode, "3", 1);
|
|
|
String diseaseType="";
|
|
@ -718,7 +718,7 @@ public class SynergyManageService extends BaseJpaService {
|
|
|
healthType += ","+one.getLabelName();
|
|
|
}
|
|
|
resultMap.put("healthType", StringUtils.isNotEmpty(healthType) ? healthType.substring(1) : "");//健康情况
|
|
|
List<SignPatientLabelInfo> labelServeType = signPatientLabelInfoDao.findByPatientAndLabelTypeAndStatus(patientCode, "2", 1);
|
|
|
List<SignPatientLabelInfo> labelServeType = signPatientLabelInfoDao.findByPatientAndLabelTypeAndStatus(patientCode, "1", 1);
|
|
|
String serveType="";
|
|
|
for(SignPatientLabelInfo one:labelServeType){
|
|
|
serveType+=","+one.getLabelName();
|
|
@ -897,6 +897,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());
|
|
@ -919,9 +922,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<>();
|
|
@ -932,7 +934,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) {
|
|
@ -1238,18 +1239,164 @@ public class SynergyManageService extends BaseJpaService {
|
|
|
return jdbcTemplate.update(sql);
|
|
|
}
|
|
|
|
|
|
public void customerIndex(String userCode){
|
|
|
Map<String,Object> map = new HashMap<>();
|
|
|
public Map<String,Object> customerIndex(String userCode){
|
|
|
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'";
|
|
|
//今日外呼量
|
|
|
String startTime=today+" 00:00:00";
|
|
|
String endTime = today+" 23:59:59";
|
|
|
Map<String,Object> map = new HashMap<>();
|
|
|
String callSql ="SELECT * FROM manage_call_record WHERE user_code='"+userCode+"' and create_time>='"+startTime+"' and create_time<='"+endTime+"'";
|
|
|
//--------------今日外呼量-----------------//
|
|
|
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++;
|
|
|
}
|
|
|
}
|
|
|
//求总时长
|
|
|
if (waihudList.size()>0){
|
|
|
int seconds = totalTaklTime(waihudList);
|
|
|
//求平均时长
|
|
|
map.put("waihuAvgTalkTime",getAvgTime(seconds,waihudList.size()));
|
|
|
}else {
|
|
|
map.put("waihuAvgTalkTime",0);
|
|
|
}
|
|
|
|
|
|
map.put("waihuCount",waihudList.size());
|
|
|
map.put("waihuCustomerNoCount",customerNoCount);
|
|
|
|
|
|
//--------------今日在线时长-----------------//
|
|
|
|
|
|
String lineSql="SELECT" +
|
|
|
" *" +
|
|
|
" FROM" +
|
|
|
" `manage_customer_online_record`" +
|
|
|
" WHERE" +
|
|
|
" customer_code ='"+userCode+"'" +
|
|
|
" AND create_time >='"+startTime+"'" +
|
|
|
" AND create_time <='"+endTime+"'" +
|
|
|
" ORDER BY" +
|
|
|
" create_time";
|
|
|
List<ManageCustomerOnlineRecordDO> manageCustomerOnlineRecordDOList = jdbcTemplate.query(lineSql,new BeanPropertyRowMapper<>(ManageCustomerOnlineRecordDO.class));
|
|
|
//如果最新一条是离线则直接获取总在线时长就是在线时间,
|
|
|
// 如果最新一条是在线,则用当前时间减去上一条登录时间加上之前的在线时长为总的在线时长
|
|
|
Map<String,Object> lineMap = getOnlineAndNotOnlineAndNowOnline(manageCustomerOnlineRecordDOList);
|
|
|
map.putAll(lineMap);
|
|
|
|
|
|
//--------------今日接入量-----------------//
|
|
|
List<CallRecord> jieruList = jdbcTemplate.query(callSql+" and type=1",new BeanPropertyRowMapper<>(CallRecord.class));
|
|
|
//求总时长
|
|
|
int jieruTotalSecond = totalTaklTime(jieruList);
|
|
|
//求平均时长
|
|
|
if (jieruList.size()>0){
|
|
|
map.put("jieruAvgTalkTime",getAvgTime(jieruTotalSecond,jieruList.size()));
|
|
|
}
|
|
|
map.put("jieruAvgTalkTime",0);
|
|
|
map.put("jieruCount",jieruList.size());
|
|
|
|
|
|
//--------------今日协同任务完成数-----------------//
|
|
|
String wanchenSql="SELECT" +
|
|
|
" count(*) as wanchengCount" +
|
|
|
" FROM" +
|
|
|
" `manage_synergy_workorder_servicer`" +
|
|
|
" WHERE" +
|
|
|
" executor_code = '"+userCode+"'" +
|
|
|
" AND executor_type = 2" +
|
|
|
" AND `status`=3" +
|
|
|
" AND complete_time >='"+startTime+"'" +
|
|
|
" AND complete_time<='"+endTime+"'";
|
|
|
Map<String,Object> wanchenMap = jdbcTemplate.queryForMap(wanchenSql);
|
|
|
String weiwanchenSql ="SELECT" +
|
|
|
" COUNT(*) AS weiwanchengCount" +
|
|
|
" FROM" +
|
|
|
" `manage_synergy_workorder_servicer`" +
|
|
|
" WHERE" +
|
|
|
" executor_code = '"+userCode+"'" +
|
|
|
" AND executor_type = 2" +
|
|
|
" AND `status`<3";
|
|
|
Map<String,Object> weiwanchenMap = jdbcTemplate.queryForMap(weiwanchenSql);
|
|
|
String fasongSql="SELECT" +
|
|
|
" COUNT(*) AS fasongCount" +
|
|
|
" FROM" +
|
|
|
" manage_synergy_workorder" +
|
|
|
" WHERE" +
|
|
|
" create_user = '"+userCode+"'" +
|
|
|
" AND create_user_type = 2" +
|
|
|
" AND del = 1" +
|
|
|
" AND create_time>='"+startTime+"'" +
|
|
|
" AND create_time<='"+endTime+"'";
|
|
|
Map<String,Object> fasongMap = jdbcTemplate.queryForMap(fasongSql);
|
|
|
map.putAll(wanchenMap);
|
|
|
map.putAll(weiwanchenMap);
|
|
|
map.putAll(fasongMap);
|
|
|
return map;
|
|
|
|
|
|
}
|
|
|
|
|
|
public Map<String,Object> getOnlineAndNotOnlineAndNowOnline(List<ManageCustomerOnlineRecordDO> list){
|
|
|
Map<String,Object> map = new HashMap<>();
|
|
|
if (list!=null && list.size()>0){
|
|
|
//如果最新一条是离线则直接获取总在线时长就是在线时间,
|
|
|
// 如果最新一条是在线,则用当前时间减去上一条登录时间加上之前的在线时长为总的在线时长
|
|
|
int status = list.get(list.size()-1).getStatus();
|
|
|
String firstOnlineTime = DateUtil.dateToStr(list.get(0).getCreateTime(),DateUtil.YYYY_MM_DD_HH_MM_SS);
|
|
|
int totalOnlineMinute=0;
|
|
|
int totalNotOnlineMinute =0;
|
|
|
int toMinute = 0;
|
|
|
//离线status==2
|
|
|
if (status==2){
|
|
|
totalOnlineMinute =list.get(list.size()-1).getTotalOnlineTime();
|
|
|
long allTime = list.get(list.size()-1).getCreateTime().getTime()-list.get(0).getCreateTime().getTime();
|
|
|
totalNotOnlineMinute= Integer.valueOf(String.valueOf(allTime/1000/60))-totalOnlineMinute;
|
|
|
}
|
|
|
//在线status==1
|
|
|
if (status==1){
|
|
|
//只有一条在线的数据,用当前时间减去数据创建时间
|
|
|
long onlineDate = 0L;
|
|
|
long allDateTime = 0L;
|
|
|
int lastOnlineTime =0;
|
|
|
Date now = new Date();
|
|
|
onlineDate = now.getTime()-list.get(list.size()-1).getCreateTime().getTime();
|
|
|
allDateTime = now.getTime()-list.get(0).getCreateTime().getTime();
|
|
|
toMinute = Integer.valueOf(String.valueOf(onlineDate/1000/60));
|
|
|
//多条数据,要加上上一次记录的在线时长
|
|
|
if(list.size()>1){
|
|
|
int notOnlineCount=0;
|
|
|
for (ManageCustomerOnlineRecordDO m : list){
|
|
|
if (m.getStatus()==2 && notOnlineCount<1){
|
|
|
notOnlineCount++;
|
|
|
lastOnlineTime = m.getTotalOnlineTime();
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
totalOnlineMinute=toMinute+lastOnlineTime;
|
|
|
totalNotOnlineMinute = Integer.valueOf(String.valueOf(allDateTime/1000/60))-totalOnlineMinute;
|
|
|
}
|
|
|
map.put("notOnline",totalNotOnlineMinute);
|
|
|
map.put("online",totalOnlineMinute);
|
|
|
map.put("nowOnline",toMinute);
|
|
|
map.put("firstOnlineTime",firstOnlineTime);
|
|
|
}else {
|
|
|
map.put("notOnline",0);
|
|
|
map.put("online",0);
|
|
|
map.put("nowOnline",0);
|
|
|
map.put("firstOnlineTime","");
|
|
|
}
|
|
|
|
|
|
return map;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 返回总的秒数
|
|
|
* @param list
|
|
|
* @return
|
|
|
*/
|
|
|
public int totalTaklTime(List<CallRecord> list){
|
|
|
int hours = 0;
|
|
|
int minutes = 0;
|
|
|
int seconds = 0;
|
|
|
for(CallRecord callRecord : waihudList){
|
|
|
//求总时长
|
|
|
for(CallRecord callRecord : list){
|
|
|
if (callRecord.getAnswerStatus()==1){
|
|
|
String talkTime = callRecord.getTalkTime();
|
|
|
String[] talkTimeStr = talkTime.split(":");
|
|
@ -1265,29 +1412,26 @@ public class SynergyManageService extends BaseJpaService {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
//获取客户未接通数量
|
|
|
if(callRecord.getAnswerStatus()==3){
|
|
|
customerNoCount++;
|
|
|
}
|
|
|
}
|
|
|
String avgTalkTime = "";
|
|
|
seconds = hours*3600+minutes*60+seconds;
|
|
|
avgTalkTime =seconds/3600+"时";
|
|
|
if (seconds%3600==0){
|
|
|
avgTalkTime +="0分0秒";
|
|
|
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 (seconds%3600%60==0){
|
|
|
avgTalkTime +=seconds%3600/60+"分0秒";
|
|
|
}else {
|
|
|
avgTalkTime +=seconds%3600/60+"分"+seconds%3600%60+"秒";
|
|
|
}
|
|
|
if (avgSeconds%3600%60==0){
|
|
|
avgTalkTime +=avgSeconds%3600/60+"分0秒";
|
|
|
}else {
|
|
|
avgTalkTime +=avgSeconds%3600/60+"分"+avgSeconds%3600%60+"秒";
|
|
|
}
|
|
|
}
|
|
|
map.put("waihuCount",waihudList.size());
|
|
|
map.put("waihuCustomerNoCount",customerNoCount);
|
|
|
map.put("waihuAvgTalkTime",avgTalkTime);
|
|
|
|
|
|
return avgTalkTime;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 添加客户操作记录
|
|
|
* @param workorderCode
|
|
@ -1394,4 +1538,233 @@ public class SynergyManageService extends BaseJpaService {
|
|
|
}
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
public Map<String,Object> adminIndex(){
|
|
|
List<User> userList = userDao.findByType(4);
|
|
|
|
|
|
Map<String,Object> map = new HashMap<>();
|
|
|
String today = DateUtil.dateToStrShort(new Date());
|
|
|
String startTime=today+" 00:00:00";
|
|
|
String endTime = today+" 23:59:59";
|
|
|
|
|
|
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 >= '"+startTime+"'" +
|
|
|
" AND r.create_time <= '"+endTime+"'";
|
|
|
|
|
|
//正在咨询人数
|
|
|
|
|
|
//当前客服人数
|
|
|
map.put("onlineNowCount",userList.size());
|
|
|
|
|
|
//今日会话总量 今日平均会话时长
|
|
|
List<CallRecord> allCallRecordList = jdbcTemplate.query(callSql+" and r.answer_status=1",new BeanPropertyRowMapper<>(CallRecord.class));
|
|
|
map.put("allCallCount",allCallRecordList.size());
|
|
|
if (allCallRecordList.size()>0){
|
|
|
int totalSeconds = totalTaklTime(allCallRecordList);
|
|
|
map.put("allAvgTaklTime",getAvgTime(totalSeconds,allCallRecordList.size()));
|
|
|
}else {
|
|
|
map.put("allAvgTaklTime",0);
|
|
|
}
|
|
|
|
|
|
|
|
|
//今日外呼量 今日平均会话时长
|
|
|
List<CallRecord> waihuCallRecordList = jdbcTemplate.query(callSql+" and r.answer_status=1 and r.type=2 ",new BeanPropertyRowMapper<>(CallRecord.class));
|
|
|
map.put("waihuCallCount",waihuCallRecordList.size());
|
|
|
if (waihuCallRecordList.size()>0){
|
|
|
int waihuTotalSeconds = totalTaklTime(waihuCallRecordList);
|
|
|
map.put("waihuAvgTaklTime",getAvgTime(waihuTotalSeconds,waihuCallRecordList.size()));
|
|
|
}else {
|
|
|
map.put("waihuAvgTaklTime",0);
|
|
|
}
|
|
|
|
|
|
|
|
|
//--------------今日协同任务外呼数-----------------//
|
|
|
String wanchenSql="SELECT" +
|
|
|
" count(*) AS wanchengCount" +
|
|
|
" FROM" +
|
|
|
" `manage_synergy_workorder_servicer` s" +
|
|
|
" LEFT JOIN wlyy_user u ON s.executor_code = u.`code`" +
|
|
|
" WHERE" +
|
|
|
" s.executor_type = 2" +
|
|
|
" AND s.`status` = 3" +
|
|
|
" AND s.complete_time >= '"+startTime+"'" +
|
|
|
" AND s.complete_time <= '"+endTime+"'";
|
|
|
Map<String,Object> wanchenMap = jdbcTemplate.queryForMap(wanchenSql);
|
|
|
String weiwanchenSql ="SELECT" +
|
|
|
" COUNT(*) AS weiwanchengCount" +
|
|
|
" FROM" +
|
|
|
" `manage_synergy_workorder_servicer` s" +
|
|
|
" LEFT JOIN wlyy_user u ON s.executor_code = u.`code`" +
|
|
|
" WHERE" +
|
|
|
" executor_type = 2" +
|
|
|
" AND `status`<3";
|
|
|
Map<String,Object> weiwanchenMap = jdbcTemplate.queryForMap(weiwanchenSql);
|
|
|
String fasongSql="SELECT" +
|
|
|
" COUNT(*) AS fasongCount" +
|
|
|
" FROM" +
|
|
|
" (" +
|
|
|
" SELECT" +
|
|
|
" s.*, w.create_user," +
|
|
|
" w.create_user_name" +
|
|
|
" FROM" +
|
|
|
" manage_synergy_workorder_servicer s" +
|
|
|
" LEFT JOIN manage_synergy_workorder w ON s.workorder_code = w.`code`" +
|
|
|
" WHERE" +
|
|
|
" w.create_user_type = 2" +
|
|
|
" AND w.del = 1" +
|
|
|
" AND w.create_time >= '"+startTime+"'" +
|
|
|
" AND w.create_time <= '"+endTime+"'" +
|
|
|
" ) a" +
|
|
|
" LEFT JOIN wlyy_user u ON a.create_user = u.`code`";
|
|
|
Map<String,Object> fasongMap = jdbcTemplate.queryForMap(fasongSql);
|
|
|
map.putAll(wanchenMap);
|
|
|
map.putAll(weiwanchenMap);
|
|
|
map.putAll(fasongMap);
|
|
|
return map;
|
|
|
|
|
|
}
|
|
|
|
|
|
public Map<String,Object> intervalOnLine(){
|
|
|
Map<String,Object> map = new HashMap<>();
|
|
|
String today = DateUtil.dateToStrShort(new Date());
|
|
|
String startTime=today+" 00:00:00";
|
|
|
String endTime = today+" 23:59:59";
|
|
|
String allSql="SELECT " +
|
|
|
" HOUR (r.create_time) AS HOUR, " +
|
|
|
" count(*) AS Count " +
|
|
|
" FROM " +
|
|
|
" manage_call_record r " +
|
|
|
" LEFT JOIN wlyy_user u ON r.user_code = u.`code` " +
|
|
|
" WHERE " +
|
|
|
" r.create_time BETWEEN '"+startTime+"' " +
|
|
|
" AND '"+endTime+"' " +
|
|
|
" AND r.answer_status = 1 " +
|
|
|
" GROUP BY " +
|
|
|
" HOUR (r.create_time) " +
|
|
|
" ORDER BY " +
|
|
|
" HOUR (r.create_time)";
|
|
|
List<Map<String,Object>> allList = jdbcTemplate.queryForList(allSql);
|
|
|
String jieruSql ="SELECT " +
|
|
|
" HOUR (r.create_time) AS HOUR, " +
|
|
|
" count(*) AS Count " +
|
|
|
" FROM " +
|
|
|
" manage_call_record r " +
|
|
|
" LEFT JOIN wlyy_user u ON r.user_code = u.`code` " +
|
|
|
" WHERE " +
|
|
|
" r.create_time BETWEEN '"+startTime+"' " +
|
|
|
" AND '"+endTime+"' " +
|
|
|
" AND r.answer_status = 1 " +
|
|
|
" AND r.type = 1 " +
|
|
|
" GROUP BY " +
|
|
|
" HOUR (r.create_time) " +
|
|
|
" ORDER BY " +
|
|
|
" HOUR (r.create_time)";
|
|
|
List<Map<String,Object>> jieruList = jdbcTemplate.queryForList(allSql);
|
|
|
map.put("all",allList);
|
|
|
map.put("jieru",jieruList);
|
|
|
return map;
|
|
|
}
|
|
|
|
|
|
public List<Map<String,Object>> TodayCustomerActivy(){
|
|
|
List<Map<String,Object>> resultList = new ArrayList<>();
|
|
|
String today = DateUtil.dateToStrShort(new Date());
|
|
|
String startTime=today+" 00:00:00";
|
|
|
String endTime = today+" 23:59:59";
|
|
|
startTime="2017-11-15 00:00:00";
|
|
|
endTime="2017-11-22 23:59:59";
|
|
|
String sql="SELECT" +
|
|
|
" u.`code`,"+
|
|
|
" u.`name`," +
|
|
|
" u.`online` as onlineType," +
|
|
|
" r.type," +
|
|
|
" COUNT(*) as num"+
|
|
|
" FROM" +
|
|
|
" wlyy_user u" +
|
|
|
" LEFT JOIN manage_call_record r ON u.`code` = r.user_code" +
|
|
|
" WHERE" +
|
|
|
" u.type = 4" +
|
|
|
" AND r.create_time>='"+startTime+"'" +
|
|
|
" AND r.create_time<='"+endTime+"'" +
|
|
|
" AND r.answer_status=1"+
|
|
|
" GROUP BY" +
|
|
|
" u.`code`," +
|
|
|
" r.type";
|
|
|
List<Map<String,Object>> list = jdbcTemplate.queryForList(sql);
|
|
|
List<Map<String,Object>> toList = new ArrayList<>();
|
|
|
for (Map<String,Object> map : list){
|
|
|
resultList.addAll(toList);
|
|
|
toList.clear();
|
|
|
String userCode = String.valueOf(map.get("code"));
|
|
|
String type = String.valueOf(map.get("type"));
|
|
|
if (resultList.size()==0){
|
|
|
Map<String,Object> resultMap = new HashMap<>();
|
|
|
resultMap.put("userCode",userCode);
|
|
|
resultMap.put("userName",map.get("name"));
|
|
|
resultMap.put("onlineType",map.get("online"));
|
|
|
if ("1".equals(type)){
|
|
|
resultMap.put("jieruCount",map.get("num"));
|
|
|
resultMap.put("waihuCount",0);
|
|
|
}
|
|
|
if ("2".equals(type)){
|
|
|
resultMap.put("jieruCount",0);
|
|
|
resultMap.put("waihuCount",map.get("num"));
|
|
|
}
|
|
|
toList.add(resultMap);
|
|
|
}else {
|
|
|
int count =0;
|
|
|
for (Map<String,Object> map1 : resultList){
|
|
|
count++;
|
|
|
if(userCode.equals(String.valueOf(map1.get("userCode")))){
|
|
|
if ("1".equals(type)){
|
|
|
map1.put("jieruCount",map.get("num"));
|
|
|
}
|
|
|
if ("2".equals(type)){
|
|
|
map1.put("waihuCount",map.get("num"));
|
|
|
}
|
|
|
}
|
|
|
if (count==resultList.size() && !userCode.equals(String.valueOf(map1.get("userCode")))){
|
|
|
Map<String,Object> resultMap = new HashMap<>();
|
|
|
resultMap.put("userCode",userCode);
|
|
|
resultMap.put("userName",map.get("name"));
|
|
|
resultMap.put("onlineType",map.get("onlineType"));
|
|
|
if ("1".equals(type)){
|
|
|
resultMap.put("jieruCount",map.get("num"));
|
|
|
resultMap.put("waihuCount",0);
|
|
|
}
|
|
|
if ("2".equals(type)){
|
|
|
resultMap.put("jieruCount",0);
|
|
|
resultMap.put("waihuCount",map.get("num"));
|
|
|
}
|
|
|
toList.add(resultMap);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
for (Map<String,Object> reMap : resultList){
|
|
|
String userCode = String.valueOf(reMap.get("userCode"));
|
|
|
String lineSql="SELECT" +
|
|
|
" *" +
|
|
|
" FROM" +
|
|
|
" `manage_customer_online_record`" +
|
|
|
" WHERE" +
|
|
|
" customer_code ='"+userCode+"'" +
|
|
|
" AND create_time >='"+startTime+"'" +
|
|
|
" AND create_time <='"+endTime+"'" +
|
|
|
" ORDER BY" +
|
|
|
" create_time";
|
|
|
List<ManageCustomerOnlineRecordDO> manageCustomerOnlineRecordDOList = jdbcTemplate.query(lineSql,new BeanPropertyRowMapper<>(ManageCustomerOnlineRecordDO.class));
|
|
|
//如果最新一条是离线则直接获取总在线时长就是在线时间
|
|
|
// 如果最新一条是在线,则用当前时间减去上一条登录时间加上之前的在线时长为总的在线时长
|
|
|
Map<String,Object> lineMap = getOnlineAndNotOnlineAndNowOnline(manageCustomerOnlineRecordDOList);
|
|
|
reMap.putAll(lineMap);
|
|
|
}
|
|
|
return resultList;
|
|
|
}
|
|
|
|
|
|
}
|