|  |  |  | @ -36,6 +36,7 @@ import javax.annotation.Resource; | 
			
		
	
		
			
				
					|  |  |  |  | import javax.servlet.http.HttpServletRequest; | 
			
		
	
		
			
				
					|  |  |  |  | import javax.validation.Valid; | 
			
		
	
		
			
				
					|  |  |  |  | import java.util.*; | 
			
		
	
		
			
				
					|  |  |  |  | import java.util.stream.Collectors; | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  | /** | 
			
		
	
		
			
				
					|  |  |  |  |  * 登录相关 | 
			
		
	
	
		
			
				
					|  |  |  | @ -125,6 +126,85 @@ public class LoginController extends BaseController { | 
			
		
	
		
			
				
					|  |  |  |  |         return ResultVOUtils.success(loginResponse); | 
			
		
	
		
			
				
					|  |  |  |  |     } | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |     /** | 
			
		
	
		
			
				
					|  |  |  |  |      * 用户登录 | 
			
		
	
		
			
				
					|  |  |  |  |      * | 
			
		
	
		
			
				
					|  |  |  |  |      * @return | 
			
		
	
		
			
				
					|  |  |  |  |      */ | 
			
		
	
		
			
				
					|  |  |  |  |     @PostMapping(value = "/pda/login") | 
			
		
	
		
			
				
					|  |  |  |  |     public BaseResponse pdaLogin(@RequestBody @Valid LoginRequest loginRequest, | 
			
		
	
		
			
				
					|  |  |  |  |                                  BindingResult bindingResult, | 
			
		
	
		
			
				
					|  |  |  |  |                                  HttpServletRequest request) { | 
			
		
	
		
			
				
					|  |  |  |  |         if (bindingResult.hasErrors()) { | 
			
		
	
		
			
				
					|  |  |  |  |             return ResultVOUtils.error(ResultEnum.PARAM_VERIFY_FALL, bindingResult.getFieldError().getDefaultMessage()); | 
			
		
	
		
			
				
					|  |  |  |  |         } | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |         AuthAdmin authAdmin = authAdminService.findByUserName(loginRequest.getUsername()); | 
			
		
	
		
			
				
					|  |  |  |  |         if (authAdmin == null) { | 
			
		
	
		
			
				
					|  |  |  |  |             throw new JsonException(ResultEnum.DATA_NOT, "用户名或密码错误"); | 
			
		
	
		
			
				
					|  |  |  |  |         } | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |         if (!PasswordUtils.authAdminPwd(loginRequest.getPassword()).equals(authAdmin.getPassWord())) { | 
			
		
	
		
			
				
					|  |  |  |  |             throw new JsonException(ResultEnum.DATA_NOT, "用户名或密码错误"); | 
			
		
	
		
			
				
					|  |  |  |  |         } | 
			
		
	
		
			
				
					|  |  |  |  |         if (authAdmin.getUserFlag() == 0) { | 
			
		
	
		
			
				
					|  |  |  |  |             throw new JsonException(ResultEnum.DATA_NOT, "该用户已被禁用!"); | 
			
		
	
		
			
				
					|  |  |  |  |         } | 
			
		
	
		
			
				
					|  |  |  |  |         SysPdaKeyEntity sysPdaKeyEntity = sysPdaKeyService.findDeviceByImei(loginRequest.getImei()); | 
			
		
	
		
			
				
					|  |  |  |  |         if (sysPdaKeyEntity == null) { | 
			
		
	
		
			
				
					|  |  |  |  |             return ResultVOUtils.error(410, "该设备未注册"); | 
			
		
	
		
			
				
					|  |  |  |  |         } else if (sysPdaKeyEntity.getIsCheck() == 0) { | 
			
		
	
		
			
				
					|  |  |  |  |             return ResultVOUtils.error(411, "该设备登记审核中,请等待,或联系管理员"); | 
			
		
	
		
			
				
					|  |  |  |  |         } else if (sysPdaKeyEntity.getIsCheck() == 2) { | 
			
		
	
		
			
				
					|  |  |  |  |             return ResultVOUtils.error(412, "该设备被拒绝登录,请联系管理员!"); | 
			
		
	
		
			
				
					|  |  |  |  |         } | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |         // 更新登录状态
 | 
			
		
	
		
			
				
					|  |  |  |  |         AuthAdmin authAdminUp = new AuthAdmin(); | 
			
		
	
		
			
				
					|  |  |  |  |         authAdminUp.setId(authAdmin.getId()); | 
			
		
	
		
			
				
					|  |  |  |  |         authAdminUp.setLastLoginTime(new Date()); | 
			
		
	
		
			
				
					|  |  |  |  |         authAdminUp.setLastLoginIp(IpUtils.getIpAddr(request)); | 
			
		
	
		
			
				
					|  |  |  |  |         authAdminService.updateAuthAdmin(authAdminUp); | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |         // 登录成功后获取权限,这里面会设置到缓存
 | 
			
		
	
		
			
				
					|  |  |  |  | //        authLoginService.listRuleByAdminId(authAdmin.getId());
 | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |         Map<String, Object> claims = new HashMap<>(); | 
			
		
	
		
			
				
					|  |  |  |  |         claims.put("admin_id", authAdmin.getId()); | 
			
		
	
		
			
				
					|  |  |  |  |         String token = JwtUtils.createToken(claims, 86400L); // 一天后过期
 | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |         Map<String, Object> map = new HashMap<>(); | 
			
		
	
		
			
				
					|  |  |  |  |         map.put("id", authAdmin.getId()); | 
			
		
	
		
			
				
					|  |  |  |  |         map.put("token", token); | 
			
		
	
		
			
				
					|  |  |  |  |         map.put("time", MsDateUtil.getDateTime()); | 
			
		
	
		
			
				
					|  |  |  |  |         LoginResponse loginResponse = new LoginResponse(); | 
			
		
	
		
			
				
					|  |  |  |  |         loginResponse.setId(authAdmin.getId() + ""); | 
			
		
	
		
			
				
					|  |  |  |  |         loginResponse.setToken(token); | 
			
		
	
		
			
				
					|  |  |  |  |         loginResponse.setDept(authAdmin.getLocDeptCode()); | 
			
		
	
		
			
				
					|  |  |  |  |         loginResponse.setDeptName(authAdmin.getDeptName()); | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |         List<SysMenu> sysMenus = menuService.selectMenuList(authAdmin.getId()); | 
			
		
	
		
			
				
					|  |  |  |  | //        .stream().filter(item -> item.getMenuName().equals("单据管理")).findFirst().get().getChildren().
 | 
			
		
	
		
			
				
					|  |  |  |  |         List<PdaMainItemEntity> menus = sysMenus.stream().filter( | 
			
		
	
		
			
				
					|  |  |  |  |                 item -> | 
			
		
	
		
			
				
					|  |  |  |  |                         item.getComponent() != null && (item.getComponent().equals("inout/IoCreateScanOrder") | 
			
		
	
		
			
				
					|  |  |  |  |                                 || item.getComponent().equals("inout/IoDealOrder") | 
			
		
	
		
			
				
					|  |  |  |  |                                 || item.getComponent().equals("inout/IoDealCheckOrder") | 
			
		
	
		
			
				
					|  |  |  |  |                                 || item.getComponent().equals("inout/IoCheckSuccessOrder") | 
			
		
	
		
			
				
					|  |  |  |  |                                 || item.getComponent().equals("inout/IoCheckAuditOrder") | 
			
		
	
		
			
				
					|  |  |  |  |                         ) | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |         ).distinct().map(item -> | 
			
		
	
		
			
				
					|  |  |  |  |                 new PdaMainItemEntity(item.getMenuName(), item.getComponent()) | 
			
		
	
		
			
				
					|  |  |  |  |         ).collect(Collectors.toList()); | 
			
		
	
		
			
				
					|  |  |  |  |         loginResponse.setMenus(menus); | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |         logininforService.recordLogininfor(authAdmin.getEmployeeName(), Constant.LOGIN_SUCCESS, "登录成功!", request); | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |         return ResultVOUtils.success(loginResponse); | 
			
		
	
		
			
				
					|  |  |  |  |     } | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |     /** | 
			
		
	
		
			
				
					|  |  |  |  |      * 用户登录 | 
			
		
	
		
			
				
					|  |  |  |  |      * | 
			
		
	
	
		
			
				
					|  |  |  | 
 |