|
@@ -156,6 +156,8 @@ async def update_contact(
|
|
|
if 'telephone' in body:
|
|
|
person.telephone=body['telephone']
|
|
|
person.order_num = body['order_num']
|
|
|
+ if body['order_num']=='':
|
|
|
+ person.order_num = -1
|
|
|
person.unit_id = db_dept.get_dept_id_by_name(db, body['unit_name'])
|
|
|
type_list = body['type_list']
|
|
|
old_person_type_list=get_person_type_by_person_id(db,person.id)
|
|
@@ -283,6 +285,10 @@ async def get_emergency_contact_list(
|
|
|
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,[])
|
|
|
+ if info.order_num ==-1:
|
|
|
+ order_num = ''
|
|
|
+ else:
|
|
|
+ order_num = str(info.order_num)
|
|
|
contact_infos_list.append({
|
|
|
"id": info.id,
|
|
|
"unit_id": info.unit_id,
|
|
@@ -294,7 +300,7 @@ async def get_emergency_contact_list(
|
|
|
"position": info.position,
|
|
|
"phone": info.phone,
|
|
|
"telephone":info.telephone,
|
|
|
- "order_num":info.order_num,
|
|
|
+ "order_num": order_num,
|
|
|
"online_status":'0',
|
|
|
"create_time": info.create_time.strftime('%Y-%m-%d %H:%M:%S'),
|
|
|
"create_by":info.create_by,
|
|
@@ -334,6 +340,10 @@ async def get_emergency_contact_id_info(
|
|
|
user_info = user_id_get_user_info(db,contact.create_by)
|
|
|
|
|
|
area_list = db_area.id_get_area_parent_list(db, contact.area_code, [])
|
|
|
+ if contact.order_num == -1:
|
|
|
+ order_num = ''
|
|
|
+ else:
|
|
|
+ order_num = str(contact.order_num)
|
|
|
contact_result = {
|
|
|
"id": contact.id,
|
|
|
"unit_id": contact.unit_id,
|
|
@@ -345,7 +355,7 @@ async def get_emergency_contact_id_info(
|
|
|
"position": contact.position,
|
|
|
"phone": contact.phone,
|
|
|
"telephone":contact.telephone,
|
|
|
- "order_num":contact.order_num,
|
|
|
+ "order_num":order_num,
|
|
|
"online_status":'0',
|
|
|
"create_time": contact.create_time.strftime('%Y-%m-%d %H:%M:%S'),
|
|
|
"create_by":contact.create_by,
|
|
@@ -469,7 +479,7 @@ def string_type_parent_id_create_data(db,string,type_parent_id,file_info,new_per
|
|
|
type_name_list = [i for i in string.split(',')]
|
|
|
reslte = []
|
|
|
for type_name in type_name_list:
|
|
|
- type_id = get_type_id_by_type_parent_id_and_type_name(db, '1', type_name)
|
|
|
+ type_id = get_type_id_by_type_parent_id_and_type_name(db, type_parent_id, type_name)
|
|
|
if type_id:
|
|
|
new_person_type = ThreeProofingResponsiblePersonType(
|
|
|
type_parent_id=type_parent_id,
|
|
@@ -482,6 +492,23 @@ def string_type_parent_id_create_data(db,string,type_parent_id,file_info,new_per
|
|
|
file_info.remark= file_info.remark+f'\n行<{row+1}>责任类别未找到<{type_name}>'
|
|
|
return reslte ,False
|
|
|
return reslte ,True
|
|
|
+def other_type_string_type_parent_id_create_data(db,string,type_parent_id,file_info,new_person,user_id,row) :
|
|
|
+ type_name_list = [i for i in string.split(',')]
|
|
|
+ reslte = []
|
|
|
+ for other_type_name in type_name_list:
|
|
|
+ other_type_id = get_type_id_by_type_parent_id_and_type_name(db, type_parent_id, other_type_name)
|
|
|
+ if other_type_id:
|
|
|
+ new_person_type = ThreeProofingResponsiblePersonOtherType(
|
|
|
+ type_parent_id=type_parent_id,
|
|
|
+ other_type_id=other_type_id,
|
|
|
+ person_id=new_person.id,
|
|
|
+ create_by=user_id
|
|
|
+ )
|
|
|
+ reslte.append(new_person_type)
|
|
|
+ else:
|
|
|
+ file_info.remark= file_info.remark+f'\n行<{row+1}>责任类别未找到<{other_type_name}>'
|
|
|
+ return reslte ,False
|
|
|
+ return reslte ,True
|
|
|
def import_data(db,file_path,user_id,file_info):
|
|
|
book = xlrd.open_workbook(file_path)
|
|
|
sheet = book.sheet_by_index(0)
|
|
@@ -559,7 +586,7 @@ def import_data(db,file_path,user_id,file_info):
|
|
|
# 党委政府
|
|
|
a1 = sheet.cell(row, 6).value
|
|
|
if a1 != '':
|
|
|
- new_type_list,status = string_type_parent_id_create_data(db,a1,'1',file_info,new_person,user_id)
|
|
|
+ new_type_list,status = string_type_parent_id_create_data(db,a1,'1',file_info,new_person,user_id,row)
|
|
|
import_status = status
|
|
|
if status:
|
|
|
db.add_all(new_type_list)
|
|
@@ -572,7 +599,7 @@ def import_data(db,file_path,user_id,file_info):
|
|
|
# 三防指挥部
|
|
|
b1 = sheet.cell(row, 8).value
|
|
|
if b1 != '':
|
|
|
- new_type_list,status = string_type_parent_id_create_data(db,b1,'2',file_info,new_person,user_id)
|
|
|
+ new_type_list,status = string_type_parent_id_create_data(db,b1,'2',file_info,new_person,user_id,row)
|
|
|
import_status = status
|
|
|
if status:
|
|
|
db.add_all(new_type_list)
|
|
@@ -583,7 +610,7 @@ def import_data(db,file_path,user_id,file_info):
|
|
|
# 应急部门
|
|
|
c1 = sheet.cell(row, 10).value
|
|
|
if c1!='':
|
|
|
- new_type_list, status = string_type_parent_id_create_data(db, c1, '3', file_info, new_person, user_id)
|
|
|
+ new_type_list, status = string_type_parent_id_create_data(db, c1, '3', file_info, new_person, user_id,row)
|
|
|
import_status = status
|
|
|
if status:
|
|
|
db.add_all(new_type_list)
|
|
@@ -591,7 +618,7 @@ def import_data(db,file_path,user_id,file_info):
|
|
|
# 成员单位
|
|
|
d1 = sheet.cell(row, 11).value
|
|
|
if d1!='':
|
|
|
- new_type_list, status = string_type_parent_id_create_data(db, d1, '4', file_info, new_person, user_id)
|
|
|
+ new_type_list, status = string_type_parent_id_create_data(db, d1, '4', file_info, new_person, user_id,row)
|
|
|
import_status = status
|
|
|
if status:
|
|
|
db.add_all(new_type_list)
|
|
@@ -603,18 +630,24 @@ def import_data(db,file_path,user_id,file_info):
|
|
|
# 重点部门
|
|
|
e1 = sheet.cell(row, 13).value
|
|
|
if e1!='':
|
|
|
- new_type_list, status = string_type_parent_id_create_data(db, e1, '5', file_info, new_person, user_id)
|
|
|
+ new_type_list, status = string_type_parent_id_create_data(db, e1, '5', file_info, new_person, user_id,row)
|
|
|
import_status = status
|
|
|
if status:
|
|
|
db.add_all(new_type_list)
|
|
|
data += new_type_list
|
|
|
e2 = sheet.cell(row, 14).value
|
|
|
e3 = sheet.cell(row, 15).value
|
|
|
+ if e3!='':
|
|
|
+ new_type_list,status = other_type_string_type_parent_id_create_data(db,e3,'5',file_info,new_person,user_id,row)
|
|
|
+ import_status = status
|
|
|
+ if status:
|
|
|
+ db.add_all(new_type_list)
|
|
|
+ data +=new_type_list
|
|
|
|
|
|
# 行政村
|
|
|
f1 = sheet.cell(row, 16).value
|
|
|
if f1!='':
|
|
|
- new_type_list, status = string_type_parent_id_create_data(db, f1, '6', file_info, new_person, user_id)
|
|
|
+ new_type_list, status = string_type_parent_id_create_data(db, f1, '6', file_info, new_person, user_id,row)
|
|
|
import_status = status
|
|
|
if status:
|
|
|
db.add_all(new_type_list)
|
|
@@ -623,18 +656,25 @@ def import_data(db,file_path,user_id,file_info):
|
|
|
# 水利工程
|
|
|
g1 = sheet.cell(row, 10).value
|
|
|
if g1!='':
|
|
|
- new_type_list, status = string_type_parent_id_create_data(db, g1, '7', file_info, new_person, user_id)
|
|
|
+ new_type_list, status = string_type_parent_id_create_data(db, g1, '7', file_info, new_person, user_id,row)
|
|
|
import_status = status
|
|
|
if status:
|
|
|
db.add_all(new_type_list)
|
|
|
data += new_type_list
|
|
|
g2 = sheet.cell(row, 11).value
|
|
|
g3 = sheet.cell(row, 12).value
|
|
|
+ if g3!='':
|
|
|
+ new_type_list, status = other_type_string_type_parent_id_create_data(db, g3, '11', file_info, new_person, user_id,
|
|
|
+ row)
|
|
|
+ import_status = status
|
|
|
+ if status:
|
|
|
+ db.add_all(new_type_list)
|
|
|
+ data += new_type_list
|
|
|
|
|
|
# 受威胁转移
|
|
|
h1 = sheet.cell(row, 13).value
|
|
|
if h1!='':
|
|
|
- new_type_list, status = string_type_parent_id_create_data(db, h1, '8', file_info, new_person, user_id)
|
|
|
+ new_type_list, status = string_type_parent_id_create_data(db, h1, '8', file_info, new_person, user_id,row)
|
|
|
import_status = status
|
|
|
if status:
|
|
|
db.add_all(new_type_list)
|
|
@@ -643,32 +683,46 @@ def import_data(db,file_path,user_id,file_info):
|
|
|
# 抢险队伍
|
|
|
j1 = sheet.cell(row, 14).value
|
|
|
if j1!='':
|
|
|
- new_type_list, status = string_type_parent_id_create_data(db, j1, '9', file_info, new_person, user_id)
|
|
|
+ new_type_list, status = string_type_parent_id_create_data(db, j1, '9', file_info, new_person, user_id,row)
|
|
|
import_status = status
|
|
|
if status:
|
|
|
db.add_all(new_type_list)
|
|
|
data += new_type_list
|
|
|
j2 = sheet.cell(row, 15).value
|
|
|
-
|
|
|
+ if j2!='':
|
|
|
+ new_type_list, status = other_type_string_type_parent_id_create_data(db, j2, '9', file_info, new_person, user_id,
|
|
|
+ row)
|
|
|
+ import_status = status
|
|
|
+ if status:
|
|
|
+ db.add_all(new_type_list)
|
|
|
+ data += new_type_list
|
|
|
# 地质灾害
|
|
|
k1 = sheet.cell(row, 16).value
|
|
|
if k1!='':
|
|
|
- new_type_list, status = string_type_parent_id_create_data(db, k1, '10', file_info, new_person, user_id)
|
|
|
+ new_type_list, status = string_type_parent_id_create_data(db, k1, '10', file_info, new_person, user_id,row)
|
|
|
import_status = status
|
|
|
if status:
|
|
|
db.add_all(new_type_list)
|
|
|
data += new_type_list
|
|
|
k2 = sheet.cell(row, 17).value
|
|
|
|
|
|
+
|
|
|
# 其他
|
|
|
l1 = sheet.cell(row, 18).value
|
|
|
if l1!='':
|
|
|
- new_type_list, status = string_type_parent_id_create_data(db, l1, '11', file_info, new_person, user_id)
|
|
|
+ new_type_list, status = string_type_parent_id_create_data(db, l1, '11', file_info, new_person, user_id,row)
|
|
|
import_status = status
|
|
|
if status:
|
|
|
db.add_all(new_type_list)
|
|
|
data += new_type_list
|
|
|
l2 = sheet.cell(row, 19).value
|
|
|
+ if l2!='':
|
|
|
+ new_type_list, status = other_type_string_type_parent_id_create_data(db, l2, '11', file_info, new_person, user_id,
|
|
|
+ row)
|
|
|
+ import_status = status
|
|
|
+ if status:
|
|
|
+ db.add_all(new_type_list)
|
|
|
+ data += new_type_list
|
|
|
|
|
|
|
|
|
if import_status == False:
|