Commit 062e6fd8 authored by caotao's avatar caotao

运行监盘增加权限

parent f6c466c1
...@@ -32,11 +32,17 @@ public class MapRegion extends BaseEntity { ...@@ -32,11 +32,17 @@ public class MapRegion extends BaseEntity {
private String name; private String name;
/** /**
* 运行监盘省份,中间用英文逗号隔开
*/
@TableField(value = "jxiop_province",typeHandler = FastjsonTypeHandler.class)
private ArrayList<String> jxiopProvince;
/**
* 省份,中间用英文逗号隔开 * 省份,中间用英文逗号隔开
*/ */
@TableField(value = "province",typeHandler = FastjsonTypeHandler.class) @TableField(value = "province",typeHandler = FastjsonTypeHandler.class)
private ArrayList<String> province; private ArrayList<String> province;
/** /**
* 片区文字显示的省份 * 片区文字显示的省份
*/ */
......
package com.yeejoin.amos.boot.module.jxiop.api.amosprojectmapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.yeejoin.amos.boot.module.jxiop.api.entity.StdUserEmpower;
import org.apache.ibatis.annotations.Select;
import java.util.Map;
/**
* @description:
* @author: tw
* @createDate: 2023/11/9
*/
public interface UserEmpowerMapper extends BaseMapper<StdUserEmpower> {
@Select("select company_name as companyName , level from privilege_company where org_code = #{orgCode}")
Map<String,String> getCompanyInfoByOrgCode(String orgCode);
}
package com.yeejoin.amos.boot.module.jxiop.api.entity;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.extension.handlers.FastjsonTypeHandler;
import com.yeejoin.amos.boot.biz.common.entity.BaseEntity;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import java.util.List;
/**
* @description:
* @author: tw
* @createDate: 2023/11/9
*/
@Data
@EqualsAndHashCode(callSuper = true)
@Accessors(chain = true)
@TableName(value = "std_user_empower",autoResultMap = true)
public class StdUserEmpower extends BaseEntity {
private static final long serialVersionUID = 1L;
/**
* 用户userid
*/
@TableField("amos_user_id")
private String amosUserId;
/**
* 单位orgcode
*/
@TableField(value = "amos_org_code",typeHandler = FastjsonTypeHandler.class)
private List<String> amosOrgCode;
/**
* 权限类型
*/
@TableField("permission_type")
private String permissionType;
}
package com.yeejoin.amos.boot.module.jxiop.biz.config;
import com.alibaba.druid.pool.DruidDataSource;
import com.baomidou.mybatisplus.extension.spring.MybatisSqlSessionFactoryBean;
import com.github.pagehelper.PageInterceptor;
import org.apache.ibatis.plugin.Interceptor;
import org.apache.ibatis.session.SqlSessionFactory;
import org.mybatis.spring.annotation.MapperScan;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.io.support.PathMatchingResourcePatternResolver;
import org.springframework.jdbc.datasource.DataSourceTransactionManager;
import javax.sql.DataSource;
import java.util.Properties;
@Configuration
@MapperScan(basePackages = "com.yeejoin.amos.boot.module.jxiop.api.amosprojectmapper", sqlSessionFactoryRef = "amosProjectSqlSessionFactory")
public class AmosProjectDbConfig {
private Logger logger = LoggerFactory.getLogger(AmosProjectDbConfig.class);
// 精确到 master 目录,以便跟其他数据源隔离
private static final String MAPPER_LOCATION = "classpath*:mapper/amosproject/*.xml";
@Value("${spring.db5.datasource.url}")
private String dbUrl;
@Value("${spring.db5.datasource.username}")
private String username;
@Value("${spring.db5.datasource.password}")
private String password;
@Value("${spring.db5.datasource.driver-class-name}")
private String driverClassName;
@Bean(name="amosProjectDataSource") //声明其为Bean实例
public DataSource masterDataSource() {
DruidDataSource datasource = new DruidDataSource();
datasource.setUrl(this.dbUrl);
datasource.setUsername(username);
datasource.setPassword(password);
datasource.setDriverClassName(driverClassName);
return datasource;
}
@Bean(name = "amosProjectTransactionManager")
public DataSourceTransactionManager masterTransactionManager() {
return new DataSourceTransactionManager(masterDataSource());
}
@Bean(name = "amosProjectSqlSessionFactory")
public SqlSessionFactory masterSqlSessionFactory(@Qualifier("amosProjectDataSource") DataSource masterDataSource)
throws Exception {
final MybatisSqlSessionFactoryBean sessionFactory = new MybatisSqlSessionFactoryBean();
sessionFactory.setDataSource(masterDataSource);
sessionFactory.setMapperLocations(new PathMatchingResourcePatternResolver()
.getResources(AmosProjectDbConfig.MAPPER_LOCATION));
sessionFactory.setTypeAliasesPackage("com.yeejoin.amos.boot.module.jxiop.api.entity");
//mybatis 数据库字段与实体类属性驼峰映射配置
sessionFactory.getObject().getConfiguration().setMapUnderscoreToCamelCase(true);
//分页插件
Interceptor interceptor = new PageInterceptor();
Properties properties = new Properties();
properties.setProperty("helperDialect", "mysql");
properties.setProperty("offsetAsPageNum", "true");
properties.setProperty("rowBoundsWithCount", "true");
properties.setProperty("reasonable", "true");
properties.setProperty("supportMethodsArguments","true");
properties.setProperty("params","pageNum=pageNum;pageSize=pageSize" +
"" +
";");
interceptor.setProperties(properties);
sessionFactory.setPlugins(new Interceptor[] {interceptor});
return sessionFactory.getObject();
}
}
...@@ -5,6 +5,7 @@ import com.alibaba.fastjson.JSON; ...@@ -5,6 +5,7 @@ import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yeejoin.amos.boot.biz.common.bo.ReginParams;
import com.yeejoin.amos.boot.biz.common.controller.BaseController; import com.yeejoin.amos.boot.biz.common.controller.BaseController;
import com.yeejoin.amos.boot.module.common.biz.utils.CommonResponseUtil; import com.yeejoin.amos.boot.module.common.biz.utils.CommonResponseUtil;
import com.yeejoin.amos.boot.module.jxiop.api.dto.IndexDto; import com.yeejoin.amos.boot.module.jxiop.api.dto.IndexDto;
...@@ -95,11 +96,12 @@ public class MonitorFanIdxController extends BaseController { ...@@ -95,11 +96,12 @@ public class MonitorFanIdxController extends BaseController {
return ResponseHelper.buildResponse(monitorFanIndicator.getFanIdxInfoByPage(equipNum, stationId, frontModule, current, size, systemType)); return ResponseHelper.buildResponse(monitorFanIndicator.getFanIdxInfoByPage(equipNum, stationId, frontModule, current, size, systemType));
} }
@TycloudOperation(needAuth = false, ApiLevel = UserType.AGENCY) @TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(value = "左侧树API") @ApiOperation(value = "左侧树API")
@GetMapping("/getTreeInfo") @GetMapping("/getTreeInfo")
public ResponseModel<TreeDto> getTreeInfo(@RequestParam(value = "sequenceNbr") String sequenceNbr) { public ResponseModel<TreeDto> getTreeInfo(@RequestParam(value = "sequenceNbr") String sequenceNbr) {
return ResponseHelper.buildResponse(monitorFanIndicator.getTreeInfo(sequenceNbr)); ReginParams reginParams = getSelectedOrgInfo();
return ResponseHelper.buildResponse(monitorFanIndicator.getTreeInfo(sequenceNbr,reginParams));
} }
......
...@@ -2,6 +2,7 @@ package com.yeejoin.amos.boot.module.jxiop.biz.controller; ...@@ -2,6 +2,7 @@ package com.yeejoin.amos.boot.module.jxiop.biz.controller;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yeejoin.amos.boot.biz.common.bo.ReginParams;
import com.yeejoin.amos.boot.biz.common.controller.BaseController; import com.yeejoin.amos.boot.biz.common.controller.BaseController;
import com.yeejoin.amos.boot.biz.common.utils.RedisUtils; import com.yeejoin.amos.boot.biz.common.utils.RedisUtils;
import com.yeejoin.amos.boot.module.jxiop.api.entity.Region; import com.yeejoin.amos.boot.module.jxiop.api.entity.Region;
...@@ -10,10 +11,7 @@ import com.yeejoin.amos.boot.module.jxiop.api.mapper.StationBasicMapper; ...@@ -10,10 +11,7 @@ import com.yeejoin.amos.boot.module.jxiop.api.mapper.StationBasicMapper;
import com.yeejoin.amos.boot.module.jxiop.api.service.IMapRegionService; import com.yeejoin.amos.boot.module.jxiop.api.service.IMapRegionService;
import com.yeejoin.amos.boot.module.jxiop.biz.dto.*; import com.yeejoin.amos.boot.module.jxiop.biz.dto.*;
import com.yeejoin.amos.boot.module.jxiop.biz.entity.Test; import com.yeejoin.amos.boot.module.jxiop.biz.entity.Test;
import com.yeejoin.amos.boot.module.jxiop.biz.service.impl.MonitoringServiceImpl; import com.yeejoin.amos.boot.module.jxiop.biz.service.impl.*;
import com.yeejoin.amos.boot.module.jxiop.biz.service.impl.RegionServiceImpl;
import com.yeejoin.amos.boot.module.jxiop.biz.service.impl.StationBasicServiceImpl;
import com.yeejoin.amos.boot.module.jxiop.biz.service.impl.TestServiceImpl;
//import com.yeejoin.amos.component.influxdb.InfluxDbConnection; //import com.yeejoin.amos.component.influxdb.InfluxDbConnection;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
...@@ -46,6 +44,9 @@ public class MonitoringMapController extends BaseController { ...@@ -46,6 +44,9 @@ public class MonitoringMapController extends BaseController {
@Autowired @Autowired
MonitoringServiceImpl monitoringServiceImpl; MonitoringServiceImpl monitoringServiceImpl;
@Autowired
JxiopMonitorMapPermissionServiceImpl jxiopMonitorMapPermissionServiceImpl;
@TycloudOperation(ApiLevel = UserType.AGENCY, needAuth = false) @TycloudOperation(ApiLevel = UserType.AGENCY, needAuth = false)
@ApiOperation(value = "获取监盘全国-安全生产天数") @ApiOperation(value = "获取监盘全国-安全生产天数")
@GetMapping("/getSecDays") @GetMapping("/getSecDays")
...@@ -178,4 +179,13 @@ public class MonitoringMapController extends BaseController { ...@@ -178,4 +179,13 @@ public class MonitoringMapController extends BaseController {
public ResponseModel<HashMap<String, Object>> getTheStationPowerCurve(@RequestParam(required = false) String stationId, @RequestParam(required = false) String date) { public ResponseModel<HashMap<String, Object>> getTheStationPowerCurve(@RequestParam(required = false) String stationId, @RequestParam(required = false) String date) {
return ResponseHelper.buildResponse(monitoringServiceImpl.getTheStationPowerCurve(stationId, date)); return ResponseHelper.buildResponse(monitoringServiceImpl.getTheStationPowerCurve(stationId, date));
} }
@TycloudOperation(ApiLevel = UserType.AGENCY, needAuth = false)
@ApiOperation(value = "根据当前登陆人获取运行监盘页面展示类型")
@GetMapping("/getShowPageType")
public ResponseModel<HashMap<String, Object>> getShowPageType() {
ReginParams reginParams = getSelectedOrgInfo();
return ResponseHelper.buildResponse(jxiopMonitorMapPermissionServiceImpl.getShowPageType(reginParams));
}
} }
package com.yeejoin.amos.boot.module.jxiop.biz.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.yeejoin.amos.boot.biz.common.bo.ReginParams;
import com.yeejoin.amos.boot.module.jxiop.api.amosprojectmapper.UserEmpowerMapper;
import com.yeejoin.amos.boot.module.jxiop.api.entity.MapRegion;
import com.yeejoin.amos.boot.module.jxiop.api.entity.StationBasic;
import com.yeejoin.amos.boot.module.jxiop.api.entity.StdUserEmpower;
import com.yeejoin.amos.boot.module.jxiop.api.mapper.MapRegionMapper;
import com.yeejoin.amos.boot.module.jxiop.api.mapper.StationBasicMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.ui.context.ThemeSource;
import org.springframework.util.ObjectUtils;
import java.util.HashMap;
import java.util.Map;
@Service
public class JxiopMonitorMapPermissionServiceImpl {
private UserEmpowerMapper userEmpowerMapper;
private StationBasicMapper stationBasicMapper;
private MapRegionMapper mapRegionMapper;
@Autowired
public JxiopMonitorMapPermissionServiceImpl(UserEmpowerMapper userEmpowerMapper,StationBasicMapper stationBasicMapper,MapRegionMapper mapRegionMapper) {
this.userEmpowerMapper = userEmpowerMapper;
this.stationBasicMapper = stationBasicMapper;
this.mapRegionMapper = mapRegionMapper;
}
public HashMap<String, Object> getShowPageType(ReginParams reginParams) {
HashMap<String, Object> result = new HashMap<String, Object>();
String userId = reginParams.getUserModel().getUserId();
result.put("showType", "error");
StdUserEmpower stdUserEmpower = userEmpowerMapper.selectOne(new QueryWrapper<StdUserEmpower>().eq("amos_user_id", userId).eq("permission_type", "YTH"));
if (ObjectUtils.isEmpty(stdUserEmpower)) {
result.put("errorMessage", "您当前未配置数据权限!");
return result;
} else {
String permissionOrgCode = stdUserEmpower.getAmosOrgCode().get(0);
Map<String,String> companyInfo= userEmpowerMapper.getCompanyInfoByOrgCode(permissionOrgCode);
String companyLevel = companyInfo.get("level").toString();
if (companyLevel.equals("categroy_leve2")) {
result.put("showType", "all");
return result;
}
if(companyLevel.equals("area")){
result.put("showType","area");
String areaName =companyInfo.get("companyName").replace("片区","");
result.put("areaName",areaName);
MapRegion mapRegion = mapRegionMapper.selectOne(new QueryWrapper<MapRegion>().eq("name",areaName));
if(!ObjectUtils.isEmpty(mapRegion)){
result.put("proviceList",mapRegion.getJxiopProvince());
}
return result;
}
if(companyLevel.equals("station")){
result.put("showType","station");
StationBasic stationBasic = stationBasicMapper.selectOne(new QueryWrapper<StationBasic>().eq("project_org_code",permissionOrgCode));
if(!ObjectUtils.isEmpty(stationBasic)){
result.put("stationId",stationBasic.getSequenceNbr());
}
return result;
}
}
return result;
}
}
...@@ -26,6 +26,9 @@ import java.util.stream.Collectors; ...@@ -26,6 +26,9 @@ import java.util.stream.Collectors;
import javax.annotation.PostConstruct; import javax.annotation.PostConstruct;
import com.yeejoin.amos.boot.biz.common.bo.ReginParams;
import com.yeejoin.amos.boot.module.jxiop.api.amosprojectmapper.UserEmpowerMapper;
import com.yeejoin.amos.boot.module.jxiop.api.entity.StdUserEmpower;
import org.apache.commons.collections.MapUtils; import org.apache.commons.collections.MapUtils;
import org.apache.commons.io.IOUtils; import org.apache.commons.io.IOUtils;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
...@@ -106,8 +109,6 @@ public class MonitorFanIndicatorImpl implements IMonitorFanIndicator { ...@@ -106,8 +109,6 @@ public class MonitorFanIndicatorImpl implements IMonitorFanIndicator {
@Autowired @Autowired
SystemEnumMapper systemEnumMapper; SystemEnumMapper systemEnumMapper;
@Autowired @Autowired
SwitchPictureMapper switchPictureMapper;
@Autowired
SjglZsjZsbtzServiceImpl sjglZsjZsbtzServiceImpl; SjglZsjZsbtzServiceImpl sjglZsjZsbtzServiceImpl;
@Autowired @Autowired
TpriDmpDatabookServiceImpl tpriDmpDatabookServiceImpl; TpriDmpDatabookServiceImpl tpriDmpDatabookServiceImpl;
...@@ -124,10 +125,6 @@ public class MonitorFanIndicatorImpl implements IMonitorFanIndicator { ...@@ -124,10 +125,6 @@ public class MonitorFanIndicatorImpl implements IMonitorFanIndicator {
@Autowired @Autowired
CommonServiceImpl commonServiceImpl; CommonServiceImpl commonServiceImpl;
@Autowired @Autowired
EquipAlarmEventMapper equipAlarmEventMapper;
@Autowired
EquipAlarmEventServiceImpl equipAlarmEventService;
@Autowired
EmqKeeper emqKeeper; EmqKeeper emqKeeper;
@Value("${pictureUrl}") @Value("${pictureUrl}")
String pictureUrl; String pictureUrl;
...@@ -148,10 +145,10 @@ public class MonitorFanIndicatorImpl implements IMonitorFanIndicator { ...@@ -148,10 +145,10 @@ public class MonitorFanIndicatorImpl implements IMonitorFanIndicator {
private Resource fanlocation; private Resource fanlocation;
@Autowired @Autowired
private IndicatorDataMapper indicatorDataMapper; private IndicatorDataMapper indicatorDataMapper;
private List<Map> list;
@Autowired @Autowired
private EquipmentSpecificIndexMapper equipmentSpecificIndexMapper; private EquipmentSpecificIndexMapper equipmentSpecificIndexMapper;
@Autowired
private UserEmpowerMapper userEmpowerMapper;
@Override @Override
public ResultsData getNationWideInfo(int current, int size, String gateway, String equipmentNumber) { public ResultsData getNationWideInfo(int current, int size, String gateway, String equipmentNumber) {
String table = gateway; String table = gateway;
...@@ -302,7 +299,17 @@ public class MonitorFanIndicatorImpl implements IMonitorFanIndicator { ...@@ -302,7 +299,17 @@ public class MonitorFanIndicatorImpl implements IMonitorFanIndicator {
return page; return page;
} }
public TreeDto getTreeInfo(String sequenceNbr) { public TreeDto getTreeInfo(String sequenceNbr, ReginParams reginParams) {
String userId = reginParams.getUserModel().getUserId();
String companyLevel ="";
StdUserEmpower stdUserEmpower = userEmpowerMapper.selectOne(new QueryWrapper<StdUserEmpower>().eq("amos_user_id", userId).eq("permission_type", "YTH"));
if (ObjectUtils.isEmpty(stdUserEmpower)) {
throw new BadRequest("您当前未配置数据权限!");
}else{
String permissionOrgCode = stdUserEmpower.getAmosOrgCode().get(0);
Map<String,String> companyInfo= userEmpowerMapper.getCompanyInfoByOrgCode(permissionOrgCode);
companyLevel = companyInfo.get("level").toString();
}
StationBasic stationBasic = stationBasicMapper.selectById(sequenceNbr); StationBasic stationBasic = stationBasicMapper.selectById(sequenceNbr);
List<Integer> integers = JSON.parseArray(stationBasic.getBelongArea(), Integer.class); List<Integer> integers = JSON.parseArray(stationBasic.getBelongArea(), Integer.class);
if (CollectionUtils.isEmpty(integers)) { if (CollectionUtils.isEmpty(integers)) {
...@@ -343,6 +350,15 @@ public class MonitorFanIndicatorImpl implements IMonitorFanIndicator { ...@@ -343,6 +350,15 @@ public class MonitorFanIndicatorImpl implements IMonitorFanIndicator {
gfzTreeDto.setChildren(gfz); gfzTreeDto.setChildren(gfz);
List<TreeDto> treeDtos = Arrays.asList(fdzTreeDto, gfzTreeDto); List<TreeDto> treeDtos = Arrays.asList(fdzTreeDto, gfzTreeDto);
treeDto.setChildren(treeDtos); treeDto.setChildren(treeDtos);
if(companyLevel.equals("station")){
List<TreeDto> children = stationListByRegionCode.stream().filter(t->t.getCode().equals(sequenceNbr)).collect(Collectors.toList());
if(stationBasic.getStationType().equals("FDZ")){
treeDto = fdzTreeDto;
}else {
treeDto = gfzTreeDto;
}
treeDto.setChildren(children);
}
return treeDto; return treeDto;
} }
......
...@@ -19,6 +19,13 @@ spring.db4.datasource.username=root ...@@ -19,6 +19,13 @@ spring.db4.datasource.username=root
spring.db4.datasource.password=Yeejoin@2020 spring.db4.datasource.password=Yeejoin@2020
spring.db4.datasource.driver-class-name: com.mysql.cj.jdbc.Driver spring.db4.datasource.driver-class-name: com.mysql.cj.jdbc.Driver
## db5-amos_project
spring.db5.datasource.type: com.alibaba.druid.pool.DruidDataSource
spring.db5.datasource.url=jdbc:mysql://139.9.173.44:3306/amos_project?allowMultiQueries=true&serverTimezone=GMT%2B8&characterEncoding=utf8
spring.db5.datasource.username=root
spring.db5.datasource.password=Yeejoin@2020
spring.db5.datasource.driver-class-name: com.mysql.cj.jdbc.Driver
## db3-td-engine ## db3-td-engine
#spring.db3.datasource.type: com.alibaba.druid.pool.DruidDataSource #spring.db3.datasource.type: com.alibaba.druid.pool.DruidDataSource
spring.db3.datasource.url=jdbc:TAOS-RS://139.9.170.47:6041/iot_data?user=root&password=taosdata&timezone=GMT%2b8&allowMultiQueries=true spring.db3.datasource.url=jdbc:TAOS-RS://139.9.170.47:6041/iot_data?user=root&password=taosdata&timezone=GMT%2b8&allowMultiQueries=true
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment