文件上传、token过期监控修改、养生区成品区代码修改、easyExcel
This commit is contained in:
@@ -7,7 +7,7 @@ import org.springframework.data.redis.listener.RedisMessageListenerContainer;
|
||||
|
||||
/**
|
||||
* @author: lyd
|
||||
* @description:
|
||||
* @description: redis监听配置
|
||||
* @Date: 2022/10/8
|
||||
*/
|
||||
@Configuration
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
package org.nl.modules.security.satoken;
|
||||
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.nl.modules.common.utils.SecurityUtils;
|
||||
import org.nl.modules.mnt.websocket.MsgType;
|
||||
import org.nl.modules.mnt.websocket.SocketMsg;
|
||||
import org.nl.modules.mnt.websocket.WebSocketServer;
|
||||
@@ -13,11 +15,10 @@ import org.springframework.data.redis.listener.RedisMessageListenerContainer;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
|
||||
/**
|
||||
* @author: lyd
|
||||
* @description:
|
||||
* @description: redis过期key监听器
|
||||
* @Date: 2022/10/8
|
||||
*/
|
||||
@Slf4j
|
||||
@@ -32,20 +33,13 @@ public class TokenKeyExpirationListener extends KeyExpirationEventMessageListene
|
||||
|
||||
@Override
|
||||
public void onMessage(Message message, byte[] pattern) {
|
||||
// 监听过期的key
|
||||
String expireKey = new String(message.getBody(), StandardCharsets.UTF_8);
|
||||
//获取key原本的value 获取不到 是null
|
||||
String expireKeyValue = redisTemplate.opsForValue().get("my-satoken");
|
||||
//我是根据tokenvalues作为主键ID的
|
||||
String[] split = expireKey.split(":");
|
||||
String s = split[split.length - 1];
|
||||
try {
|
||||
WebSocketServer.sendInfo(new SocketMsg("token会话过期!", MsgType.INFO), "exp-token");
|
||||
if (ObjectUtil.isEmpty(expireKeyValue))
|
||||
WebSocketServer.sendInfo(new SocketMsg("token会话过期!", MsgType.INFO), "exp-token");
|
||||
} catch (IOException e) {
|
||||
log.error(e.getMessage(), e);
|
||||
}
|
||||
log.info("expireKey---"+expireKey);
|
||||
log.info("expireKeyValue---"+expireKeyValue);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,35 +0,0 @@
|
||||
package org.nl.modules.security.satoken.utils;
|
||||
|
||||
import cn.dev33.satoken.stp.StpUtil;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.nl.modules.common.utils.dto.CurrentUser;
|
||||
import org.nl.modules.system.service.dto.UserDto;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author: lyd
|
||||
* @description: 当用户信息改变时候,需要刷新session
|
||||
* @Date: 2022/9/23
|
||||
*/
|
||||
@Component
|
||||
@RequiredArgsConstructor
|
||||
public class FlushSessionUtil {
|
||||
|
||||
/**
|
||||
* 更新session数据 - Session , TokenSession
|
||||
* @param userDto
|
||||
* @param permissionList
|
||||
*/
|
||||
public void flushSessionInfo(UserDto userDto, List<String> permissionList) {
|
||||
StpUtil.getSession().set("UserDto", userDto);
|
||||
// 获取权限列表 - 登录查找权限
|
||||
CurrentUser user = new CurrentUser();
|
||||
user.setId(userDto.getId());
|
||||
user.setUsername(userDto.getUsername());
|
||||
user.setUser(userDto);
|
||||
user.setPermissions(permissionList);
|
||||
StpUtil.getTokenSession().set("userInfo", user);
|
||||
}
|
||||
}
|
||||
@@ -16,6 +16,7 @@
|
||||
package org.nl.modules.tools.rest;
|
||||
|
||||
import cn.dev33.satoken.annotation.SaCheckPermission;
|
||||
import cn.dev33.satoken.annotation.SaIgnore;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
@@ -97,4 +98,12 @@ public class LocalStorageController {
|
||||
localStorageService.deleteAll(ids);
|
||||
return new ResponseEntity<>(HttpStatus.OK);
|
||||
}
|
||||
|
||||
@ApiOperation("导入数据")
|
||||
@PostMapping("/importExcel")
|
||||
@SaIgnore
|
||||
public ResponseEntity<Object> importExcel(@RequestBody String path) {
|
||||
localStorageService.importExcel(path);
|
||||
return new ResponseEntity<>(HttpStatus.OK);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -81,4 +81,10 @@ public interface LocalStorageService {
|
||||
* @throws IOException /
|
||||
*/
|
||||
void download(List<LocalStorageDto> localStorageDtos, HttpServletResponse response) throws IOException;
|
||||
|
||||
/**
|
||||
* 导入数据
|
||||
* @param path
|
||||
*/
|
||||
void importExcel(String path);
|
||||
}
|
||||
@@ -15,21 +15,23 @@
|
||||
*/
|
||||
package org.nl.modules.tools.service.impl;
|
||||
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.util.IdUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.alibaba.excel.EasyExcel;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.nl.modules.common.config.FileProperties;
|
||||
import org.nl.modules.common.exception.BadRequestException;
|
||||
import org.nl.modules.common.utils.FileUtil;
|
||||
import org.nl.modules.common.utils.PageUtil;
|
||||
import org.nl.modules.common.utils.QueryHelp;
|
||||
import org.nl.modules.common.utils.ValidationUtil;
|
||||
import org.nl.modules.common.utils.*;
|
||||
import org.nl.modules.tools.domain.LocalStorage;
|
||||
import org.nl.modules.tools.repository.LocalStorageRepository;
|
||||
import org.nl.modules.tools.service.LocalStorageService;
|
||||
import org.nl.modules.tools.service.dto.LocalStorageDto;
|
||||
import org.nl.modules.tools.service.dto.LocalStorageQueryCriteria;
|
||||
import org.nl.modules.tools.service.mapstruct.LocalStorageMapper;
|
||||
import org.nl.modules.wql.core.bean.WQLObject;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.stereotype.Service;
|
||||
@@ -135,4 +137,39 @@ public class LocalStorageServiceImpl implements LocalStorageService {
|
||||
}
|
||||
FileUtil.downloadExcel(list, response);
|
||||
}
|
||||
|
||||
/**
|
||||
* 导入数据
|
||||
*
|
||||
* @param path: 文件地址
|
||||
*/
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void importExcel(String path) {
|
||||
WQLObject measureunitTab = WQLObject.getWQLObject("md_pb_measureunit");
|
||||
Long currentUserId = SecurityUtils.getCurrentUserId();
|
||||
String nickName = SecurityUtils.getCurrentNickName();
|
||||
String now = DateUtil.now();
|
||||
List<Map<String, Object>> listMap = EasyExcel.read(path).sheet().doReadSync();
|
||||
listMap.remove(0);
|
||||
for (int i = 0; i < listMap.size(); i++) {
|
||||
Map<String, Object> map = listMap.get(i);
|
||||
String unit_code = String.valueOf(map.get(1));
|
||||
String unit_name = String.valueOf(map.get(2));
|
||||
JSONObject unit = new JSONObject();
|
||||
unit.put("measure_unit_id", IdUtil.getSnowflake(1, 1).nextId());
|
||||
unit.put("unit_code", unit_code);
|
||||
unit.put("unit_name", unit_name);
|
||||
unit.put("qty_precision", 2);
|
||||
unit.put("is_used", 1);
|
||||
unit.put("is_delete", 0);
|
||||
unit.put("create_id", currentUserId);
|
||||
unit.put("create_name", nickName);
|
||||
unit.put("create_time", now);
|
||||
unit.put("update_optid", currentUserId);
|
||||
unit.put("update_optname", nickName);
|
||||
unit.put("update_time", now);
|
||||
measureunitTab.insert(unit);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user