当前位置:   article > 正文

数据库课设-中小企业工资管理系统

数据库课设-中小企业工资管理系统

一、效果展示

二、后端代码

  1. import string
  2. import random
  3. from flask import Flask, render_template, request, jsonify, redirect, session
  4. import pymysql
  5. from flask_cors import CORS
  6. import time
  7. import schedule
  8. from datetime import datetime
  9. import threading
  10. from datetime import timedelta
  11. app = Flask(__name__)
  12. # 创建一个名为app的Flask实例
  13. app.secret_key = 'man_what_can_i_say'
  14. CORS(app)
  15. # 启用CORS机制,允许跨域访问
  16. #存储每天已经打卡的用户
  17. user_attendance_day_list = []
  18. # 设置会话有效时间为30分钟
  19. app.config['PERMANENT_SESSION_LIFETIME'] = timedelta(minutes=30)
  20. # 请求钩子,在每次请求之前被调用
  21. @app.before_request
  22. def before_request():
  23. session.permanent = True
  24. app.permanent_session_lifetime = timedelta(minutes=30) # 设置每次请求后会话的有效时间为30分钟
  25. # 如果用户已经登录或会话已经存在,则更新会话的最后访问时间
  26. if 'user_id' in session:
  27. session.modified = True
  28. ##
  29. # 数据库模块
  30. ##
  31. # MySQL数据库配置
  32. DATABASE_CONFIG = {
  33. 'host': '127.0.0.1',
  34. 'user': 'root',
  35. 'password': 'Your_Password',
  36. 'database': 'sql_web',
  37. 'cursorclass': pymysql.cursors.DictCursor
  38. # 指定游标类型为字典类型,使查询结果以字典形式返回,键为列名,值为对应数据
  39. }
  40. # 创建MySQL连接
  41. # 将字典DATABASE_CONFIG中的键对值解包后作为参数传递给connect函数,函数会返回一个表示与数据库连接的对象
  42. def create_connection():
  43. return pymysql.connect(**DATABASE_CONFIG)
  44. # 创建用户表
  45. def create_users_table():
  46. conn = create_connection()
  47. cursor = conn.cursor()
  48. cursor.execute('''
  49. CREATE TABLE IF NOT EXISTS users (
  50. u_id SMALLINT AUTO_INCREMENT PRIMARY KEY,
  51. username VARCHAR(255) NOT NULL,
  52. password VARCHAR(255) NOT NULL,
  53. phone VARCHAR(255) NOT NULL,
  54. department_id TINYINT NOT NULL,
  55. user_post_id TINYINT NOT NULL,
  56. attendance_day TINYINT DEFAULT 0,
  57. leave_day TINYINT DEFAULT 0,
  58. absence_day TINYINT DEFAULT 0,
  59. achievement_bouns INT DEFAULT 0,
  60. absence_nopay INT DEFAULT 0,
  61. other_nopay INT DEFAULT 0,
  62. gross_pay INT DEFAULT 0,
  63. after_tax_salary INT DEFAULT 0
  64. )
  65. ''')
  66. # 依次为用户姓名、手机号、所属部门、用户职务、工资、考勤天数、请假天数、缺勤天数、绩效奖金、缺勤扣除、其他扣除、税前工资、税后工资
  67. #至于不在用户表中设置基础工资的原因:因为基础工资是和所属部门和职务挂钩的,而且基础工资内容可以改变,不在用户表中设置基础工资,
  68. # 可以实现在显示用户的基础工资时,其个人中心的基础工资和工资制度中的基础工资是相吻合的
  69. conn.commit() # 提交对数据库的更改
  70. conn.close() # 关闭数据库连接
  71. # 创建部门基础工资表
  72. def create_department_salary_table():
  73. conn = create_connection()
  74. cursor = conn.cursor()
  75. cursor.execute('''
  76. CREATE TABLE IF NOT EXISTS department_salary(
  77. id SMALLINT AUTO_INCREMENT PRIMARY KEY,
  78. department VARCHAR(255) NOT NULL,
  79. position VARCHAR(255) NOT NULL,
  80. basic_salary INT DEFAULT 0,
  81. overtime_pay INT DEFAULT 0,
  82. other_salary INT DEFAULT 0,
  83. d_id SMALLINT NOT NULL,
  84. p_id SMALLINT NOT NULL
  85. )
  86. ''')
  87. conn.commit()
  88. conn.close()
  89. # 创建用户考勤表
  90. def create_user_attendance_table(u_id):
  91. id = "attendance_table" + str(u_id)
  92. conn = create_connection()
  93. cursor = conn.cursor()
  94. cursor.execute('''
  95. CREATE TABLE IF NOT EXISTS `{}`(
  96. date_time DATE,
  97. attendance_value SMALLINT
  98. )
  99. '''.format(id)) # 第一个字段用来统计日期,第二个字段分别表示打卡(1)、请假(0)、缺勤(-1)
  100. print("考勤表创建")
  101. conn.commit()
  102. conn.close()
  103. # 登录功能数据库模块
  104. def get_user(username, password):
  105. conn = create_connection()
  106. cursor = conn.cursor()
  107. cursor.execute('SELECT * FROM users WHERE username = %s AND password = %s', (username, password))
  108. user = cursor.fetchone() # 将查询的这行数据存储到变量user中
  109. conn.close()
  110. return user
  111. # 删除用户数据库模块
  112. def user_delete_sql(u_id):
  113. conn = create_connection()
  114. cursor = conn.cursor()
  115. cursor.execute('DELETE FROM users WHERE u_id = %s', u_id) # 先在用户表里删除
  116. cursor.execute('DROP TABLE `{}`'.format("attendance_table" + str(u_id)) ) # 再将该用户的考勤表删除
  117. conn.commit()
  118. conn.close()
  119. # 修改用户信息数据库模块
  120. def user_update_sql(u_id, username, password, phone, department_id, user_post_id, gross_pay):
  121. conn = create_connection()
  122. cursor = conn.cursor()
  123. cursor.execute('UPDATE users SET username=%s,password=%s,phone=%s,department_id=%s,'
  124. 'user_post_id=%s,gross_pay=%s WHERE u_id=%s',(username,password,phone,department_id,
  125. user_post_id,gross_pay,u_id))
  126. conn.commit()
  127. conn.close()
  128. # 用户列表数据库模块
  129. def user_list_sql():
  130. conn = create_connection()
  131. cursor = conn.cursor()
  132. cursor.execute('SELECT * FROM users')
  133. user_list = cursor.fetchall()
  134. conn.close()
  135. return user_list
  136. # 个人信息数据库模块
  137. def user_information_sql(u_id):
  138. conn = create_connection()
  139. cursor = conn.cursor()
  140. cursor.execute('SELECT * FROM users WHERE u_id = %s', u_id)
  141. user_info = cursor.fetchone()
  142. conn.close()
  143. return user_info
  144. # 管理界面添加用户数据库模块
  145. def user_add_sql(username, password, phone, department_id, user_post_id,gross_pay,after_tax_salary):
  146. create_users_table()
  147. conn = create_connection()
  148. cursor = conn.cursor()
  149. cursor.execute('INSERT INTO users(username,password,phone,department_id,user_post_id,'
  150. 'gross_pay,after_tax_salary)'
  151. 'VALUES(%s,%s,%s,%s,%s,%s,%s)', (username, password, phone, department_id,
  152. user_post_id,gross_pay,after_tax_salary))
  153. conn.commit()
  154. conn.close()
  155. # 管理界面搜索用户数据库模块
  156. def user_search_sql(username):
  157. conn = create_connection()
  158. cursor = conn.cursor()
  159. cursor.execute('SELECT * FROM users WHERE username=%s', username)
  160. search_result = cursor.fetchall()
  161. conn.close()
  162. return search_result
  163. # 系统概览数据库模块
  164. def system_overview_sql():
  165. conn = create_connection()
  166. cursor = conn.cursor()
  167. cursor.execute('SELECT SUM(gross_pay) FROM users')
  168. salary_total = cursor.fetchone()['SUM(gross_pay)']
  169. cursor.execute('SELECT COUNT(*) FROM users')
  170. staff_total = cursor.fetchone()['COUNT(*)']
  171. return staff_total, salary_total
  172. # 自动根据员工职务以及所属部门分配工资数据库模块
  173. def automatic_salary_allocation(department_id,user_post_id):
  174. create_department_salary_table()
  175. id_ = 0
  176. if department_id == 1 and user_post_id == 1:
  177. id_ = 1
  178. elif department_id == 1 and user_post_id == 2:
  179. id_ = 2
  180. elif department_id == 1 and user_post_id == 3:
  181. id_ = 3
  182. elif department_id == 1 and user_post_id == 4:
  183. id_ = 4
  184. elif department_id == 2 and user_post_id == 1:
  185. id_ = 5
  186. elif department_id == 2 and user_post_id == 2:
  187. id_ = 6
  188. elif department_id == 2 and user_post_id == 3:
  189. id_ = 7
  190. elif department_id == 2 and user_post_id == 4:
  191. id_ = 8
  192. elif department_id == 3 and user_post_id == 1:
  193. id_ = 9
  194. elif department_id == 3 and user_post_id == 2:
  195. id_ = 10
  196. elif department_id == 3 and user_post_id == 3:
  197. id_ = 11
  198. elif department_id == 3 and user_post_id == 4:
  199. id_ = 12
  200. elif department_id == 4 and user_post_id == 1:
  201. id_ = 13
  202. elif department_id == 4 and user_post_id == 2:
  203. id_ = 14
  204. elif department_id == 4 and user_post_id == 3:
  205. id_ = 15
  206. elif department_id == 4 and user_post_id == 4:
  207. id_ = 16
  208. elif department_id == 5 and user_post_id == 1:
  209. id_ = 17
  210. elif department_id == 5 and user_post_id == 2:
  211. id_ = 18
  212. elif department_id == 5 and user_post_id == 3:
  213. id_ = 19
  214. elif department_id == 5 and user_post_id == 4:
  215. id_ = 20
  216. elif department_id == 6 and user_post_id == 1:
  217. id_ = 21
  218. elif department_id == 6 and user_post_id == 2:
  219. id_ = 22
  220. elif department_id == 6 and user_post_id == 3:
  221. id_ = 23
  222. elif department_id == 6 and user_post_id == 4:
  223. id_ = 24
  224. else:
  225. id_ = 25
  226. conn = create_connection()
  227. cursor = conn.cursor()
  228. cursor.execute('SELECT basic_salary,overtime_pay,other_salary FROM department_salary WHERE id=%s',id_)
  229. salary_tuple = cursor.fetchone()
  230. return salary_tuple
  231. #公共单次数据库查询表数据库模块
  232. def public_search_one_sql(variable_one,variable_two,variable_three,variable_four):
  233. conn = create_connection()
  234. cursor = conn.cursor()
  235. cursor.execute(f'SELECT `{variable_one}` FROM `{variable_two}` WHERE `{variable_three}`=%s',variable_four)
  236. public_result = cursor.fetchone()
  237. conn.close()
  238. return public_result
  239. #公共单次数据库修改表数据库模块
  240. def public_update_one_sql(variable_one,variable_two,variable_three,variable_four,variable_five):
  241. conn = create_connection()
  242. cursor = conn.cursor()
  243. cursor.execute(f'UPDATE `{variable_one}` SET `{variable_two}`= %s WHERE `{variable_three}`=%s',
  244. (variable_four,variable_five))
  245. conn.commit()
  246. conn.close()
  247. #公共单次查询数据库-无条件 数据库模块
  248. def public_search_one_no_condition(variable_one,variable_two):
  249. conn = create_connection()
  250. cursor = conn.cursor()
  251. cursor.execute(f'SELECT `{variable_one}` FROM `{variable_two}`')
  252. public_result = cursor.fetchall()
  253. conn.close()
  254. return public_result
  255. #python定时任务来定时插入考勤表数据,也就是用户每天考勤表是默认为缺勤的,用户在点击考勤之后,会更新考勤表数据,以此来记录
  256. def timing_insert_attendance_table_sql():
  257. print("timing函数调用")
  258. global user_attendance_day_list
  259. global now_date
  260. user_attendance_day_list.clear()
  261. conn = create_connection()
  262. cursor = conn.cursor()
  263. cursor.execute('SELECT u_id FROM users')
  264. variable_list = cursor.fetchall()
  265. for variable_tuple in variable_list:
  266. create_user_attendance_table(variable_tuple['u_id'])
  267. variable_temporary = 'attendance_table'+str(variable_tuple['u_id'])
  268. cursor.execute(f'INSERT INTO `{variable_temporary}`(date_time,attendance_value) VALUES(%s,-1)',str(now_date))
  269. conn.commit()
  270. conn.close()
  271. #获取所有用户的u_id
  272. def get_all_users_u_id():
  273. conn = create_connection()
  274. cursor = conn.cursor()
  275. cursor.execute('SELECT u_id FROM users')
  276. users_u_id = cursor.fetchall()
  277. conn.close()
  278. return users_u_id
  279. #各部门工资组成列表
  280. def salary_composition_list():
  281. conn = create_connection()
  282. cursor = conn.cursor()
  283. cursor.execute('SELECT id,basic_salary,overtime_pay,other_salary,d_id,p_id FROM department_salary')
  284. salary_composition_list = cursor.fetchall()
  285. return salary_composition_list
  286. #管理员修改各部门基础工资功能数据库模块
  287. def modify_salary_sql():
  288. return 1
  289. # 用户密码生成函数
  290. def create_password(length=8):
  291. # 定义包含所有可能的字符串
  292. all_characters = string.ascii_letters + string.digits + string.punctuation
  293. # 随机选择字符生成密码
  294. password = ''.join(random.choice(all_characters) for _ in range(length))
  295. return password
  296. #绩效奖金/其他罚金 管理函数
  297. def user_achievement_bouns_or_other_nopay(u_id,new_salary):
  298. print("user_achievement_bouns_or_other_nopay函数调用")
  299. old_salary = public_search_one_sql('gross_pay','users','u_id',u_id)['gross_pay']
  300. print(old_salary)
  301. print(new_salary)
  302. if old_salary > new_salary:
  303. public_update_one_sql('users','other_nopay','u_id',(old_salary-new_salary),u_id)
  304. after_tax_salary = new_salary
  305. if 5000 < new_salary <= 15000:
  306. after_tax_salary = new_salary - (new_salary - 5000) * 0.05
  307. else:
  308. after_tax_salary = new_salary - (new_salary - 5000) * 0.1 - 350
  309. public_update_one_sql('users', 'after_tax_salary', 'u_id', after_tax_salary, u_id)
  310. elif old_salary < new_salary:
  311. public_update_one_sql('users','achievement_bouns','u_id',(new_salary-old_salary),u_id)
  312. after_tax_salary = new_salary
  313. if 5000 < new_salary <= 15000:
  314. after_tax_salary = new_salary - (new_salary - 5000) * 0.05
  315. else:
  316. after_tax_salary = new_salary - (new_salary - 5000) * 0.1 - 350
  317. public_update_one_sql('users', 'after_tax_salary', 'u_id', after_tax_salary, u_id)
  318. #用户工资算法(要在每天8点之后核算,这里用定时任务执行)
  319. def user_salary_algorithm():
  320. if get_current_time():
  321. global user_attendance_day_list
  322. user_all_list = [d['u_id'] for d in get_all_users_u_id()]
  323. difference_list = list(set(user_all_list)-set(user_attendance_day_list))
  324. #所有的用户与打卡的用户之间的不同就是缺勤的用户
  325. for u_id in difference_list:
  326. old_absence_nopay = public_search_one_sql('absence_nopay','users','u_id',u_id)['absence_nopay']
  327. gross_pay = public_search_one_sql('gross_pay','users','u_id',u_id)['gross_pay']
  328. public_update_one_sql('users','absence_nopay','u_id',(100+old_absence_nopay),u_id)
  329. #更新用户的缺勤罚金
  330. public_update_one_sql('users','gross_pay','u_id',(gross_pay-100),u_id)
  331. #更新用户的税前工资
  332. after_tax_salary = gross_pay
  333. if 5000 < gross_pay <= 15000:
  334. after_tax_salary = gross_pay - (gross_pay - 5000) * 0.05
  335. else:
  336. after_tax_salary = gross_pay - (gross_pay - 5000) * 0.1 - 350
  337. public_update_one_sql('users','absence_nopay','u_id',after_tax_salary,u_id)
  338. #用户列表中的关于考勤数据的更新
  339. def user_table_about_attendance_column():
  340. global now_date
  341. user_all_list = [d['u_id'] for d in get_all_users_u_id()]
  342. conn = create_connection()
  343. cursor = conn.cursor()
  344. for u_id in user_all_list:
  345. table_name = 'attendance_table'+str(u_id)
  346. attendance_value = public_search_one_sql('attendance_value',table_name,'date_time',now_date)['attendance_value']
  347. column_name = ''
  348. if attendance_value > 0:
  349. column_name = 'attendance_day'
  350. elif attendance_value==0:
  351. column_name = 'leave_day'
  352. else:
  353. column_name = 'absence_day'
  354. cursor.execute(f'UPDATE users SET `{column_name}`=`{column_name}`+1 WHERE u_id=%s', u_id)
  355. conn.commit()
  356. conn.close()
  357. #获取系统时间函数
  358. def get_current_time():
  359. now = datetime.now()
  360. return now.strftime("%Y-%m-%d")
  361. #定时任务函数
  362. def run_schedule():
  363. while True:
  364. schedule.run_pending()
  365. time.sleep(1)
  366. # 页面路由
  367. @app.route("/")
  368. def index():
  369. if session.get('logged_in'):
  370. u_id = session['user']['u_id']
  371. total = system_overview_sql()
  372. staff_total = total[0]
  373. salary_total = total[1]
  374. average_wage = staff_total / salary_total
  375. # timing_insert_attendance_table_sql()
  376. # user_salary_algorithm()
  377. # user_table_about_attendance_column()
  378. return render_template("index.html", staff_total=staff_total, salary_total=salary_total,
  379. average_wage=average_wage,u_id=u_id)
  380. else:
  381. return redirect("/login_interface")
  382. # 用户登录界面路由
  383. @app.route("/login_interface")
  384. def login_interface():
  385. return render_template("login.html")
  386. # 登陆验证模块
  387. @app.route("/login", methods=['POST'])
  388. def login():
  389. create_users_table()
  390. data = request.json
  391. username = data.get('Username')
  392. password = data.get('Password')
  393. # 调用方法,实现对用户名和密码是否匹配的验证
  394. user = get_user(username, password)
  395. # 使用session将用户数据存储在其中,从而存储用户登录信息,方便后续调用
  396. if user:
  397. session['user'] = {
  398. 'username': username,
  399. 'u_id': user['u_id'],
  400. 'user_post_id': user['user_post_id']
  401. }
  402. session['logged_in'] = True
  403. u_id = session['user']['u_id']
  404. print(public_search_one_sql('absence_nopay','users','u_id',u_id)['absence_nopay'])
  405. return jsonify({'success': True, 'message': '登录成功'})
  406. else:
  407. return jsonify({'success': False, 'message': '无效的用户名或密码'}), 401
  408. # 用户注销
  409. @app.route("/logout")
  410. def logout():
  411. session.pop('user', None)
  412. session.pop('logged_in', None)
  413. return redirect("/")
  414. # 用户管理界面
  415. @app.route("/manage_interface")
  416. def manage_interface():
  417. if session['user']['user_post_id'] <= 1:
  418. return render_template("manage_interface.html")
  419. #用户管理界面-用户列表
  420. @app.route("/manage_user_list")
  421. def manage_interface_user_list():
  422. user_list = user_list_sql()
  423. return jsonify(user_list)
  424. # 用户管理功能-添加用户
  425. @app.route("/user_add", methods=['POST'])
  426. def user_add():
  427. data = request.json
  428. username = data.get('Username')
  429. password = create_password()
  430. phone = data.get('Phone')
  431. department_id = data.get('Department_id')
  432. user_post_id = data.get('Position_id')
  433. salary_tuple = automatic_salary_allocation(int(department_id), int(user_post_id))
  434. basic_salary = salary_tuple['basic_salary'] #基本工资
  435. overtime_pay = salary_tuple['overtime_pay'] #加班工资
  436. other_salary = salary_tuple['other_salary'] #其他津贴
  437. gross_pay = basic_salary+overtime_pay+other_salary #根据用户的所属部门和职务来获取基本工资、加班工资、其他津贴
  438. after_tax_salary = gross_pay
  439. if 5000 < gross_pay <= 15000:
  440. after_tax_salary = gross_pay-(gross_pay-5000)*0.05
  441. else:
  442. after_tax_salary = gross_pay-(gross_pay-5000)*0.1-350
  443. user_add_sql(username, password, phone, department_id, user_post_id,gross_pay,after_tax_salary)
  444. return jsonify({'success': True, 'message': '添加成功'})
  445. #用户管理界面-编辑用户
  446. @app.route("/user_update",methods=['POST'])
  447. def user_update():
  448. data = request.json
  449. u_id = int(data.get('u_id'))
  450. username = data.get('username')
  451. password = data.get('password')
  452. phone = data.get('phone')
  453. department_id = int(data.get('department_id'))
  454. user_post_id = int(data.get('user_post_id'))
  455. gross_pay = int(data.get('gross_pay'))
  456. user_achievement_bouns_or_other_nopay(u_id,gross_pay)
  457. user_update_sql(u_id,username,password,phone,department_id,user_post_id,gross_pay)
  458. return jsonify({'success': True, 'message': '编辑成功'})
  459. #用户管理界面-删除用户
  460. @app.route("/user_delete",methods=['POST'])
  461. def user_delete():
  462. data = request.json
  463. u_id = int(data.get('userId'))
  464. user_delete_sql(u_id)
  465. return jsonify({'success': True, 'message': '删除成功'})
  466. #用户管理界面-搜索用户
  467. @app.route("/user_search",methods=['POST'])
  468. def user_search():
  469. data = request.json
  470. username = data.get('Uname')
  471. conn = create_connection()
  472. cursor = conn.cursor()
  473. cursor.execute('SELECT * FROM users WHERE username=%s',username)
  474. search_result_list = cursor.fetchall()
  475. print(search_result_list)
  476. return jsonify({'success': True, 'message': '搜索成功'})
  477. # 个人信息界面
  478. @app.route("/profile_interface")
  479. def profile_interface():
  480. if session.get('logged_in'):
  481. user_info = user_information_sql(session['user']['u_id'])
  482. user_department_post_salary = automatic_salary_allocation(int(user_info['department_id']),
  483. int(user_info['user_post_id']))
  484. return render_template("profile.html", username=str(user_info['username']), phone=user_info['phone'],
  485. department_id=user_info['department_id'],
  486. user_post_id=user_info['user_post_id'],
  487. basic_salary=user_department_post_salary['basic_salary'],
  488. overtime_pay = user_department_post_salary['overtime_pay'],
  489. other_salary =user_department_post_salary['other_salary'],
  490. attendance_day=user_info['attendance_day'],
  491. leave_day=user_info['leave_day'],absence_day=user_info['absence_day'],
  492. achievement_bouns=user_info['achievement_bouns'],
  493. absence_nopay=user_info['absence_nopay'],
  494. other_nopay=user_info['other_nopay'],
  495. gross_pay=user_info['gross_pay'],
  496. after_tax_salary=user_info['after_tax_salary']
  497. )
  498. else:
  499. return redirect("/login_interface")
  500. #考勤功能
  501. @app.route("/attendance_function",methods=['POST'])
  502. def attendance_function():
  503. data = request.json
  504. u_id = session['user']['u_id']
  505. global user_attendance_day_list
  506. if u_id not in user_attendance_day_list:
  507. user_attendance_day_list.append(u_id)
  508. attendance_value = int(data.get('action'))
  509. attendance_table = 'attendance_table'+str(u_id)
  510. global now_date
  511. public_update_one_sql(attendance_table,'attendance_value','date_time',attendance_value,now_date)
  512. return jsonify({'success': True, 'message': '今日打卡成功'})
  513. else:
  514. return jsonify({'success': True, 'message': '今日已打卡'})
  515. # 财务界面
  516. @app.route("/finance_department")
  517. def finance_interface():
  518. if session['user']['user_post_id'] <= 2:
  519. return render_template("finance_department.html")
  520. # 报销页面
  521. @app.route("/reimbursement_interface")
  522. def reimbursement_interface():
  523. return render_template("reimbursement.html")
  524. # 报销功能
  525. @app.route("/reimbursement")
  526. def reimbursement():
  527. return 1
  528. # 工资制度
  529. @app.route("/salary_composition")
  530. def salary_composition():
  531. # a=salary_composition_list()
  532. # print(a)
  533. return render_template("salary_composition.html",salary_composition_list=salary_composition_list())
  534. #工资制度修改
  535. @app.route("/salary_composition_change")
  536. def salary_composition_change():
  537. return 1
  538. #后勤采购
  539. @app.route("/logistics_procurement_interface")
  540. def logistics_procurement_interface():
  541. return render_template("logistics_procurement.html")
  542. schedule.every().day.at("08:00").do(timing_insert_attendance_table_sql)
  543. schedule.every().day.at("08:01").do(user_salary_algorithm)
  544. schedule.every().day.at("08:02").do(user_table_about_attendance_column)
  545. # 创建定时任务线程
  546. schedule_thread = threading.Thread(target=run_schedule)
  547. schedule_thread.daemon = True # 设置为守护线程,当主线程结束时,该线程也会结束
  548. schedule_thread.start()
  549. #获取系统时间
  550. now_date = get_current_time()
  551. if __name__ == '__main__':
  552. app.run(debug=True)

三、前端代码

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/我家自动化/article/detail/789930
推荐阅读
相关标签
  

闽ICP备14008679号