From 2a8d774975b47d8b47bfdee721c5d47b919ba786 Mon Sep 17 00:00:00 2001 From: jiang Date: Thu, 7 Aug 2025 09:07:50 +0800 Subject: [PATCH] =?UTF-8?q?=E9=A6=96=E6=AC=A1=E6=8F=90=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .idea/jijv.iml | 2 +- .idea/misc.xml | 2 +- 安全/ma_machine.py | 16 ++-- 安全/ma_type.py | 3 +- 安全/结算.py | 10 +-- 安全/维修.py | 45 ++++++----- 安全/退料.py | 14 ++-- 安全/领料.py | 195 ++++++++++++++++++++++++++++++++++++++++++--- 机具/ma_machine.py | 4 +- 机具/修试入库.py | 190 +++++++++++++++++++++++++++++++++++++++++++ 机具/新购机具.py | 2 +- 机具/新购配件.py | 2 +- 机具/标准箱.py | 2 +- 机具/维修.py | 2 +- 机具/退料.py | 2 +- 机具/领料.py | 2 +- 16 files changed, 431 insertions(+), 62 deletions(-) create mode 100644 机具/修试入库.py diff --git a/.idea/jijv.iml b/.idea/jijv.iml index 9199d9d..bb081cd 100644 --- a/.idea/jijv.iml +++ b/.idea/jijv.iml @@ -2,7 +2,7 @@ - + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml index 97fc4e8..99e1df4 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -3,5 +3,5 @@ - + \ No newline at end of file diff --git a/安全/ma_machine.py b/安全/ma_machine.py index 65abff6..303c813 100644 --- a/安全/ma_machine.py +++ b/安全/ma_machine.py @@ -33,14 +33,14 @@ target_engine = create_engine( # 定义状态映射 status_mapping = { - 16: 0, # 待入库 → 0 - 17: 1, # 在库 → 1 - 18: 2, # 在用 → 2 - 19: 3, # 退料检修 → 3 - 23: 7, # 待报废 → 7 - 24: 8, # 已报废 → 8 - 64: 18, # 丢失 → 18 - 133: 4 # 待审批 → 4 + '16': 0, # 待入库 → 0 + '17': 1, # 在库 → 1 + '18': 2, # 在用 → 2 + '19': 3, # 退料检修 → 3 + '23': 7, # 待报废 → 7 + '24': 8, # 已报废 → 8 + '64': 18, # 丢失 → 18 + '133': 4 # 待审批 → 4 } diff --git a/安全/ma_type.py b/安全/ma_type.py index 9d73b3e..94c43db 100644 --- a/安全/ma_type.py +++ b/安全/ma_type.py @@ -86,8 +86,7 @@ def process_machine_types(): result = pd.concat([result, new_df], ignore_index=True) # 先清理目标表 - if not clean_existing_data(): - return False + # 写入目标表(使用更新模式) result.to_sql('ma_type', target_engine, diff --git a/安全/结算.py b/安全/结算.py index e69bfa4..be7c849 100644 --- a/安全/结算.py +++ b/安全/结算.py @@ -118,19 +118,19 @@ def process_slt_agreement(): if row['type'] == 6: # 施工队 if row['TEAM_ID'] > 0: - unit_id = row['TEAM_ID'] + 5000 + unit_id = row['TEAM_ID'] type_code = 'sgd' elif row['type'] == 7: # 项目部 if row['DEPT_ID'] > 0: - unit_id = row['DEPT_ID'] + 4000 + unit_id = row['DEPT_ID'] type_code = 'xmb' elif row['type'] == 122: # 分包商 if row['SUB_ID'] > 0: - unit_id = row['SUB_ID'] + 6000 + unit_id = row['SUB_ID'] type_code = 'fbs' elif row['type'] == 126: # 后勤 if row['REAR_ID'] > 0: - unit_id = row['REAR_ID'] + 6000 + unit_id = row['REAR_ID'] type_code = 'hq' # 检查必要参数是否有效 @@ -139,7 +139,7 @@ def process_slt_agreement(): continue # 查询agreement_id - agreement_id = get_agreement_id(unit_id, row['PROJECT_ID'] + 3000, type_code) + agreement_id = get_agreement_id(unit_id, row['PROJECT_ID'], type_code) if agreement_id is None: skipped_records += 1 continue diff --git a/安全/维修.py b/安全/维修.py index 0cbca44..170a8f4 100644 --- a/安全/维修.py +++ b/安全/维修.py @@ -42,25 +42,20 @@ type_mapping = { def get_agreement_id(unit_id, project_id, type_code): - """根据组合条件查询agreement_id(使用参数化查询)""" + """根据组合条件查询agreement_id""" try: - # 修正2:添加参数有效性检查 - if pd.isna(unit_id) or pd.isna(project_id) or pd.isna(type_code): - return None - - sql = """ + sql = f""" SELECT (bpr.ID + 500000) as agreement_id FROM bm_project_relation bpr - WHERE bpr.UNIT_ID = %s - AND bpr.project_id = %s - AND bpr.type = %s + WHERE bpr.UNIT_ID = {unit_id} + AND bpr.project_id = {project_id} + AND bpr.type = '{type_code}' LIMIT 1 """ - params = (int(unit_id), int(project_id), str(type_code)) - result = pd.read_sql(sql, source_engine, params=params) + result = pd.read_sql(sql, source_engine) return result['agreement_id'].iloc[0] if not result.empty else None except Exception as e: - print(f"查询agreement_id出错: unit_id={unit_id}, project_id={project_id}, type={type_code}, 错误: {str(e)}") + print(f"查询agreement_id出错: {str(e)}") return None @@ -106,18 +101,27 @@ def process_tm_task_agreement(): be.SUB_ID, be.TEAM_ID, be.REAR_ID, - be.TYPE, + be2.TYPE, be.PROJECT_ID FROM bpm_example be + LEFT JOIN bpm_example be2 on be.PARENT_ID = be2.id WHERE be.DEFINITION_ID = 7 """ base_df = pd.read_sql(base_sql, source_engine) # 修正4:更安全的空值处理 base_df = base_df.fillna({ - 'DEPT_ID': 0, 'SUB_ID': 0, - 'TEAM_ID': 0, 'REAR_ID': 0, - 'PROJECT_ID': 0, 'TYPE': 0 + 'DEPT_ID': 0, + 'SUB_ID': 0, + 'TEAM_ID': 0, + 'REAR_ID': 0, + 'PROJECT_ID': 0 + }).astype({ + 'DEPT_ID': 'int64', + 'SUB_ID': 'int64', + 'TEAM_ID': 'int64', + 'REAR_ID': 'int64', + 'PROJECT_ID': 'int64' }) # 修正5:确保所有ID为整数 @@ -132,18 +136,17 @@ def process_tm_task_agreement(): # 确定unit_id和type_code unit_id = None type_code = None - if row['TYPE'] == 6 and row['TEAM_ID'] > 0: # 施工队 - unit_id = row['TEAM_ID'] + 5000 + unit_id = row['TEAM_ID'] type_code = 'sgd' elif row['TYPE'] == 7 and row['DEPT_ID'] > 0: # 项目部 - unit_id = row['DEPT_ID'] + 4000 + unit_id = row['DEPT_ID'] type_code = 'xmb' elif row['TYPE'] == 122 and row['SUB_ID'] > 0: # 分包商 - unit_id = row['SUB_ID'] + 6000 + unit_id = row['SUB_ID'] type_code = 'fbs' elif row['TYPE'] == 126 and row['REAR_ID'] > 0: # 后勤 - unit_id = row['REAR_ID'] + 6000 + unit_id = row['REAR_ID'] type_code = 'hq' if not unit_id or row['PROJECT_ID'] <= 0: diff --git a/安全/退料.py b/安全/退料.py index 05db356..53179b8 100644 --- a/安全/退料.py +++ b/安全/退料.py @@ -2,6 +2,7 @@ import configparser import pandas as pd from sqlalchemy import create_engine from urllib.parse import quote_plus + # 读取配置文件 config = configparser.ConfigParser() config.read('config.ini') @@ -90,7 +91,7 @@ def process_tm_task_agreement(): # 第一步查询基础数据 base_sql = """ SELECT - (be.ID + 600000) as task_id, + (be.ID + 500000) as task_id, be.DEPT_ID, be.SUB_ID, be.TEAM_ID, @@ -120,19 +121,19 @@ def process_tm_task_agreement(): if row['TYPE'] == 6: # 施工队 if row['TEAM_ID'] > 0: - unit_id = int(row['TEAM_ID']) + 5000 + unit_id = int(row['TEAM_ID']) type_code = 'sgd' elif row['TYPE'] == 7: # 项目部 if row['DEPT_ID'] > 0: - unit_id = int(row['DEPT_ID']) + 4000 + unit_id = int(row['DEPT_ID']) type_code = 'xmb' elif row['TYPE'] == 122: # 分包商 if row['SUB_ID'] > 0: - unit_id = int(row['SUB_ID']) + 6000 + unit_id = int(row['SUB_ID']) type_code = 'fbs' elif row['TYPE'] == 126: # 后勤 if row['REAR_ID'] > 0: - unit_id = int(row['REAR_ID']) + 6000 + unit_id = int(row['REAR_ID']) type_code = 'hq' # 检查必要参数是否有效 @@ -189,6 +190,7 @@ def process_back_apply_info(): try: sql = """ SELECT + (be.ID + 500000) as id, be.`CODE`, (be.ID + 500000) as task_id, be.LINK_MAN as back_person, @@ -288,4 +290,4 @@ if __name__ == "__main__": if all(results): print("所有退料相关表转换完成!") else: - print("部分转换失败,请检查错误日志") \ No newline at end of file + print("部分转换失败,请检查错误日志") diff --git a/安全/领料.py b/安全/领料.py index c7b4acb..a3f794e 100644 --- a/安全/领料.py +++ b/安全/领料.py @@ -2,6 +2,8 @@ import configparser import pandas as pd from sqlalchemy import create_engine from urllib.parse import quote_plus +from sqlalchemy.exc import SQLAlchemyError + # 读取配置文件 config = configparser.ConfigParser() config.read('config.ini') @@ -31,6 +33,178 @@ target_engine = create_engine( f"mysql+pymysql://{target_config['user']}:{quote_plus(target_config['password'])}@{target_config['host']}:{target_config['port']}/{target_config['database']}" ) +# 单位类型映射 +UNIT_TYPE_MAPPING = { + 6: 'sgd', + 7: 'xmb', + 122: 'fbs', + 126: 'hq' +} + + +def process_tm_task(): + """处理任务表数据""" + try: + # 执行转换SQL + sql = """ + SELECT + (be.ID + 500000) as task_id, + 2 as task_type, + IF(be.`STATUS` = 32, 3, 4) as task_status, + be.`CODE` as code, + pu.`NAME` as create_by, + be.CREATE_TIME as create_time + FROM + bpm_example be + LEFT JOIN sys_data_dict sdd on be.`STATUS` = sdd.ID + LEFT JOIN pm_user pu on be.CREATOR = pu.ID + WHERE + be.DEFINITION_ID = 1 + """ + df = pd.read_sql(sql, source_engine) + + # 写入目标表 + df.to_sql('tm_task', target_engine, if_exists='append', index=False) + + print(f"成功导入 {len(df)} 条任务数据到tm_task表") + return True + + except Exception as e: + print(f"处理任务数据时出错: {str(e)}") + return False + + +def process_tm_task_agreement(): + """处理任务协议关联表数据""" + try: + # 第一步:查询基础数据 + base_sql = """ + SELECT + (be.ID + 500000) as task_id, + 2 as task_type, + be.DEPT_ID, + be.SUB_ID, + be.TEAM_ID, + be.REAR_ID, + be.TYPE, + be.PROJECT_ID + FROM + bpm_example be + WHERE + be.DEFINITION_ID = 1 + """ + base_df = pd.read_sql(base_sql, source_engine) + + # 准备存储结果 + results = [] + skipped_records = 0 + # 对每条记录处理 + for _, row in base_df.iterrows(): + try: + # 确定unit_id和type_code + unit_id = None + type_code = None + + if row['TYPE'] == 6: # 施工队 + if row['TEAM_ID'] > 0: + unit_id = int(row['TEAM_ID']) + type_code = 'sgd' + elif row['TYPE'] == 7: # 项目部 + if row['DEPT_ID'] > 0: + unit_id = int(row['DEPT_ID']) + type_code = 'xmb' + elif row['TYPE'] == 122: # 分包商 + if row['SUB_ID'] > 0: + unit_id = int(row['SUB_ID']) + type_code = 'fbs' + elif row['TYPE'] == 126: # 后勤 + if row['REAR_ID'] > 0: + unit_id = int(row['REAR_ID']) + type_code = 'hq' + + # 检查必要参数是否有效 + if not unit_id or not type_code or row['PROJECT_ID'] <= 0: + skipped_records += 1 + continue + + # 使用参数化查询避免字符串拼接问题 + agreement_id = get_agreement_id(unit_id, int(row['PROJECT_ID']), type_code) + if agreement_id: + if agreement_id: + results.append({ + 'task_id': int(row['task_id']), + 'agreement_id': int(agreement_id) + }) + except Exception as e: + print(f"查询agreement_id时出错: {str(e)}") + continue + + # 转换为DataFrame并写入 + if results: + result_df = pd.DataFrame(results) + result_df.to_sql('tm_task_agreement', target_engine, if_exists='append', index=False) + print(f"成功导入 {len(result_df)} 条任务协议关联数据到tm_task_agreement表") + return True + else: + print("没有找到匹配的任务协议关联数据") + return False + + except Exception as e: + print(f"处理任务协议关联数据时出错: {str(e)}") + return False + + +def get_agreement_id(unit_id, project_id, type_code): + """根据组合条件查询agreement_id""" + try: + sql = f""" + SELECT (bpr.ID + 500000) as agreement_id + FROM bm_project_relation bpr + WHERE bpr.UNIT_ID = {unit_id} + AND bpr.project_id = {project_id} + AND bpr.type = '{type_code}' + LIMIT 1 + """ + result = pd.read_sql(sql, source_engine) + return result['agreement_id'].iloc[0] if not result.empty else None + except Exception as e: + print(f"查询agreement_id出错: {str(e)}") + return None + + +def process_lease_apply_info(): + """处理租赁申请信息表数据""" + try: + # 执行转换SQL + sql = """ + SELECT + (be.ID + 500000) as id, + be.`CODE` as code, + (be.ID + 500000) as task_id, + be.LINK_MAN as lease_person, + be.PHONE_NUMBER as phone, + pu.`NAME` as create_by, + be.CREATE_TIME as create_time, + be.DEPT_ID as unit_id, + be.PROJECT_ID as project_id + FROM + bpm_example be + LEFT JOIN pm_user pu on be.CREATOR = pu.ID + WHERE + be.DEFINITION_ID = 1 + """ + df = pd.read_sql(sql, source_engine) + + # 写入目标表 + df.to_sql('lease_apply_info', target_engine, if_exists='append', index=False) + + print(f"成功导入 {len(df)} 条租赁申请信息数据") + return True + + except Exception as e: + print(f"处理租赁申请信息时出错: {str(e)}") + return False + def process_lease_apply_details(): """处理租赁申请明细数据""" @@ -55,8 +229,7 @@ def process_lease_apply_details(): df = pd.read_sql(sql, source_engine) # 写入目标表 - df.to_sql('lease_apply_details', target_engine, - if_exists='append', index=False) + df.to_sql('lease_apply_details', target_engine, if_exists='append', index=False) print(f"成功导入 {len(df)} 条租赁申请明细数据") return True @@ -85,8 +258,7 @@ def process_lease_out_details(): df = pd.read_sql(sql, source_engine) # 写入目标表 - df.to_sql('lease_out_details', target_engine, - if_exists='append', index=False) + df.to_sql('lease_out_details', target_engine, if_exists='append', index=False) print(f"成功导入 {len(df)} 条租赁出库明细数据") return True @@ -97,11 +269,16 @@ def process_lease_out_details(): if __name__ == "__main__": - # 执行两个转换流程 - success1 = process_lease_apply_details() - success2 = process_lease_out_details() + # 执行所有转换流程 + results = [ + process_tm_task(), + process_tm_task_agreement(), + process_lease_apply_info(), + process_lease_apply_details(), + process_lease_out_details() + ] - if success1 and success2: + if all(results): print("所有数据转换完成!") else: - print("数据转换过程中出现错误,请检查日志") \ No newline at end of file + print("数据转换过程中出现错误,请检查日志") diff --git a/机具/ma_machine.py b/机具/ma_machine.py index c13b1d5..47feb77 100644 --- a/机具/ma_machine.py +++ b/机具/ma_machine.py @@ -114,9 +114,7 @@ def transform_and_load_ma_machines(config_file_path): # 写入目标表 print("\n正在写入目标表ma_machine...") # 步骤1:清空目标表 - with target_engine.connect() as conn: - conn.execute(text("TRUNCATE TABLE ma_machine")) # 注意需要从sqlalchemy导入text - conn.commit() # 显式提交事务 + # 步骤2:写入去重后的数据 target_df.drop_duplicates(['type_id', 'ma_code']).to_sql( diff --git a/机具/修试入库.py b/机具/修试入库.py new file mode 100644 index 0000000..c280990 --- /dev/null +++ b/机具/修试入库.py @@ -0,0 +1,190 @@ +import configparser +import pandas as pd +from sqlalchemy import create_engine +from urllib.parse import quote_plus +from sqlalchemy.exc import SQLAlchemyError +from datetime import datetime + +# 读取配置文件 +config = configparser.ConfigParser() +config.read('config.ini') + +# 获取数据库连接配置 +source_config = { + 'host': config.get('source_db', 'host'), + 'user': config.get('source_db', 'user'), + 'password': config.get('source_db', 'password'), + 'database': config.get('source_db', 'database'), + 'port': config.getint('source_db', 'port') +} + +target_config = { + 'host': config.get('target_db', 'host'), + 'user': config.get('target_db', 'user'), + 'password': config.get('target_db', 'password'), + 'database': config.get('target_db', 'database'), + 'port': config.getint('target_db', 'port') +} + +# 创建数据库引擎 +source_engine = create_engine( + f"mysql+pymysql://{source_config['user']}:{quote_plus(source_config['password'])}@{source_config['host']}:{source_config['port']}/{source_config['database']}" +) +target_engine = create_engine( + f"mysql+pymysql://{target_config['user']}:{quote_plus(target_config['password'])}@{target_config['host']}:{target_config['port']}/{target_config['database']}" +) + + +def migrate_repair_tasks(): + """迁移修试入库任务数据到tm_task表""" + try: + print("开始迁移修试入库任务数据...") + + # 执行转换SQL + sql = """ + SELECT + bri.ID as task_id, + 11 as task_type, + bri.`STATUS` as task_status, + bri.APPLY_NUMBER as code, + tt.CREATOR as create_by, + tt.CREATE_TIME as create_time + FROM + ba_ma_repair_input bri + LEFT JOIN tm_task tt on bri.ID = tt.ID + WHERE + tt.CREATE_TIME BETWEEN "2025-01-01" AND NOW() + """ + + # 读取数据 + df = pd.read_sql(sql, source_engine) + + if df.empty: + print("没有找到需要迁移的修试入库任务数据") + return True + + # 数据清洗和处理 + df['task_type'] = 11 # 修试入库类型 + + # 写入目标表 + df.to_sql('tm_task', target_engine, if_exists='append', index=False) + + print(f"成功导入 {len(df)} 条修试入库任务数据到tm_task表") + return True + + except Exception as e: + print(f"迁移修试入库任务数据时出错: {str(e)}") + return False + + +def migrate_repair_input_details(): + """迁移修试入库明细数据到repair_input_details表""" + try: + print("开始迁移修试入库明细数据...") + + # 执行转换SQL(包含UNION的两部分查询) + sql = """ + -- 第一部分查询(具体设备) + SELECT + bmri.ID as task_id, + bmri.AUDIT_ID as audit_id, + bmr.id as repair_id, + mm.ID as ma_id, + mm.TYPE as type_id, + 1 as repair_num, + IF(mm.BATCH_STATUS = 9, 0, 1) as input_num, + bmri.`STATUS` as status, + tt.CREATE_TIME as create_time + FROM + ba_ma_repair_input bmri + LEFT JOIN tm_task tt on tt.ID = bmri.ID + LEFT JOIN ba_ma_input_check bmic on bmic.ID = bmri.AUDIT_ID + LEFT JOIN ba_ma_repair bmr on bmic.repair_id = bmr.id + LEFT JOIN tm_task_ma ttm on bmri.ID = ttm.TASK_ID + LEFT JOIN ma_machines mm on ttm.MA_ID = mm.ID + WHERE + tt.CREATE_TIME BETWEEN "2025-01-01" AND NOW() + + UNION + + -- 第二部分查询(设备类型) + SELECT + bmri.ID as task_id, + bmri.AUDIT_ID as audit_id, + bmr.id as repair_id, + NULL AS ma_id, + ttmt.MA_TYPE_ID as type_id, + ttmt.MACHINES_NUM as repair_num, + ttmt.ACTUAL_NUM as input_num, + ttmt.IS_SURE as status, + tt.CREATE_TIME as create_time + FROM + ba_ma_repair_input bmri + LEFT JOIN tm_task tt on tt.ID = bmri.ID + LEFT JOIN tm_task_ma_type ttmt on ttmt.TASK_ID = bmri.ID + LEFT JOIN ba_ma_input_check bmic on bmic.ID = bmri.AUDIT_ID + LEFT JOIN ba_ma_repair bmr on bmic.repair_id = bmr.id + WHERE + tt.CREATE_TIME BETWEEN "2025-01-01" AND NOW() + AND ttmt.IS_COUNT = 1 + """ + + # 读取数据 + df = pd.read_sql(sql, source_engine) + + if df.empty: + print("没有找到需要迁移的修试入库明细数据") + return True + + # 数据清洗和处理 + # 确保数值字段为整数类型 + int_columns = ['task_id', 'audit_id', 'repair_id', 'ma_id', 'type_id', + 'repair_num', 'input_num', 'status'] + for col in int_columns: + if col in df.columns: + df[col] = pd.to_numeric(df[col], errors='coerce').fillna(0).astype(int) + + # 写入目标表 + df.to_sql('repair_input_details', target_engine, if_exists='append', index=False) + + print(f"成功导入 {len(df)} 条修试入库明细数据到repair_input_details表") + return True + + except Exception as e: + print(f"迁移修试入库明细数据时出错: {str(e)}") + return False + + +def main(): + """主函数,执行所有迁移任务""" + print("=" * 50) + print("开始数据迁移流程") + print(f"当前时间: {datetime.now().strftime('%Y-%m-%d %H:%M:%S')}") + print("=" * 50) + + # 执行所有迁移任务 + migration_tasks = [ + ("修试入库任务数据", migrate_repair_tasks), + ("修试入库明细数据", migrate_repair_input_details) + ] + + success = True + for task_name, task_func in migration_tasks: + print(f"\n正在处理: {task_name}...") + if not task_func(): + success = False + print(f"处理失败: {task_name}") + else: + print(f"处理成功: {task_name}") + + print("\n" + "=" * 50) + if success: + print("所有数据迁移任务完成!") + else: + print("数据迁移过程中出现错误,请检查日志") + print(f"完成时间: {datetime.now().strftime('%Y-%m-%d %H:%M:%S')}") + print("=" * 50) + + +if __name__ == "__main__": + main() \ No newline at end of file diff --git a/机具/新购机具.py b/机具/新购机具.py index 86b45e7..f73a596 100644 --- a/机具/新购机具.py +++ b/机具/新购机具.py @@ -4,7 +4,7 @@ from sqlalchemy import create_engine from urllib.parse import quote_plus # 读取配置文件 config = configparser.ConfigParser() -config.read(r'D:\code\Bonus-Transfer-Machines\machines\config.ini') +config.read(r'config.ini') # 获取数据库连接配置 source_config = { diff --git a/机具/新购配件.py b/机具/新购配件.py index eb3baea..5277128 100644 --- a/机具/新购配件.py +++ b/机具/新购配件.py @@ -4,7 +4,7 @@ from sqlalchemy import create_engine from urllib.parse import quote_plus # 读取配置文件 config = configparser.ConfigParser() -config.read(r'D:\code\Bonus-Transfer-Machines\machines\config.ini') +config.read('config.ini') # 获取数据库连接配置 source_config = { diff --git a/机具/标准箱.py b/机具/标准箱.py index 2a7bd70..2ab322d 100644 --- a/机具/标准箱.py +++ b/机具/标准箱.py @@ -4,7 +4,7 @@ from sqlalchemy import create_engine from urllib.parse import quote_plus # 读取配置文件 config = configparser.ConfigParser() -config.read(r'D:\code\Bonus-Transfer-Machines\machines\config.ini') +config.read('config.ini') # 获取数据库连接配置 source_config = { diff --git a/机具/维修.py b/机具/维修.py index 9726b38..4d97539 100644 --- a/机具/维修.py +++ b/机具/维修.py @@ -58,7 +58,7 @@ def process_tm_task(): ba_ma_repair bmr LEFT JOIN tm_task tt on bmr.ID = tt.ID LEFT JOIN tm_task_status tts on tt.`STATUS` = tts.`CODE` - WHERE bmr.company_id = 1 + WHERE bmr.company_id = 1 and tt.ID is not null """ df = pd.read_sql(sql, source_engine) diff --git a/机具/退料.py b/机具/退料.py index 17b5615..e1b0058 100644 --- a/机具/退料.py +++ b/机具/退料.py @@ -4,7 +4,7 @@ from sqlalchemy import create_engine from urllib.parse import quote_plus # 读取配置文件 config = configparser.ConfigParser() -config.read(r'D:\code\Bonus-Transfer-Machines\machines\config.ini') +config.read('config.ini') # 获取数据库连接配置 source_config = { diff --git a/机具/领料.py b/机具/领料.py index 8b8c896..c4446d4 100644 --- a/机具/领料.py +++ b/机具/领料.py @@ -4,7 +4,7 @@ from sqlalchemy import create_engine from urllib.parse import quote_plus # 读取配置文件 config = configparser.ConfigParser() -config.read(r'D:\code\Bonus-Transfer-Machines\machines\config.ini') +config.read('config.ini') # 获取数据库连接配置 source_config = {