|
@@ -84,30 +84,36 @@ async def create_contact(
|
|
|
)
|
|
|
db.add(new_person_type)
|
|
|
if type_parent_id in ('5','7','9'):
|
|
|
+ if 'children2' in type_info:
|
|
|
+ for other_type_id in type_info['children2']:
|
|
|
+ new_person_other_type = ThreeProofingResponsiblePersonOtherType(
|
|
|
+ type_parent_id=type_parent_id,
|
|
|
+ other_type_id=other_type_id,
|
|
|
+ person_id=new_person.id,
|
|
|
+ create_by=user_id
|
|
|
+ )
|
|
|
+ db.add(new_person_other_type)
|
|
|
+ if type_parent_id in ('4','5','7','10','11'):
|
|
|
dept_name = None
|
|
|
if 'dept_name' in type_info:
|
|
|
dept_name = type_info['dept_name']
|
|
|
- other_type_id = None
|
|
|
- if 'other_type_id' in type_info:
|
|
|
- other_type_id = type_info['other_type_id']
|
|
|
other_type_2_name = None
|
|
|
if 'other_type_2_name' in type_info:
|
|
|
other_type_2_name = type_info['other_type_2_name']
|
|
|
denger_point_name = None
|
|
|
if 'denger_point_name' in type_info:
|
|
|
denger_point_name = type_info['denger_point_name']
|
|
|
- new_person_other_type = ThreeProofingResponsiblePersonOtherInfo(
|
|
|
+ new_person_other_info = ThreeProofingResponsiblePersonOtherInfo(
|
|
|
type_parent_id = type_parent_id,
|
|
|
dept_name = dept_name,
|
|
|
- other_type_id = other_type_id,
|
|
|
other_type_2_name = other_type_2_name,
|
|
|
denger_point_name = denger_point_name,
|
|
|
person_id = new_person.id,
|
|
|
create_by=user_id
|
|
|
)
|
|
|
- db.add(new_person_other_type)
|
|
|
+ db.add(new_person_other_info)
|
|
|
except:
|
|
|
-
|
|
|
+ db.rollback()
|
|
|
traceback.print_exc()
|
|
|
new_person.del_flag='2'
|
|
|
db.commit()
|
|
@@ -154,7 +160,7 @@ async def update_contact(
|
|
|
old_person_type_list=get_person_type_by_person_id(db,person.id)
|
|
|
for old_person_type in old_person_type_list:
|
|
|
old_person_type.del_flag='2'
|
|
|
- old_person_other_type_list = get_person_other_type_by_person_id(db,person.id)
|
|
|
+ old_person_other_type_list = get_person_other_info_by_person_id(db,person.id)
|
|
|
for old_person_other_type in old_person_other_type_list:
|
|
|
old_person_other_type.del_flag = '2'
|
|
|
for type_info in type_list:
|
|
@@ -168,28 +174,34 @@ async def update_contact(
|
|
|
)
|
|
|
db.add(new_person_type)
|
|
|
if type_parent_id in ('5', '7', '9'):
|
|
|
+ if 'children2' in type_info:
|
|
|
+ for other_type_id in type_info['children2']:
|
|
|
+ new_person_other_type = ThreeProofingResponsiblePersonOtherType(
|
|
|
+ type_parent_id=type_parent_id,
|
|
|
+ other_type_id=other_type_id,
|
|
|
+ person_id=person.id,
|
|
|
+ create_by=user_id
|
|
|
+ )
|
|
|
+ db.add(new_person_other_type)
|
|
|
+ if type_parent_id in ('4', '5', '7', '10', '11'):
|
|
|
dept_name = None
|
|
|
if 'dept_name' in type_info:
|
|
|
dept_name = type_info['dept_name']
|
|
|
- other_type_id = None
|
|
|
- if 'other_type_id' in type_info:
|
|
|
- other_type_id = type_info['other_type_id']
|
|
|
other_type_2_name = None
|
|
|
if 'other_type_2_name' in type_info:
|
|
|
other_type_2_name = type_info['other_type_2_name']
|
|
|
denger_point_name = None
|
|
|
if 'denger_point_name' in type_info:
|
|
|
denger_point_name = type_info['denger_point_name']
|
|
|
- new_person_other_type = ThreeProofingResponsiblePersonOtherInfo(
|
|
|
+ new_person_other_info = ThreeProofingResponsiblePersonOtherInfo(
|
|
|
type_parent_id=type_parent_id,
|
|
|
dept_name=dept_name,
|
|
|
- other_type_id=other_type_id,
|
|
|
other_type_2_name=other_type_2_name,
|
|
|
denger_point_name=denger_point_name,
|
|
|
- person_id=id,
|
|
|
+ person_id=person.id,
|
|
|
create_by=user_id
|
|
|
)
|
|
|
- db.add(new_person_other_type)
|
|
|
+ db.add(new_person_other_info)
|
|
|
# 更新到数据库会话并提交
|
|
|
db.commit()
|
|
|
|
|
@@ -244,16 +256,21 @@ async def get_emergency_contact_list(
|
|
|
for info in contact_infos:
|
|
|
type_parent_id_list = get_type_parent_id_by_person_id(db,info.id)
|
|
|
type_parent_list = []
|
|
|
+ type_parent_list2 = []
|
|
|
for type_parent in type_parent_id_list:
|
|
|
- dict_data = get_dict_data_info(db,'three_proofing',type_parent)
|
|
|
- type_parent_list.append({"type_parent_id":type_parent,"type_parent":dict_data.dict_label})
|
|
|
+ if type_parent not in type_parent_list2:
|
|
|
+ dict_data = get_dict_data_info(db,'three_proofing',type_parent)
|
|
|
+ type_parent_list2.append(type_parent)
|
|
|
+ type_parent_list.append({"type_parent_id":type_parent,"type_parent":dict_data.dict_label})
|
|
|
area_info = id_get_area_info(db,info.area_code)
|
|
|
user_info = user_id_get_user_info(db,info.create_by)
|
|
|
+ area_list = db_area.id_get_area_parent_list(db,info.area_code)
|
|
|
contact_infos_list.append({
|
|
|
"id": info.id,
|
|
|
"unit_id": info.unit_id,
|
|
|
"unit_name": info.unit_name,
|
|
|
"name": info.name,
|
|
|
+ "area_list":area_list,
|
|
|
"area_code": info.area_code,
|
|
|
"area_name": area_info.area_name,
|
|
|
"position": info.position,
|
|
@@ -326,16 +343,21 @@ async def get_emergency_contact_id_info(
|
|
|
type_data = {"type_parent_id": type_parent_id, "type_parent": dict_data.dict_label,"children":[]}
|
|
|
for type_info in get_person_type_by_person_id_and_type_parent_id(db,contact.id,type_parent_id):
|
|
|
type_data_info = get_type_info_by_id(db,type_info.type_id)
|
|
|
- type_data['children'].append({"type_id":type_info.type_id,"type_name":type_data_info.type_name})
|
|
|
- type_other_info = get_person_other_type_by_person_id_and_type_parent_id(db,contact.id,type_parent_id)
|
|
|
- if type_other_info:
|
|
|
- type_data['dept_name']=type_other_info.dept_name
|
|
|
- if type_other_info.other_type_id:
|
|
|
- other_type_info = get_other_type_info_by_id(db,type_other_info.other_type_id)
|
|
|
- type_data['other_type_name'] = other_type_info.type_name
|
|
|
- type_data['other_type_id']=type_other_info.other_type_id
|
|
|
- type_data['1']=type_other_info.denger_point_name
|
|
|
- type_data['other_type_2_name']=type_other_info.other_type_2_name
|
|
|
+ type_data['children'].append({"id": type_info.type_id, "label": type_data_info.type_name})
|
|
|
+ other_info = get_person_other_info_by_person_id_and_type_parent_id(db, contact.id, type_parent_id)
|
|
|
+ if other_info:
|
|
|
+ type_data['dept_name'] = other_info.dept_name
|
|
|
+ type_data['denger_point_name'] = other_info.denger_point_name
|
|
|
+ type_data['other_type_2_name'] = other_info.other_type_2_name
|
|
|
+ other_type_list = get_person_other_type_by_person_id_and_type_parent_id(db, contact.id, type_parent_id)
|
|
|
+ if other_type_list:
|
|
|
+ type_data['children2'] = []
|
|
|
+ for other_type in other_type_list:
|
|
|
+ other_type_info = get_other_type_info_by_id(db, other_type.other_type_id)
|
|
|
+ label= ''
|
|
|
+ if other_type_info:
|
|
|
+ label = other_type_info.type_name
|
|
|
+ type_data['children2'].append({"id": other_type.other_type_id, "label": label})
|
|
|
|
|
|
contact_result['type_list'].append(type_data)
|
|
|
# 返回结果
|