From 1eb69824a02b4eb6d7a0f79e30a540716ead1d4a Mon Sep 17 00:00:00 2001 From: shil <452061493@qq.com> Date: Thu, 2 Apr 2026 10:45:36 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B9=8B=E5=89=8D=E6=94=B9=E7=9A=84=E7=BB=9F?= =?UTF-8?q?=E4=B8=80=E6=8F=90=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/zdxt/common/annotation/DataScope.java | 5 + .../zdxt/common/util/IdCardCryptoUtil.java | 2 +- .../zdxt/common/util/jasypt/JasyptUtils.java | 2 +- .../datascope/aspect/DataScopeAspect.java | 106 ++++++++++++------ .../auth/framework/config/CorsFilter.java | 2 +- .../src/main/resources/application-dev.yml | 12 +- .../src/main/resources/application.yml | 10 ++ .../src/main/resources/logback.xml | 99 ++++++++++++++++ .../EnforcementRegistrationController.java | 14 ++- .../impl/EnforcementCheckStatisticsImpl.java | 14 ++- .../EnforcementRegistrationServiceImpl.java | 24 ++-- ...NonEnforcementRegistrationServiceImpl.java | 12 +- .../mapper/EnforcementRegistrationMapper.xml | 4 + 13 files changed, 246 insertions(+), 60 deletions(-) create mode 100644 lib/EmergencyService/zdxtEmergencyBootStart/src/main/resources/logback.xml diff --git a/lib/EmergencyBaseLib/EmergencyCommon/src/main/java/com/zdxt/common/annotation/DataScope.java b/lib/EmergencyBaseLib/EmergencyCommon/src/main/java/com/zdxt/common/annotation/DataScope.java index 565f2518..be8c2fd6 100644 --- a/lib/EmergencyBaseLib/EmergencyCommon/src/main/java/com/zdxt/common/annotation/DataScope.java +++ b/lib/EmergencyBaseLib/EmergencyCommon/src/main/java/com/zdxt/common/annotation/DataScope.java @@ -27,6 +27,11 @@ public @interface DataScope */ public String deptField() default ""; + /** + * 额外部门id字段(与deptField以OR关系并列过滤,例如委托单位id) + */ + public String extraDeptField() default ""; + /** * 用户id替换字段 */ diff --git a/lib/EmergencyBaseLib/EmergencyCommon/src/main/java/com/zdxt/common/util/IdCardCryptoUtil.java b/lib/EmergencyBaseLib/EmergencyCommon/src/main/java/com/zdxt/common/util/IdCardCryptoUtil.java index 326a6065..ae5ce4ed 100644 --- a/lib/EmergencyBaseLib/EmergencyCommon/src/main/java/com/zdxt/common/util/IdCardCryptoUtil.java +++ b/lib/EmergencyBaseLib/EmergencyCommon/src/main/java/com/zdxt/common/util/IdCardCryptoUtil.java @@ -32,7 +32,7 @@ public class IdCardCryptoUtil { String key = "VRJHzFqJpsSZhwnsKTWNspv_GZMxTWl-bgH6DyE9Ty0"; System.out.println("====================== 示例 ======================"); // 加密 - String source_dec = "13640840165"; + String source_dec = "13823290422"; String enc = IdCardCryptoUtil.symmetricEncryptIdCard(key, source_dec); System.out.println(source_dec+" 加密后 : "+enc); // 解密 diff --git a/lib/EmergencyBaseLib/EmergencyCommon/src/main/java/com/zdxt/common/util/jasypt/JasyptUtils.java b/lib/EmergencyBaseLib/EmergencyCommon/src/main/java/com/zdxt/common/util/jasypt/JasyptUtils.java index 34ba04fa..620b9b9f 100644 --- a/lib/EmergencyBaseLib/EmergencyCommon/src/main/java/com/zdxt/common/util/jasypt/JasyptUtils.java +++ b/lib/EmergencyBaseLib/EmergencyCommon/src/main/java/com/zdxt/common/util/jasypt/JasyptUtils.java @@ -52,7 +52,7 @@ public final class JasyptUtils { //加密 String s = encryptWithMD5("szsf@zfjd", "ATPfOhpnAVp6yBas7RU"); System.out.println(s); - String channelcs1 = decryptWithMD5("2fR5TkUb/A0p4+Gp/As+LJsVCjq7pgNwJIG2OAk2yWLXY/q7DNaCDQ==", "ATPfOhpnAVp6yBas7RU"); + String channelcs1 = decryptWithMD5("+bxT7W35PF0k/5FZBYV0uwFLN+I9kZsF", "ATPfOhpnAVp6yBas7RU"); System.out.println(channelcs1); } } diff --git a/lib/EmergencyBaseLib/EmergencyCommonmDatascope/src/main/java/com/zdxt/common/datascope/aspect/DataScopeAspect.java b/lib/EmergencyBaseLib/EmergencyCommonmDatascope/src/main/java/com/zdxt/common/datascope/aspect/DataScopeAspect.java index 4fa8cd01..6771e45f 100644 --- a/lib/EmergencyBaseLib/EmergencyCommonmDatascope/src/main/java/com/zdxt/common/datascope/aspect/DataScopeAspect.java +++ b/lib/EmergencyBaseLib/EmergencyCommonmDatascope/src/main/java/com/zdxt/common/datascope/aspect/DataScopeAspect.java @@ -93,7 +93,7 @@ public class DataScopeAspect { User currentUser = (User) cacheKeys; if (!currentUser.isAdmin()){ dataScopeFilter(joinPoint, currentUser, controllerDataScope.deptAlias(), - controllerDataScope.userAlias(), controllerDataScope.deptField(), controllerDataScope.userField()); + controllerDataScope.userAlias(), controllerDataScope.deptField(), controllerDataScope.userField(), controllerDataScope.extraDeptField()); } }else{ @@ -103,7 +103,7 @@ public class DataScopeAspect { User appUser = (User) redisKeys; if (!appUser.isAdmin()){ dataScopeFilter(joinPoint, appUser, controllerDataScope.deptAlias(), - controllerDataScope.userAlias(), controllerDataScope.deptField(), controllerDataScope.userField()); + controllerDataScope.userAlias(), controllerDataScope.deptField(), controllerDataScope.userField(), controllerDataScope.extraDeptField()); } } } @@ -123,9 +123,13 @@ public class DataScopeAspect { * * @param joinPoint 切点 * @param user 用户 - * @param userAlias 别名 + * @param deptAlias 部门别名 + * @param userAlias 用户别名 + * @param deptField 部门字段 + * @param userField 用户字段 + * @param extraDeptField 额外部门字段(与deptField以OR关系并列,例如委托单位id) */ - public static void dataScopeFilter(JoinPoint joinPoint, User user, String deptAlias, String userAlias, String deptField, String userField) { + public static void dataScopeFilter(JoinPoint joinPoint, User user, String deptAlias, String userAlias, String deptField, String userField, String extraDeptField) { StringBuilder sqlString = new StringBuilder(); for (Role role : user.getRoles()) { @@ -134,64 +138,102 @@ public class DataScopeAspect { sqlString = new StringBuilder(); break; } else if (DATA_SCOPE_CUSTOM.equals(dataScope)) { + String deptCondition; if(StringUtils.isEmpty(deptAlias)){ if(!StringUtils.isEmpty(deptField)){ - sqlString.append(StringUtils.format( - " OR {} IN ( SELECT dept_id FROM sys_role_dept WHERE role_id = {} ) ", deptField, - role.getRoleId())); + deptCondition = StringUtils.format( + "{} IN ( SELECT dept_id FROM sys_role_dept WHERE role_id = {} )", deptField, + role.getRoleId()); } else { - sqlString.append(StringUtils.format( - " OR {} dept_id IN ( SELECT dept_id FROM sys_role_dept WHERE role_id = {} ) ", deptAlias, - role.getRoleId())); + deptCondition = StringUtils.format( + "dept_id IN ( SELECT dept_id FROM sys_role_dept WHERE role_id = {} )", + role.getRoleId()); } }else{ if(!StringUtils.isEmpty(deptField)){ - sqlString.append(StringUtils.format( - " OR {}.{} IN ( SELECT dept_id FROM sys_role_dept WHERE role_id = {} ) ", deptAlias, deptField, - role.getRoleId())); + deptCondition = StringUtils.format( + "{}.{} IN ( SELECT dept_id FROM sys_role_dept WHERE role_id = {} )", deptAlias, deptField, + role.getRoleId()); } else { - sqlString.append(StringUtils.format( - " OR {}.dept_id IN ( SELECT dept_id FROM sys_role_dept WHERE role_id = {} ) ", deptAlias, - role.getRoleId())); + deptCondition = StringUtils.format( + "{}.dept_id IN ( SELECT dept_id FROM sys_role_dept WHERE role_id = {} )", deptAlias, + role.getRoleId()); } } + // 额外部门字段(如委托单位),以OR并列 + if(!StringUtils.isEmpty(extraDeptField)){ + String extraCondition; + if(StringUtils.isEmpty(deptAlias)){ + extraCondition = StringUtils.format( + "{} IN ( SELECT dept_id FROM sys_role_dept WHERE role_id = {} )", extraDeptField, + role.getRoleId()); + }else{ + extraCondition = StringUtils.format( + "{}.{} IN ( SELECT dept_id FROM sys_role_dept WHERE role_id = {} )", deptAlias, extraDeptField, + role.getRoleId()); + } + sqlString.append(" OR (" + deptCondition + " OR " + extraCondition + ")"); + } else { + sqlString.append(" OR " + deptCondition); + } } else if (DATA_SCOPE_DEPT.equals(dataScope)) { + String deptCondition; //别名为空 if(StringUtils.isEmpty(deptAlias)) { if(!StringUtils.isEmpty(deptField)){ - sqlString.append(StringUtils.format(" OR {} = '{}' ", deptField, user.getDeptId())); + deptCondition = StringUtils.format("{} = '{}'", deptField, user.getDeptId()); } else { - sqlString.append(StringUtils.format(" OR {} dept_id = '{}' ", deptAlias, user.getDeptId())); + deptCondition = StringUtils.format("dept_id = '{}'", user.getDeptId()); } }else{ //别名不为空 if(!StringUtils.isEmpty(deptField)){ - sqlString.append(StringUtils.format(" OR {}.{} = '{}' ", deptAlias, deptField, user.getDeptId())); + deptCondition = StringUtils.format("{}.{} = '{}'", deptAlias, deptField, user.getDeptId()); } else { - sqlString.append(StringUtils.format(" OR {}.dept_id = '{}' ", deptAlias, user.getDeptId())); + deptCondition = StringUtils.format("{}.dept_id = '{}'", deptAlias, user.getDeptId()); + } + } + // 额外部门字段(如委托单位),以OR并列 + if(!StringUtils.isEmpty(extraDeptField)){ + String extraCondition; + if(StringUtils.isEmpty(deptAlias)){ + extraCondition = StringUtils.format("{} = '{}'", extraDeptField, user.getDeptId()); + }else{ + extraCondition = StringUtils.format("{}.{} = '{}'", deptAlias, extraDeptField, user.getDeptId()); } + sqlString.append(" OR (" + deptCondition + " OR " + extraCondition + ")"); + } else { + sqlString.append(" OR " + deptCondition); } } else if (DATA_SCOPE_DEPT_AND_CHILD.equals(dataScope)) { + String deptSubQuery = StringUtils.format( + "SELECT dept_id FROM sys_dept WHERE dept_id = '{}' or find_in_set( '{}' , ancestors ) <> 0", + user.getDeptId(), user.getDeptId()); + String deptCondition; if(StringUtils.isEmpty(deptAlias)){ if(!StringUtils.isEmpty(deptField)){ - sqlString.append(StringUtils.format( - " OR {} IN ( SELECT dept_id FROM sys_dept WHERE dept_id = '{}' or find_in_set( '{}' , ancestors ) <> 0 )", - deptField, user.getDeptId(), user.getDeptId())); + deptCondition = StringUtils.format("{} IN ( {} )", deptField, deptSubQuery); } else { - sqlString.append(StringUtils.format( - " OR {} dept_id IN ( SELECT dept_id FROM sys_dept WHERE dept_id = '{}' or find_in_set( '{}' , ancestors ) <> 0 )", - deptAlias, user.getDeptId(), user.getDeptId())); + deptCondition = StringUtils.format("dept_id IN ( {} )", deptSubQuery); } }else{ if(!StringUtils.isEmpty(deptField)){ - sqlString.append(StringUtils.format( - " OR {}.{} IN ( SELECT dept_id FROM sys_dept WHERE dept_id = '{}' or find_in_set( '{}' , ancestors ) <> 0 )", - deptAlias, deptField, user.getDeptId(), user.getDeptId())); + deptCondition = StringUtils.format("{}.{} IN ( {} )", deptAlias, deptField, deptSubQuery); } else { - sqlString.append(StringUtils.format( - " OR {}.dept_id IN ( SELECT dept_id FROM sys_dept WHERE dept_id = '{}' or find_in_set( '{}' , ancestors ) <> 0 )", - deptAlias, user.getDeptId(), user.getDeptId())); + deptCondition = StringUtils.format("{}.dept_id IN ( {} )", deptAlias, deptSubQuery); + } + } + // 额外部门字段(如委托单位),以OR并列 + if(!StringUtils.isEmpty(extraDeptField)){ + String extraCondition; + if(StringUtils.isEmpty(deptAlias)){ + extraCondition = StringUtils.format("{} IN ( {} )", extraDeptField, deptSubQuery); + }else{ + extraCondition = StringUtils.format("{}.{} IN ( {} )", deptAlias, extraDeptField, deptSubQuery); } + sqlString.append(" OR (" + deptCondition + " OR " + extraCondition + ")"); + } else { + sqlString.append(" OR " + deptCondition); } } else if (DATA_SCOPE_SELF.equals(dataScope)) { diff --git a/lib/EmergencyService/zdxtEmergencyAuthService/src/main/java/com/zdxt/auth/framework/config/CorsFilter.java b/lib/EmergencyService/zdxtEmergencyAuthService/src/main/java/com/zdxt/auth/framework/config/CorsFilter.java index 57b0ccc3..17cab140 100644 --- a/lib/EmergencyService/zdxtEmergencyAuthService/src/main/java/com/zdxt/auth/framework/config/CorsFilter.java +++ b/lib/EmergencyService/zdxtEmergencyAuthService/src/main/java/com/zdxt/auth/framework/config/CorsFilter.java @@ -31,7 +31,7 @@ public class CorsFilter implements Filter { public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { //配置可信域名 - String[] authhosts = {"http://10.132.108.3:85","http://jdm.szssfj.cn","http://localhost:85","http://192.168.31.196:3301", + String[] authhosts = {"http://10.132.108.3:85","http://jdm.szssfj.cn","http://localhost:85","http://192.168.31.196:3301","http://172.16.20.74:85", "http://localhost:3301","http://10.132.108.3:81","http://10.132.108.3:85", "http://192.168.1.130:3301", "http://192.168.110.139:3301"}; String authost = ""; HttpServletRequest httprequest = (HttpServletRequest) request; diff --git a/lib/EmergencyService/zdxtEmergencyBootStart/src/main/resources/application-dev.yml b/lib/EmergencyService/zdxtEmergencyBootStart/src/main/resources/application-dev.yml index 0a0e2b30..3ed11e4b 100644 --- a/lib/EmergencyService/zdxtEmergencyBootStart/src/main/resources/application-dev.yml +++ b/lib/EmergencyService/zdxtEmergencyBootStart/src/main/resources/application-dev.yml @@ -3,12 +3,12 @@ spring: # redis配置 redis: database: 0 - host: 10.76.108.1 +# host: 10.76.108.1 +# port: 6379 +# password: zfjd@123 + host: 127.0.0.1 port: 6379 - password: zfjd@123 -# host: 127.0.0.1 -# port: 6380 -# password: + password: timeout: 6000ms # 连接超时时长(毫秒) lettuce: pool: @@ -33,7 +33,7 @@ xxl: allowed: - servernames: 10.76.108.1,10.76.108.3,10.132.108.3,jdm.szssfj.cn,58.250.157.161,127.0.0.1,localhost,192.168.110.35,192.168.110.41 + servernames: 10.76.108.1,10.76.108.3,10.132.108.3,jdm.szssfj.cn,58.250.157.161,127.0.0.1,localhost,192.168.110.35,192.168.110.41,172.16.20.74 excel: export: true diff --git a/lib/EmergencyService/zdxtEmergencyBootStart/src/main/resources/application.yml b/lib/EmergencyService/zdxtEmergencyBootStart/src/main/resources/application.yml index ddb55606..38d0b2dd 100644 --- a/lib/EmergencyService/zdxtEmergencyBootStart/src/main/resources/application.yml +++ b/lib/EmergencyService/zdxtEmergencyBootStart/src/main/resources/application.yml @@ -37,6 +37,16 @@ server: max-http-header-size: 4048576 # 设定Httppost数据大小 max-http-post-size: 102400000 + # 连接超时时间(毫秒),防止大数据量响应时管道断开 + connection-timeout: 120000 + # 最大请求体大小 -1为不限制 + max-swallow-size: -1 + # 开启Gzip压缩,减少大数据量响应体积,防止管道断开 + compression: + enabled: true + # 超过1KB的响应就进行压缩 + min-response-size: 1024 + mime-types: application/json,application/xml,text/html,text/xml,text/plain,application/javascript,text/css,application/vnd.ms-excel,application/octet-stream # 日志配置 logging: diff --git a/lib/EmergencyService/zdxtEmergencyBootStart/src/main/resources/logback.xml b/lib/EmergencyService/zdxtEmergencyBootStart/src/main/resources/logback.xml new file mode 100644 index 00000000..69f8ae5b --- /dev/null +++ b/lib/EmergencyService/zdxtEmergencyBootStart/src/main/resources/logback.xml @@ -0,0 +1,99 @@ + + + logback + + + + + + + + + + + + + + + + + + INFO + + + + %d{HH:mm:ss.SSS} %contextName [%thread] %-5level %logger{36} - %msg%n + UTF-8 + + + + + ${zdxtEmergencyBootStart.path} + + + ERROR + DENY + ACCEPT + + + + ${historyLogPath}/%d{yyyy-MM-dd}/zdxtEmergencyBootStart.zip + 180 + + + + %date %level [%thread] %logger{36} [%file : %line] %msg%n + UTF-8 + + + + + ${zdxtEmergencyBootStart.error.path} + + + ERROR + + + + ${historyLogPath}/%d{yyyy-MM-dd}/zdxtEmergencyBootStart-error.zip + 180 + + + %date %level [%thread] %logger{36} [%file : %line] %msg%n + UTF-8 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/lib/EmergencyService/zdxtLawEnforcementCodeService/src/main/java/com/zdxt/code/controller/EnforcementRegistrationController.java b/lib/EmergencyService/zdxtLawEnforcementCodeService/src/main/java/com/zdxt/code/controller/EnforcementRegistrationController.java index 9df01487..629b2d7c 100644 --- a/lib/EmergencyService/zdxtLawEnforcementCodeService/src/main/java/com/zdxt/code/controller/EnforcementRegistrationController.java +++ b/lib/EmergencyService/zdxtLawEnforcementCodeService/src/main/java/com/zdxt/code/controller/EnforcementRegistrationController.java @@ -789,14 +789,20 @@ public class EnforcementRegistrationController extends BaseController row.createCell(11).setCellValue(enforcementRegistrationDtos.get(i).getTotal()); } } + //先将workbook写入字节数组,获取长度后再写入响应流,防止大文件导出时管道断开 + java.io.ByteArrayOutputStream bos = new java.io.ByteArrayOutputStream(); + workbook.write(bos); + workbook.close(); + byte[] content = bos.toByteArray(); httpServletResponse.setCharacterEncoding("UTF-8"); httpServletResponse.setContentType("application/vnd.ms-excel"); httpServletResponse.setHeader("Content-disposition", "attachment;filename=" + fileName); -/* httpServletResponse.flushBuffer(); - workbook.write(httpServletResponse.getOutputStream());*/ + httpServletResponse.setContentLength(content.length); + httpServletResponse.setHeader("Connection", "keep-alive"); ServletOutputStream outputStream = httpServletResponse.getOutputStream(); - workbook.write(outputStream); - workbook.close(); + outputStream.write(content); + outputStream.flush(); + outputStream.close(); } @GetMapping("/zfjdm") @ResponseBody diff --git a/lib/EmergencyService/zdxtLawEnforcementCodeService/src/main/java/com/zdxt/code/service/impl/EnforcementCheckStatisticsImpl.java b/lib/EmergencyService/zdxtLawEnforcementCodeService/src/main/java/com/zdxt/code/service/impl/EnforcementCheckStatisticsImpl.java index 439ce039..728624fa 100644 --- a/lib/EmergencyService/zdxtLawEnforcementCodeService/src/main/java/com/zdxt/code/service/impl/EnforcementCheckStatisticsImpl.java +++ b/lib/EmergencyService/zdxtLawEnforcementCodeService/src/main/java/com/zdxt/code/service/impl/EnforcementCheckStatisticsImpl.java @@ -2547,13 +2547,19 @@ public class EnforcementCheckStatisticsImpl implements EnforcementCheckStatistic //表名:深圳市涉企行政登记情况(xxxx年xx月xx日至xxxx年xx月xx日) String fileName="深圳市涉企行政登记情况("+strStart+"至"+strEnd+").xls"; fileName = URLEncoder.encode(fileName, "UTF-8"); + //先将workbook写入字节数组,获取长度后再写入响应流,防止大文件导出时管道断开 + java.io.ByteArrayOutputStream bos = new java.io.ByteArrayOutputStream(); + wb.write(bos); + wb.close(); + byte[] content = bos.toByteArray(); response.setCharacterEncoding("UTF-8"); response.setContentType("application/vnd.ms-excel"); response.setHeader("Content-disposition", "attachment;filename=" + fileName); -/* response.flushBuffer(); - wb.write(response.getOutputStream());*/ + response.setContentLength(content.length); + response.setHeader("Connection", "keep-alive"); ServletOutputStream outputStream = response.getOutputStream(); - wb.write(outputStream); - wb.close(); + outputStream.write(content); + outputStream.flush(); + outputStream.close(); } } diff --git a/lib/EmergencyService/zdxtLawEnforcementCodeService/src/main/java/com/zdxt/code/service/impl/EnforcementRegistrationServiceImpl.java b/lib/EmergencyService/zdxtLawEnforcementCodeService/src/main/java/com/zdxt/code/service/impl/EnforcementRegistrationServiceImpl.java index 56203eac..b527937e 100644 --- a/lib/EmergencyService/zdxtLawEnforcementCodeService/src/main/java/com/zdxt/code/service/impl/EnforcementRegistrationServiceImpl.java +++ b/lib/EmergencyService/zdxtLawEnforcementCodeService/src/main/java/com/zdxt/code/service/impl/EnforcementRegistrationServiceImpl.java @@ -207,7 +207,7 @@ public class EnforcementRegistrationServiceImpl implements IEnforcementRegistrat @Override // @DataScope - @DataScope(deptField = "bureau_dept_id") + @DataScope(deptField = "bureau_dept_id", extraDeptField = "entrust_dept_id") public List selectEnforcementRegistrationListNew(EnforcementRegistration enforcementRegistration) { List enforcementRegistrations = @@ -216,7 +216,7 @@ public class EnforcementRegistrationServiceImpl implements IEnforcementRegistrat } @Override - @DataScope(deptField = "bureau_dept_id") + @DataScope(deptField = "bureau_dept_id", extraDeptField = "entrust_dept_id") public List selectEnforcementRegistrationList2(EnforcementRegistration enforcementRegistration) { List enforcementRegistrations = @@ -234,7 +234,7 @@ public class EnforcementRegistrationServiceImpl implements IEnforcementRegistrat } @Override - @DataScope(deptField = "bureau_dept_id") + @DataScope(deptField = "bureau_dept_id", extraDeptField = "entrust_dept_id") public List selectEnforcementRegistrationList1(EnforcementRegistration enforcementRegistration) { DateTimeFormatter str=DateTimeFormatter.ofPattern("yyyy-MM-dd"); @@ -294,7 +294,7 @@ public class EnforcementRegistrationServiceImpl implements IEnforcementRegistrat enforcementRegistrationMapper.selectEnforcementRegistrationList1(enforcementRegistration); return enforcementRegistrations; } - @DataScope(deptAlias = "r",userAlias = "r",deptField = "bureau_dept_id") + @DataScope(deptAlias = "r",userAlias = "r",deptField = "bureau_dept_id", extraDeptField = "entrust_dept_id") @Override public List selectEnforcementRegistrationAndAddressList(EnforcementRegistration enforcementRegistration) { List enforcementRegistrations = @@ -715,7 +715,7 @@ public class EnforcementRegistrationServiceImpl implements IEnforcementRegistrat enforcementRegistrationMapper.staticEnforcementRegistration(enforcementRegistrationDto); return enforcementRegistrationDtos; } - @DataScope(deptAlias = "r",userAlias = "r",deptField = "bureau_dept_id") + @DataScope(deptAlias = "r",userAlias = "r",deptField = "bureau_dept_id", extraDeptField = "entrust_dept_id") @Override public List staticEnforcementRegistrationLI(EnforcementRegistrationDto enforcementRegistrationDto) { if(enforcementRegistrationDto.getQy()!=null&&!"".equals(enforcementRegistrationDto.getQy())){ @@ -980,15 +980,21 @@ public class EnforcementRegistrationServiceImpl implements IEnforcementRegistrat } } + //先将workbook写入字节数组,获取长度后再写入响应流,防止大文件导出时管道断开 + java.io.ByteArrayOutputStream bos = new java.io.ByteArrayOutputStream(); + workbook.write(bos); + workbook.close(); + byte[] content = bos.toByteArray(); //设置流格式 response.setCharacterEncoding("UTF-8"); response.setContentType("application/vnd.ms-excel"); response.setHeader("Content-disposition", "attachment;filename=" + fileName); -/* response.flushBuffer(); - workbook.write(response.getOutputStream());*/ + response.setContentLength(content.length); + response.setHeader("Connection", "keep-alive"); ServletOutputStream outputStream = response.getOutputStream(); - workbook.write(outputStream); - workbook.close(); + outputStream.write(content); + outputStream.flush(); + outputStream.close(); } private List enforcementRegistrationListToExport(EnforcementRegistration enforcementRegistration){ if(enforcementRegistration.getQy()!=null&&!"".equals(enforcementRegistration.getQy())){ diff --git a/lib/EmergencyService/zdxtLawEnforcementCodeService/src/main/java/com/zdxt/code/service/impl/NonEnforcementRegistrationServiceImpl.java b/lib/EmergencyService/zdxtLawEnforcementCodeService/src/main/java/com/zdxt/code/service/impl/NonEnforcementRegistrationServiceImpl.java index 5039e647..64eb42ed 100644 --- a/lib/EmergencyService/zdxtLawEnforcementCodeService/src/main/java/com/zdxt/code/service/impl/NonEnforcementRegistrationServiceImpl.java +++ b/lib/EmergencyService/zdxtLawEnforcementCodeService/src/main/java/com/zdxt/code/service/impl/NonEnforcementRegistrationServiceImpl.java @@ -266,12 +266,20 @@ public class NonEnforcementRegistrationServiceImpl implements INonEnforcementReg dateStyle.setDataFormat(cellDataFormat.getFormat("yyyy\"年\"m\"月\"d\"日\" h:mm:ss")); setExcel(sheet,param); + //先将workbook写入字节数组,获取长度后再写入响应流,防止大文件导出时管道断开 + java.io.ByteArrayOutputStream bos = new java.io.ByteArrayOutputStream(); + workbook.write(bos); + workbook.close(); + byte[] content = bos.toByteArray(); response.setCharacterEncoding("UTF-8"); response.setContentType("application/vnd.ms-excel"); response.setHeader("Content-disposition", "attachment;filename=" + fileName); + response.setContentLength(content.length); + response.setHeader("Connection", "keep-alive"); ServletOutputStream outputStream = response.getOutputStream(); - workbook.write(outputStream); - workbook.close(); + outputStream.write(content); + outputStream.flush(); + outputStream.close(); }catch (Exception e){ e.printStackTrace(); } diff --git a/lib/EmergencyService/zdxtLawEnforcementCodeService/src/main/resources/mapper/EnforcementRegistrationMapper.xml b/lib/EmergencyService/zdxtLawEnforcementCodeService/src/main/resources/mapper/EnforcementRegistrationMapper.xml index 7fa9b695..9e02169b 100644 --- a/lib/EmergencyService/zdxtLawEnforcementCodeService/src/main/resources/mapper/EnforcementRegistrationMapper.xml +++ b/lib/EmergencyService/zdxtLawEnforcementCodeService/src/main/resources/mapper/EnforcementRegistrationMapper.xml @@ -573,6 +573,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" and DATE_FORMAT(r.enforcement_time,'%Y-%m-%d') <= STR_TO_DATE(#{endTime},'%Y-%m-%d') + + + AND YEAR(r.enforcement_time) = YEAR(NOW()) + and DATE_FORMAT(r.enforcement_time,'%Y-%m-%d') >= STR_TO_DATE(#{beginEnforcementTime},'%Y-%m-%d')