Esempio n. 1
0
	def post(self):
		act = self.get_argument('act','')
		code = self.get_argument('code','')
		name = self.get_argument('name','')
		latitude = self.get_argument('latitude','')
		longitude = self.get_argument('longitude','')
		isopen = self.get_argument('isopen','')
		id = self.get_argument('id','')
		dev = devicemodel(self)
		if act == 'add':
			one = dev.only_code( code )
			if not one:
				self.prompt( 0, apimsg.notice(307), 'javascript:history.go(-1)', '该设备号已经存在' )
				return
			res = dev.add_device(code=code,name=name,latitude=latitude,longitude=longitude,isopen=isopen)
			referer = '/admin/device_list'
		elif id and act == 'edit':
			one = dev.only_code( code, id )
			if not one:
				self.prompt( 0, apimsg.notice(307), 'javascript:history.go(-1)', '该设备号已经存在' )
			res = dev.edit_device(id=id,code=code,name=name,latitude=latitude,longitude=longitude,isopen=isopen)
			referer = self.get_argument('referer','javascript:history.go(-1)')
		if res == 1:
			self.prompt( 1, apimsg.notice(305), referer )
		else:
			self.prompt( 0, apimsg.notice(307), 'javascript:history.go(-1)', res )
Esempio n. 2
0
	def get(self):
		dev = devicemodel(self)
		num = dev.error_number()
		nowtime = int(time.time())
		if num > 0:
			dlist = dev.error_list( nowtime )
		else:
			dlist = None
		self.render("admin/device_error.html", dlist=dlist, nowtime=nowtime )
Esempio n. 3
0
	def get(self):
		id = self.get_argument('id','')
		if id:
			dev = devicemodel(self)
			res = dev.delete_device(id)
			if res:
				self.prompt( 1, apimsg.notice(305), '/admin/device_list' )
			else:
				self.prompt( 0, apimsg.notice(307), 'javascript:history.go(-1)' )
Esempio n. 4
0
	def post(self):
		id = self.get_argument('id','')
		if id:
			dev = devicemodel(self)
			val = self.get_argument('val','')
			res = dev.change_open(val,id)
			#写入日志文件
			if res:
				self.finish('1')
				return
		self.finish('0')
Esempio n. 5
0
	def get(self):
		left = {}
		dev = devicemodel(self)
		#电桩异常提示数量
		left['error'] = dev.error_number()
		nowtime = int(time.time())
		#电桩异常提示详情
		if left['error'] > 0:
			dlist = dev.error_list( nowtime )
		else:
			dlist = None

		charge = chargemodel(self)
		where = {'o.finish =':0}
		clist = charge.workinglist(where,1,1)
		pinfo = charge.page_bar(2)
		if pinfo:
			left['working'] = pinfo['all_num']
		else:
			left['working'] = 0
		self.render("admin/main.html",left=left,dlist=dlist)
Esempio n. 6
0
	def get(self):
		code = self.get_argument('code','')
		name = self.get_argument('name','')
		status = self.get_argument('status','9')
		page = self.get_argument('page',1)
		where = ' where 1=1 '
		if code:
			where += " AND code = '"+code+"'"
		if name:
			where += " AND name like '%%"+name+"%%'"
		if status == '0':
			where += " AND %s - heart_time > 120 " %int(time.time())
		elif int(status) < 9:
			where += " AND status = '"+str(status)+"' AND %s - heart_time <= 120 " %int(time.time())
		dev = devicemodel(self)
		dlist = dev.devicelist( where, page, 20 )
		if dlist:
			page_bar = dev.page_bar(1)
			pinfo = dev.page_bar(2)
		else:
			page_bar = None
			pinfo = {'this_page':1,'all_page':0,'per_page':20}
		search = {'code':code,'name':name,'status':status}
		self.render("admin/devicelist.html", dlist=dlist, search=search,page_bar=page_bar,pinfo=pinfo )
Esempio n. 7
0
	def get(self):
		id = self.get_argument('id','')
		dev = devicemodel(self)
		info = dev.device_info(id)
		referer = self.request.headers['Referer']
		self.render("admin/deviceinfo.html", info=info, act='edit', referer=referer )