parent
5ede8ba0a8
commit
4639e020b7
@ -0,0 +1,28 @@
|
||||
package com.ruoyi.docking.entity.request;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
/**
|
||||
* 项目月度信息投资统计
|
||||
* @author du
|
||||
* @since 2025/5/8 10:10
|
||||
*/
|
||||
@Data
|
||||
public class YdxxtjRequest {
|
||||
|
||||
@NotNull(message = "年份不能为空!")
|
||||
@ApiModelProperty("年份")
|
||||
private String years;
|
||||
|
||||
|
||||
@NotNull(message = "项目id不能为空!")
|
||||
@ApiModelProperty("项目id")
|
||||
private Long xmId;
|
||||
|
||||
@NotNull(message = "请选择类别!")
|
||||
@ApiModelProperty("1年度 2季度")
|
||||
private Integer type;
|
||||
}
|
@ -0,0 +1,33 @@
|
||||
package com.ruoyi.gysl.entity.response;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
/**
|
||||
* 项目月度信息投资统计
|
||||
* @author du
|
||||
* @since 2025/5/8 9:34
|
||||
*/
|
||||
@Data
|
||||
public class YdxxtjResponse {
|
||||
|
||||
@ApiModelProperty("月度")
|
||||
private String month;
|
||||
|
||||
@ApiModelProperty("季度")
|
||||
private Integer jd;
|
||||
|
||||
@ApiModelProperty("季度投资额")
|
||||
private BigDecimal jdtze;
|
||||
|
||||
@ApiModelProperty("月投资额")
|
||||
private BigDecimal ytze;
|
||||
|
||||
@ApiModelProperty("月投资比例")
|
||||
private BigDecimal ytzbl;
|
||||
|
||||
@ApiModelProperty("累计投资额")
|
||||
private BigDecimal ljtze;
|
||||
}
|
@ -0,0 +1,125 @@
|
||||
package com.ruoyi.gysl.login.controller;
|
||||
|
||||
import cn.hutool.core.codec.Base64;
|
||||
import cn.hutool.http.HttpRequest;
|
||||
import cn.hutool.http.HttpResponse;
|
||||
import cn.hutool.json.JSONObject;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import com.ruoyi.common.core.domain.AjaxResult;
|
||||
import com.ruoyi.common.exception.ServiceException;
|
||||
import com.ruoyi.gysl.login.dto.request.UserInfoRequestDTO;
|
||||
import com.ruoyi.gysl.login.dto.response.ChiefResponse;
|
||||
import com.ruoyi.gysl.login.dto.response.ThirdUserInfoResponse;
|
||||
import com.ruoyi.gysl.login.util.HMAC256Config;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.net.URLEncoder;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
|
||||
/**
|
||||
* 政务端登录
|
||||
*
|
||||
* @author du
|
||||
* @since 2024/6/4 9:53
|
||||
*/
|
||||
@Api(tags = "政务端单点登录")
|
||||
@RequestMapping("/system/chief")
|
||||
@RestController
|
||||
public class ChiefController {
|
||||
|
||||
@Value("${clientId}")
|
||||
private String clientId;
|
||||
|
||||
@Value("${clientSecret}")
|
||||
private String clientSecret;
|
||||
|
||||
|
||||
@Value("${appkey}")
|
||||
private String appkey;
|
||||
|
||||
@Value("${getInfoId}")
|
||||
private String getInfoId;
|
||||
|
||||
@Value("${getAllInfo}")
|
||||
private String getAllInfo;
|
||||
|
||||
|
||||
@ApiOperation("政务端登录")
|
||||
@GetMapping
|
||||
public AjaxResult login(
|
||||
@RequestParam("userToken") String userToken,
|
||||
@RequestParam("timespan") String timespan,
|
||||
@RequestParam("signature") String signature
|
||||
) throws Exception {
|
||||
String encode = Base64.encode((HMAC256Config.HmacSHA256(clientId + timespan + userToken, clientSecret)));
|
||||
if (encode.equals(signature)) {
|
||||
//经济大脑(政务端)获取用户信息接口
|
||||
UserInfoRequestDTO req = new UserInfoRequestDTO();
|
||||
req.setClientId(clientId);
|
||||
req.setUserToken(userToken);
|
||||
//请求头
|
||||
HashMap<String, String> headers = new HashMap<>();//存放请求头,可以存放多个请求头
|
||||
headers.put("signature", Base64.encode(HMAC256Config.HmacSHA256(JSONUtil.parse(req).toString() + timespan, clientSecret)));
|
||||
headers.put("timespan", timespan);
|
||||
//请求体
|
||||
JSONObject jsonObject = new JSONObject();//存放参数
|
||||
jsonObject.set("clientId", clientId);
|
||||
jsonObject.set("userToken", userToken);
|
||||
HttpResponse response = HttpRequest.post(getInfoId)
|
||||
.addHeaders(headers)
|
||||
.body(jsonObject.toString())
|
||||
.execute();
|
||||
// 获取响应状态码
|
||||
if (response.getStatus() == 200) {
|
||||
//经济大脑(政务端)获取用户信息接口
|
||||
JSONObject jsonObj = JSONUtil.parseObj(response.body());
|
||||
ThirdUserInfoResponse res = JSONUtil.toBean(jsonObj.get("data").toString(), ThirdUserInfoResponse.class);
|
||||
//政务通获取用户信息接口(可选)
|
||||
String getInfo = getAllInfo + "?id=" + res.getUserId() + "&appkey=" + appkey;
|
||||
HttpResponse getMain = HttpRequest.get(getInfo).execute();
|
||||
if (getMain.getStatus() == 200) {
|
||||
JSONObject dataJson = JSONUtil.parseObj(getMain.body());
|
||||
ChiefResponse bean = JSONUtil.toBean(dataJson, ChiefResponse.class);
|
||||
//判断几个政务端用户,等待商量结果
|
||||
//lj 102 其他是100 //要给dept部门id
|
||||
// bean.setToken(singleLoginService.singleLogin(bean.getAccountName(), bean.getName(), null, "02", bean.getMobile(),bean.getEmail()));
|
||||
return AjaxResult.success(bean);
|
||||
} else {
|
||||
throw new ServiceException("登陆失败");
|
||||
}
|
||||
}
|
||||
} else {
|
||||
throw new ServiceException("登陆失败");
|
||||
}
|
||||
throw new ServiceException("登陆失败");
|
||||
}
|
||||
|
||||
|
||||
@ApiOperation("政务根据信用代码返回跳转路由")
|
||||
@GetMapping("/returnUrl")
|
||||
public AjaxResult returnUrl(@RequestParam("code") String code,
|
||||
@RequestParam("userToken") String userToken) throws Exception {
|
||||
//请求的地址
|
||||
StringBuilder url = new StringBuilder("http://qyt.sipac.gov.cn/sipsg-enterprise-mobile-manage/#/loginVerify?");
|
||||
//当前时间的时间戳
|
||||
String timespan = Long.toString(System.currentTimeMillis());
|
||||
UserInfoRequestDTO req = new UserInfoRequestDTO();
|
||||
req.setClientId(clientId);
|
||||
req.setUserToken(userToken);
|
||||
String signature = Base64.encode(HMAC256Config.HmacSHA256(JSONUtil.parse(req).toString() + timespan, clientSecret));
|
||||
url.append("signature=").append(signature);
|
||||
url.append("×pan=").append(timespan);
|
||||
url.append("&userToken=").append(userToken);
|
||||
url.append("&gourl=")
|
||||
.append(URLEncoder.encode("https://qyt.sipac.gov.cn/sipsg-enterprise-mobile-manage/#/workPlat/search/enterprise/detail?id="+code,"UTF-8"));
|
||||
url.append("&clientid=").append(clientId);
|
||||
return AjaxResult.success(url.toString());
|
||||
}
|
||||
}
|
@ -0,0 +1,15 @@
|
||||
package com.ruoyi.gysl.login.dto.request;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 获取用户信息请求类
|
||||
*
|
||||
* @author du
|
||||
* @since 2024/6/20 11:20
|
||||
*/
|
||||
@Data
|
||||
public class UserInfoRequestDTO {
|
||||
private String clientId;
|
||||
private String userToken;
|
||||
}
|
@ -0,0 +1,47 @@
|
||||
package com.ruoyi.gysl.login.dto.response;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 政务端用户
|
||||
*
|
||||
* @author du
|
||||
* @since 2024/6/4 11:05
|
||||
*/
|
||||
@Data
|
||||
@ApiModel("政务端用户")
|
||||
public class ChiefResponse {
|
||||
@ApiModelProperty("本系统token")
|
||||
private String token;
|
||||
|
||||
private String id;
|
||||
private String mainTopOrganizationId;
|
||||
private String isEnabled;
|
||||
private String isOfficial;
|
||||
private String isUseOA;
|
||||
private String name;
|
||||
private String familyName;
|
||||
private String givenName;
|
||||
private String accountName;
|
||||
private String email;
|
||||
private String mobile;
|
||||
private String sex;
|
||||
private String idNumber;
|
||||
private String birthday;
|
||||
private String workPhone;
|
||||
private String shortPhone;
|
||||
private String workAddress;
|
||||
private String state;
|
||||
private String description;
|
||||
// private String post;
|
||||
private String secondaryEmail;
|
||||
private String hasDomainAccount;
|
||||
private SettingsResponse settings;
|
||||
private List<OrganizationsResponse> organizations;
|
||||
private String whenCreated;
|
||||
private String whenUpdated;
|
||||
}
|
@ -0,0 +1,27 @@
|
||||
package com.ruoyi.gysl.login.dto.response;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* organizations其他响应类
|
||||
*
|
||||
* @author du
|
||||
* @since 2024/6/4 14:42
|
||||
*/
|
||||
@Data
|
||||
@ApiModel("organizations其他响应类")
|
||||
public class OrganizationsOtherResponse {
|
||||
|
||||
private String id;
|
||||
private String parentId;
|
||||
private String name;
|
||||
private String path;
|
||||
private String displayName;
|
||||
private String description;
|
||||
private String order;
|
||||
private String whenCreated;
|
||||
private String whenUpdated;
|
||||
private String type;
|
||||
private SettingsResponse settings;
|
||||
}
|
@ -0,0 +1,22 @@
|
||||
package com.ruoyi.gysl.login.dto.response;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* organizations响应类
|
||||
*
|
||||
* @author du
|
||||
* @since 2024/6/4 14:40
|
||||
*/
|
||||
@Data
|
||||
@ApiModel("organizations响应类")
|
||||
public class OrganizationsResponse {
|
||||
private String userId;
|
||||
private String isPrimary;
|
||||
private String organizationId;
|
||||
private String userOrder;
|
||||
private String organizationOrder;
|
||||
private String user;
|
||||
private OrganizationsOtherResponse organization;
|
||||
}
|
@ -0,0 +1,19 @@
|
||||
package com.ruoyi.gysl.login.dto.response;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* settings响应类
|
||||
*
|
||||
* @author du
|
||||
* @since 2024/6/4 11:07
|
||||
*/
|
||||
@Data
|
||||
@ApiModel("settings响应类")
|
||||
public class SettingsResponse {
|
||||
private String isContactsHidden;
|
||||
private String isContactsHiddenMobile;
|
||||
private String isContactsHiddenBirthday;
|
||||
private String isContactsHiddenWorkPhone;
|
||||
}
|
@ -0,0 +1,35 @@
|
||||
package com.ruoyi.gysl.login.dto.response;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @author dong
|
||||
* @since 2024/5/27 14:37
|
||||
*/
|
||||
@Data
|
||||
@ApiModel("法人用户机构代码")
|
||||
public class UserMainResponse {
|
||||
|
||||
/**
|
||||
* 对应企业的组织机构代码
|
||||
*/
|
||||
@ApiModelProperty(value = "对应企业的组织机构代码")
|
||||
private String organcode;
|
||||
|
||||
|
||||
/**
|
||||
* 对应企业的统一社会信用代码
|
||||
*/
|
||||
@ApiModelProperty(value = "对应企业的统一社会信用代码")
|
||||
private String uscc;
|
||||
|
||||
|
||||
/**
|
||||
* 对应企业名称
|
||||
*/
|
||||
@ApiModelProperty(value = "对应企业名称")
|
||||
private String epname;
|
||||
|
||||
}
|
@ -0,0 +1,74 @@
|
||||
package com.ruoyi.gysl.login.util;
|
||||
|
||||
import org.apache.commons.codec.binary.Base64;
|
||||
|
||||
import javax.crypto.Cipher;
|
||||
import javax.crypto.Mac;
|
||||
import javax.crypto.spec.IvParameterSpec;
|
||||
import javax.crypto.spec.SecretKeySpec;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
|
||||
/**
|
||||
* 签名验证
|
||||
*
|
||||
* @author du
|
||||
* @since 2024/6/20 10:15
|
||||
*/
|
||||
public class HMAC256Config {
|
||||
|
||||
/**
|
||||
* 加解密统一编码方式
|
||||
*/
|
||||
private final static String ENCODING = "utf-8";
|
||||
|
||||
/**
|
||||
* 加解密方式
|
||||
*/
|
||||
private final static String ALGORITHM = "AES";
|
||||
|
||||
/**
|
||||
* 加密模式及填充方式
|
||||
*/
|
||||
private final static String PATTERN = "AES/CBC/pkcs5padding";
|
||||
|
||||
//AES解密
|
||||
|
||||
/**
|
||||
* @param content 密文
|
||||
* @param key aes密钥
|
||||
* @return 原文
|
||||
* @throws Exception
|
||||
*/
|
||||
public static String decrypt(String content, String key) throws Exception {
|
||||
|
||||
//反序列化AES密钥
|
||||
SecretKeySpec keySpec = new SecretKeySpec(Base64.decodeBase64(key.getBytes()), ALGORITHM);
|
||||
|
||||
//128bit全零的IV向量
|
||||
byte[] iv = new byte[16];
|
||||
for (int i = 0; i < iv.length; i++) {
|
||||
iv[i] = 0;
|
||||
}
|
||||
IvParameterSpec ivParameterSpec = new IvParameterSpec(iv);
|
||||
|
||||
//初始化加密器并加密
|
||||
Cipher deCipher = Cipher.getInstance("AES/CBC/PKCS5Padding");
|
||||
deCipher.init(Cipher.DECRYPT_MODE, keySpec, ivParameterSpec);
|
||||
byte[] encryptedBytes = Base64.decodeBase64(content.getBytes(ENCODING));
|
||||
byte[] bytes = deCipher.doFinal(encryptedBytes);
|
||||
return new String(bytes);
|
||||
}
|
||||
|
||||
public static byte[] HmacSHA256(String data, String key) throws Exception {
|
||||
Mac sha256_HMAC = Mac.getInstance("HmacSHA256");
|
||||
SecretKeySpec secret_key = new SecretKeySpec(key.getBytes(StandardCharsets.UTF_8), "HmacSHA256");
|
||||
sha256_HMAC.init(secret_key);
|
||||
byte[] array = sha256_HMAC.doFinal(data.getBytes(StandardCharsets.UTF_8));
|
||||
return array;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
Loading…
Reference in new issue