diff --git a/src/main/java/com/company/project/controller/OptionController.java b/src/main/java/com/company/project/controller/OptionController.java index 2ae9285..985d91b 100644 --- a/src/main/java/com/company/project/controller/OptionController.java +++ b/src/main/java/com/company/project/controller/OptionController.java @@ -22,6 +22,7 @@ import io.swagger.annotations.ApiOperation; import lombok.extern.slf4j.Slf4j; import org.hibernate.validator.internal.util.StringHelper; +import org.springframework.beans.factory.annotation.Value; import org.springframework.util.CollectionUtils; import org.springframework.web.bind.annotation.*; import org.springframework.web.multipart.MultipartFile; @@ -30,7 +31,8 @@ import javax.annotation.Resource; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; -import java.io.File; +import java.io.*; +import java.net.URLEncoder; import java.util.ArrayList; import java.util.HashMap; import java.util.List; @@ -119,6 +121,61 @@ public class OptionController { } + + + @Value("${file.visitPath}") + private String visitPath; + + @Value("${file.path}") + private String filePath; + + @ApiOperation("文件下载") + @GetMapping("/download") + public void download(HttpServletResponse response,HttpServletRequest request) { + String path=request.getParameter("filePath"); + String filepath = filePath+path.replace(visitPath,""); + File file = new File(filepath); + if (!file.exists()) { + log.error("文件不存在:{}", filepath); + return; + } + try { + String fileName = file.getName(); + log.info("文件名:{}", fileName); + // 设置响应头 + response.reset(); + response.setCharacterEncoding("UTF-8"); + // 只设置一个Content-Type + response.setContentType("application/octet-stream"); + response.setHeader("Accept-Ranges", "bytes"); + // 正确处理文件名编码 + String encodedFileName = URLEncoder.encode(fileName, "UTF-8"); + // 处理空格编码问题 + encodedFileName = encodedFileName.replaceAll("\\+", "%20"); + + // 设置Content-Disposition头 + response.setHeader("Content-Disposition", "attachment;filename=\"" + encodedFileName + "\""); + + // 使用缓冲流提高性能 + try (InputStream inputStream = new BufferedInputStream(new FileInputStream(file)); + OutputStream outputStream = new BufferedOutputStream(response.getOutputStream())) { + + // 使用缓冲区复制文件,避免一次性读取整个文件到内存 + byte[] buffer = new byte[4096]; // 4KB缓冲区 + int bytesRead; + + while ((bytesRead = inputStream.read(buffer)) != -1) { + outputStream.write(buffer, 0, bytesRead); + } + + outputStream.flush(); + } + } catch (IOException e) { + log.error("文件下载失败", e); + } + } + + @PostMapping("/deleteInfo") @ApiOperation(value = "删除意见") @LogAnnotation(title = "意见收集", action = "删除意见") diff --git a/src/main/java/com/company/project/service/impl/OptionServiceImpl.java b/src/main/java/com/company/project/service/impl/OptionServiceImpl.java index bbc0158..a88cb75 100644 --- a/src/main/java/com/company/project/service/impl/OptionServiceImpl.java +++ b/src/main/java/com/company/project/service/impl/OptionServiceImpl.java @@ -124,16 +124,26 @@ public class OptionServiceImpl extends ServiceImpl implem return "任务不存在/已被删除"; }else{ if(!"1".equals(voo.getTaskType())){ - DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); - LocalDateTime startTime = LocalDateTime.parse(voo.getStartTime(), formatter); - LocalDateTime endTime = LocalDateTime.parse(voo.getEndTime(), formatter); - LocalDateTime now = LocalDateTime.now(); - if (now.isAfter(startTime) && now.isBefore(endTime)) { - - }else{ + DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); + LocalDateTime startTime = LocalDateTime.parse(voo.getStartTime(), formatter); + LocalDateTime endTime = LocalDateTime.parse(voo.getEndTime(), formatter); + LocalDateTime now = LocalDateTime.now(); + if (now.isAfter(startTime) && now.isBefore(endTime)) { + System.err.println("符合"); + }else if(now.isBefore(startTime) ) { + //当前时间比开始时间晚 + return "任务未开始"; + }else{ return "任务已过期"; - } - } + } + }else{ + if(StringHelper.isNullOrEmptyString(vo.getUserName())){ + throw new BusinessException("请填写用户名"); + } + if(StringHelper.isNullOrEmptyString(vo.getUserPhone())){ + throw new BusinessException("请填写手机号码!"); + } + } } String createTimes= DateUtils.format(new Date(), DateUtils.DATE_TIME_PATTERN); vo.setCreateTime(createTimes); @@ -172,6 +182,11 @@ public class OptionServiceImpl extends ServiceImpl implem return "添加失败"; } + + + + + @Override public Map getTaskDetails(TbTask vo) { Map map= Maps.newHashMap(); @@ -190,8 +205,10 @@ public class OptionServiceImpl extends ServiceImpl implem if("1".equals(voo.getTaskType())){ map.put("msg","请求成功"); map.put("data",voo); + map.put("type","1"); map.put("code","200"); }else{ + map.put("type","2"); DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); LocalDateTime startTime = LocalDateTime.parse(voo.getStartTime(), formatter); LocalDateTime endTime = LocalDateTime.parse(voo.getEndTime(), formatter); @@ -200,6 +217,10 @@ public class OptionServiceImpl extends ServiceImpl implem map.put("msg","请求成功"); map.put("data",voo); map.put("code","200"); + }else if(now.isBefore(startTime) ) { + map.put("msg","任务未开始"); + map.put("data",voo); + map.put("code","204"); }else{ map.put("msg","任务已过期"); map.put("data","任务已过期"); @@ -209,7 +230,6 @@ public class OptionServiceImpl extends ServiceImpl implem } } - return map; } @@ -236,11 +256,11 @@ public class OptionServiceImpl extends ServiceImpl implem List file=new ArrayList<>(); List returnList=new ArrayList<>(); if("1".equals(vo.getType())){ - file=mapper.getCodeFile(vo); - for (String path:file){ - path=visitPath+path; - returnList.add(path); - } + file=mapper.getCodeFile(vo); + for (String path:file){ + path=visitPath+path; + returnList.add(path); + } }else{ file=mapper.getUploadFile(vo); for (String path:file){ @@ -333,6 +353,15 @@ public class OptionServiceImpl extends ServiceImpl implem } + public static void main(String[] args) { + DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); + LocalDateTime startTime = LocalDateTime.parse("2025-04-04 12:00:00", formatter); + LocalDateTime endTime = LocalDateTime.parse("2025-04-05 12:00:00", formatter); + LocalDateTime now = LocalDateTime.now(); + System.err.println(now.isBefore(startTime)); + + + } diff --git a/src/main/java/com/company/project/utils/IDUtils.java b/src/main/java/com/company/project/utils/IDUtils.java index a2b1f7c..0551975 100644 --- a/src/main/java/com/company/project/utils/IDUtils.java +++ b/src/main/java/com/company/project/utils/IDUtils.java @@ -1,7 +1,7 @@ package com.company.project.utils; public class IDUtils { - private static byte[] lock = new byte[0]; + private static final byte[] lock = new byte[0]; // 位数,默认是8位 private final static long w = 100000000; diff --git a/src/main/resources/application-dev.yml b/src/main/resources/application-dev.yml index db1de1e..0355c53 100644 --- a/src/main/resources/application-dev.yml +++ b/src/main/resources/application-dev.yml @@ -1,5 +1,9 @@ -# 开发环境配置 +# 生产环境配置 spring: + servlet: + multipart: + max-file-size: -1 + max-request-size: -1 thymeleaf: cache: false datasource: @@ -7,10 +11,10 @@ spring: primary: master #设置默认的数据源或者数据源组,默认值即为master datasource: master: - username: mroot - password: bonus@admin123 + username: root + password: Bonus@admin123! driver-class-name: com.mysql.cj.jdbc.Driver - url: jdbc:mysql://localhost:3306/company_project?useUnicode=true&useSSL=false&characterEncoding=utf8&serverTimezone=GMT%2b8 + url: jdbc:mysql://192.168.0.14:4417/company_project?useUnicode=true&useSSL=false&characterEncoding=utf8&serverTimezone=GMT%2b8 oracle: username: root password: 123456 @@ -23,6 +27,14 @@ spring: url: jdbc:sqlserver://localhost:1433;databaseName=company_project file: - #文件上传目录 绝对路径 末尾不需要加 / - path: D:/files #windows - #path: /data/files #linux + #文件上传目录 绝对路径 末尾请加 / + path: F:/files/ #windows + #visitPath: http://192.168.0.38:21666/manager/files/ + visitPath: http://192.168.0.38:21666/manager/files/ + #path: /home/options/file/ + #linux +knife4j: + production: true #生成环境禁用查看文档 + +app: + url: http://192.168.0.14:1999/option/#key= \ No newline at end of file diff --git a/src/main/resources/application-prod.yml b/src/main/resources/application-prod.yml index 66f0761..f42fd98 100644 --- a/src/main/resources/application-prod.yml +++ b/src/main/resources/application-prod.yml @@ -1,5 +1,9 @@ # 生产环境配置 spring: + servlet: + multipart: + max-file-size: -1 + max-request-size: -1 thymeleaf: cache: false datasource: diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index b44af86..4689a3a 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -6,7 +6,7 @@ server: spring: profiles: - active: prod + active: dev mvc: throw-exception-if-no-handler-found: true resources: diff --git a/src/main/resources/mapper/mysql/OptionMapper.xml b/src/main/resources/mapper/mysql/OptionMapper.xml index c8a990b..8af7cf8 100644 --- a/src/main/resources/mapper/mysql/OptionMapper.xml +++ b/src/main/resources/mapper/mysql/OptionMapper.xml @@ -66,7 +66,7 @@ select tt.id id, tt.task_type taskType, tt.task_title taskTitle , tt.task_describe taskDescribe, tt.start_time startTime, tt.end_time endTime, tt.create_user , DATE_FORMAT(tt.create_time,'%Y-%m-%d') createTime, tt.file_path, tt.task_time taskTime,su.username createUser, - CASE tt.task_type WHEN 1 THEN '监督类' ELSE '巡查类' END type + CASE tt.task_type WHEN 1 THEN '监督类' ELSE '巡察类' END type from tb_task tt left join sys_user su ON su.id=tt.create_user @@ -119,7 +119,7 @@ tt.id id, tt.task_type taskType, tt.task_title taskTitle , tt.task_describe taskDescribe, tt.start_time startTime, tt.end_time endTime, tt.create_user , DATE_FORMAT(tt.create_time,'%Y-%m-%d') createTime, tt.file_path, tt.task_time taskTime,su.username createUser, - CASE tt.task_type WHEN 1 THEN '监督类' ELSE '巡查类' END type + CASE tt.task_type WHEN 1 THEN '监督类' ELSE '巡察类' END type from tb_task tt left join (SELECT @rownum:=0) r on 1=1 left join sys_user su ON su.id=tt.create_user diff --git a/src/main/resources/static/image/excel.jpg b/src/main/resources/static/image/excel.jpg new file mode 100644 index 0000000..df55135 Binary files /dev/null and b/src/main/resources/static/image/excel.jpg differ diff --git a/src/main/resources/static/image/pdf.png b/src/main/resources/static/image/pdf.png new file mode 100644 index 0000000..59fd95c Binary files /dev/null and b/src/main/resources/static/image/pdf.png differ diff --git a/src/main/resources/static/image/text.png b/src/main/resources/static/image/text.png new file mode 100644 index 0000000..e8efd00 Binary files /dev/null and b/src/main/resources/static/image/text.png differ diff --git a/src/main/resources/static/image/world.jpg b/src/main/resources/static/image/world.jpg new file mode 100644 index 0000000..46c9b18 Binary files /dev/null and b/src/main/resources/static/image/world.jpg differ diff --git a/src/main/resources/templates/options/option_list.html b/src/main/resources/templates/options/option_list.html index dbbe196..cabad3f 100644 --- a/src/main/resources/templates/options/option_list.html +++ b/src/main/resources/templates/options/option_list.html @@ -10,12 +10,12 @@
-
+
- @@ -23,7 +23,7 @@
- +
@@ -58,21 +58,21 @@
- +
- +
- +
@@ -130,7 +130,7 @@ -
- -
-
- -
-
- -
-
- -
+ + + + + + + + + + + + + + + + +
diff --git a/src/main/resources/templates/users/update_password.html b/src/main/resources/templates/users/update_password.html index d8d1578..b1d1cf2 100644 --- a/src/main/resources/templates/users/update_password.html +++ b/src/main/resources/templates/users/update_password.html @@ -56,8 +56,8 @@ }) form.on('submit(baseSubmit)', function (data) { CoreUtil.sendPut(ctx + "sys/user/pwd", data.field, function (res) { - layer.msg("密码已经变更请重新登录", {time: 2000}, function () { - top.window.location.href = "/index/login"; + layer.msg("修改成功", {time: 2000}, function () { + top.window.location.href = "/manager/index/login"; }); }); diff --git a/src/main/resources/templates/users/user_list.html b/src/main/resources/templates/users/user_list.html index 0f3de6e..42265f4 100644 --- a/src/main/resources/templates/users/user_list.html +++ b/src/main/resources/templates/users/user_list.html @@ -58,23 +58,23 @@
-
- -
-
- -
-
- -
-
- -
+ + + + + + + + + + + + + + + + +
@@ -249,6 +249,10 @@ $(getData).each(function (index, item) { roleIds.push(item.value); }); + if(roleIds.length>1){ + return layer.msg("一个用户只能分配一个角色,请重新选择"); + } + } CoreUtil.sendPut(ctx + "sys/user/roles/" + data.id, roleIds, function (res) { layer.msg(res.msg);