预览xls文件优化
This commit is contained in:
1 parent
ac04409e79
commit
df539f4ac1
8 files changed
+402
-43
No files matched your search
@@ -166,8 +166,22 @@ class OALeaveWorkflowService:
|
||||
'employee_id': matched['employeeId'],
|
||||
'user_id': matched['uid'],
|
||||
'name': matched['name'],
|
||||
'jobtitle': matched.get('jobtitle', ''),
|
||||
'jobtitleName': matched.get('jobtitleName', ''),
|
||||
'departmentid': matched.get('departmentid', ''),
|
||||
'departmentName': matched.get('departmentName', ''),
|
||||
'subcompanyid1': matched.get('subcompanyid1', ''),
|
||||
'subcompanyName': matched.get('subcompanyName', ''),
|
||||
}
|
||||
|
||||
@staticmethod
|
||||
def _pick_browser_field_value(*values: Any) -> str:
|
||||
for value in values:
|
||||
text = ('' if value is None else str(value)).strip()
|
||||
if text:
|
||||
return text
|
||||
return ''
|
||||
|
||||
@classmethod
|
||||
def _build_get_template_body(cls, workflow_id: str, oa_user_id: str) -> ET.Element:
|
||||
root = ET.Element(f'{{{SERVICE_NS}}}getCreateWorkflowRequestInfo')
|
||||
@@ -301,6 +315,44 @@ class OALeaveWorkflowService:
|
||||
cls._set_field(request_info, 'sqrgh', value=applicant['employee_id'])
|
||||
cls._set_field(request_info, 'tdrxm', value=filler['user_id'], show_value=filler['name'])
|
||||
cls._set_field(request_info, 'sqrxm', value=applicant['user_id'], show_value=applicant['name'])
|
||||
|
||||
filler_jobtitle = cls._pick_browser_field_value(filler.get('jobtitle'), form_data.get('fillerJobTitle'))
|
||||
filler_jobtitle_name = cls._pick_browser_field_value(filler.get('jobtitleName'))
|
||||
filler_department = cls._pick_browser_field_value(filler.get('departmentid'), form_data.get('fillerDepartmentId'))
|
||||
filler_department_name = cls._pick_browser_field_value(filler.get('departmentName'))
|
||||
filler_subcompany = cls._pick_browser_field_value(filler.get('subcompanyid1'), form_data.get('fillerSubCompanyId1'))
|
||||
filler_subcompany_name = cls._pick_browser_field_value(filler.get('subcompanyName'))
|
||||
applicant_jobtitle = cls._pick_browser_field_value(applicant.get('jobtitle'), form_data.get('applicantJobTitle'))
|
||||
applicant_jobtitle_name = cls._pick_browser_field_value(applicant.get('jobtitleName'))
|
||||
applicant_department = cls._pick_browser_field_value(applicant.get('departmentid'), form_data.get('applicantDepartmentId'))
|
||||
applicant_department_name = cls._pick_browser_field_value(applicant.get('departmentName'))
|
||||
applicant_subcompany = cls._pick_browser_field_value(applicant.get('subcompanyid1'), form_data.get('applicantSubCompanyId1'))
|
||||
applicant_subcompany_name = cls._pick_browser_field_value(applicant.get('subcompanyName'))
|
||||
|
||||
try:
|
||||
from app.services.oa_sqlserver import OASQLServerService
|
||||
if filler_jobtitle and not filler_jobtitle_name:
|
||||
filler_jobtitle_name = OASQLServerService.get_jobtitle_name(filler_jobtitle)
|
||||
if filler_department and not filler_department_name:
|
||||
filler_department_name = OASQLServerService.get_department_name(filler_department)
|
||||
if filler_subcompany and not filler_subcompany_name:
|
||||
filler_subcompany_name = OASQLServerService.get_subcompany_name(filler_subcompany)
|
||||
if applicant_jobtitle and not applicant_jobtitle_name:
|
||||
applicant_jobtitle_name = OASQLServerService.get_jobtitle_name(applicant_jobtitle)
|
||||
if applicant_department and not applicant_department_name:
|
||||
applicant_department_name = OASQLServerService.get_department_name(applicant_department)
|
||||
if applicant_subcompany and not applicant_subcompany_name:
|
||||
applicant_subcompany_name = OASQLServerService.get_subcompany_name(applicant_subcompany)
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
cls._set_field(request_info, 'tdrzw', value=filler_jobtitle, show_value=filler_jobtitle_name or filler_jobtitle or '暂无')
|
||||
cls._set_field(request_info, 'tdrbm', value=filler_department, show_value=filler_department_name or filler_department or '暂无')
|
||||
cls._set_field(request_info, 'tdrgs', value=filler_subcompany, show_value=filler_subcompany_name or filler_subcompany or '暂无')
|
||||
cls._set_field(request_info, 'sqrzw', value=applicant_jobtitle, show_value=applicant_jobtitle_name or applicant_jobtitle or '暂无')
|
||||
cls._set_field(request_info, 'sqrbm', value=applicant_department, show_value=applicant_department_name or applicant_department or '暂无')
|
||||
cls._set_field(request_info, 'sqrgs', value=applicant_subcompany, show_value=applicant_subcompany_name or applicant_subcompany or '暂无')
|
||||
|
||||
cls._set_field(request_info, 'dlrgh', value=agent['employee_id'])
|
||||
cls._set_field(request_info, 'dlrxm', value=agent['user_id'], show_value=agent['name'])
|
||||
cls._set_field(request_info, 'dlrlogid', value=agent['user_id'], show_value=agent['user_id'])
|
||||
|
||||
@@ -62,10 +62,16 @@ class OASQLServerService:
|
||||
# Fetch page
|
||||
# Compatible with older SQL Server versions (2008/2012)
|
||||
query_sql = """
|
||||
SELECT id, workcode, lastname
|
||||
SELECT v.id, v.workcode, v.lastname, v.jobtitle, v.departmentid, v.subcompanyid1,
|
||||
d.departmentname, s.subcompanyname, j.jobtitlename
|
||||
FROM (
|
||||
SELECT id, workcode, lastname, ROW_NUMBER() OVER(ORDER BY id) as rn
|
||||
FROM userInfo_view
|
||||
SELECT v.id, v.workcode, v.lastname, v.jobtitle, v.departmentid, v.subcompanyid1,
|
||||
d.departmentname, s.subcompanyname, j.jobtitlename,
|
||||
ROW_NUMBER() OVER(ORDER BY v.id) as rn
|
||||
FROM userInfo_view v
|
||||
LEFT JOIN HrmDepartment d ON v.departmentid = d.id
|
||||
LEFT JOIN HrmSubCompany s ON v.subcompanyid1 = s.id
|
||||
LEFT JOIN HrmJobTitles j ON v.jobtitle = j.id
|
||||
WHERE 1=1
|
||||
"""
|
||||
if keyword:
|
||||
@@ -82,9 +88,15 @@ class OASQLServerService:
|
||||
items = []
|
||||
for row in cursor.fetchall():
|
||||
items.append({
|
||||
"uid": str(row.id),
|
||||
"employeeId": str(row.workcode),
|
||||
"name": str(row.lastname)
|
||||
"uid": str(row.id) if row.id is not None else "",
|
||||
"employeeId": str(row.workcode) if row.workcode is not None else "",
|
||||
"name": str(row.lastname) if row.lastname is not None else "",
|
||||
"jobtitle": str(row.jobtitle) if row.jobtitle is not None else "",
|
||||
"departmentid": str(row.departmentid) if row.departmentid is not None else "",
|
||||
"subcompanyid1": str(row.subcompanyid1) if row.subcompanyid1 is not None else "",
|
||||
"departmentName": str(row.departmentname).strip() if row.departmentname else "",
|
||||
"subcompanyName": str(row.subcompanyname).strip() if row.subcompanyname else "",
|
||||
"jobtitleName": str(row.jobtitlename).strip() if row.jobtitlename else "",
|
||||
})
|
||||
|
||||
return {
|
||||
@@ -110,10 +122,14 @@ class OASQLServerService:
|
||||
raise RuntimeError("缺少姓名或工号,无法查询 OA 用户")
|
||||
|
||||
query_sql = """
|
||||
SELECT TOP 1 id, workcode, lastname
|
||||
FROM userInfo_view
|
||||
WHERE workcode = ? AND lastname = ?
|
||||
ORDER BY id
|
||||
SELECT TOP 1 v.id, v.workcode, v.lastname, v.jobtitle, v.departmentid, v.subcompanyid1,
|
||||
d.departmentname, s.subcompanyname, j.jobtitlename
|
||||
FROM userInfo_view v
|
||||
LEFT JOIN HrmDepartment d ON v.departmentid = d.id
|
||||
LEFT JOIN HrmSubCompany s ON v.subcompanyid1 = s.id
|
||||
LEFT JOIN HrmJobTitles j ON v.jobtitle = j.id
|
||||
WHERE v.workcode = ? AND v.lastname = ?
|
||||
ORDER BY v.id
|
||||
"""
|
||||
cursor.execute(query_sql, [normalized_employee_id, normalized_name])
|
||||
row = cursor.fetchone()
|
||||
@@ -121,12 +137,75 @@ class OASQLServerService:
|
||||
return None
|
||||
|
||||
return {
|
||||
"uid": str(row.id),
|
||||
"employeeId": str(row.workcode),
|
||||
"name": str(row.lastname),
|
||||
"uid": str(row.id) if row.id is not None else "",
|
||||
"employeeId": str(row.workcode) if row.workcode is not None else "",
|
||||
"name": str(row.lastname) if row.lastname is not None else "",
|
||||
"jobtitle": str(row.jobtitle) if row.jobtitle is not None else "",
|
||||
"departmentid": str(row.departmentid) if row.departmentid is not None else "",
|
||||
"subcompanyid1": str(row.subcompanyid1) if row.subcompanyid1 is not None else "",
|
||||
"departmentName": str(row.departmentname).strip() if row.departmentname else "",
|
||||
"subcompanyName": str(row.subcompanyname).strip() if row.subcompanyname else "",
|
||||
"jobtitleName": str(row.jobtitlename).strip() if row.jobtitlename else "",
|
||||
}
|
||||
finally:
|
||||
try:
|
||||
cursor.close()
|
||||
finally:
|
||||
connection.close()
|
||||
|
||||
@classmethod
|
||||
def get_department_name(cls, department_id: str) -> str:
|
||||
if not department_id or not department_id.strip():
|
||||
return ""
|
||||
connection = cls._connect()
|
||||
cursor = connection.cursor()
|
||||
try:
|
||||
cursor.execute(
|
||||
"SELECT TOP 1 departmentname FROM HrmDepartment WHERE id = ?",
|
||||
[department_id.strip()],
|
||||
)
|
||||
row = cursor.fetchone()
|
||||
return str(row.departmentname).strip() if row and row.departmentname else ""
|
||||
finally:
|
||||
try:
|
||||
cursor.close()
|
||||
finally:
|
||||
connection.close()
|
||||
|
||||
@classmethod
|
||||
def get_subcompany_name(cls, subcompany_id: str) -> str:
|
||||
if not subcompany_id or not subcompany_id.strip():
|
||||
return ""
|
||||
connection = cls._connect()
|
||||
cursor = connection.cursor()
|
||||
try:
|
||||
cursor.execute(
|
||||
"SELECT TOP 1 subcompanyname FROM HrmSubCompany WHERE id = ?",
|
||||
[subcompany_id.strip()],
|
||||
)
|
||||
row = cursor.fetchone()
|
||||
return str(row.subcompanyname).strip() if row and row.subcompanyname else ""
|
||||
finally:
|
||||
try:
|
||||
cursor.close()
|
||||
finally:
|
||||
connection.close()
|
||||
|
||||
@classmethod
|
||||
def get_jobtitle_name(cls, jobtitle_id: str) -> str:
|
||||
if not jobtitle_id or not jobtitle_id.strip():
|
||||
return ""
|
||||
connection = cls._connect()
|
||||
cursor = connection.cursor()
|
||||
try:
|
||||
cursor.execute(
|
||||
"SELECT TOP 1 jobtitlename FROM HrmJobTitles WHERE id = ?",
|
||||
[jobtitle_id.strip()],
|
||||
)
|
||||
row = cursor.fetchone()
|
||||
return str(row.jobtitlename).strip() if row and row.jobtitlename else ""
|
||||
finally:
|
||||
try:
|
||||
cursor.close()
|
||||
finally:
|
||||
connection.close()
|
||||
Reference in new issue
Block a user