From d0226747665355acecd5b4f2b5c0beb020586729 Mon Sep 17 00:00:00 2001 From: skyouc Date: 星期五, 17 一月 2025 15:37:32 +0800 Subject: [PATCH] # 23. PDA拣货单据,勾选或点击确认按钮后,完成当前单据 (已完成) 24. PDA出库成功后,界面数据重置,避免重复操作 (已修复) 25. PDA接口请求,添加一个Loading遮档 (已修复) 27. 非平库单据,在平库可做入库操作 (已修复) 28. 平库已组拖数据,组拖完成后依然可组拖 (已修复) 29. 平库入库后,订单明细没有添加(已修复) 30. 平库入库后,单据类型没有修改(已修复) 31. 没有绑定播种位,不能进行播种,前后端都需加判定(已修复) 33. 平库入库未修改入库已完成数量(已修复) 34. cacheSite缓存站点逻辑需重新梳理,入库生成波次时(已完成) 35. PDA添加发货确认,默认全选 (已修复) 36. 大屏获取任务时,是由容器到达的拖盘码确认通知 (已修复) 37. 拣货单序号不显示 问题修复 (已修复) 42. pda发货确认,添加不同颜色区分是否全部完成拣货,绿色全部拣货完成,红色完成部分拣货(已修复) 43. CTU入库完成后,订单明细没有删除,执行中数量清空(已修复) 44. 平库入库完成后,历史档明细完成数量没有更新 (已修复) 45. PDA料号不显示 (已修复) 46. 发货完成后,波次管理数据未加入历史档 (已修复) --- zy-asrs-wms/src/main/java/com/zy/asrs/wms/system/controller/AuthController.java | 488 +++++++++++++++++++++++++++++------------------------- 1 files changed, 263 insertions(+), 225 deletions(-) diff --git a/zy-asrs-wms/src/main/java/com/zy/asrs/wms/system/controller/AuthController.java b/zy-asrs-wms/src/main/java/com/zy/asrs/wms/system/controller/AuthController.java index 8b4a520..9b2fcc2 100644 --- a/zy-asrs-wms/src/main/java/com/zy/asrs/wms/system/controller/AuthController.java +++ b/zy-asrs-wms/src/main/java/com/zy/asrs/wms/system/controller/AuthController.java @@ -1,225 +1,263 @@ -package com.zy.asrs.wms.system.controller; - -import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; -import com.zy.asrs.common.domain.enums.LoginSystemType; -import com.zy.asrs.framework.annotations.ManagerAuth; -import com.zy.asrs.framework.common.Cools; -import com.zy.asrs.framework.common.R; -import com.zy.asrs.framework.exception.CoolException; -import com.zy.asrs.wms.common.annotation.OperationLog; -import com.zy.asrs.wms.common.config.ConfigProperties; -import com.zy.asrs.wms.common.security.JwtSubject; -import com.zy.asrs.wms.system.controller.param.LoginParam; -import com.zy.asrs.wms.system.controller.param.UpdatePasswordParam; -import com.zy.asrs.wms.system.controller.result.LoginResult; -import com.zy.asrs.wms.system.entity.*; -import com.zy.asrs.wms.system.service.*; -import com.zy.asrs.wms.utils.JwtUtil; -import com.zy.asrs.wms.utils.Utils; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.web.bind.annotation.*; - -import javax.annotation.Resource; -import javax.servlet.http.HttpServletRequest; -import java.util.ArrayList; -import java.util.List; - -/** - * 璁よ瘉鎺у埗鍣� - * - * Created by vincent on 1/30/2024 - */ -@RestController -@RequestMapping("/api") -public class AuthController extends BaseController { - - @Resource - private ConfigProperties configProperties; - @Resource - private UserService userService; - @Resource - private UserLoginService userLoginService; - @Resource - private RoleMenuService roleMenuService; - @Resource - private HostService hostService; - @Resource - private UserRoleService userRoleService; - @Resource - private MenuService menuService; - - @PostMapping("/login") - public R login(@RequestBody LoginParam param, HttpServletRequest request) { - String username = param.getUsername(); - Long hostId = param.getHostId(); - User user = userService.getByUsername(username, hostId); - if (user == null) { - return R.error("璐﹀彿涓嶅瓨鍦�"); - } - if (!user.getStatus().equals(1)) { - return R.error("璐﹀彿琚喕缁�"); - } - if (!userService.comparePassword(user.getPassword(), param.getPassword())) { - return R.error("瀵嗙爜閿欒"); - } - String accessToken = JwtUtil.buildToken(new JwtSubject(username, user.getHostId()), - configProperties.getTokenExpireTime(), configProperties.getTokenKey()); - userLoginService.saveAsync(user.getId(), accessToken, UserLogin.TYPE_LOGIN, hostId, null, request); - return R.ok("鐧诲綍鎴愬姛").add(new LoginResult(accessToken, user)); - } - - @GetMapping("/auth/user") - public R userInfo() { - return R.ok(userService.getByIdRel(getLoginUserId())); - } - - @GetMapping("/auth/menu") - public R userMenu() { - boolean superRole = false;//瓒呯骇绠$悊鍛� - User loginUser = getLoginUser(); - List<Role> roles = userRoleService.listByUserId(loginUser.getId()); - for (Role role : roles) { - if (role.getId() == 1) { - superRole = true; - } - } - - List<Menu> menus = null; - if (superRole) { - menus = roleMenuService.listMenuByUserId(null, Menu.TYPE_MENU, getHostId()); - }else { - menus = roleMenuService.listMenuByUserId(getLoginUserId(), Menu.TYPE_MENU, getHostId()); - } - return R.ok().add(Utils.toTreeData(menus, 0L, Menu::getParentId, Menu::getId, Menu::setChildren)); - } - - @GetMapping("/auth/host") - public R authHost() { - List<Host> list = hostService.list(); - return R.ok().add(list); - } - - @PreAuthorize("hasAuthority('sys:auth:user')") - @OperationLog - @PutMapping("/auth/user") - public R updateInfo(@RequestBody User user) { - user.setId(getLoginUserId()); - // 涓嶈兘淇敼鐨勫瓧娈� - user.setUsername(null); - user.setPassword(null); - user.setEmailVerified(null); - user.setHostId(null); - user.setStatus(null); - if (userService.updateById(user)) { - return R.ok().add(userService.getByIdRel(user.getId())); - } - return R.error("淇濆瓨澶辫触"); - } - - @PreAuthorize("hasAuthority('sys:auth:password')") - @OperationLog - @PutMapping("/auth/password") - public R updatePassword(@RequestBody UpdatePasswordParam param) { - if (Cools.isEmpty(param.getOldPassword(), param.getPassword())) { - return R.error("鍙傛暟涓嶈兘涓虹┖"); - } - Long userId = getLoginUserId(); - if (userId == null) { - return R.error("鏈櫥褰�"); - } - if (!userService.comparePassword(userService.getById(userId).getPassword(), param.getOldPassword())) { - return R.error("鍘熷瘑鐮佽緭鍏ヤ笉姝g‘"); - } - User user = new User(); - user.setId(userId); - user.setPassword(userService.encodePassword(param.getPassword())); - if (userService.updateById(user)) { - return R.ok("淇敼鎴愬姛"); - } - return R.error("淇敼澶辫触"); - } - - @GetMapping("/auth/router") - public R router() { - List<UserRole> userRoles = userRoleService.list(new LambdaQueryWrapper<UserRole>().eq(UserRole::getUserId, getLoginUserId())); - if (userRoles.isEmpty()) { - return R.error(); - } - - boolean superRole = false;//瓒呯骇绠$悊鍛� - ArrayList<Long> roles = new ArrayList<>(); - for (UserRole userRole : userRoles) { - roles.add(userRole.getRoleId()); - if (userRole.getRoleId() == 1) { - superRole = true; - } - } - - ArrayList<Long> menus = new ArrayList<>(); - if(superRole) { - List<Menu> allMenus = menuService.selectByHostId(getHostId()); - for (Menu menu : allMenus) { - if(!menus.contains(menu.getId())) { - menus.add(menu.getId()); - } - } - }else { - List<RoleMenu> roleMenus = roleMenuService.list(new LambdaQueryWrapper<RoleMenu>().in(RoleMenu::getRoleId, roles)); - for (RoleMenu roleMenu : roleMenus) { - if(!menus.contains(roleMenu.getMenuId())) { - menus.add(roleMenu.getMenuId()); - } - } - } - - List<Menu> menuList = menuService.list(new LambdaQueryWrapper<Menu>() - .in(Menu::getId, menus) - .eq(Menu::getType, Menu.TYPE_MENU) - .orderByAsc(Menu::getId)); - - return R.ok().add(menuList); - } - - @RequestMapping("/show/host.action") - @ManagerAuth - public R showHosts() { - Long hostId = getHostId(); - String hostName = null; - if (hostId != null) { - Host host = hostService.getById(hostId); - if (host != null) { - hostName = host.getName(); - } - } - boolean root = false; - List<Role> roles = userRoleService.listByUserId(getLoginUserId()); - for (Role role : roles) { - if (role.getId() == 1) { - root = true; - break; - } - } - return R.ok().add(Cools - .add("root", root) - .add("host", hostId == null) - .add("hostId", hostId) - .add("hostName", hostName) - ); - } - - @RequestMapping(value = "/root/change/host/auth") - @ManagerAuth - public R rootChangeHost(@RequestParam Long hostId) { - UserLogin userLogin = userLoginService.superFindByUserId(getLoginUserId(), String.valueOf(LoginSystemType.WMS)); - if (userLogin != null) { - userLogin.setHostId(hostId); - if (!userLoginService.updateById(userLogin)) { - throw new CoolException("淇敼鍟嗘埛澶辫触"); - } - return R.ok(); - } else { - return R.error(); - } - } - -} +package com.zy.asrs.wms.system.controller; + +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.zy.asrs.common.domain.CodeRes; +import com.zy.asrs.common.domain.enums.LoginSystemType; +import com.zy.asrs.common.utils.BarcodeUtils; +import com.zy.asrs.common.utils.QrCode; +import com.zy.asrs.framework.annotations.ManagerAuth; +import com.zy.asrs.framework.common.BaseRes; +import com.zy.asrs.framework.common.Cools; +import com.zy.asrs.framework.common.R; +import com.zy.asrs.framework.exception.CoolException; +import com.zy.asrs.wms.common.annotation.OperationLog; +import com.zy.asrs.wms.common.config.ConfigProperties; +import com.zy.asrs.wms.common.security.JwtSubject; +import com.zy.asrs.wms.system.controller.param.LoginParam; +import com.zy.asrs.wms.system.controller.param.UpdatePasswordParam; +import com.zy.asrs.wms.system.controller.result.LoginResult; +import com.zy.asrs.wms.system.entity.*; +import com.zy.asrs.wms.system.license.timer.LicenseTimer; +import com.zy.asrs.wms.system.service.*; +import com.zy.asrs.wms.utils.JwtUtil; +import com.zy.asrs.wms.utils.Utils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.web.bind.annotation.*; + +import javax.annotation.Resource; +import javax.imageio.ImageIO; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.awt.image.BufferedImage; +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; + +/** + * 璁よ瘉鎺у埗鍣� + * + * Created by vincent on 1/30/2024 + */ +@RestController +@RequestMapping("/api") +public class AuthController extends BaseController { + + @Resource + private ConfigProperties configProperties; + @Resource + private UserService userService; + @Resource + private UserLoginService userLoginService; + @Resource + private RoleMenuService roleMenuService; + @Resource + private HostService hostService; + @Resource + private UserRoleService userRoleService; + @Resource + private MenuService menuService; + @Autowired + private LicenseTimer licenseTimer; + + @PostMapping("/login") + public R login(@RequestBody LoginParam param, HttpServletRequest request) { + if (!licenseTimer.getSystemSupport()) {//璁稿彲璇佸凡澶辨晥 + return R.parse(CodeRes.SYSTEM_20001); + } + String username = param.getUsername(); + Long hostId = param.getHostId(); + User user = userService.getByUsername(username, hostId); + if (user == null) { + return R.error("璐﹀彿涓嶅瓨鍦�"); + } + if (!user.getStatus().equals(1)) { + return R.error("璐﹀彿琚喕缁�"); + } + if (!userService.comparePassword(user.getPassword(), param.getPassword())) { + return R.error("瀵嗙爜閿欒"); + } + String accessToken = JwtUtil.buildToken(new JwtSubject(username, user.getHostId()), + configProperties.getTokenExpireTime(), configProperties.getTokenKey()); + userLoginService.saveAsync(user.getId(), accessToken, UserLogin.TYPE_LOGIN, hostId, null, request); + return R.ok("鐧诲綍鎴愬姛").add(new LoginResult(accessToken, user)); + } + + @GetMapping("/auth/user") + public R userInfo() { + return R.ok(userService.getByIdRel(getLoginUserId())); + } + + @GetMapping("/auth/menu") + public R userMenu() { + boolean superRole = false;//瓒呯骇绠$悊鍛� + User loginUser = getLoginUser(); + List<Role> roles = userRoleService.listByUserId(loginUser.getId()); + for (Role role : roles) { + if (role.getId() == 1) { + superRole = true; + } + } + + List<Menu> menus = null; + if (superRole) { + menus = roleMenuService.listMenuByUserId(null, Menu.TYPE_MENU, getHostId()); + }else { + menus = roleMenuService.listMenuByUserId(getLoginUserId(), Menu.TYPE_MENU, getHostId()); + } + return R.ok().add(Utils.toTreeData(menus, 0L, Menu::getParentId, Menu::getId, Menu::setChildren)); + } + + @GetMapping("/auth/host") + public R authHost() { + List<Host> list = hostService.list(); + return R.ok().add(list); + } + + @PreAuthorize("hasAuthority('sys:auth:user')") + @OperationLog + @PutMapping("/auth/user") + public R updateInfo(@RequestBody User user) { + user.setId(getLoginUserId()); + // 涓嶈兘淇敼鐨勫瓧娈� + user.setUsername(null); + user.setPassword(null); + user.setEmailVerified(null); + user.setHostId(null); + user.setStatus(null); + if (userService.updateById(user)) { + return R.ok().add(userService.getByIdRel(user.getId())); + } + return R.error("淇濆瓨澶辫触"); + } + + @PreAuthorize("hasAuthority('sys:auth:password')") + @OperationLog + @PutMapping("/auth/password") + public R updatePassword(@RequestBody UpdatePasswordParam param) { + if (Cools.isEmpty(param.getOldPassword(), param.getPassword())) { + return R.error("鍙傛暟涓嶈兘涓虹┖"); + } + Long userId = getLoginUserId(); + if (userId == null) { + return R.error("鏈櫥褰�"); + } + if (!userService.comparePassword(userService.getById(userId).getPassword(), param.getOldPassword())) { + return R.error("鍘熷瘑鐮佽緭鍏ヤ笉姝g‘"); + } + User user = new User(); + user.setId(userId); + user.setPassword(userService.encodePassword(param.getPassword())); + if (userService.updateById(user)) { + return R.ok("淇敼鎴愬姛"); + } + return R.error("淇敼澶辫触"); + } + + @GetMapping("/auth/router") + public R router() { + List<UserRole> userRoles = userRoleService.list(new LambdaQueryWrapper<UserRole>().eq(UserRole::getUserId, getLoginUserId())); + if (userRoles.isEmpty()) { + return R.error("璇峰厛鍒嗛厤瑙掕壊"); + } + + boolean superRole = false;//瓒呯骇绠$悊鍛� + ArrayList<Long> roles = new ArrayList<>(); + for (UserRole userRole : userRoles) { + roles.add(userRole.getRoleId()); + if (userRole.getRoleId() == 1) { + superRole = true; + } + } + + ArrayList<Long> menus = new ArrayList<>(); + if(superRole) { + List<Menu> allMenus = menuService.selectByHostId(getHostId()); + for (Menu menu : allMenus) { + if(!menus.contains(menu.getId())) { + menus.add(menu.getId()); + } + } + }else { + List<RoleMenu> roleMenus = roleMenuService.list(new LambdaQueryWrapper<RoleMenu>().in(RoleMenu::getRoleId, roles)); + for (RoleMenu roleMenu : roleMenus) { + if(!menus.contains(roleMenu.getMenuId())) { + menus.add(roleMenu.getMenuId()); + } + } + } + + List<Menu> menuList = menuService.list(new LambdaQueryWrapper<Menu>() + .in(Menu::getId, menus) + .eq(Menu::getType, Menu.TYPE_MENU) + .orderByAsc(Menu::getId)); + + return R.ok().add(menuList); + } + + @RequestMapping("/show/host.action") + @ManagerAuth + public R showHosts() { + Long hostId = getHostId(); + String hostName = null; + if (hostId != null) { + Host host = hostService.getById(hostId); + if (host != null) { + hostName = host.getName(); + } + } + boolean root = false; + List<Role> roles = userRoleService.listByUserId(getLoginUserId()); + for (Role role : roles) { + if (role.getId() == 1) { + root = true; + break; + } + } + return R.ok().add(Cools + .add("root", root) + .add("host", hostId == null) + .add("hostId", hostId) + .add("hostName", hostName) + ); + } + + @RequestMapping(value = "/root/change/host/auth") + @ManagerAuth + public R rootChangeHost(@RequestParam Long hostId) { + UserLogin userLogin = userLoginService.superFindByUserId(getLoginUserId(), String.valueOf(LoginSystemType.WMS)); + if (userLogin != null) { + userLogin.setHostId(hostId); + if (!userLoginService.updateById(userLogin)) { + throw new CoolException("淇敼鍟嗘埛澶辫触"); + } + return R.ok(); + } else { + return R.error(); + } + } + + @RequestMapping(value = "/code/auth") +// @ManagerAuth(memo = "鐗╂枡缂栫爜鏉″舰鐮佽幏鍙�(type:1(鏉″舰鐮�);2(浜岀淮鐮�)") + public R matCodeBarcode(@RequestParam(defaultValue = "1") Integer type + , @RequestParam String param + , HttpServletResponse response) throws Exception { + response.setContentType("image/jpg"); + if (Cools.isEmpty(param)){ + return R.parse(BaseRes.EMPTY); + } + BufferedImage img; + if (type == 1) { + img = BarcodeUtils.encode(param); + } else { + img = QrCode.createImg(param); + } + if (!ImageIO.write(img, "jpg", response.getOutputStream())) { + throw new IOException("Could not write an image of format jpg"); + } + response.getOutputStream().flush(); + response.getOutputStream().close(); + return R.ok(); + } + +} -- Gitblit v1.9.1