rabin 6 years ago
parent
commit
453277306a

+ 2 - 2
README.md

@@ -1,6 +1,6 @@
-# demeter
+# nongxiaohe
 
 数据采集服务+本地web界面
 
 开发语言:python
-框架:gevent+tornado+demeter
+框架:demeter

+ 2 - 1
admin/page/__load__.py

@@ -7,9 +7,10 @@
 from demeter.web import *
 
 class Load(Base):
-	KEYS = ('farm', 'admin')
+	KEYS = ('admin', 'farm')
 
 	def setting(self):
+		self.search()
 		self.admin()
 
 	def admin(self):

+ 9 - 9
admin/page/admin.py

@@ -8,7 +8,7 @@
 from __load__ import *
 
 class admin_path(Load):
-	@tornado.web.authenticated
+	@Web.auth
 	def get(self):
 		self.common(
 			name = u'管理员' #中文名
@@ -24,7 +24,7 @@ class admin_path(Load):
 		self.commonView('list')
 
 class admin_update_path(Load):
-	@tornado.web.authenticated
+	@Web.auth
 	def get(self):
 		self.common(
 			path = '/admin/admin'
@@ -34,13 +34,13 @@ class admin_update_path(Load):
 		)
 		self.commonOne('manage_admin')
 		self.commonView('update')
-	@tornado.web.authenticated
+	@Web.auth
 	def post(self):
 		self.commonUpdate('manage_admin', '手机号已经被注册', mobile=self.data['update']['mobile'])
 
 
 class role_path(Load):
-	@tornado.web.authenticated
+	@Web.auth
 	def get(self):
 		self.common(
 			name = u'角色'
@@ -59,7 +59,7 @@ class role_path(Load):
 		self.commonView('list')
 
 class role_update_path(Load):
-	@tornado.web.authenticated
+	@Web.auth
 	def get(self):
 		auth = self.data['setting']['menuList']
 		self.common(
@@ -74,15 +74,15 @@ class role_update_path(Load):
 		)
 		self.commonOne('manage_role')
 		self.commonView('update')
-	@tornado.web.authenticated
+	@Web.auth
 	def post(self):
 		self.commonUpdate('manage_role')
-	@tornado.web.authenticated
+	@Web.auth
 	def delete(self):
 		self.commonDelete('manage_role')
 
 class log_path(Load):
-	@tornado.web.authenticated
+	@Web.auth
 	def get(self):
 		self.common(
 			name = u'日志' #中文名
@@ -100,7 +100,7 @@ class log_path(Load):
 		self.commonView('list')
 
 class setCookie_path(Load):
-	@tornado.web.authenticated
+	@Web.auth
 	def post(self):
 		value = self.input('farm', Demeter.config['setting']['farm'])
 		self.set_secure_cookie('farm', value)

+ 10 - 10
admin/page/content.py

@@ -8,7 +8,7 @@
 from __load__ import *
 
 class article_path(Load):
-	@tornado.web.authenticated
+	@Web.auth
 	def get(self):
 		self.common(
 			name = u'文章'
@@ -29,7 +29,7 @@ class article_path(Load):
 		self.commonView('list')
 
 class article_update_path(Load):
-	@tornado.web.authenticated
+	@Web.auth
 	def get(self):
 		self.common(
 			path = '/content/article'
@@ -39,16 +39,16 @@ class article_update_path(Load):
 		)
 		self.commonOne('article')
 		self.commonView('update')
-	@tornado.web.authenticated
+	@Web.auth
 	def post(self):
 		self.commonUpdate('article')
-	@tornado.web.authenticated
+	@Web.auth
 	def delete(self):
 		self.commonDelete('article')
 
 
 class category_path(Load):
-	@tornado.web.authenticated
+	@Web.auth
 	def get(self):
 		self.common(
 			name = u'分类'
@@ -64,7 +64,7 @@ class category_path(Load):
 		self.commonView('list')
 
 class category_update_path(Load):
-	@tornado.web.authenticated
+	@Web.auth
 	def get(self):
 		self.common(
 			path = '/content/category'
@@ -73,15 +73,15 @@ class category_update_path(Load):
 		)
 		self.commonOne('article_category')
 		self.commonView('update')
-	@tornado.web.authenticated
+	@Web.auth
 	def post(self):
 		self.commonUpdate('article_category')
-	@tornado.web.authenticated
+	@Web.auth
 	def delete(self):
 		self.commonDelete('article_category')
 
 class info_path(Load):
-	@tornado.web.authenticated
+	@Web.auth
 	def get(self):
 		self.common(
 			path = '/content/info'
@@ -90,6 +90,6 @@ class info_path(Load):
 		)
 		self.commonOne('content', id=1)
 		self.commonView('set')
-	@tornado.web.authenticated
+	@Web.auth
 	def post(self):
 		self.commonUpdate('content',id=1)

+ 29 - 29
admin/page/device.py

@@ -8,7 +8,7 @@
 from __load__ import *
 
 class page_path(Load):
-	@tornado.web.authenticated
+	@Web.auth
 	def get(self):
 		self.common(
 			name = u'页面' #中文名
@@ -27,7 +27,7 @@ class page_path(Load):
 		self.commonView('list')
 
 class page_update_path(Load):
-	@tornado.web.authenticated
+	@Web.auth
 	def get(self):
 		self.common(
 			path = 'page'
@@ -36,15 +36,15 @@ class page_update_path(Load):
 		)
 		self.commonOne('device_page')
 		self.commonView('update')
-	@tornado.web.authenticated
+	@Web.auth
 	def post(self):
 		self.commonUpdate('device_page')
-	@tornado.web.authenticated
+	@Web.auth
 	def delete(self):
 		self.commonDelete('device_page')
 
 class group_path(Load):
-	@tornado.web.authenticated
+	@Web.auth
 	def get(self):
 		self.common(
 			name = u'分组'
@@ -71,7 +71,7 @@ class group_path(Load):
 		self.commonView('list')
 
 class group_update_path(Load):
-	@tornado.web.authenticated
+	@Web.auth
 	def get(self):
 		self.common(
 			path = 'group'
@@ -82,10 +82,10 @@ class group_update_path(Load):
 		)
 		self.commonOne('device_group')
 		self.commonView('update')
-	@tornado.web.authenticated
+	@Web.auth
 	def post(self):
 		self.commonUpdate('device_group')
-	@tornado.web.authenticated
+	@Web.auth
 	def delete(self):
 		self.commonDelete('device_group')
 
@@ -97,7 +97,7 @@ class group_update_path(Load):
 		return gateway
 
 class mul_path(Load):
-	@tornado.web.authenticated
+	@Web.auth
 	def get(self):
 		self.common(
 			name = u'批量控制'
@@ -121,7 +121,7 @@ class mul_path(Load):
 		self.commonView('list')
 
 class mul_update_path(Load):
-	@tornado.web.authenticated
+	@Web.auth
 	def get(self):
 		self.common(
 			path = 'mul'
@@ -131,10 +131,10 @@ class mul_update_path(Load):
 		)
 		self.commonOne('device_mul')
 		self.commonView('update')
-	@tornado.web.authenticated
+	@Web.auth
 	def post(self):
 		self.commonUpdate('device_mul')
-	@tornado.web.authenticated
+	@Web.auth
 	def delete(self):
 		self.commonDelete('device_mul')
 
@@ -146,7 +146,7 @@ class mul_update_path(Load):
 		return gateway
 
 class gateway_path(Load):
-	@tornado.web.authenticated
+	@Web.auth
 	def get(self):
 		self.common(
 			name = u'网关'
@@ -178,7 +178,7 @@ class gateway_path(Load):
 		self.commonView('list')
 
 class gateway_update_path(Load):
-	@tornado.web.authenticated
+	@Web.auth
 	def get(self):
 		self.common(
 			path = 'gateway'
@@ -190,16 +190,16 @@ class gateway_update_path(Load):
 		)
 		self.commonOne('device_gateway')
 		self.commonView('update')
-	@tornado.web.authenticated
+	@Web.auth
 	def post(self):
 		id = self.commonUpdate('device_gateway')
 		self.hardware(id)
 
-	@tornado.web.authenticated
+	@Web.auth
 	def delete(self):
 		self.commonDelete('device_gateway')
 
-	@tornado.web.authenticated
+	@Web.auth
 	def hardware(self, id):
 		hardware_id = self.data['update']['hardware_id']
 		if hardware_id and id > 0:
@@ -214,7 +214,7 @@ class gateway_update_path(Load):
 				
 
 class info_path(Load):
-	@tornado.web.authenticated
+	@Web.auth
 	def get(self):
 		self.common(
 			name = u'设备'
@@ -259,7 +259,7 @@ class info_path(Load):
 		self.commonView('list')
 
 class info_update_path(Load):
-	@tornado.web.authenticated
+	@Web.auth
 	def get(self):
 		self.common(
 			path = 'info'
@@ -271,16 +271,16 @@ class info_update_path(Load):
 		)
 		self.commonOne('device_info')
 		self.commonView('update')
-	@tornado.web.authenticated
+	@Web.auth
 	def post(self):
 		self.commonUpdate('device_info')
-	@tornado.web.authenticated
+	@Web.auth
 	def delete(self):
 		self.commonDelete('device_info')
 
 
 class type_path(Load):
-	@tornado.web.authenticated
+	@Web.auth
 	def get(self):
 		self.common(
 			name = u'类型'
@@ -296,7 +296,7 @@ class type_path(Load):
 		self.commonView('list')
 
 class type_update_path(Load):
-	@tornado.web.authenticated
+	@Web.auth
 	def get(self):
 		self.common(
 			path = 'type'
@@ -305,16 +305,16 @@ class type_update_path(Load):
 		)
 		self.commonOne('device_type')
 		self.commonView('update')
-	@tornado.web.authenticated
+	@Web.auth
 	def post(self):
 		self.commonUpdate('device_type')
-	@tornado.web.authenticated
+	@Web.auth
 	def delete(self):
 		self.commonDelete('device_type')
 
 
 class printer_path(Load):
-	@tornado.web.authenticated
+	@Web.auth
 	def get(self):
 		self.common(
 			name = u'打印机'
@@ -335,7 +335,7 @@ class printer_path(Load):
 		self.commonView('list')
 
 class printer_update_path(Load):
-	@tornado.web.authenticated
+	@Web.auth
 	def get(self):
 		self.common(
 			path = 'printer'
@@ -345,9 +345,9 @@ class printer_update_path(Load):
 		)
 		self.commonOne('device_printer')
 		self.commonView('update')
-	@tornado.web.authenticated
+	@Web.auth
 	def post(self):
 		self.commonUpdate('device_printer')
-	@tornado.web.authenticated
+	@Web.auth
 	def delete(self):
 		self.commonDelete('device_printer')

+ 7 - 7
admin/page/farm.py

@@ -8,7 +8,7 @@
 from __load__ import *
 
 class farm_path(Load):
-	@tornado.web.authenticated
+	@Web.auth
 	def get(self):
 		self.common(
 			name = u'农场' #中文名
@@ -42,7 +42,7 @@ class farm_path(Load):
 		self.commonView('list')
 
 class farm_update_path(Load):
-	@tornado.web.authenticated
+	@Web.auth
 	def get(self):
 		self.common(
 			path = '/farm/farm'
@@ -51,13 +51,13 @@ class farm_update_path(Load):
 		)
 		self.commonOne('farm')
 		self.commonView('update')
-	@tornado.web.authenticated
+	@Web.auth
 	def post(self):
 		id = self.commonUpdate('farm')
 		Demeter.config['setting']['farmList'] = self.service('common').list('farm')
 
 class user_path(Load):
-	@tornado.web.authenticated
+	@Web.auth
 	def get(self):
 		self.common(
 			name = u'用户'
@@ -80,7 +80,7 @@ class user_path(Load):
 		self.commonView('list')
 
 class user_update_path(Load):
-	@tornado.web.authenticated
+	@Web.auth
 	def get(self):
 		self.common(
 			path = '/farm/user'
@@ -90,9 +90,9 @@ class user_update_path(Load):
 		)
 		self.commonOne('farm_user')
 		self.commonView('update')
-	@tornado.web.authenticated
+	@Web.auth
 	def post(self):
 		self.commonUpdate('farm_user', '手机号已经被注册', mobile=self.data['update']['mobile'])
-	@tornado.web.authenticated
+	@Web.auth
 	def delete(self):
 		self.commonDelete('farm_user')

+ 8 - 8
admin/page/hardware.py

@@ -8,7 +8,7 @@
 from __load__ import *
 
 class hardware_path(Load):
-	@tornado.web.authenticated
+	@Web.auth
 	def get(self):
 		self.common(
 			name = u'硬件设备'
@@ -43,7 +43,7 @@ class hardware_path(Load):
 		self.commonView('list')
 
 class hardware_update_path(Load):
-	@tornado.web.authenticated
+	@Web.auth
 	def get(self):
 		self.common(
 			path = '/hardware/hardware'
@@ -53,15 +53,15 @@ class hardware_update_path(Load):
 		)
 		self.commonOne('hardware')
 		self.commonView('update')
-	@tornado.web.authenticated
+	@Web.auth
 	def post(self):
 		self.commonUpdate('hardware')
-	@tornado.web.authenticated
+	@Web.auth
 	def delete(self):
 		self.commonDelete('hardware')
 
 class type_path(Load):
-	@tornado.web.authenticated
+	@Web.auth
 	def get(self):
 		self.common(
 			name = u'硬件类型'
@@ -77,7 +77,7 @@ class type_path(Load):
 		self.commonView('list')
 
 class type_update_path(Load):
-	@tornado.web.authenticated
+	@Web.auth
 	def get(self):
 		self.common(
 			path = '/hardware/type'
@@ -86,9 +86,9 @@ class type_update_path(Load):
 		)
 		self.commonOne('hardware_type')
 		self.commonView('update')
-	@tornado.web.authenticated
+	@Web.auth
 	def post(self):
 		self.commonUpdate('hardware_type')
-	@tornado.web.authenticated
+	@Web.auth
 	def delete(self):
 		self.commonDelete('hardware_type')

+ 2 - 2
admin/page/main.py

@@ -8,11 +8,11 @@
 from __load__ import *
 
 class index_path(Load):
-	@tornado.web.authenticated
+	@Web.auth
 	def get(self):
 		self.view("index.html")
 
 class main_path(Load):
-	@tornado.web.authenticated
+	@Web.auth
 	def get(self):
 		self.view("main.html")

+ 8 - 8
admin/page/msg.py

@@ -10,7 +10,7 @@ from __load__ import *
 push = ({'id':'sms', 'name':'短信'}, {'id':'weixin', 'name':'微信'})
 
 class msg_path(Load):
-	@tornado.web.authenticated
+	@Web.auth
 	def get(self):
 		self.common(
 			name = u'消息'
@@ -45,7 +45,7 @@ class msg_path(Load):
 		self.commonView('list')
 
 class msg_update_path(Load):
-	@tornado.web.authenticated
+	@Web.auth
 	def get(self):
 		self.common(
 			path = '/msg/msg'
@@ -58,16 +58,16 @@ class msg_update_path(Load):
 		)
 		self.commonOne('msg')
 		self.commonView('update')
-	@tornado.web.authenticated
+	@Web.auth
 	def post(self):
 		# 发消息
 		self.commonUpdate('msg')
-	@tornado.web.authenticated
+	@Web.auth
 	def delete(self):
 		self.commonDelete('msg')
 
 class type_path(Load):
-	@tornado.web.authenticated
+	@Web.auth
 	def get(self):
 		self.common(
 			name = u'消息类型'
@@ -83,7 +83,7 @@ class type_path(Load):
 		self.commonView('list')
 
 class type_update_path(Load):
-	@tornado.web.authenticated
+	@Web.auth
 	def get(self):
 		self.common(
 			path = '/msg/type'
@@ -93,9 +93,9 @@ class type_update_path(Load):
 		)
 		self.commonOne('msg_type')
 		self.commonView('update')
-	@tornado.web.authenticated
+	@Web.auth
 	def post(self):
 		self.commonUpdate('msg_type')
-	@tornado.web.authenticated
+	@Web.auth
 	def delete(self):
 		self.commonDelete('msg_type')

+ 9 - 9
admin/page/origin.py

@@ -8,7 +8,7 @@
 from __load__ import *
 
 class batch_path(Load):
-	@tornado.web.authenticated
+	@Web.auth
 	def get(self):
 		self.common(
 			name = u'溯源批次'
@@ -16,7 +16,7 @@ class batch_path(Load):
 			,width = '600'
 			,height = '600'
 			,search = (('farm_id-select-','land_id-select-'), (u'选择农场',u'地块'))
-			,thead = (u'所属农场', u'产品名称', u'种植时间', u'采收时间', u'设备', u'地块')
+			,thead = (u'所属农场', u'产品名称', u'种植时间', u'采收时间', u'设备网关', u'地块')
 			,tbody = ('farm','name', 'zzdate', 'csdate', 'device', 'land')
 			,state = True
 		)
@@ -27,28 +27,28 @@ class batch_path(Load):
 			for key, value in enumerate(self.data['list']):
 				farm = self.service('common').one('farm', id=value['farm_id'])
 				self.data['list'][key]['farm'] = farm['name']
-				device = self.service('common').one('device_info', id=value['device_id'])
+				device = self.service('common').one('device_gateway', id=value['gateway_id'])
 				self.data['list'][key]['device'] = device['name']
 				land = self.service('common').one('farm_work_land', id=value['land_id'])
 				self.data['list'][key]['land'] = land['name']
 		self.commonView('list')
 
 class batch_update_path(Load):
-	@tornado.web.authenticated
+	@Web.auth
 	def get(self):
 		self.common(
 			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','device_id-select-required','land_id-select-required','pic-pic-required')
-			,update_device_id = self.service('common').list('device_info')
+			,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_land_id = self.service('common').list('farm_work_land')
 			,update_farm_id = Demeter.config['setting']['farmList']
 		)
 		self.commonOne('origin_batch')
 		self.commonView('update')
-	@tornado.web.authenticated
+	@Web.auth
 	def post(self):
 		self.commonUpdate('origin_batch')
-	@tornado.web.authenticated
+	@Web.auth
 	def delete(self):
 		self.commonDelete('origin_batch')

+ 1 - 1
admin/page/upload.py

@@ -11,7 +11,7 @@ import os
 import uuid
 
 class upload_path(Load):
- 	@tornado.web.authenticated
+ 	@Web.auth
 	def post(self, *args, **kwargs):
 		url = self.request.protocol + "://" + self.request.host
 		file_metas = self.request.files["file"]

+ 14 - 14
admin/page/work.py

@@ -8,7 +8,7 @@
 from __load__ import *
 
 class work_path(Load):
-	@tornado.web.authenticated
+	@Web.auth
 	def get(self):
 		self.common(
 			name = u'农事'
@@ -34,7 +34,7 @@ class work_path(Load):
 		self.commonView('list')
 
 class work_update_path(Load):
-	@tornado.web.authenticated
+	@Web.auth
 	def get(self):
 		self.common(
 			path = '/work/work'
@@ -46,21 +46,21 @@ class work_update_path(Load):
 		)
 		self.commonOne('farm_work')
 		self.commonView('update')
-	@tornado.web.authenticated
+	@Web.auth
 	def post(self):
 		self.commonUpdate('farm_work')
-	@tornado.web.authenticated
+	@Web.auth
 	def delete(self):
 		self.commonDelete('farm_work')
 
 class category_path(Load):
-	@tornado.web.authenticated
+	@Web.auth
 	def get(self):
 		self.common(
 			name = u'劳作方式'
 			,path = '/work/category'
 			,width = '600'
-			,height = '200'
+			,height = '250'
 			,search = (('label-1','cdate-time-start','cdate-time-end','farm_id-select-','name-input-mlike'), (u'日期范围',u'开始时间',u'截止时间',u'选择农场',u'方式名称'))
 			,thead = (u'所属农场',u'方式名称', u'更新时间')
 			,tbody = ('farm', 'name', 'cdate')
@@ -75,7 +75,7 @@ class category_path(Load):
 		self.commonView('list')
 
 class category_update_path(Load):
-	@tornado.web.authenticated
+	@Web.auth
 	def get(self):
 		self.common(
 			path = '/work/category'
@@ -85,22 +85,22 @@ class category_update_path(Load):
 		)
 		self.commonOne('farm_work_category')
 		self.commonView('update')
-	@tornado.web.authenticated
+	@Web.auth
 	def post(self):
 		self.commonUpdate('farm_work_category')
-	@tornado.web.authenticated
+	@Web.auth
 	def delete(self):
 		self.commonDelete('farm_work_category')
 
 
 class land_path(Load):
-	@tornado.web.authenticated
+	@Web.auth
 	def get(self):
 		self.common(
 			name = u'地块'
 			,path = '/work/land'
 			,width = '600'
-			,height = '200'
+			,height = '250'
 			,search = (('label-1','cdate-time-start','cdate-time-end','farm_id-select-','name-input-mlike'), (u'日期范围',u'开始时间',u'截止时间',u'选择农场',u'地块名称'))
 			,thead = (u'所属农场',u'地块名称', u'更新时间')
 			,tbody = ('farm', 'name', 'cdate')
@@ -115,7 +115,7 @@ class land_path(Load):
 		self.commonView('list')
 
 class land_update_path(Load):
-	@tornado.web.authenticated
+	@Web.auth
 	def get(self):
 		self.common(
 			path = '/work/land'
@@ -125,9 +125,9 @@ class land_update_path(Load):
 		)
 		self.commonOne('farm_work_land')
 		self.commonView('update')
-	@tornado.web.authenticated
+	@Web.auth
 	def post(self):
 		self.commonUpdate('farm_work_land')
-	@tornado.web.authenticated
+	@Web.auth
 	def delete(self):
 		self.commonDelete('farm_work_land')

+ 11 - 0
doc/apidoc.json

@@ -0,0 +1,11 @@
+{
+  "name": "农小盒接口文档",
+  "version": "1.0.0",
+  "description": "农小盒接口文档",
+  "title": "农小盒接口文档",
+  "url" : "https://api.nongxiaohe.com/v1.0.0",
+  "template": {
+  	"withCompare": true,
+  	"withGenerator": true
+  }
+}

+ 0 - 1
front/api/__init__.py

@@ -5,7 +5,6 @@
     author:rabin
     这里写页面逻辑
 """
-import os
 from demeter.web import *
 path = os.path.split(os.path.realpath(__file__))[0] + '/'
 files = Web.file(path)

+ 13 - 1
front/api/__load__.py

@@ -6,8 +6,20 @@
 """
 from demeter.web import *
 
+# 这里做微信的登录认证
+def auth(method):
+	def wrapper(self, *args, **kwargs):
+		return method(self, *args, **kwargs)
+	return wrapper
+
+class Weixin(object):
+
+	def check(self):
+		return
+
 class Load(Base):
-	KEYS = ('farm', 'user')
+	KEYS = ('user', 'farm')
 
 	def setting(self):
+		Demeter.config['setting']['farm'] = 1
 		return

+ 82 - 0
front/api/farm.py

@@ -0,0 +1,82 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+"""
+	demeter web
+	name:farm.py 农场相关
+	author:rabin
+"""
+from __load__ import *
+
+class index_path(Load):
+	"""
+	@api {get} /farm 获取农场基本信息
+	@apiVersion 1.0.0
+	@apiName getFarm
+	@apiGroup Farm
+
+	@apiSuccess {Object[]} setting 基本信息
+	@apiSuccess {String}   setting.name  站点名
+	@apiSuccess {Number}   setting.farm  当前的农场ID
+
+	@apiSuccess {Object[]} farm 农场基本信息
+	@apiSuccess {String}   farm.name  农场名
+	@apiSuccess {String}   farm.master_name  联系人
+	@apiSuccess {String}   farm.tel  联系电话
+	@apiSuccess {String}   farm.address  农场地址
+
+	@apiErrorExample 操作成功
+	{"status": 1, "msg": "yes", "code": 0, "data": {"farm": {"info": "", "master_name": "", "tel": "", "name": "\u9ed8\u8ba4\u56ed\u533a", "pic": "", "cdate": 1503915445, "state": true, "address": "", "id": 1}, "setting": {"farm": 1, "user": 0, "name": "\u519c\u5c0f\u76d2", "copyright": "2017 nongxiaohe.com v1.0.0", "site": "http://www.nongxiaohe.com/"}}}
+	@apiErrorExample 操作失败
+	{"status": 2, "msg": "\u64cd\u4f5c\u5931\u8d25", "code": 0, "data": {}}
+	"""
+	@auth
+	def get(self):
+		# 获取农场信息
+		self.data['farm'] = self.service('common').one('farm', id=Demeter.config['setting']['farm'])
+		self.out('yes', self.data)
+
+	"""
+	@api {post} /farm 更新农场信息
+	@apiVersion 1.0.0
+	@apiName updateFarm
+	@apiGroup Farm
+
+	@apiParam {String} id 农事ID,为空则插入新记录
+	@apiParam {String} update_name 农场名称
+	@apiParam {String} update_address 农场地址
+	@apiParam {String} update_master_name 联系人
+	@apiParam {String} update_tel 联系电话
+	@apiParam {String} update_pic 农场照片
+
+	@apiSuccess {Bool} status 状态
+	@apiSuccess {String}   msg  描述
+	@apiSuccess {Number}   code  状态码
+
+	@apiErrorExample 操作成功
+	{"status": 1, "msg": "操作成功", "code": 0, "data": {}}
+	@apiErrorExample 操作失败
+	{"status": 2, "msg": "\u64cd\u4f5c\u5931\u8d25", "code": 0, "data": {}}
+	"""
+	@auth
+	def post(self):
+		id = self.input('id', None)
+		update = {}
+		update['pic'] = self.input('update_pic')
+		update['name'] = self.input('update_name')
+		update['master_name'] = self.input('update_master_name')
+		update['address'] = self.input('update_address')
+		update['tel'] = self.input('update_tel')
+		if not update['name']:
+			self.out(u'请输入农场名称')
+			return
+		if not update['master_name']:
+			self.out(u'请输入农场联系人')
+			return
+		if not update['address']:
+			self.out(u'请输入农场地址')
+			return
+		if not update['tel']:
+			self.out(u'请输入联系电话')
+			return
+		state = self.service('common').update('farm', id, update)
+		self.out('yes', {'id':state})

+ 13 - 0
front/api/login.py

@@ -0,0 +1,13 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+"""
+	demeter web
+	name:login.py 登录相关接口
+	author:rabin
+"""
+from __load__ import *
+
+class login_path(Load):
+
+	def get(self):
+		self.out('test')

+ 32 - 3
front/api/main.py

@@ -1,13 +1,42 @@
 #!/usr/bin/env python
 # -*- coding: utf-8 -*-
 """
-    demeter web page
-    name:admin.py 管理员相关页面
+    demeter web
+    name:main.py 主界面相关api
     author:rabin
 """
 from __load__ import *
 
 class index_path(Load):
+	"""
+	@api {get} / 获取首页信息
+	@apiVersion 1.0.0
+	@apiName getIndex
+	@apiGroup Common
 
+	@apiSuccess {Object[]} setting 基本信息
+	@apiSuccess {String}   setting.name  站点名
+	@apiSuccess {Number}   setting.farm  当前的农场ID
+
+	@apiSuccess {Object[]} farm 农场基本信息
+	@apiSuccess {String}   farm.name  农场名
+
+	@apiSuccess {Object[]} gateway 网关信息
+	@apiSuccess {String}   gateway.name  网关名称
+	@apiSuccess {String}   gateway.id    网关ID
+	@apiErrorExample 操作成功
+	{"status": 1, "msg": "yes", "code": 0, "data": {"farm": {"info": "", "master_name": "", "tel": "", "name": "\u9ed8\u8ba4\u56ed\u533a", "pic": "", "cdate": 1503915445, "state": true, "address": "", "id": 1}, "setting": {"farm": 1, "user": 0, "name": "\u519c\u5c0f\u76d2", "copyright": "2017 nongxiaohe.com v1.0.0", "site": "http://www.nongxiaohe.com/"}, "msg": 0, "gateway": [{"status": false, "hardware_id": 3213, "name": "323", "farm_id": 2, "cdate": 1504075691, "state": true, "power_num": null, "power_status": false, "id": "d53db924-2043-500f-8140-b24780bb4691"}, {"status": false, "hardware_id": 10086, "name": "\u9ed8\u8ba4\u7f51\u5173", "farm_id": 1, "cdate": 1503915445, "state": true, "power_num": null, "power_status": false, "id": "5828ba1d-10de-5ebc-988d-345bc5ad40a8"}]}}
+	@apiErrorExample 操作失败
+	{"status": 2, "msg": "\u64cd\u4f5c\u5931\u8d25", "code": 0, "data": {}}
+	"""
+	@auth
 	def get(self):
-		self.out('test')
+		# 获取网关
+		self.data['gateway'] = self.service('common').list('device_gateway', state=True)
+
+		# 获取农场信息
+		self.data['farm'] = self.service('common').one('farm', id=Demeter.config['setting']['farm'])
+
+		# 获取消息数量
+		self.data['msg'] = len(self.service('common').list('msg', state=True))
+		self.out('yes', self.data)

+ 125 - 0
front/api/origin.py

@@ -0,0 +1,125 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+"""
+	demeter web
+	name:origin.py 溯源相关
+	author:rabin
+"""
+from __load__ import *
+
+class index_path(Load):
+	"""
+	@api {get} /origin 获取溯源批次列表
+	@apiVersion 1.0.0
+	@apiName getOrigin
+	@apiGroup Farm
+
+	@apiSuccess {Object[]} setting 基本信息
+	@apiSuccess {String}   setting.name  站点名
+	@apiSuccess {Number}   setting.farm  当前的农场ID
+
+	@apiSuccess {Object[]} list 溯源批次列表信息
+	@apiSuccess {String}   list.name  名称
+	@apiSuccess {String}   list.id	ID
+	@apiErrorExample 操作成功
+	{"status": 1, "msg": "yes", "code": 0, "data": {"setting": {"farm": 1, "user": 0, "name": "\u519c\u5c0f\u76d2", "copyright": "2017 nongxiaohe.com v1.0.0", "site": "http://www.nongxiaohe.com/"}, "list": [{"pic": "http://192.168.15.10:8087/upload/2017/08/30/455f9d6c26b5c989b32eda1809e58d5f.jpg", "method_id": null, "land_id": "249be20d-5759-5af0-9859-b770d9f44e2a", "farm_id": 1, "state": true, "amount": "100ml", "workdate": 1504105397, "category_id": "9365ea66-be55-56f7-a511-059fc85a9478", "cdate": 1504076614, "id": "19e05f00-ae55-5605-be12-86dcd2866df9"}], "page": {"current": 1, "ajax": false, "total": 1.0, "num": 15, "totalNum": 1}}}
+	@apiErrorExample 操作失败
+	{"status": 2, "msg": "\u64cd\u4f5c\u5931\u8d25", "code": 0, "data": {}}
+	"""
+	@auth
+	def get(self):
+		self.data['list'] = self.service('common').list('origin_batch', state=True, page=True)
+		if self.data['list']:
+			for key, value in enumerate(self.data['list']):
+				self.data['list'][key]['zzdates'] = Demeter.date(value['zzdate'], '%Y-%m-%d')
+				self.data['list'][key]['csdates'] = Demeter.date(value['csdate'], '%Y-%m-%d')
+				device = self.service('common').one('device_gateway', id=value['gateway_id'])
+				self.data['list'][key]['device'] = device['name']
+				land = self.service('common').one('gateway_id', id=value['gateway_id'])
+				self.data['list'][key]['land'] = land['name']
+		self.out('yes', self.data)
+
+	"""
+	@api {post} /origin 更新溯源批次
+	@apiVersion 1.0.0
+	@apiName updateOrigin
+	@apiGroup Farm
+
+	@apiParam {String} id 批次ID,为空则插入新记录
+	@apiParam {String} update_name 批次名称
+	@apiParam {String} update_pic 图片,多个逗号隔开
+	@apiParam {String} update_device_id 设备网关ID
+	@apiParam {String} update_land 地块ID
+	@apiParam {String} update_zzdate 种植时间:2017-10-10
+	@apiParam {String} update_csdate 采收时间:2017-10-10
+
+	@apiSuccess {Bool} status 状态
+	@apiSuccess {String}   msg  描述
+	@apiSuccess {Number}   code  状态码
+
+	@apiErrorExample 操作成功
+	{"status": 1, "msg": "操作成功", "code": 0, "data": {}}
+	@apiErrorExample 操作失败
+	{"status": 2, "msg": "\u64cd\u4f5c\u5931\u8d25", "code": 0, "data": {}}
+	"""
+	@auth
+	def post(self):
+		id = self.input('id', None)
+		update = {}
+		update['pic'] = self.input('update_pic')
+		update['gateway_id'] = self.input('update_device_id')
+		update['land'] = self.input('update_land')
+		update['zzdate'] = self.input('update_zzdate')
+		update['csdate'] = self.input('update_csdate')
+		update['name'] = self.input('update_name')
+		if not update['gateway_id']:
+			self.out(u'请选择设备')
+			return
+		if not update['land']:
+			self.out(u'请选择地块')
+			return
+		if not update['zzdate']:
+			self.out(u'请输入种植时间')
+			return
+		if not update['csdate']:
+			self.out(u'请输入采收时间')
+			return
+		if not update['name']:
+			self.out(u'请输入产品名称')
+			return
+		update['zzdate'] = Demeter.mktime(update['zzdate'], '%Y-%m-%d')
+		update['csdate'] = Demeter.mktime(update['csdate'], '%Y-%m-%d')
+		state = self.service('common').update('origin_batch', id, update)
+		self.out('yes', {'id':state})
+
+class info_path(Load):
+	"""
+	@api {get} /origin/info 获取溯源批次信息
+	@apiVersion 1.0.0
+	@apiName getOrigin
+	@apiGroup Farm
+
+	@apiSuccess {Object[]} setting 基本信息
+	@apiSuccess {String}   setting.name  站点名
+	@apiSuccess {Number}   setting.farm  当前的农场ID
+
+	@apiSuccess {Object[]} info 溯源批次信息
+	@apiSuccess {String}   info.name  名称
+	@apiSuccess {String}   info.id	ID
+	@apiErrorExample 操作成功
+	{"status": 1, "msg": "yes", "code": 0, "data": {"setting": {"farm": 1, "user": 0, "name": "\u519c\u5c0f\u76d2", "copyright": "2017 nongxiaohe.com v1.0.0", "site": "http://www.nongxiaohe.com/"}, "list": [{"pic": "http://192.168.15.10:8087/upload/2017/08/30/455f9d6c26b5c989b32eda1809e58d5f.jpg", "method_id": null, "land_id": "249be20d-5759-5af0-9859-b770d9f44e2a", "farm_id": 1, "state": true, "amount": "100ml", "workdate": 1504105397, "category_id": "9365ea66-be55-56f7-a511-059fc85a9478", "cdate": 1504076614, "id": "19e05f00-ae55-5605-be12-86dcd2866df9"}], "page": {"current": 1, "ajax": false, "total": 1.0, "num": 15, "totalNum": 1}}}
+	@apiErrorExample 操作失败
+	{"status": 2, "msg": "\u64cd\u4f5c\u5931\u8d25", "code": 0, "data": {}}
+	"""
+	@auth
+	def get(self):
+		id = self.input('id', None)
+		if id:
+			self.data['info'] = self.service('common').one('origin_batch', {id:id})
+			if self.data['info']:
+				self.data['info']['zzdates'] = Demeter.date(self.data['info']['zzdate'], '%Y-%m-%d')
+				self.data['info']['csdates'] = Demeter.date(self.data['info']['csdate'], '%Y-%m-%d')
+				
+			self.out('yes', self.data)
+		else:
+			self.out('no')

+ 48 - 0
front/api/upload.py

@@ -0,0 +1,48 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+"""
+    demeter web page
+    name:upload.py
+    author:rabin
+"""
+from __load__ import *
+from datetime import *
+import os
+import uuid
+
+class index_path(Load):
+	"""
+	@api {post} /upload 上传图片
+	@apiVersion 1.0.0
+	@apiName upload
+	@apiGroup Common
+
+	@apiParam {String} file 文件流名称
+
+	@apiSuccess {Bool} status 状态
+	@apiSuccess {String}   msg  描述
+	@apiSuccess {Number}   code  状态码
+	@apiSuccess {Object[]} data 返回数据
+	@apiSuccess {String}   data.src  图片地址
+
+	@apiErrorExample 操作成功
+	{"status": 1, "msg": "操作成功", "code": 0, "data": {"src":"url"}}
+	@apiErrorExample 操作失败
+	{"status": 2, "msg": "\u64cd\u4f5c\u5931\u8d25", "code": 0, "data": {}}
+	"""
+ 	@auth
+	def post(self, *args, **kwargs):
+		url = self.request.protocol + "://" + self.request.host
+		file_metas = self.request.files["file"]
+
+		# print(file_metas)
+		day = str(date.today())
+		day = day.split('-')
+		for meta in file_metas:
+			#meta['filename']
+			file_name =  str(uuid.uuid5(uuid.uuid1(), 'file'))
+			file_path = day[0] + '/' + day[1] + '/' + day[2]
+			file_path = File.mkdirs(os.path.join(Demeter.path, 'runtime','upload', file_path)) + '/' + Demeter.md5(file_name) + '.jpg'
+			with open(file_path, 'wb') as up:
+				up.write(meta['body'])
+		self.out('yes', {'src':url + file_path.replace(Demeter.path + 'runtime', '')})

+ 200 - 0
front/api/work.py

@@ -0,0 +1,200 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+"""
+	demeter web
+	name:work.py 农事相关
+	author:rabin
+"""
+from __load__ import *
+
+class index_path(Load):
+	"""
+	@api {get} /work 获取农事记录列表
+	@apiVersion 1.0.0
+	@apiName getWorkList
+	@apiGroup Farm
+
+	@apiSuccess {Object[]} setting 基本信息
+	@apiSuccess {String}   setting.name  站点名
+	@apiSuccess {Number}   setting.farm  当前的农场ID
+
+	@apiSuccess {Object[]} list 农事列表信息
+	@apiSuccess {String}   list.name  名称
+	@apiSuccess {String}   list.id	ID
+	@apiErrorExample 操作成功
+	{"status": 1, "msg": "yes", "code": 0, "data": {"setting": {"farm": 1, "user": 0, "name": "\u519c\u5c0f\u76d2", "copyright": "2017 nongxiaohe.com v1.0.0", "site": "http://www.nongxiaohe.com/"}, "list": [{"pic": "http://192.168.15.10:8087/upload/2017/08/30/455f9d6c26b5c989b32eda1809e58d5f.jpg", "method_id": null, "land_id": "249be20d-5759-5af0-9859-b770d9f44e2a", "farm_id": 1, "state": true, "amount": "100ml", "workdate": 1504105397, "category_id": "9365ea66-be55-56f7-a511-059fc85a9478", "cdate": 1504076614, "id": "19e05f00-ae55-5605-be12-86dcd2866df9"}], "page": {"current": 1, "ajax": false, "total": 1.0, "num": 15, "totalNum": 1}}}
+	@apiErrorExample 操作失败
+	{"status": 2, "msg": "\u64cd\u4f5c\u5931\u8d25", "code": 0, "data": {}}
+	"""
+	@auth
+	def get(self):
+		self.data['list'] = self.service('common').list('farm_work', state=True, page=True)
+		if self.data['list']:
+			for key, value in enumerate(self.data['list']):
+				self.data['list'][key]['workdates'] = Demeter.date(value['workdate'], '%Y-%m-%d')
+				category = self.service('common').one('farm_work_category', id=value['category_id'])
+				self.data['list'][key]['category'] = category['name']
+				land = self.service('common').one('farm_work_land', id=value['land_id'])
+				self.data['list'][key]['land'] = land['name']
+				self.data['list'][key]['name'] = self.data['list'][key]['workdates'] + ' - ' + land['name'] + '/' + category['name']
+		self.out('yes', self.data)
+
+	"""
+	@api {post} /work 更新农事记录
+	@apiVersion 1.0.0
+	@apiName updateWork
+	@apiGroup Farm
+
+	@apiParam {String} id 农事ID,为空则插入新记录
+	@apiParam {String} update_pic 图片,多个逗号隔开
+	@apiParam {String} update_category 农事方式ID
+	@apiParam {String} update_land 地块ID
+	@apiParam {String} update_workdate 农事时间:2017-10-10
+	@apiParam {String} update_content 劳作内容
+	@apiParam {String} update_amount 劳作数量
+
+	@apiSuccess {Bool} status 状态
+	@apiSuccess {String}   msg  描述
+	@apiSuccess {Number}   code  状态码
+
+	@apiErrorExample 操作成功
+	{"status": 1, "msg": "操作成功", "code": 0, "data": {}}
+	@apiErrorExample 操作失败
+	{"status": 2, "msg": "\u64cd\u4f5c\u5931\u8d25", "code": 0, "data": {}}
+	"""
+	@auth
+	def post(self):
+		id = self.input('id', None)
+		update = {}
+		update['pic'] = self.input('update_pic')
+		update['category'] = self.input('update_category')
+		update['land'] = self.input('update_land')
+		update['workdate'] = self.input('update_workdate')
+		update['content'] = self.input('update_content')
+		update['amount'] = self.input('update_amount')
+		if not update['category']:
+			self.out(u'请选择农事方式')
+			return
+		if not update['land']:
+			self.out(u'请选择地块')
+			return
+		if not update['workdate']:
+			self.out(u'请输入农事时间')
+			return
+		if not update['content']:
+			self.out(u'请输入劳作内容')
+			return
+		if not update['amount']:
+			self.out(u'请输入劳作数量')
+			return
+		update['workdate'] = Demeter.mktime(update['workdate'], '%Y-%m-%d')
+		state = self.service('common').update('farm_work', id, update)
+		self.out('yes', {'id':state})
+
+class info_path(Load):
+	"""
+	@api {get} /work/info 获取农事信息
+	@apiVersion 1.0.0
+	@apiName getWork
+	@apiGroup Farm
+
+	@apiSuccess {Object[]} setting 基本信息
+	@apiSuccess {String}   setting.name  站点名
+	@apiSuccess {Number}   setting.farm  当前的农场ID
+
+	@apiSuccess {Object[]} info 农事信息
+	@apiSuccess {String}   info.name  名称
+	@apiSuccess {String}   info.id  ID
+	@apiErrorExample 操作成功
+	{"status": 1, "msg": "yes", "code": 0, "data": {"setting": {"farm": 1, "user": 0, "name": "\u519c\u5c0f\u76d2", "copyright": "2017 nongxiaohe.com v1.0.0", "site": "http://www.nongxiaohe.com/"}, "list": [{"pic": "http://192.168.15.10:8087/upload/2017/08/30/455f9d6c26b5c989b32eda1809e58d5f.jpg", "method_id": null, "land_id": "249be20d-5759-5af0-9859-b770d9f44e2a", "farm_id": 1, "state": true, "amount": "100ml", "workdate": 1504105397, "category_id": "9365ea66-be55-56f7-a511-059fc85a9478", "cdate": 1504076614, "id": "19e05f00-ae55-5605-be12-86dcd2866df9"}], "page": {"current": 1, "ajax": false, "total": 1.0, "num": 15, "totalNum": 1}}}
+	@apiErrorExample 操作失败
+	{"status": 2, "msg": "\u64cd\u4f5c\u5931\u8d25", "code": 0, "data": {}}
+	"""
+	@auth
+	def get(self):
+		id = self.input('id', None)
+		if id:
+			self.data['info'] = self.service('common').one('farm_work', {id:id})
+			if self.data['info']:
+				self.data['info']['workdates'] = Demeter.date(self.data['info']['workdate'], '%Y-%m-%d')
+				
+			self.out('yes', self.data)
+		else:
+			self.out('no')
+
+class land_path(Load):
+	"""
+	@api {get} /work/land 获取农事地块列表
+	@apiVersion 1.0.0
+	@apiName getWorkLandList
+	@apiGroup Farm
+
+	@apiSuccess {Object[]} setting 基本信息
+	@apiSuccess {String}   setting.name  站点名
+	@apiSuccess {Number}   setting.farm  当前的农场ID
+
+	@apiSuccess {Object[]} list 地块列表信息
+	@apiSuccess {String}   list.name  名称
+	@apiSuccess {String}   list.id	ID
+	@apiErrorExample 操作成功
+	{"status": 1, "msg": "yes", "code": 0, "data": {"setting": {"farm": 1, "user": 0, "name": "\u519c\u5c0f\u76d2", "copyright": "2017 nongxiaohe.com v1.0.0", "site": "http://www.nongxiaohe.com/"}, "list": [{"state": true, "farm_id": 1, "cdate": 1504074548, "id": "249be20d-5759-5af0-9859-b770d9f44e2a", "name": "test"}]}}
+	@apiErrorExample 操作失败
+	{"status": 2, "msg": "\u64cd\u4f5c\u5931\u8d25", "code": 0, "data": {}}
+	"""
+	@auth
+	def get(self):
+		self.data['list'] = self.service('common').list('farm_work_land', state=True)
+		self.out('yes', self.data)
+
+	"""
+	@api {post} /work/land 更新地块
+	@apiVersion 1.0.0
+	@apiName updateWorkLand
+	@apiGroup Farm
+
+	@apiParam {String} id 地块ID,为空则插入新记录
+	@apiParam {String} update_name 地块名称
+
+	@apiSuccess {Bool} status 状态
+	@apiSuccess {String}   msg  描述
+	@apiSuccess {Number}   code  状态码
+
+	@apiErrorExample 操作成功
+	{"status": 1, "msg": "操作成功", "code": 0, "data": {}}
+	@apiErrorExample 操作失败
+	{"status": 2, "msg": "\u64cd\u4f5c\u5931\u8d25", "code": 0, "data": {}}
+	"""
+	@auth
+	def post(self):
+		id = self.input('id', None)
+		update = {}
+		update['name'] = self.input('update_name')
+		if not update['name']:
+			self.out(u'请输入地块名称')
+			return
+		state = self.service('common').update('farm_work_land', id, update)
+		self.out('yes', {'id':state})
+
+class category_path(Load):
+	"""
+	@api {get} /work/category 获取农事分类列表
+	@apiVersion 1.0.0
+	@apiName getWorkCateList
+	@apiGroup Farm
+
+	@apiSuccess {Object[]} setting 基本信息
+	@apiSuccess {String}   setting.name  站点名
+	@apiSuccess {Number}   setting.farm  当前的农场ID
+
+	@apiSuccess {Object[]} list 分类列表信息
+	@apiSuccess {String}   list.name  名称
+	@apiSuccess {String}   list.id	ID
+	@apiErrorExample 操作成功
+	{"status": 1, "msg": "yes", "code": 0, "data": {"setting": {"farm": 1, "user": 0, "name": "\u519c\u5c0f\u76d2", "copyright": "2017 nongxiaohe.com v1.0.0", "site": "http://www.nongxiaohe.com/"}, "list": [{"state": true, "farm_id": 1, "cdate": 1504074837, "id": "9365ea66-be55-56f7-a511-059fc85a9478", "name": "\u65bd\u80a5"}]}}
+	@apiErrorExample 操作失败
+	{"status": 2, "msg": "\u64cd\u4f5c\u5931\u8d25", "code": 0, "data": {}}
+	"""
+	@auth
+	def get(self):
+		self.data['list'] = self.service('common').list('farm_work_category', state=True)
+		self.out('yes', self.data)

+ 2 - 2
model/farm_work.py

@@ -14,9 +14,9 @@ class Farm_work(Model):
 	farm_id = Fields(type='int', default='setting.farm', comment='园区ID', match='not')
 	amount = Fields(type='varchar(150)', comment='劳作用量')
 	category_id = Fields(type='uuid', comment='劳作分类id')
-	method_id = Fields(type='uuid', comment='劳作具体内容id')
+	content = Fields(type='varchar(300)', comment='劳作具体内容')
 	land_id = Fields(type='uuid', comment='地块id')
-	pic = Fields(type='varchar(255)', comment='图像记录')
+	pic = Fields(type='text', comment='图像记录')
 	workdate = Fields(type='int', comment='劳作时间')
 	state = Fields(type='boolean', default='True', comment='数据存在状态')
 	cdate = Fields(type='int', default='time', comment='创建时间')

+ 18 - 0
model/farm_work_land_pic.py

@@ -0,0 +1,18 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+"""
+    demeter database
+    name:farm_work_land_pic.py
+    author:rabin
+"""
+from __load__ import *
+
+class Farm_work_land_pic(Model):
+	__table__ = 'farm_work_land_pic'
+	__comment__ = '农事地块照片表'
+	id = Fields(type='uuid', primaryKey=True, comment='地块ID', uuid='farm_id')
+	farm_id = Fields(type='int', default='setting.farm', comment='园区ID', match='not')
+	land_id = Fields(type='uuid', comment='地块id')
+	pic = Fields(type='text', comment='图像记录')
+	state = Fields(type='boolean', default='True', comment='数据存在状态')
+	cdate = Fields(type='int', default='time', comment='创建时间')

+ 1 - 1
model/origin_batch.py

@@ -15,7 +15,7 @@ class Origin_batch(Model):
 	name = Fields(type='varchar(150)', comment='产品名')
 	zzdate = Fields(type='int', comment='种植时间')
 	csdate = Fields(type='int', comment='采收时间')
-	device_id = Fields(type='uuid', comment='设备id')
+	gateway_id = Fields(type='uuid', comment='网关id')
 	land_id = Fields(type='uuid', comment='地块id')
 	pic = Fields(type='text', comment='图片')
 	state = Fields(type='boolean', default='True', comment='数据存在状态')