1
0
mirror of https://github.com/chatopera/cosin.git synced 2025-08-01 16:38:02 +08:00

Fix StatusEventRepository related class

This commit is contained in:
dengchao@xgtl 2020-04-16 14:10:25 +08:00
parent 4fb52a8f24
commit af069c4363
3 changed files with 153 additions and 182 deletions

View File

@ -422,14 +422,14 @@
}); });
} else if (MainContext.ChannelType.PHONE.toString().equals(agentUser.getChannel())) { } else if (MainContext.ChannelType.PHONE.toString().equals(agentUser.getChannel())) {
if (agentService != null && StringUtils.isNotBlank(agentService.getOwner())) { if (agentService != null && StringUtils.isNotBlank(agentService.getOwner())) {
StatusEvent statusEvent = this.statusEventRes.findById(agentService.getOwner()); this.statusEventRes.findById(agentService.getOwner())
if (statusEvent != null) { .ifPresent(statusEvent -> {
if (StringUtils.isNotBlank(statusEvent.getHostid())) { if (StringUtils.isNotBlank(statusEvent.getHostid())) {
PbxHost pbxHost = pbxHostRes.findById(statusEvent.getHostid()); pbxHostRes.findById(statusEvent.getHostid())
view.addObject("pbxHost", pbxHost); .ifPresent(pbxHost -> view.addObject("pbxHost", pbxHost));
} }
view.addObject("statusEvent", statusEvent); view.addObject("statusEvent", statusEvent);
} });
} }
} }

View File

@ -1,166 +1,137 @@
/* /*
* Copyright (C) 2017 优客服-多渠道客服系统 * Copyright (C) 2017 优客服-多渠道客服系统
* Modifications copyright (C) 2018-2019 Chatopera Inc, <https://www.chatopera.com> * Modifications copyright (C) 2018-2019 Chatopera Inc, <https://www.chatopera.com>
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package com.chatopera.cc.persistence.repository; package com.chatopera.cc.persistence.repository;
import com.chatopera.cc.model.StatusEvent; import com.chatopera.cc.model.StatusEvent;
import org.springframework.data.domain.Page; import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable; import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.domain.Specification; import org.springframework.data.jpa.domain.Specification;
import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param; public interface StatusEventRepository extends JpaRepository<StatusEvent, String> {
import java.util.Date; // StatusEvent findById(String id);
import java.util.List;
// StatusEvent findByIdOrBridgeid(String id, String bridgeid);
public interface StatusEventRepository extends JpaRepository<StatusEvent, String> {
// Page<StatusEvent> findByAni(String ani, Pageable page);
StatusEvent findById(String id);
// Page<StatusEvent> findByNameid(String nameid, Pageable page);
StatusEvent findByIdOrBridgeid(String id, String bridgeid);
// Page<StatusEvent> findByDataid(String dataid, Pageable page);
Page<StatusEvent> findByAni(String ani, Pageable page);
Page<StatusEvent> findByOrgi(String orgi, Pageable page);
Page<StatusEvent> findByNameid(String nameid, Pageable page);
// Page<StatusEvent> findByServicestatusAndOrgi(String servicestatus, String orgi, Pageable page);
Page<StatusEvent> findByDataid(String dataid, Pageable page);
// Page<StatusEvent> findByMisscallAndOrgi(boolean misscall, String orgi, Pageable page);
Page<StatusEvent> findByOrgi(String orgi, Pageable page);
// Page<StatusEvent> findByRecordAndOrgi(boolean record, String orgi, Pageable page);
Page<StatusEvent> findByServicestatusAndOrgi(String servicestatus, String orgi, Pageable page);
// Page<StatusEvent> findByCalledAndOrgi(String voicemail, String orgi, Pageable page);
Page<StatusEvent> findByMisscallAndOrgi(boolean misscall, String orgi, Pageable page);
Page<StatusEvent> findAll(Specification<StatusEvent> spec, Pageable pageable); //分页按条件查询
Page<StatusEvent> findByRecordAndOrgi(boolean record, String orgi, Pageable page);
Page<StatusEvent> findByCalledAndOrgi(String voicemail, String orgi, Pageable page); // /**
// * 坐席报表
Page<StatusEvent> findAll(Specification<StatusEvent> spec, Pageable pageable); //分页按条件查询 // */
// @Query(value =
// "select " +
/** // " agent, " +
* 坐席报表 // " direction, " +
* @param channel // " count(IF(DIALPLAN is not null, 1, null)) dialplan, " +
* @param fromdate // " count(*) total, " +
* @param enddate // " sum(duration) seconds, " +
* @param organ // " count(IF(DURATION = 0, 1, null)) fails, " +
* @param orgi // " count(IF(DURATION >= 60, 1, null)) gt60," +
* @return // " max(duration) maxduration, " +
*/ // " avg(duration) avgduration, " +
@Query(value = // " agentname " +
"select " + // "from uk_callcenter_event " +
" agent, " + // "where " +
" direction, " + // " status = '已挂机' " +
" count(IF(DIALPLAN is not null, 1, null)) dialplan, " + // " and datestr >= ?2" +
" count(*) total, " + // " and datestr < ?3" +
" sum(duration) seconds, " + // " and voicechannel = ?1" +
" count(IF(DURATION = 0, 1, null)) fails, " + // " and (?4 is null or organid = ?4) " +
" count(IF(DURATION >= 60, 1, null)) gt60," + // " and orgi = ?5" +
" max(duration) maxduration, " + // " and agent is not null " +
" avg(duration) avgduration, " + // "group by" +
" agentname " + // " agent," +
"from uk_callcenter_event " + // " direction", nativeQuery = true)
"where " + // List<Object[]> queryCalloutHangupAuditGroupByAgentAndDirection(String channel, String fromdate, String enddate, String organ, String orgi);
" status = '已挂机' " +
" and datestr >= ?2" + // /**
" and datestr < ?3" + // * 外呼计划通话记录接通记录查询
" and voicechannel = ?1" + // */
" and (?4 is null or organid = ?4) " + // @Query(value = "select s from StatusEvent s where (:fromdate is null or s.createtime >= :fromdate) " +
" and orgi = ?5" + // "and (:enddate is null or s.createtime < :enddate) " +
" and agent is not null " + // "and (:organid is null or s.organid = :organid) " +
"group by" + // "and (:agent is null or s.agent = :agent) " +
" agent," + // "and (:called is null or s.called = :called) " +
" direction", nativeQuery = true) // "and (:dialplan is null or s.dialplan = :dialplan) " +
List<Object[]> // "and s.direction = :direction " +
queryCalloutHangupAuditGroupByAgentAndDirection(String channel, // "and s.status = :status " +
String fromdate, // "and s.duration > 0 ")
String enddate, // Page<StatusEvent> queryCalloutDialplanSuccRecords(@Param("fromdate") Date fromdate,
String organ, // @Param("enddate") Date enddate,
String orgi); // @Param("organid") String organid,
// @Param("agent") String agentid,
/** // @Param("called") String called,
* 外呼计划通话记录接通记录查询 // @Param("direction") String direction,
* // @Param("status") String status,
* @param fromdate // @Param("dialplan") String dialplan,
* @param enddate // Pageable page);
* @param organid
* @param agentid // @Query(value = "select s " +
* @param called // "from StatusEvent s " +
* @param page // "where " +
* @return // " s.agent = :agent and " +
*/ // " s.siptrunk = :siptrunk and " +
@Query(value = "select s from StatusEvent s where (:fromdate is null or s.createtime >= :fromdate) " + // " s.status = :status " +
"and (:enddate is null or s.createtime < :enddate) " + // "order by s.createtime DESC")
"and (:organid is null or s.organid = :organid) " + // StatusEvent findByAgentAndSiptrunkAndStatus(@Param("agent") String agent, @Param("siptrunk") String siptrunk, @Param("status") String status);
"and (:agent is null or s.agent = :agent) " +
"and (:called is null or s.called = :called) " +
"and (:dialplan is null or s.dialplan = :dialplan) " + // /**
"and s.direction = :direction " + // * 外呼日报
"and s.status = :status " + // */
"and s.duration > 0 ") // @Query(value = "select dialplan, " +
Page<StatusEvent> queryCalloutDialplanSuccRecords(@Param("fromdate") Date fromdate, // "datestr, " +
@Param("enddate") Date enddate, // "count(*) as total, " +
@Param("organid") String organid, // "count(case duration when 0 then 1 else null end) fails, " +
@Param("agent") String agentid, // "sum(duration) as seconds " +
@Param("called") String called, // "from uk_callcenter_event " +
@Param("direction") String direction, // "where " +
@Param("status") String status, // "DIRECTION = ?3 " +
@Param("dialplan") String dialplan, // "and status = '已挂机' " +
Pageable page); // "and datestr = ?1 " +
// "and voicechannel = ?2 " +
@Query(value = "select s " + // "group by dialplan", nativeQuery = true)
"from StatusEvent s " + // List<Object[]> queryCallOutHangupAggsGroupByDialplanByDatestrAndChannelAndDirection(String datestr,
"where " + // String channel,
" s.agent = :agent and " + // String direction);
" s.siptrunk = :siptrunk and " +
" s.status = :status " + // int countByAgent(String agent);
"order by s.createtime DESC")
StatusEvent findByAgentAndSiptrunkAndStatus(@Param("agent") String agent, @Param("siptrunk") String siptrunk, @Param("status") String status); // int countByAniOrCalled(String ani, String called);
// int countByAni(String ani);
/**
* 外呼日报 // int countByCalled(String called);
* @param datestr }
* @param channel
* @param direction
* @return
*/
@Query(value = "select dialplan, " +
"datestr, " +
"count(*) as total, " +
"count(case duration when 0 then 1 else null end) fails, " +
"sum(duration) as seconds " +
"from uk_callcenter_event " +
"where " +
"DIRECTION = ?3 " +
"and status = '已挂机' " +
"and datestr = ?1 " +
"and voicechannel = ?2 " +
"group by dialplan", nativeQuery = true)
List<Object[]> queryCallOutHangupAggsGroupByDialplanByDatestrAndChannelAndDirection(String datestr,
String channel,
String direction);
int countByAgent(String agent);
int countByAniOrCalled(String ani, String called);
int countByAni(String ani);
int countByCalled(String called);
}

View File

@ -162,14 +162,14 @@ public class AgentServiceProxy {
} }
} else if (MainContext.ChannelType.PHONE.toString().equals(agentUser.getChannel())) { } else if (MainContext.ChannelType.PHONE.toString().equals(agentUser.getChannel())) {
if (agentService != null && StringUtils.isNotBlank(agentService.getOwner())) { if (agentService != null && StringUtils.isNotBlank(agentService.getOwner())) {
StatusEvent statusEvent = statusEventRes.findById(agentService.getOwner()); statusEventRes.findById(agentService.getOwner())
if (statusEvent != null) { .ifPresent(statusEvent -> {
if (StringUtils.isNotBlank(statusEvent.getHostid())) { if (StringUtils.isNotBlank(statusEvent.getHostid())) {
pbxHostRes.findById(statusEvent.getHostid()) pbxHostRes.findById(statusEvent.getHostid())
.ifPresent(it -> view.addObject("pbxHost", it)); .ifPresent(it -> view.addObject("pbxHost", it));
} }
view.addObject("statusEvent", statusEvent); view.addObject("statusEvent", statusEvent);
} });
MobileAddress ma = MobileNumberUtils.getAddress(agentUser.getPhone()); MobileAddress ma = MobileNumberUtils.getAddress(agentUser.getPhone());
view.addObject("mobileAddress", ma); view.addObject("mobileAddress", ma);
} }