zhangqian
2023-11-29 d1cb09e7a23e7221b6c090ad33e4481a5b79f615
controllers/operation.go
@@ -172,6 +172,30 @@
   return nil
}
// GetOperationInfo
// @Tags      入库/出库
// @Summary   入库/出库列表
// @Produce   application/json
//
//   @Param      id   path      string         true   "id"
//
// @Success   200 {object} util.Response   "成功"
// @Router    /api-wms/v1/operation/getOperationInfo/{id} [get]
func (slf OperationController) GetOperationInfo(c *gin.Context) {
   number := c.Param("id")
   if number == "" {
      util.ResponseFormat(c, code.RequestParamError, "参数解析失败,参数不能为空")
      return
   }
   id, _ := strconv.Atoi(number)
   operation, err := models.NewOperationSearch().SetID(id).SetPreload(true).First()
   if err != nil {
      util.ResponseFormat(c, code.RequestParamError, err.Error())
      return
   }
   util.ResponseFormat(c, code.Success, operation)
}
// List
// @Tags      入库/出库
// @Summary   入库/出库列表
@@ -709,6 +733,7 @@
func AddMoveHistory(operationList []*models.Operation, db *gorm.DB) error {
   var histories []*models.MoveHistory
   operationMap := make(map[string]*models.Operation, len(operationList))
   for _, operation := range operationList {
      for _, v := range operation.Details {
         history := &models.MoveHistory{
@@ -729,12 +754,13 @@
         }
         histories = append(histories, history)
      }
      operationMap[operation.Number] = operation
   }
   if err := db.Model(&models.MoveHistory{}).Create(&histories).Error; err != nil {
      return err
   }
   for _, history := range histories {
      service.AddNewHistoryReportRecord(history.Id)
      service.AddNewHistoryReportRecord(history, operationMap[history.Number])
   }
   return nil
}