|
|
@ -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> 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); |
|
|
|
} |
|
|
|
} |
|
|
|