Merge pull request !5291 from 李鹏宇/dev
This commit is contained in:
李鹏宇
2025-09-22 03:02:37 +00:00
committed by Gitee
3 changed files with 73 additions and 26 deletions
+70 -23
View File
@@ -229,20 +229,32 @@ class HrAttendance(models.Model):
absenteeism_card += 1
if has_abnormal:
url = f"https://oa.thtzjt.com/webh5#/clock_in_staticstis?user_id={employee.user_id.id}"
self.sudo().env["wecom.apps"].sync_send_message_textcard(category='att', user_id=employee.wecom_userid, title="打卡异常提醒",
description="本月迟到: {}\n本月缺卡: {}\n本月早退: {}\n本月异常:{}\n 本月旷工: {}\n"
.format(is_late_card, is_no_card, is_early_card, is_abnormal, absenteeism_card),
url=url, btntxt="详细信息")
base_url = self.env['ir.config parameter'].sudo().get_param('web.base.url')
self.env['card.remind.form'].create({
'name': employee.name,
'start_time': current_time,
'shift': '行政班次',
'department': employee.department_id.name,
'remarks': f"域名: {base_url}"
})
logging.info(f"执行时间为{current_time}")
logging.info(f"打卡异常提醒发送成功,员工:{employee.name},本月迟到: {is_late_card},本月缺卡: {is_no_card},本月早退: {is_early_card},本月异常:{is_abnormal},本月旷工: {absenteeism_card}")
try:
self.sudo().env["wecom.apps"].sync_send_message_textcard(
category='att',
user_id=employee.wecom_userid,
title="打卡异常提醒",
description="本月迟到: {}\n本月缺卡: {}\n本月早退: {}\n本月异常:{}\n 本月旷工: {}\n"
.format(is_late_card, is_no_card, is_early_card, is_abnormal, absenteeism_card),
url=url,
btntxt="详细信息"
)
base_url = self.env['ir.config_parameter'].sudo().get_param('web.base.url')
self.env['card.remind.form'].create({
'name': employee.name,
'start_time': current_time,
'shift': '行政班次',
'department': employee.department_id.name,
'remarks': f"域名: {base_url}"
})
self._create_message_log(employee, '3', url)
# 记录成功日志
_logger.info(f"执行时间为{current_time}")
_logger.info(
f"打卡异常提醒发送成功,员工:{employee.name},本月迟到: {is_late_card},本月缺卡: {is_no_card},本月早退: {is_early_card},本月异常:{is_abnormal},本月旷工: {absenteeism_card}")
except Exception as e:
_logger.error(f"打卡异常提醒发送失败,员工:{employee.name},错误信息:{str(e)}")
def missing_card_judgment(self):
today = fields.Date.today()
@@ -967,22 +979,57 @@ class HrAttendance(models.Model):
'department': user.department_id.name, })
self.card_duty_remind(user.resource_id.employee_id)
def _create_message_log(self, employee_id, message_type, url):
"""创建消息提醒日志记录"""
today = fields.Date.today()
first_day = today.replace(day=1)
vacation = self.env['yuthon.vacation.reports'].search([
('employee_id', '=', employee_id.id),
('vacation_date', '=', first_day)
], limit=1)
if vacation:
self.env['attendance.message.log'].create({
'vacation_id': vacation.id,
'employee_id': employee_id.id,
'update_date': fields.Datetime.now(),
'message_type': message_type,
'message_url': url,
})
def card_in_comment(self, employee_id, planning_name):
data = f"您的班次是{planning_name},还有10分钟上班,记得打卡"
url = '#小程序://天投云/XttsPpKg3MEpY7h'
self.sudo().env["wecom.apps"].sync_send_message(category='att', user_id=employee_id.wecom_userid,
description=data,
title="打卡提醒",
url=url, btntxt="详细信息")
try:
self.sudo().env["wecom.apps"].sync_send_message(
category='att',
user_id=employee_id.wecom_userid,
description=data,
title="打卡提醒",
url=url,
btntxt="详细信息"
)
self._create_message_log(employee_id, '1', url)
except Exception as e:
_logger.error(f"上班打卡提醒发送失败:员工={employee_id.name}, 错误={e}")
def card_out_comment(self, employee_id, planning_name):
data = f"您的班次是{planning_name},您该下班了,记得打卡"
url = '#小程序://天投云/XttsPpKg3MEpY7h'
self.sudo().env["wecom.apps"].sync_send_message(category='att', user_id=employee_id.wecom_userid,
description=data,
title="打卡提醒",
url=url, btntxt="详细信息")
try:
self.sudo().env["wecom.apps"].sync_send_message(
category='att',
user_id=employee_id.wecom_userid,
description=data,
title="打卡提醒",
url=url,
btntxt="详细信息"
)
self._create_message_log(employee_id, '2', url)
except Exception as e:
_logger.error(f"下班打卡提醒发送失败:员工={employee_id.name}, 错误={e}")
def card_duty_remind(self, employee_id):
data = "今天您值班,记得打卡"
@@ -924,7 +924,6 @@ class AttendanceMessageLog(models.Model):
message_url = fields.Char(string="url")
class DetailsTree(models.Model):
_name = 'details.tree'
_description = '明细表'
@@ -107,7 +107,7 @@
</button>
</div>
<field name="employee_id" readonly="1"/>
<!-- <field name="vacation_date" readonly="1"/>-->
<field name="vacation_date" readonly="1"/>
<div class="col-12 text-center">
<h1>
<field name="display_date"/>
@@ -235,12 +235,13 @@
</page>
<page string="出勤消息日志">
<field name="attendance_message_log_ids">
<tree>
<tree editable="bottom" create="false" edit="false" delete="false">
<field name="vacation_id" column_invisible="1"/>
<field name="employee_id"/>
<field name="update_date"/>
<field name="message_type"/>
<field name="message_url"/>
<button name="unlink" string="删除" type="object" class="btn-primary" groups="yuthon_holiday.group_yuthon_holiday_admin"/>
</tree>
</field>
</page>