rabin преди 5 години
родител
ревизия
8eb01ad70a
променени са 6 файла, в които са добавени 54 реда и са изтрити 25 реда
  1. 6 6
      admin/page/device.py
  2. 6 1
      admin/page/farm.py
  3. 1 1
      admin/page/origin.py
  4. 1 1
      conf/dev.conf
  5. 30 6
      conf/env.conf
  6. 10 10
      front/page/device.py

+ 6 - 6
admin/page/device.py

@@ -23,7 +23,7 @@ class gateway_path(Load):
 			,state = False
 		)
 		self.data['common']['search_farm_id-select-'] = Demeter.config['setting']['farmList']
-		self.list('device_gateway')
+		self.list('device_gateway', order='hardware_id asc')
 		if self.data['list']:
 			for key, value in enumerate(self.data['list']):
 				farm = self.service('common').one('farm', id=value['farm_id'])
@@ -106,7 +106,7 @@ class info_path(Load):
 		)
 		self.data['common']['search_farm_id-select--gateway_id'] = Demeter.config['setting']['farmList']
 		self.data['common']['search_type_id-select-'] = self.service('common').list('setting_device_type')
-		self.data['common']['search_gateway_id-select---farm_id'] = self.service('common').list('device_gateway')
+		self.data['common']['search_gateway_id-select---farm_id'] = self.service('common').list('device_gateway', order='hardware_id asc')
 		self.data['common']['search_hardware_type-select-'] = self.service('common').list('hardware_type')
 		"""
 		if self.data['common']['search_hardware_type-select-']:
@@ -199,7 +199,7 @@ class info_update_path(Load):
 				,label = (u'摄像机名称', u'摄像机id', u'所属农场', u'选择网关', u'摄像机地址', u'排序')
 				,update = ('name-input-required','hardware_id-show-','farm_id-select-required-gateway_id','gateway_id-select-required--farm_id','value-text-required','inorder-input-')
 				,update_farm_id = self.service('common').list('farm', search={'eros_status':2})
-				,update_gateway_id = self.service('common').list('device_gateway')
+				,update_gateway_id = self.service('common').list('device_gateway', order='hardware_id asc')
 				#,update_hardware_type = self.service('common').list('hardware_type')
 			)
 		elif self.data['info']['hardware_type'] == 6:
@@ -208,7 +208,7 @@ class info_update_path(Load):
 				,label = (u'摄像头名称', u'摄像头id', u'所属农场', u'选择网关', u'摄像头地址', u'排序')
 				,update = ('name-input-required','hardware_id-show-','farm_id-select-required-gateway_id','gateway_id-select-required--farm_id','value-text-required','inorder-input-')
 				,update_farm_id = self.service('common').list('farm', search={'eros_status':2})
-				,update_gateway_id = self.service('common').list('device_gateway')
+				,update_gateway_id = self.service('common').list('device_gateway', order='hardware_id asc')
 			)
 		elif self.data['info']['hardware_type'] in (2,4):
 			self.set(
@@ -257,7 +257,7 @@ class camera_update_path(Load):
 			,label = (u'摄像机名称', u'摄像机id', u'所属农场', u'选择网关', u'摄像机地址',u'排序')
 			,update = ('name-input-required','hardware_id-input-required','farm_id-select-required-gateway_id','gateway_id-select-required--farm_id','value-text-required','inorder-text-')
 			,update_farm_id = self.service('common').list('farm', search={'eros_status':2})
-			,update_gateway_id = self.service('common').list('device_gateway')
+			,update_gateway_id = self.service('common').list('device_gateway', order='hardware_id asc')
 		)
 		self.one('device_info')
 		self.show('update')
@@ -287,7 +287,7 @@ class camera_pic_update_path(Load):
 			,label = (u'摄像头名称', u'摄像头id', u'所属农场', u'选择网关', u'摄像头地址',u'排序')
 			,update = ('name-input-required','hardware_id-input-required','farm_id-select-required-gateway_id','gateway_id-select-required--farm_id','value-text-required','inorder-text-')
 			,update_farm_id = self.service('common').list('farm', search={'eros_status':2})
-			,update_gateway_id = self.service('common').list('device_gateway')
+			,update_gateway_id = self.service('common').list('device_gateway', order='hardware_id asc')
 		)
 		self.one('device_info')
 		self.show('update')

+ 6 - 1
admin/page/farm.py

@@ -36,7 +36,7 @@ class farm_path(Load):
 			,{'name':'网关管理', 'url':'/device/gateway'}
 			,{'name':'设备管理', 'url':'/device/info'}
 
-			,{'name':'生成本地控制器', 'url':'/package/download'}
+			#,{'name':'生成本地控制器', 'url':'/package/download'}
 			
 			#,{'name':'打印机管理', 'url':'/device/printer'}
 			#,{'name':'消息提醒', 'url':'/msg/msg'}
@@ -114,6 +114,11 @@ class info_path(Load):
 	@Web.auth
 	@Web.setting
 	def post(self):
+		id = self.input('id')
+		info = self.service('common').one('farm', id=id)
+		if info and info['eros_status'] == 1:
+			self.out('本地服务已开启,无法通过云端修改农场资料')
+			return
 		self.update('farm')
 
 class product_path(Load):

+ 1 - 1
admin/page/origin.py

@@ -41,7 +41,7 @@ class batch_update_path(Load):
 			path = '/origin/batch'
 			,label = (u'所属农场',u'产品名称', u'种植时间',u'采收时间',u'设备网关',u'地块',u'图像记录')
 			,update = ('farm_id-select-required','name-input-required', 'zzdate-date-required', 'csdate-date-required','gateway_id-select-required','land_id-select-required','pic-pic-required')
-			,update_gateway_id = self.service('common').list('device_gateway')
+			,update_gateway_id = self.service('common').list('device_gateway', order='hardware_id asc')
 			,update_land_id = self.service('common').list('farm_work_land')
 			,update_farm_id = self.service('common').list('farm', search={'eros_status':2})
 		)

+ 1 - 1
conf/dev.conf

@@ -52,7 +52,7 @@ password			= public
 timeout				= 60
 ;topic定义
 topic				= method/type/gateway/device
-sub					= pic,sensor,control,power
+sub					= pic,sensor,control,power,status,log
 
 ;后台配置
 [admin]

+ 30 - 6
conf/env.conf

@@ -16,7 +16,7 @@ host				= iot-pgsql
 port				= 5432
 username			= postgres
 password			= 123456
-dbname				= xinnongbaohe
+dbname				= xinnongbaohe_zeus
 prefix				= demeter
 ;允许自动建表
 create				= True
@@ -54,8 +54,16 @@ debug				= True
 max_buffer_size		= 210763776
 ;子进程
 process				= 0
-;top菜单的数据来源
-top 				= farm
+;定义后台父级菜单
+menu_parent			= 农场管理:,设备管理:,配置管理:,网站管理:
+;定义后台子级菜单
+menu_child			= 农场管理:/farm/farm,用户管理:/farm/user,产品管理:/farm/product,地块管理:/work/land,农事管理:/work/work,溯源批次:/origin/batch,消息提醒:/msg/msg;网关列表:/device/gateway,设备列表:/device/info;产品配置:/setting/product,服务配置:/setting/server,设备类型:/setting/device_type,硬件类型:/hardware/type,MODBUS命令码:/setting/modbus_code,错误码配置:/device/notice_type,消息类型设置:/msg/type;网站资料设置:/web/set,帮助分类:/web/help_category,发布帮助内容:/web/help,文章分类:/web/category,发布内容文章:/web/article,菜单管理:/web/menu
+
+;cookie
+cookie_secret       = 61oETzKXQAGaYekL5gEmGeJJFuYh7EQnp2XdTP1o/Vo=
+login_url           = /user/login
+;是否使用安全cookie
+xsrf_cookies        = True
 
 ;前台配置
 [front]
@@ -63,7 +71,23 @@ port				= 8088
 debug				= True
 max_buffer_size		= 210763776
 process				= 0
-;url					= http://www.xinnongbaohe.com:8088/device
-url					= http://v3.xinnongbaohe.com/device
+url					= http://192.168.33.10:8088/device
 qrcode				= http://pan.baidu.com/share/qrcode?w=300&h=300&url=
-mobile				= True
+mobile				= True
+
+;网站前台配置
+[web]
+port                = 8089
+debug               = True
+max_buffer_size     = 210763776
+process             = 0
+url                 = http://www.xinnongbaohe.com/
+farmurl             = http://farm.xinnongbaohe.com/?id=
+originurl           = http://s.xinnongbaohe.com/?id=
+
+;同步配置
+[sync]
+;同步的表,多个用逗号隔开
+table               = notice_type,hardware_type,msg_type,setting_product,setting_device_type,setting_modbus_code
+;同步的方法,仅限service
+service              = core,eros

+ 10 - 10
front/page/device.py

@@ -13,7 +13,7 @@ class index_path(Load):
 		if 'url' in self.data:
 			self.redirect(self.data['url'])
 		# 获取网关列表
-		self.data['gateway'] = self.service('common').list('device_gateway', state=True, search={'farm_id':self.data['setting']['farm']})
+		self.data['gateway'] = self.service('common').list('device_gateway', state=True, search={'farm_id':self.data['setting']['farm']}, order='hardware_id asc')
 		# 获取页面
 		self.data['page'] = self.service('common').list('device_page', order='inorder asc,cdate desc', search={'farm_id':self.data['setting']['farm']})
 		self.view("device/index.html")
@@ -123,7 +123,7 @@ class screen_set_path(Load):
 	def get(self):
 		self.data['info'] = self.data['setting']['farmInfo']
 		self.data['info']['devices'] = self.data['info']['gateway']
-		self.data['gateway'] = self.service('common').list('device_gateway', search={'farm_id':self.data['setting']['farm']})
+		self.data['gateway'] = self.service('common').list('device_gateway', search={'farm_id':self.data['setting']['farm']}, order='hardware_id asc')
 		self.data['device'] = Device.getByGateway(self, search={'hardware_type--ins' : (2,4,5),'farm_id':self.data['setting']['farm']})
 		self.view("device/alert/screen.html")
 
@@ -357,7 +357,7 @@ class update_group_path(Load):
 		if id:
 			self.data['info'] = self.service('common').one('device_group', id=id)
 
-		self.data['gateway'] = self.service('common').list('device_gateway', search={'farm_id':self.data['setting']['farm']})
+		self.data['gateway'] = self.service('common').list('device_gateway', search={'farm_id':self.data['setting']['farm']}, order='hardware_id asc')
 		self.data['device'] = Device.getByGateway(self, search={'farm_id':self.data['setting']['farm']})
 		self.view("device/alert/group.html")
 
@@ -416,7 +416,7 @@ class update_set_mul_path(Load):
 		if id:
 			self.data['info'] = self.service('common').one('device_mul', id=id)
 
-		self.data['gateway'] = self.service('common').list('device_gateway', search={'farm_id':self.data['setting']['farm']})
+		self.data['gateway'] = self.service('common').list('device_gateway', search={'farm_id':self.data['setting']['farm']}, order='hardware_id asc')
 		self.data['device'] = Device.getByGateway(self, search={'hardware_type' : 3,'farm_id':self.data['setting']['farm']})
 		self.data['type'] = ({'id':1, 'name':'开关'},{'id':2, 'name':'卷帘'})
 		self.view("device/alert/mul.html")
@@ -460,7 +460,7 @@ class set_timing_path(Load):
 		self.data['name'] = '定时设置'
 		Device.set(self)
 		Device.setCronOper(self)
-		self.data['gateway'] = self.service('common').list('device_gateway', search={'farm_id':self.data['setting']['farm']})
+		self.data['gateway'] = self.service('common').list('device_gateway', search={'farm_id':self.data['setting']['farm']}, order='hardware_id asc')
 		self.data['device'] = Device.getByGateway(self, search={'hardware_type': 3,'farm_id':self.data['setting']['farm']})
 		self.data['list'] = self.service('common').list('device_set_timing', state=True, page={'num':10}, search={'farm_id':self.data['setting']['farm']})
 		if self.data['list']:
@@ -494,7 +494,7 @@ class update_set_timing_path(Load):
 			if self.data['info'] and self.data['info']['zdate']:
 				self.data['info']['zdate'] = Demeter.date(self.data['info']['zdate'])
 
-		self.data['gateway'] = self.service('common').list('device_gateway', search={'farm_id':self.data['setting']['farm']})
+		self.data['gateway'] = self.service('common').list('device_gateway', search={'farm_id':self.data['setting']['farm']}, order='hardware_id asc')
 		self.data['device'] = Device.getByGateway(self, search={'hardware_type' : 3,'farm_id':self.data['setting']['farm']})
 		self.view("device/alert/timing.html")
 
@@ -538,7 +538,7 @@ class set_loop_path(Load):
 		self.data['name'] = '周期设置'
 		Device.set(self)
 		Device.setCronOper(self)
-		self.data['gateway'] = self.service('common').list('device_gateway', search={'farm_id':self.data['setting']['farm']})
+		self.data['gateway'] = self.service('common').list('device_gateway', search={'farm_id':self.data['setting']['farm']}, order='hardware_id asc')
 		self.data['device'] = Device.getByGateway(self, search={'hardware_type': 3,'farm_id':self.data['setting']['farm']})
 		self.data['list'] = self.service('common').list('device_set_loop', page={'num':10}, search={'farm_id':self.data['setting']['farm']})
 		if self.data['list']:
@@ -578,7 +578,7 @@ class update_set_loop_path(Load):
 		if id:
 			self.data['info'] = self.service('common').one('device_set_loop', id=id)
 
-		self.data['gateway'] = self.service('common').list('device_gateway', search={'farm_id':self.data['setting']['farm']})
+		self.data['gateway'] = self.service('common').list('device_gateway', search={'farm_id':self.data['setting']['farm']}, order='hardware_id asc')
 		self.data['device'] = Device.getByGateway(self, search={'hardware_type' : 3,'farm_id':self.data['setting']['farm']})
 		self.view("device/alert/loop.html")
 
@@ -633,7 +633,7 @@ class set_condition_path(Load):
 		self.data['name'] = '条件控制'
 		Device.set(self)
 		Device.setCronOper(self)
-		self.data['gateway'] = self.service('common').list('device_gateway', search={'farm_id':self.data['setting']['farm']})
+		self.data['gateway'] = self.service('common').list('device_gateway', search={'farm_id':self.data['setting']['farm']}, order='hardware_id asc')
 		self.data['device'] = Device.getByGateway(self, search={'hardware_type': 3,'farm_id':self.data['setting']['farm']})
 		self.data['list'] = self.service('common').list('device_set_condition', state=True, page={'num':10}, search={'farm_id':self.data['setting']['farm']})
 		if self.data['list']:
@@ -666,7 +666,7 @@ class update_set_condition_path(Load):
 		if id:
 			self.data['info'] = self.service('common').one('device_set_condition', id=id)
 
-		self.data['gateway'] = self.service('common').list('device_gateway', search={'farm_id':self.data['setting']['farm']})
+		self.data['gateway'] = self.service('common').list('device_gateway', search={'farm_id':self.data['setting']['farm']}, order='hardware_id asc')
 		self.data['device'] = Device.getByGateway(self, search={'hardware_type' : 3,'farm_id':self.data['setting']['farm']})
 		self.data['device_list'] = self.service('common').list('device_info', search={'hardware_type--ins' : (2,4),'gateway_id':self.data['gateway'][0]['id']})
 		self.view("device/alert/condition.html")