uuid生成随机数据 :str(uuid.uuid1())
时间戳化成字符串:timeStr=time.strftime("%Y-%m-%d %H:%M:%S", time.localtime(时间戳))
日期格式化,前面补0显示:str(start_day).zfill(2)
写文件,追加的方式: f = open (tmp_dir+'/partition_1', "a")
print >>f,data
f.close()
=========================================
#!/usr/local/bin/python
#-*- coding: utf-8 -*-
import uuid
import time
from datetime import datetime
appid = 2379 
myuuid = str(uuid.uuid1())
appv1="5.9.1(appv1)"
appv2="5.9.1(appv2)"
appv1_id = 2830 
channel1="QuDao_ver1"
channel2="QuDao_ver2"
channel3="QuDao_ver3"
channel1_id = 2831
start_day = 4
start_month = 6
start_m_days = 30
calc_days = 2
## 设置构造数据从哪一天开始, 这一天的设备全是新增,后面的设备全是活跃, 这个时间不要取当天的零点。会导致 conMonitorTime 和monitorTime 不在同一天,建议写成 开始当天的 6点
pre_date_start = 1559599200000
#timeStr=time.strftime("%Y-%m-%d %H:%M:%S", time.localtime(date_start/1000+60*60*24))
#print( timeStr)
#用户访问类型,1.活跃,2,新增,3,升级
userAccessType = 2
per_device = "linlh_20190604"
device_pre = per_device +"_appv1_channel1_"
tmp_data_dir = '/data/linlh/tmp/action_data/2019/'
import os
def mkdir(path):
    if not os.path.isdir(path):
        mkdir(os.path.split(path)[0])
    else:
        return
    os.mkdir(path)
def construct_new_data(pre_date_start,start_day,start_month,start_m_days,calc_days):
	userAccessType = 2
	tmp_dir = tmp_data_dir +str(start_month).zfill(2)+'/'+str(start_day).zfill(2)+'/06'
	mkdir( tmp_dir )
	f = open(tmp_dir+"/partition_0", "a")
## 构造新增当天的数据
#   appV1,  channel1 , 设备ID:0-9
	appVerid = appv1_id
	appname = appv1
	channel_id = channel1_id 
	date_start = pre_date_start
	device_pre = per_device +"_appv1_channel1_"
	for i in range(60):
		data = "{\"accessModelId\":7,\"activityEtime\":0,\"activityId\":\"\",\"activityIdIsURL\":0,\"activityName\":\"\",\"activityStime\":0,\"appId\":"+str(appid)+",\"appMemory\":4096.0,\"appVersionId\":"+str(appVerid)+",\"appVersionName\":\""+appname+"\",\"c
hannelId\":"+str(channel_id)+",\"cityCode\":1102100,\"clientIp\":\"112.224.2.90\",\"conMonitorTime\":"+str(date_start-1000*3*60)+",\"deviceId\":\""+device_pre+str(i)+"\",\"displaySize\":\"1080*1776\",\"eventId\":0,\"fragmentName\":\"\",\"isQuit\":0,\"kv\":\"a,b\",\"la
ble\":\"\",\"lastExTime\":0,\"mobileUsage\":2070.0,\"model\":1910,\"monitorTime\":"+str(date_start)+",\"netServiceId\":2,\"netServiceName\":\"联通\",\"osVersionId\":1621,\"parentActionActivityId\":\"\",\"sessionId\":\"\",\"sessionName\":\"\",\"statmainId\":\"4:2:"+str
(uuid.uuid1())+"\",\"stayingTime\":0,\"timeCallTimeUs\":6000000,\"userAccessType\":"+str(userAccessType)+",\"userTrackStime\":0,\"worth\":0.0}"
		print >>f,data
	device_pre = per_device +"_appv1_channel2_"
	channel_id = channel1_id +1
	for i in range(70):
		data = "{\"accessModelId\":7,\"activityEtime\":0,\"activityId\":\"\",\"activityIdIsURL\":0,\"activityName\":\"\",\"activityStime\":0,\"appId\":"+str(appid)+",\"appMemory\":4096.0,\"appVersionId\":"+str(appVerid)+",\"appVersionName\":\""+appname+"\",\"c
hannelId\":"+str(channel_id)+",\"cityCode\":1102100,\"clientIp\":\"112.224.2.90\",\"conMonitorTime\":"+str(date_start-1000*3*60)+",\"deviceId\":\""+device_pre+str(i)+"\",\"displaySize\":\"1080*1776\",\"eventId\":0,\"fragmentName\":\"\",\"isQuit\":0,\"kv\":\"a,b\",\"la
ble\":\"\",\"lastExTime\":0,\"mobileUsage\":2070.0,\"model\":1910,\"monitorTime\":"+str(date_start)+",\"netServiceId\":2,\"netServiceName\":\"联通\",\"osVersionId\":1621,\"parentActionActivityId\":\"\",\"sessionId\":\"\",\"sessionName\":\"\",\"statmainId\":\"4:2:"+str
(uuid.uuid1())+"\",\"stayingTime\":0,\"timeCallTimeUs\":6000000,\"userAccessType\":"+str(userAccessType)+",\"userTrackStime\":0,\"worth\":0.0}"
		print >>f,data
	device_pre = per_device +"_appv1_channel3_"
	channel_id = channel1_id+2
	appVerid =  appv1_id
	appname = appv1
	for i in range(80):
			data = "{\"accessModelId\":7,\"activityEtime\":0,\"activityId\":\"\",\"activityIdIsURL\":0,\"activityName\":\"\",\"activityStime\":0,\"appId\":"+str(appid)+",\"appMemory\":4096.0,\"appVersionId\":"+str(appVerid)+",\"appVersionName\":\""+appname
+"\",\"channelId\":"+str(channel_id)+",\"cityCode\":1102100,\"clientIp\":\"112.224.2.90\",\"conMonitorTime\":"+str(date_start-1000*3*60)+",\"deviceId\":\""+device_pre+str(i)+"\",\"displaySize\":\"1080*1776\",\"eventId\":0,\"fragmentName\":\"\",\"isQuit\":0,\"kv\":\"a,
b\",\"lable\":\"\",\"lastExTime\":0,\"mobileUsage\":2070.0,\"model\":1910,\"monitorTime\":"+str(date_start)+",\"netServiceId\":2,\"netServiceName\":\"联通\",\"osVersionId\":1621,\"parentActionActivityId\":\"\",\"sessionId\":\"\",\"sessionName\":\"\",\"statmainId\":\"4
:2:"+str(uuid.uuid1())+"\",\"stayingTime\":0,\"timeCallTimeUs\":6000000,\"userAccessType\":"+str(userAccessType)+",\"userTrackStime\":0,\"worth\":0.0}"
			print >>f,data
	device_pre = per_device +"_appv2_channel1_"
	appVerid =  appv1_id+1
	appname = appv2
	channel_id = channel1_id
	for i in range(50):
			data = "{\"accessModelId\":7,\"activityEtime\":0,\"activityId\":\"\",\"activityIdIsURL\":0,\"activityName\":\"\",\"activityStime\":0,\"appId\":"+str(appid)+",\"appMemory\":4096.0,\"appVersionId\":"+str(appVerid)+",\"appVersionName\":\""+appname
+"\",\"channelId\":"+str(channel_id)+",\"cityCode\":1102100,\"clientIp\":\"112.224.2.90\",\"conMonitorTime\":"+str(date_start-1000*3*60)+",\"deviceId\":\""+device_pre+str(i)+"\",\"displaySize\":\"1080*1776\",\"eventId\":0,\"fragmentName\":\"\",\"isQuit\":0,\"kv\":\"a,
b\",\"lable\":\"\",\"lastExTime\":0,\"mobileUsage\":2070.0,\"model\":1910,\"monitorTime\":"+str(date_start)+",\"netServiceId\":2,\"netServiceName\":\"联通\",\"osVersionId\":1621,\"parentActionActivityId\":\"\",\"sessionId\":\"\",\"sessionName\":\"\",\"statmainId\":\"4
:2:"+str(uuid.uuid1())+"\",\"stayingTime\":0,\"timeCallTimeUs\":6000000,\"userAccessType\":"+str(userAccessType)+",\"userTrackStime\":0,\"worth\":0.0}"
			print >>f,data
	device_pre = per_device +"_appv2_channel2_"
	appVerid =  appv1_id+1
	appname = appv2
	channel_id = channel1_id +1
	for i in range(60):
			data = "{\"accessModelId\":7,\"activityEtime\":0,\"activityId\":\"\",\"activityIdIsURL\":0,\"activityName\":\"\",\"activityStime\":0,\"appId\":"+str(appid)+",\"appMemory\":4096.0,\"appVersionId\":"+str(appVerid)+",\"appVersionName\":\""+appname
+"\",\"channelId\":"+str(channel_id)+",\"cityCode\":1102100,\"clientIp\":\"112.224.2.90\",\"conMonitorTime\":"+str(date_start-1000*3*60)+",\"deviceId\":\""+device_pre+str(i)+"\",\"displaySize\":\"1080*1776\",\"eventId\":0,\"fragmentName\":\"\",\"isQuit\":0,\"kv\":\"a,
b\",\"lable\":\"\",\"lastExTime\":0,\"mobileUsage\":2070.0,\"model\":1910,\"monitorTime\":"+str(date_start)+",\"netServiceId\":2,\"netServiceName\":\"联通\",\"osVersionId\":1621,\"parentActionActivityId\":\"\",\"sessionId\":\"\",\"sessionName\":\"\",\"statmainId\":\"4
:2:"+str(uuid.uuid1())+"\",\"stayingTime\":0,\"timeCallTimeUs\":6000000,\"userAccessType\":"+str(userAccessType)+",\"userTrackStime\":0,\"worth\":0.0}"
			print >>f,data
	device_pre = per_device +"_appv2_channel3_"
	appVerid =  appv1_id+1
	appname = appv2
	channel_id = channel1_id +2
	for i in range(40):
			data = "{\"accessModelId\":7,\"activityEtime\":0,\"activityId\":\"\",\"activityIdIsURL\":0,\"activityName\":\"\",\"activityStime\":0,\"appId\":"+str(appid)+",\"appMemory\":4096.0,\"appVersionId\":"+str(appVerid)+",\"appVersionName\":\""+appname
+"\",\"channelId\":"+str(channel_id)+",\"cityCode\":1102100,\"clientIp\":\"112.224.2.90\",\"conMonitorTime\":"+str(date_start-1000*3*60)+",\"deviceId\":\""+device_pre+str(i)+"\",\"displaySize\":\"1080*1776\",\"eventId\":0,\"fragmentName\":\"\",\"isQuit\":0,\"kv\":\"a,
b\",\"lable\":\"\",\"lastExTime\":0,\"mobileUsage\":2070.0,\"model\":1910,\"monitorTime\":"+str(date_start)+",\"netServiceId\":2,\"netServiceName\":\"联通\",\"osVersionId\":1621,\"parentActionActivityId\":\"\",\"sessionId\":\"\",\"sessionName\":\"\",\"statmainId\":\"4
:2:"+str(uuid.uuid1())+"\",\"stayingTime\":0,\"timeCallTimeUs\":6000000,\"userAccessType\":"+str(userAccessType)+",\"userTrackStime\":0,\"worth\":0.0}"
			print >>f,data
f.close()
def construct_active_data(pre_date_start,start_day,start_month,start_m_days,calc_days):
	#### 上面都是针对构造的第一天的新设备来造的,下面是针对每个维度的设备,每天访问一个设备
	userAccessType = 1     ##用户访问类型,1.活跃,2,新增,3,升级
	appVerid =  appv1_id
	appname = appv1
	channel_id = channel1_id
	#device_pre = per_device +"_appv1_channel1_"
	for j in range(calc_days) :
		if start_day +1+j>start_m_days:
			tmp_dir = tmp_data_dir + str(start_month+1).zfill(2)+'/'+str(start_day+1+j-start_m_days).zfill(2)+'/06'
		else:
			tmp_dir = tmp_data_dir + str(start_month).zfill(2)+'/'+str(start_day+1+j).zfill(2)+'/06'
		mkdir(tmp_dir)
		f = open (tmp_dir+'/partition_1', "a")
		device_pre = per_device +"_appv1_channel1_"
		date_start = pre_date_start + 1000*60*60*24*(j+1)
		data = "{\"accessModelId\":7,\"activityEtime\":0,\"activityId\":\"\",\"activityIdIsURL\":0,\"activityName\":\"\",\"activityStime\":0,\"appId\":"+str(appid)+",\"appMemory\":4096.0,\"appVersionId\":"+str(appVerid)+",\"appVersionName\":\""+appname+"\",\"c
hannelId\":"+str(channel_id)+",\"cityCode\":1102100,\"clientIp\":\"112.224.2.90\",\"conMonitorTime\":"+str(date_start-1000*3*60*j)+",\"deviceId\":\""+device_pre+str(j)+"\",\"displaySize\":\"1080*1776\",\"eventId\":0,\"fragmentName\":\"\",\"isQuit\":0,\"kv\":\"a,b\",\"
lable\":\"\",\"lastExTime\":0,\"mobileUsage\":2070.0,\"model\":1910,\"monitorTime\":"+str(date_start)+",\"netServiceId\":2,\"netServiceName\":\"联通\",\"osVersionId\":1621,\"parentActionActivityId\":\"\",\"sessionId\":\"\",\"sessionName\":\"\",\"statmainId\":\"4:2:"+s
tr(uuid.uuid1())+"\",\"stayingTime\":0,\"timeCallTimeUs\":6000000,\"userAccessType\":"+str(userAccessType)+",\"userTrackStime\":0,\"worth\":0.0}"
		print >>f,data
		f.close()
	appVerid =  appv1_id
	appname = appv1
	channel_id = channel1_id+1
	#device_pre = per_device +"_appv1_channel2_"
	for j in range(calc_days) :
		if start_day+1 +j>start_m_days:
			tmp_dir = tmp_data_dir +str(start_month+1).zfill(2)+'/'+str(start_day+1+j-start_m_days).zfill(2)+'/06'
		else:
			tmp_dir = tmp_data_dir +str(start_month).zfill(2)+'/'+str(start_day+1+j).zfill(2)+'/06'
		mkdir(tmp_dir)
		f = open (tmp_dir+'/partition_1', "a")
		date_start = pre_date_start + 1000*60*60*24*(j+1)
		device_pre = per_device +"_appv1_channel2_"
		data = "{\"accessModelId\":7,\"activityEtime\":0,\"activityId\":\"\",\"activityIdIsURL\":0,\"activityName\":\"\",\"activityStime\":0,\"appId\":"+str(appid)+",\"appMemory\":4096.0,\"appVersionId\":"+str(appVerid)+",\"appVersionName\":\""+appname+"\",\"c
hannelId\":"+str(channel_id)+",\"cityCode\":1102100,\"clientIp\":\"112.224.2.90\",\"conMonitorTime\":"+str(date_start-1000*3*60*j)+",\"deviceId\":\""+device_pre+str(j)+"\",\"displaySize\":\"1080*1776\",\"eventId\":0,\"fragmentName\":\"\",\"isQuit\":0,\"kv\":\"a,b\",\"
lable\":\"\",\"lastExTime\":0,\"mobileUsage\":2070.0,\"model\":1910,\"monitorTime\":"+str(date_start)+",\"netServiceId\":2,\"netServiceName\":\"联通\",\"osVersionId\":1621,\"parentActionActivityId\":\"\",\"sessionId\":\"\",\"sessionName\":\"\",\"statmainId\":\"4:2:"+s
tr(uuid.uuid1())+"\",\"stayingTime\":0,\"timeCallTimeUs\":6000000,\"userAccessType\":"+str(userAccessType)+",\"userTrackStime\":0,\"worth\":0.0}"
		print >>f,data
		f.close()
	appVerid =  appv1_id
	appname = appv1
	channel_id = channel1_id+2
	#device_pre = per_device +"_appv1_channel3_"
	for j in range(calc_days) :
		if start_day +1+j> start_m_days :
			tmp_dir = tmp_data_dir +str(start_month+1).zfill(2)+'/'+str(start_day+1+j-start_m_days).zfill(2)+'/06'
		else:
			tmp_dir = tmp_data_dir +str(start_month).zfill(2)+'/'+str(start_day+1+j).zfill(2)+'/06'
		mkdir(tmp_dir)
		f = open (tmp_dir+'/partition_3', "a")
		date_start = pre_date_start + 1000*60*60*24*(j+1)
		device_pre = per_device +"_appv1_channel3_"
		data = "{\"accessModelId\":7,\"activityEtime\":0,\"activityId\":\"\",\"activityIdIsURL\":0,\"activityName\":\"\",\"activityStime\":0,\"appId\":"+str(appid)+",\"appMemory\":4096.0,\"appVersionId\":"+str(appVerid)+",\"appVersionName\":\""+appname+"\",\"c
hannelId\":"+str(channel_id)+",\"cityCode\":1102100,\"clientIp\":\"112.224.2.90\",\"conMonitorTime\":"+str(date_start-1000*3*60*j)+",\"deviceId\":\""+device_pre+str(j)+"\",\"displaySize\":\"1080*1776\",\"eventId\":0,\"fragmentName\":\"\",\"isQuit\":0,\"kv\":\"a,b\",\"
lable\":\"\",\"lastExTime\":0,\"mobileUsage\":2070.0,\"model\":1910,\"monitorTime\":"+str(date_start)+",\"netServiceId\":2,\"netServiceName\":\"联通\",\"osVersionId\":1621,\"parentActionActivityId\":\"\",\"sessionId\":\"\",\"sessionName\":\"\",\"statmainId\":\"4:2:"+s
tr(uuid.uuid1())+"\",\"stayingTime\":0,\"timeCallTimeUs\":6000000,\"userAccessType\":"+str(userAccessType)+",\"userTrackStime\":0,\"worth\":0.0}"
		print >>f,data
		f.close()
	appVerid =  appv1_id +1
	appname = appv2
	channel_id = channel1_id
	#device_pre = per_device +"_appv2_channel1_"
	for j in range(calc_days) :
		if start_day +1+j> start_m_days :
			tmp_dir = tmp_data_dir +str(start_month+1).zfill(2)+'/'+str(start_day+1+j-start_m_days).zfill(2)+'/06'
		else:
			tmp_dir = tmp_data_dir +str(start_month).zfill(2)+'/'+str(start_day+1+j).zfill(2)+'/06'
		mkdir(tmp_dir)
		f = open (tmp_dir+'/partition_3', "a")
		date_start = pre_date_start + 1000*60*60*24*(j+1)
		device_pre = per_device +"_appv2_channel1_"
		data = "{\"accessModelId\":7,\"activityEtime\":0,\"activityId\":\"\",\"activityIdIsURL\":0,\"activityName\":\"\",\"activityStime\":0,\"appId\":"+str(appid)+",\"appMemory\":4096.0,\"appVersionId\":"+str(appVerid)+",\"appVersionName\":\""+appname+"\",\"c
hannelId\":"+str(channel_id)+",\"cityCode\":1102100,\"clientIp\":\"112.224.2.90\",\"conMonitorTime\":"+str(date_start-1000*3*60*j)+",\"deviceId\":\""+device_pre+str(j)+"\",\"displaySize\":\"1080*1776\",\"eventId\":0,\"fragmentName\":\"\",\"isQuit\":0,\"kv\":\"a,b\",\"
lable\":\"\",\"lastExTime\":0,\"mobileUsage\":2070.0,\"model\":1910,\"monitorTime\":"+str(date_start)+",\"netServiceId\":2,\"netServiceName\":\"联通\",\"osVersionId\":1621,\"parentActionActivityId\":\"\",\"sessionId\":\"\",\"sessionName\":\"\",\"statmainId\":\"4:2:"+s
tr(uuid.uuid1())+"\",\"stayingTime\":0,\"timeCallTimeUs\":6000000,\"userAccessType\":"+str(userAccessType)+",\"userTrackStime\":0,\"worth\":0.0}"
		print >>f,data
		f.close()
	appVerid =  appv1_id +1
	appname = appv2
	channel_id = channel1_id + 1
	#device_pre = per_device +"_appv2_channel2_"
	for j in range(calc_days) :
		if start_day +1+j> start_m_days :
			tmp_dir = tmp_data_dir+str(start_month+1).zfill(2)+'/'+str(start_day+1+j-start_m_days).zfill(2)+'/06'
		else:
			tmp_dir = tmp_data_dir+str(start_month).zfill(2)+'/'+str(start_day+1+j).zfill(2)+'/06'
		mkdir(tmp_dir)
		f = open (tmp_dir+'/partition_4', "a")
		date_start = pre_date_start + 1000*60*60*24*(j+1)
		device_pre = per_device +"_appv2_channel2_"
		data = "{\"accessModelId\":7,\"activityEtime\":0,\"activityId\":\"\",\"activityIdIsURL\":0,\"activityName\":\"\",\"activityStime\":0,\"appId\":"+str(appid)+",\"appMemory\":4096.0,\"appVersionId\":"+str(appVerid)+",\"appVersionName\":\""+appname+"\",\"c
hannelId\":"+str(channel_id)+",\"cityCode\":1102100,\"clientIp\":\"112.224.2.90\",\"conMonitorTime\":"+str(date_start-1000*3*60*j)+",\"deviceId\":\""+device_pre+str(j)+"\",\"displaySize\":\"1080*1776\",\"eventId\":0,\"fragmentName\":\"\",\"isQuit\":0,\"kv\":\"a,b\",\"
lable\":\"\",\"lastExTime\":0,\"mobileUsage\":2070.0,\"model\":1910,\"monitorTime\":"+str(date_start)+",\"netServiceId\":2,\"netServiceName\":\"联通\",\"osVersionId\":1621,\"parentActionActivityId\":\"\",\"sessionId\":\"\",\"sessionName\":\"\",\"statmainId\":\"4:2:"+s
tr(uuid.uuid1())+"\",\"stayingTime\":0,\"timeCallTimeUs\":6000000,\"userAccessType\":"+str(userAccessType)+",\"userTrackStime\":0,\"worth\":0.0}"
		print >>f,data
		f.close()
	appVerid =  appv1_id +1
	appname = appv2
	channel_id = channel1_id +2
	#device_pre = per_device +"_appv2_channel3_"
	for j in range(calc_days) :
		if start_day +1+j> start_m_days :
			tmp_dir = tmp_data_dir +str(start_month+1).zfill(2)+'/'+str(start_day+1+j-start_m_days).zfill(2)+'/06'
		else:
			tmp_dir = tmp_data_dir +str(start_month).zfill(2)+'/'+str(start_day+1+j).zfill(2)+'/06'
		mkdir(tmp_dir)
		f = open (tmp_dir+'/partition_5', "a")
		date_start = pre_date_start + 1000*60*60*24*(j+1)
		device_pre = per_device +"_appv2_channel3_"
		data = "{\"accessModelId\":7,\"activityEtime\":0,\"activityId\":\"\",\"activityIdIsURL\":0,\"activityName\":\"\",\"activityStime\":0,\"appId\":"+str(appid)+",\"appMemory\":4096.0,\"appVersionId\":"+str(appVerid)+",\"appVersionName\":\""+appname+"\",\"c
hannelId\":"+str(channel_id)+",\"cityCode\":1102100,\"clientIp\":\"112.224.2.90\",\"conMonitorTime\":"+str(date_start-1000*3*60*j)+",\"deviceId\":\""+device_pre+str(j)+"\",\"displaySize\":\"1080*1776\",\"eventId\":0,\"fragmentName\":\"\",\"isQuit\":0,\"kv\":\"a,b\",\"
lable\":\"\",\"lastExTime\":0,\"mobileUsage\":2070.0,\"model\":1910,\"monitorTime\":"+str(date_start)+",\"netServiceId\":2,\"netServiceName\":\"联通\",\"osVersionId\":1621,\"parentActionActivityId\":\"\",\"sessionId\":\"\",\"sessionName\":\"\",\"statmainId\":\"4:2:"+s
tr(uuid.uuid1())+"\",\"stayingTime\":0,\"timeCallTimeUs\":6000000,\"userAccessType\":"+str(userAccessType)+",\"userTrackStime\":0,\"worth\":0.0}"
		print >>f,data
		f.close()
def construct_stable_active_data():
	
	userAccessType = 1   ##用户访问类型,1.活跃,2,新增,3,升级
	appVerid =  appv1_id
	appname = appv1
	channel_id = channel1_id
	device_pre = "linlh_stable_appv1_channel1_"
	for j in range(calc_days) :
		if start_day +1+j>start_m_days:
			tmp_dir = tmp_data_dir + str(start_month+1).zfill(2)+'/'+str(start_day+1+j-start_m_days).zfill(2)+'/06'
		else:
			tmp_dir = tmp_data_dir + str(start_month).zfill(2)+'/'+str(start_day+1+j).zfill(2)+'/06'
		mkdir(tmp_dir)
		f = open (tmp_dir+'/partition_2', "a")
		date_start = pre_date_start + 1000*60*60*24*(j+1)
		
		for k in range(calc_days+2-j):
			data = "{\"accessModelId\":7,\"activityEtime\":0,\"activityId\":\"\",\"activityIdIsURL\":0,\"activityName\":\"\",\"activityStime\":0,\"appId\":"+str(appid)+",\"appMemory\":4096.0,\"appVersionId\":"+str(appVerid)+",\"appVersionName\":\""+appname
+"\",\"channelId\":"+str(channel_id)+",\"cityCode\":1102100,\"clientIp\":\"112.224.2.90\",\"conMonitorTime\":"+str(date_start-1000*3*60*j)+",\"deviceId\":\""+device_pre+str(k)+"\",\"displaySize\":\"1080*1776\",\"eventId\":0,\"fragmentName\":\"\",\"isQuit\":0,\"kv\":\"
a,b\",\"lable\":\"\",\"lastExTime\":0,\"mobileUsage\":2070.0,\"model\":1910,\"monitorTime\":"+str(date_start)+",\"netServiceId\":2,\"netServiceName\":\"联通\",\"osVersionId\":1621,\"parentActionActivityId\":\"\",\"sessionId\":\"\",\"sessionName\":\"\",\"statmainId\":\
"4:2:"+str(uuid.uuid1())+"\",\"stayingTime\":0,\"timeCallTimeUs\":6000000,\"userAccessType\":"+str(userAccessType)+",\"userTrackStime\":0,\"worth\":0.0}"
			print >>f,data
		f.close()
start_day = 22
start_month = 5
start_m_days = 31
calc_days = 16
per_device = "linlh_20190522"
## 设置构造数据从哪一天开始, 这一天的设备全是新增,后面的设备全是活跃, 这个时间不要取当天的零点。会导致 conMonitorTime 和monitorTime 不在同一天,建议写成 开始当天的 6点
pre_date_start = 1558476000000
#timeStr=time.strftime("%Y-%m-%d %H:%M:%S", time.localtime(date_start/1000+60*60*24))
#print( timeStr)
construct_stable_active_data()
per_device = "linlh_20190522"
device_pre = per_device +"_appv1_channel1_"
tmp_start_day = 22 
for k in range(calc_days):
	if tmp_start_day +k > start_m_days:
		per_device = "linlh_2019"+str(start_month+1).zfill(2)+str(tmp_start_day +k-start_m_days).zfill(2)
		device_pre = per_device +"_appv1_channel1_"
		construct_new_data(    pre_date_start+60*60*24*1000*k, (tmp_start_day +k)-start_m_days, start_month+1, tmp_start_day -1, calc_days-k)
		construct_active_data( pre_date_start+60*60*24*1000*k, (tmp_start_day +k)-start_m_days, start_month+1, tmp_start_day -1, calc_days-k)
	else:
		per_device = "linlh_2019"+str(start_month).zfill(2)+str(tmp_start_day +k).zfill(2)
		device_pre = per_device +"_appv1_channel1_"
		construct_new_data(    pre_date_start+60*60*24*1000*k, tmp_start_day +k, start_month, start_m_days, calc_days-k)
		construct_active_data( pre_date_start+60*60*24*1000*k, tmp_start_day +k, start_month, start_m_days, calc_days-k)
 
                    
                 
 
                
            
         浙公网安备 33010602011771号
浙公网安备 33010602011771号