修改企业端单点登录

wushunjie
吴顺杰 11 months ago
parent cf31a4415e
commit b191d6140b

@ -36,8 +36,17 @@ public interface BmsEnterpriseBasicInfoMapper extends BaseMapper<BmsEnterpriseBa
*
*/
List<BmsEnterpriseBasicInfo> workSearch(@Param("req") EnterpriseInfoWorkRequest enterpriseInfoWorkRequest);
/**
* id
*/
BmsEnterpriseBasicInfo selectGetCreditCode(String getCreditCode);
/**
*
*
* @param uscc
* @return
*/
BmsEnterpriseBasicInfo findByQytyxydm(@Param("uscc") String uscc);
}

@ -9,7 +9,6 @@ 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;
@ -35,7 +34,7 @@ public class SmsEnterChange {
@Value("${isTiming}")
private Boolean isTiming;
// 每三小时执行一次
@Scheduled(cron = "0 0 */3 * * *")
@Scheduled(cron = "0 0 */12 * * *")
private void runTask() {
if(isTiming){
//查询初审的所有用户

@ -5,11 +5,11 @@ package com.ruoyi.jjh.declaration.single.controller;
* @since 2024/5/22 15:50
*/
import cn.hutool.crypto.digest.DigestUtil;
import cn.hutool.http.HttpResponse;
import cn.hutool.http.HttpUtil;
import cn.hutool.json.JSONObject;
import cn.hutool.json.JSONUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.redis.RedisCache;
import com.ruoyi.common.exception.ServiceException;
@ -32,7 +32,10 @@ import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.net.URLEncoder;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.Base64;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.TimeUnit;
@ -44,14 +47,13 @@ import java.util.concurrent.TimeUnit;
@RequestMapping("/system/singlelogin")
public class SingleLoginController {
private static final Logger log = LoggerFactory.getLogger(SingleLoginController.class);
@Value("${url}")
private String url;
@Value("${infoUrl}")
private String infoUrl;
@Value("${logoutUrl}")
private String logoutUrl;
@ -69,10 +71,11 @@ public class SingleLoginController {
@Value("${enterpriseAppId}")
private String enterpriseAppId;
@Value("${enterpriseAppsecret}")
private String enterpriseAppsecret;
/**
*
*
* @return
*/
@ApiOperation("统一登陆")
@GetMapping("/login")
@ -86,10 +89,6 @@ public class SingleLoginController {
// 添加请求头
response.setHeader("Content-Type", "application/json");
response.setHeader("X-Requested-With", "XMLHttpRequest");
// Map<String, String> stringStringMap = singleLoginService.generationHeader();
// response.setHeader("time",stringStringMap.get("time"));
// response.setHeader("appid",stringStringMap.get("appid"));
// response.setHeader("sign",stringStringMap.get("sign"));
response.sendRedirect(jumpurl);
}
@ -97,16 +96,16 @@ public class SingleLoginController {
/**
*
*
* @return
* @return
*/
@ApiOperation(value = "获取用户信息", response = UserResponse.class)
@GetMapping("/getInfo")
public AjaxResult getInfo(@RequestParam("clientToken") String clientToken) throws Exception {
String url = infoUrl + "?clienttoken=" + clientToken;
HttpResponse response = HttpUtil.createGet(url)
// .addHeaders(singleLoginService.generationHeader())
public AjaxResult getInfo(String clientToken) throws Exception {
HttpResponse response = HttpUtil.createGet(infoUrl)
.form("clienttoken", clientToken)
// .addHeaders(generationHeader())
.execute();
String responseBody = null;
String responseBody;
// 获取响应状态码
int statusCode = response.getStatus();
if (statusCode == 200) {
@ -124,9 +123,7 @@ public class SingleLoginController {
UserResponse res = JSONUtil.toBean(dataObj, UserResponse.class);
UserMainResponse req = JSONUtil.toBean(mainobj, UserMainResponse.class);
//如果在企业库里面找不到该企业就返回错误
QueryWrapper<BmsEnterpriseBasicInfo> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("tyshxydm", req.getUscc());
BmsEnterpriseBasicInfo bmsEnterpriseBasicInfo = bmsEnterpriseBasicInfoMapper.selectOne(queryWrapper);
BmsEnterpriseBasicInfo bmsEnterpriseBasicInfo = bmsEnterpriseBasicInfoMapper.findByQytyxydm(req.getUscc());
Long id;
if (bmsEnterpriseBasicInfo == null) {
throw new ServiceException("该企业不在库!请稍后再试!");
@ -142,7 +139,7 @@ public class SingleLoginController {
return AjaxResult.success(res);
} else {
log.error(response.body());
throw new ServiceException("未知异常请联系管理员");
throw new ServiceException("该用户不是企业法人");
}
} else {
log.error(response.body());
@ -150,13 +147,18 @@ public class SingleLoginController {
}
}
/**
* 退
*
* @param clienttoken clienttoken
* @return
*/
@ApiOperation(value = "退出登录")
@GetMapping("/enterpriseLogout")
public AjaxResult enterpriseLogout(@RequestParam("clienttoken") String clienttoken) {
String url = logoutUrl + "?clienttoken=" + clienttoken;
HttpResponse execute = HttpUtil.createGet(url)
// .addHeaders(singleLoginService.generationHeader())
// .addHeaders(generationHeader())
.execute();
String str;
// 获取响应状态码
@ -169,5 +171,20 @@ public class SingleLoginController {
return AjaxResult.success(str);
}
/**
*
*
* @return
*/
private Map<String, String> generationHeader() {
// 定义时间格式化器
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyyMMddHHmmss");
String format = LocalDateTime.now().format(formatter);
//正式端需要请求头
HashMap<String, String> headers = new HashMap<>();//存放请求头,可以存放多个请求头
headers.put("appid", enterpriseAppId);
headers.put("time", format);
headers.put("sign", DigestUtil.md5Hex(enterpriseAppId + enterpriseAppsecret + format));
return headers;
}
}

@ -1,9 +1,8 @@
package com.ruoyi.jjh.declaration.single.service;
import java.util.Map;
/**
*
*
* @author du
* @since 2024/6/4 15:16
*/
@ -14,9 +13,4 @@ public interface SingleLoginService {
*/
String singleLogin(String userName, String nickName, Long id, String userType, String phone);
/**
*
* @return
*/
Map<String,String> generationHeader();
}

@ -1,8 +1,5 @@
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;
@ -15,7 +12,6 @@ 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;
@ -26,9 +22,6 @@ 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;
/**
@ -53,9 +46,6 @@ public class SingleLoginServiceImpl implements SingleLoginService {
@Value("${isTiming}")
private Boolean isTiming;
@Value("${enterpriseAppId}")
private String enterpriseAppId;
/**
* token
*/
@ -83,8 +73,7 @@ public class SingleLoginServiceImpl implements SingleLoginService {
user.setUserType(userType);
user.setEnterpriseId(id);
//如果用户名也就是信用代码没有重复的就新增用户
if (userService.checkUserNameUnique(user))
{
if (userService.checkUserNameUnique(user)) {
user.setPassword(SecurityUtils.encryptPassword(user.getPassword()));
userService.insertUser(user);
if ("02".equals(userType) & isTiming) {
@ -116,23 +105,5 @@ public class SingleLoginServiceImpl implements SingleLoginService {
return String.valueOf(token.get("access_token"));
}
/**
*
* @return
*/
@Override
public Map<String, String> generationHeader() {
// 定义时间格式化器
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyyMMddHHmmss");
String format = LocalDateTime.now().format(formatter);
//正式端需要请求头
HashMap<String, String> 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;
}
}

@ -87,6 +87,8 @@ server:
#企业端测试环境应用系统编号
enterpriseAppId: BwAWS8uh
# 应用私钥
enterpriseAppsecret: 03f70874-39e9-11ef-bbd6-fa163e2b2e10
#企业端单点登陆url
url: https://qytt.sipac.gov.cn/api/usercenter/User/ssoLogin
#企业端用户信息url
@ -102,7 +104,7 @@ paramType: cs
smsV: oVFPU1y1wYJIatvqrGoTAE5ycguUyjaY
#工单编号
code: SC24071600001
#PaaSID
#短信PaaSID
paaSID: xdfwy
#短信token
smsToken: iM89cd4b0cGNVYAqKu7jl7EONyHgTa0N

@ -116,10 +116,14 @@ isTiming: true
#企业端正式环境应用系统编号
enterpriseAppId: 03f70874-39e9-11ef-bbd6-fa163e2b2e10
# 应用私钥
enterpriseAppsecret: 03f70874-39e9-11ef-bbd6-fa163e2b2e10
#企业端单点登陆url
url: https://qytt.sipac.gov.cn/api/usercenter/User/ssoLogin
#url: http://114.216.202.175:8008/api/usercenter/User/ssoLogin
#企业端用户信息url
infoUrl: https://qytt.sipac.gov.cn/api/usercenter/User/getInfo
#infoUrl: http://114.216.202.175:8008/api/usercenter/User/getInfo
#短信发送接口
smsSend: http://zwyyone.sipac.gov.cn/ebus/szyqznzs/dx
@ -131,7 +135,7 @@ paramType: zs
smsV: 3b3jaDmYcf87Mk7NqEmzis=3AaaFeYmV4DIf
#工单编号
code: SC24071600001
#PaaSID
#短信PaaSID
paaSID: xdfwy
#短信token
smsToken: iM89cd4b0cGNVYAqKu7jl7EONyHgTa0N

@ -34,7 +34,7 @@ spring:
# 国际化资源文件路径
basename: i18n/messages
profiles:
active: druid
active: internet
# 文件上传
servlet:
multipart:

@ -31,4 +31,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</where>
</select>
<select id="findByQytyxydm" resultType="com.ruoyi.jjh.declaration.entity.BmsEnterpriseBasicInfo">
select *
from bms_enterprise_basic_info
where tyshxydm = #{uscc}
</select>
</mapper>
Loading…
Cancel
Save