def GET(self): params = web.input() if "id" in params: web.heart_beat_monitor.add_log_id(params.id) return web.cmd_handler.get_current_command()
def POST(self): params = web.input() configs = {} configs[configkey.IS_PASV] = params.get(configkey.IS_PASV) configs[configkey.DS_NAME] = params.get(configkey.DS_NAME) configs[configkey.SERIAL_PORT] = params.get(configkey.SERIAL_PORT) configs[configkey.SERIAL_BAUDRATE] = params.get(configkey.SERIAL_BAUDRATE) #空白率 PIXERRATIO = params.get(configkey.PIXERRATIO) if PIXERRATIO: configs[configkey.PIXERRATIO] =PIXERRATIO configs[configkey.BARCODE_RULE] = params.get(configkey.BARCODE_RULE) try: re.compile(str(params.get(configkey.BARCODE_RULE))) except: traceback.print_exc() return json.dumps(common.buildFail(_("条码规则语法错误"))) # # session = web.config._session # configs[configkey.COMPANY_CODE + session.user.get("userNum")] = params.get(configkey.COMPANY_CODE + session.user.get("userNum")) # configs[configkey.SITE_ID + session.user.get("userNum")] = params.get(configkey.SITE_ID + session.user.get("userNum")) # configs[configkey.OPERATION_TYPE_CODE + session.user.get("userNum")] = params.get(configkey.OPERATION_TYPE_CODE + session.user.get("userNum")) rtn = common.buildFail(_("保存失败")) try: self.configDao.save(configs) rtn = common.buildSuccess() from config import config config.reloadConfigDict() except Exception: traceback.print_exc() return json.dumps(rtn)
def data_handle(self): objInput = web.input() try: obj_input = web.input() objCondition = obj_input.get('objCondition') objPageInfo = obj_input.get('objPageInfo') dictCondition = json.loads(objCondition) dictPageInfo = json.loads(objPageInfo) if 'nUserID' in dictCondition and dictCondition['nUserID']: nUserID = dictCondition['nUserID'] else: nUserID = '' if 'sWorkCode' in dictCondition and dictCondition['sWorkCode']: sWorkCode = dictCondition['sWorkCode'] else: sWorkCode = '' if 'sUserCode' in dictCondition and dictCondition['sUserCode']: sUserCode = dictCondition['sUserCode'] else: sUserCode = '' if 'sUserName' in dictCondition and dictCondition['sUserName']: sUserName = dictCondition['sUserName'] else: sUserName = '' if 'nOperaType' in dictCondition and dictCondition['nOperaType']: nOperaType = dictCondition['nOperaType'] else: nOperaType = '' if 'sPost' in dictCondition and dictCondition['sPost']: sPost = dictCondition['sPost'] else: sPost = '' if 'sDateStart' in dictCondition and dictCondition[ 'sDateStart'] and dictCondition['sDateStart'] != '': dtDateStart = to_datetime(dictCondition['sDateStart']) else: dtDateStart = '' if 'sDateEnd' in dictCondition and dictCondition[ 'sDateEnd'] and dictCondition['sDateEnd'] != '': dtDateEnd = to_datetime(dictCondition['sDateEnd']) else: dtDateEnd = '' # objPageInfo = dictCondition['objPageInfo'] # objPageInfo = json.loads(objPageInfo) except Exception, ce: print Exception, ce return FuncResult(fail='参数有误!')
def POST(self, lineId): i = web.input() ocrResult = {} ocrResult[i['code']] = i['val'] ocrResult[i['code'] + 'R'] = '0' ocrResult["resultId"] = i["resultId"] self.ocrResultDao.update(ocrResult) return True
def data_handle(self): objInput = web.input() try: sUserCode = objInput.get('sUserCode') sPassword = objInput.get('sPassword') sCode = objInput.get('sCode') except Exception, ce: return FuncResult(fail=ce)
def POST(self): i = web.input() method = i.get("method") if ("initMachine" == method): return self.initMachine() if ("doScan" == method): return self.doScan() if ("backPaper" == method): return self.backPaper() if ("searchByHeadNum" == method): return self.searchByHeadNum()
def GET(self): i = web.input() headId = i.get("headId") head = self.imgHeadDao.getById(headId) lines = self.imgLineDao.findByHeadId2(headId) # headJson = json.dumps(head) # linesJson = json.dumps(lines) if head: return render.modules.delivery.edit(head, lines) else: return render.modules.delivery.scan()
def searchByHeadNum(self): i = web.input() headNum = i.get("headNum") lines = self.imgLineDao.getByHeadNum(headNum) for line in lines: line['imgPathS'] = pathJoin("/static/images/scan", headNum, "s_" + line.get("imgNameP")) + "?r=" + str(random.random()) line['imgPathO'] = pathJoin("/static/images/scan", headNum, line.get("imgNameP")) + "?r=" + str(random.random()) fullName = line.get("imgNameS").split(".") line['imgName'] = fullName[0] line['imgExt'] = fullName[1] return json.dumps(common.buildSuccess(data=lines))
def cancel(self): # 通知电机退票 mds = HuageSerial() rtn = mds.backPaper() # rtn = common.buildSuccess() if rtn["isSuccess"]: # 删除任务 i = web.input() head_id = i.get("headId") rtn = self.deleteTaskByHeadId(head_id) return rtn
def write_log_db(log_data=None): '''写入日志到数据库 ''' table_name = 'l_operating_log' try: sql = '''INSERT INTO `%s` (`UserID`,`WorkCode`,`UserName`,`OperaType`,`LogInfo`,`IP`,`CreateTime`,`Remark`) VALUES (:UserID,:WorkCode,:UserName,:OperaType,:LogInfo,:IP,:CreateTime,:Remark)''' if web.ctx.session.user: nUserID = web.ctx.session.user['UserID'] sWorkCode = web.ctx.session.user['UserCode'] sUserName = web.ctx.session.user['UserName'] else: nUserID = '' sWorkCode = '' sUserName = '' if web.input().get('sRemark'): sRemark = web.input().get('sRemark') else: sRemark = '' web.ctx.cur_dbconn.execute( text(sql % table_name), UserID=nUserID, WorkCode=sWorkCode, UserName=sUserName, OperaType=web.ctx.apiDesc if web.ctx.apiDesc else '', LogInfo=obj_to_json(log_data), IP=web.ctx.ip, CreateTime=datetime.now(), Remark=sRemark) except: from utils.trace_except import get_cur_except print get_cur_except()[0] pass return FuncResult(success=True)
def POST(self): i = web.input() method = i.get("method") if method == "sendData": sendStr = i.get("sendStr") return json.dumps(self.sendData(sendStr.encode("utf-8"))) elif method == "recvDate": return json.dumps(self.recvDate()) elif method == "saveConf": port = i.get("port", "COM1") baudrate = i.get("baudrate", 9600) return json.dumps(self.reloadCom(port, baudrate))
def pickUp(self): i = web.input() pickupCode = i.get("pickupCode") if not pickupCode: return json.dumps(common.buildFail(u"取件码不能为空!")) # 通过取件码查询柜子 box = self.boxDao.getByPickupCode(pickupCode) if not box: return json.dumps(common.buildFail(u"取件码错误,请重新输入!")) # 发送打开柜子指令 mds = MeidingSerial() rtn = mds.openBox(box.get("boxNum")) return json.dumps(rtn)
def POST(self): i = web.input() method = i.get("method") if ("getImages" == method): return self.getImages() if ("editNum" == method): return self.editNum() if ("submit" == method): return self.submit() if ("cancel" == method): return self.cancel() pass
def data_handle(self): objInput = web.input() try: if not objInput.get('nSearchUserIDMust'): return FuncResult(fail='nSearchUserIDMust为必传参数!') if not objInput.get('sSearchUserNameMust'): return FuncResult(fail='sSearchUserNameMust为必传参数!') nCheckInID = objInput.get('nCheckInID') if not nCheckInID.strip(): return FuncResult(fail='参数nCheckInID值不能为空!') except Exception, ce: return FuncResult(fail=ce)
def GET(self): i = web.input() lang = i.get('lang') if not lang: lang = web.config._session.get('lang') lang = lang if lang else 'zh_CN' elif lang not in ['zh_CN', 'en_US']: lang = 'zh_CN' # Debug. print 'Language:', lang web.config._session['lang'] = lang from config import config web.config._session['appName'] = config.appName return render.modules.login(self.configDao.findAllAsDict(), web.cookies().get("userCd") or '')
def get_request_page_params(): '''获取请求参数 ''' web.header('Content-Type', 'text/plain') try: params = web.storage() params.userid = web.input().get('userid') query_columns = web.input().get('query_columns') query_params = web.input().get('query_params') query_params_value = web.input().get('query_params_value') if query_columns:query_columns = json_to_obj(query_columns) if query_params:query_params = json_to_obj(query_params) if query_params_value:query_params_value = json_to_obj(query_params_value) params.query_columns = query_columns params.query_params = query_params or [] params.query_params_value = query_params_value or {} ispage = web.input().get('ispage') if ispage: ispage = ispage.lower().strip() == 'true' params.ispage = ispage or False page_num = web.input().get('page_num') if page_num: page_num = int(page_num) params.page_num = page_num or 0 page_size = web.input().get('page_size') if page_size: page_size = int(page_size) params.page_size = page_size or 0 params.order = web.input().get('order', '') params.order_desc = web.input().get('order_desc', '') return FuncResult(success=True, value=params) except Exception, ce: print ce.message return FuncResult(fail='传入参数json格式有误!')
def POST(self): from model.huageSerial import HuageSerial mds = HuageSerial(port="COM1") i = web.input() method = i.get("method") if method == "initMachine": # ========================初始化==================== rtn = mds.initMachine() return json.dumps(rtn) elif method == "recyclePaper": # ========================回收==================== rtn = mds.recyclePaper() return json.dumps(rtn) elif method == "backPaper": # ========================退件==================== rtn = mds.backPaper() return json.dumps(rtn)
def editNum(self): rtn = None i = web.input() dbHead = self.imgHeadDao.findByHeadNum(i.headNum) if dbHead is not None: rtn = common.buildFail(_(u"任务编号:") + i.headNum + _(u"已经存在")) return json.dumps(rtn) try: oldDir = pathJoin(scanPath, i.oldNum) newDir = pathJoin(scanPath, i.headNum) os.rename(oldDir, newDir) self.imgHeadDao.updateImgHeadNum(i.headId, i.headNum) rtn = common.buildSuccess(u"修改编号成功"); except: traceback.print_exc() rtn = common.buildFail(_(u"修改编号失败")) return json.dumps(rtn)
def GET(self): i = web.input() session = web.config._session cond = {"userCd":session.user.get("userCd"),"order":"headerId Desc","noStatus":["TODO","WAIT"]} if i.get("custName") and i.get("custName").strip()!="": cond["custName"]=i.get("custName").strip() if i.get("uploadTimeStart") and i.get("uploadTimeStart").strip()!="": cond["uploadTimeStart"]=i.get("uploadTimeStart").strip() if i.get("uploadTimeEnd") and i.get("uploadTimeEnd").strip()!="": cond["uploadTimeEnd"]=i.get("uploadTimeEnd").strip() pageNum = 1 if not i.get("pageNum") or i.get("pageNum").strip()=="": pageNum = 1 else: pageNum = int(i.get("pageNum")) page = {"pageNum":pageNum,"cond":cond} page = self.ImgHeadDao.findByPage(page) page["headStatus"] = constants.headStatusShow return render.modules.history(page)
def POST(self): d = web.input() if d.type == "netSet": return json.dumps(self.netSet(d)) elif d.type == "testNetSet": return json.dumps(self.testNetSet(d)) elif d.type == "nologin": return json.dumps(self.nologin(d)) elif d.type == "login": return json.dumps(self.login(d)) elif d.type == "isLogin": session = web.config._session pathname = d.get("pathname") if session.get("user") is None and pathname != "/login": return False else: return True return web.seeother("/scan")
def data_handle(self): objInput = web.input() objCondition = json_to_obj(objInput.get('objCondition')) objPage = json_to_obj(objInput.get('objPageInfo')) if not objCondition: return FuncResult(msg='未输入查询条件!') else: if not objCondition.has_key( 'nSearchUserIDMust' ) or not objCondition['nSearchUserIDMust']: return FuncResult(fail='nSearchUserIDMust为必传参数!') if not objCondition.has_key( 'sSearchUserNameMust' ) or not objCondition['sSearchUserNameMust']: return FuncResult(fail='sSearchUserNameMust为必传参数!') return self.search_foreign_checkin(objCondition, objPage)
def POST(self): i = web.input() session = web.config._session userNum = session.user.get("userNum") pageNum = int(i.pageNum) if i.pageNum else 1 page = { "cond": { "headNum":i.headNum, "userNum":userNum, "isChecked":i.isChecked }, "pageNum":pageNum, } session['recognition'] = { "headNum":i.headNum, "isChecked":i.isChecked, "pageNum":pageNum, } ret = self.ocrResultDao.findByPage(page) return render.modules.recognition(Storage(ret))
def getImages(self): i = web.input() headId = i.get("headId") lines = self.imgLineDao.findByHeadId2(headId) datas = [] for line in lines: data = { "alt": "序号" + str(line.get("imgOrd")), "pid": line.get("id"), "src": "/static/images/scan/" + line.get("headNum") + "/" + line.get("imgNameP"), "thumb": "/static/images/scan/" + line.get("headNum") + "/s_" + line.get("imgNameP"), # 缩略图地址 } datas.append(data) p_data = { "title": lines[0].get("headNum"), "id": headId, "start": 0, "data": datas } return json.dumps(common.buildSuccess(data=p_data))
def GET(self): i = web.input() session = web.config._session cond = {"order":"headId Desc",'userNum':session.user.get("userNume")} if i.get("headNum") and i.get("headNum").strip()!="": cond["headNum"]=i.get("headNum").strip() if i.get("status") and i.get("status").strip()!="": cond["status"]=i.get("status").strip() else: cond["noStatus"]=["TODO","WAIT"] pageNum = 1 if not i.get("pageNum") or i.get("pageNum").strip()=="": pageNum = 1 else: pageNum = int(i.get("pageNum")) page = {"pageNum":pageNum,"cond":cond} pageSize = i.get("pageSize") if pageSize: page["pageSize"]=int(pageSize) page = self.imgHeadDao.findByPage(page) page["headStatus"] = constants.headStatusShow return render.modules.result(page)
def POST(self): i = web.input() method = i.get("method") if ("openBox" == method): return self.openBox(int(i.get("boxNum")))
def POST(self): i = web.input() method = i.get("method") if ("pickup" == method): return self.pickUp()
def uploadToFtp(self): i = web.input() session = web.config._session headId = i.get("headId") startTime = time.time() self.uploadingLineId = headId imgHead = self.imgHeadDao.getById(headId) # 清空 imgHead['errorMsg'] = '' imgHead["uploadTime"] = time.strftime('%Y-%m-%d %H:%M:%S') imgHead['status'] = headStatus.UPLOADING self.imgHeadDao.update(imgHead) userForm = {} for f in json.loads(imgHead.get("userForm")): userForm[f.get("name")] = f.get("value") jsonParam = {"appCode": imgHead.get("appCode"), "form": userForm} t1 = time.time() # 询问服务器是否能上传 ftpRet = self.evsInterface.FtpInfo(session.ticket, imgHead.get("belong"), json.dumps(jsonParam)) if not ftpRet.get("isSuccess"): self.uploadTaskDao.deleteByHeadId(headId) imgHead["status"] = headStatus.FAILURE imgHead["errorMsg"] = _(u"获取ftp信息失败") self.imgHeadDao.update(imgHead) ftpInfo = ftpRet.get("data") # 不能上传 if ftpInfo.get('code') == 'F' or ftpInfo.get("status") == ftpStatus.CLOSED: self.uploadTaskDao.deleteByHeadId(headId) imgHead["status"] = headStatus.FAILURE imgHead["errorMsg"] = ftpInfo.get("errorMsg") self.imgHeadDao.update(imgHead) # 补全ftp信息 print "-----------ftpInfo", ftpInfo print "-----------ftpInfo.get(\"ftpId\")):", ftpInfo.get("ftpId") print "-----------str(ftpInfo.get(\"ftpId\"))):", str(ftpInfo.get("ftpId")) # print "-----------self.ftpMap.get(str(ftpInfo.get(\"ftpId\"))):",self.ftpMap.get(str(ftpInfo.get("ftpId"))) ftpInfo.update(session.ftpMap.get(str(ftpInfo.get("ftpId")))) self.uploadTaskDao.updateStatusByHeadId(headId, taskStatus.UPLOADING) t2 = time.time() print "call uploadTaskDao time :%d" % (t2 - t1) imgLines = self.imgLineDao.findByHeadId2(headId) imageList = [] iconList = [] # 上传影像到ftp flag = False t1 = time.time() # ip:,port:,userName:"","password": ftpIp = ftpInfo.get("ftpIp") ftpPort = int(ftpInfo.get("port")) ftpUser = ftpInfo.get("userName") ftpPwd = ftpInfo.get("password") imagePath = ftpInfo.get("imagePath") iconPath = ftpInfo.get("iconPath") # 上传原图 myFtp = MyFTP() # 测试ftp flagFtp = True flagFtp = myFtp.testFtp(ftpIp, ftpPort, ftpUser, ftpPwd) if not flagFtp: self.uploadTaskDao.uploadFail(headId, _(u"连接ftp[%s]失败" % (str(ftpIp)))) # 如果是评价任务,删除 if constants.belongType.get("APPRAISE_TASK") == imgHead.get("belong"): print "delete dir ----->iconPath:", iconPath myFtp.deletedir(ftpIp, ftpPort, ftpUser, ftpPwd, iconPath) for imgLine in imgLines: localPath = pathJoin(scanPath, imgHead.headNum, imgLine.imgNameP) localIconPath = pathJoin(scanPath, imgHead.headNum, "s_" + imgLine.imgNameP) remotePath = pathJoin(imagePath, imgHead.headNum, imgLine.imgNameP) imageList.append(remotePath) global uploadingLineId uploadingLineId = imgLine.lineId flagFtp = flagFtp and myFtp.upload(ftpIp, ftpPort, ftpUser, ftpPwd, remotePath, localPath, self.callback2) if not flagFtp: break if iconPath: # 上传缩略图 remoteIconPath = pathJoin(iconPath, imgHead.headNum, imgLine.imgNameP) iconList.append(remoteIconPath) flagFtp = flagFtp and myFtp.upload(ftpIp, ftpPort, ftpUser, ftpPwd, remoteIconPath, localIconPath) # 只要有一个失败当前任务就算失败 if not flagFtp: break t2 = time.time() print "call ftpU.upload time :%d" % (t2 - t1) if flagFtp: # 同步上传影像的信息 TODO t1 = time.time() jsonParam["imageList"] = imageList jsonParam["iconList"] = iconList # uploadLogFlag = self.evsInterface.UploadLog(self.ticket,imgHead.get("belong"), json.dumps(jsonParam)) UploadLogRtn = self.evsInterface.UploadLog(session.ticket, imgHead.get("belong"), json.dumps(jsonParam)) uploadLogFlag = False if (UploadLogRtn and UploadLogRtn.get("isSuccess") and UploadLogRtn.get("data") and UploadLogRtn.get( "data").get("code") == 'S'): uploadLogFlag = True t2 = time.time() print "call client.service.UploadLog time :%d" % (t2 - t1) print "---------->uploadLogFlag:" + str(uploadLogFlag) flag = flagFtp and uploadLogFlag status = headStatus.FAILURE # # 在删除之前,先查询出数据,用于插入日志表 # uploadTask = self.uploadTaskDao.getByHeadId(headId) if flag: status = headStatus.SUCCESS # 删除任务 self.uploadTaskDao.deleteByHeadId(headId) else: # 修改状态 self.uploadTaskDao.updateStatusByHeadId(headId, status) # 插入上传任务历史表 t1 = time.time() # uploadTaskLog = copy.deepcopy(uploadTask) # uploadTaskLog.pop("uploadTaskId") # uploadTaskLog['status'] = status # self.uploadTaskLogDao.save(uploadTaskLog) # 修改组状态 self.imgHeadDao.updateStatusByheadId(headId, status) t2 = time.time() print "update status time :%d" % (t2 - t1) endTime = time.time() print u"总时间%d" % (endTime - startTime) return status
def POST(self): i = web.input() method = i.get("method") if ("initMachine" == method): return self.initMachine()