就诊人列表-导出
This commit is contained in:
@@ -183,6 +183,29 @@ type UserPatientData struct {
|
||||
CreatedAt time.Time // 创建时间
|
||||
}
|
||||
|
||||
// PatientFamilyData 就诊人列表
|
||||
type PatientFamilyData struct {
|
||||
UserName string `json:"user_name"` // 账号名称
|
||||
CardName string `json:"card_name"` // 患者姓名
|
||||
Relation string `json:"relation"` // 与患者关系(1:本人 2:父母 3:爱人 4:子女 5:亲戚 6:其他)
|
||||
Status string `json:"status"` // 状态(1:正常 2:删除)
|
||||
Mobile string `json:"mobile"` // 用户电话
|
||||
IsDefault string `json:"is_default"` // 是否默认(0:否 1:是)
|
||||
Type string `json:"type"` // 身份类型(1:身份证 2:护照 3:港澳通行证 4:台胞证)
|
||||
IdNumber string `json:"id_number"` // 证件号码
|
||||
Sex string `json:"sex"` // 性别(0:未知 1:男 2:女)
|
||||
Age string `json:"age"` // 年龄
|
||||
Province string `json:"province"` // 省份
|
||||
City string `json:"city"` // 城市
|
||||
County string `json:"county"` // 区县
|
||||
Height string `json:"height"` // 身高(cm)
|
||||
Weight string `json:"weight"` // 体重(kg)
|
||||
MaritalStatus string `json:"marital_status"` // 婚姻状况(0:未婚 1:已婚 2:离异)
|
||||
NationName string `json:"nation_name"` // 民族名称
|
||||
JobName string `json:"job_name"` // 职业名称
|
||||
CreatedAt time.Time `json:"created_at"` // 创建时间
|
||||
}
|
||||
|
||||
// DoctorWithdrawal 提现记录
|
||||
func (r *ExportService) DoctorWithdrawal(doctorWithdrawals []*model.DoctorWithdrawal) (string, error) {
|
||||
header := []utils.HeaderCellData{
|
||||
@@ -1094,3 +1117,84 @@ func (r *ExportService) UserPatient(d []*model.UserPatient) (string, error) {
|
||||
ossPath = utils.AddOssDomain("/" + ossPath)
|
||||
return ossPath, nil
|
||||
}
|
||||
|
||||
// PatientFamily 就诊人列表
|
||||
func (r *ExportService) PatientFamily(d []*model.PatientFamily) (string, error) {
|
||||
header := []utils.HeaderCellData{
|
||||
{Value: "账号名称", CellType: "string", NumberFmt: "", ColWidth: 18},
|
||||
{Value: "患者姓名", CellType: "string", NumberFmt: "", ColWidth: 18},
|
||||
{Value: "关系", CellType: "string", NumberFmt: "", ColWidth: 18},
|
||||
{Value: "状态", CellType: "string", NumberFmt: "", ColWidth: 18},
|
||||
{Value: "用户电话", CellType: "string", NumberFmt: "", ColWidth: 18},
|
||||
{Value: "默认", CellType: "string", NumberFmt: "", ColWidth: 18},
|
||||
{Value: "身份类型", CellType: "string", NumberFmt: "", ColWidth: 18},
|
||||
{Value: "证件号码", CellType: "string", NumberFmt: "", ColWidth: 25},
|
||||
{Value: "性别", CellType: "string", NumberFmt: "", ColWidth: 18},
|
||||
{Value: "年龄", CellType: "string", NumberFmt: "", ColWidth: 18},
|
||||
{Value: "省份", CellType: "string", NumberFmt: "", ColWidth: 20},
|
||||
{Value: "城市", CellType: "string", NumberFmt: "", ColWidth: 22},
|
||||
{Value: "区县", CellType: "string", NumberFmt: "", ColWidth: 25},
|
||||
{Value: "身高(cm)", CellType: "string", NumberFmt: "", ColWidth: 18},
|
||||
{Value: "体重(kg)", CellType: "string", NumberFmt: "", ColWidth: 18},
|
||||
{Value: "婚姻状况", CellType: "string", NumberFmt: "", ColWidth: 18},
|
||||
{Value: "民族名称", CellType: "string", NumberFmt: "", ColWidth: 22},
|
||||
{Value: "职业名称", CellType: "string", NumberFmt: "", ColWidth: 22},
|
||||
{Value: "创建时间", CellType: "date", NumberFmt: "yyyy-mm-dd hh:mm:ss", ColWidth: 30},
|
||||
}
|
||||
|
||||
var dataSlice []interface{}
|
||||
for _, v := range d {
|
||||
data := PatientFamilyData{
|
||||
CardName: v.CardName,
|
||||
Relation: utils.RelationToString(*v.Relation),
|
||||
Status: utils.PatientFamilyStatusToString(v.Status),
|
||||
IsDefault: utils.IsDefaultToString(v.IsDefault),
|
||||
Type: utils.CardTypeToString(v.Type),
|
||||
IdNumber: v.IdNumber,
|
||||
Sex: utils.SexToString(v.Sex),
|
||||
Age: fmt.Sprintf("%d", v.Age),
|
||||
Province: v.Province,
|
||||
City: v.City,
|
||||
County: v.County,
|
||||
Height: v.Height,
|
||||
Weight: v.Weight,
|
||||
MaritalStatus: utils.MaritalStatusToString(v.MaritalStatus),
|
||||
NationName: v.NationName,
|
||||
JobName: v.JobName,
|
||||
}
|
||||
|
||||
if v.UserPatient != nil {
|
||||
data.UserName = v.UserPatient.UserName
|
||||
if v.UserPatient.User != nil {
|
||||
data.Mobile = v.UserPatient.User.Mobile
|
||||
}
|
||||
}
|
||||
|
||||
if v.CreatedAt != (model.LocalTime{}) {
|
||||
t := time.Time(v.CreatedAt)
|
||||
data.CreatedAt = t
|
||||
}
|
||||
|
||||
dataSlice = append(dataSlice, data)
|
||||
}
|
||||
|
||||
file, err := utils.Export(header, dataSlice)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
// 设置文件名字
|
||||
now := time.Now()
|
||||
dateTimeString := now.Format("20060102150405") // 当前时间字符串
|
||||
rand.Seed(time.Now().UnixNano()) // 设置随机数
|
||||
ossPath := "admin/export/output" + dateTimeString + fmt.Sprintf("%d", rand.Intn(9000)+1000) + ".xlsx"
|
||||
|
||||
// 上传oss
|
||||
_, err = aliyun.PutObjectByte(ossPath, file.Bytes())
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
ossPath = utils.AddOssDomain("/" + ossPath)
|
||||
return ossPath, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user