添加功能
This commit is contained in:
@@ -30,23 +30,9 @@ class BusController(Controller):
|
||||
|
||||
@route('/api/v1/user/inf_photo', methods=['POST'], type='json', auth='public')
|
||||
def get_model_definitions(self):
|
||||
name = request.jsonrequest.get('sn') #设备序列号
|
||||
attendance_iot_id = self.env["attendance.iot"].search([('name', '=', name)])
|
||||
# 创建设备
|
||||
if not attendance_iot_id:
|
||||
self.env["attendance.iot"].create({
|
||||
'name': name,
|
||||
})
|
||||
user_id = request.jsonrequest.get('content')[0]['user_id'] #用户id
|
||||
employee = self.env["hr.employee"].search([('user_id', '=', user_id)])
|
||||
# 判断员工是否绑定多台设备
|
||||
if employee and attendance_iot_id not in employee.attendance_iot_ids.mapped('attendance_iot_id'):
|
||||
employee.write({
|
||||
'attendance_iot_ids': [(0, 0, {
|
||||
'employee_id': employee.id,
|
||||
'attendance_iot_id': attendance_iot_id.id
|
||||
})]
|
||||
})
|
||||
name = request.jsonrequest.get('sn') # 姓名
|
||||
phone = request.jsonrequest.get('content') # 电话
|
||||
print(name, phone)
|
||||
return {
|
||||
"Result": 0,
|
||||
"Msg": "更新成功"
|
||||
@@ -74,19 +60,26 @@ class BusController(Controller):
|
||||
"""
|
||||
data = request.httprequest.json
|
||||
user_name = data.get('name')
|
||||
name = data.get('sn')
|
||||
# validity_period = datetime.strptime(data.get('validity_period'), '%Y-%m-%d').date()
|
||||
employee_id = request.env(user=SUPERUSER_ID)["hr.employee"].search([('name', '=', user_name)])
|
||||
attendance_iot = request.env(user=SUPERUSER_ID)["attendance.iot.manager"]
|
||||
if not attendance_iot.search([('employee_id', '=', employee_id.id), ('attendance_number', '=', data.get('sn'))]):
|
||||
employee_id.write({
|
||||
attendance_iot_id = request.env["attendance.iot"].search([('name', '=', name)])
|
||||
if not attendance_iot_id:
|
||||
request.env["attendance.iot"].create({
|
||||
'name': name,
|
||||
})
|
||||
employee = request.env(user=SUPERUSER_ID)["hr.employee"].search([('name', '=', user_name)])
|
||||
# 判断员工是否绑定多台设备
|
||||
if employee and attendance_iot_id not in employee.attendance_iot_ids.mapped('attendance_iot_id'):
|
||||
employee.write({
|
||||
'image_1920': data.get('photo'),
|
||||
'attendance_iot_ids': [(0, 0, {
|
||||
'employee_id': employee.id,
|
||||
'attendance_address': self.get_equipment_company(data.get('sn')),
|
||||
'attendance_iot_id': attendance_iot_id.id
|
||||
})]
|
||||
})
|
||||
attendance_iot.create({
|
||||
'data_selection': "api",
|
||||
'attendance_number': data.get('sn'),
|
||||
'attendance_address': self.get_equipment_company(data.get('sn')),
|
||||
'employee_id': employee_id.id,
|
||||
})
|
||||
|
||||
|
||||
print("---------------------------------------------测试成功---------------------------------------")
|
||||
return {"Result": 0, "Msg": "添加成功"}
|
||||
|
||||
@@ -97,15 +90,18 @@ class BusController(Controller):
|
||||
:return:
|
||||
"""
|
||||
data = request.httprequest.json
|
||||
user_name = data.get('logs').get('user_id')
|
||||
employee_id = request.env(user=SUPERUSER_ID)["hr.employee"].search([('user_id', '=', user_name.id)])
|
||||
attendance_iot = request.env(user=SUPERUSER_ID)["attendance.iot.datas"]
|
||||
if not attendance_iot.search(
|
||||
[('employee_id', '=', employee_id.id), ('attendance_number', '=', data.get('sn'))]):
|
||||
attendance_iot.create({
|
||||
'attendance_number': data.get('sn'),
|
||||
'attendance_date': data.get('logs').get('recog_time'),
|
||||
user_id = data.get('logs')[0].get('user_id')
|
||||
employee_id = request.env(user=SUPERUSER_ID)["hr.employee"].search([('user_id', '=', user_id.id)])
|
||||
recog_time_str = data.get('logs')[0]["recog_time"]
|
||||
checkin_time = datetime.strptime(recog_time_str, "%Y-%m-%d %H:%M:%S")
|
||||
attendance_iot_id = request.env(user=SUPERUSER_ID)["attendance.iot"].search([('name', '=', data.get('sn'))])
|
||||
if employee_id:
|
||||
request.env(user=SUPERUSER_ID)["hr.attendance.details"].create({
|
||||
'employee_id': employee_id.id,
|
||||
'checkin_time': checkin_time,
|
||||
'source': 'iot',
|
||||
'attendance_iot_id': attendance_iot_id.id,
|
||||
'location_title': data.get('logs')[0]["location"].get('address'),
|
||||
})
|
||||
print("---------------------------------------------测试成功---------------------------------------")
|
||||
return {"Result": 0, "Msg": "添加成功"}
|
||||
|
||||
@@ -40,6 +40,8 @@ class HrAttendanceDetail(models.Model):
|
||||
employee_id = fields.Many2one('hr.employee', string="员工", readonly=True)
|
||||
company_id = fields.Many2one('res.company', string="公司", related="employee_id.company_id", store=True)
|
||||
department_id = fields.Many2one('hr.department', string="部门", related="employee_id.department_id", readonly=True, store=True)
|
||||
source = fields.Selection([('iot', '考勤机'), ('mini_programs', '小程序')], string="来源")
|
||||
attendance_iot_id = fields.Many2one('attendance.iot', string="设备号")
|
||||
userid = fields.Char(string='userid')
|
||||
groupname = fields.Char(string='打卡规则名称')
|
||||
checkin_type = fields.Char(string='打卡类型')
|
||||
|
||||
@@ -37,8 +37,8 @@
|
||||
<field name="employee_id" widget="ztree_select"/>
|
||||
<field name="company_id" optional="hide"/>
|
||||
<field name="department_id" widget="ztree_select"/>
|
||||
<field name="groupname"/>
|
||||
<field name="checkin_type"/>
|
||||
<field name="source"/>
|
||||
<field name="attendance_iot_id"/>
|
||||
<field name="checkin_time"/>
|
||||
<field name="sch_checkin_time"/>
|
||||
</tree>
|
||||
|
||||
Reference in New Issue
Block a user