call detail record controller

This commit is contained in:
Shaun Chyxion 2021-12-05 23:50:57 +08:00
parent 61a4c5f912
commit 80a6780857
10 changed files with 204 additions and 46 deletions

View File

@ -4,6 +4,7 @@ import org.apache.ibatis.annotations.Param;
import me.chyxion.tigon.mybatis.BaseMapper;
import com.pudonghot.yo.model.domain.CallDetailRecord;
import com.pudonghot.yo.model.domain.CallDetailRecordBase;
import com.pudonghot.yo.mapper.response.CallDetailRecordDailyQueryDbResp;
/**
* @author Donghuang <br>
@ -37,4 +38,22 @@ public interface CallDetailRecordMapper extends BaseMapper<Integer, CallDetailRe
* @return delete row
*/
int deleteExpired();
/**
* daily query by case key
*
* @param tenantId tenant id
* @param caseKey case key
* @return resp
*/
CallDetailRecordDailyQueryDbResp dailyQueryByCaseKey(@Param("tenantId") Integer tenantId, @Param("caseKey") String caseKey);
/**
* daily query by phone
*
* @param tenantId tenant id
* @param called called
* @return resp
*/
CallDetailRecordDailyQueryDbResp dailyQueryByPhone(@Param("tenantId") Integer tenantId, @Param("calledNumber") String called);
}

View File

@ -42,4 +42,25 @@
start_stamp < date(now() - interval 31 day)
]]>
</delete>
<select id="dailyQueryByCaseKey" resultType="com.pudonghot.yo.mapper.response.CallDetailRecordDailyQueryDbResp">
select count(1) total,
count(r.answer_stamp) answered
from br_call_detail_record r
where r.tenant_id = #{tenantId}
and r.case_key = #{caseKey}
and r.start_stamp between date(now())
and date(now() + interval 1 day)
</select>
<select id="dailyQueryByPhone" resultType="com.pudonghot.yo.mapper.response.CallDetailRecordDailyQueryDbResp">
select count(1) total,
count(r.answer_stamp) answered
from br_call_detail_record r
where r.tenant_id = #{tenantId}
and r.called_number = #{calledNumber}
and r.start_stamp between date(now())
and date(now() + interval 1 day)
</select>
</mapper>

View File

@ -0,0 +1,20 @@
package com.pudonghot.yo.mapper.response;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import java.io.Serializable;
/**
* @author Donghuang
* @date Dec 05, 2021 23:04:17
*/
@Setter
@Getter
@ToString
public class CallDetailRecordDailyQueryDbResp implements Serializable {
private static final long serialVersionUID = 1L;
private Integer total;
private Integer answered;
}

View File

@ -96,4 +96,10 @@ public class CallDetailRecordMapperTest {
public void testDeleteExpired() {
mapper.deleteExpired();
}
@Test
public void testQuery() {
mapper.dailyQueryByCaseKey(1, "XXX");
mapper.dailyQueryByPhone(1, "XXX");
}
}

View File

@ -1,46 +0,0 @@
package com.pudonghot.yo.fsagent.service.request;
import lombok.Getter;
import lombok.Setter;
import java.util.Date;
import lombok.ToString;
import java.io.Serializable;
/**
* @author Donghuang
* @date Sep 08, 2021 10:50:55
*/
@Setter
@Getter
@ToString
public class CallDetailtRecordCreateServReq implements Serializable {
private static final long serialVersionUID = 1L;
private Integer tenantId;
private String tenantCode;
private String account;
private String connId;
private String dialType;
private String callType;
private String agentType;
private Integer campaignId;
private String caseKey;
private String uuid;
private String callUuid;
private String sipCallId;
private String callerNumber;
private String calledNumber;
private Integer trunkId;
private String callingPartyNumber;
private Date startStamp;
private Date answerStamp;
private Date endStamp;
private Long duration;
private Long mduration;
private Long billsec;
private Long billmsec;
private String endpointDisposition;
private String hangupCause;
private String hangupDisposition;
}

View File

@ -0,0 +1,42 @@
package com.pudonghot.yo.openapi.controller;
import lombok.extern.slf4j.Slf4j;
import com.wacai.tigon.json.JsonService;
import javax.validation.constraints.NotBlank;
import org.springframework.stereotype.Controller;
import com.pudonghot.yo.openapi.auth.SessionAbility;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.beans.factory.annotation.Autowired;
import com.pudonghot.yo.openapi.service.CallDetailRecordService;
import com.pudonghot.yo.openapi.response.CallDetailRecordDailyQueryCtrlrResp;
/**
* @author Donghuang
* @date Dec 05, 2021 22:57:16
*/
@Slf4j
@Controller
@RequestMapping("/resource/cdr")
public class CallDetailRecordController implements SessionAbility {
@Autowired
private CallDetailRecordService service;
@Autowired
private JsonService jsonService;
@RequestMapping("/case-daily-report")
public CallDetailRecordDailyQueryCtrlrResp caseDailyReport(
@NotBlank
@RequestParam("caseKey")
final String caseKey) {
return jsonService.convert(service.dailyQueryByCaseKey(getTenantId(), caseKey), CallDetailRecordDailyQueryCtrlrResp.class);
}
@RequestMapping("/number-daily-report")
public CallDetailRecordDailyQueryCtrlrResp numberDailyReport(
@NotBlank
@RequestParam("number")
final String number) {
return jsonService.convert(service.dailyQueryByPhone(getTenantId(), number), CallDetailRecordDailyQueryCtrlrResp.class);
}
}

View File

@ -0,0 +1,20 @@
package com.pudonghot.yo.openapi.response;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import java.io.Serializable;
/**
* @author Donghuang
* @date Dec 05, 2021 23:22:49
*/
@Setter
@Getter
@ToString
public class CallDetailRecordDailyQueryCtrlrResp implements Serializable {
private static final long serialVersionUID = 1L;
private Integer total;
private Integer answered;
}

View File

@ -0,0 +1,16 @@
package com.pudonghot.yo.openapi.service;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.NotBlank;
import com.pudonghot.yo.openapi.service.response.CallDetailRecordDailyQueryServResp;
/**
* @author Donghuang
* @date Jul 13, 2020 10:24:57
*/
public interface CallDetailRecordService {
CallDetailRecordDailyQueryServResp dailyQueryByCaseKey(@NotNull Integer tenantId, @NotBlank String caseKey);
CallDetailRecordDailyQueryServResp dailyQueryByPhone(@NotNull Integer tenantId, @NotBlank String called);
}

View File

@ -0,0 +1,40 @@
package com.pudonghot.yo.openapi.service.impl;
import lombok.extern.slf4j.Slf4j;
import com.wacai.tigon.json.JsonService;
import org.springframework.stereotype.Service;
import com.pudonghot.yo.mapper.CallDetailRecordMapper;
import org.springframework.beans.factory.annotation.Autowired;
import com.pudonghot.yo.openapi.service.CallDetailRecordService;
import com.pudonghot.yo.openapi.service.response.CallDetailRecordDailyQueryServResp;
/**
* @author Donghuang
* @date Jul 13, 2020 10:25:41
*/
@Slf4j
@Service
public class CallDetailRecordServiceImpl
implements CallDetailRecordService {
@Autowired
private CallDetailRecordMapper mapper;
@Autowired
private JsonService jsonService;
/**
* {@inheritDoc}
*/
@Override
public CallDetailRecordDailyQueryServResp dailyQueryByCaseKey(final Integer tenantId, final String caseKey) {
return jsonService.convert(mapper.dailyQueryByCaseKey(tenantId, caseKey), CallDetailRecordDailyQueryServResp.class);
}
/**
* {@inheritDoc}
*/
@Override
public CallDetailRecordDailyQueryServResp dailyQueryByPhone(final Integer tenantId, final String called) {
return jsonService.convert(mapper.dailyQueryByPhone(tenantId, called), CallDetailRecordDailyQueryServResp.class);
}
}

View File

@ -0,0 +1,20 @@
package com.pudonghot.yo.openapi.service.response;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import java.io.Serializable;
/**
* @author Donghuang
* @date Dec 05, 2021 23:04:17
*/
@Setter
@Getter
@ToString
public class CallDetailRecordDailyQueryServResp implements Serializable {
private static final long serialVersionUID = 1L;
private Integer total;
private Integer answered;
}