若依微服务1.3.9

1、数据处理服务完善
2、用户管理bug修复
dev 1.3.9
xins 1 year ago
parent abab19b27a
commit d239086f75

@ -39,6 +39,13 @@ public class HwDictConstants {
public static final String DEVICE_STATUS_PUBLISH = "1";//设备状态:已发布
public static final String DEVICE_STATUS_TEST = "0";//设备状态:已发布
public static final String DEVICE_STATUS_DELETE = "9";//设备状态:已发布
public static final String DEVICE_ACTIVE_STATUS_INACTIVE = "0";//设备激活状态:未激活
public static final String DEVICE_ACTIVE_STATUS_ACTIVE = "1";//设备激活状态:激活
public static final String DEVICE_ONLINE_STATUS_ONLINE = "1";//在线状态
public static final String DEVICE_ONLINE_STATUS_OFFLINE = "0"; //离线状态
public static final String FENCE_TYPE_DEVICE = "1";//电子围栏规则类型,设备
public static final String FENCE_TYPE_MONITOR_UNIT = "2";//电子围栏规则类型,监控单元
public static final String FENCE_TYPE_SCENE = "3";//电子围栏规则类型,场景
@ -83,8 +90,6 @@ public class HwDictConstants {
SCENE_MODE_ROUTER_MAP.put(SCENE_MODE_GPS, ROUTER_GPS);
}
public static final String DEVICE_ONLINE_STATUS_ONLINE = "1";//在线状态
public static final String DEVICE_ONLINE_STATUS_OFFLINE = "0"; //离线状态
public static final String ALARM_HANDLE_STATUS_YES = "1";//已处理
public static final String ALARM_HANDLE_STATUS_NO = "0";//未处理

@ -117,7 +117,6 @@ public class DataProcessServiceImpl implements IDataProcessService {
*/
key = TdEngineConstants.TDENGINE_KEY_TRANSFER_MAP.get(key) == null ? key
: TdEngineConstants.TDENGINE_KEY_TRANSFER_MAP.get(key);
System.out.println(key + "---" + value);
if (value instanceof String) {
String valueStr = (String) value;
@ -157,13 +156,10 @@ public class DataProcessServiceImpl implements IDataProcessService {
}
}
System.out.println(databaseName + "---" + tableName);
tdTableVo.setDatabaseName(databaseName);
tdTableVo.setTableName(tableName);
tdTableVo.setSchemaFields(schemaFields);
System.out.println("longtitude:" + longitude + "latit:" + latitude);
final R<?> insertResult = this.remoteTdEngineService.insertTable(tdTableVo);
if (insertResult.getCode() == ResultEnums.SUCCESS.getCode()) {
logger.info("Insert data result: {}", insertResult.getMsg());
@ -189,20 +185,16 @@ public class DataProcessServiceImpl implements IDataProcessService {
* @date 2023-09-04 14:04
*/
private void checkElectronicFence(Long deviceId, Long tenantId, Long monitorUnitId, Long sceneId, Object longitude, Object latitude, Long ts) {
List<HwElectronicFence> hwElectronicFences = hwElectronicFenceMapper.selectElectronicFencesByDeviceId(deviceId);
if (StringUtils.isEmpty(hwElectronicFences)) {
System.out.println("---------");
hwElectronicFences = hwElectronicFenceMapper.selectElectronicFencesByMonitorUnitId(monitorUnitId);
}
if (StringUtils.isEmpty(hwElectronicFences)) {
hwElectronicFences = hwElectronicFenceMapper.selectElectronicFencesBySceneId(sceneId);
System.out.println("---------33333");
}
//根据设备ID、监控单元ID和场景ID获取所有的电子围栏配置。目前先只支持场景
// List<HwElectronicFence> hwElectronicFences = hwElectronicFenceMapper.selectElectronicFencesByDeviceId(deviceId);
// hwElectronicFences = hwElectronicFenceMapper.selectElectronicFencesByMonitorUnitId(monitorUnitId);
List<HwElectronicFence> hwElectronicFences = hwElectronicFenceMapper.selectElectronicFencesBySceneId(sceneId);
if (StringUtils.isNotEmpty(hwElectronicFences)) {
for (HwElectronicFence hwElectronicFence : hwElectronicFences) {
HwFenceArea queryFenceArea = new HwFenceArea();
queryFenceArea.setElectronicFenceId(hwElectronicFence.getElectronicFenceId());
//获取电子围栏下配置的区域列表
List<HwFenceArea> fenceAreas = hwFenceAreaMapper.selectHwFenceAreaList(queryFenceArea);
String effectiveTimeFlag = hwElectronicFence.getEffectiveTimeFlag();
String triggerStatus = hwElectronicFence.getTriggerStatus();
@ -212,6 +204,7 @@ public class DataProcessServiceImpl implements IDataProcessService {
if (effectiveTimeFlag.equals(HwDictConstants.EFFECTIVE_TIME_FLAG_LONG)) {
String areaShapeFlag = fenceArea.getAreaShapeFlag();
String areaRange = fenceArea.getAreaRange();
//多边形处理
if (areaShapeFlag.equals(HwDictConstants.AREA_SHAPE_FLAG_POLYGN)) {
LocationVo polygonVo = new LocationVo();
polygonVo.setMarkerType(LocationVo.MARKER_TYPE_POLYGON);
@ -237,9 +230,8 @@ public class DataProcessServiceImpl implements IDataProcessService {
} else if (triggerStatus.equals(HwDictConstants.ELECTRONIC_FENCE_TRIGGER_STATUS_ENTRY) && isWithin) {//如果电子围栏配置是入界,而此设备入界则报警
isAlarmed = true;
}
System.out.println("iswithin" + isWithin);
} else if (areaShapeFlag.equals(HwDictConstants.AREA_SHAPE_FLAG_CIRCULA)) {
} else if (areaShapeFlag.equals(HwDictConstants.AREA_SHAPE_FLAG_CIRCULA)) {//圆形处理
String[] areaRangeArr = areaRange.split(",");
String longitudeStr = areaRangeArr[0];
String latitudeStr = areaRangeArr[1];
@ -276,10 +268,7 @@ public class DataProcessServiceImpl implements IDataProcessService {
}
});
}
}
}
}

@ -2,6 +2,7 @@ package com.ruoyi.dataprocess.service.impl;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.ruoyi.common.core.constant.HwDictConstants;
import com.ruoyi.common.core.constant.TdEngineConstants;
import com.ruoyi.dataprocess.domain.HwDevice;
import com.ruoyi.dataprocess.mapper.HwDeviceMapper;
@ -14,6 +15,7 @@ import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
/**
@ -50,12 +52,12 @@ public class DeviceStatusServiceImpl implements IDeviceStatusService {
List<TdField> schemaFields = new ArrayList<>();
TdField onlineStatusField = new TdField();
onlineStatusField.setFieldName("onlineStatus");
onlineStatusField.setFieldName(TdEngineConstants.ST_TAG_ONLINESTATUS);
onlineStatusField.setFieldValue(json.getInteger("connectStatus"));
schemaFields.add(onlineStatusField);
TdField deviceTypeField = new TdField();
deviceTypeField.setFieldName("deviceType");
deviceTypeField.setFieldName(TdEngineConstants.ST_TAG_DEVICETYPE);
deviceTypeField.setFieldValue(json.getString("deviceType"));
schemaFields.add(deviceTypeField);
@ -69,7 +71,14 @@ public class DeviceStatusServiceImpl implements IDeviceStatusService {
this.remoteTdEngineService.insertTable(tdTableVo);
//更新设备当前状态信息
hwDevice.setOnlineStatus(String.valueOf(json.getInteger("connectStatus")));
String connectStatus = String.valueOf(json.getInteger("connectStatus"));
hwDevice.setOnlineStatus(connectStatus);
//判断如果是否是第一次连接,更新激活状态和激活时间。
if (hwDevice.getActiveStatus().equals(HwDictConstants.DEVICE_ACTIVE_STATUS_INACTIVE)) {
hwDevice.setActiveStatus(HwDictConstants.DEVICE_ACTIVE_STATUS_ACTIVE);
hwDevice.setActiveTime(new Date());
}
hwDeviceMapper.updateHwDevice(hwDevice);
}
}

@ -165,6 +165,7 @@ public class SysUserController extends BaseController {
AjaxResult ajax = AjaxResult.success();
SysRole querySysRole = new SysRole();
querySysRole.setTenantId(tenantId);
SysPost post = new SysPost();
post.setTenantId(tenantId);
List<SysRole> roles = roleService.selectRoleAll(querySysRole);
@ -213,7 +214,7 @@ public class SysUserController extends BaseController {
LoginUser loginUser = SecurityUtils.getLoginUser();
SysUser loginSysUser = loginUser.getSysUser();
//如果不是admin的租户则就保存为登录用户的租户id如果是adimin则需要保存admin在创建时选择的租户ID
if(!loginSysUser.getTenantId().equals(HwDictConstants.ADMINISTRATOR_TENANT_ID)){
if (!loginSysUser.getTenantId().equals(HwDictConstants.ADMINISTRATOR_TENANT_ID)) {
user.setTenantId(loginSysUser.getTenantId());
}
@ -313,7 +314,7 @@ public class SysUserController extends BaseController {
@GetMapping("/deptTree")
public AjaxResult deptTree(SysDept dept) {
System.out.println("ddddd:"+dept.getTenantId());
System.out.println("ddddd:" + dept.getTenantId());
return success(deptService.selectDeptTreeList(dept));
}
@ -340,16 +341,16 @@ public class SysUserController extends BaseController {
@PostMapping("/deleteUsersByTenantId/{tenantId}")
public R<Boolean> deleteUsersByTenantId(@PathVariable Long tenantId) {
Long[] userIds = userService.getUserIdsByTenantId(tenantId);
if(userIds.length == 0) {
if (userIds.length == 0) {
return R.ok();
}
if (ArrayUtils.contains(userIds, SecurityUtils.getUserId())) {
return R.fail("当前用户不能删除");
}
try{
try {
userService.deleteUserByIds(userIds);
return R.ok();
}catch(Exception e){
} catch (Exception e) {
return R.fail(e.getMessage());
}
}

@ -12,10 +12,7 @@ import com.ruoyi.system.api.model.LoginUser;
import com.ruoyi.system.domain.SysRoleDept;
import com.ruoyi.system.domain.SysRoleMenu;
import com.ruoyi.system.domain.SysUserRole;
import com.ruoyi.system.mapper.SysRoleDeptMapper;
import com.ruoyi.system.mapper.SysRoleMapper;
import com.ruoyi.system.mapper.SysRoleMenuMapper;
import com.ruoyi.system.mapper.SysUserRoleMapper;
import com.ruoyi.system.mapper.*;
import com.ruoyi.system.service.ISysRoleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@ -42,6 +39,8 @@ public class SysRoleServiceImpl implements ISysRoleService {
@Autowired
private SysRoleDeptMapper roleDeptMapper;
@Autowired
private SysUserMapper userMapper;
/**
*
*
@ -63,7 +62,11 @@ public class SysRoleServiceImpl implements ISysRoleService {
@Override
public List<SysRole> selectRolesByUserId(Long userId) {
List<SysRole> userRoles = roleMapper.selectRolePermissionByUserId(userId);
List<SysRole> roles = selectRoleAll();
SysUser user = userMapper.selectUserById(userId);
Long tenantId = user.getTenantId();
SysRole querySysRole = new SysRole();
querySysRole.setTenantId(tenantId);
List<SysRole> roles = this.selectRoleAll(querySysRole);
for (SysRole role : roles) {
for (SysRole userRole : userRoles) {
if (role.getRoleId().longValue() == userRole.getRoleId().longValue()) {

@ -312,7 +312,7 @@
:key="item.roleId"
:label="item.roleName"
:value="item.roleId"
:disabled="item.roleId != 3 && form.tenantId !== undefined && form.tenantId !==0"
:disabled="item.roleId != 3 && form.tenantId !== undefined && form.tenantId !==1"
></el-option>
</el-select>
</el-form-item>
@ -603,6 +603,8 @@ export default {
roleIds: [],
tenantId: undefined
};
this.roleOptions = [];
this.postOptions = [];
this.resetForm("form");
},
/** 搜索按钮操作 */

Loading…
Cancel
Save