|
|
@@ -1,6 +1,7 @@
|
|
|
package com.zhongshu.iot.server.core.service.device;
|
|
|
|
|
|
import com.github.microservice.net.ResultContent;
|
|
|
+import com.zhongshu.card.client.model.base.IDParam;
|
|
|
import com.zhongshu.iot.client.model.mqtt.*;
|
|
|
import com.zhongshu.iot.client.type.type.MqttUserState;
|
|
|
import com.zhongshu.iot.server.core.dao.mqtt.*;
|
|
|
@@ -8,6 +9,7 @@ import com.zhongshu.iot.server.core.dataConfig.MqttConfig;
|
|
|
import com.zhongshu.iot.server.core.domain.iot.mqtt.GateWay2User;
|
|
|
import com.zhongshu.iot.server.core.domain.iot.mqtt.GateWayInfo;
|
|
|
import com.zhongshu.iot.server.core.domain.iot.mqtt.GateWayUserInfo;
|
|
|
+import com.zhongshu.iot.server.core.domain.iot.mqtt.ProjectInfo;
|
|
|
import com.zhongshu.iot.server.core.util.CommonUtil;
|
|
|
import com.zhongshu.iot.server.core.util.DateUtils;
|
|
|
import com.zhongshu.iot.server.core.util.bean.BeanUtils;
|
|
|
@@ -54,6 +56,12 @@ public class GateWayUserInfoService {
|
|
|
@Autowired
|
|
|
private JMXSyncService jmxSyncService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private ProjectInfoDao projectInfoDao;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private DeviceInfoDao deviceInfoDao;
|
|
|
+
|
|
|
/**
|
|
|
* 刷新系统所有的用户 和 用户权限数据
|
|
|
*/
|
|
|
@@ -163,7 +171,16 @@ public class GateWayUserInfoService {
|
|
|
}
|
|
|
BeanUtils.copyProperties(param, entity);
|
|
|
gateWayUserInfoDao.save(entity);
|
|
|
+ return ResultContent.buildSuccess();
|
|
|
+ }
|
|
|
|
|
|
+ public ResultContent resetPassWord(IDParam param) {
|
|
|
+ GateWayUserInfo entity = gateWayUserInfoDao.findTopById(param.getId());
|
|
|
+ if (ObjectUtils.isEmpty(entity)) {
|
|
|
+ return ResultContent.buildFail("数据不存在");
|
|
|
+ }
|
|
|
+ entity.setPassWord(CommonUtil.generateRandomString(16));
|
|
|
+ gateWayUserInfoDao.save(entity);
|
|
|
return ResultContent.buildSuccess();
|
|
|
}
|
|
|
|
|
|
@@ -233,11 +250,22 @@ public class GateWayUserInfoService {
|
|
|
*/
|
|
|
public ResultContent updateBindNumber(GateWayUserInfo entity) {
|
|
|
if (ObjectUtils.isNotEmpty(entity)) {
|
|
|
-
|
|
|
+ entity.setBindNumber(countBindNumber(entity));
|
|
|
}
|
|
|
return ResultContent.buildSuccess();
|
|
|
}
|
|
|
|
|
|
+ public long countBindNumber(GateWayUserInfo entity) {
|
|
|
+ if (ObjectUtils.isNotEmpty(entity) && StringUtils.isNotEmpty(entity.getUserName())) {
|
|
|
+ // 网关数量
|
|
|
+ long gatewayNumber = gateWayInfoDao.countByMqttUserName(entity.getUserName());
|
|
|
+ // 设备数量
|
|
|
+ long deviceNumber = deviceInfoDao.countByMqttUserName(entity.getUserName());
|
|
|
+ return gatewayNumber + deviceNumber;
|
|
|
+ }
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 删除mqtt用户信息
|
|
|
*
|
|
|
@@ -287,6 +315,14 @@ public class GateWayUserInfoService {
|
|
|
GateWayUserInfoModel model = new GateWayUserInfoModel();
|
|
|
if (ObjectUtils.isNotEmpty(entity)) {
|
|
|
BeanUtils.copyProperties(entity, model);
|
|
|
+ String projectName = "";
|
|
|
+ if (StringUtils.isNotEmpty(entity.getProjectCode())) {
|
|
|
+ ProjectInfo projectInfo = projectInfoDao.findTopByCode(entity.getProjectCode());
|
|
|
+ if (ObjectUtils.isNotEmpty(projectInfo)) {
|
|
|
+ projectName = projectInfo.getName();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ model.setProjectName(projectName);
|
|
|
}
|
|
|
return model;
|
|
|
}
|