def index_add_wos(): vm = MaintainVM() vm.plant = 'GHUO' if 'plant' in request.form: vm.plant = request.form['plant'] wos = repository.get_all_wo_status(vm.plant, host=HOST, port=PORT, db=DB) vm.wos = wos return render_template('addwos.html', vm=vm)
def maintain(): vm = MaintainVM() vm.plant = 'GHUO' if 'plant' in request.form: vm.plant = request.form['plant'] wos = repository.get_all_wo_status(vm.plant, host=HOST, port=PORT, db=DB) vm.wos = wos vm.wo_nos = sorted(wos.keys()) return render_template('maintain.html', vm=vm)
def wos_upload_redis(): order = workOrder.Workorder() i = 0 result = [] vm = MaintainVM() vm.plant = 'GHUO' if 'plant' in request.form: vm.plant = request.form['plant'] wos = repository.get_all_wo_status(vm.plant, host=HOST, port=PORT, db=DB) vm.wos = wos try: f = request.files.get('excelFile').read() data = xlrd.open_workbook(file_contents=f) table = data.sheet_by_index(i) keys = table.row_values(0) if keys: row_num = table.nrows col_num = table.ncols for i in range(1, row_num): sheet_data = {} for j in range(0, col_num): sheet_data['DESC'] = table.row_values(i)[0] sheet_data['PN'] = table.row_values(i)[1] sheet_data['WO'] = table.row_values(i)[2] sheet_data['Qty'] = table.row_values(i)[5] sheet_data['Remark'] = table.row_values(i)[6] if sheet_data not in result: result.append(sheet_data) for info in result: order._plant = vm.plant order.desc = info['DESC'] order.pn = info['PN'] if str(int(info['WO'])).startswith('6'): order.wo_no = '0000' + str(int(info['WO'])) elif str(int(info['WO'])).startswith('1') or str(int( info['WO'])).startswith('4'): order.wo_no = '000' + str(int(info['WO'])) order.qty = info['Qty'] order.remark = info['Remark'] (order.status, order.units) = sfc.get_workOrder_status_units( vm.plant, order.wo_no, sfc.url_switch(vm.plant)) # print(order._plant, order.desc, order.pn, order.wo_no, order.qty, order.remark) repository.set_wos(order, host=HOST, port=PORT, db=DB) return render_template('addwos.html', vm=vm) except Exception: return render_template('error.html')
def index(): vm = IndexVM() vm.plant = 'GHUO' if 'plant' in request.form: vm.plant = request.form['plant'] wos = repository.get_all_wo_status(vm.plant, host=HOST, port=PORT, db=DB) # vm.wos = wos # vm.wo_nos = sorted(wos.keys()) vm.wos = wos vm.wo_nos = sorted(wos.keys()) stations = set([]) for wo_no in vm.wo_nos: stations = stations.union(vm.wos[wo_no].status.keys()) # print vm.wos[wo_no].status.keys() kf = sfc.SortKeyFinder(r'.\static\station.json') vm.stations = sorted(stations, key=lambda s: kf.get_key(s)) merger = sfc.StationMerger(r'.\static\merge.json') vm.c_stations = merger.merger(vm.stations) return render_template('index.html', vm=vm)
def close_all_wos(): # 1.删除所有 if request.form.get('btnclose'): keys = request.form.getlist('hidcloseall') vm = MaintainVM() vm.plant = keys[0] if 'plant' in request.form: vm.plant = request.form['plant'] wos = repository.get_all_wo_status(vm.plant, host=HOST, port=PORT, db=DB) vm.wos = wos vm.wo_nos = sorted(wos.keys()) # ['000060030987', '000060030988'] for wo in vm.wo_nos: result = repository.del_key('%s:%s' % (vm.plant, wo), host=HOST, port=PORT, db=DB) return render_template('maintain.html', vm=vm)
def index_query(): vm = MaintainVM() vm.plant = 'GHUO' keys = [] if 'plant' in request.form: vm.plant = request.form['plant'] wos = repository.get_all_wo_status(vm.plant, host=HOST, port=PORT, db=store_DB) vm.wos = wos vm.wo_nos = sorted(wos.keys()) stations = set([]) for wo_no in vm.wo_nos: stations = stations.union(vm.wos[wo_no].status.keys()) kf = sfc.SortKeyFinder(r'.\static\station.json') vm.stations = sorted(stations, key=lambda s: kf.get_key(s)) merger = sfc.StationMerger(r'.\static\merge.json') vm.c_stations = merger.merger(vm.stations) if request.method == 'post': return render_template('query_redis.html', vm=vm, keys=keys) return render_template('query_redis.html', vm=vm, keys=keys)
def close_part_wos(): # 1.批量删除 if request.form.get('clspart'): keys = request.form.getlist('hidclosepart') vm = MaintainVM() vm.plant = keys[0] wos = repository.get_all_wo_status(vm.plant, host=HOST, port=PORT, db=DB) vm.wos = wos vm.wo_nos = sorted(wos.keys()) part_list = request.form.getlist('CheckPart') if 'plant' in request.form: vm.plant = request.form['plant'] for wo in part_list: result = repository.del_key('%s:%s' % (vm.plant, wo), host=HOST, port=PORT, db=DB) return render_template('maintain.html', vm=vm)
def get_wos_status(): i = 0 result = [] vm = MaintainVM() vm.plant = 'GHUO' if 'plant' in request.form: vm.plant = request.form['plant'] wos = repository.get_all_wo_status(vm.plant, host=HOST, port=PORT, db=DB) vm.wos = wos try: f = request.files.get('excelFile').read() data = xlrd.open_workbook(file_contents=f) table = data.sheet_by_index(i) keys = table.row_values(0) if keys: row_num = table.nrows # 行数 col_num = table.ncols # 列数 for i in range(1, row_num): sheet_data = {} for j in range(0, col_num): sheet_data['DESC'] = table.row_values(i)[0] sheet_data['PN'] = table.row_values(i)[1] # sheet_data['WO'] = table.row_values(i)[2] if str(int(table.row_values(i)[2])).startswith('6'): sheet_data['WO'] = '0000' + str( int(table.row_values(i)[2])) elif str(int(table.row_values(i)[2])).startswith('1') \ or str(int(table.row_values(i)[2])).startswith('4'): sheet_data['WO'] = '000' + str( int(table.row_values(i)[2])) sheet_data['Qty'] = table.row_values(i)[5] sheet_data['Remark'] = table.row_values(i)[6] if sheet_data not in result: result.append(sheet_data) return render_template('addwoss.html', results=result, vm=vm) except Exception: return render_template('error.html')
def update_plant(plant): wos = repository.get_all_wo_status(plant, HOST, PORT, DB) for wo in wos: (wos[wo].status, wos[wo].units) = sfc.get_workOrder_status_units(plant, wo, sfc.url_switch(plant)) repository.set_wo(wos[wo], HOST, PORT, DB)