rabin 8 år sedan
förälder
incheckning
b89eca4116
1 ändrade filer med 8 tillägg och 7 borttagningar
  1. 8 7
      service/device.py

+ 8 - 7
service/device.py

@@ -133,7 +133,7 @@ class Device(object):
 						oper = '关闭'
 
 				# 如果有批量控制
-				self.mul(info['id'], info['name'], param['switch'], '失败:' + msg, False)
+				self.mul(info['id'], info['name'], param['switch'], '失败:' + msg, False, oper=oper)
 
 				content = oper + gateway['name'] + '下的'+ info['name'] + '失败,错误提示:' + msg
 				Demeter.service('record').msg(info['id'], content, info['farm_id'], 3)
@@ -143,12 +143,12 @@ class Device(object):
 	def notice(self, msg):
 		model = Demeter.model('notice_type')
 		model.key = msg
-		info = model.select(type='fetchone') 
+		info = model.select(type='fetchone')
 		if info:
 			msg = info['name']
 		return msg
 
-	def mul(self, id, name, switch, msg, state):
+	def mul(self, id, name, switch, msg, state, oper=''):
 		model = Demeter.model('device_mul_queue')
 		model.device_id = id
 		queue = model.select()
@@ -160,9 +160,10 @@ class Device(object):
 			if msg:
 				for v in queue:
 					model.id = v['mul_id']
-					if switch == 1:
-						oper = '开启'
-					else:
-						oper = '关闭'
+					if not oper:
+						if switch == 1:
+							oper = '开启'
+						else:
+							oper = '关闭'
 					oper = oper + name + msg
 					model.update(oper=oper)