diff --git a/ruoyi-admin/src/main/java/com/ruoyi/jjh/declaration/regular/SmsEnterChange.java b/ruoyi-admin/src/main/java/com/ruoyi/jjh/declaration/regular/SmsEnterChange.java index 09963bf..30dc96c 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/jjh/declaration/regular/SmsEnterChange.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/jjh/declaration/regular/SmsEnterChange.java @@ -9,6 +9,7 @@ import org.springframework.beans.factory.annotation.Value; import org.springframework.context.annotation.Configuration; import org.springframework.scheduling.annotation.EnableScheduling; import org.springframework.scheduling.annotation.Scheduled; +import org.springframework.stereotype.Component; import javax.annotation.Resource; import java.util.List; @@ -50,7 +51,7 @@ public class SmsEnterChange { } //查询复审的所有用户 SysUser user1 = new SysUser(); - user.setDeptId(101L); + user1.setDeptId(101L); Long count1 = iBmsDeclarationRecordsService.lambdaQuery().eq(BmsDeclarationRecords::getStatus, 2).count(); if(count1>0){ List list2 = sysUserMapper.selectUserList(user1); @@ -61,7 +62,7 @@ public class SmsEnterChange { } //查询终审的所有用户 SysUser user2 = new SysUser(); - user.setDeptId(103L); + user2.setDeptId(103L); Long count2 = iBmsDeclarationRecordsService.lambdaQuery().eq(BmsDeclarationRecords::getStatus, 3).count(); if(count2>0){ List list3 = sysUserMapper.selectUserList(user2); diff --git a/ruoyi-admin/src/main/java/com/ruoyi/jjh/declaration/single/controller/SingleLoginController.java b/ruoyi-admin/src/main/java/com/ruoyi/jjh/declaration/single/controller/SingleLoginController.java index 0c6bc63..32ef58b 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/jjh/declaration/single/controller/SingleLoginController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/jjh/declaration/single/controller/SingleLoginController.java @@ -33,6 +33,7 @@ import javax.servlet.http.HttpServletResponse; import java.io.IOException; import java.net.URLEncoder; import java.util.Base64; +import java.util.Map; import java.util.concurrent.TimeUnit; /** @@ -65,7 +66,8 @@ public class SingleLoginController { @Resource private BmsEnterpriseBasicInfoMapper bmsEnterpriseBasicInfoMapper; - + @Value("${enterpriseAppId}") + private String enterpriseAppId; /** * 统一登陆 @@ -76,7 +78,7 @@ public class SingleLoginController { @GetMapping("/login") public void login(HttpServletResponse response) throws IOException { //变成参数模式,appid 用于校验提交的来源地址,生产环境会校验,试用环境暂不校验 - String scUrl = "clientUrl=" + URLEncoder.encode(returnUrl, "UTF-8") + "?appid=BwAWS8uh"; + String scUrl = "clientUrl=" + URLEncoder.encode(returnUrl, "UTF-8") + "?appid="+enterpriseAppId; //加密后的客户端地址 scUrl = Base64.getEncoder().encodeToString(scUrl.getBytes()); //最终跳转地址 @@ -84,7 +86,10 @@ public class SingleLoginController { // 添加请求头 response.setHeader("Content-Type", "application/json"); response.setHeader("X-Requested-With", "XMLHttpRequest"); - +// Map stringStringMap = singleLoginService.generationHeader(); +// response.setHeader("time",stringStringMap.get("time")); +// response.setHeader("appid",stringStringMap.get("appid")); +// response.setHeader("sign",stringStringMap.get("sign")); response.sendRedirect(jumpurl); } @@ -98,7 +103,9 @@ public class SingleLoginController { @GetMapping("/getInfo") public AjaxResult getInfo(@RequestParam("clientToken") String clientToken) throws Exception { String url = infoUrl + "?clienttoken=" + clientToken; - HttpResponse response = HttpUtil.createGet(url).execute(); + HttpResponse response = HttpUtil.createGet(url) +// .addHeaders(singleLoginService.generationHeader()) + .execute(); String responseBody = null; // 获取响应状态码 int statusCode = response.getStatus(); @@ -148,7 +155,9 @@ public class SingleLoginController { @GetMapping("/enterpriseLogout") public AjaxResult enterpriseLogout(@RequestParam("clienttoken") String clienttoken) { String url = logoutUrl + "?clienttoken=" + clienttoken; - HttpResponse execute = HttpUtil.createGet(url).execute(); + HttpResponse execute = HttpUtil.createGet(url) +// .addHeaders(singleLoginService.generationHeader()) + .execute(); String str; // 获取响应状态码 int statusCode = execute.getStatus(); @@ -160,4 +169,5 @@ public class SingleLoginController { return AjaxResult.success(str); } + } \ No newline at end of file diff --git a/ruoyi-admin/src/main/java/com/ruoyi/jjh/declaration/single/service/SingleLoginService.java b/ruoyi-admin/src/main/java/com/ruoyi/jjh/declaration/single/service/SingleLoginService.java index fd03cf4..708754f 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/jjh/declaration/single/service/SingleLoginService.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/jjh/declaration/single/service/SingleLoginService.java @@ -1,10 +1,22 @@ package com.ruoyi.jjh.declaration.single.service; +import java.util.Map; + /** * 用户验证 * @author du * @since 2024/6/4 15:16 */ public interface SingleLoginService { + + /** + * 保存用户信息 换取本系统token + */ String singleLogin(String userName,String nickName,Long id,String userType,String phone); + + /** + * 正式环境需要的请求头 + * @return + */ + Map generationHeader(); } diff --git a/ruoyi-admin/src/main/java/com/ruoyi/jjh/declaration/single/service/impl/SingleLoginServiceImpl.java b/ruoyi-admin/src/main/java/com/ruoyi/jjh/declaration/single/service/impl/SingleLoginServiceImpl.java index 3d9a13e..ed63d7b 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/jjh/declaration/single/service/impl/SingleLoginServiceImpl.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/jjh/declaration/single/service/impl/SingleLoginServiceImpl.java @@ -1,5 +1,8 @@ package com.ruoyi.jjh.declaration.single.service.impl; +import cn.hutool.core.codec.Base64; +import cn.hutool.crypto.digest.DigestUtil; +import cn.hutool.json.JSONUtil; import com.ruoyi.common.constant.Constants; import com.ruoyi.common.core.domain.entity.SysUser; import com.ruoyi.common.core.domain.model.LoginUser; @@ -12,6 +15,7 @@ import com.ruoyi.framework.manager.factory.AsyncFactory; import com.ruoyi.framework.security.context.AuthenticationContextHolder; import com.ruoyi.framework.web.service.TokenService; import com.ruoyi.jjh.declaration.single.service.SingleLoginService; +import com.ruoyi.jjh.declaration.single.util.HMAC256Config; import com.ruoyi.jjh.ent.service.SmsAlertsService; import com.ruoyi.system.service.ISysUserService; import org.springframework.beans.factory.annotation.Value; @@ -22,6 +26,9 @@ import org.springframework.security.core.Authentication; import org.springframework.stereotype.Service; import javax.annotation.Resource; +import java.time.LocalDateTime; +import java.time.format.DateTimeFormatter; +import java.util.HashMap; import java.util.Map; /** @@ -46,6 +53,12 @@ public class SingleLoginServiceImpl implements SingleLoginService { @Value("${isTiming}") private Boolean isTiming; + @Value("${enterpriseAppId}") + private String enterpriseAppId; + + /** + * 保存用户信息 换取本系统token + */ @Override public String singleLogin(String userName, String nickName, Long id, String userType,String phone) { // 用户验证 @@ -103,5 +116,23 @@ public class SingleLoginServiceImpl implements SingleLoginService { return String.valueOf(token.get("access_token")); } + + /** + * 正式环境需要的请求头 + * @return + */ + @Override + public Map generationHeader() { + // 定义时间格式化器 + DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyyMMddHHmmss"); + String format = LocalDateTime.now().format(formatter); + //正式端需要请求头 + HashMap headers = new HashMap<>();//存放请求头,可以存放多个请求头 + headers.put("appid", enterpriseAppId); + headers.put("time", format); + headers.put("sign", DigestUtil.md5Hex(enterpriseAppId+"03f71c58-39e9-11ef-bbd6-fa163e2b2e10"+format)); + return headers; + } + } diff --git a/ruoyi-admin/src/main/resources/application-druid.yml b/ruoyi-admin/src/main/resources/application-druid.yml index c1d3ee8..a5ef059 100644 --- a/ruoyi-admin/src/main/resources/application-druid.yml +++ b/ruoyi-admin/src/main/resources/application-druid.yml @@ -62,8 +62,8 @@ spring: config: multi-statement-allow: true #自己客户端地址 -returnUrl: http://39.101.188.84:9999/demo/JinJiHu -#returnUrl: http://192.168.0.114:81 +#returnUrl: http://39.101.188.84:9999/demo/JinJiHu +returnUrl: http://192.168.0.110:80 #定时任务更新企业信息和联系人的开启 isTiming: false @@ -85,6 +85,8 @@ server: # Tomcat启动初始化的线程数,默认值10 min-spare: 100 +#企业端测试环境应用系统编号 +enterpriseAppId: BwAWS8uh #企业端单点登陆url url: https://qytt.sipac.gov.cn/api/usercenter/User/ssoLogin #企业端用户信息url diff --git a/ruoyi-admin/src/main/resources/application-internet.yml b/ruoyi-admin/src/main/resources/application-internet.yml index 235082b..8099fce 100644 --- a/ruoyi-admin/src/main/resources/application-internet.yml +++ b/ruoyi-admin/src/main/resources/application-internet.yml @@ -114,6 +114,8 @@ returnUrl: https://idp.sipac.gov.cn/bms #定时任务更新企业信息和联系人的开启 isTiming: true +#企业端正式环境应用系统编号 +enterpriseAppId: 03f70874-39e9-11ef-bbd6-fa163e2b2e10 #企业端单点登陆url url: https://qytt.sipac.gov.cn/api/usercenter/User/ssoLogin #企业端用户信息url diff --git a/ruoyi-admin/src/main/resources/application.yml b/ruoyi-admin/src/main/resources/application.yml index 8b34650..663ce31 100644 --- a/ruoyi-admin/src/main/resources/application.yml +++ b/ruoyi-admin/src/main/resources/application.yml @@ -108,6 +108,7 @@ xss: # 匹配链接 urlPatterns: /system/*,/monitor/*,/tool/* + #企业端退出登录url logoutUrl: https://qytt.sipac.gov.cn/api/usercenter/User/ssoLogOut #政务端clientId @@ -122,7 +123,6 @@ getInfoId: https://qyt.sipac.gov.cn/enterprise-gateway/sipsg-enterprise/sys/thir getAllInfo: http://uid.sipac.gov.cn/open/api/identity/data/FindUserById #法人库-企业联络人员(统一社会信用代码)和法人库-法人基本信息(统一社会信用代码)生产环境 enterpriseUrl: http://172.21.10.46/api/invoke -#自己客户端地址 -returnUrl: https://idp.sipac.gov.cn/bms +