4
0
Преглед на файлове

新增新型号液氮罐的默认冻存架、冻存盒规格信息,提取冻存架、冻存盒生成的公共方法

jianglw преди 4 години
родител
ревизия
7fe143e9d6

+ 1 - 0
src/dashoo.cn/backend/api/business/equipment/equipment.go

@@ -8,6 +8,7 @@ type Equipment struct {
 	Id             int       `xorm:"not null pk autoincr INT(10)"`
 	AccCode        string    `xorm:"VARCHAR(10)"`
 	ModelId        int       `xorm:"INT(10)"`
+	DItem          int		 `xorm:"INT(10)"`
 	Code           string    `xorm:"VARCHAR(50)"`
 	Name           string    `xorm:"VARCHAR(255)"`
 	Brand          string    `xorm:"VARCHAR(255)"`

+ 2 - 2
src/dashoo.cn/backend/api/business/samplesfileinfo/samplesfileinfoService.go

@@ -84,7 +84,7 @@ func (s *SamplesFileInfoService) GetPagingEntitiesWithTb(acccode string, pageInd
 	sqlCount := " select count(*) from " + tbldetail + " a  left join " + tblmain + " b on a.SampleCode = b.SampleCode left join " + tbldonor + " c on b.SourceId = c.Id left join " + groupdetail + " d on d.SampleId = a.Id where " + where
 	var sql string
 
-	sql = ` select a.*,b.*,c.Genus,concat(c.ProvinceName,c.CityName,c.StreetName,c.Address) as AddressName,c.SurveyDate,d.GroupId,d.GroupName from ` + tbldetail + ` a 
+	sql = ` select a.*,substr(a.SampleCode,6,4) as groupNo,b.*,c.Genus,concat(c.ProvinceName,c.CityName,c.StreetName,c.Address) as AddressName,c.SurveyDate,d.GroupId,d.GroupName from ` + tbldetail + ` a 
 	left join ` + tblmain + ` b on a.SampleCode = b.SampleCode  
 	left join ` + tbldonor + ` c on b.SourceId = c.Id  
 	left join ` + groupdetail + ` d on d.SampleId = a.Id  
@@ -153,7 +153,7 @@ func (s *SamplesFileInfoService) QueryAnimalSampleList(acccode string, where str
 	tblmain := acccode + SamplesMaintbName
 	tbldetail := acccode + SamplesDetailFiletbName
 	animaltb := acccode + AnimalInfoName
-	sql := "select a.*,b.*,c.Genus,c.GenusName,concat(c.ProvinceName,c.CityName,c.StreetName,c.Address) as AddressName,c.InnerNo as SourceInner,c.Amount,c.Unit as SourceUni,c.ProjectName,c.Longitude,c.Latitude,c.Altitude,c.SurveyDate,c.ZBack11 as BeeKeepers,c.ZBack17 as TakeAway from  " + tbldetail +
+	sql := "select a.*,substr(a.SampleCode,6,4) as groupNo,b.*,c.Genus,c.GenusName,concat(c.ProvinceName,c.CityName,c.StreetName,c.Address) as AddressName,c.InnerNo as SourceInner,c.Amount,c.Unit as SourceUni,c.ProjectName,c.Longitude,c.Latitude,c.Altitude,c.SurveyDate,c.ZBack11 as BeeKeepers,c.ZBack17 as TakeAway from  " + tbldetail +
 		" a left join " + tblmain + " b on a.SampleCode = b.SampleCode left join " + animaltb + " c on b.SourceId = c.Id where " + where + " order by a.Id desc"
 	List := make([]AnimalSamplesFileShow, 0)
 	utils.DBE.Sql(sql).Find(&List)

+ 4 - 4
src/dashoo.cn/backend/api/business/samplesinfo/samplesinfoService.go

@@ -63,7 +63,7 @@ func (s *SamplesInfoService) GetPagingEntitiesWithOrderSearch(acccode string, pa
 	fmt.Println(sqlCount)
 	var sql string
 
-	sql = ` select a.*,b.*,c.FamilyState,c.ClinicNum,d.XStation ShelfX,d.YStation ShelfY,d.Code ShelfCode,e.XStation BoxX,e.YStation BoxY,e.Code BoxCode,f.Id Eid,f.Name EName,f.Code ECode,g.GroupId,g.GroupName from ` + tbldetail + ` a 
+	sql = ` select a.*,substr(a.SampleCode,6,4) as groupNo, b.*,c.FamilyState,c.ClinicNum,d.XStation ShelfX,d.YStation ShelfY,d.Code ShelfCode,e.XStation BoxX,e.YStation BoxY,e.Code BoxCode,f.Id Eid,f.Name EName,f.Code ECode,g.GroupId,g.GroupName from ` + tbldetail + ` a 
 	left join ` + tblmain + ` b on a.SampleCode = b.SampleCode  
 	left join ` + tbldonor + ` c on b.SourceId = c.Id 
 	left join Shelf d on a.ShelfId=d.Id 
@@ -109,7 +109,7 @@ func (s *SamplesInfoService) GetPagingEntitiesWithTb(acccode string, pageIndex,
 	var sql string
 
 	//sql = ` select a.*,b.*,c.Genus,concat(c.ProvinceName,c.CityName,c.StreetName,c.Address) as AddressName,c.SurveyDate,d.XStation ShelfX,d.YStation ShelfY,d.Code ShelfCode,e.XStation BoxX,e.YStation BoxY,e.Code BoxCode,f.Id Eid,f.Name EName,f.Code ECode,g.GroupId,g.GroupName from ` + tbldetail + ` a
-	sql = ` select a.*,b.*,c.Genus,concat(c.ProvinceName,c.CityName,c.StreetName,c.Address) as AddressName,c.SurveyDate,d.XStation ShelfX,d.YStation ShelfY,d.Code ShelfCode,e.XStation BoxX,e.YStation BoxY,e.Code BoxCode,f.Id Eid,f.Name EName,f.Code ECode from ` + tbldetail + ` a
+	sql = ` select a.*,substr(a.SampleCode,6,4) as groupNo,b.*,c.Genus,concat(c.ProvinceName,c.CityName,c.StreetName,c.Address) as AddressName,c.SurveyDate,d.XStation ShelfX,d.YStation ShelfY,d.Code ShelfCode,e.XStation BoxX,e.YStation BoxY,e.Code BoxCode,f.Id Eid,f.Name EName,f.Code ECode from ` + tbldetail + ` a
 	left join ` + tblmain + ` b on a.SampleCode = b.SampleCode  
 	left join ` + tbldonor + ` c on b.SourceId = c.Id 
 	left join Shelf d on a.ShelfId=d.Id 
@@ -888,9 +888,9 @@ func (s *SamplesInfoService) QueryAnimalSampleList(acccode string, where string)
 	tblmain := acccode + SamplesMaintbName
 	tbldetail := acccode + SamplesDetailtbName
 	animaltb := acccode + AnimalInfoName
-	sql := "select a.*,b.*,c.Genus,c.GenusName,concat(c.ProvinceName,c.CityName,c.StreetName,c.Address) as AddressName,c.InnerNo as SourceInner,c.Amount,c.Unit as SourceUni,c.ProjectName,c.Longitude,c.Latitude,c.Altitude,c.SurveyDate,c.ZBack11 as BeeKeepers,c.ZBack17 as TakeAway from   " + tbldetail + " a left join " + tblmain +
+	sql := "select a.*,substr(a.SampleCode,6,4) as groupNo,b.*,c.Genus,c.GenusName,concat(c.ProvinceName,c.CityName,c.StreetName,c.Address) as AddressName,c.InnerNo as SourceInner,c.Amount,c.Unit as SourceUni,c.ProjectName,c.Longitude,c.Latitude,c.Altitude,c.SurveyDate,c.ZBack11 as BeeKeepers,c.ZBack17 as TakeAway from   " + tbldetail + " a left join " + tblmain +
 		" b on a.SampleCode = b.SampleCode left join " + animaltb +
-		" c on b.SourceId = c.Id where " + where + " order by a.Id desc"
+		" c on b.SourceId = c.Id where " + where + " order by a.Id desc, SourceName, groupNo asc , sampletype"
 	List := make([]AnimalSamplesInfoShow, 0)
 	utils.DBE.Sql(sql).Find(&List)
 

+ 30 - 30
src/dashoo.cn/backend/api/business/shelfset/shelfsetService.go

@@ -10,31 +10,31 @@ import (
 	"github.com/go-xorm/xorm"
 )
 
-type shelfsetService struct {
+type ShelfsetService struct {
 	ServiceBase
 }
 
-func GetshelfsetService(xormEngine *xorm.Engine) *shelfsetService {
-	s := new(shelfsetService)
+func GetshelfsetService(xormEngine *xorm.Engine) *ShelfsetService {
+	s := new(ShelfsetService)
 	s.DBE = xormEngine
 	return s
 }
 
-func (s *shelfsetService) GetShelfByid(id string) []Shelf {
+func (s *ShelfsetService) GetShelfByid(id string) []Shelf {
 	sql := `select * from Shelf where Id=` + id
 	List := make([]Shelf, 0)
 	s.DBE.Sql(sql).Find(&List)
 	return List
 }
 
-func (s *shelfsetService) GetBoxByid(id string) []Box {
+func (s *ShelfsetService) GetBoxByid(id string) []Box {
 	sql := `select * from Box where Id=` + id
 	List := make([]Box, 0)
 	s.DBE.Sql(sql).Find(&List)
 	return List
 }
 
-func (s *shelfsetService) GetLastShelfNum(acccode string) (a string) {
+func (s *ShelfsetService) GetLastShelfNum(acccode string) (a string) {
 	var no int
 	mpd := new(lastordernum.LastOrderNum)
 	s.DBE.Cols("LastNum", "Name", "LastDate").Where(" AccCode = '" + acccode + "' and Name='Shelf' ").Get(mpd)
@@ -51,7 +51,7 @@ func (s *shelfsetService) GetLastShelfNum(acccode string) (a string) {
 	return lastdata
 }
 
-func (s *shelfsetService) GetLastBoxNum(acccode string) (a string) {
+func (s *ShelfsetService) GetLastBoxNum(acccode string) (a string) {
 	var no int
 	mpd := new(lastordernum.LastOrderNum)
 	s.DBE.Cols("LastNum", "Name", "LastDate").Where(" AccCode = '" + acccode + "' and Name='Box' ").Get(mpd)
@@ -67,36 +67,36 @@ func (s *shelfsetService) GetLastBoxNum(acccode string) (a string) {
 
 	return lastdata
 }
-func (s *shelfsetService) UpdateShelfNum(entity interface{}, acccode string) (affected int64, err error) {
+func (s *ShelfsetService) UpdateShelfNum(entity interface{}, acccode string) (affected int64, err error) {
 	affected, err = s.DBE.Where("AccCode='" + acccode + "' and Name='Shelf'").Update(entity)
 	LogError(err)
 	return
 }
-func (s *shelfsetService) UpdateBoxNum(entity interface{}, acccode string) (affected int64, err error) {
+func (s *ShelfsetService) UpdateBoxNum(entity interface{}, acccode string) (affected int64, err error) {
 	affected, err = s.DBE.Where("AccCode='" + acccode + "' and Name='Box'").Update(entity)
 	LogError(err)
 	return
 }
-func (s *shelfsetService) GetEntityByEquipmentId(equipmentid string, x string, y string, entityPtr interface{}) (has bool) {
+func (s *ShelfsetService) GetEntityByEquipmentId(equipmentid string, x string, y string, entityPtr interface{}) (has bool) {
 	where := " EquipmentId=" + equipmentid + " and XStation=" + x + " and YStation=" + y
 	has, err := s.DBE.Where(where).Get(entityPtr)
 	LogError(err)
 	return
 }
-func (s *shelfsetService) GetEntityByShelfIdXY(shelfid string, x string, y string, entityPtr interface{}) (has bool) {
+func (s *ShelfsetService) GetEntityByShelfIdXY(shelfid string, x string, y string, entityPtr interface{}) (has bool) {
 	where := " ShelfId=" + shelfid + " and XStation=" + x + " and YStation=" + y
 	has, err := s.DBE.Where(where).Get(entityPtr)
 	LogError(err)
 	return
 }
-func (s *shelfsetService) UpdateShelf(equipmentid string, x string, y string, entity interface{}) (affected int64, err error) {
+func (s *ShelfsetService) UpdateShelf(equipmentid string, x string, y string, entity interface{}) (affected int64, err error) {
 	where := " EquipmentId=" + equipmentid + " and XStation=" + x + " and YStation=" + y
 	affected, err = s.DBE.Where(where).Update(entity)
 
 	LogError(err)
 	return
 }
-func (s *shelfsetService) UpdateBox(shelfid string, x string, y string, entity interface{}) (affected int64, err error) {
+func (s *ShelfsetService) UpdateBox(shelfid string, x string, y string, entity interface{}) (affected int64, err error) {
 	where := " ShelfId=" + shelfid + " and XStation=" + x + " and YStation=" + y
 	affected, err = s.DBE.Where(where).Update(entity)
 
@@ -105,7 +105,7 @@ func (s *shelfsetService) UpdateBox(shelfid string, x string, y string, entity i
 }
 
 //验证冻存架是否重复
-func (s *shelfsetService) GetboolByXY(equipmentid string, x string, y string, entityPtr interface{}) (has bool) {
+func (s *ShelfsetService) GetboolByXY(equipmentid string, x string, y string, entityPtr interface{}) (has bool) {
 	where := " EquipmentId=" + equipmentid + " and XStation=" + x + " and YStation=" + y
 	has, err := s.DBE.Where(where).Get(entityPtr)
 	LogError(err)
@@ -113,7 +113,7 @@ func (s *shelfsetService) GetboolByXY(equipmentid string, x string, y string, en
 }
 
 //验证冻存架中是否有冻存盒
-func (s *shelfsetService) GetBoxByShelfId(shelfid string, entityPtr interface{}) (has bool) {
+func (s *ShelfsetService) GetBoxByShelfId(shelfid string, entityPtr interface{}) (has bool) {
 	//var shelf Shelf
 	where := " ShelfId=" + shelfid
 	has, err := s.DBE.Where(where).Get(entityPtr)
@@ -122,20 +122,20 @@ func (s *shelfsetService) GetBoxByShelfId(shelfid string, entityPtr interface{})
 }
 
 //验证冻存盒是否重复
-func (s *shelfsetService) GetBoxBoolByXY(shelfid string, x_box string, y_box string, entityPtr interface{}) (has bool) {
+func (s *ShelfsetService) GetBoxBoolByXY(shelfid string, x_box string, y_box string, entityPtr interface{}) (has bool) {
 	where := " ShelfId=" + shelfid + " and XStation=" + x_box + " and YStation=" + y_box
 	has, err := s.DBE.Where(where).Get(entityPtr)
 	LogError(err)
 	return
 }
 
-func (s *shelfsetService) Delete(condiBean interface{}, equipmentid string, x string, y string) (err error) {
+func (s *ShelfsetService) Delete(condiBean interface{}, equipmentid string, x string, y string) (err error) {
 	where := " EquipmentId=" + equipmentid + " and XStation=" + x + " and YStation=" + y
 	_, err = s.DBE.Where(where).Delete(condiBean) //执行删除
 	LogError(err)
 	return
 }
-func (s *shelfsetService) DeleteBox(condiBean interface{}, shelfid string, x_box string, y_box string) (err error) {
+func (s *ShelfsetService) DeleteBox(condiBean interface{}, shelfid string, x_box string, y_box string) (err error) {
 	where := " ShelfId=" + shelfid + " and XStation=" + x_box + " and YStation=" + y_box
 	_, err = s.DBE.Where(where).Delete(condiBean) //执行删除
 	LogError(err)
@@ -143,7 +143,7 @@ func (s *shelfsetService) DeleteBox(condiBean interface{}, shelfid string, x_box
 }
 
 //验证设备中是否有冻存架
-func (s *shelfsetService) GetShelfByEquipment(equipmentid string, entityPtr interface{}) (has bool) {
+func (s *ShelfsetService) GetShelfByEquipment(equipmentid string, entityPtr interface{}) (has bool) {
 	where := " EquipmentId=" + equipmentid + ""
 	has, err := s.DBE.Where(where).Get(entityPtr)
 	LogError(err)
@@ -151,7 +151,7 @@ func (s *shelfsetService) GetShelfByEquipment(equipmentid string, entityPtr inte
 }
 
 //判断条形码是否存在
-func (s *shelfsetService) ValidExistShelfBarCode(acccode, value, id string) bool {
+func (s *ShelfsetService) ValidExistShelfBarCode(acccode, value, id string) bool {
 
 	var shelf Shelf
 	where := " AccCode = '" + acccode + "' and Id <> " + id
@@ -166,7 +166,7 @@ func (s *shelfsetService) ValidExistShelfBarCode(acccode, value, id string) bool
 }
 
 //判断冻存盒条形码是否存在
-func (s *shelfsetService) ValidExistBoxBarCode(acccode, value, id string) bool {
+func (s *ShelfsetService) ValidExistBoxBarCode(acccode, value, id string) bool {
 
 	var box Box
 	where := " AccCode = '" + acccode + "' and Id <> " + id
@@ -181,26 +181,26 @@ func (s *shelfsetService) ValidExistBoxBarCode(acccode, value, id string) bool {
 }
 
 //查询冻存架列表
-func (s *shelfsetService) ShelfListByid(where string) []Shelf {
+func (s *ShelfsetService) ShelfListByid(where string) []Shelf {
 	List := make([]Shelf, 0)
 	s.DBE.Where(where).Find(&List)
 	return List
 }
 
 //查询冻存盒列表
-func (s *shelfsetService) BoxListByid(where string) []Box {
+func (s *ShelfsetService) BoxListByid(where string) []Box {
 	List := make([]Box, 0)
 	s.DBE.Where(where).Find(&List)
 	return List
 }
 
-func (s *shelfsetService) GetStationByShelfId(shelfid string) (s_x int, s_y int) {
+func (s *ShelfsetService) GetStationByShelfId(shelfid string) (s_x int, s_y int) {
 	var shelf Shelf
 	where := " Id= " + shelfid
 	s.DBE.Cols("XStation", "YStation").Where(where).Get(&shelf)
 	return shelf.XStation, shelf.YStation
 }
-func (s *shelfsetService) GetStationByBoxId(boxid string) (s_x int, s_y int) {
+func (s *ShelfsetService) GetStationByBoxId(boxid string) (s_x int, s_y int) {
 	var box Box
 	where := " Id= " + boxid
 	s.DBE.Cols("XStation", "YStation").Where(where).Get(&box)
@@ -208,33 +208,33 @@ func (s *shelfsetService) GetStationByBoxId(boxid string) (s_x int, s_y int) {
 }
 
 //根据列名取列表
-func (s *shelfsetService) GetDatasByCols(entity interface{}, where, order string, cols []string) (err error) {
+func (s *ShelfsetService) GetDatasByCols(entity interface{}, where, order string, cols []string) (err error) {
 	err = s.DBE.Cols(cols...).Where(where).OrderBy(order).Find(entity)
 	return
 }
 
 //根据列where条件更新
-func (s *shelfsetService) UpdateEntityColsByWhere(entity interface{}, where string, cols []string) (affected int64, err error) {
+func (s *ShelfsetService) UpdateEntityColsByWhere(entity interface{}, where string, cols []string) (affected int64, err error) {
 	affected, err = s.DBE.Cols(cols...).Where(where).Update(entity)
 	LogError(err)
 	return
 }
 
 //获取冻存架数量
-func (s *shelfsetService) GetShelfCount(searchstring string) int64 {
+func (s *ShelfsetService) GetShelfCount(searchstring string) int64 {
 	shelf := new(Shelf)
 	total, _ := s.DBE.Where(searchstring).Count(shelf)
 	return total
 }
 
 //获取冻存盒数量
-func (s *shelfsetService) GetBoxCount(searchstring string) int64 {
+func (s *ShelfsetService) GetBoxCount(searchstring string) int64 {
 	box := new(Box)
 	total, _ := s.DBE.Where(searchstring).Count(box)
 	return total
 }
 
 //sql方法
-func (s *shelfsetService) SqlMethod(sql string) {
+func (s *ShelfsetService) SqlMethod(sql string) {
 	s.DBE.Exec(sql)
 }

+ 236 - 551
src/dashoo.cn/backend/api/controllers/equipment/equipment.go

@@ -483,6 +483,7 @@ func (this *EquipmentController) AddEquipment() {
 	equip.Item = 1 // 立式 取消了这项选择
 	equip.RowNum = model.RowNum
 	equip.ColumnNum = model.ColumnNum
+	equip.DItem = model.DItem
 	equip.Width, _ = utils.StrTo(model.Width).Float32()
 	equip.Height, _ = utils.StrTo(model.Height).Float32()
 	equip.Depth, _ = utils.StrTo(model.Depth).Float32()
@@ -530,74 +531,84 @@ func (this *EquipmentController) AddEquipment() {
 					box_x_int = 10
 					box_y_int = 10
 				}
-				var shelfempty shelfset.Shelf
-				shelfempty.AccCode = this.User.AccCode
-				shelfempty.EquipmentId = equip.Id
-				shelfempty.Code = "F" + utils.ToStr(num_lastdata)
-				shelfempty.BarCode = "F" + utils.ToStr(num_lastdata)
-				shelfempty.RowNum = shelf_x_int
-				shelfempty.ColumnNum = shelf_y_int
-				shelfempty.XStation = j
-				shelfempty.YStation = i
-				shelfempty.SampleType = equip.SampleType
-				shelfempty.CreateBy = this.User.Realname
-				shelfempty.CreateUserId, _ = utils.StrTo(this.User.Id).Int()
-				num_lastdata = num_lastdata + 1
-				_, err = svcshelf.InsertEntity(&shelfempty)
-				sqlfield := " AccCode,EquipmentId,ShelfId,XStation,YStation,RowNum,ColumnNum,"
-				sqlvalue := "'" + this.User.AccCode + "'," + utils.ToStr(equip.Id) + "," + utils.ToStr(shelfempty.Id) + "," + utils.ToStr(j) + "," + utils.ToStr(i) + "," + utils.ToStr(shelf_x_int) + "," + utils.ToStr(shelf_y_int) + ","
-				ii, jj := shelf_x_int, shelf_y_int
-				//添加冻存盒
-				if box_x_int > 0 && box_y_int > 0 {
-					for e := 0; e < ii; e++ {
-						charname := Boxlinename(e + 1)
-						for f := 0; f < jj; f++ {
-							fieldname := fmt.Sprintf("%v%v", charname, f+1)
-							if f == jj-1 && e == ii-1 {
-								sqlfield += fieldname
-								sqlvalue += "-1"
-							} else {
-								sqlfield += fieldname + ","
-								sqlvalue += "-1,"
-							}
-						}
-					}
-					for a := 1; a <= shelf_x_int; a++ {
-						for b := 1; b <= shelf_y_int; b++ {
-							var boxempty shelfset.Box
-							boxempty.AccCode = this.User.AccCode
-							boxempty.EquipmentId = equip.Id
-							boxempty.ShelfId = shelfempty.Id
-							boxempty.Code = "B" + utils.ToStr(num_lastdata_box)
-							boxempty.BarCode = "B" + utils.ToStr(num_lastdata_box)
-							boxempty.YStation = a
-							boxempty.XStation = b
-							boxempty.RowNum = box_x_int
-							boxempty.ColumnNum = box_y_int
-							boxempty.SampleType = equip.SampleType
-							boxempty.CreateBy = this.User.Realname
-							boxempty.CreateBy = this.User.Realname
-							num_lastdata_box = num_lastdata_box + 1
-							_, err = svc.InsertEntity(&boxempty)
-						}
-					}
-				} else {
-					for e := 0; e < ii; e++ {
-						charname := Boxlinename(e + 1)
-						for f := 0; f < jj; f++ {
-							fieldname := fmt.Sprintf("%v%v", charname, f+1)
-							if f == jj-1 && e == ii-1 {
-								sqlfield += fieldname
-								sqlvalue += "-2"
-							} else {
-								sqlfield += fieldname + ","
-								sqlvalue += "-2,"
-							}
-						}
-					}
+				err = addShelfAndBox(this.User.AccCode, this.User.Realname, this.User.Id, num_lastdata, num_lastdata_box,
+					shelf_x_int, shelf_y_int, box_x_int, box_y_int, i, j, equip,
+					svcshelf, svc)
+				if err != nil {
+					errinfo.Message = "冻存盒架子添加!" + err.Error()
+					errinfo.Code = -2
+					this.Data["json"] = &errinfo
+					this.ServeJSON()
+					return
 				}
-				svc1 := currboxcapacity.GetCurrboxcapacityService(utils.DBE)
-				svc1.Add(sqlfield, sqlvalue)
+				//var shelfempty shelfset.Shelf
+				//shelfempty.AccCode = this.User.AccCode
+				//shelfempty.EquipmentId = equip.Id
+				//shelfempty.Code = "F" + utils.ToStr(num_lastdata)
+				//shelfempty.BarCode = "F" + utils.ToStr(num_lastdata)
+				//shelfempty.RowNum = shelf_x_int
+				//shelfempty.ColumnNum = shelf_y_int
+				//shelfempty.XStation = j
+				//shelfempty.YStation = i
+				//shelfempty.SampleType = equip.SampleType
+				//shelfempty.CreateBy = this.User.Realname
+				//shelfempty.CreateUserId, _ = utils.StrTo(this.User.Id).Int()
+				//num_lastdata = num_lastdata + 1
+				//_, err = svcshelf.InsertEntity(&shelfempty)
+				//sqlfield := " AccCode,EquipmentId,ShelfId,XStation,YStation,RowNum,ColumnNum,"
+				//sqlvalue := "'" + this.User.AccCode + "'," + utils.ToStr(equip.Id) + "," + utils.ToStr(shelfempty.Id) + "," + utils.ToStr(j) + "," + utils.ToStr(i) + "," + utils.ToStr(shelf_x_int) + "," + utils.ToStr(shelf_y_int) + ","
+				//ii, jj := shelf_x_int, shelf_y_int
+				////添加冻存盒
+				//if box_x_int > 0 && box_y_int > 0 {
+				//	for e := 0; e < ii; e++ {
+				//		charname := Boxlinename(e + 1)
+				//		for f := 0; f < jj; f++ {
+				//			fieldname := fmt.Sprintf("%v%v", charname, f+1)
+				//			if f == jj-1 && e == ii-1 {
+				//				sqlfield += fieldname
+				//				sqlvalue += "-1"
+				//			} else {
+				//				sqlfield += fieldname + ","
+				//				sqlvalue += "-1,"
+				//			}
+				//		}
+				//	}
+				//	for a := 1; a <= shelf_x_int; a++ {
+				//		for b := 1; b <= shelf_y_int; b++ {
+				//			var boxempty shelfset.Box
+				//			boxempty.AccCode = this.User.AccCode
+				//			boxempty.EquipmentId = equip.Id
+				//			boxempty.ShelfId = shelfempty.Id
+				//			boxempty.Code = "B" + utils.ToStr(num_lastdata_box)
+				//			boxempty.BarCode = "B" + utils.ToStr(num_lastdata_box)
+				//			boxempty.YStation = a
+				//			boxempty.XStation = b
+				//			boxempty.RowNum = box_x_int
+				//			boxempty.ColumnNum = box_y_int
+				//			boxempty.SampleType = equip.SampleType
+				//			boxempty.CreateBy = this.User.Realname
+				//			boxempty.CreateBy = this.User.Realname
+				//			num_lastdata_box = num_lastdata_box + 1
+				//			_, err = svc.InsertEntity(&boxempty)
+				//		}
+				//	}
+				//} else {
+				//	for e := 0; e < ii; e++ {
+				//		charname := Boxlinename(e + 1)
+				//		for f := 0; f < jj; f++ {
+				//			fieldname := fmt.Sprintf("%v%v", charname, f+1)
+				//			if f == jj-1 && e == ii-1 {
+				//				sqlfield += fieldname
+				//				sqlvalue += "-2"
+				//			} else {
+				//				sqlfield += fieldname + ","
+				//				sqlvalue += "-2,"
+				//			}
+				//		}
+				//	}
+				//}
+				//svc1 := currboxcapacity.GetCurrboxcapacityService(utils.DBE)
+				//svc1.Add(sqlfield, sqlvalue)
 			}
 		}
 		num_lastdata_box = num_lastdata_box - 1
@@ -621,74 +632,16 @@ func (this *EquipmentController) AddEquipment() {
 		num_lastdata_box, _ := utils.StrTo(lastdata_box[1:]).Int64()
 		for i := 1; i <= equip.RowNum; i++ {
 			for j := 1; j <= equip.ColumnNum; j++ {
-				var shelfempty shelfset.Shelf
-				shelfempty.AccCode = this.User.AccCode
-				shelfempty.EquipmentId = equip.Id
-				shelfempty.Code = "F" + utils.ToStr(num_lastdata)
-				shelfempty.BarCode = "F" + utils.ToStr(num_lastdata)
-				shelfempty.RowNum = shelf_x_int
-				shelfempty.ColumnNum = shelf_y_int
-				shelfempty.XStation = j
-				shelfempty.YStation = i
-				shelfempty.SampleType = equip.SampleType
-				shelfempty.CreateBy = this.User.Realname
-				shelfempty.CreateUserId, _ = utils.StrTo(this.User.Id).Int()
-				num_lastdata = num_lastdata + 1
-				_, err = svcshelf.InsertEntity(&shelfempty)
-				sqlfield := " AccCode,EquipmentId,ShelfId,XStation,YStation,RowNum,ColumnNum,"
-				sqlvalue := "'" + this.User.AccCode + "'," + utils.ToStr(equip.Id) + "," + utils.ToStr(shelfempty.Id) + "," + utils.ToStr(j) + "," + utils.ToStr(i) + "," + utils.ToStr(shelf_x_int) + "," + utils.ToStr(shelf_y_int) + ","
-				ii, jj := shelf_x_int, shelf_y_int
-				//添加冻存盒
-				if box_x_int > 0 && box_y_int > 0 {
-					for e := 0; e < ii; e++ {
-						charname := Boxlinename(e + 1)
-						for f := 0; f < jj; f++ {
-							fieldname := fmt.Sprintf("%v%v", charname, f+1)
-							if f == jj-1 && e == ii-1 {
-								sqlfield += fieldname
-								sqlvalue += "-1"
-							} else {
-								sqlfield += fieldname + ","
-								sqlvalue += "-1,"
-							}
-						}
-					}
-					for a := 1; a <= shelf_x_int; a++ {
-						for b := 1; b <= shelf_y_int; b++ {
-							var boxempty shelfset.Box
-							boxempty.AccCode = this.User.AccCode
-							boxempty.EquipmentId = equip.Id
-							boxempty.ShelfId = shelfempty.Id
-							boxempty.Code = "B" + utils.ToStr(num_lastdata_box)
-							boxempty.BarCode = "B" + utils.ToStr(num_lastdata_box)
-							boxempty.YStation = a
-							boxempty.XStation = b
-							boxempty.RowNum = box_x_int
-							boxempty.ColumnNum = box_y_int
-							boxempty.SampleType = equip.SampleType
-							boxempty.CreateBy = this.User.Realname
-							boxempty.CreateBy = this.User.Realname
-							num_lastdata_box = num_lastdata_box + 1
-							_, err = svc.InsertEntity(&boxempty)
-						}
-					}
-				} else {
-					for e := 0; e < ii; e++ {
-						charname := Boxlinename(e + 1)
-						for f := 0; f < jj; f++ {
-							fieldname := fmt.Sprintf("%v%v", charname, f+1)
-							if f == jj-1 && e == ii-1 {
-								sqlfield += fieldname
-								sqlvalue += "-2"
-							} else {
-								sqlfield += fieldname + ","
-								sqlvalue += "-2,"
-							}
-						}
-					}
+				err = addShelfAndBox(this.User.AccCode, this.User.Realname, this.User.Id, num_lastdata, num_lastdata_box,
+					shelf_x_int, shelf_y_int, box_x_int, box_y_int, i, j, equip,
+					svcshelf, svc)
+				if err != nil {
+					errinfo.Message = "冻存盒架子添加!" + err.Error()
+					errinfo.Code = -2
+					this.Data["json"] = &errinfo
+					this.ServeJSON()
+					return
 				}
-				svc1 := currboxcapacity.GetCurrboxcapacityService(utils.DBE)
-				svc1.Add(sqlfield, sqlvalue)
 			}
 		}
 		num_lastdata_box = num_lastdata_box - 1
@@ -724,74 +677,16 @@ func (this *EquipmentController) AddEquipment() {
 						box_y_int = 10
 					}
 				}
-				var shelfempty shelfset.Shelf
-				shelfempty.AccCode = this.User.AccCode
-				shelfempty.EquipmentId = equip.Id
-				shelfempty.Code = "F" + utils.ToStr(num_lastdata)
-				shelfempty.BarCode = "F" + utils.ToStr(num_lastdata)
-				shelfempty.RowNum = shelf_x_int
-				shelfempty.ColumnNum = shelf_y_int
-				shelfempty.XStation = j
-				shelfempty.YStation = i
-				shelfempty.SampleType = equip.SampleType
-				shelfempty.CreateBy = this.User.Realname
-				shelfempty.CreateUserId, _ = utils.StrTo(this.User.Id).Int()
-				num_lastdata = num_lastdata + 1
-				_, err = svcshelf.InsertEntity(&shelfempty)
-				sqlfield := " AccCode,EquipmentId,ShelfId,XStation,YStation,RowNum,ColumnNum,"
-				sqlvalue := "'" + this.User.AccCode + "'," + utils.ToStr(equip.Id) + "," + utils.ToStr(shelfempty.Id) + "," + utils.ToStr(j) + "," + utils.ToStr(i) + "," + utils.ToStr(shelf_x_int) + "," + utils.ToStr(shelf_y_int) + ","
-				ii, jj := shelf_x_int, shelf_y_int
-				//添加冻存盒
-				if box_x_int > 0 && box_y_int > 0 {
-					for e := 0; e < ii; e++ {
-						charname := Boxlinename(e + 1)
-						for f := 0; f < jj; f++ {
-							fieldname := fmt.Sprintf("%v%v", charname, f+1)
-							if f == jj-1 && e == ii-1 {
-								sqlfield += fieldname
-								sqlvalue += "-1"
-							} else {
-								sqlfield += fieldname + ","
-								sqlvalue += "-1,"
-							}
-						}
-					}
-					for a := 1; a <= shelf_x_int; a++ {
-						for b := 1; b <= shelf_y_int; b++ {
-							var boxempty shelfset.Box
-							boxempty.AccCode = this.User.AccCode
-							boxempty.EquipmentId = equip.Id
-							boxempty.ShelfId = shelfempty.Id
-							boxempty.Code = "B" + utils.ToStr(num_lastdata_box)
-							boxempty.BarCode = "B" + utils.ToStr(num_lastdata_box)
-							boxempty.YStation = a
-							boxempty.XStation = b
-							boxempty.RowNum = box_x_int
-							boxempty.ColumnNum = box_y_int
-							boxempty.SampleType = equip.SampleType
-							boxempty.CreateBy = this.User.Realname
-							boxempty.CreateBy = this.User.Realname
-							num_lastdata_box = num_lastdata_box + 1
-							_, err = svc.InsertEntity(&boxempty)
-						}
-					}
-				} else {
-					for e := 0; e < ii; e++ {
-						charname := Boxlinename(e + 1)
-						for f := 0; f < jj; f++ {
-							fieldname := fmt.Sprintf("%v%v", charname, f+1)
-							if f == jj-1 && e == ii-1 {
-								sqlfield += fieldname
-								sqlvalue += "-2"
-							} else {
-								sqlfield += fieldname + ","
-								sqlvalue += "-2,"
-							}
-						}
-					}
+				err = addShelfAndBox(this.User.AccCode, this.User.Realname, this.User.Id, num_lastdata, num_lastdata_box,
+					shelf_x_int, shelf_y_int, box_x_int, box_y_int, i, j, equip,
+					svcshelf, svc)
+				if err != nil {
+					errinfo.Message = "冻存盒架子添加!" + err.Error()
+					errinfo.Code = -2
+					this.Data["json"] = &errinfo
+					this.ServeJSON()
+					return
 				}
-				svc1 := currboxcapacity.GetCurrboxcapacityService(utils.DBE)
-				svc1.Add(sqlfield, sqlvalue)
 			}
 		}
 		num_lastdata_box = num_lastdata_box - 1
@@ -815,74 +710,16 @@ func (this *EquipmentController) AddEquipment() {
 		num_lastdata_box, _ := utils.StrTo(lastdata_box[1:]).Int64()
 		for i := 1; i <= equip.RowNum; i++ {
 			for j := 1; j <= equip.ColumnNum; j++ {
-				var shelfempty shelfset.Shelf
-				shelfempty.AccCode = this.User.AccCode
-				shelfempty.EquipmentId = equip.Id
-				shelfempty.Code = "F" + utils.ToStr(num_lastdata)
-				shelfempty.BarCode = "F" + utils.ToStr(num_lastdata)
-				shelfempty.RowNum = shelf_x_int
-				shelfempty.ColumnNum = shelf_y_int
-				shelfempty.XStation = j
-				shelfempty.YStation = i
-				shelfempty.SampleType = equip.SampleType
-				shelfempty.CreateBy = this.User.Realname
-				shelfempty.CreateUserId, _ = utils.StrTo(this.User.Id).Int()
-				num_lastdata = num_lastdata + 1
-				_, err = svcshelf.InsertEntity(&shelfempty)
-				sqlfield := " AccCode,EquipmentId,ShelfId,XStation,YStation,RowNum,ColumnNum,"
-				sqlvalue := "'" + this.User.AccCode + "'," + utils.ToStr(equip.Id) + "," + utils.ToStr(shelfempty.Id) + "," + utils.ToStr(j) + "," + utils.ToStr(i) + "," + utils.ToStr(shelf_x_int) + "," + utils.ToStr(shelf_y_int) + ","
-				ii, jj := shelf_x_int, shelf_y_int
-				//添加冻存盒
-				if box_x_int > 0 && box_y_int > 0 {
-					for e := 0; e < ii; e++ {
-						charname := Boxlinename(e + 1)
-						for f := 0; f < jj; f++ {
-							fieldname := fmt.Sprintf("%v%v", charname, f+1)
-							if f == jj-1 && e == ii-1 {
-								sqlfield += fieldname
-								sqlvalue += "-1"
-							} else {
-								sqlfield += fieldname + ","
-								sqlvalue += "-1,"
-							}
-						}
-					}
-					for a := 1; a <= shelf_x_int; a++ {
-						for b := 1; b <= shelf_y_int; b++ {
-							var boxempty shelfset.Box
-							boxempty.AccCode = this.User.AccCode
-							boxempty.EquipmentId = equip.Id
-							boxempty.ShelfId = shelfempty.Id
-							boxempty.Code = "B" + utils.ToStr(num_lastdata_box)
-							boxempty.BarCode = "B" + utils.ToStr(num_lastdata_box)
-							boxempty.YStation = a
-							boxempty.XStation = b
-							boxempty.RowNum = box_x_int
-							boxempty.ColumnNum = box_y_int
-							boxempty.SampleType = equip.SampleType
-							boxempty.CreateBy = this.User.Realname
-							boxempty.CreateBy = this.User.Realname
-							num_lastdata_box = num_lastdata_box + 1
-							_, err = svc.InsertEntity(&boxempty)
-						}
-					}
-				} else {
-					for e := 0; e < ii; e++ {
-						charname := Boxlinename(e + 1)
-						for f := 0; f < jj; f++ {
-							fieldname := fmt.Sprintf("%v%v", charname, f+1)
-							if f == jj-1 && e == ii-1 {
-								sqlfield += fieldname
-								sqlvalue += "-2"
-							} else {
-								sqlfield += fieldname + ","
-								sqlvalue += "-2,"
-							}
-						}
-					}
+				err = addShelfAndBox(this.User.AccCode, this.User.Realname, this.User.Id, num_lastdata, num_lastdata_box,
+					shelf_x_int, shelf_y_int, box_x_int, box_y_int, i, j, equip,
+					svcshelf, svc)
+				if err != nil {
+					errinfo.Message = "冻存盒架子添加!" + err.Error()
+					errinfo.Code = -2
+					this.Data["json"] = &errinfo
+					this.ServeJSON()
+					return
 				}
-				svc1 := currboxcapacity.GetCurrboxcapacityService(utils.DBE)
-				svc1.Add(sqlfield, sqlvalue)
 			}
 		}
 		num_lastdata_box = num_lastdata_box - 1
@@ -905,74 +742,16 @@ func (this *EquipmentController) AddEquipment() {
 		num_lastdata_box, _ := utils.StrTo(lastdata_box[1:]).Int64()
 		for i := 1; i <= equip.RowNum; i++ {
 			for j := 1; j <= equip.ColumnNum; j++ {
-				var shelfempty shelfset.Shelf
-				shelfempty.AccCode = this.User.AccCode
-				shelfempty.EquipmentId = equip.Id
-				shelfempty.Code = "F" + utils.ToStr(num_lastdata)
-				shelfempty.BarCode = "F" + utils.ToStr(num_lastdata)
-				shelfempty.RowNum = shelf_x_int
-				shelfempty.ColumnNum = shelf_y_int
-				shelfempty.XStation = j
-				shelfempty.YStation = i
-				shelfempty.SampleType = equip.SampleType
-				shelfempty.CreateBy = this.User.Realname
-				shelfempty.CreateUserId, _ = utils.StrTo(this.User.Id).Int()
-				num_lastdata = num_lastdata + 1
-				_, err = svcshelf.InsertEntity(&shelfempty)
-				sqlfield := " AccCode,EquipmentId,ShelfId,XStation,YStation,RowNum,ColumnNum,"
-				sqlvalue := "'" + this.User.AccCode + "'," + utils.ToStr(equip.Id) + "," + utils.ToStr(shelfempty.Id) + "," + utils.ToStr(j) + "," + utils.ToStr(i) + "," + utils.ToStr(shelf_x_int) + "," + utils.ToStr(shelf_y_int) + ","
-				ii, jj := shelf_x_int, shelf_y_int
-				//添加冻存盒
-				if box_x_int > 0 && box_y_int > 0 {
-					for e := 0; e < ii; e++ {
-						charname := Boxlinename(e + 1)
-						for f := 0; f < jj; f++ {
-							fieldname := fmt.Sprintf("%v%v", charname, f+1)
-							if f == jj-1 && e == ii-1 {
-								sqlfield += fieldname
-								sqlvalue += "-1"
-							} else {
-								sqlfield += fieldname + ","
-								sqlvalue += "-1,"
-							}
-						}
-					}
-					for a := 1; a <= shelf_x_int; a++ {
-						for b := 1; b <= shelf_y_int; b++ {
-							var boxempty shelfset.Box
-							boxempty.AccCode = this.User.AccCode
-							boxempty.EquipmentId = equip.Id
-							boxempty.ShelfId = shelfempty.Id
-							boxempty.Code = "B" + utils.ToStr(num_lastdata_box)
-							boxempty.BarCode = "B" + utils.ToStr(num_lastdata_box)
-							boxempty.YStation = a
-							boxempty.XStation = b
-							boxempty.RowNum = box_x_int
-							boxempty.ColumnNum = box_y_int
-							boxempty.SampleType = equip.SampleType
-							boxempty.CreateBy = this.User.Realname
-							boxempty.CreateBy = this.User.Realname
-							num_lastdata_box = num_lastdata_box + 1
-							_, err = svc.InsertEntity(&boxempty)
-						}
-					}
-				} else {
-					for e := 0; e < ii; e++ {
-						charname := Boxlinename(e + 1)
-						for f := 0; f < jj; f++ {
-							fieldname := fmt.Sprintf("%v%v", charname, f+1)
-							if f == jj-1 && e == ii-1 {
-								sqlfield += fieldname
-								sqlvalue += "-2"
-							} else {
-								sqlfield += fieldname + ","
-								sqlvalue += "-2,"
-							}
-						}
-					}
+				err = addShelfAndBox(this.User.AccCode, this.User.Realname, this.User.Id, num_lastdata, num_lastdata_box,
+					shelf_x_int, shelf_y_int, box_x_int, box_y_int, i, j, equip,
+					svcshelf, svc)
+				if err != nil {
+					errinfo.Message = "冻存盒架子添加!" + err.Error()
+					errinfo.Code = -2
+					this.Data["json"] = &errinfo
+					this.ServeJSON()
+					return
 				}
-				svc1 := currboxcapacity.GetCurrboxcapacityService(utils.DBE)
-				svc1.Add(sqlfield, sqlvalue)
 			}
 		}
 		num_lastdata_box = num_lastdata_box - 1
@@ -1025,74 +804,16 @@ func (this *EquipmentController) AddEquipment() {
 						continue
 					}
 				}
-				var shelfempty shelfset.Shelf
-				shelfempty.AccCode = this.User.AccCode
-				shelfempty.EquipmentId = equip.Id
-				shelfempty.Code = "F" + utils.ToStr(num_lastdata)
-				shelfempty.BarCode = "F" + utils.ToStr(num_lastdata)
-				shelfempty.RowNum = shelf_x_int
-				shelfempty.ColumnNum = shelf_y_int
-				shelfempty.XStation = j
-				shelfempty.YStation = i
-				shelfempty.SampleType = equip.SampleType
-				shelfempty.CreateBy = this.User.Realname
-				shelfempty.CreateUserId, _ = utils.StrTo(this.User.Id).Int()
-				num_lastdata = num_lastdata + 1
-				_, err = svcshelf.InsertEntity(&shelfempty)
-				sqlfield := " AccCode,EquipmentId,ShelfId,XStation,YStation,RowNum,ColumnNum,"
-				sqlvalue := "'" + this.User.AccCode + "'," + utils.ToStr(equip.Id) + "," + utils.ToStr(shelfempty.Id) + "," + utils.ToStr(j) + "," + utils.ToStr(i) + "," + utils.ToStr(shelf_x_int) + "," + utils.ToStr(shelf_y_int) + ","
-				ii, jj := shelf_x_int, shelf_y_int
-				//添加冻存盒
-				if box_x_int > 0 && box_y_int > 0 {
-					for e := 0; e < ii; e++ {
-						charname := Boxlinename(e + 1)
-						for f := 0; f < jj; f++ {
-							fieldname := fmt.Sprintf("%v%v", charname, f+1)
-							if f == jj-1 && e == ii-1 {
-								sqlfield += fieldname
-								sqlvalue += "-1"
-							} else {
-								sqlfield += fieldname + ","
-								sqlvalue += "-1,"
-							}
-						}
-					}
-					for a := 1; a <= shelf_x_int; a++ {
-						for b := 1; b <= shelf_y_int; b++ {
-							var boxempty shelfset.Box
-							boxempty.AccCode = this.User.AccCode
-							boxempty.EquipmentId = equip.Id
-							boxempty.ShelfId = shelfempty.Id
-							boxempty.Code = "B" + utils.ToStr(num_lastdata_box)
-							boxempty.BarCode = "B" + utils.ToStr(num_lastdata_box)
-							boxempty.YStation = a
-							boxempty.XStation = b
-							boxempty.RowNum = box_x_int
-							boxempty.ColumnNum = box_y_int
-							boxempty.SampleType = equip.SampleType
-							boxempty.CreateBy = this.User.Realname
-							boxempty.CreateBy = this.User.Realname
-							num_lastdata_box = num_lastdata_box + 1
-							_, err = svc.InsertEntity(&boxempty)
-						}
-					}
-				} else {
-					for e := 0; e < ii; e++ {
-						charname := Boxlinename(e + 1)
-						for f := 0; f < jj; f++ {
-							fieldname := fmt.Sprintf("%v%v", charname, f+1)
-							if f == jj-1 && e == ii-1 {
-								sqlfield += fieldname
-								sqlvalue += "-2"
-							} else {
-								sqlfield += fieldname + ","
-								sqlvalue += "-2,"
-							}
-						}
-					}
+				err = addShelfAndBox(this.User.AccCode, this.User.Realname, this.User.Id, num_lastdata, num_lastdata_box,
+					shelf_x_int, shelf_y_int, box_x_int, box_y_int, i, j, equip,
+					svcshelf, svc)
+				if err != nil {
+					errinfo.Message = "冻存盒架子添加!" + err.Error()
+					errinfo.Code = -2
+					this.Data["json"] = &errinfo
+					this.ServeJSON()
+					return
 				}
-				svc1 := currboxcapacity.GetCurrboxcapacityService(utils.DBE)
-				svc1.Add(sqlfield, sqlvalue)
 			}
 		}
 		num_lastdata_box = num_lastdata_box - 1
@@ -1104,7 +825,7 @@ func (this *EquipmentController) AddEquipment() {
 		lastnum_shelf.LastNum = "F" + utils.ToStr(num_lastdata)
 		svcshelf.UpdateShelfNum(lastnum_shelf, this.User.AccCode)
 
-	}else if model.DItem == 25 { // Thermo Fisher  CE8120
+	} else if model.DItem == 25 {
 		shelf_x_int := 1
 		shelf_y_int := 1
 		box_x_int := 1
@@ -1114,97 +835,42 @@ func (this *EquipmentController) AddEquipment() {
 		num_lastdata, _ := utils.StrTo(lastdata[1:]).Int64()
 		lastdata_box := svcshelf.GetLastBoxNum(this.User.AccCode)
 		num_lastdata_box, _ := utils.StrTo(lastdata_box[1:]).Int64()
-		for i := 1; i <= equip.RowNum; i++ {
+		for i := 1; i <= equip.RowNum; i++ { //40
 			for j := 1; j <= equip.ColumnNum; j++ {
-				if j == 4 { //第4个为小型格4行5x5冻存盒
+				if j >= 1 && i <= 4 {
 					shelf_x_int = 1
-					shelf_y_int = 14
-					box_x_int = 5
-					box_y_int = 5
-				} else { //其他为大型格14行9*9冻存盒
+					shelf_y_int = 4
+					box_x_int = 9
+					box_y_int = 9
+				} else if i >= 5 && i <= 10 {
 					shelf_x_int = 1
-					shelf_y_int = 14
+					shelf_y_int = 6
 					box_x_int = 9
 					box_y_int = 9
-				}
-				var shelfempty shelfset.Shelf
-				shelfempty.AccCode = this.User.AccCode
-				shelfempty.EquipmentId = equip.Id
-				shelfempty.Code = "F" + utils.ToStr(num_lastdata)
-				shelfempty.BarCode = "F" + utils.ToStr(num_lastdata)
-				shelfempty.RowNum = shelf_x_int
-				shelfempty.ColumnNum = shelf_y_int
-				shelfempty.XStation = j
-				shelfempty.YStation = i
-				shelfempty.SampleType = equip.SampleType
-				shelfempty.CreateBy = this.User.Realname
-				shelfempty.CreateUserId, _ = utils.StrTo(this.User.Id).Int()
-				num_lastdata = num_lastdata + 1
-				_, err = svcshelf.InsertEntity(&shelfempty)
-				sqlfield := " AccCode,EquipmentId,ShelfId,XStation,YStation,RowNum,ColumnNum,"
-				sqlvalue := "'" + this.User.AccCode + "'," + utils.ToStr(equip.Id) + "," + utils.ToStr(shelfempty.Id) + "," + utils.ToStr(j) + "," + utils.ToStr(i) + "," + utils.ToStr(shelf_x_int) + "," + utils.ToStr(shelf_y_int) + ","
-				ii, jj := shelf_x_int, shelf_y_int
-				//添加冻存盒
-				if box_x_int > 0 && box_y_int > 0 {
-					for e := 0; e < ii; e++ {
-						charname := Boxlinename(e + 1)
-						for f := 0; f < jj; f++ {
-							fieldname := fmt.Sprintf("%v%v", charname, f+1)
-							if f == jj-1 && e == ii-1 {
-								sqlfield += fieldname
-								sqlvalue += "-1"
-							} else {
-								sqlfield += fieldname + ","
-								sqlvalue += "-1,"
-							}
-						}
-					}
-					for a := 1; a <= shelf_x_int; a++ {
-						for b := 1; b <= shelf_y_int; b++ {
-							var boxempty shelfset.Box
-							boxempty.AccCode = this.User.AccCode
-							boxempty.EquipmentId = equip.Id
-							boxempty.ShelfId = shelfempty.Id
-							boxempty.Code = "B" + utils.ToStr(num_lastdata_box)
-							boxempty.BarCode = "B" + utils.ToStr(num_lastdata_box)
-							boxempty.YStation = a
-							boxempty.XStation = b
-							boxempty.RowNum = box_x_int
-							boxempty.ColumnNum = box_y_int
-							boxempty.SampleType = equip.SampleType
-							boxempty.CreateBy = this.User.Realname
-							boxempty.CreateBy = this.User.Realname
-							num_lastdata_box = num_lastdata_box + 1
-							_, err = svc.InsertEntity(&boxempty)
-						}
+					if j > 6 {
+						continue
 					}
-				} else {
-					for e := 0; e < ii; e++ {
-						charname := Boxlinename(e + 1)
-						for f := 0; f < jj; f++ {
-							fieldname := fmt.Sprintf("%v%v", charname, f+1)
-							if f == jj-1 && e == ii-1 {
-								sqlfield += fieldname
-								sqlvalue += "-2"
-							} else {
-								sqlfield += fieldname + ","
-								sqlvalue += "-2,"
-							}
-						}
+				} else if i >= 11 && i <= 40 {
+					shelf_x_int = 1
+					shelf_y_int = 12
+					box_x_int = 10
+					box_y_int = 10
+					if j > 30 {
+						continue
 					}
 				}
-				svc1 := currboxcapacity.GetCurrboxcapacityService(utils.DBE)
-				svc1.Add(sqlfield, sqlvalue)
+				err = addShelfAndBox(this.User.AccCode, this.User.Realname, this.User.Id, num_lastdata, num_lastdata_box,
+					shelf_x_int, shelf_y_int, box_x_int, box_y_int, i, j, equip,
+					svcshelf, svc)
+				if err != nil {
+					errinfo.Message = "冻存盒架子添加!" + err.Error()
+					errinfo.Code = -2
+					this.Data["json"] = &errinfo
+					this.ServeJSON()
+					return
+				}
 			}
 		}
-		num_lastdata_box = num_lastdata_box - 1
-		var lastnum lastordernum.LastOrderNum
-		lastnum.LastNum = "B" + utils.ToStr(num_lastdata_box)
-		svcshelf.UpdateBoxNum(lastnum, this.User.AccCode)
-		num_lastdata = num_lastdata - 1
-		var lastnum_shelf lastordernum.LastOrderNum
-		lastnum_shelf.LastNum = "F" + utils.ToStr(num_lastdata)
-		svcshelf.UpdateShelfNum(lastnum_shelf, this.User.AccCode)
 	} else {
 
 		if model.Shelf_X > 0 && model.Shelf_y > 0 {
@@ -1219,74 +885,16 @@ func (this *EquipmentController) AddEquipment() {
 			num_lastdata_box, _ := utils.StrTo(lastdata_box[1:]).Int64()
 			for i := 1; i <= equip.RowNum; i++ {
 				for j := 1; j <= equip.ColumnNum; j++ {
-					var shelfempty shelfset.Shelf
-					shelfempty.AccCode = this.User.AccCode
-					shelfempty.EquipmentId = equip.Id
-					shelfempty.Code = "F" + utils.ToStr(num_lastdata)
-					shelfempty.BarCode = "F" + utils.ToStr(num_lastdata)
-					shelfempty.RowNum = shelf_x_int
-					shelfempty.ColumnNum = shelf_y_int
-					shelfempty.XStation = j
-					shelfempty.YStation = i
-					shelfempty.SampleType = equip.SampleType
-					shelfempty.CreateBy = this.User.Realname
-					shelfempty.CreateUserId, _ = utils.StrTo(this.User.Id).Int()
-					num_lastdata = num_lastdata + 1
-					_, err = svcshelf.InsertEntity(&shelfempty)
-					sqlfield := " AccCode,EquipmentId,ShelfId,XStation,YStation,RowNum,ColumnNum,"
-					sqlvalue := "'" + this.User.AccCode + "'," + utils.ToStr(equip.Id) + "," + utils.ToStr(shelfempty.Id) + "," + utils.ToStr(j) + "," + utils.ToStr(i) + "," + utils.ToStr(shelf_x_int) + "," + utils.ToStr(shelf_y_int) + ","
-					ii, jj := shelf_x_int, shelf_y_int
-					//添加冻存盒
-					if box_x_int > 0 && box_y_int > 0 {
-						for e := 0; e < ii; e++ {
-							charname := Boxlinename(e + 1)
-							for f := 0; f < jj; f++ {
-								fieldname := fmt.Sprintf("%v%v", charname, f+1)
-								if f == jj-1 && e == ii-1 {
-									sqlfield += fieldname
-									sqlvalue += "-1"
-								} else {
-									sqlfield += fieldname + ","
-									sqlvalue += "-1,"
-								}
-							}
-						}
-						for a := 1; a <= shelf_x_int; a++ {
-							for b := 1; b <= shelf_y_int; b++ {
-								var boxempty shelfset.Box
-								boxempty.AccCode = this.User.AccCode
-								boxempty.EquipmentId = equip.Id
-								boxempty.ShelfId = shelfempty.Id
-								boxempty.Code = "B" + utils.ToStr(num_lastdata_box)
-								boxempty.BarCode = "B" + utils.ToStr(num_lastdata_box)
-								boxempty.YStation = a
-								boxempty.XStation = b
-								boxempty.RowNum = box_x_int
-								boxempty.ColumnNum = box_y_int
-								boxempty.SampleType = equip.SampleType
-								boxempty.CreateBy = this.User.Realname
-								boxempty.CreateBy = this.User.Realname
-								num_lastdata_box = num_lastdata_box + 1
-								_, err = svc.InsertEntity(&boxempty)
-							}
-						}
-					} else {
-						for e := 0; e < ii; e++ {
-							charname := Boxlinename(e + 1)
-							for f := 0; f < jj; f++ {
-								fieldname := fmt.Sprintf("%v%v", charname, f+1)
-								if f == jj-1 && e == ii-1 {
-									sqlfield += fieldname
-									sqlvalue += "-2"
-								} else {
-									sqlfield += fieldname + ","
-									sqlvalue += "-2,"
-								}
-							}
-						}
+					err = addShelfAndBox(this.User.AccCode, this.User.Realname, this.User.Id, num_lastdata, num_lastdata_box,
+						shelf_x_int, shelf_y_int, box_x_int, box_y_int, i, j, equip,
+						svcshelf, svc)
+					if err != nil {
+						errinfo.Message = "冻存盒架子添加!" + err.Error()
+						errinfo.Code = -2
+						this.Data["json"] = &errinfo
+						this.ServeJSON()
+						return
 					}
-					svc1 := currboxcapacity.GetCurrboxcapacityService(utils.DBE)
-					svc1.Add(sqlfield, sqlvalue)
 				}
 			}
 			num_lastdata_box = num_lastdata_box - 1
@@ -1325,6 +933,83 @@ func (this *EquipmentController) AddEquipment() {
 	this.ServeJSON()
 }
 
+// 同步添加冻存架和冻存盒 姜立伟 2021-08-16
+func addShelfAndBox(accCode, realName, userId string, num_lastdata, num_lastdata_box int64, shelfX, shelfY, boxX, boxY,
+	i, j int, equipment equipment.Equipment, svcshelf *shelfset.ShelfsetService, svc *equipment.EquipmentService)  error{
+	var shelfempty shelfset.Shelf
+	shelfempty.AccCode = accCode
+	shelfempty.EquipmentId = equipment.Id
+	shelfempty.Code = "F" + utils.ToStr(num_lastdata)
+	shelfempty.BarCode = "F" + utils.ToStr(num_lastdata)
+	shelfempty.RowNum = shelfX
+	shelfempty.ColumnNum = shelfY
+	shelfempty.XStation = j
+	shelfempty.YStation = i
+	shelfempty.SampleType = equipment.SampleType
+	shelfempty.CreateBy = realName
+	shelfempty.CreateUserId, _ = utils.StrTo(userId).Int()
+	num_lastdata = num_lastdata + 1
+	_, err := svcshelf.InsertEntity(&shelfempty)
+	if err != nil {
+		return err
+	}
+	sqlfield := " AccCode,EquipmentId,ShelfId,XStation,YStation,RowNum,ColumnNum,"
+	sqlvalue := "'" + accCode + "'," + utils.ToStr(equipment.Id) + "," + utils.ToStr(shelfempty.Id) + "," + utils.ToStr(j) + "," + utils.ToStr(i) + "," + utils.ToStr(shelfX) + "," + utils.ToStr(shelfY) + ","
+	ii, jj := shelfX, shelfY
+	//添加冻存盒
+	if boxX > 0 && boxY > 0 {
+		for e := 0; e < ii; e++ {
+			charname := Boxlinename(e + 1)
+			for f := 0; f < jj; f++ {
+				fieldname := fmt.Sprintf("%v%v", charname, f+1)
+				if f == jj-1 && e == ii-1 {
+					sqlfield += fieldname
+					sqlvalue += "-1"
+				} else {
+					sqlfield += fieldname + ","
+					sqlvalue += "-1,"
+				}
+			}
+		}
+		for a := 1; a <= shelfX; a++ {
+			for b := 1; b <= shelfY; b++ {
+				var boxempty shelfset.Box
+				boxempty.AccCode = accCode
+				boxempty.EquipmentId = equipment.Id
+				boxempty.ShelfId = shelfempty.Id
+				boxempty.Code = "B" + utils.ToStr(num_lastdata_box)
+				boxempty.BarCode = "B" + utils.ToStr(num_lastdata_box)
+				boxempty.YStation = a
+				boxempty.XStation = b
+				boxempty.RowNum = boxX
+				boxempty.ColumnNum = boxY
+				boxempty.SampleType = equipment.SampleType
+				boxempty.CreateBy = realName
+				boxempty.CreateBy = realName
+				num_lastdata_box = num_lastdata_box + 1
+				_, err = svc.InsertEntity(&boxempty)
+			}
+		}
+	} else {
+		for e := 0; e < ii; e++ {
+			charname := Boxlinename(e + 1)
+			for f := 0; f < jj; f++ {
+				fieldname := fmt.Sprintf("%v%v", charname, f+1)
+				if f == jj-1 && e == ii-1 {
+					sqlfield += fieldname
+					sqlvalue += "-2"
+				} else {
+					sqlfield += fieldname + ","
+					sqlvalue += "-2,"
+				}
+			}
+		}
+	}
+	svc1 := currboxcapacity.GetCurrboxcapacityService(utils.DBE)
+	svc1.Add(sqlfield, sqlvalue)
+	return nil
+}
+
 // @Title 删除容器设备
 // @Description 删除容器设备
 // @Param	code		path 	string	true		"需要删除的传感器编号"

+ 9 - 1
src/dashoo.cn/backend/api/controllers/samplesinfo/samplesfiles.go

@@ -183,9 +183,17 @@ func (this *SamplesfilesController) AnimalList() {
 	if donorname != "" {
 		where = where + " and SourceName like '%" + donorname + "%'"
 	}
+	ditem := this.GetString("DItem")
+	if ditem != "" {
+		where = where + " and f.DItem = '" + ditem + "'"
+	}
+	equipmentIds :=this.GetString("EquipmentIds")
+	if equipmentIds != "" {
+		where += " and f.Name in("+ equipmentIds +")"
+	}
 	svc := samplesfileinfo.GetSamplesFileInfoService(utils.DBE)
 	var list []samplesfileinfo.AnimalSamplesFileInfoList
-	total, list := svc.GetPagingEntitiesWithTb(this.User.AccCode, page.CurrentPage, page.Size, this.User.AccCode+AnimaltbName, "Id desc", where)
+	total, list := svc.GetPagingEntitiesWithTb(this.User.AccCode, page.CurrentPage, page.Size, this.User.AccCode+AnimaltbName, "a.Id desc, SourceName, groupNo asc , sampletype", where)
 	var datainfo DataInfo
 	datainfo.Items = list
 	datainfo.CurrentItemCount = total

+ 12 - 3
src/dashoo.cn/backend/api/controllers/samplesinfo/samplesinput.go

@@ -295,9 +295,18 @@ func (this *SamplesinputController) AnimalList() {
 	if ditem != "" {
 		where = where + " and f.DItem = '" + ditem + "'"
 	}
-	equipmentIds :=this.GetString("EquipmentIds")
-	if equipmentIds != "" {
-		where += " and f.Name in("+ equipmentIds +")"
+	equipmentIds :=this.GetStrings("EquipmentIds")
+	if equipmentIds != nil {
+		equipmentIdsStr := "("
+		for k, v := range equipmentIds {
+			if k == len(equipmentIds) -1 {
+				equipmentIdsStr += v
+			} else {
+				equipmentIdsStr += v + ","
+			}
+		}
+		equipmentIdsStr += ")"
+		where += " and f.Name in " + equipmentIdsStr
 	}
 	var list []samplesinfo.SamplesInfoList
 	total, list := svc.GetPagingEntitiesWithTb(this.User.AccCode, page.CurrentPage, page.Size, this.User.AccCode+AnimaltbName, "a.Id desc, SourceName, groupNo asc , sampletype", where)