def admin_tabledata(request): if request.method == "POST": #POST请求 #请求body转为json tmp=request.body tmp=tmp.decode(encoding='utf-8') reqest_body=json.loads(tmp) trantype=reqest_body['trantype'] # print('-' * 20, trantype, '-' * 20) log.info('trantype=[%s]' % trantype) if trantype == 'selecttablehead': #获取表头 resp = tablecfg.selectTableHead(request) elif trantype == 'selecttabledata': #获取表数据 resp = tablecfg.selectTableData(request) elif trantype == 'getlistdata': #获取表配置的下拉列表数据元素 resp = tablecfg.GetListData(request) elif trantype == 'gettransferdata': # 获取穿梭框数据信息 resp = tablecfg.GetTransferData(request) elif trantype == 'addtabledata': #新增数据 resp = tablecfg.AddTableData(request) elif trantype == 'updtabledata': #更新数据 resp = tablecfg.UpdTableData(request) elif trantype == 'deltabledata': #删除数据 resp = tablecfg.DelTableData(request) else: s = public.setrespinfo({"respcode": "100000", "respmsg": "api error"}) resp = HttpResponse(s) elif request.method == "GET": #GET请求 s = public.setrespinfo({"respcode": "100000", "respmsg": "api error"}) resp = HttpResponse(s) return resp
def main(request): log = public.logger log.info('----------------------%s-begin---------------------------' % filename) if request.method == "POST": #POST请求 #请求body转为json tmp = request.body tmp = tmp.decode(encoding='utf-8') request_body = json.loads(tmp) trantype = request_body['trantype'] log.info('trantype=[%s]' % trantype) fun_name = trantype if globals().get(fun_name): resp = globals()[fun_name](request, request_body) else: s = public.setrespinfo({ "respcode": "100000", "respmsg": "api error! lqkjerp!" }) resp = HttpResponse(s) elif request.method == "GET": #GET请求 s = public.setrespinfo({"respcode": "100000", "respmsg": "api error"}) resp = HttpResponse(s) log.info('----------------------%s-end---------------------------' % filename) return resp
def admin_useraction(request, log): if request.method == "POST": #请求body转为json tmp=request.body tmp=tmp.decode(encoding='utf-8') reqest_body=json.loads(tmp) trantype=reqest_body['trantype'] # print('-'*20,trantype,'-'*20) log.info('trantype=[%s]' % trantype) if trantype == 'getmessagecode': #获取短信验证码 resp = useract.GetMsgCode(request) elif trantype == 'getQRcode': #获取微信登陆二维码 resp = useract.GetQRCode(request) elif trantype == 'login': #用户登陆,手机短信验证码登陆 resp = useract.UserLogin(request) elif trantype == 'loginbypass': #使用用户名密码登陆 resp = useract.LoginByPass(request) elif trantype == 'GetUserInfo': # 获取用户信息 resp = useract.GetUserInfo(request) elif trantype == 'modifypass': #修改用户登陆密码 resp = useract.modifypass(request) elif trantype == 'loginout': # 用户退出登陆 resp = useract.UserLoginOut(request) else: s = public.setrespinfo({"respcode": "100000", "respmsg": "api error"}) resp = HttpResponse(s) elif request.method == "GET": s = public.setrespinfo({"respcode": "100000", "respmsg": "api error"}) resp = HttpResponse(s) return resp
def main(request): if request.method == "POST": log = public.logger #请求body转为json tmp = request.body tmp = tmp.decode(encoding='utf-8') reqest_body = json.loads(tmp) trantype = reqest_body['trantype'] log.info('trantype=[%s]' % trantype) if trantype == 'files_upload': ## 上传文件 resp = files_upload(request, reqest_body) elif trantype == 'getmenulist': ## 获取菜单列表 resp = getmenulist(request, reqest_body) elif trantype == 'getmenutable': ## 菜单配置信息 resp = getmenutable(request, reqest_body) elif trantype == 'getdegree': ## 文件处理进度 resp = getdegree(request, reqest_body) elif trantype == 'filedeal': ## 文件处理请求 resp = filedeal(request, reqest_body) else: s = public.setrespinfo({ "respcode": "100000", "respmsg": "api error" }) resp = HttpResponse(s) elif request.method == "GET": s = public.setrespinfo({"respcode": "100000", "respmsg": "api error"}) resp = HttpResponse(s) return resp
def main(request): if request.method == "POST": log = public.logger # 请求body转为json tmp = request.body tmp = tmp.decode(encoding='utf-8') reqest_body = json.loads(tmp) trantype = reqest_body['trantype'] log.info('trantype=[%s]' % trantype) if trantype == 'initsetform': # 初始化页面表单数据 resp = initsetform(request, reqest_body) elif trantype == 'creallcusform': # 市场所有客户结算报表 resp = creallcusform(request, reqest_body) elif trantype == 'creonefacform': # 采购单个客户结算报表 resp = creonefacform(request, reqest_body) elif trantype == 'creallfacform': # 采购单个客户结算报表 resp = creallfacform(request, reqest_body) else: s = public.setrespinfo({"respcode": "100000", "respmsg": "api error"}) resp = HttpResponse(s) elif request.method == "GET": s = public.setrespinfo({"respcode": "100000", "respmsg": "api error"}) resp = HttpResponse(s) return resp
def main(request): if request.method == "POST": log = public.logger #请求body转为json tmp =request.body tmp = tmp.decode(encoding='utf-8') reqest_body = json.loads(tmp) trantype = reqest_body['trantype'] log.info('trantype=[%s]' % trantype) if trantype == 'ndformView': resp = ndformView(request,reqest_body) elif trantype == 'bomView': resp = bomView(request,reqest_body) elif trantype == 'softwareView': resp = softwareView(request,reqest_body) elif trantype == 'uploadndform': resp = uploadndform(request,reqest_body) elif trantype == 'uploadbomform': resp = uploadbomform(request, reqest_body) elif trantype == 'uploadsoftwareform': resp = uploadsoftwareform(request, reqest_body) elif trantype == 'ndformdetail': resp = ndformdetail(request, reqest_body) else: s = public.setrespinfo({"respcode": "100000", "respmsg": "api error"}) resp = HttpResponse(s) elif request.method == "GET": s = public.setrespinfo({"respcode": "100000", "respmsg": "api error"}) resp = HttpResponse(s) return resp
def main(request): if request.method == "POST": log = public.logger #请求body转为json tmp=request.body tmp=tmp.decode(encoding='utf-8') reqest_body=json.loads(tmp) trantype=reqest_body['trantype'] # print('-'*20,trantype,'-'*20) log.info('trantype=[%s]' % trantype) if trantype == 'getprojectinfo': #预览-返回url打开新页面 resp = getprojectinfo(request, reqest_body) elif trantype == 'register_snid': #扫码配对工装登记扫码信息 resp = register_snid(request, reqest_body) elif trantype == 'register_snid_check': # 扫码配对工装-检查时只管登记一下 resp = register_snid_check(request, reqest_body) elif trantype == 'getprojectinfo': #提交-发交易到后台 resp = getprojectinfo(request, reqest_body) elif trantype=='boxing': resp=boxing(request,reqest_body)#装箱 elif trantype=='get_gwid': resp=get_gwid(request,reqest_body)#获取国网id elif trantype=='getBoxInfo': resp=getBoxInfo(request,reqest_body) elif trantype=='stand_alone_login': resp=stand_alone_login(request,reqest_body) else: s = public.setrespinfo({"respcode": "100000", "respmsg": "api error"}) resp = HttpResponse(s) elif request.method == "GET": s = public.setrespinfo({"respcode": "100000", "respmsg": "api error"}) resp = HttpResponse(s) return resp
def register_snid_check(request, reqest_body): log = public.logger log.info('----------------------Lqkjsmpd-register_snid_check-begin---------------------------') orderid=reqest_body.get('order_id',None) winid = reqest_body.get('win_id', None) modelid = reqest_body.get('model_id', None) pcbsn = reqest_body.get('pcb_sn', None) gwid = reqest_body.get('gw_id', None) try: int_sn=int(pcbsn[2:]) except Exception: s = public.setrespinfo({"respcode": "500100", "respmsg": "SN码未写入芯片,请再次产测!"}) return HttpResponse(s) if int_sn==0: s = public.setrespinfo({"respcode": "500100", "respmsg": "SN码未写入芯片,请再次产测!"}) return HttpResponse(s) cur = connection.cursor() #创建游标 # 获取线别信息 select_sql = "select prod_line,station_type,station_num from yw_project_prodline_term where Platform_win_num='%s'" % str(winid) cur.execute(select_sql) row = cur.fetchone() if row: prod_line = row[0] station_type = row[1] station_num = row[2] else: s = public.setrespinfo({"respcode": "500512", "respmsg": "未认证的终端,请联系工程人员!"+str(winid)}) return HttpResponse(s) if not prod_line or not station_type or not station_num: s = public.setrespinfo({"respcode": "500513", "respmsg": "终端参数配置有误,请联系工程人员!"+str(winid)}) return HttpResponse(s) #登记历史检查表数据 insertsql = "insert into yw_project_snid_detail_check(tran_date,order_id,plan_id,spc_name,pcb_sn,model_id,gw_id,win_id,state, prod_line) " \ "VALUES(%s,%s,%s,%s,%s,%s,%s,%s,%s)" % (datetime.datetime.now(), orderid, '', '', pcbsn, modelid, gwid, winid, "1", prod_line) # log.info(insertsql) cur.execute(insertsql) cur.close() #返回成功数据 jsondata = { "respcode": "000000", "respmsg": "交易成功", "trantype": reqest_body.get('trantype', None), } s = json.dumps(jsondata, cls=models.JsonCustomEncoder, ensure_ascii=False) log.info('----------------------Lqkjsmpd-register_snid_check-end---------------------------') return HttpResponse(s)
def main(request): log = public.logger log.info( '----------------------lqkjmes_showdata_begin---------------------------' ) if request.method == "POST": #POST请求 #请求body转为json tmp = request.body tmp = tmp.decode(encoding='utf-8') reqest_body = json.loads(tmp) trantype = reqest_body['trantype'] # print('-' * 20, trantype, '-' * 20) log.info('trantype=[%s]' % trantype) # if trantype == 'getprojinfo': #获取项目信息 # resp = getprojinfo(request, reqest_body) if trantype == 'getcollectinfo': #获取汇总信息 resp = getcollectinfo(request, reqest_body) elif trantype == 'getwarninfo': #获取预警信息 resp = getwarninfo(request, reqest_body) elif trantype == 'getmaterialinfo': #获取制令单领料情况 resp = getmaterialinfo(request, reqest_body) elif trantype == 'gethourinfo': #获取每小时生产情况 resp = gethourinfo(request, reqest_body) elif trantype == 'getprocinfo': # 获取制程生产信息 resp = getprocinfo(request, reqest_body) # elif trantype == 'getprojlist': # 获取项目信息列表--MESNEW使用 # resp = getprojlist(request, reqest_body) elif trantype == 'getstationinfo': # 获取各工站生产信息 resp = getstationinfo(request, reqest_body) elif trantype == 'getprojectlist': # 根据日期段获取项目信息列表 resp = getprojectlist(request, reqest_body) elif trantype == 'getproform': # 根据日期段获取项目信息列表 resp = getproform(request, reqest_body) else: s = public.setrespinfo({ "respcode": "100000", "respmsg": "api error" }) resp = HttpResponse(s) elif request.method == "GET": #GET请求 s = public.setrespinfo({"respcode": "100000", "respmsg": "api error"}) resp = HttpResponse(s) log.info( '----------------------lqkjmes_showdata_end---------------------------' ) return resp
def files_upload(request, reqest_body): log = public.logger log.info( '----------------------Admin-files_upload-begin---------------------------' ) filename = reqest_body.get('filename', None) if filename == None or len(filename) < 2: s = public.setrespinfo({"respcode": "323311", "respmsg": "上送文件名错误"}) return s uid = reqest_body.get('uid', None) file = reqest_body.get('file', None) if file == None: s = public.setrespinfo({"respcode": "323312", "respmsg": "上送文件内容错误"}) return s filename_ext = filename.split('.')[1] #生成md5值的文件名 m2 = hashlib.md5() m2.update(file.encode('raw_unicode_escape')) md5_filename = m2.hexdigest() + '.' + filename_ext # 保存文件到本地文件上传目录 filepath = public.localhome + 'fileup/' file_name = open(filepath + md5_filename, 'wb') mylen = len(reqest_body['file']) log.info('mylen=' + str(mylen)) file_name.write( file.encode('raw_unicode_escape')) #前端在json报文中,把二进制当字符串上送了,可以这样转换 file_name.close() #插入数据库 cur = connection.cursor() sql = "insert into yw_workflow_file(flow_id,file_name,md5_name,state,tran_date,user_id) value(%s,%s,%s,%s,%s,%s)" res = cur.execute( sql, (1, filename, md5_filename, '1', datetime.datetime.now(), uid)) fileid = cur.lastrowid cur.close() data = { "respcode": "000000", "respmsg": "上传成功", "trantype": reqest_body.get('trantype', None), "fileid": str(fileid), 'filename': filename } s = json.dumps(data, cls=models.JsonCustomEncoder, ensure_ascii=False) log.info( '----------------------Admin-files_upload-end---------------------------' ) return HttpResponse(s)
def main(request): log = public.logger log.info( '----------------------admin_lqkjerp_begin---------------------------') if request.method == "POST": #POST请求 #请求body转为json tmp = request.body tmp = tmp.decode(encoding='utf-8') reqest_body = json.loads(tmp) trantype = reqest_body['trantype'] log.info('trantype=[%s]' % trantype) if trantype == 'get_productlist': #获取BOM产品信息列表 resp = get_productlist(request, reqest_body) elif trantype == 'get_CriticalCompModel': # 获取关键元器件清单列表 resp = get_CriticalCompModel(request, reqest_body) elif trantype == 'get_CriticalCompList': #获取关键元器件清单列表 resp = get_CriticalCompList(request, reqest_body) elif trantype == 'CriticalCompList_print': #关键元器件清单打印或导出 resp = CriticalCompList_print(request, reqest_body) elif trantype == 'CriticalCompList_add': # 关键元器件清单模板新增 resp = CriticalCompList_add(request, reqest_body) elif trantype == 'CriticalCompList_templist': #获取关键元器件清单模板列表 resp = CriticalCompList_templist(request, reqest_body) elif trantype == 'CriticalCompList_search': #关键元器件清单查询 resp = CriticalCompList_search(request, reqest_body) elif trantype == 'CriticalCompList_toword': #关键元器件清单导出word resp = CriticalCompList_toword(request, reqest_body) elif trantype == 'get_ProduceList': # 获取投产排队信息 resp = get_ProduceList(request, reqest_body) elif trantype == 'calc_ProduceList': # 计算投产排队信息 resp = calc_ProduceList(request, reqest_body) else: s = public.setrespinfo({ "respcode": "100000", "respmsg": "api error! lqkjerp!" }) resp = HttpResponse(s) elif request.method == "GET": #GET请求 s = public.setrespinfo({"respcode": "100000", "respmsg": "api error"}) resp = HttpResponse(s) log.info( '----------------------admin_lqkjerp_end---------------------------') return resp
def PsFilesUpload(request, reqest_body): log = public.logger log.info('----------------------fileup-files_upload-begin---------------------------') filename=reqest_body.get('filename',None) if filename==None or len(filename)<2: s = public.setrespinfo({"respcode": "323311", "respmsg": "上送文件名错误"}) return s uid=reqest_body.get('uid',None) ps_id=reqest_body.get('ps_id') if ps_id==None: s = public.setrespinfo({"respcode": "323313", "respmsg": "评审单号有误"}) return s #判断评审单是否提交(查数据库) plan_id=getPlanidByPsid(ps_id) if not plan_id: s = public.setrespinfo({"respcode": "323314", "respmsg": "请先提交评审单"}) return s #开始保存文件 file = reqest_body.get('file', None) if file == None: s = public.setrespinfo({"respcode": "323312", "respmsg": "上送文件内容错误"}) return s #################开始处理################# # 保存文件到本地文件上传目录 root = '/home/admin/lqkj_admin/SVN/项目外来文件' year, month = getPsYearMonth(ps_id) filepath = '%s/%s年订单目录/%s月订单详情/%s/未审核/' % (root, year, month, ps_id) if not os.path.exists(filepath): # 如果路径不存在 os.makedirs(filepath) file_name = open(filepath + filename, 'wb') # 有重名的会覆盖 file_name.write(file.encode('raw_unicode_escape')) # 前端在json报文中,把二进制当字符串上送了,可以这样转换 file_name.close() #如果有计划号,移动文件到计划号文件夹 if plan_id[0:2] != 'JH': plan_id = None if plan_id: movePs2Plan(log,plan_id,ps_id) data = { "respcode": "000000", "respmsg": "上传成功", "trantype": reqest_body.get('trantype', None), 'filename':filename } s = json.dumps(data, cls=models.JsonCustomEncoder, ensure_ascii=False) log.info('----------------------fileup-files_upload-end---------------------------') return HttpResponse(s)
def DelMenu(request): log=public.logger log.info('----------------------Admin-CrudCfg_AddMenu-begin---------------------------') # 请求body转为json tmp = request.body tmp = tmp.decode(encoding='utf-8') reqest_body = json.loads(tmp) log.info(reqest_body) MenuReg = reqest_body['menuinfo'] #print(MenuReg) #检查上送数据是否正确 menuid = MenuReg.get('MENU_ID', None) if menuid==None: s = public.setrespinfo({"respcode": "300001", "respmsg": "菜单编号必输!"}) return HttpResponse(s) try: MyMenuTable = models.IrsadminMenu.objects.get(menu_id=menuid) except models.IrsadminMenu.DoesNotExist: MyMenuTable = None s = public.setrespinfo({"respcode": "300002", "respmsg": "菜单编号不存在!"}) return HttpResponse(s) if MyMenuTable.system_id =='sys' or MyMenuTable.system_id =='SYS': s = public.setrespinfo({"respcode": "300012", "respmsg": "系统菜单不能直接删除!"}) return HttpResponse(s) try: MenuTable=models.IrsadminMenu.objects.get(above_menu_id=menuid) except models.IrsadminMenu.DoesNotExist: MenuTable = None if MenuTable: s = public.setrespinfo({"respcode": "100009", "respmsg": "存在下级菜单,不可删除!"}) return HttpResponse(s) #使用models插入数据库,增删改查配置注册表 menuinfo = models.IrsadminMenu( menu_id=menuid ) menuinfo.delete() log.info('删除IrsadminMenu成功') resp={"respcode":"000000", "respmsg":"删除成功"} s = json.dumps(resp, cls=models.JsonCustomEncoder, ensure_ascii=False) log.info(s) log.info('----------------------Admin-CrudCfg_AddMenu-end---------------------------') return HttpResponse(s)
def GetTableList(request): log = public.logger log.info( '----------------------Admin-GetTable-begin---------------------------' ) #获取所有的表名: try: cur = connection.cursor() sql = 'select table_name,table_comment from information_schema.tables where table_schema <> "information_schema" order by table_name asc' cur.execute(sql) rows = cur.fetchall() tableinfo_json = [] for item in rows: tableitem = {} tableitem["value"] = item[0] tableitem["lable"] = item[0] + ' ' + item[1] tableinfo_json.append(tableitem) cur.close() except: log.warning("系统异常", exc_info=True) cur.close() s = public.setrespinfo({"respcode": "100002", "respmsg": "系统异常"}) return HttpResponse(s) s = json.dumps(tableinfo_json, cls=models.JsonCustomEncoder, ensure_ascii=False) log.info(s) log.info( '----------------------Admin-GetTable-end---------------------------') return HttpResponse(s)
def PsFilesGet(request, reqest_body): log = public.logger log.info('----------------------fileup-PsFilesGet-begin---------------------------') uid=reqest_body.get('uid',None) ps_id=reqest_body.get('ps_id') if ps_id==None: s = public.setrespinfo({"respcode": "323313", "respmsg": "评审单号有误"}) return s #根据评审单号获取附件存放路径 filepath=getPathByPsid(ps_id) noverify_file_list=os.listdir(filepath) verify_file_list=os.listdir(filepath.replace('/未审核','')) verify_file_list.remove('未审核') data = { "respcode": "000000", "respmsg": "上传成功", "trantype": reqest_body.get('trantype', None), 'noverify_file_list':noverify_file_list, 'verify_file_list':verify_file_list } s = json.dumps(data, cls=models.JsonCustomEncoder, ensure_ascii=False) log.info('----------------------fileup-PsFilesGet-end---------------------------') return HttpResponse(s)
def PsFilesDownload(request, reqest_body): log = public.logger log.info('----------------------Admin-PsFilesDownload-begin---------------------------') ps_id=reqest_body.get('ps_id',None) file_name=reqest_body.get('file_name',None) if not ps_id or not file_name: s = public.setrespinfo({"respcode": "323311", "respmsg": "请求参数有误"}) return s filepath=getPathByPsid(ps_id).replace('/未审核','') # filepath = '%s/%s年订单目录/%s月订单详情/%s/' % (root, year, month, ps_id) file = open(filepath+file_name, 'rb') # response = HttpResponse(file) data = { "respcode": "000000", "trantype": reqest_body.get('trantype', None), "data": base64.b64encode(file.read()).decode(), "file_name":file_name } s = json.dumps(data) # response['Content-Type'] = 'application/octet-stream' # response['Content-Disposition'] = 'attachment;filename="%s"'%filename return HttpResponse(s)
def imageupload(request, reqest_body): log = public.logger log.info( '----------------------Admin-imageupload-begin---------------------------' ) filename = reqest_body.get('filename', None) if filename == None or len(filename) < 2: s = public.setrespinfo({"respcode": "323311", "respmsg": "上送文件名错误"}) return s file = reqest_body.get('file', None) if file == None: s = public.setrespinfo({"respcode": "323312", "respmsg": "上送文件内容错误"}) return s filename_ext = filename.split('.')[1] #生成md5值的文件名 m2 = hashlib.md5() m2.update(file.encode('raw_unicode_escape')) filename = m2.hexdigest() + '.' + filename_ext # 保存文件到本地文件上传目录 filepath = public.localhome + 'static/images/detl/' file_name = open(filepath + filename, 'wb') mylen = len(reqest_body['file']) log.info('mylen=' + str(mylen)) file_name.write( file.encode('raw_unicode_escape')) #前端在json报文中,把二进制当字符串上送了,可以这样转换 file_name.close() data = { "respcode": "000000", "respmsg": "图片上传成功", "trantype": reqest_body.get('trantype', None), "url": request.META['HTTP_ORIGIN'] + '/' + 'static/images/detl/' + filename, } s = json.dumps(data, cls=models.JsonCustomEncoder, ensure_ascii=False) log.info( '----------------------Admin-imageupload-end---------------------------' ) return HttpResponse(s)
def CriticalCompList_add(request, reqest_body): log = public.logger log.info( '----------------------lqkjerp_CriticalCompList_add_begin---------------------------' ) bom_no = reqest_body.get('bom_no', None) if bom_no == None: s = public.setrespinfo({"respcode": "600101", "respmsg": "bom号异常!"}) return HttpResponse(s) cur = connection.cursor() # 创建游标 # 登记打印head表 sql = "insert into yw_lqerp_bom_criticalcomplist_head(model_type,model_name,bom_no,bom_name,bom_spc,use_zone,writer) " \ "values('%s','%s','%s','%s','%s','%s','%s')" % \ (reqest_body.get('model_type',None), reqest_body.get('model_typename',None),reqest_body.get('bom_no',None), reqest_body.get('bom_name',None), reqest_body.get('bom_spc',None), reqest_body.get('use_zone', None), reqest_body.get('writer', None)) log.info("登记打印head表:" + sql) cur.execute(sql) # 获取head表的登记id sql = "select id from yw_lqerp_bom_criticalcomplist_head where bom_no='%s' and model_type='%s' and (plan_no is NULL or plan_no='')" \ % ( reqest_body.get('bom_no',None), reqest_body.get('model_type',None) ) log.info("获取head表的登记id:" + sql) cur.execute(sql) row = cur.fetchone() headid = row[0] log.info("headid=" + str(headid)) #登记打印明细表 CriticalCompList = reqest_body.get('CriticalCompList', None) for item in CriticalCompList: sql = "insert into yw_lqerp_bom_criticalcomplist_body(head_id,seq_no,prd_no,prd_name,prd_made,prd_type,prd_spc,prd_nature) " \ "values('%s','%s','%s','%s','%s','%s','%s','%s')" % (headid, item.get('seq_no',None),item.get('prd_no',None), item.get('prd_name',None),item.get('prd_made',None), item.get('prd_type', None), item.get('prd_spc', None), item.get('prd_nature', None) ) log.info("登记打印明细表:" + sql) cur.execute(sql) # 返回信息赋值 jsondata = { "respcode": "000000", "respmsg": "交易成功", "trantype": reqest_body.get('trantype', None), } s = json.dumps(jsondata, cls=models.JsonCustomEncoder, ensure_ascii=False) log.info(s) log.info( '----------------------lqkjerp_CriticalCompList_add_begin---------------------------' ) return HttpResponse(s)
def AdminLogin(request): try: starttime=datetime.datetime.now() global log log, fh=public.loger_init('Admin') #print('public.logger.handlers',public.logger.handlers) log.info('----------------------Admin-begin---------------------------') log.info("请求:[%s]" % request) log.info("请求path:[%s]" % request.path) log.info("请求method:[%s]" % request.method) log.info("请求GET:[%s]" % request.GET) log.info("请求body:[%s]" % request.body) log.info("请求POST:[%s]" % request.POST) respinfo=None respinfo=useract.UserLogin_Qrcode(request) #用户扫码登陆处理主流程 except Exception as e : log.warning('程序运行错误', exc_info = True) s = public.setrespinfo({"respcode": "999999", "respmsg": "系统错误:"+str(e)}) respinfo=HttpResponse(s) log.info(respinfo.getvalue().decode(encoding='utf-8')) log.info('----------------------Admin-end---------------------------') if fh: fh.close() log.removeHandler(fh) return respinfo finally: if not respinfo: #如果返回信息为空 s = public.setrespinfo({"respcode": "999999", "respmsg": "系统错误"}) respinfo=HttpResponse(s) try: log.info(respinfo) log.info(respinfo.getvalue().decode(encoding='utf-8')) except: pass log.info('----------------------Admin-end---------------------------') print('处理时间:', datetime.datetime.now()-starttime) if fh: fh.close() log.removeHandler(fh) return respinfo
def admin_crudcfg(request): if request.method == "POST": #请求body转为json tmp=request.body tmp=tmp.decode(encoding='utf-8') reqest_body=json.loads(tmp) trantype=reqest_body['trantype'] # print('-'*20,trantype,'-'*20) log.info('trantype=[%s]' % trantype) if trantype == 'gettablename': #获取数据库表名列表 resp = crudcfg.GetTableList(request) elif trantype == 'gettablefield': #获取表字段信息 resp = crudcfg.GetTableInfo(request) elif trantype == 'addcrud': #新增增删改查配置 resp = crudcfg.AddCrud(request) elif trantype == 'addmenu': #新增菜单 resp = menucfg.AddMenu(request) elif trantype == 'updmenu': #更新菜单 resp = menucfg.UpdMenu(request) elif trantype == 'delmenu': #删除菜单 resp = menucfg.DelMenu(request) elif trantype == 'getmenulist': #获取菜单列表,用户登陆成功后获取所拥有权限的菜单 resp = menucfg.GetMenuList(request) elif trantype == 'getmenucfg': #获取菜单配置列表--所有菜单信息 resp = menucfg.GetMenuCfg(request) elif trantype == 'getmenuinfo': #获取菜单配置详细 resp = menucfg.GetMenuInfo(request) elif trantype == 'getuserrole': #获取用户角色 resp = userrole.GetUserRole(request) elif trantype == 'getrolepurv': #获取角色权限 resp = userrole.GetRolePurv(request) else: s = public.setrespinfo({"respcode": "100000", "respmsg": "api error"}) resp = HttpResponse(s) elif request.method == "GET": s = public.setrespinfo({"respcode": "100000", "respmsg": "api error"}) resp = HttpResponse(s) return resp
def uploadndform(reqest,reqest_body): log = public.logger log.info('----------------------lqkjbill-uploadndform-begin---------------------------') print('123') print(reqest_body.get('trantype', None)) user_id = reqest_body.get('uid', None) ndformdata = reqest_body.get('ndformdata',None) print('ndformdata=',ndformdata) head_data, body_data = ndform_analysis(ndformdata) # 数据提交到数据库 head_insert_sql = review_form_head_sql() body_insert_sql = review_form_body_sql() print('head_insert_sql=%s'%head_insert_sql) print('body_insert_sql=%s'%body_insert_sql) print(body_data[0],len(body_data[0])) print('slq_body=',body_insert_sql%body_data[0]) none_count = 0 for i in range(1,len(head_data)-1): if head_data[i]=='': none_count +=1 if none_count != 0: s = public.setrespinfo({"respcode": "900001", "respmsg": "数据未填写完整!"}) return HttpResponse(s) else: cur = connection.cursor() # 创建游标 cur.execute(head_insert_sql,head_data) log.info(head_insert_sql % head_data) cur.close() cur = connection.cursor() # 创建游标 for item in body_data: cur.execute(body_insert_sql,item) log.info(body_insert_sql % item) cur.close() # 返回成功数据 jsondata = { "respcode": "000000", "respmsg": "交易成功", "trantype": reqest_body.get('trantype', None), } s = json.dumps(jsondata, cls=models.JsonCustomEncoder, ensure_ascii=False) log.info(s) log.info('----------------------lqkjbill-uploadndform--end---------------------------') return HttpResponse(s)
def GetUserInfo(request): log = public.logger log.info( '----------------------Admin-GetUserInfo-begin---------------------------' ) tmp = request.body tmp = tmp.decode(encoding='utf-8') reqest_body = json.loads(tmp) qttime = reqest_body.get('time', None) qtip = request.META['REMOTE_ADDR'] userid = request.session.get('user_id', None) time_now = datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S') # 查找管理台用户信息表权限 cur = connection.cursor() sql = "select user_name,uid,head_imgurl,status from irsadmin_user where user_id='%s'" % ( userid) cur.execute(sql) row = cur.fetchone() if row: username = row[0] uid = row[1] headimgurl = row[2] else: log.info("查询用户信息:" + sql) s = public.setrespinfo({"respcode": "220125", "respmsg": "查询用户信息失败!"}) return HttpResponse(s) # if uid==None or len(uid)==0: # uid=userid if headimgurl == None or len(headimgurl) < 5: headimgurl = request.META[ 'HTTP_ORIGIN'] + '/' + 'static/images/headdefimg.gif' # 默认头像 info_json = { "respcode": "000000", "respmsg": "登陆成功", "trantype": reqest_body.get('trantype', None), "logintype": request.session.get('logintype', 'password'), # password-密码, qrcode-二维码,msgcode-短信 "userid": userid, "username": username, "headimgurl": headimgurl, } s = json.dumps(info_json, cls=models.JsonCustomEncoder, ensure_ascii=False) log.info( '----------------------Admin-GetUserInfo-end---------------------------' ) return HttpResponse(s)
def getprojectinfo(request, reqest_body): log = public.logger log.info( '----------------------Lqkjsmpd-getprojectinfo-begin---------------------------' ) jsondata = { "respcode": "000000", "respmsg": "交易成功", "trantype": reqest_body.get('trantype', None), "projectinfo": [] } cur = connection.cursor() #创建游标 #根据制令单号获取计划号 time_now = datetime.datetime.now().strftime('%Y-%m-%d') sql = "select order_id, plan_id from yw_project_plan_info where DATE_FORMAT(begin_date,'%%Y-%%m-%%d') <='%s'" \ " and DATE_FORMAT(end_date,'%%Y-%%m-%%d') >='%s'" % ( time_now, time_now ) log.info("查询今日计划和昨日生产量:" + sql) cur.execute(sql) rows = cur.fetchall() if len(rows) == 0: cur.close() s = public.setrespinfo({"respcode": "500498", "respmsg": "无当日生产计划!"}) return HttpResponse(s) for item in rows: log.info(str(item)) projinfo = {} orderid = item[0] planid = item[1] projinfo["order_id"] = orderid #根据计划号获取生产信息 sql = "select order_id,spc_name,begin_id,end_id from yw_project_info where plan_id='%s' " % planid log.info(sql) cur.execute(sql) row = cur.fetchone() if row: projinfo["plan_id"] = planid projinfo["order_msg"] = row[1] projinfo["begin_id"] = row[2] projinfo["end_id"] = row[3] jsondata["projectinfo"].append(projinfo) cur.close() s = json.dumps(jsondata, cls=models.JsonCustomEncoder, ensure_ascii=False) log.info(s) log.info( '----------------------Lqkjsmpd-getprojectinfo-end---------------------------' ) return HttpResponse(s)
def stand_alone_login(request, reqest_body): log = public.logger log.info('----------------------Lqkjsmpd-stand_alone_login-begin---------------------------') jsondata = { "respcode": "000000", "respmsg": "交易成功", "trantype": reqest_body.get('trantype', None), } userid = reqest_body.get('userid') password = reqest_body.get('password') if userid and password: pass else: s = public.setrespinfo({"respcode": "220025", "respmsg": "用户名或密码错误!"}) return HttpResponse(s) # 查找管理台用户信息表权限 try: AdminUser = models.IrsadminUser.objects.get(user_id=userid, passwd=password) except models.IrsadminUser.DoesNotExist: # 找不到时,有可能使用手机号登陆的 try: AdminUser = models.IrsadminUser.objects.get(tel=userid, passwd=password) except models.IrsadminUser.DoesNotExist: s = public.setrespinfo({"respcode": "220025", "respmsg": "用户名或密码错误!"}) return HttpResponse(s) jsondata['uid'] = AdminUser.user_id s = json.dumps(jsondata, cls=models.JsonCustomEncoder, ensure_ascii=False) log.info('----------------------Lqkjsmpd-stand_alone_login-end---------------------------') return HttpResponse(s)
def files_download(request, reqest_body): log = public.logger log.info( '----------------------Admin-files_upload-begin---------------------------' ) fileid = reqest_body.get('fileid', None) if fileid == None: s = public.setrespinfo({"respcode": "323311", "respmsg": "资源id有误"}) return s cur = connection.cursor() sql = "select * from yw_workflow_file where id=%s" cur.execute(sql, fileid) rows = cur.fetchone() if not rows: s = public.setrespinfo({"respcode": "323311", "respmsg": "资源id有误"}) return s print('rows=', rows) filename = rows[2] md5_filename = rows[3] cur.close() # 本地文件上传目录 filepath = public.localhome + 'fileup/' file = open(filepath + md5_filename, 'rb') # response = HttpResponse(file) data = { "respcode": "000000", "trantype": reqest_body.get('trantype', None), "data": base64.b64encode(file.read()).decode(), "filename": filename } s = json.dumps(data) # response['Content-Type'] = 'application/octet-stream' # response['Content-Disposition'] = 'attachment;filename="%s"'%filename return HttpResponse(s)
def files_upload(request, reqest_body): log = public.logger log.info( '----------------------fileup-files_upload-begin---------------------------' ) filename = reqest_body.get('filename', None) if filename == None or len(filename) < 2: s = public.setrespinfo({"respcode": "323311", "respmsg": "上送文件名错误"}) return s uid = reqest_body.get('uid', None) file = reqest_body.get('file', None) if file == None: s = public.setrespinfo({"respcode": "323312", "respmsg": "上送文件内容错误"}) return s # 保存文件到本地文件上传目录 filepath = public.localhome + 'fileup/' file_name = open(filepath + filename, 'wb') #有重名的会覆盖 # mylen = len(reqest_body['file']) # log.info('mylen=' + str(mylen)) file_name.write( file.encode('raw_unicode_escape')) #前端在json报文中,把二进制当字符串上送了,可以这样转换 file_name.close() data = { "respcode": "000000", "respmsg": "上传成功", "trantype": reqest_body.get('trantype', None), 'filename': filename } s = json.dumps(data, cls=models.JsonCustomEncoder, ensure_ascii=False) log.info( '----------------------fileup-files_upload-end---------------------------' ) return HttpResponse(s)
def main(request): if request.method == "POST": log = public.logger #请求body转为json tmp=request.body tmp=tmp.decode(encoding='utf-8') reqest_body=json.loads(tmp) trantype=reqest_body['trantype'] log.info('trantype=[%s]' % trantype) if trantype == 'approval': #我的审批 resp = approval(request, reqest_body) elif trantype == 'getApproval': #获取审批信息 resp = getApproval(request, reqest_body) elif trantype == 'getFlowDetail': #获取流转记录 resp = getFlowDetail(request, reqest_body) elif trantype == 'getApplyInfo': #获取申请信息 resp = getApplyInfo(request, reqest_body) elif trantype == 'createApplyInfo': #发起申请信息 resp = createApplyInfo(request, reqest_body) elif trantype == 'getApplyPeopleList': #获取处理人列表 resp = getApplyPeopleList(request, reqest_body) elif trantype == 'PsFilesUpload': resp = PsFilesUpload(request, reqest_body) elif trantype == 'PsFilesGet': resp = PsFilesGet(request, reqest_body) elif trantype == 'PsFilesDownload': resp = PsFilesDownload(request, reqest_body) else: s = public.setrespinfo({"respcode": "100000", "respmsg": "api error"}) resp = HttpResponse(s) elif request.method == "GET": s = public.setrespinfo({"respcode": "100000", "respmsg": "api error"}) resp = HttpResponse(s) return resp
def getBoxInfo(request, reqest_body): log = public.logger log.info('----------------------Lqkjsmpd-getBoxInfo-begin---------------------------') jsondata = { "respcode": "000000", "respmsg": "交易成功", "trantype": reqest_body.get('trantype', None), } order_id = reqest_body.get('order_id') plan_id = reqest_body.get('plan_id') box_id=reqest_body.get('box_id') if order_id and plan_id and box_id: pass else: s = public.setrespinfo({"respcode": "500510", "respmsg": "缺少参数"}) return HttpResponse(s) cur = connection.cursor() # 创建游标 sql = "select model_id,box_code,state from yw_project_boxing_info where box_id='%s' and order_id='%s' and plan_id='%s'" % (box_id, order_id, plan_id) log.info(sql) cur.execute(sql) rows = cur.fetchall() all_count=len(rows) now_count=0 model_list=[] box_code='' if all_count>0: box_code=rows[0][1] for row in rows: if row[2]=='1': now_count+=1 model_list.append(row[0]) jsondata['detail']={ "all_count":all_count, "now_count":now_count, "box_code":box_code, "model_list":model_list } s = json.dumps(jsondata, cls=models.JsonCustomEncoder, ensure_ascii=False) log.info('----------------------Lqkjsmpd-getBoxInfo-end---------------------------') return HttpResponse(s)
def uploadsoftwareform(reqest,reqest_body): log = public.logger log.info('----------------------lqkjbill-uploadsoftwareform-begin---------------------------') print('123') print(reqest_body.get('trantype', None)) user_id = reqest_body.get('uid', None) softwareformdata = reqest_body.get('softwareformdata',None) print('softwareformdata=',softwareformdata) softwaredata = softwareform_analysis(softwareformdata) # 提交数据到数据库 software_sql = software_version_confirm_sql() none_count = 0 for i in range(1, len(softwaredata) - 1): if softwaredata[i] == '': none_count += 1 print('none_count=', none_count) if none_count != 0: s = public.setrespinfo({"respcode": "900001", "respmsg": "数据未填写完整!"}) return HttpResponse(s) else: print(softwaredata) print(len(softwaredata)) print(software_sql % softwaredata) cur = connection.cursor() # 创建游标 cur.execute(software_sql, softwaredata) log.info(software_sql % softwaredata) cur.close() # 返回成功数据 jsondata = { "respcode": "000000", "respmsg": "交易成功", "trantype": reqest_body.get('trantype', None), } s = json.dumps(jsondata, cls=models.JsonCustomEncoder, ensure_ascii=False) log.info(s) log.info('----------------------lqkjbill-uploadsoftwareform--end---------------------------') return HttpResponse(s)
def getmenutable(request, reqest_body): log = public.logger log.info( '----------------------fileup-getmenutable-begin---------------------------' ) jsondata = { "respcode": "000000", "respmsg": "交易成功", "trantype": reqest_body.get('trantype', None), } checkmenu = reqest_body.get('menuidlist', None) checkmenuid = checkmenu[-1] appid_sql = "SELECT APP_ID FROM irsadmin_menu where MENU_ID=%s" field_sql = "SELECT FIELD_ID,FIELD_NAME FROM irsadmin_db_tran_list " \ "WHERE APP_ID = %s AND STATE='Y' ORDER BY ORDER_ID" cur = connection.cursor() cur.execute(appid_sql, checkmenuid) appid = cur.fetchone()[0] menuHead = [] menuData = [] tmpdict2 = {} if appid: cur.execute(field_sql, appid) row = cur.fetchall() print('row=', row) for item in row: tmpdict1 = {"name": item[0], "label": item[1], "width": 150} tmpdict2[item[0]] = '' menuHead.append(tmpdict1) menuData.append(tmpdict2) else: s = public.setrespinfo({"respcode": "210001", "respmsg": "该菜单配置信息不全!"}) return HttpResponse(s) jsondata["menuHead"] = menuHead jsondata["menuData"] = menuData s = json.dumps(jsondata, cls=models.JsonCustomEncoder, ensure_ascii=False) log.info(s) log.info( '----------------------fileup-getmenutable-end---------------------------' ) return HttpResponse(s)