zhangying 1 тиждень тому
батько
коміт
685f340532

+ 45 - 36
zjrs-service-backend/src/main/java/com/zjrs/ggfw/portal/bpo/impl/UserBPOImpl.java

@@ -31,13 +31,16 @@ import org.springframework.http.HttpHeaders;
 import org.springframework.stereotype.Service;
 
 import javax.imageio.ImageIO;
-import javax.servlet.ServletOutputStream;
-import javax.servlet.http.HttpServletResponse;
+import jakarta.servlet.ServletOutputStream;
+import jakarta.servlet.http.HttpServletResponse;
 import java.io.ByteArrayOutputStream;
 import java.io.IOException;
 import java.time.LocalDateTime;
 import java.time.format.DateTimeFormatter;
 import java.util.*;
+import jakarta.servlet.http.HttpServletResponse; // 确保是 jakarta
+import org.springframework.web.context.request.RequestContextHolder;
+import org.springframework.web.context.request.ServletRequestAttributes;
 
 @Service
 public class UserBPOImpl extends BPOImpl implements UserBPO {
@@ -56,8 +59,8 @@ public class UserBPOImpl extends BPOImpl implements UserBPO {
     @Autowired
     private CacheManager leafCacheManager;
 
-    @Autowired
-    private HttpServletResponse response;
+//    @Autowired
+//    private HttpServletResponse response;
 
     @Autowired
     private SendSmsMapper sendSmsMapper;
@@ -493,40 +496,46 @@ public class UserBPOImpl extends BPOImpl implements UserBPO {
      */
     @Override
     public Map<String, String> render(){
-        response.setDateHeader(HttpHeaders.EXPIRES, 0L);
-        response.setHeader(HttpHeaders.CACHE_CONTROL, "no-store, no-cache, must-revalidate");
-        response.addHeader(HttpHeaders.CACHE_CONTROL, "post-check=0, pre-check=0");
-        response.setHeader(HttpHeaders.PRAGMA, "no-cache");
-        response.setContentType("application/json;charset=UTF-8");
-
-        CaptchaAutoConfiguration bean = GgfwSpringContextUtil.getBean ("captchaAutoConfiguration",CaptchaAutoConfiguration.class);
-        DefaultKaptcha kaptcha = bean.defaultKaptcha();
-        String code = kaptcha.createText();
-        LOG.info("code="+code);
-
-        Map<String, String> ajaxResponse = new HashMap<String, String>();
-
-        ajaxResponse.put("appcode", Consts.APPCODE_SUCCESS);
-        String reqid = UUID.randomUUID().toString();
-        ajaxResponse.put("reqid", reqid);
-        try (ServletOutputStream out = response.getOutputStream()) {
-            ByteArrayOutputStream os = new ByteArrayOutputStream();
-            ImageIO.write(kaptcha.createImage(code), "jpg", os);
-            ajaxResponse.put("codeimg", Base64.getEncoder().encodeToString(os.toByteArray()));
-            StringBuilder sb = new StringBuilder(JSONObject.toJSONString(ajaxResponse));
-            out.write(sb.toString().getBytes("utf-8"));
-            //放入缓存
-            ValidCodeCacheDTO codeCacheDTO = new ValidCodeCacheDTO();
-            codeCacheDTO.setCode(code);
-            codeCacheDTO.setStarttime(System.currentTimeMillis());
-            Cache cache = leafCacheManager.getCache(IMGCACHENAME);
-
-            cache.put(getCodeCacheKey(reqid), codeCacheDTO);
+        ServletRequestAttributes servletRequestAttributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
+        if (servletRequestAttributes != null) {
+            HttpServletResponse response = servletRequestAttributes.getResponse();
+            response.setDateHeader(HttpHeaders.EXPIRES, 0L);
+            response.setHeader(HttpHeaders.CACHE_CONTROL, "no-store, no-cache, must-revalidate");
+            response.addHeader(HttpHeaders.CACHE_CONTROL, "post-check=0, pre-check=0");
+            response.setHeader(HttpHeaders.PRAGMA, "no-cache");
+            response.setContentType("application/json;charset=UTF-8");
+
+            CaptchaAutoConfiguration bean = GgfwSpringContextUtil.getBean ("captchaAutoConfiguration",CaptchaAutoConfiguration.class);
+            DefaultKaptcha kaptcha = bean.defaultKaptcha();
+            String code = kaptcha.createText();
+            LOG.info("code="+code);
+
+            Map<String, String> ajaxResponse = new HashMap<String, String>();
+
+            ajaxResponse.put("appcode", Consts.APPCODE_SUCCESS);
+            String reqid = UUID.randomUUID().toString();
+            ajaxResponse.put("reqid", reqid);
+            try (ServletOutputStream out = response.getOutputStream()) {
+                ByteArrayOutputStream os = new ByteArrayOutputStream();
+                ImageIO.write(kaptcha.createImage(code), "jpg", os);
+                ajaxResponse.put("codeimg", Base64.getEncoder().encodeToString(os.toByteArray()));
+                StringBuilder sb = new StringBuilder(JSONObject.toJSONString(ajaxResponse));
+                out.write(sb.toString().getBytes("utf-8"));
+                //放入缓存
+                ValidCodeCacheDTO codeCacheDTO = new ValidCodeCacheDTO();
+                codeCacheDTO.setCode(code);
+                codeCacheDTO.setStarttime(System.currentTimeMillis());
+                Cache cache = leafCacheManager.getCache(IMGCACHENAME);
+
+                cache.put(getCodeCacheKey(reqid), codeCacheDTO);
+                return ajaxResponse;
+            } catch (IOException e) {
+                LOG.info("验证码生成失败");
+            }
             return ajaxResponse;
-        } catch (IOException e) {
-            LOG.info("验证码生成失败");
         }
-        return ajaxResponse;
+
+        return new HashMap<>();
     }
     private String getCodeCacheKey(String reqid){
         return "ValidCode"+reqid;

+ 2 - 2
zjrs-service-backend/src/main/java/com/zjrs/ggfw/portal/controller/CaptchaController.java

@@ -10,8 +10,8 @@ import org.springframework.web.bind.annotation.GetMapping;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
 
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
+import jakarta.servlet.http.HttpServletRequest;
+import jakarta.servlet.http.HttpServletResponse;
 
 /**
  * 验证码控制器

+ 1 - 1
zjrs-service-backend/src/main/java/com/zjrs/ggfw/portal/controller/EMSController.java

@@ -23,7 +23,7 @@ import org.springframework.web.bind.annotation.RequestBody;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
 
-import javax.servlet.http.HttpServletRequest;
+import jakarta.servlet.http.HttpServletRequest;
 import java.nio.charset.StandardCharsets;
 import java.util.HashMap;
 import java.util.Map;

+ 2 - 2
zjrs-service-backend/src/main/java/com/zjrs/ggfw/portal/controller/UserController.java

@@ -15,8 +15,8 @@ import org.springframework.validation.BindingResult;
 import org.springframework.validation.annotation.Validated;
 import org.springframework.web.bind.annotation.*;
 
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
+import jakarta.servlet.http.HttpServletRequest;
+import jakarta.servlet.http.HttpServletResponse;
 
 @Api("用户")
 @RestController

+ 1 - 4
zjrs-service-backend/src/main/java/com/zjrs/ggfw/rlzysc/blo/GrqzBLO.java

@@ -7,7 +7,7 @@ import com.zjrs.ggfw.rlzysc.dto.common.PageDTO;
 import com.zjrs.ggfw.rlzysc.dto.grzxjlxx.*;
 import com.zjrs.ggfw.rlzysc.po.*;
 
-import javax.servlet.http.HttpServletResponse;
+import jakarta.servlet.http.HttpServletResponse;
 import java.io.IOException;
 import java.lang.reflect.InvocationTargetException;
 import java.util.List;
@@ -121,9 +121,6 @@ public interface GrqzBLO extends IBLO {
     public void updateMyJlmrzt(MrjlUDTO dto);
     public void copyMyJlxx(CopyJlDTO dto) throws Exception;
     public void exportMyJlxx(ExportJlDTO dto, HttpServletResponse res) throws IllegalAccessException, IOException, InvocationTargetException;
-
-    void exportMyJlxx(ExportJlDTO dto, jakarta.servlet.http.HttpServletResponse res) throws IllegalAccessException, IOException, InvocationTargetException;
-
     public Map getJlxx(JltotalDTO dto);
     public JlxxPO saveJljbxx(GrqzWdjlJbxxDTO dto);
     public JlxxPO saveJljbxx(GrJlxxDTO dto);

+ 0 - 5
zjrs-service-backend/src/main/java/com/zjrs/ggfw/rlzysc/blo/impl/GrqzBLOimpl.java

@@ -2076,11 +2076,6 @@ public class GrqzBLOimpl extends BLOImpl implements GrqzBLO {
         }
     }
 
-    @Override
-    public void exportMyJlxx(ExportJlDTO dto, javax.servlet.http.HttpServletResponse res) throws IllegalAccessException, IOException, InvocationTargetException {
-
-    }
-
     @Override
     public void exportMyJlxx(ExportJlDTO dto, HttpServletResponse res) throws IllegalAccessException, IOException, InvocationTargetException {
         String rsrlzyjlxxlsh = dto.getZjlsh();

+ 1 - 1
zjrs-service-backend/src/main/java/com/zjrs/ggfw/sggfw/bpo/ExportPdfQueryBPO.java

@@ -4,7 +4,7 @@ import com.yinhai.bcpcs.exceptions.ClientException;
 import com.zjrs.ggfw.sggfw.dto.Uca919DTO;
 import com.zjrs.ggfw.sggfw.dto.Ucf074DTO;
 
-import javax.servlet.http.HttpServletResponse;
+import jakarta.servlet.http.HttpServletResponse;
 import java.io.IOException;
 
 public interface ExportPdfQueryBPO {

+ 1 - 1
zjrs-service-backend/src/main/java/com/zjrs/ggfw/sggfw/bpo/impl/ExportPdfQueryBPOImpl.java

@@ -12,7 +12,7 @@ import com.zjrs.ggfw.sggfw.util.SggfwInterface;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
-import javax.servlet.http.HttpServletResponse;
+import jakarta.servlet.http.HttpServletResponse;
 import java.io.IOException;
 import java.util.HashMap;
 import java.util.Map;

+ 1 - 1
zjrs-service-backend/src/main/java/com/zjrs/ggfw/sggfw/controller/ExportPdfQueryController.java

@@ -14,7 +14,7 @@ import org.springframework.web.bind.annotation.RequestBody;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
 
-import javax.servlet.http.HttpServletResponse;
+import jakarta.servlet.http.HttpServletResponse;
 @Api(tags = "省公共服务接口:打印报表生成接口")
 @RestController
 @RequestMapping("/api/sggfw/exportPdfQuery")

+ 1 - 1
zjrs-service-backend/src/main/java/com/zjrs/ggfw/sggfw/util/DownloadFile.java

@@ -1,6 +1,6 @@
 package com.zjrs.ggfw.sggfw.util;
 
-import javax.servlet.http.HttpServletResponse;
+import jakarta.servlet.http.HttpServletResponse;
 import java.io.BufferedOutputStream;
 import java.io.OutputStream;
 import java.util.Base64;

+ 1 - 1
zjrs-service-backend/src/main/java/com/zjrs/zwnw/auth/controller/AuthController.java

@@ -12,7 +12,7 @@ import org.springframework.util.DigestUtils;
 import org.springframework.util.StringUtils;
 import org.springframework.web.bind.annotation.*;
 
-import javax.servlet.http.HttpServletRequest;
+import jakarta.servlet.http.HttpServletRequest;
 import java.nio.charset.StandardCharsets;
 import java.util.HashMap;
 import java.util.Map;

+ 1 - 1
zjrs-service-backend/src/main/java/com/zjrs/zwnw/auth/controller/UserInfoController.java

@@ -20,7 +20,7 @@ import org.springframework.util.StringUtils;
 import org.springframework.web.bind.annotation.*;
 import org.springframework.web.multipart.MultipartFile;
 
-import javax.servlet.http.HttpServletRequest;
+import jakarta.servlet.http.HttpServletRequest;
 import java.util.*;
 
 /**

+ 36 - 0
zjrs-service-backend/src/main/resources/config/cache/ehcache.xml

@@ -0,0 +1,36 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ehcache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:noNamespaceSchemaLocation="http://ehcache.org/ehcache.xsd"
+         updateCheck="false">
+    <!-- diskStore:为缓存路径,ehcache分为内存和磁盘两级,此属性定义磁盘的缓存位置。 参数解释如下: user.home –
+        用户主目录 user.dir – 用户当前工作目录 java.io.tmpdir – 默认临时文件路径 -->
+    <diskStore path="java.io.tmpdir/Leaf6_EhCache"/>
+    <!-- defaultCache:
+    默认缓存策略,当ehcache找不到定义的缓存时,则使用这个缓存策略。只能定义一个。 -->
+    <!-- name:缓存名称。
+        maxElementsInMemory:缓存最大数目
+        maxElementsOnDisk:硬盘最大缓存个数。
+        eternal:对象是否永久有效,一但设置了,timeout将不起作用。
+        overflowToDisk:是否保存到磁盘,当系统当机时
+        timeToIdleSeconds:设置对象在失效前的允许闲置时间(单位:秒),仅当eternal=false对象不是永久有效时使用,可选属性,默认值是0,也就是可闲置时间无穷大。
+        timeToLiveSeconds:设置对象在失效前允许存活时间(单位:秒),最大时间介于创建时间和失效时间之间,仅当eternal=false对象不是永久有效时使用,默认是0.,也就是对象存活时间无穷大。
+        diskPersistent:是否缓存虚拟机重启期数据Whether the disk store persists between restarts of the Virtual Machine. The default value is false.
+        diskSpoolBufferSizeMB:这个参数设置DiskStore(磁盘缓存)的缓存区大小,默认是30MB,每个Cache都应该有自己的一个缓冲区
+        diskExpiryThreadIntervalSeconds:磁盘失效线程运行时间间隔,默认是120秒
+        memoryStoreEvictionPolicy:当达到maxElementsInMemory限制时,Ehcache将会根据指定的策略去清理内存。默认策略是LRU(最近最少使用)。 可以设置为FIFO(先进先出)或是LFU(较少使用)。
+        clearOnFlush:内存数量最大时是否清除。
+        memoryStoreEvictionPolicy:内存清除可选策略有:LRU(最近最少使用,默认策略)、FIFO(先进先出)、LFU(最少访问次数)。
+        FIFO,first in first out,先进先出
+        LFU, Less Frequently Used,一直以来最少被使用,缓存的元素有一个hit属性,hit值最小的将会被清出缓存
+        LRU,Least Recently Used,最近最少使用的,缓存的元素有一个时间戳,当缓存容量满了,而又需要腾出地方来缓存新的元素的时候,那么现有缓存元素中时间戳离当前时间最远的元素将被清出缓存
+         -->
+    <defaultCache
+            eternal="false"
+            maxElementsInMemory="1000"
+            overflowToDisk="false"
+            diskPersistent="false"
+            timeToIdleSeconds="0"
+            timeToLiveSeconds="600"
+            memoryStoreEvictionPolicy="LRU"/>
+
+</ehcache>