| | |
| | | @Component("DeleteWorkOrderImgTask") |
| | | public class DeleteWorkOrderImgTask { |
| | | private final ISysConfigService configService; |
| | | |
| | | public static String imgSaveBasePath = "/opt/zgyw/uploadPath"; |
| | | public void delWorkOrderImg() { |
| | | |
| | | String basePath = PlatformConfig.getUploadPath(); |
| | | log.info("开始删除工单照片"); |
| | | log.info("删除主路径:{}",basePath); // /opt/zgyw/uploadPath |
| | | log.info("删除主路径:{}",basePath); // /opt/zgyw/uploadPath/upload |
| | | log.info("静态设置地址:{}",imgSaveBasePath); |
| | | //字典查询需要删除时间在几个月前的照片 |
| | | String dictLabel = configService.selectConfigByKey("del.workorder.time"); |
| | | log.info("清理时间:{}月",dictLabel); |
| | | if (StringUtils.isEmpty(dictLabel)) { |
| | | log.info("未设置删除时间范围");; |
| | | dictLabel = "6"; |
| | | log.info("默认6月前的图片"); |
| | | } |
| | | log.info("默认6月前的图片"); |
| | | |
| | | //获得当前时间 |
| | | LocalDate nowDate = LocalDate.now(); |
| | | DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd"); |
| | | //计算 ? 月前的日期 ? 用字典存入系统中 |
| | | LocalDate sixMonthAgo = nowDate.minusMonths(Long.parseLong(dictLabel)); |
| | | //读取服务器中的文件夹名 |
| | | File directory = new File(basePath); |
| | | File directory = new File(imgSaveBasePath); |
| | | //检测路径存在 并且是一个目录 |
| | | if (directory.exists() && directory.isDirectory()) { |
| | | //获得 目录集合 |