|
@@ -30,6 +30,7 @@ import (
|
|
|
"os"
|
|
|
"path"
|
|
|
"sort"
|
|
|
+ "strconv"
|
|
|
"sync"
|
|
|
"time"
|
|
|
)
|
|
@@ -160,13 +161,13 @@ func (e WaybillController) Export(c *gin.Context) {
|
|
|
}
|
|
|
timeStr := time.Now().Format("20060102150405")
|
|
|
filePath := "ofile/" + "运单" + timeStr + ".xlsx"
|
|
|
- defer func() {
|
|
|
- os.Remove(filePath)
|
|
|
- }()
|
|
|
// 保存文件
|
|
|
if err = f.SaveAs(filePath); err != nil {
|
|
|
logs.Error("保存运单失败:", err)
|
|
|
}
|
|
|
+ defer func() {
|
|
|
+ os.Remove(filePath)
|
|
|
+ }()
|
|
|
c.Header("Content-Type", "application/vnd.ms-excel;charset=utf8")
|
|
|
// PathEscape 函数对中文做处理
|
|
|
c.Header("Content-Disposition", "attachment; filename="+url.PathEscape("运单"+timeStr+".xlsx"))
|
|
@@ -278,9 +279,9 @@ func (e WaybillController) GetAppletCount(c *gin.Context) {
|
|
|
var statusCount = make(map[int]int)
|
|
|
statusCount[0] = int(count)
|
|
|
for _, waybill := range list {
|
|
|
- if _, ok := statusCount[waybill.Status]; ok {
|
|
|
+ if _, ok := statusCount[waybill.Status]; ok {
|
|
|
statusCount[waybill.Status] += 1
|
|
|
- }else {
|
|
|
+ } else {
|
|
|
statusCount[waybill.Status] = 1
|
|
|
}
|
|
|
}
|
|
@@ -288,7 +289,6 @@ func (e WaybillController) GetAppletCount(c *gin.Context) {
|
|
|
e.OK(statusCount, "查询成功")
|
|
|
}
|
|
|
|
|
|
-
|
|
|
// Get 通过id获取运单
|
|
|
// @Summary 通过id获取运单
|
|
|
// @Description 通过id获取运单
|
|
@@ -926,10 +926,10 @@ func (e WaybillController) Import(c *gin.Context) {
|
|
|
}
|
|
|
|
|
|
var customerId int
|
|
|
- customerName := req.CustomerName
|
|
|
+ //customerName := req.CustomerName
|
|
|
if userObj.UserType == model.UserTypeCustomer {
|
|
|
customerId = userObj.Id
|
|
|
- customerName = userObj.NickName
|
|
|
+ //customerName = userObj.NickName
|
|
|
}
|
|
|
|
|
|
rows, _ := xlsx.GetRows("Sheet1")
|
|
@@ -945,21 +945,22 @@ func (e WaybillController) Import(c *gin.Context) {
|
|
|
for i, colCell := range row {
|
|
|
fmt.Println(i, ":", colCell)
|
|
|
}
|
|
|
-
|
|
|
+ quantity, _ := strconv.Atoi(row[10])
|
|
|
obj := dto.WaybillInsertReq{
|
|
|
Status: 1,
|
|
|
SenderAddressName: row[0],
|
|
|
SenderAddressPhone: row[1],
|
|
|
SenderAddressDetails: row[2],
|
|
|
- ConsigneeAddressName: row[3],
|
|
|
- ConsigneeAddressPhone: row[4],
|
|
|
- ConsigneeAddressDetails: row[5],
|
|
|
- TemperatureInterval: row[6],
|
|
|
- DeliveryCondition: row[7],
|
|
|
- CargoType: row[8],
|
|
|
- Remark: row[9],
|
|
|
+ CustomerName: row[3],
|
|
|
+ ConsigneeAddressName: row[4],
|
|
|
+ ConsigneeAddressPhone: row[5],
|
|
|
+ ConsigneeAddressDetails: row[6],
|
|
|
+ TemperatureInterval: row[7],
|
|
|
+ DeliveryCondition: row[8],
|
|
|
+ CargoType: row[9],
|
|
|
+ Quantity: quantity,
|
|
|
+ Remark: row[11],
|
|
|
CustomerId: customerId,
|
|
|
- CustomerName: customerName,
|
|
|
}
|
|
|
obj.SetDeptId(p.DeptId)
|
|
|
obj.SetCreateBy(user.GetUserId(c))
|
|
@@ -1302,9 +1303,9 @@ func (e WaybillController) TemperaturePDF(c *gin.Context) {
|
|
|
if y > 841.89 {
|
|
|
// 图片结束直接分页
|
|
|
pdf.AddPage()
|
|
|
- y = 40
|
|
|
+ y = 20
|
|
|
}
|
|
|
-
|
|
|
+ y += 20
|
|
|
pdf.SetFont("wts", "", 16)
|
|
|
pdf.SetXY(10, y)
|
|
|
pdf.Text("记录数据信息")
|
|
@@ -1410,9 +1411,11 @@ func (e WaybillController) TemperaturePDF(c *gin.Context) {
|
|
|
if err != nil {
|
|
|
return
|
|
|
}
|
|
|
- //defer func() {
|
|
|
- // os.Remove(filePath)
|
|
|
- //}()
|
|
|
+ defer func() {
|
|
|
+ os.Remove(tempFilepath)
|
|
|
+ os.Remove(humidityFilepath)
|
|
|
+ os.Remove(filePath)
|
|
|
+ }()
|
|
|
|
|
|
c.Header("Content-Disposition", "attachment; filename="+url.PathEscape(filename))
|
|
|
c.Header("Content-Transfer-Encoding", "binary")
|