From 298c0bdb5553e0ddb1e8907862d5c5b6f5a9bf67 Mon Sep 17 00:00:00 2001 From: chenrui <1950717904@qq.com> Date: Thu, 21 Nov 2024 14:27:14 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=90=8C=E6=AD=A5=E5=B8=82?= =?UTF-8?q?=E8=AE=A4=E8=AF=81=E5=90=8C=E6=AD=A5=E7=94=A8=E6=88=B7=E5=88=A4?= =?UTF-8?q?=E6=96=AD=E6=9D=A1=E4=BB=B6=E4=BF=AE=E6=94=B9=20=E6=B7=B1i?= =?UTF-8?q?=E4=BC=81=E7=94=A8=E6=88=B7=E9=81=BF=E5=85=8D=E9=87=8D=E5=A4=8D?= =?UTF-8?q?=E5=8A=A0=E8=BD=BD=20=E5=B8=82=E7=9B=91=E6=89=AB=E7=A0=81?= =?UTF-8?q?=E5=90=8E=E5=8F=B0=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/AppThirdLoginController.java | 2 +- .../system/user/service/UserServiceImpl.java | 33 ++++++----- .../EnterpriseInformationServiceImpl.java | 56 +++++++++++++++---- 3 files changed, 63 insertions(+), 28 deletions(-) diff --git a/lib/EmergencyService/zdxtEmergencyAppService/src/main/java/com/zdxt/app/controller/AppThirdLoginController.java b/lib/EmergencyService/zdxtEmergencyAppService/src/main/java/com/zdxt/app/controller/AppThirdLoginController.java index 952d4c1c..c6fd52e5 100644 --- a/lib/EmergencyService/zdxtEmergencyAppService/src/main/java/com/zdxt/app/controller/AppThirdLoginController.java +++ b/lib/EmergencyService/zdxtEmergencyAppService/src/main/java/com/zdxt/app/controller/AppThirdLoginController.java @@ -292,7 +292,7 @@ public class AppThirdLoginController { //锁不存在: //1.加锁限制用户登录并发情况 if(!jedisUtil.exists(redisLock)){ - jedisUtil.isLock(redisLock,10); + jedisUtil.isLock(redisLock,100); log.info("redis用户登录加锁,加锁用户:{}",userInfo.toJSONString()); //添加深i企用户 Long userId = thirdLoginService.addSiqUser(userInfo); diff --git a/lib/EmergencyService/zdxtEmergencyAuthService/src/main/java/com/zdxt/auth/project/system/user/service/UserServiceImpl.java b/lib/EmergencyService/zdxtEmergencyAuthService/src/main/java/com/zdxt/auth/project/system/user/service/UserServiceImpl.java index 325572b5..ea94a44b 100644 --- a/lib/EmergencyService/zdxtEmergencyAuthService/src/main/java/com/zdxt/auth/project/system/user/service/UserServiceImpl.java +++ b/lib/EmergencyService/zdxtEmergencyAuthService/src/main/java/com/zdxt/auth/project/system/user/service/UserServiceImpl.java @@ -745,22 +745,25 @@ public class UserServiceImpl implements IUserService { //新增用户默认不删除标记 user.setDelFlag("0"); - User uniqueUser = null; - if (StringUtils.isNotEmpty(units)) { - uniqueUser = userMapper.selectUserByCertificateNumber(units); - } else { - uniqueUser = userMapper.selectUserByLoginName(jsonObject.getString("username")); - } - if (null != uniqueUser && uniqueUser.getUserId() != null) { - // 跟新数据库 - user.setUserId(uniqueUser.getUserId()); - int rowNum = userMapper.updateUser(user); - updateNum += rowNum; - } else { - // 插入数据库 - int rowNum = userMapper.insertUser(user); - insertNum += rowNum; + //限制只通过用户信息的username来判断,避免登录出现问题 + String username = jsonObject.getString("username"); + if(StringUtils.isNotEmpty(username)){ + UserSearchDto userSearchDto = new UserSearchDto(); + userSearchDto.setLoginName(username); + userSearchDto.setUserSource(0); + User uniqueUser = userMapper.selectClientUserByLoginName(userSearchDto); + if (null != uniqueUser && uniqueUser.getUserId() != null) { + // 更新数据库 + user.setUserId(uniqueUser.getUserId()); + int rowNum = userMapper.updateUser(user); + updateNum += rowNum; + } else { + // 插入数据库 + int rowNum = userMapper.insertUser(user); + insertNum += rowNum; + } } + } catch (Exception e) { continue; } diff --git a/lib/EmergencyService/zdxtLawEnforcementCodeService/src/main/java/com/zdxt/code/service/impl/EnterpriseInformationServiceImpl.java b/lib/EmergencyService/zdxtLawEnforcementCodeService/src/main/java/com/zdxt/code/service/impl/EnterpriseInformationServiceImpl.java index 29339c54..81142f33 100644 --- a/lib/EmergencyService/zdxtLawEnforcementCodeService/src/main/java/com/zdxt/code/service/impl/EnterpriseInformationServiceImpl.java +++ b/lib/EmergencyService/zdxtLawEnforcementCodeService/src/main/java/com/zdxt/code/service/impl/EnterpriseInformationServiceImpl.java @@ -1,11 +1,10 @@ package com.zdxt.code.service.impl; -import java.io.ByteArrayOutputStream; -import java.io.File; -import java.io.FileOutputStream; -import java.io.InputStream; +import java.io.*; import java.net.HttpURLConnection; +import java.net.MalformedURLException; import java.net.URL; +import java.net.URLConnection; import java.time.Instant; import java.time.LocalDateTime; import java.time.ZoneId; @@ -422,15 +421,19 @@ public class EnterpriseInformationServiceImpl implements IEnterpriseInformationS log.info("获取市监地址,地址为空:{}", url); return null; } - StringBuffer sb = new StringBuffer(url); - StringBuffer replace = sb.replace(7, 39, sjView); - //爬取页面统一信用代码 - String s = CrawlerUtil.getCreditCode(url); - if (StringUtils.isNotEmpty(s)) { -// EnterpriseInformation enterpriseInformation = -// enterpriseInformationMapper.selectEnterpriseInformationByNum(s); - EnterpriseInformation enterpriseInformation = ssztJbxx110497Service.selectSsztJbxx110497ByCode(s); + //获取路由中的cid + //解析路由获取企业统一信用代码 + String cid = getUrlParams(url, "cid"); + if(StringUtils.isNotEmpty(cid)){ + EnterpriseInformation enterpriseInformation = ssztJbxx110497Service.selectSsztJbxx110497ByCode(cid); return enterpriseInformation; + }else { + //爬取页面统一信用代码 + String s = CrawlerUtil.getCreditCode(url); + if (StringUtils.isNotEmpty(s)) { + EnterpriseInformation enterpriseInformation = ssztJbxx110497Service.selectSsztJbxx110497ByCode(s); + return enterpriseInformation; + } } return null; } @@ -518,5 +521,34 @@ public class EnterpriseInformationServiceImpl implements IEnterpriseInformationS } return statisticsIndicatorList; } + + public String getUrlParams(String urlStr,String paramKey) throws IOException { + URL url = new URL(urlStr); + URLConnection connection = url.openConnection(); + + // 获取查询字符串,即URL中"?"后面的部分 + String query = url.getQuery(); + + // 将查询字符串拆分为键值对 + Map queryParams = new HashMap<>(); + if (query != null) { + String[] pairs = query.split("&"); + for (String pair : pairs) { + int idx = pair.indexOf("="); + String key = pair.substring(0, idx); + String value = pair.substring(idx + 1); + queryParams.put(key, value); + } + } + // 输出参数 + queryParams.forEach((k, v) -> System.out.println(k + " = " + v)); + return queryParams.get(paramKey); + + } + + + + + }