整体启动
main.py
通过多线程同时进行三个任务 (确保每个环境只有一个进程在运行)
nohup python main.py&
相关配置
配置写在文件 db.conf中
只需要根据运行环境更改数据库的配置名称即可,如:
oa = operationActivity.OperationActivity(“database_dev”) // 192
oa = operationActivity.OperationActivity(“database_prd”) // 125
1 | # !/Users/xieqj/py_env/venv python |
资讯推送
读取表 sns_qa_push_setting 中的资讯,将其按照region,industry,func(职能)推送给对应群组的用户。
具体方法就是将表 sns_qa_push_setting 中的 content 1对1的推送给表 account_basic 中对应群组的用户,即插入 message_queue 表。
需要注意控制推送时间,和在推送后 update 表 sns_qa_push_setting 中 status 字段
仓库位置
git@192.168.30.251:message_handling.git
{“messagetype”: 230,”params”: { “data”: [{“newsid”: “ EwtNMSASOSvxjerhni98uQyEXnDIp9fS”,”title”: “发布到审核”,”url”: “资讯 URL”, “coverurl”: “https: //oradtdev.s3.cn-north- 1.amazonaws.com.cn/ukIv0BqxtnjRgjuhJcGKO6jze1liPmZE/gm9YtnBtvQ20160921132139.jpg”,”createdtime”: “1474435299” } ]}}
数据表
1 | CREATE TABLE `industry_category` ( |
用户推广
基本流程与咨询推送相同
仓库位置
git@192.168.30.251:message_handling.git
git@192.168.30.251:effective.git
userPromotion.py
推广表
1 | CREATE TABLE `sys_user_promotion` ( |
活动管理
背景说明
系统中,内容管理-推送、运营管理-新增推广、运营管理-新增活动页面中,地区、行业、职能选择时,弹窗样式与“内容管理-推送”样式相同,具体请参见原型
进行推送时,匹配规则如下:
a) 行业:第一次使用APP时所选行业+当前默认身份的并集。采用1级行业-2级行业模式划分
b) 地区:第一次使用APP时所选手机号+当前默认身份的并集。采用1级地区-2级地区模式划分
c) 职能:当前默认身份。采用1级行业-职能(只有1级)模式划分
当前默认身份cardid需要通过表 account_basic_detail 的 card_id 字段得到
业务流程
仓库位置
git@192.168.30.251:message_handling.git
OperationActivity
活动表结构
1 | CREATE TABLE `operation_activity` ( |
带推送消息查询语句
资讯推送
select id,FROM_UNIXTIME(push_time) as push_time,status,region,industry,func,admin_id,content from oradt_cloud_test2.sns_qa_push_setting
where status
<> 2 and industry != ‘’ and func != ‘’ and region != ‘’
and ROUND((UNIX_TIMESTAMP(SYSDATE()) - push_time)/60) >= -2;
用户推广
select id,FROM_UNIXTIME(push_time) as push_time,status,region,industry,func,admin_id,title,json_data from oradt_cloud_test2.sys_user_promotion
where status
<> 2 and industry != ‘’ and func != ‘’ and region != ‘’
and ROUND((UNIX_TIMESTAMP(SYSDATE()) - push_time)/60) >= -2;
活动推广
select id,push_state, region, industry, func, title, json_data, user_id from oradt_cloud_test2.operation_activity
where push_state <> 2 and industry != ‘’ and func != ‘’ and region != ‘’ and ROUND((UNIX_TIMESTAMP(SYSDATE()) - push_time)/60) >= -2;
部署情况
125仿真环境
部署在IDC 云主机 /home/xieqj/python2.7_scenario/fangzhen
1 | 0 */1 * * * python2.7 /home/xieqj/python2.7_scenario/fangzhen/CardDeduplication/CardDeduplication3366.py |
名片去重 60分钟运行一次
名片异常 5分钟运行一次
人脉更新 60分钟运行一次
消息推送 main.py 60分钟一次
python2.7 运行的是125 3366端口
python2.7 message_handling/main.py (消息推送)
python2.7 CardDeduplication/CardDeduplication.py
python2.7 CardExceptionHandling/CardException.py
python2.7 cardUpdateNotification/CardUpdateNote.py
python 运行的是3388端口
python CardDeduplication.py
python CardException.py
AWS
部署在ec2 54.223.28.1191
0 0 */1 * * python2.7 /home/ec2-user/namecard/CardDeduplication/CardDeduplication_aws.py
名片异常 每5分钟运行一次
名片去重 每24小时运行一次
用户推广 每1分钟运行一次
消息推送 每1分钟运行一次