Compare commits
2 Commits
175af3ffff
...
59d26ac08e
| Author | SHA1 | Date | |
|---|---|---|---|
| 59d26ac08e | |||
| 8dc4cb19fc |
@@ -196,6 +196,7 @@ var requestProcessors = map[string]func(*ApiRequestService, []byte) ([]byte, err
|
|||||||
"JRZQ4B6C": (*ApiRequestService).ProcessJRZQ4B6CRequest,
|
"JRZQ4B6C": (*ApiRequestService).ProcessJRZQ4B6CRequest,
|
||||||
"JRZQ09J8": (*ApiRequestService).ProcessJRZQ09J8Request,
|
"JRZQ09J8": (*ApiRequestService).ProcessJRZQ09J8Request,
|
||||||
"JRZQ5E9F": (*ApiRequestService).ProcessJRZQ5E9FRequest,
|
"JRZQ5E9F": (*ApiRequestService).ProcessJRZQ5E9FRequest,
|
||||||
|
"QYGL3F8E": (*ApiRequestService).ProcessQYGL3F8ERequest,
|
||||||
}
|
}
|
||||||
|
|
||||||
// PreprocessRequestApi 调用指定的请求处理函数
|
// PreprocessRequestApi 调用指定的请求处理函数
|
||||||
@@ -1308,6 +1309,7 @@ func (a *ApiRequestService) ProcessJRZQ4B6CRequest(params []byte) ([]byte, error
|
|||||||
"name": name.String(),
|
"name": name.String(),
|
||||||
"id_card": idCard.String(),
|
"id_card": idCard.String(),
|
||||||
"mobile_no": mobile.String(),
|
"mobile_no": mobile.String(),
|
||||||
|
"authorized": "1",
|
||||||
})
|
})
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -1377,6 +1379,33 @@ func (a *ApiRequestService) ProcessJRZQ5E9FRequest(params []byte) ([]byte, error
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
respBytes, err := convertTianyuanResponse(resp)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
// 重新编码为 JSON
|
||||||
|
data, err := json.Marshal(respBytes)
|
||||||
|
if err != nil {
|
||||||
|
return nil, fmt.Errorf("编码修改后的 data 失败: %v", err)
|
||||||
|
}
|
||||||
|
return data, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// ProcessQYGL3F8ERequest 人企关系加强版2
|
||||||
|
func (a *ApiRequestService) ProcessQYGL3F8ERequest(params []byte) ([]byte, error) {
|
||||||
|
idCard := gjson.GetBytes(params, "id_card")
|
||||||
|
if !idCard.Exists() {
|
||||||
|
return nil, errors.New("api请求, QYGL3F8E, 获取相关参数失败")
|
||||||
|
}
|
||||||
|
|
||||||
|
resp, err := a.tianyuanapi.CallInterface("QYGL3F8E", map[string]interface{}{
|
||||||
|
"id_card": idCard.String(),
|
||||||
|
})
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
respBytes, err := convertTianyuanResponse(resp)
|
respBytes, err := convertTianyuanResponse(resp)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
|||||||
@@ -107,34 +107,33 @@ func (s *AuthorizationService) generatePDFContent(userInfo map[string]interface{
|
|||||||
pdf := gofpdf.New("P", "mm", "A4", "")
|
pdf := gofpdf.New("P", "mm", "A4", "")
|
||||||
pdf.AddPage()
|
pdf.AddPage()
|
||||||
|
|
||||||
// 添加中文字体支持 - 使用项目字体文件
|
// 添加中文字体支持 - 参考imageService的路径处理方式
|
||||||
fontPaths := []string{
|
fontPaths := []string{
|
||||||
|
"static/SIMHEI.TTF", // 相对于工作目录的路径(与imageService一致)
|
||||||
"/app/static/SIMHEI.TTF", // Docker容器内的字体文件
|
"/app/static/SIMHEI.TTF", // Docker容器内的字体文件
|
||||||
"../../static/SIMHEI.TTF", // 开发环境字体文件(相对于当前工作目录)
|
"app/main/api/static/SIMHEI.TTF", // 开发环境备用路径
|
||||||
"app/main/api/static/SIMHEI.TTF", // 开发环境字体文件(绝对路径)
|
|
||||||
}
|
}
|
||||||
wd, wdErr := os.Getwd()
|
|
||||||
if wdErr != nil {
|
|
||||||
logx.Errorf("获取工作目录失败: %v", wdErr)
|
|
||||||
}
|
|
||||||
logx.Infof("当前工作目录: %s", wd)
|
|
||||||
// 尝试添加字体
|
// 尝试添加字体
|
||||||
fontAdded := false
|
fontAdded := false
|
||||||
for _, fontPath := range fontPaths {
|
for _, fontPath := range fontPaths {
|
||||||
if _, err := os.Stat(fontPath); err == nil {
|
if _, err := os.Stat(fontPath); err == nil {
|
||||||
pdf.AddUTF8Font("ChineseFont", "", fontPath)
|
pdf.AddUTF8Font("ChineseFont", "", fontPath)
|
||||||
pdf.SetFont("ChineseFont", "", 12)
|
|
||||||
fontAdded = true
|
fontAdded = true
|
||||||
logx.Infof("成功加载字体: %s", fontPath)
|
logx.Infof("成功加载字体: %s", fontPath)
|
||||||
break
|
break
|
||||||
} else {
|
} else {
|
||||||
logx.Debugf("字体文件不存在: %s", fontPath)
|
logx.Debugf("字体文件不存在: %s, 错误: %v", fontPath, err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 如果没有找到字体文件,使用默认字体
|
// 如果没有找到字体文件,使用默认字体,并记录警告
|
||||||
if !fontAdded {
|
if !fontAdded {
|
||||||
pdf.SetFont("Arial", "", 12)
|
pdf.SetFont("Arial", "", 12)
|
||||||
|
logx.Errorf("未找到中文字体文件,使用默认Arial字体,可能无法正确显示中文")
|
||||||
|
} else {
|
||||||
|
// 设置默认字体
|
||||||
|
pdf.SetFont("ChineseFont", "", 12)
|
||||||
}
|
}
|
||||||
|
|
||||||
// 获取用户信息
|
// 获取用户信息
|
||||||
@@ -145,14 +144,22 @@ func (s *AuthorizationService) generatePDFContent(userInfo map[string]interface{
|
|||||||
currentDate := time.Now().Format("2006年1月2日")
|
currentDate := time.Now().Format("2006年1月2日")
|
||||||
|
|
||||||
// 设置标题样式 - 大字体、居中
|
// 设置标题样式 - 大字体、居中
|
||||||
pdf.SetFont("ChineseFont", "", 20) // 使用20号字体
|
if fontAdded {
|
||||||
|
pdf.SetFont("ChineseFont", "", 20) // 使用20号字体
|
||||||
|
} else {
|
||||||
|
pdf.SetFont("Arial", "", 20)
|
||||||
|
}
|
||||||
pdf.CellFormat(0, 15, "授权书", "", 1, "C", false, 0, "")
|
pdf.CellFormat(0, 15, "授权书", "", 1, "C", false, 0, "")
|
||||||
|
|
||||||
// 添加空行
|
// 添加空行
|
||||||
pdf.Ln(5)
|
pdf.Ln(5)
|
||||||
|
|
||||||
// 设置正文样式 - 正常字体
|
// 设置正文样式 - 正常字体
|
||||||
pdf.SetFont("ChineseFont", "", 12)
|
if fontAdded {
|
||||||
|
pdf.SetFont("ChineseFont", "", 12)
|
||||||
|
} else {
|
||||||
|
pdf.SetFont("Arial", "", 12)
|
||||||
|
}
|
||||||
|
|
||||||
// 构建授权书内容(去掉标题部分)
|
// 构建授权书内容(去掉标题部分)
|
||||||
content := fmt.Sprintf(`海南天远大数据科技有限公司:
|
content := fmt.Sprintf(`海南天远大数据科技有限公司:
|
||||||
|
|||||||
Reference in New Issue
Block a user