增加 系统药品导出
This commit is contained in:
@@ -308,6 +308,31 @@ type OrderPrescriptionData struct {
|
||||
CreatedAt time.Time // 创建时间
|
||||
}
|
||||
|
||||
// ProductData 系统商品
|
||||
type ProductData struct {
|
||||
ProductName string // 商品名称
|
||||
CommonName string // 商品通用名
|
||||
Stock string // 库存
|
||||
ProductStatus string // 商品状态(1:正常 2:下架)
|
||||
IsDelete string // 是否删除(0:否 1:是)
|
||||
PrescriptionNum string // 处方可开具的数量
|
||||
ProductPrice float64 // 商品价格
|
||||
MnemonicCode string // 商品助记码(首字母简拼)
|
||||
ProductType string // 药品类型(0:未知 1:中成药 2:西药)
|
||||
ProductPlatformCode string // 处方平台商品编码
|
||||
ProductPharmacyCode string // 第三方药店商品编码
|
||||
ProductSpec string // 商品规格
|
||||
LicenseNumber string // 批准文号
|
||||
Manufacturer string // 生产厂家
|
||||
SingleUnit string // 单次剂量(例:1次1包)
|
||||
SingleUse string // 单次用法(例:口服)
|
||||
PackagingUnit string // 基本包装单位(例:盒/瓶)
|
||||
FrequencyUse string // 使用频率(例:1天3次)
|
||||
AvailableDays float64 // 可用天数(3)
|
||||
ProductRemarks string // 商品备注
|
||||
CreatedAt time.Time // 创建时间
|
||||
}
|
||||
|
||||
// DoctorWithdrawal 提现记录
|
||||
func (r *ExportService) DoctorWithdrawal(doctorWithdrawals []*model.DoctorWithdrawal) (string, error) {
|
||||
header := []utils.HeaderCellData{
|
||||
@@ -1748,3 +1773,87 @@ func (r *ExportService) OrderPrescription(d []*model.OrderPrescription) (string,
|
||||
ossPath = utils.AddOssDomain("/" + ossPath)
|
||||
return ossPath, nil
|
||||
}
|
||||
|
||||
// Product 系统药品
|
||||
func (r *ExportService) Product(d []*model.Product) (string, error) {
|
||||
header := []utils.HeaderCellData{
|
||||
{Value: "商品名称", CellType: "string", NumberFmt: "", ColWidth: 40},
|
||||
{Value: "商品通用名", CellType: "string", NumberFmt: "", ColWidth: 40},
|
||||
{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: "float64", NumberFmt: "0.0000", ColWidth: 18},
|
||||
{Value: "商品助记码(首字母简拼)", CellType: "string", NumberFmt: "", ColWidth: 30},
|
||||
{Value: "药品类型", CellType: "string", NumberFmt: "", ColWidth: 18},
|
||||
{Value: "处方平台商品编码", CellType: "string", NumberFmt: "", ColWidth: 30},
|
||||
{Value: "第三方药店商品编码", CellType: "string", NumberFmt: "", ColWidth: 30},
|
||||
{Value: "商品规格", CellType: "string", NumberFmt: "", ColWidth: 30},
|
||||
{Value: "批准文号", CellType: "string", NumberFmt: "", ColWidth: 30},
|
||||
{Value: "生产厂家", CellType: "string", NumberFmt: "", ColWidth: 40},
|
||||
{Value: "单次剂量(例:1次1包)", CellType: "string", NumberFmt: "", ColWidth: 30},
|
||||
{Value: "单次用法(例:口服)", CellType: "string", NumberFmt: "", ColWidth: 30},
|
||||
{Value: "基本包装单位(例:盒/瓶)", CellType: "string", NumberFmt: "", ColWidth: 18},
|
||||
{Value: "使用频率(例:1天3次)", CellType: "string", NumberFmt: "", ColWidth: 18},
|
||||
{Value: "可用天数(3)", CellType: "float64", NumberFmt: "0.0000", ColWidth: 18},
|
||||
{Value: "商品备注", CellType: "string", NumberFmt: "", ColWidth: 40},
|
||||
{Value: "创建时间", CellType: "date", NumberFmt: "yyyy-mm-dd hh:mm:ss", ColWidth: 30},
|
||||
}
|
||||
|
||||
var dataSlice []interface{}
|
||||
for _, v := range d {
|
||||
data := ProductData{
|
||||
ProductName: v.ProductName,
|
||||
CommonName: v.CommonName,
|
||||
Stock: "0",
|
||||
ProductStatus: utils.IsProductStatusToString(v.ProductStatus),
|
||||
IsDelete: utils.IsIsDeleteToString(v.IsDelete),
|
||||
PrescriptionNum: fmt.Sprintf("%d", v.PrescriptionNum),
|
||||
ProductPrice: v.ProductPrice,
|
||||
MnemonicCode: v.MnemonicCode,
|
||||
ProductType: utils.IsProductTypeToString(v.ProductType),
|
||||
ProductPlatformCode: v.ProductPlatformCode,
|
||||
ProductPharmacyCode: v.ProductPharmacyCode,
|
||||
ProductSpec: v.ProductSpec,
|
||||
LicenseNumber: v.LicenseNumber,
|
||||
Manufacturer: v.Manufacturer,
|
||||
SingleUnit: v.SingleUnit,
|
||||
SingleUse: v.SingleUse,
|
||||
PackagingUnit: v.PackagingUnit,
|
||||
FrequencyUse: v.FrequencyUse,
|
||||
AvailableDays: v.AvailableDays,
|
||||
ProductRemarks: v.ProductRemarks,
|
||||
}
|
||||
|
||||
if v.ProductPlatformAmount != nil {
|
||||
data.Stock = strconv.Itoa(int(v.ProductPlatformAmount.Stock))
|
||||
}
|
||||
|
||||
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.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