|
@@ -50,7 +50,7 @@ func (s *EquipmentService) GetModelsByBrand(brand string) (models []string) {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// 获取设备列表
|
|
// 获取设备列表
|
|
|
-func (s *EquipmentService) GetEquipmentList(pageIndex, itemsPerPage int64, orgid, keyword, uid string) (int64, []EquipmentSet) {
|
|
|
|
|
|
|
+func (s *EquipmentService) GetEquipmentList(pageIndex, itemsPerPage int64, orgid, keyword, sensorType, uid string) (int64, []EquipmentSet) {
|
|
|
var err error
|
|
var err error
|
|
|
var total int64
|
|
var total int64
|
|
|
eids := s.GetEquipmentidsByUid(uid)
|
|
eids := s.GetEquipmentidsByUid(uid)
|
|
@@ -61,6 +61,12 @@ func (s *EquipmentService) GetEquipmentList(pageIndex, itemsPerPage int64, orgid
|
|
|
if keyword != "" {
|
|
if keyword != "" {
|
|
|
where += ` and (m.Code like '%` + keyword + `%' or m.Id in (select EquipMentId from Channels where Serial like '%` + keyword + `%' or Title like '%` + keyword + `%' ))`
|
|
where += ` and (m.Code like '%` + keyword + `%' or m.Id in (select EquipMentId from Channels where Serial like '%` + keyword + `%' or Title like '%` + keyword + `%' ))`
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ // 添加传感器类型查询条件
|
|
|
|
|
+ if sensorType != "" {
|
|
|
|
|
+ where += ` and m.Id in (select EquipMentId from Channels where DataItem = '` + sensorType + `')`
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
//获取总记录数
|
|
//获取总记录数
|
|
|
sqlCount := " select count(*) from EquipMent m where " + where + ""
|
|
sqlCount := " select count(*) from EquipMent m where " + where + ""
|
|
|
var sql, limitstr string = "", ""
|
|
var sql, limitstr string = "", ""
|
|
@@ -186,14 +192,14 @@ func (s *EquipmentService) GetAllIdsByOrgTopId(topids []string, uid string) (ids
|
|
|
return
|
|
return
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-//根据设备id批量修改设备状态
|
|
|
|
|
|
|
+// 根据设备id批量修改设备状态
|
|
|
func (s *EquipmentService) BatchSetState(state, ids string) {
|
|
func (s *EquipmentService) BatchSetState(state, ids string) {
|
|
|
sql := fmt.Sprintf(`update EquipMent set DeviceState=%v
|
|
sql := fmt.Sprintf(`update EquipMent set DeviceState=%v
|
|
|
where id in (%v)`, state, ids)
|
|
where id in (%v)`, state, ids)
|
|
|
s.DBE.Exec(sql)
|
|
s.DBE.Exec(sql)
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-//权限,根据id获取有权限的设备ids
|
|
|
|
|
|
|
+// 权限,根据id获取有权限的设备ids
|
|
|
func (s *EquipmentService) GetEquipmentidsByUid(userid string) (ids string) {
|
|
func (s *EquipmentService) GetEquipmentidsByUid(userid string) (ids string) {
|
|
|
var idmodel Id_Str
|
|
var idmodel Id_Str
|
|
|
s.DBE.SQL(`select group_concat(EquipmentId) Id FROM Base_UserEquipments where UserId= ` + userid).Get(&idmodel)
|
|
s.DBE.SQL(`select group_concat(EquipmentId) Id FROM Base_UserEquipments where UserId= ` + userid).Get(&idmodel)
|
|
@@ -205,21 +211,21 @@ func (s *EquipmentService) GetEquipmentidsByUid(userid string) (ids string) {
|
|
|
return
|
|
return
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-//清除用户的所有channel信息
|
|
|
|
|
|
|
+// 清除用户的所有channel信息
|
|
|
func (s *EquipmentService) ClearUserEquipmentByUid(userid int) {
|
|
func (s *EquipmentService) ClearUserEquipmentByUid(userid int) {
|
|
|
var condiBean Base_UserEquipments
|
|
var condiBean Base_UserEquipments
|
|
|
condiBean.UserId = userid
|
|
condiBean.UserId = userid
|
|
|
s.DeleteEntity(&condiBean)
|
|
s.DeleteEntity(&condiBean)
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-//清除设备的所有channel信息
|
|
|
|
|
|
|
+// 清除设备的所有channel信息
|
|
|
func (s *EquipmentService) ClearUserEquipmentByEquid(eid int) {
|
|
func (s *EquipmentService) ClearUserEquipmentByEquid(eid int) {
|
|
|
var condiBean Base_UserEquipments
|
|
var condiBean Base_UserEquipments
|
|
|
condiBean.EquipmentId = eid
|
|
condiBean.EquipmentId = eid
|
|
|
s.DeleteEntity(&condiBean)
|
|
s.DeleteEntity(&condiBean)
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-//权限,根据equid获取组织
|
|
|
|
|
|
|
+// 权限,根据equid获取组织
|
|
|
func (s *EquipmentService) GetOrgidsByEqids(eids string) (oids string) {
|
|
func (s *EquipmentService) GetOrgidsByEqids(eids string) (oids string) {
|
|
|
var idmodel Id_Str
|
|
var idmodel Id_Str
|
|
|
|
|
|
|
@@ -257,7 +263,7 @@ func (s *EquipmentService) GetEquipmentAl111l() []Trigger_Abnormal1 {
|
|
|
return List
|
|
return List
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-//根据微信openid 获取账户
|
|
|
|
|
|
|
+// 根据微信openid 获取账户
|
|
|
func GetUserByWx(openid string) (uid int, usermodel Base_User) {
|
|
func GetUserByWx(openid string) (uid int, usermodel Base_User) {
|
|
|
svcweixin := userweixin.GetUserWeixinService(utils.DBE)
|
|
svcweixin := userweixin.GetUserWeixinService(utils.DBE)
|
|
|
uid = svcweixin.GetUserByWeixin(openid)
|
|
uid = svcweixin.GetUserByWeixin(openid)
|