Commit 7236b3fe authored by tangwei's avatar tangwei

解决冲突

parents d8e03e38 af330ea3
......@@ -830,7 +830,7 @@ private FanHealthIndexDayMapper fanHealthIndexDayMapper;
List<IdxBizFanHealthLevel> healthLevelInfoList = idxBizFanHealthIndexMapper.getHealthLevelInfoList(gatewayIds);
List<FullViewRecallDataDTO> list = idxBizFanHealthIndexMapper.getFullViewRecall();
List<FullViewRecallDataDTO> list = idxBizFanHealthIndexMapper.getFullViewRecall(null);
Map<String, Map<String, Map<String, Map<String, Map<String, List<FullViewRecallDataDTO>>>>>> resultMap = list.stream()
.collect(Collectors.groupingBy(FullViewRecallDataDTO::getArea,
Collectors.groupingBy(FullViewRecallDataDTO::getStation,
......
......@@ -181,7 +181,7 @@ public class KafkaAnalyseController {
List<IdxBizFanHealthLevel> healthLevelInfoList = idxBizFanHealthIndexMapper.getHealthLevelInfoList(gatewayIds);
List<FullViewRecallDataDTO> list = idxBizFanHealthIndexMapper.getFullViewRecall();
List<FullViewRecallDataDTO> list = idxBizFanHealthIndexMapper.getFullViewRecall(gatewayIds);
Map<String, Map<String, Map<String, Map<String, Map<String, List<FullViewRecallDataDTO>>>>>> resultMap = list.stream()
.collect(Collectors.groupingBy(FullViewRecallDataDTO::getArea,
Collectors.groupingBy(FullViewRecallDataDTO::getStation,
......
......@@ -936,7 +936,7 @@ public class TDBigScreenAnalyseController extends BaseController {
List<IdxBizFanHealthLevel> healthLevelInfoList = idxBizFanHealthIndexMapper.getHealthLevelInfoList(gatewayIds);
List<FullViewRecallDataDTO> list = idxBizFanHealthIndexMapper.getFullViewRecall();
List<FullViewRecallDataDTO> list = idxBizFanHealthIndexMapper.getFullViewRecall(null);
Map<String, Map<String, Map<String, Map<String, Map<String, List<FullViewRecallDataDTO>>>>>> resultMap = list
.stream()
.collect(Collectors.groupingBy(FullViewRecallDataDTO::getArea,
......
......@@ -100,7 +100,7 @@ public interface IdxBizFanHealthIndexMapper extends BaseMapper<IdxBizFanHealthIn
String getPointNameByIndexAddress(@Param("varDesc") String varDesc, @Param("tableName") String tableName,
@Param("gatewayId") String gatewayId);
List<FullViewRecallDataDTO> getFullViewRecall();
List<FullViewRecallDataDTO> getFullViewRecall(@Param("gatewayIds") List<String> gatewayIds);
List<Map<String, Object>> getStationIndexInfo();
......
......@@ -5,4 +5,5 @@ import java.util.List;
public interface IPermissionService {
List<String> getCurrentUserPermissions();
List<String> getCurrentUserProjectOrgCodes();
}
......@@ -35,13 +35,6 @@ public class IPermissionServiceImpl implements IPermissionService {
@Autowired
private StationBasicMapper stationBasicMapper;
// @Autowired
// public IPermissionServiceImpl(RedisUtils redisUtils, UserEmpowerMapper userEmpowerMapper, StationBasicMapper stationBasicMapper) {
// this.redisUtils = redisUtils;
// this.userEmpowerMapper = userEmpowerMapper;
// this.stationBasicMapper = stationBasicMapper;
// }
@Override
public List<String> getCurrentUserPermissions() {
List<String> result = new ArrayList<>();
......@@ -70,4 +63,33 @@ public class IPermissionServiceImpl implements IPermissionService {
}
return result;
}
@Override
public List<String> getCurrentUserProjectOrgCodes() {
List<String> result = new ArrayList<>();
ReginParams reginParams = JSONObject.parseObject(redisUtils.get(RedisKey.buildReginKey(RequestContext.getExeUserId(), RequestContext.getToken())).toString(), ReginParams.class);
String userId = reginParams.getUserModel().getUserId();
StdUserEmpower stdUserEmpower = userEmpowerMapper.selectOne(new QueryWrapper<StdUserEmpower>().eq("amos_user_id", userId).eq("permission_type", "YTH"));
if (ObjectUtils.isEmpty(stdUserEmpower)) {
return null;
} 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")) {
return null;
}
if (companyLevel.equals("area")) {
List<StationBasic> stationBasics = stationBasicMapper.selectList(new QueryWrapper<StationBasic>().like("project_org_code", permissionOrgCode));
result = stationBasics.stream().map(StationBasic::getProjectOrgCode).collect(Collectors.toList());
return result;
}
if (companyLevel.equals("station")) {
StationBasic stationBasic = stationBasicMapper.selectOne(new QueryWrapper<StationBasic>().eq("project_org_code", permissionOrgCode));
result.add(stationBasic.getProjectOrgCode());
return result;
}
}
return result;
}
}
......@@ -90,7 +90,7 @@ spring.db3.datasource.password=taosdata
spring.db3.datasource.driver-class-name: com.taosdata.jdbc.rs.RestfulDriver
# 分析专用td数据库 analyse_data
# ����ר��td���ݿ� analyse_data
#spring.db4.datasource.type: com.alibaba.druid.pool.DruidDataSource
spring.db4.datasource.url=jdbc:TAOS-RS://10.20.0.203:6041/analysis_data?user=root&password=taosdata&timezone=GMT%2b8&allowMultiQueries=true
spring.db4.datasource.username=root
......@@ -181,19 +181,19 @@ spring.kafka.consumer.key-deserializer=org.apache.kafka.common.serialization.Str
spring.kafka.consumer.value-deserializer=org.apache.kafka.common.serialization.StringDeserializer
spring.kafka.listener.ack-mode=manual_immediate
spring.kafka.listener.type=batch
#一次拉取数量 && 线程数量
����ȡ���� && �߳�����
spring.kafka.consumer.max-poll-records=30
#spring.kafka.consumer.fetch-max-wait= 10000
#当前时间向前偏移月数 向历史偏移月数
#��ǰʱ����ǰƫ������ ����ʷƫ������
last.month.num = 12
#相关性 算法调用
#����� �㷨����
base.url.XGX=http://139.9.171.247:8052/intelligent-analysis/correlation
#工况划分 算法调用地
#�������� �㷨���õ�ַ
base.url.GKHF=http://139.9.171.247:8052/intelligent-analysis/working-condition-division
#相关性 算法调用
#����� �㷨����
base.url.ZXZ=http://139.9.171.247:8052/intelligent-analysis/central-value
#指数分析,算法调用
���������㷨����
base.url.zsfx:http://139.9.171.247:8052/intelligent-analysis/index-analysis
\ No newline at end of file
......@@ -742,6 +742,11 @@
AND SUB_SYSTEM is not null
AND POINT_NAME is not null
AND INDEX_ADDRESS is not null
<if test="gatewayIds != null and gatewayIds.size() > 0"> and GATEWAY_ID in
<foreach item="item" index="index" collection="gatewayIds" open="(" separator="," close=")">
#{item}
</foreach>
</if>
)
UNION ALL
(SELECT ARAE AS area,
......@@ -759,6 +764,11 @@
AND EQUIPMENT_NAME is not null
AND POINT_NAME is not null
AND INDEX_ADDRESS is not null
<if test="gatewayIds != null and gatewayIds.size() > 0"> and GATEWAY_ID in
<foreach item="item" index="index" collection="gatewayIds" open="(" separator="," close=")">
#{item}
</foreach>
</if>
)
) a
ORDER BY a.station ASC, a.equipmentName ASC, a.equipmentName asc, a.subSystem asc
......
package com.yeejoin.amos.boot.module.jxiop.api.feign;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yeejoin.amos.component.feign.config.InnerInvokException;
import com.yeejoin.amos.component.feign.model.FeignClientResult;
import org.springframework.cloud.openfeign.FeignClient;
......@@ -39,4 +40,35 @@ public interface McbWarningFeign {
@PostMapping("/task/updateRawDataByTraceId")
FeignClientResult<Boolean> updateRawDataByTraceId(@RequestParam(value = "traceId") String traceId, @RequestParam(value = "rawData") String rawData);
/**
* 任务详情分页列表
*/
@GetMapping("/warning-warning-info/page")
FeignClientResult<Page<Map<String, Object>>> getTaskDetailPage(@RequestParam Map<String, Object> map);
/**
* 问题记录分页列表
*/
@GetMapping("/warning-question-info/questionPage")
FeignClientResult<Page<Map<String, Object>>> getQuestionRecordPage(@RequestParam Map<String, Object> map);
/**
* 任务详情、问题记录左侧树
*/
@GetMapping("/warning-warning-info/tree")
FeignClientResult getWarnTree(@RequestParam Map<String, Object> map);
/**
* 任务详情列表统计
*/
@GetMapping("/warning-warning-info/statistics")
FeignClientResult getTaskDetailStatistic(@RequestParam Map<String, Object> map);
/**
* 问题记录列表统计
*/
@GetMapping("/warning-question-info/questionPageTopStatistics")
FeignClientResult getQuestionRecordStatistic(@RequestParam Map<String, Object> map);
}
package com.yeejoin.amos.boot.module.jxiop.api.service;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import java.util.List;
import java.util.Map;
public interface IMcbWarningService {
/**
* 今日预警-预警总数
*
* @param processingStatus 处理状态
* @return 预警总数
*/
Map<String, Object> queryTodayCount(Integer processingStatus);
/**
* 近七日预警统计
*
* @return 预警统计
*/
List<Map<String, Object>> queryWeekCount();
/**
* 预警信息列表
*
* @return 预警信息列表
*/
Page<Map<String, Object>> queryWarningPage(Page<Map<String, Object>> page, Integer processingStatus, String eventLevel, String createDate, String warningSourceType);
/**
* 预警信息总数
*
* @return 预警信息总数
*/
Long queryWarningCount(Integer processingStatus, String eventLevel, String createDate, String warningSourceType);
/**
* 问题信息列表
*
* @return 问题信息列表
*/
Page<Map<String, Object>> queryQuestionPage(Page<Map<String, Object>> page, Integer completionStatus);
/**
* 问题信息列表
*
* @return 问题信息列表
*/
Long queryQuestionCount(Integer completionStatus);
/**
* 获取地图点位/路线
*
* @return 地图点位/路线
*/
Object queryMapRoutes(String province);
/**
* 任务详情分页列表
*
* @return 任务详情分页列表
*/
Page<Map<String, Object>> getTaskDetailPage(Map<String, Object> map);
/**
* 问题记录分页列表
*
* @return 任务详情分页列表
*/
Page<Map<String, Object>> getQuestionRecordPage(Map<String, Object> map);
/**
* 任务详情、问题记录左侧树
*/
Object getWarnTree(Map<String, Object> map);
/**
* 任务详情列表统计
*/
Object getTaskDetailStatistic(Map<String, Object> map);
/**
* 问题记录列表统计
*/
Object getQuestionRecordStatistic(Map<String, Object> map);
}
package com.yeejoin.amos.boot.module.jxiop.api.service;
import java.util.List;
public interface IPermissionService {
List<String> getCurrentUserPermissions();
List<String> getCurrentUserProjectOrgCodes();
}
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.yeejoin.amos.boot.module.jxiop.biz.mcbwarningmapper.McbWarningMapper">
<select id="queryTodayCount" resultType="java.util.Map">
SELECT
COUNT(*) as count
FROM
amos_mcb.mcb_warning_warning_info log
LEFT JOIN amos_mcb.mcb_warning_base_source_attribution source ON source.CODE = log.SOURCE_ATTRIBUTION
<where>
date(log.CREATE_DATE) = CURRENT_DATE
<if test="projectOrgCodes != null and projectOrgCodes.size() > 0">
AND SOURCE_ATTRIBUTION IN
<foreach collection="projectOrgCodes" item="item" open="(" separator="," close=")">
#{item}
</foreach>
</if>
<if test="processingStatus != null and processingStatus != ''">
AND log.processing_status = #{processingStatus}
</if>
</where>
</select>
<select id="queryWeekCount" resultType="java.util.Map">
SELECT
DATE_FORMAT(b.alarmDate, '%m/%d') AS alarmDate,
b.code AS code,
b.province AS province,
IFNULL(count(log.SEQUENCE_NBR), 0) AS countNum
FROM
(
SELECT
source.CODE AS code,
a.DATE AS alarmDate,
source.PROVINCE AS province
FROM
amos_mcb.mcb_warning_base_source_attribution source,
(
SELECT CURDATE() AS date
UNION ALL
SELECT DATE_SUB( CURDATE(), INTERVAL 1 DAY ) AS date
UNION ALL
SELECT DATE_SUB( CURDATE(), INTERVAL 2 DAY ) AS date
UNION ALL
SELECT DATE_SUB( CURDATE(), INTERVAL 3 DAY ) AS date
UNION ALL
SELECT DATE_SUB( CURDATE(), INTERVAL 4 DAY ) AS date
UNION ALL
SELECT DATE_SUB( CURDATE(), INTERVAL 5 DAY ) AS date
UNION ALL
SELECT DATE_SUB( CURDATE(), INTERVAL 6 DAY ) AS date
) a
) b
LEFT JOIN amos_mcb.mcb_warning_warning_info log ON date(log.CREATE_DATE) = b.alarmDate AND log.SOURCE_ATTRIBUTION = b.CODE
GROUP BY
-- b.code,
b.alarmDate
<trim prefix="having" prefixOverrides="and">
<if test="projectOrgCodes != null and projectOrgCodes.size() > 0">
AND log.SOURCE_ATTRIBUTION IN
<foreach collection="projectOrgCodes" item="item" open="(" separator="," close=")">
#{item}
</foreach>
</if>
</trim>
ORDER BY
b.alarmDate ASC
</select>
<select id="queryWarningList" resultType="java.util.Map">
SELECT
log.SEQUENCE_NBR,
DATE_FORMAT(log.CREATE_DATE, '%Y-%m-%d %H:%i:%s') AS CREATE_DATE,
log.EVENT_LEVEL_DESC,
log.EVENT_LEVEL,
log.SOURCE_ATTRIBUTION_DESC,
log.SOURCE_ATTRIBUTION,
log.CONTENT,
LEVEL.COLOR,
source.PROVINCE,
log.WARNING_SOURCE_TYPE
FROM
amos_mcb.mcb_warning_warning_info log
LEFT JOIN amos_mcb.mcb_warning_base_warning_level LEVEL ON log.EVENT_LEVEL = LEVEL.CODE and LEVEL.SEQUENCE_NBR in (1, 2, 3)
LEFT JOIN amos_mcb.mcb_warning_base_source_attribution source ON source.CODE = log.SOURCE_ATTRIBUTION
<where>
<if test="projectOrgCodes != null and projectOrgCodes.size() > 0">
AND log.SOURCE_ATTRIBUTION IN
<foreach collection="projectOrgCodes" item="item" open="(" separator="," close=")">
#{item}
</foreach>
</if>
<if test="processingStatus != null">
AND log.PROCESSING_STATUS = #{processingStatus}
</if>
<if test="eventLevel != null and eventLevel != ''">
AND log.EVENT_LEVEL = #{eventLevel}
</if>
<if test="createDate != null and createDate != ''">
AND log.CREATE_DATE &gt;= concat(#{createDate}, ' 00:00:00')
AND log.CREATE_DATE &lt;= concat(#{createDate}, ' 23:59:59')
</if>
<if test="warningSourceType != null and warningSourceType != ''">
AND log.WARNING_SOURCE_TYPE = #{warningSourceType}
</if>
</where>
ORDER BY
log.CREATE_DATE DESC
LIMIT #{start}, #{offset}
</select>
<select id="queryWarningCount" resultType="java.lang.Long">
SELECT
count(*)
FROM
amos_mcb.mcb_warning_warning_info log
LEFT JOIN amos_mcb.mcb_warning_base_warning_level LEVEL ON log.EVENT_LEVEL = LEVEL.CODE and LEVEL.SEQUENCE_NBR in (1, 2, 3)
LEFT JOIN amos_mcb.mcb_warning_base_source_attribution source ON source.CODE = log.SOURCE_ATTRIBUTION
<where>
<if test="projectOrgCodes != null and projectOrgCodes.size() > 0">
AND log.SOURCE_ATTRIBUTION IN
<foreach collection="projectOrgCodes" item="item" open="(" separator="," close=")">
#{item}
</foreach>
</if>
<if test="processingStatus != null">
AND log.PROCESSING_STATUS = #{processingStatus}
</if>
<if test="eventLevel != null and eventLevel != ''">
AND log.EVENT_LEVEL = #{eventLevel}
</if>
<if test="createDate != null and createDate != ''">
AND log.CREATE_DATE &gt;= concat(#{createDate}, ' 00:00:00')
AND log.CREATE_DATE &lt;= concat(#{createDate}, ' 23:59:59')
</if>
<if test="warningSourceType != null and warningSourceType != ''">
AND log.WARNING_SOURCE_TYPE = #{warningSourceType}
</if>
</where>
</select>
<select id="queryQuestionList" resultType="java.util.Map">
SELECT
question.SEQUENCE_NBR,
DATE_FORMAT(ifnull(question.REC_DATE, question.CREATE_DATE), '%Y-%m-%d %H:%i:%s') AS REC_DATE,
question.COMPLETION_STATUS_DESC,
question.COMPLETION_STATUS,
question.SOURCE_ATTRIBUTION_DESC,
question.SOURCE_ATTRIBUTION,
question.CONTENT,
source.PROVINCE
FROM
amos_mcb.mcb_warning_question_info question
LEFT JOIN amos_mcb.mcb_warning_base_source_attribution source ON source.CODE = question.SOURCE_ATTRIBUTION
<where>
<if test="projectOrgCodes != null and projectOrgCodes.size() > 0">
AND question.SOURCE_ATTRIBUTION IN
<foreach collection="projectOrgCodes" item="item" open="(" separator="," close=")">
#{item}
</foreach>
</if>
<if test="completionStatus != null">
AND question.COMPLETION_STATUS = #{completionStatus}
</if>
</where>
ORDER BY
question.REC_DATE DESC
LIMIT #{start}, #{offset}
</select>
<select id="queryQuestionCount" resultType="java.lang.Long">
SELECT
count(*)
FROM
amos_mcb.mcb_warning_question_info question
LEFT JOIN amos_mcb.mcb_warning_base_source_attribution source ON source.CODE = question.SOURCE_ATTRIBUTION
<where>
<if test="projectOrgCodes != null and projectOrgCodes.size() > 0">
AND question.SOURCE_ATTRIBUTION IN
<foreach collection="projectOrgCodes" item="item" open="(" separator="," close=")">
#{item}
</foreach>
</if>
<if test="completionStatus != null">
AND question.COMPLETION_STATUS = #{completionStatus}
</if>
</where>
</select>
</mapper>
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.biz.mcbwarningmapper", sqlSessionFactoryRef = "mcbWarningSqlSessionFactory")
public class MabWarningDbConfig {
private Logger logger = LoggerFactory.getLogger(MabWarningDbConfig.class);
// 精确到 master 目录,以便跟其他数据源隔离
private static final String MAPPER_LOCATION = "classpath*:mapper/warning/*.xml";
@Value("${spring.db3.datasource.url}")
private String dbUrl;
@Value("${spring.db2.datasource.username}")
private String username;
@Value("${spring.db2.datasource.password}")
private String password;
@Value("${spring.db2.datasource.driver-class-name}")
private String driverClassName;
@Bean(name="mcbWarningDataSource") //声明其为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 = "mcbWarningTransactionManager")
public DataSourceTransactionManager masterTransactionManager() {
return new DataSourceTransactionManager(masterDataSource());
}
@Bean(name = "mcbWarningSqlSessionFactory")
public SqlSessionFactory masterSqlSessionFactory(@Qualifier("mcbWarningDataSource") DataSource masterDataSource)
throws Exception {
final MybatisSqlSessionFactoryBean sessionFactory = new MybatisSqlSessionFactoryBean();
sessionFactory.setDataSource(masterDataSource);
sessionFactory.setMapperLocations(new PathMatchingResourcePatternResolver()
.getResources(MabWarningDbConfig.MAPPER_LOCATION));
sessionFactory.setTypeAliasesPackage("com.yeejoin.amos.boot.module.jxiop.biz.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(interceptor);
return sessionFactory.getObject();
}
}
package com.yeejoin.amos.boot.module.jxiop.biz.controller;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yeejoin.amos.boot.module.jxiop.api.service.IMcbWarningService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.typroject.tyboot.core.foundation.enumeration.UserType;
import org.typroject.tyboot.core.restful.doc.TycloudOperation;
import org.typroject.tyboot.core.restful.utils.ResponseHelper;
import org.typroject.tyboot.core.restful.utils.ResponseModel;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@RestController
@Api(tags = "McbWarning Controller")
@RequestMapping(value = "/warning")
public class McbWarningController {
@Autowired
private IMcbWarningService mcbWarningService;
@TycloudOperation(ApiLevel = UserType.AGENCY, needAuth = false)
@ApiOperation(httpMethod = "GET", value = "[监测总览]今日预警-预警总数", notes = "[监测总览]今日预警-预警总数")
@GetMapping(value = "/count/today")
public ResponseModel<Map<String, Object>> queryTodayCount(@RequestParam(value = "processingStatus", required = false) Integer processingStatus) {
return ResponseHelper.buildResponse(mcbWarningService.queryTodayCount(processingStatus));
}
@TycloudOperation(ApiLevel = UserType.AGENCY, needAuth = false)
@ApiOperation(httpMethod = "GET", value = "[监测总览]近七日预警统计", notes = "[监测总览]近七日预警统计")
@GetMapping(value = "/count/week")
public ResponseModel<List<Map<String, Object>>> queryWeekCount() {
return ResponseHelper.buildResponse(mcbWarningService.queryWeekCount());
}
@TycloudOperation(ApiLevel = UserType.AGENCY, needAuth = false)
@ApiOperation(httpMethod = "GET", value = "[监测总览]预警信息列表", notes = "[监测总览]预警信息列表")
@GetMapping(value = "/warning/page")
public ResponseModel<Page<Map<String, Object>>> queryWarningPage(@RequestParam(value = "pageNumber", defaultValue = "1") Integer pageNumber,
@RequestParam(value = "pageSize", defaultValue = "20") Integer pageSize,
@RequestParam(value = "processingStatus", required = false) Integer processingStatus,
@RequestParam(value = "eventLevel", required = false) String eventLevel,
@RequestParam(value = "createDate", required = false) String createDate,
@RequestParam(value = "warningSourceType", required = false) String warningSourceType
) {
Page<Map<String, Object>> page = new Page<>(pageNumber, pageSize);
return ResponseHelper.buildResponse(mcbWarningService.queryWarningPage(page, processingStatus, eventLevel, createDate, warningSourceType));
}
@TycloudOperation(ApiLevel = UserType.AGENCY, needAuth = false)
@ApiOperation(httpMethod = "GET", value = "[监测总览]预警信息总数", notes = "[监测总览]预警信息总数")
@GetMapping(value = "/warning/count")
public ResponseModel<Map<String, Object>> queryWarningCount(@RequestParam(value = "processingStatus", required = false) Integer processingStatus,
@RequestParam(value = "eventLevel", required = false) String eventLevel,
@RequestParam(value = "createDate", required = false) String createDate,
@RequestParam(value = "warningSourceType", required = false) String warningSourceType) {
Long count = mcbWarningService.queryWarningCount(processingStatus, eventLevel, createDate, warningSourceType);
Map<String, Object> result = new HashMap<String, Object>() {{
this.put("count", count);
}};
return ResponseHelper.buildResponse(result);
}
@TycloudOperation(ApiLevel = UserType.AGENCY, needAuth = false)
@ApiOperation(httpMethod = "GET", value = "[监测总览]问题列表", notes = "[监测总览]问题列表")
@GetMapping(value = "/question/page")
public ResponseModel<Page<Map<String, Object>>> queryQuestionList(@RequestParam(value = "pageNumber", defaultValue = "1") Integer pageNumber,
@RequestParam(value = "pageSize", defaultValue = "20") Integer pageSize,
@RequestParam(value = "completionStatus", required = false) Integer completionStatus) {
Page<Map<String, Object>> page = new Page<>(pageNumber, pageSize);
return ResponseHelper.buildResponse(mcbWarningService.queryQuestionPage(page, completionStatus));
}
@TycloudOperation(ApiLevel = UserType.AGENCY, needAuth = false)
@ApiOperation(httpMethod = "GET", value = "任务详情、问题记录左侧树", notes = "任务详情、问题记录左侧树")
@GetMapping(value = "/warning-warning-info/tree")
public ResponseModel getWarnTree(@RequestParam Map<String, Object> map) {
return ResponseHelper.buildResponse(mcbWarningService.getWarnTree(map));
}
@TycloudOperation(ApiLevel = UserType.AGENCY, needAuth = false)
@ApiOperation(httpMethod = "GET", value = "任务详情分页列表", notes = "任务详情分页列表")
@GetMapping(value = "/warning-warning-info/page")
public ResponseModel<Page<Map<String, Object>>> getTaskDetailPage(@RequestParam Map<String, Object> map) {
return ResponseHelper.buildResponse(mcbWarningService.getTaskDetailPage(map));
}
@TycloudOperation(ApiLevel = UserType.AGENCY, needAuth = false)
@ApiOperation(httpMethod = "GET", value = "任务详情统计", notes = "任务详情统计")
@GetMapping(value = "/warning-warning-info/statistics")
public ResponseModel getTaskDetailStatistic(@RequestParam Map<String, Object> map) {
return ResponseHelper.buildResponse(mcbWarningService.getTaskDetailStatistic(map));
}
@TycloudOperation(ApiLevel = UserType.AGENCY, needAuth = false)
@ApiOperation(httpMethod = "GET", value = "问题记录分页列表", notes = "问题记录分页列表")
@GetMapping(value = "/warning-question-info/questionPage")
public ResponseModel<Page<Map<String, Object>>> getQuestionRecordPage(@RequestParam Map<String, Object> map) {
return ResponseHelper.buildResponse(mcbWarningService.getQuestionRecordPage(map));
}
@TycloudOperation(ApiLevel = UserType.AGENCY, needAuth = false)
@ApiOperation(httpMethod = "GET", value = "问题记录统计", notes = "问题记录统计")
@GetMapping(value = "/warning-question-info/questionPageTopStatistics")
public ResponseModel getQuestionRecordStatistic(@RequestParam Map<String, Object> map) {
return ResponseHelper.buildResponse(mcbWarningService.getQuestionRecordStatistic(map));
}
@TycloudOperation(ApiLevel = UserType.AGENCY, needAuth = false)
@ApiOperation(httpMethod = "GET", value = "[监测总览]问题总数", notes = "[监测总览]问题总数")
@GetMapping(value = "/question/count")
public ResponseModel<Map<String, Object>> queryQuestionCount(@RequestParam(value = "completionStatus", required = false) Integer completionStatus) {
Long count = mcbWarningService.queryQuestionCount(completionStatus);
Map<String, Object> result = new HashMap<String, Object>() {{
this.put("count", count);
}};
return ResponseHelper.buildResponse(result);
}
@TycloudOperation(ApiLevel = UserType.AGENCY, needAuth = false)
@ApiOperation(httpMethod = "GET", value = "[监测总览]地图点位/路线", notes = "[监测总览]地图点位/路线")
@GetMapping(value = "/map/routes")
public ResponseModel<Object> queryMapRoutes(@RequestParam(value = "province", required = false) String province) {
return ResponseHelper.buildResponse(mcbWarningService.queryMapRoutes(province));
}
}
package com.yeejoin.amos.boot.module.jxiop.biz.mcbwarningmapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
import java.util.Map;
public interface McbWarningMapper extends BaseMapper {
/**
* 今日预警-预警总数
*
* @param processingStatus 处理状态
* @return 总数信息
*/
Map<String, Object> queryTodayCount(
@Param("projectOrgCodes") List<String> projectOrgCodes,
@Param("processingStatus") Integer processingStatus
);
/**
* 近七日预警统计
*
* @return 预警统计
*/
List<Map<String, Object>> queryWeekCount(
@Param("projectOrgCodes") List<String> projectOrgCodes
);
/**
* 预警列表
*
* @return 预警列表
*/
List<Map<String, Object>> queryWarningList(
@Param("start") Long start,
@Param("offset") Long offset,
@Param("projectOrgCodes") List<String> projectOrgCodes,
@Param("processingStatus") Integer processingStatus,
@Param("eventLevel") String eventLevel,
@Param("createDate") String createDate,
@Param("warningSourceType") String warningSourceType
);
/**
* 预警总数
*
* @return 预警总数
*/
Long queryWarningCount(
@Param("projectOrgCodes") List<String> projectOrgCodes,
@Param("processingStatus") Integer processingStatus,
@Param("eventLevel") String eventLevel,
@Param("createDate") String createDate,
@Param("warningSourceType") String warningSourceType
);
/**
* 问题列表
*
* @return 问题列表
*/
List<Map<String, Object>> queryQuestionList(
@Param("start") Long start,
@Param("offset") Long offset,
@Param("projectOrgCodes") List<String> projectOrgCodes,
@Param("completionStatus") Integer completionStatus
);
/**
* 问题总数
*
* @return 问题总数
*/
Long queryQuestionCount(
@Param("projectOrgCodes") List<String> projectOrgCodes,
@Param("completionStatus") Integer completionStatus
);
}
package com.yeejoin.amos.boot.module.jxiop.biz.service.impl;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.yeejoin.amos.boot.biz.common.bo.ReginParams;
import com.yeejoin.amos.boot.biz.common.utils.RedisKey;
import com.yeejoin.amos.boot.biz.common.utils.RedisUtils;
import com.yeejoin.amos.boot.module.jxiop.api.entity.StationBasic;
import com.yeejoin.amos.boot.module.jxiop.api.mapper.StationBasicMapper;
import com.yeejoin.amos.boot.module.jxiop.api.service.IPermissionService;
import com.yeejoin.amos.boot.module.jxiop.biz.amosprojectmapper.UserEmpowerMapper;
import com.yeejoin.amos.boot.module.jxiop.biz.entity.StdUserEmpower;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.ObjectUtils;
import org.typroject.tyboot.core.foundation.context.RequestContext;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
@Service
public class IPermissionServiceImpl implements IPermissionService {
@Autowired
private RedisUtils redisUtils;
@Autowired
private UserEmpowerMapper userEmpowerMapper;
@Autowired
private StationBasicMapper stationBasicMapper;
@Override
public List<String> getCurrentUserPermissions() {
List<String> result = new ArrayList<>();
ReginParams reginParams = JSONObject.parseObject(redisUtils.get(RedisKey.buildReginKey(RequestContext.getExeUserId(), RequestContext.getToken())).toString(), ReginParams.class);
String userId = reginParams.getUserModel().getUserId();
StdUserEmpower stdUserEmpower = userEmpowerMapper.selectOne(new QueryWrapper<StdUserEmpower>().eq("amos_user_id", userId).eq("permission_type", "YTH"));
if (ObjectUtils.isEmpty(stdUserEmpower)) {
return null;
} else {
String permissionOrgCode = stdUserEmpower.getAmosOrgCode().get(0);
Map<String, String> companyInfo = userEmpowerMapper.getCompanyInfoByOrgCode(permissionOrgCode);
String companyLevel = companyInfo.get("level");
if (companyLevel.equals("categroy_leve2")) {
return null;
}
if (companyLevel.equals("area")) {
List<StationBasic> stationBasics = stationBasicMapper.selectList(new QueryWrapper<StationBasic>().like("project_org_code", permissionOrgCode));
result = stationBasics.stream().map(StationBasic::getFanGatewayId).collect(Collectors.toList());
return result;
}
if (companyLevel.equals("station")) {
StationBasic stationBasic = stationBasicMapper.selectOne(new QueryWrapper<StationBasic>().eq("project_org_code", permissionOrgCode));
result.add(stationBasic.getFanGatewayId());
return result;
}
}
return result;
}
@Override
public List<String> getCurrentUserProjectOrgCodes() {
List<String> result = new ArrayList<>();
ReginParams reginParams = JSONObject.parseObject(redisUtils.get(RedisKey.buildReginKey(RequestContext.getExeUserId(), RequestContext.getToken())).toString(), ReginParams.class);
String userId = reginParams.getUserModel().getUserId();
StdUserEmpower stdUserEmpower = userEmpowerMapper.selectOne(new QueryWrapper<StdUserEmpower>().eq("amos_user_id", userId).eq("permission_type", "YTH"));
if (ObjectUtils.isEmpty(stdUserEmpower)) {
return null;
} else {
String permissionOrgCode = stdUserEmpower.getAmosOrgCode().get(0);
Map<String, String> companyInfo = userEmpowerMapper.getCompanyInfoByOrgCode(permissionOrgCode);
String companyLevel = companyInfo.get("level");
if (companyLevel.equals("categroy_leve2")) {
return null;
}
if (companyLevel.equals("area")) {
List<StationBasic> stationBasics = stationBasicMapper.selectList(new QueryWrapper<StationBasic>().like("project_org_code", permissionOrgCode));
result = stationBasics.stream().map(StationBasic::getProjectOrgCode).collect(Collectors.toList());
return result;
}
if (companyLevel.equals("station")) {
StationBasic stationBasic = stationBasicMapper.selectOne(new QueryWrapper<StationBasic>().eq("project_org_code", permissionOrgCode));
result.add(stationBasic.getProjectOrgCode());
return result;
}
}
return result;
}
}
package com.yeejoin.amos.boot.module.jxiop.biz.service.impl;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yeejoin.amos.boot.module.jxiop.api.feign.McbWarningFeign;
import com.yeejoin.amos.boot.module.jxiop.api.service.IMcbWarningService;
import com.yeejoin.amos.boot.module.jxiop.api.service.IPermissionService;
import com.yeejoin.amos.boot.module.jxiop.biz.mcbwarningmapper.McbWarningMapper;
import com.yeejoin.amos.component.feign.model.FeignClientResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.*;
@Service
public class McbWarningServiceImpl implements IMcbWarningService {
@Autowired
private McbWarningMapper mcbWarningMapper;
@Autowired
private IPermissionService permissionService;
@Autowired
private McbWarningFeign mcbWarningFeign;
/**
* 今日预警-预警总数
*
* @param processingStatus 处理状态
* @return 总数信息
*/
@Override
public Map<String, Object> queryTodayCount(Integer processingStatus) {
List<String> projectOrgCodes = this.getProjectOrgCodes();
return mcbWarningMapper.queryTodayCount(projectOrgCodes, processingStatus);
}
/**
* 近七日预警统计
*
* @return 预警统计
*/
@Override
public List<Map<String, Object>> queryWeekCount() {
List<String> projectOrgCodes = this.getProjectOrgCodes();
return mcbWarningMapper.queryWeekCount(projectOrgCodes);
}
/**
* 预警信息列表
*
* @param page 分页
* @param processingStatus 处理状态
* @return 预警信息列表
*/
@Override
public Page<Map<String, Object>> queryWarningPage(Page<Map<String, Object>> page, Integer processingStatus, String eventLevel, String createDate, String warningSourceType) {
List<String> projectOrgCodes = this.getProjectOrgCodes();
long start = page.getCurrent() - 1;
long offset = page.getSize() * page.getCurrent();
List<Map<String, Object>> records = mcbWarningMapper.queryWarningList(start, offset, projectOrgCodes, processingStatus, eventLevel, createDate, warningSourceType);
Long total = mcbWarningMapper.queryWarningCount(projectOrgCodes, processingStatus, eventLevel, createDate, warningSourceType);
page.setRecords(records);
page.setTotal(total);
return page;
}
/**
* 预警信息总数
*
* @param processingStatus 处理状态
* @return 预警信息总数
*/
@Override
public Long queryWarningCount(Integer processingStatus, String eventLevel, String createDate, String warningSourceType) {
List<String> projectOrgCodes = this.getProjectOrgCodes();
return mcbWarningMapper.queryWarningCount(projectOrgCodes, processingStatus, eventLevel, createDate, warningSourceType);
}
/**
* 问题信息列表
*
* @param page 分页
* @param completionStatus 完成状态
* @return 问题信息列表
*/
@Override
public Page<Map<String, Object>> queryQuestionPage(Page<Map<String, Object>> page, Integer completionStatus) {
List<String> projectOrgCodes = this.getProjectOrgCodes();
long start = page.getCurrent() - 1;
long offset = page.getSize() * page.getCurrent();
List<Map<String, Object>> records = mcbWarningMapper.queryQuestionList(start, offset, projectOrgCodes, completionStatus);
Long total = mcbWarningMapper.queryQuestionCount(projectOrgCodes, completionStatus);
page.setRecords(records);
page.setTotal(total);
return page;
}
/**
* 问题信息列表
*
* @param completionStatus 完成状态
* @return 问题信息列表
*/
@Override
public Long queryQuestionCount(Integer completionStatus) {
List<String> projectOrgCodes = this.getProjectOrgCodes();
return mcbWarningMapper.queryQuestionCount(projectOrgCodes, completionStatus);
}
/**
* 获取地图点位/路线
*
* @param province 省份
* @return 地图点位/路线
*/
@Override
public Object queryMapRoutes(String province) {
List<String> projectOrgCodes = this.getProjectOrgCodes();
// TODO: 远程调用warning服务
return null;
}
/**
* 任务详情分页列表
*/
@Override
public Page<Map<String, Object>> getTaskDetailPage(Map<String, Object> map) {
map.put("GATEWAY_ID", String.format("[%s]", buildGateWayIdsParam()));
FeignClientResult<Page<Map<String, Object>>> page = mcbWarningFeign.getTaskDetailPage(map);
return page.getResult();
}
@Override
public Page<Map<String, Object>> getQuestionRecordPage(Map<String, Object> map) {
map.put("GATEWAY_ID", String.format("[%s]", buildGateWayIdsParam()));
FeignClientResult<Page<Map<String, Object>>> page = mcbWarningFeign.getQuestionRecordPage(map);
return page.getResult();
}
/**
* 任务详情、问题记录左侧树
*
*/
@Override
public Object getWarnTree(Map<String, Object> map) {
map.put("GATEWAY_ID", String.format("[%s]", buildGateWayIdsParam()));
FeignClientResult result = mcbWarningFeign.getWarnTree(map);
return result.getResult();
}
/**
* 任务详情列表统计
*
*/
@Override
public Object getTaskDetailStatistic(Map<String, Object> map) {
map.put("GATEWAY_ID", String.format("[%s]", buildGateWayIdsParam()));
FeignClientResult result = mcbWarningFeign.getTaskDetailStatistic(map);
return result.getResult();
}
/**
* 问题记录统计
*
*/
@Override
public Object getQuestionRecordStatistic(Map<String, Object> map) {
map.put("GATEWAY_ID", String.format("[%s]", buildGateWayIdsParam()));
FeignClientResult result = mcbWarningFeign.getQuestionRecordStatistic(map);
return result.getResult();
}
/**
* 获取用户权限(此处使用projectOrgCode)
*
* @return gatewayIds
*/
private List<String> getProjectOrgCodes() {
List<String> projectOrgCodes = permissionService.getCurrentUserProjectOrgCodes();
if (Objects.isNull(projectOrgCodes)) {
projectOrgCodes = Collections.emptyList();
}
return projectOrgCodes;
}
private String buildGateWayIdsParam() {
List<String> currentUserPermissions = permissionService.getCurrentUserPermissions();
if (Objects.isNull(currentUserPermissions)) {
currentUserPermissions = new ArrayList<>();
}
String gatewayIds = String.join(",", currentUserPermissions);
if (!gatewayIds.isEmpty()) {
gatewayIds = String.format("[%s]", gatewayIds);
}
return Optional.ofNullable(gatewayIds).orElse("[]");
}
}
......@@ -9,6 +9,11 @@ spring.db2.datasource.url=jdbc:mysql://139.9.173.44:3306/amos_project?allowMulti
spring.db2.datasource.username=root
spring.db2.datasource.password=Yeejoin@2020
spring.db3.datasource.driver-class-name: com.mysql.cj.jdbc.Driver
spring.db3.datasource.url=jdbc:mysql://139.9.173.44:3306/amos_mcb?allowMultiQueries=true&serverTimezone=GMT%2B8&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull
spring.db3.datasource.username=root
spring.db3.datasource.password=Yeejoin@2020
## eureka properties:
eureka.instance.hostname=172.16.10.220
eureka.client.serviceUrl.defaultZone=http://admin:a1234560@${eureka.instance.hostname}:10001/eureka/
......
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