job_res = [] for page in range(1, 21): url = job_url.format(_page=page) job_res.extend(job_request(url))

时间: 2023-04-11 18:01:29 浏览: 43
这是一个Python代码片段,其中使用了一个空列表job_res和一个for循环来遍历1到20的页数,然后使用.format()方法将页数插入到job_url中,生成每一页的URL,最后使用extend()方法将每一页的职位请求结果添加到job_res列表中。
相关问题

@app.route("/jobdata", methods=['POST']) def jobdata(): edus=db.session.query(Recruitersnumbers.job_name).filter().limit(5).all() edulist=[] for edu in edus: edulist.append(edu.job_name) recruitersnumbers = db.session.query(Recruitersnumbers.job_name,Jobsalarylevel.salary,Jobsalarylevel.count).join(Jobsalarylevel,Recruitersnumbers.job_name==Jobsalarylevel.job_name)\ .filter(or_(Recruitersnumbers.job_name==edulist[0],Recruitersnumbers.job_name==edulist[1],Recruitersnumbers.job_name==edulist[2],Recruitersnumbers.job_name==edulist[3],Recruitersnumbers.job_name==edulist[4]))\ .order_by(Jobsalarylevel.job_name,Jobsalarylevel.salary) list_ = [] for x in recruitersnumbers: data={ "job_name":x.job_name, "salary":x.salary, "count":x.count } list_.append(data) return jsonify(list_)

这是一个 Flask 路由函数,当以 POST 方法访问 "/jobdata" 路径时,会执行以下操作: 1. 查询数据库中的 "Recruitersnumbers" 表,获取前 5 条记录的 "job_name" 字段值。 2. 将查询结果存储在列表 "edulist" 中。 3. 使用 SQLAlchemy 的联接操作,查询 "Recruitersnumbers" 表和 "Jobsalarylevel" 表,并根据条件筛选出与 "edulist" 中的职位名称匹配的记录。 4. 将查询结果按照 "job_name" 和 "salary" 进行排序。 5. 遍历查询结果,将每条记录中的 "job_name"、"salary" 和 "count" 存储在字典 "data" 中,并将字典添加到列表 "list_" 中。 6. 将列表 "list_" 转换为 JSON 格式并返回。 这个路由函数的作用是返回根据职位名称和薪资等级筛选的数据结果,可以在前端进行展示或进一步处理。

select a.job_id, a.job_name, a.job_group, a.invoke_target, a.cron_expression, a.misfire_policy, a.concurrent, a.status, a.create_by, a.create_time, a.remark, a.job_des, a.cron_des, b.status as last_execute_status, b.create_time as last_execute_time from sys_job a left join sys_job_log b ON a.job_name = b.job_name and a.job_group = b.job_group where b.create_time = (select max(create_time) from sys_job_log c where a.job_name = c.job_name and a.job_group = c.job_group) or b.create_time is null 此SQl为Oracle运行环境,因为sys_job_log有create_time相同的数据导致了数据重复,如何解决

可以在子查询中增加一个条件,筛选出除了最大create_time之外的数据,即: ``` select a.job_id, a.job_name, a.job_group, a.invoke_target, a.cron_expression, a.misfire_policy, a.concurrent, a.status, a.create_by, a.create_time, a.remark, a.job_des, a.cron_des, b.status as last_execute_status, b.create_time as last_execute_time from sys_job a left join sys_job_log b ON a.job_name = b.job_name and a.job_group = b.job_group where b.create_time = (select max(c.create_time) from sys_job_log c where a.job_name = c.job_name and a.job_group = c.job_group and c.create_time < b.create_time) or b.create_time is null ``` 这样可以避免重复数据的问题。

相关推荐

以hive的角度检查语法: with cur_dim_comb as (SELECT DISTINCT t.dim_comb ,t.var_sub_class ,t.acc_value FROM gerp.cux_cst_data_alloc_his t WHERE t.top_var_type = '10' AND t.job_ver_id in (SELECT ver.job_ver_id AS p_job_ver_id FROM gerp.cux_cst_dist_jobs_all job INNER JOIN gerp.cux_cst_dist_jobs_vers_all ver ON job.job_id = ver.job_id )) select tp.bd_code --事业部编码 ,tp.bd_name --事业部名称 ,hp.ou_code --OU名称 ,hp.ou_name --OU编码 ,op.main_class_desc --差异大类 ,op.acc_value --科目代码 ,op.acc_desc --科目名称 ,op.dim_comb --区分维度 ,op.begin_amount --期初余额 ,op.accrual_amount --本期发生 ,op.balance_diff_alloc_amount --期末差异结存 ,op.var_sub_class ,op.main_class_value ,op.org_id ,op.period_name ,op.job_ver_id from (select up.* ,q1.* from (SELECT DISTINCT maincl.* ,t.* FROM t inner join (SELECT fv.flex_value ,fv.description FROM fv inner join fs on fv.flex_value_set_id = fs.flex_value_set_id AND fs.flex_value_set_name = 'CUX_CST_VARIANCE_TYPE' AND fv.enabled_flag = 'Y' AND fv.hierarchy_level = '2' AND fv.flex_value LIKE '10%' ) maincl on t.var_main_class = maincl.flex_value inner join cur_dim_comb on cur_dim_comb.var_sub_class = t.var_sub_class and cur_dim_comb.acc_value = t.acc_value WHERE 1 = 1 AND t.top_var_type = '10' AND t.job_ver_id in (SELECT ver.job_ver_id AS p_job_ver_id FROM gerp.cux_cst_dist_jobs_all job INNER JOIN gerp.cux_cst_dist_jobs_vers_all ver ON job.job_id = ver.job_id) ORDER BY maincl.description ,t.acc_value ,cur_dim_comb.dim_comb ) up inner join (SELECT t1.* ,SUM(t1.begin_amount) begin_amount ,SUM(t1.accrual_amount) accrual_amount ,SUM(t1.balance_diff_alloc_amount) balance_diff_alloc_amount FROM gerp.cux_cst_data_alloc_his t1 LEFT JOIN gerp.cux_cst_data_alloc_his t ON t1.top_var_type = '10' AND t1.var_sub_class = t.var_sub_class --p_var_sub_class AND t1.org_id = t.org_id --p_org_id AND t1.period_name = t.period_name --p_period_name AND t1.job_ver_id = t.job_ver_id --p_job_ver_id AND t1.acc_value = t.acc_value --p_acc_value WHERE t1.dim_comb in (select distinct dim_comb from cur_dim_comb) group by t1.org_id,t1.period_name,t1.job_ver_id,t1.var_sub_class,t1.acc_value ) q1 on q1.org_id = up.org_id --p_org_id AND q1.period_name = up.period_name --p_period_name AND q1.job_ver_id = up.job_ver_id --p_job_ver_id AND q1.var_sub_class = up.var_sub_class --p_var_sub_class AND q1.acc_value = up.acc_value --p_acc_value ) op

优化sql:SELECT we.organization_id ,we.wip_entity_id ,case when wl.line_id is null then we.wip_entity_name else '' end wip_entity_name ,we.primary_item_id ,mtt.transaction_type_name ,mmt.transaction_date ,bd.department_code ,mmt.inventory_item_id ,mmt.subinventory_code ,mta.reference_account ,br.resource_code ,lu2.meaning as line_type_name ,mta.base_transaction_value ,mta.cost_element_id ,flv.meaning as cost_element ,wdj.class_code job_type_code ,ml.meaning job_type_name FROM (select * from gerp.mtl_material_transactions where substr(transaction_date,1,7) >= '2023-06' and transaction_source_type_id = 5) mmt inner join gerp.wip_entities we on mmt.organization_id = we.organization_id inner join gerp.mtl_transaction_accounts mta on mta.transaction_source_id = we.wip_entity_id and mta.transaction_id = mmt.transaction_id and mta.transaction_source_type_id = 5 inner join gerp.mtl_transaction_types mtt on mtt.transaction_type_id = mmt.transaction_type_id inner join mfg_lookups lu2 on lu2.lookup_code = mta.accounting_line_type and lu2.lookup_type = 'CST_ACCOUNTING_LINE_TYPE' inner join gerp.mtl_system_items_b msi on msi.inventory_item_id = mmt.inventory_item_id and msi.organization_id = mta.organization_id left join gerp.bom_departments bd on bd.department_id = mmt.department_id left join gerp.bom_resources br on br.resource_id = mta.resource_id left join gerp.wip_lines wl on wl.line_id = mmt.repetitive_line_id left join gerp.wip_discrete_jobs wdj on wdj.wip_entity_id = mta.transaction_source_id left join gerp.fnd_lookup_values_vl flv on cast(mta.cost_element_id as string) = flv.lookup_code and flv.lookup_type = 'CST_COST_CODE_TYPE' left join mfg_lookups ml on ml.lookup_code = wdj.job_type and ml.lookup_type = 'WIP_DISCRETE_JOB' 。其中mmt,we,mta,msi,wdj数据量很大

import numpy as np from platypus import NSGAII, Problem, Real, Integer # 定义问题 class JobShopProblem(Problem): def __init__(self, jobs, machines, processing_times): num_jobs = len(jobs) num_machines = len(machines[0]) super().__init__(num_jobs, 1, 1) self.jobs = jobs self.machines = machines self.processing_times = processing_times self.types[:] = Integer(0, num_jobs - 1) self.constraints[:] = [lambda x: x[0] == 1] def evaluate(self, solution): job_order = np.argsort(np.array(solution.variables[:], dtype=int)) machine_available_time = np.zeros(len(self.machines)) job_completion_time = np.zeros(len(self.jobs)) for job_idx in job_order: job = self.jobs[job_idx] for machine_idx, processing_time in zip(job, self.processing_times[job_idx]): machine_available_time[machine_idx] = max(machine_available_time[machine_idx], job_completion_time[job_idx]) job_completion_time[job_idx] = machine_available_time[machine_idx] + processing_time solution.objectives[:] = [np.max(job_completion_time)] # 定义问题参数 jobs = [[0, 1], [2, 0], [1, 2]] machines = [[0, 1, 2], [1, 2, 0], [2, 0, 1]] processing_times = [[5, 4], [3, 5], [1, 3]] # 创建算法实例 problem = JobShopProblem(jobs, machines, processing_times) algorithm = NSGAII(problem) algorithm.population_size = 100 # 设置优化目标 problem.directions[:] = Problem.MINIMIZE # 定义算法参数 algorithm.population_size = 100 max_generations = 100 mutation_probability = 0.1 # 设置算法参数 algorithm.max_iterations = max_generations algorithm.mutation_probability = mutation_probability # 运行算法 algorithm.run(max_generations) # 输出结果 print("最小化的最大完工时间:", algorithm.result[0].objectives[0]) print("工件加工顺序和机器安排方案:", algorithm.result[0].variables[:]) 请检查上述代码

最新推荐

recommend-type

oracle数据库定时任务dbms_job的用法详解

给大家详细介绍了dbms_job的用法,用于安排和管理作业队列,通过使用作业,可以使ORACLE数据库定期执行特定的任务。有需要的朋友们可以参考借鉴。
recommend-type

pre_o_1csdn63m9a1bs0e1rr51niuu33e.a

pre_o_1csdn63m9a1bs0e1rr51niuu33e.a
recommend-type

matlab建立计算力学课程的笔记和文件.zip

matlab建立计算力学课程的笔记和文件.zip
recommend-type

FT-Prog-v3.12.38.643-FTD USB 工作模式设定及eprom读写

FT_Prog_v3.12.38.643--FTD USB 工作模式设定及eprom读写
recommend-type

matlab基于RRT和人工势场法混合算法的路径规划.zip

matlab基于RRT和人工势场法混合算法的路径规划.zip
recommend-type

zigbee-cluster-library-specification

最新的zigbee-cluster-library-specification说明文档。
recommend-type

管理建模和仿真的文件

管理Boualem Benatallah引用此版本:布阿利姆·贝纳塔拉。管理建模和仿真。约瑟夫-傅立叶大学-格勒诺布尔第一大学,1996年。法语。NNT:电话:00345357HAL ID:电话:00345357https://theses.hal.science/tel-003453572008年12月9日提交HAL是一个多学科的开放存取档案馆,用于存放和传播科学研究论文,无论它们是否被公开。论文可以来自法国或国外的教学和研究机构,也可以来自公共或私人研究中心。L’archive ouverte pluridisciplinaire
recommend-type

实现实时数据湖架构:Kafka与Hive集成

![实现实时数据湖架构:Kafka与Hive集成](https://img-blog.csdnimg.cn/img_convert/10eb2e6972b3b6086286fc64c0b3ee41.jpeg) # 1. 实时数据湖架构概述** 实时数据湖是一种现代数据管理架构,它允许企业以低延迟的方式收集、存储和处理大量数据。与传统数据仓库不同,实时数据湖不依赖于预先定义的模式,而是采用灵活的架构,可以处理各种数据类型和格式。这种架构为企业提供了以下优势: - **实时洞察:**实时数据湖允许企业访问最新的数据,从而做出更明智的决策。 - **数据民主化:**实时数据湖使各种利益相关者都可
recommend-type

2. 通过python绘制y=e-xsin(2πx)图像

可以使用matplotlib库来绘制这个函数的图像。以下是一段示例代码: ```python import numpy as np import matplotlib.pyplot as plt def func(x): return np.exp(-x) * np.sin(2 * np.pi * x) x = np.linspace(0, 5, 500) y = func(x) plt.plot(x, y) plt.xlabel('x') plt.ylabel('y') plt.title('y = e^{-x} sin(2πx)') plt.show() ``` 运行这段
recommend-type

JSBSim Reference Manual

JSBSim参考手册,其中包含JSBSim简介,JSBSim配置文件xml的编写语法,编程手册以及一些应用实例等。其中有部分内容还没有写完,估计有生之年很难看到完整版了,但是内容还是很有参考价值的。