Просмотр исходного кода

修改epoint oauth地址
添加获取信息登录积分平台接口

hzh 4 лет назад
Родитель
Сommit
48c1e658c6

+ 49 - 0
src/main/java/platform/modules/api/service/SyncThridFacade.java

@@ -0,0 +1,49 @@
+package platform.modules.api.service;
+
+import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONObject;
+import com.xiaoleilu.hutool.crypto.SecureUtil;
+import org.apache.commons.lang3.StringUtils;
+import org.apache.http.entity.StringEntity;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+import platform.common.Constant;
+import platform.common.util.HttpsUtils;
+import platform.common.util.ThreadPoolUtil;
+import platform.modules.api.dto.Sync;
+import platform.modules.api.dto.SyncUserDto;
+import platform.modules.build.entity.Company;
+import platform.modules.build.service.CompanyService;
+import platform.modules.company.service.CompanyInfoManageService;
+import platform.modules.government.entity.Street;
+import platform.modules.government.entity.User;
+import platform.modules.government.service.StreetService;
+import platform.modules.government.service.UserService;
+import platform.modules.sys.web.ResponseMessage;
+import sun.misc.BASE64Decoder;
+import sun.misc.BASE64Encoder;
+
+import javax.crypto.Cipher;
+import javax.crypto.KeyGenerator;
+import javax.crypto.SecretKey;
+import javax.crypto.spec.SecretKeySpec;
+import java.security.SecureRandom;
+import java.util.*;
+import java.util.concurrent.CompletableFuture;
+
+/**
+ * @author huzhihao
+ * @since 2021/9/4 2:19 PM
+ */
+@Service
+public class SyncThridFacade {
+
+    @Autowired
+    private SkyImageApiService skyImageApiService;
+
+    public void syncUser(SyncUserDto syncUserDto, String type) {
+        syncUserDto.setToken(skyImageApiService.accessToken());
+        skyImageApiService.syncUserInfo(syncUserDto);
+    }
+}

+ 4 - 7
src/main/java/platform/modules/company/service/CompanyInfoManageService.java

@@ -3,6 +3,7 @@ package platform.modules.company.service;
 import java.io.InputStream;
 import java.text.SimpleDateFormat;
 import java.util.*;
+import java.util.concurrent.CompletableFuture;
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
 
@@ -25,11 +26,7 @@ import platform.common.Constant;
 import platform.common.base.service.BaseService;
 import platform.common.base.service.DictionaryItemService;
 import platform.common.base.service.DictionaryTypeService;
-import platform.common.util.AlibabaSMSUtil;
-import platform.common.util.DateUtil;
-import platform.common.util.ExportExcel;
-import platform.common.util.ShiroUtils;
-import platform.common.util.WebUtil;
+import platform.common.util.*;
 import platform.modules.api.dto.SyncUserDto;
 import platform.modules.api.service.SkyImageApiService;
 import platform.modules.build.DTO.CompanyDto;
@@ -400,7 +397,7 @@ public class CompanyInfoManageService extends BaseService<Company> {
         userService.updateByCompanyId(id.toString(), user);
 
         //企业名称同步到天启
-        new Thread(() -> {
+        CompletableFuture.runAsync(() -> {
             //同步信息天启
             List<User> userDtos = userService.findUsersByCompanyId(id);
             for (User userDto : userDtos) {
@@ -418,7 +415,7 @@ public class CompanyInfoManageService extends BaseService<Company> {
                 dto.setToken(skyImageApiService.accessToken());
                 skyImageApiService.syncUserInfo(dto);
             }
-        }, "syncUserInfo").start();
+        }, ThreadPoolUtil.getInstance());
 
         if (flag) {
             return ResponseMessage.success("编辑成功");

+ 5 - 4
src/main/java/platform/modules/home/HomeController.java

@@ -72,6 +72,7 @@ import java.io.File;
 import java.io.FileInputStream;
 import java.io.OutputStream;
 import java.util.*;
+import java.util.concurrent.CompletableFuture;
 
 import static platform.common.Constant.HEAD_SESSION_STATUS_KEY;
 import static platform.common.Constant.HEAD_SESSION_STATUS_VALUE;
@@ -1315,7 +1316,7 @@ public class HomeController extends BaseController {
             information.setCreate_name(user.getUser_name());
             companyService.updateSelective(information);
 
-            new Thread(() -> {
+            CompletableFuture.runAsync(() -> {
                 //同步信息天启
                 SyncUserDto dto = new SyncUserDto();
                 dto.setAction(Constant.METHOD_STATUS.INSERT);
@@ -1330,7 +1331,7 @@ public class HomeController extends BaseController {
                 }
                 dto.setToken(skyImageApiService.accessToken());
                 skyImageApiService.syncUserInfo(dto);
-            }, "syncUserInfo").start();
+            }, ThreadPoolUtil.getInstance());
 
             //新增街道待办
             addWaitToDo(information);
@@ -1396,7 +1397,7 @@ public class HomeController extends BaseController {
             user.setPassword(SecureUtil.md5().digestHex(information.getPassword()));
             userService.updateSelective(user);
 
-            new Thread(() -> {
+            CompletableFuture.runAsync(() -> {
                 // 同步密码到天启
                 SyncUserDto dto = new SyncUserDto();
                 dto.setAction(Constant.METHOD_STATUS.UPDATE);
@@ -1406,7 +1407,7 @@ public class HomeController extends BaseController {
                 dto.setPassword(information.getPassword());
                 dto.setToken(skyImageApiService.accessToken());
                 skyImageApiService.syncUserInfo(dto);
-            }, "syncUserInfo").start();
+            }, ThreadPoolUtil.getInstance());
 
         } catch (Exception e) {
             e.printStackTrace();

+ 44 - 32
src/main/java/platform/modules/home/web/HomeRefactorController.java

@@ -4,14 +4,12 @@ import com.alibaba.fastjson.JSONObject;
 import com.aliyuncs.exceptions.ClientException;
 import com.github.pagehelper.PageInfo;
 import com.xiaoleilu.hutool.crypto.SecureUtil;
-import com.xiaoleilu.hutool.http.HttpUtil;
 import com.xiaoleilu.hutool.util.StrUtil;
 import io.jsonwebtoken.Claims;
 import org.apache.commons.lang3.StringUtils;
 import org.apache.shiro.authc.*;
 import org.apache.shiro.authc.pam.UnsupportedTokenException;
 import org.apache.shiro.subject.Subject;
-import org.omg.CORBA.INTERNAL;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.data.redis.core.HashOperations;
@@ -29,6 +27,7 @@ import platform.config.redis.RedisService;
 import platform.modules.api.dto.SyncUserDto;
 import platform.modules.api.response.epoint.EpointTokenDto;
 import platform.modules.api.service.SkyImageApiService;
+import platform.modules.api.service.SyncThridFacade;
 import platform.modules.build.entity.Company;
 import platform.modules.build.entity.CompanyContact;
 import platform.modules.build.entity.CompanyMaterial;
@@ -121,6 +120,9 @@ public class HomeRefactorController extends BaseController {
     @Autowired
     private SkyImageApiService skyImageApiService;
 
+    @Autowired
+    private SyncThridFacade syncThridFacade;
+
     @Autowired
     CompanyInfoManageService companyInfoManageService;
 
@@ -520,7 +522,6 @@ public class HomeRefactorController extends BaseController {
 
             Street finalStreet = street;
             CompletableFuture.runAsync(() -> {
-                //同步信息天启
                 SyncUserDto dto = new SyncUserDto();
                 dto.setAction(Constant.METHOD_STATUS.INSERT);
                 dto.setOldUserName("");
@@ -532,23 +533,8 @@ public class HomeRefactorController extends BaseController {
                     dto.setStreetName(finalStreet.getName());
                 }
                 dto.setToken(skyImageApiService.accessToken());
-                skyImageApiService.syncUserInfo(dto);
+                syncThridFacade.syncUser(dto, null);
             }, ThreadPoolUtil.getInstance());
-            /*new Thread(() -> {
-                //同步信息天启
-                SyncUserDto dto = new SyncUserDto();
-                dto.setAction(Constant.METHOD_STATUS.INSERT);
-                dto.setOldUserName("");
-                dto.setUserName(user.getUser_name());
-                dto.setUserLoginName(user.getNick_name());
-                dto.setPassword(information.getPassword().trim());
-                dto.setCompanyName(information.getCompany_name());
-                if (null != information.getStreet_id()) {
-                    dto.setStreetName(finalStreet.getName());
-                }
-                dto.setToken(skyImageApiService.accessToken());
-                skyImageApiService.syncUserInfo(dto);
-            }, "syncUserInfo").start();*/
 
             //发送短信
             Map<String, String> params = new HashMap<>();
@@ -597,17 +583,6 @@ public class HomeRefactorController extends BaseController {
                 dto.setToken(skyImageApiService.accessToken());
                 skyImageApiService.syncUserInfo(dto);
             }, ThreadPoolUtil.getInstance());
-            /*new Thread(() -> {
-                // 同步密码到天启
-                SyncUserDto dto = new SyncUserDto();
-                dto.setAction(Constant.METHOD_STATUS.UPDATE);
-                dto.setOldUserName(user.getNick_name());
-                dto.setUserName(user.getUser_name());
-                dto.setUserLoginName(user.getNick_name());
-                dto.setPassword(information.getPassword());
-                dto.setToken(skyImageApiService.accessToken());
-                skyImageApiService.syncUserInfo(dto);
-            }, "syncUserInfo").start();*/
 
         } catch (Exception e) {
             e.printStackTrace();
@@ -616,6 +591,43 @@ public class HomeRefactorController extends BaseController {
         return ResponseMessage.success("密码修改成功!系统将跳转到登陆页进行登录");
     }
 
+    @Value("${jszypt.url.login}")
+    private String JszyptLoginUrl;
+
+    @OperationLog(value = "获取积分平台登录信息")
+    @GetMapping(value = "/jszyptLoginInfo")
+    @ResponseBody
+    public ResponseMessage getJszyptLoginInfo() {
+
+        User user = ShiroUtils.getUserEntity();
+        Map map = new HashMap();
+        //地址
+        map.put("url", JszyptLoginUrl);
+        //账号
+        map.put("userName ", user.getNick_name());
+        //联系电话
+        map.put("phone", user.getPhone());
+        //用户类型(1代表个人用户,2代表企业用户,3代表政府用户)
+        Integer userType = user.getUser_type();
+        if(Objects.equals(Constant.UserType.PERSONAL,userType)){
+            map.put("userType", 1);
+        }else if(Objects.equals(Constant.UserType.COMPANY,userType)){
+            map.put("userType", 2);
+        }else if(Objects.equals(Constant.UserType.GOVERNMENT,userType)){
+            map.put("userType", 3);
+        }
+        if(Objects.equals(Constant.UserType.COMPANY,userType)){
+            Company company = companyService.findById(user.getCompany_id());
+            if(company!=null){
+                //统一社会信用代码
+                map.put("paperNo", company.getUscc());
+                //公司名称
+                map.put("companyName", company.getCompany_name());
+            }
+        }
+        return ResponseMessage.success("获取积分平台登录信息", map);
+    }
+
     /**
      * 用户登陆
      * 先根据用户名查询出一条用户记录再对比密码是否正确可以防止sql注入
@@ -692,12 +704,12 @@ public class HomeRefactorController extends BaseController {
             //根据code拿到token
             EpointTokenDto epointTokenDto = homeRefactorService.getTokenByCode(code);
             String accessToken = epointTokenDto.getAccess_token();
-            if(StrUtil.isBlank(accessToken)){
+            if (StrUtil.isBlank(accessToken)) {
                 return ResponseMessage.error(Constant.USER_CODE_INVALIAD);
             }
             //根据token与库里对比拿用户
             User user = homeRefactorService.getCurrentLoginUser(accessToken);
-            if (user!=null) {
+            if (user != null) {
                 String username = user.getNick_name();
                 //获取当前的Subject
                 Subject currentUser = ShiroUtils.getSubject();

+ 4 - 2
src/main/java/platform/modules/sys/web/LoginController.java

@@ -16,6 +16,7 @@ import platform.common.Constant;
 import platform.common.annotation.OperationLog;
 import platform.common.base.controller.BaseController;
 import platform.common.util.ShiroUtils;
+import platform.common.util.ThreadPoolUtil;
 import platform.common.util.WebUtil;
 import platform.modules.api.dto.SyncUserDto;
 import platform.modules.api.service.SkyImageApiService;
@@ -32,6 +33,7 @@ import javax.servlet.http.HttpServletResponse;
 
 import java.util.ArrayList;
 import java.util.List;
+import java.util.concurrent.CompletableFuture;
 
 import static platform.common.Constant.HEAD_SESSION_STATUS_KEY;
 import static platform.common.Constant.HEAD_SESSION_STATUS_VALUE;
@@ -157,7 +159,7 @@ public class LoginController extends BaseController {
             messagesMap.put("status", SUCCESS);
             messagesMap.put("message", "修改密码成功!");
 
-            new Thread(() -> {
+            CompletableFuture.runAsync(() -> {
                 //同步信息天启
                 SyncUserDto dto = new SyncUserDto();
                 dto.setAction(Constant.METHOD_STATUS.UPDATE);
@@ -167,7 +169,7 @@ public class LoginController extends BaseController {
                 dto.setPassword(newPassword);
                 dto.setToken(skyImageApiService.accessToken());
                 skyImageApiService.syncUserInfo(dto);
-            }, "syncUserInfo").start();
+            }, ThreadPoolUtil.getInstance());
 
             return messagesMap;
         } catch (Exception e) {

+ 6 - 6
src/main/java/platform/modules/sys/web/UserController.java

@@ -408,7 +408,7 @@ public class UserController extends BaseController {
             messagesMap.put("status", SUCCESS);
             messagesMap.put("message", "编辑成功!");
 
-            new Thread(() -> {
+            CompletableFuture.runAsync(() -> {
                 //同步信息给天启
                 SyncUserDto dto = new SyncUserDto();
                 dto.setAction(Constant.METHOD_STATUS.UPDATE);
@@ -423,7 +423,7 @@ public class UserController extends BaseController {
 //            }
                 dto.setToken(skyImageApiService.accessToken());
                 skyImageApiService.syncUserInfo(dto);
-            }, "syncUserInfo").start();
+            }, ThreadPoolUtil.getInstance());
 
             return messagesMap;
         }
@@ -650,7 +650,7 @@ public class UserController extends BaseController {
             messagesMap.put("status", SUCCESS);
             messagesMap.put("message", "添加成功!");
 
-            new Thread(() -> {
+            CompletableFuture.runAsync(() -> {
                 //同步信息给天启
                 SyncUserDto dto = new SyncUserDto();
                 dto.setAction(Constant.METHOD_STATUS.INSERT);
@@ -661,7 +661,7 @@ public class UserController extends BaseController {
                 dto.setCompanyName(content.getCompany_name());
                 dto.setToken(skyImageApiService.accessToken());
                 skyImageApiService.syncUserInfo(dto);
-            }, "syncUserInfo").start();
+            }, ThreadPoolUtil.getInstance());
 
             return messagesMap;
         }
@@ -744,7 +744,7 @@ public class UserController extends BaseController {
             messagesMap.put("status", SUCCESS);
             messagesMap.put("message", "编辑成功!");
 
-            new Thread(() -> {
+            CompletableFuture.runAsync(() -> {
                 //同步信息给天启
                 SyncUserDto dto = new SyncUserDto();
                 dto.setAction(Constant.METHOD_STATUS.UPDATE);
@@ -755,7 +755,7 @@ public class UserController extends BaseController {
                 dto.setCompanyName(content.getCompany_name());
                 dto.setToken(skyImageApiService.accessToken());
                 skyImageApiService.syncUserInfo(dto);
-            }, "syncUserInfo").start();
+            }, ThreadPoolUtil.getInstance());
 
             return messagesMap;
         }

+ 6 - 2
src/main/resources/application.yml

@@ -315,8 +315,12 @@ epoint:
   grant-type: authorization_code
   redirect-uri: http%3A%2F%2F47.105.241.108%2Fsnd-escloud%2Findex%2F%23%2Fhome
   url:
-    get-current-login-user: http://180.108.205.61:8080/epoint-smartcity-sso/rest/smartcitysso/getCurrentLoginUser
-    get-token-by-code: http://180.108.205.61:8080/epoint-smartcity-sso/rest/oauth2/token
+    get-current-login-user: http://180.108.205.61:8080/sst-smartcity-sso/rest/smartcitysso/getCurrentLoginUser
+    get-token-by-code: http://180.108.205.61:8080/sst-smartcity-sso/rest/oauth2/token
+
+jszypt:
+  url:
+    login: https://test.jszypt.com:23424/front/login-for-cloud-platfrom/login
 
 ---
 #开发环境配置

+ 6 - 2
src/main/resources/application_prod_in.yml

@@ -355,8 +355,12 @@ epoint:
   grant-type: authorization_code
   redirect-uri: http%3A%2F%2Fescloud.snd.gov.cn%2Findex%2F%23%2Fhome
   url:
-    get-current-login-user: https://sst.suzhou.gov.cn/epoint-smartcity-sso/rest/smartcitysso/getCurrentLoginUser
-    get-token-by-code: https://sst.suzhou.gov.cn/epoint-smartcity-sso/rest/oauth2/token
+    get-current-login-user: https://sst.suzhou.gov.cn/sst-smartcity-sso/rest/smartcitysso/getCurrentLoginUser
+    get-token-by-code: https://sst.suzhou.gov.cn/sst-smartcity-sso/rest/oauth2/token
+
+jszypt:
+  url:
+    login: https://test.jszypt.com:23424/front/login-for-cloud-platfrom/login
 ---
 #prod外网环境配置
 server:

+ 7 - 2
src/main/resources/application_prod_out.yml

@@ -409,8 +409,13 @@ epoint:
   grant-type: authorization_code
   redirect-uri: http%3A%2F%2Fescloud.snd.gov.cn%2Findex%2F%23%2Fhome
   url:
-    get-current-login-user: https://sst.suzhou.gov.cn/epoint-smartcity-sso/rest/smartcitysso/getCurrentLoginUser
-    get-token-by-code: https://sst.suzhou.gov.cn/epoint-smartcity-sso/rest/oauth2/token
+    get-current-login-user: https://sst.suzhou.gov.cn/sst-smartcity-sso/rest/smartcitysso/getCurrentLoginUser
+    get-token-by-code: https://sst.suzhou.gov.cn/sst-smartcity-sso/rest/oauth2/token
+
+jszypt:
+  url:
+    login: https://test.jszypt.com:23424/front/login-for-cloud-platfrom/login
+
 ---
 #prod-test外网环境配置
 server: