From 2ccbb8881721a16ec5cf68b12346ecdc0b6941cf Mon Sep 17 00:00:00 2001
From: huangzhen <867127663@qq.com>
Date: 星期日, 09 十月 2022 09:10:00 +0800
Subject: [PATCH] 获取所有的风险分析单元的编码和姓名
---
src/main/java/com/ruoyi/doublePrevention/service/impl/RiskServiceImpl.java | 15 +
src/main/java/com/ruoyi/doublePrevention/entity/dto/resp/PreventRiskUnitCodeAndNameListQueryRespDTO.java | 40 +++++
src/main/java/com/ruoyi/doublePrevention/service/baseService/PreventRiskListService.java | 8 +
src/main/java/com/ruoyi/project/mobile/service/ApiService.java | 18 ++
src/main/java/com/ruoyi/doublePrevention/config/redis/RedisUtils.java | 261 ++++++++++++++++++++++++++++++++
src/main/java/com/ruoyi/doublePrevention/service/baseService/impl/PreventRiskListServiceImpl.java | 11 +
src/main/java/com/ruoyi/project/mobile/service/ApiPreventRiskUnitService.java | 31 +++
src/main/resources/mybatis/doublePrevention/PreventRiskListMapper.xml | 9 +
src/main/java/com/ruoyi/doublePrevention/config/redis/RedisConfig.java | 43 +++++
src/main/java/com/ruoyi/doublePrevention/repository/PreventRiskListRepository.java | 8 +
src/main/java/com/ruoyi/doublePrevention/service/RiskService.java | 10
11 files changed, 448 insertions(+), 6 deletions(-)
diff --git a/src/main/java/com/ruoyi/doublePrevention/config/redis/RedisConfig.java b/src/main/java/com/ruoyi/doublePrevention/config/redis/RedisConfig.java
new file mode 100644
index 0000000..cb916f8
--- /dev/null
+++ b/src/main/java/com/ruoyi/doublePrevention/config/redis/RedisConfig.java
@@ -0,0 +1,43 @@
+//package com.ruoyi.doublePrevention.config.redis;
+//
+//import org.springframework.context.annotation.Bean;
+//import org.springframework.context.annotation.Configuration;
+//import org.springframework.data.redis.connection.RedisConnectionFactory;
+//import org.springframework.data.redis.core.RedisTemplate;
+//import org.springframework.data.redis.serializer.GenericJackson2JsonRedisSerializer;
+//import org.springframework.data.redis.serializer.StringRedisSerializer;
+//
+//@Configuration
+//public class RedisConfig {
+//
+//
+//
+// /**
+// * @Description: key和value的序列化方式
+// */
+// @Bean
+// public RedisTemplate<String, Object> redisTemplate(RedisConnectionFactory factory) {
+//
+// RedisTemplate<String, Object> template = new RedisTemplate<>();
+// template.setConnectionFactory(factory);
+// // json序列化对象
+// GenericJackson2JsonRedisSerializer jackson2JsonRedisSerializer = new GenericJackson2JsonRedisSerializer();
+// StringRedisSerializer stringRedisSerializer = new StringRedisSerializer();
+// // key=>string
+// template.setKeySerializer(stringRedisSerializer);
+// // hash=>string
+// template.setHashKeySerializer(stringRedisSerializer);
+// // value=>json
+// template.setValueSerializer(jackson2JsonRedisSerializer);
+// // hashValue=>json
+// template.setHashValueSerializer(jackson2JsonRedisSerializer);
+// // set
+// template.afterPropertiesSet();
+// return template;
+// }
+//
+//
+//
+//
+//
+//}
diff --git a/src/main/java/com/ruoyi/doublePrevention/config/redis/RedisUtils.java b/src/main/java/com/ruoyi/doublePrevention/config/redis/RedisUtils.java
new file mode 100644
index 0000000..2ea8c61
--- /dev/null
+++ b/src/main/java/com/ruoyi/doublePrevention/config/redis/RedisUtils.java
@@ -0,0 +1,261 @@
+//package com.ruoyi.doublePrevention.config.redis;
+//
+//
+//import org.slf4j.Logger;
+//import org.slf4j.LoggerFactory;
+//import org.springframework.data.redis.connection.RedisClusterConnection;
+//import org.springframework.data.redis.connection.RedisClusterNode;
+//import org.springframework.data.redis.connection.RedisConnection;
+//import org.springframework.data.redis.connection.RedisConnectionFactory;
+//import org.springframework.data.redis.connection.jedis.JedisClusterConnection;
+//import org.springframework.data.redis.connection.jedis.JedisConnection;
+//import org.springframework.data.redis.core.*;
+//import org.springframework.stereotype.Repository;
+//
+//import javax.annotation.PostConstruct;
+//import javax.annotation.Resource;
+//import java.io.Serializable;
+//import java.util.HashSet;
+//import java.util.Iterator;
+//import java.util.List;
+//import java.util.Set;
+//import java.util.concurrent.TimeUnit;
+//
+///**
+//* @Description: redis工具类
+//*/
+//
+//@Repository("configRedisRepository")
+//@SuppressWarnings(value = { "unchecked", "rawtypes" })
+//public class RedisUtils {
+//
+//
+// @Resource
+// private RedisTemplate redisTemplate;
+// /**
+// * logger
+// */
+// private final Logger logger = LoggerFactory.getLogger(this.getClass());
+//
+//
+// @PostConstruct
+// public void initRepository(){
+// try {
+// this.set("test:module:Web", "testConnection", 60L, TimeUnit.SECONDS);
+// logger.info("[ModuleRedis][Web] is connected");
+// } catch (Exception e) {
+// logger.error("[ModuleRedis][Web] connected failed!!");
+// }
+// }
+//
+// /**
+// * 写入缓存
+// * @param key
+// * @param value
+// * @return
+// */
+// public boolean set(final String key, Object value) {
+// boolean result = false;
+// try {
+// ValueOperations<Serializable, Object> operations = redisTemplate.opsForValue();
+// operations.set(key, value);
+// result = true;
+// } catch (Exception e) {
+// e.printStackTrace();
+// }
+// return result;
+// }
+// /**
+// * 写入缓存设置时效时间
+// * @param key
+// * @param value
+// * @return
+// */
+// public boolean set(final String key, Object value, Long expireTime ,TimeUnit timeUnit) {
+// boolean result = false;
+// try {
+// ValueOperations<Serializable, Object> operations = redisTemplate.opsForValue();
+// operations.set(key, value);
+// redisTemplate.expire(key, expireTime, timeUnit);
+// result = true;
+// } catch (Exception e) {
+// e.printStackTrace();
+// }
+// return result;
+// }
+// /**
+// * 批量删除对应的value
+// * @param keys
+// */
+// public void remove(final String... keys) {
+// for (String key : keys) {
+// remove(key);
+// }
+// }
+// /**
+// * 批量删除key
+// * @param pattern
+// */
+// public void removePattern(final String pattern) {
+// Set<Serializable> keys = redisTemplate.keys(pattern);
+// if (keys.size() > 0){
+// redisTemplate.delete(keys);
+// }
+// }
+// /**
+// * 删除对应的value
+// * @param key
+// */
+// public void remove(final String key) {
+// if (exists(key)) {
+// redisTemplate.delete(key);
+// }
+// }
+// /**
+// * 判断缓存中是否有对应的value
+// * @param key
+// * @return
+// */
+// public boolean exists(final String key) {
+// return redisTemplate.hasKey(key);
+// }
+// /**
+// * 读取缓存
+// * @param key
+// * @return
+// */
+// public Object get(final String key) {
+// Object result = null;
+// ValueOperations<Serializable, Object> operations = redisTemplate.opsForValue();
+// result = operations.get(key);
+// return result;
+// }
+// /**
+// * 哈希 添加
+// * @param key
+// * @param hashKey
+// * @param value
+// */
+// public void hmSet(String key, Object hashKey, Object value){
+// HashOperations<String, Object, Object> hash = redisTemplate.opsForHash();
+// hash.put(key,hashKey,value);
+// }
+// /**
+// * 哈希获取数据
+// * @param key
+// * @param hashKey
+// * @return
+// */
+// public Object hmGet(String key, Object hashKey){
+// HashOperations<String, Object, Object> hash = redisTemplate.opsForHash();
+// return hash.get(key,hashKey);
+// }
+// /**
+// * 列表添加
+// * @param k
+// * @param v
+// */
+// public void lPush(String k,Object v){
+// ListOperations<String, Object> list = redisTemplate.opsForList();
+// list.rightPush(k,v);
+// }
+// /**
+// * 列表获取
+// * @param k
+// * @param l
+// * @param l1
+// * @return
+// */
+// public List<Object> lRange(String k, long l, long l1){
+// ListOperations<String, Object> list = redisTemplate.opsForList();
+// return list.range(k,l,l1);
+// }
+// /**
+// * 集合添加
+// * @param key
+// * @param value
+// */
+// public void add(String key,Object value){
+// SetOperations<String, Object> set = redisTemplate.opsForSet();
+// set.add(key,value);
+// }
+// /**
+// * 集合获取
+// * @param key
+// * @return
+// */
+// public Set<Object> setMembers(String key){
+// SetOperations<String, Object> set = redisTemplate.opsForSet();
+// return set.members(key);
+// }
+// /**
+// * 有序集合添加
+// * @param key
+// * @param value
+// * @param scoure
+// */
+// public void zAdd(String key,Object value,double scoure){
+// ZSetOperations<String, Object> zset = redisTemplate.opsForZSet();
+// zset.add(key,value,scoure);
+// }
+// /**
+// * 有序集合获取
+// * @param key
+// * @param scoure
+// * @param scoure1
+// * @return
+// */
+// public Set<Object> rangeByScore(String key,double scoure,double scoure1){
+// ZSetOperations<String, Object> zset = redisTemplate.opsForZSet();
+// return zset.rangeByScore(key, scoure, scoure1);
+// }
+//
+// /**
+// * @Description: 获取过期时间 返回 秒
+// */
+//
+// public Long getExpireTime(String key) {
+// return redisTemplate.getExpire(key, TimeUnit.SECONDS);
+// }
+//
+//
+// /**
+// * @Description: 重置key 的 过期时间
+// */
+// public void resetKeyExpireTime(String key, Long seconds) {
+// redisTemplate.expire(key, seconds, TimeUnit.SECONDS);
+// }
+//
+// public Set<String> scanMatch(String matchKey) {
+// Set<String> keys = new HashSet();
+// RedisConnectionFactory connectionFactory = redisTemplate.getConnectionFactory();
+// RedisConnection redisConnection = connectionFactory.getConnection();
+// Cursor<byte[]> scan = null;
+// if(redisConnection instanceof JedisClusterConnection){
+// RedisClusterConnection clusterConnection = connectionFactory.getClusterConnection();
+// Iterable<RedisClusterNode> redisClusterNodes = clusterConnection.clusterGetNodes();
+// Iterator<RedisClusterNode> iterator = redisClusterNodes.iterator();
+// while (iterator.hasNext()) {
+// RedisClusterNode next = iterator.next();
+// scan = clusterConnection.scan(next, ScanOptions.scanOptions().match(matchKey).count(Integer.MAX_VALUE).build());
+// while (scan.hasNext()) {
+// keys.add(new String(scan.next()));
+// }
+// scan.close();
+// }
+// return keys;
+// }
+// if(redisConnection instanceof JedisConnection){
+// scan = redisConnection.scan(ScanOptions.scanOptions().match(matchKey).count(Integer.MAX_VALUE).build());
+// while (scan.hasNext()){
+// //找到一次就添加一次
+// keys.add(new String(scan.next()));
+// }
+// scan.close();
+// return keys;
+// }
+//
+// return keys;
+//}
+//
+//}
diff --git a/src/main/java/com/ruoyi/doublePrevention/entity/dto/resp/PreventRiskUnitCodeAndNameListQueryRespDTO.java b/src/main/java/com/ruoyi/doublePrevention/entity/dto/resp/PreventRiskUnitCodeAndNameListQueryRespDTO.java
new file mode 100644
index 0000000..2fed24d
--- /dev/null
+++ b/src/main/java/com/ruoyi/doublePrevention/entity/dto/resp/PreventRiskUnitCodeAndNameListQueryRespDTO.java
@@ -0,0 +1,40 @@
+package com.ruoyi.doublePrevention.entity.dto.resp;
+
+import java.io.Serializable;
+
+public class PreventRiskUnitCodeAndNameListQueryRespDTO implements Serializable {
+
+ /** id */
+ private Long riskListId;
+
+ /** 风险单元编号 */
+ private String riskListNum;
+
+ /** 风险单元名称 */
+ private String riskListName;
+
+ public Long getRiskListId() {
+ return riskListId;
+ }
+
+ public void setRiskListId(Long riskListId) {
+ this.riskListId = riskListId;
+ }
+
+ public String getRiskListNum() {
+ return riskListNum;
+ }
+
+ public void setRiskListNum(String riskListNum) {
+ this.riskListNum = riskListNum;
+ }
+
+ public String getRiskListName() {
+ return riskListName;
+ }
+
+ public void setRiskListName(String riskListName) {
+ this.riskListName = riskListName;
+ }
+
+}
diff --git a/src/main/java/com/ruoyi/doublePrevention/repository/PreventRiskListRepository.java b/src/main/java/com/ruoyi/doublePrevention/repository/PreventRiskListRepository.java
index b15ffc3..e88f91b 100644
--- a/src/main/java/com/ruoyi/doublePrevention/repository/PreventRiskListRepository.java
+++ b/src/main/java/com/ruoyi/doublePrevention/repository/PreventRiskListRepository.java
@@ -3,6 +3,8 @@
import com.ruoyi.doublePrevention.entity.PreventRiskList;
import org.springframework.stereotype.Repository;
+import java.util.List;
+
@Repository
public interface PreventRiskListRepository{
@@ -10,4 +12,10 @@
* @description 根据id获取风险清单
*/
PreventRiskList getPreventRiskListById(Long id);
+
+ /**
+ * @description 获取所有的风险分析单元的编码和姓名
+ */
+ List<PreventRiskList> listRiskUnitCodeAndName();
+
}
diff --git a/src/main/java/com/ruoyi/doublePrevention/service/RiskService.java b/src/main/java/com/ruoyi/doublePrevention/service/RiskService.java
index 52f7962..7b2aa23 100644
--- a/src/main/java/com/ruoyi/doublePrevention/service/RiskService.java
+++ b/src/main/java/com/ruoyi/doublePrevention/service/RiskService.java
@@ -1,7 +1,5 @@
package com.ruoyi.doublePrevention.service;
-import com.baomidou.mybatisplus.core.metadata.IPage;
-import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ruoyi.doublePrevention.entity.PreventRiskControlMeasure;
import com.ruoyi.doublePrevention.entity.PreventRiskEvent;
import com.ruoyi.doublePrevention.entity.PreventRiskJobAndMeasure;
@@ -10,10 +8,8 @@
import com.ruoyi.doublePrevention.repository.param.PreventPointAndMeasureParams;
import com.ruoyi.doublePrevention.vo.ResultVO;
import com.ruoyi.project.tr.HiddenDangerCheckJob.domain.HiddenDangerCheckJob;
-import com.ruoyi.project.tr.baseCheckPoint.domain.BaseCheckPoint;
import com.ruoyi.project.tr.hiddenDangerCheck.domain.HiddenDangerCheck;
import com.ruoyi.project.tr.hiddenDangerCheckPoint.domain.HiddenDangerCheckPoint;
-import com.ruoyi.project.tr.riskList.domain.RiskList;
import java.util.List;
@@ -149,4 +145,10 @@
* 隐患整改信息 - 修改
*/
int updateDangerInfoRectify(HiddenDangerCheckPoint hiddenDangerCheckPoint);
+
+ /**
+ * @description 获取所有的风险分析单元的编码和姓名
+ */
+ List<PreventRiskUnitCodeAndNameListQueryRespDTO> listRiskUnitCodeAndName();
+
}
diff --git a/src/main/java/com/ruoyi/doublePrevention/service/baseService/PreventRiskListService.java b/src/main/java/com/ruoyi/doublePrevention/service/baseService/PreventRiskListService.java
index 3144790..cb3e544 100644
--- a/src/main/java/com/ruoyi/doublePrevention/service/baseService/PreventRiskListService.java
+++ b/src/main/java/com/ruoyi/doublePrevention/service/baseService/PreventRiskListService.java
@@ -2,10 +2,18 @@
import com.ruoyi.doublePrevention.entity.PreventRiskList;
+import java.util.List;
+
public interface PreventRiskListService {
/**
* @description 根据id获取风险清单
*/
PreventRiskList getPreventRiskListById(Long id);
+
+ /**
+ * @description 获取所有的风险分析单元的编码和姓名
+ */
+ List<PreventRiskList> listRiskUnitCodeAndName();
+
}
diff --git a/src/main/java/com/ruoyi/doublePrevention/service/baseService/impl/PreventRiskListServiceImpl.java b/src/main/java/com/ruoyi/doublePrevention/service/baseService/impl/PreventRiskListServiceImpl.java
index ed0bf75..ff20f0a 100644
--- a/src/main/java/com/ruoyi/doublePrevention/service/baseService/impl/PreventRiskListServiceImpl.java
+++ b/src/main/java/com/ruoyi/doublePrevention/service/baseService/impl/PreventRiskListServiceImpl.java
@@ -6,6 +6,8 @@
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
+import java.util.List;
+
@Service("PreventRiskListService")
public class PreventRiskListServiceImpl implements PreventRiskListService {
@@ -19,4 +21,13 @@
public PreventRiskList getPreventRiskListById(Long id) {
return riskListRepository.getPreventRiskListById(id);
}
+
+
+ /**
+ * @description 获取所有的风险分析单元的编码和姓名
+ */
+ @Override
+ public List<PreventRiskList> listRiskUnitCodeAndName() {
+ return riskListRepository.listRiskUnitCodeAndName();
+ }
}
diff --git a/src/main/java/com/ruoyi/doublePrevention/service/impl/RiskServiceImpl.java b/src/main/java/com/ruoyi/doublePrevention/service/impl/RiskServiceImpl.java
index f9f216c..e9aa466 100644
--- a/src/main/java/com/ruoyi/doublePrevention/service/impl/RiskServiceImpl.java
+++ b/src/main/java/com/ruoyi/doublePrevention/service/impl/RiskServiceImpl.java
@@ -1,6 +1,5 @@
package com.ruoyi.doublePrevention.service.impl;
-import com.baomidou.mybatisplus.core.metadata.IPage;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.ruoyi.common.utils.StringUtils;
@@ -1136,4 +1135,18 @@
return 0;
}
+
+ /**
+ * @description 获取所有的风险分析单元的编码和姓名
+ */
+ @Override
+ public List<PreventRiskUnitCodeAndNameListQueryRespDTO> listRiskUnitCodeAndName() {
+ List<PreventRiskList> riskLists = preventRiskListService.listRiskUnitCodeAndName();
+ List<PreventRiskUnitCodeAndNameListQueryRespDTO> listQueryRespDTOs= riskLists.stream().map((riskList)->{
+ PreventRiskUnitCodeAndNameListQueryRespDTO listQueryRespDTO = new PreventRiskUnitCodeAndNameListQueryRespDTO();
+ BeanUtils.copyProperties(riskList,listQueryRespDTO);
+ return listQueryRespDTO;
+ }).collect(Collectors.toList());
+ return listQueryRespDTOs;
+ }
}
\ No newline at end of file
diff --git a/src/main/java/com/ruoyi/project/mobile/service/ApiPreventRiskUnitService.java b/src/main/java/com/ruoyi/project/mobile/service/ApiPreventRiskUnitService.java
new file mode 100644
index 0000000..476e2f5
--- /dev/null
+++ b/src/main/java/com/ruoyi/project/mobile/service/ApiPreventRiskUnitService.java
@@ -0,0 +1,31 @@
+package com.ruoyi.project.mobile.service;
+
+import com.ruoyi.doublePrevention.entity.dto.resp.PreventRiskUnitCodeAndNameListQueryRespDTO;
+import com.ruoyi.doublePrevention.service.RiskService;
+import com.ruoyi.project.mobile.domain.ApiRequestHeader;
+import com.ruoyi.project.mobile.domain.ApiResult;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.List;
+
+/**
+ * @description todo-2022 安卓端用于获取所有的风险分析单元的编码和姓名
+ */
+@Service
+public class ApiPreventRiskUnitService extends BaseApiService{
+
+ @Autowired
+ private RiskService preventRiskService;
+
+ public ApiResult listRiskUnitCodeAndName(String str, ApiRequestHeader header) {
+ //验证userId,loginName,token,deviceType,deviceId,appType 是否一致
+ ApiRequestHeader requestHeader = getHeader(header);
+ if (!(header.equals(requestHeader))) {
+ return ApiResult.errorToken("验证userId,loginName,token,deviceType,deviceId,appType 不一致");
+ }
+
+ List<PreventRiskUnitCodeAndNameListQueryRespDTO> listQueryRespDTOs = preventRiskService.listRiskUnitCodeAndName();
+ return ApiResult.success("查询成功", listQueryRespDTOs);
+ }
+}
diff --git a/src/main/java/com/ruoyi/project/mobile/service/ApiService.java b/src/main/java/com/ruoyi/project/mobile/service/ApiService.java
index d09235a..f694ef2 100644
--- a/src/main/java/com/ruoyi/project/mobile/service/ApiService.java
+++ b/src/main/java/com/ruoyi/project/mobile/service/ApiService.java
@@ -1,13 +1,20 @@
package com.ruoyi.project.mobile.service;
+import com.ruoyi.doublePrevention.entity.dto.resp.PreventRiskUnitCodeAndNameListQueryRespDTO;
+import com.ruoyi.doublePrevention.service.RiskService;
+import com.ruoyi.doublePrevention.vo.ResultVO;
import com.ruoyi.project.mobile.domain.ApiRequestHeader;
import com.ruoyi.project.mobile.domain.ApiResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
+import org.springframework.web.bind.annotation.PostMapping;
+
+import java.util.List;
@Service
public class ApiService {
+
@Autowired
ApiSystemService apiSystemService;//登录
@Autowired
@@ -22,6 +29,9 @@
ApiBaseService baseService;
@Autowired
ApiAllDataStatisticsService allDataStatisticsService;//总的数据统计
+
+ @Autowired
+ ApiPreventRiskUnitService preventRiskUnitService; //风险单元 todo-2022
/**
* 风险模块
@@ -452,4 +462,12 @@
return baseService.getSlideshowPic(str, header);
}
+
+ /**
+ * @description 获取所有的风险分析单元的编码和姓名
+ */
+ public ApiResult listRiskUnitCodeAndName(String str, ApiRequestHeader header) {
+ return preventRiskUnitService.listRiskUnitCodeAndName(str,header);
+ }
+
}
diff --git a/src/main/resources/mybatis/doublePrevention/PreventRiskListMapper.xml b/src/main/resources/mybatis/doublePrevention/PreventRiskListMapper.xml
index c39d8cb..b22f884 100644
--- a/src/main/resources/mybatis/doublePrevention/PreventRiskListMapper.xml
+++ b/src/main/resources/mybatis/doublePrevention/PreventRiskListMapper.xml
@@ -27,8 +27,15 @@
</resultMap>
<select id="getPreventRiskListById" resultMap="BaseResultMap">
- select * from tr_risk_list
+ select *
+ from tr_risk_list
where risk_list_id = #{id}
</select>
+ <select id="listRiskUnitCodeAndName" resultMap="BaseResultMap">
+ select *
+ from tr_risk_list
+ where risk_type <> 4
+ </select>
+
</mapper>
\ No newline at end of file
--
Gitblit v1.9.2