数据分析平台 报警设置窗口-按测试厂
报警设置窗口-按产品型号
This commit is contained in:
parent
58e060805f
commit
04e4ca1225
@ -7,7 +7,7 @@ import (
|
||||
|
||||
type Warning struct {
|
||||
ID int64 `json:"id" gorm:"primaryKey"`
|
||||
ProductionControl []ProductionControl `json:"production_control" gorm:"foreignKey:WarningID;references:ID"`
|
||||
//ProductionControl []ProductionControl `json:"production_control" gorm:"foreignKey:WarningID;references:ID"`
|
||||
PassProbabilityDiff []PassProbabilityDiff `json:"pass_probability_diff" gorm:"foreignKey:WarningID;references:ID"`
|
||||
BinControl []BinControl `json:"bin_control" gorm:"foreignKey:WarningID;references:ID"`
|
||||
SelectionDiffControl []SelectionDiffControl `json:"selection_diff_control" gorm:"foreignKey:WarningID;references:ID"`
|
||||
@ -27,7 +27,7 @@ type Warning struct {
|
||||
|
||||
type ProductionControl struct {
|
||||
ID int64 `json:"id" gorm:"primaryKey"`
|
||||
WarningID int64 `json:"warning_id"`
|
||||
//WarningID int64 `json:"warning_id"`
|
||||
Factory string `json:"factory"`
|
||||
TestQuantityDiffH string `json:"test_quantity_diff_h"` // 测试数量差异上限
|
||||
TestQuantityDiffL string `json:"test_quantity_diff_l"` // 测试数量差异下限
|
||||
|
@ -90,7 +90,7 @@ func ShowListWarning(offset, limit int, keyWord string) ([]*model.Warning, int64
|
||||
|
||||
func DeleteWarning(req *model.Warning) error {
|
||||
var warning *model.Warning
|
||||
if errors.Is(global.PostGreSQL.Find(&warning, req.ID).Error, gorm.ErrRecordNotFound) {
|
||||
if errors.Is(global.PostGreSQL.First(&warning, req.ID).Error, gorm.ErrRecordNotFound) {
|
||||
return errors.New("未找到需要删除的型号信息")
|
||||
}
|
||||
global.PostGreSQL.Delete(&warning)
|
||||
@ -99,7 +99,7 @@ func DeleteWarning(req *model.Warning) error {
|
||||
|
||||
func UpdateWarningFactory(req *model.ProductionControl) error {
|
||||
var warning *model.ProductionControl
|
||||
if errors.Is(global.PostGreSQL.Where("factory = ?", req.Factory).Find(&warning).Error, gorm.ErrRecordNotFound) {
|
||||
if errors.Is(global.PostGreSQL.Where("factory = ?", req.Factory).First(&warning).Error, gorm.ErrRecordNotFound) {
|
||||
global.PostGreSQL.Create(&model.ProductionControl{
|
||||
Factory: req.Factory,
|
||||
TestQuantityDiffH: req.TestQuantityDiffH,
|
||||
@ -108,7 +108,7 @@ func UpdateWarningFactory(req *model.ProductionControl) error {
|
||||
PassQuantityDiffL: req.PassQuantityDiffL,
|
||||
})
|
||||
} else {
|
||||
global.PostGreSQL.Model(&req).Updates(map[string]interface{}{
|
||||
global.PostGreSQL.Model(&warning).Updates(map[string]interface{}{
|
||||
"test_quantity_diff_h": req.TestQuantityDiffH,
|
||||
"test_quantity_diff_l": req.TestQuantityDiffL,
|
||||
"pass_quantity_diff_h": req.PassQuantityDiffH,
|
||||
@ -133,7 +133,7 @@ func ShowListWarningFactory(offset, limit int, keyWord string) ([]*model.Product
|
||||
|
||||
func DeleteWarningFactory(req *model.ProductionControl) error {
|
||||
var warning *model.ProductionControl
|
||||
if errors.Is(global.PostGreSQL.Find(&warning, req.ID).Error, gorm.ErrRecordNotFound) {
|
||||
if errors.Is(global.PostGreSQL.First(&warning, req.ID).Error, gorm.ErrRecordNotFound) {
|
||||
return errors.New("未找到需要删除的测试厂信息")
|
||||
}
|
||||
global.PostGreSQL.Delete(&warning)
|
||||
|
Loading…
Reference in New Issue
Block a user