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