Jelajahi Sumber

兴瑞需求 后端

shihang 6 tahun lalu
induk
melakukan
5fb4159aca

+ 9 - 0
src/dashoo.cn/backend/api/controllers/biobank/samplesbook.go

@@ -71,6 +71,15 @@ func (this *SamplesBookController) GetBookList() {
 			where = where + " and CollectionDate>='" + minDate + "' and CollectionDate<='" + maxDate + "'"
 		}
 	}
+	CreateOn := this.GetString("CreateOn")
+	if CreateOn != "" {
+		dates := strings.Split(CreateOn, ",")
+		if len(dates) == 2 {
+			minDate := dates[0]
+			maxDate := dates[1]
+			where = where + " and CreateOn>='" + minDate + "' and CreateOn<='" + maxDate + "'"
+		}
+	}
 	total, list := svc.GetSampleCodeBooklist(page.CurrentPage, page.Size, orderby, this.User.AccCode+SamplesBookName, this.User.AccCode+SamplesBookDetailName, this.User.AccCode+DonorstbName, where)
 	var datainfo DataInfo
 	datainfo.Items = list

+ 9 - 0
src/dashoo.cn/backend/api/controllers/biobank/samplescustomor.go

@@ -58,6 +58,15 @@ func (this *SamplesCustomorController) SamplesCustomorList() {
 			where = where + " and ConsultDate>='" + minDate + "' and ConsultDate<='" + maxDate + "'"
 		}
 	}
+	CreateOn := this.GetString("CreateOn")
+	if CreateOn != "" {
+		dates := strings.Split(CreateOn, ",")
+		if len(dates) == 2 {
+			minDate := dates[0]
+			maxDate := dates[1]
+			where = where + " and CreateOn>='" + minDate + "' and CreateOn<='" + maxDate + "'"
+		}
+	}
 	ConUserBy := this.GetString("ConUserBy")
 	if ConUserBy != "" {
 		where = where + " and ConUserBy like '%" + ConUserBy + "%'"

+ 9 - 0
src/dashoo.cn/backend/api/controllers/biobank/samplesprotocol.go

@@ -79,6 +79,15 @@ func (this *SamplesProtocolController) SamplesCustomorList() {
 			where = where + " and ProtocolStart>='" + minDate + "' and ProtocolStart<='" + maxDate + "'"
 		}
 	}
+	CreateOn := this.GetString("CreateOn")
+	if CreateOn != "" {
+		dates := strings.Split(CreateOn, ",")
+		if len(dates) == 2 {
+			minDate := dates[0]
+			maxDate := dates[1]
+			where = where + " and CreateOn>='" + minDate + "' and CreateOn<='" + maxDate + "'"
+		}
+	}
 	ConUserBy := this.GetString("ConUserBy")
 	if ConUserBy != "" {
 		where = where + " and ConUserBy like '%" + ConUserBy + "%'"

+ 71 - 4
src/dashoo.cn/backend/api/controllers/biobank/samplessource.go

@@ -5,10 +5,13 @@ import (
 	"encoding/json"
 	//"fmt"
 
-	//"strings"
+	"strings"
 	"time"
 
 	"dashoo.cn/backend/api/business/donorsinfo"
+	"dashoo.cn/backend/api/business/equipment"
+	"dashoo.cn/backend/api/business/samplesfileinfo"
+	"dashoo.cn/backend/api/business/samplesinfo"
 	"dashoo.cn/backend/api/business/samplessource"
 	"dashoo.cn/backend/api/business/sampletest"
 
@@ -47,16 +50,16 @@ func (this *SamplesSourceController) SamplesSourceList() {
 		}
 	}
 	if idcard != "" {
-		where = where + " and IDCard =" + idcard + " "
+		where = where + " and IDCard = '" + idcard + "'"
 	}
 	if name != "" {
 		where = where + " and Name like '%" + name + "%'"
 	}
 	if telephone != "" {
-		where = where + " and Telephone =" + telephone + " "
+		where = where + " and Telephone = '" + telephone + "'"
 	}
 	if innerno != "" {
-		where = where + " and InnerNo =" + innerno + " "
+		where = where + " and InnerNo = '" + innerno + "'"
 	}
 	if starttimeint > 0 {
 		where = where + " and  CreateOn >'" + time.Unix(starttimeint/1000, 0).Format("2006-01-02") + "'"
@@ -833,3 +836,67 @@ func (this *SamplesSourceController) DelBioInfo() {
 		this.ServeJSON()
 	}
 }
+
+type DonorSampleTotalModel struct {
+	Samplenum       int `json:"samplenum"`
+	Sampleprenum    int `json:"sampleprenum"`
+	Sampleunsavenum int `json:"sampleunsavenum"`
+	Samplefilesnum  int `json:"samplefilesnum"`
+	Allsamplesum    int `json:"allsamplesum"`
+}
+
+// @Title 获取样本统计数据
+// @Description 获取样本统计数据
+// @Success	200	{object} controllers.Request
+// @router /getsampletotal/:id [get]
+func (this *SamplesSourceController) Getsampletotal() {
+	id := this.Ctx.Input.Param(":id")
+	var model DonorSampleTotalModel
+	//设备权限
+	svcequip := equipment.GetEquipmentService(utils.DBE)
+	poweeids := svcequip.GetPowerEquipmentids(this.User.AccCode, utils.ToStr(this.User.Id))
+	//设备中样本总数
+	svcsample := samplesinfo.GetSamplesInfoService(utils.DBE)
+	wherecout := " DeletionStateCode=0 and SourceId=" + id + " and IState=1 and EquipmentId in(" + strings.Join(poweeids, ",") + ") "
+	samplenum := svcsample.GetSampleOwnCountBySourceId(this.User.AccCode, wherecout)
+	model.Samplenum = samplenum
+	//预录入样本总数
+	wherecout = " DeletionStateCode=0 and SourceId=" + id + " and IState in (2,3,4,7,8) "
+	sampleprenum := svcsample.GetSampleOwnCountBySourceId(this.User.AccCode, wherecout)
+	model.Sampleprenum = sampleprenum
+	//待复存样本总数
+	wherecout = " DeletionStateCode=0 and SourceId=" + id + " and (IState=6 or ( IState=5 and EquipmentId in(" + strings.Join(poweeids, ",") + ")))"
+	sampleunsavenum := svcsample.GetSampleOwnCountBySourceId(this.User.AccCode, wherecout)
+	model.Sampleunsavenum = sampleunsavenum
+
+	//归档样本总数
+	svcsampleFile := samplesfileinfo.GetSamplesFileInfoService(utils.DBE)
+	wheresamplefiles := " DeletionStateCode=0 and SourceId=" + id
+	samplefilesnum := svcsampleFile.GetSampleFileCount(this.User.AccCode, wheresamplefiles)
+	model.Samplefilesnum = samplefilesnum
+	//总数
+	model.Allsamplesum = samplenum + sampleprenum + sampleunsavenum + samplefilesnum
+
+	this.Data["json"] = &model
+	this.ServeJSON()
+}
+
+// @Title 获取设备中样本信息
+// @Description 获取设备中样本信息
+// @Success 200 {object} business.device.DeviceChannels
+// @router /getdevicesamples/:id [get]
+func (this *SamplesSourceController) Getdevicesamples() {
+	id := this.Ctx.Input.Param(":id")
+	//获取分页信息
+	page := this.GetPageInfoForm()
+	svcequip := equipment.GetEquipmentService(utils.DBE)
+	poweeids := svcequip.GetPowerEquipmentids(this.User.AccCode, utils.ToStr(this.User.Id))
+	svc := samplesinfo.GetSamplesInfoService(utils.DBE)
+	wheresourceid := " IState=1 and DeletionStateCode=0 and SourceId=" + id + " and a.EquipmentId in(" + strings.Join(poweeids, ",") + ")"
+	total, data := svc.GetPagingEntitiesWithOrderSearch(this.User.AccCode, page.CurrentPage, page.Size, "Id", wheresourceid)
+	var datainfo DataInfo
+	datainfo.Items = data
+	datainfo.CurrentItemCount = total
+	this.Data["json"] = &datainfo
+	this.ServeJSON()
+}

+ 9 - 1
src/dashoo.cn/backend/api/controllers/biobank/sampletest.go

@@ -76,7 +76,15 @@ func (this *SampleTestController) SampleTestlist() {
 			where = where + " and CheckTime>='" + ValidityminDate + "' and CheckTime<='" + ValiditymaxDate + "'"
 		}
 	}
-
+	CreateOn := this.GetString("CreateOn")
+	if CreateOn != "" {
+		dates := strings.Split(CreateOn, ",")
+		if len(dates) == 2 {
+			minDate := dates[0]
+			maxDate := dates[1]
+			where = where + " and CreateOn>='" + minDate + "' and CreateOn<='" + maxDate + "'"
+		}
+	}
 	svc := sampletest.GetSampleTestService(utils.DBE)
 	var list []sampletest.SampleTestMain
 	total := svc.GetPagingEntitiesWithOrderBytbl(this.User.AccCode, page.CurrentPage, page.Size, orderby, asc, &list, where)

+ 61 - 156
src/dashoo.cn/backend/api/controllers/casbin/role.go

@@ -31,8 +31,8 @@ type RolePerAjaxModel struct {
 	Selecteoperation []permission.Base_Permissionstrtree
 }
 type OrganizeAjaxModel struct {
-	Organize        []organize.Base_Organizetree
-	SelecteOrganize []organize.Base_Organizetree
+	Organize         []organize.Base_Organizetree
+	SelectedOrganize []organize.Base_Organizetree
 }
 type DistrictAjaxModel struct {
 	District         []district.Base_Districttree
@@ -153,34 +153,46 @@ func (this *RoleController) GetRolePowerAjax() {
 	this.ServeJSON()
 }
 
-// @Title 获得部门
-// @Description 获得部门
+// @Title 保存权限
+// @Description 保存权限--菜单权限
 // @Success	200	{object} controllers.Request
-// @router /getdepartment [get]
-func (this *RoleController) DepartmentListGet() {
-	id := this.GetString("id") //roleid
-	svc := permission.GetPermissionService(utils.DBE)
-	currentuser := this.User
-	userid := utils.ToStr(currentuser.Id)
-	organizemodu := svc.GetOrganizeTree(userid)
-	organizeselectedmodu := svc.GetOrganizeTreeByRole(id)
-	rest := OrganizeAjaxModel{organizemodu, organizeselectedmodu}
-	this.Data["json"] = &rest
+// @router /savepower [put]
+func (this *RoleController) RolePowerPost() {
+	roleid := this.GetString("id")
+	var errinfo ErrorInfo
+	if roleid == "" {
+		errinfo.Message = utils.AlertProcess("操作失败!请求信息不完整!")
+		errinfo.Code = -2
+		this.Data["json"] = &errinfo
+		this.ServeJSON()
+	}
+	moduleids := strings.Split(this.GetString("moduleids"), ",")
+	utils.RBAC.RemoveFilteredNamedGroupingPolicy("g2", 0, "rid_"+roleid, utils.DOMAIN)
+	if this.GetString("moduleids") != "" {
+		for j := 0; j < len(moduleids); j++ {
+			moduleid := utils.ToStr(moduleids[j])
+			utils.RBAC.AddNamedGroupingPolicy("g2", "rid_"+roleid, utils.DOMAIN, "mid_"+moduleid)
+		}
+	}
+	errinfo.Message = utils.AlertProcess("权限保存成功!")
+	errinfo.Code = 0
+	this.Data["json"] = &errinfo
 	this.ServeJSON()
 }
 
-// @Title 获得区域
-// @Description 获得区域
-// @Success	200	{object} controllers.Request
-// @router /getdistrict [get]
-func (this *RoleController) DistrictListGet() {
-	id := this.GetString("id") //roleid
+// @Title 操作权限
+// @Description 获取角色操作权限列表
+// @Success 200 {object} controllers.Request
+// @router /getItemPower [get]
+func (this *RoleController) GetRoleItemPowerAjax() {
+	id := this.GetString("id")
 	svc := permission.GetPermissionService(utils.DBE)
 	currentuser := this.User
 	userid := utils.ToStr(currentuser.Id)
-	districtmodu := svc.GetDistrictTree(userid)
-	districtselectedmodu := svc.GetDistrictTreeByRole(id)
-	rest := DistrictAjaxModel{districtmodu, districtselectedmodu}
+	ztreecurrentusernodesope := svc.GetPermissionItemsByUserV2(userid, "0")
+	ztreeselectedusernodesope := svc.GetPermissionItemsByRoleV2(id, "0")
+
+	rest := RolePerAjaxModel{ztreecurrentusernodesope, ztreeselectedusernodesope}
 	this.Data["json"] = &rest
 	this.ServeJSON()
 }
@@ -202,23 +214,21 @@ func (this *RoleController) RoleOperationPowerPost() {
 	}
 
 	//utils.RBAC.DeletePermissionsForUser("rid_" + roleid) //撤销角色的操作访问权限
+	utils.RBAC.RemoveFilteredNamedPolicy("p", 0, "rid_"+roleid, utils.DOMAIN)
 	operationids := strings.Split(this.GetString("operids"), ",")
 	if this.GetString("operids") != "" {
 		for i := 0; i < len(operationids); i++ {
 			if strings.HasPrefix(operationids[i], "self_") {
 				_operationid := []byte(operationids[i])[5:]
 				operationid, _ := utils.StrTo(_operationid).Int()
-				//err := svc.GrantRoleRolePermission(roleid, roleid, operationid, userRole.Base_User{Id: uid, Realname: this.User.Realname})
-				utils.RBAC.DeletePermissionForUser("rid_"+roleid, "pid_"+strconv.Itoa(operationid))
-				ret := utils.RBAC.AddPermissionForUser("rid_"+roleid, "pid_"+strconv.Itoa(operationid))
+				ret := utils.RBAC.AddPermissionForUser("rid_"+roleid, utils.DOMAIN, "pid_"+strconv.Itoa(operationid))
 				if ret == false {
 					beego.Debug("insert error:", ret)
 					continue
 				}
 			} else {
 				operationid, _ := utils.StrTo(operationids[i]).Int()
-				utils.RBAC.DeletePermissionForUser("rid_"+roleid, "pid_"+strconv.Itoa(operationid))
-				ret := utils.RBAC.AddPermissionForUser("rid_"+roleid, "pid_"+strconv.Itoa(operationid))
+				ret := utils.RBAC.AddPermissionForUser("rid_"+roleid, utils.DOMAIN, "pid_"+strconv.Itoa(operationid))
 				if ret == false {
 					beego.Debug("insert error:", ret)
 					continue
@@ -232,115 +242,23 @@ func (this *RoleController) RoleOperationPowerPost() {
 	this.ServeJSON()
 }
 
-// @Title 保存资源权限 ---部门
-// @Description 保存权限
-// @Success	200	{object} controllers.Request
-// @router /savedepartmentmessageview [put]
-func (this *RoleController) OrganizePost() {
-	roleid := this.GetString("id")
-	var errinfo ErrorInfo
-	if roleid == "" {
-		errinfo.Message = utils.AlertProcess("操作失败!请求信息不完整!")
-		errinfo.Code = -2
-		this.Data["json"] = &errinfo
-		this.ServeJSON()
-		return
-	}
-	organizeids := strings.Split(this.GetString("organizeids"), ",")
-	if this.GetString("organizeids") != "" {
-		for i := 0; i < len(organizeids); i++ {
-			if strings.HasPrefix(organizeids[i], "self_") {
-				_organizeids := []byte(organizeids[i])[5:]
-				organizeids, _ := utils.StrTo(_organizeids).Int()
-				ret := utils.RBAC.AddNamedGroupingPolicy("g3", "rid_"+roleid, "oid_"+strconv.Itoa(organizeids), utils.DOMAIN)
-				//utils.RBAC.DeletePermissionForUser("rid_"+roleid, "oid_"+strconv.Itoa(organizeids))
-				//ret := utils.RBAC.AddPermissionForUser("rid_"+roleid, "oid_"+strconv.Itoa(organizeids))
-				if ret == false {
-					beego.Debug("insert error:", ret)
-					continue
-				}
-			} else {
-				organizeids, _ := utils.StrTo(organizeids[i]).Int()
-				ret := utils.RBAC.AddNamedGroupingPolicy("g3", "rid_"+roleid, "oid_"+strconv.Itoa(organizeids), utils.DOMAIN)
-				if ret == false {
-					beego.Debug("insert error:", ret)
-					continue
-				}
-			}
-		}
-	}
-	errinfo.Message = utils.AlertProcess("权限保存成功!")
-	errinfo.Code = 0
-	this.Data["json"] = &errinfo
-	this.ServeJSON()
-}
-
-// @Title 保存资源权限 ---区域
-// @Description 保存权限
-// @Success	200	{object} controllers.Request
-// @router /savedistrict [put]
-func (this *RoleController) DistrictPost() {
-	roleid := this.GetString("id")
-	var errinfo ErrorInfo
-	if roleid == "" {
-		errinfo.Message = utils.AlertProcess("操作失败!请求信息不完整!")
-		errinfo.Code = -2
-		this.Data["json"] = &errinfo
-		this.ServeJSON()
-		return
-	}
-	districtids := strings.Split(this.GetString("districtids"), ",")
-	if this.GetString("districtids") != "" {
-		for i := 0; i < len(districtids); i++ {
-			if strings.HasPrefix(districtids[i], "self_") {
-				_districtids := []byte(districtids[i])[5:]
-				districtids, _ := utils.StrTo(_districtids).Int()
-				ret := utils.RBAC.AddNamedGroupingPolicy("g4", "rid_"+roleid, "did_"+strconv.Itoa(districtids), utils.DOMAIN)
-				//utils.RBAC.DeletePermissionForUser("rid_"+roleid,"did_"+strconv.Itoa(districtids))
-				//ret := utils.RBAC.AddPermissionForUser("rid_"+roleid, "did_"+strconv.Itoa(districtids))
-				if ret == false {
-					beego.Debug("insert error:", ret)
-					continue
-				}
-			} else {
-				districtids, _ := utils.StrTo(districtids[i]).Int()
-				ret := utils.RBAC.AddNamedGroupingPolicy("g4", "rid_"+roleid, "did_"+strconv.Itoa(districtids), utils.DOMAIN)
-				if ret == false {
-					beego.Debug("insert error:", ret)
-					continue
-				}
-			}
-		}
-	}
-	errinfo.Message = utils.AlertProcess("权限保存成功!")
-	errinfo.Code = 0
-	this.Data["json"] = &errinfo
-	this.ServeJSON()
-}
-
-// @Title 权限
-// @Description 获取角色操作权限列表
+// @Title 获取角色容器权限
+// @Description 获取角色容器权限
 // @Success 200 {object} controllers.Request
-// @router /getItemPower [get]
-func (this *RoleController) GetRoleItemPowerAjax() {
+// @router /getroleequidpower [get]
+func (this *RoleController) GetRoleEquidPowerAjax() {
 	id := this.GetString("id")
 	svc := permission.GetPermissionService(utils.DBE)
-	currentuser := this.User
-	userid := utils.ToStr(currentuser.Id)
-	ztreecurrentusernodesope := svc.GetPermissionItemsByUserV2(userid, "0")
-	ztreeselectedusernodesope := svc.GetPermissionItemsByRoleV2(id, "0")
-
-	rest := RolePerAjaxModel{ztreecurrentusernodesope, ztreeselectedusernodesope}
-	this.Data["json"] = &rest
+	eids := svc.GetEquipmentIdByByRole(id)
+	this.Data["json"] = &eids
 	this.ServeJSON()
 }
 
-// @Title 保存权限
-// @Description 保存权限--菜单权限
+// @Title 保存容器权限
+// @Description 保存容器权限
 // @Success	200	{object} controllers.Request
-// @router /savepower [put]
-func (this *RoleController) RolePowerPost() {
-	//svc := casbin.GetPermissionService(utils.DBE)
+// @router /saveequpipower [put]
+func (this *RoleController) SaveequpiPower() {
 	roleid := this.GetString("id")
 	var errinfo ErrorInfo
 	if roleid == "" {
@@ -349,25 +267,12 @@ func (this *RoleController) RolePowerPost() {
 		this.Data["json"] = &errinfo
 		this.ServeJSON()
 	}
-
-	//svc.RevokeRolePermission(roleid)       //撤销角色的操作权限
-	//svc.RevokeRoleModulePermission(roleid) //撤销角色的模块访问权限
-	//	operationids := strings.Split(this.GetString("operids"), ",")
-	moduleids := strings.Split(this.GetString("moduleids"), ",")
-	//uid, _ := utils.StrTo(this.User.Id).Int()
-	//	if this.GetString("operids") != "" {
-	//		for i := 0; i < len(operationids); i++ {
-	//			operationid, _ := utils.StrTo(operationids[i]).Int()
-	//			svc.GrantRolePermission(roleid, operationid, userRole.Base_User{Id: uid, Realname: this.User.Realname})
-	//		}
-	//	}
-	if this.GetString("moduleids") != "" {
-		for j := 0; j < len(moduleids); j++ {
-			moduleid := utils.ToStr(moduleids[j])
-			//utils.RBAC.DeletePermissionForUser("rid_"+roleid, "mid_"+moduleid)
-			utils.RBAC.AddNamedGroupingPolicy("g2", "rid_"+roleid, "mid_"+moduleid, utils.DOMAIN)
-			//utils.RBAC.AddPermissionForUser("rid_"+roleid, "mid_"+moduleid)
-			//svc.GrantRoleModulePermission(roleid, moduleid, userRole.Base_User{Id: uid, Realname: this.User.Realname})
+	selectedids := strings.Split(this.GetString("selectedids"), ",")
+	utils.RBAC.RemoveFilteredNamedGroupingPolicy("g5", 0, "rid_"+roleid, utils.DOMAIN)
+	if this.GetString("selectedids") != "" {
+		for j := 0; j < len(selectedids); j++ {
+			selectedid := utils.ToStr(selectedids[j])
+			utils.RBAC.AddNamedGroupingPolicy("g5", "rid_"+roleid, utils.DOMAIN, "eid_"+selectedid)
 		}
 	}
 	errinfo.Message = utils.AlertProcess("权限保存成功!")
@@ -376,8 +281,8 @@ func (this *RoleController) RolePowerPost() {
 	this.ServeJSON()
 }
 
-// @Title 权限
-// @Description 获取角色操作列表
+// @Title 获取该角色下用户列表
+// @Description 获取该角色下用户列表
 // @Success 200 {object} controllers.Request
 // @router /getusersforrole/:rid [get]
 func (this *RoleController) GetUsersForRole() {
@@ -440,7 +345,7 @@ func (this *RoleController) UserDelete() {
 	serial := strings.Split(inputstr, "_")
 	id := serial[0]
 	roleid := serial[1]
-	utils.RBAC.DeleteRoleForUser("uid_"+id, "rid_"+roleid)
+	utils.RBAC.DeleteRoleForUserInDomain("uid_"+id, "rid_"+roleid, utils.DOMAIN)
 	var errinfo ErrorInfo
 	var err error = nil
 	if err == nil {
@@ -466,7 +371,7 @@ func (this *RoleController) DeleteUserAll() {
 	where := "IsVisible=1"
 	_, users = svc.GetUserListForRole(0, 0, roleid, "Id", where)
 	for i := 0; i < len(users); i++ {
-		utils.RBAC.DeleteRoleForUser("uid_"+utils.ToStr(users[i].Id), "rid_"+roleid)
+		utils.RBAC.DeleteRoleForUserInDomain("uid_"+utils.ToStr(users[i].Id), "rid_"+roleid, utils.DOMAIN)
 	}
 	var errinfo ErrorInfo
 	var err error = nil
@@ -487,10 +392,10 @@ func (this *RoleController) DeleteUserAll() {
 //@Success 200 {object} controllers.Request
 //@router /deleterole/:id [delete]
 func (this *RoleController) DeleteRole() {
-	roleid := this.Ctx.Input.Param(":id")
-	utils.RBAC.DeleteRole("rid_" + roleid)
+	id := this.Ctx.Input.Param(":id")
+	svc := userRole.GetRoleService(utils.DBE)
+	err := svc.DeleteRole(id)
 	var errinfo ErrorInfo
-	var err error = nil
 	if err == nil {
 		errinfo.Message = utils.AlertProcess("删除角色成功!")
 		errinfo.Code = 0

+ 58 - 12
src/dashoo.cn/backend/api/controllers/casbin/user.go

@@ -4,17 +4,19 @@ import (
 	"encoding/json"
 	"strings"
 
-	"dashoo.cn/backend/api/business/equipment"
-	"dashoo.cn/backend/api/business/flupplan"
 	"dashoo.cn/backend/api/business/organize"
 	"dashoo.cn/backend/api/business/role"
-	"dashoo.cn/backend/api/business/samplesapply"
-	"dashoo.cn/backend/api/business/samplesfileinfo"
-	"dashoo.cn/backend/api/business/samplesinfo"
 	"dashoo.cn/backend/api/models"
 	"dashoo.cn/business2/permission"
 	"dashoo.cn/business2/userRole"
 
+	"dashoo.cn/backend/api/business/equipment"
+	"dashoo.cn/backend/api/business/flupplan"
+	"dashoo.cn/backend/api/business/samplesapply"
+	"dashoo.cn/backend/api/business/samplesfileinfo"
+	"dashoo.cn/backend/api/business/samplesgroup"
+	"dashoo.cn/backend/api/business/samplesinfo"
+
 	. "dashoo.cn/backend/api/controllers"
 	"dashoo.cn/utils"
 )
@@ -72,7 +74,8 @@ func (this *UserController) Get() {
 	user.Profile.AccCode = usermodel.AccCode
 	user.Profile.DepartmentId = usermodel.Departmentid
 	user.Profile.Id = usermodel.Id
-
+	// todo 从this.User获取用户名,再查询出具体用户
+	//	user := models.User{"user01", "张三", models.Profile{Gender: "male", Age: 20, Address: "china", Email: "123zs@gmail.com", Realname: "ppppppp"}}
 	this.Data["json"] = user
 	this.ServeJSON()
 }
@@ -107,7 +110,7 @@ func (this *UserController) GetUserModuleTree() {
 // @router /getuserrole/:id [get]
 func (this *UserController) UserPowerCheckRole() {
 	userid := this.Ctx.Input.Param(":id")
-	roleofuser := utils.RBAC.GetRolesForUser("uid_" + userid)
+	roleofuser := utils.RBAC.GetRolesForUserInDomain("uid_"+userid, utils.DOMAIN)
 	for i := 0; i < len(roleofuser); i++ {
 		roleofuser[i] = strings.Replace(roleofuser[i], "rid_", "", 1)
 	}
@@ -182,7 +185,9 @@ func (this *UserController) UserPowerPostRole() {
 // @Success	200	{object} controllers.Request
 // @router / [post]
 func (this *UserController) AddUser() {
-	/*var model UserModel
+	groupid := this.GetString("groupid")
+	groupname := this.GetString("groupname")
+	var model UserModel
 	var jsonblob = this.Ctx.Input.RequestBody
 	json.Unmarshal(jsonblob, &model)
 	var errinfo ErrorDataInfo
@@ -223,9 +228,6 @@ func (this *UserController) AddUser() {
 	userentity.Departmentid = model.DepartmentId
 	userentity.Departmentname = model.DepartmentName
 
-	//salt := utils.GetRandomString(5)
-	//userentity.Userpassword = fmt.Sprintf("%s$%s", salt, utils.EncodePassword("123456", salt))
-	//更改密码算法2014-11-21
 	pwd, key, errrk := utils.TripleDesEncrypt("123456")
 	if errrk != nil {
 		errinfo.Message = "添加失败!" + utils.AlertProcess(errrk.Error())
@@ -241,6 +243,23 @@ func (this *UserController) AddUser() {
 	svc := userRole.GetUserService(utils.DBE)
 	err := svc.AddUser(&userentity)
 
+	//写入分组表
+	if err == nil {
+		if groupid != "" {
+			var entity samplesgroup.GroupDetail
+			entity.GroupId = groupid
+			entity.GroupName = groupname
+			entity.UserId = userentity.Id
+			entity.UserName = model.Username
+			entity.RealName = model.Realname
+			entity.GroupType = "UserGroup"
+			entity.CreateBy = this.User.Realname
+			entity.CreateUserId, _ = utils.StrTo(this.User.Id).Int()
+			groupSvc := samplesgroup.GetSamplesGroupService(utils.DBE)
+			groupSvc.InsertEntityBytbl(this.User.AccCode+GroupDetailName, &entity)
+		}
+	}
+
 	if err == nil {
 		errinfo.Message = "添加用户成功,初始密码为123456!"
 		errinfo.Code = 0
@@ -254,7 +273,7 @@ func (this *UserController) AddUser() {
 		this.Data["json"] = &errinfo
 		this.ServeJSON()
 		return
-	}*/
+	}
 }
 
 // @Title 编辑用户
@@ -364,6 +383,33 @@ func (this *UserController) Delete() {
 	}
 }
 
+// @Title get获取合作用户
+// @Description get user by token
+// @Success 200 {object} models.User
+// @router /listwithrole [get]
+func (this *UserController) ListWithRole() {
+	page := this.GetPageInfoForm()
+	keyword := this.GetString("keyword")
+	svc := permission.GetPermissionService(utils.DBE)
+	var users []userRole.UserRoleModel
+	orderby := "m.Id desc"
+	Order := this.GetString("Order")
+	Prop := this.GetString("Prop")
+	if Order != "" && Prop != "" {
+		orderby = Prop + " " + Order
+	}
+	where := "a.IsVisible=1 and a.CreateUserId='" + utils.ToStr(this.User.Id) + "' or a.Id = '" + utils.ToStr(this.User.Id) + "' "
+	if keyword != "" {
+		where = where + " and a.Realname like '%" + keyword + "%'"
+	}
+	total, users := svc.GetPartnerListWithRole(page.CurrentPage, page.Size, this.User.AccCode+GroupDetailName, orderby, where)
+	var datainfo DataInfo
+	datainfo.Items = users
+	datainfo.CurrentItemCount = total
+	this.Data["json"] = &datainfo
+	this.ServeJSON()
+}
+
 //############获取账户信息
 type AccountTjModel struct {
 	DeviceTotal int64

+ 71 - 69
src/dashoo.cn/backend/api/controllers/equipment/equipment.go

@@ -3,6 +3,7 @@ package equipment
 import (
 	"encoding/json"
 	"fmt"
+	"strconv"
 	"strings"
 	"time"
 
@@ -15,6 +16,7 @@ import (
 	"dashoo.cn/backend/api/business/shelfset"
 	. "dashoo.cn/backend/api/controllers"
 	"dashoo.cn/utils"
+	. "dashoo.cn/utils/db"
 )
 
 // 设备异常报警接口说明
@@ -850,83 +852,83 @@ func (this *EquipmentController) EquipmentDelete() {
 // @Success 200 {object} ErrorInfo
 // @Failure 403 :id 为空
 // @router /refresh [put]
-//func (this *EquipmentController) RefreshCapacity() {
-//	s := currboxcapacity.GetCurrboxcapacityService(utils.DBE)
-//	var acccodes []Id_Str //账户AccCode列表
-//	curracccode := this.User.AccCode
-//	if curracccode == "" {
-//		sqltables := "select distinct AccCode Id from Equipment "
-//		s.DBE.Sql(sqltables).Find(&acccodes)
-//	} else { //账户内部刷新
-//		acccodes = append(acccodes, Id_Str{curracccode})
-//	}
-//	var tablename string //表名
-//	var boxdata []samplesinfo.SampleBoxCount
-//	for _, v := range acccodes {
-//		tablename = string(v.Id) + "SamplesDetail" //样本表名
+func (this *EquipmentController) RefreshCapacity() {
+	s := currboxcapacity.GetCurrboxcapacityService(utils.DBE)
+	var acccodes []Id_Str //账户AccCode列表
+	curracccode := this.User.AccCode
+	if curracccode == "" {
+		sqltables := "select distinct AccCode Id from Equipment "
+		s.DBE.Sql(sqltables).Find(&acccodes)
+	} else { //账户内部刷新
+		acccodes = append(acccodes, Id_Str{curracccode})
+	}
+	var tablename string //表名
+	var boxdata []samplesinfo.SampleBoxCount
+	for _, v := range acccodes {
+		tablename = string(v.Id) + "SamplesDetail" //样本表名
 
-//		var fieldname, updatesql string
+		var fieldname, updatesql string
 
-//		whereshelf := " where AccCode = '" + v.Id + "'"
-//		var shelflist []shelfset.Shelf
-//		shelflist = s.GetShelfList(whereshelf)   //获取冻存架列表
-//		for si := 0; si < len(shelflist); si++ { //循环遍历冻存架,去样本库中查找样本
-//			fieldStr := " UpdateTime= now() "
-//			updateStr := " UpdateTime= now() "
+		whereshelf := " where AccCode = '" + v.Id + "'"
+		var shelflist []shelfset.Shelf
+		shelflist = s.GetShelfList(whereshelf)   //获取冻存架列表
+		for si := 0; si < len(shelflist); si++ { //循环遍历冻存架,去样本库中查找样本
+			fieldStr := " UpdateTime= now() "
+			updateStr := " UpdateTime= now() "
 
-//			//先将所有的状态置成-1//////////////////////////开始/////////////////////////////////
-//			var boxlist []shelfset.Box
-//			boxlist = s.GetBoxByShelfId(utils.ToStr(shelflist[si].Id))
-//			boxlistcount := len(boxlist)
-//			for bi := 0; bi < boxlistcount; bi++ {
-//				updatename := Boxlinename(boxlist[bi].YStation) + utils.ToStr(boxlist[bi].XStation)
-//				updateStr = updateStr + ","
-//				updateStr = updateStr + updatename + "= -1"
-//			}
+			//先将所有的状态置成-1//////////////////////////开始/////////////////////////////////
+			var boxlist []shelfset.Box
+			boxlist = s.GetBoxByShelfId(utils.ToStr(shelflist[si].Id))
+			boxlistcount := len(boxlist)
+			for bi := 0; bi < boxlistcount; bi++ {
+				updatename := Boxlinename(boxlist[bi].YStation) + utils.ToStr(boxlist[bi].XStation)
+				updateStr = updateStr + ","
+				updateStr = updateStr + updatename + "= -1"
+			}
 
-//			if updateStr != "" {
-//				updatesql = " update CurrBoxCapacity set " + updateStr + " where ShelfId = " + utils.ToStr(shelflist[si].Id)
-//				fmt.Println(updatesql)
-//				_, err := s.DBE.Exec(updatesql)
-//				LogError(err)
-//			}
-//			//先将所有的状态置成-1//////////////////////////结束/////////////////////////////////
+			if updateStr != "" {
+				updatesql = " update CurrBoxCapacity set " + updateStr + " where ShelfId = " + utils.ToStr(shelflist[si].Id)
+				fmt.Println(updatesql)
+				_, err := s.DBE.Exec(updatesql)
+				LogError(err)
+			}
+			//先将所有的状态置成-1//////////////////////////结束/////////////////////////////////
 
-//			//更改冻存盒的实际状态////////////////////开始//////////////////////////////////////
-//			boxwhere := " where IState=1 and DeletionStateCode = 0 and ShelfId =" + utils.ToStr(shelflist[si].Id) + ""
-//			svc := samplesinfo.GetSamplesInfoService(utils.DBE)
-//			boxdata = svc.QuerySampleBoxDataList(tablename, boxwhere) //一个冻存盒Id是一条数据
-//			if len(boxdata) > 0 {
-//				for i := 0; i < len(boxdata); i++ {
-//					box := new(shelfset.Box)
-//					s.GetBoxById(utils.ToStr(boxdata[i].BoxId), box)
-//					if box.Id == 0 { //如果找不到冻存盒
-//						continue
-//					} else {
-//						fieldStr = fieldStr + ","
-//						boxdata[i].AllCount = int(box.RowNum * box.ColumnNum)
-//						crate := float64(boxdata[i].CurrCount) / float64(boxdata[i].AllCount) * 100
+			//更改冻存盒的实际状态////////////////////开始//////////////////////////////////////
+			boxwhere := " where IState=1 and DeletionStateCode = 0 and ShelfId =" + utils.ToStr(shelflist[si].Id) + ""
+			svc := samplesinfo.GetSamplesInfoService(utils.DBE)
+			boxdata = svc.QuerySampleBoxDataList(tablename, boxwhere) //一个冻存盒Id是一条数据
+			if len(boxdata) > 0 {
+				for i := 0; i < len(boxdata); i++ {
+					box := new(shelfset.Box)
+					s.GetBoxById(utils.ToStr(boxdata[i].BoxId), box)
+					if box.Id == 0 { //如果找不到冻存盒
+						continue
+					} else {
+						fieldStr = fieldStr + ","
+						boxdata[i].AllCount = int(box.RowNum * box.ColumnNum)
+						crate := float64(boxdata[i].CurrCount) / float64(boxdata[i].AllCount) * 100
 
-//						c_str := strconv.FormatFloat(crate, 'f', 2, 64)
-//						c_f64, _ := strconv.ParseFloat(c_str, 64)
-//						boxdata[i].CurrRate = c_f64
+						c_str := strconv.FormatFloat(crate, 'f', 2, 64)
+						c_f64, _ := strconv.ParseFloat(c_str, 64)
+						boxdata[i].CurrRate = c_f64
 
-//						fieldname = Boxlinename(box.YStation) + utils.ToStr(box.XStation)
-//					}
-//					fieldStr = fieldStr + fieldname + "=" + utils.ToStr(boxdata[i].CurrRate)
-//				}
-//				if fieldStr != "" {
-//					updatesql = " update CurrBoxCapacity set " + fieldStr + " where ShelfId = " + utils.ToStr(shelflist[si].Id)
-//					fmt.Println(updatesql)
-//					_, err := s.DBE.Exec(updatesql)
-//					LogError(err)
-//				}
-//			}
-//			//更改冻存盒的实际状态//////////////////////结束////////////////////////////////////
-//		}
+						fieldname = Boxlinename(box.YStation) + utils.ToStr(box.XStation)
+					}
+					fieldStr = fieldStr + fieldname + "=" + utils.ToStr(boxdata[i].CurrRate)
+				}
+				if fieldStr != "" {
+					updatesql = " update CurrBoxCapacity set " + fieldStr + " where ShelfId = " + utils.ToStr(shelflist[si].Id)
+					fmt.Println(updatesql)
+					_, err := s.DBE.Exec(updatesql)
+					LogError(err)
+				}
+			}
+			//更改冻存盒的实际状态//////////////////////结束////////////////////////////////////
+		}
 
-//	}
-//}
+	}
+}
 
 // @Title 获取传感器列表
 // @Description 获取传感器列表

+ 867 - 845
src/dashoo.cn/backend/api/controllers/equipment/shelfset.go

@@ -1,15 +1,21 @@
 package equipment
 
 import (
-	//	"fmt"
-	//	"strings"
-	//	"time"
+	"encoding/json"
+	"fmt"
+	"strings"
+	"time"
+
+	"dashoo.cn/backend/api/business/currboxcapacity"
+	"dashoo.cn/backend/api/business/equipment"
+	"dashoo.cn/backend/api/business/lastordernum"
+	"dashoo.cn/backend/api/business/sampleorgan"
+	"dashoo.cn/backend/api/business/samplesbusiness"
+	"dashoo.cn/backend/api/business/samplesinfo"
+	"dashoo.cn/backend/api/business/sampletype"
+	"dashoo.cn/backend/api/business/shelfset"
 	. "dashoo.cn/backend/api/controllers"
-	//	"dashoo.cn/backend/api/business/currboxcapacity"
-	//	"dashoo.cn/backend/api/business/equipment"
-	//	"dashoo.cn/backend/api/business/lastordernum"
-	//	"dashoo.cn/backend/api/business/shelfset"
-	//	"dashoo.cn/utils"
+	"dashoo.cn/utils"
 )
 
 // 冻存架 冻存盒
@@ -17,840 +23,856 @@ type ShelfSetController struct {
 	BaseController
 }
 
-//// 冻存盒
-//type BoxData struct {
-//	Shelfbox shelfset.Shelf
-//	Boxshelf shelfset.Box
-//	//	Boxsample []samplesinfo.SamplesInfoShow
-//}
-
-//// 回传数据model
-//type Output struct {
-//	Dimension [2]int      `json:"dimension,omitempty"` //冰箱尺寸
-//	Items     interface{} `json:"items,omitempty"`     //数据列表
-//}
-
-//// 添加样本model
-//type SampleModel struct {
-//	BarCode          string    `json:"BarCode,omitempty"`          // 样本条码
-//	SampleCode       string    `json:"SampleCode,omitempty"`       // 样本编码
-//	SampleType       string    `json:"SampleType,omitempty"`       // 样本类型
-//	SampleTypeName   string    `json:"SampleTypeName,omitempty"`   // 样本类型
-//	Zuzhi            string    `json:"zuzhi,omitempty"`            // 组织器官
-//	Zuzhiming        string    `json:"zuzhiming,omitempty"`        // 组织器官
-//	SamplingSite     string    `json:"SamplingSite,omitempty"`     // 取材部位
-//	SamplingSiteName string    `json:"SamplingSiteName,omitempty"` // 取材部位
-//	Name             string    `json:"Name,omitempty"`             // 名称
-//	ReceiveDate      time.Time `json:"ReceiveDate,omitempty"`      // 接收日期
-//	Capacity         string    `json:"Capacity,omitempty"`         // 可用容量
-//	Unit             string    `json:"Unit,omitempty"`             // 单位(容量)
-//	ValidityDate     time.Time `json:"ValidityDate,omitempty"`     // 有效日期
-//	InnerCode        string    `json:"InnerCode,omitempty"`        // 样本内码
-//	SourceName       string    `json:"SourceName,omitempty"`       // 样本来源
-//	Remark           string    `json:"Remark,omitempty"`           // 备注
-//	PositionStr      string    `json:"PositionStr,omitempty"`      // 位置信息
-//}
-
-//// 添加冻存盒model
-//type BoxModel struct {
-//	XBox   int `json:"xbox,omitempty"`   // 冻存盒x
-//	YBox   int `json:"ybox,omitempty"`   // 冻存盒y
-//	XShelf int `json:"xshelf,omitempty"` // 冻存架x
-//	YShelf int `json:"yshelf,omitempty"` // 冻存架y
-//	//	SampleType string `json:"sampletype,omitempty"` // 样本类型
-//	BarCode   string `json:"barcode,omitempty"`   // 编码
-//	Eid       string `json:"eid,omitempty"`       // 设备id
-//	Boxxvalue int    `json:"boxxvalue,omitempty"` // 冻存盒x大小
-//	Boxyvalue int    `json:"boxyvalue,omitempty"` // 冻存盒y大小
-//}
-
-//// @Title 报警项目列表
-//// @Description 报警项目列表
-//// @Success 200 {object} business.device.DeviceChannels
-//// @router /equipmentinfo/:eid [get]
-////func (this *ShelfSetController) EquipmentInfo() {
-////	eid := this.Ctx.Input.Param(":eid")
-////	svc := currboxcapacity.GetCurrboxcapacityService(utils.DBE)
-////	data := svc.GetCurrboxcapacityByid(eid)
-////	fmt.Println("=========================datattatat:", data)
-////	//	dataStyleScheme := svc.GetStyleScheme("1")
-////	svcequipment := equipment.GetEquipmentService(utils.DBE)
-////	equipmentdata := svcequipment.GetInfoById(eid)
-////	map_list := make(map[string]string)
-////	sample_type := sampletype.GetSampleTypeService(utils.DBE)
-////	where := " AccCode='" + this.User.AccCode + "'"
-////	sample_type_list := sample_type.ListSampleType(where)
-////	for i := 0; i < len(sample_type_list); i++ {
-////		map_list[utils.ToStr(sample_type_list[i].Id)] = sample_type_list[i].Photo
-////	}
-////	this.Data["entitySampleType"] = sample_type_list
-////	this.Data["map_list"] = map_list
-////	this.Data["equipmentdata"] = equipmentdata
-////	this.Data["equipmentName"] = equipmentdata.Name
-////	this.Data["IsLargeSpec"] = equipmentdata.IsLargeSpec
-////	this.Data["json"] = &equipmentdata
-////	this.ServeJSON()
-////}
-
-//// @Title 报警项目列表
-//// @Description 报警项目列表
-//// @Success 200 {object} business.device.DeviceChannels
-//// @router /equipmentdraw/:eid [get]
-//func (this *ShelfSetController) EquipmentDraw() {
-//	// 读取参数和初始化服务
-//	eid := this.Ctx.Input.Param(":eid")
-//	svc := currboxcapacity.GetCurrboxcapacityService(utils.DBE)
-//	// 获取所有相关冻存架信息
-//	data := svc.GetCurrboxcapacityByid(eid)
-//	// 获取冰箱尺寸
-//	sve := equipment.GetEquipmentService(utils.DBE)
-//	entity := sve.GetInfoById(eid)
-//	// 回传数据
-//	var output Output
-//	array := [2]int{entity.ColumnNum, entity.RowNum}
-//	output.Items = &data
-//	output.Dimension = array
-//	this.Data["json"] = &output
-//	this.ServeJSON()
-//}
-
-//// @Title 报警项目列表
-//// @Description 报警项目列表
-//// @Success 200 {object} business.device.DeviceChannels
-//// @router /boxdraw/:inputstr [get]
-////func (this *ShelfSetController) BoxDraw() {
-////	// 读取参数和初始服务
-////	var boxdata BoxData
-////	inputstr := this.Ctx.Input.Param(":inputstr")
-////	serials := strings.Split(inputstr, ",")
-////	id := serials[0]
-////	x := serials[1]
-////	y := serials[2]
-////	x_box := serials[3]
-////	y_box := serials[4]
-////	svs := shelfset.GetshelfsetService(utils.DBE)
-////	// 获取选中box
-////	svc := currboxcapacity.GetCurrboxcapacityService(utils.DBE)
-////	svc.GetBox(&boxdata.Boxshelf, id, x, y, x_box, y_box)
-////	boxdata.Boxsample = nil
-////	// 获取样本, where语句IState部分未经修改
-////	if boxdata.Boxshelf.Id != 0 {
-////		where := " IState in (1,5,10,99) and DeletionStateCode=0 and BoxId = " + utils.ToStr(boxdata.Boxshelf.Id)
-////		svc1 := samplesinfo.GetSamplesInfoService(utils.DBE)
-////		boxdata.Boxsample = svc1.QuerySampleList(this.User.AccCode, where)
-////	}
-////	// 获取冻存架
-////	svs.GetEntityByEquipmentId(id, x, y, &boxdata.Shelfbox)
-////	// 回传数据
-////	this.Data["json"] = boxdata
-////	this.ServeJSON()
-////}
-
-////// @Title 报警项目列表
-////// @Description 报警项目列表
-////// @Success 200 {object} business.device.DeviceChannels
-////// @router /getpos/:inputstr [get]
-////func (this *ShelfSetController) GetPosition() {
-////	inputstr := this.Ctx.Input.Param(":inputstr")
-////	serial := strings.Split(inputstr, "_")
-////	for i := 0; i < len(serial); i++ {
-////		//		println("sdfasdf=f-======", serial[i])
-////	}
-////	svs := shelfset.GetshelfsetService(utils.DBE)
-////	shelf := svs.GetShelfByid(serial[7])
-////	box := svs.GetBoxByid(serial[8])
-
-////	posarr := [4]int{shelf[0].XStation, shelf[0].YStation, box[0].XStation, box[0].YStation}
-////	var datainfo DataInfo
-////	datainfo.Items = posarr
-////	this.Data["json"] = &datainfo
-////	this.ServeJSON()
-
-////}
-
-//// @Title 添加冻存盒或冻存架
-//// @Description 添加冻存盒或冻存架
-//// @Success 200 {object} business.device.DeviceChannels
-//// @router / [post]
-////func (this *ShelfSetController) AddforEquipment() {
-////	// 获得前端传输的model
-////	var model BoxModel
-////	var jsonblob = this.Ctx.Input.RequestBody
-////	json.Unmarshal(jsonblob, &model)
-////	serial := strings.Split(model.Eid, "_")
-////	// 日志初始化
-////	var lastnum lastordernum.LastOrderNum
-////	svss := shelfset.GetshelfsetService(utils.DBE)
-////	lastdata := svss.GetLastBoxNum(this.User.AccCode)
-////	lastnum.LastNum = lastdata
-////	// 其他初始化
-////	var errinfo ErrorInfo
-////	var shelf shelfset.Shelf
-////	var box shelfset.Box
-////	var shelfcap currboxcapacity.CurrBoxCapacity
-////	svc := currboxcapacity.GetCurrboxcapacityService(utils.DBE)
-////	if serial[1] == "1" {
-////		// 更新日志
-////		svss.UpdateBoxNum(lastnum, this.User.AccCode)
-
-////		svss.GetEntityByEquipmentId(serial[0], utils.ToStr(model.XShelf), utils.ToStr(model.YShelf), &shelf)
-////		box.AccCode = this.User.AccCode
-////		box.BarCode = model.BarCode
-////		box.ColumnNum = model.Boxyvalue
-////		box.RowNum = model.Boxxvalue
-////		box.SampleType = model.SampleType
-////		box.XStation = model.XBox
-////		box.YStation = model.YBox
-////		box.EquipmentId, _ = utils.StrTo(serial[0]).Int()
-////		box.ShelfId = shelf.Id
-////		box.Code = lastdata
-////		box.CreateUserId, _ = utils.StrTo(this.User.Id).Int()
-////		box.CreateBy = this.User.Realname
-////		// 更新冻存盒颜色
-////		svc.GetCurrboxcapacityByShelfid(utils.ToStr(shelf.Id), &shelfcap)
-////		colname := string(box.YStation+64) + utils.ToStr(box.XStation)
-////		where := "AccCode='" + this.User.AccCode + "' and EquipmentId='" + serial[0] + "' and ShelfId ='" + utils.ToStr(shelf.Id) + "'"
-////		err := svc.Updata(colname, "-1", where)
-////		// 添加冻存盒
-////		_, err = svss.InsertEntity(&box)
-////		// 错误检测
-////		if err != nil {
-////			errinfo.Message = "添加冻存盒失败!"
-////			errinfo.Code = -2
-////			this.Data["json"] = &errinfo
-////			this.ServeJSON()
-////			return
-////		} else {
-////			errinfo.Message = "添加冻存盒成功!"
-////			errinfo.Code = 0
-////			this.Data["json"] = &errinfo
-////			this.ServeJSON()
-////		}
-////	} else {
-////		// 更新日志 添加设备
-////		svss.UpdateShelfNum(lastnum, this.User.AccCode)
-////		shelf.AccCode = this.User.AccCode
-////		shelf.EquipmentId, _ = utils.StrTo(serial[0]).Int()
-////		shelf.Code = lastdata
-////		shelf.BarCode = model.BarCode
-////		shelf.CreateBy = this.User.Realname
-////		shelf.CreateUserId, _ = utils.StrTo(this.User.Id).Int()
-////		shelf.SampleType = model.SampleType
-////		shelf.RowNum = model.YBox
-////		shelf.ColumnNum = model.XBox
-////		shelf.XStation = model.XShelf
-////		shelf.YStation = model.YShelf
-////		_, err := svss.InsertEntity(&shelf)
-////		// 添加冻存盒颜色----currboxcap
-////		var colstr string = "AccCode, EquipmentId, ShelfId, RowNum, ColumnNum, XStation, YStation,"
-////		var valuestr string = "'" + this.User.AccCode + "'," + serial[0] + "," + utils.ToStr(shelf.Id) + "," + utils.ToStr(shelf.RowNum) + "," + utils.ToStr(shelf.ColumnNum) + "," + utils.ToStr(shelf.XStation) + "," + utils.ToStr(shelf.YStation) + ","
-////		for i := 1; i <= shelf.RowNum; i++ {
-////			for j := 1; j <= shelf.ColumnNum; j++ {
-////				colstr = colstr + string(i+64) + utils.ToStr(j) + ","
-////				valuestr = valuestr + "-2,"
-////			}
-////		}
-////		colstr = colstr[:len(colstr)-1]
-////		valuestr = valuestr[:len(valuestr)-1]
-////		err = svc.Add(colstr, valuestr)
-////		// 错误检测
-////		if err != nil {
-////			errinfo.Message = "添加冻存架失败!"
-////			errinfo.Code = -2
-////			this.Data["json"] = &errinfo
-////			this.ServeJSON()
-////			return
-////		} else {
-////			errinfo.Message = "添加冻存架成功!"
-////			errinfo.Code = 0
-////			this.Data["json"] = &errinfo
-////			this.ServeJSON()
-////		}
-////	}
-
-////}
-
-//// @Title 编辑冻存盒或冻存架
-//// @Description 编辑冻存盒或冻存架
-//// @Success	200	{object} controllers.Request
-//// @router /editforequip [put]
-////func (this *ShelfSetController) EditforEquipment() {
-////	var model BoxModel
-////	var jsonblob = this.Ctx.Input.RequestBody
-////	json.Unmarshal(jsonblob, &model)
-////	fmt.Println("==============modddeelll", model)
-////	serial := strings.Split(model.Eid, "_")
-////	svc := shelfset.GetshelfsetService(utils.DBE)
-////	var errinfo ErrorInfo
-////	if serial[1] == "2" {
-////		//初始化服务
-////		var shelfempty shelfset.Shelf
-////		var shelf shelfset.Shelf
-////		svc.GetEntityByEquipmentId(serial[0], utils.ToStr(model.XShelf), utils.ToStr(model.YShelf), &shelf)
-////		//编辑
-////		shelf.ModifiedBy = this.User.Realname
-////		shelf.ModifiedUserId, _ = utils.StrTo(this.User.Id).Int()
-////		shelf.SampleType = model.SampleType
-////		shelf.BarCode = model.BarCode
-////		var cols []string = []string{"RowNum", "ColumnNum", "BarCode", "SampleType", "ModifiedUserId", "ModifiedBy"}
-////		opdesc := "编辑冻存架-" + shelf.ShelfSpecName + ",第" + utils.ToStr(shelf.YStation) + "行第" + utils.ToStr(shelf.XStation) + "列"
-////		err := svc.UpdateEntityAndWriteLog(shelf.Id, &shelf, &shelfempty, cols, utils.ToStr(this.User.Id), this.User.Username, opdesc, this.User.AccCode, "设备管理")
-////		// 错误检测
-////		if err != nil {
-////			errinfo.Message = "编辑冻存架失败!"
-////			errinfo.Code = -2
-////			this.Data["json"] = &errinfo
-////			this.ServeJSON()
-////			return
-////		} else {
-////			errinfo.Message = "编辑冻存架成功!"
-////			errinfo.Code = 0
-////			this.Data["json"] = &errinfo
-////			this.ServeJSON()
-////		}
-////	} else {
-////		var box shelfset.Box
-////		var boxempty shelfset.Box
-////		svc.GetEntityByShelfIdXY(serial[2], utils.ToStr(model.XBox), utils.ToStr(model.YBox), &box)
-////		box.ColumnNum = model.Boxyvalue
-////		box.RowNum = model.Boxxvalue
-////		box.ModifiedBy = this.User.Realname
-////		box.ModifiedUserId, _ = utils.StrTo(this.User.Id).Int()
-////		box.SampleType = model.SampleType
-////		box.BarCode = model.BarCode
-////		var cols []string = []string{"RowNum", "ColumnNum", "BarCode", "SampleType", "ModifiedUserId", "ModifiedBy"}
-////		opdesc := "编辑冻存盒-" + box.Code + ",冻存架第" + serial[4] + "行第" + serial[3] + "列,冻存盒第" + utils.ToStr(box.YStation) + "行第" + utils.ToStr(box.XStation) + "列"
-////		err := svc.UpdateEntityAndWriteLog(box.Id, &box, &boxempty, cols, utils.ToStr(this.User.Id), this.User.Username, opdesc, this.User.AccCode, "设备管理")
-////		// 错误检测
-////		if err != nil {
-////			errinfo.Message = "编辑冻存盒失败!"
-////			errinfo.Code = -2
-////			this.Data["json"] = &errinfo
-////			this.ServeJSON()
-////			return
-////		} else {
-////			errinfo.Message = "编辑冻存盒成功!"
-////			errinfo.Code = 0
-////			this.Data["json"] = &errinfo
-////			this.ServeJSON()
-////		}
-////	}
-
-////}
-
-//// @Title 冻存架移动
-//// @Description 检测样本类型是否匹配和冻存架移动,分两个方法
-//// @Success	200	{object} controllers.Request
-//// @router /shelfmove/:inputstr [put]
-////func (this *ShelfSetController) BeforeMoveShelf() {
-////	inputstr := this.Ctx.Input.Param(":inputstr")
-////	println("===ssss=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-", inputstr)
-////	serial := strings.Split(inputstr, "_")
-////	var errinfo ErrorInfo
-////	var entity equipment.Equipment
-////	var shelf shelfset.Shelf
-////	sve := equipment.GetEquipmentService(utils.DBE)
-////	svs := shelfset.GetshelfsetService(utils.DBE)
-////	where := "Id = " + serial[0]
-////	sve.GetEntity(&entity, where)
-////	println("ccc-=====================", entity.SampleType)
-////	seriale := strings.Split(entity.SampleType, ",")
-////	svs.GetEntityByEquipmentId(serial[1], serial[2], serial[3], &shelf)
-////	println("xxx-=====================", shelf.SampleType)
-////	serials := strings.Split(shelf.SampleType, ",")
-////	var exist = false
-////	for i := 0; i < len(serials); i++ {
-////		for j := 0; j < len(seriale); j++ {
-////			if serials[i] == seriale[j] {
-////				exist = true
-////			}
-////		}
-////		if !exist {
-////			errinfo.Message = "存在不支持的样本类型!"
-////			errinfo.Code = -1
-////			this.Data["json"] = &errinfo
-////			this.ServeJSON()
-////			return
-////		}
-////		exist = false
-////	}
-////	this.MoveforShelf(utils.ToStr(shelf.Id))
-////}
-
-////func (this *ShelfSetController) MoveforShelf(shelfid string) {
-////	inputstr := this.Ctx.Input.Param(":inputstr")
-////	println("===ssss=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-", inputstr)
-////	serial := strings.Split(inputstr, "_")
-////	var errinfo ErrorInfo
-////	var shelf shelfset.Shelf
-////	var shelfempty shelfset.Shelf
-////	// shelf
-////	// equipmentid := serial[1]
-////	svc := shelfset.GetshelfsetService(utils.DBE)
-////	shelf.EquipmentId, _ = utils.StrTo(serial[0]).Int()
-////	shelf.XStation, _ = utils.StrTo(serial[4]).Int()
-////	shelf.YStation, _ = utils.StrTo(serial[5]).Int()
-////	shelf.ModifiedBy = this.User.Realname
-////	shelf.ModifiedUserId, _ = utils.StrTo(this.User.Id).Int()
-////	var cols []string = []string{"EquipmentId", "XStation", "YStation", "ModifiedUserId", "ModifiedBy"}
-////	opdesc := "移动冻存架-原位置:" + serial[1] + ",第" + serial[3] + "行第" + serial[2] + "列"
-////	svc.UpdateEntityAndWriteLog(shelfid, &shelf, &shelfempty, cols, utils.ToStr(this.User.Id), this.User.Username, opdesc, this.User.AccCode, "设备管理")
-////	// 冻存盒颜色
-////	var currboxcapacitys currboxcapacity.CurrBoxCapacity
-////	svc1 := currboxcapacity.GetCurrboxcapacityService(utils.DBE)
-////	currboxcapacitys.EquipmentId, _ = utils.StrTo(serial[0]).Int()
-////	currboxcapacitys.ShelfId, _ = utils.StrTo(shelfid).Int()
-////	currboxcapacitys.XStation, _ = utils.StrTo(serial[4]).Int()
-////	currboxcapacitys.YStation, _ = utils.StrTo(serial[5]).Int()
-////	where1 := "  AccCode='" + this.User.AccCode + "' and ShelfId=" + shelfid
-////	svc1.UpdateEntityByWhere(where1, &currboxcapacitys)
-////	// 冻存盒
-////	var boxempty shelfset.Box
-////	var colss []string = []string{"EquipmentId", "ModifiedUserId", "ModifiedBy"}
-////	boxempty.EquipmentId, _ = utils.StrTo(serial[0]).Int()
-////	boxempty.ModifiedBy = this.User.Realname
-////	boxempty.ModifiedUserId, _ = utils.StrTo(this.User.Id).Int()
-////	where := "  AccCode='" + this.User.AccCode + "' and ShelfId=" + shelfid
-////	svc.UpdateEntityColsByWhere(&boxempty, where, colss)
-////	// 样本---isAddFNum是否记录冻融次数
-////	tblDetai := this.User.AccCode + SamplesDetailtbName
-////	sql := ""
-////	if serial[6] == "true" {
-////		sql = "update " + tblDetai + " set EquipmentId=" + serial[0] + ",FreezingNum=FreezingNum+1 where ShelfId=" + shelfid + " and DeletionStateCode=0 and IState in (1,5)"
-////	} else {
-////		sql = "update " + tblDetai + " set EquipmentId=" + serial[0] + " where ShelfId=" + shelfid + " and DeletionStateCode=0 and IState in (1,5)"
-////	}
-////	svc.SqlMethod(sql)
-////	// 样本
-////	var SamplesData []samplesinfo.SamplesInfoShow
-////	where = " DeletionStateCode=0 and EquipmentId=" + serial[0] + " and ShelfId=" + shelfid + " and IState in (1,5)"
-////	svcSample := samplesinfo.GetSamplesInfoService(utils.DBE)
-////	SamplesData = svcSample.QuerySampleList(this.User.AccCode, where)
-
-////	svcequipment := equipment.GetEquipmentService(utils.DBE)
-////	newequipmententity := svcequipment.GetInfoById(serial[0])
-////	newpositon := "-新位置:" + newequipmententity.Name + ",第" + serial[5] + "行第" + serial[4] + "列"
-////	//	//业务记录
-////	//	for i := 0; i < len(SamplesData); i++ {
-////	//		var databuss samplesbusiness.SamplesBusiness
-////	//		databuss.AccCode = this.User.AccCode
-////	//		databuss.OpType = 41
-////	//		databuss.SampleCode = SamplesData[i].SampleCode
-////	//		databuss.BarCode = SamplesData[i].BarCode
-////	//		databuss.SampleType = SamplesData[i].SampleType
-////	//		databuss.CapacityUsed = SamplesData[i].Capacity
-////	//		databuss.CapacityRest = SamplesData[i].Capacity
-////	//		databuss.Unit = SamplesData[i].Unit
-////	//		databuss.EquipmentId = SamplesData[i].EquipmentId
-////	//		databuss.ShelfId = SamplesData[i].ShelfId
-////	//		databuss.BoxId = SamplesData[i].BoxId
-////	//		databuss.Position = SamplesData[i].Position
-////	//		databuss.PositionDesc = svcSample.GetPostiondescByPosId(databuss.EquipmentId, databuss.ShelfId, databuss.BoxId, databuss.Position)
-
-////	//		databuss.CreateUserId, _ = utils.StrTo(this.User.Id).Int()
-////	//		databuss.CreateBy = this.User.Realname
-////	//		databuss.OpDesc = opdesc + "-" + newpositon
-////	//		svcSample.InsertEntityBytbl(this.User.AccCode+SamplesBusstbName, &databuss)
-////	//	}
-////	errinfo.Message = "成功"
-////	errinfo.Code = 0
-////	this.Data["json"] = &errinfo
-////	this.ServeJSON()
-////	return
-////}
-
-//// @Title 冻存盒移动
-//// @Description 检测样本类型是否匹配和冻存盒移动,分两个方法
-//// @Success	200	{object} controllers.Request
-//// @router /boxmove/:inputstr [put]
-//func (this *ShelfSetController) BeforeMoveBox() {
-//	inputstr := this.Ctx.Input.Param(":inputstr")
-//	serial := strings.Split(inputstr, "_")
-//	var errinfo ErrorInfo
-//	var entity equipment.Equipment
-//	var shelf shelfset.Shelf
-//	var box shelfset.Box
-//	sve := equipment.GetEquipmentService(utils.DBE)
-//	svs := shelfset.GetshelfsetService(utils.DBE)
-//	where := "Id = " + serial[0]
-//	sve.GetEntity(&entity, where)
-//	println("eee-=====================", entity.SampleType)
-//	seriale := strings.Split(entity.SampleType, ",")
-//	svs.GetEntityByEquipmentId(serial[1], serial[7], serial[8], &shelf)
-//	svs.GetEntityByShelfIdXY(utils.ToStr(shelf.Id), serial[2], serial[3], &box)
-//	println("bbb-=====================", box.SampleType)
-//	serialb := strings.Split(box.SampleType, ",")
-//	var exist = false
-//	for i := 0; i < len(serialb); i++ {
-//		for j := 0; j < len(seriale); j++ {
-//			if serialb[i] == seriale[j] {
-//				exist = true
-//			}
-//		}
-//		if !exist {
-//			errinfo.Message = "存在不支持的样本类型!"
-//			errinfo.Code = -1
-//			this.Data["json"] = &errinfo
-//			this.ServeJSON()
-//			return
-//		}
-//		exist = false
-//	}
-//	this.MoveforBox(utils.ToStr(box.Id), utils.ToStr(shelf.Id))
-//}
-
-//func (this *ShelfSetController) MoveforBox(boxid string, shelfoldid string) {
-//	inputstr := this.Ctx.Input.Param(":inputstr")
-//	println("===ss-=-=-=-=-=-=-=-", inputstr)
-//	serial := strings.Split(inputstr, "_")
-//	var box shelfset.Box
-//	var boxempty shelfset.Box
-//	var shelf shelfset.Shelf
-//	var errinfo ErrorInfo
-//	//equipmentid := this.GetString("equipmentid")
-//	svc := shelfset.GetshelfsetService(utils.DBE)
-//	svc.GetEntityByEquipmentId(serial[0], serial[9], serial[10], &shelf)
-//	// 冻存盒
-//	box.EquipmentId, _ = utils.StrTo(serial[0]).Int()
-//	box.ShelfId = shelf.Id
-//	box.XStation, _ = utils.StrTo(serial[4]).Int()
-//	box.YStation, _ = utils.StrTo(serial[5]).Int()
-//	box.ModifiedBy = this.User.Realname
-//	box.ModifiedUserId, _ = utils.StrTo(this.User.Id).Int()
-//	var cols []string = []string{"EquipmentId", "ShelfId", "XStation", "YStation", "ModifiedUserId", "ModifiedBy"}
-//	opdesc := "移动冻存盒-原位置:" + serial[1] + ",冻存架第" + serial[8] + "行第" + serial[7] + "列,冻存盒第" + serial[3] + "行第" + serial[2] + "列"
-//	svc.UpdateEntityAndWriteLog(boxid, &box, &boxempty, cols, utils.ToStr(this.User.Id), this.User.Username, opdesc, this.User.AccCode, "设备管理")
-//	// 冻存盒颜色
-//	svc1 := currboxcapacity.GetCurrboxcapacityService(utils.DBE)
-//	ystaion, _ := utils.StrTo(serial[3]).Int()
-//	charname := Boxlinename(ystaion)
-//	sqlfield := fmt.Sprintf("%v%v", charname, serial[2])
-//	where := " EquipmentId='" + serial[1] + "' and ShelfId ='" + shelfoldid + "'"
-//	svc1.Updata(sqlfield, "-2", where)
-//	ystaion1, _ := utils.StrTo(serial[5]).Int()
-//	charname1 := Boxlinename(ystaion1)
-//	sqlfield1 := fmt.Sprintf("%v%v", charname1, serial[4])
-//	where1 := " EquipmentId='" + serial[0] + "' and ShelfId ='" + utils.ToStr(shelf.Id) + "'"
-//	svc1.Updata(sqlfield1, "-1", where1)
-//	// 样本----冻融记录
-//	tblDetai := this.User.AccCode + SamplesDetailtbName
-//	sql := ""
-//	if serial[6] == "true" {
-//		sql = "update " + tblDetai + " set EquipmentId=" + serial[0] + ",ShelfId=" + utils.ToStr(shelf.Id) + ",FreezingNum=FreezingNum+1 where BoxId=" + boxid + " and DeletionStateCode=0 and IState in (1,5) "
-//	} else {
-//		sql = "update " + tblDetai + " set EquipmentId=" + serial[0] + ",ShelfId=" + utils.ToStr(shelf.Id) + " where BoxId=" + boxid + " and DeletionStateCode=0 and IState in (1,5) "
-//	}
-//	svc.SqlMethod(sql)
-//	// 样本
-//	var SamplesData []samplesinfo.SamplesInfoShow
-//	where = " DeletionStateCode=0 and EquipmentId=" + serial[0] + " and ShelfId=" + utils.ToStr(shelf.Id) + " and BoxId=" + boxid + " and IState in (1,5) "
-//	svcSample := samplesinfo.GetSamplesInfoService(utils.DBE)
-//	SamplesData = svcSample.QuerySampleList(this.User.AccCode, where)
-//	svcequipment := equipment.GetEquipmentService(utils.DBE)
-//	newequipmententity := svcequipment.GetInfoById(serial[0])
-//	newpositon := "新位置:" + newequipmententity.Name + ",冻存架第" + serial[10] + "行第" + serial[9] + "列,冻存盒第" + serial[5] + "行第" + serial[4] + "列"
-//	//	for i := 0; i < len(SamplesData); i++ {
-//	//		var databuss samplesbusiness.SamplesBusiness //业务记录
-//	//		databuss.AccCode = this.User.AccCode
-//	//		databuss.OpType = 41
-//	//		databuss.SampleCode = SamplesData[i].SampleCode
-//	//		databuss.BarCode = SamplesData[i].BarCode
-//	//		databuss.SampleType = SamplesData[i].SampleType
-//	//		databuss.CapacityUsed = SamplesData[i].Capacity
-//	//		databuss.CapacityRest = SamplesData[i].Capacity
-//	//		databuss.Unit = SamplesData[i].Unit
-//	//		databuss.EquipmentId = SamplesData[i].EquipmentId
-//	//		databuss.ShelfId = SamplesData[i].ShelfId
-//	//		databuss.BoxId = SamplesData[i].BoxId
-//	//		databuss.Position = SamplesData[i].Position
-//	//		databuss.PositionDesc = svcSample.GetPostiondescByPosId(databuss.EquipmentId, databuss.ShelfId, databuss.BoxId, databuss.Position)
-
-//	//		databuss.CreateUserId, _ = utils.StrTo(this.User.Id).Int()
-//	//		databuss.CreateBy = this.User.Realname
-//	//		databuss.OpDesc = opdesc + "-" + newpositon
-//	//		svcSample.InsertEntityBytbl(this.User.AccCode+SamplesBusstbName, &databuss)
-//	//	}
-//	errinfo.Message = "成功"
-//	errinfo.Code = 0
-//	this.Data["json"] = &errinfo
-//	this.ServeJSON()
-//	return
-//}
-
-//// @Title 冻存架复制
-//// @Description 冻存架复制
-//// @Success	200	{object} controllers.Request
-//// @router /shelfcopy/:inputstr [put]
-//func (this *ShelfSetController) CopyforShelf() {
-//	inputstr := this.Ctx.Input.Param(":inputstr")
-//	serial := strings.Split(inputstr, "_")
-//	for i := 0; i < len(serial); i++ {
-//		println("sdfasdf=f-======", serial[i])
-//	}
-//	var shelf shelfset.Shelf
-//	var box_model []shelfset.Box
-//	shelf_model := new(shelfset.Shelf)
-//	id := serial[0]
-//	data1 := serial[1]
-//	data2 := strings.Split(data1, ",")
-//	copybox := serial[2]
-//	svc := shelfset.GetshelfsetService(utils.DBE)
-//	svc.GetEntityByEquipmentId(id, serial[3], serial[4], shelf_model)
-//	lastdata := svc.GetLastShelfNum(this.User.AccCode)
-//	num_lastdata, _ := utils.StrTo(lastdata[1:]).Int64()
-//	for i := 0; i < len(data2); i++ {
-//		shelf.AccCode = this.User.AccCode
-//		shelf.EquipmentId = shelf_model.EquipmentId
-//		shelf.Code = "F" + utils.ToStr(num_lastdata)
-//		shelf.ShelfSpecName = shelf_model.ShelfSpecName
-//		station := strings.Split(utils.ToStr(data2[i]), ";")
-//		fmt.Println(station)
-//		shelf.XStation, _ = utils.StrTo(station[0]).Int()
-//		shelf.YStation, _ = utils.StrTo(station[1]).Int()
-//		shelf.BarCode = "F" + utils.ToStr(num_lastdata)
-//		shelf.RowNum = shelf_model.RowNum
-//		shelf.ColumnNum = shelf_model.ColumnNum
-//		shelf.SampleType = shelf_model.SampleType
-//		shelf.CreateUserId, _ = utils.StrTo(this.User.Id).Int()
-//		shelf.CreateBy = this.User.Realname
-//		num_lastdata = num_lastdata + 1
-//		svc.InsertEntity(&shelf)
-//		svc1 := currboxcapacity.GetCurrboxcapacityService(utils.DBE)
-//		if copybox == "true" {
-//			where := "ShelfId=" + utils.ToStr(shelf_model.Id)
-//			box_model = svc.BoxListByid(where)
-//			lastdata_box := svc.GetLastBoxNum(this.User.AccCode)
-//			num_lastdata_box, _ := utils.StrTo(lastdata_box[1:]).Int64()
-//			for i := 0; i < len(box_model); i++ {
-//				box_model[i].Code = "B" + utils.ToStr(num_lastdata_box)
-//				box_model[i].BarCode = "B" + utils.ToStr(num_lastdata_box)
-//				box_model[i].ShelfId = shelf.Id
-//				box_model[i].CreateBy = this.User.Realname
-//				box_model[i].CreateUserId, _ = utils.StrTo(this.User.Id).Int()
-//				num_lastdata_box = num_lastdata_box + 1
-//				svc.InsertEntity(&box_model[i])
-//			}
-//			num_lastdata_box = num_lastdata_box - 1
-//			var lastnum lastordernum.LastOrderNum
-//			lastnum.LastNum = "B" + utils.ToStr(num_lastdata_box)
-//			svc.UpdateBoxNum(lastnum, this.User.AccCode)
-//			svc1.RangeCurrboxcapacityByShelfid(utils.ToStr(shelf_model.Id), utils.ToStr(shelf.Id), utils.ToStr(shelf.XStation), utils.ToStr(shelf.YStation))
-//		} else {
-//			sqlfield := "AccCode,EquipmentId,ShelfId,XStation,YStation,RowNum,ColumnNum,"
-//			sqlvalue := "'" + this.User.AccCode + "'," + utils.ToStr(shelf.EquipmentId) + "," + utils.ToStr(shelf.Id) + "," + utils.ToStr(shelf.XStation) + "," + utils.ToStr(shelf.YStation) + "," + utils.ToStr(shelf.RowNum) + "," + utils.ToStr(shelf.ColumnNum) + ","
-//			i, j := shelf.RowNum, shelf.ColumnNum
-//			for e := 0; e < i; e++ {
-//				charname := Boxlinename(e + 1)
-//				for f := 0; f < j; f++ {
-//					fieldname := fmt.Sprintf("%v%v", charname, f+1)
-//					if f == j-1 && e == i-1 {
-//						sqlfield += fieldname
-//						sqlvalue += "-2"
-//					} else {
-//						sqlfield += fieldname + ","
-//						sqlvalue += "-2,"
-//					}
-//				}
-//			}
-//			svc1.Add(sqlfield, sqlvalue)
-//		}
-//	}
-//	num_lastdata = num_lastdata - 1
-//	var lastnum_shelf lastordernum.LastOrderNum
-//	lastnum_shelf.LastNum = "F" + utils.ToStr(num_lastdata)
-//	svc.UpdateShelfNum(lastnum_shelf, this.User.AccCode)
-
-//	var errinfo ErrorInfo
-//	errinfo.Message = "复制冻存架成功!"
-//	errinfo.Code = 0
-//	this.Data["json"] = &errinfo
-//	this.ServeJSON()
-//}
-
-//// @Title 冻存架复制
-//// @Description 冻存架复制
-//// @Success	200	{object} controllers.Request
-//// @router /boxcopy/:inputstr [put]
-//func (this *ShelfSetController) CopyforBox() {
-//	inputstr := this.Ctx.Input.Param(":inputstr")
-//	serial := strings.Split(inputstr, "_")
-//	for i := 0; i < len(serial); i++ {
-//		println("sdfasdf=f-======", serial[i])
-//	}
-//	var shelf shelfset.Shelf
-//	box_model := new(shelfset.Box)
-//	var box shelfset.Box
-//	var sqlfield_str string
-//	//var fieldValue string
-//	id := serial[0]
-//	data1 := serial[5]
-//	data2 := strings.Split(data1, ",")
-//	svc := shelfset.GetshelfsetService(utils.DBE)
-//	svc.GetEntityByEquipmentId(id, serial[1], serial[2], &shelf)
-//	svc.GetEntityByShelfIdXY(utils.ToStr(shelf.Id), serial[3], serial[4], box_model)
-//	lastdata_box := svc.GetLastBoxNum(this.User.AccCode)
-//	num_lastdata_box, _ := utils.StrTo(lastdata_box[1:]).Int64()
-//	for i := 0; i < len(data2); i++ {
-//		box.AccCode = this.User.AccCode
-//		box.EquipmentId = box_model.EquipmentId
-//		box.ShelfId = box_model.ShelfId
-//		box.Code = "B" + utils.ToStr(num_lastdata_box)
-//		station := strings.Split(utils.ToStr(data2[i]), ";")
-//		fmt.Println(station)
-//		box.XStation, _ = utils.StrTo(station[0]).Int()
-//		box.YStation, _ = utils.StrTo(station[1]).Int()
-//		box.BarCode = "B" + utils.ToStr(num_lastdata_box)
-//		box.RowNum = box_model.RowNum
-//		box.ColumnNum = box_model.ColumnNum
-//		box.SampleType = box_model.SampleType
-//		box.CreateUserId, _ = utils.StrTo(this.User.Id).Int()
-//		box.CreateBy = this.User.Realname
-//		num_lastdata_box = num_lastdata_box + 1
-//		svc.InsertEntity(&box)
-//		charname := Boxlinename(box.YStation)
-//		sqlfield := fmt.Sprintf("%v%v", charname, box.XStation)
-//		if i == len(data2)-1 {
-//			sqlfield_str += sqlfield + "=-1 "
-//			//fieldValue+="-1"
-//		} else {
-//			//sqlfield_str+=sqlfield+","
-//			//fieldValue+="-1,"
-//			sqlfield_str += sqlfield + "=-1,"
-//		}
-
-//	}
-//	num_lastdata_box = num_lastdata_box - 1
-//	var lastnum lastordernum.LastOrderNum
-//	lastnum.LastNum = "B" + utils.ToStr(num_lastdata_box)
-//	svc.UpdateBoxNum(lastnum, this.User.AccCode)
-//	svc1 := currboxcapacity.GetCurrboxcapacityService(utils.DBE)
-//	where := "AccCode='" + this.User.AccCode + "' and EquipmentId='" + serial[0] + "' and ShelfId ='" + utils.ToStr(shelf.Id) + "'"
-//	svc1.UpdataCopyTo(sqlfield_str, where)
-
-//	var errinfo ErrorInfo
-//	errinfo.Message = "复制冻存盒成功!"
-//	errinfo.Code = 0
-//	this.Data["json"] = &errinfo
-//	this.ServeJSON()
-//}
-
-//// @Title 删除冻存盒或冻存架
-//// @Description 删除冻存盒或冻存架
-//// @Param	code		path 	string	true
-//// @Success 200 {object} ErrorInfo
-//// @Failure 403 :code 为空
-//// @router deleteforequip/:inputstr [delete]
-//func (this *ShelfSetController) DeleteforEquipment() {
-//	inputstr := this.Ctx.Input.Param(":inputstr")
-//	serial := strings.Split(inputstr, "_")
-//	println("===ssss=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-", serial[0])
-//	println("===ssss=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-", serial[1])
-//	println("===ssss=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-", serial[2])
-//	println("===ssss=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-", serial[3])
-//	var errinfo ErrorInfo
-//	var shelf shelfset.Shelf
-//	svc1 := currboxcapacity.GetCurrboxcapacityService(utils.DBE)
-//	svc := shelfset.GetshelfsetService(utils.DBE)
-
-//	if serial[0] == "0" {
-//		var shelfempty shelfset.Shelf
-//		svc.GetEntityByEquipmentId(serial[3], serial[1], serial[2], &shelf)
-//		var currboxcapacitys currboxcapacity.CurrBoxCapacity
-//		err := svc1.DeleteCurrbox(currboxcapacitys, utils.ToStr(shelf.Id))
-//		// 删除冻存盒
-//		where_box := "ShelfId =" + utils.ToStr(shelf.Id)
-//		box_list := svc.BoxListByid(where_box)
-//		for i := 0; i < len(box_list); i++ {
-//			var boxempty shelfset.Box
-//			opdesc := "删除冻存盒-" + utils.ToStr(box_list[i].Code) + ",冻存架第" + serial[2] + "行第" + serial[1] + "列,冻存盒第" + utils.ToStr(box_list[i].YStation) + "行第" + utils.ToStr(box_list[i].XStation) + "列"
-//			err = svc.DeleteEntityAndWriteLog(box_list[i].Id, &box_list[i], &boxempty, utils.ToStr(this.User.Id), this.User.Username, opdesc, this.User.AccCode, "设备管理")
-//		}
-//		opdesc := "删除冻存架-" + utils.ToStr(shelf.Id) + ",第" + serial[2] + "行第" + serial[1] + "列"
-//		err = svc.DeleteEntityAndWriteLog(shelf.Id, &shelf, &shelfempty, utils.ToStr(this.User.Id), this.User.Username, opdesc, this.User.AccCode, "设备管理")
-//		// 错误检测
-//		if err != nil {
-//			errinfo.Message = "删除冻存架失败!"
-//			errinfo.Code = -1
-//			this.Data["json"] = &errinfo
-//			this.ServeJSON()
-//			return
-//		} else {
-//			errinfo.Message = "删除冻存架成功!"
-//			errinfo.Code = 0
-//			this.Data["json"] = &errinfo
-//			this.ServeJSON()
-//		}
-//	} else {
-//		var box shelfset.Box
-//		var boxempty shelfset.Box
-//		svc.GetEntityByEquipmentId(serial[3], serial[4], serial[5], &shelf)
-//		// 更新颜色
-//		x, _ := utils.StrTo(serial[2]).Int()
-//		colname := string(x+64) + serial[1]
-//		where := "AccCode='" + this.User.AccCode + "' and EquipmentId='" + serial[3] + "' and ShelfId ='" + utils.ToStr(shelf.Id) + "'"
-//		err := svc1.Updata(colname, "-2", where)
-//		svc.GetBoxBoolByXY(utils.ToStr(shelf.Id), serial[1], serial[2], &box)
-//		opdesc := "删除冻存盒-" + box.Code + ",冻存架第" + utils.ToStr(shelf.YStation) + "行第" + utils.ToStr(shelf.XStation) + "列,冻存盒第" + utils.ToStr(box.YStation) + "行第" + utils.ToStr(box.XStation) + "列"
-//		err = svc.DeleteEntityAndWriteLog(box.Id, &box, &boxempty, utils.ToStr(this.User.Id), this.User.Username, opdesc, this.User.AccCode, "设备管理")
-//		// 错误检测
-//		if err != nil {
-//			errinfo.Message = "删除冻存盒失败!"
-//			errinfo.Code = -1
-//			this.Data["json"] = &errinfo
-//			this.ServeJSON()
-//			return
-//		} else {
-//			errinfo.Message = "删除冻存盒成功!"
-//			errinfo.Code = 0
-//			this.Data["json"] = &errinfo
-//			this.ServeJSON()
-//		}
-//	}
-//}
-
-//// @Title 删除传感器
-//// @Description 删除传感器
-//// @Param	code		path 	string	true		"需要删除的传感器编号"
-//// @Success 200 {object} ErrorInfo
-//// @Failure 403 :code 为空
-//// @router deletesample/:id [delete]
-//func (this *ShelfSetController) SampleDelete() {
-//	id := this.Ctx.Input.Param(":id")
-//	inputarr := strings.Split(id, ",")
-//	// 初始化服务
-//	var errinfo ErrorInfo
-//	svs := samplesinfo.GetSamplesInfoService(utils.DBE)
-//	//	svc := currboxcapacity.GetCurrboxcapacityService(utils.DBE)
-//	//	svss := shelfset.GetshelfsetService(utils.DBE)
-//	var datamain samplesinfo.SamplesMain
-//	var datadetail samplesinfo.SamplesDetail
-//	//	var testdetail []samplesinfo.SamplesDetail
-//	//	var shelfcap currboxcapacity.CurrBoxCapacity
-//	//	var box []shelfset.Box
-//	where := "SampleCode = '" + inputarr[1] + "'"
-//	svs.GetEntityByWhere(this.User.AccCode+"SamplesMain", where, &datamain)
-//	svs.GetEntityByWhere(this.User.AccCode+"SamplesDetail", where, &datadetail)
-//	// 更改冻存盒颜色
-//	//	svc.GetCurrboxcapacityByShelfid(utils.ToStr(datadetail.ShelfId), &shelfcap)
-//	//	box = svss.GetBoxByid(utils.ToStr(datadetail.BoxId))
-//	//	colname := string(box[0].YStation+64) + utils.ToStr(box[0].XStation)
-//	//	where = "BoxId = " + utils.ToStr(datadetail.BoxId)
-//	//	svs.GetEntitysByWhere(this.User.AccCode+"SamplesDetail", where, &testdetail)
-//	//	where = "ShelfId = " + utils.ToStr(datadetail.ShelfId)
-//	//	if len(testdetail) == 1 {
-//	//		svc.Updata(colname, "-1", where) // 删除最后一个
-//	//	} else {
-//	//		svc.Updata(colname, inputarr[0], where)
-//	//	}
-//	// 删除
-//	err := svs.DelSMainInfo(this.User.AccCode, datamain.MId)
-//	err = svs.DelSDetailInfo(this.User.AccCode, datadetail.Id)
-//	// 错误检测
-//	if err != nil {
-//		errinfo.Message = "添加样本失败!"
-//		errinfo.Code = -2
-//		this.Data["json"] = &errinfo
-//		this.ServeJSON()
-//		return
-//	}
-//}
+// 冻存盒
+type BoxData struct {
+	Shelfbox  shelfset.Shelf
+	Boxshelf  shelfset.Box
+	Boxsample []samplesinfo.SamplesInfoShow
+}
+
+// 回传数据model
+type Output struct {
+	Dimension [2]int      `json:"dimension,omitempty"` //冰箱尺寸
+	Items     interface{} `json:"items,omitempty"`     //数据列表
+}
+
+// 添加样本model
+type SampleModel struct {
+	BarCode          string    `json:"BarCode,omitempty"`          // 样本条码
+	SampleCode       string    `json:"SampleCode,omitempty"`       // 样本编码
+	SampleType       string    `json:"SampleType,omitempty"`       // 样本类型
+	SampleTypeName   string    `json:"SampleTypeName,omitempty"`   // 样本类型
+	Zuzhi            string    `json:"zuzhi,omitempty"`            // 组织器官
+	Zuzhiming        string    `json:"zuzhiming,omitempty"`        // 组织器官
+	SamplingSite     string    `json:"SamplingSite,omitempty"`     // 取材部位
+	SamplingSiteName string    `json:"SamplingSiteName,omitempty"` // 取材部位
+	Name             string    `json:"Name,omitempty"`             // 名称
+	ReceiveDate      time.Time `json:"ReceiveDate,omitempty"`      // 接收日期
+	Capacity         string    `json:"Capacity,omitempty"`         // 可用容量
+	Unit             string    `json:"Unit,omitempty"`             // 单位(容量)
+	ValidityDate     time.Time `json:"ValidityDate,omitempty"`     // 有效日期
+	InnerCode        string    `json:"InnerCode,omitempty"`        // 样本内码
+	SourceName       string    `json:"SourceName,omitempty"`       // 样本来源
+	Remark           string    `json:"Remark,omitempty"`           // 备注
+	PositionStr      string    `json:"PositionStr,omitempty"`      // 位置信息
+}
+
+// 添加冻存盒model
+type BoxModel struct {
+	XBox       int    `json:"xbox,omitempty"`       // 冻存盒x
+	YBox       int    `json:"ybox,omitempty"`       // 冻存盒y
+	XShelf     int    `json:"xshelf,omitempty"`     // 冻存架x
+	YShelf     int    `json:"yshelf,omitempty"`     // 冻存架y
+	SampleType string `json:"sampletype,omitempty"` // 样本类型
+	BarCode    string `json:"barcode,omitempty"`    // 编码
+	Eid        string `json:"eid,omitempty"`        // 设备id
+	Boxxvalue  int    `json:"boxxvalue,omitempty"`  // 冻存盒x大小
+	Boxyvalue  int    `json:"boxyvalue,omitempty"`  // 冻存盒y大小
+}
+
+// @Title 报警项目列表
+// @Description 报警项目列表
+// @Success 200 {object} business.device.DeviceChannels
+// @router /equipmentinfo/:eid [get]
+func (this *ShelfSetController) EquipmentInfo() {
+	eid := this.Ctx.Input.Param(":eid")
+	svc := currboxcapacity.GetCurrboxcapacityService(utils.DBE)
+	data := svc.GetCurrboxcapacityByid(eid)
+	fmt.Println("=========================datattatat:", data)
+	//	dataStyleScheme := svc.GetStyleScheme("1")
+	svcequipment := equipment.GetEquipmentService(utils.DBE)
+	equipmentdata := svcequipment.GetInfoById(eid)
+	map_list := make(map[string]string)
+	sample_type := sampletype.GetSampleTypeService(utils.DBE)
+	where := " AccCode='" + this.User.AccCode + "'"
+	sample_type_list := sample_type.ListSampleType(where)
+	for i := 0; i < len(sample_type_list); i++ {
+		map_list[utils.ToStr(sample_type_list[i].Id)] = sample_type_list[i].Photo
+	}
+	this.Data["entitySampleType"] = sample_type_list
+	this.Data["map_list"] = map_list
+	this.Data["equipmentdata"] = equipmentdata
+	this.Data["equipmentName"] = equipmentdata.Name
+	this.Data["IsLargeSpec"] = equipmentdata.IsLargeSpec
+	this.Data["json"] = &equipmentdata
+	this.ServeJSON()
+}
+
+// @Title 报警项目列表
+// @Description 报警项目列表
+// @Success 200 {object} business.device.DeviceChannels
+// @router /equipmentdraw/:eid [get]
+func (this *ShelfSetController) EquipmentDraw() {
+	// 读取参数和初始化服务
+	eid := this.Ctx.Input.Param(":eid")
+	svc := currboxcapacity.GetCurrboxcapacityService(utils.DBE)
+	// 获取所有相关冻存架信息
+	data := svc.GetCurrboxcapacityByid(eid)
+	// 获取冰箱尺寸
+	sve := equipment.GetEquipmentService(utils.DBE)
+	entity := sve.GetInfoById(eid)
+	// 回传数据
+	var output Output
+	array := [2]int{entity.ColumnNum, entity.RowNum}
+	output.Items = &data
+	output.Dimension = array
+	this.Data["json"] = &output
+	this.ServeJSON()
+}
+
+// @Title 报警项目列表
+// @Description 报警项目列表
+// @Success 200 {object} business.device.DeviceChannels
+// @router /boxdraw/:inputstr [get]
+func (this *ShelfSetController) BoxDraw() {
+	// 读取参数和初始服务
+	var boxdata BoxData
+	inputstr := this.Ctx.Input.Param(":inputstr")
+	serials := strings.Split(inputstr, ",")
+	id := serials[0]
+	x := serials[1]
+	y := serials[2]
+	x_box := serials[3]
+	y_box := serials[4]
+	svs := shelfset.GetshelfsetService(utils.DBE)
+	// 获取选中box
+	svc := currboxcapacity.GetCurrboxcapacityService(utils.DBE)
+	svc.GetBox(&boxdata.Boxshelf, id, x, y, x_box, y_box)
+	boxdata.Boxsample = nil
+	// 获取样本, where语句IState部分未经修改
+	if boxdata.Boxshelf.Id != 0 {
+		where := " IState in (1,5,10,99) and DeletionStateCode=0 and BoxId = " + utils.ToStr(boxdata.Boxshelf.Id)
+		svc1 := samplesinfo.GetSamplesInfoService(utils.DBE)
+		boxdata.Boxsample = svc1.QuerySampleList(this.User.AccCode, where)
+	}
+	// 获取冻存架
+	svs.GetEntityByEquipmentId(id, x, y, &boxdata.Shelfbox)
+	// 回传数据
+	this.Data["json"] = boxdata
+	this.ServeJSON()
+}
+
+// @Title 报警项目列表
+// @Description 报警项目列表
+// @Success 200 {object} business.device.DeviceChannels
+// @router /getorgan [get]
+func (this *ShelfSetController) GetOrgan() {
+	svo := sampleorgan.GetSampleOrganService(utils.DBE)
+	var list []sampleorgan.SampleOrgan
+	where := " AccCode='" + this.User.AccCode + "' and TNodeParent != ''"
+	list = svo.GetEntityListByWhere(where)
+
+	var datainfo DataInfo
+	datainfo.Items = list
+	this.Data["json"] = &datainfo
+	this.ServeJSON()
+}
+
+// @Title 报警项目列表
+// @Description 报警项目列表
+// @Success 200 {object} business.device.DeviceChannels
+// @router /getpos/:inputstr [get]
+func (this *ShelfSetController) GetPosition() {
+	inputstr := this.Ctx.Input.Param(":inputstr")
+	serial := strings.Split(inputstr, "_")
+	for i := 0; i < len(serial); i++ {
+		//		println("sdfasdf=f-======", serial[i])
+	}
+	svs := shelfset.GetshelfsetService(utils.DBE)
+	shelf := svs.GetShelfByid(serial[7])
+	box := svs.GetBoxByid(serial[8])
+
+	posarr := [4]int{shelf[0].XStation, shelf[0].YStation, box[0].XStation, box[0].YStation}
+	var datainfo DataInfo
+	datainfo.Items = posarr
+	this.Data["json"] = &datainfo
+	this.ServeJSON()
+
+}
+
+// @Title 添加冻存盒或冻存架
+// @Description 添加冻存盒或冻存架
+// @Success 200 {object} business.device.DeviceChannels
+// @router / [post]
+func (this *ShelfSetController) AddforEquipment() {
+	// 获得前端传输的model
+	var model BoxModel
+	var jsonblob = this.Ctx.Input.RequestBody
+	json.Unmarshal(jsonblob, &model)
+	serial := strings.Split(model.Eid, "_")
+	// 日志初始化
+	var lastnum lastordernum.LastOrderNum
+	svss := shelfset.GetshelfsetService(utils.DBE)
+	lastdata := svss.GetLastBoxNum(this.User.AccCode)
+	lastnum.LastNum = lastdata
+	// 其他初始化
+	var errinfo ErrorInfo
+	var shelf shelfset.Shelf
+	var box shelfset.Box
+	var shelfcap currboxcapacity.CurrBoxCapacity
+	svc := currboxcapacity.GetCurrboxcapacityService(utils.DBE)
+	if serial[1] == "1" {
+		// 更新日志
+		svss.UpdateBoxNum(lastnum, this.User.AccCode)
+
+		svss.GetEntityByEquipmentId(serial[0], utils.ToStr(model.XShelf), utils.ToStr(model.YShelf), &shelf)
+		box.AccCode = this.User.AccCode
+		box.BarCode = model.BarCode
+		box.ColumnNum = model.Boxyvalue
+		box.RowNum = model.Boxxvalue
+		box.SampleType = model.SampleType
+		box.XStation = model.XBox
+		box.YStation = model.YBox
+		box.EquipmentId, _ = utils.StrTo(serial[0]).Int()
+		box.ShelfId = shelf.Id
+		box.Code = lastdata
+		box.CreateUserId, _ = utils.StrTo(this.User.Id).Int()
+		box.CreateBy = this.User.Realname
+		// 更新冻存盒颜色
+		svc.GetCurrboxcapacityByShelfid(utils.ToStr(shelf.Id), &shelfcap)
+		colname := string(box.YStation+64) + utils.ToStr(box.XStation)
+		where := "AccCode='" + this.User.AccCode + "' and EquipmentId='" + serial[0] + "' and ShelfId ='" + utils.ToStr(shelf.Id) + "'"
+		err := svc.Updata(colname, "-1", where)
+		// 添加冻存盒
+		_, err = svss.InsertEntity(&box)
+		// 错误检测
+		if err != nil {
+			errinfo.Message = "添加冻存盒失败!"
+			errinfo.Code = -2
+			this.Data["json"] = &errinfo
+			this.ServeJSON()
+			return
+		} else {
+			errinfo.Message = "添加冻存盒成功!"
+			errinfo.Code = 0
+			this.Data["json"] = &errinfo
+			this.ServeJSON()
+		}
+	} else {
+		// 更新日志 添加设备
+		svss.UpdateShelfNum(lastnum, this.User.AccCode)
+		shelf.AccCode = this.User.AccCode
+		shelf.EquipmentId, _ = utils.StrTo(serial[0]).Int()
+		shelf.Code = lastdata
+		shelf.BarCode = model.BarCode
+		shelf.CreateBy = this.User.Realname
+		shelf.CreateUserId, _ = utils.StrTo(this.User.Id).Int()
+		shelf.SampleType = model.SampleType
+		shelf.RowNum = model.YBox
+		shelf.ColumnNum = model.XBox
+		shelf.XStation = model.XShelf
+		shelf.YStation = model.YShelf
+		_, err := svss.InsertEntity(&shelf)
+		// 添加冻存盒颜色----currboxcap
+		var colstr string = "AccCode, EquipmentId, ShelfId, RowNum, ColumnNum, XStation, YStation,"
+		var valuestr string = "'" + this.User.AccCode + "'," + serial[0] + "," + utils.ToStr(shelf.Id) + "," + utils.ToStr(shelf.RowNum) + "," + utils.ToStr(shelf.ColumnNum) + "," + utils.ToStr(shelf.XStation) + "," + utils.ToStr(shelf.YStation) + ","
+		for i := 1; i <= shelf.RowNum; i++ {
+			for j := 1; j <= shelf.ColumnNum; j++ {
+				colstr = colstr + string(i+64) + utils.ToStr(j) + ","
+				valuestr = valuestr + "-2,"
+			}
+		}
+		colstr = colstr[:len(colstr)-1]
+		valuestr = valuestr[:len(valuestr)-1]
+		err = svc.Add(colstr, valuestr)
+		// 错误检测
+		if err != nil {
+			errinfo.Message = "添加冻存架失败!"
+			errinfo.Code = -2
+			this.Data["json"] = &errinfo
+			this.ServeJSON()
+			return
+		} else {
+			errinfo.Message = "添加冻存架成功!"
+			errinfo.Code = 0
+			this.Data["json"] = &errinfo
+			this.ServeJSON()
+		}
+	}
+
+}
+
+// @Title 编辑冻存盒或冻存架
+// @Description 编辑冻存盒或冻存架
+// @Success	200	{object} controllers.Request
+// @router /editforequip [put]
+func (this *ShelfSetController) EditforEquipment() {
+	var model BoxModel
+	var jsonblob = this.Ctx.Input.RequestBody
+	json.Unmarshal(jsonblob, &model)
+	fmt.Println("==============modddeelll", model)
+	serial := strings.Split(model.Eid, "_")
+	svc := shelfset.GetshelfsetService(utils.DBE)
+	var errinfo ErrorInfo
+	if serial[1] == "2" {
+		//初始化服务
+		var shelfempty shelfset.Shelf
+		var shelf shelfset.Shelf
+		svc.GetEntityByEquipmentId(serial[0], utils.ToStr(model.XShelf), utils.ToStr(model.YShelf), &shelf)
+		//编辑
+		shelf.ModifiedBy = this.User.Realname
+		shelf.ModifiedUserId, _ = utils.StrTo(this.User.Id).Int()
+		shelf.SampleType = model.SampleType
+		shelf.BarCode = model.BarCode
+		var cols []string = []string{"RowNum", "ColumnNum", "BarCode", "SampleType", "ModifiedUserId", "ModifiedBy"}
+		opdesc := "编辑冻存架-" + shelf.ShelfSpecName + ",第" + utils.ToStr(shelf.YStation) + "行第" + utils.ToStr(shelf.XStation) + "列"
+		err := svc.UpdateEntityAndWriteLog(shelf.Id, &shelf, &shelfempty, cols, utils.ToStr(this.User.Id), this.User.Username, opdesc, this.User.AccCode, "设备管理")
+		// 错误检测
+		if err != nil {
+			errinfo.Message = "编辑冻存架失败!"
+			errinfo.Code = -2
+			this.Data["json"] = &errinfo
+			this.ServeJSON()
+			return
+		} else {
+			errinfo.Message = "编辑冻存架成功!"
+			errinfo.Code = 0
+			this.Data["json"] = &errinfo
+			this.ServeJSON()
+		}
+	} else {
+		var box shelfset.Box
+		var boxempty shelfset.Box
+		svc.GetEntityByShelfIdXY(serial[2], utils.ToStr(model.XBox), utils.ToStr(model.YBox), &box)
+		box.ColumnNum = model.Boxyvalue
+		box.RowNum = model.Boxxvalue
+		box.ModifiedBy = this.User.Realname
+		box.ModifiedUserId, _ = utils.StrTo(this.User.Id).Int()
+		box.SampleType = model.SampleType
+		box.BarCode = model.BarCode
+		var cols []string = []string{"RowNum", "ColumnNum", "BarCode", "SampleType", "ModifiedUserId", "ModifiedBy"}
+		opdesc := "编辑冻存盒-" + box.Code + ",冻存架第" + serial[4] + "行第" + serial[3] + "列,冻存盒第" + utils.ToStr(box.YStation) + "行第" + utils.ToStr(box.XStation) + "列"
+		err := svc.UpdateEntityAndWriteLog(box.Id, &box, &boxempty, cols, utils.ToStr(this.User.Id), this.User.Username, opdesc, this.User.AccCode, "设备管理")
+		// 错误检测
+		if err != nil {
+			errinfo.Message = "编辑冻存盒失败!"
+			errinfo.Code = -2
+			this.Data["json"] = &errinfo
+			this.ServeJSON()
+			return
+		} else {
+			errinfo.Message = "编辑冻存盒成功!"
+			errinfo.Code = 0
+			this.Data["json"] = &errinfo
+			this.ServeJSON()
+		}
+	}
+
+}
+
+// @Title 冻存架移动
+// @Description 检测样本类型是否匹配和冻存架移动,分两个方法
+// @Success	200	{object} controllers.Request
+// @router /shelfmove/:inputstr [put]
+func (this *ShelfSetController) BeforeMoveShelf() {
+	inputstr := this.Ctx.Input.Param(":inputstr")
+	println("===ssss=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-", inputstr)
+	serial := strings.Split(inputstr, "_")
+	var errinfo ErrorInfo
+	var entity equipment.Equipment
+	var shelf shelfset.Shelf
+	sve := equipment.GetEquipmentService(utils.DBE)
+	svs := shelfset.GetshelfsetService(utils.DBE)
+	where := "Id = " + serial[0]
+	sve.GetEntity(&entity, where)
+	println("ccc-=====================", entity.SampleType)
+	seriale := strings.Split(entity.SampleType, ",")
+	svs.GetEntityByEquipmentId(serial[1], serial[2], serial[3], &shelf)
+	println("xxx-=====================", shelf.SampleType)
+	serials := strings.Split(shelf.SampleType, ",")
+	var exist = false
+	for i := 0; i < len(serials); i++ {
+		for j := 0; j < len(seriale); j++ {
+			if serials[i] == seriale[j] {
+				exist = true
+			}
+		}
+		if !exist {
+			errinfo.Message = "存在不支持的样本类型!"
+			errinfo.Code = -1
+			this.Data["json"] = &errinfo
+			this.ServeJSON()
+			return
+		}
+		exist = false
+	}
+	this.MoveforShelf(utils.ToStr(shelf.Id))
+}
+
+func (this *ShelfSetController) MoveforShelf(shelfid string) {
+	inputstr := this.Ctx.Input.Param(":inputstr")
+	println("===ssss=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-", inputstr)
+	serial := strings.Split(inputstr, "_")
+	var errinfo ErrorInfo
+	var shelf shelfset.Shelf
+	var shelfempty shelfset.Shelf
+	// shelf
+	// equipmentid := serial[1]
+	svc := shelfset.GetshelfsetService(utils.DBE)
+	shelf.EquipmentId, _ = utils.StrTo(serial[0]).Int()
+	shelf.XStation, _ = utils.StrTo(serial[4]).Int()
+	shelf.YStation, _ = utils.StrTo(serial[5]).Int()
+	shelf.ModifiedBy = this.User.Realname
+	shelf.ModifiedUserId, _ = utils.StrTo(this.User.Id).Int()
+	var cols []string = []string{"EquipmentId", "XStation", "YStation", "ModifiedUserId", "ModifiedBy"}
+	opdesc := "移动冻存架-原位置:" + serial[1] + ",第" + serial[3] + "行第" + serial[2] + "列"
+	svc.UpdateEntityAndWriteLog(shelfid, &shelf, &shelfempty, cols, utils.ToStr(this.User.Id), this.User.Username, opdesc, this.User.AccCode, "设备管理")
+	// 冻存盒颜色
+	var currboxcapacitys currboxcapacity.CurrBoxCapacity
+	svc1 := currboxcapacity.GetCurrboxcapacityService(utils.DBE)
+	currboxcapacitys.EquipmentId, _ = utils.StrTo(serial[0]).Int()
+	currboxcapacitys.ShelfId, _ = utils.StrTo(shelfid).Int()
+	currboxcapacitys.XStation, _ = utils.StrTo(serial[4]).Int()
+	currboxcapacitys.YStation, _ = utils.StrTo(serial[5]).Int()
+	where1 := "  AccCode='" + this.User.AccCode + "' and ShelfId=" + shelfid
+	svc1.UpdateEntityByWhere(where1, &currboxcapacitys)
+	// 冻存盒
+	var boxempty shelfset.Box
+	var colss []string = []string{"EquipmentId", "ModifiedUserId", "ModifiedBy"}
+	boxempty.EquipmentId, _ = utils.StrTo(serial[0]).Int()
+	boxempty.ModifiedBy = this.User.Realname
+	boxempty.ModifiedUserId, _ = utils.StrTo(this.User.Id).Int()
+	where := "  AccCode='" + this.User.AccCode + "' and ShelfId=" + shelfid
+	svc.UpdateEntityColsByWhere(&boxempty, where, colss)
+	// 样本---isAddFNum是否记录冻融次数
+	tblDetai := this.User.AccCode + SamplesDetailtbName
+	sql := ""
+	if serial[6] == "true" {
+		sql = "update " + tblDetai + " set EquipmentId=" + serial[0] + ",FreezingNum=FreezingNum+1 where ShelfId=" + shelfid + " and DeletionStateCode=0 and IState in (1,5)"
+	} else {
+		sql = "update " + tblDetai + " set EquipmentId=" + serial[0] + " where ShelfId=" + shelfid + " and DeletionStateCode=0 and IState in (1,5)"
+	}
+	svc.SqlMethod(sql)
+	// 样本
+	var SamplesData []samplesinfo.SamplesInfoShow
+	where = " DeletionStateCode=0 and EquipmentId=" + serial[0] + " and ShelfId=" + shelfid + " and IState in (1,5)"
+	svcSample := samplesinfo.GetSamplesInfoService(utils.DBE)
+	SamplesData = svcSample.QuerySampleList(this.User.AccCode, where)
+
+	svcequipment := equipment.GetEquipmentService(utils.DBE)
+	newequipmententity := svcequipment.GetInfoById(serial[0])
+	newpositon := "-新位置:" + newequipmententity.Name + ",第" + serial[5] + "行第" + serial[4] + "列"
+	//业务记录
+	for i := 0; i < len(SamplesData); i++ {
+		var databuss samplesbusiness.SamplesBusiness
+		databuss.AccCode = this.User.AccCode
+		databuss.OpType = 41
+		databuss.SampleCode = SamplesData[i].SampleCode
+		databuss.BarCode = SamplesData[i].BarCode
+		databuss.SampleType = SamplesData[i].SampleType
+		databuss.CapacityUsed = SamplesData[i].Capacity
+		databuss.CapacityRest = SamplesData[i].Capacity
+		databuss.Unit = SamplesData[i].Unit
+		databuss.EquipmentId = SamplesData[i].EquipmentId
+		databuss.ShelfId = SamplesData[i].ShelfId
+		databuss.BoxId = SamplesData[i].BoxId
+		databuss.Position = SamplesData[i].Position
+		databuss.PositionDesc = svcSample.GetPostiondescByPosId(databuss.EquipmentId, databuss.ShelfId, databuss.BoxId, databuss.Position)
+
+		databuss.CreateUserId, _ = utils.StrTo(this.User.Id).Int()
+		databuss.CreateBy = this.User.Realname
+		databuss.OpDesc = opdesc + "-" + newpositon
+		svcSample.InsertEntityBytbl(this.User.AccCode+SamplesBusstbName, &databuss)
+	}
+	errinfo.Message = "成功"
+	errinfo.Code = 0
+	this.Data["json"] = &errinfo
+	this.ServeJSON()
+	return
+}
+
+// @Title 冻存盒移动
+// @Description 检测样本类型是否匹配和冻存盒移动,分两个方法
+// @Success	200	{object} controllers.Request
+// @router /boxmove/:inputstr [put]
+func (this *ShelfSetController) BeforeMoveBox() {
+	inputstr := this.Ctx.Input.Param(":inputstr")
+	serial := strings.Split(inputstr, "_")
+	var errinfo ErrorInfo
+	var entity equipment.Equipment
+	var shelf shelfset.Shelf
+	var box shelfset.Box
+	sve := equipment.GetEquipmentService(utils.DBE)
+	svs := shelfset.GetshelfsetService(utils.DBE)
+	where := "Id = " + serial[0]
+	sve.GetEntity(&entity, where)
+	println("eee-=====================", entity.SampleType)
+	seriale := strings.Split(entity.SampleType, ",")
+	svs.GetEntityByEquipmentId(serial[1], serial[7], serial[8], &shelf)
+	svs.GetEntityByShelfIdXY(utils.ToStr(shelf.Id), serial[2], serial[3], &box)
+	println("bbb-=====================", box.SampleType)
+	serialb := strings.Split(box.SampleType, ",")
+	var exist = false
+	for i := 0; i < len(serialb); i++ {
+		for j := 0; j < len(seriale); j++ {
+			if serialb[i] == seriale[j] {
+				exist = true
+			}
+		}
+		if !exist {
+			errinfo.Message = "存在不支持的样本类型!"
+			errinfo.Code = -1
+			this.Data["json"] = &errinfo
+			this.ServeJSON()
+			return
+		}
+		exist = false
+	}
+	this.MoveforBox(utils.ToStr(box.Id), utils.ToStr(shelf.Id))
+}
+
+func (this *ShelfSetController) MoveforBox(boxid string, shelfoldid string) {
+	inputstr := this.Ctx.Input.Param(":inputstr")
+	println("===ss-=-=-=-=-=-=-=-", inputstr)
+	serial := strings.Split(inputstr, "_")
+	var box shelfset.Box
+	var boxempty shelfset.Box
+	var shelf shelfset.Shelf
+	var errinfo ErrorInfo
+	//equipmentid := this.GetString("equipmentid")
+	svc := shelfset.GetshelfsetService(utils.DBE)
+	svc.GetEntityByEquipmentId(serial[0], serial[9], serial[10], &shelf)
+	// 冻存盒
+	box.EquipmentId, _ = utils.StrTo(serial[0]).Int()
+	box.ShelfId = shelf.Id
+	box.XStation, _ = utils.StrTo(serial[4]).Int()
+	box.YStation, _ = utils.StrTo(serial[5]).Int()
+	box.ModifiedBy = this.User.Realname
+	box.ModifiedUserId, _ = utils.StrTo(this.User.Id).Int()
+	var cols []string = []string{"EquipmentId", "ShelfId", "XStation", "YStation", "ModifiedUserId", "ModifiedBy"}
+	opdesc := "移动冻存盒-原位置:" + serial[1] + ",冻存架第" + serial[8] + "行第" + serial[7] + "列,冻存盒第" + serial[3] + "行第" + serial[2] + "列"
+	svc.UpdateEntityAndWriteLog(boxid, &box, &boxempty, cols, utils.ToStr(this.User.Id), this.User.Username, opdesc, this.User.AccCode, "设备管理")
+	// 冻存盒颜色
+	svc1 := currboxcapacity.GetCurrboxcapacityService(utils.DBE)
+	ystaion, _ := utils.StrTo(serial[3]).Int()
+	charname := Boxlinename(ystaion)
+	sqlfield := fmt.Sprintf("%v%v", charname, serial[2])
+	where := " EquipmentId='" + serial[1] + "' and ShelfId ='" + shelfoldid + "'"
+	svc1.Updata(sqlfield, "-2", where)
+	ystaion1, _ := utils.StrTo(serial[5]).Int()
+	charname1 := Boxlinename(ystaion1)
+	sqlfield1 := fmt.Sprintf("%v%v", charname1, serial[4])
+	where1 := " EquipmentId='" + serial[0] + "' and ShelfId ='" + utils.ToStr(shelf.Id) + "'"
+	svc1.Updata(sqlfield1, "-1", where1)
+	// 样本----冻融记录
+	tblDetai := this.User.AccCode + SamplesDetailtbName
+	sql := ""
+	if serial[6] == "true" {
+		sql = "update " + tblDetai + " set EquipmentId=" + serial[0] + ",ShelfId=" + utils.ToStr(shelf.Id) + ",FreezingNum=FreezingNum+1 where BoxId=" + boxid + " and DeletionStateCode=0 and IState in (1,5) "
+	} else {
+		sql = "update " + tblDetai + " set EquipmentId=" + serial[0] + ",ShelfId=" + utils.ToStr(shelf.Id) + " where BoxId=" + boxid + " and DeletionStateCode=0 and IState in (1,5) "
+	}
+	svc.SqlMethod(sql)
+	// 样本
+	var SamplesData []samplesinfo.SamplesInfoShow
+	where = " DeletionStateCode=0 and EquipmentId=" + serial[0] + " and ShelfId=" + utils.ToStr(shelf.Id) + " and BoxId=" + boxid + " and IState in (1,5) "
+	svcSample := samplesinfo.GetSamplesInfoService(utils.DBE)
+	SamplesData = svcSample.QuerySampleList(this.User.AccCode, where)
+	svcequipment := equipment.GetEquipmentService(utils.DBE)
+	newequipmententity := svcequipment.GetInfoById(serial[0])
+	newpositon := "新位置:" + newequipmententity.Name + ",冻存架第" + serial[10] + "行第" + serial[9] + "列,冻存盒第" + serial[5] + "行第" + serial[4] + "列"
+	for i := 0; i < len(SamplesData); i++ {
+		var databuss samplesbusiness.SamplesBusiness //业务记录
+		databuss.AccCode = this.User.AccCode
+		databuss.OpType = 41
+		databuss.SampleCode = SamplesData[i].SampleCode
+		databuss.BarCode = SamplesData[i].BarCode
+		databuss.SampleType = SamplesData[i].SampleType
+		databuss.CapacityUsed = SamplesData[i].Capacity
+		databuss.CapacityRest = SamplesData[i].Capacity
+		databuss.Unit = SamplesData[i].Unit
+		databuss.EquipmentId = SamplesData[i].EquipmentId
+		databuss.ShelfId = SamplesData[i].ShelfId
+		databuss.BoxId = SamplesData[i].BoxId
+		databuss.Position = SamplesData[i].Position
+		databuss.PositionDesc = svcSample.GetPostiondescByPosId(databuss.EquipmentId, databuss.ShelfId, databuss.BoxId, databuss.Position)
+
+		databuss.CreateUserId, _ = utils.StrTo(this.User.Id).Int()
+		databuss.CreateBy = this.User.Realname
+		databuss.OpDesc = opdesc + "-" + newpositon
+		svcSample.InsertEntityBytbl(this.User.AccCode+SamplesBusstbName, &databuss)
+	}
+	errinfo.Message = "成功"
+	errinfo.Code = 0
+	this.Data["json"] = &errinfo
+	this.ServeJSON()
+	return
+}
+
+// @Title 冻存架复制
+// @Description 冻存架复制
+// @Success	200	{object} controllers.Request
+// @router /shelfcopy/:inputstr [put]
+func (this *ShelfSetController) CopyforShelf() {
+	inputstr := this.Ctx.Input.Param(":inputstr")
+	serial := strings.Split(inputstr, "_")
+	for i := 0; i < len(serial); i++ {
+		println("sdfasdf=f-======", serial[i])
+	}
+	var shelf shelfset.Shelf
+	var box_model []shelfset.Box
+	shelf_model := new(shelfset.Shelf)
+	id := serial[0]
+	data1 := serial[1]
+	data2 := strings.Split(data1, ",")
+	copybox := serial[2]
+	svc := shelfset.GetshelfsetService(utils.DBE)
+	svc.GetEntityByEquipmentId(id, serial[3], serial[4], shelf_model)
+	lastdata := svc.GetLastShelfNum(this.User.AccCode)
+	num_lastdata, _ := utils.StrTo(lastdata[1:]).Int64()
+	for i := 0; i < len(data2); i++ {
+		shelf.AccCode = this.User.AccCode
+		shelf.EquipmentId = shelf_model.EquipmentId
+		shelf.Code = "F" + utils.ToStr(num_lastdata)
+		shelf.ShelfSpecName = shelf_model.ShelfSpecName
+		station := strings.Split(utils.ToStr(data2[i]), ";")
+		fmt.Println(station)
+		shelf.XStation, _ = utils.StrTo(station[0]).Int()
+		shelf.YStation, _ = utils.StrTo(station[1]).Int()
+		shelf.BarCode = "F" + utils.ToStr(num_lastdata)
+		shelf.RowNum = shelf_model.RowNum
+		shelf.ColumnNum = shelf_model.ColumnNum
+		shelf.SampleType = shelf_model.SampleType
+		shelf.CreateUserId, _ = utils.StrTo(this.User.Id).Int()
+		shelf.CreateBy = this.User.Realname
+		num_lastdata = num_lastdata + 1
+		svc.InsertEntity(&shelf)
+		svc1 := currboxcapacity.GetCurrboxcapacityService(utils.DBE)
+		if copybox == "true" {
+			where := "ShelfId=" + utils.ToStr(shelf_model.Id)
+			box_model = svc.BoxListByid(where)
+			lastdata_box := svc.GetLastBoxNum(this.User.AccCode)
+			num_lastdata_box, _ := utils.StrTo(lastdata_box[1:]).Int64()
+			for i := 0; i < len(box_model); i++ {
+				box_model[i].Code = "B" + utils.ToStr(num_lastdata_box)
+				box_model[i].BarCode = "B" + utils.ToStr(num_lastdata_box)
+				box_model[i].ShelfId = shelf.Id
+				box_model[i].CreateBy = this.User.Realname
+				box_model[i].CreateUserId, _ = utils.StrTo(this.User.Id).Int()
+				num_lastdata_box = num_lastdata_box + 1
+				svc.InsertEntity(&box_model[i])
+			}
+			num_lastdata_box = num_lastdata_box - 1
+			var lastnum lastordernum.LastOrderNum
+			lastnum.LastNum = "B" + utils.ToStr(num_lastdata_box)
+			svc.UpdateBoxNum(lastnum, this.User.AccCode)
+			svc1.RangeCurrboxcapacityByShelfid(utils.ToStr(shelf_model.Id), utils.ToStr(shelf.Id), utils.ToStr(shelf.XStation), utils.ToStr(shelf.YStation))
+		} else {
+			sqlfield := "AccCode,EquipmentId,ShelfId,XStation,YStation,RowNum,ColumnNum,"
+			sqlvalue := "'" + this.User.AccCode + "'," + utils.ToStr(shelf.EquipmentId) + "," + utils.ToStr(shelf.Id) + "," + utils.ToStr(shelf.XStation) + "," + utils.ToStr(shelf.YStation) + "," + utils.ToStr(shelf.RowNum) + "," + utils.ToStr(shelf.ColumnNum) + ","
+			i, j := shelf.RowNum, shelf.ColumnNum
+			for e := 0; e < i; e++ {
+				charname := Boxlinename(e + 1)
+				for f := 0; f < j; f++ {
+					fieldname := fmt.Sprintf("%v%v", charname, f+1)
+					if f == j-1 && e == i-1 {
+						sqlfield += fieldname
+						sqlvalue += "-2"
+					} else {
+						sqlfield += fieldname + ","
+						sqlvalue += "-2,"
+					}
+				}
+			}
+			svc1.Add(sqlfield, sqlvalue)
+		}
+	}
+	num_lastdata = num_lastdata - 1
+	var lastnum_shelf lastordernum.LastOrderNum
+	lastnum_shelf.LastNum = "F" + utils.ToStr(num_lastdata)
+	svc.UpdateShelfNum(lastnum_shelf, this.User.AccCode)
+
+	var errinfo ErrorInfo
+	errinfo.Message = "复制冻存架成功!"
+	errinfo.Code = 0
+	this.Data["json"] = &errinfo
+	this.ServeJSON()
+}
+
+// @Title 冻存架复制
+// @Description 冻存架复制
+// @Success	200	{object} controllers.Request
+// @router /boxcopy/:inputstr [put]
+func (this *ShelfSetController) CopyforBox() {
+	inputstr := this.Ctx.Input.Param(":inputstr")
+	serial := strings.Split(inputstr, "_")
+	for i := 0; i < len(serial); i++ {
+		println("sdfasdf=f-======", serial[i])
+	}
+	var shelf shelfset.Shelf
+	box_model := new(shelfset.Box)
+	var box shelfset.Box
+	var sqlfield_str string
+	//var fieldValue string
+	id := serial[0]
+	data1 := serial[5]
+	data2 := strings.Split(data1, ",")
+	svc := shelfset.GetshelfsetService(utils.DBE)
+	svc.GetEntityByEquipmentId(id, serial[1], serial[2], &shelf)
+	svc.GetEntityByShelfIdXY(utils.ToStr(shelf.Id), serial[3], serial[4], box_model)
+	lastdata_box := svc.GetLastBoxNum(this.User.AccCode)
+	num_lastdata_box, _ := utils.StrTo(lastdata_box[1:]).Int64()
+	for i := 0; i < len(data2); i++ {
+		box.AccCode = this.User.AccCode
+		box.EquipmentId = box_model.EquipmentId
+		box.ShelfId = box_model.ShelfId
+		box.Code = "B" + utils.ToStr(num_lastdata_box)
+		station := strings.Split(utils.ToStr(data2[i]), ";")
+		fmt.Println(station)
+		box.XStation, _ = utils.StrTo(station[0]).Int()
+		box.YStation, _ = utils.StrTo(station[1]).Int()
+		box.BarCode = "B" + utils.ToStr(num_lastdata_box)
+		box.RowNum = box_model.RowNum
+		box.ColumnNum = box_model.ColumnNum
+		box.SampleType = box_model.SampleType
+		box.CreateUserId, _ = utils.StrTo(this.User.Id).Int()
+		box.CreateBy = this.User.Realname
+		num_lastdata_box = num_lastdata_box + 1
+		svc.InsertEntity(&box)
+		charname := Boxlinename(box.YStation)
+		sqlfield := fmt.Sprintf("%v%v", charname, box.XStation)
+		if i == len(data2)-1 {
+			sqlfield_str += sqlfield + "=-1 "
+			//fieldValue+="-1"
+		} else {
+			//sqlfield_str+=sqlfield+","
+			//fieldValue+="-1,"
+			sqlfield_str += sqlfield + "=-1,"
+		}
+
+	}
+	num_lastdata_box = num_lastdata_box - 1
+	var lastnum lastordernum.LastOrderNum
+	lastnum.LastNum = "B" + utils.ToStr(num_lastdata_box)
+	svc.UpdateBoxNum(lastnum, this.User.AccCode)
+	svc1 := currboxcapacity.GetCurrboxcapacityService(utils.DBE)
+	where := "AccCode='" + this.User.AccCode + "' and EquipmentId='" + serial[0] + "' and ShelfId ='" + utils.ToStr(shelf.Id) + "'"
+	svc1.UpdataCopyTo(sqlfield_str, where)
+
+	var errinfo ErrorInfo
+	errinfo.Message = "复制冻存盒成功!"
+	errinfo.Code = 0
+	this.Data["json"] = &errinfo
+	this.ServeJSON()
+}
+
+// @Title 删除冻存盒或冻存架
+// @Description 删除冻存盒或冻存架
+// @Param	code		path 	string	true
+// @Success 200 {object} ErrorInfo
+// @Failure 403 :code 为空
+// @router deleteforequip/:inputstr [delete]
+func (this *ShelfSetController) DeleteforEquipment() {
+	inputstr := this.Ctx.Input.Param(":inputstr")
+	serial := strings.Split(inputstr, "_")
+	println("===ssss=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-", serial[0])
+	println("===ssss=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-", serial[1])
+	println("===ssss=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-", serial[2])
+	println("===ssss=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-", serial[3])
+	var errinfo ErrorInfo
+	var shelf shelfset.Shelf
+	svc1 := currboxcapacity.GetCurrboxcapacityService(utils.DBE)
+	svc := shelfset.GetshelfsetService(utils.DBE)
+
+	if serial[0] == "0" {
+		var shelfempty shelfset.Shelf
+		svc.GetEntityByEquipmentId(serial[3], serial[1], serial[2], &shelf)
+		var currboxcapacitys currboxcapacity.CurrBoxCapacity
+		err := svc1.DeleteCurrbox(currboxcapacitys, utils.ToStr(shelf.Id))
+		// 删除冻存盒
+		where_box := "ShelfId =" + utils.ToStr(shelf.Id)
+		box_list := svc.BoxListByid(where_box)
+		for i := 0; i < len(box_list); i++ {
+			var boxempty shelfset.Box
+			opdesc := "删除冻存盒-" + utils.ToStr(box_list[i].Code) + ",冻存架第" + serial[2] + "行第" + serial[1] + "列,冻存盒第" + utils.ToStr(box_list[i].YStation) + "行第" + utils.ToStr(box_list[i].XStation) + "列"
+			err = svc.DeleteEntityAndWriteLog(box_list[i].Id, &box_list[i], &boxempty, utils.ToStr(this.User.Id), this.User.Username, opdesc, this.User.AccCode, "设备管理")
+		}
+		opdesc := "删除冻存架-" + utils.ToStr(shelf.Id) + ",第" + serial[2] + "行第" + serial[1] + "列"
+		err = svc.DeleteEntityAndWriteLog(shelf.Id, &shelf, &shelfempty, utils.ToStr(this.User.Id), this.User.Username, opdesc, this.User.AccCode, "设备管理")
+		// 错误检测
+		if err != nil {
+			errinfo.Message = "删除冻存架失败!"
+			errinfo.Code = -1
+			this.Data["json"] = &errinfo
+			this.ServeJSON()
+			return
+		} else {
+			errinfo.Message = "删除冻存架成功!"
+			errinfo.Code = 0
+			this.Data["json"] = &errinfo
+			this.ServeJSON()
+		}
+	} else {
+		var box shelfset.Box
+		var boxempty shelfset.Box
+		svc.GetEntityByEquipmentId(serial[3], serial[4], serial[5], &shelf)
+		// 更新颜色
+		x, _ := utils.StrTo(serial[2]).Int()
+		colname := string(x+64) + serial[1]
+		where := "AccCode='" + this.User.AccCode + "' and EquipmentId='" + serial[3] + "' and ShelfId ='" + utils.ToStr(shelf.Id) + "'"
+		err := svc1.Updata(colname, "-2", where)
+		svc.GetBoxBoolByXY(utils.ToStr(shelf.Id), serial[1], serial[2], &box)
+		opdesc := "删除冻存盒-" + box.Code + ",冻存架第" + utils.ToStr(shelf.YStation) + "行第" + utils.ToStr(shelf.XStation) + "列,冻存盒第" + utils.ToStr(box.YStation) + "行第" + utils.ToStr(box.XStation) + "列"
+		err = svc.DeleteEntityAndWriteLog(box.Id, &box, &boxempty, utils.ToStr(this.User.Id), this.User.Username, opdesc, this.User.AccCode, "设备管理")
+		// 错误检测
+		if err != nil {
+			errinfo.Message = "删除冻存盒失败!"
+			errinfo.Code = -1
+			this.Data["json"] = &errinfo
+			this.ServeJSON()
+			return
+		} else {
+			errinfo.Message = "删除冻存盒成功!"
+			errinfo.Code = 0
+			this.Data["json"] = &errinfo
+			this.ServeJSON()
+		}
+	}
+}
+
+// @Title 删除传感器
+// @Description 删除传感器
+// @Param	code		path 	string	true		"需要删除的传感器编号"
+// @Success 200 {object} ErrorInfo
+// @Failure 403 :code 为空
+// @router deletesample/:id [delete]
+func (this *ShelfSetController) SampleDelete() {
+	id := this.Ctx.Input.Param(":id")
+	inputarr := strings.Split(id, ",")
+	// 初始化服务
+	var errinfo ErrorInfo
+	svs := samplesinfo.GetSamplesInfoService(utils.DBE)
+	//	svc := currboxcapacity.GetCurrboxcapacityService(utils.DBE)
+	//	svss := shelfset.GetshelfsetService(utils.DBE)
+	var datamain samplesinfo.SamplesMain
+	var datadetail samplesinfo.SamplesDetail
+	//	var testdetail []samplesinfo.SamplesDetail
+	//	var shelfcap currboxcapacity.CurrBoxCapacity
+	//	var box []shelfset.Box
+	where := "SampleCode = '" + inputarr[1] + "'"
+	svs.GetEntityByWhere(this.User.AccCode+"SamplesMain", where, &datamain)
+	svs.GetEntityByWhere(this.User.AccCode+"SamplesDetail", where, &datadetail)
+	// 更改冻存盒颜色
+	//	svc.GetCurrboxcapacityByShelfid(utils.ToStr(datadetail.ShelfId), &shelfcap)
+	//	box = svss.GetBoxByid(utils.ToStr(datadetail.BoxId))
+	//	colname := string(box[0].YStation+64) + utils.ToStr(box[0].XStation)
+	//	where = "BoxId = " + utils.ToStr(datadetail.BoxId)
+	//	svs.GetEntitysByWhere(this.User.AccCode+"SamplesDetail", where, &testdetail)
+	//	where = "ShelfId = " + utils.ToStr(datadetail.ShelfId)
+	//	if len(testdetail) == 1 {
+	//		svc.Updata(colname, "-1", where) // 删除最后一个
+	//	} else {
+	//		svc.Updata(colname, inputarr[0], where)
+	//	}
+	// 删除
+	err := svs.DelSMainInfo(this.User.AccCode, datamain.MId)
+	err = svs.DelSDetailInfo(this.User.AccCode, datadetail.Id)
+	// 错误检测
+	if err != nil {
+		errinfo.Message = "添加样本失败!"
+		errinfo.Code = -2
+		this.Data["json"] = &errinfo
+		this.ServeJSON()
+		return
+	}
+}

+ 19 - 17
src/dashoo.cn/backend/api/controllers/family/familyman.go

@@ -2,7 +2,7 @@ package family
 
 import (
 	"encoding/json"
-	"fmt"
+	//"fmt"
 
 	"dashoo.cn/backend/api/business/donorsinfo"
 	"dashoo.cn/backend/api/business/familyman"
@@ -35,7 +35,6 @@ func (this *FamilymanController) List() {
 	}
 	total, familymanlist := svc.GetPagingEntitiesWithOrderSearch(page.CurrentPage, page.Size, "a.Id desc", where)
 
-	fmt.Println("------------------------------aaa1", total)
 	var datainfo DataInfo
 	datainfo.Items = familymanlist
 	datainfo.CurrentItemCount = total
@@ -49,17 +48,12 @@ func (this *FamilymanController) List() {
 // @router /getdonorsmodel/:id [get]
 func (this *FamilymanController) GetdonorsModel() {
 	//	id := this.GetString("id")
-	id := this.Ctx.Input.Param(":id")
+	//	id := this.Ctx.Input.Param(":id")
 	var familydonors donorsinfo.DonorsInfo
-	svc := donorsinfo.GetDonorsInfoService(utils.DBE)
-	//	svc.GetEntityById(id, &familydonors) //修改时获取列表
+	//	svc := donorsinfo.GetDonorsInfoService(utils.DBE)
 	this.Data["entity"] = familydonors
-	fmt.Println("ssssb11111", svc)
-	fmt.Println("prprprprprrrr111111r", id)
-	fmt.Println("prprprprprrrrr1111111111", familydonors)
 	this.Data["json"] = &familydonors
 	this.ServeJSON()
-	//	this.TplNames = "admin/familyman/edit.tpl" // 页面模板文件
 }
 
 // @Title 报警项目列表
@@ -73,11 +67,8 @@ func (this *FamilymanController) GetModel() {
 	svc := familyman.GetFamilyManService(utils.DBE)
 	svc.GetEntityById(id, &familymanentity) //修改时获取列表
 	this.Data["entity"] = familymanentity
-	fmt.Println("prprprprprrrrr", id)
-	fmt.Println("prprprprprrrrr", familymanentity)
 	this.Data["json"] = &familymanentity
 	this.ServeJSON()
-	//	this.TplNames = "admin/familyman/edit.tpl" // 页面模板文件
 }
 
 // @Title 创建家系
@@ -244,18 +235,29 @@ func (this *FamilymanController) GetPublicSampletypeData() {
 	var list []donorsinfo.DonorsInfo
 	page := this.GetPageInfoForm()
 
-	cardid := this.GetString("cardid")
-	fmt.Println("-----------------------------yangben list", cardid, page)
+	//	cardid := this.GetString("cardid")
 	svc := donorsinfo.GetDonorsInfoService(utils.DBE)
 
 	where := " 1=1 "
-	fmt.Println("TTTTTTTTTongkudexinYang")
 	total := svc.GetPagingEntitiesWithOrderBytbl(this.User.AccCode, page.CurrentPage, page.Size, "Id", false, &list, where)
-	datas := svc.QueryDonorsList(this.User.AccCode+DonorstbName, where)
-	fmt.Println("=============================a", datas)
+	//	datas := svc.QueryDonorsList(this.User.AccCode+DonorstbName, where)
 	var datainfo DataInfo
 	datainfo.Items = list
 	datainfo.CurrentItemCount = total
 	this.Data["json"] = &datainfo
 	this.ServeJSON()
 }
+
+// @Title 获取家庭关系
+// @Description 获取家庭关系
+// @Success	200	{object} controllers.Request
+// @router /familydetaillist/:id [get]
+func (this *FamilymanController) Familydetaillist() {
+	id := this.Ctx.Input.Param(":id")
+	svcfamily := familyman.GetFamilyManService(utils.DBE)
+	List := svcfamily.GetFamilyDetailList(this.User.AccCode, id)
+	var datainfo DataInfo
+	datainfo.Items = List
+	this.Data["json"] = &datainfo
+	this.ServeJSON()
+}

+ 6 - 7
src/dashoo.cn/backend/api/controllers/reports.go

@@ -868,14 +868,14 @@ func (this *ReportsController) SamplesDetailList() {
 	where := " 1=1 and a.DeletionStateCode=0 "
 	CreateDate := this.GetString("CreateDate")
 	SourceId := this.GetString("SourceId")
-	GroupDetailId := this.GetString("GroupDetailId")
+	GroupId := this.GetString("GroupId")
 	SampleTypeId := this.GetString("SampleTypeId")
 	Name := this.GetString("Name")
 	if SourceId != "" {
 		where = where + " and b.SourceId=" + SourceId
 	}
-	if GroupDetailId != "" {
-		where = where + " and g.Id=" + GroupDetailId
+	if GroupId != "" {
+		where = where + " and g.Id=" + GroupId
 	}
 	if SampleTypeId != "" {
 		where = where + " and b.SampleType=" + SampleTypeId
@@ -893,7 +893,6 @@ func (this *ReportsController) SamplesDetailList() {
 	}
 	var lists []reports.SamplesDetail
 	svc := reports.GetReportService(utils.DBE)
-	// this.User.AccCode, page.CurrentPage, page.Size, "Id desc", where
 	total, lists := svc.GetSampleDetailt(this.User.AccCode, page.CurrentPage, page.Size, "BarCode", where)
 	var datainfo DataInfo
 	datainfo.Items = lists
@@ -915,13 +914,13 @@ func (this *ReportsController) SampleStoredList() {
 	EId := this.GetString("EId")
 	Name := this.GetString("Name")
 	if SampleType != "" {
-		where = where + " and  b.SampleType = " + SampleType + ""
+		where = where + " and  b.SampleType = '" + SampleType + "'"
 	}
 	if EId != "" {
-		where = where + " and  f.Id = " + EId + ""
+		where = where + " and  f.Id = '" + EId + "'"
 	}
 	if Name != "" {
-		where = where + " and  b.Name = " + Name + ""
+		where = where + " and  b.Name = '" + Name + "'"
 	}
 	if CreateDate != "" {
 		dates := strings.Split(CreateDate, ",")

+ 0 - 4
src/dashoo.cn/backend/api/controllers/setting/items.go

@@ -30,13 +30,9 @@ func (this *ItemsController) List() {
 	}
 	total := svc.GetPagingEntitiesWithOrder(page.CurrentPage, page.Size, "SortCode", true, &entities, where)
 
-	//	this.SetPaginator(ItemsPerPage, total)
-	//	this.Data["json"] = &entities
-	//	this.ServeJSON()
 	var datainfo DataInfo
 	datainfo.PageIndex = page.CurrentPage
 	datainfo.ItemsPerPage = page.Size
-	//this.Data["List"] = entities
 	datainfo.Items = entities
 	datainfo.CurrentItemCount = total
 	this.Data["json"] = &datainfo