| | |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.fzzy.igds.domain.FileInfo; |
| | | import com.fzzy.igds.mapper.FileMapper; |
| | | import com.fzzy.igds.utils.Base64Util; |
| | | import com.fzzy.igds.utils.ContextUtil; |
| | | import com.ruoyi.common.config.FrameworkConfig; |
| | | import org.apache.commons.lang3.time.DateFormatUtils; |
| | |
| | | } |
| | | |
| | | /** |
| | | * |
| | | * @param id |
| | | */ |
| | | public void delFile(String id) { |
| | | fileMapper.deleteById(id); |
| | | } |
| | | |
| | | /** |
| | | * 获取出入库文件路径 |
| | | * 根据类型获取文件路径 |
| | | * @param pathTag |
| | | * @return |
| | | */ |
| | |
| | | if(StringUtils.isBlank(pathTag)){ |
| | | pathTag = "COMMON"; |
| | | } |
| | | if("EVENT".equals(pathTag)) return getEventFilePath(); |
| | | if("SNAP".equals(pathTag)) return getSnapFilePath(); |
| | | if("INOUT".equals(pathTag)) return getInoutFilePath(); |
| | | if("PATROL".equals(pathTag)) return getPatrolFilePath(); |
| | | if("DEPT".equals(pathTag)) return getDeptFilePath(); |
| | | if("TEMP".equals(pathTag)) return getTempFilePath(); |
| | | if("CONF".equals(pathTag)) return getConfPath(); |
| | | if("TEMPLATE".equals(pathTag)) return getTemplateFilePath(); |
| | | if("WORD".equals(pathTag)) return getWordPath(); |
| | | |
| | | return getCommonFilePath(); |
| | | } |
| | | |
| | | /** |
| | | * 获取出入库文件路径 |
| | | * 获取事件文件路径 |
| | | * @return |
| | | */ |
| | | public String getEventFilePath() { |
| | | String basePath = FrameworkConfig.getProfile() + "EVENT/" + DateFormatUtils.format(new Date(), "yyyyMM") + "/"; |
| | | File file = new File(basePath); |
| | | if (!file.exists()) { |
| | | file.mkdirs(); |
| | | } |
| | | return basePath; |
| | | } |
| | | |
| | | /** |
| | | * 获取抓拍文件路径 |
| | | * @return |
| | | */ |
| | | public String getSnapFilePath() { |
| | | String basePath = FrameworkConfig.getProfile() + "SNAP/" + DateFormatUtils.format(new Date(), "yyyyMM") + "/"; |
| | | File file = new File(basePath); |
| | | if (!file.exists()) { |
| | | file.mkdirs(); |
| | | } |
| | | return basePath; |
| | | } |
| | | |
| | | /** |
| | | * 获取巡检文件路径 |
| | | * @return |
| | | */ |
| | | public String getPatrolFilePath() { |
| | | String basePath = FrameworkConfig.getProfile() + "INOUT/" + DateFormatUtils.format(new Date(), "yyyyMM") + "/"; |
| | | String basePath = FrameworkConfig.getProfile() + "PATROL/" + DateFormatUtils.format(new Date(), "yyyyMM") + "/"; |
| | | File file = new File(basePath); |
| | | if (!file.exists()) { |
| | | file.mkdirs(); |
| | |
| | | |
| | | /** |
| | | * 获取临时路径 |
| | | * @param companyId |
| | | * @return |
| | | */ |
| | | public String getTempFilePath(String companyId) { |
| | | public String getTempFilePath() { |
| | | |
| | | String basePath = FrameworkConfig.getProfile() + "TEMP/"; |
| | | if (org.apache.commons.lang3.StringUtils.isNotEmpty(companyId)) { |
| | | basePath += companyId + "/"; |
| | | } |
| | | File file = new File(basePath); |
| | | if (!file.exists()) { |
| | | file.mkdirs(); |
| | |
| | | file.mkdirs(); |
| | | } |
| | | return basePath; |
| | | } |
| | | |
| | | /** |
| | | * 获取模板路径:所有模板统一放在TEMPLATE/目录下 |
| | | * @return |
| | | */ |
| | | public String getTemplateFilePath() { |
| | | String basePath = FrameworkConfig.getProfile() + "TEMPLATE/"; |
| | | File file = new File(basePath); |
| | | if (!file.exists()) { |
| | | file.mkdirs(); |
| | | } |
| | | return basePath; |
| | | } |
| | | |
| | | /** |
| | | * 获取word路径 |
| | | * @return |
| | | */ |
| | | public String getWordPath() { |
| | | |
| | | String basePath = FrameworkConfig.getProfile() + "WORD/"; |
| | | File file = new File(basePath); |
| | | if (!file.exists()) { |
| | | file.mkdirs(); |
| | | } |
| | | return basePath; |
| | | } |
| | | |
| | | /** |
| | | * base64转图片保存 |
| | | * @param filePath |
| | | * @param imgData |
| | | */ |
| | | public void baseImg2Disk(String filePath, String imgData) { |
| | | Base64Util.generateImage(imgData, filePath); |
| | | } |
| | | |
| | | /** |
| | |
| | | return path; |
| | | } |
| | | |
| | | /** |
| | | * 获取模板路径:所有模板统一放在TEMPLATE/目录下 |
| | | * @return |
| | | */ |
| | | public String getTemplateFilePath() { |
| | | String basePath = FrameworkConfig.getProfile() + "TEMPLATE/"; |
| | | File file = new File(basePath); |
| | | if (!file.exists()) { |
| | | file.mkdirs(); |
| | | } |
| | | return basePath; |
| | | } |
| | | |
| | | /** |
| | | * 获取word路径 |
| | | * @param deptId |
| | | * @return |
| | | */ |
| | | public String getWordPath(String deptId) { |
| | | if(StringUtils.isBlank(deptId)){ |
| | | deptId = "0000"; |
| | | } |
| | | String basePath = FrameworkConfig.getProfile() + deptId + "/WORD/"; |
| | | File file = new File(basePath); |
| | | if (!file.exists()) { |
| | | file.mkdirs(); |
| | | } |
| | | return basePath; |
| | | } |
| | | } |