Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
T
tour_business
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
魏强
tour_business
Commits
b379f2d1
Commit
b379f2d1
authored
Sep 10, 2020
by
魏强
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
手动弹出记录到数据库;
parent
1e46a14b
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
29 additions
and
1 deletions
+29
-1
Controller/ToolController.py
+12
-1
Model/Machine/TakeoutToolModel.py
+17
-0
No files found.
Controller/ToolController.py
View file @
b379f2d1
...
@@ -2,13 +2,14 @@
...
@@ -2,13 +2,14 @@
import
datetime
import
datetime
import
time
import
time
from
flask
import
Blueprint
,
jsonify
,
request
from
flask
import
Blueprint
,
jsonify
,
request
,
g
from
Libs.ErrorTips
import
MACHINE_NOT_EXIST_ERROR
,
MACHINE_HATCH_NOT_ILLEGAL
,
MACHINE_NOT_ONLINE
,
BASE_RESPONSE
from
Libs.ErrorTips
import
MACHINE_NOT_EXIST_ERROR
,
MACHINE_HATCH_NOT_ILLEGAL
,
MACHINE_NOT_ONLINE
,
BASE_RESPONSE
from
Libs.Onenet.Message.Message
import
CommandMessage
from
Libs.Onenet.Message.Message
import
CommandMessage
from
Libs.Onenet.OneNetApi
import
OneNetApi
from
Libs.Onenet.OneNetApi
import
OneNetApi
from
Model.Base
import
db
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.Power.PowerModel
import
Power
from
Model.Power.PowerModel
import
Power
from
Redis_Cache
import
redis
from
Redis_Cache
import
redis
from
Service.ToolService
import
ToolService
from
Service.ToolService
import
ToolService
...
@@ -95,19 +96,29 @@ def take_out_multiple():
...
@@ -95,19 +96,29 @@ def take_out_multiple():
else
:
else
:
one_api
=
OneNetApi
(
onenet_config
[
"api_key"
],
onenet_config
[
"url"
])
one_api
=
OneNetApi
(
onenet_config
[
"api_key"
],
onenet_config
[
"url"
])
result
=
one_api
.
send_data_to_edp
(
command_message
.
get_device_id
(),
1
,
0
,
command_message
.
pack
())
result
=
one_api
.
send_data_to_edp
(
command_message
.
get_device_id
(),
1
,
0
,
command_message
.
pack
())
takeout_tool
=
TakeoutTool
()
takeout_tool
.
customer_id
=
g
.
user
.
id
takeout_tool
.
mac_no
=
mac_no
takeout_tool
.
spot_id
=
machine_info
.
spot_id
takeout_tool
.
hatch_no
=
i
if
'errno'
in
result
.
keys
()
and
result
[
'errno'
]
==
0
:
if
'errno'
in
result
.
keys
()
and
result
[
'errno'
]
==
0
:
if
result
[
'error'
]
==
'succ'
:
if
result
[
'error'
]
==
'succ'
:
data
[
i
]
=
'success'
data
[
i
]
=
'success'
Power
.
query
.
filter_by
(
hatch_no
=
i
,
machine_id
=
machine_info
.
id
)
.
update
({
'status'
:
8
,
'has_power'
:
0
})
Power
.
query
.
filter_by
(
hatch_no
=
i
,
machine_id
=
machine_info
.
id
)
.
update
({
'status'
:
8
,
'has_power'
:
0
})
db
.
session
.
commit
()
db
.
session
.
commit
()
take_out_success_number
+=
1
take_out_success_number
+=
1
takeout_tool
.
status
=
1
else
:
else
:
data
[
i
]
=
'fail'
data
[
i
]
=
'fail'
takeout_tool
.
status
=
0
else
:
else
:
if
'error_message'
in
result
.
keys
():
if
'error_message'
in
result
.
keys
():
data
[
i
]
=
result
[
'error_message'
]
data
[
i
]
=
result
[
'error_message'
]
else
:
else
:
data
[
i
]
=
'fail'
data
[
i
]
=
'fail'
takeout_tool
.
status
=
0
db
.
session
.
add
(
takeout_tool
)
db
.
session
.
commit
()
time
.
sleep
(
3
)
time
.
sleep
(
3
)
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
:
...
...
Model/Machine/TakeoutToolModel.py
0 → 100644
View file @
b379f2d1
# -*- coding: utf-8 -*-
__author__
=
'weiqiang'
__date__
=
'2020/9/10 11:07'
from
sqlalchemy
import
Column
,
Integer
,
FetchedValue
,
String
from
Model.Base
import
BaseModel
class
TakeoutTool
(
BaseModel
):
__tablename__
=
'takeout_tool'
id
=
Column
(
Integer
,
primary_key
=
True
)
customer_id
=
Column
(
Integer
,
nullable
=
False
,
comment
=
'用户id'
)
mac_no
=
Column
(
String
(
16
,
'utf8mb4_unicode_ci'
),
nullable
=
False
,
comment
=
'机柜编号'
)
spot_id
=
Column
(
Integer
,
nullable
=
False
,
comment
=
'景点id'
)
hatch_no
=
Column
(
Integer
,
nullable
=
False
,
comment
=
'弹出的仓口号'
)
status
=
Column
(
Integer
,
nullable
=
False
,
server_default
=
FetchedValue
(),
comment
=
'状态:0弹出失败,1弹出成功'
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment