Browse Source

feature(mcs_common): 获取设备列表增加传感器类型过滤

sunmiao 17 hours ago
parent
commit
ac24979fe6

+ 1 - 0
backend/src/dashoo.cn/mcs_common/business/device/channels.go

@@ -85,6 +85,7 @@ type DeviceChannels struct {
 	Signal       string
 	Signal       string
 	DState       int    //设备状态 1在线,2离线
 	DState       int    //设备状态 1在线,2离线
 	LiquidLevel  string //液位
 	LiquidLevel  string //液位
+	WaveAlarm    string //wave报警
 	TriggerCount string //设置报警数
 	TriggerCount string //设置报警数
 }
 }
 
 

+ 13 - 7
backend/src/dashoo.cn/mcs_common/business/equipment/equipmentService.go

@@ -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)