def paymentMonth(self): #获取所有人员名单 sql="select a.id,b.role_level from sc_user a,sc_role b,sc_userrole c where a.id=c.user_id and c.role_id=b.id" data = db.session.execute(sql).fetchall() pay = Payment() #上月 lst_fist = datetime.date(datetime.datetime.now().year,datetime.datetime.now().month-1,1) #客户经理工资计算 for obj in data: if obj.role_level==2: pay.payroll(obj.id,lst_fist,80) #后台岗工资计算 for obj in data: if obj.role_level==3: pay.backPayment(obj.id,lst_fist,80)
def khjlKPI(id): if request.method == 'GET': kpi_officer = SC_Kpi_Officer.query.filter_by(id=id).first() return render_template("Performance/ygpgkh/khjlKPI.html",kpi_officer=kpi_officer) else: kpi_officer = SC_Kpi_Officer.query.filter_by(id=id).first() try: kpi_officer.bq_dkye = request.form['bq_dkye'] kpi_officer.bq_ghs = request.form['bq_ghs'] kpi_officer.bq_khs = request.form['bq_khs'] kpi_officer.bq_lxsr = request.form['bq_lxsr'] kpi_officer.bq_zsbs = request.form['bq_zsbs'] kpi_officer.bm_dkye = request.form['bm_dkye'] kpi_officer.bm_ghs = request.form['bm_ghs'] kpi_officer.bm_lrgxd = request.form['bm_lrgxd'] kpi_officer.gr_dkye = request.form['gr_dkye'] kpi_officer.gr_ghs = request.form['gr_ghs'] kpi_officer.gr_xzkhs = request.form['gr_xzkhs'] kpi_officer.gr_zsbs = request.form['gr_zsbs'] kpi_officer.gr_lrgxd = request.form['gr_lrgxd'] kpi_officer.rcxwpg = request.form['rcxwpg'] kpi_officer.yql = request.form['yql'] kpi_officer.total = request.form['total'] kpi_officer.result = request.form['result'] kpi_officer.qtpj = request.form['qtpj'] kpi_officer.xq_dkye = request.form['xq_dkye'] kpi_officer.xq_ghs = request.form['xq_ghs'] kpi_officer.xq_xzkhs = request.form['xq_xzkhs'] kpi_officer.xq_lxsr = request.form['xq_lxsr'] kpi_officer.xq_zsbs = request.form['xq_zsbs'] kpi_officer.manager = current_user.id kpi_officer.date_2 = datetime.datetime.now() #计算三个月的分数 assess_record = SC_assess_record.query.filter_by(manager_id=kpi_officer.user_id).first() if assess_record: if assess_record.assess_sum == '1': assess_record.assess_score_2 = assess_record.assess_score_1 assess_record.assess_score_1 = request.form['total'] assess_record.assess_sum = 2 assess_record.assess_arg = (Decimal(assess_record.assess_score_1)+Decimal(assess_record.assess_score_2))/2 elif assess_record.assess_sum == '2': assess_record.assess_score_3 = assess_record.assess_score_2 assess_record.assess_score_2 = assess_record.assess_score_1 assess_record.assess_score_1 = request.form['total'] assess_record.assess_sum = 3 assess_record.assess_arg = (Decimal(assess_record.assess_score_1)+Decimal(assess_record.assess_score_2)+Decimal(assess_record.assess_score_3))/3 elif assess_record.assess_sum == '3': assess_record.assess_score_3 = assess_record.assess_score_2 assess_record.assess_score_2 = assess_record.assess_score_1 assess_record.assess_score_1 = request.form['total'] assess_record.assess_sum = 3 assess_record.assess_arg = (Decimal(assess_record.assess_score_1)+Decimal(assess_record.assess_score_2)+Decimal(assess_record.assess_score_3))/3 else: assess_record_new = SC_assess_record(kpi_officer.user_id) assess_record_new.add() db.session.flush() assess_record_new.assess_sum = 1 assess_record_new.assess_arg = request.form['total'] assess_record_new.assess_score_1 = request.form['total'] #调用贺珈的函数 pay = Payment() pay.payroll(kpi_officer.user_id,kpi_officer.assess_date,kpi_officer.total) # 事务提交 db.session.commit() # 消息闪现 flash('保存成功','success') except: # 回滚 db.session.rollback() logger.exception('exception') # 消息闪现 flash('保存失败','error') return redirect('Performance/ygpgkh/zgpg_search')