You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
60 lines
2.6 KiB
60 lines
2.6 KiB
# -*- coding: utf-8 -*-
|
|
# t11-final.py — 票 11 终验:owner_dept_id 全量落值 + 子表计数(只读)
|
|
import io, sys
|
|
sys.stdout = io.TextIOWrapper(sys.stdout.buffer, encoding='utf-8')
|
|
import pymysql
|
|
conn = pymysql.connect(host='8.129.84.155', port=3306, user='root', password='Itc@123456',
|
|
database='crm', charset='utf8mb4')
|
|
cur = conn.cursor()
|
|
|
|
print('== 商机 owner_dept_id 落值盘点 ==')
|
|
cur.execute("SELECT opp_name, opp_status, owner_dept_id, owner_user_id IS NULL FROM opportunity "
|
|
"ORDER BY opp_name")
|
|
null_dept = 0
|
|
for name, st, dept, owner_null in cur.fetchall():
|
|
flag = '' if dept else ' ←⚠ owner_dept_id 为空'
|
|
if not dept:
|
|
null_dept += 1
|
|
print(f' {name} status={st} dept={dept}{flag}')
|
|
print(f' owner_dept_id 为空行数: {null_dept}')
|
|
|
|
print('== 子表计数 ==')
|
|
for t in ('opportunity_customer', 'opportunity_team', 'opportunity_follow',
|
|
'opportunity_site_survey', 'opportunity_scheme_card'):
|
|
cur.execute(f'SELECT COUNT(*) FROM {t}')
|
|
print(f' {t}: {cur.fetchone()[0]}')
|
|
|
|
print('== a2 团队成员明细(快照回显验证)==')
|
|
cur.execute("SELECT o.opp_name, t.user_id, t.user_name_snapshot, t.project_role, t.permission "
|
|
"FROM opportunity_team t JOIN opportunity o ON o.id=t.opportunity_id "
|
|
"WHERE o.opp_name LIKE '%%A-推进%%' ORDER BY t.id")
|
|
for r in cur.fetchall():
|
|
print(' ', r)
|
|
|
|
print('== a2 主要意向客户(set-primary 切换后)==')
|
|
cur.execute("SELECT o.opp_name, o.primary_customer_name_snapshot, c.customer_name_snapshot, c.is_primary_intended "
|
|
"FROM opportunity o JOIN opportunity_customer c ON c.opportunity_id=o.id "
|
|
"WHERE o.opp_name LIKE '%%A-推进-智慧园区二期%%'")
|
|
for r in cur.fetchall():
|
|
print(' ', r)
|
|
|
|
print('== a3 长期暂缓样例 ==')
|
|
cur.execute("SELECT opp_name, opp_status, pause_expected_restart_date, pause_remark FROM opportunity "
|
|
"WHERE opp_name LIKE '%%A-暂缓%%'")
|
|
for r in cur.fetchall():
|
|
print(' ', r)
|
|
|
|
print('== 发布中公海规则 ==')
|
|
cur.execute("SELECT rule_name, apply_scope, is_default, allow_free_claim, auto_recycle_enabled "
|
|
"FROM opportunity_pool_rule WHERE status=2")
|
|
for r in cur.fetchall():
|
|
print(' ', r)
|
|
cur.execute("SHOW COLUMNS FROM opportunity_pool_rule_dept")
|
|
print(' pool_rule_dept 列:', [r[0] for r in cur.fetchall()])
|
|
cur.execute("SELECT d.dept_id, r.rule_name FROM opportunity_pool_rule_dept d "
|
|
"JOIN opportunity_pool_rule r ON r.id = d.rule_version_id WHERE r.status=2")
|
|
for r in cur.fetchall():
|
|
print(' dept绑定:', r)
|
|
|
|
conn.close()
|
|
print('done')
|
|
|