feat: 修改能管采集的点位
This commit is contained in:
parent
c38457e947
commit
5c163cdcbb
|
@ -86,10 +86,10 @@ def db_ins_mplogx():
|
||||||
if bill_date is None:
|
if bill_date is None:
|
||||||
raise Exception("bill_date is None")
|
raise Exception("bill_date is None")
|
||||||
query = """
|
query = """
|
||||||
SELECT id, de_real_quantity, CONCAT('x', inv_name) AS inv_name, bill_date
|
SELECT id, de_real_quantity, inv_code, bill_date
|
||||||
FROM sa_weigh_view
|
FROM sa_weigh_view
|
||||||
WHERE bill_date >= %s and de_real_quantity > 0
|
WHERE bill_date >= %s and de_real_quantity > 0
|
||||||
AND inv_name IN %s
|
AND inv_code IN %s
|
||||||
ORDER BY bill_date
|
ORDER BY bill_date
|
||||||
"""
|
"""
|
||||||
cursor.execute(query, (bill_date, tuple(batchs)))
|
cursor.execute(query, (bill_date, tuple(batchs)))
|
||||||
|
|
|
@ -84,6 +84,34 @@ class MpointViewSet(CustomModelViewSet):
|
||||||
king_sync(getattr(settings, "KING_PROJECTNAME", ""))
|
king_sync(getattr(settings, "KING_PROJECTNAME", ""))
|
||||||
return Response()
|
return Response()
|
||||||
|
|
||||||
|
@action(methods=["post"], detail=False, perms_map={"post": "mpoint.create"}, serializer_class=Serializer)
|
||||||
|
def show_picture(self, request, *args, **kwargs):
|
||||||
|
import requests
|
||||||
|
import os
|
||||||
|
headers = {
|
||||||
|
"Content-Type": "application/json;charset=utf-8",
|
||||||
|
}
|
||||||
|
url = "http://localhost:8093/boxplot"
|
||||||
|
payload = {
|
||||||
|
"startTime1": request.data.get("startTime1"),
|
||||||
|
"endTime1": request.data.get("endTime1"),
|
||||||
|
"startTime2": request.data.get("startTime2"),
|
||||||
|
"endTime2": request.data.get("endTime2")
|
||||||
|
}
|
||||||
|
try:
|
||||||
|
response = requests.request("POST", url, json=payload, headers=headers)
|
||||||
|
except Exception as e:
|
||||||
|
myLogger.error(e)
|
||||||
|
pic_dir = os.path.join(settings.MEDIA_ROOT, "box_pic")
|
||||||
|
os.makedirs(pic_dir, exist_ok=True)
|
||||||
|
file_name= datetime.now().strftime('%Y%m%d_%H%M%S')+'.png'
|
||||||
|
pic_path = os.path.join(pic_dir, file_name)
|
||||||
|
with open(pic_path, 'wb') as f:
|
||||||
|
f.write(response.content)
|
||||||
|
rel_path = os.path.join('media/box_pic', file_name)
|
||||||
|
rel_path = rel_path.replace('\\', '/')
|
||||||
|
return Response({"rel_path": rel_path})
|
||||||
|
|
||||||
|
|
||||||
class XscriptViewSet(CustomModelViewSet):
|
class XscriptViewSet(CustomModelViewSet):
|
||||||
"""
|
"""
|
||||||
|
|
Loading…
Reference in New Issue