Quellcode durchsuchen

保温箱记录,冰排记录

huangyan vor 21 Stunden
Ursprung
Commit
34fef14604

+ 174 - 1
app/admin/controller/cooler_box.go

@@ -8,11 +8,15 @@ import (
 	"cold-delivery/common/nats/nats_server"
 	"encoding/json"
 	"fmt"
+	"github.com/beego/beego/v2/core/logs"
 	"github.com/gin-gonic/gin"
 	"github.com/gin-gonic/gin/binding"
+	"github.com/xuri/excelize/v2"
 	"gogs.baozhida.cn/zoie/OAuth-core/api"
 	"gogs.baozhida.cn/zoie/OAuth-core/pkg/jwtauth/user"
 	_ "gogs.baozhida.cn/zoie/OAuth-core/pkg/response"
+	"net/url"
+	"os"
 	"sort"
 	"time"
 )
@@ -455,7 +459,7 @@ func (e CoolerBoxController) GetCoolerBoxAll(c *gin.Context) {
 		e.Error(500, err, err.Error())
 		return
 	}
-	list := make([]model.IceRaftRecord, 0)
+	list := make([]model.CoolerBoxRecord, 0)
 	var count int64
 	//数据权限检查
 	p := actions.GetPermissionFromContext(c)
@@ -466,3 +470,172 @@ func (e CoolerBoxController) GetCoolerBoxAll(c *gin.Context) {
 	}
 	e.PageOK(list, int(count), req.GetPageIndex(), req.GetPageSize(), "查询成功")
 }
+
+// ExportExecl 导出保温箱使用记录
+// @Summary 导出保温箱使用记录
+// @Description 导出保温箱使用记录
+// @Tags 保温箱
+// @Accept  application/json
+// @Product application/json
+// @Param data body dto.IceRaftRecordEedReq true "body"
+// @Success 200 {string} string	"{"code": 200, "message": "提交成功"}"
+// @Success 200 {string} string	"{"code": -1, "message": "提交成功"}"
+// @Router /api/export-execl [get]
+// @Security Bearer
+func (e CoolerBoxController) ExportExecl(c *gin.Context) {
+	s := service.CoolerBox{}
+	req := dto.GetCoolerBoxIceAll{}
+	err := e.MakeContext(c).
+		MakeOrm().
+		Bind(&req, binding.Query).
+		MakeService(&s.Service).
+		Errors
+	if err != nil {
+		e.Logger.Error(err)
+		e.Error(500, err, err.Error())
+		return
+	}
+	list := make([]model.CoolerBoxRecord, 0)
+	var count int64
+	//数据权限检查
+	p := actions.GetPermissionFromContext(c)
+	req.PageSize = 9999
+	req.Page = 1
+	err = s.GetCoolerBoxIceAll(&req, &list, p, &count)
+	if err != nil {
+		e.Error(500, err, err.Error())
+		return
+	}
+	f := excelize.NewFile() // 设置单元格的值
+	//获取当前登录用户信息,查询是否有权限
+	err, sysUser := service.GetUserProfile(e.Orm, p.UserId)
+	if err != nil {
+		e.Error(500, err, "获取用户信息失败")
+		return
+	}
+	fmt.Println(sysUser)
+	if sysUser.Dept.IsCoolerReleaseCold {
+		// 这里设置表头ÒÒ
+		f.SetCellValue("Sheet1", "A1", "序号")
+		f.SetCellValue("Sheet1", "B1", "SN")
+		f.SetCellValue("Sheet1", "C1", "预冷放入时间")
+		f.SetCellValue("Sheet1", "D1", "预冷温度")
+		f.SetCellValue("Sheet1", "E1", "预冷地点")
+		f.SetCellValue("Sheet1", "F1", "预冷操作人员")
+		f.SetCellValue("Sheet1", "G1", "使用日期")
+		f.SetCellValue("Sheet1", "H1", "放置冰排编号")
+		f.SetCellValue("Sheet1", "I1", "放置冰排数量")
+		f.SetCellValue("Sheet1", "J1", "操作人员")
+		f.SetCellValue("Sheet1", "K1", "备注")
+
+		// 设置列宽
+		f.SetColWidth("Sheet1", "A", "A", 6)
+		f.SetColWidth("Sheet1", "B", "B", 8)
+		f.SetColWidth("Sheet1", "C", "C", 14)
+		f.SetColWidth("Sheet1", "D", "D", 14)
+		f.SetColWidth("Sheet1", "E", "E", 30)
+		f.SetColWidth("Sheet1", "F", "F", 14)
+		f.SetColWidth("Sheet1", "G", "G", 14)
+		f.SetColWidth("Sheet1", "H", "H", 30)
+		f.SetColWidth("Sheet1", "I", "J", 15)
+		f.SetColWidth("Sheet1", "K", "K", 30)
+
+		line := 1
+
+		// 循环写入数据
+		for i, v := range list {
+			line++
+			f.SetCellValue("Sheet1", fmt.Sprintf("A%d", line), i+1)
+			f.SetCellValue("Sheet1", fmt.Sprintf("B%d", line), v.Sn)
+			f.SetCellValue("Sheet1", fmt.Sprintf("C%d", line), v.CoolerBoxStarTime)
+			f.SetCellValue("Sheet1", fmt.Sprintf("D%d", line), v.ColdTemperatures)
+			f.SetCellValue("Sheet1", fmt.Sprintf("E%d", line), v.CoolerColdAddress)
+			f.SetCellValue("Sheet1", fmt.Sprintf("F%d", line), v.CoolerColdUsers)
+			f.SetCellValue("Sheet1", fmt.Sprintf("G%d", line), v.CoolerUserTime)
+			f.SetCellValue("Sheet1", fmt.Sprintf("H%d", line), v.HistoryCode)
+			f.SetCellValue("Sheet1", fmt.Sprintf("I%d", line), len(v.HistoryCode))
+			f.SetCellValue("Sheet1", fmt.Sprintf("J%d", line), v.CoolerUseUsers)
+			f.SetCellValue("Sheet1", fmt.Sprintf("K%d", line), "")
+		}
+	} else {
+		// 这里设置表头ÒÒ
+		f.SetCellValue("Sheet1", "A1", "序号")
+		f.SetCellValue("Sheet1", "B1", "SN")
+		f.SetCellValue("Sheet1", "C1", "使用日期")
+		f.SetCellValue("Sheet1", "D1", "放置冰排编号")
+		f.SetCellValue("Sheet1", "E1", "放置冰排数量")
+		f.SetCellValue("Sheet1", "F1", "操作人员")
+		f.SetCellValue("Sheet1", "G1", "备注")
+
+		// 设置列宽
+		f.SetColWidth("Sheet1", "A", "A", 6)
+		f.SetColWidth("Sheet1", "B", "B", 8)
+		f.SetColWidth("Sheet1", "C", "C", 14)
+		f.SetColWidth("Sheet1", "D", "D", 14)
+		f.SetColWidth("Sheet1", "E", "E", 30)
+		f.SetColWidth("Sheet1", "F", "F", 14)
+		f.SetColWidth("Sheet1", "G", "G", 14)
+
+		line := 1
+
+		// 循环写入数据
+		for i, v := range list {
+			line++
+			f.SetCellValue("Sheet1", fmt.Sprintf("A%d", line), i+1)
+			f.SetCellValue("Sheet1", fmt.Sprintf("B%d", line), v.Sn)
+			f.SetCellValue("Sheet1", fmt.Sprintf("C%d", line), v.CoolerUserTime)
+			f.SetCellValue("Sheet1", fmt.Sprintf("D%d", line), v.HistoryCode)
+			f.SetCellValue("Sheet1", fmt.Sprintf("E%d", line), len(v.HistoryCode))
+			f.SetCellValue("Sheet1", fmt.Sprintf("F%d", line), v.CoolerUseUsers)
+			f.SetCellValue("Sheet1", fmt.Sprintf("G%d", line), "")
+		}
+	}
+	timeStr := time.Now().Format("20060102150405")
+	filePath := "ofile/" + "保温箱使用记录表" + timeStr + ".xlsx"
+	// 保存文件
+	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"))
+	c.Header("Content-Transfer-Encoding", "binary")
+	c.File(filePath)
+}
+
+// CoolerBoxStarTime 保温箱开始遇冷
+// @Summary 保温箱开始遇冷
+// @Description 保温箱开始遇冷
+// @Tags 冰排
+// @Accept  application/json
+// @Product application/json
+// @Param data body dto.IceRaftRecordEedReq true "body"
+// @Success 200 {string} string	"{"code": 200, "message": "提交成功"}"
+// @Success 200 {string} string	"{"code": -1, "message": "提交成功"}"
+// @Router /api/coolerboxstarttime [post]
+// @Security Bearer
+func (e CoolerBoxController) CoolerBoxStarTime(c *gin.Context) {
+	s := service.CoolerBox{}
+	req := dto.IceStartbleForColfTimReq{}
+	err := e.MakeContext(c).
+		MakeOrm().
+		Bind(&req, binding.JSON, nil).
+		MakeService(&s.Service).
+		Errors
+	if err != nil {
+		e.Logger.Error(err)
+		e.Error(500, err, err.Error())
+		return
+	}
+	//数据权限检查
+	p := actions.GetPermissionFromContext(c)
+	err = s.CoolerBoxStarTime(&req, p)
+	if err != nil {
+		e.Error(500, err, err.Error())
+		return
+	}
+	e.OK(req, "提交成功")
+}

+ 36 - 0
app/admin/controller/ice_locker.go

@@ -229,3 +229,39 @@ func (e IceLockerController) BatchInsert(c *gin.Context) {
 	}
 	e.OK(nil, "添加成功")
 }
+
+// GetIceLocker 获取指定冷冻柜下的所有冰排信息
+// @Summary 获取指定冷冻柜下的所有冰排信息
+// @Description 获取指定冷冻柜下的所有冰排信息
+// @Tags 冷冻柜
+// @Accept  application/json
+// @Product application/json
+// @Param data body dto.CoolerBoxBatchInsertReq true "data"
+// @Success 200 {string} string	"{"code": 200, "message": "添加成功"}"
+// @Success 200 {string} string	"{"code": -1, "message": "添加失败"}"
+// @Router /api/cooler-box/geticelocker [get]
+// @Security Bearer
+func (e IceLockerController) GetIceLocker(c *gin.Context) {
+	s := service.IceLocker{}
+	req := dto.GetIceLockerReq{}
+	err := e.MakeContext(c).
+		MakeOrm().
+		Bind(&req, binding.Form).
+		MakeService(&s.Service).
+		Errors
+	if err != nil {
+		e.Logger.Error(err)
+		e.Error(500, err, err.Error())
+		return
+	}
+	list := make([]model.IceRaft, 0)
+	var count int64
+	//数据权限检查
+	p := actions.GetPermissionFromContext(c)
+	err = s.GetIceLocker(&req, &list, p, &count)
+	if err != nil {
+		e.Error(500, err, err.Error())
+		return
+	}
+	e.PageOK(list, int(count), req.GetPageIndex(), req.GetPageSize(), "查询成功")
+}

+ 222 - 0
app/admin/controller/ice_raft.go

@@ -7,11 +7,15 @@ import (
 	"cold-delivery/common/actions"
 	"encoding/json"
 	"fmt"
+	"github.com/beego/beego/v2/core/logs"
 	"github.com/gin-gonic/gin"
 	"github.com/gin-gonic/gin/binding"
+	"github.com/xuri/excelize/v2"
 	"gogs.baozhida.cn/zoie/OAuth-core/api"
 	"gogs.baozhida.cn/zoie/OAuth-core/pkg/jwtauth/user"
 	_ "gogs.baozhida.cn/zoie/OAuth-core/pkg/response"
+	"net/url"
+	"os"
 	"time"
 )
 
@@ -434,6 +438,41 @@ func (e IceRaftController) OutStorage(c *gin.Context) {
 	e.OK(nil, "出库成功")
 }
 
+// IsOutStorage 判断冰排出库
+// @Summary 判断冰排出库
+// @Description 判断冰排出库
+// @Tags 冰排
+// @Accept  application/json
+// @Product application/json
+// @Param data body dto.IceRaftOutStorageReq true "body"
+// @Success 200 {string} string	"{"code": 200, "message": "删除成功"}"
+// @Success 200 {string} string	"{"code": -1, "message": "删除失败"}"
+// @Router /api/isoutstorage [post]
+// @Security Bearer
+func (e IceRaftController) IsOutStorage(c *gin.Context) {
+	s := service.IceRaft{}
+	req := dto.IceOutStorageReq{}
+	err := e.MakeContext(c).
+		MakeOrm().
+		Bind(&req, binding.JSON, nil).
+		MakeService(&s.Service).
+		Errors
+	if err != nil {
+		e.Logger.Error(err)
+		e.Error(500, err, err.Error())
+		return
+	}
+
+	//数据权限检查
+	p := actions.GetPermissionFromContext(c)
+	err, str := s.IsOutStorage(&req, p)
+	if err != nil {
+		e.Error(500, err, err.Error())
+		return
+	}
+	e.OK(nil, str)
+}
+
 type IceRaftRecordController struct {
 	api.Api
 }
@@ -613,3 +652,186 @@ func (e IceRaftRecordController) StartForCold(c *gin.Context) {
 	}
 	e.OK(req, "提交成功")
 }
+
+// IceRaftRecordRecording 冰排使用记录
+// @Summary 冰排使用记录
+// @Description 冰排使用记录
+// @Tags 冰排
+// @Accept  application/json
+// @Product application/json
+// @Param data body dto.IceRaftRecordEedReq true "body"
+// @Success 200 {string} string	"{"code": 200, "message": "提交成功"}"
+// @Success 200 {string} string	"{"code": -1, "message": "提交成功"}"
+// @Router /api/recording [get]
+// @Security Bearer
+func (e IceRaftRecordController) IceRaftRecordRecording(c *gin.Context) {
+	s := service.IceRaft{}
+	req := dto.IceRaftRecordRecording{}
+	err := e.MakeContext(c).
+		MakeOrm().
+		Bind(&req, binding.Query).
+		MakeService(&s.Service).
+		Errors
+	if err != nil {
+		e.Logger.Error(err)
+		e.Error(500, err, err.Error())
+		return
+	}
+
+	//数据权限检查
+	p := actions.GetPermissionFromContext(c)
+	list := make([]model.IceRaftRecord, 0)
+	var count int64
+
+	err = s.IceRaftRecordRecording(&req, &list, &count, p)
+	if err != nil {
+		e.Error(500, err, err.Error())
+		return
+	}
+	e.PageOK(list, int(count), req.GetPageIndex(), req.GetPageSize(), "查询成功")
+}
+
+// ExportExecl 导出冰排使用记录
+// @Summary 导出冰排使用记录
+// @Description 导出冰排使用记录
+// @Tags 冰排
+// @Accept  application/json
+// @Product application/json
+// @Param data body dto.IceRaftRecordEedReq true "body"
+// @Success 200 {string} string	"{"code": 200, "message": "提交成功"}"
+// @Success 200 {string} string	"{"code": -1, "message": "提交成功"}"
+// @Router /api/export-execl [get]
+// @Security Bearer
+func (e IceRaftRecordController) ExportExecl(c *gin.Context) {
+	s := service.IceRaft{}
+	req := dto.IceRaftRecordRecording{}
+	err := e.MakeContext(c).
+		MakeOrm().
+		Bind(&req, binding.Query).
+		MakeService(&s.Service).
+		Errors
+	if err != nil {
+		e.Logger.Error(err)
+		e.Error(500, err, err.Error())
+		return
+	}
+	//数据权限检查
+	p := actions.GetPermissionFromContext(c)
+	list := make([]model.IceRaftRecord, 0)
+	var count int64
+	req.Page = 1
+	req.PageSize = 9999
+	err = s.IceRaftRecordRecording(&req, &list, &count, p)
+	if err != nil {
+		e.Error(500, err, err.Error())
+		return
+	}
+	f := excelize.NewFile() // 设置单元格的值
+	//获取当前登录用户信息,查询是否有权限
+	err, sysUser := service.GetUserProfile(e.Orm, p.UserId)
+	if err != nil {
+		e.Error(500, err, "获取用户信息失败")
+		return
+	}
+	if sysUser.Dept.IsIceReleaseCold {
+
+		// 这里设置表头ÒÒ
+		f.SetCellValue("Sheet1", "A1", "序号")
+		f.SetCellValue("Sheet1", "B1", "冰排编号")
+		f.SetCellValue("Sheet1", "C1", "预冷日期")
+		f.SetCellValue("Sheet1", "D1", "预冷时间")
+		f.SetCellValue("Sheet1", "E1", "预冷温度")
+		f.SetCellValue("Sheet1", "F1", "预冷地点")
+		f.SetCellValue("Sheet1", "G1", "操作人员")
+		f.SetCellValue("Sheet1", "H1", "使用日期")
+		f.SetCellValue("Sheet1", "I1", "使用时间")
+		f.SetCellValue("Sheet1", "J1", "操作人员")
+		f.SetCellValue("Sheet1", "K1", "备注")
+
+		// 设置列宽
+		f.SetColWidth("Sheet1", "A", "A", 6)
+		f.SetColWidth("Sheet1", "B", "B", 8)
+		f.SetColWidth("Sheet1", "C", "C", 14)
+		f.SetColWidth("Sheet1", "D", "D", 14)
+		f.SetColWidth("Sheet1", "E", "E", 30)
+		f.SetColWidth("Sheet1", "F", "F", 14)
+		f.SetColWidth("Sheet1", "G", "G", 14)
+		f.SetColWidth("Sheet1", "H", "H", 30)
+		f.SetColWidth("Sheet1", "I", "J", 15)
+		f.SetColWidth("Sheet1", "K", "K", 30)
+
+		line := 1
+
+		// 循环写入数据
+		for i, v := range list {
+			line++
+			start, _ := time.Parse("2006-01-02 15:04:05", v.IceUseTime.String())
+			end, _ := time.Parse("2006-01-02 15:04:05", v.StartIceColdTime.String())
+			sub := start.Sub(end).String()
+			parse, _ := time.Parse("2006-01-02 15:04:05", v.UpdatedAt.String())
+			s2 := parse.Sub(end).String()
+			f.SetCellValue("Sheet1", fmt.Sprintf("A%d", line), i+1)
+			f.SetCellValue("Sheet1", fmt.Sprintf("B%d", line), v.Code)
+			f.SetCellValue("Sheet1", fmt.Sprintf("C%d", line), v.StartIceColdTime)
+			f.SetCellValue("Sheet1", fmt.Sprintf("D%d", line), sub)
+			f.SetCellValue("Sheet1", fmt.Sprintf("E%d", line), v.SuitableForCold)
+			f.SetCellValue("Sheet1", fmt.Sprintf("F%d", line), v.IceColdAddress)
+			f.SetCellValue("Sheet1", fmt.Sprintf("G%d", line), v.IceColdUsers)
+			f.SetCellValue("Sheet1", fmt.Sprintf("H%d", line), v.IceUseTime)
+			f.SetCellValue("Sheet1", fmt.Sprintf("I%d", line), s2)
+			f.SetCellValue("Sheet1", fmt.Sprintf("J%d", line), v.IceUseUsers)
+			f.SetCellValue("Sheet1", fmt.Sprintf("K%d", line), "")
+		}
+	} else {
+
+		// 这里设置表头ÒÒ
+		f.SetCellValue("Sheet1", "A1", "序号")
+		f.SetCellValue("Sheet1", "B1", "冰排编号")
+		f.SetCellValue("Sheet1", "C1", "操作人员")
+		f.SetCellValue("Sheet1", "D1", "使用日期")
+		f.SetCellValue("Sheet1", "E1", "使用时间")
+		f.SetCellValue("Sheet1", "F1", "操作人员")
+		f.SetCellValue("Sheet1", "G1", "备注")
+
+		// 设置列宽
+		f.SetColWidth("Sheet1", "A", "A", 6)
+		f.SetColWidth("Sheet1", "B", "B", 8)
+		f.SetColWidth("Sheet1", "C", "C", 14)
+		f.SetColWidth("Sheet1", "D", "D", 30)
+		f.SetColWidth("Sheet1", "E", "E", 15)
+		f.SetColWidth("Sheet1", "F", "F", 30)
+		f.SetColWidth("Sheet1", "G", "G", 30)
+
+		line := 1
+
+		// 循环写入数据
+		for i, v := range list {
+			line++
+			start, _ := time.Parse("2006-01-02 15:04:05", v.IceUseTime.String())
+			parse, _ := time.Parse("2006-01-02 15:04:05", v.UpdatedAt.String())
+			s2 := parse.Sub(start).String()
+			f.SetCellValue("Sheet1", fmt.Sprintf("A%d", line), i+1)
+			f.SetCellValue("Sheet1", fmt.Sprintf("B%d", line), v.Code)
+			f.SetCellValue("Sheet1", fmt.Sprintf("C%d", line), v.IceColdUsers)
+			f.SetCellValue("Sheet1", fmt.Sprintf("D%d", line), v.IceUseTime)
+			f.SetCellValue("Sheet1", fmt.Sprintf("E%d", line), s2)
+			f.SetCellValue("Sheet1", fmt.Sprintf("F%d", line), v.IceUseUsers)
+			f.SetCellValue("Sheet1", fmt.Sprintf("G%d", line), "")
+		}
+	}
+
+	timeStr := time.Now().Format("20060102150405")
+	filePath := "ofile/" + "冰排使用记录表" + timeStr + ".xlsx"
+	// 保存文件
+	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"))
+	c.Header("Content-Transfer-Encoding", "binary")
+	c.File(filePath)
+}

+ 32 - 10
app/admin/model/cooler_box.go

@@ -13,16 +13,37 @@ const (
 // 保温箱
 type CoolerBox struct {
 	model2.Model
-	Name       string                  `json:"name" gorm:"size:128"`                                 // 商品名称
-	Sn         string                  `json:"sn" gorm:"size:128"`                                   // sn
-	Status     string                  `json:"status" gorm:"size:4;not null;default:'2';comment:状态"` // 1-停用 2-正常
-	HistorySn  model2.StringList       `json:"historySn"`                                            // 历史绑定的sn
-	DeviceData natsModel.DeviceData_R2 `json:"deviceData" gorm:"-"`
+	Name             string                  `json:"name" gorm:"size:128"`                                 // 商品名称
+	Sn               string                  `json:"sn" gorm:"size:128"`                                   // sn
+	Status           string                  `json:"status" gorm:"size:4;not null;default:'2';comment:状态"` // 1-停用 2-正常
+	HistorySn        model2.StringList       `json:"historySn"`                                            // 历史绑定的sn
+	ColdSpots        string                  `json:"cold_spots"`                                           //遇冷地点
+	ColdTemperatures string                  `json:"cold_temperatures"`                                    //遇冷温度
+	DeviceData       natsModel.DeviceData_R2 `json:"deviceData" gorm:"-"`
 	model2.ControlBy
 	model2.ModelTime
 	model2.DeptBy
 	IceRaft []IceRaft `json:"ice_raft" gorm:"-"`
 }
+
+// CoolerBoxRecord 保温箱历史记录
+type CoolerBoxRecord struct {
+	model2.Model
+	CoolerBoxId       int               `json:"coolerBoxId" gorm:"size:128"`
+	Name              string            `json:"name" gorm:"size:128"`                                 // 保温箱名称
+	Sn                string            `json:"sn" gorm:"size:128"`                                   // sn
+	HistoryCode       model2.StringList `json:"historyCode"`                                          // 历史冰排
+	Status            string            `json:"status" gorm:"size:4;not null;default:'0';comment:状态"` // 0待使用 1-使用中 2-使用结束
+	CoolerBoxStarTime model2.Time       `json:"coolerBoxStarTime"  gorm:"size:128;comment:保温箱开始预冷时间"` //保温箱开始预冷时间
+	CoolerUserTime    model2.Time       `json:"coolerBoxUserTime"  gorm:"size:128;comment:保温箱开始使用时间"` //保温箱使用时间
+	CoolerColdAddress string            `json:"cooler-cold-address" gorm:"size:128;comment:保温箱预冷地点"`  //保温箱预冷地点
+	ColdTemperatures  string            `json:"cold_temperatures"`                                    //遇冷温度
+	CoolerColdUsers   string            `json:"cooler-cold-users" gorm:"size:128;comment:保温箱预冷操作人员"`  //保温箱预冷操作人员
+	CoolerUseUsers    string            `json:"cooler-use-users" gorm:"size:128;comment:保温箱使用操作人员"`   //保温箱使用操作人员
+	model2.ControlBy
+	model2.ModelTime
+	model2.DeptBy
+}
 type CoolerBoxAndIceRaft struct {
 	model2.Model
 	Name       string                  `json:"name" gorm:"size:128"`                                 // 商品名称
@@ -36,16 +57,17 @@ type CoolerBoxAndIceRaft struct {
 	IceRaft []IceRaft `json:"ice_raft"`
 }
 type CoolerBoxOmit struct {
-	Id        int         `json:"id,omitempty"`       // 主键编码
-	Name      string      `json:"name,omitempty"`     // 商品名称
-	Sn        string      `json:"sn" gorm:"size:128"` // sn
-	StartTime model2.Time `json:"startTime"`
-	EndTime   model2.Time `json:"endTime"`
+	Id   int    `json:"id,omitempty"`       // 主键编码
+	Name string `json:"name,omitempty"`     // 商品名称
+	Sn   string `json:"sn" gorm:"size:128"` // sn
 }
 
 func (CoolerBox) TableName() string {
 	return "cooler_box"
 }
+func (CoolerBoxRecord) TableName() string {
+	return "cooler_box_record"
+}
 func (CoolerBoxOmit) TableName() string {
 	return "cooler_box"
 }

+ 20 - 0
app/admin/model/drug.go

@@ -0,0 +1,20 @@
+package model
+
+import model2 "cold-delivery/common/model"
+
+type Drug struct {
+	model2.Model
+	model2.ControlBy
+	model2.ModelTime
+	model2.DeptBy
+	WaybillNo             string `json:"waybillId" gorm:"size:128;comment:运单id"`
+	Physic_name           string `json:"physic_name" gorm:"size:128;comment:药品名称"`
+	Physic_type_desc      string `json:"physic_type_desc" gorm:"size:128;comment:药品类型"`
+	Pkg_spec_crit         string `json:"pkg_spec_crit" gorm:"size:128;comment:包装规格"`
+	Prepn_spec            string `json:"prepn_spec" gorm:"size:128;comment:制剂规格"`
+	Prepn_type_desc       string `json:"prepn_type_desc" gorm:"size:128;comment:制剂类型"`
+	Approval_licence_no   string `json:"approval_licence_no" gorm:"size:128;comment:批准文号"`
+	Drug_ent_base_info_id string `json:"drug_ent_base_info_id" gorm:"size:128;comment:药品id"`
+	Ent_name              string `json:"ent_name" gorm:"size:128;comment:企业名称"`
+	Code                  string `json:"code" gorm:"size:128;comment:药品编码"`
+}

+ 63 - 42
app/admin/model/ice_raft.go

@@ -10,13 +10,14 @@ const (
 // 冰排
 type IceRaft struct {
 	model2.Model
-	Code                string            `json:"code" gorm:"size:128"`                                 // 商品名称
-	Status              string            `json:"status" gorm:"size:4;not null;default:'2';comment:状态"` // 1-停用 2-正常
-	IceRaftRecordId     int               `json:"iceRaftRecordId" gorm:"size:128"`                      // 最新入库记录
-	FreezeClaim         float32           `json:"freezeClaim" gorm:"type:decimal(10,2);comment:冷冻要求"`   // 冷冻要求 单位小时
-	IceRaftRecord       IceRaftRecordOmit `json:"iceRaftRecord" gorm:"->;foreignkey:IceRaftRecordId;references:Id"`
-	Label               string            `json:"label" gorm:"size:128;comment:标签"`                 // 标签
-	SuitableForColdTime int               `json:"suitableForColdTime" gorm:"size:128;comment:适冷时间"` // 适冷时间 单位分钟
+	Code            string            `json:"code" gorm:"size:128"`                                 // 商品名称
+	Status          string            `json:"status" gorm:"size:4;not null;default:'2';comment:状态"` // 1-停用 2-正常
+	IceRaftRecordId int               `json:"iceRaftRecordId" gorm:"size:128"`                      // 最新入库记录
+	FreezeClaim     model2.FloatList  `json:"freezeClaim" gorm:"type:json;comment:冷冻要求"`            // 冷冻要求 单位小时
+	IceRaftRecord   IceRaftRecordOmit `json:"iceRaftRecord" gorm:"->;foreignkey:IceRaftRecordId;references:Id"`
+	Label           string            `json:"label" gorm:"size:128;comment:标签"`                         // 标签
+	IceColdAddress  string            `json:"iceColdAddress" gorm:"size:128;comment:冰排预冷地点"`            //冰排预冷地点
+	SuitableForCold float32           `json:"suitableForCold" gorm:"type:decimal(10,2);comment:冰排适冷温度"` // 冰排遇冷温度
 	model2.ControlBy
 	model2.ModelTime
 	model2.DeptBy
@@ -34,10 +35,11 @@ func (IceRaftOmit) TableName() string {
 }
 
 const (
-	IceRaftRecordStatusFreezing = "1" // 冷冻中
-	IceRaftRecordStatusWaitUse  = "2" // 待使用
-	IceRaftRecordStatusUsing    = "3" // 使用中
-	IceRaftRecordStatusFinish   = "4" // 已结束
+	IceRaftRecordStatusFreezing    = "1" // 冷冻中
+	IceRaftRecordStatusWaitUse     = "2" // 待使用
+	IceRaftRecordStatusUsing       = "3" // 使用中
+	IceRaftRecordStatusFinish      = "4" // 已结束
+	IceRaftRecordReleasedInTheCold = "5" // 释冷中
 )
 
 func GetIceRaftRecordStatus(s string) string {
@@ -52,6 +54,8 @@ func GetIceRaftRecordStatus(s string) string {
 		return "使用中"
 	case IceRaftRecordStatusFinish:
 		return "已结束"
+	case IceRaftRecordReleasedInTheCold:
+		return "释冷中"
 	}
 	return ""
 }
@@ -59,43 +63,60 @@ func GetIceRaftRecordStatus(s string) string {
 // 冰排记录
 type IceRaftRecord struct {
 	model2.Model
-	IceRaftId         int           `json:"iceRaftId" gorm:"size:128;comment:冰排id"`
-	Label             string        `json:"label" gorm:"size:128;comment:标签"`                         // 标签
-	Status            string        `json:"status" gorm:"size:4;not null;default:'2';comment:状态"`     // 0未入库 1-冷冻中 2-待使用 3-使用中 4已结束
-	InStorageTime     model2.Time   `json:"inStorageTime"  gorm:"size:128;comment:入库时间"`              // 入库时间
-	OutStorageTime    model2.Time   `json:"outStorageTime"  gorm:"size:128;comment:出库时间"`             // 出库时间
-	IceLockerId       int           `json:"iceLockerId" gorm:"size:128;comment:冷冻柜id"`                // 冷冻柜id
-	CoolerBoxId       int           `json:"coolerBoxId" gorm:"size:128;comment:保温箱id"`                // 保温箱id
-	FreezeClaim       float32       `json:"freezeClaim" gorm:"type:decimal(10,2);comment:冷冻要求"`       // 冷冻要求 单位小时
-	FreezeDuration    int           `json:"freezeDuration" gorm:"size:128;comment:冷冻时长"`              // 冷冻时长 单位分钟
-	SuitableForCold   float32       `json:"suitableForCold" gorm:"type:decimal(10,2);comment:冰排适冷温度"` // 冰排适冷温度
-	EndForColdTime    model2.Time   `json:"endForColdTime"  gorm:"size:128;comment:适冷结束时间"`           // 适冷结束时间
-	IsSuitableForCold int           `json:"isSuitableForCold" gorm:"size:4;not null;comment:是否结束适冷"`  //0 未适冷 1已适冷
-	CoolerBoxStarTime model2.Time   `json:"coolerBoxStarTime"  gorm:"size:128;comment:保温箱开始记录时间"`     //保温箱开始记录时间
-	CoolerBoxEndTime  model2.Time   `json:"coolerBoxEndTime"  gorm:"size:128;comment:保温箱结束记录时间"`      //保温箱结束记录时间
-	StartIceColdTime  model2.Time   `json:"start_ice_cold_time" gorm:"size:128;comment:释冷开始时间"`       //释冷开始时间
-	IceLocker         IceLockerOmit `json:"iceLocker" gorm:"->"`
-	CoolerBox         CoolerBoxOmit `json:"coolerBox" gorm:"->"`
+	IceRaftId         int              `json:"iceRaftId" gorm:"size:128;comment:冰排id"`
+	Label             string           `json:"label" gorm:"size:128;comment:标签"`                         // 标签
+	Code              string           `json:"code" gorm:"size:128;comment:编号"`                          // 编号
+	Status            string           `json:"status" gorm:"size:4;not null;default:'2';comment:状态"`     // 0未入库 1-冷冻中 2-待使用 3-使用中 4已结束 5-释冷中
+	InStorageTime     model2.Time      `json:"inStorageTime"  gorm:"size:128;comment:入库时间"`              // 入库时间
+	OutStorageTime    model2.Time      `json:"outStorageTime"  gorm:"size:128;comment:出库时间"`             // 出库时间
+	IceLockerId       int              `json:"iceLockerId" gorm:"size:128;comment:冷冻柜id"`                // 冷冻柜id
+	CoolerBoxId       int              `json:"coolerBoxId" gorm:"size:128;comment:保温箱id"`                // 保温箱id
+	FreezeClaim       model2.FloatList `json:"freezeClaim" gorm:"type:json;comment:冷冻要求"`                // 冷冻要求 单位小时
+	FreezeDuration    int              `json:"freezeDuration" gorm:"size:128;comment:冷冻时长"`              // 冷冻时长 单位分钟
+	SuitableForCold   float32          `json:"suitableForCold" gorm:"type:decimal(10,2);comment:冰排适冷温度"` // 冰排适冷温度
+	EndForColdTime    model2.Time      `json:"endForColdTime"  gorm:"size:128;comment:适冷结束时间"`           // 适冷结束时间
+	IsSuitableForCold int              `json:"isSuitableForCold" gorm:"size:4;not null;comment:是否结束适冷"`  //0 未适冷 1已适冷
+	CoolerBoxStarTime model2.Time      `json:"coolerBoxStarTime"  gorm:"size:128;comment:保温箱开始预冷时间"`     //保温箱开始预冷时间
+	CoolerBoxEndTime  model2.Time      `json:"coolerBoxEndTime"  gorm:"size:128;comment:保温箱结束记录时间"`      //保温箱结束记录时间
+	StartIceColdTime  model2.Time      `json:"start_ice_cold_time" gorm:"size:128;comment:释冷开始时间"`       //冰排释冷开始时间
+	IceColdAddress    string           `json:"ice_cold_address" gorm:"size:128;comment:冰排预冷地点"`          //冰排预冷地点
+	IceColdUsers      string           `json:"ice_cold_users" gorm:"size:128;comment:冰排预冷操作人员"`          //冰排预冷操作人员
+	IceUseUsers       string           `json:"ice_use_users" gorm:"size:128;comment:冰排使用操作人员"`           //冰排使用操作人员
+	IceUseTime        model2.Time      `json:"ice_use_time" gorm:"size:128;comment:冰排使用时间"`              //冰排使用时间
+	CoolerColdAddress string           `json:"cooler-cold-address" gorm:"size:128;comment:保温箱预冷地点"`      //保温箱预冷地点
+	CoolerColdUsers   string           `json:"cooler-cold-users" gorm:"size:128;comment:保温箱预冷操作人员"`      //保温箱预冷操作人员
+	CoolerUseUsers    string           `json:"cooler-use-users" gorm:"size:128;comment:保温箱使用操作人员"`       //保温箱使用操作人员
+	IceLocker         IceLockerOmit    `json:"iceLocker" gorm:"->"`
+	CoolerBox         CoolerBoxOmit    `json:"coolerBox" gorm:"->"`
+	CoolerBoxRecord   CoolerBoxRecord  `json:"coolerBoxRecord" gorm:"-"`
 	model2.ControlBy
 	model2.ModelTime
 	model2.DeptBy
 }
 
 type IceRaftRecordOmit struct {
-	Id                int           `json:"id,omitempty"`             // 主键编码
-	IceRaftId         int           `json:"iceRaftId,omitempty"`      // 冰排id
-	Status            string        `json:"status"`                   // 1-停用 2-正常
-	InStorageTime     model2.Time   `json:"inStorageTime,omitempty"`  // 入库时间
-	OutStorageTime    model2.Time   `json:"outStorageTime,omitempty"` // 出库时间
-	IceLockerId       int           `json:"iceLockerId,omitempty"`    // 冷冻柜id
-	CoolerBoxId       int           `json:"coolerBoxId,omitempty"`    // 保温箱id
-	FreezeClaim       float32       `json:"freezeClaim"`              // 冷冻要求 单位小时
-	FreezeDuration    int           `json:"freezeDuration"`           // 冷冻时长 单位分钟
-	SuitableForCold   float32       `json:"suitableForCold" `         // 冰排适冷温度
-	EndForColdTime    model2.Time   `json:"endForColdTime"  `         // 适冷结束时间
-	IsSuitableForCold int           `json:"isSuitableForCold" `       //0 未适冷 1已适冷
-	IceLocker         IceLockerOmit `json:"iceLocker" gorm:"->"`
-	CoolerBox         CoolerBoxOmit `json:"coolerBox" gorm:"->"`
+	Id                int              `json:"id,omitempty"`                                        // 主键编码
+	IceRaftId         int              `json:"iceRaftId,omitempty"`                                 // 冰排id
+	Status            string           `json:"status"`                                              // 1-停用 2-正常
+	InStorageTime     model2.Time      `json:"inStorageTime,omitempty"`                             // 入库时间
+	OutStorageTime    model2.Time      `json:"outStorageTime,omitempty"`                            // 出库时间
+	IceLockerId       int              `json:"iceLockerId,omitempty"`                               // 冷冻柜id
+	CoolerBoxId       int              `json:"coolerBoxId,omitempty"`                               // 保温箱id
+	FreezeClaim       model2.FloatList `json:"freezeClaim" gorm:"type:json;comment:冷冻要求"`           // 冷冻要求 单位小时
+	FreezeDuration    int              `json:"freezeDuration"`                                      // 冷冻时长 单位分钟
+	SuitableForCold   float32          `json:"suitableForCold" `                                    // 冰排适冷温度
+	EndForColdTime    model2.Time      `json:"endForColdTime"  `                                    // 适冷结束时间
+	IsSuitableForCold int              `json:"isSuitableForCold" `                                  //0 未适冷 1已适冷
+	StartIceColdTime  model2.Time      `json:"start_ice_cold_time" gorm:"size:128;comment:释冷开始时间"`  //冰排释冷开始时间
+	IceColdAddress    string           `json:"ice_cold_address" gorm:"size:128;comment:冰排预冷地点"`     //冰排预冷地点
+	IceColdUsers      string           `json:"ice_cold_users" gorm:"size:128;comment:冰排预冷操作人员"`     //冰排预冷操作人员
+	IceUseUsers       string           `json:"ice_use_users" gorm:"size:128;comment:冰排使用操作人员"`      //冰排使用操作人员
+	IceUseTime        model2.Time      `json:"ice_use_time" gorm:"size:128;comment:冰排使用时间"`         //冰排使用时间
+	CoolerColdAddress string           `json:"cooler-cold-address" gorm:"size:128;comment:保温箱预冷地点"` //保温箱预冷地点
+	CoolerColdUsers   string           `json:"cooler-cold-users" gorm:"size:128;comment:保温箱预冷操作人员"` //保温箱预冷操作人员
+	CoolerUseUsers    string           `json:"cooler-use-users" gorm:"size:128;comment:保温箱使用操作人员"`  //保温箱使用操作人员
+	IceLocker         IceLockerOmit    `json:"iceLocker" gorm:"->"`
+	CoolerBox         CoolerBoxOmit    `json:"coolerBox" gorm:"->"`
 }
 
 func (IceRaftRecord) TableName() string {

+ 2 - 0
app/admin/model/sys_dept.go

@@ -23,6 +23,8 @@ type SysDept struct {
 	ColdPid             int       `json:"coldPid"  gorm:"size:128;"`                             // 冷链3.0公司id
 	IsIceReleaseCold    bool      `json:"isIceReleaseCold" gorm:"type:boolean;default:false"`    //冰排是否释冷
 	IsCoolerReleaseCold bool      `json:"isCoolerReleaseCold" gorm:"type:boolean;default:false"` //保温箱是否释冷
+	IsCoolerShow        bool      `json:"isCoolerShow" gorm:"type:boolean;default:false"`        //保温箱是否展示开始使用时间
+	IsOutStorage        bool      `json:"isOutStorage" gorm:"type:boolean;default:false"`        //是否可以出库
 	Children            []SysDept `json:"children" gorm:"-"`
 	CompanyAddress      string    `json:"companyAddress"` //公司地址
 	model2.ControlBy

+ 14 - 13
app/admin/model/waybill.go

@@ -101,19 +101,20 @@ type Waybill struct {
 	Delivery                   SysUserOmit    `json:"delivery" gorm:"->"`                            // 部门
 	ReCheck                    SysUserOmit    `json:"reCheck" gorm:"->"`                             // 部门
 	IceRaftCode                IceRaftCode    `json:"iceRaftCode" gorm:"size:text"`
-	AssessStar                 int            `json:"assessStar"  gorm:"size:128"`                          // 评价星星
-	AssessContent              string         `json:"assessContent"  gorm:"size:128"`                       // 评价内容
-	PrescriptionIsAudit        int            `json:"prescriptionIssue"   gorm:"size:128;default:1"`        // 处方是否审核 1 未审核 2已审核
-	InvoiceIsAudit             int            `json:"invoiceIssue"   gorm:"size:128;default:1"`             // 发票是否审核 1 未审核 2已审核
-	InspectionReportIsAudit    int            `json:"inspectionReportIssue"   gorm:"size:128;default:1"`    // 检验报告是否审核 1 未审核 2已审核
-	DispensingMedicinesIsAudit int            `json:"dispensingMedicinesIssue"   gorm:"size:128;default:1"` // 调配药品信息是否审核  1 未审核 2已审核
-	IsCold                     int            `json:"isCold"   gorm:"size:128;default:1"`                   // 是否冷链 1 否 2 是
-	PaymentStatus              int            `json:"paymentStatus"  gorm:"size:128;default:1"`             //支付状态 1 结清 2 未结清  3 支付完成
-	PaymentType                int            `json:"paymentType"  gorm:"size:128;default:0"`               //支付方式  1现金 2线上支付 3银行卡 4医保 5其他
-	PaymentRemark              string         `json:"paymentremark"  gorm:"size:128;"`                      //支付备注
-	AssignmentStatus           int            `json:"assignmentStatus"  gorm:"size:128;default:1"`          //分配状态  1 未分配  2已分配
-	AuditRemark                string         `json:"audit_remark"  gorm:"size:255;"`                       //驳回原因
-	AdminAuditRemark           string         `json:"admin_audit_remark"  gorm:"size:255;"`                 //管理员审核备注
+	AssessStar                 int            `json:"assessStar"  gorm:"size:128"`                                 // 评价星星
+	AssessContent              string         `json:"assessContent"  gorm:"size:128"`                              // 评价内容
+	PrescriptionIsAudit        int            `json:"prescriptionIssue"   gorm:"size:128;default:1"`               // 处方是否审核 1 未审核 2已审核
+	InvoiceIsAudit             int            `json:"invoiceIssue"   gorm:"size:128;default:1"`                    // 发票是否审核 1 未审核 2已审核
+	InspectionReportIsAudit    int            `json:"inspectionReportIssue"   gorm:"size:128;default:1"`           // 检验报告是否审核 1 未审核 2已审核
+	DispensingMedicinesIsAudit int            `json:"dispensingMedicinesIssue"   gorm:"size:128;default:1"`        // 调配药品信息是否审核  1 未审核 2已审核
+	IsCold                     int            `json:"isCold"   gorm:"size:128;default:1"`                          // 是否冷链 1 否 2 是
+	PaymentStatus              int            `json:"paymentStatus"  gorm:"size:128;default:1"`                    //支付状态 1 结清 2 未结清  3 支付完成
+	PaymentType                int            `json:"paymentType"  gorm:"size:128;default:0"`                      //支付方式  1现金 2线上支付 3银行卡 4医保 5其他
+	PaymentRemark              string         `json:"paymentremark"  gorm:"size:128;"`                             //支付备注
+	AssignmentStatus           int            `json:"assignmentStatus"  gorm:"size:128;default:1"`                 //分配状态  1 未分配  2已分配
+	AuditRemark                string         `json:"audit_remark"  gorm:"size:255;"`                              //驳回原因
+	AdminAuditRemark           string         `json:"admin_audit_remark"  gorm:"size:255;"`                        //管理员审核备注
+	IsSecondaryDistribution    bool           `json:"is_secondary_distribution" gorm:"type:boolean;default:false"` //是否二次分配
 	model2.ControlBy
 	model2.ModelTime
 	model2.DeptBy

+ 2 - 0
app/admin/router/cooler_box.go

@@ -26,5 +26,7 @@ func registerCoolerBoxRouter(v1 *gin.RouterGroup, authMiddleware *jwt.GinJWTMidd
 		r.POST("/historylocus", cont.GetCoolerBoxLocus)
 		r.GET("/getcoolerboxice", cont.GetCoolerBoxIce)
 		r.GET("/getcoolerboxall", cont.GetCoolerBoxAll)
+		r.POST("/coolerboxstarttime", cont.CoolerBoxStarTime)
+		r.GET("/export-execl", cont.ExportExecl)
 	}
 }

+ 1 - 0
app/admin/router/ice_locker.go

@@ -22,6 +22,7 @@ func registerIceLockerRouter(v1 *gin.RouterGroup, authMiddleware *jwt.GinJWTMidd
 		r.PUT("", cont.Update)
 		r.DELETE("", cont.Delete)
 		r.POST("/import", cont.BatchInsert)
+		r.GET("/geticelocker", cont.GetIceLocker)
 
 	}
 }

+ 3 - 0
app/admin/router/ice_raft.go

@@ -27,6 +27,7 @@ func registerIceRaftRouter(v1 *gin.RouterGroup, authMiddleware *jwt.GinJWTMiddle
 		r.POST("/out-storage", cont.OutStorage)
 		r.GET("/newest-record-sse", cont.GetNewestRecordPageSSE)
 		r.GET("/cooler-box", cont.GetPageByCoolerBoxId)
+		r.POST("/isoutstorage", cont.IsOutStorage)
 	}
 
 	cont2 := controller.IceRaftRecordController{}
@@ -37,5 +38,7 @@ func registerIceRaftRouter(v1 *gin.RouterGroup, authMiddleware *jwt.GinJWTMiddle
 		r2.DELETE("", cont2.Delete)
 		r2.POST("/end-for-cold", cont2.EndForCold)
 		r2.POST("/start-for-cold", cont2.StartForCold)
+		r2.GET("/recording", cont2.IceRaftRecordRecording)
+		r2.GET("/export-execl", cont2.ExportExecl)
 	}
 }

+ 4 - 0
app/admin/service/company.go

@@ -386,6 +386,10 @@ func (e *Company) DeptPageCall(deptList *[]model.SysDept, menu model.SysDept) mo
 		mi.Status = list[j].Status
 		mi.Remark = list[j].Remark
 		mi.CreatedAt = list[j].CreatedAt
+		mi.IsCoolerReleaseCold = list[j].IsCoolerReleaseCold
+		mi.IsCoolerShow = list[j].IsCoolerShow
+		mi.IsIceReleaseCold = list[j].IsIceReleaseCold
+		mi.CompanyAddress = list[j].CompanyAddress
 		mi.Children = []model.SysDept{}
 		ms := e.DeptPageCall(deptList, mi)
 		min = append(min, ms)

+ 102 - 9
app/admin/service/cooler_box.go

@@ -7,6 +7,7 @@ import (
 	cDto "cold-delivery/common/dto"
 	"cold-delivery/common/global"
 	"cold-delivery/common/lib"
+	model2 "cold-delivery/common/model"
 	"cold-delivery/common/nats/nats_server"
 	"errors"
 	"fmt"
@@ -542,7 +543,7 @@ func (e *CoolerBox) GetCoolerBoxIce(c *dto.GetCoolerBoxIce, list *[]model.IceRaf
 }
 
 // GetCoolerBoxIceAll 获取保温箱所有历史记录
-func (e *CoolerBox) GetCoolerBoxIceAll(c *dto.GetCoolerBoxIceAll, list *[]model.IceRaftRecord, p *actions.DataPermission, count *int64) error {
+func (e *CoolerBox) GetCoolerBoxIceAll(c *dto.GetCoolerBoxIceAll, list *[]model.CoolerBoxRecord, p *actions.DataPermission, count *int64) error {
 	var err error
 
 	tx := e.Orm.Begin()
@@ -554,14 +555,28 @@ func (e *CoolerBox) GetCoolerBoxIceAll(c *dto.GetCoolerBoxIceAll, list *[]model.
 		}
 	}()
 	//查询保温箱是否存在
-	var icerecord model.IceRaftRecord
-	err = e.Orm.Scopes(
-		cDto.Paginate(c.GetPageSize(), c.GetPageIndex()),
-		actions.Permission(icerecord.TableName(), p)).
-		Not("cooler_box_id", 0).
-		Preload("IceLocker").
-		Preload("CoolerBox").
-		Find(&list).Count(count).Error
+	var cooler model.CoolerBoxRecord
+	if c.PageSize == 9999 {
+		err = e.Orm.Scopes(
+			cDto.MakeCondition(c.GetNeedSearch()),
+			actions.Permission(cooler.TableName(), p),
+			CollerStartTimeAndEndTimeScopes(c.StartTime, c.EndTime),
+		).
+			Where("status = ?", 2).
+			Find(&list).
+			Count(count).Error
+	} else {
+		err = e.Orm.Scopes(
+			cDto.Paginate(c.GetPageSize(), c.GetPageIndex()),
+			cDto.MakeCondition(c.GetNeedSearch()),
+			actions.Permission(cooler.TableName(), p),
+			CollerStartTimeAndEndTimeScopes(c.StartTime, c.EndTime),
+		).
+			Where("status = ?", 2).
+			Find(&list).
+			Count(count).Error
+	}
+
 	if err != nil {
 		e.Log.Errorf("db error: %s", err)
 		if errors.Is(err, gorm.ErrRecordNotFound) {
@@ -571,3 +586,81 @@ func (e *CoolerBox) GetCoolerBoxIceAll(c *dto.GetCoolerBoxIceAll, list *[]model.
 	}
 	return nil
 }
+
+// CoolerBoxStarTime 保温箱开始释冷
+//
+//	func (e *CoolerBox) CoolerBoxStarTime(c *dto.IceStartbleForColfTimReq, p *actions.DataPermission) error {
+//		var err error
+//
+//		tx := e.Orm.Begin()
+//		defer func() {
+//			if err != nil {
+//				tx.Rollback()
+//			} else {
+//				tx.Commit()
+//			}
+//		}()
+//		//查询冰排是否存在
+//		for _, v := range c.Id {
+//			var iceRaftRecordModel model.IceRaftRecord
+//			err = e.Orm.Scopes(actions.Permission(iceRaftRecordModel.TableName(), p)).
+//				First(&iceRaftRecordModel, v).Error
+//			if err != nil {
+//				e.Log.Errorf("db error: %s", err)
+//				if errors.Is(err, gorm.ErrRecordNotFound) {
+//					return global.UpdateNotFoundOrNoPermissionErr
+//				}
+//				return global.UpdateFailedErr
+//			}
+//			iceRaftRecordModel.CoolerBoxStarTime = model2.Time(time.Now())
+//			updates := tx.Where("id = ?", iceRaftRecordModel.Id).Updates(&iceRaftRecordModel)
+//			if err = updates.Error; err != nil {
+//				e.Log.Errorf("db error: %s", err)
+//				return global.UpdateFailedErr
+//			}
+//		}
+//		return nil
+//	}
+func (e *CoolerBox) CoolerBoxStarTime(c *dto.IceStartbleForColfTimReq, p *actions.DataPermission) error {
+	var err error
+
+	tx := e.Orm.Begin()
+	defer func() {
+		if err != nil {
+			tx.Rollback()
+		} else {
+			tx.Commit()
+		}
+	}()
+	var user model.SysUser
+	first := e.Orm.Model(&model.SysUser{}).Where("id = ?", p.UserId).First(&user)
+	if first.Error != nil {
+		return global.GetFailedErr
+	}
+	//添加保温箱记录
+	for _, v := range c.Id {
+		var cooler model.CoolerBoxRecord
+		var coolerBox model.CoolerBox
+		err = e.Orm.Model(&model.CoolerBox{}).Where("id = ?", v).First(&coolerBox).Error
+		if err != nil {
+			e.Log.Errorf("获取保温箱信息失败: %s", err)
+			return errors.New("获取保温箱信息失败")
+		}
+		cooler.CoolerBoxStarTime = model2.Time(time.Now())
+		cooler.CoolerColdUsers = user.NickName
+		cooler.CoolerColdAddress = coolerBox.ColdSpots
+		cooler.ColdTemperatures = coolerBox.ColdTemperatures
+		cooler.Status = "1" //保温箱使用状态变为使用中
+		CoolerBoxId, _ := strconv.Atoi(v)
+		cooler.CoolerBoxId = CoolerBoxId
+		cooler.DeptId = p.DeptId
+		cooler.Sn = coolerBox.Sn
+		cooler.Name = coolerBox.Name
+		err = e.Orm.Create(&cooler).Error
+		if err != nil {
+			e.Log.Errorf("db error: %s", err)
+			return global.CreateFailedErr
+		}
+	}
+	return nil
+}

+ 23 - 14
app/admin/service/dto/company.go

@@ -32,13 +32,14 @@ func (m *CompanyGetAllReq) GetNeedSearch() interface{} {
 
 type CompanyInsertReq struct {
 	Id                  int    `json:"id" swaggerignore:"true"`
-	Name                string `json:"name" example:"名称" vd:"len($)>0;msg:'公司名称不能为空'"`       //名称
-	Remark              string `json:"remark"`                                               // 备注
-	ColdKey             string `json:"coldKey"`                                              // 冷链3.0key
-	ParentId            int    `json:"parentId" example:"0" vd:"?"`                          //上级公司
-	IsIceReleaseCold    bool   `json:"isIceReleaseCold" gorm:"type:boolean;default:true"`    //冰排是否释冷
-	IsCoolerReleaseCold bool   `json:"isCoolerReleaseCold" gorm:"type:boolean;default:true"` //保温箱是否释冷
-	CompanyAddress      string `json:"companyAddress"`                                       //公司地址
+	Name                string `json:"name" example:"名称" vd:"len($)>0;msg:'公司名称不能为空'"`        //名称
+	Remark              string `json:"remark"`                                                // 备注
+	ColdKey             string `json:"coldKey"`                                               // 冷链3.0key
+	ParentId            int    `json:"parentId" example:"0" vd:"?"`                           //上级公司
+	IsIceReleaseCold    bool   `json:"isIceReleaseCold" gorm:"type:boolean;default:false"`    //冰排是否释冷
+	IsCoolerReleaseCold bool   `json:"isCoolerReleaseCold" gorm:"type:boolean;default:false"` //保温箱是否释冷
+	IsOutStorage        bool   `json:"isOutStorage" gorm:"type:boolean;default:false"`        //是否出库
+	CompanyAddress      string `json:"companyAddress"`                                        //公司地址
 	common.ControlBy    `swaggerignore:"true"`
 }
 
@@ -53,6 +54,7 @@ func (s *CompanyInsertReq) Generate(model *model.SysDept) {
 	model.CompanyAddress = s.CompanyAddress
 	model.IsIceReleaseCold = s.IsIceReleaseCold
 	model.IsCoolerReleaseCold = s.IsCoolerReleaseCold
+	model.IsOutStorage = s.IsOutStorage
 }
 
 // GetId 获取数据对应的ID
@@ -61,13 +63,15 @@ func (s *CompanyInsertReq) GetId() interface{} {
 }
 
 type CompanyUpdateReq struct {
-	Id                  int    `json:"id" comment:"编码"`                                      // 编码
-	Name                string `json:"name" example:"名称"`                                    //名称
-	Remark              string `json:"remark"`                                               // 备注
-	ColdKey             string `json:"coldKey"`                                              // 冷链3.0key
-	IsIceReleaseCold    bool   `json:"isIceReleaseCold" gorm:"type:boolean;default:true"`    //冰排是否释冷
-	IsCoolerReleaseCold bool   `json:"isCoolerReleaseCold" gorm:"type:boolean;default:true"` //保温箱是否释冷
-	CompanyAddress      string `json:"companyAddress"`                                       //公司地址
+	Id                  int    `json:"id" comment:"编码"`                                // 编码
+	Name                string `json:"name" example:"名称"`                              //名称
+	Remark              string `json:"remark"`                                         // 备注
+	ColdKey             string `json:"coldKey"`                                        // 冷链3.0key
+	IsIceReleaseCold    bool   `json:"isIceReleaseCold"`                               //冰排是否释冷
+	IsCoolerReleaseCold bool   `json:"isCoolerReleaseCold"`                            //保温箱是否释冷
+	IsOutStorage        bool   `json:"isOutStorage" gorm:"type:boolean;default:false"` //保温箱是否释冷
+	IsCoolerShow        bool   `json:"isCoolerShow"`                                   //保温箱是否展示开始使用时间
+	CompanyAddress      string `json:"companyAddress"`                                 //公司地址
 	common.ControlBy    `swaggerignore:"true"`
 }
 
@@ -79,6 +83,11 @@ func (s *CompanyUpdateReq) Generate(model *model.SysDept) {
 	model.Name = s.Name
 	model.Remark = s.Remark
 	model.ColdKey = s.ColdKey
+	model.CompanyAddress = s.CompanyAddress
+	model.IsIceReleaseCold = s.IsIceReleaseCold
+	model.IsCoolerReleaseCold = s.IsCoolerReleaseCold
+	model.IsCoolerShow = s.IsCoolerShow
+	model.IsOutStorage = s.IsOutStorage
 }
 
 // GetId 获取数据对应的ID

+ 15 - 2
app/admin/service/dto/cooler_box.go

@@ -29,6 +29,8 @@ type CoolerBoxInsertReq struct {
 	Name             string `json:"name"`                                 // 保温箱名称
 	Sn               string `json:"sn"`                                   // sn
 	Status           string `json:"status"`                               // 1-停用 2-正常
+	ColdSpots        string `json:"cold_spots"`                           //遇冷地点
+	ColdTemperatures string `json:"cold_temperatures"`                    //遇冷温度
 	common.ControlBy `swaggerignore:"true"`
 	common.DeptBy    `swaggerignore:"true"`
 }
@@ -40,6 +42,8 @@ func (s *CoolerBoxInsertReq) Generate(model *model.CoolerBox) {
 	model.Name = s.Name
 	model.Sn = strings.TrimSpace(s.Sn)
 	model.Status = s.Status
+	model.ColdSpots = s.ColdSpots
+	model.ColdTemperatures = s.ColdTemperatures
 	if s.ControlBy.UpdateBy != 0 {
 		model.UpdateBy = s.UpdateBy
 	}
@@ -60,6 +64,8 @@ type CoolerBoxUpdateReq struct {
 	Name             string `json:"name"`            // 保温箱名称
 	Sn               string `json:"sn"`              // sn
 	Status           string `json:"status"`          // 1-停用 2-正常
+	ColdSpots        string `json:"cold_spots"`      //遇冷地点
+	ColdTemperatures string `json:"cold_temperatures"`
 	common.ControlBy `swaggerignore:"true"`
 }
 
@@ -70,6 +76,8 @@ func (s *CoolerBoxUpdateReq) Generate(model *model.CoolerBox) {
 	model.Name = s.Name
 	model.Sn = strings.TrimSpace(s.Sn)
 	model.Status = s.Status
+	model.ColdSpots = s.ColdSpots
+	model.ColdTemperatures = s.ColdTemperatures
 	if s.ControlBy.UpdateBy != 0 {
 		model.UpdateBy = s.UpdateBy
 	}
@@ -136,6 +144,11 @@ type GetCoolerBoxIce struct {
 }
 type GetCoolerBoxIceAll struct {
 	dto.Pagination `search:"-"`
-	Name           string `form:"name" search:"type:contains;column:name;table:ice_locker"`  // 保温箱
-	Status         string `form:"status" search:"type:exact;column:status;table:ice_locker"` // 状态
+	StartTime      string `form:"startTime" search:"-"`                                                            // 开始时间
+	EndTime        string `form:"endTime" search:"-"`                                                              // 结束时间
+	CoolerBoxId    string `form:"coolerBoxId" search:"type:contains;column:cooler_box_id;table:cooler_box_record"` // 保温箱id
+}
+
+func (m *GetCoolerBoxIceAll) GetNeedSearch() interface{} {
+	return *m
 }

+ 10 - 0
app/admin/service/dto/ice_locker.go

@@ -20,6 +20,16 @@ type IceLockerOrder struct {
 	CreatedAtOrder string `search:"type:order;column:created_at;table:ice_locker" form:"createdAtOrder" default:"desc"`
 	IdOrder        string `search:"type:order;column:id;table:ice_locker" form:"idOrder" default:"desc"`
 }
+type GetIceLockerReq struct {
+	dto.Pagination `search:"-"`
+	Status         string `form:"status" search:"type:exact;column:status;table:ice_raft_record"`
+	Locker         int    `form:"LockerId" search:"type:exact;column:ice_locker_id;table:ice_raft_record"`
+	Code           string `form:"code" search:"type:contains;column:code;table:ice_raft"` // 冰排名称
+}
+
+func (m *GetIceLockerReq) GetNeedSearch() interface{} {
+	return *m
+}
 
 func (m *IceLockerGetPageReq) GetNeedSearch() interface{} {
 	return *m

+ 40 - 21
app/admin/service/dto/ice_raft.go

@@ -12,6 +12,14 @@ type IceRaftGetPageReq struct {
 	Status         string `form:"status" search:"type:exact;column:status;table:ice_raft"` // 状态
 	IceRaftOrder
 }
+type IceRaftRecordRecording struct {
+	dto.Pagination `search:"-"`
+	StartTime      string `form:"startTime" search:"-"`                                                          // 开始时间
+	EndTime        string `form:"endTime" search:"-"`                                                            // 结束时间
+	CoolerBoxId    int    `form:"coolerBoxId" search:"type:contains;column:cooler_box_id;table:ice_raft_record"` // 保温箱id
+	IceLockerId    int    `form:"iceLockerId" search:"type:contains;column:ice_locker_id;table:ice_raft_record"` // 冷冻柜id
+	Code           string `form:"code" search:"type:contains;column:code;table:ice_raft_record"`                 // 冰排名称
+}
 type IceRaftGetNewestRecordPageReq struct {
 	dto.Pagination `search:"-"`
 	Code           string `form:"code" search:"type:contains;column:code;table:ice_raft"` // 冰排名称
@@ -30,6 +38,9 @@ type IceRaftOrder struct {
 	IdOrder        string `search:"type:order;column:id;table:ice_raft" form:"idOrder" default:"desc"`
 }
 
+func (m *IceRaftRecordRecording) GetNeedSearch() interface{} {
+	return *m
+}
 func (m *IceRaftGetPageReq) GetNeedSearch() interface{} {
 	return *m
 }
@@ -38,14 +49,15 @@ func (m *IceRaftGetNewestRecordPageReq) GetNeedSearch() interface{} {
 }
 
 type IceRaftInsertReq struct {
-	Id                  int      `json:"id" comment:"编码" swaggerignore:"true"`  // 编码
-	CodeList            []string `json:"codeList" vd:"len($)>0;msg:'冰排编号不能为空'"` // 冰排名称
-	Status              string   `json:"status"`                                // 1-停用 2-正常
-	FreezeClaim         float32  `json:"freezeClaim"`                           // 冷冻要求 单位小时
-	Label               string   `json:"label"`                                 // 标签
-	SuitableForColdTime int      `json:"suitableForColdTime"`                   // 适冷时间 单位分钟
-	common.ControlBy    `swaggerignore:"true"`
-	common.DeptBy       `swaggerignore:"true"`
+	Id               int              `json:"id" comment:"编码" swaggerignore:"true"`                     // 编码
+	CodeList         []string         `json:"codeList" vd:"len($)>0;msg:'冰排编号不能为空'"`                    // 冰排名称
+	Status           string           `json:"status"`                                                   // 1-停用 2-正常
+	FreezeClaim      common.FloatList `json:"freezeClaim"`                                              // 冷冻要求 单位小时
+	Label            string           `json:"label"`                                                    // 标签
+	IceColdAddress   string           `json:"iceColdAddress" gorm:"size:128;comment:冰排预冷地点"`            //冰排预冷地点
+	SuitableForCold  float32          `json:"suitableForCold" gorm:"type:decimal(10,2);comment:冰排适冷温度"` // 冰排遇冷温度
+	common.ControlBy `swaggerignore:"true"`
+	common.DeptBy    `swaggerignore:"true"`
 }
 
 func (s *IceRaftInsertReq) Generate(model *model.IceRaft, code string) {
@@ -56,7 +68,8 @@ func (s *IceRaftInsertReq) Generate(model *model.IceRaft, code string) {
 	model.Status = s.Status
 	model.FreezeClaim = s.FreezeClaim
 	model.Label = s.Label
-	model.SuitableForColdTime = s.SuitableForColdTime
+	model.IceColdAddress = s.IceColdAddress
+	model.SuitableForCold = s.SuitableForCold
 	if s.ControlBy.UpdateBy != 0 {
 		model.UpdateBy = s.UpdateBy
 	}
@@ -73,13 +86,14 @@ func (s *IceRaftInsertReq) GetId() interface{} {
 }
 
 type IceRaftUpdateReq struct {
-	Id                  int     `json:"id" comment:"编码"`                   // 编码
-	Label               string  `json:"label" gorm:"size:128;comment:标签"`  // 标签
-	Code                string  `json:"code" vd:"len($)>0;msg:'冰排编号不能为空'"` // 冰排名称
-	Status              string  `json:"status"`                            // 1-停用 2-正常
-	FreezeClaim         float32 `json:"freezeClaim"`                       // 冷冻要求 单位小时
-	SuitableForColdTime int     `json:"suitableForColdTime"`               // 适冷时间 单位分钟
-	common.ControlBy    `swaggerignore:"true"`
+	Id               int              `json:"id" comment:"编码"`                                          // 编码
+	Label            string           `json:"label" gorm:"size:128;comment:标签"`                         // 标签
+	Code             string           `json:"code" vd:"len($)>0;msg:'冰排编号不能为空'"`                        // 冰排名称
+	Status           string           `json:"status"`                                                   // 1-停用 2-正常
+	FreezeClaim      common.FloatList `json:"freezeClaim"`                                              // 冷冻要求 单位小时
+	IceColdAddress   string           `json:"iceColdAddress" gorm:"size:128;comment:冰排预冷地点"`            //冰排预冷地点
+	SuitableForCold  float32          `json:"suitableForCold" gorm:"type:decimal(10,2);comment:冰排适冷温度"` // 冰排遇冷温度
+	common.ControlBy `swaggerignore:"true"`
 }
 
 func (s *IceRaftUpdateReq) Generate(model *model.IceRaft) {
@@ -90,7 +104,8 @@ func (s *IceRaftUpdateReq) Generate(model *model.IceRaft) {
 	model.Status = s.Status
 	model.FreezeClaim = s.FreezeClaim
 	model.Label = s.Label
-	model.SuitableForColdTime = s.SuitableForColdTime
+	model.IceColdAddress = s.IceColdAddress
+	model.SuitableForCold = s.SuitableForCold
 	if s.ControlBy.UpdateBy != 0 {
 		model.UpdateBy = s.UpdateBy
 	}
@@ -139,6 +154,10 @@ type IceRaftOutStorageReq struct {
 type IceStartbleForColfTimReq struct {
 	Id []string `json:"id"`
 }
+type IceOutStorageReq struct {
+	Code             []string `json:"code"`
+	common.ControlBy `swaggerignore:"true"`
+}
 
 type IceRaftRecordGetPageReq struct {
 	dto.Pagination `search:"-"`
@@ -155,10 +174,10 @@ func (m *IceRaftRecordGetPageReq) GetNeedSearch() interface{} {
 }
 
 type IceRaftRecordUpdateReq struct {
-	Id               int     `json:"id" comment:"编码"` // 编码
-	IceLockerId      int     `json:"iceLockerId"`     // 冷冻柜id
-	CoolerBoxId      int     `json:"coolerBoxId"`     // 保温箱id
-	FreezeClaim      float32 `json:"freezeClaim"`     // 冷冻要求 单位小时
+	Id               int              `json:"id" comment:"编码"` // 编码
+	IceLockerId      int              `json:"iceLockerId"`     // 冷冻柜id
+	CoolerBoxId      int              `json:"coolerBoxId"`     // 保温箱id
+	FreezeClaim      common.FloatList `json:"freezeClaim"`     // 冷冻要求 单位小时
 	common.ControlBy `swaggerignore:"true"`
 }
 

+ 20 - 17
app/admin/service/dto/waybill.go

@@ -44,23 +44,25 @@ func (m *WaybillGetCustomerPageReq) GetNeedSearch() interface{} {
 }
 
 type WaybillInsertReq struct {
-	Id                      int    `json:"id" comment:"编码" swaggerignore:"true"`                                 // 编码
-	No                      string `json:"no" swaggerignore:"true"`                                              //单号
-	OrderNo                 string `json:"orderNo"`                                                              // 订单号
-	Status                  int    `json:"status" swaggerignore:"true"`                                          //订单状态:1-待处理;102-待装车 103-运输中 104-已签收
-	SaveConsigneeAddress    bool   `json:"SaveConsigneeAddress"`                                                 //保存收货地址
-	ConsigneeAddressDetails string `json:"consigneeAddressDetails"`                                              //收发货地址详情
-	ConsigneeAddressName    string `json:"consigneeAddressName"`                                                 //收发货地址名称
-	ConsigneeAddressPhone   string `json:"consigneeAddressPhone" vd:"regexp('^1[3-9]\\d{9}$');msg:'收件人电话格式不正确'"` //收发货地址电话
-	DeliveryName            string `json:"deliveryName"`                                                         // 配送姓名
-	DeliveryPhone           string `json:"deliveryPhone"`                                                        // 配送电话
-	DeliveryId              int    `json:"deliveryId"`                                                           // 配送人id
-	ReCheckId               int    `json:"reCheckId"`                                                            // 复核人id
-	Quantity                int    `json:"quantity"`                                                             // 药品数量
-	Remark                  string `json:"remark"`                                                               // 运输备注
-	TamperProofLabel        string `json:"tamperProofLabel"`                                                     // 防拆码标签
-	TamperProofLabelImg     string `json:"tamperProofLabelImg"`                                                  // 防拆码标签图片
-	CoolerBoxId             int    `json:"coolerBoxId"`                                                          // 保温箱id
+	Id                      int          `json:"id" comment:"编码" swaggerignore:"true"`                                 // 编码
+	No                      string       `json:"no" swaggerignore:"true"`                                              //单号
+	OrderNo                 string       `json:"orderNo"`                                                              // 订单号
+	Status                  int          `json:"status" swaggerignore:"true"`                                          //订单状态:1-待处理;102-待装车 103-运输中 104-已签收
+	SaveConsigneeAddress    bool         `json:"SaveConsigneeAddress"`                                                 //保存收货地址
+	ConsigneeAddressDetails string       `json:"consigneeAddressDetails"`                                              //收发货地址详情
+	ConsigneeAddressName    string       `json:"consigneeAddressName"`                                                 //收发货地址名称
+	ConsigneeAddressPhone   string       `json:"consigneeAddressPhone" vd:"regexp('^1[3-9]\\d{9}$');msg:'收件人电话格式不正确'"` //收发货地址电话
+	DeliveryName            string       `json:"deliveryName"`                                                         // 配送姓名
+	DeliveryPhone           string       `json:"deliveryPhone"`                                                        // 配送电话
+	DeliveryId              int          `json:"deliveryId"`                                                           // 配送人id
+	ReCheckId               int          `json:"reCheckId"`                                                            // 复核人id
+	Quantity                int          `json:"quantity"`                                                             // 药品数量
+	Remark                  string       `json:"remark"`                                                               // 运输备注
+	TamperProofLabel        string       `json:"tamperProofLabel"`                                                     // 防拆码标签
+	TamperProofLabelImg     string       `json:"tamperProofLabelImg"`                                                  // 防拆码标签图片
+	CoolerBoxId             int          `json:"coolerBoxId"`                                                          // 保温箱id
+	IsSecondaryDistribution bool         `json:"is_secondary_distribution"`                                            //是否二次分配
+	Drugs                   []model.Drug `json:"drugs"`                                                                //药品信息
 	model2.ControlBy        `swaggerignore:"true"`
 	model2.DeptBy
 }
@@ -83,6 +85,7 @@ func (s *WaybillInsertReq) Generate(m *model.Waybill) {
 	m.TamperProofLabel = s.TamperProofLabel
 	m.TamperProofLabelImg = s.TamperProofLabelImg
 	m.CoolerBoxId = s.CoolerBoxId
+	m.IsSecondaryDistribution = s.IsSecondaryDistribution
 	m.OrderTime = model2.Time(time.Now())
 
 	if s.ControlBy.UpdateBy != 0 {

+ 39 - 0
app/admin/service/ice_locker.go

@@ -329,3 +329,42 @@ func (e *IceLocker) BatchInsert(c *dto.IceLockerBatchInsertReq) error {
 	return nil
 
 }
+func (e *IceLocker) GetIceLocker(c *dto.GetIceLockerReq, list *[]model.IceRaft, p *actions.DataPermission, count *int64) error {
+	var err error
+	tx := e.Orm.Begin()
+	defer func() {
+		if err != nil {
+			tx.Rollback()
+		} else {
+			tx.Commit()
+		}
+	}()
+	//查询冷冻柜是否存在
+	var icerecord model.IceRaft
+
+	err = e.Orm.Model(&icerecord).
+		Scopes(
+			cDto.MakeCondition(c.GetNeedSearch()),
+			cDto.Paginate(c.GetPageSize(), c.GetPageIndex()),
+			actions.Permission(icerecord.TableName(), p),
+			IceRaftNameRecordIceLockerScopes(c.Status),
+			IceRaftNameRecordIceLockerIdScopes(c.Locker),
+		).
+		//Where("ice_raft.status = '2'").
+		Joins("left join ice_raft_record on ice_raft.ice_raft_record_id = ice_raft_record.id").
+		Preload("IceRaftRecord.IceLocker").
+		Preload("IceRaftRecord.CoolerBox").
+		Preload("IceRaftRecord").
+		//Order("FIELD(ice_raft_record.status,'2','','1','3','4')").
+		Find(list).Limit(-1).Offset(-1).
+		Count(count).Error
+	if err != nil {
+		e.Log.Errorf("db error: %s", err)
+		if errors.Is(err, gorm.ErrRecordNotFound) {
+			return global.GetFailedErr
+		}
+		return global.GetFailedErr
+	}
+
+	return nil
+}

+ 177 - 6
app/admin/service/ice_raft.go

@@ -11,6 +11,7 @@ import (
 	"fmt"
 	"gogs.baozhida.cn/zoie/OAuth-core/service"
 	"gorm.io/gorm"
+	"sort"
 	"time"
 )
 
@@ -58,6 +59,18 @@ func IceRaftNameRecordStatusScopes(status string) func(db *gorm.DB) *gorm.DB {
 		return db.Where("ice_raft_record.status = ?", status)
 	}
 }
+func IceRaftNameRecordIceLockerScopes(status string) func(db *gorm.DB) *gorm.DB {
+	return func(db *gorm.DB) *gorm.DB {
+		if len(status) == 0 {
+			return db.Where("ice_raft_record.status = 1 or ice_raft_record.status =2")
+		}
+		if status == "0" {
+			return db.Where("ice_raft_record.status is null")
+
+		}
+		return db.Where("ice_raft_record.status = ?", status)
+	}
+}
 func IceRaftNameRecordIceLockerIdScopes(iceLockerId int) func(db *gorm.DB) *gorm.DB {
 	return func(db *gorm.DB) *gorm.DB {
 		if iceLockerId == 0 {
@@ -75,6 +88,22 @@ func IceRaftNameRecordCoolerBoxIdScopes(coolerBoxId int) func(db *gorm.DB) *gorm
 		return db.Where("ice_raft_record.cooler_box_id = ?", coolerBoxId)
 	}
 }
+func IceRaftStartTimeAndEndTimeScopes(startTime, endtime string) func(db *gorm.DB) *gorm.DB {
+	return func(db *gorm.DB) *gorm.DB {
+		if len(startTime) == 0 {
+			return db
+		}
+		return db.Where("ice_raft_record.ice_use_time >= ?", startTime).Where("ice_raft_record.ice_use_time <= ?", endtime)
+	}
+}
+func CollerStartTimeAndEndTimeScopes(startTime, endtime string) func(db *gorm.DB) *gorm.DB {
+	return func(db *gorm.DB) *gorm.DB {
+		if len(startTime) == 0 {
+			return db
+		}
+		return db.Where("cooler_box_record.cooler_box_star_time >= ?", startTime).Where("cooler_box_record.cooler_box_star_time <= ?", endtime)
+	}
+}
 
 func (e *IceRaft) GetRecordPage(c *dto.IceRaftGetNewestRecordPageReq, list *[]model.IceRaft, count *int64, p *actions.DataPermission) error {
 	var err error
@@ -368,12 +397,14 @@ func (e *IceRaft) InStorage(c *dto.IceRaftInStorageReq, p *actions.DataPermissio
 			IceRaftId:     iceRaftModel.Id,
 			Status:        model.IceRaftRecordStatusFreezing,
 			Label:         iceRaftModel.Label,
+			Code:          code,
 			InStorageTime: model2.Time(time.Now()),
-			FreezeClaim:   iceRaftModel.FreezeClaim,
+			//FreezeClaim:   iceRaftModel.FreezeClaim,
 			DeptBy: model2.DeptBy{
 				DeptId: p.DeptId,
 			},
 		}
+		iceRaftRecordModel.FreezeClaim = append(iceRaftRecordModel.FreezeClaim, iceRaftModel.FreezeClaim...)
 		err = tx.Create(&iceRaftRecordModel).Error
 		if err != nil {
 			e.Log.Errorf("db error: %s", err)
@@ -418,7 +449,11 @@ func (e *IceRaft) OutStorage(c *dto.IceRaftOutStorageReq, p *actions.DataPermiss
 		err = errors.New("保温箱状态异常")
 		return err
 	}
-
+	var user model.SysUser
+	first := e.Orm.Model(&model.SysUser{}).Where("id = ?", p.UserId).First(&user)
+	if first.Error != nil {
+		return global.GetFailedErr
+	}
 	for _, code := range c.Code {
 		// 查询冰排是否存在
 		var iceRaftModel model.IceRaft
@@ -452,15 +487,33 @@ func (e *IceRaft) OutStorage(c *dto.IceRaftOutStorageReq, p *actions.DataPermiss
 		}
 
 		inTime := iceRaftRecordModel.InStorageTime.Local()
-		if inTime.Add(time.Hour * time.Duration(iceRaftRecordModel.FreezeClaim)).After(time.Now()) {
-			err = errors.New(fmt.Sprintf("冰排【%s】未达到冷冻时长,禁止出库", code))
+		sort.Slice(iceRaftRecordModel.FreezeClaim, func(i, j int) bool {
+			return iceRaftRecordModel.FreezeClaim[i] < iceRaftRecordModel.FreezeClaim[j]
+		})
+		err, sysUser := GetUserProfile(e.Orm, p.UserId)
+		if err != nil {
+			err = errors.New("获取用户信息失败")
 			return err
 		}
+		if sysUser.Dept.IsOutStorage {
+			for _, v := range iceRaftRecordModel.FreezeClaim {
+				if inTime.Add(time.Hour * time.Duration(v)).After(time.Now()) {
+					str := fmt.Sprintf("冰排【%s】未达到冷冻时长【%v】,禁止出库", code, v)
+					err = errors.New(str)
+					return err
+				}
+			}
+		}
+		//if inTime.Add(time.Hour * time.Duration(iceRaftRecordModel.FreezeClaim[0])).After(time.Now()) {
+		//	err = errors.New(fmt.Sprintf("冰排【%s】未达到冷冻时长,禁止出库", code))
+		//	return err
+		//}
 
 		iceRaftRecordModel.Status = model.IceRaftRecordStatusUsing
 		iceRaftRecordModel.CoolerBoxId = coolerBoxModel.Id
 		iceRaftRecordModel.OutStorageTime = model2.Time(time.Now())
-		iceRaftRecordModel.SuitableForCold = c.SuitableForCold
+		iceRaftRecordModel.IceUseUsers = user.NickName
+		iceRaftRecordModel.IceUseTime = model2.Time(time.Now())
 		//data, err := nats_server.Read_DeviceTask_List_By_Condition(coolerBoxModel.Sn)
 		//if data.T_State != 1 {
 		//	e.Log.Errorf("该保温箱未启动: %s", err)
@@ -478,14 +531,81 @@ func (e *IceRaft) OutStorage(c *dto.IceRaftOutStorageReq, p *actions.DataPermiss
 		}
 	}
 
+	//添加保温箱记录
+	var cooler model.CoolerBoxRecord
+	cooler.CoolerBoxId = coolerBoxModel.Id
+	cooler.CoolerUserTime = model2.Time(time.Now())
+	cooler.Sn = coolerBoxModel.Sn
+	cooler.Status = "1" //保温箱使用状态变为使用中
+	cooler.DeptId = p.DeptId
+	cooler.Name = coolerBoxModel.Name
+	cooler.HistoryCode = append(cooler.HistoryCode, c.Code...)
+	cooler.CoolerUseUsers = user.NickName
+	//查询是否有正在使用中的保温箱记录
+	var count int64
+	err = e.Orm.Model(&model.CoolerBoxRecord{}).Where("id = ?", coolerBoxModel.Id).Where("status = ?", "1").Count(&count).Error
+	if err != nil {
+		e.Log.Errorf("获取保温箱信息失败: %s", err)
+		return errors.New("获取保温箱信息失败")
+	}
+	//如果有正在使用中的保温箱记录,就更新
+	if count > 0 {
+		err = e.Orm.Updates(&cooler).Error
+		if err != nil {
+			e.Log.Errorf("db 更新保温箱记录失败: %s", err)
+			return errors.New("更新保温箱记录失败")
+		}
+	} else {
+		err = e.Orm.Create(&cooler).Error
+		if err != nil {
+			e.Log.Errorf("db 创建保温箱记录失败: %s", err)
+			return errors.New("创建保温箱记录失败")
+		}
+	}
 	return nil
 }
 
+// IsOutStorage 判断冰排是否达到冷冻时长
+func (e *IceRaft) IsOutStorage(c *dto.IceOutStorageReq, p *actions.DataPermission) (error, string) {
+	var err error
+	var str string
+	// 获取冰排记录
+	for _, v := range c.Code {
+		var iceRaftRecordModel model.IceRaftRecord
+		err = e.Orm.Scopes(actions.Permission(iceRaftRecordModel.TableName(), p)).
+			Where("code = ?", v).
+			Where("status = ?", model.IceRaftRecordStatusFreezing).Or("status = ?", model.IceRaftRecordStatusWaitUse).
+			First(&iceRaftRecordModel).Error
+		if err != nil {
+			e.Log.Errorf("db error: %s", err)
+			return errors.New("获取冰排记录失败,请确认冰排是否入库!"), ""
+		}
+
+		if len(iceRaftRecordModel.OutStorageTime.String()) > 0 {
+			err = errors.New(fmt.Sprintf("冰排【%s】已出库,禁止出库!", v))
+			return err, ""
+		}
+
+		inTime := iceRaftRecordModel.InStorageTime.Local()
+		sort.Slice(iceRaftRecordModel.FreezeClaim, func(i, j int) bool {
+			return iceRaftRecordModel.FreezeClaim[i] < iceRaftRecordModel.FreezeClaim[j]
+		})
+
+		for _, vs := range iceRaftRecordModel.FreezeClaim {
+			if inTime.Add(time.Hour * time.Duration(vs)).After(time.Now()) {
+				str = fmt.Sprintf("冰排编号【%s】未达到冷冻时长【%v】小时,已达到冷冻时长【%v】,是否继续出库", v, vs, time.Now().Sub(inTime))
+				break
+			}
+		}
+	}
+	return nil, str
+}
+
 // 查询保温箱关联的冰排
 func (e *IceRaft) GetPageByCoolerBoxId(coolerBoxId int, list *[]string, p *actions.DataPermission) error {
 	var data model.IceRaft
 	err := e.Orm.Model(&data).
-		Select("code").
+		Select("ice_raft.code").
 		Scopes(
 			actions.Permission(data.TableName(), p),
 			IceRaftNameRecordStatusScopes(model.IceRaftRecordStatusUsing),
@@ -686,9 +806,15 @@ func (e *IceRaftRecord) StartForCold(c *dto.IceStartbleForColfTimReq, p *actions
 			tx.Commit()
 		}
 	}()
+	var user model.SysUser
+	first := e.Orm.Model(&model.SysUser{}).Where("id = ?", p.UserId).First(&user)
+	if first.Error != nil {
+		return global.GetFailedErr
+	}
 	//查询冰排是否存在
 	for _, v := range c.Id {
 		var iceRaftRecordModel model.IceRaftRecord
+		var iceRaft model.IceRaft
 		err = e.Orm.Scopes(actions.Permission(iceRaftRecordModel.TableName(), p)).
 			First(&iceRaftRecordModel, v).Error
 		if err != nil {
@@ -698,7 +824,15 @@ func (e *IceRaftRecord) StartForCold(c *dto.IceStartbleForColfTimReq, p *actions
 			}
 			return global.UpdateFailedErr
 		}
+		err = e.Orm.Model(&iceRaft).Where("id = ?", iceRaftRecordModel.IceRaftId).Error
+		if err != nil {
+			return global.GetFailedErr
+		}
 		iceRaftRecordModel.StartIceColdTime = model2.Time(time.Now())
+		iceRaftRecordModel.Status = model.IceRaftRecordReleasedInTheCold //释冷中
+		iceRaftRecordModel.IceColdUsers = user.NickName
+		iceRaftRecordModel.IceColdAddress = iceRaft.IceColdAddress
+		iceRaftRecordModel.SuitableForCold = iceRaft.SuitableForCold
 		updates := tx.Where("id = ?", iceRaftRecordModel.Id).Updates(&iceRaftRecordModel)
 		if err = updates.Error; err != nil {
 			e.Log.Errorf("db error: %s", err)
@@ -707,3 +841,40 @@ func (e *IceRaftRecord) StartForCold(c *dto.IceStartbleForColfTimReq, p *actions
 	}
 	return nil
 }
+
+// IceRaftRecordRecording 获取冰排的历史记录
+func (e *IceRaft) IceRaftRecordRecording(c *dto.IceRaftRecordRecording, list *[]model.IceRaftRecord, count *int64, p *actions.DataPermission) error {
+	var err error
+	var data model.IceRaftRecord
+	if c.PageSize == 9999 {
+		err = e.Orm.Model(&data).
+			Scopes(
+				cDto.MakeCondition(c.GetNeedSearch()),
+				actions.Permission(data.TableName(), p),
+				IceRaftStartTimeAndEndTimeScopes(c.StartTime, c.EndTime),
+			).
+			Where("status =?", model.IceRaftRecordStatusFinish).
+			Preload("IceLocker").
+			Preload("CoolerBox").
+			Find(list).Limit(-1).Offset(-1).
+			Count(count).Error
+	} else {
+		err = e.Orm.Model(&data).
+			Scopes(
+				cDto.MakeCondition(c.GetNeedSearch()),
+				cDto.Paginate(c.GetPageSize(), c.GetPageIndex()),
+				actions.Permission(data.TableName(), p),
+				IceRaftStartTimeAndEndTimeScopes(c.StartTime, c.EndTime),
+			).
+			Where("status =?", model.IceRaftRecordStatusFinish).
+			Preload("IceLocker").
+			Preload("CoolerBox").
+			Find(list).Limit(-1).Offset(-1).
+			Count(count).Error
+	}
+	if err != nil {
+		e.Log.Errorf("db error: %s", err)
+		return global.GetFailedErr
+	}
+	return nil
+}

+ 13 - 0
app/admin/service/sys_user.go

@@ -405,3 +405,16 @@ func (e *SysUser) GetProfile(c *dto.SysUserById, user *model.SysUser) error {
 
 	return nil
 }
+
+// GetUserProfile 获取当前用户权限
+func GetUserProfile(e *gorm.DB, userid int) (err error, user model.SysUser) {
+	err = e.Preload("Dept").First(&user, userid).Error
+	if err != nil {
+		if errors.Is(err, gorm.ErrRecordNotFound) {
+			return errors.New("User not found"), user
+		}
+		return err, user
+	}
+
+	return nil, user
+}

+ 84 - 16
app/admin/service/waybill.go

@@ -324,6 +324,12 @@ func (e *Waybill) Insert(c *dto.WaybillInsertReq) error {
 
 	// 添加运单
 	data.WaybillNo = no
+	sole, err := e.CreateSole()
+	if err != nil {
+		err = errors.New("生成运单号失败")
+		return err
+	}
+	data.OrderNo = sole
 	c.Generate(&data)
 	err = tx.Create(&data).Error
 	if err != nil {
@@ -371,9 +377,27 @@ func (e *Waybill) Insert(c *dto.WaybillInsertReq) error {
 			}
 		}
 	}
-
+	if len(c.Drugs) > 0 {
+		for _, drug := range c.Drugs {
+			var drugs model.Drug
+			drugs.WaybillNo = no
+			drugs.Drug_ent_base_info_id = drug.Drug_ent_base_info_id
+			drugs.Ent_name = drug.Ent_name
+			drugs.Physic_name = drug.Physic_name
+			drugs.Approval_licence_no = drug.Approval_licence_no
+			drugs.Prepn_spec = drug.Prepn_spec
+			drugs.Physic_type_desc = drug.Physic_type_desc
+			drugs.Pkg_spec_crit = drug.Pkg_spec_crit
+			drugs.Prepn_type_desc = drug.Prepn_type_desc
+			drugs.Code = drug.Code
+			err = tx.Save(&drugs).Error
+			if err != nil {
+				e.Log.Errorf("db error: %s", err)
+				return errors.New("保存药品信息失败")
+			}
+		}
+	}
 	return nil
-
 }
 
 // Update 修改Waybill对象
@@ -635,6 +659,11 @@ func (e *Waybill) Delivery(c *dto.WaybillDeliveryReq, p *actions.DataPermission)
 			return errors.New("获取保温箱信息失败")
 		}
 	}
+	var user model.SysUser
+	first := e.Orm.Table(user.TableName()).Where("id = ?", p.UserId).First(&user)
+	if first.Error != nil {
+		return global.GetFailedErr
+	}
 
 	for _, id := range c.WaybillIds {
 
@@ -650,7 +679,7 @@ func (e *Waybill) Delivery(c *dto.WaybillDeliveryReq, p *actions.DataPermission)
 			return global.UpdateFailedErr
 		}
 		//派单时添加
-		waybillModeStatus := waybillModel.Status
+		//waybillModeStatus := waybillModel.Status
 		if waybillModel.Status == model.WaybillStatusInDeliverys ||
 			(waybillModel.Status == model.WaybillStatusInDeliverys && waybillModel.CoolerBoxId != c.CoolerBoxId) ||
 			(waybillModel.Status == model.WaybillStatusInDeliverys && !lib.StrListEqual(c.IceRaftCode, c.OldIceRaftCode)) {
@@ -664,20 +693,58 @@ func (e *Waybill) Delivery(c *dto.WaybillDeliveryReq, p *actions.DataPermission)
 			waybillModel.IceRaftCode = c.IceRaftCode
 			if c.Status == model.WaybillStatusInShippeds {
 				waybillModel.Status = c.Status
+				// 查询保温箱信息
+				var coolerBoxModel model.CoolerBox
+				err = e.Orm.Scopes(actions.Permission(coolerBoxModel.TableName(), p)).
+					First(&coolerBoxModel, waybillModel.CoolerBoxId).Error
+				if err != nil {
+					e.Log.Errorf("获取保温箱信息失败: %s", err)
+					return errors.New("获取保温箱信息失败")
+				}
+				var data model.IceRaft
+				var list []string
+				err := e.Orm.Model(&data).
+					Select("ice_raft.code").
+					Scopes(
+						actions.Permission(data.TableName(), p),
+						IceRaftNameRecordStatusScopes(model.IceRaftRecordStatusUsing),
+						IceRaftNameRecordCoolerBoxIdScopes(coolerBoxModel.Id),
+					).
+					Joins("left join ice_raft_record on ice_raft.ice_raft_record_id = ice_raft_record.id").
+					Find(&list).Error
+				if err != nil {
+					e.Log.Errorf("db error: %s", err)
+					return errors.New("获取冰排编号失败")
+				}
+				//查询保温箱记录信息状态为1使用中
+				var cooler model.CoolerBoxRecord
+				err = e.Orm.Scopes(actions.Permission(cooler.TableName(), p)).
+					First(&cooler).Where("cooler_box_id = ?", coolerBoxModel.Id).Where("status = ?", 1).Error
+				if err != nil {
+					e.Log.Errorf("db 获取保温箱记录信息失败: %s", err)
+					return errors.New("获取保温箱记录信息失败")
+				}
+				cooler.CoolerUseUsers = user.NickName
+				cooler.HistoryCode = append(cooler.HistoryCode, list...)
+				cooler.CoolerUserTime = model2.Time(time.Now())
+				cooler.Status = "2" //使用结束
+				err = e.Orm.Updates(&cooler).Where("id = ?", cooler.Id).Error
+				if err != nil {
+					e.Log.Errorf("db error: %s", err)
+					return errors.New("保存保温箱记录失败")
+				}
 				// 配送中状态下才发送短信
-				if waybillModeStatus == model.WaybillStatusInShippeds {
-					ss := sms.NewSMS(conf.ExtConfig.SubMail.Appid, conf.ExtConfig.SubMail.Signature)
-					addr := conf.ExtConfig.Applet.WaybillUrl + url.QueryEscape(lib.AesEncryptCBC(waybillModel.WaybillNo, lib.AesKey))
-					res, err1 := ss.SmsXSend(waybillModel.ConsigneeAddressPhone, addr)
-					if err1 != nil || res.Status != sms.SUCCESS {
-						e.Log.Errorf("派单短信发送失败", zap.Any("res", res), zap.Error(err1))
-						err = errors.New("派单短信发送失败,请检查收件人电话是否正确!")
-						return err
-					}
-					waybillModel.SendLog = model.WaybillSendLog{
-						Phone:   waybillModel.ConsigneeAddressPhone,
-						Content: "【冷链送药追溯平台】您的运单正在派送中,点击查看详情:" + addr,
-					}
+				ss := sms.NewSMS(conf.ExtConfig.SubMail.Appid, conf.ExtConfig.SubMail.Signature)
+				addr := conf.ExtConfig.Applet.WaybillUrl + url.QueryEscape(lib.AesEncryptCBC(waybillModel.WaybillNo, lib.AesKey))
+				res, err1 := ss.SmsXSend(waybillModel.ConsigneeAddressPhone, addr)
+				if err1 != nil || res.Status != sms.SUCCESS {
+					e.Log.Errorf("派单短信发送失败", zap.Any("res", res), zap.Error(err1))
+					err = errors.New("派单短信发送失败,请检查收件人电话是否正确!")
+					return err
+				}
+				waybillModel.SendLog = model.WaybillSendLog{
+					Phone:   waybillModel.ConsigneeAddressPhone,
+					Content: "【冷链送药追溯平台】您的运单正在派送中,点击查看详情:" + addr,
 				}
 				// 查询任务
 				var logistics model.WaybillLogistics
@@ -1571,6 +1638,7 @@ func (e *Waybill) WaybillTurnarounds(c *dto.WaybillTurnarounds, p *actions.DataP
 	for _, v := range Depts {
 		if v.Id == c.DeptId {
 			contains = true
+			break
 		} else {
 			contains = false
 		}

+ 1 - 1
app/jobs/jobs.go

@@ -65,7 +65,7 @@ func (t CountIceRaftRecordFreezeDuration) Exec(arg interface{}) error {
 
 		inTime := record.InStorageTime.Local()
 		//if inTime.Add(time.Hour * time.Duration(record.FreezeClaim)).After(time.Now()) {
-		if inTime.Add(time.Duration(float64(time.Hour) * float64(record.FreezeClaim))).After(time.Now()) {
+		if inTime.Add(time.Duration(float64(time.Hour) * record.FreezeClaim[0])).After(time.Now()) {
 			// 未达到冷冻时长 不修改状态 只修改时间
 			record.FreezeDuration = int(time.Now().Sub(inTime).Minutes())
 		} else {

+ 23 - 0
common/model/byat.go

@@ -3,6 +3,7 @@ package model
 import (
 	"database/sql/driver"
 	"encoding/json"
+	"errors"
 	"fmt"
 	"gorm.io/gorm"
 	"time"
@@ -99,7 +100,29 @@ func (t *Time) Scan(v interface{}) error {
 }
 
 type StringList []string
+type FloatList []float64
 
+func (f *FloatList) Scan(value interface{}) error {
+	if value == nil {
+		return nil
+	}
+
+	switch v := value.(type) {
+	case string:
+		return json.Unmarshal([]byte(v), f)
+	case []byte:
+		return json.Unmarshal(v, f)
+	case float64:
+		*f = FloatList{v}
+		return nil
+	default:
+		return errors.New("cannot unmarshal type into FloatList")
+	}
+}
+
+func (f FloatList) Value() (driver.Value, error) {
+	return json.Marshal(f)
+}
 func (e StringList) Value() (driver.Value, error) {
 	d, err := json.Marshal(e)
 	return string(d), err

+ 2 - 0
db/migration.go

@@ -29,6 +29,8 @@ func AutoMigrateDB() {
 			&model.IceRaft{},
 			&model.IceLocker{},
 			&model.IceRaftRecord{},
+			&model.CoolerBoxRecord{},
+			&model.Drug{},
 		)
 	if err != nil {
 		zap.L().Panic("migrate db fail", zap.Error(err))