From e7df85b0e0cee722b73bd0a5a83ace5cbaa75c46 Mon Sep 17 00:00:00 2001 From: zhousq Date: Sat, 3 Aug 2024 11:45:12 +0800 Subject: [PATCH] =?UTF-8?q?-024-08-03=20=E5=A2=9E=E5=8A=A0=E6=97=A5?= =?UTF-8?q?=E5=BF=97=E7=9A=84=E5=88=A0=E9=99=A4=E6=97=B6=E6=98=AF=E5=90=A6?= =?UTF-8?q?=E5=90=8C=E6=AD=A5=E5=88=A0=E9=99=A4=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- win-admin/src/main/resources/application.yml | 5 ++- .../WinPrintTasksLogsController.java | 44 ++++++++++++------- .../print/mapper/WinPrintTasksLogsMapper.java | 2 +- .../service/IWinPrintTasksLogsService.java | 2 +- .../impl/WinPrintTasksLogsServiceImpl.java | 5 ++- .../mapper/print/WinPrintTasksLogsMapper.xml | 7 +++ 6 files changed, 45 insertions(+), 20 deletions(-) diff --git a/win-admin/src/main/resources/application.yml b/win-admin/src/main/resources/application.yml index f553d2f..11e3f11 100644 --- a/win-admin/src/main/resources/application.yml +++ b/win-admin/src/main/resources/application.yml @@ -17,8 +17,9 @@ win: path: template: /models print: /print - - + file: + print: + delSync: false #是否同步删除文件 # 开发环境配置 server: # 服务器的HTTP端口,默认为80 diff --git a/win-print/src/main/java/com/win/print/controller/WinPrintTasksLogsController.java b/win-print/src/main/java/com/win/print/controller/WinPrintTasksLogsController.java index a1ccddf..9cfddbc 100644 --- a/win-print/src/main/java/com/win/print/controller/WinPrintTasksLogsController.java +++ b/win-print/src/main/java/com/win/print/controller/WinPrintTasksLogsController.java @@ -5,6 +5,7 @@ import java.net.http.HttpResponse; import java.util.List; import cn.hutool.core.date.DateUtil; +import cn.hutool.core.io.FileUtil; import cn.hutool.core.io.IoUtil; import cn.hutool.core.util.ObjectUtil; import cn.hutool.http.HttpRequest; @@ -51,10 +52,14 @@ import javax.print.attribute.PrintRequestAttributeSet; @RequestMapping("/print/logmanager") public class WinPrintTasksLogsController extends BaseController { private String prefix = "print/logmanager"; + // @Resource +// IWinPrintSettingsService iSettingsService; @Resource - IWinPrintSettingsService iSettingsService; - @Autowired private IWinPrintTasksLogsService winPrintTasksLogsService; + @Value("${win.path.print}") + private String printFilepath; //生成的打印文件存储路径 + @Value("${win.file.print.delSync}") + private Boolean delSync; //删除日志记录时是否删除文件 @RequiresPermissions("print:logmanager:view") @GetMapping() @@ -116,10 +121,10 @@ public class WinPrintTasksLogsController extends BaseController { mmap.put("winPrintTasksLogs", winPrintTasksLogs); return prefix + "/edit"; } + @RequiresPermissions("print:logmanager:edit") @GetMapping("/detail/{id}") - public String detail(@PathVariable("id") Long id, ModelMap mmap) - { + public String detail(@PathVariable("id") Long id, ModelMap mmap) { mmap.put("name", "printLog"); mmap.put("printLog", winPrintTasksLogsService.selectWinPrintTasksLogsById(id)); return prefix + "/detail"; @@ -127,34 +132,34 @@ public class WinPrintTasksLogsController extends BaseController { @RequiresPermissions("print:logmanager:edit") @GetMapping("/printChange/{id}") - public String printChange(@PathVariable("id") Long id, ModelMap mmap) - { + public String printChange(@PathVariable("id") Long id, ModelMap mmap) { //mmap.put("name", "printer"); mmap.put("winPrintTasksLogs", winPrintTasksLogsService.selectWinPrintTasksLogsById(id)); return prefix + "/printChange"; } - @Value("${win.path.print}") - private String printFilepath; //生成的打印文件存储路径 + + @RequiresPermissions("print:logmanager:edit") @GetMapping("/print/{id}") @ResponseBody public AjaxResult print(@PathVariable("id") Long id) { WinPrintTasksLogs tasksLog = winPrintTasksLogsService.selectWinPrintTasksLogsById(id); - if (null!=tasksLog) { - tasksLog.setPrintTime(DateUtil.date()); - tasksLog.setTaskStatus("0"); + if (null != tasksLog) { + tasksLog.setPrintTime(DateUtil.date()); + tasksLog.setTaskStatus("0"); winPrintTasksLogsService.updateWinPrintTasksLogs(tasksLog); - return AjaxResult.success("打印已经发送到打印机!"); + return AjaxResult.success("打印已经发送到打印机!"); } else { return AjaxResult.error("打印失败!没有可以补打的记录!"); } } + @RequiresPermissions("print:logmanager:edit") @GetMapping("/doprint/{id}") @ResponseBody - public AjaxResult doprint(@RequestParam("id") Long id,@RequestParam("printer") String printer) { + public AjaxResult doprint(@RequestParam("id") Long id, @RequestParam("printer") String printer) { WinPrintTasksLogs tasksLog = winPrintTasksLogsService.selectWinPrintTasksLogsById(id); if (ObjectUtil.isNotEmpty(tasksLog)) { // try { @@ -173,7 +178,7 @@ public class WinPrintTasksLogsController extends BaseController { // } catch (PrintException e) { // return AjaxResult.error("打印失败!打印机错误!"); // } catch (IOException e) { - return AjaxResult.error("打印失败!文件IO错误!"); + return AjaxResult.error("打印失败!文件IO错误!"); // } } else { @@ -201,6 +206,15 @@ public class WinPrintTasksLogsController extends BaseController { @PostMapping("/remove") @ResponseBody public AjaxResult remove(String ids) { - return toAjax(winPrintTasksLogsService.deleteWinPrintTasksLogsByIds(ids)); + List winPrintTasksLogs = winPrintTasksLogsService.selectWinPrintTasksLogsByIds(ids); + int i = winPrintTasksLogsService.deleteWinPrintTasksLogsByIds(ids); + if (delSync) { + if (i > 0 && winPrintTasksLogs.size() > 0) { + winPrintTasksLogs.forEach(item -> { + FileUtil.del(DataUnitl.getWorkingDir(printFilepath) + "/" + item.getDataFile()); + }); + } + } + return toAjax(i); } } diff --git a/win-print/src/main/java/com/win/print/mapper/WinPrintTasksLogsMapper.java b/win-print/src/main/java/com/win/print/mapper/WinPrintTasksLogsMapper.java index efc0ec3..8a01e48 100644 --- a/win-print/src/main/java/com/win/print/mapper/WinPrintTasksLogsMapper.java +++ b/win-print/src/main/java/com/win/print/mapper/WinPrintTasksLogsMapper.java @@ -18,7 +18,7 @@ public interface WinPrintTasksLogsMapper * @return 打印任务日志 */ public WinPrintTasksLogs selectWinPrintTasksLogsById(Long id); - + public List selectWinPrintTasksLogsByIds(String[] ids); /** * 查询打印任务日志列表 * diff --git a/win-print/src/main/java/com/win/print/service/IWinPrintTasksLogsService.java b/win-print/src/main/java/com/win/print/service/IWinPrintTasksLogsService.java index 6ddf326..1972f13 100644 --- a/win-print/src/main/java/com/win/print/service/IWinPrintTasksLogsService.java +++ b/win-print/src/main/java/com/win/print/service/IWinPrintTasksLogsService.java @@ -44,7 +44,7 @@ public interface IWinPrintTasksLogsService * @return 结果 */ public int updateWinPrintTasksLogs(WinPrintTasksLogs winPrintTasksLogs); - + public List selectWinPrintTasksLogsByIds(String ids); /** * 批量删除打印任务日志 * diff --git a/win-print/src/main/java/com/win/print/service/impl/WinPrintTasksLogsServiceImpl.java b/win-print/src/main/java/com/win/print/service/impl/WinPrintTasksLogsServiceImpl.java index d1661c1..2c5d9c7 100644 --- a/win-print/src/main/java/com/win/print/service/impl/WinPrintTasksLogsServiceImpl.java +++ b/win-print/src/main/java/com/win/print/service/impl/WinPrintTasksLogsServiceImpl.java @@ -98,7 +98,10 @@ public class WinPrintTasksLogsServiceImpl implements IWinPrintTasksLogsService { return winPrintTasksLogsMapper.deleteWinPrintTasksLogsByIds(Convert.toStrArray(ids)); } - + @Override + public List selectWinPrintTasksLogsByIds(String ids){ + return winPrintTasksLogsMapper.selectWinPrintTasksLogsByIds(Convert.toStrArray(ids)); + } /** * 删除打印任务日志信息 * diff --git a/win-print/src/main/resources/mapper/print/WinPrintTasksLogsMapper.xml b/win-print/src/main/resources/mapper/print/WinPrintTasksLogsMapper.xml index 227f552..0fbb1c0 100644 --- a/win-print/src/main/resources/mapper/print/WinPrintTasksLogsMapper.xml +++ b/win-print/src/main/resources/mapper/print/WinPrintTasksLogsMapper.xml @@ -59,6 +59,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" where id = #{id} + insert into win_print_tasks_logs