Commit f53ff517 by 魏强

弹出数量超过五台,短信提醒;

parent 77b3c9b0
...@@ -11,7 +11,9 @@ from Model.Base import db ...@@ -11,7 +11,9 @@ from Model.Base import db
from Model.Machine.MachineModel import Machine from Model.Machine.MachineModel import Machine
from Model.Machine.TakeoutToolModel import TakeoutTool from Model.Machine.TakeoutToolModel import TakeoutTool
from Model.Power.PowerModel import Power from Model.Power.PowerModel import Power
from Model.Spot.SpotModel import Spot
from Redis_Cache import redis from Redis_Cache import redis
from Service.SMSService import SMSService
from Service.ToolService import ToolService from Service.ToolService import ToolService
from Config.common_config import NEW_ONENET_CONFIG as new_onenet_config, ONENET_CONFIG as onenet_config, \ from Config.common_config import NEW_ONENET_CONFIG as new_onenet_config, ONENET_CONFIG as onenet_config, \
TAKEOUT_RECORD_MAC_NO TAKEOUT_RECORD_MAC_NO
...@@ -120,6 +122,19 @@ def take_out_multiple(): ...@@ -120,6 +122,19 @@ def take_out_multiple():
db.session.add(takeout_tool) db.session.add(takeout_tool)
db.session.commit() db.session.commit()
time.sleep(3) time.sleep(3)
# 当弹出充电宝数量大于5台时,给管理员手机发送短信
cur_take_out_num = len(hatch_no_list)
if cur_take_out_num >= 5:
cur_user_name = g.user.user_name
cur_user_phone = g.user.phone
cur_spot_name = Spot.query.filter_by(id=machine_info.spot_id).first().spotname
# 发短信
sms = SMSService()
sms.phoneSendTips(cur_user_name, cur_spot_name, mac_no, cur_take_out_num, cur_user_phone, '18068402080', '灰兔智能')
try: try:
if take_out_success_number > 0 and machine_info.mac_no in TAKEOUT_RECORD_MAC_NO: if take_out_success_number > 0 and machine_info.mac_no in TAKEOUT_RECORD_MAC_NO:
redis_result = redis.get('M_TKO_C_{}'.format(machine_info.mac_no)) redis_result = redis.get('M_TKO_C_{}'.format(machine_info.mac_no))
......
...@@ -62,6 +62,17 @@ class SMSService(): ...@@ -62,6 +62,17 @@ class SMSService():
print(e) print(e)
return return
def phoneSendTips(self, user_name, spot_name, mac_no, num, from_phone, to_phone, sign='灰兔智能'):
params = [user_name, spot_name, mac_no, num, from_phone]
try:
result = self.ssender.send_with_param(86, to_phone, 766214, params, sign=sign, extend="", ext='')
return result
except HTTPError as e:
print(e)
except Exception as e:
print(e)
return
def phoneSendCodeWithContent(self, phoneNumber, tempId, Content, sign='灰兔智能'): def phoneSendCodeWithContent(self, phoneNumber, tempId, Content, sign='灰兔智能'):
''' '''
发送验证码 发送验证码
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment