fix:手持登入
This commit is contained in:
@@ -30,9 +30,11 @@ import java.time.LocalDateTime;
|
|||||||
public class ApiError {
|
public class ApiError {
|
||||||
|
|
||||||
private String code = "400";
|
private String code = "400";
|
||||||
|
private Integer status = 400;
|
||||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||||
private LocalDateTime timestamp;
|
private LocalDateTime timestamp;
|
||||||
private String msg;
|
private String msg;
|
||||||
|
private String message;
|
||||||
|
|
||||||
private ApiError() {
|
private ApiError() {
|
||||||
timestamp = LocalDateTime.now();
|
timestamp = LocalDateTime.now();
|
||||||
@@ -41,6 +43,7 @@ public class ApiError {
|
|||||||
public static ApiError error(String message){
|
public static ApiError error(String message){
|
||||||
ApiError apiError = new ApiError();
|
ApiError apiError = new ApiError();
|
||||||
apiError.setMsg(message);
|
apiError.setMsg(message);
|
||||||
|
apiError.setMessage(message);
|
||||||
return apiError;
|
return apiError;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -48,6 +51,7 @@ public class ApiError {
|
|||||||
ApiError apiError = new ApiError();
|
ApiError apiError = new ApiError();
|
||||||
apiError.setCode(String.valueOf(status));
|
apiError.setCode(String.valueOf(status));
|
||||||
apiError.setMsg(message);
|
apiError.setMsg(message);
|
||||||
|
apiError.setMessage(message);
|
||||||
return apiError;
|
return apiError;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -50,6 +50,7 @@ public class GlobalExceptionHandler {
|
|||||||
*/
|
*/
|
||||||
@ExceptionHandler(value = NotLoginException.class)
|
@ExceptionHandler(value = NotLoginException.class)
|
||||||
public ResponseEntity<ApiError> notLoginException(Exception e) {
|
public ResponseEntity<ApiError> notLoginException(Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
log.error("token超时:-------------------------------------"+e.getMessage());
|
log.error("token超时:-------------------------------------"+e.getMessage());
|
||||||
return buildResponseEntity(ApiError.error(401,"token 失效"));
|
return buildResponseEntity(ApiError.error(401,"token 失效"));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package org.nl.wms.pda_manage.palletio.controller;
|
|||||||
|
|
||||||
|
|
||||||
import cn.dev33.satoken.annotation.SaIgnore;
|
import cn.dev33.satoken.annotation.SaIgnore;
|
||||||
|
import cn.hutool.http.HttpRequest;
|
||||||
import com.alibaba.fastjson.JSONObject;
|
import com.alibaba.fastjson.JSONObject;
|
||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
import org.nl.common.TableDataInfo;
|
import org.nl.common.TableDataInfo;
|
||||||
@@ -10,6 +11,7 @@ import org.nl.common.domain.entity.PageQuery;
|
|||||||
import org.nl.common.utils.MapOf;
|
import org.nl.common.utils.MapOf;
|
||||||
import org.nl.wms.dispatch_manage.task.service.ISchBaseTaskService;
|
import org.nl.wms.dispatch_manage.task.service.ISchBaseTaskService;
|
||||||
import org.nl.wms.pda_manage.palletio.service.PalletIostorinvService;
|
import org.nl.wms.pda_manage.palletio.service.PalletIostorinvService;
|
||||||
|
import org.nl.wms.pda_manage.palletio.service.dto.LabelValueVo;
|
||||||
import org.nl.wms.stor_manage.io.service.dto.StorInvQuery;
|
import org.nl.wms.stor_manage.io.service.dto.StorInvQuery;
|
||||||
import org.nl.wms.stor_manage.io.service.iostor.IStIvtIostorinvService;
|
import org.nl.wms.stor_manage.io.service.iostor.IStIvtIostorinvService;
|
||||||
import org.nl.wms.stor_manage.io.service.iostor.dao.StIvtIostorinv;
|
import org.nl.wms.stor_manage.io.service.iostor.dao.StIvtIostorinv;
|
||||||
@@ -42,31 +44,48 @@ public class PalletStIvtIostorinvController {
|
|||||||
@Autowired
|
@Autowired
|
||||||
private PalletIostorinvService palletIostorinvService;
|
private PalletIostorinvService palletIostorinvService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 手持托盘入库
|
||||||
|
* @param form
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
@PostMapping("in")
|
@PostMapping("in")
|
||||||
@SaIgnore
|
@SaIgnore
|
||||||
@Log("手持托盘入库")
|
@Log("手持托盘入库")
|
||||||
public ResponseEntity<Object> inStorage(@RequestBody JSONObject form) {
|
public ResponseEntity<TableDataInfo> inStorage(@RequestBody JSONObject form) {
|
||||||
palletIostorinvService.inStorage(form);
|
palletIostorinvService.inStorage(form);
|
||||||
return new ResponseEntity<>(TableDataInfo.build(),HttpStatus.OK);
|
return new ResponseEntity<>(TableDataInfo.build(),HttpStatus.OK);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 手持托盘出库
|
||||||
|
* @param form
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
@PostMapping("out")
|
@PostMapping("out")
|
||||||
@SaIgnore
|
@SaIgnore
|
||||||
@Log("手持托盘出库")
|
@Log("手持托盘出库")
|
||||||
public ResponseEntity<Object> outStorage(@RequestBody JSONObject form) {
|
public ResponseEntity<TableDataInfo> outStorage(@RequestBody JSONObject form) {
|
||||||
palletIostorinvService.outStorage(form);
|
palletIostorinvService.outStorage(form);
|
||||||
return new ResponseEntity<>(TableDataInfo.build(),HttpStatus.OK);
|
return new ResponseEntity<>(TableDataInfo.build(),HttpStatus.OK);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 托盘出库出库点
|
||||||
|
* @return
|
||||||
|
* @throws InterruptedException
|
||||||
|
*/
|
||||||
@RequestMapping("targetPoint")
|
@RequestMapping("targetPoint")
|
||||||
@SaIgnore
|
@SaIgnore
|
||||||
@Log("手持托盘出库点")
|
@Log("手持托盘出库点")
|
||||||
public ResponseEntity<Object> targetPoint() {
|
public ResponseEntity<List<LabelValueVo>> targetPoint() throws InterruptedException {
|
||||||
List<Object> result = new ArrayList<>();
|
List<LabelValueVo> result = new ArrayList<>();
|
||||||
for (String label : Pallet_OutPoint.keySet()) {
|
for (String label : Pallet_OutPoint.keySet()) {
|
||||||
String value = Pallet_OutPoint.get(label);
|
String value = Pallet_OutPoint.get(label);
|
||||||
result.add(MapOf.of("label",value,value));
|
result.add(new LabelValueVo(label,value));
|
||||||
}
|
}
|
||||||
return new ResponseEntity<>(TableDataInfo.build(result),HttpStatus.OK);
|
Thread.sleep(5000);
|
||||||
|
return new ResponseEntity<>(result,HttpStatus.OK);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ import java.util.stream.Collectors;
|
|||||||
@Service
|
@Service
|
||||||
public class PickingService {
|
public class PickingService {
|
||||||
|
|
||||||
private static Map<String, String> Pick_Convery = MapOf.of("1309", "1207", "1311", "1209");
|
private static Map<String, String> Pick_Convery = MapOf.of("1308", "1207", "1311", "1209");
|
||||||
@Autowired
|
@Autowired
|
||||||
private IPmFormDataService iFormDataService;
|
private IPmFormDataService iFormDataService;
|
||||||
@Autowired
|
@Autowired
|
||||||
|
|||||||
@@ -23,6 +23,7 @@ import com.alibaba.fastjson.JSONObject;
|
|||||||
import com.wf.captcha.base.Captcha;
|
import com.wf.captcha.base.Captcha;
|
||||||
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.nl.common.anno.Log;
|
||||||
import org.nl.common.utils.RedisUtils;
|
import org.nl.common.utils.RedisUtils;
|
||||||
import org.nl.common.utils.SecurityUtils;
|
import org.nl.common.utils.SecurityUtils;
|
||||||
|
|
||||||
@@ -66,6 +67,7 @@ public class AuthorizationController {
|
|||||||
|
|
||||||
//("登录授权")
|
//("登录授权")
|
||||||
@PostMapping(value = "/login")
|
@PostMapping(value = "/login")
|
||||||
|
@Log("手持登入接口")
|
||||||
public ResponseEntity<Object> login(@RequestBody JSONObject authMap) throws Exception {
|
public ResponseEntity<Object> login(@RequestBody JSONObject authMap) throws Exception {
|
||||||
return new ResponseEntity(userService.login(authMap),HttpStatus.OK);
|
return new ResponseEntity(userService.login(authMap),HttpStatus.OK);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ package org.nl.wms.system_manage.service.secutiry.impl;
|
|||||||
import cn.dev33.satoken.secure.SaSecureUtil;
|
import cn.dev33.satoken.secure.SaSecureUtil;
|
||||||
import cn.dev33.satoken.stp.SaLoginModel;
|
import cn.dev33.satoken.stp.SaLoginModel;
|
||||||
import cn.dev33.satoken.stp.StpUtil;
|
import cn.dev33.satoken.stp.StpUtil;
|
||||||
|
import cn.hutool.core.lang.Assert;
|
||||||
import cn.hutool.core.map.MapUtil;
|
import cn.hutool.core.map.MapUtil;
|
||||||
import cn.hutool.core.util.StrUtil;
|
import cn.hutool.core.util.StrUtil;
|
||||||
import com.alibaba.fastjson.JSON;
|
import com.alibaba.fastjson.JSON;
|
||||||
@@ -13,8 +14,10 @@ import lombok.extern.slf4j.Slf4j;
|
|||||||
import org.nl.common.domain.exception.BadRequestException;
|
import org.nl.common.domain.exception.BadRequestException;
|
||||||
import org.nl.common.utils.RedisUtils;
|
import org.nl.common.utils.RedisUtils;
|
||||||
|
|
||||||
|
import org.nl.common.utils.RsaUtils;
|
||||||
import org.nl.wms.system_manage.service.role.ISysRoleService;
|
import org.nl.wms.system_manage.service.role.ISysRoleService;
|
||||||
import org.nl.wms.system_manage.service.secutiry.HandLoginService;
|
import org.nl.wms.system_manage.service.secutiry.HandLoginService;
|
||||||
|
import org.nl.wms.system_manage.service.secutiry.dto.AuthUserDto;
|
||||||
import org.nl.wms.system_manage.service.user.ISysUserService;
|
import org.nl.wms.system_manage.service.user.ISysUserService;
|
||||||
import org.nl.wms.system_manage.service.user.dao.SysUser;
|
import org.nl.wms.system_manage.service.user.dao.SysUser;
|
||||||
import org.nl.wms.system_manage.service.user.dto.CurrentUser;
|
import org.nl.wms.system_manage.service.user.dto.CurrentUser;
|
||||||
@@ -31,7 +34,7 @@ public class HandLoginServiceImpl implements HandLoginService {
|
|||||||
@Autowired
|
@Autowired
|
||||||
private RedisUtils redisUtils;
|
private RedisUtils redisUtils;
|
||||||
@Autowired
|
@Autowired
|
||||||
private ISysUserService userService;
|
private ISysUserService iSysUserService;
|
||||||
@Autowired
|
@Autowired
|
||||||
private ISysRoleService roleService;
|
private ISysRoleService roleService;
|
||||||
|
|
||||||
@@ -39,50 +42,32 @@ public class HandLoginServiceImpl implements HandLoginService {
|
|||||||
@SneakyThrows
|
@SneakyThrows
|
||||||
@Override
|
@Override
|
||||||
public Map<String, Object> handleLogin(Map<String, String> param) {
|
public Map<String, Object> handleLogin(Map<String, String> param) {
|
||||||
JSONObject resultJson = new JSONObject();
|
Assert.notNull(param,"请求参数不能为空");
|
||||||
MapUtil.getStr(param, "user");
|
SysUser userInfo = iSysUserService.getOne(new QueryWrapper<SysUser>().eq("username",param.get("user")));
|
||||||
String userName = MapUtil.getStr(param, "user");
|
if (userInfo == null||!userInfo.getPassword().equals(SaSecureUtil.md5BySalt(RsaUtils.decryptByPrivateKey(RsaUtils.KEY, param.get("password")), "salt"))) { // 这里需要密码加密
|
||||||
String password = MapUtil.getStr(param, "password");
|
throw new BadRequestException("账号或密码错误");
|
||||||
if (StrUtil.isEmpty(userName)) {
|
|
||||||
throw new BadRequestException("用户不能为空");
|
|
||||||
}
|
}
|
||||||
if (StrUtil.isEmpty("device_id")) {
|
if (!userInfo.getIs_used()) {
|
||||||
resultJson.put("code", "0");
|
throw new BadRequestException("账号未激活");
|
||||||
resultJson.put("desc", "设备不能为空");
|
|
||||||
}
|
}
|
||||||
if (StrUtil.isEmpty(password)) {
|
List<String> permissionList = roleService.getPermissionList((JSONObject) JSON.toJSON(userInfo));
|
||||||
throw new BadRequestException("密码不能为空!");
|
|
||||||
}
|
|
||||||
SysUser userInfo = userService.getOne(new QueryWrapper<SysUser>().eq("username", userName));// 拿不到已经抛出异常
|
|
||||||
if(!SaSecureUtil.md5BySalt(userInfo.getPassword(), "salt").equals(SaSecureUtil.md5BySalt(password, "salt"))){
|
|
||||||
throw new BadRequestException("密码错误");
|
|
||||||
}
|
|
||||||
|
|
||||||
// 获取权限列表 - 登录查找权限
|
|
||||||
List<String> permissionList = roleService.getPermissionList(JSONObject.parseObject(JSON.toJSONString(userInfo)));
|
|
||||||
// 登录输入,登出删除
|
// 登录输入,登出删除
|
||||||
CurrentUser user = new CurrentUser();
|
CurrentUser user = new CurrentUser();
|
||||||
user.setId(userInfo.getUser_id());
|
user.setId(userInfo.getUser_id());
|
||||||
user.setUsername(userInfo.getUsername());
|
user.setUsername(userInfo.getUsername());
|
||||||
user.setPresonName(userInfo.getPerson_name());
|
user.setPresonName((userInfo.getPerson_name()));
|
||||||
user.setUser(userInfo);
|
user.setUser(userInfo);
|
||||||
user.setPermissions(permissionList);
|
user.setPermissions(permissionList);
|
||||||
|
|
||||||
// SaLoginModel 配置登录相关参数
|
// SaLoginModel 配置登录相关参数
|
||||||
StpUtil.login(userInfo.getUser_id(), new SaLoginModel()
|
StpUtil.login(userInfo.getUser_id(), new SaLoginModel()
|
||||||
.setDevice("PE") // 此次登录的客户端设备类型, 用于[同端互斥登录]时指定此次登录的设备类型
|
.setDevice("PC") // 此次登录的客户端设备类型, 用于[同端互斥登录]时指定此次登录的设备类型
|
||||||
.setExtra("loginInfo", JSONObject.toJSONString(user)) // Token挂载的扩展参数 (此方法只有在集成jwt插件时才会生效)
|
.setExtra("loginInfo", JSONObject.toJSONString(user)) // Token挂载的扩展参数 (此方法只有在集成jwt插件时才会生效)
|
||||||
);
|
);
|
||||||
|
JSONObject result = new JSONObject();
|
||||||
// 返回 token 与 用户信息
|
result.put("token", StpUtil.getTokenValue());
|
||||||
JSONObject jsonObject = new JSONObject();
|
result.put("roles", permissionList);
|
||||||
jsonObject.put("user", userInfo);
|
result.put("user", user);
|
||||||
Map<String, Object> authInfo = new HashMap<String, Object>(2) {{
|
return result;
|
||||||
put("token", StpUtil.getTokenValue());
|
|
||||||
put("user", jsonObject);
|
|
||||||
}};
|
|
||||||
redisUtils.set("pe-satoken", StpUtil.getTokenValue(), StpUtil.getTokenTimeout());
|
|
||||||
return authInfo;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -90,6 +90,7 @@ security:
|
|||||||
- /api/param/getValueByCode
|
- /api/param/getValueByCode
|
||||||
- /plumelog/**
|
- /plumelog/**
|
||||||
- /api/esLog/**
|
- /api/esLog/**
|
||||||
|
- /api/bigScreenScreen/**
|
||||||
- /api/users
|
- /api/users
|
||||||
mybatis-plus:
|
mybatis-plus:
|
||||||
configuration:
|
configuration:
|
||||||
|
|||||||
Reference in New Issue
Block a user