Beispiel #1
0
    def GET(self, dms_id):
        if dms_id is None:
            raise web.seeother('/dms/admin/show/1')

        condition = {'_id': ObjectId(dms_id)}
        dms_model().remove(condition)
        raise web.seeother("/dms/admin/show/1")
Beispiel #2
0
	def POST(self):
		form = web.input()
		if form['userFrom'] is None or form['userFrom'] == '':
			return render("apply.html", msg="业务名不能为空")
			
		if form['level'] is None or form['level'] == '':
			return render("apply.html", msg="保存等级不能为空")
			
		if form['tagID'] is None or form['tagID'] == '':
			return render("apply.html", msg="业务ID不能为空")
			
		userFrom = form['userFrom'].lower()
		level = form['level']	
		tagID = form['tagID']
		remark = ''
		if form['remark']:
			remark = form['remark']
		
		condition_user = {'userFrom':userFrom}		
		item_user = dms_model().find_one(condition_user)
		
		condition_id = {'tagID':tagID}		
		item_id = dms_model().find_one(condition_id)
		if item_user:
			return render("apply.html", msg="此系统用户已注册")
		if item_id:
			return render("apply.html", msg="ID号已注册")
		else:		
			item = {"userFrom":userFrom,"tagID":tagID,"level":level, "remark":remark}
			dms_model().insert(item)
			return render("apply.html", msg="注册成功")
Beispiel #3
0
    def GET(self, p):
        if p is None or p == '':
            p = '1'
        p = int(p)

        j.bss = dms_model().find_page(pagenum=p)
        j.page = dms_model().get_page(p)
        return render('systemlist.html', **j)
Beispiel #4
0
    def GET(self):
        dbs = dms_model().find()
        result = []
        for db in dbs:
            result.append(db['remark'])

        data = {"userfrom": result}
        data = json.dumps(data)
        return data
Beispiel #5
0
    def GET(self):
        result = {"status": 0, "msg": "", "options": {}}
        i = web.input()
        userfrom = i.get("userFrom").lower()
        condition = {'userFrom': userfrom}
        item = dms_model().find_one(condition)

        if not item:
            result["status"] = 1
            result["msg"] = "系统还未注册"
            return result
        else:
            result["status"] = 0
            result["msg"] = "OK"
            result["options"]["tagID"] = item["tagID"]
            return result
Beispiel #6
0
 def GET(self):
     data = web.input()
     userfrom = ''
     remark = ''
     if data and data['userFrom']:
         remark = data['userFrom']
     conditions = {}
     conditions['remark'] = remark
     user = dms_model().find_one(conditions=conditions)
     if user:
         userfrom = user['userFrom'].lower()
     tns = data_model(userfrom).find()
     result = []
     for tn in tns:
         result.append(tn["tablename"])
     data = {"tablename": result}
     data = json.dumps(data)
     return data
Beispiel #7
0
def test(data):
	result = {"status":0,"msg":"","options":{}}		
	common._LOG.info(data)
	msg = json.loads(data)
		
	#读取字典内容
	if "userFrom" not in msg.keys():
		result["status"] = 1
		result["msg"] = "缺少必要字段"
		return result
	if "tagID" not in msg.keys():
		result["status"] = 1
		result["msg"] = "缺少必要字段"
		return result		
	if "options" not in msg.keys() or len(msg["options"])<1:
		result["status"] = 1
		result["msg"] = "无有效数据保存"
		return result
			
	userFrom = msg["userFrom"].lower()
	tagID = msg["tagID"]
		
	file = open("./file" + userFrom,"a")
		
	condition = {"userFrom":userFrom}
	item = dms_model().find_one(condition)
	if not item:
		result["status"] = 1
		result["msg"] = "此系统还未注册"
		return result
	if int(item["tagID"]) == tagID:
		pass
	else:
		result["status"] = 1
		result["msg"] = "业务名与业务ID不符"
		return result
	level = string.atoi(item["level"])
		
	conditions = dict()
	conditions["userFrom"] = userFrom
	set = userfrom_model().count(conditions)
	if set == 0:
		userfrom_model().insert(conditions)
	data = msg["options"]
		
	#获取数据表名
	tablename = data[0]['tablename']
	insertdata = {"tablename":tablename}
	set = data_model(userFrom).count(insertdata)
	if set == 0:
		data_model(userFrom).insert(insertdata)
	#find_table = data_model("childtable").find_one(insertdata)
	#if find_table is None:
	#	table_save_level = 1
	#else:
	#	table_save_level = int(find_table['level'])
		
	count = 0
	table_file = None
	for item in data:
		item["acceptTime"] = time.strftime('%Y%m%d%H%M%S',time.localtime(time.time()))
		if tablename == 'loger' and 'datetime' in item.keys():
			item['acceptTime'] = item['datetime']
			del item['datetime']
	#	if tablename == 'loger' and 'socketOut_P' in item['content'].keys() and float(item['content']['socketOut_P']) == 0:#过滤掉功率为0的日志信息
	#		continue 
		if tablename == 'loger' and 'CMD' in item['content'].keys() and item['content']['CMD'] == '3001' and 'connInterval' in item['content'].keys():#过滤掉请求获取电量信息的指令
			continue
		if tablename == 'live.area.temp.history' and item['key'].startswith('1'):#过滤掉天气数据中key为代号的信息
			continue
		if tablename == 'loger' and 'socketOut_P' in item['content'].keys() and 'socketOut_W' in item['content'].keys():
			item['content']['socketOut_P'] = int(item['content']['socketOut_P'])
			item['content']['socketOut_W'] = float('%0.4f'%(float(item['content']['socketOut_W'])))
		dealItem(item)
		if level == 2:
			if '_id' in item.keys():
				item['_id'] = str(item['_id'])
			file.write(unparse.dictTostr(item))
			file.write("\n")
			count = count + 1
		elif level == 1:
			try:
				if tablename == 'devCurrInfo':
					devid = item.get('deviceId','None')
					item["acceptTime"] = time.strftime('%Y%m%d%H%M%S',time.localtime(time.time()))
					data_model('devCurrInfo').remove(condition={'deviceId':devid})
					data_model('devCurrInfo').insert(item)
				if tablename == 'live.area.temp.history':
					if item.get('city','') == '':
						pass
					else:
						data_model(tablename).insert(item)
				else:
					data_model(tablename).insert(item)
				count = count + 1
			except Exception as e:
				print e
				common._LOG.info('%s:%s'%(type(e), str(e)))	
				common._LOG.info("保存失败!")
	file.close()
	data_model("count").update_inc(insertdata,values={"count":count},upsert=True)
			
	result["status"] = 0
	result["msg"] = "OK"
	return result