diff --git a/sh_backmate_theme_adv_enterprise/static/src/js/calculator.js b/sh_backmate_theme_adv_enterprise/static/src/js/calculator.js
index 72183c910..170916b13 100644
--- a/sh_backmate_theme_adv_enterprise/static/src/js/calculator.js
+++ b/sh_backmate_theme_adv_enterprise/static/src/js/calculator.js
@@ -10,77 +10,75 @@ import { useService } from "@web/core/utils/hooks";
import { session } from "@web/session";
export class CalculaterSh extends Component {
- static template = "CalculatorTemplate";
+ static template = "CalculatorTemplate";
- setup() {
- this.orm = useService("orm");
- this.search_sh_enable_calculator_mode()
+ setup() {
+ this.orm = useService("orm");
+ this.search_sh_enable_calculator_mode()
+ }
+
+ search_sh_enable_calculator_mode() {
+ this.sh_enable_calculator_mode = session.sh_enable_calculator_mode
+ }
+
+ onClickCalculator() {
+ if($('.calculator').length > 0){
+ $(".sh_calc_results").html("");
+ }else{
+ // render template
+ var qweb_data = `
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
`
+ $(".sh_calc_results").html(qweb_data);
}
-
- search_sh_enable_calculator_mode() {
- this.sh_enable_calculator_mode = session.sh_enable_calculator_mode
+ if($('.sh_calc_util').hasClass('active')){
+ $('.sh_calc_util').removeClass('active')
+ }else{
+ $('.sh_calc_util').addClass('active')
+ }
+ // close other popup
+ $('.sh_user_language_list_cls').css("display","none")
+ $('.sh_wqm_quick_menu_submenu_list_cls').css("display","none")
+ $('.todo_layout').removeClass("sh_theme_model");
}
-
- onClickCalculator() {
- if($('.calculator').length > 0){
- $(".sh_calc_results").html("");
- }else{
- // render template
- var qweb_data = '
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
'
- $(".sh_calc_results").html(qweb_data);
- }
-
- if($('.sh_calc_util').hasClass('active')){
- $('.sh_calc_util').removeClass('active')
- }else{
- $('.sh_calc_util').addClass('active')
- }
-
- // close other popup
- $('.sh_user_language_list_cls').css("display","none")
- $('.sh_wqm_quick_menu_submenu_list_cls').css("display","none")
- $('.todo_layout').removeClass("sh_theme_model");
- }
-
}
registry.category("systray").add("sh_entmate_theme.calculater_sh", { Component: CalculaterSh }, { sequence: 25 });
diff --git a/sh_backmate_theme_adv_enterprise/static/src/js/navbar.js b/sh_backmate_theme_adv_enterprise/static/src/js/navbar.js
index 81517eb1b..ad11cb7b1 100644
--- a/sh_backmate_theme_adv_enterprise/static/src/js/navbar.js
+++ b/sh_backmate_theme_adv_enterprise/static/src/js/navbar.js
@@ -374,62 +374,76 @@ patch(NavBar.prototype, {
getXmlID(app_id) {
return this.menuService.getMenuAsTree(app_id).xmlid;
},
- OnClickDropdown(ev){
- /*close pop-ups*/
- $('.backmate_theme_layout').removeClass("sh_theme_model");
- $('.todo_layout').removeClass("sh_theme_model");
- $('.todo').removeClass('todo_active');
- $('.sh_calc_util').removeClass("active")
- $(".sh_calc_results").html("");
- $('.sh_wqm_quick_menu_submenu_list_cls').css("display","none")
- $('.o_user_bookmark_menu').removeClass('bookmark_active')
- $('.sh_search_results').css("display", "none");
- if (!$(ev.currentTarget).next().hasClass('show_ul')) {
- $(ev.currentTarget).next('.dropdown-menu-right').first().slideDown('slow');
+ /**
+ * 处理点击下拉菜单事件
+ *
+ * @param {Event} ev - 触发事件的对象
+ */
+ OnClickDropdown(ev) {
+ // 1. 关闭弹出窗口
+ $('.backmate_theme_layout').removeClass("sh_theme_model");
+ $('.todo_layout').removeClass("sh_theme_model");
+ $('.todo').removeClass('todo_active');
+ $('.sh_calc_util').removeClass("active");
+ $(".sh_calc_results").html(""); // 清空计算结果
+ $('.sh_wqm_quick_menu_submenu_list_cls').css("display", "none");
+ $('.o_user_bookmark_menu').removeClass('bookmark_active');
+ $('.sh_search_results').css("display", "none");
+ // 2. 切换子菜单显示状态
+ // 检查当前菜单项的下一个兄弟元素是否有 'show_ul' 类
+ if (!$(ev.currentTarget).next().hasClass('show_ul')) {
+ // 如果没有展开子菜单,则展开当前菜单
+ $(ev.currentTarget).next('.dropdown-menu-right').first().slideDown('slow');
- $(ev.currentTarget).parents('.dropdown-menu').first().find('.show_ul').slideUp(600)
- $(ev.currentTarget).parents('.dropdown-menu').first().find('.show_ul').css("display", "none !important")
- $(ev.currentTarget).parents('.dropdown-menu').first().find('.show_ul').removeClass('show_ul');
+ // 隐藏其他已经展开的子菜单
+ $(ev.currentTarget).parents('.dropdown-menu').first().find('.show_ul').slideUp(600); // 收起其他子菜单
+ $(ev.currentTarget).parents('.dropdown-menu').first().find('.show_ul').css("display", "none !important"); // 强制隐藏
+ $(ev.currentTarget).parents('.dropdown-menu').first().find('.show_ul').removeClass('show_ul'); // 移除 'show_ul' 类
+ // 3. 根据当前父元素的不同,调整子菜单的样式
+ if ($(ev.currentTarget).next('.dropdown-menu').parents('.dropdown-header').length === 1) {
+ // 如果当前菜单的父元素是 '.dropdown-header',则给它添加样式
+ $(ev.currentTarget).parents('.dropdown-menu').first().find('.sh_sub_dropdown').removeClass('sh_sub_dropdown');
+ $(ev.currentTarget).next('.dropdown-menu').parents('.dropdown-header').children('.dropdown-item').addClass('sh_sub_dropdown');
+ } else if ($(ev.currentTarget).next('.dropdown-menu').parents('.dropdown-header').length > 1) {
+ // 如果当前菜单的父元素是 '.dropdown-header',则给它添加样式
+ $(ev.currentTarget).parents('.dropdown-menu').first().find('.sh_sub_dropdown').removeClass('sh_sub_dropdown');
+ $(ev.currentTarget).next('.dropdown-menu').parents('.dropdown-header').children('.dropdown-item').addClass('sh_sub_dropdown');
+ } else {
+ // 否则,调整其他菜单项的样式
+ $(ev.currentTarget).parents('.dropdown-menu').first().find('.sh_dropdown').removeClass('sh_dropdown');
+ $(ev.currentTarget).parents('.dropdown-menu').first().find('.active').removeClass('active');
+ $(ev.currentTarget).parents('.dropdown-menu').first().find('.sh_sub_dropdown').removeClass('sh_sub_dropdown');
+ $(ev.currentTarget).next('.dropdown-menu').parents('.sh_dropdown_div').children('.dropdown-item').addClass('sh_dropdown');
+ $(ev.currentTarget).next('.dropdown-menu').parents('.sh_dropdown_div').children('.dropdown-item').addClass('active');
+ }
+ }
- if ($(ev.currentTarget).next('.dropdown-menu').parents('.dropdown-header').length == 1) {
- $(ev.currentTarget).parents('.dropdown-menu').first().find('.sh_sub_dropdown').removeClass('sh_sub_dropdown');
- $(ev.currentTarget).next('.dropdown-menu').parents('.dropdown-header').children('.dropdown-item').addClass('sh_sub_dropdown');
+ // 4. 如果子菜单已经展开,则隐藏它
+ if ($(ev.currentTarget).next().hasClass('show_ul')) {
+ // 如果当前子菜单已经展开,则收起它
+ $(ev.currentTarget).next('.dropdown-menu-right').first().slideUp(600);
+ // 移除展开时的样式
+ if ($(ev.currentTarget).next('.dropdown-menu').parents('.dropdown-header').length === 1) {
+ $(ev.currentTarget).next('.dropdown-menu').parents('.dropdown-header').children('.dropdown-item').removeClass('sh_sub_dropdown');
+ } else if ($(ev.currentTarget).next('.dropdown-menu').parents('.dropdown-header').length > 1) {
+ $(ev.currentTarget).next('.dropdown-menu').parents('.dropdown-header').first().children('.dropdown-item').removeClass('sh_sub_dropdown');
+ $(ev.currentTarget).next('.dropdown-menu').parents('.dropdown-header').last().removeClass('sh_sub_dropdown');
+ } else {
+ $(ev.currentTarget).next('.dropdown-menu').parents('.sh_dropdown_div').children('span').removeClass('sh_dropdown');
+ $(ev.currentTarget).next('.dropdown-menu').parents('.sh_dropdown_div').children('span').removeClass('active');
+ }
+ }
- } else {
- $(ev.currentTarget).parents('.dropdown-menu').first().find('.sh_dropdown').removeClass('sh_dropdown');
- $(ev.currentTarget).parents('.dropdown-menu').first().find('.active').removeClass('active');
-
- $(ev.currentTarget).parents('.dropdown-menu').first().find('.sh_sub_dropdown').removeClass('sh_sub_dropdown');
- $(ev.currentTarget).next('.dropdown-menu').parents('.sh_dropdown_div').children('.dropdown-item').addClass('sh_dropdown');
- $(ev.currentTarget).next('.dropdown-menu').parents('.sh_dropdown_div').children('.dropdown-item').addClass('active');
- }
- }
-
- if ($(ev.currentTarget).next().hasClass('show_ul')) {
- $(ev.currentTarget).next('.dropdown-menu-right').first().slideUp(600);
-
- if ($(ev.currentTarget).next('.dropdown-menu').parents('.dropdown-header').length == 1) {
- $(ev.currentTarget).next('.dropdown-menu').parents('.dropdown-header').children('.dropdown-item').removeClass('sh_sub_dropdown');
- } else {
-
- $(ev.currentTarget).next('.dropdown-menu').parents('.sh_dropdown_div').children('span').removeClass('sh_dropdown');
- $(ev.currentTarget).next('.dropdown-menu').parents('.sh_dropdown_div').children('span').removeClass('active');
- }
- }
-
- var $subMenu = $(ev.currentTarget).next('.dropdown-menu');
- $subMenu.toggleClass('show_ul');
-
+ // 5. 切换当前子菜单的状态
+ var $subMenu = $(ev.currentTarget).next('.dropdown-menu');
+ $subMenu.toggleClass('show_ul'); // 切换子菜单的显示状态
},
- currentMenuAppSections(app_id) {
- return (
- (this.menuService.getMenuAsTree(app_id).childrenTree) ||
- []
- );
+ currentMenuAppSections(app_id) {
+ return ((this.menuService.getMenuAsTree(app_id).childrenTree) || []);
},
getThemeStyle(ev) {
diff --git a/sh_backmate_theme_adv_enterprise/static/src/scss/sidebar/collapsed.scss b/sh_backmate_theme_adv_enterprise/static/src/scss/sidebar/collapsed.scss
index e93e95f22..edc31b2c1 100644
--- a/sh_backmate_theme_adv_enterprise/static/src/scss/sidebar/collapsed.scss
+++ b/sh_backmate_theme_adv_enterprise/static/src/scss/sidebar/collapsed.scss
@@ -560,6 +560,7 @@
width: 260px !important;
}
}
+
.o-dropdown--menu.dropdown-menu.d-block {
width: 70px !important;
min-width: 70px !important;
diff --git a/sh_backmate_theme_adv_enterprise/static/src/xml/menu.xml b/sh_backmate_theme_adv_enterprise/static/src/xml/menu.xml
index cbbdfc966..21868ded8 100644
--- a/sh_backmate_theme_adv_enterprise/static/src/xml/menu.xml
+++ b/sh_backmate_theme_adv_enterprise/static/src/xml/menu.xml
@@ -1,234 +1,159 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
-
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
+
+
+
+
-
-
-
@@ -259,21 +184,16 @@
-
-
-
-
-
@@ -304,7 +224,8 @@
-
+
+
-
diff --git a/sh_backmate_theme_adv_enterprise/views/assets_backend.xml b/sh_backmate_theme_adv_enterprise/views/assets_backend.xml
index da9ba65ed..9c5c223af 100644
--- a/sh_backmate_theme_adv_enterprise/views/assets_backend.xml
+++ b/sh_backmate_theme_adv_enterprise/views/assets_backend.xml
@@ -6,9 +6,5 @@
-
-
-
-
\ No newline at end of file
diff --git a/yuthon_wechat/models/hr_attendance_detail.py b/yuthon_wechat/models/hr_attendance_detail.py
index c02a8086f..0d1083269 100644
--- a/yuthon_wechat/models/hr_attendance_detail.py
+++ b/yuthon_wechat/models/hr_attendance_detail.py
@@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-
import os
import base64
-import datetime
+from datetime import datetime, timedelta, time
import logging
import traceback
from odoo import api, fields, models, tools, _
@@ -14,7 +14,8 @@ class HrAttendanceDetailImage(models.Model):
_name = "hr.attendance.detail.image"
_description = "打卡原始抓取数据图片"
- attendance_detail_id = fields.Many2one('hr.attendance.detail', string="原始打卡记录", ondelete="cascade", readonly=True)
+ attendance_detail_id = fields.Many2one('hr.attendance.detail', string="原始打卡记录", ondelete="cascade",
+ readonly=True)
media_url = fields.Char(string='附件地址')
media_file = fields.Binary(string='附件文件', compute="_compute_media_file")
@@ -55,7 +56,8 @@ class HrAttendanceDetail(models.Model):
schedule_id = fields.Char(string='班次id')
timeline_id = fields.Integer(string='时段id')
- attendance_detail_image_ids = fields.One2many(string="打卡记录图片", comodel_name='hr.attendance.detail.image', inverse_name='attendance_detail_id')
+ attendance_detail_image_ids = fields.One2many(string="打卡记录图片", comodel_name='hr.attendance.detail.image',
+ inverse_name='attendance_detail_id')
hr_attendance_id = fields.Many2one('hr.attendance', string="出勤记录", ondelete="cascade", readonly=True)
def action_show_details(self):
@@ -97,8 +99,8 @@ class HrAttendanceDetail(models.Model):
:return:
"""
# 先按照天抓取,时间戳
- now_time = datetime.datetime.now() + datetime.timedelta(hours=8)
- start_time = now_time - datetime.timedelta(days=30)
+ now_time = datetime.now() + timedelta(hours=8)
+ start_time = now_time - timedelta(days=30)
start_time_stamp = int(start_time.timestamp())
end_time_stamp = int(now_time.timestamp())
# 整理请求信息
@@ -127,7 +129,8 @@ class HrAttendanceDetail(models.Model):
return []
result = response.json()
if result.get('errcode') != 0:
- _logger.error('获取外出打卡数据失败,异常:{0},用户列表{1}'.format(str(result.get('errmsg')), str(userid_limit)))
+ _logger.error(
+ '获取外出打卡数据失败,异常:{0},用户列表{1}'.format(str(result.get('errmsg')), str(userid_limit)))
return []
checkin_data = result.get('checkindata', [])
if not checkin_data:
@@ -148,8 +151,8 @@ class HrAttendanceDetail(models.Model):
if not userid or not checkin_time_stamp:
_logger.error('没有抓取到用户出勤信息,异常:{0},用户列表{1}'.format(str(data), str(userid_limit)))
return False
- checkin_time = datetime.datetime.fromtimestamp(checkin_time_stamp) if checkin_time_stamp else None
- sch_checkin_time = datetime.datetime.fromtimestamp(sch_checkin_time_stamp) if sch_checkin_time_stamp else None
+ checkin_time = datetime.fromtimestamp(checkin_time_stamp) if checkin_time_stamp else None
+ sch_checkin_time = datetime.fromtimestamp(sch_checkin_time_stamp) if sch_checkin_time_stamp else None
return checkin_time, sch_checkin_time
def _check_wx_attendance_media(self, data):
@@ -172,7 +175,8 @@ class HrAttendanceDetail(models.Model):
try:
result, response = self.sudo().env["wecom.apps"].sync_media_get(data)
if result:
- filename = response.headers['Content-Disposition'].split('; ')[2].replace('filename=', '').replace('"', '')
+ filename = response.headers['Content-Disposition'].split('; ')[2].replace('filename=', '').replace(
+ '"', '')
wx_work_auth = self.env['auth.oauth.provider'].search([('name', '=', 'Wechat Card')], limit=1)
wx_work_image = os.path.join(wx_work_auth.wx_work_image_path, str(filename))
with open(wx_work_image, 'wb') as f:
@@ -181,9 +185,11 @@ class HrAttendanceDetail(models.Model):
'media_url': filename,
}))
else:
- _logger.error('检查保存之前的数据分析出想要的数据失败,异常:{0},数据信息{1}'.format(str(response), str(data)))
+ _logger.error(
+ '检查保存之前的数据分析出想要的数据失败,异常:{0},数据信息{1}'.format(str(response), str(data)))
except Exception as e:
- _logger.error('请求原始图片失败,异常:{0},数据信息{1},异常详情:{2}'.format(str(e), str(data), str(traceback.format_exc())))
+ _logger.error('请求原始图片失败,异常:{0},数据信息{1},异常详情:{2}'.format(str(e), str(data),
+ str(traceback.format_exc())))
return media_list
@@ -198,7 +204,8 @@ class HrAttendanceDetail(models.Model):
"""
userid = data.get("userid", "")
# 查询是否存在数据
- if userid and checkin_time and self.env['hr.attendance.detail'].sudo().search_count([("userid", "=", userid), ("checkin_time", "=", checkin_time)]) <= 0:
+ if userid and checkin_time and self.env['hr.attendance.detail'].sudo().search_count(
+ [("userid", "=", userid), ("checkin_time", "=", checkin_time)]) <= 0:
res_user_obj = self.env['res.users'].sudo().search([("oauth_uid", "=", userid)], limit=1)
hr_employee_obj = self.env['hr.employee'].sudo().search([("user_id", "=", res_user_obj.id)], limit=1)
if not res_user_obj or not hr_employee_obj:
@@ -232,15 +239,18 @@ class HrAttendanceDetail(models.Model):
media_list = self._check_wx_attendance_media(data)
attendance_detail_obj.attendance_detail_image_ids = media_list
except Exception as e:
- _logger.error('检查保存之前的数据分析出想要的数据失败,异常:{0},数据信息{1},异常详情:{2}'.format(str(e), str(data), str(traceback.format_exc())))
+ _logger.error(
+ '检查保存之前的数据分析出想要的数据失败,异常:{0},数据信息{1},异常详情:{2}'.format(str(e), str(data),
+ str(traceback.format_exc())))
userid = data.get("userid", "")
# 区分当天的上班,下班,中午打卡,合并一个
- checkin_time_now = checkin_time + datetime.timedelta(hours=8) if checkin_time else None
- sch_checkin_time_now = sch_checkin_time + datetime.timedelta(hours=8) if sch_checkin_time else None
- current_data = (sch_checkin_time + datetime.timedelta(hours=8)).strftime("%Y-%m-%d") if sch_checkin_time_now else checkin_time_now.strftime("%Y-%m-%d")
+ checkin_time_now = checkin_time + timedelta(hours=8) if checkin_time else None
+ sch_checkin_time_now = sch_checkin_time + timedelta(hours=8) if sch_checkin_time else None
+ current_data = (sch_checkin_time + timedelta(hours=8)).strftime("%Y-%m-%d") if sch_checkin_time_now else checkin_time_now.strftime("%Y-%m-%d")
# 同步整理当天出勤数据
- attendance_obj = self.env['hr.attendance'].search([("userid", "=", userid), ("current_data", "=", current_data)], limit=1)
+ attendance_obj = self.env['hr.attendance'].search(
+ [("userid", "=", userid), ("current_data", "=", current_data)], limit=1)
attendance_obj.attendance_type = "wx_work"
checkin_type = data.get("checkin_type", "")
exception_type = data.get("exception_type", "")
@@ -255,10 +265,8 @@ class HrAttendanceDetail(models.Model):
"attendance_type": "wx_work"
})
else:
- current_datetime_start = datetime.datetime.combine(
- datetime.datetime.strptime(current_data, '%Y-%m-%d'), datetime.time.min)
- current_datetime_end = datetime.datetime.combine(
- datetime.datetime.strptime(current_data, '%Y-%m-%d'), datetime.time.max)
+ current_datetime_start = datetime.combine(datetime.strptime(current_data, '%Y-%m-%d'), datetime.min.time())
+ current_datetime_end = datetime.combine(datetime.strptime(current_data, '%Y-%m-%d'), datetime.max.time())
planning_slot_id = self.env['planning.slot'].search(
[('resource_id', '=', hr_employee_obj.resource_id.id),
('start_datetime', '>=', current_datetime_start),
@@ -272,7 +280,7 @@ class HrAttendanceDetail(models.Model):
"attendance_type": "wx_work"
})
if not hr_employee_obj.default_planning_role_id:
- # 获取考勤日历的上班下班时间
+ # 获取考勤日历的上班下班时间
min_hour_from = self.env['resource.calendar'].search([])[0].attendance_ids[0].hour_from
min_hour = int(min_hour_from)
min_minute = int(min_hour_from * 10 % min_hour_from)
@@ -327,60 +335,67 @@ class HrAttendanceDetail(models.Model):
else:
attendance_obj.sudo().write({"is_no_card": True, "is_abnormal": True})
else:
- current_datetime_start = datetime.datetime.combine(datetime.datetime.strptime(current_data, '%Y-%m-%d'), datetime.time.min)
- current_datetime_end = datetime.datetime.combine(datetime.datetime.strptime(current_data, '%Y-%m-%d'), datetime.time.max)
+ current_data = datetime.strptime(current_data, '%Y-%m-%d')
+ # 获取当天的起始和结束时间
+ current_datetime_start = datetime.combine(current_data, datetime.min.time())
+ current_datetime_end = datetime.combine(current_data, datetime.max.time())
+ # 获取本人当天的班次
planning_id = self.env['planning.slot'].search([('resource_id', '=', hr_employee_obj.resource_id.id),
('start_datetime', '>=', current_datetime_start),
('start_datetime', '<=', current_datetime_end)])
if planning_id:
- planning_start_time = planning_id.start_datetime
- planning_end_time = planning_id.end_datetime
- if planning_id.department_id.name == '保安部':
+ planning_start_time = planning_id.start_datetime + timedelta(hours=8)
+ planning_end_time = planning_id.end_datetime + timedelta(hours=8)
+ if planning_id.role_id.name == '保安部':
+ # {'白班': [['8:30', '9.30'], ['8:30', '9.30']]}white
+ # {'中班': [['8:30', '9.30'], ['8:30', '9.30']]}mid
+ # {'夜班': [['8:30', '9.30'], ['8:30', '9.30']]}night
# 白班上班区间
- start_time = datetime.datetime.combine(current_data, datetime.time(6, 0))+ datetime.timedelta(hours=8)
- end_time = datetime.datetime.combine(current_data, datetime.time(9, 0))+ datetime.timedelta(hours=8)
+ start_time = datetime.combine(current_data, time(6, 0)) + timedelta(hours=8)
+ end_time = datetime.combine(current_data, time(9, 0)) + timedelta(hours=8)
# 白班下班区间
- start_time1 = datetime.datetime.combine(current_data, datetime.time(2, 0))+ datetime.timedelta(hours=8)
- end_time1 = datetime.datetime.combine(current_data, datetime.time(4, 0))+ datetime.timedelta(hours=8)
+ start_time1 = datetime.combine(current_data, time(2, 0)) + timedelta(hours=8)
+ end_time1 = datetime.combine(current_data, time(4, 0)) + timedelta(hours=8)
# 中班上班区间
- start_time2 = datetime.datetime.combine(current_data, datetime.time(14, 0))+ datetime.timedelta(hours=8)
- end_time2 = datetime.datetime.combine(current_data, datetime.time(17, 0))+ datetime.timedelta(hours=8)
+ start_time2 = datetime.combine(current_data, time(14, 0)) + timedelta(hours=8)
+ end_time2 = datetime.combine(current_data, time(17, 0)) + timedelta(hours=8)
# 中班下班区间
- start_time3 = datetime.datetime.combine(current_data, datetime.time(22, 0))+ datetime.timedelta(hours=8)
- end_time3 = datetime.datetime.combine(current_data, datetime.time(1, 0))+ datetime.timedelta(hours=8)
+ start_time3 = datetime.combine(current_data, time(22, 0)) + timedelta(hours=8)
+ end_time3 = datetime.combine(current_data, time(1, 0)) + timedelta(hours=8)
# 夜班上班区间
- start_time4 = datetime.datetime.combine(current_data, datetime.time(22, 0))+ datetime.timedelta(hours=8)
- end_time4 = datetime.datetime.combine(current_data, datetime.time(1, 0))+ datetime.timedelta(hours=8)
+ start_time4 = datetime.combine(current_data, time(22, 0)) + timedelta(hours=8)
+ end_time4 = datetime.combine(current_data, time(1, 0)) + timedelta(hours=8)
# 夜班下班区间
- start_time5 = datetime.datetime.combine(current_data, datetime.time(6, 0))+ datetime.timedelta(hours=8)
- end_time5 = datetime.datetime.combine(current_data, datetime.time(9, 0))+ datetime.timedelta(hours=8)
+ start_time5 = datetime.combine(current_data, time(6, 0)) + timedelta(hours=8)
+ end_time5 = datetime.combine(current_data, time(9, 0)) + timedelta(hours=8)
if checkin_time:
- if start_time<= checkin_time <=end_time and not attendance_obj.check_in and planning_id.template_id.planning_name == '白班':
+ planning_name = planning_id.template_id.planning_name
+ if start_time <= checkin_time <= end_time and planning_name == '白班':
attendance_obj.sudo().write({
"check_in": checkin_time,
"is_late_card": checkin_time > planning_start_time
})
- elif start_time1<= checkin_time <=end_time1 and not attendance_obj.check_out and planning_id.template_id.planning_name == '白班':
- attendance_obj.sudo().write({
- "check_out": checkin_time,
- "is_early_card": planning_end_time> checkin_time,
- })
- elif start_time2 <= checkin_time <= end_time2 and not attendance_obj.check_in and planning_id.template_id.planning_name == '中班':
- attendance_obj.sudo().write({
- "check_in": checkin_time,
- "is_late_card": checkin_time > planning_start_time
- })
- elif start_time3 <= checkin_time <= end_time3 and not attendance_obj.check_out and planning_id.template_id.planning_name == '中班':
+ elif start_time1 <= checkin_time <= end_time1 and planning_name == '白班':
attendance_obj.sudo().write({
"check_out": checkin_time,
"is_early_card": planning_end_time > checkin_time,
})
- elif start_time4 <= checkin_time <= end_time4 and not attendance_obj.check_in and planning_id.template_id.planning_name == '夜班':
+ elif start_time2 <= checkin_time <= end_time2 and planning_name == '中班':
attendance_obj.sudo().write({
"check_in": checkin_time,
"is_late_card": checkin_time > planning_start_time
})
- elif start_time5 <= checkin_time <= end_time5 and not attendance_obj.check_out and planning_id.template_id.planning_name == '夜班':
+ elif start_time3 <= checkin_time <= end_time3 and planning_name == '中班':
+ attendance_obj.sudo().write({
+ "check_out": checkin_time,
+ "is_early_card": planning_end_time > checkin_time,
+ })
+ elif start_time4 <= checkin_time <= end_time4 and planning_name == '夜班':
+ attendance_obj.sudo().write({
+ "check_in": checkin_time,
+ "is_late_card": checkin_time > planning_start_time
+ })
+ elif start_time5 <= checkin_time <= end_time5 and planning_name == '夜班':
attendance_obj.sudo().write({
"check_out": checkin_time,
"is_early_card": planning_end_time > checkin_time,
@@ -389,107 +404,129 @@ class HrAttendanceDetail(models.Model):
attendance_obj.sudo().write({"is_abnormal": True})
else:
attendance_obj.sudo().write({"is_no_card": True, "is_abnormal": True})
- elif planning_id.role_id.name == '工程部':
- # 白班和白值上班区间
- start_time = datetime.datetime.combine(current_data, datetime.time(7, 0))+ datetime.timedelta(hours=8)
- end_time = datetime.datetime.combine(current_data, datetime.time(10, 0))+ datetime.timedelta(hours=8)
- # 白班和白值下班区间
- start_time1 = datetime.datetime.combine(current_data, datetime.time(16, 0))+ datetime.timedelta(hours=8)
- end_time1 = datetime.datetime.combine(current_data, datetime.time(19, 0))+ datetime.timedelta(hours=8)
- # 白值值班打卡区间
- start_time2 = datetime.datetime.combine(current_data, datetime.time(11,30))+ datetime.timedelta(hours=8)
- end_time2 = datetime.datetime.combine(current_data, datetime.time(13, 30))+ datetime.timedelta(hours=8)
- # 中夜上班区间 中夜下班区间跟白班上班区间一样
- start_time3 = datetime.datetime.combine(current_data, datetime.time(13, 0))+ datetime.timedelta(hours=8)
- end_time3 = datetime.datetime.combine(current_data, datetime.time(16, 0))+ datetime.timedelta(hours=8)
- # 中夜值班打卡区间
- start_time4 = datetime.datetime.combine(current_data, datetime.time(20, 0))+ datetime.timedelta(hours=8)
- end_time4 = datetime.datetime.combine(current_data, datetime.time(23, 0))+ datetime.timedelta(hours=8)
- if planning_id:
- if checkin_time:
- if start_time<= checkin_time <=end_time and not attendance_obj.check_in and (planning_id.template_id.planning_name in ['白班','白值']):
- attendance_obj.sudo().write({
- "check_in": checkin_time,
- "is_late_card": checkin_time > planning_start_time
- })
- elif end_time1<= checkin_time <=start_time1 and not attendance_obj.check_out and (planning_id.template_id.planning_name in ['白班','白值']):
- attendance_obj.sudo().write({
- "check_out": checkin_time,
- "is_early_card": planning_end_time > checkin_time,
- })
- elif start_time3<= checkin_time <=end_time3 and not attendance_obj.check_in and planning_id.template_id.planning_name == '中夜':
- attendance_obj.sudo().write({
- "check_in": checkin_time,
- "is_late_card": checkin_time > planning_start_time
- })
- elif start_time<= checkin_time <=end_time and not attendance_obj.check_out and planning_id.template_id.planning_name == '中夜':
- attendance_obj.sudo().write({
- "check_out": checkin_time,
- "is_early_card":checkin_time > planning_start_time
- })
- elif planning_id.template_id.planning == '白值' and start_time2 <= checkin_time <= end_time2:
- attendance_obj.sudo().write({
- "sch_check_out_time": sch_checkin_time,
- "noon_duty": checkin_time,
- })
- elif planning_id.template_id.planning == '中夜' and start_time4 <= checkin_time <= end_time4:
- attendance_obj.sudo().write({
- "sch_check_out_time": sch_checkin_time,
- "night_duty": checkin_time,
- })
- # 异常情况处理,移到所有打卡逻辑之后
- if (attendance_obj.is_early_card or attendance_obj.is_late_card or
- (planning_id.template_id.planning == '白值' and not attendance_obj.noon_duty) or
- (planning_id.template_id.planning == '中夜' and not attendance_obj.night_duty)):
- attendance_obj.sudo().write({"is_abnormal": True})
- else:
- attendance_obj.sudo().write({"is_no_card": True, "is_abnormal": True})
- elif planning_id.role_id.name == '联安粮储':
- # 白班上班区间
- start_time = datetime.datetime.combine(current_data, datetime.time(7, 0))+ datetime.timedelta(hours=8)
- end_time = datetime.datetime.combine(current_data, datetime.time(10, 0))+ datetime.timedelta(hours=8)
- # 白班下班区间
- start_time1 = datetime.datetime.combine(current_data, datetime.time(15, 0))+ datetime.timedelta(hours=8)
- end_time1 = datetime.datetime.combine(current_data, datetime.time(18, 0))+ datetime.timedelta(hours=8)
- # 白值上班
- start_time2 = datetime.datetime.combine(current_data, datetime.time(8,0 ))+ datetime.timedelta(hours=8)
- end_time2 = datetime.datetime.combine(current_data, datetime.time(10, 0))+ datetime.timedelta(hours=8)
- # 白值下班
- start_time4 = datetime.datetime.combine(current_data, datetime.time(4, 0))+ datetime.timedelta(hours=8)
- end_time4 = datetime.datetime.combine(current_data, datetime.time(7, 0))+ datetime.timedelta(hours=8)
- # 白值打卡区间、
- start_time3 = datetime.datetime.combine(current_data, datetime.time(11, 30))+ datetime.timedelta(hours=8)
- end_time3 = datetime.datetime.combine(current_data, datetime.time(13, 30))+ datetime.timedelta(hours=8)
- if planning_id:
- if start_time<= checkin_time <=end_time and not attendance_obj.check_in and planning_id.template_id.planning_name == '白班':
- attendance_obj.sudo().write({
- "check_in": checkin_time,
- "is_late_card": checkin_time > planning_start_time
- })
- elif start_time1<= checkin_time <=end_time1 and not attendance_obj.check_out and planning_id.template_id.planning_name == '白班':
- attendance_obj.sudo().write({
- "check_out": checkin_time,
- "is_early_card": planning_end_time > checkin_time,
- })
- elif start_time2<= checkin_time <=end_time2 and not attendance_obj.check_in and planning_id.template_id.planning_name == '白值':
- attendance_obj.sudo().write({
- "check_in": checkin_time,
- "is_late_card": checkin_time > planning_start_time,
- })
- elif start_time4<= checkin_time <=end_time4 and not attendance_obj.check_out and planning_id.template_id.planning_name == '白值':
- attendance_obj.sudo().write({
- "check_out": checkin_time,
- "is_early_card": planning_end_time > checkin_time,
- })
- elif start_time3<= checkin_time <=end_time3 and planning_id.template_id.planning_name == '白值':
- attendance_obj.sudo().write({
- "noon_duty": checkin_time,
- })
- if (attendance_obj.is_early_card or attendance_obj.is_late_card or
- (planning_id.template_id.planning == '白值班' and not attendance_obj.noon_duty)):
- attendance_obj.sudo().write({"is_abnormal": True})
- else:
- attendance_obj.sudo().write({"is_no_card": True, "is_abnormal": True})
+ # elif planning_id.role_id.name == '工程部':
+ # # 白班和白值上班区间
+ # start_time = datetime.combine(current_data, time(7, 0)) + timedelta(
+ # hours=8)
+ # end_time = datetime.combine(current_data, time(10, 0)) + timedelta(
+ # hours=8)
+ # # 白班和白值下班区间
+ # start_time1 = datetime.combine(current_data,
+ # time(16, 0)) + timedelta(hours=8)
+ # end_time1 = datetime.combine(current_data, time(19, 0)) + timedelta(
+ # hours=8)
+ # # 白值值班打卡区间
+ # start_time2 = datetime.combine(current_data,
+ # time(11, 30)) + timedelta(hours=8)
+ # end_time2 = datetime.combine(current_data, time(13, 30)) + timedelta(
+ # hours=8)
+ # # 中夜上班区间 中夜下班区间跟白班上班区间一样
+ # start_time3 = datetime.combine(current_data,
+ # time(13, 0)) + timedelta(hours=8)
+ # end_time3 = datetime.combine(current_data, time(16, 0)) + timedelta(
+ # hours=8)
+ # # 中夜值班打卡区间
+ # start_time4 = datetime.combine(current_data,
+ # time(20, 0)) + timedelta(hours=8)
+ # end_time4 = datetime.combine(current_data, time(23, 0)) + timedelta(
+ # hours=8)
+ # if planning_id:
+ # if checkin_time:
+ # if start_time <= checkin_time <= end_time and not attendance_obj.check_in and (
+ # planning_name in ['白班', '白值']):
+ # attendance_obj.sudo().write({
+ # "check_in": checkin_time,
+ # "is_late_card": checkin_time > planning_start_time
+ # })
+ # elif end_time1 <= checkin_time <= start_time1 and not attendance_obj.check_out and (
+ # planning_name in ['白班', '白值']):
+ # attendance_obj.sudo().write({
+ # "check_out": checkin_time,
+ # "is_early_card": planning_end_time > checkin_time,
+ # })
+ # elif start_time3 <= checkin_time <= end_time3 and not attendance_obj.check_in and planning_name == '中夜':
+ # attendance_obj.sudo().write({
+ # "check_in": checkin_time,
+ # "is_late_card": checkin_time > planning_start_time
+ # })
+ # elif start_time <= checkin_time <= end_time and not attendance_obj.check_out and planning_name == '中夜':
+ # attendance_obj.sudo().write({
+ # "check_out": checkin_time,
+ # "is_early_card": checkin_time > planning_start_time
+ # })
+ # elif planning_id.template_id.planning == '白值' and start_time2 <= checkin_time <= end_time2:
+ # attendance_obj.sudo().write({
+ # "sch_check_out_time": sch_checkin_time,
+ # "noon_duty": checkin_time,
+ # })
+ # elif planning_id.template_id.planning == '中夜' and start_time4 <= checkin_time <= end_time4:
+ # attendance_obj.sudo().write({
+ # "sch_check_out_time": sch_checkin_time,
+ # "night_duty": checkin_time,
+ # })
+ # # 异常情况处理,移到所有打卡逻辑之后
+ # if (attendance_obj.is_early_card or attendance_obj.is_late_card or
+ # (planning_id.template_id.planning == '白值' and not attendance_obj.noon_duty) or
+ # (planning_id.template_id.planning == '中夜' and not attendance_obj.night_duty)):
+ # attendance_obj.sudo().write({"is_abnormal": True})
+ # else:
+ # attendance_obj.sudo().write({"is_no_card": True, "is_abnormal": True})
+ # elif planning_id.role_id.name == '联安粮储':
+ # # 白班上班区间
+ # start_time = datetime.combine(current_data, time(7, 0)) + timedelta(
+ # hours=8)
+ # end_time = datetime.combine(current_data, time(10, 0)) + timedelta(
+ # hours=8)
+ # # 白班下班区间
+ # start_time1 = datetime.combine(current_data,
+ # time(15, 0)) + timedelta(hours=8)
+ # end_time1 = datetime.combine(current_data, time(18, 0)) + timedelta(
+ # hours=8)
+ # # 白值上班
+ # start_time2 = datetime.combine(current_data, time(8, 0)) + timedelta(
+ # hours=8)
+ # end_time2 = datetime.combine(current_data, time(10, 0)) + timedelta(
+ # hours=8)
+ # # 白值下班
+ # start_time4 = datetime.combine(current_data, time(4, 0)) + timedelta(
+ # hours=8)
+ # end_time4 = datetime.combine(current_data, time(7, 0)) + timedelta(
+ # hours=8)
+ # # 白值打卡区间、
+ # start_time3 = datetime.combine(current_data,
+ # time(11, 30)) + timedelta(hours=8)
+ # end_time3 = datetime.combine(current_data, time(13, 30)) + timedelta(
+ # hours=8)
+ # if planning_id:
+ # if start_time <= checkin_time <= end_time and not attendance_obj.check_in and planning_name == '白班':
+ # attendance_obj.sudo().write({
+ # "check_in": checkin_time,
+ # "is_late_card": checkin_time > planning_start_time
+ # })
+ # elif start_time1 <= checkin_time <= end_time1 and not attendance_obj.check_out and planning_name == '白班':
+ # attendance_obj.sudo().write({
+ # "check_out": checkin_time,
+ # "is_early_card": planning_end_time > checkin_time,
+ # })
+ # elif start_time2 <= checkin_time <= end_time2 and not attendance_obj.check_in and planning_name == '白值':
+ # attendance_obj.sudo().write({
+ # "check_in": checkin_time,
+ # "is_late_card": checkin_time > planning_start_time,
+ # })
+ # elif start_time4 <= checkin_time <= end_time4 and not attendance_obj.check_out and planning_name == '白值':
+ # attendance_obj.sudo().write({
+ # "check_out": checkin_time,
+ # "is_early_card": planning_end_time > checkin_time,
+ # })
+ # elif start_time3 <= checkin_time <= end_time3 and planning_name == '白值':
+ # attendance_obj.sudo().write({
+ # "noon_duty": checkin_time,
+ # })
+ # if (attendance_obj.is_early_card or attendance_obj.is_late_card or
+ # (planning_id.template_id.planning == '白值班' and not attendance_obj.noon_duty)):
+ # attendance_obj.sudo().write({"is_abnormal": True})
+ # else:
+ # attendance_obj.sudo().write({"is_no_card": True, "is_abnormal": True})
# 进行关联
attendance_detail_obj.hr_attendance_id = attendance_obj.id
return True
@@ -508,13 +545,17 @@ class HrAttendanceDetail(models.Model):
attendance_data = self._get_wx_attendance_data(userid_limit)
attendance_result, response = self.sudo().env["wecom.apps"].sync_checkin_data(attendance_data)
except Exception as e:
- _logger.error('获取企业微信的打卡信息失败,异常:{0},用户列表{1},异常详情:{2}'.format(str(e), str(userid_limit), str(traceback.format_exc())))
+ _logger.error(
+ '获取企业微信的打卡信息失败,异常:{0},用户列表{1},异常详情:{2}'.format(str(e), str(userid_limit),
+ str(traceback.format_exc())))
continue
# 检查请求返回的信息是否正确
try:
checkin_data = self._check_wx_attendance_data(response, userid_limit)
except Exception as e:
- _logger.error('检查请求返回的信息失败,异常:{0},用户列表{1},异常详情:{2}'.format(str(e), str(userid_limit), str(traceback.format_exc())))
+ _logger.error(
+ '检查请求返回的信息失败,异常:{0},用户列表{1},异常详情:{2}'.format(str(e), str(userid_limit),
+ str(traceback.format_exc())))
continue
# 将原始数据存储
for data in checkin_data:
@@ -522,13 +563,17 @@ class HrAttendanceDetail(models.Model):
try:
checkin_time, sch_checkin_time = self._check_wx_attendance_time(data, userid_limit)
except Exception as e:
- _logger.error('检查保存之前的数据分析出想要的数据失败,异常:{0},数据信息{1},异常详情:{2}'.format(str(e), str(data), str(traceback.format_exc())))
+ _logger.error(
+ '检查保存之前的数据分析出想要的数据失败,异常:{0},数据信息{1},异常详情:{2}'.format(str(e),
+ str(data),
+ str(traceback.format_exc())))
continue
# 保存相关的企业微信的原始打卡信息
try:
self._save_wx_attendance_detail_data(data, checkin_time, sch_checkin_time)
except Exception as e:
- _logger.error('保存相关的企业微信的原始打卡信息失败,异常:{0},数据信息{1},异常详情:{2}'.format(str(e), str(data), str(traceback.format_exc())))
+ _logger.error(
+ '保存相关的企业微信的原始打卡信息失败,异常:{0},数据信息{1},异常详情:{2}'.format(str(e),
+ str(data),
+ str(traceback.format_exc())))
return True
-
-