Commit 204f82d3 authored by zhengjinlei's avatar zhengjinlei

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

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