def rfsMain(self, mes=None, barcode=None): if not mes: self.rfsGetTask( ) # вдруг уже есть выполняемое задание if barcode: bcInfo = self.kBarCodeInfo(barcode) if bcInfo and bcInfo['result'] == 0: mes = _('Invalid barcode') if bcInfo['usercode'] == 'SITE': r = self.dbExec(sql='select * from K_SITE_ROWBYSLOT(?)', params=[self.kId(bcInfo['recordid'])], fetch='one') if r and r['rowid']: raise HTTPRedirect('rfsRow?id=%s&orderby=%s' % (r['ROWID'], r['ORDERBY'])) else: mes = 'Не возможно установить ряд по отсканированному МП!' elif bcInfo['usercode'] == 'WARES': raise HTTPRedirect('rfsWares?id=%s' % (bcInfo['recordid'])) else: mes = bcInfo['mes'] rows = self.dbExec(sql='select * from K_WH_REFILLSLOT_LISTEMPLROWS(?)', params=[self.getIfaceVar('wmsid')], fetch='all') return self.drawTemplate( templ=index, data=[rows, { 'mes': mes, 'reloadurl': 'rfsMain' }])
def rfsMain(self, mes=None, barcode=None): if not mes: self.rfsGetTask( ) # вдруг уже есть выполняемое задание if barcode: bcInfo = self.kBarCodeInfo(barcode) if bcInfo and bcInfo['result'] == 0: mes = _('Invalid barcode') if bcInfo['usercode'] == 'SITE': raise HTTPRedirect('rfsSlot?id=%s' % (self.kId(bcInfo['recordid']))) elif bcInfo['usercode'] == 'WARES': self.rfsTaskByWares(wid=self.kId(bcInfo['recordid'])) raise HTTPRedirect('rfsWares?id=%s' % (bcInfo['recordid'])) elif bcInfo['usercode'] == 'WARESUNIT': w = self.qWaresByBarcode(barcode) if len(w['datalist']) == 1: self.rfsTaskByWares( wid=self.kId(w['datalist'][0]['wid'])) raise HTTPRedirect('rfsWares?id=%s' % (w['datalist'][0]['wid'])) elif len(w['datalist']) > 1: return self.drawTemplate(templ=rangeWares, data=[w]) else: mes = bcInfo['mes'] self.setIfaceVar('rfsRowId', None) rows = self.dbExec(sql='select * from K_WH_REFILLSLOT_LISTEMPLROWS(?)', params=[self.getIfaceVar('wmsid')], fetch='all') return self.drawTemplate( templ=index, data=[rows, { 'mes': mes, 'reloadurl': 'rfsMain' }])
def google(self, **kwargs): req = cherrypy.request orm_session = req.orm_session try: # Aquire API token internally pub('oauth-token') # Aquire OAuth2Session instance, built with token google_api = pub('google-api') cherrypy.session['google_user'] = google_api.get( 'https://www.googleapis.com/oauth2/v1/userinfo').json() cherrypy.session['admin_user'] = to_collection( find_admin_by_email(orm_session, cherrypy.session['google_user']['email'])) cherrypy.session['google_oauth'] = kwargs if cherrypy.session.get('auth_redirect'): logger.debug('redirect after auth') raise HTTPRedirect(cherrypy.session['auth_redirect']) raise HTTPRedirect(url_for_class('controller.Root.admin')) except MissingCodeError as mce: raise HTTPError(401, 'Error: {}'.format(kwargs.get('error'))) from mce except (MismatchingStateError, KeyError) as wrong_state: raise HTTPRedirect( url_for_class('controller.Root.auth')) from wrong_state
def wpMain(self, barcode=None, mes=None): if barcode: bcInfo = self.kBarCodeInfo(barcode) if bcInfo and bcInfo['result'] == 0: mes = _('Не верный ШК') if bcInfo['usercode'] == 'PALLET': raise HTTPRedirect('pal?id=%s' % (bcInfo['recordid'])) elif bcInfo['usercode'] == 'SITE': s = self.siteInfo(siteid=bcInfo['recordid'], proc=True) if s['SITEPALLETID']: raise HTTPRedirect('pal?id=%s' % (s['SITEPALLETID'])) #pid = self.getSitePallet(siteid=bcInfo['recordid']) #if pid: # raise HTTPRedirect('pal?id=%s' % (pid)) elif bcInfo['usercode'] == 'PALLETFP': raise HTTPRedirect('palCreateFP?barcode=%s' % (barcode)) elif bcInfo['usercode'] == 'PRINTER': raise HTTPRedirect('printer?id=%s' % (self.kId(bcInfo['recordid']))) else: mes = bcInfo['mes'] up = self.dbExec(sql='select * from WH_USER_LISTPALLET(?)', params=[self.getUserVar('uid')], fetch='all') return self.drawTemplate(templ=index, data=[up, {'mes': mes}])
def rfsTaskWaresSave(self, **args): slotid = None if args.has_key('barcode'): bcInfo = self.kBarCodeInfo(args['barcode']) if bcInfo and bcInfo['result'] == 0: if bcInfo['usercode'] == 'SITE': slotid = self.kId(bcInfo['recordid']) if not slotid: raise HTTPRedirect( 'rfsTaskWares?tid=%s&wid=%s&mes=%s' % (args['tid'], args['wid'], _('Invalid barcode'))) wlots = '' amounts = '' for item in args: if item.find('wl') != -1: wlots += item[2:] + ';' amounts += args[item] + ';' try: #print [self.getIfaceVar('wmsid'), args['tid'], slotid, args['wuid'], wlots, amounts, # args['ctm']] self.dbExec( sql='execute procedure K_WH_REFILLSLOT_DO(?,?,?,?,?,?,?)', fetch='none', params=[ self.getIfaceVar('wmsid'), args['tid'], slotid, args['wuid'], wlots, amounts, args['ctm'] ]) except FBExc, exc: raise HTTPRedirect('rfsTaskWares?tid=%s&wid=%s&mes=%s' % (args['tid'], args['wid'], exc[1]))
def main(self, barcode=None, mes=None): if barcode: mes = _('Invalid barcode') bcInfo = self.kBarCodeInfo(barcode) if bcInfo and bcInfo['result'] == 0: if bcInfo['usercode'] == 'DOCUMENT': t = self.dbExec( sql= "select * from K_WH_INCOME_LISTDOCS(?) where docid=?", params=[ self.getIfaceVar('wmsid'), self.kId(bcInfo['recordid']) ], fetch='one') if t and t['taskid']: raise HTTPRedirect('task?tid=%s' % (t['taskid'])) elif bcInfo['usercode'] == 'PRINTER': raise HTTPRedirect('printer?id=%s' % (self.kId(bcInfo['recordid']))) docs = self.dbExec(sql="select * from K_WH_INCOME_LISTDOCS(?)", params=[self.getIfaceVar('wmsid')], fetch='all') zonedocs = self.dbExec(sql="select * from K_WH_INCOME_LISTOBJDOCS(?)", params=[self.getIfaceVar('wmsid')], fetch='all') zonedocs['zd'] = zonedocs['datalist'] del zonedocs['datalist'] return self.drawTemplate( templ=self.tmplIndex, data=[docs, zonedocs, { 'mes': mes, 'reloadurl': 'main' }])
def delete(self, *args): if args == None: raise HTTPRedirect('/?message=Please specify an id! ') request.db.query(Post).filter_by(id=args[0]).delete() raise HTTPRedirect("/")
def rfsGetTask(self, tid=None): try: t = self.dbExec(sql='select * from K_WH_REFILLSLOT_GETTASK(?)', params=[self.getIfaceVar('wmsid')], fetch='one') if t and t['TASKID'] and self.kId(t['TASKID']) != tid: raise HTTPRedirect('rfsTask?id=%s&chkTask=1' % (t['TASKID'])) except FBExc, exc: raise HTTPRedirect('rfsMain?mes=%s' % (self.fbExcText(exc[1])))
def add(self, **kwargs): if kwargs['title'] == None or kwargs['content'] == None: cherrypy.session['MESSAGE'] = u"Please Fill All Post Fields!" raise HTTPRedirect('/') blog = Post(title=kwargs['title'], content=kwargs['content']) request.db.add(blog) raise HTTPRedirect("/")
def rfsTaskByWares(self, wid): try: t = self.dbExec(sql='select * from WH_REFILLSLOT_TASKBYWARES(?,?)', params=[wid, self.getIfaceVar('wmsid')], fetch='one') if t and t['TASKID']: raise HTTPRedirect('rfsTaskWares?tid=%s&wid=%s' % (t['TASKID'], wid)) except FBExc, exc: raise HTTPRedirect('rfsMain?mes=%s' % (self.fbExcText(exc[1])))
def taskStackWaresModel(self, tid, sid, wid): s = self.siteStackInfo(sid) if s['S_SPCODE'] != 'STACK': raise HTTPRedirect('taskStackWaresProdLine?tid=%s&sid=%s&wid=%s' % (tid, sid, wid)) m = self.dbExec(sql="select distinct * from WH_STACKWARES_LISTAVAIL(?,?)", params=[sid, wid], fetch="all") if len(m['datalist'])==1: raise HTTPRedirect('taskStackWaresProdLine?tid=%s&sid=%s&wid=%s&mid=%s' % (tid, sid, wid, m['datalist'][0]['MODELID'])) t = self.taskInfo(tid) w = self.waresInfo(wid) return self.drawTemplate(templ=self.tmplTaskStackWaresModel, data=[t, s, w, m, {'backurl': 'taskStack?tid=%s&sid=%s' % (tid, sid)}])
def waresScan(self, id, barcode): bcInfo = self.kBarCodeInfo(barcode) if bcInfo and bcInfo['result'] == 0: mes = _('Не верный ШК') if bcInfo['usercode'] == 'WARES': raise HTTPRedirect('wares?id=%s' % (bcInfo['recordid'])) elif bcInfo['usercode'] == 'SITE': raise HTTPRedirect('waresSlot?wid=%s&sid=%s' % (id, bcInfo['recordid'])) else: mes = bcInfo['mes'] return self.wares(id=id, mes=mes)
def taskScan(self, tid, barcode): sl = self.dbExec(sql='select * from WH_FIRSTINCOMEFG_SITEBYTEXT(?)', params=[barcode], fetch='all') if len(sl['datalist']) == 1: s = sl['datalist'][0] if s['SPCODE'] == 'STACK': raise HTTPRedirect('taskStack?tid=%s&sid=%s' % (tid, s['SID'])) elif s['SPCODE'] == 'S': raise HTTPRedirect('taskSlot?tid=%s&sid=%s' % (tid, s['SID'])) elif s['SPCODE'] == 'B': raise HTTPRedirect('taskStack?tid=%s&sid=%s' % (tid, s['SID'])) elif len(sl['datalist']) > 1: return self.taskRangeSite(dl=sl, tid=tid) """else:
def bpMain(self, barcode=None, mes=None): if barcode: bcInfo = self.kBarCodeInfo(barcode) if bcInfo and bcInfo['result']==0: mes = _('Не верный ШК') if bcInfo['usercode']=='PALLET': raise HTTPRedirect('bpPallet?id=%s'%(bcInfo['recordid'])) elif bcInfo['usercode']=='SITE': pid = self.getSitePallet(siteid = bcInfo['recordid']) if pid: raise HTTPRedirect('bpPallet?id=%s'%(pid)) else: mes = bcInfo['mes'] return self.drawTemplate(templ=index,data=[{'mes':mes}])
def rfsGetTask(self, tid=None): try: t = self.dbExec(sql='select * from K_WH_REFILLSLOT_GETTASK(?)', params=[self.getIfaceVar('wmsid')], fetch='one') if t and t['TASKID']: raise HTTPRedirect('rfsTaskWares?tid=%s&wid=%s' % (t['TASKID'], t['WARESID'])) except FBExc, exc: if tid: raise HTTPRedirect('rfsTask?id=%s&mes=%s' % (tid, self.fbExcText(exc[1]))) else: raise HTTPRedirect('rfsMain?mes=%s' % (self.fbExcText(exc[1])))
def auto(self, id, barcode = None, mes = None): if barcode: bcInfo = self.kBarCodeInfo(barcode) if bcInfo and bcInfo['result']==0: if bcInfo['usercode']=='AUTO': raise HTTPRedirect('auto?id=%s'%(bcInfo['recordid'])) elif bcInfo['usercode']=='TRANSUNIT': raise HTTPRedirect('autoTransUnit?aid=%s&tuid=%s'%(id,bcInfo['recordid'])) else: mes = _('Не верный ШК') else: mes = bcInfo['mes'] a = self.autoInfo(id) atu = self.dbExec(sql="select * from WH_TRANSUNITRETURN_AUTOLISTTU(?)",params=[id],fetch="all") return self.drawTemplate(templ=auto,data=[a,atu,{'backurl':'main', 'mes':mes}])
def _test(self, arg): """tests a command on a different bunny1 host. usage: _test [fully-qualified-bunny1-url] [command]""" (bunny1_url, arg) = arg.split(None, 1) if not bunny1_url.endswith("?"): bunny1_url += "?" save("bunny1testurl", bunny1_url) raise HTTPRedirect(bunny1_url + quote(arg))
def logout(self, return_url=None): for key in [ 'google_oauth', 'google_user', 'admin_user', 'auth_redirect' ]: if cherrypy.session.get(key): del cherrypy.session[key] return_url = (return_url if return_url else cherrypy.request.headers.get('Referer', '/')) if (any( return_url.startswith(_) for _ in ['/', 'https://', 'http://']) and not return_url.startswith('/auth')): raise HTTPRedirect(return_url) raise HTTPRedirect(url_for_class('controller.Root'))
def rfsTaskWares(self, tid, wid, mes=None): tid = self.kId(tid) wid = self.kId(wid) w = self.waresInfo(wid) tw = self.dbExec( sql='select * from K_WH_REFILLSLOT_LISTTASKWARES(?,?)', params=[tid, wid], fetch='one') wp = self.dbExec(sql="select * from K_WORKPALLET_PALWARLOTS(?,?)", params=[tw['pid'], wid], fetch='all') if not wp or len(wp['datalist']) == 0: raise HTTPRedirect( 'rfsTaskWaresPallet?tid=%s&wid=%s&mes=%s' % (tid, wid, 'Нет товара на поддоне!<br>(' + w['WCODE'] + ') ' + w['WNAME'])) t = self.taskInfo(tid) s = self.siteInfo(t['SITEID']) params = { 'backurl': 'rfsTask?id=%s' % (tid), 'treeName': 'Позиция', 'mes': mes, 'ctm': self.dbCurrentTimestamp() } return self.drawTemplate(templ=taskWares, data=[t, tw, w, s, wp, params])
def main(self, mes=None): t = self.dbExec(sql="select * from WH_FIRSTINCOMEFG_GETTASK(?)", params=[self.getIfaceVar('wmsid')], fetch='one') if t and t['TASKID']: raise HTTPRedirect('task?tid=%s'%(t['TASKID'])) return self.drawTemplate(templ=self.tmplIndex, data=[t, {'mes': _('Нет задания на приемку'), 'reloadurl': 'main'}])
def printer(self, labeltype, barcode=None, pcnt=None): mes = None if pcnt and barcode: if labeltype == 'I': tasktypecode = 'INCOME' elif labeltype == 'CR': tasktypecode = 'COMERETURN' bcInfo = self.kBarCodeInfo(barcode) if bcInfo and bcInfo['result'] == 0 and bcInfo[ 'usercode'] == 'PRINTER': try: params = [ tasktypecode, self.getIfaceVar('wmsid'), self.kId(bcInfo['recordid']), pcnt ] self.dbExec( sql= "execute procedure WH_INCOME_PRINTPALLET(?,?,NULL,?,?)", params=params, fetch='none') except FBExc, exc: mes = self.fbExcText(exc[1]) else: raise HTTPRedirect('main') else: mes = _('Invalid barcode')
def rfsTaskWaresQ(self, taskid, waresid): try: tw = self.dbExec(sql='select * from WH_REFILLSLOT_CALCQNEED(?,?)', params=[taskid, waresid], fetch='one') except FBExc, exc: raise HTTPRedirect('rfsMain?mes=%s' % (self.fbExcText(exc[1])))
def rfsTaskEnd(self, id): try: self.dbExec(sql='execute procedure K_WH_REFILLSLOT_END(?)', fetch='none', params=[id]) except FBExc, exc: raise HTTPRedirect('rfsTask?id=%s&mes=%s' % (id, exc[1]))
def rfsTaskBySlot(self, id): try: t = self.dbExec(sql='select * from wh_REFILLSLOT_TASKBYSLOT(?,?)', params=[id, self.getIfaceVar('wmsid')], fetch='one') except FBExc, exc: raise HTTPRedirect('rfsMain?mes=%s' % (self.fbExcText(exc[1])))
def gate(self, id, barcode=None, mes=None): id = self.kId(id) if barcode: mes = _('Неверный ШК') bcInfo = self.kBarCodeInfo(barcode) if bcInfo and bcInfo['result'] == 0: if bcInfo['usercode'] == 'SITE': s = self.siteInfo(id = bcInfo['recordid']) if s['SPCODE'] == 'GATE': raise HTTPRedirect('gate?id=%s'%(bcInfo['recordid'])) elif bcInfo['usercode'] == 'AUTO': raise HTTPRedirect('gateAuto?gid=%s&aid=%s&bu=g'%(id,bcInfo['recordid'])) g = self.gateInfo(id = id) if g['TID']: raise HTTPRedirect('task?id=%s'%(g['TID'])) else: dl = self.dbExec(sql="select * from WH_LOADAUTODC_GATELISTAUTO(?)",params=[id],fetch="all") return self.drawTemplate(templ=self.tmplGate,data=[g,dl,{'mes':mes,'backurl':'main'}])
def waresData(self, wid, prdate=None, lid=None, prid=None, pcnt=None, pq=None, barcode=None): mes = None if prdate and pcnt and pq and barcode: bcInfo = self.kBarCodeInfo(barcode) if bcInfo and bcInfo['result'] == 0 and bcInfo[ 'usercode'] == 'PRINTER': try: self.dbExec( sql= "execute procedure WH_FG_PRINTPALLET(?,?,?,?,?,?,?,?)", fetch='none', params=[ self.getUserVar('uid'), wid, prid, lid, pcnt, self.kId(bcInfo['recordid']), prdate, None ]) except FBExc, exc: mes = self.fbExcText(exc[1]) else: raise HTTPRedirect('main') else: mes = _('Invalid barcode')
def chgZone(self, id): try: self.dbExec(sql="execute procedure WH_SESSION_SETZONE(?,?)", params=[self.getIfaceVar('wmsid'), id], fetch='none') except FBExc, exc: raise HTTPRedirect('main?mes=%s' % (self.fbExcText(exc[1])))
def qTaskJoin(self, tid): try: self.dbExec(sql="execute procedure K_SESSION_JOIN_TASK(?,?)", params=[tid, self.getIfaceVar('wmsid')], fetch='none') except FBExc, exc: raise HTTPRedirect('main?mes=%s' % (self.fbExcText(exc[1])))
def taskWaresScan(self, tid, barcode, wid=None): mes = _('ШК не обрабатывается') bcInfo = self.kBarCodeInfo(barcode) if bcInfo and bcInfo['result'] == 0: mes = _('Invalid barcode') if bcInfo['usercode'] == 'WARESUNIT': tw = self.dbExec( sql="select * from WH_INCOME_LISTWARES_BY_BARCODE(?,?)", params=[tid, barcode], fetch='all') if len(tw['datalist']) == 1: tw0 = tw['datalist'][0] raise HTTPRedirect('taskWares?tid=%s&wid=%s&wuid=%s' % (tid, tw0['WID'], tw0['WUID'])) elif len(tw['datalist']) > 1: raise HTTPRedirect('rangeWares?tid=%s&barcode=%s' % (tid, barcode)) else: mes = _( 'Товары с этим ШК не найдены в задании на приемку!' ) elif bcInfo['usercode'] == 'WARES': tw = self.dbExec( sql="select * from K_WH_INCOME_LISTWARES(?) where wid=?", params=[tid, self.kId(bcInfo['recordid'])], fetch='one') if tw and tw['WID']: raise HTTPRedirect('taskWares?tid=%s&wid=%s' % (tid, bcInfo['recordid'])) else: mes = _('Товар не найден в задании!') raise HTTPRedirect('taskWares?tid=%s&wid=%s' % (tid, bcInfo['recordid'])) elif bcInfo['usercode'] == 'WARESWEIGHT': ww = self.dbExec(sql=bcInfo['SELECTSQL'], params=[], fetch='one') if ww: raise HTTPRedirect('taskWaresAdd?tid=%s&wid=%s&amount=%s' % (tid, ww['WID'], ww['WWEIGHT'])) elif bcInfo['usercode'] == 'PALLET': url = 'pallet?id=%s&tid=%s' % (bcInfo['recordid'], tid) if wid: url += '&wid=%s' % (wid) raise HTTPRedirect(url) elif bcInfo['usercode'] == 'PRINTER' and self.urlTaskPrinter: raise HTTPRedirect(self.urlTaskPrinter + '?tid=%s&prid=%s' % (tid, bcInfo['recordid'])) if wid: raise HTTPRedirect('taskWares?tid=%s&wid=%s&mes=%s' % (tid, wid, mes)) else: raise HTTPRedirect('task?tid=%s&mes=%s' % (tid, mes))
def taskEnd(self, tid): try: self.dbExec(sql="execute procedure K_WH_INCOMEDC_TASKEND(?,?)", params=[tid, self.getIfaceVar('wmsid')], fetch='none') except FBExc, exc: raise HTTPRedirect('task?tid=%s&mes=%s' % (tid, self.fbExcText(exc[1])))