|
|
@@ -1,6 +1,7 @@
|
|
|
package setting
|
|
|
|
|
|
import (
|
|
|
+ "dashoo.cn/backend/api/business/limscheckequipmentlist"
|
|
|
"encoding/json"
|
|
|
"fmt"
|
|
|
"strconv"
|
|
|
@@ -115,6 +116,28 @@ func (this *ItemsController) AddDetectionModel() {
|
|
|
model.CreateuserId=this.User.Id
|
|
|
model.CreateBy=this.User.Realname
|
|
|
_,err:=svc.InsertEntityBytblOne("Base_ItemDetails_DetectionCycle",&model)
|
|
|
+
|
|
|
+ var list []limscheckequipmentlist.LimsCheckEquipmentList
|
|
|
+ where := "TemplateTypeId=" + strconv.Itoa(model.Pid)
|
|
|
+ svc.GetEntitysByWhere(this.User.AccCode + LimsCheckEquipmentListName, where, &list)
|
|
|
+
|
|
|
+ for _,item := range list {
|
|
|
+ cols := []string{"NextCheckDate", "Cycle", "CycleUnit"}
|
|
|
+ var entity limscheckequipmentlist.LimsCheckEquipmentList
|
|
|
+ entity.Cycle = float32(model.DetectionNum)
|
|
|
+ entity.CycleUnit = model.DetectionUnit
|
|
|
+ if model.DetectionUnit == "年" {
|
|
|
+ entity.NextCheckDate = item.LastCheckDate.AddDate(int(model.DetectionNum), 0, 0)
|
|
|
+ } else if model.DetectionUnit == "月" {
|
|
|
+ entity.NextCheckDate = item.LastCheckDate.AddDate(0, model.DetectionNum, 0)
|
|
|
+ } else if model.DetectionUnit == "日" {
|
|
|
+ entity.NextCheckDate = item.LastCheckDate.AddDate(0, 0, model.DetectionNum)
|
|
|
+ }
|
|
|
+
|
|
|
+ where := "Id=" + strconv.Itoa(item.Id)
|
|
|
+ svc.UpdateEntityBywheretbl(this.User.AccCode + LimsCheckEquipmentListName, &entity, cols, where)
|
|
|
+ }
|
|
|
+
|
|
|
if err == nil {
|
|
|
errinfo.Message = utils.AlertProcess("保存成功!")
|
|
|
errinfo.Code = 0
|
|
|
@@ -147,6 +170,28 @@ func (this *ItemsController) EditDetectionModel() {
|
|
|
|
|
|
cols := []string{"DetectionUnit","DetectionNum","ModifiedOn","ModifieduserId","ModifiedBy"}
|
|
|
_,err:=svc.UpdateEntityByIdCols(id,&model,cols)
|
|
|
+
|
|
|
+ var list []limscheckequipmentlist.LimsCheckEquipmentList
|
|
|
+ where := "TemplateTypeId=" + strconv.Itoa(model.Pid)
|
|
|
+ svc.GetEntitysByWhere(this.User.AccCode + LimsCheckEquipmentListName, where, &list)
|
|
|
+
|
|
|
+ for _,item := range list {
|
|
|
+ cols := []string{"NextCheckDate", "Cycle", "CycleUnit"}
|
|
|
+ var entity limscheckequipmentlist.LimsCheckEquipmentList
|
|
|
+ entity.Cycle = float32(model.DetectionNum)
|
|
|
+ entity.CycleUnit = model.DetectionUnit
|
|
|
+ if model.DetectionUnit == "年" {
|
|
|
+ entity.NextCheckDate = item.LastCheckDate.AddDate(int(model.DetectionNum), 0, 0)
|
|
|
+ } else if model.DetectionUnit == "月" {
|
|
|
+ entity.NextCheckDate = item.LastCheckDate.AddDate(0, model.DetectionNum, 0)
|
|
|
+ } else if model.DetectionUnit == "日" {
|
|
|
+ entity.NextCheckDate = item.LastCheckDate.AddDate(0, 0, model.DetectionNum)
|
|
|
+ }
|
|
|
+
|
|
|
+ where := "Id=" + strconv.Itoa(item.Id)
|
|
|
+ svc.UpdateEntityBywheretbl(this.User.AccCode + LimsCheckEquipmentListName, &entity, cols, where)
|
|
|
+ }
|
|
|
+
|
|
|
if err == nil {
|
|
|
errinfo.Message = utils.AlertProcess("保存成功!")
|
|
|
errinfo.Code = 0
|