From d9c5c8b63b9b839e393935008c4b3aaa8582a93a Mon Sep 17 00:00:00 2001 From: du <1725534722@qq.com> Date: Sat, 17 May 2025 14:05:03 +0800 Subject: [PATCH] =?UTF-8?q?=E6=95=B0=E6=8D=AE=E5=AF=B9=E6=8E=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ruoyi/gysl/controller/CybqController.java | 110 ++++++++++- .../controller/SingleLoginController.java | 184 ++++++++++++++++++ .../com/ruoyi/gysl/login/util/SM2Demo.java | 113 +++++++++++ .../com/ruoyi/gysl/login/util/SM4Demo.java | 103 ++++++++++ .../com/ruoyi/gysl/regular/NoticeTiming.java | 27 +-- .../ruoyi/gysl/utils/ImgBase64Extractor.java | 55 ------ .../src/main/resources/application-druid.yml | 8 +- .../main/resources/application-internet.yml | 8 +- .../src/main/resources/application.yml | 10 + 9 files changed, 541 insertions(+), 77 deletions(-) create mode 100644 ruoyi-admin/src/main/java/com/ruoyi/gysl/login/controller/SingleLoginController.java create mode 100644 ruoyi-admin/src/main/java/com/ruoyi/gysl/login/util/SM2Demo.java create mode 100644 ruoyi-admin/src/main/java/com/ruoyi/gysl/login/util/SM4Demo.java delete mode 100644 ruoyi-admin/src/main/java/com/ruoyi/gysl/utils/ImgBase64Extractor.java diff --git a/ruoyi-admin/src/main/java/com/ruoyi/gysl/controller/CybqController.java b/ruoyi-admin/src/main/java/com/ruoyi/gysl/controller/CybqController.java index 4dfebd0..706c310 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/gysl/controller/CybqController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/gysl/controller/CybqController.java @@ -1,6 +1,12 @@ package com.ruoyi.gysl.controller; +import cn.hutool.crypto.SmUtil; +import cn.hutool.http.HttpRequest; +import cn.hutool.http.HttpResponse; +import cn.hutool.http.HttpUtil; +import cn.hutool.json.JSONObject; +import cn.hutool.json.JSONUtil; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.ruoyi.common.core.controller.BaseController; import com.ruoyi.common.core.domain.AjaxResult; @@ -8,17 +14,26 @@ import com.ruoyi.common.exception.ServiceException; import com.ruoyi.common.utils.poi.ExcelUtil; import com.ruoyi.gysl.entity.Cybq; import com.ruoyi.gysl.entity.request.CybqRequest; +import com.ruoyi.gysl.login.util.SM4Demo; import com.ruoyi.gysl.service.CybqService; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; +import org.springframework.beans.factory.annotation.Value; import org.springframework.transaction.annotation.Transactional; import org.springframework.web.bind.annotation.*; import org.springframework.web.multipart.MultipartFile; import javax.annotation.Resource; import javax.servlet.http.HttpServletResponse; -import java.io.Serializable; +import java.io.*; +import java.net.HttpURLConnection; +import java.net.URL; +import java.net.URLEncoder; +import java.nio.charset.StandardCharsets; +import java.util.Base64; +import java.util.HashMap; import java.util.List; +import java.util.Map; /** * 产业标签(GyslCybq)表控制层 @@ -36,6 +51,99 @@ public class CybqController extends BaseController { @Resource private CybqService cybqService; + + @Value("${isZs}") + private Boolean isZs; + private static final String BOUNDARY = "----WebKitFormBoundary7MA4YWxkTrZu0gW"; // 边界字符串(需唯一) + + /** + * 企业经济标签信息(统一社会信用代码) + */ + @ApiOperation("企业经济标签信息(统一社会信用代码)") + @GetMapping("/getCybq") + public AjaxResult getCybq() throws Exception { + if(true){ + String contacts = "http://172.21.10.46/api/invoke/323018/qyjjbqxx"; + String uscc = Base64.getEncoder().encodeToString((byte[]) + SM4Demo.exec("91320594067622605M".getBytes(), + "ECB", "PKCS5Padding", "random", "ef5323158e0d43e69442718cd4932116".getBytes(),null)); + String pageIndex = Base64.getEncoder().encodeToString((byte[]) + SM4Demo.exec("1".getBytes(), + "ECB", "PKCS5Padding", "random", "ef5323158e0d43e69442718cd4932116".getBytes(),null)); + String pageSize = Base64.getEncoder().encodeToString((byte[]) + SM4Demo.exec("10".getBytes(), + "ECB", "PKCS5Padding", "random", "ef5323158e0d43e69442718cd4932116".getBytes(),null)); + //生成sm3签名 + String input = "pageIndex=1&pageSize=10&uscc=91320594067622605M"; +// contacts+= "?signature="+ SmUtil.sm3(input); + System.out.println(contacts); + System.out.println(uscc); + System.out.println(pageIndex); + System.out.println(pageSize); + + try { + // 1. 构建 URL(含签名参数,处理特殊符号) + String encodedSignature = URLEncoder.encode(SmUtil.sm3(input), "UTF-8") + .replace("+", "%20"); // 确保 + 不被编码为空格 + String fullUrl = contacts + "?signature=" + encodedSignature; + System.out.println(fullUrl); + // 2. 创建连接 + URL url = new URL(fullUrl); + HttpURLConnection conn = (HttpURLConnection) url.openConnection(); + conn.setRequestMethod("POST"); + conn.setDoOutput(true); + conn.setRequestProperty("Content-Type", "multipart/form-data; boundary=" + BOUNDARY); + + // 3. 构建请求体(严格对齐 curl -F 格式) + try (DataOutputStream out = new DataOutputStream(conn.getOutputStream())) { + // 参数 uscc + writeFormField(out, "uscc", uscc); + // 参数 pageIndex + writeFormField(out, "pageIndex", pageIndex); + // 参数 pageSize + writeFormField(out, "pageSize", pageSize); + // 结束标记 + out.writeBytes("--" + BOUNDARY + "--\r\n"); + } + + // 4. 处理响应 + int statusCode = conn.getResponseCode(); + StringBuilder response = new StringBuilder(); + try (BufferedReader in = new BufferedReader(new InputStreamReader( + (statusCode >= 200 && statusCode < 300) ? conn.getInputStream() : conn.getErrorStream(), + StandardCharsets.UTF_8))) { + String line; + while ((line = in.readLine()) != null) { + response.append(line); + } + } + + System.out.println("状态码: " + statusCode); + System.out.println("响应内容:\n" + response.toString()); + + } catch (Exception e) { + e.printStackTrace(); + } + +// if (response.getStatus() == 200) { +// System.out.println(response.body()); +// JSONObject jsonObj = JSONUtil.parseObj(response.body()); +// if ("200".equals(jsonObj.get("code"))) { +// JSONObject reqData = JSONUtil.parseObj(jsonObj.get("data")); +// JSONArray arr = reqData.getJSONArray("data"); // 直接获取数组,无需再次解析 +// int total = reqData.getInt("total"); // 只需解析一次total并转换为整数 +// } +// } + } + return success(); + } + private static void writeFormField(DataOutputStream out, String name, String value) throws Exception { + out.writeBytes("--" + BOUNDARY + "\r\n"); + out.writeBytes("Content-Disposition: form-data; name=\"" + name + "\"\r\n"); + out.writeBytes("Content-Type: text/plain; charset=UTF-8\r\n\r\n"); + out.writeBytes(value + "\r\n"); + } + /** * 分页查询所有数据 * diff --git a/ruoyi-admin/src/main/java/com/ruoyi/gysl/login/controller/SingleLoginController.java b/ruoyi-admin/src/main/java/com/ruoyi/gysl/login/controller/SingleLoginController.java new file mode 100644 index 0000000..5b0d042 --- /dev/null +++ b/ruoyi-admin/src/main/java/com/ruoyi/gysl/login/controller/SingleLoginController.java @@ -0,0 +1,184 @@ +package com.ruoyi.gysl.login.controller; + +/** + * @author dong + * @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.ruoyi.common.core.domain.AjaxResult; +import com.ruoyi.common.core.redis.RedisCache; +import com.ruoyi.common.exception.ServiceException; +import com.ruoyi.gysl.login.dto.response.UserMainResponse; +import com.ruoyi.gysl.login.dto.response.UserResponse; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +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 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; + +/** + * 单点登陆 + */ +@Api(tags = "企业端单点登陆") +@RestController +@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; + + @Value("${returnUrl}") + private String returnUrl; + + @Resource + private RedisCache redisCache; + + + @Value("${enterpriseAppId}") + private String enterpriseAppId; + + @Value("${enterpriseAppsecret}") + private String enterpriseAppsecret; + + /** + * 统一登陆 + */ + @ApiOperation("统一登陆") + @GetMapping("/login") + public void login(HttpServletResponse response) throws IOException { + //变成参数模式,appid 用于校验提交的来源地址,生产环境会校验,试用环境暂不校验 + String scUrl = "clientUrl=" + URLEncoder.encode(returnUrl, "UTF-8") + "?appid=" + enterpriseAppId; + //加密后的客户端地址 + scUrl = Base64.getEncoder().encodeToString(scUrl.getBytes()); + //最终跳转地址 + String jumpurl = url + "?scUrl=" + URLEncoder.encode(scUrl, "UTF-8"); + // 添加请求头 + response.setHeader("Content-Type", "application/json"); + response.setHeader("X-Requested-With", "XMLHttpRequest"); + response.sendRedirect(jumpurl); + } + + + /** + * 获取用户信息 + * + * @return 用户信息 + */ + @ApiOperation(value = "获取用户信息", response = UserResponse.class) + @GetMapping("/getInfo") + public AjaxResult getInfo(String clientToken) throws Exception { + HttpResponse response = HttpUtil.createGet(infoUrl) + .form("clienttoken", clientToken) +// .addHeaders(generationHeader()) + .execute(); + String responseBody; + // 获取响应状态码 + int statusCode = response.getStatus(); + if (statusCode == 200) { + // 获取响应内容 + responseBody = response.body(); + JSONObject jsonObj = JSONUtil.parseObj(responseBody); + JSONObject dataObj = jsonObj.getJSONObject("data"); + // 设置过期时间(可选) + int expirationSeconds = 24 * 60; + // 将用户信息存储到Redis中 + String key = "user:" + clientToken; + //判断是法人用户 + if ("ep".equals(dataObj.get("usertype"))) { + JSONObject mainobj = dataObj.getJSONObject("mainbody"); + UserResponse res = JSONUtil.toBean(dataObj, UserResponse.class); + UserMainResponse req = JSONUtil.toBean(mainobj, UserMainResponse.class); + + //如果在企业库里面找不到该企业就返回错误 +// BmsEnterpriseBasicInfo bmsEnterpriseBasicInfo = +// bmsEnterpriseBasicInfoMapper.findByQytyxydm(req.getUscc()); + Long id; +// if (bmsEnterpriseBasicInfo == null) { +// throw new ServiceException("该企业不在库!请稍后再试!"); +// } else { +// id = bmsEnterpriseBasicInfo.getId(); +// } + // 设置过期时间为8小时 +// String token = singleLoginService.singleLogin(req.getUscc(), req.getEpname(), id, "01", null,null); +// res.setToken(token); +// res.setMain(req); +// redisCache.setCacheObject(key, res, expirationSeconds, TimeUnit.MINUTES); + + return AjaxResult.success(res); + } else { + log.error(response.body()); + throw new ServiceException("该用户不是企业法人"); + } + } else { + log.error(response.body()); + throw new ServiceException("未知异常请联系管理员"); + } + } + + /** + * 退出登录 + * + * @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(generationHeader()) + .execute(); + String str; + // 获取响应状态码 + int statusCode = execute.getStatus(); + if (statusCode == 200) { + str = "退出成功"; + } else { + str = "退出失败"; + } + return AjaxResult.success(str); + } + + /** + * 正式环境需要的请求头 + * + * @return 请求头 + */ + private 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 + enterpriseAppsecret + format)); + return headers; + } +} \ No newline at end of file diff --git a/ruoyi-admin/src/main/java/com/ruoyi/gysl/login/util/SM2Demo.java b/ruoyi-admin/src/main/java/com/ruoyi/gysl/login/util/SM2Demo.java new file mode 100644 index 0000000..d0954a2 --- /dev/null +++ b/ruoyi-admin/src/main/java/com/ruoyi/gysl/login/util/SM2Demo.java @@ -0,0 +1,113 @@ +package com.ruoyi.gysl.login.util; + +import org.bouncycastle.crypto.engines.SM2Engine; +import org.bouncycastle.crypto.engines.SM2Engine.Mode; +import org.bouncycastle.crypto.params.ECDomainParameters; +import org.bouncycastle.crypto.params.ECPrivateKeyParameters; +import org.bouncycastle.crypto.params.ECPublicKeyParameters; +import org.bouncycastle.crypto.params.ParametersWithRandom; +import org.bouncycastle.jce.interfaces.ECPrivateKey; +import org.bouncycastle.jce.interfaces.ECPublicKey; +import org.bouncycastle.jce.provider.BouncyCastleProvider; +import org.bouncycastle.jce.spec.ECParameterSpec; +import org.bouncycastle.math.ec.ECCurve; +import org.bouncycastle.math.ec.ECPoint; + +import java.math.BigInteger; +import java.nio.charset.StandardCharsets; +import java.security.KeyFactory; +import java.security.Security; +import java.security.spec.PKCS8EncodedKeySpec; +import java.security.spec.X509EncodedKeySpec; +import java.util.Base64; + +public class SM2Demo { + /** + * 国密SM2加密算法,对标RSA + */ + + private static final String ALGORITHM = "SM2"; + private static final String SM2 = "EC"; + private static final String C1C2C3 = "C1C2C3"; + + + /** + * 加密方法 + * @param objects + * @return + * @throws Exception + */ + + public static Object exec(Object... objects) throws Exception { + if (objects == null || objects.length != 3) { + return null; + } + byte[] message = (byte[]) objects[0]; + String order = objects[1].toString(); + byte[] publicKey = (byte[]) objects[2]; + ECPublicKey ecPublicKey = (ECPublicKey) KeyFactory.getInstance(SM2, new BouncyCastleProvider()) + .generatePublic(new X509EncodedKeySpec(publicKey)); + ECPublicKeyParameters ecPublicKeyParameters = getPublicKeyParameters(ecPublicKey); + Mode mode = order.equals(C1C2C3) ? Mode.C1C2C3 : Mode.C1C3C2; + SM2Engine sm2Engine = new SM2Engine(mode); + sm2Engine.init(true, new ParametersWithRandom(ecPublicKeyParameters)); + return sm2Engine.processBlock(message, 0, message.length); + } + /** + * 解密方法 + * @param objects + * @return + * @throws Exception + */ + public static Object dexec(Object... objects) throws Exception { + if (objects == null || objects.length != 3) { + return null; + } + byte[] message = (byte[]) objects[0]; + String order = objects[1].toString(); + byte[] privateKey = (byte[]) objects[2]; + + ECPrivateKey ecPrivateKey = (ECPrivateKey) KeyFactory.getInstance(SM2, new BouncyCastleProvider()) + .generatePrivate(new PKCS8EncodedKeySpec(privateKey)); + ECPrivateKeyParameters privateKeyParameters = getPrivateKeyParameters(ecPrivateKey); + Mode mode = order.equals(C1C2C3) ? Mode.C1C2C3 : Mode.C1C3C2; + SM2Engine sm2Engine = new SM2Engine(mode); + sm2Engine.init(false, privateKeyParameters); + return sm2Engine.processBlock(message, 0, message.length); + } + + private static ECPublicKeyParameters getPublicKeyParameters(ECPublicKey ecPublicKey) { + ECParameterSpec parameterSpec = ecPublicKey.getParameters(); + ECCurve curve = parameterSpec.getCurve(); + ECPoint g = parameterSpec.getG(); + BigInteger n = parameterSpec.getN(); + BigInteger h = parameterSpec.getH(); + ECDomainParameters domainParams = new ECDomainParameters(curve, g, n, h); + return new ECPublicKeyParameters(ecPublicKey.getQ(), domainParams); + } + + private static ECPrivateKeyParameters getPrivateKeyParameters(ECPrivateKey ecPrivateKey) { + ECParameterSpec parameterSpec = ecPrivateKey.getParameters(); + ECCurve curve = parameterSpec.getCurve(); + ECPoint g = parameterSpec.getG(); + BigInteger n = parameterSpec.getN(); + BigInteger h = parameterSpec.getH(); + ECDomainParameters domainParams = new ECDomainParameters(curve, g, n, h); + return new ECPrivateKeyParameters(ecPrivateKey.getD(), domainParams); + } + +// public static void main(String[] args) throws Exception { +// SM2Demo computeFactor = new SM2Demo(); +// String pub = "XXXX";//公钥 +// String pri = "XXXX";//私钥 +// //待加密字符串 +// String text = "XXXXXXXXXXXXXX"; +// Object result = computeFactor +// .exec(text.getBytes(StandardCharsets.UTF_8), "C1C2C3", Base64.getDecoder().decode(pub)); +// System.out.println("加密: " + Base64.getEncoder().encodeToString((byte[]) result)); +// //待解密base64编码 +// String encode = "XXXXXXXXXXXXX"; +// Object result1 = computeFactor.dexec(Base64.getDecoder().decode(encode), "C1C2C3", Base64.getDecoder().decode(pri)); +// System.out.println("解密: " + new String((byte[]) result1, StandardCharsets.UTF_8)); +// } +} diff --git a/ruoyi-admin/src/main/java/com/ruoyi/gysl/login/util/SM4Demo.java b/ruoyi-admin/src/main/java/com/ruoyi/gysl/login/util/SM4Demo.java new file mode 100644 index 0000000..4a2cd64 --- /dev/null +++ b/ruoyi-admin/src/main/java/com/ruoyi/gysl/login/util/SM4Demo.java @@ -0,0 +1,103 @@ +package com.ruoyi.gysl.login.util; + +import org.apache.commons.lang3.StringUtils; +import org.bouncycastle.jce.provider.BouncyCastleProvider; + +import javax.crypto.Cipher; +import javax.crypto.KeyGenerator; +import javax.crypto.SecretKey; +import javax.crypto.spec.IvParameterSpec; +import javax.crypto.spec.SecretKeySpec; +import java.nio.charset.Charset; +import java.security.Key; +import java.security.NoSuchAlgorithmException; +import java.security.SecureRandom; +import java.security.Security; +import java.util.Base64; + +public class SM4Demo { + /** + * 国密SM4,对标 DES + */ + private static final String ALGORITHM = "SM4"; + private static final Integer KEY_SIZE = 128; + + static { + Security.addProvider(new BouncyCastleProvider()); + } + + public static Key getKey(String algorithm, int length, String passwordType, byte[] password) + throws NoSuchAlgorithmException { + Key key; + if (passwordType == null || passwordType.equals("fix")) { + key = new SecretKeySpec(password, algorithm); + } else { + KeyGenerator keyGenerator = KeyGenerator.getInstance(algorithm); + SecureRandom secureRandom = SecureRandom.getInstance("SHA1PRNG"); + secureRandom.setSeed(password); + keyGenerator.init(length, secureRandom); + SecretKey secretKey = keyGenerator.generateKey(); + key = new SecretKeySpec(secretKey.getEncoded(), algorithm); + } + return key; + } + + public static Cipher getCipher(Key key, String algorithm, String mode, String padding, int encryptMode, byte[] iv, + BouncyCastleProvider provider) + throws Exception { + Cipher cipher = Cipher.getInstance(StringUtils.join(new String[]{algorithm, mode, padding}, "/"), provider); + if (mode.equals("ECB")) { + cipher.init(encryptMode, key); + } else if (mode.equals("CBC") && iv != null) { + IvParameterSpec ivSpec = new IvParameterSpec(iv); + cipher.init(encryptMode, key, ivSpec); + } + return cipher; + } + public static Object exec(Object... objects) throws Exception { + if (objects == null || objects.length != 6) { + return null; + } + byte[] message = (byte[]) objects[0]; + String mode = objects[1].toString(); + String padding = objects[2].toString(); + String passwordType = objects[3].toString(); + byte[] password = (byte[]) objects[4]; + byte[] iv = (byte[]) objects[5]; + Key key = SM4Demo.getKey(ALGORITHM, KEY_SIZE, passwordType, password); + Cipher cipher = SM4Demo + .getCipher(key, ALGORITHM, mode, padding, Cipher.ENCRYPT_MODE, iv, new BouncyCastleProvider()); + return cipher.doFinal(message); + } + + public static Object dexec(Object... objects) throws Exception { + if (objects == null || objects.length != 6) { + return null; + } + byte[] message = (byte[]) objects[0]; + String mode = objects[1].toString(); + String padding = objects[2].toString(); + String passwordType = objects[3].toString(); + byte[] password = (byte[]) objects[4]; + byte[] iv = (byte[]) objects[5]; + Key key = SM4Demo.getKey(ALGORITHM, KEY_SIZE, passwordType, password); + Cipher cipher = SM4Demo + .getCipher(key, ALGORITHM, mode, padding, Cipher.DECRYPT_MODE, iv, new BouncyCastleProvider()); + return cipher.doFinal(message); + } + + public static void main(String[] args) throws Exception { + //待加密字符串 + String content = "91320594067622605M"; + SM4Demo computeFactor = new SM4Demo(); + Object result = computeFactor + .exec(content.getBytes(), "ECB", "PKCS5Padding", "random", "ef5323158e0d43e69442718cd4932116".getBytes(), + null); + System.out.println(Base64.getEncoder().encodeToString((byte[]) result)); + //待解密的字符串 + String encodeSM2String="t/lpTpuW6JeN+JhACXkWqWeHr55Bwj5BTBgMmG5a9+w="; + Object result2 = computeFactor.dexec(Base64.getDecoder().decode(encodeSM2String), "ECB", "PKCS5Padding", "random", "ef5323158e0d43e69442718cd4932116".getBytes(),null); + System.out.println(new String((byte[]) result2, Charset.forName("utf-8"))); + + } +} diff --git a/ruoyi-admin/src/main/java/com/ruoyi/gysl/regular/NoticeTiming.java b/ruoyi-admin/src/main/java/com/ruoyi/gysl/regular/NoticeTiming.java index 6b575e6..0c70273 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/gysl/regular/NoticeTiming.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/gysl/regular/NoticeTiming.java @@ -5,6 +5,9 @@ import com.ruoyi.docking.entity.SmartReminders; import com.ruoyi.docking.service.*; import com.ruoyi.gysl.entity.BasicInformation; import com.ruoyi.gysl.service.BasicInformationService; +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; @@ -22,9 +25,9 @@ import java.util.List; * @author du * @since 2025/3/23 16:35 */ -//@Configuration -//@EnableScheduling -@Component +@Configuration +@EnableScheduling +//@Component public class NoticeTiming { @@ -49,7 +52,7 @@ public class NoticeTiming { /** * 每个月固定发一次政务通知 */ -// @Scheduled(cron = "0 0 0 1 * ?") + @Scheduled(cron = "0 0 0 1 * ?") private void configureTasks() { userService.getAllZwUser(LocalDate.now().getYear() + "年" + @@ -58,25 +61,11 @@ public class NoticeTiming { "项目进展未填写", null, null, String.valueOf(LocalDate.now().getMonth().getValue())); } - /** - * 每个月1号的2点进行上个月的项目月度信息查询并进行新增 - */ -// @Scheduled(cron = "0 0 2 1 * ?") // 每月1号 2:00:00 执行 -// private void changeProgress() { -// List pList = projectProgressService.djList(); -// //修改该progressId为空 -// pList.forEach(x-> x.setProgressId(null)); -// //批量新增 -// projectProgressService.saveBatch(pList); -// -// List pjList = projectService.djList(); -// projectService.saveBatch(pjList); -// } /** * 定时不定期提醒 */ -// @Scheduled(cron = "0 40 1 * * *") + @Scheduled(cron = "0 40 1 * * *") public void changeNdq() { //获取企业的不定时提醒 SmartReminders qy = smartRemindersService.getById(1); diff --git a/ruoyi-admin/src/main/java/com/ruoyi/gysl/utils/ImgBase64Extractor.java b/ruoyi-admin/src/main/java/com/ruoyi/gysl/utils/ImgBase64Extractor.java deleted file mode 100644 index 3538f36..0000000 --- a/ruoyi-admin/src/main/java/com/ruoyi/gysl/utils/ImgBase64Extractor.java +++ /dev/null @@ -1,55 +0,0 @@ -package com.ruoyi.gysl.utils; - -import java.io.ByteArrayOutputStream; -import java.io.IOException; -import java.io.InputStream; -import java.net.HttpURLConnection; -import java.net.MalformedURLException; -import java.net.URL; -import java.net.URLConnection; -import java.util.ArrayList; -import java.util.Base64; -import java.util.List; - -public class ImgBase64Extractor { - - public static void main(String[] args) throws IOException { - String imgUrl ="http://39.101.188.84:7071/profile/upload/2025/03/24/abc_20250324154129A006.jpg"; - - URL url = new URL(imgUrl); - HttpURLConnection connection = (HttpURLConnection) url.openConnection(); - connection.setRequestMethod("GET"); - connection.setDoInput(true); - // 添加请求头 - connection.setRequestProperty("User-Agent", "Mozilla/5.0"); - connection.setRequestProperty("Accept", "image/webp,image/apng,image/*,*/*;q=0.8"); - connection.setRequestProperty("Accept-Language", "en-US,en;q=0.5"); - - // 连接并获取响应 - connection.connect(); - - // 检查响应码 - int responseCode = connection.getResponseCode(); - if (responseCode == HttpURLConnection.HTTP_OK) { - // 连接成功,获取输入流 - InputStream inputStream = connection.getInputStream(); - - // 读取输入流 - ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); - byte[] buffer = new byte[1024]; - int bytesRead; - - while ((bytesRead = inputStream.read(buffer)) != -1) { - outputStream.write(buffer, 0, bytesRead); - } - - inputStream.close(); - byte[] imageBytes = outputStream.toByteArray(); - System.out.println(imageBytes); - } else { - System.out.println("Error: Server returned HTTP response code: " + responseCode); - - } - } - -} diff --git a/ruoyi-admin/src/main/resources/application-druid.yml b/ruoyi-admin/src/main/resources/application-druid.yml index de0c563..be5b7e9 100644 --- a/ruoyi-admin/src/main/resources/application-druid.yml +++ b/ruoyi-admin/src/main/resources/application-druid.yml @@ -60,4 +60,10 @@ spring: config: multi-statement-allow: true # 是否是正式环境 -isZs: false \ No newline at end of file +isZs: false +#企业端正式环境应用系统编号 +enterpriseAppId: 03f70874-39e9-11ef-bbd6-fa163e2b2e10 +# 应用私钥 +enterpriseAppsecret: 03f70874-39e9-11ef-bbd6-fa163e2b2e10 +#自己客户端地址 +returnUrl: https://idp.sipac.gov.cn/bms \ No newline at end of file diff --git a/ruoyi-admin/src/main/resources/application-internet.yml b/ruoyi-admin/src/main/resources/application-internet.yml index 9cbf2f4..781e3d1 100644 --- a/ruoyi-admin/src/main/resources/application-internet.yml +++ b/ruoyi-admin/src/main/resources/application-internet.yml @@ -115,4 +115,10 @@ swagger: # 请求前缀 pathMapping: / # 是否是正式环境 -isZs: true \ No newline at end of file +isZs: true +#企业端正式环境应用系统编号 +enterpriseAppId: 03f70874-39e9-11ef-bbd6-fa163e2b2e10 +# 应用私钥 +enterpriseAppsecret: 03f70874-39e9-11ef-bbd6-fa163e2b2e10 +#自己客户端地址 +returnUrl: https://idp.sipac.gov.cn/bms \ No newline at end of file diff --git a/ruoyi-admin/src/main/resources/application.yml b/ruoyi-admin/src/main/resources/application.yml index 2e68950..7b9ab88 100644 --- a/ruoyi-admin/src/main/resources/application.yml +++ b/ruoyi-admin/src/main/resources/application.yml @@ -140,3 +140,13 @@ getInfoId: https://172.21.10.12/enterprise-gateway/sipsg-enterprise/sys/third/us #政务端政务通获取用户信息接口(可选) getAllInfo: http://172.21.10.14/open/api/identity/data/FindUserById + +#企业端单点登陆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 +#企业端退出登录url +logoutUrl: https://qytt.sipac.gov.cn/api/usercenter/User/ssoLogOut +