Commit 05432645 authored by KeYong's avatar KeYong

Merge remote-tracking branch 'origin/developer' into developer

parents 427fd295 bf374478
package com.yeejoin.amos.boot.module.jxiop.biz.controller;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yeejoin.amos.boot.biz.common.entity.BaseEntity;
import com.yeejoin.amos.boot.module.jxiop.biz.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.List;
import java.util.Map;
@RestController
@Api(tags = "McbWarning Controller")
@RequestMapping(value = "/mcb-warning")
public class McbWarningController {
@Autowired
private IMcbWarningService IMcbWarningService;
@TycloudOperation(ApiLevel = UserType.AGENCY, needAuth = false)
@ApiOperation(httpMethod = "GET", value = "[监测总览]今日预警-预警总数", notes = "[监测总览]今日预警-预警总数")
@GetMapping(value = "/count/today")
public ResponseModel<Map<String, Object>> queryTodayCount(@RequestParam("processingStatus") Integer processingStatus) {
return ResponseHelper.buildResponse(IMcbWarningService.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(IMcbWarningService.queryWeekCount());
}
@TycloudOperation(ApiLevel = UserType.AGENCY, needAuth = false)
@ApiOperation(httpMethod = "GET", value = "[监测总览]预警信息列表", notes = "[监测总览]预警信息列表")
@GetMapping(value = "/warning/page")
public ResponseModel<Page<Map<String, Object>>> queryList(@RequestParam(value = "pageNumber", defaultValue = "1") Integer pageNumber,
@RequestParam(value = "pageSize", defaultValue = "20") Integer pageSize,
@RequestParam("processingStatus") Integer processingStatus) {
Page<BaseEntity> page = new Page<>(pageNumber, pageSize);
return ResponseHelper.buildResponse(IMcbWarningService.queryWarningPage(page, processingStatus));
}
@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("completionStatus") Integer completionStatus) {
Page<BaseEntity> page = new Page<>(pageNumber, pageSize);
return ResponseHelper.buildResponse(IMcbWarningService.queryQuestionPage(page, completionStatus));
}
}
package com.yeejoin.amos.boot.module.jxiop.biz.mapper2;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yeejoin.amos.boot.biz.common.entity.BaseEntity;
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 预警列表
*/
Page<Map<String, Object>> queryWarningPage(
@Param("projectOrgCodes") List<String> projectOrgCodes,
@Param("page") Page<BaseEntity> page,
@Param("processingStatus") Integer processingStatus
);
/**
* 问题列表
*
* @return 问题列表
*/
Page<Map<String, Object>> queryQuestionPage(
@Param("projectOrgCodes") List<String> projectOrgCodes,
@Param("page") Page<BaseEntity> page,
@Param("completionStatus") Integer completionStatus
);
}
package com.yeejoin.amos.boot.module.jxiop.biz.service;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yeejoin.amos.boot.biz.common.entity.BaseEntity;
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<BaseEntity> page, Integer processingStatus);
/**
* 问题信息列表
*
* @return 问题信息列表
*/
Page<Map<String, Object>> queryQuestionPage(Page<BaseEntity> page, Integer processingStatus);
}
...@@ -5,4 +5,5 @@ import java.util.List; ...@@ -5,4 +5,5 @@ import java.util.List;
public interface IPermissionService { public interface IPermissionService {
List<String> getCurrentUserPermissions(); List<String> getCurrentUserPermissions();
List<String> getCurrentUserProjectOrgCodes();
} }
...@@ -35,13 +35,6 @@ public class IPermissionServiceImpl implements IPermissionService { ...@@ -35,13 +35,6 @@ public class IPermissionServiceImpl implements IPermissionService {
@Autowired @Autowired
private StationBasicMapper stationBasicMapper; private StationBasicMapper stationBasicMapper;
// @Autowired
// public IPermissionServiceImpl(RedisUtils redisUtils, UserEmpowerMapper userEmpowerMapper, StationBasicMapper stationBasicMapper) {
// this.redisUtils = redisUtils;
// this.userEmpowerMapper = userEmpowerMapper;
// this.stationBasicMapper = stationBasicMapper;
// }
@Override @Override
public List<String> getCurrentUserPermissions() { public List<String> getCurrentUserPermissions() {
List<String> result = new ArrayList<>(); List<String> result = new ArrayList<>();
...@@ -70,4 +63,33 @@ public class IPermissionServiceImpl implements IPermissionService { ...@@ -70,4 +63,33 @@ public class IPermissionServiceImpl implements IPermissionService {
} }
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").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;
}
} }
package com.yeejoin.amos.boot.module.jxiop.biz.service.impl;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yeejoin.amos.boot.biz.common.entity.BaseEntity;
import com.yeejoin.amos.boot.module.jxiop.biz.mapper2.McbWarningMapper;
import com.yeejoin.amos.boot.module.jxiop.biz.service.IMcbWarningService;
import com.yeejoin.amos.boot.module.jxiop.biz.service.IPermissionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.Objects;
@Service
public class McbWarningServiceImpl implements IMcbWarningService {
@Autowired
private McbWarningMapper mcbWarningMapper;
@Autowired
private IPermissionService permissionService;
/**
* 今日预警-预警总数
*
* @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<BaseEntity> page, Integer processingStatus) {
List<String> projectOrgCodes = this.getProjectOrgCodes();
return mcbWarningMapper.queryWarningPage(projectOrgCodes, page, processingStatus);
}
/**
* 问题信息列表
*
* @param page 分页
* @param completionStatus 处理状态
* @return 问题信息列表
*/
@Override
public Page<Map<String, Object>> queryQuestionPage(Page<BaseEntity> page, Integer completionStatus) {
List<String> projectOrgCodes = this.getProjectOrgCodes();
return mcbWarningMapper.queryQuestionPage(projectOrgCodes, page, completionStatus);
}
/**
* 获取用户权限(此处使用gatewayId)
*
* @return gatewayIds
*/
private List<String> getProjectOrgCodes() {
List<String> projectOrgCodes = permissionService.getCurrentUserProjectOrgCodes();
if (Objects.isNull(projectOrgCodes)) {
projectOrgCodes = Collections.emptyList();
}
return projectOrgCodes;
}
}
<?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.mapper2.McbWarningMapper">
<select id="queryTodayCount" resultType="java.util.Map">
SELECT
COUNT(*) as count
FROM
mcb_warning_warning_info log
LEFT JOIN 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
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 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 b.`code` IN
<foreach collection="projectOrgCodes" item="item" open="(" separator="," close=")">
${item}
</foreach>
</if>
</trim>
ORDER BY
b.alarmDate ASC
</select>
<select id="queryWarningPage" resultType="java.util.Map">
SELECT
log.SEQUENCE_NBR,
log.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
mcb_warning_warning_info log
LEFT JOIN mcb_warning_base_warning_level LEVEL ON log.EVENT_LEVEL = LEVEL.CODE and LEVEL.SEQUENCE_NBR in (1, 2, 3)
LEFT JOIN mcb_warning_base_source_attribution source ON source.CODE = log.SOURCE_ATTRIBUTION
<where>
<if test="projectOrgCodes != null and projectOrgCodes.size() > 0">
AND b.CODE IN
<foreach collection="projectOrgCodes" item="item" open="(" separator="," close=")">
${item}
</foreach>
</if>
<if test="processingStatus != null">
AND log.PROCESSING_STATUS = #{processingStatus}
</if>
</where>
ORDER BY
log.CREATE_DATE DESC
</select>
<select id="queryQuestionPage" resultType="java.util.Map">
SELECT
question.SEQUENCE_NBR,
ifnull(question.REC_DATE, question.CREATE_DATE) as REC_DATE,
question.COMPLETION_STATUS_DESC,
question.COMPLETION_STATUS,
question.SOURCE_ATTRIBUTION_DESC,
question.SOURCE_ATTRIBUTION,
question.CONTENT,
source.PROVINCE
FROM
mcb_warning_question_info question
LEFT JOIN mcb_warning_base_source_attribution source ON source.CODE = question.SOURCE_ATTRIBUTION
<where>
<if test="projectOrgCodes != null and projectOrgCodes.size() > 0">
AND b.CODE 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
</select>
</mapper>
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