Commit 204f82d3 authored by zhengjinlei's avatar zhengjinlei

客户画像命中3次以上,才打上标签

parent cc0572f8
......@@ -24,7 +24,7 @@ class OpenApi(viewsets.ViewSet):
logger.error('[phone_label]---invalid params')
return Response({'code': -1, 'msg': '请传入手机号'})
labels = []
profile = CustomProfile.objects.filter(phone_number=phone_num).first()
profile = CustomProfile.objects.filter(phone_number=phone_num, custom_labels__isnull=False).first()
if not profile:
return Response({'code': 0, 'msg': '查询成功', 'data': json.dumps(labels)})
if profile.custom_labels:
......
......@@ -27,11 +27,13 @@ class ProfileApi(viewsets.ViewSet):
if username in name_list:
logger.info('[profile_labels]获取的username是: %s', username)
region = username
condition = {}
condition = {'custom_labels__isnull': False}
if region and region != '安徽picc':
condition['region'] = region
profiles = CustomProfile.objects.filter(**condition).values('phone_number', 'region', 'call_recent',
'call_count', 'custom_labels')
profiles = CustomProfile.objects.filter(**condition).order_by('-call_recent').values('phone_number', 'region',
'call_recent',
'call_count',
'custom_labels')
paginator = Paginator(profiles, page_size)
total_count = paginator.count
try:
......
......@@ -46,6 +46,7 @@
prop="call_recent"
label="最近通话日期"
width="200"
:formatter="datetimeFormat"
>
</el-table-column>
<el-table-column
......
......@@ -203,8 +203,7 @@ def delete_stat_by_task(task):
ScoreStat.objects.filter(taskId=task.id).delete()
def save_custom_profile(task, check, name):
label = name.replace('[客户画像]', '')
def save_custom_profile(task, check, name, profile_count):
custom = check['customName'].split('&') if check['customName'] else []
region = task['name'].split('_')[0]
if custom:
......@@ -213,29 +212,32 @@ def save_custom_profile(task, check, name):
if custom_phone and len(custom_phone) > 11 and custom_phone.startswith('0'):
custom_phone = custom_phone[1:]
profile = CustomProfile.objects.filter(phone_number=custom_phone).first()
team = '未找到团队'
# team = team_seat().get(check['agentName'], '未找到团队')
# team = '未找到团队'
team = team_seat().get(check['agentName'], '未找到团队')
call_time = datetime.strptime(check['startTime'].replace('.0', ''), "%Y-%m-%d %H:%M:%S") if check['startTime'] \
else None
if profile:
profile.call_count += profile_count
if call_time:
profile.call_recent = call_time
profile.call_count += 1
if not profile.custom_labels:
profile.custom_labels = label
if label not in profile.custom_labels.split('、'):
profile.custom_labels += f'、{label}'
profile.save()
else:
profile = CustomProfile.objects.create(name=custom_name, phone_number=custom_phone,
call_recent=call_time,
call_count=1, custom_labels=label, region=region,
call_count=1, region=region,
create_at=datetime.now(), update_at=datetime.now())
if name and '[客户画像]' in name:
label = name.replace('[客户画像]', '')
CustomLabel.objects.create(profile_id=profile.id, call_time=call_time,
label=label, team=team, agent_name=check['agentName'], task_id=check['taskId'],
session_id=check['sessionId'], session_table_id=check['id'],
session_collection_id=task['sessionCollectionId'], create_at=datetime.now(),
update_at=datetime.now())
if CustomLabel.objects.filter(profile_id=profile.id, label=label).count() >= 3:
if not profile.custom_labels:
profile.custom_labels = label
if label not in profile.custom_labels.split('、'):
profile.custom_labels += f'、{label}'
profile.save()
def single_data_stat(t, create_date, stat_count=0):
......@@ -271,20 +273,22 @@ def single_data_stat(t, create_date, stat_count=0):
if result:
rules_list = []
data = json.loads(result)
profile_count = 1
for d in data:
if 'isViolation' in d.keys() and d['isViolation'] and 'rule' in d.keys() and 'name' in d['rule'].keys():
name = d['rule']['name']
name = name.replace('【', '[').replace('】', ']')
if name and '[客户画像]' in name:
if rule_stat_flag:
save_custom_profile(t, check, name)
else:
save_custom_profile(t, check, name, profile_count)
profile_count = 0
if name and '[客户画像]' not in name:
validate_rule_count += 1
if rule_stat_flag:
rule_obj = {'create_date': create_date, 'sessionCollectionId': t['sessionCollectionId'],
'rule': name, 'rule_num': 1,
'task': '未找到团队',
# 'task': team_seat().get(check['agentName'], '未找到团队'),
# 'task': '未找到团队',
'task': team_seat().get(check['agentName'], '未找到团队'),
'agentName': check['agentName'], 'customName': check['customName'],
'score': check['score'], 'remainTime': remain,
'taskId': check['taskId'], 'sessionId': check['sessionId'],
......@@ -303,8 +307,8 @@ def single_data_stat(t, create_date, stat_count=0):
else:
seat_dict[check['agentName']] = {'create_date': create_date, 'agentName': check['agentName'],
'taskId': check['taskId'],
'task': '未找到团队',
# 'task': team_seat().get(check['agentName'], '未找到团队'),
# 'task': '未找到团队',
'task': team_seat().get(check['agentName'], '未找到团队'),
'sessionCollectionId': t['sessionCollectionId'],
'total_session': 1}
seat_dict[check['agentName']]['validate_session'] = 1 if validate_rule_count > 0 else 0
......@@ -339,8 +343,8 @@ def single_data_stat(t, create_date, stat_count=0):
else:
score_dict[check['agentName']] = {'create_date': create_date, 'agentName': check['agentName'],
'taskId': check['taskId'],
'task': '未找到团队',
# 'task': team_seat().get(check['agentName'], '未找到团队'),
# 'task': '未找到团队',
'task': team_seat().get(check['agentName'], '未找到团队'),
'sessionCollectionId': t['sessionCollectionId'], 'total_session': 1,
'score': score, 'service_score': service_score,
'business_score': business_score, 'validate_zero': validate_zero}
......
new Vue({
el: '#childApp',
data:function(){
data: function () {
return {
ss:'sas',
ss: 'sas',
dateTime: '',
cityList:[],
countryList:[],
teamList:[],
cityList: [],
countryList: [],
teamList: [],
cityvalue: '',
countryvalue: '',
teamvalue: '',
......@@ -14,7 +14,7 @@ new Vue({
team_show: true,
start_date: '',
isscrollTop: false,
currentPage:1,
currentPage: 1,
pagesize: 10,
total: 10,
poppage: 1,
......@@ -25,12 +25,12 @@ new Vue({
popcurrentPage: 1,
isHidePage: true,
scrollTop: 0,
end_date:'',
end_date: '',
poploading: false,
BASEURL: window_url,
dialogTableVisible: false,
takeList:[],
dateRange:[new Date(), new Date()],
takeList: [],
dateRange: [new Date(), new Date()],
loading: true,
poptableData: [],
tableData: []
......@@ -43,7 +43,7 @@ new Vue({
this.cityvalue = msg;
this.getProfile(); // 获取统计数据
},
getCity(){
getCity() {
let that = this;
var request = new XMLHttpRequest();
......@@ -54,7 +54,7 @@ new Vue({
if (request.status === 200) {
data = JSON.parse(request.response);
console.log(data.code);
if(data.code != 0){
if (data.code != 0) {
that.$message('服务器错误');
} else {
that.cityList = data.data.city_list;
......@@ -104,6 +104,24 @@ new Vue({
dateFormat(date) {
return date.getFullYear() + "-" + (date.getMonth() + 1) + "-" + date.getDate();
},
datetimeFormat(row, column) {
let data = row[column.property];
if(data == null) {
return null
}
let dt = new Date(data);
let month = dt.getMonth() + 1;
month = month.toString().length === 1 ? ('0' + month.toString()) : month.toString();
let day = dt.getDate();
day = day.toString().length === 1 ? ('0' + day.toString()) : day.toString();
let hh = dt.getHours();
hh = hh.toString().length === 1 ? ('0' + hh.toString()) : hh.toString();
let mm = dt.getMinutes();
mm = mm.toString().length === 1 ? ('0' + mm.toString()) : mm.toString();
let ss = dt.getSeconds();
ss = ss.toString().length === 1 ? ('0' + ss.toString()) : ss.toString();
return dt.getFullYear() + '-' + month + '-' + day + ' ' + hh + ':' + mm + ':' + ss
},
init() {
this.getCity(); // 获取任务
this.getProfile(); // 获取统计数据
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment