浏览代码

客服首页和管理员首页

zd_123 6 年之前
父节点
当前提交
c7ba59ec2a

+ 12 - 2
patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/controller/synergy/customer/CustomerSynergyManageController.java

@ -319,8 +319,7 @@ public class CustomerSynergyManageController extends BaseController {
    @ApiOperation(value = "客服首页")
    public String customerIndex(@ApiParam(name="userCode",value="客服code")@RequestParam(value ="userCode")String userCode){
        try{
            return write(200,"获取成功!");
            return write(200,"获取成功!","data",synergyManageService.customerIndex(userCode));
        }catch (Exception e){
            e.printStackTrace();
            return write(-1,"获取失败!");
@ -379,5 +378,16 @@ public class CustomerSynergyManageController extends BaseController {
            return error(-1, "请求失败");
        }
    }
    @RequestMapping(value = "adminIndex",method = RequestMethod.GET)
    @ApiOperation(value = "管理员首页")
    public String adminIndex(@ApiParam(name="userCode",value="客服code")@RequestParam(value ="userCode")String userCode){
        try{
            return write(200,"获取成功!","data",synergyManageService.customerIndex(userCode));
        }catch (Exception e){
            e.printStackTrace();
            return write(-1,"获取失败!");
        }
    }
}

+ 10 - 0
patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/entity/synergy/ManageCustomerOnlineRecordDO.java

@ -22,6 +22,7 @@ public class ManageCustomerOnlineRecordDO extends IdEntity {
    private String jobNo;//客服工号
    private String seat;//席位
    private String phone;//客服电话
    private String totalOnlineTime;//在线总时长
    @Column(name = "code")
    public String getCode() {
@ -94,4 +95,13 @@ public class ManageCustomerOnlineRecordDO extends IdEntity {
    public void setPhone(String phone) {
        this.phone = phone;
    }
    @Column(name = "total_online_time")
    public String getTotalOnlineTime() {
        return totalOnlineTime;
    }
    public void setTotalOnlineTime(String totalOnlineTime) {
        this.totalOnlineTime = totalOnlineTime;
    }
}

+ 2 - 0
patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/repository/UserDao.java

@ -38,4 +38,6 @@ public interface UserDao extends PagingAndSortingRepository<User, Long>, JpaSpec
	User findByJobNo(String jobNo);
	List<User> findByType(int type);
}

+ 6 - 0
patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/repository/synergy/ManageCustomerOnlineRecordDao.java

@ -1,10 +1,16 @@
package com.yihu.wlyy.repository.synergy;
import com.yihu.wlyy.entity.synergy.ManageCustomerOnlineRecordDO;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import java.util.List;
/**
 * Created by 刘文彬 on 2018/9/27.
 */
public interface ManageCustomerOnlineRecordDao extends PagingAndSortingRepository<ManageCustomerOnlineRecordDO, Long> {
    @Query("select r from ManageCustomerOnlineRecordDO r where r.customerCode=?1 and r.createTime>=?2 and r.createTime<=?3 order by r.createTime")
    List<ManageCustomerOnlineRecordDO> findByCustomerCodeToday(String userCode,String startTime,String endTime);
}

+ 107 - 22
patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/service/synergy/SynergyManageService.java

@ -67,6 +67,8 @@ public class SynergyManageService extends BaseJpaService {
    private ManageSynergyWorkorderServicerLogDao manageSynergyWorkorderServicerLogDao;
    @Autowired
    private TownDao townDao;
    @Autowired
    private ManageCustomerOnlineRecordDao manageCustomerOnlineRecordDao;
    /**
     * 根据服务编码获取工单
@ -1191,18 +1193,59 @@ public class SynergyManageService extends BaseJpaService {
        return  jdbcTemplate.update(sql);
    }
    public void customerIndex(String userCode){
    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 : waihudList){
            //求总时长
        for(CallRecord callRecord : list){
            if (callRecord.getAnswerStatus()==1){
                String talkTime = callRecord.getTalkTime();
                String[] talkTimeStr = talkTime.split(":");
@ -1218,29 +1261,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
@ -1253,4 +1293,49 @@ public class SynergyManageService extends BaseJpaService {
    public void addWorkorderCustomerLog(String workorderCode,String workorderServiceCode,String userCode,String userName,String callCode,String status){
    }
    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;
    }
}