提交 c70a04bb authored 作者: 张颂恩's avatar 张颂恩

Merge branch 'dev' of http://124.225.116.118:35236/tj_django/datacenter into dev

......@@ -671,6 +671,9 @@ urlpatterns = [
url(r'^wx/test/get/activity/(?P<company_id>\d+)/$', wx_views.test_get_activity),
#2024-10-11 lisin 查询最近一次物流记录
url(r'^wx/ajax/recent_inventory_record/$', wx_views.ajax_recent_inventory_record),
#2020-08-04
url(r'^wx/fw/wl/$', wx_views.fwcode_to_wlcode),
......
......@@ -13370,4 +13370,64 @@ def get_awardreed_status(request):
except Exception as e:
data['e'] = f'操作失败:{str(e)}'
return JsonResponse(data)
\ No newline at end of file
return JsonResponse(data)
def ajax_recent_inventory_record(request):
company_id = request.GET.get("company_id", "")
voucher_code = request.GET.get("voucher_code", "")
data = {
'data': {},
'e': '',
}
k = sK
e = time_key_check(request, k)
if e:
data['e'] = e
if not voucher_code :
data['e'] = '缺少必要参数'
vs=Voucher.objects.filter(code=voucher_code.upper())
if not vs :
data['e'] = '不存在改物流类型'
if data['e'] == '':
v=vs[0]
vid=str(v.id)
print('vid',vid)
sWhere=" where company_id="+company_id+" and vtype_id="+ vid
recentBacth = Batch.objects.filter(vtype_id=vid,company_id=company_id).order_by('-tm').first()
s = f"""
select id, code ,tm,
company_to_id,
coalesce((SELECT name from company_company where id = (SELECT parent_id from company_company WHERE id = b.company_to_id)),''),
store_fr_id,
coalesce((select name from inventory_storehouse where id=b.store_fr_id),''),
product_id,
coalesce((select name from product_product where id=b.product_id),'')
from inventory_batch b {sWhere}
order by tm desc
limit 1
"""
cur = connection.cursor()
cur.execute(s)
r = cur.fetchone()
if r:
tm_str = str(r[2])
tm_dt = datetime.datetime.strptime(tm_str, "%Y-%m-%d %H:%M:%S.%f")
tm = tm_dt.strftime("%Y-%m-%d %H:%M:%S")
data['data'] = {
'id': r[0],
'code': r[1],
'tm': tm,
'agent_id':r[3],
'agent_name':r[4],
'store_id':r[5],
'store_name':r[6],
'product_id':r[7],
'product_name':r[8]
}
return JsonResponse(data)
\ No newline at end of file
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论