def get(self, request, *args, **kwargs): ip = request.META.get('HTTP_X_FORWARDED_FOR') if request.META.get( 'HTTP_X_FORWARDED_FOR') else request.META.get('REMOTE_ADDR') sort = request._request.GET.get('sort', '-create_time') max_page = request._request.GET.get('max_page', 100) list = BaseInfoModel.objects.filter( appid=request.user.appid).order_by(sort) if request._request.GET.get('goods_code', ''): list = list.filter(goods_code__icontains=request._request.GET.get( 'goods_code', '')).order_by(sort) pg = MyPageNumberPagination() pg_list = pg.paginate_queryset(queryset=list, request=request, view=self) list_ser = ListSerializers(pg_list, many=True) ret = FBMsg.ret() ret['ip'] = ip ret['data'] = list_ser.data ret['totlepage'] = math.ceil(list.count() / int(max_page)) return pg.get_paginated_response(ret)
def get(self, request, *args, **kwargs): vip_id = Users.objects.filter(appid=request.user.appid, developer=1, is_delete=0).first().vip vip_check = VipCheck.VipCheck(vip_id) if vip_check == "N": return Response(FBMsg.wms_vip_get()) elif vip_check == "Y": if request._request.GET.get('getfile', ''): if str(request._request.GET.get('getfile', '')) == "1": file_data = DetailModel.objects.filter( appid=request.user.appid, is_delete=0) file_detail1 = [] file_detail2 = [] file_detail3 = [] file_detail4 = [] file_detail5 = [] filepath = os.path.join( settings.BASE_DIR, 'media/file/' + pathlink + '/' + request.user.appid + '.xlsx') for i in range(len(file_data)): file_detail1.append(file_data[i].name) file_detail2.append(file_data[i].po_status) file_detail3.append(file_data[i].create_name) file_detail4.append(file_data[i].create_time.strftime( "%Y-%m-%d %H:%M:%S")) file_detail5.append( file_data[i].last_update_time.strftime( "%Y-%m-%d %H:%M:%S")) df = pd.DataFrame({ pathname: file_detail1, '订单状态': file_detail2, '创建人': file_detail3, '创建时间': file_detail4, '最后更新时间': file_detail5 }) dir_path = os.path.join(settings.BASE_DIR, 'media/file/' + pathlink + '/') if os.path.exists(dir_path): pass else: os.makedirs(dir_path) if os.path.isfile(filepath): os.remove(filepath) else: pass df.to_excel(filepath, sheet_name='sheet1', startcol=0, index=False) file = open(filepath, 'rb') response = FileResponse(file) response['Content-Type'] = 'application/octet-stream' response[ 'Content-Disposition'] = 'attachment;filename="%s.xlsx"' % pathlink return response else: ret = FBMsg.wms_errfile() return Response(ret) else: sort = request._request.GET.get('sort', '-create_time') max_page = request._request.GET.get('max_page', 100) list = DetailModel.objects.filter(appid=request.user.appid, is_delete=0).order_by(sort) if request._request.GET.get('po_number', ''): list = list.filter( name__icontains=request._request.GET.get( 'po_number', '')).order_by(sort) if request._request.GET.get('po_status', ''): list = list.filter( po_status=int(request._request.GET.get( 'po_status', ''))).order_by(sort) if request._request.GET.get('supplier', ''): list = list.filter( supplier__icontains=request._request.GET.get( 'supplier', '')).order_by(sort) if request._request.GET.get('sorted', ''): list = list.filter(up_qty__gt=int( request._request.GET.get('sorted', ''))).order_by(sort) if request._request.GET.get('shortage', ''): list = list.filter(shortage_qty__gt=int( request._request.GET.get('shortage', ''))).order_by( sort) if request._request.GET.get('damage', ''): list = list.filter(damage_qty__gt=int( request._request.GET.get('damage', ''))).order_by(sort) if request._request.GET.get('more', ''): list = list.filter(more_qty__gt=int( request._request.GET.get('more', ''))).order_by(sort) if request._request.GET.get('create_name', ''): list = list.filter( create_name__icontains=request._request.GET.get( 'create_name', '')).order_by(sort) if request._request.GET.get('t_code', ''): list = list.filter(t_code=request._request.GET.get( 't_code', '')).order_by(sort) if request._request.GET.get('date1', ''): try: start_date = request._request.GET.get('date1', '') date = [int(x) for x in start_date.split('/')] new = datetime.datetime(date[0], date[1], date[2]) start_date = new.strftime('%Y-%m-%d') if request._request.GET.get('date2', ''): date_end = request._request.GET.get('date2', '') delta = datetime.timedelta(days=1) date = [int(x) for x in date_end.split('/')] old = datetime.datetime(date[0], date[1], date[2]) end_date = (old + delta).strftime('%Y-%m-%d') else: today = datetime.date.today() delta = datetime.timedelta(days=1) end_date = (today + delta).strftime('%Y-%m-%d') date = [int(x) for x in end_date.split('-')] old = datetime.datetime(date[0], date[1], date[2]) if (old - new).days < 0: return Response(FBMsg.wms_time()) else: list = list.filter( create_time__range=[start_date, end_date ]).order_by(sort) except: pass if request._request.GET.get('udate1', ''): try: start_date = request._request.GET.get('udate1', '') date = [int(x) for x in start_date.split('/')] new = datetime.datetime(date[0], date[1], date[2]) start_date = new.strftime('%Y-%m-%d') if request._request.GET.get('udate2', ''): date_end = request._request.GET.get('udate2', '') delta = datetime.timedelta(days=1) date = [int(x) for x in date_end.split('/')] old = datetime.datetime(date[0], date[1], date[2]) end_date = (old + delta).strftime('%Y-%m-%d') else: today = datetime.date.today() delta = datetime.timedelta(days=1) end_date = (today + delta).strftime('%Y-%m-%d') date = [int(x) for x in end_date.split('-')] old = datetime.datetime(date[0], date[1], date[2]) if (old - new).days < 0: return Response(FBMsg.wms_time()) else: list = list.filter( last_update_time__range=[start_date, end_date ]).order_by(sort) except: pass pg = MyPageNumberPagination() pg_list = pg.paginate_queryset(queryset=list, request=request, view=self) list_ser = ListSerializers(pg_list, many=True) ip = request.META.get( 'HTTP_X_FORWARDED_FOR') if request.META.get( 'HTTP_X_FORWARDED_FOR') else request.META.get( 'REMOTE_ADDR') bin_list = binset.models.ListModel.objects.filter( appid=request.user.appid, is_delete=0).order_by('name') bin_list_ser = BinListSerializers(bin_list, many=True) ret = FBMsg.ret() ret['ip'] = ip ret['data'] = list_ser.data ret['totlepage'] = math.ceil(list.count() / int(max_page)) ret['bin_list'] = bin_list_ser.data return pg.get_paginated_response(ret) else: return Response(FBMsg.wms_vip_get())
def get(self, request, *args, **kwargs): vip_id = Users.objects.filter(appid=request.user.appid, developer=1, is_delete=0).first().vip vip_check = VipCheck.VipCheck(vip_id) if vip_check == "N": return Response(FBMsg.wms_vip_get()) elif vip_check == "Y": if request._request.GET.get('getfile', ''): if str(request._request.GET.get('getfile', '')) == "1": file_data = UserAuth.objects.filter( appid=request.user.appid, is_delete=0) file_detail1 = [] file_detail2 = [] file_detail3 = [] file_detail4 = [] file_detail5 = [] file_detail6 = [] file_detail7 = [] file_detail8 = [] file_detail9 = [] file_detail10 = [] file_detail11 = [] file_detail12 = [] file_detail13 = [] file_detail14 = [] file_detail15 = [] file_detail16 = [] file_detail17 = [] file_detail18 = [] file_detail19 = [] file_detail20 = [] file_detail21 = [] file_detail22 = [] file_detail23 = [] filepath = os.path.join( settings.BASE_DIR, 'media/file/' + pathlink + '/' + request.user.appid + '.xlsx') for i in range(len(file_data)): file_detail1.append(file_data[i].name) file_detail2.append(file_data[i].aut1) file_detail3.append(file_data[i].aut2) file_detail4.append(file_data[i].aut3) file_detail5.append(file_data[i].aut4) file_detail6.append(file_data[i].aut5) file_detail7.append(file_data[i].aut6) file_detail8.append(file_data[i].aut7) file_detail9.append(file_data[i].aut8) file_detail10.append(file_data[i].aut9) file_detail11.append(file_data[i].aut10) file_detail12.append(file_data[i].aut11) file_detail13.append(file_data[i].aut12) file_detail14.append(file_data[i].aut13) file_detail15.append(file_data[i].aut14) file_detail16.append(file_data[i].aut15) file_detail17.append(file_data[i].aut16) file_detail18.append(file_data[i].aut17) file_detail19.append(file_data[i].aut18) file_detail20.append(file_data[i].aut19) file_detail21.append(file_data[i].aut20) file_detail22.append(file_data[i].create_time.strftime( "%Y-%m-%d %H:%M:%S")) file_detail23.append( file_data[i].last_update_time.strftime( "%Y-%m-%d %H:%M:%S")) df = pd.DataFrame({ pathname: file_detail1, 'aut1': file_detail2, 'aut2': file_detail3, 'aut3': file_detail4, 'aut4': file_detail5, 'aut5': file_detail6, 'aut6': file_detail7, 'aut7': file_detail2, 'aut8': file_detail9, 'aut9': file_detail10, 'aut10': file_detail11, 'aut11': file_detail12, 'aut12': file_detail13, 'aut13': file_detail14, 'aut14': file_detail15, 'aut15': file_detail16, 'aut16': file_detail17, 'aut17': file_detail18, 'aut18': file_detail19, 'aut19': file_detail20, 'aut20': file_detail21, '创建时间': file_detail22, '最后更新时间': file_detail23 }) dir_path = os.path.join(settings.BASE_DIR, 'media/file/' + pathlink + '/') if os.path.exists(dir_path): pass else: os.makedirs(dir_path) if os.path.isfile(filepath): os.remove(filepath) else: pass df.to_excel(filepath, sheet_name='sheet1', index=False, encoding='utf-8') file = open(filepath, 'rb') response = FileResponse(file) response['Content-Type'] = 'application/octet-stream' response[ 'Content-Disposition'] = 'attachment;filename="%s.xlsx"' % pathlink return response else: ret = FBMsg.wms_errfile() return Response(ret) else: sort = request._request.GET.get('sort', '-create_time') max_page = request._request.GET.get('max_page', 100) list = UserAuth.objects.filter(appid=request.user.appid, is_delete=0).order_by(sort) if request._request.GET.get('name', ''): list = list.filter(name__icontains=request._request.GET. get('name', '')).order_by(sort) if request._request.GET.get('create_name', ''): list = list.filter( create_name__icontains=request._request.GET.get( 'create_name', '')).order_by(sort) if request._request.GET.get('authorization', ''): if str(request._request.GET.get('authorization', '')) == "1": auth_name = Users.objects.filter( appid=request.user.appid, openid=request.auth, is_delete=0).first().auth_name list = list.filter(appid=request.user.appid, name=auth_name, is_delete=0).order_by(sort) if request._request.GET.get('date1', ''): try: start_date = request._request.GET.get('date1', '') date = [int(x) for x in start_date.split('/')] new = datetime.datetime(date[0], date[1], date[2]) start_date = new.strftime('%Y-%m-%d') if request._request.GET.get('date2', ''): date_end = request._request.GET.get('date2', '') delta = datetime.timedelta(days=1) date = [int(x) for x in date_end.split('/')] old = datetime.datetime(date[0], date[1], date[2]) end_date = (old + delta).strftime('%Y-%m-%d') else: today = datetime.date.today() delta = datetime.timedelta(days=1) end_date = (today + delta).strftime('%Y-%m-%d') date = [int(x) for x in end_date.split('-')] old = datetime.datetime(date[0], date[1], date[2]) if (old - new).days < 0: return Response(FBMsg.wms_time()) else: list = list.filter( create_time__range=[start_date, end_date ]).order_by(sort) except: pass if request._request.GET.get('udate1', ''): try: start_date = request._request.GET.get('udate1', '') date = [int(x) for x in start_date.split('/')] new = datetime.datetime(date[0], date[1], date[2]) start_date = new.strftime('%Y-%m-%d') if request._request.GET.get('udate2', ''): date_end = request._request.GET.get('udate2', '') delta = datetime.timedelta(days=1) date = [int(x) for x in date_end.split('/')] old = datetime.datetime(date[0], date[1], date[2]) end_date = (old + delta).strftime('%Y-%m-%d') else: today = datetime.date.today() delta = datetime.timedelta(days=1) end_date = (today + delta).strftime('%Y-%m-%d') date = [int(x) for x in end_date.split('-')] old = datetime.datetime(date[0], date[1], date[2]) if (old - new).days < 0: return Response(FBMsg.wms_time()) else: list = list.filter( last_update_time__range=[start_date, end_date ]).order_by(sort) except: pass pg = MyPageNumberPagination() pg_list = pg.paginate_queryset(queryset=list, request=request, view=self) list_ser = ListSerializers(pg_list, many=True) ip = request.META.get( 'HTTP_X_FORWARDED_FOR') if request.META.get( 'HTTP_X_FORWARDED_FOR') else request.META.get( 'REMOTE_ADDR') ret = FBMsg.ret() ret['ip'] = ip ret['data'] = list_ser.data ret['totlepage'] = math.ceil(list.count() / int(max_page)) return pg.get_paginated_response(ret) else: return Response(FBMsg.wms_vip_get())
def get(self, request, *args, **kwargs): vip_id = Users.objects.filter(appid=request.user.appid, developer=1, is_delete=0).first().vip vip_check = VipCheck.VipCheck(vip_id) if vip_check == "N": return Response(FBMsg.wms_vip_get()) elif vip_check == "Y": if request._request.GET.get('getfile', ''): if str(request._request.GET.get('getfile', '')) == "1": file_data = ListModel.objects.filter(appid=request.user.appid, is_delete=0) file_detail1 = [] file_detail2 = [] file_detail3 = [] file_detail4 = [] file_detail5 = [] file_detail6 = [] file_detail7 = [] file_detail8 = [] file_detail9 = [] file_detail11 = [] file_detail12 = [] file_detail13 = [] file_detail14 = [] file_detail15 = [] file_detail16 = [] file_detail17 = [] file_detail18 = [] file_detail19 = [] file_detail20 = [] filepath = os.path.join(settings.BASE_DIR, 'media/file/' + pathlink + '/' + request.user.appid + '.xlsx') for i in range(len(file_data)): file_detail1.append(file_data[i].name) file_detail2.append(file_data[i].goods_name) file_detail3.append(file_data[i].goods_unit) file_detail4.append(file_data[i].goods_class) file_detail5.append(file_data[i].goods_spacs) file_detail6.append(file_data[i].goods_shape) file_detail7.append(file_data[i].goods_color) file_detail8.append(file_data[i].goods_brand) file_detail9.append(file_data[i].goods_city) file_detail11.append(file_data[i].goods_l) file_detail12.append(file_data[i].goods_w) file_detail13.append(file_data[i].goods_h) file_detail14.append(file_data[i].goods_weight) file_detail15.append(file_data[i].goods_cost) file_detail16.append(file_data[i].goods_price1) file_detail17.append(file_data[i].goods_price2) file_detail18.append(file_data[i].goods_price3) file_detail19.append(file_data[i].create_time.strftime("%Y-%m-%d %H:%M:%S")) file_detail20.append(file_data[i].last_update_time.strftime("%Y-%m-%d %H:%M:%S")) df = pd.DataFrame({pathname: file_detail1, '商品描述': file_detail2, '商品单位': file_detail3, '商品类别': file_detail4, '商品规格': file_detail5, '商品形状': file_detail6, '商品颜色': file_detail7, '商品品牌': file_detail8, '商品产地': file_detail9, '商品长(单位: mm)': file_detail11, '商品宽(单位: mm)': file_detail12, '商品高(单位: mm)': file_detail13, '商品重量(单位: 克)': file_detail14, '成本价(单位: 元)': file_detail15, '一销价(单位: 元)': file_detail16, '二销价(单位: 元)': file_detail17, '三销价(单位: 元)': file_detail18, '创建时间': file_detail19, '最后更新时间': file_detail20 }) dir_path = os.path.join(settings.BASE_DIR, 'media/file/' + pathlink + '/') if os.path.exists(dir_path): pass else: os.makedirs(dir_path) if os.path.isfile(filepath): os.remove(filepath) else: pass df.to_excel(filepath, sheet_name='sheet1', startcol=0, index=False) file = open(filepath, 'rb') response = FileResponse(file) response['Content-Type'] = 'application/octet-stream' response['Content-Disposition'] = 'attachment;filename="%s.xlsx"' % pathlink return response else: ret = FBMsg.wms_errfile() return Response(ret) else: sort = request._request.GET.get('sort', '-create_time') max_page = request._request.GET.get('max_page', 100) list = ListModel.objects.filter(appid=request.user.appid, is_delete=0).order_by(sort) if request._request.GET.get('name', ''): list = list.filter(name__icontains=str(request._request.GET.get('name', ''))).order_by(sort) if request._request.GET.get('goods_name', ''): list = list.filter(goods_name__icontains=str(request._request.GET.get('goods_name', ''))).order_by(sort) if request._request.GET.get('goods_unit', ''): list = list.filter(goods_unit__icontains=str(request._request.GET.get('goods_unit', ''))).order_by(sort) if request._request.GET.get('goods_class', ''): list = list.filter(goods_class__icontains=str(request._request.GET.get('goods_class', ''))).order_by(sort) if request._request.GET.get('goods_spacs', ''): list = list.filter(goods_spacs__icontains=str(request._request.GET.get('goods_spacs', ''))).order_by(sort) if request._request.GET.get('goods_shape', ''): list = list.filter(goods_shape__icontains=str(request._request.GET.get('goods_shape', ''))).order_by(sort) if request._request.GET.get('goods_color', ''): list = list.filter(goods_color__icontains=str(request._request.GET.get('goods_color', ''))).order_by(sort) if request._request.GET.get('goods_brand', ''): list = list.filter(goods_brand__icontains=str(request._request.GET.get('goods_brand', ''))).order_by(sort) if request._request.GET.get('goods_city', ''): list = list.filter(goods_city__icontains=str(request._request.GET.get('goods_city', ''))).order_by(sort) if request._request.GET.get('create_name', ''): list = list.filter(create_name__icontains=str(request._request.GET.get('create_name', ''))).order_by(sort) if request._request.GET.get('date1', ''): try: start_date = request._request.GET.get('date1', '') date = [int(x) for x in start_date.split('/')] new = datetime.datetime(date[0], date[1], date[2]) start_date = new.strftime('%Y-%m-%d') if request._request.GET.get('date2', ''): date_end = request._request.GET.get('date2', '') delta = datetime.timedelta(days=1) date = [int(x) for x in date_end.split('/')] old = datetime.datetime(date[0], date[1], date[2]) end_date = (old + delta).strftime('%Y-%m-%d') else: today = datetime.date.today() delta = datetime.timedelta(days=1) end_date = (today + delta).strftime('%Y-%m-%d') date = [int(x) for x in end_date.split('-')] old = datetime.datetime(date[0], date[1], date[2]) if (old - new).days < 0: return Response(FBMsg.wms_time()) else: list = list.filter(create_time__range=[start_date, end_date]).order_by(sort) except: pass if request._request.GET.get('udate1', ''): try: start_date = request._request.GET.get('udate1', '') date = [int(x) for x in start_date.split('/')] new = datetime.datetime(date[0], date[1], date[2]) start_date = new.strftime('%Y-%m-%d') if request._request.GET.get('udate2', ''): date_end = request._request.GET.get('udate2', '') delta = datetime.timedelta(days=1) date = [int(x) for x in date_end.split('/')] old = datetime.datetime(date[0], date[1], date[2]) end_date = (old + delta).strftime('%Y-%m-%d') else: today = datetime.date.today() delta = datetime.timedelta(days=1) end_date = (today + delta).strftime('%Y-%m-%d') date = [int(x) for x in end_date.split('-')] old = datetime.datetime(date[0], date[1], date[2]) if (old - new).days < 0: return Response(FBMsg.wms_time()) else: list = list.filter(last_update_time__range=[start_date, end_date]).order_by(sort) except: pass pg = MyPageNumberPagination() pg_list = pg.paginate_queryset(queryset=list, request=request, view=self) list_ser = ListSerializers(pg_list, many=True) ip = request.META.get('HTTP_X_FORWARDED_FOR') if request.META.get( 'HTTP_X_FORWARDED_FOR') else request.META.get('REMOTE_ADDR') ret = FBMsg.ret() ret['ip'] = ip ret['data'] = list_ser.data ret['totlepage'] = math.ceil(list.count()/int(max_page)) return pg.get_paginated_response(ret) else: return Response(FBMsg.wms_vip_get())
def get(self, request, *args, **kwargs): vip_id = Users.objects.filter(appid=request.user.appid, developer=1, is_delete=0).first().vip vip_check = VipCheck.VipCheck(vip_id) if vip_check == "N": return Response(FBMsg.wms_vip_get()) elif vip_check == "Y": if request._request.GET.get('getfile', ''): if str(request._request.GET.get('getfile', '')) == "1": file_data = stockbinlist.models.ListModel.objects.filter( appid=request.user.appid, is_delete=0).order_by('name') file_detail1 = [] file_detail2 = [] file_detail3 = [] file_detail4 = [] file_detail5 = [] filepath = os.path.join( settings.BASE_DIR, 'media/file/' + pathlink + '/' + request.user.appid + '.xlsx') for i in range(len(file_data)): file_detail1.append(file_data[i].name) file_detail2.append(file_data[i].goods_code) file_detail3.append(file_data[i].goods_name) file_detail4.append('') file_detail5.append(file_data[i].t_code) df = pd.DataFrame({ pathname: file_detail1, '商品编码': file_detail2, '商品描述': file_detail3, '盘点用户名': file_detail4, '数据标识': file_detail5 }) dir_path = os.path.join(settings.BASE_DIR, 'media/file/' + pathlink + '/') if os.path.exists(dir_path): pass else: os.makedirs(dir_path) if os.path.isfile(filepath): os.remove(filepath) else: pass df.to_excel(filepath, sheet_name='sheet1', startcol=0, index=False) file = open(filepath, 'rb') response = FileResponse(file) response['Content-Type'] = 'application/octet-stream' response[ 'Content-Disposition'] = 'attachment;filename="cyclecountlist.xlsx"' return response if str(request._request.GET.get('getfile', '')) == "2": file_data = ListModel.objects.filter( appid=request.user.appid) file_detail1 = [] file_detail2 = [] file_detail3 = [] file_detail4 = [] file_detail5 = [] file_detail6 = [] file_detail7 = [] file_detail8 = [] file_detail9 = [] filepath = os.path.join( settings.BASE_DIR, 'media/file/' + pathlink + '/' + request.user.appid + '.xlsx') for i in range(len(file_data)): file_detail1.append(file_data[i].name) file_detail2.append(file_data[i].goods_code) file_detail3.append(file_data[i].goods_name) file_detail4.append(file_data[i].goods_qty) file_detail5.append(file_data[i].cycle_count_balance) file_detail6.append(file_data[i].staff) file_detail7.append(file_data[i].inbound_time.strftime( "%Y-%m-%d %H:%M:%S")) file_detail8.append(file_data[i].create_time.strftime( "%Y-%m-%d %H:%M:%S")) file_detail9.append( file_data[i].last_update_time.strftime( "%Y-%m-%d %H:%M:%S")) df = pd.DataFrame({ pathname: file_detail1, '商品编码': file_detail2, '商品描述': file_detail3, '盘点数量': file_detail4, '盘点差异': file_detail5, '盘点用户名': file_detail6, '入库时间': file_detail7, '创建时间': file_detail8, '最后更新时间': file_detail9 }) dir_path = os.path.join(settings.BASE_DIR, 'media/file/' + pathlink + '/') if os.path.exists(dir_path): pass else: os.makedirs(dir_path) if os.path.isfile(filepath): os.remove(filepath) else: pass df.to_excel(filepath, sheet_name='sheet1', startcol=0, index=False) file = open(filepath, 'rb') response = FileResponse(file) response['Content-Type'] = 'application/octet-stream' response[ 'Content-Disposition'] = 'attachment;filename="cyclecountresult.xlsx"' return response else: ret = FBMsg.wms_errfile() return Response(ret) else: sort = request._request.GET.get('sort', 'name') max_page = request._request.GET.get('max_page', 100) list = ListModel.objects.filter( appid=request.user.appid).order_by(sort) if request._request.GET.get('name', ''): list = list.filter(name__icontains=str( request._request.GET.get('name', ''))).order_by(sort) if request._request.GET.get('goods_code', ''): list = list.filter(goods_code__icontains=str( request._request.GET.get('goods_code', ''))).order_by( sort) if request._request.GET.get('goods_name', ''): list = list.filter(goods_name__icontains=str( request._request.GET.get('goods_name', ''))).order_by( sort) if request._request.GET.get('staff', ''): if list.filter(staff=str( request._request.GET.get('staff', ''))).exists(): list = list.filter( staff=str(request._request.GET.get( 'staff', ''))).order_by(sort) else: return Response(FBMsg.wms_no_user()) if request._request.GET.get('t_code', ''): list = list.filter(t_code=str( request._request.GET.get('t_code', ''))).order_by(sort) if request._request.GET.get('date1', ''): try: start_date = request._request.GET.get('date1', '') date = [int(x) for x in start_date.split('/')] new = datetime.datetime(date[0], date[1], date[2]) start_date = new.strftime('%Y-%m-%d') if request._request.GET.get('date2', ''): date_end = request._request.GET.get('date2', '') delta = datetime.timedelta(days=1) date = [int(x) for x in date_end.split('/')] old = datetime.datetime(date[0], date[1], date[2]) end_date = (old + delta).strftime('%Y-%m-%d') else: today = datetime.date.today() delta = datetime.timedelta(days=1) end_date = (today + delta).strftime('%Y-%m-%d') date = [int(x) for x in end_date.split('-')] old = datetime.datetime(date[0], date[1], date[2]) if (old - new).days < 0: return Response(FBMsg.wms_time()) else: list = list.filter( create_time__range=[start_date, end_date ]).order_by(sort) except: pass if request._request.GET.get('udate1', ''): try: start_date = request._request.GET.get('udate1', '') date = [int(x) for x in start_date.split('/')] new = datetime.datetime(date[0], date[1], date[2]) start_date = new.strftime('%Y-%m-%d') if request._request.GET.get('udate2', ''): date_end = request._request.GET.get('udate2', '') delta = datetime.timedelta(days=1) date = [int(x) for x in date_end.split('/')] old = datetime.datetime(date[0], date[1], date[2]) end_date = (old + delta).strftime('%Y-%m-%d') else: today = datetime.date.today() delta = datetime.timedelta(days=1) end_date = (today + delta).strftime('%Y-%m-%d') date = [int(x) for x in end_date.split('-')] old = datetime.datetime(date[0], date[1], date[2]) if (old - new).days < 0: return Response(FBMsg.wms_time()) else: list = list.filter( last_update_time__range=[start_date, end_date ]).order_by(sort) except: pass pg = MyPageNumberPagination() pg_list = pg.paginate_queryset(queryset=list, request=request, view=self) list_ser = ListSerializers(pg_list, many=True) ip = request.META.get( 'HTTP_X_FORWARDED_FOR') if request.META.get( 'HTTP_X_FORWARDED_FOR') else request.META.get( 'REMOTE_ADDR') ret = FBMsg.ret() ret['ip'] = ip ret['data'] = list_ser.data ret['totlepage'] = math.ceil(list.count() / int(max_page)) return pg.get_paginated_response(ret) else: return Response(FBMsg.wms_vip_get())