zhangqian
2024-04-25 2d6875c93b25d0b7336c7fa11e066d213259fe2e
model/work_order.go
@@ -9,19 +9,19 @@
type (
   Order struct {
      gorm.Model
      WorkOrderID string          `gorm:"index;type:varchar(191);not null;comment:'工单ID'" json:"workOrderId"`
      OrderID     string          `gorm:"index;type:varchar(191);not null;comment:'订单ID'" json:"orderId"`
      ProductID   string          `gorm:"type:varchar(191);comment:'产品ID'" json:"productId"`
      ProductName string          `gorm:"type:varchar(191);comment:'产品名称'" json:"productName"`
      Parameter   string          `gorm:"type:varchar(1024);comment:'参数需求'" json:"parameter"`
      Customer    string          `gorm:"type:varchar(191);comment:'客户编码'" json:"customer"`
      DeliverDate string          `gorm:"type:varchar(100);comment:'交货日期'" json:"deliverDate"`
      CommonModel
      WorkOrderID string          `gorm:"index;type:varchar(191);not null" json:"workOrderId"`
      OrderID     string          `gorm:"index;type:varchar(191);not null" json:"orderId"`
      ProductID   string          `gorm:"type:varchar(191)" json:"productId"`
      ProductName string          `gorm:"type:varchar(191)" json:"productName"`
      Parameter   string          `gorm:"type:varchar(1024)" json:"parameter"`
      Customer    string          `gorm:"type:varchar(191)" json:"customer"`
      DeliverDate string          `gorm:"type:varchar(100)" json:"deliverDate"`
      OrderAttr   string          `json:"orderAttr"` // 订单属性拼接的字符串,即货物描述
      Amount      decimal.Decimal `gorm:"type:decimal(35,18);comment:'数量'" json:"amount"`
      Unit        string          `gorm:"type:varchar(100);comment:'单位'" json:"unit"`
      StartTime   int64           `gorm:"comment:'计划开始时间'" json:"startTime"`
      EndTime     int64           `gorm:"comment:'计划结束时间'" json:"endTime"`
      Amount      decimal.Decimal `gorm:"type:decimal(35,18)" json:"amount"`
      Unit        string          `gorm:"type:varchar(100)" json:"unit"`
      StartTime   int64           `json:"startTime"`
      EndTime     int64           `json:"endTime"`
      Status      OrderStatus
   }
@@ -127,6 +127,10 @@
      db = db.Where("work_order_id = ?", slf.WorkOrderID)
   }
   if len(slf.WorkOrderIDs) != 0 {
      db = db.Where("work_order_id in (?)", slf.WorkOrderIDs)
   }
   if slf.Status != 0 {
      db = db.Where("status = ?", slf.Status)
   }
@@ -156,17 +160,6 @@
   if err := db.Create(record).Error; err != nil {
      return fmt.Errorf("create err: %v, record: %+v", err, record)
   }
   return nil
}
// CreateBatch 批量插入
func (slf *OrderSearch) CreateBatch(records []*Order) error {
   var db = slf.build()
   if err := db.Create(&records).Error; err != nil {
      return fmt.Errorf("create batch err: %v, records: %+v", err, records)
   }
   return nil