1、增加导出药房关联医生列表导出
2、检测到有绑定/默认医生时直接报错,强制要求管理员先手动处理;
This commit is contained in:
@@ -380,6 +380,21 @@ type ProductData struct {
|
||||
CreatedAt string // 创建时间
|
||||
}
|
||||
|
||||
// PharmacyDoctorData 药房关联医生
|
||||
type PharmacyDoctorData struct {
|
||||
PharmacyName string // 药房名称
|
||||
PharmacyCode string // 药房代码
|
||||
DoctorName string // 医生姓名
|
||||
Mobile string // 手机号
|
||||
DoctorTitle string // 医生职称
|
||||
HospitalName string // 医院名称
|
||||
DepartmentCustomName string // 科室名称
|
||||
DepartmentCustomMobile string // 科室电话
|
||||
IsDefault string // 是否默认药房(0:否 1:是)
|
||||
Status string // 状态(0:禁用 1:正常)
|
||||
CreatedAt string // 关联时间
|
||||
}
|
||||
|
||||
// DoctorWithdrawal 提现记录
|
||||
func (r *ExportService) DoctorWithdrawal(doctorWithdrawals []*model.DoctorWithdrawal) (string, error) {
|
||||
header := []utils.HeaderCellData{
|
||||
@@ -2052,3 +2067,75 @@ func (r *ExportService) Product(d []*model.Product) (string, error) {
|
||||
ossPath = utils.AddOssDomain("/" + ossPath)
|
||||
return ossPath, nil
|
||||
}
|
||||
|
||||
// PharmacyDoctor 药房关联医生
|
||||
func (r *ExportService) PharmacyDoctor(d []*model.DoctorPharmacy) (string, error) {
|
||||
header := []utils.HeaderCellData{
|
||||
{Value: "药房名称", CellType: "string", NumberFmt: "", ColWidth: 25},
|
||||
{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: 30},
|
||||
{Value: "科室名称", CellType: "string", NumberFmt: "", ColWidth: 20},
|
||||
{Value: "科室电话", CellType: "string", NumberFmt: "", ColWidth: 18},
|
||||
{Value: "是否默认药房", CellType: "string", NumberFmt: "", ColWidth: 18},
|
||||
{Value: "状态", CellType: "string", NumberFmt: "", ColWidth: 15},
|
||||
{Value: "关联时间", CellType: "date", NumberFmt: "yyyy-mm-dd hh:mm:ss", ColWidth: 30},
|
||||
}
|
||||
|
||||
var dataSlice []interface{}
|
||||
for _, v := range d {
|
||||
data := PharmacyDoctorData{
|
||||
IsDefault: utils.IsDefaultToString(v.IsDefault),
|
||||
Status: "正常",
|
||||
}
|
||||
if v.Status == 0 {
|
||||
data.Status = "禁用"
|
||||
}
|
||||
|
||||
if v.Pharmacy != nil {
|
||||
data.PharmacyName = v.Pharmacy.PharmacyName
|
||||
data.PharmacyCode = v.Pharmacy.PharmacyCode
|
||||
}
|
||||
|
||||
if v.UserDoctor != nil {
|
||||
data.DoctorName = v.UserDoctor.UserName
|
||||
data.DoctorTitle = utils.DoctorTitleToString(v.UserDoctor.DoctorTitle)
|
||||
data.DepartmentCustomName = v.UserDoctor.DepartmentCustomName
|
||||
data.DepartmentCustomMobile = v.UserDoctor.DepartmentCustomMobile
|
||||
if v.UserDoctor.Hospital != nil {
|
||||
data.HospitalName = v.UserDoctor.Hospital.HospitalName
|
||||
}
|
||||
if v.UserDoctor.User != nil {
|
||||
data.Mobile = v.UserDoctor.User.Mobile
|
||||
}
|
||||
}
|
||||
|
||||
if v.CreatedAt != (model.LocalTime{}) {
|
||||
data.CreatedAt = time.Time(v.CreatedAt).Format("2006-01-02 15:04:05")
|
||||
}
|
||||
|
||||
dataSlice = append(dataSlice, data)
|
||||
}
|
||||
|
||||
file, err := utils.Export(header, dataSlice)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
// 设置文件名字
|
||||
now := time.Now()
|
||||
dateTimeString := now.Format("20060102150405") // 当前时间字符串
|
||||
rand.New(rand.NewSource(time.Now().UnixNano())) // 设置随机数
|
||||
ossPath := "admin/export/药房关联医生" + 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