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

@ -21,146 +21,117 @@ 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;
import java.util.Date;
import java.util.List;
public interface StatusEventRepository extends JpaRepository<StatusEvent, String> { public interface StatusEventRepository extends JpaRepository<StatusEvent, String> {
StatusEvent findById(String id); // StatusEvent findById(String id);
StatusEvent findByIdOrBridgeid(String id, String bridgeid); // StatusEvent findByIdOrBridgeid(String id, String bridgeid);
Page<StatusEvent> findByAni(String ani, Pageable page); // Page<StatusEvent> findByAni(String ani, Pageable page);
Page<StatusEvent> findByNameid(String nameid, Pageable page); // Page<StatusEvent> findByNameid(String nameid, Pageable page);
Page<StatusEvent> findByDataid(String dataid, Pageable page); // Page<StatusEvent> findByDataid(String dataid, Pageable page);
Page<StatusEvent> findByOrgi(String orgi, Pageable page); Page<StatusEvent> findByOrgi(String orgi, Pageable page);
Page<StatusEvent> findByServicestatusAndOrgi(String servicestatus, String orgi, Pageable page); // Page<StatusEvent> findByServicestatusAndOrgi(String servicestatus, String orgi, Pageable page);
Page<StatusEvent> findByMisscallAndOrgi(boolean misscall, String orgi, Pageable page); // Page<StatusEvent> findByMisscallAndOrgi(boolean misscall, String orgi, Pageable page);
Page<StatusEvent> findByRecordAndOrgi(boolean record, String orgi, Pageable page); // Page<StatusEvent> findByRecordAndOrgi(boolean record, String orgi, Pageable page);
Page<StatusEvent> findByCalledAndOrgi(String voicemail, String orgi, Pageable page); // Page<StatusEvent> findByCalledAndOrgi(String voicemail, String orgi, Pageable page);
Page<StatusEvent> findAll(Specification<StatusEvent> spec, Pageable pageable); //分页按条件查询 Page<StatusEvent> findAll(Specification<StatusEvent> spec, Pageable pageable); //分页按条件查询
/** // /**
* 坐席报表 // * 坐席报表
* @param channel // */
* @param fromdate // @Query(value =
* @param enddate // "select " +
* @param organ // " agent, " +
* @param orgi // " direction, " +
* @return // " count(IF(DIALPLAN is not null, 1, null)) dialplan, " +
*/ // " count(*) total, " +
@Query(value = // " sum(duration) seconds, " +
"select " + // " count(IF(DURATION = 0, 1, null)) fails, " +
" agent, " + // " count(IF(DURATION >= 60, 1, null)) gt60," +
" direction, " + // " max(duration) maxduration, " +
" count(IF(DIALPLAN is not null, 1, null)) dialplan, " + // " avg(duration) avgduration, " +
" count(*) total, " + // " agentname " +
" sum(duration) seconds, " + // "from uk_callcenter_event " +
" count(IF(DURATION = 0, 1, null)) fails, " + // "where " +
" count(IF(DURATION >= 60, 1, null)) gt60," + // " status = '已挂机' " +
" max(duration) maxduration, " + // " and datestr >= ?2" +
" avg(duration) avgduration, " + // " and datestr < ?3" +
" agentname " + // " and voicechannel = ?1" +
"from uk_callcenter_event " + // " and (?4 is null or organid = ?4) " +
"where " + // " and orgi = ?5" +
" status = '已挂机' " + // " and agent is not null " +
" and datestr >= ?2" + // "group by" +
" and datestr < ?3" + // " agent," +
" and voicechannel = ?1" + // " direction", nativeQuery = true)
" and (?4 is null or organid = ?4) " + // List<Object[]> queryCalloutHangupAuditGroupByAgentAndDirection(String channel, String fromdate, String enddate, String organ, String orgi);
" and orgi = ?5" +
" and agent is not null " +
"group by" +
" agent," +
" direction", nativeQuery = true)
List<Object[]>
queryCalloutHangupAuditGroupByAgentAndDirection(String channel,
String fromdate,
String enddate,
String organ,
String orgi);
/** // /**
* 外呼计划通话记录接通记录查询 // * 外呼计划通话记录接通记录查询
* // */
* @param fromdate // @Query(value = "select s from StatusEvent s where (:fromdate is null or s.createtime >= :fromdate) " +
* @param enddate // "and (:enddate is null or s.createtime < :enddate) " +
* @param organid // "and (:organid is null or s.organid = :organid) " +
* @param agentid // "and (:agent is null or s.agent = :agent) " +
* @param called // "and (:called is null or s.called = :called) " +
* @param page // "and (:dialplan is null or s.dialplan = :dialplan) " +
* @return // "and s.direction = :direction " +
*/ // "and s.status = :status " +
@Query(value = "select s from StatusEvent s where (:fromdate is null or s.createtime >= :fromdate) " + // "and s.duration > 0 ")
"and (:enddate is null or s.createtime < :enddate) " + // Page<StatusEvent> queryCalloutDialplanSuccRecords(@Param("fromdate") Date fromdate,
"and (:organid is null or s.organid = :organid) " + // @Param("enddate") Date enddate,
"and (:agent is null or s.agent = :agent) " + // @Param("organid") String organid,
"and (:called is null or s.called = :called) " + // @Param("agent") String agentid,
"and (:dialplan is null or s.dialplan = :dialplan) " + // @Param("called") String called,
"and s.direction = :direction " + // @Param("direction") String direction,
"and s.status = :status " + // @Param("status") String status,
"and s.duration > 0 ") // @Param("dialplan") String dialplan,
Page<StatusEvent> queryCalloutDialplanSuccRecords(@Param("fromdate") Date fromdate, // Pageable page);
@Param("enddate") Date enddate,
@Param("organid") String organid,
@Param("agent") String agentid,
@Param("called") String called,
@Param("direction") String direction,
@Param("status") String status,
@Param("dialplan") String dialplan,
Pageable page);
@Query(value = "select s " + // @Query(value = "select s " +
"from StatusEvent s " + // "from StatusEvent s " +
"where " + // "where " +
" s.agent = :agent and " + // " s.agent = :agent and " +
" s.siptrunk = :siptrunk and " + // " s.siptrunk = :siptrunk and " +
" s.status = :status " + // " s.status = :status " +
"order by s.createtime DESC") // "order by s.createtime DESC")
StatusEvent findByAgentAndSiptrunkAndStatus(@Param("agent") String agent, @Param("siptrunk") String siptrunk, @Param("status") String status); // StatusEvent findByAgentAndSiptrunkAndStatus(@Param("agent") String agent, @Param("siptrunk") String siptrunk, @Param("status") String status);
/** // /**
* 外呼日报 // * 外呼日报
* @param datestr // */
* @param channel // @Query(value = "select dialplan, " +
* @param direction // "datestr, " +
* @return // "count(*) as total, " +
*/ // "count(case duration when 0 then 1 else null end) fails, " +
@Query(value = "select dialplan, " + // "sum(duration) as seconds " +
"datestr, " + // "from uk_callcenter_event " +
"count(*) as total, " + // "where " +
"count(case duration when 0 then 1 else null end) fails, " + // "DIRECTION = ?3 " +
"sum(duration) as seconds " + // "and status = '已挂机' " +
"from uk_callcenter_event " + // "and datestr = ?1 " +
"where " + // "and voicechannel = ?2 " +
"DIRECTION = ?3 " + // "group by dialplan", nativeQuery = true)
"and status = '已挂机' " + // List<Object[]> queryCallOutHangupAggsGroupByDialplanByDatestrAndChannelAndDirection(String datestr,
"and datestr = ?1 " + // String channel,
"and voicechannel = ?2 " + // String direction);
"group by dialplan", nativeQuery = true)
List<Object[]> queryCallOutHangupAggsGroupByDialplanByDatestrAndChannelAndDirection(String datestr,
String channel,
String direction);
int countByAgent(String agent); // int countByAgent(String agent);
int countByAniOrCalled(String ani, String called); // int countByAniOrCalled(String ani, String called);
int countByAni(String ani); // int countByAni(String ani);
int countByCalled(String called);
// 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);
} }